From f03bd54d9eaaa69e0080ca2c9b3b6401cbeffb62 Mon Sep 17 00:00:00 2001 From: bailu1992 Date: Sat, 7 Jun 2025 23:33:33 +0800 Subject: [PATCH] Added sample code Signed-off-by: bailu1992 --- README.md | 0 .../Ability/AbilityFeature/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Ability/AbilityFeature/README_zh.md | 196 +- .../AbilityFeature/build-profile.json5 | 86 +- .../AbilityFeature/entry/build-profile.json5 | 56 +- .../AbilityFeature/entry/oh-package.json5 | 20 +- .../characteroperation/CharacterOperation.ets | 292 +- .../main/ets/entryability/EntryAbility.ets | 122 +- .../src/main/ets/newability/NewAbility.ets | 118 +- .../entry/src/main/ets/pages/New.ets | 114 +- .../entry/src/main/ets/util/Logger.ets | 96 +- .../entry/src/main/module.json5 | 122 +- .../main/resources/base/element/color.json | 46 +- .../main/resources/base/element/float.json | 14 +- .../entry/src/ohosTest/ets/util/Logger.ts | 96 +- .../entry/src/ohosTest/module.json5 | 102 +- .../AbilityFeature/hvigor/hvigor-config.json5 | 10 +- .../Ability/AbilityFeature/oh-package.json5 | 54 +- .../Ability/AbilityFeature/ohosTest.md | 30 +- .../Ability/AbilityRuntime/AppScope/app.json5 | 56 +- .../resources/base/element/string.json | 16 +- .../Ability/AbilityRuntime/README_zh.md | 408 +- .../AbilityRuntime/build-profile.json5 | 100 +- .../AbilityRuntime/entry/build-profile.json5 | 82 +- .../AbilityRuntime/entry/oh-package.json5 | 48 +- .../AbilityLifecycleCallback.ets | 478 +- .../src/main/ets/abilitypages/AppManager.ets | 696 +- .../ets/abilitypages/ApplicationContext.ets | 448 +- .../main/ets/abilitypages/DataUriUtils.ets | 394 +- .../main/ets/abilitypages/ErrorManager.ets | 388 +- .../ets/abilitypages/UIAbilityContext.ets | 224 +- .../src/main/ets/abilitypages/WantAgent.ets | 1010 +- .../main/ets/entryability/EntryAbility.ets | 176 +- .../entrybackupability/EntryBackupAbility.ets | 22 +- .../entry/src/main/module.json5 | 172 +- .../main/resources/base/element/color.json | 30 +- .../resources/base/profile/backup_config.json | 4 +- .../entry/src/ohosTest/module.json5 | 52 +- .../AbilityRuntime/hvigor/hvigor-config.json5 | 36 +- .../Ability/AbilityRuntime/oh-package.json5 | 48 +- .../Ability/UniversalLink/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Ability/UniversalLink/README_zh.md | 132 +- .../Ability/UniversalLink/build-profile.json5 | 102 +- .../UniversalLink/entry/build-profile.json5 | 84 +- .../UniversalLink/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 176 +- .../main/ets/entryability/OpenLinkAbility.ets | 170 +- .../entrybackupability/EntryBackupAbility.ets | 22 +- .../src/main/ets/pages/UniversalLinkIndex.ets | 76 +- .../UniversalLink/entry/src/main/module.json5 | 192 +- .../main/resources/base/element/color.json | 30 +- .../resources/base/profile/backup_config.json | 4 +- .../entry/src/ohosTest/module.json5 | 54 +- .../UniversalLink/hvigor/hvigor-config.json5 | 74 +- .../Ability/UniversalLink/oh-package.json5 | 50 +- .../BundleManagement/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../BundleManagement/README_zh.md | 0 .../BundleManagement/build-profile.json5 | 134 +- .../entry/build-profile.json5 | 54 +- .../BundleManagement/entry/hvigorfile.ts | 0 .../BundleManagement/entry/oh-package.json5 | 26 +- .../src/main/ets/entryability/EntryAbility.ts | 158 +- .../src/main/ets/newability/NewAbility.ts | 118 +- .../ets/newuiextability/NewUIExtAbility.ets | 82 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/NewPage.ets | 116 +- .../entry/src/main/module.json5 | 202 +- .../main/resources/base/element/color.json | 38 +- .../main/resources/base/element/string.json | 0 .../src/main/resources/base/media/ic_back.svg | 0 .../src/main/resources/base/media/icon.png | Bin .../main/resources/base/media/pic_empty.svg | 0 .../resources/base/profile/main_pages.json | 0 .../base/profile/shortcuts_config.json | 0 .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/testability/TestAbility.ets | 0 .../ohosTest/ets/testability/pages/Index.ets | 0 .../ets/testrunner/OpenHarmonyTestRunner.ts | 0 .../entry/src/ohosTest/module.json5 | 102 +- .../resources/base/element/color.json | 0 .../resources/base/element/string.json | 0 .../ohosTest/resources/base/media/icon.png | Bin .../resources/base/profile/test_pages.json | 0 .../resources/en_US/element/string.json | 0 .../resources/zh_CN/element/string.json | 0 .../hvigor/hvigor-config.json5 | 40 +- .../BundleManagement/hvigor/hvigor-wrapper.js | 0 .../BundleManagement/hvigorfile.ts | 0 .../BundleManager/BundleManagement/hvigorw | 0 .../BundleManagement/hvigorw.bat | 0 .../libraryOverlay/build-profile.json5 | 48 +- .../libraryOverlay/hvigorfile.ts | 0 .../libraryOverlay/oh-package.json5 | 20 +- .../libraryOverlay/src/main/ets/Index.ets | 30 +- .../src/main/ets/pages/Index.ets | 0 .../libraryOverlay/src/main/ets/utils/Calc.ts | 0 .../libraryOverlay/src/main/module.json5 | 56 +- .../main/resources/base/element/color.json | 0 .../main/resources/base/element/string.json | 22 +- .../src/main/resources/base/media/icon.png | Bin .../main/resources/base/media/setting.jpeg | Bin .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../libraryRuntimeOverlay/build-profile.json5 | 48 +- .../libraryRuntimeOverlay/hvigorfile.ts | 0 .../libraryRuntimeOverlay/oh-package.json5 | 20 +- .../src/main/ets/Index.ets | 30 +- .../src/main/ets/pages/Index.ets | 0 .../src/main/ets/utils/Calc.ts | 0 .../src/main/module.json5 | 56 +- .../main/resources/base/element/color.json | 0 .../main/resources/base/element/string.json | 22 +- .../src/main/resources/base/media/icon.png | Bin .../main/resources/base/media/setting.jpeg | Bin .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../BundleManagement/oh-package.json5 | 24 +- .../BundleManagement/ohosTest.md | 0 .../sceenshots/device/Scene-directory.png | Bin .../sceenshots/device/snapshot_directory.png | Bin .../DynamicRouter/AppScope/app.json5 | 48 +- .../resources/base/element/string.json | 16 +- .../DynamicRouter/README_zh.md | 172 +- .../DynamicRouter/RouterModule/Index.ets | 28 +- .../RouterModule/build-profile.json5 | 48 +- .../RouterModule/oh-package.json5 | 48 +- .../src/main/ets/utils/RouterModule.ets | 144 +- .../RouterModule/src/main/module.json5 | 46 +- .../DynamicRouter/build-profile.json5 | 104 +- .../DynamicRouter/entry/build-profile.json5 | 72 +- .../DynamicRouter/entry/oh-package-lock.json5 | 84 +- .../DynamicRouter/entry/oh-package.json5 | 56 +- .../src/main/ets/entryability/EntryAbility.ts | 114 +- .../DynamicRouter/entry/src/main/module.json5 | 100 +- .../main/resources/base/element/color.json | 14 +- .../entry/src/ohosTest/module.json5 | 102 +- .../DynamicRouter/harA/Index.ets | 60 +- .../DynamicRouter/harA/build-profile.json5 | 48 +- .../DynamicRouter/harA/oh-package-lock.json5 | 52 +- .../DynamicRouter/harA/oh-package.json5 | 52 +- .../main/ets/components/mainpage/page1.ets | 130 +- .../main/ets/components/mainpage/page2.ets | 128 +- .../main/ets/components/mainpage/page3.ets | 128 +- .../DynamicRouter/harA/src/main/module.json5 | 48 +- .../DynamicRouter/harB/Index.ets | 60 +- .../DynamicRouter/harB/build-profile.json5 | 50 +- .../DynamicRouter/harB/oh-package-lock.json5 | 52 +- .../DynamicRouter/harB/oh-package.json5 | 52 +- .../main/ets/components/mainpage/page1.ets | 130 +- .../main/ets/components/mainpage/page2.ets | 130 +- .../main/ets/components/mainpage/page3.ets | 130 +- .../DynamicRouter/harB/src/main/module.json5 | 48 +- .../DynamicRouter/hvigor/hvigor-config.json5 | 10 +- .../DynamicRouter/oh-package.json5 | 52 +- .../DynamicRouter/ohosTest.md | 18 +- .../MultipleFilesDownload/AppScope/app.json5 | 48 +- .../resources/base/element/string.json | 16 +- .../MultipleFilesDownload/README.md | 400 +- .../MultipleFilesDownload/build-profile.json5 | 118 +- .../multiplefilesdownload/oh-package.json5 | 44 +- .../entry/build-profile.json5 | 84 +- .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../resources/base/profile/backup_config.json | 4 +- .../main/resources/dark/element/color.json | 14 +- .../entry/src/ohosTest/module.json5 | 54 +- .../hvigor/hvigor-config.json5 | 72 +- .../MultipleFilesDownload/oh-package.json5 | 50 +- .../MultipleFilesDownload/ohosTest.md | 26 +- .../UploadAndDownLoad/README_zh.md | 302 +- .../UploadAndDownLoad/build-profile.json5 | 94 +- .../entry/src/main/ets/pages/CertLock.ets | 382 +- .../entry/src/main/ets/pages/Download.ets | 862 +- .../entry/src/main/ets/pages/Index.ets | 308 +- .../entry/src/main/ets/pages/Upload.ets | 490 +- .../main/resources/base/element/color.json | 86 +- .../main/resources/base/element/string.json | 310 +- .../resources/base/profile/main_pages.json | 16 +- .../base/profile/network_config.json | 46 +- .../main/resources/en_US/element/string.json | 302 +- .../main/resources/zh_CN/element/string.json | 302 +- .../src/main/ets/download/RequestDownload.ets | 458 +- .../src/main/ets/upload/RequestUpload.ets | 612 +- .../src/main/ets/utils/Constants.ets | 46 +- .../src/main/ets/utils/UrlUtils.ets | 94 +- .../hvigor/hvigor-config.json5 | 6 - .../hvigor/hvigor-wrapper.js | 1 - .../Connectivity/VPN/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Connectivity/VPN/README_zh.md | 170 +- ...50\344\276\213\346\212\245\345\221\212.md" | 18 +- .../Connectivity/VPN/build-profile.json5 | 110 +- .../VPN/entry/build-profile.json5 | 76 +- .../Connectivity/VPN/entry/oh-package.json5 | 50 +- .../VPN/entry/src/main/cpp/CMakeLists.txt | 40 +- .../src/main/cpp/types/libentry/index.d.ts | 38 +- .../main/cpp/types/libentry/oh-package.json5 | 10 +- .../VPN/entry/src/main/cpp/vpn_client.cpp | 500 +- .../src/main/ets/entryability/EntryAbility.ts | 116 +- .../VPN/entry/src/main/ets/model/Logger.ets | 78 +- .../VPN/entry/src/main/ets/pages/Index.ets | 108 +- .../VPN/entry/src/main/ets/pages/StartVpn.ets | 366 +- .../VPN/entry/src/main/ets/pages/StopVpn.ets | 158 +- .../VPN/entry/src/main/module.json5 | 112 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 62 +- .../resources/base/profile/main_pages.json | 14 +- .../main/resources/en_US/element/string.json | 62 +- .../main/resources/zh_CN/element/string.json | 62 +- .../src/ohosTest/ets/test/Ability.test.ets | 466 +- .../VPN/entry/src/ohosTest/module.json5 | 104 +- .../VPN/hvigor/hvigor-config.json5 | 64 +- .../Connectivity/VPN/oh-package.json5 | 56 +- code/BasicFeature/DFX/AppRecovery/.gitignore | 24 +- .../DFX/AppRecovery/AppScope/app.json5 | 52 +- .../resources/base/element/string.json | 16 +- .../BasicFeature/DFX/AppRecovery/README_zh.md | 256 +- .../DFX/AppRecovery/build-profile.json5 | 84 +- .../DFX/AppRecovery/entry/.gitignore | 6 +- .../DFX/AppRecovery/entry/build-profile.json5 | 74 +- .../DFX/AppRecovery/entry/hvigorfile.ts | 4 +- .../DFX/AppRecovery/entry/oh-package.json5 | 46 +- .../entry/src/main/cpp/CMakeLists.txt | 46 +- .../AppRecovery/entry/src/main/cpp/hello.cpp | 102 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../src/main/ets/ability/EntryAbility.ets | 186 +- .../src/main/ets/ability/RecoveryAbility.ets | 142 +- .../src/main/ets/ability/SecondAbility.ets | 180 +- .../entry/src/main/ets/app/MyAbilityStage.ets | 50 +- .../src/main/ets/common/CurActiveAbility.ts | 70 +- .../entry/src/main/ets/common/ResUtil.ts | 58 +- .../src/main/ets/pages/FaultTriggerPage.ets | 630 +- .../entry/src/main/ets/pages/Index.ets | 186 +- .../entry/src/main/ets/pages/RecoveryPage.ets | 224 +- .../AppRecovery/entry/src/main/module.json5 | 146 +- .../main/resources/base/element/color.json | 54 +- .../main/resources/base/element/string.json | 238 +- .../resources/base/profile/main_pages.json | 14 +- .../main/resources/en_US/element/string.json | 238 +- .../main/resources/zh_CN/element/string.json | 238 +- .../ets/TestRunner/OpenHarmonyTestRunner.ts | 168 +- .../src/ohosTest/ets/test/Ability.test.ets | 168 +- .../entry/src/ohosTest/ets/test/List.test.ets | 38 +- .../ohosTest/ets/testability/TestAbility.ets | 118 +- .../ohosTest/ets/testability/pages/Index.ets | 98 +- .../entry/src/ohosTest/module.json5 | 102 +- .../resources/base/element/color.json | 14 +- .../resources/base/element/string.json | 30 +- .../resources/base/profile/test_pages.json | 10 +- .../DFX/AppRecovery/hvigorfile.ts | 2 +- .../DFX/AppRecovery/oh-package.json5 | 50 +- .../UniformTypeDescriptor/UTDType/.gitignore | 0 .../UTDType/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../UTDType/README_zh.md | 0 .../UTDType/build-profile.json5 | 86 +- .../UTDType/entry/.gitignore | 0 .../UTDType/entry/build-profile.json5 | 0 .../UTDType/entry/hvigorfile.js | 0 .../UTDType/entry/oh-package.json5 | 0 .../src/main/ets/entryability/EntryAbility.ts | 112 +- .../entry/src/main/ets/pages/Index.ets | 0 .../src/main/ets/pages/displayMediaFile.ets | 324 +- .../src/main/ets/pages/selectMediaType.ets | 528 +- .../UTDType/entry/src/main/ets/util/Logger.ts | 0 .../UTDType/entry/src/main/module.json5 | 0 .../main/resources/base/element/color.json | 0 .../main/resources/base/element/string.json | 0 .../src/main/resources/base/media/file.png | Bin .../media/ic_select_option_collection.png | Bin .../src/main/resources/base/media/icon.png | Bin .../src/main/resources/base/media/image.png | Bin .../src/main/resources/base/media/myAudio.png | Bin .../resources/base/media/utdType_back.svg | 0 .../src/main/resources/base/media/video.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/main/resources/en/element/string.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/zh/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../ets/Application/TestAbilityStage.ts | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/testability/TestAbility.ets | 0 .../ohosTest/ets/testability/pages/Index.ets | 0 .../ets/testrunner/OpenHarmonyTestRunner.ts | 0 .../entry/src/ohosTest/ets/util/Logger.ts | 0 .../UTDType/entry/src/ohosTest/module.json5 | 0 .../resources/base/element/color.json | 0 .../resources/base/element/string.json | 0 .../ohosTest/resources/base/media/icon.png | Bin .../resources/base/profile/test_pages.json | 0 .../ohosTest/resources/en/element/string.json | 0 .../ohosTest/resources/zh/element/string.json | 0 .../UTDType/hvigor/hvigor-config.json5 | 10 +- .../UTDType/hvigor/hvigor-wrapper.js | 0 .../UniformTypeDescriptor/UTDType/hvigorw | 0 .../UniformTypeDescriptor/UTDType/hvigorw.bat | 0 .../UTDType/oh-package.json5 | 24 +- .../UniformTypeDescriptor/UTDType/ohosTest.md | 0 .../UTDType/screenshots/display_file.png | Bin .../UTDType/screenshots/first.png | Bin .../UTDType/screenshots/select_type.png | Bin .../Sensor/Capi/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Sensor/Capi/build-profile.json5 | 80 +- .../Sensor/Capi/entry/build-profile.json5 | 56 +- .../Sensor/Capi/entry/oh-package.json5 | 54 +- .../src/main/ets/entryability/EntryAbility.ts | 112 +- .../Sensor/Capi/entry/src/main/module.json5 | 112 +- .../main/resources/base/element/color.json | 14 +- .../Capi/entry/src/ohosTest/module.json5 | 104 +- .../Sensor/Capi/hvigor/hvigor-config.json5 | 12 +- .../Sensor/Capi/oh-package.json5 | 54 +- .../DeviceManagement/Sensor/JsApi/.gitignore | 11 + .../Sensor/JsApi/AppScope/app.json5 | 10 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin 0 -> 6790 bytes .../Sensor/JsApi/build-profile.json5 | 27 + .../Sensor/JsApi}/entry/.gitignore | 0 .../Sensor/JsApi/entry/build-profile.json5 | 14 + .../Sensor/JsApi/entry/hvigorfile.ts | 2 + .../Sensor/JsApi/entry/oh-package.json5 | 10 + .../src/main/ets/entryability/EntryAbility.ts | 41 + .../JsApi/entry/src/main/ets/pages/Index.ets | 356 + .../Sensor/JsApi/entry/src/main/module.json5 | 37 + .../main/resources/base/element/color.json | 0 .../main/resources/base/element/string.json | 16 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 16 + .../main/resources/zh_CN/element/string.json | 16 + .../src/ohosTest/ets/test/Ability.test.ets | 35 + .../entry/src/ohosTest/ets/test/List.test.ets | 5 + .../ohosTest/ets/testability/TestAbility.ets | 48 + .../ohosTest/ets/testability/pages/Index.ets | 34 + .../ets/testrunner/OpenHarmonyTestRunner.ts | 49 + .../JsApi/entry/src/ohosTest/module.json5 | 37 + .../resources/base/element/color.json | 8 + .../resources/base/element/string.json | 16 + .../ohosTest/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/test_pages.json | 5 + .../Sensor/JsApi/hvigor/hvigor-config.json5 | 6 + .../Sensor/JsApi/hvigor/hvigor-wrapper.js | 2 + .../Sensor/JsApi/hvigorfile.ts | 2 + .../DeviceManagement/Sensor/JsApi/hvigorw | 48 + .../DeviceManagement/Sensor/JsApi/hvigorw.bat | 64 + .../Sensor/JsApi/oh-package-lock.json5 | 13 + .../Sensor/JsApi/oh-package.json5 | 13 + .../Vibrator/CustomHaptic/AppScope/app.json5 | 52 +- .../resources/base/element/string.json | 16 +- .../Vibrator/CustomHaptic/build-profile.json5 | 84 +- .../CustomHaptic/entry/build-profile.json5 | 56 +- .../CustomHaptic/entry/oh-package.json5 | 52 +- .../entry/src/main/ets/component/Battle.ets | 68 +- .../entry/src/main/ets/component/Common.ets | 190 +- .../src/main/ets/component/Environment.ets | 68 +- .../entry/src/main/ets/component/Exercise.ets | 68 +- .../entry/src/main/ets/component/Footstep.ets | 68 +- .../src/main/ets/component/Instrument.ets | 68 +- .../src/main/ets/component/Interaction.ets | 432 +- .../entry/src/main/ets/component/Racing.ets | 68 +- .../src/main/ets/component/Realistic.ets | 68 +- .../entry/src/main/ets/component/Shooting.ets | 68 +- .../src/main/ets/component/VideoPreview.ets | 116 +- .../src/main/ets/entryability/EntryAbility.ts | 148 +- .../src/main/ets/module/DisplayModule.ets | 382 +- .../entry/src/main/ets/module/ImageData.ets | 1460 +- .../src/main/ets/module/MyInfoModule.ets | 456 +- .../entry/src/main/ets/module/TabBar.ets | 172 +- .../entry/src/main/ets/module/Util.ets | 236 +- .../src/main/ets/module/VideoListModule.ets | 188 +- .../src/main/ets/module/VideoPlayModule.ets | 146 +- .../CustomHaptic/entry/src/main/module.json5 | 132 +- .../main/resources/base/element/color.json | 14 +- .../src/main/resources/rawfile/AK47_h.json | 72 +- .../src/main/resources/rawfile/AK47_l.json | 72 +- .../src/main/resources/rawfile/AK47_m.json | 72 +- .../resources/rawfile/AssaultRifle_h.json | 92 +- .../resources/rawfile/AssaultRifle_l.json | 92 +- .../resources/rawfile/AssaultRifle_m.json | 92 +- .../main/resources/rawfile/Badminton_h.json | 448 +- .../main/resources/rawfile/Badminton_l.json | 448 +- .../main/resources/rawfile/Badminton_m.json | 448 +- .../main/resources/rawfile/Baseball_h.json | 184 +- .../main/resources/rawfile/Baseball_l.json | 184 +- .../main/resources/rawfile/Baseball_m.json | 184 +- .../main/resources/rawfile/Basketball_h.json | 722 +- .../main/resources/rawfile/Basketball_l.json | 722 +- .../main/resources/rawfile/Basketball_m.json | 722 +- .../src/main/resources/rawfile/Blast_h.json | 230 +- .../src/main/resources/rawfile/Blast_l.json | 230 +- .../src/main/resources/rawfile/Blast_m.json | 230 +- .../src/main/resources/rawfile/Bomb_h.json | 1306 +- .../src/main/resources/rawfile/Bomb_l.json | 1306 +- .../src/main/resources/rawfile/Bomb_m.json | 1306 +- .../src/main/resources/rawfile/CZ75_h.json | 72 +- .../src/main/resources/rawfile/CZ75_l.json | 72 +- .../src/main/resources/rawfile/CZ75_m.json | 72 +- .../main/resources/rawfile/Campfire_h.json | 554 +- .../main/resources/rawfile/Campfire_l.json | 554 +- .../main/resources/rawfile/Campfire_m.json | 554 +- .../main/resources/rawfile/CarCrash_h.json | 1062 +- .../main/resources/rawfile/CarCrash_l.json | 1062 +- .../main/resources/rawfile/CarCrash_m.json | 1062 +- .../main/resources/rawfile/CarIgnite_h.json | 510 +- .../main/resources/rawfile/CarIgnite_l.json | 510 +- .../main/resources/rawfile/CarIgnite_m.json | 510 +- .../src/main/resources/rawfile/CarSkid_h.json | 404 +- .../src/main/resources/rawfile/CarSkid_l.json | 404 +- .../src/main/resources/rawfile/CarSkid_m.json | 404 +- .../src/main/resources/rawfile/Claves_h.json | 52 +- .../src/main/resources/rawfile/Claves_l.json | 52 +- .../src/main/resources/rawfile/Claves_m.json | 52 +- .../main/resources/rawfile/CoinDrop_h.json | 230 +- .../main/resources/rawfile/CoinDrop_l.json | 230 +- .../main/resources/rawfile/CoinDrop_m.json | 230 +- .../src/main/resources/rawfile/Creek_h.json | 2652 ++-- .../src/main/resources/rawfile/Creek_l.json | 2652 ++-- .../src/main/resources/rawfile/Creek_m.json | 2652 ++-- .../main/resources/rawfile/Cymbals2_h.json | 98 +- .../main/resources/rawfile/Cymbals2_l.json | 98 +- .../main/resources/rawfile/Cymbals2_m.json | 98 +- .../src/main/resources/rawfile/Cymbals_h.json | 98 +- .../src/main/resources/rawfile/Cymbals_l.json | 98 +- .../src/main/resources/rawfile/Cymbals_m.json | 98 +- .../src/main/resources/rawfile/Diving_h.json | 1592 +- .../src/main/resources/rawfile/Diving_l.json | 1592 +- .../src/main/resources/rawfile/Diving_m.json | 1592 +- .../main/resources/rawfile/DriftingJet_h.json | 108 +- .../main/resources/rawfile/DriftingJet_l.json | 108 +- .../main/resources/rawfile/DriftingJet_m.json | 108 +- .../main/resources/rawfile/Firework_h.json | 352 +- .../main/resources/rawfile/Firework_l.json | 352 +- .../main/resources/rawfile/Firework_m.json | 352 +- .../main/resources/rawfile/Gesture_up.json | 52 +- .../src/main/resources/rawfile/Gong_h.json | 138 +- .../src/main/resources/rawfile/Gong_l.json | 138 +- .../src/main/resources/rawfile/Gong_m.json | 138 +- .../src/main/resources/rawfile/Guitar_h.json | 290 +- .../src/main/resources/rawfile/Guitar_l.json | 290 +- .../src/main/resources/rawfile/Guitar_m.json | 290 +- .../src/main/resources/rawfile/HK416_h.json | 164 +- .../src/main/resources/rawfile/HK416_l.json | 164 +- .../src/main/resources/rawfile/HK416_m.json | 164 +- .../main/resources/rawfile/HapticVideo.json | 520 +- .../main/resources/rawfile/HitGlass_h.json | 528 +- .../main/resources/rawfile/HitGlass_l.json | 528 +- .../main/resources/rawfile/HitGlass_m.json | 528 +- .../main/resources/rawfile/HitMetal_h.json | 370 +- .../main/resources/rawfile/HitMetal_l.json | 370 +- .../main/resources/rawfile/HitMetal_m.json | 370 +- .../src/main/resources/rawfile/HitSand_h.json | 314 +- .../src/main/resources/rawfile/HitSand_l.json | 314 +- .../src/main/resources/rawfile/HitSand_m.json | 314 +- .../main/resources/rawfile/HitWater_h.json | 304 +- .../main/resources/rawfile/HitWater_l.json | 304 +- .../main/resources/rawfile/HitWater_m.json | 304 +- .../src/main/resources/rawfile/HitWood_h.json | 334 +- .../src/main/resources/rawfile/HitWood_l.json | 334 +- .../src/main/resources/rawfile/HitWood_m.json | 334 +- .../src/main/resources/rawfile/Hurt_h.json | 404 +- .../src/main/resources/rawfile/Hurt_l.json | 404 +- .../src/main/resources/rawfile/Hurt_m.json | 404 +- .../src/main/resources/rawfile/JetN2O_h.json | 390 +- .../src/main/resources/rawfile/JetN2O_l.json | 390 +- .../src/main/resources/rawfile/JetN2O_m.json | 390 +- .../main/resources/rawfile/Keyboard_h.json | 172 +- .../main/resources/rawfile/Keyboard_l.json | 172 +- .../main/resources/rawfile/Keyboard_m.json | 172 +- .../main/resources/rawfile/KickDrum2_h.json | 98 +- .../main/resources/rawfile/KickDrum2_l.json | 98 +- .../main/resources/rawfile/KickDrum2_m.json | 98 +- .../main/resources/rawfile/KickDrum_h.json | 52 +- .../main/resources/rawfile/KickDrum_l.json | 52 +- .../main/resources/rawfile/KickDrum_m.json | 52 +- .../src/main/resources/rawfile/Kick_h.json | 214 +- .../src/main/resources/rawfile/Kick_l.json | 214 +- .../src/main/resources/rawfile/Kick_m.json | 214 +- .../src/main/resources/rawfile/M4_h.json | 424 +- .../src/main/resources/rawfile/M4_l.json | 424 +- .../src/main/resources/rawfile/M4_m.json | 424 +- .../src/main/resources/rawfile/MP5_h.json | 112 +- .../src/main/resources/rawfile/MP5_l.json | 112 +- .../src/main/resources/rawfile/MP5_m.json | 112 +- .../main/resources/rawfile/OnCarpet_h.json | 456 +- .../main/resources/rawfile/OnCarpet_l.json | 456 +- .../main/resources/rawfile/OnCarpet_m.json | 456 +- .../main/resources/rawfile/OnConcrete_h.json | 800 +- .../main/resources/rawfile/OnConcrete_l.json | 800 +- .../main/resources/rawfile/OnConcrete_m.json | 800 +- .../src/main/resources/rawfile/OnGrass_h.json | 1034 +- .../src/main/resources/rawfile/OnGrass_l.json | 1034 +- .../src/main/resources/rawfile/OnGrass_m.json | 1034 +- .../main/resources/rawfile/OnGravel_h.json | 1168 +- .../main/resources/rawfile/OnGravel_l.json | 1168 +- .../main/resources/rawfile/OnGravel_m.json | 1168 +- .../src/main/resources/rawfile/OnMud_h.json | 736 +- .../src/main/resources/rawfile/OnMud_l.json | 736 +- .../src/main/resources/rawfile/OnMud_m.json | 736 +- .../src/main/resources/rawfile/OnSnow_h.json | 2104 +-- .../src/main/resources/rawfile/OnSnow_l.json | 2104 +-- .../src/main/resources/rawfile/OnSnow_m.json | 2104 +-- .../src/main/resources/rawfile/OnWood_h.json | 456 +- .../src/main/resources/rawfile/OnWood_l.json | 456 +- .../src/main/resources/rawfile/OnWood_m.json | 456 +- .../src/main/resources/rawfile/Picker_h.json | 384 +- .../src/main/resources/rawfile/Picker_l.json | 384 +- .../src/main/resources/rawfile/Picker_m.json | 384 +- .../src/main/resources/rawfile/Punch_h.json | 118 +- .../src/main/resources/rawfile/Punch_l.json | 118 +- .../src/main/resources/rawfile/Punch_m.json | 118 +- .../main/resources/rawfile/RacingStart_h.json | 128 +- .../main/resources/rawfile/RacingStart_l.json | 128 +- .../main/resources/rawfile/RacingStart_m.json | 128 +- .../src/main/resources/rawfile/Rain_h.json | 2172 +-- .../src/main/resources/rawfile/Rain_l.json | 2172 +-- .../src/main/resources/rawfile/Rain_m.json | 2172 +-- .../src/main/resources/rawfile/Rifle_h.json | 72 +- .../src/main/resources/rawfile/Rifle_l.json | 72 +- .../src/main/resources/rawfile/Rifle_m.json | 72 +- .../src/main/resources/rawfile/Skating_h.json | 1238 +- .../src/main/resources/rawfile/Skating_l.json | 1238 +- .../src/main/resources/rawfile/Skating_m.json | 1238 +- .../src/main/resources/rawfile/Skiing_h.json | 978 +- .../src/main/resources/rawfile/Skiing_l.json | 978 +- .../src/main/resources/rawfile/Skiing_m.json | 978 +- .../resources/rawfile/Slide_LeftRight.json | 90 +- .../src/main/resources/rawfile/Slide_Up.json | 66 +- .../main/resources/rawfile/Snowdrift_h.json | 752 +- .../main/resources/rawfile/Snowdrift_l.json | 752 +- .../main/resources/rawfile/Snowdrift_m.json | 752 +- .../src/main/resources/rawfile/SpeedUp_h.json | 1380 +- .../src/main/resources/rawfile/SpeedUp_l.json | 1380 +- .../src/main/resources/rawfile/SpeedUp_m.json | 1380 +- .../main/resources/rawfile/Switch_App.json | 90 +- .../main/resources/rawfile/TableTennis_h.json | 192 +- .../main/resources/rawfile/TableTennis_l.json | 192 +- .../main/resources/rawfile/TableTennis_m.json | 192 +- .../main/resources/rawfile/Tambourine_h.json | 338 +- .../main/resources/rawfile/Tambourine_l.json | 338 +- .../main/resources/rawfile/Tambourine_m.json | 338 +- .../src/main/resources/rawfile/Thunder_h.json | 1976 +-- .../src/main/resources/rawfile/Thunder_l.json | 1976 +-- .../src/main/resources/rawfile/Thunder_m.json | 1976 +-- .../src/main/resources/rawfile/Tumble_h.json | 712 +- .../src/main/resources/rawfile/Tumble_l.json | 712 +- .../src/main/resources/rawfile/Tumble_m.json | 712 +- .../main/resources/rawfile/Typewriter_h.json | 634 +- .../main/resources/rawfile/Typewriter_l.json | 634 +- .../main/resources/rawfile/Typewriter_m.json | 634 +- .../main/resources/rawfile/UpSlide_Stop.json | 66 +- .../src/main/resources/rawfile/Walk_h.json | 252 +- .../src/main/resources/rawfile/Walk_l.json | 252 +- .../src/main/resources/rawfile/Walk_m.json | 252 +- .../src/main/resources/rawfile/Water_h.json | 270 +- .../src/main/resources/rawfile/Water_l.json | 270 +- .../src/main/resources/rawfile/Water_m.json | 270 +- .../src/main/resources/rawfile/Wave_h.json | 4606 +++--- .../src/main/resources/rawfile/Wave_l.json | 4606 +++--- .../src/main/resources/rawfile/Wave_m.json | 4606 +++--- .../main/resources/rawfile/Winchester_h.json | 118 +- .../main/resources/rawfile/Winchester_l.json | 118 +- .../main/resources/rawfile/Winchester_m.json | 118 +- .../src/main/resources/rawfile/Wind_h.json | 516 +- .../src/main/resources/rawfile/Wind_l.json | 516 +- .../src/main/resources/rawfile/Wind_m.json | 516 +- .../src/main/resources/rawfile/bell_h.json | 120 +- .../src/main/resources/rawfile/bell_l.json | 120 +- .../src/main/resources/rawfile/bell_m.json | 120 +- .../resources/rawfile/camerashutter2_h.json | 184 +- .../resources/rawfile/camerashutter2_l.json | 184 +- .../resources/rawfile/camerashutter2_m.json | 184 +- .../resources/rawfile/camerashutter_h.json | 344 +- .../resources/rawfile/camerashutter_l.json | 344 +- .../resources/rawfile/camerashutter_m.json | 344 +- .../src/main/resources/rawfile/clock_h.json | 290 +- .../src/main/resources/rawfile/clock_l.json | 290 +- .../src/main/resources/rawfile/clock_m.json | 290 +- .../main/resources/rawfile/heartbeat_h.json | 456 +- .../main/resources/rawfile/heartbeat_l.json | 456 +- .../main/resources/rawfile/heartbeat_m.json | 456 +- .../src/main/resources/rawfile/ice_h.json | 202 +- .../src/main/resources/rawfile/ice_l.json | 202 +- .../src/main/resources/rawfile/ice_m.json | 202 +- .../src/main/resources/rawfile/timer_h.json | 362 +- .../src/main/resources/rawfile/timer_l.json | 362 +- .../src/main/resources/rawfile/timer_m.json | 362 +- .../main/resources/rawfile/triangle_h.json | 120 +- .../main/resources/rawfile/triangle_l.json | 120 +- .../main/resources/rawfile/triangle_m.json | 120 +- .../entry/src/ohosTest/module.json5 | 104 +- .../CustomHaptic/hvigor/hvigor-config.json5 | 10 +- .../Vibrator/CustomHaptic/oh-package.json5 | 52 +- .../Vibrator/JsApi/.gitignore | 11 + .../Vibrator/JsApi/AppScope/app.json5 | 10 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin 0 -> 6790 bytes .../Vibrator/JsApi/build-profile.json5 | 27 + .../Vibrator/JsApi/entry}/.gitignore | 0 .../Vibrator/JsApi/entry/build-profile.json5 | 14 + .../Vibrator/JsApi/entry/hvigorfile.ts | 2 + .../Vibrator/JsApi/entry/oh-package.json5 | 10 + .../src/main/ets/entryability/EntryAbility.ts | 41 + .../JsApi/entry/src/main/ets/pages/Index.ets | 379 + .../JsApi/entry/src/main/module.json5 | 37 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 16 + .../src/main/resources/rawfile/vibrator.json | 40 + .../main/resources/zh_CN/element/string.json | 16 + .../src/ohosTest/ets/test/Ability.test.ets | 35 + .../entry/src/ohosTest/ets/test/List.test.ets | 5 + .../ohosTest/ets/testability/TestAbility.ets | 48 + .../ohosTest/ets/testability/pages/Index.ets | 34 + .../ets/testrunner/OpenHarmonyTestRunner.ts | 49 + .../JsApi/entry/src/ohosTest/module.json5 | 37 + .../resources/base/element/color.json | 8 + .../resources/base/element/string.json | 16 + .../ohosTest/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/test_pages.json | 5 + .../Vibrator/JsApi/hvigor/hvigor-config.json5 | 6 + .../Vibrator/JsApi/hvigor/hvigor-wrapper.js | 2 + .../Vibrator/JsApi/hvigorfile.ts | 2 + .../DeviceManagement/Vibrator/JsApi/hvigorw | 48 + .../Vibrator/JsApi/hvigorw.bat | 64 + .../Vibrator/JsApi/oh-package-lock.json5 | 13 + .../Vibrator/JsApi/oh-package.json5 | 13 + .../DisplaySoloist/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../DisplaySoloist/build-profile.json5 | 84 +- .../DisplaySoloist/entry/build-profile.json5 | 68 +- .../DisplaySoloist/entry/oh-package.json5 | 24 +- .../entry/src/main/ets/pages/Index.ets | 292 +- .../entry/src/main/ets/utils/Logger.ets | 86 +- .../entry/src/ohosTest/ets/utils/Logger.ets | 88 +- .../DisplaySoloist/hvigor/hvigor-config.json5 | 10 +- .../Graphics/DisplaySoloist/oh-package.json5 | 24 +- .../Graphics/DisplaySync/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Graphics/DisplaySync/build-profile.json5 | 84 +- .../DisplaySync/entry/build-profile.json5 | 76 +- .../DisplaySync/entry/oh-package.json5 | 20 +- .../main/ets/pages/CustomDrawDisplaySync.ets | 378 +- .../pages/PropertyAnimationDisplaySync.ets | 314 +- .../main/ets/pages/XComponentDisplaySync.ets | 254 +- .../entry/src/main/ets/utils/Logger.ets | 86 +- .../entry/src/ohosTest/ets/utils/Logger.ets | 88 +- .../DisplaySync/hvigor/hvigor-config.json5 | 64 +- .../Graphics/DisplaySync/oh-package.json5 | 24 +- .../Graphics2d/ExpandText/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Graphics2d/ExpandText/build-profile.json5 | 100 +- .../ExpandText/entry/build-profile.json5 | 84 +- .../ExpandText/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../main/ets/pages/TextCollapseEtsDemo.ets | 688 +- .../ExpandText/entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../resources/base/profile/backup_config.json | 4 +- .../ExpandText/hvigor/hvigor-config.json5 | 42 +- .../Graphics2d/ExpandText/oh-package.json5 | 50 +- .../Media/AVSession/VideoPlayer/ohosTest.md | 26 +- .../entry/src/main/ets/pages/LiveCapturer.ets | 1352 +- .../entry/src/main/ets/pages/SpatialAudio.ets | 902 +- .../entry/src/main/ets/pages/VolumePanel.ets | 162 +- code/BasicFeature/Media/Camera/README.md | 280 +- .../Media/Camera/entry/oh-package.json5 | 22 +- .../main/cpp/types/libentry/oh-package.json5 | 10 +- .../entry/src/ohosTest/ets/test/Logger.ts | 88 +- .../Media/Camera/hvigor/hvigor-config.json5 | 38 +- .../Media/Camera/oh-package.json5 | 52 +- .../src/main/resources/rawfile/test1.srt | 244 +- .../Native/NdkNativeFence/.gitignore | 0 .../Native/NdkNativeFence/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../Native/NdkNativeFence/README_zh.md | 0 .../Native/NdkNativeFence/build-profile.json5 | 110 +- .../Native/NdkNativeFence/code-linter.json5 | 0 .../Native/NdkNativeFence/entry/.gitignore | 0 .../NdkNativeFence/entry/build-profile.json5 | 68 +- .../Native/NdkNativeFence/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../NdkNativeFence/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 50 +- .../entry/src/main/cpp/common/log_common.h | 0 .../entry/src/main/cpp/napi_init.cpp | 332 +- .../src/main/cpp/types/libentry/Index.d.ts | 34 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 108 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/Libentry.mock.ets | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 56 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../NdkNativeFence/hvigor/hvigor-config.json5 | 74 +- .../Native/NdkNativeFence/hvigorfile.ts | 0 .../Native/NdkNativeFence/oh-package.json5 | 50 +- .../Native/NdkNativeFence/ohosTest.md | 0 .../NdkNativeFence/screenshots/SyncFence.jpeg | Bin .../Native/NdkNativeImage/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Native/NdkNativeImage/build-profile.json5 | 110 +- .../NdkNativeImage/entry/build-profile.json5 | 68 +- .../NdkNativeImage/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 72 +- .../entry/src/main/cpp/napi_init.cpp | 272 +- .../src/main/cpp/render/image_render.cpp | 736 +- .../entry/src/main/cpp/render/image_render.h | 128 +- .../src/main/cpp/render/native_render.cpp | 444 +- .../entry/src/main/cpp/render/native_render.h | 80 +- .../src/main/cpp/render/render_engine.cpp | 800 +- .../entry/src/main/cpp/render/render_engine.h | 262 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 82 +- .../entrybackupability/EntryBackupAbility.ets | 22 +- .../entry/src/main/ets/pages/Index.ets | 84 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../resources/base/profile/backup_config.json | 4 +- .../ohosTest/ets/test/NdkNativeImage.test.ets | 90 +- .../entry/src/ohosTest/module.json5 | 54 +- .../NdkNativeImage/hvigor/hvigor-config.json5 | 44 +- .../Native/NdkNativeImage/oh-package.json5 | 50 +- .../Native/NdkNativeWindow/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../NdkNativeWindow/build-profile.json5 | 84 +- .../NdkNativeWindow/entry/build-profile.json5 | 68 +- .../NdkNativeWindow/entry/oh-package.json5 | 24 +- .../entry/src/main/cpp/CMakeLists.txt | 58 +- .../main/cpp/types/libentry/oh-package.json5 | 10 +- .../src/main/ets/entryability/EntryAbility.ts | 116 +- .../entry/src/main/ets/pages/Index.ets | 370 +- .../entry/src/main/module.json5 | 102 +- .../main/resources/base/element/color.json | 14 +- .../entry/src/ohosTest/module.json5 | 104 +- .../hvigor/hvigor-config.json5 | 62 +- .../Native/NdkNativeWindow/oh-package.json5 | 54 +- .../Native/NdkOpenGL/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Native/NdkOpenGL/build-profile.json5 | 84 +- .../NdkOpenGL/entry/build-profile.json5 | 66 +- .../Native/NdkOpenGL/entry/oh-package.json5 | 54 +- .../entry/src/main/cpp/CMakeLists.txt | 92 +- .../entry/src/main/cpp/include/tetrahedron.h | 120 +- .../entry/src/main/cpp/include/util/log.h | 70 +- .../src/main/cpp/include/util/napi_manager.h | 160 +- .../entry/src/main/cpp/tetrahedron.cpp | 698 +- .../main/cpp/type/libentry/oh-package.json5 | 10 +- .../cpp/type/libentry/tetrahedron_napi.d.ts | 32 +- .../entry/src/main/ets/pages/Index.ets | 192 +- .../entry/src/main/ets/utils/Logger.ets | 88 +- .../NdkOpenGL/entry/src/main/module.json5 | 100 +- .../main/resources/base/element/color.json | 182 +- .../NdkOpenGL/entry/src/ohosTest/module.json5 | 102 +- .../NdkOpenGL/hvigor/hvigor-config.json5 | 10 +- .../Native/NdkOpenGL/oh-package.json5 | 54 +- .../Native/NdkQoS/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Native/NdkQoS/build-profile.json5 | 102 +- .../Native/NdkQoS/entry/build-profile.json5 | 114 +- .../Native/NdkQoS/entry/oh-package.json5 | 20 +- .../NdkQoS/entry/src/main/cpp/CMakeLists.txt | 28 +- .../Native/NdkQoS/entry/src/main/cpp/main.cpp | 418 +- .../src/main/cpp/types/libentry/index.d.ts | 32 +- .../main/cpp/types/libentry/oh-package.json5 | 10 +- .../main/ets/entryability/EntryAbility.ets | 116 +- .../NdkQoS/entry/src/main/ets/pages/Index.ets | 156 +- .../Native/NdkQoS/entry/src/main/module.json5 | 104 +- .../main/resources/base/element/color.json | 14 +- .../NdkQoS/entry/src/ohosTest/module.json5 | 104 +- .../Native/NdkQoS/hvigor/hvigor-config.json5 | 44 +- .../Native/NdkQoS/oh-package.json5 | 28 +- .../Native/NdkRawfile/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Native/NdkRawfile/build-profile.json5 | 84 +- .../NdkRawfile/entry/build-profile.json5 | 74 +- .../Native/NdkRawfile/entry/oh-package.json5 | 52 +- .../entry/src/main/cpp/CMakeLists.txt | 20 +- .../entry/src/main/cpp/rawfile_demo.cpp | 730 +- .../src/main/cpp/types/libentry/index.d.ts | 70 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 116 +- .../entry/src/main/ets/pages/Index.ets | 278 +- .../entry/src/main/ets/utils/Logger.ets | 86 +- .../NdkRawfile/entry/src/main/module.json5 | 102 +- .../main/resources/base/element/color.json | 14 +- .../entry/src/ohosTest/module.json5 | 104 +- .../NdkRawfile/hvigor/hvigor-config.json5 | 8 +- .../Native/NdkRawfile/oh-package.json5 | 24 +- .../Native/XComponent/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Native/XComponent/build-profile.json5 | 84 +- .../XComponent/entry/build-profile.json5 | 76 +- .../Native/XComponent/entry/oh-package.json5 | 20 +- .../XComponent/entry/src/main/module.json5 | 100 +- .../XComponent/hvigor/hvigor-config.json5 | 40 +- .../Native/XComponent/oh-package.json5 | 24 +- .../CustomCommonEvent/README_zh.md | 332 +- .../ets/entryformability/EntryFormAbility.ts | 118 +- .../ets/publishcard/pages/PublishCard.ets | 246 +- .../main/resources/base/element/float.json | 230 +- .../resources/base/profile/form_config.json | 44 +- .../CustomCommonEventRely/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../CustomCommonEventRely/build-profile.json5 | 84 +- .../entry/build-profile.json5 | 56 +- .../entry/oh-package.json5 | 20 +- .../src/main/ets/entryability/EntryAbility.ts | 112 +- .../ets/entryformability/EntryFormAbility.ts | 114 +- .../src/main/ets/widget/pages/PublishCard.ets | 246 +- .../entry/src/main/module.json5 | 146 +- .../main/resources/base/element/color.json | 46 +- .../main/resources/base/element/float.json | 118 +- .../resources/base/profile/form_config.json | 44 +- .../hvigor/hvigor-config.json5 | 40 +- .../CustomCommonEventRely/oh-package.json5 | 24 +- .../ScanNapiInterfaceDemo/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Print/ScanNapiInterfaceDemo/README_zh.md | 266 +- .../ScanNapiInterfaceDemo/build-profile.json5 | 98 +- .../entry/build-profile.json5 | 84 +- .../main/ets/entryability/EntryAbility.ets | 110 +- .../entrybackupability/EntryBackupAbility.ets | 50 +- .../entry/src/main/ets/scan/log.ts | 64 +- .../entry/src/main/ets/scan/scan.ts | 324 +- .../entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../resources/base/profile/backup_config.json | 4 +- .../entry/src/ohosTest/ets/test/Scan.test.ets | 228 +- .../entry/src/ohosTest/module.json5 | 52 +- .../hvigor/hvigor-config.json5 | 72 +- .../oh-package-lock.json5 | 82 +- .../ScanNapiInterfaceDemo/oh-package.json5 | 48 +- .../main/ets/entryability/EntryAbility.ets | 122 +- .../libraryOverlay/build-profile.json5 | 48 +- .../libraryOverlay/oh-package.json5 | 20 +- .../libraryOverlay/src/main/ets/Index.ets | 30 +- .../libraryOverlay/src/main/module.json5 | 56 +- .../main/resources/base/element/string.json | 22 +- .../libraryRuntimeOverlay/build-profile.json5 | 48 +- .../libraryRuntimeOverlay/oh-package.json5 | 20 +- .../src/main/ets/Index.ets | 30 +- .../src/main/module.json5 | 54 +- .../main/resources/base/element/string.json | 22 +- code/BasicFeature/Security/Asset/.gitignore | 22 +- .../Security/Asset/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../AppScope/resources/base/media/back.png | Bin .../AppScope/resources/base/media/forward.png | Bin code/BasicFeature/Security/Asset/README_zh.md | 218 +- .../Security/Asset/build-profile.json5 | 84 +- .../Security/Asset/entry/.gitignore | 10 +- .../Security/Asset/entry/build-profile.json5 | 52 +- .../Security/Asset/entry/hvigorfile.ts | 12 +- .../Security/Asset/entry/oh-package.json5 | 22 +- .../Asset/entry/src/main/ets/common/Logger.ts | 116 +- .../src/main/ets/entryability/EntryAbility.ts | 116 +- .../entry/src/main/ets/model/AssetModel.ets | 666 +- .../Asset/entry/src/main/ets/pages/Index.ets | 1400 +- .../src/main/ets/pages/QueryResultPage.ets | 362 +- .../entry/src/main/ets/pages/UpdatePage.ets | 438 +- .../Asset/entry/src/main/module.json5 | 118 +- .../main/resources/base/element/color.json | 62 +- .../main/resources/base/element/float.json | 374 +- .../main/resources/base/element/images.json | 14 +- .../main/resources/base/element/string.json | 238 +- .../resources/base/element/stringarray.json | 68 +- .../resources/base/profile/main_pages.json | 14 +- .../main/resources/en_US/element/string.json | 238 +- .../main/resources/zh_CN/element/string.json | 238 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/testability/TestAbility.ets | 0 .../ohosTest/ets/testability/pages/Index.ets | 0 .../ets/testrunner/OpenHarmonyTestRunner.ets | 0 .../Asset/entry/src/ohosTest/module.json5 | 102 +- .../resources/base/element/color.json | 0 .../resources/base/element/string.json | 0 .../ohosTest/resources/base/media/icon.png | Bin .../resources/base/profile/test_pages.json | 0 .../Security/Asset/hvigor/hvigor-config.json5 | 34 +- .../Security/Asset/hvigor/hvigor-wrapper.js | 0 .../BasicFeature/Security/Asset/hvigorfile.ts | 12 +- code/BasicFeature/Security/Asset/hvigorw | 0 code/BasicFeature/Security/Asset/hvigorw.bat | 154 +- .../Security/Asset/oh-package.json5 | 56 +- code/BasicFeature/Security/Asset/ohosTest.md | 20 +- .../Asset/screenshots/batch_query_result.jpeg | Bin .../Security/Asset/screenshots/delete.jpeg | Bin .../Security/Asset/screenshots/query.jpeg | Bin .../Security/Asset/screenshots/save.jpeg | Bin .../screenshots/single_query_result.jpeg | Bin .../Asset/screenshots/update_edit.jpeg | Bin .../Asset/screenshots/update_list.jpeg | Bin .../CryptoFramework/AppScope/app.json5 | 52 +- .../resources/base/element/string.json | 16 +- .../Security/CryptoFramework/README.md | 104 +- .../CryptoFramework/build-profile.json5 | 82 +- .../CryptoFramework/entry/build-profile.json5 | 54 +- .../CryptoFramework/entry/oh-package.json5 | 48 +- .../ets/cryptoframework/CryptoOperation.ts | 770 +- .../src/main/ets/entryability/EntryAbility.ts | 112 +- .../entry/src/main/ets/tab/Decrypt.ets | 660 +- .../entry/src/main/ets/tab/Encrypt.ets | 762 +- .../entry/src/main/ets/tab/Sign.ets | 704 +- .../entry/src/main/ets/tab/Verify.ets | 716 +- .../ets/textfilemanager/TextFileManager.ts | 158 +- .../entry/src/main/ets/util/Logger.ts | 116 +- .../entry/src/main/module.json5 | 102 +- .../main/resources/base/element/color.json | 14 +- .../entry/src/ohosTest/module.json5 | 104 +- .../hvigor/hvigor-config.json5 | 42 +- .../Security/CryptoFramework/oh-package.json5 | 52 +- .../Security/CryptoFramework/ohosTest.md | 48 +- .../src/main/ets/common/MinAccessControl.ets | 440 +- .../Performance/Startup/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 46 +- .../Ability/Performance/Startup/README_zh.md | 458 +- .../Performance/Startup/build-profile.json5 | 102 +- .../Startup/entry/build-profile.json5 | 56 +- .../Startup/entry/oh-package.json5 | 20 +- .../entry/src/main/ets/common/Logger.ts | 88 +- .../src/main/ets/entryability/EntryAbility.ts | 204 +- .../main/ets/myabilitystage/MyAbilityStage.ts | 92 +- .../Startup/entry/src/main/module.json5 | 102 +- .../main/resources/base/element/color.json | 44 +- .../entry/src/ohosTest/ets/util/Logger.ts | 88 +- .../Startup/entry/src/ohosTest/module.json5 | 102 +- .../Startup/hvigor/hvigor-config.json5 | 66 +- .../Performance/Startup/oh-package.json5 | 24 +- .../Ability/Performance/Startup/ohosTest.md | 16 +- .../Account/DomainAccount/.gitignore | 0 .../Account/DomainAccount/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../Account/DomainAccount/README.md | 182 +- .../Account/DomainAccount/build-profile.json5 | 114 +- .../Account/DomainAccount/code-linter.json5 | 0 .../Account/DomainAccount/entry/.gitignore | 0 .../DomainAccount/entry/build-profile.json5 | 84 +- .../Account/DomainAccount/entry/hvigorfile.ts | 0 .../DomainAccount/entry/obfuscation-rules.txt | 0 .../DomainAccount/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../AuthenticationDomainAccount.ets | 228 +- .../DomainAccount/ManageDomainAccounts.ets | 358 +- .../ManageDomainAccountsPlugin.ets | 412 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/util/CommonButton.ets | 0 .../DomainAccount/entry/src/main/module.json5 | 150 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 56 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../DomainAccount/hvigor/hvigor-config.json5 | 74 +- .../Account/DomainAccount/hvigorfile.ts | 0 .../Account/DomainAccount/oh-package.json5 | 50 +- .../Account/DomainAccount/ohosTest.md | 28 +- .../screenshots/DomainAccount_1.png | Bin .../screenshots/DomainAccount_10.png | Bin .../screenshots/DomainAccount_11.png | Bin .../screenshots/DomainAccount_12.png | Bin .../screenshots/DomainAccount_2.png | Bin .../screenshots/DomainAccount_3.png | Bin .../screenshots/DomainAccount_4.png | Bin .../screenshots/DomainAccount_5.png | Bin .../screenshots/DomainAccount_6.png | Bin .../screenshots/DomainAccount_7.png | Bin .../screenshots/DomainAccount_8.png | Bin .../screenshots/DomainAccount_9.png | Bin .../ManageDistributedAccount/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ManageDistributedAccount/README.md | 140 +- .../build-profile.json5 | 102 +- .../code-linter.json5 | 0 .../ManageDistributedAccount/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 138 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 56 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ManageDistributedAccount/hvigorfile.ts | 0 .../ManageDistributedAccount/oh-package.json5 | 50 +- .../ManageDistributedAccount/ohosTest.md | 20 +- .../ManageDistributedAccount_1.png | Bin .../ManageDistributedAccount_2.png | Bin .../ManageDistributedAccount_3.png | Bin .../ManageDistributedAccount_4.png | Bin .../ManageDistributedAccount_5.png | Bin .../ManageSystemAccountCredentials/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ManageSystemAccountCredentials/README.md | 158 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 158 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 56 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 22 +- .../screenshots/AccountCredentials_1.png | Bin .../screenshots/AccountCredentials_2.png | Bin .../screenshots/AccountCredentials_3.png | Bin .../screenshots/AccountCredentials_4.png | Bin .../screenshots/AccountCredentials_5.png | Bin .../screenshots/AccountCredentials_6.png | Bin .../ManagerApplicationAccount/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ManagerApplicationAccount/README.md | 152 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/module.json5 | 132 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 56 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ManagerApplicationAccount/hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ManagerApplicationAccount/ohosTest.md | 24 +- .../ManagerApplicationAccount_1.png | Bin .../ManagerApplicationAccount_2.png | Bin .../ManagerApplicationAccount_3.png | Bin .../ManagerApplicationAccount_4.png | Bin .../ManagerApplicationAccount_5.png | Bin .../ManagerApplicationAccount_6.png | Bin .../ManagerApplicationAccount_7.png | Bin .../Account/SystemAccount/.gitignore | 0 .../Account/SystemAccount/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../Account/SystemAccount/README.md | 188 +- .../Account/SystemAccount/build-profile.json5 | 114 +- .../Account/SystemAccount/code-linter.json5 | 0 .../Account/SystemAccount/entry/.gitignore | 0 .../SystemAccount/entry/build-profile.json5 | 84 +- .../Account/SystemAccount/entry/hvigorfile.ts | 0 .../SystemAccount/entry/obfuscation-rules.txt | 0 .../SystemAccount/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../SystemAccount/ManageSystemAccounts.ets | 418 +- .../UseConstraintManagementSystemAccount.ets | 188 +- .../entry/src/main/ets/util/CommonButton.ets | 0 .../SystemAccount/entry/src/main/module.json5 | 144 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 56 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../SystemAccount/hvigor/hvigor-config.json5 | 74 +- .../Account/SystemAccount/hvigorfile.ts | 0 .../Account/SystemAccount/oh-package.json5 | 50 +- .../Account/SystemAccount/ohosTest.md | 28 +- .../screenshots/SystemAccount_1.png | Bin .../screenshots/SystemAccount_10.png | Bin .../screenshots/SystemAccount_11.png | Bin .../screenshots/SystemAccount_2.png | Bin .../screenshots/SystemAccount_3.png | Bin .../screenshots/SystemAccount_4.png | Bin .../screenshots/SystemAccount_5.png | Bin .../screenshots/SystemAccount_6.png | Bin .../screenshots/SystemAccount_7.png | Bin .../screenshots/SystemAccount_8.png | Bin .../screenshots/SystemAccount_9.png | Bin .../AppScope/app.json5 | 52 +- .../resources/base/element/string.json | 16 +- .../build-profile.json5 | 84 +- .../entry/build-profile.json5 | 54 +- .../entry/oh-package.json5 | 18 +- .../src/main/ets/entryability/EntryAbility.ts | 118 +- .../entry/src/main/module.json5 | 134 +- .../main/resources/base/element/color.json | 14 +- .../hvigor/hvigor-config.json5 | 40 +- .../ImplicitStartByTypeRely/oh-package.json5 | 22 +- .../ImplicitStartRely/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../ImplicitStartRely/build-profile.json5 | 84 +- .../entry/build-profile.json5 | 56 +- .../ImplicitStartRely/entry/oh-package.json5 | 20 +- .../src/main/ets/entryability/EntryAbility.ts | 116 +- .../entry/src/main/module.json5 | 128 +- .../main/resources/base/element/color.json | 14 +- .../hvigor/hvigor-config.json5 | 40 +- .../ImplicitStartRely/oh-package.json5 | 24 +- .../MindSporeLiteArkTSDemo/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../MindSporeLiteArkTSDemo/README_zh.md | 152 +- .../build-profile.json5 | 102 +- .../entry/build-profile.json5 | 84 +- .../entry/oh-package.json5 | 20 +- .../main/ets/entryability/EntryAbility.ets | 82 +- .../entry/src/main/ets/pages/model.ets | 68 +- .../entry/src/main/module.json5 | 120 +- .../main/resources/base/element/color.json | 14 +- .../entry/src/ohosTest/ets/utils/Logger.ts | 88 +- .../src/ohosTest/ets/utils/ResourceUtil.ets | 44 +- .../entry/src/ohosTest/module.json5 | 104 +- .../resources/base/element/string.json | 46 +- .../hvigor/hvigor-config.json5 | 74 +- .../MindSporeLiteArkTSDemo/oh-package.json5 | 58 +- .../MindSporeLiteArkTSDemo/ohosTest.md | 16 +- .../MindSporeLiteCDemo/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../MindSporeLiteCDemo/README_zh.md | 170 +- .../MindSporeLiteCDemo/build-profile.json5 | 102 +- .../entry/build-profile.json5 | 108 +- .../MindSporeLiteCDemo/entry/oh-package.json5 | 20 +- .../entry/src/main/cpp/CMakeLists.txt | 34 +- .../entry/src/main/cpp/mslite_napi.cpp | 460 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 10 +- .../main/ets/entryability/EntryAbility.ets | 82 +- .../entry/src/main/ets/pages/Index.ets | 596 +- .../entry/src/main/module.json5 | 120 +- .../main/resources/base/element/color.json | 14 +- .../src/ohosTest/ets/utils/ResourceUtil.ets | 44 +- .../entry/src/ohosTest/module.json5 | 104 +- .../resources/base/element/string.json | 46 +- .../hvigor/hvigor-config.json5 | 74 +- .../MindSporeLiteCDemo/oh-package.json5 | 58 +- .../MindSporeLiteCDemo/ohosTest.md | 16 +- .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../build-profile.json5 | 88 +- .../entry/build-profile.json5 | 56 +- .../entry/oh-package.json5 | 50 +- .../ets/IdlServiceExt/i_idl_service_ext.ts | 46 +- .../ets/IdlServiceExt/idl_service_ext_impl.ts | 132 +- .../IdlServiceExt/idl_service_ext_proxy.ts | 162 +- .../ets/IdlServiceExt/idl_service_ext_stub.ts | 148 +- .../collaborateability/CollaborateAbility.ts | 134 +- .../MultitonAbility.ts | 78 +- .../SingletonAbility.ts | 78 +- .../SpecifiedFirstAbility.ts | 50 +- .../SpecifiedSecondAbility.ts | 50 +- .../main/ets/contextability/ContextAbility.ts | 132 +- .../src/main/ets/entryability/EntryAbility.ts | 244 +- .../src/main/ets/eventability/EventAbility.ts | 114 +- .../src/main/ets/funcability/FuncAbilityA.ts | 68 +- .../src/main/ets/funcability/FuncAbilityB.ts | 50 +- .../ets/lifecycleability/LifecycleAbility.ts | 186 +- .../ets/migrationability/MigrationAbility.ts | 284 +- .../main/ets/myabilitystage/MyAbilityStage.ts | 126 +- .../entry/src/main/ets/pages/Page_Context.ets | 546 +- .../src/main/ets/pages/Page_EventHub.ets | 252 +- .../pages/Page_ServiceExtensionAbility.ets | 588 +- .../src/main/ets/pages/Page_StartFAModel.ets | 414 +- .../src/main/ets/pages/Page_StartModel.ets | 424 +- .../Page_UIAbilityComponentsBasicUsage.ets | 176 +- .../Page_UIAbilityComponentsInteractive.ets | 1030 +- .../Page_CollaborateAbility.ets | 890 +- .../Page_ContextAbility.ets | 302 +- .../page_funcability/Page_FuncAbilityA.ets | 276 +- .../page_funcability/Page_FuncAbilityB.ets | 96 +- .../Page_LifecycleAbility.ets | 96 +- .../Page_MigrationAbilityFirst.ets | 296 +- .../Page_MigrationAbilitySecond.ets | 96 +- .../Page_MigrationAbilityThird.ets | 96 +- .../page_startupability/Page_Multiton.ets | 96 +- .../page_startupability/Page_Singleton.ets | 96 +- .../Page_Specified_First.ets | 96 +- .../Page_Specified_Second.ets | 96 +- .../entry/src/main/ets/utils/Logger.ts | 120 +- .../entry/src/main/module.json5 | 444 +- .../main/resources/base/element/color.json | 46 +- .../entry/src/ohosTest/ets/utils/Logger.ts | 120 +- .../entry/src/ohosTest/module.json5 | 104 +- .../hvigor/hvigor-config.json5 | 40 +- .../StageModelAbilityDevelop/oh-package.json5 | 54 +- .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../build-profile.json5 | 88 +- .../entry/build-profile.json5 | 56 +- .../entry/oh-package.json5 | 50 +- .../ets/IdlServiceExt/i_idl_service_ext.ts | 46 +- .../ets/IdlServiceExt/idl_service_ext_impl.ts | 132 +- .../IdlServiceExt/idl_service_ext_proxy.ts | 162 +- .../ets/IdlServiceExt/idl_service_ext_stub.ts | 148 +- .../main/ets/calleeability/CalleeAbility.ts | 268 +- .../collaborateability/CollaborateAbility.ts | 74 +- .../src/main/ets/entryability/EntryAbility.ts | 156 +- .../src/main/ets/funcability/FuncAbility.ts | 84 +- .../src/main/ets/funcbability/FuncBAbility.ts | 74 +- .../src/main/ets/pages/Page_CalleeAbility.ets | 96 +- .../src/main/ets/pages/Page_ColdStartUp.ets | 128 +- .../ets/pages/Page_CollaborateAbility.ets | 150 +- .../main/ets/pages/Page_FromStageModel.ets | 126 +- .../src/main/ets/pages/Page_HotStartUp.ets | 94 +- .../entry/src/main/module.json5 | 284 +- .../main/resources/base/element/color.json | 46 +- .../base/profile/serviceextability.json | 14 +- .../hvigor/hvigor-config.json5 | 40 +- .../oh-package.json5 | 54 +- .../StageProcessThread/AppScope/app.json5 | 48 +- .../resources/base/element/string.json | 16 +- .../StageProcessThread/build-profile.json5 | 84 +- .../entry/build-profile.json5 | 64 +- .../StageProcessThread/entry/oh-package.json5 | 48 +- .../src/main/ets/entryability/EntryAbility.ts | 174 +- .../src/main/ets/pages/PageProcessModel.ets | 662 +- .../src/main/ets/pages/PageTaskManager.ets | 922 +- .../src/main/ets/pages/PageThreadModel.ets | 348 +- .../entry/src/main/ets/workers/Worker.ts | 52 +- .../entry/src/main/module.json5 | 154 +- .../main/resources/base/element/color.json | 38 +- .../base/profile/staticsubscriber.json | 20 +- .../entry/src/ohosTest/module.json5 | 102 +- .../hvigor/hvigor-config.json5 | 40 +- .../StageProcessThread/oh-package.json5 | 52 +- .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../StageServiceWidgetCards/README_zh.md | 496 +- .../build-profile.json5 | 90 +- .../entry/build-profile.json5 | 58 +- .../attranimation/pages/AttrAnimationCard.ets | 88 +- .../pages/CustomCanvasDrawingCard.ets | 182 +- .../src/main/ets/entryability/EntryAbility.ts | 156 +- .../ets/entryformability/EntryFormAbility.ts | 214 +- .../jscardentryability/JsCardEntryAbility.ts | 110 +- .../pages/NextRefreshTimeCard.ets | 142 +- .../ets/requestForm/pages/RequestFormCard.ets | 92 +- .../pages/ScheduledUpdateTimeCard.ets | 92 +- .../pages/UpdateByMessageCard.ets | 134 +- .../pages/UpdateDurationCard.ets | 92 +- .../WidgetCalleeEntryAbility.ts | 190 +- .../pages/WidgetEventCallCard.ets | 194 +- .../WidgetEventCallEntryAbility.ts | 170 +- .../WidgetEventRouterEntryAbility.ts | 160 +- .../pages/WidgetEventRouterCard.ets | 148 +- .../pages/WidgetImageUpdateCard.ets | 214 +- .../pages/WidgetPersistentDataCard.ets | 80 +- .../pages/WidgetProcessDataCard.ets | 78 +- .../pages/WidgetUpdateByStatusCard.ets | 226 +- .../pages/WidgetUpdateCallCard.ets | 134 +- .../pages/WidgetUpdateRouterCard.ets | 132 +- .../main/js/WidgetJS/pages/index/index.json | 42 +- .../entry/src/main/module.json5 | 458 +- .../main/resources/base/element/color.json | 46 +- .../main/resources/base/element/float.json | 54 +- .../resources/base/profile/form_config.json | 158 +- .../base/profile/form_imgupdate_config.json | 44 +- .../base/profile/form_jscard_config.json | 42 +- .../profile/form_persistentdata_config.json | 46 +- .../base/profile/form_processdata_config.json | 44 +- .../profile/form_updatebystatus_config.json | 44 +- .../profile/form_updatebytime_config.json | 168 +- .../profile/form_widgetcallee_config.json | 120 +- .../entry/src/ohosTest/ets/test/Form.test.ets | 2548 ++-- .../entry/src/ohosTest/module.json5 | 104 +- .../hvigor/hvigor-config.json5 | 38 +- .../WidgetUpdateByProxy/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../WidgetUpdateByProxy/build-profile.json5 | 90 +- .../entry/build-profile.json5 | 58 +- .../entry/oh-package.json5 | 50 +- .../DataShareExtAbility.ts | 182 +- .../src/main/ets/entryability/EntryAbility.ts | 76 +- .../entry/src/main/module.json5 | 222 +- .../main/resources/base/element/color.json | 22 +- .../main/resources/base/element/float.json | 54 +- .../base/profile/data_share_config.json | 30 +- .../resources/base/profile/my_config.json | 8 +- .../entry/src/ohosTest/module.json5 | 102 +- .../hvigor/hvigor-config.json5 | 38 +- .../WidgetUpdateByProxy/oh-package.json5 | 24 +- .../ArkTSModule/DynamicImport/.gitignore | 0 .../DynamicImport/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../ArkTSModule/DynamicImport/README.md | 111 + .../DynamicImport/build-profile.json5 | 86 + .../DynamicImport/code-linter.json5 | 0 .../DynamicImport/entry}/.gitignore | 0 .../DynamicImport/entry/build-profile.json5 | 81 + .../DynamicImport/entry/hvigorfile.ts | 0 .../DynamicImport/entry/oh-package.json5 | 38 + .../entry/src/main/cpp/CMakeLists.txt | 15 + .../entry/src/main/cpp/napi_init.cpp | 55 + .../src/main/cpp/types/libentry/index.d.ts | 18 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../DynamicImport/entry/src/main/ets/Calc.ets | 22 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Calc.ets | 20 + .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/utils/Calc.ets | 20 + .../DynamicImport/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ohosTest/ets/test/DynamicImport.test.ets | 454 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../DynamicImport/har1}/.gitignore | 0 .../ArkTSModule/DynamicImport/har1/Index.ets | 20 + .../DynamicImport/har1/build-profile.json5 | 46 + .../DynamicImport/har1/hvigorfile.ts | 0 .../DynamicImport/har1/oh-package.json5 | 24 + .../har1/src/main/ets/components/MainPage.ets | 31 + .../har1/src/main/ets/utils/Calc.ets | 27 + .../DynamicImport/har1/src/main/module.json5 | 25 + .../main/resources/base/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../har1/src/ohosTest/ets/test/List.test.ets | 0 .../har1/src/ohosTest/module.json5 | 27 + .../DynamicImport/har1/src/test/List.test.ets | 0 .../har1/src/test/LocalUnit.test.ets | 0 .../DynamicImport/har2}/.gitignore | 0 .../ArkTSModule/DynamicImport/har2/Index.ets | 20 + .../DynamicImport/har2/build-profile.json5 | 46 + .../DynamicImport/har2/hvigorfile.ts | 0 .../DynamicImport/har2/oh-package.json5 | 24 + .../har2/src/main/ets/components/MainPage.ets | 31 + .../har2/src/main/ets/utils/Calc.ets | 22 + .../DynamicImport/har2/src/main/module.json5 | 25 + .../main/resources/base/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../har2/src/ohosTest/ets/test/List.test.ets | 0 .../har2/src/ohosTest/module.json5 | 27 + .../DynamicImport/har2/src/test/List.test.ets | 0 .../har2/src/test/LocalUnit.test.ets | 0 .../DynamicImport/harlibrary}/.gitignore | 0 .../DynamicImport/harlibrary/Index.ets | 20 + .../harlibrary/build-profile.json5 | 46 + .../DynamicImport/harlibrary/hvigorfile.ts | 0 .../DynamicImport/harlibrary/oh-package.json5 | 24 + .../src/main/ets/components/MainPage.ets | 31 + .../harlibrary/src/main/ets/utils/Calc.ets | 36 + .../harlibrary/src/main/module.json5 | 25 + .../main/resources/base/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../harlibrary/src/ohosTest/module.json5 | 27 + .../harlibrary/src/test/List.test.ets | 0 .../harlibrary/src/test/LocalUnit.test.ets | 0 .../DynamicImport/hvigor/hvigor-config.json5 | 37 + .../ArkTSModule/DynamicImport/hvigorfile.ts | 0 .../DynamicImport/myHar}/.gitignore | 0 .../ArkTSModule/DynamicImport/myHar/Index.ets | 24 + .../DynamicImport/myHar/build-profile.json5 | 46 + .../DynamicImport/myHar/hvigorfile.ts | 0 .../DynamicImport/myHar/oh-package.json5 | 24 + .../src/main/ets/components/MainPage.ets | 31 + .../DynamicImport/myHar/src/main/module.json5 | 25 + .../main/resources/base/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../myHar/src/ohosTest/ets/test/List.test.ets | 0 .../myHar/src/ohosTest/module.json5 | 27 + .../myHar/src/test/List.test.ets | 0 .../myHar/src/test/LocalUnit.test.ets | 0 .../DynamicImport/myHsp}/.gitignore | 0 .../ArkTSModule/DynamicImport/myHsp/Index.ets | 22 + .../DynamicImport/myHsp/build-profile.json5 | 43 + .../DynamicImport/myHsp/hvigorfile.ts | 0 .../DynamicImport/myHsp/oh-package.json5 | 26 + .../myHsp/src/main/ets/pages/Index.ets | 0 .../myHsp/src/main/ets/utils/Calc.ets | 0 .../DynamicImport/myHsp/src/main/module.json5 | 28 + .../main/resources/base/element/string.json | 8 + .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../myHsp/src/ohosTest/ets/test/List.test.ets | 0 .../myHsp/src/ohosTest/module.json5 | 27 + .../myHsp/src/test/List.test.ets | 0 .../myHsp/src/test/LocalUnit.test.ets | 0 .../DynamicImport/oh-package.json5 | 25 + .../ArkTSModule/DynamicImport/ohosTest.md | 27 + .../screenshots/DynamicImport.png | Bin .../JsApisLoadNativeModule/.gitignore | 0 .../JsApisLoadNativeModule/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsApisLoadNativeModule/README.md | 73 + .../build-profile.json5 | 58 + .../JsApisLoadNativeModule/code-linter.json5 | 0 .../JsApisLoadNativeModule}/entry/.gitignore | 0 .../entry/build-profile.json5 | 70 + .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 28 + .../entry/src/main/cpp/CMakeLists.txt | 15 + .../entry/src/main/cpp/napi_init.cpp | 62 + .../src/main/cpp/types/libentry/index.d.ts | 18 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 56 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ets/test/JsApisLoadNativeModule.test.ets | 110 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../JsApisLoadNativeModule/hvigorfile.ts | 0 .../JsApisLoadNativeModule/oh-package.json5 | 25 + .../JsApisLoadNativeModule/ohosTest.md | 9 + .../screenshots/JsApisLoadNativeModule1.png | Bin .../screenshots/JsApisLoadNativeModule2.png | Bin .../screenshots/JsApisLoadNativeModule3.png | Bin .../ArkTSModule/LazyImport/.gitignore | 0 .../ArkTSModule/LazyImport/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../ArkTSModule/LazyImport/README.md | 75 + .../LazyImport/build-profile.json5 | 58 + .../ArkTSModule/LazyImport/code-linter.json5 | 0 .../ArkTSModule/LazyImport}/entry/.gitignore | 0 .../LazyImport/entry/build-profile.json5 | 43 + .../LazyImport/entry/hvigorfile.ts | 0 .../LazyImport/entry/oh-package.json5 | 25 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../LazyImport/entry/src/main/ets/pages/A.ets | 44 +- .../entry/src/main/ets/pages/A_ns.ets | 42 +- .../LazyImport/entry/src/main/ets/pages/B.ets | 38 +- .../LazyImport/entry/src/main/ets/pages/C.ets | 38 +- .../entry/src/main/ets/pages/fail_example.ets | 58 +- .../entry/src/main/ets/pages/main.ets | 0 .../entry/src/main/ets/pages/middle.ets | 38 +- .../entry/src/main/ets/pages/mod1.ets | 46 +- .../entry/src/main/ets/pages/mod2.ets | 38 +- .../LazyImport/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/LazyImport.test.ets | 140 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 27 + .../LazyImport/entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../LazyImport/hvigor/hvigor-config.json5 | 37 + .../ArkTSModule/LazyImport/hvigorfile.ts | 0 .../ArkTSModule/LazyImport/oh-package.json5 | 25 + .../ArkTSModule/LazyImport/ohosTest.md | 12 + .../LazyImport/screenshots/LazyImport1.png | Bin .../LazyImport/screenshots/LazyImport2.png | Bin .../ModuleLoadingSideEffects/.gitignore | 0 .../AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../ModuleLoadingSideEffects/README.md | 74 + .../build-profile.json5 | 58 + .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 43 + .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 25 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 0 .../LazyImportChangeExecutionOrder/module.ets | 20 + .../moduleOptimize.ets | 20 + .../moduleUseGlobalVar.ets | 0 .../ets/pages/ModifyGlobalObject/main.ets | 0 .../ets/pages/ModifyGlobalObject/module.ets | 20 + .../ModifyGlobalObject/moduleOptimize.ets | 20 + .../ModifyGlobalObject/moduleUseGlobalVar.ets | 44 +- .../moduleUseGlobalVarOptimize.ets | 42 +- .../ModifyGlobalObject/sideEffectModule.ets | 38 +- .../sideEffectModuleOptimize.ets | 38 +- .../ModifyTheApplicationLevelArkUI/Index.ets | 0 .../ModifyTheApplicationLevelArkUI/module.ets | 20 + .../moduleOptimize.ets | 20 + .../ets/pages/ModifyingGlobalVariables/a.ets | 42 +- .../ets/pages/ModifyingGlobalVariables/b.ets | 42 +- .../pages/ModifyingGlobalVariables/main.ets | 0 .../modifyPrototype.ts | 42 +- .../ets/pages/TopCodeModification/main.ets | 0 .../ets/pages/TopCodeModification/module.ets | 24 + .../TopCodeModification/topCodeModule.ets | 34 +- .../topCodeModuleOptimize.ets | 30 +- .../entry/src/main/ets/util/CommonButton.ets | 0 .../entry/src/main/ets/util/resource.ets | 25 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../test/ModuleLoadingSideEffects.test.ets | 310 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../ModuleLoadingSideEffects/hvigorfile.ts | 0 .../ModuleLoadingSideEffects/oh-package.json5 | 25 + .../ModuleLoadingSideEffects/ohosTest.md | 12 + .../screenshots/ModuleLoadingSideEffects.png | Bin .../ApplicationMultithreading/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ApplicationMultithreading/README.md | 188 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 98 +- .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../managers/CpuIntensiveTaskDevelopment.ets | 194 +- .../managers/IoIntensiveTaskDevelopment.ets | 138 +- .../main/ets/managers/LongTimeTaskGuide.ets | 154 +- .../main/ets/managers/ResidentTaskGuide.ets | 96 +- .../main/ets/managers/SyncTaskDevelopment.ets | 150 +- .../entry/src/main/ets/managers/write.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/util/CommonButton.ets | 0 .../entry/src/main/ets/util/resource.ets | 48 +- .../entry/src/main/ets/workers/MyWorker1.ts | 0 .../entry/src/main/ets/workers/MyWorker2.ts | 74 +- .../entry/src/main/ets/workers/Worker.ets | 84 +- .../entry/src/main/ets/workers/handle.ts | 50 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ApplicationMultithreading/hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ApplicationMultithreading/ohosTest.md | 22 +- .../ApplicationMultithreading_1.png | Bin .../ApplicationMultithreading_2.png | Bin .../NativeInterthreadShared/.gitignore | 0 .../AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NativeInterthreadShared/README.md | 78 + .../build-profile.json5 | 58 + .../NativeInterthreadShared/code-linter.json5 | 0 .../NativeInterthreadShared}/entry/.gitignore | 0 .../entry/build-profile.json5 | 55 + .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 15 + .../entry/src/main/cpp/napi_init.cpp | 132 + .../src/main/cpp/types/libentry/Index.d.ts | 18 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 45 + .../src/main/ets/pages/SendableObjTest.ets | 44 +- .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NativeInterthreadShared/hvigorfile.ts | 0 .../NativeInterthreadShared/oh-package.json5 | 25 + .../NativeInterthreadShared/ohosTest.md | 8 + .../screenshots/NativeInterthreadShared_1.png | Bin .../screenshots/NativeInterthreadShared_2.png | Bin .../PracticalCases/.gitignore | 0 .../PracticalCases/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../PracticalCases/README.md | 218 +- .../PracticalCases/build-profile.json5 | 114 +- .../PracticalCases/code-linter.json5 | 0 .../PracticalCases/entry/.gitignore | 0 .../PracticalCases/entry/build-profile.json5 | 84 +- .../PracticalCases/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../PracticalCases/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../ConcurrentLoadingModulesGuide.ets | 192 +- .../entry/src/main/ets/managers/Config.ets | 134 +- .../ets/managers/GlobalConfigurationGuide.ets | 252 +- .../ets/managers/MakeobservedSendable.ets | 116 +- .../entry/src/main/ets/managers/Mock.ets | 70 +- .../src/main/ets/managers/SendableData.ets | 48 +- .../main/ets/managers/SharedValuesBucket.ets | 74 +- .../src/main/ets/managers/UsingSendable.ets | 290 +- .../src/main/ets/managers/UsingTaskPool.ets | 286 +- .../main/ets/managers/WaterFlowDataSource.ets | 286 +- .../main/ets/managers/WaterfallRendering.ets | 264 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/sdk/Calculator.ets | 138 +- .../entry/src/main/ets/sdk/TimerSdk.ets | 62 +- .../entry/src/main/ets/util/CommonButton.ets | 0 .../entry/src/main/ets/util/resource.ets | 48 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../PracticalCases/hvigor/hvigor-config.json5 | 74 +- .../PracticalCases/hvigorfile.ts | 0 .../PracticalCases/oh-package.json5 | 50 +- .../PracticalCases/ohosTest.md | 24 +- .../screenshots/PracticalCases_1.png | Bin .../screenshots/PracticalCases_2.png | Bin .../AsyncConcurrencyOverview/.gitignore | 0 .../AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../AsyncConcurrencyOverview/README.md | 66 + .../build-profile.json5 | 58 + .../code-linter.json5 | 0 .../entry}/.gitignore | 0 .../entry/build-profile.json5 | 43 + .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 25 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../AsyncConcurrencyOverview/hvigorfile.ts | 0 .../AsyncConcurrencyOverview/oh-package.json5 | 25 + .../AsyncConcurrencyOverview/ohosTest.md | 8 + .../AsyncConcurrencyOverview_1.png | Bin .../AsyncConcurrencyOverview_2.png | Bin .../CommunicationObjects/.gitignore | 0 .../CommunicationObjects/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../CommunicationObjects/README.md | 93 + .../CommunicationObjects/build-profile.json5 | 58 + .../CommunicationObjects/code-linter.json5 | 0 .../CommunicationObjects/entry}/.gitignore | 0 .../entry/build-profile.json5 | 43 + .../CommunicationObjects/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 25 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../main/ets/managers/ArrayBufferObject.ets | 152 +- .../src/main/ets/managers/NormalObject.ets | 118 +- .../ets/managers/SharedArrayBufferObject.ets | 120 +- .../entry/src/main/ets/managers/Test.ets | 24 + .../main/ets/managers/TransferabledObject.ets | 132 +- .../src/main/ets/managers/pixelMapTest.ets | 64 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/util/CommonButton.ets | 0 .../entry/src/main/ets/util/resource.ets | 25 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../CommunicationObjects/hvigorfile.ts | 0 .../CommunicationObjects/oh-package.json5 | 25 + .../CommunicationObjects/ohosTest.md | 11 + .../screenshots/CommunicationObjects_1.png | Bin .../screenshots/CommunicationObjects_2.png | Bin .../RulesAndRestrictions/.gitignore | 0 .../RulesAndRestrictions/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../RulesAndRestrictions/README.md | 360 +- .../achievenon/.gitignore | 0 .../achievenon/build-profile.json5 | 84 +- .../achievenon/hvigorfile.ts | 0 .../achievenon/obfuscation-rules.txt | 0 .../achievenon/oh-package.json5 | 50 +- .../achievenonability/AchievenonAbility.ets | 112 +- .../achievenon/src/main/ets/pages/Index.ets | 0 .../achievenon/src/main/module.json5 | 82 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../achievenon/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../achievenon/src/ohosTest/module.json5 | 54 +- .../achievenon/src/test/List.test.ets | 0 .../achievenon/src/test/LocalUnit.test.ets | 0 .../arrowfunctions/.gitignore | 0 .../arrowfunctions/build-profile.json5 | 84 +- .../arrowfunctions/hvigorfile.ts | 0 .../arrowfunctions/obfuscation-rules.txt | 0 .../arrowfunctions/oh-package.json5 | 50 +- .../ArrowfunctionsAbility.ets | 56 - .../src/main/ets/pages/Index.ets | 0 .../arrowfunctions/src/main/module.json5 | 82 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../arrowfunctions/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../arrowfunctions/src/ohosTest/module.json5 | 54 +- .../arrowfunctions/src/test/List.test.ets | 0 .../src/test/LocalUnit.test.ets | 0 .../RulesAndRestrictions/build-profile.json5 | 378 +- .../cannotbeused/.gitignore | 0 .../cannotbeused/build-profile.json5 | 84 +- .../cannotbeused/hvigorfile.ts | 0 .../cannotbeused/obfuscation-rules.txt | 0 .../cannotbeused/oh-package.json5 | 50 +- .../CannotbeusedAbility.ets | 112 +- .../cannotbeused/src/main/ets/pages/Index.ets | 0 .../cannotbeused/src/main/module.json5 | 82 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../cannotbeused/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../cannotbeused/src/ohosTest/module.json5 | 54 +- .../cannotbeused/src/test/List.test.ets | 0 .../cannotbeused/src/test/LocalUnit.test.ets | 0 .../RulesAndRestrictions/code-linter.json5 | 0 .../hvigor/hvigor-config.json5 | 74 +- .../RulesAndRestrictions/hvigorfile.ts | 0 .../inheritedfromnon/.gitignore | 0 .../inheritedfromnon/build-profile.json5 | 84 +- .../inheritedfromnon/hvigorfile.ts | 0 .../inheritedfromnon/obfuscation-rules.txt | 0 .../inheritedfromnon/oh-package.json5 | 50 +- .../src/main/ets/pages/Index.ets | 0 .../inheritedfromnon/src/main/module.json5 | 82 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../src/ohosTest/module.json5 | 54 +- .../inheritedfromnon/src/test/List.test.ets | 0 .../src/test/LocalUnit.test.ets | 0 .../inheritonly/.gitignore | 0 .../inheritonly/build-profile.json5 | 84 +- .../inheritonly/hvigorfile.ts | 0 .../inheritonly/obfuscation-rules.txt | 0 .../inheritonly/oh-package.json5 | 46 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../inheritonly/src/main/ets/pages/Index.ets | 0 .../inheritonly/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../inheritonly/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../inheritonly/src/ohosTest/module.json5 | 52 +- .../inheritonly/src/test/List.test.ets | 0 .../inheritonly/src/test/LocalUnit.test.ets | 0 .../nocalculationsupport/.gitignore | 0 .../nocalculationsupport/build-profile.json5 | 84 +- .../nocalculationsupport/hvigorfile.ts | 0 .../obfuscation-rules.txt | 0 .../nocalculationsupport/oh-package.json5 | 50 +- .../src/main/ets/pages/Index.ets | 0 .../src/main/module.json5 | 82 +- .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../src/ohosTest/module.json5 | 54 +- .../src/test/List.test.ets | 0 .../src/test/LocalUnit.test.ets | 0 .../notallowedInside}/.gitignore | 0 .../notallowedInside/build-profile.json5 | 43 + .../notallowedInside/hvigorfile.ts | 0 .../notallowedInside/obfuscation-rules.txt | 0 .../notallowedInside/oh-package.json5 | 25 + .../src/main/ets/pages/Index.ets | 0 .../notallowedInside/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../src/ohosTest/module.json5 | 27 + .../notallowedInside/src/test/List.test.ets | 0 .../src/test/LocalUnit.test.ets | 0 .../objectliterals}/.gitignore | 0 .../objectliterals/build-profile.json5 | 43 + .../objectliterals/hvigorfile.ts | 0 .../objectliterals/obfuscation-rules.txt | 0 .../objectliterals/oh-package.json5 | 25 + .../src/main/ets/pages/Index.ets | 0 .../objectliterals/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../objectliterals/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../objectliterals/src/ohosTest/module.json5 | 27 + .../objectliterals/src/test/List.test.ets | 0 .../src/test/LocalUnit.test.ets | 0 .../RulesAndRestrictions/oh-package.json5 | 50 +- .../RulesAndRestrictions/ohosTest.md | 38 +- .../screenshots/RulesAndRestrictions_1.png | Bin .../screenshots/RulesAndRestrictions_2.png | Bin .../templatetype}/.gitignore | 0 .../templatetype/build-profile.json5 | 43 + .../templatetype/hvigorfile.ts | 0 .../templatetype/obfuscation-rules.txt | 0 .../templatetype/oh-package.json5 | 25 + .../templatetype/src/main/ets/pages/Index.ets | 0 .../TemplatetypeAbility.ets | 112 +- .../templatetype/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../templatetype/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../templatetype/src/ohosTest/module.json5 | 27 + .../templatetype/src/test/List.test.ets | 0 .../templatetype/src/test/LocalUnit.test.ets | 0 .../typecannot}/.gitignore | 0 .../typecannot/build-profile.json5 | 43 + .../typecannot/hvigorfile.ts | 0 .../typecannot/obfuscation-rules.txt | 0 .../typecannot/oh-package.json5 | 25 + .../typecannot/src/main/ets/pages/Index.ets | 0 .../typecannotability/TypecannotAbility.ets | 112 +- .../typecannot/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../typecannot/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../typecannot/src/ohosTest/module.json5 | 27 + .../typecannot/src/test/List.test.ets | 0 .../typecannot/src/test/LocalUnit.test.ets | 0 .../variablenotsupported}/.gitignore | 0 .../variablenotsupported/build-profile.json5 | 43 + .../variablenotsupported/hvigorfile.ts | 0 .../obfuscation-rules.txt | 0 .../variablenotsupported/oh-package.json5 | 25 + .../src/main/ets/pages/Index.ets | 0 .../src/main/module.json5 | 42 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../src/ohosTest/module.json5 | 27 + .../src/test/List.test.ets | 0 .../src/test/LocalUnit.test.ets | 0 .../variablesupport}/.gitignore | 0 .../variablesupport/build-profile.json5 | 43 + .../variablesupport/hvigorfile.ts | 0 .../variablesupport/obfuscation-rules.txt | 0 .../variablesupport/oh-package.json5 | 25 + .../src/main/ets/pages/Index.ets | 0 .../variablesupport/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../variablesupport/src/ohosTest/module.json5 | 27 + .../variablesupport/src/test/List.test.ets | 0 .../src/test/LocalUnit.test.ets | 0 .../SendableObjectIntroduction/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../SendableObjectIntroduction/README.md | 146 +- .../build-profile.json5 | 122 +- .../class/.gitignore | 0 .../class/BuildProfile.ets | 0 .../class/Index.ets | 66 +- .../class/build-profile.json5 | 92 +- .../class/consumer-rules.txt | 0 .../class/hvigorfile.ts | 0 .../class/obfuscation-rules.txt | 0 .../class/oh-package.json5 | 48 +- .../src/main/ets/components/MainPage.ets | 62 +- .../class/src/main/module.json5 | 50 +- .../main/resources/base/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../class/src/ohosTest/ets/test/List.test.ets | 0 .../class/src/ohosTest/module.json5 | 54 +- .../class/src/test/List.test.ets | 0 .../class/src/test/LocalUnit.test.ets | 0 .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 54 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/managers/classusage.ets | 82 +- .../src/main/ets/managers/functionusage.ets | 160 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/util/CommonButton.ets | 0 .../entry/src/main/ets/util/resource.ets | 48 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../SendableObjectIntroduction/hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../SendableObjectIntroduction/ohosTest.md | 16 +- .../SendableObjectIntroduction_1.png | Bin .../SendableObjectIntroduction_2.png | Bin .../SendableObjectRelated/.gitignore | 0 .../SendableObjectRelated/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../SendableObjectRelated/README.md | 222 +- .../SendableObjectRelated/build-profile.json5 | 114 +- .../SendableObjectRelated/code-linter.json5 | 0 .../SendableObjectRelated/entry/.gitignore | 0 .../entry/build-profile.json5 | 94 +- .../SendableObjectRelated/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../managers/ArktsAsyncLockIntroduction.ets | 142 +- .../managers/ArktsCollectionsIntroduction.ets | 122 +- .../main/ets/managers/ArktsSendableModule.ets | 184 +- .../ets/managers/AsonParsingGeneration.ets | 88 +- .../src/main/ets/managers/SendableFreeze.ets | 112 +- .../entry/src/main/ets/managers/helper.ts | 40 +- .../src/main/ets/managers/sharedModule.ets | 86 +- .../entry/src/main/ets/managers/test.ets | 56 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/util/CommonButton.ets | 0 .../entry/src/main/ets/util/resource.ets | 48 +- .../entry/src/main/ets/workers/Worker.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../SendableObjectRelated/hvigorfile.ts | 0 .../SendableObjectRelated/oh-package.json5 | 50 +- .../SendableObjectRelated/ohosTest.md | 22 +- .../screenshots/SendableObjectRelated_1.png | Bin .../screenshots/SendableObjectRelated_2.png | Bin .../SendableScenarios/.gitignore | 0 .../SendableScenarios/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../SendableScenarios/README.md | 168 +- .../SendableScenarios/bigdata/.gitignore | 0 .../bigdata/build-profile.json5 | 84 +- .../SendableScenarios/bigdata/hvigorfile.ts | 0 .../bigdata/obfuscation-rules.txt | 0 .../bigdata/oh-package.json5 | 46 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../bigdata/src/main/ets/pages/Index.ets | 0 .../bigdata/src/main/ets/pages/sendable.ets | 84 +- .../bigdata/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../bigdata/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../bigdata/src/ohosTest/module.json5 | 52 +- .../bigdata/src/test/List.test.ets | 0 .../bigdata/src/test/LocalUnit.test.ets | 0 .../SendableScenarios/build-profile.json5 | 138 +- .../SendableScenarios/code-linter.json5 | 0 .../crossconcurrency/.gitignore | 0 .../crossconcurrency/build-profile.json5 | 84 +- .../crossconcurrency/hvigorfile.ts | 0 .../crossconcurrency/obfuscation-rules.txt | 0 .../crossconcurrency/oh-package.json5 | 50 +- .../CrossconcurrencyAbility.ets | 56 - .../src/main/ets/pages/Index.ets | 0 .../src/main/ets/pages/sendable.ets | 94 +- .../crossconcurrency/src/main/module.json5 | 82 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../src/ohosTest/module.json5 | 54 +- .../crossconcurrency/src/test/List.test.ets | 0 .../src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../SendableScenarios/hvigorfile.ts | 0 .../SendableScenarios/oh-package.json5 | 50 +- .../SendableScenarios/ohosTest.md | 16 +- .../screenshots/SendableScenarios_1.png | Bin .../screenshots/SendableScenarios_2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 206 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 94 +- .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/managers/IconItemSource.ets | 52 +- .../src/main/ets/managers/IndependentTask.ets | 72 +- .../managers/IndependentTimeConsumingTask.ets | 98 +- .../entry/src/main/ets/managers/MultiTask.ets | 70 +- .../ets/managers/MultiTimeConsumingTasks.ets | 94 +- .../main/ets/managers/TaskSendDataUsage.ets | 0 .../ets/managers/WorkerCallGlobalUsage.ets | 0 .../WorkerCommunicatesWithMainthread.ets | 154 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/util/CommonButton.ets | 0 .../entry/src/main/ets/util/resource.ets | 48 +- .../entry/src/main/ets/workers/Worker.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 22 +- .../InterThreadCommunicationScenario_1.png | Bin .../InterThreadCommunicationScenario_2.png | Bin .../MultiThreadConcurrencyOverview/.gitignore | 0 .../AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../MultiThreadConcurrencyOverview/README.md | 72 + .../build-profile.json5 | 58 + .../code-linter.json5 | 0 .../entry}/.gitignore | 0 .../entry/build-profile.json5 | 43 + .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 25 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../hvigorfile.ts | 0 .../oh-package.json5 | 25 + .../ohosTest.md | 9 + .../MultiThreadConcurrencyOverview_1.png | Bin .../MultiThreadConcurrencyOverview_2.png | Bin .../TaskPoolIntroduction/.gitignore | 0 .../TaskPoolIntroduction/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../TaskPoolIntroduction/README.md | 148 +- .../TaskPoolIntroduction/build-profile.json5 | 114 +- .../TaskPoolIntroduction/code-linter.json5 | 0 .../TaskPoolIntroduction/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../TaskPoolIntroduction/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/managers/Test.ets | 64 +- .../ets/managers/asynchronousfunctions.ets | 176 +- .../src/main/ets/managers/customclasses.ets | 190 +- .../src/main/ets/managers/generaluse.ets | 116 +- .../src/main/ets/managers/returnpromise.ets | 248 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/util/CommonButton.ets | 0 .../entry/src/main/ets/util/resource.ets | 54 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../TaskPoolIntroduction/hvigorfile.ts | 0 .../TaskPoolIntroduction/oh-package.json5 | 50 +- .../TaskPoolIntroduction/ohosTest.md | 20 +- .../screenshots/TaskPoolIntroduction_1.png | Bin .../screenshots/TaskPoolIntroduction_2.png | Bin .../WorkerIntroduction/.gitignore | 0 .../WorkerIntroduction/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../WorkerIntroduction/README.md | 170 +- .../WorkerIntroduction/build-profile.json5 | 122 +- .../WorkerIntroduction/code-linter.json5 | 0 .../WorkerIntroduction/entry/.gitignore | 0 .../entry/build-profile.json5 | 110 +- .../WorkerIntroduction/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../WorkerIntroduction/entry/oh-package.json5 | 56 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/managers/basicusage.ets | 138 +- .../entry/src/main/ets/managers/crosshar.ets | 96 +- .../main/ets/managers/notrecommendedone.ets | 118 +- .../main/ets/managers/notrecommendedtwo.ets | 118 +- .../entry/src/main/ets/managers/recommend.ets | 118 +- .../notrecommendedoneworker/childworker.ets | 62 +- .../notrecommendedoneworker/parentworker.ets | 88 +- .../notrecommendedtwoworker/childworker.ets | 48 +- .../notrecommendedtwoworker/parentworker.ets | 94 +- .../entry/src/main/ets/pages/Index.ets | 0 .../main/ets/recommendworkers/childworker.ets | 60 +- .../ets/recommendworkers/parentworker.ets | 94 +- .../entry/src/main/ets/util/CommonButton.ets | 0 .../entry/src/main/ets/util/resource.ets | 48 +- .../entry/src/main/ets/workers/worker.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../WorkerIntroduction/har/.gitignore | 0 .../WorkerIntroduction/har/BuildProfile.ets | 0 .../WorkerIntroduction/har/Index.ets | 32 +- .../har/build-profile.json5 | 100 +- .../WorkerIntroduction/har/consumer-rules.txt | 0 .../WorkerIntroduction/har/hvigorfile.ts | 0 .../har/obfuscation-rules.txt | 0 .../WorkerIntroduction/har/oh-package.json5 | 48 +- .../har/src/main/ets/components/MainPage.ets | 62 +- .../har/src/main/ets/workers/worker.ets | 0 .../har/src/main/module.json5 | 50 +- .../main/resources/base/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../har/src/ohosTest/ets/test/List.test.ets | 0 .../har/src/ohosTest/module.json5 | 54 +- .../har/src/test/List.test.ets | 0 .../har/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../WorkerIntroduction/hvigorfile.ts | 0 .../WorkerIntroduction/oh-package.json5 | 50 +- .../WorkerIntroduction/ohosTest.md | 22 +- .../screenshots/WorkerIntroduction_1.png | Bin .../screenshots/WorkerIntroduction_2.png | Bin .../JSVMAPI/JsvmDebug}/.gitignore | 0 .../JSVMAPI/JsvmDebug/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../ArkTS/JSVMAPI/JsvmDebug/README.md | 138 + .../JsvmDebug/aboutcodecache}/.gitignore | 0 .../aboutcodecache}/build-profile.json5 | 0 .../JsvmDebug/aboutcodecache}/hvigorfile.ts | 0 .../aboutcodecache}/obfuscation-rules.txt | 0 .../JsvmDebug/aboutcodecache/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../aboutcodecache/src/main/cpp/hello.cpp | 207 + .../cpp/types/libaboutcodecache}/Index.d.ts | 0 .../types/libaboutcodecache/oh-package.json5 | 21 + .../AboutcodecacheAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../aboutcodecache/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 0 .../aboutcodecache/src/ohosTest/module.json5 | 27 + .../JSVMAPI/JsvmDebug/build-profile.json5 | 94 + .../JSVMAPI/JsvmDebug}/code-linter.json5 | 0 .../JsvmDebug/hvigor/hvigor-config.json5 | 37 + .../ArkTS/JSVMAPI/JsvmDebug/hvigorfile.ts | 22 + .../ArkTS/JSVMAPI/JsvmDebug/oh-package.json5 | 25 + .../ArkTS/JSVMAPI/JsvmDebug/ohosTest.md | 11 + .../JsvmDebug/openinspector}/.gitignore | 0 .../openinspector/build-profile.json5 | 54 + .../JsvmDebug/openinspector}/hvigorfile.ts | 0 .../openinspector}/obfuscation-rules.txt | 0 .../JsvmDebug/openinspector/oh-package.json5 | 26 + .../openinspector/src/main/cpp/CMakeLists.txt | 13 + .../openinspector/src/main/cpp/hello.cpp | 163 + .../src/main/cpp/types/libentry}/Index.d.ts | 0 .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../src/main/ets/pages/Index.ets | 43 + .../openinspector/src/main/module.json5 | 78 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 0 .../openinspector/src/ohosTest/module.json5 | 27 + .../JSVMAPI/JsvmDebug/runtimetask}/.gitignore | 0 .../JsvmDebug/runtimetask/build-profile.json5 | 54 + .../JsvmDebug/runtimetask}/hvigorfile.ts | 0 .../runtimetask}/obfuscation-rules.txt | 0 .../JsvmDebug/runtimetask/oh-package.json5 | 26 + .../runtimetask/src/main/cpp/CMakeLists.txt | 13 + .../runtimetask/src/main/cpp/hello.cpp | 425 + .../main/cpp/types/libruntimetask/Index.d.ts | 16 + .../cpp/types/libruntimetask/oh-package.json5 | 0 .../runtimetask/src/main/ets/pages/Index.ets | 43 + .../runtimetaskability/RuntimetaskAbility.ets | 0 .../runtimetask/src/main/module.json5 | 41 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/float.json | 0 .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../runtimetask/src/ohosTest/module.json5 | 26 + .../JsvmDebug/screenshots/JsvmDebug_1.png | Bin .../JsvmDebug/screenshots/JsvmDebug_2.png | Bin .../JSVMAPI/JsvmDebug/snapshot}/.gitignore | 0 .../JsvmDebug/snapshot/build-profile.json5 | 54 + .../JSVMAPI/JsvmDebug/snapshot/hvigorfile.ts | 21 + .../JsvmDebug/snapshot}/obfuscation-rules.txt | 0 .../JsvmDebug/snapshot/oh-package.json5 | 26 + .../snapshot/src/main/cpp/CMakeLists.txt | 13 + .../JsvmDebug/snapshot/src/main/cpp/hello.cpp | 238 + .../src/main/cpp/types/libsnapshot/Index.d.ts | 16 + .../cpp/types/libsnapshot/oh-package.json5 | 21 + .../snapshot/src/main/ets/pages/Index.ets | 43 + .../ets/snapshotability/SnapshotAbility.ets | 112 +- .../JsvmDebug/snapshot/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 0 .../snapshot/src/ohosTest/module.json5 | 27 + .../JSVMAPI/JsvmProcess}/.gitignore | 0 .../JSVMAPI/JsvmProcess/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../ArkTS/JSVMAPI/JsvmProcess/README.md | 76 + .../JSVMAPI/JsvmProcess/build-profile.json5 | 58 + .../JSVMAPI/JsvmProcess}/code-linter.json5 | 0 .../JSVMAPI/JsvmProcess/entry}/.gitignore | 0 .../JsvmProcess/entry/build-profile.json5 | 55 + .../JSVMAPI/JsvmProcess/entry}/hvigorfile.ts | 0 .../JsvmProcess/entry}/obfuscation-rules.txt | 0 .../JsvmProcess/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 14 + .../JsvmProcess/entry/src/main/cpp/hello.cpp | 162 + .../src/main/cpp/types/libentry/Index.d.ts | 18 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 45 + .../JsvmProcess/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 16 + .../main/resources/zh_CN/element/string.json | 16 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 27 + .../JsvmProcess/hvigor/hvigor-config.json5 | 37 + .../JSVMAPI/JsvmProcess}/hvigorfile.ts | 0 .../JSVMAPI/JsvmProcess/oh-package.json5 | 25 + .../ArkTS/JSVMAPI/JsvmProcess/ohosTest.md | 8 + .../JsvmProcess/screenshots/JsvmProcess_1.png | Bin .../JsvmProcess/screenshots/JsvmProcess_2.png | Bin .../JsvmUsageGuide/JsvmAboutArray}/.gitignore | 0 .../JsvmAboutArray/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmUsageGuide/JsvmAboutArray/README.md | 333 + .../JsvmAboutArray/build-profile.json5 | 214 + .../JsvmAboutArray}/code-linter.json5 | 0 .../JsvmAboutArray/createarray}/.gitignore | 0 .../createarray/build-profile.json5 | 54 + .../JsvmAboutArray/createarray}/hvigorfile.ts | 0 .../createarray}/obfuscation-rules.txt | 0 .../createarray/oh-package.json5 | 26 + .../createarray/src/main/cpp/CMakeLists.txt | 14 + .../createarray/src/main/cpp/hello.cpp | 168 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../createarray/src/main/ets/pages/Index.ets | 43 + .../createarray/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 0 .../createarray/src/ohosTest/module.json5 | 27 + .../createarraywithlength}/.gitignore | 0 .../createarraywithlength/build-profile.json5 | 54 + .../createarraywithlength}/hvigorfile.ts | 0 .../obfuscation-rules.txt | 0 .../createarraywithlength/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../src/main/cpp/hello.cpp | 175 + .../types/libcreatearraywithlength/Index.d.ts | 16 + .../libcreatearraywithlength/oh-package.json5 | 21 + .../CreatearraywithlengthAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 0 .../src/ohosTest/module.json5 | 27 + .../JsvmAboutArray/createdataview}/.gitignore | 0 .../createdataview/build-profile.json5 | 54 + .../createdataview}/hvigorfile.ts | 0 .../createdataview}/obfuscation-rules.txt | 0 .../createdataview/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../createdataview/src/main/cpp/hello.cpp | 225 + .../cpp/types/libcreatedataview/Index.d.ts | 16 + .../types/libcreatedataview/oh-package.json5 | 21 + .../CreatedataviewAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createdataview/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 54 + .../src/ohosTest/ets/test/List.test.ets | 0 .../createdataview/src/ohosTest/module.json5 | 27 + .../createtypedarray}/.gitignore | 0 .../createtypedarray/build-profile.json5 | 54 + .../createtypedarray}/hvigorfile.ts | 0 .../createtypedarray/obfuscation-rules.txt | 23 + .../createtypedarray/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../createtypedarray/src/main/cpp/hello.cpp | 218 + .../cpp/types/libcreatetypedarray/Index.d.ts | 16 + .../libcreatetypedarray/oh-package.json5 | 21 + .../CreatetypedarrayAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createtypedarray/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 0 .../src/ohosTest/module.json5 | 27 + .../JsvmAboutArray/deleteelement}/.gitignore | 0 .../deleteelement/build-profile.json5 | 54 + .../deleteelement}/hvigorfile.ts | 0 .../deleteelement/obfuscation-rules.txt | 23 + .../deleteelement/oh-package.json5 | 26 + .../deleteelement/src/main/cpp/CMakeLists.txt | 13 + .../deleteelement/src/main/cpp/hello.cpp | 169 + .../cpp/types/libdeleteelement/Index.d.ts | 16 + .../types/libdeleteelement/oh-package.json5 | 21 + .../DeleteelementAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../deleteelement/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 0 .../deleteelement/src/ohosTest/module.json5 | 27 + .../JsvmAboutArray/getarraylength}/.gitignore | 0 .../getarraylength/build-profile.json5 | 54 + .../getarraylength}/hvigorfile.ts | 0 .../getarraylength/obfuscation-rules.txt | 23 + .../getarraylength/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../getarraylength/src/main/cpp/hello.cpp | 167 + .../cpp/types/libgetarraylength/Index.d.ts | 16 + .../types/libgetarraylength/oh-package.json5 | 21 + .../GetarraylengthAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../getarraylength/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getarraylength/src/ohosTest/module.json5 | 27 + .../getdataviewinfo}/.gitignore | 0 .../getdataviewinfo/build-profile.json5 | 54 + .../getdataviewinfo}/hvigorfile.ts | 0 .../getdataviewinfo/obfuscation-rules.txt | 23 + .../getdataviewinfo/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../getdataviewinfo/src/main/cpp/hello.cpp | 218 + .../cpp/types/libgetdataviewinfo/Index.d.ts | 16 + .../types/libgetdataviewinfo/oh-package.json5 | 21 + .../GetdataviewinfoAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../getdataviewinfo/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getdataviewinfo/src/ohosTest/module.json5 | 27 + .../JsvmAboutArray/getelement}/.gitignore | 0 .../getelement/build-profile.json5 | 54 + .../JsvmAboutArray/getelement}/hvigorfile.ts | 0 .../getelement/obfuscation-rules.txt | 23 + .../getelement/oh-package.json5 | 26 + .../getelement/src/main/cpp/CMakeLists.txt | 13 + .../getelement/src/main/cpp/hello.cpp | 166 + .../main/cpp/types/libgetelement/Index.d.ts | 16 + .../cpp/types/libgetelement/oh-package.json5 | 21 + .../getelementability/GetelementAbility.ets | 112 +- .../getelement/src/main/ets/pages/Index.ets | 43 + .../getelement/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getelement/src/ohosTest/module.json5 | 28 + .../gettypedarrayinfo}/.gitignore | 0 .../gettypedarrayinfo/build-profile.json5 | 54 + .../gettypedarrayinfo}/hvigorfile.ts | 0 .../gettypedarrayinfo/obfuscation-rules.txt | 23 + .../gettypedarrayinfo/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../gettypedarrayinfo/src/main/cpp/hello.cpp | 227 + .../cpp/types/libgettypedarrayinfo/Index.d.ts | 16 + .../libgettypedarrayinfo/oh-package.json5 | 21 + .../GettypedarrayinfoAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../gettypedarrayinfo/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 28 + .../JsvmAboutArray/haselement}/.gitignore | 0 .../haselement/build-profile.json5 | 54 + .../JsvmAboutArray/haselement}/hvigorfile.ts | 0 .../haselement/obfuscation-rules.txt | 23 + .../haselement/oh-package.json5 | 26 + .../haselement/src/main/cpp/CMakeLists.txt | 13 + .../haselement/src/main/cpp/hello.cpp | 169 + .../main/cpp/types/libhaselement/Index.d.ts | 16 + .../cpp/types/libhaselement/oh-package.json5 | 21 + .../haselementability/HaselementAbility.ets | 112 +- .../haselement/src/main/ets/pages/Index.ets | 43 + .../haselement/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../haselement/src/ohosTest/module.json5 | 28 + .../JsvmAboutArray/hvigor/hvigor-config.json5 | 37 + .../JsvmAboutArray}/hvigorfile.ts | 0 .../JsvmAboutArray/isarray}/.gitignore | 0 .../isarray/build-profile.json5 | 54 + .../JsvmAboutArray/isarray}/hvigorfile.ts | 0 .../isarray/obfuscation-rules.txt | 23 + .../JsvmAboutArray/isarray/oh-package.json5 | 26 + .../isarray/src/main/cpp/CMakeLists.txt | 13 + .../isarray/src/main/cpp/hello.cpp | 163 + .../src/main/cpp/types/libisarray/Index.d.ts | 16 + .../cpp/types/libisarray/oh-package.json5 | 21 + .../ets/isarrayability/IsarrayAbility.ets | 112 +- .../isarray/src/main/ets/pages/Index.ets | 43 + .../isarray/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../isarray/src/ohosTest/module.json5 | 28 + .../JsvmAboutArray/isdataview}/.gitignore | 0 .../isdataview/build-profile.json5 | 54 + .../JsvmAboutArray/isdataview}/hvigorfile.ts | 0 .../isdataview/obfuscation-rules.txt | 23 + .../isdataview/oh-package.json5 | 26 + .../isdataview/src/main/cpp/CMakeLists.txt | 13 + .../isdataview/src/main/cpp/hello.cpp | 165 + .../main/cpp/types/libisdataview/Index.d.ts | 16 + .../cpp/types/libisdataview/oh-package.json5 | 21 + .../isdataviewability/IsdataviewAbility.ets | 112 +- .../isdataview/src/main/ets/pages/Index.ets | 43 + .../isdataview/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../isdataview/src/ohosTest/module.json5 | 28 + .../JsvmAboutArray/istypedarray}/.gitignore | 0 .../istypedarray/build-profile.json5 | 54 + .../istypedarray}/hvigorfile.ts | 0 .../istypedarray/obfuscation-rules.txt | 23 + .../istypedarray/oh-package.json5 | 26 + .../istypedarray/src/main/cpp/CMakeLists.txt | 13 + .../istypedarray/src/main/cpp/hello.cpp | 162 + .../main/cpp/types/libistypedarray/Index.d.ts | 16 + .../types/libistypedarray/oh-package.json5 | 21 + .../IstypedarrayAbility.ets | 112 +- .../istypedarray/src/main/ets/pages/Index.ets | 43 + .../istypedarray/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../istypedarray/src/ohosTest/module.json5 | 28 + .../JsvmAboutArray/oh-package.json5 | 25 + .../JsvmUsageGuide/JsvmAboutArray/ohosTest.md | 21 + .../screenshots/JsvmAboutArray_1.png | Bin .../screenshots/JsvmAboutArray_2.png | Bin .../JsvmAboutArray/setelement}/.gitignore | 0 .../setelement/build-profile.json5 | 54 + .../JsvmAboutArray/setelement}/hvigorfile.ts | 0 .../setelement/obfuscation-rules.txt | 23 + .../setelement/oh-package.json5 | 26 + .../setelement/src/main/cpp/CMakeLists.txt | 13 + .../setelement/src/main/cpp/hello.cpp | 162 + .../main/cpp/types/libsetelement/Index.d.ts | 16 + .../cpp/types/libsetelement/oh-package.json5 | 21 + .../setelement/src/main/ets/pages/Index.ets | 43 + .../setelementability/SetelementAbility.ets | 112 +- .../setelement/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../setelement/src/ohosTest/module.json5 | 28 + .../JsvmAboutArraybuffer}/.gitignore | 0 .../JsvmAboutArraybuffer/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmAboutArraybuffer/README.md | 133 + .../JsvmAboutArraybuffer/build-profile.json5 | 94 + .../JsvmAboutArraybuffer}/code-linter.json5 | 0 .../createarraybuffer}/.gitignore | 0 .../createarraybuffer/build-profile.json5 | 54 + .../createarraybuffer}/hvigorfile.ts | 0 .../createarraybuffer/obfuscation-rules.txt | 23 + .../createarraybuffer/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../createarraybuffer/src/main/cpp/hello.cpp | 168 + .../cpp/types/libcreatearraybuffer/Index.d.ts | 16 + .../libcreatearraybuffer/oh-package.json5 | 21 + .../CreatearraybufferAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createarraybuffer/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../getarraybufferinfo}/.gitignore | 0 .../getarraybufferinfo/build-profile.json5 | 54 + .../getarraybufferinfo}/hvigorfile.ts | 0 .../getarraybufferinfo/obfuscation-rules.txt | 23 + .../getarraybufferinfo/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../getarraybufferinfo/src/main/cpp/hello.cpp | 168 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../src/main/ets/pages/Index.ets | 43 + .../getarraybufferinfo/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../hvigor/hvigor-config.json5 | 37 + .../JsvmAboutArraybuffer}/hvigorfile.ts | 0 .../isarraybuffer}/.gitignore | 0 .../isarraybuffer/build-profile.json5 | 54 + .../isarraybuffer}/hvigorfile.ts | 0 .../isarraybuffer/obfuscation-rules.txt | 23 + .../isarraybuffer/oh-package.json5 | 26 + .../isarraybuffer/src/main/cpp/CMakeLists.txt | 14 + .../isarraybuffer/src/main/cpp/hello.cpp | 163 + .../cpp/types/libisarraybuffer/Index.d.ts | 16 + .../types/libisarraybuffer/oh-package.json5 | 21 + .../IsarraybufferAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../isarraybuffer/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../isarraybuffer/src/ohosTest/module.json5 | 27 + .../isdetachedarraybuffer}/.gitignore | 0 .../isdetachedarraybuffer/build-profile.json5 | 54 + .../isdetachedarraybuffer}/hvigorfile.ts | 0 .../obfuscation-rules.txt | 23 + .../isdetachedarraybuffer/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../src/main/cpp/hello.cpp | 182 + .../types/libisdetachedarraybuffer/Index.d.ts | 16 + .../libisdetachedarraybuffer/oh-package.json5 | 21 + .../IsdetachedarraybufferAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../JsvmAboutArraybuffer/oh-package.json5 | 25 + .../JsvmAboutArraybuffer/ohosTest.md | 11 + .../screenshots/JsvmAboutArraybuffer_1.png | Bin .../screenshots/JsvmAboutArraybuffer_2.png | Bin .../JsvmAboutBigint}/.gitignore | 0 .../JsvmAboutBigint/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmUsageGuide/JsvmAboutBigint/README.md | 173 + .../JsvmAboutBigint/build-profile.json5 | 118 + .../JsvmAboutBigint}/code-linter.json5 | 0 .../createbigintint64}/.gitignore | 0 .../createbigintint64/build-profile.json5 | 54 + .../createbigintint64}/hvigorfile.ts | 0 .../createbigintint64/obfuscation-rules.txt | 23 + .../createbigintint64/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../createbigintint64/src/main/cpp/hello.cpp | 156 + .../cpp/types/libcreatebigintint64/Index.d.ts | 16 + .../libcreatebigintint64/oh-package.json5 | 21 + .../Createbigintint64Ability.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createbigintint64/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../createbigintuint64}/.gitignore | 0 .../createbigintuint64/build-profile.json5 | 54 + .../createbigintuint64}/hvigorfile.ts | 0 .../createbigintuint64/obfuscation-rules.txt | 23 + .../createbigintuint64/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../createbigintuint64/src/main/cpp/hello.cpp | 157 + .../types/libcreatebigintuint64/Index.d.ts | 16 + .../libcreatebigintuint64/oh-package.json5 | 21 + .../Createbigintuint64Ability.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createbigintuint64/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../createbigintwords}/.gitignore | 0 .../createbigintwords/build-profile.json5 | 54 + .../createbigintwords}/hvigorfile.ts | 0 .../createbigintwords/obfuscation-rules.txt | 23 + .../createbigintwords/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../createbigintwords/src/main/cpp/hello.cpp | 159 + .../cpp/types/libcreatebigintwords/Index.d.ts | 16 + .../libcreatebigintwords/oh-package.json5 | 21 + .../CreatebigintwordsAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createbigintwords/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../getvaluebigintint64}/.gitignore | 0 .../getvaluebigintint64/build-profile.json5 | 54 + .../getvaluebigintint64}/hvigorfile.ts | 0 .../getvaluebigintint64/obfuscation-rules.txt | 23 + .../getvaluebigintint64/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../src/main/cpp/hello.cpp | 163 + .../types/libgetvaluebigintint64/Index.d.ts | 16 + .../libgetvaluebigintint64/oh-package.json5 | 21 + .../Getvaluebigintint64Ability.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../getvaluebigintint64/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../getvaluebigintuint64}/.gitignore | 0 .../getvaluebigintuint64/build-profile.json5 | 54 + .../getvaluebigintuint64}/hvigorfile.ts | 0 .../obfuscation-rules.txt | 23 + .../getvaluebigintuint64/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../src/main/cpp/hello.cpp | 163 + .../types/libgetvaluebigintuint64/Index.d.ts | 16 + .../libgetvaluebigintuint64/oh-package.json5 | 21 + .../Getvaluebigintuint64Ability.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../getvaluebigintwords}/.gitignore | 0 .../getvaluebigintwords/build-profile.json5 | 54 + .../getvaluebigintwords}/hvigorfile.ts | 0 .../getvaluebigintwords/obfuscation-rules.txt | 23 + .../getvaluebigintwords/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../src/main/cpp/hello.cpp | 179 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../src/main/ets/pages/Index.ets | 43 + .../getvaluebigintwords/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../hvigor/hvigor-config.json5 | 37 + .../JsvmAboutBigint}/hvigorfile.ts | 0 .../JsvmAboutBigint/oh-package.json5 | 25 + .../JsvmAboutBigint/ohosTest.md | 13 + .../screenshots/JsvmAboutBigint_1.png | Bin .../screenshots/JsvmAboutBigint_2.png | Bin .../JsvmUsageGuide/JsvmAboutClass}/.gitignore | 0 .../JsvmAboutClass/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmUsageGuide/JsvmAboutClass/README.md | 113 + .../JsvmAboutClass/build-profile.json5 | 82 + .../JsvmAboutClass}/code-linter.json5 | 0 .../JsvmAboutClass/defineclass}/.gitignore | 0 .../defineclass/build-profile.json5 | 54 + .../JsvmAboutClass/defineclass/hvigorfile.ts | 21 + .../defineclass/obfuscation-rules.txt | 23 + .../defineclass/oh-package.json5 | 26 + .../defineclass/src/main/cpp/CMakeLists.txt | 14 + .../defineclass/src/main/cpp/hello.cpp | 207 + .../main/cpp/types/libdefineclass/Index.d.ts | 16 + .../cpp/types/libdefineclass/oh-package.json5 | 21 + .../defineclassability/DefineclassAbility.ets | 112 +- .../defineclass/src/main/ets/pages/Index.ets | 43 + .../defineclass/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 20 + .../defineclass/src/ohosTest/module.json5 | 27 + .../JsvmAboutClass/hvigor/hvigor-config.json5 | 37 + .../JsvmAboutClass}/hvigorfile.ts | 0 .../JsvmAboutClass/newinstance}/.gitignore | 0 .../newinstance/build-profile.json5 | 54 + .../JsvmAboutClass/newinstance/hvigorfile.ts | 21 + .../newinstance/obfuscation-rules.txt | 23 + .../newinstance/oh-package.json5 | 26 + .../newinstance/src/main/cpp/CMakeLists.txt | 14 + .../newinstance/src/main/cpp/hello.cpp | 176 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../newinstance/src/main/ets/pages/Index.ets | 43 + .../newinstance/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 20 + .../newinstance/src/ohosTest/module.json5 | 27 + .../JsvmAboutClass/oh-package.json5 | 25 + .../JsvmUsageGuide/JsvmAboutClass/ohosTest.md | 10 + .../JsvmAboutClass/removewrap}/.gitignore | 0 .../removewrap/build-profile.json5 | 54 + .../JsvmAboutClass/removewrap/hvigorfile.ts | 21 + .../removewrap/obfuscation-rules.txt | 23 + .../removewrap/oh-package.json5 | 26 + .../removewrap/src/main/cpp/CMakeLists.txt | 14 + .../removewrap/src/main/cpp/hello.cpp | 209 + .../main/cpp/types/libremovewrap/Index.d.ts | 16 + .../cpp/types/libremovewrap/oh-package.json5 | 21 + .../removewrap/src/main/ets/pages/Index.ets | 43 + .../removewrapability/RemovewrapAbility.ets | 112 +- .../removewrap/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 20 + .../removewrap/src/ohosTest/module.json5 | 27 + .../screenshots/JsvmAboutClass_1.png | Bin .../screenshots/JsvmAboutClass_2.png | Bin .../JsvmUsageGuide/JsvmAboutDate}/.gitignore | 0 .../JsvmAboutDate/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmUsageGuide/JsvmAboutDate/README.md | 113 + .../JsvmAboutDate/build-profile.json5 | 82 + .../JsvmAboutDate}/code-linter.json5 | 0 .../JsvmAboutDate/createdate/.gitignore | 6 + .../createdate/build-profile.json5 | 54 + .../JsvmAboutDate/createdate/hvigorfile.ts | 21 + .../createdate/obfuscation-rules.txt | 23 + .../JsvmAboutDate/createdate/oh-package.json5 | 26 + .../createdate/src/main/cpp/CMakeLists.txt | 14 + .../createdate/src/main/cpp/hello.cpp | 170 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../createdate/src/main/ets/pages/Index.ets | 43 + .../createdate/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createdate/src/ohosTest/module.json5 | 27 + .../JsvmAboutDate/getdatevalue/.gitignore | 6 + .../getdatevalue/build-profile.json5 | 54 + .../JsvmAboutDate/getdatevalue/hvigorfile.ts | 21 + .../getdatevalue/obfuscation-rules.txt | 23 + .../getdatevalue/oh-package.json5 | 26 + .../getdatevalue/src/main/cpp/CMakeLists.txt | 14 + .../getdatevalue/src/main/cpp/hello.cpp | 163 + .../main/cpp/types/libgetdatevalue/Index.d.ts | 16 + .../types/libgetdatevalue/oh-package.json5 | 21 + .../GetdatevalueAbility.ets | 112 +- .../getdatevalue/src/main/ets/pages/Index.ets | 43 + .../getdatevalue/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getdatevalue/src/ohosTest/module.json5 | 27 + .../JsvmAboutDate/hvigor/hvigor-config.json5 | 37 + .../JsvmAboutDate}/hvigorfile.ts | 0 .../JsvmAboutDate/isdate/.gitignore | 6 + .../JsvmAboutDate/isdate/build-profile.json5 | 54 + .../JsvmAboutDate/isdate/hvigorfile.ts | 21 + .../isdate/obfuscation-rules.txt | 23 + .../JsvmAboutDate/isdate/oh-package.json5 | 26 + .../isdate/src/main/cpp/CMakeLists.txt | 14 + .../isdate/src/main/cpp/hello.cpp | 155 + .../src/main/cpp/types/libisdate/Index.d.ts | 16 + .../main/cpp/types/libisdate/oh-package.json5 | 21 + .../main/ets/isdateability/IsdateAbility.ets | 112 +- .../isdate/src/main/ets/pages/Index.ets | 43 + .../isdate/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../isdate/src/ohosTest/module.json5 | 27 + .../JsvmAboutDate/oh-package.json5 | 25 + .../JsvmUsageGuide/JsvmAboutDate/ohosTest.md | 10 + .../screenshots/JsvmAboutDate_1.png | Bin .../screenshots/JsvmAboutDate_2.png | Bin .../JsvmAboutObject}/.gitignore | 0 .../JsvmAboutObject/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmUsageGuide/JsvmAboutObject/README.md | 273 + .../JsvmAboutObject/build-profile.json5 | 178 + .../checkobjecttypetag/.gitignore | 6 + .../checkobjecttypetag/build-profile.json5 | 54 + .../checkobjecttypetag/hvigorfile.ts | 21 + .../checkobjecttypetag/obfuscation-rules.txt | 23 + .../checkobjecttypetag/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../checkobjecttypetag/src/main/cpp/hello.cpp | 205 + .../types/libcheckobjecttypetag/Index.d.ts | 16 + .../libcheckobjecttypetag/oh-package.json5 | 21 + .../CheckobjecttypetagAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../checkobjecttypetag/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../JsvmAboutObject}/code-linter.json5 | 0 .../JsvmAboutObject/createexternal/.gitignore | 6 + .../createexternal/build-profile.json5 | 54 + .../createexternal/hvigorfile.ts | 21 + .../createexternal/obfuscation-rules.txt | 23 + .../createexternal/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../createexternal/src/main/cpp/hello.cpp | 168 + .../cpp/types/libcreateexternal/Index.d.ts | 16 + .../types/libcreateexternal/oh-package.json5 | 21 + .../CreateexternalAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createexternal/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createexternal/src/ohosTest/module.json5 | 27 + .../JsvmAboutObject/createobject/.gitignore | 6 + .../createobject/build-profile.json5 | 54 + .../createobject/hvigorfile.ts | 21 + .../createobject/obfuscation-rules.txt | 23 + .../createobject/oh-package.json5 | 26 + .../createobject/src/main/cpp/CMakeLists.txt | 14 + .../createobject/src/main/cpp/hello.cpp | 164 + .../main/cpp/types/libcreateobject/Index.d.ts | 16 + .../types/libcreateobject/oh-package.json5 | 21 + .../CreateobjectAbility.ets | 112 +- .../createobject/src/main/ets/pages/Index.ets | 43 + .../createobject/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createobject/src/ohosTest/module.json5 | 27 + .../JsvmAboutObject/createsymbol/.gitignore | 6 + .../createsymbol/build-profile.json5 | 54 + .../createsymbol/hvigorfile.ts | 21 + .../createsymbol/obfuscation-rules.txt | 23 + .../createsymbol/oh-package.json5 | 26 + .../createsymbol/src/main/cpp/CMakeLists.txt | 13 + .../createsymbol/src/main/cpp/hello.cpp | 159 + .../main/cpp/types/libcreatesymbol/Index.d.ts | 16 + .../types/libcreatesymbol/oh-package.json5 | 21 + .../CreatesymbolAbility.ets | 112 +- .../createsymbol/src/main/ets/pages/Index.ets | 43 + .../createsymbol/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createsymbol/src/ohosTest/module.json5 | 27 + .../JsvmAboutObject/getprototype/.gitignore | 6 + .../getprototype/build-profile.json5 | 54 + .../getprototype/hvigorfile.ts | 21 + .../getprototype/obfuscation-rules.txt | 23 + .../getprototype/oh-package.json5 | 26 + .../getprototype/src/main/cpp/CMakeLists.txt | 14 + .../getprototype/src/main/cpp/hello.cpp | 159 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../getprototype/src/main/ets/pages/Index.ets | 43 + .../getprototype/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getprototype/src/ohosTest/module.json5 | 27 + .../getvalueexternal/.gitignore | 6 + .../getvalueexternal/build-profile.json5 | 54 + .../getvalueexternal/hvigorfile.ts | 21 + .../getvalueexternal/obfuscation-rules.txt | 23 + .../getvalueexternal/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../getvalueexternal/src/main/cpp/hello.cpp | 166 + .../cpp/types/libgetvalueexternal/Index.d.ts | 16 + .../libgetvalueexternal/oh-package.json5 | 21 + .../GetvalueexternalAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../getvalueexternal/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../hvigor/hvigor-config.json5 | 37 + .../JsvmAboutObject}/hvigorfile.ts | 0 .../JsvmAboutObject/instanceof/.gitignore | 6 + .../instanceof/build-profile.json5 | 54 + .../JsvmAboutObject/instanceof/hvigorfile.ts | 21 + .../instanceof/obfuscation-rules.txt | 23 + .../instanceof/oh-package.json5 | 26 + .../instanceof/src/main/cpp/CMakeLists.txt | 13 + .../instanceof/src/main/cpp/hello.cpp | 169 + .../main/cpp/types/libinstanceof/Index.d.ts | 16 + .../cpp/types/libinstanceof/oh-package.json5 | 21 + .../instanceofability/InstanceofAbility.ets | 112 +- .../instanceof/src/main/ets/pages/Index.ets | 43 + .../instanceof/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../instanceof/src/ohosTest/module.json5 | 28 + .../JsvmAboutObject/objectfreeze/.gitignore | 6 + .../objectfreeze/build-profile.json5 | 54 + .../objectfreeze/hvigorfile.ts | 21 + .../objectfreeze/obfuscation-rules.txt | 23 + .../objectfreeze/oh-package.json5 | 26 + .../objectfreeze/src/main/cpp/CMakeLists.txt | 14 + .../objectfreeze/src/main/cpp/hello.cpp | 163 + .../main/cpp/types/libobjectfreeze/Index.d.ts | 16 + .../types/libobjectfreeze/oh-package.json5 | 21 + .../ObjectfreezeAbility.ets | 112 +- .../objectfreeze/src/main/ets/pages/Index.ets | 43 + .../objectfreeze/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../objectfreeze/src/ohosTest/module.json5 | 28 + .../JsvmAboutObject/objectseal/.gitignore | 6 + .../objectseal/build-profile.json5 | 54 + .../JsvmAboutObject/objectseal/hvigorfile.ts | 21 + .../objectseal/obfuscation-rules.txt | 23 + .../objectseal/oh-package.json5 | 26 + .../objectseal/src/main/cpp/CMakeLists.txt | 14 + .../objectseal/src/main/cpp/hello.cpp | 176 + .../main/cpp/types/libobjectseal/Index.d.ts | 16 + .../cpp/types/libobjectseal/oh-package.json5 | 21 + .../objectsealability/ObjectsealAbility.ets | 112 +- .../objectseal/src/main/ets/pages/Index.ets | 43 + .../objectseal/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | 0 .../main/resources/base/media/foreground.png | 0 .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | 0 .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../objectseal/src/ohosTest/module.json5 | 28 + .../JsvmAboutObject/oh-package.json5 | 25 + .../JsvmAboutObject/ohosTest.md | 18 + .../screenshots/JsvmAboutObject_1.png | Bin .../screenshots/JsvmAboutObject_2.png | Bin .../JsvmAboutObject/symbolfor/.gitignore | 6 + .../symbolfor/build-profile.json5 | 54 + .../JsvmAboutObject/symbolfor/hvigorfile.ts | 21 + .../symbolfor/obfuscation-rules.txt | 23 + .../symbolfor/oh-package.json5 | 26 + .../symbolfor/src/main/cpp/CMakeLists.txt | 13 + .../symbolfor/src/main/cpp/hello.cpp | 166 + .../main/cpp/types/libsymbolfor/Index.d.ts | 16 + .../cpp/types/libsymbolfor/oh-package.json5 | 21 + .../symbolfor/src/main/ets/pages/Index.ets | 43 + .../ets/symbolforability/SymbolforAbility.ets | 112 +- .../symbolfor/src/main/module.json5 | 43 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../symbolfor/src/ohosTest/module.json5 | 28 + .../JsvmAboutObject/typeof/.gitignore | 6 + .../typeof/build-profile.json5 | 54 + .../JsvmAboutObject/typeof/hvigorfile.ts | 21 + .../typeof/obfuscation-rules.txt | 23 + .../JsvmAboutObject/typeof/oh-package.json5 | 26 + .../typeof/src/main/cpp/CMakeLists.txt | 13 + .../typeof/src/main/cpp/hello.cpp | 199 + .../src/main/cpp/types/libtypeof/Index.d.ts | 16 + .../main/cpp/types/libtypeof/oh-package.json5 | 21 + .../typeof/src/main/ets/pages/Index.ets | 43 + .../main/ets/typeofability/TypeofAbility.ets | 112 +- .../typeof/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../typeof/src/ohosTest/module.json5 | 28 + .../JsvmAboutPrimitive}/.gitignore | 0 .../JsvmAboutPrimitive/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmAboutPrimitive/README.md | 233 + .../JsvmAboutPrimitive/build-profile.json5 | 154 + .../JsvmAboutPrimitive}/code-linter.json5 | 0 .../coercetobool/.gitignore | 6 + .../coercetobool/build-profile.json5 | 54 + .../coercetobool/hvigorfile.ts | 21 + .../coercetobool/obfuscation-rules.txt | 23 + .../coercetobool/oh-package.json5 | 26 + .../coercetobool/src/main/cpp/CMakeLists.txt | 14 + .../coercetobool/src/main/cpp/hello.cpp | 159 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../coercetobool/src/main/ets/pages/Index.ets | 43 + .../coercetobool/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../coercetobool/src/ohosTest/module.json5 | 27 + .../coercetonumber/.gitignore | 6 + .../coercetonumber/build-profile.json5 | 54 + .../coercetonumber/hvigorfile.ts | 21 + .../coercetonumber/obfuscation-rules.txt | 23 + .../coercetonumber/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../coercetonumber/src/main/cpp/hello.cpp | 159 + .../cpp/types/libcoercetonumber/Index.d.ts | 16 + .../types/libcoercetonumber/oh-package.json5 | 21 + .../CoercetonumberAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../coercetonumber/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../coercetonumber/src/ohosTest/module.json5 | 27 + .../coercetoobject/.gitignore | 6 + .../coercetoobject/build-profile.json5 | 54 + .../coercetoobject/hvigorfile.ts | 21 + .../coercetoobject/obfuscation-rules.txt | 23 + .../coercetoobject/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../coercetoobject/src/main/cpp/hello.cpp | 158 + .../cpp/types/libcoercetoobject/Index.d.ts | 16 + .../types/libcoercetoobject/oh-package.json5 | 21 + .../CoercetoobjectAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../coercetoobject/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../coercetoobject/src/ohosTest/module.json5 | 27 + .../coercetostring/.gitignore | 6 + .../coercetostring/build-profile.json5 | 54 + .../coercetostring/hvigorfile.ts | 21 + .../coercetostring/obfuscation-rules.txt | 23 + .../coercetostring/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../coercetostring/src/main/cpp/hello.cpp | 158 + .../cpp/types/libcoercetostring/Index.d.ts | 16 + .../types/libcoercetostring/oh-package.json5 | 21 + .../CoercetostringAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../coercetostring/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../coercetostring/src/ohosTest/module.json5 | 27 + .../JsvmAboutPrimitive/getboolean/.gitignore | 6 + .../getboolean/build-profile.json5 | 54 + .../getboolean/hvigorfile.ts | 21 + .../getboolean/obfuscation-rules.txt | 23 + .../getboolean/oh-package.json5 | 26 + .../getboolean/src/main/cpp/CMakeLists.txt | 13 + .../getboolean/src/main/cpp/hello.cpp | 172 + .../main/cpp/types/libgetboolean/Index.d.ts | 16 + .../cpp/types/libgetboolean/oh-package.json5 | 21 + .../getbooleanability/GetbooleanAbility.ets | 112 +- .../getboolean/src/main/ets/pages/Index.ets | 43 + .../getboolean/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getboolean/src/ohosTest/module.json5 | 27 + .../JsvmAboutPrimitive/getglobal/.gitignore | 6 + .../getglobal/build-profile.json5 | 54 + .../getglobal/hvigorfile.ts | 21 + .../getglobal/obfuscation-rules.txt | 23 + .../getglobal/oh-package.json5 | 26 + .../getglobal/src/main/cpp/CMakeLists.txt | 13 + .../getglobal/src/main/cpp/hello.cpp | 158 + .../main/cpp/types/libgetglobal/Index.d.ts | 16 + .../cpp/types/libgetglobal/oh-package.json5 | 21 + .../ets/getglobalability/GetglobalAbility.ets | 112 +- .../getglobal/src/main/ets/pages/Index.ets | 43 + .../getglobal/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getglobal/src/ohosTest/module.json5 | 28 + .../JsvmAboutPrimitive/getnull/.gitignore | 6 + .../getnull/build-profile.json5 | 54 + .../JsvmAboutPrimitive/getnull/hvigorfile.ts | 21 + .../getnull/obfuscation-rules.txt | 23 + .../getnull/oh-package.json5 | 26 + .../getnull/src/main/cpp/CMakeLists.txt | 13 + .../getnull/src/main/cpp/hello.cpp | 154 + .../src/main/cpp/types/libgetnull/Index.d.ts | 16 + .../cpp/types/libgetnull/oh-package.json5 | 21 + .../ets/getnullability/GetnullAbility.ets | 112 +- .../getnull/src/main/ets/pages/Index.ets | 43 + .../getnull/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getnull/src/ohosTest/module.json5 | 28 + .../getundefined/.gitignore | 6 + .../getundefined/build-profile.json5 | 54 + .../getundefined/hvigorfile.ts | 21 + .../getundefined/obfuscation-rules.txt | 23 + .../getundefined/oh-package.json5 | 26 + .../getundefined/src/main/cpp/CMakeLists.txt | 13 + .../getundefined/src/main/cpp/hello.cpp | 159 + .../main/cpp/types/libgetundefined/Index.d.ts | 16 + .../types/libgetundefined/oh-package.json5 | 21 + .../GetundefinedAbility.ets | 112 +- .../getundefined/src/main/ets/pages/Index.ets | 43 + .../getundefined/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getundefined/src/ohosTest/module.json5 | 28 + .../getvaluebool/.gitignore | 6 + .../getvaluebool/build-profile.json5 | 54 + .../getvaluebool/hvigorfile.ts | 21 + .../getvaluebool/obfuscation-rules.txt | 23 + .../getvaluebool/oh-package.json5 | 26 + .../getvaluebool/src/main/cpp/CMakeLists.txt | 13 + .../getvaluebool/src/main/cpp/hello.cpp | 163 + .../main/cpp/types/libgetvaluebool/Index.d.ts | 16 + .../types/libgetvaluebool/oh-package.json5 | 21 + .../GetvalueboolAbility.ets | 112 +- .../getvaluebool/src/main/ets/pages/Index.ets | 43 + .../getvaluebool/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getvaluebool/src/ohosTest/module.json5 | 28 + .../hvigor/hvigor-config.json5 | 37 + .../JsvmAboutPrimitive}/hvigorfile.ts | 0 .../JsvmAboutPrimitive/oh-package.json5 | 25 + .../JsvmAboutPrimitive/ohosTest.md | 16 + .../screenshots/JsvmAboutPrimitive_1.png | Bin .../screenshots/JsvmAboutPrimitive_2.png | Bin .../JsvmAboutPromise}/.gitignore | 0 .../JsvmAboutPromise/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmUsageGuide/JsvmAboutPromise/README.md | 93 + .../JsvmAboutPromise/build-profile.json5 | 70 + .../JsvmAboutPromise}/code-linter.json5 | 0 .../hvigor/hvigor-config.json5 | 37 + .../JsvmAboutPromise}/hvigorfile.ts | 0 .../JsvmAboutPromise/ispromise/.gitignore | 6 + .../ispromise/build-profile.json5 | 54 + .../JsvmAboutPromise/ispromise/hvigorfile.ts | 21 + .../ispromise/obfuscation-rules.txt | 23 + .../ispromise/oh-package.json5 | 26 + .../ispromise/src/main/cpp/CMakeLists.txt | 13 + .../ispromise/src/main/cpp/hello.cpp | 160 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../ispromise/src/main/ets/pages/Index.ets | 43 + .../ispromise/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 20 + .../ispromise/src/ohosTest/module.json5 | 27 + .../JsvmAboutPromise/oh-package.json5 | 25 + .../JsvmAboutPromise/ohosTest.md | 9 + .../JsvmAboutPromise/resolvereject/.gitignore | 6 + .../resolvereject/build-profile.json5 | 54 + .../resolvereject/hvigorfile.ts | 21 + .../resolvereject/obfuscation-rules.txt | 23 + .../resolvereject/oh-package.json5 | 26 + .../resolvereject/src/main/cpp/CMakeLists.txt | 13 + .../resolvereject/src/main/cpp/hello.cpp | 197 + .../cpp/types/libresolvereject/Index.d.ts | 16 + .../types/libresolvereject/oh-package.json5 | 21 + .../src/main/ets/pages/Index.ets | 43 + .../ResolverejectAbility.ets | 112 +- .../resolvereject/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 20 + .../resolvereject/src/ohosTest/module.json5 | 27 + .../screenshots/JsvmAboutPromise_1.png | Bin .../screenshots/JsvmAboutPromise_2.png | Bin .../JsvmAboutProperty}/.gitignore | 0 .../JsvmAboutProperty/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmAboutProperty/README.md | 273 + .../JsvmAboutProperty/build-profile.json5 | 178 + .../JsvmAboutProperty}/code-linter.json5 | 0 .../defineproperties/.gitignore | 6 + .../defineproperties/build-profile.json5 | 54 + .../defineproperties/hvigorfile.ts | 21 + .../defineproperties/obfuscation-rules.txt | 23 + .../defineproperties/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../defineproperties/src/main/cpp/hello.cpp | 257 + .../cpp/types/libdefineproperties/Index.d.ts | 16 + .../libdefineproperties/oh-package.json5 | 21 + .../DefinepropertiesAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../defineproperties/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../deleteproperty/.gitignore | 6 + .../deleteproperty/build-profile.json5 | 54 + .../deleteproperty/hvigorfile.ts | 21 + .../deleteproperty/obfuscation-rules.txt | 23 + .../deleteproperty/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../deleteproperty/src/main/cpp/hello.cpp | 172 + .../cpp/types/libdeleteproperty/Index.d.ts | 16 + .../types/libdeleteproperty/oh-package.json5 | 21 + .../DeletepropertyAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../deleteproperty/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../deleteproperty/src/ohosTest/module.json5 | 27 + .../getallpropertynames/.gitignore | 6 + .../getallpropertynames/build-profile.json5 | 54 + .../getallpropertynames/hvigorfile.ts | 21 + .../getallpropertynames/obfuscation-rules.txt | 23 + .../getallpropertynames/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../src/main/cpp/hello.cpp | 166 + .../types/libgetallpropertynames/Index.d.ts | 16 + .../libgetallpropertynames/oh-package.json5 | 21 + .../GetallpropertynamesAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../getallpropertynames/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../getnamedproperty/.gitignore | 6 + .../getnamedproperty/build-profile.json5 | 54 + .../getnamedproperty/hvigorfile.ts | 21 + .../getnamedproperty/obfuscation-rules.txt | 23 + .../getnamedproperty/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../getnamedproperty/src/main/cpp/hello.cpp | 168 + .../cpp/types/libgetnamedproperty/Index.d.ts | 16 + .../libgetnamedproperty/oh-package.json5 | 21 + .../GetnamedpropertyAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../getnamedproperty/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../JsvmAboutProperty/getproperty/.gitignore | 6 + .../getproperty/build-profile.json5 | 54 + .../getproperty/hvigorfile.ts | 21 + .../getproperty/obfuscation-rules.txt | 23 + .../getproperty/oh-package.json5 | 26 + .../getproperty/src/main/cpp/CMakeLists.txt | 13 + .../getproperty/src/main/cpp/hello.cpp | 163 + .../main/cpp/types/libgetproperty/Index.d.ts | 16 + .../cpp/types/libgetproperty/oh-package.json5 | 21 + .../getpropertyability/GetpropertyAbility.ets | 112 +- .../getproperty/src/main/ets/pages/Index.ets | 43 + .../getproperty/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getproperty/src/ohosTest/module.json5 | 27 + .../getpropertynames/.gitignore | 6 + .../getpropertynames/build-profile.json5 | 54 + .../getpropertynames/hvigorfile.ts | 21 + .../getpropertynames/obfuscation-rules.txt | 23 + .../getpropertynames/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../getpropertynames/src/main/cpp/hello.cpp | 163 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../src/main/ets/pages/Index.ets | 43 + .../getpropertynames/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../hasnamedproperty/.gitignore | 6 + .../hasnamedproperty/build-profile.json5 | 54 + .../hasnamedproperty/hvigorfile.ts | 21 + .../hasnamedproperty/obfuscation-rules.txt | 23 + .../hasnamedproperty/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../hasnamedproperty/src/main/cpp/hello.cpp | 171 + .../cpp/types/libhasnamedproperty/Index.d.ts | 16 + .../libhasnamedproperty/oh-package.json5 | 21 + .../HasnamedpropertyAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../hasnamedproperty/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 28 + .../hasownproperty/.gitignore | 6 + .../hasownproperty/build-profile.json5 | 54 + .../hasownproperty/hvigorfile.ts | 21 + .../hasownproperty/obfuscation-rules.txt | 23 + .../hasownproperty/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../hasownproperty/src/main/cpp/hello.cpp | 181 + .../cpp/types/libhasownproperty/Index.d.ts | 16 + .../types/libhasownproperty/oh-package.json5 | 21 + .../HasownpropertyAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../hasownproperty/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../hasownproperty/src/ohosTest/module.json5 | 28 + .../JsvmAboutProperty/hasproperty/.gitignore | 6 + .../hasproperty/build-profile.json5 | 54 + .../hasproperty/hvigorfile.ts | 21 + .../hasproperty/obfuscation-rules.txt | 23 + .../hasproperty/oh-package.json5 | 26 + .../hasproperty/src/main/cpp/CMakeLists.txt | 13 + .../hasproperty/src/main/cpp/hello.cpp | 167 + .../main/cpp/types/libhasproperty/Index.d.ts | 16 + .../cpp/types/libhasproperty/oh-package.json5 | 21 + .../haspropertyability/HaspropertyAbility.ets | 112 +- .../hasproperty/src/main/ets/pages/Index.ets | 43 + .../hasproperty/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../hasproperty/src/ohosTest/module.json5 | 28 + .../hvigor/hvigor-config.json5 | 37 + .../JsvmAboutProperty}/hvigorfile.ts | 0 .../JsvmAboutProperty/oh-package.json5 | 25 + .../JsvmAboutProperty/ohosTest.md | 18 + .../screenshots/JsvmAboutProperty_1.png | Bin .../screenshots/JsvmAboutProperty_2.png | Bin .../setnamedproperty/.gitignore | 6 + .../setnamedproperty/build-profile.json5 | 54 + .../setnamedproperty/hvigorfile.ts | 21 + .../setnamedproperty/obfuscation-rules.txt | 23 + .../setnamedproperty/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../setnamedproperty/src/main/cpp/hello.cpp | 174 + .../cpp/types/libsetnamedproperty/Index.d.ts | 16 + .../libsetnamedproperty/oh-package.json5 | 21 + .../src/main/ets/pages/Index.ets | 43 + .../SetnamedpropertyAbility.ets | 112 +- .../setnamedproperty/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 28 + .../JsvmAboutProperty/setproperty/.gitignore | 6 + .../setproperty/build-profile.json5 | 54 + .../setproperty/hvigorfile.ts | 21 + .../setproperty/obfuscation-rules.txt | 23 + .../setproperty/oh-package.json5 | 26 + .../setproperty/src/main/cpp/CMakeLists.txt | 13 + .../setproperty/src/main/cpp/hello.cpp | 167 + .../main/cpp/types/libsetproperty/Index.d.ts | 16 + .../cpp/types/libsetproperty/oh-package.json5 | 21 + .../setproperty/src/main/ets/pages/Index.ets | 43 + .../setpropertyability/SetpropertyAbility.ets | 112 +- .../setproperty/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../setproperty/src/ohosTest/module.json5 | 28 + .../JsvmAboutString}/.gitignore | 0 .../JsvmAboutString/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmUsageGuide/JsvmAboutString/README.md | 173 + .../JsvmAboutString/build-profile.json5 | 118 + .../JsvmAboutString}/code-linter.json5 | 0 .../createstringlatin1/.gitignore | 6 + .../createstringlatin1/build-profile.json5 | 54 + .../createstringlatin1/hvigorfile.ts | 21 + .../createstringlatin1/obfuscation-rules.txt | 23 + .../createstringlatin1/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../createstringlatin1/src/main/cpp/hello.cpp | 165 + .../types/libcreatestringlatin1/Index.d.ts | 16 + .../libcreatestringlatin1/oh-package.json5 | 21 + .../Createstringlatin1Ability.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createstringlatin1/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../createstringutf16/.gitignore | 6 + .../createstringutf16/build-profile.json5 | 54 + .../createstringutf16/hvigorfile.ts | 21 + .../createstringutf16/obfuscation-rules.txt | 23 + .../createstringutf16/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../createstringutf16/src/main/cpp/hello.cpp | 167 + .../cpp/types/libcreatestringutf16/Index.d.ts | 16 + .../libcreatestringutf16/oh-package.json5 | 21 + .../Createstringutf16Ability.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createstringutf16/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../createstringutf8/.gitignore | 6 + .../createstringutf8/build-profile.json5 | 54 + .../createstringutf8/hvigorfile.ts | 21 + .../createstringutf8/obfuscation-rules.txt | 23 + .../createstringutf8/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../createstringutf8/src/main/cpp/hello.cpp | 161 + .../cpp/types/libcreatestringutf8/Index.d.ts | 16 + .../libcreatestringutf8/oh-package.json5 | 21 + .../Createstringutf8Ability.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createstringutf8/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../getvaluestringlatin1/.gitignore | 6 + .../getvaluestringlatin1/build-profile.json5 | 54 + .../getvaluestringlatin1/hvigorfile.ts | 21 + .../obfuscation-rules.txt | 23 + .../getvaluestringlatin1/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../src/main/cpp/hello.cpp | 167 + .../types/libgetvaluestringlatin1/Index.d.ts | 16 + .../libgetvaluestringlatin1/oh-package.json5 | 21 + .../Getvaluestringlatin1Ability.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../getvaluestringutf16/.gitignore | 6 + .../getvaluestringutf16/build-profile.json5 | 54 + .../getvaluestringutf16/hvigorfile.ts | 21 + .../getvaluestringutf16/obfuscation-rules.txt | 23 + .../getvaluestringutf16/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../src/main/cpp/hello.cpp | 177 + .../types/libgetvaluestringutf16/Index.d.ts | 16 + .../libgetvaluestringutf16/oh-package.json5 | 21 + .../Getvaluestringutf16Ability.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../getvaluestringutf16/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../getvaluestringutf8/.gitignore | 6 + .../getvaluestringutf8/build-profile.json5 | 54 + .../getvaluestringutf8/hvigorfile.ts | 21 + .../getvaluestringutf8/obfuscation-rules.txt | 23 + .../getvaluestringutf8/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../getvaluestringutf8/src/main/cpp/hello.cpp | 174 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../src/main/ets/pages/Index.ets | 43 + .../getvaluestringutf8/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../hvigor/hvigor-config.json5 | 37 + .../JsvmAboutString}/hvigorfile.ts | 0 .../JsvmAboutString/oh-package.json5 | 25 + .../JsvmAboutString/ohosTest.md | 13 + .../screenshots/JsvmAboutString_1.png | Bin .../screenshots/JsvmAboutString_2.png | Bin .../JsvmBasicDataTypes}/.gitignore | 0 .../JsvmBasicDataTypes/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmBasicDataTypes/README.md | 213 + .../JsvmBasicDataTypes/build-profile.json5 | 142 + .../JsvmBasicDataTypes/code-linter.json5 | 47 + .../createdouble/.gitignore | 6 + .../createdouble/build-profile.json5 | 54 + .../createdouble/hvigorfile.ts | 21 + .../createdouble/obfuscation-rules.txt | 23 + .../createdouble/oh-package.json5 | 26 + .../createdouble/src/main/cpp/CMakeLists.txt | 14 + .../createdouble/src/main/cpp/hello.cpp | 160 + .../main/cpp/types/libcreatedouble/Index.d.ts | 16 + .../types/libcreatedouble/oh-package.json5 | 21 + .../CreatedoubleAbility.ets | 116 +- .../createdouble/src/main/ets/pages/Index.ets | 43 + .../createdouble/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/float.json | 0 .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createdouble/src/ohosTest/module.json5 | 27 + .../JsvmBasicDataTypes/createint32/.gitignore | 6 + .../createint32/build-profile.json5 | 54 + .../createint32/hvigorfile.ts | 21 + .../createint32/obfuscation-rules.txt | 23 + .../createint32/oh-package.json5 | 26 + .../createint32/src/main/cpp/CMakeLists.txt | 14 + .../createint32/src/main/cpp/hello.cpp | 161 + .../main/cpp/types/libcreateint32/Index.d.ts | 16 + .../cpp/types/libcreateint32/oh-package.json5 | 21 + .../createint32ability/Createint32Ability.ets | 116 +- .../createint32/src/main/ets/pages/Index.ets | 43 + .../createint32/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/float.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createint32/src/ohosTest/module.json5 | 27 + .../JsvmBasicDataTypes/createint64/.gitignore | 6 + .../createint64/build-profile.json5 | 54 + .../createint64/hvigorfile.ts | 21 + .../createint64/obfuscation-rules.txt | 23 + .../createint64/oh-package.json5 | 26 + .../createint64/src/main/cpp/CMakeLists.txt | 14 + .../createint64/src/main/cpp/hello.cpp | 163 + .../main/cpp/types/libcreateint64/Index.d.ts | 16 + .../cpp/types/libcreateint64/oh-package.json5 | 21 + .../createint64ability/Createint64Ability.ets | 116 +- .../createint64/src/main/ets/pages/Index.ets | 43 + .../createint64/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/float.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createint64/src/ohosTest/module.json5 | 27 + .../createuint32/.gitignore | 6 + .../createuint32/build-profile.json5 | 54 + .../createuint32/hvigorfile.ts | 21 + .../createuint32/obfuscation-rules.txt | 23 + .../createuint32/oh-package.json5 | 26 + .../createuint32/src/main/cpp/CMakeLists.txt | 14 + .../createuint32/src/main/cpp/hello.cpp | 165 + .../main/cpp/types/libcreateuint32/Index.d.ts | 16 + .../types/libcreateuint32/oh-package.json5 | 21 + .../Createuint32Ability.ets | 116 +- .../createuint32/src/main/ets/pages/Index.ets | 43 + .../createuint32/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/float.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createuint32/src/ohosTest/module.json5 | 27 + .../getvaluedouble/.gitignore | 6 + .../getvaluedouble/build-profile.json5 | 54 + .../getvaluedouble/hvigorfile.ts | 21 + .../getvaluedouble/obfuscation-rules.txt | 23 + .../getvaluedouble/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../getvaluedouble/src/main/cpp/hello.cpp | 160 + .../cpp/types/libgetvaluedouble/Index.d.ts | 16 + .../types/libgetvaluedouble/oh-package.json5 | 21 + .../GetvaluedoubleAbility.ets | 116 +- .../src/main/ets/pages/Index.ets | 43 + .../getvaluedouble/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/float.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getvaluedouble/src/ohosTest/module.json5 | 27 + .../getvalueint32/.gitignore | 6 + .../getvalueint32/build-profile.json5 | 54 + .../getvalueint32/hvigorfile.ts | 21 + .../getvalueint32/obfuscation-rules.txt | 23 + .../getvalueint32/oh-package.json5 | 26 + .../getvalueint32/src/main/cpp/CMakeLists.txt | 14 + .../getvalueint32/src/main/cpp/hello.cpp | 165 + .../cpp/types/libgetvalueint32/Index.d.ts | 16 + .../types/libgetvalueint32/oh-package.json5 | 21 + .../Getvalueint32Ability.ets | 116 +- .../src/main/ets/pages/Index.ets | 43 + .../getvalueint32/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/float.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getvalueint32/src/ohosTest/module.json5 | 27 + .../getvalueint64/.gitignore | 6 + .../getvalueint64/build-profile.json5 | 54 + .../getvalueint64/hvigorfile.ts | 21 + .../getvalueint64/obfuscation-rules.txt | 23 + .../getvalueint64/oh-package.json5 | 26 + .../getvalueint64/src/main/cpp/CMakeLists.txt | 14 + .../getvalueint64/src/main/cpp/hello.cpp | 162 + .../cpp/types/libgetvalueint64/Index.d.ts | 16 + .../types/libgetvalueint64/oh-package.json5 | 21 + .../Getvalueint64Ability.ets | 116 +- .../src/main/ets/pages/Index.ets | 43 + .../getvalueint64/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/float.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getvalueint64/src/ohosTest/module.json5 | 27 + .../getvalueuint32/.gitignore | 6 + .../getvalueuint32/build-profile.json5 | 54 + .../getvalueuint32/hvigorfile.ts | 21 + .../getvalueuint32/obfuscation-rules.txt | 23 + .../getvalueuint32/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 14 + .../getvalueuint32/src/main/cpp/hello.cpp | 164 + .../cpp/types/libgetvalueuint32/Index.d.ts | 16 + .../types/libgetvalueuint32/oh-package.json5 | 21 + .../Getvalueuint32Ability.ets | 116 +- .../Getvalueuint32BackupAbility.ets | 60 +- .../src/main/ets/pages/Index.ets | 43 + .../getvalueuint32/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/float.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getvalueuint32/src/ohosTest/module.json5 | 27 + .../hvigor/hvigor-config.json5 | 37 + .../JsvmBasicDataTypes}/hvigorfile.ts | 0 .../JsvmBasicDataTypes/oh-package.json5 | 25 + .../JsvmBasicDataTypes/ohosTest.md | 15 + .../screenshots/JsvmBasicDataTypes_1.png | Bin .../screenshots/JsvmBasicDataTypes_2.png | Bin .../JsvmUsageGuide/JsvmError}/.gitignore | 0 .../JsvmError/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmUsageGuide/JsvmError/README.md | 293 + .../JsvmError/build-profile.json5 | 190 + .../JsvmError}/code-linter.json5 | 0 .../JsvmError/createerror/.gitignore | 6 + .../JsvmError/createerror/build-profile.json5 | 54 + .../JsvmError/createerror/hvigorfile.ts | 21 + .../createerror/obfuscation-rules.txt | 23 + .../JsvmError/createerror/oh-package.json5 | 26 + .../createerror/src/main/cpp/CMakeLists.txt | 13 + .../createerror/src/main/cpp/hello.cpp | 179 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../createerror/src/main/ets/pages/Index.ets | 43 + .../createerror/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createerror/src/ohosTest/module.json5 | 27 + .../JsvmError/createrangeerror/.gitignore | 6 + .../createrangeerror/build-profile.json5 | 54 + .../JsvmError/createrangeerror/hvigorfile.ts | 21 + .../createrangeerror/obfuscation-rules.txt | 23 + .../createrangeerror/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../createrangeerror/src/main/cpp/hello.cpp | 159 + .../cpp/types/libcreaterangeerror/Index.d.ts | 16 + .../libcreaterangeerror/oh-package.json5 | 21 + .../CreaterangeerrorAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createrangeerror/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../JsvmError/createsyntaxerror/.gitignore | 6 + .../createsyntaxerror/build-profile.json5 | 54 + .../JsvmError/createsyntaxerror/hvigorfile.ts | 21 + .../createsyntaxerror/obfuscation-rules.txt | 23 + .../createsyntaxerror/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../createsyntaxerror/src/main/cpp/hello.cpp | 159 + .../cpp/types/libcreatesyntaxerror/Index.d.ts | 16 + .../libcreatesyntaxerror/oh-package.json5 | 21 + .../CreatesyntaxerrorAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createsyntaxerror/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../JsvmError/createtypeerror/.gitignore | 6 + .../createtypeerror/build-profile.json5 | 54 + .../JsvmError/createtypeerror/hvigorfile.ts | 21 + .../createtypeerror/obfuscation-rules.txt | 23 + .../createtypeerror/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../createtypeerror/src/main/cpp/hello.cpp | 159 + .../cpp/types/libcreatetypeerror/Index.d.ts | 16 + .../types/libcreatetypeerror/oh-package.json5 | 21 + .../CreateTypeErrorAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../createtypeerror/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createtypeerror/src/ohosTest/module.json5 | 27 + .../getandclearlastexception/.gitignore | 6 + .../build-profile.json5 | 54 + .../getandclearlastexception/hvigorfile.ts | 21 + .../obfuscation-rules.txt | 23 + .../getandclearlastexception/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../src/main/cpp/hello.cpp | 156 + .../libgetandclearlastexception/Index.d.ts | 16 + .../oh-package.json5 | 21 + .../GetandclearlastexceptionAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../JsvmError/getlasterrorinfo/.gitignore | 6 + .../getlasterrorinfo/build-profile.json5 | 54 + .../JsvmError/getlasterrorinfo/hvigorfile.ts | 21 + .../getlasterrorinfo/obfuscation-rules.txt | 23 + .../getlasterrorinfo/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../getlasterrorinfo/src/main/cpp/hello.cpp | 166 + .../cpp/types/libgetlasterrorinfo/Index.d.ts | 16 + .../libgetlasterrorinfo/oh-package.json5 | 21 + .../GetlasterrorInfoAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../getlasterrorinfo/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../JsvmError/hvigor/hvigor-config.json5 | 37 + .../JsvmUsageGuide/JsvmError}/hvigorfile.ts | 0 .../JsvmError/iserror/.gitignore | 6 + .../JsvmError/iserror/build-profile.json5 | 54 + .../JsvmError/iserror/hvigorfile.ts | 21 + .../JsvmError/iserror/obfuscation-rules.txt | 23 + .../JsvmError/iserror/oh-package.json5 | 26 + .../iserror/src/main/cpp/CMakeLists.txt | 13 + .../JsvmError/iserror/src/main/cpp/hello.cpp | 161 + .../src/main/cpp/types/libiserror/Index.d.ts | 16 + .../cpp/types/libiserror/oh-package.json5 | 21 + .../ets/iserrorability/IserrorAbility.ets | 112 +- .../iserror/src/main/ets/pages/Index.ets | 43 + .../JsvmError/iserror/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../iserror/src/ohosTest/module.json5 | 28 + .../JsvmError/isexceptionpending/.gitignore | 6 + .../isexceptionpending/build-profile.json5 | 54 + .../isexceptionpending/hvigorfile.ts | 21 + .../isexceptionpending/obfuscation-rules.txt | 23 + .../isexceptionpending/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../isexceptionpending/src/main/cpp/hello.cpp | 168 + .../types/libisexceptionpending/Index.d.ts | 16 + .../libisexceptionpending/oh-package.json5 | 21 + .../IsexceptionpendingAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../isexceptionpending/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 28 + .../JsvmUsageGuide/JsvmError/oh-package.json5 | 25 + .../JsvmUsageGuide/JsvmError/ohosTest.md | 20 + .../JsvmError/screenshots/JsvmError_1.png | Bin .../JsvmError/screenshots/JsvmError_2.png | Bin .../JsvmError/throwerror/.gitignore | 6 + .../JsvmError/throwerror/build-profile.json5 | 54 + .../JsvmError/throwerror/hvigorfile.ts | 21 + .../throwerror/obfuscation-rules.txt | 23 + .../JsvmError/throwerror/oh-package.json5 | 26 + .../throwerror/src/main/cpp/CMakeLists.txt | 13 + .../throwerror/src/main/cpp/hello.cpp | 183 + .../main/cpp/types/libthrowerror/Index.d.ts | 16 + .../cpp/types/libthrowerror/oh-package.json5 | 21 + .../throwerror/src/main/ets/pages/Index.ets | 43 + .../throwerrorability/ThrowerrorAbility.ets | 112 +- .../throwerror/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../throwerror/src/ohosTest/module.json5 | 28 + .../JsvmError/throwrangeerror/.gitignore | 6 + .../throwrangeerror/build-profile.json5 | 54 + .../JsvmError/throwrangeerror/hvigorfile.ts | 21 + .../throwrangeerror/obfuscation-rules.txt | 23 + .../throwrangeerror/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../throwrangeerror/src/main/cpp/hello.cpp | 179 + .../cpp/types/libthrowrangeerror/Index.d.ts | 16 + .../types/libthrowrangeerror/oh-package.json5 | 21 + .../src/main/ets/pages/Index.ets | 43 + .../ThrowrangeerrorAbility.ets | 112 +- .../throwrangeerror/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../throwrangeerror/src/ohosTest/module.json5 | 28 + .../JsvmError/throwsyntaxerror/.gitignore | 6 + .../throwsyntaxerror/build-profile.json5 | 54 + .../JsvmError/throwsyntaxerror/hvigorfile.ts | 21 + .../throwsyntaxerror/obfuscation-rules.txt | 23 + .../throwsyntaxerror/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../throwsyntaxerror/src/main/cpp/hello.cpp | 184 + .../cpp/types/libthrowsyntaxerror/Index.d.ts | 16 + .../libthrowsyntaxerror/oh-package.json5 | 21 + .../src/main/ets/pages/Index.ets | 43 + .../ThrowsyntaxerrorAbility.ets | 112 +- .../throwsyntaxerror/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 28 + .../JsvmError/throwtypeerror/.gitignore | 6 + .../throwtypeerror/build-profile.json5 | 54 + .../JsvmError/throwtypeerror/hvigorfile.ts | 21 + .../throwtypeerror/obfuscation-rules.txt | 23 + .../JsvmError/throwtypeerror/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../throwtypeerror/src/main/cpp/hello.cpp | 183 + .../cpp/types/libthrowtypeerror/Index.d.ts | 16 + .../types/libthrowtypeerror/oh-package.json5 | 21 + .../src/main/ets/pages/Index.ets | 43 + .../ThrowtypeerrorAbility.ets | 112 +- .../throwtypeerror/src/main/module.json5 | 44 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../throwtypeerror/src/ohosTest/module.json5 | 28 + .../JsvmUsageGuide/JsvmLifeCycle}/.gitignore | 0 .../JsvmLifeCycle/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../JsvmUsageGuide/JsvmLifeCycle/README.md | 141 + .../JsvmLifeCycle/addfinalizer/.gitignore | 6 + .../addfinalizer/build-profile.json5 | 54 + .../JsvmLifeCycle/addfinalizer/hvigorfile.ts | 21 + .../addfinalizer/obfuscation-rules.txt | 23 + .../addfinalizer/oh-package.json5 | 26 + .../addfinalizer/src/main/cpp/CMakeLists.txt | 13 + .../addfinalizer/src/main/cpp/hello.cpp | 126 + .../main/cpp/types/libaddfinalizer/Index.d.ts | 16 + .../types/libaddfinalizer/oh-package.json5 | 21 + .../AddfinalizerAbility.ets | 112 +- .../addfinalizer/src/main/ets/pages/Index.ets | 43 + .../addfinalizer/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../addfinalizer/src/ohosTest/module.json5 | 27 + .../JsvmLifeCycle/build-profile.json5 | 94 + .../JsvmLifeCycle}/code-linter.json5 | 0 .../JsvmLifeCycle/hvigor/hvigor-config.json5 | 22 + .../JsvmLifeCycle}/hvigorfile.ts | 0 .../JsvmLifeCycle/oh-package.json5 | 25 + .../JsvmUsageGuide/JsvmLifeCycle/ohosTest.md | 11 + .../openescapablehandlescope/.gitignore | 6 + .../build-profile.json5 | 54 + .../openescapablehandlescope/hvigorfile.ts | 21 + .../obfuscation-rules.txt | 23 + .../openescapablehandlescope/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../src/main/cpp/hello.cpp | 177 + .../libopenescapablehandlescope/Index.d.ts | 16 + .../oh-package.json5 | 21 + .../OpenescapablehandlescopeAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../JsvmLifeCycle/openhandlescope/.gitignore | 6 + .../openhandlescope/build-profile.json5 | 54 + .../openhandlescope/hvigorfile.ts | 21 + .../openhandlescope/obfuscation-rules.txt | 23 + .../openhandlescope/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../openhandlescope/src/main/cpp/hello.cpp | 169 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../src/main/ets/pages/Index.ets | 43 + .../openhandlescope/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../openhandlescope/src/ohosTest/module.json5 | 27 + .../JsvmLifeCycle/referenceref/.gitignore | 6 + .../referenceref/build-profile.json5 | 54 + .../JsvmLifeCycle/referenceref/hvigorfile.ts | 21 + .../referenceref/obfuscation-rules.txt | 23 + .../referenceref/oh-package.json5 | 26 + .../referenceref/src/main/cpp/CMakeLists.txt | 13 + .../referenceref/src/main/cpp/hello.cpp | 195 + .../main/cpp/types/libreferenceref/Index.d.ts | 16 + .../types/libreferenceref/oh-package.json5 | 21 + .../referenceref/src/main/ets/pages/Index.ets | 43 + .../ReferencerefAbility.ets | 112 +- .../referenceref/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../referenceref/src/ohosTest/module.json5 | 27 + .../screenshots/JsvmLifeCycle_1.png | Bin .../screenshots/JsvmLifeCycle_2.png | Bin .../UsageInstructionsOne}/.gitignore | 0 .../UsageInstructionsOne/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../UsageInstructionsOne/README.md | 160 + .../UsageInstructionsOne/aboutjson/.gitignore | 6 + .../aboutjson/build-profile.json5 | 54 + .../aboutjson/hvigorfile.ts | 21 + .../aboutjson/obfuscation-rules.txt | 23 + .../aboutjson/oh-package.json5 | 26 + .../aboutjson/src/main/cpp/CMakeLists.txt | 14 + .../aboutjson/src/main/cpp/hello.cpp | 185 + .../main/cpp/types/libaboutjson/Index.d.ts | 16 + .../cpp/types/libaboutjson/oh-package.json5 | 21 + .../ets/aboutjsonability/AboutjsonAbility.ets | 112 +- .../aboutjson/src/main/ets/pages/Index.ets | 43 + .../aboutjson/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../aboutjson/src/ohosTest/module.json5 | 26 + .../UsageInstructionsOne/build-profile.json5 | 106 + .../UsageInstructionsOne}/code-linter.json5 | 0 .../createsnapshot/.gitignore | 6 + .../createsnapshot/build-profile.json5 | 54 + .../createsnapshot/hvigorfile.ts | 21 + .../createsnapshot/obfuscation-rules.txt | 23 + .../createsnapshot/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../createsnapshot/src/main/cpp/hello.cpp | 277 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../src/main/ets/pages/Index.ets | 45 + .../createsnapshot/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../createsnapshot/src/ohosTest/module.json5 | 27 + .../functioncall/.gitignore | 6 + .../functioncall/build-profile.json5 | 54 + .../functioncall/hvigorfile.ts | 21 + .../functioncall/obfuscation-rules.txt | 23 + .../functioncall/oh-package.json5 | 26 + .../functioncall/src/main/cpp/CMakeLists.txt | 14 + .../functioncall/src/main/cpp/hello.cpp | 151 + .../main/cpp/types/libfunctioncall/Index.d.ts | 16 + .../types/libfunctioncall/oh-package.json5 | 21 + .../FunctioncallAbility.ets | 112 +- .../functioncall/src/main/ets/pages/Index.ets | 43 + .../functioncall/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../functioncall/src/ohosTest/module.json5 | 26 + .../hvigor/hvigor-config.json5 | 37 + .../UsageInstructionsOne}/hvigorfile.ts | 0 .../UsageInstructionsOne/oh-package.json5 | 25 + .../UsageInstructionsOne/ohosTest.md | 12 + .../pumpmessageloop/.gitignore | 6 + .../pumpmessageloop/build-profile.json5 | 39 + .../pumpmessageloop/hvigorfile.ts | 0 .../pumpmessageloop/obfuscation-rules.txt | 23 + .../pumpmessageloop/oh-package.json5 | 11 + .../src/main/cpp/CMakeLists.txt | 13 + .../pumpmessageloop/src/main/cpp/hello.cpp | 197 + .../cpp/types/libpumpmessageloop/Index.d.ts | 16 + .../types/libpumpmessageloop/oh-package.json5 | 21 + .../src/main/ets/pages/Index.ets | 43 + .../PumpmessageloopAbility.ets | 82 +- .../pumpmessageloop/src/main/module.json5 | 27 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../pumpmessageloop/src/ohosTest/module.json5 | 11 + .../screenshots/UsageInstructionsOne_1.png | Bin .../screenshots/UsageInstructionsOne_2.png | Bin .../webassembly/.gitignore | 6 + .../webassembly/build-profile.json5 | 54 + .../webassembly/hvigorfile.ts | 0 .../webassembly/obfuscation-rules.txt | 23 + .../webassembly/oh-package.json5 | 0 .../webassembly/src/main/cpp/CMakeLists.txt | 0 .../webassembly/src/main/cpp/hello.cpp | 0 .../main/cpp/types/libwebassembly/Index.d.ts | 16 + .../cpp/types/libwebassembly/oh-package.json5 | 0 .../webassembly/src/main/ets/pages/Index.ets | 0 .../webassemblyability/WebassemblyAbility.ets | 0 .../webassembly/src/main/module.json5 | 0 .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/float.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 20 + .../webassembly/src/ohosTest/module.json5 | 0 .../UsageInstructionsTwo}/.gitignore | 0 .../UsageInstructionsTwo/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../UsageInstructionsTwo/README.md | 179 + .../adjustexternalmemory/.gitignore | 6 + .../adjustexternalmemory/build-profile.json5 | 54 + .../adjustexternalmemory/hvigorfile.ts | 21 + .../obfuscation-rules.txt | 23 + .../adjustexternalmemory/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../src/main/cpp/hello.cpp | 159 + .../types/libadjustexternalmemory/Index.d.ts | 16 + .../libadjustexternalmemory/oh-package.json5 | 21 + .../AdjustexternalmemoryAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../UsageInstructionsTwo/build-profile.json5 | 118 + .../UsageInstructionsTwo}/code-linter.json5 | 0 .../getheapstatistics/.gitignore | 6 + .../getheapstatistics/build-profile.json5 | 54 + .../getheapstatistics/hvigorfile.ts | 21 + .../getheapstatistics/obfuscation-rules.txt | 23 + .../getheapstatistics/oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../getheapstatistics/src/main/cpp/hello.cpp | 175 + .../cpp/types/libgetheapstatistics/Index.d.ts | 16 + .../libgetheapstatistics/oh-package.json5 | 21 + .../GetheapstatisticsAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../getheapstatistics/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../getversion/.gitignore | 6 + .../getversion/build-profile.json5 | 54 + .../getversion/hvigorfile.ts | 21 + .../getversion/obfuscation-rules.txt | 23 + .../getversion/oh-package.json5 | 26 + .../getversion/src/main/cpp/CMakeLists.txt | 13 + .../getversion/src/main/cpp/hello.cpp | 175 + .../main/cpp/types/libgetversion/Index.d.ts | 16 + .../cpp/types/libgetversion/oh-package.json5 | 21 + .../getversionability/GetversionAbility.ets | 112 +- .../getversion/src/main/ets/pages/Index.ets | 43 + .../getversion/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../getversion/src/ohosTest/module.json5 | 27 + .../UsageInstructionsTwo/getvm/.gitignore | 6 + .../getvm/build-profile.json5 | 54 + .../UsageInstructionsTwo/getvm/hvigorfile.ts | 21 + .../getvm/obfuscation-rules.txt | 23 + .../getvm/oh-package.json5 | 26 + .../getvm/src/main/cpp/CMakeLists.txt | 13 + .../getvm/src/main/cpp/hello.cpp | 158 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../getvm/src/main/ets/pages/Index.ets | 43 + .../getvm/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../getvm/src/ohosTest/ets/test/List.test.ets | 20 + .../getvm/src/ohosTest/module.json5 | 27 + .../hvigor/hvigor-config.json5 | 37 + .../UsageInstructionsTwo}/hvigorfile.ts | 0 .../memorypressurenotification/.gitignore | 6 + .../build-profile.json5 | 54 + .../memorypressurenotification/hvigorfile.ts | 21 + .../obfuscation-rules.txt | 23 + .../oh-package.json5 | 26 + .../src/main/cpp/CMakeLists.txt | 13 + .../src/main/cpp/hello.cpp | 156 + .../libmemorypressurenotification/Index.d.ts | 16 + .../oh-package.json5 | 21 + .../MemorypressurenotificationAbility.ets | 112 +- .../src/main/ets/pages/Index.ets | 43 + .../src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../src/ohosTest/module.json5 | 27 + .../UsageInstructionsTwo/oh-package.json5 | 25 + .../UsageInstructionsTwo/ohosTest.md | 13 + .../screenshots/UsageInstructionsTwo_1.png | Bin .../screenshots/UsageInstructionsTwo_2.png | Bin .../strictequals/.gitignore | 6 + .../strictequals/build-profile.json5 | 54 + .../strictequals/hvigorfile.ts | 21 + .../strictequals/obfuscation-rules.txt | 23 + .../strictequals/oh-package.json5 | 26 + .../strictequals/src/main/cpp/CMakeLists.txt | 13 + .../strictequals/src/main/cpp/hello.cpp | 161 + .../main/cpp/types/libstrictequals/Index.d.ts | 16 + .../types/libstrictequals/oh-package.json5 | 21 + .../strictequals/src/main/ets/pages/Index.ets | 43 + .../StrictequalsAbility.ets | 112 +- .../strictequals/src/main/module.json5 | 42 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../src/ohosTest/ets/test/Ability.test.ets | 52 + .../src/ohosTest/ets/test/List.test.ets | 20 + .../strictequals/src/ohosTest/module.json5 | 27 + .../NodeAPIAsynchronousTask}/.gitignore | 0 .../AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeAPIAsynchronousTask/README.md | 74 + .../build-profile.json5 | 58 + .../code-linter.json5 | 0 .../NodeAPIAsynchronousTask/entry/.gitignore | 6 + .../entry/build-profile.json5 | 59 + .../entry/hvigorfile.ts | 21 + .../entry/oh-package.json5 | 27 + .../entry/src/main/cpp/CMakeLists.txt | 18 + .../entry/src/main/cpp/callback.cpp | 208 +- .../entry/src/main/cpp/napi_init.cpp | 99 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../src/main/cpp/types/libentry1/Index.d.ts | 16 + .../main/cpp/types/libentry1/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 53 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/NodeAPIAsynchronousTask.test.ets | 146 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeAPIAsynchronousTask}/hvigorfile.ts | 0 .../NodeAPIAsynchronousTask/oh-package.json5 | 25 + .../NodeAPIAsynchronousTask/ohosTest.md | 9 + .../screenshots/NodeAPIAsynchronousTask1.png | Bin .../screenshots/NodeAPIAsynchronousTask2.png | Bin .../NodeApiApplicationScenario}/.gitignore | 0 .../AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiApplicationScenario/README.md | 87 + .../build-profile.json5 | 58 + .../code-linter.json5 | 0 .../entry/.gitignore | 6 + .../entry/build-profile.json5 | 70 + .../entry/hvigorfile.ts | 21 + .../entry/oh-package.json5 | 27 + .../entry/src/main/cpp/CMakeLists.txt | 12 + .../entry/src/main/cpp/napi_init.cpp | 232 + .../entry/src/main/cpp/thread_safety.cpp | 292 +- .../src/main/cpp/types/libentry/Index.d.ts | 23 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../src/main/cpp/types/libentry1/Index.d.ts | 17 + .../main/cpp/types/libentry1/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 82 + .../entry/src/main/ets/pages/ObjectUtils.ets | 58 +- .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../test/NodeApiApplicationScenario.test.ets | 214 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeApiApplicationScenario}/hvigorfile.ts | 0 .../oh-package.json5 | 25 + .../NodeApiApplicationScenario/ohosTest.md | 11 + .../NodeApiApplicationScenario1.png | Bin .../NodeApiApplicationScenario2.png | Bin .../NodeApiLoadModule}/.gitignore | 0 .../NodeApiLoadModule/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiLoadModule/README.md | 75 + .../NodeApiLoadModule/build-profile.json5 | 58 + .../NodeApiLoadModule}/code-linter.json5 | 0 .../NodeApiLoadModule/entry/.gitignore | 6 + .../entry/build-profile.json5 | 68 + .../NodeApiLoadModule/entry/hvigorfile.ts | 21 + .../NodeApiLoadModule/entry/oh-package.json5 | 27 + .../entry/src/main/cpp/CMakeLists.txt | 18 + .../entry/src/main/cpp/file.cpp | 60 + .../entry/src/main/cpp/napi_init.cpp | 66 + .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../src/main/cpp/types/libentry1/Index.d.ts | 16 + .../main/cpp/types/libentry1/oh-package.json5 | 21 + .../entry/src/main/ets/Test.ets | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 46 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/NodeApiLoadModule.test.ets | 146 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeApiLoadModule}/hvigorfile.ts | 0 .../NodeApiLoadModule/oh-package.json5 | 25 + .../NodeApiLoadModule/ohosTest.md | 9 + .../screenshots/NodeApiLoadModule1.png | Bin .../screenshots/NodeApiLoadModule2.png | Bin .../NodeApiLoadModuleWithInfo}/.gitignore | 0 .../AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiLoadModuleWithInfo/README.md | 86 + .../build-profile.json5 | 70 + .../code-linter.json5 | 0 .../entry/.gitignore | 6 + .../entry/build-profile.json5 | 94 + .../entry/hvigorfile.ts | 21 + .../entry/oh-package.json5 | 43 + .../entry/src/main/cpp/CMakeLists.txt | 27 + .../entry/src/main/cpp/api.cpp | 132 +- .../entry/src/main/cpp/file.cpp | 61 + .../entry/src/main/cpp/har_name.cpp | 120 +- .../entry/src/main/cpp/napi_init.cpp | 62 + .../entry/src/main/cpp/remote_har.cpp | 108 +- .../src/main/cpp/types/libentry/Index.d.ts | 16 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/cpp/types/libentryfour/Index.d.ts | 16 + .../cpp/types/libentryfour/oh-package.json5 | 21 + .../src/main/cpp/types/libentryone/Index.d.ts | 16 + .../cpp/types/libentryone/oh-package.json5 | 21 + .../main/cpp/types/libentrythree/Index.d.ts | 16 + .../cpp/types/libentrythree/oh-package.json5 | 21 + .../src/main/cpp/types/libentrytwo/Index.d.ts | 16 + .../cpp/types/libentrytwo/oh-package.json5 | 21 + .../entry/src/main/ets/Test.ets | 23 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 73 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../test/NodeApiLoadModuleWithInfo.test.ets | 264 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry}/src/test/List.test.ets | 0 .../entry}/src/test/LocalUnit.test.ets | 0 .../NodeApiLoadModuleWithInfo/har1/.gitignore | 6 + .../NodeApiLoadModuleWithInfo/har1/Index.ets | 24 + .../har1/build-profile.json5 | 72 + .../har1/hvigorfile.ts | 0 .../har1/oh-package.json5 | 29 + .../har1/src/main/cpp/CMakeLists.txt | 15 + .../har1/src/main/cpp/napi_init.cpp | 85 + .../src/main/cpp/types/libhar1/index.d.ts | 18 + .../main/cpp/types/libhar1/oh-package.json5 | 21 + .../har1/src/main/ets/components/MainPage.ets | 31 + .../har1/src/main/module.json5 | 25 + .../main/resources/base/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../har1/src/ohosTest/ets/test/List.test.ets | 20 + .../har1/src/ohosTest/module.json5 | 27 + .../har1}/src/test/List.test.ets | 0 .../har1}/src/test/LocalUnit.test.ets | 0 .../NodeApiLoadModuleWithInfo/har2/.gitignore | 6 + .../NodeApiLoadModuleWithInfo/har2/Index.ets | 25 + .../har2/build-profile.json5 | 46 + .../har2/hvigorfile.ts | 0 .../har2/oh-package.json5 | 24 + .../har2/src/main/ets/components/MainPage.ets | 31 + .../har2/src/main/module.json5 | 25 + .../main/resources/base/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../har2/src/ohosTest/ets/test/List.test.ets | 20 + .../har2/src/ohosTest/module.json5 | 27 + .../har2}/src/test/List.test.ets | 0 .../har2}/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeApiLoadModuleWithInfo}/hvigorfile.ts | 0 .../library/.gitignore | 6 + .../library/Index.ets | 23 + .../library/build-profile.json5 | 46 + .../library/hvigorfile.ts | 0 .../library/oh-package.json5 | 24 + .../src/main/ets/components/MainPage.ets | 31 + .../library/src/main/module.json5 | 25 + .../main/resources/base/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 20 + .../library/src/ohosTest/module.json5 | 27 + .../library}/src/test/List.test.ets | 0 .../library}/src/test/LocalUnit.test.ets | 0 .../oh-package.json5 | 25 + .../NodeApiLoadModuleWithInfo/ohosTest.md | 13 + .../NodeApiLoadModuleWithInfo1.png | Bin .../NodeApiLoadModuleWithInfo2.png | Bin .../NodeApiUse/NodeAPIArray}/.gitignore | 0 .../NodeAPIArray/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeAPI/NodeApiUse/NodeAPIArray/README.md | 75 + .../NodeAPIArray/build-profile.json5 | 58 + .../NodeAPIArray}/code-linter.json5 | 0 .../NodeApiUse/NodeAPIArray/entry/.gitignore | 6 + .../NodeAPIArray/entry/build-profile.json5 | 59 + .../NodeAPIArray/entry/hvigorfile.ts | 21 + .../NodeAPIArray/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 475 + .../src/main/cpp/types/libentry/Index.d.ts | 89 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 310 + .../NodeAPIArray/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/test/NodeAPIArray.test.ets | 538 +- .../entry/src/ohosTest/module.json5 | 27 + .../NodeAPIArray/entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../NodeAPIArray/hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIArray}/hvigorfile.ts | 0 .../NodeApiUse/NodeAPIArray/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIArray/ohosTest.md | 21 + .../screenshots/NodeAPIArray1.png | Bin .../screenshots/NodeAPIArray2.png | Bin .../NodeApiUse/NodeAPIArraybuffer}/.gitignore | 0 .../NodeAPIArraybuffer/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeAPIArraybuffer/README.md | 75 + .../NodeAPIArraybuffer/build-profile.json5 | 58 + .../NodeAPIArraybuffer}/code-linter.json5 | 0 .../NodeAPIArraybuffer/entry/.gitignore | 6 + .../entry/build-profile.json5 | 59 + .../NodeAPIArraybuffer/entry/hvigorfile.ts | 21 + .../NodeAPIArraybuffer/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 157 + .../src/main/cpp/types/libentry/Index.d.ts | 37 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 118 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/NodeAPIArraybuffer.test.ets | 204 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeAPIArraybuffer}/hvigorfile.ts | 0 .../NodeAPIArraybuffer/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIArraybuffer/ohosTest.md | 11 + .../screenshots/NodeAPIArraybuffer1.png | Bin .../screenshots/NodeAPIArraybuffer2.png | Bin .../NodeAPIBasicDataTypes}/.gitignore | 0 .../NodeAPIBasicDataTypes/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeAPIBasicDataTypes/README.md | 75 + .../NodeAPIBasicDataTypes/build-profile.json5 | 58 + .../NodeAPIBasicDataTypes}/code-linter.json5 | 0 .../NodeAPIBasicDataTypes/entry/.gitignore | 6 + .../entry/build-profile.json5 | 59 + .../NodeAPIBasicDataTypes/entry/hvigorfile.ts | 21 + .../entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 204 + .../src/main/cpp/types/libentry/Index.d.ts | 46 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 152 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/NodeAPIBasicDataTypes.test.ets | 342 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeAPIBasicDataTypes}/hvigorfile.ts | 0 .../NodeAPIBasicDataTypes/oh-package.json5 | 25 + .../NodeAPIBasicDataTypes/ohosTest.md | 15 + .../screenshots/NodeAPIBasicDataTypes1.png | Bin .../screenshots/NodeAPIBasicDataTypes2.png | Bin .../NodeApiUse/NodeAPIBigint}/.gitignore | 0 .../NodeAPIBigint/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeAPIBigint/README.md | 75 + .../NodeAPIBigint/build-profile.json5 | 58 + .../NodeAPIBigint}/code-linter.json5 | 0 .../NodeApiUse/NodeAPIBigint/entry/.gitignore | 6 + .../NodeAPIBigint/entry/build-profile.json5 | 59 + .../NodeAPIBigint/entry/hvigorfile.ts | 21 + .../NodeAPIBigint/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 162 + .../src/main/cpp/types/libentry/Index.d.ts | 38 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 149 + .../NodeAPIBigint/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/test/NodeAPIBigint.test.ets | 278 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../NodeAPIBigint/hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIBigint}/hvigorfile.ts | 0 .../NodeApiUse/NodeAPIBigint/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIBigint/ohosTest.md | 13 + .../screenshots/NodeAPIBigint1.png | Bin .../screenshots/NodeAPIBigint2.png | Bin .../NodeApiUse/NodeAPIBuffer/.gitignore | 12 + .../NodeAPIBuffer/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeAPIBuffer/README.md | 75 + .../NodeAPIBuffer/build-profile.json5 | 58 + .../NodeAPIBuffer}/code-linter.json5 | 0 .../NodeApiUse/NodeAPIBuffer/entry/.gitignore | 6 + .../NodeAPIBuffer/entry/build-profile.json5 | 59 + .../NodeAPIBuffer/entry/hvigorfile.ts | 21 + .../NodeAPIBuffer/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 181 + .../src/main/cpp/types/libentry/Index.d.ts | 26 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 120 + .../NodeAPIBuffer/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/test/NodeAPIBuffer.test.ets | 278 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../NodeAPIBuffer/hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIBuffer}/hvigorfile.ts | 0 .../NodeApiUse/NodeAPIBuffer/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIBuffer/ohosTest.md | 12 + .../screenshots/NodeAPIBuffer1.png | Bin .../screenshots/NodeAPIBuffer2.png | Bin .../NodeApiUse/NodeAPIClass/.gitignore | 12 + .../NodeAPIClass/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeAPI/NodeApiUse/NodeAPIClass/README.md | 73 + .../NodeAPIClass/build-profile.json5 | 58 + .../NodeApiUse/NodeAPIClass/code-linter.json5 | 35 + .../NodeApiUse/NodeAPIClass/entry/.gitignore | 6 + .../NodeAPIClass/entry/build-profile.json5 | 59 + .../NodeAPIClass/entry/hvigorfile.ts | 21 + .../NodeAPIClass/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 120 + .../src/main/cpp/types/libentry/Index.d.ts | 26 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 99 + .../NodeAPIClass/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/test/NodeAPIClass.test.ets | 150 +- .../entry/src/ohosTest/module.json5 | 27 + .../NodeAPIClass/entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../NodeAPIClass/hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIClass/hvigorfile.ts | 21 + .../NodeApiUse/NodeAPIClass/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIClass/ohosTest.md | 9 + .../screenshots/NodeAPIClass1.png | Bin .../screenshots/NodeAPIClass2.png | Bin .../NodeApiUse/NodeAPICleanuphook/.gitignore | 12 + .../NodeAPICleanuphook/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeAPICleanuphook/README.md | 75 + .../NodeAPICleanuphook/build-profile.json5 | 58 + .../NodeAPICleanuphook/code-linter.json5 | 35 + .../NodeAPICleanuphook/entry/.gitignore | 6 + .../entry/build-profile.json5 | 64 + .../NodeAPICleanuphook/entry/hvigorfile.ts | 21 + .../NodeAPICleanuphook/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 191 + .../src/main/cpp/types/libentry/Index.d.ts | 22 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 92 + .../entry/src/main/ets/workers/worker.ts | 0 .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/NodeAPICleanuphook.test.ets | 150 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeAPICleanuphook/hvigorfile.ts | 21 + .../NodeAPICleanuphook/oh-package.json5 | 25 + .../NodeApiUse/NodeAPICleanuphook/ohosTest.md | 9 + .../screenshots/NodeAPICleanuphook1.png | Bin .../screenshots/NodeAPICleanuphook2.png | Bin .../NodeAPI/NodeApiUse/NodeAPIDate/.gitignore | 12 + .../NodeApiUse/NodeAPIDate/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeAPI/NodeApiUse/NodeAPIDate/README.md | 73 + .../NodeAPIDate/build-profile.json5 | 58 + .../NodeApiUse/NodeAPIDate/code-linter.json5 | 35 + .../NodeApiUse/NodeAPIDate/entry/.gitignore | 6 + .../NodeAPIDate/entry/build-profile.json5 | 59 + .../NodeAPIDate/entry/hvigorfile.ts | 21 + .../NodeAPIDate/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 104 + .../src/main/cpp/types/libentry/Index.d.ts | 26 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 105 + .../NodeAPIDate/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/test/NodeAPIDate.test.ets | 182 +- .../entry/src/ohosTest/module.json5 | 27 + .../NodeAPIDate/entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../NodeAPIDate/hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIDate/hvigorfile.ts | 21 + .../NodeApiUse/NodeAPIDate/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIDate/ohosTest.md | 10 + .../NodeAPIDate/screenshots/NodeAPIDate1.png | Bin .../NodeAPIDate/screenshots/NodeAPIDate2.png | Bin .../NodeAPIEnvironmentalLifeCycle/.gitignore | 12 + .../AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeAPIEnvironmentalLifeCycle/README.md | 73 + .../build-profile.json5 | 58 + .../code-linter.json5 | 35 + .../entry/.gitignore | 6 + .../entry/build-profile.json5 | 59 + .../entry/hvigorfile.ts | 21 + .../entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 91 + .../src/main/cpp/types/libentry/Index.d.ts | 22 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 77 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../NodeAPIEnvironmentalLifeCycle.test.ets | 150 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../hvigorfile.ts | 21 + .../oh-package.json5 | 25 + .../NodeAPIEnvironmentalLifeCycle/ohosTest.md | 9 + .../NodeAPIEnvironmentalLifeCycle1.png | Bin .../NodeAPIEnvironmentalLifeCycle2.png | Bin .../NodeApiUse/NodeAPIError/.gitignore | 12 + .../NodeAPIError/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeAPI/NodeApiUse/NodeAPIError/README.md | 73 + .../NodeAPIError/build-profile.json5 | 58 + .../NodeApiUse/NodeAPIError/code-linter.json5 | 35 + .../NodeApiUse/NodeAPIError/entry/.gitignore | 6 + .../NodeAPIError/entry/build-profile.json5 | 59 + .../NodeAPIError/entry/hvigorfile.ts | 21 + .../NodeAPIError/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 324 + .../src/main/cpp/types/libentry/Index.d.ts | 75 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 308 + .../NodeAPIError/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/test/NodeAPIError.test.ets | 406 +- .../entry/src/ohosTest/module.json5 | 27 + .../NodeAPIError/entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../NodeAPIError/hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIError/hvigorfile.ts | 21 + .../NodeApiUse/NodeAPIError/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIError/ohosTest.md | 17 + .../screenshots/NodeAPIError1.png | Bin .../screenshots/NodeAPIError2.png | Bin .../NodeAPIExtendCapabilities/.gitignore | 12 + .../AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeAPIExtendCapabilities/README.md | 73 + .../build-profile.json5 | 58 + .../code-linter.json5 | 35 + .../entry/.gitignore | 6 + .../entry/build-profile.json5 | 59 + .../entry/hvigorfile.ts | 21 + .../entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 18 + .../entry/src/main/cpp/napi_init.cpp | 578 + .../src/main/cpp/types/libentry/Index.d.ts | 96 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 267 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../entry/src/main/resources/rawfile/test.abc | Bin .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../test/NodeAPIExtendCapabilities.test.ets | 634 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeAPIExtendCapabilities/hvigorfile.ts | 21 + .../oh-package.json5 | 25 + .../NodeAPIExtendCapabilities/ohosTest.md | 23 + .../NodeAPIExtendCapabilities1.png | Bin .../NodeAPIExtendCapabilities2.png | Bin .../NodeApiUse/NodeAPIFunction/.gitignore | 12 + .../NodeAPIFunction/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeAPIFunction/README.md | 73 + .../NodeAPIFunction/build-profile.json5 | 58 + .../NodeAPIFunction/code-linter.json5 | 35 + .../NodeAPIFunction/entry/.gitignore | 6 + .../NodeAPIFunction/entry/build-profile.json5 | 59 + .../NodeAPIFunction/entry/hvigorfile.ts | 21 + .../NodeAPIFunction/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 126 + .../src/main/cpp/types/libentry/Index.d.ts | 33 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 141 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/NodeAPIFunction.test.ets | 182 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIFunction/hvigorfile.ts | 21 + .../NodeAPIFunction/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIFunction/ohosTest.md | 10 + .../screenshots/NodeAPIFunction1.png | Bin .../screenshots/NodeAPIFunction2.png | Bin .../NodeApiUse/NodeAPILifeCycle/.gitignore | 12 + .../NodeAPILifeCycle/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeAPILifeCycle/README.md | 73 + .../NodeAPILifeCycle/build-profile.json5 | 58 + .../NodeAPILifeCycle/code-linter.json5 | 35 + .../NodeAPILifeCycle/entry/.gitignore | 6 + .../entry/build-profile.json5 | 59 + .../NodeAPILifeCycle/entry/hvigorfile.ts | 21 + .../NodeAPILifeCycle/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 196 + .../src/main/cpp/types/libentry/Index.d.ts | 32 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 121 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/NodeAPILifeCycle.test.ets | 182 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPILifeCycle/hvigorfile.ts | 21 + .../NodeAPILifeCycle/oh-package.json5 | 25 + .../NodeApiUse/NodeAPILifeCycle/ohosTest.md | 10 + .../screenshots/NodeAPILifeCycle1.png | Bin .../screenshots/NodeAPILifeCycle2.png | Bin .../NodeApiUse/NodeAPIObject/.gitignore | 12 + .../NodeAPIObject/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeAPIObject/README.md | 73 + .../NodeAPIObject/build-profile.json5 | 58 + .../NodeAPIObject/code-linter.json5 | 35 + .../NodeApiUse/NodeAPIObject/entry/.gitignore | 6 + .../NodeAPIObject/entry/build-profile.json5 | 59 + .../NodeAPIObject/entry/hvigorfile.ts | 21 + .../NodeAPIObject/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 303 + .../src/main/cpp/types/libentry/Index.d.ts | 49 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 234 + .../src/main/ets/pages/napiGetPrototype.ts | 84 +- .../NodeAPIObject/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/test/NodeAPIObject.test.ets | 406 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../NodeAPIObject/hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIObject/hvigorfile.ts | 21 + .../NodeApiUse/NodeAPIObject/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIObject/ohosTest.md | 17 + .../screenshots/NodeAPIObject1.png | Bin .../screenshots/NodeAPIObject2.png | Bin .../NodeApiUse/NodeAPIPrimitive/.gitignore | 12 + .../NodeAPIPrimitive/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeAPIPrimitive/README.md | 73 + .../NodeAPIPrimitive/build-profile.json5 | 58 + .../NodeAPIPrimitive/code-linter.json5 | 35 + .../NodeAPIPrimitive/entry/.gitignore | 6 + .../entry/build-profile.json5 | 59 + .../NodeAPIPrimitive/entry/hvigorfile.ts | 21 + .../NodeAPIPrimitive/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 192 + .../src/main/cpp/types/libentry/Index.d.ts | 50 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 166 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/NodeAPIPrimitive.test.ets | 374 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIPrimitive/hvigorfile.ts | 21 + .../NodeAPIPrimitive/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIPrimitive/ohosTest.md | 16 + .../screenshots/NodeAPIPrimitive1.png | Bin .../screenshots/NodeAPIPrimitive2.png | Bin .../NodeApiUse/NodeAPIPromise/.gitignore | 12 + .../NodeAPIPromise/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeAPIPromise/README.md | 73 + .../NodeAPIPromise/build-profile.json5 | 58 + .../NodeAPIPromise/code-linter.json5 | 35 + .../NodeAPIPromise/entry/.gitignore | 6 + .../NodeAPIPromise/entry/build-profile.json5 | 59 + .../NodeAPIPromise/entry/hvigorfile.ts | 21 + .../NodeAPIPromise/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 115 + .../src/main/cpp/types/libentry/Index.d.ts | 24 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 104 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/test/NodeAPIPromise.test.ets | 150 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../NodeAPIPromise/hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIPromise/hvigorfile.ts | 21 + .../NodeAPIPromise/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIPromise/ohosTest.md | 9 + .../screenshots/NodeAPIPromise1.png | Bin .../screenshots/NodeAPIPromise2.png | Bin .../NodeApiUse/NodeAPIProperty/.gitignore | 12 + .../NodeAPIProperty/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeAPIProperty/README.md | 73 + .../NodeAPIProperty/build-profile.json5 | 58 + .../NodeAPIProperty/code-linter.json5 | 35 + .../NodeAPIProperty/entry/.gitignore | 6 + .../NodeAPIProperty/entry/build-profile.json5 | 59 + .../NodeAPIProperty/entry/hvigorfile.ts | 21 + .../NodeAPIProperty/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 391 + .../src/main/cpp/types/libentry/Index.d.ts | 76 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 294 + .../src/main/ets/pages/napiDeleteProperty.ts | 72 +- .../src/main/ets/pages/napiHasOwnProperty.ts | 58 +- .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/NodeAPIProperty.test.ets | 444 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeAPIProperty/hvigorfile.ts | 21 + .../NodeAPIProperty/oh-package.json5 | 25 + .../NodeApiUse/NodeAPIProperty/ohosTest.md | 18 + .../screenshots/NodeAPIProperty1.png | Bin .../screenshots/NodeAPIProperty2.png | Bin .../.gitignore | 12 + .../AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../README.md | 75 + .../build-profile.json5 | 58 + .../code-linter.json5 | 35 + .../entry/.gitignore | 6 + .../entry/build-profile.json5 | 59 + .../entry/hvigorfile.ts | 21 + .../entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 19 + .../entry/src/main/cpp/napi_init.cpp | 95 + .../src/main/cpp/types/libentry/Index.d.ts | 18 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 65 + .../entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 ...deApiCustomAsynchronousOperations.test.ets | 118 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 37 + .../hvigorfile.ts | 21 + .../oh-package.json5 | 25 + .../ohosTest.md | 8 + .../NodeApiCustomAsynchronousOperations1.png | Bin .../NodeApiCustomAsynchronousOperations2.png | Bin .../NodeApiUse/NodeApiString/.gitignore | 12 + .../NodeApiString/AppScope/app.json5 | 25 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin .../NodeApiUse/NodeApiString/README.md | 73 + .../NodeApiString/build-profile.json5 | 58 + .../NodeApiString/code-linter.json5 | 35 + .../NodeApiUse/NodeApiString/entry/.gitignore | 6 + .../NodeApiString/entry/build-profile.json5 | 59 + .../NodeApiString/entry/hvigorfile.ts | 21 + .../NodeApiString/entry/oh-package.json5 | 26 + .../entry/src/main/cpp/CMakeLists.txt | 17 + .../entry/src/main/cpp/napi_init.cpp | 162 + .../src/main/cpp/types/libentry/Index.d.ts | 38 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../main/ets/entryability/EntryAbility.ets | 57 + .../entrybackupability/EntryBackupAbility.ets | 27 + .../entry/src/main/ets/pages/Index.ets | 95 + .../NodeApiString/entry/src/main/module.json5 | 66 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 7 + .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 3 + .../resources/base/profile/main_pages.json | 5 + .../main/resources/dark/element/color.json | 8 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/test/NodeApiString.test.ets | 118 +- .../entry/src/ohosTest/module.json5 | 27 + .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../NodeApiString/hvigor/hvigor-config.json5 | 37 + .../NodeApiUse/NodeApiString/hvigorfile.ts | 21 + .../NodeApiUse/NodeApiString/oh-package.json5 | 25 + .../NodeApiUse/NodeApiString/ohosTest.md | 8 + .../screenshots/NodeApiString1.png | Bin .../screenshots/NodeApiString2.png | Bin .../DynamicImport/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../ArkTSModule/DynamicImport/README.md | 111 - .../DynamicImport/build-profile.json5 | 86 - .../DynamicImport/entry/build-profile.json5 | 81 - .../DynamicImport/entry/oh-package.json5 | 38 - .../entry/src/main/cpp/CMakeLists.txt | 15 - .../entry/src/main/cpp/napi_init.cpp | 55 - .../src/main/cpp/types/libentry/index.d.ts | 18 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../DynamicImport/entry/src/main/ets/Calc.ets | 22 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Calc.ets | 20 - .../entry/src/main/ets/utils/Calc.ets | 20 - .../DynamicImport/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../ArkTSModule/DynamicImport/har1/Index.ets | 20 - .../DynamicImport/har1/build-profile.json5 | 46 - .../DynamicImport/har1/oh-package.json5 | 24 - .../har1/src/main/ets/components/MainPage.ets | 31 - .../har1/src/main/ets/utils/Calc.ets | 27 - .../DynamicImport/har1/src/main/module.json5 | 25 - .../har1/src/ohosTest/module.json5 | 27 - .../ArkTSModule/DynamicImport/har2/Index.ets | 20 - .../DynamicImport/har2/build-profile.json5 | 46 - .../DynamicImport/har2/oh-package.json5 | 24 - .../har2/src/main/ets/components/MainPage.ets | 31 - .../har2/src/main/ets/utils/Calc.ets | 22 - .../DynamicImport/har2/src/main/module.json5 | 25 - .../har2/src/ohosTest/module.json5 | 27 - .../DynamicImport/harlibrary/Index.ets | 20 - .../harlibrary/build-profile.json5 | 46 - .../DynamicImport/harlibrary/oh-package.json5 | 24 - .../src/main/ets/components/MainPage.ets | 31 - .../harlibrary/src/main/ets/utils/Calc.ets | 36 - .../harlibrary/src/main/module.json5 | 25 - .../harlibrary/src/ohosTest/module.json5 | 27 - .../DynamicImport/hvigor/hvigor-config.json5 | 37 - .../ArkTSModule/DynamicImport/myHar/Index.ets | 24 - .../DynamicImport/myHar/build-profile.json5 | 46 - .../DynamicImport/myHar/oh-package.json5 | 24 - .../src/main/ets/components/MainPage.ets | 31 - .../DynamicImport/myHar/src/main/module.json5 | 25 - .../myHar/src/ohosTest/module.json5 | 27 - .../ArkTSModule/DynamicImport/myHsp/Index.ets | 22 - .../DynamicImport/myHsp/build-profile.json5 | 43 - .../DynamicImport/myHsp/oh-package.json5 | 26 - .../DynamicImport/myHsp/src/main/module.json5 | 28 - .../main/resources/base/element/string.json | 8 - .../myHsp/src/ohosTest/module.json5 | 27 - .../DynamicImport/oh-package.json5 | 25 - .../ArkTSModule/DynamicImport/ohosTest.md | 27 - .../JsApisLoadNativeModule/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsApisLoadNativeModule/README.md | 73 - .../build-profile.json5 | 58 - .../entry/build-profile.json5 | 70 - .../entry/oh-package.json5 | 28 - .../entry/src/main/cpp/CMakeLists.txt | 15 - .../entry/src/main/cpp/napi_init.cpp | 62 - .../src/main/cpp/types/libentry/index.d.ts | 18 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 56 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../JsApisLoadNativeModule/oh-package.json5 | 25 - .../JsApisLoadNativeModule/ohosTest.md | 9 - .../ArkTSModule/LazyImport/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../ArkTSModule/LazyImport/README.md | 75 - .../LazyImport/build-profile.json5 | 58 - .../LazyImport/entry/build-profile.json5 | 43 - .../LazyImport/entry/oh-package.json5 | 25 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../LazyImport/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../LazyImport/hvigor/hvigor-config.json5 | 37 - .../ArkTSModule/LazyImport/oh-package.json5 | 25 - .../ArkTSModule/LazyImport/ohosTest.md | 12 - .../AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../ModuleLoadingSideEffects/README.md | 74 - .../build-profile.json5 | 58 - .../entry/build-profile.json5 | 43 - .../entry/oh-package.json5 | 25 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../LazyImportChangeExecutionOrder/module.ets | 20 - .../moduleOptimize.ets | 20 - .../ets/pages/ModifyGlobalObject/module.ets | 20 - .../ModifyGlobalObject/moduleOptimize.ets | 20 - .../ModifyTheApplicationLevelArkUI/module.ets | 20 - .../moduleOptimize.ets | 20 - .../ets/pages/TopCodeModification/module.ets | 24 - .../entry/src/main/ets/util/resource.ets | 25 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../ModuleLoadingSideEffects/oh-package.json5 | 25 - .../ModuleLoadingSideEffects/ohosTest.md | 12 - .../AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NativeInterthreadShared/README.md | 78 - .../build-profile.json5 | 58 - .../entry/build-profile.json5 | 55 - .../entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 15 - .../entry/src/main/cpp/napi_init.cpp | 132 - .../src/main/cpp/types/libentry/Index.d.ts | 18 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 45 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../NativeInterthreadShared/oh-package.json5 | 25 - .../NativeInterthreadShared/ohosTest.md | 8 - .../AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../AsyncConcurrencyOverview/README.md | 66 - .../build-profile.json5 | 58 - .../entry/build-profile.json5 | 43 - .../entry/oh-package.json5 | 25 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../AsyncConcurrencyOverview/oh-package.json5 | 25 - .../AsyncConcurrencyOverview/ohosTest.md | 8 - .../CommunicationObjects/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../CommunicationObjects/README.md | 93 - .../CommunicationObjects/build-profile.json5 | 58 - .../entry/build-profile.json5 | 43 - .../entry/oh-package.json5 | 25 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/managers/Test.ets | 24 - .../entry/src/main/ets/util/resource.ets | 25 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../CommunicationObjects/oh-package.json5 | 25 - .../CommunicationObjects/ohosTest.md | 11 - .../notallowedInside/build-profile.json5 | 43 - .../notallowedInside/oh-package.json5 | 25 - .../notallowedInside/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../src/ohosTest/module.json5 | 27 - .../objectliterals/build-profile.json5 | 43 - .../objectliterals/oh-package.json5 | 25 - .../ObjectliteralsAbility.ets | 56 - .../objectliterals/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../objectliterals/src/ohosTest/module.json5 | 27 - .../templatetype/build-profile.json5 | 43 - .../templatetype/oh-package.json5 | 25 - .../templatetype/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../templatetype/src/ohosTest/module.json5 | 27 - .../typecannot/build-profile.json5 | 43 - .../typecannot/oh-package.json5 | 25 - .../typecannot/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../typecannot/src/ohosTest/module.json5 | 27 - .../variablenotsupported/build-profile.json5 | 43 - .../variablenotsupported/oh-package.json5 | 25 - .../src/main/module.json5 | 42 - .../src/ohosTest/module.json5 | 27 - .../variablesupport/build-profile.json5 | 43 - .../variablesupport/oh-package.json5 | 25 - .../variablesupport/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../variablesupport/src/ohosTest/module.json5 | 27 - .../AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../MultiThreadConcurrencyOverview/README.md | 72 - .../build-profile.json5 | 58 - .../entry/build-profile.json5 | 43 - .../entry/oh-package.json5 | 25 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../oh-package.json5 | 25 - .../ohosTest.md | 9 - .../ArkTs/JSVMAPI/JsvmDebug/.gitignore | 12 - .../JSVMAPI/JsvmDebug/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../ArkTs/JSVMAPI/JsvmDebug/README.md | 138 - .../JsvmDebug/aboutcodecache/.gitignore | 6 - .../aboutcodecache/build-profile.json5 | 54 - .../JsvmDebug/aboutcodecache/hvigorfile.ts | 21 - .../aboutcodecache/obfuscation-rules.txt | 23 - .../JsvmDebug/aboutcodecache/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../aboutcodecache/src/main/cpp/hello.cpp | 207 - .../cpp/types/libaboutcodecache/Index.d.ts | 16 - .../types/libaboutcodecache/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../aboutcodecache/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../aboutcodecache/src/ohosTest/module.json5 | 27 - .../JSVMAPI/JsvmDebug/build-profile.json5 | 94 - .../ArkTs/JSVMAPI/JsvmDebug/code-linter.json5 | 35 - .../JsvmDebug/hvigor/hvigor-config.json5 | 37 - .../ArkTs/JSVMAPI/JsvmDebug/hvigorfile.ts | 22 - .../ArkTs/JSVMAPI/JsvmDebug/oh-package.json5 | 25 - .../ArkTs/JSVMAPI/JsvmDebug/ohosTest.md | 11 - .../JsvmDebug/openinspector/.gitignore | 6 - .../openinspector/build-profile.json5 | 54 - .../JsvmDebug/openinspector/hvigorfile.ts | 21 - .../openinspector/obfuscation-rules.txt | 23 - .../JsvmDebug/openinspector/oh-package.json5 | 26 - .../openinspector/src/main/cpp/CMakeLists.txt | 13 - .../openinspector/src/main/cpp/hello.cpp | 163 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../src/main/ets/pages/Index.ets | 43 - .../openinspector/src/main/module.json5 | 78 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../openinspector/src/ohosTest/module.json5 | 27 - .../JsvmDebug/runtimetask/build-profile.json5 | 54 - .../JsvmDebug/runtimetask/hvigorfile.ts | 21 - .../JsvmDebug/runtimetask/oh-package.json5 | 26 - .../runtimetask/src/main/cpp/CMakeLists.txt | 13 - .../runtimetask/src/main/cpp/hello.cpp | 425 - .../runtimetask/src/main/ets/pages/Index.ets | 43 - .../runtimetask/src/main/module.json5 | 41 - .../main/resources/base/element/color.json | 8 - .../runtimetask/src/ohosTest/module.json5 | 26 - .../JSVMAPI/JsvmDebug/snapshot/.gitignore | 6 - .../JsvmDebug/snapshot/build-profile.json5 | 54 - .../JSVMAPI/JsvmDebug/snapshot/hvigorfile.ts | 21 - .../JsvmDebug/snapshot/obfuscation-rules.txt | 23 - .../JsvmDebug/snapshot/oh-package.json5 | 26 - .../snapshot/src/main/cpp/CMakeLists.txt | 13 - .../JsvmDebug/snapshot/src/main/cpp/hello.cpp | 238 - .../src/main/cpp/types/libsnapshot/Index.d.ts | 16 - .../cpp/types/libsnapshot/oh-package.json5 | 21 - .../snapshot/src/main/ets/pages/Index.ets | 43 - .../JsvmDebug/snapshot/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../snapshot/src/ohosTest/module.json5 | 27 - .../ArkTs/JSVMAPI/JsvmProcess/.gitignore | 12 - .../JSVMAPI/JsvmProcess/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../ArkTs/JSVMAPI/JsvmProcess/README.md | 76 - .../JSVMAPI/JsvmProcess/build-profile.json5 | 58 - .../JSVMAPI/JsvmProcess/code-linter.json5 | 35 - .../JSVMAPI/JsvmProcess/entry/.gitignore | 6 - .../JsvmProcess/entry/build-profile.json5 | 55 - .../JSVMAPI/JsvmProcess/entry/hvigorfile.ts | 21 - .../JsvmProcess/entry/obfuscation-rules.txt | 23 - .../JsvmProcess/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 14 - .../JsvmProcess/entry/src/main/cpp/hello.cpp | 162 - .../src/main/cpp/types/libentry/Index.d.ts | 18 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 45 - .../JsvmProcess/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../main/resources/en_US/element/string.json | 16 - .../main/resources/zh_CN/element/string.json | 16 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../entry/src/ohosTest/ets/test/List.test.ets | 20 - .../entry/src/ohosTest/module.json5 | 27 - .../JsvmProcess/hvigor/hvigor-config.json5 | 37 - .../ArkTs/JSVMAPI/JsvmProcess/hvigorfile.ts | 21 - .../JSVMAPI/JsvmProcess/oh-package.json5 | 25 - .../ArkTs/JSVMAPI/JsvmProcess/ohosTest.md | 8 - .../JsvmUsageGuide/JsvmAboutArray/.gitignore | 12 - .../JsvmAboutArray/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmUsageGuide/JsvmAboutArray/README.md | 333 - .../JsvmAboutArray/build-profile.json5 | 214 - .../JsvmAboutArray/code-linter.json5 | 35 - .../JsvmAboutArray/createarray/.gitignore | 6 - .../createarray/build-profile.json5 | 54 - .../JsvmAboutArray/createarray/hvigorfile.ts | 21 - .../createarray/obfuscation-rules.txt | 23 - .../createarray/oh-package.json5 | 26 - .../createarray/src/main/cpp/CMakeLists.txt | 14 - .../createarray/src/main/cpp/hello.cpp | 168 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../createarray/src/main/ets/pages/Index.ets | 43 - .../createarray/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createarray/src/ohosTest/module.json5 | 27 - .../createarraywithlength/.gitignore | 6 - .../createarraywithlength/build-profile.json5 | 54 - .../createarraywithlength/hvigorfile.ts | 21 - .../obfuscation-rules.txt | 23 - .../createarraywithlength/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../src/main/cpp/hello.cpp | 175 - .../types/libcreatearraywithlength/Index.d.ts | 16 - .../libcreatearraywithlength/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../JsvmAboutArray/createdataview/.gitignore | 6 - .../createdataview/build-profile.json5 | 54 - .../createdataview/hvigorfile.ts | 21 - .../createdataview/obfuscation-rules.txt | 23 - .../createdataview/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../createdataview/src/main/cpp/hello.cpp | 225 - .../cpp/types/libcreatedataview/Index.d.ts | 16 - .../types/libcreatedataview/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createdataview/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 54 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createdataview/src/ohosTest/module.json5 | 27 - .../createtypedarray/.gitignore | 6 - .../createtypedarray/build-profile.json5 | 54 - .../createtypedarray/hvigorfile.ts | 21 - .../createtypedarray/obfuscation-rules.txt | 23 - .../createtypedarray/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../createtypedarray/src/main/cpp/hello.cpp | 218 - .../cpp/types/libcreatetypedarray/Index.d.ts | 16 - .../libcreatetypedarray/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createtypedarray/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../JsvmAboutArray/deleteelement/.gitignore | 6 - .../deleteelement/build-profile.json5 | 54 - .../deleteelement/hvigorfile.ts | 21 - .../deleteelement/obfuscation-rules.txt | 23 - .../deleteelement/oh-package.json5 | 26 - .../deleteelement/src/main/cpp/CMakeLists.txt | 13 - .../deleteelement/src/main/cpp/hello.cpp | 169 - .../cpp/types/libdeleteelement/Index.d.ts | 16 - .../types/libdeleteelement/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../deleteelement/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../deleteelement/src/ohosTest/module.json5 | 27 - .../JsvmAboutArray/getarraylength/.gitignore | 6 - .../getarraylength/build-profile.json5 | 54 - .../getarraylength/hvigorfile.ts | 21 - .../getarraylength/obfuscation-rules.txt | 23 - .../getarraylength/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../getarraylength/src/main/cpp/hello.cpp | 167 - .../cpp/types/libgetarraylength/Index.d.ts | 16 - .../types/libgetarraylength/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getarraylength/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getarraylength/src/ohosTest/module.json5 | 27 - .../JsvmAboutArray/getdataviewinfo/.gitignore | 6 - .../getdataviewinfo/build-profile.json5 | 54 - .../getdataviewinfo/hvigorfile.ts | 21 - .../getdataviewinfo/obfuscation-rules.txt | 23 - .../getdataviewinfo/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../getdataviewinfo/src/main/cpp/hello.cpp | 218 - .../cpp/types/libgetdataviewinfo/Index.d.ts | 16 - .../types/libgetdataviewinfo/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getdataviewinfo/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getdataviewinfo/src/ohosTest/module.json5 | 27 - .../JsvmAboutArray/getelement/.gitignore | 6 - .../getelement/build-profile.json5 | 54 - .../JsvmAboutArray/getelement/hvigorfile.ts | 21 - .../getelement/obfuscation-rules.txt | 23 - .../getelement/oh-package.json5 | 26 - .../getelement/src/main/cpp/CMakeLists.txt | 13 - .../getelement/src/main/cpp/hello.cpp | 166 - .../main/cpp/types/libgetelement/Index.d.ts | 16 - .../cpp/types/libgetelement/oh-package.json5 | 21 - .../getelement/src/main/ets/pages/Index.ets | 43 - .../getelement/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getelement/src/ohosTest/module.json5 | 28 - .../gettypedarrayinfo/.gitignore | 6 - .../gettypedarrayinfo/build-profile.json5 | 54 - .../gettypedarrayinfo/hvigorfile.ts | 21 - .../gettypedarrayinfo/obfuscation-rules.txt | 23 - .../gettypedarrayinfo/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../gettypedarrayinfo/src/main/cpp/hello.cpp | 227 - .../cpp/types/libgettypedarrayinfo/Index.d.ts | 16 - .../libgettypedarrayinfo/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../gettypedarrayinfo/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 28 - .../JsvmAboutArray/haselement/.gitignore | 6 - .../haselement/build-profile.json5 | 54 - .../JsvmAboutArray/haselement/hvigorfile.ts | 21 - .../haselement/obfuscation-rules.txt | 23 - .../haselement/oh-package.json5 | 26 - .../haselement/src/main/cpp/CMakeLists.txt | 13 - .../haselement/src/main/cpp/hello.cpp | 169 - .../main/cpp/types/libhaselement/Index.d.ts | 16 - .../cpp/types/libhaselement/oh-package.json5 | 21 - .../haselement/src/main/ets/pages/Index.ets | 43 - .../haselement/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../haselement/src/ohosTest/module.json5 | 28 - .../JsvmAboutArray/hvigor/hvigor-config.json5 | 37 - .../JsvmAboutArray/hvigorfile.ts | 21 - .../JsvmAboutArray/isarray/.gitignore | 6 - .../isarray/build-profile.json5 | 54 - .../JsvmAboutArray/isarray/hvigorfile.ts | 21 - .../isarray/obfuscation-rules.txt | 23 - .../JsvmAboutArray/isarray/oh-package.json5 | 26 - .../isarray/src/main/cpp/CMakeLists.txt | 13 - .../isarray/src/main/cpp/hello.cpp | 163 - .../src/main/cpp/types/libisarray/Index.d.ts | 16 - .../cpp/types/libisarray/oh-package.json5 | 21 - .../isarray/src/main/ets/pages/Index.ets | 43 - .../isarray/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../isarray/src/ohosTest/module.json5 | 28 - .../JsvmAboutArray/isdataview/.gitignore | 6 - .../isdataview/build-profile.json5 | 54 - .../JsvmAboutArray/isdataview/hvigorfile.ts | 21 - .../isdataview/obfuscation-rules.txt | 23 - .../isdataview/oh-package.json5 | 26 - .../isdataview/src/main/cpp/CMakeLists.txt | 13 - .../isdataview/src/main/cpp/hello.cpp | 165 - .../main/cpp/types/libisdataview/Index.d.ts | 16 - .../cpp/types/libisdataview/oh-package.json5 | 21 - .../isdataview/src/main/ets/pages/Index.ets | 43 - .../isdataview/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../isdataview/src/ohosTest/module.json5 | 28 - .../JsvmAboutArray/istypedarray/.gitignore | 6 - .../istypedarray/build-profile.json5 | 54 - .../JsvmAboutArray/istypedarray/hvigorfile.ts | 21 - .../istypedarray/obfuscation-rules.txt | 23 - .../istypedarray/oh-package.json5 | 26 - .../istypedarray/src/main/cpp/CMakeLists.txt | 13 - .../istypedarray/src/main/cpp/hello.cpp | 162 - .../main/cpp/types/libistypedarray/Index.d.ts | 16 - .../types/libistypedarray/oh-package.json5 | 21 - .../istypedarray/src/main/ets/pages/Index.ets | 43 - .../istypedarray/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../istypedarray/src/ohosTest/module.json5 | 28 - .../JsvmAboutArray/oh-package.json5 | 25 - .../JsvmUsageGuide/JsvmAboutArray/ohosTest.md | 21 - .../JsvmAboutArray/setelement/.gitignore | 6 - .../setelement/build-profile.json5 | 54 - .../JsvmAboutArray/setelement/hvigorfile.ts | 21 - .../setelement/obfuscation-rules.txt | 23 - .../setelement/oh-package.json5 | 26 - .../setelement/src/main/cpp/CMakeLists.txt | 13 - .../setelement/src/main/cpp/hello.cpp | 162 - .../main/cpp/types/libsetelement/Index.d.ts | 16 - .../cpp/types/libsetelement/oh-package.json5 | 21 - .../setelement/src/main/ets/pages/Index.ets | 43 - .../setelement/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../setelement/src/ohosTest/module.json5 | 28 - .../JsvmAboutArraybuffer/.gitignore | 12 - .../JsvmAboutArraybuffer/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmAboutArraybuffer/README.md | 133 - .../JsvmAboutArraybuffer/build-profile.json5 | 94 - .../JsvmAboutArraybuffer/code-linter.json5 | 35 - .../createarraybuffer/.gitignore | 6 - .../createarraybuffer/build-profile.json5 | 54 - .../createarraybuffer/hvigorfile.ts | 21 - .../createarraybuffer/obfuscation-rules.txt | 23 - .../createarraybuffer/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../createarraybuffer/src/main/cpp/hello.cpp | 168 - .../cpp/types/libcreatearraybuffer/Index.d.ts | 16 - .../libcreatearraybuffer/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createarraybuffer/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../getarraybufferinfo/.gitignore | 6 - .../getarraybufferinfo/build-profile.json5 | 54 - .../getarraybufferinfo/hvigorfile.ts | 21 - .../getarraybufferinfo/obfuscation-rules.txt | 23 - .../getarraybufferinfo/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../getarraybufferinfo/src/main/cpp/hello.cpp | 168 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../src/main/ets/pages/Index.ets | 43 - .../getarraybufferinfo/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../JsvmAboutArraybuffer/hvigorfile.ts | 21 - .../isarraybuffer/.gitignore | 6 - .../isarraybuffer/build-profile.json5 | 54 - .../isarraybuffer/hvigorfile.ts | 21 - .../isarraybuffer/obfuscation-rules.txt | 23 - .../isarraybuffer/oh-package.json5 | 26 - .../isarraybuffer/src/main/cpp/CMakeLists.txt | 14 - .../isarraybuffer/src/main/cpp/hello.cpp | 163 - .../cpp/types/libisarraybuffer/Index.d.ts | 16 - .../types/libisarraybuffer/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../isarraybuffer/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../isarraybuffer/src/ohosTest/module.json5 | 27 - .../isdetachedarraybuffer/.gitignore | 6 - .../isdetachedarraybuffer/build-profile.json5 | 54 - .../isdetachedarraybuffer/hvigorfile.ts | 21 - .../obfuscation-rules.txt | 23 - .../isdetachedarraybuffer/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../src/main/cpp/hello.cpp | 182 - .../types/libisdetachedarraybuffer/Index.d.ts | 16 - .../libisdetachedarraybuffer/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../JsvmAboutArraybuffer/oh-package.json5 | 25 - .../JsvmAboutArraybuffer/ohosTest.md | 11 - .../JsvmUsageGuide/JsvmAboutBigint/.gitignore | 12 - .../JsvmAboutBigint/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmUsageGuide/JsvmAboutBigint/README.md | 173 - .../JsvmAboutBigint/build-profile.json5 | 118 - .../JsvmAboutBigint/code-linter.json5 | 35 - .../createbigintint64/.gitignore | 6 - .../createbigintint64/build-profile.json5 | 54 - .../createbigintint64/hvigorfile.ts | 21 - .../createbigintint64/obfuscation-rules.txt | 23 - .../createbigintint64/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../createbigintint64/src/main/cpp/hello.cpp | 156 - .../cpp/types/libcreatebigintint64/Index.d.ts | 16 - .../libcreatebigintint64/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createbigintint64/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../createbigintuint64/.gitignore | 6 - .../createbigintuint64/build-profile.json5 | 54 - .../createbigintuint64/hvigorfile.ts | 21 - .../createbigintuint64/obfuscation-rules.txt | 23 - .../createbigintuint64/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../createbigintuint64/src/main/cpp/hello.cpp | 157 - .../types/libcreatebigintuint64/Index.d.ts | 16 - .../libcreatebigintuint64/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createbigintuint64/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../createbigintwords/.gitignore | 6 - .../createbigintwords/build-profile.json5 | 54 - .../createbigintwords/hvigorfile.ts | 21 - .../createbigintwords/obfuscation-rules.txt | 23 - .../createbigintwords/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../createbigintwords/src/main/cpp/hello.cpp | 159 - .../cpp/types/libcreatebigintwords/Index.d.ts | 16 - .../libcreatebigintwords/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createbigintwords/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../getvaluebigintint64/.gitignore | 6 - .../getvaluebigintint64/build-profile.json5 | 54 - .../getvaluebigintint64/hvigorfile.ts | 21 - .../getvaluebigintint64/obfuscation-rules.txt | 23 - .../getvaluebigintint64/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../src/main/cpp/hello.cpp | 163 - .../types/libgetvaluebigintint64/Index.d.ts | 16 - .../libgetvaluebigintint64/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getvaluebigintint64/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../getvaluebigintuint64/.gitignore | 6 - .../getvaluebigintuint64/build-profile.json5 | 54 - .../getvaluebigintuint64/hvigorfile.ts | 21 - .../obfuscation-rules.txt | 23 - .../getvaluebigintuint64/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../src/main/cpp/hello.cpp | 163 - .../types/libgetvaluebigintuint64/Index.d.ts | 16 - .../libgetvaluebigintuint64/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../getvaluebigintwords/.gitignore | 6 - .../getvaluebigintwords/build-profile.json5 | 54 - .../getvaluebigintwords/hvigorfile.ts | 21 - .../getvaluebigintwords/obfuscation-rules.txt | 23 - .../getvaluebigintwords/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../src/main/cpp/hello.cpp | 179 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../src/main/ets/pages/Index.ets | 43 - .../getvaluebigintwords/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../JsvmAboutBigint/hvigorfile.ts | 21 - .../JsvmAboutBigint/oh-package.json5 | 25 - .../JsvmAboutBigint/ohosTest.md | 13 - .../JsvmAboutClass/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmUsageGuide/JsvmAboutClass/README.md | 113 - .../JsvmAboutClass/build-profile.json5 | 82 - .../defineclass/build-profile.json5 | 54 - .../defineclass/oh-package.json5 | 26 - .../defineclass/src/main/cpp/CMakeLists.txt | 14 - .../defineclass/src/main/cpp/hello.cpp | 207 - .../main/cpp/types/libdefineclass/Index.d.ts | 16 - .../cpp/types/libdefineclass/oh-package.json5 | 21 - .../defineclass/src/main/ets/pages/Index.ets | 43 - .../defineclass/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../defineclass/src/ohosTest/module.json5 | 27 - .../JsvmAboutClass/hvigor/hvigor-config.json5 | 37 - .../newinstance/build-profile.json5 | 54 - .../newinstance/oh-package.json5 | 26 - .../newinstance/src/main/cpp/CMakeLists.txt | 14 - .../newinstance/src/main/cpp/hello.cpp | 176 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../newinstance/src/main/ets/pages/Index.ets | 43 - .../newinstance/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../newinstance/src/ohosTest/module.json5 | 27 - .../JsvmAboutClass/oh-package.json5 | 25 - .../JsvmUsageGuide/JsvmAboutClass/ohosTest.md | 10 - .../removewrap/build-profile.json5 | 54 - .../removewrap/oh-package.json5 | 26 - .../removewrap/src/main/cpp/CMakeLists.txt | 14 - .../removewrap/src/main/cpp/hello.cpp | 209 - .../main/cpp/types/libremovewrap/Index.d.ts | 16 - .../cpp/types/libremovewrap/oh-package.json5 | 21 - .../removewrap/src/main/ets/pages/Index.ets | 43 - .../removewrap/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../removewrap/src/ohosTest/module.json5 | 27 - .../JsvmUsageGuide/JsvmAboutDate/.gitignore | 12 - .../JsvmAboutDate/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmUsageGuide/JsvmAboutDate/README.md | 113 - .../JsvmAboutDate/build-profile.json5 | 82 - .../JsvmAboutDate/code-linter.json5 | 35 - .../JsvmAboutDate/createdate/.gitignore | 6 - .../createdate/build-profile.json5 | 54 - .../JsvmAboutDate/createdate/hvigorfile.ts | 21 - .../createdate/obfuscation-rules.txt | 23 - .../JsvmAboutDate/createdate/oh-package.json5 | 26 - .../createdate/src/main/cpp/CMakeLists.txt | 14 - .../createdate/src/main/cpp/hello.cpp | 170 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../createdate/src/main/ets/pages/Index.ets | 43 - .../createdate/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createdate/src/ohosTest/module.json5 | 27 - .../JsvmAboutDate/getdatevalue/.gitignore | 6 - .../getdatevalue/build-profile.json5 | 54 - .../JsvmAboutDate/getdatevalue/hvigorfile.ts | 21 - .../getdatevalue/obfuscation-rules.txt | 23 - .../getdatevalue/oh-package.json5 | 26 - .../getdatevalue/src/main/cpp/CMakeLists.txt | 14 - .../getdatevalue/src/main/cpp/hello.cpp | 163 - .../main/cpp/types/libgetdatevalue/Index.d.ts | 16 - .../types/libgetdatevalue/oh-package.json5 | 21 - .../getdatevalue/src/main/ets/pages/Index.ets | 43 - .../getdatevalue/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getdatevalue/src/ohosTest/module.json5 | 27 - .../JsvmAboutDate/hvigor/hvigor-config.json5 | 37 - .../JsvmAboutDate/hvigorfile.ts | 21 - .../JsvmAboutDate/isdate/.gitignore | 6 - .../JsvmAboutDate/isdate/build-profile.json5 | 54 - .../JsvmAboutDate/isdate/hvigorfile.ts | 21 - .../isdate/obfuscation-rules.txt | 23 - .../JsvmAboutDate/isdate/oh-package.json5 | 26 - .../isdate/src/main/cpp/CMakeLists.txt | 14 - .../isdate/src/main/cpp/hello.cpp | 155 - .../src/main/cpp/types/libisdate/Index.d.ts | 16 - .../main/cpp/types/libisdate/oh-package.json5 | 21 - .../isdate/src/main/ets/pages/Index.ets | 43 - .../isdate/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../isdate/src/ohosTest/module.json5 | 27 - .../JsvmAboutDate/oh-package.json5 | 25 - .../JsvmUsageGuide/JsvmAboutDate/ohosTest.md | 10 - .../JsvmUsageGuide/JsvmAboutObject/.gitignore | 12 - .../JsvmAboutObject/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmUsageGuide/JsvmAboutObject/README.md | 273 - .../JsvmAboutObject/build-profile.json5 | 178 - .../checkobjecttypetag/.gitignore | 6 - .../checkobjecttypetag/build-profile.json5 | 54 - .../checkobjecttypetag/hvigorfile.ts | 21 - .../checkobjecttypetag/obfuscation-rules.txt | 23 - .../checkobjecttypetag/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../checkobjecttypetag/src/main/cpp/hello.cpp | 205 - .../types/libcheckobjecttypetag/Index.d.ts | 16 - .../libcheckobjecttypetag/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../checkobjecttypetag/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../JsvmAboutObject/code-linter.json5 | 35 - .../JsvmAboutObject/createexternal/.gitignore | 6 - .../createexternal/build-profile.json5 | 54 - .../createexternal/hvigorfile.ts | 21 - .../createexternal/obfuscation-rules.txt | 23 - .../createexternal/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../createexternal/src/main/cpp/hello.cpp | 168 - .../cpp/types/libcreateexternal/Index.d.ts | 16 - .../types/libcreateexternal/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createexternal/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createexternal/src/ohosTest/module.json5 | 27 - .../JsvmAboutObject/createobject/.gitignore | 6 - .../createobject/build-profile.json5 | 54 - .../createobject/hvigorfile.ts | 21 - .../createobject/obfuscation-rules.txt | 23 - .../createobject/oh-package.json5 | 26 - .../createobject/src/main/cpp/CMakeLists.txt | 14 - .../createobject/src/main/cpp/hello.cpp | 164 - .../main/cpp/types/libcreateobject/Index.d.ts | 16 - .../types/libcreateobject/oh-package.json5 | 21 - .../createobject/src/main/ets/pages/Index.ets | 43 - .../createobject/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createobject/src/ohosTest/module.json5 | 27 - .../JsvmAboutObject/createsymbol/.gitignore | 6 - .../createsymbol/build-profile.json5 | 54 - .../createsymbol/hvigorfile.ts | 21 - .../createsymbol/obfuscation-rules.txt | 23 - .../createsymbol/oh-package.json5 | 26 - .../createsymbol/src/main/cpp/CMakeLists.txt | 13 - .../createsymbol/src/main/cpp/hello.cpp | 159 - .../main/cpp/types/libcreatesymbol/Index.d.ts | 16 - .../types/libcreatesymbol/oh-package.json5 | 21 - .../createsymbol/src/main/ets/pages/Index.ets | 43 - .../createsymbol/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createsymbol/src/ohosTest/module.json5 | 27 - .../JsvmAboutObject/getprototype/.gitignore | 6 - .../getprototype/build-profile.json5 | 54 - .../getprototype/hvigorfile.ts | 21 - .../getprototype/obfuscation-rules.txt | 23 - .../getprototype/oh-package.json5 | 26 - .../getprototype/src/main/cpp/CMakeLists.txt | 14 - .../getprototype/src/main/cpp/hello.cpp | 159 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../getprototype/src/main/ets/pages/Index.ets | 43 - .../getprototype/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getprototype/src/ohosTest/module.json5 | 27 - .../getvalueexternal/.gitignore | 6 - .../getvalueexternal/build-profile.json5 | 54 - .../getvalueexternal/hvigorfile.ts | 21 - .../getvalueexternal/obfuscation-rules.txt | 23 - .../getvalueexternal/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../getvalueexternal/src/main/cpp/hello.cpp | 166 - .../cpp/types/libgetvalueexternal/Index.d.ts | 16 - .../libgetvalueexternal/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getvalueexternal/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../JsvmAboutObject/hvigorfile.ts | 21 - .../JsvmAboutObject/instanceof/.gitignore | 6 - .../instanceof/build-profile.json5 | 54 - .../JsvmAboutObject/instanceof/hvigorfile.ts | 21 - .../instanceof/obfuscation-rules.txt | 23 - .../instanceof/oh-package.json5 | 26 - .../instanceof/src/main/cpp/CMakeLists.txt | 13 - .../instanceof/src/main/cpp/hello.cpp | 169 - .../main/cpp/types/libinstanceof/Index.d.ts | 16 - .../cpp/types/libinstanceof/oh-package.json5 | 21 - .../instanceof/src/main/ets/pages/Index.ets | 43 - .../instanceof/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../instanceof/src/ohosTest/module.json5 | 28 - .../JsvmAboutObject/objectfreeze/.gitignore | 6 - .../objectfreeze/build-profile.json5 | 54 - .../objectfreeze/hvigorfile.ts | 21 - .../objectfreeze/obfuscation-rules.txt | 23 - .../objectfreeze/oh-package.json5 | 26 - .../objectfreeze/src/main/cpp/CMakeLists.txt | 14 - .../objectfreeze/src/main/cpp/hello.cpp | 163 - .../main/cpp/types/libobjectfreeze/Index.d.ts | 16 - .../types/libobjectfreeze/oh-package.json5 | 21 - .../objectfreeze/src/main/ets/pages/Index.ets | 43 - .../objectfreeze/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../objectfreeze/src/ohosTest/module.json5 | 28 - .../JsvmAboutObject/objectseal/.gitignore | 6 - .../objectseal/build-profile.json5 | 54 - .../JsvmAboutObject/objectseal/hvigorfile.ts | 21 - .../objectseal/obfuscation-rules.txt | 23 - .../objectseal/oh-package.json5 | 26 - .../objectseal/src/main/cpp/CMakeLists.txt | 14 - .../objectseal/src/main/cpp/hello.cpp | 176 - .../main/cpp/types/libobjectseal/Index.d.ts | 16 - .../cpp/types/libobjectseal/oh-package.json5 | 21 - .../objectseal/src/main/ets/pages/Index.ets | 43 - .../objectseal/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../objectseal/src/ohosTest/module.json5 | 28 - .../JsvmAboutObject/oh-package.json5 | 25 - .../JsvmAboutObject/ohosTest.md | 18 - .../JsvmAboutObject/symbolfor/.gitignore | 6 - .../symbolfor/build-profile.json5 | 54 - .../JsvmAboutObject/symbolfor/hvigorfile.ts | 21 - .../symbolfor/obfuscation-rules.txt | 23 - .../symbolfor/oh-package.json5 | 26 - .../symbolfor/src/main/cpp/CMakeLists.txt | 13 - .../symbolfor/src/main/cpp/hello.cpp | 166 - .../main/cpp/types/libsymbolfor/Index.d.ts | 16 - .../cpp/types/libsymbolfor/oh-package.json5 | 21 - .../symbolfor/src/main/ets/pages/Index.ets | 43 - .../symbolfor/src/main/module.json5 | 43 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../symbolfor/src/ohosTest/module.json5 | 28 - .../JsvmAboutObject/typeof/.gitignore | 6 - .../typeof/build-profile.json5 | 54 - .../JsvmAboutObject/typeof/hvigorfile.ts | 21 - .../typeof/obfuscation-rules.txt | 23 - .../JsvmAboutObject/typeof/oh-package.json5 | 26 - .../typeof/src/main/cpp/CMakeLists.txt | 13 - .../typeof/src/main/cpp/hello.cpp | 199 - .../src/main/cpp/types/libtypeof/Index.d.ts | 16 - .../main/cpp/types/libtypeof/oh-package.json5 | 21 - .../typeof/src/main/ets/pages/Index.ets | 43 - .../typeof/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../typeof/src/ohosTest/module.json5 | 28 - .../JsvmAboutPrimitive/.gitignore | 12 - .../JsvmAboutPrimitive/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmAboutPrimitive/README.md | 233 - .../JsvmAboutPrimitive/build-profile.json5 | 154 - .../JsvmAboutPrimitive/code-linter.json5 | 35 - .../coercetobool/.gitignore | 6 - .../coercetobool/build-profile.json5 | 54 - .../coercetobool/hvigorfile.ts | 21 - .../coercetobool/obfuscation-rules.txt | 23 - .../coercetobool/oh-package.json5 | 26 - .../coercetobool/src/main/cpp/CMakeLists.txt | 14 - .../coercetobool/src/main/cpp/hello.cpp | 159 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../coercetobool/src/main/ets/pages/Index.ets | 43 - .../coercetobool/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../coercetobool/src/ohosTest/module.json5 | 27 - .../coercetonumber/.gitignore | 6 - .../coercetonumber/build-profile.json5 | 54 - .../coercetonumber/hvigorfile.ts | 21 - .../coercetonumber/obfuscation-rules.txt | 23 - .../coercetonumber/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../coercetonumber/src/main/cpp/hello.cpp | 159 - .../cpp/types/libcoercetonumber/Index.d.ts | 16 - .../types/libcoercetonumber/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../coercetonumber/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../coercetonumber/src/ohosTest/module.json5 | 27 - .../coercetoobject/.gitignore | 6 - .../coercetoobject/build-profile.json5 | 54 - .../coercetoobject/hvigorfile.ts | 21 - .../coercetoobject/obfuscation-rules.txt | 23 - .../coercetoobject/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../coercetoobject/src/main/cpp/hello.cpp | 158 - .../cpp/types/libcoercetoobject/Index.d.ts | 16 - .../types/libcoercetoobject/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../coercetoobject/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../coercetoobject/src/ohosTest/module.json5 | 27 - .../coercetostring/.gitignore | 6 - .../coercetostring/build-profile.json5 | 54 - .../coercetostring/hvigorfile.ts | 21 - .../coercetostring/obfuscation-rules.txt | 23 - .../coercetostring/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../coercetostring/src/main/cpp/hello.cpp | 158 - .../cpp/types/libcoercetostring/Index.d.ts | 16 - .../types/libcoercetostring/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../coercetostring/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../coercetostring/src/ohosTest/module.json5 | 27 - .../JsvmAboutPrimitive/getboolean/.gitignore | 6 - .../getboolean/build-profile.json5 | 54 - .../getboolean/hvigorfile.ts | 21 - .../getboolean/obfuscation-rules.txt | 23 - .../getboolean/oh-package.json5 | 26 - .../getboolean/src/main/cpp/CMakeLists.txt | 13 - .../getboolean/src/main/cpp/hello.cpp | 172 - .../main/cpp/types/libgetboolean/Index.d.ts | 16 - .../cpp/types/libgetboolean/oh-package.json5 | 21 - .../getboolean/src/main/ets/pages/Index.ets | 43 - .../getboolean/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getboolean/src/ohosTest/module.json5 | 27 - .../JsvmAboutPrimitive/getglobal/.gitignore | 6 - .../getglobal/build-profile.json5 | 54 - .../getglobal/hvigorfile.ts | 21 - .../getglobal/obfuscation-rules.txt | 23 - .../getglobal/oh-package.json5 | 26 - .../getglobal/src/main/cpp/CMakeLists.txt | 13 - .../getglobal/src/main/cpp/hello.cpp | 158 - .../main/cpp/types/libgetglobal/Index.d.ts | 16 - .../cpp/types/libgetglobal/oh-package.json5 | 21 - .../getglobal/src/main/ets/pages/Index.ets | 43 - .../getglobal/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getglobal/src/ohosTest/module.json5 | 28 - .../JsvmAboutPrimitive/getnull/.gitignore | 6 - .../getnull/build-profile.json5 | 54 - .../JsvmAboutPrimitive/getnull/hvigorfile.ts | 21 - .../getnull/obfuscation-rules.txt | 23 - .../getnull/oh-package.json5 | 26 - .../getnull/src/main/cpp/CMakeLists.txt | 13 - .../getnull/src/main/cpp/hello.cpp | 154 - .../src/main/cpp/types/libgetnull/Index.d.ts | 16 - .../cpp/types/libgetnull/oh-package.json5 | 21 - .../getnull/src/main/ets/pages/Index.ets | 43 - .../getnull/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getnull/src/ohosTest/module.json5 | 28 - .../getundefined/.gitignore | 6 - .../getundefined/build-profile.json5 | 54 - .../getundefined/hvigorfile.ts | 21 - .../getundefined/obfuscation-rules.txt | 23 - .../getundefined/oh-package.json5 | 26 - .../getundefined/src/main/cpp/CMakeLists.txt | 13 - .../getundefined/src/main/cpp/hello.cpp | 159 - .../main/cpp/types/libgetundefined/Index.d.ts | 16 - .../types/libgetundefined/oh-package.json5 | 21 - .../getundefined/src/main/ets/pages/Index.ets | 43 - .../getundefined/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getundefined/src/ohosTest/module.json5 | 28 - .../getvaluebool/.gitignore | 6 - .../getvaluebool/build-profile.json5 | 54 - .../getvaluebool/hvigorfile.ts | 21 - .../getvaluebool/obfuscation-rules.txt | 23 - .../getvaluebool/oh-package.json5 | 26 - .../getvaluebool/src/main/cpp/CMakeLists.txt | 13 - .../getvaluebool/src/main/cpp/hello.cpp | 163 - .../main/cpp/types/libgetvaluebool/Index.d.ts | 16 - .../types/libgetvaluebool/oh-package.json5 | 21 - .../getvaluebool/src/main/ets/pages/Index.ets | 43 - .../getvaluebool/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getvaluebool/src/ohosTest/module.json5 | 28 - .../hvigor/hvigor-config.json5 | 37 - .../JsvmAboutPrimitive/hvigorfile.ts | 21 - .../JsvmAboutPrimitive/oh-package.json5 | 25 - .../JsvmAboutPrimitive/ohosTest.md | 16 - .../JsvmAboutPromise/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmUsageGuide/JsvmAboutPromise/README.md | 93 - .../JsvmAboutPromise/build-profile.json5 | 70 - .../hvigor/hvigor-config.json5 | 37 - .../ispromise/build-profile.json5 | 54 - .../ispromise/oh-package.json5 | 26 - .../ispromise/src/main/cpp/CMakeLists.txt | 13 - .../ispromise/src/main/cpp/hello.cpp | 160 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../ispromise/src/main/ets/pages/Index.ets | 43 - .../ispromise/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../ispromise/src/ohosTest/module.json5 | 27 - .../JsvmAboutPromise/oh-package.json5 | 25 - .../JsvmAboutPromise/ohosTest.md | 9 - .../resolvereject/build-profile.json5 | 54 - .../resolvereject/oh-package.json5 | 26 - .../resolvereject/src/main/cpp/CMakeLists.txt | 13 - .../resolvereject/src/main/cpp/hello.cpp | 197 - .../cpp/types/libresolvereject/Index.d.ts | 16 - .../types/libresolvereject/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../resolvereject/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../resolvereject/src/ohosTest/module.json5 | 27 - .../JsvmAboutProperty/.gitignore | 12 - .../JsvmAboutProperty/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmAboutProperty/README.md | 273 - .../JsvmAboutProperty/build-profile.json5 | 178 - .../JsvmAboutProperty/code-linter.json5 | 35 - .../defineproperties/.gitignore | 6 - .../defineproperties/build-profile.json5 | 54 - .../defineproperties/hvigorfile.ts | 21 - .../defineproperties/obfuscation-rules.txt | 23 - .../defineproperties/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../defineproperties/src/main/cpp/hello.cpp | 257 - .../cpp/types/libdefineproperties/Index.d.ts | 16 - .../libdefineproperties/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../defineproperties/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../deleteproperty/.gitignore | 6 - .../deleteproperty/build-profile.json5 | 54 - .../deleteproperty/hvigorfile.ts | 21 - .../deleteproperty/obfuscation-rules.txt | 23 - .../deleteproperty/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../deleteproperty/src/main/cpp/hello.cpp | 172 - .../cpp/types/libdeleteproperty/Index.d.ts | 16 - .../types/libdeleteproperty/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../deleteproperty/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../deleteproperty/src/ohosTest/module.json5 | 27 - .../getallpropertynames/.gitignore | 6 - .../getallpropertynames/build-profile.json5 | 54 - .../getallpropertynames/hvigorfile.ts | 21 - .../getallpropertynames/obfuscation-rules.txt | 23 - .../getallpropertynames/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../src/main/cpp/hello.cpp | 166 - .../types/libgetallpropertynames/Index.d.ts | 16 - .../libgetallpropertynames/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getallpropertynames/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../getnamedproperty/.gitignore | 6 - .../getnamedproperty/build-profile.json5 | 54 - .../getnamedproperty/hvigorfile.ts | 21 - .../getnamedproperty/obfuscation-rules.txt | 23 - .../getnamedproperty/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../getnamedproperty/src/main/cpp/hello.cpp | 168 - .../cpp/types/libgetnamedproperty/Index.d.ts | 16 - .../libgetnamedproperty/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getnamedproperty/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../JsvmAboutProperty/getproperty/.gitignore | 6 - .../getproperty/build-profile.json5 | 54 - .../getproperty/hvigorfile.ts | 21 - .../getproperty/obfuscation-rules.txt | 23 - .../getproperty/oh-package.json5 | 26 - .../getproperty/src/main/cpp/CMakeLists.txt | 13 - .../getproperty/src/main/cpp/hello.cpp | 163 - .../main/cpp/types/libgetproperty/Index.d.ts | 16 - .../cpp/types/libgetproperty/oh-package.json5 | 21 - .../getproperty/src/main/ets/pages/Index.ets | 43 - .../getproperty/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getproperty/src/ohosTest/module.json5 | 27 - .../getpropertynames/.gitignore | 6 - .../getpropertynames/build-profile.json5 | 54 - .../getpropertynames/hvigorfile.ts | 21 - .../getpropertynames/obfuscation-rules.txt | 23 - .../getpropertynames/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../getpropertynames/src/main/cpp/hello.cpp | 163 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../src/main/ets/pages/Index.ets | 43 - .../getpropertynames/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../hasnamedproperty/.gitignore | 6 - .../hasnamedproperty/build-profile.json5 | 54 - .../hasnamedproperty/hvigorfile.ts | 21 - .../hasnamedproperty/obfuscation-rules.txt | 23 - .../hasnamedproperty/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../hasnamedproperty/src/main/cpp/hello.cpp | 171 - .../cpp/types/libhasnamedproperty/Index.d.ts | 16 - .../libhasnamedproperty/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../hasnamedproperty/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 28 - .../hasownproperty/.gitignore | 6 - .../hasownproperty/build-profile.json5 | 54 - .../hasownproperty/hvigorfile.ts | 21 - .../hasownproperty/obfuscation-rules.txt | 23 - .../hasownproperty/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../hasownproperty/src/main/cpp/hello.cpp | 181 - .../cpp/types/libhasownproperty/Index.d.ts | 16 - .../types/libhasownproperty/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../hasownproperty/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../hasownproperty/src/ohosTest/module.json5 | 28 - .../JsvmAboutProperty/hasproperty/.gitignore | 6 - .../hasproperty/build-profile.json5 | 54 - .../hasproperty/hvigorfile.ts | 21 - .../hasproperty/obfuscation-rules.txt | 23 - .../hasproperty/oh-package.json5 | 26 - .../hasproperty/src/main/cpp/CMakeLists.txt | 13 - .../hasproperty/src/main/cpp/hello.cpp | 167 - .../main/cpp/types/libhasproperty/Index.d.ts | 16 - .../cpp/types/libhasproperty/oh-package.json5 | 21 - .../hasproperty/src/main/ets/pages/Index.ets | 43 - .../hasproperty/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../hasproperty/src/ohosTest/module.json5 | 28 - .../hvigor/hvigor-config.json5 | 37 - .../JsvmAboutProperty/hvigorfile.ts | 21 - .../JsvmAboutProperty/oh-package.json5 | 25 - .../JsvmAboutProperty/ohosTest.md | 18 - .../setnamedproperty/.gitignore | 6 - .../setnamedproperty/build-profile.json5 | 54 - .../setnamedproperty/hvigorfile.ts | 21 - .../setnamedproperty/obfuscation-rules.txt | 23 - .../setnamedproperty/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../setnamedproperty/src/main/cpp/hello.cpp | 174 - .../cpp/types/libsetnamedproperty/Index.d.ts | 16 - .../libsetnamedproperty/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../setnamedproperty/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 28 - .../JsvmAboutProperty/setproperty/.gitignore | 6 - .../setproperty/build-profile.json5 | 54 - .../setproperty/hvigorfile.ts | 21 - .../setproperty/obfuscation-rules.txt | 23 - .../setproperty/oh-package.json5 | 26 - .../setproperty/src/main/cpp/CMakeLists.txt | 13 - .../setproperty/src/main/cpp/hello.cpp | 167 - .../main/cpp/types/libsetproperty/Index.d.ts | 16 - .../cpp/types/libsetproperty/oh-package.json5 | 21 - .../setproperty/src/main/ets/pages/Index.ets | 43 - .../setproperty/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../setproperty/src/ohosTest/module.json5 | 28 - .../JsvmUsageGuide/JsvmAboutString/.gitignore | 12 - .../JsvmAboutString/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmUsageGuide/JsvmAboutString/README.md | 173 - .../JsvmAboutString/build-profile.json5 | 118 - .../JsvmAboutString/code-linter.json5 | 35 - .../createstringlatin1/.gitignore | 6 - .../createstringlatin1/build-profile.json5 | 54 - .../createstringlatin1/hvigorfile.ts | 21 - .../createstringlatin1/obfuscation-rules.txt | 23 - .../createstringlatin1/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../createstringlatin1/src/main/cpp/hello.cpp | 165 - .../types/libcreatestringlatin1/Index.d.ts | 16 - .../libcreatestringlatin1/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createstringlatin1/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../createstringutf16/.gitignore | 6 - .../createstringutf16/build-profile.json5 | 54 - .../createstringutf16/hvigorfile.ts | 21 - .../createstringutf16/obfuscation-rules.txt | 23 - .../createstringutf16/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../createstringutf16/src/main/cpp/hello.cpp | 167 - .../cpp/types/libcreatestringutf16/Index.d.ts | 16 - .../libcreatestringutf16/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createstringutf16/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../createstringutf8/.gitignore | 6 - .../createstringutf8/build-profile.json5 | 54 - .../createstringutf8/hvigorfile.ts | 21 - .../createstringutf8/obfuscation-rules.txt | 23 - .../createstringutf8/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../createstringutf8/src/main/cpp/hello.cpp | 161 - .../cpp/types/libcreatestringutf8/Index.d.ts | 16 - .../libcreatestringutf8/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createstringutf8/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../getvaluestringlatin1/.gitignore | 6 - .../getvaluestringlatin1/build-profile.json5 | 54 - .../getvaluestringlatin1/hvigorfile.ts | 21 - .../obfuscation-rules.txt | 23 - .../getvaluestringlatin1/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../src/main/cpp/hello.cpp | 167 - .../types/libgetvaluestringlatin1/Index.d.ts | 16 - .../libgetvaluestringlatin1/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../getvaluestringutf16/.gitignore | 6 - .../getvaluestringutf16/build-profile.json5 | 54 - .../getvaluestringutf16/hvigorfile.ts | 21 - .../getvaluestringutf16/obfuscation-rules.txt | 23 - .../getvaluestringutf16/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../src/main/cpp/hello.cpp | 177 - .../types/libgetvaluestringutf16/Index.d.ts | 16 - .../libgetvaluestringutf16/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getvaluestringutf16/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../getvaluestringutf8/.gitignore | 6 - .../getvaluestringutf8/build-profile.json5 | 54 - .../getvaluestringutf8/hvigorfile.ts | 21 - .../getvaluestringutf8/obfuscation-rules.txt | 23 - .../getvaluestringutf8/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../getvaluestringutf8/src/main/cpp/hello.cpp | 174 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../src/main/ets/pages/Index.ets | 43 - .../getvaluestringutf8/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../JsvmAboutString/hvigorfile.ts | 21 - .../JsvmAboutString/oh-package.json5 | 25 - .../JsvmAboutString/ohosTest.md | 13 - .../JsvmBasicDataTypes/.gitignore | 12 - .../JsvmBasicDataTypes/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmBasicDataTypes/README.md | 213 - .../JsvmBasicDataTypes/build-profile.json5 | 142 - .../JsvmBasicDataTypes/code-linter.json5 | 47 - .../createdouble/.gitignore | 6 - .../createdouble/build-profile.json5 | 54 - .../createdouble/hvigorfile.ts | 21 - .../createdouble/obfuscation-rules.txt | 23 - .../createdouble/oh-package.json5 | 26 - .../createdouble/src/main/cpp/CMakeLists.txt | 14 - .../createdouble/src/main/cpp/hello.cpp | 160 - .../main/cpp/types/libcreatedouble/Index.d.ts | 16 - .../types/libcreatedouble/oh-package.json5 | 21 - .../createdouble/src/main/ets/pages/Index.ets | 43 - .../createdouble/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/float.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createdouble/src/ohosTest/module.json5 | 27 - .../JsvmBasicDataTypes/createint32/.gitignore | 6 - .../createint32/build-profile.json5 | 54 - .../createint32/hvigorfile.ts | 21 - .../createint32/obfuscation-rules.txt | 23 - .../createint32/oh-package.json5 | 26 - .../createint32/src/main/cpp/CMakeLists.txt | 14 - .../createint32/src/main/cpp/hello.cpp | 161 - .../main/cpp/types/libcreateint32/Index.d.ts | 16 - .../cpp/types/libcreateint32/oh-package.json5 | 21 - .../createint32/src/main/ets/pages/Index.ets | 43 - .../createint32/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/float.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createint32/src/ohosTest/module.json5 | 27 - .../JsvmBasicDataTypes/createint64/.gitignore | 6 - .../createint64/build-profile.json5 | 54 - .../createint64/hvigorfile.ts | 21 - .../createint64/obfuscation-rules.txt | 23 - .../createint64/oh-package.json5 | 26 - .../createint64/src/main/cpp/CMakeLists.txt | 14 - .../createint64/src/main/cpp/hello.cpp | 163 - .../main/cpp/types/libcreateint64/Index.d.ts | 16 - .../cpp/types/libcreateint64/oh-package.json5 | 21 - .../createint64/src/main/ets/pages/Index.ets | 43 - .../createint64/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/float.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createint64/src/ohosTest/module.json5 | 27 - .../createuint32/.gitignore | 6 - .../createuint32/build-profile.json5 | 54 - .../createuint32/hvigorfile.ts | 21 - .../createuint32/obfuscation-rules.txt | 23 - .../createuint32/oh-package.json5 | 26 - .../createuint32/src/main/cpp/CMakeLists.txt | 14 - .../createuint32/src/main/cpp/hello.cpp | 165 - .../main/cpp/types/libcreateuint32/Index.d.ts | 16 - .../types/libcreateuint32/oh-package.json5 | 21 - .../createuint32/src/main/ets/pages/Index.ets | 43 - .../createuint32/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/float.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createuint32/src/ohosTest/module.json5 | 27 - .../getvaluedouble/.gitignore | 6 - .../getvaluedouble/build-profile.json5 | 54 - .../getvaluedouble/hvigorfile.ts | 21 - .../getvaluedouble/obfuscation-rules.txt | 23 - .../getvaluedouble/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../getvaluedouble/src/main/cpp/hello.cpp | 160 - .../cpp/types/libgetvaluedouble/Index.d.ts | 16 - .../types/libgetvaluedouble/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getvaluedouble/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/float.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getvaluedouble/src/ohosTest/module.json5 | 27 - .../getvalueint32/.gitignore | 6 - .../getvalueint32/build-profile.json5 | 54 - .../getvalueint32/hvigorfile.ts | 21 - .../getvalueint32/obfuscation-rules.txt | 23 - .../getvalueint32/oh-package.json5 | 26 - .../getvalueint32/src/main/cpp/CMakeLists.txt | 14 - .../getvalueint32/src/main/cpp/hello.cpp | 165 - .../cpp/types/libgetvalueint32/Index.d.ts | 16 - .../types/libgetvalueint32/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getvalueint32/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/float.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getvalueint32/src/ohosTest/module.json5 | 27 - .../getvalueint64/.gitignore | 6 - .../getvalueint64/build-profile.json5 | 54 - .../getvalueint64/hvigorfile.ts | 21 - .../getvalueint64/obfuscation-rules.txt | 23 - .../getvalueint64/oh-package.json5 | 26 - .../getvalueint64/src/main/cpp/CMakeLists.txt | 14 - .../getvalueint64/src/main/cpp/hello.cpp | 162 - .../cpp/types/libgetvalueint64/Index.d.ts | 16 - .../types/libgetvalueint64/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getvalueint64/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/float.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getvalueint64/src/ohosTest/module.json5 | 27 - .../getvalueuint32/.gitignore | 6 - .../getvalueuint32/build-profile.json5 | 54 - .../getvalueuint32/hvigorfile.ts | 21 - .../getvalueuint32/obfuscation-rules.txt | 23 - .../getvalueuint32/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 14 - .../getvalueuint32/src/main/cpp/hello.cpp | 164 - .../cpp/types/libgetvalueuint32/Index.d.ts | 16 - .../types/libgetvalueuint32/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getvalueuint32/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/float.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getvalueuint32/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../JsvmBasicDataTypes/hvigorfile.ts | 21 - .../JsvmBasicDataTypes/oh-package.json5 | 25 - .../JsvmBasicDataTypes/ohosTest.md | 15 - .../JsvmUsageGuide/JsvmError/.gitignore | 12 - .../JsvmError/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmUsageGuide/JsvmError/README.md | 293 - .../JsvmError/build-profile.json5 | 190 - .../JsvmError/code-linter.json5 | 35 - .../JsvmError/createerror/.gitignore | 6 - .../JsvmError/createerror/build-profile.json5 | 54 - .../JsvmError/createerror/hvigorfile.ts | 21 - .../createerror/obfuscation-rules.txt | 23 - .../JsvmError/createerror/oh-package.json5 | 26 - .../createerror/src/main/cpp/CMakeLists.txt | 13 - .../createerror/src/main/cpp/hello.cpp | 179 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../createerror/src/main/ets/pages/Index.ets | 43 - .../createerror/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createerror/src/ohosTest/module.json5 | 27 - .../JsvmError/createrangeerror/.gitignore | 6 - .../createrangeerror/build-profile.json5 | 54 - .../JsvmError/createrangeerror/hvigorfile.ts | 21 - .../createrangeerror/obfuscation-rules.txt | 23 - .../createrangeerror/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../createrangeerror/src/main/cpp/hello.cpp | 159 - .../cpp/types/libcreaterangeerror/Index.d.ts | 16 - .../libcreaterangeerror/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createrangeerror/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../JsvmError/createsyntaxerror/.gitignore | 6 - .../createsyntaxerror/build-profile.json5 | 54 - .../JsvmError/createsyntaxerror/hvigorfile.ts | 21 - .../createsyntaxerror/obfuscation-rules.txt | 23 - .../createsyntaxerror/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../createsyntaxerror/src/main/cpp/hello.cpp | 159 - .../cpp/types/libcreatesyntaxerror/Index.d.ts | 16 - .../libcreatesyntaxerror/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createsyntaxerror/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../JsvmError/createtypeerror/.gitignore | 6 - .../createtypeerror/build-profile.json5 | 54 - .../JsvmError/createtypeerror/hvigorfile.ts | 21 - .../createtypeerror/obfuscation-rules.txt | 23 - .../createtypeerror/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../createtypeerror/src/main/cpp/hello.cpp | 159 - .../cpp/types/libcreatetypeerror/Index.d.ts | 16 - .../types/libcreatetypeerror/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../createtypeerror/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createtypeerror/src/ohosTest/module.json5 | 27 - .../getandclearlastexception/.gitignore | 6 - .../build-profile.json5 | 54 - .../getandclearlastexception/hvigorfile.ts | 21 - .../obfuscation-rules.txt | 23 - .../getandclearlastexception/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../src/main/cpp/hello.cpp | 156 - .../libgetandclearlastexception/Index.d.ts | 16 - .../oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../JsvmError/getlasterrorinfo/.gitignore | 6 - .../getlasterrorinfo/build-profile.json5 | 54 - .../JsvmError/getlasterrorinfo/hvigorfile.ts | 21 - .../getlasterrorinfo/obfuscation-rules.txt | 23 - .../getlasterrorinfo/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../getlasterrorinfo/src/main/cpp/hello.cpp | 166 - .../cpp/types/libgetlasterrorinfo/Index.d.ts | 16 - .../libgetlasterrorinfo/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getlasterrorinfo/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../JsvmError/hvigor/hvigor-config.json5 | 37 - .../JsvmUsageGuide/JsvmError/hvigorfile.ts | 21 - .../JsvmError/iserror/.gitignore | 6 - .../JsvmError/iserror/build-profile.json5 | 54 - .../JsvmError/iserror/hvigorfile.ts | 21 - .../JsvmError/iserror/obfuscation-rules.txt | 23 - .../JsvmError/iserror/oh-package.json5 | 26 - .../iserror/src/main/cpp/CMakeLists.txt | 13 - .../JsvmError/iserror/src/main/cpp/hello.cpp | 161 - .../src/main/cpp/types/libiserror/Index.d.ts | 16 - .../cpp/types/libiserror/oh-package.json5 | 21 - .../iserror/src/main/ets/pages/Index.ets | 43 - .../JsvmError/iserror/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../iserror/src/ohosTest/module.json5 | 28 - .../JsvmError/isexceptionpending/.gitignore | 6 - .../isexceptionpending/build-profile.json5 | 54 - .../isexceptionpending/hvigorfile.ts | 21 - .../isexceptionpending/obfuscation-rules.txt | 23 - .../isexceptionpending/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../isexceptionpending/src/main/cpp/hello.cpp | 168 - .../types/libisexceptionpending/Index.d.ts | 16 - .../libisexceptionpending/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../isexceptionpending/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 28 - .../JsvmUsageGuide/JsvmError/oh-package.json5 | 25 - .../JsvmUsageGuide/JsvmError/ohosTest.md | 20 - .../JsvmError/throwerror/.gitignore | 6 - .../JsvmError/throwerror/build-profile.json5 | 54 - .../JsvmError/throwerror/hvigorfile.ts | 21 - .../throwerror/obfuscation-rules.txt | 23 - .../JsvmError/throwerror/oh-package.json5 | 26 - .../throwerror/src/main/cpp/CMakeLists.txt | 13 - .../throwerror/src/main/cpp/hello.cpp | 183 - .../main/cpp/types/libthrowerror/Index.d.ts | 16 - .../cpp/types/libthrowerror/oh-package.json5 | 21 - .../throwerror/src/main/ets/pages/Index.ets | 43 - .../throwerror/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../throwerror/src/ohosTest/module.json5 | 28 - .../JsvmError/throwrangeerror/.gitignore | 6 - .../throwrangeerror/build-profile.json5 | 54 - .../JsvmError/throwrangeerror/hvigorfile.ts | 21 - .../throwrangeerror/obfuscation-rules.txt | 23 - .../throwrangeerror/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../throwrangeerror/src/main/cpp/hello.cpp | 179 - .../cpp/types/libthrowrangeerror/Index.d.ts | 16 - .../types/libthrowrangeerror/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../throwrangeerror/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../throwrangeerror/src/ohosTest/module.json5 | 28 - .../JsvmError/throwsyntaxerror/.gitignore | 6 - .../throwsyntaxerror/build-profile.json5 | 54 - .../JsvmError/throwsyntaxerror/hvigorfile.ts | 21 - .../throwsyntaxerror/obfuscation-rules.txt | 23 - .../throwsyntaxerror/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../throwsyntaxerror/src/main/cpp/hello.cpp | 184 - .../cpp/types/libthrowsyntaxerror/Index.d.ts | 16 - .../libthrowsyntaxerror/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../throwsyntaxerror/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 28 - .../JsvmError/throwtypeerror/.gitignore | 6 - .../throwtypeerror/build-profile.json5 | 54 - .../JsvmError/throwtypeerror/hvigorfile.ts | 21 - .../throwtypeerror/obfuscation-rules.txt | 23 - .../JsvmError/throwtypeerror/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../throwtypeerror/src/main/cpp/hello.cpp | 183 - .../cpp/types/libthrowtypeerror/Index.d.ts | 16 - .../types/libthrowtypeerror/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../throwtypeerror/src/main/module.json5 | 44 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../throwtypeerror/src/ohosTest/module.json5 | 28 - .../JsvmUsageGuide/JsvmLifeCycle/.gitignore | 12 - .../JsvmLifeCycle/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../JsvmUsageGuide/JsvmLifeCycle/README.md | 141 - .../JsvmLifeCycle/addfinalizer/.gitignore | 6 - .../addfinalizer/build-profile.json5 | 54 - .../JsvmLifeCycle/addfinalizer/hvigorfile.ts | 21 - .../addfinalizer/obfuscation-rules.txt | 23 - .../addfinalizer/oh-package.json5 | 26 - .../addfinalizer/src/main/cpp/CMakeLists.txt | 13 - .../addfinalizer/src/main/cpp/hello.cpp | 126 - .../main/cpp/types/libaddfinalizer/Index.d.ts | 16 - .../types/libaddfinalizer/oh-package.json5 | 21 - .../addfinalizer/src/main/ets/pages/Index.ets | 43 - .../addfinalizer/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../addfinalizer/src/ohosTest/module.json5 | 27 - .../JsvmLifeCycle/build-profile.json5 | 94 - .../JsvmLifeCycle/code-linter.json5 | 35 - .../JsvmLifeCycle/hvigor/hvigor-config.json5 | 22 - .../JsvmLifeCycle/hvigorfile.ts | 21 - .../JsvmLifeCycle/oh-package.json5 | 25 - .../JsvmUsageGuide/JsvmLifeCycle/ohosTest.md | 11 - .../openescapablehandlescope/.gitignore | 6 - .../build-profile.json5 | 54 - .../openescapablehandlescope/hvigorfile.ts | 21 - .../obfuscation-rules.txt | 23 - .../openescapablehandlescope/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../src/main/cpp/hello.cpp | 177 - .../libopenescapablehandlescope/Index.d.ts | 16 - .../oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../JsvmLifeCycle/openhandlescope/.gitignore | 6 - .../openhandlescope/build-profile.json5 | 54 - .../openhandlescope/hvigorfile.ts | 21 - .../openhandlescope/obfuscation-rules.txt | 23 - .../openhandlescope/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../openhandlescope/src/main/cpp/hello.cpp | 169 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../src/main/ets/pages/Index.ets | 43 - .../openhandlescope/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../openhandlescope/src/ohosTest/module.json5 | 27 - .../JsvmLifeCycle/referenceref/.gitignore | 6 - .../referenceref/build-profile.json5 | 54 - .../JsvmLifeCycle/referenceref/hvigorfile.ts | 21 - .../referenceref/obfuscation-rules.txt | 23 - .../referenceref/oh-package.json5 | 26 - .../referenceref/src/main/cpp/CMakeLists.txt | 13 - .../referenceref/src/main/cpp/hello.cpp | 195 - .../main/cpp/types/libreferenceref/Index.d.ts | 16 - .../types/libreferenceref/oh-package.json5 | 21 - .../referenceref/src/main/ets/pages/Index.ets | 43 - .../referenceref/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../referenceref/src/ohosTest/module.json5 | 27 - .../UsageInstructionsOne/.gitignore | 12 - .../UsageInstructionsOne/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../UsageInstructionsOne/README.md | 160 - .../UsageInstructionsOne/aboutjson/.gitignore | 6 - .../aboutjson/build-profile.json5 | 54 - .../aboutjson/hvigorfile.ts | 21 - .../aboutjson/obfuscation-rules.txt | 23 - .../aboutjson/oh-package.json5 | 26 - .../aboutjson/src/main/cpp/CMakeLists.txt | 14 - .../aboutjson/src/main/cpp/hello.cpp | 185 - .../main/cpp/types/libaboutjson/Index.d.ts | 16 - .../cpp/types/libaboutjson/oh-package.json5 | 21 - .../aboutjson/src/main/ets/pages/Index.ets | 43 - .../aboutjson/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../aboutjson/src/ohosTest/module.json5 | 26 - .../UsageInstructionsOne/build-profile.json5 | 106 - .../UsageInstructionsOne/code-linter.json5 | 35 - .../createsnapshot/.gitignore | 6 - .../createsnapshot/build-profile.json5 | 54 - .../createsnapshot/hvigorfile.ts | 21 - .../createsnapshot/obfuscation-rules.txt | 23 - .../createsnapshot/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../createsnapshot/src/main/cpp/hello.cpp | 277 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../src/main/ets/pages/Index.ets | 45 - .../createsnapshot/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../createsnapshot/src/ohosTest/module.json5 | 27 - .../functioncall/.gitignore | 6 - .../functioncall/build-profile.json5 | 54 - .../functioncall/hvigorfile.ts | 21 - .../functioncall/obfuscation-rules.txt | 23 - .../functioncall/oh-package.json5 | 26 - .../functioncall/src/main/cpp/CMakeLists.txt | 14 - .../functioncall/src/main/cpp/hello.cpp | 151 - .../main/cpp/types/libfunctioncall/Index.d.ts | 16 - .../types/libfunctioncall/oh-package.json5 | 21 - .../functioncall/src/main/ets/pages/Index.ets | 43 - .../functioncall/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../functioncall/src/ohosTest/module.json5 | 26 - .../hvigor/hvigor-config.json5 | 37 - .../UsageInstructionsOne/hvigorfile.ts | 21 - .../UsageInstructionsOne/oh-package.json5 | 25 - .../UsageInstructionsOne/ohosTest.md | 12 - .../pumpmessageloop/build-profile.json5 | 39 - .../pumpmessageloop/oh-package.json5 | 11 - .../src/main/cpp/CMakeLists.txt | 13 - .../pumpmessageloop/src/main/cpp/hello.cpp | 197 - .../cpp/types/libpumpmessageloop/Index.d.ts | 16 - .../types/libpumpmessageloop/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../pumpmessageloop/src/main/module.json5 | 27 - .../main/resources/base/element/color.json | 8 - .../pumpmessageloop/src/ohosTest/module.json5 | 11 - .../UsageInstructionsTwo/.gitignore | 12 - .../UsageInstructionsTwo/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../UsageInstructionsTwo/README.md | 179 - .../adjustexternalmemory/.gitignore | 6 - .../adjustexternalmemory/build-profile.json5 | 54 - .../adjustexternalmemory/hvigorfile.ts | 21 - .../obfuscation-rules.txt | 23 - .../adjustexternalmemory/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../src/main/cpp/hello.cpp | 159 - .../types/libadjustexternalmemory/Index.d.ts | 16 - .../libadjustexternalmemory/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../UsageInstructionsTwo/build-profile.json5 | 118 - .../UsageInstructionsTwo/code-linter.json5 | 35 - .../getheapstatistics/.gitignore | 6 - .../getheapstatistics/build-profile.json5 | 54 - .../getheapstatistics/hvigorfile.ts | 21 - .../getheapstatistics/obfuscation-rules.txt | 23 - .../getheapstatistics/oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../getheapstatistics/src/main/cpp/hello.cpp | 175 - .../cpp/types/libgetheapstatistics/Index.d.ts | 16 - .../libgetheapstatistics/oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../getheapstatistics/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../getversion/.gitignore | 6 - .../getversion/build-profile.json5 | 54 - .../getversion/hvigorfile.ts | 21 - .../getversion/obfuscation-rules.txt | 23 - .../getversion/oh-package.json5 | 26 - .../getversion/src/main/cpp/CMakeLists.txt | 13 - .../getversion/src/main/cpp/hello.cpp | 175 - .../main/cpp/types/libgetversion/Index.d.ts | 16 - .../cpp/types/libgetversion/oh-package.json5 | 21 - .../getversion/src/main/ets/pages/Index.ets | 43 - .../getversion/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../getversion/src/ohosTest/module.json5 | 27 - .../UsageInstructionsTwo/getvm/.gitignore | 6 - .../getvm/build-profile.json5 | 54 - .../UsageInstructionsTwo/getvm/hvigorfile.ts | 21 - .../getvm/obfuscation-rules.txt | 23 - .../getvm/oh-package.json5 | 26 - .../getvm/src/main/cpp/CMakeLists.txt | 13 - .../getvm/src/main/cpp/hello.cpp | 158 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../getvm/src/main/ets/pages/Index.ets | 43 - .../getvm/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/backup_config.json | 3 - .../resources/base/profile/main_pages.json | 5 - .../main/resources/dark/element/color.json | 8 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../getvm/src/ohosTest/ets/test/List.test.ets | 20 - .../getvm/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../UsageInstructionsTwo/hvigorfile.ts | 21 - .../memorypressurenotification/.gitignore | 6 - .../build-profile.json5 | 54 - .../memorypressurenotification/hvigorfile.ts | 21 - .../obfuscation-rules.txt | 23 - .../oh-package.json5 | 26 - .../src/main/cpp/CMakeLists.txt | 13 - .../src/main/cpp/hello.cpp | 156 - .../libmemorypressurenotification/Index.d.ts | 16 - .../oh-package.json5 | 21 - .../src/main/ets/pages/Index.ets | 43 - .../src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../src/ohosTest/module.json5 | 27 - .../UsageInstructionsTwo/oh-package.json5 | 25 - .../UsageInstructionsTwo/ohosTest.md | 13 - .../strictequals/.gitignore | 6 - .../strictequals/build-profile.json5 | 54 - .../strictequals/hvigorfile.ts | 21 - .../strictequals/obfuscation-rules.txt | 23 - .../strictequals/oh-package.json5 | 26 - .../strictequals/src/main/cpp/CMakeLists.txt | 13 - .../strictequals/src/main/cpp/hello.cpp | 161 - .../main/cpp/types/libstrictequals/Index.d.ts | 16 - .../types/libstrictequals/oh-package.json5 | 21 - .../strictequals/src/main/ets/pages/Index.ets | 43 - .../strictequals/src/main/module.json5 | 42 - .../main/resources/base/element/color.json | 8 - .../main/resources/base/element/string.json | 16 - .../resources/base/media/layered_image.json | 7 - .../resources/base/profile/main_pages.json | 5 - .../src/ohosTest/ets/test/Ability.test.ets | 52 - .../src/ohosTest/ets/test/List.test.ets | 20 - .../strictequals/src/ohosTest/module.json5 | 27 - .../AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeAPIAsynchronousTask/README.md | 74 - .../build-profile.json5 | 58 - .../entry/build-profile.json5 | 59 - .../entry/oh-package.json5 | 27 - .../entry/src/main/cpp/CMakeLists.txt | 18 - .../entry/src/main/cpp/napi_init.cpp | 99 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../src/main/cpp/types/libentry1/Index.d.ts | 16 - .../main/cpp/types/libentry1/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 53 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../NodeAPIAsynchronousTask/oh-package.json5 | 25 - .../NodeAPIAsynchronousTask/ohosTest.md | 9 - .../NodeApiLoadModule/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiLoadModule/README.md | 75 - .../NodeApiLoadModule/build-profile.json5 | 58 - .../entry/build-profile.json5 | 68 - .../NodeApiLoadModule/entry/oh-package.json5 | 27 - .../entry/src/main/cpp/CMakeLists.txt | 18 - .../entry/src/main/cpp/file.cpp | 60 - .../entry/src/main/cpp/napi_init.cpp | 66 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../src/main/cpp/types/libentry1/Index.d.ts | 16 - .../main/cpp/types/libentry1/oh-package.json5 | 21 - .../entry/src/main/ets/Test.ets | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 46 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../NodeApiLoadModule/oh-package.json5 | 25 - .../NodeApiLoadModule/ohosTest.md | 9 - .../AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiLoadModuleWithInfo/README.md | 86 - .../build-profile.json5 | 70 - .../entry/build-profile.json5 | 94 - .../entry/oh-package.json5 | 43 - .../entry/src/main/cpp/CMakeLists.txt | 27 - .../entry/src/main/cpp/file.cpp | 61 - .../entry/src/main/cpp/napi_init.cpp | 62 - .../src/main/cpp/types/libentry/Index.d.ts | 16 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/cpp/types/libentryfour/Index.d.ts | 16 - .../cpp/types/libentryfour/oh-package.json5 | 21 - .../src/main/cpp/types/libentryone/Index.d.ts | 16 - .../cpp/types/libentryone/oh-package.json5 | 21 - .../main/cpp/types/libentrythree/Index.d.ts | 16 - .../cpp/types/libentrythree/oh-package.json5 | 21 - .../src/main/cpp/types/libentrytwo/Index.d.ts | 16 - .../cpp/types/libentrytwo/oh-package.json5 | 21 - .../entry/src/main/ets/Test.ets | 23 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 73 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../NodeApiLoadModuleWithInfo/har1/Index.ets | 24 - .../har1/build-profile.json5 | 72 - .../har1/oh-package.json5 | 29 - .../har1/src/main/cpp/CMakeLists.txt | 15 - .../har1/src/main/cpp/napi_init.cpp | 85 - .../src/main/cpp/types/libhar1/index.d.ts | 18 - .../main/cpp/types/libhar1/oh-package.json5 | 21 - .../har1/src/main/ets/components/MainPage.ets | 31 - .../har1/src/main/module.json5 | 25 - .../har1/src/ohosTest/module.json5 | 27 - .../NodeApiLoadModuleWithInfo/har2/Index.ets | 25 - .../har2/build-profile.json5 | 46 - .../har2/oh-package.json5 | 24 - .../har2/src/main/ets/components/MainPage.ets | 31 - .../har2/src/main/module.json5 | 25 - .../har2/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../library/Index.ets | 23 - .../library/build-profile.json5 | 46 - .../library/oh-package.json5 | 24 - .../src/main/ets/components/MainPage.ets | 31 - .../library/src/main/module.json5 | 25 - .../library/src/ohosTest/module.json5 | 27 - .../oh-package.json5 | 25 - .../NodeApiLoadModuleWithInfo/ohosTest.md | 13 - .../AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiApplicationScenario/README.md | 87 - .../build-profile.json5 | 58 - .../entry/build-profile.json5 | 70 - .../entry/oh-package.json5 | 27 - .../entry/src/main/cpp/CMakeLists.txt | 12 - .../entry/src/main/cpp/napi_init.cpp | 232 - .../src/main/cpp/types/libentry/Index.d.ts | 23 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../src/main/cpp/types/libentry1/Index.d.ts | 17 - .../main/cpp/types/libentry1/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 82 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../oh-package.json5 | 25 - .../NodeApiApplicationScenario/ohosTest.md | 11 - .../NodeAPIArray/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeAPI/NodeApiUse/NodeAPIArray/README.md | 75 - .../NodeAPIArray/build-profile.json5 | 58 - .../NodeAPIArray/entry/build-profile.json5 | 59 - .../NodeAPIArray/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 475 - .../src/main/cpp/types/libentry/Index.d.ts | 89 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 310 - .../NodeAPIArray/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../NodeAPIArray/hvigor/hvigor-config.json5 | 37 - .../NodeApiUse/NodeAPIArray/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIArray/ohosTest.md | 21 - .../NodeAPIArraybuffer/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeAPIArraybuffer/README.md | 75 - .../NodeAPIArraybuffer/build-profile.json5 | 58 - .../entry/build-profile.json5 | 59 - .../NodeAPIArraybuffer/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 157 - .../src/main/cpp/types/libentry/Index.d.ts | 37 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 118 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../NodeAPIArraybuffer/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIArraybuffer/ohosTest.md | 11 - .../NodeAPIBasicDataTypes/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeAPIBasicDataTypes/README.md | 75 - .../NodeAPIBasicDataTypes/build-profile.json5 | 58 - .../entry/build-profile.json5 | 59 - .../entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 204 - .../src/main/cpp/types/libentry/Index.d.ts | 46 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 152 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../NodeAPIBasicDataTypes/oh-package.json5 | 25 - .../NodeAPIBasicDataTypes/ohosTest.md | 15 - .../NodeAPIBigint/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeAPIBigint/README.md | 75 - .../NodeAPIBigint/build-profile.json5 | 58 - .../NodeAPIBigint/entry/build-profile.json5 | 59 - .../NodeAPIBigint/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 162 - .../src/main/cpp/types/libentry/Index.d.ts | 38 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 149 - .../NodeAPIBigint/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../NodeAPIBigint/hvigor/hvigor-config.json5 | 37 - .../NodeApiUse/NodeAPIBigint/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIBigint/ohosTest.md | 13 - .../NodeAPIBuffer/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeAPIBuffer/README.md | 75 - .../NodeAPIBuffer/build-profile.json5 | 58 - .../NodeAPIBuffer/entry/build-profile.json5 | 59 - .../NodeAPIBuffer/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 181 - .../src/main/cpp/types/libentry/Index.d.ts | 26 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 120 - .../NodeAPIBuffer/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../NodeAPIBuffer/hvigor/hvigor-config.json5 | 37 - .../NodeApiUse/NodeAPIBuffer/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIBuffer/ohosTest.md | 12 - .../NodeAPIClass/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeAPI/NodeApiUse/NodeAPIClass/README.md | 73 - .../NodeAPIClass/build-profile.json5 | 58 - .../NodeAPIClass/entry/build-profile.json5 | 59 - .../NodeAPIClass/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 120 - .../src/main/cpp/types/libentry/Index.d.ts | 26 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 99 - .../NodeAPIClass/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../NodeAPIClass/hvigor/hvigor-config.json5 | 37 - .../NodeApiUse/NodeAPIClass/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIClass/ohosTest.md | 9 - .../NodeAPICleanuphook/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeAPICleanuphook/README.md | 75 - .../NodeAPICleanuphook/build-profile.json5 | 58 - .../entry/build-profile.json5 | 64 - .../NodeAPICleanuphook/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 191 - .../src/main/cpp/types/libentry/Index.d.ts | 22 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 92 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../NodeAPICleanuphook/oh-package.json5 | 25 - .../NodeApiUse/NodeAPICleanuphook/ohosTest.md | 9 - .../NodeApiUse/NodeAPIDate/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeAPI/NodeApiUse/NodeAPIDate/README.md | 73 - .../NodeAPIDate/build-profile.json5 | 58 - .../NodeAPIDate/entry/build-profile.json5 | 59 - .../NodeAPIDate/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 104 - .../src/main/cpp/types/libentry/Index.d.ts | 26 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 105 - .../NodeAPIDate/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../NodeAPIDate/hvigor/hvigor-config.json5 | 37 - .../NodeApiUse/NodeAPIDate/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIDate/ohosTest.md | 10 - .../AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeAPIEnvironmentalLifeCycle/README.md | 73 - .../build-profile.json5 | 58 - .../entry/build-profile.json5 | 59 - .../entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 91 - .../src/main/cpp/types/libentry/Index.d.ts | 22 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 77 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../oh-package.json5 | 25 - .../NodeAPIEnvironmentalLifeCycle/ohosTest.md | 9 - .../NodeAPIError/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeAPI/NodeApiUse/NodeAPIError/README.md | 73 - .../NodeAPIError/build-profile.json5 | 58 - .../NodeAPIError/entry/build-profile.json5 | 59 - .../NodeAPIError/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 324 - .../src/main/cpp/types/libentry/Index.d.ts | 75 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 308 - .../NodeAPIError/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../NodeAPIError/hvigor/hvigor-config.json5 | 37 - .../NodeApiUse/NodeAPIError/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIError/ohosTest.md | 17 - .../AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeAPIExtendCapabilities/README.md | 73 - .../build-profile.json5 | 58 - .../entry/build-profile.json5 | 59 - .../entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 18 - .../entry/src/main/cpp/napi_init.cpp | 578 - .../src/main/cpp/types/libentry/Index.d.ts | 96 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 267 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../oh-package.json5 | 25 - .../NodeAPIExtendCapabilities/ohosTest.md | 23 - .../NodeAPIFunction/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeAPIFunction/README.md | 73 - .../NodeAPIFunction/build-profile.json5 | 58 - .../NodeAPIFunction/entry/build-profile.json5 | 59 - .../NodeAPIFunction/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 126 - .../src/main/cpp/types/libentry/Index.d.ts | 33 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 141 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../NodeAPIFunction/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIFunction/ohosTest.md | 10 - .../NodeAPILifeCycle/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeAPILifeCycle/README.md | 73 - .../NodeAPILifeCycle/build-profile.json5 | 58 - .../entry/build-profile.json5 | 59 - .../NodeAPILifeCycle/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 196 - .../src/main/cpp/types/libentry/Index.d.ts | 32 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 121 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../NodeAPILifeCycle/oh-package.json5 | 25 - .../NodeApiUse/NodeAPILifeCycle/ohosTest.md | 10 - .../NodeAPIObject/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeAPIObject/README.md | 73 - .../NodeAPIObject/build-profile.json5 | 58 - .../NodeAPIObject/entry/build-profile.json5 | 59 - .../NodeAPIObject/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 303 - .../src/main/cpp/types/libentry/Index.d.ts | 49 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 234 - .../NodeAPIObject/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../NodeAPIObject/hvigor/hvigor-config.json5 | 37 - .../NodeApiUse/NodeAPIObject/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIObject/ohosTest.md | 17 - .../NodeAPIPrimitive/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeAPIPrimitive/README.md | 73 - .../NodeAPIPrimitive/build-profile.json5 | 58 - .../entry/build-profile.json5 | 59 - .../NodeAPIPrimitive/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 192 - .../src/main/cpp/types/libentry/Index.d.ts | 50 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 166 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../NodeAPIPrimitive/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIPrimitive/ohosTest.md | 16 - .../NodeAPIPromise/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeAPIPromise/README.md | 73 - .../NodeAPIPromise/build-profile.json5 | 58 - .../NodeAPIPromise/entry/build-profile.json5 | 59 - .../NodeAPIPromise/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 115 - .../src/main/cpp/types/libentry/Index.d.ts | 24 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 104 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../NodeAPIPromise/hvigor/hvigor-config.json5 | 37 - .../NodeAPIPromise/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIPromise/ohosTest.md | 9 - .../NodeAPIProperty/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeAPIProperty/README.md | 73 - .../NodeAPIProperty/build-profile.json5 | 58 - .../NodeAPIProperty/entry/build-profile.json5 | 59 - .../NodeAPIProperty/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 391 - .../src/main/cpp/types/libentry/Index.d.ts | 76 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 294 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../NodeAPIProperty/oh-package.json5 | 25 - .../NodeApiUse/NodeAPIProperty/ohosTest.md | 18 - .../AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../README.md | 75 - .../build-profile.json5 | 58 - .../entry/build-profile.json5 | 59 - .../entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 19 - .../entry/src/main/cpp/napi_init.cpp | 95 - .../src/main/cpp/types/libentry/Index.d.ts | 18 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 65 - .../entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../hvigor/hvigor-config.json5 | 37 - .../oh-package.json5 | 25 - .../ohosTest.md | 8 - .../NodeApiString/AppScope/app.json5 | 25 - .../resources/base/element/string.json | 8 - .../NodeApiUse/NodeApiString/README.md | 73 - .../NodeApiString/build-profile.json5 | 58 - .../NodeApiString/entry/build-profile.json5 | 59 - .../NodeApiString/entry/oh-package.json5 | 26 - .../entry/src/main/cpp/CMakeLists.txt | 17 - .../entry/src/main/cpp/napi_init.cpp | 162 - .../src/main/cpp/types/libentry/Index.d.ts | 38 - .../main/cpp/types/libentry/oh-package.json5 | 21 - .../main/ets/entryability/EntryAbility.ets | 57 - .../entrybackupability/EntryBackupAbility.ets | 27 - .../entry/src/main/ets/pages/Index.ets | 95 - .../NodeApiString/entry/src/main/module.json5 | 66 - .../main/resources/base/element/color.json | 8 - .../resources/base/profile/backup_config.json | 3 - .../main/resources/dark/element/color.json | 8 - .../entry/src/ohosTest/module.json5 | 27 - .../NodeApiString/hvigor/hvigor-config.json5 | 37 - .../NodeApiUse/NodeApiString/oh-package.json5 | 25 - .../NodeApiUse/NodeApiString/ohosTest.md | 8 - .../ets/pages/arcList/ArcListAcrScrollBar.ets | 276 +- .../pages/arcList/ArcListArcIndexerBar.ets | 310 +- .../ets/pages/arcList/ArcListContents.ets | 160 +- .../main/ets/pages/arcList/ArcListCrown.ets | 268 +- .../main/ets/pages/arcList/ArcListShow.ets | 254 +- .../ets/pages/arcList/ArcListSideSlip.ets | 316 +- .../main/ets/pages/arcList/ArcListStyles.ets | 700 +- .../main/ets/pages/arcList/ArcLongList.ets | 300 +- .../arcList/arcListBuiltInScrollerBar.ets | 256 +- .../src/main/ets/pages/arcList/index.ets | 262 +- .../ets/pages/arcSwiper/ArcSwiperAction.ets | 154 +- .../pages/arcSwiper/ArcSwiperHorizontal.ets | 128 +- .../ets/pages/arcSwiper/ArcSwiperSideSlip.ets | 146 +- .../ets/pages/arcSwiper/ArcSwiperStyles.ets | 190 +- .../ets/pages/arcSwiper/ArcSwiperToggle.ets | 198 +- .../ets/pages/arcSwiper/ArcSwiperVertical.ets | 134 +- .../src/main/ets/pages/arcSwiper/index.ets | 212 +- .../main/ets/pages/grid/GridDataSource.ets | 116 +- .../src/main/ets/pages/grid/GridScrollbar.ets | 158 +- .../main/ets/pages/grid/GridSideToSide.ets | 178 +- .../src/main/ets/pages/grid/LongGrid.ets | 138 +- .../main/ets/pages/list/CollapseAndExpand.ets | 366 +- .../src/main/ets/pages/list/ListChatRoom.ets | 218 +- .../main/ets/pages/list/ListDataSource.ets | 112 +- .../src/main/ets/pages/list/LongList.ets | 132 +- .../ets/pages/swiper/SwiperAndTabsLinkage.ets | 248 +- .../swiper/SwiperIgnoreComponentSize.ets | 240 +- .../pages/waterFlow/WaterFlowDataSource.ets | 290 +- .../waterFlow/WaterFlowDynamicSwitchover.ets | 358 +- .../waterFlow/WaterFlowGroupingMixing.ets | 360 +- .../waterFlow/WaterFlowInfiniteScrolling.ets | 294 +- .../WaterFlowInfiniteScrollingEarly.ets | 292 +- .../src/main/ets/pages/waterFlow/index.ets | 182 +- .../StateMgmtV2MVVM/AppScope/app.json5 | 52 +- .../resources/base/element/string.json | 16 +- .../ArkUISample/StateMgmtV2MVVM/README.md | 142 +- .../StateMgmtV2MVVM/build-profile.json5 | 116 +- .../StateMgmtV2MVVM/entry/build-profile.json5 | 86 +- .../StateMgmtV2MVVM/entry/oh-package.json5 | 52 +- .../main/ets/entryability/EntryAbility.ets | 114 +- .../src/main/ets/model/TaskListModel.ets | 82 +- .../entry/src/main/ets/model/TaskModel.ets | 42 +- .../entry/src/main/ets/pages/10-Builder.ets | 318 +- .../entry/src/main/ets/pages/2-Local.ets | 76 +- .../entry/src/main/ets/pages/3-Param.ets | 96 +- .../entry/src/main/ets/pages/4-Event.ets | 134 +- .../entry/src/main/ets/pages/5-Repeat.ets | 136 +- .../src/main/ets/pages/6-ObservedV2Trace.ets | 188 +- .../src/main/ets/pages/7-MonitorComputed.ets | 210 +- .../src/main/ets/pages/8-AppStorageV2.ets | 240 +- .../src/main/ets/pages/9-PersistenceV2.ets | 292 +- .../entry/src/main/ets/pages/SettingPage.ets | 100 +- .../entry/src/main/ets/pages/TodoListPage.ets | 112 +- .../ets/settingability/SettingAbility.ets | 114 +- .../entry/src/main/ets/view/BottomView.ets | 124 +- .../entry/src/main/ets/view/ListView.ets | 132 +- .../entry/src/main/ets/view/TitleView.ets | 62 +- .../main/ets/viewmodel/TaskListViewModel.ets | 102 +- .../src/main/ets/viewmodel/TaskViewModel.ets | 66 +- .../entry/src/main/module.json5 | 120 +- .../main/resources/base/element/color.json | 14 +- .../resources/base/profile/backup_config.json | 4 +- .../main/resources/rawfile/defaultTasks.json | 12 +- .../src/ohosTest/ets/test/TodoList.test.ets | 304 +- .../entry/src/ohosTest/module.json5 | 56 +- .../hvigor/hvigor-config.json5 | 76 +- .../StateMgmtV2MVVM/oh-package.json5 | 52 +- .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../ArkWeb/ArkWebSchemeHandler/ohosTest.md | 0 .../ArkWeb/LifecycleWebComp/.gitignore | 0 .../LifecycleWebComp/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ArkWeb/LifecycleWebComp/README.md | 0 .../LifecycleWebComp/build-profile.json5 | 102 +- .../ArkWeb/LifecycleWebComp/code-linter.json5 | 0 .../ArkWeb/LifecycleWebComp/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../LifecycleWebComp/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../LifecycleWebComp/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/index.html | 18 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ArkWeb/LifecycleWebComp/hvigorfile.ts | 0 .../ArkWeb/LifecycleWebComp/oh-package.json5 | 50 +- .../ArkWeb/LifecycleWebComp/ohosTest.md | 0 .../screenshots/LifecycleWebComp.png | Bin .../ArkWeb/ManageWebCompSecPriv/.gitignore | 0 .../ManageWebCompSecPriv/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ArkWeb/ManageWebCompSecPriv/README.md | 0 .../ManageWebCompSecPriv/build-profile.json5 | 102 +- .../ManageWebCompSecPriv/code-linter.json5 | 0 .../ManageWebCompSecPriv/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../ManageWebCompSecPriv/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../pages/AddIntTrackPreventByPassList.ets | 0 .../pages/ClearIntTrackPreventByPassList.ets | 64 +- .../CollectingAdsBlockingInformation.ets | 84 +- .../ets/pages/DisAdsBlockSpecDomPages_one.ets | 130 +- .../ets/pages/DisAdsBlockSpecDomPages_two.ets | 132 +- .../main/ets/pages/EnableIntTrackPrevent.ets | 80 +- .../main/ets/pages/EnablingAdsBlocking.ets | 0 .../entry/src/main/ets/pages/Index.ets | 146 +- .../ets/pages/IsIntTrackPreventEnabled.ets | 80 +- .../ets/pages/LocCrossOriginResAccSol_one.ets | 0 .../ets/pages/LocCrossOriginResAccSol_two.ets | 0 .../ets/pages/OnIntTrackPreventResult.ets | 88 +- .../pages/RemoveIntTrackPreventByPassList.ets | 78 +- .../entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/index.html | 46 +- .../src/main/resources/rawfile/js/script.js | 40 +- .../src/main/resources/resfile/index.html | 112 +- .../src/main/resources/resfile/js/script.js | 40 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ArkWeb/ManageWebCompSecPriv/hvigorfile.ts | 0 .../ManageWebCompSecPriv/oh-package.json5 | 50 +- .../ArkWeb/ManageWebCompSecPriv/ohosTest.md | 0 .../AddIntTrackPreventByPassList.png | Bin .../ClearIntTrackPreventByPassList.png | Bin .../CollectingAdsBlockingInformation.png | Bin .../DisAdsBlockSpecDomPages_one.png | Bin .../DisAdsBlockSpecDomPages_two.png | Bin .../screenshots/EnableIntTrackPrevent.png | Bin .../screenshots/EnablingAdsBlocking_1.png | Bin .../screenshots/EnablingAdsBlocking_2.png | Bin .../screenshots/IsIntTrackPreventEnabled.png | Bin .../LocCrossOriginResAccSol_one.png | Bin .../LocCrossOriginResAccSol_two_1.png | Bin .../LocCrossOriginResAccSol_two_2.png | Bin .../screenshots/OnIntTrackPreventResult.png | Bin .../RemoveIntTrackPreventByPassList.png | Bin .../ArkWeb/ManageWebPageFileIO/.gitignore | 0 .../ManageWebPageFileIO/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ArkWeb/ManageWebPageFileIO/README.md | 0 .../ManageWebPageFileIO/build-profile.json5 | 102 +- .../ManageWebPageFileIO/code-linter.json5 | 0 .../ManageWebPageFileIO/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../ManageWebPageFileIO/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 82 +- .../ets/pages/InitiatingADownloadTask.ets | 146 +- .../src/main/ets/pages/ListenForPageDown.ets | 0 .../src/main/ets/pages/ResumeDownload.ets | 210 +- .../entry/src/main/ets/pages/UploadFiles.ets | 0 .../entry/src/main/ets/pages/downloadUtil.ets | 134 +- .../entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/download.html | 40 +- .../src/main/resources/rawfile/index.html | 42 +- .../src/main/resources/rawfile/local.html | 56 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ArkWeb/ManageWebPageFileIO/hvigorfile.ts | 0 .../ManageWebPageFileIO/oh-package.json5 | 50 +- .../ArkWeb/ManageWebPageFileIO/ohosTest.md | 0 .../screenshots/InitiatingADownloadTask_1.png | Bin .../screenshots/InitiatingADownloadTask_2.png | Bin .../screenshots/ListenForPageDown_1.png | Bin .../screenshots/ListenForPageDown_2.png | Bin .../screenshots/ResumeDownload.png | Bin .../screenshots/UploadFiles_1.png | Bin .../screenshots/UploadFiles_2.png | Bin .../ArkWeb/ManageWebPageInteracts/.gitignore | 0 .../ManageWebPageInteracts/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ArkWeb/ManageWebPageInteracts/README.md | 0 .../build-profile.json5 | 126 +- .../ManageWebPageInteracts/code-linter.json5 | 0 .../ManageWebPageInteracts/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/ImpNestedScroll.ets | 0 .../entry/src/main/ets/pages/Index.ets | 74 +- .../ets/pages/OnIntKbdAttachSysCustIn.ets | 242 +- .../src/main/ets/pages/SetSKBMode_one.ets | 0 .../entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../resources/rawfile/SetSKBModeIndex.html | 50 +- .../src/main/resources/rawfile/index.html | 126 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../ManageWebPageInteracts/entry2/.gitignore | 0 .../entry2/build-profile.json5 | 84 +- .../entry2/hvigorfile.ts | 0 .../entry2/obfuscation-rules.txt | 0 .../entry2/oh-package.json5 | 50 +- .../main/ets/entry2ability/Entry2Ability.ets | 120 +- .../Entry2BackupAbility.ets | 52 +- .../entry2/src/main/ets/pages/Index.ets | 0 .../entry2/src/main/module.json5 | 132 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../src/main/resources/rawfile/index.html | 48 +- .../entry2/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry2/src/ohosTest/module.json5 | 54 +- .../entry2/src/test/List.test.ets | 0 .../entry2/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ManageWebPageInteracts/hvigorfile.ts | 0 .../ManageWebPageInteracts/oh-package.json5 | 50 +- .../ArkWeb/ManageWebPageInteracts/ohosTest.md | 0 .../screenshots/ImpNestedScroll.png | Bin .../screenshots/OnIntKbdAttachSysCustIn.png | Bin .../screenshots/SetSKBMode_one_1.png | Bin .../screenshots/SetSKBMode_one_2.png | Bin .../screenshots/SetSKBMode_two_1.png | Bin .../screenshots/SetSKBMode_two_2.png | Bin .../AcceleratePageAccess/.gitignore | 0 .../AcceleratePageAccess/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../AcceleratePageAccess/README.md | 0 .../AcceleratePageAccess/build-profile.json5 | 198 +- .../AcceleratePageAccess/code-linter.json5 | 0 .../AcceleratePageAccess/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../AcceleratePageAccess/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../AcceleratePageAccess/entry1/.gitignore | 0 .../entry1/build-profile.json5 | 84 +- .../AcceleratePageAccess/entry1/hvigorfile.ts | 0 .../entry1/obfuscation-rules.txt | 0 .../entry1/oh-package.json5 | 50 +- .../main/ets/entry1ability/Entry1Ability.ets | 130 +- .../entry1/src/main/ets/pages/Index.ets | 0 .../entry1/src/main/module.json5 | 92 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../entry1/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry1/src/ohosTest/module.json5 | 54 +- .../entry1/src/test/List.test.ets | 0 .../entry1/src/test/LocalUnit.test.ets | 0 .../AcceleratePageAccess/entry2/.gitignore | 0 .../entry2/build-profile.json5 | 84 +- .../AcceleratePageAccess/entry2/hvigorfile.ts | 0 .../entry2/obfuscation-rules.txt | 0 .../entry2/oh-package.json5 | 50 +- .../main/ets/entry2ability/Entry2Ability.ets | 112 +- .../entry2/src/main/ets/pages/Index.ets | 0 .../entry2/src/main/ets/pages/Prefetching.ets | 0 .../ets/pages/PrefetchingAPOSTRequest_one.ets | 92 +- .../pages/PrefetchingAPOSTRequest_three.ets | 86 +- .../ets/pages/PrefetchingAPOSTRequest_two.ets | 86 +- .../entry2/src/main/module.json5 | 92 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../entry2/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry2/src/ohosTest/module.json5 | 54 +- .../entry2/src/test/List.test.ets | 0 .../entry2/src/test/LocalUnit.test.ets | 0 .../AcceleratePageAccess/entry3/.gitignore | 0 .../entry3/build-profile.json5 | 84 +- .../AcceleratePageAccess/entry3/hvigorfile.ts | 0 .../entry3/obfuscation-rules.txt | 0 .../entry3/oh-package.json5 | 50 +- .../main/ets/entry3ability/Entry3Ability.ets | 132 +- .../src/main/ets/pages/BusinessWebview.ets | 52 +- .../src/main/ets/pages/DynamicComponent.ets | 118 +- .../entry3/src/main/ets/pages/Index.ets | 0 .../src/main/ets/pages/PrecompileConfig.ets | 80 +- .../src/main/ets/pages/PrecompileWebview.ets | 108 +- .../entry3/src/main/module.json5 | 92 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../entry3/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry3/src/ohosTest/module.json5 | 54 +- .../entry3/src/test/List.test.ets | 0 .../entry3/src/test/LocalUnit.test.ets | 0 .../AcceleratePageAccess/entry4/.gitignore | 0 .../entry4/build-profile.json5 | 84 +- .../AcceleratePageAccess/entry4/hvigorfile.ts | 0 .../entry4/obfuscation-rules.txt | 0 .../entry4/oh-package.json5 | 50 +- .../main/ets/entry4ability/Entry4Ability.ets | 132 +- .../src/main/ets/pages/BusinessWebview.ets | 50 +- .../src/main/ets/pages/DynamicComponent.ets | 118 +- .../entry4/src/main/ets/pages/Index.ets | 0 .../src/main/ets/pages/InjectWebview.ets | 126 +- .../entry4/src/main/ets/pages/Resource.ets | 110 +- .../entry4/src/main/module.json5 | 92 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../entry4/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry4/src/ohosTest/module.json5 | 54 +- .../entry4/src/test/List.test.ets | 0 .../entry4/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../AcceleratePageAccess/hvigorfile.ts | 0 .../AcceleratePageAccess/oh-package.json5 | 50 +- .../AcceleratePageAccess/ohosTest.md | 0 .../screenshots/InjOffResNoInt_1.png | Bin .../screenshots/InjOffResNoInt_2.png | Bin .../screenshots/PrecompForCompCache_1.png | Bin .../screenshots/PrecompForCompCache_2.png | Bin .../screenshots/Prefetching.png | Bin .../PrefetchingAPOSTRequest_one.png | Bin .../PrefetchingAPOSTRequest_three.png | Bin .../PrefetchingAPOSTRequest_two.png | Bin .../screenshots/PrepareForPageLoad_one_1.png | Bin .../screenshots/PrepareForPageLoad_one_2.png | Bin .../screenshots/PrepareForPageLoad_two_1.png | Bin .../screenshots/PrepareForPageLoad_two_2.png | Bin .../CustomizePageResp/.gitignore | 0 .../CustomizePageResp/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../CustomizePageResp/README.md | 0 .../CustomizePageResp/build-profile.json5 | 102 +- .../CustomizePageResp/code-linter.json5 | 0 .../CustomizePageResp/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../CustomizePageResp/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../CustomizePageResp/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 110 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../main/ets/pages/OnInterceptRequest_one.ets | 0 .../main/ets/pages/OnInterceptRequest_two.ets | 154 +- .../entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/index1.html | 50 +- .../src/main/resources/rawfile/index2.html | 72 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../CustomizePageResp/hvigorfile.ts | 0 .../CustomizePageResp/oh-package.json5 | 50 +- .../CustomizePageResp/ohosTest.md | 0 .../screenshots/OnInterceptRequest_one_1.png | Bin .../screenshots/OnInterceptRequest_one_2.png | Bin .../screenshots/OnInterceptRequest_two.png | Bin .../LoadPages/.gitignore | 0 .../LoadPages/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 14 +- .../resources/base/media/app_icon.png | Bin .../LoadPages/README.md | 0 .../LoadPages/build-profile.json5 | 102 +- .../LoadPages/code-linter.json5 | 0 .../LoadPages/entry/.gitignore | 0 .../LoadPages/entry/build-profile.json5 | 84 +- .../LoadPages/entry/hvigorfile.ts | 0 .../LoadPages/entry/obfuscation-rules.txt | 0 .../LoadPages/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/GlobalContext.ets | 72 +- .../entry/src/main/ets/pages/Index.ets | 0 .../LoadLocalPageFileInSandboxPath_one.ets | 70 +- .../LoadLocalPageFileInSandboxPath_two.ets | 64 +- .../ets/pages/LoadingHTMLRichTextData.ets | 86 +- .../src/main/ets/pages/LoadingLocalPages.ets | 82 +- .../src/main/ets/pages/LoadingWebPages.ets | 80 +- .../LoadPages/entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/local.html | 42 +- .../src/main/resources/rawfile/local1.html | 42 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../LoadPages/entry/src/ohosTest/module.json5 | 54 +- .../LoadPages/entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../LoadPages/hvigor/hvigor-config.json5 | 74 +- .../LoadPages/hvigorfile.ts | 0 .../LoadPages/oh-package.json5 | 50 +- .../LoadPages/ohosTest.md | 0 .../LoadLocalPageFileInSandboxPath_one.png | Bin .../LoadLocalPageFileInSandboxPath_two.png | Bin .../screenshots/LoadingHTMLRichTextData_1.png | Bin .../screenshots/LoadingHTMLRichTextData_2.png | Bin .../screenshots/LoadingLocalPages_1.png | Bin .../screenshots/LoadingLocalPages_2.png | Bin .../screenshots/LoadingWebPages_1.png | Bin .../screenshots/LoadingWebPages_2.png | Bin .../ManagePageRedirectNav/.gitignore | 0 .../ManagePageRedirectNav/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ManagePageRedirectNav/README.md | 0 .../ManagePageRedirectNav/build-profile.json5 | 102 +- .../ManagePageRedirectNav/code-linter.json5 | 0 .../ManagePageRedirectNav/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../ManagePageRedirectNav/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 110 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../ets/pages/CrossApplicationRedirection.ets | 96 +- .../src/main/ets/pages/HistoryNavigati.ets | 0 .../entry/src/main/ets/pages/Index.ets | 0 .../src/main/ets/pages/PageRedirection.ets | 84 +- .../entry/src/main/ets/pages/ProfilePage.ets | 54 +- .../entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/call.html | 48 +- .../src/main/resources/rawfile/route.html | 48 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ManagePageRedirectNav/hvigorfile.ts | 0 .../ManagePageRedirectNav/oh-package.json5 | 50 +- .../ManagePageRedirectNav/ohosTest.md | 0 .../CrossApplicationRedirection_1.png | Bin .../CrossApplicationRedirection_2.png | Bin .../screenshots/HistoryNavigati_1.png | Bin .../screenshots/HistoryNavigati_2.png | Bin .../screenshots/PageRedirection_1.png | Bin .../screenshots/PageRedirection_2.png | Bin .../NetReqInterceptCacheWinOps/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../NetReqInterceptCacheWinOps/README.md | 0 .../build-profile.json5 | 150 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 108 +- .../entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/hello.cpp | 328 +- .../entry/src/main/cpp/napi_init.cpp | 134 +- .../entry/src/main/cpp/rawfile_request.cpp | 576 +- .../entry/src/main/cpp/rawfile_request.h | 122 +- .../src/main/cpp/types/libentry/Index.d.ts | 42 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 120 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 98 +- .../entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../rawfile/chunked_post_stream.html | 92 +- .../main/resources/rawfile/csp_bypassing.html | 52 +- .../src/main/resources/rawfile/csp_script.js | 42 +- .../src/main/resources/rawfile/isolated.html | 52 +- .../main/resources/rawfile/isolated_script.js | 38 +- .../src/main/resources/rawfile/local.html | 52 +- .../main/resources/rawfile/local_script.js | 38 +- .../src/main/resources/rawfile/post_data.html | 96 +- .../resources/rawfile/service_worker.html | 68 +- .../entry/src/main/resources/rawfile/sw.js | 54 +- .../src/main/resources/rawfile/test.html | 60 +- .../entry/src/main/resources/rawfile/test.mp4 | 0 .../src/main/resources/rawfile/video.html | 50 +- .../entry/src/main/resources/rawfile/xhr | 30 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/Libentry.mock.ets | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../entry2/.gitignore | 0 .../entry2/build-profile.json5 | 84 +- .../entry2/hvigorfile.ts | 0 .../entry2/obfuscation-rules.txt | 0 .../entry2/oh-package.json5 | 50 +- .../main/ets/entry2ability/Entry2Ability.ets | 128 +- .../Entry2BackupAbility.ets | 52 +- .../entry2/src/main/ets/pages/Index.ets | 0 .../entry2/src/main/module.json5 | 138 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../entry2/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry2/src/ohosTest/module.json5 | 52 +- .../entry2/src/test/List.test.ets | 0 .../entry2/src/test/LocalUnit.test.ets | 0 .../entry3/.gitignore | 0 .../entry3/build-profile.json5 | 84 +- .../entry3/hvigorfile.ts | 0 .../entry3/obfuscation-rules.txt | 0 .../entry3/oh-package.json5 | 50 +- .../main/ets/entry3ability/Entry3Ability.ets | 126 +- .../entry3/src/main/ets/pages/Index.ets | 0 .../entry3/src/main/ets/pages/common.ets | 236 +- .../entry3/src/main/module.json5 | 92 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../entry3/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry3/src/ohosTest/module.json5 | 54 +- .../entry3/src/test/List.test.ets | 0 .../entry3/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../NetReqInterceptCacheWinOps/hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../NetReqInterceptCacheWinOps/ohosTest.md | 0 .../screenshots/InterceptNetRequest_1.png | Bin .../screenshots/InterceptNetRequest_2.png | Bin .../screenshots/MigrateWebCompWin_1.png | Bin .../screenshots/MigrateWebCompWin_2.png | Bin .../screenshots/SetBackForwardCache_1.png | Bin .../screenshots/SetBackForwardCache_2.png | Bin .../ArkWeb/ProcessWebPageCont/.gitignore | 0 .../ProcessWebPageCont/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ArkWeb/ProcessWebPageCont/README.md | 0 .../ProcessWebPageCont/build-profile.json5 | 102 +- .../ProcessWebPageCont/code-linter.json5 | 0 .../ProcessWebPageCont/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../ProcessWebPageCont/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../ProcessWebPageCont/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/CalcAdjustSafeArea.ets | 62 +- .../entry/src/main/ets/pages/Index.ets | 82 +- .../main/ets/pages/InitiatePrintAppAPI.ets | 0 .../main/ets/pages/InitiatePrintW3CAPI.ets | 0 .../entry/src/main/ets/pages/PreviewPDF.ets | 76 +- .../entry/src/main/module.json5 | 162 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/print.html | 126 +- .../entry/src/main/resources/rawfile/test.pdf | Bin .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ArkWeb/ProcessWebPageCont/hvigorfile.ts | 0 .../ProcessWebPageCont/oh-package.json5 | 50 +- .../ArkWeb/ProcessWebPageCont/ohosTest.md | 0 .../screenshots/CalcAdjustSafeArea.png | Bin .../screenshots/InitiatePrintAppAPI.png | Bin .../screenshots/InitiatePrintW3CAPI.png | Bin .../screenshots/PreviewPDF.png | Bin .../SetBasicAttrsEvtsOne/.gitignore | 0 .../SetBasicAttrsEvtsOne/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../SetBasicAttrsEvtsOne/README.md | 0 .../SetBasicAttrsEvtsOne/build-profile.json5 | 102 +- .../SetBasicAttrsEvtsOne/code-linter.json5 | 0 .../SetBasicAttrsEvtsOne/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../SetBasicAttrsEvtsOne/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/AllowGeolocation.ets | 0 .../main/ets/pages/ClearAllCookiesSync.ets | 0 .../src/main/ets/pages/ConfigCookieSync.ets | 0 .../entry/src/main/ets/pages/DarkMode_one.ets | 0 .../entry/src/main/ets/pages/DarkMode_two.ets | 0 .../src/main/ets/pages/DeleteAllData.ets | 0 .../src/main/ets/pages/DeleteGeolocation.ets | 0 .../entry/src/main/ets/pages/ExistCookie.ets | 0 .../src/main/ets/pages/FetchCookieSync.ets | 0 .../ets/pages/GetAccessibleGeolocation.ets | 0 .../src/main/ets/pages/IncognitoMode_one.ets | 0 .../src/main/ets/pages/IncognitoMode_two.ets | 0 .../entry/src/main/ets/pages/Index.ets | 162 +- .../src/main/ets/pages/ManageLocPerms.ets | 142 +- .../src/main/ets/pages/OpenPageNewWin.ets | 138 +- .../entry/src/main/module.json5 | 194 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../main/resources/rawfile/darkModePage.html | 68 +- .../main/resources/rawfile/getLocation.html | 68 +- .../src/main/resources/rawfile/index.html | 110 +- .../src/main/resources/rawfile/window.html | 66 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../SetBasicAttrsEvtsOne/hvigorfile.ts | 0 .../SetBasicAttrsEvtsOne/oh-package.json5 | 50 +- .../SetBasicAttrsEvtsOne/ohosTest.md | 0 .../screenshots/AllowGeolocation.png | Bin .../screenshots/ClearAllCookiesSync.png | Bin .../screenshots/ConfigCookieSync.png | Bin .../screenshots/DarkMode_one.png | Bin .../screenshots/DarkMode_two.png | Bin .../screenshots/DeleteAllData.png | Bin .../screenshots/DeleteGeolocation.png | Bin .../screenshots/ExistCookie.png | Bin .../screenshots/FetchCookieSync.png | Bin .../screenshots/GetAccessibleGeolocation.png | Bin .../screenshots/IncognitoMode_one.png | Bin .../screenshots/IncognitoMode_two.png | Bin .../screenshots/ManageLocPerms_1.png | Bin .../screenshots/ManageLocPerms_2.png | Bin .../screenshots/OpenPageNewWin_1.png | Bin .../screenshots/OpenPageNewWin_2.png | Bin .../SetBasicAttrsEvtsTwo/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../SetBasicAttrsEvtsTwo/README.md | 0 .../SetBasicAttrsEvtsTwo/build-profile.json5 | 102 +- .../SetBasicAttrsEvtsTwo/code-linter.json5 | 0 .../SetBasicAttrsEvtsTwo/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../SetBasicAttrsEvtsTwo/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Cache_one.ets | 0 .../entry/src/main/ets/pages/Cache_two.ets | 0 .../src/main/ets/pages/CookieManagement.ets | 0 .../entry/src/main/ets/pages/DomStorage.ets | 0 .../entry/src/main/ets/pages/Index.ets | 114 +- .../src/main/ets/pages/UseMotionDirSensor.ets | 148 +- .../src/main/ets/pages/UserAgent_one.ets | 0 .../src/main/ets/pages/UserAgent_three.ets | 0 .../src/main/ets/pages/UserAgent_two.ets | 0 .../entry/src/main/module.json5 | 160 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/index.html | 308 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../SetBasicAttrsEvtsTwo/hvigorfile.ts | 0 .../SetBasicAttrsEvtsTwo/oh-package.json5 | 50 +- .../SetBasicAttrsEvtsTwo/ohosTest.md | 0 .../screenshots/Cache_one.png | Bin .../screenshots/Cache_two.png | Bin .../screenshots/CookieManagement.png | Bin .../screenshots/DomStorage.png | Bin .../screenshots/UseMotionDirSensor_1.png | Bin .../screenshots/UseMotionDirSensor_2.png | Bin .../screenshots/UserAgent_one.png | Bin .../screenshots/UserAgent_three.png | Bin .../screenshots/UserAgent_two.png | Bin .../ArkWeb/UseFrontendJSApp/.gitignore | 0 .../UseFrontendJSApp/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ArkWeb/UseFrontendJSApp/README.md | 0 .../UseFrontendJSApp/build-profile.json5 | 198 +- .../ArkWeb/UseFrontendJSApp/code-linter.json5 | 0 .../ArkWeb/UseFrontendJSApp/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../UseFrontendJSApp/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../UseFrontendJSApp/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/index.html | 78 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../ArkWeb/UseFrontendJSApp/entry2/.gitignore | 0 .../entry2/build-profile.json5 | 84 +- .../UseFrontendJSApp/entry2/hvigorfile.ts | 0 .../entry2/obfuscation-rules.txt | 0 .../UseFrontendJSApp/entry2/oh-package.json5 | 50 +- .../main/ets/entry2ability/Entry2Ability.ets | 112 +- .../Entry2BackupAbility.ets | 52 +- .../entry2/src/main/ets/pages/Index.ets | 122 +- .../src/main/ets/pages/JavaScriptProxy.ets | 0 .../entry2/src/main/ets/pages/Promise_one.ets | 0 .../entry2/src/main/ets/pages/Promise_two.ets | 0 .../ets/pages/RegisterJavaScriptProxy.ets | 0 .../ets/pages/UsageOfComplexTypes_five.ets | 0 .../ets/pages/UsageOfComplexTypes_four.ets | 0 .../ets/pages/UsageOfComplexTypes_one.ets | 0 .../ets/pages/UsageOfComplexTypes_three.ets | 0 .../ets/pages/UsageOfComplexTypes_two.ets | 0 .../entry2/src/main/module.json5 | 138 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../src/main/resources/rawfile/index1.html | 56 +- .../src/main/resources/rawfile/index2.html | 52 +- .../src/main/resources/rawfile/index3.html | 58 +- .../src/main/resources/rawfile/index4.html | 56 +- .../src/main/resources/rawfile/index5.html | 52 +- .../src/main/resources/rawfile/index6.html | 102 +- .../src/main/resources/rawfile/index7.html | 52 +- .../src/main/resources/rawfile/index8.html | 52 +- .../src/main/resources/rawfile/index9.html | 52 +- .../entry2/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry2/src/ohosTest/module.json5 | 52 +- .../entry2/src/test/List.test.ets | 0 .../entry2/src/test/LocalUnit.test.ets | 0 .../ArkWeb/UseFrontendJSApp/entry3/.gitignore | 0 .../entry3/build-profile.json5 | 84 +- .../UseFrontendJSApp/entry3/hvigorfile.ts | 0 .../entry3/obfuscation-rules.txt | 0 .../UseFrontendJSApp/entry3/oh-package.json5 | 50 +- .../main/ets/entry3ability/Entry3Ability.ets | 112 +- .../entry3/src/main/ets/pages/Index.ets | 0 .../entry3/src/main/module.json5 | 82 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/main/resources/rawfile/index.html | 138 +- .../entry3/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry3/src/ohosTest/module.json5 | 54 +- .../entry3/src/test/List.test.ets | 0 .../entry3/src/test/LocalUnit.test.ets | 0 .../ArkWeb/UseFrontendJSApp/entry4/.gitignore | 0 .../entry4/build-profile.json5 | 108 +- .../UseFrontendJSApp/entry4/hvigorfile.ts | 0 .../entry4/obfuscation-rules.txt | 0 .../UseFrontendJSApp/entry4/oh-package.json5 | 50 +- .../entry4/src/main/cpp/CMakeLists.txt | 46 +- .../entry4/src/main/cpp/hello.cpp | 652 +- .../entry4/src/main/cpp/jsbridge_object.cpp | 178 +- .../entry4/src/main/cpp/jsbridge_object.h | 78 +- .../entry4/src/main/cpp/napi_init.cpp | 134 +- .../src/main/cpp/types/libentry4/Index.d.ts | 36 +- .../main/cpp/types/libentry4/oh-package.json5 | 40 +- .../main/ets/entry4ability/Entry4Ability.ets | 112 +- .../entry4/src/main/ets/pages/Index.ets | 142 +- .../entry4/src/main/module.json5 | 82 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/main/resources/rawfile/runJS.html | 184 +- .../entry4/src/mock/Libentry4.mock.ets | 0 .../entry4/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry4/src/ohosTest/module.json5 | 54 +- .../entry4/src/test/List.test.ets | 0 .../entry4/src/test/LocalUnit.test.ets | 0 .../ArkWeb/UseFrontendJSApp/entry5/.gitignore | 0 .../entry5/build-profile.json5 | 108 +- .../UseFrontendJSApp/entry5/hvigorfile.ts | 0 .../entry5/obfuscation-rules.txt | 0 .../UseFrontendJSApp/entry5/oh-package.json5 | 50 +- .../entry5/src/main/cpp/CMakeLists.txt | 50 +- .../entry5/src/main/cpp/hello.cpp | 936 +- .../entry5/src/main/cpp/napi_init.cpp | 134 +- .../src/main/cpp/types/libentry5/Index.d.ts | 54 +- .../main/cpp/types/libentry5/oh-package.json5 | 40 +- .../main/ets/entry5ability/Entry5Ability.ets | 112 +- .../entry5/src/main/ets/pages/Index.ets | 548 +- .../entry5/src/main/module.json5 | 82 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../src/main/resources/rawfile/index.html | 276 +- .../entry5/src/mock/Libentry5.mock.ets | 0 .../entry5/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry5/src/ohosTest/module.json5 | 54 +- .../entry5/src/test/List.test.ets | 0 .../entry5/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ArkWeb/UseFrontendJSApp/hvigorfile.ts | 0 .../ArkWeb/UseFrontendJSApp/oh-package.json5 | 50 +- .../ArkWeb/UseFrontendJSApp/ohosTest.md | 0 .../screenshots/AppCallFrontendFn_1.png | Bin .../screenshots/AppCallFrontendFn_2.png | Bin .../screenshots/AppCallFrontendFn_3.png | Bin .../screenshots/EstabDataChannelC_C_1.png | Bin .../screenshots/EstabDataChannelC_C_2.png | Bin .../screenshots/EstabDataChannel_1.png | Bin .../screenshots/EstabDataChannel_2.png | Bin .../screenshots/EstabDataChannel_3.png | Bin .../screenshots/JavaScriptProxy_1.png | Bin .../screenshots/JavaScriptProxy_2.png | Bin .../screenshots/MutualInvokeCCpp.png | Bin .../screenshots/Promise_one.png | Bin .../screenshots/Promise_two.png | Bin .../screenshots/RegisterJavaScriptProxy_1.png | Bin .../screenshots/RegisterJavaScriptProxy_2.png | Bin .../screenshots/UsageOfComplexTypes_five.png | Bin .../screenshots/UsageOfComplexTypes_four.png | Bin .../screenshots/UsageOfComplexTypes_one.png | Bin .../screenshots/UsageOfComplexTypes_three.png | Bin .../screenshots/UsageOfComplexTypes_two.png | Bin .../ArkWeb/UseOfflineWebComp/.gitignore | 0 .../UseOfflineWebComp/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ArkWeb/UseOfflineWebComp/README.md | 0 .../UseOfflineWebComp/build-profile.json5 | 150 +- .../UseOfflineWebComp/code-linter.json5 | 0 .../ArkWeb/UseOfflineWebComp/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../UseOfflineWebComp/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../UseOfflineWebComp/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 114 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/common.ets | 200 +- .../entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../UseOfflineWebComp/entry1/.gitignore | 0 .../entry1/build-profile.json5 | 84 +- .../UseOfflineWebComp/entry1/hvigorfile.ts | 0 .../entry1/obfuscation-rules.txt | 0 .../UseOfflineWebComp/entry1/oh-package.json5 | 50 +- .../main/ets/entry1ability/Entry1Ability.ets | 112 +- .../entry1/src/main/ets/pages/Index.ets | 0 .../entry1/src/main/ets/pages/common.ets | 194 +- .../entry1/src/main/ets/pages/index2.ets | 68 +- .../entry1/src/main/module.json5 | 92 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../entry1/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry1/src/ohosTest/module.json5 | 54 +- .../entry1/src/test/List.test.ets | 0 .../entry1/src/test/LocalUnit.test.ets | 0 .../UseOfflineWebComp/entry2/.gitignore | 0 .../entry2/build-profile.json5 | 84 +- .../UseOfflineWebComp/entry2/hvigorfile.ts | 0 .../entry2/obfuscation-rules.txt | 0 .../UseOfflineWebComp/entry2/oh-package.json5 | 50 +- .../main/ets/entry2ability/Entry2Ability.ets | 112 +- .../entry2/src/main/ets/pages/Index.ets | 0 .../entry2/src/main/ets/pages/common.ets | 220 +- .../entry2/src/main/ets/pages/index2.ets | 0 .../entry2/src/main/module.json5 | 96 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 0 .../entry2/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry2/src/ohosTest/module.json5 | 54 +- .../entry2/src/test/List.test.ets | 0 .../entry2/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ArkWeb/UseOfflineWebComp/hvigorfile.ts | 0 .../ArkWeb/UseOfflineWebComp/oh-package.json5 | 50 +- .../ArkWeb/UseOfflineWebComp/ohosTest.md | 0 .../CreatingOfflineWebComponents.png | Bin .../PreLaunchingRenderingProcess_one_1.png | Bin .../PreLaunchingRenderingProcess_one_2.png | Bin .../PreLaunchingRenderingProcess_two_1.png | Bin .../PreLaunchingRenderingProcess_two_2.png | Bin .../ArkWeb/UseSameLayerRender/.gitignore | 0 .../UseSameLayerRender/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ArkWeb/UseSameLayerRender/README.md | 0 .../UseSameLayerRender/build-profile.json5 | 102 +- .../UseSameLayerRender/code-linter.json5 | 0 .../UseSameLayerRender/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../UseSameLayerRender/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../UseSameLayerRender/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/DrawXCompAVPBtn.ets | 432 +- .../entry/src/main/ets/pages/Index.ets | 74 +- .../entry/src/main/ets/pages/PlayerDemo.ets | 206 +- .../ets/pages/RenderTxtBoxSameLayer_one.ets | 0 .../ets/pages/RenderTxtBoxSameLayer_two.ets | 0 .../entry/src/main/module.json5 | 146 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/test1.html | 66 +- .../src/main/resources/rawfile/test2.html | 66 +- .../src/main/resources/rawfile/test3.html | 56 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ArkWeb/UseSameLayerRender/hvigorfile.ts | 0 .../UseSameLayerRender/oh-package.json5 | 50 +- .../ArkWeb/UseSameLayerRender/ohosTest.md | 0 .../screenshots/DrawXCompAVPBtn.png | Bin .../screenshots/RenderTxtBoxSameLayer_one.png | Bin .../screenshots/RenderTxtBoxSameLayer_two.png | Bin .../ArkWeb/UsingWebMultimedia/.gitignore | 0 .../UsingWebMultimedia/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ArkWeb/UsingWebMultimedia/README.md | 0 .../UsingWebMultimedia/build-profile.json5 | 150 +- .../UsingWebMultimedia/code-linter.json5 | 0 .../UsingWebMultimedia/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../UsingWebMultimedia/entry/hvigorfile.ts | 0 .../entry/obfuscation-rules.txt | 0 .../UsingWebMultimedia/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 118 +- .../entrybackupability/EntryBackupAbility.ets | 56 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 218 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../src/main/resources/rawfile/index.html | 90 +- .../main/resources/zh_CN/element/string.json | 0 .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../UsingWebMultimedia/entry2/.gitignore | 0 .../entry2/build-profile.json5 | 84 +- .../UsingWebMultimedia/entry2/hvigorfile.ts | 0 .../entry2/obfuscation-rules.txt | 0 .../entry2/oh-package.json5 | 50 +- .../main/ets/entry2ability/Entry2Ability.ets | 112 +- .../Entry2BackupAbility.ets | 52 +- .../entry2/src/main/ets/pages/Index.ets | 0 .../entry2/src/main/ets/pages/PlayerDemo.ets | 554 +- .../entry2/src/main/module.json5 | 138 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../src/main/resources/rawfile/main.html | 54 +- .../entry2/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/List.test.ets | 0 .../entry2/src/ohosTest/module.json5 | 52 +- .../entry2/src/test/List.test.ets | 0 .../entry2/src/test/LocalUnit.test.ets | 0 .../entry3/build-profile.json5 | 84 +- .../entry3/oh-package.json5 | 50 +- .../main/ets/entry3ability/Entry3Ability.ets | 116 +- .../Entry3BackupAbility.ets | 60 +- .../entry3/src/main/module.json5 | 128 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/float.json | 16 +- .../resources/base/profile/backup_config.json | 4 +- .../resources/rawfile/PictureInPicture.html | 172 +- .../entry3/src/ohosTest/module.json5 | 52 +- .../hvigor/hvigor-config.json5 | 74 +- .../ArkWeb/UsingWebMultimedia/hvigorfile.ts | 0 .../UsingWebMultimedia/oh-package.json5 | 50 +- .../ArkWeb/UsingWebMultimedia/ohosTest.md | 0 .../screenshots/HoldVideoConfWebRTC_1.png | Bin .../screenshots/HoldVideoConfWebRTC_2.png | Bin .../screenshots/HoldVideoConfWebRTC_3.png | Bin .../screenshots/TakeOverMediaPlay.png | Bin .../ArkWeb/WebRenderLayout/.gitignore | 22 +- .../ArkWeb/WebRenderLayout/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ArkWeb/WebRenderLayout/README.md | 154 +- .../WebRenderLayout/build-profile.json5 | 102 +- .../ArkWeb/WebRenderLayout/code-linter.json5 | 68 +- .../ArkWeb/WebRenderLayout/entry/.gitignore | 10 +- .../WebRenderLayout/entry/build-profile.json5 | 84 +- .../WebRenderLayout/entry/hvigorfile.ts | 42 +- .../entry/obfuscation-rules.txt | 44 +- .../WebRenderLayout/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/FitPageContent.ets | 98 +- .../entry/src/main/ets/pages/Index.ets | 68 +- .../entry/src/main/ets/pages/RenderMode.ets | 66 +- .../entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 46 +- .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 12 +- .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 14 +- .../main/resources/en_US/element/string.json | 30 +- .../main/resources/rawfile/fit_content.html | 126 +- .../main/resources/zh_CN/element/string.json | 30 +- .../entry/src/mock/mock-config.json5 | 32 +- .../src/ohosTest/ets/test/Ability.test.ets | 194 +- .../entry/src/ohosTest/ets/test/List.test.ets | 38 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 38 +- .../entry/src/test/LocalUnit.test.ets | 94 +- .../hvigor/hvigor-config.json5 | 74 +- .../ArkWeb/WebRenderLayout/hvigorfile.ts | 42 +- .../ArkWeb/WebRenderLayout/oh-package.json5 | 50 +- .../ArkWeb/WebRenderLayout/ohosTest.md | 0 .../screenshots/FitPageContent.png | Bin .../screenshots/RenderModeWebComp.png | Bin .../HarSample/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../HarSample/build-profile.json5 | 92 +- .../HarSample/entry/build-profile.json5 | 56 +- .../HarSample/entry/oh-package.json5 | 54 +- .../src/main/ets/entryability/EntryAbility.ts | 108 +- .../entry/src/main/ets/logger/Logger.ts | 96 +- .../HarSample/entry/src/main/module.json5 | 100 +- .../main/resources/base/element/color.json | 38 +- .../entry/src/ohosTest/ets/logger/Logger.ts | 96 +- .../HarSample/entry/src/ohosTest/module.json5 | 102 +- .../HarSample/hvigor/hvigor-config.json5 | 40 +- .../HarSample/library/build-profile.json5 | 70 +- .../HarSample/library/index.ets | 38 +- .../HarSample/library/oh-package.json5 | 54 +- .../src/main/cpp/types/liblibrary/index.d.ts | 30 +- .../cpp/types/liblibrary/oh-package.json5 | 40 +- .../main/ets/components/mainpage/MainPage.ets | 88 +- .../library/src/main/ets/utils/nativeTest.ts | 40 +- .../HarSample/library/src/main/module.json5 | 50 +- .../main/resources/base/element/color.json | 38 +- .../HarSample/library/src/main/ts/test.ets | 54 +- .../HarSample/oh-package.json5 | 54 +- .../HspSample/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../HspSample/build-profile.json5 | 108 +- .../HspSample/entry/build-profile.json5 | 56 +- .../HspSample/entry/oh-package.json5 | 54 +- .../src/main/ets/entryability/EntryAbility.ts | 108 +- .../entry/src/main/ets/logger/Logger.ts | 96 +- .../HspSample/entry/src/main/module.json5 | 100 +- .../main/resources/base/element/color.json | 46 +- .../entry/src/ohosTest/ets/logger/Logger.ts | 96 +- .../HspSample/entry/src/ohosTest/module.json5 | 102 +- .../HspSample/hvigor/hvigor-config.json5 | 40 +- .../HspSample/library/build-profile.json5 | 58 +- .../HspSample/library/oh-package.json5 | 54 +- .../src/main/cpp/types/liblibrary/index.d.ts | 30 +- .../cpp/types/liblibrary/oh-package.json5 | 40 +- .../HspSample/library/src/main/ets/Index.ets | 36 +- .../library/src/main/ets/ResManager.ets | 44 +- .../src/main/ets/components/MyTitleBar.ets | 58 +- .../library/src/main/ets/pages/Back.ets | 150 +- .../library/src/main/ets/pages/Menu.ets | 110 +- .../library/src/main/ets/utils/nativeTest.ts | 40 +- .../HspSample/library/src/main/module.json5 | 54 +- .../main/resources/base/element/string.json | 46 +- .../HspSample/oh-package.json5 | 54 +- .../HCECardSimulationDevelopment/ohosTest.md | 12 +- .../screenshots/image.jpeg | Bin .../NFC/NFCReadAndWrite/ohosTest.md | 12 +- .../NFCReadAndWrite/screenshots/image.jpeg | Bin .../NFC/SecureElement/ohosTest.md | 12 +- .../NFC/SecureElement/screenshots/image.jpeg | Bin .../ConnectivityKit/Wlan/ohosTest.md | 18 +- .../src/main/cpp/samples/sample_brush.cpp | 554 +- .../src/main/cpp/samples/sample_canvas.cpp | 388 +- .../src/main/cpp/samples/sample_matrix.cpp | 612 +- .../src/main/cpp/samples/sample_path.cpp | 904 +- .../entry/src/main/cpp/samples/sample_pen.cpp | 486 +- .../src/main/cpp/samples/sample_pixelmap.cpp | 326 +- .../src/main/cpp/samples/sample_rect.cpp | 252 +- .../main/ets/drawing/pages/BitmapDrawing.ets | 68 +- .../main/ets/drawing/pages/BrushDrawing.ets | 154 +- .../main/ets/drawing/pages/CanvasDrawing.ets | 182 +- .../main/ets/drawing/pages/ImageDrawing.ets | 68 +- .../main/ets/drawing/pages/MatrixDrawing.ets | 238 +- .../main/ets/drawing/pages/PathDrawing.ets | 154 +- .../src/main/ets/drawing/pages/PenDrawing.ets | 182 +- .../ets/drawing/pages/PixelMapDrawing.ets | 152 +- .../main/ets/drawing/pages/RectDrawing.ets | 140 +- .../NDKAPIDrawing/entry/src/main/module.json5 | 100 +- .../Notification/AppScope/app.json5 | 48 +- .../resources/base/element/string.json | 16 +- .../Notification/Notification/README_zh.md | 160 +- .../Notification/build-profile.json5 | 84 +- .../Notification/entry/build-profile.json5 | 56 +- .../Notification/entry/oh-package.json5 | 20 +- .../main/ets/entryAbility/EntryAbility.ets | 124 +- .../entry/src/main/ets/pages/Second.ets | 92 +- .../src/main/ets/publish/PublishOperation.ets | 588 +- .../main/ets/secondAbility/SecondAbility.ets | 120 +- .../main/ets/subscribe/SubscribeOperation.ets | 122 +- .../entry/src/main/ets/util/Logger.ets | 96 +- .../Notification/entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 38 +- .../entry/src/ohosTest/ets/util/Logger.ets | 96 +- .../entry/src/ohosTest/module.json5 | 104 +- .../Notification/hvigor/hvigor-config.json5 | 40 +- .../Notification/oh-package.json5 | 52 +- .../Notification/Notification/ohosTest.md | 32 +- .../AssetStoreKit/AssetStoreArkTS/.gitignore | 0 .../AssetStoreArkTS/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../AssetStoreKit/AssetStoreArkTS/README.md | 144 +- .../AssetStoreArkTS/build-profile.json5 | 114 +- .../AssetStoreArkTS/code-linter.json5 | 0 .../AssetStoreArkTS/entry/.gitignore | 0 .../AssetStoreArkTS/entry/build-profile.json5 | 84 +- .../AssetStoreArkTS/entry/hvigorfile.ts | 0 .../AssetStoreArkTS/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 148 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ets/test/AssetStoreArkTS.test.ets | 220 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../AssetStoreArkTS/hvigorfile.ts | 0 .../AssetStoreArkTS/oh-package.json5 | 50 +- .../AssetStoreKit/AssetStoreArkTS/ohosTest.md | 20 +- .../screenshots/AssetStoreArkTS1.png | Bin .../screenshots/AssetStoreArkTS2.png | Bin .../AssetStoreKit/AssetStoreNdk/.gitignore | 0 .../AssetStoreNdk/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../AssetStoreKit/AssetStoreNdk/README.md | 154 +- .../AssetStoreNdk/build-profile.json5 | 114 +- .../AssetStoreNdk/code-linter.json5 | 0 .../AssetStoreNdk/entry/.gitignore | 0 .../AssetStoreNdk/entry/build-profile.json5 | 116 +- .../AssetStoreNdk/entry/hvigorfile.ts | 0 .../AssetStoreNdk/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 444 +- .../src/main/cpp/types/libentry/Index.d.ts | 50 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 142 +- .../AssetStoreNdk/entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ohosTest/ets/test/AssetStoreNdk.test.ets | 158 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../AssetStoreNdk/hvigor/hvigor-config.json5 | 74 +- .../AssetStoreKit/AssetStoreNdk/hvigorfile.ts | 0 .../AssetStoreNdk/oh-package.json5 | 50 +- .../AssetStoreKit/AssetStoreNdk/ohosTest.md | 18 +- .../screenshots/AssetStoreNdk1.png | Bin .../screenshots/AssetStoreNdk2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 160 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 92 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../3des_ecb_encryption_decryption.cpp | 156 +- .../entry/src/main/cpp/types/project/file.h | 44 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../pages/3des_ecb_encryption_decryption.ets | 70 +- ...ecb_encryption_decryption_asynchronous.ets | 166 +- ..._ecb_encryption_decryption_synchronous.ets | 166 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../EncryptionDecryptionGuidance3DES.test.ets | 194 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 18 +- .../EncryptionDecryptionGuidance3DES1.png | Bin .../EncryptionDecryptionGuidance3DES2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../EncryptionDecryptionGuidanceAes/README.md | 168 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 156 +- .../src/main/cpp/types/libentry/Index.d.ts | 48 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../project/aes_cbc_encryption_decryption.cpp | 184 +- .../project/aes_ccm_encryption_decryption.cpp | 232 +- .../project/aes_ecb_encryption_decryption.cpp | 172 +- .../project/aes_gcm_encryption_decryption.cpp | 234 +- .../aes_gcm_segment_encryption_decryption.cpp | 290 +- .../entry/src/main/cpp/types/project/file.h | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 124 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../EncryptionDecryptionGuidanceAes.test.ets | 226 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 22 +- .../EncryptionDecryptionGuidanceAes1.png | Bin .../EncryptionDecryptionGuidanceAes2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 170 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 ...cbc_encryption_decryption_asynchronous.ets | 204 +- ..._cbc_encryption_decryption_synchronous.ets | 204 +- ...ccm_encryption_decryption_asynchronous.ets | 208 +- ..._ccm_encryption_decryption_synchronous.ets | 208 +- ...ecb_encryption_decryption_asynchronous.ets | 170 +- ..._ecb_encryption_decryption_synchronous.ets | 170 +- ...gcm_encryption_decryption_asynchronous.ets | 232 +- ..._gcm_encryption_decryption_synchronous.ets | 232 +- ...seg_encryption_decryption_asynchronous.ets | 141 - ..._seg_encryption_decryption_synchronous.ets | 141 - .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 ...ryptionDecryptionGuidanceAesArkTs.test.ets | 446 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 32 +- .../EncryptionDecryptionGuidanceAesArkTs1.png | Bin .../EncryptionDecryptionGuidanceAesArkTs2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../EncryptionDecryptionGuidanceRSA/README.md | 154 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../ets/pages/rsa_pkcs1/RSAPKCS1Async.ets | 244 +- .../main/ets/pages/rsa_pkcs1/RSAPKCS1Sync.ets | 244 +- .../rsa_pkcs1_oaep/RSAPKCS1OAEPAsync.ets | 260 +- .../pages/rsa_pkcs1_oaep/RSAPKCS1OAEPSync.ets | 250 +- .../rsa_segmentation/RSASegmentationAsync.ets | 208 +- .../rsa_segmentation/RSASegmentationSync.ets | 208 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../EncryptionDecryptionGuidanceRSA.test.ets | 302 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 24 +- .../EncryptionDecryptionGuidanceRSA1.png | Bin .../EncryptionDecryptionGuidanceRSA2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../EncryptionDecryptionGuidanceSM2/README.md | 144 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../ets/pages/sm2/CreateASN.1Ciphertext.ets | 104 +- .../main/ets/pages/sm2/ObtainCiphertext.ets | 102 +- .../sm2/SM2EncryptionDecryptionAsync.ets | 188 +- .../pages/sm2/SM2EncryptionDecryptionSync.ets | 188 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../EncryptionDecryptionGuidanceSM2.test.ets | 230 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 20 +- .../EncryptionDecryptionGuidanceSM21.png | Bin .../EncryptionDecryptionGuidanceSM22.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../EncryptionDecryptionGuidanceSM4/README.md | 164 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 140 +- .../src/main/cpp/types/libentry/Index.d.ts | 44 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../entry/src/main/cpp/types/project/file.h | 40 +- .../project/sm4_cbc_encryption_decryption.cpp | 194 +- .../project/sm4_ecb_encryption_decryption.cpp | 178 +- .../project/sm4_gcm_encryption_decryption.cpp | 240 +- .../sm4_gcm_seg_encryption_decryption.cpp | 288 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 112 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../EncryptionDecryptionGuidanceSM4.test.ets | 198 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 20 +- .../EncryptionDecryptionGuidanceSM41.png | Bin .../EncryptionDecryptionGuidanceSM42.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 162 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 ...cbc_encryption_decryption_asynchronous.ets | 204 +- ..._cbc_encryption_decryption_synchronous.ets | 204 +- ...ecb_encryption_decryption_asynchronous.ets | 162 +- ..._ecb_encryption_decryption_synchronous.ets | 162 +- ...gcm_encryption_decryption_asynchronous.ets | 232 +- ..._gcm_encryption_decryption_synchronous.ets | 232 +- ...seg_encryption_decryption_asynchronous.ets | 141 - ..._seg_encryption_decryption_synchronous.ets | 141 - .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 ...yptionDecryptionGuidance3DESArkTs.test.ets | 374 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 28 +- .../EncryptionDecryptionGuidanceSM4ArkTs1.png | Bin .../EncryptionDecryptionGuidanceSM4ArkTs2.png | Bin .../KeyDerivation/HKDFDerivation/.gitignore | 0 .../HKDFDerivation/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../KeyDerivation/HKDFDerivation/README.md | 138 +- .../HKDFDerivation/build-profile.json5 | 114 +- .../HKDFDerivation/code-linter.json5 | 0 .../HKDFDerivation/entry/.gitignore | 0 .../HKDFDerivation/entry/build-profile.json5 | 84 +- .../HKDFDerivation/entry/hvigorfile.ts | 0 .../HKDFDerivation/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Await.ets | 116 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/Promise.ets | 128 +- .../entry/src/main/ets/pages/Sync.ets | 114 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ohosTest/ets/test/HKDFDerivation.test.ets | 194 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../HKDFDerivation/hvigor/hvigor-config.json5 | 74 +- .../HKDFDerivation/hvigorfile.ts | 0 .../HKDFDerivation/oh-package.json5 | 50 +- .../KeyDerivation/HKDFDerivation/ohosTest.md | 18 +- .../screenshots/HKDFDerivation1.png | Bin .../screenshots/HKDFDerivation2.png | Bin .../KeyDerivation/PBKDF2Derivation/.gitignore | 0 .../PBKDF2Derivation/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../KeyDerivation/PBKDF2Derivation/README.md | 138 +- .../PBKDF2Derivation/build-profile.json5 | 114 +- .../PBKDF2Derivation/code-linter.json5 | 0 .../PBKDF2Derivation/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../PBKDF2Derivation/entry/hvigorfile.ts | 0 .../PBKDF2Derivation/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Await.ets | 108 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/Promise.ets | 114 +- .../entry/src/main/ets/pages/Sync.ets | 106 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/PBKDF2Derivation.test.ets | 194 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../PBKDF2Derivation/hvigorfile.ts | 0 .../PBKDF2Derivation/oh-package.json5 | 50 +- .../PBKDF2Derivation/ohosTest.md | 18 +- .../screenshots/PBKDF2Derivation1.png | Bin .../screenshots/PBKDF2Derivation2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 160 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 126 +- .../src/main/cpp/types/libentry/Index.d.ts | 38 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../entry/src/main/cpp/types/project/ecc.cpp | 110 +- .../entry/src/main/cpp/types/project/file.h | 46 +- .../entry/src/main/cpp/types/project/rsa.cpp | 106 +- .../entry/src/main/cpp/types/project/sm2.cpp | 108 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 100 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 ...inaryDataConvertAsymmetricKeyPair.test.ets | 170 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 18 +- .../BinaryDataConvertAsymmetricKeyPair1.png | Bin .../BinaryDataConvertAsymmetricKeyPair2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 158 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/ecc/Callback.ets | 124 +- .../entry/src/main/ets/pages/ecc/Sync.ets | 126 +- .../src/main/ets/pages/pkcs8ecc/PKCS8ECC.ets | 126 +- .../entry/src/main/ets/pages/rsa/Callback.ets | 122 +- .../entry/src/main/ets/pages/rsa/Sync.ets | 124 +- .../entry/src/main/ets/pages/sm2/Callback.ets | 126 +- .../entry/src/main/ets/pages/sm2/Sync.ets | 128 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 ...DataConvertAsymmetricKeyPairArkTS.test.ets | 338 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 26 +- ...naryDataConvertAsymmetricKeyPairArkTS1.png | Bin ...naryDataConvertAsymmetricKeyPairArkTS2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 166 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 90 +- .../src/main/cpp/types/libentry/Index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../entry/src/main/cpp/types/project/file.h | 42 +- .../entry/src/main/cpp/types/project/rsa.cpp | 124 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 122 +- .../entry/src/main/ets/pages/Promise.ets | 150 +- .../entry/src/main/ets/pages/Sync.ets | 168 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 ...vertSpecifiedPEMAsymmetricKeyPair.test.ets | 186 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 48 +- .../ohosTest.md | 18 +- .../ConvertSpecifiedPEMAsymmetricKeyPair1.png | Bin .../ConvertSpecifiedPEMAsymmetricKeyPair2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ConvertSymmetricKeyBinaryFormat/README.md | 158 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 110 +- .../src/main/cpp/types/libentry/Index.d.ts | 34 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../entry/src/main/cpp/types/project/3des.cpp | 100 +- .../entry/src/main/cpp/types/project/file.h | 44 +- .../entry/src/main/cpp/types/project/hmac.cpp | 102 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 88 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ConvertSymmetricKeyBinaryFormat.test.ets | 142 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 16 +- .../ConvertSymmetricKeyBinaryFormat1.png | Bin .../ConvertSymmetricKeyBinaryFormat2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 148 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/3des/Callback.ets | 148 +- .../entry/src/main/ets/pages/3des/Sync.ets | 148 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/hmac/Await.ets | 108 +- .../entry/src/main/ets/pages/hmac/Sync.ets | 108 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 ...vertSymmetricKeyBinaryFormatArkTS.test.ets | 230 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 20 +- .../ConvertSymmetricKeyBinaryFormatArkTS1.png | Bin .../ConvertSymmetricKeyBinaryFormatArkTS2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 166 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 92 +- .../src/main/cpp/types/libentry/Index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../entry/src/main/cpp/types/project/file.h | 42 +- .../project/specifyUncompressedPublicKey.cpp | 120 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../main/ets/pages/CompressedPointData.ets | 108 +- .../entry/src/main/ets/pages/GetKeyObject.ets | 136 +- .../entry/src/main/ets/pages/Index.ets | 132 +- .../pages/SpecifyUncompressedPublicKey.ets | 108 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 ...CompressPublicKeyFormatConversion.test.ets | 222 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 20 +- .../ECCCompressPublicKeyFormatConversion1.png | Bin .../ECCCompressPublicKeyFormatConversion2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 158 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 106 +- .../src/main/cpp/types/libentry/Index.d.ts | 34 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../entry/src/main/cpp/types/project/file.h | 46 +- .../entry/src/main/cpp/types/project/rsa.cpp | 110 +- .../entry/src/main/cpp/types/project/sm2.cpp | 106 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 88 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 ...RandomlyGenerateAsymmetricKeyPair.test.ets | 142 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 16 +- .../RandomlyGenerateAsymmetricKeyPair1.png | Bin .../RandomlyGenerateAsymmetricKeyPair2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 148 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/rsa/Promise.ets | 114 +- .../entry/src/main/ets/pages/rsa/Sync.ets | 126 +- .../entry/src/main/ets/pages/sm2/Promise.ets | 114 +- .../entry/src/main/ets/pages/sm2/Sync.ets | 126 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 ...mlyGenerateAsymmetricKeyPairArkTS.test.ets | 230 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 20 +- ...andomlyGenerateAsymmetricKeyPairArkTS1.png | Bin ...andomlyGenerateAsymmetricKeyPairArkTS2.png | Bin .../RandomlyGenerateSymmetricKey/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../RandomlyGenerateSymmetricKey/README.md | 158 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 114 +- .../src/main/cpp/types/libentry/Index.d.ts | 34 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../entry/src/main/cpp/types/project/aes.cpp | 88 +- .../entry/src/main/cpp/types/project/file.h | 44 +- .../entry/src/main/cpp/types/project/sm4.cpp | 88 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 88 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../RandomlyGenerateSymmetricKey.test.ets | 142 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../RandomlyGenerateSymmetricKey/ohosTest.md | 16 +- .../RandomlyGenerateSymmetricKey1.png | Bin .../RandomlyGenerateSymmetricKey2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 148 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/aes/Promise.ets | 106 +- .../entry/src/main/ets/pages/aes/Sync.ets | 102 +- .../entry/src/main/ets/pages/sm4/Promise.ets | 106 +- .../entry/src/main/ets/pages/sm4/Sync.ets | 102 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 ...RandomlyGenerateSymmetricKeyArkTS.test.ets | 230 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 20 +- .../RandomlyGenerateSymmetricKeyArkTS1.png | Bin .../RandomlyGenerateSymmetricKeyArkTS2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 154 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/ecc/Promise.ets | 286 +- .../entry/src/main/ets/pages/ecc/Sync.ets | 272 +- .../entry/src/main/ets/pages/rsa/Callback.ets | 216 +- .../entry/src/main/ets/pages/rsa/Sync.ets | 222 +- .../entry/src/main/ets/pages/sm2/Promise.ets | 128 +- .../entry/src/main/ets/pages/sm2/Sync.ets | 144 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 ...rametersGenerateAsymmetricKeyPair.test.ets | 300 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 24 +- ...edParametersGenerateAsymmetricKeyPair1.png | Bin ...edParametersGenerateAsymmetricKeyPair2.png | Bin .../KeyNegotiation/.gitignore | 0 .../KeyNegotiation/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../KeyNegotiation/README.md | 154 +- .../KeyNegotiation/build-profile.json5 | 114 +- .../KeyNegotiation/code-linter.json5 | 0 .../KeyNegotiation/entry/.gitignore | 0 .../KeyNegotiation/entry/build-profile.json5 | 84 +- .../KeyNegotiation/entry/hvigorfile.ts | 0 .../KeyNegotiation/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/DH/DHAsync.ets | 120 +- .../entry/src/main/ets/pages/DH/DHSync.ets | 122 +- .../src/main/ets/pages/ECDH/EDCHAsync.ets | 138 +- .../src/main/ets/pages/ECDH/EDCHSync.ets | 144 +- .../entry/src/main/ets/pages/Index.ets | 0 .../src/main/ets/pages/X25519/X25519Async.ets | 132 +- .../src/main/ets/pages/X25519/X25519Sync.ets | 132 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ohosTest/ets/test/KeyNegotiation.test.ets | 302 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../KeyNegotiation/hvigor/hvigor-config.json5 | 74 +- .../KeyNegotiation/hvigorfile.ts | 0 .../KeyNegotiation/oh-package.json5 | 50 +- .../KeyNegotiation/ohosTest.md | 24 +- .../screenshots/KeyNegotiation1.png | Bin .../screenshots/KeyNegotiation2.png | Bin .../MessageAuthenticationCode/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../MessageAuthenticationCode/README.md | 144 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../main/ets/pages/HMACSegmentation/Async.ets | 136 +- .../main/ets/pages/HMACSegmentation/Sync.ets | 132 +- .../main/ets/pages/HMACSingleTime/Async.ets | 144 +- .../main/ets/pages/HMACSingleTime/Sync.ets | 144 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../test/MessageAuthenticationCode.test.ets | 230 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../MessageAuthenticationCode/hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../MessageAuthenticationCode/ohosTest.md | 20 +- .../MessageAuthenticationCode1.png | Bin .../MessageAuthenticationCode2.png | Bin .../MessageDigestComputation/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../MessageDigestComputation/README.md | 168 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../MessageDigestComputation/entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 104 +- .../src/main/cpp/types/libentry/index.d.ts | 34 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../entry/src/main/cpp/types/project/file.h | 44 +- .../main/cpp/types/project/segmentation.cpp | 126 +- .../src/main/cpp/types/project/singleTime.cpp | 100 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../pages/segmentation/SegmentationAsync.ets | 118 +- .../pages/segmentation/SegmentationSync.ets | 120 +- .../ets/pages/singleTime/SingleTimeAsync.ets | 108 +- .../ets/pages/singleTime/SingleTimeSync.ets | 104 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../test/MessageDigestComputation.test.ets | 286 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../MessageDigestComputation/hvigorfile.ts | 0 .../MessageDigestComputation/oh-package.json5 | 50 +- .../MessageDigestComputation/ohosTest.md | 24 +- .../screenshots/MessageDigestComputation1.png | Bin .../screenshots/MessageDigestComputation2.png | Bin .../SecureRandomNumberGeneration/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../SecureRandomNumberGeneration/README.md | 136 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../SecureRandomNumberGeneration.test.ets | 142 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../SecureRandomNumberGeneration/ohosTest.md | 16 +- .../SecureRandomNumberGeneration1.png | Bin .../SecureRandomNumberGeneration2.png | Bin .../SigningSignatureVerification/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../SigningSignatureVerification/README.md | 176 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 30 +- .../entry/src/main/cpp/napi_init.cpp | 176 +- .../src/main/cpp/types/libentry/Index.d.ts | 50 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../project/ecdsa_signature_verification.cpp | 158 +- .../project/rsa_pkcs1_segment_signature.cpp | 244 +- .../rsa_pkcs1_signature_restoration.cpp | 198 +- .../project/rsa_pkcs1_signature_validator.cpp | 202 +- .../project/rsa_pss_verification_tool.cpp | 230 +- .../project/signing_signature_verification.h | 56 +- .../project/sm2_signature_verification.cpp | 174 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 132 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../SigningSignatureVerification.test.ets | 254 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../SigningSignatureVerification/ohosTest.md | 24 +- .../SigningSignatureVerification1.png | Bin .../SigningSignatureVerification2.png | Bin .../.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../README.md | 158 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 ...sa_signature_verification_asynchronous.ets | 158 +- ...dsa_signature_verification_synchronous.ets | 156 +- ...a_pkcs1_segment_signature_asynchronous.ets | 196 +- ...sa_pkcs1_segment_signature_synchronous.ets | 196 +- ...cs1_signature_restoration_asynchronous.ets | 148 +- ...kcs1_signature_restoration_synchronous.ets | 148 +- ...pkcs1_signature_validator_asynchronous.ets | 156 +- ..._pkcs1_signature_validator_synchronous.ets | 156 +- ...ss_signature_verification_asynchronous.ets | 252 +- ...pss_signature_verification_synchronous.ets | 252 +- ...m2_signature_verification_asynchronous.ets | 156 +- ...sm2_signature_verification_synchronous.ets | 156 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../entry/src/mock/mock-config.json5 | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 ...SigningSignatureVerificationArkTs.test.ets | 516 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../ohosTest.md | 36 +- .../SigningSignatureVerificationArkTs1.png | Bin .../SigningSignatureVerificationArkTs2.png | Bin .../DataProtection/.gitignore | 0 .../DataProtection/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../DataProtection/README.md | 146 +- .../DataProtection/build-profile.json5 | 114 +- .../DataProtection/code-linter.json5 | 0 .../DataProtection/entry/.gitignore | 0 .../DataProtection/entry/build-profile.json5 | 84 +- .../DataProtection/entry/hvigorfile.ts | 0 .../DataProtection/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 132 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ohosTest/ets/test/DataProtection.test.ets | 126 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../DataProtection/hvigor/hvigor-config.json5 | 74 +- .../DataProtection/hvigorfile.ts | 0 .../DataProtection/oh-package.json5 | 50 +- .../DataProtection/ohosTest.md | 14 +- .../screenshots/DataProtection.png | Bin .../CertificateAlgorithmLibrary/.gitignore | 0 .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../CertificateAlgorithmLibrary/README.md | 162 +- .../build-profile.json5 | 114 +- .../code-linter.json5 | 0 .../entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../main/ets/pages/CreateGetCertCrlObject.ets | 268 +- .../ets/pages/CreateParseVerifyCertObject.ets | 228 +- .../CreateParseVerifyCertextensionObject.ets | 198 +- .../ets/pages/CreateParseVerifyCrlObject.ets | 408 +- .../ets/pages/CreateTrustanchorFromP12.ets | 320 +- .../CreateVerifyCerchainvalidatorObject.ets | 306 +- .../ets/pages/CreateVerifyCertchainObject.ets | 296 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 154 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../test/CertificateAlgorithmLibrary.test.ets | 350 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../CertificateAlgorithmLibrary/hvigorfile.ts | 0 .../oh-package.json5 | 50 +- .../CertificateAlgorithmLibrary/ohosTest.md | 26 +- .../CertificateAlgorithmLibrary1.png | Bin .../CertificateAlgorithmLibrary2.png | Bin .../CertificateManagement/.gitignore | 0 .../CertificateManagement/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../CertificateManagement/README.md | 142 +- .../CertificateManagement/build-profile.json5 | 114 +- .../CertificateManagement/code-linter.json5 | 0 .../CertificateManagement/entry/.gitignore | 0 .../entry/build-profile.json5 | 84 +- .../CertificateManagement/entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../ets/pages/CertManagerDialogGuidelines.ets | 116 +- .../main/ets/pages/CertManagerGuidelines.ets | 594 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 154 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ets/test/CertificateManagement.test.ets | 168 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../CertificateManagement/hvigorfile.ts | 0 .../CertificateManagement/oh-package.json5 | 50 +- .../CertificateManagement/ohosTest.md | 16 +- .../screenshots/CertificateManagement1.png | Bin .../screenshots/CertificateManagement2.png | Bin .../KeyDeletion/.gitignore | 0 .../KeyDeletion/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../KeyDeletion/README.md | 0 .../KeyDeletion/build-profile.json5 | 114 +- .../KeyDeletion/code-linter.json5 | 0 .../KeyDeletion/entry/.gitignore | 0 .../KeyDeletion/entry/build-profile.json5 | 116 +- .../KeyDeletion/entry/hvigorfile.ts | 0 .../KeyDeletion/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 232 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/KeyDeletion.ets | 342 +- .../KeyDeletion/entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ohosTest/ets/test/KeyDeletion.test.ets | 152 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../KeyDeletion/entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../KeyDeletion/hvigor/hvigor-config.json5 | 74 +- .../KeyDeletion/hvigorfile.ts | 0 .../KeyDeletion/oh-package.json5 | 50 +- .../KeyDeletion/ohosTest.md | 16 +- .../screenshots/KeyDeletionCpp_1.png | Bin .../screenshots/KeyDeletionCpp_2.png | Bin .../KeyDeletion/screenshots/KeyDeletion_1.png | Bin .../KeyDeletion/screenshots/KeyDeletion_2.png | Bin .../GenerateKey/.gitignore | 0 .../GenerateKey/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../GenerateKey/README.md | 0 .../GenerateKey/build-profile.json5 | 114 +- .../GenerateKey/code-linter.json5 | 0 .../GenerateKey/entry/.gitignore | 0 .../GenerateKey/entry/build-profile.json5 | 116 +- .../GenerateKey/entry/hvigorfile.ts | 0 .../GenerateKey/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 180 +- .../src/main/cpp/types/libentry/Index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 254 +- .../GenerateKey/entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ohosTest/ets/test/GenerateKey.test.ets | 142 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../GenerateKey/entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../GenerateKey/hvigor/hvigor-config.json5 | 74 +- .../GenerateKey/hvigorfile.ts | 0 .../GenerateKey/oh-package.json5 | 50 +- .../GenerateKey/ohosTest.md | 16 +- .../GenerateKey/screenshots/ArkTS_1.png | Bin .../GenerateKey/screenshots/ArkTS_2.png | Bin .../GenerateKey/screenshots/Cpp_1.png | Bin .../GenerateKey/screenshots/Cpp_2.png | Bin .../ImportEncryptedKey/.gitignore | 0 .../ImportEncryptedKey/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ImportEncryptedKey/README.md | 0 .../ImportEncryptedKey/build-profile.json5 | 116 +- .../ImportEncryptedKey/code-linter.json5 | 68 +- .../ImportEncryptedKey/entry/.gitignore | 0 .../entry/build-profile.json5 | 118 +- .../ImportEncryptedKey/entry/hvigorfile.ts | 42 +- .../ImportEncryptedKey/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 1222 +- .../src/main/cpp/types/libentry/index.d.ts | 32 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/ImportEncryptedKey.ets | 1322 +- .../entry/src/main/ets/pages/Index.ets | 126 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 98 +- .../ets/test/ImportEncryptedKey.test.ets | 146 +- .../entry/src/ohosTest/ets/test/List.test.ets | 40 +- .../entry/src/ohosTest/module.json5 | 54 +- .../hvigor/hvigor-config.json5 | 74 +- .../ImportEncryptedKey/hvigorfile.ts | 42 +- .../ImportEncryptedKey/oh-package.json5 | 50 +- .../ImportEncryptedKey/ohosTest.md | 16 +- .../ImportKeyPlainText/.gitignore | 0 .../ImportKeyPlainText/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../ImportKeyPlainText/build-profile.json5 | 114 +- .../ImportKeyPlainText/code-linter.json5 | 0 .../ImportKeyPlainText/entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../ImportKeyPlainText/entry/hvigorfile.ts | 0 .../ImportKeyPlainText/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 202 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/AES256.ets | 282 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/RSA2048.ets | 380 +- .../entry/src/main/ets/pages/X25519.ets | 302 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ets/test/ImportKeyPlainText.test.ets | 194 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../ImportKeyPlainText/hvigorfile.ts | 0 .../ImportKeyPlainText/oh-package.json5 | 50 +- .../AnonymousKeyProof/.gitignore | 0 .../AnonymousKeyProof/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../AnonymousKeyProof/README.md | 0 .../AnonymousKeyProof/build-profile.json5 | 114 +- .../AnonymousKeyProof/code-linter.json5 | 0 .../AnonymousKeyProof/entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../AnonymousKeyProof/entry/hvigorfile.ts | 0 .../AnonymousKeyProof/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 314 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/AnonymousKeyProof.ets | 430 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ets/test/AnonymousKeyProof.test.ets | 152 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../AnonymousKeyProof/hvigorfile.ts | 0 .../AnonymousKeyProof/oh-package.json5 | 50 +- .../AnonymousKeyProof/ohosTest.md | 16 +- .../screenshots/AnonymousKeyProof_1.png | Bin .../screenshots/AnonymousKeyProof_2.png | Bin .../AnonymousKeyProof/screenshots/Cpp_1.png | Bin .../AnonymousKeyProof/screenshots/Cpp_2.png | Bin .../NonanonymousKeyProof/.gitignore | 0 .../NonanonymousKeyProof/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../NonanonymousKeyProof/README.md | 0 .../NonanonymousKeyProof/build-profile.json5 | 114 +- .../NonanonymousKeyProof/code-linter.json5 | 0 .../NonanonymousKeyProof/entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../NonanonymousKeyProof/entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../main/ets/pages/NonAnonymousKeyProof.ets | 430 +- .../entry/src/main/module.json5 | 156 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/NonAnonymousKeyProof.test.ets | 152 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../NonanonymousKeyProof/hvigorfile.ts | 0 .../NonanonymousKeyProof/oh-package.json5 | 50 +- .../NonanonymousKeyProof/ohosTest.md | 16 +- .../screenshots/Cpp_1.png | Bin .../screenshots/Cpp_2.png | Bin .../screenshots/NonAnonymousKeyProof_1.png | Bin .../screenshots/NonAnonymousKeyProof_2.png | Bin .../KeyUsage/AccessControl/.gitignore | 22 +- .../KeyUsage/AccessControl/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../KeyUsage/AccessControl/README.md | 176 +- .../AccessControl/build-profile.json5 | 116 +- .../KeyUsage/AccessControl/code-linter.json5 | 68 +- .../KeyUsage/AccessControl/entry/.gitignore | 10 +- .../AccessControl/entry/build-profile.json5 | 84 +- .../AccessControl/entry/hvigorfile.ts | 42 +- .../AccessControl/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../FineGrainedUserIdentityAuthentication.ets | 886 +- .../entry/src/main/ets/pages/Index.ets | 134 +- .../ets/pages/UserIdentityAuthentication.ets | 834 +- .../AccessControl/entry/src/main/module.json5 | 140 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/float.json | 14 +- .../main/resources/base/element/string.json | 48 +- .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 12 +- .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 12 +- .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 98 +- .../ohosTest/ets/test/AccessControl.test.ets | 158 +- .../entry/src/ohosTest/ets/test/List.test.ets | 40 +- .../entry/src/ohosTest/module.json5 | 54 +- .../AccessControl/hvigor/hvigor-config.json5 | 74 +- .../KeyUsage/AccessControl/hvigorfile.ts | 42 +- .../KeyUsage/AccessControl/oh-package.json5 | 50 +- .../KeyUsage/AccessControl/ohosTest.md | 16 +- ...ineGrainedUserIdentityAuthentication_1.png | Bin ...ineGrainedUserIdentityAuthentication_2.png | Bin .../UserIdentityAuthentication_1.png | Bin .../UserIdentityAuthentication_2.png | Bin .../KeyUsage/EncryptionDecryption/.gitignore | 0 .../EncryptionDecryption/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../KeyUsage/EncryptionDecryption/README.md | 0 .../EncryptionDecryption/build-profile.json5 | 114 +- .../EncryptionDecryption/code-linter.json5 | 0 .../EncryptionDecryption/entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../EncryptionDecryption/entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 458 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/AESCBCPKCS7.ets | 528 +- .../src/main/ets/pages/AESGCMNoPadding.ets | 544 +- .../entry/src/main/ets/pages/Index.ets | 0 .../src/main/ets/pages/RSAECBOAEPSHA256.ets | 522 +- .../src/main/ets/pages/RSAECBPKCS1_V1_5.ets | 524 +- .../entry/src/main/ets/pages/SM2.ets | 500 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ets/test/EncryptionDecryption.test.ets | 296 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../EncryptionDecryption/hvigorfile.ts | 0 .../EncryptionDecryption/oh-package.json5 | 50 +- .../KeyUsage/EncryptionDecryption/ohosTest.md | 24 +- .../screenshots/AESCBCPKCS7_1.png | Bin .../screenshots/AESCBCPKCS7_2.png | Bin .../screenshots/AESGCMNoPadding_1.png | Bin .../screenshots/AESGCMNoPadding_2.png | Bin .../screenshots/Cpp_1.png | Bin .../screenshots/RSAECBOAEPSHA256_1.png | Bin .../screenshots/RSAECBOAEPSHA256_2.png | Bin .../screenshots/RSAECBPKCS1_V1_5_1.png | Bin .../screenshots/RSAECBPKCS1_V1_5_2.png | Bin .../screenshots/SM2_1.png | Bin .../screenshots/SM2_2.png | Bin .../KeyUsage/HMAC/.gitignore | 0 .../KeyUsage/HMAC/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../KeyUsage/HMAC/README.md | 0 .../KeyUsage/HMAC/build-profile.json5 | 116 +- .../KeyUsage/HMAC/code-linter.json5 | 68 +- .../KeyUsage/HMAC/entry/.gitignore | 0 .../KeyUsage/HMAC/entry/build-profile.json5 | 116 +- .../KeyUsage/HMAC/entry/hvigorfile.ts | 42 +- .../KeyUsage/HMAC/entry/oh-package.json5 | 50 +- .../HMAC/entry/src/main/cpp/CMakeLists.txt | 28 +- .../HMAC/entry/src/main/cpp/napi_init.cpp | 268 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../HMAC/entry/src/main/ets/pages/HMAC.ets | 310 +- .../HMAC/entry/src/main/ets/pages/Index.ets | 138 +- .../KeyUsage/HMAC/entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 98 +- .../entry/src/ohosTest/ets/test/HMAC.test.ets | 154 +- .../entry/src/ohosTest/ets/test/List.test.ets | 38 +- .../HMAC/entry/src/ohosTest/module.json5 | 54 +- .../KeyUsage/HMAC/hvigor/hvigor-config.json5 | 74 +- .../KeyUsage/HMAC/hvigorfile.ts | 42 +- .../KeyUsage/HMAC/oh-package.json5 | 50 +- .../KeyUsage/HMAC/ohosTest.md | 16 +- .../KeyUsage/HMAC/screenshots/HMAC_1.png | Bin .../KeyUsage/HMAC/screenshots/HMAC_2.png | Bin .../KeyUsage/HMAC/screenshots/cpp_1.png | Bin .../KeyUsage/HMAC/screenshots/cpp_2.png | Bin .../KeyUsage/KeyDerivation/.gitignore | 0 .../KeyUsage/KeyDerivation/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../KeyUsage/KeyDerivation/README.md | 0 .../KeyDerivation/build-profile.json5 | 114 +- .../KeyUsage/KeyDerivation/code-linter.json5 | 0 .../KeyUsage/KeyDerivation/entry/.gitignore | 0 .../KeyDerivation/entry/build-profile.json5 | 116 +- .../KeyDerivation/entry/hvigorfile.ts | 0 .../KeyDerivation/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 296 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/HKDF.ets | 724 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/PBKDF2.ets | 746 +- .../KeyDerivation/entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ohosTest/ets/test/KeyDerivation.test.ets | 190 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../KeyDerivation/hvigor/hvigor-config.json5 | 74 +- .../KeyUsage/KeyDerivation/hvigorfile.ts | 0 .../KeyUsage/KeyDerivation/oh-package.json5 | 50 +- .../KeyUsage/KeyDerivation/ohosTest.md | 18 +- .../KeyDerivation/screenshots/Cpp_1.png | Bin .../KeyDerivation/screenshots/Cpp_2.png | Bin .../KeyDerivation/screenshots/HKDF_1.png | Bin .../KeyDerivation/screenshots/HKDF_2.png | Bin .../KeyDerivation/screenshots/PBKDF2_1.png | Bin .../KeyDerivation/screenshots/PBKDF2_2.png | Bin .../KeyUsage/KeyExchange/.gitignore | 0 .../KeyUsage/KeyExchange/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../KeyUsage/KeyExchange/README.md | 0 .../KeyUsage/KeyExchange/build-profile.json5 | 114 +- .../KeyUsage/KeyExchange/code-linter.json5 | 0 .../KeyUsage/KeyExchange/entry/.gitignore | 0 .../KeyExchange/entry/build-profile.json5 | 116 +- .../KeyUsage/KeyExchange/entry/hvigorfile.ts | 0 .../KeyExchange/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 530 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/DH.ets | 406 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/X25519.ets | 854 +- .../KeyExchange/entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ohosTest/ets/test/KeyExchange.test.ets | 188 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../KeyExchange/entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../KeyExchange/hvigor/hvigor-config.json5 | 74 +- .../KeyUsage/KeyExchange/hvigorfile.ts | 0 .../KeyUsage/KeyExchange/oh-package.json5 | 50 +- .../KeyUsage/KeyExchange/ohosTest.md | 18 +- .../KeyExchange/screenshots/Cpp_1.png | Bin .../KeyExchange/screenshots/Cpp_2.png | Bin .../KeyUsage/KeyExchange/screenshots/DH_1.png | Bin .../KeyUsage/KeyExchange/screenshots/DH_2.png | Bin .../KeyExchange/screenshots/X25519_1.png | Bin .../KeyExchange/screenshots/X25519_2.png | Bin .../KeyUsage/SigningVerification/.gitignore | 0 .../SigningVerification/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../KeyUsage/SigningVerification/README.md | 0 .../SigningVerification/build-profile.json5 | 114 +- .../SigningVerification/code-linter.json5 | 0 .../SigningVerification/entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../SigningVerification/entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 334 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/ECC256SHA256.ets | 430 +- .../entry/src/main/ets/pages/Index.ets | 0 .../main/ets/pages/RSASHA256PKCS1_V1_5.ets | 438 +- .../entry/src/main/ets/pages/RSASHA256PSS.ets | 452 +- .../entry/src/main/ets/pages/SM2SM3.ets | 436 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/SigningVerification.test.ets | 260 +- .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../SigningVerification/hvigorfile.ts | 0 .../SigningVerification/oh-package.json5 | 50 +- .../KeyUsage/SigningVerification/ohosTest.md | 22 +- .../screenshots/ECC2561.png | Bin .../screenshots/ECC2562.png | Bin .../SigningVerification/screenshots/RSA1.png | Bin .../SigningVerification/screenshots/RSA2.png | Bin .../screenshots/SHA2561.png | Bin .../screenshots/SHA2562.png | Bin .../SigningVerification/screenshots/SM21.png | Bin .../SigningVerification/screenshots/SM22.png | Bin .../SigningVerification/screenshots/cpp1.png | Bin .../SigningVerification/screenshots/cpp2.png | Bin .../OtherOperations/CheckKeyExists/.gitignore | 0 .../CheckKeyExists/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../OtherOperations/CheckKeyExists/README.md | 0 .../CheckKeyExists/build-profile.json5 | 114 +- .../CheckKeyExists/code-linter.json5 | 0 .../CheckKeyExists/entry/.gitignore | 0 .../CheckKeyExists/entry/build-profile.json5 | 116 +- .../CheckKeyExists/entry/hvigorfile.ts | 0 .../CheckKeyExists/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 232 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/CheckKeyExists.ets | 280 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ohosTest/ets/test/CheckKeyExists.test.ets | 154 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../CheckKeyExists/hvigor/hvigor-config.json5 | 74 +- .../CheckKeyExists/hvigorfile.ts | 0 .../CheckKeyExists/oh-package.json5 | 50 +- .../CheckKeyExists/ohosTest.md | 16 +- .../screenshots/CheckKeyExists_1.png | Bin .../screenshots/CheckKeyExists_2.png | Bin .../CheckKeyExists/screenshots/Cpp_1.png | Bin .../CheckKeyExists/screenshots/Cpp_2.png | Bin .../GetKeyAttributes/.gitignore | 0 .../GetKeyAttributes/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../GetKeyAttributes/README.md | 0 .../GetKeyAttributes/build-profile.json5 | 114 +- .../GetKeyAttributes/code-linter.json5 | 0 .../GetKeyAttributes/entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../GetKeyAttributes/entry/hvigorfile.ts | 0 .../GetKeyAttributes/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 264 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/GetKeyAttributes.ets | 268 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../ets/test/GetKeyAttributes.test.ets | 154 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../entry/src/ohosTest/module.json5 | 54 +- .../entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../hvigor/hvigor-config.json5 | 74 +- .../GetKeyAttributes/hvigorfile.ts | 0 .../GetKeyAttributes/oh-package.json5 | 50 +- .../GetKeyAttributes/ohosTest.md | 16 +- .../GetKeyAttributes/screenshots/Cpp_1.png | Bin .../GetKeyAttributes/screenshots/Cpp_2.png | Bin .../screenshots/GetKeyAttributes_1.png | Bin .../screenshots/GetKeyAttributes_2.png | Bin .../OtherOperations/KeyExport/.gitignore | 0 .../KeyExport/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../OtherOperations/KeyExport/README.md | 0 .../KeyExport/build-profile.json5 | 114 +- .../KeyExport/code-linter.json5 | 0 .../KeyExport/entry/.gitignore | 0 .../KeyExport/entry/build-profile.json5 | 116 +- .../KeyExport/entry/hvigorfile.ts | 0 .../KeyExport/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 248 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../entry/src/main/ets/pages/KeyExport.ets | 270 +- .../KeyExport/entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../src/ohosTest/ets/test/KeyExport.test.ets | 152 +- .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../KeyExport/entry/src/ohosTest/module.json5 | 54 +- .../KeyExport/entry/src/test/List.test.ets | 0 .../entry/src/test/LocalUnit.test.ets | 0 .../KeyExport/hvigor/hvigor-config.json5 | 74 +- .../OtherOperations/KeyExport/hvigorfile.ts | 0 .../KeyExport/oh-package.json5 | 50 +- .../OtherOperations/KeyExport/ohosTest.md | 16 +- .../KeyExport/screenshots/Cpp_1.png | Bin .../KeyExport/screenshots/Cpp_2.png | Bin .../KeyExport/screenshots/KeyExport_1.png | Bin .../KeyExport/screenshots/KeyExport_2.png | Bin .../QueryKeyAliasSet/.gitignore | 0 .../QueryKeyAliasSet/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../QueryKeyAliasSet/README.md | 0 .../QueryKeyAliasSet/build-profile.json5 | 114 +- .../QueryKeyAliasSet/code-linter.json5 | 0 .../QueryKeyAliasSet/entry/.gitignore | 0 .../entry/build-profile.json5 | 116 +- .../QueryKeyAliasSet/entry/hvigorfile.ts | 0 .../QueryKeyAliasSet/entry/oh-package.json5 | 50 +- .../entry/src/main/cpp/CMakeLists.txt | 28 +- .../entry/src/main/cpp/napi_init.cpp | 200 +- .../src/main/cpp/types/libentry/index.d.ts | 30 +- .../main/cpp/types/libentry/oh-package.json5 | 40 +- .../main/ets/entryability/EntryAbility.ets | 112 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../entry/src/main/ets/pages/Index.ets | 0 .../src/main/ets/pages/QueryKeyAliasSet.ets | 156 +- .../entry/src/main/module.json5 | 130 +- .../main/resources/base/element/color.json | 14 +- .../main/resources/base/element/string.json | 0 .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/backup_config.json | 4 +- .../resources/base/profile/main_pages.json | 0 .../main/resources/dark/element/color.json | 14 +- .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ets/test/QueryKeyAliasSet.test.ets | 152 +- .../entry/src/ohosTest/module.json5 | 54 +- .../hvigor/hvigor-config.json5 | 74 +- .../QueryKeyAliasSet/hvigorfile.ts | 0 .../QueryKeyAliasSet/oh-package.json5 | 50 +- .../QueryKeyAliasSet/ohosTest.md | 16 +- .../ArkRuntime/NBody/AppScope/app.json5 | 48 +- .../resources/base/element/string.json | 16 +- .../ArkRuntime/NBody/build-profile.json5 | 100 +- .../NBody/entry/build-profile.json5 | 66 +- .../ArkRuntime/NBody/entry/oh-package.json5 | 20 +- .../main/ets/entryability/EntryAbility.ets | 120 +- .../src/main/ets/model/CalculateUtil.ets | 196 +- .../NBody/entry/src/main/module.json5 | 102 +- .../main/resources/base/element/color.json | 22 +- .../main/resources/base/element/integer.json | 72 +- .../NBody/entry/src/ohosTest/module.json5 | 104 +- .../NBody/hvigor/hvigor-config.json5 | 36 +- .../ArkRuntime/NBody/oh-package.json5 | 24 +- .../renderGroup/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- code/Performance/renderGroup/README.md | 172 +- .../renderGroup/build-profile.json5 | 110 +- .../renderGroup/feature/renderGroup/Index.ets | 34 +- .../feature/renderGroup/build-profile.json5 | 86 +- .../feature/renderGroup/oh-package.json5 | 50 +- .../src/main/ets/pages/NonProfitScene.ets | 252 +- .../src/main/ets/pages/ProfitScene.ets | 286 +- .../renderGroup/src/main/ets/utils/Logger.ets | 92 +- .../src/main/ets/view/IconView.ets | 102 +- .../src/main/ets/view/NonIconView.ets | 122 +- .../feature/renderGroup/src/main/module.json5 | 50 +- .../main/resources/base/element/color.json | 30 +- .../main/resources/base/element/integer.json | 174 +- .../src/main/resources/base/media/album.svg | 58 +- .../src/main/resources/base/media/applet.svg | 30 +- .../src/main/resources/base/media/back.svg | 44 +- .../src/main/resources/base/media/cards.svg | 54 +- .../src/main/resources/base/media/nearby.svg | 60 +- .../src/main/resources/base/media/scan.svg | 56 +- .../src/main/resources/base/media/shop.svg | 60 +- .../renderGroup/hvigor/hvigor-config.json5 | 34 +- code/Performance/renderGroup/oh-package.json5 | 24 +- .../product/phone/entry/build-profile.json5 | 54 +- .../product/phone/entry/oh-package.json5 | 24 +- .../src/main/ets/entryability/EntryAbility.ts | 116 +- .../entry/src/main/ets/model/DataType.ets | 38 +- .../entry/src/main/ets/model/MockData.ets | 44 +- .../pages/renderGroup/NonProfitScenePage.ets | 50 +- .../ets/pages/renderGroup/ProfitScenePage.ets | 50 +- .../pages/renderGroup/RenderGroupHomePage.ets | 166 +- .../phone/entry/src/main/ets/utils/Logger.ets | 92 +- .../product/phone/entry/src/main/module.json5 | 102 +- .../main/resources/base/element/color.json | 30 +- .../main/resources/base/element/integer.json | 110 +- .../entry/src/ohosTest/ets/util/Logger.ets | 88 +- .../phone/entry/src/ohosTest/module.json5 | 104 +- .../uitest/entry/src/main/ets/pages/Web.ets | 86 +- .../src/main/ets/webability/WebAbility.ts | 124 +- .../src/main/resources/rawfile/index.html | 70 +- .../InputMethod/KikaInput/build-profile.json5 | 43 - code/Solutions/Social/GrapeSquare/.gitignore | 20 +- .../Social/GrapeSquare/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Social/GrapeSquare/build-profile.json5 | 108 +- .../GrapeSquare/hvigor/hvigor-config.json5 | 34 +- .../Social/GrapeSquare/hvigorfile.ts | 42 +- code/Solutions/Social/GrapeSquare/hvigorw.bat | 158 +- .../Social/GrapeSquare/oh-package.json5 | 52 +- .../product/phone/entry/.gitignore | 10 +- .../product/phone/entry/build-profile.json5 | 54 +- .../product/phone/entry/hvigorfile.ts | 42 +- .../product/phone/entry/oh-package.json5 | 52 +- .../src/main/ets/entryability/EntryAbility.ts | 216 +- .../src/main/ets/pages/AdvertisingPage.ets | 142 +- .../src/main/ets/pages/CommentDetailPage.ets | 50 +- .../entry/src/main/ets/pages/HomePage.ets | 200 +- .../src/main/ets/pages/SameCityListPage.ets | 54 +- .../entry/src/main/ets/utils/Constants.ets | 54 +- .../phone/entry/src/main/ets/utils/Logger.ts | 92 +- .../src/main/ets/utils/ResourceUtils.ets | 50 +- .../product/phone/entry/src/main/module.json5 | 102 +- .../main/resources/base/element/color.json | 30 +- .../main/resources/base/element/integer.json | 78 +- .../main/resources/base/element/string.json | 70 +- .../base/media/ic_gallery_discover.svg | 30 +- .../base/media/ic_gallery_discover_filled.svg | 36 +- .../base/media/ic_public_contacts.svg | 50 +- .../base/media/ic_public_contacts_filled.svg | 34 +- .../resources/base/media/ic_public_home.svg | 30 +- .../base/media/ic_public_home_filled.svg | 30 +- .../resources/base/profile/main_pages.json | 16 +- .../main/resources/en_US/element/string.json | 70 +- .../main/resources/zh_CN/element/string.json | 70 +- .../src/ohosTest/ets/test/Ability.test.ets | 324 +- .../entry/src/ohosTest/ets/test/List.test.ets | 38 +- .../entry/src/ohosTest/ets/test/Logger.ts | 92 +- .../ohosTest/ets/testability/TestAbility.ets | 128 +- .../ohosTest/ets/testability/pages/Index.ets | 96 +- .../ets/testrunner/OpenHarmonyTestRunner.ts | 144 +- .../phone/entry/src/ohosTest/module.json5 | 104 +- .../resources/base/element/color.json | 14 +- .../resources/base/element/string.json | 78 +- .../resources/base/profile/test_pages.json | 10 +- .../main/ets/serviceability/ServiceAbility.ts | 456 +- .../DistributedFilemanager/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../build-profile.json5 | 88 +- .../main/ets/entryability/EntryAbility.ets | 160 +- .../entry/src/main/ets/model/DataObject.ets | 300 +- .../entry/src/main/ets/model/FsManager.ets | 632 +- .../rawfile/arkdata/utd/utd-adt.json | 52 +- .../hvigor/hvigor-config.json5 | 40 +- .../DistributedFilemanager/oh-package.json5 | 24 +- .../entry/src/main/ets/model/GlobalContext.ts | 72 +- .../data/applications/Applications.ets | 100 +- .../AbilityFeatureSystem/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Ability/AbilityFeatureSystem/README_zh.md | 226 +- .../AbilityFeatureSystem/build-profile.json5 | 86 +- .../entry/build-profile.json5 | 56 +- .../entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 122 +- .../src/main/ets/newability/NewAbility.ets | 118 +- .../ets/newuiextability/NewUIExtAbility.ets | 102 +- .../entry/src/main/ets/pages/Ext.ets | 232 +- .../entry/src/main/ets/pages/New.ets | 114 +- .../entry/src/main/ets/pages/NewExt.ets | 126 +- .../entry/src/main/ets/pages/SendSync.ets | 274 +- .../entry/src/main/ets/pages/SendSyncExt.ets | 92 +- .../entry/src/main/ets/pages/Transit.ets | 82 +- .../SendSyncUIExtAbility.ets | 102 +- .../main/ets/uiextability/UIExtAbility.ets | 100 +- .../entry/src/main/ets/util/Logger.ets | 96 +- .../entry/src/main/module.json5 | 180 +- .../main/resources/base/element/color.json | 46 +- .../main/resources/base/element/float.json | 14 +- .../entry/src/ohosTest/ets/util/Logger.ts | 96 +- .../entry/src/ohosTest/module.json5 | 102 +- .../hvigor/hvigor-config.json5 | 40 +- .../AbilityFeatureSystem/oh-package.json5 | 54 +- .../Ability/AbilityFeatureSystem/ohosTest.md | 28 +- .../AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../build-profile.json5 | 100 +- .../entry/build-profile.json5 | 56 +- .../entry/oh-package.json5 | 50 +- .../EmbeddedUIExtAbility.ts | 100 +- .../src/main/ets/entryability/EntryAbility.ts | 120 +- .../entry/src/main/ets/model/Logger.ts | 88 +- .../entry/src/main/ets/pages/extension.ets | 92 +- .../entry/src/main/module.json5 | 122 +- .../main/resources/base/element/color.json | 14 +- .../entry/src/ohosTest/module.json5 | 104 +- .../hvigor/hvigor-config.json5 | 36 +- .../oh-package.json5 | 54 +- .../src/ohosTest/ets/test/Launcher.test.ets | 542 +- .../StaticSubscriber/entry/hvigorfile.ts | 4 +- .../StaticSubscriber/hvigorfile.ts | 2 +- .../StaticSubscriber/publish/hvigorfile.ts | 4 +- .../CrossChainBack/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../CrossChainBack/build-profile.json5 | 82 +- .../CrossChainBack/entry/build-profile.json5 | 56 +- .../CrossChainBack/entry/oh-package.json5 | 50 +- .../src/main/ets/entryability/EntryAbility.ts | 112 +- .../entry/src/main/ets/logger/Logger.ts | 120 +- .../main/ets/secondability/SecondAbility.ts | 116 +- .../main/ets/serviceability/ServiceAbility.ts | 122 +- .../entry/src/main/module.json5 | 150 +- .../main/resources/base/element/color.json | 14 +- .../CrossChainBack/hvigor/hvigor-config.json5 | 42 +- .../CrossChainBack/oh-package.json5 | 54 +- .../StartRecentAbility/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../StartRecentAbility/build-profile.json5 | 82 +- .../entry/build-profile.json5 | 56 +- .../StartRecentAbility/entry/oh-package.json5 | 50 +- .../src/main/ets/entryability/EntryAbility.ts | 122 +- .../entry/src/main/ets/logger/Logger.ts | 122 +- .../main/ets/secondability/SecondAbility.ts | 114 +- .../entry/src/main/module.json5 | 122 +- .../main/resources/base/element/color.json | 14 +- .../hvigor/hvigor-config.json5 | 42 +- .../StartRecentAbility/oh-package.json5 | 54 +- .../UIExtensionAbility/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../UIExtensionAbility/build-profile.json5 | 100 +- .../entry/build-profile.json5 | 56 +- .../UIExtensionAbility/entry/oh-package.json5 | 20 +- .../src/main/ets/entryability/EntryAbility.ts | 122 +- .../entry/src/main/ets/model/Logger.ts | 88 +- .../entry/src/main/ets/pages/Extension.ets | 90 +- .../uiextensionability/UIExtensionAbility.ets | 100 +- .../entry/src/main/module.json5 | 120 +- .../main/resources/base/element/color.json | 14 +- .../entry/src/ohosTest/module.json5 | 104 +- .../hvigor/hvigor-config.json5 | 66 +- .../UIExtensionAbility/oh-package.json5 | 54 +- .../AutoFill/AutoFill/AppScope/app.json5 | 48 +- .../resources/base/element/string.json | 16 +- .../AutoFill/AutoFill/build-profile.json5 | 84 +- .../AutoFill/entry/build-profile.json5 | 56 +- .../AutoFill/AutoFill/entry/oh-package.json5 | 20 +- .../ets/autofillability/AutoFillAbility.ts | 196 +- .../ets/autofillpages/AutoFillControl.ets | 226 +- .../ets/autofillpages/AutoFillNewPassWord.ets | 244 +- .../autofillpages/BiometricAuthentication.ets | 316 +- .../ets/autofillpages/LoginSuccessPage.ets | 62 +- .../main/ets/autofillpages/RegisterPage.ets | 386 +- .../src/main/ets/autofillpages/SavePage.ets | 212 +- .../src/main/ets/entryability/EntryAbility.ts | 152 +- .../AutoFill/entry/src/main/ets/log/Logger.ts | 88 +- .../AutoFill/entry/src/main/module.json5 | 122 +- .../main/resources/base/element/color.json | 94 +- .../src/main/resources/base/media/arrow.svg | 0 .../src/main/resources/base/media/svg.png | Bin .../entry/src/ohosTest/ets/util/Logger.ts | 88 +- .../AutoFill/entry/src/ohosTest/module.json5 | 104 +- .../AutoFill/hvigor/hvigor-config.json5 | 36 +- .../AutoFill/AutoFill/oh-package.json5 | 52 +- .../AutoFill/AutoFill/ohosTest.md | 22 +- .../AutoFill/screenshots/autoFillControl.jpg | Bin .../screenshots/biometricauthentication.jpg | Bin .../AppScope/app.json5 | 48 +- .../resources/base/element/string.json | 16 +- .../resources/base/media/app_icon.png | Bin .../AutoFillScenarioization/README_zh.md | 0 .../build-profile.json5 | 84 +- .../entry/build-profile.json5 | 56 +- .../entry/hvigorfile.ts | 0 .../entry/oh-package.json5 | 18 +- .../src/main/ets/application/ItemListData.ts | 32 +- .../autofillability/TextAutoFillAbility.ts | 232 +- .../main/ets/autofillpages/ReturnMainPage.ets | 0 .../src/main/ets/autofillpages/SavePage.ets | 206 +- .../main/ets/autofillpages/SelectorList.ets | 224 +- .../src/main/ets/entryability/EntryAbility.ts | 124 +- .../entry/src/main/ets/pages/Index.ets | 338 +- .../entry/src/main/module.json5 | 124 +- .../main/resources/base/element/color.json | 78 +- .../main/resources/base/element/string.json | 0 .../src/main/resources/base/media/arrow.png | Bin .../resources/base/media/ic_public_back.svg | 0 .../src/main/resources/base/media/icon.png | Bin .../src/main/resources/base/media/style.png | Bin .../resources/base/profile/main_pages.json | 0 .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../src/ohosTest/ets/test/Ability.test.ets | 0 .../entry/src/ohosTest/ets/test/List.test.ets | 0 .../ohosTest/ets/testability/TestAbility.ets | 0 .../ohosTest/ets/testability/pages/Index.ets | 0 .../ets/testrunner/OpenHarmonyTestRunner.ts | 0 .../entry/src/ohosTest/module.json5 | 102 +- .../resources/base/element/color.json | 0 .../resources/base/element/string.json | 0 .../ohosTest/resources/base/media/icon.png | Bin .../resources/base/profile/test_pages.json | 0 .../hvigor/hvigor-config.json5 | 40 +- .../hvigor/hvigor-wrapper.js | 0 .../AutoFillScenarioization/hvigorfile.ts | 0 .../AutoFill/AutoFillScenarioization/hvigorw | 0 .../AutoFillScenarioization/hvigorw.bat | 0 .../AutoFillScenarioization/oh-package.json5 | 24 +- .../AutoFillScenarioization/ohosTest.md | 20 +- .../screenshots/Index.jpg | Bin .../screenshots/NameAssociation.jpg | Bin .../screenshots/ReturnMainPage.jpg | Bin .../screenshots/SavePage.jpg | Bin .../screenshots/SelectorList.jpg | Bin .../FullScreenStart/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../FullScreenStart/build-profile.json5 | 102 +- .../FullScreenStart/entry/build-profile.json5 | 84 +- .../FullScreenStart/entry/oh-package.json5 | 50 +- .../main/ets/entryability/EntryAbility.ets | 114 +- .../entrybackupability/EntryBackupAbility.ets | 52 +- .../src/main/ets/pages/ExtensionIndex.ets | 116 +- .../uiextensionability/UIExtensionAbility.ets | 94 +- .../entry/src/main/module.json5 | 144 +- .../main/resources/base/element/color.json | 14 +- .../resources/base/profile/backup_config.json | 4 +- .../entry/src/ohosTest/module.json5 | 54 +- .../hvigor/hvigor-config.json5 | 74 +- .../FullScreenStart/oh-package.json5 | 50 +- .../FullScreenStart/ohosTest.md | 16 +- .../AppScope/app.json5 | 52 +- .../resources/base/element/string.json | 16 +- .../build-profile.json5 | 100 +- .../entry/build-profile.json5 | 84 +- .../entry/oh-package.json5 | 50 +- .../ets/common/constants/CommonConstants.ets | 248 +- .../main/ets/common/util/CalculateUtil.ets | 562 +- .../main/ets/common/util/CheckEmptyUtil.ets | 100 +- .../main/ets/entryability/EntryAbility.ets | 130 +- .../src/main/ets/viewmodel/PressKeysItem.ets | 58 +- .../main/ets/viewmodel/PresskeysViewModel.ets | 112 +- .../entry/src/main/module.json5 | 102 +- .../main/resources/base/element/color.json | 62 +- .../main/resources/base/element/float.json | 150 +- .../entry/src/ohosTest/module.json5 | 54 +- .../hvigor/hvigor-config.json5 | 74 +- .../FullScreenStart_Service/oh-package.json5 | 50 +- .../AuthorizedButton/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- .../Security/AuthorizedButton/README_zh.md | 186 +- .../AuthorizedButton/build-profile.json5 | 82 +- .../entry/build-profile.json5 | 56 +- .../AuthorizedButton/entry/oh-package.json5 | 50 +- .../ets/common/Component/AuthorizedButton.ets | 82 +- .../main/ets/common/Component/CopyButton.ets | 150 +- .../ets/common/Component/LocationButton.ets | 218 +- .../main/ets/common/Component/PasteButton.ets | 174 +- .../main/ets/common/Component/SaveButton.ets | 174 +- .../src/main/ets/entryability/EntryAbility.ts | 116 +- .../ets/securitycomponent/pages/Location.ets | 120 +- .../ets/securitycomponent/pages/Paste.ets | 234 +- .../main/ets/securitycomponent/pages/Save.ets | 118 +- .../entry/src/main/ets/utils/Logger.ts | 88 +- .../entry/src/main/module.json5 | 100 +- .../main/resources/base/element/color.json | 62 +- .../entry/src/ohosTest/module.json5 | 102 +- .../entry/src/ohosTest/utils/Logger.ts | 88 +- .../hvigor/hvigor-config.json5 | 10 +- .../AuthorizedButton/oh-package.json5 | 54 +- .../Security/DLP/AppScope/app.json5 | 50 +- .../resources/base/element/string.json | 16 +- code/SystemFeature/Security/DLP/README_zh.md | 152 +- .../Security/DLP/build-profile.json5 | 100 +- .../Security/DLP/entry/build-profile.json5 | 56 +- .../Security/DLP/entry/oh-package.json5 | 50 +- .../src/main/ets/component/CustomDialog.ets | 220 +- .../src/main/ets/entryability/EntryAbility.ts | 164 +- .../entry/src/main/ets/feature/DlpManager.ets | 476 +- .../src/main/ets/feature/FileManager.ets | 316 +- .../main/ets/feature/PreferencesManager.ets | 168 +- .../DLP/entry/src/main/ets/util/Logger.ts | 88 +- .../entry/src/main/ets/util/ResourceUtils.ets | 50 +- .../Security/DLP/entry/src/main/module.json5 | 148 +- .../main/resources/base/element/color.json | 30 +- .../src/main/resources/base/media/ic_docs.svg | 24 +- .../main/resources/base/media/ic_folder.svg | 24 +- .../main/resources/base/media/ic_saveas.svg | 24 +- .../main/resources/base/media/triangle.svg | 22 +- .../src/ohosTest/ets/test/Ability.test.ets | 416 +- .../entry/src/ohosTest/ets/test/List.test.ets | 38 +- .../DLP/entry/src/ohosTest/ets/test/Logger.ts | 92 +- .../ohosTest/ets/testability/TestAbility.ets | 128 +- .../ohosTest/ets/testability/pages/Index.ets | 102 +- .../ets/testrunner/OpenHarmonyTestRunner.ts | 120 +- .../DLP/entry/src/ohosTest/module.json5 | 104 +- .../resources/base/element/color.json | 14 +- .../resources/base/element/string.json | 46 +- .../resources/base/profile/test_pages.json | 10 +- .../Security/DLP/hvigor/hvigor-config.json5 | 34 +- .../Security/DLP/oh-package.json5 | 54 +- code/SystemFeature/Security/DLP/ohosTest.md | 22 +- .../UIExtensionSamples/AppScope/app.json5 | 48 +- .../resources/base/element/string.json | 16 +- .../UIExtensionSamples/README_zh.md | 304 +- .../UIExtensionSamples/build-profile.json5 | 104 +- .../entry/build-profile.json5 | 82 +- .../UIExtensionSamples/entry/oh-package.json5 | 20 +- .../main/ets/entryability/EntryAbility.ets | 176 +- .../ets/entryability/OpenLinkUIAbility.ets | 190 +- .../ContextUIExtensionAbility.ets | 104 +- .../SessionUIExtensionAbility.ets | 100 +- .../uiextensionpages/AbilityStartCallback.ets | 312 +- .../UIExtensionContentSession.ets | 226 +- .../UIExtensionContentSessionPage.ets | 424 +- .../uiextensionpages/UIExtensionContext.ets | 336 +- .../UIExtensionContextPage.ets | 442 +- .../entry/src/main/module.json5 | 208 +- .../main/resources/base/element/color.json | 30 +- .../resources/base/profile/backup_config.json | 4 +- .../entry/src/ohosTest/module.json5 | 52 +- .../hvigor/hvigor-config.json5 | 44 +- .../UIExtensionSamples/oh-package.json5 | 20 +- .../LayoutAnimationSample.ets | 402 +- .../SideBarTransitionSample.ets | 170 +- .../SizeTransitionSample.ets | 384 +- .../listSample/ListSample.ets | 170 +- .../navRouterSample/NavRouterSample.ets | 116 +- .../SwiperCustomAnimationControlPanel.ets | 184 +- .../imageSpanSample/ImageSpanSample.ets | 146 +- .../customEventSample/CustomClickEvent.ets | 356 +- .../customEventSample/CustomEventHome.ets | 196 +- .../CustomScrollingEvent.ets | 368 +- .../customGesture/CustomGestureJudge.ets | 340 +- .../backgroundSample/ChangePanel.ets | 156 +- .../properties/effectsSample/ChangePanel.ets | 168 +- .../foregroundSample/ForegroundSample.ets | 138 +- .../properties/safeAreaSample/ChangePanel.ets | 0 .../safeAreaSample/SafeAreaSample.ets | 152 +- .../src/main/resources/ar/element/string.json | 11974 ++++++++-------- .../src/main/resources/ar/element/string.json | 16 +- .../src/main/resources/ar/element/string.json | 14 +- .../screenshots/devices/general.jpeg | Bin .../ParentChildPartialContentSyncCode.ets | 108 - 12849 files changed, 340523 insertions(+), 339414 deletions(-) mode change 100755 => 100644 README.md mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/app.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/README_zh.md mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/build-profile.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/build-profile.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/hvigorfile.ts mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/entryability/EntryAbility.ts mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newability/NewAbility.ts mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newuiextability/NewUIExtAbility.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/NewPage.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/module.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/ic_back.svg mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/icon.png mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/pic_empty.svg mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/profile/shortcuts_config.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testability/TestAbility.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testability/pages/Index.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/element/color.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/media/icon.png mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/profile/test_pages.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/en_US/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/zh_CN/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-wrapper.js mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorfile.ts mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw.bat mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/build-profile.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/hvigorfile.ts mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/Index.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/utils/Calc.ts mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/module.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/color.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/icon.png mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/setting.jpeg mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/build-profile.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/hvigorfile.ts mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/Index.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/utils/Calc.ts mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/module.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/color.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/icon.png mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/setting.jpeg mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/ohosTest.md mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/Scene-directory.png mode change 100755 => 100644 code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/snapshot_directory.png delete mode 100644 code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-config.json5 delete mode 100644 code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-wrapper.js mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/.gitignore mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/app.json5 mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/README_zh.md mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/build-profile.json5 mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/.gitignore mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/build-profile.json5 mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/hvigorfile.js mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/entryability/EntryAbility.ts mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/displayMediaFile.ets mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/selectMediaType.ets mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/util/Logger.ts mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/module.json5 mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/file.png mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/ic_select_option_collection.png mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/icon.png mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/image.png mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/myAudio.png mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/utdType_back.svg mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/video.png mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/en/element/string.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/zh/element/string.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/Application/TestAbilityStage.ts mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testability/TestAbility.ets mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testability/pages/Index.ets mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/util/Logger.ts mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/element/color.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/media/icon.png mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/profile/test_pages.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/en/element/string.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/zh/element/string.json mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-wrapper.js mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigorw mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigorw.bat mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/ohosTest.md mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/display_file.png mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/first.png mode change 100755 => 100644 code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/select_type.png create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/.gitignore create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/app.json5 create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/resources/base/element/string.json create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/resources/base/media/app_icon.png create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/build-profile.json5 rename code/{DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport => BasicFeature/DeviceManagement/Sensor/JsApi}/entry/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/build-profile.json5 create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/hvigorfile.ts create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/oh-package.json5 create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/ets/entryability/EntryAbility.ts create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/ets/pages/Index.ets create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/module.json5 rename code/{DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly => BasicFeature/DeviceManagement/Sensor/JsApi/entry}/src/main/resources/base/element/color.json (100%) create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/resources/base/element/string.json create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/resources/base/media/icon.png rename code/{DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport => BasicFeature/DeviceManagement/Sensor/JsApi}/entry/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/resources/en_US/element/string.json create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/resources/zh_CN/element/string.json create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/test/List.test.ets create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/testability/TestAbility.ets create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/testability/pages/Index.ets create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/module.json5 create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/element/color.json create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/element/string.json create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/media/icon.png create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/profile/test_pages.json create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigor/hvigor-config.json5 create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigor/hvigor-wrapper.js create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorfile.ts create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorw create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorw.bat create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/oh-package-lock.json5 create mode 100644 code/BasicFeature/DeviceManagement/Sensor/JsApi/oh-package.json5 create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/.gitignore create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/app.json5 create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/resources/base/element/string.json create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/resources/base/media/app_icon.png create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/build-profile.json5 rename code/{DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1 => BasicFeature/DeviceManagement/Vibrator/JsApi/entry}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/build-profile.json5 create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/hvigorfile.ts create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/oh-package.json5 create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/ets/entryability/EntryAbility.ts create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/ets/pages/Index.ets create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/module.json5 create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/base/element/color.json create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/base/element/string.json create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/base/media/icon.png rename code/{DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp => BasicFeature/DeviceManagement/Vibrator/JsApi/entry}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/en_US/element/string.json create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/rawfile/vibrator.json create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/zh_CN/element/string.json create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/test/List.test.ets create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/testability/TestAbility.ets create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/testability/pages/Index.ets create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/module.json5 create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/element/color.json create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/element/string.json create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/media/icon.png create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/profile/test_pages.json create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigor/hvigor-config.json5 create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigor/hvigor-wrapper.js create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorfile.ts create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorw create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorw.bat create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/oh-package-lock.json5 create mode 100644 code/BasicFeature/DeviceManagement/Vibrator/JsApi/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/.gitignore mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/AppScope/app.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/README_zh.md mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/build-profile.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/code-linter.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/.gitignore mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/build-profile.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/hvigorfile.ts mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/obfuscation-rules.txt mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/common/log_common.h mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/module.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/mock/Libentry.mock.ets mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/test/List.test.ets mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/hvigorfile.ts mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/ohosTest.md mode change 100755 => 100644 code/BasicFeature/Native/NdkNativeFence/screenshots/SyncFence.jpeg mode change 100755 => 100644 code/BasicFeature/Security/Asset/.gitignore mode change 100755 => 100644 code/BasicFeature/Security/Asset/AppScope/app.json5 mode change 100755 => 100644 code/BasicFeature/Security/Asset/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/BasicFeature/Security/Asset/AppScope/resources/base/media/back.png mode change 100755 => 100644 code/BasicFeature/Security/Asset/AppScope/resources/base/media/forward.png mode change 100755 => 100644 code/BasicFeature/Security/Asset/README_zh.md mode change 100755 => 100644 code/BasicFeature/Security/Asset/build-profile.json5 mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/.gitignore mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/build-profile.json5 mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/hvigorfile.ts mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/ets/common/Logger.ts mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/ets/entryability/EntryAbility.ts mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/ets/model/AssetModel.ets mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/ets/pages/QueryResultPage.ets mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/ets/pages/UpdatePage.ets mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/module.json5 mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/float.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/images.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/stringarray.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/testability/TestAbility.ets mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/testability/pages/Index.ets mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/element/color.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/element/string.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/media/icon.png mode change 100755 => 100644 code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/profile/test_pages.json mode change 100755 => 100644 code/BasicFeature/Security/Asset/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/BasicFeature/Security/Asset/hvigor/hvigor-wrapper.js mode change 100755 => 100644 code/BasicFeature/Security/Asset/hvigorfile.ts mode change 100755 => 100644 code/BasicFeature/Security/Asset/hvigorw mode change 100755 => 100644 code/BasicFeature/Security/Asset/hvigorw.bat mode change 100755 => 100644 code/BasicFeature/Security/Asset/oh-package.json5 mode change 100755 => 100644 code/BasicFeature/Security/Asset/ohosTest.md mode change 100755 => 100644 code/BasicFeature/Security/Asset/screenshots/batch_query_result.jpeg mode change 100755 => 100644 code/BasicFeature/Security/Asset/screenshots/delete.jpeg mode change 100755 => 100644 code/BasicFeature/Security/Asset/screenshots/query.jpeg mode change 100755 => 100644 code/BasicFeature/Security/Asset/screenshots/save.jpeg mode change 100755 => 100644 code/BasicFeature/Security/Asset/screenshots/single_query_result.jpeg mode change 100755 => 100644 code/BasicFeature/Security/Asset/screenshots/update_edit.jpeg mode change 100755 => 100644 code/BasicFeature/Security/Asset/screenshots/update_list.jpeg mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/.gitignore mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/AuthenticationDomainAccount.ets mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/ManageDomainAccounts.ets mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/ets/util/CommonButton.ets mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/ohosTest.md mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_1.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_10.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_11.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_12.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_2.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_3.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_4.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_5.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_6.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_7.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_8.png mode change 100755 => 100644 code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_9.png mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/.gitignore mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/ohosTest.md mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_1.png mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_2.png mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_3.png mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_4.png mode change 100755 => 100644 code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_5.png mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/.gitignore mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/ohosTest.md mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_1.png mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_2.png mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_3.png mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_4.png mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_5.png mode change 100755 => 100644 code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_6.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/.gitignore mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/README.md mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/ohosTest.md mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_1.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_2.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_3.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_4.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_5.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_6.png mode change 100755 => 100644 code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_7.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/.gitignore mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/SystemAccount/ManageSystemAccounts.ets mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/SystemAccount/UseConstraintManagementSystemAccount.ets mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/ets/util/CommonButton.ets mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/ohosTest.md mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_1.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_10.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_11.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_2.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_3.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_4.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_5.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_6.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_7.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_8.png mode change 100755 => 100644 code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_9.png rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/README.md create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2 => ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/index.d.ts create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/Calc.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Calc.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/utils/Calc.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule => ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport}/entry/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/DynamicImport.test.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary => ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/Index.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har1/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/components/MainPage.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/utils/Calc.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar => ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/Index.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har2/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/components/MainPage.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/utils/Calc.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp => ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/Index.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/components/MainPage.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/utils/Calc.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry => ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/Index.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/ets/components/MainPage.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry => ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/Index.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/ets/utils/Calc.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry => ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/DynamicImport/screenshots/DynamicImport.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/README.md create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects => ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule}/entry/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/index.d.ts create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview => ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule}/entry/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/JsApisLoadNativeModule.test.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule3.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/README.md create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared => ArkTS/ArkTSRuntime/ArkTSModule/LazyImport}/entry/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A_ns.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/B.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/C.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/fail_example.ets (98%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/main.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/middle.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod1.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod2.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/LazyImport.test.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/screenshots/LazyImport1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/LazyImport/screenshots/LazyImport2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/README.md create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview => ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects}/entry/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/module.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleOptimize.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleUseGlobalVar.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/main.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/module.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleOptimize.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVar.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVarOptimize.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModule.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModuleOptimize.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/Index.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/module.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/moduleOptimize.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/a.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/b.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/main.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/modifyPrototype.ts (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/main.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/module.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModule.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModuleOptimize.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/CommonButton.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/resource.ets create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/ModuleLoadingSideEffects.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/screenshots/ModuleLoadingSideEffects.png (100%) mode change 100755 => 100644 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/README.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/CpuIntensiveTaskDevelopment.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/IoIntensiveTaskDevelopment.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/LongTimeTaskGuide.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/ResidentTaskGuide.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/SyncTaskDevelopment.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/write.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/util/CommonButton.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/util/resource.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/MyWorker1.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/MyWorker2.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/Worker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/handle.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/screenshots/ApplicationMultithreading_1.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/screenshots/ApplicationMultithreading_2.png rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/README.md create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects => ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared}/entry/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/SendableObjTest.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside => ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/screenshots/NativeInterthreadShared_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/screenshots/NativeInterthreadShared_2.png (100%) mode change 100755 => 100644 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/README.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/ConcurrentLoadingModulesGuide.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/Config.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/GlobalConfigurationGuide.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/MakeobservedSendable.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/Mock.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/SendableData.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/SharedValuesBucket.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/UsingSendable.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/UsingTaskPool.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/WaterFlowDataSource.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/WaterfallRendering.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/sdk/Calculator.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/sdk/TimerSdk.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/util/CommonButton.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/util/resource.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/screenshots/PracticalCases_1.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/screenshots/PracticalCases_2.png rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/README.md create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside => ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals => ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/screenshots/AsyncConcurrencyOverview_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/AsyncConcurrencyOverview/screenshots/AsyncConcurrencyOverview_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/README.md create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/ArrayBufferObject.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/NormalObject.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/SharedArrayBufferObject.ets (96%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/Test.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/TransferabledObject.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/pixelMapTest.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/CommonButton.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/resource.ets create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/screenshots/CommunicationObjects_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/screenshots/CommunicationObjects_2.png (100%) mode change 100755 => 100644 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/README.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/ets/achievenonability/AchievenonAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/oh-package.json5 delete mode 100755 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/ets/arrowfunctionsability/ArrowfunctionsAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/ets/cannotbeusedability/CannotbeusedAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/test/LocalUnit.test.ets rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/screenshots/RulesAndRestrictions_1.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/screenshots/RulesAndRestrictions_2.png rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/templatetypeability/TemplatetypeAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/typecannotability/TypecannotAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmDebug/runtimetask => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmDebug/runtimetask => ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/README.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/BuildProfile.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/consumer-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/ets/components/MainPage.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/managers/classusage.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/managers/functionusage.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/util/CommonButton.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/util/resource.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/screenshots/SendableObjectIntroduction_1.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/screenshots/SendableObjectIntroduction_2.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/README.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsAsyncLockIntroduction.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsCollectionsIntroduction.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsSendableModule.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/AsonParsingGeneration.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/SendableFreeze.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/helper.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/sharedModule.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/util/CommonButton.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/util/resource.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/workers/Worker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/screenshots/SendableObjectRelated_1.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/screenshots/SendableObjectRelated_2.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/README.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/pages/sendable.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/oh-package.json5 delete mode 100755 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/crossconcurrencyability/CrossconcurrencyAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/pages/sendable.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/screenshots/SendableScenarios_1.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/screenshots/SendableScenarios_2.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/README.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IconItemSource.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IndependentTask.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IndependentTimeConsumingTask.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/MultiTask.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/MultiTimeConsumingTasks.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/TaskSendDataUsage.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/WorkerCallGlobalUsage.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/WorkerCommunicatesWithMainthread.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/util/CommonButton.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/util/resource.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/workers/Worker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/screenshots/InterThreadCommunicationScenario_1.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/screenshots/InterThreadCommunicationScenario_2.png rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/README.md create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass => ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/pages/Index.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass => ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/mock/mock-config.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/screenshots/MultiThreadConcurrencyOverview_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/screenshots/MultiThreadConcurrencyOverview_2.png (100%) mode change 100755 => 100644 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/README.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/Test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/asynchronousfunctions.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/customclasses.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/generaluse.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/returnpromise.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/util/CommonButton.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/util/resource.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/screenshots/TaskPoolIntroduction_1.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/screenshots/TaskPoolIntroduction_2.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/README.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/basicusage.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/crosshar.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/notrecommendedone.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/notrecommendedtwo.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/recommend.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedoneworker/childworker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedoneworker/parentworker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedtwoworker/childworker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedtwoworker/parentworker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/recommendworkers/childworker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/recommendworkers/parentworker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/util/CommonButton.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/util/resource.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/workers/worker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/.gitignore mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/BuildProfile.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/Index.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/consumer-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/ets/components/MainPage.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/ets/workers/worker.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/screenshots/WorkerIntroduction_1.png mode change 100755 => 100644 code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/screenshots/WorkerIntroduction_2.png rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass => ArkTS/JSVMAPI/JsvmDebug}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/README.md rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance => ArkTS/JSVMAPI/JsvmDebug/aboutcodecache}/.gitignore (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly => ArkTS/JSVMAPI/JsvmDebug/aboutcodecache}/build-profile.json5 (100%) rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass => ArkTS/JSVMAPI/JsvmDebug/aboutcodecache}/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmDebug/runtimetask => ArkTS/JSVMAPI/JsvmDebug/aboutcodecache}/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/hello.cpp rename code/DocsSample/{ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask => ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache}/Index.d.ts (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/aboutcodecacheability/AboutcodecacheAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmDebug/runtimetask => ArkTS/JSVMAPI/JsvmDebug/aboutcodecache}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance => ArkTS/JSVMAPI/JsvmDebug/aboutcodecache}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/Ability.test.ets rename code/DocsSample/{ArkTs/JSVMAPI/JsvmDebug/runtimetask => ArkTS/JSVMAPI/JsvmDebug/aboutcodecache}/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/build-profile.json5 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass => ArkTS/JSVMAPI/JsvmDebug}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/ohosTest.md rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap => ArkTS/JSVMAPI/JsvmDebug/openinspector}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/build-profile.json5 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance => ArkTS/JSVMAPI/JsvmDebug/openinspector}/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass => ArkTS/JSVMAPI/JsvmDebug/openinspector}/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/hello.cpp rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly => ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry}/Index.d.ts (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass => ArkTS/JSVMAPI/JsvmDebug/openinspector}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap => ArkTS/JSVMAPI/JsvmDebug/openinspector}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/Ability.test.ets rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass => ArkTS/JSVMAPI/JsvmDebug/openinspector}/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise => ArkTS/JSVMAPI/JsvmDebug/runtimetask}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/build-profile.json5 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap => ArkTS/JSVMAPI/JsvmDebug/runtimetask}/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance => ArkTS/JSVMAPI/JsvmDebug/runtimetask}/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/Index.d.ts rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/oh-package.json5 (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/runtimetaskability/RuntimetaskAbility.ets (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/float.json (100%) rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance => ArkTS/JSVMAPI/JsvmDebug/runtimetask}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise => ArkTS/JSVMAPI/JsvmDebug/runtimetask}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance => ArkTS/JSVMAPI/JsvmDebug/runtimetask}/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/screenshots/JsvmDebug_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/screenshots/JsvmDebug_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject => ArkTS/JSVMAPI/JsvmDebug/snapshot}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/hvigorfile.ts rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap => ArkTS/JSVMAPI/JsvmDebug/snapshot}/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/snapshot/src/main/ets/snapshotability/SnapshotAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap => ArkTS/JSVMAPI/JsvmDebug/snapshot}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject => ArkTS/JSVMAPI/JsvmDebug/snapshot}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/Ability.test.ets rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap => ArkTS/JSVMAPI/JsvmDebug/snapshot}/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise => ArkTS/JSVMAPI/JsvmProcess}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmProcess/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/build-profile.json5 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise => ArkTS/JSVMAPI/JsvmProcess}/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop => ArkTS/JSVMAPI/JsvmProcess/entry}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/build-profile.json5 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise => ArkTS/JSVMAPI/JsvmProcess/entry}/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise => ArkTS/JSVMAPI/JsvmProcess/entry}/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise => ArkTS/JSVMAPI/JsvmProcess/entry}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop => ArkTS/JSVMAPI/JsvmProcess/entry}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/en_US/element/string.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/zh_CN/element/string.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/Ability.test.ets rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise => ArkTS/JSVMAPI/JsvmProcess/entry}/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass => ArkTS/JSVMAPI/JsvmProcess}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmProcess/screenshots/JsvmProcess_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmProcess/screenshots/JsvmProcess_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray}/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray}/.gitignore (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/build-profile.json5 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray}/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray}/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray}/src/main/resources/base/profile/main_pages.json (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/Ability.test.ets rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray}/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength}/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength}/obfuscation-rules.txt (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/createarraywithlengthability/CreatearraywithlengthAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/Ability.test.ets rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength}/src/ohosTest/ets/test/List.test.ets (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview}/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview}/obfuscation-rules.txt (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/createdataviewability/CreatedataviewAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview}/src/main/resources/base/media/layered_image.json (100%) rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/Ability.test.ets rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1 => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview}/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/createtypedarrayability/CreatetypedarrayAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/Ability.test.ets rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2 => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray}/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1 => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/deleteelementability/DeleteelementAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/Ability.test.ets rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement}/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2 => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/getarraylengthability/GetarraylengthAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/getdataviewinfoability/GetdataviewinfoAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/getelementability/GetelementAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/gettypedarrayinfoability/GettypedarrayinfoAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/haselementability/HaselementAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray}/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/isarrayability/IsarrayAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/isdataviewability/IsdataviewAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/istypedarrayability/IstypedarrayAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/screenshots/JsvmAboutArray_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/screenshots/JsvmAboutArray_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/setelementability/SetelementAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer}/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/createarraybufferability/CreatearraybufferAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer}/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/isarraybufferability/IsarraybufferAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/isdetachedarraybufferability/IsdetachedarraybufferAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/screenshots/JsvmAboutArraybuffer_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/screenshots/JsvmAboutArraybuffer_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint}/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/createbigintint64ability/Createbigintint64Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/createbigintuint64ability/Createbigintuint64Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/createbigintwordsability/CreatebigintwordsAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/getvaluebigintint64ability/Getvaluebigintint64Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/getvaluebigintuint64ability/Getvaluebigintuint64Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/backup_config.json rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords}/src/main/resources/base/profile/main_pages.json (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/screenshots/JsvmAboutBigint_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/screenshots/JsvmAboutBigint_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass}/code-linter.json5 (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/defineclassability/DefineclassAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/profile/main_pages.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass}/hvigorfile.ts (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance}/src/main/resources/base/media/layered_image.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/ohosTest.md rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/removewrapability/RemovewrapAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/profile/main_pages.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/screenshots/JsvmAboutClass_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/screenshots/JsvmAboutClass_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArray => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArray => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/getdatevalueability/GetdatevalueAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/isdateability/IsdateAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/screenshots/JsvmAboutDate_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/screenshots/JsvmAboutDate_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/checkobjecttypetagability/CheckobjecttypetagAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/createexternalability/CreateexternalAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/createobjectability/CreateobjectAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/createsymbolability/CreatesymbolAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/getvalueexternalability/GetvalueexternalAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArray => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/instanceofability/InstanceofAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/objectfreezeability/ObjectfreezeAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/objectsealability/ObjectsealAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/screenshots/JsvmAboutObject_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/screenshots/JsvmAboutObject_2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/symbolforability/SymbolforAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/typeofability/TypeofAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/coercetonumberability/CoercetonumberAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/coercetoobjectability/CoercetoobjectAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/coercetostringability/CoercetostringAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/getbooleanability/GetbooleanAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/getglobalability/GetglobalAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/getnullability/GetnullAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/getundefinedability/GetundefinedAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/getvalueboolability/GetvalueboolAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/screenshots/JsvmAboutPrimitive_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/screenshots/JsvmAboutPrimitive_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ohosTest.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/resolverejectability/ResolverejectAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/profile/main_pages.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/screenshots/JsvmAboutPromise_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/screenshots/JsvmAboutPromise_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/definepropertiesability/DefinepropertiesAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/deletepropertyability/DeletepropertyAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/getallpropertynamesability/GetallpropertynamesAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/getnamedpropertyability/GetnamedpropertyAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/getpropertyability/GetpropertyAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/hasnamedpropertyability/HasnamedpropertyAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/hasownpropertyability/HasownpropertyAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/haspropertyability/HaspropertyAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/screenshots/JsvmAboutProperty_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/screenshots/JsvmAboutProperty_2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/setnamedpropertyability/SetnamedpropertyAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/setpropertyability/SetpropertyAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIClass => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIClass => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/createstringlatin1ability/Createstringlatin1Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/createstringutf16ability/Createstringutf16Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/createstringutf8ability/Createstringutf8Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/getvaluestringlatin1ability/Getvaluestringlatin1Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/getvaluestringutf16ability/Getvaluestringutf16Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/screenshots/JsvmAboutString_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmAboutString/screenshots/JsvmAboutString_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/createdoubleability/CreatedoubleAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble}/src/main/resources/base/element/float.json (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/createint32ability/Createint32Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/float.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/createint64ability/Createint64Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/float.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/createuint32ability/Createuint32Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/float.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/getvaluedoubleability/GetvaluedoubleAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/float.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/getvalueint32ability/Getvalueint32Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/float.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/getvalueint64ability/Getvalueint64Ability.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/float.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32ability/Getvalueuint32Ability.ets (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32backupability/Getvalueuint32BackupAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/float.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIClass => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/screenshots/JsvmBasicDataTypes_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/screenshots/JsvmBasicDataTypes_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIDate => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/createrangeerrorability/CreaterangeerrorAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/createsyntaxerrorability/CreatesyntaxerrorAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/createtypeerrorability/CreateTypeErrorAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/getandclearlastexceptionability/GetandclearlastexceptionAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/getlasterrorinfoability/GetlasterrorInfoAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/iserrorability/IserrorAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/isexceptionpendingability/IsexceptionpendingAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/screenshots/JsvmError_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/screenshots/JsvmError_2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/throwerrorability/ThrowerrorAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/throwrangeerrorability/ThrowrangeerrorAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/throwsyntaxerrorability/ThrowsyntaxerrorAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/throwtypeerrorability/ThrowtypeerrorAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/addfinalizerability/AddfinalizerAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIDate => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIDate => ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/ohosTest.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/openescapablehandlescopeability/OpenescapablehandlescopeAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/referencerefability/ReferencerefAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/screenshots/JsvmLifeCycle_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/screenshots/JsvmLifeCycle_2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIError => ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/aboutjsonability/AboutjsonAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle => ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/functioncallability/FunctioncallAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle => ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/ohosTest.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pumpmessageloopability/PumpmessageloopAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/profile/main_pages.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/screenshots/UsageInstructionsOne_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/screenshots/UsageInstructionsOne_2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/hvigorfile.ts (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/obfuscation-rules.txt rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/oh-package.json5 (100%) rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/CMakeLists.txt (100%) rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/hello.cpp (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/Index.d.ts rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/oh-package.json5 (100%) rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/ets/pages/Index.ets (100%) rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/ets/webassemblyability/WebassemblyAbility.ets (100%) rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/module.json5 (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/float.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/string.json (100%) rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/background.png (100%) rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/foreground.png (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/startIcon.png (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/profile/main_pages.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/Ability.test.ets (100%) create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/List.test.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/module.json5 (100%) rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities => ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/README.md create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/adjustexternalmemoryability/AdjustexternalmemoryAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIError => ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/getheapstatisticsability/GetheapstatisticsAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/getversionability/GetversionAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/dark/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIError => ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/oh-package.json5 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/memorypressurenotificationability/MemorypressurenotificationAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/screenshots/UsageInstructionsTwo_1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/screenshots/UsageInstructionsTwo_2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/.gitignore create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/obfuscation-rules.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/hello.cpp create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/Index.d.ts create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/strictequalsability/StrictequalsAbility.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/color.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/Ability.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/CMakeLists.txt rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/callback.cpp (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/NodeAPIAsynchronousTask.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/screenshots/NodeAPIAsynchronousTask1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/screenshots/NodeAPIAsynchronousTask2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario}/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/napi_init.cpp rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases => ArkTS/NodeAPI/NodeAPIClassicUseCases}/NodeApiApplicationScenario/entry/src/main/cpp/thread_safety.cpp (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases => ArkTS/NodeAPI/NodeAPIClassicUseCases}/NodeApiApplicationScenario/entry/src/main/ets/pages/ObjectUtils.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases => ArkTS/NodeAPI/NodeAPIClassicUseCases}/NodeApiApplicationScenario/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario}/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario}/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario}/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases => ArkTS/NodeAPI/NodeAPIClassicUseCases}/NodeApiApplicationScenario/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases => ArkTS/NodeAPI/NodeAPIClassicUseCases}/NodeApiApplicationScenario/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario}/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases => ArkTS/NodeAPI/NodeAPIClassicUseCases}/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases => ArkTS/NodeAPI/NodeAPIClassicUseCases}/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/NodeApiApplicationScenario.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario}/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario}/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/ohosTest.md rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases => ArkTS/NodeAPI/NodeAPIClassicUseCases}/NodeApiApplicationScenario/screenshots/NodeApiApplicationScenario1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases => ArkTS/NodeAPI/NodeAPIClassicUseCases}/NodeApiApplicationScenario/screenshots/NodeApiApplicationScenario2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIObject => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule}/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/file.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/Test.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule}/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule}/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule}/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule}/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/NodeApiLoadModule.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule}/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule}/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/screenshots/NodeApiLoadModule1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/screenshots/NodeApiLoadModule2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo}/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIObject => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/CMakeLists.txt rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/api.cpp (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/file.cpp rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/har_name.cpp (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/napi_init.cpp rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/remote_har.cpp (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/Test.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo}/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo}/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo}/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1 => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry}/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/NodeApiLoadModuleWithInfo.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1 => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry}/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1 => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry}/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/ets/components/MainPage.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2 => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1}/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2 => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1}/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2 => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1}/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/ets/components/MainPage.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2}/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2}/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2}/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIObject => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/build-profile.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/ets/components/MainPage.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library}/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/ets/test/List.test.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library}/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry => ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library}/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/screenshots/NodeApiLoadModuleWithInfo1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/screenshots/NodeApiLoadModuleWithInfo2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise => ArkTS/NodeAPI/NodeApiUse/NodeAPIArray}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive => ArkTS/NodeAPI/NodeApiUse/NodeAPIArray}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/NodeAPIArray.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive => ArkTS/NodeAPI/NodeApiUse/NodeAPIArray}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/screenshots/NodeAPIArray1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArray/screenshots/NodeAPIArray2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty => ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise => ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/NodeAPIArraybuffer.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise => ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/screenshots/NodeAPIArraybuffer1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIArraybuffer/screenshots/NodeAPIArraybuffer2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations => ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty => ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/NodeAPIBasicDataTypes.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty => ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/screenshots/NodeAPIBasicDataTypes1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/screenshots/NodeAPIBasicDataTypes2.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiString => ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint}/.gitignore (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations => ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/NodeAPIBigint.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations => ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/screenshots/NodeAPIBigint1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBigint/screenshots/NodeAPIBigint2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/build-profile.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiString => ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer}/code-linter.json5 (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/NodeAPIBuffer.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigor/hvigor-config.json5 rename code/DocsSample/{ArkTs/NodeAPI/NodeApiUse/NodeApiString => ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer}/hvigorfile.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/screenshots/NodeAPIBuffer1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIBuffer/screenshots/NodeAPIBuffer2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/NodeAPIClass.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/screenshots/NodeAPIClass1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIClass/screenshots/NodeAPIClass2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/workers/worker.ts (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/NodeAPICleanuphook.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/screenshots/NodeAPICleanuphook1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPICleanuphook/screenshots/NodeAPICleanuphook2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/NodeAPIDate.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/screenshots/NodeAPIDate1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIDate/screenshots/NodeAPIDate2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/NodeAPIEnvironmentalLifeCycle.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/screenshots/NodeAPIEnvironmentalLifeCycle1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/screenshots/NodeAPIEnvironmentalLifeCycle2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/NodeAPIError.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/screenshots/NodeAPIError1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIError/screenshots/NodeAPIError2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/rawfile/test.abc (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/NodeAPIExtendCapabilities.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/screenshots/NodeAPIExtendCapabilities1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/screenshots/NodeAPIExtendCapabilities2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/NodeAPIFunction.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/screenshots/NodeAPIFunction1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIFunction/screenshots/NodeAPIFunction2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/NodeAPILifeCycle.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/screenshots/NodeAPILifeCycle1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPILifeCycle/screenshots/NodeAPILifeCycle2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/napiGetPrototype.ts (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/NodeAPIObject.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/screenshots/NodeAPIObject1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIObject/screenshots/NodeAPIObject2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/NodeAPIPrimitive.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/screenshots/NodeAPIPrimitive1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPrimitive/screenshots/NodeAPIPrimitive2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/NodeAPIPromise.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/screenshots/NodeAPIPromise1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIPromise/screenshots/NodeAPIPromise2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/Index.ets rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiDeleteProperty.ts (97%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiHasOwnProperty.ts (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/NodeAPIProperty.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/screenshots/NodeAPIProperty1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeAPIProperty/screenshots/NodeAPIProperty2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/NodeApiCustomAsynchronousOperations.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/screenshots/NodeApiCustomAsynchronousOperations1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/screenshots/NodeApiCustomAsynchronousOperations2.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/AppScope/app.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/element/string.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/media/app_icon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/README.md create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/code-linter.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/.gitignore create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/build-profile.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/CMakeLists.txt create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/napi_init.cpp create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/Index.d.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/pages/Index.ets create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/module.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/background.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/foreground.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/layered_image.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/startIcon.png (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/backup_config.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/main_pages.json create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/dark/element/color.json rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/en_US/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/zh_CN/element/string.json (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/Ability.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/NodeApiString.test.ets (97%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/module.json5 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/test/List.test.ets (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/entry/src/test/LocalUnit.test.ets (100%) mode change 100755 => 100644 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/hvigor/hvigor-config.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/hvigorfile.ts create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/oh-package.json5 create mode 100644 code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/ohosTest.md rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/screenshots/NodeApiString1.png (100%) mode change 100755 => 100644 rename code/DocsSample/{ArkTs => ArkTS}/NodeAPI/NodeApiUse/NodeApiString/screenshots/NodeApiString2.png (100%) mode change 100755 => 100644 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/README.md delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/index.d.ts delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/Calc.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Calc.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/utils/Calc.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/Index.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/components/MainPage.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/utils/Calc.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/Index.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/components/MainPage.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/utils/Calc.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/Index.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/components/MainPage.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/utils/Calc.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/Index.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/ets/components/MainPage.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/Index.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/README.md delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/index.d.ts delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/README.md delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/README.md delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/module.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleOptimize.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/module.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleOptimize.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/module.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/moduleOptimize.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/module.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/resource.ets delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/README.md delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/README.md delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/README.md delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/Test.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/resource.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/ets/objectliteralsability/ObjectliteralsAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/README.md delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/en_US/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/zh_CN/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/float.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/float.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/float.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/float.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/float.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/float.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/float.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/float.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/README.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/code-linter.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/.gitignore delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/hvigorfile.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/obfuscation-rules.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/hello.cpp delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/layered_image.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/profile/main_pages.json delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/Ability.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/List.test.ets delete mode 100755 code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/file.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/Test.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/file.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/Test.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/ets/components/MainPage.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/ets/components/MainPage.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/ets/components/MainPage.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/ohosTest.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/AppScope/app.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/element/string.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/README.md delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/build-profile.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/CMakeLists.txt delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/napi_init.cpp delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/Index.d.ts delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entryability/EntryAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/pages/Index.ets delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/backup_config.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/dark/element/color.json delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/module.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/hvigor/hvigor-config.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/oh-package.json5 delete mode 100755 code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ArkWebSchemeHandler/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/LifecycleWebComp/screenshots/LifecycleWebComp.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/js/script.js mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/AddIntTrackPreventByPassList.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/ClearIntTrackPreventByPassList.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/CollectingAdsBlockingInformation.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/EnableIntTrackPrevent.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/IsIntTrackPreventEnabled.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/OnIntTrackPreventResult.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/RemoveIntTrackPreventByPassList.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ListenForPageDown.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/UploadFiles.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/local.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/ListenForPageDown_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/ListenForPageDown_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/ResumeDownload.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/UploadFiles_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/UploadFiles_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/ImpNestedScroll.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/SetSKBMode_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/rawfile/SetSKBModeIndex.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2ability/Entry2Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/ImpNestedScroll.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/OnIntKbdAttachSysCustIn.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_one_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_one_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_two_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_two_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/entry1ability/Entry1Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/entry2ability/Entry2Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Prefetching.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_three.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/entry3ability/Entry3Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/BusinessWebview.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/DynamicComponent.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileConfig.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileWebview.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/BusinessWebview.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/DynamicComponent.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/InjectWebview.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Resource.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/InjOffResNoInt_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/InjOffResNoInt_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrecompForCompCache_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrecompForCompCache_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/Prefetching.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_three.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_one_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_one_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_two_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_two_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/rawfile/index1.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/rawfile/index2.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/GlobalContext.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local1.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/CrossApplicationRedirection.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/HistoryNavigati.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/PageRedirection.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/ProfilePage.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/call.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/route.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/hello.cpp mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.cpp mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.h mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_bypassing.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_script.js mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated_script.js mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local_script.js mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/sw.js mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.mp4 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/xhr mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/Libentry.mock.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2ability/Entry2Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/entry3ability/Entry3Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/common.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintAppAPI.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintW3CAPI.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/rawfile/test.pdf mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/CalcAdjustSafeArea.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/InitiatePrintAppAPI.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/InitiatePrintW3CAPI.png mode change 100755 => 100644 code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/PreviewPDF.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/AllowGeolocation.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ClearAllCookiesSync.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ConfigCookieSync.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteAllData.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteGeolocation.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ExistCookie.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/FetchCookieSync.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/GetAccessibleGeolocation.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ManageLocPerms.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/OpenPageNewWin.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/darkModePage.html mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/getLocation.html mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/window.html mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/AllowGeolocation.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ClearAllCookiesSync.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ConfigCookieSync.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DarkMode_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DarkMode_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DeleteAllData.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DeleteGeolocation.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ExistCookie.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/FetchCookieSync.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/GetAccessibleGeolocation.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/IncognitoMode_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/IncognitoMode_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ManageLocPerms_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ManageLocPerms_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/OpenPageNewWin_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/OpenPageNewWin_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Cache_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Cache_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/CookieManagement.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/DomStorage.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UseMotionDirSensor.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UserAgent_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UserAgent_three.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UserAgent_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/Cache_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/Cache_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/CookieManagement.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/DomStorage.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UseMotionDirSensor_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UseMotionDirSensor_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UserAgent_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UserAgent_three.png mode change 100755 => 100644 code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UserAgent_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/entry2ability/Entry2Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/JavaScriptProxy.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/RegisterJavaScriptProxy.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_five.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_four.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_three.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index1.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index2.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index3.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index4.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index5.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index6.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index7.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index8.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index9.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/ets/entry3ability/Entry3Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/hello.cpp mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.cpp mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.h mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/Index.d.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/ets/entry4ability/Entry4Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/rawfile/runJS.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/mock/Libentry4.mock.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/hello.cpp mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/types/libentry5/Index.d.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/types/libentry5/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/ets/entry5ability/Entry5Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/mock/Libentry5.mock.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/AppCallFrontendFn_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/AppCallFrontendFn_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/AppCallFrontendFn_3.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannelC_C_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannelC_C_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannel_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannel_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannel_3.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/JavaScriptProxy_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/JavaScriptProxy_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/MutualInvokeCCpp.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/Promise_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/Promise_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/RegisterJavaScriptProxy_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/RegisterJavaScriptProxy_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_five.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_four.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_three.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/entry1ability/Entry1Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/common.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/index2.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/entry2ability/Entry2Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/common.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/index2.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/CreatingOfflineWebComponents.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_one_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_one_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_two_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_two_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/DrawXCompAVPBtn.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/PlayerDemo.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/RenderTxtBoxSameLayer_one.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/RenderTxtBoxSameLayer_two.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test1.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test2.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test3.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/screenshots/DrawXCompAVPBtn.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/screenshots/RenderTxtBoxSameLayer_one.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UseSameLayerRender/screenshots/RenderTxtBoxSameLayer_two.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/rawfile/index.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/PlayerDemo.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/rawfile/main.html mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/HoldVideoConfWebRTC_1.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/HoldVideoConfWebRTC_2.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/HoldVideoConfWebRTC_3.png mode change 100755 => 100644 code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/TakeOverMediaPlay.png mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/README.md mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/code-linter.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/.gitignore mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/obfuscation-rules.txt mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/FitPageContent.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/RenderMode.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/rawfile/fit_content.html mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/oh-package.json5 mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/ohosTest.md mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/screenshots/FitPageContent.png mode change 100755 => 100644 code/DocsSample/ArkWeb/WebRenderLayout/screenshots/RenderModeWebComp.png mode change 100755 => 100644 code/DocsSample/ConnectivityKit/NFC/HCECardSimulationDevelopment/ohosTest.md mode change 100755 => 100644 code/DocsSample/ConnectivityKit/NFC/HCECardSimulationDevelopment/screenshots/image.jpeg mode change 100755 => 100644 code/DocsSample/ConnectivityKit/NFC/NFCReadAndWrite/ohosTest.md mode change 100755 => 100644 code/DocsSample/ConnectivityKit/NFC/NFCReadAndWrite/screenshots/image.jpeg mode change 100755 => 100644 code/DocsSample/ConnectivityKit/NFC/SecureElement/ohosTest.md mode change 100755 => 100644 code/DocsSample/ConnectivityKit/NFC/SecureElement/screenshots/image.jpeg mode change 100755 => 100644 code/DocsSample/ConnectivityKit/Wlan/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/.gitignore mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/README.md mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/AssetStoreArkTS.test.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/screenshots/AssetStoreArkTS1.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/screenshots/AssetStoreArkTS2.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/.gitignore mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/README.md mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/AssetStoreNdk.test.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/screenshots/AssetStoreNdk1.png mode change 100755 => 100644 code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/screenshots/AssetStoreNdk2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/project/3des_ecb_encryption_decryption.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/project/file.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidance3DES.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/screenshots/EncryptionDecryptionGuidance3DES1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/screenshots/EncryptionDecryptionGuidance3DES2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_cbc_encryption_decryption.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_ccm_encryption_decryption.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_ecb_encryption_decryption.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_gcm_encryption_decryption.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_gcm_segment_encryption_decryption.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/file.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceAes.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/screenshots/EncryptionDecryptionGuidanceAes1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/screenshots/EncryptionDecryptionGuidanceAes2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_cbc_encryption_decryption/aes_cbc_encryption_decryption_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_cbc_encryption_decryption/aes_cbc_encryption_decryption_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ccm_encryption_decryption/aes_ccm_encryption_decryption_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ccm_encryption_decryption/aes_ccm_encryption_decryption_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ecb_encryption_decryption/aes_ecb_encryption_decryption_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ecb_encryption_decryption/aes_ecb_encryption_decryption_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_encryption_decryption/aes_gcm_encryption_decryption_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_encryption_decryption/aes_gcm_encryption_decryption_synchronous.ets delete mode 100755 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_seg_encryption_decryption/aes_gcm_seg_encryption_decryption_asynchronous.ets delete mode 100755 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_seg_encryption_decryption/aes_gcm_seg_encryption_decryption_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceAesArkTs.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/screenshots/EncryptionDecryptionGuidanceAesArkTs1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/screenshots/EncryptionDecryptionGuidanceAesArkTs2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Async.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1_oaep/RSAPKCS1OAEPAsync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1_oaep/RSAPKCS1OAEPSync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_segmentation/RSASegmentationAsync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_segmentation/RSASegmentationSync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceRSA.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/screenshots/EncryptionDecryptionGuidanceRSA1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/screenshots/EncryptionDecryptionGuidanceRSA2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/CreateASN.1Ciphertext.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/ObtainCiphertext.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/SM2EncryptionDecryptionAsync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/SM2EncryptionDecryptionSync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceSM2.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/screenshots/EncryptionDecryptionGuidanceSM21.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/screenshots/EncryptionDecryptionGuidanceSM22.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/file.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_cbc_encryption_decryption.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_ecb_encryption_decryption.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_gcm_encryption_decryption.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_gcm_seg_encryption_decryption.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceSM4.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/screenshots/EncryptionDecryptionGuidanceSM41.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/screenshots/EncryptionDecryptionGuidanceSM42.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_cbc_encryption_decryption/sm4_cbc_encryption_decryption_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_cbc_encryption_decryption/sm4_cbc_encryption_decryption_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_ecb_encryption_decryption/sm4_ecb_encryption_decryption_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_ecb_encryption_decryption/sm4_ecb_encryption_decryption_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_synchronous.ets delete mode 100755 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_seg_encryption_decryption/sm4_gcm_seg_encryption_decryption_asynchronous.ets delete mode 100755 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_seg_encryption_decryption/sm4_gcm_seg_encryption_decryption_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidance3DESArkTs.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/screenshots/EncryptionDecryptionGuidanceSM4ArkTs1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/screenshots/EncryptionDecryptionGuidanceSM4ArkTs2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Await.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Promise.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/HKDFDerivation.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/screenshots/HKDFDerivation1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/screenshots/HKDFDerivation2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Await.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Promise.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/PBKDF2Derivation.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/screenshots/PBKDF2Derivation1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/screenshots/PBKDF2Derivation2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/ecc.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/sm2.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/BinaryDataConvertAsymmetricKeyPair.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/screenshots/BinaryDataConvertAsymmetricKeyPair1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/screenshots/BinaryDataConvertAsymmetricKeyPair2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/ecc/Callback.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/ecc/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/pkcs8ecc/PKCS8ECC.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Callback.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Callback.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/BinaryDataConvertAsymmetricKeyPairArkTS.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/screenshots/BinaryDataConvertAsymmetricKeyPairArkTS1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/screenshots/BinaryDataConvertAsymmetricKeyPairArkTS2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Promise.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/ConvertSpecifiedPEMAsymmetricKeyPair.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/screenshots/ConvertSpecifiedPEMAsymmetricKeyPair1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/screenshots/ConvertSpecifiedPEMAsymmetricKeyPair2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/3des.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/file.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/hmac.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/ConvertSymmetricKeyBinaryFormat.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/screenshots/ConvertSymmetricKeyBinaryFormat1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/screenshots/ConvertSymmetricKeyBinaryFormat2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/3des/Callback.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/3des/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/hmac/Await.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/hmac/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/ConvertSymmetricKeyBinaryFormatArkTS.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/screenshots/ConvertSymmetricKeyBinaryFormatArkTS1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/screenshots/ConvertSymmetricKeyBinaryFormatArkTS2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/project/file.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/project/specifyUncompressedPublicKey.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/CompressedPointData.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/GetKeyObject.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/SpecifyUncompressedPublicKey.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/ECCCompressPublicKeyFormatConversion.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/screenshots/ECCCompressPublicKeyFormatConversion1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/screenshots/ECCCompressPublicKeyFormatConversion2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/sm2.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/RandomlyGenerateAsymmetricKeyPair.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/screenshots/RandomlyGenerateAsymmetricKeyPair1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/screenshots/RandomlyGenerateAsymmetricKeyPair2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Promise.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Promise.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/RandomlyGenerateAsymmetricKeyPairArkTS.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/screenshots/RandomlyGenerateAsymmetricKeyPairArkTS1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/screenshots/RandomlyGenerateAsymmetricKeyPairArkTS2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/aes.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/file.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/sm4.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/RandomlyGenerateSymmetricKey.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/screenshots/RandomlyGenerateSymmetricKey1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/screenshots/RandomlyGenerateSymmetricKey2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/aes/Promise.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/aes/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/sm4/Promise.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/sm4/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/RandomlyGenerateSymmetricKeyArkTS.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/screenshots/RandomlyGenerateSymmetricKeyArkTS1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/screenshots/RandomlyGenerateSymmetricKeyArkTS2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/ecc/Promise.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/ecc/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/rsa/Callback.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/rsa/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/sm2/Promise.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/sm2/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/SpecifiedParametersGenerateAsymmetricKeyPair.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/screenshots/SpecifiedParametersGenerateAsymmetricKeyPair1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/screenshots/SpecifiedParametersGenerateAsymmetricKeyPair2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHAsync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHSync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHAsync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHSync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Async.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/KeyNegotiation.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/screenshots/KeyNegotiation1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/screenshots/KeyNegotiation2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Async.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Async.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Sync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/MessageAuthenticationCode.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/screenshots/MessageAuthenticationCode1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/screenshots/MessageAuthenticationCode2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/file.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/segmentation.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/singleTime.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationAsync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationSync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeAsync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeSync.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/MessageDigestComputation.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/screenshots/MessageDigestComputation1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/screenshots/MessageDigestComputation2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/SecureRandomNumberGeneration.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/screenshots/SecureRandomNumberGeneration1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/screenshots/SecureRandomNumberGeneration2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/ecdsa_signature_verification.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_segment_signature.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_signature_restoration.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_signature_validator.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pss_verification_tool.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/signing_signature_verification.h mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/sm2_signature_verification.cpp mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/SigningSignatureVerification.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/screenshots/SigningSignatureVerification1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/screenshots/SigningSignatureVerification2.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/README.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_segment_signature/rsa_pkcs1_segment_signature_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_segment_signature/rsa_pkcs1_segment_signature_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_restoration/rsa_pkcs1_signature_restoration_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_restoration/rsa_pkcs1_signature_restoration_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_validator/rsa_pkcs1_signature_validator_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_validator/rsa_pkcs1_signature_validator_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pss_signature_verification/rsa_pss_signature_verification_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pss_signature_verification/rsa_pss_signature_verification_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_asynchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_synchronous.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/mock/mock-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/SigningSignatureVerificationArkTs.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/screenshots/SigningSignatureVerificationArkTs1.png mode change 100755 => 100644 code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/screenshots/SigningSignatureVerificationArkTs2.png mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/.gitignore mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/README.md mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/DataProtection.test.ets mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/DataProtectionKit/DataProtection/screenshots/DataProtection.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/.gitignore mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/README.md mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateGetCertCrlObject.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertObject.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertextensionObject.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCrlObject.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateTrustanchorFromP12.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCerchainvalidatorObject.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCertchainObject.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/CertificateAlgorithmLibrary.test.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/screenshots/CertificateAlgorithmLibrary1.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/screenshots/CertificateAlgorithmLibrary2.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/.gitignore mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/README.md mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/CertificateManagement.test.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement1.png mode change 100755 => 100644 code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/KeyDeletion.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/Index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/GenerateKey.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/ImportEncryptedKey.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/ImportKeyPlainText.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/AnonymousKeyProof.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/NonAnonymousKeyProof.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/float.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/AccessControl.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/EncryptionDecryption.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/Cpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/HMAC.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/KeyDerivation.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/KeyExchange.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/SigningVerification.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2561.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2562.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2561.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2562.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM21.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM22.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/CheckKeyExists.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/GetKeyAttributes.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/KeyExport.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/LocalUnit.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/ohosTest.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_1.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_2.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/app.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/README.md mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/code-linter.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/.gitignore mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/build-profile.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/CMakeLists.txt mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/napi_init.cpp mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/index.d.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entryability/EntryAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/QueryKeyAliasSet.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/background.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/foreground.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/layered_image.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/startIcon.png mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/backup_config.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/dark/element/color.json mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/QueryKeyAliasSet.test.ets mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigorfile.ts mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/oh-package.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/ohosTest.md delete mode 100644 code/Solutions/InputMethod/KikaInput/build-profile.json5 mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/BiometricAuthentication.ets mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFill/entry/src/main/resources/base/media/arrow.svg mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFill/entry/src/main/resources/base/media/svg.png mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFill/screenshots/autoFillControl.jpg mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFill/screenshots/biometricauthentication.jpg mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/app.json5 mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/resources/base/element/string.json mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/resources/base/media/app_icon.png mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/README_zh.md mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/build-profile.json5 mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/build-profile.json5 mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/hvigorfile.ts mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/oh-package.json5 mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/application/ItemListData.ts mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillability/TextAutoFillAbility.ts mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/ReturnMainPage.ets mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/SavePage.ets mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/SelectorList.ets mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/entryability/EntryAbility.ts mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/pages/Index.ets mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/module.json5 mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/element/color.json mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/element/string.json mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/arrow.png mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/ic_public_back.svg mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/icon.png mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/style.png mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/profile/main_pages.json mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/en_US/element/string.json mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/zh_CN/element/string.json mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/test/Ability.test.ets mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/test/List.test.ets mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/testability/TestAbility.ets mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/testability/pages/Index.ets mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/module.json5 mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/element/color.json mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/element/string.json mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/media/icon.png mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/profile/test_pages.json mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/hvigor/hvigor-config.json5 mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/hvigor/hvigor-wrapper.js mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/hvigorfile.ts mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/hvigorw mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/hvigorw.bat mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/oh-package.json5 mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/ohosTest.md mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/Index.jpg mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/NameAssociation.jpg mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/ReturnMainPage.jpg mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/SavePage.jpg mode change 100755 => 100644 code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/SelectorList.jpg mode change 100755 => 100644 code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/informationPresentationAndDynamicEffects/listSample/ListSample.ets mode change 100755 => 100644 code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/navigation/navRouterSample/NavRouterSample.ets mode change 100755 => 100644 code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomClickEvent.ets mode change 100755 => 100644 code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomEventHome.ets mode change 100755 => 100644 code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomScrollingEvent.ets mode change 100755 => 100644 code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/safeAreaSample/ChangePanel.ets mode change 100755 => 100644 code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/safeAreaSample/SafeAreaSample.ets mode change 100755 => 100644 code/UI/ArkTsComponentCollection/ComponentCollection/screenshots/devices/general.jpeg delete mode 100644 code/UI/ArkTsComponentCollection/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSyncCode.ets diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Ability/AbilityFeature/AppScope/app.json5 b/code/BasicFeature/Ability/AbilityFeature/AppScope/app.json5 index 151a5d2ac9..0a2e1b209c 100644 --- a/code/BasicFeature/Ability/AbilityFeature/AppScope/app.json5 +++ b/code/BasicFeature/Ability/AbilityFeature/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.abilityFeature", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.abilityFeature", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Ability/AbilityFeature/AppScope/resources/base/element/string.json b/code/BasicFeature/Ability/AbilityFeature/AppScope/resources/base/element/string.json index 7f9e90ebc7..3c15b21f5a 100644 --- a/code/BasicFeature/Ability/AbilityFeature/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Ability/AbilityFeature/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AbilityFeature" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AbilityFeature" + } + ] +} diff --git a/code/BasicFeature/Ability/AbilityFeature/README_zh.md b/code/BasicFeature/Ability/AbilityFeature/README_zh.md index 42a50d6eeb..bc3e4ff2fc 100644 --- a/code/BasicFeature/Ability/AbilityFeature/README_zh.md +++ b/code/BasicFeature/Ability/AbilityFeature/README_zh.md @@ -1,98 +1,98 @@ -# 基础能力增强 - -### 介绍 - -本示例使用 [ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) ,[ohos.ability.wantConstant](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-ability-wantConstant.md) ,[ohos.app.ability.StartOptions](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-startOptions.md)等接口实现了以下功能: - -1. 支持应用定制系统环境参数; - -5. 支持隐式启动个数为0时才触发提示弹框--增加了一个flag; - -6. 支持应用清理自己的数据; - -7. Ability启动参数支持传递初始位置/初始大小/是否携带动效; - -### 效果预览 - -| 主页面 | 隐式启动弹窗 | 英文切换页 | 深色模式切换页 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | :--------------------------------------------------: | :--------------------------------------------------: | -| | | ![](./screenshots/Screenshot_20231208091638669.jpeg) | ![](./screenshots/Screenshot_20231208091619146.jpeg) | - -使用说明 - -1.应用切换语言的能力; - -点击'切换英文语言'的ListItem,当前页面切换为英文,标题'基础能力增强'切换成'Basic capabilities are enhanced' -,点击'切换中文语言'的ListItem,当前页面切换为中文,标题'Basic capabilities are enhanced'切换成'基础能力增强'; - -2.应用切换颜色模式的能力 - -点击'切换深色模式'的ListItem,当前页面颜色切换为深色,弹出Toast提示'切换成功',点击'切换浅色模式' -的ListItem,当前页面颜色切换为浅色,弹出Toast提示'切换成功'; - -3.应用隐式启动个数为0时,才触发提示弹框的特性 - -点击'隐式启动弹窗'的ListItem,弹出弹窗,弹窗标题为'未找到文件',点击'隐式启动不弹窗' -的ListItem,弹出Toast提示'隐式启动不弹窗',且无弹窗(仅支持rk); - -4.应用清理自己的数据的能力 - -点击'创建数据'的ListItem,弹出Toast提示创建'缓存文件成功',点击'检查数据'的ListItem,弹出Toast提示创建'查询到缓存文件' -,点击'清除数据'的ListItem,应用清理缓存文件后自动退出。手动重新启动应用后,点击'检查数据'的ListItem,弹出Toast提示创建'未找到缓存文件'; - -5.应用可以设置启动参数启动Ability能力 - -点击'StartOptions配置'的ListItem,应用启动NewAbility。返回主界面后,点击'启动动画'的Toggle,再点击' -StartOptions配置'的ListItem,应用启动NewAbility; - -### 工程目录 - -``` -entry/src/main/ets/ -|---characteroperation -| |---CharacterOperation.ets // 调用applicationContext方法的工具类 -|---entryability -| |---EntryAbility.ets // 首页的Ability -|---pages -| |---Index.ets // 首页 -| |---New.ets // 被启动UIAbility的展示页 -|---newability -| |---NewAbility.ets // 被启动的UIAbility(验证新接口启动使用) -|---utils // 工具 -| |---Logger.ets // 日志工具 -``` - -### 具体实现 - -- 应用切换语言的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用setLanguage(language: string): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets) -- 应用切换颜色模式的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用setColorMode(colorMode: ConfigurationConstant.ColorMode): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets) -- 应用清理自己的数据的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用clearUpApplicationData(callback: AsyncCallback): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets) -- 应用隐式启动个数为0时不触发提示弹框的特性,通过给Want的flags设置为FLAG_START_WITHOUT_TIPS,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) -- 应用可以设置启动参数启动Ability能力,通过给startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void;方法传递新增参数StartOptions来设置启动位置,大小以及是否包含动画,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) - -### 相关权限 - -无 - -### 依赖 - -无 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568; - -2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.5.1; - -3.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行; - -### 下载 - -```shell -git init -git config core.sparsecheckout true -echo code/BasicFeature/Ability/AbilityFeature/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` - +# 基础能力增强 + +### 介绍 + +本示例使用 [ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) ,[ohos.ability.wantConstant](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-ability-wantConstant.md) ,[ohos.app.ability.StartOptions](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-startOptions.md)等接口实现了以下功能: + +1. 支持应用定制系统环境参数; + +5. 支持隐式启动个数为0时才触发提示弹框--增加了一个flag; + +6. 支持应用清理自己的数据; + +7. Ability启动参数支持传递初始位置/初始大小/是否携带动效; + +### 效果预览 + +| 主页面 | 隐式启动弹窗 | 英文切换页 | 深色模式切换页 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | :--------------------------------------------------: | :--------------------------------------------------: | +| | | ![](./screenshots/Screenshot_20231208091638669.jpeg) | ![](./screenshots/Screenshot_20231208091619146.jpeg) | + +使用说明 + +1.应用切换语言的能力; + +点击'切换英文语言'的ListItem,当前页面切换为英文,标题'基础能力增强'切换成'Basic capabilities are enhanced' +,点击'切换中文语言'的ListItem,当前页面切换为中文,标题'Basic capabilities are enhanced'切换成'基础能力增强'; + +2.应用切换颜色模式的能力 + +点击'切换深色模式'的ListItem,当前页面颜色切换为深色,弹出Toast提示'切换成功',点击'切换浅色模式' +的ListItem,当前页面颜色切换为浅色,弹出Toast提示'切换成功'; + +3.应用隐式启动个数为0时,才触发提示弹框的特性 + +点击'隐式启动弹窗'的ListItem,弹出弹窗,弹窗标题为'未找到文件',点击'隐式启动不弹窗' +的ListItem,弹出Toast提示'隐式启动不弹窗',且无弹窗(仅支持rk); + +4.应用清理自己的数据的能力 + +点击'创建数据'的ListItem,弹出Toast提示创建'缓存文件成功',点击'检查数据'的ListItem,弹出Toast提示创建'查询到缓存文件' +,点击'清除数据'的ListItem,应用清理缓存文件后自动退出。手动重新启动应用后,点击'检查数据'的ListItem,弹出Toast提示创建'未找到缓存文件'; + +5.应用可以设置启动参数启动Ability能力 + +点击'StartOptions配置'的ListItem,应用启动NewAbility。返回主界面后,点击'启动动画'的Toggle,再点击' +StartOptions配置'的ListItem,应用启动NewAbility; + +### 工程目录 + +``` +entry/src/main/ets/ +|---characteroperation +| |---CharacterOperation.ets // 调用applicationContext方法的工具类 +|---entryability +| |---EntryAbility.ets // 首页的Ability +|---pages +| |---Index.ets // 首页 +| |---New.ets // 被启动UIAbility的展示页 +|---newability +| |---NewAbility.ets // 被启动的UIAbility(验证新接口启动使用) +|---utils // 工具 +| |---Logger.ets // 日志工具 +``` + +### 具体实现 + +- 应用切换语言的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用setLanguage(language: string): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets) +- 应用切换颜色模式的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用setColorMode(colorMode: ConfigurationConstant.ColorMode): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets) +- 应用清理自己的数据的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用clearUpApplicationData(callback: AsyncCallback): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets) +- 应用隐式启动个数为0时不触发提示弹框的特性,通过给Want的flags设置为FLAG_START_WITHOUT_TIPS,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) +- 应用可以设置启动参数启动Ability能力,通过给startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void;方法传递新增参数StartOptions来设置启动位置,大小以及是否包含动画,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) + +### 相关权限 + +无 + +### 依赖 + +无 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568; + +2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.5.1; + +3.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行; + +### 下载 + +```shell +git init +git config core.sparsecheckout true +echo code/BasicFeature/Ability/AbilityFeature/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` + diff --git a/code/BasicFeature/Ability/AbilityFeature/build-profile.json5 b/code/BasicFeature/Ability/AbilityFeature/build-profile.json5 index 6e4824ee32..51d43b29fe 100644 --- a/code/BasicFeature/Ability/AbilityFeature/build-profile.json5 +++ b/code/BasicFeature/Ability/AbilityFeature/build-profile.json5 @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/build-profile.json5 b/code/BasicFeature/Ability/AbilityFeature/entry/build-profile.json5 index 0c8525dfdd..910cc991f5 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/build-profile.json5 +++ b/code/BasicFeature/Ability/AbilityFeature/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/oh-package.json5 b/code/BasicFeature/Ability/AbilityFeature/entry/oh-package.json5 index 60744fdbc7..225946cb11 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/oh-package.json5 +++ b/code/BasicFeature/Ability/AbilityFeature/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/characteroperation/CharacterOperation.ets b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/characteroperation/CharacterOperation.ets index 9a5778e9e5..2907869790 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/characteroperation/CharacterOperation.ets +++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/characteroperation/CharacterOperation.ets @@ -1,146 +1,146 @@ -/* - * Copyright (c) 2023 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 ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; -import fs from '@ohos.file.fs'; -import prompt from '@ohos.promptAction'; -import { logger } from '../util/Logger'; - -const TAG: string = 'EntryAbility'; -const TIME: number = 3000; - -export default class CharacterOperation { - private context: Context; - - constructor(context: Context) { - this.context = context; - } - // 设置中文 - setZHCNLanguage = () => { - let applicationContext = this.context.getApplicationContext(); - applicationContext.setLanguage('zh-cn'); - logger.info(`${TAG} Chinese success`); - } - // 设置英文 - setENUSLanguage = () => { - let applicationContext = this.context.getApplicationContext(); - applicationContext.setLanguage('en-us'); - logger.info(`${TAG} English success`); - } - // 设置深色模式 - setDarKColorMode = () => { - let applicationContext = this.context.getApplicationContext(); - applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_DARK); - prompt.showToast({ - message: $r('app.string.switchDarkSuccess'), duration: TIME - }); - } - // 设置浅色模式 - setLightColorMode = () => { - let applicationContext = this.context.getApplicationContext(); - applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); - prompt.showToast({ - message: $r('app.string.switchLightSuccess'), duration: TIME - }); - } - // 获取缓存路径 - generateStorageFiles = () => { - let context = this.context; - let filePathName = '/test.txt'; - let cacheDirPath = context.cacheDir + filePathName; - let filesDirPath = context.filesDir + filePathName; - let preferencesDirPath = context.preferencesDir + filePathName; - let tempDirPath = context.tempDir + filePathName; - let databaseDirPath = context.databaseDir + filePathName; - - return [cacheDirPath, filesDirPath, preferencesDirPath, tempDirPath, databaseDirPath]; - } - // 创建存储数据 - createStorageData = () => { - let context = this.context; - let filePathName = '/test.txt'; - let cacheDirPath = context.cacheDir + filePathName; - let filesDirPath = context.filesDir + filePathName; - let preferencesDirPath = context.preferencesDir + filePathName; - let tempDirPath = context.tempDir + filePathName; - let databaseDirPath = context.databaseDir + filePathName; - try { - let file1 = fs.openSync(cacheDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); - let file2 = fs.openSync(filesDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); - let file3 = fs.openSync(preferencesDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); - let file4 = fs.openSync(tempDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); - let file5 = fs.openSync(databaseDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); - - fs.closeSync(file1); - fs.closeSync(file2); - fs.closeSync(file3); - fs.closeSync(file4); - fs.closeSync(file5); - - if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath) - && fs.accessSync(preferencesDirPath) && fs.accessSync(tempDirPath) - && fs.accessSync(databaseDirPath)) { - prompt.showToast({ - message: $r('app.string.create_File_Success'), duration: TIME - }); - } - } catch (error) { - } - } - // 检查文件 - checkStorageData = () => { - let context = this.context; - let filePathName = '/test.txt'; - let cacheDirPath = context.cacheDir + filePathName; - let filesDirPath = context.filesDir + filePathName; - let preferencesDirPath = context.preferencesDir + filePathName; - let tempDirPath = context.tempDir + filePathName; - let databaseDirPath = context.databaseDir + filePathName; - if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath) - && fs.accessSync(preferencesDirPath) && fs.accessSync(tempDirPath) && fs.accessSync(databaseDirPath)) { - prompt.showToast({ - message: $r('app.string.search_File_Success'), duration: TIME - }); - } else { - prompt.showToast({ - message: $r('app.string.search_File_Failed'), duration: TIME - }); - } - } - // 清理存储数据 - clearStorageData = () => { - let context = this.context; - let filePathName = '/test.txt'; - let cacheDirPath = context.cacheDir + filePathName; - let filesDirPath = context.filesDir + filePathName; - let preferencesDirPath = context.preferencesDir + filePathName; - let tempDirPath = context.tempDir + filePathName; - let databaseDirPath = context.databaseDir + filePathName; - if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath) && fs.accessSync(preferencesDirPath) - && fs.accessSync(tempDirPath) && fs.accessSync(databaseDirPath)) { - context.getApplicationContext().clearUpApplicationData((err) => { - logger.info(`clearUpApplicationData err:${JSON.stringify(err)}}`); - prompt.showToast({ - message: $r('app.string.clean_Data_Success'), duration: TIME - }); - }); - } else { - // 清理存储数据失败 - prompt.showToast({ - message: $r('app.string.clean_Data_Failed'), duration: TIME - }); - } - } -} +/* + * Copyright (c) 2023 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 ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; +import fs from '@ohos.file.fs'; +import prompt from '@ohos.promptAction'; +import { logger } from '../util/Logger'; + +const TAG: string = 'EntryAbility'; +const TIME: number = 3000; + +export default class CharacterOperation { + private context: Context; + + constructor(context: Context) { + this.context = context; + } + // 设置中文 + setZHCNLanguage = () => { + let applicationContext = this.context.getApplicationContext(); + applicationContext.setLanguage('zh-cn'); + logger.info(`${TAG} Chinese success`); + } + // 设置英文 + setENUSLanguage = () => { + let applicationContext = this.context.getApplicationContext(); + applicationContext.setLanguage('en-us'); + logger.info(`${TAG} English success`); + } + // 设置深色模式 + setDarKColorMode = () => { + let applicationContext = this.context.getApplicationContext(); + applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_DARK); + prompt.showToast({ + message: $r('app.string.switchDarkSuccess'), duration: TIME + }); + } + // 设置浅色模式 + setLightColorMode = () => { + let applicationContext = this.context.getApplicationContext(); + applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); + prompt.showToast({ + message: $r('app.string.switchLightSuccess'), duration: TIME + }); + } + // 获取缓存路径 + generateStorageFiles = () => { + let context = this.context; + let filePathName = '/test.txt'; + let cacheDirPath = context.cacheDir + filePathName; + let filesDirPath = context.filesDir + filePathName; + let preferencesDirPath = context.preferencesDir + filePathName; + let tempDirPath = context.tempDir + filePathName; + let databaseDirPath = context.databaseDir + filePathName; + + return [cacheDirPath, filesDirPath, preferencesDirPath, tempDirPath, databaseDirPath]; + } + // 创建存储数据 + createStorageData = () => { + let context = this.context; + let filePathName = '/test.txt'; + let cacheDirPath = context.cacheDir + filePathName; + let filesDirPath = context.filesDir + filePathName; + let preferencesDirPath = context.preferencesDir + filePathName; + let tempDirPath = context.tempDir + filePathName; + let databaseDirPath = context.databaseDir + filePathName; + try { + let file1 = fs.openSync(cacheDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let file2 = fs.openSync(filesDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let file3 = fs.openSync(preferencesDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let file4 = fs.openSync(tempDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let file5 = fs.openSync(databaseDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + + fs.closeSync(file1); + fs.closeSync(file2); + fs.closeSync(file3); + fs.closeSync(file4); + fs.closeSync(file5); + + if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath) + && fs.accessSync(preferencesDirPath) && fs.accessSync(tempDirPath) + && fs.accessSync(databaseDirPath)) { + prompt.showToast({ + message: $r('app.string.create_File_Success'), duration: TIME + }); + } + } catch (error) { + } + } + // 检查文件 + checkStorageData = () => { + let context = this.context; + let filePathName = '/test.txt'; + let cacheDirPath = context.cacheDir + filePathName; + let filesDirPath = context.filesDir + filePathName; + let preferencesDirPath = context.preferencesDir + filePathName; + let tempDirPath = context.tempDir + filePathName; + let databaseDirPath = context.databaseDir + filePathName; + if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath) + && fs.accessSync(preferencesDirPath) && fs.accessSync(tempDirPath) && fs.accessSync(databaseDirPath)) { + prompt.showToast({ + message: $r('app.string.search_File_Success'), duration: TIME + }); + } else { + prompt.showToast({ + message: $r('app.string.search_File_Failed'), duration: TIME + }); + } + } + // 清理存储数据 + clearStorageData = () => { + let context = this.context; + let filePathName = '/test.txt'; + let cacheDirPath = context.cacheDir + filePathName; + let filesDirPath = context.filesDir + filePathName; + let preferencesDirPath = context.preferencesDir + filePathName; + let tempDirPath = context.tempDir + filePathName; + let databaseDirPath = context.databaseDir + filePathName; + if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath) && fs.accessSync(preferencesDirPath) + && fs.accessSync(tempDirPath) && fs.accessSync(databaseDirPath)) { + context.getApplicationContext().clearUpApplicationData((err) => { + logger.info(`clearUpApplicationData err:${JSON.stringify(err)}}`); + prompt.showToast({ + message: $r('app.string.clean_Data_Success'), duration: TIME + }); + }); + } else { + // 清理存储数据失败 + prompt.showToast({ + message: $r('app.string.clean_Data_Failed'), duration: TIME + }); + } + } +} diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/entryability/EntryAbility.ets index f640336e76..d759f4f0a6 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import window from '@ohos.window'; -import Want from '@ohos.app.ability.Want'; -import { BusinessError } from '@ohos.base'; -import { logger } from '../util/Logger'; - -export default class EntryAbility extends UIAbility { - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - windowStage.loadContent('pages/Index', (err: BusinessError) => { - }); - windowStage.getMainWindow((err, windowClass) => { - if (err.code) { - return; - } - windowClass.setWindowLayoutFullScreen(true); - }) - logger.info(`EntryAbility onWindowStageCreate`); - } - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - AppStorage.setOrCreate('want', want); - AppStorage.setOrCreate('launchParam', launchParam); - logger.info(`EntryAbility onCreate ${want.bundleName},${launchParam.launchReason}`); - } - - onDestroy() { - logger.info(`EntryAbility onDestroy`); - } - - onWindowStageDestroy() { - logger.info(`EntryAbility onWindowStageDestroy`); - // Main window is destroyed, release UI related resources - } - - onForeground() { - logger.info(`EntryAbility onForeground`); - // Ability has brought to foreground - } - - onBackground() { - logger.info(`EntryAbility onBackground`); - // Ability has back to background - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import { BusinessError } from '@ohos.base'; +import { logger } from '../util/Logger'; + +export default class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + windowStage.loadContent('pages/Index', (err: BusinessError) => { + }); + windowStage.getMainWindow((err, windowClass) => { + if (err.code) { + return; + } + windowClass.setWindowLayoutFullScreen(true); + }) + logger.info(`EntryAbility onWindowStageCreate`); + } + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + AppStorage.setOrCreate('want', want); + AppStorage.setOrCreate('launchParam', launchParam); + logger.info(`EntryAbility onCreate ${want.bundleName},${launchParam.launchReason}`); + } + + onDestroy() { + logger.info(`EntryAbility onDestroy`); + } + + onWindowStageDestroy() { + logger.info(`EntryAbility onWindowStageDestroy`); + // Main window is destroyed, release UI related resources + } + + onForeground() { + logger.info(`EntryAbility onForeground`); + // Ability has brought to foreground + } + + onBackground() { + logger.info(`EntryAbility onBackground`); + // Ability has back to background + } +} diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/newability/NewAbility.ets b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/newability/NewAbility.ets index b9acfd827c..f74c81a86d 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/newability/NewAbility.ets +++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/newability/NewAbility.ets @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import window from '@ohos.window'; -import Want from '@ohos.app.ability.Want'; -import { logger } from '../util/Logger'; - -export default class NewAbility extends UIAbility { - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - windowStage.loadContent('pages/New', () => { - }); - windowStage.getMainWindow((err, windowClass) => { - if (err.code) { - return; - } - windowClass.setWindowLayoutFullScreen(true); - }) - } - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - AppStorage.setOrCreate('want', want); - AppStorage.setOrCreate('launchParam', launchParam); - logger.info(`NewAbility onCreate ${want.bundleName},${launchParam.launchReason}`); - } - - onDestroy() { - logger.info(`NewAbility onDestroy`); - } - - onWindowStageDestroy() { - logger.info(`NewAbility onWindowStageDestroy`); - // Main window is destroyed, release UI related resources - } - - onForeground() { - logger.info(`NewAbility onForeground`); - // Ability has brought to foreground - } - - onBackground() { - logger.info(`NewAbility onBackground`); - // Ability has back to background - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import { logger } from '../util/Logger'; + +export default class NewAbility extends UIAbility { + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + windowStage.loadContent('pages/New', () => { + }); + windowStage.getMainWindow((err, windowClass) => { + if (err.code) { + return; + } + windowClass.setWindowLayoutFullScreen(true); + }) + } + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + AppStorage.setOrCreate('want', want); + AppStorage.setOrCreate('launchParam', launchParam); + logger.info(`NewAbility onCreate ${want.bundleName},${launchParam.launchReason}`); + } + + onDestroy() { + logger.info(`NewAbility onDestroy`); + } + + onWindowStageDestroy() { + logger.info(`NewAbility onWindowStageDestroy`); + // Main window is destroyed, release UI related resources + } + + onForeground() { + logger.info(`NewAbility onForeground`); + // Ability has brought to foreground + } + + onBackground() { + logger.info(`NewAbility onBackground`); + // Ability has back to background + } +} diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/pages/New.ets b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/pages/New.ets index 93bec9d38d..e7eb83d5d2 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/pages/New.ets +++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/pages/New.ets @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import { logger } from '../util/Logger'; - -const TAG: string = 'NewAbility'; - -@Entry -@Component -struct New { - private context = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Image($r('app.media.ic_back')) - .size({ width: 20, height: 18 }) - .margin({ right: 18 }) - .onClick(() => { - this.context.terminateSelf((err, data) => { - logger.info(`${TAG} terminateSelf err:${JSON.stringify(err)},data:${JSON.stringify(data)}`); - }) - }) - Text($r('app.string.NewAbility_label')) - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.height(56) - .padding({ left: 26, right: 26 }) - .width('100%') - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { - Column() { - Image($r('app.media.pic_empty')).width('33%') - Text($r('app.string.empty')) - .fontSize(14) - } - }.width('100%') - .height('90%') - } - .width('100%') - .height('100%') - .padding({ top: 36, bottom: 0 }) - .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import { logger } from '../util/Logger'; + +const TAG: string = 'NewAbility'; + +@Entry +@Component +struct New { + private context = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Image($r('app.media.ic_back')) + .size({ width: 20, height: 18 }) + .margin({ right: 18 }) + .onClick(() => { + this.context.terminateSelf((err, data) => { + logger.info(`${TAG} terminateSelf err:${JSON.stringify(err)},data:${JSON.stringify(data)}`); + }) + }) + Text($r('app.string.NewAbility_label')) + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.height(56) + .padding({ left: 26, right: 26 }) + .width('100%') + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { + Column() { + Image($r('app.media.pic_empty')).width('33%') + Text($r('app.string.empty')) + .fontSize(14) + } + }.width('100%') + .height('90%') + } + .width('100%') + .height('100%') + .padding({ top: 36, bottom: 0 }) + .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/util/Logger.ets b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/util/Logger.ets index dbbf08e529..69eaf0c33e 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/util/Logger.ets +++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/util/Logger.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export let logger = new Logger('[Basic capabilities are enhanced]'); \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/module.json5 b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/module.json5 index 420b8c1ce3..1658c2f6e8 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/module.json5 +++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/module.json5 @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2023 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" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ets", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "NewAbility", - "srcEntry": "./ets/newability/NewAbility.ets", - "description": "$string:NewAbility_desc", - "icon": "$media:icon", - "label": "$string:NewAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - }, - ], - "extensionAbilities": [ - ] - } +/* + * Copyright (c) 2023 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" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "NewAbility", + "srcEntry": "./ets/newability/NewAbility.ets", + "description": "$string:NewAbility_desc", + "icon": "$media:icon", + "label": "$string:NewAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + }, + ], + "extensionAbilities": [ + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/color.json index a55608bdfd..01dee51761 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/color.json @@ -1,24 +1,24 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "background", - "value": "#FAFAFA" - }, - { - "name": "line_color", - "value": "#182431" - }, - { - "name": "text_color", - "value": "#182431" - }, - { - "name": "button_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "background", + "value": "#FAFAFA" + }, + { + "name": "line_color", + "value": "#182431" + }, + { + "name": "text_color", + "value": "#182431" + }, + { + "name": "button_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/float.json b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/float.json index 51aeb0059c..c8d10991d6 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/float.json +++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/float.json @@ -1,8 +1,8 @@ -{ - "float": [ - { - "name": "font_size", - "value": "16fp" - } - ] +{ + "float": [ + { + "name": "font_size", + "value": "16fp" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/ets/util/Logger.ts b/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/ets/util/Logger.ts index dbbf08e529..69eaf0c33e 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/ets/util/Logger.ts +++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/ets/util/Logger.ts @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export let logger = new Logger('[Basic capabilities are enhanced]'); \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/module.json5 b/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/module.json5 index 0511adbc86..c6ad62fbbd 100644 --- a/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/Ability/AbilityFeature/hvigor/hvigor-config.json5 b/code/BasicFeature/Ability/AbilityFeature/hvigor/hvigor-config.json5 index b84b124bfa..69b4a2dad7 100644 --- a/code/BasicFeature/Ability/AbilityFeature/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Ability/AbilityFeature/hvigor/hvigor-config.json5 @@ -1,6 +1,6 @@ -{ - "hvigorVersion": "4.1.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.1.2" - } +{ + "hvigorVersion": "4.1.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.1.2" + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityFeature/oh-package.json5 b/code/BasicFeature/Ability/AbilityFeature/oh-package.json5 index 1919d17c03..6daa33b912 100644 --- a/code/BasicFeature/Ability/AbilityFeature/oh-package.json5 +++ b/code/BasicFeature/Ability/AbilityFeature/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "abilityFeature", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "abilityFeature", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Ability/AbilityFeature/ohosTest.md b/code/BasicFeature/Ability/AbilityFeature/ohosTest.md index de91defcc0..dd6adf53fb 100644 --- a/code/BasicFeature/Ability/AbilityFeature/ohosTest.md +++ b/code/BasicFeature/Ability/AbilityFeature/ohosTest.md @@ -1,15 +1,15 @@ -# 基础能力增强测试用例 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | -------- | -| 应用切换语言的能力 | 设备正常运行 | 应用启动成功,点击'切换英文语言'的ListItem | 当前页面切换为英文,标题'基础能力增强'切换成'Basic capabilities are enhanced' | Yes | Pass | -| 应用切换语言的能力 | 设备正常运行 | 应用启动成功,点击'切换中文语言'的ListItem | 当前页面切换为中文,标题'Basic capabilities are enhanced'切换成'基础能力增强' | Yes | Pass | -| 应用切换颜色模式的能力 | 设备正常运行 | 应用启动成功,点击'切换深色模式'的ListItem | 当前页面颜色切换为深色,弹出Toast提示'切换成功' | Yes | Pass | -| 应用切换颜色模式的能力 | 设备正常运行 | 应用启动成功,点击'切换浅色模式'的ListItem | 当前页面颜色切换为浅色,弹出Toast提示'切换成功' | Yes | Pass | -| 应用隐式启动个数为0时不触发提示弹框的特性 | 设备正常运行 | 应用启动成功,点击'隐式启动弹窗'的ListItem | 弹出Toast提示'隐式启动弹窗',并且弹出弹窗,弹窗标题为'未找到文件' | Yes | Pass | -| 应用隐式启动个数为0时不触发提示弹框的特性 | 设备正常运行 | 应用启动成功,点击'隐式启动不弹窗'的ListItem | 弹出Toast提示'隐式启动不弹窗',且无弹窗 | Yes | Pass | -| 应用可以设置启动参数启动Ability能力 | 设备正常运行 | 1.应用启动成功,点击''启动动画'的“开启”的按钮
2.点击''StartOptions配置'的ListItem | 1.按钮变为“关闭”
2.应用启动NewAbility | Yes | Pass | -| 应用清理自己的数据的能力 | 设备正常运行 | 1.应用启动成功,点击'创建数据'的ListItem
2.点击'检查数据'的ListItem
3.点击'清除数据'的ListItem
4.点击应用图标
5.点击'检查数据'的ListItem | 1.弹出Toast提示'创建缓存文件成功'
2.弹出Toast提示'查询到缓存文件',
3.应用退出
4.重新启动应用
5.弹出Toast提示'未找到缓存文件' | No | Pass | - +# 基础能力增强测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | -------- | +| 应用切换语言的能力 | 设备正常运行 | 应用启动成功,点击'切换英文语言'的ListItem | 当前页面切换为英文,标题'基础能力增强'切换成'Basic capabilities are enhanced' | Yes | Pass | +| 应用切换语言的能力 | 设备正常运行 | 应用启动成功,点击'切换中文语言'的ListItem | 当前页面切换为中文,标题'Basic capabilities are enhanced'切换成'基础能力增强' | Yes | Pass | +| 应用切换颜色模式的能力 | 设备正常运行 | 应用启动成功,点击'切换深色模式'的ListItem | 当前页面颜色切换为深色,弹出Toast提示'切换成功' | Yes | Pass | +| 应用切换颜色模式的能力 | 设备正常运行 | 应用启动成功,点击'切换浅色模式'的ListItem | 当前页面颜色切换为浅色,弹出Toast提示'切换成功' | Yes | Pass | +| 应用隐式启动个数为0时不触发提示弹框的特性 | 设备正常运行 | 应用启动成功,点击'隐式启动弹窗'的ListItem | 弹出Toast提示'隐式启动弹窗',并且弹出弹窗,弹窗标题为'未找到文件' | Yes | Pass | +| 应用隐式启动个数为0时不触发提示弹框的特性 | 设备正常运行 | 应用启动成功,点击'隐式启动不弹窗'的ListItem | 弹出Toast提示'隐式启动不弹窗',且无弹窗 | Yes | Pass | +| 应用可以设置启动参数启动Ability能力 | 设备正常运行 | 1.应用启动成功,点击''启动动画'的“开启”的按钮
2.点击''StartOptions配置'的ListItem | 1.按钮变为“关闭”
2.应用启动NewAbility | Yes | Pass | +| 应用清理自己的数据的能力 | 设备正常运行 | 1.应用启动成功,点击'创建数据'的ListItem
2.点击'检查数据'的ListItem
3.点击'清除数据'的ListItem
4.点击应用图标
5.点击'检查数据'的ListItem | 1.弹出Toast提示'创建缓存文件成功'
2.弹出Toast提示'查询到缓存文件',
3.应用退出
4.重新启动应用
5.弹出Toast提示'未找到缓存文件' | No | Pass | + diff --git a/code/BasicFeature/Ability/AbilityRuntime/AppScope/app.json5 b/code/BasicFeature/Ability/AbilityRuntime/AppScope/app.json5 index 38b4d0880e..c15af56bb0 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/AppScope/app.json5 +++ b/code/BasicFeature/Ability/AbilityRuntime/AppScope/app.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2024 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.abilityruntime", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name", - "multiAppMode": { - "multiAppModeType": "appClone", - "maxCount": 5 - } - } -} +/* + * Copyright (c) 2024 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.abilityruntime", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "multiAppMode": { + "multiAppModeType": "appClone", + "maxCount": 5 + } + } +} diff --git a/code/BasicFeature/Ability/AbilityRuntime/AppScope/resources/base/element/string.json b/code/BasicFeature/Ability/AbilityRuntime/AppScope/resources/base/element/string.json index 7de244d006..07d445bead 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Ability/AbilityRuntime/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AbilityRuntime" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AbilityRuntime" + } + ] +} diff --git a/code/BasicFeature/Ability/AbilityRuntime/README_zh.md b/code/BasicFeature/Ability/AbilityRuntime/README_zh.md index 81b3f5aae9..486d032d94 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/README_zh.md +++ b/code/BasicFeature/Ability/AbilityRuntime/README_zh.md @@ -1,204 +1,204 @@ -# 基础能力增强 - -### 介绍 - -本示例使用 [AppManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-appManager.md) ,[dataUriUtils](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-ability-dataUriUtils.md),[WantAgent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-wantAgent.md),[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md),[errorManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-errorManager.md),[UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md)中的接口进行实现。 - -### 效果预览 - -| 主页面 | appManager开发示例 | errorManager开发示例 | UIAbilityContext开发示例 | -| :----------------------------------------------: | :---------------------------------------------------: | :-----------------------------------------------------: | :---------------------------------------------------------: | -| | | | | - -### 使用说明 - -AppManager对应接口 - -1.点击主页面**appManager开发示例**按钮,跳转到'appManager开发示例'界面; - -2.点击**isRunningInStabilityTest callback**按钮,弹出'isRunningInStabilityTest(callback) success...'信息; - -3.点击**isRunningInStabilityTest promise**按钮,弹出提示'isRunningInStabilityTest(promise) success...'信息; - -4.点击**isRamConstrainedDevice callback**按钮,弹出提示'isRamConstrainedDevice(callback) success...'信息; - -5.点击**isRamConstrainedDevice promise**按钮,弹出提示'isRamConstrainedDevice(promise) success...'信息; - -6.点击**getAppMemorySize callback**按钮,弹出提示'getAppMemorySize(callback) success...'信息; - -7.点击**getAppMemorySize promise**按钮,弹出提示'getAppMemorySize(promise) success...'信息; - -8.点击**getRunningProcessInformation callback**按钮,弹出提示'getRunningProcessInformation(callback) success...'信息; - -9.点击**getRunningProcessInformation promise**按钮,弹出提示'getRunningProcessInformation(promise) success...'信息; - - - -dataUriUtils对应接口 - -1.点击主页面**dataUriUtils开发示例**按钮,跳转到'dataUriUtils开发示例'界面; - -2.点击**getId**按钮,弹出提示'dataUriUtils.getId() called...'信息; - -3.点击**attachId**按钮,弹出提示'dataUriUtils.attachd() called...'信息; - -4.点击**deleteId**按钮,弹出提示'dataUriUtils.deleteId() called...'信息; - -5.点击**updateId**按钮,弹出提示'dataUriUtils.updateId() called...'信息; - - - -WantAgent对应接口 - -1.点击主页面**WantAgent开发示例**按钮,跳转到'WantAgent开发示例'界面; - -2.点击**getBundleName callback**按钮,弹出提示'getBundleName(callback) success...'信息; - -3.点击**getBundleName promise**按钮,弹出提示'getBundleName(promise) success...'信息; - -4.点击**getUid callback**按钮,弹出提示'getUid(callback) success...'信息; - -5.点击**getUid promise**按钮,弹出提示'getUid(promise) success...'信息; - -6.点击**cancel callback**按钮,弹出提示'cancel(callback) success'信息; - -7.点击**cancel promise**按钮,弹出提示'cancel(promise) success'信息; - -8.点击**equal callback**按钮,弹出提示'equal(callback) success...'信息; - -9.点击**equal promise**按钮,弹出提示'equal(promise) success...'信息; - -10.点击**getOperationType callback**按钮,弹出提示'getOperationType(callback) success...'信息; - -11.点击**getOperationType promise**按钮,弹出提示'getOperationType(promise) success...'信息; - -12.点击**trigger**按钮,弹出提示'trigger success...'信息; - - - -ApplicationContext对应接口 - -1.点击主页面**ApplicationContext开发示例**按钮,跳转到'ApplicationContext开发示例'界面; - -2.点击**setFont**按钮,弹出提示'setFont successfully'信息; - -3.点击**getRunningProcessInformation promise**按钮,弹出提示'getRunningProcessInformation promise successfully...'信息; - -4.点击**getRunningProcessInformation callback**按钮,弹出提示'getRunningProcessInformation callback successfully...'信息; - -5.点击**getCurrentAppCloneIndex**按钮,弹出提示'getCurrentAppCloneIndex successfully...'信息; - - - -errorManager对应接口 - -1.点击主页面**errorManager开发示例**按钮,跳转到'errorManager开发示例'界面; - -2.点击**注册LoopObserver**按钮,弹出提示'loopObserver registered successfully...'信息; - -3.点击**注册UnhandledRejectionObserver**按钮,弹出提示'unhandledRejection registered successfully'信息,列表中增加**模拟UnhandledRejection**按钮,并且原**注册UnhandledRejectionObserver**按钮变为**注销UnhandledRejectionObserver**按钮 - -4.点击**模拟UnhandledRejection**按钮,弹出提示'UnhandledRejectionObserver reason...'信息; - -5.点击**注销UnhandledRejection**按钮,弹出提示'unhandledRejection unregistered successfully'信息,**注销UnhandledRejectionObserver**按钮变回**注册UnhandledRejectionObserver**按钮,列表中**模拟UnhandledRejection**按钮消失; - - - -UIAbilityContext对应接口 - -1.点击主页面**UIAbilityContext开发示例**按钮,启动新的Ability显示'UIAbilityContext开发示例'界面; - -2.点击**moveAbilityToBackground**按钮,将启动的Ability移动到后台,页面显示为主页面,触发AbilityLifecycleCallback中的生命周期; - -3.再次点击主页面**UIAbilityContext开发示例**按钮,启动新的Ability显示'UIAbilityContext开发示例'界面,点击**terminateSelf**按钮,回到主页面; - -### 工程目录 - -``` -entry/src/main/ets/ -|---abilitylifecyclecallback -| |---AbilityLifecycleCallback.ets //AbilityLifecycleCallback生命周期 -|---abilitypages -| |---ApplicationContext.ets //ApplicationContext中对应接口 -| |---AppManager.ets //AppManager中对应接口 -| |---DataUriUtils.ets //DataUriUtils中对应接口 -| |---ErrorManager.ets //ErrorManager中对应接口 -| |---UIAbilityContext.ets //UIAbilityContext中对应接口 -| |---WantAgent.ets //WantAgent中对应接口 -|---entryability -| |---EntryAbility.ets // 首页的Ability -|---pages -| |---Index.ets // 首页 -``` - -### 具体实现 - -* AppManager对应接口实现,源码参考[AppManager.ets](entry/src/main/ets/abilitypages/appManager.ets) - - * isRunningInStabilityTest(callback)接口实现:通过调用appManager.isRunningInStabilityTest()接口,查询当前是否处于稳定性测试场景。使用callback异步回调,并将弹出Toast信息的功能; - * isRunningInStabilityTest(promise)接口实现:通过调用appManager.isRunningInStabilityTest()接口,查询当前是否处于稳定性测试场景。使用Promise异步回调,并将弹出Toast信息的功能; - * isRamConstrainedDevice(callback)接口实现:通过调用appManager.isRamConstrainedDevice()接口,查询是否为ram受限设备。使用callback异步回调,并将弹出Toast信息的功能; - * isRamConstrainedDevice(promise)接口实现:通过调用appManager.isRamConstrainedDevice()接口,查询是否为ram受限设备。使用Promise异步回调,并将弹出Toast信息的功能; - * getAppMemorySize(callback)接口实现:通过调用appManager.getAppMemorySize()接口,获取当前应用程序可以使用的内存的值。使用callback异步回调,并将弹出Toast信息的功能; - * getAppMemorySize(promise)接口实现:通过调用appManager.getAppMemorySize()接口,获取当前应用程序可以使用的内存的值。使用Promise异步回调,并将弹出Toast信息的功能; - * getRunningProcessInformation(callback)接口实现:通过调用appManager.getRunningProcessInformation()接口,获取当前运行进程的有关信息。使用callback异步回调,并将弹出Toast信息的功能; - * getRunningProcessInformation(promise)接口实现:通过调用appManager.getRunningProcessInformation()接口,获取当前运行进程的有关信息。使用Promise异步回调,并将弹出Toast信息的功能; -* dataUriUtils对应接口实现,源码参考[DataUriUtils.ets](entry/src/main/ets/abilitypages/DataUriUtils.ets) - - * getId接口实现:通过调用dataUriUtils.getId()接口,获取指定uri路径末尾的ID的功能; - * attachId接口实现:通过调用dataUriUtils.attachId()接口,将ID附加到uri的路径末尾的功能; - * deleteId接口实现:通过调用dataUriUtils.deleteId()接口,删除指定uri路径末尾的ID的功能; - * updateId接口实现:通过调用dataUriUtils.updateId()接口,更新指定uri中的ID的功能; -* WantAgent对应接口实现,源码参考[WantAgent.ets](entry/src/main/ets/abilitypages/WantAgent.ets) - - * getBundleName(callback)接口实现:通过调用this.getBundleNameCallback()接口,获取WantAgent实例的包名; - * getBundleName(promise)接口实现:通过调用this.getBundleNamePromise()接口,获取WantAgent实例的包名; - * getUid(callback)接口实现:通过调用this.getUidCallback()接口,获取WantAgent实例的用户ID; - * getUid(promise)接口实现:通过调用this.getUidPromise接口,获取WantAgent实例的用户ID; - * cancel(callback)接口实现:通过调用this.cancelCallback()接口,取消WantAgent实例; - * cancel(promise)接口实现:通过调用this.cancelPromise()接口,取消WantAgent实例; - * equal(callback)接口实现:通过调用this.equalCallback()接口,以此来判断是否是来自同一应用的相同操作,判断两个WantAgent实例是否相等的回调方法。返回true表示两个WantAgent实例相等,false表示两个WantAgent实例不相等; - * equal(promise)接口实现:通过调用this.equalPromise()接口,以此来判断是否是来自同一应用的相同操作,判断两个WantAgent实例是否相等的结果。返回true表示两个WantAgent实例相等,false表示两个WantAgent实例不相等; - * getOperationType(callback)接口实现:通过调用this.getOperationTypeCallback()接口,获取一个WantAgent的OperationType信息; - * getOperationType(promise)接口实现:通过调用this.getOperationTypePromise()接口,获取一个WantAgent的OperationType信息; - * trigger接口实现:通过调用this.trigger()接口,主动激发WantAgent实例; -* ApplicationContext对应接口实现,源码参考[ApplicationContext.ets](entry/src/main/ets/abilitypages/ApplicationContext.ets) - - * setFont接口实现:通过调用applicationContext.setFont接口,设置应用的字体类型。仅支持主线程调用,设置字体类型,字体可以通过font.registerFont方法进行注册使用; - * getRunningProcessInformation(callback)接口实现:通过调用ApplicationContext.getRunningProcessInformation接口,获取有关运行进程的信息; - * getRunningProcessInformation(promise)接口实现:通过调用ApplicationContext.getRunningProcessInformation接口,获取有关运行进程的信息; - * getCurrentAppCloneIndex接口实现:通过调用ApplicationContext.getCurrentAppCloneIndex接口,获取当前应用的分身索引; -* errorManager对应接口实现,源码参考[ErrorManager.ets](entry/src/main/ets/abilitypages/ErrorManager.ets) - * 注册on(loopObserver类型)接口实现:通过调用errorManager.on 接口,注册监听loopObserver,注册后可以捕获到应用主线程处理消息的具体执行时间,触发onLoopTimeOut,之后注销监听; - * 注册on(unhandledRejection类型)接口实现:通过调用errorManager.on接口,注册监听unhandledRejection,注册后可以捕获到当前线程中未被捕获到的promise rejection,模拟unhandledRejection类型错误,触发监听,之后注销监听; -* UIAbilityContext对应接口实现:源码参考[UIAbilityContext.ets](entry/src/main/ets/abilitypages/UIAbilityContext.ets) - * moveAbilityToBackground接口实现:通过调用context.moveAbilityToBackground()接口,将处于前台的Ability移动到后台,调用context.terminateSelf(),停止Ability自身,触发AbilityLifecycleCallback中的生命周期; - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568; - -2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31; - -3.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.502, built on July 28, 2024)才可编译运行; - -### 下载 - -```shell -git init -git config core.sparsecheckout true -echo code/BasicFeature/Ability/AbilityRuntime > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` - - - +# 基础能力增强 + +### 介绍 + +本示例使用 [AppManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-appManager.md) ,[dataUriUtils](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-ability-dataUriUtils.md),[WantAgent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-wantAgent.md),[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md),[errorManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-errorManager.md),[UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md)中的接口进行实现。 + +### 效果预览 + +| 主页面 | appManager开发示例 | errorManager开发示例 | UIAbilityContext开发示例 | +| :----------------------------------------------: | :---------------------------------------------------: | :-----------------------------------------------------: | :---------------------------------------------------------: | +| | | | | + +### 使用说明 + +AppManager对应接口 + +1.点击主页面**appManager开发示例**按钮,跳转到'appManager开发示例'界面; + +2.点击**isRunningInStabilityTest callback**按钮,弹出'isRunningInStabilityTest(callback) success...'信息; + +3.点击**isRunningInStabilityTest promise**按钮,弹出提示'isRunningInStabilityTest(promise) success...'信息; + +4.点击**isRamConstrainedDevice callback**按钮,弹出提示'isRamConstrainedDevice(callback) success...'信息; + +5.点击**isRamConstrainedDevice promise**按钮,弹出提示'isRamConstrainedDevice(promise) success...'信息; + +6.点击**getAppMemorySize callback**按钮,弹出提示'getAppMemorySize(callback) success...'信息; + +7.点击**getAppMemorySize promise**按钮,弹出提示'getAppMemorySize(promise) success...'信息; + +8.点击**getRunningProcessInformation callback**按钮,弹出提示'getRunningProcessInformation(callback) success...'信息; + +9.点击**getRunningProcessInformation promise**按钮,弹出提示'getRunningProcessInformation(promise) success...'信息; + + + +dataUriUtils对应接口 + +1.点击主页面**dataUriUtils开发示例**按钮,跳转到'dataUriUtils开发示例'界面; + +2.点击**getId**按钮,弹出提示'dataUriUtils.getId() called...'信息; + +3.点击**attachId**按钮,弹出提示'dataUriUtils.attachd() called...'信息; + +4.点击**deleteId**按钮,弹出提示'dataUriUtils.deleteId() called...'信息; + +5.点击**updateId**按钮,弹出提示'dataUriUtils.updateId() called...'信息; + + + +WantAgent对应接口 + +1.点击主页面**WantAgent开发示例**按钮,跳转到'WantAgent开发示例'界面; + +2.点击**getBundleName callback**按钮,弹出提示'getBundleName(callback) success...'信息; + +3.点击**getBundleName promise**按钮,弹出提示'getBundleName(promise) success...'信息; + +4.点击**getUid callback**按钮,弹出提示'getUid(callback) success...'信息; + +5.点击**getUid promise**按钮,弹出提示'getUid(promise) success...'信息; + +6.点击**cancel callback**按钮,弹出提示'cancel(callback) success'信息; + +7.点击**cancel promise**按钮,弹出提示'cancel(promise) success'信息; + +8.点击**equal callback**按钮,弹出提示'equal(callback) success...'信息; + +9.点击**equal promise**按钮,弹出提示'equal(promise) success...'信息; + +10.点击**getOperationType callback**按钮,弹出提示'getOperationType(callback) success...'信息; + +11.点击**getOperationType promise**按钮,弹出提示'getOperationType(promise) success...'信息; + +12.点击**trigger**按钮,弹出提示'trigger success...'信息; + + + +ApplicationContext对应接口 + +1.点击主页面**ApplicationContext开发示例**按钮,跳转到'ApplicationContext开发示例'界面; + +2.点击**setFont**按钮,弹出提示'setFont successfully'信息; + +3.点击**getRunningProcessInformation promise**按钮,弹出提示'getRunningProcessInformation promise successfully...'信息; + +4.点击**getRunningProcessInformation callback**按钮,弹出提示'getRunningProcessInformation callback successfully...'信息; + +5.点击**getCurrentAppCloneIndex**按钮,弹出提示'getCurrentAppCloneIndex successfully...'信息; + + + +errorManager对应接口 + +1.点击主页面**errorManager开发示例**按钮,跳转到'errorManager开发示例'界面; + +2.点击**注册LoopObserver**按钮,弹出提示'loopObserver registered successfully...'信息; + +3.点击**注册UnhandledRejectionObserver**按钮,弹出提示'unhandledRejection registered successfully'信息,列表中增加**模拟UnhandledRejection**按钮,并且原**注册UnhandledRejectionObserver**按钮变为**注销UnhandledRejectionObserver**按钮 + +4.点击**模拟UnhandledRejection**按钮,弹出提示'UnhandledRejectionObserver reason...'信息; + +5.点击**注销UnhandledRejection**按钮,弹出提示'unhandledRejection unregistered successfully'信息,**注销UnhandledRejectionObserver**按钮变回**注册UnhandledRejectionObserver**按钮,列表中**模拟UnhandledRejection**按钮消失; + + + +UIAbilityContext对应接口 + +1.点击主页面**UIAbilityContext开发示例**按钮,启动新的Ability显示'UIAbilityContext开发示例'界面; + +2.点击**moveAbilityToBackground**按钮,将启动的Ability移动到后台,页面显示为主页面,触发AbilityLifecycleCallback中的生命周期; + +3.再次点击主页面**UIAbilityContext开发示例**按钮,启动新的Ability显示'UIAbilityContext开发示例'界面,点击**terminateSelf**按钮,回到主页面; + +### 工程目录 + +``` +entry/src/main/ets/ +|---abilitylifecyclecallback +| |---AbilityLifecycleCallback.ets //AbilityLifecycleCallback生命周期 +|---abilitypages +| |---ApplicationContext.ets //ApplicationContext中对应接口 +| |---AppManager.ets //AppManager中对应接口 +| |---DataUriUtils.ets //DataUriUtils中对应接口 +| |---ErrorManager.ets //ErrorManager中对应接口 +| |---UIAbilityContext.ets //UIAbilityContext中对应接口 +| |---WantAgent.ets //WantAgent中对应接口 +|---entryability +| |---EntryAbility.ets // 首页的Ability +|---pages +| |---Index.ets // 首页 +``` + +### 具体实现 + +* AppManager对应接口实现,源码参考[AppManager.ets](entry/src/main/ets/abilitypages/appManager.ets) + + * isRunningInStabilityTest(callback)接口实现:通过调用appManager.isRunningInStabilityTest()接口,查询当前是否处于稳定性测试场景。使用callback异步回调,并将弹出Toast信息的功能; + * isRunningInStabilityTest(promise)接口实现:通过调用appManager.isRunningInStabilityTest()接口,查询当前是否处于稳定性测试场景。使用Promise异步回调,并将弹出Toast信息的功能; + * isRamConstrainedDevice(callback)接口实现:通过调用appManager.isRamConstrainedDevice()接口,查询是否为ram受限设备。使用callback异步回调,并将弹出Toast信息的功能; + * isRamConstrainedDevice(promise)接口实现:通过调用appManager.isRamConstrainedDevice()接口,查询是否为ram受限设备。使用Promise异步回调,并将弹出Toast信息的功能; + * getAppMemorySize(callback)接口实现:通过调用appManager.getAppMemorySize()接口,获取当前应用程序可以使用的内存的值。使用callback异步回调,并将弹出Toast信息的功能; + * getAppMemorySize(promise)接口实现:通过调用appManager.getAppMemorySize()接口,获取当前应用程序可以使用的内存的值。使用Promise异步回调,并将弹出Toast信息的功能; + * getRunningProcessInformation(callback)接口实现:通过调用appManager.getRunningProcessInformation()接口,获取当前运行进程的有关信息。使用callback异步回调,并将弹出Toast信息的功能; + * getRunningProcessInformation(promise)接口实现:通过调用appManager.getRunningProcessInformation()接口,获取当前运行进程的有关信息。使用Promise异步回调,并将弹出Toast信息的功能; +* dataUriUtils对应接口实现,源码参考[DataUriUtils.ets](entry/src/main/ets/abilitypages/DataUriUtils.ets) + + * getId接口实现:通过调用dataUriUtils.getId()接口,获取指定uri路径末尾的ID的功能; + * attachId接口实现:通过调用dataUriUtils.attachId()接口,将ID附加到uri的路径末尾的功能; + * deleteId接口实现:通过调用dataUriUtils.deleteId()接口,删除指定uri路径末尾的ID的功能; + * updateId接口实现:通过调用dataUriUtils.updateId()接口,更新指定uri中的ID的功能; +* WantAgent对应接口实现,源码参考[WantAgent.ets](entry/src/main/ets/abilitypages/WantAgent.ets) + + * getBundleName(callback)接口实现:通过调用this.getBundleNameCallback()接口,获取WantAgent实例的包名; + * getBundleName(promise)接口实现:通过调用this.getBundleNamePromise()接口,获取WantAgent实例的包名; + * getUid(callback)接口实现:通过调用this.getUidCallback()接口,获取WantAgent实例的用户ID; + * getUid(promise)接口实现:通过调用this.getUidPromise接口,获取WantAgent实例的用户ID; + * cancel(callback)接口实现:通过调用this.cancelCallback()接口,取消WantAgent实例; + * cancel(promise)接口实现:通过调用this.cancelPromise()接口,取消WantAgent实例; + * equal(callback)接口实现:通过调用this.equalCallback()接口,以此来判断是否是来自同一应用的相同操作,判断两个WantAgent实例是否相等的回调方法。返回true表示两个WantAgent实例相等,false表示两个WantAgent实例不相等; + * equal(promise)接口实现:通过调用this.equalPromise()接口,以此来判断是否是来自同一应用的相同操作,判断两个WantAgent实例是否相等的结果。返回true表示两个WantAgent实例相等,false表示两个WantAgent实例不相等; + * getOperationType(callback)接口实现:通过调用this.getOperationTypeCallback()接口,获取一个WantAgent的OperationType信息; + * getOperationType(promise)接口实现:通过调用this.getOperationTypePromise()接口,获取一个WantAgent的OperationType信息; + * trigger接口实现:通过调用this.trigger()接口,主动激发WantAgent实例; +* ApplicationContext对应接口实现,源码参考[ApplicationContext.ets](entry/src/main/ets/abilitypages/ApplicationContext.ets) + + * setFont接口实现:通过调用applicationContext.setFont接口,设置应用的字体类型。仅支持主线程调用,设置字体类型,字体可以通过font.registerFont方法进行注册使用; + * getRunningProcessInformation(callback)接口实现:通过调用ApplicationContext.getRunningProcessInformation接口,获取有关运行进程的信息; + * getRunningProcessInformation(promise)接口实现:通过调用ApplicationContext.getRunningProcessInformation接口,获取有关运行进程的信息; + * getCurrentAppCloneIndex接口实现:通过调用ApplicationContext.getCurrentAppCloneIndex接口,获取当前应用的分身索引; +* errorManager对应接口实现,源码参考[ErrorManager.ets](entry/src/main/ets/abilitypages/ErrorManager.ets) + * 注册on(loopObserver类型)接口实现:通过调用errorManager.on 接口,注册监听loopObserver,注册后可以捕获到应用主线程处理消息的具体执行时间,触发onLoopTimeOut,之后注销监听; + * 注册on(unhandledRejection类型)接口实现:通过调用errorManager.on接口,注册监听unhandledRejection,注册后可以捕获到当前线程中未被捕获到的promise rejection,模拟unhandledRejection类型错误,触发监听,之后注销监听; +* UIAbilityContext对应接口实现:源码参考[UIAbilityContext.ets](entry/src/main/ets/abilitypages/UIAbilityContext.ets) + * moveAbilityToBackground接口实现:通过调用context.moveAbilityToBackground()接口,将处于前台的Ability移动到后台,调用context.terminateSelf(),停止Ability自身,触发AbilityLifecycleCallback中的生命周期; + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568; + +2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31; + +3.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.502, built on July 28, 2024)才可编译运行; + +### 下载 + +```shell +git init +git config core.sparsecheckout true +echo code/BasicFeature/Ability/AbilityRuntime > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` + + + diff --git a/code/BasicFeature/Ability/AbilityRuntime/build-profile.json5 b/code/BasicFeature/Ability/AbilityRuntime/build-profile.json5 index 96292e1b2c..7848132072 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/build-profile.json5 +++ b/code/BasicFeature/Ability/AbilityRuntime/build-profile.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2024 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": 12, - "compileSdkVersion": 12, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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": 12, + "compileSdkVersion": 12, + "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/BasicFeature/Ability/AbilityRuntime/entry/build-profile.json5 b/code/BasicFeature/Ability/AbilityRuntime/entry/build-profile.json5 index d04cb6b90c..b4c2311b76 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/build-profile.json5 +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/build-profile.json5 @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2024 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", - } - ] +/* + * Copyright (c) 2024 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/BasicFeature/Ability/AbilityRuntime/entry/oh-package.json5 b/code/BasicFeature/Ability/AbilityRuntime/entry/oh-package.json5 index 65ca50243f..3d327009e0 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/oh-package.json5 +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2024 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": {} -} - +/* + * Copyright (c) 2024 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/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets index 430cc48537..3500fd2007 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets @@ -1,240 +1,240 @@ -/* - * Copyright (c) 2024 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, AbilityLifecycleCallback, UIAbility } from '@kit.AbilityKit'; -import { BusinessError } from '@ohos.base'; -import { window } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = '[AbilityLifecycleCallback]'; -const DOMAIN: number = 0xFF00; - -export class GlobalContext { - private constructor() { - } - - private static instance: GlobalContext; - private _objects = new Map(); - - public static getContext(): GlobalContext { - if (!GlobalContext.instance) { - GlobalContext.instance = new GlobalContext(); - } - return GlobalContext.instance; - } - - getObject(value: string): Object | undefined { - return this._objects.get(value); - } - - setObject(key: string, objectClass: Object): void { - this._objects.set(key, objectClass); - } -} - -// 声明ability生命周期回调,需配置所有回调后才可以在applicationContext注册 -let abilityLifecycleCallback: AbilityLifecycleCallback = { - onAbilityCreate(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityCreate.'); - }, - onWindowStageCreate(ability, windowStage) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageCreate.'); - }, - onWindowStageActive(ability, windowStage) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageActive.'); - }, - onWindowStageInactive(ability, windowStage) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageInactive.'); - }, - onWindowStageDestroy(ability, windowStage) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageDestroy.'); - }, - onAbilityDestroy(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityDestroy.'); - }, - onAbilityForeground(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityForeground.'); - }, - onAbilityBackground(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityBackground.'); - }, - onAbilityContinue(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityContinue.'); - }, - // 注册监听应用上下文的生命周期后,在UIAbility的[onNewWant]触发后回调。 - onNewWant(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onNewWant'); - }, - // 注册监听应用上下文的生命周期后,在UIAbility的[onNewWant]触发前回调。 - onWillNewWant(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWillNewWant'); - }, - // 注册监听应用上下文的生命周期后,在UIAbility的[onCreate]触发前回调。 - onAbilityWillCreate(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillCreate'); - }, - // 注册监听应用上下文的生命周期后,在UIAbility的[onWindowStageCreate]触发前回调。 - onWindowStageWillCreate(ability, windowStage) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageWillCreate'); - }, - // 注册监听应用上下文的生命周期后,在UIAbility的[onWindowStageDestroy]触发前回调。 - onWindowStageWillDestroy(ability, windowStage) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageWillDestroy'); - }, - // 注册监听应用上下文的生命周期后,在UIAbility的[onDestroy]触发前回调。 - onAbilityWillDestroy(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillDestroy'); - }, - // 注册监听应用上下文的生命周期后,在UIAbility的[onForeground]触发前回调。 - onAbilityWillForeground(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillForeground'); - }, - // 注册监听应用上下文的生命周期后,在UIAbility的[onBackground]触发前回调。 - onAbilityWillBackground(ability) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillBackground'); - }, - // 注册监听应用上下文的生命周期后,在UIAbility的[onSaveState]触发前回调。 - onAbilityWillSaveState(ability: UIAbility) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillSaveState.'); - }, - // 注册监听应用上下文的生命周期后,在UIAbility的[onSaveState]触发后回调。 - onAbilitySaveState(ability: UIAbility) { - hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilitySaveState.'); - } -}; - -export default class AbilityLifecycle extends UIAbility { - onCreate() { - hilog.info(DOMAIN, TAG, 'MyAbilityStage onCreate'); - - // 1.通过context属性获取applicationContext - let applicationContext = this.context.getApplicationContext(); - // 2.通过applicationContext注册监听应用内生命周期 - try { - let lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); - GlobalContext.getContext().setObject('lifecycleId', lifecycleId); - hilog.info(DOMAIN, TAG, - `registerAbilityLifecycleCallback lifecycleId: ${GlobalContext.getContext().getObject('lifecycleId')}`); - } catch (paramError) { - hilog.error(DOMAIN, TAG, `error: ${paramError.code}, ${paramError.message}`); - } - } - - onWindowStageCreate(windowStage: window.WindowStage) { - hilog.info(DOMAIN, TAG, 'onWindowStageCreate'); - - let windowClass: window.Window | undefined = undefined; - windowStage.getMainWindow((err: BusinessError, data) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); - return; - } - windowClass = data; - let systemBarProperties: window.SystemBarProperties = { - statusBarColor: '#f1f3f5', - navigationBarColor: '#f1f3f5', - }; - try { - windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); - }); - } catch (exception) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); - } - }); - - windowStage.loadContent('abilitypages/UIAbilityContext', (err, data) => { - if (err.code) { - return; - } - }); - } - - onBackground() { - hilog.info(DOMAIN, TAG, 'onBackground'); - } - - onForeground() { - hilog.info(DOMAIN, TAG, 'onBackground'); - } - - onPrepareToTerminate() { - hilog.info(DOMAIN, TAG, 'onPrepareToTerminate'); - // 开发者定义预关闭动作 - // 例如拉起另一个ability,根据ability处理结果执行异步关闭 - let want: Want = { - bundleName: 'com.samples.abilityruntime', - abilityName: 'AbilityLifecycleAbility' - } - this.context.startAbilityForResult(want) - .then((result) => { - // 获取ability处理结果,当返回结果的resultCode为0关闭当前UIAbility - hilog.info(DOMAIN, TAG, 'startAbilityForResult success, resultCode is ' + result.resultCode); - if (result.resultCode === 0) { - this.context.terminateSelf(); - } - }).catch((err: BusinessError) => { - // 异常处理 - hilog.error(DOMAIN, TAG, 'startAbilityForResult failed, err:' + JSON.stringify(err)); - this.context.terminateSelf(); - }) - - return true; // 已定义预关闭操作后,返回true表示UIAbility取消关闭 - } - - onWindowStageWillDestroy(windowStage: window.WindowStage) { - hilog.info(DOMAIN, TAG, 'onWindowStageWillDestroy'); - } - - onWindowStageRestore(windowStage: window.WindowStage) { - hilog.info(DOMAIN, TAG, 'onWindowStageRestore'); - } - - onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult { - // No need to save state - hilog.info(DOMAIN, TAG, 'onSaveState'); - return AbilityConstant.OnSaveResult.ALL_REJECT; - } - - onWindowStageDestroy() { - hilog.info(DOMAIN, TAG, 'onWindowStageDestroy'); - } - - onDestroy() { - let applicationContext = this.context.getApplicationContext(); - let lifecycleId = GlobalContext.getContext().getObject('lifecycleId') as number; - try { - // 3.通过applicationContext注销监听应用内生命周期 - applicationContext.off('abilityLifecycle', lifecycleId, (error) => { - if (error && error.code !== 0) { - hilog.error(DOMAIN, TAG, `unregisterAbilityLifecycleCallback fail, error: ${JSON.stringify(error)}`); - } else { - hilog.info(DOMAIN, TAG, 'unregisterAbilityLifecycleCallback success.'); - } - }); - } catch (paramError) { - hilog.error(DOMAIN, TAG, - `error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`); - } - } +/* + * Copyright (c) 2024 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, AbilityLifecycleCallback, UIAbility } from '@kit.AbilityKit'; +import { BusinessError } from '@ohos.base'; +import { window } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = '[AbilityLifecycleCallback]'; +const DOMAIN: number = 0xFF00; + +export class GlobalContext { + private constructor() { + } + + private static instance: GlobalContext; + private _objects = new Map(); + + public static getContext(): GlobalContext { + if (!GlobalContext.instance) { + GlobalContext.instance = new GlobalContext(); + } + return GlobalContext.instance; + } + + getObject(value: string): Object | undefined { + return this._objects.get(value); + } + + setObject(key: string, objectClass: Object): void { + this._objects.set(key, objectClass); + } +} + +// 声明ability生命周期回调,需配置所有回调后才可以在applicationContext注册 +let abilityLifecycleCallback: AbilityLifecycleCallback = { + onAbilityCreate(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityCreate.'); + }, + onWindowStageCreate(ability, windowStage) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageCreate.'); + }, + onWindowStageActive(ability, windowStage) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageActive.'); + }, + onWindowStageInactive(ability, windowStage) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageInactive.'); + }, + onWindowStageDestroy(ability, windowStage) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageDestroy.'); + }, + onAbilityDestroy(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityDestroy.'); + }, + onAbilityForeground(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityForeground.'); + }, + onAbilityBackground(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityBackground.'); + }, + onAbilityContinue(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityContinue.'); + }, + // 注册监听应用上下文的生命周期后,在UIAbility的[onNewWant]触发后回调。 + onNewWant(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onNewWant'); + }, + // 注册监听应用上下文的生命周期后,在UIAbility的[onNewWant]触发前回调。 + onWillNewWant(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWillNewWant'); + }, + // 注册监听应用上下文的生命周期后,在UIAbility的[onCreate]触发前回调。 + onAbilityWillCreate(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillCreate'); + }, + // 注册监听应用上下文的生命周期后,在UIAbility的[onWindowStageCreate]触发前回调。 + onWindowStageWillCreate(ability, windowStage) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageWillCreate'); + }, + // 注册监听应用上下文的生命周期后,在UIAbility的[onWindowStageDestroy]触发前回调。 + onWindowStageWillDestroy(ability, windowStage) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageWillDestroy'); + }, + // 注册监听应用上下文的生命周期后,在UIAbility的[onDestroy]触发前回调。 + onAbilityWillDestroy(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillDestroy'); + }, + // 注册监听应用上下文的生命周期后,在UIAbility的[onForeground]触发前回调。 + onAbilityWillForeground(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillForeground'); + }, + // 注册监听应用上下文的生命周期后,在UIAbility的[onBackground]触发前回调。 + onAbilityWillBackground(ability) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillBackground'); + }, + // 注册监听应用上下文的生命周期后,在UIAbility的[onSaveState]触发前回调。 + onAbilityWillSaveState(ability: UIAbility) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillSaveState.'); + }, + // 注册监听应用上下文的生命周期后,在UIAbility的[onSaveState]触发后回调。 + onAbilitySaveState(ability: UIAbility) { + hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilitySaveState.'); + } +}; + +export default class AbilityLifecycle extends UIAbility { + onCreate() { + hilog.info(DOMAIN, TAG, 'MyAbilityStage onCreate'); + + // 1.通过context属性获取applicationContext + let applicationContext = this.context.getApplicationContext(); + // 2.通过applicationContext注册监听应用内生命周期 + try { + let lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); + GlobalContext.getContext().setObject('lifecycleId', lifecycleId); + hilog.info(DOMAIN, TAG, + `registerAbilityLifecycleCallback lifecycleId: ${GlobalContext.getContext().getObject('lifecycleId')}`); + } catch (paramError) { + hilog.error(DOMAIN, TAG, `error: ${paramError.code}, ${paramError.message}`); + } + } + + onWindowStageCreate(windowStage: window.WindowStage) { + hilog.info(DOMAIN, TAG, 'onWindowStageCreate'); + + let windowClass: window.Window | undefined = undefined; + windowStage.getMainWindow((err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + return; + } + windowClass = data; + let systemBarProperties: window.SystemBarProperties = { + statusBarColor: '#f1f3f5', + navigationBarColor: '#f1f3f5', + }; + try { + windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); + }); + } catch (exception) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); + } + }); + + windowStage.loadContent('abilitypages/UIAbilityContext', (err, data) => { + if (err.code) { + return; + } + }); + } + + onBackground() { + hilog.info(DOMAIN, TAG, 'onBackground'); + } + + onForeground() { + hilog.info(DOMAIN, TAG, 'onBackground'); + } + + onPrepareToTerminate() { + hilog.info(DOMAIN, TAG, 'onPrepareToTerminate'); + // 开发者定义预关闭动作 + // 例如拉起另一个ability,根据ability处理结果执行异步关闭 + let want: Want = { + bundleName: 'com.samples.abilityruntime', + abilityName: 'AbilityLifecycleAbility' + } + this.context.startAbilityForResult(want) + .then((result) => { + // 获取ability处理结果,当返回结果的resultCode为0关闭当前UIAbility + hilog.info(DOMAIN, TAG, 'startAbilityForResult success, resultCode is ' + result.resultCode); + if (result.resultCode === 0) { + this.context.terminateSelf(); + } + }).catch((err: BusinessError) => { + // 异常处理 + hilog.error(DOMAIN, TAG, 'startAbilityForResult failed, err:' + JSON.stringify(err)); + this.context.terminateSelf(); + }) + + return true; // 已定义预关闭操作后,返回true表示UIAbility取消关闭 + } + + onWindowStageWillDestroy(windowStage: window.WindowStage) { + hilog.info(DOMAIN, TAG, 'onWindowStageWillDestroy'); + } + + onWindowStageRestore(windowStage: window.WindowStage) { + hilog.info(DOMAIN, TAG, 'onWindowStageRestore'); + } + + onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult { + // No need to save state + hilog.info(DOMAIN, TAG, 'onSaveState'); + return AbilityConstant.OnSaveResult.ALL_REJECT; + } + + onWindowStageDestroy() { + hilog.info(DOMAIN, TAG, 'onWindowStageDestroy'); + } + + onDestroy() { + let applicationContext = this.context.getApplicationContext(); + let lifecycleId = GlobalContext.getContext().getObject('lifecycleId') as number; + try { + // 3.通过applicationContext注销监听应用内生命周期 + applicationContext.off('abilityLifecycle', lifecycleId, (error) => { + if (error && error.code !== 0) { + hilog.error(DOMAIN, TAG, `unregisterAbilityLifecycleCallback fail, error: ${JSON.stringify(error)}`); + } else { + hilog.info(DOMAIN, TAG, 'unregisterAbilityLifecycleCallback success.'); + } + }); + } catch (paramError) { + hilog.error(DOMAIN, TAG, + `error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`); + } + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/AppManager.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/AppManager.ets index d9d9c9df20..a87a3f5b41 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/AppManager.ets +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/AppManager.ets @@ -1,349 +1,349 @@ -/* - * Copyright (c) 2024 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 { appManager } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { promptAction } from '@kit.ArkUI'; - -const TAG: string = 'AppManager'; -const DOMAIN: number = 0xFF00; - -@Entry -@Component -struct AppManager { - private promptDuration: number = 2000; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.AppManager')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: 8, - bottom: 8, - left: 12 - }) - } - } - .width('100%') - .height('7.18%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - .margin({ - top: '7.18%', - bottom: '6.41%', - left: '3.33%' - }) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.isRunningInStabilityTestCallback')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - .id('isRunningInStabilityTestCallback') - } - .onClick(() => { - try { - appManager.isRunningInStabilityTest((err, data) => { - hilog.info(DOMAIN, TAG, - `The result of isRunningInStabilityTest(callback) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `isRunningInStabilityTest(callback) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - } catch (err) { - hilog.info(DOMAIN, TAG, `isRunningInStabilityTest(callback) fail, err: ${JSON.stringify(err)}`); - } - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.isRunningInStabilityTestPromise')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - .id('isRunningInStabilityTestPromise') - } - .onClick(() => { - try { - appManager.isRunningInStabilityTest().then((data) => { - hilog.info(DOMAIN, TAG, - `The result of isRunningInStabilityTest(promise) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `isRunningInStabilityTest(promise) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - } catch (err) { - hilog.info(DOMAIN, TAG, `isRunningInStabilityTest(promise) fail, err: ${JSON.stringify(err)}`); - } - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.isRamConstrainedDeviceCallback')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - .id('isRamConstrainedDeviceCallback') - } - .onClick(() => { - try { - appManager.isRamConstrainedDevice((err, data) => { - hilog.info(DOMAIN, TAG, - `The result of isRamConstrainedDevice(callback) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `isRamConstrainedDevice(callback) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - } catch (err) { - hilog.info(DOMAIN, TAG, `isRamConstrainedDevice(callback) fail, err: ${JSON.stringify(err)}`); - } - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.isRamConstrainedDevicePromise')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - .id('isRamConstrainedDevicePromise') - } - .onClick(() => { - try { - appManager.isRamConstrainedDevice().then((data) => { - hilog.info(DOMAIN, TAG, - `The result of isRamConstrainedDevice(promise) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `isRamConstrainedDevice(promise) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - } catch (err) { - hilog.info(DOMAIN, TAG, `isRamConstrainedDevice(promise) fail, err: ${JSON.stringify(err)}`); - } - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.getAppMemorySizeCallback')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - .id('getAppMemorySizeCallback') - } - .onClick(() => { - try { - appManager.getAppMemorySize((err, data) => { - hilog.info(DOMAIN, TAG, - `The result of getAppMemorySize(callback) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `getAppMemorySize(callback) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - } catch (err) { - hilog.info(DOMAIN, TAG, `getAppMemorySize(callback) fail, err: ${JSON.stringify(err)}`); - } - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.getAppMemorySizePromise')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - .id('getAppMemorySizePromise') - } - .onClick(() => { - try { - appManager.getAppMemorySize().then((data) => { - hilog.info(DOMAIN, TAG, - `The result of getAppMemorySize(promise) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `getAppMemorySize(promise) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - } catch (err) { - hilog.info(DOMAIN, TAG, `getAppMemorySize(promise) fail, err: ${JSON.stringify(err)}`); - } - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.getRunningProcessInformationCallback')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('100%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - .id('getRunningProcessInformationCallback') - } - .onClick(() => { - try { - appManager.getRunningProcessInformation((err, data) => { - hilog.info(DOMAIN, TAG, - `The result of getRunningProcessInformation(callback) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `getRunningProcessInformation(callback) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - } catch (err) { - hilog.info(DOMAIN, TAG, `getRunningProcessInformation(callback) fail, err: ${JSON.stringify(err)}`); - } - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.getRunningProcessInformationPromise')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('100%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - .id('getRunningProcessInformationPromise') - } - .onClick(() => { - try { - appManager.getRunningProcessInformation().then((data) => { - hilog.info(DOMAIN, TAG, - `The result of getRunningProcessInformation(promise) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `getRunningProcessInformation(promise) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - } catch (err) { - hilog.info(DOMAIN, TAG, `getRunningProcessInformation(promise) fail, err: ${JSON.stringify(err)}`); - } - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2024 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 { appManager } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { promptAction } from '@kit.ArkUI'; + +const TAG: string = 'AppManager'; +const DOMAIN: number = 0xFF00; + +@Entry +@Component +struct AppManager { + private promptDuration: number = 2000; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.AppManager')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: 8, + bottom: 8, + left: 12 + }) + } + } + .width('100%') + .height('7.18%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + .margin({ + top: '7.18%', + bottom: '6.41%', + left: '3.33%' + }) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.isRunningInStabilityTestCallback')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + .id('isRunningInStabilityTestCallback') + } + .onClick(() => { + try { + appManager.isRunningInStabilityTest((err, data) => { + hilog.info(DOMAIN, TAG, + `The result of isRunningInStabilityTest(callback) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `isRunningInStabilityTest(callback) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + } catch (err) { + hilog.info(DOMAIN, TAG, `isRunningInStabilityTest(callback) fail, err: ${JSON.stringify(err)}`); + } + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.isRunningInStabilityTestPromise')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + .id('isRunningInStabilityTestPromise') + } + .onClick(() => { + try { + appManager.isRunningInStabilityTest().then((data) => { + hilog.info(DOMAIN, TAG, + `The result of isRunningInStabilityTest(promise) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `isRunningInStabilityTest(promise) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + } catch (err) { + hilog.info(DOMAIN, TAG, `isRunningInStabilityTest(promise) fail, err: ${JSON.stringify(err)}`); + } + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.isRamConstrainedDeviceCallback')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + .id('isRamConstrainedDeviceCallback') + } + .onClick(() => { + try { + appManager.isRamConstrainedDevice((err, data) => { + hilog.info(DOMAIN, TAG, + `The result of isRamConstrainedDevice(callback) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `isRamConstrainedDevice(callback) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + } catch (err) { + hilog.info(DOMAIN, TAG, `isRamConstrainedDevice(callback) fail, err: ${JSON.stringify(err)}`); + } + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.isRamConstrainedDevicePromise')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + .id('isRamConstrainedDevicePromise') + } + .onClick(() => { + try { + appManager.isRamConstrainedDevice().then((data) => { + hilog.info(DOMAIN, TAG, + `The result of isRamConstrainedDevice(promise) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `isRamConstrainedDevice(promise) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + } catch (err) { + hilog.info(DOMAIN, TAG, `isRamConstrainedDevice(promise) fail, err: ${JSON.stringify(err)}`); + } + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.getAppMemorySizeCallback')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + .id('getAppMemorySizeCallback') + } + .onClick(() => { + try { + appManager.getAppMemorySize((err, data) => { + hilog.info(DOMAIN, TAG, + `The result of getAppMemorySize(callback) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `getAppMemorySize(callback) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + } catch (err) { + hilog.info(DOMAIN, TAG, `getAppMemorySize(callback) fail, err: ${JSON.stringify(err)}`); + } + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.getAppMemorySizePromise')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + .id('getAppMemorySizePromise') + } + .onClick(() => { + try { + appManager.getAppMemorySize().then((data) => { + hilog.info(DOMAIN, TAG, + `The result of getAppMemorySize(promise) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `getAppMemorySize(promise) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + } catch (err) { + hilog.info(DOMAIN, TAG, `getAppMemorySize(promise) fail, err: ${JSON.stringify(err)}`); + } + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.getRunningProcessInformationCallback')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('100%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + .id('getRunningProcessInformationCallback') + } + .onClick(() => { + try { + appManager.getRunningProcessInformation((err, data) => { + hilog.info(DOMAIN, TAG, + `The result of getRunningProcessInformation(callback) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `getRunningProcessInformation(callback) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + } catch (err) { + hilog.info(DOMAIN, TAG, `getRunningProcessInformation(callback) fail, err: ${JSON.stringify(err)}`); + } + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.getRunningProcessInformationPromise')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('100%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + .id('getRunningProcessInformationPromise') + } + .onClick(() => { + try { + appManager.getRunningProcessInformation().then((data) => { + hilog.info(DOMAIN, TAG, + `The result of getRunningProcessInformation(promise) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `getRunningProcessInformation(promise) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + } catch (err) { + hilog.info(DOMAIN, TAG, `getRunningProcessInformation(promise) fail, err: ${JSON.stringify(err)}`); + } + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ApplicationContext.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ApplicationContext.ets index ea2e625223..18c221ec1d 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ApplicationContext.ets +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ApplicationContext.ets @@ -1,225 +1,225 @@ -/* - * Copyright (c) 2024 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 { common } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { font, promptAction } from '@kit.ArkUI'; - -const TAG: string = 'ApplicationContext'; -const DOMAIN: number = 0xFF00; - -@Entry -@Component -struct ApplicationContext { - private promptDuration: number = 2000; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.ApplicationContext')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: 8, - bottom: 8, - left: 12 - }) - } - } - .width('100%') - .height('14.36%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.ApplicationContext_getCurrentAppCloneIndex')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('100%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getCurrentAppCloneIndex') - .onClick(() => { - hilog.info(DOMAIN, TAG, 'ApplicationContext.getCurrentAppCloneIndex begin.'); - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - let applicationContext = context.getApplicationContext(); - try { - let index = applicationContext.getCurrentAppCloneIndex(); - let msg = `getCurrentAppCloneIndex successfully, index: ${index}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ - message: msg, - duration: this.promptDuration - }) - } catch (error) { - hilog.info(DOMAIN, TAG, - `ApplicationContext.getCurrentAppCloneIndex fail, error: ${JSON.stringify(error)}`); - } - hilog.info(DOMAIN, TAG, 'ApplicationContext.getCurrentAppCloneIndex succeed.'); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.ApplicationContext_getRunningProcessInformation_callback')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('100%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getRunningProcessInformationCallback') - .onClick(() => { - hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation callback begin.'); - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - let applicationContext = context.getApplicationContext(); - - try { - applicationContext.getRunningProcessInformation((err, data) => { - let msg = `getRunningProcessInformation callback successfully, data: ${JSON.stringify(data)}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ - message: msg, - duration: this.promptDuration - }) - }) - } catch (err) { - hilog.info(DOMAIN, TAG, - `ApplicationContext.getRunningProcessInformation callback fail, error: ${JSON.stringify(err)}`); - } - hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation callback succeed.'); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.ApplicationContext_getRunningProcessInformation_promise')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('100%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getRunningProcessInformationPromise') - .onClick(() => { - hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation promise begin.'); - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - let applicationContext = context.getApplicationContext(); - - try { - applicationContext.getRunningProcessInformation().then((data) => { - let msg = `getRunningProcessInformation promise successfully, data: ${JSON.stringify(data)}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ - message: msg, - duration: this.promptDuration - }) - }) - } catch (err) { - hilog.info(DOMAIN, TAG, - `ApplicationContext.getRunningProcessInformation promise fail, error: ${JSON.stringify(err)}`); - } - hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation promise succeed.'); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.ApplicationContext_setFont')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('100%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('setFont') - .onClick(() => { - font.registerFont({ - familyName: 'fontName', - familySrc: $rawfile('font/Roboto-Regular.ttf') - }) - - hilog.info(DOMAIN, TAG, 'ApplicationContext.setFont begin.'); - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - let applicationContext = context.getApplicationContext(); - - try { - applicationContext.setFont('fontName'); - let msg = `setFont successfully`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ - message: msg, - duration: this.promptDuration - }) - } catch (err) { - hilog.info(DOMAIN, TAG, - `ApplicationContext.setFont fail, error: ${JSON.stringify(err)}`); - } - hilog.info(DOMAIN, TAG, 'ApplicationContext.setFont succeed.'); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2024 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 { common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { font, promptAction } from '@kit.ArkUI'; + +const TAG: string = 'ApplicationContext'; +const DOMAIN: number = 0xFF00; + +@Entry +@Component +struct ApplicationContext { + private promptDuration: number = 2000; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.ApplicationContext')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: 8, + bottom: 8, + left: 12 + }) + } + } + .width('100%') + .height('14.36%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.ApplicationContext_getCurrentAppCloneIndex')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('100%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getCurrentAppCloneIndex') + .onClick(() => { + hilog.info(DOMAIN, TAG, 'ApplicationContext.getCurrentAppCloneIndex begin.'); + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + let applicationContext = context.getApplicationContext(); + try { + let index = applicationContext.getCurrentAppCloneIndex(); + let msg = `getCurrentAppCloneIndex successfully, index: ${index}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ + message: msg, + duration: this.promptDuration + }) + } catch (error) { + hilog.info(DOMAIN, TAG, + `ApplicationContext.getCurrentAppCloneIndex fail, error: ${JSON.stringify(error)}`); + } + hilog.info(DOMAIN, TAG, 'ApplicationContext.getCurrentAppCloneIndex succeed.'); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.ApplicationContext_getRunningProcessInformation_callback')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('100%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getRunningProcessInformationCallback') + .onClick(() => { + hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation callback begin.'); + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + let applicationContext = context.getApplicationContext(); + + try { + applicationContext.getRunningProcessInformation((err, data) => { + let msg = `getRunningProcessInformation callback successfully, data: ${JSON.stringify(data)}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ + message: msg, + duration: this.promptDuration + }) + }) + } catch (err) { + hilog.info(DOMAIN, TAG, + `ApplicationContext.getRunningProcessInformation callback fail, error: ${JSON.stringify(err)}`); + } + hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation callback succeed.'); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.ApplicationContext_getRunningProcessInformation_promise')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('100%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getRunningProcessInformationPromise') + .onClick(() => { + hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation promise begin.'); + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + let applicationContext = context.getApplicationContext(); + + try { + applicationContext.getRunningProcessInformation().then((data) => { + let msg = `getRunningProcessInformation promise successfully, data: ${JSON.stringify(data)}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ + message: msg, + duration: this.promptDuration + }) + }) + } catch (err) { + hilog.info(DOMAIN, TAG, + `ApplicationContext.getRunningProcessInformation promise fail, error: ${JSON.stringify(err)}`); + } + hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation promise succeed.'); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.ApplicationContext_setFont')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('100%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('setFont') + .onClick(() => { + font.registerFont({ + familyName: 'fontName', + familySrc: $rawfile('font/Roboto-Regular.ttf') + }) + + hilog.info(DOMAIN, TAG, 'ApplicationContext.setFont begin.'); + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + let applicationContext = context.getApplicationContext(); + + try { + applicationContext.setFont('fontName'); + let msg = `setFont successfully`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ + message: msg, + duration: this.promptDuration + }) + } catch (err) { + hilog.info(DOMAIN, TAG, + `ApplicationContext.setFont fail, error: ${JSON.stringify(err)}`); + } + hilog.info(DOMAIN, TAG, 'ApplicationContext.setFont succeed.'); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/DataUriUtils.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/DataUriUtils.ets index 274b22b686..f969d2154d 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/DataUriUtils.ets +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/DataUriUtils.ets @@ -1,198 +1,198 @@ -/* - * Copyright (c) 2024 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 { dataUriUtils } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { promptAction } from '@kit.ArkUI'; - -const TAG: string = 'DataUriUtils'; -const DOMAIN: number = 0xFF00; -const ID = 1122; - -@Entry -@Component -struct DataUriUtils { - private promptDuration: number = 2000; - @State loopObserverRegistered: boolean = false; - @State unhandledRejectionRegistered: boolean = false; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.DataUriUtils')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: 8, - bottom: 8, - left: 12 - }) - } - } - .width('100%') - .height('14.36%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.getId')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getId') - .onClick(() => { - ((): void => { - try { - let id = dataUriUtils.getId('com.example.dataUriUtils/1221'); - hilog.info(DOMAIN, TAG, `dataUriUtils.getId() called. id: ${id}`); - promptAction.showToast({ - message: `dataUriUtils.getId() called. id: ${id}`, - duration: this.promptDuration - }); - } catch (err) { - hilog.info(DOMAIN, TAG, `dataUriUtils.getId() error: ${err}`); - promptAction.showToast({ - message: `dataUriUtils.getId() error: ${err}`, - duration: this.promptDuration - }); - } - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.attachId')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('attachId') - .onClick(() => { - ((): void => { - let id = 1122; - let uri = dataUriUtils.attachId( - 'com.example.dataUriUtils', - id, - ); - promptAction.showToast({ - message: `dataUriUtils.attachId() called. uri: ${JSON.stringify(uri)}`, - duration: this.promptDuration - }); - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.deleteId')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('deleteId') - .onClick(() => { - ((): void => { - let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221'); - promptAction.showToast({ - message: `dataUriUtils.deleteId() called. uri: ${JSON.stringify(uri)}`, - duration: this.promptDuration - }); - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.updateId')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('updateId') - .onClick(() => { - ((): void => { - let uri = dataUriUtils.updateId( - 'com.example.dataUriUtils/1221', - ID - ); - promptAction.showToast({ - message: `dataUriUtils.updateId() called. uri: ${JSON.stringify(uri)}`, - duration: this.promptDuration - }); - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2024 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 { dataUriUtils } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { promptAction } from '@kit.ArkUI'; + +const TAG: string = 'DataUriUtils'; +const DOMAIN: number = 0xFF00; +const ID = 1122; + +@Entry +@Component +struct DataUriUtils { + private promptDuration: number = 2000; + @State loopObserverRegistered: boolean = false; + @State unhandledRejectionRegistered: boolean = false; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.DataUriUtils')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: 8, + bottom: 8, + left: 12 + }) + } + } + .width('100%') + .height('14.36%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.getId')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getId') + .onClick(() => { + ((): void => { + try { + let id = dataUriUtils.getId('com.example.dataUriUtils/1221'); + hilog.info(DOMAIN, TAG, `dataUriUtils.getId() called. id: ${id}`); + promptAction.showToast({ + message: `dataUriUtils.getId() called. id: ${id}`, + duration: this.promptDuration + }); + } catch (err) { + hilog.info(DOMAIN, TAG, `dataUriUtils.getId() error: ${err}`); + promptAction.showToast({ + message: `dataUriUtils.getId() error: ${err}`, + duration: this.promptDuration + }); + } + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.attachId')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('attachId') + .onClick(() => { + ((): void => { + let id = 1122; + let uri = dataUriUtils.attachId( + 'com.example.dataUriUtils', + id, + ); + promptAction.showToast({ + message: `dataUriUtils.attachId() called. uri: ${JSON.stringify(uri)}`, + duration: this.promptDuration + }); + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.deleteId')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('deleteId') + .onClick(() => { + ((): void => { + let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221'); + promptAction.showToast({ + message: `dataUriUtils.deleteId() called. uri: ${JSON.stringify(uri)}`, + duration: this.promptDuration + }); + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.updateId')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('updateId') + .onClick(() => { + ((): void => { + let uri = dataUriUtils.updateId( + 'com.example.dataUriUtils/1221', + ID + ); + promptAction.showToast({ + message: `dataUriUtils.updateId() called. uri: ${JSON.stringify(uri)}`, + duration: this.promptDuration + }); + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ErrorManager.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ErrorManager.ets index 701e0d6c81..84c71b39b5 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ErrorManager.ets +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ErrorManager.ets @@ -1,195 +1,195 @@ -/* - * Copyright (c) 2024 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 { errorManager } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { promptAction } from '@kit.ArkUI'; - -const TAG: string = 'ErrorManager'; -const DOMAIN: number = 0xFF00; - -let observer: errorManager.LoopObserver = { - onLoopTimeOut(timeout: number) { - hilog.info(DOMAIN, TAG, `onLoopTimeOut, timeout: ${timeout}`) - errorManager.off('loopObserver'); - } -}; - -@Entry -@Component -struct ErrorManager { - private promptDuration: number = 2000; - private loopTimeOut: number = 20; - @State unhandledRejectionRegistered: boolean = false; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.ErrorManager')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: 8, - bottom: 8, - left: 12 - }) - } - } - .width('100%') - .height('14.36%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.registerLoopObserver')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('registerLoopObserver') - .onClick(() => { - ((): void => { - try { - errorManager.on('loopObserver', this.loopTimeOut, observer); - let msg = `loopObserver registered successfully, loopTimeOut: ${this.loopTimeOut}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ - message: msg, - duration: this.promptDuration - }) - } catch (error) { - hilog.info(DOMAIN, TAG, `errorManager.on('loopObserver') failed, error: ${JSON.stringify(error)}`); - } - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text(this.unhandledRejectionRegistered ? - $r('app.string.unregisterUnhandledRejection') : $r('app.string.registerUnhandledRejection')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id(this.unhandledRejectionRegistered ? ('unregisterUnhandledRejection') : ('registerUnhandledRejection')) - .onClick(() => { - ((): void => { - if (this.unhandledRejectionRegistered == false) { - let observer: errorManager.UnhandledRejectionObserver = (reason: Error, promise: Promise) => { - let msg = `UnhandledRejectionObserver reason: ${JSON.stringify(reason)}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ - message: msg, - duration: this.promptDuration - }) - }; - - try { - errorManager.on('unhandledRejection', observer); - this.unhandledRejectionRegistered = true; - let msg = `unhandledRejection registered successfully`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ - message: msg, - duration: this.promptDuration - }) - } catch (error) { - hilog.info(DOMAIN, TAG, - `errorManager.on('unhandledRejection') failed, error: ${JSON.stringify(error)}`); - this.unhandledRejectionRegistered = false; - } - - } else { - try { - errorManager.off('unhandledRejection'); - this.unhandledRejectionRegistered = false; - let msg: string = `unhandledRejection unregistered successfully`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ - message: msg, - duration: this.promptDuration - }) - } catch (error) { - this.unhandledRejectionRegistered = true; - hilog.info(DOMAIN, TAG, `unhandledRejection unregistered failed, error: ${JSON.stringify(error)}`); - } - } - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - if (this.unhandledRejectionRegistered) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.simulateUnhandledRejection')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('simulateUnhandledRejection') - .onClick(() => { - Promise.reject({ name: 'test', message: 'simulateUnhandledRejection' }); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2024 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 { errorManager } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { promptAction } from '@kit.ArkUI'; + +const TAG: string = 'ErrorManager'; +const DOMAIN: number = 0xFF00; + +let observer: errorManager.LoopObserver = { + onLoopTimeOut(timeout: number) { + hilog.info(DOMAIN, TAG, `onLoopTimeOut, timeout: ${timeout}`) + errorManager.off('loopObserver'); + } +}; + +@Entry +@Component +struct ErrorManager { + private promptDuration: number = 2000; + private loopTimeOut: number = 20; + @State unhandledRejectionRegistered: boolean = false; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.ErrorManager')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: 8, + bottom: 8, + left: 12 + }) + } + } + .width('100%') + .height('14.36%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.registerLoopObserver')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('registerLoopObserver') + .onClick(() => { + ((): void => { + try { + errorManager.on('loopObserver', this.loopTimeOut, observer); + let msg = `loopObserver registered successfully, loopTimeOut: ${this.loopTimeOut}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ + message: msg, + duration: this.promptDuration + }) + } catch (error) { + hilog.info(DOMAIN, TAG, `errorManager.on('loopObserver') failed, error: ${JSON.stringify(error)}`); + } + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text(this.unhandledRejectionRegistered ? + $r('app.string.unregisterUnhandledRejection') : $r('app.string.registerUnhandledRejection')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id(this.unhandledRejectionRegistered ? ('unregisterUnhandledRejection') : ('registerUnhandledRejection')) + .onClick(() => { + ((): void => { + if (this.unhandledRejectionRegistered == false) { + let observer: errorManager.UnhandledRejectionObserver = (reason: Error, promise: Promise) => { + let msg = `UnhandledRejectionObserver reason: ${JSON.stringify(reason)}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ + message: msg, + duration: this.promptDuration + }) + }; + + try { + errorManager.on('unhandledRejection', observer); + this.unhandledRejectionRegistered = true; + let msg = `unhandledRejection registered successfully`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ + message: msg, + duration: this.promptDuration + }) + } catch (error) { + hilog.info(DOMAIN, TAG, + `errorManager.on('unhandledRejection') failed, error: ${JSON.stringify(error)}`); + this.unhandledRejectionRegistered = false; + } + + } else { + try { + errorManager.off('unhandledRejection'); + this.unhandledRejectionRegistered = false; + let msg: string = `unhandledRejection unregistered successfully`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ + message: msg, + duration: this.promptDuration + }) + } catch (error) { + this.unhandledRejectionRegistered = true; + hilog.info(DOMAIN, TAG, `unhandledRejection unregistered failed, error: ${JSON.stringify(error)}`); + } + } + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + if (this.unhandledRejectionRegistered) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.simulateUnhandledRejection')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('simulateUnhandledRejection') + .onClick(() => { + Promise.reject({ name: 'test', message: 'simulateUnhandledRejection' }); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/UIAbilityContext.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/UIAbilityContext.ets index 26baf797fd..914f1337b5 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/UIAbilityContext.ets +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/UIAbilityContext.ets @@ -1,113 +1,113 @@ -/* - * Copyright (c) 2024 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 { common } from '@kit.AbilityKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'UIAbilityContext'; -const DOMAIN: number = 0xFF00; - -@Entry -@Component -struct UIAbilityContext { - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIAbilityContext')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: 8, - bottom: 8, - left: 12 - }) - } - } - .width('100%') - .height('14.36%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIAbilityContext_moveAbilityToBackground')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('moveAbilityToBackground') - .onClick(() => { - let context = getContext(this) as common.UIAbilityContext; - context.moveAbilityToBackground().then(() => { - hilog.info(DOMAIN, TAG, 'moveAbilityToBackground success.'); - }).catch((err: BusinessError) => { - hilog.info(DOMAIN, TAG, `moveAbilityToBackground error: ${JSON.stringify(err)}.`); - }); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIAbilityContext_terminateSelf')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('terminateSelf') - .onClick(() => { - let context = getContext(this) as common.UIAbilityContext; - context.terminateSelf().then(() => { - hilog.info(DOMAIN, TAG, 'terminateSelf success.'); - }).catch((err: BusinessError) => { - hilog.info(DOMAIN, TAG, `terminateSelf error: ${JSON.stringify(err)}.`); - }); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .backgroundColor($r('app.color.backGrounding')) - .width('100%') - .height('100%') - } +/* + * Copyright (c) 2024 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 { common } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'UIAbilityContext'; +const DOMAIN: number = 0xFF00; + +@Entry +@Component +struct UIAbilityContext { + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIAbilityContext')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: 8, + bottom: 8, + left: 12 + }) + } + } + .width('100%') + .height('14.36%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIAbilityContext_moveAbilityToBackground')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('moveAbilityToBackground') + .onClick(() => { + let context = getContext(this) as common.UIAbilityContext; + context.moveAbilityToBackground().then(() => { + hilog.info(DOMAIN, TAG, 'moveAbilityToBackground success.'); + }).catch((err: BusinessError) => { + hilog.info(DOMAIN, TAG, `moveAbilityToBackground error: ${JSON.stringify(err)}.`); + }); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIAbilityContext_terminateSelf')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('terminateSelf') + .onClick(() => { + let context = getContext(this) as common.UIAbilityContext; + context.terminateSelf().then(() => { + hilog.info(DOMAIN, TAG, 'terminateSelf success.'); + }).catch((err: BusinessError) => { + hilog.info(DOMAIN, TAG, `terminateSelf error: ${JSON.stringify(err)}.`); + }); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .backgroundColor($r('app.color.backGrounding')) + .width('100%') + .height('100%') + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/WantAgent.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/WantAgent.ets index 8e4bad93d0..33c1177c84 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/WantAgent.ets +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/WantAgent.ets @@ -1,506 +1,506 @@ -/* - * Copyright (c) 2024 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 { wantAgent } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { promptAction } from '@kit.ArkUI'; - -const TAG: string = 'WantAgent'; -const DOMAIN: number = 0xFF00; - -@Entry -@Component -struct WantAgentClass { - private promptDuration: number = 2000; - private wantAgentInfo: wantAgent.WantAgentInfo = { - wants: [ - { - bundleName: 'com.samples.abilityruntime', - abilityName: 'EntryAbility', - } - ], - actionType: wantAgent.OperationType.START_ABILITY, - requestCode: 0, - actionFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] - } - - async getBundleNameCallback(): Promise { - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.getBundleName(dataBase, (err, data) => { - hilog.info(DOMAIN, TAG, - `The result of getBundleName(callback) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `getBundleName(callback) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - async getBundleNamePromise(): Promise { - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.getBundleName(dataBase).then((data) => { - hilog.info(DOMAIN, TAG, - `The result of getBundleName(promise) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `getBundleName(promise) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - async getUidCallback(): Promise { - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.getUid(dataBase, (err, data) => { - hilog.info(DOMAIN, TAG, - `The result of getUid(callback) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `getUid(callback) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - async getUidPromise(): Promise { - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.getUid(dataBase).then((data) => { - hilog.info(DOMAIN, TAG, - `The result of getUid(promise) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `getUid(promise) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - async cancelCallback(): Promise { - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.cancel(dataBase, (err, data) => { - hilog.info(DOMAIN, TAG, - `The result of cancel(callback) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `cancel(callback) success`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - async cancelPromise(): Promise { - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.cancel(dataBase).then((data) => { - hilog.info(DOMAIN, TAG, - `The result of cancel(promise) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `cancel(promise) success`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - async equalCallback(): Promise { - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.equal(dataBase, dataBase, (err, data) => { - hilog.info(DOMAIN, TAG, - `The result of equal(callback) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `equal(callback) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - async equalPromise(): Promise { - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.equal(dataBase, dataBase).then((data) => { - hilog.info(DOMAIN, TAG, - `The result of equal(promise) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `equal(promise) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - async getOperationTypeCallback(): Promise { - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.getOperationType(dataBase, (err, data) => { - hilog.info(DOMAIN, TAG, - `The result of getOperationType(callback) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `getOperationType(callback) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - async getOperationTypePromise(): Promise { - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.getOperationType(dataBase).then((data) => { - hilog.info(DOMAIN, TAG, - `The result of getOperationType(promise) is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `getOperationType(promise) success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - async trigger(): Promise { - let triggerInfo: wantAgent.TriggerInfo = { - code: 0, - want: { - bundleName: 'com.samples.abilityruntime', - abilityName: 'EntryAbility', - }, - permission: '', - extraInfo: { - test: 'this is a test value' - } - } - - wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { - wantAgent.trigger(dataBase, triggerInfo, (err, data) => { - hilog.info(DOMAIN, TAG, - `The result of trigger is: ${JSON.stringify(data)}`); - promptAction.showToast({ - message: `trigger success, data: ${JSON.stringify(data)}`, - duration: this.promptDuration - }) - }) - console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) - }) - } - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.WantAgent')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: 8, - bottom: 8, - left: 12 - }) - } - } - .width('100%') - .height('14.36%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.getBundleNameCallback`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getBundleNameCallback') - .onClick(() => { - this.getBundleNameCallback(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.getBundleNamePromise`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getBundleNamePromise') - .onClick(() => { - this.getBundleNamePromise(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.getUidCallback`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getUidCallback') - .onClick(() => { - this.getUidCallback(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.getUidPromise`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getUidPromise') - .onClick(() => { - this.getUidPromise(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.cancelCallback`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('cancelCallback') - .onClick(() => { - this.cancelCallback(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.cancelPromise`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('cancelPromise') - .onClick(() => { - this.cancelPromise(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.equalCallback`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('equalCallback') - .onClick(() => { - this.equalCallback(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.equalPromise`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('equalPromise') - .onClick(() => { - this.equalPromise(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.getOperationTypeCallback`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getOperationTypeCallback') - .onClick(() => { - this.getOperationTypeCallback(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.getOperationTypePromise`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getOperationTypePromise') - .onClick(() => { - this.getOperationTypePromise(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r(`app.string.trigger`)) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('trigger') - .onClick(() => { - this.trigger(); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - } +/* + * Copyright (c) 2024 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 { wantAgent } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { promptAction } from '@kit.ArkUI'; + +const TAG: string = 'WantAgent'; +const DOMAIN: number = 0xFF00; + +@Entry +@Component +struct WantAgentClass { + private promptDuration: number = 2000; + private wantAgentInfo: wantAgent.WantAgentInfo = { + wants: [ + { + bundleName: 'com.samples.abilityruntime', + abilityName: 'EntryAbility', + } + ], + actionType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + actionFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + } + + async getBundleNameCallback(): Promise { + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.getBundleName(dataBase, (err, data) => { + hilog.info(DOMAIN, TAG, + `The result of getBundleName(callback) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `getBundleName(callback) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + async getBundleNamePromise(): Promise { + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.getBundleName(dataBase).then((data) => { + hilog.info(DOMAIN, TAG, + `The result of getBundleName(promise) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `getBundleName(promise) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + async getUidCallback(): Promise { + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.getUid(dataBase, (err, data) => { + hilog.info(DOMAIN, TAG, + `The result of getUid(callback) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `getUid(callback) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + async getUidPromise(): Promise { + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.getUid(dataBase).then((data) => { + hilog.info(DOMAIN, TAG, + `The result of getUid(promise) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `getUid(promise) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + async cancelCallback(): Promise { + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.cancel(dataBase, (err, data) => { + hilog.info(DOMAIN, TAG, + `The result of cancel(callback) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `cancel(callback) success`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + async cancelPromise(): Promise { + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.cancel(dataBase).then((data) => { + hilog.info(DOMAIN, TAG, + `The result of cancel(promise) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `cancel(promise) success`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + async equalCallback(): Promise { + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.equal(dataBase, dataBase, (err, data) => { + hilog.info(DOMAIN, TAG, + `The result of equal(callback) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `equal(callback) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + async equalPromise(): Promise { + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.equal(dataBase, dataBase).then((data) => { + hilog.info(DOMAIN, TAG, + `The result of equal(promise) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `equal(promise) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + async getOperationTypeCallback(): Promise { + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.getOperationType(dataBase, (err, data) => { + hilog.info(DOMAIN, TAG, + `The result of getOperationType(callback) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `getOperationType(callback) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + async getOperationTypePromise(): Promise { + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.getOperationType(dataBase).then((data) => { + hilog.info(DOMAIN, TAG, + `The result of getOperationType(promise) is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `getOperationType(promise) success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + async trigger(): Promise { + let triggerInfo: wantAgent.TriggerInfo = { + code: 0, + want: { + bundleName: 'com.samples.abilityruntime', + abilityName: 'EntryAbility', + }, + permission: '', + extraInfo: { + test: 'this is a test value' + } + } + + wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => { + wantAgent.trigger(dataBase, triggerInfo, (err, data) => { + hilog.info(DOMAIN, TAG, + `The result of trigger is: ${JSON.stringify(data)}`); + promptAction.showToast({ + message: `trigger success, data: ${JSON.stringify(data)}`, + duration: this.promptDuration + }) + }) + console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`) + }) + } + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.WantAgent')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: 8, + bottom: 8, + left: 12 + }) + } + } + .width('100%') + .height('14.36%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.getBundleNameCallback`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getBundleNameCallback') + .onClick(() => { + this.getBundleNameCallback(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.getBundleNamePromise`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getBundleNamePromise') + .onClick(() => { + this.getBundleNamePromise(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.getUidCallback`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getUidCallback') + .onClick(() => { + this.getUidCallback(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.getUidPromise`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getUidPromise') + .onClick(() => { + this.getUidPromise(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.cancelCallback`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('cancelCallback') + .onClick(() => { + this.cancelCallback(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.cancelPromise`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('cancelPromise') + .onClick(() => { + this.cancelPromise(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.equalCallback`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('equalCallback') + .onClick(() => { + this.equalCallback(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.equalPromise`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('equalPromise') + .onClick(() => { + this.equalPromise(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.getOperationTypeCallback`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getOperationTypeCallback') + .onClick(() => { + this.getOperationTypeCallback(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.getOperationTypePromise`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getOperationTypePromise') + .onClick(() => { + this.getOperationTypePromise(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r(`app.string.trigger`)) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('trigger') + .onClick(() => { + this.trigger(); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entryability/EntryAbility.ets index 57f379afaf..9b1882bc13 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,88 +1,88 @@ -/* - * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -const TAG: string = 'EntryAbility'; -const DOMAIN: number = 0xFF00; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, TAG, 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, TAG, 'Ability onWindowStageCreate'); - - let windowClass: window.Window | undefined = undefined; - windowStage.getMainWindow((err: BusinessError, data) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); - return; - } - windowClass = data; - let systemBarProperties: window.SystemBarProperties = { - statusBarColor: '#f1f3f5', - navigationBarColor: '#f1f3f5', - }; - try { - windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); - }); - } catch (exception) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); - } - }); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, TAG, 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, TAG, 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, TAG, 'Ability onBackground'); - } -} +/* + * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG: string = 'EntryAbility'; +const DOMAIN: number = 0xFF00; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, TAG, 'Ability onWindowStageCreate'); + + let windowClass: window.Window | undefined = undefined; + windowStage.getMainWindow((err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + return; + } + windowClass = data; + let systemBarProperties: window.SystemBarProperties = { + statusBarColor: '#f1f3f5', + navigationBarColor: '#f1f3f5', + }; + try { + windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); + }); + } catch (exception) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); + } + }); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, TAG, 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, TAG, 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, TAG, 'Ability onBackground'); + } +} diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index b72fc477d9..dc55c03d3e 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,12 +1,12 @@ -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)); - } +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/BasicFeature/Ability/AbilityRuntime/entry/src/main/module.json5 b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/module.json5 index f7ffb1e19b..b46bb5595a 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/module.json5 +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/module.json5 @@ -1,87 +1,87 @@ -/* - * Copyright (c) 2024 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:startIcon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "recoverable": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "AbilityLifecycleAbility", - "srcEntry": "./ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets", - "description": "$string:EntryAbility_desc", - "icon": "$media:startIcon", - "label": "$string:EntryAbility_label", - "recoverable": true, - "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" - } - ] - }, - ], - } +/* + * Copyright (c) 2024 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:startIcon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "recoverable": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AbilityLifecycleAbility", + "srcEntry": "./ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:startIcon", + "label": "$string:EntryAbility_label", + "recoverable": true, + "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/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/element/color.json index 73d32c4c75..6cdb3e3002 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/element/color.json @@ -1,16 +1,16 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "backGrounding", - "value": "#f1f3f5" - }, - { - "name": "text_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "backGrounding", + "value": "#f1f3f5" + }, + { + "name": "text_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/profile/backup_config.json index d742c2f96e..78f40ae7c4 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/profile/backup_config.json +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/ohosTest/module.json5 b/code/BasicFeature/Ability/AbilityRuntime/entry/src/ohosTest/module.json5 index 93f5a2e5d6..556081afc7 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/ohosTest/module.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/BasicFeature/Ability/AbilityRuntime/hvigor/hvigor-config.json5 b/code/BasicFeature/Ability/AbilityRuntime/hvigor/hvigor-config.json5 index ab4cf8bc32..3ac9626c8b 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Ability/AbilityRuntime/hvigor/hvigor-config.json5 @@ -1,19 +1,19 @@ -/* - * Copyright (c) 2024 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": { - } +/* + * Copyright (c) 2024 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": { + } } \ No newline at end of file diff --git a/code/BasicFeature/Ability/AbilityRuntime/oh-package.json5 b/code/BasicFeature/Ability/AbilityRuntime/oh-package.json5 index 5d3d2f801c..4b93216c04 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/oh-package.json5 +++ b/code/BasicFeature/Ability/AbilityRuntime/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2024 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" - } -} +/* + * Copyright (c) 2024 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/BasicFeature/Ability/UniversalLink/AppScope/app.json5 b/code/BasicFeature/Ability/UniversalLink/AppScope/app.json5 index 036de81010..e063348523 100644 --- a/code/BasicFeature/Ability/UniversalLink/AppScope/app.json5 +++ b/code/BasicFeature/Ability/UniversalLink/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.example.universallink", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.example.universallink", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Ability/UniversalLink/AppScope/resources/base/element/string.json b/code/BasicFeature/Ability/UniversalLink/AppScope/resources/base/element/string.json index f9a2f3aa9d..c8e33e8783 100644 --- a/code/BasicFeature/Ability/UniversalLink/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Ability/UniversalLink/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "UniversalLink" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "UniversalLink" + } + ] +} diff --git a/code/BasicFeature/Ability/UniversalLink/README_zh.md b/code/BasicFeature/Ability/UniversalLink/README_zh.md index 6482300789..0009ef24e4 100644 --- a/code/BasicFeature/Ability/UniversalLink/README_zh.md +++ b/code/BasicFeature/Ability/UniversalLink/README_zh.md @@ -1,66 +1,66 @@ -# 基础能力增强 - -### 介绍 - -本示例使用 [UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md) 接口实现了通过AppLinking启动UIAbility功能。 - -### 效果预览 - -| 主页面 | 点击按钮拉起Ability | -| :----------------------------------------------: | :---------------------------------------------------: | -| | | - -### 使用说明 - -UniversalLink基础能力展示 - -1.点击主页面**openLink(promise)拉起应用**按钮,拉起新的Ability,页面显示'UniversalLink方式拉起Ability成功'; - -2.点击主页面**openLink(callback)拉起应用**按钮,拉起新的Ability,页面显示'UniversalLink方式拉起Ability成功'; - -### 工程目录 - -``` -entry/src/main/ets/ -|---entryability -| |---EntryAbility.ets // 首页的Ability -| |---OpenLinkAbility.ets // UIAbility(用于验证UniversalLink功能使用) -|---pages -| |---Index.ets // 首页(包含openLink接口的调用) -| |---UniversalLinkIndex.ets // 被启动的UIAbility的展示页 -``` - -### 具体实现 - -* UniversalLink基础能力实现,源码参考[Index.ets](entry/src/main/ets/pages/Index.ets) - - * openLink(promise)接口实现:通过调用context.openLink接口,传入与要拉起的应用相同的配置,实现拉起应用的功能; - * openLink(callback)接口实现:通过调用context.openLink接口,传入与要拉起的应用相同的配置,实现拉起应用的功能; - - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568; - -2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31; - -3.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.403, built on June 20, 2024)才可编译运行; - -### 下载 - -```shell -git init -git config core.sparsecheckout true -echo code/BasicFeature/Ability/UniversalLink/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` - +# 基础能力增强 + +### 介绍 + +本示例使用 [UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md) 接口实现了通过AppLinking启动UIAbility功能。 + +### 效果预览 + +| 主页面 | 点击按钮拉起Ability | +| :----------------------------------------------: | :---------------------------------------------------: | +| | | + +### 使用说明 + +UniversalLink基础能力展示 + +1.点击主页面**openLink(promise)拉起应用**按钮,拉起新的Ability,页面显示'UniversalLink方式拉起Ability成功'; + +2.点击主页面**openLink(callback)拉起应用**按钮,拉起新的Ability,页面显示'UniversalLink方式拉起Ability成功'; + +### 工程目录 + +``` +entry/src/main/ets/ +|---entryability +| |---EntryAbility.ets // 首页的Ability +| |---OpenLinkAbility.ets // UIAbility(用于验证UniversalLink功能使用) +|---pages +| |---Index.ets // 首页(包含openLink接口的调用) +| |---UniversalLinkIndex.ets // 被启动的UIAbility的展示页 +``` + +### 具体实现 + +* UniversalLink基础能力实现,源码参考[Index.ets](entry/src/main/ets/pages/Index.ets) + + * openLink(promise)接口实现:通过调用context.openLink接口,传入与要拉起的应用相同的配置,实现拉起应用的功能; + * openLink(callback)接口实现:通过调用context.openLink接口,传入与要拉起的应用相同的配置,实现拉起应用的功能; + + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568; + +2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31; + +3.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.403, built on June 20, 2024)才可编译运行; + +### 下载 + +```shell +git init +git config core.sparsecheckout true +echo code/BasicFeature/Ability/UniversalLink/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` + diff --git a/code/BasicFeature/Ability/UniversalLink/build-profile.json5 b/code/BasicFeature/Ability/UniversalLink/build-profile.json5 index f0b12f54c1..6774a44508 100644 --- a/code/BasicFeature/Ability/UniversalLink/build-profile.json5 +++ b/code/BasicFeature/Ability/UniversalLink/build-profile.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2024 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": 12, - "compileSdkVersion": 12, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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": 12, + "compileSdkVersion": 12, + "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/BasicFeature/Ability/UniversalLink/entry/build-profile.json5 b/code/BasicFeature/Ability/UniversalLink/entry/build-profile.json5 index 97f563b45a..63b88fb1a0 100644 --- a/code/BasicFeature/Ability/UniversalLink/entry/build-profile.json5 +++ b/code/BasicFeature/Ability/UniversalLink/entry/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2024 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", - } - ] +/* + * Copyright (c) 2024 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/BasicFeature/Ability/UniversalLink/entry/oh-package.json5 b/code/BasicFeature/Ability/UniversalLink/entry/oh-package.json5 index 41a4755f66..4e54d14e1b 100644 --- a/code/BasicFeature/Ability/UniversalLink/entry/oh-package.json5 +++ b/code/BasicFeature/Ability/UniversalLink/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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": {} -} - +/* + * Copyright (c) 2024 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/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/EntryAbility.ets index 3722d79ef8..08928746d7 100644 --- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,88 +1,88 @@ -/* - * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; -import { BusinessError } from '@kit.BasicServicesKit'; - -const TAG: string = '[EntryAbility]'; -const DOMAIN: number = 0xFF00; - -export default class EntryAbility extends UIAbility { - onCreate(): void { - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - let windowClass: window.Window | undefined = undefined; - windowStage.getMainWindow((err: BusinessError, data) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); - return; - } - windowClass = data; - let systemBarProperties: window.SystemBarProperties = { - statusBarColor: '#f1f3f5', - navigationBarColor: '#f1f3f5', - }; - try { - windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); - }); - } catch (exception) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); - } - }); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.info(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +const TAG: string = '[EntryAbility]'; +const DOMAIN: number = 0xFF00; + +export default class EntryAbility extends UIAbility { + onCreate(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + let windowClass: window.Window | undefined = undefined; + windowStage.getMainWindow((err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + return; + } + windowClass = data; + let systemBarProperties: window.SystemBarProperties = { + statusBarColor: '#f1f3f5', + navigationBarColor: '#f1f3f5', + }; + try { + windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); + }); + } catch (exception) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); + } + }); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.info(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/OpenLinkAbility.ets b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/OpenLinkAbility.ets index 08686c3818..e836d7f74c 100644 --- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/OpenLinkAbility.ets +++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/OpenLinkAbility.ets @@ -1,86 +1,86 @@ -/* - * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; -import { UIAbility } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -const TAG: string = '[OpenLinkAbility]'; -const DOMAIN: number = 0xFF00; - -export default class OpenLinkAbility extends UIAbility { - onCreate(): void { - hilog.info(DOMAIN, TAG, '%{public}s', 'OpenLinkAbility onCreate'); - } - - onForeground() { - hilog.info(DOMAIN, TAG, `OpenLinkAbility onForeground`); - } - - onBackground() { - hilog.info(DOMAIN, TAG, `OpenLinkAbility onBackground`); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, TAG, '%{public}s', 'OpenLinkAbility onWindowStageCreate'); - - let windowClass: window.Window | undefined = undefined; - windowStage.getMainWindow((err: BusinessError, data) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); - return; - } - windowClass = data; - let systemBarProperties: window.SystemBarProperties = { - statusBarColor: '#f1f3f5', - navigationBarColor: '#f1f3f5', - }; - try { - windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); - }); - } catch (exception) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); - } - }); - - windowStage.loadContent('pages/UniversalLinkIndex', (err) => { - if (err.code) { - hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); - }); - } - - onDestroy(): void { - hilog.info(DOMAIN, TAG, 'OpenLinkAbility onDestroy'); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, TAG, 'OpenLinkAbility onWindowStageDestroy'); - } +/* + * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; +import { UIAbility } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG: string = '[OpenLinkAbility]'; +const DOMAIN: number = 0xFF00; + +export default class OpenLinkAbility extends UIAbility { + onCreate(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'OpenLinkAbility onCreate'); + } + + onForeground() { + hilog.info(DOMAIN, TAG, `OpenLinkAbility onForeground`); + } + + onBackground() { + hilog.info(DOMAIN, TAG, `OpenLinkAbility onBackground`); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, TAG, '%{public}s', 'OpenLinkAbility onWindowStageCreate'); + + let windowClass: window.Window | undefined = undefined; + windowStage.getMainWindow((err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + return; + } + windowClass = data; + let systemBarProperties: window.SystemBarProperties = { + statusBarColor: '#f1f3f5', + navigationBarColor: '#f1f3f5', + }; + try { + windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); + }); + } catch (exception) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); + } + }); + + windowStage.loadContent('pages/UniversalLinkIndex', (err) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, 'OpenLinkAbility onDestroy'); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, TAG, 'OpenLinkAbility onWindowStageDestroy'); + } }; \ No newline at end of file diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index b72fc477d9..dc55c03d3e 100644 --- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,12 +1,12 @@ -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)); - } +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/BasicFeature/Ability/UniversalLink/entry/src/main/ets/pages/UniversalLinkIndex.ets b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/pages/UniversalLinkIndex.ets index 6c706d3e12..b86832a068 100644 --- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/pages/UniversalLinkIndex.ets +++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/pages/UniversalLinkIndex.ets @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2024 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 UniversalLinkIndex { - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.OpenLinkTitle')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - } - } - .width('100%') - .height('80%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } -} +/* + * Copyright (c) 2024 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 UniversalLinkIndex { + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.OpenLinkTitle')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + } + } + .width('100%') + .height('80%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } +} diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/main/module.json5 b/code/BasicFeature/Ability/UniversalLink/entry/src/main/module.json5 index 5c5e88d321..1e83bc34d3 100644 --- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/module.json5 +++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/module.json5 @@ -1,97 +1,97 @@ -/* - * Copyright (c) 2024 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:startIcon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "OpenLinkAbility", - "srcEntry": "./ets/entryability/OpenLinkAbility.ets", - "description": "uri", - "icon": "$media:layered_image", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "entities": [ - "entity.system.home", - "entity.system.browsable" - ], - "actions": [ - "action.system.home", - "ohos.want.action.viewData" - ], - "uris": [ - { - // scheme可以自定义 - "scheme": "http", - // host须配置关联的域名 - "host": "docs.openharmony.cn", - // path可选,为了避免匹配到多个应用,建议配置该字段 - "path": "" - } - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "EntryBackupAbility", - "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", - "type": "backup", - "exported": false, - "metadata": [ - { - "name": "ohos.extension.backup", - "resource": "$profile:backup_config" - } - ] - } - ] - } +/* + * Copyright (c) 2024 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:startIcon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "OpenLinkAbility", + "srcEntry": "./ets/entryability/OpenLinkAbility.ets", + "description": "uri", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "entities": [ + "entity.system.home", + "entity.system.browsable" + ], + "actions": [ + "action.system.home", + "ohos.want.action.viewData" + ], + "uris": [ + { + // scheme可以自定义 + "scheme": "http", + // host须配置关联的域名 + "host": "docs.openharmony.cn", + // path可选,为了避免匹配到多个应用,建议配置该字段 + "path": "" + } + ] + } + ] + } + ], + "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/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/element/color.json index 73d32c4c75..6cdb3e3002 100644 --- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/element/color.json @@ -1,16 +1,16 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "backGrounding", - "value": "#f1f3f5" - }, - { - "name": "text_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "backGrounding", + "value": "#f1f3f5" + }, + { + "name": "text_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/profile/backup_config.json index d742c2f96e..78f40ae7c4 100644 --- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/profile/backup_config.json +++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/ohosTest/module.json5 b/code/BasicFeature/Ability/UniversalLink/entry/src/ohosTest/module.json5 index 1f646ea03f..5f63462032 100644 --- a/code/BasicFeature/Ability/UniversalLink/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Ability/UniversalLink/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/BasicFeature/Ability/UniversalLink/hvigor/hvigor-config.json5 b/code/BasicFeature/Ability/UniversalLink/hvigor/hvigor-config.json5 index 5f9d8a5758..76e3231223 100644 --- a/code/BasicFeature/Ability/UniversalLink/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Ability/UniversalLink/hvigor/hvigor-config.json5 @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2024 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*/ - } -} +/* + * Copyright (c) 2024 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/BasicFeature/Ability/UniversalLink/oh-package.json5 b/code/BasicFeature/Ability/UniversalLink/oh-package.json5 index d645a02be5..a941f44583 100644 --- a/code/BasicFeature/Ability/UniversalLink/oh-package.json5 +++ b/code/BasicFeature/Ability/UniversalLink/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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" - } -} +/* + * Copyright (c) 2024 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/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/app.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/app.json5 old mode 100755 new mode 100644 index 9933eb9fd5..8a01fbc442 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/app.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.bundlemanagement", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.bundlemanagement", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 5987cf90b2..6e551034bf --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "bundleManagement" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "bundleManagement" + } + ] +} diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/media/app_icon.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/README_zh.md b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/README_zh.md old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/build-profile.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/build-profile.json5 old mode 100755 new mode 100644 index b38a57b105..f2e5bbf7ea --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/build-profile.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/build-profile.json5 @@ -1,67 +1,67 @@ -/** - * Copyright (c) 2024 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", - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "libraryOverlay", - "srcPath": "./libraryOverlay", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "libraryRuntimeOverlay", - "srcPath": "./libraryRuntimeOverlay", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} +/** + * Copyright (c) 2024 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", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "libraryOverlay", + "srcPath": "./libraryOverlay", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "libraryRuntimeOverlay", + "srcPath": "./libraryRuntimeOverlay", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/build-profile.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/build-profile.json5 old mode 100755 new mode 100644 index f6cbf2f1e1..85d986b1fc --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/build-profile.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/build-profile.json5 @@ -1,28 +1,28 @@ -/* -* Copyright (c) 2024 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": { - }, - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* +* Copyright (c) 2024 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": { + }, + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/hvigorfile.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/oh-package.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/oh-package.json5 old mode 100755 new mode 100644 index 57a65bc499..bf70bbf466 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/oh-package.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/oh-package.json5 @@ -1,13 +1,13 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": { - "libraryOverlay": "file:../libraryOverlay", - "libraryRuntimeOverlay": "file:../libraryRuntimeOverlay" - } -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": { + "libraryOverlay": "file:../libraryOverlay", + "libraryRuntimeOverlay": "file:../libraryRuntimeOverlay" + } +} diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/entryability/EntryAbility.ts old mode 100755 new mode 100644 index 40c6f70ca4..e4316af591 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'entryAbility'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - } - - onDestroy() { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - - windowStage.getMainWindow((err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); - return; - } - let windowClass = data; - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); - - let SystemBarProperties = { - statusBarColor: "#f1f3f5", - navigationBarColor: "#f1f3f5" - }; - windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in setting the system bar properties.'); - }); - }) - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground'); - } - - onBackground() { - // Ability has back to background - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'entryAbility'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + + windowStage.getMainWindow((err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + return; + } + let windowClass = data; + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); + + let SystemBarProperties = { + statusBarColor: "#f1f3f5", + navigationBarColor: "#f1f3f5" + }; + windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in setting the system bar properties.'); + }); + }) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newability/NewAbility.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newability/NewAbility.ts old mode 100755 new mode 100644 index 587e40dce9..3d4d389046 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newability/NewAbility.ts +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newability/NewAbility.ts @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'newAbility'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class NewAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onCreate'); - } - - onDestroy() { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onWindowStageCreate'); - - windowStage.loadContent('pages/NewPage', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onForeground'); - } - - onBackground() { - // Ability has back to background - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onBackground'); - } +/* + * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'newAbility'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class NewAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onCreate'); + } + + onDestroy() { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onWindowStageCreate'); + + windowStage.loadContent('pages/NewPage', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onBackground'); + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newuiextability/NewUIExtAbility.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newuiextability/NewUIExtAbility.ets old mode 100755 new mode 100644 index 2722952497..c78ee21470 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newuiextability/NewUIExtAbility.ets +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newuiextability/NewUIExtAbility.ets @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2024 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 { Want, UIExtensionAbility, UIExtensionContentSession } from '@kit.AbilityKit'; - -export default class NewUIExtAbility extends UIExtensionAbility { - onCreate() { - } - - onDestroy() { - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - let param: Record = { - 'session': session, - 'want': want - }; - - let storage: LocalStorage = new LocalStorage(param); - session.loadContent('pages/NewPage', storage); - } - - onForeground() { - // Ability has brought to foreground - } - - onBackground() { - // Ability has back to background - } +/* + * Copyright (c) 2024 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 { Want, UIExtensionAbility, UIExtensionContentSession } from '@kit.AbilityKit'; + +export default class NewUIExtAbility extends UIExtensionAbility { + onCreate() { + } + + onDestroy() { + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + let param: Record = { + 'session': session, + 'want': want + }; + + let storage: LocalStorage = new LocalStorage(param); + session.loadContent('pages/NewPage', storage); + } + + onForeground() { + // Ability has brought to foreground + } + + onBackground() { + // Ability has back to background + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/NewPage.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/NewPage.ets old mode 100755 new mode 100644 index 9cab3d3b3e..93826059c7 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/NewPage.ets +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/NewPage.ets @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2024 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 { common } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = '[Sample_ShortCut]'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct NewPage { - private context = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Image($r('app.media.ic_back')) - .size({ width: 20, height: 18 }) - .margin({ right: 18 }) - .onClick(() => { - this.context.terminateSelf(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'terminateSelf'); - }) - }) - Text($r('app.string.NewAbility_label')) - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.height(56) - .padding({ left: 26, right: 26 }) - .width('100%') - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { - Column() { - Image($r('app.media.pic_empty')).width('33%') - Text($r('app.string.empty')) - .fontSize(14) - } - }.width('100%') - .height('90%') - } - .width('100%') - .height('100%') - .padding({ top: 36, bottom: 0 }) - .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) - } +/* + * Copyright (c) 2024 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 { common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = '[Sample_ShortCut]'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct NewPage { + private context = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Image($r('app.media.ic_back')) + .size({ width: 20, height: 18 }) + .margin({ right: 18 }) + .onClick(() => { + this.context.terminateSelf(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'terminateSelf'); + }) + }) + Text($r('app.string.NewAbility_label')) + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.height(56) + .padding({ left: 26, right: 26 }) + .width('100%') + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { + Column() { + Image($r('app.media.pic_empty')).width('33%') + Text($r('app.string.empty')) + .fontSize(14) + } + }.width('100%') + .height('90%') + } + .width('100%') + .height('100%') + .padding({ top: 36, bottom: 0 }) + .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/module.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/module.json5 old mode 100755 new mode 100644 index cc8bd34fc2..b6e22c8236 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/module.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/module.json5 @@ -1,102 +1,102 @@ -/* - * Copyright (c) 2024 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ], - "uris": [ - { - "scheme": "http" - } - ] - } - ], - "metadata": [ - { - "name": "ohos.ability.shortcuts", - "resource": "$profile:shortcuts_config" - } - ] - }, - { - "name": "NewAbility", - "srcEntry": "./ets/newability/NewAbility.ts", - "description": "$string:NewAbility_desc", - "icon": "$media:icon", - "label": "$string:NewAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "metadata": [ - { - "name": "ohos.ability.NewAbility", - "resource": "$profile:shortcuts_config" - } - ] - } - ], - "extensionAbilities": [ - { - "name": "NewUIExtAbility", - "icon": "$media:icon", - "description": "NewUIExtAbility", - "exported": true, - "type": "sysPicker/share", - "srcEntry": "./ets/newuiextability/NewUIExtAbility.ets", - "metadata": [ - { - "name": "ohos.ability.NewUIExtAbility", - "resource": "$profile:shortcuts_config" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.RUN_DYN_CODE", - } - ], - "querySchemes": [ - "http" - ] - } +/* + * Copyright (c) 2024 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ], + "uris": [ + { + "scheme": "http" + } + ] + } + ], + "metadata": [ + { + "name": "ohos.ability.shortcuts", + "resource": "$profile:shortcuts_config" + } + ] + }, + { + "name": "NewAbility", + "srcEntry": "./ets/newability/NewAbility.ts", + "description": "$string:NewAbility_desc", + "icon": "$media:icon", + "label": "$string:NewAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "metadata": [ + { + "name": "ohos.ability.NewAbility", + "resource": "$profile:shortcuts_config" + } + ] + } + ], + "extensionAbilities": [ + { + "name": "NewUIExtAbility", + "icon": "$media:icon", + "description": "NewUIExtAbility", + "exported": true, + "type": "sysPicker/share", + "srcEntry": "./ets/newuiextability/NewUIExtAbility.ets", + "metadata": [ + { + "name": "ohos.ability.NewUIExtAbility", + "resource": "$profile:shortcuts_config" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.RUN_DYN_CODE", + } + ], + "querySchemes": [ + "http" + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index 397f3ddb2b..8fe12b6f07 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/color.json @@ -1,20 +1,20 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "button_color", - "value": "#027DFF" - }, - { - "name": "backGrounding", - "value": "#f1f3f5" - }, - { - "name": "text_color", - "value": "#000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "button_color", + "value": "#027DFF" + }, + { + "name": "backGrounding", + "value": "#f1f3f5" + }, + { + "name": "text_color", + "value": "#000" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/ic_back.svg b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/ic_back.svg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/icon.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/pic_empty.svg b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/pic_empty.svg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/profile/shortcuts_config.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/profile/shortcuts_config.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testability/TestAbility.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testability/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/module.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 0ea2ffbd55..91e15a07ae --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* -* Copyright (c) 2024 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/element/color.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/media/icon.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/media/icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/profile/test_pages.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/en_US/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/zh_CN/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-config.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index fb29482d10..9a79085076 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-wrapper.js b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-wrapper.js old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorfile.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw.bat b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw.bat old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/build-profile.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/build-profile.json5 old mode 100755 new mode 100644 index 28dd9a05d1..26d4447c11 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/build-profile.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/build-profile.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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": { - }, - "targets": [ - { - "name": "default" - } - ] +/* + * Copyright (c) 2024 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": { + }, + "targets": [ + { + "name": "default" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/hvigorfile.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/oh-package.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/oh-package.json5 old mode 100755 new mode 100644 index 2c177c4b11..8921a9e7f6 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/oh-package.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "Apache-2.0", - "devDependencies": {}, - "author": "", - "name": "libraryOverlay", - "description": "Please describe the basic information.", - "main": "./src/main/ets/Index.ets", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "Apache-2.0", + "devDependencies": {}, + "author": "", + "name": "libraryOverlay", + "description": "Please describe the basic information.", + "main": "./src/main/ets/Index.ets", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/Index.ets old mode 100755 new mode 100644 index ac3645ba79..8facc0b5e7 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/Index.ets +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/Index.ets @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2024 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. - */ - +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export { add } from './utils/Calc' \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/pages/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/utils/Calc.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/utils/Calc.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/module.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/module.json5 old mode 100755 new mode 100644 index 35e810f31b..e576fbd6bd --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/module.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/module.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2024 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": "libraryOverlay", - "type": "shared", - "description": "$string:shared_desc", - "targetModuleName":"entry", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" - } +/* + * Copyright (c) 2024 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": "libraryOverlay", + "type": "shared", + "description": "$string:shared_desc", + "targetModuleName":"entry", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "pages": "$profile:main_pages" + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/color.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index 8ff4fc989c..e5e5574f73 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/string.json +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/string.json @@ -1,12 +1,12 @@ -{ - "string": [ - { - "name": "shared_desc", - "value": "description" - }, - { - "name": "test_string", - "value": "base_overlay_test" - } - ] +{ + "string": [ + { + "name": "shared_desc", + "value": "description" + }, + { + "name": "test_string", + "value": "base_overlay_test" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/icon.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/setting.jpeg b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/setting.jpeg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/en_US/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/build-profile.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/build-profile.json5 old mode 100755 new mode 100644 index 28dd9a05d1..26d4447c11 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/build-profile.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/build-profile.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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": { - }, - "targets": [ - { - "name": "default" - } - ] +/* + * Copyright (c) 2024 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": { + }, + "targets": [ + { + "name": "default" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/hvigorfile.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/oh-package.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/oh-package.json5 old mode 100755 new mode 100644 index 52496b1d38..fff6109ffb --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/oh-package.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "Apache-2.0", - "devDependencies": {}, - "author": "", - "name": "libraryRuntimeOverlay", - "description": "Please describe the basic information.", - "main": "./src/main/ets/Index.ets", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "Apache-2.0", + "devDependencies": {}, + "author": "", + "name": "libraryRuntimeOverlay", + "description": "Please describe the basic information.", + "main": "./src/main/ets/Index.ets", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/Index.ets old mode 100755 new mode 100644 index ac3645ba79..8facc0b5e7 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/Index.ets +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/Index.ets @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2024 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. - */ - +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export { add } from './utils/Calc' \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/pages/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/utils/Calc.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/utils/Calc.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/module.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/module.json5 old mode 100755 new mode 100644 index b431873677..f110da5073 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/module.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/module.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2024 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": "libraryRuntimeOverlay", - "type": "shared", - "description": "$string:shared_desc", - "targetModuleName":"entry", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" - } +/* + * Copyright (c) 2024 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": "libraryRuntimeOverlay", + "type": "shared", + "description": "$string:shared_desc", + "targetModuleName":"entry", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "pages": "$profile:main_pages" + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/color.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index 6175c8ac06..9996631913 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/string.json +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/string.json @@ -1,12 +1,12 @@ -{ - "string": [ - { - "name": "shared_desc", - "value": "description" - }, - { - "name": "test_string", - "value": "en_US_overlay_RUNTIME" - } - ] +{ + "string": [ + { + "name": "shared_desc", + "value": "description" + }, + { + "name": "test_string", + "value": "en_US_overlay_RUNTIME" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/icon.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/setting.jpeg b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/setting.jpeg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/en_US/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/oh-package.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/oh-package.json5 old mode 100755 new mode 100644 index 5092a626e5..6faa9e99fc --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/oh-package.json5 +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "shortcut", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "shortcut", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/ohosTest.md b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/Scene-directory.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/Scene-directory.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/snapshot_directory.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/snapshot_directory.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/app.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/app.json5 index 375c5a9b4b..615d9c69bc 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/app.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/app.json5 @@ -1,24 +1,24 @@ -/* -* Copyright (C) 2024 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.navigation", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* +* Copyright (C) 2024 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.navigation", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/resources/base/element/string.json index f2fd092934..03ada0a8e4 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "Navigation" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "Navigation" + } + ] +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/README_zh.md b/code/BasicFeature/ApplicationModels/DynamicRouter/README_zh.md index e149ceff52..2e2b728c43 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/README_zh.md +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/README_zh.md @@ -1,86 +1,86 @@ -# Navigation动态路由 - -### 介绍 - -本项目提供动态路由的验证,运用了WrapperBuilder的自定义函数打包能力,以及动态路由的跨模块文件引用的能力,解除了har包和hap包的依赖关系,实现了 -即使hap包不引用har包,依然能跳转到har包中的页面的能力 -目前还不支持动态import变量表达式和跨模块相对路径的文件,所以代码中使用switch作为替代,若后续版本支持,会出相应的补丁 -由于环境的差异,不建议下载后直接编译,应先当创建项目,参考示例代码进行编写 - -### 效果预览 -![image](images/Index.jpg) -![image](images/HarA.jpg) -![image](images/HarB.jpg) - -使用说明 - -1. 主页会提供一个NavIndex的导航页,点击按钮会跳转到不同的来自har包的页面 - -2. 每个har包的页面也存在跳转到别的页面的按钮 - -### 工程目录 - -``` -. -├── entry // 主页面 -│ ├── pages -│ │ ├── Index.ets -│ ├── entryability -│ │ ├── EntryAbility.ets -├── harA -│ ├── pages -│ │ ├── page1.ets -│ │ ├── page2.ets -│ │ ├── page3.ets -│ ├── entryability -│ │ ├── EntryAbility.ets -├── harB -│ ├── pages -│ │ ├── page1.ets -│ │ ├── page2.ets -│ │ ├── page3.ets -│ ├── entryability -│ │ ├── EntryAbility.ets -├── RouterModule -│ ├── utils -│ │ ├── RouterModule.ets -│ ├── entryability -│ │ ├── EntryAbility.ets -. -``` - -### 具体实现 - -1.创建hapA harA harB - -2.创建路由框架RouterModule,使用map存储hap包的路由和har包的页面信息 - -3.在RouterModule中封装get和set方法,并对外开放,允许外部模块引用和调用 - -4.创建push方法,允许传入一串url,并对其进行解析,通过拆解出路由名称从map中获取到路由栈,并将目标页面压栈 - -5.在hap和har包中引入RouterModule,将hap包的路由栈和har包的页面信息通过开放的set方法存入RouterModule - -### 相关权限 - -不涉及 - -### 约束与限制 - -1. 本示例仅支持标准系统上运行,支持设备:RK3568。 - -2. 本示例需要使用DevEco Studio 版本号(Build Version: 4.1.1.500, built on January 21, 2024)及以上版本才可编译运行。 - -3. 本示例为Stage模型,支持API11版本SDK,SDK版本号(4.1.6.3以上),镜像版本号(4.1.6.3以上)。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/BasicFeature/ApplicationModels/DynamicRouter > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` +# Navigation动态路由 + +### 介绍 + +本项目提供动态路由的验证,运用了WrapperBuilder的自定义函数打包能力,以及动态路由的跨模块文件引用的能力,解除了har包和hap包的依赖关系,实现了 +即使hap包不引用har包,依然能跳转到har包中的页面的能力 +目前还不支持动态import变量表达式和跨模块相对路径的文件,所以代码中使用switch作为替代,若后续版本支持,会出相应的补丁 +由于环境的差异,不建议下载后直接编译,应先当创建项目,参考示例代码进行编写 + +### 效果预览 +![image](images/Index.jpg) +![image](images/HarA.jpg) +![image](images/HarB.jpg) + +使用说明 + +1. 主页会提供一个NavIndex的导航页,点击按钮会跳转到不同的来自har包的页面 + +2. 每个har包的页面也存在跳转到别的页面的按钮 + +### 工程目录 + +``` +. +├── entry // 主页面 +│ ├── pages +│ │ ├── Index.ets +│ ├── entryability +│ │ ├── EntryAbility.ets +├── harA +│ ├── pages +│ │ ├── page1.ets +│ │ ├── page2.ets +│ │ ├── page3.ets +│ ├── entryability +│ │ ├── EntryAbility.ets +├── harB +│ ├── pages +│ │ ├── page1.ets +│ │ ├── page2.ets +│ │ ├── page3.ets +│ ├── entryability +│ │ ├── EntryAbility.ets +├── RouterModule +│ ├── utils +│ │ ├── RouterModule.ets +│ ├── entryability +│ │ ├── EntryAbility.ets +. +``` + +### 具体实现 + +1.创建hapA harA harB + +2.创建路由框架RouterModule,使用map存储hap包的路由和har包的页面信息 + +3.在RouterModule中封装get和set方法,并对外开放,允许外部模块引用和调用 + +4.创建push方法,允许传入一串url,并对其进行解析,通过拆解出路由名称从map中获取到路由栈,并将目标页面压栈 + +5.在hap和har包中引入RouterModule,将hap包的路由栈和har包的页面信息通过开放的set方法存入RouterModule + +### 相关权限 + +不涉及 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:RK3568。 + +2. 本示例需要使用DevEco Studio 版本号(Build Version: 4.1.1.500, built on January 21, 2024)及以上版本才可编译运行。 + +3. 本示例为Stage模型,支持API11版本SDK,SDK版本号(4.1.6.3以上),镜像版本号(4.1.6.3以上)。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/BasicFeature/ApplicationModels/DynamicRouter > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/Index.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/Index.ets index f5920d2bb6..e1547ce35a 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/Index.ets +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/Index.ets @@ -1,14 +1,14 @@ -/* -* Copyright (C) 2024 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. -*/ +/* +* Copyright (C) 2024 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. +*/ diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/build-profile.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/build-profile.json5 index ac6f2b3a18..6a29181242 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/build-profile.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/build-profile.json5 @@ -1,24 +1,24 @@ -/* -* Copyright (C) 2024 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": { - }, - "targets": [ - { - "name": "default" - } - ] -} +/* +* Copyright (C) 2024 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": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/oh-package.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/oh-package.json5 index 1be403cb8b..e71c1f8b1f 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/oh-package.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/oh-package.json5 @@ -1,24 +1,24 @@ -/* -* Copyright (C) 2024 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. -*/ -{ - "license": "Apache-2.0", - "devDependencies": {}, - "author": "", - "name": "routermodule", - "description": "Please describe the basic information.", - "main": "Index.ets", - "version": "1.0.0", - "dependencies": {} -} +/* +* Copyright (C) 2024 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. +*/ +{ + "license": "Apache-2.0", + "devDependencies": {}, + "author": "", + "name": "routermodule", + "description": "Please describe the basic information.", + "main": "Index.ets", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/ets/utils/RouterModule.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/ets/utils/RouterModule.ets index a6c3b72b49..5c2269bf63 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/ets/utils/RouterModule.ets +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/ets/utils/RouterModule.ets @@ -1,72 +1,72 @@ -/* -* Copyright (C) 2024 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 class RouterModule { - static builderMap: Map> = new Map>(); - static routerMap: Map = new Map(); - - // 通过名称注册builder - public static registerBuilder(builderName: string, builder: WrappedBuilder<[object]>): void{ - RouterModule.builderMap.set(builderName, builder); - } - - // 通过名称获取builder - public static getBuilder(builderName: string): WrappedBuilder<[object]>{ - let builder = RouterModule.builderMap.get(builderName); - return builder as WrappedBuilder<[object]>; - } - - // 通过名称注册router - public static createRouter(routerName: string, router: NavPathStack): void{ - RouterModule.routerMap.set(routerName, router); - } - - // 通过名称获取router - public static getRouter(routerName: string): NavPathStack{ - let router = RouterModule.routerMap.get(routerName); - return router as NavPathStack; - } - - // 通过获取页面栈跳转到指定页面 - public static async push(url: string): Promise{ - // 分解url - // 获取包名、路由名、页面名 - let params = url.split("/"); - const harName = params[0]; - let context = params[params.length - 1].split("-"); - const routerName = context[0]; - const builderName = context[1]; - // 获取路径 - let path = "."; - for (let i = 1; i < params.length - 1; i++) { - path += "/" + params[i]; - } - // 动态引入要跳转的页面 - let ns: ESObject = await import(harName); - ns.harInit(path); - RouterModule.getRouter(routerName).pushPathByName(builderName, null); - } - - // 通过获取页面栈并pop - public static pop(routerName: string): void { - // 查找到对应的路由栈进行pop - RouterModule.getRouter(routerName).pop(); - } - - // 通过获取页面栈并将其清空 - public static clear(routerName: string): void { - // 查找到对应的路由栈进行pop - RouterModule.getRouter(routerName).clear(); - } -} +/* +* Copyright (C) 2024 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 class RouterModule { + static builderMap: Map> = new Map>(); + static routerMap: Map = new Map(); + + // 通过名称注册builder + public static registerBuilder(builderName: string, builder: WrappedBuilder<[object]>): void{ + RouterModule.builderMap.set(builderName, builder); + } + + // 通过名称获取builder + public static getBuilder(builderName: string): WrappedBuilder<[object]>{ + let builder = RouterModule.builderMap.get(builderName); + return builder as WrappedBuilder<[object]>; + } + + // 通过名称注册router + public static createRouter(routerName: string, router: NavPathStack): void{ + RouterModule.routerMap.set(routerName, router); + } + + // 通过名称获取router + public static getRouter(routerName: string): NavPathStack{ + let router = RouterModule.routerMap.get(routerName); + return router as NavPathStack; + } + + // 通过获取页面栈跳转到指定页面 + public static async push(url: string): Promise{ + // 分解url + // 获取包名、路由名、页面名 + let params = url.split("/"); + const harName = params[0]; + let context = params[params.length - 1].split("-"); + const routerName = context[0]; + const builderName = context[1]; + // 获取路径 + let path = "."; + for (let i = 1; i < params.length - 1; i++) { + path += "/" + params[i]; + } + // 动态引入要跳转的页面 + let ns: ESObject = await import(harName); + ns.harInit(path); + RouterModule.getRouter(routerName).pushPathByName(builderName, null); + } + + // 通过获取页面栈并pop + public static pop(routerName: string): void { + // 查找到对应的路由栈进行pop + RouterModule.getRouter(routerName).pop(); + } + + // 通过获取页面栈并将其清空 + public static clear(routerName: string): void { + // 查找到对应的路由栈进行pop + RouterModule.getRouter(routerName).clear(); + } +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/module.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/module.json5 index 8d6911a8ce..e72c17c68e 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/module.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/module.json5 @@ -1,24 +1,24 @@ -/* -* Copyright (C) 2024 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": "RouterModule", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } +/* +* Copyright (C) 2024 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": "RouterModule", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/build-profile.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/build-profile.json5 index 774f06a9c7..08a3adf541 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/build-profile.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/build-profile.json5 @@ -1,53 +1,53 @@ -/* -* Copyright (C) 2024 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "runtimeOS": "OpenHarmony", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11 - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "harA", - "srcPath": "./harA" - }, - { - "name": "harB", - "srcPath": "./harB" - }, - { - "name": "RouterModule", - "srcPath": "./RouterModule" - } - ] +/* +* Copyright (C) 2024 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "runtimeOS": "OpenHarmony", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11 + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "harA", + "srcPath": "./harA" + }, + { + "name": "harB", + "srcPath": "./harB" + }, + { + "name": "RouterModule", + "srcPath": "./RouterModule" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/build-profile.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/build-profile.json5 index 8a11f78124..5afd0f621b 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/build-profile.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/build-profile.json5 @@ -1,37 +1,37 @@ -/* -* Copyright (C) 2024 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": { - "arkOptions": { - "runtimeOnly": { - "sources": [ - ], - "packages": [ - "HarA", - "HarB" - ] - } - } - }, - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* +* Copyright (C) 2024 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": { + "arkOptions": { + "runtimeOnly": { + "sources": [ + ], + "packages": [ + "HarA", + "HarB" + ] + } + } + }, + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package-lock.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package-lock.json5 index 6262463277..4413194cad 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package-lock.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package-lock.json5 @@ -1,43 +1,43 @@ -/* -* Copyright (C) 2024 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. -*/ -{ - "lockfileVersion": 3, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "HarB@../harB": "HarB@../harB", - "RouterModule@../RouterModule": "RouterModule@../RouterModule", - "HarA@../harA": "HarA@../harA" - }, - "packages": { - "HarB@../harB": { - "mtime": "1707210920658.4658", - "resolved": "../harB", - "dependencies": { - "RouterModule": "file:../RouterModule" - } - }, - "RouterModule@../RouterModule": { - "mtime": "1707210724992.75", - "resolved": "../RouterModule" - }, - "HarA@../harA": { - "mtime": "1707210916733.4844", - "resolved": "../harA", - "dependencies": { - "RouterModule": "file:../RouterModule" - } - } - } +/* +* Copyright (C) 2024 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. +*/ +{ + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "HarB@../harB": "HarB@../harB", + "RouterModule@../RouterModule": "RouterModule@../RouterModule", + "HarA@../harA": "HarA@../harA" + }, + "packages": { + "HarB@../harB": { + "mtime": "1707210920658.4658", + "resolved": "../harB", + "dependencies": { + "RouterModule": "file:../RouterModule" + } + }, + "RouterModule@../RouterModule": { + "mtime": "1707210724992.75", + "resolved": "../RouterModule" + }, + "HarA@../harA": { + "mtime": "1707210916733.4844", + "resolved": "../harA", + "dependencies": { + "RouterModule": "file:../RouterModule" + } + } + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package.json5 index 73a404a398..f95a2f9fba 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package.json5 @@ -1,28 +1,28 @@ -/* -* Copyright (C) 2024 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. -*/ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": { - "RouterModule": "file:../RouterModule", - "HarA": "file:../harA", - "HarB": "file:../harB" - } -} +/* +* Copyright (C) 2024 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. +*/ +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": { + "RouterModule": "file:../RouterModule", + "HarA": "file:../harA", + "HarB": "file:../harB" + } +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/ets/entryability/EntryAbility.ts index 42252a5bd2..0037532ae8 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,57 +1,57 @@ -/* -* Copyright (C) 2024 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 from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, 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(): 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'); - } -} +/* +* Copyright (C) 2024 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 from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, 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(): 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/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/module.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/module.json5 index 89ec46f039..11e428235e 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/module.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/module.json5 @@ -1,51 +1,51 @@ -/* -* Copyright (C) 2024 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* +* Copyright (C) 2024 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/ohosTest/module.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/ohosTest/module.json5 index 7c9a2ac3fb..4a6cc8c2cc 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* -* Copyright (C) 2024 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/Index.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/Index.ets index b739b34f38..e68e860c43 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/Index.ets +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/Index.ets @@ -1,30 +1,30 @@ -/* -* Copyright (C) 2024 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -export function harInit(path: string): void{ - // 动态引入要跳转的页面 - switch (path) { - case "./src/main/ets/components/mainpage/page1": - import("./src/main/ets/components/mainpage/page1"); - break; - case "./src/main/ets/components/mainpage/page2": - import("./src/main/ets/components/mainpage/page2"); - break; - case "./src/main/ets/components/mainpage/page3": - import("./src/main/ets/components/mainpage/page3"); - break; - default: - break; - } -} +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +export function harInit(path: string): void{ + // 动态引入要跳转的页面 + switch (path) { + case "./src/main/ets/components/mainpage/page1": + import("./src/main/ets/components/mainpage/page1"); + break; + case "./src/main/ets/components/mainpage/page2": + import("./src/main/ets/components/mainpage/page2"); + break; + case "./src/main/ets/components/mainpage/page3": + import("./src/main/ets/components/mainpage/page3"); + break; + default: + break; + } +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/build-profile.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/build-profile.json5 index ac6f2b3a18..6a29181242 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/build-profile.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/build-profile.json5 @@ -1,24 +1,24 @@ -/* -* Copyright (C) 2024 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": { - }, - "targets": [ - { - "name": "default" - } - ] -} +/* +* Copyright (C) 2024 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": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package-lock.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package-lock.json5 index 595baf01e1..4d162199c6 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package-lock.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package-lock.json5 @@ -1,27 +1,27 @@ -/* -* Copyright (C) 2024 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. -*/ -{ - "lockfileVersion": 3, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "RouterModule@../RouterModule": "RouterModule@../RouterModule" - }, - "packages": { - "RouterModule@../RouterModule": { - "mtime": "1707210724992.75", - "resolved": "../RouterModule" - } - } +/* +* Copyright (C) 2024 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. +*/ +{ + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "RouterModule@../RouterModule": "RouterModule@../RouterModule" + }, + "packages": { + "RouterModule@../RouterModule": { + "mtime": "1707210724992.75", + "resolved": "../RouterModule" + } + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package.json5 index 84ed860c14..2f818abe09 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package.json5 @@ -1,26 +1,26 @@ -/* -* Copyright (C) 2024 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. -*/ -{ - "license": "Apache-2.0", - "devDependencies": {}, - "author": "", - "name": "hara", - "description": "Please describe the basic information.", - "main": "Index.ets", - "version": "1.0.0", - "dependencies": { - "RouterModule": "file:../RouterModule" - } -} +/* +* Copyright (C) 2024 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. +*/ +{ + "license": "Apache-2.0", + "devDependencies": {}, + "author": "", + "name": "hara", + "description": "Please describe the basic information.", + "main": "Index.ets", + "version": "1.0.0", + "dependencies": { + "RouterModule": "file:../RouterModule" + } +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page1.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page1.ets index 2ceb4ad898..8b117082b4 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page1.ets +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page1.ets @@ -1,65 +1,65 @@ -/* -* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; - -@Builder -export function harBuilder(value: object) { - NavDestination(){ - Column(){ - Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let routerName = "HapA_Router"; - RouterModule.clear(routerName); - }) - Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder"; - RouterModule.push(url); - }) - }.width('100%').height('100%') - }.title('HarA_Page1') - .onBackPressed(() => { - RouterModule.pop("HapA_Router"); - return true; - }) -} - -let builderName = 'HarA_Page1_Builder'; -if (!RouterModule.getBuilder(builderName)) { - let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); - RouterModule.registerBuilder(builderName, builder); -} +/* +* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; + +@Builder +export function harBuilder(value: object) { + NavDestination(){ + Column(){ + Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let routerName = "HapA_Router"; + RouterModule.clear(routerName); + }) + Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder"; + RouterModule.push(url); + }) + }.width('100%').height('100%') + }.title('HarA_Page1') + .onBackPressed(() => { + RouterModule.pop("HapA_Router"); + return true; + }) +} + +let builderName = 'HarA_Page1_Builder'; +if (!RouterModule.getBuilder(builderName)) { + let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); + RouterModule.registerBuilder(builderName, builder); +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page2.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page2.ets index 30ab96b161..047e4ba416 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page2.ets +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page2.ets @@ -1,65 +1,65 @@ -/* -* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; - -@Builder -export function harBuilder(value: object) { - NavDestination(){ - Column(){ - Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let routerName = "HapA_Router"; - RouterModule.clear(routerName); - }) - Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder"; - RouterModule.push(url); - }) - }.width('100%').height('100%') - }.title('HarA_Page2') - .onBackPressed(() => { - RouterModule.pop("HapA_Router"); - return true; - }) -} - -let builderName = 'HarA_Page2_Builder'; -if (!RouterModule.getBuilder(builderName)) { - let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); - RouterModule.registerBuilder(builderName, builder); +/* +* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; + +@Builder +export function harBuilder(value: object) { + NavDestination(){ + Column(){ + Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let routerName = "HapA_Router"; + RouterModule.clear(routerName); + }) + Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder"; + RouterModule.push(url); + }) + }.width('100%').height('100%') + }.title('HarA_Page2') + .onBackPressed(() => { + RouterModule.pop("HapA_Router"); + return true; + }) +} + +let builderName = 'HarA_Page2_Builder'; +if (!RouterModule.getBuilder(builderName)) { + let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); + RouterModule.registerBuilder(builderName, builder); } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page3.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page3.ets index 2fbd970720..eb1adce692 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page3.ets +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page3.ets @@ -1,65 +1,65 @@ -/* -* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; - -@Builder -export function harBuilder(value: object) { - NavDestination(){ - Column(){ - Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let routerName = "HapA_Router"; - RouterModule.clear(routerName); - }) - Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder"; - RouterModule.push(url); - }) - }.width('100%').height('100%') - }.title('HarA_Page3') - .onBackPressed(() => { - RouterModule.pop("HapA_Router"); - return true; - }) -} - -let builderName = 'HarA_Page3_Builder'; -if (!RouterModule.getBuilder(builderName)) { - let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); - RouterModule.registerBuilder(builderName, builder); +/* +* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; + +@Builder +export function harBuilder(value: object) { + NavDestination(){ + Column(){ + Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let routerName = "HapA_Router"; + RouterModule.clear(routerName); + }) + Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder"; + RouterModule.push(url); + }) + }.width('100%').height('100%') + }.title('HarA_Page3') + .onBackPressed(() => { + RouterModule.pop("HapA_Router"); + return true; + }) +} + +let builderName = 'HarA_Page3_Builder'; +if (!RouterModule.getBuilder(builderName)) { + let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); + RouterModule.registerBuilder(builderName, builder); } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/module.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/module.json5 index a0c6877ad9..5d42003186 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/module.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/module.json5 @@ -1,24 +1,24 @@ -/* -* Copyright (C) 2024 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": "harA", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} +/* +* Copyright (C) 2024 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": "harA", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/Index.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/Index.ets index b739b34f38..e68e860c43 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/Index.ets +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/Index.ets @@ -1,30 +1,30 @@ -/* -* Copyright (C) 2024 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -export function harInit(path: string): void{ - // 动态引入要跳转的页面 - switch (path) { - case "./src/main/ets/components/mainpage/page1": - import("./src/main/ets/components/mainpage/page1"); - break; - case "./src/main/ets/components/mainpage/page2": - import("./src/main/ets/components/mainpage/page2"); - break; - case "./src/main/ets/components/mainpage/page3": - import("./src/main/ets/components/mainpage/page3"); - break; - default: - break; - } -} +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +export function harInit(path: string): void{ + // 动态引入要跳转的页面 + switch (path) { + case "./src/main/ets/components/mainpage/page1": + import("./src/main/ets/components/mainpage/page1"); + break; + case "./src/main/ets/components/mainpage/page2": + import("./src/main/ets/components/mainpage/page2"); + break; + case "./src/main/ets/components/mainpage/page3": + import("./src/main/ets/components/mainpage/page3"); + break; + default: + break; + } +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/build-profile.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/build-profile.json5 index 2783f9a949..c776629856 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/build-profile.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/build-profile.json5 @@ -1,25 +1,25 @@ -/* -* Copyright (C) 2024 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": { - }, - "targets": [ - { - "name": "default" - } - ] -} +/* +* Copyright (C) 2024 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": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package-lock.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package-lock.json5 index 595baf01e1..4d162199c6 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package-lock.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package-lock.json5 @@ -1,27 +1,27 @@ -/* -* Copyright (C) 2024 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. -*/ -{ - "lockfileVersion": 3, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "RouterModule@../RouterModule": "RouterModule@../RouterModule" - }, - "packages": { - "RouterModule@../RouterModule": { - "mtime": "1707210724992.75", - "resolved": "../RouterModule" - } - } +/* +* Copyright (C) 2024 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. +*/ +{ + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "RouterModule@../RouterModule": "RouterModule@../RouterModule" + }, + "packages": { + "RouterModule@../RouterModule": { + "mtime": "1707210724992.75", + "resolved": "../RouterModule" + } + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package.json5 index 489a3704df..584b7808d5 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package.json5 @@ -1,26 +1,26 @@ -/* -* Copyright (C) 2024 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. -*/ -{ - "license": "Apache-2.0", - "devDependencies": {}, - "author": "", - "name": "harb", - "description": "Please describe the basic information.", - "main": "Index.ets", - "version": "1.0.0", - "dependencies": { - "RouterModule": "file:../RouterModule" - } -} +/* +* Copyright (C) 2024 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. +*/ +{ + "license": "Apache-2.0", + "devDependencies": {}, + "author": "", + "name": "harb", + "description": "Please describe the basic information.", + "main": "Index.ets", + "version": "1.0.0", + "dependencies": { + "RouterModule": "file:../RouterModule" + } +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page1.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page1.ets index 8f9752914d..b0f04cedae 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page1.ets +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page1.ets @@ -1,65 +1,65 @@ -/* -* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; - -@Builder -export function harBuilder(value: object) { - NavDestination(){ - Column(){ - Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let routerName = "HapA_Router"; - RouterModule.clear(routerName); - }) - Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder"; - RouterModule.push(url); - }) - }.width('100%').height('100%') - }.title('HarB_Page1') - .onBackPressed(() => { - RouterModule.pop("HapA_Router"); - return true; - }) -} - -let builderName = 'HarB_Page1_Builder'; -if (!RouterModule.getBuilder(builderName)) { - let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); - RouterModule.registerBuilder(builderName, builder); -} +/* +* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; + +@Builder +export function harBuilder(value: object) { + NavDestination(){ + Column(){ + Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let routerName = "HapA_Router"; + RouterModule.clear(routerName); + }) + Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder"; + RouterModule.push(url); + }) + }.width('100%').height('100%') + }.title('HarB_Page1') + .onBackPressed(() => { + RouterModule.pop("HapA_Router"); + return true; + }) +} + +let builderName = 'HarB_Page1_Builder'; +if (!RouterModule.getBuilder(builderName)) { + let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); + RouterModule.registerBuilder(builderName, builder); +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page2.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page2.ets index 6ff8d325a6..6fef357292 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page2.ets +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page2.ets @@ -1,65 +1,65 @@ -/* -* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; - -@Builder -export function harBuilder(value: object) { - NavDestination(){ - Column(){ - Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let routerName = "HapA_Router"; - RouterModule.clear(routerName); - }) - Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder"; - RouterModule.push(url); - }) - }.width('100%').height('100%') - }.title('HarB_Page2') - .onBackPressed(() => { - RouterModule.pop("HapA_Router"); - return true; - }) -} - -let builderName = 'HarB_Page2_Builder'; -if (!RouterModule.getBuilder(builderName)) { - let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); - RouterModule.registerBuilder(builderName, builder); -} +/* +* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; + +@Builder +export function harBuilder(value: object) { + NavDestination(){ + Column(){ + Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let routerName = "HapA_Router"; + RouterModule.clear(routerName); + }) + Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder"; + RouterModule.push(url); + }) + }.width('100%').height('100%') + }.title('HarB_Page2') + .onBackPressed(() => { + RouterModule.pop("HapA_Router"); + return true; + }) +} + +let builderName = 'HarB_Page2_Builder'; +if (!RouterModule.getBuilder(builderName)) { + let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); + RouterModule.registerBuilder(builderName, builder); +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page3.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page3.ets index a8f0b9e4ff..b4922252f8 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page3.ets +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page3.ets @@ -1,65 +1,65 @@ -/* -* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; - -@Builder -export function harBuilder(value: object) { - NavDestination(){ - Column(){ - Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let routerName = "HapA_Router"; - RouterModule.clear(routerName); - }) - Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder"; - RouterModule.push(url); - }) - Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule }) - .width('80%') - .height(40) - .margin(20) - .onClick(() => { - let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder"; - RouterModule.push(url); - }) - }.width('100%').height('100%') - }.title('HarB_Page3') - .onBackPressed(() => { - RouterModule.pop("HapA_Router"); - return true; - }) -} - -let builderName = 'HarB_Page3_Builder'; -if (!RouterModule.getBuilder(builderName)) { - let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); - RouterModule.registerBuilder(builderName, builder); -} +/* +* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule"; + +@Builder +export function harBuilder(value: object) { + NavDestination(){ + Column(){ + Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let routerName = "HapA_Router"; + RouterModule.clear(routerName); + }) + Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder"; + RouterModule.push(url); + }) + Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder"; + RouterModule.push(url); + }) + }.width('100%').height('100%') + }.title('HarB_Page3') + .onBackPressed(() => { + RouterModule.pop("HapA_Router"); + return true; + }) +} + +let builderName = 'HarB_Page3_Builder'; +if (!RouterModule.getBuilder(builderName)) { + let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder); + RouterModule.registerBuilder(builderName, builder); +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/module.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/module.json5 index 51a6edaffb..a052108752 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/module.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/module.json5 @@ -1,24 +1,24 @@ -/* -* Copyright (C) 2024 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": "harB", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} +/* +* Copyright (C) 2024 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": "harB", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/hvigor/hvigor-config.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/hvigor/hvigor-config.json5 index e1b617db91..0b5647c97e 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/hvigor/hvigor-config.json5 @@ -1,6 +1,6 @@ -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/oh-package.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/oh-package.json5 index dce34f96c0..41f1d62f0d 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/oh-package.json5 +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/oh-package.json5 @@ -1,26 +1,26 @@ -/* -* Copyright (C) 2024 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. -*/ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "myapplication", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* +* Copyright (C) 2024 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. +*/ +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "myapplication", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/ohosTest.md b/code/BasicFeature/ApplicationModels/DynamicRouter/ohosTest.md index 74fe3b6ece..8d459c87e3 100644 --- a/code/BasicFeature/ApplicationModels/DynamicRouter/ohosTest.md +++ b/code/BasicFeature/ApplicationModels/DynamicRouter/ohosTest.md @@ -1,10 +1,10 @@ -# FileManager 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 |是否自动|测试结果| -|----------------|----------|-----------|--------------|--------------------------------|--------------------------------| -| 拉起应用 | 设备正常运行 | | 成功拉起应用 |是|Pass| -| 从首页跳转到harA页面 | 进入首页 | 点击ToHarA | 成功跳转到harA页面 |是|Pass| -| 从harA跳转到harB页面 | 进入HarA页面 | 点击ToHarB | 成功跳转跳转到harB页面 |是|Pass| +# FileManager 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 |是否自动|测试结果| +|----------------|----------|-----------|--------------|--------------------------------|--------------------------------| +| 拉起应用 | 设备正常运行 | | 成功拉起应用 |是|Pass| +| 从首页跳转到harA页面 | 进入首页 | 点击ToHarA | 成功跳转到harA页面 |是|Pass| +| 从harA跳转到harB页面 | 进入HarA页面 | 点击ToHarB | 成功跳转跳转到harB页面 |是|Pass| | 从harB跳转到首页 | 进入HarB页面 | 点击ToIndex | 成功跳转到首页 |是|Pass| \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/app.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/app.json5 index 7422edb8a7..f8349cd66b 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/app.json5 +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/app.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -{ - "app": { - "bundleName": "com.samples.multiplefilesdownload", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.multiplefilesdownload", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/resources/base/element/string.json b/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/resources/base/element/string.json index f5b165b843..35ce4d49ab 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MultipleFilesDownload" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "MultipleFilesDownload" + } + ] +} diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/README.md b/code/BasicFeature/Connectivity/MultipleFilesDownload/README.md index b75f037faf..281c945193 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/README.md +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/README.md @@ -1,201 +1,201 @@ - - -# 多文件下载监听案例 - -### 介绍 - -多文件下载监听在应用开发中是一个非常常见的需求。本示例将介绍如何使用request上传下载模块实现多文件下载监听,如监听每个文件下载任务的进度,任务暂停,下载完成等下载情况。下载历史页面展示的是下载完成的文件,可对页面中已删除的文件进行重新下载 。每个应用至多支持创建10个未完成的任务,相关规格说明请参考[request.agent.create](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md#requestagentcreate10)。 - -### 效果图预览 - -![](./casesfeature/multiplefilesdownload/multiple_files_download.gif) - -**使用说明** - -1. 连接网络。进入页面,点击“全部开始”,启动所有文件的下载任务。点击“全部暂停”,暂停所有文件下载任务。再次点击“全部开始”,可重新启动未完成的下载任务。如出现下载失败,一般是网络不稳定,点击“全部开始”即可重新下载。 -2. 下载完成的文件会保存在应用缓存路径下,出现在下载历史页面中。 -3. 可点击删除按钮,在应用缓存路径下删除该文件存储的数据。 -4. 点击文件,若文件中在应用缓存路径下存在,弹窗提示用户“文件已存在”;否则弹窗提示用户“文件不存在,是否重新下载?”,点击确认按钮,该条文件数据会出现在下载列表中,可点击“全部开始“按钮重新下载。 - -### 实现思路 - -1. 配置下载参数。一个下载任务需要配置对应一套下载参数request.agent.Config。本例中使用downloadConfig方法简单配置了下载文件的url,实际业务中请按实际情况按需配置。源码参考[MultipleFilesDownload.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/MultipleFilesDownload.ets)。 - - ```typescript - let config: request.agent.Config = { - action: request.agent.Action.DOWNLOAD, // 配置任务选项,这里配置为下载任务 - url: downloadUrl, // 配置下载任务url - overwrite: true, // 下载过程中路径已存在时的解决方案选择。true表示覆盖已存在的文件 - method: 'GET', // HTTP标准方法。下载时,使用GET或POST。 - saveas: './', // 这里'./'表示下载至应用当前缓存路径下。 - mode: request.agent.Mode.BACKGROUND, // 任务模式设置后台任务。 - gauge: true // 后台任务的过程进度通知策略,仅应用于后台任务。true表示发出每个进度已完成或失败的通知。 - }; - ``` - -2. 创建多个文件下载监听实例。单个文件下载监听只需要配置下载参数,创建下载任务,注册下载任务相关监听,启动下载任务即可实现。而要实现多文件下载监听,需要每个下载任务注册独立的下载监听回调。本例通过封装自定义组件FileDownloadItem,在每个FileDownloadItem中创建各自的下载任务和监听回调,从而实现多文件下载监听。源码参考[MultipleFilesDownload.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/MultipleFilesDownload.ets)。 - - ```typescript - ForEach(this.downloadConfigArray, (item: request.agent.Config) => { - ListItem() { - // 创建文件下载监听实例 - FileDownloadItem({ - downloadConfig: item, // 文件下载配置 - isStartAllDownload: this.isStartAllDownload, // 是否全部开始下载 - downloadCount: this.downloadCount // 待下载任务数量 - downloadFailCount: this.downloadFailCount // 下载失败任务数量 - }) - } - }, (item: request.agent.Config) => JSON.stringify(item)) - ``` - -3. 创建下载任务,并注册下载任务相关监听。本例在每个FileDownloadItem中使用request.agent.create创建下载任务。然后在下载任务创建成功后,注册各自下载任务相关监听。本例中注册了下载任务完成回调,下载任务失败回调,下载进度更新回调,暂停任务回调,重新启动任务回调。源码参考[FileDownloadItem.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/FileDownloadItem.ets)。 - - ```typescript - request.agent.create(context, this.downloadConfig).then((task: request.agent.Task) => { - // 注册下载任务相关回调 - task.on('completed', this.completedCallback); // 下载任务完成回调 - task.on('failed', this.failedCallback); // 下载任务失败回调 - task.on('pause', this.pauseCallback); // 暂停任务回调 - task.on('resume', this.resumeCallback); // 重新启动任务回调 - task.on('progress', this.progressCallback); // 下载进度更新回调 - }).catch((err: BusinessError) => { - logger.error(TAG, `Failed to task create with error message: ${err.message}, error code: ${err.code}`); - }); - ``` - -4. 启动下载任务。本例在每个FileDownloadItem中使用task.start方法启动各自的下载任务。源码参考[FileDownloadItem.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/FileDownloadItem.ets)。 - - ```typescript - task.start((err: BusinessError) => { - if (err) { - logger.error(TAG, `Failed to task start with error message: ${err.message}, error code: ${err.code}`); - return; - } - this.downloadTask = task; - }) - ``` - -5. 删除文件。使用fs.unlink删除该条数据应用文件路径 - - ```typescript - // TODO:知识点:删除该条数据应用文件路径 - fs.unlink(filePath).then(() => { - // 文件状态变为已删除 - this.FileInfo.fileStatus = 3; - promptAction.showToast({ - message: $r('app.string.multiple_files_download_history_toast_text_del'), - duration: 2000, - bottom: '50%', - }) - }).catch((error: BusinessError) => { - logger.error("remove file failed with error:" + error); - }); - ``` - -6. 重新下载已删除的文件。使用fs.access判断文件是否已经存在,若不存在弹窗提示用户是否重新下载。 - - ```typescript - // 获取应用文件路径 - const cacheDir = context.cacheDir; - const FilePath: string = `${cacheDir}/${this.fileName}`; - - // TODO:知识点:使用fs.access判断目录是否已经存在。 - fs.access(FilePath).then((res: boolean) => { - if (!res) { - // 文件已删除,弹窗提示是否重新下载 - AlertDialog.show({ - message: `${this.fileName}文件不存在,是否重新下载?`, - alignment: DialogAlignment.Center, // 弹窗在竖直方向上的对齐方式。 - autoCancel: false, // 点击遮罩层时,是否关闭弹窗。默认值:true - primaryButton: { - value: $r('app.string.multiple_files_download_history_button_text_cancel'), - fontColor: $r('app.color.multiple_files_download_text_color'), - action: () => { - logger.info('已取消'); - } - }, - secondaryButton: { - value: $r('app.string.multiple_files_download_history_button_text_confirm'), - fontColor: $r('app.color.multiple_files_download_del_bgc'), - action: () => { - // 更改该条数据下载状态 - this.FileInfo.fileStatus = 0; - // 该条数据加入下载列表数组中 - this.downloadFileArray.push(this.FileInfo); - // 下载历史列表删除该条数据 - this.historyArray = this.historyArray.filter( ( item: downloadFilesData ) => { - return item.id !== this.FileInfo.id; - }); - // 更新待下载任务数量 - this.downloadCount = this.downloadFileArray.length; - } - }, - cornerRadius: $r('app.integer.multiple_files_download_borderRadius_twelve'), // 弹窗边框弧度 - width: $r('app.string.multiple_files_download_list_height'), // 弹窗宽度 - cancel: () => { - logger.info('点击关闭按钮'); - } - }); - } else { - // 文件已下载到本地,弹窗提示文件已存在 - promptAction.showToast({ - message: $r('app.string.multiple_files_download_history_toast_text_exist'), - duration: 1000, - bottom: '50%', - }) - } - ``` - -### 高性能知识点 - -本示例中注册了progress下载进度更新监听,不建议在下载进度更新回调中加日志打印,以减少不必要的性能损耗。 - -### FAQ - -1. 无网络时,点击”全部开始“,下载队列中的任务状态却显示”已暂停“。 - - 答:request.agent.Config有一个参数retry默认是true,如果没有网络或者网络不满足时,会自动暂停waiting,所以在没网络的时候下载底层逻辑会走暂停回调,应用侧在暂停回调里设置了显示当前下载状态,所以无网络时,点击”全部开始“,下载队列中的任务状态显示”已暂停“。目前本例中已经把retry设置为false,没网络时,开启下载任务会直接走入失败回调,直接显示”下载失败“。 - -### 工程结构&模块类型 - - ``` - multiplefilesdownload // har类型 - |---view - | |---MultipleFilesDownload.ets // 视图层-文件下载页面 - | |---FileDownloadItem.ets // 视图层-单个文件下载组件 - | |---HistoryItem.ets // 视图层-单个文件历史组件 - ``` - -### 参考资料 - -[上传下载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md) - -### 相关权限 - -| 权限名 | 权限说明 | 级别 | -| ------------------------ | -------------------- | ------ | -| ohos.permission.INTERNET | 允许使用Interent网络 | normal | - -### 依赖 - -不涉及。 -### 约束与限制 - -1.本示例仅支持标准系统上运行。 - -2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12 Release)。 - -3.本示例需要使用DevEco Studio版本号(DevEco Studio 5.0.0 Release)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```shell -git init -git config core.sparsecheckout true -echo code/BasicFeature/Connectivity/MultipleFilesDownload > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master + + +# 多文件下载监听案例 + +### 介绍 + +多文件下载监听在应用开发中是一个非常常见的需求。本示例将介绍如何使用request上传下载模块实现多文件下载监听,如监听每个文件下载任务的进度,任务暂停,下载完成等下载情况。下载历史页面展示的是下载完成的文件,可对页面中已删除的文件进行重新下载 。每个应用至多支持创建10个未完成的任务,相关规格说明请参考[request.agent.create](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md#requestagentcreate10)。 + +### 效果图预览 + +![](./casesfeature/multiplefilesdownload/multiple_files_download.gif) + +**使用说明** + +1. 连接网络。进入页面,点击“全部开始”,启动所有文件的下载任务。点击“全部暂停”,暂停所有文件下载任务。再次点击“全部开始”,可重新启动未完成的下载任务。如出现下载失败,一般是网络不稳定,点击“全部开始”即可重新下载。 +2. 下载完成的文件会保存在应用缓存路径下,出现在下载历史页面中。 +3. 可点击删除按钮,在应用缓存路径下删除该文件存储的数据。 +4. 点击文件,若文件中在应用缓存路径下存在,弹窗提示用户“文件已存在”;否则弹窗提示用户“文件不存在,是否重新下载?”,点击确认按钮,该条文件数据会出现在下载列表中,可点击“全部开始“按钮重新下载。 + +### 实现思路 + +1. 配置下载参数。一个下载任务需要配置对应一套下载参数request.agent.Config。本例中使用downloadConfig方法简单配置了下载文件的url,实际业务中请按实际情况按需配置。源码参考[MultipleFilesDownload.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/MultipleFilesDownload.ets)。 + + ```typescript + let config: request.agent.Config = { + action: request.agent.Action.DOWNLOAD, // 配置任务选项,这里配置为下载任务 + url: downloadUrl, // 配置下载任务url + overwrite: true, // 下载过程中路径已存在时的解决方案选择。true表示覆盖已存在的文件 + method: 'GET', // HTTP标准方法。下载时,使用GET或POST。 + saveas: './', // 这里'./'表示下载至应用当前缓存路径下。 + mode: request.agent.Mode.BACKGROUND, // 任务模式设置后台任务。 + gauge: true // 后台任务的过程进度通知策略,仅应用于后台任务。true表示发出每个进度已完成或失败的通知。 + }; + ``` + +2. 创建多个文件下载监听实例。单个文件下载监听只需要配置下载参数,创建下载任务,注册下载任务相关监听,启动下载任务即可实现。而要实现多文件下载监听,需要每个下载任务注册独立的下载监听回调。本例通过封装自定义组件FileDownloadItem,在每个FileDownloadItem中创建各自的下载任务和监听回调,从而实现多文件下载监听。源码参考[MultipleFilesDownload.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/MultipleFilesDownload.ets)。 + + ```typescript + ForEach(this.downloadConfigArray, (item: request.agent.Config) => { + ListItem() { + // 创建文件下载监听实例 + FileDownloadItem({ + downloadConfig: item, // 文件下载配置 + isStartAllDownload: this.isStartAllDownload, // 是否全部开始下载 + downloadCount: this.downloadCount // 待下载任务数量 + downloadFailCount: this.downloadFailCount // 下载失败任务数量 + }) + } + }, (item: request.agent.Config) => JSON.stringify(item)) + ``` + +3. 创建下载任务,并注册下载任务相关监听。本例在每个FileDownloadItem中使用request.agent.create创建下载任务。然后在下载任务创建成功后,注册各自下载任务相关监听。本例中注册了下载任务完成回调,下载任务失败回调,下载进度更新回调,暂停任务回调,重新启动任务回调。源码参考[FileDownloadItem.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/FileDownloadItem.ets)。 + + ```typescript + request.agent.create(context, this.downloadConfig).then((task: request.agent.Task) => { + // 注册下载任务相关回调 + task.on('completed', this.completedCallback); // 下载任务完成回调 + task.on('failed', this.failedCallback); // 下载任务失败回调 + task.on('pause', this.pauseCallback); // 暂停任务回调 + task.on('resume', this.resumeCallback); // 重新启动任务回调 + task.on('progress', this.progressCallback); // 下载进度更新回调 + }).catch((err: BusinessError) => { + logger.error(TAG, `Failed to task create with error message: ${err.message}, error code: ${err.code}`); + }); + ``` + +4. 启动下载任务。本例在每个FileDownloadItem中使用task.start方法启动各自的下载任务。源码参考[FileDownloadItem.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/FileDownloadItem.ets)。 + + ```typescript + task.start((err: BusinessError) => { + if (err) { + logger.error(TAG, `Failed to task start with error message: ${err.message}, error code: ${err.code}`); + return; + } + this.downloadTask = task; + }) + ``` + +5. 删除文件。使用fs.unlink删除该条数据应用文件路径 + + ```typescript + // TODO:知识点:删除该条数据应用文件路径 + fs.unlink(filePath).then(() => { + // 文件状态变为已删除 + this.FileInfo.fileStatus = 3; + promptAction.showToast({ + message: $r('app.string.multiple_files_download_history_toast_text_del'), + duration: 2000, + bottom: '50%', + }) + }).catch((error: BusinessError) => { + logger.error("remove file failed with error:" + error); + }); + ``` + +6. 重新下载已删除的文件。使用fs.access判断文件是否已经存在,若不存在弹窗提示用户是否重新下载。 + + ```typescript + // 获取应用文件路径 + const cacheDir = context.cacheDir; + const FilePath: string = `${cacheDir}/${this.fileName}`; + + // TODO:知识点:使用fs.access判断目录是否已经存在。 + fs.access(FilePath).then((res: boolean) => { + if (!res) { + // 文件已删除,弹窗提示是否重新下载 + AlertDialog.show({ + message: `${this.fileName}文件不存在,是否重新下载?`, + alignment: DialogAlignment.Center, // 弹窗在竖直方向上的对齐方式。 + autoCancel: false, // 点击遮罩层时,是否关闭弹窗。默认值:true + primaryButton: { + value: $r('app.string.multiple_files_download_history_button_text_cancel'), + fontColor: $r('app.color.multiple_files_download_text_color'), + action: () => { + logger.info('已取消'); + } + }, + secondaryButton: { + value: $r('app.string.multiple_files_download_history_button_text_confirm'), + fontColor: $r('app.color.multiple_files_download_del_bgc'), + action: () => { + // 更改该条数据下载状态 + this.FileInfo.fileStatus = 0; + // 该条数据加入下载列表数组中 + this.downloadFileArray.push(this.FileInfo); + // 下载历史列表删除该条数据 + this.historyArray = this.historyArray.filter( ( item: downloadFilesData ) => { + return item.id !== this.FileInfo.id; + }); + // 更新待下载任务数量 + this.downloadCount = this.downloadFileArray.length; + } + }, + cornerRadius: $r('app.integer.multiple_files_download_borderRadius_twelve'), // 弹窗边框弧度 + width: $r('app.string.multiple_files_download_list_height'), // 弹窗宽度 + cancel: () => { + logger.info('点击关闭按钮'); + } + }); + } else { + // 文件已下载到本地,弹窗提示文件已存在 + promptAction.showToast({ + message: $r('app.string.multiple_files_download_history_toast_text_exist'), + duration: 1000, + bottom: '50%', + }) + } + ``` + +### 高性能知识点 + +本示例中注册了progress下载进度更新监听,不建议在下载进度更新回调中加日志打印,以减少不必要的性能损耗。 + +### FAQ + +1. 无网络时,点击”全部开始“,下载队列中的任务状态却显示”已暂停“。 + + 答:request.agent.Config有一个参数retry默认是true,如果没有网络或者网络不满足时,会自动暂停waiting,所以在没网络的时候下载底层逻辑会走暂停回调,应用侧在暂停回调里设置了显示当前下载状态,所以无网络时,点击”全部开始“,下载队列中的任务状态显示”已暂停“。目前本例中已经把retry设置为false,没网络时,开启下载任务会直接走入失败回调,直接显示”下载失败“。 + +### 工程结构&模块类型 + + ``` + multiplefilesdownload // har类型 + |---view + | |---MultipleFilesDownload.ets // 视图层-文件下载页面 + | |---FileDownloadItem.ets // 视图层-单个文件下载组件 + | |---HistoryItem.ets // 视图层-单个文件历史组件 + ``` + +### 参考资料 + +[上传下载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md) + +### 相关权限 + +| 权限名 | 权限说明 | 级别 | +| ------------------------ | -------------------- | ------ | +| ohos.permission.INTERNET | 允许使用Interent网络 | normal | + +### 依赖 + +不涉及。 +### 约束与限制 + +1.本示例仅支持标准系统上运行。 + +2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12 Release)。 + +3.本示例需要使用DevEco Studio版本号(DevEco Studio 5.0.0 Release)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```shell +git init +git config core.sparsecheckout true +echo code/BasicFeature/Connectivity/MultipleFilesDownload > .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/BasicFeature/Connectivity/MultipleFilesDownload/build-profile.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/build-profile.json5 index 62ec91ec46..3bd213566f 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/build-profile.json5 +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/build-profile.json5 @@ -1,60 +1,60 @@ -/* - * 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", - compileSdkVersion: 12, - "compatibleSdkVersion": 12, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug" - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "multiplefilesdownload", - "srcPath": "./casesfeature/multiplefilesdownload" - } - ] +/* + * 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", + compileSdkVersion: 12, + "compatibleSdkVersion": 12, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "multiplefilesdownload", + "srcPath": "./casesfeature/multiplefilesdownload" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/casesfeature/multiplefilesdownload/oh-package.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/casesfeature/multiplefilesdownload/oh-package.json5 index b6a8c714fa..2464e14a8c 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/casesfeature/multiplefilesdownload/oh-package.json5 +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/casesfeature/multiplefilesdownload/oh-package.json5 @@ -1,23 +1,23 @@ -/* - * 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" : "multiplefilesdownload", - "version" : "1.0.0", - "description" : "Please describe the basic information.", - "main" : "Index.ets", - "author" : "", - "license" : "Apache-2.0", - "dependencies" : { } +/* + * 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" : "multiplefilesdownload", + "version" : "1.0.0", + "description" : "Please describe the basic information.", + "main" : "Index.ets", + "author" : "", + "license" : "Apache-2.0", + "dependencies" : { } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/build-profile.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/build-profile.json5 index b4d65d490e..e7569e3056 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/build-profile.json5 +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/oh-package.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/oh-package.json5 index f24d0a9a5e..71c70d510a 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/oh-package.json5 +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/oh-package.json5 @@ -1,26 +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": { - "multiplefilesdownload": "file:../casesfeature/multiplefilesdownload" - } +/* + * 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": { + "multiplefilesdownload": "file:../casesfeature/multiplefilesdownload" + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entryability/EntryAbility.ets index 3e77e4b9f7..edc2839f20 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index 1504a74f09..b1e2129472 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/module.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/module.json5 index dfbe47e6ac..9deddb7dec 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/module.json5 +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/module.json5 @@ -1,66 +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:app_name", - "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" - } - ] - } - ] - } +/* + * 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:app_name", + "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/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/profile/backup_config.json index d742c2f96e..78f40ae7c4 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/profile/backup_config.json +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/dark/element/color.json b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/dark/element/color.json index 438d5bc43b..79b11c2747 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/dark/element/color.json +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/ohosTest/module.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/ohosTest/module.json5 index 9983b2ba4e..c3fd9dda30 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/hvigor/hvigor-config.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/hvigor/hvigor-config.json5 index dccc142c23..5282eefe05 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/hvigor/hvigor-config.json5 @@ -1,36 +1,36 @@ -/* - * 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.1", - "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*/ - } -} +/* + * 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.1", + "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/BasicFeature/Connectivity/MultipleFilesDownload/oh-package.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/oh-package.json5 index eaef52736f..e41bae026a 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/oh-package.json5 +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/ohosTest.md b/code/BasicFeature/Connectivity/MultipleFilesDownload/ohosTest.md index 7691735123..1d79cbba9d 100644 --- a/code/BasicFeature/Connectivity/MultipleFilesDownload/ohosTest.md +++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/ohosTest.md @@ -1,13 +1,13 @@ -# 多文件下载监听案例 测试用例归档 - -## 用例表 - -|测试功能|预置条件|输入|预期输出|是否自动|测试结果| -|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------| -|点击“全部开始”功能是否正常启动下载| 1.进入案例页面 2.正常连接网络 | 点击“全部开始” |点击“全部开始”,下载队列中两个任务能正常下载|是|Pass| -|点击“全部暂停”功能是否能正常暂停下载| 1.进入案例页面 2.正常连接网络 | 点击“全部暂停” |点击“全部暂停”,下载队列中正在下载的任务被暂停了|是|Pass| -|点击“全部开始”,然后在下载完成前点击“全部暂停”,然后再次点击“全部开始”查看被暂停的下载任务能否正常恢复下载| 1.进入案例页面 2.正常连接网络 | 点击“全部开始”,然后在下载完成前点击点击“全部暂停”,然后再次点击“全部开始” |下载任务重新恢复下载|是|Pass| -|下载文件保存是否正常| 1.进入案例页面 2.正常连接网络 | 点击“全部开始”,等待下载完成后,查看下载的文件是否保存在应用缓存路径下。(手工可用hdc shell cd /data/app/el2/100/base/com/north.cases/haps/entry/cache/) |下载完成后,在案例应用缓存路径下可以找到下载的文件:favor_list_tea.png favor_list_tree.png|是|Pass| -|在下载历史中已下载的文件是否能删除|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击“删除”| 点击“删除”,文件被删除样式发生变化且在案例应用缓存路径下不能找到已删除的文件 |是|Pass| -|点击下载历史中的文件,是否能把已删除的文件重新下载|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击已删除文件|弹出“xxx文件已被删除,是否重新下载”的弹窗提示用户是否重新下载,若用户点击“确认”文件重新下载|是|Pass| -|在下载历史中点击已下载的文件是否弹出“文件已存在”信息|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击已下载文件|弹出“文件已存在”toast|是|Pass| +# 多文件下载监听案例 测试用例归档 + +## 用例表 + +|测试功能|预置条件|输入|预期输出|是否自动|测试结果| +|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------| +|点击“全部开始”功能是否正常启动下载| 1.进入案例页面 2.正常连接网络 | 点击“全部开始” |点击“全部开始”,下载队列中两个任务能正常下载|是|Pass| +|点击“全部暂停”功能是否能正常暂停下载| 1.进入案例页面 2.正常连接网络 | 点击“全部暂停” |点击“全部暂停”,下载队列中正在下载的任务被暂停了|是|Pass| +|点击“全部开始”,然后在下载完成前点击“全部暂停”,然后再次点击“全部开始”查看被暂停的下载任务能否正常恢复下载| 1.进入案例页面 2.正常连接网络 | 点击“全部开始”,然后在下载完成前点击点击“全部暂停”,然后再次点击“全部开始” |下载任务重新恢复下载|是|Pass| +|下载文件保存是否正常| 1.进入案例页面 2.正常连接网络 | 点击“全部开始”,等待下载完成后,查看下载的文件是否保存在应用缓存路径下。(手工可用hdc shell cd /data/app/el2/100/base/com/north.cases/haps/entry/cache/) |下载完成后,在案例应用缓存路径下可以找到下载的文件:favor_list_tea.png favor_list_tree.png|是|Pass| +|在下载历史中已下载的文件是否能删除|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击“删除”| 点击“删除”,文件被删除样式发生变化且在案例应用缓存路径下不能找到已删除的文件 |是|Pass| +|点击下载历史中的文件,是否能把已删除的文件重新下载|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击已删除文件|弹出“xxx文件已被删除,是否重新下载”的弹窗提示用户是否重新下载,若用户点击“确认”文件重新下载|是|Pass| +|在下载历史中点击已下载的文件是否弹出“文件已存在”信息|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击已下载文件|弹出“文件已存在”toast|是|Pass| diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md b/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md index 96dda84b85..a6ef8c6ee9 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md @@ -1,152 +1,152 @@ -# 上传和下载 - -### 介绍 -本示例使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)接口创建上传和下载任务,实现上传、下载功能,hfs作为服务器,实现了文件的上传和下载和任务的查询功能。 - -### 效果预览 - -| 主页 | 上传 | 片段上传 | 下载 | 下载到用户目录 | 证书锁定 | -| :---------------------------------------: | :---------------------------------------: | :--------------------------------------: | :--------------------------------------: | :--------------------------------------: | ---------------------------------------- | -| ![home](screenshots/devices/zh/home.jpg) | ![util](screenshots/devices/zh/upload.jpg) | ![util](screenshots/devices/zh/uploadchunk.jpg) | ![convertxml](screenshots/devices/zh/download.jpg) | ![convertxml](screenshots/devices/zh/download_user.jpg) | ![cert_lock](screenshots/devices/zh/cert_lock.jpg) | - -使用说明 - -1.本示例功能需要先配置服务器环境后使用,具体配置见[上传下载服务配置](./environment)。 - -2.首页展示上传、下载、下载到用户目录和证书锁定四个入口组件,点击进入对应的页面,如果要使用后台下载任务,请开启后台任务开关。 - -3.上传页面: - -点击 **+**,**从相册选择**拉起图库选择照片,图片选择页面支持拍照,选择照片后点击**上传**进行上传。 - -可选的,点击缩略图,显示文件片段上传配置选项弹窗,可以配置上传起点和终点,取值为闭区间;起点默认为0,终点默认为文件结尾。点击**上传**进行选中文件片段以及后续文件全部内容上传。 - -点击**返回**键或片段上传配置选项弹窗外区域,取消片段上传。 - -在首页中打开后台任务开关后,上传页面开启的是后台上传任务,后台任务在应用退出到后台时可以在通知栏看到任务状态。 - -后台上传**暂停**时,需要服务器支持上传暂停服务(HFS暂不支持此操作)。如仍然使用HFS作为服务器,此时HFS服务将中断文件写入,立即将当前传输的数据保存为文件片段。点击**继续**时则会重新生成一份文件,并在新文件中开始写入。 - -4.下载页面: - -点击文件列表选择要下载的文件后,点击**下载**选择指定路径后开始下载。 - -点击**查看下载文件**进入下载文件页面,点击文件夹查看文件夹内的文件。 - -在首页中打开后台任务开关后,下载页面开启的是后台下载任务,后台任务在应用退出到后台时可以在通知栏看到任务状态。 - -前台下载时只支持单文件下载,后台下载时支持选择多个文件下载。 - -后台下载**暂停**时,本示例功能将自动记录断点。此时HFS服务仍会进行一定时间的传输,但是传输的数据并不会被接受。点击**继续**后将会从上次暂停的断点继续下载。 - -5.证书锁定页面: - -点击**下载**按钮会使用get方式访问百度,并在空白处显示返回的响应header内容。 - -点击**上传**按钮会使用post方式访问百度,并在空白处显示返回的响应header内容。 - -以上功能需要在src/main/resources/base/profile/network_config.json中配置domains和digest,只有你配置的证书信息通过验证,上传和下载才可以正常响应;否则将无法正常访问百度,会通过toast提示上传或者下载失败,日志中会有具体错误信息。如果你要访问的服务器根证书不在系统中,你需要把它的根证书放到src/main/resources/resfile目录下。 - -如示例中访问百度,则digest需要取百度服务器的证书生成: - -```bash -cat server.crt \ -| openssl x509 -noout -pubkey \ -| openssl pkey -pubin -outform der \ -| openssl dgst -sha256 -binary \ -| openssl enc -base64 -``` - -因为服务器证书可能定期更新,所以digest的值需要与服务端证书对应,及时更新。 - -![服务端证书](screenshots/ca.png) - -![获取digest](screenshots/get_digest.png) - - -### 工程目录 - -``` -UploadAndDownload -├── AppScope -│ └── app.json5 //APP信息配置文件 -├── entry/src/main //应用首页 -│ ├── ets -│ │ ├── entryability -│ │ ├── components //自定义组件 -│ │ ├── pages -│ │ │ ├── Index.ets //主页入口 -│ │ │ ├── Download.ets //下载页面 -│ │ │ ├── DownloadFiles.ets //查看下载文件页面 -│ │ │ ├── Upload.ets //上传页面 -│ │ │ ├── CertLock.ets //证书锁定页面 -│ └── module.json5 -│ -├── features/uploadanddownload/src/main //上传和下载 -│ ├── ets -│ │ ├── Index.ets //对外提供的接口列表 -│ │ ├── components -│ │ │ └── FileBrowse.ets //查看下载文件组件 -│ │ ├── download //下载任务相关 -│ │ ├── upload //上传任务相关 -│ │ ├── utils //相关工具类 -│ └── module.json5 -``` - -### 具体实现 - -* 该示例分为三个模块: - * 上传模块 - * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现上传任务的创建、取消、进度加载,失败的任务会调用查询接口获取失败原因并打印在日志中,支持多个文件上传及片段上传。 - * 源码链接:[RequestUpload.ets](./features/uploadanddownload/src/main/ets/upload/RequestUpload.ets),[AddPictures.ets](./entry/src/main/ets/components/AddPictures.ets),[Upload.ets](./entry/src/main/ets/pages/Upload.ets) - * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md),[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) - - * 下载模块 - - * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建下载任务,调用@ohos.request中的Task相关接口实现下载任务的创建、取消、进度加载,失败的任务会调用查询接口获取失败原因并打印在日志中,前台下载任务只支持单个文件下载,后台下载任务支持多文件下载,下载到用户目录只支持前台下载。使用[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md)完成指定路径的创建和查询已下载的文件。使用[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md)进行用户文件的目录路径选择和查看。 - * 源码链接:[RequestDownload.ets](./features/uploadanddownload/src/main/ets/download/RequestDownload.ets),[Download.ets](./entry/src/main/ets/pages/Download.ets),[FileUtils.ets](./features/uploadanddownload/src/main/ets/utils/FileUtils.ets),[FileBrowse.ets](./features/uploadanddownload/src/main/ets/components/FileBrowse.ets) - * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md),[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md),[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) - - * 证书锁定模块 - - * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现通过get或者post方式访问指定的网页,点击按钮后会在空白处显示返回的响应header内容。你需要提前在src/main/resources/base/profile/network_config.json中配置domains和digest,只有你配置的证书信息通过验证,上传和下载才可以正常响应。如果你要访问的服务器根证书不在系统中,你需要把它的根证书放在src/main/resources/resfile目录下。 - - * 源码链接,[CertLock.ets](./entry/src/main/ets/pages/CertLock.ets) - - * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md) - - - - - -### 相关权限 - -[ohos.permission.INTERNET](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) - -[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionread_media) - -### 依赖 - -[上传下载服务配置](./environment)。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568。 - -2.本示例为Stage模型,支持API20版本SDK,SDK版本号(API Version 20),镜像版本号(6.0) - -3.本示例需要使用DevEco Studio 版本号(5.0.5 Release)及以上版本才可编译运行。 - -4.运行本示例需全程联网。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```bash -git init -git config core.sparsecheckout true -echo code/BasicFeature/Connectivity/UploadAndDownload/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 上传和下载 + +### 介绍 +本示例使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)接口创建上传和下载任务,实现上传、下载功能,hfs作为服务器,实现了文件的上传和下载和任务的查询功能。 + +### 效果预览 + +| 主页 | 上传 | 片段上传 | 下载 | 下载到用户目录 | 证书锁定 | +| :---------------------------------------: | :---------------------------------------: | :--------------------------------------: | :--------------------------------------: | :--------------------------------------: | ---------------------------------------- | +| ![home](screenshots/devices/zh/home.jpg) | ![util](screenshots/devices/zh/upload.jpg) | ![util](screenshots/devices/zh/uploadchunk.jpg) | ![convertxml](screenshots/devices/zh/download.jpg) | ![convertxml](screenshots/devices/zh/download_user.jpg) | ![cert_lock](screenshots/devices/zh/cert_lock.jpg) | + +使用说明 + +1.本示例功能需要先配置服务器环境后使用,具体配置见[上传下载服务配置](./environment)。 + +2.首页展示上传、下载、下载到用户目录和证书锁定四个入口组件,点击进入对应的页面,如果要使用后台下载任务,请开启后台任务开关。 + +3.上传页面: + +点击 **+**,**从相册选择**拉起图库选择照片,图片选择页面支持拍照,选择照片后点击**上传**进行上传。 + +可选的,点击缩略图,显示文件片段上传配置选项弹窗,可以配置上传起点和终点,取值为闭区间;起点默认为0,终点默认为文件结尾。点击**上传**进行选中文件片段以及后续文件全部内容上传。 + +点击**返回**键或片段上传配置选项弹窗外区域,取消片段上传。 + +在首页中打开后台任务开关后,上传页面开启的是后台上传任务,后台任务在应用退出到后台时可以在通知栏看到任务状态。 + +后台上传**暂停**时,需要服务器支持上传暂停服务(HFS暂不支持此操作)。如仍然使用HFS作为服务器,此时HFS服务将中断文件写入,立即将当前传输的数据保存为文件片段。点击**继续**时则会重新生成一份文件,并在新文件中开始写入。 + +4.下载页面: + +点击文件列表选择要下载的文件后,点击**下载**选择指定路径后开始下载。 + +点击**查看下载文件**进入下载文件页面,点击文件夹查看文件夹内的文件。 + +在首页中打开后台任务开关后,下载页面开启的是后台下载任务,后台任务在应用退出到后台时可以在通知栏看到任务状态。 + +前台下载时只支持单文件下载,后台下载时支持选择多个文件下载。 + +后台下载**暂停**时,本示例功能将自动记录断点。此时HFS服务仍会进行一定时间的传输,但是传输的数据并不会被接受。点击**继续**后将会从上次暂停的断点继续下载。 + +5.证书锁定页面: + +点击**下载**按钮会使用get方式访问百度,并在空白处显示返回的响应header内容。 + +点击**上传**按钮会使用post方式访问百度,并在空白处显示返回的响应header内容。 + +以上功能需要在src/main/resources/base/profile/network_config.json中配置domains和digest,只有你配置的证书信息通过验证,上传和下载才可以正常响应;否则将无法正常访问百度,会通过toast提示上传或者下载失败,日志中会有具体错误信息。如果你要访问的服务器根证书不在系统中,你需要把它的根证书放到src/main/resources/resfile目录下。 + +如示例中访问百度,则digest需要取百度服务器的证书生成: + +```bash +cat server.crt \ +| openssl x509 -noout -pubkey \ +| openssl pkey -pubin -outform der \ +| openssl dgst -sha256 -binary \ +| openssl enc -base64 +``` + +因为服务器证书可能定期更新,所以digest的值需要与服务端证书对应,及时更新。 + +![服务端证书](screenshots/ca.png) + +![获取digest](screenshots/get_digest.png) + + +### 工程目录 + +``` +UploadAndDownload +├── AppScope +│ └── app.json5 //APP信息配置文件 +├── entry/src/main //应用首页 +│ ├── ets +│ │ ├── entryability +│ │ ├── components //自定义组件 +│ │ ├── pages +│ │ │ ├── Index.ets //主页入口 +│ │ │ ├── Download.ets //下载页面 +│ │ │ ├── DownloadFiles.ets //查看下载文件页面 +│ │ │ ├── Upload.ets //上传页面 +│ │ │ ├── CertLock.ets //证书锁定页面 +│ └── module.json5 +│ +├── features/uploadanddownload/src/main //上传和下载 +│ ├── ets +│ │ ├── Index.ets //对外提供的接口列表 +│ │ ├── components +│ │ │ └── FileBrowse.ets //查看下载文件组件 +│ │ ├── download //下载任务相关 +│ │ ├── upload //上传任务相关 +│ │ ├── utils //相关工具类 +│ └── module.json5 +``` + +### 具体实现 + +* 该示例分为三个模块: + * 上传模块 + * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现上传任务的创建、取消、进度加载,失败的任务会调用查询接口获取失败原因并打印在日志中,支持多个文件上传及片段上传。 + * 源码链接:[RequestUpload.ets](./features/uploadanddownload/src/main/ets/upload/RequestUpload.ets),[AddPictures.ets](./entry/src/main/ets/components/AddPictures.ets),[Upload.ets](./entry/src/main/ets/pages/Upload.ets) + * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md),[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) + + * 下载模块 + + * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建下载任务,调用@ohos.request中的Task相关接口实现下载任务的创建、取消、进度加载,失败的任务会调用查询接口获取失败原因并打印在日志中,前台下载任务只支持单个文件下载,后台下载任务支持多文件下载,下载到用户目录只支持前台下载。使用[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md)完成指定路径的创建和查询已下载的文件。使用[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md)进行用户文件的目录路径选择和查看。 + * 源码链接:[RequestDownload.ets](./features/uploadanddownload/src/main/ets/download/RequestDownload.ets),[Download.ets](./entry/src/main/ets/pages/Download.ets),[FileUtils.ets](./features/uploadanddownload/src/main/ets/utils/FileUtils.ets),[FileBrowse.ets](./features/uploadanddownload/src/main/ets/components/FileBrowse.ets) + * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md),[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md),[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) + + * 证书锁定模块 + + * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现通过get或者post方式访问指定的网页,点击按钮后会在空白处显示返回的响应header内容。你需要提前在src/main/resources/base/profile/network_config.json中配置domains和digest,只有你配置的证书信息通过验证,上传和下载才可以正常响应。如果你要访问的服务器根证书不在系统中,你需要把它的根证书放在src/main/resources/resfile目录下。 + + * 源码链接,[CertLock.ets](./entry/src/main/ets/pages/CertLock.ets) + + * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md) + + + + + +### 相关权限 + +[ohos.permission.INTERNET](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) + +[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionread_media) + +### 依赖 + +[上传下载服务配置](./environment)。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568。 + +2.本示例为Stage模型,支持API20版本SDK,SDK版本号(API Version 20),镜像版本号(6.0) + +3.本示例需要使用DevEco Studio 版本号(5.0.5 Release)及以上版本才可编译运行。 + +4.运行本示例需全程联网。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```bash +git init +git config core.sparsecheckout true +echo code/BasicFeature/Connectivity/UploadAndDownload/ > .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/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5 b/code/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5 index 875dfdc535..d6b080d316 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5 +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5 @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 20, - "compatibleSdkVersion": 20, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "uploadanddownload", - "srcPath": "./features/uploadanddownload" - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "uploadanddownload", + "srcPath": "./features/uploadanddownload" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/CertLock.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/CertLock.ets index 5a02607081..1ded11e16c 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/CertLock.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/CertLock.ets @@ -1,192 +1,192 @@ -/* - * Copyright (c) 2024 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 common from '@ohos.app.ability.common'; -import promptAction from '@ohos.promptAction'; -import request from '@ohos.request'; -import connection from '@ohos.net.connection'; -import router from '@ohos.router'; -import { BusinessError } from '@ohos.base'; -import { logger, TOAST_BOTTOM } from '@ohos/uploaddownload'; - -const TAG: string = 'CertLockSample'; - -@Entry -@Component -struct CertLock { - @State message: string = '' - @State taskId: string = ''; - @State progress: string = '0%'; - - build() { - Navigation() { - Text(this.message) - .fontSize(16) - .fontColor($r('app.color.text_message')) - .textAlign(TextAlign.Start) - .id('http_response') - .width('90%') - .height('80%') - .maxLines(30) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - - Button($r('app.string.upload')) - .id('upload') - .width('90%') - .fontSize(16) - .height(40) - .margin({ top: 10, bottom: 20 }) - .enabled(true) - .backgroundColor($r('app.color.button_blue')) - .onClick(() => { - this.uploadTask(); - }) - - Button($r('app.string.download')) - .id('download') - .type(ButtonType.Capsule) - .width('90%') - .fontSize(16) - .fontColor($r('app.color.btn_text_blue')) - .height(40) - .margin({ bottom: 10 }) - .enabled(true) - .backgroundColor($r('app.color.button_light_gray')) - .onClick(() => { - this.DownloadTask(); - }) - } - .width('100%') - .height('100%') - .hideBackButton(false) - .titleMode(NavigationTitleMode.Mini) - .mode(NavigationMode.Stack) - .backgroundColor($r('app.color.light_gray')) - .hideToolBar(false) - .title($r('app.string.cert_lock')) - } - - static task: request.agent.Task; - static netConnection = connection.createNetConnection(); - - async DownloadTask() { - logger.debug(TAG, 'DownloadTask'); - let config: request.agent.Config = { - action: request.agent.Action.DOWNLOAD, - url: 'https://www.baidu.com', - gauge: true, - overwrite: true, - method: 'GET', - network: request.agent.Network.ANY, - }; - let task: request.agent.Task = await request.agent.create(getContext(), config); - CertLock.task = task; - task.on('progress', async (progress) => { - logger.debug(TAG, `/Request download status ${progress.state}, downloaded ${progress.processed}`); - promptAction.showToast({ - message: $r('app.string.download_finish'), - bottom: TOAST_BOTTOM, - offset: { dx: 10, dy: 96 } - }); - this.taskId = task.tid; - }) - let responseOnCallback = (response: request.agent.HttpResponse) => { - logger.debug(TAG, `response : ${response.version} ${response.statusCode} ${response.reason} ${response.headers} ${response.headers.size}`) - let headers: string = ''; - for (let k of response.headers.keys()) { - headers = headers + k + ':' + response.headers.get(k) + '\r\n'; - ; - logger.debug(TAG, `response 1 ${k}, ${response.headers.get(k)}`) - } - this.message = headers; - }; - task.on('response', responseOnCallback); - - task.on('failed', async (progress) => { - this.message = JSON.stringify(progress); - logger.debug(TAG, `/Request download failed ${(JSON.stringify(progress))}`); - promptAction.showToast({ message: $r('app.string.download_fail'), bottom: TOAST_BOTTOM }); - }) - logger.debug(TAG, 'Downloading before'); - await task.start(); - logger.debug(TAG, 'Downloading started'); - } - - async uploadTask() { - logger.debug(TAG, 'uploadTask'); - let attachments: Array = []; - let attachment: request.agent.FormItem = { - name: 'test', - value: [ - { - filename: 'testUpload.txt', - path: './testUpload.txt', - }, - ] - }; - attachments.push(attachment); - let config: request.agent.Config = { - action: request.agent.Action.UPLOAD, - url: 'https://www.baidu.com', - title: 'taskOnTest', - mode: request.agent.Mode.FOREGROUND, - overwrite: true, - method: 'POST', - data: attachments, - saveas: './' - }; - let createOnCallback = (progress: request.agent.Progress) => { - let txt: string = $r('app.string.upload_fail').bundleName; - this.progress = txt + ((progress.processed / 1024 / 1024)); - promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM }); - }; - request.agent.create(getContext(), config).then((task: request.agent.Task) => { - task.start((err: BusinessError) => { - if (err) { - this.progress = `Failed to start the upload task, Code: ${err.code} message: ${err.message}`; - return; - } - }); - task.on('progress', createOnCallback); - let responseOnCallback = (response: request.agent.HttpResponse) => { - logger.debug(TAG, `response : ${response.version} ${response.statusCode} ${response.reason} ${response.headers} ${response.headers.size}`) - let headers: string = ''; - for (let k of response.headers.keys()) { - headers = headers + k + ':' + response.headers.get(k) + '\r\n'; - ; - logger.debug(TAG, `response 1 ${k}, ${response.headers.get(k)}`) - } - this.message = headers; - }; - task.on('response', responseOnCallback); - task.on('failed', async (progress) => { - this.message = JSON.stringify(progress); - logger.debug(TAG, `/Request upload failed ${(JSON.stringify(progress))}`); - promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM }); - }) - logger.debug(TAG, `Succeeded in creating a upload task. result: ${task.tid}`); - }).catch((err: BusinessError) => { - this.progress = `Failed to create a upload task, Code: ${err.code}, message: ${err.message}`; - }); - } - - aboutToAppear() { - logger.debug(TAG, 'aboutToAppear'); - } - - stateChange() { - logger.debug(TAG, 'stateChange'); - } +/* + * Copyright (c) 2024 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 common from '@ohos.app.ability.common'; +import promptAction from '@ohos.promptAction'; +import request from '@ohos.request'; +import connection from '@ohos.net.connection'; +import router from '@ohos.router'; +import { BusinessError } from '@ohos.base'; +import { logger, TOAST_BOTTOM } from '@ohos/uploaddownload'; + +const TAG: string = 'CertLockSample'; + +@Entry +@Component +struct CertLock { + @State message: string = '' + @State taskId: string = ''; + @State progress: string = '0%'; + + build() { + Navigation() { + Text(this.message) + .fontSize(16) + .fontColor($r('app.color.text_message')) + .textAlign(TextAlign.Start) + .id('http_response') + .width('90%') + .height('80%') + .maxLines(30) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + + Button($r('app.string.upload')) + .id('upload') + .width('90%') + .fontSize(16) + .height(40) + .margin({ top: 10, bottom: 20 }) + .enabled(true) + .backgroundColor($r('app.color.button_blue')) + .onClick(() => { + this.uploadTask(); + }) + + Button($r('app.string.download')) + .id('download') + .type(ButtonType.Capsule) + .width('90%') + .fontSize(16) + .fontColor($r('app.color.btn_text_blue')) + .height(40) + .margin({ bottom: 10 }) + .enabled(true) + .backgroundColor($r('app.color.button_light_gray')) + .onClick(() => { + this.DownloadTask(); + }) + } + .width('100%') + .height('100%') + .hideBackButton(false) + .titleMode(NavigationTitleMode.Mini) + .mode(NavigationMode.Stack) + .backgroundColor($r('app.color.light_gray')) + .hideToolBar(false) + .title($r('app.string.cert_lock')) + } + + static task: request.agent.Task; + static netConnection = connection.createNetConnection(); + + async DownloadTask() { + logger.debug(TAG, 'DownloadTask'); + let config: request.agent.Config = { + action: request.agent.Action.DOWNLOAD, + url: 'https://www.baidu.com', + gauge: true, + overwrite: true, + method: 'GET', + network: request.agent.Network.ANY, + }; + let task: request.agent.Task = await request.agent.create(getContext(), config); + CertLock.task = task; + task.on('progress', async (progress) => { + logger.debug(TAG, `/Request download status ${progress.state}, downloaded ${progress.processed}`); + promptAction.showToast({ + message: $r('app.string.download_finish'), + bottom: TOAST_BOTTOM, + offset: { dx: 10, dy: 96 } + }); + this.taskId = task.tid; + }) + let responseOnCallback = (response: request.agent.HttpResponse) => { + logger.debug(TAG, `response : ${response.version} ${response.statusCode} ${response.reason} ${response.headers} ${response.headers.size}`) + let headers: string = ''; + for (let k of response.headers.keys()) { + headers = headers + k + ':' + response.headers.get(k) + '\r\n'; + ; + logger.debug(TAG, `response 1 ${k}, ${response.headers.get(k)}`) + } + this.message = headers; + }; + task.on('response', responseOnCallback); + + task.on('failed', async (progress) => { + this.message = JSON.stringify(progress); + logger.debug(TAG, `/Request download failed ${(JSON.stringify(progress))}`); + promptAction.showToast({ message: $r('app.string.download_fail'), bottom: TOAST_BOTTOM }); + }) + logger.debug(TAG, 'Downloading before'); + await task.start(); + logger.debug(TAG, 'Downloading started'); + } + + async uploadTask() { + logger.debug(TAG, 'uploadTask'); + let attachments: Array = []; + let attachment: request.agent.FormItem = { + name: 'test', + value: [ + { + filename: 'testUpload.txt', + path: './testUpload.txt', + }, + ] + }; + attachments.push(attachment); + let config: request.agent.Config = { + action: request.agent.Action.UPLOAD, + url: 'https://www.baidu.com', + title: 'taskOnTest', + mode: request.agent.Mode.FOREGROUND, + overwrite: true, + method: 'POST', + data: attachments, + saveas: './' + }; + let createOnCallback = (progress: request.agent.Progress) => { + let txt: string = $r('app.string.upload_fail').bundleName; + this.progress = txt + ((progress.processed / 1024 / 1024)); + promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM }); + }; + request.agent.create(getContext(), config).then((task: request.agent.Task) => { + task.start((err: BusinessError) => { + if (err) { + this.progress = `Failed to start the upload task, Code: ${err.code} message: ${err.message}`; + return; + } + }); + task.on('progress', createOnCallback); + let responseOnCallback = (response: request.agent.HttpResponse) => { + logger.debug(TAG, `response : ${response.version} ${response.statusCode} ${response.reason} ${response.headers} ${response.headers.size}`) + let headers: string = ''; + for (let k of response.headers.keys()) { + headers = headers + k + ':' + response.headers.get(k) + '\r\n'; + ; + logger.debug(TAG, `response 1 ${k}, ${response.headers.get(k)}`) + } + this.message = headers; + }; + task.on('response', responseOnCallback); + task.on('failed', async (progress) => { + this.message = JSON.stringify(progress); + logger.debug(TAG, `/Request upload failed ${(JSON.stringify(progress))}`); + promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM }); + }) + logger.debug(TAG, `Succeeded in creating a upload task. result: ${task.tid}`); + }).catch((err: BusinessError) => { + this.progress = `Failed to create a upload task, Code: ${err.code}, message: ${err.message}`; + }); + } + + aboutToAppear() { + logger.debug(TAG, 'aboutToAppear'); + } + + stateChange() { + logger.debug(TAG, 'stateChange'); + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets index 46e6cbaf4a..476f681e7d 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets @@ -1,432 +1,432 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import promptAction from '@ohos.promptAction'; -import router from '@ohos.router'; -import { CustomDataSource } from '../components/CustomDataSource'; -import { - FileModel, - FileType, - fileUtils, - logger, - requestFiles, - requestDownload, - BackgroundTaskState, - TOAST_BOTTOM -} from '@ohos/uploaddownload'; -import { SelectFolderDialog } from '../components/SelectFolderDialog'; -import { common } from '@kit.AbilityKit'; -import { picker } from '@kit.CoreFileKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -const TAG: string = 'DownloadSample'; -const userDir: string = 'file://docs/storage/Users/currentUser'; - -@Entry -@Component -struct Download { - private fileData: CustomDataSource = new CustomDataSource([]); - private documentSelectOptions = new picker.DocumentSelectOptions(); - @StorageLink('isBackground') isBackground: boolean = false; - @StorageLink('backDownTaskState') backDownTaskState: BackgroundTaskState = BackgroundTaskState.NONE; - @StorageLink('downloadServer') downloadServerStr: string = './'; - @Provide downloadFolder: Array = []; - @State isGetData: boolean = false; - @State checkFile: Array = []; - @State checkList: Array = []; - @State isRunning: boolean = false; - @State isUserFolder: boolean = true; - @State isPause: boolean = false; - @State progress: number = 0; - private selectFolder = (folder: string) => { - logger.info(TAG, `selectFolder = ${folder}`); - this.download('./' + folder); - } - private folderDialogController: CustomDialogController = new CustomDialogController({ - builder: SelectFolderDialog({ selectFolder: this.selectFolder }), - autoCancel: true, - alignment: DialogAlignment.Bottom, - offset: { dx: 0, dy: -12 } - }); - async selectUserFolder() { - const documentSaveOptions = new picker.DocumentSaveOptions(); - logger.info(TAG, `documentSaveOptions: ${JSON.stringify(documentSaveOptions)}`) - logger.info(TAG, `documentSelectOptions: ${JSON.stringify(this.documentSelectOptions)}`) - this.checkFile = []; - if (this.checkList === undefined) { - return; - } - logger.info(TAG, `checkList = ${JSON.stringify(this.checkList)}`); - for (let i = 0; i < this.checkList.length; i++) { - if (this.checkList[i]) { - let fileModel = this.fileData.getData(i); - logger.info(TAG, `fileModel = ${JSON.stringify(fileModel)}`); - fileModel.files.forEach((url: string) => { - let splitUrl = url.split('//')[1].split('/'); - if (splitUrl[splitUrl.length-1] !== '') { - this.checkFile.push(url); - documentSaveOptions.newFileNames = [splitUrl[splitUrl.length-1]]; - } - }); - } - } - - logger.info(TAG, `checkFile = ${JSON.stringify(this.checkFile)}`); - - if (this.checkFile.length === 0) { - promptAction.showToast({ message: $r('app.string.check_file_tips'), bottom: TOAST_BOTTOM }); - return; - } - - logger.info(TAG, `documentSaveOptions: ${documentSaveOptions}`) - let context = this.getUIContext().getHostContext() as common.UIAbilityContext; - logger.info(TAG, `context: ${JSON.stringify(context)}`) - const documentViewPicker = new picker.DocumentViewPicker(context); - logger.info(TAG, `documentViewPicker: ${JSON.stringify(documentViewPicker)}`) - await documentViewPicker.save(documentSaveOptions).then((documentSaveResult: Array) => { - logger.info(TAG, `documentSaveResult: ${documentSaveResult}`) - let splitUrl = documentSaveResult[0].split('/'); - logger.info(TAG, `splitUrl: ${splitUrl}`) - splitUrl.pop(); - logger.info(TAG, `splitUrl: ${splitUrl}`) - let splitUrl1=splitUrl.join('/'); - logger.info(TAG, `selectFolder = ${splitUrl1}`); - this.documentSelectOptions.defaultFilePathUri = splitUrl1 - this.download(splitUrl1); - logger.info(TAG, `selectFolder = ${splitUrl1}`); - }).catch((err: BusinessError) => { - logger.error(TAG, `code : ${err.code} message : ${err.message}`) - }); - } - - build() { - Navigation() { - Column() { - if (this.isGetData) { - LoadingProgress() - .width(100) - .layoutWeight(1) - } else { - List({ space: 12 }) { - LazyForEach(this.fileData, (item: FileModel, index?: number) => { - ListItem() { - if (index !== undefined) { - this.FileItem(item, index) - } - } - }, (item: FileModel) => JSON.stringify(item)) - } - .width('100%') - .scrollBar(BarState.Off) - .layoutWeight(1) - .backgroundColor(Color.White) - .borderRadius(24) - .padding({ top: 4, bottom: 4 }) - .divider({ strokeWidth: 1, startMargin: 44, endMargin: 12 }) - } - this.BottomView() - } - .padding({ left: 12, right: 12, bottom: 12 }) - .height('100%') - } - .width('100%') - .height('100%') - .hideBackButton(false) - .titleMode(NavigationTitleMode.Mini) - .mode(NavigationMode.Stack) - .backgroundColor($r('app.color.light_gray')) - .hideToolBar(false) - .title(this.isUserFolder?$r('app.string.downloadToUser'):$r('app.string.download')) - } - - @Builder - FileItem(file: FileModel, index: number) { - Row() { - Row() { - if (file.fileType === FileType.FOLDER) { - Image($r('app.media.ic_files_folder')) - .size({ width: 24, height: 24 }) - .objectFit(ImageFit.Contain) - } else if (file.fileType === FileType.IMAGE) { - Image($r('app.media.ic_public_picture')) - .size({ width: 24, height: 24 }) - .objectFit(ImageFit.Contain) - } else if (file.fileType === FileType.MUSIC) { - Image($r('app.media.ic_public_music')) - .size({ width: 24, height: 24 }) - .objectFit(ImageFit.Contain) - } else if (file.fileType === FileType.Video) { - Image($r('app.media.ic_public_video')) - .size({ width: 24, height: 24 }) - .objectFit(ImageFit.Contain) - } else { - Image($r('app.media.ic_public_document')) - .size({ width: 24, height: 24 }) - .objectFit(ImageFit.Contain) - } - - Text(decodeURIComponent(file.name)) - .fontSize(16) - .fontWeight(400) - .layoutWeight(1) - .maxLines(1) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .margin({ left: 12 }) - } - .layoutWeight(1) - - Checkbox({ name: '', group: 'checkboxGroup' }) - .select(this.checkList[index]) - .selectedColor($r('app.color.button_blue')) - .margin({ left: 12 }) - .hitTestBehavior(HitTestMode.None) - } - .width('100%') - .padding({ left: 12, right: 12 }) - .height(48) - .onClick(() => { - this.fileCheck(index); - }) - } - - @Builder - BottomView() { - Column({ space: 12 }) { - if (this.isBackground && this.backDownTaskState !== BackgroundTaskState.NONE) { - Button() { - Row() { - Text(this.backDownTaskState === BackgroundTaskState.PAUSE ? $r('app.string.continue') : $r('app.string.pause')) - .fontColor(Color.White) - .fontSize(16) - } - } - .id('download_to') - .type(ButtonType.Capsule) - .height(45) - .width('100%') - .backgroundColor($r('app.color.button_blue')) - .onClick(() => { - requestDownload.pauseOrResume(); - }) - - Button() { - Row() { - Text($r('app.string.cancel')) - .fontColor(Color.White) - .fontSize(16) - } - } - .id('download_to') - .type(ButtonType.Capsule) - .height(45) - .width('100%') - .backgroundColor($r('app.color.button_blue')) - .onClick(() => { - requestDownload.deleteAllBackTasks(); - }) - } - if (!this.isBackground || this.isBackground && this.backDownTaskState === BackgroundTaskState.NONE) { - Button() { - Row() { - if (!this.isBackground && this.isRunning) { - Text(`${this.progress}%`) - .fontColor(Color.White) - .fontSize(16) - Text($r('app.string.downloading')) - .fontColor(Color.White) - .fontSize(16) - .margin({ left: 12 }) - } else { - Text(this.isUserFolder?$r('app.string.downloadToUser'):$r('app.string.download')) - .fontColor(Color.White) - .fontSize(16) - } - } - } - .id('download_to') - .type(ButtonType.Capsule) - .height(45) - .width('100%') - .backgroundColor($r('app.color.button_blue')) - .onClick(async () => { - if (!this.isRunning) { - if (this.isUserFolder ) { - await this.selectUserFolder(); - } else { - this.folderDialogController.open(); - } - } - }) - } - Button($r('app.string.view_download_files')) - .id('view_download_files') - .type(ButtonType.Capsule) - .backgroundColor($r('sys.color.ohos_id_color_button_normal')) - .width('100%') - .fontSize(16) - .margin({ bottom: 12 }) - .fontColor($r('app.color.btn_text_blue')) - .onClick(() => { - if (this.isUserFolder ) { - let context = this.getUIContext().getHostContext() as common.UIAbilityContext; - logger.info(TAG, `context: ${JSON.stringify(context)}`) - const documentViewPicker = new picker.DocumentViewPicker(context); - logger.info(TAG, `documentViewPicker: ${JSON.stringify(documentViewPicker)}`) - logger.info(TAG, `documentSelectOptions: ${JSON.stringify(this.documentSelectOptions)}`) - documentViewPicker.select(this.documentSelectOptions).then((documentSelectResult: Array) =>{ - logger.info(TAG, `documentSelectResult: ${documentSelectResult}`) - }) - } else { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - AppStorage.setOrCreate('downloadDir', context.cacheDir); - router.pushUrl({ - url: 'pages/DownloadFiles' - }) - } - }) - } - .margin({ top: 12, left: 12, right: 12 }) - } - - aboutToAppear() { - logger.debug(TAG, 'aboutToAppear'); - this.isRunning = false; - this.isPause = false; - this.isGetData = true; - const params = router.getParams(); - logger.info(`router.params: ${params}`); - if (params) { - this.isUserFolder=true; - this.checkList = []; - this.isRunning = false; - let itemtxt:FileModel = new FileModel('test.txt',false,[this.downloadServerStr + 'test.txt']); - let itemjpg:FileModel = new FileModel('edge_picture.jpg',false,[this.downloadServerStr + 'edge_picture.jpg']); - let itemmp3:FileModel = new FileModel('audio_test.mp3',false,[this.downloadServerStr + 'audio_test.mp3']); - let itemmp4:FileModel = new FileModel('video_media.mp4',false,[this.downloadServerStr + 'video_media.mp4']); - this.fileData.dataArray = [itemtxt,itemjpg,itemmp3,itemmp4] ; - this.fileData.dataArray.forEach((item: FileModel) => { - logger.debug(TAG, `item:${JSON.stringify(item)}`); - this.checkList.push(false); - }) - this.isGetData = false; - this.fileData.notifyDataReload(); - fileUtils.listFolders(userDir).then((folders: Array) => { - logger.debug(TAG, `folders:${JSON.stringify(folders)}`); - this.downloadFolder = folders; - }) - } else { - this.isUserFolder=false; - requestFiles.requestFiles().then((data: FileModel[]) => { - this.checkList = []; - this.isRunning = false; - this.fileData.dataArray = data; - this.fileData.dataArray.forEach((item: FileModel) => { - this.checkList.push(false); - }) - this.isGetData = false; - this.fileData.notifyDataReload(); - }) - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - fileUtils.listFolders(context.cacheDir).then((folders: Array) => { - logger.debug(TAG, `folders:${JSON.stringify(folders)}`); - this.downloadFolder = folders; - }) - } - } - - fileCheck(index: number) { - logger.debug(TAG, `fileCheck= ${index}`); - if (!this.isBackground) { - for (let i = 0; i < this.checkList.length; i++) { - if (i !== index) { - this.checkList[i] = false; - } - } - } - this.checkList[index] = !this.checkList[index]; - logger.info(TAG, `this.checkList = ${JSON.stringify(this.checkList)}`); - } - - download(folder: string) { - logger.debug(TAG, `download folder= ${folder}`); - this.checkFile = []; - if (this.checkList === undefined) { - return; - } - logger.info(TAG, `this.checkList = ${JSON.stringify(this.checkList)}`); - for (let i = 0; i < this.checkList.length; i++) { - if (this.checkList[i]) { - let fileModel = this.fileData.getData(i); - logger.info(TAG, `fileModel = ${JSON.stringify(fileModel)}`); - fileModel.files.forEach((url: string) => { - let splitUrl = url.split('//')[1].split('/'); - if (splitUrl[splitUrl.length-1] !== '') { - this.checkFile.push(url); - } - }); - } - } - logger.info(TAG, `this.checkFile = ${JSON.stringify(this.checkFile)}`); - if (this.checkFile.length === 0) { - promptAction.showToast({ message: $r('app.string.check_file_tips'), bottom: TOAST_BOTTOM }); - return; - } - this.progress = 0; - logger.info(TAG, `this.isBackground = ${JSON.stringify(this.isBackground)}`); - if (this.isBackground) { - this.isRunning = false; - this.backDownTaskState = BackgroundTaskState.RUNNING; - requestDownload.downloadFilesBackground(folder, this.checkFile); - this.checkFile = []; - this.checkList = []; - this.fileData.dataArray.forEach((item: FileModel) => { - this.checkList.push(false); - }) - this.fileData.notifyDataReload(); - promptAction.showToast({ message: $r('app.string.background_task_start'), bottom: TOAST_BOTTOM }); - } else { - this.isRunning = true; - requestDownload.downloadFile(folder, this.checkFile[0], this.downloadFileCallback); - } - } - - downloadFilesCallback = (downloadCount: number, isSuccess: boolean) => { - logger.debug(TAG, 'downloadFilesCallback'); - this.progress = downloadCount; - if (downloadCount === this.checkFile.length) { - this.downloadFinish(isSuccess); - } - } - downloadFileCallback = (progress: number, isSuccess: boolean) => { - logger.debug(TAG, 'downloadFileCallback'); - this.progress = progress; - if (this.progress === 100) { - this.downloadFinish(isSuccess); - } - } - - downloadFinish(isSuccess: boolean) { - logger.debug(TAG, 'downloadFinish'); - this.isRunning = false; - this.checkFile = []; - this.checkList = []; - this.fileData.dataArray.forEach((item: FileModel) => { - this.checkList.push(false); - }) - this.fileData.notifyDataReload(); - let message = isSuccess ? $r('app.string.download_finish') : $r('app.string.download_fail'); - promptAction.showToast({ message: message, bottom: TOAST_BOTTOM }); - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import promptAction from '@ohos.promptAction'; +import router from '@ohos.router'; +import { CustomDataSource } from '../components/CustomDataSource'; +import { + FileModel, + FileType, + fileUtils, + logger, + requestFiles, + requestDownload, + BackgroundTaskState, + TOAST_BOTTOM +} from '@ohos/uploaddownload'; +import { SelectFolderDialog } from '../components/SelectFolderDialog'; +import { common } from '@kit.AbilityKit'; +import { picker } from '@kit.CoreFileKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +const TAG: string = 'DownloadSample'; +const userDir: string = 'file://docs/storage/Users/currentUser'; + +@Entry +@Component +struct Download { + private fileData: CustomDataSource = new CustomDataSource([]); + private documentSelectOptions = new picker.DocumentSelectOptions(); + @StorageLink('isBackground') isBackground: boolean = false; + @StorageLink('backDownTaskState') backDownTaskState: BackgroundTaskState = BackgroundTaskState.NONE; + @StorageLink('downloadServer') downloadServerStr: string = './'; + @Provide downloadFolder: Array = []; + @State isGetData: boolean = false; + @State checkFile: Array = []; + @State checkList: Array = []; + @State isRunning: boolean = false; + @State isUserFolder: boolean = true; + @State isPause: boolean = false; + @State progress: number = 0; + private selectFolder = (folder: string) => { + logger.info(TAG, `selectFolder = ${folder}`); + this.download('./' + folder); + } + private folderDialogController: CustomDialogController = new CustomDialogController({ + builder: SelectFolderDialog({ selectFolder: this.selectFolder }), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -12 } + }); + async selectUserFolder() { + const documentSaveOptions = new picker.DocumentSaveOptions(); + logger.info(TAG, `documentSaveOptions: ${JSON.stringify(documentSaveOptions)}`) + logger.info(TAG, `documentSelectOptions: ${JSON.stringify(this.documentSelectOptions)}`) + this.checkFile = []; + if (this.checkList === undefined) { + return; + } + logger.info(TAG, `checkList = ${JSON.stringify(this.checkList)}`); + for (let i = 0; i < this.checkList.length; i++) { + if (this.checkList[i]) { + let fileModel = this.fileData.getData(i); + logger.info(TAG, `fileModel = ${JSON.stringify(fileModel)}`); + fileModel.files.forEach((url: string) => { + let splitUrl = url.split('//')[1].split('/'); + if (splitUrl[splitUrl.length-1] !== '') { + this.checkFile.push(url); + documentSaveOptions.newFileNames = [splitUrl[splitUrl.length-1]]; + } + }); + } + } + + logger.info(TAG, `checkFile = ${JSON.stringify(this.checkFile)}`); + + if (this.checkFile.length === 0) { + promptAction.showToast({ message: $r('app.string.check_file_tips'), bottom: TOAST_BOTTOM }); + return; + } + + logger.info(TAG, `documentSaveOptions: ${documentSaveOptions}`) + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + logger.info(TAG, `context: ${JSON.stringify(context)}`) + const documentViewPicker = new picker.DocumentViewPicker(context); + logger.info(TAG, `documentViewPicker: ${JSON.stringify(documentViewPicker)}`) + await documentViewPicker.save(documentSaveOptions).then((documentSaveResult: Array) => { + logger.info(TAG, `documentSaveResult: ${documentSaveResult}`) + let splitUrl = documentSaveResult[0].split('/'); + logger.info(TAG, `splitUrl: ${splitUrl}`) + splitUrl.pop(); + logger.info(TAG, `splitUrl: ${splitUrl}`) + let splitUrl1=splitUrl.join('/'); + logger.info(TAG, `selectFolder = ${splitUrl1}`); + this.documentSelectOptions.defaultFilePathUri = splitUrl1 + this.download(splitUrl1); + logger.info(TAG, `selectFolder = ${splitUrl1}`); + }).catch((err: BusinessError) => { + logger.error(TAG, `code : ${err.code} message : ${err.message}`) + }); + } + + build() { + Navigation() { + Column() { + if (this.isGetData) { + LoadingProgress() + .width(100) + .layoutWeight(1) + } else { + List({ space: 12 }) { + LazyForEach(this.fileData, (item: FileModel, index?: number) => { + ListItem() { + if (index !== undefined) { + this.FileItem(item, index) + } + } + }, (item: FileModel) => JSON.stringify(item)) + } + .width('100%') + .scrollBar(BarState.Off) + .layoutWeight(1) + .backgroundColor(Color.White) + .borderRadius(24) + .padding({ top: 4, bottom: 4 }) + .divider({ strokeWidth: 1, startMargin: 44, endMargin: 12 }) + } + this.BottomView() + } + .padding({ left: 12, right: 12, bottom: 12 }) + .height('100%') + } + .width('100%') + .height('100%') + .hideBackButton(false) + .titleMode(NavigationTitleMode.Mini) + .mode(NavigationMode.Stack) + .backgroundColor($r('app.color.light_gray')) + .hideToolBar(false) + .title(this.isUserFolder?$r('app.string.downloadToUser'):$r('app.string.download')) + } + + @Builder + FileItem(file: FileModel, index: number) { + Row() { + Row() { + if (file.fileType === FileType.FOLDER) { + Image($r('app.media.ic_files_folder')) + .size({ width: 24, height: 24 }) + .objectFit(ImageFit.Contain) + } else if (file.fileType === FileType.IMAGE) { + Image($r('app.media.ic_public_picture')) + .size({ width: 24, height: 24 }) + .objectFit(ImageFit.Contain) + } else if (file.fileType === FileType.MUSIC) { + Image($r('app.media.ic_public_music')) + .size({ width: 24, height: 24 }) + .objectFit(ImageFit.Contain) + } else if (file.fileType === FileType.Video) { + Image($r('app.media.ic_public_video')) + .size({ width: 24, height: 24 }) + .objectFit(ImageFit.Contain) + } else { + Image($r('app.media.ic_public_document')) + .size({ width: 24, height: 24 }) + .objectFit(ImageFit.Contain) + } + + Text(decodeURIComponent(file.name)) + .fontSize(16) + .fontWeight(400) + .layoutWeight(1) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .margin({ left: 12 }) + } + .layoutWeight(1) + + Checkbox({ name: '', group: 'checkboxGroup' }) + .select(this.checkList[index]) + .selectedColor($r('app.color.button_blue')) + .margin({ left: 12 }) + .hitTestBehavior(HitTestMode.None) + } + .width('100%') + .padding({ left: 12, right: 12 }) + .height(48) + .onClick(() => { + this.fileCheck(index); + }) + } + + @Builder + BottomView() { + Column({ space: 12 }) { + if (this.isBackground && this.backDownTaskState !== BackgroundTaskState.NONE) { + Button() { + Row() { + Text(this.backDownTaskState === BackgroundTaskState.PAUSE ? $r('app.string.continue') : $r('app.string.pause')) + .fontColor(Color.White) + .fontSize(16) + } + } + .id('download_to') + .type(ButtonType.Capsule) + .height(45) + .width('100%') + .backgroundColor($r('app.color.button_blue')) + .onClick(() => { + requestDownload.pauseOrResume(); + }) + + Button() { + Row() { + Text($r('app.string.cancel')) + .fontColor(Color.White) + .fontSize(16) + } + } + .id('download_to') + .type(ButtonType.Capsule) + .height(45) + .width('100%') + .backgroundColor($r('app.color.button_blue')) + .onClick(() => { + requestDownload.deleteAllBackTasks(); + }) + } + if (!this.isBackground || this.isBackground && this.backDownTaskState === BackgroundTaskState.NONE) { + Button() { + Row() { + if (!this.isBackground && this.isRunning) { + Text(`${this.progress}%`) + .fontColor(Color.White) + .fontSize(16) + Text($r('app.string.downloading')) + .fontColor(Color.White) + .fontSize(16) + .margin({ left: 12 }) + } else { + Text(this.isUserFolder?$r('app.string.downloadToUser'):$r('app.string.download')) + .fontColor(Color.White) + .fontSize(16) + } + } + } + .id('download_to') + .type(ButtonType.Capsule) + .height(45) + .width('100%') + .backgroundColor($r('app.color.button_blue')) + .onClick(async () => { + if (!this.isRunning) { + if (this.isUserFolder ) { + await this.selectUserFolder(); + } else { + this.folderDialogController.open(); + } + } + }) + } + Button($r('app.string.view_download_files')) + .id('view_download_files') + .type(ButtonType.Capsule) + .backgroundColor($r('sys.color.ohos_id_color_button_normal')) + .width('100%') + .fontSize(16) + .margin({ bottom: 12 }) + .fontColor($r('app.color.btn_text_blue')) + .onClick(() => { + if (this.isUserFolder ) { + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + logger.info(TAG, `context: ${JSON.stringify(context)}`) + const documentViewPicker = new picker.DocumentViewPicker(context); + logger.info(TAG, `documentViewPicker: ${JSON.stringify(documentViewPicker)}`) + logger.info(TAG, `documentSelectOptions: ${JSON.stringify(this.documentSelectOptions)}`) + documentViewPicker.select(this.documentSelectOptions).then((documentSelectResult: Array) =>{ + logger.info(TAG, `documentSelectResult: ${documentSelectResult}`) + }) + } else { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + AppStorage.setOrCreate('downloadDir', context.cacheDir); + router.pushUrl({ + url: 'pages/DownloadFiles' + }) + } + }) + } + .margin({ top: 12, left: 12, right: 12 }) + } + + aboutToAppear() { + logger.debug(TAG, 'aboutToAppear'); + this.isRunning = false; + this.isPause = false; + this.isGetData = true; + const params = router.getParams(); + logger.info(`router.params: ${params}`); + if (params) { + this.isUserFolder=true; + this.checkList = []; + this.isRunning = false; + let itemtxt:FileModel = new FileModel('test.txt',false,[this.downloadServerStr + 'test.txt']); + let itemjpg:FileModel = new FileModel('edge_picture.jpg',false,[this.downloadServerStr + 'edge_picture.jpg']); + let itemmp3:FileModel = new FileModel('audio_test.mp3',false,[this.downloadServerStr + 'audio_test.mp3']); + let itemmp4:FileModel = new FileModel('video_media.mp4',false,[this.downloadServerStr + 'video_media.mp4']); + this.fileData.dataArray = [itemtxt,itemjpg,itemmp3,itemmp4] ; + this.fileData.dataArray.forEach((item: FileModel) => { + logger.debug(TAG, `item:${JSON.stringify(item)}`); + this.checkList.push(false); + }) + this.isGetData = false; + this.fileData.notifyDataReload(); + fileUtils.listFolders(userDir).then((folders: Array) => { + logger.debug(TAG, `folders:${JSON.stringify(folders)}`); + this.downloadFolder = folders; + }) + } else { + this.isUserFolder=false; + requestFiles.requestFiles().then((data: FileModel[]) => { + this.checkList = []; + this.isRunning = false; + this.fileData.dataArray = data; + this.fileData.dataArray.forEach((item: FileModel) => { + this.checkList.push(false); + }) + this.isGetData = false; + this.fileData.notifyDataReload(); + }) + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + fileUtils.listFolders(context.cacheDir).then((folders: Array) => { + logger.debug(TAG, `folders:${JSON.stringify(folders)}`); + this.downloadFolder = folders; + }) + } + } + + fileCheck(index: number) { + logger.debug(TAG, `fileCheck= ${index}`); + if (!this.isBackground) { + for (let i = 0; i < this.checkList.length; i++) { + if (i !== index) { + this.checkList[i] = false; + } + } + } + this.checkList[index] = !this.checkList[index]; + logger.info(TAG, `this.checkList = ${JSON.stringify(this.checkList)}`); + } + + download(folder: string) { + logger.debug(TAG, `download folder= ${folder}`); + this.checkFile = []; + if (this.checkList === undefined) { + return; + } + logger.info(TAG, `this.checkList = ${JSON.stringify(this.checkList)}`); + for (let i = 0; i < this.checkList.length; i++) { + if (this.checkList[i]) { + let fileModel = this.fileData.getData(i); + logger.info(TAG, `fileModel = ${JSON.stringify(fileModel)}`); + fileModel.files.forEach((url: string) => { + let splitUrl = url.split('//')[1].split('/'); + if (splitUrl[splitUrl.length-1] !== '') { + this.checkFile.push(url); + } + }); + } + } + logger.info(TAG, `this.checkFile = ${JSON.stringify(this.checkFile)}`); + if (this.checkFile.length === 0) { + promptAction.showToast({ message: $r('app.string.check_file_tips'), bottom: TOAST_BOTTOM }); + return; + } + this.progress = 0; + logger.info(TAG, `this.isBackground = ${JSON.stringify(this.isBackground)}`); + if (this.isBackground) { + this.isRunning = false; + this.backDownTaskState = BackgroundTaskState.RUNNING; + requestDownload.downloadFilesBackground(folder, this.checkFile); + this.checkFile = []; + this.checkList = []; + this.fileData.dataArray.forEach((item: FileModel) => { + this.checkList.push(false); + }) + this.fileData.notifyDataReload(); + promptAction.showToast({ message: $r('app.string.background_task_start'), bottom: TOAST_BOTTOM }); + } else { + this.isRunning = true; + requestDownload.downloadFile(folder, this.checkFile[0], this.downloadFileCallback); + } + } + + downloadFilesCallback = (downloadCount: number, isSuccess: boolean) => { + logger.debug(TAG, 'downloadFilesCallback'); + this.progress = downloadCount; + if (downloadCount === this.checkFile.length) { + this.downloadFinish(isSuccess); + } + } + downloadFileCallback = (progress: number, isSuccess: boolean) => { + logger.debug(TAG, 'downloadFileCallback'); + this.progress = progress; + if (this.progress === 100) { + this.downloadFinish(isSuccess); + } + } + + downloadFinish(isSuccess: boolean) { + logger.debug(TAG, 'downloadFinish'); + this.isRunning = false; + this.checkFile = []; + this.checkList = []; + this.fileData.dataArray.forEach((item: FileModel) => { + this.checkList.push(false); + }) + this.fileData.notifyDataReload(); + let message = isSuccess ? $r('app.string.download_finish') : $r('app.string.download_fail'); + promptAction.showToast({ message: message, bottom: TOAST_BOTTOM }); + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets index cfcacb8950..7bd4321c1e 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets @@ -1,155 +1,155 @@ -/* - * Copyright (c) 2023 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 notificationManager from '@ohos.notificationManager'; -import router from '@ohos.router'; -import common from '@ohos.app.ability.common'; -import { urlUtils } from '@ohos/uploaddownload'; -import { promptAction } from '@kit.ArkUI'; - - -@Styles -function itemStyle() { - .width('100%') - .height(56) - .padding({ top: 17, bottom: 17, left: 12, right: 12 }) - .backgroundColor(Color.White) - .borderRadius(24) - .margin({ top: 20 }) -} - -@Extend(Text) -function textStyle() { - .fontColor($r('app.color.text_normal')) - .fontWeight(400) - .fontFamily('HarmonyHeiTi') - .fontSize(16) -} - -@Entry -@Component -struct Index { - @StorageLink('isBackground') isBackground: boolean = false; - - aboutToAppear() { - notificationManager.requestEnableNotification(); - } - - build() { - Navigation() { - Scroll() { - Column() { - Row() { - Text($r('app.string.background_tips')) - .textStyle() - Blank() - Toggle({ type: ToggleType.Switch, isOn: this.isBackground }) - .width(40) - .height(24) - .onChange((isOn: boolean) => { - this.isBackground = isOn; - AppStorage.setOrCreate('isBackground', isOn); - }) - } - .itemStyle() - .margin({ top: 20 }) - - TextInput({ text: $r('app.string.downloadServer') }) - .visibility(Visibility.Hidden) - .height(0) - .onChange((downloadServer) => AppStorage.setOrCreate('downloadServer', downloadServer)) - - Row() { - Text($r('app.string.HFS_tips')) - .textStyle() - Blank() - TextInput() - .width(250) - .height(40) - .margin({left : 20}) - .onChange((val) => urlUtils.saveUrl(getContext(this) as common.UIAbilityContext,val)) - } - - .itemStyle() - .margin({ top: 15 }) - - this.CapabilityView($r('app.media.ic_upload'), $r('app.string.upload'), 'btn_upload', () => { - router.pushUrl({ - url: 'pages/Upload' - }) - }) - this.CapabilityView($r('app.media.ic_download'), $r('app.string.download'), 'btn_download', () => { - router.pushUrl({ - url: 'pages/Download' - }) - }) - this.CapabilityView($r('app.media.ic_download'), $r('app.string.downloadToUser'), 'btn_downloadToUser', - () => { - if (this.isBackground == false ) { - router.pushUrl({ - url: 'pages/Download', - params: { - action: 'ToUser' - } - }) - } else { - promptAction.showToast({ message: '不支持后台下载到用户目录', duration: 5000 }); - } - }) - this.CapabilityView($r('app.media.ic_certified'), $r('app.string.cert_lock'), 'btn_cert_lock', () => { - router.pushUrl({ - url: 'pages/CertLock' - }) - }) - } - .width('100%') - .margin({ left:-12 }) - } - .padding({ left: 12, right: 6 }) - .height('100%') - .align(Alignment.Top) - } - .width('100%') - .height('100%') - .hideBackButton(true) - .titleMode(NavigationTitleMode.Mini) - .backgroundColor($r('app.color.light_gray')) - .title({ - main: this.getResourceString($r('app.string.EntryAbility_label')), - sub: this.getResourceString($r('app.string.home_tips')) - }) - .padding({ top:5 }) - } - - @Builder - CapabilityView(image: Resource, text: Resource, id: string, onClick: () => void) { - Row() { - Image(image) - .size({ width: 24, height: 24 }) - .objectFit(ImageFit.Cover) - Text(text) - .textStyle() - .margin({ left: 12 }) - } - .itemStyle() - .id(id) - .onClick(onClick) - } - - getResourceString(resource: Resource) { - let context = getContext(this) as common.UIAbilityContext; - return context.resourceManager.getStringSync(resource.id); - } +/* + * Copyright (c) 2023 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 notificationManager from '@ohos.notificationManager'; +import router from '@ohos.router'; +import common from '@ohos.app.ability.common'; +import { urlUtils } from '@ohos/uploaddownload'; +import { promptAction } from '@kit.ArkUI'; + + +@Styles +function itemStyle() { + .width('100%') + .height(56) + .padding({ top: 17, bottom: 17, left: 12, right: 12 }) + .backgroundColor(Color.White) + .borderRadius(24) + .margin({ top: 20 }) +} + +@Extend(Text) +function textStyle() { + .fontColor($r('app.color.text_normal')) + .fontWeight(400) + .fontFamily('HarmonyHeiTi') + .fontSize(16) +} + +@Entry +@Component +struct Index { + @StorageLink('isBackground') isBackground: boolean = false; + + aboutToAppear() { + notificationManager.requestEnableNotification(); + } + + build() { + Navigation() { + Scroll() { + Column() { + Row() { + Text($r('app.string.background_tips')) + .textStyle() + Blank() + Toggle({ type: ToggleType.Switch, isOn: this.isBackground }) + .width(40) + .height(24) + .onChange((isOn: boolean) => { + this.isBackground = isOn; + AppStorage.setOrCreate('isBackground', isOn); + }) + } + .itemStyle() + .margin({ top: 20 }) + + TextInput({ text: $r('app.string.downloadServer') }) + .visibility(Visibility.Hidden) + .height(0) + .onChange((downloadServer) => AppStorage.setOrCreate('downloadServer', downloadServer)) + + Row() { + Text($r('app.string.HFS_tips')) + .textStyle() + Blank() + TextInput() + .width(250) + .height(40) + .margin({left : 20}) + .onChange((val) => urlUtils.saveUrl(getContext(this) as common.UIAbilityContext,val)) + } + + .itemStyle() + .margin({ top: 15 }) + + this.CapabilityView($r('app.media.ic_upload'), $r('app.string.upload'), 'btn_upload', () => { + router.pushUrl({ + url: 'pages/Upload' + }) + }) + this.CapabilityView($r('app.media.ic_download'), $r('app.string.download'), 'btn_download', () => { + router.pushUrl({ + url: 'pages/Download' + }) + }) + this.CapabilityView($r('app.media.ic_download'), $r('app.string.downloadToUser'), 'btn_downloadToUser', + () => { + if (this.isBackground == false ) { + router.pushUrl({ + url: 'pages/Download', + params: { + action: 'ToUser' + } + }) + } else { + promptAction.showToast({ message: '不支持后台下载到用户目录', duration: 5000 }); + } + }) + this.CapabilityView($r('app.media.ic_certified'), $r('app.string.cert_lock'), 'btn_cert_lock', () => { + router.pushUrl({ + url: 'pages/CertLock' + }) + }) + } + .width('100%') + .margin({ left:-12 }) + } + .padding({ left: 12, right: 6 }) + .height('100%') + .align(Alignment.Top) + } + .width('100%') + .height('100%') + .hideBackButton(true) + .titleMode(NavigationTitleMode.Mini) + .backgroundColor($r('app.color.light_gray')) + .title({ + main: this.getResourceString($r('app.string.EntryAbility_label')), + sub: this.getResourceString($r('app.string.home_tips')) + }) + .padding({ top:5 }) + } + + @Builder + CapabilityView(image: Resource, text: Resource, id: string, onClick: () => void) { + Row() { + Image(image) + .size({ width: 24, height: 24 }) + .objectFit(ImageFit.Cover) + Text(text) + .textStyle() + .margin({ left: 12 }) + } + .itemStyle() + .id(id) + .onClick(onClick) + } + + getResourceString(resource: Resource) { + let context = getContext(this) as common.UIAbilityContext; + return context.resourceManager.getStringSync(resource.id); + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets index d47bf2c71a..e7d7bdc916 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets @@ -1,246 +1,246 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import fs from '@ohos.file.fs'; -import promptAction from '@ohos.promptAction'; -import { AddPictures } from '../components/AddPictures'; -import { ConfigFileChunkDialog } from '../components/ConfigFileChunkDialog'; -import { BackgroundTaskState, requestUpload, logger, TOAST_BOTTOM, NO_IMAGE_SELECTED } from '@ohos/uploaddownload'; - -const TIME_MAX: number = 5; -const TAG: string = 'UploadSample'; - -@Entry -@Component -struct Upload { - @StorageLink('isBackground') isBackground: boolean = false; - @StorageLink('backTaskState') @Watch('stateChange') backTaskState: BackgroundTaskState = BackgroundTaskState.NONE; - @State isBegin: boolean = false; - @Provide imageList: Array = []; - @State progress: number = 0; - @State countdown: number = 0; - @Provide @Watch('onChunkImgIndexChange') chunkImgIndex: number = NO_IMAGE_SELECTED; - @Provide chunkInputEnable: boolean = false; - @Provide chunkParaBegins: number = 0; - @Provide chunkParaEnds: number = -1; - chunkDialog: CustomDialogController = new CustomDialogController({ - builder: ConfigFileChunkDialog({ - upload: this.uploadFiles - }), - alignment: DialogAlignment.Bottom, - offset: { dx: 0, dy: -12 }, - cancel: this.onChunkDiaglogCancel - }); - - build() { - Navigation() { - Scroll() { - AddPictures() - } - .padding({ left: 24, right: 24 }) - .width('100%') - .layoutWeight(1) - .align(Alignment.Top) - .margin({ bottom: 24 }) - - Column() { - Button() { - if (this.isBackground && this.backTaskState !== BackgroundTaskState.NONE) { - if (this.backTaskState === BackgroundTaskState.RUNNING) { - Text($r('app.string.pause')) - .fontSize(16) - .fontWeight(500) - .fontColor($r('app.color.white')) - } else { - Text($r('app.string.continue')) - .fontSize(16) - .fontWeight(500) - .fontColor($r('app.color.white')) - } - } else if (this.isBegin && !this.isBackground) { - Row() { - Progress({ value: this.progress, type: ProgressType.Ring }) - .width(20) - .height(20) - .backgroundColor('#FFFFFF') - .color('#558DFF') - .style({ strokeWidth: 2, scaleCount: 100, scaleWidth: 2 }) - Text(`${this.getResourceString($r('app.string.uploading'))}${this.progress}%`) - .fontSize(16) - .fontColor(0xffffff) - .fontWeight(500) - .margin({ left: 12 }) - }.alignItems(VerticalAlign.Center) - } else { - if (this.countdown > 0) { - Text(`${this.countdown}s`) - .fontSize(16) - .fontWeight(500) - .fontColor($r('app.color.white')) - } else { - Text($r('app.string.upload')) - .fontSize(16) - .fontWeight(500) - .fontColor($r('app.color.white')) - } - } - } - .id('publish') - .width('100%') - .height(40) - .margin({ bottom: this.isBegin ? 16 : 24 }) - .enabled(this.countdown > 0 ? false : true) - .backgroundColor($r('app.color.button_blue')) - .onClick(() => { - if (this.isBackground && this.backTaskState !== BackgroundTaskState.NONE) { - requestUpload.pauseOrResume(); - } else { - this.uploadFiles(); - } - }) - - if (this.isBegin) { - Button() { - Text($r('app.string.cancel')) - .fontSize(16) - .fontWeight(500) - .fontColor($r('app.color.btn_text_blue')) - } - .id('cancel') - .width('100%') - .height(40) - .margin({ bottom: 24 }) - .backgroundColor($r('app.color.button_light_gray')) - .onClick(() => { - // 取消上传任务 - requestUpload.cancelTask(); - this.progress = 0; - this.isBegin = false; - }) - } - } - .width('100%') - .padding({ left: 24, right: 24 }) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.light_gray')) - .title($r('app.string.upload')) - .hideBackButton(false) - .titleMode(NavigationTitleMode.Mini) - .mode(NavigationMode.Stack) - } - - aboutToAppear() { - logger.debug(TAG, 'aboutToAppear'); - this.isBegin = false; - this.backTaskState = BackgroundTaskState.NONE; - } - - stateChange() { - logger.debug(TAG, 'stateChange'); - if (this.backTaskState === BackgroundTaskState.NONE) { - this.imageList = []; - } - } - - uploadFiles() { - logger.debug(TAG, 'uploadFiles'); - if (this.imageList.length == 0) { - return; - } - - if (this.chunkInputEnable) { // 选中checkbox,从该文件分段上传 - this.isBegin = true; - this.progress = 0; - let index = this.chunkImgIndex; - let fileUris = this.imageList.slice(index); - logger.debug(TAG + 'fileuri:' + fileUris); - requestUpload.uploadFileChunk(fileUris, this.chunkParaBegins, this.chunkParaEnds, (progress: number, isSucceed: boolean) => { - this.progress = progress; - if (this.progress === 100 && isSucceed) { - this.isBegin = false; - this.imageList = this.imageList.slice(0, index); - promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM }); - } - if (this.progress === 100 && isSucceed === false) { - this.isBegin = false; - this.countdown = TIME_MAX; - let interval = setInterval(() => { - if (this.countdown > 0) { - this.countdown--; - } else { - clearInterval(interval); - } - }, 1000); - promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM }); - } - }); - return; - } - logger.debug(TAG + ':imageList:' + this.imageList); - if (this.isBackground) { - AppStorage.setOrCreate('backTaskState', BackgroundTaskState.RUNNING); - requestUpload.uploadFilesBackground(this.imageList); - promptAction.showToast({ message: $r('app.string.background_task_start'), bottom: TOAST_BOTTOM }); - } else { - this.isBegin = true; - this.progress = 0; - requestUpload.uploadFiles(this.imageList, (progress: number, isSucceed: boolean) => { - this.progress = progress; - if (this.progress === 100 && isSucceed) { - this.isBegin = false; - this.imageList = []; - promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM }) - } - if (this.progress === 100 && isSucceed === false) { - this.isBegin = false; - this.countdown = TIME_MAX; - let interval = setInterval(() => { - if (this.countdown > 0) { - this.countdown--; - } else { - clearInterval(interval); - } - }, 1000); - promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM }) - } - }); - } - } - - getResourceString(resource: Resource) { - let context = getContext(this) as common.UIAbilityContext; - let res = context.resourceManager.getStringSync(resource.id); - logger.debug(TAG + ':****' + res); - return res; - } - - onChunkImgIndexChange(propName: string) { - logger.debug(TAG, 'onChunkImgIndexChange'); - if (this.chunkImgIndex != NO_IMAGE_SELECTED) { - this.chunkDialog.open(); - } - this.chunkInputEnable = false; - this.chunkParaBegins = 0; - this.chunkParaEnds = -1; - } - - onChunkDiaglogCancel() { - logger.debug(TAG, 'onChunkDiaglogCancel'); - this.chunkImgIndex = NO_IMAGE_SELECTED; - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import fs from '@ohos.file.fs'; +import promptAction from '@ohos.promptAction'; +import { AddPictures } from '../components/AddPictures'; +import { ConfigFileChunkDialog } from '../components/ConfigFileChunkDialog'; +import { BackgroundTaskState, requestUpload, logger, TOAST_BOTTOM, NO_IMAGE_SELECTED } from '@ohos/uploaddownload'; + +const TIME_MAX: number = 5; +const TAG: string = 'UploadSample'; + +@Entry +@Component +struct Upload { + @StorageLink('isBackground') isBackground: boolean = false; + @StorageLink('backTaskState') @Watch('stateChange') backTaskState: BackgroundTaskState = BackgroundTaskState.NONE; + @State isBegin: boolean = false; + @Provide imageList: Array = []; + @State progress: number = 0; + @State countdown: number = 0; + @Provide @Watch('onChunkImgIndexChange') chunkImgIndex: number = NO_IMAGE_SELECTED; + @Provide chunkInputEnable: boolean = false; + @Provide chunkParaBegins: number = 0; + @Provide chunkParaEnds: number = -1; + chunkDialog: CustomDialogController = new CustomDialogController({ + builder: ConfigFileChunkDialog({ + upload: this.uploadFiles + }), + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -12 }, + cancel: this.onChunkDiaglogCancel + }); + + build() { + Navigation() { + Scroll() { + AddPictures() + } + .padding({ left: 24, right: 24 }) + .width('100%') + .layoutWeight(1) + .align(Alignment.Top) + .margin({ bottom: 24 }) + + Column() { + Button() { + if (this.isBackground && this.backTaskState !== BackgroundTaskState.NONE) { + if (this.backTaskState === BackgroundTaskState.RUNNING) { + Text($r('app.string.pause')) + .fontSize(16) + .fontWeight(500) + .fontColor($r('app.color.white')) + } else { + Text($r('app.string.continue')) + .fontSize(16) + .fontWeight(500) + .fontColor($r('app.color.white')) + } + } else if (this.isBegin && !this.isBackground) { + Row() { + Progress({ value: this.progress, type: ProgressType.Ring }) + .width(20) + .height(20) + .backgroundColor('#FFFFFF') + .color('#558DFF') + .style({ strokeWidth: 2, scaleCount: 100, scaleWidth: 2 }) + Text(`${this.getResourceString($r('app.string.uploading'))}${this.progress}%`) + .fontSize(16) + .fontColor(0xffffff) + .fontWeight(500) + .margin({ left: 12 }) + }.alignItems(VerticalAlign.Center) + } else { + if (this.countdown > 0) { + Text(`${this.countdown}s`) + .fontSize(16) + .fontWeight(500) + .fontColor($r('app.color.white')) + } else { + Text($r('app.string.upload')) + .fontSize(16) + .fontWeight(500) + .fontColor($r('app.color.white')) + } + } + } + .id('publish') + .width('100%') + .height(40) + .margin({ bottom: this.isBegin ? 16 : 24 }) + .enabled(this.countdown > 0 ? false : true) + .backgroundColor($r('app.color.button_blue')) + .onClick(() => { + if (this.isBackground && this.backTaskState !== BackgroundTaskState.NONE) { + requestUpload.pauseOrResume(); + } else { + this.uploadFiles(); + } + }) + + if (this.isBegin) { + Button() { + Text($r('app.string.cancel')) + .fontSize(16) + .fontWeight(500) + .fontColor($r('app.color.btn_text_blue')) + } + .id('cancel') + .width('100%') + .height(40) + .margin({ bottom: 24 }) + .backgroundColor($r('app.color.button_light_gray')) + .onClick(() => { + // 取消上传任务 + requestUpload.cancelTask(); + this.progress = 0; + this.isBegin = false; + }) + } + } + .width('100%') + .padding({ left: 24, right: 24 }) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.light_gray')) + .title($r('app.string.upload')) + .hideBackButton(false) + .titleMode(NavigationTitleMode.Mini) + .mode(NavigationMode.Stack) + } + + aboutToAppear() { + logger.debug(TAG, 'aboutToAppear'); + this.isBegin = false; + this.backTaskState = BackgroundTaskState.NONE; + } + + stateChange() { + logger.debug(TAG, 'stateChange'); + if (this.backTaskState === BackgroundTaskState.NONE) { + this.imageList = []; + } + } + + uploadFiles() { + logger.debug(TAG, 'uploadFiles'); + if (this.imageList.length == 0) { + return; + } + + if (this.chunkInputEnable) { // 选中checkbox,从该文件分段上传 + this.isBegin = true; + this.progress = 0; + let index = this.chunkImgIndex; + let fileUris = this.imageList.slice(index); + logger.debug(TAG + 'fileuri:' + fileUris); + requestUpload.uploadFileChunk(fileUris, this.chunkParaBegins, this.chunkParaEnds, (progress: number, isSucceed: boolean) => { + this.progress = progress; + if (this.progress === 100 && isSucceed) { + this.isBegin = false; + this.imageList = this.imageList.slice(0, index); + promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM }); + } + if (this.progress === 100 && isSucceed === false) { + this.isBegin = false; + this.countdown = TIME_MAX; + let interval = setInterval(() => { + if (this.countdown > 0) { + this.countdown--; + } else { + clearInterval(interval); + } + }, 1000); + promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM }); + } + }); + return; + } + logger.debug(TAG + ':imageList:' + this.imageList); + if (this.isBackground) { + AppStorage.setOrCreate('backTaskState', BackgroundTaskState.RUNNING); + requestUpload.uploadFilesBackground(this.imageList); + promptAction.showToast({ message: $r('app.string.background_task_start'), bottom: TOAST_BOTTOM }); + } else { + this.isBegin = true; + this.progress = 0; + requestUpload.uploadFiles(this.imageList, (progress: number, isSucceed: boolean) => { + this.progress = progress; + if (this.progress === 100 && isSucceed) { + this.isBegin = false; + this.imageList = []; + promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM }) + } + if (this.progress === 100 && isSucceed === false) { + this.isBegin = false; + this.countdown = TIME_MAX; + let interval = setInterval(() => { + if (this.countdown > 0) { + this.countdown--; + } else { + clearInterval(interval); + } + }, 1000); + promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM }) + } + }); + } + } + + getResourceString(resource: Resource) { + let context = getContext(this) as common.UIAbilityContext; + let res = context.resourceManager.getStringSync(resource.id); + logger.debug(TAG + ':****' + res); + return res; + } + + onChunkImgIndexChange(propName: string) { + logger.debug(TAG, 'onChunkImgIndexChange'); + if (this.chunkImgIndex != NO_IMAGE_SELECTED) { + this.chunkDialog.open(); + } + this.chunkInputEnable = false; + this.chunkParaBegins = 0; + this.chunkParaEnds = -1; + } + + onChunkDiaglogCancel() { + logger.debug(TAG, 'onChunkDiaglogCancel'); + this.chunkImgIndex = NO_IMAGE_SELECTED; + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/color.json index c11c9fb284..123baf3b97 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/color.json @@ -1,44 +1,44 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "text_normal", - "value": "#182431" - }, - { - "name": "button_light_gray", - "value": "#0C182431" - }, - { - "name": "button_blue", - "value": "#007DFF" - }, - { - "name": "btn_text_blue", - "value": "#007DFF" - }, - { - "name": "maskColor", - "value": "#66182431" - }, - { - "name": "white", - "value": "#FFFFFF" - }, - { - "name": "gray", - "value": "#F7F7F7" - }, - { - "name": "light_gray", - "value": "#F1F3F5" - }, - { - "name": "text_message", - "value": "#99182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "text_normal", + "value": "#182431" + }, + { + "name": "button_light_gray", + "value": "#0C182431" + }, + { + "name": "button_blue", + "value": "#007DFF" + }, + { + "name": "btn_text_blue", + "value": "#007DFF" + }, + { + "name": "maskColor", + "value": "#66182431" + }, + { + "name": "white", + "value": "#FFFFFF" + }, + { + "name": "gray", + "value": "#F7F7F7" + }, + { + "name": "light_gray", + "value": "#F1F3F5" + }, + { + "name": "text_message", + "value": "#99182431" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json index 15f5c8c410..226a25be48 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json @@ -1,156 +1,156 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "UploadAndDownload" - }, - { - "name": "upload", - "value": "Upload" - }, - { - "name": "upload_fail", - "value": "Upload fail,resume upload later" - }, - { - "name": "upload_success", - "value": "Upload success,continue upload" - }, - { - "name": "uploading", - "value": "Uploading" - }, - { - "name": "user_tip", - "value": "Feature development" - }, - { - "name": "open", - "value": "Open" - }, - { - "name": "anyone", - "value": "Anyone" - }, - { - "name": "gps", - "value": "Location" - }, - { - "name": "tip", - "value": "Thoughts of the moment..." - }, - { - "name": "pick_album", - "value": "Pick from album" - }, - { - "name": "ok", - "value": "OK" - }, - { - "name": "cancel", - "value": "Cancel" - }, - { - "name": "check_file_tips", - "value": "Please check files" - }, - { - "name": "download", - "value": "Download" - }, - { - "name": "downloadToApplication", - "value": "downloadToApplication" - }, - { - "name": "downloadToUser", - "value": "DownloadToUser" - }, - { - "name": "downloadServer", - "value": "https://gitee.com/tiga-ultraman/downloadTests/releases/download/v1.01/" - }, - { - "name": "download_to", - "value": "Select a download location" - }, - { - "name": "view_download_files", - "value": "View download files" - }, - { - "name": "download_finish", - "value": "Download finish" - }, - { - "name": "download_fail", - "value": "Download fail" - }, - { - "name": "pause", - "value": "Pause" - }, - { - "name": "downloading", - "value": "Downloading" - }, - { - "name": "continue", - "value": "Continue" - }, - { - "name": "media_permission", - "value": "Allows the app to read media file information from the user's external storage" - }, - { - "name": "media_internet_permission", - "value": "Allow access to the network" - }, - { - "name": "background_tips", - "value": "Whether to start background tasks" - }, - { - "name": "HFS_tips", - "value": "HFS Address" - }, - { - "name": "home_tips", - "value": "Demonstrate foreground and background upload and download tasks" - }, - { - "name": "background_task_start", - "value": "The background task has started, and you can check the download status in the notification bar" - }, - { - "name": "chunk_checkbox_tips", - "value": "Upload from this file's chunk" - }, - { - "name": "chunk_begins", - "value": "Null, input the value which uploading from the certain byte" - }, - { - "name": "chunk_ends", - "value": "Null, input the value which uploading to the certain byte" - }, - { - "name": "chunk_para_invalid", - "value": "Begins or Ends is invalid" - }, - { - "name": "cert_lock", - "value": "Cert lock" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "UploadAndDownload" + }, + { + "name": "upload", + "value": "Upload" + }, + { + "name": "upload_fail", + "value": "Upload fail,resume upload later" + }, + { + "name": "upload_success", + "value": "Upload success,continue upload" + }, + { + "name": "uploading", + "value": "Uploading" + }, + { + "name": "user_tip", + "value": "Feature development" + }, + { + "name": "open", + "value": "Open" + }, + { + "name": "anyone", + "value": "Anyone" + }, + { + "name": "gps", + "value": "Location" + }, + { + "name": "tip", + "value": "Thoughts of the moment..." + }, + { + "name": "pick_album", + "value": "Pick from album" + }, + { + "name": "ok", + "value": "OK" + }, + { + "name": "cancel", + "value": "Cancel" + }, + { + "name": "check_file_tips", + "value": "Please check files" + }, + { + "name": "download", + "value": "Download" + }, + { + "name": "downloadToApplication", + "value": "downloadToApplication" + }, + { + "name": "downloadToUser", + "value": "DownloadToUser" + }, + { + "name": "downloadServer", + "value": "https://gitee.com/tiga-ultraman/downloadTests/releases/download/v1.01/" + }, + { + "name": "download_to", + "value": "Select a download location" + }, + { + "name": "view_download_files", + "value": "View download files" + }, + { + "name": "download_finish", + "value": "Download finish" + }, + { + "name": "download_fail", + "value": "Download fail" + }, + { + "name": "pause", + "value": "Pause" + }, + { + "name": "downloading", + "value": "Downloading" + }, + { + "name": "continue", + "value": "Continue" + }, + { + "name": "media_permission", + "value": "Allows the app to read media file information from the user's external storage" + }, + { + "name": "media_internet_permission", + "value": "Allow access to the network" + }, + { + "name": "background_tips", + "value": "Whether to start background tasks" + }, + { + "name": "HFS_tips", + "value": "HFS Address" + }, + { + "name": "home_tips", + "value": "Demonstrate foreground and background upload and download tasks" + }, + { + "name": "background_task_start", + "value": "The background task has started, and you can check the download status in the notification bar" + }, + { + "name": "chunk_checkbox_tips", + "value": "Upload from this file's chunk" + }, + { + "name": "chunk_begins", + "value": "Null, input the value which uploading from the certain byte" + }, + { + "name": "chunk_ends", + "value": "Null, input the value which uploading to the certain byte" + }, + { + "name": "chunk_para_invalid", + "value": "Begins or Ends is invalid" + }, + { + "name": "cert_lock", + "value": "Cert lock" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/main_pages.json index f76da0fb65..7f87ebc087 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/main_pages.json +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/main_pages.json @@ -1,9 +1,9 @@ -{ - "src": [ - "pages/Index", - "pages/Upload", - "pages/Download", - "pages/CertLock", - "pages/DownloadFiles" - ] +{ + "src": [ + "pages/Index", + "pages/Upload", + "pages/Download", + "pages/CertLock", + "pages/DownloadFiles" + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/network_config.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/network_config.json index 9f8de4095b..58d3c06a31 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/network_config.json +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/network_config.json @@ -1,24 +1,24 @@ -{ - "network-security-config": { - "domain-config": [ - { - "domains": [ - { - "include-subdomains": true, - "name": "www.baidu.com" - } - ], - "trust-anchors": [{"certificates": "/data/storage/el1/bundle/entry/resources/resfile/"}], - "pin-set": { - "expiration": "2025-04-08", - "pin": [ - { - "digest-algorithm": "sha256", - "digest": "g8CsdcpyAKxmLoWFvMd2hC7ZDUy7L4E2NYOi1i8qEtE=" - } - ] - } - } - ] - } +{ + "network-security-config": { + "domain-config": [ + { + "domains": [ + { + "include-subdomains": true, + "name": "www.baidu.com" + } + ], + "trust-anchors": [{"certificates": "/data/storage/el1/bundle/entry/resources/resfile/"}], + "pin-set": { + "expiration": "2025-04-08", + "pin": [ + { + "digest-algorithm": "sha256", + "digest": "g8CsdcpyAKxmLoWFvMd2hC7ZDUy7L4E2NYOi1i8qEtE=" + } + ] + } + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json index ab355f1e97..02a6c62408 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json @@ -1,152 +1,152 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "UploadAndDownload" - }, - { - "name": "upload", - "value": "Upload" - }, - { - "name": "upload_fail", - "value": "Upload fail,resume upload later" - }, - { - "name": "upload_success", - "value": "Upload success,continue upload" - }, - { - "name": "uploading", - "value": "Uploading" - }, - { - "name": "user_tip", - "value": "Feature development" - }, - { - "name": "open", - "value": "Open" - }, - { - "name": "anyone", - "value": "Anyone" - }, - { - "name": "gps", - "value": "Location" - }, - { - "name": "tip", - "value": "Thoughts of the moment..." - }, - { - "name": "pick_album", - "value": "Pick from album" - }, - { - "name": "ok", - "value": "OK" - }, - { - "name": "cancel", - "value": "Cancel" - }, - { - "name": "check_file_tips", - "value": "Please check files" - }, - { - "name": "download", - "value": "Download" - }, - { - "name": "downloading", - "value": "Downloading" - }, - { - "name": "download_to", - "value": "Select a download location" - }, - { - "name": "view_download_files", - "value": "View download files" - }, - { - "name": "download_finish", - "value": "Download finish" - }, - { - "name": "download_fail", - "value": "Download fail" - }, - { - "name": "pause", - "value": "Pause" - }, - { - "name": "continue", - "value": "Continue" - }, - { - "name": "media_permission", - "value": "Allows the app to read media file information from the user's external storage" - }, - { - "name": "media_internet_permission", - "value": "Allow access to the network" - }, - { - "name": "background_tips", - "value": "Whether to start background tasks" - }, - { - "name": "HFS_tips", - "value": "HFS Address" - }, - { - "name": "home_tips", - "value": "Demonstrate foreground and background upload and download tasks" - }, - { - "name": "background_task_start", - "value": "The background task has started, and you can check the download status in the notification bar" - }, - { - "name": "chunk_checkbox_tips", - "value": "Upload from this file's chunk" - }, - { - "name": "chunk_begins", - "value": "Null, input the value which uploading from the certain byte" - }, - { - "name": "chunk_ends", - "value": "Null, input the value which uploading to the certain byte" - }, - { - "name": "chunk_para_invalid", - "value": "Begins or Ends is invalid" - }, - { - "name": "cert_lock", - "value": "Cert lock" - }, - { - "name": "downloadToUser", - "value": "DownloadToUser" - }, - { - "name": "downloadToApplication", - "value": "DownloadToApplication" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "UploadAndDownload" + }, + { + "name": "upload", + "value": "Upload" + }, + { + "name": "upload_fail", + "value": "Upload fail,resume upload later" + }, + { + "name": "upload_success", + "value": "Upload success,continue upload" + }, + { + "name": "uploading", + "value": "Uploading" + }, + { + "name": "user_tip", + "value": "Feature development" + }, + { + "name": "open", + "value": "Open" + }, + { + "name": "anyone", + "value": "Anyone" + }, + { + "name": "gps", + "value": "Location" + }, + { + "name": "tip", + "value": "Thoughts of the moment..." + }, + { + "name": "pick_album", + "value": "Pick from album" + }, + { + "name": "ok", + "value": "OK" + }, + { + "name": "cancel", + "value": "Cancel" + }, + { + "name": "check_file_tips", + "value": "Please check files" + }, + { + "name": "download", + "value": "Download" + }, + { + "name": "downloading", + "value": "Downloading" + }, + { + "name": "download_to", + "value": "Select a download location" + }, + { + "name": "view_download_files", + "value": "View download files" + }, + { + "name": "download_finish", + "value": "Download finish" + }, + { + "name": "download_fail", + "value": "Download fail" + }, + { + "name": "pause", + "value": "Pause" + }, + { + "name": "continue", + "value": "Continue" + }, + { + "name": "media_permission", + "value": "Allows the app to read media file information from the user's external storage" + }, + { + "name": "media_internet_permission", + "value": "Allow access to the network" + }, + { + "name": "background_tips", + "value": "Whether to start background tasks" + }, + { + "name": "HFS_tips", + "value": "HFS Address" + }, + { + "name": "home_tips", + "value": "Demonstrate foreground and background upload and download tasks" + }, + { + "name": "background_task_start", + "value": "The background task has started, and you can check the download status in the notification bar" + }, + { + "name": "chunk_checkbox_tips", + "value": "Upload from this file's chunk" + }, + { + "name": "chunk_begins", + "value": "Null, input the value which uploading from the certain byte" + }, + { + "name": "chunk_ends", + "value": "Null, input the value which uploading to the certain byte" + }, + { + "name": "chunk_para_invalid", + "value": "Begins or Ends is invalid" + }, + { + "name": "cert_lock", + "value": "Cert lock" + }, + { + "name": "downloadToUser", + "value": "DownloadToUser" + }, + { + "name": "downloadToApplication", + "value": "DownloadToApplication" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json index 3e42b66c3f..02c3643259 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json @@ -1,152 +1,152 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "上传下载" - }, - { - "name": "upload", - "value": "上传" - }, - { - "name": "upload_fail", - "value": "上传失败,稍后继续上传" - }, - { - "name": "upload_success", - "value": "上传成功,继续上传" - }, - { - "name": "uploading", - "value": "已上传" - }, - { - "name": "user_tip", - "value": "功能开发中" - }, - { - "name": "open", - "value": "公开" - }, - { - "name": "anyone", - "value": "谁可以看" - }, - { - "name": "gps", - "value": "所在位置" - }, - { - "name": "tip", - "value": "这一刻的想法..." - }, - { - "name": "pick_album", - "value": "从相册选择" - }, - { - "name": "ok", - "value": "确定" - }, - { - "name": "cancel", - "value": "取消" - }, - { - "name": "check_file_tips", - "value": "请选择文件" - }, - { - "name": "download", - "value": "下载" - }, - { - "name": "downloading", - "value": "已下载" - }, - { - "name": "view_download_files", - "value": "查看下载文件" - }, - { - "name": "download_to", - "value": "选择下载位置" - }, - { - "name": "download_finish", - "value": "下载完成" - }, - { - "name": "download_fail", - "value": "下载失败" - }, - { - "name": "pause", - "value": "暂停" - }, - { - "name": "continue", - "value": "继续" - }, - { - "name": "media_permission", - "value": "允许应用读取用户外部存储中的媒体文件信息" - }, - { - "name": "media_internet_permission", - "value": "允许访问网络" - }, - { - "name": "background_tips", - "value": "是否开启后台任务" - }, - { - "name": "HFS_tips", - "value": "HFS 地址" - }, - { - "name": "home_tips", - "value": "演示前台和后台上传和下载任务" - }, - { - "name": "background_task_start", - "value": "后台任务已开始,可在通知栏查看下载状态" - }, - { - "name": "chunk_checkbox_tips", - "value": "从当前文件开始片段上传" - }, - { - "name": "chunk_begins", - "value": "空,填入任意数值,表示从某字节开始上传该文件" - }, - { - "name": "chunk_ends", - "value": "空,填入任意数值,表示从某字节结束上传该文件" - }, - { - "name": "chunk_para_invalid", - "value": "Begins 或 Ends 无效" - }, - { - "name": "cert_lock", - "value": "证书锁定" - }, - { - "name": "downloadToUser", - "value": "下载到用户目录" - }, - { - "name": "downloadToApplication", - "value": "下载到应用目录" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "上传下载" + }, + { + "name": "upload", + "value": "上传" + }, + { + "name": "upload_fail", + "value": "上传失败,稍后继续上传" + }, + { + "name": "upload_success", + "value": "上传成功,继续上传" + }, + { + "name": "uploading", + "value": "已上传" + }, + { + "name": "user_tip", + "value": "功能开发中" + }, + { + "name": "open", + "value": "公开" + }, + { + "name": "anyone", + "value": "谁可以看" + }, + { + "name": "gps", + "value": "所在位置" + }, + { + "name": "tip", + "value": "这一刻的想法..." + }, + { + "name": "pick_album", + "value": "从相册选择" + }, + { + "name": "ok", + "value": "确定" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "check_file_tips", + "value": "请选择文件" + }, + { + "name": "download", + "value": "下载" + }, + { + "name": "downloading", + "value": "已下载" + }, + { + "name": "view_download_files", + "value": "查看下载文件" + }, + { + "name": "download_to", + "value": "选择下载位置" + }, + { + "name": "download_finish", + "value": "下载完成" + }, + { + "name": "download_fail", + "value": "下载失败" + }, + { + "name": "pause", + "value": "暂停" + }, + { + "name": "continue", + "value": "继续" + }, + { + "name": "media_permission", + "value": "允许应用读取用户外部存储中的媒体文件信息" + }, + { + "name": "media_internet_permission", + "value": "允许访问网络" + }, + { + "name": "background_tips", + "value": "是否开启后台任务" + }, + { + "name": "HFS_tips", + "value": "HFS 地址" + }, + { + "name": "home_tips", + "value": "演示前台和后台上传和下载任务" + }, + { + "name": "background_task_start", + "value": "后台任务已开始,可在通知栏查看下载状态" + }, + { + "name": "chunk_checkbox_tips", + "value": "从当前文件开始片段上传" + }, + { + "name": "chunk_begins", + "value": "空,填入任意数值,表示从某字节开始上传该文件" + }, + { + "name": "chunk_ends", + "value": "空,填入任意数值,表示从某字节结束上传该文件" + }, + { + "name": "chunk_para_invalid", + "value": "Begins 或 Ends 无效" + }, + { + "name": "cert_lock", + "value": "证书锁定" + }, + { + "name": "downloadToUser", + "value": "下载到用户目录" + }, + { + "name": "downloadToApplication", + "value": "下载到应用目录" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets index 8e1f1051f3..3480370f75 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets @@ -1,230 +1,230 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import request from '@ohos.request'; -import promptAction from '@ohos.promptAction'; -import { logger } from '../utils/Logger'; -import { BackgroundTaskState, TASK_MAX, TOAST_BOTTOM } from '../utils/Constants'; - -const TAG: string = 'RequestDownload'; - -class RequestDownload { - private context: common.UIAbilityContext | undefined = undefined; - private waitList: Array = []; - private downloadTask: request.agent.Task | undefined = undefined; - private backgroundDownloadTaskList: Array = []; - - constructor() { - setInterval(() => { - this.flushBackgroundTask() - }, 2000); - } - - async downloadFilesBackground(folder: string, files: Array) { - logger.info(TAG, 'downloadFiles'); - this.context = getContext(this) as common.UIAbilityContext; - files.forEach((item: string) => { - this.waitList.push([folder, item]); - }); - } - - async flushBackgroundTask() { - let tasks = await request.agent.search({ - state: request.agent.State.RUNNING - }); - if (tasks.length < TASK_MAX && this.waitList.length > 0) { - let downloadList: Array = []; - if (this.waitList.length <= TASK_MAX - tasks.length) { - downloadList = this.waitList; - this.waitList = []; - } else { - downloadList = this.waitList.slice(0, TASK_MAX - tasks.length); - this.waitList = this.waitList.slice(TASK_MAX - tasks.length, this.waitList.length); - } - logger.info(TAG, `this.waitList = ${JSON.stringify(this.waitList)}`); - this.createBackgroundTask(downloadList); - } else { - let state = AppStorage.get('backDownTaskState'); - logger.info(TAG, `backLists = ${this.backgroundDownloadTaskList.map(i => i.tid)}`); - if (state === BackgroundTaskState.RUNNING) { - if (tasks.length === 0) { - AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.NONE); - this.backgroundDownloadTaskList = []; - } - } - } - } - - async createBackgroundTask(downloadList: Array) { - if (this.context === undefined) { - return; - } - for (let i = 0; i < downloadList.length; i++) { - try { - let splitUrl = downloadList[i][1].split('//')[1].split('/'); - let downloadConfig: request.agent.Config = { - action: request.agent.Action.DOWNLOAD, - url: downloadList[i][1], - method: 'POST', - title: 'download', - mode: request.agent.Mode.BACKGROUND, - network: request.agent.Network.ANY, - saveas: `./${downloadList[i][0]}/${splitUrl[splitUrl.length-1]}`, - overwrite: true, - gauge: true - } - let downTask = await request.agent.create(this.context, downloadConfig); - if (this.backgroundDownloadTaskList.findIndex(task => task.config.url === downTask.config.url) === -1) { - this.backgroundDownloadTaskList.push(downTask); - } - await downTask.start(); - } catch (err) { - logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); - this.waitList.push(downloadList[i]); - } - } - } - - async downloadFile(folder: string, url: string, callback: (progress: number, isSuccess: boolean) => void) { - logger.info(TAG, `downloadFile folder:${folder} url:${url}`); - // 查询到存在正在执行的下载任务,提示并返回 - let tasks = await request.agent.search({ - state: request.agent.State.RUNNING, - action: request.agent.Action.DOWNLOAD, - mode: request.agent.Mode.FOREGROUND - }); - if (tasks.length > 0) { - promptAction.showToast({ message: $r('app.string.have_download_task_tips'), bottom: TOAST_BOTTOM }); - return; - } - let splitUrl = url.split('//')[1].split('/'); - let saveas = `${folder}/${splitUrl[splitUrl.length-1]}` - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - let downloadConfig: request.agent.Config = { - action: request.agent.Action.DOWNLOAD, - url: url, - method: 'GET', - title: 'download', - mode: request.agent.Mode.FOREGROUND, - network: request.agent.Network.ANY, - saveas: saveas, - overwrite: true - } - logger.info(TAG, `downloadFile, downloadConfig = ${JSON.stringify(downloadConfig)}`); - try { - this.downloadTask = await request.agent.create(context, downloadConfig); - this.downloadTask.on('progress', (progress: request.agent.Progress) => { - logger.info(TAG, `progress, progress = ${progress.processed} ${progress.state}`); - let processed = Number(progress.processed.toString()).valueOf(); - let size = progress.sizes[0]; - let process: number = Math.floor(processed / size * 100); - if (process < 100) { - callback(process, false); - } - }) - this.downloadTask.on('completed', (progress: request.agent.Progress) => { - logger.info(TAG, `download complete, file= ${url}, progress = ${progress.processed}`); - callback(100, true); - this.deleteTask(); - }) - this.downloadTask.on('failed', async (progress: request.agent.Progress) => { - if (this.downloadTask) { - let taskInfo = await request.agent.show(this.downloadTask.tid); - logger.error(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`); - promptAction.showToast({ message: `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`, bottom: TOAST_BOTTOM }); - } - callback(100, false); - this.deleteTask(); - }) - await this.downloadTask.start(); - } catch (err) { - logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); - promptAction.showToast({ message: JSON.stringify(err), bottom: TOAST_BOTTOM }); - callback(100, false); - } - } - - async pauseOrResume() { - let state = AppStorage.get('backDownTaskState'); - if (state === BackgroundTaskState.RUNNING) { - await this.pause(); - AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.PAUSE); - } else if (state === BackgroundTaskState.PAUSE) { - await this.resume(); - AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.RUNNING); - } else { - logger.info(TAG, 'this task state is error'); - } - } - - async pause() { - logger.info(TAG, 'pause'); - if (this.backgroundDownloadTaskList.length === 0) { - return; - } - try { - this.backgroundDownloadTaskList.forEach(async task => { - await task.pause(); - }) - } catch (err) { - logger.info(TAG, `pause fail,err= ${JSON.stringify(err)}`); - } - } - - async resume() { - logger.info(TAG, 'resume'); - if (this.backgroundDownloadTaskList.length === 0) { - return; - } - try { - this.backgroundDownloadTaskList.forEach(async task => { - await task.resume(); - }) - } catch (err) { - logger.info(TAG, `resume fail,err= ${JSON.stringify(err)}`); - } - } - - async deleteTask() { - if (this.downloadTask) { - try { - this.downloadTask.off('progress'); - this.downloadTask.off('completed'); - this.downloadTask.off('failed'); - await request.agent.remove(this.downloadTask.tid); - } catch (err) { - logger.info(TAG, `deleteTask fail, err= ${JSON.stringify(err)}`); - } - } - this.downloadTask = undefined; - } - - async deleteAllBackTasks() { - if (this.backgroundDownloadTaskList.length > 0) { - try { - this.backgroundDownloadTaskList.forEach(async task => { - await request.agent.remove(task.tid); - }) - this.backgroundDownloadTaskList = []; - AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.NONE); - } catch (err) { - logger.info(TAG, `deleteAllTask fail, err= ${JSON.stringify(err)}`); - } - } - } -} - +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import request from '@ohos.request'; +import promptAction from '@ohos.promptAction'; +import { logger } from '../utils/Logger'; +import { BackgroundTaskState, TASK_MAX, TOAST_BOTTOM } from '../utils/Constants'; + +const TAG: string = 'RequestDownload'; + +class RequestDownload { + private context: common.UIAbilityContext | undefined = undefined; + private waitList: Array = []; + private downloadTask: request.agent.Task | undefined = undefined; + private backgroundDownloadTaskList: Array = []; + + constructor() { + setInterval(() => { + this.flushBackgroundTask() + }, 2000); + } + + async downloadFilesBackground(folder: string, files: Array) { + logger.info(TAG, 'downloadFiles'); + this.context = getContext(this) as common.UIAbilityContext; + files.forEach((item: string) => { + this.waitList.push([folder, item]); + }); + } + + async flushBackgroundTask() { + let tasks = await request.agent.search({ + state: request.agent.State.RUNNING + }); + if (tasks.length < TASK_MAX && this.waitList.length > 0) { + let downloadList: Array = []; + if (this.waitList.length <= TASK_MAX - tasks.length) { + downloadList = this.waitList; + this.waitList = []; + } else { + downloadList = this.waitList.slice(0, TASK_MAX - tasks.length); + this.waitList = this.waitList.slice(TASK_MAX - tasks.length, this.waitList.length); + } + logger.info(TAG, `this.waitList = ${JSON.stringify(this.waitList)}`); + this.createBackgroundTask(downloadList); + } else { + let state = AppStorage.get('backDownTaskState'); + logger.info(TAG, `backLists = ${this.backgroundDownloadTaskList.map(i => i.tid)}`); + if (state === BackgroundTaskState.RUNNING) { + if (tasks.length === 0) { + AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.NONE); + this.backgroundDownloadTaskList = []; + } + } + } + } + + async createBackgroundTask(downloadList: Array) { + if (this.context === undefined) { + return; + } + for (let i = 0; i < downloadList.length; i++) { + try { + let splitUrl = downloadList[i][1].split('//')[1].split('/'); + let downloadConfig: request.agent.Config = { + action: request.agent.Action.DOWNLOAD, + url: downloadList[i][1], + method: 'POST', + title: 'download', + mode: request.agent.Mode.BACKGROUND, + network: request.agent.Network.ANY, + saveas: `./${downloadList[i][0]}/${splitUrl[splitUrl.length-1]}`, + overwrite: true, + gauge: true + } + let downTask = await request.agent.create(this.context, downloadConfig); + if (this.backgroundDownloadTaskList.findIndex(task => task.config.url === downTask.config.url) === -1) { + this.backgroundDownloadTaskList.push(downTask); + } + await downTask.start(); + } catch (err) { + logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); + this.waitList.push(downloadList[i]); + } + } + } + + async downloadFile(folder: string, url: string, callback: (progress: number, isSuccess: boolean) => void) { + logger.info(TAG, `downloadFile folder:${folder} url:${url}`); + // 查询到存在正在执行的下载任务,提示并返回 + let tasks = await request.agent.search({ + state: request.agent.State.RUNNING, + action: request.agent.Action.DOWNLOAD, + mode: request.agent.Mode.FOREGROUND + }); + if (tasks.length > 0) { + promptAction.showToast({ message: $r('app.string.have_download_task_tips'), bottom: TOAST_BOTTOM }); + return; + } + let splitUrl = url.split('//')[1].split('/'); + let saveas = `${folder}/${splitUrl[splitUrl.length-1]}` + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + let downloadConfig: request.agent.Config = { + action: request.agent.Action.DOWNLOAD, + url: url, + method: 'GET', + title: 'download', + mode: request.agent.Mode.FOREGROUND, + network: request.agent.Network.ANY, + saveas: saveas, + overwrite: true + } + logger.info(TAG, `downloadFile, downloadConfig = ${JSON.stringify(downloadConfig)}`); + try { + this.downloadTask = await request.agent.create(context, downloadConfig); + this.downloadTask.on('progress', (progress: request.agent.Progress) => { + logger.info(TAG, `progress, progress = ${progress.processed} ${progress.state}`); + let processed = Number(progress.processed.toString()).valueOf(); + let size = progress.sizes[0]; + let process: number = Math.floor(processed / size * 100); + if (process < 100) { + callback(process, false); + } + }) + this.downloadTask.on('completed', (progress: request.agent.Progress) => { + logger.info(TAG, `download complete, file= ${url}, progress = ${progress.processed}`); + callback(100, true); + this.deleteTask(); + }) + this.downloadTask.on('failed', async (progress: request.agent.Progress) => { + if (this.downloadTask) { + let taskInfo = await request.agent.show(this.downloadTask.tid); + logger.error(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`); + promptAction.showToast({ message: `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`, bottom: TOAST_BOTTOM }); + } + callback(100, false); + this.deleteTask(); + }) + await this.downloadTask.start(); + } catch (err) { + logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); + promptAction.showToast({ message: JSON.stringify(err), bottom: TOAST_BOTTOM }); + callback(100, false); + } + } + + async pauseOrResume() { + let state = AppStorage.get('backDownTaskState'); + if (state === BackgroundTaskState.RUNNING) { + await this.pause(); + AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.PAUSE); + } else if (state === BackgroundTaskState.PAUSE) { + await this.resume(); + AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.RUNNING); + } else { + logger.info(TAG, 'this task state is error'); + } + } + + async pause() { + logger.info(TAG, 'pause'); + if (this.backgroundDownloadTaskList.length === 0) { + return; + } + try { + this.backgroundDownloadTaskList.forEach(async task => { + await task.pause(); + }) + } catch (err) { + logger.info(TAG, `pause fail,err= ${JSON.stringify(err)}`); + } + } + + async resume() { + logger.info(TAG, 'resume'); + if (this.backgroundDownloadTaskList.length === 0) { + return; + } + try { + this.backgroundDownloadTaskList.forEach(async task => { + await task.resume(); + }) + } catch (err) { + logger.info(TAG, `resume fail,err= ${JSON.stringify(err)}`); + } + } + + async deleteTask() { + if (this.downloadTask) { + try { + this.downloadTask.off('progress'); + this.downloadTask.off('completed'); + this.downloadTask.off('failed'); + await request.agent.remove(this.downloadTask.tid); + } catch (err) { + logger.info(TAG, `deleteTask fail, err= ${JSON.stringify(err)}`); + } + } + this.downloadTask = undefined; + } + + async deleteAllBackTasks() { + if (this.backgroundDownloadTaskList.length > 0) { + try { + this.backgroundDownloadTaskList.forEach(async task => { + await request.agent.remove(task.tid); + }) + this.backgroundDownloadTaskList = []; + AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.NONE); + } catch (err) { + logger.info(TAG, `deleteAllTask fail, err= ${JSON.stringify(err)}`); + } + } + } +} + export const requestDownload = new RequestDownload(); \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/upload/RequestUpload.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/upload/RequestUpload.ets index 4f97c70418..9c5201fe4b 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/upload/RequestUpload.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/upload/RequestUpload.ets @@ -1,307 +1,307 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import request from '@ohos.request'; -import promptAction from '@ohos.promptAction'; -import { urlUtils } from '../utils/UrlUtils'; -import { logger } from '../utils/Logger'; -import { MediaUtils } from '../utils/MediaUtils'; -import { BackgroundTaskState, UPLOAD_TOKEN, TOAST_BOTTOM, TASK_MAX } from '../utils/Constants'; - -const TAG: string = 'RequestUpload'; -const HEADER: Record = { 'Content-Type': 'multipart/form-data' }; - -class Upload { - private mediaUtils: MediaUtils = new MediaUtils(); - private config: request.agent.Config = { - action: request.agent.Action.UPLOAD, - headers: HEADER, - url: '', - mode: request.agent.Mode.FOREGROUND, - method: 'POST', - title: 'upload', - network: request.agent.Network.ANY, - data: [], - token: UPLOAD_TOKEN - } - private context: common.UIAbilityContext | undefined = undefined; - private uploadTask: request.agent.Task | undefined = undefined; - private backgroundTask: request.agent.Task | undefined = undefined; - private waitList: Array = []; - - constructor() { - setInterval(() => { - this.flushBackgroundTask() - }, 2000); - } - - getFileName(filePath: string): string { - const lastSlashIndex = filePath.lastIndexOf('/'); - if (lastSlashIndex === -1) { - return filePath; - } - return filePath.substring(lastSlashIndex + 1); - } - - async uploadFilesBackground(fileUris: Array): Promise { - logger.info(TAG, `uploadFilesBackground:uploadFiles begin, ${JSON.stringify(fileUris)}`); - this.context = getContext(this) as common.UIAbilityContext; - if (fileUris.length === 0) { - return; - } - fileUris.forEach((item: string) => { - this.waitList.push(item); - }); - } - - async flushBackgroundTask() { - logger.info(TAG, 'flushBackgroundTask:uploadFiles begin'); - let tasks = await request.agent.search({ - state: request.agent.State.RUNNING - }); - let state = AppStorage.get('backTaskState'); - if (state === BackgroundTaskState.RUNNING) { - if (tasks.length < TASK_MAX && this.waitList.length > 0) { - this.createBackgroundTask(this.waitList); - this.waitList = []; - } else { - if (this.backgroundTask === undefined || tasks.indexOf(this.backgroundTask.tid) === -1) { - AppStorage.setOrCreate('backTaskState', BackgroundTaskState.NONE); - this.backgroundTask = undefined; - } - } - } - } - - async createBackgroundTask(fileUris: Array) { - logger.info(TAG, `createBackgroundTask:uploadFiles begin, ${JSON.stringify(fileUris)}`); - if (this.context === undefined) { - return; - } - this.config.url = await urlUtils.getUrl(this.context); - this.config.data = await this.getFilesAndData(this.context.cacheDir, fileUris); - this.config.mode = request.agent.Mode.BACKGROUND; - try { - this.backgroundTask = await request.agent.create(this.context, this.config); - await this.backgroundTask.start(); - let state = AppStorage.get('backTaskState'); - if (state === BackgroundTaskState.PAUSE) { - await this.backgroundTask.pause(); - } - logger.info(TAG, `createBackgroundTask success`); - } catch (err) { - logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); - } - } - - async uploadFiles(fileUris: Array, callback: (progress: number, isSucceed: boolean) => void): Promise { - logger.info(TAG, `uploadFiles begin, ${JSON.stringify(fileUris)}`); - if (fileUris.length === 0) { - return; - } - // 查询到存在正在执行的上传任务,提示并返回 - let tasks = await request.agent.search({ - state: request.agent.State.RUNNING, - action: request.agent.Action.UPLOAD, - mode: request.agent.Mode.FOREGROUND - }); - if (tasks.length > 0) { - promptAction.showToast({ message: $r('app.string.have_upload_task_tips'), bottom: TOAST_BOTTOM }); - return; - } - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - this.config.data = await this.getFilesAndData(context.cacheDir, fileUris); - logger.info(TAG, `config data:${JSON.stringify(this.config.data)}`); - this.config.url = await urlUtils.getUrl(context); - logger.info(TAG, `config url:${JSON.stringify(this.config.url)}`); - this.config.mode = request.agent.Mode.FOREGROUND; - try { - this.uploadTask = await request.agent.create(context, this.config); - this.uploadTask.on('progress', (progress: request.agent.Progress) => { - logger.info(TAG, `progress, progress = ${progress.processed} ${progress.state}`); - let processed = Number(progress.processed.toString()).valueOf(); - let size = progress.sizes[0]; - let process: number = Math.floor(processed / size * 100); - if (process < 100) { - callback(process, false); - } - }); - this.uploadTask.on('completed', (progress: request.agent.Progress) => { - logger.info(TAG, `complete, progress = ${progress.processed} ${progress.state}`); - callback(100, true); - this.cancelTask(); - }); - this.uploadTask.on('failed', async (progress: request.agent.Progress) => { - if (this.uploadTask) { - let taskInfo = await request.agent.touch(this.uploadTask.tid, UPLOAD_TOKEN); - logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`); - } - callback(100, false); - this.cancelTask(); - }); - await this.uploadTask.start(); - } catch (err) { - logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); - callback(100, false); - } - } - - async uploadFileChunk(fileUris: Array, begin: number, end: number, callback: (progress: number, isSucceed: boolean) => void): Promise { - logger.info(TAG, `uploadFileChunk begin,${fileUris}, begin:${begin}, end:${end}`); - // 查询到存在正在执行的上传任务,提示并返回 - let tasks = await request.agent.search({ - state: request.agent.State.RUNNING, - action: request.agent.Action.UPLOAD, - mode: request.agent.Mode.FOREGROUND - }); - if (tasks.length > 0) { - promptAction.showToast({ message: $r('app.string.have_upload_task_tips'), bottom: TOAST_BOTTOM }); - return; - } - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - let config: request.agent.Config = { - action: request.agent.Action.UPLOAD, - headers: HEADER, - url: await urlUtils.getUrl(context), - mode: request.agent.Mode.FOREGROUND, - method: 'POST', - title: 'upload', - network: request.agent.Network.ANY, - data: await this.getFilesAndData(context.cacheDir, fileUris), - token: UPLOAD_TOKEN, - index: 0, // 指定片段上传的文件 - begins: begin, - ends: end - }; - - try { - this.uploadTask = await request.agent.create(context, config); - this.uploadTask.on('progress', (progress: request.agent.Progress) => { - let processed = Number(progress.processed.toString()).valueOf(); - let size = progress.sizes[progress.index]; - if (progress.index === 0) { - if (end === -1) { - size -= begin; - } else { - size = end - begin + 1; - } - } - logger.info(TAG, `progress, index:${progress.index}, progressed = ${progress.processed}, size=${size}`); - let process: number = Math.floor(processed / size * 100); - if (process < 100) { - callback(process, false); - } - }); - this.uploadTask.on('completed', (progress: request.agent.Progress) => { - logger.info(TAG, `complete, progress = ${progress.processed} ${progress.state}`); - callback(100, true); - this.cancelTask(); - }); - this.uploadTask.on('failed', async (progress: request.agent.Progress) => { - if (this.uploadTask) { - let taskInfo = await request.agent.touch(this.uploadTask.tid, UPLOAD_TOKEN); - logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`); - } - callback(100, false); - this.cancelTask(); - }) - await this.uploadTask.start(); - } catch (err) { - logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); - callback(100, false); - } - } - - async cancelTask() { - logger.info(TAG, 'cancelTask'); - if (this.uploadTask === undefined) { - return; - } - try { - this.uploadTask.off('progress'); - this.uploadTask.off('failed'); - this.uploadTask.off('completed'); - await this.uploadTask.stop(); - await request.agent.remove(this.uploadTask.tid); - } catch (err) { - logger.info(TAG, `deleteTask fail,err= ${JSON.stringify(err)}`); - } - this.uploadTask = undefined; - } - - async pauseOrResume() { - logger.info(TAG, 'pauseOrResume'); - let state = AppStorage.get('backTaskState'); - if (state === BackgroundTaskState.RUNNING) { - await this.pause(); - AppStorage.setOrCreate('backTaskState', BackgroundTaskState.PAUSE); - } else if (state === BackgroundTaskState.PAUSE) { - await this.resume(); - AppStorage.setOrCreate('backTaskState', BackgroundTaskState.RUNNING); - } else { - logger.info(TAG, 'this task state is error'); - } - } - - async pause() { - logger.info(TAG, 'pause'); - if (this.backgroundTask === undefined) { - return; - } - try { - await this.backgroundTask.pause(); - } catch (err) { - logger.info(TAG, `pause fail,err= ${JSON.stringify(err)}`); - } - } - - async resume() { - logger.info(TAG, 'resume'); - if (this.backgroundTask === undefined) { - return; - } - try { - await this.backgroundTask.resume(); - } catch (err) { - logger.info(TAG, `resume fail,err= ${JSON.stringify(err)}`); - } - } - - private async getFilesAndData(cacheDir: string, fileUris: Array): Promise> { - logger.info(TAG, `getFilesAndData begin`); - let files: Array = []; - for (let i = 0; i < fileUris.length; i++) { - logger.info(TAG, `getFile fileUri = ${fileUris[i]}`); - let imagePath = fileUris[i]; - logger.info(TAG, `getFilesAndData imagePath: ${JSON.stringify(imagePath)}`); - let fileName = this.getFileName(imagePath); - let file: request.agent.FormItem = { - name: 'createTest', - value: { - filename: fileName, - mimeType: 'application/octet-stream', - path: imagePath, - } - } - logger.info(TAG, `getFile file = ${JSON.stringify(file)}`); - files.push(file); - } - logger.info(TAG, `getFilesAndData ${JSON.stringify(files)}`); - return files; - } -} - +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import request from '@ohos.request'; +import promptAction from '@ohos.promptAction'; +import { urlUtils } from '../utils/UrlUtils'; +import { logger } from '../utils/Logger'; +import { MediaUtils } from '../utils/MediaUtils'; +import { BackgroundTaskState, UPLOAD_TOKEN, TOAST_BOTTOM, TASK_MAX } from '../utils/Constants'; + +const TAG: string = 'RequestUpload'; +const HEADER: Record = { 'Content-Type': 'multipart/form-data' }; + +class Upload { + private mediaUtils: MediaUtils = new MediaUtils(); + private config: request.agent.Config = { + action: request.agent.Action.UPLOAD, + headers: HEADER, + url: '', + mode: request.agent.Mode.FOREGROUND, + method: 'POST', + title: 'upload', + network: request.agent.Network.ANY, + data: [], + token: UPLOAD_TOKEN + } + private context: common.UIAbilityContext | undefined = undefined; + private uploadTask: request.agent.Task | undefined = undefined; + private backgroundTask: request.agent.Task | undefined = undefined; + private waitList: Array = []; + + constructor() { + setInterval(() => { + this.flushBackgroundTask() + }, 2000); + } + + getFileName(filePath: string): string { + const lastSlashIndex = filePath.lastIndexOf('/'); + if (lastSlashIndex === -1) { + return filePath; + } + return filePath.substring(lastSlashIndex + 1); + } + + async uploadFilesBackground(fileUris: Array): Promise { + logger.info(TAG, `uploadFilesBackground:uploadFiles begin, ${JSON.stringify(fileUris)}`); + this.context = getContext(this) as common.UIAbilityContext; + if (fileUris.length === 0) { + return; + } + fileUris.forEach((item: string) => { + this.waitList.push(item); + }); + } + + async flushBackgroundTask() { + logger.info(TAG, 'flushBackgroundTask:uploadFiles begin'); + let tasks = await request.agent.search({ + state: request.agent.State.RUNNING + }); + let state = AppStorage.get('backTaskState'); + if (state === BackgroundTaskState.RUNNING) { + if (tasks.length < TASK_MAX && this.waitList.length > 0) { + this.createBackgroundTask(this.waitList); + this.waitList = []; + } else { + if (this.backgroundTask === undefined || tasks.indexOf(this.backgroundTask.tid) === -1) { + AppStorage.setOrCreate('backTaskState', BackgroundTaskState.NONE); + this.backgroundTask = undefined; + } + } + } + } + + async createBackgroundTask(fileUris: Array) { + logger.info(TAG, `createBackgroundTask:uploadFiles begin, ${JSON.stringify(fileUris)}`); + if (this.context === undefined) { + return; + } + this.config.url = await urlUtils.getUrl(this.context); + this.config.data = await this.getFilesAndData(this.context.cacheDir, fileUris); + this.config.mode = request.agent.Mode.BACKGROUND; + try { + this.backgroundTask = await request.agent.create(this.context, this.config); + await this.backgroundTask.start(); + let state = AppStorage.get('backTaskState'); + if (state === BackgroundTaskState.PAUSE) { + await this.backgroundTask.pause(); + } + logger.info(TAG, `createBackgroundTask success`); + } catch (err) { + logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); + } + } + + async uploadFiles(fileUris: Array, callback: (progress: number, isSucceed: boolean) => void): Promise { + logger.info(TAG, `uploadFiles begin, ${JSON.stringify(fileUris)}`); + if (fileUris.length === 0) { + return; + } + // 查询到存在正在执行的上传任务,提示并返回 + let tasks = await request.agent.search({ + state: request.agent.State.RUNNING, + action: request.agent.Action.UPLOAD, + mode: request.agent.Mode.FOREGROUND + }); + if (tasks.length > 0) { + promptAction.showToast({ message: $r('app.string.have_upload_task_tips'), bottom: TOAST_BOTTOM }); + return; + } + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + this.config.data = await this.getFilesAndData(context.cacheDir, fileUris); + logger.info(TAG, `config data:${JSON.stringify(this.config.data)}`); + this.config.url = await urlUtils.getUrl(context); + logger.info(TAG, `config url:${JSON.stringify(this.config.url)}`); + this.config.mode = request.agent.Mode.FOREGROUND; + try { + this.uploadTask = await request.agent.create(context, this.config); + this.uploadTask.on('progress', (progress: request.agent.Progress) => { + logger.info(TAG, `progress, progress = ${progress.processed} ${progress.state}`); + let processed = Number(progress.processed.toString()).valueOf(); + let size = progress.sizes[0]; + let process: number = Math.floor(processed / size * 100); + if (process < 100) { + callback(process, false); + } + }); + this.uploadTask.on('completed', (progress: request.agent.Progress) => { + logger.info(TAG, `complete, progress = ${progress.processed} ${progress.state}`); + callback(100, true); + this.cancelTask(); + }); + this.uploadTask.on('failed', async (progress: request.agent.Progress) => { + if (this.uploadTask) { + let taskInfo = await request.agent.touch(this.uploadTask.tid, UPLOAD_TOKEN); + logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`); + } + callback(100, false); + this.cancelTask(); + }); + await this.uploadTask.start(); + } catch (err) { + logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); + callback(100, false); + } + } + + async uploadFileChunk(fileUris: Array, begin: number, end: number, callback: (progress: number, isSucceed: boolean) => void): Promise { + logger.info(TAG, `uploadFileChunk begin,${fileUris}, begin:${begin}, end:${end}`); + // 查询到存在正在执行的上传任务,提示并返回 + let tasks = await request.agent.search({ + state: request.agent.State.RUNNING, + action: request.agent.Action.UPLOAD, + mode: request.agent.Mode.FOREGROUND + }); + if (tasks.length > 0) { + promptAction.showToast({ message: $r('app.string.have_upload_task_tips'), bottom: TOAST_BOTTOM }); + return; + } + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + let config: request.agent.Config = { + action: request.agent.Action.UPLOAD, + headers: HEADER, + url: await urlUtils.getUrl(context), + mode: request.agent.Mode.FOREGROUND, + method: 'POST', + title: 'upload', + network: request.agent.Network.ANY, + data: await this.getFilesAndData(context.cacheDir, fileUris), + token: UPLOAD_TOKEN, + index: 0, // 指定片段上传的文件 + begins: begin, + ends: end + }; + + try { + this.uploadTask = await request.agent.create(context, config); + this.uploadTask.on('progress', (progress: request.agent.Progress) => { + let processed = Number(progress.processed.toString()).valueOf(); + let size = progress.sizes[progress.index]; + if (progress.index === 0) { + if (end === -1) { + size -= begin; + } else { + size = end - begin + 1; + } + } + logger.info(TAG, `progress, index:${progress.index}, progressed = ${progress.processed}, size=${size}`); + let process: number = Math.floor(processed / size * 100); + if (process < 100) { + callback(process, false); + } + }); + this.uploadTask.on('completed', (progress: request.agent.Progress) => { + logger.info(TAG, `complete, progress = ${progress.processed} ${progress.state}`); + callback(100, true); + this.cancelTask(); + }); + this.uploadTask.on('failed', async (progress: request.agent.Progress) => { + if (this.uploadTask) { + let taskInfo = await request.agent.touch(this.uploadTask.tid, UPLOAD_TOKEN); + logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`); + } + callback(100, false); + this.cancelTask(); + }) + await this.uploadTask.start(); + } catch (err) { + logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); + callback(100, false); + } + } + + async cancelTask() { + logger.info(TAG, 'cancelTask'); + if (this.uploadTask === undefined) { + return; + } + try { + this.uploadTask.off('progress'); + this.uploadTask.off('failed'); + this.uploadTask.off('completed'); + await this.uploadTask.stop(); + await request.agent.remove(this.uploadTask.tid); + } catch (err) { + logger.info(TAG, `deleteTask fail,err= ${JSON.stringify(err)}`); + } + this.uploadTask = undefined; + } + + async pauseOrResume() { + logger.info(TAG, 'pauseOrResume'); + let state = AppStorage.get('backTaskState'); + if (state === BackgroundTaskState.RUNNING) { + await this.pause(); + AppStorage.setOrCreate('backTaskState', BackgroundTaskState.PAUSE); + } else if (state === BackgroundTaskState.PAUSE) { + await this.resume(); + AppStorage.setOrCreate('backTaskState', BackgroundTaskState.RUNNING); + } else { + logger.info(TAG, 'this task state is error'); + } + } + + async pause() { + logger.info(TAG, 'pause'); + if (this.backgroundTask === undefined) { + return; + } + try { + await this.backgroundTask.pause(); + } catch (err) { + logger.info(TAG, `pause fail,err= ${JSON.stringify(err)}`); + } + } + + async resume() { + logger.info(TAG, 'resume'); + if (this.backgroundTask === undefined) { + return; + } + try { + await this.backgroundTask.resume(); + } catch (err) { + logger.info(TAG, `resume fail,err= ${JSON.stringify(err)}`); + } + } + + private async getFilesAndData(cacheDir: string, fileUris: Array): Promise> { + logger.info(TAG, `getFilesAndData begin`); + let files: Array = []; + for (let i = 0; i < fileUris.length; i++) { + logger.info(TAG, `getFile fileUri = ${fileUris[i]}`); + let imagePath = fileUris[i]; + logger.info(TAG, `getFilesAndData imagePath: ${JSON.stringify(imagePath)}`); + let fileName = this.getFileName(imagePath); + let file: request.agent.FormItem = { + name: 'createTest', + value: { + filename: fileName, + mimeType: 'application/octet-stream', + path: imagePath, + } + } + logger.info(TAG, `getFile file = ${JSON.stringify(file)}`); + files.push(file); + } + logger.info(TAG, `getFilesAndData ${JSON.stringify(files)}`); + return files; + } +} + export const requestUpload = new Upload(); \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/Constants.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/Constants.ets index 67a4a64cff..8bb5482b04 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/Constants.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/Constants.ets @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2023 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 TOAST_BOTTOM: number = 200; -export const UPLOAD_TOKEN: string = 'upload_token'; -export const TASK_MAX: number = 10; -export enum BackgroundTaskState { - NONE = 0, - RUNNING = 1, - PAUSE = 2 -} +/* + * Copyright (c) 2023 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 TOAST_BOTTOM: number = 200; +export const UPLOAD_TOKEN: string = 'upload_token'; +export const TASK_MAX: number = 10; +export enum BackgroundTaskState { + NONE = 0, + RUNNING = 1, + PAUSE = 2 +} export const NO_IMAGE_SELECTED: number = -1; \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/UrlUtils.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/UrlUtils.ets index 8262e18cae..a06833d2f7 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/UrlUtils.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/UrlUtils.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import commonEventManager from '@ohos.commonEventManager'; -import preferences from '@ohos.data.preferences'; -import { CommonEventData } from './commonEvent/commonEventData'; -import { CommonEventSubscriber } from './commonEvent/commonEventSubscriber'; -import { logger } from './Logger'; - -const TAG: string = 'UrlUtils'; -const URL_KEY: string = 'url'; -const STORE_NAME: string = 'server_url'; -const DEFAULT_SERVER_URL: string = 'http://192.168.1.1/'; - -class UrlUtil { - async getUrl(context: common.UIAbilityContext): Promise { - let preference = await preferences.getPreferences(context, STORE_NAME); - let url = await preference.get(URL_KEY, '') as string; - if (url == '') { - url = DEFAULT_SERVER_URL; - logger.info(TAG, 'config url is null'); - } - logger.info(TAG, `getUrl,url= ${url}`); - return url; - } - - async saveUrl(context: common.UIAbilityContext, url: string) { - let preference = await preferences.getPreferences(context, STORE_NAME); - await preference.put(URL_KEY, url); - await preference.flush(); - } -} - -export const urlUtils = new UrlUtil(); +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import commonEventManager from '@ohos.commonEventManager'; +import preferences from '@ohos.data.preferences'; +import { CommonEventData } from './commonEvent/commonEventData'; +import { CommonEventSubscriber } from './commonEvent/commonEventSubscriber'; +import { logger } from './Logger'; + +const TAG: string = 'UrlUtils'; +const URL_KEY: string = 'url'; +const STORE_NAME: string = 'server_url'; +const DEFAULT_SERVER_URL: string = 'http://192.168.1.1/'; + +class UrlUtil { + async getUrl(context: common.UIAbilityContext): Promise { + let preference = await preferences.getPreferences(context, STORE_NAME); + let url = await preference.get(URL_KEY, '') as string; + if (url == '') { + url = DEFAULT_SERVER_URL; + logger.info(TAG, 'config url is null'); + } + logger.info(TAG, `getUrl,url= ${url}`); + return url; + } + + async saveUrl(context: common.UIAbilityContext, url: string) { + let preference = await preferences.getPreferences(context, STORE_NAME); + await preference.put(URL_KEY, url); + await preference.flush(); + } +} + +export const urlUtils = new UrlUtil(); diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-config.json5 b/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-config.json5 deleted file mode 100644 index 64655e6970..0000000000 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,6 +0,0 @@ -{ - "hvigorVersion": "3.2.4", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.2.4" - } -} \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-wrapper.js b/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-wrapper.js deleted file mode 100644 index 372eae8eb4..0000000000 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-wrapper.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";var u=require("path"),D=require("os"),e=require("fs"),t=require("crypto"),r=require("child_process"),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={},C={},F=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(C,"__esModule",{value:!0}),C.maxPathLength=C.isMac=C.isLinux=C.isWindows=void 0;const E=F(D),A="Windows_NT",o="Darwin";function a(){return E.default.type()===A}function c(){return E.default.type()===o}C.isWindows=a,C.isLinux=function(){return"Linux"===E.default.type()},C.isMac=c,C.maxPathLength=function(){return c()?1016:a()?259:4095},function(e){var t=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),r=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),i=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&t(D,u,e);return r(D,u),D};Object.defineProperty(e,"__esModule",{value:!0}),e.WORK_SPACE=e.HVIGOR_PROJECT_WRAPPER_HOME=e.HVIGOR_PROJECT_ROOT_DIR=e.HVIGOR_PROJECT_CACHES_HOME=e.HVIGOR_PNPM_STORE_PATH=e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=e.PROJECT_CACHES=e.HVIGOR_WRAPPER_TOOLS_HOME=e.HVIGOR_USER_HOME=e.DEFAULT_PACKAGE_JSON=e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME=e.PNPM=e.HVIGOR=e.NPM_TOOL=e.PNPM_TOOL=e.HVIGOR_ENGINE_PACKAGE_NAME=void 0;const F=i(D),E=i(u),A=C;e.HVIGOR_ENGINE_PACKAGE_NAME="@ohos/hvigor",e.PNPM_TOOL=(0,A.isWindows)()?"pnpm.cmd":"pnpm",e.NPM_TOOL=(0,A.isWindows)()?"npm.cmd":"npm",e.HVIGOR="hvigor",e.PNPM="pnpm",e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME="hvigor-config.json5",e.DEFAULT_PACKAGE_JSON="package.json",e.HVIGOR_USER_HOME=E.resolve(F.homedir(),".hvigor"),e.HVIGOR_WRAPPER_TOOLS_HOME=E.resolve(e.HVIGOR_USER_HOME,"wrapper","tools"),e.PROJECT_CACHES="project_caches",e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=E.resolve(e.HVIGOR_WRAPPER_TOOLS_HOME,"node_modules",".bin",e.PNPM_TOOL),e.HVIGOR_PNPM_STORE_PATH=E.resolve(e.HVIGOR_USER_HOME,"caches"),e.HVIGOR_PROJECT_CACHES_HOME=E.resolve(e.HVIGOR_USER_HOME,e.PROJECT_CACHES),e.HVIGOR_PROJECT_ROOT_DIR=process.cwd(),e.HVIGOR_PROJECT_WRAPPER_HOME=E.resolve(e.HVIGOR_PROJECT_ROOT_DIR,e.HVIGOR),e.WORK_SPACE="workspace"}(i);var s={},l={};Object.defineProperty(l,"__esModule",{value:!0}),l.logInfoPrintConsole=l.logErrorAndExit=void 0,l.logErrorAndExit=function(u){u instanceof Error?console.error(u.message):console.error(u),process.exit(-1)},l.logInfoPrintConsole=function(u){console.log(u)};var B=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),d=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),f=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&B(D,u,e);return d(D,u),D};Object.defineProperty(s,"__esModule",{value:!0});var _=s.executeBuild=void 0;const p=f(e),O=f(u),h=l;_=s.executeBuild=function(u){const D=O.resolve(u,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const u=p.realpathSync(D);require(u)}catch(e){(0,h.logErrorAndExit)(`Error: ENOENT: no such file ${D},delete ${u} and retry.`)}};var P={},v={};!function(u){var D=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(u,"__esModule",{value:!0}),u.hashFile=u.hash=u.createHash=void 0;const r=D(t),i=D(e);u.createHash=(u="MD5")=>r.default.createHash(u);u.hash=(D,e)=>(0,u.createHash)(e).update(D).digest("hex");u.hashFile=(D,e)=>{if(i.default.existsSync(D))return(0,u.hash)(i.default.readFileSync(D,"utf-8"),e)}}(v);var g={},m={},R={};Object.defineProperty(R,"__esModule",{value:!0}),R.Unicode=void 0;class y{}R.Unicode=y,y.SPACE_SEPARATOR=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,y.ID_START=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,y.ID_CONTINUE=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Object.defineProperty(m,"__esModule",{value:!0}),m.JudgeUtil=void 0;const I=R;m.JudgeUtil=class{static isIgnoreChar(u){return"string"==typeof u&&("\t"===u||"\v"===u||"\f"===u||" "===u||" "===u||"\ufeff"===u||"\n"===u||"\r"===u||"\u2028"===u||"\u2029"===u)}static isSpaceSeparator(u){return"string"==typeof u&&I.Unicode.SPACE_SEPARATOR.test(u)}static isIdStartChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||"$"===u||"_"===u||I.Unicode.ID_START.test(u))}static isIdContinueChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||u>="0"&&u<="9"||"$"===u||"_"===u||"‌"===u||"‍"===u||I.Unicode.ID_CONTINUE.test(u))}static isDigitWithoutZero(u){return/[1-9]/.test(u)}static isDigit(u){return"string"==typeof u&&/[0-9]/.test(u)}static isHexDigit(u){return"string"==typeof u&&/[0-9A-Fa-f]/.test(u)}};var N=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(g,"__esModule",{value:!0}),g.parseJsonText=g.parseJsonFile=void 0;const b=N(e),S=N(D),w=N(u),H=m;var x;!function(u){u[u.Char=0]="Char",u[u.EOF=1]="EOF",u[u.Identifier=2]="Identifier"}(x||(x={}));let M,T,V,G,j,J,W="start",U=[],L=0,$=1,k=0,K=!1,z="default",q="'",Z=1;function X(u,D=!1){T=String(u),W="start",U=[],L=0,$=1,k=0,G=void 0,K=D;do{M=Q(),nu[W]()}while("eof"!==M.type);return G}function Q(){for(z="default",j="",q="'",Z=1;;){J=Y();const u=Du[z]();if(u)return u}}function Y(){if(T[L])return String.fromCodePoint(T.codePointAt(L))}function uu(){const u=Y();return"\n"===u?($++,k=0):u?k+=u.length:k++,u&&(L+=u.length),u}g.parseJsonFile=function(u,D=!1,e="utf-8"){const t=b.default.readFileSync(w.default.resolve(u),{encoding:e});try{return X(t,D)}catch(D){if(D instanceof SyntaxError){const e=D.message.split("at");if(2===e.length)throw new Error(`${e[0].trim()}${S.default.EOL}\t at ${u}:${e[1].trim()}`)}throw new Error(`${u} is not in valid JSON/JSON5 format.`)}},g.parseJsonText=X;const Du={default(){switch(J){case"/":return uu(),void(z="comment");case void 0:return uu(),eu("eof")}if(!H.JudgeUtil.isIgnoreChar(J)&&!H.JudgeUtil.isSpaceSeparator(J))return Du[W]();uu()},start(){z="value"},beforePropertyName(){switch(J){case"$":case"_":return j=uu(),void(z="identifierName");case"\\":return uu(),void(z="identifierNameStartEscape");case"}":return eu("punctuator",uu());case'"':case"'":return q=J,uu(),void(z="string")}if(H.JudgeUtil.isIdStartChar(J))return j+=uu(),void(z="identifierName");throw Eu(x.Char,uu())},afterPropertyName(){if(":"===J)return eu("punctuator",uu());throw Eu(x.Char,uu())},beforePropertyValue(){z="value"},afterPropertyValue(){switch(J){case",":case"}":return eu("punctuator",uu())}throw Eu(x.Char,uu())},beforeArrayValue(){if("]"===J)return eu("punctuator",uu());z="value"},afterArrayValue(){switch(J){case",":case"]":return eu("punctuator",uu())}throw Eu(x.Char,uu())},end(){throw Eu(x.Char,uu())},comment(){switch(J){case"*":return uu(),void(z="multiLineComment");case"/":return uu(),void(z="singleLineComment")}throw Eu(x.Char,uu())},multiLineComment(){switch(J){case"*":return uu(),void(z="multiLineCommentAsterisk");case void 0:throw Eu(x.Char,uu())}uu()},multiLineCommentAsterisk(){switch(J){case"*":return void uu();case"/":return uu(),void(z="default");case void 0:throw Eu(x.Char,uu())}uu(),z="multiLineComment"},singleLineComment(){switch(J){case"\n":case"\r":case"\u2028":case"\u2029":return uu(),void(z="default");case void 0:return uu(),eu("eof")}uu()},value(){switch(J){case"{":case"[":return eu("punctuator",uu());case"n":return uu(),tu("ull"),eu("null",null);case"t":return uu(),tu("rue"),eu("boolean",!0);case"f":return uu(),tu("alse"),eu("boolean",!1);case"-":case"+":return"-"===uu()&&(Z=-1),void(z="numerical");case".":case"0":case"I":case"N":return void(z="numerical");case'"':case"'":return q=J,uu(),j="",void(z="string")}if(void 0===J||!H.JudgeUtil.isDigitWithoutZero(J))throw Eu(x.Char,uu());z="numerical"},numerical(){switch(J){case".":return j=uu(),void(z="decimalPointLeading");case"0":return j=uu(),void(z="zero");case"I":return uu(),tu("nfinity"),eu("numeric",Z*(1/0));case"N":return uu(),tu("aN"),eu("numeric",NaN)}if(void 0!==J&&H.JudgeUtil.isDigitWithoutZero(J))return j=uu(),void(z="decimalInteger");throw Eu(x.Char,uu())},zero(){switch(J){case".":case"e":case"E":return void(z="decimal");case"x":case"X":return j+=uu(),void(z="hexadecimal")}return eu("numeric",0)},decimalInteger(){switch(J){case".":case"e":case"E":return void(z="decimal")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimal(){switch(J){case".":j+=uu(),z="decimalFraction";break;case"e":case"E":j+=uu(),z="decimalExponent"}},decimalPointLeading(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalFraction");throw Eu(x.Char,uu())},decimalFraction(){switch(J){case"e":case"E":return j+=uu(),void(z="decimalExponent")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimalExponent(){switch(J){case"+":case"-":return j+=uu(),void(z="decimalExponentSign")}if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Eu(x.Char,uu())},decimalExponentSign(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Eu(x.Char,uu())},decimalExponentInteger(){if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},hexadecimal(){if(H.JudgeUtil.isHexDigit(J))return j+=uu(),void(z="hexadecimalInteger");throw Eu(x.Char,uu())},hexadecimalInteger(){if(!H.JudgeUtil.isHexDigit(J))return eu("numeric",Z*Number(j));j+=uu()},identifierNameStartEscape(){if("u"!==J)throw Eu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":break;default:if(!H.JudgeUtil.isIdStartChar(u))throw Eu(x.Identifier)}j+=u,z="identifierName"},identifierName(){switch(J){case"$":case"_":case"‌":case"‍":return void(j+=uu());case"\\":return uu(),void(z="identifierNameEscape")}if(!H.JudgeUtil.isIdContinueChar(J))return eu("identifier",j);j+=uu()},identifierNameEscape(){if("u"!==J)throw Eu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":case"‌":case"‍":break;default:if(!H.JudgeUtil.isIdContinueChar(u))throw Eu(x.Identifier)}j+=u,z="identifierName"},string(){switch(J){case"\\":return uu(),void(j+=function(){const u=Y(),D=function(){switch(Y()){case"b":return uu(),"\b";case"f":return uu(),"\f";case"n":return uu(),"\n";case"r":return uu(),"\r";case"t":return uu(),"\t";case"v":return uu(),"\v"}return}();if(D)return D;switch(u){case"0":if(uu(),H.JudgeUtil.isDigit(Y()))throw Eu(x.Char,uu());return"\0";case"x":return uu(),function(){let u="",D=Y();if(!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());if(u+=uu(),D=Y(),!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());return u+=uu(),String.fromCodePoint(parseInt(u,16))}();case"u":return uu(),ru();case"\n":case"\u2028":case"\u2029":return uu(),"";case"\r":return uu(),"\n"===Y()&&uu(),""}if(void 0===u||H.JudgeUtil.isDigitWithoutZero(u))throw Eu(x.Char,uu());return uu()}());case'"':case"'":if(J===q){const u=eu("string",j);return uu(),u}return void(j+=uu());case"\n":case"\r":case void 0:throw Eu(x.Char,uu());case"\u2028":case"\u2029":!function(u){console.warn(`JSON5: '${Fu(u)}' in strings is not valid ECMAScript; consider escaping.`)}(J)}j+=uu()}};function eu(u,D){return{type:u,value:D,line:$,column:k}}function tu(u){for(const D of u){if(Y()!==D)throw Eu(x.Char,uu());uu()}}function ru(){let u="",D=4;for(;D-- >0;){const D=Y();if(!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());u+=uu()}return String.fromCodePoint(parseInt(u,16))}const nu={start(){if("eof"===M.type)throw Eu(x.EOF);iu()},beforePropertyName(){switch(M.type){case"identifier":case"string":return V=M.value,void(W="afterPropertyName");case"punctuator":return void Cu();case"eof":throw Eu(x.EOF)}},afterPropertyName(){if("eof"===M.type)throw Eu(x.EOF);W="beforePropertyValue"},beforePropertyValue(){if("eof"===M.type)throw Eu(x.EOF);iu()},afterPropertyValue(){if("eof"===M.type)throw Eu(x.EOF);switch(M.value){case",":return void(W="beforePropertyName");case"}":Cu()}},beforeArrayValue(){if("eof"===M.type)throw Eu(x.EOF);"punctuator"!==M.type||"]"!==M.value?iu():Cu()},afterArrayValue(){if("eof"===M.type)throw Eu(x.EOF);switch(M.value){case",":return void(W="beforeArrayValue");case"]":Cu()}},end(){}};function iu(){const u=function(){let u;switch(M.type){case"punctuator":switch(M.value){case"{":u={};break;case"[":u=[]}break;case"null":case"boolean":case"numeric":case"string":u=M.value}return u}();if(K&&"object"==typeof u&&(u._line=$,u._column=k),void 0===G)G=u;else{const D=U[U.length-1];Array.isArray(D)?K&&"object"!=typeof u?D.push({value:u,_line:$,_column:k}):D.push(u):D[V]=K&&"object"!=typeof u?{value:u,_line:$,_column:k}:u}!function(u){if(u&&"object"==typeof u)U.push(u),W=Array.isArray(u)?"beforeArrayValue":"beforePropertyName";else{const u=U[U.length-1];W=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}}(u)}function Cu(){U.pop();const u=U[U.length-1];W=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}function Fu(u){const D={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(D[u])return D[u];if(u<" "){const D=u.charCodeAt(0).toString(16);return`\\x${`00${D}`.substring(D.length)}`}return u}function Eu(u,D){let e="";switch(u){case x.Char:e=void 0===D?`JSON5: invalid end of input at ${$}:${k}`:`JSON5: invalid character '${Fu(D)}' at ${$}:${k}`;break;case x.EOF:e=`JSON5: invalid end of input at ${$}:${k}`;break;case x.Identifier:k-=5,e=`JSON5: invalid identifier character at ${$}:${k}`}const t=new Au(e);return t.lineNumber=$,t.columnNumber=k,t}class Au extends SyntaxError{}var ou={},au=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),cu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),su=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&au(D,u,e);return cu(D,u),D},lu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(ou,"__esModule",{value:!0}),ou.isFileExists=ou.offlinePluginConversion=ou.executeCommand=ou.getNpmPath=ou.hasNpmPackInPaths=void 0;const Bu=r,du=lu(e),fu=su(u),_u=i,pu=l;ou.hasNpmPackInPaths=function(u,D){try{return require.resolve(u,{paths:[...D]}),!0}catch(u){return!1}},ou.getNpmPath=function(){const u=process.execPath;return fu.join(fu.dirname(u),_u.NPM_TOOL)},ou.executeCommand=function(u,D,e){0!==(0,Bu.spawnSync)(u,D,e).status&&(0,pu.logErrorAndExit)(`Error: ${u} ${D} execute failed.See above for details.`)},ou.offlinePluginConversion=function(u,D){return D.startsWith("file:")||D.endsWith(".tgz")?fu.resolve(u,_u.HVIGOR,D.replace("file:","")):D},ou.isFileExists=function(u){return du.default.existsSync(u)&&du.default.statSync(u).isFile()};var Ou=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),hu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),Pu=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&Ou(D,u,e);return hu(D,u),D},vu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(P,"__esModule",{value:!0});var gu=P.initProjectWorkSpace=void 0;const mu=Pu(e),Ru=vu(D),yu=Pu(u),Iu=v,Nu=i,bu=g,Su=l,wu=ou;let Hu,xu,Mu;function Tu(u,D,e){return void 0!==e.dependencies&&(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,D.dependencies[u])===yu.normalize(e.dependencies[u])}function Vu(){const u=yu.join(Mu,Nu.WORK_SPACE);if((0,Su.logInfoPrintConsole)("Hvigor cleaning..."),!mu.existsSync(u))return;const D=mu.readdirSync(u);if(!D||0===D.length)return;const e=yu.resolve(Mu,"node_modules","@ohos","hvigor","bin","hvigor.js");mu.existsSync(e)&&(0,wu.executeCommand)(process.argv[0],[e,"--stop-daemon"],{});try{D.forEach((D=>{mu.rmSync(yu.resolve(u,D),{recursive:!0})}))}catch(D){(0,Su.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${u}.`)}}gu=P.initProjectWorkSpace=function(){if(Hu=function(){const u=yu.resolve(Nu.HVIGOR_PROJECT_WRAPPER_HOME,Nu.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);mu.existsSync(u)||(0,Su.logErrorAndExit)(`Error: Hvigor config file ${u} does not exist.`);return(0,bu.parseJsonFile)(u)}(),Mu=function(u){let D;D=function(u){let D=u.hvigorVersion;if(D.startsWith("file:")||D.endsWith(".tgz"))return!1;const e=u.dependencies,t=Object.getOwnPropertyNames(e);for(const u of t){const D=e[u];if(D.startsWith("file:")||D.endsWith(".tgz"))return!1}if(1===t.length&&"@ohos/hvigor-ohos-plugin"===t[0])return D>"2.5.0";return!1}(u)?function(u){let D=`${Nu.HVIGOR_ENGINE_PACKAGE_NAME}@${u.hvigorVersion}`;const e=u.dependencies;if(e){Object.getOwnPropertyNames(e).sort().forEach((u=>{D+=`,${u}@${e[u]}`}))}return(0,Iu.hash)(D)}(u):(0,Iu.hash)(process.cwd());return yu.resolve(Ru.default.homedir(),".hvigor","project_caches",D)}(Hu),xu=function(){const u=yu.resolve(Mu,Nu.WORK_SPACE,Nu.DEFAULT_PACKAGE_JSON);return mu.existsSync(u)?(0,bu.parseJsonFile)(u):{dependencies:{}}}(),!(0,wu.hasNpmPackInPaths)(Nu.HVIGOR_ENGINE_PACKAGE_NAME,[yu.join(Mu,Nu.WORK_SPACE)])||(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion)!==xu.dependencies[Nu.HVIGOR_ENGINE_PACKAGE_NAME]||!function(){function u(u){const D=null==u?void 0:u.dependencies;return void 0===D?0:Object.getOwnPropertyNames(D).length}const D=u(Hu),e=u(xu);if(D+1!==e)return!1;for(const u in null==Hu?void 0:Hu.dependencies)if(!(0,wu.hasNpmPackInPaths)(u,[yu.join(Mu,Nu.WORK_SPACE)])||!Tu(u,Hu,xu))return!1;return!0}()){Vu();try{!function(){(0,Su.logInfoPrintConsole)("Hvigor installing...");for(const u in Hu.dependencies)Hu.dependencies[u]&&(Hu.dependencies[u]=(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.dependencies[u]));const u={dependencies:{...Hu.dependencies}};u.dependencies[Nu.HVIGOR_ENGINE_PACKAGE_NAME]=(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion);const D=yu.join(Mu,Nu.WORK_SPACE);try{mu.mkdirSync(D,{recursive:!0});const e=yu.resolve(D,Nu.DEFAULT_PACKAGE_JSON);mu.writeFileSync(e,JSON.stringify(u))}catch(u){(0,Su.logErrorAndExit)(u)}(function(){const u=["config","set","store-dir",Nu.HVIGOR_PNPM_STORE_PATH],D={cwd:yu.join(Mu,Nu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(Nu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)})(),function(){const u=["install"],D={cwd:yu.join(Mu,Nu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(Nu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)}(),(0,Su.logInfoPrintConsole)("Hvigor install success.")}()}catch(u){Vu()}}return Mu};var Gu={};!function(t){var C=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),F=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),E=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&C(D,u,e);return F(D,u),D},A=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(t,"__esModule",{value:!0}),t.executeInstallPnpm=t.isPnpmInstalled=t.environmentHandler=t.checkNpmConifg=t.PNPM_VERSION=void 0;const o=r,a=E(e),c=A(D),s=E(u),B=i,d=l,f=ou;t.PNPM_VERSION="7.30.0",t.checkNpmConifg=function(){const u=s.resolve(B.HVIGOR_PROJECT_ROOT_DIR,".npmrc"),D=s.resolve(c.default.homedir(),".npmrc");if((0,f.isFileExists)(u)||(0,f.isFileExists)(D))return;const e=(0,f.getNpmPath)(),t=(0,o.spawnSync)(e,["config","get","prefix"],{cwd:B.HVIGOR_PROJECT_ROOT_DIR});if(0!==t.status||!t.stdout)return void(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.");const r=s.resolve(`${t.stdout}`.replace(/[\r\n]/gi,""),".npmrc");(0,f.isFileExists)(r)||(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.")},t.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},t.isPnpmInstalled=function(){return!!a.existsSync(B.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,f.hasNpmPackInPaths)("pnpm",[B.HVIGOR_WRAPPER_TOOLS_HOME])},t.executeInstallPnpm=function(){(0,d.logInfoPrintConsole)(`Installing pnpm@${t.PNPM_VERSION}...`);const u=(0,f.getNpmPath)();!function(){const u=s.resolve(B.HVIGOR_WRAPPER_TOOLS_HOME,B.DEFAULT_PACKAGE_JSON);try{a.existsSync(B.HVIGOR_WRAPPER_TOOLS_HOME)||a.mkdirSync(B.HVIGOR_WRAPPER_TOOLS_HOME,{recursive:!0});const D={dependencies:{}};D.dependencies[B.PNPM]=t.PNPM_VERSION,a.writeFileSync(u,JSON.stringify(D))}catch(D){(0,d.logErrorAndExit)(`Error: EPERM: operation not permitted,create ${u} failed.`)}}(),(0,f.executeCommand)(u,["install","pnpm"],{cwd:B.HVIGOR_WRAPPER_TOOLS_HOME,stdio:["inherit","inherit","inherit"],env:process.env}),(0,d.logInfoPrintConsole)("Pnpm install success.")}}(Gu),function(){Gu.checkNpmConifg(),Gu.environmentHandler(),Gu.isPnpmInstalled()||Gu.executeInstallPnpm();const D=gu();_(u.join(D,i.WORK_SPACE))}(); \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/AppScope/app.json5 b/code/BasicFeature/Connectivity/VPN/AppScope/app.json5 index 0b2f74849b..3cdcbddae4 100644 --- a/code/BasicFeature/Connectivity/VPN/AppScope/app.json5 +++ b/code/BasicFeature/Connectivity/VPN/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* -* Copyright (c) 2023 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.example.testvpnclient", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* +* Copyright (c) 2023 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.example.testvpnclient", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Connectivity/VPN/AppScope/resources/base/element/string.json b/code/BasicFeature/Connectivity/VPN/AppScope/resources/base/element/string.json index 095e4c59b5..5ee9d169b2 100644 --- a/code/BasicFeature/Connectivity/VPN/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Connectivity/VPN/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "testvpnclient" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "testvpnclient" + } + ] +} diff --git a/code/BasicFeature/Connectivity/VPN/README_zh.md b/code/BasicFeature/Connectivity/VPN/README_zh.md index a837fea404..c34babfd81 100644 --- a/code/BasicFeature/Connectivity/VPN/README_zh.md +++ b/code/BasicFeature/Connectivity/VPN/README_zh.md @@ -1,85 +1,85 @@ -# VPN连接 - -### 介绍 -本示例使用@ohos.net.vpn接口创建VPN 隧道,建立vpn网络,vpn隧道保护,销毁VPN网络以及使用@ohos.net.vpnExtension接口创建三方vpn等功能。 -实现了VPN的进行服务器连接,发送数据的功能 - -### 效果预览 -| 主页 | vpn启动 | vpn关闭 | -| ------------------------------ | --------------------------------- | --------------------------------------- | -| ![main.jpeg](sceenshots%2Fmain.jpeg) | ![start.jpeg](sceenshots%2Fstart.jpeg) | ![stop.jpeg](sceenshots%2Fstop.jpeg) | - - 使用说明 -1. 进入应用前请先安装[VPNFoundation](./lib/VPNFoundation-1.0.0.hap)。 -2. 进入应用后,主界面有启用VPN和停用VPN的选项。分别对应开启和关闭VPN功能。 -3. 在主界面,可以点击启用VPN来创建VPN连接。 -4. 在VPN启动界面,可以配置VPN服务器IP地址/隧道IP地址/使用VPN的应用程序。 -5. 在VPN启动界面,点击创建对象可以创建VPN隧道,点击隧道保护可以开启隧道保护,点击启动VPN可以进行网络连接。 -6. 在主界面,可以点击停用VPN来断开和关闭VPN连接。 - -7. 以上演示系统vpn,如果使用三方vpn,点击启动vpnExt按钮,弹窗提示vpn使用许可,同意后三方vpn启动并自动连接,尝试用浏览器等hap包访问百度 - -| 三方vpn弹窗 | -| ------------------------------ | -| ![vpnextension.jpeg](sceenshots%2Fvpnextension.jpeg)| - -8 .访问成功后返回主页面,点击关闭vpnExt按钮,断开三方vpn连接 - -### 工程目录 - -``` -entry/src/main/ets/ -|---entryability -| |---EntryAbility.ts // 项目入口,请求相关权限 -|---pages -| |---Index.ets // 首页 -| |---StartVpn.ets // 打开vpn -| |---StopVpn.ets // 关闭vpn -|---model -| |---Logger.ets // 日志 -|---serviceextability -| |---MyVpnExtAbility.ts // 三方vpn能力 - -``` - -### 具体实现 - -创建VPN隧道,建立VPN网络,VPN隧道保护,销毁VPN网络,接口封装在StartVpn和StopVpn,源码参考:StartVpn.ets和StopVpn.ets。 - - * 创建VPN隧道:调用StartVpn.CreateTunnel()来创建VPN隧道; - * 建立VPN网络:调用StartVpn.SetupVpn()来建立VPN网络; - * 销毁VPN网络:调用StopVpn.Destroy()来销毁VPN网络; - * VPN隧道保护:调用StartVpn.Protect()来开启VPN隧道保护; - -### 相关权限 -允许系统应用获取网络权限: ohos.permission.INTERNET,允许系统应用获取VPN权限: ohos.permission.MANAGE_VPN。 - -### 依赖 - -不涉及 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568。 - -2.本示例为Stage模型,支持API11版本SDK,SDK版本号(API Version 4.1 Beta1),镜像版本号(4.1 Beta1) - -3.本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。 - -4.本示例在启动前需搭建服务端环境,成功启动相应服务端后再运行客户端,服务端脚本(server_python)需要在Python 3.8.5版本下运行(需与客户端处于同一局域网)。 - -5.该示例运行测试完成后,再次运行需要重新启动服务端和客户端。 - -6.本示例使用了system_basic级别的权限(相关权限级别请查看[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md) ),需要手动配置高级别的权限签名(具体操作可查看[自动化签名方案](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465) ) 。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/BasicFeature/Connectivity/VPN/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` +# VPN连接 + +### 介绍 +本示例使用@ohos.net.vpn接口创建VPN 隧道,建立vpn网络,vpn隧道保护,销毁VPN网络以及使用@ohos.net.vpnExtension接口创建三方vpn等功能。 +实现了VPN的进行服务器连接,发送数据的功能 + +### 效果预览 +| 主页 | vpn启动 | vpn关闭 | +| ------------------------------ | --------------------------------- | --------------------------------------- | +| ![main.jpeg](sceenshots%2Fmain.jpeg) | ![start.jpeg](sceenshots%2Fstart.jpeg) | ![stop.jpeg](sceenshots%2Fstop.jpeg) | + + 使用说明 +1. 进入应用前请先安装[VPNFoundation](./lib/VPNFoundation-1.0.0.hap)。 +2. 进入应用后,主界面有启用VPN和停用VPN的选项。分别对应开启和关闭VPN功能。 +3. 在主界面,可以点击启用VPN来创建VPN连接。 +4. 在VPN启动界面,可以配置VPN服务器IP地址/隧道IP地址/使用VPN的应用程序。 +5. 在VPN启动界面,点击创建对象可以创建VPN隧道,点击隧道保护可以开启隧道保护,点击启动VPN可以进行网络连接。 +6. 在主界面,可以点击停用VPN来断开和关闭VPN连接。 + +7. 以上演示系统vpn,如果使用三方vpn,点击启动vpnExt按钮,弹窗提示vpn使用许可,同意后三方vpn启动并自动连接,尝试用浏览器等hap包访问百度 + +| 三方vpn弹窗 | +| ------------------------------ | +| ![vpnextension.jpeg](sceenshots%2Fvpnextension.jpeg)| + +8 .访问成功后返回主页面,点击关闭vpnExt按钮,断开三方vpn连接 + +### 工程目录 + +``` +entry/src/main/ets/ +|---entryability +| |---EntryAbility.ts // 项目入口,请求相关权限 +|---pages +| |---Index.ets // 首页 +| |---StartVpn.ets // 打开vpn +| |---StopVpn.ets // 关闭vpn +|---model +| |---Logger.ets // 日志 +|---serviceextability +| |---MyVpnExtAbility.ts // 三方vpn能力 + +``` + +### 具体实现 + +创建VPN隧道,建立VPN网络,VPN隧道保护,销毁VPN网络,接口封装在StartVpn和StopVpn,源码参考:StartVpn.ets和StopVpn.ets。 + + * 创建VPN隧道:调用StartVpn.CreateTunnel()来创建VPN隧道; + * 建立VPN网络:调用StartVpn.SetupVpn()来建立VPN网络; + * 销毁VPN网络:调用StopVpn.Destroy()来销毁VPN网络; + * VPN隧道保护:调用StartVpn.Protect()来开启VPN隧道保护; + +### 相关权限 +允许系统应用获取网络权限: ohos.permission.INTERNET,允许系统应用获取VPN权限: ohos.permission.MANAGE_VPN。 + +### 依赖 + +不涉及 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568。 + +2.本示例为Stage模型,支持API11版本SDK,SDK版本号(API Version 4.1 Beta1),镜像版本号(4.1 Beta1) + +3.本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。 + +4.本示例在启动前需搭建服务端环境,成功启动相应服务端后再运行客户端,服务端脚本(server_python)需要在Python 3.8.5版本下运行(需与客户端处于同一局域网)。 + +5.该示例运行测试完成后,再次运行需要重新启动服务端和客户端。 + +6.本示例使用了system_basic级别的权限(相关权限级别请查看[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md) ),需要手动配置高级别的权限签名(具体操作可查看[自动化签名方案](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465) ) 。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/BasicFeature/Connectivity/VPN/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` diff --git "a/code/BasicFeature/Connectivity/VPN/VPN\346\265\213\350\257\225\347\224\250\344\276\213\346\212\245\345\221\212.md" "b/code/BasicFeature/Connectivity/VPN/VPN\346\265\213\350\257\225\347\224\250\344\276\213\346\212\245\345\221\212.md" index 9a2a4d043e..e026087716 100644 --- "a/code/BasicFeature/Connectivity/VPN/VPN\346\265\213\350\257\225\347\224\250\344\276\213\346\212\245\345\221\212.md" +++ "b/code/BasicFeature/Connectivity/VPN/VPN\346\265\213\350\257\225\347\224\250\344\276\213\346\212\245\345\221\212.md" @@ -1,9 +1,9 @@ -| 用例名称 | 预置条件 | 用例测试功能 | 输入 | 预期输出 | 是否自动 | 测试结果 | -|------------------| ---------------- |---------------------------|----------------------------|-----------------------------------------------| -------- | -------- | -| VPN_sample_test001 | 位于主页 | 界面UI展示 | 打开VPNSample。| 展示启用VPN和停用VPN的按钮,以及Toy VPN标题。| 是 | Pass | -| VPN_sample_test002 | 位于主页 | 选择启用VPN | 打开VPNSample,点击启用VPN按钮。| 1.正常跳转到启动VPN页面。
2.正常显示VPN配置,创建对象、隧道保护以及启动vpn按钮正常显示和可用。| 否 | Pass | -| VPN_sample_test003 | 位于启动VPN界面 | 创建VPN隧道 | 打开VPNSample,点击启用VPN按钮,点击创建对象按钮。| 和已经配置IP地址和端口的VpnServer发起Tcp建联,返回隧道的Fd。| 否 | Pass | -| VPN_sample_test004 | 位于启动VPN界面 | 开启隧道保护 | 打开VPNSample,点击启用VPN按钮,点击隧道保护按钮。| 提示开启隧道保护成功。| 否 | Pass | -| VPN_sample_test005 | 位于启动VPN界面 | 启动VPN连接 | 打开VPNSample,点击启用VPN按钮,点击启动vpn按钮。| 提示通过隧道进行VPN连接。| 否 | Pass | -| VPN_sample_test006 | 位于主页 | 选择停用VPN | 打开VPNSample,点击停用VPN按钮。| 1.正常跳转到关闭vpn页面。
2.正常显示关闭vpn按钮且按钮可用。| 否 | Pass | -| VPN_sample_test007 | 位于停用VPN界面 | 选择关闭VPN | 打开VPNSample,点击停用VPN按钮,点击关闭vpn按钮。| 1.正常跳转到关闭vpn页面。
2.提示关闭VPN隧道和连接。| 否 | Pass | +| 用例名称 | 预置条件 | 用例测试功能 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|------------------| ---------------- |---------------------------|----------------------------|-----------------------------------------------| -------- | -------- | +| VPN_sample_test001 | 位于主页 | 界面UI展示 | 打开VPNSample。| 展示启用VPN和停用VPN的按钮,以及Toy VPN标题。| 是 | Pass | +| VPN_sample_test002 | 位于主页 | 选择启用VPN | 打开VPNSample,点击启用VPN按钮。| 1.正常跳转到启动VPN页面。
2.正常显示VPN配置,创建对象、隧道保护以及启动vpn按钮正常显示和可用。| 否 | Pass | +| VPN_sample_test003 | 位于启动VPN界面 | 创建VPN隧道 | 打开VPNSample,点击启用VPN按钮,点击创建对象按钮。| 和已经配置IP地址和端口的VpnServer发起Tcp建联,返回隧道的Fd。| 否 | Pass | +| VPN_sample_test004 | 位于启动VPN界面 | 开启隧道保护 | 打开VPNSample,点击启用VPN按钮,点击隧道保护按钮。| 提示开启隧道保护成功。| 否 | Pass | +| VPN_sample_test005 | 位于启动VPN界面 | 启动VPN连接 | 打开VPNSample,点击启用VPN按钮,点击启动vpn按钮。| 提示通过隧道进行VPN连接。| 否 | Pass | +| VPN_sample_test006 | 位于主页 | 选择停用VPN | 打开VPNSample,点击停用VPN按钮。| 1.正常跳转到关闭vpn页面。
2.正常显示关闭vpn按钮且按钮可用。| 否 | Pass | +| VPN_sample_test007 | 位于停用VPN界面 | 选择关闭VPN | 打开VPNSample,点击停用VPN按钮,点击关闭vpn按钮。| 1.正常跳转到关闭vpn页面。
2.提示关闭VPN隧道和连接。| 否 | Pass | diff --git a/code/BasicFeature/Connectivity/VPN/build-profile.json5 b/code/BasicFeature/Connectivity/VPN/build-profile.json5 index 1b9ae4c2c2..47bc713287 100644 --- a/code/BasicFeature/Connectivity/VPN/build-profile.json5 +++ b/code/BasicFeature/Connectivity/VPN/build-profile.json5 @@ -1,56 +1,56 @@ -/* -* Copyright (c) 2023 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", - //Specify the version of OpenHarmony application/service to be used during compilation. - "compileSdkVersion": 11, - //Specify the minimum version of OpenHarmony that the application/service is compatible with. - "compatibleSdkVersion": 11, - //Specify the target version of OpenHarmony for the application/service. If not set, it defaults to compatibleSdkVersion. - "targetSdkVersion": 11, - //Specify OpenHarmony as the target platform. - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* +* Copyright (c) 2023 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", + //Specify the version of OpenHarmony application/service to be used during compilation. + "compileSdkVersion": 11, + //Specify the minimum version of OpenHarmony that the application/service is compatible with. + "compatibleSdkVersion": 11, + //Specify the target version of OpenHarmony for the application/service. If not set, it defaults to compatibleSdkVersion. + "targetSdkVersion": 11, + //Specify OpenHarmony as the target platform. + "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/BasicFeature/Connectivity/VPN/entry/build-profile.json5 b/code/BasicFeature/Connectivity/VPN/entry/build-profile.json5 index 6968595ec3..f2e9110296 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/build-profile.json5 +++ b/code/BasicFeature/Connectivity/VPN/entry/build-profile.json5 @@ -1,39 +1,39 @@ -/* -* Copyright (c) 2023-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" - ] - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* +* Copyright (c) 2023-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" + ] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/oh-package.json5 b/code/BasicFeature/Connectivity/VPN/entry/oh-package.json5 index e74c2f98f6..f4b9ceda41 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/oh-package.json5 +++ b/code/BasicFeature/Connectivity/VPN/entry/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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": { - "libvpn_client.so": "file:./src/main/cpp/types/libentry" - } +/* + * Copyright (c) 2023 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": { + "libvpn_client.so": "file:./src/main/cpp/types/libentry" + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/CMakeLists.txt index 0e63d48d35..3b34f4f7a2 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/CMakeLists.txt +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/CMakeLists.txt @@ -1,21 +1,21 @@ -# Set the minimum required version of CMake to 3.4.1 -cmake_minimum_required(VERSION 3.4.1) - -# set the project name as "XComponent" -project(XComponent) - -# Define the variable NATIVERENDER_ROOT_PATH as the root path of the current source code -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -# Add the header file path to the project -include_directories( - ${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include -) - -# Build the shared library vpn_client and add the source code file vpn_client.cpp -add_library(vpn_client SHARED vpn_client.cpp) - -# Link two library files into the vpn_client library -target_link_libraries(vpn_client PUBLIC libace_napi.z.so libc++.a) +# Set the minimum required version of CMake to 3.4.1 +cmake_minimum_required(VERSION 3.4.1) + +# set the project name as "XComponent" +project(XComponent) + +# Define the variable NATIVERENDER_ROOT_PATH as the root path of the current source code +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +# Add the header file path to the project +include_directories( + ${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include +) + +# Build the shared library vpn_client and add the source code file vpn_client.cpp +add_library(vpn_client SHARED vpn_client.cpp) + +# Link two library files into the vpn_client library +target_link_libraries(vpn_client PUBLIC libace_napi.z.so libc++.a) target_link_libraries(vpn_client PUBLIC libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/index.d.ts b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/index.d.ts index ac36d80b3f..f80e777f2b 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2023 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 tcpConnect: (addr: string, port: number) => number; - -export const startVpn: (tunFd: number, tunnelFd: number) => number; - +/* + * Copyright (c) 2023 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 tcpConnect: (addr: string, port: number) => number; + +export const startVpn: (tunFd: number, tunnelFd: number) => number; + export const stopVpn: (tunnelFd: number) => number; \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/oh-package.json5 index b959526d1a..9429d311a6 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,6 +1,6 @@ -{ - "name": "libvpn_client.so", - "types": "./index.d.ts", - "version": "", - "description": "Please describe the basic information." +{ + "name": "libvpn_client.so", + "types": "./index.d.ts", + "version": "", + "description": "Please describe the basic information." } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/vpn_client.cpp b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/vpn_client.cpp index efc71e40c3..605863aa7c 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/vpn_client.cpp +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/vpn_client.cpp @@ -1,250 +1,250 @@ -/* -* Copyright (c) 2023 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 "hilog/log.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define MAKE_FILE_NAME (strrchr(__FILE__, '/') + 1) - -#define NETMANAGER_VPN_LOGE(fmt, ...) \ - OH_LOG_Print(LOG_APP, LOG_ERROR, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \ - __LINE__, ##__VA_ARGS__) - -#define NETMANAGER_VPN_LOGI(fmt, ...) \ - OH_LOG_Print(LOG_APP, LOG_INFO, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \ - __LINE__, ##__VA_ARGS__) - -#define NETMANAGER_VPN_LOGD(fmt, ...) \ - OH_LOG_Print(LOG_APP, LOG_DEBUG, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \ - __LINE__, ##__VA_ARGS__) - -constexpr int BUFFER_SIZE = 2048; -constexpr int ERRORAGAIN = 11; - -struct FdInfo { - int32_t tunFd = 0; - int32_t tunnelFd = 0; - struct sockaddr_in serverAddr; -}; - -static FdInfo g_fdInfo; -static bool g_threadRunF = false; -static std::thread g_threadt1; -static std::thread g_threadt2; - -static constexpr const int MAX_STRING_LENGTH = 1024; -static std::string GetStringFromValueUtf8(napi_env env, napi_value value) -{ - std::string result; - char str[MAX_STRING_LENGTH] = {0}; - size_t length = 0; - napi_get_value_string_utf8(env, value, str, MAX_STRING_LENGTH, &length); - if (length > 0) { - return result.append(str, length); - } - return result; -} - -static void HandleReadTunfd(FdInfo fdInfo) -{ - uint8_t buffer[BUFFER_SIZE] = {0}; - while (g_threadRunF) { - if (fdInfo.tunFd <= 0) { - sleep(1); - continue; - } - - int ret = read(fdInfo.tunFd, buffer, sizeof(buffer)); - if (ret <= 0) { - if (errno != ERRORAGAIN) { - sleep(1); - } - continue; - } - - // Read the data from the virtual network interface and send it to the client through a TCP tunnel. - NETMANAGER_VPN_LOGD("buffer: %{public}s, len: %{public}d", buffer, ret); - ret = sendto(fdInfo.tunnelFd, buffer, ret, 0, - reinterpret_cast(&fdInfo.serverAddr), sizeof(fdInfo.serverAddr)); - if (ret <= 0) { - NETMANAGER_VPN_LOGE("send to server[%{public}s:%{public}d] failed, ret: %{public}d, error: %{public}s", - inet_ntoa(fdInfo.serverAddr.sin_addr), ntohs(fdInfo.serverAddr.sin_port), ret, - strerror(errno)); - continue; - } - } -} - -static void HandleTcpReceived(FdInfo fdInfo) -{ - int addrlen = sizeof(struct sockaddr_in); - uint8_t buffer[BUFFER_SIZE] = {0}; - while (g_threadRunF) { - if (fdInfo.tunnelFd <= 0) { - sleep(1); - continue; - } - - int length = recvfrom(fdInfo.tunnelFd, buffer, sizeof(buffer), 0, - reinterpret_cast(&fdInfo.serverAddr), - reinterpret_cast(&addrlen)); - if (length < 0) { - if (errno != EAGAIN) { - NETMANAGER_VPN_LOGE("read tun device error: %{public}d %{public}d", errno, fdInfo.tunnelFd); - } - continue; - } - - NETMANAGER_VPN_LOGI("from [%{public}s:%{public}d] data: %{public}s, len: %{public}d", - inet_ntoa(fdInfo.serverAddr.sin_addr), ntohs(fdInfo.serverAddr.sin_port), buffer, length); - int ret = write(fdInfo.tunFd, buffer, length); - if (ret <= 0) { - NETMANAGER_VPN_LOGE("error Write To Tunfd, errno: %{public}d", errno); - } - } -} - -static napi_value TcpConnect(napi_env env, napi_callback_info info) -{ - size_t numArgs = 2; - size_t argc = numArgs; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - int32_t port = 0; - napi_get_value_int32(env, args[1], &port); - std::string ipAddr = GetStringFromValueUtf8(env, args[0]); - - NETMANAGER_VPN_LOGI("ip: %{public}s port: %{public}d", ipAddr.c_str(), port); - - int32_t sockFd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockFd == -1) { - NETMANAGER_VPN_LOGE("socket() error"); - return 0; - } - - struct timeval timeout = {1, 0}; - setsockopt(sockFd, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&timeout), sizeof(struct timeval)); - - memset(&g_fdInfo.serverAddr, 0, sizeof(g_fdInfo.serverAddr)); - g_fdInfo.serverAddr.sin_family = AF_INET; - g_fdInfo.serverAddr.sin_addr.s_addr = inet_addr(ipAddr.c_str()); // server's IP addr - g_fdInfo.serverAddr.sin_port = htons(port); // port - - NETMANAGER_VPN_LOGI("Connection successful\n"); - - napi_value tunnelFd; - napi_create_int32(env, sockFd, &tunnelFd); - return tunnelFd; -} - -static napi_value StartVpn(napi_env env, napi_callback_info info) -{ - size_t numArgs = 2; - size_t argc = numArgs; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - napi_get_value_int32(env, args[0], &g_fdInfo.tunFd); - napi_get_value_int32(env, args[1], &g_fdInfo.tunnelFd); - - if (g_threadRunF) { - g_threadRunF = false; - g_threadt1.join(); - g_threadt2.join(); - } - - g_threadRunF = true; - std::thread tt1(HandleReadTunfd, g_fdInfo); - std::thread tt2(HandleTcpReceived, g_fdInfo); - - g_threadt1 = std::move(tt1); - g_threadt2 = std::move(tt2); - - NETMANAGER_VPN_LOGI("StartVpn successful\n"); - - napi_value retValue; - napi_create_int32(env, 0, &retValue); - return retValue; -} - -static napi_value StopVpn(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - int32_t tunnelFd; - napi_get_value_int32(env, args[0], &tunnelFd); - if (tunnelFd) { - close(tunnelFd); - tunnelFd = 0; - } - - if (g_threadRunF) { - g_threadRunF = false; - g_threadt1.join(); - g_threadt2.join(); - } - - NETMANAGER_VPN_LOGI("StopVpn successful\n"); - - napi_value retValue; - napi_create_int32(env, 0, &retValue); - return retValue; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"tcpConnect", nullptr, TcpConnect, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"startVpn", nullptr, StartVpn, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"stopVpn", nullptr, StopVpn, nullptr, nullptr, nullptr, napi_default, nullptr}, - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - NETMANAGER_VPN_LOGI("vpn 15b0 HELLO ~~~~~~~~~~"); - napi_module_register(&demoModule); -} +/* +* Copyright (c) 2023 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 "hilog/log.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define MAKE_FILE_NAME (strrchr(__FILE__, '/') + 1) + +#define NETMANAGER_VPN_LOGE(fmt, ...) \ + OH_LOG_Print(LOG_APP, LOG_ERROR, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \ + __LINE__, ##__VA_ARGS__) + +#define NETMANAGER_VPN_LOGI(fmt, ...) \ + OH_LOG_Print(LOG_APP, LOG_INFO, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \ + __LINE__, ##__VA_ARGS__) + +#define NETMANAGER_VPN_LOGD(fmt, ...) \ + OH_LOG_Print(LOG_APP, LOG_DEBUG, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \ + __LINE__, ##__VA_ARGS__) + +constexpr int BUFFER_SIZE = 2048; +constexpr int ERRORAGAIN = 11; + +struct FdInfo { + int32_t tunFd = 0; + int32_t tunnelFd = 0; + struct sockaddr_in serverAddr; +}; + +static FdInfo g_fdInfo; +static bool g_threadRunF = false; +static std::thread g_threadt1; +static std::thread g_threadt2; + +static constexpr const int MAX_STRING_LENGTH = 1024; +static std::string GetStringFromValueUtf8(napi_env env, napi_value value) +{ + std::string result; + char str[MAX_STRING_LENGTH] = {0}; + size_t length = 0; + napi_get_value_string_utf8(env, value, str, MAX_STRING_LENGTH, &length); + if (length > 0) { + return result.append(str, length); + } + return result; +} + +static void HandleReadTunfd(FdInfo fdInfo) +{ + uint8_t buffer[BUFFER_SIZE] = {0}; + while (g_threadRunF) { + if (fdInfo.tunFd <= 0) { + sleep(1); + continue; + } + + int ret = read(fdInfo.tunFd, buffer, sizeof(buffer)); + if (ret <= 0) { + if (errno != ERRORAGAIN) { + sleep(1); + } + continue; + } + + // Read the data from the virtual network interface and send it to the client through a TCP tunnel. + NETMANAGER_VPN_LOGD("buffer: %{public}s, len: %{public}d", buffer, ret); + ret = sendto(fdInfo.tunnelFd, buffer, ret, 0, + reinterpret_cast(&fdInfo.serverAddr), sizeof(fdInfo.serverAddr)); + if (ret <= 0) { + NETMANAGER_VPN_LOGE("send to server[%{public}s:%{public}d] failed, ret: %{public}d, error: %{public}s", + inet_ntoa(fdInfo.serverAddr.sin_addr), ntohs(fdInfo.serverAddr.sin_port), ret, + strerror(errno)); + continue; + } + } +} + +static void HandleTcpReceived(FdInfo fdInfo) +{ + int addrlen = sizeof(struct sockaddr_in); + uint8_t buffer[BUFFER_SIZE] = {0}; + while (g_threadRunF) { + if (fdInfo.tunnelFd <= 0) { + sleep(1); + continue; + } + + int length = recvfrom(fdInfo.tunnelFd, buffer, sizeof(buffer), 0, + reinterpret_cast(&fdInfo.serverAddr), + reinterpret_cast(&addrlen)); + if (length < 0) { + if (errno != EAGAIN) { + NETMANAGER_VPN_LOGE("read tun device error: %{public}d %{public}d", errno, fdInfo.tunnelFd); + } + continue; + } + + NETMANAGER_VPN_LOGI("from [%{public}s:%{public}d] data: %{public}s, len: %{public}d", + inet_ntoa(fdInfo.serverAddr.sin_addr), ntohs(fdInfo.serverAddr.sin_port), buffer, length); + int ret = write(fdInfo.tunFd, buffer, length); + if (ret <= 0) { + NETMANAGER_VPN_LOGE("error Write To Tunfd, errno: %{public}d", errno); + } + } +} + +static napi_value TcpConnect(napi_env env, napi_callback_info info) +{ + size_t numArgs = 2; + size_t argc = numArgs; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + int32_t port = 0; + napi_get_value_int32(env, args[1], &port); + std::string ipAddr = GetStringFromValueUtf8(env, args[0]); + + NETMANAGER_VPN_LOGI("ip: %{public}s port: %{public}d", ipAddr.c_str(), port); + + int32_t sockFd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockFd == -1) { + NETMANAGER_VPN_LOGE("socket() error"); + return 0; + } + + struct timeval timeout = {1, 0}; + setsockopt(sockFd, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&timeout), sizeof(struct timeval)); + + memset(&g_fdInfo.serverAddr, 0, sizeof(g_fdInfo.serverAddr)); + g_fdInfo.serverAddr.sin_family = AF_INET; + g_fdInfo.serverAddr.sin_addr.s_addr = inet_addr(ipAddr.c_str()); // server's IP addr + g_fdInfo.serverAddr.sin_port = htons(port); // port + + NETMANAGER_VPN_LOGI("Connection successful\n"); + + napi_value tunnelFd; + napi_create_int32(env, sockFd, &tunnelFd); + return tunnelFd; +} + +static napi_value StartVpn(napi_env env, napi_callback_info info) +{ + size_t numArgs = 2; + size_t argc = numArgs; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_get_value_int32(env, args[0], &g_fdInfo.tunFd); + napi_get_value_int32(env, args[1], &g_fdInfo.tunnelFd); + + if (g_threadRunF) { + g_threadRunF = false; + g_threadt1.join(); + g_threadt2.join(); + } + + g_threadRunF = true; + std::thread tt1(HandleReadTunfd, g_fdInfo); + std::thread tt2(HandleTcpReceived, g_fdInfo); + + g_threadt1 = std::move(tt1); + g_threadt2 = std::move(tt2); + + NETMANAGER_VPN_LOGI("StartVpn successful\n"); + + napi_value retValue; + napi_create_int32(env, 0, &retValue); + return retValue; +} + +static napi_value StopVpn(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + int32_t tunnelFd; + napi_get_value_int32(env, args[0], &tunnelFd); + if (tunnelFd) { + close(tunnelFd); + tunnelFd = 0; + } + + if (g_threadRunF) { + g_threadRunF = false; + g_threadt1.join(); + g_threadt2.join(); + } + + NETMANAGER_VPN_LOGI("StopVpn successful\n"); + + napi_value retValue; + napi_create_int32(env, 0, &retValue); + return retValue; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"tcpConnect", nullptr, TcpConnect, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"startVpn", nullptr, StartVpn, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"stopVpn", nullptr, StopVpn, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + NETMANAGER_VPN_LOGI("vpn 15b0 HELLO ~~~~~~~~~~"); + napi_module_register(&demoModule); +} diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/entryability/EntryAbility.ts index fe1acdb252..6132d1d0d3 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,58 +1,58 @@ -/* -* Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - 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'); - } -}; +/* +* Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + 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/BasicFeature/Connectivity/VPN/entry/src/main/ets/model/Logger.ets b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/model/Logger.ets index ec90e1fa3b..1f100b4df5 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/model/Logger.ets +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/model/Logger.ets @@ -1,40 +1,40 @@ -/* -* Copyright (c) 2023 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. -*/ - - class Logger { - private prefix: string - - constructor(prefix: string) { - this.prefix = prefix - } - - log(...args: string[]) { - console.log(`[${this.prefix}].${args.join(' ')}`) - } - - info(...args: string[]) { - console.log(`[${this.prefix}].${args.join(' ')}`) - } - - debug(...args: string[]) { - console.log(`[${this.prefix}].${args.join(' ')}`) - } - - error(...args: string[]) { - console.log(`[${this.prefix}].${args.join(' ')}`) - } - } - +/* +* Copyright (c) 2023 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. +*/ + + class Logger { + private prefix: string + + constructor(prefix: string) { + this.prefix = prefix + } + + log(...args: string[]) { + console.log(`[${this.prefix}].${args.join(' ')}`) + } + + info(...args: string[]) { + console.log(`[${this.prefix}].${args.join(' ')}`) + } + + debug(...args: string[]) { + console.log(`[${this.prefix}].${args.join(' ')}`) + } + + error(...args: string[]) { + console.log(`[${this.prefix}].${args.join(' ')}`) + } + } + export default new Logger('[Sample_Wlan]') \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/Index.ets index c09c56ce83..6c6879fd53 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/Index.ets @@ -1,55 +1,55 @@ -/* -* Copyright (c) 2023 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import hilog from '@ohos.hilog'; -import router from '@ohos.router'; -import { BusinessError } from '@ohos.base'; - -@Entry -@Component -struct Index { - @State message: string = 'Toy VPN'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(35) - .fontWeight(FontWeight.Bold) - .onClick(() => { - hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client'); - }) - Button('Start VPN').onClick(() => { - hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in clicking the button.'); - router.pushUrl({ url: 'pages/StartVpn' }).then(() => { - hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in jumping to the second page.'); - }).catch((err: BusinessError) => { - hilog.error(0x0000, 'developTag', 'Failed to jump to the second page: %{public}s', - JSON.stringify(err) ?? ''); - }) - }).width('70%').fontSize(45).margin(16) - Button('Stop VPN').onClick(() => { - hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in clicking the button.'); - router.pushUrl({ url: 'pages/StopVpn' }).then(() => { - hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in jumping to the second page.'); - }).catch((err: BusinessError) => { - hilog.error(0x0000, 'developTag', 'Failed to jump to the second page: %{public}s', - JSON.stringify(err) ?? ''); - }) - }).width('70%').fontSize(45) - }.width('100%') - }.height('100%') - } +/* +* Copyright (c) 2023 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import hilog from '@ohos.hilog'; +import router from '@ohos.router'; +import { BusinessError } from '@ohos.base'; + +@Entry +@Component +struct Index { + @State message: string = 'Toy VPN'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(35) + .fontWeight(FontWeight.Bold) + .onClick(() => { + hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client'); + }) + Button('Start VPN').onClick(() => { + hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in clicking the button.'); + router.pushUrl({ url: 'pages/StartVpn' }).then(() => { + hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in jumping to the second page.'); + }).catch((err: BusinessError) => { + hilog.error(0x0000, 'developTag', 'Failed to jump to the second page: %{public}s', + JSON.stringify(err) ?? ''); + }) + }).width('70%').fontSize(45).margin(16) + Button('Stop VPN').onClick(() => { + hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in clicking the button.'); + router.pushUrl({ url: 'pages/StopVpn' }).then(() => { + hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in jumping to the second page.'); + }).catch((err: BusinessError) => { + hilog.error(0x0000, 'developTag', 'Failed to jump to the second page: %{public}s', + JSON.stringify(err) ?? ''); + }) + }).width('70%').fontSize(45) + }.width('100%') + }.height('100%') + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StartVpn.ets b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StartVpn.ets index 8952dfeaf3..8753a423e3 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StartVpn.ets +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StartVpn.ets @@ -1,184 +1,184 @@ -/* -* Copyright (c) 2023 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import hilog from '@ohos.hilog'; -import vpn_client from 'libvpn_client.so'; -import common from '@ohos.app.ability.common'; -import vpnext from '@ohos.net.vpnExtension'; -import Want from '@ohos.app.ability.Want'; -import { showToast } from '../components/ShowToast'; -import { BusinessError } from '@kit.BasicServicesKit'; - -let want: Want = { - deviceId: "", - bundleName: "com.example.myvpndemo", - abilityName: "MyVpnExtAbility", -}; - -let g_tunFd = -1; -let g_tunnelFd = -1; - -@Entry -@Component -struct StartVpn { - @State message: string = 'Toy VPN'; - @State vpnServerIp: string = '192.168.31.13'; - @State tunIp: string = '10.0.0.5'; - @State prefix: string = '24'; - @State blockedAppName: string = 'com.example.baidumyapplication'; - private context = getContext(this) as common.VpnExtensionContext; - private VpnConnection: vpnext.VpnConnection = vpnext.createVpnConnection(this.context); - - CreateTunnel() { - g_tunnelFd = vpn_client.tcpConnect(this.vpnServerIp, 8888); - if (g_tunnelFd) { - showToast('CreateTunnel Success', 2000); - hilog.info(0x0000, 'developTag', '%{public}s', 'CreateTunnel Success'); - } else { - showToast('CreateTunnel Fail', 2000); - hilog.error(0x0000, 'developTag', 'CreateTunnel Fail %{public}s', 'CreateTunnel Fail'); - } - } - - Protect() { - hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Protect'); - this.VpnConnection.protect(g_tunnelFd).then(() => { - showToast('vpn Protect Success', 2000); - hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Protect Success'); - }).catch((err: Error) => { - showToast('vpn Protect Failed: ' + JSON.stringify(err), 2000); - hilog.error(0x0000, 'developTag', 'vpn Protect Failed %{public}s', JSON.stringify(err) ?? ''); - }) - } - - SetupVpn() { - hilog.info(0x0000, 'developTag', '%{public}s', 'vpn SetupVpn'); - class Address { - address: string; - family: number; - - constructor(address: string, family: number) { - this.address = address; - this.family = family; - } - } - - class AddressWithPrefix { - address: Address; - prefixLength: number; - - constructor(address: Address, prefixLength: number) { - this.address = address; - this.prefixLength = prefixLength; - } - } - - class Config { - addresses: AddressWithPrefix[]; - mtu: number; - dnsAddresses: string[]; - trustedApplications: string[]; - blockedApplications: string[]; - - constructor( - tunIp: string, - blockedAppName: string - ) { - this.addresses = [ - new AddressWithPrefix(new Address(tunIp, 1), 24) - ]; - this.mtu = 1400; - this.dnsAddresses = ["114.114.114.114"]; - this.trustedApplications = []; - this.blockedApplications = [blockedAppName]; - } - } - - let config = new Config(this.tunIp, this.blockedAppName); - this.VpnConnection.create(config).then((data) => { - g_tunFd = data; - hilog.error(0x0000, 'developTag', 'tunfd: %{public}s', JSON.stringify(data) ?? ''); - vpn_client.startVpn(g_tunFd, g_tunnelFd); - showToast('vpn start Success', 2000); - hilog.info(0x0000, 'developTag', '%{public}s', 'vpn start Success'); - }).catch((err: BusinessError) => { - showToast('vpn start Fail: ' + JSON.stringify(err), 2000); - hilog.error(0x0000, 'developTag', 'vpn start Fail %{public}s', JSON.stringify(err) ?? ''); - }) - } - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(35) - .fontWeight(FontWeight.Bold) - .onClick(() => { - hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client'); - }) - - Row() { - //ip address of server - Text('server ip').fontSize(30).width('40%').textAlign(TextAlign.Center) - .backgroundColor(0xAFEEEE) - TextInput({ text: '192.168.31.13' }).onChange((value) => { - this.vpnServerIp = value; - }).width('60%').margin(2) - }.width('90%') - - Row() { - //ip address of tun-vpn on server - Text('tun ip').fontSize(30).width('40%').textAlign(TextAlign.Center) - .backgroundColor(0xAFEEEE) - TextInput({ text: '10.0.0.5' }).onChange((value) => { - this.tunIp = value; - }).width('60%').margin(2) - }.width('90%') - - Row() { - //blocked Hap - Text('blockedApp').fontSize(30).width('40%').textAlign(TextAlign.Center) - .backgroundColor(0xAFEEEE) - TextInput({ text: 'com.example.baidumyapplication' }).onChange((value) => { - this.blockedAppName = value; - }).width('60%').margin(2) - }.width('90%') - - Button($r('app.string.btn_create_tunnel')).onClick(() => { - this.CreateTunnel(); - }).fontSize(50) - Button($r('app.string.btn_protect')).onClick(() => { - this.Protect(); - }).fontSize(50) - Button($r('app.string.btn_start_vpn')).onClick(() => { - this.SetupVpn(); - }).fontSize(50) - Button($r('app.string.btn_start_vpnExt')).onClick(() => { - try { - vpnext.startVpnExtensionAbility(want).then(() => { - showToast('start vpnExt Success', 2000); - hilog.info(0x0000, 'developTag', '%{public}s', 'start vpnExt Success'); - }) - } catch (err) { - showToast('start vpnExt Fail: ' + JSON.stringify(err), 2000); - hilog.error(0x0000, 'developTag', 'start vpnExt Fail %{public}s', JSON.stringify(err) ?? ''); - } - }).fontSize(50) - } - .width('100%') - } - .height('100%') - } +/* +* Copyright (c) 2023 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import hilog from '@ohos.hilog'; +import vpn_client from 'libvpn_client.so'; +import common from '@ohos.app.ability.common'; +import vpnext from '@ohos.net.vpnExtension'; +import Want from '@ohos.app.ability.Want'; +import { showToast } from '../components/ShowToast'; +import { BusinessError } from '@kit.BasicServicesKit'; + +let want: Want = { + deviceId: "", + bundleName: "com.example.myvpndemo", + abilityName: "MyVpnExtAbility", +}; + +let g_tunFd = -1; +let g_tunnelFd = -1; + +@Entry +@Component +struct StartVpn { + @State message: string = 'Toy VPN'; + @State vpnServerIp: string = '192.168.31.13'; + @State tunIp: string = '10.0.0.5'; + @State prefix: string = '24'; + @State blockedAppName: string = 'com.example.baidumyapplication'; + private context = getContext(this) as common.VpnExtensionContext; + private VpnConnection: vpnext.VpnConnection = vpnext.createVpnConnection(this.context); + + CreateTunnel() { + g_tunnelFd = vpn_client.tcpConnect(this.vpnServerIp, 8888); + if (g_tunnelFd) { + showToast('CreateTunnel Success', 2000); + hilog.info(0x0000, 'developTag', '%{public}s', 'CreateTunnel Success'); + } else { + showToast('CreateTunnel Fail', 2000); + hilog.error(0x0000, 'developTag', 'CreateTunnel Fail %{public}s', 'CreateTunnel Fail'); + } + } + + Protect() { + hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Protect'); + this.VpnConnection.protect(g_tunnelFd).then(() => { + showToast('vpn Protect Success', 2000); + hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Protect Success'); + }).catch((err: Error) => { + showToast('vpn Protect Failed: ' + JSON.stringify(err), 2000); + hilog.error(0x0000, 'developTag', 'vpn Protect Failed %{public}s', JSON.stringify(err) ?? ''); + }) + } + + SetupVpn() { + hilog.info(0x0000, 'developTag', '%{public}s', 'vpn SetupVpn'); + class Address { + address: string; + family: number; + + constructor(address: string, family: number) { + this.address = address; + this.family = family; + } + } + + class AddressWithPrefix { + address: Address; + prefixLength: number; + + constructor(address: Address, prefixLength: number) { + this.address = address; + this.prefixLength = prefixLength; + } + } + + class Config { + addresses: AddressWithPrefix[]; + mtu: number; + dnsAddresses: string[]; + trustedApplications: string[]; + blockedApplications: string[]; + + constructor( + tunIp: string, + blockedAppName: string + ) { + this.addresses = [ + new AddressWithPrefix(new Address(tunIp, 1), 24) + ]; + this.mtu = 1400; + this.dnsAddresses = ["114.114.114.114"]; + this.trustedApplications = []; + this.blockedApplications = [blockedAppName]; + } + } + + let config = new Config(this.tunIp, this.blockedAppName); + this.VpnConnection.create(config).then((data) => { + g_tunFd = data; + hilog.error(0x0000, 'developTag', 'tunfd: %{public}s', JSON.stringify(data) ?? ''); + vpn_client.startVpn(g_tunFd, g_tunnelFd); + showToast('vpn start Success', 2000); + hilog.info(0x0000, 'developTag', '%{public}s', 'vpn start Success'); + }).catch((err: BusinessError) => { + showToast('vpn start Fail: ' + JSON.stringify(err), 2000); + hilog.error(0x0000, 'developTag', 'vpn start Fail %{public}s', JSON.stringify(err) ?? ''); + }) + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(35) + .fontWeight(FontWeight.Bold) + .onClick(() => { + hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client'); + }) + + Row() { + //ip address of server + Text('server ip').fontSize(30).width('40%').textAlign(TextAlign.Center) + .backgroundColor(0xAFEEEE) + TextInput({ text: '192.168.31.13' }).onChange((value) => { + this.vpnServerIp = value; + }).width('60%').margin(2) + }.width('90%') + + Row() { + //ip address of tun-vpn on server + Text('tun ip').fontSize(30).width('40%').textAlign(TextAlign.Center) + .backgroundColor(0xAFEEEE) + TextInput({ text: '10.0.0.5' }).onChange((value) => { + this.tunIp = value; + }).width('60%').margin(2) + }.width('90%') + + Row() { + //blocked Hap + Text('blockedApp').fontSize(30).width('40%').textAlign(TextAlign.Center) + .backgroundColor(0xAFEEEE) + TextInput({ text: 'com.example.baidumyapplication' }).onChange((value) => { + this.blockedAppName = value; + }).width('60%').margin(2) + }.width('90%') + + Button($r('app.string.btn_create_tunnel')).onClick(() => { + this.CreateTunnel(); + }).fontSize(50) + Button($r('app.string.btn_protect')).onClick(() => { + this.Protect(); + }).fontSize(50) + Button($r('app.string.btn_start_vpn')).onClick(() => { + this.SetupVpn(); + }).fontSize(50) + Button($r('app.string.btn_start_vpnExt')).onClick(() => { + try { + vpnext.startVpnExtensionAbility(want).then(() => { + showToast('start vpnExt Success', 2000); + hilog.info(0x0000, 'developTag', '%{public}s', 'start vpnExt Success'); + }) + } catch (err) { + showToast('start vpnExt Fail: ' + JSON.stringify(err), 2000); + hilog.error(0x0000, 'developTag', 'start vpnExt Fail %{public}s', JSON.stringify(err) ?? ''); + } + }).fontSize(50) + } + .width('100%') + } + .height('100%') + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StopVpn.ets b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StopVpn.ets index dfae42ccbd..75b6c75020 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StopVpn.ets +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StopVpn.ets @@ -1,80 +1,80 @@ -/* -* Copyright (c) 2023 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import hilog from '@ohos.hilog'; -import vpnext from '@ohos.net.vpnExtension'; -import Want from '@ohos.app.ability.Want'; -import common from '@ohos.app.ability.common'; -import vpn_client from "libvpn_client.so"; -import { showToast } from '../components/ShowToast'; - -let want: Want = { - deviceId: "", - bundleName: "com.example.myvpndemo", - abilityName: "MyVpnExtAbility", -}; -let g_tunnelFd = -1; - -@Entry -@Component -struct StopVpn { - @State message: string = 'VPN'; - @State vpnServerIp: string = '192.168.31.13'; - @State tunIp: string = '10.0.0.5'; - @State routeAddr: string = '192.168.214.0'; - @State prefix: string = '24'; - @State blockedAppName: string = 'com.example.baidumyapplication'; - private context = getContext(this) as common.VpnExtensionContext; - private VpnConnection: vpnext.VpnConnection = vpnext.createVpnConnection(this.context); - - Destroy() { - hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Destroy'); - vpn_client.stopVpn(g_tunnelFd); - this.VpnConnection.destroy().then(() => { - showToast('vpn Destroy Success', 2000); - hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Destroy Success'); - }).catch((err: Error) => { - showToast('vpn Destroy Failed: ' + JSON.stringify(err), 2000); - hilog.error(0x0000, 'developTag', 'vpn Destroy Failed: %{public}s', JSON.stringify(err) ?? ''); - }) - } - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(35) - .fontWeight(FontWeight.Bold) - .onClick(() => { - hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client'); - }) - Button('stop vpn').onClick(() => { - this.Destroy(); - }).fontSize(50) - Button('stop vpnExt').onClick(() => { - try { - vpnext.stopVpnExtensionAbility(want).then(() => { - showToast('stop vpnExt Success', 2000); - hilog.info(0x0000, 'developTag', '%{public}s', 'stop vpnExt Success'); - }) - } catch (err) { - showToast('stop vpnExt Fail: ' + JSON.stringify(err), 2000); - hilog.error(0x0000, 'developTag', 'stop vpnExt Fail %{public}s', JSON.stringify(err) ?? ''); - } - }).fontSize(50) - }.width('100%') - }.height('100%') - } +/* +* Copyright (c) 2023 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import hilog from '@ohos.hilog'; +import vpnext from '@ohos.net.vpnExtension'; +import Want from '@ohos.app.ability.Want'; +import common from '@ohos.app.ability.common'; +import vpn_client from "libvpn_client.so"; +import { showToast } from '../components/ShowToast'; + +let want: Want = { + deviceId: "", + bundleName: "com.example.myvpndemo", + abilityName: "MyVpnExtAbility", +}; +let g_tunnelFd = -1; + +@Entry +@Component +struct StopVpn { + @State message: string = 'VPN'; + @State vpnServerIp: string = '192.168.31.13'; + @State tunIp: string = '10.0.0.5'; + @State routeAddr: string = '192.168.214.0'; + @State prefix: string = '24'; + @State blockedAppName: string = 'com.example.baidumyapplication'; + private context = getContext(this) as common.VpnExtensionContext; + private VpnConnection: vpnext.VpnConnection = vpnext.createVpnConnection(this.context); + + Destroy() { + hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Destroy'); + vpn_client.stopVpn(g_tunnelFd); + this.VpnConnection.destroy().then(() => { + showToast('vpn Destroy Success', 2000); + hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Destroy Success'); + }).catch((err: Error) => { + showToast('vpn Destroy Failed: ' + JSON.stringify(err), 2000); + hilog.error(0x0000, 'developTag', 'vpn Destroy Failed: %{public}s', JSON.stringify(err) ?? ''); + }) + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(35) + .fontWeight(FontWeight.Bold) + .onClick(() => { + hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client'); + }) + Button('stop vpn').onClick(() => { + this.Destroy(); + }).fontSize(50) + Button('stop vpnExt').onClick(() => { + try { + vpnext.stopVpnExtensionAbility(want).then(() => { + showToast('stop vpnExt Success', 2000); + hilog.info(0x0000, 'developTag', '%{public}s', 'stop vpnExt Success'); + }) + } catch (err) { + showToast('stop vpnExt Fail: ' + JSON.stringify(err), 2000); + hilog.error(0x0000, 'developTag', 'stop vpnExt Fail %{public}s', JSON.stringify(err) ?? ''); + } + }).fontSize(50) + }.width('100%') + }.height('100%') + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/module.json5 b/code/BasicFeature/Connectivity/VPN/entry/src/main/module.json5 index 7b5d4bddec..cf0f399062 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/module.json5 +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/module.json5 @@ -1,57 +1,57 @@ -/* -* Copyright (c) 2023 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": [ - "tablet", - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ], - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* +* Copyright (c) 2023 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": [ + "tablet", + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ], + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/string.json b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/string.json index 02ef7dfd95..55e9d9478b 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/string.json +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/string.json @@ -1,32 +1,32 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "VPN" - }, - { - "name": "btn_create_tunnel", - "value": "创建隧道" - }, - { - "name": "btn_protect", - "value": "隧道保护" - }, - { - "name": "btn_start_vpn", - "value": "启动vpn" - }, - { - "name": "btn_start_vpnExt", - "value": "启动vpnExt" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "VPN" + }, + { + "name": "btn_create_tunnel", + "value": "创建隧道" + }, + { + "name": "btn_protect", + "value": "隧道保护" + }, + { + "name": "btn_start_vpn", + "value": "启动vpn" + }, + { + "name": "btn_start_vpnExt", + "value": "启动vpnExt" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/profile/main_pages.json index fc9de9b35a..65b5903f30 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/profile/main_pages.json +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/profile/main_pages.json @@ -1,7 +1,7 @@ -{ - "src": [ - "pages/Index", - "pages/StartVpn", - "pages/StopVpn" - ] -} +{ + "src": [ + "pages/Index", + "pages/StartVpn", + "pages/StopVpn" + ] +} diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/en_US/element/string.json index c50c4c2c0d..172a8567ec 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/en_US/element/string.json +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/en_US/element/string.json @@ -1,32 +1,32 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "label" - }, - { - "name": "btn_create_tunnel", - "value": "创建隧道" - }, - { - "name": "btn_protect", - "value": "隧道保护" - }, - { - "name": "btn_start_vpn", - "value": "启动vpn" - }, - { - "name": "btn_start_vpnExt", - "value": "启动vpnExt" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "btn_create_tunnel", + "value": "创建隧道" + }, + { + "name": "btn_protect", + "value": "隧道保护" + }, + { + "name": "btn_start_vpn", + "value": "启动vpn" + }, + { + "name": "btn_start_vpnExt", + "value": "启动vpnExt" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/zh_CN/element/string.json index 19a14d7711..320848d813 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/zh_CN/element/string.json +++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/zh_CN/element/string.json @@ -1,32 +1,32 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "模块描述" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "label" - }, - { - "name": "btn_create_tunnel", - "value": "创建隧道" - }, - { - "name": "btn_protect", - "value": "隧道保护" - }, - { - "name": "btn_start_vpn", - "value": "启动vpn" - }, - { - "name": "btn_start_vpnExt", - "value": "启动vpnExt" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "btn_create_tunnel", + "value": "创建隧道" + }, + { + "name": "btn_protect", + "value": "隧道保护" + }, + { + "name": "btn_start_vpn", + "value": "启动vpn" + }, + { + "name": "btn_start_vpnExt", + "value": "启动vpnExt" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/ets/test/Ability.test.ets index f7b9ddf659..32b21d3878 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,233 +1,233 @@ -/* -* Copyright (c) 2024 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import hilog from '@ohos.hilog'; -import { describe, it, expect } from '@ohos/hypium' -import { Driver, ON } from '@ohos.UiTest'; -import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; - -const TAG = '[Sample_VpnConnect]'; -const DOMAIN = 0xF811; - -let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); -async function getResourceString(resource: Resource): Promise { - let manage = abilityDelegator.getAppContext().resourceManager - let text = await manage.getStringValue(resource) - return text -} - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 启动Ability - */ - it('startAbility_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, 'startAbility_001 start'); - let driver = Driver.create(); - await driver.delayMs(1000); - await startAbility(); - await driver.delayMs(1000); - hilog.info(DOMAIN, TAG, 'startAbility_001 end'); - done(); - }); - - /** - * 进入首页,标题显示正确 - */ - it('IndexPageEnter_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, 'IndexPageEnter_001 start'); - let driver: Driver = Driver.create(); - await terminateAbility(); - await driver.delayMs(1000); - await startAbility(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Toy VPN')); - let titleComponent = await driver.findComponent(ON.text('Toy VPN')); - let titleContent = await titleComponent.getText(); - await driver.delayMs(200); - expect('Toy VPN').assertEqual(titleContent); - await driver.delayMs(200); - hilog.info(DOMAIN, TAG, 'IndexPageEnter_001 end'); - done(); - }); - - /** - * 在主界面启用VPN - */ - it('StartVpn_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, 'StartVpn_001 start'); - let driver = Driver.create(); - await terminateAbility(); - await driver.delayMs(1000); - await startAbility(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Start VPN')); - let startVpn = await driver.findComponent(ON.text('Start VPN')); - await driver.delayMs(200); - await startVpn.click(); - await driver.delayMs(200); - hilog.info(DOMAIN, TAG, 'StartVpn_001 end'); - done(); - }); - - /** - * 在主界面启用VPN后,再创建隧道 - */ - it('CreateTunnel_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, 'CreateTunnel_001 start'); - let driver = Driver.create(); - await terminateAbility(); - await driver.delayMs(1000); - await startAbility(); - await driver.delayMs(1000); - // 点击启用VPN - await driver.assertComponentExist(ON.text('Start VPN')); - let startVpn = await driver.findComponent(ON.text('Start VPN')); - await driver.delayMs(200); - await startVpn.click(); - // 点击创建隧道 - await driver.delayMs(200); - await driver.assertComponentExist(ON.text('创建对象')); - let createTunnel = await driver.findComponent(ON.text('创建对象')); - await driver.delayMs(200); - await createTunnel.click(); - await driver.delayMs(200); - hilog.info(DOMAIN, TAG, 'CreateTunnel_001 end'); - done(); - }); - - /** - * 启用VPN后开启隧道保护 - */ - it('StartTunnelProtect_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, 'StartTunnelProtect_001 start'); - let driver = Driver.create(); - await terminateAbility(); - await driver.delayMs(1000); - await startAbility(); - await driver.delayMs(1000); - // 点击启用VPN - await driver.assertComponentExist(ON.text('Start VPN')); - let startVpn = await driver.findComponent(ON.text('Start VPN')); - await driver.delayMs(200); - await startVpn.click(); - // 点击开启隧道保护 - await driver.delayMs(200); - await driver.assertComponentExist(ON.text('隧道保护')); - let protect = await driver.findComponent(ON.text('隧道保护')); - await driver.delayMs(200); - await protect.click(); - await driver.delayMs(200); - hilog.info(DOMAIN, TAG, 'StartTunnelProtect_001 end'); - done(); - }); - - /** - * 启用VPN后启动VPN连接 - */ - it('SetupVpn_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, 'SetupVpn_001 start'); - let driver = Driver.create(); - await terminateAbility(); - await driver.delayMs(1000); - await startAbility(); - await driver.delayMs(1000); - // 点击启用VPN - await driver.assertComponentExist(ON.text('Start VPN')); - let startVpn = await driver.findComponent(ON.text('Start VPN')); - await driver.delayMs(200); - await startVpn.click(); - // 点击开启vpn - await driver.delayMs(200); - await driver.assertComponentExist(ON.text('启动vpn')); - let setupVpn = await driver.findComponent(ON.text('启动vpn')); - await setupVpn.click(); - await driver.delayMs(200); - hilog.info(DOMAIN, TAG, 'SetupVpn_001 end'); - done(); - }); - - /** - * 停用VPN - */ - it('StopVpn_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, 'StopVpn_001 start'); - let driver = Driver.create(); - await terminateAbility(); - await driver.delayMs(1000); - await startAbility(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Stop VPN')); - let stopVpn = await driver.findComponent(ON.text('Stop VPN')); - await stopVpn.click(); - await driver.delayMs(200); - hilog.info(DOMAIN, TAG, 'StopVpn_001 end') - done(); - }); - - /** - * 关闭VPN连接 - */ - it('CloseVpn_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, 'CloseVpn_001 start'); - let driver = Driver.create(); - await terminateAbility(); - await driver.delayMs(1000); - await startAbility(); - await driver.delayMs(1000); - // 点击停用VPN - await driver.assertComponentExist(ON.text('Stop VPN')); - let stopVpn = await driver.findComponent(ON.text('Stop VPN')); - await stopVpn.click(); - // 点击关闭VPN - await driver.delayMs(200); - await driver.assertComponentExist(ON.text('关闭vpn')); - let closeVpn = await driver.findComponent(ON.text('关闭vpn')); - await closeVpn.click(); - await driver.delayMs(200); - hilog.info(DOMAIN, TAG, 'CloseVpn_001 end'); - done(); - }); - }); -} - -/** - * 拉起应用 - */ -async function startAbility() { - try { - let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - await abilityDelegator.startAbility({ - bundleName: "com.example.testvpnclient", - abilityName: "EntryAbility" - }); - } catch (err) { - hilog.info(DOMAIN, TAG, 'startAbility err'); - } -} - -/** - * 关闭应用 - */ -async function terminateAbility() { - try { - let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - let topAbility = await abilityDelegator.getCurrentTopAbility(); - await topAbility.context.terminateSelf(); - } catch (err) { - hilog.info(DOMAIN, TAG, 'terminateAbility err'); - } -} - +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import hilog from '@ohos.hilog'; +import { describe, it, expect } from '@ohos/hypium' +import { Driver, ON } from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +const TAG = '[Sample_VpnConnect]'; +const DOMAIN = 0xF811; + +let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +async function getResourceString(resource: Resource): Promise { + let manage = abilityDelegator.getAppContext().resourceManager + let text = await manage.getStringValue(resource) + return text +} + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 启动Ability + */ + it('startAbility_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, 'startAbility_001 start'); + let driver = Driver.create(); + await driver.delayMs(1000); + await startAbility(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'startAbility_001 end'); + done(); + }); + + /** + * 进入首页,标题显示正确 + */ + it('IndexPageEnter_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, 'IndexPageEnter_001 start'); + let driver: Driver = Driver.create(); + await terminateAbility(); + await driver.delayMs(1000); + await startAbility(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Toy VPN')); + let titleComponent = await driver.findComponent(ON.text('Toy VPN')); + let titleContent = await titleComponent.getText(); + await driver.delayMs(200); + expect('Toy VPN').assertEqual(titleContent); + await driver.delayMs(200); + hilog.info(DOMAIN, TAG, 'IndexPageEnter_001 end'); + done(); + }); + + /** + * 在主界面启用VPN + */ + it('StartVpn_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, 'StartVpn_001 start'); + let driver = Driver.create(); + await terminateAbility(); + await driver.delayMs(1000); + await startAbility(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Start VPN')); + let startVpn = await driver.findComponent(ON.text('Start VPN')); + await driver.delayMs(200); + await startVpn.click(); + await driver.delayMs(200); + hilog.info(DOMAIN, TAG, 'StartVpn_001 end'); + done(); + }); + + /** + * 在主界面启用VPN后,再创建隧道 + */ + it('CreateTunnel_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, 'CreateTunnel_001 start'); + let driver = Driver.create(); + await terminateAbility(); + await driver.delayMs(1000); + await startAbility(); + await driver.delayMs(1000); + // 点击启用VPN + await driver.assertComponentExist(ON.text('Start VPN')); + let startVpn = await driver.findComponent(ON.text('Start VPN')); + await driver.delayMs(200); + await startVpn.click(); + // 点击创建隧道 + await driver.delayMs(200); + await driver.assertComponentExist(ON.text('创建对象')); + let createTunnel = await driver.findComponent(ON.text('创建对象')); + await driver.delayMs(200); + await createTunnel.click(); + await driver.delayMs(200); + hilog.info(DOMAIN, TAG, 'CreateTunnel_001 end'); + done(); + }); + + /** + * 启用VPN后开启隧道保护 + */ + it('StartTunnelProtect_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, 'StartTunnelProtect_001 start'); + let driver = Driver.create(); + await terminateAbility(); + await driver.delayMs(1000); + await startAbility(); + await driver.delayMs(1000); + // 点击启用VPN + await driver.assertComponentExist(ON.text('Start VPN')); + let startVpn = await driver.findComponent(ON.text('Start VPN')); + await driver.delayMs(200); + await startVpn.click(); + // 点击开启隧道保护 + await driver.delayMs(200); + await driver.assertComponentExist(ON.text('隧道保护')); + let protect = await driver.findComponent(ON.text('隧道保护')); + await driver.delayMs(200); + await protect.click(); + await driver.delayMs(200); + hilog.info(DOMAIN, TAG, 'StartTunnelProtect_001 end'); + done(); + }); + + /** + * 启用VPN后启动VPN连接 + */ + it('SetupVpn_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, 'SetupVpn_001 start'); + let driver = Driver.create(); + await terminateAbility(); + await driver.delayMs(1000); + await startAbility(); + await driver.delayMs(1000); + // 点击启用VPN + await driver.assertComponentExist(ON.text('Start VPN')); + let startVpn = await driver.findComponent(ON.text('Start VPN')); + await driver.delayMs(200); + await startVpn.click(); + // 点击开启vpn + await driver.delayMs(200); + await driver.assertComponentExist(ON.text('启动vpn')); + let setupVpn = await driver.findComponent(ON.text('启动vpn')); + await setupVpn.click(); + await driver.delayMs(200); + hilog.info(DOMAIN, TAG, 'SetupVpn_001 end'); + done(); + }); + + /** + * 停用VPN + */ + it('StopVpn_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, 'StopVpn_001 start'); + let driver = Driver.create(); + await terminateAbility(); + await driver.delayMs(1000); + await startAbility(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Stop VPN')); + let stopVpn = await driver.findComponent(ON.text('Stop VPN')); + await stopVpn.click(); + await driver.delayMs(200); + hilog.info(DOMAIN, TAG, 'StopVpn_001 end') + done(); + }); + + /** + * 关闭VPN连接 + */ + it('CloseVpn_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, 'CloseVpn_001 start'); + let driver = Driver.create(); + await terminateAbility(); + await driver.delayMs(1000); + await startAbility(); + await driver.delayMs(1000); + // 点击停用VPN + await driver.assertComponentExist(ON.text('Stop VPN')); + let stopVpn = await driver.findComponent(ON.text('Stop VPN')); + await stopVpn.click(); + // 点击关闭VPN + await driver.delayMs(200); + await driver.assertComponentExist(ON.text('关闭vpn')); + let closeVpn = await driver.findComponent(ON.text('关闭vpn')); + await closeVpn.click(); + await driver.delayMs(200); + hilog.info(DOMAIN, TAG, 'CloseVpn_001 end'); + done(); + }); + }); +} + +/** + * 拉起应用 + */ +async function startAbility() { + try { + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + await abilityDelegator.startAbility({ + bundleName: "com.example.testvpnclient", + abilityName: "EntryAbility" + }); + } catch (err) { + hilog.info(DOMAIN, TAG, 'startAbility err'); + } +} + +/** + * 关闭应用 + */ +async function terminateAbility() { + try { + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let topAbility = await abilityDelegator.getCurrentTopAbility(); + await topAbility.context.terminateSelf(); + } catch (err) { + hilog.info(DOMAIN, TAG, 'terminateAbility err'); + } +} + diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/module.json5 b/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/module.json5 index 8a85c47aa8..12caf23cd2 100644 --- a/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* -* Copyright (c) 2023 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* +* Copyright (c) 2023 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/Connectivity/VPN/hvigor/hvigor-config.json5 b/code/BasicFeature/Connectivity/VPN/hvigor/hvigor-config.json5 index ccfdcf1340..f6cf598454 100644 --- a/code/BasicFeature/Connectivity/VPN/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Connectivity/VPN/hvigor/hvigor-config.json5 @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "hvigorVersion": "3.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.2" - }, - "execution": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } +/* + * Copyright (c) 2023 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. + */ + +{ + "hvigorVersion": "3.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.2" + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/VPN/oh-package.json5 b/code/BasicFeature/Connectivity/VPN/oh-package.json5 index 3c30215fd0..427c512f09 100644 --- a/code/BasicFeature/Connectivity/VPN/oh-package.json5 +++ b/code/BasicFeature/Connectivity/VPN/oh-package.json5 @@ -1,28 +1,28 @@ -/* -* Copyright (c) 2023 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": "testvpnclient", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.6" - } -} +/* +* Copyright (c) 2023 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": "testvpnclient", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.6" + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/.gitignore b/code/BasicFeature/DFX/AppRecovery/.gitignore index b031e2b2be..5a13775085 100644 --- a/code/BasicFeature/DFX/AppRecovery/.gitignore +++ b/code/BasicFeature/DFX/AppRecovery/.gitignore @@ -1,12 +1,12 @@ -/node_modules -/local.properties -/.idea -**/build -/.hvigor -.cxx -/.clangd -/.clang-format -/.clang-tidy -/oh-package-lock.json5 -/package-lock.json -/entry/package-lock.json +/node_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +/oh-package-lock.json5 +/package-lock.json +/entry/package-lock.json diff --git a/code/BasicFeature/DFX/AppRecovery/AppScope/app.json5 b/code/BasicFeature/DFX/AppRecovery/AppScope/app.json5 index 66eeccf56c..bf1a3d1a33 100644 --- a/code/BasicFeature/DFX/AppRecovery/AppScope/app.json5 +++ b/code/BasicFeature/DFX/AppRecovery/AppScope/app.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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.recovery", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name", - "distributedNotificationEnabled": true - } -} +/* + * Copyright (c) 2023 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.recovery", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/AppScope/resources/base/element/string.json b/code/BasicFeature/DFX/AppRecovery/AppScope/resources/base/element/string.json index 5d97eb3a83..21bb9f4985 100644 --- a/code/BasicFeature/DFX/AppRecovery/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/DFX/AppRecovery/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AppRecoverySample" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AppRecoverySample" + } + ] +} diff --git a/code/BasicFeature/DFX/AppRecovery/README_zh.md b/code/BasicFeature/DFX/AppRecovery/README_zh.md index 02d787035e..f90c553c5a 100644 --- a/code/BasicFeature/DFX/AppRecovery/README_zh.md +++ b/code/BasicFeature/DFX/AppRecovery/README_zh.md @@ -1,128 +1,128 @@ -# 应用故障恢复 - -### 介绍 -本示例展示了在应用中如何适配故障恢复相关接口。 - -样例包含以下场景:\ -一.单Ability自动恢复 \ -在EntryAbility的故障触发页面触发故障,自动重启回到故障触发页面。 - -二.多Ability自动恢复 \ -应用中启动了EntryAbility和SecondAbility,在第二个启动的SecondAbility的故障触发页面触发故障。 \ -自动重启到SecondAbility的故障触发页面。 \ -从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,并恢复页面上点击次数信息。 - -三.多Ability主动恢复 \ -应用中启动了EntryAbility和SecondAbility,在第二个启动的SecondAbility的故障触发页面触发故障。 \ -重启时启动RecoveryAbility,让使用者选择具体启动的Ability。 - -四.Ability后台强制终止恢复 \ -应用中启动了EntryAbility和SecondAbility,并切入后台。\ -系统回收该应用,再次拉起时能够恢复先前的状态。 - -相关概念: \ -故障:指的是应用处于无法提供服务的状态,如卡死以及崩溃。 \ -系统强制终止:指的是由于系统或者应用的原因,系统强制终止正在运行的应用进程,并回收资源的操作。 - -### 效果预览 -|首页|故障触发页面| -|---|---| -|![home](screenshots/devices/zh/entry_page.jpeg)|![fault](screenshots/devices/zh/fault_trigger_page.jpeg)| - -使用说明 - -一.单Ability自动恢复 \ -点击首页点击``跳转到故障触发页面`` \ -在故障触发页面点击按钮``点击``,再点击``保存当前Ability状态``以及``触发JsError``。 \ -以上场景预期:\ -能够回到``故障触发页面``页面,页面上的点击次数与触发保存状态时的一致。 - -二.多Ability自动恢复 \ -点击首页点击跳转到``故障触发页面`` \ -在``故障触发页面``点击``启动SecondAbility`` -点击首页点击``跳转到故障触发页面`` \ -在故障触发页面点击按钮``点击``,再点击``保存当前Ability状态``以及``触发JsError``。 \ -以上场景预期:\ -立即回到SecondAbility的故障触发页面,并恢复页面的点击次数信息。\ -从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,页面上的点击次数与触发保存状态时的一致。 - -三.多Ability主动恢复 \ -点击首页点击跳转到``故障触发页面`` \ -在``故障触发页面``点击``启动SecondAbility`` -在SecondAbility的故障触发页面点击设置重启Ability。 \ -在SecondAbility的故障触发页面点击``触发JsError``。 \ -以上场景预期:\ -重启时启动RecoveryAbility。 - -四.Ability后台强制终止恢复 \ -点击首页点击跳转到``故障触发页面`` \ -在``故障触发页面``点击``启动SecondAbility`` -在SecondAbility的故障触发页面点击Counter,点击``保存当前Ability状态``,并切入后台 \ -使用kill命令强制终止当前应用 \ -以上场景预期:\ -从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,并恢复页面上的点击次数信息。\ -从任务管理中将SecondAbility切回前台,预期能回到故障触发页面,并恢复页面上的点击次数信息。 - -为避免反复拉起,两次测试的间隔至少为60秒(自动拉起的间隔为60秒)。 -### 工程目录 -``` -entry/src/main/ -├── cpp // 触发Native卡死代码 -│   ├── CMakeLists.txt -│   ├── hello.cpp -│   └── types -│   └── libentry -│   ├── index.d.ts -│   └── oh-package.json5 -├── ets -│   ├── ability -│   │   ├── EntryAbility.ets // 测试入口Ability -│   │   ├── RecoveryAbility.ets // 恢复引导Ability -│   │   └── SecondAbility.ets // 测试第二Ability -│   ├── app -│   │   └── MyAbilityStage.ets // 用于初始化appRecovery的配置 -│   ├── common -│   │   ├── Logger.ts // 日志 -│   │   └── TitleBar.ets // 标题 -│   └── pages -│   ├── FaultTriggerPage.ets // 故障触发页面 -│   ├── Index.ets // 首页 -│   └── RecoveryPage.ets // 恢复页面 -``` - -### 具体实现 -* 使能应用恢复功能,源码参考:[MyAbilityStage.ets](entry/src/main/ets/app/MyAbilityStage.ets) - * 在``onCreate``中 调用[appRecovery](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/dfx/apprecovery-guidelines.md)接口使能功能 -* 配置支持恢复的Ability,源码参考:[module.json5](entry/src/main/module.json5) - * 在``Ability``的节点中增加``recoverable``的配置,并设置为``true`` -* 实现恢复功能,源码参考:[EntryAbility.ets](entry/src/main/ets/ability/EntryAbility.ets) - * 在``onSaveState``中保存用于恢复的数据 - * 在``onCreate``的``want``参数中恢复所需要的数据 - -### 相关权限 -不涉及 - -### 依赖 -无 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568。 - -2.本示例为Stage模型,支持API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0 Release) - -3.本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。 - -### 下载 - -给出单独下载本工程的命令,在代码中替换工程目录并以/结尾,如下面示例中的 **code/BasicFeature/DFX/AppRecovery/**,示例如下: - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/BasicFeature/DFX/AppRecovery/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` +# 应用故障恢复 + +### 介绍 +本示例展示了在应用中如何适配故障恢复相关接口。 + +样例包含以下场景:\ +一.单Ability自动恢复 \ +在EntryAbility的故障触发页面触发故障,自动重启回到故障触发页面。 + +二.多Ability自动恢复 \ +应用中启动了EntryAbility和SecondAbility,在第二个启动的SecondAbility的故障触发页面触发故障。 \ +自动重启到SecondAbility的故障触发页面。 \ +从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,并恢复页面上点击次数信息。 + +三.多Ability主动恢复 \ +应用中启动了EntryAbility和SecondAbility,在第二个启动的SecondAbility的故障触发页面触发故障。 \ +重启时启动RecoveryAbility,让使用者选择具体启动的Ability。 + +四.Ability后台强制终止恢复 \ +应用中启动了EntryAbility和SecondAbility,并切入后台。\ +系统回收该应用,再次拉起时能够恢复先前的状态。 + +相关概念: \ +故障:指的是应用处于无法提供服务的状态,如卡死以及崩溃。 \ +系统强制终止:指的是由于系统或者应用的原因,系统强制终止正在运行的应用进程,并回收资源的操作。 + +### 效果预览 +|首页|故障触发页面| +|---|---| +|![home](screenshots/devices/zh/entry_page.jpeg)|![fault](screenshots/devices/zh/fault_trigger_page.jpeg)| + +使用说明 + +一.单Ability自动恢复 \ +点击首页点击``跳转到故障触发页面`` \ +在故障触发页面点击按钮``点击``,再点击``保存当前Ability状态``以及``触发JsError``。 \ +以上场景预期:\ +能够回到``故障触发页面``页面,页面上的点击次数与触发保存状态时的一致。 + +二.多Ability自动恢复 \ +点击首页点击跳转到``故障触发页面`` \ +在``故障触发页面``点击``启动SecondAbility`` +点击首页点击``跳转到故障触发页面`` \ +在故障触发页面点击按钮``点击``,再点击``保存当前Ability状态``以及``触发JsError``。 \ +以上场景预期:\ +立即回到SecondAbility的故障触发页面,并恢复页面的点击次数信息。\ +从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,页面上的点击次数与触发保存状态时的一致。 + +三.多Ability主动恢复 \ +点击首页点击跳转到``故障触发页面`` \ +在``故障触发页面``点击``启动SecondAbility`` +在SecondAbility的故障触发页面点击设置重启Ability。 \ +在SecondAbility的故障触发页面点击``触发JsError``。 \ +以上场景预期:\ +重启时启动RecoveryAbility。 + +四.Ability后台强制终止恢复 \ +点击首页点击跳转到``故障触发页面`` \ +在``故障触发页面``点击``启动SecondAbility`` +在SecondAbility的故障触发页面点击Counter,点击``保存当前Ability状态``,并切入后台 \ +使用kill命令强制终止当前应用 \ +以上场景预期:\ +从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,并恢复页面上的点击次数信息。\ +从任务管理中将SecondAbility切回前台,预期能回到故障触发页面,并恢复页面上的点击次数信息。 + +为避免反复拉起,两次测试的间隔至少为60秒(自动拉起的间隔为60秒)。 +### 工程目录 +``` +entry/src/main/ +├── cpp // 触发Native卡死代码 +│   ├── CMakeLists.txt +│   ├── hello.cpp +│   └── types +│   └── libentry +│   ├── index.d.ts +│   └── oh-package.json5 +├── ets +│   ├── ability +│   │   ├── EntryAbility.ets // 测试入口Ability +│   │   ├── RecoveryAbility.ets // 恢复引导Ability +│   │   └── SecondAbility.ets // 测试第二Ability +│   ├── app +│   │   └── MyAbilityStage.ets // 用于初始化appRecovery的配置 +│   ├── common +│   │   ├── Logger.ts // 日志 +│   │   └── TitleBar.ets // 标题 +│   └── pages +│   ├── FaultTriggerPage.ets // 故障触发页面 +│   ├── Index.ets // 首页 +│   └── RecoveryPage.ets // 恢复页面 +``` + +### 具体实现 +* 使能应用恢复功能,源码参考:[MyAbilityStage.ets](entry/src/main/ets/app/MyAbilityStage.ets) + * 在``onCreate``中 调用[appRecovery](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/dfx/apprecovery-guidelines.md)接口使能功能 +* 配置支持恢复的Ability,源码参考:[module.json5](entry/src/main/module.json5) + * 在``Ability``的节点中增加``recoverable``的配置,并设置为``true`` +* 实现恢复功能,源码参考:[EntryAbility.ets](entry/src/main/ets/ability/EntryAbility.ets) + * 在``onSaveState``中保存用于恢复的数据 + * 在``onCreate``的``want``参数中恢复所需要的数据 + +### 相关权限 +不涉及 + +### 依赖 +无 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568。 + +2.本示例为Stage模型,支持API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0 Release) + +3.本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。 + +### 下载 + +给出单独下载本工程的命令,在代码中替换工程目录并以/结尾,如下面示例中的 **code/BasicFeature/DFX/AppRecovery/**,示例如下: + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/BasicFeature/DFX/AppRecovery/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` diff --git a/code/BasicFeature/DFX/AppRecovery/build-profile.json5 b/code/BasicFeature/DFX/AppRecovery/build-profile.json5 index 390b41a944..947c318515 100644 --- a/code/BasicFeature/DFX/AppRecovery/build-profile.json5 +++ b/code/BasicFeature/DFX/AppRecovery/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" - } - ], - "signingConfigs": [] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "runtimeOS": "OpenHarmony" + } + ], + "signingConfigs": [] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/.gitignore b/code/BasicFeature/DFX/AppRecovery/entry/.gitignore index 4a65948351..5a6ba80fa3 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/.gitignore +++ b/code/BasicFeature/DFX/AppRecovery/entry/.gitignore @@ -1,4 +1,4 @@ -/node_modules -/.preview -/build +/node_modules +/.preview +/build /.cxx \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/build-profile.json5 b/code/BasicFeature/DFX/AppRecovery/entry/build-profile.json5 index 4822212a55..71efbba6e5 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/build-profile.json5 +++ b/code/BasicFeature/DFX/AppRecovery/entry/build-profile.json5 @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2023 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": "", - "abiFilters": [ - "armeabi-v7a", - "arm64-v8a" - ], - "cppFlags": "", - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": "", + "abiFilters": [ + "armeabi-v7a", + "arm64-v8a" + ], + "cppFlags": "", + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/hvigorfile.ts b/code/BasicFeature/DFX/AppRecovery/entry/hvigorfile.ts index c57c77181d..80e4ec5b81 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/hvigorfile.ts +++ b/code/BasicFeature/DFX/AppRecovery/entry/hvigorfile.ts @@ -1,2 +1,2 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -export { hapTasks } from '@ohos/hvigor-ohos-plugin'; +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { hapTasks } from '@ohos/hvigor-ohos-plugin'; diff --git a/code/BasicFeature/DFX/AppRecovery/entry/oh-package.json5 b/code/BasicFeature/DFX/AppRecovery/entry/oh-package.json5 index 92a9bafefb..3e99258f08 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/oh-package.json5 +++ b/code/BasicFeature/DFX/AppRecovery/entry/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "ISC", - "devDependencies": {}, - "name": "entry", - "description": "app recovery sample", - "repository": {}, - "version": "1.0.0", - "dependencies": {} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "description": "app recovery sample", + "repository": {}, + "version": "1.0.0", + "dependencies": {} } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/CMakeLists.txt index 8825d37322..0304a9904c 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/CMakeLists.txt +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/CMakeLists.txt @@ -1,24 +1,24 @@ -# Copyright (c) 2023 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. -# -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.4.1) -project(MyApplication6) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED hello.cpp) +# Copyright (c) 2023 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. +# +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(MyApplication6) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED hello.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/hello.cpp b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/hello.cpp index 4b1c45621c..32c697284e 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/hello.cpp +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/hello.cpp @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 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 -#include "napi/native_api.h" - -static napi_value DeadLoop(napi_env env, napi_callback_info info) -{ - while (true) { - printf("aaa\n"); - } - return 0; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor functions[] = { - { "deadLoop", nullptr, DeadLoop, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(functions) / sizeof(functions[0]), functions); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2023 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 +#include "napi/native_api.h" + +static napi_value DeadLoop(napi_env env, napi_callback_info info) +{ + while (true) { + printf("aaa\n"); + } + return 0; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor functions[] = { + { "deadLoop", nullptr, DeadLoop, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(functions) / sizeof(functions[0]), functions); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/index.d.ts b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/index.d.ts index 50ede76b5d..7811a521b4 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2023 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. - */ - +/* + * Copyright (c) 2023 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 deadLoop: () => number; \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/oh-package.json5 index 982d2e7abb..58bef51c5d 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "types": "./index.d.ts", - "name": "libentry.so", - "description": "", - "version": "" +/* + * Copyright (c) 2023 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. + */ + +{ + "types": "./index.d.ts", + "name": "libentry.so", + "description": "", + "version": "" } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/EntryAbility.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/EntryAbility.ets index 5f81cef6f1..0c92955e97 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/EntryAbility.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/EntryAbility.ets @@ -1,93 +1,93 @@ -/* - * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery'; -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import Window from '@ohos.window'; - -import Logger from '../common/Logger'; -import { CurActiveAbility } from '../common/CurActiveAbility'; - -const TAG: string = 'EntryAbility'; - -export default class EntryAbility extends UIAbility { - isRecoverLaunch: boolean = false; - storage: LocalStorage = new LocalStorage(); - - // Read previous saved status from want if we are launched by appRecovery - restoreLocalStorage(want: Want): void { - Logger.info(TAG, "RestoreLocalStorage String:${want.parameters['Page1Str']} Counter:${want.parameters['Page2Counter']}"); - if (want.parameters !== undefined) { - this.storage.setOrCreate('FaultTriggerPageString', want.parameters['FaultTriggerPageString'] as string); - this.storage.setOrCreate('FaultTriggerPageCounter', want.parameters['FaultTriggerPageCounter'] as number); - } - - } - - onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void { - Logger.info(TAG, 'onCreate Want:${JSON.stringify(want)} launchParam: ${JSON.stringify(launchParam)}'); - this.isRecoverLaunch = (launchParam.launchReason == AbilityConstant.LaunchReason.APP_RECOVERY); - this.storage.setOrCreate('CurrentAbilityName', 'EntryAbility'); - this.storage.setOrCreate('launchReason', launchParam.launchReason.toString()); - this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString()); - if (this.isRecoverLaunch) { - // savedState is in wantParams - this.restoreLocalStorage(want); - this.context.restoreWindowStage(this.storage); - } - } - - onDestroy(): void { - Logger.info(TAG, 'onDestroy'); - } - - onWindowStageCreate(windowStage: Window.WindowStage): void { - Logger.info(TAG, 'onWindowStageCreate'); - // Share storage between pages and current ability - windowStage.loadContent('pages/Index', this.storage, (err, data): void => { - if (err.code) { - Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}'); - return; - } - }); - } - - onWindowStageDestroy(): void { - Logger.info(TAG, 'onWindowStageDestroy'); - } - - onForeground(): void { - Logger.info(TAG, 'onForeground'); - CurActiveAbility.GetInstance().SetGlobalAbility(this); - } - - onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult { - Logger.info(TAG, 'onSaveState'); - let string = this.storage.get('FaultTriggerPageString'); - let counter = this.storage.get('FaultTriggerPageCounter'); - wantParam['FaultTriggerPageString'] = string ?? 'Empty'; - wantParam['FaultTriggerPageCounter'] = counter as number; - Logger.info(TAG, 'SavedText:${string} SavedCounter:${counter}'); - return AbilityConstant.OnSaveResult.ALL_AGREE; - } - - onBackground(): void { - Logger.info(TAG, 'onBackground'); - // save state when background - appRecovery.saveAppState(this.context); - } -} +/* + * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import Window from '@ohos.window'; + +import Logger from '../common/Logger'; +import { CurActiveAbility } from '../common/CurActiveAbility'; + +const TAG: string = 'EntryAbility'; + +export default class EntryAbility extends UIAbility { + isRecoverLaunch: boolean = false; + storage: LocalStorage = new LocalStorage(); + + // Read previous saved status from want if we are launched by appRecovery + restoreLocalStorage(want: Want): void { + Logger.info(TAG, "RestoreLocalStorage String:${want.parameters['Page1Str']} Counter:${want.parameters['Page2Counter']}"); + if (want.parameters !== undefined) { + this.storage.setOrCreate('FaultTriggerPageString', want.parameters['FaultTriggerPageString'] as string); + this.storage.setOrCreate('FaultTriggerPageCounter', want.parameters['FaultTriggerPageCounter'] as number); + } + + } + + onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void { + Logger.info(TAG, 'onCreate Want:${JSON.stringify(want)} launchParam: ${JSON.stringify(launchParam)}'); + this.isRecoverLaunch = (launchParam.launchReason == AbilityConstant.LaunchReason.APP_RECOVERY); + this.storage.setOrCreate('CurrentAbilityName', 'EntryAbility'); + this.storage.setOrCreate('launchReason', launchParam.launchReason.toString()); + this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString()); + if (this.isRecoverLaunch) { + // savedState is in wantParams + this.restoreLocalStorage(want); + this.context.restoreWindowStage(this.storage); + } + } + + onDestroy(): void { + Logger.info(TAG, 'onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage): void { + Logger.info(TAG, 'onWindowStageCreate'); + // Share storage between pages and current ability + windowStage.loadContent('pages/Index', this.storage, (err, data): void => { + if (err.code) { + Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}'); + return; + } + }); + } + + onWindowStageDestroy(): void { + Logger.info(TAG, 'onWindowStageDestroy'); + } + + onForeground(): void { + Logger.info(TAG, 'onForeground'); + CurActiveAbility.GetInstance().SetGlobalAbility(this); + } + + onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult { + Logger.info(TAG, 'onSaveState'); + let string = this.storage.get('FaultTriggerPageString'); + let counter = this.storage.get('FaultTriggerPageCounter'); + wantParam['FaultTriggerPageString'] = string ?? 'Empty'; + wantParam['FaultTriggerPageCounter'] = counter as number; + Logger.info(TAG, 'SavedText:${string} SavedCounter:${counter}'); + return AbilityConstant.OnSaveResult.ALL_AGREE; + } + + onBackground(): void { + Logger.info(TAG, 'onBackground'); + // save state when background + appRecovery.saveAppState(this.context); + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/RecoveryAbility.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/RecoveryAbility.ets index da3abb03d5..adea24140c 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/RecoveryAbility.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/RecoveryAbility.ets @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import Window from '@ohos.window' -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import Want from '@ohos.app.ability.Want'; - -import Logger from '../common/Logger' -import { CurActiveAbility } from '../common/CurActiveAbility'; - -const TAG: string = 'SecondAbility'; - -export default class RecoveryAbility extends UIAbility { - storage: LocalStorage = new LocalStorage(); - - onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void { - Logger.info(TAG, 'onCreate'); - this.storage.setOrCreate('launchReason', launchParam.launchReason.toString()); - this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString()); - if (want.parameters !== undefined) { - AppStorage.SetOrCreate('RecoverAbility', want.parameters['RecoverAbility'] as string); - } - } - - onDestroy(): void { - Logger.info(TAG, 'onDestroy'); - } - - onWindowStageCreate(windowStage: Window.WindowStage):void { - Logger.info(TAG, 'onWindowStageCreate'); - windowStage.loadContent('pages/RecoveryPage', this.storage, (err, data) => { - if (err.code) { - Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}}'); - return; - } - }); - } - - onWindowStageDestroy(): void { - Logger.info(TAG, 'onWindowStageDestroy'); - } - - onForeground(): void { - Logger.info(TAG, 'onForeground'); - CurActiveAbility.GetInstance().SetGlobalAbility(this); - } - - onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult { - // No need to save state - Logger.info(TAG, 'onSaveState'); - return AbilityConstant.OnSaveResult.ALL_REJECT; - } - - onBackground(): void { - // Ability has back to background - Logger.info(TAG, 'onBackground'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import Window from '@ohos.window' +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import Want from '@ohos.app.ability.Want'; + +import Logger from '../common/Logger' +import { CurActiveAbility } from '../common/CurActiveAbility'; + +const TAG: string = 'SecondAbility'; + +export default class RecoveryAbility extends UIAbility { + storage: LocalStorage = new LocalStorage(); + + onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void { + Logger.info(TAG, 'onCreate'); + this.storage.setOrCreate('launchReason', launchParam.launchReason.toString()); + this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString()); + if (want.parameters !== undefined) { + AppStorage.SetOrCreate('RecoverAbility', want.parameters['RecoverAbility'] as string); + } + } + + onDestroy(): void { + Logger.info(TAG, 'onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage):void { + Logger.info(TAG, 'onWindowStageCreate'); + windowStage.loadContent('pages/RecoveryPage', this.storage, (err, data) => { + if (err.code) { + Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}}'); + return; + } + }); + } + + onWindowStageDestroy(): void { + Logger.info(TAG, 'onWindowStageDestroy'); + } + + onForeground(): void { + Logger.info(TAG, 'onForeground'); + CurActiveAbility.GetInstance().SetGlobalAbility(this); + } + + onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult { + // No need to save state + Logger.info(TAG, 'onSaveState'); + return AbilityConstant.OnSaveResult.ALL_REJECT; + } + + onBackground(): void { + // Ability has back to background + Logger.info(TAG, 'onBackground'); + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/SecondAbility.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/SecondAbility.ets index ed13cc61fb..2754443218 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/SecondAbility.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/SecondAbility.ets @@ -1,90 +1,90 @@ -/* - * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery'; -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import Window from '@ohos.window'; - -import Logger from '../common/Logger'; -import { CurActiveAbility } from '../common/CurActiveAbility'; - -const TAG: string = 'SecondAbility'; - -export default class SecondAbility extends UIAbility { - isRecoverLaunch: boolean = false; - storage: LocalStorage = new LocalStorage(); - - // Read previous saved status from want if we are launched by appRecovery - restoreLocalStorage(want: Want) : void { - if (want.parameters !== undefined) { - this.storage.setOrCreate('FaultTriggerPageString', want.parameters['FaultTriggerPageString'] as string); - this.storage.setOrCreate('FaultTriggerPageCounter', want.parameters['FaultTriggerPageCounter'] as number); - } - } - - onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void { - Logger.info(TAG, 'onCreate'); - this.storage.setOrCreate('CurrentAbilityName', 'SecondAbility'); - this.storage.setOrCreate('launchReason', launchParam.launchReason.toString()); - this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString()); - this.isRecoverLaunch = (launchParam.launchReason == AbilityConstant.LaunchReason.APP_RECOVERY); - if (this.isRecoverLaunch) { - // savedState is in wantParams - this.restoreLocalStorage(want); - this.context.restoreWindowStage(this.storage); - } - } - - onDestroy(): void { - Logger.info(TAG, 'onDestroy'); - } - - onWindowStageCreate(windowStage: Window.WindowStage): void { - Logger.info(TAG, 'onWindowStageCreate'); - // Share storage between pages and current ability - windowStage.loadContent('pages/Index', this.storage, (err, data) => { - if (err.code) { - Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}}'); - return; - } - }); - } - - onWindowStageDestroy(): void { - Logger.info(TAG, 'onWindowStageDestroy'); - } - - onForeground(): void { - Logger.info(TAG, 'onForeground'); - CurActiveAbility.GetInstance().SetGlobalAbility(this); - } - - onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult { - Logger.info(TAG, 'onSaveState'); - let string = this.storage.get('FaultTriggerPageString'); - let counter = this.storage.get('FaultTriggerPageCounter'); - wantParam['FaultTriggerPageString'] = string ?? 'Empty'; - wantParam['FaultTriggerPageCounter'] = counter as number; - return AbilityConstant.OnSaveResult.ALL_AGREE; - } - - onBackground(): void { - Logger.info(TAG, 'onBackground'); - // save state when background - appRecovery.saveAppState(this.context); - } -} +/* + * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import Window from '@ohos.window'; + +import Logger from '../common/Logger'; +import { CurActiveAbility } from '../common/CurActiveAbility'; + +const TAG: string = 'SecondAbility'; + +export default class SecondAbility extends UIAbility { + isRecoverLaunch: boolean = false; + storage: LocalStorage = new LocalStorage(); + + // Read previous saved status from want if we are launched by appRecovery + restoreLocalStorage(want: Want) : void { + if (want.parameters !== undefined) { + this.storage.setOrCreate('FaultTriggerPageString', want.parameters['FaultTriggerPageString'] as string); + this.storage.setOrCreate('FaultTriggerPageCounter', want.parameters['FaultTriggerPageCounter'] as number); + } + } + + onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void { + Logger.info(TAG, 'onCreate'); + this.storage.setOrCreate('CurrentAbilityName', 'SecondAbility'); + this.storage.setOrCreate('launchReason', launchParam.launchReason.toString()); + this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString()); + this.isRecoverLaunch = (launchParam.launchReason == AbilityConstant.LaunchReason.APP_RECOVERY); + if (this.isRecoverLaunch) { + // savedState is in wantParams + this.restoreLocalStorage(want); + this.context.restoreWindowStage(this.storage); + } + } + + onDestroy(): void { + Logger.info(TAG, 'onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage): void { + Logger.info(TAG, 'onWindowStageCreate'); + // Share storage between pages and current ability + windowStage.loadContent('pages/Index', this.storage, (err, data) => { + if (err.code) { + Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}}'); + return; + } + }); + } + + onWindowStageDestroy(): void { + Logger.info(TAG, 'onWindowStageDestroy'); + } + + onForeground(): void { + Logger.info(TAG, 'onForeground'); + CurActiveAbility.GetInstance().SetGlobalAbility(this); + } + + onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult { + Logger.info(TAG, 'onSaveState'); + let string = this.storage.get('FaultTriggerPageString'); + let counter = this.storage.get('FaultTriggerPageCounter'); + wantParam['FaultTriggerPageString'] = string ?? 'Empty'; + wantParam['FaultTriggerPageCounter'] = counter as number; + return AbilityConstant.OnSaveResult.ALL_AGREE; + } + + onBackground(): void { + Logger.info(TAG, 'onBackground'); + // save state when background + appRecovery.saveAppState(this.context); + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/app/MyAbilityStage.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/app/MyAbilityStage.ets index 08c38d3971..95880a8431 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/app/MyAbilityStage.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/app/MyAbilityStage.ets @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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 AbilityStage from '@ohos.app.ability.AbilityStage'; -import appRecovery from '@ohos.app.ability.appRecovery'; -import Logger from '../common/Logger' -const TAG: string = 'MyAbilityStage' -export default class MyAbilityStage extends AbilityStage { - onCreate() { - Logger.info(TAG, 'onCreate') - // global switch for appRecovery function in current package - appRecovery.enableAppRecovery(); - } +/* + * Copyright (c) 2023 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 AbilityStage from '@ohos.app.ability.AbilityStage'; +import appRecovery from '@ohos.app.ability.appRecovery'; +import Logger from '../common/Logger' +const TAG: string = 'MyAbilityStage' +export default class MyAbilityStage extends AbilityStage { + onCreate() { + Logger.info(TAG, 'onCreate') + // global switch for appRecovery function in current package + appRecovery.enableAppRecovery(); + } } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/CurActiveAbility.ts b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/CurActiveAbility.ts index 8e98759606..253aa9ed5e 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/CurActiveAbility.ts +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/CurActiveAbility.ts @@ -1,36 +1,36 @@ -/** - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; - -export class CurActiveAbility extends UIAbility { - private static instance: CurActiveAbility; - private _object : Object; - - public static GetInstance(): CurActiveAbility { - if (!CurActiveAbility.instance) { - CurActiveAbility.instance = new CurActiveAbility(); - } - return CurActiveAbility.instance; - } - - SetGlobalAbility(object: Object): void{ - this._object = object; - } - - GetGlobalAbility(): UIAbility { - return this._object as UIAbility; - } +/** + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; + +export class CurActiveAbility extends UIAbility { + private static instance: CurActiveAbility; + private _object : Object; + + public static GetInstance(): CurActiveAbility { + if (!CurActiveAbility.instance) { + CurActiveAbility.instance = new CurActiveAbility(); + } + return CurActiveAbility.instance; + } + + SetGlobalAbility(object: Object): void{ + this._object = object; + } + + GetGlobalAbility(): UIAbility { + return this._object as UIAbility; + } } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/ResUtil.ts b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/ResUtil.ts index d25871d66e..789e0158c4 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/ResUtil.ts +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/ResUtil.ts @@ -1,29 +1,29 @@ -/** - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import resourceManager from '@ohos.resourceManager'; -import Logger from './Logger'; -import { CurActiveAbility } from './CurActiveAbility'; - -export class ResUtil { - async getString(id): Promise { - let resourceMgr = CurActiveAbility.GetInstance().GetGlobalAbility().context.resourceManager; - return resourceMgr.getStringValue(id); - } -} - -let resUtil = new ResUtil(); - -export default resUtil as ResUtil; +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import resourceManager from '@ohos.resourceManager'; +import Logger from './Logger'; +import { CurActiveAbility } from './CurActiveAbility'; + +export class ResUtil { + async getString(id): Promise { + let resourceMgr = CurActiveAbility.GetInstance().GetGlobalAbility().context.resourceManager; + return resourceMgr.getStringValue(id); + } +} + +let resUtil = new ResUtil(); + +export default resUtil as ResUtil; diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/FaultTriggerPage.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/FaultTriggerPage.ets index 5d0c57b05c..2dda66cb3e 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/FaultTriggerPage.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/FaultTriggerPage.ets @@ -1,315 +1,315 @@ -/* - * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery'; -import testNapi from 'libentry.so'; -import ResUtil from '../common/ResUtil'; -import { CurActiveAbility } from '../common/CurActiveAbility'; - -@Entry -@Component -struct FaultTriggerPage { - storage = LocalStorage.GetShared(); - @State counter: number = 0; - @State callerAbility: string = ''; - @State launchReason: string = ''; - @State lastExitReason: string = ''; - @State curAbilitySaveState: string = ''; - @State allAbilitySaveState: string = ''; - @State setRecoveryAbility: string = ''; - - aboutToAppear() { - this.counter = this.storage.get('FaultTriggerPageCounter') ?? 0; - this.callerAbility = this.storage.get('CurrentAbilityName') ?? 'UnknownCallingAbility'; - this.launchReason = this.storage.get('launchReason') ?? 'Unknown'; - this.lastExitReason = this.storage.get('lastExitReason') ?? 'Unknown'; - ResUtil.getString($r('app.string.save_state').id).then((value: string) => this.curAbilitySaveState = value); - ResUtil.getString($r('app.string.save_state').id).then((value: string) => this.allAbilitySaveState = value); - ResUtil.getString($r('app.string.set_config').id).then((value: string) => this.setRecoveryAbility = value); - } - - doHeavyWork() : void { - let i = 0; - while (i < 1000000000) { - i++; - let j = 0; - while (j < 1000000000) { - j++; - let k = 0; - while (k < 1000000000) { - k++; - } - } - } - } - - build() { - Column() { - Text(this.callerAbility) - .fontSize('30fp') - .fontWeight(FontWeight.Bold) - .padding({ left: '24vp', right: '24vp', top: '7vp', bottom: '8vp' }) - .margin({ top: '14vp' }) - .textAlign(TextAlign.Start) - .height('56vp') - .width('100%') - .fontColor($r('app.color.text_grey')); - - List() { - ListItem() { - Column() { - Row() { - Text($r('app.string.launch_reason')).fontSize('16fp').width('86%'); - Text('0' + this.launchReason) - .fontSize('14fp') - .width('14%') - .fontColor($r('app.color.text_grey')) - .opacity(0.6) - .textAlign(TextAlign.End); - } - } - }.width('100%').height('48vp').align(Alignment.Center); - - ListItem() { - Column() { - Row() { - Text($r('app.string.last_exit_reason')).fontSize('16fp').width('86%'); - Text('0' + this.lastExitReason) - .fontSize('14fp') - .width('14%') - .fontColor($r('app.color.text_grey')) - .opacity(0.6) - .textAlign(TextAlign.End); - } - } - }.width('100%').height('48vp').align(Alignment.Center); - } - .alignListItem(ListItemAlign.Center) - .margin({ left: '12vp', right: '12vp', top: '8vp' }) - .width('93.3%') - .borderRadius('24vp') - .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) - .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) - .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') }); - - List() { - ListItem() { - Column() { - Row() { - Row() { - Text($r('app.string.click_counter')).fontSize('16fp') - Text(this.counter.toString()).fontSize('16fp') - }.align(Alignment.Center).width('76.3%'); - Button($r('app.string.counter_name')) - .fontSize('12fp') - .width('23.7%') - .fontColor($r('app.color.text_blue_opacity')) - .onClick(() => { - this.counter++; - this.storage.setOrCreate('FaultTriggerPageCounter', this.counter); - this.storage.setOrCreate('FaultTriggerPageString', 'TestFaultTriggerPageString'); - }) - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - .align(Alignment.Center) - .height('28vp'); - }.align(Alignment.Center).height('48vp'); - } - }.align(Alignment.Center).padding({ top: '4vp', bottom: '4vp' }).width('100%'); - } - .height('56vp') - .margin({ left: '12vp', right: '12vp', top: '12vp' }) - .width('93.3%') - .borderRadius('24vp') - .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) - .padding({ left: '12vp', right: '12vp' }); - - Text($r('app.string.recover_settings')) - .fontSize('14fp') - .margin({ left: '24vp', right: '24vp', top: '19.5vp', bottom: '9.5vp' }) - .textAlign(TextAlign.Start) - .fontColor($r('app.color.text_grey')) - .opacity(0.6) - .height('19vp') - .width('86.7%'); - - List() { - ListItem() { - Column() { - Row() { - Text($r('app.string.save_current_ability_status')).fontSize('16fp').width('76.3%'); - Button(this.curAbilitySaveState) - .fontSize('12fp') - .width('23.7%') - .fontColor($r('app.color.text_blue_opacity')) - .onClick(() => { - appRecovery.saveAppState(CurActiveAbility.GetInstance().GetGlobalAbility().context); - ResUtil.getString($r('app.string.save_state_done').id) - .then((value: string) => this.curAbilitySaveState = value); - }) - .height('28vp') - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - }.height('48vp').width('100%'); - } - }.width('100%'); - - ListItem() { - Column() { - Row() { - Text($r('app.string.save_all_ability_status')).fontSize('16fp').width('76.3%'); - Button(this.allAbilitySaveState) - .fontSize('12fp') - .width('23.7%') - .fontColor($r('app.color.text_blue_opacity')) - .onClick(() => { - appRecovery.saveAppState(); - ResUtil.getString($r('app.string.save_state_done').id) - .then((value: string) => this.allAbilitySaveState = value); - }) - .height('28vp') - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - }.height('48vp').width('100%'); - } - }.width('100%'); - - ListItem() { - Column() { - Row() { - Text($r('app.string.set_recovery_ability')).fontSize('16fp').width('76.3%'); - Button(this.setRecoveryAbility) - .fontSize('12fp') - .width('23.7%') - .fontColor($r('app.color.text_blue_opacity')) - .onClick(() => { - let tmp: Record = {'RecoverAbility': this.callerAbility } - let want: Record = { - 'bundleName': 'com.samples.recovery', - 'abilityName': 'RecoveryAbility', - 'parameters': tmp, - }; - appRecovery.setRestartWant(want); - ResUtil.getString($r('app.string.set_config_done').id).then((value: string) => this.setRecoveryAbility = value); - }) - .height('28vp') - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - }.height('48vp').width('100%'); - } - }.width('100%'); - - if (this.callerAbility === 'EntryAbility') { - ListItem() { - Column() { - Row() { - Text('SecondAbility').fontSize('16fp').width('76.3%'); - Button($r('app.string.launch_ability')) - .fontSize('12fp') - .width('23.7%') - .fontColor($r('app.color.text_blue_opacity')) - .onClick(() => { - if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) { - return; - } - let want: Record = { - 'bundleName': 'com.samples.recovery', - 'abilityName': 'SecondAbility' - }; - CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want); - }) - .height('28vp') - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - }.height('48vp').width('100%'); - } - }.width('100%'); - } - } - .margin({ left: '12vp', right: '12vp' }) - .width('93.3%') - .borderRadius('24vp') - .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) - .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) - .divider( - { strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') } - ); - - Text($r('app.string.trigger_fault_items')) - .fontSize('14fp') - .margin({ left: '24vp', right: '24vp', top: '19.5vp', bottom: '9.5vp' }) - .textAlign(TextAlign.Start) - .fontColor($r('app.color.text_grey')) - .opacity(0.6) - .height('19vp') - .width('86.7%'); - - List() { - ListItem() { - Column() { - Row() { - Text($r('app.string.trigger_js_error')).fontSize('16fp').width('76.3%'); - Button($r('app.string.trigger')) - .fontSize('12fp') - .width('23.7%') - .fontColor($r('app.color.text_blue_opacity')) - .onClick(() => { - throw new Error('Force Crash'); - }) - .height('28vp') - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - }.height('48vp').align(Alignment.Center).width('100%'); - } - }.width('100%'); - - ListItem() { - Column() { - Row() { - Text($r('app.string.trigger_freeze_in_js_code')).fontSize('16fp').width('76.3%'); - Button($r('app.string.trigger')) - .fontSize('12fp') - .width('23.7%') - .fontColor($r('app.color.text_blue_opacity')) - .onClick(() => { - this.doHeavyWork(); - }) - .height('28vp') - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - }.height('48vp').align(Alignment.Center).width('100%'); - } - }.width('100%'); - - ListItem() { - Column() { - Row() { - Text($r('app.string.trigger_freeze_in_native_code')).fontSize('16fp').width('76.3%'); - Button($r('app.string.trigger')) - .fontSize('12fp') - .width('23.7%') - .fontColor($r('app.color.text_blue_opacity')) - .onClick(() => { - testNapi.add(1, 1); - }) - .height('28vp') - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - }.height('48vp').align(Alignment.Center).width('100%'); - } - }.align(Alignment.Center).width('100%'); - } - .margin({ left: '12vp', right: '12vp' }) - .width('93.3%') - .borderRadius('24vp') - .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) - .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) - .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') }); - }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%') - .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]); - } -} +/* + * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery'; +import testNapi from 'libentry.so'; +import ResUtil from '../common/ResUtil'; +import { CurActiveAbility } from '../common/CurActiveAbility'; + +@Entry +@Component +struct FaultTriggerPage { + storage = LocalStorage.GetShared(); + @State counter: number = 0; + @State callerAbility: string = ''; + @State launchReason: string = ''; + @State lastExitReason: string = ''; + @State curAbilitySaveState: string = ''; + @State allAbilitySaveState: string = ''; + @State setRecoveryAbility: string = ''; + + aboutToAppear() { + this.counter = this.storage.get('FaultTriggerPageCounter') ?? 0; + this.callerAbility = this.storage.get('CurrentAbilityName') ?? 'UnknownCallingAbility'; + this.launchReason = this.storage.get('launchReason') ?? 'Unknown'; + this.lastExitReason = this.storage.get('lastExitReason') ?? 'Unknown'; + ResUtil.getString($r('app.string.save_state').id).then((value: string) => this.curAbilitySaveState = value); + ResUtil.getString($r('app.string.save_state').id).then((value: string) => this.allAbilitySaveState = value); + ResUtil.getString($r('app.string.set_config').id).then((value: string) => this.setRecoveryAbility = value); + } + + doHeavyWork() : void { + let i = 0; + while (i < 1000000000) { + i++; + let j = 0; + while (j < 1000000000) { + j++; + let k = 0; + while (k < 1000000000) { + k++; + } + } + } + } + + build() { + Column() { + Text(this.callerAbility) + .fontSize('30fp') + .fontWeight(FontWeight.Bold) + .padding({ left: '24vp', right: '24vp', top: '7vp', bottom: '8vp' }) + .margin({ top: '14vp' }) + .textAlign(TextAlign.Start) + .height('56vp') + .width('100%') + .fontColor($r('app.color.text_grey')); + + List() { + ListItem() { + Column() { + Row() { + Text($r('app.string.launch_reason')).fontSize('16fp').width('86%'); + Text('0' + this.launchReason) + .fontSize('14fp') + .width('14%') + .fontColor($r('app.color.text_grey')) + .opacity(0.6) + .textAlign(TextAlign.End); + } + } + }.width('100%').height('48vp').align(Alignment.Center); + + ListItem() { + Column() { + Row() { + Text($r('app.string.last_exit_reason')).fontSize('16fp').width('86%'); + Text('0' + this.lastExitReason) + .fontSize('14fp') + .width('14%') + .fontColor($r('app.color.text_grey')) + .opacity(0.6) + .textAlign(TextAlign.End); + } + } + }.width('100%').height('48vp').align(Alignment.Center); + } + .alignListItem(ListItemAlign.Center) + .margin({ left: '12vp', right: '12vp', top: '8vp' }) + .width('93.3%') + .borderRadius('24vp') + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) + .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') }); + + List() { + ListItem() { + Column() { + Row() { + Row() { + Text($r('app.string.click_counter')).fontSize('16fp') + Text(this.counter.toString()).fontSize('16fp') + }.align(Alignment.Center).width('76.3%'); + Button($r('app.string.counter_name')) + .fontSize('12fp') + .width('23.7%') + .fontColor($r('app.color.text_blue_opacity')) + .onClick(() => { + this.counter++; + this.storage.setOrCreate('FaultTriggerPageCounter', this.counter); + this.storage.setOrCreate('FaultTriggerPageString', 'TestFaultTriggerPageString'); + }) + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + .align(Alignment.Center) + .height('28vp'); + }.align(Alignment.Center).height('48vp'); + } + }.align(Alignment.Center).padding({ top: '4vp', bottom: '4vp' }).width('100%'); + } + .height('56vp') + .margin({ left: '12vp', right: '12vp', top: '12vp' }) + .width('93.3%') + .borderRadius('24vp') + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .padding({ left: '12vp', right: '12vp' }); + + Text($r('app.string.recover_settings')) + .fontSize('14fp') + .margin({ left: '24vp', right: '24vp', top: '19.5vp', bottom: '9.5vp' }) + .textAlign(TextAlign.Start) + .fontColor($r('app.color.text_grey')) + .opacity(0.6) + .height('19vp') + .width('86.7%'); + + List() { + ListItem() { + Column() { + Row() { + Text($r('app.string.save_current_ability_status')).fontSize('16fp').width('76.3%'); + Button(this.curAbilitySaveState) + .fontSize('12fp') + .width('23.7%') + .fontColor($r('app.color.text_blue_opacity')) + .onClick(() => { + appRecovery.saveAppState(CurActiveAbility.GetInstance().GetGlobalAbility().context); + ResUtil.getString($r('app.string.save_state_done').id) + .then((value: string) => this.curAbilitySaveState = value); + }) + .height('28vp') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + }.height('48vp').width('100%'); + } + }.width('100%'); + + ListItem() { + Column() { + Row() { + Text($r('app.string.save_all_ability_status')).fontSize('16fp').width('76.3%'); + Button(this.allAbilitySaveState) + .fontSize('12fp') + .width('23.7%') + .fontColor($r('app.color.text_blue_opacity')) + .onClick(() => { + appRecovery.saveAppState(); + ResUtil.getString($r('app.string.save_state_done').id) + .then((value: string) => this.allAbilitySaveState = value); + }) + .height('28vp') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + }.height('48vp').width('100%'); + } + }.width('100%'); + + ListItem() { + Column() { + Row() { + Text($r('app.string.set_recovery_ability')).fontSize('16fp').width('76.3%'); + Button(this.setRecoveryAbility) + .fontSize('12fp') + .width('23.7%') + .fontColor($r('app.color.text_blue_opacity')) + .onClick(() => { + let tmp: Record = {'RecoverAbility': this.callerAbility } + let want: Record = { + 'bundleName': 'com.samples.recovery', + 'abilityName': 'RecoveryAbility', + 'parameters': tmp, + }; + appRecovery.setRestartWant(want); + ResUtil.getString($r('app.string.set_config_done').id).then((value: string) => this.setRecoveryAbility = value); + }) + .height('28vp') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + }.height('48vp').width('100%'); + } + }.width('100%'); + + if (this.callerAbility === 'EntryAbility') { + ListItem() { + Column() { + Row() { + Text('SecondAbility').fontSize('16fp').width('76.3%'); + Button($r('app.string.launch_ability')) + .fontSize('12fp') + .width('23.7%') + .fontColor($r('app.color.text_blue_opacity')) + .onClick(() => { + if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) { + return; + } + let want: Record = { + 'bundleName': 'com.samples.recovery', + 'abilityName': 'SecondAbility' + }; + CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want); + }) + .height('28vp') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + }.height('48vp').width('100%'); + } + }.width('100%'); + } + } + .margin({ left: '12vp', right: '12vp' }) + .width('93.3%') + .borderRadius('24vp') + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) + .divider( + { strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') } + ); + + Text($r('app.string.trigger_fault_items')) + .fontSize('14fp') + .margin({ left: '24vp', right: '24vp', top: '19.5vp', bottom: '9.5vp' }) + .textAlign(TextAlign.Start) + .fontColor($r('app.color.text_grey')) + .opacity(0.6) + .height('19vp') + .width('86.7%'); + + List() { + ListItem() { + Column() { + Row() { + Text($r('app.string.trigger_js_error')).fontSize('16fp').width('76.3%'); + Button($r('app.string.trigger')) + .fontSize('12fp') + .width('23.7%') + .fontColor($r('app.color.text_blue_opacity')) + .onClick(() => { + throw new Error('Force Crash'); + }) + .height('28vp') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + }.height('48vp').align(Alignment.Center).width('100%'); + } + }.width('100%'); + + ListItem() { + Column() { + Row() { + Text($r('app.string.trigger_freeze_in_js_code')).fontSize('16fp').width('76.3%'); + Button($r('app.string.trigger')) + .fontSize('12fp') + .width('23.7%') + .fontColor($r('app.color.text_blue_opacity')) + .onClick(() => { + this.doHeavyWork(); + }) + .height('28vp') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + }.height('48vp').align(Alignment.Center).width('100%'); + } + }.width('100%'); + + ListItem() { + Column() { + Row() { + Text($r('app.string.trigger_freeze_in_native_code')).fontSize('16fp').width('76.3%'); + Button($r('app.string.trigger')) + .fontSize('12fp') + .width('23.7%') + .fontColor($r('app.color.text_blue_opacity')) + .onClick(() => { + testNapi.add(1, 1); + }) + .height('28vp') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + }.height('48vp').align(Alignment.Center).width('100%'); + } + }.align(Alignment.Center).width('100%'); + } + .margin({ left: '12vp', right: '12vp' }) + .width('93.3%') + .borderRadius('24vp') + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) + .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') }); + }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%') + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]); + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/Index.ets index 5d0ad7ec9b..a18cab7c37 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/Index.ets @@ -1,93 +1,93 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router'; - -@Entry -@Component -struct FirstPage { - storage = LocalStorage.GetShared(); - @State launchReason: string = ''; - @State lastExitReason: string = ''; - @State callerAbility: string = ''; - - aboutToAppear() { - this.launchReason = this.storage.get('launchReason') ?? 'Unknown'; - this.lastExitReason = this.storage.get('lastExitReason') ?? 'Unknown'; - this.callerAbility = this.storage.get('CurrentAbilityName') ?? 'Unknown'; - } - - build() { - Column() { - Text(this.callerAbility) - .fontSize('30fp') - .fontWeight(FontWeight.Bold) - .padding({ left: '24vp', right: '24vp', top: '7vp', bottom: '8vp' }) - .margin({ top: '14vp' }) - .textAlign(TextAlign.Start) - .height('56vp') - .width('100%') - .fontColor($r('app.color.text_grey')); - - List() { - ListItem() { - Column() { - Row() { - Text($r('app.string.launch_reason')).fontSize('16fp').width('86%'); - Text('0' + this.launchReason) - .fontSize('14fp') - .width('14%') - .fontColor($r('app.color.text_grey')) - .opacity(0.6) - .textAlign(TextAlign.End); - } - } - }.width('100%').height('48vp').align(Alignment.Center); - - ListItem() { - Column() { - Row() { - Text($r('app.string.last_exit_reason')).fontSize('16fp').width('86%'); - Text('0' + this.lastExitReason) - .fontSize('14fp') - .width('14%') - .fontColor($r('app.color.text_grey')) - .opacity(0.6) - .textAlign(TextAlign.End); - } - } - }.width('100%').height('48vp').align(Alignment.Center); - } - .alignListItem(ListItemAlign.Center) - .margin({ left: '12vp', right: '12vp', top: '8vp' }) - .width('93.3%') - .borderRadius('24vp') - .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) - .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) - .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') }); - - Button($r('app.string.trigger_fault')) - .fontSize('16fp') - .onClick(() => { - router.pushUrl({ url: 'pages/FaultTriggerPage' }); - }) - .width('88.9%') - .margin({ top: '480vp', right: '24vp', left: '24vp', bottom: '34vp' }) - .height('40vp') - .backgroundColor($r('app.color.text_blue_opacity')); - }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%') - .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]); - } -} +/* + * Copyright (c) 2023 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 router from '@ohos.router'; + +@Entry +@Component +struct FirstPage { + storage = LocalStorage.GetShared(); + @State launchReason: string = ''; + @State lastExitReason: string = ''; + @State callerAbility: string = ''; + + aboutToAppear() { + this.launchReason = this.storage.get('launchReason') ?? 'Unknown'; + this.lastExitReason = this.storage.get('lastExitReason') ?? 'Unknown'; + this.callerAbility = this.storage.get('CurrentAbilityName') ?? 'Unknown'; + } + + build() { + Column() { + Text(this.callerAbility) + .fontSize('30fp') + .fontWeight(FontWeight.Bold) + .padding({ left: '24vp', right: '24vp', top: '7vp', bottom: '8vp' }) + .margin({ top: '14vp' }) + .textAlign(TextAlign.Start) + .height('56vp') + .width('100%') + .fontColor($r('app.color.text_grey')); + + List() { + ListItem() { + Column() { + Row() { + Text($r('app.string.launch_reason')).fontSize('16fp').width('86%'); + Text('0' + this.launchReason) + .fontSize('14fp') + .width('14%') + .fontColor($r('app.color.text_grey')) + .opacity(0.6) + .textAlign(TextAlign.End); + } + } + }.width('100%').height('48vp').align(Alignment.Center); + + ListItem() { + Column() { + Row() { + Text($r('app.string.last_exit_reason')).fontSize('16fp').width('86%'); + Text('0' + this.lastExitReason) + .fontSize('14fp') + .width('14%') + .fontColor($r('app.color.text_grey')) + .opacity(0.6) + .textAlign(TextAlign.End); + } + } + }.width('100%').height('48vp').align(Alignment.Center); + } + .alignListItem(ListItemAlign.Center) + .margin({ left: '12vp', right: '12vp', top: '8vp' }) + .width('93.3%') + .borderRadius('24vp') + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) + .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') }); + + Button($r('app.string.trigger_fault')) + .fontSize('16fp') + .onClick(() => { + router.pushUrl({ url: 'pages/FaultTriggerPage' }); + }) + .width('88.9%') + .margin({ top: '480vp', right: '24vp', left: '24vp', bottom: '34vp' }) + .height('40vp') + .backgroundColor($r('app.color.text_blue_opacity')); + }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%') + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]); + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/RecoveryPage.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/RecoveryPage.ets index 9f4bb4093b..fcc2469853 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/RecoveryPage.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/RecoveryPage.ets @@ -1,112 +1,112 @@ -/* - * Copyright (c) 2023 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 { CurActiveAbility } from '../common/CurActiveAbility'; -@Entry -@Component -struct Index { - storage = LocalStorage.GetShared(); - @State launchParam: string = ''; - @State wantParam: string = ''; - fromEntryAbility: boolean = false; - - aboutToAppear() { - this.launchParam = this.storage.get('launchParam') ?? 'UnknownLaunchParam'; - this.wantParam = this.storage.get('wantParam') ?? 'UnknownWantParam'; - let abilityName = AppStorage.Get('RecoverAbility'); - if (abilityName === 'EntryAbility') { - this.fromEntryAbility = true; - } - } - - build() { - Column() { - Text('RecoveryPage') - .fontSize('30fp') - .fontWeight(FontWeight.Bold) - .padding({ left: '24vp', right: '24vp', top: '4vp', bottom: '4vp' }) - .margin({ top: '14vp' }) - .textAlign(TextAlign.Start) - .height('56vp') - .width('100%') - .fontColor($r('app.color.text_grey')); - - if (this.fromEntryAbility === false) { - List() { - ListItem() { - Column() { - Row() { - Text('SecondAbility').fontSize('16fp').width('76.3%'); - Button($r('app.string.recover')) - .fontSize('12fp') - .width('23.7%') - .fontColor($r('app.color.text_blue_opacity')) - .onClick(() => { - if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) { - return; - } - let want: Record = { - 'bundleName': 'com.samples.recovery', - 'abilityName': 'SecondAbility' - }; - CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want); - }) - .height('28vp') - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - }.height('48vp').align(Alignment.Center).width('100%'); - } - }.width('100%') - } - .margin({ left: '12vp', right: '12vp', top: '12vp' }) - .width('93.3%') - .borderRadius('24vp') - .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) - .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) - } - - List() { - ListItem() { - Column() { - Row() { - Text('EntryAbility').fontSize('16fp').width('76.3%'); - Button($r('app.string.recover')) - .fontSize('12fp') - .width('23.7%') - .fontColor($r('app.color.text_blue_opacity')) - .onClick(() => { - if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) { - return; - } - let want: Record = { - 'bundleName': 'com.samples.recovery', - 'abilityName': 'EntryAbility' - }; - CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want); - }) - .height('28vp') - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - }.height('48vp').align(Alignment.Center).width('100%'); - } - }.width('100%') - } - .margin({ left: '12vp', right: '12vp', top: '12vp' }) - .width('93.3%') - .borderRadius('24vp') - .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) - .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) - }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%') - .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]); - } -} +/* + * Copyright (c) 2023 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 { CurActiveAbility } from '../common/CurActiveAbility'; +@Entry +@Component +struct Index { + storage = LocalStorage.GetShared(); + @State launchParam: string = ''; + @State wantParam: string = ''; + fromEntryAbility: boolean = false; + + aboutToAppear() { + this.launchParam = this.storage.get('launchParam') ?? 'UnknownLaunchParam'; + this.wantParam = this.storage.get('wantParam') ?? 'UnknownWantParam'; + let abilityName = AppStorage.Get('RecoverAbility'); + if (abilityName === 'EntryAbility') { + this.fromEntryAbility = true; + } + } + + build() { + Column() { + Text('RecoveryPage') + .fontSize('30fp') + .fontWeight(FontWeight.Bold) + .padding({ left: '24vp', right: '24vp', top: '4vp', bottom: '4vp' }) + .margin({ top: '14vp' }) + .textAlign(TextAlign.Start) + .height('56vp') + .width('100%') + .fontColor($r('app.color.text_grey')); + + if (this.fromEntryAbility === false) { + List() { + ListItem() { + Column() { + Row() { + Text('SecondAbility').fontSize('16fp').width('76.3%'); + Button($r('app.string.recover')) + .fontSize('12fp') + .width('23.7%') + .fontColor($r('app.color.text_blue_opacity')) + .onClick(() => { + if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) { + return; + } + let want: Record = { + 'bundleName': 'com.samples.recovery', + 'abilityName': 'SecondAbility' + }; + CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want); + }) + .height('28vp') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + }.height('48vp').align(Alignment.Center).width('100%'); + } + }.width('100%') + } + .margin({ left: '12vp', right: '12vp', top: '12vp' }) + .width('93.3%') + .borderRadius('24vp') + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) + } + + List() { + ListItem() { + Column() { + Row() { + Text('EntryAbility').fontSize('16fp').width('76.3%'); + Button($r('app.string.recover')) + .fontSize('12fp') + .width('23.7%') + .fontColor($r('app.color.text_blue_opacity')) + .onClick(() => { + if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) { + return; + } + let want: Record = { + 'bundleName': 'com.samples.recovery', + 'abilityName': 'EntryAbility' + }; + CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want); + }) + .height('28vp') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + }.height('48vp').align(Alignment.Center).width('100%'); + } + }.width('100%') + } + .margin({ left: '12vp', right: '12vp', top: '12vp' }) + .width('93.3%') + .borderRadius('24vp') + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) + }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%') + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]); + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/module.json5 b/code/BasicFeature/DFX/AppRecovery/entry/src/main/module.json5 index a096762082..f63149349a 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/module.json5 +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/module.json5 @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2023 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", - "srcEntry": "./ets/app/MyAbilityStage.ets", - "mainElement": "EntryAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/ability/EntryAbility.ets", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "recoverable": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "SecondAbility", - "srcEntry": "./ets/ability/SecondAbility.ets", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:TextAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "recoverable": true - }, - { - "name": "RecoveryAbility", - "srcEntry": "./ets/ability/RecoveryAbility.ets", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:RecoveryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } +/* + * Copyright (c) 2023 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", + "srcEntry": "./ets/app/MyAbilityStage.ets", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/ability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "recoverable": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "SecondAbility", + "srcEntry": "./ets/ability/SecondAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:TextAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "recoverable": true + }, + { + "name": "RecoveryAbility", + "srcEntry": "./ets/ability/RecoveryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:RecoveryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/color.json b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/color.json index 357a66c7ff..c3a092dc68 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/color.json @@ -1,28 +1,28 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "title_background", - "value": "#0D9FFB" - }, - { - "name": "text_grey", - "value": "#182431" - }, - { - "name": "text_black", - "value": "#000000" - }, - { - "name": "text_grey_opacity", - "value": "#F3F4F4" - }, - { - "name": "text_blue_opacity", - "value": "#007dFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "title_background", + "value": "#0D9FFB" + }, + { + "name": "text_grey", + "value": "#182431" + }, + { + "name": "text_black", + "value": "#000000" + }, + { + "name": "text_grey_opacity", + "value": "#F3F4F4" + }, + { + "name": "text_blue_opacity", + "value": "#007dFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/string.json b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/string.json index 63c648fdf0..e0a8911ecb 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/string.json +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/string.json @@ -1,120 +1,120 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "AppRecoverySample" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "EntryAbility" - }, - { - "name": "TextAbility_label", - "value": "TextAbility" - }, - { - "name": "RecoveryAbility_label", - "value": "RecoveryAbility" - }, - { - "name": "app_has_recovered", - "value": "Application has recovered from error" - }, - { - "name": "trigger_fault", - "value": "Fault trigger page" - }, - { - "name": "current_ability", - "value": "Ability:" - }, - { - "name": "launch_reason", - "value": "Launch reason" - }, - { - "name": "last_exit_reason", - "value": "Last exit reason" - }, - { - "name": "current_status", - "value": "Current status:" - }, - { - "name": "click_counter", - "value": "Click Count:" - }, - { - "name": "trigger_fault_items", - "value": "Trigger Faults" - }, - { - "name": "trigger_js_error", - "value": "Trigger JsError" - }, - { - "name": "trigger_freeze_in_js_code", - "value": "Hung In Js Code" - }, - { - "name": "trigger_freeze_in_native_code", - "value": "Hung In Native Code" - }, - { - "name": "recover_settings", - "value": "Recovery settings" - }, - { - "name": "save_all_ability_status", - "value": "Whole abilities status" - }, - { - "name": "save_current_ability_status", - "value": "Current ability status" - }, - { - "name": "route_to_second_ability", - "value": "Route to SecondAbility" - }, - { - "name": "set_recovery_ability", - "value": "Set recovery ability" - }, - { - "name": "counter_name", - "value": "ClickMe" - }, - { - "name": "save_state", - "value": "Save" - }, - { - "name": "set_config", - "value": "Set" - }, - { - "name": "save_state_done", - "value": "Saved" - }, - { - "name": "set_config_done", - "value": "Set" - }, - { - "name": "launch_ability", - "value": "Launch" - }, - { - "name": "trigger", - "value": "Trigger" - }, - { - "name": "recover", - "value": "Recover" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "AppRecoverySample" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "EntryAbility" + }, + { + "name": "TextAbility_label", + "value": "TextAbility" + }, + { + "name": "RecoveryAbility_label", + "value": "RecoveryAbility" + }, + { + "name": "app_has_recovered", + "value": "Application has recovered from error" + }, + { + "name": "trigger_fault", + "value": "Fault trigger page" + }, + { + "name": "current_ability", + "value": "Ability:" + }, + { + "name": "launch_reason", + "value": "Launch reason" + }, + { + "name": "last_exit_reason", + "value": "Last exit reason" + }, + { + "name": "current_status", + "value": "Current status:" + }, + { + "name": "click_counter", + "value": "Click Count:" + }, + { + "name": "trigger_fault_items", + "value": "Trigger Faults" + }, + { + "name": "trigger_js_error", + "value": "Trigger JsError" + }, + { + "name": "trigger_freeze_in_js_code", + "value": "Hung In Js Code" + }, + { + "name": "trigger_freeze_in_native_code", + "value": "Hung In Native Code" + }, + { + "name": "recover_settings", + "value": "Recovery settings" + }, + { + "name": "save_all_ability_status", + "value": "Whole abilities status" + }, + { + "name": "save_current_ability_status", + "value": "Current ability status" + }, + { + "name": "route_to_second_ability", + "value": "Route to SecondAbility" + }, + { + "name": "set_recovery_ability", + "value": "Set recovery ability" + }, + { + "name": "counter_name", + "value": "ClickMe" + }, + { + "name": "save_state", + "value": "Save" + }, + { + "name": "set_config", + "value": "Set" + }, + { + "name": "save_state_done", + "value": "Saved" + }, + { + "name": "set_config_done", + "value": "Set" + }, + { + "name": "launch_ability", + "value": "Launch" + }, + { + "name": "trigger", + "value": "Trigger" + }, + { + "name": "recover", + "value": "Recover" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/profile/main_pages.json index 262d048acf..98e0d65bd8 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/profile/main_pages.json +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/profile/main_pages.json @@ -1,7 +1,7 @@ -{ - "src": [ - "pages/Index", - "pages/FaultTriggerPage", - "pages/RecoveryPage" - ] -} +{ + "src": [ + "pages/Index", + "pages/FaultTriggerPage", + "pages/RecoveryPage" + ] +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/en_US/element/string.json index 63c648fdf0..e0a8911ecb 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/en_US/element/string.json +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/en_US/element/string.json @@ -1,120 +1,120 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "AppRecoverySample" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "EntryAbility" - }, - { - "name": "TextAbility_label", - "value": "TextAbility" - }, - { - "name": "RecoveryAbility_label", - "value": "RecoveryAbility" - }, - { - "name": "app_has_recovered", - "value": "Application has recovered from error" - }, - { - "name": "trigger_fault", - "value": "Fault trigger page" - }, - { - "name": "current_ability", - "value": "Ability:" - }, - { - "name": "launch_reason", - "value": "Launch reason" - }, - { - "name": "last_exit_reason", - "value": "Last exit reason" - }, - { - "name": "current_status", - "value": "Current status:" - }, - { - "name": "click_counter", - "value": "Click Count:" - }, - { - "name": "trigger_fault_items", - "value": "Trigger Faults" - }, - { - "name": "trigger_js_error", - "value": "Trigger JsError" - }, - { - "name": "trigger_freeze_in_js_code", - "value": "Hung In Js Code" - }, - { - "name": "trigger_freeze_in_native_code", - "value": "Hung In Native Code" - }, - { - "name": "recover_settings", - "value": "Recovery settings" - }, - { - "name": "save_all_ability_status", - "value": "Whole abilities status" - }, - { - "name": "save_current_ability_status", - "value": "Current ability status" - }, - { - "name": "route_to_second_ability", - "value": "Route to SecondAbility" - }, - { - "name": "set_recovery_ability", - "value": "Set recovery ability" - }, - { - "name": "counter_name", - "value": "ClickMe" - }, - { - "name": "save_state", - "value": "Save" - }, - { - "name": "set_config", - "value": "Set" - }, - { - "name": "save_state_done", - "value": "Saved" - }, - { - "name": "set_config_done", - "value": "Set" - }, - { - "name": "launch_ability", - "value": "Launch" - }, - { - "name": "trigger", - "value": "Trigger" - }, - { - "name": "recover", - "value": "Recover" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "AppRecoverySample" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "EntryAbility" + }, + { + "name": "TextAbility_label", + "value": "TextAbility" + }, + { + "name": "RecoveryAbility_label", + "value": "RecoveryAbility" + }, + { + "name": "app_has_recovered", + "value": "Application has recovered from error" + }, + { + "name": "trigger_fault", + "value": "Fault trigger page" + }, + { + "name": "current_ability", + "value": "Ability:" + }, + { + "name": "launch_reason", + "value": "Launch reason" + }, + { + "name": "last_exit_reason", + "value": "Last exit reason" + }, + { + "name": "current_status", + "value": "Current status:" + }, + { + "name": "click_counter", + "value": "Click Count:" + }, + { + "name": "trigger_fault_items", + "value": "Trigger Faults" + }, + { + "name": "trigger_js_error", + "value": "Trigger JsError" + }, + { + "name": "trigger_freeze_in_js_code", + "value": "Hung In Js Code" + }, + { + "name": "trigger_freeze_in_native_code", + "value": "Hung In Native Code" + }, + { + "name": "recover_settings", + "value": "Recovery settings" + }, + { + "name": "save_all_ability_status", + "value": "Whole abilities status" + }, + { + "name": "save_current_ability_status", + "value": "Current ability status" + }, + { + "name": "route_to_second_ability", + "value": "Route to SecondAbility" + }, + { + "name": "set_recovery_ability", + "value": "Set recovery ability" + }, + { + "name": "counter_name", + "value": "ClickMe" + }, + { + "name": "save_state", + "value": "Save" + }, + { + "name": "set_config", + "value": "Set" + }, + { + "name": "save_state_done", + "value": "Saved" + }, + { + "name": "set_config_done", + "value": "Set" + }, + { + "name": "launch_ability", + "value": "Launch" + }, + { + "name": "trigger", + "value": "Trigger" + }, + { + "name": "recover", + "value": "Recover" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/zh_CN/element/string.json index eb713b875b..b04853b653 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/zh_CN/element/string.json +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/zh_CN/element/string.json @@ -1,120 +1,120 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "应用恢复范例" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "EntryAbility" - }, - { - "name": "TextAbility_label", - "value": "TextAbility" - }, - { - "name": "RecoveryAbility_label", - "value": "RecoveryAbility" - }, - { - "name": "app_has_recovered", - "value": "应用已经从故障中恢复" - }, - { - "name": "trigger_fault", - "value": "跳转到故障触发页面" - }, - { - "name": "current_ability", - "value": "当前页面:" - }, - { - "name": "launch_reason", - "value": "启动原因" - }, - { - "name": "last_exit_reason", - "value": "上次退出原因" - }, - { - "name": "current_status", - "value": "当前状态:" - }, - { - "name": "click_counter", - "value": "按钮点击计数:" - }, - { - "name": "trigger_fault_items", - "value": "触发故障" - }, - { - "name": "trigger_js_error", - "value": "JsError" - }, - { - "name": "trigger_freeze_in_js_code", - "value": "Js代码卡死" - }, - { - "name": "trigger_freeze_in_native_code", - "value": "Native代码卡死" - }, - { - "name": "recover_settings", - "value": "应用恢复设置" - }, - { - "name": "save_all_ability_status", - "value": "所有Ability状态" - }, - { - "name": "save_current_ability_status", - "value": "当前Ability状态" - }, - { - "name": "route_to_second_ability", - "value": "启动SecondAbility" - }, - { - "name": "set_recovery_ability", - "value": "恢复Ability" - }, - { - "name": "counter_name", - "value": "点击" - }, - { - "name": "save_state", - "value": "保存" - }, - { - "name": "set_config", - "value": "设置" - }, - { - "name": "save_state_done", - "value": "已保存" - }, - { - "name": "set_config_done", - "value": "已设置" - }, - { - "name": "launch_ability", - "value": "启动" - }, - { - "name": "trigger", - "value": "触发" - }, - { - "name": "recover", - "value": "恢复" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "应用恢复范例" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "EntryAbility" + }, + { + "name": "TextAbility_label", + "value": "TextAbility" + }, + { + "name": "RecoveryAbility_label", + "value": "RecoveryAbility" + }, + { + "name": "app_has_recovered", + "value": "应用已经从故障中恢复" + }, + { + "name": "trigger_fault", + "value": "跳转到故障触发页面" + }, + { + "name": "current_ability", + "value": "当前页面:" + }, + { + "name": "launch_reason", + "value": "启动原因" + }, + { + "name": "last_exit_reason", + "value": "上次退出原因" + }, + { + "name": "current_status", + "value": "当前状态:" + }, + { + "name": "click_counter", + "value": "按钮点击计数:" + }, + { + "name": "trigger_fault_items", + "value": "触发故障" + }, + { + "name": "trigger_js_error", + "value": "JsError" + }, + { + "name": "trigger_freeze_in_js_code", + "value": "Js代码卡死" + }, + { + "name": "trigger_freeze_in_native_code", + "value": "Native代码卡死" + }, + { + "name": "recover_settings", + "value": "应用恢复设置" + }, + { + "name": "save_all_ability_status", + "value": "所有Ability状态" + }, + { + "name": "save_current_ability_status", + "value": "当前Ability状态" + }, + { + "name": "route_to_second_ability", + "value": "启动SecondAbility" + }, + { + "name": "set_recovery_ability", + "value": "恢复Ability" + }, + { + "name": "counter_name", + "value": "点击" + }, + { + "name": "save_state", + "value": "保存" + }, + { + "name": "set_config", + "value": "设置" + }, + { + "name": "save_state_done", + "value": "已保存" + }, + { + "name": "set_config_done", + "value": "已设置" + }, + { + "name": "launch_ability", + "value": "启动" + }, + { + "name": "trigger", + "value": "触发" + }, + { + "name": "recover", + "value": "恢复" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts index ece6bfbc6e..1cdc33bdf4 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -1,84 +1,84 @@ -/* - * Copyright (c) 2023 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 TestRunner from '@ohos.application.testRunner'; -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; -import Logger from '../../../main/ets/common/Logger'; - -let abilityDelegator = undefined; -let abilityDelegatorArguments = undefined; - -const TAG: string = 'TestRunner'; -const keySet = new Set([ - '-s class', '-s notClass', '-s suite', '-s it', - '-s level', '-s testType', '-s size', '-s timeout', - '-s dryRun' -]); - -function translateParamsToString(parameters): string { - let targetParams = ''; - for (const key in parameters) { - if (keySet.has(key)) { - targetParams = '${targetParams} ${key} ${parameters[key]}'; - Logger.info(TAG, 'targetParams:${targetParams}'); - } - } - return targetParams.trim(); -} - -async function onAbilityCreateCallback(): Promise { - Logger.info(TAG, 'onAbilityCreateCallback'); -} - -async function addAbilityMonitorCallback(err: Error): Promise { - Logger.info(TAG, 'addAbilityMonitorCallback'); -} - -export default class OpenHarmonyTestRunner implements TestRunner { - constructor() { - } - - onPrepare(): void { - Logger.info(TAG, 'OpenHarmonyTestRunner onPrepare'); - } - - async onRun(): Promise { - Logger.info(TAG, 'OpenHarmonyTestRunner onRun'); - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); - - let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'; - let lMonitor = { - abilityName: testAbilityName, - onAbilityCreate: onAbilityCreateCallback, - }; - - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); - - let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; - cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters); - let debug = abilityDelegatorArguments.parameters['-D']; - if (debug === 'true') { - cmd += ' -D'; - } - Logger.info(TAG, 'cmd:${cmd}'); - - abilityDelegator.executeShellCommand(cmd, - (err: any, d: any) => { - Logger.info(TAG, 'OpenHarmonyTestRunner onError'); - }); - Logger.info(TAG, 'OpenHarmonyTestRunner onRun end'); - } -} +/* + * Copyright (c) 2023 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 TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import Logger from '../../../main/ets/common/Logger'; + +let abilityDelegator = undefined; +let abilityDelegatorArguments = undefined; + +const TAG: string = 'TestRunner'; +const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' +]); + +function translateParamsToString(parameters): string { + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = '${targetParams} ${key} ${parameters[key]}'; + Logger.info(TAG, 'targetParams:${targetParams}'); + } + } + return targetParams.trim(); +} + +async function onAbilityCreateCallback(): Promise { + Logger.info(TAG, 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: Error): Promise { + Logger.info(TAG, 'addAbilityMonitorCallback'); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare(): void { + Logger.info(TAG, 'OpenHarmonyTestRunner onPrepare'); + } + + async onRun(): Promise { + Logger.info(TAG, 'OpenHarmonyTestRunner onRun'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + + let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); + + let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters); + let debug = abilityDelegatorArguments.parameters['-D']; + if (debug === 'true') { + cmd += ' -D'; + } + Logger.info(TAG, 'cmd:${cmd}'); + + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + Logger.info(TAG, 'OpenHarmonyTestRunner onError'); + }); + Logger.info(TAG, 'OpenHarmonyTestRunner onRun end'); + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/Ability.test.ets index 94e6fccffd..0febaf1ef3 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,84 +1,84 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' -import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; -import Logger from '../../../main/ets/common/Logger' - -const TAG = '[Sample_AppRecovery]' -const BUNDLE = 'appRecovery_' - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - // Defines a test suite. Two parameters are supported: test suite name and test suite function. - beforeAll(() => { - // Presets an action, which is performed only once before all test cases of the test suite start. - // This API supports only one parameter: preset action function. - }); - beforeEach(() => { - // Presets an action, which is performed before each unit test case starts. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: preset action function. - }); - afterEach(() => { - // Presets a clear action, which is performed after each unit test case ends. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: clear action function. - }); - afterAll(() => { - // Presets a clear action, which is performed after all test cases of the test suite end. - // This API supports only one parameter: clear action function. - }); - - it('AppRecoverySample_StartAbility_001', 0, () => { - Logger.info(TAG, BUNDLE + 'StartAbility_001 begin'); - let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); - try { - abilityDelegator.startAbility({ - bundleName: 'com.sample.recovery', abilityName: 'EntryAbility' - }); - } catch (exception) { - expect().assertFail(); - } - Logger.info(TAG, BUNDLE + 'StartAbility_001 end'); - }); - - it('AppRecoverySample_StartAbility_002', 0, () => { - Logger.info(TAG, BUNDLE + 'StartAbility_002 begin'); - let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); - try { - abilityDelegator.startAbility({ - bundleName: 'com.sample.recovery', abilityName: 'SecondAbility' - }); - } catch (exception) { - expect().assertFail(); - } - Logger.info(TAG, BUNDLE + 'StartAbility_002 end'); - }); - - it('AppRecoverySample_StartAbility_003', 0, () => { - Logger.info(TAG, BUNDLE + 'StartAbility_003 begin'); - let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); - try { - abilityDelegator.startAbility({ - bundleName: 'com.sample.recovery', abilityName: 'RecoveryAbility' - }); - } catch (exception) { - expect().assertFail(); - } - Logger.info(TAG, BUNDLE + 'StartAbility_003 end'); - }); - }); -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import Logger from '../../../main/ets/common/Logger' + +const TAG = '[Sample_AppRecovery]' +const BUNDLE = 'appRecovery_' + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + + it('AppRecoverySample_StartAbility_001', 0, () => { + Logger.info(TAG, BUNDLE + 'StartAbility_001 begin'); + let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); + try { + abilityDelegator.startAbility({ + bundleName: 'com.sample.recovery', abilityName: 'EntryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + Logger.info(TAG, BUNDLE + 'StartAbility_001 end'); + }); + + it('AppRecoverySample_StartAbility_002', 0, () => { + Logger.info(TAG, BUNDLE + 'StartAbility_002 begin'); + let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); + try { + abilityDelegator.startAbility({ + bundleName: 'com.sample.recovery', abilityName: 'SecondAbility' + }); + } catch (exception) { + expect().assertFail(); + } + Logger.info(TAG, BUNDLE + 'StartAbility_002 end'); + }); + + it('AppRecoverySample_StartAbility_003', 0, () => { + Logger.info(TAG, BUNDLE + 'StartAbility_003 begin'); + let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); + try { + abilityDelegator.startAbility({ + bundleName: 'com.sample.recovery', abilityName: 'RecoveryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + Logger.info(TAG, BUNDLE + 'StartAbility_003 end'); + }); + }); +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/List.test.ets index 2a22ae6dc9..27c07a1a17 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/List.test.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/List.test.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test' - -export default function testsuite() { - abilityTest() +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/TestAbility.ets index 2295bc8496..b71566313b 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/TestAbility.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import Window from '@ohos.window'; -import Want from '@ohos.app.ability.Want'; -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; -import { Hypium } from '@ohos/hypium'; -import testsuite from '../test/List.test'; -import Logger from '../../../main/ets/common/Logger'; - -const TAG = '[Sample_AppRecovery]' - -export default class TestAbility extends UIAbility { - onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void { - Logger.info(TAG, 'onCreate Want:${JSON.stringify(want)} launchParam: ${JSON.stringify(launchParam)}'); - let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - let abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); - } - - onDestroy(): void { - Logger.info(TAG, 'onDestroy'); - } - - onWindowStageCreate(windowStage: Window.WindowStage): void { - Logger.info(TAG, 'onWindowStageCreate'); - windowStage.loadContent('testability/pages/Index', (err, data) => { - if (err.code) { - return; - } - }); - } - - onWindowStageDestroy(): void { - Logger.info(TAG, 'onWindowStageDestroy'); - } - - onForeground(): void { - Logger.info(TAG, 'onForeground'); - } - - onBackground(): void { - Logger.info(TAG, 'onBackground'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import Window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; +import Logger from '../../../main/ets/common/Logger'; + +const TAG = '[Sample_AppRecovery]' + +export default class TestAbility extends UIAbility { + onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void { + Logger.info(TAG, 'onCreate Want:${JSON.stringify(want)} launchParam: ${JSON.stringify(launchParam)}'); + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); + } + + onDestroy(): void { + Logger.info(TAG, 'onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage): void { + Logger.info(TAG, 'onWindowStageCreate'); + windowStage.loadContent('testability/pages/Index', (err, data) => { + if (err.code) { + return; + } + }); + } + + onWindowStageDestroy(): void { + Logger.info(TAG, 'onWindowStageDestroy'); + } + + onForeground(): void { + Logger.info(TAG, 'onForeground'); + } + + onBackground(): void { + Logger.info(TAG, 'onBackground'); + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/pages/Index.ets index 874769e7cb..98da6018fb 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/pages/Index.ets +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 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 { - aboutToAppear() { - } - - @State message: string = 'Hello World' - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(20) - .fontWeight(FontWeight.Bold) - } - .type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('35%') - .height('5%') - .onClick(() => { - }) - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2023 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 { + aboutToAppear() { + } + + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(() => { + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/module.json5 b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/module.json5 index be787551f0..b86e44a1f9 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "visible": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/color.json +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/string.json index 04e87abb72..65d8fa5a7c 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/string.json +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/string.json @@ -1,16 +1,16 @@ -{ - "string": [ - { - "name": "module_test_desc", - "value": "test ability description" - }, - { - "name": "TestAbility_desc", - "value": "the test ability" - }, - { - "name": "TestAbility_label", - "value": "test label" - } - ] +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/profile/test_pages.json index c3d813c41a..b7e7343cac 100644 --- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/profile/test_pages.json +++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -1,5 +1,5 @@ -{ - "src": [ - "testability/pages/Index" - ] -} +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/code/BasicFeature/DFX/AppRecovery/hvigorfile.ts b/code/BasicFeature/DFX/AppRecovery/hvigorfile.ts index 1a4d9969c6..6478186902 100644 --- a/code/BasicFeature/DFX/AppRecovery/hvigorfile.ts +++ b/code/BasicFeature/DFX/AppRecovery/hvigorfile.ts @@ -1,2 +1,2 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/code/BasicFeature/DFX/AppRecovery/oh-package.json5 b/code/BasicFeature/DFX/AppRecovery/oh-package.json5 index 57600fe0a1..3dc884c6f8 100644 --- a/code/BasicFeature/DFX/AppRecovery/oh-package.json5 +++ b/code/BasicFeature/DFX/AppRecovery/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "ISC", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "name": "AppRecoverySample", - "description": "app recovery sample", - "repository": {}, - "version": "1.0.0", - "dependencies": {} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "ISC", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "name": "AppRecoverySample", + "description": "app recovery sample", + "repository": {}, + "version": "1.0.0", + "dependencies": {} } \ No newline at end of file diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/.gitignore b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/.gitignore old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/app.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/app.json5 old mode 100755 new mode 100644 index edc19e4572..3470aba677 --- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/app.json5 +++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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": "ohos.samples.UTDType", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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": "ohos.samples.UTDType", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 312b4a8ac1..2f400f9794 --- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "UTDType" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "UTDType" + } + ] +} diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/media/app_icon.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/README_zh.md b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/README_zh.md old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/build-profile.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/build-profile.json5 old mode 100755 new mode 100644 index c38ebad24c..ce0311a175 --- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/build-profile.json5 +++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 11, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" - } - ], - "signingConfigs": [] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} +/* + * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 11, + "compatibleSdkVersion": 10, + "runtimeOS": "OpenHarmony" + } + ], + "signingConfigs": [] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/.gitignore b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/build-profile.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/build-profile.json5 old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/hvigorfile.js b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/hvigorfile.js old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/oh-package.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/oh-package.json5 old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/entryability/EntryAbility.ts old mode 100755 new mode 100644 index db9f5c164e..414945cf53 --- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 UIAbility from '@ohos.app.ability.UIAbility'; -import hilog from '@ohos.hilog'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - 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'); - } -} +/* + * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + 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/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/displayMediaFile.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/displayMediaFile.ets old mode 100755 new mode 100644 index 75723cb5c9..509e7ebcd6 --- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/displayMediaFile.ets +++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/displayMediaFile.ets @@ -1,162 +1,162 @@ -/* - * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 utdDesc from '@ohos.data.uniformTypeDescriptor'; -import router from '@ohos.router'; -import { logger } from '../util/Logger'; - -const TAG: string = 'DisplayMediaFile'; - -interface paramsTape { - src: string, - selectIconFile: string, -} - -interface FileIconType { - type: string, - value: string, - icon: Resource -} - -const FILE_TYPE_ICON: FileIconType[] = [ - { - type: "Image", - value: "general.image", - icon: $r("app.media.image") - }, - { - type: "Audio", - value: "general.audio", - icon: $r("app.media.myAudio") - }, - { - type: "Video", - value: "general.video", - icon: $r("app.media.video") - } -] - -@Entry -@Component -struct selectMediaType { - @State src: string = (router.getParams() as paramsTape).src; - @State selectIconFile: string = (router.getParams() as paramsTape).selectIconFile; - private routerBackUrl: string = 'pages/selectMediaType'; - - onPageShow() { - this.src = (router.getParams() as paramsTape).src; - this.selectIconFile = (router.getParams() as paramsTape).selectIconFile; - } - - getFileIcon(fileName: string): Resource { - let fileIcon = $r("app.media.file"); - let index = fileName.lastIndexOf('.'); - if (index < 0) { - return fileIcon; - } else { - let fileExtension = fileName.substring(index); - let utd = utdDesc.getUniformDataTypeByFilenameExtension(fileExtension); - let typeObj: utdDesc.TypeDescriptor; - try { - typeObj = utdDesc.getTypeDescriptor(utd); - } catch (e) { - logger.info(TAG, `invalid file type`); - return fileIcon; - } - FILE_TYPE_ICON.forEach(DataType => { - if(typeObj.belongsTo(DataType.value)) { - logger.info(TAG, `file type: ${DataType.type}`); - fileIcon = DataType.icon; - } - }) - return fileIcon; - } - } - - build() { - Column() { - Column() { - Row() { - Image($r('app.media.utdType_back')) - .id('thirdPageBack') - .width(24) - .height(24) - .visibility(Visibility.Visible) - .objectFit(ImageFit.Fill) - .alignSelf(ItemAlign.Auto) - .margin({ left: 24, right: 12 }) - .onClick(() => { - router.pushUrl({ url: this.routerBackUrl }, router.RouterMode.Single); - }) - Text($r('app.string.displayMediaFile_title')) - .fontStyle(FontStyle.Normal) - .fontSize(20) - .textAlign(TextAlign.Start) - .fontWeight(700) - } - .width('100%') - .height(56) - } - .width(280) - .height(56) - .alignItems(HorizontalAlign.Start) - .justifyContent(FlexAlign.Center) - - Column() { - List({ space: 2, initialIndex: 0 }) { - ListItem() { - Row() { - Image(this.getFileIcon(this.src)) - .id('imageBack') - .width(24) - .height(24) - .objectFit(ImageFit.Fill) - .alignSelf(ItemAlign.Auto) - .margin({ left: 12, right: 12 }) - Text(this.src) - .fontSize(16) - .textAlign(TextAlign.Start) - .fontWeight(500) - }.width('100%').height('100%') - } - } - .listDirection(Axis.Vertical) // 排列方向 - .scrollBar(BarState.Auto) - .friction(0.6) - .margin({ left: 12, right: 12 }) - .borderRadius(24) - .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring - .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { - logger.info(TAG, 'first' + firstIndex) - logger.info(TAG, 'last' + lastIndex) - logger.info(TAG, 'center' + centerIndex) - }) - .onScroll((scrollOffset: number, scrollState: ScrollState) => { - logger.info(TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset) - }) - .backgroundColor(0xFFFFFF) - .alignListItem(ListItemAlign.Center) - } - .width('100%') - .height(64) - .alignItems(HorizontalAlign.Start) - .justifyContent(FlexAlign.Center) - } - .width('100%') - .height('100%') - .alignItems(HorizontalAlign.Start) - .backgroundColor($r('app.color.background_shallow_grey')) - } -} +/* + * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 utdDesc from '@ohos.data.uniformTypeDescriptor'; +import router from '@ohos.router'; +import { logger } from '../util/Logger'; + +const TAG: string = 'DisplayMediaFile'; + +interface paramsTape { + src: string, + selectIconFile: string, +} + +interface FileIconType { + type: string, + value: string, + icon: Resource +} + +const FILE_TYPE_ICON: FileIconType[] = [ + { + type: "Image", + value: "general.image", + icon: $r("app.media.image") + }, + { + type: "Audio", + value: "general.audio", + icon: $r("app.media.myAudio") + }, + { + type: "Video", + value: "general.video", + icon: $r("app.media.video") + } +] + +@Entry +@Component +struct selectMediaType { + @State src: string = (router.getParams() as paramsTape).src; + @State selectIconFile: string = (router.getParams() as paramsTape).selectIconFile; + private routerBackUrl: string = 'pages/selectMediaType'; + + onPageShow() { + this.src = (router.getParams() as paramsTape).src; + this.selectIconFile = (router.getParams() as paramsTape).selectIconFile; + } + + getFileIcon(fileName: string): Resource { + let fileIcon = $r("app.media.file"); + let index = fileName.lastIndexOf('.'); + if (index < 0) { + return fileIcon; + } else { + let fileExtension = fileName.substring(index); + let utd = utdDesc.getUniformDataTypeByFilenameExtension(fileExtension); + let typeObj: utdDesc.TypeDescriptor; + try { + typeObj = utdDesc.getTypeDescriptor(utd); + } catch (e) { + logger.info(TAG, `invalid file type`); + return fileIcon; + } + FILE_TYPE_ICON.forEach(DataType => { + if(typeObj.belongsTo(DataType.value)) { + logger.info(TAG, `file type: ${DataType.type}`); + fileIcon = DataType.icon; + } + }) + return fileIcon; + } + } + + build() { + Column() { + Column() { + Row() { + Image($r('app.media.utdType_back')) + .id('thirdPageBack') + .width(24) + .height(24) + .visibility(Visibility.Visible) + .objectFit(ImageFit.Fill) + .alignSelf(ItemAlign.Auto) + .margin({ left: 24, right: 12 }) + .onClick(() => { + router.pushUrl({ url: this.routerBackUrl }, router.RouterMode.Single); + }) + Text($r('app.string.displayMediaFile_title')) + .fontStyle(FontStyle.Normal) + .fontSize(20) + .textAlign(TextAlign.Start) + .fontWeight(700) + } + .width('100%') + .height(56) + } + .width(280) + .height(56) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Center) + + Column() { + List({ space: 2, initialIndex: 0 }) { + ListItem() { + Row() { + Image(this.getFileIcon(this.src)) + .id('imageBack') + .width(24) + .height(24) + .objectFit(ImageFit.Fill) + .alignSelf(ItemAlign.Auto) + .margin({ left: 12, right: 12 }) + Text(this.src) + .fontSize(16) + .textAlign(TextAlign.Start) + .fontWeight(500) + }.width('100%').height('100%') + } + } + .listDirection(Axis.Vertical) // 排列方向 + .scrollBar(BarState.Auto) + .friction(0.6) + .margin({ left: 12, right: 12 }) + .borderRadius(24) + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { + logger.info(TAG, 'first' + firstIndex) + logger.info(TAG, 'last' + lastIndex) + logger.info(TAG, 'center' + centerIndex) + }) + .onScroll((scrollOffset: number, scrollState: ScrollState) => { + logger.info(TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset) + }) + .backgroundColor(0xFFFFFF) + .alignListItem(ListItemAlign.Center) + } + .width('100%') + .height(64) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Center) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Start) + .backgroundColor($r('app.color.background_shallow_grey')) + } +} diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/selectMediaType.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/selectMediaType.ets old mode 100755 new mode 100644 index 74dddc4837..b445b259f7 --- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/selectMediaType.ets +++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/selectMediaType.ets @@ -1,264 +1,264 @@ -/* - * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router'; -import fs from '@ohos.file.fs'; -import common from '@ohos.app.ability.common'; -import utdDesc from '@ohos.data.uniformTypeDescriptor'; -import { BusinessError } from '@ohos.base'; -import { logger } from '../util/Logger'; - -const TAG: string = 'SelectMediaType'; -// 获取应用文件路径 -let context = getContext(this) as common.UIAbilityContext; -let baseDir = context.filesDir; -let filesDir = baseDir + '/udmf_test'; - -let class2UTD = new Map([ - ["All", "All"], - ["Images", "general.image"], - ["Audios", "general.audio"], - ["Videos", "general.video"] -]); - -class FileInfo { - filename: string; - iconFile: string; - - constructor(fileName: string, iconFile: string) { - this.filename = fileName; - this.iconFile = iconFile; - } -} - -@Entry -@Component -struct selectMediaType { - @State text: string = "Images"; - @State index: number = 1; - @State space: number = 12; - @State arrowPosition: ArrowPosition = ArrowPosition.END; - @State fileNames: string[] = []; - @State selectedFilesInfos: FileInfo[] = []; - private routerBackUrl: string = 'pages/Index'; - private routerNextUrl: string = 'pages/displayMediaFile'; - - getListFile(): string[] { - let files = fs.listFileSync(filesDir); - return files; - } - - UpdateSelectedFiles(): void { - this.fileNames = this.getListFile(); - for (let i = this.selectedFilesInfos.length - 1; i >= 0; i--) { - this.selectedFilesInfos.pop(); - } - this.selectedFilesInfos = []; - logger.info(TAG, "selectText: " + this.text) - for (let i = 0; i < this.fileNames.length; i++) { - let fileName = this.fileNames[i]; - let index = fileName.lastIndexOf('.'); - if (index < 0) { - logger.info(TAG, `fileNames file: ${fileName}`); - if (this.text == "All") { - let fileInfo = new FileInfo(fileName, ""); - this.selectedFilesInfos.push(fileInfo); - } - continue; - } else { - let fileExtension = fileName.substring(index); - let utd = utdDesc.getUniformDataTypeByFilenameExtension(fileExtension); - logger.info(TAG, `fileNames file: ${fileName}, extension: ${fileExtension}, utd: ${utd}`); - try { - if (utd != null) { - let typeObj: utdDesc.TypeDescriptor = utdDesc.getTypeDescriptor(utd); - if (class2UTD.get(this.text) == "All") { - let fileInfo = new FileInfo(fileName, typeObj.iconFile); - this.selectedFilesInfos.push(fileInfo); - logger.info(TAG, `All type: ${fileInfo.filename}, utd: ${utd}, iconFile: ${fileInfo.iconFile}`); - } else { - let ret = typeObj.belongsTo(class2UTD.get(this.text)); - logger.info(TAG, `typeObj.belongsTo: ${fileName}, utd: ${class2UTD.get(this.text)}, ret: ${ret} iconFile: ${typeObj.iconFile}`); - if (ret) { - let fileInfo = new FileInfo(fileName, typeObj.iconFile); - this.selectedFilesInfos.push(fileInfo); - } - } - } else { - if (class2UTD.get(this.text) == "All") { - let fileInfo = new FileInfo(fileName, ""); - this.selectedFilesInfos.push(fileInfo); - logger.info(TAG, `utd null All type: ${fileInfo.filename}, utd: ${utd}, iconFile: ${fileInfo.iconFile}`); - } - } - } - catch (e) { - let error: BusinessError = e as BusinessError; - logger.error(TAG, `belongsTo throws an exception. code is ${error.code}, message is ${error.message}`); - } - } - } - logger.info(TAG, `all files ${JSON.stringify(this.selectedFilesInfos)}}`); - } - - aboutToAppear() { - logger.info(TAG, 'filesDir: ' + filesDir); - this.UpdateSelectedFiles(); - } - - aboutToDisappear() { - for (let i = this.selectedFilesInfos.length - 1; i >= 0; i--) { - this.selectedFilesInfos.pop(); - } - } - - build() { - Column() { - Column() { - Row() { - Image($r('app.media.utdType_back')) - .id('secondPageBack') - .width(24) - .height(24) - .objectFit(ImageFit.Fill) - .visibility(Visibility.Visible) - .alignSelf(ItemAlign.Auto) - .margin({ left: 24, right: 12 }) - .onClick(() => { - router.pushUrl({ url: this.routerBackUrl }, router.RouterMode.Single); - }) - Text($r('app.string.selectMediaType_title')) - .fontStyle(FontStyle.Normal) - .fontSize(20) - .fontWeight(700) - .textAlign(TextAlign.Start) - .id('titleText') - } - .width('100%') - .height(56) - .alignItems(VerticalAlign.Center) - } - .width(280) - .height(56) - .alignItems(HorizontalAlign.Start) - - Column() { - Select([{ value: 'All', icon: $r('app.media.ic_select_option_collection') }, - { value: 'Images', icon: $r('app.media.ic_select_option_collection') }, - { value: 'Audios', icon: $r('app.media.ic_select_option_collection') }, - { value: 'Videos', icon: $r('app.media.ic_select_option_collection') }]) - .selected(this.index) - .value(this.text) - .id('SelectTypeList') - .font({ size: 16, weight: 500 }) - .fontColor('#182431') - .selectedOptionFont({ size: 16, weight: 500 }) - .optionFont({ size: 16, weight: 500 }) - .space(this.space) - .arrowPosition(this.arrowPosition) - .menuAlign(MenuAlignType.START, { dx: 0, dy: 0 }) - .backgroundColor($r('app.color.background_shallow_grey')) - .onSelect((index: number, text?: string | undefined) => { - this.index = index; - if (text) { - this.text = text; - logger.info(TAG, 'Select type:' + text); - this.UpdateSelectedFiles(); - } - }) - } - .margin({ left: 12, right: 12 }) - .height(48) - .width(160) - .alignItems(HorizontalAlign.Start) - .justifyContent(FlexAlign.Center) - - Column() { - List({ space: 2, initialIndex: 0 }) { - ForEach(this.selectedFilesInfos, (item: FileInfo, no: Number) => { - ListItem() { - Row() { - Column() { - Text(item.filename) - .fontSize(16) - .height(46) - .textAlign(TextAlign.Start) - .margin({ left: 12, right: 12 }) - .fontWeight(500) - .id("textFilename_" + no) - .visibility(Visibility.Visible) - .onClick(() => { - logger.info(TAG, `selected file:` + item.filename + `and clicked`); - try { - router.pushUrl({ - url: this.routerNextUrl, - params: { - src: item.filename, - selectIconFile: item.iconFile - } - }, router.RouterMode.Single); - } - catch (e) { - let error: BusinessError = e as BusinessError; - logger.error(TAG, `select file and router exception. code is ${error.code}, message is ${error.message}`); - } - }) - Divider() - .vertical(false) - .height(2) - .color($r('app.color.background_shallow_grey')) - .opacity(0.6) - .margin({ left: 12, right: 12 }) - } - .width('100%') - .height(48) - .justifyContent(FlexAlign.Center) - .alignItems(HorizontalAlign.Start) - } - .width('100%') - .height(48) - .alignItems(VerticalAlign.Center) - } - .id("listItem_" + no) - }) - } - .listDirection(Axis.Vertical) // 排列方向 - .scrollBar(BarState.Auto) - .friction(0.6) - .margin({ left: 12, right: 12 }) - .borderRadius(24) - .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring - .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { - logger.info(TAG, 'first: ' + firstIndex); - logger.info(TAG, 'last: ' + lastIndex); - logger.info(TAG, 'center: ' + centerIndex); - }) - .onScroll((scrollOffset: number, scrollState: ScrollState) => { - logger.info(TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset); - }) - .backgroundColor(0xFFFFFF) - } - .width('100%') - .height(680) - .alignItems(HorizontalAlign.Start) - .justifyContent(FlexAlign.Start) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.background_shallow_grey')) - .alignItems(HorizontalAlign.Start) - .justifyContent(FlexAlign.Center) - } -} +/* + * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router'; +import fs from '@ohos.file.fs'; +import common from '@ohos.app.ability.common'; +import utdDesc from '@ohos.data.uniformTypeDescriptor'; +import { BusinessError } from '@ohos.base'; +import { logger } from '../util/Logger'; + +const TAG: string = 'SelectMediaType'; +// 获取应用文件路径 +let context = getContext(this) as common.UIAbilityContext; +let baseDir = context.filesDir; +let filesDir = baseDir + '/udmf_test'; + +let class2UTD = new Map([ + ["All", "All"], + ["Images", "general.image"], + ["Audios", "general.audio"], + ["Videos", "general.video"] +]); + +class FileInfo { + filename: string; + iconFile: string; + + constructor(fileName: string, iconFile: string) { + this.filename = fileName; + this.iconFile = iconFile; + } +} + +@Entry +@Component +struct selectMediaType { + @State text: string = "Images"; + @State index: number = 1; + @State space: number = 12; + @State arrowPosition: ArrowPosition = ArrowPosition.END; + @State fileNames: string[] = []; + @State selectedFilesInfos: FileInfo[] = []; + private routerBackUrl: string = 'pages/Index'; + private routerNextUrl: string = 'pages/displayMediaFile'; + + getListFile(): string[] { + let files = fs.listFileSync(filesDir); + return files; + } + + UpdateSelectedFiles(): void { + this.fileNames = this.getListFile(); + for (let i = this.selectedFilesInfos.length - 1; i >= 0; i--) { + this.selectedFilesInfos.pop(); + } + this.selectedFilesInfos = []; + logger.info(TAG, "selectText: " + this.text) + for (let i = 0; i < this.fileNames.length; i++) { + let fileName = this.fileNames[i]; + let index = fileName.lastIndexOf('.'); + if (index < 0) { + logger.info(TAG, `fileNames file: ${fileName}`); + if (this.text == "All") { + let fileInfo = new FileInfo(fileName, ""); + this.selectedFilesInfos.push(fileInfo); + } + continue; + } else { + let fileExtension = fileName.substring(index); + let utd = utdDesc.getUniformDataTypeByFilenameExtension(fileExtension); + logger.info(TAG, `fileNames file: ${fileName}, extension: ${fileExtension}, utd: ${utd}`); + try { + if (utd != null) { + let typeObj: utdDesc.TypeDescriptor = utdDesc.getTypeDescriptor(utd); + if (class2UTD.get(this.text) == "All") { + let fileInfo = new FileInfo(fileName, typeObj.iconFile); + this.selectedFilesInfos.push(fileInfo); + logger.info(TAG, `All type: ${fileInfo.filename}, utd: ${utd}, iconFile: ${fileInfo.iconFile}`); + } else { + let ret = typeObj.belongsTo(class2UTD.get(this.text)); + logger.info(TAG, `typeObj.belongsTo: ${fileName}, utd: ${class2UTD.get(this.text)}, ret: ${ret} iconFile: ${typeObj.iconFile}`); + if (ret) { + let fileInfo = new FileInfo(fileName, typeObj.iconFile); + this.selectedFilesInfos.push(fileInfo); + } + } + } else { + if (class2UTD.get(this.text) == "All") { + let fileInfo = new FileInfo(fileName, ""); + this.selectedFilesInfos.push(fileInfo); + logger.info(TAG, `utd null All type: ${fileInfo.filename}, utd: ${utd}, iconFile: ${fileInfo.iconFile}`); + } + } + } + catch (e) { + let error: BusinessError = e as BusinessError; + logger.error(TAG, `belongsTo throws an exception. code is ${error.code}, message is ${error.message}`); + } + } + } + logger.info(TAG, `all files ${JSON.stringify(this.selectedFilesInfos)}}`); + } + + aboutToAppear() { + logger.info(TAG, 'filesDir: ' + filesDir); + this.UpdateSelectedFiles(); + } + + aboutToDisappear() { + for (let i = this.selectedFilesInfos.length - 1; i >= 0; i--) { + this.selectedFilesInfos.pop(); + } + } + + build() { + Column() { + Column() { + Row() { + Image($r('app.media.utdType_back')) + .id('secondPageBack') + .width(24) + .height(24) + .objectFit(ImageFit.Fill) + .visibility(Visibility.Visible) + .alignSelf(ItemAlign.Auto) + .margin({ left: 24, right: 12 }) + .onClick(() => { + router.pushUrl({ url: this.routerBackUrl }, router.RouterMode.Single); + }) + Text($r('app.string.selectMediaType_title')) + .fontStyle(FontStyle.Normal) + .fontSize(20) + .fontWeight(700) + .textAlign(TextAlign.Start) + .id('titleText') + } + .width('100%') + .height(56) + .alignItems(VerticalAlign.Center) + } + .width(280) + .height(56) + .alignItems(HorizontalAlign.Start) + + Column() { + Select([{ value: 'All', icon: $r('app.media.ic_select_option_collection') }, + { value: 'Images', icon: $r('app.media.ic_select_option_collection') }, + { value: 'Audios', icon: $r('app.media.ic_select_option_collection') }, + { value: 'Videos', icon: $r('app.media.ic_select_option_collection') }]) + .selected(this.index) + .value(this.text) + .id('SelectTypeList') + .font({ size: 16, weight: 500 }) + .fontColor('#182431') + .selectedOptionFont({ size: 16, weight: 500 }) + .optionFont({ size: 16, weight: 500 }) + .space(this.space) + .arrowPosition(this.arrowPosition) + .menuAlign(MenuAlignType.START, { dx: 0, dy: 0 }) + .backgroundColor($r('app.color.background_shallow_grey')) + .onSelect((index: number, text?: string | undefined) => { + this.index = index; + if (text) { + this.text = text; + logger.info(TAG, 'Select type:' + text); + this.UpdateSelectedFiles(); + } + }) + } + .margin({ left: 12, right: 12 }) + .height(48) + .width(160) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Center) + + Column() { + List({ space: 2, initialIndex: 0 }) { + ForEach(this.selectedFilesInfos, (item: FileInfo, no: Number) => { + ListItem() { + Row() { + Column() { + Text(item.filename) + .fontSize(16) + .height(46) + .textAlign(TextAlign.Start) + .margin({ left: 12, right: 12 }) + .fontWeight(500) + .id("textFilename_" + no) + .visibility(Visibility.Visible) + .onClick(() => { + logger.info(TAG, `selected file:` + item.filename + `and clicked`); + try { + router.pushUrl({ + url: this.routerNextUrl, + params: { + src: item.filename, + selectIconFile: item.iconFile + } + }, router.RouterMode.Single); + } + catch (e) { + let error: BusinessError = e as BusinessError; + logger.error(TAG, `select file and router exception. code is ${error.code}, message is ${error.message}`); + } + }) + Divider() + .vertical(false) + .height(2) + .color($r('app.color.background_shallow_grey')) + .opacity(0.6) + .margin({ left: 12, right: 12 }) + } + .width('100%') + .height(48) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + } + .width('100%') + .height(48) + .alignItems(VerticalAlign.Center) + } + .id("listItem_" + no) + }) + } + .listDirection(Axis.Vertical) // 排列方向 + .scrollBar(BarState.Auto) + .friction(0.6) + .margin({ left: 12, right: 12 }) + .borderRadius(24) + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { + logger.info(TAG, 'first: ' + firstIndex); + logger.info(TAG, 'last: ' + lastIndex); + logger.info(TAG, 'center: ' + centerIndex); + }) + .onScroll((scrollOffset: number, scrollState: ScrollState) => { + logger.info(TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset); + }) + .backgroundColor(0xFFFFFF) + } + .width('100%') + .height(680) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Start) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.background_shallow_grey')) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Center) + } +} diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/util/Logger.ts b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/util/Logger.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/module.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/module.json5 old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/element/color.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/file.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/file.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/ic_select_option_collection.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/ic_select_option_collection.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/icon.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/image.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/image.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/myAudio.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/myAudio.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/utdType_back.svg b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/utdType_back.svg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/video.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/video.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/en/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/en/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/zh/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/zh/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/Application/TestAbilityStage.ts b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/Application/TestAbilityStage.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testability/TestAbility.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testability/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/util/Logger.ts b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/util/Logger.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/module.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/element/color.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/media/icon.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/media/icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/profile/test_pages.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/en/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/en/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/zh/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/zh/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-config.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index 3e204d9324..122677b194 --- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-config.json5 @@ -1,6 +1,6 @@ -{ - "hvigorVersion": "3.0.9", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.9" - } +{ + "hvigorVersion": "3.0.9", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.9" + } } \ No newline at end of file diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-wrapper.js b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-wrapper.js old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigorw b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigorw old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigorw.bat b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigorw.bat old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/oh-package.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/oh-package.json5 old mode 100755 new mode 100644 index 3762fe6b2a..368c840c89 --- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/oh-package.json5 +++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "myfile", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "myfile", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/ohosTest.md b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/display_file.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/display_file.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/first.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/first.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/select_type.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/select_type.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/app.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/app.json5 index e621231c39..88e8194488 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/app.json5 +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.example.sensor", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.example.sensor", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/resources/base/element/string.json b/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/resources/base/element/string.json index 27bc1ff1ff..3050b880be 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "Sensor" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "Sensor" + } + ] +} diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/build-profile.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/build-profile.json5 index 7c88aef542..6b7e50621e 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/build-profile.json5 +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/build-profile.json5 @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2023 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": { - "compileSdkVersion": 9, - "compatibleSdkVersion": 9, - "products": [ - { - "name": "default", - "signingConfig": "default", - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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": { + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, + "products": [ + { + "name": "default", + "signingConfig": "default", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/build-profile.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/build-profile.json5 index 0c8525dfdd..910cc991f5 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/build-profile.json5 +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/oh-package.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/oh-package.json5 index 80997033c9..e7aaaec223 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/oh-package.json5 +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": { - "library": "file:../libs/library.har" - } -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": { + "library": "file:../libs/library.har" + } +} diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/ets/entryability/EntryAbility.ts index 202b948c9e..7370b8f327 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import hilog from '@ohos.hilog'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - 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'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + 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/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/module.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/module.json5 index 4dd6059374..370d208a19 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/module.json5 +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/module.json5 @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2023 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": [ - "phone", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.VIBRATE", - } - ] - } +/* + * Copyright (c) 2023 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": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.VIBRATE", + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/resources/base/element/color.json b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/ohosTest/module.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/ohosTest/module.json5 index 259be9c7d7..237ccad18b 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "phone", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/hvigor/hvigor-config.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/hvigor/hvigor-config.json5 index 9fa38552b0..0450bec274 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/hvigor/hvigor-config.json5 @@ -1,6 +1,6 @@ -{ - "hvigorVersion": "2.4.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "2.4.2" - } -} +{ + "hvigorVersion": "2.4.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "2.4.2" + } +} diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/oh-package.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/oh-package.json5 index 8ce88801dd..4dc6591383 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/Capi/oh-package.json5 +++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "sensor", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "sensor", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/.gitignore b/code/BasicFeature/DeviceManagement/Sensor/JsApi/.gitignore new file mode 100644 index 0000000000..fbabf77101 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/.gitignore @@ -0,0 +1,11 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/app.json5 b/code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/app.json5 new file mode 100644 index 0000000000..5470c22e22 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/resources/base/element/string.json b/code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..1080233f01 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + } + ] +} diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/resources/base/media/app_icon.png b/code/BasicFeature/DeviceManagement/Sensor/JsApi/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD_{QVu$(&K6H|C37TG1Am9Re{<<3gd zh@`>;BqkXMW&p0T6rt|iB$)~CvFe(XC)F9WgAZn*0@t$oZo;!*}r@_`h?KKH&6A@3= zISXoQB+~`op>NP-buiA*^0n{@i{_?MRG)&k)c)k_F+-2Lud!S9pc+i`s74NpBCaGF zXN+pHkubw*msGBTY27BKHv)RRh3;nMg4&$fD_6X9Vt~;_4D+5XPH~#Kn-yjcy!$}1 zigv#FNY>TqMhtIBb@UoF!cE~Q8~;!Pek>SQQwHnHuWKoVBosAiOr}q>!>aE*Krc)V zBUMEcJ5NU0g8}-h6i1zpMY9>m4ne?=U2~`w7K7Q0gB_=p@$5K7p6}thw z-~3dMj?YNX2X$lZ+7ngQ$=s}3mizNN@kE%OtB)?c&i~2L55z8^=yz;xMHLmlY>&Q# zJj?!)M#q_SyfkQh)k?j8IfLtB)ZCp|*vf4_B zos?73yd^h-Ac+;?E4*bpf=o*^3x3-`TVjbY4n6!EN10K6o@fxdyps05Vo3PU)otB} z`3kR+2w7_C#8Z!q`J)p{Vh!+m9-UP!$STp+Hb}}#@#_u^SsUQg<}59< zTvH3%XS4G+6FF^(m6bVF&nSUIXcl;nw{=H$%fgeJ>CgDYiLdpDXr{;-AnG z8dvcrHYVMI&`R6;GWekI@Ir3!uo)oz4^{6q0m^}@f2tM9&=YHNi6-?rh0-{+k@cQm zdp`g#YdQn%MDVg2GR>wZ`n2<0l4)9nx1Wfr&!Dvz=bPwU!h2S?ez6MVc5APE4-xLB zi&W9Q8k2@0w!C53g?iAIQ}~p*3O(@zja6KQ=M3zfW*_6o5SwR-)6VBh~m7{^-=MC-owYH5-u40a}a0liho3QZZ5L{bS_xM1)4}19)zTU$$MY zq3eZML1WC{K%YFd`Be0M-rkO^l?h{kM{$2oK1*A@HVJ57*yhDkUF!2WZ&oA4Y-sK( zCY69%#`mBCi6>6uw(x4gbFaP0+FD*JKJ-q!F1E?vLJ+d35!I5d7@^eU?(CS|C^tmI5?lv@s{{*|1F zFg|OzNpZ0hxljdjaW%45O0MOttRrd(Z?h{HYbB-KFUx&9GfFL3b8NwZ$zNu)WbBD` zYkj$^UB5%3Pj1MDr>S2Ejr9pUcgA!;ZG!@{uAy12)vG=*^9-|dNQBc8&`oxBlU~#y zs!anJX&T?57Jdr^sb>e+V`MVfY>Y0ESg7MG<7W0g&bR-ZYzzZ%2H&Etcp zcd6QeXO1D!5A#zM0lx*GH}`M)2~ZFLE;sP^RSB5wVMNfiZXPd(cmO>j=OSA3`o5r& zna(|^jGXbdN7PK)U8b7^zYtYkkeb%<%F~=OqB~kXMQkq}ii|skh@WSRt>5za;cjP0 zZ~nD%6)wzedqE}BMLt~qKwlvTr33))#uP~xyw#*Eaa|DbMQ_%mG0U8numf8)0DX`r zRoG2bM;#g|p-8gWnwRV5SCW0tLjLO&9Z?K>FImeIxlGUgo0Zk`9Qzhj1eco~7XZy+hXc@YF&ZQ=? zn*^1O56yK^x{y}q`j7}blGCx%dydV!c7)g~tJzmHhV=W~jbWRRR{1<^oDK+1clprm zz$eCy7y9+?{E|YgkW~}}iB#I4XoJ*xr8R?i_Hv$=Cof5bo-Nj~f`-DLebH}&0% zfQj9@WGd4;N~Y?mzQsHJTJq6!Qzl^-vwol(+fMt#Pl=Wh#lI5Vmu@QM0=_r+1wHt` z+8WZ~c2}KQQ+q)~2Ki77QvV&`xb|xVcTms99&cD$Zz4+-^R4kvUBxG8gDk7Y`K*)JZ^2rL(+ZWV~%W(@6 z)0bPArG#BROa_PHs~&WplQ_UIrpd)1N1QGPfv!J(Z9jNT#i%H?CE6|pPZb9hJ1JW4 z^q;ft#!HRNV0YgPojzIYT`8LuET2rUe-J|c!9l4`^*;4WtY@Ew@pL>wkjmMgGfN7 ze}}GtmU0@<_#08~I-Suk=^*9GLW=H4xhsml;vAV{%hy5Eegl@!6qKqbG024%n2HHw zCc@ivW_$@5ZoHP70(7D+(`PvgjW1Pd`wsiuv-aCukMrafwDm)B!xXVy*j2opohhoU zcJz%ADmj>i3`-3-$7nQKBQQuGY;2Qt&+(L~C>vSGFj5{Mlv?T_^dql;{zkpe4R1}R z%XfZyQ}wr*sr>jrKgm*PWLjuVc%6&&`Kbf1SuFpHPN&>W)$GmqC;pIoBC`=4-hPY8 zT*>%I2fP}vGW;R=^!1be?ta2UQd2>alOFFbVl;(SQJ4Jk#)4Z0^wpWEVvY4=vyDk@ zqlModi@iVPMC+{?rm=4(n+<;|lmUO@UKYA>EPTS~AndtK^Wy^%#3<;(dQdk3WaUkRtzSMC9}7x2||CNpF#(3T4C)@ z$~RWs`BNABKX|{cmBt>Q=&gkXl&x!!NK_%5hW0LS)Z4PB>%sV?F-{Wyj#s7W%$F{D zXdK^Fp3wvy+48+GP6F_|^PCRx=ddcTO3sG;B23A49~Qaw31SZ0Rc~`r4qqt%#OGW{ zCA_(LG5^N>yzUn&kAgVmxb=EA8s&tBXC}S1CZ(KoW)(%^JjLTPo^fs`Va;`=YlVPgmB$!yB}<(4ym6OeZ3xAJJ#;)2+B%p3P1Wt+d$eo`vz`T zXfUP2))kBDPoscH;Jc7I3NU<({|@wM$&GaDt`n7WLgIY3IA7A6-_R?z8N3mz|}*i z(zl5ot--Oq@f2-nv{X(ujT2T(k1vY_qh93pK@>H-qc%2Xta)IP0Q%zt%bqYgI`o!wv!0QerB`nCN^1n|@$sVOQ!V0teVG!I z_fD%JvfDeT1cK#-{o6Gv7}& zY0#NWin~kVaf$aufV&;63Hbs|`QVZWpDX6IMk1Hj2G}fiH9e-^6u2zf^FIr^BwD<6zjw63+{yUe8PUFvk8v{sJ=R{d#`O!sz`Q13~< zPT$JS(w=yQfU2`zPCNfSw=&zup@DXc(98afjhv@1w_f!m2Z>rMJ19AB&dB%P#Ls3b z=lK7OILM+SQ&VEd=1GN6o&>YVVtIzoZ%=Z_SdqJN2}E43{bE`>w+A;=y->@^k{oCC z$F*WTY&?34;kfyFV?b*Xb1Pq`Z=%OgwEg)Rz)tx=`f%5#w_INP=x&z5!jI;#;N$ma zhO)+MDm;SxOEVL15; zGq(v2pL3&P1Sl)8P*;G-fd{l1QJsv@e@d8)1PK4w2m*M%V3j-V~L^$i|&C@b?D?9tfwE{B^}Z$k8e5FmQ>v7Xz)sG32g9t}YBt zyR$+*_00RmPx+0mW+vVG4mxd(n$(eQf3-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { + 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/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..b2361555ce --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,356 @@ +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import common from '@ohos.app.ability.common'; +import hiTraceMeter from '@ohos.hiTraceMeter'; +import { sensor } from '@kit.SensorServiceKit'; +import { ComponentContent, promptAction, PromptAction, SelectDialog } from '@kit.ArkUI'; +import BusinessError from "@ohos.base"; + +let TAG = 'sensor: ' + +interface CheckRet { + ok: boolean + ret: T + msg?: string +} + +@Entry +@Component +struct SensorList { + @State + private sensorItems: string[] = [] + private sampleRate: number = 200000000 + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + dialogControllerList: CustomDialogController | null = null; + selectedSensorId: number = 0; + @State + private realSensorName: string = '' + @State + private deviceId: number = 0 + private strDeviceId: string = '' + private sensors = new Map(); + @State + private callbackContent:string = "" + @State + private SensorListByDevice:string = "" + SensorListByDeviceList: sensor.Sensor[] = []; + private supportSensorIdList: (number|undefined)[] = [1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 277, 278, 279, 280, 281, 282, 513, 514] + private sensorType = new Map([ + ['sensor_test', 0], + ['ACCELEROMETER', 1], + ['GYROSCOPE', 2], + ['AMBIENT_LIGHT', 5], + ['MAGNETIC_FIELD', 6], + ['CAPACITIVE', 7], + ['BAROMETER', 8], + ['TEMPERATURE', 9], + ['HALL', 10], + ['GESTURE', 11], + ['PROXIMITY', 12], + ['HUMIDITY', 13], + ['COLOR', 14], + ['SAR', 15], + ['AMBIENT_LIGHT1', 16], + ['ORIENTATION', 256], + ['GRAVITY', 257], + ['LINEAR_ACCELEROMETER', 258], + ['ROTATION_VECTOR', 259], + ['AMBIENT_TEMPERATURE', 260], + ['MAGNETIC_FIELD_UNCALIBRATED', 261], + ['GAME_ROTATION_VECTOR', 262], + ['GYROSCOPE_UNCALIBRATED', 263], + ['SIGNIFICANT_MOTION', 264], + ['PEDOMETER_DETECTION', 265], + ['PEDOMETER', 266], + ['POSTURE', 267], + ['HEAD_POSTURE', 268], + ['DROP_DETECTION', 269], + ['GEOMAGNETIC_ROTATION_VECTOR', 277], + ['HEART_RATE', 278], + ['DEVICE_ORIENTATION', 279], + ['WEAR_DETECTION', 280], + ['ACCELEROMETER_UNCALIBRATED', 281], + ]) + + private checkDeviceId(): CheckRet { + if (!this.strDeviceId.length) { + return { ok: false, ret: -1 }; + } + return { ok: true, ret: Number(this.deviceId) }; + } + + sensorStatusChangeCallback = (data: sensor.SensorStatusEvent) => { + console.debug('Succeeded in getting data: ' + JSON.stringify(data)); + } + + onPageShow(): void { + + let traceCount = 0; + console.info(TAG + 'getSensorList in'); + try { + sensor.getSensorList((error, data) => { + if (error) { + console.info(TAG + 'getSensorList failed'); + } else { + console.info(TAG + 'getSensorList call back in'); + hiTraceMeter.startTrace("myTraceTest4", 1004);traceCount++; + hiTraceMeter.traceByValue("myTestCount", traceCount); + for (let i = 0; i < data.length; i++) { + console.info(TAG + "getSensorList " + JSON.stringify(data[i])); + this.sensorItems[i] = data[i].sensorName + this.sensors.set(data[i].sensorName, data[i].sensorId) + } + + } + this.sensorItems.push("第二接近光") + this.sensorItems.push("第二环境光") + this.sensorItems.push("第二加速度") + this.sensors.set("第二接近光", 18) + this.sensors.set("第二环境光", 16) + this.sensors.set("第二加速度", 513) + this.sensors.set("第二陀螺仪", 514) + }); + } catch (e) { + console.info(TAG + "get list exception in2, code:" + e.code + "msg:" + e.message) + console.info(TAG + "get list exception in1, msg:" + JSON.stringify(e)) + + } + console.info(TAG + 'getSensorList left'); + } + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + TextInput({ placeholder: 'Please select sensor type', text: this.realSensorName }) + .placeholderColor("rgb(0,0,225)") + .placeholderFont({ size: 20, weight: 100, family: 'cursive', style: FontStyle.Italic }) + .caretColor(Color.Blue) + .height(50) + .type(InputType.Normal) + .fontSize(20) + .fontWeight(FontWeight.Normal) + .fontFamily("sans-serif") + .fontStyle(FontStyle.Normal) + .fontColor(Color.Black) + .enableKeyboardOnFocus(false) + .textAlign(TextAlign.Center) + .borderStyle(BorderStyle.Solid).borderWidth(1).borderColor("rgb(0,0,225)").borderRadius(10) + .focusable(false) + .onClick(() => { + TextPickerDialog.show({ + range: this.sensorItems, + selected: 0, + onAccept: (result: TextPickerResult) => { + this.realSensorName = result.value.toString(); + }, + onCancel: () => { + // console.info(CommonConstants.MY_TAG, 'TextPickerDialog onCancel'); + } + }); + }) + .width('80%') + .margin({top: 10}) + + TextInput({ placeholder: 'deviceId' }) + .placeholderColor("rgb(0,0,225)") + .placeholderFont({ size: 20, weight: 100, family: 'cursive', style: FontStyle.Italic }) + .caretColor(Color.Blue) + .height(50) + .type(InputType.Number) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .fontFamily("sans-serif") + .fontStyle(FontStyle.Normal) + .fontColor(Color.Red) + .textAlign(TextAlign.Center) + .onChange((value: string) => { + this.deviceId = parseInt(value) + }).width('100%') + .margin({top: 10}) + + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center}) { + Button('订 阅').onClick(() => { + try { + console.info(TAG + this.realSensorName + "订阅 in") + if (!this.supportSensorIdList.includes(this.sensors.get(this.realSensorName))) { + // Utils.toast("This is not support, please change other sensorId!") + return + } + if (this.sensors.get(this.realSensorName) == 265 || this.sensors.get(this.realSensorName) == 266) { //计步器 + console.info(TAG + this.sensors.get(this.realSensorName) + 'on in') + let atManager = abilityAccessCtrl.createAtManager(); + let context = getContext(this) as common.UIAbilityContext + atManager.requestPermissionsFromUser(context, ["ohos.permission.ACTIVITY_MOTION"], (err, data)=>{ + if (err) { + console.info(TAG + "grant ACTIVITY_MOTION failed:" + JSON.stringify(data)); + return; + } + console.info(TAG + "data:" + JSON.stringify(data)); + console.info(TAG + "data permissions:" + data.permissions); + console.info(TAG + "data authResults:" + data.authResults); + sensor.getSingleSensor(this.sensors.get(this.realSensorName), (err, data) => { + if(err) { + console.error(TAG + JSON.stringify(err)) + return; + } + if(data) { + sensor.on(this.sensors.get(this.realSensorName), (data:sensor.Response)=>{ + console.info(TAG + "PEDOMETER: " + JSON.stringify(data)); + this.callbackContent = JSON.stringify(data) + }) + } else { + console.info(TAG + 'Program run failed'); + } + }); + }); + console.info(TAG + this.sensors.get(this.realSensorName) + 'on left') + } else if(this.sensors.get(this.realSensorName) == 278) { + console.info(TAG + this.sensors.get(this.realSensorName) + 'on in') + let atManager = abilityAccessCtrl.createAtManager(); + let context = getContext(this) as common.UIAbilityContext + atManager.requestPermissionsFromUser(context, ["ohos.permission.READ_HEALTH_DATA"], (err, data)=>{ + if (err) { + console.info(TAG + "grant READ_HEALTH_DATA failed:" + JSON.stringify(data)); + return; + } + console.info(TAG + "data:" + JSON.stringify(data)); + console.info(TAG + "data permissions:" + data.permissions); + console.info(TAG + "data authResults:" + data.authResults); + sensor.getSingleSensor(this.sensors.get(this.realSensorName), (err, data) => { + if(err) { + console.error(TAG + JSON.stringify(err)) + return; + } + if(data) { + sensor.on(this.sensors.get(this.realSensorName), (data:sensor.Response)=>{ + console.info(TAG + "PEDOMETER: " + JSON.stringify(data)); + this.callbackContent = JSON.stringify(data) + }) + } else { + console.info(TAG + 'Program run failed'); + } + }); + }); + } else { //普通sensor + console.info('wzh before') + let countSame:number = 0; + let timestamp:number = 0; + let countSame2:number = 0; + let timestamp2:number = 0; + sensor.on(this.sensors.get(this.realSensorName), ((data:sensor.Response) => { + console.info(TAG + "callback: " + JSON.stringify(data)); + this.callbackContent = JSON.stringify(data) + if (data.timestamp - timestamp == 0) { + countSame = countSame + 1; + console.info(TAG + "callbackcountSame: " + JSON.stringify(data)); + } + timestamp = data.timestamp; + }), {'interval': this.sampleRate}); + console.info('wzh left') + + } + }catch(e) { + console.info(TAG + "订阅exception in,msg:" + JSON.stringify(e)) + console.info(TAG + "取消订阅exception in,code:" + e.code + "msg:" + e.message) + } + }) + + Button('取消订阅').onClick(() => { + console.info(TAG + "取消订阅 in") + try { + sensor.off(this.sensors.get(this.realSensorName)) + }catch(e) { + console.info(TAG + "取消订阅exception in,msg:" + JSON.stringify(e)) + } + this.callbackContent = "" + }) + + Button('getSensorListByDeviceSync') + .onClick(() => { + console.info(TAG + "getSensorListByDeviceSync in") + try { + let sensorInfoList = sensor.getSensorListByDeviceSync(); + this.SensorListByDevice = 'sensorInfoList:' + JSON.stringify(sensorInfoList); + this.SensorListByDeviceList = sensorInfoList; + console.info(TAG + "取消订阅exception in,msg:" + JSON.stringify(sensorInfoList)) + } catch (err) { + console.error("Error occurred: " + JSON.stringify(err)); + } + }) + + Button('getSingleSensorByDeviceSync') + .onClick(() => { + if (!this.SensorListByDevice.length) { + this.promptAction.showToast({ + message: "请先点击上面的getSensorListByDeviceSync.", + duration: 2000 + }); + return; + } + this.dialogControllerList = new CustomDialogController({ + autoCancel: false, + builder: SelectDialog({ + title: '选择SensorId', + selectedIndex: this.selectedSensorId, + radioContent: this.SensorListByDeviceList.map((sensorInfo: sensor.Sensor) => { + return { + title: `${sensorInfo.sensorName}_${sensorInfo.sensorId}`, + action: async () => { + this.selectedSensorId = sensorInfo.sensorId; + try { + const checkRet = this.checkDeviceId(); + const data = sensor.getSingleSensorByDeviceSync(this.selectedSensorId, + checkRet.ok ? checkRet.ret : undefined); + this.SensorListByDevice = 'sensorInfoList:' + JSON.stringify(data); + } catch (error) { + console.error("Error occurred: " + JSON.stringify(error)); + } + } + } as SheetInfo + }), + }), + }) + this.dialogControllerList.open(); + }) + + Button("on SensorStatusChange").fontSize(16).fontWeight(FontWeight.Bold).width('100%') + .onClick(() => { + console.info("sensor.on('SensorStatusChange')"); + try { + sensor.on('sensorStatusChange', this.sensorStatusChangeCallback); + this.callbackContent = 'on:sensorStatusChange' + } catch (error) { + let e: BusinessError.BusinessError = error as BusinessError.BusinessError; + console.error(`Failed to invoke on. Code: ${e.code}, message: ${e.message}`); + } + }) + + Button("off SensorStatusChange").fontSize(16).fontWeight(FontWeight.Bold).width('100%') + .onClick(() => { + try { + sensor.off('sensorStatusChange', this.sensorStatusChangeCallback); + this.callbackContent = 'off:sensorStatusChange' + } catch (error) { + let e: BusinessError.BusinessError = error as BusinessError.BusinessError; + console.error(`Failed to invoke on. Code: ${e.code}, message: ${e.message}`); + } + }) + + Button('clean') + .onClick(() => { + this.SensorListByDevice = '' + }) + + + }.margin({top: 20}) + + Text(`${this.callbackContent}`) + .fontSize(20) + .margin({ top: 20 }) + + Text(`${this.SensorListByDevice}`) + .fontSize(20) + .margin({ top: 20 }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/module.json5 b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/module.json5 new file mode 100644 index 0000000000..3e0fd3cee3 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/module.json5 @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/color.json b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/resources/base/element/color.json similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/color.json rename to code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/resources/base/element/color.json diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/resources/base/element/string.json b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..f94595515a --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/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": "label" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/resources/base/media/icon.png b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD_{QVu$(&K6H|C37TG1Am9Re{<<3gd zh@`>;BqkXMW&p0T6rt|iB$)~CvFe(XC)F9WgAZn*0@t$oZo;!*}r@_`h?KKH&6A@3= zISXoQB+~`op>NP-buiA*^0n{@i{_?MRG)&k)c)k_F+-2Lud!S9pc+i`s74NpBCaGF zXN+pHkubw*msGBTY27BKHv)RRh3;nMg4&$fD_6X9Vt~;_4D+5XPH~#Kn-yjcy!$}1 zigv#FNY>TqMhtIBb@UoF!cE~Q8~;!Pek>SQQwHnHuWKoVBosAiOr}q>!>aE*Krc)V zBUMEcJ5NU0g8}-h6i1zpMY9>m4ne?=U2~`w7K7Q0gB_=p@$5K7p6}thw z-~3dMj?YNX2X$lZ+7ngQ$=s}3mizNN@kE%OtB)?c&i~2L55z8^=yz;xMHLmlY>&Q# zJj?!)M#q_SyfkQh)k?j8IfLtB)ZCp|*vf4_B zos?73yd^h-Ac+;?E4*bpf=o*^3x3-`TVjbY4n6!EN10K6o@fxdyps05Vo3PU)otB} z`3kR+2w7_C#8Z!q`J)p{Vh!+m9-UP!$STp+Hb}}#@#_u^SsUQg<}59< zTvH3%XS4G+6FF^(m6bVF&nSUIXcl;nw{=H$%fgeJ>CgDYiLdpDXr{;-AnG z8dvcrHYVMI&`R6;GWekI@Ir3!uo)oz4^{6q0m^}@f2tM9&=YHNi6-?rh0-{+k@cQm zdp`g#YdQn%MDVg2GR>wZ`n2<0l4)9nx1Wfr&!Dvz=bPwU!h2S?ez6MVc5APE4-xLB zi&W9Q8k2@0w!C53g?iAIQ}~p*3O(@zja6KQ=M3zfW*_6o5SwR-)6VBh~m7{^-=MC-owYH5-u40a}a0liho3QZZ5L{bS_xM1)4}19)zTU$$MY zq3eZML1WC{K%YFd`Be0M-rkO^l?h{kM{$2oK1*A@HVJ57*yhDkUF!2WZ&oA4Y-sK( zCY69%#`mBCi6>6uw(x4gbFaP0+FD*JKJ-q!F1E?vLJ+d35!I5d7@^eU?(CS|C^tmI5?lv@s{{*|1F zFg|OzNpZ0hxljdjaW%45O0MOttRrd(Z?h{HYbB-KFUx&9GfFL3b8NwZ$zNu)WbBD` zYkj$^UB5%3Pj1MDr>S2Ejr9pUcgA!;ZG!@{uAy12)vG=*^9-|dNQBc8&`oxBlU~#y zs!anJX&T?57Jdr^sb>e+V`MVfY>Y0ESg7MG<7W0g&bR-ZYzzZ%2H&Etcp zcd6QeXO1D!5A#zM0lx*GH}`M)2~ZFLE;sP^RSB5wVMNfiZXPd(cmO>j=OSA3`o5r& zna(|^jGXbdN7PK)U8b7^zYtYkkeb%<%F~=OqB~kXMQkq}ii|skh@WSRt>5za;cjP0 zZ~nD%6)wzedqE}BMLt~qKwlvTr33))#uP~xyw#*Eaa|DbMQ_%mG0U8numf8)0DX`r zRoG2bM;#g|p-8gWnwRV5SCW0tLjLO&9Z?K>FImeIxlGUgo0Zk`9Qzhj1eco~7XZy+hXc@YF&ZQ=? zn*^1O56yK^x{y}q`j7}blGCx%dydV!c7)g~tJzmHhV=W~jbWRRR{1<^oDK+1clprm zz$eCy7y9+?{E|YgkW~}}iB#I4XoJ*xr8R?i_Hv$=Cof5bo-Nj~f`-DLebH}&0% zfQj9@WGd4;N~Y?mzQsHJTJq6!Qzl^-vwol(+fMt#Pl=Wh#lI5Vmu@QM0=_r+1wHt` z+8WZ~c2}KQQ+q)~2Ki77QvV&`xb|xVcTms99&cD$Zz4+-^R4kvUBxG8gDk7Y`K*)JZ^2rL(+ZWV~%W(@6 z)0bPArG#BROa_PHs~&WplQ_UIrpd)1N1QGPfv!J(Z9jNT#i%H?CE6|pPZb9hJ1JW4 z^q;ft#!HRNV0YgPojzIYT`8LuET2rUe-J|c!9l4`^*;4WtY@Ew@pL>wkjmMgGfN7 ze}}GtmU0@<_#08~I-Suk=^*9GLW=H4xhsml;vAV{%hy5Eegl@!6qKqbG024%n2HHw zCc@ivW_$@5ZoHP70(7D+(`PvgjW1Pd`wsiuv-aCukMrafwDm)B!xXVy*j2opohhoU zcJz%ADmj>i3`-3-$7nQKBQQuGY;2Qt&+(L~C>vSGFj5{Mlv?T_^dql;{zkpe4R1}R z%XfZyQ}wr*sr>jrKgm*PWLjuVc%6&&`Kbf1SuFpHPN&>W)$GmqC;pIoBC`=4-hPY8 zT*>%I2fP}vGW;R=^!1be?ta2UQd2>alOFFbVl;(SQJ4Jk#)4Z0^wpWEVvY4=vyDk@ zqlModi@iVPMC+{?rm=4(n+<;|lmUO@UKYA>EPTS~AndtK^Wy^%#3<;(dQdk3WaUkRtzSMC9}7x2||CNpF#(3T4C)@ z$~RWs`BNABKX|{cmBt>Q=&gkXl&x!!NK_%5hW0LS)Z4PB>%sV?F-{Wyj#s7W%$F{D zXdK^Fp3wvy+48+GP6F_|^PCRx=ddcTO3sG;B23A49~Qaw31SZ0Rc~`r4qqt%#OGW{ zCA_(LG5^N>yzUn&kAgVmxb=EA8s&tBXC}S1CZ(KoW)(%^JjLTPo^fs`Va;`=YlVPgmB$!yB}<(4ym6OeZ3xAJJ#;)2+B%p3P1Wt+d$eo`vz`T zXfUP2))kBDPoscH;Jc7I3NU<({|@wM$&GaDt`n7WLgIY3IA7A6-_R?z8N3mz|}*i z(zl5ot--Oq@f2-nv{X(ujT2T(k1vY_qh93pK@>H-qc%2Xta)IP0Q%zt%bqYgI`o!wv!0QerB`nCN^1n|@$sVOQ!V0teVG!I z_fD%JvfDeT1cK#-{o6Gv7}& zY0#NWin~kVaf$aufV&;63Hbs|`QVZWpDX6IMk1Hj2G}fiH9e-^6u2zf^FIr^BwD<6zjw63+{yUe8PUFvk8v{sJ=R{d#`O!sz`Q13~< zPT$JS(w=yQfU2`zPCNfSw=&zup@DXc(98afjhv@1w_f!m2Z>rMJ19AB&dB%P#Ls3b z=lK7OILM+SQ&VEd=1GN6o&>YVVtIzoZ%=Z_SdqJN2}E43{bE`>w+A;=y->@^k{oCC z$F*WTY&?34;kfyFV?b*Xb1Pq`Z=%OgwEg)Rz)tx=`f%5#w_INP=x&z5!jI;#;N$ma zhO)+MDm;SxOEVL15; zGq(v2pL3&P1Sl)8P*;G-fd{l1QJsv@e@d8)1PK4w2m*M%V3j-V~L^$i|&C@b?D?9tfwE{B^}Z$k8e5FmQ>v7Xz)sG32g9t}YBt zyR$+*_00RmPx+0mW+vVG4mxd(n$(eQf3-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { + 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() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000000..166366593a --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,34 @@ +import hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000..92a16d84e8 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,49 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/module.json5 b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c031340ae7 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/module.json5 @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/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/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000000..65d8fa5a7c --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/media/icon.png b/code/BasicFeature/DeviceManagement/Sensor/JsApi/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD_{QVu$(&K6H|C37TG1Am9Re{<<3gd zh@`>;BqkXMW&p0T6rt|iB$)~CvFe(XC)F9WgAZn*0@t$oZo;!*}r@_`h?KKH&6A@3= zISXoQB+~`op>NP-buiA*^0n{@i{_?MRG)&k)c)k_F+-2Lud!S9pc+i`s74NpBCaGF zXN+pHkubw*msGBTY27BKHv)RRh3;nMg4&$fD_6X9Vt~;_4D+5XPH~#Kn-yjcy!$}1 zigv#FNY>TqMhtIBb@UoF!cE~Q8~;!Pek>SQQwHnHuWKoVBosAiOr}q>!>aE*Krc)V zBUMEcJ5NU0g8}-h6i1zpMY9>m4ne?=U2~`w7K7Q0gB_=p@$5K7p6}thw z-~3dMj?YNX2X$lZ+7ngQ$=s}3mizNN@kE%OtB)?c&i~2L55z8^=yz;xMHLmlY>&Q# zJj?!)M#q_SyfkQh)k?j8IfLtB)ZCp|*vf4_B zos?73yd^h-Ac+;?E4*bpf=o*^3x3-`TVjbY4n6!EN10K6o@fxdyps05Vo3PU)otB} z`3kR+2w7_C#8Z!q`J)p{Vh!+m9-UP!$STp+Hb}}#@#_u^SsUQg<}59< zTvH3%XS4G+6FF^(m6bVF&nSUIXcl;nw{=H$%fgeJ>CgDYiLdpDXr{;-AnG z8dvcrHYVMI&`R6;GWekI@Ir3!uo)oz4^{6q0m^}@f2tM9&=YHNi6-?rh0-{+k@cQm zdp`g#YdQn%MDVg2GR>wZ`n2<0l4)9nx1Wfr&!Dvz=bPwU!h2S?ez6MVc5APE4-xLB zi&W9Q8k2@0w!C53g?iAIQ}~p*3O(@zja6KQ=M3zfW*_6o5SwR-)6VBh~m7{^-=MC-owYH5-u40a}a0liho3QZZ5L{bS_xM1)4}19)zTU$$MY zq3eZML1WC{K%YFd`Be0M-rkO^l?h{kM{$2oK1*A@HVJ57*yhDkUF!2WZ&oA4Y-sK( zCY69%#`mBCi6>6uw(x4gbFaP0+FD*JKJ-q!F1E?vLJ+d35!I5d7@^eU?(CS|C^tmI5?lv@s{{*|1F zFg|OzNpZ0hxljdjaW%45O0MOttRrd(Z?h{HYbB-KFUx&9GfFL3b8NwZ$zNu)WbBD` zYkj$^UB5%3Pj1MDr>S2Ejr9pUcgA!;ZG!@{uAy12)vG=*^9-|dNQBc8&`oxBlU~#y zs!anJX&T?57Jdr^sb>e+V`MVfY>Y0ESg7MG<7W0g&bR-ZYzzZ%2H&Etcp zcd6QeXO1D!5A#zM0lx*GH}`M)2~ZFLE;sP^RSB5wVMNfiZXPd(cmO>j=OSA3`o5r& zna(|^jGXbdN7PK)U8b7^zYtYkkeb%<%F~=OqB~kXMQkq}ii|skh@WSRt>5za;cjP0 zZ~nD%6)wzedqE}BMLt~qKwlvTr33))#uP~xyw#*Eaa|DbMQ_%mG0U8numf8)0DX`r zRoG2bM;#g|p-8gWnwRV5SCW0tLjLO&9Z?K>FImeIxlGUgo0Zk`9Qzhj1eco~7XZy+hXc@YF&ZQ=? zn*^1O56yK^x{y}q`j7}blGCx%dydV!c7)g~tJzmHhV=W~jbWRRR{1<^oDK+1clprm zz$eCy7y9+?{E|YgkW~}}iB#I4XoJ*xr8R?i_Hv$=Cof5bo-Nj~f`-DLebH}&0% zfQj9@WGd4;N~Y?mzQsHJTJq6!Qzl^-vwol(+fMt#Pl=Wh#lI5Vmu@QM0=_r+1wHt` z+8WZ~c2}KQQ+q)~2Ki77QvV&`xb|xVcTms99&cD$Zz4+-^R4kvUBxG8gDk7Y`K*)JZ^2rL(+ZWV~%W(@6 z)0bPArG#BROa_PHs~&WplQ_UIrpd)1N1QGPfv!J(Z9jNT#i%H?CE6|pPZb9hJ1JW4 z^q;ft#!HRNV0YgPojzIYT`8LuET2rUe-J|c!9l4`^*;4WtY@Ew@pL>wkjmMgGfN7 ze}}GtmU0@<_#08~I-Suk=^*9GLW=H4xhsml;vAV{%hy5Eegl@!6qKqbG024%n2HHw zCc@ivW_$@5ZoHP70(7D+(`PvgjW1Pd`wsiuv-aCukMrafwDm)B!xXVy*j2opohhoU zcJz%ADmj>i3`-3-$7nQKBQQuGY;2Qt&+(L~C>vSGFj5{Mlv?T_^dql;{zkpe4R1}R z%XfZyQ}wr*sr>jrKgm*PWLjuVc%6&&`Kbf1SuFpHPN&>W)$GmqC;pIoBC`=4-hPY8 zT*>%I2fP}vGW;R=^!1be?ta2UQd2>alOFFbVl;(SQJ4Jk#)4Z0^wpWEVvY4=vyDk@ zqlModi@iVPMC+{?rm=4(n+<;|lmUO@UKYA>EPTS~AndtK^Wy^%#3<;(dQdk3WaUkRtzSMC9}7x2||CNpF#(3T4C)@ z$~RWs`BNABKX|{cmBt>Q=&gkXl&x!!NK_%5hW0LS)Z4PB>%sV?F-{Wyj#s7W%$F{D zXdK^Fp3wvy+48+GP6F_|^PCRx=ddcTO3sG;B23A49~Qaw31SZ0Rc~`r4qqt%#OGW{ zCA_(LG5^N>yzUn&kAgVmxb=EA8s&tBXC}S1CZ(KoW)(%^JjLTPo^fs`Va;`=YlVPgmB$!yB}<(4ym6OeZ3xAJJ#;)2+B%p3P1Wt+d$eo`vz`T zXfUP2))kBDPoscH;Jc7I3NU<({|@wM$&GaDt`n7WLgIY3IA7A6-_R?z8N3mz|}*i z(zl5ot--Oq@f2-nv{X(ujT2T(k1vY_qh93pK@>H-qc%2Xta)IP0Q%zt%bqYgI`o!wv!0QerB`nCN^1n|@$sVOQ!V0teVG!I z_fD%JvfDeT1cK#-{o6Gv7}& zY0#NWin~kVaf$aufV&;63Hbs|`QVZWpDX6IMk1Hj2G}fiH9e-^6u2zf^FIr^BwD<6zjw63+{yUe8PUFvk8v{sJ=R{d#`O!sz`Q13~< zPT$JS(w=yQfU2`zPCNfSw=&zup@DXc(98afjhv@1w_f!m2Z>rMJ19AB&dB%P#Ls3b z=lK7OILM+SQ&VEd=1GN6o&>YVVtIzoZ%=Z_SdqJN2}E43{bE`>w+A;=y->@^k{oCC z$F*WTY&?34;kfyFV?b*Xb1Pq`Z=%OgwEg)Rz)tx=`f%5#w_INP=x&z5!jI;#;N$ma zhO)+MDm;SxOEVL15; zGq(v2pL3&P1Sl)8P*;G-fd{l1QJsv@e@d8)1PK4w2m*M%V3j-V~L^$i|&C@b?D?9tfwE{B^}Z$k8e5FmQ>v7Xz)sG32g9t}YBt zyR$+*_00RmPx+0mW+vVG4mxd(n$(eQf3-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y="a"&&e<="z"||e>="A"&&e<="Z"||"$"===e||"_"===e||te.Unicode.ID_Start.test(e))}static isIdContinueChar(e){return"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"$"===e||"_"===e||"‌"===e||"‍"===e||te.Unicode.ID_Continue.test(e))}static isDigitWithoutZero(e){return/[1-9]/.test(e)}static isDigit(e){return"string"==typeof e&&/[0-9]/.test(e)}static isHexDigit(e){return"string"==typeof e&&/[0-9A-Fa-f]/.test(e)}};var ne={},re={fromCallback:function(e){return Object.defineProperty((function(...t){if("function"!=typeof t[t.length-1])return new Promise(((n,r)=>{e.call(this,...t,((e,t)=>null!=e?r(e):n(t)))}));e.apply(this,t)}),"name",{value:e.name})},fromPromise:function(e){return Object.defineProperty((function(...t){const n=t[t.length-1];if("function"!=typeof n)return e.apply(this,t);e.apply(this,t.slice(0,-1)).then((e=>n(null,e)),n)}),"name",{value:e.name})}},ue=y.default,oe=process.cwd,ie=null,se=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ie||(ie=oe.call(process)),ie};try{process.cwd()}catch(e){}if("function"==typeof process.chdir){var ce=process.chdir;process.chdir=function(e){ie=null,ce.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ce)}var ae=function(e){ue.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(e){e.lchmod=function(t,n,r){e.open(t,ue.O_WRONLY|ue.O_SYMLINK,n,(function(t,u){t?r&&r(t):e.fchmod(u,n,(function(t){e.close(u,(function(e){r&&r(t||e)}))}))}))},e.lchmodSync=function(t,n){var r,u=e.openSync(t,ue.O_WRONLY|ue.O_SYMLINK,n),o=!0;try{r=e.fchmodSync(u,n),o=!1}finally{if(o)try{e.closeSync(u)}catch(e){}else e.closeSync(u)}return r}}(e);e.lutimes||function(e){ue.hasOwnProperty("O_SYMLINK")&&e.futimes?(e.lutimes=function(t,n,r,u){e.open(t,ue.O_SYMLINK,(function(t,o){t?u&&u(t):e.futimes(o,n,r,(function(t){e.close(o,(function(e){u&&u(t||e)}))}))}))},e.lutimesSync=function(t,n,r){var u,o=e.openSync(t,ue.O_SYMLINK),i=!0;try{u=e.futimesSync(o,n,r),i=!1}finally{if(i)try{e.closeSync(o)}catch(e){}else e.closeSync(o)}return u}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}(e);e.chown=r(e.chown),e.fchown=r(e.fchown),e.lchown=r(e.lchown),e.chmod=t(e.chmod),e.fchmod=t(e.fchmod),e.lchmod=t(e.lchmod),e.chownSync=u(e.chownSync),e.fchownSync=u(e.fchownSync),e.lchownSync=u(e.lchownSync),e.chmodSync=n(e.chmodSync),e.fchmodSync=n(e.fchmodSync),e.lchmodSync=n(e.lchmodSync),e.stat=o(e.stat),e.fstat=o(e.fstat),e.lstat=o(e.lstat),e.statSync=i(e.statSync),e.fstatSync=i(e.fstatSync),e.lstatSync=i(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){});e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){});"win32"===se&&(e.rename="function"!=typeof e.rename?e.rename:function(t){function n(n,r,u){var o=Date.now(),i=0;t(n,r,(function s(c){if(c&&("EACCES"===c.code||"EPERM"===c.code||"EBUSY"===c.code)&&Date.now()-o<6e4)return setTimeout((function(){e.stat(r,(function(e,o){e&&"ENOENT"===e.code?t(n,r,s):u(c)}))}),i),void(i<100&&(i+=10));u&&u(c)}))}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.rename));function t(t){return t?function(n,r,u){return t.call(e,n,r,(function(e){s(e)&&(e=null),u&&u.apply(this,arguments)}))}:t}function n(t){return t?function(n,r){try{return t.call(e,n,r)}catch(e){if(!s(e))throw e}}:t}function r(t){return t?function(n,r,u,o){return t.call(e,n,r,u,(function(e){s(e)&&(e=null),o&&o.apply(this,arguments)}))}:t}function u(t){return t?function(n,r,u){try{return t.call(e,n,r,u)}catch(e){if(!s(e))throw e}}:t}function o(t){return t?function(n,r,u){function o(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),u&&u.apply(this,arguments)}return"function"==typeof r&&(u=r,r=null),r?t.call(e,n,r,o):t.call(e,n,o)}:t}function i(t){return t?function(n,r){var u=r?t.call(e,n,r):t.call(e,n);return u&&(u.uid<0&&(u.uid+=4294967296),u.gid<0&&(u.gid+=4294967296)),u}:t}function s(e){return!e||("ENOSYS"===e.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==e.code&&"EPERM"!==e.code))}e.read="function"!=typeof e.read?e.read:function(t){function n(n,r,u,o,i,s){var c;if(s&&"function"==typeof s){var a=0;c=function(l,f,d){if(l&&"EAGAIN"===l.code&&a<10)return a++,t.call(e,n,r,u,o,i,c);s.apply(this,arguments)}}return t.call(e,n,r,u,o,i,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.read),e.readSync="function"!=typeof e.readSync?e.readSync:(c=e.readSync,function(t,n,r,u,o){for(var i=0;;)try{return c.call(e,t,n,r,u,o)}catch(e){if("EAGAIN"===e.code&&i<10){i++;continue}throw e}});var c};var le=C.default.Stream,fe=function(e){return{ReadStream:function t(n,r){if(!(this instanceof t))return new t(n,r);le.call(this);var u=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var o=Object.keys(r),i=0,s=o.length;ithis.end)throw new Error("start must be <= end");this.pos=this.start}if(null!==this.fd)return void process.nextTick((function(){u._read()}));e.open(this.path,this.flags,this.mode,(function(e,t){if(e)return u.emit("error",e),void(u.readable=!1);u.fd=t,u.emit("open",t),u._read()}))},WriteStream:function t(n,r){if(!(this instanceof t))return new t(n,r);le.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var u=Object.keys(r),o=0,i=u.length;o= zero");this.pos=this.start}this.busy=!1,this._queue=[],null===this.fd&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}};var de=function(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Object)var t={__proto__:De(e)};else t=Object.create(null);return Object.getOwnPropertyNames(e).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})),t},De=Object.getPrototypeOf||function(e){return e.__proto__};var pe,Ee,me=D.default,he=ae,ye=fe,Ce=de,Fe=F.default;function ge(e,t){Object.defineProperty(e,pe,{get:function(){return t}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(pe=Symbol.for("graceful-fs.queue"),Ee=Symbol.for("graceful-fs.previous")):(pe="___graceful-fs.queue",Ee="___graceful-fs.previous");var Ae=function(){};if(Fe.debuglog?Ae=Fe.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Ae=function(){var e=Fe.format.apply(Fe,arguments);e="GFS4: "+e.split(/\n/).join("\nGFS4: "),console.error(e)}),!me[pe]){var ve=w[pe]||[];ge(me,ve),me.close=function(e){function t(t,n){return e.call(me,t,(function(e){e||_e(),"function"==typeof n&&n.apply(this,arguments)}))}return Object.defineProperty(t,Ee,{value:e}),t}(me.close),me.closeSync=function(e){function t(t){e.apply(me,arguments),_e()}return Object.defineProperty(t,Ee,{value:e}),t}(me.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",(function(){Ae(me[pe]),g.default.equal(me[pe].length,0)}))}w[pe]||ge(w,me[pe]);var Se,we=Oe(Ce(me));function Oe(e){he(e),e.gracefulify=Oe,e.createReadStream=function(t,n){return new e.ReadStream(t,n)},e.createWriteStream=function(t,n){return new e.WriteStream(t,n)};var t=e.readFile;e.readFile=function(e,n,r){"function"==typeof n&&(r=n,n=null);return function e(n,r,u,o){return t(n,r,(function(t){!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?"function"==typeof u&&u.apply(this,arguments):be([e,[n,r,u],t,o||Date.now(),Date.now()])}))}(e,n,r)};var n=e.writeFile;e.writeFile=function(e,t,r,u){"function"==typeof r&&(u=r,r=null);return function e(t,r,u,o,i){return n(t,r,u,(function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,r,u,o],n,i||Date.now(),Date.now()])}))}(e,t,r,u)};var r=e.appendFile;r&&(e.appendFile=function(e,t,n,u){"function"==typeof n&&(u=n,n=null);return function e(t,n,u,o,i){return r(t,n,u,(function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,n,u,o],r,i||Date.now(),Date.now()])}))}(e,t,n,u)});var u=e.copyFile;u&&(e.copyFile=function(e,t,n,r){"function"==typeof n&&(r=n,n=0);return function e(t,n,r,o,i){return u(t,n,r,(function(u){!u||"EMFILE"!==u.code&&"ENFILE"!==u.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,n,r,o],u,i||Date.now(),Date.now()])}))}(e,t,n,r)});var o=e.readdir;e.readdir=function(e,t,n){"function"==typeof t&&(n=t,t=null);var r=i.test(process.version)?function(e,t,n,r){return o(e,u(e,t,n,r))}:function(e,t,n,r){return o(e,t,u(e,t,n,r))};return r(e,t,n);function u(e,t,n,u){return function(o,i){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?(i&&i.sort&&i.sort(),"function"==typeof n&&n.call(this,o,i)):be([r,[e,t,n],o,u||Date.now(),Date.now()])}}};var i=/^v[0-5]\./;if("v0.8"===process.version.substr(0,4)){var s=ye(e);d=s.ReadStream,D=s.WriteStream}var c=e.ReadStream;c&&(d.prototype=Object.create(c.prototype),d.prototype.open=function(){var e=this;E(e.path,e.flags,e.mode,(function(t,n){t?(e.autoClose&&e.destroy(),e.emit("error",t)):(e.fd=n,e.emit("open",n),e.read())}))});var a=e.WriteStream;a&&(D.prototype=Object.create(a.prototype),D.prototype.open=function(){var e=this;E(e.path,e.flags,e.mode,(function(t,n){t?(e.destroy(),e.emit("error",t)):(e.fd=n,e.emit("open",n))}))}),Object.defineProperty(e,"ReadStream",{get:function(){return d},set:function(e){d=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return D},set:function(e){D=e},enumerable:!0,configurable:!0});var l=d;Object.defineProperty(e,"FileReadStream",{get:function(){return l},set:function(e){l=e},enumerable:!0,configurable:!0});var f=D;function d(e,t){return this instanceof d?(c.apply(this,arguments),this):d.apply(Object.create(d.prototype),arguments)}function D(e,t){return this instanceof D?(a.apply(this,arguments),this):D.apply(Object.create(D.prototype),arguments)}Object.defineProperty(e,"FileWriteStream",{get:function(){return f},set:function(e){f=e},enumerable:!0,configurable:!0});var p=e.open;function E(e,t,n,r){return"function"==typeof n&&(r=n,n=null),function e(t,n,r,u,o){return p(t,n,r,(function(i,s){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?"function"==typeof u&&u.apply(this,arguments):be([e,[t,n,r,u],i,o||Date.now(),Date.now()])}))}(e,t,n,r)}return e.open=E,e}function be(e){Ae("ENQUEUE",e[0].name,e[1]),me[pe].push(e),Be()}function _e(){for(var e=Date.now(),t=0;t2&&(me[pe][t][3]=e,me[pe][t][4]=e);Be()}function Be(){if(clearTimeout(Se),Se=void 0,0!==me[pe].length){var e=me[pe].shift(),t=e[0],n=e[1],r=e[2],u=e[3],o=e[4];if(void 0===u)Ae("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-u>=6e4){Ae("TIMEOUT",t.name,n);var i=n.pop();"function"==typeof i&&i.call(null,r)}else{var s=Date.now()-o,c=Math.max(o-u,1);s>=Math.min(1.2*c,100)?(Ae("RETRY",t.name,n),t.apply(null,n.concat([u]))):me[pe].push(e)}void 0===Se&&(Se=setTimeout(Be,0))}}process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!me.__patched&&(we=Oe(me),me.__patched=!0),function(e){const t=re.fromCallback,n=we,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter((e=>"function"==typeof n[e]));Object.assign(e,n),r.forEach((r=>{e[r]=t(n[r])})),e.realpath.native=t(n.realpath.native),e.exists=function(e,t){return"function"==typeof t?n.exists(e,t):new Promise((t=>n.exists(e,t)))},e.read=function(e,t,r,u,o,i){return"function"==typeof i?n.read(e,t,r,u,o,i):new Promise(((i,s)=>{n.read(e,t,r,u,o,((e,t,n)=>{if(e)return s(e);i({bytesRead:t,buffer:n})}))}))},e.write=function(e,t,...r){return"function"==typeof r[r.length-1]?n.write(e,t,...r):new Promise(((u,o)=>{n.write(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffer:n})}))}))},"function"==typeof n.writev&&(e.writev=function(e,t,...r){return"function"==typeof r[r.length-1]?n.writev(e,t,...r):new Promise(((u,o)=>{n.writev(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffers:n})}))}))})}(ne);var Pe={},ke={};const xe=p.default;ke.checkPath=function(e){if("win32"===process.platform){if(/[<>:"|?*]/.test(e.replace(xe.parse(e).root,""))){const t=new Error(`Path contains invalid characters: ${e}`);throw t.code="EINVAL",t}}};const Ne=ne,{checkPath:Ie}=ke,Te=e=>"number"==typeof e?e:{mode:511,...e}.mode;Pe.makeDir=async(e,t)=>(Ie(e),Ne.mkdir(e,{mode:Te(t),recursive:!0})),Pe.makeDirSync=(e,t)=>(Ie(e),Ne.mkdirSync(e,{mode:Te(t),recursive:!0}));const Re=re.fromPromise,{makeDir:Me,makeDirSync:Le}=Pe,je=Re(Me);var $e={mkdirs:je,mkdirsSync:Le,mkdirp:je,mkdirpSync:Le,ensureDir:je,ensureDirSync:Le};const He=re.fromPromise,Je=ne;var Ge={pathExists:He((function(e){return Je.access(e).then((()=>!0)).catch((()=>!1))})),pathExistsSync:Je.existsSync};const Ve=we;var Ue=function(e,t,n,r){Ve.open(e,"r+",((e,u)=>{if(e)return r(e);Ve.futimes(u,t,n,(e=>{Ve.close(u,(t=>{r&&r(e||t)}))}))}))},We=function(e,t,n){const r=Ve.openSync(e,"r+");return Ve.futimesSync(r,t,n),Ve.closeSync(r)};const ze=ne,Ke=p.default,qe=F.default;function Ye(e,t,n){const r=n.dereference?e=>ze.stat(e,{bigint:!0}):e=>ze.lstat(e,{bigint:!0});return Promise.all([r(e),r(t).catch((e=>{if("ENOENT"===e.code)return null;throw e}))]).then((([e,t])=>({srcStat:e,destStat:t})))}function Xe(e,t){return t.ino&&t.dev&&t.ino===e.ino&&t.dev===e.dev}function Ze(e,t){const n=Ke.resolve(e).split(Ke.sep).filter((e=>e)),r=Ke.resolve(t).split(Ke.sep).filter((e=>e));return n.reduce(((e,t,n)=>e&&r[n]===t),!0)}function Qe(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}var et={checkPaths:function(e,t,n,r,u){qe.callbackify(Ye)(e,t,r,((r,o)=>{if(r)return u(r);const{srcStat:i,destStat:s}=o;if(s){if(Xe(i,s)){const r=Ke.basename(e),o=Ke.basename(t);return"move"===n&&r!==o&&r.toLowerCase()===o.toLowerCase()?u(null,{srcStat:i,destStat:s,isChangingCase:!0}):u(new Error("Source and destination must not be the same."))}if(i.isDirectory()&&!s.isDirectory())return u(new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`));if(!i.isDirectory()&&s.isDirectory())return u(new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`))}return i.isDirectory()&&Ze(e,t)?u(new Error(Qe(e,t,n))):u(null,{srcStat:i,destStat:s})}))},checkPathsSync:function(e,t,n,r){const{srcStat:u,destStat:o}=function(e,t,n){let r;const u=n.dereference?e=>ze.statSync(e,{bigint:!0}):e=>ze.lstatSync(e,{bigint:!0}),o=u(e);try{r=u(t)}catch(e){if("ENOENT"===e.code)return{srcStat:o,destStat:null};throw e}return{srcStat:o,destStat:r}}(e,t,r);if(o){if(Xe(u,o)){const r=Ke.basename(e),i=Ke.basename(t);if("move"===n&&r!==i&&r.toLowerCase()===i.toLowerCase())return{srcStat:u,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(u.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!u.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(u.isDirectory()&&Ze(e,t))throw new Error(Qe(e,t,n));return{srcStat:u,destStat:o}},checkParentPaths:function e(t,n,r,u,o){const i=Ke.resolve(Ke.dirname(t)),s=Ke.resolve(Ke.dirname(r));if(s===i||s===Ke.parse(s).root)return o();ze.stat(s,{bigint:!0},((i,c)=>i?"ENOENT"===i.code?o():o(i):Xe(n,c)?o(new Error(Qe(t,r,u))):e(t,n,s,u,o)))},checkParentPathsSync:function e(t,n,r,u){const o=Ke.resolve(Ke.dirname(t)),i=Ke.resolve(Ke.dirname(r));if(i===o||i===Ke.parse(i).root)return;let s;try{s=ze.statSync(i,{bigint:!0})}catch(e){if("ENOENT"===e.code)return;throw e}if(Xe(n,s))throw new Error(Qe(t,r,u));return e(t,n,i,u)},isSrcSubdir:Ze,areIdentical:Xe};const tt=we,nt=p.default,rt=$e.mkdirs,ut=Ge.pathExists,ot=Ue,it=et;function st(e,t,n,r,u){const o=nt.dirname(n);ut(o,((i,s)=>i?u(i):s?at(e,t,n,r,u):void rt(o,(o=>o?u(o):at(e,t,n,r,u)))))}function ct(e,t,n,r,u,o){Promise.resolve(u.filter(n,r)).then((i=>i?e(t,n,r,u,o):o()),(e=>o(e)))}function at(e,t,n,r,u){(r.dereference?tt.stat:tt.lstat)(t,((o,i)=>o?u(o):i.isDirectory()?function(e,t,n,r,u,o){return t?Dt(n,r,u,o):function(e,t,n,r,u){tt.mkdir(n,(o=>{if(o)return u(o);Dt(t,n,r,(t=>t?u(t):dt(n,e,u)))}))}(e.mode,n,r,u,o)}(i,e,t,n,r,u):i.isFile()||i.isCharacterDevice()||i.isBlockDevice()?function(e,t,n,r,u,o){return t?function(e,t,n,r,u){if(!r.overwrite)return r.errorOnExist?u(new Error(`'${n}' already exists`)):u();tt.unlink(n,(o=>o?u(o):lt(e,t,n,r,u)))}(e,n,r,u,o):lt(e,n,r,u,o)}(i,e,t,n,r,u):i.isSymbolicLink()?function(e,t,n,r,u){tt.readlink(t,((t,o)=>t?u(t):(r.dereference&&(o=nt.resolve(process.cwd(),o)),e?void tt.readlink(n,((t,i)=>t?"EINVAL"===t.code||"UNKNOWN"===t.code?tt.symlink(o,n,u):u(t):(r.dereference&&(i=nt.resolve(process.cwd(),i)),it.isSrcSubdir(o,i)?u(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`)):e.isDirectory()&&it.isSrcSubdir(i,o)?u(new Error(`Cannot overwrite '${i}' with '${o}'.`)):function(e,t,n){tt.unlink(t,(r=>r?n(r):tt.symlink(e,t,n)))}(o,n,u)))):tt.symlink(o,n,u))))}(e,t,n,r,u):i.isSocket()?u(new Error(`Cannot copy a socket file: ${t}`)):i.isFIFO()?u(new Error(`Cannot copy a FIFO pipe: ${t}`)):u(new Error(`Unknown file: ${t}`))))}function lt(e,t,n,r,u){tt.copyFile(t,n,(o=>o?u(o):r.preserveTimestamps?function(e,t,n,r){if(function(e){return 0==(128&e)}(e))return function(e,t,n){return dt(e,128|t,n)}(n,e,(u=>u?r(u):ft(e,t,n,r)));return ft(e,t,n,r)}(e.mode,t,n,u):dt(n,e.mode,u)))}function ft(e,t,n,r){!function(e,t,n){tt.stat(e,((e,r)=>e?n(e):ot(t,r.atime,r.mtime,n)))}(t,n,(t=>t?r(t):dt(n,e,r)))}function dt(e,t,n){return tt.chmod(e,t,n)}function Dt(e,t,n,r){tt.readdir(e,((u,o)=>u?r(u):pt(o,e,t,n,r)))}function pt(e,t,n,r,u){const o=e.pop();return o?function(e,t,n,r,u,o){const i=nt.join(n,t),s=nt.join(r,t);it.checkPaths(i,s,"copy",u,((t,c)=>{if(t)return o(t);const{destStat:a}=c;!function(e,t,n,r,u){r.filter?ct(at,e,t,n,r,u):at(e,t,n,r,u)}(a,i,s,u,(t=>t?o(t):pt(e,n,r,u,o)))}))}(e,o,t,n,r,u):u()}var Et=function(e,t,n,r){"function"!=typeof n||r?"function"==typeof n&&(n={filter:n}):(r=n,n={}),r=r||function(){},(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),it.checkPaths(e,t,"copy",n,((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;it.checkParentPaths(e,i,t,"copy",(u=>u?r(u):n.filter?ct(st,s,e,t,n,r):st(s,e,t,n,r)))}))};const mt=we,ht=p.default,yt=$e.mkdirsSync,Ct=We,Ft=et;function gt(e,t,n,r){const u=(r.dereference?mt.statSync:mt.lstatSync)(t);if(u.isDirectory())return function(e,t,n,r,u){return t?St(n,r,u):function(e,t,n,r){return mt.mkdirSync(n),St(t,n,r),vt(n,e)}(e.mode,n,r,u)}(u,e,t,n,r);if(u.isFile()||u.isCharacterDevice()||u.isBlockDevice())return function(e,t,n,r,u){return t?function(e,t,n,r){if(r.overwrite)return mt.unlinkSync(n),At(e,t,n,r);if(r.errorOnExist)throw new Error(`'${n}' already exists`)}(e,n,r,u):At(e,n,r,u)}(u,e,t,n,r);if(u.isSymbolicLink())return function(e,t,n,r){let u=mt.readlinkSync(t);r.dereference&&(u=ht.resolve(process.cwd(),u));if(e){let e;try{e=mt.readlinkSync(n)}catch(e){if("EINVAL"===e.code||"UNKNOWN"===e.code)return mt.symlinkSync(u,n);throw e}if(r.dereference&&(e=ht.resolve(process.cwd(),e)),Ft.isSrcSubdir(u,e))throw new Error(`Cannot copy '${u}' to a subdirectory of itself, '${e}'.`);if(mt.statSync(n).isDirectory()&&Ft.isSrcSubdir(e,u))throw new Error(`Cannot overwrite '${e}' with '${u}'.`);return function(e,t){return mt.unlinkSync(t),mt.symlinkSync(e,t)}(u,n)}return mt.symlinkSync(u,n)}(e,t,n,r);if(u.isSocket())throw new Error(`Cannot copy a socket file: ${t}`);if(u.isFIFO())throw new Error(`Cannot copy a FIFO pipe: ${t}`);throw new Error(`Unknown file: ${t}`)}function At(e,t,n,r){return mt.copyFileSync(t,n),r.preserveTimestamps&&function(e,t,n){(function(e){return 0==(128&e)})(e)&&function(e,t){vt(e,128|t)}(n,e);(function(e,t){const n=mt.statSync(e);Ct(t,n.atime,n.mtime)})(t,n)}(e.mode,t,n),vt(n,e.mode)}function vt(e,t){return mt.chmodSync(e,t)}function St(e,t,n){mt.readdirSync(e).forEach((r=>function(e,t,n,r){const u=ht.join(t,e),o=ht.join(n,e),{destStat:i}=Ft.checkPathsSync(u,o,"copy",r);return function(e,t,n,r){if(!r.filter||r.filter(t,n))return gt(e,t,n,r)}(i,u,o,r)}(r,e,t,n)))}var wt=function(e,t,n){"function"==typeof n&&(n={filter:n}),(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:u}=Ft.checkPathsSync(e,t,"copy",n);return Ft.checkParentPathsSync(e,r,t,"copy"),function(e,t,n,r){if(r.filter&&!r.filter(t,n))return;const u=ht.dirname(n);mt.existsSync(u)||yt(u);return gt(e,t,n,r)}(u,e,t,n)};var Ot={copy:(0,re.fromCallback)(Et),copySync:wt};const bt=we,_t=p.default,Bt=g.default,Pt="win32"===process.platform;function kt(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach((t=>{e[t]=e[t]||bt[t],e[t+="Sync"]=e[t]||bt[t]})),e.maxBusyTries=e.maxBusyTries||3}function xt(e,t,n){let r=0;"function"==typeof t&&(n=t,t={}),Bt(e,"rimraf: missing path"),Bt.strictEqual(typeof e,"string","rimraf: path should be a string"),Bt.strictEqual(typeof n,"function","rimraf: callback function required"),Bt(t,"rimraf: invalid options argument provided"),Bt.strictEqual(typeof t,"object","rimraf: options should be object"),kt(t),Nt(e,t,(function u(o){if(o){if(("EBUSY"===o.code||"ENOTEMPTY"===o.code||"EPERM"===o.code)&&rNt(e,t,u)),100*r)}"ENOENT"===o.code&&(o=null)}n(o)}))}function Nt(e,t,n){Bt(e),Bt(t),Bt("function"==typeof n),t.lstat(e,((r,u)=>r&&"ENOENT"===r.code?n(null):r&&"EPERM"===r.code&&Pt?It(e,t,r,n):u&&u.isDirectory()?Rt(e,t,r,n):void t.unlink(e,(r=>{if(r){if("ENOENT"===r.code)return n(null);if("EPERM"===r.code)return Pt?It(e,t,r,n):Rt(e,t,r,n);if("EISDIR"===r.code)return Rt(e,t,r,n)}return n(r)}))))}function It(e,t,n,r){Bt(e),Bt(t),Bt("function"==typeof r),t.chmod(e,438,(u=>{u?r("ENOENT"===u.code?null:n):t.stat(e,((u,o)=>{u?r("ENOENT"===u.code?null:n):o.isDirectory()?Rt(e,t,n,r):t.unlink(e,r)}))}))}function Tt(e,t,n){let r;Bt(e),Bt(t);try{t.chmodSync(e,438)}catch(e){if("ENOENT"===e.code)return;throw n}try{r=t.statSync(e)}catch(e){if("ENOENT"===e.code)return;throw n}r.isDirectory()?Lt(e,t,n):t.unlinkSync(e)}function Rt(e,t,n,r){Bt(e),Bt(t),Bt("function"==typeof r),t.rmdir(e,(u=>{!u||"ENOTEMPTY"!==u.code&&"EEXIST"!==u.code&&"EPERM"!==u.code?u&&"ENOTDIR"===u.code?r(n):r(u):function(e,t,n){Bt(e),Bt(t),Bt("function"==typeof n),t.readdir(e,((r,u)=>{if(r)return n(r);let o,i=u.length;if(0===i)return t.rmdir(e,n);u.forEach((r=>{xt(_t.join(e,r),t,(r=>{if(!o)return r?n(o=r):void(0==--i&&t.rmdir(e,n))}))}))}))}(e,t,r)}))}function Mt(e,t){let n;kt(t=t||{}),Bt(e,"rimraf: missing path"),Bt.strictEqual(typeof e,"string","rimraf: path should be a string"),Bt(t,"rimraf: missing options"),Bt.strictEqual(typeof t,"object","rimraf: options should be object");try{n=t.lstatSync(e)}catch(n){if("ENOENT"===n.code)return;"EPERM"===n.code&&Pt&&Tt(e,t,n)}try{n&&n.isDirectory()?Lt(e,t,null):t.unlinkSync(e)}catch(n){if("ENOENT"===n.code)return;if("EPERM"===n.code)return Pt?Tt(e,t,n):Lt(e,t,n);if("EISDIR"!==n.code)throw n;Lt(e,t,n)}}function Lt(e,t,n){Bt(e),Bt(t);try{t.rmdirSync(e)}catch(r){if("ENOTDIR"===r.code)throw n;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(e,t){if(Bt(e),Bt(t),t.readdirSync(e).forEach((n=>Mt(_t.join(e,n),t))),!Pt){return t.rmdirSync(e,t)}{const n=Date.now();do{try{return t.rmdirSync(e,t)}catch{}}while(Date.now()-n<500)}}(e,t);else if("ENOENT"!==r.code)throw r}}var jt=xt;xt.sync=Mt;const $t=we,Ht=re.fromCallback,Jt=jt;var Gt={remove:Ht((function(e,t){if($t.rm)return $t.rm(e,{recursive:!0,force:!0},t);Jt(e,t)})),removeSync:function(e){if($t.rmSync)return $t.rmSync(e,{recursive:!0,force:!0});Jt.sync(e)}};const Vt=re.fromPromise,Ut=ne,Wt=p.default,zt=$e,Kt=Gt,qt=Vt((async function(e){let t;try{t=await Ut.readdir(e)}catch{return zt.mkdirs(e)}return Promise.all(t.map((t=>Kt.remove(Wt.join(e,t)))))}));function Yt(e){let t;try{t=Ut.readdirSync(e)}catch{return zt.mkdirsSync(e)}t.forEach((t=>{t=Wt.join(e,t),Kt.removeSync(t)}))}var Xt={emptyDirSync:Yt,emptydirSync:Yt,emptyDir:qt,emptydir:qt};const Zt=re.fromCallback,Qt=p.default,en=we,tn=$e;var nn={createFile:Zt((function(e,t){function n(){en.writeFile(e,"",(e=>{if(e)return t(e);t()}))}en.stat(e,((r,u)=>{if(!r&&u.isFile())return t();const o=Qt.dirname(e);en.stat(o,((e,r)=>{if(e)return"ENOENT"===e.code?tn.mkdirs(o,(e=>{if(e)return t(e);n()})):t(e);r.isDirectory()?n():en.readdir(o,(e=>{if(e)return t(e)}))}))}))})),createFileSync:function(e){let t;try{t=en.statSync(e)}catch{}if(t&&t.isFile())return;const n=Qt.dirname(e);try{en.statSync(n).isDirectory()||en.readdirSync(n)}catch(e){if(!e||"ENOENT"!==e.code)throw e;tn.mkdirsSync(n)}en.writeFileSync(e,"")}};const rn=re.fromCallback,un=p.default,on=we,sn=$e,cn=Ge.pathExists,{areIdentical:an}=et;var ln={createLink:rn((function(e,t,n){function r(e,t){on.link(e,t,(e=>{if(e)return n(e);n(null)}))}on.lstat(t,((u,o)=>{on.lstat(e,((u,i)=>{if(u)return u.message=u.message.replace("lstat","ensureLink"),n(u);if(o&&an(i,o))return n(null);const s=un.dirname(t);cn(s,((u,o)=>u?n(u):o?r(e,t):void sn.mkdirs(s,(u=>{if(u)return n(u);r(e,t)}))))}))}))})),createLinkSync:function(e,t){let n;try{n=on.lstatSync(t)}catch{}try{const t=on.lstatSync(e);if(n&&an(t,n))return}catch(e){throw e.message=e.message.replace("lstat","ensureLink"),e}const r=un.dirname(t);return on.existsSync(r)||sn.mkdirsSync(r),on.linkSync(e,t)}};const fn=p.default,dn=we,Dn=Ge.pathExists;var pn={symlinkPaths:function(e,t,n){if(fn.isAbsolute(e))return dn.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:e})));{const r=fn.dirname(t),u=fn.join(r,e);return Dn(u,((t,o)=>t?n(t):o?n(null,{toCwd:u,toDst:e}):dn.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:fn.relative(r,e)})))))}},symlinkPathsSync:function(e,t){let n;if(fn.isAbsolute(e)){if(n=dn.existsSync(e),!n)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}{const r=fn.dirname(t),u=fn.join(r,e);if(n=dn.existsSync(u),n)return{toCwd:u,toDst:e};if(n=dn.existsSync(e),!n)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:fn.relative(r,e)}}}};const En=we;var mn={symlinkType:function(e,t,n){if(n="function"==typeof t?t:n,t="function"!=typeof t&&t)return n(null,t);En.lstat(e,((e,r)=>{if(e)return n(null,"file");t=r&&r.isDirectory()?"dir":"file",n(null,t)}))},symlinkTypeSync:function(e,t){let n;if(t)return t;try{n=En.lstatSync(e)}catch{return"file"}return n&&n.isDirectory()?"dir":"file"}};const hn=re.fromCallback,yn=p.default,Cn=ne,Fn=$e.mkdirs,gn=$e.mkdirsSync,An=pn.symlinkPaths,vn=pn.symlinkPathsSync,Sn=mn.symlinkType,wn=mn.symlinkTypeSync,On=Ge.pathExists,{areIdentical:bn}=et;function _n(e,t,n,r){An(e,t,((u,o)=>{if(u)return r(u);e=o.toDst,Sn(o.toCwd,n,((n,u)=>{if(n)return r(n);const o=yn.dirname(t);On(o,((n,i)=>n?r(n):i?Cn.symlink(e,t,u,r):void Fn(o,(n=>{if(n)return r(n);Cn.symlink(e,t,u,r)}))))}))}))}var Bn={createSymlink:hn((function(e,t,n,r){r="function"==typeof n?n:r,n="function"!=typeof n&&n,Cn.lstat(t,((u,o)=>{!u&&o.isSymbolicLink()?Promise.all([Cn.stat(e),Cn.stat(t)]).then((([u,o])=>{if(bn(u,o))return r(null);_n(e,t,n,r)})):_n(e,t,n,r)}))})),createSymlinkSync:function(e,t,n){let r;try{r=Cn.lstatSync(t)}catch{}if(r&&r.isSymbolicLink()){const n=Cn.statSync(e),r=Cn.statSync(t);if(bn(n,r))return}const u=vn(e,t);e=u.toDst,n=wn(u.toCwd,n);const o=yn.dirname(t);return Cn.existsSync(o)||gn(o),Cn.symlinkSync(e,t,n)}};const{createFile:Pn,createFileSync:kn}=nn,{createLink:xn,createLinkSync:Nn}=ln,{createSymlink:In,createSymlinkSync:Tn}=Bn;var Rn={createFile:Pn,createFileSync:kn,ensureFile:Pn,ensureFileSync:kn,createLink:xn,createLinkSync:Nn,ensureLink:xn,ensureLinkSync:Nn,createSymlink:In,createSymlinkSync:Tn,ensureSymlink:In,ensureSymlinkSync:Tn};var Mn={stringify:function(e,{EOL:t="\n",finalEOL:n=!0,replacer:r=null,spaces:u}={}){const o=n?t:"";return JSON.stringify(e,r,u).replace(/\n/g,t)+o},stripBom:function(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}};let Ln;try{Ln=we}catch(e){Ln=D.default}const jn=re,{stringify:$n,stripBom:Hn}=Mn;const Jn=jn.fromPromise((async function(e,t={}){"string"==typeof t&&(t={encoding:t});const n=t.fs||Ln,r=!("throws"in t)||t.throws;let u,o=await jn.fromCallback(n.readFile)(e,t);o=Hn(o);try{u=JSON.parse(o,t?t.reviver:null)}catch(t){if(r)throw t.message=`${e}: ${t.message}`,t;return null}return u}));const Gn=jn.fromPromise((async function(e,t,n={}){const r=n.fs||Ln,u=$n(t,n);await jn.fromCallback(r.writeFile)(e,u,n)}));const Vn={readFile:Jn,readFileSync:function(e,t={}){"string"==typeof t&&(t={encoding:t});const n=t.fs||Ln,r=!("throws"in t)||t.throws;try{let r=n.readFileSync(e,t);return r=Hn(r),JSON.parse(r,t.reviver)}catch(t){if(r)throw t.message=`${e}: ${t.message}`,t;return null}},writeFile:Gn,writeFileSync:function(e,t,n={}){const r=n.fs||Ln,u=$n(t,n);return r.writeFileSync(e,u,n)}};var Un={readJson:Vn.readFile,readJsonSync:Vn.readFileSync,writeJson:Vn.writeFile,writeJsonSync:Vn.writeFileSync};const Wn=re.fromCallback,zn=we,Kn=p.default,qn=$e,Yn=Ge.pathExists;var Xn={outputFile:Wn((function(e,t,n,r){"function"==typeof n&&(r=n,n="utf8");const u=Kn.dirname(e);Yn(u,((o,i)=>o?r(o):i?zn.writeFile(e,t,n,r):void qn.mkdirs(u,(u=>{if(u)return r(u);zn.writeFile(e,t,n,r)}))))})),outputFileSync:function(e,...t){const n=Kn.dirname(e);if(zn.existsSync(n))return zn.writeFileSync(e,...t);qn.mkdirsSync(n),zn.writeFileSync(e,...t)}};const{stringify:Zn}=Mn,{outputFile:Qn}=Xn;var er=async function(e,t,n={}){const r=Zn(t,n);await Qn(e,r,n)};const{stringify:tr}=Mn,{outputFileSync:nr}=Xn;var rr=function(e,t,n){const r=tr(t,n);nr(e,r,n)};const ur=re.fromPromise,or=Un;or.outputJson=ur(er),or.outputJsonSync=rr,or.outputJSON=or.outputJson,or.outputJSONSync=or.outputJsonSync,or.writeJSON=or.writeJson,or.writeJSONSync=or.writeJsonSync,or.readJSON=or.readJson,or.readJSONSync=or.readJsonSync;var ir=or;const sr=we,cr=p.default,ar=Ot.copy,lr=Gt.remove,fr=$e.mkdirp,dr=Ge.pathExists,Dr=et;function pr(e,t,n,r,u){return r?Er(e,t,n,u):n?lr(t,(r=>r?u(r):Er(e,t,n,u))):void dr(t,((r,o)=>r?u(r):o?u(new Error("dest already exists.")):Er(e,t,n,u)))}function Er(e,t,n,r){sr.rename(e,t,(u=>u?"EXDEV"!==u.code?r(u):function(e,t,n,r){const u={overwrite:n,errorOnExist:!0};ar(e,t,u,(t=>t?r(t):lr(e,r)))}(e,t,n,r):r()))}var mr=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=n.overwrite||n.clobber||!1;Dr.checkPaths(e,t,"move",n,((n,o)=>{if(n)return r(n);const{srcStat:i,isChangingCase:s=!1}=o;Dr.checkParentPaths(e,i,t,"move",(n=>n?r(n):function(e){const t=cr.dirname(e);return cr.parse(t).root===t}(t)?pr(e,t,u,s,r):void fr(cr.dirname(t),(n=>n?r(n):pr(e,t,u,s,r)))))}))};const hr=we,yr=p.default,Cr=Ot.copySync,Fr=Gt.removeSync,gr=$e.mkdirpSync,Ar=et;function vr(e,t,n){try{hr.renameSync(e,t)}catch(r){if("EXDEV"!==r.code)throw r;return function(e,t,n){const r={overwrite:n,errorOnExist:!0};return Cr(e,t,r),Fr(e)}(e,t,n)}}var Sr=function(e,t,n){const r=(n=n||{}).overwrite||n.clobber||!1,{srcStat:u,isChangingCase:o=!1}=Ar.checkPathsSync(e,t,"move",n);return Ar.checkParentPathsSync(e,u,t,"move"),function(e){const t=yr.dirname(e);return yr.parse(t).root===t}(t)||gr(yr.dirname(t)),function(e,t,n,r){if(r)return vr(e,t,n);if(n)return Fr(t),vr(e,t,n);if(hr.existsSync(t))throw new Error("dest already exists.");return vr(e,t,n)}(e,t,r,o)};var wr,Or,br,_r,Br,Pr={move:(0,re.fromCallback)(mr),moveSync:Sr},kr={...ne,...Ot,...Xt,...Rn,...ir,...$e,...Pr,...Xn,...Ge,...Gt},xr={},Nr={exports:{}},Ir={exports:{}};function Tr(){if(Or)return wr;Or=1;var e=1e3,t=60*e,n=60*t,r=24*n,u=7*r,o=365.25*r;function i(e,t,n,r){var u=t>=1.5*n;return Math.round(e/n)+" "+r+(u?"s":"")}return wr=function(s,c){c=c||{};var a=typeof s;if("string"===a&&s.length>0)return function(i){if((i=String(i)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!s)return;var c=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*u;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(s);if("number"===a&&isFinite(s))return c.long?function(u){var o=Math.abs(u);if(o>=r)return i(u,o,r,"day");if(o>=n)return i(u,o,n,"hour");if(o>=t)return i(u,o,t,"minute");if(o>=e)return i(u,o,e,"second");return u+" ms"}(s):function(u){var o=Math.abs(u);if(o>=r)return Math.round(u/r)+"d";if(o>=n)return Math.round(u/n)+"h";if(o>=t)return Math.round(u/t)+"m";if(o>=e)return Math.round(u/e)+"s";return u+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}function Rr(){if(_r)return br;return _r=1,br=function(e){function t(e){let r,u,o,i=null;function s(...e){if(!s.enabled)return;const n=s,u=Number(new Date),o=u-(r||u);n.diff=o,n.prev=r,n.curr=u,r=u,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,u)=>{if("%%"===r)return"%";i++;const o=t.formatters[u];if("function"==typeof o){const t=e[i];r=o.call(n,t),e.splice(i,1),i--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(u!==t.namespaces&&(u=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(s),s}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),u=r.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{const n=e.startsWith("-")?"":1===e.length?"-":"--",r=t.indexOf(n+e),u=t.indexOf("--");return-1!==r&&(-1===u||r{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=function(){if($r)return jr;$r=1;const e=E.default,t=A.default,n=Vr(),{env:r}=process;let u;function o(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function i(t,o){if(0===u)return 0;if(n("color=16m")||n("color=full")||n("color=truecolor"))return 3;if(n("color=256"))return 2;if(t&&!o&&void 0===u)return 0;const i=u||0;if("dumb"===r.TERM)return i;if("win32"===process.platform){const t=e.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in r))||"codeship"===r.CI_NAME?1:i;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if("truecolor"===r.COLORTERM)return 3;if("TERM_PROGRAM"in r){const e=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:i}return n("no-color")||n("no-colors")||n("color=false")||n("color=never")?u=0:(n("color")||n("colors")||n("color=true")||n("color=always"))&&(u=1),"FORCE_COLOR"in r&&(u="true"===r.FORCE_COLOR?1:"false"===r.FORCE_COLOR?0:0===r.FORCE_COLOR.length?1:Math.min(parseInt(r.FORCE_COLOR,10),3)),jr={supportsColor:function(e){return o(i(e,e&&e.isTTY))},stdout:o(i(!0,t.isatty(1))),stderr:o(i(!0,t.isatty(2)))}}();e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let r=process.env[t];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),e[n]=r,e}),{}),e.exports=Rr()(t);const{formatters:u}=e.exports;u.o=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},u.O=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts)}}(Gr,Gr.exports)),Gr.exports}Jr=Nr,"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?Jr.exports=(Br||(Br=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,u=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(u=r))})),t.splice(u,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Rr()(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ir,Ir.exports)),Ir.exports):Jr.exports=Ur();var Wr=function(e){return(e=e||{}).circles?function(e){var t=[],n=[];return e.proto?function e(u){if("object"!=typeof u||null===u)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return r(u,e);if(u instanceof Map)return new Map(r(Array.from(u),e));if(u instanceof Set)return new Set(r(Array.from(u),e));var o={};for(var i in t.push(u),n.push(o),u){var s=u[i];if("object"!=typeof s||null===s)o[i]=s;else if(s instanceof Date)o[i]=new Date(s);else if(s instanceof Map)o[i]=new Map(r(Array.from(s),e));else if(s instanceof Set)o[i]=new Set(r(Array.from(s),e));else if(ArrayBuffer.isView(s))o[i]=zr(s);else{var c=t.indexOf(s);o[i]=-1!==c?n[c]:e(s)}}return t.pop(),n.pop(),o}:function e(u){if("object"!=typeof u||null===u)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return r(u,e);if(u instanceof Map)return new Map(r(Array.from(u),e));if(u instanceof Set)return new Set(r(Array.from(u),e));var o={};for(var i in t.push(u),n.push(o),u)if(!1!==Object.hasOwnProperty.call(u,i)){var s=u[i];if("object"!=typeof s||null===s)o[i]=s;else if(s instanceof Date)o[i]=new Date(s);else if(s instanceof Map)o[i]=new Map(r(Array.from(s),e));else if(s instanceof Set)o[i]=new Set(r(Array.from(s),e));else if(ArrayBuffer.isView(s))o[i]=zr(s);else{var c=t.indexOf(s);o[i]=-1!==c?n[c]:e(s)}}return t.pop(),n.pop(),o};function r(e,r){for(var u=Object.keys(e),o=new Array(u.length),i=0;i!e,Qr=e=>e&&"object"==typeof e&&!Array.isArray(e),eu=(e,t,n)=>{(Array.isArray(t)?t:[t]).forEach((t=>{if(t)throw new Error(`Problem with log4js configuration: (${Kr.inspect(e,{depth:5})}) - ${n}`)}))};var tu={configure:e=>{qr("New configuration to be validated: ",e),eu(e,Zr(Qr(e)),"must be an object."),qr(`Calling pre-processing listeners (${Yr.length})`),Yr.forEach((t=>t(e))),qr("Configuration pre-processing finished."),qr(`Calling configuration listeners (${Xr.length})`),Xr.forEach((t=>t(e))),qr("Configuration finished.")},addListener:e=>{Xr.push(e),qr(`Added listener, now ${Xr.length} listeners`)},addPreProcessingListener:e=>{Yr.push(e),qr(`Added pre-processing listener, now ${Yr.length} listeners`)},throwExceptionIf:eu,anObject:Qr,anInteger:e=>e&&"number"==typeof e&&Number.isInteger(e),validIdentifier:e=>/^[A-Za-z][A-Za-z0-9_]*$/g.test(e),not:Zr},nu={exports:{}};!function(e){function t(e,t){for(var n=e.toString();n.length-1?s:c,l=n(u.getHours()),f=n(u.getMinutes()),d=n(u.getSeconds()),D=t(u.getMilliseconds(),3),p=function(e){var t=Math.abs(e),n=String(Math.floor(t/60)),r=String(t%60);return n=("0"+n).slice(-2),r=("0"+r).slice(-2),0===e?"Z":(e<0?"+":"-")+n+":"+r}(u.getTimezoneOffset());return r.replace(/dd/g,o).replace(/MM/g,i).replace(/y{1,4}/g,a).replace(/hh/g,l).replace(/mm/g,f).replace(/ss/g,d).replace(/SSS/g,D).replace(/O/g,p)}function u(e,t,n,r){e["set"+(r?"":"UTC")+t](n)}e.exports=r,e.exports.asString=r,e.exports.parse=function(t,n,r){if(!t)throw new Error("pattern must be supplied");return function(t,n,r){var o=t.indexOf("O")<0,i=!1,s=[{pattern:/y{1,4}/,regexp:"\\d{1,4}",fn:function(e,t){u(e,"FullYear",t,o)}},{pattern:/MM/,regexp:"\\d{1,2}",fn:function(e,t){u(e,"Month",t-1,o),e.getMonth()!==t-1&&(i=!0)}},{pattern:/dd/,regexp:"\\d{1,2}",fn:function(e,t){i&&u(e,"Month",e.getMonth()-1,o),u(e,"Date",t,o)}},{pattern:/hh/,regexp:"\\d{1,2}",fn:function(e,t){u(e,"Hours",t,o)}},{pattern:/mm/,regexp:"\\d\\d",fn:function(e,t){u(e,"Minutes",t,o)}},{pattern:/ss/,regexp:"\\d\\d",fn:function(e,t){u(e,"Seconds",t,o)}},{pattern:/SSS/,regexp:"\\d\\d\\d",fn:function(e,t){u(e,"Milliseconds",t,o)}},{pattern:/O/,regexp:"[+-]\\d{1,2}:?\\d{2}?|Z",fn:function(e,t){t="Z"===t?0:t.replace(":","");var n=Math.abs(t),r=(t>0?-1:1)*(n%100+60*Math.floor(n/100));e.setUTCMinutes(e.getUTCMinutes()+r)}}],c=s.reduce((function(e,t){return t.pattern.test(e.regexp)?(t.index=e.regexp.match(t.pattern).index,e.regexp=e.regexp.replace(t.pattern,"("+t.regexp+")")):t.index=-1,e}),{regexp:t,index:[]}),a=s.filter((function(e){return e.index>-1}));a.sort((function(e,t){return e.index-t.index}));var l=new RegExp(c.regexp).exec(n);if(l){var f=r||e.exports.now();return a.forEach((function(e,t){e.fn(f,l[t+1])})),f}throw new Error("String '"+n+"' could not be parsed as '"+t+"'")}(t,n,r)},e.exports.now=function(){return new Date},e.exports.ISO8601_FORMAT="yyyy-MM-ddThh:mm:ss.SSS",e.exports.ISO8601_WITH_TZ_OFFSET_FORMAT="yyyy-MM-ddThh:mm:ss.SSSO",e.exports.DATETIME_FORMAT="dd MM yyyy hh:mm:ss.SSS",e.exports.ABSOLUTETIME_FORMAT="hh:mm:ss.SSS"}(nu);const ru=nu.exports,uu=E.default,ou=F.default,iu=p.default,su={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[90,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[91,39],yellow:[33,39]};function cu(e){return e?`[${su[e][0]}m`:""}function au(e){return e?`[${su[e][1]}m`:""}function lu(e,t){return n=ou.format("[%s] [%s] %s - ",ru.asString(e.startTime),e.level.toString(),e.categoryName),cu(r=t)+n+au(r);var n,r}function fu(e){return lu(e)+ou.format(...e.data)}function du(e){return lu(e,e.level.colour)+ou.format(...e.data)}function Du(e){return ou.format(...e.data)}function pu(e){return e.data[0]}function Eu(e,t){const n=/%(-?[0-9]+)?(\.?-?[0-9]+)?([[\]cdhmnprzxXyflos%])(\{([^}]+)\})?|([^%]+)/;function r(e){return e&&e.pid?e.pid.toString():process.pid.toString()}e=e||"%r %p %c - %m%n";const u={c:function(e,t){let n=e.categoryName;if(t){const e=parseInt(t,10),r=n.split(".");ee&&(n=r.slice(-e).join(iu.sep))}return n},l:function(e){return e.lineNumber?`${e.lineNumber}`:""},o:function(e){return e.columnNumber?`${e.columnNumber}`:""},s:function(e){return e.callStack||""}};function o(e,t,n){return u[e](t,n)}function i(e,t,n){let r=e;return r=function(e,t){let n;return e?(n=parseInt(e.substr(1),10),n>0?t.slice(0,n):t.slice(n)):t}(t,r),r=function(e,t){let n;if(e)if("-"===e.charAt(0))for(n=parseInt(e.substr(1),10);t.lengthDu,basic:()=>fu,colored:()=>du,coloured:()=>du,pattern:e=>Eu(e&&e.pattern,e&&e.tokens),dummy:()=>pu};var hu={basicLayout:fu,messagePassThroughLayout:Du,patternLayout:Eu,colouredLayout:du,coloredLayout:du,dummyLayout:pu,addLayout(e,t){mu[e]=t},layout:(e,t)=>mu[e]&&mu[e](t)};const yu=tu,Cu=["white","grey","black","blue","cyan","green","magenta","red","yellow"];class Fu{constructor(e,t,n){this.level=e,this.levelStr=t,this.colour=n}toString(){return this.levelStr}static getLevel(e,t){return e?e instanceof Fu?e:(e instanceof Object&&e.levelStr&&(e=e.levelStr),Fu[e.toString().toUpperCase()]||t):t}static addLevels(e){if(e){Object.keys(e).forEach((t=>{const n=t.toUpperCase();Fu[n]=new Fu(e[t].value,n,e[t].colour);const r=Fu.levels.findIndex((e=>e.levelStr===n));r>-1?Fu.levels[r]=Fu[n]:Fu.levels.push(Fu[n])})),Fu.levels.sort(((e,t)=>e.level-t.level))}}isLessThanOrEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level<=e.level}isGreaterThanOrEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level>=e.level}isEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level===e.level}}Fu.levels=[],Fu.addLevels({ALL:{value:Number.MIN_VALUE,colour:"grey"},TRACE:{value:5e3,colour:"blue"},DEBUG:{value:1e4,colour:"cyan"},INFO:{value:2e4,colour:"green"},WARN:{value:3e4,colour:"yellow"},ERROR:{value:4e4,colour:"red"},FATAL:{value:5e4,colour:"magenta"},MARK:{value:9007199254740992,colour:"grey"},OFF:{value:Number.MAX_VALUE,colour:"grey"}}),yu.addListener((e=>{const t=e.levels;if(t){yu.throwExceptionIf(e,yu.not(yu.anObject(t)),"levels must be an object");Object.keys(t).forEach((n=>{yu.throwExceptionIf(e,yu.not(yu.validIdentifier(n)),`level name "${n}" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)`),yu.throwExceptionIf(e,yu.not(yu.anObject(t[n])),`level "${n}" must be an object`),yu.throwExceptionIf(e,yu.not(t[n].value),`level "${n}" must have a 'value' property`),yu.throwExceptionIf(e,yu.not(yu.anInteger(t[n].value)),`level "${n}".value must have an integer value`),yu.throwExceptionIf(e,yu.not(t[n].colour),`level "${n}" must have a 'colour' property`),yu.throwExceptionIf(e,yu.not(Cu.indexOf(t[n].colour)>-1),`level "${n}".colour must be one of ${Cu.join(", ")}`)}))}})),yu.addListener((e=>{Fu.addLevels(e.levels)}));var gu=Fu,Au={exports:{}},vu={};/*! (c) 2020 Andrea Giammarchi */ +const{parse:Su,stringify:wu}=JSON,{keys:Ou}=Object,bu=String,_u="string",Bu={},Pu="object",ku=(e,t)=>t,xu=e=>e instanceof bu?bu(e):e,Nu=(e,t)=>typeof t===_u?new bu(t):t,Iu=(e,t,n,r)=>{const u=[];for(let o=Ou(n),{length:i}=o,s=0;s{const r=bu(t.push(n)-1);return e.set(n,r),r},Ru=(e,t)=>{const n=Su(e,Nu).map(xu),r=n[0],u=t||ku,o=typeof r===Pu&&r?Iu(n,new Set,r,u):r;return u.call({"":o},"",o)};vu.parse=Ru;const Mu=(e,t,n)=>{const r=t&&typeof t===Pu?(e,n)=>""===e||-1Su(Mu(e));vu.fromJSON=e=>Ru(wu(e));const Lu=vu,ju=gu;class $u{constructor(e,t,n,r,u){this.startTime=new Date,this.categoryName=e,this.data=n,this.level=t,this.context=Object.assign({},r),this.pid=process.pid,u&&(this.functionName=u.functionName,this.fileName=u.fileName,this.lineNumber=u.lineNumber,this.columnNumber=u.columnNumber,this.callStack=u.callStack)}serialise(){const e=this.data.map((e=>(e&&e.message&&e.stack&&(e=Object.assign({message:e.message,stack:e.stack},e)),e)));return this.data=e,Lu.stringify(this)}static deserialise(e){let t;try{const n=Lu.parse(e);n.data=n.data.map((e=>{if(e&&e.message&&e.stack){const t=new Error(e);Object.keys(e).forEach((n=>{t[n]=e[n]})),e=t}return e})),t=new $u(n.categoryName,ju.getLevel(n.level.levelStr),n.data,n.context),t.startTime=new Date(n.startTime),t.pid=n.pid,t.cluster=n.cluster}catch(n){t=new $u("log4js",ju.ERROR,["Unable to parse log:",e,"because: ",n])}return t}}var Hu=$u;const Ju=Nr.exports("log4js:clustering"),Gu=Hu,Vu=tu;let Uu=!1,Wu=null;try{Wu=require("cluster")}catch(e){Ju("cluster module not present"),Uu=!0}const zu=[];let Ku=!1,qu="NODE_APP_INSTANCE";const Yu=()=>Ku&&"0"===process.env[qu],Xu=()=>Uu||Wu.isMaster||Yu(),Zu=e=>{zu.forEach((t=>t(e)))},Qu=(e,t)=>{if(Ju("cluster message received from worker ",e,": ",t),e.topic&&e.data&&(t=e,e=void 0),t&&t.topic&&"log4js:message"===t.topic){Ju("received message: ",t.data);const e=Gu.deserialise(t.data);Zu(e)}};Uu||Vu.addListener((e=>{zu.length=0,({pm2:Ku,disableClustering:Uu,pm2InstanceVar:qu="NODE_APP_INSTANCE"}=e),Ju(`clustering disabled ? ${Uu}`),Ju(`cluster.isMaster ? ${Wu&&Wu.isMaster}`),Ju(`pm2 enabled ? ${Ku}`),Ju(`pm2InstanceVar = ${qu}`),Ju(`process.env[${qu}] = ${process.env[qu]}`),Ku&&process.removeListener("message",Qu),Wu&&Wu.removeListener&&Wu.removeListener("message",Qu),Uu||e.disableClustering?Ju("Not listening for cluster messages, because clustering disabled."):Yu()?(Ju("listening for PM2 broadcast messages"),process.on("message",Qu)):Wu.isMaster?(Ju("listening for cluster messages"),Wu.on("message",Qu)):Ju("not listening for messages, because we are not a master process")}));var eo={onlyOnMaster:(e,t)=>Xu()?e():t,isMaster:Xu,send:e=>{Xu()?Zu(e):(Ku||(e.cluster={workerId:Wu.worker.id,worker:process.pid}),process.send({topic:"log4js:message",data:e.serialise()}))},onMessage:e=>{zu.push(e)}},to={};function no(e){if("number"==typeof e&&Number.isInteger(e))return e;const t={K:1024,M:1048576,G:1073741824},n=Object.keys(t),r=e.substr(e.length-1).toLocaleUpperCase(),u=e.substring(0,e.length-1).trim();if(n.indexOf(r)<0||!Number.isInteger(Number(u)))throw Error(`maxLogSize: "${e}" is invalid`);return u*t[r]}function ro(e){return function(e,t){const n=Object.assign({},t);return Object.keys(e).forEach((r=>{n[r]&&(n[r]=e[r](t[r]))})),n}({maxLogSize:no},e)}const uo={file:ro,fileSync:ro};to.modifyConfig=e=>uo[e.type]?uo[e.type](e):e;var oo={};const io=console.log.bind(console);oo.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{io(e(n,t))}}(n,e.timezoneOffset)};var so={};so.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{process.stdout.write(`${e(n,t)}\n`)}}(n,e.timezoneOffset)};var co={};co.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{process.stderr.write(`${e(n,t)}\n`)}}(n,e.timezoneOffset)};var ao={};ao.configure=function(e,t,n,r){const u=n(e.appender);return function(e,t,n,r){const u=r.getLevel(e),o=r.getLevel(t,r.FATAL);return e=>{const t=e.level;t.isGreaterThanOrEqualTo(u)&&t.isLessThanOrEqualTo(o)&&n(e)}}(e.level,e.maxLevel,u,r)};var lo={};const fo=Nr.exports("log4js:categoryFilter");lo.configure=function(e,t,n){const r=n(e.appender);return function(e,t){return"string"==typeof e&&(e=[e]),n=>{fo(`Checking ${n.categoryName} against ${e}`),-1===e.indexOf(n.categoryName)&&(fo("Not excluded, sending to appender"),t(n))}}(e.exclude,r)};var Do={};const po=Nr.exports("log4js:noLogFilter");Do.configure=function(e,t,n){const r=n(e.appender);return function(e,t){return n=>{po(`Checking data: ${n.data} against filters: ${e}`),"string"==typeof e&&(e=[e]),e=e.filter((e=>null!=e&&""!==e));const r=new RegExp(e.join("|"),"i");(0===e.length||n.data.findIndex((e=>r.test(e)))<0)&&(po("Not excluded, sending to appender"),t(n))}}(e.exclude,r)};var Eo={},mo={exports:{}},ho={},yo={fromCallback:function(e){return Object.defineProperty((function(){if("function"!=typeof arguments[arguments.length-1])return new Promise(((t,n)=>{arguments[arguments.length]=(e,r)=>{if(e)return n(e);t(r)},arguments.length++,e.apply(this,arguments)}));e.apply(this,arguments)}),"name",{value:e.name})},fromPromise:function(e){return Object.defineProperty((function(){const t=arguments[arguments.length-1];if("function"!=typeof t)return e.apply(this,arguments);e.apply(this,arguments).then((e=>t(null,e)),t)}),"name",{value:e.name})}};!function(e){const t=yo.fromCallback,n=we,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchown","lchmod","link","lstat","mkdir","mkdtemp","open","readFile","readdir","readlink","realpath","rename","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter((e=>"function"==typeof n[e]));Object.keys(n).forEach((t=>{"promises"!==t&&(e[t]=n[t])})),r.forEach((r=>{e[r]=t(n[r])})),e.exists=function(e,t){return"function"==typeof t?n.exists(e,t):new Promise((t=>n.exists(e,t)))},e.read=function(e,t,r,u,o,i){return"function"==typeof i?n.read(e,t,r,u,o,i):new Promise(((i,s)=>{n.read(e,t,r,u,o,((e,t,n)=>{if(e)return s(e);i({bytesRead:t,buffer:n})}))}))},e.write=function(e,t,...r){return"function"==typeof r[r.length-1]?n.write(e,t,...r):new Promise(((u,o)=>{n.write(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffer:n})}))}))},"function"==typeof n.realpath.native&&(e.realpath.native=t(n.realpath.native))}(ho);const Co=p.default;function Fo(e){return(e=Co.normalize(Co.resolve(e)).split(Co.sep)).length>0?e[0]:null}const go=/[<>:"|?*]/;var Ao=function(e){const t=Fo(e);return e=e.replace(t,""),go.test(e)};const vo=we,So=p.default,wo=Ao,Oo=parseInt("0777",8);var bo=function e(t,n,r,u){if("function"==typeof n?(r=n,n={}):n&&"object"==typeof n||(n={mode:n}),"win32"===process.platform&&wo(t)){const e=new Error(t+" contains invalid WIN32 path characters.");return e.code="EINVAL",r(e)}let o=n.mode;const i=n.fs||vo;void 0===o&&(o=Oo&~process.umask()),u||(u=null),r=r||function(){},t=So.resolve(t),i.mkdir(t,o,(o=>{if(!o)return r(null,u=u||t);if("ENOENT"===o.code){if(So.dirname(t)===t)return r(o);e(So.dirname(t),n,((u,o)=>{u?r(u,o):e(t,n,r,o)}))}else i.stat(t,((e,t)=>{e||!t.isDirectory()?r(o,u):r(null,u)}))}))};const _o=we,Bo=p.default,Po=Ao,ko=parseInt("0777",8);var xo=function e(t,n,r){n&&"object"==typeof n||(n={mode:n});let u=n.mode;const o=n.fs||_o;if("win32"===process.platform&&Po(t)){const e=new Error(t+" contains invalid WIN32 path characters.");throw e.code="EINVAL",e}void 0===u&&(u=ko&~process.umask()),r||(r=null),t=Bo.resolve(t);try{o.mkdirSync(t,u),r=r||t}catch(u){if("ENOENT"===u.code){if(Bo.dirname(t)===t)throw u;r=e(Bo.dirname(t),n,r),e(t,n,r)}else{let e;try{e=o.statSync(t)}catch(e){throw u}if(!e.isDirectory())throw u}}return r};const No=(0,yo.fromCallback)(bo);var Io={mkdirs:No,mkdirsSync:xo,mkdirp:No,mkdirpSync:xo,ensureDir:No,ensureDirSync:xo};const To=we;E.default,p.default;var Ro=function(e,t,n,r){To.open(e,"r+",((e,u)=>{if(e)return r(e);To.futimes(u,t,n,(e=>{To.close(u,(t=>{r&&r(e||t)}))}))}))},Mo=function(e,t,n){const r=To.openSync(e,"r+");return To.futimesSync(r,t,n),To.closeSync(r)};const Lo=we,jo=p.default,$o=10,Ho=5,Jo=0,Go=process.versions.node.split("."),Vo=Number.parseInt(Go[0],10),Uo=Number.parseInt(Go[1],10),Wo=Number.parseInt(Go[2],10);function zo(){if(Vo>$o)return!0;if(Vo===$o){if(Uo>Ho)return!0;if(Uo===Ho&&Wo>=Jo)return!0}return!1}function Ko(e,t){const n=jo.resolve(e).split(jo.sep).filter((e=>e)),r=jo.resolve(t).split(jo.sep).filter((e=>e));return n.reduce(((e,t,n)=>e&&r[n]===t),!0)}function qo(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}var Yo,Xo,Zo={checkPaths:function(e,t,n,r){!function(e,t,n){zo()?Lo.stat(e,{bigint:!0},((e,r)=>{if(e)return n(e);Lo.stat(t,{bigint:!0},((e,t)=>e?"ENOENT"===e.code?n(null,{srcStat:r,destStat:null}):n(e):n(null,{srcStat:r,destStat:t})))})):Lo.stat(e,((e,r)=>{if(e)return n(e);Lo.stat(t,((e,t)=>e?"ENOENT"===e.code?n(null,{srcStat:r,destStat:null}):n(e):n(null,{srcStat:r,destStat:t})))}))}(e,t,((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;return s&&s.ino&&s.dev&&s.ino===i.ino&&s.dev===i.dev?r(new Error("Source and destination must not be the same.")):i.isDirectory()&&Ko(e,t)?r(new Error(qo(e,t,n))):r(null,{srcStat:i,destStat:s})}))},checkPathsSync:function(e,t,n){const{srcStat:r,destStat:u}=function(e,t){let n,r;n=zo()?Lo.statSync(e,{bigint:!0}):Lo.statSync(e);try{r=zo()?Lo.statSync(t,{bigint:!0}):Lo.statSync(t)}catch(e){if("ENOENT"===e.code)return{srcStat:n,destStat:null};throw e}return{srcStat:n,destStat:r}}(e,t);if(u&&u.ino&&u.dev&&u.ino===r.ino&&u.dev===r.dev)throw new Error("Source and destination must not be the same.");if(r.isDirectory()&&Ko(e,t))throw new Error(qo(e,t,n));return{srcStat:r,destStat:u}},checkParentPaths:function e(t,n,r,u,o){const i=jo.resolve(jo.dirname(t)),s=jo.resolve(jo.dirname(r));if(s===i||s===jo.parse(s).root)return o();zo()?Lo.stat(s,{bigint:!0},((i,c)=>i?"ENOENT"===i.code?o():o(i):c.ino&&c.dev&&c.ino===n.ino&&c.dev===n.dev?o(new Error(qo(t,r,u))):e(t,n,s,u,o))):Lo.stat(s,((i,c)=>i?"ENOENT"===i.code?o():o(i):c.ino&&c.dev&&c.ino===n.ino&&c.dev===n.dev?o(new Error(qo(t,r,u))):e(t,n,s,u,o)))},checkParentPathsSync:function e(t,n,r,u){const o=jo.resolve(jo.dirname(t)),i=jo.resolve(jo.dirname(r));if(i===o||i===jo.parse(i).root)return;let s;try{s=zo()?Lo.statSync(i,{bigint:!0}):Lo.statSync(i)}catch(e){if("ENOENT"===e.code)return;throw e}if(s.ino&&s.dev&&s.ino===n.ino&&s.dev===n.dev)throw new Error(qo(t,r,u));return e(t,n,i,u)},isSrcSubdir:Ko};const Qo=we,ei=p.default,ti=Io.mkdirsSync,ni=Mo,ri=Zo;function ui(e,t,n,r){if(!r.filter||r.filter(t,n))return function(e,t,n,r){const u=r.dereference?Qo.statSync:Qo.lstatSync,o=u(t);if(o.isDirectory())return function(e,t,n,r,u){if(!t)return function(e,t,n,r){return Qo.mkdirSync(n),ii(t,n,r),Qo.chmodSync(n,e.mode)}(e,n,r,u);if(t&&!t.isDirectory())throw new Error(`Cannot overwrite non-directory '${r}' with directory '${n}'.`);return ii(n,r,u)}(o,e,t,n,r);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return function(e,t,n,r,u){return t?function(e,t,n,r){if(r.overwrite)return Qo.unlinkSync(n),oi(e,t,n,r);if(r.errorOnExist)throw new Error(`'${n}' already exists`)}(e,n,r,u):oi(e,n,r,u)}(o,e,t,n,r);if(o.isSymbolicLink())return function(e,t,n,r){let u=Qo.readlinkSync(t);r.dereference&&(u=ei.resolve(process.cwd(),u));if(e){let e;try{e=Qo.readlinkSync(n)}catch(e){if("EINVAL"===e.code||"UNKNOWN"===e.code)return Qo.symlinkSync(u,n);throw e}if(r.dereference&&(e=ei.resolve(process.cwd(),e)),ri.isSrcSubdir(u,e))throw new Error(`Cannot copy '${u}' to a subdirectory of itself, '${e}'.`);if(Qo.statSync(n).isDirectory()&&ri.isSrcSubdir(e,u))throw new Error(`Cannot overwrite '${e}' with '${u}'.`);return function(e,t){return Qo.unlinkSync(t),Qo.symlinkSync(e,t)}(u,n)}return Qo.symlinkSync(u,n)}(e,t,n,r)}(e,t,n,r)}function oi(e,t,n,r){return"function"==typeof Qo.copyFileSync?(Qo.copyFileSync(t,n),Qo.chmodSync(n,e.mode),r.preserveTimestamps?ni(n,e.atime,e.mtime):void 0):function(e,t,n,r){const u=65536,o=(Xo?Yo:(Xo=1,Yo=function(e){if("function"==typeof Buffer.allocUnsafe)try{return Buffer.allocUnsafe(e)}catch(t){return new Buffer(e)}return new Buffer(e)}))(u),i=Qo.openSync(t,"r"),s=Qo.openSync(n,"w",e.mode);let c=0;for(;cfunction(e,t,n,r){const u=ei.join(t,e),o=ei.join(n,e),{destStat:i}=ri.checkPathsSync(u,o,"copy");return ui(i,u,o,r)}(r,e,t,n)))}var si=function(e,t,n){"function"==typeof n&&(n={filter:n}),(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:u}=ri.checkPathsSync(e,t,"copy");return ri.checkParentPathsSync(e,r,t,"copy"),function(e,t,n,r){if(r.filter&&!r.filter(t,n))return;const u=ei.dirname(n);Qo.existsSync(u)||ti(u);return ui(e,t,n,r)}(u,e,t,n)},ci={copySync:si};const ai=yo.fromPromise,li=ho;var fi={pathExists:ai((function(e){return li.access(e).then((()=>!0)).catch((()=>!1))})),pathExistsSync:li.existsSync};const di=we,Di=p.default,pi=Io.mkdirs,Ei=fi.pathExists,mi=Ro,hi=Zo;function yi(e,t,n,r,u){const o=Di.dirname(n);Ei(o,((i,s)=>i?u(i):s?Fi(e,t,n,r,u):void pi(o,(o=>o?u(o):Fi(e,t,n,r,u)))))}function Ci(e,t,n,r,u,o){Promise.resolve(u.filter(n,r)).then((i=>i?e(t,n,r,u,o):o()),(e=>o(e)))}function Fi(e,t,n,r,u){return r.filter?Ci(gi,e,t,n,r,u):gi(e,t,n,r,u)}function gi(e,t,n,r,u){(r.dereference?di.stat:di.lstat)(t,((o,i)=>o?u(o):i.isDirectory()?function(e,t,n,r,u,o){if(!t)return function(e,t,n,r,u){di.mkdir(n,(o=>{if(o)return u(o);Si(t,n,r,(t=>t?u(t):di.chmod(n,e.mode,u)))}))}(e,n,r,u,o);if(t&&!t.isDirectory())return o(new Error(`Cannot overwrite non-directory '${r}' with directory '${n}'.`));return Si(n,r,u,o)}(i,e,t,n,r,u):i.isFile()||i.isCharacterDevice()||i.isBlockDevice()?function(e,t,n,r,u,o){return t?function(e,t,n,r,u){if(!r.overwrite)return r.errorOnExist?u(new Error(`'${n}' already exists`)):u();di.unlink(n,(o=>o?u(o):Ai(e,t,n,r,u)))}(e,n,r,u,o):Ai(e,n,r,u,o)}(i,e,t,n,r,u):i.isSymbolicLink()?function(e,t,n,r,u){di.readlink(t,((t,o)=>t?u(t):(r.dereference&&(o=Di.resolve(process.cwd(),o)),e?void di.readlink(n,((t,i)=>t?"EINVAL"===t.code||"UNKNOWN"===t.code?di.symlink(o,n,u):u(t):(r.dereference&&(i=Di.resolve(process.cwd(),i)),hi.isSrcSubdir(o,i)?u(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`)):e.isDirectory()&&hi.isSrcSubdir(i,o)?u(new Error(`Cannot overwrite '${i}' with '${o}'.`)):function(e,t,n){di.unlink(t,(r=>r?n(r):di.symlink(e,t,n)))}(o,n,u)))):di.symlink(o,n,u))))}(e,t,n,r,u):void 0))}function Ai(e,t,n,r,u){return"function"==typeof di.copyFile?di.copyFile(t,n,(t=>t?u(t):vi(e,n,r,u))):function(e,t,n,r,u){const o=di.createReadStream(t);o.on("error",(e=>u(e))).once("open",(()=>{const t=di.createWriteStream(n,{mode:e.mode});t.on("error",(e=>u(e))).on("open",(()=>o.pipe(t))).once("close",(()=>vi(e,n,r,u)))}))}(e,t,n,r,u)}function vi(e,t,n,r){di.chmod(t,e.mode,(u=>u?r(u):n.preserveTimestamps?mi(t,e.atime,e.mtime,r):r()))}function Si(e,t,n,r){di.readdir(e,((u,o)=>u?r(u):wi(o,e,t,n,r)))}function wi(e,t,n,r,u){const o=e.pop();return o?function(e,t,n,r,u,o){const i=Di.join(n,t),s=Di.join(r,t);hi.checkPaths(i,s,"copy",((t,c)=>{if(t)return o(t);const{destStat:a}=c;Fi(a,i,s,u,(t=>t?o(t):wi(e,n,r,u,o)))}))}(e,o,t,n,r,u):u()}var Oi=function(e,t,n,r){"function"!=typeof n||r?"function"==typeof n&&(n={filter:n}):(r=n,n={}),r=r||function(){},(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),hi.checkPaths(e,t,"copy",((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;hi.checkParentPaths(e,i,t,"copy",(u=>u?r(u):n.filter?Ci(yi,s,e,t,n,r):yi(s,e,t,n,r)))}))};var bi={copy:(0,yo.fromCallback)(Oi)};const _i=we,Bi=p.default,Pi=g.default,ki="win32"===process.platform;function xi(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach((t=>{e[t]=e[t]||_i[t],e[t+="Sync"]=e[t]||_i[t]})),e.maxBusyTries=e.maxBusyTries||3}function Ni(e,t,n){let r=0;"function"==typeof t&&(n=t,t={}),Pi(e,"rimraf: missing path"),Pi.strictEqual(typeof e,"string","rimraf: path should be a string"),Pi.strictEqual(typeof n,"function","rimraf: callback function required"),Pi(t,"rimraf: invalid options argument provided"),Pi.strictEqual(typeof t,"object","rimraf: options should be object"),xi(t),Ii(e,t,(function u(o){if(o){if(("EBUSY"===o.code||"ENOTEMPTY"===o.code||"EPERM"===o.code)&&rIi(e,t,u)),100*r)}"ENOENT"===o.code&&(o=null)}n(o)}))}function Ii(e,t,n){Pi(e),Pi(t),Pi("function"==typeof n),t.lstat(e,((r,u)=>r&&"ENOENT"===r.code?n(null):r&&"EPERM"===r.code&&ki?Ti(e,t,r,n):u&&u.isDirectory()?Mi(e,t,r,n):void t.unlink(e,(r=>{if(r){if("ENOENT"===r.code)return n(null);if("EPERM"===r.code)return ki?Ti(e,t,r,n):Mi(e,t,r,n);if("EISDIR"===r.code)return Mi(e,t,r,n)}return n(r)}))))}function Ti(e,t,n,r){Pi(e),Pi(t),Pi("function"==typeof r),n&&Pi(n instanceof Error),t.chmod(e,438,(u=>{u?r("ENOENT"===u.code?null:n):t.stat(e,((u,o)=>{u?r("ENOENT"===u.code?null:n):o.isDirectory()?Mi(e,t,n,r):t.unlink(e,r)}))}))}function Ri(e,t,n){let r;Pi(e),Pi(t),n&&Pi(n instanceof Error);try{t.chmodSync(e,438)}catch(e){if("ENOENT"===e.code)return;throw n}try{r=t.statSync(e)}catch(e){if("ENOENT"===e.code)return;throw n}r.isDirectory()?ji(e,t,n):t.unlinkSync(e)}function Mi(e,t,n,r){Pi(e),Pi(t),n&&Pi(n instanceof Error),Pi("function"==typeof r),t.rmdir(e,(u=>{!u||"ENOTEMPTY"!==u.code&&"EEXIST"!==u.code&&"EPERM"!==u.code?u&&"ENOTDIR"===u.code?r(n):r(u):function(e,t,n){Pi(e),Pi(t),Pi("function"==typeof n),t.readdir(e,((r,u)=>{if(r)return n(r);let o,i=u.length;if(0===i)return t.rmdir(e,n);u.forEach((r=>{Ni(Bi.join(e,r),t,(r=>{if(!o)return r?n(o=r):void(0==--i&&t.rmdir(e,n))}))}))}))}(e,t,r)}))}function Li(e,t){let n;xi(t=t||{}),Pi(e,"rimraf: missing path"),Pi.strictEqual(typeof e,"string","rimraf: path should be a string"),Pi(t,"rimraf: missing options"),Pi.strictEqual(typeof t,"object","rimraf: options should be object");try{n=t.lstatSync(e)}catch(n){if("ENOENT"===n.code)return;"EPERM"===n.code&&ki&&Ri(e,t,n)}try{n&&n.isDirectory()?ji(e,t,null):t.unlinkSync(e)}catch(n){if("ENOENT"===n.code)return;if("EPERM"===n.code)return ki?Ri(e,t,n):ji(e,t,n);if("EISDIR"!==n.code)throw n;ji(e,t,n)}}function ji(e,t,n){Pi(e),Pi(t),n&&Pi(n instanceof Error);try{t.rmdirSync(e)}catch(r){if("ENOTDIR"===r.code)throw n;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(e,t){if(Pi(e),Pi(t),t.readdirSync(e).forEach((n=>Li(Bi.join(e,n),t))),!ki){return t.rmdirSync(e,t)}{const n=Date.now();do{try{return t.rmdirSync(e,t)}catch(e){}}while(Date.now()-n<500)}}(e,t);else if("ENOENT"!==r.code)throw r}}var $i=Ni;Ni.sync=Li;const Hi=$i;var Ji={remove:(0,yo.fromCallback)(Hi),removeSync:Hi.sync};const Gi=yo.fromCallback,Vi=we,Ui=p.default,Wi=Io,zi=Ji,Ki=Gi((function(e,t){t=t||function(){},Vi.readdir(e,((n,r)=>{if(n)return Wi.mkdirs(e,t);r=r.map((t=>Ui.join(e,t))),function e(){const n=r.pop();if(!n)return t();zi.remove(n,(n=>{if(n)return t(n);e()}))}()}))}));function qi(e){let t;try{t=Vi.readdirSync(e)}catch(t){return Wi.mkdirsSync(e)}t.forEach((t=>{t=Ui.join(e,t),zi.removeSync(t)}))}var Yi={emptyDirSync:qi,emptydirSync:qi,emptyDir:Ki,emptydir:Ki};const Xi=yo.fromCallback,Zi=p.default,Qi=we,es=Io,ts=fi.pathExists;var ns={createFile:Xi((function(e,t){function n(){Qi.writeFile(e,"",(e=>{if(e)return t(e);t()}))}Qi.stat(e,((r,u)=>{if(!r&&u.isFile())return t();const o=Zi.dirname(e);ts(o,((e,r)=>e?t(e):r?n():void es.mkdirs(o,(e=>{if(e)return t(e);n()}))))}))})),createFileSync:function(e){let t;try{t=Qi.statSync(e)}catch(e){}if(t&&t.isFile())return;const n=Zi.dirname(e);Qi.existsSync(n)||es.mkdirsSync(n),Qi.writeFileSync(e,"")}};const rs=yo.fromCallback,us=p.default,os=we,is=Io,ss=fi.pathExists;var cs={createLink:rs((function(e,t,n){function r(e,t){os.link(e,t,(e=>{if(e)return n(e);n(null)}))}ss(t,((u,o)=>u?n(u):o?n(null):void os.lstat(e,(u=>{if(u)return u.message=u.message.replace("lstat","ensureLink"),n(u);const o=us.dirname(t);ss(o,((u,i)=>u?n(u):i?r(e,t):void is.mkdirs(o,(u=>{if(u)return n(u);r(e,t)}))))}))))})),createLinkSync:function(e,t){if(os.existsSync(t))return;try{os.lstatSync(e)}catch(e){throw e.message=e.message.replace("lstat","ensureLink"),e}const n=us.dirname(t);return os.existsSync(n)||is.mkdirsSync(n),os.linkSync(e,t)}};const as=p.default,ls=we,fs=fi.pathExists;var ds={symlinkPaths:function(e,t,n){if(as.isAbsolute(e))return ls.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:e})));{const r=as.dirname(t),u=as.join(r,e);return fs(u,((t,o)=>t?n(t):o?n(null,{toCwd:u,toDst:e}):ls.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:as.relative(r,e)})))))}},symlinkPathsSync:function(e,t){let n;if(as.isAbsolute(e)){if(n=ls.existsSync(e),!n)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}{const r=as.dirname(t),u=as.join(r,e);if(n=ls.existsSync(u),n)return{toCwd:u,toDst:e};if(n=ls.existsSync(e),!n)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:as.relative(r,e)}}}};const Ds=we;var ps={symlinkType:function(e,t,n){if(n="function"==typeof t?t:n,t="function"!=typeof t&&t)return n(null,t);Ds.lstat(e,((e,r)=>{if(e)return n(null,"file");t=r&&r.isDirectory()?"dir":"file",n(null,t)}))},symlinkTypeSync:function(e,t){let n;if(t)return t;try{n=Ds.lstatSync(e)}catch(e){return"file"}return n&&n.isDirectory()?"dir":"file"}};const Es=yo.fromCallback,ms=p.default,hs=we,ys=Io.mkdirs,Cs=Io.mkdirsSync,Fs=ds.symlinkPaths,gs=ds.symlinkPathsSync,As=ps.symlinkType,vs=ps.symlinkTypeSync,Ss=fi.pathExists;var ws={createSymlink:Es((function(e,t,n,r){r="function"==typeof n?n:r,n="function"!=typeof n&&n,Ss(t,((u,o)=>u?r(u):o?r(null):void Fs(e,t,((u,o)=>{if(u)return r(u);e=o.toDst,As(o.toCwd,n,((n,u)=>{if(n)return r(n);const o=ms.dirname(t);Ss(o,((n,i)=>n?r(n):i?hs.symlink(e,t,u,r):void ys(o,(n=>{if(n)return r(n);hs.symlink(e,t,u,r)}))))}))}))))})),createSymlinkSync:function(e,t,n){if(hs.existsSync(t))return;const r=gs(e,t);e=r.toDst,n=vs(r.toCwd,n);const u=ms.dirname(t);return hs.existsSync(u)||Cs(u),hs.symlinkSync(e,t,n)}};var Os,bs={createFile:ns.createFile,createFileSync:ns.createFileSync,ensureFile:ns.createFile,ensureFileSync:ns.createFileSync,createLink:cs.createLink,createLinkSync:cs.createLinkSync,ensureLink:cs.createLink,ensureLinkSync:cs.createLinkSync,createSymlink:ws.createSymlink,createSymlinkSync:ws.createSymlinkSync,ensureSymlink:ws.createSymlink,ensureSymlinkSync:ws.createSymlinkSync};try{Os=we}catch(e){Os=D.default}function _s(e,t){var n,r="\n";return"object"==typeof t&&null!==t&&(t.spaces&&(n=t.spaces),t.EOL&&(r=t.EOL)),JSON.stringify(e,t?t.replacer:null,n).replace(/\n/g,r)+r}function Bs(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e=e.replace(/^\uFEFF/,"")}var Ps={readFile:function(e,t,n){null==n&&(n=t,t={}),"string"==typeof t&&(t={encoding:t});var r=(t=t||{}).fs||Os,u=!0;"throws"in t&&(u=t.throws),r.readFile(e,t,(function(r,o){if(r)return n(r);var i;o=Bs(o);try{i=JSON.parse(o,t?t.reviver:null)}catch(t){return u?(t.message=e+": "+t.message,n(t)):n(null,null)}n(null,i)}))},readFileSync:function(e,t){"string"==typeof(t=t||{})&&(t={encoding:t});var n=t.fs||Os,r=!0;"throws"in t&&(r=t.throws);try{var u=n.readFileSync(e,t);return u=Bs(u),JSON.parse(u,t.reviver)}catch(t){if(r)throw t.message=e+": "+t.message,t;return null}},writeFile:function(e,t,n,r){null==r&&(r=n,n={});var u=(n=n||{}).fs||Os,o="";try{o=_s(t,n)}catch(e){return void(r&&r(e,null))}u.writeFile(e,o,n,r)},writeFileSync:function(e,t,n){var r=(n=n||{}).fs||Os,u=_s(t,n);return r.writeFileSync(e,u,n)}},ks=Ps;const xs=yo.fromCallback,Ns=ks;var Is={readJson:xs(Ns.readFile),readJsonSync:Ns.readFileSync,writeJson:xs(Ns.writeFile),writeJsonSync:Ns.writeFileSync};const Ts=p.default,Rs=Io,Ms=fi.pathExists,Ls=Is;var js=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=Ts.dirname(e);Ms(u,((o,i)=>o?r(o):i?Ls.writeJson(e,t,n,r):void Rs.mkdirs(u,(u=>{if(u)return r(u);Ls.writeJson(e,t,n,r)}))))};const $s=we,Hs=p.default,Js=Io,Gs=Is;var Vs=function(e,t,n){const r=Hs.dirname(e);$s.existsSync(r)||Js.mkdirsSync(r),Gs.writeJsonSync(e,t,n)};const Us=yo.fromCallback,Ws=Is;Ws.outputJson=Us(js),Ws.outputJsonSync=Vs,Ws.outputJSON=Ws.outputJson,Ws.outputJSONSync=Ws.outputJsonSync,Ws.writeJSON=Ws.writeJson,Ws.writeJSONSync=Ws.writeJsonSync,Ws.readJSON=Ws.readJson,Ws.readJSONSync=Ws.readJsonSync;var zs=Ws;const Ks=we,qs=p.default,Ys=ci.copySync,Xs=Ji.removeSync,Zs=Io.mkdirpSync,Qs=Zo;function ec(e,t,n){try{Ks.renameSync(e,t)}catch(r){if("EXDEV"!==r.code)throw r;return function(e,t,n){const r={overwrite:n,errorOnExist:!0};return Ys(e,t,r),Xs(e)}(e,t,n)}}var tc=function(e,t,n){const r=(n=n||{}).overwrite||n.clobber||!1,{srcStat:u}=Qs.checkPathsSync(e,t,"move");return Qs.checkParentPathsSync(e,u,t,"move"),Zs(qs.dirname(t)),function(e,t,n){if(n)return Xs(t),ec(e,t,n);if(Ks.existsSync(t))throw new Error("dest already exists.");return ec(e,t,n)}(e,t,r)},nc={moveSync:tc};const rc=we,uc=p.default,oc=bi.copy,ic=Ji.remove,sc=Io.mkdirp,cc=fi.pathExists,ac=Zo;function lc(e,t,n,r){rc.rename(e,t,(u=>u?"EXDEV"!==u.code?r(u):function(e,t,n,r){const u={overwrite:n,errorOnExist:!0};oc(e,t,u,(t=>t?r(t):ic(e,r)))}(e,t,n,r):r()))}var fc=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=n.overwrite||n.clobber||!1;ac.checkPaths(e,t,"move",((n,o)=>{if(n)return r(n);const{srcStat:i}=o;ac.checkParentPaths(e,i,t,"move",(n=>{if(n)return r(n);sc(uc.dirname(t),(n=>n?r(n):function(e,t,n,r){if(n)return ic(t,(u=>u?r(u):lc(e,t,n,r)));cc(t,((u,o)=>u?r(u):o?r(new Error("dest already exists.")):lc(e,t,n,r)))}(e,t,u,r)))}))}))};var dc={move:(0,yo.fromCallback)(fc)};const Dc=yo.fromCallback,pc=we,Ec=p.default,mc=Io,hc=fi.pathExists;var yc={outputFile:Dc((function(e,t,n,r){"function"==typeof n&&(r=n,n="utf8");const u=Ec.dirname(e);hc(u,((o,i)=>o?r(o):i?pc.writeFile(e,t,n,r):void mc.mkdirs(u,(u=>{if(u)return r(u);pc.writeFile(e,t,n,r)}))))})),outputFileSync:function(e,...t){const n=Ec.dirname(e);if(pc.existsSync(n))return pc.writeFileSync(e,...t);mc.mkdirsSync(n),pc.writeFileSync(e,...t)}};!function(e){e.exports=Object.assign({},ho,ci,bi,Yi,bs,zs,Io,nc,dc,yc,fi,Ji);const t=D.default;Object.getOwnPropertyDescriptor(t,"promises")&&Object.defineProperty(e.exports,"promises",{get:()=>t.promises})}(mo);const Cc=Nr.exports("streamroller:fileNameFormatter"),Fc=p.default;const gc=Nr.exports("streamroller:fileNameParser"),Ac=nu.exports;const vc=Nr.exports("streamroller:moveAndMaybeCompressFile"),Sc=mo.exports,wc=v.default;var Oc=async(e,t,n)=>{if(n=function(e){const t={mode:parseInt("0600",8),compress:!1},n=Object.assign({},t,e);return vc(`_parseOption: moveAndMaybeCompressFile called with option=${JSON.stringify(n)}`),n}(n),e!==t){if(await Sc.pathExists(e))if(vc(`moveAndMaybeCompressFile: moving file from ${e} to ${t} ${n.compress?"with":"without"} compress`),n.compress)await new Promise(((r,u)=>{let o=!1;const i=Sc.createWriteStream(t,{mode:n.mode,flags:"wx"}).on("open",(()=>{o=!0;const t=Sc.createReadStream(e).on("open",(()=>{t.pipe(wc.createGzip()).pipe(i)})).on("error",(t=>{vc(`moveAndMaybeCompressFile: error reading ${e}`,t),i.destroy(t)}))})).on("finish",(()=>{vc(`moveAndMaybeCompressFile: finished compressing ${t}, deleting ${e}`),Sc.unlink(e).then(r).catch((t=>{vc(`moveAndMaybeCompressFile: error deleting ${e}, truncating instead`,t),Sc.truncate(e).then(r).catch((t=>{vc(`moveAndMaybeCompressFile: error truncating ${e}`,t),u(t)}))}))})).on("error",(e=>{o?(vc(`moveAndMaybeCompressFile: error writing ${t}, deleting`,e),Sc.unlink(t).then((()=>{u(e)})).catch((e=>{vc(`moveAndMaybeCompressFile: error deleting ${t}`,e),u(e)}))):(vc(`moveAndMaybeCompressFile: error creating ${t}`,e),u(e))}))})).catch((()=>{}));else{vc(`moveAndMaybeCompressFile: renaming ${e} to ${t}`);try{await Sc.move(e,t,{overwrite:!0})}catch(n){if(vc(`moveAndMaybeCompressFile: error renaming ${e} to ${t}`,n),"ENOENT"!==n.code){vc("moveAndMaybeCompressFile: trying copy+truncate instead");try{await Sc.copy(e,t,{overwrite:!0}),await Sc.truncate(e)}catch(e){vc("moveAndMaybeCompressFile: error copy+truncate",e)}}}}}else vc("moveAndMaybeCompressFile: source and target are the same, not doing anything")};const bc=Nr.exports("streamroller:RollingFileWriteStream"),_c=mo.exports,Bc=p.default,Pc=E.default,kc=()=>new Date,xc=nu.exports,{Writable:Nc}=C.default,Ic=({file:e,keepFileExt:t,needsIndex:n,alwaysIncludeDate:r,compress:u,fileNameSep:o})=>{let i=o||".";const s=Fc.join(e.dir,e.name),c=t=>t+e.ext,a=(e,t,r)=>!n&&r||!t?e:e+i+t,l=(e,t,n)=>(t>0||r)&&n?e+i+n:e,f=(e,t)=>t&&u?e+".gz":e,d=t?[l,a,c,f]:[c,l,a,f];return({date:e,index:t})=>(Cc(`_formatFileName: date=${e}, index=${t}`),d.reduce(((n,r)=>r(n,t,e)),s))},Tc=({file:e,keepFileExt:t,pattern:n,fileNameSep:r})=>{let u=r||".";const o="__NOT_MATCHING__";let i=[(e,t)=>e.endsWith(".gz")?(gc("it is gzipped"),t.isCompressed=!0,e.slice(0,-1*".gz".length)):e,t?t=>t.startsWith(e.name)&&t.endsWith(e.ext)?(gc("it starts and ends with the right things"),t.slice(e.name.length+1,-1*e.ext.length)):o:t=>t.startsWith(e.base)?(gc("it starts with the right things"),t.slice(e.base.length+1)):o,n?(e,t)=>{const r=e.split(u);let o=r[r.length-1];gc("items: ",r,", indexStr: ",o);let i=e;void 0!==o&&o.match(/^\d+$/)?(i=e.slice(0,-1*(o.length+1)),gc(`dateStr is ${i}`),n&&!i&&(i=o,o="0")):o="0";try{const r=Ac.parse(n,i,new Date(0,0));return Ac.asString(n,r)!==i?e:(t.index=parseInt(o,10),t.date=i,t.timestamp=r.getTime(),"")}catch(t){return gc(`Problem parsing ${i} as ${n}, error was: `,t),e}}:(e,t)=>e.match(/^\d+$/)?(gc("it has an index"),t.index=parseInt(e,10),""):e];return e=>{let t={filename:e,index:0,isCompressed:!1};return i.reduce(((e,n)=>n(e,t)),e)?null:t}},Rc=Oc;var Mc=class extends Nc{constructor(e,t){if(bc(`constructor: creating RollingFileWriteStream. path=${e}`),"string"!=typeof e||0===e.length)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(Bc.sep))throw new Error(`Filename is a directory: ${e}`);0===e.indexOf(`~${Bc.sep}`)&&(e=e.replace("~",Pc.homedir())),super(t),this.options=this._parseOption(t),this.fileObject=Bc.parse(e),""===this.fileObject.dir&&(this.fileObject=Bc.parse(Bc.join(process.cwd(),e))),this.fileFormatter=Ic({file:this.fileObject,alwaysIncludeDate:this.options.alwaysIncludePattern,needsIndex:this.options.maxSize 0`)}else delete n.maxSize;if(n.numBackups||0===n.numBackups){if(n.numBackups<0)throw new Error(`options.numBackups (${n.numBackups}) should be >= 0`);if(n.numBackups>=Number.MAX_SAFE_INTEGER)throw new Error(`options.numBackups (${n.numBackups}) should be < Number.MAX_SAFE_INTEGER`);n.numToKeep=n.numBackups+1}else if(n.numToKeep<=0)throw new Error(`options.numToKeep (${n.numToKeep}) should be > 0`);return bc(`_parseOption: creating stream with option=${JSON.stringify(n)}`),n}_final(e){this.currentFileStream.end("",this.options.encoding,e)}_write(e,t,n){this._shouldRoll().then((()=>{bc(`_write: writing chunk. file=${this.currentFileStream.path} state=${JSON.stringify(this.state)} chunk=${e}`),this.currentFileStream.write(e,t,(t=>{this.state.currentSize+=e.length,n(t)}))}))}async _shouldRoll(){(this._dateChanged()||this._tooBig())&&(bc(`_shouldRoll: rolling because dateChanged? ${this._dateChanged()} or tooBig? ${this._tooBig()}`),await this._roll())}_dateChanged(){return this.state.currentDate&&this.state.currentDate!==xc(this.options.pattern,kc())}_tooBig(){return this.state.currentSize>=this.options.maxSize}_roll(){return bc("_roll: closing the current stream"),new Promise(((e,t)=>{this.currentFileStream.end("",this.options.encoding,(()=>{this._moveOldFiles().then(e).catch(t)}))}))}async _moveOldFiles(){const e=await this._getExistingFiles();for(let t=(this.state.currentDate?e.filter((e=>e.date===this.state.currentDate)):e).length;t>=0;t--){bc(`_moveOldFiles: i = ${t}`);const e=this.fileFormatter({date:this.state.currentDate,index:t}),n=this.fileFormatter({date:this.state.currentDate,index:t+1}),r={compress:this.options.compress&&0===t,mode:this.options.mode};await Rc(e,n,r)}this.state.currentSize=0,this.state.currentDate=this.state.currentDate?xc(this.options.pattern,kc()):null,bc(`_moveOldFiles: finished rolling files. state=${JSON.stringify(this.state)}`),this._renewWriteStream(),await new Promise(((e,t)=>{this.currentFileStream.write("","utf8",(()=>{this._clean().then(e).catch(t)}))}))}async _getExistingFiles(){const e=await _c.readdir(this.fileObject.dir).catch((()=>[]));bc(`_getExistingFiles: files=${e}`);const t=e.map((e=>this.fileNameParser(e))).filter((e=>e)),n=e=>(e.timestamp?e.timestamp:kc().getTime())-e.index;return t.sort(((e,t)=>n(e)-n(t))),t}_renewWriteStream(){const e=this.fileFormatter({date:this.state.currentDate,index:0}),t=e=>{try{return _c.mkdirSync(e,{recursive:!0})}catch(n){if("ENOENT"===n.code)return t(Bc.dirname(e)),t(e);if("EEXIST"!==n.code&&"EROFS"!==n.code)throw n;try{if(_c.statSync(e).isDirectory())return e;throw n}catch(e){throw n}}};t(this.fileObject.dir);const n={flags:this.options.flags,encoding:this.options.encoding,mode:this.options.mode};var r,u;_c.appendFileSync(e,"",(r={...n},u="flags",r["flag"]=r[u],delete r[u],r)),this.currentFileStream=_c.createWriteStream(e,n),this.currentFileStream.on("error",(e=>{this.emit("error",e)}))}async _clean(){const e=await this._getExistingFiles();if(bc(`_clean: numToKeep = ${this.options.numToKeep}, existingFiles = ${e.length}`),bc("_clean: existing files are: ",e),this._tooManyFiles(e.length)){const n=e.slice(0,e.length-this.options.numToKeep).map((e=>Bc.format({dir:this.fileObject.dir,base:e.filename})));await(t=n,bc(`deleteFiles: files to delete: ${t}`),Promise.all(t.map((e=>_c.unlink(e).catch((t=>{bc(`deleteFiles: error when unlinking ${e}, ignoring. Error was ${t}`)}))))))}var t}_tooManyFiles(e){return this.options.numToKeep>0&&e>this.options.numToKeep}};const Lc=Mc;var jc=class extends Lc{constructor(e,t,n,r){r||(r={}),t&&(r.maxSize=t),r.numBackups||0===r.numBackups||(n||0===n||(n=1),r.numBackups=n),super(e,r),this.backups=r.numBackups,this.size=this.options.maxSize}get theStream(){return this.currentFileStream}};const $c=Mc;var Hc={RollingFileWriteStream:Mc,RollingFileStream:jc,DateRollingFileStream:class extends $c{constructor(e,t,n){t&&"object"==typeof t&&(n=t,t=null),n||(n={}),t||(t="yyyy-MM-dd"),n.pattern=t,n.numBackups||0===n.numBackups?n.daysToKeep=n.numBackups:(n.daysToKeep||0===n.daysToKeep?process.emitWarning("options.daysToKeep is deprecated due to the confusion it causes when used together with file size rolling. Please use options.numBackups instead.","DeprecationWarning","streamroller-DEP0001"):n.daysToKeep=1,n.numBackups=n.daysToKeep),super(e,n),this.mode=this.options.mode}get theStream(){return this.currentFileStream}}};const Jc=Nr.exports("log4js:file"),Gc=p.default,Vc=Hc,Uc=E.default.EOL;let Wc=!1;const zc=new Set;function Kc(){zc.forEach((e=>{e.sighupHandler()}))}function qc(e,t,n,r){const u=new Vc.RollingFileStream(e,t,n,r);return u.on("error",(t=>{console.error("log4js.fileAppender - Writing to file %s, error happened ",e,t)})),u.on("drain",(()=>{process.emit("log4js:pause",!1)})),u}Eo.configure=function(e,t){let n=t.basicLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),e.mode=e.mode||384,function(e,t,n,r,u,o){e=Gc.normalize(e),Jc("Creating file appender (",e,", ",n,", ",r=r||0===r?r:5,", ",u,", ",o,")");let i=qc(e,n,r,u);const s=function(e){if(i.writable){if(!0===u.removeColor){const t=/\x1b[[0-9;]*m/g;e.data=e.data.map((e=>"string"==typeof e?e.replace(t,""):e))}i.write(t(e,o)+Uc,"utf8")||process.emit("log4js:pause",!0)}};return s.reopen=function(){i.end((()=>{i=qc(e,n,r,u)}))},s.sighupHandler=function(){Jc("SIGHUP handler called."),s.reopen()},s.shutdown=function(e){zc.delete(s),0===zc.size&&Wc&&(process.removeListener("SIGHUP",Kc),Wc=!1),i.end("","utf-8",e)},zc.add(s),Wc||(process.on("SIGHUP",Kc),Wc=!0),s}(e.filename,n,e.maxLogSize,e.backups,e,e.timezoneOffset)};var Yc={};const Xc=Hc,Zc=E.default.EOL;function Qc(e,t,n,r,u){r.maxSize=r.maxLogSize;const o=function(e,t,n){const r=new Xc.DateRollingFileStream(e,t,n);return r.on("error",(t=>{console.error("log4js.dateFileAppender - Writing to file %s, error happened ",e,t)})),r.on("drain",(()=>{process.emit("log4js:pause",!1)})),r}(e,t,r),i=function(e){o.writable&&(o.write(n(e,u)+Zc,"utf8")||process.emit("log4js:pause",!0))};return i.shutdown=function(e){o.end("","utf-8",e)},i}Yc.configure=function(e,t){let n=t.basicLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),e.alwaysIncludePattern||(e.alwaysIncludePattern=!1),e.mode=e.mode||384,Qc(e.filename,e.pattern,n,e,e.timezoneOffset)};var ea={};const ta=Nr.exports("log4js:fileSync"),na=p.default,ra=D.default,ua=E.default.EOL||"\n";function oa(e,t){if(ra.existsSync(e))return;const n=ra.openSync(e,t.flags,t.mode);ra.closeSync(n)}class ia{constructor(e,t,n,r){ta("In RollingFileStream"),function(){if(!e||!t||t<=0)throw new Error("You must specify a filename and file size")}(),this.filename=e,this.size=t,this.backups=n,this.options=r,this.currentSize=0,this.currentSize=function(e){let t=0;try{t=ra.statSync(e).size}catch(t){oa(e,r)}return t}(this.filename)}shouldRoll(){return ta("should roll with current size %d, and max size %d",this.currentSize,this.size),this.currentSize>=this.size}roll(e){const t=this,n=new RegExp(`^${na.basename(e)}`);function r(e){return n.test(e)}function u(t){return parseInt(t.substring(`${na.basename(e)}.`.length),10)||0}function o(e,t){return u(e)>u(t)?1:u(e) ${e}.${r+1}`),ra.renameSync(na.join(na.dirname(e),n),`${e}.${r+1}`)}}ta("Rolling, rolling, rolling"),ta("Renaming the old files"),ra.readdirSync(na.dirname(e)).filter(r).sort(o).reverse().forEach(i)}write(e,t){const n=this;ta("in write"),this.shouldRoll()&&(this.currentSize=0,this.roll(this.filename)),ta("writing the chunk to the file"),n.currentSize+=e.length,ra.appendFileSync(n.filename,e)}}ea.configure=function(e,t){let n=t.basicLayout;e.layout&&(n=t.layout(e.layout.type,e.layout));const r={flags:e.flags||"a",encoding:e.encoding||"utf8",mode:e.mode||384};return function(e,t,n,r,u,o){ta("fileSync appender created");const i=function(e,t,n){let r;var u;return t?r=new ia(e,t,n,o):(oa(u=e,o),r={write(e){ra.appendFileSync(u,e)}}),r}(e=na.normalize(e),n,r=r||0===r?r:5);return e=>{i.write(t(e,u)+ua)}}(e.filename,n,e.maxLogSize,e.backups,e.timezoneOffset,r)};var sa={};const ca=Nr.exports("log4js:tcp"),aa=S.default;sa.configure=function(e,t){ca(`configure with config = ${e}`);let n=function(e){return e.serialise()};return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){let n=!1;const r=[];let u,o=3,i="__LOG4JS__";function s(e){ca("Writing log event to socket"),n=u.write(`${t(e)}${i}`,"utf8")}function c(){let e;for(ca("emptying buffer");e=r.shift();)s(e)}function a(e){n?s(e):(ca("buffering log event because it cannot write at the moment"),r.push(e))}return function t(){ca(`appender creating socket to ${e.host||"localhost"}:${e.port||5e3}`),i=`${e.endMsg||"__LOG4JS__"}`,u=aa.createConnection(e.port||5e3,e.host||"localhost"),u.on("connect",(()=>{ca("socket connected"),c(),n=!0})),u.on("drain",(()=>{ca("drain event received, emptying buffer"),n=!0,c()})),u.on("timeout",u.end.bind(u)),u.on("error",(e=>{ca("connection error",e),n=!1,c()})),u.on("close",t)}(),a.shutdown=function(e){ca("shutdown called"),r.length&&o?(ca("buffer has items, waiting 100ms to empty"),o-=1,setTimeout((()=>{a.shutdown(e)}),100)):(u.removeAllListeners("close"),u.end(e))},a}(e,n)};const la=p.default,fa=Nr.exports("log4js:appenders"),da=tu,Da=eo,pa=gu,Ea=hu,ma=to,ha=new Map;ha.set("console",oo),ha.set("stdout",so),ha.set("stderr",co),ha.set("logLevelFilter",ao),ha.set("categoryFilter",lo),ha.set("noLogFilter",Do),ha.set("file",Eo),ha.set("dateFile",Yc),ha.set("fileSync",ea),ha.set("tcp",sa);const ya=new Map,Ca=(e,t)=>{fa("Loading module from ",e);try{return require(e)}catch(n){return void da.throwExceptionIf(t,"MODULE_NOT_FOUND"!==n.code,`appender "${e}" could not be loaded (error was: ${n})`)}},Fa=new Set,ga=(e,t)=>{if(ya.has(e))return ya.get(e);if(!t.appenders[e])return!1;if(Fa.has(e))throw new Error(`Dependency loop detected for appender ${e}.`);Fa.add(e),fa(`Creating appender ${e}`);const n=Aa(e,t);return Fa.delete(e),ya.set(e,n),n},Aa=(e,t)=>{const n=t.appenders[e],r=n.type.configure?n.type:((e,t)=>ha.get(e)||Ca(`./${e}`,t)||Ca(e,t)||require.main&&Ca(la.join(la.dirname(require.main.filename),e),t)||Ca(la.join(process.cwd(),e),t))(n.type,t);return da.throwExceptionIf(t,da.not(r),`appender "${e}" is not valid (type "${n.type}" could not be found)`),r.appender&&fa(`DEPRECATION: Appender ${n.type} exports an appender function.`),r.shutdown&&fa(`DEPRECATION: Appender ${n.type} exports a shutdown function.`),fa(`${e}: clustering.isMaster ? ${Da.isMaster()}`),fa(`${e}: appenderModule is ${F.default.inspect(r)}`),Da.onlyOnMaster((()=>(fa(`calling appenderModule.configure for ${e} / ${n.type}`),r.configure(ma.modifyConfig(n),Ea,(e=>ga(e,t)),pa))),(()=>{}))},va=e=>{ya.clear(),Fa.clear();const t=[];Object.values(e.categories).forEach((e=>{t.push(...e.appenders)})),Object.keys(e.appenders).forEach((n=>{(t.includes(n)||"tcp-server"===e.appenders[n].type)&&ga(n,e)}))},Sa=()=>{va({appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"trace"}}})};Sa(),da.addListener((e=>{da.throwExceptionIf(e,da.not(da.anObject(e.appenders)),'must have a property "appenders" of type object.');const t=Object.keys(e.appenders);da.throwExceptionIf(e,da.not(t.length),"must define at least one appender."),t.forEach((t=>{da.throwExceptionIf(e,da.not(e.appenders[t].type),`appender "${t}" is not valid (must be an object with property "type")`)}))})),da.addListener(va),Au.exports=ya,Au.exports.init=Sa;var wa={exports:{}};!function(e){const t=Nr.exports("log4js:categories"),n=tu,r=gu,u=Au.exports,o=new Map;function i(e,t,n){if(!1===t.inherit)return;const r=n.lastIndexOf(".");if(r<0)return;const u=n.substring(0,r);let o=e.categories[u];o||(o={inherit:!0,appenders:[]}),i(e,o,u),!e.categories[u]&&o.appenders&&o.appenders.length&&o.level&&(e.categories[u]=o),t.appenders=t.appenders||[],t.level=t.level||o.level,o.appenders.forEach((e=>{t.appenders.includes(e)||t.appenders.push(e)})),t.parent=o}function s(e){if(!e.categories)return;Object.keys(e.categories).forEach((t=>{const n=e.categories[t];i(e,n,t)}))}n.addPreProcessingListener((e=>s(e))),n.addListener((e=>{n.throwExceptionIf(e,n.not(n.anObject(e.categories)),'must have a property "categories" of type object.');const t=Object.keys(e.categories);n.throwExceptionIf(e,n.not(t.length),"must define at least one category."),t.forEach((t=>{const o=e.categories[t];n.throwExceptionIf(e,[n.not(o.appenders),n.not(o.level)],`category "${t}" is not valid (must be an object with properties "appenders" and "level")`),n.throwExceptionIf(e,n.not(Array.isArray(o.appenders)),`category "${t}" is not valid (appenders must be an array of appender names)`),n.throwExceptionIf(e,n.not(o.appenders.length),`category "${t}" is not valid (appenders must contain at least one appender name)`),Object.prototype.hasOwnProperty.call(o,"enableCallStack")&&n.throwExceptionIf(e,"boolean"!=typeof o.enableCallStack,`category "${t}" is not valid (enableCallStack must be boolean type)`),o.appenders.forEach((r=>{n.throwExceptionIf(e,n.not(u.get(r)),`category "${t}" is not valid (appender "${r}" is not defined)`)})),n.throwExceptionIf(e,n.not(r.getLevel(o.level)),`category "${t}" is not valid (level "${o.level}" not recognised; valid levels are ${r.levels.join(", ")})`)})),n.throwExceptionIf(e,n.not(e.categories.default),'must define a "default" category.')}));const c=e=>{o.clear();Object.keys(e.categories).forEach((n=>{const i=e.categories[n],s=[];i.appenders.forEach((e=>{s.push(u.get(e)),t(`Creating category ${n}`),o.set(n,{appenders:s,level:r.getLevel(i.level),enableCallStack:i.enableCallStack||!1})}))}))},a=()=>{c({categories:{default:{appenders:["out"],level:"OFF"}}})};a(),n.addListener(c);const l=e=>(t(`configForCategory: searching for config for ${e}`),o.has(e)?(t(`configForCategory: ${e} exists in config, returning it`),o.get(e)):e.indexOf(".")>0?(t(`configForCategory: ${e} has hierarchy, searching for parents`),l(e.substring(0,e.lastIndexOf(".")))):(t("configForCategory: returning config for default category"),l("default")));e.exports=o,e.exports=Object.assign(e.exports,{appendersForCategory:e=>l(e).appenders,getLevelForCategory:e=>l(e).level,setLevelForCategory:(e,n)=>{let r=o.get(e);if(t(`setLevelForCategory: found ${r} for ${e}`),!r){const n=l(e);t(`setLevelForCategory: no config found for category, found ${n} for parents of ${e}`),r={appenders:n.appenders}}r.level=n,o.set(e,r)},getEnableCallStackForCategory:e=>!0===l(e).enableCallStack,setEnableCallStackForCategory:(e,t)=>{l(e).enableCallStack=t},init:a})}(wa);const Oa=Nr.exports("log4js:logger"),ba=Hu,_a=gu,Ba=eo,Pa=wa.exports,ka=tu,xa=/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/;function Na(e,t=4){const n=e.stack.split("\n").slice(t),r=xa.exec(n[0]);return r&&6===r.length?{functionName:r[1],fileName:r[2],lineNumber:parseInt(r[3],10),columnNumber:parseInt(r[4],10),callStack:n.join("\n")}:null}class Ia{constructor(e){if(!e)throw new Error("No category provided.");this.category=e,this.context={},this.parseCallStack=Na,Oa(`Logger created (${this.category}, ${this.level})`)}get level(){return _a.getLevel(Pa.getLevelForCategory(this.category),_a.TRACE)}set level(e){Pa.setLevelForCategory(this.category,_a.getLevel(e,this.level))}get useCallStack(){return Pa.getEnableCallStackForCategory(this.category)}set useCallStack(e){Pa.setEnableCallStackForCategory(this.category,!0===e)}log(e,...t){let n=_a.getLevel(e);n||(this._log(_a.WARN,"log4js:logger.log: invalid value for log-level as first parameter given: ",e),n=_a.INFO),this.isLevelEnabled(n)&&this._log(n,t)}isLevelEnabled(e){return this.level.isLessThanOrEqualTo(e)}_log(e,t){Oa(`sending log data (${e}) to appenders`);const n=new ba(this.category,e,t,this.context,this.useCallStack&&this.parseCallStack(new Error));Ba.send(n)}addContext(e,t){this.context[e]=t}removeContext(e){delete this.context[e]}clearContext(){this.context={}}setParseCallStackFunction(e){this.parseCallStack=e}}function Ta(e){const t=_a.getLevel(e),n=t.toString().toLowerCase().replace(/_([a-z])/g,(e=>e[1].toUpperCase())),r=n[0].toUpperCase()+n.slice(1);Ia.prototype[`is${r}Enabled`]=function(){return this.isLevelEnabled(t)},Ia.prototype[n]=function(...e){this.log(t,...e)}}_a.levels.forEach(Ta),ka.addListener((()=>{_a.levels.forEach(Ta)}));var Ra=Ia;const Ma=gu;function La(e){return e.originalUrl||e.url}function ja(e,t){for(let n=0;ne.source?e.source:e));t=new RegExp(n.join("|"))}return t}(t.nolog);return(e,i,s)=>{if(e._logging)return s();if(o&&o.test(e.originalUrl))return s();if(n.isLevelEnabled(r)||"auto"===t.level){const o=new Date,{writeHead:s}=i;e._logging=!0,i.writeHead=(e,t)=>{i.writeHead=s,i.writeHead(e,t),i.__statusCode=e,i.__headers=t||{}},i.on("finish",(()=>{i.responseTime=new Date-o,i.statusCode&&"auto"===t.level&&(r=Ma.INFO,i.statusCode>=300&&(r=Ma.WARN),i.statusCode>=400&&(r=Ma.ERROR)),r=function(e,t,n){let r=t;if(n){const t=n.find((t=>{let n=!1;return n=t.from&&t.to?e>=t.from&&e<=t.to:-1!==t.codes.indexOf(e),n}));t&&(r=Ma.getLevel(t.level,r))}return r}(i.statusCode,r,t.statusRules);const s=function(e,t,n){const r=[];return r.push({token:":url",replacement:La(e)}),r.push({token:":protocol",replacement:e.protocol}),r.push({token:":hostname",replacement:e.hostname}),r.push({token:":method",replacement:e.method}),r.push({token:":status",replacement:t.__statusCode||t.statusCode}),r.push({token:":response-time",replacement:t.responseTime}),r.push({token:":date",replacement:(new Date).toUTCString()}),r.push({token:":referrer",replacement:e.headers.referer||e.headers.referrer||""}),r.push({token:":http-version",replacement:`${e.httpVersionMajor}.${e.httpVersionMinor}`}),r.push({token:":remote-addr",replacement:e.headers["x-forwarded-for"]||e.ip||e._remoteAddress||e.socket&&(e.socket.remoteAddress||e.socket.socket&&e.socket.socket.remoteAddress)}),r.push({token:":user-agent",replacement:e.headers["user-agent"]}),r.push({token:":content-length",replacement:t.getHeader("content-length")||t.__headers&&t.__headers["Content-Length"]||"-"}),r.push({token:/:req\[([^\]]+)]/g,replacement:(t,n)=>e.headers[n.toLowerCase()]}),r.push({token:/:res\[([^\]]+)]/g,replacement:(e,n)=>t.getHeader(n.toLowerCase())||t.__headers&&t.__headers[n]}),(e=>{const t=e.concat();for(let e=0;eja(e,s)));t&&n.log(r,t)}else n.log(r,ja(u,s));t.context&&n.removeContext("res")}))}return s()}},nl=Va;let rl=!1;function ul(e){if(!rl)return;Ua("Received log event ",e);Za.appendersForCategory(e.categoryName).forEach((t=>{t(e)}))}function ol(e){rl&&il();let t=e;return"string"==typeof t&&(t=function(e){Ua(`Loading configuration from ${e}`);try{return JSON.parse(Wa.readFileSync(e,"utf8"))}catch(t){throw new Error(`Problem reading config from file "${e}". Error was ${t.message}`,t)}}(e)),Ua(`Configuration is ${t}`),Ka.configure(za(t)),el.onMessage(ul),rl=!0,sl}function il(e){Ua("Shutdown called. Disabling all log writing."),rl=!1;const t=Array.from(Xa.values());Xa.init(),Za.init();const n=t.reduceRight(((e,t)=>t.shutdown?e+1:e),0);if(0===n)return Ua("No appenders with shutdown functions found."),void 0!==e&&e();let r,u=0;function o(t){r=r||t,u+=1,Ua(`Appender shutdowns complete: ${u} / ${n}`),u>=n&&(Ua("All shutdown functions completed."),e&&e(r))}return Ua(`Found ${n} appenders with shutdown functions.`),t.filter((e=>e.shutdown)).forEach((e=>e.shutdown(o))),null}const sl={getLogger:function(e){return rl||ol(process.env.LOG4JS_CONFIG||{appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"OFF"}}}),new Qa(e||"default")},configure:ol,shutdown:il,connectLogger:tl,levels:Ya,addLayout:qa.addLayout,recording:function(){return nl}};var cl=sl,al={};Object.defineProperty(al,"__esModule",{value:!0}),al.levelMap=al.getLevel=al.setCategoriesLevel=al.getConfiguration=al.setConfiguration=void 0;const ll=cl;let fl={appenders:{debug:{type:"stdout",layout:{type:"pattern",pattern:"[%d] > hvigor %p %c %[%m%]"}},info:{type:"stdout",layout:{type:"pattern",pattern:"[%d] > hvigor %[%m%]"}},"no-pattern-info":{type:"stdout",layout:{type:"pattern",pattern:"%m"}},wrong:{type:"stderr",layout:{type:"pattern",pattern:"[%d] > hvigor %[%p: %m%]"}},"just-debug":{type:"logLevelFilter",appender:"debug",level:"debug",maxLevel:"debug"},"just-info":{type:"logLevelFilter",appender:"info",level:"info",maxLevel:"info"},"just-wrong":{type:"logLevelFilter",appender:"wrong",level:"warn",maxLevel:"error"}},categories:{default:{appenders:["just-debug","just-info","just-wrong"],level:"debug"},"no-pattern-info":{appenders:["no-pattern-info"],level:"info"}}};al.setConfiguration=e=>{fl=e};al.getConfiguration=()=>fl;let dl=ll.levels.DEBUG;al.setCategoriesLevel=(e,t)=>{dl=e;const n=fl.categories;for(const r in n)(null==t?void 0:t.includes(r))||Object.prototype.hasOwnProperty.call(n,r)&&(n[r].level=e.levelStr)};al.getLevel=()=>dl,al.levelMap=new Map([["ALL",ll.levels.ALL],["MARK",ll.levels.MARK],["TRACE",ll.levels.TRACE],["DEBUG",ll.levels.DEBUG],["INFO",ll.levels.INFO],["WARN",ll.levels.WARN],["ERROR",ll.levels.ERROR],["FATAL",ll.levels.FATAL],["OFF",ll.levels.OFF]]);var Dl=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),pl=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),El=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&Dl(t,e,n);return pl(t,e),t};Object.defineProperty(xr,"__esModule",{value:!0}),xr.evaluateLogLevel=xr.HvigorLogger=void 0;const ml=El(cl),hl=cl,yl=El(F.default),Cl=al;class Fl{constructor(e){ml.configure((0,Cl.getConfiguration)()),this._logger=ml.getLogger(e),this._logger.level=(0,Cl.getLevel)()}static getLogger(e){return new Fl(e)}log(e,...t){this._logger.log(e,...t)}debug(e,...t){this._logger.debug(e,...t)}info(e,...t){this._logger.info(e,...t)}warn(e,...t){void 0!==e&&""!==e&&this._logger.warn(e,...t)}error(e,...t){this._logger.error(e,...t)}_printTaskExecuteInfo(e,t){this.info(`Finished :${e}... after ${t}`)}_printFailedTaskInfo(e){this.error(`Failed :${e}... `)}_printDisabledTaskInfo(e){this.info(`Disabled :${e}... `)}_printUpToDateTaskInfo(e){this.info(`UP-TO-DATE :${e}... `)}errorMessageExit(e,...t){throw new Error(yl.format(e,...t))}errorExit(e,t,...n){t&&this._logger.error(t,n),this._logger.error(e.stack)}setLevel(e,t){(0,Cl.setCategoriesLevel)(e,t),ml.shutdown(),ml.configure((0,Cl.getConfiguration)())}getLevel(){return this._logger.level}configure(e){const t=(0,Cl.getConfiguration)(),n={appenders:{...t.appenders,...e.appenders},categories:{...t.categories,...e.categories}};(0,Cl.setConfiguration)(n),ml.shutdown(),ml.configure(n)}}xr.HvigorLogger=Fl,xr.evaluateLogLevel=function(e,t){t.debug?e.setLevel(hl.levels.DEBUG):t.warn?e.setLevel(hl.levels.WARN):t.error?e.setLevel(hl.levels.ERROR):e.setLevel(hl.levels.INFO)};var gl=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(X,"__esModule",{value:!0}),X.parseJsonText=X.parseJsonFile=void 0;const Al=Z,vl=gl(kr),Sl=gl(p.default),wl=gl(E.default),Ol=xr.HvigorLogger.getLogger("parse-json-util");var bl;!function(e){e[e.Char=0]="Char",e[e.EOF=1]="EOF",e[e.Identifier=2]="Identifier"}(bl||(bl={}));let _l,Bl,Pl,kl,xl,Nl,Il="start",Tl=[],Rl=0,Ml=1,Ll=0,jl=!1,$l="default",Hl="'",Jl=1;function Gl(e,t=!1){Bl=String(e),Il="start",Tl=[],Rl=0,Ml=1,Ll=0,kl=void 0,jl=t;do{_l=Vl(),Xl[Il]()}while("eof"!==_l.type);return kl}function Vl(){for($l="default",xl="",Hl="'",Jl=1;;){Nl=Ul();const e=zl[$l]();if(e)return e}}function Ul(){if(Bl[Rl])return String.fromCodePoint(Bl.codePointAt(Rl))}function Wl(){const e=Ul();return"\n"===e?(Ml++,Ll=0):e?Ll+=e.length:Ll++,e&&(Rl+=e.length),e}X.parseJsonFile=function(e,t=!1,n="utf-8"){const r=vl.default.readFileSync(Sl.default.resolve(e),{encoding:n});try{return Gl(r,t)}catch(t){if(t instanceof SyntaxError){const n=t.message.split("at");2===n.length&&Ol.errorMessageExit(`${n[0].trim()}${wl.default.EOL}\t at ${e}:${n[1].trim()}`)}Ol.errorMessageExit(`${e} is not in valid JSON/JSON5 format.`)}},X.parseJsonText=Gl;const zl={default(){switch(Nl){case"/":return Wl(),void($l="comment");case void 0:return Wl(),Kl("eof")}if(!Al.JudgeUtil.isIgnoreChar(Nl)&&!Al.JudgeUtil.isSpaceSeparator(Nl))return zl[Il]();Wl()},start(){$l="value"},beforePropertyName(){switch(Nl){case"$":case"_":return xl=Wl(),void($l="identifierName");case"\\":return Wl(),void($l="identifierNameStartEscape");case"}":return Kl("punctuator",Wl());case'"':case"'":return Hl=Nl,Wl(),void($l="string")}if(Al.JudgeUtil.isIdStartChar(Nl))return xl+=Wl(),void($l="identifierName");throw tf(bl.Char,Wl())},afterPropertyName(){if(":"===Nl)return Kl("punctuator",Wl());throw tf(bl.Char,Wl())},beforePropertyValue(){$l="value"},afterPropertyValue(){switch(Nl){case",":case"}":return Kl("punctuator",Wl())}throw tf(bl.Char,Wl())},beforeArrayValue(){if("]"===Nl)return Kl("punctuator",Wl());$l="value"},afterArrayValue(){switch(Nl){case",":case"]":return Kl("punctuator",Wl())}throw tf(bl.Char,Wl())},end(){throw tf(bl.Char,Wl())},comment(){switch(Nl){case"*":return Wl(),void($l="multiLineComment");case"/":return Wl(),void($l="singleLineComment")}throw tf(bl.Char,Wl())},multiLineComment(){switch(Nl){case"*":return Wl(),void($l="multiLineCommentAsterisk");case void 0:throw tf(bl.Char,Wl())}Wl()},multiLineCommentAsterisk(){switch(Nl){case"*":return void Wl();case"/":return Wl(),void($l="default");case void 0:throw tf(bl.Char,Wl())}Wl(),$l="multiLineComment"},singleLineComment(){switch(Nl){case"\n":case"\r":case"\u2028":case"\u2029":return Wl(),void($l="default");case void 0:return Wl(),Kl("eof")}Wl()},value(){switch(Nl){case"{":case"[":return Kl("punctuator",Wl());case"n":return Wl(),ql("ull"),Kl("null",null);case"t":return Wl(),ql("rue"),Kl("boolean",!0);case"f":return Wl(),ql("alse"),Kl("boolean",!1);case"-":case"+":return"-"===Wl()&&(Jl=-1),void($l="numerical");case".":case"0":case"I":case"N":return void($l="numerical");case'"':case"'":return Hl=Nl,Wl(),xl="",void($l="string")}if(void 0===Nl||!Al.JudgeUtil.isDigitWithoutZero(Nl))throw tf(bl.Char,Wl());$l="numerical"},numerical(){switch(Nl){case".":return xl=Wl(),void($l="decimalPointLeading");case"0":return xl=Wl(),void($l="zero");case"I":return Wl(),ql("nfinity"),Kl("numeric",Jl*(1/0));case"N":return Wl(),ql("aN"),Kl("numeric",NaN)}if(void 0!==Nl&&Al.JudgeUtil.isDigitWithoutZero(Nl))return xl=Wl(),void($l="decimalInteger");throw tf(bl.Char,Wl())},zero(){switch(Nl){case".":case"e":case"E":return void($l="decimal");case"x":case"X":return xl+=Wl(),void($l="hexadecimal")}return Kl("numeric",0)},decimalInteger(){switch(Nl){case".":case"e":case"E":return void($l="decimal")}if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},decimal(){switch(Nl){case".":xl+=Wl(),$l="decimalFraction";break;case"e":case"E":xl+=Wl(),$l="decimalExponent"}},decimalPointLeading(){if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalFraction");throw tf(bl.Char,Wl())},decimalFraction(){switch(Nl){case"e":case"E":return xl+=Wl(),void($l="decimalExponent")}if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},decimalExponent(){switch(Nl){case"+":case"-":return xl+=Wl(),void($l="decimalExponentSign")}if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalExponentInteger");throw tf(bl.Char,Wl())},decimalExponentSign(){if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalExponentInteger");throw tf(bl.Char,Wl())},decimalExponentInteger(){if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},hexadecimal(){if(Al.JudgeUtil.isHexDigit(Nl))return xl+=Wl(),void($l="hexadecimalInteger");throw tf(bl.Char,Wl())},hexadecimalInteger(){if(!Al.JudgeUtil.isHexDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},identifierNameStartEscape(){if("u"!==Nl)throw tf(bl.Char,Wl());Wl();const e=Yl();switch(e){case"$":case"_":break;default:if(!Al.JudgeUtil.isIdStartChar(e))throw tf(bl.Identifier)}xl+=e,$l="identifierName"},identifierName(){switch(Nl){case"$":case"_":case"‌":case"‍":return void(xl+=Wl());case"\\":return Wl(),void($l="identifierNameEscape")}if(!Al.JudgeUtil.isIdContinueChar(Nl))return Kl("identifier",xl);xl+=Wl()},identifierNameEscape(){if("u"!==Nl)throw tf(bl.Char,Wl());Wl();const e=Yl();switch(e){case"$":case"_":case"‌":case"‍":break;default:if(!Al.JudgeUtil.isIdContinueChar(e))throw tf(bl.Identifier)}xl+=e,$l="identifierName"},string(){switch(Nl){case"\\":return Wl(),void(xl+=function(){const e=Ul(),t=function(){switch(Ul()){case"b":return Wl(),"\b";case"f":return Wl(),"\f";case"n":return Wl(),"\n";case"r":return Wl(),"\r";case"t":return Wl(),"\t";case"v":return Wl(),"\v"}return}();if(t)return t;switch(e){case"0":if(Wl(),Al.JudgeUtil.isDigit(Ul()))throw tf(bl.Char,Wl());return"\0";case"x":return Wl(),function(){let e="",t=Ul();if(!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());if(e+=Wl(),t=Ul(),!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());return e+=Wl(),String.fromCodePoint(parseInt(e,16))}();case"u":return Wl(),Yl();case"\n":case"\u2028":case"\u2029":return Wl(),"";case"\r":return Wl(),"\n"===Ul()&&Wl(),""}if(void 0===e||Al.JudgeUtil.isDigitWithoutZero(e))throw tf(bl.Char,Wl());return Wl()}());case'"':case"'":if(Nl===Hl){const e=Kl("string",xl);return Wl(),e}return void(xl+=Wl());case"\n":case"\r":case void 0:throw tf(bl.Char,Wl());case"\u2028":case"\u2029":!function(e){Ol.warn(`JSON5: '${ef(e)}' in strings is not valid ECMAScript; consider escaping.`)}(Nl)}xl+=Wl()}};function Kl(e,t){return{type:e,value:t,line:Ml,column:Ll}}function ql(e){for(const t of e){if(Ul()!==t)throw tf(bl.Char,Wl());Wl()}}function Yl(){let e="",t=4;for(;t-- >0;){const t=Ul();if(!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());e+=Wl()}return String.fromCodePoint(parseInt(e,16))}const Xl={start(){if("eof"===_l.type)throw tf(bl.EOF);Zl()},beforePropertyName(){switch(_l.type){case"identifier":case"string":return Pl=_l.value,void(Il="afterPropertyName");case"punctuator":return void Ql();case"eof":throw tf(bl.EOF)}},afterPropertyName(){if("eof"===_l.type)throw tf(bl.EOF);Il="beforePropertyValue"},beforePropertyValue(){if("eof"===_l.type)throw tf(bl.EOF);Zl()},afterPropertyValue(){if("eof"===_l.type)throw tf(bl.EOF);switch(_l.value){case",":return void(Il="beforePropertyName");case"}":Ql()}},beforeArrayValue(){if("eof"===_l.type)throw tf(bl.EOF);"punctuator"!==_l.type||"]"!==_l.value?Zl():Ql()},afterArrayValue(){if("eof"===_l.type)throw tf(bl.EOF);switch(_l.value){case",":return void(Il="beforeArrayValue");case"]":Ql()}},end(){}};function Zl(){const e=function(){let e;switch(_l.type){case"punctuator":switch(_l.value){case"{":e={};break;case"[":e=[]}break;case"null":case"boolean":case"numeric":case"string":e=_l.value}return e}();if(jl&&"object"==typeof e&&(e._line=Ml,e._column=Ll),void 0===kl)kl=e;else{const t=Tl[Tl.length-1];Array.isArray(t)?jl&&"object"!=typeof e?t.push({value:e,_line:Ml,_column:Ll}):t.push(e):t[Pl]=jl&&"object"!=typeof e?{value:e,_line:Ml,_column:Ll}:e}!function(e){if(e&&"object"==typeof e)Tl.push(e),Il=Array.isArray(e)?"beforeArrayValue":"beforePropertyName";else{const e=Tl[Tl.length-1];Il=e?Array.isArray(e)?"afterArrayValue":"afterPropertyValue":"end"}}(e)}function Ql(){Tl.pop();const e=Tl[Tl.length-1];Il=e?Array.isArray(e)?"afterArrayValue":"afterPropertyValue":"end"}function ef(e){const t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){const t=e.charCodeAt(0).toString(16);return`\\x${`00${t}`.substring(t.length)}`}return e}function tf(e,t){let n="";switch(e){case bl.Char:n=void 0===t?`JSON5: invalid end of input at ${Ml}:${Ll}`:`JSON5: invalid character '${ef(t)}' at ${Ml}:${Ll}`;break;case bl.EOF:n=`JSON5: invalid end of input at ${Ml}:${Ll}`;break;case bl.Identifier:Ll-=5,n=`JSON5: invalid identifier character at ${Ml}:${Ll}`}const r=new nf(n);return r.lineNumber=Ml,r.columnNumber=Ll,r}class nf extends SyntaxError{}var rf=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),uf=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),of=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&rf(t,e,n);return uf(t,e),t};Object.defineProperty(Y,"__esModule",{value:!0});var sf=Y.cleanWorkSpace=Ff=Y.executeInstallHvigor=yf=Y.isHvigorInstalled=mf=Y.isAllDependenciesInstalled=void 0;const cf=of(D.default),af=of(p.default),lf=b,ff=j,df=$,Df=X;let pf,Ef;var mf=Y.isAllDependenciesInstalled=function(){function e(e){const t=null==e?void 0:e.dependencies;return void 0===t?0:Object.getOwnPropertyNames(t).length}if(pf=gf(),Ef=Af(),e(pf)+1!==e(Ef))return!1;for(const e in null==pf?void 0:pf.dependencies)if(!(0,ff.hasNpmPackInPaths)(e,[lf.HVIGOR_PROJECT_DEPENDENCIES_HOME])||!hf(e,pf,Ef))return!1;return!0};function hf(e,t,n){return void 0!==n.dependencies&&(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,t.dependencies[e])===n.dependencies[e]}var yf=Y.isHvigorInstalled=function(){return pf=gf(),Ef=Af(),(0,ff.hasNpmPackInPaths)(lf.HVIGOR_ENGINE_PACKAGE_NAME,[lf.HVIGOR_PROJECT_DEPENDENCIES_HOME])&&(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,pf.hvigorVersion)===Ef.dependencies[lf.HVIGOR_ENGINE_PACKAGE_NAME]};const Cf={cwd:lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,stdio:["inherit","inherit","inherit"]};var Ff=Y.executeInstallHvigor=function(){(0,df.logInfoPrintConsole)("Hvigor installing...");const e={dependencies:{}};e.dependencies[lf.HVIGOR_ENGINE_PACKAGE_NAME]=(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,pf.hvigorVersion);try{cf.mkdirSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,{recursive:!0});const t=af.resolve(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,lf.DEFAULT_PACKAGE_JSON);cf.writeFileSync(t,JSON.stringify(e))}catch(e){(0,df.logErrorAndExit)(e)}!function(){const e=["config","set","store-dir",lf.HVIGOR_PNPM_STORE_PATH];(0,ff.executeCommand)(lf.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,e,Cf)}(),(0,ff.executeCommand)(lf.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,["install"],Cf)};function gf(){const e=af.resolve(lf.HVIGOR_PROJECT_WRAPPER_HOME,lf.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);return cf.existsSync(e)||(0,df.logErrorAndExit)(`Error: Hvigor config file ${e} does not exist.`),(0,Df.parseJsonFile)(e)}function Af(){return cf.existsSync(lf.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH)?(0,Df.parseJsonFile)(lf.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH):{dependencies:{}}}sf=Y.cleanWorkSpace=function(){if((0,df.logInfoPrintConsole)("Hvigor cleaning..."),!cf.existsSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME))return;const e=cf.readdirSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME);if(e&&0!==e.length){cf.existsSync(lf.HVIGOR_BOOT_JS_FILE_PATH)&&(0,ff.executeCommand)(process.argv[0],[lf.HVIGOR_BOOT_JS_FILE_PATH,"--stop-daemon"],{});try{e.forEach((e=>{cf.rmSync(af.resolve(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,e),{recursive:!0})}))}catch(e){(0,df.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${lf.HVIGOR_PROJECT_DEPENDENCIES_HOME}.`)}}};var vf={},Sf=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),wf=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Of=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&Sf(t,e,n);return wf(t,e),t};Object.defineProperty(vf,"__esModule",{value:!0});var bf=vf.executeBuild=void 0;const _f=b,Bf=Of(D.default),Pf=Of(p.default),kf=$;bf=vf.executeBuild=function(){const e=Pf.resolve(_f.HVIGOR_PROJECT_DEPENDENCIES_HOME,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const t=Bf.realpathSync(e);require(t)}catch(t){(0,kf.logErrorAndExit)(`Error: ENOENT: no such file ${e},delete ${_f.HVIGOR_PROJECT_DEPENDENCIES_HOME} and retry.`)}},function(){if(O.checkNpmConifg(),O.environmentHandler(),O.isPnpmAvailable()||O.executeInstallPnpm(),yf()&&mf())bf();else{sf();try{Ff()}catch(e){return void sf()}bf()}}(); \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorfile.ts b/code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorfile.ts new file mode 100644 index 0000000000..6478186902 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorfile.ts @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorw b/code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorw new file mode 100644 index 0000000000..54aadd226b --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorw @@ -0,0 +1,48 @@ +#!/bin/bash + +# ---------------------------------------------------------------------------- +# Hvigor startup script, version 1.0.0 +# +# Required ENV vars: +# ------------------ +# NODE_HOME - location of a Node home dir +# or +# Add /usr/local/nodejs/bin to the PATH environment variable +# ---------------------------------------------------------------------------- + +HVIGOR_APP_HOME=$(dirname $(readlink -f $0)) +HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js +warn() { + echo "" + echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +error() { + echo "" + echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +fail() { + error "$@" + exit 1 +} + +# Determine node to start hvigor wrapper script +if [ -n "${NODE_HOME}" ];then + EXECUTABLE_NODE="${NODE_HOME}/bin/node" + if [ ! -x "$EXECUTABLE_NODE" ];then + fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" + fi +else + EXECUTABLE_NODE="node" + which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" +fi + +# Check hvigor wrapper script +if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then + fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" +fi + +# start hvigor-wrapper script +exec "${EXECUTABLE_NODE}" \ + "${HVIGOR_WRAPPER_SCRIPT}" "$@" diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorw.bat b/code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorw.bat new file mode 100644 index 0000000000..6861293e47 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/hvigorw.bat @@ -0,0 +1,64 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Hvigor startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js +set NODE_EXE=node.exe + +goto start + +:start +@rem Find node.exe +if defined NODE_HOME goto findNodeFromNodeHome + +%NODE_EXE% --version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:findNodeFromNodeHome +set NODE_HOME=%NODE_HOME:"=% +set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% + +if exist "%NODE_EXE_PATH%" goto execute +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:execute +@rem Execute hvigor +"%NODE_EXE%" %WRAPPER_MODULE_PATH% %* + +if "%ERRORLEVEL%" == "0" goto hvigorwEnd + +:fail +exit /b 1 + +:hvigorwEnd +if "%OS%" == "Windows_NT" endlocal + +:end diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/oh-package-lock.json5 b/code/BasicFeature/DeviceManagement/Sensor/JsApi/oh-package-lock.json5 new file mode 100644 index 0000000000..bc40219d5a --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/oh-package-lock.json5 @@ -0,0 +1,13 @@ +{ + "lockfileVersion": 1, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6" + }, + "packages": { + "@ohos/hypium@1.0.6": { + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", + "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" + } + } +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/JsApi/oh-package.json5 b/code/BasicFeature/DeviceManagement/Sensor/JsApi/oh-package.json5 new file mode 100644 index 0000000000..dbc2e2dc41 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Sensor/JsApi/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "name": "myapplication", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.6" + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/app.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/app.json5 index 1f9987259b..6c137fcb31 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/app.json5 +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/app.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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.haptic", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name", - "distributedNotificationEnabled": true - } -} +/* + * Copyright (c) 2023 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.haptic", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/resources/base/element/string.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/resources/base/element/string.json index b2c6a66807..13156d6afc 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "Haptic Sample" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "Haptic Sample" + } + ] +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/build-profile.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/build-profile.json5 index 390b41a944..947c318515 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/build-profile.json5 +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" - } - ], - "signingConfigs": [] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "runtimeOS": "OpenHarmony" + } + ], + "signingConfigs": [] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/build-profile.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/build-profile.json5 index 0c8525dfdd..910cc991f5 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/build-profile.json5 +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/oh-package.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/oh-package.json5 index 7cee9755d2..fcff8e1a08 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/oh-package.json5 +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "ISC", - "devDependencies": {}, - "name": "entry", - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": { - "library": "file:../libs/library.har" - } -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": { + "library": "file:../libs/library.har" + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Battle.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Battle.ets index f7469ab6f1..57b8b4aaa4 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Battle.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Battle.ets @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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 { getImageBattleList, ImageDataSource } from '../module/ImageData' -import CommonLayout from './Common' - -@Component -export default struct BattleLayout { - @State battleList: ImageDataSource = new ImageDataSource(getImageBattleList()) - @State status: boolean[] = [false, false, false, false, false, false] - @Link vibrationIntensity: string - @Link php: string - - build() { - CommonLayout({ - dataList: $battleList, - status: $status, - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } -} +/* + * Copyright (c) 2023 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 { getImageBattleList, ImageDataSource } from '../module/ImageData' +import CommonLayout from './Common' + +@Component +export default struct BattleLayout { + @State battleList: ImageDataSource = new ImageDataSource(getImageBattleList()) + @State status: boolean[] = [false, false, false, false, false, false] + @Link vibrationIntensity: string + @Link php: string + + build() { + CommonLayout({ + dataList: $battleList, + status: $status, + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Common.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Common.ets index 66c1ee33f0..4e9ebcef15 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Common.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Common.ets @@ -1,95 +1,95 @@ -/* - * Copyright (c) 2023 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 { playVibrateCustom, getDynamicStates } from '../module/Util' -import { ImageDataSource, ImagesData } from '../module/ImageData' -import AudioPlayer from '../module/AudioPlayer' -import Logger from '../module/Logger' - -const TAG = '[CommonLayout]' - -@Component -export default struct CommonLayout { - @Link dataList: ImageDataSource - @Link status: boolean[] - @Link vibrationIntensity: string - @Link php: string - - build() { - Column({ space: 10 }) { - List() { - LazyForEach(this.dataList, (item: ImagesData) => { - ListItem() { - Row() { - Row() { - Image(item.src) - .width(60) - .height(50) - .borderRadius(5) - .autoResize(false) - } - - Stack({ alignContent: Alignment.Start }) { - Column() { - Text(item.name) - .fontSize(15) - .fontColor(Color.White) - } - .alignItems(HorizontalAlign.Start) - .padding({ left: 20 }) - } - .layoutWeight(7) - - if (item.id !== undefined) { - Image($r("app.media.music")) - .width(15) - .height(15) - .visibility(this.status[item.id] ? Visibility.Visible : Visibility.Hidden) - } - } - .id("audioHaptic") - .width("95%") - .height(70) - .padding({ top: 5, left: 10, right: 10, bottom: 5 }) - .backgroundColor(this.status[item.id!] ? "#1a3e3f56" : "#4d191a32") - .onClick(() => { - this.status = getDynamicStates(this.status, item.id!) - AudioPlayer.playAudio(item.audioName!) - if (this.vibrationIntensity === 'H') { - Logger.info(TAG, "High intensity mode") - playVibrateCustom(item.vibratorFileH!, this.php) - } else if (this.vibrationIntensity === 'M') { - Logger.info(TAG, "Middle intensity mode") - playVibrateCustom(item.vibratorFileM!, this.php) - } else if (this.vibrationIntensity === 'L') { - Logger.info(TAG, "Low intensity mode") - playVibrateCustom(item.vibratorFileL!, this.php) - } else { - Logger.info(TAG, "Vibration mode error") - } - if (item.id) { - Logger.info(TAG, item.id.toString() + ' ' + item.name + ' ' + item.audioName) - } - }) - } - }) // LazyForEach - } - .listDirection(Axis.Vertical) - .divider({ strokeWidth: 3, color: "#00f3f3f3", startMargin: 0, endMargin: 0 }) - .height('50%') - .width('100%') - } - } -} +/* + * Copyright (c) 2023 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 { playVibrateCustom, getDynamicStates } from '../module/Util' +import { ImageDataSource, ImagesData } from '../module/ImageData' +import AudioPlayer from '../module/AudioPlayer' +import Logger from '../module/Logger' + +const TAG = '[CommonLayout]' + +@Component +export default struct CommonLayout { + @Link dataList: ImageDataSource + @Link status: boolean[] + @Link vibrationIntensity: string + @Link php: string + + build() { + Column({ space: 10 }) { + List() { + LazyForEach(this.dataList, (item: ImagesData) => { + ListItem() { + Row() { + Row() { + Image(item.src) + .width(60) + .height(50) + .borderRadius(5) + .autoResize(false) + } + + Stack({ alignContent: Alignment.Start }) { + Column() { + Text(item.name) + .fontSize(15) + .fontColor(Color.White) + } + .alignItems(HorizontalAlign.Start) + .padding({ left: 20 }) + } + .layoutWeight(7) + + if (item.id !== undefined) { + Image($r("app.media.music")) + .width(15) + .height(15) + .visibility(this.status[item.id] ? Visibility.Visible : Visibility.Hidden) + } + } + .id("audioHaptic") + .width("95%") + .height(70) + .padding({ top: 5, left: 10, right: 10, bottom: 5 }) + .backgroundColor(this.status[item.id!] ? "#1a3e3f56" : "#4d191a32") + .onClick(() => { + this.status = getDynamicStates(this.status, item.id!) + AudioPlayer.playAudio(item.audioName!) + if (this.vibrationIntensity === 'H') { + Logger.info(TAG, "High intensity mode") + playVibrateCustom(item.vibratorFileH!, this.php) + } else if (this.vibrationIntensity === 'M') { + Logger.info(TAG, "Middle intensity mode") + playVibrateCustom(item.vibratorFileM!, this.php) + } else if (this.vibrationIntensity === 'L') { + Logger.info(TAG, "Low intensity mode") + playVibrateCustom(item.vibratorFileL!, this.php) + } else { + Logger.info(TAG, "Vibration mode error") + } + if (item.id) { + Logger.info(TAG, item.id.toString() + ' ' + item.name + ' ' + item.audioName) + } + }) + } + }) // LazyForEach + } + .listDirection(Axis.Vertical) + .divider({ strokeWidth: 3, color: "#00f3f3f3", startMargin: 0, endMargin: 0 }) + .height('50%') + .width('100%') + } + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Environment.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Environment.ets index 68cebf3f04..7ef5240367 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Environment.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Environment.ets @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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 { getImageEnvironmentList, ImageDataSource } from '../module/ImageData' -import CommonLayout from './Common' - -@Component -export default struct EnvironmentLayout { - @State environmentList: ImageDataSource = new ImageDataSource(getImageEnvironmentList()) - @State status: boolean[] = [false, false, false, false, false, false, false] - @Link vibrationIntensity: string - @Link php: string - - build() { - CommonLayout({ - dataList: $environmentList, - status: $status, - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } -} +/* + * Copyright (c) 2023 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 { getImageEnvironmentList, ImageDataSource } from '../module/ImageData' +import CommonLayout from './Common' + +@Component +export default struct EnvironmentLayout { + @State environmentList: ImageDataSource = new ImageDataSource(getImageEnvironmentList()) + @State status: boolean[] = [false, false, false, false, false, false, false] + @Link vibrationIntensity: string + @Link php: string + + build() { + CommonLayout({ + dataList: $environmentList, + status: $status, + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Exercise.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Exercise.ets index 2de2cb07c8..7543a256b9 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Exercise.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Exercise.ets @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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 { getImageExerciseList, ImageDataSource } from '../module/ImageData' -import CommonLayout from './Common' - -@Component -export default struct ExerciseLayout { - @State exerciseList: ImageDataSource = new ImageDataSource(getImageExerciseList()) - @State status: boolean[] = [false, false, false, false, false, false, false] - @Link vibrationIntensity: string - @Link php: string - - build() { - CommonLayout({ - dataList: $exerciseList, - status: $status, - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } -} +/* + * Copyright (c) 2023 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 { getImageExerciseList, ImageDataSource } from '../module/ImageData' +import CommonLayout from './Common' + +@Component +export default struct ExerciseLayout { + @State exerciseList: ImageDataSource = new ImageDataSource(getImageExerciseList()) + @State status: boolean[] = [false, false, false, false, false, false, false] + @Link vibrationIntensity: string + @Link php: string + + build() { + CommonLayout({ + dataList: $exerciseList, + status: $status, + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Footstep.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Footstep.ets index 56b4e443b9..db58ec43d3 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Footstep.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Footstep.ets @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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 { getImageFootstepList, ImageDataSource } from '../module/ImageData' -import CommonLayout from './Common' - -@Component -export default struct FootstepLayout { - @State footstepList: ImageDataSource = new ImageDataSource(getImageFootstepList()) - @State status: boolean[] = [false, false, false, false, false, false, false] - @Link vibrationIntensity: string - @Link php: string - - build() { - CommonLayout({ - dataList: $footstepList, - status: $status, - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } -} +/* + * Copyright (c) 2023 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 { getImageFootstepList, ImageDataSource } from '../module/ImageData' +import CommonLayout from './Common' + +@Component +export default struct FootstepLayout { + @State footstepList: ImageDataSource = new ImageDataSource(getImageFootstepList()) + @State status: boolean[] = [false, false, false, false, false, false, false] + @Link vibrationIntensity: string + @Link php: string + + build() { + CommonLayout({ + dataList: $footstepList, + status: $status, + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Instrument.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Instrument.ets index 2635097373..0f4cf857f2 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Instrument.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Instrument.ets @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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 { getImageInstrumentsList, ImageDataSource } from '../module/ImageData' -import CommonLayout from './Common' - -@Component -export default struct InstrumentLayout { - @State instrumentList: ImageDataSource = new ImageDataSource(getImageInstrumentsList()) - @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false] - @Link vibrationIntensity: string - @Link php: string - - build() { - CommonLayout({ - dataList: $instrumentList, - status: $status, - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } -} +/* + * Copyright (c) 2023 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 { getImageInstrumentsList, ImageDataSource } from '../module/ImageData' +import CommonLayout from './Common' + +@Component +export default struct InstrumentLayout { + @State instrumentList: ImageDataSource = new ImageDataSource(getImageInstrumentsList()) + @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false] + @Link vibrationIntensity: string + @Link php: string + + build() { + CommonLayout({ + dataList: $instrumentList, + status: $status, + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Interaction.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Interaction.ets index 9936c87b1c..0f11126a62 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Interaction.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Interaction.ets @@ -1,216 +1,216 @@ -/* - * Copyright (c) 2023 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 { playVibrateCustom } from '../module/Util' - -@Component -export default struct InteractionLayout { - @State status: boolean[] = [false, false, false, false] - @State stateSlideLeftRight: AnimationStatus = AnimationStatus.Initial - @State stateSlideUp: AnimationStatus = AnimationStatus.Initial - @State stateSwitchApp: AnimationStatus = AnimationStatus.Initial - @State stateUpSlideStop: AnimationStatus = AnimationStatus.Initial - @State iterations: number = 1 - @Link php: string - - build() { - Column() { - List({ space: 20 }) { - ListItem() { - Row({ space: 30 }) { - Column({ space: 10 }) { - Row() { - ImageAnimator() - .images([ - { src: $r("app.media.Slide_LeftRight1") }, - { src: $r("app.media.Slide_LeftRight2") }, - { src: $r("app.media.Slide_LeftRight3") }, - { src: $r("app.media.Slide_LeftRight4") }, - { src: $r("app.media.Slide_LeftRight5") }, - { src: $r("app.media.Slide_LeftRight6") }, - { src: $r("app.media.Slide_LeftRight7") }, - { src: $r("app.media.Slide_LeftRight8") }, - { src: $r("app.media.Slide_LeftRight9") }, - { src: $r("app.media.Slide_LeftRight10") }, - { src: $r("app.media.Slide_LeftRight11") }, - { src: $r("app.media.Slide_LeftRight12") }, - ]) - .borderRadius(10) - .duration(3000) - .state(this.stateSlideLeftRight) - .fillMode(FillMode.None) - .iterations(this.iterations) - .width("100%") - .height("100%") - .onFinish(() => { - this.stateSlideLeftRight = AnimationStatus.Initial - }) - } - .width('30%') - .borderRadius(20) - .backgroundColor("#66191a32") - .height("60%") - .onClick(() => { - this.stateSlideLeftRight = AnimationStatus.Running - playVibrateCustom("Slide_LeftRight.json", this.php) - }) - - Text($r("app.string.interaction_slide_left_right")) - .fontColor(Color.White) - .fontSize(18) - } - - Column({ space: 10 }) { - Row() { - ImageAnimator() - .images([ - { src: $r("app.media.slide_up1") }, - { src: $r("app.media.slide_up2") }, - { src: $r("app.media.slide_up3") }, - { src: $r("app.media.slide_up4") }, - { src: $r("app.media.slide_up5") }, - { src: $r("app.media.slide_up6") }, - { src: $r("app.media.slide_up7") }, - { src: $r("app.media.slide_up8") }, - { src: $r("app.media.slide_up9") }, - ]) - .borderRadius(10) - .duration(2250) - .state(this.stateSlideUp) - .fillMode(FillMode.None) - .iterations(this.iterations) - .width("100%") - .height("100%") - .onFinish(() => { - this.stateSlideUp = AnimationStatus.Initial - }) - } - .width('30%') - .borderRadius(20) - .backgroundColor("#66191a32") - .height("60%") - .onClick(() => { - this.stateSlideUp = AnimationStatus.Running - playVibrateCustom("Slide_Up.json", this.php) - }) - - Text($r("app.string.interaction_slide_up")) - .fontColor(Color.White) - .fontSize(18) - } - } - .justifyContent(FlexAlign.Center) - } - .margin({ left: "1%" }) - .width("100%") - - ListItem() { - Row({ space: 30 }) { - Column({ space: 10 }) { - Row() { - ImageAnimator() - .images([ - { src: $r("app.media.Switch_App1") }, - { src: $r("app.media.Switch_App2") }, - { src: $r("app.media.Switch_App3") }, - { src: $r("app.media.Switch_App4") }, - { src: $r("app.media.Switch_App5") }, - { src: $r("app.media.Switch_App6") }, - { src: $r("app.media.Switch_App7") }, - { src: $r("app.media.Switch_App8") }, - { src: $r("app.media.Switch_App9") }, - { src: $r("app.media.Switch_App10") }, - { src: $r("app.media.Switch_App11") }, - { src: $r("app.media.Switch_App12") }, - { src: $r("app.media.Switch_App13") }, - { src: $r("app.media.Switch_App14") }, - ]) - .borderRadius(10) - .duration(3500) - .state(this.stateSwitchApp) - .fillMode(FillMode.None) - .iterations(this.iterations) - .width("100%") - .height("100%") - .onFinish(() => { - this.stateSwitchApp = AnimationStatus.Initial - }) - } - .width('30%') - .borderRadius(20) - .backgroundColor("#66191a32") - .height("60%") - .onClick(() => { - this.stateSwitchApp = AnimationStatus.Running - playVibrateCustom("Switch_App.json", this.php) - }) - - Text($r("app.string.interaction_switch_app")) - .fontColor(Color.White) - .fontSize(18) - } - - Column({ space: 10 }) { - Row() { - ImageAnimator() - .images([ - { src: $r("app.media.Upslide_Stop1") }, - { src: $r("app.media.Upslide_Stop2") }, - { src: $r("app.media.Upslide_Stop3") }, - { src: $r("app.media.Upslide_Stop4") }, - { src: $r("app.media.Upslide_Stop5") }, - { src: $r("app.media.Upslide_Stop6") }, - { src: $r("app.media.Upslide_Stop7") }, - { src: $r("app.media.Upslide_Stop8") }, - { src: $r("app.media.Upslide_Stop9") }, - { src: $r("app.media.Upslide_Stop10") }, - { src: $r("app.media.Upslide_Stop11") }, - { src: $r("app.media.Upslide_Stop12") }, - ]) - .borderRadius(10) - .duration(3000) - .state(this.stateUpSlideStop) - .fillMode(FillMode.None) - .iterations(this.iterations) - .width("100%") - .height("100%") - .onFinish(() => { - this.stateUpSlideStop = AnimationStatus.Initial - }) - } - .width('30%') - .borderRadius(20) - .backgroundColor("#66191a32") - .height("60%") - .onClick(() => { - this.stateUpSlideStop = AnimationStatus.Running - playVibrateCustom("UpSlide_Stop.json", this.php) - }) - - Text($r("app.string.interaction_slide_stop")) - .fontColor(Color.White) - .fontSize(18) - } - } - .justifyContent(FlexAlign.Center) - } - .margin({ left: "1%" }) - .width("100%") - } - .height('50%') - .width("100%") - } - } -} +/* + * Copyright (c) 2023 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 { playVibrateCustom } from '../module/Util' + +@Component +export default struct InteractionLayout { + @State status: boolean[] = [false, false, false, false] + @State stateSlideLeftRight: AnimationStatus = AnimationStatus.Initial + @State stateSlideUp: AnimationStatus = AnimationStatus.Initial + @State stateSwitchApp: AnimationStatus = AnimationStatus.Initial + @State stateUpSlideStop: AnimationStatus = AnimationStatus.Initial + @State iterations: number = 1 + @Link php: string + + build() { + Column() { + List({ space: 20 }) { + ListItem() { + Row({ space: 30 }) { + Column({ space: 10 }) { + Row() { + ImageAnimator() + .images([ + { src: $r("app.media.Slide_LeftRight1") }, + { src: $r("app.media.Slide_LeftRight2") }, + { src: $r("app.media.Slide_LeftRight3") }, + { src: $r("app.media.Slide_LeftRight4") }, + { src: $r("app.media.Slide_LeftRight5") }, + { src: $r("app.media.Slide_LeftRight6") }, + { src: $r("app.media.Slide_LeftRight7") }, + { src: $r("app.media.Slide_LeftRight8") }, + { src: $r("app.media.Slide_LeftRight9") }, + { src: $r("app.media.Slide_LeftRight10") }, + { src: $r("app.media.Slide_LeftRight11") }, + { src: $r("app.media.Slide_LeftRight12") }, + ]) + .borderRadius(10) + .duration(3000) + .state(this.stateSlideLeftRight) + .fillMode(FillMode.None) + .iterations(this.iterations) + .width("100%") + .height("100%") + .onFinish(() => { + this.stateSlideLeftRight = AnimationStatus.Initial + }) + } + .width('30%') + .borderRadius(20) + .backgroundColor("#66191a32") + .height("60%") + .onClick(() => { + this.stateSlideLeftRight = AnimationStatus.Running + playVibrateCustom("Slide_LeftRight.json", this.php) + }) + + Text($r("app.string.interaction_slide_left_right")) + .fontColor(Color.White) + .fontSize(18) + } + + Column({ space: 10 }) { + Row() { + ImageAnimator() + .images([ + { src: $r("app.media.slide_up1") }, + { src: $r("app.media.slide_up2") }, + { src: $r("app.media.slide_up3") }, + { src: $r("app.media.slide_up4") }, + { src: $r("app.media.slide_up5") }, + { src: $r("app.media.slide_up6") }, + { src: $r("app.media.slide_up7") }, + { src: $r("app.media.slide_up8") }, + { src: $r("app.media.slide_up9") }, + ]) + .borderRadius(10) + .duration(2250) + .state(this.stateSlideUp) + .fillMode(FillMode.None) + .iterations(this.iterations) + .width("100%") + .height("100%") + .onFinish(() => { + this.stateSlideUp = AnimationStatus.Initial + }) + } + .width('30%') + .borderRadius(20) + .backgroundColor("#66191a32") + .height("60%") + .onClick(() => { + this.stateSlideUp = AnimationStatus.Running + playVibrateCustom("Slide_Up.json", this.php) + }) + + Text($r("app.string.interaction_slide_up")) + .fontColor(Color.White) + .fontSize(18) + } + } + .justifyContent(FlexAlign.Center) + } + .margin({ left: "1%" }) + .width("100%") + + ListItem() { + Row({ space: 30 }) { + Column({ space: 10 }) { + Row() { + ImageAnimator() + .images([ + { src: $r("app.media.Switch_App1") }, + { src: $r("app.media.Switch_App2") }, + { src: $r("app.media.Switch_App3") }, + { src: $r("app.media.Switch_App4") }, + { src: $r("app.media.Switch_App5") }, + { src: $r("app.media.Switch_App6") }, + { src: $r("app.media.Switch_App7") }, + { src: $r("app.media.Switch_App8") }, + { src: $r("app.media.Switch_App9") }, + { src: $r("app.media.Switch_App10") }, + { src: $r("app.media.Switch_App11") }, + { src: $r("app.media.Switch_App12") }, + { src: $r("app.media.Switch_App13") }, + { src: $r("app.media.Switch_App14") }, + ]) + .borderRadius(10) + .duration(3500) + .state(this.stateSwitchApp) + .fillMode(FillMode.None) + .iterations(this.iterations) + .width("100%") + .height("100%") + .onFinish(() => { + this.stateSwitchApp = AnimationStatus.Initial + }) + } + .width('30%') + .borderRadius(20) + .backgroundColor("#66191a32") + .height("60%") + .onClick(() => { + this.stateSwitchApp = AnimationStatus.Running + playVibrateCustom("Switch_App.json", this.php) + }) + + Text($r("app.string.interaction_switch_app")) + .fontColor(Color.White) + .fontSize(18) + } + + Column({ space: 10 }) { + Row() { + ImageAnimator() + .images([ + { src: $r("app.media.Upslide_Stop1") }, + { src: $r("app.media.Upslide_Stop2") }, + { src: $r("app.media.Upslide_Stop3") }, + { src: $r("app.media.Upslide_Stop4") }, + { src: $r("app.media.Upslide_Stop5") }, + { src: $r("app.media.Upslide_Stop6") }, + { src: $r("app.media.Upslide_Stop7") }, + { src: $r("app.media.Upslide_Stop8") }, + { src: $r("app.media.Upslide_Stop9") }, + { src: $r("app.media.Upslide_Stop10") }, + { src: $r("app.media.Upslide_Stop11") }, + { src: $r("app.media.Upslide_Stop12") }, + ]) + .borderRadius(10) + .duration(3000) + .state(this.stateUpSlideStop) + .fillMode(FillMode.None) + .iterations(this.iterations) + .width("100%") + .height("100%") + .onFinish(() => { + this.stateUpSlideStop = AnimationStatus.Initial + }) + } + .width('30%') + .borderRadius(20) + .backgroundColor("#66191a32") + .height("60%") + .onClick(() => { + this.stateUpSlideStop = AnimationStatus.Running + playVibrateCustom("UpSlide_Stop.json", this.php) + }) + + Text($r("app.string.interaction_slide_stop")) + .fontColor(Color.White) + .fontSize(18) + } + } + .justifyContent(FlexAlign.Center) + } + .margin({ left: "1%" }) + .width("100%") + } + .height('50%') + .width("100%") + } + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Racing.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Racing.ets index b6107a202d..abdc75438b 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Racing.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Racing.ets @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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 { getImageRacingList, ImageDataSource } from '../module/ImageData' -import CommonLayout from './Common' - -@Component -export default struct RacingLayout { - @State carList: ImageDataSource = new ImageDataSource(getImageRacingList()) - @State status: boolean[] = [false, false, false, false, false, false, false] - @Link vibrationIntensity: string - @Link php: string - - build() { - CommonLayout({ - dataList: $carList, - status: $status, - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } -} +/* + * Copyright (c) 2023 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 { getImageRacingList, ImageDataSource } from '../module/ImageData' +import CommonLayout from './Common' + +@Component +export default struct RacingLayout { + @State carList: ImageDataSource = new ImageDataSource(getImageRacingList()) + @State status: boolean[] = [false, false, false, false, false, false, false] + @Link vibrationIntensity: string + @Link php: string + + build() { + CommonLayout({ + dataList: $carList, + status: $status, + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Realistic.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Realistic.ets index 9221a66af1..fbd517c398 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Realistic.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Realistic.ets @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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 { getImageRealisticList, ImageDataSource } from '../module/ImageData' -import CommonLayout from './Common' - -@Component -export default struct RealisticLayout { - @State realisticList: ImageDataSource = new ImageDataSource(getImageRealisticList()) - @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false, false, false, false] - @Link vibrationIntensity: string - @Link php: string - - build() { - CommonLayout({ - dataList: $realisticList, - status: $status, - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } -} +/* + * Copyright (c) 2023 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 { getImageRealisticList, ImageDataSource } from '../module/ImageData' +import CommonLayout from './Common' + +@Component +export default struct RealisticLayout { + @State realisticList: ImageDataSource = new ImageDataSource(getImageRealisticList()) + @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false, false, false, false] + @Link vibrationIntensity: string + @Link php: string + + build() { + CommonLayout({ + dataList: $realisticList, + status: $status, + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Shooting.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Shooting.ets index 524769f6e6..ccf7589d02 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Shooting.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Shooting.ets @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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 { getImageShootList, ImageDataSource } from '../module/ImageData' -import CommonLayout from './Common' - -@Component -export default struct ShootLayout { - @State shootList: ImageDataSource = new ImageDataSource(getImageShootList()) - @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false, false, false, false] - @Link vibrationIntensity: string - @Link php: string - - build() { - CommonLayout({ - dataList: $shootList, - status: $status, - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } -} +/* + * Copyright (c) 2023 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 { getImageShootList, ImageDataSource } from '../module/ImageData' +import CommonLayout from './Common' + +@Component +export default struct ShootLayout { + @State shootList: ImageDataSource = new ImageDataSource(getImageShootList()) + @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false, false, false, false] + @Link vibrationIntensity: string + @Link php: string + + build() { + CommonLayout({ + dataList: $shootList, + status: $status, + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/VideoPreview.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/VideoPreview.ets index 2e0e970b7c..8bf3176ad3 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/VideoPreview.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/VideoPreview.ets @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router' - -@Component -export default struct VideoListLayout { - @State playDis: boolean = false - @Link php: string - - build() { - Scroll() { - Row({ space: 10 }) { - Stack() { - Image($r("app.media.HapticVideoPreview")) - .width("100%") - .height("100%") - .borderRadius(10) - Image($r("app.media.player2")) - .width("30%") - .height("30%") - .visibility(this.playDis ? Visibility.Hidden : Visibility.Visible) - } - .id("videoPreview") - .width("95%") - .height("30%") - .onClick(() => { - this.playDis = true - router.pushUrl({ - url: "module/VideoPlayModule", - params: { - vibrateFileName: "HapticVideo.json", - videoName: 'HapticVideo', - videoSrc: $r("app.media.HapticVideo"), - previewUri: $r("app.media.HapticVideoPreview"), - pages: "Index", - php: this.php - } - }) - }) - .padding({ left: 10 }) - } - } - .scrollable(ScrollDirection.Horizontal).scrollBar(BarState.Off) - } -} +/* + * Copyright (c) 2023 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 router from '@ohos.router' + +@Component +export default struct VideoListLayout { + @State playDis: boolean = false + @Link php: string + + build() { + Scroll() { + Row({ space: 10 }) { + Stack() { + Image($r("app.media.HapticVideoPreview")) + .width("100%") + .height("100%") + .borderRadius(10) + Image($r("app.media.player2")) + .width("30%") + .height("30%") + .visibility(this.playDis ? Visibility.Hidden : Visibility.Visible) + } + .id("videoPreview") + .width("95%") + .height("30%") + .onClick(() => { + this.playDis = true + router.pushUrl({ + url: "module/VideoPlayModule", + params: { + vibrateFileName: "HapticVideo.json", + videoName: 'HapticVideo', + videoSrc: $r("app.media.HapticVideo"), + previewUri: $r("app.media.HapticVideoPreview"), + pages: "Index", + php: this.php + } + }) + }) + .padding({ left: 10 }) + } + } + .scrollable(ScrollDirection.Horizontal).scrollBar(BarState.Off) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/entryability/EntryAbility.ts index d30b8cd46b..63f68c7013 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2023 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 Ability from '@ohos.app.ability.UIAbility'; -import type Window from '@ohos.window'; -import vibrator from '@ohos.vibrator'; -import Logger from '../module/Logger'; - -const TAG = '[EntryAbility]'; - -export default class EntryAbility extends Ability { - onCreate(want, launchParam) { - Logger.info(TAG, 'Ability onCreate, want param: %{public}s, launchParam: %{public}s', - JSON.stringify(want) ?? '', JSON.stringify(launchParam) ?? ''); - - vibrator.isSupportEffect('haptic.clock.timer', (error, data) => { - if (data) { - vibrator.startVibration({ - type: 'preset', - effectId: 'haptic.clock.timer', - count: 1, - }, { - usage: 'notification' - }); - } else { - Logger.info(TAG, 'Failed to vibrate onCreate'); - } - }); - } - - onDestroy() { - Logger.info(TAG, 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: Window.WindowStage) { - // Main window is created, set main page for this ability - Logger.info(TAG, 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - Logger.error(TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - Logger.info(TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - Logger.info(TAG, '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - Logger.info(TAG, '%{public}s', 'Ability onForeground'); - } - - onBackground() { - // Ability has back to background - Logger.info(TAG, '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2023 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 Ability from '@ohos.app.ability.UIAbility'; +import type Window from '@ohos.window'; +import vibrator from '@ohos.vibrator'; +import Logger from '../module/Logger'; + +const TAG = '[EntryAbility]'; + +export default class EntryAbility extends Ability { + onCreate(want, launchParam) { + Logger.info(TAG, 'Ability onCreate, want param: %{public}s, launchParam: %{public}s', + JSON.stringify(want) ?? '', JSON.stringify(launchParam) ?? ''); + + vibrator.isSupportEffect('haptic.clock.timer', (error, data) => { + if (data) { + vibrator.startVibration({ + type: 'preset', + effectId: 'haptic.clock.timer', + count: 1, + }, { + usage: 'notification' + }); + } else { + Logger.info(TAG, 'Failed to vibrate onCreate'); + } + }); + } + + onDestroy() { + Logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + // Main window is created, set main page for this ability + Logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error(TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + Logger.info(TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + Logger.info(TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + Logger.info(TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + Logger.info(TAG, '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/DisplayModule.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/DisplayModule.ets index d54b9e410a..dfb985fa14 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/DisplayModule.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/DisplayModule.ets @@ -1,191 +1,191 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router' -import VideoListLayout from '../component/VideoPreview' -import RacingLayout from '../component/Racing' -import BattleLayout from '../component/Battle' -import ShootLayout from '../component/Shooting' -import InstrumentLayout from '../component/Instrument' -import RealisticLayout from '../component/Realistic' -import FootstepLayout from '../component/Footstep' -import EnvironmentLayout from '../component/Environment' -import ExerciseLayout from '../component/Exercise' -import InteractionLayout from '../component/Interaction' -import Logger from './Logger' -import TabBar from './TabBar' - -const TAG = '[DisplayModule]' - -export enum TabIndex { - RACING = 0, - BATTLE, - SHOOT, - INSTRUMENT, - REALISTIC, - FOOTSTEP, - ENVIRONMENT, - EXERCISE, - INTERACTION, -} - -@Component -export default struct DisplayModule { - @State titleArr: Resource[] = [ - $r("app.string.display_racing"), $r("app.string.display_battle"), $r("app.string.display_shoot"), - $r("app.string.display_instrument"), $r("app.string.display_realistic"), $r("app.string.display_footstep"), - $r("app.string.display_environment"), $r("app.string.display_exercise"), $r("app.string.display_interaction") - ] - @State currentIndex: number = 0 - private swiperController: SwiperController = new SwiperController() - private tabHeight = 50 - @State playDis: boolean = false - @Link vibrationIntensity: string - @Link php: string - private controller: TabsController = new TabsController(); - - build() { - Column({ space: 10 }) { - Row() { - Text($r("app.string.display_haptic_video")) - .width('50%') - .fontSize(24) - .fontColor('#ffffffff') - .fontWeight(FontWeight.Normal) - .textAlign(TextAlign.Start) - .layoutWeight(7) - .padding({ left: 10 }) - Button($r("app.string.display_show_more")) - .id('showMore') - .backgroundColor("#00d613ca") - .layoutWeight(3) - .height(35) - .fontColor('#919191') - .onClick(() => { - Logger.info(TAG, 'Show more pressed') - router.pushUrl({ - url: 'module/VideoListModule', - params: {php: this.php} - }) - }) - } - .padding({ top: 5 }) - - VideoListLayout({php: $php}) - - Text($r("app.string.display_haptic_library")) - .width('100%') - .fontSize(24) - .fontColor('#ffffffff') - .fontWeight(FontWeight.Normal) - .textAlign(TextAlign.Start) - .padding({ left: 10 }) - - Row() { - TabBar({ - titleArr: $titleArr, - currentIndex: $currentIndex, - tabSelected: (position: number, title: string) => { - this.currentIndex = position - Logger.info(TAG, 'onTabSelected position = ' + position + ', title = ' + title) - this.swiperController.showNext() - }, - }) - } - .width('100%') - .height(this.tabHeight) - .zIndex(10) - - Scroll() { - Column() { - Swiper(this.swiperController) { - ForEach(this.titleArr, (item: string) => { - Column() { - if (this.currentIndex === TabIndex.RACING) { - RacingLayout({ - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } else if (this.currentIndex === TabIndex.BATTLE) { - BattleLayout({ - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } else if (this.currentIndex === TabIndex.SHOOT) { - ShootLayout({ - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } else if (this.currentIndex === TabIndex.INSTRUMENT) { - InstrumentLayout({ - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } else if (this.currentIndex === TabIndex.REALISTIC) { - RealisticLayout({ - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } else if (this.currentIndex === TabIndex.FOOTSTEP) { - FootstepLayout({ - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } else if (this.currentIndex === TabIndex.ENVIRONMENT) { - EnvironmentLayout({ - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } else if (this.currentIndex === TabIndex.EXERCISE) { - ExerciseLayout({ - vibrationIntensity: $vibrationIntensity, - php: $php - }) - } else if (this.currentIndex === TabIndex.INTERACTION) { - InteractionLayout({ - php: $php - }) - } else { - Text('Please Waiting!') - .fontSize(48) - .fontColor(Color.Black) - .width("100%") - .height("100%") - } - } - }, (item: string) => item) - } - .index(0) - .autoPlay(false) - .indicator(false) - .loop(false) - .vertical(false) - .itemSpace(0) - .index(this.currentIndex) - .flexGrow(1) - .width('100%') - .onChange((index: number) => { - Logger.info(TAG, index.toString()) - this.currentIndex = index - }) - } - } - .scrollBar(BarState.Off) - } - .width('100%') - .height('100%') - .backgroundColor('#f2191a32') - } -} +/* + * Copyright (c) 2023 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 router from '@ohos.router' +import VideoListLayout from '../component/VideoPreview' +import RacingLayout from '../component/Racing' +import BattleLayout from '../component/Battle' +import ShootLayout from '../component/Shooting' +import InstrumentLayout from '../component/Instrument' +import RealisticLayout from '../component/Realistic' +import FootstepLayout from '../component/Footstep' +import EnvironmentLayout from '../component/Environment' +import ExerciseLayout from '../component/Exercise' +import InteractionLayout from '../component/Interaction' +import Logger from './Logger' +import TabBar from './TabBar' + +const TAG = '[DisplayModule]' + +export enum TabIndex { + RACING = 0, + BATTLE, + SHOOT, + INSTRUMENT, + REALISTIC, + FOOTSTEP, + ENVIRONMENT, + EXERCISE, + INTERACTION, +} + +@Component +export default struct DisplayModule { + @State titleArr: Resource[] = [ + $r("app.string.display_racing"), $r("app.string.display_battle"), $r("app.string.display_shoot"), + $r("app.string.display_instrument"), $r("app.string.display_realistic"), $r("app.string.display_footstep"), + $r("app.string.display_environment"), $r("app.string.display_exercise"), $r("app.string.display_interaction") + ] + @State currentIndex: number = 0 + private swiperController: SwiperController = new SwiperController() + private tabHeight = 50 + @State playDis: boolean = false + @Link vibrationIntensity: string + @Link php: string + private controller: TabsController = new TabsController(); + + build() { + Column({ space: 10 }) { + Row() { + Text($r("app.string.display_haptic_video")) + .width('50%') + .fontSize(24) + .fontColor('#ffffffff') + .fontWeight(FontWeight.Normal) + .textAlign(TextAlign.Start) + .layoutWeight(7) + .padding({ left: 10 }) + Button($r("app.string.display_show_more")) + .id('showMore') + .backgroundColor("#00d613ca") + .layoutWeight(3) + .height(35) + .fontColor('#919191') + .onClick(() => { + Logger.info(TAG, 'Show more pressed') + router.pushUrl({ + url: 'module/VideoListModule', + params: {php: this.php} + }) + }) + } + .padding({ top: 5 }) + + VideoListLayout({php: $php}) + + Text($r("app.string.display_haptic_library")) + .width('100%') + .fontSize(24) + .fontColor('#ffffffff') + .fontWeight(FontWeight.Normal) + .textAlign(TextAlign.Start) + .padding({ left: 10 }) + + Row() { + TabBar({ + titleArr: $titleArr, + currentIndex: $currentIndex, + tabSelected: (position: number, title: string) => { + this.currentIndex = position + Logger.info(TAG, 'onTabSelected position = ' + position + ', title = ' + title) + this.swiperController.showNext() + }, + }) + } + .width('100%') + .height(this.tabHeight) + .zIndex(10) + + Scroll() { + Column() { + Swiper(this.swiperController) { + ForEach(this.titleArr, (item: string) => { + Column() { + if (this.currentIndex === TabIndex.RACING) { + RacingLayout({ + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } else if (this.currentIndex === TabIndex.BATTLE) { + BattleLayout({ + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } else if (this.currentIndex === TabIndex.SHOOT) { + ShootLayout({ + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } else if (this.currentIndex === TabIndex.INSTRUMENT) { + InstrumentLayout({ + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } else if (this.currentIndex === TabIndex.REALISTIC) { + RealisticLayout({ + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } else if (this.currentIndex === TabIndex.FOOTSTEP) { + FootstepLayout({ + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } else if (this.currentIndex === TabIndex.ENVIRONMENT) { + EnvironmentLayout({ + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } else if (this.currentIndex === TabIndex.EXERCISE) { + ExerciseLayout({ + vibrationIntensity: $vibrationIntensity, + php: $php + }) + } else if (this.currentIndex === TabIndex.INTERACTION) { + InteractionLayout({ + php: $php + }) + } else { + Text('Please Waiting!') + .fontSize(48) + .fontColor(Color.Black) + .width("100%") + .height("100%") + } + } + }, (item: string) => item) + } + .index(0) + .autoPlay(false) + .indicator(false) + .loop(false) + .vertical(false) + .itemSpace(0) + .index(this.currentIndex) + .flexGrow(1) + .width('100%') + .onChange((index: number) => { + Logger.info(TAG, index.toString()) + this.currentIndex = index + }) + } + } + .scrollBar(BarState.Off) + } + .width('100%') + .height('100%') + .backgroundColor('#f2191a32') + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/ImageData.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/ImageData.ets index 2c1d532df3..5b205c8d05 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/ImageData.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/ImageData.ets @@ -1,730 +1,730 @@ -/* - * Copyright (c) 2023 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 class ImagesData { - id ?: number - src ?: Resource - name ?: Resource - vibratorFileL ?: string - vibratorFileM ?: string - vibratorFileH ?: string - audioName ?: string -} - -export function getImageRacingList(): Array { - let ImagesDataArray: Array = [ - { - id: 0, - src: $r("app.media.Racing1"), - name: $r("app.string.display_racing_car_crash"), - vibratorFileL: "CarCrash_l.json", - vibratorFileM: "CarCrash_m.json", - vibratorFileH: "CarCrash_h.json", - audioName: "CarCrash.wav" - }, - { - id: 1, - src: $r("app.media.Racing2"), - name: $r("app.string.display_racing_ignite"), - vibratorFileL: "CarIgnite_l.json", - vibratorFileM: "CarIgnite_m.json", - vibratorFileH: "CarIgnite_h.json", - audioName: "CarIgnite.wav" - }, - { - id: 2, - src: $r("app.media.Racing3"), - name: $r("app.string.display_racing_skid"), - vibratorFileL: "CarSkid_l.json", - vibratorFileM: "CarSkid_m.json", - vibratorFileH: "CarSkid_h.json", - audioName: "CarSkid.wav" - }, - { - id: 3, - src: $r("app.media.Racing4"), - name: $r("app.string.display_racing_drifting_jet"), - vibratorFileL: "DriftingJet_l.json", - vibratorFileM: "DriftingJet_m.json", - vibratorFileH: "DriftingJet_h.json", - audioName: "DriftingJet.wav" - }, - { - id: 4, - src: $r("app.media.Racing5"), - name: $r("app.string.display_racing_jet_n2o"), - vibratorFileL: "JetN2O_l.json", - vibratorFileM: "JetN2O_m.json", - vibratorFileH: "JetN2O_h.json", - audioName: "JetN2O.wav" - }, - { - id: 5, - src: $r("app.media.Racing6"), - name: $r("app.string.display_racing_start"), - vibratorFileL: "RacingStart_l.json", - vibratorFileM: "RacingStart_m.json", - vibratorFileH: "RacingStart_h.json", - audioName: "RacingStart.wav" - }, - { - id: 6, - src: $r("app.media.Racing8"), - name: $r("app.string.display_racing_speed_up"), - vibratorFileL: "SpeedUp_l.json", - vibratorFileM: "SpeedUp_m.json", - vibratorFileH: "SpeedUp_h.json", - audioName: "SpeedUp.wav" - }, - ] - return ImagesDataArray; -} - -export function getImageBattleList(): Array { - let ImagesDataArray: Array = [ - { - id: 0, - src: $r("app.media.Battle7"), - name: $r("app.string.display_battle_tumble"), - vibratorFileL: "Tumble_l.json", - vibratorFileM: "Tumble_m.json", - vibratorFileH: "Tumble_h.json", - audioName: "Tumble.wav" - }, - { - id: 1, - src: $r("app.media.Battle2"), - name: $r("app.string.display_battle_punch"), - vibratorFileL: "Punch_l.json", - vibratorFileM: "Punch_m.json", - vibratorFileH: "Punch_h.json", - audioName: "Punch.wav" - }, - { - id: 2, - src: $r("app.media.Battle3"), - name: $r("app.string.display_battle_kick"), - vibratorFileL: "Kick_l.json", - vibratorFileM: "Kick_m.json", - vibratorFileH: "Kick_h.json", - audioName: "Kick.wav" - }, - { - id: 3, - src: $r("app.media.Battle4"), - name: $r("app.string.display_battle_hurt"), - vibratorFileL: "Hurt_l.json", - vibratorFileM: "Hurt_m.json", - vibratorFileH: "Hurt_h.json", - audioName: "Hurt.wav" - }, - { - id: 4, - src: $r("app.media.Battle5"), - name: $r("app.string.display_battle_blast"), - vibratorFileL: "Blast_l.json", - vibratorFileM: "Blast_m.json", - vibratorFileH: "Blast_h.json", - audioName: "Blast.wav" - }, - { - id: 5, - src: $r("app.media.Battle6"), - name: $r("app.string.display_battle_bomb"), - vibratorFileL: "Bomb_l.json", - vibratorFileM: "Bomb_m.json", - vibratorFileH: "Bomb_h.json", - audioName: "Bomb.wav" - }, - ] - return ImagesDataArray; -} - -export function getImageShootList(): Array { - let ImagesDataArray: Array = [ - { - id: 0, - src: $r("app.media.AK47"), - name: $r("app.string.display_shoot_AK47"), - vibratorFileL: "AK47_l.json", - vibratorFileM: "AK47_m.json", - vibratorFileH: "AK47_h.json", - audioName: "AK47.wav" - }, - { - id: 1, - src: $r("app.media.HK416"), - name: $r("app.string.display_shoot_HK416"), - vibratorFileL: "HK416_l.json", - vibratorFileM: "HK416_m.json", - vibratorFileH: "HK416_h.json", - audioName: "HK416.wav" - }, - { - id: 2, - src: $r("app.media.M4"), - name: $r("app.string.display_shoot_M4"), - vibratorFileL: "M4_l.json", - vibratorFileM: "M4_m.json", - vibratorFileH: "M4_h.json", - audioName: "M4.wav" - }, - { - id: 3, - src: $r("app.media.MP5"), - name: $r("app.string.display_shoot_MP5"), - vibratorFileL: "MP5_l.json", - vibratorFileM: "MP5_m.json", - vibratorFileH: "MP5_h.json", - audioName: "MP5.wav" - }, - { - id: 4, - src: $r("app.media.CZ75"), - name: $r("app.string.display_shoot_CZ75"), - vibratorFileL: "CZ75_l.json", - vibratorFileM: "CZ75_m.json", - vibratorFileH: "CZ75_h.json", - audioName: "CZ75.wav" - }, - { - id: 5, - src: $r("app.media.Winchester"), - name: $r("app.string.display_shoot_winchester"), - vibratorFileL: "Winchester_l.json", - vibratorFileM: "Winchester_m.json", - vibratorFileH: "Winchester_h.json", - audioName: "Winchester.wav" - }, - { - id: 6, - src: $r("app.media.Rifle"), - name: $r("app.string.display_shoot_rifle"), - vibratorFileL: "Rifle_l.json", - vibratorFileM: "Rifle_m.json", - vibratorFileH: "Rifle_h.json", - audioName: "Rifle.wav" - }, - { - id: 7, - src: $r("app.media.AssaultRifle"), - name: $r("app.string.display_shoot_assault_rifle"), - vibratorFileL: "AssaultRifle_l.json", - vibratorFileM: "AssaultRifle_m.json", - vibratorFileH: "AssaultRifle_h.json", - audioName: "AssaultRifle.wav" - }, - { - id: 8, - src: $r("app.media.HitSand"), - name: $r("app.string.display_shoot_hit_sand"), - vibratorFileL: "HitSand_l.json", - vibratorFileM: "HitSand_m.json", - vibratorFileH: "HitSand_h.json", - audioName: "HitSand.wav" - }, - { - id: 9, - src: $r("app.media.HitWater"), - name: $r("app.string.display_shoot_hit_water"), - vibratorFileL: "HitWater_l.json", - vibratorFileM: "HitWater_m.json", - vibratorFileH: "HitWater_h.json", - audioName: "HitWater.wav" - }, - { - id: 10, - src: $r("app.media.HitMetal"), - name: $r("app.string.display_shoot_hit_metal"), - vibratorFileL: "HitMetal_l.json", - vibratorFileM: "HitMetal_m.json", - vibratorFileH: "HitMetal_h.json", - audioName: "HitMetal.wav" - }, - { - id: 11, - src: $r("app.media.HitWood"), - name: $r("app.string.display_shoot_hit_wood"), - vibratorFileL: "HitWood_l.json", - vibratorFileM: "HitWood_m.json", - vibratorFileH: "HitWood_h.json", - audioName: "HitWood.wav" - }, - { - id: 12, - src: $r("app.media.HitGlass"), - name: $r("app.string.display_shoot_hit_glass"), - vibratorFileL: "HitGlass_l.json", - vibratorFileM: "HitGlass_m.json", - vibratorFileH: "HitGlass_h.json", - audioName: "HitGlass.wav" - }, - ] - return ImagesDataArray; -} - -export function getImageInstrumentsList(): Array { - let ImagesDataArray: Array = [ - { - id: 0, - src: $r("app.media.Cymbals"), - name: $r("app.string.display_instrument_cymbals"), - vibratorFileL: "Cymbals_l.json", - vibratorFileM: "Cymbals_m.json", - vibratorFileH: "Cymbals_h.json", - audioName: "Cymbals.wav" - }, - { - id: 1, - src: $r("app.media.Cymbals2"), - name: $r("app.string.display_instrument_cymbals2"), - vibratorFileL: "Cymbals2_l.json", - vibratorFileM: "Cymbals2_m.json", - vibratorFileH: "Cymbals2_h.json", - audioName: "Cymbals2.wav" - }, - { - id: 2, - src: $r("app.media.KickDrum"), - name: $r("app.string.display_instrument_kick_drum"), - vibratorFileL: "KickDrum_l.json", - vibratorFileM: "KickDrum_m.json", - vibratorFileH: "KickDrum_h.json", - audioName: "KickDrum.wav" - }, - { - id: 3, - src: $r("app.media.KickDrum2"), - name: $r("app.string.display_instrument_kick_drum2"), - vibratorFileL: "KickDrum2_l.json", - vibratorFileM: "KickDrum2_m.json", - vibratorFileH: "KickDrum2_h.json", - audioName: "KickDrum2.wav" - }, - { - id: 4, - src: $r("app.media.Guitar"), - name: $r("app.string.display_instrument_guitar"), - vibratorFileL: "Guitar_l.json", - vibratorFileM: "Guitar_m.json", - vibratorFileH: "Guitar_h.json", - audioName: "Guitar.wav" - }, - { - id: 5, - src: $r("app.media.Tambourine"), - name: $r("app.string.display_instrument_tambourine"), - vibratorFileL: "Tambourine_l.json", - vibratorFileM: "Tambourine_m.json", - vibratorFileH: "Tambourine_h.json", - audioName: "Tambourine.wav" - }, - { - id: 6, - src: $r("app.media.Bell"), - name: $r("app.string.display_instrument_bell"), - vibratorFileL: "bell_l.json", - vibratorFileM: "bell_m.json", - vibratorFileH: "bell_h.json", - audioName: "bell.wav" - }, - { - id: 7, - src: $r("app.media.Claves"), - name: $r("app.string.display_instrument_claves"), - vibratorFileL: "Claves_l.json", - vibratorFileM: "Claves_m.json", - vibratorFileH: "Claves_h.json", - audioName: "Claves.wav" - }, - { - id: 8, - src: $r("app.media.Gong"), - name: $r("app.string.display_instrument_gong"), - vibratorFileL: "Gong_l.json", - vibratorFileM: "Gong_m.json", - vibratorFileH: "Gong_h.json", - audioName: "Gong.wav" - }, - { - id: 9, - src: $r("app.media.Triangle"), - name: $r("app.string.display_instrument_triangle"), - vibratorFileL: "triangle_l.json", - vibratorFileM: "triangle_m.json", - vibratorFileH: "triangle_h.json", - audioName: "triangle.wav" - }, - ] - return ImagesDataArray; -} - -export function getImageRealisticList(): Array { - let ImagesDataArray: Array = [ - { - id: 0, - src: $r("app.media.Ice"), - name: $r("app.string.display_realistic_ice"), - vibratorFileL: "ice_l.json", - vibratorFileM: "ice_m.json", - vibratorFileH: "ice_h.json", - audioName: "ice.wav" - }, - { - id: 1, - src: $r("app.media.Keyboard"), - name: $r("app.string.display_realistic_keyboard"), - vibratorFileL: "Keyboard_l.json", - vibratorFileM: "Keyboard_m.json", - vibratorFileH: "Keyboard_h.json", - audioName: "Keyboard.wav" - }, - { - id: 2, - src: $r("app.media.Typewriter"), - name: $r("app.string.display_realistic_typewriter"), - vibratorFileL: "Typewriter_l.json", - vibratorFileM: "Typewriter_m.json", - vibratorFileH: "Typewriter_h.json", - audioName: "Typewriter.wav" - }, - { - id: 3, - src: $r("app.media.CoinDrop"), - name: $r("app.string.display_realistic_coin_drop"), - vibratorFileL: "CoinDrop_l.json", - vibratorFileM: "CoinDrop_m.json", - vibratorFileH: "CoinDrop_h.json", - audioName: "CoinDrop.wav" - }, - { - id: 4, - src: $r("app.media.Timer"), - name: $r("app.string.display_realistic_timer"), - vibratorFileL: "timer_l.json", - vibratorFileM: "timer_m.json", - vibratorFileH: "timer_h.json", - audioName: "timer.wav" - }, - { - id: 5, - src: $r("app.media.Walk"), - name: $r("app.string.display_realistic_walk"), - vibratorFileL: "Walk_l.json", - vibratorFileM: "Walk_m.json", - vibratorFileH: "Walk_h.json", - audioName: "Walk.wav" - }, - { - id: 6, - src: $r("app.media.camerashutter"), - name: $r("app.string.display_realistic_camerashutter"), - vibratorFileL: "camerashutter_l.json", - vibratorFileM: "camerashutter_m.json", - vibratorFileH: "camerashutter_h.json", - audioName: "camerashutter.wav" - }, - { - id: 7, - src: $r("app.media.camerashutter2"), - name: $r("app.string.display_realistic_camerashutter2"), - vibratorFileL: "camerashutter2_l.json", - vibratorFileM: "camerashutter2_m.json", - vibratorFileH: "camerashutter2_h.json", - audioName: "camerashutter2.wav" - }, - { - id: 8, - src: $r("app.media.Clock"), - name: $r("app.string.display_realistic_clock"), - vibratorFileL: "clock_l.json", - vibratorFileM: "clock_m.json", - vibratorFileH: "clock_h.json", - audioName: "clock.wav" - }, - { - id: 9, - src: $r("app.media.Water"), - name: $r("app.string.display_realistic_water"), - vibratorFileL: "Water_l.json", - vibratorFileM: "Water_m.json", - vibratorFileH: "Water_h.json", - audioName: "Water.wav" - }, - { - id: 10, - src: $r("app.media.heartbeat"), - name: $r("app.string.display_realistic_heartbeat"), - vibratorFileL: "heartbeat_l.json", - vibratorFileM: "heartbeat_m.json", - vibratorFileH: "heartbeat_h.json", - audioName: "heartbeat.wav" - }, - { - id: 11, - src: $r("app.media.Firework"), - name: $r("app.string.display_realistic_firework"), - vibratorFileL: "Firework_l.json", - vibratorFileM: "Firework_m.json", - vibratorFileH: "Firework_h.json", - audioName: "Firework.wav" - }, - { - id: 12, - src: $r("app.media.Picker"), - name: $r("app.string.display_realistic_picker"), - vibratorFileL: "Picker_l.json", - vibratorFileM: "Picker_m.json", - vibratorFileH: "Picker_h.json", - audioName: "Picker.wav" - }, - ] - return ImagesDataArray; -} - -export function getImageFootstepList(): Array { - let ImagesDataArray: Array = [ - { - id: 0, - src: $r("app.media.Footstep1"), - name: $r("app.string.display_footstep_on_carpet"), - vibratorFileL: "OnCarpet_l.json", - vibratorFileM: "OnCarpet_m.json", - vibratorFileH: "OnCarpet_h.json", - audioName: "OnCarpet.wav" - }, - { - id: 1, - src: $r("app.media.Footstep2"), - name: $r("app.string.display_footstep_on_concrete"), - vibratorFileL: "OnConcrete_l.json", - vibratorFileM: "OnConcrete_m.json", - vibratorFileH: "OnConcrete_h.json", - audioName: "OnConcrete.wav" - }, - { - id: 2, - src: $r("app.media.Footstep3"), - name: $r("app.string.display_footstep_on_grass"), - vibratorFileL: "OnGrass_l.json", - vibratorFileM: "OnGrass_m.json", - vibratorFileH: "OnGrass_h.json", - audioName: "OnGrass.wav" - }, - { - id: 3, - src: $r("app.media.Footstep4"), - name: $r("app.string.display_footstep_on_board"), - vibratorFileL: "OnWood_l.json", - vibratorFileM: "OnWood_m.json", - vibratorFileH: "OnWood_h.json", - audioName: "OnWood.wav" - }, - { - id: 4, - src: $r("app.media.Footstep5"), - name: $r("app.string.display_footstep_on_gravel"), - vibratorFileL: "OnGravel_l.json", - vibratorFileM: "OnGravel_m.json", - vibratorFileH: "OnGravel_h.json", - audioName: "OnGravel.wav" - }, - { - id: 5, - src: $r("app.media.Footstep6"), - name: $r("app.string.display_footstep_on_mud"), - vibratorFileL: "OnMud_l.json", - vibratorFileM: "OnMud_m.json", - vibratorFileH: "OnMud_h.json", - audioName: "OnMud.wav" - }, - { - id: 6, - src: $r("app.media.Footstep7"), - name: $r("app.string.display_footstep_on_snow"), - vibratorFileL: "OnSnow_l.json", - vibratorFileM: "OnSnow_m.json", - vibratorFileH: "OnSnow_h.json", - audioName: "OnSnow.wav" - }, - ] - return ImagesDataArray; -} - -export function getImageEnvironmentList(): Array { - let ImagesDataArray: Array = [ - { - id: 0, - src: $r("app.media.Rain"), - name: $r("app.string.display_environment_rain"), - vibratorFileL: "Rain_l.json", - vibratorFileM: "Rain_m.json", - vibratorFileH: "Rain_h.json", - audioName: "Rain.wav" - }, - { - id: 1, - src: $r("app.media.Snowdrift"), - name: $r("app.string.display_environment_snowdrift"), - vibratorFileL: "Snowdrift_l.json", - vibratorFileM: "Snowdrift_m.json", - vibratorFileH: "Snowdrift_h.json", - audioName: "Snowdrift.wav" - }, - { - id: 2, - src: $r("app.media.Campfire"), - name: $r("app.string.display_environment_campfire"), - vibratorFileL: "Campfire_l.json", - vibratorFileM: "Campfire_m.json", - vibratorFileH: "Campfire_h.json", - audioName: "Campfire.wav" - }, - { - id: 3, - src: $r("app.media.Creek"), - name: $r("app.string.display_environment_creek"), - vibratorFileL: "Creek_l.json", - vibratorFileM: "Creek_m.json", - vibratorFileH: "Creek_h.json", - audioName: "Creek.wav" - }, - { - id: 4, - src: $r("app.media.Wave"), - name: $r("app.string.display_environment_wave"), - vibratorFileL: "Wave_l.json", - vibratorFileM: "Wave_m.json", - vibratorFileH: "Wave_h.json", - audioName: "Wave.wav" - }, - { - id: 5, - src: $r("app.media.Wind"), - name: $r("app.string.display_environment_wind"), - vibratorFileL: "Wind_l.json", - vibratorFileM: "Wind_m.json", - vibratorFileH: "Wind_h.json", - audioName: "Wind.wav" - }, - { - id: 6, - src: $r("app.media.Thunder"), - name: $r("app.string.display_environment_thunder"), - vibratorFileL: "Thunder_l.json", - vibratorFileM: "Thunder_m.json", - vibratorFileH: "Thunder_h.json", - audioName: "Thunder.wav" - }, - ] - return ImagesDataArray; -} - -export function getImageExerciseList(): Array { - let ImagesDataArray: Array = [ - { - id: 0, - src: $r("app.media.Badminton"), - name: $r("app.string.display_exercise_badminton"), - vibratorFileL: "Badminton_l.json", - vibratorFileM: "Badminton_m.json", - vibratorFileH: "Badminton_h.json", - audioName: "Badminton.wav" - }, - { - id: 1, - src: $r("app.media.Baseball"), - name: $r("app.string.display_exercise_baseball"), - vibratorFileL: "Baseball_l.json", - vibratorFileM: "Baseball_m.json", - vibratorFileH: "Baseball_h.json", - audioName: "Baseball.wav" - }, - { - id: 2, - src: $r("app.media.Basketball"), - name: $r("app.string.display_exercise_basketball"), - vibratorFileL: "Basketball_l.json", - vibratorFileM: "Basketball_m.json", - vibratorFileH: "Basketball_h.json", - audioName: "Basketball.wav" - }, - { - id: 3, - src: $r("app.media.Skating"), - name: $r("app.string.display_exercise_skating"), - vibratorFileL: "Skating_l.json", - vibratorFileM: "Skating_m.json", - vibratorFileH: "Skating_h.json", - audioName: "Skating.wav" - }, - { - id: 4, - src: $r("app.media.Skiing"), - name: $r("app.string.display_exercise_skiing"), - vibratorFileL: "Skiing_l.json", - vibratorFileM: "Skiing_m.json", - vibratorFileH: "Skiing_h.json", - audioName: "Skiing.wav" - }, - { - id: 5, - src: $r("app.media.TableTennis"), - name: $r("app.string.display_exercise_tabletennis"), - vibratorFileL: "TableTennis_l.json", - vibratorFileM: "TableTennis_m.json", - vibratorFileH: "TableTennis_h.json", - audioName: "TableTennis.wav" - }, - { - id: 6, - src: $r("app.media.Diving"), - name: $r("app.string.display_exercise_diving"), - vibratorFileL: "Diving_l.json", - vibratorFileM: "Diving_m.json", - vibratorFileH: "Diving_h.json", - audioName: "Diving.wav" - }, - ] - return ImagesDataArray; -} - -export abstract class BaseDataSource implements IDataSource { - private mDataSource: T[] = []; - - constructor(dataList: T[]) { - this.mDataSource = dataList; - } - - totalCount(): number { - return this.mDataSource === null ? 0 : this.mDataSource.length - } - - getData(index: number): T | null { - return index >= 0 && index < this.totalCount() ? this.mDataSource[index] : null; - } - - registerDataChangeListener(listener: DataChangeListener) { - } - - unregisterDataChangeListener(listener: DataChangeListener) { - } -} - -export class ImageDataSource extends BaseDataSource { - constructor(students: ImagesData[]) { - super(students) - } -} +/* + * Copyright (c) 2023 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 class ImagesData { + id ?: number + src ?: Resource + name ?: Resource + vibratorFileL ?: string + vibratorFileM ?: string + vibratorFileH ?: string + audioName ?: string +} + +export function getImageRacingList(): Array { + let ImagesDataArray: Array = [ + { + id: 0, + src: $r("app.media.Racing1"), + name: $r("app.string.display_racing_car_crash"), + vibratorFileL: "CarCrash_l.json", + vibratorFileM: "CarCrash_m.json", + vibratorFileH: "CarCrash_h.json", + audioName: "CarCrash.wav" + }, + { + id: 1, + src: $r("app.media.Racing2"), + name: $r("app.string.display_racing_ignite"), + vibratorFileL: "CarIgnite_l.json", + vibratorFileM: "CarIgnite_m.json", + vibratorFileH: "CarIgnite_h.json", + audioName: "CarIgnite.wav" + }, + { + id: 2, + src: $r("app.media.Racing3"), + name: $r("app.string.display_racing_skid"), + vibratorFileL: "CarSkid_l.json", + vibratorFileM: "CarSkid_m.json", + vibratorFileH: "CarSkid_h.json", + audioName: "CarSkid.wav" + }, + { + id: 3, + src: $r("app.media.Racing4"), + name: $r("app.string.display_racing_drifting_jet"), + vibratorFileL: "DriftingJet_l.json", + vibratorFileM: "DriftingJet_m.json", + vibratorFileH: "DriftingJet_h.json", + audioName: "DriftingJet.wav" + }, + { + id: 4, + src: $r("app.media.Racing5"), + name: $r("app.string.display_racing_jet_n2o"), + vibratorFileL: "JetN2O_l.json", + vibratorFileM: "JetN2O_m.json", + vibratorFileH: "JetN2O_h.json", + audioName: "JetN2O.wav" + }, + { + id: 5, + src: $r("app.media.Racing6"), + name: $r("app.string.display_racing_start"), + vibratorFileL: "RacingStart_l.json", + vibratorFileM: "RacingStart_m.json", + vibratorFileH: "RacingStart_h.json", + audioName: "RacingStart.wav" + }, + { + id: 6, + src: $r("app.media.Racing8"), + name: $r("app.string.display_racing_speed_up"), + vibratorFileL: "SpeedUp_l.json", + vibratorFileM: "SpeedUp_m.json", + vibratorFileH: "SpeedUp_h.json", + audioName: "SpeedUp.wav" + }, + ] + return ImagesDataArray; +} + +export function getImageBattleList(): Array { + let ImagesDataArray: Array = [ + { + id: 0, + src: $r("app.media.Battle7"), + name: $r("app.string.display_battle_tumble"), + vibratorFileL: "Tumble_l.json", + vibratorFileM: "Tumble_m.json", + vibratorFileH: "Tumble_h.json", + audioName: "Tumble.wav" + }, + { + id: 1, + src: $r("app.media.Battle2"), + name: $r("app.string.display_battle_punch"), + vibratorFileL: "Punch_l.json", + vibratorFileM: "Punch_m.json", + vibratorFileH: "Punch_h.json", + audioName: "Punch.wav" + }, + { + id: 2, + src: $r("app.media.Battle3"), + name: $r("app.string.display_battle_kick"), + vibratorFileL: "Kick_l.json", + vibratorFileM: "Kick_m.json", + vibratorFileH: "Kick_h.json", + audioName: "Kick.wav" + }, + { + id: 3, + src: $r("app.media.Battle4"), + name: $r("app.string.display_battle_hurt"), + vibratorFileL: "Hurt_l.json", + vibratorFileM: "Hurt_m.json", + vibratorFileH: "Hurt_h.json", + audioName: "Hurt.wav" + }, + { + id: 4, + src: $r("app.media.Battle5"), + name: $r("app.string.display_battle_blast"), + vibratorFileL: "Blast_l.json", + vibratorFileM: "Blast_m.json", + vibratorFileH: "Blast_h.json", + audioName: "Blast.wav" + }, + { + id: 5, + src: $r("app.media.Battle6"), + name: $r("app.string.display_battle_bomb"), + vibratorFileL: "Bomb_l.json", + vibratorFileM: "Bomb_m.json", + vibratorFileH: "Bomb_h.json", + audioName: "Bomb.wav" + }, + ] + return ImagesDataArray; +} + +export function getImageShootList(): Array { + let ImagesDataArray: Array = [ + { + id: 0, + src: $r("app.media.AK47"), + name: $r("app.string.display_shoot_AK47"), + vibratorFileL: "AK47_l.json", + vibratorFileM: "AK47_m.json", + vibratorFileH: "AK47_h.json", + audioName: "AK47.wav" + }, + { + id: 1, + src: $r("app.media.HK416"), + name: $r("app.string.display_shoot_HK416"), + vibratorFileL: "HK416_l.json", + vibratorFileM: "HK416_m.json", + vibratorFileH: "HK416_h.json", + audioName: "HK416.wav" + }, + { + id: 2, + src: $r("app.media.M4"), + name: $r("app.string.display_shoot_M4"), + vibratorFileL: "M4_l.json", + vibratorFileM: "M4_m.json", + vibratorFileH: "M4_h.json", + audioName: "M4.wav" + }, + { + id: 3, + src: $r("app.media.MP5"), + name: $r("app.string.display_shoot_MP5"), + vibratorFileL: "MP5_l.json", + vibratorFileM: "MP5_m.json", + vibratorFileH: "MP5_h.json", + audioName: "MP5.wav" + }, + { + id: 4, + src: $r("app.media.CZ75"), + name: $r("app.string.display_shoot_CZ75"), + vibratorFileL: "CZ75_l.json", + vibratorFileM: "CZ75_m.json", + vibratorFileH: "CZ75_h.json", + audioName: "CZ75.wav" + }, + { + id: 5, + src: $r("app.media.Winchester"), + name: $r("app.string.display_shoot_winchester"), + vibratorFileL: "Winchester_l.json", + vibratorFileM: "Winchester_m.json", + vibratorFileH: "Winchester_h.json", + audioName: "Winchester.wav" + }, + { + id: 6, + src: $r("app.media.Rifle"), + name: $r("app.string.display_shoot_rifle"), + vibratorFileL: "Rifle_l.json", + vibratorFileM: "Rifle_m.json", + vibratorFileH: "Rifle_h.json", + audioName: "Rifle.wav" + }, + { + id: 7, + src: $r("app.media.AssaultRifle"), + name: $r("app.string.display_shoot_assault_rifle"), + vibratorFileL: "AssaultRifle_l.json", + vibratorFileM: "AssaultRifle_m.json", + vibratorFileH: "AssaultRifle_h.json", + audioName: "AssaultRifle.wav" + }, + { + id: 8, + src: $r("app.media.HitSand"), + name: $r("app.string.display_shoot_hit_sand"), + vibratorFileL: "HitSand_l.json", + vibratorFileM: "HitSand_m.json", + vibratorFileH: "HitSand_h.json", + audioName: "HitSand.wav" + }, + { + id: 9, + src: $r("app.media.HitWater"), + name: $r("app.string.display_shoot_hit_water"), + vibratorFileL: "HitWater_l.json", + vibratorFileM: "HitWater_m.json", + vibratorFileH: "HitWater_h.json", + audioName: "HitWater.wav" + }, + { + id: 10, + src: $r("app.media.HitMetal"), + name: $r("app.string.display_shoot_hit_metal"), + vibratorFileL: "HitMetal_l.json", + vibratorFileM: "HitMetal_m.json", + vibratorFileH: "HitMetal_h.json", + audioName: "HitMetal.wav" + }, + { + id: 11, + src: $r("app.media.HitWood"), + name: $r("app.string.display_shoot_hit_wood"), + vibratorFileL: "HitWood_l.json", + vibratorFileM: "HitWood_m.json", + vibratorFileH: "HitWood_h.json", + audioName: "HitWood.wav" + }, + { + id: 12, + src: $r("app.media.HitGlass"), + name: $r("app.string.display_shoot_hit_glass"), + vibratorFileL: "HitGlass_l.json", + vibratorFileM: "HitGlass_m.json", + vibratorFileH: "HitGlass_h.json", + audioName: "HitGlass.wav" + }, + ] + return ImagesDataArray; +} + +export function getImageInstrumentsList(): Array { + let ImagesDataArray: Array = [ + { + id: 0, + src: $r("app.media.Cymbals"), + name: $r("app.string.display_instrument_cymbals"), + vibratorFileL: "Cymbals_l.json", + vibratorFileM: "Cymbals_m.json", + vibratorFileH: "Cymbals_h.json", + audioName: "Cymbals.wav" + }, + { + id: 1, + src: $r("app.media.Cymbals2"), + name: $r("app.string.display_instrument_cymbals2"), + vibratorFileL: "Cymbals2_l.json", + vibratorFileM: "Cymbals2_m.json", + vibratorFileH: "Cymbals2_h.json", + audioName: "Cymbals2.wav" + }, + { + id: 2, + src: $r("app.media.KickDrum"), + name: $r("app.string.display_instrument_kick_drum"), + vibratorFileL: "KickDrum_l.json", + vibratorFileM: "KickDrum_m.json", + vibratorFileH: "KickDrum_h.json", + audioName: "KickDrum.wav" + }, + { + id: 3, + src: $r("app.media.KickDrum2"), + name: $r("app.string.display_instrument_kick_drum2"), + vibratorFileL: "KickDrum2_l.json", + vibratorFileM: "KickDrum2_m.json", + vibratorFileH: "KickDrum2_h.json", + audioName: "KickDrum2.wav" + }, + { + id: 4, + src: $r("app.media.Guitar"), + name: $r("app.string.display_instrument_guitar"), + vibratorFileL: "Guitar_l.json", + vibratorFileM: "Guitar_m.json", + vibratorFileH: "Guitar_h.json", + audioName: "Guitar.wav" + }, + { + id: 5, + src: $r("app.media.Tambourine"), + name: $r("app.string.display_instrument_tambourine"), + vibratorFileL: "Tambourine_l.json", + vibratorFileM: "Tambourine_m.json", + vibratorFileH: "Tambourine_h.json", + audioName: "Tambourine.wav" + }, + { + id: 6, + src: $r("app.media.Bell"), + name: $r("app.string.display_instrument_bell"), + vibratorFileL: "bell_l.json", + vibratorFileM: "bell_m.json", + vibratorFileH: "bell_h.json", + audioName: "bell.wav" + }, + { + id: 7, + src: $r("app.media.Claves"), + name: $r("app.string.display_instrument_claves"), + vibratorFileL: "Claves_l.json", + vibratorFileM: "Claves_m.json", + vibratorFileH: "Claves_h.json", + audioName: "Claves.wav" + }, + { + id: 8, + src: $r("app.media.Gong"), + name: $r("app.string.display_instrument_gong"), + vibratorFileL: "Gong_l.json", + vibratorFileM: "Gong_m.json", + vibratorFileH: "Gong_h.json", + audioName: "Gong.wav" + }, + { + id: 9, + src: $r("app.media.Triangle"), + name: $r("app.string.display_instrument_triangle"), + vibratorFileL: "triangle_l.json", + vibratorFileM: "triangle_m.json", + vibratorFileH: "triangle_h.json", + audioName: "triangle.wav" + }, + ] + return ImagesDataArray; +} + +export function getImageRealisticList(): Array { + let ImagesDataArray: Array = [ + { + id: 0, + src: $r("app.media.Ice"), + name: $r("app.string.display_realistic_ice"), + vibratorFileL: "ice_l.json", + vibratorFileM: "ice_m.json", + vibratorFileH: "ice_h.json", + audioName: "ice.wav" + }, + { + id: 1, + src: $r("app.media.Keyboard"), + name: $r("app.string.display_realistic_keyboard"), + vibratorFileL: "Keyboard_l.json", + vibratorFileM: "Keyboard_m.json", + vibratorFileH: "Keyboard_h.json", + audioName: "Keyboard.wav" + }, + { + id: 2, + src: $r("app.media.Typewriter"), + name: $r("app.string.display_realistic_typewriter"), + vibratorFileL: "Typewriter_l.json", + vibratorFileM: "Typewriter_m.json", + vibratorFileH: "Typewriter_h.json", + audioName: "Typewriter.wav" + }, + { + id: 3, + src: $r("app.media.CoinDrop"), + name: $r("app.string.display_realistic_coin_drop"), + vibratorFileL: "CoinDrop_l.json", + vibratorFileM: "CoinDrop_m.json", + vibratorFileH: "CoinDrop_h.json", + audioName: "CoinDrop.wav" + }, + { + id: 4, + src: $r("app.media.Timer"), + name: $r("app.string.display_realistic_timer"), + vibratorFileL: "timer_l.json", + vibratorFileM: "timer_m.json", + vibratorFileH: "timer_h.json", + audioName: "timer.wav" + }, + { + id: 5, + src: $r("app.media.Walk"), + name: $r("app.string.display_realistic_walk"), + vibratorFileL: "Walk_l.json", + vibratorFileM: "Walk_m.json", + vibratorFileH: "Walk_h.json", + audioName: "Walk.wav" + }, + { + id: 6, + src: $r("app.media.camerashutter"), + name: $r("app.string.display_realistic_camerashutter"), + vibratorFileL: "camerashutter_l.json", + vibratorFileM: "camerashutter_m.json", + vibratorFileH: "camerashutter_h.json", + audioName: "camerashutter.wav" + }, + { + id: 7, + src: $r("app.media.camerashutter2"), + name: $r("app.string.display_realistic_camerashutter2"), + vibratorFileL: "camerashutter2_l.json", + vibratorFileM: "camerashutter2_m.json", + vibratorFileH: "camerashutter2_h.json", + audioName: "camerashutter2.wav" + }, + { + id: 8, + src: $r("app.media.Clock"), + name: $r("app.string.display_realistic_clock"), + vibratorFileL: "clock_l.json", + vibratorFileM: "clock_m.json", + vibratorFileH: "clock_h.json", + audioName: "clock.wav" + }, + { + id: 9, + src: $r("app.media.Water"), + name: $r("app.string.display_realistic_water"), + vibratorFileL: "Water_l.json", + vibratorFileM: "Water_m.json", + vibratorFileH: "Water_h.json", + audioName: "Water.wav" + }, + { + id: 10, + src: $r("app.media.heartbeat"), + name: $r("app.string.display_realistic_heartbeat"), + vibratorFileL: "heartbeat_l.json", + vibratorFileM: "heartbeat_m.json", + vibratorFileH: "heartbeat_h.json", + audioName: "heartbeat.wav" + }, + { + id: 11, + src: $r("app.media.Firework"), + name: $r("app.string.display_realistic_firework"), + vibratorFileL: "Firework_l.json", + vibratorFileM: "Firework_m.json", + vibratorFileH: "Firework_h.json", + audioName: "Firework.wav" + }, + { + id: 12, + src: $r("app.media.Picker"), + name: $r("app.string.display_realistic_picker"), + vibratorFileL: "Picker_l.json", + vibratorFileM: "Picker_m.json", + vibratorFileH: "Picker_h.json", + audioName: "Picker.wav" + }, + ] + return ImagesDataArray; +} + +export function getImageFootstepList(): Array { + let ImagesDataArray: Array = [ + { + id: 0, + src: $r("app.media.Footstep1"), + name: $r("app.string.display_footstep_on_carpet"), + vibratorFileL: "OnCarpet_l.json", + vibratorFileM: "OnCarpet_m.json", + vibratorFileH: "OnCarpet_h.json", + audioName: "OnCarpet.wav" + }, + { + id: 1, + src: $r("app.media.Footstep2"), + name: $r("app.string.display_footstep_on_concrete"), + vibratorFileL: "OnConcrete_l.json", + vibratorFileM: "OnConcrete_m.json", + vibratorFileH: "OnConcrete_h.json", + audioName: "OnConcrete.wav" + }, + { + id: 2, + src: $r("app.media.Footstep3"), + name: $r("app.string.display_footstep_on_grass"), + vibratorFileL: "OnGrass_l.json", + vibratorFileM: "OnGrass_m.json", + vibratorFileH: "OnGrass_h.json", + audioName: "OnGrass.wav" + }, + { + id: 3, + src: $r("app.media.Footstep4"), + name: $r("app.string.display_footstep_on_board"), + vibratorFileL: "OnWood_l.json", + vibratorFileM: "OnWood_m.json", + vibratorFileH: "OnWood_h.json", + audioName: "OnWood.wav" + }, + { + id: 4, + src: $r("app.media.Footstep5"), + name: $r("app.string.display_footstep_on_gravel"), + vibratorFileL: "OnGravel_l.json", + vibratorFileM: "OnGravel_m.json", + vibratorFileH: "OnGravel_h.json", + audioName: "OnGravel.wav" + }, + { + id: 5, + src: $r("app.media.Footstep6"), + name: $r("app.string.display_footstep_on_mud"), + vibratorFileL: "OnMud_l.json", + vibratorFileM: "OnMud_m.json", + vibratorFileH: "OnMud_h.json", + audioName: "OnMud.wav" + }, + { + id: 6, + src: $r("app.media.Footstep7"), + name: $r("app.string.display_footstep_on_snow"), + vibratorFileL: "OnSnow_l.json", + vibratorFileM: "OnSnow_m.json", + vibratorFileH: "OnSnow_h.json", + audioName: "OnSnow.wav" + }, + ] + return ImagesDataArray; +} + +export function getImageEnvironmentList(): Array { + let ImagesDataArray: Array = [ + { + id: 0, + src: $r("app.media.Rain"), + name: $r("app.string.display_environment_rain"), + vibratorFileL: "Rain_l.json", + vibratorFileM: "Rain_m.json", + vibratorFileH: "Rain_h.json", + audioName: "Rain.wav" + }, + { + id: 1, + src: $r("app.media.Snowdrift"), + name: $r("app.string.display_environment_snowdrift"), + vibratorFileL: "Snowdrift_l.json", + vibratorFileM: "Snowdrift_m.json", + vibratorFileH: "Snowdrift_h.json", + audioName: "Snowdrift.wav" + }, + { + id: 2, + src: $r("app.media.Campfire"), + name: $r("app.string.display_environment_campfire"), + vibratorFileL: "Campfire_l.json", + vibratorFileM: "Campfire_m.json", + vibratorFileH: "Campfire_h.json", + audioName: "Campfire.wav" + }, + { + id: 3, + src: $r("app.media.Creek"), + name: $r("app.string.display_environment_creek"), + vibratorFileL: "Creek_l.json", + vibratorFileM: "Creek_m.json", + vibratorFileH: "Creek_h.json", + audioName: "Creek.wav" + }, + { + id: 4, + src: $r("app.media.Wave"), + name: $r("app.string.display_environment_wave"), + vibratorFileL: "Wave_l.json", + vibratorFileM: "Wave_m.json", + vibratorFileH: "Wave_h.json", + audioName: "Wave.wav" + }, + { + id: 5, + src: $r("app.media.Wind"), + name: $r("app.string.display_environment_wind"), + vibratorFileL: "Wind_l.json", + vibratorFileM: "Wind_m.json", + vibratorFileH: "Wind_h.json", + audioName: "Wind.wav" + }, + { + id: 6, + src: $r("app.media.Thunder"), + name: $r("app.string.display_environment_thunder"), + vibratorFileL: "Thunder_l.json", + vibratorFileM: "Thunder_m.json", + vibratorFileH: "Thunder_h.json", + audioName: "Thunder.wav" + }, + ] + return ImagesDataArray; +} + +export function getImageExerciseList(): Array { + let ImagesDataArray: Array = [ + { + id: 0, + src: $r("app.media.Badminton"), + name: $r("app.string.display_exercise_badminton"), + vibratorFileL: "Badminton_l.json", + vibratorFileM: "Badminton_m.json", + vibratorFileH: "Badminton_h.json", + audioName: "Badminton.wav" + }, + { + id: 1, + src: $r("app.media.Baseball"), + name: $r("app.string.display_exercise_baseball"), + vibratorFileL: "Baseball_l.json", + vibratorFileM: "Baseball_m.json", + vibratorFileH: "Baseball_h.json", + audioName: "Baseball.wav" + }, + { + id: 2, + src: $r("app.media.Basketball"), + name: $r("app.string.display_exercise_basketball"), + vibratorFileL: "Basketball_l.json", + vibratorFileM: "Basketball_m.json", + vibratorFileH: "Basketball_h.json", + audioName: "Basketball.wav" + }, + { + id: 3, + src: $r("app.media.Skating"), + name: $r("app.string.display_exercise_skating"), + vibratorFileL: "Skating_l.json", + vibratorFileM: "Skating_m.json", + vibratorFileH: "Skating_h.json", + audioName: "Skating.wav" + }, + { + id: 4, + src: $r("app.media.Skiing"), + name: $r("app.string.display_exercise_skiing"), + vibratorFileL: "Skiing_l.json", + vibratorFileM: "Skiing_m.json", + vibratorFileH: "Skiing_h.json", + audioName: "Skiing.wav" + }, + { + id: 5, + src: $r("app.media.TableTennis"), + name: $r("app.string.display_exercise_tabletennis"), + vibratorFileL: "TableTennis_l.json", + vibratorFileM: "TableTennis_m.json", + vibratorFileH: "TableTennis_h.json", + audioName: "TableTennis.wav" + }, + { + id: 6, + src: $r("app.media.Diving"), + name: $r("app.string.display_exercise_diving"), + vibratorFileL: "Diving_l.json", + vibratorFileM: "Diving_m.json", + vibratorFileH: "Diving_h.json", + audioName: "Diving.wav" + }, + ] + return ImagesDataArray; +} + +export abstract class BaseDataSource implements IDataSource { + private mDataSource: T[] = []; + + constructor(dataList: T[]) { + this.mDataSource = dataList; + } + + totalCount(): number { + return this.mDataSource === null ? 0 : this.mDataSource.length + } + + getData(index: number): T | null { + return index >= 0 && index < this.totalCount() ? this.mDataSource[index] : null; + } + + registerDataChangeListener(listener: DataChangeListener) { + } + + unregisterDataChangeListener(listener: DataChangeListener) { + } +} + +export class ImageDataSource extends BaseDataSource { + constructor(students: ImagesData[]) { + super(students) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/MyInfoModule.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/MyInfoModule.ets index 972601945d..99f666bf13 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/MyInfoModule.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/MyInfoModule.ets @@ -1,228 +1,228 @@ -/* - * Copyright (c) 2023 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 Logger from './Logger' - -const TAG = '[MyInfoModule]' - -@Component -export default struct MyInfoModule { - @State selectContent: Resource = $r("app.string.my_low_mode") - @State selectContent1: Resource = $r("app.string.my_ets") - - @Link vibrationIntensity: string - @Link php: string - - build() { - Column({ space: 30 }) { - Column({ space: 10 }) { - Row({ space: 10 }) { - Image($r("app.media.set")) - .height(20) - .width(20) - Text($r("app.string.my_settings")) - .fontColor(Color.White) - .fontSize(20) - Text(this.selectContent) - .fontSize(16) - .fontColor("#ffcbc2c2") - } - .id('intensitySelect') - .height("100%") - .width("80%") - .onClick(() => { - ActionSheet.show({ - title: $r("app.string.my_settings"), - message: $r("app.string.my_select_msg"), - autoCancel: true, - confirm: { - value: $r("app.string.cancel"), - action: () => { - Logger.info(TAG, 'Get Alert Dialog handled') - } - }, - cancel: () => { - Logger.info(TAG, 'actionSheet canceled') - }, - alignment: DialogAlignment.Bottom, - offset: { dx: 0, dy: -10 }, - sheets: [ - { - icon: $r("app.media.app_icon"), - title: $r("app.string.my_high_mode"), - action: () => { - this.selectContent = $r("app.string.my_high_mode") - this.vibrationIntensity = 'H' - Logger.info(TAG, 'Vibration intensity is high') - } - }, - { - icon: $r("app.media.app_icon"), - title: $r("app.string.my_middle_mode"), - action: () => { - this.selectContent = $r("app.string.my_middle_mode") - this.vibrationIntensity = 'M' - Logger.info(TAG, 'Vibration intensity is middle') - } - }, - { - icon: $r("app.media.app_icon"), - title: $r("app.string.my_low_mode"), - action: () => { - this.selectContent = $r("app.string.my_low_mode") - this.vibrationIntensity = 'L' - Logger.info(TAG, 'Vibration intensity is low') - } - } - ] - }) - }) - .width("80%") - - Row() { - } - .height(1) - .width("85%") - .backgroundColor('#ff404048') - } - - Column({ space: 10 }) { - Row({ space: 10 }) { - Image($r("app.media.select")) - .height(20) - .width(20) - Text($r("app.string.my_php")) - .fontColor(Color.White) - .fontSize(20) - Text(this.selectContent1) - .fontSize(16) - .fontColor("#ffcbc2c2") - } - .id('phpSelect1') - .height("100%") - .width("80%") - .onClick(() => { - ActionSheet.show({ - title: $r("app.string.my_php_select"), - message: $r("app.string.my_linguistic_type"), - autoCancel: true, - confirm: { - value: $r("app.string.cancel"), - action: () => { - Logger.info(TAG, 'Get Alert Dialog handled') - } - }, - cancel: () => { - Logger.info(TAG, 'actionSheet canceled') - }, - alignment: DialogAlignment.Bottom, - offset: { dx: 0, dy: -10 }, - sheets: [ - { - icon: $r("app.media.app_icon"), - title: $r("app.string.my_ets"), - action: () => { - this.selectContent1 = $r("app.string.my_ets") - this.php = 'ets' - } - }, - { - icon: $r("app.media.app_icon"), - title: $r("app.string.my_capi"), - action: () => { - this.selectContent1 = $r("app.string.my_capi") - this.php = 'capi' - } - } - ] - }) - }) - .width("80%") - - Row() { - } - .height(1) - .width("85%") - .backgroundColor('#ff404048') - } - - Column({ space: 10 }) { - Row({ space: 10 }) { - Image($r("app.media.Verison")) - .width(20) - .height(20) - Text($r("app.string.my_version")) - .fontColor(Color.White) - .fontSize(20) - .backgroundColor('#cc191a32') - Text('v1.0') - .fontSize(20) - .fontColor("#ff706666") - } - .width("80%") - - Row() { - } - .height(1) - .width("85%") - .backgroundColor("#ff404048") - } - - Column({ space: 10 }) { - Row({ space: 10 }) { - Image($r("app.media.bangzhu")) - .width(20) - .height(20) - Text($r("app.string.my_help")) - .fontColor(Color.White) - .fontSize(20) - .backgroundColor('#cc191a32') - Text('Please Waiting!') - .fontSize(20) - .fontColor("#ff706666") - } - .width("80%") - - Row() { - } - .height(1) - .width("85%") - .backgroundColor("#ff404048") - } - - Column({ space: 10 }) { - Row({ space: 10 }) { - Image($r("app.media.xinxi")) - .width(20) - .height(20) - Text($r("app.string.my_develop")) - .fontColor(Color.White) - .fontSize(20) - .backgroundColor('#cc191a32') - Text('Please Waiting!') - .fontSize(20) - .fontColor("#ff706666") - } - .width("80%") - - Row() { - } - .height(1) - .width("85%") - .backgroundColor("#ff404048") - } - } - } -} +/* + * Copyright (c) 2023 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 Logger from './Logger' + +const TAG = '[MyInfoModule]' + +@Component +export default struct MyInfoModule { + @State selectContent: Resource = $r("app.string.my_low_mode") + @State selectContent1: Resource = $r("app.string.my_ets") + + @Link vibrationIntensity: string + @Link php: string + + build() { + Column({ space: 30 }) { + Column({ space: 10 }) { + Row({ space: 10 }) { + Image($r("app.media.set")) + .height(20) + .width(20) + Text($r("app.string.my_settings")) + .fontColor(Color.White) + .fontSize(20) + Text(this.selectContent) + .fontSize(16) + .fontColor("#ffcbc2c2") + } + .id('intensitySelect') + .height("100%") + .width("80%") + .onClick(() => { + ActionSheet.show({ + title: $r("app.string.my_settings"), + message: $r("app.string.my_select_msg"), + autoCancel: true, + confirm: { + value: $r("app.string.cancel"), + action: () => { + Logger.info(TAG, 'Get Alert Dialog handled') + } + }, + cancel: () => { + Logger.info(TAG, 'actionSheet canceled') + }, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -10 }, + sheets: [ + { + icon: $r("app.media.app_icon"), + title: $r("app.string.my_high_mode"), + action: () => { + this.selectContent = $r("app.string.my_high_mode") + this.vibrationIntensity = 'H' + Logger.info(TAG, 'Vibration intensity is high') + } + }, + { + icon: $r("app.media.app_icon"), + title: $r("app.string.my_middle_mode"), + action: () => { + this.selectContent = $r("app.string.my_middle_mode") + this.vibrationIntensity = 'M' + Logger.info(TAG, 'Vibration intensity is middle') + } + }, + { + icon: $r("app.media.app_icon"), + title: $r("app.string.my_low_mode"), + action: () => { + this.selectContent = $r("app.string.my_low_mode") + this.vibrationIntensity = 'L' + Logger.info(TAG, 'Vibration intensity is low') + } + } + ] + }) + }) + .width("80%") + + Row() { + } + .height(1) + .width("85%") + .backgroundColor('#ff404048') + } + + Column({ space: 10 }) { + Row({ space: 10 }) { + Image($r("app.media.select")) + .height(20) + .width(20) + Text($r("app.string.my_php")) + .fontColor(Color.White) + .fontSize(20) + Text(this.selectContent1) + .fontSize(16) + .fontColor("#ffcbc2c2") + } + .id('phpSelect1') + .height("100%") + .width("80%") + .onClick(() => { + ActionSheet.show({ + title: $r("app.string.my_php_select"), + message: $r("app.string.my_linguistic_type"), + autoCancel: true, + confirm: { + value: $r("app.string.cancel"), + action: () => { + Logger.info(TAG, 'Get Alert Dialog handled') + } + }, + cancel: () => { + Logger.info(TAG, 'actionSheet canceled') + }, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -10 }, + sheets: [ + { + icon: $r("app.media.app_icon"), + title: $r("app.string.my_ets"), + action: () => { + this.selectContent1 = $r("app.string.my_ets") + this.php = 'ets' + } + }, + { + icon: $r("app.media.app_icon"), + title: $r("app.string.my_capi"), + action: () => { + this.selectContent1 = $r("app.string.my_capi") + this.php = 'capi' + } + } + ] + }) + }) + .width("80%") + + Row() { + } + .height(1) + .width("85%") + .backgroundColor('#ff404048') + } + + Column({ space: 10 }) { + Row({ space: 10 }) { + Image($r("app.media.Verison")) + .width(20) + .height(20) + Text($r("app.string.my_version")) + .fontColor(Color.White) + .fontSize(20) + .backgroundColor('#cc191a32') + Text('v1.0') + .fontSize(20) + .fontColor("#ff706666") + } + .width("80%") + + Row() { + } + .height(1) + .width("85%") + .backgroundColor("#ff404048") + } + + Column({ space: 10 }) { + Row({ space: 10 }) { + Image($r("app.media.bangzhu")) + .width(20) + .height(20) + Text($r("app.string.my_help")) + .fontColor(Color.White) + .fontSize(20) + .backgroundColor('#cc191a32') + Text('Please Waiting!') + .fontSize(20) + .fontColor("#ff706666") + } + .width("80%") + + Row() { + } + .height(1) + .width("85%") + .backgroundColor("#ff404048") + } + + Column({ space: 10 }) { + Row({ space: 10 }) { + Image($r("app.media.xinxi")) + .width(20) + .height(20) + Text($r("app.string.my_develop")) + .fontColor(Color.White) + .fontSize(20) + .backgroundColor('#cc191a32') + Text('Please Waiting!') + .fontSize(20) + .fontColor("#ff706666") + } + .width("80%") + + Row() { + } + .height(1) + .width("85%") + .backgroundColor("#ff404048") + } + } + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/TabBar.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/TabBar.ets index 4665acd838..3bb7067170 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/TabBar.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/TabBar.ets @@ -1,86 +1,86 @@ -/* - * Copyright (c) 2023 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 Logger from './Logger' - -const TAG = '[TabBar]' - -export class TabModel { - index ?: number - content ?: Resource - left ?: number - width ?: number -} - -@Component -export default struct TabBar { - private fontSizeNormal = 18 - private tabMargin = 15 - private titleLength = 3 - @Link titleArr: Resource[] - @Link currentIndex: number - private left: number = 0 - private tabSelected: (position: number, title: string) => void = (position: number, title: string) => { - Logger.info(TAG, 'tabSelected position = ' + position + ', title = ' + title) - } - @State private tabDataArr: TabModel[] = [] - private scroller: Scroller = new Scroller() - - aboutToAppear() { - this.tabDataArr = this.titleArr.map((title: Resource, index: number) => { - let tabModel = new TabModel() - tabModel.index = index - tabModel.content = title - tabModel.left = this.left - let width = this.titleLength * this.fontSizeNormal + this.tabMargin * 2 - tabModel.width = width - tabModel.left = this.left - this.left += width - return tabModel - }) - } - - build() { - Scroll(this.scroller) { - Flex({ direction: FlexDirection.Row }) { - ForEach(this.tabDataArr, (item: TabModel) => { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text(item.content) - .fontSize(this.currentIndex === item.index ? this.fontSizeNormal + 3 : this.fontSizeNormal) - .fontColor(this.currentIndex === item.index ? "#2AEFCC" : Color.White) - .fontWeight(this.currentIndex === item.index ? FontWeight.Bold : FontWeight.Normal) - .textAlign(TextAlign.Center) - Column() - .height(3) - .width(item.width! - this.tabMargin * 2) - .margin({ top: 10 }) - .backgroundColor("#2AEFCC") - .visibility(this.currentIndex === item.index ? Visibility.Visible : Visibility.Hidden) - } - .width(item.width!) - .height('100%') - .backgroundColor("#00002222") - .onClick(() => { - if (item.index !== undefined) { - this.currentIndex = item.index - } - }) - }, (item: TabModel) => item.index!.toString()) - } - } - .scrollable(ScrollDirection.Horizontal) - .scrollBar(BarState.Off) - } -} +/* + * Copyright (c) 2023 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 Logger from './Logger' + +const TAG = '[TabBar]' + +export class TabModel { + index ?: number + content ?: Resource + left ?: number + width ?: number +} + +@Component +export default struct TabBar { + private fontSizeNormal = 18 + private tabMargin = 15 + private titleLength = 3 + @Link titleArr: Resource[] + @Link currentIndex: number + private left: number = 0 + private tabSelected: (position: number, title: string) => void = (position: number, title: string) => { + Logger.info(TAG, 'tabSelected position = ' + position + ', title = ' + title) + } + @State private tabDataArr: TabModel[] = [] + private scroller: Scroller = new Scroller() + + aboutToAppear() { + this.tabDataArr = this.titleArr.map((title: Resource, index: number) => { + let tabModel = new TabModel() + tabModel.index = index + tabModel.content = title + tabModel.left = this.left + let width = this.titleLength * this.fontSizeNormal + this.tabMargin * 2 + tabModel.width = width + tabModel.left = this.left + this.left += width + return tabModel + }) + } + + build() { + Scroll(this.scroller) { + Flex({ direction: FlexDirection.Row }) { + ForEach(this.tabDataArr, (item: TabModel) => { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text(item.content) + .fontSize(this.currentIndex === item.index ? this.fontSizeNormal + 3 : this.fontSizeNormal) + .fontColor(this.currentIndex === item.index ? "#2AEFCC" : Color.White) + .fontWeight(this.currentIndex === item.index ? FontWeight.Bold : FontWeight.Normal) + .textAlign(TextAlign.Center) + Column() + .height(3) + .width(item.width! - this.tabMargin * 2) + .margin({ top: 10 }) + .backgroundColor("#2AEFCC") + .visibility(this.currentIndex === item.index ? Visibility.Visible : Visibility.Hidden) + } + .width(item.width!) + .height('100%') + .backgroundColor("#00002222") + .onClick(() => { + if (item.index !== undefined) { + this.currentIndex = item.index + } + }) + }, (item: TabModel) => item.index!.toString()) + } + } + .scrollable(ScrollDirection.Horizontal) + .scrollBar(BarState.Off) + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/Util.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/Util.ets index addcbc5698..33bad70bb0 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/Util.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/Util.ets @@ -1,118 +1,118 @@ -/* - * Copyright (c) 2023 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 vibrator from '@ohos.vibrator' -import Window from '@ohos.window' -import Logger from './Logger' -import resourceManager from '@ohos.resourceManager' -import { BusinessError } from '@ohos.base' -import { StartCustom } from 'library'; - -const TAG = '[Util]' - -export function getDynamicStates(dis: boolean[], id: number): boolean[] { - for (let i = 0; i < dis.length; i++) { - i === id ? dis[i] = true : dis[i] = false - Logger.info(TAG, dis[i].toString()) - } - return dis -} - -export async function playVibrateCustom(fileName: string, mode: string) { - let rawFd: resourceManager.RawFileDescriptor | undefined = undefined - await getContext().resourceManager.getRawFd(fileName).then(value => { - rawFd = value - Logger.info(TAG, "rawFd of vibration:" + " fd:" + rawFd.fd + ", offset:" + rawFd.offset + ", length: " + rawFd.length) - }) - if (mode === "ets") { - try { - vibrator.startVibration({ - type: "file", - hapticFd: { fd: rawFd!.fd, offset: rawFd!.offset, length: rawFd!.length } - }, { - usage: "unknown" - }, (error: BusinessError) => { - if (error) { - Logger.info(TAG, 'startVibration failed, type is file, in callback'); - } else { - Logger.info(TAG, 'startVibration successful, type is file, in callback'); - } - }); - } catch (error) { - let err: BusinessError = error as BusinessError; - Logger.info(TAG, 'startVibration failed, type is file, in catch, err code:' + err.code + ' err msg:' + err.message) - } - } else if (mode === "capi"){ - let ret: number - ret = StartCustom(rawFd!.fd, rawFd!.offset, rawFd!.length) - console.info('StartCustom ret', ret); - } -} - -export function changeOrientationInternal(lastWindow: Window.Window, portrait: boolean): void { - if (portrait) { - lastWindow.setPreferredOrientation(Window.Orientation.LANDSCAPE).then(() => { - Logger.info(TAG, "setPreferredOrientation success") - }).catch((error: BusinessError) => { - Logger.info(TAG, "setPreferredOrientation failure" + JSON.stringify(error)) - }) - } else { - lastWindow.setPreferredOrientation(Window.Orientation.PORTRAIT).then(() => { - Logger.info(TAG, "setPreferredOrientation success") - }).catch((error: BusinessError) => { - Logger.info(TAG, "setPreferredOrientation failure: " + JSON.stringify(error)) - }) - } -} - -export function changeOrientation(portrait: boolean): void { - Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => { - changeOrientationInternal(lastWindow, portrait) - }).catch((error: BusinessError) => { - Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error)) - }) -} - -export function hideTitleBar(): void { - Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => { - if (lastWindow) { - lastWindow.setWindowSystemBarEnable([], (err: BusinessError) => { - if (err) { - Logger.info(TAG, "hideTitleBar failed") - } else { - Logger.info(TAG, "hideTitleBar successful") - } - }) - } - }).catch((error: BusinessError) => { - Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error)) - }) -} - -export function showTitleBar(): void { - Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => { - if (lastWindow) { - lastWindow.setWindowSystemBarEnable(['status', 'navigation'], (err: BusinessError) => { - if (err) { - Logger.info(TAG, "showTitleBar failed") - } else { - Logger.info(TAG, "showTitleBar successful") - } - }) - } - }).catch((error: BusinessError) => { - Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error)) - }) -} +/* + * Copyright (c) 2023 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 vibrator from '@ohos.vibrator' +import Window from '@ohos.window' +import Logger from './Logger' +import resourceManager from '@ohos.resourceManager' +import { BusinessError } from '@ohos.base' +import { StartCustom } from 'library'; + +const TAG = '[Util]' + +export function getDynamicStates(dis: boolean[], id: number): boolean[] { + for (let i = 0; i < dis.length; i++) { + i === id ? dis[i] = true : dis[i] = false + Logger.info(TAG, dis[i].toString()) + } + return dis +} + +export async function playVibrateCustom(fileName: string, mode: string) { + let rawFd: resourceManager.RawFileDescriptor | undefined = undefined + await getContext().resourceManager.getRawFd(fileName).then(value => { + rawFd = value + Logger.info(TAG, "rawFd of vibration:" + " fd:" + rawFd.fd + ", offset:" + rawFd.offset + ", length: " + rawFd.length) + }) + if (mode === "ets") { + try { + vibrator.startVibration({ + type: "file", + hapticFd: { fd: rawFd!.fd, offset: rawFd!.offset, length: rawFd!.length } + }, { + usage: "unknown" + }, (error: BusinessError) => { + if (error) { + Logger.info(TAG, 'startVibration failed, type is file, in callback'); + } else { + Logger.info(TAG, 'startVibration successful, type is file, in callback'); + } + }); + } catch (error) { + let err: BusinessError = error as BusinessError; + Logger.info(TAG, 'startVibration failed, type is file, in catch, err code:' + err.code + ' err msg:' + err.message) + } + } else if (mode === "capi"){ + let ret: number + ret = StartCustom(rawFd!.fd, rawFd!.offset, rawFd!.length) + console.info('StartCustom ret', ret); + } +} + +export function changeOrientationInternal(lastWindow: Window.Window, portrait: boolean): void { + if (portrait) { + lastWindow.setPreferredOrientation(Window.Orientation.LANDSCAPE).then(() => { + Logger.info(TAG, "setPreferredOrientation success") + }).catch((error: BusinessError) => { + Logger.info(TAG, "setPreferredOrientation failure" + JSON.stringify(error)) + }) + } else { + lastWindow.setPreferredOrientation(Window.Orientation.PORTRAIT).then(() => { + Logger.info(TAG, "setPreferredOrientation success") + }).catch((error: BusinessError) => { + Logger.info(TAG, "setPreferredOrientation failure: " + JSON.stringify(error)) + }) + } +} + +export function changeOrientation(portrait: boolean): void { + Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => { + changeOrientationInternal(lastWindow, portrait) + }).catch((error: BusinessError) => { + Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error)) + }) +} + +export function hideTitleBar(): void { + Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => { + if (lastWindow) { + lastWindow.setWindowSystemBarEnable([], (err: BusinessError) => { + if (err) { + Logger.info(TAG, "hideTitleBar failed") + } else { + Logger.info(TAG, "hideTitleBar successful") + } + }) + } + }).catch((error: BusinessError) => { + Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error)) + }) +} + +export function showTitleBar(): void { + Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => { + if (lastWindow) { + lastWindow.setWindowSystemBarEnable(['status', 'navigation'], (err: BusinessError) => { + if (err) { + Logger.info(TAG, "showTitleBar failed") + } else { + Logger.info(TAG, "showTitleBar successful") + } + }) + } + }).catch((error: BusinessError) => { + Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error)) + }) +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoListModule.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoListModule.ets index a20194e783..fb6d6f85c2 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoListModule.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoListModule.ets @@ -1,94 +1,94 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router' - -@Entry -@Component -struct VideoListModule { - private php: string = (router.getParams() as Record)['php'] - build() { - Column({ space: 20 }) { - Row() { - Button({ type: ButtonType.Normal }) { - Text("<") - .fontColor(Color.White) - .fontSize(28) - } - .backgroundColor('#00191a32') - .padding({ left: 5 }) - .layoutWeight(1) - .onClick(() => { - router.pushUrl({ - url: 'pages/Index' - }) - }) - - Text($r("app.string.back")) - .fontColor(Color.White) - .fontSize(24) - .layoutWeight(7) - .padding({ right: 10 }) - } - .padding({ top: 5 }) - - Column({ space: 20 }) { - List({ space: 10 }) { - ListItem() { - Row() { - Image($r("app.media.HapticVideoPreview")) - .width("50%") - .height(100) - .borderRadius(10) - Column() { - Text($r("app.string.video_list_haptic_video")) - .fontSize(18) - .fontColor(Color.White) - Text($r("app.string.video_list_haptic_video_msg")) - .fontSize(16) - .fontColor("#ff837979") - } - .alignItems(HorizontalAlign.Start) - .padding({ left: 5 }) - .height(100) - } - .width("95%") - .padding({ left: 10 }) - .backgroundColor("#00002222") - .onClick(() => { - router.pushUrl({ - url: "module/VideoPlayModule", - params: { - vibrateFileName: "HapticVideo.json", - videoName: 'HapticVideo', - videoSrc: $r("app.media.HapticVideo"), - previewUri: $r("app.media.HapticVideoPreview"), - pages: "VideoListPage", - php: this.php - } - }) - }) - } - } - .listDirection(Axis.Vertical) - .divider({ strokeWidth: 10, color: "#00f3f3f3", startMargin: 20, endMargin: 20 }) - .height("60%") - } - } - .width('100%') - .height('100%') - .backgroundColor('#f2191a32') - } -} +/* + * Copyright (c) 2023 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 router from '@ohos.router' + +@Entry +@Component +struct VideoListModule { + private php: string = (router.getParams() as Record)['php'] + build() { + Column({ space: 20 }) { + Row() { + Button({ type: ButtonType.Normal }) { + Text("<") + .fontColor(Color.White) + .fontSize(28) + } + .backgroundColor('#00191a32') + .padding({ left: 5 }) + .layoutWeight(1) + .onClick(() => { + router.pushUrl({ + url: 'pages/Index' + }) + }) + + Text($r("app.string.back")) + .fontColor(Color.White) + .fontSize(24) + .layoutWeight(7) + .padding({ right: 10 }) + } + .padding({ top: 5 }) + + Column({ space: 20 }) { + List({ space: 10 }) { + ListItem() { + Row() { + Image($r("app.media.HapticVideoPreview")) + .width("50%") + .height(100) + .borderRadius(10) + Column() { + Text($r("app.string.video_list_haptic_video")) + .fontSize(18) + .fontColor(Color.White) + Text($r("app.string.video_list_haptic_video_msg")) + .fontSize(16) + .fontColor("#ff837979") + } + .alignItems(HorizontalAlign.Start) + .padding({ left: 5 }) + .height(100) + } + .width("95%") + .padding({ left: 10 }) + .backgroundColor("#00002222") + .onClick(() => { + router.pushUrl({ + url: "module/VideoPlayModule", + params: { + vibrateFileName: "HapticVideo.json", + videoName: 'HapticVideo', + videoSrc: $r("app.media.HapticVideo"), + previewUri: $r("app.media.HapticVideoPreview"), + pages: "VideoListPage", + php: this.php + } + }) + }) + } + } + .listDirection(Axis.Vertical) + .divider({ strokeWidth: 10, color: "#00f3f3f3", startMargin: 20, endMargin: 20 }) + .height("60%") + } + } + .width('100%') + .height('100%') + .backgroundColor('#f2191a32') + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoPlayModule.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoPlayModule.ets index df913bb18f..adadb75787 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoPlayModule.ets +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoPlayModule.ets @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2023 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 vibrator from '@ohos.vibrator'; -import router from '@ohos.router' -import { changeOrientation, showTitleBar, playVibrateCustom, hideTitleBar } from './Util' - -@Entry -@Component -struct VideoPlayModule { - @State videoName: string = (router.getParams() as Record)['videoName'] - private pages: string = (router.getParams() as Record)['pages'] - @State videoSrc: Resource = (router.getParams() as Record)['videoSrc'] - @State previewUri: Resource = (router.getParams() as Record)['previewUri'] - private vibrateFileName: string = (router.getParams() as Record)['vibrateFileName'] - @State portrait: boolean = true - private php: string = (router.getParams() as Record)['php'] - videoController: VideoController = new VideoController() - - build() { - Stack({ alignContent: Alignment.TopStart }) { - Video({ - src: this.videoSrc, - previewUri: this.previewUri, - controller: this.videoController, - }) - .height("100%") - .width('100%') - .objectFit(ImageFit.Auto) - .controls(false) - .onStart(() => { - changeOrientation(false) - hideTitleBar() - playVibrateCustom(this.vibrateFileName, this.php) - }) - .onClick(() => { - this.portrait = !this.portrait - }) - .autoPlay(true) - Row() { - Button('<') - .fontSize(15) - .backgroundColor("#00222222") - .id('videoBack') - .onClick(() => { - changeOrientation(false) - showTitleBar() - vibrator.stopVibration() - router.back() - }) - Text(this.videoName).fontSize(15).fontColor(Color.White) - } - .width("100%") - .height("10%") - .backgroundColor('#80191a32') - .visibility(this.portrait ? Visibility.Visible : Visibility.Hidden) - }.width('100%') - .height('100%') - .backgroundColor('#f2191a32') - } -} +/* + * Copyright (c) 2023 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 vibrator from '@ohos.vibrator'; +import router from '@ohos.router' +import { changeOrientation, showTitleBar, playVibrateCustom, hideTitleBar } from './Util' + +@Entry +@Component +struct VideoPlayModule { + @State videoName: string = (router.getParams() as Record)['videoName'] + private pages: string = (router.getParams() as Record)['pages'] + @State videoSrc: Resource = (router.getParams() as Record)['videoSrc'] + @State previewUri: Resource = (router.getParams() as Record)['previewUri'] + private vibrateFileName: string = (router.getParams() as Record)['vibrateFileName'] + @State portrait: boolean = true + private php: string = (router.getParams() as Record)['php'] + videoController: VideoController = new VideoController() + + build() { + Stack({ alignContent: Alignment.TopStart }) { + Video({ + src: this.videoSrc, + previewUri: this.previewUri, + controller: this.videoController, + }) + .height("100%") + .width('100%') + .objectFit(ImageFit.Auto) + .controls(false) + .onStart(() => { + changeOrientation(false) + hideTitleBar() + playVibrateCustom(this.vibrateFileName, this.php) + }) + .onClick(() => { + this.portrait = !this.portrait + }) + .autoPlay(true) + Row() { + Button('<') + .fontSize(15) + .backgroundColor("#00222222") + .id('videoBack') + .onClick(() => { + changeOrientation(false) + showTitleBar() + vibrator.stopVibration() + router.back() + }) + Text(this.videoName).fontSize(15).fontColor(Color.White) + } + .width("100%") + .height("10%") + .backgroundColor('#80191a32') + .visibility(this.portrait ? Visibility.Visible : Visibility.Hidden) + }.width('100%') + .height('100%') + .backgroundColor('#f2191a32') + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/module.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/module.json5 index 9171640f70..7ce1388a9c 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/module.json5 +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/module.json5 @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2023 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", - "srcEntrance": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "metadata": [ - { - "name": "ArkTSPartialUpdate", - "value": "true" - }, - { - "name": "partialUpdateStrictCheck", - "value": "warn" - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.VIBRATE" - } - ] - } +/* + * Copyright (c) 2023 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", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "true" + }, + { + "name": "partialUpdateStrictCheck", + "value": "warn" + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.VIBRATE" + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/base/element/color.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_h.json index 6800ed2bb0..f5c83b76a6 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_h.json @@ -1,37 +1,37 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 147, - "Parameters": { - "Intensity": 100, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 182, - "Parameters": { - "Intensity": 100, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 147, + "Parameters": { + "Intensity": 100, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 182, + "Parameters": { + "Intensity": 100, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_l.json index d518b903f7..de732a7ba2 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_l.json @@ -1,37 +1,37 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 147, - "Parameters": { - "Intensity": 60, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 182, - "Parameters": { - "Intensity": 60, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 147, + "Parameters": { + "Intensity": 60, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 182, + "Parameters": { + "Intensity": 60, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_m.json index 335d1d3e79..dfd948738e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AK47_m.json @@ -1,37 +1,37 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 147, - "Parameters": { - "Intensity": 80, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 182, - "Parameters": { - "Intensity": 80, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 147, + "Parameters": { + "Intensity": 80, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 182, + "Parameters": { + "Intensity": 80, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_h.json index e0ccf32c64..091cc5f291 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_h.json @@ -1,47 +1,47 @@ -{ - "MetaData": { - "Create": "2020-08-10", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 0, - "Parameters": { - "Intensity": 9, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 35, - "Parameters": { - "Intensity": 100, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 130, - "Parameters": { - "Intensity": 80, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2020-08-10", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 0, + "Parameters": { + "Intensity": 9, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 35, + "Parameters": { + "Intensity": 100, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 130, + "Parameters": { + "Intensity": 80, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_l.json index e69558665f..1b4aa377ba 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_l.json @@ -1,47 +1,47 @@ -{ - "MetaData": { - "Create": "2020-08-10", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 0, - "Parameters": { - "Intensity": 5, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 35, - "Parameters": { - "Intensity": 60, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 130, - "Parameters": { - "Intensity": 48, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2020-08-10", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 0, + "Parameters": { + "Intensity": 5, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 35, + "Parameters": { + "Intensity": 60, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 130, + "Parameters": { + "Intensity": 48, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_m.json index 1980176c14..d3e058f644 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/AssaultRifle_m.json @@ -1,47 +1,47 @@ -{ - "MetaData": { - "Create": "2020-08-10", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 0, - "Parameters": { - "Intensity": 7, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 35, - "Parameters": { - "Intensity": 80, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 130, - "Parameters": { - "Intensity": 64, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2020-08-10", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 0, + "Parameters": { + "Intensity": 7, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 35, + "Parameters": { + "Intensity": 80, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 130, + "Parameters": { + "Intensity": 64, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_h.json index 9b6f55dd12..b1b7319a2b 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_h.json @@ -1,225 +1,225 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 50, - "StartTime": 27, - "Parameters": { - "Intensity": 92, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 49, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 10 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 140, - "StartTime": 78, - "Parameters": { - "Intensity": 65, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 99, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 140, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 114, - "StartTime": 548, - "Parameters": { - "Intensity": 60, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 25, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 39, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 114, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 114, - "StartTime": 548, - "Parameters": { - "Intensity": 29, - "Frequency": 65, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 25, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 29, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 114, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 62, - "StartTime": 662, - "Parameters": { - "Intensity": 85, - "Frequency": 75, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 22, - "Intensity": 0.06, - "Frequency": -30 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 20 - }, - { - "Time": 62, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1179, - "Parameters": { - "Intensity": 80, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 110, - "StartTime": 1217, - "Parameters": { - "Intensity": 45, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 77, - "Intensity": 0.66, - "Frequency": 0 - }, - { - "Time": 110, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 50, + "StartTime": 27, + "Parameters": { + "Intensity": 92, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 49, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 10 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 140, + "StartTime": 78, + "Parameters": { + "Intensity": 65, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 99, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 140, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 114, + "StartTime": 548, + "Parameters": { + "Intensity": 60, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 25, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 39, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 114, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 114, + "StartTime": 548, + "Parameters": { + "Intensity": 29, + "Frequency": 65, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 25, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 29, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 114, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 62, + "StartTime": 662, + "Parameters": { + "Intensity": 85, + "Frequency": 75, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 22, + "Intensity": 0.06, + "Frequency": -30 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 20 + }, + { + "Time": 62, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1179, + "Parameters": { + "Intensity": 80, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 110, + "StartTime": 1217, + "Parameters": { + "Intensity": 45, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 77, + "Intensity": 0.66, + "Frequency": 0 + }, + { + "Time": 110, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_l.json index 2dd217e8c5..b0df34b91e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_l.json @@ -1,225 +1,225 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 50, - "StartTime": 27, - "Parameters": { - "Intensity": 55, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 49, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 10 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 140, - "StartTime": 78, - "Parameters": { - "Intensity": 39, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 99, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 140, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 114, - "StartTime": 548, - "Parameters": { - "Intensity": 36, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 25, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 39, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 114, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 114, - "StartTime": 548, - "Parameters": { - "Intensity": 17, - "Frequency": 65, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 25, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 29, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 114, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 62, - "StartTime": 662, - "Parameters": { - "Intensity": 51, - "Frequency": 75, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 22, - "Intensity": 0.06, - "Frequency": -30 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 20 - }, - { - "Time": 62, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1179, - "Parameters": { - "Intensity": 48, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 110, - "StartTime": 1217, - "Parameters": { - "Intensity": 27, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 77, - "Intensity": 0.66, - "Frequency": 0 - }, - { - "Time": 110, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 50, + "StartTime": 27, + "Parameters": { + "Intensity": 55, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 49, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 10 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 140, + "StartTime": 78, + "Parameters": { + "Intensity": 39, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 99, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 140, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 114, + "StartTime": 548, + "Parameters": { + "Intensity": 36, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 25, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 39, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 114, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 114, + "StartTime": 548, + "Parameters": { + "Intensity": 17, + "Frequency": 65, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 25, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 29, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 114, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 62, + "StartTime": 662, + "Parameters": { + "Intensity": 51, + "Frequency": 75, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 22, + "Intensity": 0.06, + "Frequency": -30 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 20 + }, + { + "Time": 62, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1179, + "Parameters": { + "Intensity": 48, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 110, + "StartTime": 1217, + "Parameters": { + "Intensity": 27, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 77, + "Intensity": 0.66, + "Frequency": 0 + }, + { + "Time": 110, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_m.json index 897da3d77b..585fa871bf 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Badminton_m.json @@ -1,225 +1,225 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 50, - "StartTime": 27, - "Parameters": { - "Intensity": 73, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 49, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 10 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 140, - "StartTime": 78, - "Parameters": { - "Intensity": 52, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 99, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 140, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 114, - "StartTime": 548, - "Parameters": { - "Intensity": 48, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 25, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 39, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 114, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 114, - "StartTime": 548, - "Parameters": { - "Intensity": 23, - "Frequency": 65, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 25, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 29, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 114, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 62, - "StartTime": 662, - "Parameters": { - "Intensity": 68, - "Frequency": 75, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 22, - "Intensity": 0.06, - "Frequency": -30 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 20 - }, - { - "Time": 62, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1179, - "Parameters": { - "Intensity": 64, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 110, - "StartTime": 1217, - "Parameters": { - "Intensity": 36, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 77, - "Intensity": 0.66, - "Frequency": 0 - }, - { - "Time": 110, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 50, + "StartTime": 27, + "Parameters": { + "Intensity": 73, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 49, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 10 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 140, + "StartTime": 78, + "Parameters": { + "Intensity": 52, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 99, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 140, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 114, + "StartTime": 548, + "Parameters": { + "Intensity": 48, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 25, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 39, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 114, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 114, + "StartTime": 548, + "Parameters": { + "Intensity": 23, + "Frequency": 65, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 25, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 29, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 114, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 62, + "StartTime": 662, + "Parameters": { + "Intensity": 68, + "Frequency": 75, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 22, + "Intensity": 0.06, + "Frequency": -30 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 20 + }, + { + "Time": 62, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1179, + "Parameters": { + "Intensity": 64, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 110, + "StartTime": 1217, + "Parameters": { + "Intensity": 36, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 77, + "Intensity": 0.66, + "Frequency": 0 + }, + { + "Time": 110, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_h.json index 97345e62f7..1168c116cb 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_h.json @@ -1,93 +1,93 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 114, - "StartTime": 106, - "Parameters": { - "Intensity": 55, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 0.26, - "Frequency": 10 - }, - { - "Time": 86, - "Intensity": 0.59, - "Frequency": 15 - }, - { - "Time": 102, - "Intensity": 0.59, - "Frequency": 10 - }, - { - "Time": 114, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 141, - "StartTime": 232, - "Parameters": { - "Intensity": 100, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 10 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 45, - "Intensity": 0.51, - "Frequency": -20 - }, - { - "Time": 141, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 114, + "StartTime": 106, + "Parameters": { + "Intensity": 55, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 0.26, + "Frequency": 10 + }, + { + "Time": 86, + "Intensity": 0.59, + "Frequency": 15 + }, + { + "Time": 102, + "Intensity": 0.59, + "Frequency": 10 + }, + { + "Time": 114, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 141, + "StartTime": 232, + "Parameters": { + "Intensity": 100, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 10 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 45, + "Intensity": 0.51, + "Frequency": -20 + }, + { + "Time": 141, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_l.json index bae3f24bb3..f6d24b719b 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_l.json @@ -1,93 +1,93 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 114, - "StartTime": 106, - "Parameters": { - "Intensity": 33, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 0.26, - "Frequency": 10 - }, - { - "Time": 86, - "Intensity": 0.59, - "Frequency": 15 - }, - { - "Time": 102, - "Intensity": 0.59, - "Frequency": 10 - }, - { - "Time": 114, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 141, - "StartTime": 232, - "Parameters": { - "Intensity": 60, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 10 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 45, - "Intensity": 0.51, - "Frequency": -20 - }, - { - "Time": 141, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 114, + "StartTime": 106, + "Parameters": { + "Intensity": 33, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 0.26, + "Frequency": 10 + }, + { + "Time": 86, + "Intensity": 0.59, + "Frequency": 15 + }, + { + "Time": 102, + "Intensity": 0.59, + "Frequency": 10 + }, + { + "Time": 114, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 141, + "StartTime": 232, + "Parameters": { + "Intensity": 60, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 10 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 45, + "Intensity": 0.51, + "Frequency": -20 + }, + { + "Time": 141, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_m.json index e2358fdebe..48570ab26d 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Baseball_m.json @@ -1,93 +1,93 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 114, - "StartTime": 106, - "Parameters": { - "Intensity": 44, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 0.26, - "Frequency": 10 - }, - { - "Time": 86, - "Intensity": 0.59, - "Frequency": 15 - }, - { - "Time": 102, - "Intensity": 0.59, - "Frequency": 10 - }, - { - "Time": 114, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 141, - "StartTime": 232, - "Parameters": { - "Intensity": 80, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 10 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 45, - "Intensity": 0.51, - "Frequency": -20 - }, - { - "Time": 141, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 114, + "StartTime": 106, + "Parameters": { + "Intensity": 44, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 0.26, + "Frequency": 10 + }, + { + "Time": 86, + "Intensity": 0.59, + "Frequency": 15 + }, + { + "Time": 102, + "Intensity": 0.59, + "Frequency": 10 + }, + { + "Time": 114, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 141, + "StartTime": 232, + "Parameters": { + "Intensity": 80, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 10 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 45, + "Intensity": 0.51, + "Frequency": -20 + }, + { + "Time": 141, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_h.json index 7497bd0f5e..573ed0435f 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_h.json @@ -1,362 +1,362 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 221, - "StartTime": 31, - "Parameters": { - "Intensity": 100, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 55, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 62, - "Intensity": 0.35, - "Frequency": -10 - }, - { - "Time": 154, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 221, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 49, - "Parameters": { - "Intensity": 100, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 588, - "Parameters": { - "Intensity": 50, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 240, - "StartTime": 692, - "Parameters": { - "Intensity": 80, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 60, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 67, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 168, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 240, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 712, - "Parameters": { - "Intensity": 80, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1073, - "Parameters": { - "Intensity": 40, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 220, - "StartTime": 1139, - "Parameters": { - "Intensity": 70, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 55, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 61, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 154, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 220, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1156, - "Parameters": { - "Intensity": 70, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1506, - "Parameters": { - "Intensity": 33, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 220, - "StartTime": 1569, - "Parameters": { - "Intensity": 60, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 55, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 61, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 154, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 220, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1586, - "Parameters": { - "Intensity": 60, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1851, - "Parameters": { - "Intensity": 25, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 169, - "StartTime": 1923, - "Parameters": { - "Intensity": 50, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 46, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 53, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 113, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 169, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1935, - "Parameters": { - "Intensity": 50, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2087, - "Parameters": { - "Intensity": 50, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2185, - "Parameters": { - "Intensity": 40, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2289, - "Parameters": { - "Intensity": 40, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2382, - "Parameters": { - "Intensity": 30, - "Frequency": 40 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 221, + "StartTime": 31, + "Parameters": { + "Intensity": 100, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 55, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 62, + "Intensity": 0.35, + "Frequency": -10 + }, + { + "Time": 154, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 221, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 49, + "Parameters": { + "Intensity": 100, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 588, + "Parameters": { + "Intensity": 50, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 240, + "StartTime": 692, + "Parameters": { + "Intensity": 80, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 60, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 67, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 168, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 240, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 712, + "Parameters": { + "Intensity": 80, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1073, + "Parameters": { + "Intensity": 40, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 220, + "StartTime": 1139, + "Parameters": { + "Intensity": 70, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 55, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 61, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 154, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 220, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1156, + "Parameters": { + "Intensity": 70, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1506, + "Parameters": { + "Intensity": 33, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 220, + "StartTime": 1569, + "Parameters": { + "Intensity": 60, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 55, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 61, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 154, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 220, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1586, + "Parameters": { + "Intensity": 60, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1851, + "Parameters": { + "Intensity": 25, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 169, + "StartTime": 1923, + "Parameters": { + "Intensity": 50, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 46, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 53, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 113, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 169, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1935, + "Parameters": { + "Intensity": 50, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2087, + "Parameters": { + "Intensity": 50, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2185, + "Parameters": { + "Intensity": 40, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2289, + "Parameters": { + "Intensity": 40, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2382, + "Parameters": { + "Intensity": 30, + "Frequency": 40 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_l.json index 83beb60d84..84e078c139 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_l.json @@ -1,362 +1,362 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 221, - "StartTime": 31, - "Parameters": { - "Intensity": 60, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 55, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 62, - "Intensity": 0.35, - "Frequency": -10 - }, - { - "Time": 154, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 221, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 49, - "Parameters": { - "Intensity": 60, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 588, - "Parameters": { - "Intensity": 30, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 240, - "StartTime": 692, - "Parameters": { - "Intensity": 48, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 60, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 67, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 168, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 240, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 712, - "Parameters": { - "Intensity": 48, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1073, - "Parameters": { - "Intensity": 24, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 220, - "StartTime": 1139, - "Parameters": { - "Intensity": 42, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 55, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 61, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 154, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 220, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1156, - "Parameters": { - "Intensity": 42, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1506, - "Parameters": { - "Intensity": 19, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 220, - "StartTime": 1569, - "Parameters": { - "Intensity": 36, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 55, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 61, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 154, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 220, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1586, - "Parameters": { - "Intensity": 36, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1851, - "Parameters": { - "Intensity": 15, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 169, - "StartTime": 1923, - "Parameters": { - "Intensity": 30, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 46, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 53, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 113, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 169, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1935, - "Parameters": { - "Intensity": 30, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2087, - "Parameters": { - "Intensity": 30, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2185, - "Parameters": { - "Intensity": 24, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2289, - "Parameters": { - "Intensity": 24, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2382, - "Parameters": { - "Intensity": 18, - "Frequency": 40 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 221, + "StartTime": 31, + "Parameters": { + "Intensity": 60, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 55, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 62, + "Intensity": 0.35, + "Frequency": -10 + }, + { + "Time": 154, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 221, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 49, + "Parameters": { + "Intensity": 60, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 588, + "Parameters": { + "Intensity": 30, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 240, + "StartTime": 692, + "Parameters": { + "Intensity": 48, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 60, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 67, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 168, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 240, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 712, + "Parameters": { + "Intensity": 48, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1073, + "Parameters": { + "Intensity": 24, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 220, + "StartTime": 1139, + "Parameters": { + "Intensity": 42, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 55, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 61, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 154, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 220, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1156, + "Parameters": { + "Intensity": 42, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1506, + "Parameters": { + "Intensity": 19, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 220, + "StartTime": 1569, + "Parameters": { + "Intensity": 36, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 55, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 61, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 154, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 220, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1586, + "Parameters": { + "Intensity": 36, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1851, + "Parameters": { + "Intensity": 15, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 169, + "StartTime": 1923, + "Parameters": { + "Intensity": 30, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 46, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 53, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 113, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 169, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1935, + "Parameters": { + "Intensity": 30, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2087, + "Parameters": { + "Intensity": 30, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2185, + "Parameters": { + "Intensity": 24, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2289, + "Parameters": { + "Intensity": 24, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2382, + "Parameters": { + "Intensity": 18, + "Frequency": 40 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_m.json index ecf43fafa5..f3827b5e6e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Basketball_m.json @@ -1,362 +1,362 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 221, - "StartTime": 31, - "Parameters": { - "Intensity": 80, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 55, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 62, - "Intensity": 0.35, - "Frequency": -10 - }, - { - "Time": 154, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 221, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 49, - "Parameters": { - "Intensity": 80, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 588, - "Parameters": { - "Intensity": 40, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 240, - "StartTime": 692, - "Parameters": { - "Intensity": 64, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 60, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 67, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 168, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 240, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 712, - "Parameters": { - "Intensity": 64, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1073, - "Parameters": { - "Intensity": 32, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 220, - "StartTime": 1139, - "Parameters": { - "Intensity": 56, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 55, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 61, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 154, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 220, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1156, - "Parameters": { - "Intensity": 56, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1506, - "Parameters": { - "Intensity": 26, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 220, - "StartTime": 1569, - "Parameters": { - "Intensity": 48, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 7, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 55, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 61, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 154, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 220, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1586, - "Parameters": { - "Intensity": 48, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1851, - "Parameters": { - "Intensity": 20, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 169, - "StartTime": 1923, - "Parameters": { - "Intensity": 40, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 46, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 53, - "Intensity": 0.36, - "Frequency": -10 - }, - { - "Time": 113, - "Intensity": 0.34, - "Frequency": -15 - }, - { - "Time": 169, - "Intensity": 0, - "Frequency": -10 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1935, - "Parameters": { - "Intensity": 40, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2087, - "Parameters": { - "Intensity": 40, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2185, - "Parameters": { - "Intensity": 32, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2289, - "Parameters": { - "Intensity": 32, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2382, - "Parameters": { - "Intensity": 24, - "Frequency": 40 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 221, + "StartTime": 31, + "Parameters": { + "Intensity": 80, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 55, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 62, + "Intensity": 0.35, + "Frequency": -10 + }, + { + "Time": 154, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 221, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 49, + "Parameters": { + "Intensity": 80, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 588, + "Parameters": { + "Intensity": 40, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 240, + "StartTime": 692, + "Parameters": { + "Intensity": 64, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 60, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 67, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 168, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 240, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 712, + "Parameters": { + "Intensity": 64, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1073, + "Parameters": { + "Intensity": 32, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 220, + "StartTime": 1139, + "Parameters": { + "Intensity": 56, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 55, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 61, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 154, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 220, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1156, + "Parameters": { + "Intensity": 56, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1506, + "Parameters": { + "Intensity": 26, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 220, + "StartTime": 1569, + "Parameters": { + "Intensity": 48, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 7, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 55, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 61, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 154, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 220, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1586, + "Parameters": { + "Intensity": 48, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1851, + "Parameters": { + "Intensity": 20, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 169, + "StartTime": 1923, + "Parameters": { + "Intensity": 40, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 46, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 53, + "Intensity": 0.36, + "Frequency": -10 + }, + { + "Time": 113, + "Intensity": 0.34, + "Frequency": -15 + }, + { + "Time": 169, + "Intensity": 0, + "Frequency": -10 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1935, + "Parameters": { + "Intensity": 40, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2087, + "Parameters": { + "Intensity": 40, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2185, + "Parameters": { + "Intensity": 32, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2289, + "Parameters": { + "Intensity": 32, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2382, + "Parameters": { + "Intensity": 24, + "Frequency": 40 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_h.json index 653a4f5d7b..25832cd2da 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_h.json @@ -1,116 +1,116 @@ -{ - "MetaData": { - "Create": "2021-02-23", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 260, - "StartTime": 0, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": -33 - }, - { - "Time": 44, - "Intensity": 1.0, - "Frequency": 63 - }, - { - "Time": 79, - "Intensity": 1.0, - "Frequency": -5 - }, - { - "Time": 260, - "Intensity": 0.0, - "Frequency": -14 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 597, - "StartTime": 265, - "Parameters": { - "Intensity": 81, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 81, - "Intensity": 1.0, - "Frequency": -45 - }, - { - "Time": 534, - "Intensity": 0.64, - "Frequency": -45 - }, - { - "Time": 597, - "Intensity": 0.0, - "Frequency": -14 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 597, - "StartTime": 867, - "Parameters": { - "Intensity": 63, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 81, - "Intensity": 1.0, - "Frequency": -45 - }, - { - "Time": 423, - "Intensity": 0.31, - "Frequency": -45 - }, - { - "Time": 597, - "Intensity": 0.0, - "Frequency": -14 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2021-02-23", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 260, + "StartTime": 0, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": -33 + }, + { + "Time": 44, + "Intensity": 1.0, + "Frequency": 63 + }, + { + "Time": 79, + "Intensity": 1.0, + "Frequency": -5 + }, + { + "Time": 260, + "Intensity": 0.0, + "Frequency": -14 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 597, + "StartTime": 265, + "Parameters": { + "Intensity": 81, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 81, + "Intensity": 1.0, + "Frequency": -45 + }, + { + "Time": 534, + "Intensity": 0.64, + "Frequency": -45 + }, + { + "Time": 597, + "Intensity": 0.0, + "Frequency": -14 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 597, + "StartTime": 867, + "Parameters": { + "Intensity": 63, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 81, + "Intensity": 1.0, + "Frequency": -45 + }, + { + "Time": 423, + "Intensity": 0.31, + "Frequency": -45 + }, + { + "Time": 597, + "Intensity": 0.0, + "Frequency": -14 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_l.json index d03f9261c5..fa30c08b58 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_l.json @@ -1,116 +1,116 @@ -{ - "MetaData": { - "Create": "2021-02-23", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 260, - "StartTime": 0, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": -33 - }, - { - "Time": 44, - "Intensity": 1.0, - "Frequency": 63 - }, - { - "Time": 79, - "Intensity": 1.0, - "Frequency": -5 - }, - { - "Time": 260, - "Intensity": 0.0, - "Frequency": -14 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 597, - "StartTime": 265, - "Parameters": { - "Intensity": 48, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 81, - "Intensity": 1.0, - "Frequency": -45 - }, - { - "Time": 534, - "Intensity": 0.64, - "Frequency": -45 - }, - { - "Time": 597, - "Intensity": 0.0, - "Frequency": -14 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 597, - "StartTime": 867, - "Parameters": { - "Intensity": 37, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 81, - "Intensity": 1.0, - "Frequency": -45 - }, - { - "Time": 423, - "Intensity": 0.31, - "Frequency": -45 - }, - { - "Time": 597, - "Intensity": 0.0, - "Frequency": -14 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2021-02-23", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 260, + "StartTime": 0, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": -33 + }, + { + "Time": 44, + "Intensity": 1.0, + "Frequency": 63 + }, + { + "Time": 79, + "Intensity": 1.0, + "Frequency": -5 + }, + { + "Time": 260, + "Intensity": 0.0, + "Frequency": -14 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 597, + "StartTime": 265, + "Parameters": { + "Intensity": 48, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 81, + "Intensity": 1.0, + "Frequency": -45 + }, + { + "Time": 534, + "Intensity": 0.64, + "Frequency": -45 + }, + { + "Time": 597, + "Intensity": 0.0, + "Frequency": -14 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 597, + "StartTime": 867, + "Parameters": { + "Intensity": 37, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 81, + "Intensity": 1.0, + "Frequency": -45 + }, + { + "Time": 423, + "Intensity": 0.31, + "Frequency": -45 + }, + { + "Time": 597, + "Intensity": 0.0, + "Frequency": -14 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_m.json index 8a2b86584f..66ca31f02a 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Blast_m.json @@ -1,116 +1,116 @@ -{ - "MetaData": { - "Create": "2021-02-23", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 260, - "StartTime": 0, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": -33 - }, - { - "Time": 44, - "Intensity": 1.0, - "Frequency": 63 - }, - { - "Time": 79, - "Intensity": 1.0, - "Frequency": -5 - }, - { - "Time": 260, - "Intensity": 0.0, - "Frequency": -14 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 597, - "StartTime": 265, - "Parameters": { - "Intensity": 64, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 81, - "Intensity": 1.0, - "Frequency": -45 - }, - { - "Time": 534, - "Intensity": 0.64, - "Frequency": -45 - }, - { - "Time": 597, - "Intensity": 0.0, - "Frequency": -14 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 597, - "StartTime": 867, - "Parameters": { - "Intensity": 50, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 81, - "Intensity": 1.0, - "Frequency": -45 - }, - { - "Time": 423, - "Intensity": 0.31, - "Frequency": -45 - }, - { - "Time": 597, - "Intensity": 0.0, - "Frequency": -14 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2021-02-23", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 260, + "StartTime": 0, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": -33 + }, + { + "Time": 44, + "Intensity": 1.0, + "Frequency": 63 + }, + { + "Time": 79, + "Intensity": 1.0, + "Frequency": -5 + }, + { + "Time": 260, + "Intensity": 0.0, + "Frequency": -14 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 597, + "StartTime": 265, + "Parameters": { + "Intensity": 64, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 81, + "Intensity": 1.0, + "Frequency": -45 + }, + { + "Time": 534, + "Intensity": 0.64, + "Frequency": -45 + }, + { + "Time": 597, + "Intensity": 0.0, + "Frequency": -14 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 597, + "StartTime": 867, + "Parameters": { + "Intensity": 50, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 81, + "Intensity": 1.0, + "Frequency": -45 + }, + { + "Time": 423, + "Intensity": 0.31, + "Frequency": -45 + }, + { + "Time": 597, + "Intensity": 0.0, + "Frequency": -14 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_h.json index cbc9e4a35f..a504caf382 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_h.json @@ -1,654 +1,654 @@ -{ - "MetaData": { - "Create": "2021-10-18", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 126, - "Parameters": { - "Intensity": 100, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 69.313 - }, - { - "Time": 26, - "Intensity": 0.21, - "Frequency": 69.313 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 67.3027 - }, - { - "Time": 60, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 102, - "Intensity": 1, - "Frequency": 27 - }, - { - "Time": 144, - "Intensity": 1, - "Frequency": 27 - }, - { - "Time": 167, - "Intensity": 0.36219, - "Frequency": 47.0092 - }, - { - "Time": 200, - "Intensity": 0.82, - "Frequency": 8 - }, - { - "Time": 233, - "Intensity": 0.18445, - "Frequency": 47.9644 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 47.9644 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 359, - "Parameters": { - "Intensity": 100, - "Frequency": 48, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 47.9644 - }, - { - "Time": 11, - "Intensity": 0.75, - "Frequency": 26 - }, - { - "Time": 67, - "Intensity": 0.40413, - "Frequency": 46.0884 - }, - { - "Time": 143, - "Intensity": 0.27, - "Frequency": 26.5024 - }, - { - "Time": 212, - "Intensity": 0.51, - "Frequency": 21.0208 - }, - { - "Time": 234, - "Intensity": 0.29322, - "Frequency": 20.638 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 23.1938 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 593, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20.638 - }, - { - "Time": 6, - "Intensity": 0.34, - "Frequency": 23.1938 - }, - { - "Time": 34, - "Intensity": 0.61, - "Frequency": 23.1944 - }, - { - "Time": 50, - "Intensity": 0.21961, - "Frequency": 23.1944 - }, - { - "Time": 109, - "Intensity": 0.42, - "Frequency": 8 - }, - { - "Time": 167, - "Intensity": 0.23, - "Frequency": 0 - }, - { - "Time": 233, - "Intensity": 0.14725, - "Frequency": 17.5734 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 14.3638 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 826, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 17.5734 - }, - { - "Time": 33, - "Intensity": 0.34455, - "Frequency": 13.7928 - }, - { - "Time": 83, - "Intensity": 0.17566, - "Frequency": 13.2156 - }, - { - "Time": 99, - "Intensity": 0.47, - "Frequency": 13.8843 - }, - { - "Time": 150, - "Intensity": 0.099891, - "Frequency": 16.2494 - }, - { - "Time": 167, - "Intensity": 0.54439, - "Frequency": 16.251 - }, - { - "Time": 183, - "Intensity": 0.20715, - "Frequency": 14.4624 - }, - { - "Time": 217, - "Intensity": 0.083533, - "Frequency": 15.2237 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 14.4596 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1059, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 15.0306 - }, - { - "Time": 17, - "Intensity": 0.24137, - "Frequency": 14.4596 - }, - { - "Time": 34, - "Intensity": 0.27653, - "Frequency": 14.7438 - }, - { - "Time": 50, - "Intensity": 0.24485, - "Frequency": 19.939 - }, - { - "Time": 67, - "Intensity": 0.20559, - "Frequency": 20.5117 - }, - { - "Time": 84, - "Intensity": 0.11978, - "Frequency": 20.3226 - }, - { - "Time": 100, - "Intensity": 0.32286, - "Frequency": 18.1331 - }, - { - "Time": 117, - "Intensity": 0.21612, - "Frequency": 18.1331 - }, - { - "Time": 134, - "Intensity": 0.49264, - "Frequency": 21.2452 - }, - { - "Time": 150, - "Intensity": 0.18907, - "Frequency": 18.3376 - }, - { - "Time": 167, - "Intensity": 0.14537, - "Frequency": 17.9806 - }, - { - "Time": 184, - "Intensity": 0.26344, - "Frequency": 17.1246 - }, - { - "Time": 200, - "Intensity": 0.35007, - "Frequency": 17.7879 - }, - { - "Time": 217, - "Intensity": 0.14297, - "Frequency": 14.3585 - }, - { - "Time": 234, - "Intensity": 0.21184, - "Frequency": 16.9936 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 15.7556 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1293, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 16.9936 - }, - { - "Time": 16, - "Intensity": 0.2691, - "Frequency": 15.7556 - }, - { - "Time": 33, - "Intensity": 0.1914, - "Frequency": 16.9983 - }, - { - "Time": 50, - "Intensity": 0.14346, - "Frequency": 16.6456 - }, - { - "Time": 66, - "Intensity": 0.093315, - "Frequency": 17.6002 - }, - { - "Time": 83, - "Intensity": 0.13911, - "Frequency": 17.031 - }, - { - "Time": 100, - "Intensity": 0.071573, - "Frequency": 15.6997 - }, - { - "Time": 116, - "Intensity": 0.36325, - "Frequency": 14.6485 - }, - { - "Time": 133, - "Intensity": 0.10331, - "Frequency": 15.2189 - }, - { - "Time": 150, - "Intensity": 0.081988, - "Frequency": 15.2189 - }, - { - "Time": 166, - "Intensity": 0.074824, - "Frequency": 15.4095 - }, - { - "Time": 183, - "Intensity": 0.045809, - "Frequency": 14.5488 - }, - { - "Time": 200, - "Intensity": 0.033725, - "Frequency": 14.6454 - }, - { - "Time": 216, - "Intensity": 0.089506, - "Frequency": 14.2635 - }, - { - "Time": 233, - "Intensity": 0.066092, - "Frequency": 14.743 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 14.27 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1526, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 14.743 - }, - { - "Time": 17, - "Intensity": 0.085394, - "Frequency": 14.27 - }, - { - "Time": 33, - "Intensity": 0.029442, - "Frequency": 13.9832 - }, - { - "Time": 50, - "Intensity": 0.020521, - "Frequency": 16.1406 - }, - { - "Time": 67, - "Intensity": 0.05142, - "Frequency": 16.5194 - }, - { - "Time": 83, - "Intensity": 0.026311, - "Frequency": 16.6157 - }, - { - "Time": 100, - "Intensity": 0.017077, - "Frequency": 17.2985 - }, - { - "Time": 117, - "Intensity": 0.017877, - "Frequency": 16.7269 - }, - { - "Time": 133, - "Intensity": 0.004579, - "Frequency": 18.9123 - }, - { - "Time": 150, - "Intensity": 0.015018, - "Frequency": 18.3264 - }, - { - "Time": 167, - "Intensity": 0.0063699, - "Frequency": 19.3763 - }, - { - "Time": 183, - "Intensity": 0.003663, - "Frequency": 19.3763 - }, - { - "Time": 200, - "Intensity": 0.0042855, - "Frequency": 3.7525 - }, - { - "Time": 217, - "Intensity": 0.0021302, - "Frequency": 3.847 - }, - { - "Time": 233, - "Intensity": 0.0078309, - "Frequency": 6.7964 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 7.1782 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1759, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 6.7964 - }, - { - "Time": 17, - "Intensity": 0.0035206, - "Frequency": 7.1782 - }, - { - "Time": 34, - "Intensity": 0.0011543, - "Frequency": 6.7993 - }, - { - "Time": 50, - "Intensity": 0.0022953, - "Frequency": 7.3322 - }, - { - "Time": 67, - "Intensity": 0.003826, - "Frequency": 12.0493 - }, - { - "Time": 84, - "Intensity": 0.0012973, - "Frequency": 16.6841 - }, - { - "Time": 100, - "Intensity": 0.0021943, - "Frequency": 20.0356 - }, - { - "Time": 117, - "Intensity": 0.0025446, - "Frequency": 17.6828 - }, - { - "Time": 134, - "Intensity": 0.0013369, - "Frequency": 13.7097 - }, - { - "Time": 150, - "Intensity": 0.00056959, - "Frequency": 7.8294 - }, - { - "Time": 167, - "Intensity": 0.00094861, - "Frequency": 0 - }, - { - "Time": 184, - "Intensity": 0.00058555, - "Frequency": 1 - }, - { - "Time": 200, - "Intensity": 0.00044257, - "Frequency": 3.5058 - }, - { - "Time": 217, - "Intensity": 0.00034451, - "Frequency": 3.5058 - }, - { - "Time": 234, - "Intensity": 0.00010188, - "Frequency": 6.3945 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 5.4841 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 75, - "StartTime": 1993, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 6.3945 - }, - { - "Time": 16, - "Intensity": 5.9868e-05, - "Frequency": 5.4841 - }, - { - "Time": 33, - "Intensity": 6.1123e-05, - "Frequency": 5.4841 - }, - { - "Time": 50, - "Intensity": 1.8783e-05, - "Frequency": 9.5255 - }, - { - "Time": 66, - "Intensity": 5.7126e-06, - "Frequency": 15.0855 - }, - { - "Time": 75, - "Intensity": 0, - "Frequency": 17.5105 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2021-10-18", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 126, + "Parameters": { + "Intensity": 100, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 69.313 + }, + { + "Time": 26, + "Intensity": 0.21, + "Frequency": 69.313 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 67.3027 + }, + { + "Time": 60, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 102, + "Intensity": 1, + "Frequency": 27 + }, + { + "Time": 144, + "Intensity": 1, + "Frequency": 27 + }, + { + "Time": 167, + "Intensity": 0.36219, + "Frequency": 47.0092 + }, + { + "Time": 200, + "Intensity": 0.82, + "Frequency": 8 + }, + { + "Time": 233, + "Intensity": 0.18445, + "Frequency": 47.9644 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 47.9644 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 359, + "Parameters": { + "Intensity": 100, + "Frequency": 48, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 47.9644 + }, + { + "Time": 11, + "Intensity": 0.75, + "Frequency": 26 + }, + { + "Time": 67, + "Intensity": 0.40413, + "Frequency": 46.0884 + }, + { + "Time": 143, + "Intensity": 0.27, + "Frequency": 26.5024 + }, + { + "Time": 212, + "Intensity": 0.51, + "Frequency": 21.0208 + }, + { + "Time": 234, + "Intensity": 0.29322, + "Frequency": 20.638 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 23.1938 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 593, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20.638 + }, + { + "Time": 6, + "Intensity": 0.34, + "Frequency": 23.1938 + }, + { + "Time": 34, + "Intensity": 0.61, + "Frequency": 23.1944 + }, + { + "Time": 50, + "Intensity": 0.21961, + "Frequency": 23.1944 + }, + { + "Time": 109, + "Intensity": 0.42, + "Frequency": 8 + }, + { + "Time": 167, + "Intensity": 0.23, + "Frequency": 0 + }, + { + "Time": 233, + "Intensity": 0.14725, + "Frequency": 17.5734 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 14.3638 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 826, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 17.5734 + }, + { + "Time": 33, + "Intensity": 0.34455, + "Frequency": 13.7928 + }, + { + "Time": 83, + "Intensity": 0.17566, + "Frequency": 13.2156 + }, + { + "Time": 99, + "Intensity": 0.47, + "Frequency": 13.8843 + }, + { + "Time": 150, + "Intensity": 0.099891, + "Frequency": 16.2494 + }, + { + "Time": 167, + "Intensity": 0.54439, + "Frequency": 16.251 + }, + { + "Time": 183, + "Intensity": 0.20715, + "Frequency": 14.4624 + }, + { + "Time": 217, + "Intensity": 0.083533, + "Frequency": 15.2237 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 14.4596 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1059, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 15.0306 + }, + { + "Time": 17, + "Intensity": 0.24137, + "Frequency": 14.4596 + }, + { + "Time": 34, + "Intensity": 0.27653, + "Frequency": 14.7438 + }, + { + "Time": 50, + "Intensity": 0.24485, + "Frequency": 19.939 + }, + { + "Time": 67, + "Intensity": 0.20559, + "Frequency": 20.5117 + }, + { + "Time": 84, + "Intensity": 0.11978, + "Frequency": 20.3226 + }, + { + "Time": 100, + "Intensity": 0.32286, + "Frequency": 18.1331 + }, + { + "Time": 117, + "Intensity": 0.21612, + "Frequency": 18.1331 + }, + { + "Time": 134, + "Intensity": 0.49264, + "Frequency": 21.2452 + }, + { + "Time": 150, + "Intensity": 0.18907, + "Frequency": 18.3376 + }, + { + "Time": 167, + "Intensity": 0.14537, + "Frequency": 17.9806 + }, + { + "Time": 184, + "Intensity": 0.26344, + "Frequency": 17.1246 + }, + { + "Time": 200, + "Intensity": 0.35007, + "Frequency": 17.7879 + }, + { + "Time": 217, + "Intensity": 0.14297, + "Frequency": 14.3585 + }, + { + "Time": 234, + "Intensity": 0.21184, + "Frequency": 16.9936 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 15.7556 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1293, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 16.9936 + }, + { + "Time": 16, + "Intensity": 0.2691, + "Frequency": 15.7556 + }, + { + "Time": 33, + "Intensity": 0.1914, + "Frequency": 16.9983 + }, + { + "Time": 50, + "Intensity": 0.14346, + "Frequency": 16.6456 + }, + { + "Time": 66, + "Intensity": 0.093315, + "Frequency": 17.6002 + }, + { + "Time": 83, + "Intensity": 0.13911, + "Frequency": 17.031 + }, + { + "Time": 100, + "Intensity": 0.071573, + "Frequency": 15.6997 + }, + { + "Time": 116, + "Intensity": 0.36325, + "Frequency": 14.6485 + }, + { + "Time": 133, + "Intensity": 0.10331, + "Frequency": 15.2189 + }, + { + "Time": 150, + "Intensity": 0.081988, + "Frequency": 15.2189 + }, + { + "Time": 166, + "Intensity": 0.074824, + "Frequency": 15.4095 + }, + { + "Time": 183, + "Intensity": 0.045809, + "Frequency": 14.5488 + }, + { + "Time": 200, + "Intensity": 0.033725, + "Frequency": 14.6454 + }, + { + "Time": 216, + "Intensity": 0.089506, + "Frequency": 14.2635 + }, + { + "Time": 233, + "Intensity": 0.066092, + "Frequency": 14.743 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 14.27 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1526, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 14.743 + }, + { + "Time": 17, + "Intensity": 0.085394, + "Frequency": 14.27 + }, + { + "Time": 33, + "Intensity": 0.029442, + "Frequency": 13.9832 + }, + { + "Time": 50, + "Intensity": 0.020521, + "Frequency": 16.1406 + }, + { + "Time": 67, + "Intensity": 0.05142, + "Frequency": 16.5194 + }, + { + "Time": 83, + "Intensity": 0.026311, + "Frequency": 16.6157 + }, + { + "Time": 100, + "Intensity": 0.017077, + "Frequency": 17.2985 + }, + { + "Time": 117, + "Intensity": 0.017877, + "Frequency": 16.7269 + }, + { + "Time": 133, + "Intensity": 0.004579, + "Frequency": 18.9123 + }, + { + "Time": 150, + "Intensity": 0.015018, + "Frequency": 18.3264 + }, + { + "Time": 167, + "Intensity": 0.0063699, + "Frequency": 19.3763 + }, + { + "Time": 183, + "Intensity": 0.003663, + "Frequency": 19.3763 + }, + { + "Time": 200, + "Intensity": 0.0042855, + "Frequency": 3.7525 + }, + { + "Time": 217, + "Intensity": 0.0021302, + "Frequency": 3.847 + }, + { + "Time": 233, + "Intensity": 0.0078309, + "Frequency": 6.7964 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 7.1782 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1759, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 6.7964 + }, + { + "Time": 17, + "Intensity": 0.0035206, + "Frequency": 7.1782 + }, + { + "Time": 34, + "Intensity": 0.0011543, + "Frequency": 6.7993 + }, + { + "Time": 50, + "Intensity": 0.0022953, + "Frequency": 7.3322 + }, + { + "Time": 67, + "Intensity": 0.003826, + "Frequency": 12.0493 + }, + { + "Time": 84, + "Intensity": 0.0012973, + "Frequency": 16.6841 + }, + { + "Time": 100, + "Intensity": 0.0021943, + "Frequency": 20.0356 + }, + { + "Time": 117, + "Intensity": 0.0025446, + "Frequency": 17.6828 + }, + { + "Time": 134, + "Intensity": 0.0013369, + "Frequency": 13.7097 + }, + { + "Time": 150, + "Intensity": 0.00056959, + "Frequency": 7.8294 + }, + { + "Time": 167, + "Intensity": 0.00094861, + "Frequency": 0 + }, + { + "Time": 184, + "Intensity": 0.00058555, + "Frequency": 1 + }, + { + "Time": 200, + "Intensity": 0.00044257, + "Frequency": 3.5058 + }, + { + "Time": 217, + "Intensity": 0.00034451, + "Frequency": 3.5058 + }, + { + "Time": 234, + "Intensity": 0.00010188, + "Frequency": 6.3945 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 5.4841 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 75, + "StartTime": 1993, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 6.3945 + }, + { + "Time": 16, + "Intensity": 5.9868e-05, + "Frequency": 5.4841 + }, + { + "Time": 33, + "Intensity": 6.1123e-05, + "Frequency": 5.4841 + }, + { + "Time": 50, + "Intensity": 1.8783e-05, + "Frequency": 9.5255 + }, + { + "Time": 66, + "Intensity": 5.7126e-06, + "Frequency": 15.0855 + }, + { + "Time": 75, + "Intensity": 0, + "Frequency": 17.5105 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_l.json index dfdf7d5fc2..96410b5b05 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_l.json @@ -1,654 +1,654 @@ -{ - "MetaData": { - "Create": "2021-10-18", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 126, - "Parameters": { - "Intensity": 60, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 69.313 - }, - { - "Time": 26, - "Intensity": 0.21, - "Frequency": 69.313 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 67.3027 - }, - { - "Time": 60, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 102, - "Intensity": 1, - "Frequency": 27 - }, - { - "Time": 144, - "Intensity": 1, - "Frequency": 27 - }, - { - "Time": 167, - "Intensity": 0.36219, - "Frequency": 47.0092 - }, - { - "Time": 200, - "Intensity": 0.82, - "Frequency": 8 - }, - { - "Time": 233, - "Intensity": 0.18445, - "Frequency": 47.9644 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 47.9644 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 359, - "Parameters": { - "Intensity": 60, - "Frequency": 48, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 47.9644 - }, - { - "Time": 11, - "Intensity": 0.75, - "Frequency": 26 - }, - { - "Time": 67, - "Intensity": 0.40413, - "Frequency": 46.0884 - }, - { - "Time": 143, - "Intensity": 0.27, - "Frequency": 26.5024 - }, - { - "Time": 212, - "Intensity": 0.51, - "Frequency": 21.0208 - }, - { - "Time": 234, - "Intensity": 0.29322, - "Frequency": 20.638 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 23.1938 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 593, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20.638 - }, - { - "Time": 6, - "Intensity": 0.34, - "Frequency": 23.1938 - }, - { - "Time": 34, - "Intensity": 0.61, - "Frequency": 23.1944 - }, - { - "Time": 50, - "Intensity": 0.21961, - "Frequency": 23.1944 - }, - { - "Time": 109, - "Intensity": 0.42, - "Frequency": 8 - }, - { - "Time": 167, - "Intensity": 0.23, - "Frequency": 0 - }, - { - "Time": 233, - "Intensity": 0.14725, - "Frequency": 17.5734 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 14.3638 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 826, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 17.5734 - }, - { - "Time": 33, - "Intensity": 0.34455, - "Frequency": 13.7928 - }, - { - "Time": 83, - "Intensity": 0.17566, - "Frequency": 13.2156 - }, - { - "Time": 99, - "Intensity": 0.47, - "Frequency": 13.8843 - }, - { - "Time": 150, - "Intensity": 0.099891, - "Frequency": 16.2494 - }, - { - "Time": 167, - "Intensity": 0.54439, - "Frequency": 16.251 - }, - { - "Time": 183, - "Intensity": 0.20715, - "Frequency": 14.4624 - }, - { - "Time": 217, - "Intensity": 0.083533, - "Frequency": 15.2237 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 14.4596 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1059, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 15.0306 - }, - { - "Time": 17, - "Intensity": 0.24137, - "Frequency": 14.4596 - }, - { - "Time": 34, - "Intensity": 0.27653, - "Frequency": 14.7438 - }, - { - "Time": 50, - "Intensity": 0.24485, - "Frequency": 19.939 - }, - { - "Time": 67, - "Intensity": 0.20559, - "Frequency": 20.5117 - }, - { - "Time": 84, - "Intensity": 0.11978, - "Frequency": 20.3226 - }, - { - "Time": 100, - "Intensity": 0.32286, - "Frequency": 18.1331 - }, - { - "Time": 117, - "Intensity": 0.21612, - "Frequency": 18.1331 - }, - { - "Time": 134, - "Intensity": 0.49264, - "Frequency": 21.2452 - }, - { - "Time": 150, - "Intensity": 0.18907, - "Frequency": 18.3376 - }, - { - "Time": 167, - "Intensity": 0.14537, - "Frequency": 17.9806 - }, - { - "Time": 184, - "Intensity": 0.26344, - "Frequency": 17.1246 - }, - { - "Time": 200, - "Intensity": 0.35007, - "Frequency": 17.7879 - }, - { - "Time": 217, - "Intensity": 0.14297, - "Frequency": 14.3585 - }, - { - "Time": 234, - "Intensity": 0.21184, - "Frequency": 16.9936 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 15.7556 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1293, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 16.9936 - }, - { - "Time": 16, - "Intensity": 0.2691, - "Frequency": 15.7556 - }, - { - "Time": 33, - "Intensity": 0.1914, - "Frequency": 16.9983 - }, - { - "Time": 50, - "Intensity": 0.14346, - "Frequency": 16.6456 - }, - { - "Time": 66, - "Intensity": 0.093315, - "Frequency": 17.6002 - }, - { - "Time": 83, - "Intensity": 0.13911, - "Frequency": 17.031 - }, - { - "Time": 100, - "Intensity": 0.071573, - "Frequency": 15.6997 - }, - { - "Time": 116, - "Intensity": 0.36325, - "Frequency": 14.6485 - }, - { - "Time": 133, - "Intensity": 0.10331, - "Frequency": 15.2189 - }, - { - "Time": 150, - "Intensity": 0.081988, - "Frequency": 15.2189 - }, - { - "Time": 166, - "Intensity": 0.074824, - "Frequency": 15.4095 - }, - { - "Time": 183, - "Intensity": 0.045809, - "Frequency": 14.5488 - }, - { - "Time": 200, - "Intensity": 0.033725, - "Frequency": 14.6454 - }, - { - "Time": 216, - "Intensity": 0.089506, - "Frequency": 14.2635 - }, - { - "Time": 233, - "Intensity": 0.066092, - "Frequency": 14.743 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 14.27 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1526, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 14.743 - }, - { - "Time": 17, - "Intensity": 0.085394, - "Frequency": 14.27 - }, - { - "Time": 33, - "Intensity": 0.029442, - "Frequency": 13.9832 - }, - { - "Time": 50, - "Intensity": 0.020521, - "Frequency": 16.1406 - }, - { - "Time": 67, - "Intensity": 0.05142, - "Frequency": 16.5194 - }, - { - "Time": 83, - "Intensity": 0.026311, - "Frequency": 16.6157 - }, - { - "Time": 100, - "Intensity": 0.017077, - "Frequency": 17.2985 - }, - { - "Time": 117, - "Intensity": 0.017877, - "Frequency": 16.7269 - }, - { - "Time": 133, - "Intensity": 0.004579, - "Frequency": 18.9123 - }, - { - "Time": 150, - "Intensity": 0.015018, - "Frequency": 18.3264 - }, - { - "Time": 167, - "Intensity": 0.0063699, - "Frequency": 19.3763 - }, - { - "Time": 183, - "Intensity": 0.003663, - "Frequency": 19.3763 - }, - { - "Time": 200, - "Intensity": 0.0042855, - "Frequency": 3.7525 - }, - { - "Time": 217, - "Intensity": 0.0021302, - "Frequency": 3.847 - }, - { - "Time": 233, - "Intensity": 0.0078309, - "Frequency": 6.7964 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 7.1782 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1759, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 6.7964 - }, - { - "Time": 17, - "Intensity": 0.0035206, - "Frequency": 7.1782 - }, - { - "Time": 34, - "Intensity": 0.0011543, - "Frequency": 6.7993 - }, - { - "Time": 50, - "Intensity": 0.0022953, - "Frequency": 7.3322 - }, - { - "Time": 67, - "Intensity": 0.003826, - "Frequency": 12.0493 - }, - { - "Time": 84, - "Intensity": 0.0012973, - "Frequency": 16.6841 - }, - { - "Time": 100, - "Intensity": 0.0021943, - "Frequency": 20.0356 - }, - { - "Time": 117, - "Intensity": 0.0025446, - "Frequency": 17.6828 - }, - { - "Time": 134, - "Intensity": 0.0013369, - "Frequency": 13.7097 - }, - { - "Time": 150, - "Intensity": 0.00056959, - "Frequency": 7.8294 - }, - { - "Time": 167, - "Intensity": 0.00094861, - "Frequency": 0 - }, - { - "Time": 184, - "Intensity": 0.00058555, - "Frequency": 1 - }, - { - "Time": 200, - "Intensity": 0.00044257, - "Frequency": 3.5058 - }, - { - "Time": 217, - "Intensity": 0.00034451, - "Frequency": 3.5058 - }, - { - "Time": 234, - "Intensity": 0.00010188, - "Frequency": 6.3945 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 5.4841 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 75, - "StartTime": 1993, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 6.3945 - }, - { - "Time": 16, - "Intensity": 5.9868e-05, - "Frequency": 5.4841 - }, - { - "Time": 33, - "Intensity": 6.1123e-05, - "Frequency": 5.4841 - }, - { - "Time": 50, - "Intensity": 1.8783e-05, - "Frequency": 9.5255 - }, - { - "Time": 66, - "Intensity": 5.7126e-06, - "Frequency": 15.0855 - }, - { - "Time": 75, - "Intensity": 0, - "Frequency": 17.5105 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2021-10-18", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 126, + "Parameters": { + "Intensity": 60, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 69.313 + }, + { + "Time": 26, + "Intensity": 0.21, + "Frequency": 69.313 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 67.3027 + }, + { + "Time": 60, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 102, + "Intensity": 1, + "Frequency": 27 + }, + { + "Time": 144, + "Intensity": 1, + "Frequency": 27 + }, + { + "Time": 167, + "Intensity": 0.36219, + "Frequency": 47.0092 + }, + { + "Time": 200, + "Intensity": 0.82, + "Frequency": 8 + }, + { + "Time": 233, + "Intensity": 0.18445, + "Frequency": 47.9644 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 47.9644 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 359, + "Parameters": { + "Intensity": 60, + "Frequency": 48, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 47.9644 + }, + { + "Time": 11, + "Intensity": 0.75, + "Frequency": 26 + }, + { + "Time": 67, + "Intensity": 0.40413, + "Frequency": 46.0884 + }, + { + "Time": 143, + "Intensity": 0.27, + "Frequency": 26.5024 + }, + { + "Time": 212, + "Intensity": 0.51, + "Frequency": 21.0208 + }, + { + "Time": 234, + "Intensity": 0.29322, + "Frequency": 20.638 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 23.1938 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 593, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20.638 + }, + { + "Time": 6, + "Intensity": 0.34, + "Frequency": 23.1938 + }, + { + "Time": 34, + "Intensity": 0.61, + "Frequency": 23.1944 + }, + { + "Time": 50, + "Intensity": 0.21961, + "Frequency": 23.1944 + }, + { + "Time": 109, + "Intensity": 0.42, + "Frequency": 8 + }, + { + "Time": 167, + "Intensity": 0.23, + "Frequency": 0 + }, + { + "Time": 233, + "Intensity": 0.14725, + "Frequency": 17.5734 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 14.3638 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 826, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 17.5734 + }, + { + "Time": 33, + "Intensity": 0.34455, + "Frequency": 13.7928 + }, + { + "Time": 83, + "Intensity": 0.17566, + "Frequency": 13.2156 + }, + { + "Time": 99, + "Intensity": 0.47, + "Frequency": 13.8843 + }, + { + "Time": 150, + "Intensity": 0.099891, + "Frequency": 16.2494 + }, + { + "Time": 167, + "Intensity": 0.54439, + "Frequency": 16.251 + }, + { + "Time": 183, + "Intensity": 0.20715, + "Frequency": 14.4624 + }, + { + "Time": 217, + "Intensity": 0.083533, + "Frequency": 15.2237 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 14.4596 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1059, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 15.0306 + }, + { + "Time": 17, + "Intensity": 0.24137, + "Frequency": 14.4596 + }, + { + "Time": 34, + "Intensity": 0.27653, + "Frequency": 14.7438 + }, + { + "Time": 50, + "Intensity": 0.24485, + "Frequency": 19.939 + }, + { + "Time": 67, + "Intensity": 0.20559, + "Frequency": 20.5117 + }, + { + "Time": 84, + "Intensity": 0.11978, + "Frequency": 20.3226 + }, + { + "Time": 100, + "Intensity": 0.32286, + "Frequency": 18.1331 + }, + { + "Time": 117, + "Intensity": 0.21612, + "Frequency": 18.1331 + }, + { + "Time": 134, + "Intensity": 0.49264, + "Frequency": 21.2452 + }, + { + "Time": 150, + "Intensity": 0.18907, + "Frequency": 18.3376 + }, + { + "Time": 167, + "Intensity": 0.14537, + "Frequency": 17.9806 + }, + { + "Time": 184, + "Intensity": 0.26344, + "Frequency": 17.1246 + }, + { + "Time": 200, + "Intensity": 0.35007, + "Frequency": 17.7879 + }, + { + "Time": 217, + "Intensity": 0.14297, + "Frequency": 14.3585 + }, + { + "Time": 234, + "Intensity": 0.21184, + "Frequency": 16.9936 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 15.7556 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1293, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 16.9936 + }, + { + "Time": 16, + "Intensity": 0.2691, + "Frequency": 15.7556 + }, + { + "Time": 33, + "Intensity": 0.1914, + "Frequency": 16.9983 + }, + { + "Time": 50, + "Intensity": 0.14346, + "Frequency": 16.6456 + }, + { + "Time": 66, + "Intensity": 0.093315, + "Frequency": 17.6002 + }, + { + "Time": 83, + "Intensity": 0.13911, + "Frequency": 17.031 + }, + { + "Time": 100, + "Intensity": 0.071573, + "Frequency": 15.6997 + }, + { + "Time": 116, + "Intensity": 0.36325, + "Frequency": 14.6485 + }, + { + "Time": 133, + "Intensity": 0.10331, + "Frequency": 15.2189 + }, + { + "Time": 150, + "Intensity": 0.081988, + "Frequency": 15.2189 + }, + { + "Time": 166, + "Intensity": 0.074824, + "Frequency": 15.4095 + }, + { + "Time": 183, + "Intensity": 0.045809, + "Frequency": 14.5488 + }, + { + "Time": 200, + "Intensity": 0.033725, + "Frequency": 14.6454 + }, + { + "Time": 216, + "Intensity": 0.089506, + "Frequency": 14.2635 + }, + { + "Time": 233, + "Intensity": 0.066092, + "Frequency": 14.743 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 14.27 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1526, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 14.743 + }, + { + "Time": 17, + "Intensity": 0.085394, + "Frequency": 14.27 + }, + { + "Time": 33, + "Intensity": 0.029442, + "Frequency": 13.9832 + }, + { + "Time": 50, + "Intensity": 0.020521, + "Frequency": 16.1406 + }, + { + "Time": 67, + "Intensity": 0.05142, + "Frequency": 16.5194 + }, + { + "Time": 83, + "Intensity": 0.026311, + "Frequency": 16.6157 + }, + { + "Time": 100, + "Intensity": 0.017077, + "Frequency": 17.2985 + }, + { + "Time": 117, + "Intensity": 0.017877, + "Frequency": 16.7269 + }, + { + "Time": 133, + "Intensity": 0.004579, + "Frequency": 18.9123 + }, + { + "Time": 150, + "Intensity": 0.015018, + "Frequency": 18.3264 + }, + { + "Time": 167, + "Intensity": 0.0063699, + "Frequency": 19.3763 + }, + { + "Time": 183, + "Intensity": 0.003663, + "Frequency": 19.3763 + }, + { + "Time": 200, + "Intensity": 0.0042855, + "Frequency": 3.7525 + }, + { + "Time": 217, + "Intensity": 0.0021302, + "Frequency": 3.847 + }, + { + "Time": 233, + "Intensity": 0.0078309, + "Frequency": 6.7964 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 7.1782 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1759, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 6.7964 + }, + { + "Time": 17, + "Intensity": 0.0035206, + "Frequency": 7.1782 + }, + { + "Time": 34, + "Intensity": 0.0011543, + "Frequency": 6.7993 + }, + { + "Time": 50, + "Intensity": 0.0022953, + "Frequency": 7.3322 + }, + { + "Time": 67, + "Intensity": 0.003826, + "Frequency": 12.0493 + }, + { + "Time": 84, + "Intensity": 0.0012973, + "Frequency": 16.6841 + }, + { + "Time": 100, + "Intensity": 0.0021943, + "Frequency": 20.0356 + }, + { + "Time": 117, + "Intensity": 0.0025446, + "Frequency": 17.6828 + }, + { + "Time": 134, + "Intensity": 0.0013369, + "Frequency": 13.7097 + }, + { + "Time": 150, + "Intensity": 0.00056959, + "Frequency": 7.8294 + }, + { + "Time": 167, + "Intensity": 0.00094861, + "Frequency": 0 + }, + { + "Time": 184, + "Intensity": 0.00058555, + "Frequency": 1 + }, + { + "Time": 200, + "Intensity": 0.00044257, + "Frequency": 3.5058 + }, + { + "Time": 217, + "Intensity": 0.00034451, + "Frequency": 3.5058 + }, + { + "Time": 234, + "Intensity": 0.00010188, + "Frequency": 6.3945 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 5.4841 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 75, + "StartTime": 1993, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 6.3945 + }, + { + "Time": 16, + "Intensity": 5.9868e-05, + "Frequency": 5.4841 + }, + { + "Time": 33, + "Intensity": 6.1123e-05, + "Frequency": 5.4841 + }, + { + "Time": 50, + "Intensity": 1.8783e-05, + "Frequency": 9.5255 + }, + { + "Time": 66, + "Intensity": 5.7126e-06, + "Frequency": 15.0855 + }, + { + "Time": 75, + "Intensity": 0, + "Frequency": 17.5105 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_m.json index 19d73876bd..f6a274394a 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Bomb_m.json @@ -1,654 +1,654 @@ -{ - "MetaData": { - "Create": "2021-10-18", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 126, - "Parameters": { - "Intensity": 80, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 69.313 - }, - { - "Time": 26, - "Intensity": 0.21, - "Frequency": 69.313 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 67.3027 - }, - { - "Time": 60, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 102, - "Intensity": 1, - "Frequency": 27 - }, - { - "Time": 144, - "Intensity": 1, - "Frequency": 27 - }, - { - "Time": 167, - "Intensity": 0.36219, - "Frequency": 47.0092 - }, - { - "Time": 200, - "Intensity": 0.82, - "Frequency": 8 - }, - { - "Time": 233, - "Intensity": 0.18445, - "Frequency": 47.9644 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 47.9644 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 359, - "Parameters": { - "Intensity": 80, - "Frequency": 48, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 47.9644 - }, - { - "Time": 11, - "Intensity": 0.75, - "Frequency": 26 - }, - { - "Time": 67, - "Intensity": 0.40413, - "Frequency": 46.0884 - }, - { - "Time": 143, - "Intensity": 0.27, - "Frequency": 26.5024 - }, - { - "Time": 212, - "Intensity": 0.51, - "Frequency": 21.0208 - }, - { - "Time": 234, - "Intensity": 0.29322, - "Frequency": 20.638 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 23.1938 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 593, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20.638 - }, - { - "Time": 6, - "Intensity": 0.34, - "Frequency": 23.1938 - }, - { - "Time": 34, - "Intensity": 0.61, - "Frequency": 23.1944 - }, - { - "Time": 50, - "Intensity": 0.21961, - "Frequency": 23.1944 - }, - { - "Time": 109, - "Intensity": 0.42, - "Frequency": 8 - }, - { - "Time": 167, - "Intensity": 0.23, - "Frequency": 0 - }, - { - "Time": 233, - "Intensity": 0.14725, - "Frequency": 17.5734 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 14.3638 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 826, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 17.5734 - }, - { - "Time": 33, - "Intensity": 0.34455, - "Frequency": 13.7928 - }, - { - "Time": 83, - "Intensity": 0.17566, - "Frequency": 13.2156 - }, - { - "Time": 99, - "Intensity": 0.47, - "Frequency": 13.8843 - }, - { - "Time": 150, - "Intensity": 0.099891, - "Frequency": 16.2494 - }, - { - "Time": 167, - "Intensity": 0.54439, - "Frequency": 16.251 - }, - { - "Time": 183, - "Intensity": 0.20715, - "Frequency": 14.4624 - }, - { - "Time": 217, - "Intensity": 0.083533, - "Frequency": 15.2237 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 14.4596 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1059, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 15.0306 - }, - { - "Time": 17, - "Intensity": 0.24137, - "Frequency": 14.4596 - }, - { - "Time": 34, - "Intensity": 0.27653, - "Frequency": 14.7438 - }, - { - "Time": 50, - "Intensity": 0.24485, - "Frequency": 19.939 - }, - { - "Time": 67, - "Intensity": 0.20559, - "Frequency": 20.5117 - }, - { - "Time": 84, - "Intensity": 0.11978, - "Frequency": 20.3226 - }, - { - "Time": 100, - "Intensity": 0.32286, - "Frequency": 18.1331 - }, - { - "Time": 117, - "Intensity": 0.21612, - "Frequency": 18.1331 - }, - { - "Time": 134, - "Intensity": 0.49264, - "Frequency": 21.2452 - }, - { - "Time": 150, - "Intensity": 0.18907, - "Frequency": 18.3376 - }, - { - "Time": 167, - "Intensity": 0.14537, - "Frequency": 17.9806 - }, - { - "Time": 184, - "Intensity": 0.26344, - "Frequency": 17.1246 - }, - { - "Time": 200, - "Intensity": 0.35007, - "Frequency": 17.7879 - }, - { - "Time": 217, - "Intensity": 0.14297, - "Frequency": 14.3585 - }, - { - "Time": 234, - "Intensity": 0.21184, - "Frequency": 16.9936 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 15.7556 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1293, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 16.9936 - }, - { - "Time": 16, - "Intensity": 0.2691, - "Frequency": 15.7556 - }, - { - "Time": 33, - "Intensity": 0.1914, - "Frequency": 16.9983 - }, - { - "Time": 50, - "Intensity": 0.14346, - "Frequency": 16.6456 - }, - { - "Time": 66, - "Intensity": 0.093315, - "Frequency": 17.6002 - }, - { - "Time": 83, - "Intensity": 0.13911, - "Frequency": 17.031 - }, - { - "Time": 100, - "Intensity": 0.071573, - "Frequency": 15.6997 - }, - { - "Time": 116, - "Intensity": 0.36325, - "Frequency": 14.6485 - }, - { - "Time": 133, - "Intensity": 0.10331, - "Frequency": 15.2189 - }, - { - "Time": 150, - "Intensity": 0.081988, - "Frequency": 15.2189 - }, - { - "Time": 166, - "Intensity": 0.074824, - "Frequency": 15.4095 - }, - { - "Time": 183, - "Intensity": 0.045809, - "Frequency": 14.5488 - }, - { - "Time": 200, - "Intensity": 0.033725, - "Frequency": 14.6454 - }, - { - "Time": 216, - "Intensity": 0.089506, - "Frequency": 14.2635 - }, - { - "Time": 233, - "Intensity": 0.066092, - "Frequency": 14.743 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 14.27 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1526, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 14.743 - }, - { - "Time": 17, - "Intensity": 0.085394, - "Frequency": 14.27 - }, - { - "Time": 33, - "Intensity": 0.029442, - "Frequency": 13.9832 - }, - { - "Time": 50, - "Intensity": 0.020521, - "Frequency": 16.1406 - }, - { - "Time": 67, - "Intensity": 0.05142, - "Frequency": 16.5194 - }, - { - "Time": 83, - "Intensity": 0.026311, - "Frequency": 16.6157 - }, - { - "Time": 100, - "Intensity": 0.017077, - "Frequency": 17.2985 - }, - { - "Time": 117, - "Intensity": 0.017877, - "Frequency": 16.7269 - }, - { - "Time": 133, - "Intensity": 0.004579, - "Frequency": 18.9123 - }, - { - "Time": 150, - "Intensity": 0.015018, - "Frequency": 18.3264 - }, - { - "Time": 167, - "Intensity": 0.0063699, - "Frequency": 19.3763 - }, - { - "Time": 183, - "Intensity": 0.003663, - "Frequency": 19.3763 - }, - { - "Time": 200, - "Intensity": 0.0042855, - "Frequency": 3.7525 - }, - { - "Time": 217, - "Intensity": 0.0021302, - "Frequency": 3.847 - }, - { - "Time": 233, - "Intensity": 0.0078309, - "Frequency": 6.7964 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 7.1782 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1759, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 6.7964 - }, - { - "Time": 17, - "Intensity": 0.0035206, - "Frequency": 7.1782 - }, - { - "Time": 34, - "Intensity": 0.0011543, - "Frequency": 6.7993 - }, - { - "Time": 50, - "Intensity": 0.0022953, - "Frequency": 7.3322 - }, - { - "Time": 67, - "Intensity": 0.003826, - "Frequency": 12.0493 - }, - { - "Time": 84, - "Intensity": 0.0012973, - "Frequency": 16.6841 - }, - { - "Time": 100, - "Intensity": 0.0021943, - "Frequency": 20.0356 - }, - { - "Time": 117, - "Intensity": 0.0025446, - "Frequency": 17.6828 - }, - { - "Time": 134, - "Intensity": 0.0013369, - "Frequency": 13.7097 - }, - { - "Time": 150, - "Intensity": 0.00056959, - "Frequency": 7.8294 - }, - { - "Time": 167, - "Intensity": 0.00094861, - "Frequency": 0 - }, - { - "Time": 184, - "Intensity": 0.00058555, - "Frequency": 1 - }, - { - "Time": 200, - "Intensity": 0.00044257, - "Frequency": 3.5058 - }, - { - "Time": 217, - "Intensity": 0.00034451, - "Frequency": 3.5058 - }, - { - "Time": 234, - "Intensity": 0.00010188, - "Frequency": 6.3945 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 5.4841 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 75, - "StartTime": 1993, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 6.3945 - }, - { - "Time": 16, - "Intensity": 5.9868e-05, - "Frequency": 5.4841 - }, - { - "Time": 33, - "Intensity": 6.1123e-05, - "Frequency": 5.4841 - }, - { - "Time": 50, - "Intensity": 1.8783e-05, - "Frequency": 9.5255 - }, - { - "Time": 66, - "Intensity": 5.7126e-06, - "Frequency": 15.0855 - }, - { - "Time": 75, - "Intensity": 0, - "Frequency": 17.5105 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2021-10-18", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 126, + "Parameters": { + "Intensity": 80, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 69.313 + }, + { + "Time": 26, + "Intensity": 0.21, + "Frequency": 69.313 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 67.3027 + }, + { + "Time": 60, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 102, + "Intensity": 1, + "Frequency": 27 + }, + { + "Time": 144, + "Intensity": 1, + "Frequency": 27 + }, + { + "Time": 167, + "Intensity": 0.36219, + "Frequency": 47.0092 + }, + { + "Time": 200, + "Intensity": 0.82, + "Frequency": 8 + }, + { + "Time": 233, + "Intensity": 0.18445, + "Frequency": 47.9644 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 47.9644 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 359, + "Parameters": { + "Intensity": 80, + "Frequency": 48, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 47.9644 + }, + { + "Time": 11, + "Intensity": 0.75, + "Frequency": 26 + }, + { + "Time": 67, + "Intensity": 0.40413, + "Frequency": 46.0884 + }, + { + "Time": 143, + "Intensity": 0.27, + "Frequency": 26.5024 + }, + { + "Time": 212, + "Intensity": 0.51, + "Frequency": 21.0208 + }, + { + "Time": 234, + "Intensity": 0.29322, + "Frequency": 20.638 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 23.1938 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 593, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20.638 + }, + { + "Time": 6, + "Intensity": 0.34, + "Frequency": 23.1938 + }, + { + "Time": 34, + "Intensity": 0.61, + "Frequency": 23.1944 + }, + { + "Time": 50, + "Intensity": 0.21961, + "Frequency": 23.1944 + }, + { + "Time": 109, + "Intensity": 0.42, + "Frequency": 8 + }, + { + "Time": 167, + "Intensity": 0.23, + "Frequency": 0 + }, + { + "Time": 233, + "Intensity": 0.14725, + "Frequency": 17.5734 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 14.3638 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 826, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 17.5734 + }, + { + "Time": 33, + "Intensity": 0.34455, + "Frequency": 13.7928 + }, + { + "Time": 83, + "Intensity": 0.17566, + "Frequency": 13.2156 + }, + { + "Time": 99, + "Intensity": 0.47, + "Frequency": 13.8843 + }, + { + "Time": 150, + "Intensity": 0.099891, + "Frequency": 16.2494 + }, + { + "Time": 167, + "Intensity": 0.54439, + "Frequency": 16.251 + }, + { + "Time": 183, + "Intensity": 0.20715, + "Frequency": 14.4624 + }, + { + "Time": 217, + "Intensity": 0.083533, + "Frequency": 15.2237 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 14.4596 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1059, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 15.0306 + }, + { + "Time": 17, + "Intensity": 0.24137, + "Frequency": 14.4596 + }, + { + "Time": 34, + "Intensity": 0.27653, + "Frequency": 14.7438 + }, + { + "Time": 50, + "Intensity": 0.24485, + "Frequency": 19.939 + }, + { + "Time": 67, + "Intensity": 0.20559, + "Frequency": 20.5117 + }, + { + "Time": 84, + "Intensity": 0.11978, + "Frequency": 20.3226 + }, + { + "Time": 100, + "Intensity": 0.32286, + "Frequency": 18.1331 + }, + { + "Time": 117, + "Intensity": 0.21612, + "Frequency": 18.1331 + }, + { + "Time": 134, + "Intensity": 0.49264, + "Frequency": 21.2452 + }, + { + "Time": 150, + "Intensity": 0.18907, + "Frequency": 18.3376 + }, + { + "Time": 167, + "Intensity": 0.14537, + "Frequency": 17.9806 + }, + { + "Time": 184, + "Intensity": 0.26344, + "Frequency": 17.1246 + }, + { + "Time": 200, + "Intensity": 0.35007, + "Frequency": 17.7879 + }, + { + "Time": 217, + "Intensity": 0.14297, + "Frequency": 14.3585 + }, + { + "Time": 234, + "Intensity": 0.21184, + "Frequency": 16.9936 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 15.7556 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1293, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 16.9936 + }, + { + "Time": 16, + "Intensity": 0.2691, + "Frequency": 15.7556 + }, + { + "Time": 33, + "Intensity": 0.1914, + "Frequency": 16.9983 + }, + { + "Time": 50, + "Intensity": 0.14346, + "Frequency": 16.6456 + }, + { + "Time": 66, + "Intensity": 0.093315, + "Frequency": 17.6002 + }, + { + "Time": 83, + "Intensity": 0.13911, + "Frequency": 17.031 + }, + { + "Time": 100, + "Intensity": 0.071573, + "Frequency": 15.6997 + }, + { + "Time": 116, + "Intensity": 0.36325, + "Frequency": 14.6485 + }, + { + "Time": 133, + "Intensity": 0.10331, + "Frequency": 15.2189 + }, + { + "Time": 150, + "Intensity": 0.081988, + "Frequency": 15.2189 + }, + { + "Time": 166, + "Intensity": 0.074824, + "Frequency": 15.4095 + }, + { + "Time": 183, + "Intensity": 0.045809, + "Frequency": 14.5488 + }, + { + "Time": 200, + "Intensity": 0.033725, + "Frequency": 14.6454 + }, + { + "Time": 216, + "Intensity": 0.089506, + "Frequency": 14.2635 + }, + { + "Time": 233, + "Intensity": 0.066092, + "Frequency": 14.743 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 14.27 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1526, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 14.743 + }, + { + "Time": 17, + "Intensity": 0.085394, + "Frequency": 14.27 + }, + { + "Time": 33, + "Intensity": 0.029442, + "Frequency": 13.9832 + }, + { + "Time": 50, + "Intensity": 0.020521, + "Frequency": 16.1406 + }, + { + "Time": 67, + "Intensity": 0.05142, + "Frequency": 16.5194 + }, + { + "Time": 83, + "Intensity": 0.026311, + "Frequency": 16.6157 + }, + { + "Time": 100, + "Intensity": 0.017077, + "Frequency": 17.2985 + }, + { + "Time": 117, + "Intensity": 0.017877, + "Frequency": 16.7269 + }, + { + "Time": 133, + "Intensity": 0.004579, + "Frequency": 18.9123 + }, + { + "Time": 150, + "Intensity": 0.015018, + "Frequency": 18.3264 + }, + { + "Time": 167, + "Intensity": 0.0063699, + "Frequency": 19.3763 + }, + { + "Time": 183, + "Intensity": 0.003663, + "Frequency": 19.3763 + }, + { + "Time": 200, + "Intensity": 0.0042855, + "Frequency": 3.7525 + }, + { + "Time": 217, + "Intensity": 0.0021302, + "Frequency": 3.847 + }, + { + "Time": 233, + "Intensity": 0.0078309, + "Frequency": 6.7964 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 7.1782 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1759, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 6.7964 + }, + { + "Time": 17, + "Intensity": 0.0035206, + "Frequency": 7.1782 + }, + { + "Time": 34, + "Intensity": 0.0011543, + "Frequency": 6.7993 + }, + { + "Time": 50, + "Intensity": 0.0022953, + "Frequency": 7.3322 + }, + { + "Time": 67, + "Intensity": 0.003826, + "Frequency": 12.0493 + }, + { + "Time": 84, + "Intensity": 0.0012973, + "Frequency": 16.6841 + }, + { + "Time": 100, + "Intensity": 0.0021943, + "Frequency": 20.0356 + }, + { + "Time": 117, + "Intensity": 0.0025446, + "Frequency": 17.6828 + }, + { + "Time": 134, + "Intensity": 0.0013369, + "Frequency": 13.7097 + }, + { + "Time": 150, + "Intensity": 0.00056959, + "Frequency": 7.8294 + }, + { + "Time": 167, + "Intensity": 0.00094861, + "Frequency": 0 + }, + { + "Time": 184, + "Intensity": 0.00058555, + "Frequency": 1 + }, + { + "Time": 200, + "Intensity": 0.00044257, + "Frequency": 3.5058 + }, + { + "Time": 217, + "Intensity": 0.00034451, + "Frequency": 3.5058 + }, + { + "Time": 234, + "Intensity": 0.00010188, + "Frequency": 6.3945 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 5.4841 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 75, + "StartTime": 1993, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 6.3945 + }, + { + "Time": 16, + "Intensity": 5.9868e-05, + "Frequency": 5.4841 + }, + { + "Time": 33, + "Intensity": 6.1123e-05, + "Frequency": 5.4841 + }, + { + "Time": 50, + "Intensity": 1.8783e-05, + "Frequency": 9.5255 + }, + { + "Time": 66, + "Intensity": 5.7126e-06, + "Frequency": 15.0855 + }, + { + "Time": 75, + "Intensity": 0, + "Frequency": 17.5105 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_h.json index 2ce2420365..82d3749bc6 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_h.json @@ -1,37 +1,37 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 107, - "Parameters": { - "Intensity": 80, - "Frequency": 21 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 161, - "Parameters": { - "Intensity": 100, - "Frequency": 21 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 107, + "Parameters": { + "Intensity": 80, + "Frequency": 21 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 161, + "Parameters": { + "Intensity": 100, + "Frequency": 21 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_l.json index c3ffde424b..53a5b90bbd 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_l.json @@ -1,37 +1,37 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 107, - "Parameters": { - "Intensity": 48, - "Frequency": 21 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 161, - "Parameters": { - "Intensity": 60, - "Frequency": 21 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 107, + "Parameters": { + "Intensity": 48, + "Frequency": 21 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 161, + "Parameters": { + "Intensity": 60, + "Frequency": 21 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_m.json index d3b8469f6f..f8c61f7cac 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CZ75_m.json @@ -1,37 +1,37 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 107, - "Parameters": { - "Intensity": 64, - "Frequency": 21 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 161, - "Parameters": { - "Intensity": 80, - "Frequency": 21 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 107, + "Parameters": { + "Intensity": 64, + "Frequency": 21 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 161, + "Parameters": { + "Intensity": 80, + "Frequency": 21 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_h.json index 90bb9156c8..a085857ffa 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_h.json @@ -1,278 +1,278 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 923, - "StartTime": 20, - "Parameters": { - "Intensity": 56, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 95, - "Intensity": 0.72, - "Frequency": -15 - }, - { - "Time": 497, - "Intensity": 0.57, - "Frequency": -50 - }, - { - "Time": 782, - "Intensity": 0.77, - "Frequency": -15 - }, - { - "Time": 923, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 185, - "Parameters": { - "Intensity": 46, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 720, - "Parameters": { - "Intensity": 37, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 908, - "Parameters": { - "Intensity": 41, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 3785, - "StartTime": 965, - "Parameters": { - "Intensity": 55, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 204, - "Intensity": 0.64, - "Frequency": -15 - }, - { - "Time": 473, - "Intensity": 0.77, - "Frequency": -50 - }, - { - "Time": 628, - "Intensity": 0.88, - "Frequency": -15 - }, - { - "Time": 946, - "Intensity": 0.73, - "Frequency": -50 - }, - { - "Time": 1347, - "Intensity": 0.68, - "Frequency": -15 - }, - { - "Time": 1631, - "Intensity": 0.83, - "Frequency": -50 - }, - { - "Time": 1896, - "Intensity": 0.7, - "Frequency": -15 - }, - { - "Time": 2275, - "Intensity": 0.45, - "Frequency": -50 - }, - { - "Time": 2737, - "Intensity": 0.77, - "Frequency": -15 - }, - { - "Time": 3115, - "Intensity": 0.75, - "Frequency": -50 - }, - { - "Time": 3312, - "Intensity": 0.87, - "Frequency": -15 - }, - { - "Time": 3759, - "Intensity": 0.75, - "Frequency": -15 - }, - { - "Time": 3785, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1008, - "Parameters": { - "Intensity": 59, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1447, - "Parameters": { - "Intensity": 37, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1610, - "Parameters": { - "Intensity": 52, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2105, - "Parameters": { - "Intensity": 45, - "Frequency": 14 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2175, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2660, - "Parameters": { - "Intensity": 47, - "Frequency": 14 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2993, - "Parameters": { - "Intensity": 64, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3072, - "Parameters": { - "Intensity": 90, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3390, - "Parameters": { - "Intensity": 41, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3960, - "Parameters": { - "Intensity": 50, - "Frequency": 38 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4220, - "Parameters": { - "Intensity": 41, - "Frequency": 0 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 923, + "StartTime": 20, + "Parameters": { + "Intensity": 56, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 95, + "Intensity": 0.72, + "Frequency": -15 + }, + { + "Time": 497, + "Intensity": 0.57, + "Frequency": -50 + }, + { + "Time": 782, + "Intensity": 0.77, + "Frequency": -15 + }, + { + "Time": 923, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 185, + "Parameters": { + "Intensity": 46, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 720, + "Parameters": { + "Intensity": 37, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 908, + "Parameters": { + "Intensity": 41, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 3785, + "StartTime": 965, + "Parameters": { + "Intensity": 55, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 204, + "Intensity": 0.64, + "Frequency": -15 + }, + { + "Time": 473, + "Intensity": 0.77, + "Frequency": -50 + }, + { + "Time": 628, + "Intensity": 0.88, + "Frequency": -15 + }, + { + "Time": 946, + "Intensity": 0.73, + "Frequency": -50 + }, + { + "Time": 1347, + "Intensity": 0.68, + "Frequency": -15 + }, + { + "Time": 1631, + "Intensity": 0.83, + "Frequency": -50 + }, + { + "Time": 1896, + "Intensity": 0.7, + "Frequency": -15 + }, + { + "Time": 2275, + "Intensity": 0.45, + "Frequency": -50 + }, + { + "Time": 2737, + "Intensity": 0.77, + "Frequency": -15 + }, + { + "Time": 3115, + "Intensity": 0.75, + "Frequency": -50 + }, + { + "Time": 3312, + "Intensity": 0.87, + "Frequency": -15 + }, + { + "Time": 3759, + "Intensity": 0.75, + "Frequency": -15 + }, + { + "Time": 3785, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1008, + "Parameters": { + "Intensity": 59, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1447, + "Parameters": { + "Intensity": 37, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1610, + "Parameters": { + "Intensity": 52, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2105, + "Parameters": { + "Intensity": 45, + "Frequency": 14 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2175, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2660, + "Parameters": { + "Intensity": 47, + "Frequency": 14 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2993, + "Parameters": { + "Intensity": 64, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3072, + "Parameters": { + "Intensity": 90, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3390, + "Parameters": { + "Intensity": 41, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3960, + "Parameters": { + "Intensity": 50, + "Frequency": 38 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4220, + "Parameters": { + "Intensity": 41, + "Frequency": 0 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_l.json index 5e6b258e3e..38d31c8e92 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_l.json @@ -1,278 +1,278 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 923, - "StartTime": 20, - "Parameters": { - "Intensity": 33, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 95, - "Intensity": 0.72, - "Frequency": -15 - }, - { - "Time": 497, - "Intensity": 0.57, - "Frequency": -50 - }, - { - "Time": 782, - "Intensity": 0.77, - "Frequency": -15 - }, - { - "Time": 923, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 185, - "Parameters": { - "Intensity": 27, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 720, - "Parameters": { - "Intensity": 22, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 908, - "Parameters": { - "Intensity": 24, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 3785, - "StartTime": 965, - "Parameters": { - "Intensity": 33, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 204, - "Intensity": 0.64, - "Frequency": -15 - }, - { - "Time": 473, - "Intensity": 0.77, - "Frequency": -50 - }, - { - "Time": 628, - "Intensity": 0.88, - "Frequency": -15 - }, - { - "Time": 946, - "Intensity": 0.73, - "Frequency": -50 - }, - { - "Time": 1347, - "Intensity": 0.68, - "Frequency": -15 - }, - { - "Time": 1631, - "Intensity": 0.83, - "Frequency": -50 - }, - { - "Time": 1896, - "Intensity": 0.7, - "Frequency": -15 - }, - { - "Time": 2275, - "Intensity": 0.45, - "Frequency": -50 - }, - { - "Time": 2737, - "Intensity": 0.77, - "Frequency": -15 - }, - { - "Time": 3115, - "Intensity": 0.75, - "Frequency": -50 - }, - { - "Time": 3312, - "Intensity": 0.87, - "Frequency": -15 - }, - { - "Time": 3759, - "Intensity": 0.75, - "Frequency": -15 - }, - { - "Time": 3785, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1008, - "Parameters": { - "Intensity": 35, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1447, - "Parameters": { - "Intensity": 22, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1610, - "Parameters": { - "Intensity": 31, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2105, - "Parameters": { - "Intensity": 27, - "Frequency": 14 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2175, - "Parameters": { - "Intensity": 36, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2660, - "Parameters": { - "Intensity": 28, - "Frequency": 14 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2993, - "Parameters": { - "Intensity": 38, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3072, - "Parameters": { - "Intensity": 54, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3390, - "Parameters": { - "Intensity": 24, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3960, - "Parameters": { - "Intensity": 30, - "Frequency": 38 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4220, - "Parameters": { - "Intensity": 24, - "Frequency": 0 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 923, + "StartTime": 20, + "Parameters": { + "Intensity": 33, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 95, + "Intensity": 0.72, + "Frequency": -15 + }, + { + "Time": 497, + "Intensity": 0.57, + "Frequency": -50 + }, + { + "Time": 782, + "Intensity": 0.77, + "Frequency": -15 + }, + { + "Time": 923, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 185, + "Parameters": { + "Intensity": 27, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 720, + "Parameters": { + "Intensity": 22, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 908, + "Parameters": { + "Intensity": 24, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 3785, + "StartTime": 965, + "Parameters": { + "Intensity": 33, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 204, + "Intensity": 0.64, + "Frequency": -15 + }, + { + "Time": 473, + "Intensity": 0.77, + "Frequency": -50 + }, + { + "Time": 628, + "Intensity": 0.88, + "Frequency": -15 + }, + { + "Time": 946, + "Intensity": 0.73, + "Frequency": -50 + }, + { + "Time": 1347, + "Intensity": 0.68, + "Frequency": -15 + }, + { + "Time": 1631, + "Intensity": 0.83, + "Frequency": -50 + }, + { + "Time": 1896, + "Intensity": 0.7, + "Frequency": -15 + }, + { + "Time": 2275, + "Intensity": 0.45, + "Frequency": -50 + }, + { + "Time": 2737, + "Intensity": 0.77, + "Frequency": -15 + }, + { + "Time": 3115, + "Intensity": 0.75, + "Frequency": -50 + }, + { + "Time": 3312, + "Intensity": 0.87, + "Frequency": -15 + }, + { + "Time": 3759, + "Intensity": 0.75, + "Frequency": -15 + }, + { + "Time": 3785, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1008, + "Parameters": { + "Intensity": 35, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1447, + "Parameters": { + "Intensity": 22, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1610, + "Parameters": { + "Intensity": 31, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2105, + "Parameters": { + "Intensity": 27, + "Frequency": 14 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2175, + "Parameters": { + "Intensity": 36, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2660, + "Parameters": { + "Intensity": 28, + "Frequency": 14 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2993, + "Parameters": { + "Intensity": 38, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3072, + "Parameters": { + "Intensity": 54, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3390, + "Parameters": { + "Intensity": 24, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3960, + "Parameters": { + "Intensity": 30, + "Frequency": 38 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4220, + "Parameters": { + "Intensity": 24, + "Frequency": 0 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_m.json index 74a91481c3..4a31f6f642 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Campfire_m.json @@ -1,278 +1,278 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 923, - "StartTime": 20, - "Parameters": { - "Intensity": 44, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 95, - "Intensity": 0.72, - "Frequency": -15 - }, - { - "Time": 497, - "Intensity": 0.57, - "Frequency": -50 - }, - { - "Time": 782, - "Intensity": 0.77, - "Frequency": -15 - }, - { - "Time": 923, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 185, - "Parameters": { - "Intensity": 36, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 720, - "Parameters": { - "Intensity": 29, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 908, - "Parameters": { - "Intensity": 32, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 3785, - "StartTime": 965, - "Parameters": { - "Intensity": 44, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 204, - "Intensity": 0.64, - "Frequency": -15 - }, - { - "Time": 473, - "Intensity": 0.77, - "Frequency": -50 - }, - { - "Time": 628, - "Intensity": 0.88, - "Frequency": -15 - }, - { - "Time": 946, - "Intensity": 0.73, - "Frequency": -50 - }, - { - "Time": 1347, - "Intensity": 0.68, - "Frequency": -15 - }, - { - "Time": 1631, - "Intensity": 0.83, - "Frequency": -50 - }, - { - "Time": 1896, - "Intensity": 0.7, - "Frequency": -15 - }, - { - "Time": 2275, - "Intensity": 0.45, - "Frequency": -50 - }, - { - "Time": 2737, - "Intensity": 0.77, - "Frequency": -15 - }, - { - "Time": 3115, - "Intensity": 0.75, - "Frequency": -50 - }, - { - "Time": 3312, - "Intensity": 0.87, - "Frequency": -15 - }, - { - "Time": 3759, - "Intensity": 0.75, - "Frequency": -15 - }, - { - "Time": 3785, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1008, - "Parameters": { - "Intensity": 47, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1447, - "Parameters": { - "Intensity": 29, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1610, - "Parameters": { - "Intensity": 41, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2105, - "Parameters": { - "Intensity": 36, - "Frequency": 14 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2175, - "Parameters": { - "Intensity": 48, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2660, - "Parameters": { - "Intensity": 37, - "Frequency": 14 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2993, - "Parameters": { - "Intensity": 51, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3072, - "Parameters": { - "Intensity": 72, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3390, - "Parameters": { - "Intensity": 32, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3960, - "Parameters": { - "Intensity": 40, - "Frequency": 38 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4220, - "Parameters": { - "Intensity": 32, - "Frequency": 0 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 923, + "StartTime": 20, + "Parameters": { + "Intensity": 44, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 95, + "Intensity": 0.72, + "Frequency": -15 + }, + { + "Time": 497, + "Intensity": 0.57, + "Frequency": -50 + }, + { + "Time": 782, + "Intensity": 0.77, + "Frequency": -15 + }, + { + "Time": 923, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 185, + "Parameters": { + "Intensity": 36, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 720, + "Parameters": { + "Intensity": 29, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 908, + "Parameters": { + "Intensity": 32, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 3785, + "StartTime": 965, + "Parameters": { + "Intensity": 44, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 204, + "Intensity": 0.64, + "Frequency": -15 + }, + { + "Time": 473, + "Intensity": 0.77, + "Frequency": -50 + }, + { + "Time": 628, + "Intensity": 0.88, + "Frequency": -15 + }, + { + "Time": 946, + "Intensity": 0.73, + "Frequency": -50 + }, + { + "Time": 1347, + "Intensity": 0.68, + "Frequency": -15 + }, + { + "Time": 1631, + "Intensity": 0.83, + "Frequency": -50 + }, + { + "Time": 1896, + "Intensity": 0.7, + "Frequency": -15 + }, + { + "Time": 2275, + "Intensity": 0.45, + "Frequency": -50 + }, + { + "Time": 2737, + "Intensity": 0.77, + "Frequency": -15 + }, + { + "Time": 3115, + "Intensity": 0.75, + "Frequency": -50 + }, + { + "Time": 3312, + "Intensity": 0.87, + "Frequency": -15 + }, + { + "Time": 3759, + "Intensity": 0.75, + "Frequency": -15 + }, + { + "Time": 3785, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1008, + "Parameters": { + "Intensity": 47, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1447, + "Parameters": { + "Intensity": 29, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1610, + "Parameters": { + "Intensity": 41, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2105, + "Parameters": { + "Intensity": 36, + "Frequency": 14 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2175, + "Parameters": { + "Intensity": 48, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2660, + "Parameters": { + "Intensity": 37, + "Frequency": 14 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2993, + "Parameters": { + "Intensity": 51, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3072, + "Parameters": { + "Intensity": 72, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3390, + "Parameters": { + "Intensity": 32, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3960, + "Parameters": { + "Intensity": 40, + "Frequency": 38 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4220, + "Parameters": { + "Intensity": 32, + "Frequency": 0 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_h.json index 3554aac99d..c8cb0d0d34 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_h.json @@ -1,532 +1,532 @@ -{ - "MetaData": { - "Create": "2022-09-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2, - "Parameters": { - "Intensity": 100, - "Frequency": 10, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37 - }, - { - "Time": 30, - "Intensity": 0.08, - "Frequency": 45 - }, - { - "Time": 47, - "Intensity": 0.14, - "Frequency": 47 - }, - { - "Time": 58, - "Intensity": 0.23, - "Frequency": 48 - }, - { - "Time": 75, - "Intensity": 0.52, - "Frequency": 46 - }, - { - "Time": 89, - "Intensity": 0.93, - "Frequency": 48 - }, - { - "Time": 99, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 124, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 138, - "Intensity": 1, - "Frequency": 52 - }, - { - "Time": 150, - "Intensity": 0.84, - "Frequency": 54 - }, - { - "Time": 166, - "Intensity": 0.72, - "Frequency": 52 - }, - { - "Time": 183, - "Intensity": 0.59, - "Frequency": 50 - }, - { - "Time": 200, - "Intensity": 0.54, - "Frequency": 49 - }, - { - "Time": 217, - "Intensity": 0.32, - "Frequency": 50 - }, - { - "Time": 233, - "Intensity": 0.34, - "Frequency": 50 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 22 - }, - { - "Time": 30, - "Intensity": 0.08, - "Frequency": 39 - }, - { - "Time": 47, - "Intensity": 0.14, - "Frequency": 36 - }, - { - "Time": 60, - "Intensity": 0.24, - "Frequency": 38 - }, - { - "Time": 75, - "Intensity": 0.52, - "Frequency": 39 - }, - { - "Time": 89, - "Intensity": 0.93, - "Frequency": 42 - }, - { - "Time": 99, - "Intensity": 1, - "Frequency": 39 - }, - { - "Time": 124, - "Intensity": 1, - "Frequency": 40 - }, - { - "Time": 138, - "Intensity": 1, - "Frequency": 42 - }, - { - "Time": 150, - "Intensity": 0.84, - "Frequency": 44 - }, - { - "Time": 166, - "Intensity": 0.72, - "Frequency": 42 - }, - { - "Time": 183, - "Intensity": 0.59, - "Frequency": 40 - }, - { - "Time": 200, - "Intensity": 0.54, - "Frequency": 39 - }, - { - "Time": 217, - "Intensity": 0.32, - "Frequency": 42 - }, - { - "Time": 233, - "Intensity": 0.34, - "Frequency": 40 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 40 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 254, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 17, - "Intensity": 0.15, - "Frequency": 60 - }, - { - "Time": 34, - "Intensity": 0.25, - "Frequency": 57 - }, - { - "Time": 50, - "Intensity": 0.19, - "Frequency": 59 - }, - { - "Time": 67, - "Intensity": 0.22, - "Frequency": 62 - }, - { - "Time": 84, - "Intensity": 0.32, - "Frequency": 66 - }, - { - "Time": 100, - "Intensity": 0.32, - "Frequency": 69 - }, - { - "Time": 117, - "Intensity": 0.18, - "Frequency": 71 - }, - { - "Time": 134, - "Intensity": 0.09, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.16, - "Frequency": 75 - }, - { - "Time": 167, - "Intensity": 0.21, - "Frequency": 76 - }, - { - "Time": 184, - "Intensity": 0.28, - "Frequency": 77 - }, - { - "Time": 200, - "Intensity": 0.12, - "Frequency": 75 - }, - { - "Time": 217, - "Intensity": 0.2, - "Frequency": 73 - }, - { - "Time": 234, - "Intensity": 0.13, - "Frequency": 74 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 75 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 290, - "Parameters": { - "Intensity": 85, - "Frequency": 83 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 342, - "Parameters": { - "Intensity": 69, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 395, - "Parameters": { - "Intensity": 51, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 446, - "Parameters": { - "Intensity": 36, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 483, - "Parameters": { - "Intensity": 27, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 222, - "StartTime": 504, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 74 - }, - { - "Time": 14, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 25, - "Intensity": 0.17, - "Frequency": 75 - }, - { - "Time": 38, - "Intensity": 0.22, - "Frequency": 75 - }, - { - "Time": 58, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 73, - "Intensity": 0.05, - "Frequency": 78 - }, - { - "Time": 88, - "Intensity": 0.07, - "Frequency": 79 - }, - { - "Time": 101, - "Intensity": 0.12, - "Frequency": 81 - }, - { - "Time": 118, - "Intensity": 0.27, - "Frequency": 80 - }, - { - "Time": 132, - "Intensity": 0.22, - "Frequency": 79 - }, - { - "Time": 147, - "Intensity": 0.12, - "Frequency": 79 - }, - { - "Time": 161, - "Intensity": 0.1, - "Frequency": 78 - }, - { - "Time": 176, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 191, - "Intensity": 0.22, - "Frequency": 75 - }, - { - "Time": 202, - "Intensity": 0.18, - "Frequency": 76 - }, - { - "Time": 222, - "Intensity": 0, - "Frequency": 76 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 727, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 76 - }, - { - "Time": 17, - "Intensity": 0.07, - "Frequency": 76 - }, - { - "Time": 33, - "Intensity": 0.07, - "Frequency": 76 - }, - { - "Time": 50, - "Intensity": 0.06, - "Frequency": 78 - }, - { - "Time": 67, - "Intensity": 0.03, - "Frequency": 76 - }, - { - "Time": 83, - "Intensity": 0.03, - "Frequency": 76 - }, - { - "Time": 100, - "Intensity": 0.04, - "Frequency": 74 - }, - { - "Time": 116, - "Intensity": 0.11, - "Frequency": 80 - }, - { - "Time": 132, - "Intensity": 0.07, - "Frequency": 81 - }, - { - "Time": 150, - "Intensity": 0.05, - "Frequency": 79 - }, - { - "Time": 167, - "Intensity": 0.02, - "Frequency": 75 - }, - { - "Time": 183, - "Intensity": 0.01, - "Frequency": 73 - }, - { - "Time": 198, - "Intensity": 0.03, - "Frequency": 74 - }, - { - "Time": 216, - "Intensity": 0.06, - "Frequency": 73 - }, - { - "Time": 234, - "Intensity": 0.04, - "Frequency": 73 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 74 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-09-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2, + "Parameters": { + "Intensity": 100, + "Frequency": 10, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37 + }, + { + "Time": 30, + "Intensity": 0.08, + "Frequency": 45 + }, + { + "Time": 47, + "Intensity": 0.14, + "Frequency": 47 + }, + { + "Time": 58, + "Intensity": 0.23, + "Frequency": 48 + }, + { + "Time": 75, + "Intensity": 0.52, + "Frequency": 46 + }, + { + "Time": 89, + "Intensity": 0.93, + "Frequency": 48 + }, + { + "Time": 99, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 124, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 138, + "Intensity": 1, + "Frequency": 52 + }, + { + "Time": 150, + "Intensity": 0.84, + "Frequency": 54 + }, + { + "Time": 166, + "Intensity": 0.72, + "Frequency": 52 + }, + { + "Time": 183, + "Intensity": 0.59, + "Frequency": 50 + }, + { + "Time": 200, + "Intensity": 0.54, + "Frequency": 49 + }, + { + "Time": 217, + "Intensity": 0.32, + "Frequency": 50 + }, + { + "Time": 233, + "Intensity": 0.34, + "Frequency": 50 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 22 + }, + { + "Time": 30, + "Intensity": 0.08, + "Frequency": 39 + }, + { + "Time": 47, + "Intensity": 0.14, + "Frequency": 36 + }, + { + "Time": 60, + "Intensity": 0.24, + "Frequency": 38 + }, + { + "Time": 75, + "Intensity": 0.52, + "Frequency": 39 + }, + { + "Time": 89, + "Intensity": 0.93, + "Frequency": 42 + }, + { + "Time": 99, + "Intensity": 1, + "Frequency": 39 + }, + { + "Time": 124, + "Intensity": 1, + "Frequency": 40 + }, + { + "Time": 138, + "Intensity": 1, + "Frequency": 42 + }, + { + "Time": 150, + "Intensity": 0.84, + "Frequency": 44 + }, + { + "Time": 166, + "Intensity": 0.72, + "Frequency": 42 + }, + { + "Time": 183, + "Intensity": 0.59, + "Frequency": 40 + }, + { + "Time": 200, + "Intensity": 0.54, + "Frequency": 39 + }, + { + "Time": 217, + "Intensity": 0.32, + "Frequency": 42 + }, + { + "Time": 233, + "Intensity": 0.34, + "Frequency": 40 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 40 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 254, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 17, + "Intensity": 0.15, + "Frequency": 60 + }, + { + "Time": 34, + "Intensity": 0.25, + "Frequency": 57 + }, + { + "Time": 50, + "Intensity": 0.19, + "Frequency": 59 + }, + { + "Time": 67, + "Intensity": 0.22, + "Frequency": 62 + }, + { + "Time": 84, + "Intensity": 0.32, + "Frequency": 66 + }, + { + "Time": 100, + "Intensity": 0.32, + "Frequency": 69 + }, + { + "Time": 117, + "Intensity": 0.18, + "Frequency": 71 + }, + { + "Time": 134, + "Intensity": 0.09, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.16, + "Frequency": 75 + }, + { + "Time": 167, + "Intensity": 0.21, + "Frequency": 76 + }, + { + "Time": 184, + "Intensity": 0.28, + "Frequency": 77 + }, + { + "Time": 200, + "Intensity": 0.12, + "Frequency": 75 + }, + { + "Time": 217, + "Intensity": 0.2, + "Frequency": 73 + }, + { + "Time": 234, + "Intensity": 0.13, + "Frequency": 74 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 75 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 290, + "Parameters": { + "Intensity": 85, + "Frequency": 83 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 342, + "Parameters": { + "Intensity": 69, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 395, + "Parameters": { + "Intensity": 51, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 446, + "Parameters": { + "Intensity": 36, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 483, + "Parameters": { + "Intensity": 27, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 222, + "StartTime": 504, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 74 + }, + { + "Time": 14, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 25, + "Intensity": 0.17, + "Frequency": 75 + }, + { + "Time": 38, + "Intensity": 0.22, + "Frequency": 75 + }, + { + "Time": 58, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 73, + "Intensity": 0.05, + "Frequency": 78 + }, + { + "Time": 88, + "Intensity": 0.07, + "Frequency": 79 + }, + { + "Time": 101, + "Intensity": 0.12, + "Frequency": 81 + }, + { + "Time": 118, + "Intensity": 0.27, + "Frequency": 80 + }, + { + "Time": 132, + "Intensity": 0.22, + "Frequency": 79 + }, + { + "Time": 147, + "Intensity": 0.12, + "Frequency": 79 + }, + { + "Time": 161, + "Intensity": 0.1, + "Frequency": 78 + }, + { + "Time": 176, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 191, + "Intensity": 0.22, + "Frequency": 75 + }, + { + "Time": 202, + "Intensity": 0.18, + "Frequency": 76 + }, + { + "Time": 222, + "Intensity": 0, + "Frequency": 76 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 727, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 76 + }, + { + "Time": 17, + "Intensity": 0.07, + "Frequency": 76 + }, + { + "Time": 33, + "Intensity": 0.07, + "Frequency": 76 + }, + { + "Time": 50, + "Intensity": 0.06, + "Frequency": 78 + }, + { + "Time": 67, + "Intensity": 0.03, + "Frequency": 76 + }, + { + "Time": 83, + "Intensity": 0.03, + "Frequency": 76 + }, + { + "Time": 100, + "Intensity": 0.04, + "Frequency": 74 + }, + { + "Time": 116, + "Intensity": 0.11, + "Frequency": 80 + }, + { + "Time": 132, + "Intensity": 0.07, + "Frequency": 81 + }, + { + "Time": 150, + "Intensity": 0.05, + "Frequency": 79 + }, + { + "Time": 167, + "Intensity": 0.02, + "Frequency": 75 + }, + { + "Time": 183, + "Intensity": 0.01, + "Frequency": 73 + }, + { + "Time": 198, + "Intensity": 0.03, + "Frequency": 74 + }, + { + "Time": 216, + "Intensity": 0.06, + "Frequency": 73 + }, + { + "Time": 234, + "Intensity": 0.04, + "Frequency": 73 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 74 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_l.json index d9911761be..370eaa4c8e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_l.json @@ -1,532 +1,532 @@ -{ - "MetaData": { - "Create": "2022-09-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2, - "Parameters": { - "Intensity": 60, - "Frequency": 10, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37 - }, - { - "Time": 30, - "Intensity": 0.08, - "Frequency": 45 - }, - { - "Time": 47, - "Intensity": 0.14, - "Frequency": 47 - }, - { - "Time": 58, - "Intensity": 0.23, - "Frequency": 48 - }, - { - "Time": 75, - "Intensity": 0.52, - "Frequency": 46 - }, - { - "Time": 89, - "Intensity": 0.93, - "Frequency": 48 - }, - { - "Time": 99, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 124, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 138, - "Intensity": 1, - "Frequency": 52 - }, - { - "Time": 150, - "Intensity": 0.84, - "Frequency": 54 - }, - { - "Time": 166, - "Intensity": 0.72, - "Frequency": 52 - }, - { - "Time": 183, - "Intensity": 0.59, - "Frequency": 50 - }, - { - "Time": 200, - "Intensity": 0.54, - "Frequency": 49 - }, - { - "Time": 217, - "Intensity": 0.32, - "Frequency": 50 - }, - { - "Time": 233, - "Intensity": 0.34, - "Frequency": 50 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 22 - }, - { - "Time": 30, - "Intensity": 0.08, - "Frequency": 39 - }, - { - "Time": 47, - "Intensity": 0.14, - "Frequency": 36 - }, - { - "Time": 60, - "Intensity": 0.24, - "Frequency": 38 - }, - { - "Time": 75, - "Intensity": 0.52, - "Frequency": 39 - }, - { - "Time": 89, - "Intensity": 0.93, - "Frequency": 42 - }, - { - "Time": 99, - "Intensity": 1, - "Frequency": 39 - }, - { - "Time": 124, - "Intensity": 1, - "Frequency": 40 - }, - { - "Time": 138, - "Intensity": 1, - "Frequency": 42 - }, - { - "Time": 150, - "Intensity": 0.84, - "Frequency": 44 - }, - { - "Time": 166, - "Intensity": 0.72, - "Frequency": 42 - }, - { - "Time": 183, - "Intensity": 0.59, - "Frequency": 40 - }, - { - "Time": 200, - "Intensity": 0.54, - "Frequency": 39 - }, - { - "Time": 217, - "Intensity": 0.32, - "Frequency": 42 - }, - { - "Time": 233, - "Intensity": 0.34, - "Frequency": 40 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 40 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 254, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 17, - "Intensity": 0.15, - "Frequency": 60 - }, - { - "Time": 34, - "Intensity": 0.25, - "Frequency": 57 - }, - { - "Time": 50, - "Intensity": 0.19, - "Frequency": 59 - }, - { - "Time": 67, - "Intensity": 0.22, - "Frequency": 62 - }, - { - "Time": 84, - "Intensity": 0.32, - "Frequency": 66 - }, - { - "Time": 100, - "Intensity": 0.32, - "Frequency": 69 - }, - { - "Time": 117, - "Intensity": 0.18, - "Frequency": 71 - }, - { - "Time": 134, - "Intensity": 0.09, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.16, - "Frequency": 75 - }, - { - "Time": 167, - "Intensity": 0.21, - "Frequency": 76 - }, - { - "Time": 184, - "Intensity": 0.28, - "Frequency": 77 - }, - { - "Time": 200, - "Intensity": 0.12, - "Frequency": 75 - }, - { - "Time": 217, - "Intensity": 0.2, - "Frequency": 73 - }, - { - "Time": 234, - "Intensity": 0.13, - "Frequency": 74 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 75 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 290, - "Parameters": { - "Intensity": 51, - "Frequency": 83 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 342, - "Parameters": { - "Intensity": 41, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 395, - "Parameters": { - "Intensity": 30, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 446, - "Parameters": { - "Intensity": 21, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 483, - "Parameters": { - "Intensity": 16, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 222, - "StartTime": 504, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 74 - }, - { - "Time": 14, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 25, - "Intensity": 0.17, - "Frequency": 75 - }, - { - "Time": 38, - "Intensity": 0.22, - "Frequency": 75 - }, - { - "Time": 58, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 73, - "Intensity": 0.05, - "Frequency": 78 - }, - { - "Time": 88, - "Intensity": 0.07, - "Frequency": 79 - }, - { - "Time": 101, - "Intensity": 0.12, - "Frequency": 81 - }, - { - "Time": 118, - "Intensity": 0.27, - "Frequency": 80 - }, - { - "Time": 132, - "Intensity": 0.22, - "Frequency": 79 - }, - { - "Time": 147, - "Intensity": 0.12, - "Frequency": 79 - }, - { - "Time": 161, - "Intensity": 0.1, - "Frequency": 78 - }, - { - "Time": 176, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 191, - "Intensity": 0.22, - "Frequency": 75 - }, - { - "Time": 202, - "Intensity": 0.18, - "Frequency": 76 - }, - { - "Time": 222, - "Intensity": 0, - "Frequency": 76 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 727, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 76 - }, - { - "Time": 17, - "Intensity": 0.07, - "Frequency": 76 - }, - { - "Time": 33, - "Intensity": 0.07, - "Frequency": 76 - }, - { - "Time": 50, - "Intensity": 0.06, - "Frequency": 78 - }, - { - "Time": 67, - "Intensity": 0.03, - "Frequency": 76 - }, - { - "Time": 83, - "Intensity": 0.03, - "Frequency": 76 - }, - { - "Time": 100, - "Intensity": 0.04, - "Frequency": 74 - }, - { - "Time": 116, - "Intensity": 0.11, - "Frequency": 80 - }, - { - "Time": 132, - "Intensity": 0.07, - "Frequency": 81 - }, - { - "Time": 150, - "Intensity": 0.05, - "Frequency": 79 - }, - { - "Time": 167, - "Intensity": 0.02, - "Frequency": 75 - }, - { - "Time": 183, - "Intensity": 0.01, - "Frequency": 73 - }, - { - "Time": 198, - "Intensity": 0.03, - "Frequency": 74 - }, - { - "Time": 216, - "Intensity": 0.06, - "Frequency": 73 - }, - { - "Time": 234, - "Intensity": 0.04, - "Frequency": 73 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 74 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-09-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2, + "Parameters": { + "Intensity": 60, + "Frequency": 10, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37 + }, + { + "Time": 30, + "Intensity": 0.08, + "Frequency": 45 + }, + { + "Time": 47, + "Intensity": 0.14, + "Frequency": 47 + }, + { + "Time": 58, + "Intensity": 0.23, + "Frequency": 48 + }, + { + "Time": 75, + "Intensity": 0.52, + "Frequency": 46 + }, + { + "Time": 89, + "Intensity": 0.93, + "Frequency": 48 + }, + { + "Time": 99, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 124, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 138, + "Intensity": 1, + "Frequency": 52 + }, + { + "Time": 150, + "Intensity": 0.84, + "Frequency": 54 + }, + { + "Time": 166, + "Intensity": 0.72, + "Frequency": 52 + }, + { + "Time": 183, + "Intensity": 0.59, + "Frequency": 50 + }, + { + "Time": 200, + "Intensity": 0.54, + "Frequency": 49 + }, + { + "Time": 217, + "Intensity": 0.32, + "Frequency": 50 + }, + { + "Time": 233, + "Intensity": 0.34, + "Frequency": 50 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 22 + }, + { + "Time": 30, + "Intensity": 0.08, + "Frequency": 39 + }, + { + "Time": 47, + "Intensity": 0.14, + "Frequency": 36 + }, + { + "Time": 60, + "Intensity": 0.24, + "Frequency": 38 + }, + { + "Time": 75, + "Intensity": 0.52, + "Frequency": 39 + }, + { + "Time": 89, + "Intensity": 0.93, + "Frequency": 42 + }, + { + "Time": 99, + "Intensity": 1, + "Frequency": 39 + }, + { + "Time": 124, + "Intensity": 1, + "Frequency": 40 + }, + { + "Time": 138, + "Intensity": 1, + "Frequency": 42 + }, + { + "Time": 150, + "Intensity": 0.84, + "Frequency": 44 + }, + { + "Time": 166, + "Intensity": 0.72, + "Frequency": 42 + }, + { + "Time": 183, + "Intensity": 0.59, + "Frequency": 40 + }, + { + "Time": 200, + "Intensity": 0.54, + "Frequency": 39 + }, + { + "Time": 217, + "Intensity": 0.32, + "Frequency": 42 + }, + { + "Time": 233, + "Intensity": 0.34, + "Frequency": 40 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 40 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 254, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 17, + "Intensity": 0.15, + "Frequency": 60 + }, + { + "Time": 34, + "Intensity": 0.25, + "Frequency": 57 + }, + { + "Time": 50, + "Intensity": 0.19, + "Frequency": 59 + }, + { + "Time": 67, + "Intensity": 0.22, + "Frequency": 62 + }, + { + "Time": 84, + "Intensity": 0.32, + "Frequency": 66 + }, + { + "Time": 100, + "Intensity": 0.32, + "Frequency": 69 + }, + { + "Time": 117, + "Intensity": 0.18, + "Frequency": 71 + }, + { + "Time": 134, + "Intensity": 0.09, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.16, + "Frequency": 75 + }, + { + "Time": 167, + "Intensity": 0.21, + "Frequency": 76 + }, + { + "Time": 184, + "Intensity": 0.28, + "Frequency": 77 + }, + { + "Time": 200, + "Intensity": 0.12, + "Frequency": 75 + }, + { + "Time": 217, + "Intensity": 0.2, + "Frequency": 73 + }, + { + "Time": 234, + "Intensity": 0.13, + "Frequency": 74 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 75 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 290, + "Parameters": { + "Intensity": 51, + "Frequency": 83 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 342, + "Parameters": { + "Intensity": 41, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 395, + "Parameters": { + "Intensity": 30, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 446, + "Parameters": { + "Intensity": 21, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 483, + "Parameters": { + "Intensity": 16, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 222, + "StartTime": 504, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 74 + }, + { + "Time": 14, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 25, + "Intensity": 0.17, + "Frequency": 75 + }, + { + "Time": 38, + "Intensity": 0.22, + "Frequency": 75 + }, + { + "Time": 58, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 73, + "Intensity": 0.05, + "Frequency": 78 + }, + { + "Time": 88, + "Intensity": 0.07, + "Frequency": 79 + }, + { + "Time": 101, + "Intensity": 0.12, + "Frequency": 81 + }, + { + "Time": 118, + "Intensity": 0.27, + "Frequency": 80 + }, + { + "Time": 132, + "Intensity": 0.22, + "Frequency": 79 + }, + { + "Time": 147, + "Intensity": 0.12, + "Frequency": 79 + }, + { + "Time": 161, + "Intensity": 0.1, + "Frequency": 78 + }, + { + "Time": 176, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 191, + "Intensity": 0.22, + "Frequency": 75 + }, + { + "Time": 202, + "Intensity": 0.18, + "Frequency": 76 + }, + { + "Time": 222, + "Intensity": 0, + "Frequency": 76 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 727, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 76 + }, + { + "Time": 17, + "Intensity": 0.07, + "Frequency": 76 + }, + { + "Time": 33, + "Intensity": 0.07, + "Frequency": 76 + }, + { + "Time": 50, + "Intensity": 0.06, + "Frequency": 78 + }, + { + "Time": 67, + "Intensity": 0.03, + "Frequency": 76 + }, + { + "Time": 83, + "Intensity": 0.03, + "Frequency": 76 + }, + { + "Time": 100, + "Intensity": 0.04, + "Frequency": 74 + }, + { + "Time": 116, + "Intensity": 0.11, + "Frequency": 80 + }, + { + "Time": 132, + "Intensity": 0.07, + "Frequency": 81 + }, + { + "Time": 150, + "Intensity": 0.05, + "Frequency": 79 + }, + { + "Time": 167, + "Intensity": 0.02, + "Frequency": 75 + }, + { + "Time": 183, + "Intensity": 0.01, + "Frequency": 73 + }, + { + "Time": 198, + "Intensity": 0.03, + "Frequency": 74 + }, + { + "Time": 216, + "Intensity": 0.06, + "Frequency": 73 + }, + { + "Time": 234, + "Intensity": 0.04, + "Frequency": 73 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 74 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_m.json index d95d9c2020..4a6e651ff0 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarCrash_m.json @@ -1,532 +1,532 @@ -{ - "MetaData": { - "Create": "2022-09-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2, - "Parameters": { - "Intensity": 80, - "Frequency": 10, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37 - }, - { - "Time": 30, - "Intensity": 0.08, - "Frequency": 45 - }, - { - "Time": 47, - "Intensity": 0.14, - "Frequency": 47 - }, - { - "Time": 58, - "Intensity": 0.23, - "Frequency": 48 - }, - { - "Time": 75, - "Intensity": 0.52, - "Frequency": 46 - }, - { - "Time": 89, - "Intensity": 0.93, - "Frequency": 48 - }, - { - "Time": 99, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 124, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 138, - "Intensity": 1, - "Frequency": 52 - }, - { - "Time": 150, - "Intensity": 0.84, - "Frequency": 54 - }, - { - "Time": 166, - "Intensity": 0.72, - "Frequency": 52 - }, - { - "Time": 183, - "Intensity": 0.59, - "Frequency": 50 - }, - { - "Time": 200, - "Intensity": 0.54, - "Frequency": 49 - }, - { - "Time": 217, - "Intensity": 0.32, - "Frequency": 50 - }, - { - "Time": 233, - "Intensity": 0.34, - "Frequency": 50 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 22 - }, - { - "Time": 30, - "Intensity": 0.08, - "Frequency": 39 - }, - { - "Time": 47, - "Intensity": 0.14, - "Frequency": 36 - }, - { - "Time": 60, - "Intensity": 0.24, - "Frequency": 38 - }, - { - "Time": 75, - "Intensity": 0.52, - "Frequency": 39 - }, - { - "Time": 89, - "Intensity": 0.93, - "Frequency": 42 - }, - { - "Time": 99, - "Intensity": 1, - "Frequency": 39 - }, - { - "Time": 124, - "Intensity": 1, - "Frequency": 40 - }, - { - "Time": 138, - "Intensity": 1, - "Frequency": 42 - }, - { - "Time": 150, - "Intensity": 0.84, - "Frequency": 44 - }, - { - "Time": 166, - "Intensity": 0.72, - "Frequency": 42 - }, - { - "Time": 183, - "Intensity": 0.59, - "Frequency": 40 - }, - { - "Time": 200, - "Intensity": 0.54, - "Frequency": 39 - }, - { - "Time": 217, - "Intensity": 0.32, - "Frequency": 42 - }, - { - "Time": 233, - "Intensity": 0.34, - "Frequency": 40 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 40 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 254, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 17, - "Intensity": 0.15, - "Frequency": 60 - }, - { - "Time": 34, - "Intensity": 0.25, - "Frequency": 57 - }, - { - "Time": 50, - "Intensity": 0.19, - "Frequency": 59 - }, - { - "Time": 67, - "Intensity": 0.22, - "Frequency": 62 - }, - { - "Time": 84, - "Intensity": 0.32, - "Frequency": 66 - }, - { - "Time": 100, - "Intensity": 0.32, - "Frequency": 69 - }, - { - "Time": 117, - "Intensity": 0.18, - "Frequency": 71 - }, - { - "Time": 134, - "Intensity": 0.09, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.16, - "Frequency": 75 - }, - { - "Time": 167, - "Intensity": 0.21, - "Frequency": 76 - }, - { - "Time": 184, - "Intensity": 0.28, - "Frequency": 77 - }, - { - "Time": 200, - "Intensity": 0.12, - "Frequency": 75 - }, - { - "Time": 217, - "Intensity": 0.2, - "Frequency": 73 - }, - { - "Time": 234, - "Intensity": 0.13, - "Frequency": 74 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 75 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 290, - "Parameters": { - "Intensity": 68, - "Frequency": 83 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 342, - "Parameters": { - "Intensity": 55, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 395, - "Parameters": { - "Intensity": 40, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 446, - "Parameters": { - "Intensity": 28, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 483, - "Parameters": { - "Intensity": 21, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 222, - "StartTime": 504, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 74 - }, - { - "Time": 14, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 25, - "Intensity": 0.17, - "Frequency": 75 - }, - { - "Time": 38, - "Intensity": 0.22, - "Frequency": 75 - }, - { - "Time": 58, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 73, - "Intensity": 0.05, - "Frequency": 78 - }, - { - "Time": 88, - "Intensity": 0.07, - "Frequency": 79 - }, - { - "Time": 101, - "Intensity": 0.12, - "Frequency": 81 - }, - { - "Time": 118, - "Intensity": 0.27, - "Frequency": 80 - }, - { - "Time": 132, - "Intensity": 0.22, - "Frequency": 79 - }, - { - "Time": 147, - "Intensity": 0.12, - "Frequency": 79 - }, - { - "Time": 161, - "Intensity": 0.1, - "Frequency": 78 - }, - { - "Time": 176, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 191, - "Intensity": 0.22, - "Frequency": 75 - }, - { - "Time": 202, - "Intensity": 0.18, - "Frequency": 76 - }, - { - "Time": 222, - "Intensity": 0, - "Frequency": 76 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 727, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 76 - }, - { - "Time": 17, - "Intensity": 0.07, - "Frequency": 76 - }, - { - "Time": 33, - "Intensity": 0.07, - "Frequency": 76 - }, - { - "Time": 50, - "Intensity": 0.06, - "Frequency": 78 - }, - { - "Time": 67, - "Intensity": 0.03, - "Frequency": 76 - }, - { - "Time": 83, - "Intensity": 0.03, - "Frequency": 76 - }, - { - "Time": 100, - "Intensity": 0.04, - "Frequency": 74 - }, - { - "Time": 116, - "Intensity": 0.11, - "Frequency": 80 - }, - { - "Time": 132, - "Intensity": 0.07, - "Frequency": 81 - }, - { - "Time": 150, - "Intensity": 0.05, - "Frequency": 79 - }, - { - "Time": 167, - "Intensity": 0.02, - "Frequency": 75 - }, - { - "Time": 183, - "Intensity": 0.01, - "Frequency": 73 - }, - { - "Time": 198, - "Intensity": 0.03, - "Frequency": 74 - }, - { - "Time": 216, - "Intensity": 0.06, - "Frequency": 73 - }, - { - "Time": 234, - "Intensity": 0.04, - "Frequency": 73 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 74 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-09-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2, + "Parameters": { + "Intensity": 80, + "Frequency": 10, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37 + }, + { + "Time": 30, + "Intensity": 0.08, + "Frequency": 45 + }, + { + "Time": 47, + "Intensity": 0.14, + "Frequency": 47 + }, + { + "Time": 58, + "Intensity": 0.23, + "Frequency": 48 + }, + { + "Time": 75, + "Intensity": 0.52, + "Frequency": 46 + }, + { + "Time": 89, + "Intensity": 0.93, + "Frequency": 48 + }, + { + "Time": 99, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 124, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 138, + "Intensity": 1, + "Frequency": 52 + }, + { + "Time": 150, + "Intensity": 0.84, + "Frequency": 54 + }, + { + "Time": 166, + "Intensity": 0.72, + "Frequency": 52 + }, + { + "Time": 183, + "Intensity": 0.59, + "Frequency": 50 + }, + { + "Time": 200, + "Intensity": 0.54, + "Frequency": 49 + }, + { + "Time": 217, + "Intensity": 0.32, + "Frequency": 50 + }, + { + "Time": 233, + "Intensity": 0.34, + "Frequency": 50 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 22 + }, + { + "Time": 30, + "Intensity": 0.08, + "Frequency": 39 + }, + { + "Time": 47, + "Intensity": 0.14, + "Frequency": 36 + }, + { + "Time": 60, + "Intensity": 0.24, + "Frequency": 38 + }, + { + "Time": 75, + "Intensity": 0.52, + "Frequency": 39 + }, + { + "Time": 89, + "Intensity": 0.93, + "Frequency": 42 + }, + { + "Time": 99, + "Intensity": 1, + "Frequency": 39 + }, + { + "Time": 124, + "Intensity": 1, + "Frequency": 40 + }, + { + "Time": 138, + "Intensity": 1, + "Frequency": 42 + }, + { + "Time": 150, + "Intensity": 0.84, + "Frequency": 44 + }, + { + "Time": 166, + "Intensity": 0.72, + "Frequency": 42 + }, + { + "Time": 183, + "Intensity": 0.59, + "Frequency": 40 + }, + { + "Time": 200, + "Intensity": 0.54, + "Frequency": 39 + }, + { + "Time": 217, + "Intensity": 0.32, + "Frequency": 42 + }, + { + "Time": 233, + "Intensity": 0.34, + "Frequency": 40 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 40 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 254, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 17, + "Intensity": 0.15, + "Frequency": 60 + }, + { + "Time": 34, + "Intensity": 0.25, + "Frequency": 57 + }, + { + "Time": 50, + "Intensity": 0.19, + "Frequency": 59 + }, + { + "Time": 67, + "Intensity": 0.22, + "Frequency": 62 + }, + { + "Time": 84, + "Intensity": 0.32, + "Frequency": 66 + }, + { + "Time": 100, + "Intensity": 0.32, + "Frequency": 69 + }, + { + "Time": 117, + "Intensity": 0.18, + "Frequency": 71 + }, + { + "Time": 134, + "Intensity": 0.09, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.16, + "Frequency": 75 + }, + { + "Time": 167, + "Intensity": 0.21, + "Frequency": 76 + }, + { + "Time": 184, + "Intensity": 0.28, + "Frequency": 77 + }, + { + "Time": 200, + "Intensity": 0.12, + "Frequency": 75 + }, + { + "Time": 217, + "Intensity": 0.2, + "Frequency": 73 + }, + { + "Time": 234, + "Intensity": 0.13, + "Frequency": 74 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 75 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 290, + "Parameters": { + "Intensity": 68, + "Frequency": 83 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 342, + "Parameters": { + "Intensity": 55, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 395, + "Parameters": { + "Intensity": 40, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 446, + "Parameters": { + "Intensity": 28, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 483, + "Parameters": { + "Intensity": 21, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 222, + "StartTime": 504, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 74 + }, + { + "Time": 14, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 25, + "Intensity": 0.17, + "Frequency": 75 + }, + { + "Time": 38, + "Intensity": 0.22, + "Frequency": 75 + }, + { + "Time": 58, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 73, + "Intensity": 0.05, + "Frequency": 78 + }, + { + "Time": 88, + "Intensity": 0.07, + "Frequency": 79 + }, + { + "Time": 101, + "Intensity": 0.12, + "Frequency": 81 + }, + { + "Time": 118, + "Intensity": 0.27, + "Frequency": 80 + }, + { + "Time": 132, + "Intensity": 0.22, + "Frequency": 79 + }, + { + "Time": 147, + "Intensity": 0.12, + "Frequency": 79 + }, + { + "Time": 161, + "Intensity": 0.1, + "Frequency": 78 + }, + { + "Time": 176, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 191, + "Intensity": 0.22, + "Frequency": 75 + }, + { + "Time": 202, + "Intensity": 0.18, + "Frequency": 76 + }, + { + "Time": 222, + "Intensity": 0, + "Frequency": 76 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 727, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 76 + }, + { + "Time": 17, + "Intensity": 0.07, + "Frequency": 76 + }, + { + "Time": 33, + "Intensity": 0.07, + "Frequency": 76 + }, + { + "Time": 50, + "Intensity": 0.06, + "Frequency": 78 + }, + { + "Time": 67, + "Intensity": 0.03, + "Frequency": 76 + }, + { + "Time": 83, + "Intensity": 0.03, + "Frequency": 76 + }, + { + "Time": 100, + "Intensity": 0.04, + "Frequency": 74 + }, + { + "Time": 116, + "Intensity": 0.11, + "Frequency": 80 + }, + { + "Time": 132, + "Intensity": 0.07, + "Frequency": 81 + }, + { + "Time": 150, + "Intensity": 0.05, + "Frequency": 79 + }, + { + "Time": 167, + "Intensity": 0.02, + "Frequency": 75 + }, + { + "Time": 183, + "Intensity": 0.01, + "Frequency": 73 + }, + { + "Time": 198, + "Intensity": 0.03, + "Frequency": 74 + }, + { + "Time": 216, + "Intensity": 0.06, + "Frequency": 73 + }, + { + "Time": 234, + "Intensity": 0.04, + "Frequency": 73 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 74 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_h.json index 05b88416e8..771aca2e49 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_h.json @@ -1,256 +1,256 @@ -{ - "MetaData": { - "Create": "2022-04-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 672, - "StartTime": 90, - "Parameters": { - "Intensity": 85, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -3 - }, - { - "Time": 26, - "Intensity": 0.87, - "Frequency": 6 - }, - { - "Time": 54, - "Intensity": 0.96, - "Frequency": 9 - }, - { - "Time": 73, - "Intensity": 0.19, - "Frequency": -11 - }, - { - "Time": 110, - "Intensity": 0.79, - "Frequency": -1 - }, - { - "Time": 151, - "Intensity": 0.19, - "Frequency": -9 - }, - { - "Time": 264, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 331, - "Intensity": 0.76, - "Frequency": 0 - }, - { - "Time": 345, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 380, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 425, - "Intensity": 0.7, - "Frequency": 0 - }, - { - "Time": 452, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 499, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 571, - "Intensity": 0.89, - "Frequency": 0 - }, - { - "Time": 599, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 672, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 672, - "StartTime": 96, - "Parameters": { - "Intensity": 85, - "Frequency": 60, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -3 - }, - { - "Time": 26, - "Intensity": 0.87, - "Frequency": 6 - }, - { - "Time": 54, - "Intensity": 0.96, - "Frequency": 9 - }, - { - "Time": 73, - "Intensity": 0.19, - "Frequency": -11 - }, - { - "Time": 110, - "Intensity": 0.79, - "Frequency": -1 - }, - { - "Time": 151, - "Intensity": 0.19, - "Frequency": -9 - }, - { - "Time": 176, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 319, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 672, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1300, - "StartTime": 768, - "Parameters": { - "Intensity": 100, - "Frequency": 57, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -73 - }, - { - "Time": 105, - "Intensity": 0.32, - "Frequency": -58 - }, - { - "Time": 179, - "Intensity": 1, - "Frequency": -8 - }, - { - "Time": 218, - "Intensity": 0.98, - "Frequency": 0 - }, - { - "Time": 314, - "Intensity": 0.2, - "Frequency": -10 - }, - { - "Time": 443, - "Intensity": 0.1, - "Frequency": -33 - }, - { - "Time": 547, - "Intensity": 0.08, - "Frequency": 0 - }, - { - "Time": 646, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 729, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 840, - "Intensity": 0.06, - "Frequency": 0 - }, - { - "Time": 906, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 962, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 1005, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 1067, - "Intensity": 0.04, - "Frequency": 0 - }, - { - "Time": 1300, - "Intensity": 0, - "Frequency": -32 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 672, + "StartTime": 90, + "Parameters": { + "Intensity": 85, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -3 + }, + { + "Time": 26, + "Intensity": 0.87, + "Frequency": 6 + }, + { + "Time": 54, + "Intensity": 0.96, + "Frequency": 9 + }, + { + "Time": 73, + "Intensity": 0.19, + "Frequency": -11 + }, + { + "Time": 110, + "Intensity": 0.79, + "Frequency": -1 + }, + { + "Time": 151, + "Intensity": 0.19, + "Frequency": -9 + }, + { + "Time": 264, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 331, + "Intensity": 0.76, + "Frequency": 0 + }, + { + "Time": 345, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 380, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 425, + "Intensity": 0.7, + "Frequency": 0 + }, + { + "Time": 452, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 499, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 571, + "Intensity": 0.89, + "Frequency": 0 + }, + { + "Time": 599, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 672, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 672, + "StartTime": 96, + "Parameters": { + "Intensity": 85, + "Frequency": 60, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -3 + }, + { + "Time": 26, + "Intensity": 0.87, + "Frequency": 6 + }, + { + "Time": 54, + "Intensity": 0.96, + "Frequency": 9 + }, + { + "Time": 73, + "Intensity": 0.19, + "Frequency": -11 + }, + { + "Time": 110, + "Intensity": 0.79, + "Frequency": -1 + }, + { + "Time": 151, + "Intensity": 0.19, + "Frequency": -9 + }, + { + "Time": 176, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 319, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 672, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1300, + "StartTime": 768, + "Parameters": { + "Intensity": 100, + "Frequency": 57, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -73 + }, + { + "Time": 105, + "Intensity": 0.32, + "Frequency": -58 + }, + { + "Time": 179, + "Intensity": 1, + "Frequency": -8 + }, + { + "Time": 218, + "Intensity": 0.98, + "Frequency": 0 + }, + { + "Time": 314, + "Intensity": 0.2, + "Frequency": -10 + }, + { + "Time": 443, + "Intensity": 0.1, + "Frequency": -33 + }, + { + "Time": 547, + "Intensity": 0.08, + "Frequency": 0 + }, + { + "Time": 646, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 729, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 840, + "Intensity": 0.06, + "Frequency": 0 + }, + { + "Time": 906, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 962, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 1005, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 1067, + "Intensity": 0.04, + "Frequency": 0 + }, + { + "Time": 1300, + "Intensity": 0, + "Frequency": -32 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_l.json index 6184919420..96d98b6903 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_l.json @@ -1,256 +1,256 @@ -{ - "MetaData": { - "Create": "2022-04-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 672, - "StartTime": 90, - "Parameters": { - "Intensity": 51, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -3 - }, - { - "Time": 26, - "Intensity": 0.87, - "Frequency": 6 - }, - { - "Time": 54, - "Intensity": 0.96, - "Frequency": 9 - }, - { - "Time": 73, - "Intensity": 0.19, - "Frequency": -11 - }, - { - "Time": 110, - "Intensity": 0.79, - "Frequency": -1 - }, - { - "Time": 151, - "Intensity": 0.19, - "Frequency": -9 - }, - { - "Time": 264, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 331, - "Intensity": 0.76, - "Frequency": 0 - }, - { - "Time": 345, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 380, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 425, - "Intensity": 0.7, - "Frequency": 0 - }, - { - "Time": 452, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 499, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 571, - "Intensity": 0.89, - "Frequency": 0 - }, - { - "Time": 599, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 672, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 672, - "StartTime": 96, - "Parameters": { - "Intensity": 51, - "Frequency": 60, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -3 - }, - { - "Time": 26, - "Intensity": 0.87, - "Frequency": 6 - }, - { - "Time": 54, - "Intensity": 0.96, - "Frequency": 9 - }, - { - "Time": 73, - "Intensity": 0.19, - "Frequency": -11 - }, - { - "Time": 110, - "Intensity": 0.79, - "Frequency": -1 - }, - { - "Time": 151, - "Intensity": 0.19, - "Frequency": -9 - }, - { - "Time": 176, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 319, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 672, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1300, - "StartTime": 768, - "Parameters": { - "Intensity": 60, - "Frequency": 57, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -73 - }, - { - "Time": 105, - "Intensity": 0.32, - "Frequency": -58 - }, - { - "Time": 179, - "Intensity": 1, - "Frequency": -8 - }, - { - "Time": 218, - "Intensity": 0.98, - "Frequency": 0 - }, - { - "Time": 314, - "Intensity": 0.2, - "Frequency": -10 - }, - { - "Time": 443, - "Intensity": 0.1, - "Frequency": -33 - }, - { - "Time": 547, - "Intensity": 0.08, - "Frequency": 0 - }, - { - "Time": 646, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 729, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 840, - "Intensity": 0.06, - "Frequency": 0 - }, - { - "Time": 906, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 962, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 1005, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 1067, - "Intensity": 0.04, - "Frequency": 0 - }, - { - "Time": 1300, - "Intensity": 0, - "Frequency": -32 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 672, + "StartTime": 90, + "Parameters": { + "Intensity": 51, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -3 + }, + { + "Time": 26, + "Intensity": 0.87, + "Frequency": 6 + }, + { + "Time": 54, + "Intensity": 0.96, + "Frequency": 9 + }, + { + "Time": 73, + "Intensity": 0.19, + "Frequency": -11 + }, + { + "Time": 110, + "Intensity": 0.79, + "Frequency": -1 + }, + { + "Time": 151, + "Intensity": 0.19, + "Frequency": -9 + }, + { + "Time": 264, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 331, + "Intensity": 0.76, + "Frequency": 0 + }, + { + "Time": 345, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 380, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 425, + "Intensity": 0.7, + "Frequency": 0 + }, + { + "Time": 452, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 499, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 571, + "Intensity": 0.89, + "Frequency": 0 + }, + { + "Time": 599, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 672, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 672, + "StartTime": 96, + "Parameters": { + "Intensity": 51, + "Frequency": 60, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -3 + }, + { + "Time": 26, + "Intensity": 0.87, + "Frequency": 6 + }, + { + "Time": 54, + "Intensity": 0.96, + "Frequency": 9 + }, + { + "Time": 73, + "Intensity": 0.19, + "Frequency": -11 + }, + { + "Time": 110, + "Intensity": 0.79, + "Frequency": -1 + }, + { + "Time": 151, + "Intensity": 0.19, + "Frequency": -9 + }, + { + "Time": 176, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 319, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 672, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1300, + "StartTime": 768, + "Parameters": { + "Intensity": 60, + "Frequency": 57, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -73 + }, + { + "Time": 105, + "Intensity": 0.32, + "Frequency": -58 + }, + { + "Time": 179, + "Intensity": 1, + "Frequency": -8 + }, + { + "Time": 218, + "Intensity": 0.98, + "Frequency": 0 + }, + { + "Time": 314, + "Intensity": 0.2, + "Frequency": -10 + }, + { + "Time": 443, + "Intensity": 0.1, + "Frequency": -33 + }, + { + "Time": 547, + "Intensity": 0.08, + "Frequency": 0 + }, + { + "Time": 646, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 729, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 840, + "Intensity": 0.06, + "Frequency": 0 + }, + { + "Time": 906, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 962, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 1005, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 1067, + "Intensity": 0.04, + "Frequency": 0 + }, + { + "Time": 1300, + "Intensity": 0, + "Frequency": -32 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_m.json index 898953b911..056dce1765 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarIgnite_m.json @@ -1,256 +1,256 @@ -{ - "MetaData": { - "Create": "2022-04-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 672, - "StartTime": 90, - "Parameters": { - "Intensity": 68, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -3 - }, - { - "Time": 26, - "Intensity": 0.87, - "Frequency": 6 - }, - { - "Time": 54, - "Intensity": 0.96, - "Frequency": 9 - }, - { - "Time": 73, - "Intensity": 0.19, - "Frequency": -11 - }, - { - "Time": 110, - "Intensity": 0.79, - "Frequency": -1 - }, - { - "Time": 151, - "Intensity": 0.19, - "Frequency": -9 - }, - { - "Time": 264, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 331, - "Intensity": 0.76, - "Frequency": 0 - }, - { - "Time": 345, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 380, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 425, - "Intensity": 0.7, - "Frequency": 0 - }, - { - "Time": 452, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 499, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 571, - "Intensity": 0.89, - "Frequency": 0 - }, - { - "Time": 599, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 672, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 672, - "StartTime": 96, - "Parameters": { - "Intensity": 68, - "Frequency": 60, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -3 - }, - { - "Time": 26, - "Intensity": 0.87, - "Frequency": 6 - }, - { - "Time": 54, - "Intensity": 0.96, - "Frequency": 9 - }, - { - "Time": 73, - "Intensity": 0.19, - "Frequency": -11 - }, - { - "Time": 110, - "Intensity": 0.79, - "Frequency": -1 - }, - { - "Time": 151, - "Intensity": 0.19, - "Frequency": -9 - }, - { - "Time": 176, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 319, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 672, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1300, - "StartTime": 768, - "Parameters": { - "Intensity": 80, - "Frequency": 57, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -73 - }, - { - "Time": 105, - "Intensity": 0.32, - "Frequency": -58 - }, - { - "Time": 179, - "Intensity": 1, - "Frequency": -8 - }, - { - "Time": 218, - "Intensity": 0.98, - "Frequency": 0 - }, - { - "Time": 314, - "Intensity": 0.2, - "Frequency": -10 - }, - { - "Time": 443, - "Intensity": 0.1, - "Frequency": -33 - }, - { - "Time": 547, - "Intensity": 0.08, - "Frequency": 0 - }, - { - "Time": 646, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 729, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 840, - "Intensity": 0.06, - "Frequency": 0 - }, - { - "Time": 906, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 962, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 1005, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 1067, - "Intensity": 0.04, - "Frequency": 0 - }, - { - "Time": 1300, - "Intensity": 0, - "Frequency": -32 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 672, + "StartTime": 90, + "Parameters": { + "Intensity": 68, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -3 + }, + { + "Time": 26, + "Intensity": 0.87, + "Frequency": 6 + }, + { + "Time": 54, + "Intensity": 0.96, + "Frequency": 9 + }, + { + "Time": 73, + "Intensity": 0.19, + "Frequency": -11 + }, + { + "Time": 110, + "Intensity": 0.79, + "Frequency": -1 + }, + { + "Time": 151, + "Intensity": 0.19, + "Frequency": -9 + }, + { + "Time": 264, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 331, + "Intensity": 0.76, + "Frequency": 0 + }, + { + "Time": 345, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 380, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 425, + "Intensity": 0.7, + "Frequency": 0 + }, + { + "Time": 452, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 499, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 571, + "Intensity": 0.89, + "Frequency": 0 + }, + { + "Time": 599, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 672, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 672, + "StartTime": 96, + "Parameters": { + "Intensity": 68, + "Frequency": 60, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -3 + }, + { + "Time": 26, + "Intensity": 0.87, + "Frequency": 6 + }, + { + "Time": 54, + "Intensity": 0.96, + "Frequency": 9 + }, + { + "Time": 73, + "Intensity": 0.19, + "Frequency": -11 + }, + { + "Time": 110, + "Intensity": 0.79, + "Frequency": -1 + }, + { + "Time": 151, + "Intensity": 0.19, + "Frequency": -9 + }, + { + "Time": 176, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 319, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 672, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1300, + "StartTime": 768, + "Parameters": { + "Intensity": 80, + "Frequency": 57, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -73 + }, + { + "Time": 105, + "Intensity": 0.32, + "Frequency": -58 + }, + { + "Time": 179, + "Intensity": 1, + "Frequency": -8 + }, + { + "Time": 218, + "Intensity": 0.98, + "Frequency": 0 + }, + { + "Time": 314, + "Intensity": 0.2, + "Frequency": -10 + }, + { + "Time": 443, + "Intensity": 0.1, + "Frequency": -33 + }, + { + "Time": 547, + "Intensity": 0.08, + "Frequency": 0 + }, + { + "Time": 646, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 729, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 840, + "Intensity": 0.06, + "Frequency": 0 + }, + { + "Time": 906, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 962, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 1005, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 1067, + "Intensity": 0.04, + "Frequency": 0 + }, + { + "Time": 1300, + "Intensity": 0, + "Frequency": -32 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_h.json index 91f9c35cf1..a70ce486a0 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_h.json @@ -1,203 +1,203 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 4838, - "StartTime": 23, - "Parameters": { - "Intensity": 95, - "Frequency": 44, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 126, - "Intensity": 0.36, - "Frequency": 0 - }, - { - "Time": 339, - "Intensity": 0.76, - "Frequency": 2 - }, - { - "Time": 576, - "Intensity": 0.84, - "Frequency": 0 - }, - { - "Time": 997, - "Intensity": 0.6, - "Frequency": 0 - }, - { - "Time": 1301, - "Intensity": 0.87, - "Frequency": 0 - }, - { - "Time": 2032, - "Intensity": 0.97, - "Frequency": 3 - }, - { - "Time": 2424, - "Intensity": 0.61, - "Frequency": 0 - }, - { - "Time": 2753, - "Intensity": 1, - "Frequency": 4 - }, - { - "Time": 2975, - "Intensity": 0.93, - "Frequency": 5 - }, - { - "Time": 3232, - "Intensity": 0.27, - "Frequency": 0 - }, - { - "Time": 3851, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 4107, - "Intensity": 0.44, - "Frequency": 11 - }, - { - "Time": 4354, - "Intensity": 0.4, - "Frequency": 16 - }, - { - "Time": 4519, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 4838, - "Intensity": 0, - "Frequency": 2 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 4838, - "StartTime": 30, - "Parameters": { - "Intensity": 95, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 126, - "Intensity": 0.36, - "Frequency": 0 - }, - { - "Time": 339, - "Intensity": 0.76, - "Frequency": 2 - }, - { - "Time": 576, - "Intensity": 0.84, - "Frequency": 0 - }, - { - "Time": 997, - "Intensity": 0.6, - "Frequency": 0 - }, - { - "Time": 1301, - "Intensity": 0.87, - "Frequency": 0 - }, - { - "Time": 2032, - "Intensity": 0.97, - "Frequency": 3 - }, - { - "Time": 2424, - "Intensity": 0.61, - "Frequency": 0 - }, - { - "Time": 2758, - "Intensity": 1, - "Frequency": 7 - }, - { - "Time": 3038, - "Intensity": 0.92, - "Frequency": 8 - }, - { - "Time": 3227, - "Intensity": 0.28, - "Frequency": 0 - }, - { - "Time": 3851, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 4122, - "Intensity": 0.4, - "Frequency": 9 - }, - { - "Time": 4417, - "Intensity": 0.36, - "Frequency": 5 - }, - { - "Time": 4625, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 4838, - "Intensity": 0, - "Frequency": 2 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 4838, + "StartTime": 23, + "Parameters": { + "Intensity": 95, + "Frequency": 44, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 126, + "Intensity": 0.36, + "Frequency": 0 + }, + { + "Time": 339, + "Intensity": 0.76, + "Frequency": 2 + }, + { + "Time": 576, + "Intensity": 0.84, + "Frequency": 0 + }, + { + "Time": 997, + "Intensity": 0.6, + "Frequency": 0 + }, + { + "Time": 1301, + "Intensity": 0.87, + "Frequency": 0 + }, + { + "Time": 2032, + "Intensity": 0.97, + "Frequency": 3 + }, + { + "Time": 2424, + "Intensity": 0.61, + "Frequency": 0 + }, + { + "Time": 2753, + "Intensity": 1, + "Frequency": 4 + }, + { + "Time": 2975, + "Intensity": 0.93, + "Frequency": 5 + }, + { + "Time": 3232, + "Intensity": 0.27, + "Frequency": 0 + }, + { + "Time": 3851, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 4107, + "Intensity": 0.44, + "Frequency": 11 + }, + { + "Time": 4354, + "Intensity": 0.4, + "Frequency": 16 + }, + { + "Time": 4519, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 4838, + "Intensity": 0, + "Frequency": 2 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 4838, + "StartTime": 30, + "Parameters": { + "Intensity": 95, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 126, + "Intensity": 0.36, + "Frequency": 0 + }, + { + "Time": 339, + "Intensity": 0.76, + "Frequency": 2 + }, + { + "Time": 576, + "Intensity": 0.84, + "Frequency": 0 + }, + { + "Time": 997, + "Intensity": 0.6, + "Frequency": 0 + }, + { + "Time": 1301, + "Intensity": 0.87, + "Frequency": 0 + }, + { + "Time": 2032, + "Intensity": 0.97, + "Frequency": 3 + }, + { + "Time": 2424, + "Intensity": 0.61, + "Frequency": 0 + }, + { + "Time": 2758, + "Intensity": 1, + "Frequency": 7 + }, + { + "Time": 3038, + "Intensity": 0.92, + "Frequency": 8 + }, + { + "Time": 3227, + "Intensity": 0.28, + "Frequency": 0 + }, + { + "Time": 3851, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 4122, + "Intensity": 0.4, + "Frequency": 9 + }, + { + "Time": 4417, + "Intensity": 0.36, + "Frequency": 5 + }, + { + "Time": 4625, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 4838, + "Intensity": 0, + "Frequency": 2 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_l.json index dfacbfafd7..9ad3327ba2 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_l.json @@ -1,203 +1,203 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 4838, - "StartTime": 23, - "Parameters": { - "Intensity": 57, - "Frequency": 44, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 126, - "Intensity": 0.36, - "Frequency": 0 - }, - { - "Time": 339, - "Intensity": 0.76, - "Frequency": 2 - }, - { - "Time": 576, - "Intensity": 0.84, - "Frequency": 0 - }, - { - "Time": 997, - "Intensity": 0.6, - "Frequency": 0 - }, - { - "Time": 1301, - "Intensity": 0.87, - "Frequency": 0 - }, - { - "Time": 2032, - "Intensity": 0.97, - "Frequency": 3 - }, - { - "Time": 2424, - "Intensity": 0.61, - "Frequency": 0 - }, - { - "Time": 2753, - "Intensity": 1, - "Frequency": 4 - }, - { - "Time": 2975, - "Intensity": 0.93, - "Frequency": 5 - }, - { - "Time": 3232, - "Intensity": 0.27, - "Frequency": 0 - }, - { - "Time": 3851, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 4107, - "Intensity": 0.44, - "Frequency": 11 - }, - { - "Time": 4354, - "Intensity": 0.4, - "Frequency": 16 - }, - { - "Time": 4519, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 4838, - "Intensity": 0, - "Frequency": 2 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 4838, - "StartTime": 30, - "Parameters": { - "Intensity": 57, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 126, - "Intensity": 0.36, - "Frequency": 0 - }, - { - "Time": 339, - "Intensity": 0.76, - "Frequency": 2 - }, - { - "Time": 576, - "Intensity": 0.84, - "Frequency": 0 - }, - { - "Time": 997, - "Intensity": 0.6, - "Frequency": 0 - }, - { - "Time": 1301, - "Intensity": 0.87, - "Frequency": 0 - }, - { - "Time": 2032, - "Intensity": 0.97, - "Frequency": 3 - }, - { - "Time": 2424, - "Intensity": 0.61, - "Frequency": 0 - }, - { - "Time": 2758, - "Intensity": 1, - "Frequency": 7 - }, - { - "Time": 3038, - "Intensity": 0.92, - "Frequency": 8 - }, - { - "Time": 3227, - "Intensity": 0.28, - "Frequency": 0 - }, - { - "Time": 3851, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 4122, - "Intensity": 0.4, - "Frequency": 9 - }, - { - "Time": 4417, - "Intensity": 0.36, - "Frequency": 5 - }, - { - "Time": 4625, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 4838, - "Intensity": 0, - "Frequency": 2 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 4838, + "StartTime": 23, + "Parameters": { + "Intensity": 57, + "Frequency": 44, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 126, + "Intensity": 0.36, + "Frequency": 0 + }, + { + "Time": 339, + "Intensity": 0.76, + "Frequency": 2 + }, + { + "Time": 576, + "Intensity": 0.84, + "Frequency": 0 + }, + { + "Time": 997, + "Intensity": 0.6, + "Frequency": 0 + }, + { + "Time": 1301, + "Intensity": 0.87, + "Frequency": 0 + }, + { + "Time": 2032, + "Intensity": 0.97, + "Frequency": 3 + }, + { + "Time": 2424, + "Intensity": 0.61, + "Frequency": 0 + }, + { + "Time": 2753, + "Intensity": 1, + "Frequency": 4 + }, + { + "Time": 2975, + "Intensity": 0.93, + "Frequency": 5 + }, + { + "Time": 3232, + "Intensity": 0.27, + "Frequency": 0 + }, + { + "Time": 3851, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 4107, + "Intensity": 0.44, + "Frequency": 11 + }, + { + "Time": 4354, + "Intensity": 0.4, + "Frequency": 16 + }, + { + "Time": 4519, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 4838, + "Intensity": 0, + "Frequency": 2 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 4838, + "StartTime": 30, + "Parameters": { + "Intensity": 57, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 126, + "Intensity": 0.36, + "Frequency": 0 + }, + { + "Time": 339, + "Intensity": 0.76, + "Frequency": 2 + }, + { + "Time": 576, + "Intensity": 0.84, + "Frequency": 0 + }, + { + "Time": 997, + "Intensity": 0.6, + "Frequency": 0 + }, + { + "Time": 1301, + "Intensity": 0.87, + "Frequency": 0 + }, + { + "Time": 2032, + "Intensity": 0.97, + "Frequency": 3 + }, + { + "Time": 2424, + "Intensity": 0.61, + "Frequency": 0 + }, + { + "Time": 2758, + "Intensity": 1, + "Frequency": 7 + }, + { + "Time": 3038, + "Intensity": 0.92, + "Frequency": 8 + }, + { + "Time": 3227, + "Intensity": 0.28, + "Frequency": 0 + }, + { + "Time": 3851, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 4122, + "Intensity": 0.4, + "Frequency": 9 + }, + { + "Time": 4417, + "Intensity": 0.36, + "Frequency": 5 + }, + { + "Time": 4625, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 4838, + "Intensity": 0, + "Frequency": 2 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_m.json index 1ef16f9bd9..7d11120217 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CarSkid_m.json @@ -1,203 +1,203 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 4838, - "StartTime": 23, - "Parameters": { - "Intensity": 76, - "Frequency": 44, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 126, - "Intensity": 0.36, - "Frequency": 0 - }, - { - "Time": 339, - "Intensity": 0.76, - "Frequency": 2 - }, - { - "Time": 576, - "Intensity": 0.84, - "Frequency": 0 - }, - { - "Time": 997, - "Intensity": 0.6, - "Frequency": 0 - }, - { - "Time": 1301, - "Intensity": 0.87, - "Frequency": 0 - }, - { - "Time": 2032, - "Intensity": 0.97, - "Frequency": 3 - }, - { - "Time": 2424, - "Intensity": 0.61, - "Frequency": 0 - }, - { - "Time": 2753, - "Intensity": 1, - "Frequency": 4 - }, - { - "Time": 2975, - "Intensity": 0.93, - "Frequency": 5 - }, - { - "Time": 3232, - "Intensity": 0.27, - "Frequency": 0 - }, - { - "Time": 3851, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 4107, - "Intensity": 0.44, - "Frequency": 11 - }, - { - "Time": 4354, - "Intensity": 0.4, - "Frequency": 16 - }, - { - "Time": 4519, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 4838, - "Intensity": 0, - "Frequency": 2 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 4838, - "StartTime": 30, - "Parameters": { - "Intensity": 76, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 126, - "Intensity": 0.36, - "Frequency": 0 - }, - { - "Time": 339, - "Intensity": 0.76, - "Frequency": 2 - }, - { - "Time": 576, - "Intensity": 0.84, - "Frequency": 0 - }, - { - "Time": 997, - "Intensity": 0.6, - "Frequency": 0 - }, - { - "Time": 1301, - "Intensity": 0.87, - "Frequency": 0 - }, - { - "Time": 2032, - "Intensity": 0.97, - "Frequency": 3 - }, - { - "Time": 2424, - "Intensity": 0.61, - "Frequency": 0 - }, - { - "Time": 2758, - "Intensity": 1, - "Frequency": 7 - }, - { - "Time": 3038, - "Intensity": 0.92, - "Frequency": 8 - }, - { - "Time": 3227, - "Intensity": 0.28, - "Frequency": 0 - }, - { - "Time": 3851, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 4122, - "Intensity": 0.4, - "Frequency": 9 - }, - { - "Time": 4417, - "Intensity": 0.36, - "Frequency": 5 - }, - { - "Time": 4625, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 4838, - "Intensity": 0, - "Frequency": 2 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 4838, + "StartTime": 23, + "Parameters": { + "Intensity": 76, + "Frequency": 44, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 126, + "Intensity": 0.36, + "Frequency": 0 + }, + { + "Time": 339, + "Intensity": 0.76, + "Frequency": 2 + }, + { + "Time": 576, + "Intensity": 0.84, + "Frequency": 0 + }, + { + "Time": 997, + "Intensity": 0.6, + "Frequency": 0 + }, + { + "Time": 1301, + "Intensity": 0.87, + "Frequency": 0 + }, + { + "Time": 2032, + "Intensity": 0.97, + "Frequency": 3 + }, + { + "Time": 2424, + "Intensity": 0.61, + "Frequency": 0 + }, + { + "Time": 2753, + "Intensity": 1, + "Frequency": 4 + }, + { + "Time": 2975, + "Intensity": 0.93, + "Frequency": 5 + }, + { + "Time": 3232, + "Intensity": 0.27, + "Frequency": 0 + }, + { + "Time": 3851, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 4107, + "Intensity": 0.44, + "Frequency": 11 + }, + { + "Time": 4354, + "Intensity": 0.4, + "Frequency": 16 + }, + { + "Time": 4519, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 4838, + "Intensity": 0, + "Frequency": 2 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 4838, + "StartTime": 30, + "Parameters": { + "Intensity": 76, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 126, + "Intensity": 0.36, + "Frequency": 0 + }, + { + "Time": 339, + "Intensity": 0.76, + "Frequency": 2 + }, + { + "Time": 576, + "Intensity": 0.84, + "Frequency": 0 + }, + { + "Time": 997, + "Intensity": 0.6, + "Frequency": 0 + }, + { + "Time": 1301, + "Intensity": 0.87, + "Frequency": 0 + }, + { + "Time": 2032, + "Intensity": 0.97, + "Frequency": 3 + }, + { + "Time": 2424, + "Intensity": 0.61, + "Frequency": 0 + }, + { + "Time": 2758, + "Intensity": 1, + "Frequency": 7 + }, + { + "Time": 3038, + "Intensity": 0.92, + "Frequency": 8 + }, + { + "Time": 3227, + "Intensity": 0.28, + "Frequency": 0 + }, + { + "Time": 3851, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 4122, + "Intensity": 0.4, + "Frequency": 9 + }, + { + "Time": 4417, + "Intensity": 0.36, + "Frequency": 5 + }, + { + "Time": 4625, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 4838, + "Intensity": 0, + "Frequency": 2 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_h.json index 9778004e68..b984d8e9d3 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_h.json @@ -1,27 +1,27 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 8, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 8, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_l.json index b90f5994d4..e3281ce53f 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_l.json @@ -1,27 +1,27 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 8, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 8, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_m.json index 554b435b35..c8503d44dd 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Claves_m.json @@ -1,27 +1,27 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 8, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 8, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_h.json index ae856f6eb6..164f6aa65e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_h.json @@ -1,116 +1,116 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 0, - "Parameters": { - "Intensity": 100, - "Frequency": 31 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 54, - "StartTime": 40, - "Parameters": { - "Intensity": 38, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 103, - "Parameters": { - "Intensity": 79, - "Frequency": 69 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 180, - "Parameters": { - "Intensity": 53, - "Frequency": 82 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 239, - "Parameters": { - "Intensity": 51, - "Frequency": 82 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 319, - "Parameters": { - "Intensity": 37, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 350, - "Parameters": { - "Intensity": 24, - "Frequency": 44 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 0, + "Parameters": { + "Intensity": 100, + "Frequency": 31 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 54, + "StartTime": 40, + "Parameters": { + "Intensity": 38, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 103, + "Parameters": { + "Intensity": 79, + "Frequency": 69 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 180, + "Parameters": { + "Intensity": 53, + "Frequency": 82 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 239, + "Parameters": { + "Intensity": 51, + "Frequency": 82 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 319, + "Parameters": { + "Intensity": 37, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 350, + "Parameters": { + "Intensity": 24, + "Frequency": 44 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_l.json index de063457a4..98a5fab392 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_l.json @@ -1,116 +1,116 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 0, - "Parameters": { - "Intensity": 60, - "Frequency": 31 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 54, - "StartTime": 40, - "Parameters": { - "Intensity": 22, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 103, - "Parameters": { - "Intensity": 47, - "Frequency": 69 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 180, - "Parameters": { - "Intensity": 31, - "Frequency": 82 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 239, - "Parameters": { - "Intensity": 30, - "Frequency": 82 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 319, - "Parameters": { - "Intensity": 22, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 350, - "Parameters": { - "Intensity": 14, - "Frequency": 44 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 0, + "Parameters": { + "Intensity": 60, + "Frequency": 31 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 54, + "StartTime": 40, + "Parameters": { + "Intensity": 22, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 103, + "Parameters": { + "Intensity": 47, + "Frequency": 69 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 180, + "Parameters": { + "Intensity": 31, + "Frequency": 82 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 239, + "Parameters": { + "Intensity": 30, + "Frequency": 82 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 319, + "Parameters": { + "Intensity": 22, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 350, + "Parameters": { + "Intensity": 14, + "Frequency": 44 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_m.json index 88b2160afd..31efc482f7 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/CoinDrop_m.json @@ -1,116 +1,116 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 0, - "Parameters": { - "Intensity": 80, - "Frequency": 31 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 54, - "StartTime": 40, - "Parameters": { - "Intensity": 30, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 103, - "Parameters": { - "Intensity": 63, - "Frequency": 69 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 180, - "Parameters": { - "Intensity": 42, - "Frequency": 82 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 239, - "Parameters": { - "Intensity": 40, - "Frequency": 82 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 319, - "Parameters": { - "Intensity": 29, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 350, - "Parameters": { - "Intensity": 19, - "Frequency": 44 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 0, + "Parameters": { + "Intensity": 80, + "Frequency": 31 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 54, + "StartTime": 40, + "Parameters": { + "Intensity": 30, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 103, + "Parameters": { + "Intensity": 63, + "Frequency": 69 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 180, + "Parameters": { + "Intensity": 42, + "Frequency": 82 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 239, + "Parameters": { + "Intensity": 40, + "Frequency": 82 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 319, + "Parameters": { + "Intensity": 29, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 350, + "Parameters": { + "Intensity": 19, + "Frequency": 44 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_h.json index 76106e93d4..edda5e767f 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_h.json @@ -1,1327 +1,1327 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 0, - "Parameters": { - "Intensity": 70, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 12, - "Intensity": 0.59, - "Frequency": -47 - }, - { - "Time": 52, - "Intensity": 0.96, - "Frequency": -44 - }, - { - "Time": 100, - "Intensity": 0.53, - "Frequency": -42 - }, - { - "Time": 133, - "Intensity": 0.94, - "Frequency": -39 - }, - { - "Time": 172, - "Intensity": 0.6, - "Frequency": -50 - }, - { - "Time": 210, - "Intensity": 0.38, - "Frequency": -50 - }, - { - "Time": 239, - "Intensity": 0.74, - "Frequency": -45 - }, - { - "Time": 287, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 7, - "Parameters": { - "Intensity": 66, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 18, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 55, - "Intensity": 0.85, - "Frequency": -44 - }, - { - "Time": 106, - "Intensity": 0.64, - "Frequency": -42 - }, - { - "Time": 136, - "Intensity": 0.91, - "Frequency": -39 - }, - { - "Time": 165, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 206, - "Intensity": 0.53, - "Frequency": -50 - }, - { - "Time": 225, - "Intensity": 0.69, - "Frequency": -45 - }, - { - "Time": 294, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 311, - "Parameters": { - "Intensity": 70, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 32, - "Intensity": 0.93, - "Frequency": -50 - }, - { - "Time": 86, - "Intensity": 0.83, - "Frequency": -47 - }, - { - "Time": 145, - "Intensity": 0.43, - "Frequency": -47 - }, - { - "Time": 196, - "Intensity": 1, - "Frequency": -41 - }, - { - "Time": 252, - "Intensity": 0.49, - "Frequency": -50 - }, - { - "Time": 280, - "Intensity": 0.86, - "Frequency": -38 - }, - { - "Time": 322, - "Intensity": 0.57, - "Frequency": -50 - }, - { - "Time": 336, - "Intensity": 0.95, - "Frequency": -38 - }, - { - "Time": 399, - "Intensity": 0.57, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 313, - "Parameters": { - "Intensity": 64, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 9, - "Intensity": 0.49, - "Frequency": -46 - }, - { - "Time": 53, - "Intensity": 0.93, - "Frequency": -47 - }, - { - "Time": 114, - "Intensity": 0.82, - "Frequency": -50 - }, - { - "Time": 149, - "Intensity": 0.59, - "Frequency": -46 - }, - { - "Time": 190, - "Intensity": 0.94, - "Frequency": -38 - }, - { - "Time": 236, - "Intensity": 0.69, - "Frequency": -50 - }, - { - "Time": 264, - "Intensity": 0.82, - "Frequency": -49 - }, - { - "Time": 310, - "Intensity": 0.74, - "Frequency": -46 - }, - { - "Time": 329, - "Intensity": 1, - "Frequency": -39 - }, - { - "Time": 394, - "Intensity": 0.69, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 714, - "Parameters": { - "Intensity": 71, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 5, - "Intensity": 0.73, - "Frequency": -39 - }, - { - "Time": 52, - "Intensity": 0.54, - "Frequency": -48 - }, - { - "Time": 96, - "Intensity": 0.68, - "Frequency": -50 - }, - { - "Time": 118, - "Intensity": 1, - "Frequency": -43 - }, - { - "Time": 161, - "Intensity": 0.81, - "Frequency": -47 - }, - { - "Time": 217, - "Intensity": 0.43, - "Frequency": -50 - }, - { - "Time": 299, - "Intensity": 0.61, - "Frequency": -38 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 716, - "Parameters": { - "Intensity": 65, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 5, - "Intensity": 0.76, - "Frequency": -40 - }, - { - "Time": 47, - "Intensity": 0.76, - "Frequency": -43 - }, - { - "Time": 79, - "Intensity": 0.81, - "Frequency": -50 - }, - { - "Time": 119, - "Intensity": 1, - "Frequency": -41 - }, - { - "Time": 166, - "Intensity": 0.82, - "Frequency": -38 - }, - { - "Time": 202, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 296, - "Intensity": 0.65, - "Frequency": -38 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1016, - "Parameters": { - "Intensity": 74, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 21, - "Intensity": 0.66, - "Frequency": -44 - }, - { - "Time": 74, - "Intensity": 0.67, - "Frequency": -47 - }, - { - "Time": 102, - "Intensity": 0.83, - "Frequency": -38 - }, - { - "Time": 134, - "Intensity": 0.91, - "Frequency": -39 - }, - { - "Time": 147, - "Intensity": 0.74, - "Frequency": -47 - }, - { - "Time": 195, - "Intensity": 0.6, - "Frequency": -50 - }, - { - "Time": 225, - "Intensity": 0.88, - "Frequency": -43 - }, - { - "Time": 295, - "Intensity": 0.7, - "Frequency": -45 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1017, - "Parameters": { - "Intensity": 64, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 14, - "Intensity": 0.69, - "Frequency": -47 - }, - { - "Time": 65, - "Intensity": 0.47, - "Frequency": -42 - }, - { - "Time": 95, - "Intensity": 0.75, - "Frequency": -34 - }, - { - "Time": 130, - "Intensity": 0.97, - "Frequency": -39 - }, - { - "Time": 167, - "Intensity": 0.62, - "Frequency": -50 - }, - { - "Time": 208, - "Intensity": 0.45, - "Frequency": -50 - }, - { - "Time": 226, - "Intensity": 0.99, - "Frequency": -39 - }, - { - "Time": 296, - "Intensity": 0.72, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1323, - "Parameters": { - "Intensity": 72, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.46, - "Frequency": -39 - }, - { - "Time": 31, - "Intensity": 0.73, - "Frequency": -50 - }, - { - "Time": 70, - "Intensity": 0.94, - "Frequency": -50 - }, - { - "Time": 115, - "Intensity": 0.79, - "Frequency": -37 - }, - { - "Time": 134, - "Intensity": 0.6, - "Frequency": -38 - }, - { - "Time": 154, - "Intensity": 0.77, - "Frequency": -47 - }, - { - "Time": 185, - "Intensity": 0.71, - "Frequency": -50 - }, - { - "Time": 217, - "Intensity": 0.57, - "Frequency": -48 - }, - { - "Time": 275, - "Intensity": 0.64, - "Frequency": -46 - }, - { - "Time": 297, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1327, - "Parameters": { - "Intensity": 67, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 2, - "Intensity": 0.42, - "Frequency": -47 - }, - { - "Time": 29, - "Intensity": 0.78, - "Frequency": -50 - }, - { - "Time": 74, - "Intensity": 0.95, - "Frequency": -45 - }, - { - "Time": 108, - "Intensity": 0.65, - "Frequency": -39 - }, - { - "Time": 131, - "Intensity": 0.39, - "Frequency": -45 - }, - { - "Time": 164, - "Intensity": 0.76, - "Frequency": -46 - }, - { - "Time": 194, - "Intensity": 0.69, - "Frequency": -43 - }, - { - "Time": 235, - "Intensity": 0.41, - "Frequency": -46 - }, - { - "Time": 264, - "Intensity": 0.6, - "Frequency": -41 - }, - { - "Time": 295, - "Intensity": 0.49, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1627, - "Parameters": { - "Intensity": 78, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.35, - "Frequency": -46 - }, - { - "Time": 37, - "Intensity": 0.65, - "Frequency": -47 - }, - { - "Time": 84, - "Intensity": 0.41, - "Frequency": -50 - }, - { - "Time": 128, - "Intensity": 0.94, - "Frequency": -46 - }, - { - "Time": 154, - "Intensity": 0.51, - "Frequency": -38 - }, - { - "Time": 179, - "Intensity": 0.81, - "Frequency": -50 - }, - { - "Time": 212, - "Intensity": 0.58, - "Frequency": -49 - }, - { - "Time": 238, - "Intensity": 0.86, - "Frequency": -46 - }, - { - "Time": 277, - "Intensity": 0.79, - "Frequency": -39 - }, - { - "Time": 299, - "Intensity": 0.53, - "Frequency": -46 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1628, - "Parameters": { - "Intensity": 72, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 7, - "Intensity": 0.49, - "Frequency": -46 - }, - { - "Time": 44, - "Intensity": 0.82, - "Frequency": -47 - }, - { - "Time": 82, - "Intensity": 0.5, - "Frequency": -50 - }, - { - "Time": 124, - "Intensity": 0.85, - "Frequency": -46 - }, - { - "Time": 154, - "Intensity": 0.53, - "Frequency": -38 - }, - { - "Time": 175, - "Intensity": 0.81, - "Frequency": -50 - }, - { - "Time": 208, - "Intensity": 0.57, - "Frequency": -49 - }, - { - "Time": 230, - "Intensity": 0.82, - "Frequency": -46 - }, - { - "Time": 278, - "Intensity": 0.78, - "Frequency": -39 - }, - { - "Time": 296, - "Intensity": 0.69, - "Frequency": -46 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 1929, - "Parameters": { - "Intensity": 74, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 24, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 82, - "Intensity": 0.62, - "Frequency": -44 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": -42 - }, - { - "Time": 186, - "Intensity": 0.72, - "Frequency": -39 - }, - { - "Time": 234, - "Intensity": 0.41, - "Frequency": -50 - }, - { - "Time": 278, - "Intensity": 0.82, - "Frequency": -50 - }, - { - "Time": 328, - "Intensity": 0.64, - "Frequency": -45 - }, - { - "Time": 392, - "Intensity": 0.54, - "Frequency": -47 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 1931, - "Parameters": { - "Intensity": 81, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 24, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 85, - "Intensity": 0.65, - "Frequency": -44 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": -42 - }, - { - "Time": 189, - "Intensity": 0.72, - "Frequency": -39 - }, - { - "Time": 241, - "Intensity": 0.34, - "Frequency": -50 - }, - { - "Time": 278, - "Intensity": 0.82, - "Frequency": -50 - }, - { - "Time": 328, - "Intensity": 0.64, - "Frequency": -45 - }, - { - "Time": 392, - "Intensity": 0.54, - "Frequency": -47 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 2332, - "Parameters": { - "Intensity": 75, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.39, - "Frequency": -47 - }, - { - "Time": 31, - "Intensity": 0.55, - "Frequency": -42 - }, - { - "Time": 81, - "Intensity": 0.5, - "Frequency": -34 - }, - { - "Time": 96, - "Intensity": 0.84, - "Frequency": -43 - }, - { - "Time": 145, - "Intensity": 0.71, - "Frequency": -50 - }, - { - "Time": 203, - "Intensity": 0.56, - "Frequency": -50 - }, - { - "Time": 242, - "Intensity": 0.84, - "Frequency": -44 - }, - { - "Time": 296, - "Intensity": 0.72, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 2334, - "Parameters": { - "Intensity": 64, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 3, - "Intensity": 0.38, - "Frequency": -47 - }, - { - "Time": 18, - "Intensity": 0.7, - "Frequency": -42 - }, - { - "Time": 79, - "Intensity": 0.62, - "Frequency": -34 - }, - { - "Time": 95, - "Intensity": 0.88, - "Frequency": -39 - }, - { - "Time": 148, - "Intensity": 0.73, - "Frequency": -50 - }, - { - "Time": 204, - "Intensity": 0.49, - "Frequency": -50 - }, - { - "Time": 242, - "Intensity": 0.84, - "Frequency": -39 - }, - { - "Time": 296, - "Intensity": 0.72, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 2636, - "Parameters": { - "Intensity": 64, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 9, - "Intensity": 0.49, - "Frequency": -46 - }, - { - "Time": 53, - "Intensity": 0.93, - "Frequency": -47 - }, - { - "Time": 105, - "Intensity": 0.62, - "Frequency": -50 - }, - { - "Time": 154, - "Intensity": 0.88, - "Frequency": -46 - }, - { - "Time": 196, - "Intensity": 0.75, - "Frequency": -38 - }, - { - "Time": 230, - "Intensity": 0.52, - "Frequency": -50 - }, - { - "Time": 254, - "Intensity": 0.92, - "Frequency": -49 - }, - { - "Time": 306, - "Intensity": 0.83, - "Frequency": -46 - }, - { - "Time": 329, - "Intensity": 1, - "Frequency": -48 - }, - { - "Time": 394, - "Intensity": 0.69, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 2637, - "Parameters": { - "Intensity": 71, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 17, - "Intensity": 0.44, - "Frequency": -50 - }, - { - "Time": 53, - "Intensity": 0.88, - "Frequency": -47 - }, - { - "Time": 123, - "Intensity": 0.61, - "Frequency": -47 - }, - { - "Time": 169, - "Intensity": 0.8, - "Frequency": -41 - }, - { - "Time": 224, - "Intensity": 0.52, - "Frequency": -50 - }, - { - "Time": 254, - "Intensity": 0.86, - "Frequency": -38 - }, - { - "Time": 311, - "Intensity": 0.68, - "Frequency": -50 - }, - { - "Time": 336, - "Intensity": 0.95, - "Frequency": -46 - }, - { - "Time": 388, - "Intensity": 0.66, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 3040, - "Parameters": { - "Intensity": 67, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 4, - "Intensity": 0.75, - "Frequency": -46 - }, - { - "Time": 49, - "Intensity": 0.52, - "Frequency": -43 - }, - { - "Time": 88, - "Intensity": 0.65, - "Frequency": -50 - }, - { - "Time": 114, - "Intensity": 0.85, - "Frequency": -41 - }, - { - "Time": 163, - "Intensity": 0.74, - "Frequency": -38 - }, - { - "Time": 202, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 296, - "Intensity": 0.65, - "Frequency": -38 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 301, - "StartTime": 3044, - "Parameters": { - "Intensity": 74, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 10, - "Intensity": 0.71, - "Frequency": -46 - }, - { - "Time": 46, - "Intensity": 0.47, - "Frequency": -48 - }, - { - "Time": 80, - "Intensity": 0.61, - "Frequency": -50 - }, - { - "Time": 100, - "Intensity": 0.92, - "Frequency": -43 - }, - { - "Time": 156, - "Intensity": 0.76, - "Frequency": -47 - }, - { - "Time": 212, - "Intensity": 0.44, - "Frequency": -50 - }, - { - "Time": 298, - "Intensity": 0.61, - "Frequency": -38 - }, - { - "Time": 301, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 0, + "Parameters": { + "Intensity": 70, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 12, + "Intensity": 0.59, + "Frequency": -47 + }, + { + "Time": 52, + "Intensity": 0.96, + "Frequency": -44 + }, + { + "Time": 100, + "Intensity": 0.53, + "Frequency": -42 + }, + { + "Time": 133, + "Intensity": 0.94, + "Frequency": -39 + }, + { + "Time": 172, + "Intensity": 0.6, + "Frequency": -50 + }, + { + "Time": 210, + "Intensity": 0.38, + "Frequency": -50 + }, + { + "Time": 239, + "Intensity": 0.74, + "Frequency": -45 + }, + { + "Time": 287, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 7, + "Parameters": { + "Intensity": 66, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 18, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 55, + "Intensity": 0.85, + "Frequency": -44 + }, + { + "Time": 106, + "Intensity": 0.64, + "Frequency": -42 + }, + { + "Time": 136, + "Intensity": 0.91, + "Frequency": -39 + }, + { + "Time": 165, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 206, + "Intensity": 0.53, + "Frequency": -50 + }, + { + "Time": 225, + "Intensity": 0.69, + "Frequency": -45 + }, + { + "Time": 294, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 311, + "Parameters": { + "Intensity": 70, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 32, + "Intensity": 0.93, + "Frequency": -50 + }, + { + "Time": 86, + "Intensity": 0.83, + "Frequency": -47 + }, + { + "Time": 145, + "Intensity": 0.43, + "Frequency": -47 + }, + { + "Time": 196, + "Intensity": 1, + "Frequency": -41 + }, + { + "Time": 252, + "Intensity": 0.49, + "Frequency": -50 + }, + { + "Time": 280, + "Intensity": 0.86, + "Frequency": -38 + }, + { + "Time": 322, + "Intensity": 0.57, + "Frequency": -50 + }, + { + "Time": 336, + "Intensity": 0.95, + "Frequency": -38 + }, + { + "Time": 399, + "Intensity": 0.57, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 313, + "Parameters": { + "Intensity": 64, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 9, + "Intensity": 0.49, + "Frequency": -46 + }, + { + "Time": 53, + "Intensity": 0.93, + "Frequency": -47 + }, + { + "Time": 114, + "Intensity": 0.82, + "Frequency": -50 + }, + { + "Time": 149, + "Intensity": 0.59, + "Frequency": -46 + }, + { + "Time": 190, + "Intensity": 0.94, + "Frequency": -38 + }, + { + "Time": 236, + "Intensity": 0.69, + "Frequency": -50 + }, + { + "Time": 264, + "Intensity": 0.82, + "Frequency": -49 + }, + { + "Time": 310, + "Intensity": 0.74, + "Frequency": -46 + }, + { + "Time": 329, + "Intensity": 1, + "Frequency": -39 + }, + { + "Time": 394, + "Intensity": 0.69, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 714, + "Parameters": { + "Intensity": 71, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 5, + "Intensity": 0.73, + "Frequency": -39 + }, + { + "Time": 52, + "Intensity": 0.54, + "Frequency": -48 + }, + { + "Time": 96, + "Intensity": 0.68, + "Frequency": -50 + }, + { + "Time": 118, + "Intensity": 1, + "Frequency": -43 + }, + { + "Time": 161, + "Intensity": 0.81, + "Frequency": -47 + }, + { + "Time": 217, + "Intensity": 0.43, + "Frequency": -50 + }, + { + "Time": 299, + "Intensity": 0.61, + "Frequency": -38 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 716, + "Parameters": { + "Intensity": 65, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 5, + "Intensity": 0.76, + "Frequency": -40 + }, + { + "Time": 47, + "Intensity": 0.76, + "Frequency": -43 + }, + { + "Time": 79, + "Intensity": 0.81, + "Frequency": -50 + }, + { + "Time": 119, + "Intensity": 1, + "Frequency": -41 + }, + { + "Time": 166, + "Intensity": 0.82, + "Frequency": -38 + }, + { + "Time": 202, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 296, + "Intensity": 0.65, + "Frequency": -38 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1016, + "Parameters": { + "Intensity": 74, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 21, + "Intensity": 0.66, + "Frequency": -44 + }, + { + "Time": 74, + "Intensity": 0.67, + "Frequency": -47 + }, + { + "Time": 102, + "Intensity": 0.83, + "Frequency": -38 + }, + { + "Time": 134, + "Intensity": 0.91, + "Frequency": -39 + }, + { + "Time": 147, + "Intensity": 0.74, + "Frequency": -47 + }, + { + "Time": 195, + "Intensity": 0.6, + "Frequency": -50 + }, + { + "Time": 225, + "Intensity": 0.88, + "Frequency": -43 + }, + { + "Time": 295, + "Intensity": 0.7, + "Frequency": -45 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1017, + "Parameters": { + "Intensity": 64, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 14, + "Intensity": 0.69, + "Frequency": -47 + }, + { + "Time": 65, + "Intensity": 0.47, + "Frequency": -42 + }, + { + "Time": 95, + "Intensity": 0.75, + "Frequency": -34 + }, + { + "Time": 130, + "Intensity": 0.97, + "Frequency": -39 + }, + { + "Time": 167, + "Intensity": 0.62, + "Frequency": -50 + }, + { + "Time": 208, + "Intensity": 0.45, + "Frequency": -50 + }, + { + "Time": 226, + "Intensity": 0.99, + "Frequency": -39 + }, + { + "Time": 296, + "Intensity": 0.72, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1323, + "Parameters": { + "Intensity": 72, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.46, + "Frequency": -39 + }, + { + "Time": 31, + "Intensity": 0.73, + "Frequency": -50 + }, + { + "Time": 70, + "Intensity": 0.94, + "Frequency": -50 + }, + { + "Time": 115, + "Intensity": 0.79, + "Frequency": -37 + }, + { + "Time": 134, + "Intensity": 0.6, + "Frequency": -38 + }, + { + "Time": 154, + "Intensity": 0.77, + "Frequency": -47 + }, + { + "Time": 185, + "Intensity": 0.71, + "Frequency": -50 + }, + { + "Time": 217, + "Intensity": 0.57, + "Frequency": -48 + }, + { + "Time": 275, + "Intensity": 0.64, + "Frequency": -46 + }, + { + "Time": 297, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1327, + "Parameters": { + "Intensity": 67, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 2, + "Intensity": 0.42, + "Frequency": -47 + }, + { + "Time": 29, + "Intensity": 0.78, + "Frequency": -50 + }, + { + "Time": 74, + "Intensity": 0.95, + "Frequency": -45 + }, + { + "Time": 108, + "Intensity": 0.65, + "Frequency": -39 + }, + { + "Time": 131, + "Intensity": 0.39, + "Frequency": -45 + }, + { + "Time": 164, + "Intensity": 0.76, + "Frequency": -46 + }, + { + "Time": 194, + "Intensity": 0.69, + "Frequency": -43 + }, + { + "Time": 235, + "Intensity": 0.41, + "Frequency": -46 + }, + { + "Time": 264, + "Intensity": 0.6, + "Frequency": -41 + }, + { + "Time": 295, + "Intensity": 0.49, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1627, + "Parameters": { + "Intensity": 78, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.35, + "Frequency": -46 + }, + { + "Time": 37, + "Intensity": 0.65, + "Frequency": -47 + }, + { + "Time": 84, + "Intensity": 0.41, + "Frequency": -50 + }, + { + "Time": 128, + "Intensity": 0.94, + "Frequency": -46 + }, + { + "Time": 154, + "Intensity": 0.51, + "Frequency": -38 + }, + { + "Time": 179, + "Intensity": 0.81, + "Frequency": -50 + }, + { + "Time": 212, + "Intensity": 0.58, + "Frequency": -49 + }, + { + "Time": 238, + "Intensity": 0.86, + "Frequency": -46 + }, + { + "Time": 277, + "Intensity": 0.79, + "Frequency": -39 + }, + { + "Time": 299, + "Intensity": 0.53, + "Frequency": -46 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1628, + "Parameters": { + "Intensity": 72, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 7, + "Intensity": 0.49, + "Frequency": -46 + }, + { + "Time": 44, + "Intensity": 0.82, + "Frequency": -47 + }, + { + "Time": 82, + "Intensity": 0.5, + "Frequency": -50 + }, + { + "Time": 124, + "Intensity": 0.85, + "Frequency": -46 + }, + { + "Time": 154, + "Intensity": 0.53, + "Frequency": -38 + }, + { + "Time": 175, + "Intensity": 0.81, + "Frequency": -50 + }, + { + "Time": 208, + "Intensity": 0.57, + "Frequency": -49 + }, + { + "Time": 230, + "Intensity": 0.82, + "Frequency": -46 + }, + { + "Time": 278, + "Intensity": 0.78, + "Frequency": -39 + }, + { + "Time": 296, + "Intensity": 0.69, + "Frequency": -46 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 1929, + "Parameters": { + "Intensity": 74, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 24, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 82, + "Intensity": 0.62, + "Frequency": -44 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": -42 + }, + { + "Time": 186, + "Intensity": 0.72, + "Frequency": -39 + }, + { + "Time": 234, + "Intensity": 0.41, + "Frequency": -50 + }, + { + "Time": 278, + "Intensity": 0.82, + "Frequency": -50 + }, + { + "Time": 328, + "Intensity": 0.64, + "Frequency": -45 + }, + { + "Time": 392, + "Intensity": 0.54, + "Frequency": -47 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 1931, + "Parameters": { + "Intensity": 81, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 24, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 85, + "Intensity": 0.65, + "Frequency": -44 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": -42 + }, + { + "Time": 189, + "Intensity": 0.72, + "Frequency": -39 + }, + { + "Time": 241, + "Intensity": 0.34, + "Frequency": -50 + }, + { + "Time": 278, + "Intensity": 0.82, + "Frequency": -50 + }, + { + "Time": 328, + "Intensity": 0.64, + "Frequency": -45 + }, + { + "Time": 392, + "Intensity": 0.54, + "Frequency": -47 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 2332, + "Parameters": { + "Intensity": 75, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.39, + "Frequency": -47 + }, + { + "Time": 31, + "Intensity": 0.55, + "Frequency": -42 + }, + { + "Time": 81, + "Intensity": 0.5, + "Frequency": -34 + }, + { + "Time": 96, + "Intensity": 0.84, + "Frequency": -43 + }, + { + "Time": 145, + "Intensity": 0.71, + "Frequency": -50 + }, + { + "Time": 203, + "Intensity": 0.56, + "Frequency": -50 + }, + { + "Time": 242, + "Intensity": 0.84, + "Frequency": -44 + }, + { + "Time": 296, + "Intensity": 0.72, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 2334, + "Parameters": { + "Intensity": 64, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 3, + "Intensity": 0.38, + "Frequency": -47 + }, + { + "Time": 18, + "Intensity": 0.7, + "Frequency": -42 + }, + { + "Time": 79, + "Intensity": 0.62, + "Frequency": -34 + }, + { + "Time": 95, + "Intensity": 0.88, + "Frequency": -39 + }, + { + "Time": 148, + "Intensity": 0.73, + "Frequency": -50 + }, + { + "Time": 204, + "Intensity": 0.49, + "Frequency": -50 + }, + { + "Time": 242, + "Intensity": 0.84, + "Frequency": -39 + }, + { + "Time": 296, + "Intensity": 0.72, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 2636, + "Parameters": { + "Intensity": 64, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 9, + "Intensity": 0.49, + "Frequency": -46 + }, + { + "Time": 53, + "Intensity": 0.93, + "Frequency": -47 + }, + { + "Time": 105, + "Intensity": 0.62, + "Frequency": -50 + }, + { + "Time": 154, + "Intensity": 0.88, + "Frequency": -46 + }, + { + "Time": 196, + "Intensity": 0.75, + "Frequency": -38 + }, + { + "Time": 230, + "Intensity": 0.52, + "Frequency": -50 + }, + { + "Time": 254, + "Intensity": 0.92, + "Frequency": -49 + }, + { + "Time": 306, + "Intensity": 0.83, + "Frequency": -46 + }, + { + "Time": 329, + "Intensity": 1, + "Frequency": -48 + }, + { + "Time": 394, + "Intensity": 0.69, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 2637, + "Parameters": { + "Intensity": 71, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 17, + "Intensity": 0.44, + "Frequency": -50 + }, + { + "Time": 53, + "Intensity": 0.88, + "Frequency": -47 + }, + { + "Time": 123, + "Intensity": 0.61, + "Frequency": -47 + }, + { + "Time": 169, + "Intensity": 0.8, + "Frequency": -41 + }, + { + "Time": 224, + "Intensity": 0.52, + "Frequency": -50 + }, + { + "Time": 254, + "Intensity": 0.86, + "Frequency": -38 + }, + { + "Time": 311, + "Intensity": 0.68, + "Frequency": -50 + }, + { + "Time": 336, + "Intensity": 0.95, + "Frequency": -46 + }, + { + "Time": 388, + "Intensity": 0.66, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 3040, + "Parameters": { + "Intensity": 67, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 4, + "Intensity": 0.75, + "Frequency": -46 + }, + { + "Time": 49, + "Intensity": 0.52, + "Frequency": -43 + }, + { + "Time": 88, + "Intensity": 0.65, + "Frequency": -50 + }, + { + "Time": 114, + "Intensity": 0.85, + "Frequency": -41 + }, + { + "Time": 163, + "Intensity": 0.74, + "Frequency": -38 + }, + { + "Time": 202, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 296, + "Intensity": 0.65, + "Frequency": -38 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 301, + "StartTime": 3044, + "Parameters": { + "Intensity": 74, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 10, + "Intensity": 0.71, + "Frequency": -46 + }, + { + "Time": 46, + "Intensity": 0.47, + "Frequency": -48 + }, + { + "Time": 80, + "Intensity": 0.61, + "Frequency": -50 + }, + { + "Time": 100, + "Intensity": 0.92, + "Frequency": -43 + }, + { + "Time": 156, + "Intensity": 0.76, + "Frequency": -47 + }, + { + "Time": 212, + "Intensity": 0.44, + "Frequency": -50 + }, + { + "Time": 298, + "Intensity": 0.61, + "Frequency": -38 + }, + { + "Time": 301, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_l.json index 0aaebbc6d8..b126ec6ca1 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_l.json @@ -1,1327 +1,1327 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 0, - "Parameters": { - "Intensity": 42, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 12, - "Intensity": 0.59, - "Frequency": -47 - }, - { - "Time": 52, - "Intensity": 0.96, - "Frequency": -44 - }, - { - "Time": 100, - "Intensity": 0.53, - "Frequency": -42 - }, - { - "Time": 133, - "Intensity": 0.94, - "Frequency": -39 - }, - { - "Time": 172, - "Intensity": 0.6, - "Frequency": -50 - }, - { - "Time": 210, - "Intensity": 0.38, - "Frequency": -50 - }, - { - "Time": 239, - "Intensity": 0.74, - "Frequency": -45 - }, - { - "Time": 287, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 7, - "Parameters": { - "Intensity": 39, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 18, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 55, - "Intensity": 0.85, - "Frequency": -44 - }, - { - "Time": 106, - "Intensity": 0.64, - "Frequency": -42 - }, - { - "Time": 136, - "Intensity": 0.91, - "Frequency": -39 - }, - { - "Time": 165, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 206, - "Intensity": 0.53, - "Frequency": -50 - }, - { - "Time": 225, - "Intensity": 0.69, - "Frequency": -45 - }, - { - "Time": 294, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 311, - "Parameters": { - "Intensity": 42, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 32, - "Intensity": 0.93, - "Frequency": -50 - }, - { - "Time": 86, - "Intensity": 0.83, - "Frequency": -47 - }, - { - "Time": 145, - "Intensity": 0.43, - "Frequency": -47 - }, - { - "Time": 196, - "Intensity": 1, - "Frequency": -41 - }, - { - "Time": 252, - "Intensity": 0.49, - "Frequency": -50 - }, - { - "Time": 280, - "Intensity": 0.86, - "Frequency": -38 - }, - { - "Time": 322, - "Intensity": 0.57, - "Frequency": -50 - }, - { - "Time": 336, - "Intensity": 0.95, - "Frequency": -38 - }, - { - "Time": 399, - "Intensity": 0.57, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 313, - "Parameters": { - "Intensity": 38, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 9, - "Intensity": 0.49, - "Frequency": -46 - }, - { - "Time": 53, - "Intensity": 0.93, - "Frequency": -47 - }, - { - "Time": 114, - "Intensity": 0.82, - "Frequency": -50 - }, - { - "Time": 149, - "Intensity": 0.59, - "Frequency": -46 - }, - { - "Time": 190, - "Intensity": 0.94, - "Frequency": -38 - }, - { - "Time": 236, - "Intensity": 0.69, - "Frequency": -50 - }, - { - "Time": 264, - "Intensity": 0.82, - "Frequency": -49 - }, - { - "Time": 310, - "Intensity": 0.74, - "Frequency": -46 - }, - { - "Time": 329, - "Intensity": 1, - "Frequency": -39 - }, - { - "Time": 394, - "Intensity": 0.69, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 714, - "Parameters": { - "Intensity": 42, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 5, - "Intensity": 0.73, - "Frequency": -39 - }, - { - "Time": 52, - "Intensity": 0.54, - "Frequency": -48 - }, - { - "Time": 96, - "Intensity": 0.68, - "Frequency": -50 - }, - { - "Time": 118, - "Intensity": 1, - "Frequency": -43 - }, - { - "Time": 161, - "Intensity": 0.81, - "Frequency": -47 - }, - { - "Time": 217, - "Intensity": 0.43, - "Frequency": -50 - }, - { - "Time": 299, - "Intensity": 0.61, - "Frequency": -38 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 716, - "Parameters": { - "Intensity": 39, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 5, - "Intensity": 0.76, - "Frequency": -40 - }, - { - "Time": 47, - "Intensity": 0.76, - "Frequency": -43 - }, - { - "Time": 79, - "Intensity": 0.81, - "Frequency": -50 - }, - { - "Time": 119, - "Intensity": 1, - "Frequency": -41 - }, - { - "Time": 166, - "Intensity": 0.82, - "Frequency": -38 - }, - { - "Time": 202, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 296, - "Intensity": 0.65, - "Frequency": -38 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1016, - "Parameters": { - "Intensity": 44, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 21, - "Intensity": 0.66, - "Frequency": -44 - }, - { - "Time": 74, - "Intensity": 0.67, - "Frequency": -47 - }, - { - "Time": 102, - "Intensity": 0.83, - "Frequency": -38 - }, - { - "Time": 134, - "Intensity": 0.91, - "Frequency": -39 - }, - { - "Time": 147, - "Intensity": 0.74, - "Frequency": -47 - }, - { - "Time": 195, - "Intensity": 0.6, - "Frequency": -50 - }, - { - "Time": 225, - "Intensity": 0.88, - "Frequency": -43 - }, - { - "Time": 295, - "Intensity": 0.7, - "Frequency": -45 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1017, - "Parameters": { - "Intensity": 38, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 14, - "Intensity": 0.69, - "Frequency": -47 - }, - { - "Time": 65, - "Intensity": 0.47, - "Frequency": -42 - }, - { - "Time": 95, - "Intensity": 0.75, - "Frequency": -34 - }, - { - "Time": 130, - "Intensity": 0.97, - "Frequency": -39 - }, - { - "Time": 167, - "Intensity": 0.62, - "Frequency": -50 - }, - { - "Time": 208, - "Intensity": 0.45, - "Frequency": -50 - }, - { - "Time": 226, - "Intensity": 0.99, - "Frequency": -39 - }, - { - "Time": 296, - "Intensity": 0.72, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1323, - "Parameters": { - "Intensity": 43, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.46, - "Frequency": -39 - }, - { - "Time": 31, - "Intensity": 0.73, - "Frequency": -50 - }, - { - "Time": 70, - "Intensity": 0.94, - "Frequency": -50 - }, - { - "Time": 115, - "Intensity": 0.79, - "Frequency": -37 - }, - { - "Time": 134, - "Intensity": 0.6, - "Frequency": -38 - }, - { - "Time": 154, - "Intensity": 0.77, - "Frequency": -47 - }, - { - "Time": 185, - "Intensity": 0.71, - "Frequency": -50 - }, - { - "Time": 217, - "Intensity": 0.57, - "Frequency": -48 - }, - { - "Time": 275, - "Intensity": 0.64, - "Frequency": -46 - }, - { - "Time": 297, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1327, - "Parameters": { - "Intensity": 40, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 2, - "Intensity": 0.42, - "Frequency": -47 - }, - { - "Time": 29, - "Intensity": 0.78, - "Frequency": -50 - }, - { - "Time": 74, - "Intensity": 0.95, - "Frequency": -45 - }, - { - "Time": 108, - "Intensity": 0.65, - "Frequency": -39 - }, - { - "Time": 131, - "Intensity": 0.39, - "Frequency": -45 - }, - { - "Time": 164, - "Intensity": 0.76, - "Frequency": -46 - }, - { - "Time": 194, - "Intensity": 0.69, - "Frequency": -43 - }, - { - "Time": 235, - "Intensity": 0.41, - "Frequency": -46 - }, - { - "Time": 264, - "Intensity": 0.6, - "Frequency": -41 - }, - { - "Time": 295, - "Intensity": 0.49, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1627, - "Parameters": { - "Intensity": 46, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.35, - "Frequency": -46 - }, - { - "Time": 37, - "Intensity": 0.65, - "Frequency": -47 - }, - { - "Time": 84, - "Intensity": 0.41, - "Frequency": -50 - }, - { - "Time": 128, - "Intensity": 0.94, - "Frequency": -46 - }, - { - "Time": 154, - "Intensity": 0.51, - "Frequency": -38 - }, - { - "Time": 179, - "Intensity": 0.81, - "Frequency": -50 - }, - { - "Time": 212, - "Intensity": 0.58, - "Frequency": -49 - }, - { - "Time": 238, - "Intensity": 0.86, - "Frequency": -46 - }, - { - "Time": 277, - "Intensity": 0.79, - "Frequency": -39 - }, - { - "Time": 299, - "Intensity": 0.53, - "Frequency": -46 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1628, - "Parameters": { - "Intensity": 43, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 7, - "Intensity": 0.49, - "Frequency": -46 - }, - { - "Time": 44, - "Intensity": 0.82, - "Frequency": -47 - }, - { - "Time": 82, - "Intensity": 0.5, - "Frequency": -50 - }, - { - "Time": 124, - "Intensity": 0.85, - "Frequency": -46 - }, - { - "Time": 154, - "Intensity": 0.53, - "Frequency": -38 - }, - { - "Time": 175, - "Intensity": 0.81, - "Frequency": -50 - }, - { - "Time": 208, - "Intensity": 0.57, - "Frequency": -49 - }, - { - "Time": 230, - "Intensity": 0.82, - "Frequency": -46 - }, - { - "Time": 278, - "Intensity": 0.78, - "Frequency": -39 - }, - { - "Time": 296, - "Intensity": 0.69, - "Frequency": -46 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 1929, - "Parameters": { - "Intensity": 44, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 24, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 82, - "Intensity": 0.62, - "Frequency": -44 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": -42 - }, - { - "Time": 186, - "Intensity": 0.72, - "Frequency": -39 - }, - { - "Time": 234, - "Intensity": 0.41, - "Frequency": -50 - }, - { - "Time": 278, - "Intensity": 0.82, - "Frequency": -50 - }, - { - "Time": 328, - "Intensity": 0.64, - "Frequency": -45 - }, - { - "Time": 392, - "Intensity": 0.54, - "Frequency": -47 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 1931, - "Parameters": { - "Intensity": 48, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 24, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 85, - "Intensity": 0.65, - "Frequency": -44 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": -42 - }, - { - "Time": 189, - "Intensity": 0.72, - "Frequency": -39 - }, - { - "Time": 241, - "Intensity": 0.34, - "Frequency": -50 - }, - { - "Time": 278, - "Intensity": 0.82, - "Frequency": -50 - }, - { - "Time": 328, - "Intensity": 0.64, - "Frequency": -45 - }, - { - "Time": 392, - "Intensity": 0.54, - "Frequency": -47 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 2332, - "Parameters": { - "Intensity": 45, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.39, - "Frequency": -47 - }, - { - "Time": 31, - "Intensity": 0.55, - "Frequency": -42 - }, - { - "Time": 81, - "Intensity": 0.5, - "Frequency": -34 - }, - { - "Time": 96, - "Intensity": 0.84, - "Frequency": -43 - }, - { - "Time": 145, - "Intensity": 0.71, - "Frequency": -50 - }, - { - "Time": 203, - "Intensity": 0.56, - "Frequency": -50 - }, - { - "Time": 242, - "Intensity": 0.84, - "Frequency": -44 - }, - { - "Time": 296, - "Intensity": 0.72, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 2334, - "Parameters": { - "Intensity": 38, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 3, - "Intensity": 0.38, - "Frequency": -47 - }, - { - "Time": 18, - "Intensity": 0.7, - "Frequency": -42 - }, - { - "Time": 79, - "Intensity": 0.62, - "Frequency": -34 - }, - { - "Time": 95, - "Intensity": 0.88, - "Frequency": -39 - }, - { - "Time": 148, - "Intensity": 0.73, - "Frequency": -50 - }, - { - "Time": 204, - "Intensity": 0.49, - "Frequency": -50 - }, - { - "Time": 242, - "Intensity": 0.84, - "Frequency": -39 - }, - { - "Time": 296, - "Intensity": 0.72, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 2636, - "Parameters": { - "Intensity": 38, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 9, - "Intensity": 0.49, - "Frequency": -46 - }, - { - "Time": 53, - "Intensity": 0.93, - "Frequency": -47 - }, - { - "Time": 105, - "Intensity": 0.62, - "Frequency": -50 - }, - { - "Time": 154, - "Intensity": 0.88, - "Frequency": -46 - }, - { - "Time": 196, - "Intensity": 0.75, - "Frequency": -38 - }, - { - "Time": 230, - "Intensity": 0.52, - "Frequency": -50 - }, - { - "Time": 254, - "Intensity": 0.92, - "Frequency": -49 - }, - { - "Time": 306, - "Intensity": 0.83, - "Frequency": -46 - }, - { - "Time": 329, - "Intensity": 1, - "Frequency": -48 - }, - { - "Time": 394, - "Intensity": 0.69, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 2637, - "Parameters": { - "Intensity": 42, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 17, - "Intensity": 0.44, - "Frequency": -50 - }, - { - "Time": 53, - "Intensity": 0.88, - "Frequency": -47 - }, - { - "Time": 123, - "Intensity": 0.61, - "Frequency": -47 - }, - { - "Time": 169, - "Intensity": 0.8, - "Frequency": -41 - }, - { - "Time": 224, - "Intensity": 0.52, - "Frequency": -50 - }, - { - "Time": 254, - "Intensity": 0.86, - "Frequency": -38 - }, - { - "Time": 311, - "Intensity": 0.68, - "Frequency": -50 - }, - { - "Time": 336, - "Intensity": 0.95, - "Frequency": -46 - }, - { - "Time": 388, - "Intensity": 0.66, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 3040, - "Parameters": { - "Intensity": 40, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 4, - "Intensity": 0.75, - "Frequency": -46 - }, - { - "Time": 49, - "Intensity": 0.52, - "Frequency": -43 - }, - { - "Time": 88, - "Intensity": 0.65, - "Frequency": -50 - }, - { - "Time": 114, - "Intensity": 0.85, - "Frequency": -41 - }, - { - "Time": 163, - "Intensity": 0.74, - "Frequency": -38 - }, - { - "Time": 202, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 296, - "Intensity": 0.65, - "Frequency": -38 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 301, - "StartTime": 3044, - "Parameters": { - "Intensity": 44, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 10, - "Intensity": 0.71, - "Frequency": -46 - }, - { - "Time": 46, - "Intensity": 0.47, - "Frequency": -48 - }, - { - "Time": 80, - "Intensity": 0.61, - "Frequency": -50 - }, - { - "Time": 100, - "Intensity": 0.92, - "Frequency": -43 - }, - { - "Time": 156, - "Intensity": 0.76, - "Frequency": -47 - }, - { - "Time": 212, - "Intensity": 0.44, - "Frequency": -50 - }, - { - "Time": 298, - "Intensity": 0.61, - "Frequency": -38 - }, - { - "Time": 301, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 0, + "Parameters": { + "Intensity": 42, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 12, + "Intensity": 0.59, + "Frequency": -47 + }, + { + "Time": 52, + "Intensity": 0.96, + "Frequency": -44 + }, + { + "Time": 100, + "Intensity": 0.53, + "Frequency": -42 + }, + { + "Time": 133, + "Intensity": 0.94, + "Frequency": -39 + }, + { + "Time": 172, + "Intensity": 0.6, + "Frequency": -50 + }, + { + "Time": 210, + "Intensity": 0.38, + "Frequency": -50 + }, + { + "Time": 239, + "Intensity": 0.74, + "Frequency": -45 + }, + { + "Time": 287, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 7, + "Parameters": { + "Intensity": 39, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 18, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 55, + "Intensity": 0.85, + "Frequency": -44 + }, + { + "Time": 106, + "Intensity": 0.64, + "Frequency": -42 + }, + { + "Time": 136, + "Intensity": 0.91, + "Frequency": -39 + }, + { + "Time": 165, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 206, + "Intensity": 0.53, + "Frequency": -50 + }, + { + "Time": 225, + "Intensity": 0.69, + "Frequency": -45 + }, + { + "Time": 294, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 311, + "Parameters": { + "Intensity": 42, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 32, + "Intensity": 0.93, + "Frequency": -50 + }, + { + "Time": 86, + "Intensity": 0.83, + "Frequency": -47 + }, + { + "Time": 145, + "Intensity": 0.43, + "Frequency": -47 + }, + { + "Time": 196, + "Intensity": 1, + "Frequency": -41 + }, + { + "Time": 252, + "Intensity": 0.49, + "Frequency": -50 + }, + { + "Time": 280, + "Intensity": 0.86, + "Frequency": -38 + }, + { + "Time": 322, + "Intensity": 0.57, + "Frequency": -50 + }, + { + "Time": 336, + "Intensity": 0.95, + "Frequency": -38 + }, + { + "Time": 399, + "Intensity": 0.57, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 313, + "Parameters": { + "Intensity": 38, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 9, + "Intensity": 0.49, + "Frequency": -46 + }, + { + "Time": 53, + "Intensity": 0.93, + "Frequency": -47 + }, + { + "Time": 114, + "Intensity": 0.82, + "Frequency": -50 + }, + { + "Time": 149, + "Intensity": 0.59, + "Frequency": -46 + }, + { + "Time": 190, + "Intensity": 0.94, + "Frequency": -38 + }, + { + "Time": 236, + "Intensity": 0.69, + "Frequency": -50 + }, + { + "Time": 264, + "Intensity": 0.82, + "Frequency": -49 + }, + { + "Time": 310, + "Intensity": 0.74, + "Frequency": -46 + }, + { + "Time": 329, + "Intensity": 1, + "Frequency": -39 + }, + { + "Time": 394, + "Intensity": 0.69, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 714, + "Parameters": { + "Intensity": 42, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 5, + "Intensity": 0.73, + "Frequency": -39 + }, + { + "Time": 52, + "Intensity": 0.54, + "Frequency": -48 + }, + { + "Time": 96, + "Intensity": 0.68, + "Frequency": -50 + }, + { + "Time": 118, + "Intensity": 1, + "Frequency": -43 + }, + { + "Time": 161, + "Intensity": 0.81, + "Frequency": -47 + }, + { + "Time": 217, + "Intensity": 0.43, + "Frequency": -50 + }, + { + "Time": 299, + "Intensity": 0.61, + "Frequency": -38 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 716, + "Parameters": { + "Intensity": 39, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 5, + "Intensity": 0.76, + "Frequency": -40 + }, + { + "Time": 47, + "Intensity": 0.76, + "Frequency": -43 + }, + { + "Time": 79, + "Intensity": 0.81, + "Frequency": -50 + }, + { + "Time": 119, + "Intensity": 1, + "Frequency": -41 + }, + { + "Time": 166, + "Intensity": 0.82, + "Frequency": -38 + }, + { + "Time": 202, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 296, + "Intensity": 0.65, + "Frequency": -38 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1016, + "Parameters": { + "Intensity": 44, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 21, + "Intensity": 0.66, + "Frequency": -44 + }, + { + "Time": 74, + "Intensity": 0.67, + "Frequency": -47 + }, + { + "Time": 102, + "Intensity": 0.83, + "Frequency": -38 + }, + { + "Time": 134, + "Intensity": 0.91, + "Frequency": -39 + }, + { + "Time": 147, + "Intensity": 0.74, + "Frequency": -47 + }, + { + "Time": 195, + "Intensity": 0.6, + "Frequency": -50 + }, + { + "Time": 225, + "Intensity": 0.88, + "Frequency": -43 + }, + { + "Time": 295, + "Intensity": 0.7, + "Frequency": -45 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1017, + "Parameters": { + "Intensity": 38, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 14, + "Intensity": 0.69, + "Frequency": -47 + }, + { + "Time": 65, + "Intensity": 0.47, + "Frequency": -42 + }, + { + "Time": 95, + "Intensity": 0.75, + "Frequency": -34 + }, + { + "Time": 130, + "Intensity": 0.97, + "Frequency": -39 + }, + { + "Time": 167, + "Intensity": 0.62, + "Frequency": -50 + }, + { + "Time": 208, + "Intensity": 0.45, + "Frequency": -50 + }, + { + "Time": 226, + "Intensity": 0.99, + "Frequency": -39 + }, + { + "Time": 296, + "Intensity": 0.72, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1323, + "Parameters": { + "Intensity": 43, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.46, + "Frequency": -39 + }, + { + "Time": 31, + "Intensity": 0.73, + "Frequency": -50 + }, + { + "Time": 70, + "Intensity": 0.94, + "Frequency": -50 + }, + { + "Time": 115, + "Intensity": 0.79, + "Frequency": -37 + }, + { + "Time": 134, + "Intensity": 0.6, + "Frequency": -38 + }, + { + "Time": 154, + "Intensity": 0.77, + "Frequency": -47 + }, + { + "Time": 185, + "Intensity": 0.71, + "Frequency": -50 + }, + { + "Time": 217, + "Intensity": 0.57, + "Frequency": -48 + }, + { + "Time": 275, + "Intensity": 0.64, + "Frequency": -46 + }, + { + "Time": 297, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1327, + "Parameters": { + "Intensity": 40, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 2, + "Intensity": 0.42, + "Frequency": -47 + }, + { + "Time": 29, + "Intensity": 0.78, + "Frequency": -50 + }, + { + "Time": 74, + "Intensity": 0.95, + "Frequency": -45 + }, + { + "Time": 108, + "Intensity": 0.65, + "Frequency": -39 + }, + { + "Time": 131, + "Intensity": 0.39, + "Frequency": -45 + }, + { + "Time": 164, + "Intensity": 0.76, + "Frequency": -46 + }, + { + "Time": 194, + "Intensity": 0.69, + "Frequency": -43 + }, + { + "Time": 235, + "Intensity": 0.41, + "Frequency": -46 + }, + { + "Time": 264, + "Intensity": 0.6, + "Frequency": -41 + }, + { + "Time": 295, + "Intensity": 0.49, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1627, + "Parameters": { + "Intensity": 46, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.35, + "Frequency": -46 + }, + { + "Time": 37, + "Intensity": 0.65, + "Frequency": -47 + }, + { + "Time": 84, + "Intensity": 0.41, + "Frequency": -50 + }, + { + "Time": 128, + "Intensity": 0.94, + "Frequency": -46 + }, + { + "Time": 154, + "Intensity": 0.51, + "Frequency": -38 + }, + { + "Time": 179, + "Intensity": 0.81, + "Frequency": -50 + }, + { + "Time": 212, + "Intensity": 0.58, + "Frequency": -49 + }, + { + "Time": 238, + "Intensity": 0.86, + "Frequency": -46 + }, + { + "Time": 277, + "Intensity": 0.79, + "Frequency": -39 + }, + { + "Time": 299, + "Intensity": 0.53, + "Frequency": -46 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1628, + "Parameters": { + "Intensity": 43, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 7, + "Intensity": 0.49, + "Frequency": -46 + }, + { + "Time": 44, + "Intensity": 0.82, + "Frequency": -47 + }, + { + "Time": 82, + "Intensity": 0.5, + "Frequency": -50 + }, + { + "Time": 124, + "Intensity": 0.85, + "Frequency": -46 + }, + { + "Time": 154, + "Intensity": 0.53, + "Frequency": -38 + }, + { + "Time": 175, + "Intensity": 0.81, + "Frequency": -50 + }, + { + "Time": 208, + "Intensity": 0.57, + "Frequency": -49 + }, + { + "Time": 230, + "Intensity": 0.82, + "Frequency": -46 + }, + { + "Time": 278, + "Intensity": 0.78, + "Frequency": -39 + }, + { + "Time": 296, + "Intensity": 0.69, + "Frequency": -46 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 1929, + "Parameters": { + "Intensity": 44, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 24, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 82, + "Intensity": 0.62, + "Frequency": -44 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": -42 + }, + { + "Time": 186, + "Intensity": 0.72, + "Frequency": -39 + }, + { + "Time": 234, + "Intensity": 0.41, + "Frequency": -50 + }, + { + "Time": 278, + "Intensity": 0.82, + "Frequency": -50 + }, + { + "Time": 328, + "Intensity": 0.64, + "Frequency": -45 + }, + { + "Time": 392, + "Intensity": 0.54, + "Frequency": -47 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 1931, + "Parameters": { + "Intensity": 48, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 24, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 85, + "Intensity": 0.65, + "Frequency": -44 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": -42 + }, + { + "Time": 189, + "Intensity": 0.72, + "Frequency": -39 + }, + { + "Time": 241, + "Intensity": 0.34, + "Frequency": -50 + }, + { + "Time": 278, + "Intensity": 0.82, + "Frequency": -50 + }, + { + "Time": 328, + "Intensity": 0.64, + "Frequency": -45 + }, + { + "Time": 392, + "Intensity": 0.54, + "Frequency": -47 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 2332, + "Parameters": { + "Intensity": 45, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.39, + "Frequency": -47 + }, + { + "Time": 31, + "Intensity": 0.55, + "Frequency": -42 + }, + { + "Time": 81, + "Intensity": 0.5, + "Frequency": -34 + }, + { + "Time": 96, + "Intensity": 0.84, + "Frequency": -43 + }, + { + "Time": 145, + "Intensity": 0.71, + "Frequency": -50 + }, + { + "Time": 203, + "Intensity": 0.56, + "Frequency": -50 + }, + { + "Time": 242, + "Intensity": 0.84, + "Frequency": -44 + }, + { + "Time": 296, + "Intensity": 0.72, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 2334, + "Parameters": { + "Intensity": 38, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 3, + "Intensity": 0.38, + "Frequency": -47 + }, + { + "Time": 18, + "Intensity": 0.7, + "Frequency": -42 + }, + { + "Time": 79, + "Intensity": 0.62, + "Frequency": -34 + }, + { + "Time": 95, + "Intensity": 0.88, + "Frequency": -39 + }, + { + "Time": 148, + "Intensity": 0.73, + "Frequency": -50 + }, + { + "Time": 204, + "Intensity": 0.49, + "Frequency": -50 + }, + { + "Time": 242, + "Intensity": 0.84, + "Frequency": -39 + }, + { + "Time": 296, + "Intensity": 0.72, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 2636, + "Parameters": { + "Intensity": 38, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 9, + "Intensity": 0.49, + "Frequency": -46 + }, + { + "Time": 53, + "Intensity": 0.93, + "Frequency": -47 + }, + { + "Time": 105, + "Intensity": 0.62, + "Frequency": -50 + }, + { + "Time": 154, + "Intensity": 0.88, + "Frequency": -46 + }, + { + "Time": 196, + "Intensity": 0.75, + "Frequency": -38 + }, + { + "Time": 230, + "Intensity": 0.52, + "Frequency": -50 + }, + { + "Time": 254, + "Intensity": 0.92, + "Frequency": -49 + }, + { + "Time": 306, + "Intensity": 0.83, + "Frequency": -46 + }, + { + "Time": 329, + "Intensity": 1, + "Frequency": -48 + }, + { + "Time": 394, + "Intensity": 0.69, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 2637, + "Parameters": { + "Intensity": 42, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 17, + "Intensity": 0.44, + "Frequency": -50 + }, + { + "Time": 53, + "Intensity": 0.88, + "Frequency": -47 + }, + { + "Time": 123, + "Intensity": 0.61, + "Frequency": -47 + }, + { + "Time": 169, + "Intensity": 0.8, + "Frequency": -41 + }, + { + "Time": 224, + "Intensity": 0.52, + "Frequency": -50 + }, + { + "Time": 254, + "Intensity": 0.86, + "Frequency": -38 + }, + { + "Time": 311, + "Intensity": 0.68, + "Frequency": -50 + }, + { + "Time": 336, + "Intensity": 0.95, + "Frequency": -46 + }, + { + "Time": 388, + "Intensity": 0.66, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 3040, + "Parameters": { + "Intensity": 40, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 4, + "Intensity": 0.75, + "Frequency": -46 + }, + { + "Time": 49, + "Intensity": 0.52, + "Frequency": -43 + }, + { + "Time": 88, + "Intensity": 0.65, + "Frequency": -50 + }, + { + "Time": 114, + "Intensity": 0.85, + "Frequency": -41 + }, + { + "Time": 163, + "Intensity": 0.74, + "Frequency": -38 + }, + { + "Time": 202, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 296, + "Intensity": 0.65, + "Frequency": -38 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 301, + "StartTime": 3044, + "Parameters": { + "Intensity": 44, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 10, + "Intensity": 0.71, + "Frequency": -46 + }, + { + "Time": 46, + "Intensity": 0.47, + "Frequency": -48 + }, + { + "Time": 80, + "Intensity": 0.61, + "Frequency": -50 + }, + { + "Time": 100, + "Intensity": 0.92, + "Frequency": -43 + }, + { + "Time": 156, + "Intensity": 0.76, + "Frequency": -47 + }, + { + "Time": 212, + "Intensity": 0.44, + "Frequency": -50 + }, + { + "Time": 298, + "Intensity": 0.61, + "Frequency": -38 + }, + { + "Time": 301, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_m.json index f34559e84d..cafa334652 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Creek_m.json @@ -1,1327 +1,1327 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 0, - "Parameters": { - "Intensity": 56, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 12, - "Intensity": 0.59, - "Frequency": -47 - }, - { - "Time": 52, - "Intensity": 0.96, - "Frequency": -44 - }, - { - "Time": 100, - "Intensity": 0.53, - "Frequency": -42 - }, - { - "Time": 133, - "Intensity": 0.94, - "Frequency": -39 - }, - { - "Time": 172, - "Intensity": 0.6, - "Frequency": -50 - }, - { - "Time": 210, - "Intensity": 0.38, - "Frequency": -50 - }, - { - "Time": 239, - "Intensity": 0.74, - "Frequency": -45 - }, - { - "Time": 287, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 7, - "Parameters": { - "Intensity": 52, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 18, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 55, - "Intensity": 0.85, - "Frequency": -44 - }, - { - "Time": 106, - "Intensity": 0.64, - "Frequency": -42 - }, - { - "Time": 136, - "Intensity": 0.91, - "Frequency": -39 - }, - { - "Time": 165, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 206, - "Intensity": 0.53, - "Frequency": -50 - }, - { - "Time": 225, - "Intensity": 0.69, - "Frequency": -45 - }, - { - "Time": 294, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 311, - "Parameters": { - "Intensity": 56, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 32, - "Intensity": 0.93, - "Frequency": -50 - }, - { - "Time": 86, - "Intensity": 0.83, - "Frequency": -47 - }, - { - "Time": 145, - "Intensity": 0.43, - "Frequency": -47 - }, - { - "Time": 196, - "Intensity": 1, - "Frequency": -41 - }, - { - "Time": 252, - "Intensity": 0.49, - "Frequency": -50 - }, - { - "Time": 280, - "Intensity": 0.86, - "Frequency": -38 - }, - { - "Time": 322, - "Intensity": 0.57, - "Frequency": -50 - }, - { - "Time": 336, - "Intensity": 0.95, - "Frequency": -38 - }, - { - "Time": 399, - "Intensity": 0.57, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 313, - "Parameters": { - "Intensity": 51, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 9, - "Intensity": 0.49, - "Frequency": -46 - }, - { - "Time": 53, - "Intensity": 0.93, - "Frequency": -47 - }, - { - "Time": 114, - "Intensity": 0.82, - "Frequency": -50 - }, - { - "Time": 149, - "Intensity": 0.59, - "Frequency": -46 - }, - { - "Time": 190, - "Intensity": 0.94, - "Frequency": -38 - }, - { - "Time": 236, - "Intensity": 0.69, - "Frequency": -50 - }, - { - "Time": 264, - "Intensity": 0.82, - "Frequency": -49 - }, - { - "Time": 310, - "Intensity": 0.74, - "Frequency": -46 - }, - { - "Time": 329, - "Intensity": 1, - "Frequency": -39 - }, - { - "Time": 394, - "Intensity": 0.69, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 714, - "Parameters": { - "Intensity": 56, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 5, - "Intensity": 0.73, - "Frequency": -39 - }, - { - "Time": 52, - "Intensity": 0.54, - "Frequency": -48 - }, - { - "Time": 96, - "Intensity": 0.68, - "Frequency": -50 - }, - { - "Time": 118, - "Intensity": 1, - "Frequency": -43 - }, - { - "Time": 161, - "Intensity": 0.81, - "Frequency": -47 - }, - { - "Time": 217, - "Intensity": 0.43, - "Frequency": -50 - }, - { - "Time": 299, - "Intensity": 0.61, - "Frequency": -38 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 716, - "Parameters": { - "Intensity": 52, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 5, - "Intensity": 0.76, - "Frequency": -40 - }, - { - "Time": 47, - "Intensity": 0.76, - "Frequency": -43 - }, - { - "Time": 79, - "Intensity": 0.81, - "Frequency": -50 - }, - { - "Time": 119, - "Intensity": 1, - "Frequency": -41 - }, - { - "Time": 166, - "Intensity": 0.82, - "Frequency": -38 - }, - { - "Time": 202, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 296, - "Intensity": 0.65, - "Frequency": -38 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1016, - "Parameters": { - "Intensity": 59, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 21, - "Intensity": 0.66, - "Frequency": -44 - }, - { - "Time": 74, - "Intensity": 0.67, - "Frequency": -47 - }, - { - "Time": 102, - "Intensity": 0.83, - "Frequency": -38 - }, - { - "Time": 134, - "Intensity": 0.91, - "Frequency": -39 - }, - { - "Time": 147, - "Intensity": 0.74, - "Frequency": -47 - }, - { - "Time": 195, - "Intensity": 0.6, - "Frequency": -50 - }, - { - "Time": 225, - "Intensity": 0.88, - "Frequency": -43 - }, - { - "Time": 295, - "Intensity": 0.7, - "Frequency": -45 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1017, - "Parameters": { - "Intensity": 51, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 14, - "Intensity": 0.69, - "Frequency": -47 - }, - { - "Time": 65, - "Intensity": 0.47, - "Frequency": -42 - }, - { - "Time": 95, - "Intensity": 0.75, - "Frequency": -34 - }, - { - "Time": 130, - "Intensity": 0.97, - "Frequency": -39 - }, - { - "Time": 167, - "Intensity": 0.62, - "Frequency": -50 - }, - { - "Time": 208, - "Intensity": 0.45, - "Frequency": -50 - }, - { - "Time": 226, - "Intensity": 0.99, - "Frequency": -39 - }, - { - "Time": 296, - "Intensity": 0.72, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1323, - "Parameters": { - "Intensity": 57, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.46, - "Frequency": -39 - }, - { - "Time": 31, - "Intensity": 0.73, - "Frequency": -50 - }, - { - "Time": 70, - "Intensity": 0.94, - "Frequency": -50 - }, - { - "Time": 115, - "Intensity": 0.79, - "Frequency": -37 - }, - { - "Time": 134, - "Intensity": 0.6, - "Frequency": -38 - }, - { - "Time": 154, - "Intensity": 0.77, - "Frequency": -47 - }, - { - "Time": 185, - "Intensity": 0.71, - "Frequency": -50 - }, - { - "Time": 217, - "Intensity": 0.57, - "Frequency": -48 - }, - { - "Time": 275, - "Intensity": 0.64, - "Frequency": -46 - }, - { - "Time": 297, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1327, - "Parameters": { - "Intensity": 53, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 2, - "Intensity": 0.42, - "Frequency": -47 - }, - { - "Time": 29, - "Intensity": 0.78, - "Frequency": -50 - }, - { - "Time": 74, - "Intensity": 0.95, - "Frequency": -45 - }, - { - "Time": 108, - "Intensity": 0.65, - "Frequency": -39 - }, - { - "Time": 131, - "Intensity": 0.39, - "Frequency": -45 - }, - { - "Time": 164, - "Intensity": 0.76, - "Frequency": -46 - }, - { - "Time": 194, - "Intensity": 0.69, - "Frequency": -43 - }, - { - "Time": 235, - "Intensity": 0.41, - "Frequency": -46 - }, - { - "Time": 264, - "Intensity": 0.6, - "Frequency": -41 - }, - { - "Time": 295, - "Intensity": 0.49, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1627, - "Parameters": { - "Intensity": 62, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.35, - "Frequency": -46 - }, - { - "Time": 37, - "Intensity": 0.65, - "Frequency": -47 - }, - { - "Time": 84, - "Intensity": 0.41, - "Frequency": -50 - }, - { - "Time": 128, - "Intensity": 0.94, - "Frequency": -46 - }, - { - "Time": 154, - "Intensity": 0.51, - "Frequency": -38 - }, - { - "Time": 179, - "Intensity": 0.81, - "Frequency": -50 - }, - { - "Time": 212, - "Intensity": 0.58, - "Frequency": -49 - }, - { - "Time": 238, - "Intensity": 0.86, - "Frequency": -46 - }, - { - "Time": 277, - "Intensity": 0.79, - "Frequency": -39 - }, - { - "Time": 299, - "Intensity": 0.53, - "Frequency": -46 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 1628, - "Parameters": { - "Intensity": 57, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 7, - "Intensity": 0.49, - "Frequency": -46 - }, - { - "Time": 44, - "Intensity": 0.82, - "Frequency": -47 - }, - { - "Time": 82, - "Intensity": 0.5, - "Frequency": -50 - }, - { - "Time": 124, - "Intensity": 0.85, - "Frequency": -46 - }, - { - "Time": 154, - "Intensity": 0.53, - "Frequency": -38 - }, - { - "Time": 175, - "Intensity": 0.81, - "Frequency": -50 - }, - { - "Time": 208, - "Intensity": 0.57, - "Frequency": -49 - }, - { - "Time": 230, - "Intensity": 0.82, - "Frequency": -46 - }, - { - "Time": 278, - "Intensity": 0.78, - "Frequency": -39 - }, - { - "Time": 296, - "Intensity": 0.69, - "Frequency": -46 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 1929, - "Parameters": { - "Intensity": 59, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 24, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 82, - "Intensity": 0.62, - "Frequency": -44 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": -42 - }, - { - "Time": 186, - "Intensity": 0.72, - "Frequency": -39 - }, - { - "Time": 234, - "Intensity": 0.41, - "Frequency": -50 - }, - { - "Time": 278, - "Intensity": 0.82, - "Frequency": -50 - }, - { - "Time": 328, - "Intensity": 0.64, - "Frequency": -45 - }, - { - "Time": 392, - "Intensity": 0.54, - "Frequency": -47 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 1931, - "Parameters": { - "Intensity": 64, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 24, - "Intensity": 0.55, - "Frequency": -47 - }, - { - "Time": 85, - "Intensity": 0.65, - "Frequency": -44 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": -42 - }, - { - "Time": 189, - "Intensity": 0.72, - "Frequency": -39 - }, - { - "Time": 241, - "Intensity": 0.34, - "Frequency": -50 - }, - { - "Time": 278, - "Intensity": 0.82, - "Frequency": -50 - }, - { - "Time": 328, - "Intensity": 0.64, - "Frequency": -45 - }, - { - "Time": 392, - "Intensity": 0.54, - "Frequency": -47 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 2332, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.39, - "Frequency": -47 - }, - { - "Time": 31, - "Intensity": 0.55, - "Frequency": -42 - }, - { - "Time": 81, - "Intensity": 0.5, - "Frequency": -34 - }, - { - "Time": 96, - "Intensity": 0.84, - "Frequency": -43 - }, - { - "Time": 145, - "Intensity": 0.71, - "Frequency": -50 - }, - { - "Time": 203, - "Intensity": 0.56, - "Frequency": -50 - }, - { - "Time": 242, - "Intensity": 0.84, - "Frequency": -44 - }, - { - "Time": 296, - "Intensity": 0.72, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 2334, - "Parameters": { - "Intensity": 51, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 3, - "Intensity": 0.38, - "Frequency": -47 - }, - { - "Time": 18, - "Intensity": 0.7, - "Frequency": -42 - }, - { - "Time": 79, - "Intensity": 0.62, - "Frequency": -34 - }, - { - "Time": 95, - "Intensity": 0.88, - "Frequency": -39 - }, - { - "Time": 148, - "Intensity": 0.73, - "Frequency": -50 - }, - { - "Time": 204, - "Intensity": 0.49, - "Frequency": -50 - }, - { - "Time": 242, - "Intensity": 0.84, - "Frequency": -39 - }, - { - "Time": 296, - "Intensity": 0.72, - "Frequency": -47 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 2636, - "Parameters": { - "Intensity": 51, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 9, - "Intensity": 0.49, - "Frequency": -46 - }, - { - "Time": 53, - "Intensity": 0.93, - "Frequency": -47 - }, - { - "Time": 105, - "Intensity": 0.62, - "Frequency": -50 - }, - { - "Time": 154, - "Intensity": 0.88, - "Frequency": -46 - }, - { - "Time": 196, - "Intensity": 0.75, - "Frequency": -38 - }, - { - "Time": 230, - "Intensity": 0.52, - "Frequency": -50 - }, - { - "Time": 254, - "Intensity": 0.92, - "Frequency": -49 - }, - { - "Time": 306, - "Intensity": 0.83, - "Frequency": -46 - }, - { - "Time": 329, - "Intensity": 1, - "Frequency": -48 - }, - { - "Time": 394, - "Intensity": 0.69, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 400, - "StartTime": 2637, - "Parameters": { - "Intensity": 56, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 17, - "Intensity": 0.44, - "Frequency": -50 - }, - { - "Time": 53, - "Intensity": 0.88, - "Frequency": -47 - }, - { - "Time": 123, - "Intensity": 0.61, - "Frequency": -47 - }, - { - "Time": 169, - "Intensity": 0.8, - "Frequency": -41 - }, - { - "Time": 224, - "Intensity": 0.52, - "Frequency": -50 - }, - { - "Time": 254, - "Intensity": 0.86, - "Frequency": -38 - }, - { - "Time": 311, - "Intensity": 0.68, - "Frequency": -50 - }, - { - "Time": 336, - "Intensity": 0.95, - "Frequency": -46 - }, - { - "Time": 388, - "Intensity": 0.66, - "Frequency": -46 - }, - { - "Time": 400, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 300, - "StartTime": 3040, - "Parameters": { - "Intensity": 53, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 4, - "Intensity": 0.75, - "Frequency": -46 - }, - { - "Time": 49, - "Intensity": 0.52, - "Frequency": -43 - }, - { - "Time": 88, - "Intensity": 0.65, - "Frequency": -50 - }, - { - "Time": 114, - "Intensity": 0.85, - "Frequency": -41 - }, - { - "Time": 163, - "Intensity": 0.74, - "Frequency": -38 - }, - { - "Time": 202, - "Intensity": 0.58, - "Frequency": -50 - }, - { - "Time": 296, - "Intensity": 0.65, - "Frequency": -38 - }, - { - "Time": 300, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 301, - "StartTime": 3044, - "Parameters": { - "Intensity": 59, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 10, - "Intensity": 0.71, - "Frequency": -46 - }, - { - "Time": 46, - "Intensity": 0.47, - "Frequency": -48 - }, - { - "Time": 80, - "Intensity": 0.61, - "Frequency": -50 - }, - { - "Time": 100, - "Intensity": 0.92, - "Frequency": -43 - }, - { - "Time": 156, - "Intensity": 0.76, - "Frequency": -47 - }, - { - "Time": 212, - "Intensity": 0.44, - "Frequency": -50 - }, - { - "Time": 298, - "Intensity": 0.61, - "Frequency": -38 - }, - { - "Time": 301, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 0, + "Parameters": { + "Intensity": 56, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 12, + "Intensity": 0.59, + "Frequency": -47 + }, + { + "Time": 52, + "Intensity": 0.96, + "Frequency": -44 + }, + { + "Time": 100, + "Intensity": 0.53, + "Frequency": -42 + }, + { + "Time": 133, + "Intensity": 0.94, + "Frequency": -39 + }, + { + "Time": 172, + "Intensity": 0.6, + "Frequency": -50 + }, + { + "Time": 210, + "Intensity": 0.38, + "Frequency": -50 + }, + { + "Time": 239, + "Intensity": 0.74, + "Frequency": -45 + }, + { + "Time": 287, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 7, + "Parameters": { + "Intensity": 52, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 18, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 55, + "Intensity": 0.85, + "Frequency": -44 + }, + { + "Time": 106, + "Intensity": 0.64, + "Frequency": -42 + }, + { + "Time": 136, + "Intensity": 0.91, + "Frequency": -39 + }, + { + "Time": 165, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 206, + "Intensity": 0.53, + "Frequency": -50 + }, + { + "Time": 225, + "Intensity": 0.69, + "Frequency": -45 + }, + { + "Time": 294, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 311, + "Parameters": { + "Intensity": 56, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 32, + "Intensity": 0.93, + "Frequency": -50 + }, + { + "Time": 86, + "Intensity": 0.83, + "Frequency": -47 + }, + { + "Time": 145, + "Intensity": 0.43, + "Frequency": -47 + }, + { + "Time": 196, + "Intensity": 1, + "Frequency": -41 + }, + { + "Time": 252, + "Intensity": 0.49, + "Frequency": -50 + }, + { + "Time": 280, + "Intensity": 0.86, + "Frequency": -38 + }, + { + "Time": 322, + "Intensity": 0.57, + "Frequency": -50 + }, + { + "Time": 336, + "Intensity": 0.95, + "Frequency": -38 + }, + { + "Time": 399, + "Intensity": 0.57, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 313, + "Parameters": { + "Intensity": 51, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 9, + "Intensity": 0.49, + "Frequency": -46 + }, + { + "Time": 53, + "Intensity": 0.93, + "Frequency": -47 + }, + { + "Time": 114, + "Intensity": 0.82, + "Frequency": -50 + }, + { + "Time": 149, + "Intensity": 0.59, + "Frequency": -46 + }, + { + "Time": 190, + "Intensity": 0.94, + "Frequency": -38 + }, + { + "Time": 236, + "Intensity": 0.69, + "Frequency": -50 + }, + { + "Time": 264, + "Intensity": 0.82, + "Frequency": -49 + }, + { + "Time": 310, + "Intensity": 0.74, + "Frequency": -46 + }, + { + "Time": 329, + "Intensity": 1, + "Frequency": -39 + }, + { + "Time": 394, + "Intensity": 0.69, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 714, + "Parameters": { + "Intensity": 56, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 5, + "Intensity": 0.73, + "Frequency": -39 + }, + { + "Time": 52, + "Intensity": 0.54, + "Frequency": -48 + }, + { + "Time": 96, + "Intensity": 0.68, + "Frequency": -50 + }, + { + "Time": 118, + "Intensity": 1, + "Frequency": -43 + }, + { + "Time": 161, + "Intensity": 0.81, + "Frequency": -47 + }, + { + "Time": 217, + "Intensity": 0.43, + "Frequency": -50 + }, + { + "Time": 299, + "Intensity": 0.61, + "Frequency": -38 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 716, + "Parameters": { + "Intensity": 52, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 5, + "Intensity": 0.76, + "Frequency": -40 + }, + { + "Time": 47, + "Intensity": 0.76, + "Frequency": -43 + }, + { + "Time": 79, + "Intensity": 0.81, + "Frequency": -50 + }, + { + "Time": 119, + "Intensity": 1, + "Frequency": -41 + }, + { + "Time": 166, + "Intensity": 0.82, + "Frequency": -38 + }, + { + "Time": 202, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 296, + "Intensity": 0.65, + "Frequency": -38 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1016, + "Parameters": { + "Intensity": 59, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 21, + "Intensity": 0.66, + "Frequency": -44 + }, + { + "Time": 74, + "Intensity": 0.67, + "Frequency": -47 + }, + { + "Time": 102, + "Intensity": 0.83, + "Frequency": -38 + }, + { + "Time": 134, + "Intensity": 0.91, + "Frequency": -39 + }, + { + "Time": 147, + "Intensity": 0.74, + "Frequency": -47 + }, + { + "Time": 195, + "Intensity": 0.6, + "Frequency": -50 + }, + { + "Time": 225, + "Intensity": 0.88, + "Frequency": -43 + }, + { + "Time": 295, + "Intensity": 0.7, + "Frequency": -45 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1017, + "Parameters": { + "Intensity": 51, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 14, + "Intensity": 0.69, + "Frequency": -47 + }, + { + "Time": 65, + "Intensity": 0.47, + "Frequency": -42 + }, + { + "Time": 95, + "Intensity": 0.75, + "Frequency": -34 + }, + { + "Time": 130, + "Intensity": 0.97, + "Frequency": -39 + }, + { + "Time": 167, + "Intensity": 0.62, + "Frequency": -50 + }, + { + "Time": 208, + "Intensity": 0.45, + "Frequency": -50 + }, + { + "Time": 226, + "Intensity": 0.99, + "Frequency": -39 + }, + { + "Time": 296, + "Intensity": 0.72, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1323, + "Parameters": { + "Intensity": 57, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.46, + "Frequency": -39 + }, + { + "Time": 31, + "Intensity": 0.73, + "Frequency": -50 + }, + { + "Time": 70, + "Intensity": 0.94, + "Frequency": -50 + }, + { + "Time": 115, + "Intensity": 0.79, + "Frequency": -37 + }, + { + "Time": 134, + "Intensity": 0.6, + "Frequency": -38 + }, + { + "Time": 154, + "Intensity": 0.77, + "Frequency": -47 + }, + { + "Time": 185, + "Intensity": 0.71, + "Frequency": -50 + }, + { + "Time": 217, + "Intensity": 0.57, + "Frequency": -48 + }, + { + "Time": 275, + "Intensity": 0.64, + "Frequency": -46 + }, + { + "Time": 297, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1327, + "Parameters": { + "Intensity": 53, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 2, + "Intensity": 0.42, + "Frequency": -47 + }, + { + "Time": 29, + "Intensity": 0.78, + "Frequency": -50 + }, + { + "Time": 74, + "Intensity": 0.95, + "Frequency": -45 + }, + { + "Time": 108, + "Intensity": 0.65, + "Frequency": -39 + }, + { + "Time": 131, + "Intensity": 0.39, + "Frequency": -45 + }, + { + "Time": 164, + "Intensity": 0.76, + "Frequency": -46 + }, + { + "Time": 194, + "Intensity": 0.69, + "Frequency": -43 + }, + { + "Time": 235, + "Intensity": 0.41, + "Frequency": -46 + }, + { + "Time": 264, + "Intensity": 0.6, + "Frequency": -41 + }, + { + "Time": 295, + "Intensity": 0.49, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1627, + "Parameters": { + "Intensity": 62, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.35, + "Frequency": -46 + }, + { + "Time": 37, + "Intensity": 0.65, + "Frequency": -47 + }, + { + "Time": 84, + "Intensity": 0.41, + "Frequency": -50 + }, + { + "Time": 128, + "Intensity": 0.94, + "Frequency": -46 + }, + { + "Time": 154, + "Intensity": 0.51, + "Frequency": -38 + }, + { + "Time": 179, + "Intensity": 0.81, + "Frequency": -50 + }, + { + "Time": 212, + "Intensity": 0.58, + "Frequency": -49 + }, + { + "Time": 238, + "Intensity": 0.86, + "Frequency": -46 + }, + { + "Time": 277, + "Intensity": 0.79, + "Frequency": -39 + }, + { + "Time": 299, + "Intensity": 0.53, + "Frequency": -46 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 1628, + "Parameters": { + "Intensity": 57, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 7, + "Intensity": 0.49, + "Frequency": -46 + }, + { + "Time": 44, + "Intensity": 0.82, + "Frequency": -47 + }, + { + "Time": 82, + "Intensity": 0.5, + "Frequency": -50 + }, + { + "Time": 124, + "Intensity": 0.85, + "Frequency": -46 + }, + { + "Time": 154, + "Intensity": 0.53, + "Frequency": -38 + }, + { + "Time": 175, + "Intensity": 0.81, + "Frequency": -50 + }, + { + "Time": 208, + "Intensity": 0.57, + "Frequency": -49 + }, + { + "Time": 230, + "Intensity": 0.82, + "Frequency": -46 + }, + { + "Time": 278, + "Intensity": 0.78, + "Frequency": -39 + }, + { + "Time": 296, + "Intensity": 0.69, + "Frequency": -46 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 1929, + "Parameters": { + "Intensity": 59, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 24, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 82, + "Intensity": 0.62, + "Frequency": -44 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": -42 + }, + { + "Time": 186, + "Intensity": 0.72, + "Frequency": -39 + }, + { + "Time": 234, + "Intensity": 0.41, + "Frequency": -50 + }, + { + "Time": 278, + "Intensity": 0.82, + "Frequency": -50 + }, + { + "Time": 328, + "Intensity": 0.64, + "Frequency": -45 + }, + { + "Time": 392, + "Intensity": 0.54, + "Frequency": -47 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 1931, + "Parameters": { + "Intensity": 64, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 24, + "Intensity": 0.55, + "Frequency": -47 + }, + { + "Time": 85, + "Intensity": 0.65, + "Frequency": -44 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": -42 + }, + { + "Time": 189, + "Intensity": 0.72, + "Frequency": -39 + }, + { + "Time": 241, + "Intensity": 0.34, + "Frequency": -50 + }, + { + "Time": 278, + "Intensity": 0.82, + "Frequency": -50 + }, + { + "Time": 328, + "Intensity": 0.64, + "Frequency": -45 + }, + { + "Time": 392, + "Intensity": 0.54, + "Frequency": -47 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 2332, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.39, + "Frequency": -47 + }, + { + "Time": 31, + "Intensity": 0.55, + "Frequency": -42 + }, + { + "Time": 81, + "Intensity": 0.5, + "Frequency": -34 + }, + { + "Time": 96, + "Intensity": 0.84, + "Frequency": -43 + }, + { + "Time": 145, + "Intensity": 0.71, + "Frequency": -50 + }, + { + "Time": 203, + "Intensity": 0.56, + "Frequency": -50 + }, + { + "Time": 242, + "Intensity": 0.84, + "Frequency": -44 + }, + { + "Time": 296, + "Intensity": 0.72, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 2334, + "Parameters": { + "Intensity": 51, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 3, + "Intensity": 0.38, + "Frequency": -47 + }, + { + "Time": 18, + "Intensity": 0.7, + "Frequency": -42 + }, + { + "Time": 79, + "Intensity": 0.62, + "Frequency": -34 + }, + { + "Time": 95, + "Intensity": 0.88, + "Frequency": -39 + }, + { + "Time": 148, + "Intensity": 0.73, + "Frequency": -50 + }, + { + "Time": 204, + "Intensity": 0.49, + "Frequency": -50 + }, + { + "Time": 242, + "Intensity": 0.84, + "Frequency": -39 + }, + { + "Time": 296, + "Intensity": 0.72, + "Frequency": -47 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 2636, + "Parameters": { + "Intensity": 51, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 9, + "Intensity": 0.49, + "Frequency": -46 + }, + { + "Time": 53, + "Intensity": 0.93, + "Frequency": -47 + }, + { + "Time": 105, + "Intensity": 0.62, + "Frequency": -50 + }, + { + "Time": 154, + "Intensity": 0.88, + "Frequency": -46 + }, + { + "Time": 196, + "Intensity": 0.75, + "Frequency": -38 + }, + { + "Time": 230, + "Intensity": 0.52, + "Frequency": -50 + }, + { + "Time": 254, + "Intensity": 0.92, + "Frequency": -49 + }, + { + "Time": 306, + "Intensity": 0.83, + "Frequency": -46 + }, + { + "Time": 329, + "Intensity": 1, + "Frequency": -48 + }, + { + "Time": 394, + "Intensity": 0.69, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 400, + "StartTime": 2637, + "Parameters": { + "Intensity": 56, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 17, + "Intensity": 0.44, + "Frequency": -50 + }, + { + "Time": 53, + "Intensity": 0.88, + "Frequency": -47 + }, + { + "Time": 123, + "Intensity": 0.61, + "Frequency": -47 + }, + { + "Time": 169, + "Intensity": 0.8, + "Frequency": -41 + }, + { + "Time": 224, + "Intensity": 0.52, + "Frequency": -50 + }, + { + "Time": 254, + "Intensity": 0.86, + "Frequency": -38 + }, + { + "Time": 311, + "Intensity": 0.68, + "Frequency": -50 + }, + { + "Time": 336, + "Intensity": 0.95, + "Frequency": -46 + }, + { + "Time": 388, + "Intensity": 0.66, + "Frequency": -46 + }, + { + "Time": 400, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 300, + "StartTime": 3040, + "Parameters": { + "Intensity": 53, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 4, + "Intensity": 0.75, + "Frequency": -46 + }, + { + "Time": 49, + "Intensity": 0.52, + "Frequency": -43 + }, + { + "Time": 88, + "Intensity": 0.65, + "Frequency": -50 + }, + { + "Time": 114, + "Intensity": 0.85, + "Frequency": -41 + }, + { + "Time": 163, + "Intensity": 0.74, + "Frequency": -38 + }, + { + "Time": 202, + "Intensity": 0.58, + "Frequency": -50 + }, + { + "Time": 296, + "Intensity": 0.65, + "Frequency": -38 + }, + { + "Time": 300, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 301, + "StartTime": 3044, + "Parameters": { + "Intensity": 59, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 10, + "Intensity": 0.71, + "Frequency": -46 + }, + { + "Time": 46, + "Intensity": 0.47, + "Frequency": -48 + }, + { + "Time": 80, + "Intensity": 0.61, + "Frequency": -50 + }, + { + "Time": 100, + "Intensity": 0.92, + "Frequency": -43 + }, + { + "Time": 156, + "Intensity": 0.76, + "Frequency": -47 + }, + { + "Time": 212, + "Intensity": 0.44, + "Frequency": -50 + }, + { + "Time": 298, + "Intensity": 0.61, + "Frequency": -38 + }, + { + "Time": 301, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_h.json index d8867502e2..1c097b8129 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_h.json @@ -1,50 +1,50 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 1617, - "StartTime": 29, - "Parameters": { - "Intensity": 100, - "Frequency": 70, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": -59 - }, - { - "Time": 5, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 63 - }, - { - "Time": 1617, - "Intensity": 0.0, - "Frequency": 100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 1617, + "StartTime": 29, + "Parameters": { + "Intensity": 100, + "Frequency": 70, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": -59 + }, + { + "Time": 5, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 63 + }, + { + "Time": 1617, + "Intensity": 0.0, + "Frequency": 100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_l.json index 7298d99657..803c85e872 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_l.json @@ -1,50 +1,50 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 1617, - "StartTime": 29, - "Parameters": { - "Intensity": 60, - "Frequency": 70, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": -59 - }, - { - "Time": 5, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 63 - }, - { - "Time": 1617, - "Intensity": 0.0, - "Frequency": 100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 1617, + "StartTime": 29, + "Parameters": { + "Intensity": 60, + "Frequency": 70, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": -59 + }, + { + "Time": 5, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 63 + }, + { + "Time": 1617, + "Intensity": 0.0, + "Frequency": 100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_m.json index 7b867cde4a..30ad230616 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals2_m.json @@ -1,50 +1,50 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 1617, - "StartTime": 29, - "Parameters": { - "Intensity": 80, - "Frequency": 70, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": -59 - }, - { - "Time": 5, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 63 - }, - { - "Time": 1617, - "Intensity": 0.0, - "Frequency": 100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 1617, + "StartTime": 29, + "Parameters": { + "Intensity": 80, + "Frequency": 70, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": -59 + }, + { + "Time": 5, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 63 + }, + { + "Time": 1617, + "Intensity": 0.0, + "Frequency": 100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_h.json index fd86767f10..2ed96e002e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_h.json @@ -1,50 +1,50 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 158, - "StartTime": 0, - "Parameters": { - "Intensity": 100, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 5, - "Intensity": 1.0, - "Frequency": 40 - }, - { - "Time": 36, - "Intensity": 0.51, - "Frequency": -19 - }, - { - "Time": 158, - "Intensity": 0.0, - "Frequency": 100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 158, + "StartTime": 0, + "Parameters": { + "Intensity": 100, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 5, + "Intensity": 1.0, + "Frequency": 40 + }, + { + "Time": 36, + "Intensity": 0.51, + "Frequency": -19 + }, + { + "Time": 158, + "Intensity": 0.0, + "Frequency": 100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_l.json index 3e28cb4590..f5c0015367 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_l.json @@ -1,50 +1,50 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 158, - "StartTime": 0, - "Parameters": { - "Intensity": 60, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 5, - "Intensity": 1.0, - "Frequency": 40 - }, - { - "Time": 36, - "Intensity": 0.51, - "Frequency": -19 - }, - { - "Time": 158, - "Intensity": 0.0, - "Frequency": 100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 158, + "StartTime": 0, + "Parameters": { + "Intensity": 60, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 5, + "Intensity": 1.0, + "Frequency": 40 + }, + { + "Time": 36, + "Intensity": 0.51, + "Frequency": -19 + }, + { + "Time": 158, + "Intensity": 0.0, + "Frequency": 100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_m.json index a82c789071..6c85b0a64f 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Cymbals_m.json @@ -1,50 +1,50 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 158, - "StartTime": 0, - "Parameters": { - "Intensity": 80, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 5, - "Intensity": 1.0, - "Frequency": 40 - }, - { - "Time": 36, - "Intensity": 0.51, - "Frequency": -19 - }, - { - "Time": 158, - "Intensity": 0.0, - "Frequency": 100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 158, + "StartTime": 0, + "Parameters": { + "Intensity": 80, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 5, + "Intensity": 1.0, + "Frequency": 40 + }, + { + "Time": 36, + "Intensity": 0.51, + "Frequency": -19 + }, + { + "Time": 158, + "Intensity": 0.0, + "Frequency": 100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_h.json index 163f281332..74ec332759 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_h.json @@ -1,797 +1,797 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 135, - "StartTime": 110, - "Parameters": { - "Intensity": 38, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 77, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 106, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 135, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 138, - "StartTime": 255, - "Parameters": { - "Intensity": 95, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 23, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 75, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 80, - "Intensity": 0.43, - "Frequency": -25 - }, - { - "Time": 131, - "Intensity": 0.35, - "Frequency": 20 - }, - { - "Time": 138, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 414, - "Parameters": { - "Intensity": 51, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 256, - "StartTime": 474, - "Parameters": { - "Intensity": 42, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 0.46, - "Frequency": 3 - }, - { - "Time": 71, - "Intensity": 0.5, - "Frequency": -5 - }, - { - "Time": 163, - "Intensity": 1, - "Frequency": 3 - }, - { - "Time": 222, - "Intensity": 1, - "Frequency": -3 - }, - { - "Time": 255, - "Intensity": 0.72, - "Frequency": 0 - }, - { - "Time": 256, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 574, - "Parameters": { - "Intensity": 43, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 95, - "Intensity": 0.48, - "Frequency": -6 - }, - { - "Time": 140, - "Intensity": 0.09, - "Frequency": 0 - }, - { - "Time": 170, - "Intensity": 0.89, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 257, - "StartTime": 731, - "Parameters": { - "Intensity": 35, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.88, - "Frequency": 3 - }, - { - "Time": 64, - "Intensity": 0.82, - "Frequency": -5 - }, - { - "Time": 128, - "Intensity": 0.42, - "Frequency": 0 - }, - { - "Time": 202, - "Intensity": 0.4, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.31, - "Frequency": -3 - }, - { - "Time": 257, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 990, - "Parameters": { - "Intensity": 70, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.29, - "Frequency": 3 - }, - { - "Time": 34, - "Intensity": 0.47, - "Frequency": -5 - }, - { - "Time": 76, - "Intensity": 0.52, - "Frequency": 3 - }, - { - "Time": 138, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 208, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 249, - "Intensity": 0.29, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 990, - "Parameters": { - "Intensity": 32, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 102, - "Intensity": 0.72, - "Frequency": -6 - }, - { - "Time": 144, - "Intensity": 0.09, - "Frequency": 8 - }, - { - "Time": 169, - "Intensity": 0.25, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 230, - "Intensity": 0.53, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 298, - "StartTime": 1242, - "Parameters": { - "Intensity": 55, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.39, - "Frequency": 3 - }, - { - "Time": 99, - "Intensity": 0.5, - "Frequency": -5 - }, - { - "Time": 212, - "Intensity": 0.29, - "Frequency": 3 - }, - { - "Time": 297, - "Intensity": 0.3, - "Frequency": -3 - }, - { - "Time": 298, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 298, - "StartTime": 1244, - "Parameters": { - "Intensity": 31, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 27, - "Intensity": 0.6, - "Frequency": 5 - }, - { - "Time": 79, - "Intensity": 0.08, - "Frequency": -13 - }, - { - "Time": 101, - "Intensity": 0.81, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.17, - "Frequency": 0 - }, - { - "Time": 202, - "Intensity": 0.24, - "Frequency": -16 - }, - { - "Time": 238, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 277, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 298, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1541, - "Parameters": { - "Intensity": 26, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1542, - "Parameters": { - "Intensity": 59, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.27, - "Frequency": 3 - }, - { - "Time": 40, - "Intensity": 0.39, - "Frequency": -5 - }, - { - "Time": 91, - "Intensity": 0.37, - "Frequency": 0 - }, - { - "Time": 135, - "Intensity": 0.43, - "Frequency": 3 - }, - { - "Time": 201, - "Intensity": 0.37, - "Frequency": 0 - }, - { - "Time": 249, - "Intensity": 0.25, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1793, - "Parameters": { - "Intensity": 55, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.28, - "Frequency": 3 - }, - { - "Time": 46, - "Intensity": 0.3, - "Frequency": -5 - }, - { - "Time": 105, - "Intensity": 0.41, - "Frequency": 3 - }, - { - "Time": 162, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 213, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 249, - "Intensity": 0.23, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1793, - "Parameters": { - "Intensity": 20, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 251, - "StartTime": 2043, - "Parameters": { - "Intensity": 30, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.4, - "Frequency": 3 - }, - { - "Time": 81, - "Intensity": 0.71, - "Frequency": -5 - }, - { - "Time": 189, - "Intensity": 0.54, - "Frequency": 3 - }, - { - "Time": 212, - "Intensity": 0.26, - "Frequency": -3 - }, - { - "Time": 251, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2043, - "Parameters": { - "Intensity": 25, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 135, + "StartTime": 110, + "Parameters": { + "Intensity": 38, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 77, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 106, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 135, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 138, + "StartTime": 255, + "Parameters": { + "Intensity": 95, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 23, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 75, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 80, + "Intensity": 0.43, + "Frequency": -25 + }, + { + "Time": 131, + "Intensity": 0.35, + "Frequency": 20 + }, + { + "Time": 138, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 414, + "Parameters": { + "Intensity": 51, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 256, + "StartTime": 474, + "Parameters": { + "Intensity": 42, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 0.46, + "Frequency": 3 + }, + { + "Time": 71, + "Intensity": 0.5, + "Frequency": -5 + }, + { + "Time": 163, + "Intensity": 1, + "Frequency": 3 + }, + { + "Time": 222, + "Intensity": 1, + "Frequency": -3 + }, + { + "Time": 255, + "Intensity": 0.72, + "Frequency": 0 + }, + { + "Time": 256, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 574, + "Parameters": { + "Intensity": 43, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 95, + "Intensity": 0.48, + "Frequency": -6 + }, + { + "Time": 140, + "Intensity": 0.09, + "Frequency": 0 + }, + { + "Time": 170, + "Intensity": 0.89, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 257, + "StartTime": 731, + "Parameters": { + "Intensity": 35, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.88, + "Frequency": 3 + }, + { + "Time": 64, + "Intensity": 0.82, + "Frequency": -5 + }, + { + "Time": 128, + "Intensity": 0.42, + "Frequency": 0 + }, + { + "Time": 202, + "Intensity": 0.4, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.31, + "Frequency": -3 + }, + { + "Time": 257, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 990, + "Parameters": { + "Intensity": 70, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.29, + "Frequency": 3 + }, + { + "Time": 34, + "Intensity": 0.47, + "Frequency": -5 + }, + { + "Time": 76, + "Intensity": 0.52, + "Frequency": 3 + }, + { + "Time": 138, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 208, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 249, + "Intensity": 0.29, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 990, + "Parameters": { + "Intensity": 32, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 102, + "Intensity": 0.72, + "Frequency": -6 + }, + { + "Time": 144, + "Intensity": 0.09, + "Frequency": 8 + }, + { + "Time": 169, + "Intensity": 0.25, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 230, + "Intensity": 0.53, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 298, + "StartTime": 1242, + "Parameters": { + "Intensity": 55, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.39, + "Frequency": 3 + }, + { + "Time": 99, + "Intensity": 0.5, + "Frequency": -5 + }, + { + "Time": 212, + "Intensity": 0.29, + "Frequency": 3 + }, + { + "Time": 297, + "Intensity": 0.3, + "Frequency": -3 + }, + { + "Time": 298, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 298, + "StartTime": 1244, + "Parameters": { + "Intensity": 31, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 27, + "Intensity": 0.6, + "Frequency": 5 + }, + { + "Time": 79, + "Intensity": 0.08, + "Frequency": -13 + }, + { + "Time": 101, + "Intensity": 0.81, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.17, + "Frequency": 0 + }, + { + "Time": 202, + "Intensity": 0.24, + "Frequency": -16 + }, + { + "Time": 238, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 277, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 298, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1541, + "Parameters": { + "Intensity": 26, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1542, + "Parameters": { + "Intensity": 59, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.27, + "Frequency": 3 + }, + { + "Time": 40, + "Intensity": 0.39, + "Frequency": -5 + }, + { + "Time": 91, + "Intensity": 0.37, + "Frequency": 0 + }, + { + "Time": 135, + "Intensity": 0.43, + "Frequency": 3 + }, + { + "Time": 201, + "Intensity": 0.37, + "Frequency": 0 + }, + { + "Time": 249, + "Intensity": 0.25, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1793, + "Parameters": { + "Intensity": 55, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.28, + "Frequency": 3 + }, + { + "Time": 46, + "Intensity": 0.3, + "Frequency": -5 + }, + { + "Time": 105, + "Intensity": 0.41, + "Frequency": 3 + }, + { + "Time": 162, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 213, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 249, + "Intensity": 0.23, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1793, + "Parameters": { + "Intensity": 20, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 251, + "StartTime": 2043, + "Parameters": { + "Intensity": 30, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.4, + "Frequency": 3 + }, + { + "Time": 81, + "Intensity": 0.71, + "Frequency": -5 + }, + { + "Time": 189, + "Intensity": 0.54, + "Frequency": 3 + }, + { + "Time": 212, + "Intensity": 0.26, + "Frequency": -3 + }, + { + "Time": 251, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2043, + "Parameters": { + "Intensity": 25, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_l.json index 60cdf5ccab..693b1de4bd 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_l.json @@ -1,797 +1,797 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 135, - "StartTime": 110, - "Parameters": { - "Intensity": 22, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 77, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 106, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 135, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 138, - "StartTime": 255, - "Parameters": { - "Intensity": 57, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 23, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 75, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 80, - "Intensity": 0.43, - "Frequency": -25 - }, - { - "Time": 131, - "Intensity": 0.35, - "Frequency": 20 - }, - { - "Time": 138, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 414, - "Parameters": { - "Intensity": 30, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 256, - "StartTime": 474, - "Parameters": { - "Intensity": 25, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 0.46, - "Frequency": 3 - }, - { - "Time": 71, - "Intensity": 0.5, - "Frequency": -5 - }, - { - "Time": 163, - "Intensity": 1, - "Frequency": 3 - }, - { - "Time": 222, - "Intensity": 1, - "Frequency": -3 - }, - { - "Time": 255, - "Intensity": 0.72, - "Frequency": 0 - }, - { - "Time": 256, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 574, - "Parameters": { - "Intensity": 25, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 95, - "Intensity": 0.48, - "Frequency": -6 - }, - { - "Time": 140, - "Intensity": 0.09, - "Frequency": 0 - }, - { - "Time": 170, - "Intensity": 0.89, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 257, - "StartTime": 731, - "Parameters": { - "Intensity": 21, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.88, - "Frequency": 3 - }, - { - "Time": 64, - "Intensity": 0.82, - "Frequency": -5 - }, - { - "Time": 128, - "Intensity": 0.42, - "Frequency": 0 - }, - { - "Time": 202, - "Intensity": 0.4, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.31, - "Frequency": -3 - }, - { - "Time": 257, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 990, - "Parameters": { - "Intensity": 42, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.29, - "Frequency": 3 - }, - { - "Time": 34, - "Intensity": 0.47, - "Frequency": -5 - }, - { - "Time": 76, - "Intensity": 0.52, - "Frequency": 3 - }, - { - "Time": 138, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 208, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 249, - "Intensity": 0.29, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 990, - "Parameters": { - "Intensity": 19, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 102, - "Intensity": 0.72, - "Frequency": -6 - }, - { - "Time": 144, - "Intensity": 0.09, - "Frequency": 8 - }, - { - "Time": 169, - "Intensity": 0.25, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 230, - "Intensity": 0.53, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 298, - "StartTime": 1242, - "Parameters": { - "Intensity": 33, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.39, - "Frequency": 3 - }, - { - "Time": 99, - "Intensity": 0.5, - "Frequency": -5 - }, - { - "Time": 212, - "Intensity": 0.29, - "Frequency": 3 - }, - { - "Time": 297, - "Intensity": 0.3, - "Frequency": -3 - }, - { - "Time": 298, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 298, - "StartTime": 1244, - "Parameters": { - "Intensity": 18, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 27, - "Intensity": 0.6, - "Frequency": 5 - }, - { - "Time": 79, - "Intensity": 0.08, - "Frequency": -13 - }, - { - "Time": 101, - "Intensity": 0.81, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.17, - "Frequency": 0 - }, - { - "Time": 202, - "Intensity": 0.24, - "Frequency": -16 - }, - { - "Time": 238, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 277, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 298, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1541, - "Parameters": { - "Intensity": 15, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1542, - "Parameters": { - "Intensity": 35, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.27, - "Frequency": 3 - }, - { - "Time": 40, - "Intensity": 0.39, - "Frequency": -5 - }, - { - "Time": 91, - "Intensity": 0.37, - "Frequency": 0 - }, - { - "Time": 135, - "Intensity": 0.43, - "Frequency": 3 - }, - { - "Time": 201, - "Intensity": 0.37, - "Frequency": 0 - }, - { - "Time": 249, - "Intensity": 0.25, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1793, - "Parameters": { - "Intensity": 33, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.28, - "Frequency": 3 - }, - { - "Time": 46, - "Intensity": 0.3, - "Frequency": -5 - }, - { - "Time": 105, - "Intensity": 0.41, - "Frequency": 3 - }, - { - "Time": 162, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 213, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 249, - "Intensity": 0.23, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1793, - "Parameters": { - "Intensity": 12, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 251, - "StartTime": 2043, - "Parameters": { - "Intensity": 18, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.4, - "Frequency": 3 - }, - { - "Time": 81, - "Intensity": 0.71, - "Frequency": -5 - }, - { - "Time": 189, - "Intensity": 0.54, - "Frequency": 3 - }, - { - "Time": 212, - "Intensity": 0.26, - "Frequency": -3 - }, - { - "Time": 251, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2043, - "Parameters": { - "Intensity": 15, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 135, + "StartTime": 110, + "Parameters": { + "Intensity": 22, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 77, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 106, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 135, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 138, + "StartTime": 255, + "Parameters": { + "Intensity": 57, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 23, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 75, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 80, + "Intensity": 0.43, + "Frequency": -25 + }, + { + "Time": 131, + "Intensity": 0.35, + "Frequency": 20 + }, + { + "Time": 138, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 414, + "Parameters": { + "Intensity": 30, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 256, + "StartTime": 474, + "Parameters": { + "Intensity": 25, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 0.46, + "Frequency": 3 + }, + { + "Time": 71, + "Intensity": 0.5, + "Frequency": -5 + }, + { + "Time": 163, + "Intensity": 1, + "Frequency": 3 + }, + { + "Time": 222, + "Intensity": 1, + "Frequency": -3 + }, + { + "Time": 255, + "Intensity": 0.72, + "Frequency": 0 + }, + { + "Time": 256, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 574, + "Parameters": { + "Intensity": 25, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 95, + "Intensity": 0.48, + "Frequency": -6 + }, + { + "Time": 140, + "Intensity": 0.09, + "Frequency": 0 + }, + { + "Time": 170, + "Intensity": 0.89, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 257, + "StartTime": 731, + "Parameters": { + "Intensity": 21, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.88, + "Frequency": 3 + }, + { + "Time": 64, + "Intensity": 0.82, + "Frequency": -5 + }, + { + "Time": 128, + "Intensity": 0.42, + "Frequency": 0 + }, + { + "Time": 202, + "Intensity": 0.4, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.31, + "Frequency": -3 + }, + { + "Time": 257, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 990, + "Parameters": { + "Intensity": 42, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.29, + "Frequency": 3 + }, + { + "Time": 34, + "Intensity": 0.47, + "Frequency": -5 + }, + { + "Time": 76, + "Intensity": 0.52, + "Frequency": 3 + }, + { + "Time": 138, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 208, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 249, + "Intensity": 0.29, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 990, + "Parameters": { + "Intensity": 19, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 102, + "Intensity": 0.72, + "Frequency": -6 + }, + { + "Time": 144, + "Intensity": 0.09, + "Frequency": 8 + }, + { + "Time": 169, + "Intensity": 0.25, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 230, + "Intensity": 0.53, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 298, + "StartTime": 1242, + "Parameters": { + "Intensity": 33, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.39, + "Frequency": 3 + }, + { + "Time": 99, + "Intensity": 0.5, + "Frequency": -5 + }, + { + "Time": 212, + "Intensity": 0.29, + "Frequency": 3 + }, + { + "Time": 297, + "Intensity": 0.3, + "Frequency": -3 + }, + { + "Time": 298, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 298, + "StartTime": 1244, + "Parameters": { + "Intensity": 18, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 27, + "Intensity": 0.6, + "Frequency": 5 + }, + { + "Time": 79, + "Intensity": 0.08, + "Frequency": -13 + }, + { + "Time": 101, + "Intensity": 0.81, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.17, + "Frequency": 0 + }, + { + "Time": 202, + "Intensity": 0.24, + "Frequency": -16 + }, + { + "Time": 238, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 277, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 298, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1541, + "Parameters": { + "Intensity": 15, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1542, + "Parameters": { + "Intensity": 35, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.27, + "Frequency": 3 + }, + { + "Time": 40, + "Intensity": 0.39, + "Frequency": -5 + }, + { + "Time": 91, + "Intensity": 0.37, + "Frequency": 0 + }, + { + "Time": 135, + "Intensity": 0.43, + "Frequency": 3 + }, + { + "Time": 201, + "Intensity": 0.37, + "Frequency": 0 + }, + { + "Time": 249, + "Intensity": 0.25, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1793, + "Parameters": { + "Intensity": 33, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.28, + "Frequency": 3 + }, + { + "Time": 46, + "Intensity": 0.3, + "Frequency": -5 + }, + { + "Time": 105, + "Intensity": 0.41, + "Frequency": 3 + }, + { + "Time": 162, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 213, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 249, + "Intensity": 0.23, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1793, + "Parameters": { + "Intensity": 12, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 251, + "StartTime": 2043, + "Parameters": { + "Intensity": 18, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.4, + "Frequency": 3 + }, + { + "Time": 81, + "Intensity": 0.71, + "Frequency": -5 + }, + { + "Time": 189, + "Intensity": 0.54, + "Frequency": 3 + }, + { + "Time": 212, + "Intensity": 0.26, + "Frequency": -3 + }, + { + "Time": 251, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2043, + "Parameters": { + "Intensity": 15, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_m.json index ea582b9abe..c9053b0e5f 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Diving_m.json @@ -1,797 +1,797 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 135, - "StartTime": 110, - "Parameters": { - "Intensity": 30, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 77, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 106, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 135, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 138, - "StartTime": 255, - "Parameters": { - "Intensity": 76, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 20 - }, - { - "Time": 23, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 75, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 80, - "Intensity": 0.43, - "Frequency": -25 - }, - { - "Time": 131, - "Intensity": 0.35, - "Frequency": 20 - }, - { - "Time": 138, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 414, - "Parameters": { - "Intensity": 40, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 256, - "StartTime": 474, - "Parameters": { - "Intensity": 33, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 0.46, - "Frequency": 3 - }, - { - "Time": 71, - "Intensity": 0.5, - "Frequency": -5 - }, - { - "Time": 163, - "Intensity": 1, - "Frequency": 3 - }, - { - "Time": 222, - "Intensity": 1, - "Frequency": -3 - }, - { - "Time": 255, - "Intensity": 0.72, - "Frequency": 0 - }, - { - "Time": 256, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 574, - "Parameters": { - "Intensity": 34, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 95, - "Intensity": 0.48, - "Frequency": -6 - }, - { - "Time": 140, - "Intensity": 0.09, - "Frequency": 0 - }, - { - "Time": 170, - "Intensity": 0.89, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 257, - "StartTime": 731, - "Parameters": { - "Intensity": 28, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.88, - "Frequency": 3 - }, - { - "Time": 64, - "Intensity": 0.82, - "Frequency": -5 - }, - { - "Time": 128, - "Intensity": 0.42, - "Frequency": 0 - }, - { - "Time": 202, - "Intensity": 0.4, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.31, - "Frequency": -3 - }, - { - "Time": 257, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 990, - "Parameters": { - "Intensity": 56, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.29, - "Frequency": 3 - }, - { - "Time": 34, - "Intensity": 0.47, - "Frequency": -5 - }, - { - "Time": 76, - "Intensity": 0.52, - "Frequency": 3 - }, - { - "Time": 138, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 208, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 249, - "Intensity": 0.29, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 990, - "Parameters": { - "Intensity": 25, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 102, - "Intensity": 0.72, - "Frequency": -6 - }, - { - "Time": 144, - "Intensity": 0.09, - "Frequency": 8 - }, - { - "Time": 169, - "Intensity": 0.25, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 230, - "Intensity": 0.53, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 298, - "StartTime": 1242, - "Parameters": { - "Intensity": 44, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.39, - "Frequency": 3 - }, - { - "Time": 99, - "Intensity": 0.5, - "Frequency": -5 - }, - { - "Time": 212, - "Intensity": 0.29, - "Frequency": 3 - }, - { - "Time": 297, - "Intensity": 0.3, - "Frequency": -3 - }, - { - "Time": 298, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 298, - "StartTime": 1244, - "Parameters": { - "Intensity": 24, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 27, - "Intensity": 0.6, - "Frequency": 5 - }, - { - "Time": 79, - "Intensity": 0.08, - "Frequency": -13 - }, - { - "Time": 101, - "Intensity": 0.81, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.17, - "Frequency": 0 - }, - { - "Time": 202, - "Intensity": 0.24, - "Frequency": -16 - }, - { - "Time": 238, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 277, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 298, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1541, - "Parameters": { - "Intensity": 20, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1542, - "Parameters": { - "Intensity": 47, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.27, - "Frequency": 3 - }, - { - "Time": 40, - "Intensity": 0.39, - "Frequency": -5 - }, - { - "Time": 91, - "Intensity": 0.37, - "Frequency": 0 - }, - { - "Time": 135, - "Intensity": 0.43, - "Frequency": 3 - }, - { - "Time": 201, - "Intensity": 0.37, - "Frequency": 0 - }, - { - "Time": 249, - "Intensity": 0.25, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1793, - "Parameters": { - "Intensity": 44, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.28, - "Frequency": 3 - }, - { - "Time": 46, - "Intensity": 0.3, - "Frequency": -5 - }, - { - "Time": 105, - "Intensity": 0.41, - "Frequency": 3 - }, - { - "Time": 162, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 213, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 249, - "Intensity": 0.23, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1793, - "Parameters": { - "Intensity": 16, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 251, - "StartTime": 2043, - "Parameters": { - "Intensity": 24, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.4, - "Frequency": 3 - }, - { - "Time": 81, - "Intensity": 0.71, - "Frequency": -5 - }, - { - "Time": 189, - "Intensity": 0.54, - "Frequency": 3 - }, - { - "Time": 212, - "Intensity": 0.26, - "Frequency": -3 - }, - { - "Time": 251, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2043, - "Parameters": { - "Intensity": 20, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 135, + "StartTime": 110, + "Parameters": { + "Intensity": 30, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 77, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 106, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 135, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 138, + "StartTime": 255, + "Parameters": { + "Intensity": 76, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 20 + }, + { + "Time": 23, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 75, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 80, + "Intensity": 0.43, + "Frequency": -25 + }, + { + "Time": 131, + "Intensity": 0.35, + "Frequency": 20 + }, + { + "Time": 138, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 414, + "Parameters": { + "Intensity": 40, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 256, + "StartTime": 474, + "Parameters": { + "Intensity": 33, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 0.46, + "Frequency": 3 + }, + { + "Time": 71, + "Intensity": 0.5, + "Frequency": -5 + }, + { + "Time": 163, + "Intensity": 1, + "Frequency": 3 + }, + { + "Time": 222, + "Intensity": 1, + "Frequency": -3 + }, + { + "Time": 255, + "Intensity": 0.72, + "Frequency": 0 + }, + { + "Time": 256, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 574, + "Parameters": { + "Intensity": 34, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 95, + "Intensity": 0.48, + "Frequency": -6 + }, + { + "Time": 140, + "Intensity": 0.09, + "Frequency": 0 + }, + { + "Time": 170, + "Intensity": 0.89, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 257, + "StartTime": 731, + "Parameters": { + "Intensity": 28, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.88, + "Frequency": 3 + }, + { + "Time": 64, + "Intensity": 0.82, + "Frequency": -5 + }, + { + "Time": 128, + "Intensity": 0.42, + "Frequency": 0 + }, + { + "Time": 202, + "Intensity": 0.4, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.31, + "Frequency": -3 + }, + { + "Time": 257, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 990, + "Parameters": { + "Intensity": 56, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.29, + "Frequency": 3 + }, + { + "Time": 34, + "Intensity": 0.47, + "Frequency": -5 + }, + { + "Time": 76, + "Intensity": 0.52, + "Frequency": 3 + }, + { + "Time": 138, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 208, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 249, + "Intensity": 0.29, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 990, + "Parameters": { + "Intensity": 25, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 102, + "Intensity": 0.72, + "Frequency": -6 + }, + { + "Time": 144, + "Intensity": 0.09, + "Frequency": 8 + }, + { + "Time": 169, + "Intensity": 0.25, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 230, + "Intensity": 0.53, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 298, + "StartTime": 1242, + "Parameters": { + "Intensity": 44, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.39, + "Frequency": 3 + }, + { + "Time": 99, + "Intensity": 0.5, + "Frequency": -5 + }, + { + "Time": 212, + "Intensity": 0.29, + "Frequency": 3 + }, + { + "Time": 297, + "Intensity": 0.3, + "Frequency": -3 + }, + { + "Time": 298, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 298, + "StartTime": 1244, + "Parameters": { + "Intensity": 24, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 27, + "Intensity": 0.6, + "Frequency": 5 + }, + { + "Time": 79, + "Intensity": 0.08, + "Frequency": -13 + }, + { + "Time": 101, + "Intensity": 0.81, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.17, + "Frequency": 0 + }, + { + "Time": 202, + "Intensity": 0.24, + "Frequency": -16 + }, + { + "Time": 238, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 277, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 298, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1541, + "Parameters": { + "Intensity": 20, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1542, + "Parameters": { + "Intensity": 47, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.27, + "Frequency": 3 + }, + { + "Time": 40, + "Intensity": 0.39, + "Frequency": -5 + }, + { + "Time": 91, + "Intensity": 0.37, + "Frequency": 0 + }, + { + "Time": 135, + "Intensity": 0.43, + "Frequency": 3 + }, + { + "Time": 201, + "Intensity": 0.37, + "Frequency": 0 + }, + { + "Time": 249, + "Intensity": 0.25, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1793, + "Parameters": { + "Intensity": 44, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.28, + "Frequency": 3 + }, + { + "Time": 46, + "Intensity": 0.3, + "Frequency": -5 + }, + { + "Time": 105, + "Intensity": 0.41, + "Frequency": 3 + }, + { + "Time": 162, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 213, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 249, + "Intensity": 0.23, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1793, + "Parameters": { + "Intensity": 16, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 251, + "StartTime": 2043, + "Parameters": { + "Intensity": 24, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.4, + "Frequency": 3 + }, + { + "Time": 81, + "Intensity": 0.71, + "Frequency": -5 + }, + { + "Time": 189, + "Intensity": 0.54, + "Frequency": 3 + }, + { + "Time": 212, + "Intensity": 0.26, + "Frequency": -3 + }, + { + "Time": 251, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2043, + "Parameters": { + "Intensity": 20, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_h.json index 0fb299d90e..de873e8f3a 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_h.json @@ -1,55 +1,55 @@ -{ - "MetaData": { - "Create": "2022-04-15", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 294, - "StartTime": 11, - "Parameters": { - "Intensity": 100, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 63, - "Intensity": 0.3, - "Frequency": -83 - }, - { - "Time": 109, - "Intensity": 1, - "Frequency": -26 - }, - { - "Time": 165, - "Intensity": 0.2, - "Frequency": -58 - }, - { - "Time": 294, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-15", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 294, + "StartTime": 11, + "Parameters": { + "Intensity": 100, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 63, + "Intensity": 0.3, + "Frequency": -83 + }, + { + "Time": 109, + "Intensity": 1, + "Frequency": -26 + }, + { + "Time": 165, + "Intensity": 0.2, + "Frequency": -58 + }, + { + "Time": 294, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_l.json index 8d3d95d30d..bf16055636 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_l.json @@ -1,55 +1,55 @@ -{ - "MetaData": { - "Create": "2022-04-15", - "Discription": "EA json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 294, - "StartTime": 11, - "Parameters": { - "Intensity": 60, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 63, - "Intensity": 0.3, - "Frequency": -83 - }, - { - "Time": 109, - "Intensity": 1, - "Frequency": -26 - }, - { - "Time": 165, - "Intensity": 0.2, - "Frequency": -58 - }, - { - "Time": 294, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-15", + "Discription": "EA json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 294, + "StartTime": 11, + "Parameters": { + "Intensity": 60, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 63, + "Intensity": 0.3, + "Frequency": -83 + }, + { + "Time": 109, + "Intensity": 1, + "Frequency": -26 + }, + { + "Time": 165, + "Intensity": 0.2, + "Frequency": -58 + }, + { + "Time": 294, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_m.json index 9f97b2eeb2..5713d4803d 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/DriftingJet_m.json @@ -1,55 +1,55 @@ -{ - "MetaData": { - "Create": "2022-04-15", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 294, - "StartTime": 11, - "Parameters": { - "Intensity": 80, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 63, - "Intensity": 0.3, - "Frequency": -83 - }, - { - "Time": 109, - "Intensity": 1, - "Frequency": -26 - }, - { - "Time": 165, - "Intensity": 0.2, - "Frequency": -58 - }, - { - "Time": 294, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-15", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 294, + "StartTime": 11, + "Parameters": { + "Intensity": 80, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 63, + "Intensity": 0.3, + "Frequency": -83 + }, + { + "Time": 109, + "Intensity": 1, + "Frequency": -26 + }, + { + "Time": 165, + "Intensity": 0.2, + "Frequency": -58 + }, + { + "Time": 294, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_h.json index 88eafe36c3..d8c3cc1662 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_h.json @@ -1,177 +1,177 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 67, - "Parameters": { - "Intensity": 93, - "Frequency": 61 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 381, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 478, - "Parameters": { - "Intensity": 100, - "Frequency": 69 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 498, - "Parameters": { - "Intensity": 57, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 663, - "Parameters": { - "Intensity": 100, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 726, - "Parameters": { - "Intensity": 48, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 799, - "Parameters": { - "Intensity": 100, - "Frequency": 63 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 846, - "Parameters": { - "Intensity": 89, - "Frequency": 91 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 904, - "Parameters": { - "Intensity": 86, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 928, - "Parameters": { - "Intensity": 77, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 961, - "Parameters": { - "Intensity": 68, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 992, - "Parameters": { - "Intensity": 61, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1038, - "Parameters": { - "Intensity": 53, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1066, - "Parameters": { - "Intensity": 51, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1117, - "Parameters": { - "Intensity": 45, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1161, - "Parameters": { - "Intensity": 30, - "Frequency": 93 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 67, + "Parameters": { + "Intensity": 93, + "Frequency": 61 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 381, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 478, + "Parameters": { + "Intensity": 100, + "Frequency": 69 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 498, + "Parameters": { + "Intensity": 57, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 663, + "Parameters": { + "Intensity": 100, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 726, + "Parameters": { + "Intensity": 48, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 799, + "Parameters": { + "Intensity": 100, + "Frequency": 63 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 846, + "Parameters": { + "Intensity": 89, + "Frequency": 91 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 904, + "Parameters": { + "Intensity": 86, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 928, + "Parameters": { + "Intensity": 77, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 961, + "Parameters": { + "Intensity": 68, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 992, + "Parameters": { + "Intensity": 61, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1038, + "Parameters": { + "Intensity": 53, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1066, + "Parameters": { + "Intensity": 51, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1117, + "Parameters": { + "Intensity": 45, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1161, + "Parameters": { + "Intensity": 30, + "Frequency": 93 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_l.json index da89162a00..dc23e91a2d 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_l.json @@ -1,177 +1,177 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 67, - "Parameters": { - "Intensity": 55, - "Frequency": 61 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 381, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 478, - "Parameters": { - "Intensity": 60, - "Frequency": 69 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 498, - "Parameters": { - "Intensity": 34, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 663, - "Parameters": { - "Intensity": 60, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 726, - "Parameters": { - "Intensity": 28, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 799, - "Parameters": { - "Intensity": 60, - "Frequency": 63 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 846, - "Parameters": { - "Intensity": 53, - "Frequency": 91 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 904, - "Parameters": { - "Intensity": 51, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 928, - "Parameters": { - "Intensity": 46, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 961, - "Parameters": { - "Intensity": 40, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 992, - "Parameters": { - "Intensity": 36, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1038, - "Parameters": { - "Intensity": 31, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1066, - "Parameters": { - "Intensity": 30, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1117, - "Parameters": { - "Intensity": 27, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1161, - "Parameters": { - "Intensity": 18, - "Frequency": 93 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 67, + "Parameters": { + "Intensity": 55, + "Frequency": 61 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 381, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 478, + "Parameters": { + "Intensity": 60, + "Frequency": 69 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 498, + "Parameters": { + "Intensity": 34, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 663, + "Parameters": { + "Intensity": 60, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 726, + "Parameters": { + "Intensity": 28, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 799, + "Parameters": { + "Intensity": 60, + "Frequency": 63 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 846, + "Parameters": { + "Intensity": 53, + "Frequency": 91 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 904, + "Parameters": { + "Intensity": 51, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 928, + "Parameters": { + "Intensity": 46, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 961, + "Parameters": { + "Intensity": 40, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 992, + "Parameters": { + "Intensity": 36, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1038, + "Parameters": { + "Intensity": 31, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1066, + "Parameters": { + "Intensity": 30, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1117, + "Parameters": { + "Intensity": 27, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1161, + "Parameters": { + "Intensity": 18, + "Frequency": 93 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_m.json index 88eb46a0cd..08255bc514 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Firework_m.json @@ -1,177 +1,177 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 67, - "Parameters": { - "Intensity": 74, - "Frequency": 61 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 381, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 478, - "Parameters": { - "Intensity": 80, - "Frequency": 69 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 498, - "Parameters": { - "Intensity": 45, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 663, - "Parameters": { - "Intensity": 80, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 726, - "Parameters": { - "Intensity": 38, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 799, - "Parameters": { - "Intensity": 80, - "Frequency": 63 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 846, - "Parameters": { - "Intensity": 71, - "Frequency": 91 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 904, - "Parameters": { - "Intensity": 68, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 928, - "Parameters": { - "Intensity": 61, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 961, - "Parameters": { - "Intensity": 54, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 992, - "Parameters": { - "Intensity": 48, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1038, - "Parameters": { - "Intensity": 42, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1066, - "Parameters": { - "Intensity": 40, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1117, - "Parameters": { - "Intensity": 36, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1161, - "Parameters": { - "Intensity": 24, - "Frequency": 93 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 67, + "Parameters": { + "Intensity": 74, + "Frequency": 61 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 381, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 478, + "Parameters": { + "Intensity": 80, + "Frequency": 69 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 498, + "Parameters": { + "Intensity": 45, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 663, + "Parameters": { + "Intensity": 80, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 726, + "Parameters": { + "Intensity": 38, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 799, + "Parameters": { + "Intensity": 80, + "Frequency": 63 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 846, + "Parameters": { + "Intensity": 71, + "Frequency": 91 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 904, + "Parameters": { + "Intensity": 68, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 928, + "Parameters": { + "Intensity": 61, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 961, + "Parameters": { + "Intensity": 54, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 992, + "Parameters": { + "Intensity": 48, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1038, + "Parameters": { + "Intensity": 42, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1066, + "Parameters": { + "Intensity": 40, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1117, + "Parameters": { + "Intensity": 36, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1161, + "Parameters": { + "Intensity": 24, + "Frequency": 93 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gesture_up.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gesture_up.json index a7fbc70bd0..82c89a4c9b 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gesture_up.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gesture_up.json @@ -1,27 +1,27 @@ -{ - "MetaData": { - "Create": "2023-03-03 18:28:51.965244", - "Description": "gesture up", - "Version": 1.0, - "ChannelNumber": 1 - }, - "Channels": [ - { - "Parameters": { - "Index": 1 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 30, - "Parameters": { - "Intensity": 100, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-03-03 18:28:51.965244", + "Description": "gesture up", + "Version": 1.0, + "ChannelNumber": 1 + }, + "Channels": [ + { + "Parameters": { + "Index": 1 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 30, + "Parameters": { + "Intensity": 100, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_h.json index b83577d2cf..5f6cc431ec 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_h.json @@ -1,70 +1,70 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 5000, - "StartTime": 85, - "Parameters": { - "Intensity": 72, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 11 - }, - { - "Time": 29, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 107, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 200, - "Intensity": 0.49, - "Frequency": 0 - }, - { - "Time": 314, - "Intensity": 0.6, - "Frequency": 0 - }, - { - "Time": 1643, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 3164, - "Intensity": 0.24, - "Frequency": 21 - }, - { - "Time": 5000, - "Intensity": 0, - "Frequency": -96 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 5000, + "StartTime": 85, + "Parameters": { + "Intensity": 72, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 11 + }, + { + "Time": 29, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 107, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 200, + "Intensity": 0.49, + "Frequency": 0 + }, + { + "Time": 314, + "Intensity": 0.6, + "Frequency": 0 + }, + { + "Time": 1643, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 3164, + "Intensity": 0.24, + "Frequency": 21 + }, + { + "Time": 5000, + "Intensity": 0, + "Frequency": -96 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_l.json index 316c892562..a5ce425bf5 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_l.json @@ -1,70 +1,70 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 5000, - "StartTime": 85, - "Parameters": { - "Intensity": 43, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 11 - }, - { - "Time": 29, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 107, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 200, - "Intensity": 0.49, - "Frequency": 0 - }, - { - "Time": 314, - "Intensity": 0.6, - "Frequency": 0 - }, - { - "Time": 1643, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 3164, - "Intensity": 0.24, - "Frequency": 21 - }, - { - "Time": 5000, - "Intensity": 0, - "Frequency": -96 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 5000, + "StartTime": 85, + "Parameters": { + "Intensity": 43, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 11 + }, + { + "Time": 29, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 107, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 200, + "Intensity": 0.49, + "Frequency": 0 + }, + { + "Time": 314, + "Intensity": 0.6, + "Frequency": 0 + }, + { + "Time": 1643, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 3164, + "Intensity": 0.24, + "Frequency": 21 + }, + { + "Time": 5000, + "Intensity": 0, + "Frequency": -96 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_m.json index 219f960785..7b2df04f4d 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Gong_m.json @@ -1,70 +1,70 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 5000, - "StartTime": 85, - "Parameters": { - "Intensity": 57, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 11 - }, - { - "Time": 29, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 107, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 200, - "Intensity": 0.49, - "Frequency": 0 - }, - { - "Time": 314, - "Intensity": 0.6, - "Frequency": 0 - }, - { - "Time": 1643, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 3164, - "Intensity": 0.24, - "Frequency": 21 - }, - { - "Time": 5000, - "Intensity": 0, - "Frequency": -96 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 5000, + "StartTime": 85, + "Parameters": { + "Intensity": 57, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 11 + }, + { + "Time": 29, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 107, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 200, + "Intensity": 0.49, + "Frequency": 0 + }, + { + "Time": 314, + "Intensity": 0.6, + "Frequency": 0 + }, + { + "Time": 1643, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 3164, + "Intensity": 0.24, + "Frequency": 21 + }, + { + "Time": 5000, + "Intensity": 0, + "Frequency": -96 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_h.json index cfdb1a01d6..db97897d8e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_h.json @@ -1,146 +1,146 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 11, - "Parameters": { - "Intensity": 100, - "Frequency": 89 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 426, - "StartTime": 56, - "Parameters": { - "Intensity": 48, - "Frequency": 94, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 304, - "Intensity": 0.6137255, - "Frequency": -26 - }, - { - "Time": 426, - "Intensity": 0.0, - "Frequency": -22 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 491, - "Parameters": { - "Intensity": 100, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 492, - "StartTime": 535, - "Parameters": { - "Intensity": 54, - "Frequency": 66, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 16, - "Intensity": 0.95490193, - "Frequency": 0 - }, - { - "Time": 221, - "Intensity": 0.7921569, - "Frequency": -29 - }, - { - "Time": 492, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1039, - "Parameters": { - "Intensity": 100, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 694, - "StartTime": 1090, - "Parameters": { - "Intensity": 64, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 487, - "Intensity": 0.73333335, - "Frequency": 0 - }, - { - "Time": 694, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 11, + "Parameters": { + "Intensity": 100, + "Frequency": 89 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 426, + "StartTime": 56, + "Parameters": { + "Intensity": 48, + "Frequency": 94, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 304, + "Intensity": 0.6137255, + "Frequency": -26 + }, + { + "Time": 426, + "Intensity": 0.0, + "Frequency": -22 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 491, + "Parameters": { + "Intensity": 100, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 492, + "StartTime": 535, + "Parameters": { + "Intensity": 54, + "Frequency": 66, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 16, + "Intensity": 0.95490193, + "Frequency": 0 + }, + { + "Time": 221, + "Intensity": 0.7921569, + "Frequency": -29 + }, + { + "Time": 492, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1039, + "Parameters": { + "Intensity": 100, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 694, + "StartTime": 1090, + "Parameters": { + "Intensity": 64, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 487, + "Intensity": 0.73333335, + "Frequency": 0 + }, + { + "Time": 694, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_l.json index e6536878c2..419025dbd4 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_l.json @@ -1,146 +1,146 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 11, - "Parameters": { - "Intensity": 60, - "Frequency": 89 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 426, - "StartTime": 56, - "Parameters": { - "Intensity": 28, - "Frequency": 94, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 304, - "Intensity": 0.6137255, - "Frequency": -26 - }, - { - "Time": 426, - "Intensity": 0.0, - "Frequency": -22 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 491, - "Parameters": { - "Intensity": 60, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 492, - "StartTime": 535, - "Parameters": { - "Intensity": 32, - "Frequency": 66, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 16, - "Intensity": 0.95490193, - "Frequency": 0 - }, - { - "Time": 221, - "Intensity": 0.7921569, - "Frequency": -29 - }, - { - "Time": 492, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1039, - "Parameters": { - "Intensity": 60, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 694, - "StartTime": 1090, - "Parameters": { - "Intensity": 38, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 487, - "Intensity": 0.73333335, - "Frequency": 0 - }, - { - "Time": 694, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 11, + "Parameters": { + "Intensity": 60, + "Frequency": 89 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 426, + "StartTime": 56, + "Parameters": { + "Intensity": 28, + "Frequency": 94, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 304, + "Intensity": 0.6137255, + "Frequency": -26 + }, + { + "Time": 426, + "Intensity": 0.0, + "Frequency": -22 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 491, + "Parameters": { + "Intensity": 60, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 492, + "StartTime": 535, + "Parameters": { + "Intensity": 32, + "Frequency": 66, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 16, + "Intensity": 0.95490193, + "Frequency": 0 + }, + { + "Time": 221, + "Intensity": 0.7921569, + "Frequency": -29 + }, + { + "Time": 492, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1039, + "Parameters": { + "Intensity": 60, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 694, + "StartTime": 1090, + "Parameters": { + "Intensity": 38, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 487, + "Intensity": 0.73333335, + "Frequency": 0 + }, + { + "Time": 694, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_m.json index 03ab8b478d..c8199879a3 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Guitar_m.json @@ -1,146 +1,146 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 11, - "Parameters": { - "Intensity": 80, - "Frequency": 89 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 426, - "StartTime": 56, - "Parameters": { - "Intensity": 38, - "Frequency": 94, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 304, - "Intensity": 0.6137255, - "Frequency": -26 - }, - { - "Time": 426, - "Intensity": 0.0, - "Frequency": -22 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 491, - "Parameters": { - "Intensity": 80, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 492, - "StartTime": 535, - "Parameters": { - "Intensity": 43, - "Frequency": 66, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 16, - "Intensity": 0.95490193, - "Frequency": 0 - }, - { - "Time": 221, - "Intensity": 0.7921569, - "Frequency": -29 - }, - { - "Time": 492, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1039, - "Parameters": { - "Intensity": 80, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 694, - "StartTime": 1090, - "Parameters": { - "Intensity": 51, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 487, - "Intensity": 0.73333335, - "Frequency": 0 - }, - { - "Time": 694, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 11, + "Parameters": { + "Intensity": 80, + "Frequency": 89 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 426, + "StartTime": 56, + "Parameters": { + "Intensity": 38, + "Frequency": 94, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 304, + "Intensity": 0.6137255, + "Frequency": -26 + }, + { + "Time": 426, + "Intensity": 0.0, + "Frequency": -22 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 491, + "Parameters": { + "Intensity": 80, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 492, + "StartTime": 535, + "Parameters": { + "Intensity": 43, + "Frequency": 66, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 16, + "Intensity": 0.95490193, + "Frequency": 0 + }, + { + "Time": 221, + "Intensity": 0.7921569, + "Frequency": -29 + }, + { + "Time": 492, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1039, + "Parameters": { + "Intensity": 80, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 694, + "StartTime": 1090, + "Parameters": { + "Intensity": 51, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 487, + "Intensity": 0.73333335, + "Frequency": 0 + }, + { + "Time": 694, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_h.json index 1187798891..f4ec693e92 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_h.json @@ -1,83 +1,83 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 41, - "StartTime": 130, - "Parameters": { - "Intensity": 70, - "Frequency": 37, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 41, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 55, - "StartTime": 202, - "Parameters": { - "Intensity": 100, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 55, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 41, + "StartTime": 130, + "Parameters": { + "Intensity": 70, + "Frequency": 37, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 41, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 55, + "StartTime": 202, + "Parameters": { + "Intensity": 100, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 55, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_l.json index c7c5a133f9..35c1090b6d 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_l.json @@ -1,83 +1,83 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 41, - "StartTime": 130, - "Parameters": { - "Intensity": 42, - "Frequency": 37, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 41, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 55, - "StartTime": 202, - "Parameters": { - "Intensity": 60, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 55, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 41, + "StartTime": 130, + "Parameters": { + "Intensity": 42, + "Frequency": 37, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 41, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 55, + "StartTime": 202, + "Parameters": { + "Intensity": 60, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 55, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_m.json index e3c2fee114..bee3334058 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HK416_m.json @@ -1,83 +1,83 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 41, - "StartTime": 130, - "Parameters": { - "Intensity": 56, - "Frequency": 37, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 41, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 55, - "StartTime": 202, - "Parameters": { - "Intensity": 80, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 55, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 41, + "StartTime": 130, + "Parameters": { + "Intensity": 56, + "Frequency": 37, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 41, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 55, + "StartTime": 202, + "Parameters": { + "Intensity": 80, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 55, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HapticVideo.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HapticVideo.json index 7e4ea04823..15c7702989 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HapticVideo.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HapticVideo.json @@ -1,261 +1,261 @@ -{ - "MetaData": { - "Create": "2023-05-25 18:19:52.022145", - "Description": "a json file format demo", - "Version": 1.0, - "ChannelNumber": 1 - }, - "Channels": [ - { - "Parameters": { - "Index": 1 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 414, - "Parameters": { - "Intensity": 38, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 444, - "Parameters": { - "Intensity": 38, - "Frequency": 50 - }, - "Duration": 16 - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 460, - "Parameters": { - "Intensity": 100, - "Frequency": 53 - }, - "Duration": 46 - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 506, - "Parameters": { - "Intensity": 48, - "Frequency": 53 - }, - "Duration": 46 - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 552, - "Parameters": { - "Intensity": 92, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 582, - "Parameters": { - "Intensity": 92, - "Frequency": 53 - }, - "Duration": 16 - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 598, - "Parameters": { - "Intensity": 73, - "Frequency": 37 - }, - "Duration": 46 - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 644, - "Parameters": { - "Intensity": 42, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 674, - "Parameters": { - "Intensity": 42, - "Frequency": 43 - }, - "Duration": 16 - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 690, - "Parameters": { - "Intensity": 40, - "Frequency": 44 - }, - "Duration": 46 - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 736, - "Parameters": { - "Intensity": 16, - "Frequency": 44 - }, - "Duration": 46 - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 782, - "Parameters": { - "Intensity": 30, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 828, - "Parameters": { - "Intensity": 10, - "Frequency": 44 - }, - "Duration": 92 - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1288, - "Parameters": { - "Intensity": 30, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 1334, - "Parameters": { - "Intensity": 5, - "Frequency": 44 - }, - "Duration": 46 - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1610, - "Parameters": { - "Intensity": 30, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2484, - "Parameters": { - "Intensity": 30, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 2530, - "Parameters": { - "Intensity": 4, - "Frequency": 44 - }, - "Duration": 46 - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4140, - "Parameters": { - "Intensity": 30, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4968, - "Parameters": { - "Intensity": 30, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 5014, - "Parameters": { - "Intensity": 4, - "Frequency": 44 - }, - "Duration": 46 - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 5060, - "Parameters": { - "Intensity": 6, - "Frequency": 44 - }, - "Duration": 46 - } - }, - { - "Event": { - "Type": "continuous", - "StartTime": 5106, - "Parameters": { - "Intensity": 8, - "Frequency": 44 - }, - "Duration": 92 - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-05-25 18:19:52.022145", + "Description": "a json file format demo", + "Version": 1.0, + "ChannelNumber": 1 + }, + "Channels": [ + { + "Parameters": { + "Index": 1 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 414, + "Parameters": { + "Intensity": 38, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 444, + "Parameters": { + "Intensity": 38, + "Frequency": 50 + }, + "Duration": 16 + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 460, + "Parameters": { + "Intensity": 100, + "Frequency": 53 + }, + "Duration": 46 + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 506, + "Parameters": { + "Intensity": 48, + "Frequency": 53 + }, + "Duration": 46 + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 552, + "Parameters": { + "Intensity": 92, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 582, + "Parameters": { + "Intensity": 92, + "Frequency": 53 + }, + "Duration": 16 + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 598, + "Parameters": { + "Intensity": 73, + "Frequency": 37 + }, + "Duration": 46 + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 644, + "Parameters": { + "Intensity": 42, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 674, + "Parameters": { + "Intensity": 42, + "Frequency": 43 + }, + "Duration": 16 + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 690, + "Parameters": { + "Intensity": 40, + "Frequency": 44 + }, + "Duration": 46 + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 736, + "Parameters": { + "Intensity": 16, + "Frequency": 44 + }, + "Duration": 46 + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 782, + "Parameters": { + "Intensity": 30, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 828, + "Parameters": { + "Intensity": 10, + "Frequency": 44 + }, + "Duration": 92 + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1288, + "Parameters": { + "Intensity": 30, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 1334, + "Parameters": { + "Intensity": 5, + "Frequency": 44 + }, + "Duration": 46 + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1610, + "Parameters": { + "Intensity": 30, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2484, + "Parameters": { + "Intensity": 30, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 2530, + "Parameters": { + "Intensity": 4, + "Frequency": 44 + }, + "Duration": 46 + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4140, + "Parameters": { + "Intensity": 30, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4968, + "Parameters": { + "Intensity": 30, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 5014, + "Parameters": { + "Intensity": 4, + "Frequency": 44 + }, + "Duration": 46 + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 5060, + "Parameters": { + "Intensity": 6, + "Frequency": 44 + }, + "Duration": 46 + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 5106, + "Parameters": { + "Intensity": 8, + "Frequency": 44 + }, + "Duration": 92 + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_h.json index 9995877a2e..83473545d8 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_h.json @@ -1,265 +1,265 @@ -{ - "MetaData": { - "Create": "2022-05-25", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 242, - "Parameters": { - "Intensity": 91, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 281, - "Parameters": { - "Intensity": 100, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 302, - "Parameters": { - "Intensity": 0, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 317, - "Parameters": { - "Intensity": 90, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 377, - "Parameters": { - "Intensity": 0, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 392, - "Parameters": { - "Intensity": 37, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 469, - "Parameters": { - "Intensity": 50, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 549, - "Parameters": { - "Intensity": 39, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 642, - "Parameters": { - "Intensity": 73, - "Frequency": 76 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 679, - "Parameters": { - "Intensity": 100, - "Frequency": 46 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 733, - "Parameters": { - "Intensity": 70, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 789, - "Parameters": { - "Intensity": 49, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 847, - "Parameters": { - "Intensity": 33, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 909, - "Parameters": { - "Intensity": 64, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 200, - "StartTime": 963, - "Parameters": { - "Intensity": 100, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 17, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 34, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 84, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 117, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 134, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 167, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 184, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 60 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1013, - "Parameters": { - "Intensity": 47, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1087, - "Parameters": { - "Intensity": 40, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1270, - "Parameters": { - "Intensity": 0, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-25", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 242, + "Parameters": { + "Intensity": 91, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 281, + "Parameters": { + "Intensity": 100, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 302, + "Parameters": { + "Intensity": 0, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 317, + "Parameters": { + "Intensity": 90, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 377, + "Parameters": { + "Intensity": 0, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 392, + "Parameters": { + "Intensity": 37, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 469, + "Parameters": { + "Intensity": 50, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 549, + "Parameters": { + "Intensity": 39, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 642, + "Parameters": { + "Intensity": 73, + "Frequency": 76 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 679, + "Parameters": { + "Intensity": 100, + "Frequency": 46 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 733, + "Parameters": { + "Intensity": 70, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 789, + "Parameters": { + "Intensity": 49, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 847, + "Parameters": { + "Intensity": 33, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 909, + "Parameters": { + "Intensity": 64, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 200, + "StartTime": 963, + "Parameters": { + "Intensity": 100, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 17, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 34, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 84, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 117, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 134, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 167, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 184, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 60 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1013, + "Parameters": { + "Intensity": 47, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1087, + "Parameters": { + "Intensity": 40, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1270, + "Parameters": { + "Intensity": 0, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_l.json index 492a4caf9c..531f1a81b7 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_l.json @@ -1,265 +1,265 @@ -{ - "MetaData": { - "Create": "2022-05-25", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 242, - "Parameters": { - "Intensity": 54, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 281, - "Parameters": { - "Intensity": 60, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 302, - "Parameters": { - "Intensity": 0, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 317, - "Parameters": { - "Intensity": 54, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 377, - "Parameters": { - "Intensity": 0, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 392, - "Parameters": { - "Intensity": 22, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 469, - "Parameters": { - "Intensity": 30, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 549, - "Parameters": { - "Intensity": 23, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 642, - "Parameters": { - "Intensity": 43, - "Frequency": 76 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 679, - "Parameters": { - "Intensity": 60, - "Frequency": 46 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 733, - "Parameters": { - "Intensity": 42, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 789, - "Parameters": { - "Intensity": 29, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 847, - "Parameters": { - "Intensity": 19, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 909, - "Parameters": { - "Intensity": 38, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 200, - "StartTime": 963, - "Parameters": { - "Intensity": 60, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 17, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 34, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 84, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 117, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 134, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 167, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 184, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 60 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1013, - "Parameters": { - "Intensity": 28, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1087, - "Parameters": { - "Intensity": 24, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1270, - "Parameters": { - "Intensity": 0, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-25", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 242, + "Parameters": { + "Intensity": 54, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 281, + "Parameters": { + "Intensity": 60, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 302, + "Parameters": { + "Intensity": 0, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 317, + "Parameters": { + "Intensity": 54, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 377, + "Parameters": { + "Intensity": 0, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 392, + "Parameters": { + "Intensity": 22, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 469, + "Parameters": { + "Intensity": 30, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 549, + "Parameters": { + "Intensity": 23, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 642, + "Parameters": { + "Intensity": 43, + "Frequency": 76 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 679, + "Parameters": { + "Intensity": 60, + "Frequency": 46 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 733, + "Parameters": { + "Intensity": 42, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 789, + "Parameters": { + "Intensity": 29, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 847, + "Parameters": { + "Intensity": 19, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 909, + "Parameters": { + "Intensity": 38, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 200, + "StartTime": 963, + "Parameters": { + "Intensity": 60, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 17, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 34, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 84, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 117, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 134, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 167, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 184, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 60 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1013, + "Parameters": { + "Intensity": 28, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1087, + "Parameters": { + "Intensity": 24, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1270, + "Parameters": { + "Intensity": 0, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_m.json index d74290df9f..e619ed8f55 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitGlass_m.json @@ -1,265 +1,265 @@ -{ - "MetaData": { - "Create": "2022-05-25", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 242, - "Parameters": { - "Intensity": 72, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 281, - "Parameters": { - "Intensity": 80, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 302, - "Parameters": { - "Intensity": 0, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 317, - "Parameters": { - "Intensity": 72, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 377, - "Parameters": { - "Intensity": 0, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 392, - "Parameters": { - "Intensity": 29, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 469, - "Parameters": { - "Intensity": 40, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 549, - "Parameters": { - "Intensity": 31, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 642, - "Parameters": { - "Intensity": 58, - "Frequency": 76 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 679, - "Parameters": { - "Intensity": 80, - "Frequency": 46 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 733, - "Parameters": { - "Intensity": 56, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 789, - "Parameters": { - "Intensity": 39, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 847, - "Parameters": { - "Intensity": 26, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 909, - "Parameters": { - "Intensity": 51, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 200, - "StartTime": 963, - "Parameters": { - "Intensity": 80, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 17, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 34, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 84, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 117, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 134, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 167, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 184, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 60 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1013, - "Parameters": { - "Intensity": 37, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1087, - "Parameters": { - "Intensity": 32, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1270, - "Parameters": { - "Intensity": 0, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-25", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 242, + "Parameters": { + "Intensity": 72, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 281, + "Parameters": { + "Intensity": 80, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 302, + "Parameters": { + "Intensity": 0, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 317, + "Parameters": { + "Intensity": 72, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 377, + "Parameters": { + "Intensity": 0, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 392, + "Parameters": { + "Intensity": 29, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 469, + "Parameters": { + "Intensity": 40, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 549, + "Parameters": { + "Intensity": 31, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 642, + "Parameters": { + "Intensity": 58, + "Frequency": 76 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 679, + "Parameters": { + "Intensity": 80, + "Frequency": 46 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 733, + "Parameters": { + "Intensity": 56, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 789, + "Parameters": { + "Intensity": 39, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 847, + "Parameters": { + "Intensity": 26, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 909, + "Parameters": { + "Intensity": 51, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 200, + "StartTime": 963, + "Parameters": { + "Intensity": 80, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 17, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 34, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 84, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 117, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 134, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 167, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 184, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 60 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1013, + "Parameters": { + "Intensity": 37, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1087, + "Parameters": { + "Intensity": 32, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1270, + "Parameters": { + "Intensity": 0, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_h.json index a72276d422..c2d21f7528 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_h.json @@ -1,186 +1,186 @@ -{ - "MetaData": { - "Create": "2022-05-28", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 105, - "StartTime": 0, - "Parameters": { - "Intensity": 50, - "Frequency": 73, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 21, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 43, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 70, - "Intensity": 0.3, - "Frequency": 0 - }, - { - "Time": 92, - "Intensity": 0.08, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 105, - "StartTime": 0, - "Parameters": { - "Intensity": 50, - "Frequency": 88, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 21, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 43, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 70, - "Intensity": 0.3, - "Frequency": 0 - }, - { - "Time": 93, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 105, - "Parameters": { - "Intensity": 100, - "Frequency": 62 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 148, - "Parameters": { - "Intensity": 71, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 655, - "StartTime": 160, - "Parameters": { - "Intensity": 96, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.56, - "Frequency": 10 - }, - { - "Time": 42, - "Intensity": 0.66, - "Frequency": 10 - }, - { - "Time": 139, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 231, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 329, - "Intensity": 0.44, - "Frequency": 10 - }, - { - "Time": 445, - "Intensity": 0.24, - "Frequency": -5 - }, - { - "Time": 526, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 583, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 655, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-28", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 105, + "StartTime": 0, + "Parameters": { + "Intensity": 50, + "Frequency": 73, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 21, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 43, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 70, + "Intensity": 0.3, + "Frequency": 0 + }, + { + "Time": 92, + "Intensity": 0.08, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 105, + "StartTime": 0, + "Parameters": { + "Intensity": 50, + "Frequency": 88, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 21, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 43, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 70, + "Intensity": 0.3, + "Frequency": 0 + }, + { + "Time": 93, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 105, + "Parameters": { + "Intensity": 100, + "Frequency": 62 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 148, + "Parameters": { + "Intensity": 71, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 655, + "StartTime": 160, + "Parameters": { + "Intensity": 96, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.56, + "Frequency": 10 + }, + { + "Time": 42, + "Intensity": 0.66, + "Frequency": 10 + }, + { + "Time": 139, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 231, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 329, + "Intensity": 0.44, + "Frequency": 10 + }, + { + "Time": 445, + "Intensity": 0.24, + "Frequency": -5 + }, + { + "Time": 526, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 583, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 655, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_l.json index 0cbb41e6ce..245503fb48 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_l.json @@ -1,186 +1,186 @@ -{ - "MetaData": { - "Create": "2022-05-28", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 105, - "StartTime": 0, - "Parameters": { - "Intensity": 30, - "Frequency": 73, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 21, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 43, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 70, - "Intensity": 0.3, - "Frequency": 0 - }, - { - "Time": 92, - "Intensity": 0.08, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 105, - "StartTime": 0, - "Parameters": { - "Intensity": 30, - "Frequency": 88, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 21, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 43, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 70, - "Intensity": 0.3, - "Frequency": 0 - }, - { - "Time": 93, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 105, - "Parameters": { - "Intensity": 60, - "Frequency": 62 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 148, - "Parameters": { - "Intensity": 42, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 655, - "StartTime": 160, - "Parameters": { - "Intensity": 57, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.56, - "Frequency": 10 - }, - { - "Time": 42, - "Intensity": 0.66, - "Frequency": 10 - }, - { - "Time": 139, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 231, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 329, - "Intensity": 0.44, - "Frequency": 10 - }, - { - "Time": 445, - "Intensity": 0.24, - "Frequency": -5 - }, - { - "Time": 526, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 583, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 655, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-28", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 105, + "StartTime": 0, + "Parameters": { + "Intensity": 30, + "Frequency": 73, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 21, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 43, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 70, + "Intensity": 0.3, + "Frequency": 0 + }, + { + "Time": 92, + "Intensity": 0.08, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 105, + "StartTime": 0, + "Parameters": { + "Intensity": 30, + "Frequency": 88, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 21, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 43, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 70, + "Intensity": 0.3, + "Frequency": 0 + }, + { + "Time": 93, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 105, + "Parameters": { + "Intensity": 60, + "Frequency": 62 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 148, + "Parameters": { + "Intensity": 42, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 655, + "StartTime": 160, + "Parameters": { + "Intensity": 57, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.56, + "Frequency": 10 + }, + { + "Time": 42, + "Intensity": 0.66, + "Frequency": 10 + }, + { + "Time": 139, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 231, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 329, + "Intensity": 0.44, + "Frequency": 10 + }, + { + "Time": 445, + "Intensity": 0.24, + "Frequency": -5 + }, + { + "Time": 526, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 583, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 655, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_m.json index ea2ea78a16..b9d0a19dfd 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitMetal_m.json @@ -1,186 +1,186 @@ -{ - "MetaData": { - "Create": "2022-05-28", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 105, - "StartTime": 0, - "Parameters": { - "Intensity": 40, - "Frequency": 73, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 21, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 43, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 70, - "Intensity": 0.3, - "Frequency": 0 - }, - { - "Time": 92, - "Intensity": 0.08, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 105, - "StartTime": 0, - "Parameters": { - "Intensity": 40, - "Frequency": 88, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 21, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 43, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 70, - "Intensity": 0.3, - "Frequency": 0 - }, - { - "Time": 93, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 105, - "Parameters": { - "Intensity": 80, - "Frequency": 62 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 148, - "Parameters": { - "Intensity": 56, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 655, - "StartTime": 160, - "Parameters": { - "Intensity": 76, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.56, - "Frequency": 10 - }, - { - "Time": 42, - "Intensity": 0.66, - "Frequency": 10 - }, - { - "Time": 139, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 231, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 329, - "Intensity": 0.44, - "Frequency": 10 - }, - { - "Time": 445, - "Intensity": 0.24, - "Frequency": -5 - }, - { - "Time": 526, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 583, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 655, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-28", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 105, + "StartTime": 0, + "Parameters": { + "Intensity": 40, + "Frequency": 73, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 21, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 43, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 70, + "Intensity": 0.3, + "Frequency": 0 + }, + { + "Time": 92, + "Intensity": 0.08, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 105, + "StartTime": 0, + "Parameters": { + "Intensity": 40, + "Frequency": 88, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 21, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 43, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 70, + "Intensity": 0.3, + "Frequency": 0 + }, + { + "Time": 93, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 105, + "Parameters": { + "Intensity": 80, + "Frequency": 62 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 148, + "Parameters": { + "Intensity": 56, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 655, + "StartTime": 160, + "Parameters": { + "Intensity": 76, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.56, + "Frequency": 10 + }, + { + "Time": 42, + "Intensity": 0.66, + "Frequency": 10 + }, + { + "Time": 139, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 231, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 329, + "Intensity": 0.44, + "Frequency": 10 + }, + { + "Time": 445, + "Intensity": 0.24, + "Frequency": -5 + }, + { + "Time": 526, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 583, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 655, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_h.json index 40bc8a7c9c..7b5f7d0abd 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_h.json @@ -1,158 +1,158 @@ -{ - "MetaData": { - "Create": "2022-05-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 171, - "StartTime": 0, - "Parameters": { - "Intensity": 51, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 26, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 143, - "Intensity": 0.75, - "Frequency": 0 - }, - { - "Time": 171, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 173, - "StartTime": 3, - "Parameters": { - "Intensity": 41, - "Frequency": 49, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.43, - "Frequency": 0 - }, - { - "Time": 131, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 160, - "Intensity": 0.35, - "Frequency": 36 - }, - { - "Time": 173, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 176, - "Parameters": { - "Intensity": 100, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 304, - "Parameters": { - "Intensity": 42, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 336, - "Parameters": { - "Intensity": 42, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 421, - "Parameters": { - "Intensity": 38, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 475, - "Parameters": { - "Intensity": 33, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 519, - "Parameters": { - "Intensity": 27, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 556, - "Parameters": { - "Intensity": 20, - "Frequency": 78 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 171, + "StartTime": 0, + "Parameters": { + "Intensity": 51, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 26, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 143, + "Intensity": 0.75, + "Frequency": 0 + }, + { + "Time": 171, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 173, + "StartTime": 3, + "Parameters": { + "Intensity": 41, + "Frequency": 49, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.43, + "Frequency": 0 + }, + { + "Time": 131, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 160, + "Intensity": 0.35, + "Frequency": 36 + }, + { + "Time": 173, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 176, + "Parameters": { + "Intensity": 100, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 304, + "Parameters": { + "Intensity": 42, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 336, + "Parameters": { + "Intensity": 42, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 421, + "Parameters": { + "Intensity": 38, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 475, + "Parameters": { + "Intensity": 33, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 519, + "Parameters": { + "Intensity": 27, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 556, + "Parameters": { + "Intensity": 20, + "Frequency": 78 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_l.json index f8cf239d0a..2cf22e5202 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_l.json @@ -1,158 +1,158 @@ -{ - "MetaData": { - "Create": "2022-05-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 171, - "StartTime": 0, - "Parameters": { - "Intensity": 30, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 26, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 143, - "Intensity": 0.75, - "Frequency": 0 - }, - { - "Time": 171, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 173, - "StartTime": 3, - "Parameters": { - "Intensity": 24, - "Frequency": 49, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.43, - "Frequency": 0 - }, - { - "Time": 131, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 160, - "Intensity": 0.35, - "Frequency": 36 - }, - { - "Time": 173, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 176, - "Parameters": { - "Intensity": 60, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 304, - "Parameters": { - "Intensity": 25, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 336, - "Parameters": { - "Intensity": 25, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 421, - "Parameters": { - "Intensity": 22, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 475, - "Parameters": { - "Intensity": 19, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 519, - "Parameters": { - "Intensity": 16, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 556, - "Parameters": { - "Intensity": 12, - "Frequency": 78 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 171, + "StartTime": 0, + "Parameters": { + "Intensity": 30, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 26, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 143, + "Intensity": 0.75, + "Frequency": 0 + }, + { + "Time": 171, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 173, + "StartTime": 3, + "Parameters": { + "Intensity": 24, + "Frequency": 49, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.43, + "Frequency": 0 + }, + { + "Time": 131, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 160, + "Intensity": 0.35, + "Frequency": 36 + }, + { + "Time": 173, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 176, + "Parameters": { + "Intensity": 60, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 304, + "Parameters": { + "Intensity": 25, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 336, + "Parameters": { + "Intensity": 25, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 421, + "Parameters": { + "Intensity": 22, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 475, + "Parameters": { + "Intensity": 19, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 519, + "Parameters": { + "Intensity": 16, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 556, + "Parameters": { + "Intensity": 12, + "Frequency": 78 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_m.json index cd1d36e961..31a08459cc 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitSand_m.json @@ -1,158 +1,158 @@ -{ - "MetaData": { - "Create": "2022-05-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 171, - "StartTime": 0, - "Parameters": { - "Intensity": 40, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 26, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 143, - "Intensity": 0.75, - "Frequency": 0 - }, - { - "Time": 171, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 173, - "StartTime": 3, - "Parameters": { - "Intensity": 32, - "Frequency": 49, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.43, - "Frequency": 0 - }, - { - "Time": 131, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 160, - "Intensity": 0.35, - "Frequency": 36 - }, - { - "Time": 173, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 176, - "Parameters": { - "Intensity": 80, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 304, - "Parameters": { - "Intensity": 33, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 336, - "Parameters": { - "Intensity": 33, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 421, - "Parameters": { - "Intensity": 30, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 475, - "Parameters": { - "Intensity": 26, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 519, - "Parameters": { - "Intensity": 21, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 556, - "Parameters": { - "Intensity": 16, - "Frequency": 78 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 171, + "StartTime": 0, + "Parameters": { + "Intensity": 40, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 26, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 143, + "Intensity": 0.75, + "Frequency": 0 + }, + { + "Time": 171, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 173, + "StartTime": 3, + "Parameters": { + "Intensity": 32, + "Frequency": 49, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.43, + "Frequency": 0 + }, + { + "Time": 131, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 160, + "Intensity": 0.35, + "Frequency": 36 + }, + { + "Time": 173, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 176, + "Parameters": { + "Intensity": 80, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 304, + "Parameters": { + "Intensity": 33, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 336, + "Parameters": { + "Intensity": 33, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 421, + "Parameters": { + "Intensity": 30, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 475, + "Parameters": { + "Intensity": 26, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 519, + "Parameters": { + "Intensity": 21, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 556, + "Parameters": { + "Intensity": 16, + "Frequency": 78 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_h.json index faa9ba5800..c73ea4184a 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_h.json @@ -1,153 +1,153 @@ -{ - "MetaData": { - "Create": "2022-09-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 233, - "StartTime": 23, - "Parameters": { - "Intensity": 84, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 28 - }, - { - "Time": 25, - "Intensity": 0.19, - "Frequency": 25 - }, - { - "Time": 75, - "Intensity": 0.32, - "Frequency": 29 - }, - { - "Time": 131, - "Intensity": 0.46, - "Frequency": 43 - }, - { - "Time": 177, - "Intensity": 0.5, - "Frequency": 53 - }, - { - "Time": 198, - "Intensity": 0.2, - "Frequency": 48 - }, - { - "Time": 218, - "Intensity": 0.08, - "Frequency": 41 - }, - { - "Time": 233, - "Intensity": 0, - "Frequency": 48 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 177, - "Parameters": { - "Intensity": 100, - "Frequency": 46 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 266, - "Parameters": { - "Intensity": 44, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 28 - }, - { - "Time": 27, - "Intensity": 0.19, - "Frequency": 25 - }, - { - "Time": 81, - "Intensity": 0.32, - "Frequency": 29 - }, - { - "Time": 136, - "Intensity": 0.39, - "Frequency": 43 - }, - { - "Time": 187, - "Intensity": 0.32, - "Frequency": 53 - }, - { - "Time": 212, - "Intensity": 0.2, - "Frequency": 48 - }, - { - "Time": 233, - "Intensity": 0.08, - "Frequency": 41 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 48 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 308, - "Parameters": { - "Intensity": 89, - "Frequency": 13 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 382, - "Parameters": { - "Intensity": 81, - "Frequency": 13 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-09-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 233, + "StartTime": 23, + "Parameters": { + "Intensity": 84, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 28 + }, + { + "Time": 25, + "Intensity": 0.19, + "Frequency": 25 + }, + { + "Time": 75, + "Intensity": 0.32, + "Frequency": 29 + }, + { + "Time": 131, + "Intensity": 0.46, + "Frequency": 43 + }, + { + "Time": 177, + "Intensity": 0.5, + "Frequency": 53 + }, + { + "Time": 198, + "Intensity": 0.2, + "Frequency": 48 + }, + { + "Time": 218, + "Intensity": 0.08, + "Frequency": 41 + }, + { + "Time": 233, + "Intensity": 0, + "Frequency": 48 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 177, + "Parameters": { + "Intensity": 100, + "Frequency": 46 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 266, + "Parameters": { + "Intensity": 44, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 28 + }, + { + "Time": 27, + "Intensity": 0.19, + "Frequency": 25 + }, + { + "Time": 81, + "Intensity": 0.32, + "Frequency": 29 + }, + { + "Time": 136, + "Intensity": 0.39, + "Frequency": 43 + }, + { + "Time": 187, + "Intensity": 0.32, + "Frequency": 53 + }, + { + "Time": 212, + "Intensity": 0.2, + "Frequency": 48 + }, + { + "Time": 233, + "Intensity": 0.08, + "Frequency": 41 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 48 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 308, + "Parameters": { + "Intensity": 89, + "Frequency": 13 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 382, + "Parameters": { + "Intensity": 81, + "Frequency": 13 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_l.json index b8d1bb71f6..81d5b8d1ce 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_l.json @@ -1,153 +1,153 @@ -{ - "MetaData": { - "Create": "2022-09-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 233, - "StartTime": 23, - "Parameters": { - "Intensity": 50, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 28 - }, - { - "Time": 25, - "Intensity": 0.19, - "Frequency": 25 - }, - { - "Time": 75, - "Intensity": 0.32, - "Frequency": 29 - }, - { - "Time": 131, - "Intensity": 0.46, - "Frequency": 43 - }, - { - "Time": 177, - "Intensity": 0.5, - "Frequency": 53 - }, - { - "Time": 198, - "Intensity": 0.2, - "Frequency": 48 - }, - { - "Time": 218, - "Intensity": 0.08, - "Frequency": 41 - }, - { - "Time": 233, - "Intensity": 0, - "Frequency": 48 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 177, - "Parameters": { - "Intensity": 60, - "Frequency": 46 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 266, - "Parameters": { - "Intensity": 26, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 28 - }, - { - "Time": 27, - "Intensity": 0.19, - "Frequency": 25 - }, - { - "Time": 81, - "Intensity": 0.32, - "Frequency": 29 - }, - { - "Time": 136, - "Intensity": 0.39, - "Frequency": 43 - }, - { - "Time": 187, - "Intensity": 0.32, - "Frequency": 53 - }, - { - "Time": 212, - "Intensity": 0.2, - "Frequency": 48 - }, - { - "Time": 233, - "Intensity": 0.08, - "Frequency": 41 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 48 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 308, - "Parameters": { - "Intensity": 53, - "Frequency": 13 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 382, - "Parameters": { - "Intensity": 48, - "Frequency": 13 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-09-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 233, + "StartTime": 23, + "Parameters": { + "Intensity": 50, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 28 + }, + { + "Time": 25, + "Intensity": 0.19, + "Frequency": 25 + }, + { + "Time": 75, + "Intensity": 0.32, + "Frequency": 29 + }, + { + "Time": 131, + "Intensity": 0.46, + "Frequency": 43 + }, + { + "Time": 177, + "Intensity": 0.5, + "Frequency": 53 + }, + { + "Time": 198, + "Intensity": 0.2, + "Frequency": 48 + }, + { + "Time": 218, + "Intensity": 0.08, + "Frequency": 41 + }, + { + "Time": 233, + "Intensity": 0, + "Frequency": 48 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 177, + "Parameters": { + "Intensity": 60, + "Frequency": 46 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 266, + "Parameters": { + "Intensity": 26, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 28 + }, + { + "Time": 27, + "Intensity": 0.19, + "Frequency": 25 + }, + { + "Time": 81, + "Intensity": 0.32, + "Frequency": 29 + }, + { + "Time": 136, + "Intensity": 0.39, + "Frequency": 43 + }, + { + "Time": 187, + "Intensity": 0.32, + "Frequency": 53 + }, + { + "Time": 212, + "Intensity": 0.2, + "Frequency": 48 + }, + { + "Time": 233, + "Intensity": 0.08, + "Frequency": 41 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 48 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 308, + "Parameters": { + "Intensity": 53, + "Frequency": 13 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 382, + "Parameters": { + "Intensity": 48, + "Frequency": 13 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_m.json index 4b21a8c8e8..d735b23abf 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWater_m.json @@ -1,153 +1,153 @@ -{ - "MetaData": { - "Create": "2022-09-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 233, - "StartTime": 23, - "Parameters": { - "Intensity": 67, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 28 - }, - { - "Time": 25, - "Intensity": 0.19, - "Frequency": 25 - }, - { - "Time": 75, - "Intensity": 0.32, - "Frequency": 29 - }, - { - "Time": 131, - "Intensity": 0.46, - "Frequency": 43 - }, - { - "Time": 177, - "Intensity": 0.5, - "Frequency": 53 - }, - { - "Time": 198, - "Intensity": 0.2, - "Frequency": 48 - }, - { - "Time": 218, - "Intensity": 0.08, - "Frequency": 41 - }, - { - "Time": 233, - "Intensity": 0, - "Frequency": 48 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 177, - "Parameters": { - "Intensity": 80, - "Frequency": 46 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 266, - "Parameters": { - "Intensity": 35, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 28 - }, - { - "Time": 27, - "Intensity": 0.19, - "Frequency": 25 - }, - { - "Time": 81, - "Intensity": 0.32, - "Frequency": 29 - }, - { - "Time": 136, - "Intensity": 0.39, - "Frequency": 43 - }, - { - "Time": 187, - "Intensity": 0.32, - "Frequency": 53 - }, - { - "Time": 212, - "Intensity": 0.2, - "Frequency": 48 - }, - { - "Time": 233, - "Intensity": 0.08, - "Frequency": 41 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 48 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 308, - "Parameters": { - "Intensity": 71, - "Frequency": 13 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 382, - "Parameters": { - "Intensity": 64, - "Frequency": 13 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-09-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 233, + "StartTime": 23, + "Parameters": { + "Intensity": 67, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 28 + }, + { + "Time": 25, + "Intensity": 0.19, + "Frequency": 25 + }, + { + "Time": 75, + "Intensity": 0.32, + "Frequency": 29 + }, + { + "Time": 131, + "Intensity": 0.46, + "Frequency": 43 + }, + { + "Time": 177, + "Intensity": 0.5, + "Frequency": 53 + }, + { + "Time": 198, + "Intensity": 0.2, + "Frequency": 48 + }, + { + "Time": 218, + "Intensity": 0.08, + "Frequency": 41 + }, + { + "Time": 233, + "Intensity": 0, + "Frequency": 48 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 177, + "Parameters": { + "Intensity": 80, + "Frequency": 46 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 266, + "Parameters": { + "Intensity": 35, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 28 + }, + { + "Time": 27, + "Intensity": 0.19, + "Frequency": 25 + }, + { + "Time": 81, + "Intensity": 0.32, + "Frequency": 29 + }, + { + "Time": 136, + "Intensity": 0.39, + "Frequency": 43 + }, + { + "Time": 187, + "Intensity": 0.32, + "Frequency": 53 + }, + { + "Time": 212, + "Intensity": 0.2, + "Frequency": 48 + }, + { + "Time": 233, + "Intensity": 0.08, + "Frequency": 41 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 48 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 308, + "Parameters": { + "Intensity": 71, + "Frequency": 13 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 382, + "Parameters": { + "Intensity": 64, + "Frequency": 13 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_h.json index 562378abcb..af64f7a1ee 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_h.json @@ -1,168 +1,168 @@ -{ - "MetaData": { - "Create": "2022-05-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 144, - "StartTime": 15, - "Parameters": { - "Intensity": 76, - "Frequency": 19, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 80, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 114, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 134, - "Intensity": 0.15, - "Frequency": 36 - }, - { - "Time": 144, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 124, - "StartTime": 36, - "Parameters": { - "Intensity": 81, - "Frequency": 43, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 12, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 85, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 124, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 160, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 262, - "Parameters": { - "Intensity": 50, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 314, - "Parameters": { - "Intensity": 67, - "Frequency": 53 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 364, - "Parameters": { - "Intensity": 50, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 417, - "Parameters": { - "Intensity": 65, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 496, - "Parameters": { - "Intensity": 43, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 534, - "Parameters": { - "Intensity": 55, - "Frequency": 57 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 603, - "Parameters": { - "Intensity": 40, - "Frequency": 50 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 144, + "StartTime": 15, + "Parameters": { + "Intensity": 76, + "Frequency": 19, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 80, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 114, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 134, + "Intensity": 0.15, + "Frequency": 36 + }, + { + "Time": 144, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 124, + "StartTime": 36, + "Parameters": { + "Intensity": 81, + "Frequency": 43, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 12, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 85, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 124, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 160, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 262, + "Parameters": { + "Intensity": 50, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 314, + "Parameters": { + "Intensity": 67, + "Frequency": 53 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 364, + "Parameters": { + "Intensity": 50, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 417, + "Parameters": { + "Intensity": 65, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 496, + "Parameters": { + "Intensity": 43, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 534, + "Parameters": { + "Intensity": 55, + "Frequency": 57 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 603, + "Parameters": { + "Intensity": 40, + "Frequency": 50 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_l.json index a811d974ed..aa3281725c 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_l.json @@ -1,168 +1,168 @@ -{ - "MetaData": { - "Create": "2022-05-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 144, - "StartTime": 15, - "Parameters": { - "Intensity": 45, - "Frequency": 19, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 80, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 114, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 134, - "Intensity": 0.15, - "Frequency": 36 - }, - { - "Time": 144, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 124, - "StartTime": 36, - "Parameters": { - "Intensity": 48, - "Frequency": 43, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 12, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 85, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 124, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 160, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 262, - "Parameters": { - "Intensity": 30, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 314, - "Parameters": { - "Intensity": 40, - "Frequency": 53 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 364, - "Parameters": { - "Intensity": 30, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 417, - "Parameters": { - "Intensity": 39, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 496, - "Parameters": { - "Intensity": 25, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 534, - "Parameters": { - "Intensity": 33, - "Frequency": 57 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 603, - "Parameters": { - "Intensity": 24, - "Frequency": 50 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 144, + "StartTime": 15, + "Parameters": { + "Intensity": 45, + "Frequency": 19, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 80, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 114, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 134, + "Intensity": 0.15, + "Frequency": 36 + }, + { + "Time": 144, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 124, + "StartTime": 36, + "Parameters": { + "Intensity": 48, + "Frequency": 43, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 12, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 85, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 124, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 160, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 262, + "Parameters": { + "Intensity": 30, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 314, + "Parameters": { + "Intensity": 40, + "Frequency": 53 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 364, + "Parameters": { + "Intensity": 30, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 417, + "Parameters": { + "Intensity": 39, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 496, + "Parameters": { + "Intensity": 25, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 534, + "Parameters": { + "Intensity": 33, + "Frequency": 57 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 603, + "Parameters": { + "Intensity": 24, + "Frequency": 50 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_m.json index db1da2e253..430c081e9c 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/HitWood_m.json @@ -1,168 +1,168 @@ -{ - "MetaData": { - "Create": "2022-05-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 144, - "StartTime": 15, - "Parameters": { - "Intensity": 60, - "Frequency": 19, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 80, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 114, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 134, - "Intensity": 0.15, - "Frequency": 36 - }, - { - "Time": 144, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 124, - "StartTime": 36, - "Parameters": { - "Intensity": 64, - "Frequency": 43, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 12, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 85, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 124, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 160, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 262, - "Parameters": { - "Intensity": 40, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 314, - "Parameters": { - "Intensity": 53, - "Frequency": 53 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 364, - "Parameters": { - "Intensity": 40, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 417, - "Parameters": { - "Intensity": 52, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 496, - "Parameters": { - "Intensity": 34, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 534, - "Parameters": { - "Intensity": 44, - "Frequency": 57 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 603, - "Parameters": { - "Intensity": 32, - "Frequency": 50 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-05-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 144, + "StartTime": 15, + "Parameters": { + "Intensity": 60, + "Frequency": 19, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 80, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 114, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 134, + "Intensity": 0.15, + "Frequency": 36 + }, + { + "Time": 144, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 124, + "StartTime": 36, + "Parameters": { + "Intensity": 64, + "Frequency": 43, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 12, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 85, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 124, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 160, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 262, + "Parameters": { + "Intensity": 40, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 314, + "Parameters": { + "Intensity": 53, + "Frequency": 53 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 364, + "Parameters": { + "Intensity": 40, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 417, + "Parameters": { + "Intensity": 52, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 496, + "Parameters": { + "Intensity": 34, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 534, + "Parameters": { + "Intensity": 44, + "Frequency": 57 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 603, + "Parameters": { + "Intensity": 32, + "Frequency": 50 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_h.json index c310bc29e0..7c2f531319 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_h.json @@ -1,203 +1,203 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 270, - "StartTime": 36, - "Parameters": { - "Intensity": 81, - "Frequency": 39, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0.25, - "Frequency": -50 - }, - { - "Time": 101, - "Intensity": 0.83, - "Frequency": 30 - }, - { - "Time": 135, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 168, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 270, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 340, - "StartTime": 278, - "Parameters": { - "Intensity": 100, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 74 - }, - { - "Time": 21, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 38, - "Intensity": 0.17, - "Frequency": 75 - }, - { - "Time": 61, - "Intensity": 0.24, - "Frequency": 75 - }, - { - "Time": 89, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 112, - "Intensity": 0.05, - "Frequency": 78 - }, - { - "Time": 135, - "Intensity": 0.07, - "Frequency": 79 - }, - { - "Time": 155, - "Intensity": 0.12, - "Frequency": 81 - }, - { - "Time": 183, - "Intensity": 0.21, - "Frequency": 80 - }, - { - "Time": 203, - "Intensity": 0.15, - "Frequency": 79 - }, - { - "Time": 225, - "Intensity": 0.12, - "Frequency": 79 - }, - { - "Time": 246, - "Intensity": 0.1, - "Frequency": 78 - }, - { - "Time": 269, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 293, - "Intensity": 0.16, - "Frequency": 75 - }, - { - "Time": 308, - "Intensity": 0.11, - "Frequency": 76 - }, - { - "Time": 340, - "Intensity": 0, - "Frequency": 76 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 370, - "Parameters": { - "Intensity": 24, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 413, - "Parameters": { - "Intensity": 41, - "Frequency": 83 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 462, - "Parameters": { - "Intensity": 32, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 516, - "Parameters": { - "Intensity": 22, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 587, - "Parameters": { - "Intensity": 27, - "Frequency": 82 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 270, + "StartTime": 36, + "Parameters": { + "Intensity": 81, + "Frequency": 39, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0.25, + "Frequency": -50 + }, + { + "Time": 101, + "Intensity": 0.83, + "Frequency": 30 + }, + { + "Time": 135, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 168, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 270, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 340, + "StartTime": 278, + "Parameters": { + "Intensity": 100, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 74 + }, + { + "Time": 21, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 38, + "Intensity": 0.17, + "Frequency": 75 + }, + { + "Time": 61, + "Intensity": 0.24, + "Frequency": 75 + }, + { + "Time": 89, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 112, + "Intensity": 0.05, + "Frequency": 78 + }, + { + "Time": 135, + "Intensity": 0.07, + "Frequency": 79 + }, + { + "Time": 155, + "Intensity": 0.12, + "Frequency": 81 + }, + { + "Time": 183, + "Intensity": 0.21, + "Frequency": 80 + }, + { + "Time": 203, + "Intensity": 0.15, + "Frequency": 79 + }, + { + "Time": 225, + "Intensity": 0.12, + "Frequency": 79 + }, + { + "Time": 246, + "Intensity": 0.1, + "Frequency": 78 + }, + { + "Time": 269, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 293, + "Intensity": 0.16, + "Frequency": 75 + }, + { + "Time": 308, + "Intensity": 0.11, + "Frequency": 76 + }, + { + "Time": 340, + "Intensity": 0, + "Frequency": 76 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 370, + "Parameters": { + "Intensity": 24, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 413, + "Parameters": { + "Intensity": 41, + "Frequency": 83 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 462, + "Parameters": { + "Intensity": 32, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 516, + "Parameters": { + "Intensity": 22, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 587, + "Parameters": { + "Intensity": 27, + "Frequency": 82 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_l.json index 69716aa7a8..9a0e02e709 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_l.json @@ -1,203 +1,203 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 270, - "StartTime": 36, - "Parameters": { - "Intensity": 48, - "Frequency": 39, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0.25, - "Frequency": -50 - }, - { - "Time": 101, - "Intensity": 0.83, - "Frequency": 30 - }, - { - "Time": 135, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 168, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 270, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 340, - "StartTime": 278, - "Parameters": { - "Intensity": 60, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 74 - }, - { - "Time": 21, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 38, - "Intensity": 0.17, - "Frequency": 75 - }, - { - "Time": 61, - "Intensity": 0.24, - "Frequency": 75 - }, - { - "Time": 89, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 112, - "Intensity": 0.05, - "Frequency": 78 - }, - { - "Time": 135, - "Intensity": 0.07, - "Frequency": 79 - }, - { - "Time": 155, - "Intensity": 0.12, - "Frequency": 81 - }, - { - "Time": 183, - "Intensity": 0.21, - "Frequency": 80 - }, - { - "Time": 203, - "Intensity": 0.15, - "Frequency": 79 - }, - { - "Time": 225, - "Intensity": 0.12, - "Frequency": 79 - }, - { - "Time": 246, - "Intensity": 0.1, - "Frequency": 78 - }, - { - "Time": 269, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 293, - "Intensity": 0.16, - "Frequency": 75 - }, - { - "Time": 308, - "Intensity": 0.11, - "Frequency": 76 - }, - { - "Time": 340, - "Intensity": 0, - "Frequency": 76 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 370, - "Parameters": { - "Intensity": 14, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 413, - "Parameters": { - "Intensity": 24, - "Frequency": 83 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 462, - "Parameters": { - "Intensity": 19, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 516, - "Parameters": { - "Intensity": 13, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 587, - "Parameters": { - "Intensity": 16, - "Frequency": 82 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 270, + "StartTime": 36, + "Parameters": { + "Intensity": 48, + "Frequency": 39, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0.25, + "Frequency": -50 + }, + { + "Time": 101, + "Intensity": 0.83, + "Frequency": 30 + }, + { + "Time": 135, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 168, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 270, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 340, + "StartTime": 278, + "Parameters": { + "Intensity": 60, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 74 + }, + { + "Time": 21, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 38, + "Intensity": 0.17, + "Frequency": 75 + }, + { + "Time": 61, + "Intensity": 0.24, + "Frequency": 75 + }, + { + "Time": 89, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 112, + "Intensity": 0.05, + "Frequency": 78 + }, + { + "Time": 135, + "Intensity": 0.07, + "Frequency": 79 + }, + { + "Time": 155, + "Intensity": 0.12, + "Frequency": 81 + }, + { + "Time": 183, + "Intensity": 0.21, + "Frequency": 80 + }, + { + "Time": 203, + "Intensity": 0.15, + "Frequency": 79 + }, + { + "Time": 225, + "Intensity": 0.12, + "Frequency": 79 + }, + { + "Time": 246, + "Intensity": 0.1, + "Frequency": 78 + }, + { + "Time": 269, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 293, + "Intensity": 0.16, + "Frequency": 75 + }, + { + "Time": 308, + "Intensity": 0.11, + "Frequency": 76 + }, + { + "Time": 340, + "Intensity": 0, + "Frequency": 76 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 370, + "Parameters": { + "Intensity": 14, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 413, + "Parameters": { + "Intensity": 24, + "Frequency": 83 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 462, + "Parameters": { + "Intensity": 19, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 516, + "Parameters": { + "Intensity": 13, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 587, + "Parameters": { + "Intensity": 16, + "Frequency": 82 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_m.json index ccc24a4b64..680c548a0d 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Hurt_m.json @@ -1,203 +1,203 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 270, - "StartTime": 36, - "Parameters": { - "Intensity": 64, - "Frequency": 39, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0.25, - "Frequency": -50 - }, - { - "Time": 101, - "Intensity": 0.83, - "Frequency": 30 - }, - { - "Time": 135, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 168, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 270, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 340, - "StartTime": 278, - "Parameters": { - "Intensity": 80, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 74 - }, - { - "Time": 21, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 38, - "Intensity": 0.17, - "Frequency": 75 - }, - { - "Time": 61, - "Intensity": 0.24, - "Frequency": 75 - }, - { - "Time": 89, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 112, - "Intensity": 0.05, - "Frequency": 78 - }, - { - "Time": 135, - "Intensity": 0.07, - "Frequency": 79 - }, - { - "Time": 155, - "Intensity": 0.12, - "Frequency": 81 - }, - { - "Time": 183, - "Intensity": 0.21, - "Frequency": 80 - }, - { - "Time": 203, - "Intensity": 0.15, - "Frequency": 79 - }, - { - "Time": 225, - "Intensity": 0.12, - "Frequency": 79 - }, - { - "Time": 246, - "Intensity": 0.1, - "Frequency": 78 - }, - { - "Time": 269, - "Intensity": 0.06, - "Frequency": 76 - }, - { - "Time": 293, - "Intensity": 0.16, - "Frequency": 75 - }, - { - "Time": 308, - "Intensity": 0.11, - "Frequency": 76 - }, - { - "Time": 340, - "Intensity": 0, - "Frequency": 76 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 370, - "Parameters": { - "Intensity": 19, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 413, - "Parameters": { - "Intensity": 32, - "Frequency": 83 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 462, - "Parameters": { - "Intensity": 25, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 516, - "Parameters": { - "Intensity": 17, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 587, - "Parameters": { - "Intensity": 21, - "Frequency": 82 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 270, + "StartTime": 36, + "Parameters": { + "Intensity": 64, + "Frequency": 39, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0.25, + "Frequency": -50 + }, + { + "Time": 101, + "Intensity": 0.83, + "Frequency": 30 + }, + { + "Time": 135, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 168, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 270, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 340, + "StartTime": 278, + "Parameters": { + "Intensity": 80, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 74 + }, + { + "Time": 21, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 38, + "Intensity": 0.17, + "Frequency": 75 + }, + { + "Time": 61, + "Intensity": 0.24, + "Frequency": 75 + }, + { + "Time": 89, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 112, + "Intensity": 0.05, + "Frequency": 78 + }, + { + "Time": 135, + "Intensity": 0.07, + "Frequency": 79 + }, + { + "Time": 155, + "Intensity": 0.12, + "Frequency": 81 + }, + { + "Time": 183, + "Intensity": 0.21, + "Frequency": 80 + }, + { + "Time": 203, + "Intensity": 0.15, + "Frequency": 79 + }, + { + "Time": 225, + "Intensity": 0.12, + "Frequency": 79 + }, + { + "Time": 246, + "Intensity": 0.1, + "Frequency": 78 + }, + { + "Time": 269, + "Intensity": 0.06, + "Frequency": 76 + }, + { + "Time": 293, + "Intensity": 0.16, + "Frequency": 75 + }, + { + "Time": 308, + "Intensity": 0.11, + "Frequency": 76 + }, + { + "Time": 340, + "Intensity": 0, + "Frequency": 76 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 370, + "Parameters": { + "Intensity": 19, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 413, + "Parameters": { + "Intensity": 32, + "Frequency": 83 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 462, + "Parameters": { + "Intensity": 25, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 516, + "Parameters": { + "Intensity": 17, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 587, + "Parameters": { + "Intensity": 21, + "Frequency": 82 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_h.json index 17ec74e849..aa77836f22 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_h.json @@ -1,196 +1,196 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 2468, - "StartTime": 13, - "Parameters": { - "Intensity": 97, - "Frequency": 34, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -7 - }, - { - "Time": 42, - "Intensity": 1, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.94, - "Frequency": -4 - }, - { - "Time": 217, - "Intensity": 0.63, - "Frequency": -14 - }, - { - "Time": 763, - "Intensity": 0.53, - "Frequency": -10 - }, - { - "Time": 1125, - "Intensity": 0.48, - "Frequency": -14 - }, - { - "Time": 1503, - "Intensity": 0.42, - "Frequency": -14 - }, - { - "Time": 1858, - "Intensity": 0.39, - "Frequency": -14 - }, - { - "Time": 2295, - "Intensity": 0.34, - "Frequency": -17 - }, - { - "Time": 2448, - "Intensity": 0.21, - "Frequency": -14 - }, - { - "Time": 2468, - "Intensity": 0, - "Frequency": -21 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 2468, - "StartTime": 15, - "Parameters": { - "Intensity": 97, - "Frequency": 27, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -7 - }, - { - "Time": 47, - "Intensity": 0.9, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.84, - "Frequency": -4 - }, - { - "Time": 143, - "Intensity": 0.59, - "Frequency": -14 - }, - { - "Time": 183, - "Intensity": 0.16, - "Frequency": -10 - }, - { - "Time": 1081, - "Intensity": 0.1, - "Frequency": -14 - }, - { - "Time": 1464, - "Intensity": 0.07, - "Frequency": -14 - }, - { - "Time": 1826, - "Intensity": 0.04, - "Frequency": -14 - }, - { - "Time": 2056, - "Intensity": 0.04, - "Frequency": -17 - }, - { - "Time": 2391, - "Intensity": 0.03, - "Frequency": -14 - }, - { - "Time": 2468, - "Intensity": 0, - "Frequency": -21 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 570, - "StartTime": 2486, - "Parameters": { - "Intensity": 80, - "Frequency": 90, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 127, - "Intensity": 0.09, - "Frequency": -80 - }, - { - "Time": 263, - "Intensity": 0.97, - "Frequency": -34 - }, - { - "Time": 300, - "Intensity": 0.92, - "Frequency": -34 - }, - { - "Time": 464, - "Intensity": 0.16, - "Frequency": -60 - }, - { - "Time": 570, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 2468, + "StartTime": 13, + "Parameters": { + "Intensity": 97, + "Frequency": 34, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -7 + }, + { + "Time": 42, + "Intensity": 1, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.94, + "Frequency": -4 + }, + { + "Time": 217, + "Intensity": 0.63, + "Frequency": -14 + }, + { + "Time": 763, + "Intensity": 0.53, + "Frequency": -10 + }, + { + "Time": 1125, + "Intensity": 0.48, + "Frequency": -14 + }, + { + "Time": 1503, + "Intensity": 0.42, + "Frequency": -14 + }, + { + "Time": 1858, + "Intensity": 0.39, + "Frequency": -14 + }, + { + "Time": 2295, + "Intensity": 0.34, + "Frequency": -17 + }, + { + "Time": 2448, + "Intensity": 0.21, + "Frequency": -14 + }, + { + "Time": 2468, + "Intensity": 0, + "Frequency": -21 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 2468, + "StartTime": 15, + "Parameters": { + "Intensity": 97, + "Frequency": 27, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -7 + }, + { + "Time": 47, + "Intensity": 0.9, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.84, + "Frequency": -4 + }, + { + "Time": 143, + "Intensity": 0.59, + "Frequency": -14 + }, + { + "Time": 183, + "Intensity": 0.16, + "Frequency": -10 + }, + { + "Time": 1081, + "Intensity": 0.1, + "Frequency": -14 + }, + { + "Time": 1464, + "Intensity": 0.07, + "Frequency": -14 + }, + { + "Time": 1826, + "Intensity": 0.04, + "Frequency": -14 + }, + { + "Time": 2056, + "Intensity": 0.04, + "Frequency": -17 + }, + { + "Time": 2391, + "Intensity": 0.03, + "Frequency": -14 + }, + { + "Time": 2468, + "Intensity": 0, + "Frequency": -21 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 570, + "StartTime": 2486, + "Parameters": { + "Intensity": 80, + "Frequency": 90, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 127, + "Intensity": 0.09, + "Frequency": -80 + }, + { + "Time": 263, + "Intensity": 0.97, + "Frequency": -34 + }, + { + "Time": 300, + "Intensity": 0.92, + "Frequency": -34 + }, + { + "Time": 464, + "Intensity": 0.16, + "Frequency": -60 + }, + { + "Time": 570, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_l.json index 384cdb88c3..764f2127f8 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_l.json @@ -1,196 +1,196 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 2468, - "StartTime": 13, - "Parameters": { - "Intensity": 58, - "Frequency": 34, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -7 - }, - { - "Time": 42, - "Intensity": 1, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.94, - "Frequency": -4 - }, - { - "Time": 217, - "Intensity": 0.63, - "Frequency": -14 - }, - { - "Time": 763, - "Intensity": 0.53, - "Frequency": -10 - }, - { - "Time": 1125, - "Intensity": 0.48, - "Frequency": -14 - }, - { - "Time": 1503, - "Intensity": 0.42, - "Frequency": -14 - }, - { - "Time": 1858, - "Intensity": 0.39, - "Frequency": -14 - }, - { - "Time": 2295, - "Intensity": 0.34, - "Frequency": -17 - }, - { - "Time": 2448, - "Intensity": 0.21, - "Frequency": -14 - }, - { - "Time": 2468, - "Intensity": 0, - "Frequency": -21 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 2468, - "StartTime": 15, - "Parameters": { - "Intensity": 58, - "Frequency": 27, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -7 - }, - { - "Time": 47, - "Intensity": 0.9, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.84, - "Frequency": -4 - }, - { - "Time": 143, - "Intensity": 0.59, - "Frequency": -14 - }, - { - "Time": 183, - "Intensity": 0.16, - "Frequency": -10 - }, - { - "Time": 1081, - "Intensity": 0.1, - "Frequency": -14 - }, - { - "Time": 1464, - "Intensity": 0.07, - "Frequency": -14 - }, - { - "Time": 1826, - "Intensity": 0.04, - "Frequency": -14 - }, - { - "Time": 2056, - "Intensity": 0.04, - "Frequency": -17 - }, - { - "Time": 2391, - "Intensity": 0.03, - "Frequency": -14 - }, - { - "Time": 2468, - "Intensity": 0, - "Frequency": -21 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 570, - "StartTime": 2486, - "Parameters": { - "Intensity": 48, - "Frequency": 90, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 127, - "Intensity": 0.09, - "Frequency": -80 - }, - { - "Time": 263, - "Intensity": 0.97, - "Frequency": -34 - }, - { - "Time": 300, - "Intensity": 0.92, - "Frequency": -34 - }, - { - "Time": 464, - "Intensity": 0.16, - "Frequency": -60 - }, - { - "Time": 570, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 2468, + "StartTime": 13, + "Parameters": { + "Intensity": 58, + "Frequency": 34, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -7 + }, + { + "Time": 42, + "Intensity": 1, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.94, + "Frequency": -4 + }, + { + "Time": 217, + "Intensity": 0.63, + "Frequency": -14 + }, + { + "Time": 763, + "Intensity": 0.53, + "Frequency": -10 + }, + { + "Time": 1125, + "Intensity": 0.48, + "Frequency": -14 + }, + { + "Time": 1503, + "Intensity": 0.42, + "Frequency": -14 + }, + { + "Time": 1858, + "Intensity": 0.39, + "Frequency": -14 + }, + { + "Time": 2295, + "Intensity": 0.34, + "Frequency": -17 + }, + { + "Time": 2448, + "Intensity": 0.21, + "Frequency": -14 + }, + { + "Time": 2468, + "Intensity": 0, + "Frequency": -21 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 2468, + "StartTime": 15, + "Parameters": { + "Intensity": 58, + "Frequency": 27, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -7 + }, + { + "Time": 47, + "Intensity": 0.9, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.84, + "Frequency": -4 + }, + { + "Time": 143, + "Intensity": 0.59, + "Frequency": -14 + }, + { + "Time": 183, + "Intensity": 0.16, + "Frequency": -10 + }, + { + "Time": 1081, + "Intensity": 0.1, + "Frequency": -14 + }, + { + "Time": 1464, + "Intensity": 0.07, + "Frequency": -14 + }, + { + "Time": 1826, + "Intensity": 0.04, + "Frequency": -14 + }, + { + "Time": 2056, + "Intensity": 0.04, + "Frequency": -17 + }, + { + "Time": 2391, + "Intensity": 0.03, + "Frequency": -14 + }, + { + "Time": 2468, + "Intensity": 0, + "Frequency": -21 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 570, + "StartTime": 2486, + "Parameters": { + "Intensity": 48, + "Frequency": 90, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 127, + "Intensity": 0.09, + "Frequency": -80 + }, + { + "Time": 263, + "Intensity": 0.97, + "Frequency": -34 + }, + { + "Time": 300, + "Intensity": 0.92, + "Frequency": -34 + }, + { + "Time": 464, + "Intensity": 0.16, + "Frequency": -60 + }, + { + "Time": 570, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_m.json index 207ce36352..5783f17325 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/JetN2O_m.json @@ -1,196 +1,196 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 2468, - "StartTime": 13, - "Parameters": { - "Intensity": 77, - "Frequency": 34, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -7 - }, - { - "Time": 42, - "Intensity": 1, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.94, - "Frequency": -4 - }, - { - "Time": 217, - "Intensity": 0.63, - "Frequency": -14 - }, - { - "Time": 763, - "Intensity": 0.53, - "Frequency": -10 - }, - { - "Time": 1125, - "Intensity": 0.48, - "Frequency": -14 - }, - { - "Time": 1503, - "Intensity": 0.42, - "Frequency": -14 - }, - { - "Time": 1858, - "Intensity": 0.39, - "Frequency": -14 - }, - { - "Time": 2295, - "Intensity": 0.34, - "Frequency": -17 - }, - { - "Time": 2448, - "Intensity": 0.21, - "Frequency": -14 - }, - { - "Time": 2468, - "Intensity": 0, - "Frequency": -21 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 2468, - "StartTime": 15, - "Parameters": { - "Intensity": 77, - "Frequency": 27, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -7 - }, - { - "Time": 47, - "Intensity": 0.9, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.84, - "Frequency": -4 - }, - { - "Time": 143, - "Intensity": 0.59, - "Frequency": -14 - }, - { - "Time": 183, - "Intensity": 0.16, - "Frequency": -10 - }, - { - "Time": 1081, - "Intensity": 0.1, - "Frequency": -14 - }, - { - "Time": 1464, - "Intensity": 0.07, - "Frequency": -14 - }, - { - "Time": 1826, - "Intensity": 0.04, - "Frequency": -14 - }, - { - "Time": 2056, - "Intensity": 0.04, - "Frequency": -17 - }, - { - "Time": 2391, - "Intensity": 0.03, - "Frequency": -14 - }, - { - "Time": 2468, - "Intensity": 0, - "Frequency": -21 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 570, - "StartTime": 2486, - "Parameters": { - "Intensity": 64, - "Frequency": 90, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 127, - "Intensity": 0.09, - "Frequency": -80 - }, - { - "Time": 263, - "Intensity": 0.97, - "Frequency": -34 - }, - { - "Time": 300, - "Intensity": 0.92, - "Frequency": -34 - }, - { - "Time": 464, - "Intensity": 0.16, - "Frequency": -60 - }, - { - "Time": 570, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 2468, + "StartTime": 13, + "Parameters": { + "Intensity": 77, + "Frequency": 34, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -7 + }, + { + "Time": 42, + "Intensity": 1, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.94, + "Frequency": -4 + }, + { + "Time": 217, + "Intensity": 0.63, + "Frequency": -14 + }, + { + "Time": 763, + "Intensity": 0.53, + "Frequency": -10 + }, + { + "Time": 1125, + "Intensity": 0.48, + "Frequency": -14 + }, + { + "Time": 1503, + "Intensity": 0.42, + "Frequency": -14 + }, + { + "Time": 1858, + "Intensity": 0.39, + "Frequency": -14 + }, + { + "Time": 2295, + "Intensity": 0.34, + "Frequency": -17 + }, + { + "Time": 2448, + "Intensity": 0.21, + "Frequency": -14 + }, + { + "Time": 2468, + "Intensity": 0, + "Frequency": -21 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 2468, + "StartTime": 15, + "Parameters": { + "Intensity": 77, + "Frequency": 27, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -7 + }, + { + "Time": 47, + "Intensity": 0.9, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.84, + "Frequency": -4 + }, + { + "Time": 143, + "Intensity": 0.59, + "Frequency": -14 + }, + { + "Time": 183, + "Intensity": 0.16, + "Frequency": -10 + }, + { + "Time": 1081, + "Intensity": 0.1, + "Frequency": -14 + }, + { + "Time": 1464, + "Intensity": 0.07, + "Frequency": -14 + }, + { + "Time": 1826, + "Intensity": 0.04, + "Frequency": -14 + }, + { + "Time": 2056, + "Intensity": 0.04, + "Frequency": -17 + }, + { + "Time": 2391, + "Intensity": 0.03, + "Frequency": -14 + }, + { + "Time": 2468, + "Intensity": 0, + "Frequency": -21 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 570, + "StartTime": 2486, + "Parameters": { + "Intensity": 64, + "Frequency": 90, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 127, + "Intensity": 0.09, + "Frequency": -80 + }, + { + "Time": 263, + "Intensity": 0.97, + "Frequency": -34 + }, + { + "Time": 300, + "Intensity": 0.92, + "Frequency": -34 + }, + { + "Time": 464, + "Intensity": 0.16, + "Frequency": -60 + }, + { + "Time": 570, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_h.json index 5809f62e5c..3b5f4ef42c 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_h.json @@ -1,87 +1,87 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 32, - "Parameters": { - "Intensity": 100, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 121, - "Parameters": { - "Intensity": 50, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 206, - "Parameters": { - "Intensity": 100, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 297, - "Parameters": { - "Intensity": 49, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 391, - "Parameters": { - "Intensity": 100, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 474, - "Parameters": { - "Intensity": 49, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 566, - "Parameters": { - "Intensity": 100, - "Frequency": 90 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 32, + "Parameters": { + "Intensity": 100, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 121, + "Parameters": { + "Intensity": 50, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 206, + "Parameters": { + "Intensity": 100, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 297, + "Parameters": { + "Intensity": 49, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 391, + "Parameters": { + "Intensity": 100, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 474, + "Parameters": { + "Intensity": 49, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 566, + "Parameters": { + "Intensity": 100, + "Frequency": 90 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_l.json index b74735fe5d..8fec407dae 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_l.json @@ -1,87 +1,87 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 32, - "Parameters": { - "Intensity": 60, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 121, - "Parameters": { - "Intensity": 30, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 206, - "Parameters": { - "Intensity": 60, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 297, - "Parameters": { - "Intensity": 29, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 391, - "Parameters": { - "Intensity": 60, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 474, - "Parameters": { - "Intensity": 29, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 566, - "Parameters": { - "Intensity": 60, - "Frequency": 90 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 32, + "Parameters": { + "Intensity": 60, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 121, + "Parameters": { + "Intensity": 30, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 206, + "Parameters": { + "Intensity": 60, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 297, + "Parameters": { + "Intensity": 29, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 391, + "Parameters": { + "Intensity": 60, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 474, + "Parameters": { + "Intensity": 29, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 566, + "Parameters": { + "Intensity": 60, + "Frequency": 90 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_m.json index 7d164294e6..141e38f250 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Keyboard_m.json @@ -1,87 +1,87 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 32, - "Parameters": { - "Intensity": 80, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 121, - "Parameters": { - "Intensity": 40, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 206, - "Parameters": { - "Intensity": 80, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 297, - "Parameters": { - "Intensity": 39, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 391, - "Parameters": { - "Intensity": 80, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 474, - "Parameters": { - "Intensity": 39, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 566, - "Parameters": { - "Intensity": 80, - "Frequency": 90 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 32, + "Parameters": { + "Intensity": 80, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 121, + "Parameters": { + "Intensity": 40, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 206, + "Parameters": { + "Intensity": 80, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 297, + "Parameters": { + "Intensity": 39, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 391, + "Parameters": { + "Intensity": 80, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 474, + "Parameters": { + "Intensity": 39, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 566, + "Parameters": { + "Intensity": 80, + "Frequency": 90 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_h.json index 21e70cfebc..e6777614b4 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_h.json @@ -1,50 +1,50 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 76, - "StartTime": 9, - "Parameters": { - "Intensity": 100, - "Frequency": 53, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 6, - "Intensity": 1, - "Frequency": -100 - }, - { - "Time": 57, - "Intensity": 1, - "Frequency": -100 - }, - { - "Time": 76, - "Intensity": 0, - "Frequency": -100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 76, + "StartTime": 9, + "Parameters": { + "Intensity": 100, + "Frequency": 53, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 6, + "Intensity": 1, + "Frequency": -100 + }, + { + "Time": 57, + "Intensity": 1, + "Frequency": -100 + }, + { + "Time": 76, + "Intensity": 0, + "Frequency": -100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_l.json index 0f2c6e7334..04f05cb08b 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_l.json @@ -1,50 +1,50 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 76, - "StartTime": 9, - "Parameters": { - "Intensity": 60, - "Frequency": 53, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 6, - "Intensity": 1, - "Frequency": -100 - }, - { - "Time": 57, - "Intensity": 1, - "Frequency": -100 - }, - { - "Time": 76, - "Intensity": 0, - "Frequency": -100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 76, + "StartTime": 9, + "Parameters": { + "Intensity": 60, + "Frequency": 53, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 6, + "Intensity": 1, + "Frequency": -100 + }, + { + "Time": 57, + "Intensity": 1, + "Frequency": -100 + }, + { + "Time": 76, + "Intensity": 0, + "Frequency": -100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_m.json index 32b42b0fd2..e77899d198 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum2_m.json @@ -1,50 +1,50 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 76, - "StartTime": 9, - "Parameters": { - "Intensity": 80, - "Frequency": 53, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 6, - "Intensity": 1, - "Frequency": -100 - }, - { - "Time": 57, - "Intensity": 1, - "Frequency": -100 - }, - { - "Time": 76, - "Intensity": 0, - "Frequency": -100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 76, + "StartTime": 9, + "Parameters": { + "Intensity": 80, + "Frequency": 53, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 6, + "Intensity": 1, + "Frequency": -100 + }, + { + "Time": 57, + "Intensity": 1, + "Frequency": -100 + }, + { + "Time": 76, + "Intensity": 0, + "Frequency": -100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_h.json index 50a37c25f6..52fa2abd27 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_h.json @@ -1,27 +1,27 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 14, - "Parameters": { - "Intensity": 100, - "Frequency": 15 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 14, + "Parameters": { + "Intensity": 100, + "Frequency": 15 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_l.json index 6687fafbaa..ed618ebb47 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_l.json @@ -1,27 +1,27 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 14, - "Parameters": { - "Intensity": 60, - "Frequency": 15 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 14, + "Parameters": { + "Intensity": 60, + "Frequency": 15 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_m.json index f19f7e3c09..c129fe54d7 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/KickDrum_m.json @@ -1,27 +1,27 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 14, - "Parameters": { - "Intensity": 80, - "Frequency": 15 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 14, + "Parameters": { + "Intensity": 80, + "Frequency": 15 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_h.json index 16de21e9e6..7a3eea6e48 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_h.json @@ -1,108 +1,108 @@ -{ - "MetaData": { - "Create": "2022-04-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 224, - "StartTime": 0, - "Parameters": { - "Intensity": 94, - "Frequency": 31, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -22 - }, - { - "Time": 101, - "Intensity": 0.36, - "Frequency": -9 - }, - { - "Time": 126, - "Intensity": 0.76, - "Frequency": -19 - }, - { - "Time": 134, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 170, - "Intensity": 0.28, - "Frequency": 0 - }, - { - "Time": 224, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 218, - "StartTime": 224, - "Parameters": { - "Intensity": 86, - "Frequency": 57, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 48, - "Intensity": 0.31, - "Frequency": -83 - }, - { - "Time": 81, - "Intensity": 1, - "Frequency": -8 - }, - { - "Time": 137, - "Intensity": 0.23, - "Frequency": -58 - }, - { - "Time": 218, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 276, - "Parameters": { - "Intensity": 100, - "Frequency": 45 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 224, + "StartTime": 0, + "Parameters": { + "Intensity": 94, + "Frequency": 31, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -22 + }, + { + "Time": 101, + "Intensity": 0.36, + "Frequency": -9 + }, + { + "Time": 126, + "Intensity": 0.76, + "Frequency": -19 + }, + { + "Time": 134, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 170, + "Intensity": 0.28, + "Frequency": 0 + }, + { + "Time": 224, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 218, + "StartTime": 224, + "Parameters": { + "Intensity": 86, + "Frequency": 57, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 48, + "Intensity": 0.31, + "Frequency": -83 + }, + { + "Time": 81, + "Intensity": 1, + "Frequency": -8 + }, + { + "Time": 137, + "Intensity": 0.23, + "Frequency": -58 + }, + { + "Time": 218, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 276, + "Parameters": { + "Intensity": 100, + "Frequency": 45 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_l.json index 7479575425..82cdf451fd 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_l.json @@ -1,108 +1,108 @@ -{ - "MetaData": { - "Create": "2022-04-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 224, - "StartTime": 0, - "Parameters": { - "Intensity": 56, - "Frequency": 31, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -22 - }, - { - "Time": 101, - "Intensity": 0.36, - "Frequency": -9 - }, - { - "Time": 126, - "Intensity": 0.76, - "Frequency": -19 - }, - { - "Time": 134, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 170, - "Intensity": 0.28, - "Frequency": 0 - }, - { - "Time": 224, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 218, - "StartTime": 224, - "Parameters": { - "Intensity": 51, - "Frequency": 57, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 48, - "Intensity": 0.31, - "Frequency": -83 - }, - { - "Time": 81, - "Intensity": 1, - "Frequency": -8 - }, - { - "Time": 137, - "Intensity": 0.23, - "Frequency": -58 - }, - { - "Time": 218, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 276, - "Parameters": { - "Intensity": 60, - "Frequency": 45 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 224, + "StartTime": 0, + "Parameters": { + "Intensity": 56, + "Frequency": 31, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -22 + }, + { + "Time": 101, + "Intensity": 0.36, + "Frequency": -9 + }, + { + "Time": 126, + "Intensity": 0.76, + "Frequency": -19 + }, + { + "Time": 134, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 170, + "Intensity": 0.28, + "Frequency": 0 + }, + { + "Time": 224, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 218, + "StartTime": 224, + "Parameters": { + "Intensity": 51, + "Frequency": 57, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 48, + "Intensity": 0.31, + "Frequency": -83 + }, + { + "Time": 81, + "Intensity": 1, + "Frequency": -8 + }, + { + "Time": 137, + "Intensity": 0.23, + "Frequency": -58 + }, + { + "Time": 218, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 276, + "Parameters": { + "Intensity": 60, + "Frequency": 45 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_m.json index b47833fa6d..89e45880b6 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Kick_m.json @@ -1,108 +1,108 @@ -{ - "MetaData": { - "Create": "2022-04-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 224, - "StartTime": 0, - "Parameters": { - "Intensity": 75, - "Frequency": 31, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -22 - }, - { - "Time": 101, - "Intensity": 0.36, - "Frequency": -9 - }, - { - "Time": 126, - "Intensity": 0.76, - "Frequency": -19 - }, - { - "Time": 134, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 170, - "Intensity": 0.28, - "Frequency": 0 - }, - { - "Time": 224, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 218, - "StartTime": 224, - "Parameters": { - "Intensity": 68, - "Frequency": 57, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 48, - "Intensity": 0.31, - "Frequency": -83 - }, - { - "Time": 81, - "Intensity": 1, - "Frequency": -8 - }, - { - "Time": 137, - "Intensity": 0.23, - "Frequency": -58 - }, - { - "Time": 218, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 276, - "Parameters": { - "Intensity": 80, - "Frequency": 45 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 224, + "StartTime": 0, + "Parameters": { + "Intensity": 75, + "Frequency": 31, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -22 + }, + { + "Time": 101, + "Intensity": 0.36, + "Frequency": -9 + }, + { + "Time": 126, + "Intensity": 0.76, + "Frequency": -19 + }, + { + "Time": 134, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 170, + "Intensity": 0.28, + "Frequency": 0 + }, + { + "Time": 224, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 218, + "StartTime": 224, + "Parameters": { + "Intensity": 68, + "Frequency": 57, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 48, + "Intensity": 0.31, + "Frequency": -83 + }, + { + "Time": 81, + "Intensity": 1, + "Frequency": -8 + }, + { + "Time": 137, + "Intensity": 0.23, + "Frequency": -58 + }, + { + "Time": 218, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 276, + "Parameters": { + "Intensity": 80, + "Frequency": 45 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_h.json index 6c61384113..c4994c5d14 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_h.json @@ -1,213 +1,213 @@ -{ - "MetaData": { - "Create": "2022-09-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 76 - }, - { - "Time": 33, - "Intensity": 0, - "Frequency": 76 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 69 - }, - { - "Time": 83, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 68 - }, - { - "Time": 117, - "Intensity": 0, - "Frequency": 73 - }, - { - "Time": 133, - "Intensity": 0, - "Frequency": 73 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 71 - }, - { - "Time": 167, - "Intensity": 0, - "Frequency": 69 - }, - { - "Time": 183, - "Intensity": 0, - "Frequency": 69 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 38 - }, - { - "Time": 221, - "Intensity": 0.22, - "Frequency": 34 - }, - { - "Time": 233, - "Intensity": 1, - "Frequency": 44 - }, - { - "Time": 238, - "Intensity": 1, - "Frequency": 40 - }, - { - "Time": 244, - "Intensity": 0.06, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 70 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 211, - "Parameters": { - "Intensity": 100, - "Frequency": 31 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 231, - "StartTime": 252, - "Parameters": { - "Intensity": 70, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 70 - }, - { - "Time": 16, - "Intensity": 0.17, - "Frequency": 70 - }, - { - "Time": 35, - "Intensity": 0.36, - "Frequency": 74 - }, - { - "Time": 41, - "Intensity": 0.28, - "Frequency": 75 - }, - { - "Time": 62, - "Intensity": 0.31, - "Frequency": 74 - }, - { - "Time": 79, - "Intensity": 0.23, - "Frequency": 73 - }, - { - "Time": 107, - "Intensity": 0.14, - "Frequency": 72 - }, - { - "Time": 128, - "Intensity": 0.12, - "Frequency": 73 - }, - { - "Time": 142, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 159, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 177, - "Intensity": 0.08, - "Frequency": 75 - }, - { - "Time": 202, - "Intensity": 0.05, - "Frequency": 74 - }, - { - "Time": 217, - "Intensity": 0.03, - "Frequency": 75 - }, - { - "Time": 231, - "Intensity": 0, - "Frequency": 74 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 280, - "Parameters": { - "Intensity": 100, - "Frequency": 45 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-09-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 76 + }, + { + "Time": 33, + "Intensity": 0, + "Frequency": 76 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 69 + }, + { + "Time": 83, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 68 + }, + { + "Time": 117, + "Intensity": 0, + "Frequency": 73 + }, + { + "Time": 133, + "Intensity": 0, + "Frequency": 73 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 71 + }, + { + "Time": 167, + "Intensity": 0, + "Frequency": 69 + }, + { + "Time": 183, + "Intensity": 0, + "Frequency": 69 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 38 + }, + { + "Time": 221, + "Intensity": 0.22, + "Frequency": 34 + }, + { + "Time": 233, + "Intensity": 1, + "Frequency": 44 + }, + { + "Time": 238, + "Intensity": 1, + "Frequency": 40 + }, + { + "Time": 244, + "Intensity": 0.06, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 70 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 211, + "Parameters": { + "Intensity": 100, + "Frequency": 31 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 231, + "StartTime": 252, + "Parameters": { + "Intensity": 70, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 70 + }, + { + "Time": 16, + "Intensity": 0.17, + "Frequency": 70 + }, + { + "Time": 35, + "Intensity": 0.36, + "Frequency": 74 + }, + { + "Time": 41, + "Intensity": 0.28, + "Frequency": 75 + }, + { + "Time": 62, + "Intensity": 0.31, + "Frequency": 74 + }, + { + "Time": 79, + "Intensity": 0.23, + "Frequency": 73 + }, + { + "Time": 107, + "Intensity": 0.14, + "Frequency": 72 + }, + { + "Time": 128, + "Intensity": 0.12, + "Frequency": 73 + }, + { + "Time": 142, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 159, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 177, + "Intensity": 0.08, + "Frequency": 75 + }, + { + "Time": 202, + "Intensity": 0.05, + "Frequency": 74 + }, + { + "Time": 217, + "Intensity": 0.03, + "Frequency": 75 + }, + { + "Time": 231, + "Intensity": 0, + "Frequency": 74 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 280, + "Parameters": { + "Intensity": 100, + "Frequency": 45 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_l.json index 6c54dc025e..36acfef6eb 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_l.json @@ -1,213 +1,213 @@ -{ - "MetaData": { - "Create": "2022-09-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1, - "Parameters": { - "Intensity": 36, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 76 - }, - { - "Time": 33, - "Intensity": 0, - "Frequency": 76 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 69 - }, - { - "Time": 83, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 68 - }, - { - "Time": 117, - "Intensity": 0, - "Frequency": 73 - }, - { - "Time": 133, - "Intensity": 0, - "Frequency": 73 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 71 - }, - { - "Time": 167, - "Intensity": 0, - "Frequency": 69 - }, - { - "Time": 183, - "Intensity": 0, - "Frequency": 69 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 38 - }, - { - "Time": 221, - "Intensity": 0.22, - "Frequency": 34 - }, - { - "Time": 233, - "Intensity": 1, - "Frequency": 44 - }, - { - "Time": 238, - "Intensity": 1, - "Frequency": 40 - }, - { - "Time": 244, - "Intensity": 0.06, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 70 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 211, - "Parameters": { - "Intensity": 60, - "Frequency": 31 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 231, - "StartTime": 252, - "Parameters": { - "Intensity": 42, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 70 - }, - { - "Time": 16, - "Intensity": 0.17, - "Frequency": 70 - }, - { - "Time": 35, - "Intensity": 0.36, - "Frequency": 74 - }, - { - "Time": 41, - "Intensity": 0.28, - "Frequency": 75 - }, - { - "Time": 62, - "Intensity": 0.31, - "Frequency": 74 - }, - { - "Time": 79, - "Intensity": 0.23, - "Frequency": 73 - }, - { - "Time": 107, - "Intensity": 0.14, - "Frequency": 72 - }, - { - "Time": 128, - "Intensity": 0.12, - "Frequency": 73 - }, - { - "Time": 142, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 159, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 177, - "Intensity": 0.08, - "Frequency": 75 - }, - { - "Time": 202, - "Intensity": 0.05, - "Frequency": 74 - }, - { - "Time": 217, - "Intensity": 0.03, - "Frequency": 75 - }, - { - "Time": 231, - "Intensity": 0, - "Frequency": 74 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 280, - "Parameters": { - "Intensity": 60, - "Frequency": 45 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-09-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1, + "Parameters": { + "Intensity": 36, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 76 + }, + { + "Time": 33, + "Intensity": 0, + "Frequency": 76 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 69 + }, + { + "Time": 83, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 68 + }, + { + "Time": 117, + "Intensity": 0, + "Frequency": 73 + }, + { + "Time": 133, + "Intensity": 0, + "Frequency": 73 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 71 + }, + { + "Time": 167, + "Intensity": 0, + "Frequency": 69 + }, + { + "Time": 183, + "Intensity": 0, + "Frequency": 69 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 38 + }, + { + "Time": 221, + "Intensity": 0.22, + "Frequency": 34 + }, + { + "Time": 233, + "Intensity": 1, + "Frequency": 44 + }, + { + "Time": 238, + "Intensity": 1, + "Frequency": 40 + }, + { + "Time": 244, + "Intensity": 0.06, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 70 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 211, + "Parameters": { + "Intensity": 60, + "Frequency": 31 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 231, + "StartTime": 252, + "Parameters": { + "Intensity": 42, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 70 + }, + { + "Time": 16, + "Intensity": 0.17, + "Frequency": 70 + }, + { + "Time": 35, + "Intensity": 0.36, + "Frequency": 74 + }, + { + "Time": 41, + "Intensity": 0.28, + "Frequency": 75 + }, + { + "Time": 62, + "Intensity": 0.31, + "Frequency": 74 + }, + { + "Time": 79, + "Intensity": 0.23, + "Frequency": 73 + }, + { + "Time": 107, + "Intensity": 0.14, + "Frequency": 72 + }, + { + "Time": 128, + "Intensity": 0.12, + "Frequency": 73 + }, + { + "Time": 142, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 159, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 177, + "Intensity": 0.08, + "Frequency": 75 + }, + { + "Time": 202, + "Intensity": 0.05, + "Frequency": 74 + }, + { + "Time": 217, + "Intensity": 0.03, + "Frequency": 75 + }, + { + "Time": 231, + "Intensity": 0, + "Frequency": 74 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 280, + "Parameters": { + "Intensity": 60, + "Frequency": 45 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_m.json index f68a16f409..ee0c170cc6 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/M4_m.json @@ -1,213 +1,213 @@ -{ - "MetaData": { - "Create": "2022-09-26", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1, - "Parameters": { - "Intensity": 48, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 76 - }, - { - "Time": 33, - "Intensity": 0, - "Frequency": 76 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 69 - }, - { - "Time": 83, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 68 - }, - { - "Time": 117, - "Intensity": 0, - "Frequency": 73 - }, - { - "Time": 133, - "Intensity": 0, - "Frequency": 73 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 71 - }, - { - "Time": 167, - "Intensity": 0, - "Frequency": 69 - }, - { - "Time": 183, - "Intensity": 0, - "Frequency": 69 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 38 - }, - { - "Time": 221, - "Intensity": 0.22, - "Frequency": 34 - }, - { - "Time": 233, - "Intensity": 1, - "Frequency": 44 - }, - { - "Time": 238, - "Intensity": 1, - "Frequency": 40 - }, - { - "Time": 244, - "Intensity": 0.06, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 70 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 211, - "Parameters": { - "Intensity": 80, - "Frequency": 31 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 231, - "StartTime": 252, - "Parameters": { - "Intensity": 56, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 70 - }, - { - "Time": 16, - "Intensity": 0.17, - "Frequency": 70 - }, - { - "Time": 35, - "Intensity": 0.36, - "Frequency": 74 - }, - { - "Time": 41, - "Intensity": 0.28, - "Frequency": 75 - }, - { - "Time": 62, - "Intensity": 0.31, - "Frequency": 74 - }, - { - "Time": 79, - "Intensity": 0.23, - "Frequency": 73 - }, - { - "Time": 107, - "Intensity": 0.14, - "Frequency": 72 - }, - { - "Time": 128, - "Intensity": 0.12, - "Frequency": 73 - }, - { - "Time": 142, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 159, - "Intensity": 0.11, - "Frequency": 75 - }, - { - "Time": 177, - "Intensity": 0.08, - "Frequency": 75 - }, - { - "Time": 202, - "Intensity": 0.05, - "Frequency": 74 - }, - { - "Time": 217, - "Intensity": 0.03, - "Frequency": 75 - }, - { - "Time": 231, - "Intensity": 0, - "Frequency": 74 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 280, - "Parameters": { - "Intensity": 80, - "Frequency": 45 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-09-26", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1, + "Parameters": { + "Intensity": 48, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 76 + }, + { + "Time": 33, + "Intensity": 0, + "Frequency": 76 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 69 + }, + { + "Time": 83, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 68 + }, + { + "Time": 117, + "Intensity": 0, + "Frequency": 73 + }, + { + "Time": 133, + "Intensity": 0, + "Frequency": 73 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 71 + }, + { + "Time": 167, + "Intensity": 0, + "Frequency": 69 + }, + { + "Time": 183, + "Intensity": 0, + "Frequency": 69 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 38 + }, + { + "Time": 221, + "Intensity": 0.22, + "Frequency": 34 + }, + { + "Time": 233, + "Intensity": 1, + "Frequency": 44 + }, + { + "Time": 238, + "Intensity": 1, + "Frequency": 40 + }, + { + "Time": 244, + "Intensity": 0.06, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 70 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 211, + "Parameters": { + "Intensity": 80, + "Frequency": 31 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 231, + "StartTime": 252, + "Parameters": { + "Intensity": 56, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 70 + }, + { + "Time": 16, + "Intensity": 0.17, + "Frequency": 70 + }, + { + "Time": 35, + "Intensity": 0.36, + "Frequency": 74 + }, + { + "Time": 41, + "Intensity": 0.28, + "Frequency": 75 + }, + { + "Time": 62, + "Intensity": 0.31, + "Frequency": 74 + }, + { + "Time": 79, + "Intensity": 0.23, + "Frequency": 73 + }, + { + "Time": 107, + "Intensity": 0.14, + "Frequency": 72 + }, + { + "Time": 128, + "Intensity": 0.12, + "Frequency": 73 + }, + { + "Time": 142, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 159, + "Intensity": 0.11, + "Frequency": 75 + }, + { + "Time": 177, + "Intensity": 0.08, + "Frequency": 75 + }, + { + "Time": 202, + "Intensity": 0.05, + "Frequency": 74 + }, + { + "Time": 217, + "Intensity": 0.03, + "Frequency": 75 + }, + { + "Time": 231, + "Intensity": 0, + "Frequency": 74 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 280, + "Parameters": { + "Intensity": 80, + "Frequency": 45 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_h.json index 39544face5..88eec903d3 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_h.json @@ -1,57 +1,57 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 396, - "Parameters": { - "Intensity": 50, - "Frequency": 8 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 443, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 493, - "Parameters": { - "Intensity": 56, - "Frequency": 82 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 524, - "Parameters": { - "Intensity": 41, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 396, + "Parameters": { + "Intensity": 50, + "Frequency": 8 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 443, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 493, + "Parameters": { + "Intensity": 56, + "Frequency": 82 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 524, + "Parameters": { + "Intensity": 41, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_l.json index aa1d05a876..67e8ae9114 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_l.json @@ -1,57 +1,57 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 396, - "Parameters": { - "Intensity": 30, - "Frequency": 8 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 443, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 493, - "Parameters": { - "Intensity": 33, - "Frequency": 82 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 524, - "Parameters": { - "Intensity": 24, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 396, + "Parameters": { + "Intensity": 30, + "Frequency": 8 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 443, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 493, + "Parameters": { + "Intensity": 33, + "Frequency": 82 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 524, + "Parameters": { + "Intensity": 24, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_m.json index 630995d608..426033da78 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/MP5_m.json @@ -1,57 +1,57 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 396, - "Parameters": { - "Intensity": 40, - "Frequency": 8 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 443, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 493, - "Parameters": { - "Intensity": 44, - "Frequency": 82 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 524, - "Parameters": { - "Intensity": 32, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 396, + "Parameters": { + "Intensity": 40, + "Frequency": 8 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 443, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 493, + "Parameters": { + "Intensity": 44, + "Frequency": 82 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 524, + "Parameters": { + "Intensity": 32, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_h.json index 7a6d292b4d..15fecdf097 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_h.json @@ -1,229 +1,229 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 12, - "Parameters": { - "Intensity": 85, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 10, - "Intensity": 0.76, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 35, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 154, - "Parameters": { - "Intensity": 81, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 583, - "Parameters": { - "Intensity": 83, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 8, - "Intensity": 0.8, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 34, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 690, - "Parameters": { - "Intensity": 80, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 1182, - "Parameters": { - "Intensity": 82, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 8, - "Intensity": 0.77, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 34, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 10 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1314, - "Parameters": { - "Intensity": 79, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 1786, - "Parameters": { - "Intensity": 72, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 9, - "Intensity": 0.83, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 34, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1911, - "Parameters": { - "Intensity": 79, - "Frequency": 35 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 12, + "Parameters": { + "Intensity": 85, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 10, + "Intensity": 0.76, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 35, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 154, + "Parameters": { + "Intensity": 81, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 583, + "Parameters": { + "Intensity": 83, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 8, + "Intensity": 0.8, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 34, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 690, + "Parameters": { + "Intensity": 80, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 1182, + "Parameters": { + "Intensity": 82, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 8, + "Intensity": 0.77, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 34, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 10 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1314, + "Parameters": { + "Intensity": 79, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 1786, + "Parameters": { + "Intensity": 72, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 9, + "Intensity": 0.83, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 34, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1911, + "Parameters": { + "Intensity": 79, + "Frequency": 35 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_l.json index 033a04d680..773886face 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_l.json @@ -1,229 +1,229 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 12, - "Parameters": { - "Intensity": 51, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 10, - "Intensity": 0.76, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 35, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 154, - "Parameters": { - "Intensity": 48, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 583, - "Parameters": { - "Intensity": 49, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 8, - "Intensity": 0.8, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 34, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 690, - "Parameters": { - "Intensity": 48, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 1182, - "Parameters": { - "Intensity": 49, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 8, - "Intensity": 0.77, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 34, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 10 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1314, - "Parameters": { - "Intensity": 47, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 1786, - "Parameters": { - "Intensity": 43, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 9, - "Intensity": 0.83, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 34, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1911, - "Parameters": { - "Intensity": 47, - "Frequency": 35 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 12, + "Parameters": { + "Intensity": 51, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 10, + "Intensity": 0.76, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 35, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 154, + "Parameters": { + "Intensity": 48, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 583, + "Parameters": { + "Intensity": 49, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 8, + "Intensity": 0.8, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 34, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 690, + "Parameters": { + "Intensity": 48, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 1182, + "Parameters": { + "Intensity": 49, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 8, + "Intensity": 0.77, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 34, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 10 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1314, + "Parameters": { + "Intensity": 47, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 1786, + "Parameters": { + "Intensity": 43, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 9, + "Intensity": 0.83, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 34, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1911, + "Parameters": { + "Intensity": 47, + "Frequency": 35 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_m.json index 5b4dac9562..ff5ca23f6b 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnCarpet_m.json @@ -1,229 +1,229 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 12, - "Parameters": { - "Intensity": 68, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 10, - "Intensity": 0.76, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 35, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 154, - "Parameters": { - "Intensity": 64, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 583, - "Parameters": { - "Intensity": 66, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 8, - "Intensity": 0.8, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 34, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 690, - "Parameters": { - "Intensity": 64, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 1182, - "Parameters": { - "Intensity": 65, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 8, - "Intensity": 0.77, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 34, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 10 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1314, - "Parameters": { - "Intensity": 63, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 74, - "StartTime": 1786, - "Parameters": { - "Intensity": 57, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 9, - "Intensity": 0.83, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 34, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 73, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1911, - "Parameters": { - "Intensity": 63, - "Frequency": 35 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 12, + "Parameters": { + "Intensity": 68, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 10, + "Intensity": 0.76, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 35, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 154, + "Parameters": { + "Intensity": 64, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 583, + "Parameters": { + "Intensity": 66, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 8, + "Intensity": 0.8, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 34, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 690, + "Parameters": { + "Intensity": 64, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 1182, + "Parameters": { + "Intensity": 65, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 8, + "Intensity": 0.77, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 34, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 10 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1314, + "Parameters": { + "Intensity": 63, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 74, + "StartTime": 1786, + "Parameters": { + "Intensity": 57, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 9, + "Intensity": 0.83, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 34, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 73, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1911, + "Parameters": { + "Intensity": 63, + "Frequency": 35 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_h.json index d57b5f5120..114f809680 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_h.json @@ -1,401 +1,401 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 6, - "Parameters": { - "Intensity": 100, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 82, - "Parameters": { - "Intensity": 71, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 50, - "StartTime": 303, - "Parameters": { - "Intensity": 100, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 23, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 27, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 48, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 375, - "Parameters": { - "Intensity": 64, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 50, - "StartTime": 601, - "Parameters": { - "Intensity": 100, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 23, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 27, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 48, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 675, - "Parameters": { - "Intensity": 70, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 898, - "Parameters": { - "Intensity": 100, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 980, - "Parameters": { - "Intensity": 74, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 6, + "Parameters": { + "Intensity": 100, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 82, + "Parameters": { + "Intensity": 71, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 50, + "StartTime": 303, + "Parameters": { + "Intensity": 100, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 23, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 27, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 48, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 375, + "Parameters": { + "Intensity": 64, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 50, + "StartTime": 601, + "Parameters": { + "Intensity": 100, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 23, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 27, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 48, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 675, + "Parameters": { + "Intensity": 70, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 898, + "Parameters": { + "Intensity": 100, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 980, + "Parameters": { + "Intensity": 74, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_l.json index a5515897fd..17d3063002 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_l.json @@ -1,401 +1,401 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 6, - "Parameters": { - "Intensity": 60, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 82, - "Parameters": { - "Intensity": 42, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 50, - "StartTime": 303, - "Parameters": { - "Intensity": 60, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 23, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 27, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 48, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 375, - "Parameters": { - "Intensity": 38, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 50, - "StartTime": 601, - "Parameters": { - "Intensity": 60, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 23, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 27, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 48, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 675, - "Parameters": { - "Intensity": 42, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 898, - "Parameters": { - "Intensity": 60, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 980, - "Parameters": { - "Intensity": 44, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 6, + "Parameters": { + "Intensity": 60, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 82, + "Parameters": { + "Intensity": 42, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 50, + "StartTime": 303, + "Parameters": { + "Intensity": 60, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 23, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 27, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 48, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 375, + "Parameters": { + "Intensity": 38, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 50, + "StartTime": 601, + "Parameters": { + "Intensity": 60, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 23, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 27, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 48, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 675, + "Parameters": { + "Intensity": 42, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 898, + "Parameters": { + "Intensity": 60, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 980, + "Parameters": { + "Intensity": 44, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_m.json index 078945e6c2..b1a2f1b295 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnConcrete_m.json @@ -1,401 +1,401 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 6, - "Parameters": { - "Intensity": 80, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 82, - "Parameters": { - "Intensity": 56, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 50, - "StartTime": 303, - "Parameters": { - "Intensity": 80, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 23, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 27, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 48, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 375, - "Parameters": { - "Intensity": 51, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 50, - "StartTime": 601, - "Parameters": { - "Intensity": 80, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 23, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 27, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 48, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 675, - "Parameters": { - "Intensity": 56, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 898, - "Parameters": { - "Intensity": 80, - "Frequency": 40, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 56, - "StartTime": 980, - "Parameters": { - "Intensity": 59, - "Frequency": 42, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -10 - }, - { - "Time": 1, - "Intensity": 0.47, - "Frequency": -10 - }, - { - "Time": 10, - "Intensity": 1, - "Frequency": 8 - }, - { - "Time": 26, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 30, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 6, + "Parameters": { + "Intensity": 80, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 82, + "Parameters": { + "Intensity": 56, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 50, + "StartTime": 303, + "Parameters": { + "Intensity": 80, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 23, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 27, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 48, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 375, + "Parameters": { + "Intensity": 51, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 50, + "StartTime": 601, + "Parameters": { + "Intensity": 80, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 23, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 27, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 48, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 675, + "Parameters": { + "Intensity": 56, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 898, + "Parameters": { + "Intensity": 80, + "Frequency": 40, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 56, + "StartTime": 980, + "Parameters": { + "Intensity": 59, + "Frequency": 42, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -10 + }, + { + "Time": 1, + "Intensity": 0.47, + "Frequency": -10 + }, + { + "Time": 10, + "Intensity": 1, + "Frequency": 8 + }, + { + "Time": 26, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 30, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_h.json index e5671edb47..a19204f1a5 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_h.json @@ -1,518 +1,518 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 24, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 46, - "Parameters": { - "Intensity": 100, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 104, - "Parameters": { - "Intensity": 78, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 230, - "Intensity": 0.44, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 246, - "StartTime": 139, - "Parameters": { - "Intensity": 69, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 0.73, - "Frequency": 0 - }, - { - "Time": 101, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 177, - "Intensity": 0.22, - "Frequency": 36 - }, - { - "Time": 246, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 707, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 729, - "Parameters": { - "Intensity": 100, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 787, - "Parameters": { - "Intensity": 78, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 230, - "Intensity": 0.44, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 195, - "StartTime": 821, - "Parameters": { - "Intensity": 90, - "Frequency": 66, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 24, - "Intensity": 0.81, - "Frequency": 0 - }, - { - "Time": 97, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 159, - "Intensity": 0.3, - "Frequency": 36 - }, - { - "Time": 195, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1423, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 1445, - "Parameters": { - "Intensity": 100, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 1503, - "Parameters": { - "Intensity": 78, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 230, - "Intensity": 0.44, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 129, - "StartTime": 1538, - "Parameters": { - "Intensity": 69, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 11, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 52, - "Intensity": 0.71, - "Frequency": 0 - }, - { - "Time": 93, - "Intensity": 0.22, - "Frequency": 36 - }, - { - "Time": 129, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2109, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 2131, - "Parameters": { - "Intensity": 100, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 2178, - "Parameters": { - "Intensity": 78, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 222, - "Intensity": 0.42, - "Frequency": 0 - }, - { - "Time": 351, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 129, - "StartTime": 2224, - "Parameters": { - "Intensity": 69, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 11, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 52, - "Intensity": 0.71, - "Frequency": 0 - }, - { - "Time": 93, - "Intensity": 0.22, - "Frequency": 36 - }, - { - "Time": 129, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 24, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 46, + "Parameters": { + "Intensity": 100, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 104, + "Parameters": { + "Intensity": 78, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 230, + "Intensity": 0.44, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 246, + "StartTime": 139, + "Parameters": { + "Intensity": 69, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 0.73, + "Frequency": 0 + }, + { + "Time": 101, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 177, + "Intensity": 0.22, + "Frequency": 36 + }, + { + "Time": 246, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 707, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 729, + "Parameters": { + "Intensity": 100, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 787, + "Parameters": { + "Intensity": 78, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 230, + "Intensity": 0.44, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 195, + "StartTime": 821, + "Parameters": { + "Intensity": 90, + "Frequency": 66, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 24, + "Intensity": 0.81, + "Frequency": 0 + }, + { + "Time": 97, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 159, + "Intensity": 0.3, + "Frequency": 36 + }, + { + "Time": 195, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1423, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 1445, + "Parameters": { + "Intensity": 100, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 1503, + "Parameters": { + "Intensity": 78, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 230, + "Intensity": 0.44, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 129, + "StartTime": 1538, + "Parameters": { + "Intensity": 69, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 11, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 52, + "Intensity": 0.71, + "Frequency": 0 + }, + { + "Time": 93, + "Intensity": 0.22, + "Frequency": 36 + }, + { + "Time": 129, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2109, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 2131, + "Parameters": { + "Intensity": 100, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 2178, + "Parameters": { + "Intensity": 78, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 222, + "Intensity": 0.42, + "Frequency": 0 + }, + { + "Time": 351, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 129, + "StartTime": 2224, + "Parameters": { + "Intensity": 69, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 11, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 52, + "Intensity": 0.71, + "Frequency": 0 + }, + { + "Time": 93, + "Intensity": 0.22, + "Frequency": 36 + }, + { + "Time": 129, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_l.json index d4d7ec6256..a503164900 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_l.json @@ -1,518 +1,518 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 24, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 46, - "Parameters": { - "Intensity": 60, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 104, - "Parameters": { - "Intensity": 46, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 230, - "Intensity": 0.44, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 246, - "StartTime": 139, - "Parameters": { - "Intensity": 41, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 0.73, - "Frequency": 0 - }, - { - "Time": 101, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 177, - "Intensity": 0.22, - "Frequency": 36 - }, - { - "Time": 246, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 707, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 729, - "Parameters": { - "Intensity": 60, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 787, - "Parameters": { - "Intensity": 46, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 230, - "Intensity": 0.44, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 195, - "StartTime": 821, - "Parameters": { - "Intensity": 54, - "Frequency": 66, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 24, - "Intensity": 0.81, - "Frequency": 0 - }, - { - "Time": 97, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 159, - "Intensity": 0.3, - "Frequency": 36 - }, - { - "Time": 195, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1423, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 1445, - "Parameters": { - "Intensity": 60, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 1503, - "Parameters": { - "Intensity": 46, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 230, - "Intensity": 0.44, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 129, - "StartTime": 1538, - "Parameters": { - "Intensity": 41, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 11, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 52, - "Intensity": 0.71, - "Frequency": 0 - }, - { - "Time": 93, - "Intensity": 0.22, - "Frequency": 36 - }, - { - "Time": 129, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2109, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 2131, - "Parameters": { - "Intensity": 60, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 2178, - "Parameters": { - "Intensity": 46, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 222, - "Intensity": 0.42, - "Frequency": 0 - }, - { - "Time": 351, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 129, - "StartTime": 2224, - "Parameters": { - "Intensity": 41, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 11, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 52, - "Intensity": 0.71, - "Frequency": 0 - }, - { - "Time": 93, - "Intensity": 0.22, - "Frequency": 36 - }, - { - "Time": 129, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 24, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 46, + "Parameters": { + "Intensity": 60, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 104, + "Parameters": { + "Intensity": 46, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 230, + "Intensity": 0.44, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 246, + "StartTime": 139, + "Parameters": { + "Intensity": 41, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 0.73, + "Frequency": 0 + }, + { + "Time": 101, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 177, + "Intensity": 0.22, + "Frequency": 36 + }, + { + "Time": 246, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 707, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 729, + "Parameters": { + "Intensity": 60, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 787, + "Parameters": { + "Intensity": 46, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 230, + "Intensity": 0.44, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 195, + "StartTime": 821, + "Parameters": { + "Intensity": 54, + "Frequency": 66, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 24, + "Intensity": 0.81, + "Frequency": 0 + }, + { + "Time": 97, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 159, + "Intensity": 0.3, + "Frequency": 36 + }, + { + "Time": 195, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1423, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 1445, + "Parameters": { + "Intensity": 60, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 1503, + "Parameters": { + "Intensity": 46, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 230, + "Intensity": 0.44, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 129, + "StartTime": 1538, + "Parameters": { + "Intensity": 41, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 11, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 52, + "Intensity": 0.71, + "Frequency": 0 + }, + { + "Time": 93, + "Intensity": 0.22, + "Frequency": 36 + }, + { + "Time": 129, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2109, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 2131, + "Parameters": { + "Intensity": 60, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 2178, + "Parameters": { + "Intensity": 46, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 222, + "Intensity": 0.42, + "Frequency": 0 + }, + { + "Time": 351, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 129, + "StartTime": 2224, + "Parameters": { + "Intensity": 41, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 11, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 52, + "Intensity": 0.71, + "Frequency": 0 + }, + { + "Time": 93, + "Intensity": 0.22, + "Frequency": 36 + }, + { + "Time": 129, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_m.json index 3aafd27d55..cb2ebbb288 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGrass_m.json @@ -1,518 +1,518 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 24, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 46, - "Parameters": { - "Intensity": 80, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 104, - "Parameters": { - "Intensity": 62, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 230, - "Intensity": 0.44, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 246, - "StartTime": 139, - "Parameters": { - "Intensity": 55, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 0.73, - "Frequency": 0 - }, - { - "Time": 101, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 177, - "Intensity": 0.22, - "Frequency": 36 - }, - { - "Time": 246, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 707, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 729, - "Parameters": { - "Intensity": 80, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 787, - "Parameters": { - "Intensity": 62, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 230, - "Intensity": 0.44, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 195, - "StartTime": 821, - "Parameters": { - "Intensity": 72, - "Frequency": 66, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 24, - "Intensity": 0.81, - "Frequency": 0 - }, - { - "Time": 97, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 159, - "Intensity": 0.3, - "Frequency": 36 - }, - { - "Time": 195, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1423, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 1445, - "Parameters": { - "Intensity": 80, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 1503, - "Parameters": { - "Intensity": 62, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 230, - "Intensity": 0.44, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 129, - "StartTime": 1538, - "Parameters": { - "Intensity": 55, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 11, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 52, - "Intensity": 0.71, - "Frequency": 0 - }, - { - "Time": 93, - "Intensity": 0.22, - "Frequency": 36 - }, - { - "Time": 129, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2109, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 68, - "StartTime": 2131, - "Parameters": { - "Intensity": 80, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 43, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 56, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 68, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 397, - "StartTime": 2178, - "Parameters": { - "Intensity": 62, - "Frequency": 15, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 122, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 222, - "Intensity": 0.42, - "Frequency": 0 - }, - { - "Time": 351, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 397, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 129, - "StartTime": 2224, - "Parameters": { - "Intensity": 55, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 11, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 52, - "Intensity": 0.71, - "Frequency": 0 - }, - { - "Time": 93, - "Intensity": 0.22, - "Frequency": 36 - }, - { - "Time": 129, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 24, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 46, + "Parameters": { + "Intensity": 80, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 104, + "Parameters": { + "Intensity": 62, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 230, + "Intensity": 0.44, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 246, + "StartTime": 139, + "Parameters": { + "Intensity": 55, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 0.73, + "Frequency": 0 + }, + { + "Time": 101, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 177, + "Intensity": 0.22, + "Frequency": 36 + }, + { + "Time": 246, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 707, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 729, + "Parameters": { + "Intensity": 80, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 787, + "Parameters": { + "Intensity": 62, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 230, + "Intensity": 0.44, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 195, + "StartTime": 821, + "Parameters": { + "Intensity": 72, + "Frequency": 66, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 24, + "Intensity": 0.81, + "Frequency": 0 + }, + { + "Time": 97, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 159, + "Intensity": 0.3, + "Frequency": 36 + }, + { + "Time": 195, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1423, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 1445, + "Parameters": { + "Intensity": 80, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 1503, + "Parameters": { + "Intensity": 62, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 230, + "Intensity": 0.44, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 129, + "StartTime": 1538, + "Parameters": { + "Intensity": 55, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 11, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 52, + "Intensity": 0.71, + "Frequency": 0 + }, + { + "Time": 93, + "Intensity": 0.22, + "Frequency": 36 + }, + { + "Time": 129, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2109, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 68, + "StartTime": 2131, + "Parameters": { + "Intensity": 80, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 43, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 56, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 68, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 397, + "StartTime": 2178, + "Parameters": { + "Intensity": 62, + "Frequency": 15, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 122, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 222, + "Intensity": 0.42, + "Frequency": 0 + }, + { + "Time": 351, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 397, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 129, + "StartTime": 2224, + "Parameters": { + "Intensity": 55, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 11, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 52, + "Intensity": 0.71, + "Frequency": 0 + }, + { + "Time": 93, + "Intensity": 0.22, + "Frequency": 36 + }, + { + "Time": 129, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_h.json index f25a3ee6da..dbecb953f7 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_h.json @@ -1,585 +1,585 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 39, - "Parameters": { - "Intensity": 100, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 75, - "Parameters": { - "Intensity": 93, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 346, - "Parameters": { - "Intensity": 100, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 371, - "Parameters": { - "Intensity": 89, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 620, - "Parameters": { - "Intensity": 100, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 649, - "Parameters": { - "Intensity": 89, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 888, - "Parameters": { - "Intensity": 100, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 896, - "Parameters": { - "Intensity": 89, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1163, - "Parameters": { - "Intensity": 100, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1204, - "Parameters": { - "Intensity": 89, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1430, - "Parameters": { - "Intensity": 100, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1471, - "Parameters": { - "Intensity": 89, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1685, - "Parameters": { - "Intensity": 100, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1718, - "Parameters": { - "Intensity": 89, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1957, - "Parameters": { - "Intensity": 100, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1988, - "Parameters": { - "Intensity": 89, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 39, + "Parameters": { + "Intensity": 100, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 75, + "Parameters": { + "Intensity": 93, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 346, + "Parameters": { + "Intensity": 100, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 371, + "Parameters": { + "Intensity": 89, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 620, + "Parameters": { + "Intensity": 100, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 649, + "Parameters": { + "Intensity": 89, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 888, + "Parameters": { + "Intensity": 100, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 896, + "Parameters": { + "Intensity": 89, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1163, + "Parameters": { + "Intensity": 100, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1204, + "Parameters": { + "Intensity": 89, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1430, + "Parameters": { + "Intensity": 100, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1471, + "Parameters": { + "Intensity": 89, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1685, + "Parameters": { + "Intensity": 100, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1718, + "Parameters": { + "Intensity": 89, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1957, + "Parameters": { + "Intensity": 100, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1988, + "Parameters": { + "Intensity": 89, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_l.json index 5f8019d713..6a78d78925 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_l.json @@ -1,585 +1,585 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 39, - "Parameters": { - "Intensity": 60, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 75, - "Parameters": { - "Intensity": 55, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 346, - "Parameters": { - "Intensity": 60, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 371, - "Parameters": { - "Intensity": 53, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 620, - "Parameters": { - "Intensity": 60, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 649, - "Parameters": { - "Intensity": 53, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 888, - "Parameters": { - "Intensity": 60, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 896, - "Parameters": { - "Intensity": 53, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1163, - "Parameters": { - "Intensity": 60, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1204, - "Parameters": { - "Intensity": 53, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1430, - "Parameters": { - "Intensity": 60, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1471, - "Parameters": { - "Intensity": 53, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1685, - "Parameters": { - "Intensity": 60, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1718, - "Parameters": { - "Intensity": 53, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1957, - "Parameters": { - "Intensity": 60, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1988, - "Parameters": { - "Intensity": 53, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 39, + "Parameters": { + "Intensity": 60, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 75, + "Parameters": { + "Intensity": 55, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 346, + "Parameters": { + "Intensity": 60, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 371, + "Parameters": { + "Intensity": 53, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 620, + "Parameters": { + "Intensity": 60, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 649, + "Parameters": { + "Intensity": 53, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 888, + "Parameters": { + "Intensity": 60, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 896, + "Parameters": { + "Intensity": 53, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1163, + "Parameters": { + "Intensity": 60, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1204, + "Parameters": { + "Intensity": 53, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1430, + "Parameters": { + "Intensity": 60, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1471, + "Parameters": { + "Intensity": 53, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1685, + "Parameters": { + "Intensity": 60, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1718, + "Parameters": { + "Intensity": 53, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1957, + "Parameters": { + "Intensity": 60, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1988, + "Parameters": { + "Intensity": 53, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_m.json index b7e8171ec0..ecfaa84bc9 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnGravel_m.json @@ -1,585 +1,585 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 39, - "Parameters": { - "Intensity": 80, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 75, - "Parameters": { - "Intensity": 74, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 346, - "Parameters": { - "Intensity": 80, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 371, - "Parameters": { - "Intensity": 71, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 620, - "Parameters": { - "Intensity": 80, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 649, - "Parameters": { - "Intensity": 71, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 888, - "Parameters": { - "Intensity": 80, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 896, - "Parameters": { - "Intensity": 71, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1163, - "Parameters": { - "Intensity": 80, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1204, - "Parameters": { - "Intensity": 71, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1430, - "Parameters": { - "Intensity": 80, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1471, - "Parameters": { - "Intensity": 71, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1685, - "Parameters": { - "Intensity": 80, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1718, - "Parameters": { - "Intensity": 71, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 1957, - "Parameters": { - "Intensity": 80, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 87, - "Intensity": 0.74, - "Frequency": 0 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 136, - "StartTime": 1988, - "Parameters": { - "Intensity": 71, - "Frequency": 25, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 18 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 13 - }, - { - "Time": 83, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 136, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 39, + "Parameters": { + "Intensity": 80, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 75, + "Parameters": { + "Intensity": 74, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 346, + "Parameters": { + "Intensity": 80, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 371, + "Parameters": { + "Intensity": 71, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 620, + "Parameters": { + "Intensity": 80, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 649, + "Parameters": { + "Intensity": 71, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 888, + "Parameters": { + "Intensity": 80, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 896, + "Parameters": { + "Intensity": 71, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1163, + "Parameters": { + "Intensity": 80, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1204, + "Parameters": { + "Intensity": 71, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1430, + "Parameters": { + "Intensity": 80, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1471, + "Parameters": { + "Intensity": 71, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1685, + "Parameters": { + "Intensity": 80, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1718, + "Parameters": { + "Intensity": 71, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 1957, + "Parameters": { + "Intensity": 80, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 87, + "Intensity": 0.74, + "Frequency": 0 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 136, + "StartTime": 1988, + "Parameters": { + "Intensity": 71, + "Frequency": 25, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 18 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 13 + }, + { + "Time": 83, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 136, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_h.json index e9ac8ed0a9..9f2f11e157 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_h.json @@ -1,369 +1,369 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 48, - "Parameters": { - "Intensity": 88, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 39, - "Intensity": 0.65, - "Frequency": 40 - }, - { - "Time": 127, - "Intensity": 0.97, - "Frequency": 30 - }, - { - "Time": 147, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 211, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 280, - "Intensity": 0.61, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 396, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 469, - "Intensity": 0.44, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 596, - "Intensity": 0.1, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 143, - "Parameters": { - "Intensity": 100, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 853, - "StartTime": 1130, - "Parameters": { - "Intensity": 84, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 47, - "Intensity": 0.71, - "Frequency": 40 - }, - { - "Time": 178, - "Intensity": 0.95, - "Frequency": 30 - }, - { - "Time": 188, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 236, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 327, - "Intensity": 0.6, - "Frequency": 10 - }, - { - "Time": 439, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 524, - "Intensity": 0.23, - "Frequency": 0 - }, - { - "Time": 586, - "Intensity": 0.48, - "Frequency": 10 - }, - { - "Time": 676, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 785, - "Intensity": 0.07, - "Frequency": 10 - }, - { - "Time": 853, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1274, - "Parameters": { - "Intensity": 100, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 2446, - "Parameters": { - "Intensity": 89, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 24, - "Intensity": 0.81, - "Frequency": 40 - }, - { - "Time": 66, - "Intensity": 0.97, - "Frequency": 30 - }, - { - "Time": 101, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 248, - "Intensity": 0.6, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 490, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2525, - "Parameters": { - "Intensity": 100, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2860, - "Parameters": { - "Intensity": 67, - "Frequency": 12 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 3685, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 24, - "Intensity": 0.81, - "Frequency": 40 - }, - { - "Time": 66, - "Intensity": 0.97, - "Frequency": 30 - }, - { - "Time": 101, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 247, - "Intensity": 0.6, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.49, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3780, - "Parameters": { - "Intensity": 100, - "Frequency": 29 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4143, - "Parameters": { - "Intensity": 59, - "Frequency": 16 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 48, + "Parameters": { + "Intensity": 88, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 39, + "Intensity": 0.65, + "Frequency": 40 + }, + { + "Time": 127, + "Intensity": 0.97, + "Frequency": 30 + }, + { + "Time": 147, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 211, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 280, + "Intensity": 0.61, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 396, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 469, + "Intensity": 0.44, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 596, + "Intensity": 0.1, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 143, + "Parameters": { + "Intensity": 100, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 853, + "StartTime": 1130, + "Parameters": { + "Intensity": 84, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 47, + "Intensity": 0.71, + "Frequency": 40 + }, + { + "Time": 178, + "Intensity": 0.95, + "Frequency": 30 + }, + { + "Time": 188, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 236, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 327, + "Intensity": 0.6, + "Frequency": 10 + }, + { + "Time": 439, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 524, + "Intensity": 0.23, + "Frequency": 0 + }, + { + "Time": 586, + "Intensity": 0.48, + "Frequency": 10 + }, + { + "Time": 676, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 785, + "Intensity": 0.07, + "Frequency": 10 + }, + { + "Time": 853, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1274, + "Parameters": { + "Intensity": 100, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 2446, + "Parameters": { + "Intensity": 89, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 24, + "Intensity": 0.81, + "Frequency": 40 + }, + { + "Time": 66, + "Intensity": 0.97, + "Frequency": 30 + }, + { + "Time": 101, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 248, + "Intensity": 0.6, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 490, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2525, + "Parameters": { + "Intensity": 100, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2860, + "Parameters": { + "Intensity": 67, + "Frequency": 12 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 3685, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 24, + "Intensity": 0.81, + "Frequency": 40 + }, + { + "Time": 66, + "Intensity": 0.97, + "Frequency": 30 + }, + { + "Time": 101, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 247, + "Intensity": 0.6, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.49, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3780, + "Parameters": { + "Intensity": 100, + "Frequency": 29 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4143, + "Parameters": { + "Intensity": 59, + "Frequency": 16 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_l.json index aeec0b1057..1891aca832 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_l.json @@ -1,369 +1,369 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 48, - "Parameters": { - "Intensity": 52, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 39, - "Intensity": 0.65, - "Frequency": 40 - }, - { - "Time": 127, - "Intensity": 0.97, - "Frequency": 30 - }, - { - "Time": 147, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 211, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 280, - "Intensity": 0.61, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 396, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 469, - "Intensity": 0.44, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 596, - "Intensity": 0.1, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 143, - "Parameters": { - "Intensity": 60, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 853, - "StartTime": 1130, - "Parameters": { - "Intensity": 50, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 47, - "Intensity": 0.71, - "Frequency": 40 - }, - { - "Time": 178, - "Intensity": 0.95, - "Frequency": 30 - }, - { - "Time": 188, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 236, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 327, - "Intensity": 0.6, - "Frequency": 10 - }, - { - "Time": 439, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 524, - "Intensity": 0.23, - "Frequency": 0 - }, - { - "Time": 586, - "Intensity": 0.48, - "Frequency": 10 - }, - { - "Time": 676, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 785, - "Intensity": 0.07, - "Frequency": 10 - }, - { - "Time": 853, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1274, - "Parameters": { - "Intensity": 60, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 2446, - "Parameters": { - "Intensity": 53, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 24, - "Intensity": 0.81, - "Frequency": 40 - }, - { - "Time": 66, - "Intensity": 0.97, - "Frequency": 30 - }, - { - "Time": 101, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 248, - "Intensity": 0.6, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 490, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2525, - "Parameters": { - "Intensity": 60, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2860, - "Parameters": { - "Intensity": 40, - "Frequency": 12 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 3685, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 24, - "Intensity": 0.81, - "Frequency": 40 - }, - { - "Time": 66, - "Intensity": 0.97, - "Frequency": 30 - }, - { - "Time": 101, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 247, - "Intensity": 0.6, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.49, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3780, - "Parameters": { - "Intensity": 60, - "Frequency": 29 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4143, - "Parameters": { - "Intensity": 35, - "Frequency": 16 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 48, + "Parameters": { + "Intensity": 52, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 39, + "Intensity": 0.65, + "Frequency": 40 + }, + { + "Time": 127, + "Intensity": 0.97, + "Frequency": 30 + }, + { + "Time": 147, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 211, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 280, + "Intensity": 0.61, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 396, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 469, + "Intensity": 0.44, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 596, + "Intensity": 0.1, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 143, + "Parameters": { + "Intensity": 60, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 853, + "StartTime": 1130, + "Parameters": { + "Intensity": 50, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 47, + "Intensity": 0.71, + "Frequency": 40 + }, + { + "Time": 178, + "Intensity": 0.95, + "Frequency": 30 + }, + { + "Time": 188, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 236, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 327, + "Intensity": 0.6, + "Frequency": 10 + }, + { + "Time": 439, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 524, + "Intensity": 0.23, + "Frequency": 0 + }, + { + "Time": 586, + "Intensity": 0.48, + "Frequency": 10 + }, + { + "Time": 676, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 785, + "Intensity": 0.07, + "Frequency": 10 + }, + { + "Time": 853, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1274, + "Parameters": { + "Intensity": 60, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 2446, + "Parameters": { + "Intensity": 53, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 24, + "Intensity": 0.81, + "Frequency": 40 + }, + { + "Time": 66, + "Intensity": 0.97, + "Frequency": 30 + }, + { + "Time": 101, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 248, + "Intensity": 0.6, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 490, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2525, + "Parameters": { + "Intensity": 60, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2860, + "Parameters": { + "Intensity": 40, + "Frequency": 12 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 3685, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 24, + "Intensity": 0.81, + "Frequency": 40 + }, + { + "Time": 66, + "Intensity": 0.97, + "Frequency": 30 + }, + { + "Time": 101, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 247, + "Intensity": 0.6, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.49, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3780, + "Parameters": { + "Intensity": 60, + "Frequency": 29 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4143, + "Parameters": { + "Intensity": 35, + "Frequency": 16 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_m.json index c61f6153e1..6058bd02d2 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnMud_m.json @@ -1,369 +1,369 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 48, - "Parameters": { - "Intensity": 70, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 39, - "Intensity": 0.65, - "Frequency": 40 - }, - { - "Time": 127, - "Intensity": 0.97, - "Frequency": 30 - }, - { - "Time": 147, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 211, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 280, - "Intensity": 0.61, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 396, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 469, - "Intensity": 0.44, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 596, - "Intensity": 0.1, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 143, - "Parameters": { - "Intensity": 80, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 853, - "StartTime": 1130, - "Parameters": { - "Intensity": 67, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 47, - "Intensity": 0.71, - "Frequency": 40 - }, - { - "Time": 178, - "Intensity": 0.95, - "Frequency": 30 - }, - { - "Time": 188, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 236, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 327, - "Intensity": 0.6, - "Frequency": 10 - }, - { - "Time": 439, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 524, - "Intensity": 0.23, - "Frequency": 0 - }, - { - "Time": 586, - "Intensity": 0.48, - "Frequency": 10 - }, - { - "Time": 676, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 785, - "Intensity": 0.07, - "Frequency": 10 - }, - { - "Time": 853, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1274, - "Parameters": { - "Intensity": 80, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 2446, - "Parameters": { - "Intensity": 71, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 24, - "Intensity": 0.81, - "Frequency": 40 - }, - { - "Time": 66, - "Intensity": 0.97, - "Frequency": 30 - }, - { - "Time": 101, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 248, - "Intensity": 0.6, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 490, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2525, - "Parameters": { - "Intensity": 80, - "Frequency": 45 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2860, - "Parameters": { - "Intensity": 53, - "Frequency": 12 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 3685, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 24, - "Intensity": 0.81, - "Frequency": 40 - }, - { - "Time": 66, - "Intensity": 0.97, - "Frequency": 30 - }, - { - "Time": 101, - "Intensity": 0.36, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 247, - "Intensity": 0.6, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.49, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3780, - "Parameters": { - "Intensity": 80, - "Frequency": 29 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4143, - "Parameters": { - "Intensity": 47, - "Frequency": 16 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 48, + "Parameters": { + "Intensity": 70, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 39, + "Intensity": 0.65, + "Frequency": 40 + }, + { + "Time": 127, + "Intensity": 0.97, + "Frequency": 30 + }, + { + "Time": 147, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 211, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 280, + "Intensity": 0.61, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 396, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 469, + "Intensity": 0.44, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 596, + "Intensity": 0.1, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 143, + "Parameters": { + "Intensity": 80, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 853, + "StartTime": 1130, + "Parameters": { + "Intensity": 67, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 47, + "Intensity": 0.71, + "Frequency": 40 + }, + { + "Time": 178, + "Intensity": 0.95, + "Frequency": 30 + }, + { + "Time": 188, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 236, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 327, + "Intensity": 0.6, + "Frequency": 10 + }, + { + "Time": 439, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 524, + "Intensity": 0.23, + "Frequency": 0 + }, + { + "Time": 586, + "Intensity": 0.48, + "Frequency": 10 + }, + { + "Time": 676, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 785, + "Intensity": 0.07, + "Frequency": 10 + }, + { + "Time": 853, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1274, + "Parameters": { + "Intensity": 80, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 2446, + "Parameters": { + "Intensity": 71, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 24, + "Intensity": 0.81, + "Frequency": 40 + }, + { + "Time": 66, + "Intensity": 0.97, + "Frequency": 30 + }, + { + "Time": 101, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 248, + "Intensity": 0.6, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 490, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2525, + "Parameters": { + "Intensity": 80, + "Frequency": 45 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2860, + "Parameters": { + "Intensity": 53, + "Frequency": 12 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 3685, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 24, + "Intensity": 0.81, + "Frequency": 40 + }, + { + "Time": 66, + "Intensity": 0.97, + "Frequency": 30 + }, + { + "Time": 101, + "Intensity": 0.36, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 247, + "Intensity": 0.6, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.49, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3780, + "Parameters": { + "Intensity": 80, + "Frequency": 29 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4143, + "Parameters": { + "Intensity": 47, + "Frequency": 16 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_h.json index 6eea0b9f40..80445048a1 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_h.json @@ -1,1053 +1,1053 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 175, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 134, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 310, - "Parameters": { - "Intensity": 76, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 562, - "Parameters": { - "Intensity": 66, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 1332, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 146, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1467, - "Parameters": { - "Intensity": 76, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1719, - "Parameters": { - "Intensity": 68, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 2863, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 134, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2998, - "Parameters": { - "Intensity": 76, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3250, - "Parameters": { - "Intensity": 66, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 4014, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 120, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4149, - "Parameters": { - "Intensity": 76, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4401, - "Parameters": { - "Intensity": 69, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 175, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 134, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 310, + "Parameters": { + "Intensity": 76, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 562, + "Parameters": { + "Intensity": 66, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 1332, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 146, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1467, + "Parameters": { + "Intensity": 76, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1719, + "Parameters": { + "Intensity": 68, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 2863, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 134, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2998, + "Parameters": { + "Intensity": 76, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3250, + "Parameters": { + "Intensity": 66, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 4014, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 120, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4149, + "Parameters": { + "Intensity": 76, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4401, + "Parameters": { + "Intensity": 69, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_l.json index 7af23f77b3..ca863918a1 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_l.json @@ -1,1053 +1,1053 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 175, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 134, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 310, - "Parameters": { - "Intensity": 45, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 562, - "Parameters": { - "Intensity": 39, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 1332, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 146, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1467, - "Parameters": { - "Intensity": 45, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1719, - "Parameters": { - "Intensity": 40, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 2863, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 134, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2998, - "Parameters": { - "Intensity": 45, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3250, - "Parameters": { - "Intensity": 39, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 4014, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 120, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4149, - "Parameters": { - "Intensity": 45, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4401, - "Parameters": { - "Intensity": 41, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 175, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 134, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 310, + "Parameters": { + "Intensity": 45, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 562, + "Parameters": { + "Intensity": 39, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 1332, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 146, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1467, + "Parameters": { + "Intensity": 45, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1719, + "Parameters": { + "Intensity": 40, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 2863, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 134, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2998, + "Parameters": { + "Intensity": 45, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3250, + "Parameters": { + "Intensity": 39, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 4014, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 120, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4149, + "Parameters": { + "Intensity": 45, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4401, + "Parameters": { + "Intensity": 41, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_m.json index a64fb59250..5afeddc1a5 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnSnow_m.json @@ -1,1053 +1,1053 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 175, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 134, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 310, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 562, - "Parameters": { - "Intensity": 52, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 1332, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 146, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1467, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1719, - "Parameters": { - "Intensity": 54, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 2863, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 134, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2998, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3250, - "Parameters": { - "Intensity": 52, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 653, - "StartTime": 4014, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 20, - "Intensity": 0.82, - "Frequency": 40 - }, - { - "Time": 92, - "Intensity": 0.96, - "Frequency": 30 - }, - { - "Time": 120, - "Intensity": 0.41, - "Frequency": 10 - }, - { - "Time": 181, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 253, - "Intensity": 0.38, - "Frequency": 10 - }, - { - "Time": 337, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 439, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 494, - "Intensity": 0.28, - "Frequency": 10 - }, - { - "Time": 555, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 621, - "Intensity": 0.12, - "Frequency": 10 - }, - { - "Time": 653, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4149, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 66 - }, - { - "Time": 17, - "Intensity": 0.38, - "Frequency": 68 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 71 - }, - { - "Time": 48, - "Intensity": 0.57, - "Frequency": 70 - }, - { - "Time": 59, - "Intensity": 0.43, - "Frequency": 69 - }, - { - "Time": 67, - "Intensity": 0.2, - "Frequency": 70 - }, - { - "Time": 83, - "Intensity": 0.4, - "Frequency": 69 - }, - { - "Time": 102, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 125, - "Intensity": 0.34, - "Frequency": 66 - }, - { - "Time": 150, - "Intensity": 0.58, - "Frequency": 68 - }, - { - "Time": 167, - "Intensity": 0.71, - "Frequency": 70 - }, - { - "Time": 183, - "Intensity": 0.45, - "Frequency": 64 - }, - { - "Time": 212, - "Intensity": 0.3, - "Frequency": 59 - }, - { - "Time": 233, - "Intensity": 0.53, - "Frequency": 57 - }, - { - "Time": 240, - "Intensity": 0.2, - "Frequency": 60 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 62 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4401, - "Parameters": { - "Intensity": 55, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 60 - }, - { - "Time": 10, - "Intensity": 0.43, - "Frequency": 62 - }, - { - "Time": 36, - "Intensity": 0.74, - "Frequency": 64 - }, - { - "Time": 49, - "Intensity": 0.35, - "Frequency": 62 - }, - { - "Time": 67, - "Intensity": 0.21, - "Frequency": 64 - }, - { - "Time": 80, - "Intensity": 0.66, - "Frequency": 61 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 67 - }, - { - "Time": 117, - "Intensity": 0.63, - "Frequency": 67 - }, - { - "Time": 134, - "Intensity": 0.07, - "Frequency": 72 - }, - { - "Time": 150, - "Intensity": 0.66, - "Frequency": 72 - }, - { - "Time": 164, - "Intensity": 0.37, - "Frequency": 70 - }, - { - "Time": 184, - "Intensity": 0.07, - "Frequency": 70 - }, - { - "Time": 200, - "Intensity": 0.3, - "Frequency": 66 - }, - { - "Time": 213, - "Intensity": 0.59, - "Frequency": 66 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 61 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 63 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 175, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 134, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 310, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 562, + "Parameters": { + "Intensity": 52, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 1332, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 146, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1467, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1719, + "Parameters": { + "Intensity": 54, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 2863, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 134, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2998, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3250, + "Parameters": { + "Intensity": 52, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 653, + "StartTime": 4014, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 20, + "Intensity": 0.82, + "Frequency": 40 + }, + { + "Time": 92, + "Intensity": 0.96, + "Frequency": 30 + }, + { + "Time": 120, + "Intensity": 0.41, + "Frequency": 10 + }, + { + "Time": 181, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 253, + "Intensity": 0.38, + "Frequency": 10 + }, + { + "Time": 337, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 439, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 494, + "Intensity": 0.28, + "Frequency": 10 + }, + { + "Time": 555, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 621, + "Intensity": 0.12, + "Frequency": 10 + }, + { + "Time": 653, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4149, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 66 + }, + { + "Time": 17, + "Intensity": 0.38, + "Frequency": 68 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 71 + }, + { + "Time": 48, + "Intensity": 0.57, + "Frequency": 70 + }, + { + "Time": 59, + "Intensity": 0.43, + "Frequency": 69 + }, + { + "Time": 67, + "Intensity": 0.2, + "Frequency": 70 + }, + { + "Time": 83, + "Intensity": 0.4, + "Frequency": 69 + }, + { + "Time": 102, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 125, + "Intensity": 0.34, + "Frequency": 66 + }, + { + "Time": 150, + "Intensity": 0.58, + "Frequency": 68 + }, + { + "Time": 167, + "Intensity": 0.71, + "Frequency": 70 + }, + { + "Time": 183, + "Intensity": 0.45, + "Frequency": 64 + }, + { + "Time": 212, + "Intensity": 0.3, + "Frequency": 59 + }, + { + "Time": 233, + "Intensity": 0.53, + "Frequency": 57 + }, + { + "Time": 240, + "Intensity": 0.2, + "Frequency": 60 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 62 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4401, + "Parameters": { + "Intensity": 55, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 60 + }, + { + "Time": 10, + "Intensity": 0.43, + "Frequency": 62 + }, + { + "Time": 36, + "Intensity": 0.74, + "Frequency": 64 + }, + { + "Time": 49, + "Intensity": 0.35, + "Frequency": 62 + }, + { + "Time": 67, + "Intensity": 0.21, + "Frequency": 64 + }, + { + "Time": 80, + "Intensity": 0.66, + "Frequency": 61 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 67 + }, + { + "Time": 117, + "Intensity": 0.63, + "Frequency": 67 + }, + { + "Time": 134, + "Intensity": 0.07, + "Frequency": 72 + }, + { + "Time": 150, + "Intensity": 0.66, + "Frequency": 72 + }, + { + "Time": 164, + "Intensity": 0.37, + "Frequency": 70 + }, + { + "Time": 184, + "Intensity": 0.07, + "Frequency": 70 + }, + { + "Time": 200, + "Intensity": 0.3, + "Frequency": 66 + }, + { + "Time": 213, + "Intensity": 0.59, + "Frequency": 66 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 61 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 63 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_h.json index 3d6ceaeaa8..5434fa92e9 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_h.json @@ -1,229 +1,229 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 14, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 122, - "Parameters": { - "Intensity": 100, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 897, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 1040, - "Parameters": { - "Intensity": 100, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1565, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 1680, - "Parameters": { - "Intensity": 100, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2313, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 2440, - "Parameters": { - "Intensity": 100, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 14, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 122, + "Parameters": { + "Intensity": 100, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 897, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 1040, + "Parameters": { + "Intensity": 100, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1565, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 1680, + "Parameters": { + "Intensity": 100, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2313, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 2440, + "Parameters": { + "Intensity": 100, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_l.json index 5c431634ce..4c3d771f75 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_l.json @@ -1,229 +1,229 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 14, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 122, - "Parameters": { - "Intensity": 60, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 897, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 1040, - "Parameters": { - "Intensity": 60, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1565, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 1680, - "Parameters": { - "Intensity": 60, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2313, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 2440, - "Parameters": { - "Intensity": 60, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 14, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 122, + "Parameters": { + "Intensity": 60, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 897, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 1040, + "Parameters": { + "Intensity": 60, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1565, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 1680, + "Parameters": { + "Intensity": 60, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2313, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 2440, + "Parameters": { + "Intensity": 60, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_m.json index ad0fb12239..f3251a91a9 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/OnWood_m.json @@ -1,229 +1,229 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 14, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 122, - "Parameters": { - "Intensity": 80, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 897, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 1040, - "Parameters": { - "Intensity": 80, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1565, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 1680, - "Parameters": { - "Intensity": 80, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2313, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 2440, - "Parameters": { - "Intensity": 80, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 22, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 29, - "Intensity": 0.38, - "Frequency": -10 - }, - { - "Time": 61, - "Intensity": 0.13, - "Frequency": -30 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 14, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 122, + "Parameters": { + "Intensity": 80, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 897, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 1040, + "Parameters": { + "Intensity": 80, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1565, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 1680, + "Parameters": { + "Intensity": 80, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2313, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 2440, + "Parameters": { + "Intensity": 80, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 22, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 29, + "Intensity": 0.38, + "Frequency": -10 + }, + { + "Time": 61, + "Intensity": 0.13, + "Frequency": -30 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_h.json index e3d0a1e799..d2ff03dee2 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_h.json @@ -1,193 +1,193 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 120, - "Parameters": { - "Intensity": 75, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 172, - "Parameters": { - "Intensity": 73, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 236, - "Parameters": { - "Intensity": 71, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 287, - "Parameters": { - "Intensity": 73, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 317, - "Parameters": { - "Intensity": 66, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 348, - "Parameters": { - "Intensity": 72, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 391, - "Parameters": { - "Intensity": 71, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 420, - "Parameters": { - "Intensity": 69, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 466, - "Parameters": { - "Intensity": 72, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 511, - "Parameters": { - "Intensity": 68, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 553, - "Parameters": { - "Intensity": 64, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 596, - "Parameters": { - "Intensity": 64, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 620, - "Parameters": { - "Intensity": 62, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 648, - "Parameters": { - "Intensity": 70, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 711, - "Parameters": { - "Intensity": 67, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 801, - "Parameters": { - "Intensity": 69, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 120, + "Parameters": { + "Intensity": 75, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 172, + "Parameters": { + "Intensity": 73, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 236, + "Parameters": { + "Intensity": 71, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 287, + "Parameters": { + "Intensity": 73, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 317, + "Parameters": { + "Intensity": 66, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 348, + "Parameters": { + "Intensity": 72, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 391, + "Parameters": { + "Intensity": 71, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 420, + "Parameters": { + "Intensity": 69, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 466, + "Parameters": { + "Intensity": 72, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 511, + "Parameters": { + "Intensity": 68, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 553, + "Parameters": { + "Intensity": 64, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 596, + "Parameters": { + "Intensity": 64, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 620, + "Parameters": { + "Intensity": 62, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 648, + "Parameters": { + "Intensity": 70, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 711, + "Parameters": { + "Intensity": 67, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 801, + "Parameters": { + "Intensity": 69, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_l.json index 42d0c5e92d..735ba10bcd 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_l.json @@ -1,193 +1,193 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 120, - "Parameters": { - "Intensity": 45, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 172, - "Parameters": { - "Intensity": 43, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 236, - "Parameters": { - "Intensity": 42, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 287, - "Parameters": { - "Intensity": 43, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 317, - "Parameters": { - "Intensity": 39, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 348, - "Parameters": { - "Intensity": 43, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 391, - "Parameters": { - "Intensity": 42, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 420, - "Parameters": { - "Intensity": 41, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 466, - "Parameters": { - "Intensity": 43, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 511, - "Parameters": { - "Intensity": 40, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 553, - "Parameters": { - "Intensity": 38, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 596, - "Parameters": { - "Intensity": 38, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 620, - "Parameters": { - "Intensity": 37, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 648, - "Parameters": { - "Intensity": 42, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 711, - "Parameters": { - "Intensity": 40, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 801, - "Parameters": { - "Intensity": 41, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 120, + "Parameters": { + "Intensity": 45, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 172, + "Parameters": { + "Intensity": 43, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 236, + "Parameters": { + "Intensity": 42, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 287, + "Parameters": { + "Intensity": 43, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 317, + "Parameters": { + "Intensity": 39, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 348, + "Parameters": { + "Intensity": 43, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 391, + "Parameters": { + "Intensity": 42, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 420, + "Parameters": { + "Intensity": 41, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 466, + "Parameters": { + "Intensity": 43, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 511, + "Parameters": { + "Intensity": 40, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 553, + "Parameters": { + "Intensity": 38, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 596, + "Parameters": { + "Intensity": 38, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 620, + "Parameters": { + "Intensity": 37, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 648, + "Parameters": { + "Intensity": 42, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 711, + "Parameters": { + "Intensity": 40, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 801, + "Parameters": { + "Intensity": 41, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_m.json index 1cdc3935aa..3713709aea 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Picker_m.json @@ -1,193 +1,193 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 120, - "Parameters": { - "Intensity": 60, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 172, - "Parameters": { - "Intensity": 58, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 236, - "Parameters": { - "Intensity": 56, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 287, - "Parameters": { - "Intensity": 58, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 317, - "Parameters": { - "Intensity": 52, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 348, - "Parameters": { - "Intensity": 57, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 391, - "Parameters": { - "Intensity": 56, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 420, - "Parameters": { - "Intensity": 55, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 466, - "Parameters": { - "Intensity": 57, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 511, - "Parameters": { - "Intensity": 54, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 553, - "Parameters": { - "Intensity": 51, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 596, - "Parameters": { - "Intensity": 51, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 620, - "Parameters": { - "Intensity": 49, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 648, - "Parameters": { - "Intensity": 56, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 711, - "Parameters": { - "Intensity": 53, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 801, - "Parameters": { - "Intensity": 55, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 120, + "Parameters": { + "Intensity": 60, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 172, + "Parameters": { + "Intensity": 58, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 236, + "Parameters": { + "Intensity": 56, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 287, + "Parameters": { + "Intensity": 58, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 317, + "Parameters": { + "Intensity": 52, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 348, + "Parameters": { + "Intensity": 57, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 391, + "Parameters": { + "Intensity": 56, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 420, + "Parameters": { + "Intensity": 55, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 466, + "Parameters": { + "Intensity": 57, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 511, + "Parameters": { + "Intensity": 54, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 553, + "Parameters": { + "Intensity": 51, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 596, + "Parameters": { + "Intensity": 51, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 620, + "Parameters": { + "Intensity": 49, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 648, + "Parameters": { + "Intensity": 56, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 711, + "Parameters": { + "Intensity": 53, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 801, + "Parameters": { + "Intensity": 55, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_h.json index fa1ac4da2e..1b7ee07e42 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_h.json @@ -1,60 +1,60 @@ -{ - "MetaData": { - "Create": "2022-04-21", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 34, - "Parameters": { - "Intensity": 31, - "Frequency": 5 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 63, - "StartTime": 81, - "Parameters": { - "Intensity": 100, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 17, - "Intensity": 0.79, - "Frequency": 0 - }, - { - "Time": 48, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 63, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-21", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 34, + "Parameters": { + "Intensity": 31, + "Frequency": 5 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 63, + "StartTime": 81, + "Parameters": { + "Intensity": 100, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 17, + "Intensity": 0.79, + "Frequency": 0 + }, + { + "Time": 48, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 63, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_l.json index d73d3d2f50..02c9bf677f 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_l.json @@ -1,60 +1,60 @@ -{ - "MetaData": { - "Create": "2022-04-21", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 34, - "Parameters": { - "Intensity": 18, - "Frequency": 5 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 63, - "StartTime": 81, - "Parameters": { - "Intensity": 60, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 17, - "Intensity": 0.79, - "Frequency": 0 - }, - { - "Time": 48, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 63, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-21", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 34, + "Parameters": { + "Intensity": 18, + "Frequency": 5 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 63, + "StartTime": 81, + "Parameters": { + "Intensity": 60, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 17, + "Intensity": 0.79, + "Frequency": 0 + }, + { + "Time": 48, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 63, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_m.json index e9dbdd08e6..113eadb47a 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Punch_m.json @@ -1,60 +1,60 @@ -{ - "MetaData": { - "Create": "2022-04-21", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 34, - "Parameters": { - "Intensity": 24, - "Frequency": 5 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 63, - "StartTime": 81, - "Parameters": { - "Intensity": 80, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 17, - "Intensity": 0.79, - "Frequency": 0 - }, - { - "Time": 48, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 63, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-21", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 34, + "Parameters": { + "Intensity": 24, + "Frequency": 5 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 63, + "StartTime": 81, + "Parameters": { + "Intensity": 80, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 17, + "Intensity": 0.79, + "Frequency": 0 + }, + { + "Time": 48, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 63, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_h.json index f2ba4c8f07..51e9d70ae9 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_h.json @@ -1,65 +1,65 @@ -{ - "MetaData": { - "Create": "2022-04-15", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 69, - "StartTime": 19, - "Parameters": { - "Intensity": 71, - "Frequency": 90, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 13, - "Intensity": 0.09, - "Frequency": -83 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": -36 - }, - { - "Time": 68, - "Intensity": 0.1, - "Frequency": -58 - }, - { - "Time": 69, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 92, - "Parameters": { - "Intensity": 100, - "Frequency": 61 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-15", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 69, + "StartTime": 19, + "Parameters": { + "Intensity": 71, + "Frequency": 90, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 13, + "Intensity": 0.09, + "Frequency": -83 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": -36 + }, + { + "Time": 68, + "Intensity": 0.1, + "Frequency": -58 + }, + { + "Time": 69, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 92, + "Parameters": { + "Intensity": 100, + "Frequency": 61 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_l.json index b932a84333..f396288aee 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_l.json @@ -1,65 +1,65 @@ -{ - "MetaData": { - "Create": "2022-04-15", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 69, - "StartTime": 19, - "Parameters": { - "Intensity": 42, - "Frequency": 90, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 13, - "Intensity": 0.09, - "Frequency": -83 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": -36 - }, - { - "Time": 68, - "Intensity": 0.1, - "Frequency": -58 - }, - { - "Time": 69, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 92, - "Parameters": { - "Intensity": 60, - "Frequency": 61 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-15", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 69, + "StartTime": 19, + "Parameters": { + "Intensity": 42, + "Frequency": 90, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 13, + "Intensity": 0.09, + "Frequency": -83 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": -36 + }, + { + "Time": 68, + "Intensity": 0.1, + "Frequency": -58 + }, + { + "Time": 69, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 92, + "Parameters": { + "Intensity": 60, + "Frequency": 61 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_m.json index 8f35ff2247..ba6e756a41 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/RacingStart_m.json @@ -1,65 +1,65 @@ -{ - "MetaData": { - "Create": "2022-04-15", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 69, - "StartTime": 19, - "Parameters": { - "Intensity": 56, - "Frequency": 90, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -100 - }, - { - "Time": 13, - "Intensity": 0.09, - "Frequency": -83 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": -36 - }, - { - "Time": 68, - "Intensity": 0.1, - "Frequency": -58 - }, - { - "Time": 69, - "Intensity": 0, - "Frequency": -88 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 92, - "Parameters": { - "Intensity": 80, - "Frequency": 61 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-15", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 69, + "StartTime": 19, + "Parameters": { + "Intensity": 56, + "Frequency": 90, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -100 + }, + { + "Time": 13, + "Intensity": 0.09, + "Frequency": -83 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": -36 + }, + { + "Time": 68, + "Intensity": 0.1, + "Frequency": -58 + }, + { + "Time": 69, + "Intensity": 0, + "Frequency": -88 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 92, + "Parameters": { + "Intensity": 80, + "Frequency": 61 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_h.json index 896821a113..0e3e289299 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_h.json @@ -1,1087 +1,1087 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 4, - "Parameters": { - "Intensity": 31, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 39, - "Parameters": { - "Intensity": 42, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 86, - "Parameters": { - "Intensity": 32, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 112, - "Parameters": { - "Intensity": 34, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 156, - "Parameters": { - "Intensity": 40, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 192, - "Parameters": { - "Intensity": 54, - "Frequency": 11 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 248, - "Parameters": { - "Intensity": 48, - "Frequency": 38 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 304, - "Parameters": { - "Intensity": 31, - "Frequency": 17 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 344, - "Parameters": { - "Intensity": 39, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 368, - "Parameters": { - "Intensity": 35, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 406, - "Parameters": { - "Intensity": 43, - "Frequency": 7 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 455, - "Parameters": { - "Intensity": 40, - "Frequency": 17 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 495, - "Parameters": { - "Intensity": 43, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 532, - "Parameters": { - "Intensity": 32, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 565, - "Parameters": { - "Intensity": 34, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 629, - "Parameters": { - "Intensity": 42, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 680, - "Parameters": { - "Intensity": 51, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 723, - "Parameters": { - "Intensity": 37, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 770, - "Parameters": { - "Intensity": 34, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 797, - "Parameters": { - "Intensity": 34, - "Frequency": 21 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 858, - "Parameters": { - "Intensity": 29, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 904, - "Parameters": { - "Intensity": 30, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 965, - "Parameters": { - "Intensity": 32, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 999, - "Parameters": { - "Intensity": 38, - "Frequency": 14 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1039, - "Parameters": { - "Intensity": 31, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1078, - "Parameters": { - "Intensity": 48, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1114, - "Parameters": { - "Intensity": 38, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1168, - "Parameters": { - "Intensity": 28, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1205, - "Parameters": { - "Intensity": 46, - "Frequency": 28 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1248, - "Parameters": { - "Intensity": 33, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1315, - "Parameters": { - "Intensity": 37, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1374, - "Parameters": { - "Intensity": 33, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1401, - "Parameters": { - "Intensity": 45, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1439, - "Parameters": { - "Intensity": 30, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1507, - "Parameters": { - "Intensity": 42, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1554, - "Parameters": { - "Intensity": 41, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1581, - "Parameters": { - "Intensity": 35, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1625, - "Parameters": { - "Intensity": 30, - "Frequency": 39 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1664, - "Parameters": { - "Intensity": 33, - "Frequency": 67 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1691, - "Parameters": { - "Intensity": 36, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1739, - "Parameters": { - "Intensity": 31, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1798, - "Parameters": { - "Intensity": 36, - "Frequency": 41 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1838, - "Parameters": { - "Intensity": 29, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1868, - "Parameters": { - "Intensity": 54, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1917, - "Parameters": { - "Intensity": 31, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1959, - "Parameters": { - "Intensity": 35, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2009, - "Parameters": { - "Intensity": 39, - "Frequency": 9 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2068, - "Parameters": { - "Intensity": 35, - "Frequency": 72 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2102, - "Parameters": { - "Intensity": 48, - "Frequency": 11 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2151, - "Parameters": { - "Intensity": 34, - "Frequency": 37 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2188, - "Parameters": { - "Intensity": 33, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2229, - "Parameters": { - "Intensity": 36, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2288, - "Parameters": { - "Intensity": 29, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2349, - "Parameters": { - "Intensity": 26, - "Frequency": 31 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2389, - "Parameters": { - "Intensity": 31, - "Frequency": 73 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2420, - "Parameters": { - "Intensity": 34, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2462, - "Parameters": { - "Intensity": 49, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2509, - "Parameters": { - "Intensity": 40, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2546, - "Parameters": { - "Intensity": 30, - "Frequency": 22 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2592, - "Parameters": { - "Intensity": 43, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2656, - "Parameters": { - "Intensity": 35, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2718, - "Parameters": { - "Intensity": 29, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2744, - "Parameters": { - "Intensity": 32, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2802, - "Parameters": { - "Intensity": 38, - "Frequency": 37 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2848, - "Parameters": { - "Intensity": 30, - "Frequency": 77 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2881, - "Parameters": { - "Intensity": 51, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2933, - "Parameters": { - "Intensity": 38, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2959, - "Parameters": { - "Intensity": 31, - "Frequency": 32 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3004, - "Parameters": { - "Intensity": 35, - "Frequency": 27 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3051, - "Parameters": { - "Intensity": 38, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3095, - "Parameters": { - "Intensity": 29, - "Frequency": 11 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3144, - "Parameters": { - "Intensity": 36, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3182, - "Parameters": { - "Intensity": 33, - "Frequency": 66 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3215, - "Parameters": { - "Intensity": 51, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3275, - "Parameters": { - "Intensity": 37, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3315, - "Parameters": { - "Intensity": 32, - "Frequency": 16 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3363, - "Parameters": { - "Intensity": 28, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3410, - "Parameters": { - "Intensity": 39, - "Frequency": 24 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3451, - "Parameters": { - "Intensity": 32, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3482, - "Parameters": { - "Intensity": 46, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3530, - "Parameters": { - "Intensity": 33, - "Frequency": 62 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3567, - "Parameters": { - "Intensity": 34, - "Frequency": 16 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3614, - "Parameters": { - "Intensity": 52, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3660, - "Parameters": { - "Intensity": 42, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3731, - "Parameters": { - "Intensity": 32, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3770, - "Parameters": { - "Intensity": 36, - "Frequency": 26 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3810, - "Parameters": { - "Intensity": 38, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3851, - "Parameters": { - "Intensity": 36, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3899, - "Parameters": { - "Intensity": 29, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3937, - "Parameters": { - "Intensity": 36, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3965, - "Parameters": { - "Intensity": 49, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4014, - "Parameters": { - "Intensity": 31, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4058, - "Parameters": { - "Intensity": 36, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4090, - "Parameters": { - "Intensity": 32, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4122, - "Parameters": { - "Intensity": 41, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4170, - "Parameters": { - "Intensity": 33, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4213, - "Parameters": { - "Intensity": 30, - "Frequency": 77 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4238, - "Parameters": { - "Intensity": 45, - "Frequency": 26 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4282, - "Parameters": { - "Intensity": 51, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4330, - "Parameters": { - "Intensity": 29, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4375, - "Parameters": { - "Intensity": 40, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4418, - "Parameters": { - "Intensity": 35, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4467, - "Parameters": { - "Intensity": 28, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4495, - "Parameters": { - "Intensity": 36, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4536, - "Parameters": { - "Intensity": 29, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4598, - "Parameters": { - "Intensity": 38, - "Frequency": 22 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4645, - "Parameters": { - "Intensity": 21, - "Frequency": 56 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 4, + "Parameters": { + "Intensity": 31, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 39, + "Parameters": { + "Intensity": 42, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 86, + "Parameters": { + "Intensity": 32, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 112, + "Parameters": { + "Intensity": 34, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 156, + "Parameters": { + "Intensity": 40, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 192, + "Parameters": { + "Intensity": 54, + "Frequency": 11 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 248, + "Parameters": { + "Intensity": 48, + "Frequency": 38 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 304, + "Parameters": { + "Intensity": 31, + "Frequency": 17 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 344, + "Parameters": { + "Intensity": 39, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 368, + "Parameters": { + "Intensity": 35, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 406, + "Parameters": { + "Intensity": 43, + "Frequency": 7 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 455, + "Parameters": { + "Intensity": 40, + "Frequency": 17 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 495, + "Parameters": { + "Intensity": 43, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 532, + "Parameters": { + "Intensity": 32, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 565, + "Parameters": { + "Intensity": 34, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 629, + "Parameters": { + "Intensity": 42, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 680, + "Parameters": { + "Intensity": 51, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 723, + "Parameters": { + "Intensity": 37, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 770, + "Parameters": { + "Intensity": 34, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 797, + "Parameters": { + "Intensity": 34, + "Frequency": 21 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 858, + "Parameters": { + "Intensity": 29, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 904, + "Parameters": { + "Intensity": 30, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 965, + "Parameters": { + "Intensity": 32, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 999, + "Parameters": { + "Intensity": 38, + "Frequency": 14 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1039, + "Parameters": { + "Intensity": 31, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1078, + "Parameters": { + "Intensity": 48, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1114, + "Parameters": { + "Intensity": 38, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1168, + "Parameters": { + "Intensity": 28, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1205, + "Parameters": { + "Intensity": 46, + "Frequency": 28 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1248, + "Parameters": { + "Intensity": 33, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1315, + "Parameters": { + "Intensity": 37, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1374, + "Parameters": { + "Intensity": 33, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1401, + "Parameters": { + "Intensity": 45, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1439, + "Parameters": { + "Intensity": 30, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1507, + "Parameters": { + "Intensity": 42, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1554, + "Parameters": { + "Intensity": 41, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1581, + "Parameters": { + "Intensity": 35, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1625, + "Parameters": { + "Intensity": 30, + "Frequency": 39 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1664, + "Parameters": { + "Intensity": 33, + "Frequency": 67 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1691, + "Parameters": { + "Intensity": 36, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1739, + "Parameters": { + "Intensity": 31, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1798, + "Parameters": { + "Intensity": 36, + "Frequency": 41 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1838, + "Parameters": { + "Intensity": 29, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1868, + "Parameters": { + "Intensity": 54, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1917, + "Parameters": { + "Intensity": 31, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1959, + "Parameters": { + "Intensity": 35, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2009, + "Parameters": { + "Intensity": 39, + "Frequency": 9 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2068, + "Parameters": { + "Intensity": 35, + "Frequency": 72 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2102, + "Parameters": { + "Intensity": 48, + "Frequency": 11 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2151, + "Parameters": { + "Intensity": 34, + "Frequency": 37 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2188, + "Parameters": { + "Intensity": 33, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2229, + "Parameters": { + "Intensity": 36, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2288, + "Parameters": { + "Intensity": 29, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2349, + "Parameters": { + "Intensity": 26, + "Frequency": 31 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2389, + "Parameters": { + "Intensity": 31, + "Frequency": 73 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2420, + "Parameters": { + "Intensity": 34, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2462, + "Parameters": { + "Intensity": 49, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2509, + "Parameters": { + "Intensity": 40, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2546, + "Parameters": { + "Intensity": 30, + "Frequency": 22 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2592, + "Parameters": { + "Intensity": 43, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2656, + "Parameters": { + "Intensity": 35, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2718, + "Parameters": { + "Intensity": 29, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2744, + "Parameters": { + "Intensity": 32, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2802, + "Parameters": { + "Intensity": 38, + "Frequency": 37 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2848, + "Parameters": { + "Intensity": 30, + "Frequency": 77 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2881, + "Parameters": { + "Intensity": 51, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2933, + "Parameters": { + "Intensity": 38, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2959, + "Parameters": { + "Intensity": 31, + "Frequency": 32 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3004, + "Parameters": { + "Intensity": 35, + "Frequency": 27 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3051, + "Parameters": { + "Intensity": 38, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3095, + "Parameters": { + "Intensity": 29, + "Frequency": 11 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3144, + "Parameters": { + "Intensity": 36, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3182, + "Parameters": { + "Intensity": 33, + "Frequency": 66 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3215, + "Parameters": { + "Intensity": 51, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3275, + "Parameters": { + "Intensity": 37, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3315, + "Parameters": { + "Intensity": 32, + "Frequency": 16 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3363, + "Parameters": { + "Intensity": 28, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3410, + "Parameters": { + "Intensity": 39, + "Frequency": 24 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3451, + "Parameters": { + "Intensity": 32, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3482, + "Parameters": { + "Intensity": 46, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3530, + "Parameters": { + "Intensity": 33, + "Frequency": 62 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3567, + "Parameters": { + "Intensity": 34, + "Frequency": 16 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3614, + "Parameters": { + "Intensity": 52, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3660, + "Parameters": { + "Intensity": 42, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3731, + "Parameters": { + "Intensity": 32, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3770, + "Parameters": { + "Intensity": 36, + "Frequency": 26 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3810, + "Parameters": { + "Intensity": 38, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3851, + "Parameters": { + "Intensity": 36, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3899, + "Parameters": { + "Intensity": 29, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3937, + "Parameters": { + "Intensity": 36, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3965, + "Parameters": { + "Intensity": 49, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4014, + "Parameters": { + "Intensity": 31, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4058, + "Parameters": { + "Intensity": 36, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4090, + "Parameters": { + "Intensity": 32, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4122, + "Parameters": { + "Intensity": 41, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4170, + "Parameters": { + "Intensity": 33, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4213, + "Parameters": { + "Intensity": 30, + "Frequency": 77 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4238, + "Parameters": { + "Intensity": 45, + "Frequency": 26 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4282, + "Parameters": { + "Intensity": 51, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4330, + "Parameters": { + "Intensity": 29, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4375, + "Parameters": { + "Intensity": 40, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4418, + "Parameters": { + "Intensity": 35, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4467, + "Parameters": { + "Intensity": 28, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4495, + "Parameters": { + "Intensity": 36, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4536, + "Parameters": { + "Intensity": 29, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4598, + "Parameters": { + "Intensity": 38, + "Frequency": 22 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4645, + "Parameters": { + "Intensity": 21, + "Frequency": 56 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_l.json index f0b8fdb77c..c8c4a8c8f7 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_l.json @@ -1,1087 +1,1087 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 4, - "Parameters": { - "Intensity": 18, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 39, - "Parameters": { - "Intensity": 25, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 86, - "Parameters": { - "Intensity": 19, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 112, - "Parameters": { - "Intensity": 20, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 156, - "Parameters": { - "Intensity": 24, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 192, - "Parameters": { - "Intensity": 32, - "Frequency": 11 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 248, - "Parameters": { - "Intensity": 28, - "Frequency": 38 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 304, - "Parameters": { - "Intensity": 18, - "Frequency": 17 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 344, - "Parameters": { - "Intensity": 23, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 368, - "Parameters": { - "Intensity": 21, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 406, - "Parameters": { - "Intensity": 25, - "Frequency": 7 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 455, - "Parameters": { - "Intensity": 24, - "Frequency": 17 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 495, - "Parameters": { - "Intensity": 25, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 532, - "Parameters": { - "Intensity": 19, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 565, - "Parameters": { - "Intensity": 20, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 629, - "Parameters": { - "Intensity": 25, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 680, - "Parameters": { - "Intensity": 30, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 723, - "Parameters": { - "Intensity": 22, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 770, - "Parameters": { - "Intensity": 20, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 797, - "Parameters": { - "Intensity": 20, - "Frequency": 21 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 858, - "Parameters": { - "Intensity": 17, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 904, - "Parameters": { - "Intensity": 18, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 965, - "Parameters": { - "Intensity": 19, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 999, - "Parameters": { - "Intensity": 22, - "Frequency": 14 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1039, - "Parameters": { - "Intensity": 18, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1078, - "Parameters": { - "Intensity": 28, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1114, - "Parameters": { - "Intensity": 22, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1168, - "Parameters": { - "Intensity": 16, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1205, - "Parameters": { - "Intensity": 27, - "Frequency": 28 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1248, - "Parameters": { - "Intensity": 19, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1315, - "Parameters": { - "Intensity": 22, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1374, - "Parameters": { - "Intensity": 19, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1401, - "Parameters": { - "Intensity": 27, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1439, - "Parameters": { - "Intensity": 18, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1507, - "Parameters": { - "Intensity": 25, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1554, - "Parameters": { - "Intensity": 24, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1581, - "Parameters": { - "Intensity": 21, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1625, - "Parameters": { - "Intensity": 18, - "Frequency": 39 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1664, - "Parameters": { - "Intensity": 19, - "Frequency": 67 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1691, - "Parameters": { - "Intensity": 21, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1739, - "Parameters": { - "Intensity": 18, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1798, - "Parameters": { - "Intensity": 21, - "Frequency": 41 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1838, - "Parameters": { - "Intensity": 17, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1868, - "Parameters": { - "Intensity": 32, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1917, - "Parameters": { - "Intensity": 18, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1959, - "Parameters": { - "Intensity": 21, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2009, - "Parameters": { - "Intensity": 23, - "Frequency": 9 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2068, - "Parameters": { - "Intensity": 21, - "Frequency": 72 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2102, - "Parameters": { - "Intensity": 28, - "Frequency": 11 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2151, - "Parameters": { - "Intensity": 20, - "Frequency": 37 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2188, - "Parameters": { - "Intensity": 19, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2229, - "Parameters": { - "Intensity": 21, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2288, - "Parameters": { - "Intensity": 17, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2349, - "Parameters": { - "Intensity": 15, - "Frequency": 31 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2389, - "Parameters": { - "Intensity": 18, - "Frequency": 73 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2420, - "Parameters": { - "Intensity": 20, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2462, - "Parameters": { - "Intensity": 29, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2509, - "Parameters": { - "Intensity": 24, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2546, - "Parameters": { - "Intensity": 18, - "Frequency": 22 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2592, - "Parameters": { - "Intensity": 25, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2656, - "Parameters": { - "Intensity": 21, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2718, - "Parameters": { - "Intensity": 17, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2744, - "Parameters": { - "Intensity": 19, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2802, - "Parameters": { - "Intensity": 22, - "Frequency": 37 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2848, - "Parameters": { - "Intensity": 18, - "Frequency": 77 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2881, - "Parameters": { - "Intensity": 30, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2933, - "Parameters": { - "Intensity": 22, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2959, - "Parameters": { - "Intensity": 18, - "Frequency": 32 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3004, - "Parameters": { - "Intensity": 21, - "Frequency": 27 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3051, - "Parameters": { - "Intensity": 22, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3095, - "Parameters": { - "Intensity": 17, - "Frequency": 11 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3144, - "Parameters": { - "Intensity": 21, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3182, - "Parameters": { - "Intensity": 19, - "Frequency": 66 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3215, - "Parameters": { - "Intensity": 30, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3275, - "Parameters": { - "Intensity": 22, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3315, - "Parameters": { - "Intensity": 19, - "Frequency": 16 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3363, - "Parameters": { - "Intensity": 16, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3410, - "Parameters": { - "Intensity": 23, - "Frequency": 24 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3451, - "Parameters": { - "Intensity": 19, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3482, - "Parameters": { - "Intensity": 27, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3530, - "Parameters": { - "Intensity": 19, - "Frequency": 62 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3567, - "Parameters": { - "Intensity": 20, - "Frequency": 16 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3614, - "Parameters": { - "Intensity": 31, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3660, - "Parameters": { - "Intensity": 25, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3731, - "Parameters": { - "Intensity": 19, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3770, - "Parameters": { - "Intensity": 21, - "Frequency": 26 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3810, - "Parameters": { - "Intensity": 22, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3851, - "Parameters": { - "Intensity": 21, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3899, - "Parameters": { - "Intensity": 17, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3937, - "Parameters": { - "Intensity": 21, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3965, - "Parameters": { - "Intensity": 29, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4014, - "Parameters": { - "Intensity": 18, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4058, - "Parameters": { - "Intensity": 21, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4090, - "Parameters": { - "Intensity": 19, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4122, - "Parameters": { - "Intensity": 24, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4170, - "Parameters": { - "Intensity": 19, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4213, - "Parameters": { - "Intensity": 18, - "Frequency": 77 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4238, - "Parameters": { - "Intensity": 27, - "Frequency": 26 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4282, - "Parameters": { - "Intensity": 30, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4330, - "Parameters": { - "Intensity": 17, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4375, - "Parameters": { - "Intensity": 24, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4418, - "Parameters": { - "Intensity": 21, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4467, - "Parameters": { - "Intensity": 16, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4495, - "Parameters": { - "Intensity": 21, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4536, - "Parameters": { - "Intensity": 17, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4598, - "Parameters": { - "Intensity": 22, - "Frequency": 22 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4645, - "Parameters": { - "Intensity": 12, - "Frequency": 56 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 4, + "Parameters": { + "Intensity": 18, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 39, + "Parameters": { + "Intensity": 25, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 86, + "Parameters": { + "Intensity": 19, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 112, + "Parameters": { + "Intensity": 20, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 156, + "Parameters": { + "Intensity": 24, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 192, + "Parameters": { + "Intensity": 32, + "Frequency": 11 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 248, + "Parameters": { + "Intensity": 28, + "Frequency": 38 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 304, + "Parameters": { + "Intensity": 18, + "Frequency": 17 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 344, + "Parameters": { + "Intensity": 23, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 368, + "Parameters": { + "Intensity": 21, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 406, + "Parameters": { + "Intensity": 25, + "Frequency": 7 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 455, + "Parameters": { + "Intensity": 24, + "Frequency": 17 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 495, + "Parameters": { + "Intensity": 25, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 532, + "Parameters": { + "Intensity": 19, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 565, + "Parameters": { + "Intensity": 20, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 629, + "Parameters": { + "Intensity": 25, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 680, + "Parameters": { + "Intensity": 30, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 723, + "Parameters": { + "Intensity": 22, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 770, + "Parameters": { + "Intensity": 20, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 797, + "Parameters": { + "Intensity": 20, + "Frequency": 21 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 858, + "Parameters": { + "Intensity": 17, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 904, + "Parameters": { + "Intensity": 18, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 965, + "Parameters": { + "Intensity": 19, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 999, + "Parameters": { + "Intensity": 22, + "Frequency": 14 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1039, + "Parameters": { + "Intensity": 18, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1078, + "Parameters": { + "Intensity": 28, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1114, + "Parameters": { + "Intensity": 22, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1168, + "Parameters": { + "Intensity": 16, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1205, + "Parameters": { + "Intensity": 27, + "Frequency": 28 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1248, + "Parameters": { + "Intensity": 19, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1315, + "Parameters": { + "Intensity": 22, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1374, + "Parameters": { + "Intensity": 19, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1401, + "Parameters": { + "Intensity": 27, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1439, + "Parameters": { + "Intensity": 18, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1507, + "Parameters": { + "Intensity": 25, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1554, + "Parameters": { + "Intensity": 24, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1581, + "Parameters": { + "Intensity": 21, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1625, + "Parameters": { + "Intensity": 18, + "Frequency": 39 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1664, + "Parameters": { + "Intensity": 19, + "Frequency": 67 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1691, + "Parameters": { + "Intensity": 21, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1739, + "Parameters": { + "Intensity": 18, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1798, + "Parameters": { + "Intensity": 21, + "Frequency": 41 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1838, + "Parameters": { + "Intensity": 17, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1868, + "Parameters": { + "Intensity": 32, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1917, + "Parameters": { + "Intensity": 18, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1959, + "Parameters": { + "Intensity": 21, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2009, + "Parameters": { + "Intensity": 23, + "Frequency": 9 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2068, + "Parameters": { + "Intensity": 21, + "Frequency": 72 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2102, + "Parameters": { + "Intensity": 28, + "Frequency": 11 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2151, + "Parameters": { + "Intensity": 20, + "Frequency": 37 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2188, + "Parameters": { + "Intensity": 19, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2229, + "Parameters": { + "Intensity": 21, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2288, + "Parameters": { + "Intensity": 17, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2349, + "Parameters": { + "Intensity": 15, + "Frequency": 31 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2389, + "Parameters": { + "Intensity": 18, + "Frequency": 73 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2420, + "Parameters": { + "Intensity": 20, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2462, + "Parameters": { + "Intensity": 29, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2509, + "Parameters": { + "Intensity": 24, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2546, + "Parameters": { + "Intensity": 18, + "Frequency": 22 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2592, + "Parameters": { + "Intensity": 25, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2656, + "Parameters": { + "Intensity": 21, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2718, + "Parameters": { + "Intensity": 17, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2744, + "Parameters": { + "Intensity": 19, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2802, + "Parameters": { + "Intensity": 22, + "Frequency": 37 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2848, + "Parameters": { + "Intensity": 18, + "Frequency": 77 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2881, + "Parameters": { + "Intensity": 30, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2933, + "Parameters": { + "Intensity": 22, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2959, + "Parameters": { + "Intensity": 18, + "Frequency": 32 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3004, + "Parameters": { + "Intensity": 21, + "Frequency": 27 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3051, + "Parameters": { + "Intensity": 22, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3095, + "Parameters": { + "Intensity": 17, + "Frequency": 11 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3144, + "Parameters": { + "Intensity": 21, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3182, + "Parameters": { + "Intensity": 19, + "Frequency": 66 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3215, + "Parameters": { + "Intensity": 30, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3275, + "Parameters": { + "Intensity": 22, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3315, + "Parameters": { + "Intensity": 19, + "Frequency": 16 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3363, + "Parameters": { + "Intensity": 16, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3410, + "Parameters": { + "Intensity": 23, + "Frequency": 24 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3451, + "Parameters": { + "Intensity": 19, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3482, + "Parameters": { + "Intensity": 27, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3530, + "Parameters": { + "Intensity": 19, + "Frequency": 62 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3567, + "Parameters": { + "Intensity": 20, + "Frequency": 16 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3614, + "Parameters": { + "Intensity": 31, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3660, + "Parameters": { + "Intensity": 25, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3731, + "Parameters": { + "Intensity": 19, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3770, + "Parameters": { + "Intensity": 21, + "Frequency": 26 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3810, + "Parameters": { + "Intensity": 22, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3851, + "Parameters": { + "Intensity": 21, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3899, + "Parameters": { + "Intensity": 17, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3937, + "Parameters": { + "Intensity": 21, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3965, + "Parameters": { + "Intensity": 29, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4014, + "Parameters": { + "Intensity": 18, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4058, + "Parameters": { + "Intensity": 21, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4090, + "Parameters": { + "Intensity": 19, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4122, + "Parameters": { + "Intensity": 24, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4170, + "Parameters": { + "Intensity": 19, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4213, + "Parameters": { + "Intensity": 18, + "Frequency": 77 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4238, + "Parameters": { + "Intensity": 27, + "Frequency": 26 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4282, + "Parameters": { + "Intensity": 30, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4330, + "Parameters": { + "Intensity": 17, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4375, + "Parameters": { + "Intensity": 24, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4418, + "Parameters": { + "Intensity": 21, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4467, + "Parameters": { + "Intensity": 16, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4495, + "Parameters": { + "Intensity": 21, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4536, + "Parameters": { + "Intensity": 17, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4598, + "Parameters": { + "Intensity": 22, + "Frequency": 22 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4645, + "Parameters": { + "Intensity": 12, + "Frequency": 56 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_m.json index b1089886cf..1ee461a669 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rain_m.json @@ -1,1087 +1,1087 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 4, - "Parameters": { - "Intensity": 24, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 39, - "Parameters": { - "Intensity": 33, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 86, - "Parameters": { - "Intensity": 25, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 112, - "Parameters": { - "Intensity": 27, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 156, - "Parameters": { - "Intensity": 32, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 192, - "Parameters": { - "Intensity": 43, - "Frequency": 11 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 248, - "Parameters": { - "Intensity": 38, - "Frequency": 38 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 304, - "Parameters": { - "Intensity": 24, - "Frequency": 17 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 344, - "Parameters": { - "Intensity": 31, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 368, - "Parameters": { - "Intensity": 28, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 406, - "Parameters": { - "Intensity": 34, - "Frequency": 7 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 455, - "Parameters": { - "Intensity": 32, - "Frequency": 17 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 495, - "Parameters": { - "Intensity": 34, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 532, - "Parameters": { - "Intensity": 25, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 565, - "Parameters": { - "Intensity": 27, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 629, - "Parameters": { - "Intensity": 33, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 680, - "Parameters": { - "Intensity": 40, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 723, - "Parameters": { - "Intensity": 29, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 770, - "Parameters": { - "Intensity": 27, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 797, - "Parameters": { - "Intensity": 27, - "Frequency": 21 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 858, - "Parameters": { - "Intensity": 23, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 904, - "Parameters": { - "Intensity": 24, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 965, - "Parameters": { - "Intensity": 25, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 999, - "Parameters": { - "Intensity": 30, - "Frequency": 14 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1039, - "Parameters": { - "Intensity": 24, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1078, - "Parameters": { - "Intensity": 38, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1114, - "Parameters": { - "Intensity": 30, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1168, - "Parameters": { - "Intensity": 22, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1205, - "Parameters": { - "Intensity": 36, - "Frequency": 28 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1248, - "Parameters": { - "Intensity": 26, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1315, - "Parameters": { - "Intensity": 29, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1374, - "Parameters": { - "Intensity": 26, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1401, - "Parameters": { - "Intensity": 36, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1439, - "Parameters": { - "Intensity": 24, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1507, - "Parameters": { - "Intensity": 33, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1554, - "Parameters": { - "Intensity": 32, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1581, - "Parameters": { - "Intensity": 28, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1625, - "Parameters": { - "Intensity": 24, - "Frequency": 39 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1664, - "Parameters": { - "Intensity": 26, - "Frequency": 67 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1691, - "Parameters": { - "Intensity": 28, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1739, - "Parameters": { - "Intensity": 24, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1798, - "Parameters": { - "Intensity": 28, - "Frequency": 41 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1838, - "Parameters": { - "Intensity": 23, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1868, - "Parameters": { - "Intensity": 43, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1917, - "Parameters": { - "Intensity": 24, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1959, - "Parameters": { - "Intensity": 28, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2009, - "Parameters": { - "Intensity": 31, - "Frequency": 9 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2068, - "Parameters": { - "Intensity": 28, - "Frequency": 72 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2102, - "Parameters": { - "Intensity": 38, - "Frequency": 11 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2151, - "Parameters": { - "Intensity": 27, - "Frequency": 37 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2188, - "Parameters": { - "Intensity": 26, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2229, - "Parameters": { - "Intensity": 28, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2288, - "Parameters": { - "Intensity": 23, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2349, - "Parameters": { - "Intensity": 20, - "Frequency": 31 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2389, - "Parameters": { - "Intensity": 24, - "Frequency": 73 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2420, - "Parameters": { - "Intensity": 27, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2462, - "Parameters": { - "Intensity": 39, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2509, - "Parameters": { - "Intensity": 32, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2546, - "Parameters": { - "Intensity": 24, - "Frequency": 22 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2592, - "Parameters": { - "Intensity": 34, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2656, - "Parameters": { - "Intensity": 28, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2718, - "Parameters": { - "Intensity": 23, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2744, - "Parameters": { - "Intensity": 25, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2802, - "Parameters": { - "Intensity": 30, - "Frequency": 37 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2848, - "Parameters": { - "Intensity": 24, - "Frequency": 77 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2881, - "Parameters": { - "Intensity": 40, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2933, - "Parameters": { - "Intensity": 30, - "Frequency": 55 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2959, - "Parameters": { - "Intensity": 24, - "Frequency": 32 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3004, - "Parameters": { - "Intensity": 28, - "Frequency": 27 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3051, - "Parameters": { - "Intensity": 30, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3095, - "Parameters": { - "Intensity": 23, - "Frequency": 11 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3144, - "Parameters": { - "Intensity": 28, - "Frequency": 35 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3182, - "Parameters": { - "Intensity": 26, - "Frequency": 66 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3215, - "Parameters": { - "Intensity": 40, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3275, - "Parameters": { - "Intensity": 29, - "Frequency": 36 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3315, - "Parameters": { - "Intensity": 25, - "Frequency": 16 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3363, - "Parameters": { - "Intensity": 22, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3410, - "Parameters": { - "Intensity": 31, - "Frequency": 24 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3451, - "Parameters": { - "Intensity": 25, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3482, - "Parameters": { - "Intensity": 36, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3530, - "Parameters": { - "Intensity": 26, - "Frequency": 62 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3567, - "Parameters": { - "Intensity": 27, - "Frequency": 16 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3614, - "Parameters": { - "Intensity": 41, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3660, - "Parameters": { - "Intensity": 33, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3731, - "Parameters": { - "Intensity": 25, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3770, - "Parameters": { - "Intensity": 28, - "Frequency": 26 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3810, - "Parameters": { - "Intensity": 30, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3851, - "Parameters": { - "Intensity": 28, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3899, - "Parameters": { - "Intensity": 23, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3937, - "Parameters": { - "Intensity": 28, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3965, - "Parameters": { - "Intensity": 39, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4014, - "Parameters": { - "Intensity": 24, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4058, - "Parameters": { - "Intensity": 28, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4090, - "Parameters": { - "Intensity": 25, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4122, - "Parameters": { - "Intensity": 32, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4170, - "Parameters": { - "Intensity": 26, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4213, - "Parameters": { - "Intensity": 24, - "Frequency": 77 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4238, - "Parameters": { - "Intensity": 36, - "Frequency": 26 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4282, - "Parameters": { - "Intensity": 40, - "Frequency": 40 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4330, - "Parameters": { - "Intensity": 23, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4375, - "Parameters": { - "Intensity": 32, - "Frequency": 25 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4418, - "Parameters": { - "Intensity": 28, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4467, - "Parameters": { - "Intensity": 22, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4495, - "Parameters": { - "Intensity": 28, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4536, - "Parameters": { - "Intensity": 23, - "Frequency": 10 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4598, - "Parameters": { - "Intensity": 30, - "Frequency": 22 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4645, - "Parameters": { - "Intensity": 16, - "Frequency": 56 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 4, + "Parameters": { + "Intensity": 24, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 39, + "Parameters": { + "Intensity": 33, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 86, + "Parameters": { + "Intensity": 25, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 112, + "Parameters": { + "Intensity": 27, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 156, + "Parameters": { + "Intensity": 32, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 192, + "Parameters": { + "Intensity": 43, + "Frequency": 11 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 248, + "Parameters": { + "Intensity": 38, + "Frequency": 38 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 304, + "Parameters": { + "Intensity": 24, + "Frequency": 17 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 344, + "Parameters": { + "Intensity": 31, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 368, + "Parameters": { + "Intensity": 28, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 406, + "Parameters": { + "Intensity": 34, + "Frequency": 7 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 455, + "Parameters": { + "Intensity": 32, + "Frequency": 17 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 495, + "Parameters": { + "Intensity": 34, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 532, + "Parameters": { + "Intensity": 25, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 565, + "Parameters": { + "Intensity": 27, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 629, + "Parameters": { + "Intensity": 33, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 680, + "Parameters": { + "Intensity": 40, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 723, + "Parameters": { + "Intensity": 29, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 770, + "Parameters": { + "Intensity": 27, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 797, + "Parameters": { + "Intensity": 27, + "Frequency": 21 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 858, + "Parameters": { + "Intensity": 23, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 904, + "Parameters": { + "Intensity": 24, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 965, + "Parameters": { + "Intensity": 25, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 999, + "Parameters": { + "Intensity": 30, + "Frequency": 14 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1039, + "Parameters": { + "Intensity": 24, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1078, + "Parameters": { + "Intensity": 38, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1114, + "Parameters": { + "Intensity": 30, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1168, + "Parameters": { + "Intensity": 22, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1205, + "Parameters": { + "Intensity": 36, + "Frequency": 28 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1248, + "Parameters": { + "Intensity": 26, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1315, + "Parameters": { + "Intensity": 29, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1374, + "Parameters": { + "Intensity": 26, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1401, + "Parameters": { + "Intensity": 36, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1439, + "Parameters": { + "Intensity": 24, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1507, + "Parameters": { + "Intensity": 33, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1554, + "Parameters": { + "Intensity": 32, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1581, + "Parameters": { + "Intensity": 28, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1625, + "Parameters": { + "Intensity": 24, + "Frequency": 39 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1664, + "Parameters": { + "Intensity": 26, + "Frequency": 67 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1691, + "Parameters": { + "Intensity": 28, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1739, + "Parameters": { + "Intensity": 24, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1798, + "Parameters": { + "Intensity": 28, + "Frequency": 41 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1838, + "Parameters": { + "Intensity": 23, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1868, + "Parameters": { + "Intensity": 43, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1917, + "Parameters": { + "Intensity": 24, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1959, + "Parameters": { + "Intensity": 28, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2009, + "Parameters": { + "Intensity": 31, + "Frequency": 9 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2068, + "Parameters": { + "Intensity": 28, + "Frequency": 72 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2102, + "Parameters": { + "Intensity": 38, + "Frequency": 11 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2151, + "Parameters": { + "Intensity": 27, + "Frequency": 37 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2188, + "Parameters": { + "Intensity": 26, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2229, + "Parameters": { + "Intensity": 28, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2288, + "Parameters": { + "Intensity": 23, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2349, + "Parameters": { + "Intensity": 20, + "Frequency": 31 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2389, + "Parameters": { + "Intensity": 24, + "Frequency": 73 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2420, + "Parameters": { + "Intensity": 27, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2462, + "Parameters": { + "Intensity": 39, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2509, + "Parameters": { + "Intensity": 32, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2546, + "Parameters": { + "Intensity": 24, + "Frequency": 22 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2592, + "Parameters": { + "Intensity": 34, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2656, + "Parameters": { + "Intensity": 28, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2718, + "Parameters": { + "Intensity": 23, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2744, + "Parameters": { + "Intensity": 25, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2802, + "Parameters": { + "Intensity": 30, + "Frequency": 37 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2848, + "Parameters": { + "Intensity": 24, + "Frequency": 77 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2881, + "Parameters": { + "Intensity": 40, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2933, + "Parameters": { + "Intensity": 30, + "Frequency": 55 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2959, + "Parameters": { + "Intensity": 24, + "Frequency": 32 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3004, + "Parameters": { + "Intensity": 28, + "Frequency": 27 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3051, + "Parameters": { + "Intensity": 30, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3095, + "Parameters": { + "Intensity": 23, + "Frequency": 11 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3144, + "Parameters": { + "Intensity": 28, + "Frequency": 35 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3182, + "Parameters": { + "Intensity": 26, + "Frequency": 66 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3215, + "Parameters": { + "Intensity": 40, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3275, + "Parameters": { + "Intensity": 29, + "Frequency": 36 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3315, + "Parameters": { + "Intensity": 25, + "Frequency": 16 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3363, + "Parameters": { + "Intensity": 22, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3410, + "Parameters": { + "Intensity": 31, + "Frequency": 24 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3451, + "Parameters": { + "Intensity": 25, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3482, + "Parameters": { + "Intensity": 36, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3530, + "Parameters": { + "Intensity": 26, + "Frequency": 62 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3567, + "Parameters": { + "Intensity": 27, + "Frequency": 16 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3614, + "Parameters": { + "Intensity": 41, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3660, + "Parameters": { + "Intensity": 33, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3731, + "Parameters": { + "Intensity": 25, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3770, + "Parameters": { + "Intensity": 28, + "Frequency": 26 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3810, + "Parameters": { + "Intensity": 30, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3851, + "Parameters": { + "Intensity": 28, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3899, + "Parameters": { + "Intensity": 23, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3937, + "Parameters": { + "Intensity": 28, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3965, + "Parameters": { + "Intensity": 39, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4014, + "Parameters": { + "Intensity": 24, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4058, + "Parameters": { + "Intensity": 28, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4090, + "Parameters": { + "Intensity": 25, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4122, + "Parameters": { + "Intensity": 32, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4170, + "Parameters": { + "Intensity": 26, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4213, + "Parameters": { + "Intensity": 24, + "Frequency": 77 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4238, + "Parameters": { + "Intensity": 36, + "Frequency": 26 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4282, + "Parameters": { + "Intensity": 40, + "Frequency": 40 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4330, + "Parameters": { + "Intensity": 23, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4375, + "Parameters": { + "Intensity": 32, + "Frequency": 25 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4418, + "Parameters": { + "Intensity": 28, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4467, + "Parameters": { + "Intensity": 22, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4495, + "Parameters": { + "Intensity": 28, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4536, + "Parameters": { + "Intensity": 23, + "Frequency": 10 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4598, + "Parameters": { + "Intensity": 30, + "Frequency": 22 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4645, + "Parameters": { + "Intensity": 16, + "Frequency": 56 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_h.json index 6b5ee2b70a..b1994b8bf8 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_h.json @@ -1,37 +1,37 @@ -{ - "MetaData": { - "Create": "2020-08-10", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 0, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 35, - "Parameters": { - "Intensity": 100, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2020-08-10", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 0, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 35, + "Parameters": { + "Intensity": 100, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_l.json index 6facf8791d..f72f07b7c4 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_l.json @@ -1,37 +1,37 @@ -{ - "MetaData": { - "Create": "2020-08-10", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 0, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 35, - "Parameters": { - "Intensity": 60, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2020-08-10", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 0, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 35, + "Parameters": { + "Intensity": 60, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_m.json index 2a392fb4eb..b0759ad0e2 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Rifle_m.json @@ -1,37 +1,37 @@ -{ - "MetaData": { - "Create": "2020-08-10", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 0, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 35, - "Parameters": { - "Intensity": 80, - "Frequency": 100 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2020-08-10", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 0, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 35, + "Parameters": { + "Intensity": 80, + "Frequency": 100 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_h.json index bb1c88da23..89608bc0ac 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_h.json @@ -1,620 +1,620 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 380, - "StartTime": 100, - "Parameters": { - "Intensity": 34, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 61, - "Intensity": 0.48, - "Frequency": 0 - }, - { - "Time": 148, - "Intensity": 0.35, - "Frequency": 0 - }, - { - "Time": 183, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 275, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 320, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 379, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 380, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 385, - "StartTime": 103, - "Parameters": { - "Intensity": 81, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 17, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 383, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 385, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 156, - "StartTime": 491, - "Parameters": { - "Intensity": 75, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -25 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": -30 - }, - { - "Time": 46, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 156, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 340, - "StartTime": 983, - "Parameters": { - "Intensity": 96, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 45, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 69, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 129, - "Intensity": 0.86, - "Frequency": 0 - }, - { - "Time": 163, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 197, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 241, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 278, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 340, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 340, - "StartTime": 995, - "Parameters": { - "Intensity": 100, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 45, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 163, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 197, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 340, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1042, - "StartTime": 1518, - "Parameters": { - "Intensity": 55, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 142, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 224, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 297, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 374, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 444, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 510, - "Intensity": 0.28, - "Frequency": 0 - }, - { - "Time": 578, - "Intensity": 0.45, - "Frequency": 0 - }, - { - "Time": 709, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 756, - "Intensity": 0.79, - "Frequency": 0 - }, - { - "Time": 815, - "Intensity": 0.49, - "Frequency": 0 - }, - { - "Time": 857, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 895, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 984, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 1042, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1042, - "StartTime": 1530, - "Parameters": { - "Intensity": 85, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 653, - "Intensity": 0.41, - "Frequency": 0 - }, - { - "Time": 821, - "Intensity": 0.85, - "Frequency": 0 - }, - { - "Time": 1042, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 469, - "StartTime": 2573, - "Parameters": { - "Intensity": 80, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 78, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 251, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 307, - "Intensity": 0.96, - "Frequency": 6 - }, - { - "Time": 407, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 468, - "Intensity": 0.36, - "Frequency": 5 - }, - { - "Time": 469, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 460, - "StartTime": 2590, - "Parameters": { - "Intensity": 50, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 57, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 110, - "Intensity": 0.2, - "Frequency": 17 - }, - { - "Time": 166, - "Intensity": 0.51, - "Frequency": 30 - }, - { - "Time": 214, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 280, - "Intensity": 1, - "Frequency": 6 - }, - { - "Time": 327, - "Intensity": 0.69, - "Frequency": 0 - }, - { - "Time": 336, - "Intensity": 0.92, - "Frequency": 10 - }, - { - "Time": 385, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 403, - "Intensity": 0.56, - "Frequency": 0 - }, - { - "Time": 459, - "Intensity": 0.3, - "Frequency": 0 - }, - { - "Time": 460, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 929, - "StartTime": 3042, - "Parameters": { - "Intensity": 70, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.42, - "Frequency": 0 - }, - { - "Time": 180, - "Intensity": 0.43, - "Frequency": 0 - }, - { - "Time": 290, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 428, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 929, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 900, - "StartTime": 3050, - "Parameters": { - "Intensity": 46, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 0.57, - "Frequency": 0 - }, - { - "Time": 98, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 144, - "Intensity": 0.61, - "Frequency": 0 - }, - { - "Time": 199, - "Intensity": 0.41, - "Frequency": 0 - }, - { - "Time": 261, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 346, - "Intensity": 0.35, - "Frequency": 0 - }, - { - "Time": 390, - "Intensity": 0.56, - "Frequency": 0 - }, - { - "Time": 463, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 492, - "Intensity": 0.48, - "Frequency": 0 - }, - { - "Time": 575, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 602, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 682, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 706, - "Intensity": 0.23, - "Frequency": 0 - }, - { - "Time": 900, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 380, + "StartTime": 100, + "Parameters": { + "Intensity": 34, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 61, + "Intensity": 0.48, + "Frequency": 0 + }, + { + "Time": 148, + "Intensity": 0.35, + "Frequency": 0 + }, + { + "Time": 183, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 275, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 320, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 379, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 380, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 385, + "StartTime": 103, + "Parameters": { + "Intensity": 81, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 17, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 383, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 385, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 156, + "StartTime": 491, + "Parameters": { + "Intensity": 75, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -25 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": -30 + }, + { + "Time": 46, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 156, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 340, + "StartTime": 983, + "Parameters": { + "Intensity": 96, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 45, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 69, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 129, + "Intensity": 0.86, + "Frequency": 0 + }, + { + "Time": 163, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 197, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 241, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 278, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 340, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 340, + "StartTime": 995, + "Parameters": { + "Intensity": 100, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 45, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 163, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 197, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 340, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1042, + "StartTime": 1518, + "Parameters": { + "Intensity": 55, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 142, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 224, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 297, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 374, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 444, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 510, + "Intensity": 0.28, + "Frequency": 0 + }, + { + "Time": 578, + "Intensity": 0.45, + "Frequency": 0 + }, + { + "Time": 709, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 756, + "Intensity": 0.79, + "Frequency": 0 + }, + { + "Time": 815, + "Intensity": 0.49, + "Frequency": 0 + }, + { + "Time": 857, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 895, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 984, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 1042, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1042, + "StartTime": 1530, + "Parameters": { + "Intensity": 85, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 653, + "Intensity": 0.41, + "Frequency": 0 + }, + { + "Time": 821, + "Intensity": 0.85, + "Frequency": 0 + }, + { + "Time": 1042, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 469, + "StartTime": 2573, + "Parameters": { + "Intensity": 80, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 78, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 251, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 307, + "Intensity": 0.96, + "Frequency": 6 + }, + { + "Time": 407, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 468, + "Intensity": 0.36, + "Frequency": 5 + }, + { + "Time": 469, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 460, + "StartTime": 2590, + "Parameters": { + "Intensity": 50, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 57, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 110, + "Intensity": 0.2, + "Frequency": 17 + }, + { + "Time": 166, + "Intensity": 0.51, + "Frequency": 30 + }, + { + "Time": 214, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 280, + "Intensity": 1, + "Frequency": 6 + }, + { + "Time": 327, + "Intensity": 0.69, + "Frequency": 0 + }, + { + "Time": 336, + "Intensity": 0.92, + "Frequency": 10 + }, + { + "Time": 385, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 403, + "Intensity": 0.56, + "Frequency": 0 + }, + { + "Time": 459, + "Intensity": 0.3, + "Frequency": 0 + }, + { + "Time": 460, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 929, + "StartTime": 3042, + "Parameters": { + "Intensity": 70, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.42, + "Frequency": 0 + }, + { + "Time": 180, + "Intensity": 0.43, + "Frequency": 0 + }, + { + "Time": 290, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 428, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 929, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 900, + "StartTime": 3050, + "Parameters": { + "Intensity": 46, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 0.57, + "Frequency": 0 + }, + { + "Time": 98, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 144, + "Intensity": 0.61, + "Frequency": 0 + }, + { + "Time": 199, + "Intensity": 0.41, + "Frequency": 0 + }, + { + "Time": 261, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 346, + "Intensity": 0.35, + "Frequency": 0 + }, + { + "Time": 390, + "Intensity": 0.56, + "Frequency": 0 + }, + { + "Time": 463, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 492, + "Intensity": 0.48, + "Frequency": 0 + }, + { + "Time": 575, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 602, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 682, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 706, + "Intensity": 0.23, + "Frequency": 0 + }, + { + "Time": 900, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_l.json index a23ee84959..f2b3c06abd 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_l.json @@ -1,620 +1,620 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 380, - "StartTime": 100, - "Parameters": { - "Intensity": 20, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 61, - "Intensity": 0.48, - "Frequency": 0 - }, - { - "Time": 148, - "Intensity": 0.35, - "Frequency": 0 - }, - { - "Time": 183, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 275, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 320, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 379, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 380, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 385, - "StartTime": 103, - "Parameters": { - "Intensity": 48, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 17, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 383, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 385, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 156, - "StartTime": 491, - "Parameters": { - "Intensity": 45, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -25 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": -30 - }, - { - "Time": 46, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 156, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 340, - "StartTime": 983, - "Parameters": { - "Intensity": 57, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 45, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 69, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 129, - "Intensity": 0.86, - "Frequency": 0 - }, - { - "Time": 163, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 197, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 241, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 278, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 340, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 340, - "StartTime": 995, - "Parameters": { - "Intensity": 60, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 45, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 163, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 197, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 340, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1042, - "StartTime": 1518, - "Parameters": { - "Intensity": 33, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 142, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 224, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 297, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 374, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 444, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 510, - "Intensity": 0.28, - "Frequency": 0 - }, - { - "Time": 578, - "Intensity": 0.45, - "Frequency": 0 - }, - { - "Time": 709, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 756, - "Intensity": 0.79, - "Frequency": 0 - }, - { - "Time": 815, - "Intensity": 0.49, - "Frequency": 0 - }, - { - "Time": 857, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 895, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 984, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 1042, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1042, - "StartTime": 1530, - "Parameters": { - "Intensity": 51, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 653, - "Intensity": 0.41, - "Frequency": 0 - }, - { - "Time": 821, - "Intensity": 0.85, - "Frequency": 0 - }, - { - "Time": 1042, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 469, - "StartTime": 2573, - "Parameters": { - "Intensity": 48, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 78, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 251, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 307, - "Intensity": 0.96, - "Frequency": 6 - }, - { - "Time": 407, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 468, - "Intensity": 0.36, - "Frequency": 5 - }, - { - "Time": 469, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 460, - "StartTime": 2590, - "Parameters": { - "Intensity": 30, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 57, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 110, - "Intensity": 0.2, - "Frequency": 17 - }, - { - "Time": 166, - "Intensity": 0.51, - "Frequency": 30 - }, - { - "Time": 214, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 280, - "Intensity": 1, - "Frequency": 6 - }, - { - "Time": 327, - "Intensity": 0.69, - "Frequency": 0 - }, - { - "Time": 336, - "Intensity": 0.92, - "Frequency": 10 - }, - { - "Time": 385, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 403, - "Intensity": 0.56, - "Frequency": 0 - }, - { - "Time": 459, - "Intensity": 0.3, - "Frequency": 0 - }, - { - "Time": 460, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 929, - "StartTime": 3042, - "Parameters": { - "Intensity": 42, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.42, - "Frequency": 0 - }, - { - "Time": 180, - "Intensity": 0.43, - "Frequency": 0 - }, - { - "Time": 290, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 428, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 929, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 900, - "StartTime": 3050, - "Parameters": { - "Intensity": 27, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 0.57, - "Frequency": 0 - }, - { - "Time": 98, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 144, - "Intensity": 0.61, - "Frequency": 0 - }, - { - "Time": 199, - "Intensity": 0.41, - "Frequency": 0 - }, - { - "Time": 261, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 346, - "Intensity": 0.35, - "Frequency": 0 - }, - { - "Time": 390, - "Intensity": 0.56, - "Frequency": 0 - }, - { - "Time": 463, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 492, - "Intensity": 0.48, - "Frequency": 0 - }, - { - "Time": 575, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 602, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 682, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 706, - "Intensity": 0.23, - "Frequency": 0 - }, - { - "Time": 900, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 380, + "StartTime": 100, + "Parameters": { + "Intensity": 20, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 61, + "Intensity": 0.48, + "Frequency": 0 + }, + { + "Time": 148, + "Intensity": 0.35, + "Frequency": 0 + }, + { + "Time": 183, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 275, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 320, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 379, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 380, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 385, + "StartTime": 103, + "Parameters": { + "Intensity": 48, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 17, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 383, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 385, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 156, + "StartTime": 491, + "Parameters": { + "Intensity": 45, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -25 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": -30 + }, + { + "Time": 46, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 156, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 340, + "StartTime": 983, + "Parameters": { + "Intensity": 57, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 45, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 69, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 129, + "Intensity": 0.86, + "Frequency": 0 + }, + { + "Time": 163, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 197, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 241, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 278, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 340, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 340, + "StartTime": 995, + "Parameters": { + "Intensity": 60, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 45, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 163, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 197, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 340, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1042, + "StartTime": 1518, + "Parameters": { + "Intensity": 33, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 142, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 224, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 297, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 374, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 444, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 510, + "Intensity": 0.28, + "Frequency": 0 + }, + { + "Time": 578, + "Intensity": 0.45, + "Frequency": 0 + }, + { + "Time": 709, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 756, + "Intensity": 0.79, + "Frequency": 0 + }, + { + "Time": 815, + "Intensity": 0.49, + "Frequency": 0 + }, + { + "Time": 857, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 895, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 984, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 1042, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1042, + "StartTime": 1530, + "Parameters": { + "Intensity": 51, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 653, + "Intensity": 0.41, + "Frequency": 0 + }, + { + "Time": 821, + "Intensity": 0.85, + "Frequency": 0 + }, + { + "Time": 1042, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 469, + "StartTime": 2573, + "Parameters": { + "Intensity": 48, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 78, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 251, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 307, + "Intensity": 0.96, + "Frequency": 6 + }, + { + "Time": 407, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 468, + "Intensity": 0.36, + "Frequency": 5 + }, + { + "Time": 469, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 460, + "StartTime": 2590, + "Parameters": { + "Intensity": 30, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 57, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 110, + "Intensity": 0.2, + "Frequency": 17 + }, + { + "Time": 166, + "Intensity": 0.51, + "Frequency": 30 + }, + { + "Time": 214, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 280, + "Intensity": 1, + "Frequency": 6 + }, + { + "Time": 327, + "Intensity": 0.69, + "Frequency": 0 + }, + { + "Time": 336, + "Intensity": 0.92, + "Frequency": 10 + }, + { + "Time": 385, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 403, + "Intensity": 0.56, + "Frequency": 0 + }, + { + "Time": 459, + "Intensity": 0.3, + "Frequency": 0 + }, + { + "Time": 460, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 929, + "StartTime": 3042, + "Parameters": { + "Intensity": 42, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.42, + "Frequency": 0 + }, + { + "Time": 180, + "Intensity": 0.43, + "Frequency": 0 + }, + { + "Time": 290, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 428, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 929, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 900, + "StartTime": 3050, + "Parameters": { + "Intensity": 27, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 0.57, + "Frequency": 0 + }, + { + "Time": 98, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 144, + "Intensity": 0.61, + "Frequency": 0 + }, + { + "Time": 199, + "Intensity": 0.41, + "Frequency": 0 + }, + { + "Time": 261, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 346, + "Intensity": 0.35, + "Frequency": 0 + }, + { + "Time": 390, + "Intensity": 0.56, + "Frequency": 0 + }, + { + "Time": 463, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 492, + "Intensity": 0.48, + "Frequency": 0 + }, + { + "Time": 575, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 602, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 682, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 706, + "Intensity": 0.23, + "Frequency": 0 + }, + { + "Time": 900, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_m.json index f12fa64eb4..3e5fe1fdc0 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skating_m.json @@ -1,620 +1,620 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 380, - "StartTime": 100, - "Parameters": { - "Intensity": 27, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 61, - "Intensity": 0.48, - "Frequency": 0 - }, - { - "Time": 148, - "Intensity": 0.35, - "Frequency": 0 - }, - { - "Time": 183, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 275, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 320, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 379, - "Intensity": 0.34, - "Frequency": 0 - }, - { - "Time": 380, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 385, - "StartTime": 103, - "Parameters": { - "Intensity": 64, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 17, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 383, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 385, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 156, - "StartTime": 491, - "Parameters": { - "Intensity": 60, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -25 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": -30 - }, - { - "Time": 46, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 156, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 340, - "StartTime": 983, - "Parameters": { - "Intensity": 76, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 45, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 69, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 129, - "Intensity": 0.86, - "Frequency": 0 - }, - { - "Time": 163, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 197, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 241, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 278, - "Intensity": 0.07, - "Frequency": 0 - }, - { - "Time": 340, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 340, - "StartTime": 995, - "Parameters": { - "Intensity": 80, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 45, - "Intensity": 1, - "Frequency": 30 - }, - { - "Time": 163, - "Intensity": 0.93, - "Frequency": 0 - }, - { - "Time": 197, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 340, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1042, - "StartTime": 1518, - "Parameters": { - "Intensity": 44, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 142, - "Intensity": 0.22, - "Frequency": 0 - }, - { - "Time": 224, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 297, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 374, - "Intensity": 0.25, - "Frequency": 0 - }, - { - "Time": 444, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 510, - "Intensity": 0.28, - "Frequency": 0 - }, - { - "Time": 578, - "Intensity": 0.45, - "Frequency": 0 - }, - { - "Time": 709, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 756, - "Intensity": 0.79, - "Frequency": 0 - }, - { - "Time": 815, - "Intensity": 0.49, - "Frequency": 0 - }, - { - "Time": 857, - "Intensity": 0.77, - "Frequency": 0 - }, - { - "Time": 895, - "Intensity": 0.21, - "Frequency": 0 - }, - { - "Time": 984, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 1042, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1042, - "StartTime": 1530, - "Parameters": { - "Intensity": 68, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 653, - "Intensity": 0.41, - "Frequency": 0 - }, - { - "Time": 821, - "Intensity": 0.85, - "Frequency": 0 - }, - { - "Time": 1042, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 469, - "StartTime": 2573, - "Parameters": { - "Intensity": 64, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 78, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 251, - "Intensity": 0.47, - "Frequency": 0 - }, - { - "Time": 307, - "Intensity": 0.96, - "Frequency": 6 - }, - { - "Time": 407, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 468, - "Intensity": 0.36, - "Frequency": 5 - }, - { - "Time": 469, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 460, - "StartTime": 2590, - "Parameters": { - "Intensity": 40, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 57, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 110, - "Intensity": 0.2, - "Frequency": 17 - }, - { - "Time": 166, - "Intensity": 0.51, - "Frequency": 30 - }, - { - "Time": 214, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 280, - "Intensity": 1, - "Frequency": 6 - }, - { - "Time": 327, - "Intensity": 0.69, - "Frequency": 0 - }, - { - "Time": 336, - "Intensity": 0.92, - "Frequency": 10 - }, - { - "Time": 385, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 403, - "Intensity": 0.56, - "Frequency": 0 - }, - { - "Time": 459, - "Intensity": 0.3, - "Frequency": 0 - }, - { - "Time": 460, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 929, - "StartTime": 3042, - "Parameters": { - "Intensity": 56, - "Frequency": 80, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.42, - "Frequency": 0 - }, - { - "Time": 180, - "Intensity": 0.43, - "Frequency": 0 - }, - { - "Time": 290, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 428, - "Intensity": 0.39, - "Frequency": 0 - }, - { - "Time": 929, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 900, - "StartTime": 3050, - "Parameters": { - "Intensity": 36, - "Frequency": 100, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 0.57, - "Frequency": 0 - }, - { - "Time": 98, - "Intensity": 0.33, - "Frequency": 0 - }, - { - "Time": 144, - "Intensity": 0.61, - "Frequency": 0 - }, - { - "Time": 199, - "Intensity": 0.41, - "Frequency": 0 - }, - { - "Time": 261, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 346, - "Intensity": 0.35, - "Frequency": 0 - }, - { - "Time": 390, - "Intensity": 0.56, - "Frequency": 0 - }, - { - "Time": 463, - "Intensity": 0.29, - "Frequency": 0 - }, - { - "Time": 492, - "Intensity": 0.48, - "Frequency": 0 - }, - { - "Time": 575, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 602, - "Intensity": 0.32, - "Frequency": 0 - }, - { - "Time": 682, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 706, - "Intensity": 0.23, - "Frequency": 0 - }, - { - "Time": 900, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 380, + "StartTime": 100, + "Parameters": { + "Intensity": 27, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 61, + "Intensity": 0.48, + "Frequency": 0 + }, + { + "Time": 148, + "Intensity": 0.35, + "Frequency": 0 + }, + { + "Time": 183, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 275, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 320, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 379, + "Intensity": 0.34, + "Frequency": 0 + }, + { + "Time": 380, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 385, + "StartTime": 103, + "Parameters": { + "Intensity": 64, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 17, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 383, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 385, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 156, + "StartTime": 491, + "Parameters": { + "Intensity": 60, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -25 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": -30 + }, + { + "Time": 46, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 156, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 340, + "StartTime": 983, + "Parameters": { + "Intensity": 76, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 45, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 69, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 129, + "Intensity": 0.86, + "Frequency": 0 + }, + { + "Time": 163, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 197, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 241, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 278, + "Intensity": 0.07, + "Frequency": 0 + }, + { + "Time": 340, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 340, + "StartTime": 995, + "Parameters": { + "Intensity": 80, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 45, + "Intensity": 1, + "Frequency": 30 + }, + { + "Time": 163, + "Intensity": 0.93, + "Frequency": 0 + }, + { + "Time": 197, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 340, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1042, + "StartTime": 1518, + "Parameters": { + "Intensity": 44, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 142, + "Intensity": 0.22, + "Frequency": 0 + }, + { + "Time": 224, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 297, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 374, + "Intensity": 0.25, + "Frequency": 0 + }, + { + "Time": 444, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 510, + "Intensity": 0.28, + "Frequency": 0 + }, + { + "Time": 578, + "Intensity": 0.45, + "Frequency": 0 + }, + { + "Time": 709, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 756, + "Intensity": 0.79, + "Frequency": 0 + }, + { + "Time": 815, + "Intensity": 0.49, + "Frequency": 0 + }, + { + "Time": 857, + "Intensity": 0.77, + "Frequency": 0 + }, + { + "Time": 895, + "Intensity": 0.21, + "Frequency": 0 + }, + { + "Time": 984, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 1042, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1042, + "StartTime": 1530, + "Parameters": { + "Intensity": 68, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 653, + "Intensity": 0.41, + "Frequency": 0 + }, + { + "Time": 821, + "Intensity": 0.85, + "Frequency": 0 + }, + { + "Time": 1042, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 469, + "StartTime": 2573, + "Parameters": { + "Intensity": 64, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 78, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 251, + "Intensity": 0.47, + "Frequency": 0 + }, + { + "Time": 307, + "Intensity": 0.96, + "Frequency": 6 + }, + { + "Time": 407, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 468, + "Intensity": 0.36, + "Frequency": 5 + }, + { + "Time": 469, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 460, + "StartTime": 2590, + "Parameters": { + "Intensity": 40, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 57, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 110, + "Intensity": 0.2, + "Frequency": 17 + }, + { + "Time": 166, + "Intensity": 0.51, + "Frequency": 30 + }, + { + "Time": 214, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 280, + "Intensity": 1, + "Frequency": 6 + }, + { + "Time": 327, + "Intensity": 0.69, + "Frequency": 0 + }, + { + "Time": 336, + "Intensity": 0.92, + "Frequency": 10 + }, + { + "Time": 385, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 403, + "Intensity": 0.56, + "Frequency": 0 + }, + { + "Time": 459, + "Intensity": 0.3, + "Frequency": 0 + }, + { + "Time": 460, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 929, + "StartTime": 3042, + "Parameters": { + "Intensity": 56, + "Frequency": 80, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.42, + "Frequency": 0 + }, + { + "Time": 180, + "Intensity": 0.43, + "Frequency": 0 + }, + { + "Time": 290, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 428, + "Intensity": 0.39, + "Frequency": 0 + }, + { + "Time": 929, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 900, + "StartTime": 3050, + "Parameters": { + "Intensity": 36, + "Frequency": 100, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 0.57, + "Frequency": 0 + }, + { + "Time": 98, + "Intensity": 0.33, + "Frequency": 0 + }, + { + "Time": 144, + "Intensity": 0.61, + "Frequency": 0 + }, + { + "Time": 199, + "Intensity": 0.41, + "Frequency": 0 + }, + { + "Time": 261, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 346, + "Intensity": 0.35, + "Frequency": 0 + }, + { + "Time": 390, + "Intensity": 0.56, + "Frequency": 0 + }, + { + "Time": 463, + "Intensity": 0.29, + "Frequency": 0 + }, + { + "Time": 492, + "Intensity": 0.48, + "Frequency": 0 + }, + { + "Time": 575, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 602, + "Intensity": 0.32, + "Frequency": 0 + }, + { + "Time": 682, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 706, + "Intensity": 0.23, + "Frequency": 0 + }, + { + "Time": 900, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_h.json index 6e7d2c3546..f00634ac3e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_h.json @@ -1,490 +1,490 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 1848, - "StartTime": 128, - "Parameters": { - "Intensity": 42, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 364, - "Intensity": 0.81, - "Frequency": 0 - }, - { - "Time": 558, - "Intensity": 0.89, - "Frequency": 5 - }, - { - "Time": 682, - "Intensity": 0.98, - "Frequency": 10 - }, - { - "Time": 806, - "Intensity": 0.79, - "Frequency": 4 - }, - { - "Time": 902, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 1009, - "Intensity": 0.44, - "Frequency": -2 - }, - { - "Time": 1190, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 1312, - "Intensity": 0.85, - "Frequency": 4 - }, - { - "Time": 1425, - "Intensity": 0.95, - "Frequency": 10 - }, - { - "Time": 1724, - "Intensity": 0.65, - "Frequency": 2 - }, - { - "Time": 1841, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 1848, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1848, - "StartTime": 135, - "Parameters": { - "Intensity": 29, - "Frequency": 63, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 126, - "Intensity": 0.52, - "Frequency": 0 - }, - { - "Time": 248, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 333, - "Intensity": 0.76, - "Frequency": 0 - }, - { - "Time": 455, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 558, - "Intensity": 0.89, - "Frequency": 5 - }, - { - "Time": 682, - "Intensity": 0.98, - "Frequency": 10 - }, - { - "Time": 848, - "Intensity": 0.73, - "Frequency": 4 - }, - { - "Time": 972, - "Intensity": 0.43, - "Frequency": 0 - }, - { - "Time": 1037, - "Intensity": 0.66, - "Frequency": -2 - }, - { - "Time": 1146, - "Intensity": 0.5, - "Frequency": 0 - }, - { - "Time": 1242, - "Intensity": 0.84, - "Frequency": 4 - }, - { - "Time": 1425, - "Intensity": 0.95, - "Frequency": 10 - }, - { - "Time": 1724, - "Intensity": 0.65, - "Frequency": 2 - }, - { - "Time": 1841, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 1848, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 260, - "StartTime": 2005, - "Parameters": { - "Intensity": 100, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.98, - "Frequency": 0 - }, - { - "Time": 61, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 104, - "Intensity": 0.97, - "Frequency": 4 - }, - { - "Time": 139, - "Intensity": 1, - "Frequency": 9 - }, - { - "Time": 171, - "Intensity": 0.45, - "Frequency": 10 - }, - { - "Time": 241, - "Intensity": 0.41, - "Frequency": 2 - }, - { - "Time": 259, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 260, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2220, - "Parameters": { - "Intensity": 54, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2296, - "Parameters": { - "Intensity": 31, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 260, - "StartTime": 2378, - "Parameters": { - "Intensity": 69, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.98, - "Frequency": 0 - }, - { - "Time": 61, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 104, - "Intensity": 0.97, - "Frequency": 4 - }, - { - "Time": 139, - "Intensity": 1, - "Frequency": 9 - }, - { - "Time": 171, - "Intensity": 0.45, - "Frequency": 10 - }, - { - "Time": 241, - "Intensity": 0.41, - "Frequency": 2 - }, - { - "Time": 259, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 260, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2586, - "Parameters": { - "Intensity": 40, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 634, - "StartTime": 2638, - "Parameters": { - "Intensity": 29, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.54, - "Frequency": 0 - }, - { - "Time": 106, - "Intensity": 0.68, - "Frequency": 5 - }, - { - "Time": 208, - "Intensity": 0.73, - "Frequency": 10 - }, - { - "Time": 277, - "Intensity": 0.67, - "Frequency": 4 - }, - { - "Time": 309, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 346, - "Intensity": 0.44, - "Frequency": -2 - }, - { - "Time": 408, - "Intensity": 0.52, - "Frequency": 0 - }, - { - "Time": 464, - "Intensity": 0.51, - "Frequency": 4 - }, - { - "Time": 509, - "Intensity": 0.35, - "Frequency": 10 - }, - { - "Time": 569, - "Intensity": 0.26, - "Frequency": 2 - }, - { - "Time": 611, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 634, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 634, - "StartTime": 2640, - "Parameters": { - "Intensity": 19, - "Frequency": 63, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.54, - "Frequency": 0 - }, - { - "Time": 110, - "Intensity": 0.75, - "Frequency": 5 - }, - { - "Time": 182, - "Intensity": 0.45, - "Frequency": 10 - }, - { - "Time": 232, - "Intensity": 0.69, - "Frequency": 4 - }, - { - "Time": 309, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 346, - "Intensity": 0.44, - "Frequency": -2 - }, - { - "Time": 408, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 455, - "Intensity": 0.35, - "Frequency": 4 - }, - { - "Time": 515, - "Intensity": 0.24, - "Frequency": 10 - }, - { - "Time": 566, - "Intensity": 0.38, - "Frequency": 2 - }, - { - "Time": 611, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 634, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 1848, + "StartTime": 128, + "Parameters": { + "Intensity": 42, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 364, + "Intensity": 0.81, + "Frequency": 0 + }, + { + "Time": 558, + "Intensity": 0.89, + "Frequency": 5 + }, + { + "Time": 682, + "Intensity": 0.98, + "Frequency": 10 + }, + { + "Time": 806, + "Intensity": 0.79, + "Frequency": 4 + }, + { + "Time": 902, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 1009, + "Intensity": 0.44, + "Frequency": -2 + }, + { + "Time": 1190, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 1312, + "Intensity": 0.85, + "Frequency": 4 + }, + { + "Time": 1425, + "Intensity": 0.95, + "Frequency": 10 + }, + { + "Time": 1724, + "Intensity": 0.65, + "Frequency": 2 + }, + { + "Time": 1841, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 1848, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1848, + "StartTime": 135, + "Parameters": { + "Intensity": 29, + "Frequency": 63, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 126, + "Intensity": 0.52, + "Frequency": 0 + }, + { + "Time": 248, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 333, + "Intensity": 0.76, + "Frequency": 0 + }, + { + "Time": 455, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 558, + "Intensity": 0.89, + "Frequency": 5 + }, + { + "Time": 682, + "Intensity": 0.98, + "Frequency": 10 + }, + { + "Time": 848, + "Intensity": 0.73, + "Frequency": 4 + }, + { + "Time": 972, + "Intensity": 0.43, + "Frequency": 0 + }, + { + "Time": 1037, + "Intensity": 0.66, + "Frequency": -2 + }, + { + "Time": 1146, + "Intensity": 0.5, + "Frequency": 0 + }, + { + "Time": 1242, + "Intensity": 0.84, + "Frequency": 4 + }, + { + "Time": 1425, + "Intensity": 0.95, + "Frequency": 10 + }, + { + "Time": 1724, + "Intensity": 0.65, + "Frequency": 2 + }, + { + "Time": 1841, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 1848, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 260, + "StartTime": 2005, + "Parameters": { + "Intensity": 100, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.98, + "Frequency": 0 + }, + { + "Time": 61, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 104, + "Intensity": 0.97, + "Frequency": 4 + }, + { + "Time": 139, + "Intensity": 1, + "Frequency": 9 + }, + { + "Time": 171, + "Intensity": 0.45, + "Frequency": 10 + }, + { + "Time": 241, + "Intensity": 0.41, + "Frequency": 2 + }, + { + "Time": 259, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 260, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2220, + "Parameters": { + "Intensity": 54, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2296, + "Parameters": { + "Intensity": 31, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 260, + "StartTime": 2378, + "Parameters": { + "Intensity": 69, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.98, + "Frequency": 0 + }, + { + "Time": 61, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 104, + "Intensity": 0.97, + "Frequency": 4 + }, + { + "Time": 139, + "Intensity": 1, + "Frequency": 9 + }, + { + "Time": 171, + "Intensity": 0.45, + "Frequency": 10 + }, + { + "Time": 241, + "Intensity": 0.41, + "Frequency": 2 + }, + { + "Time": 259, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 260, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2586, + "Parameters": { + "Intensity": 40, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 634, + "StartTime": 2638, + "Parameters": { + "Intensity": 29, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.54, + "Frequency": 0 + }, + { + "Time": 106, + "Intensity": 0.68, + "Frequency": 5 + }, + { + "Time": 208, + "Intensity": 0.73, + "Frequency": 10 + }, + { + "Time": 277, + "Intensity": 0.67, + "Frequency": 4 + }, + { + "Time": 309, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 346, + "Intensity": 0.44, + "Frequency": -2 + }, + { + "Time": 408, + "Intensity": 0.52, + "Frequency": 0 + }, + { + "Time": 464, + "Intensity": 0.51, + "Frequency": 4 + }, + { + "Time": 509, + "Intensity": 0.35, + "Frequency": 10 + }, + { + "Time": 569, + "Intensity": 0.26, + "Frequency": 2 + }, + { + "Time": 611, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 634, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 634, + "StartTime": 2640, + "Parameters": { + "Intensity": 19, + "Frequency": 63, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.54, + "Frequency": 0 + }, + { + "Time": 110, + "Intensity": 0.75, + "Frequency": 5 + }, + { + "Time": 182, + "Intensity": 0.45, + "Frequency": 10 + }, + { + "Time": 232, + "Intensity": 0.69, + "Frequency": 4 + }, + { + "Time": 309, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 346, + "Intensity": 0.44, + "Frequency": -2 + }, + { + "Time": 408, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 455, + "Intensity": 0.35, + "Frequency": 4 + }, + { + "Time": 515, + "Intensity": 0.24, + "Frequency": 10 + }, + { + "Time": 566, + "Intensity": 0.38, + "Frequency": 2 + }, + { + "Time": 611, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 634, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_l.json index 05bedae360..12fb05af93 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_l.json @@ -1,490 +1,490 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 1848, - "StartTime": 128, - "Parameters": { - "Intensity": 25, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 364, - "Intensity": 0.81, - "Frequency": 0 - }, - { - "Time": 558, - "Intensity": 0.89, - "Frequency": 5 - }, - { - "Time": 682, - "Intensity": 0.98, - "Frequency": 10 - }, - { - "Time": 806, - "Intensity": 0.79, - "Frequency": 4 - }, - { - "Time": 902, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 1009, - "Intensity": 0.44, - "Frequency": -2 - }, - { - "Time": 1190, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 1312, - "Intensity": 0.85, - "Frequency": 4 - }, - { - "Time": 1425, - "Intensity": 0.95, - "Frequency": 10 - }, - { - "Time": 1724, - "Intensity": 0.65, - "Frequency": 2 - }, - { - "Time": 1841, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 1848, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1848, - "StartTime": 135, - "Parameters": { - "Intensity": 17, - "Frequency": 63, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 126, - "Intensity": 0.52, - "Frequency": 0 - }, - { - "Time": 248, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 333, - "Intensity": 0.76, - "Frequency": 0 - }, - { - "Time": 455, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 558, - "Intensity": 0.89, - "Frequency": 5 - }, - { - "Time": 682, - "Intensity": 0.98, - "Frequency": 10 - }, - { - "Time": 848, - "Intensity": 0.73, - "Frequency": 4 - }, - { - "Time": 972, - "Intensity": 0.43, - "Frequency": 0 - }, - { - "Time": 1037, - "Intensity": 0.66, - "Frequency": -2 - }, - { - "Time": 1146, - "Intensity": 0.5, - "Frequency": 0 - }, - { - "Time": 1242, - "Intensity": 0.84, - "Frequency": 4 - }, - { - "Time": 1425, - "Intensity": 0.95, - "Frequency": 10 - }, - { - "Time": 1724, - "Intensity": 0.65, - "Frequency": 2 - }, - { - "Time": 1841, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 1848, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 260, - "StartTime": 2005, - "Parameters": { - "Intensity": 60, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.98, - "Frequency": 0 - }, - { - "Time": 61, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 104, - "Intensity": 0.97, - "Frequency": 4 - }, - { - "Time": 139, - "Intensity": 1, - "Frequency": 9 - }, - { - "Time": 171, - "Intensity": 0.45, - "Frequency": 10 - }, - { - "Time": 241, - "Intensity": 0.41, - "Frequency": 2 - }, - { - "Time": 259, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 260, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2220, - "Parameters": { - "Intensity": 32, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2296, - "Parameters": { - "Intensity": 18, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 260, - "StartTime": 2378, - "Parameters": { - "Intensity": 41, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.98, - "Frequency": 0 - }, - { - "Time": 61, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 104, - "Intensity": 0.97, - "Frequency": 4 - }, - { - "Time": 139, - "Intensity": 1, - "Frequency": 9 - }, - { - "Time": 171, - "Intensity": 0.45, - "Frequency": 10 - }, - { - "Time": 241, - "Intensity": 0.41, - "Frequency": 2 - }, - { - "Time": 259, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 260, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2586, - "Parameters": { - "Intensity": 24, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 634, - "StartTime": 2638, - "Parameters": { - "Intensity": 17, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.54, - "Frequency": 0 - }, - { - "Time": 106, - "Intensity": 0.68, - "Frequency": 5 - }, - { - "Time": 208, - "Intensity": 0.73, - "Frequency": 10 - }, - { - "Time": 277, - "Intensity": 0.67, - "Frequency": 4 - }, - { - "Time": 309, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 346, - "Intensity": 0.44, - "Frequency": -2 - }, - { - "Time": 408, - "Intensity": 0.52, - "Frequency": 0 - }, - { - "Time": 464, - "Intensity": 0.51, - "Frequency": 4 - }, - { - "Time": 509, - "Intensity": 0.35, - "Frequency": 10 - }, - { - "Time": 569, - "Intensity": 0.26, - "Frequency": 2 - }, - { - "Time": 611, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 634, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 634, - "StartTime": 2640, - "Parameters": { - "Intensity": 11, - "Frequency": 63, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.54, - "Frequency": 0 - }, - { - "Time": 110, - "Intensity": 0.75, - "Frequency": 5 - }, - { - "Time": 182, - "Intensity": 0.45, - "Frequency": 10 - }, - { - "Time": 232, - "Intensity": 0.69, - "Frequency": 4 - }, - { - "Time": 309, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 346, - "Intensity": 0.44, - "Frequency": -2 - }, - { - "Time": 408, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 455, - "Intensity": 0.35, - "Frequency": 4 - }, - { - "Time": 515, - "Intensity": 0.24, - "Frequency": 10 - }, - { - "Time": 566, - "Intensity": 0.38, - "Frequency": 2 - }, - { - "Time": 611, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 634, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 1848, + "StartTime": 128, + "Parameters": { + "Intensity": 25, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 364, + "Intensity": 0.81, + "Frequency": 0 + }, + { + "Time": 558, + "Intensity": 0.89, + "Frequency": 5 + }, + { + "Time": 682, + "Intensity": 0.98, + "Frequency": 10 + }, + { + "Time": 806, + "Intensity": 0.79, + "Frequency": 4 + }, + { + "Time": 902, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 1009, + "Intensity": 0.44, + "Frequency": -2 + }, + { + "Time": 1190, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 1312, + "Intensity": 0.85, + "Frequency": 4 + }, + { + "Time": 1425, + "Intensity": 0.95, + "Frequency": 10 + }, + { + "Time": 1724, + "Intensity": 0.65, + "Frequency": 2 + }, + { + "Time": 1841, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 1848, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1848, + "StartTime": 135, + "Parameters": { + "Intensity": 17, + "Frequency": 63, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 126, + "Intensity": 0.52, + "Frequency": 0 + }, + { + "Time": 248, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 333, + "Intensity": 0.76, + "Frequency": 0 + }, + { + "Time": 455, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 558, + "Intensity": 0.89, + "Frequency": 5 + }, + { + "Time": 682, + "Intensity": 0.98, + "Frequency": 10 + }, + { + "Time": 848, + "Intensity": 0.73, + "Frequency": 4 + }, + { + "Time": 972, + "Intensity": 0.43, + "Frequency": 0 + }, + { + "Time": 1037, + "Intensity": 0.66, + "Frequency": -2 + }, + { + "Time": 1146, + "Intensity": 0.5, + "Frequency": 0 + }, + { + "Time": 1242, + "Intensity": 0.84, + "Frequency": 4 + }, + { + "Time": 1425, + "Intensity": 0.95, + "Frequency": 10 + }, + { + "Time": 1724, + "Intensity": 0.65, + "Frequency": 2 + }, + { + "Time": 1841, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 1848, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 260, + "StartTime": 2005, + "Parameters": { + "Intensity": 60, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.98, + "Frequency": 0 + }, + { + "Time": 61, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 104, + "Intensity": 0.97, + "Frequency": 4 + }, + { + "Time": 139, + "Intensity": 1, + "Frequency": 9 + }, + { + "Time": 171, + "Intensity": 0.45, + "Frequency": 10 + }, + { + "Time": 241, + "Intensity": 0.41, + "Frequency": 2 + }, + { + "Time": 259, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 260, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2220, + "Parameters": { + "Intensity": 32, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2296, + "Parameters": { + "Intensity": 18, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 260, + "StartTime": 2378, + "Parameters": { + "Intensity": 41, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.98, + "Frequency": 0 + }, + { + "Time": 61, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 104, + "Intensity": 0.97, + "Frequency": 4 + }, + { + "Time": 139, + "Intensity": 1, + "Frequency": 9 + }, + { + "Time": 171, + "Intensity": 0.45, + "Frequency": 10 + }, + { + "Time": 241, + "Intensity": 0.41, + "Frequency": 2 + }, + { + "Time": 259, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 260, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2586, + "Parameters": { + "Intensity": 24, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 634, + "StartTime": 2638, + "Parameters": { + "Intensity": 17, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.54, + "Frequency": 0 + }, + { + "Time": 106, + "Intensity": 0.68, + "Frequency": 5 + }, + { + "Time": 208, + "Intensity": 0.73, + "Frequency": 10 + }, + { + "Time": 277, + "Intensity": 0.67, + "Frequency": 4 + }, + { + "Time": 309, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 346, + "Intensity": 0.44, + "Frequency": -2 + }, + { + "Time": 408, + "Intensity": 0.52, + "Frequency": 0 + }, + { + "Time": 464, + "Intensity": 0.51, + "Frequency": 4 + }, + { + "Time": 509, + "Intensity": 0.35, + "Frequency": 10 + }, + { + "Time": 569, + "Intensity": 0.26, + "Frequency": 2 + }, + { + "Time": 611, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 634, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 634, + "StartTime": 2640, + "Parameters": { + "Intensity": 11, + "Frequency": 63, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.54, + "Frequency": 0 + }, + { + "Time": 110, + "Intensity": 0.75, + "Frequency": 5 + }, + { + "Time": 182, + "Intensity": 0.45, + "Frequency": 10 + }, + { + "Time": 232, + "Intensity": 0.69, + "Frequency": 4 + }, + { + "Time": 309, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 346, + "Intensity": 0.44, + "Frequency": -2 + }, + { + "Time": 408, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 455, + "Intensity": 0.35, + "Frequency": 4 + }, + { + "Time": 515, + "Intensity": 0.24, + "Frequency": 10 + }, + { + "Time": 566, + "Intensity": 0.38, + "Frequency": 2 + }, + { + "Time": 611, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 634, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_m.json index a2f062bbb8..54a2b3a171 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Skiing_m.json @@ -1,490 +1,490 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 1848, - "StartTime": 128, - "Parameters": { - "Intensity": 33, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 364, - "Intensity": 0.81, - "Frequency": 0 - }, - { - "Time": 558, - "Intensity": 0.89, - "Frequency": 5 - }, - { - "Time": 682, - "Intensity": 0.98, - "Frequency": 10 - }, - { - "Time": 806, - "Intensity": 0.79, - "Frequency": 4 - }, - { - "Time": 902, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 1009, - "Intensity": 0.44, - "Frequency": -2 - }, - { - "Time": 1190, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 1312, - "Intensity": 0.85, - "Frequency": 4 - }, - { - "Time": 1425, - "Intensity": 0.95, - "Frequency": 10 - }, - { - "Time": 1724, - "Intensity": 0.65, - "Frequency": 2 - }, - { - "Time": 1841, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 1848, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1848, - "StartTime": 135, - "Parameters": { - "Intensity": 23, - "Frequency": 63, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 126, - "Intensity": 0.52, - "Frequency": 0 - }, - { - "Time": 248, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 333, - "Intensity": 0.76, - "Frequency": 0 - }, - { - "Time": 455, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 558, - "Intensity": 0.89, - "Frequency": 5 - }, - { - "Time": 682, - "Intensity": 0.98, - "Frequency": 10 - }, - { - "Time": 848, - "Intensity": 0.73, - "Frequency": 4 - }, - { - "Time": 972, - "Intensity": 0.43, - "Frequency": 0 - }, - { - "Time": 1037, - "Intensity": 0.66, - "Frequency": -2 - }, - { - "Time": 1146, - "Intensity": 0.5, - "Frequency": 0 - }, - { - "Time": 1242, - "Intensity": 0.84, - "Frequency": 4 - }, - { - "Time": 1425, - "Intensity": 0.95, - "Frequency": 10 - }, - { - "Time": 1724, - "Intensity": 0.65, - "Frequency": 2 - }, - { - "Time": 1841, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 1848, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 260, - "StartTime": 2005, - "Parameters": { - "Intensity": 80, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.98, - "Frequency": 0 - }, - { - "Time": 61, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 104, - "Intensity": 0.97, - "Frequency": 4 - }, - { - "Time": 139, - "Intensity": 1, - "Frequency": 9 - }, - { - "Time": 171, - "Intensity": 0.45, - "Frequency": 10 - }, - { - "Time": 241, - "Intensity": 0.41, - "Frequency": 2 - }, - { - "Time": 259, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 260, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2220, - "Parameters": { - "Intensity": 43, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2296, - "Parameters": { - "Intensity": 24, - "Frequency": 15 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 260, - "StartTime": 2378, - "Parameters": { - "Intensity": 55, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.98, - "Frequency": 0 - }, - { - "Time": 61, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 104, - "Intensity": 0.97, - "Frequency": 4 - }, - { - "Time": 139, - "Intensity": 1, - "Frequency": 9 - }, - { - "Time": 171, - "Intensity": 0.45, - "Frequency": 10 - }, - { - "Time": 241, - "Intensity": 0.41, - "Frequency": 2 - }, - { - "Time": 259, - "Intensity": 0.26, - "Frequency": 0 - }, - { - "Time": 260, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2586, - "Parameters": { - "Intensity": 32, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 634, - "StartTime": 2638, - "Parameters": { - "Intensity": 23, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.54, - "Frequency": 0 - }, - { - "Time": 106, - "Intensity": 0.68, - "Frequency": 5 - }, - { - "Time": 208, - "Intensity": 0.73, - "Frequency": 10 - }, - { - "Time": 277, - "Intensity": 0.67, - "Frequency": 4 - }, - { - "Time": 309, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 346, - "Intensity": 0.44, - "Frequency": -2 - }, - { - "Time": 408, - "Intensity": 0.52, - "Frequency": 0 - }, - { - "Time": 464, - "Intensity": 0.51, - "Frequency": 4 - }, - { - "Time": 509, - "Intensity": 0.35, - "Frequency": 10 - }, - { - "Time": 569, - "Intensity": 0.26, - "Frequency": 2 - }, - { - "Time": 611, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 634, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 634, - "StartTime": 2640, - "Parameters": { - "Intensity": 15, - "Frequency": 63, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.54, - "Frequency": 0 - }, - { - "Time": 110, - "Intensity": 0.75, - "Frequency": 5 - }, - { - "Time": 182, - "Intensity": 0.45, - "Frequency": 10 - }, - { - "Time": 232, - "Intensity": 0.69, - "Frequency": 4 - }, - { - "Time": 309, - "Intensity": 0.51, - "Frequency": 0 - }, - { - "Time": 346, - "Intensity": 0.44, - "Frequency": -2 - }, - { - "Time": 408, - "Intensity": 0.62, - "Frequency": 0 - }, - { - "Time": 455, - "Intensity": 0.35, - "Frequency": 4 - }, - { - "Time": 515, - "Intensity": 0.24, - "Frequency": 10 - }, - { - "Time": 566, - "Intensity": 0.38, - "Frequency": 2 - }, - { - "Time": 611, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 634, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 1848, + "StartTime": 128, + "Parameters": { + "Intensity": 33, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 364, + "Intensity": 0.81, + "Frequency": 0 + }, + { + "Time": 558, + "Intensity": 0.89, + "Frequency": 5 + }, + { + "Time": 682, + "Intensity": 0.98, + "Frequency": 10 + }, + { + "Time": 806, + "Intensity": 0.79, + "Frequency": 4 + }, + { + "Time": 902, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 1009, + "Intensity": 0.44, + "Frequency": -2 + }, + { + "Time": 1190, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 1312, + "Intensity": 0.85, + "Frequency": 4 + }, + { + "Time": 1425, + "Intensity": 0.95, + "Frequency": 10 + }, + { + "Time": 1724, + "Intensity": 0.65, + "Frequency": 2 + }, + { + "Time": 1841, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 1848, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1848, + "StartTime": 135, + "Parameters": { + "Intensity": 23, + "Frequency": 63, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 126, + "Intensity": 0.52, + "Frequency": 0 + }, + { + "Time": 248, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 333, + "Intensity": 0.76, + "Frequency": 0 + }, + { + "Time": 455, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 558, + "Intensity": 0.89, + "Frequency": 5 + }, + { + "Time": 682, + "Intensity": 0.98, + "Frequency": 10 + }, + { + "Time": 848, + "Intensity": 0.73, + "Frequency": 4 + }, + { + "Time": 972, + "Intensity": 0.43, + "Frequency": 0 + }, + { + "Time": 1037, + "Intensity": 0.66, + "Frequency": -2 + }, + { + "Time": 1146, + "Intensity": 0.5, + "Frequency": 0 + }, + { + "Time": 1242, + "Intensity": 0.84, + "Frequency": 4 + }, + { + "Time": 1425, + "Intensity": 0.95, + "Frequency": 10 + }, + { + "Time": 1724, + "Intensity": 0.65, + "Frequency": 2 + }, + { + "Time": 1841, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 1848, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 260, + "StartTime": 2005, + "Parameters": { + "Intensity": 80, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.98, + "Frequency": 0 + }, + { + "Time": 61, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 104, + "Intensity": 0.97, + "Frequency": 4 + }, + { + "Time": 139, + "Intensity": 1, + "Frequency": 9 + }, + { + "Time": 171, + "Intensity": 0.45, + "Frequency": 10 + }, + { + "Time": 241, + "Intensity": 0.41, + "Frequency": 2 + }, + { + "Time": 259, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 260, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2220, + "Parameters": { + "Intensity": 43, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2296, + "Parameters": { + "Intensity": 24, + "Frequency": 15 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 260, + "StartTime": 2378, + "Parameters": { + "Intensity": 55, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.98, + "Frequency": 0 + }, + { + "Time": 61, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 104, + "Intensity": 0.97, + "Frequency": 4 + }, + { + "Time": 139, + "Intensity": 1, + "Frequency": 9 + }, + { + "Time": 171, + "Intensity": 0.45, + "Frequency": 10 + }, + { + "Time": 241, + "Intensity": 0.41, + "Frequency": 2 + }, + { + "Time": 259, + "Intensity": 0.26, + "Frequency": 0 + }, + { + "Time": 260, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2586, + "Parameters": { + "Intensity": 32, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 634, + "StartTime": 2638, + "Parameters": { + "Intensity": 23, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.54, + "Frequency": 0 + }, + { + "Time": 106, + "Intensity": 0.68, + "Frequency": 5 + }, + { + "Time": 208, + "Intensity": 0.73, + "Frequency": 10 + }, + { + "Time": 277, + "Intensity": 0.67, + "Frequency": 4 + }, + { + "Time": 309, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 346, + "Intensity": 0.44, + "Frequency": -2 + }, + { + "Time": 408, + "Intensity": 0.52, + "Frequency": 0 + }, + { + "Time": 464, + "Intensity": 0.51, + "Frequency": 4 + }, + { + "Time": 509, + "Intensity": 0.35, + "Frequency": 10 + }, + { + "Time": 569, + "Intensity": 0.26, + "Frequency": 2 + }, + { + "Time": 611, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 634, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 634, + "StartTime": 2640, + "Parameters": { + "Intensity": 15, + "Frequency": 63, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.54, + "Frequency": 0 + }, + { + "Time": 110, + "Intensity": 0.75, + "Frequency": 5 + }, + { + "Time": 182, + "Intensity": 0.45, + "Frequency": 10 + }, + { + "Time": 232, + "Intensity": 0.69, + "Frequency": 4 + }, + { + "Time": 309, + "Intensity": 0.51, + "Frequency": 0 + }, + { + "Time": 346, + "Intensity": 0.44, + "Frequency": -2 + }, + { + "Time": 408, + "Intensity": 0.62, + "Frequency": 0 + }, + { + "Time": 455, + "Intensity": 0.35, + "Frequency": 4 + }, + { + "Time": 515, + "Intensity": 0.24, + "Frequency": 10 + }, + { + "Time": 566, + "Intensity": 0.38, + "Frequency": 2 + }, + { + "Time": 611, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 634, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Slide_LeftRight.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Slide_LeftRight.json index 4273bc3e48..a74eac3c47 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Slide_LeftRight.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Slide_LeftRight.json @@ -1,45 +1,45 @@ -{ - "Channels" : - [ - { - "Parameters" : - { - "Index" : 1 - }, - "Pattern" : - [ - { - "Event" : - { - "Parameters" : - { - "Frequency" : 100, - "Intensity" : 100 - }, - "StartTime" : 500, - "Type" : "transient" - } - }, - { - "Event" : - { - "Parameters" : - { - "Frequency" : 100, - "Intensity" : 100 - }, - "StartTime" : 2000, - "Type" : "transient" - } - } - ] - } - ], - "MetaData" : - { - "ChannelNumber" : 1, - "Create" : "2023-03-17", - "Discription" : "slide left right", - "Version" : 1.0 - } -} +{ + "Channels" : + [ + { + "Parameters" : + { + "Index" : 1 + }, + "Pattern" : + [ + { + "Event" : + { + "Parameters" : + { + "Frequency" : 100, + "Intensity" : 100 + }, + "StartTime" : 500, + "Type" : "transient" + } + }, + { + "Event" : + { + "Parameters" : + { + "Frequency" : 100, + "Intensity" : 100 + }, + "StartTime" : 2000, + "Type" : "transient" + } + } + ] + } + ], + "MetaData" : + { + "ChannelNumber" : 1, + "Create" : "2023-03-17", + "Discription" : "slide left right", + "Version" : 1.0 + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Slide_Up.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Slide_Up.json index debdcf8af1..ab425201ce 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Slide_Up.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Slide_Up.json @@ -1,33 +1,33 @@ -{ - "Channels" : - [ - { - "Parameters" : - { - "Index" : 1 - }, - "Pattern" : - [ - { - "Event" : - { - "Parameters" : - { - "Frequency" : 100, - "Intensity" : 100 - }, - "StartTime" : 1000, - "Type" : "transient" - } - } - ] - } - ], - "MetaData" : - { - "ChannelNumber" : 1, - "Create" : "2023-03-17", - "Discription" : "slide up", - "Version" : 1.0 - } -} +{ + "Channels" : + [ + { + "Parameters" : + { + "Index" : 1 + }, + "Pattern" : + [ + { + "Event" : + { + "Parameters" : + { + "Frequency" : 100, + "Intensity" : 100 + }, + "StartTime" : 1000, + "Type" : "transient" + } + } + ] + } + ], + "MetaData" : + { + "ChannelNumber" : 1, + "Create" : "2023-03-17", + "Discription" : "slide up", + "Version" : 1.0 + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_h.json index 22bfffba9c..332c105ea0 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_h.json @@ -1,377 +1,377 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 433, - "StartTime": 785, - "Parameters": { - "Intensity": 80, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 184, - "Intensity": 0.54, - "Frequency": 0 - }, - { - "Time": 190, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 237, - "Intensity": 1, - "Frequency": -10 - }, - { - "Time": 249, - "Intensity": 0.53, - "Frequency": 5 - }, - { - "Time": 433, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1138, - "Parameters": { - "Intensity": 50, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1268, - "Parameters": { - "Intensity": 38, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1343, - "Parameters": { - "Intensity": 36, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1483, - "Parameters": { - "Intensity": 27, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1632, - "Parameters": { - "Intensity": 33, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1390, - "StartTime": 2103, - "Parameters": { - "Intensity": 80, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 591, - "Intensity": 0.38, - "Frequency": -5 - }, - { - "Time": 602, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 717, - "Intensity": 0.94, - "Frequency": 5 - }, - { - "Time": 848, - "Intensity": 0.52, - "Frequency": -10 - }, - { - "Time": 1315, - "Intensity": 0.31, - "Frequency": 5 - }, - { - "Time": 1390, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2200, - "Parameters": { - "Intensity": 37, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2410, - "Parameters": { - "Intensity": 46, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2503, - "Parameters": { - "Intensity": 31, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2548, - "Parameters": { - "Intensity": 50, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3135, - "Parameters": { - "Intensity": 48, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3350, - "Parameters": { - "Intensity": 46, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3490, - "Parameters": { - "Intensity": 30, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3558, - "Parameters": { - "Intensity": 32, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3830, - "Parameters": { - "Intensity": 50, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 220, - "StartTime": 3915, - "Parameters": { - "Intensity": 65, - "Frequency": 10, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 17, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 143, - "Intensity": 0.82, - "Frequency": 5 - }, - { - "Time": 220, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 115, - "StartTime": 4770, - "Parameters": { - "Intensity": 50, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 53, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 80, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 115, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 95, - "StartTime": 4910, - "Parameters": { - "Intensity": 65, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 59, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 95, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5033, - "Parameters": { - "Intensity": 28, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5080, - "Parameters": { - "Intensity": 33, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5278, - "Parameters": { - "Intensity": 27, - "Frequency": 0 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 433, + "StartTime": 785, + "Parameters": { + "Intensity": 80, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 184, + "Intensity": 0.54, + "Frequency": 0 + }, + { + "Time": 190, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 237, + "Intensity": 1, + "Frequency": -10 + }, + { + "Time": 249, + "Intensity": 0.53, + "Frequency": 5 + }, + { + "Time": 433, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1138, + "Parameters": { + "Intensity": 50, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1268, + "Parameters": { + "Intensity": 38, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1343, + "Parameters": { + "Intensity": 36, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1483, + "Parameters": { + "Intensity": 27, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1632, + "Parameters": { + "Intensity": 33, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1390, + "StartTime": 2103, + "Parameters": { + "Intensity": 80, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 591, + "Intensity": 0.38, + "Frequency": -5 + }, + { + "Time": 602, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 717, + "Intensity": 0.94, + "Frequency": 5 + }, + { + "Time": 848, + "Intensity": 0.52, + "Frequency": -10 + }, + { + "Time": 1315, + "Intensity": 0.31, + "Frequency": 5 + }, + { + "Time": 1390, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2200, + "Parameters": { + "Intensity": 37, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2410, + "Parameters": { + "Intensity": 46, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2503, + "Parameters": { + "Intensity": 31, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2548, + "Parameters": { + "Intensity": 50, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3135, + "Parameters": { + "Intensity": 48, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3350, + "Parameters": { + "Intensity": 46, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3490, + "Parameters": { + "Intensity": 30, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3558, + "Parameters": { + "Intensity": 32, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3830, + "Parameters": { + "Intensity": 50, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 220, + "StartTime": 3915, + "Parameters": { + "Intensity": 65, + "Frequency": 10, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 17, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 143, + "Intensity": 0.82, + "Frequency": 5 + }, + { + "Time": 220, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 115, + "StartTime": 4770, + "Parameters": { + "Intensity": 50, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 53, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 80, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 115, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 95, + "StartTime": 4910, + "Parameters": { + "Intensity": 65, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 59, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 95, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5033, + "Parameters": { + "Intensity": 28, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5080, + "Parameters": { + "Intensity": 33, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5278, + "Parameters": { + "Intensity": 27, + "Frequency": 0 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_l.json index d9cc8cab0a..77cfbb2c7a 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_l.json @@ -1,377 +1,377 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 433, - "StartTime": 785, - "Parameters": { - "Intensity": 48, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 184, - "Intensity": 0.54, - "Frequency": 0 - }, - { - "Time": 190, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 237, - "Intensity": 1, - "Frequency": -10 - }, - { - "Time": 249, - "Intensity": 0.53, - "Frequency": 5 - }, - { - "Time": 433, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1138, - "Parameters": { - "Intensity": 30, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1268, - "Parameters": { - "Intensity": 22, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1343, - "Parameters": { - "Intensity": 21, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1483, - "Parameters": { - "Intensity": 16, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1632, - "Parameters": { - "Intensity": 19, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1390, - "StartTime": 2103, - "Parameters": { - "Intensity": 48, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 591, - "Intensity": 0.38, - "Frequency": -5 - }, - { - "Time": 602, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 717, - "Intensity": 0.94, - "Frequency": 5 - }, - { - "Time": 848, - "Intensity": 0.52, - "Frequency": -10 - }, - { - "Time": 1315, - "Intensity": 0.31, - "Frequency": 5 - }, - { - "Time": 1390, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2200, - "Parameters": { - "Intensity": 22, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2410, - "Parameters": { - "Intensity": 27, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2503, - "Parameters": { - "Intensity": 18, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2548, - "Parameters": { - "Intensity": 30, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3135, - "Parameters": { - "Intensity": 28, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3350, - "Parameters": { - "Intensity": 27, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3490, - "Parameters": { - "Intensity": 18, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3558, - "Parameters": { - "Intensity": 19, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3830, - "Parameters": { - "Intensity": 30, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 220, - "StartTime": 3915, - "Parameters": { - "Intensity": 39, - "Frequency": 10, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 17, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 143, - "Intensity": 0.82, - "Frequency": 5 - }, - { - "Time": 220, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 115, - "StartTime": 4770, - "Parameters": { - "Intensity": 30, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 53, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 80, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 115, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 95, - "StartTime": 4910, - "Parameters": { - "Intensity": 39, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 59, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 95, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5033, - "Parameters": { - "Intensity": 16, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5080, - "Parameters": { - "Intensity": 19, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5278, - "Parameters": { - "Intensity": 16, - "Frequency": 0 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 433, + "StartTime": 785, + "Parameters": { + "Intensity": 48, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 184, + "Intensity": 0.54, + "Frequency": 0 + }, + { + "Time": 190, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 237, + "Intensity": 1, + "Frequency": -10 + }, + { + "Time": 249, + "Intensity": 0.53, + "Frequency": 5 + }, + { + "Time": 433, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1138, + "Parameters": { + "Intensity": 30, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1268, + "Parameters": { + "Intensity": 22, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1343, + "Parameters": { + "Intensity": 21, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1483, + "Parameters": { + "Intensity": 16, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1632, + "Parameters": { + "Intensity": 19, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1390, + "StartTime": 2103, + "Parameters": { + "Intensity": 48, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 591, + "Intensity": 0.38, + "Frequency": -5 + }, + { + "Time": 602, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 717, + "Intensity": 0.94, + "Frequency": 5 + }, + { + "Time": 848, + "Intensity": 0.52, + "Frequency": -10 + }, + { + "Time": 1315, + "Intensity": 0.31, + "Frequency": 5 + }, + { + "Time": 1390, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2200, + "Parameters": { + "Intensity": 22, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2410, + "Parameters": { + "Intensity": 27, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2503, + "Parameters": { + "Intensity": 18, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2548, + "Parameters": { + "Intensity": 30, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3135, + "Parameters": { + "Intensity": 28, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3350, + "Parameters": { + "Intensity": 27, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3490, + "Parameters": { + "Intensity": 18, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3558, + "Parameters": { + "Intensity": 19, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3830, + "Parameters": { + "Intensity": 30, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 220, + "StartTime": 3915, + "Parameters": { + "Intensity": 39, + "Frequency": 10, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 17, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 143, + "Intensity": 0.82, + "Frequency": 5 + }, + { + "Time": 220, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 115, + "StartTime": 4770, + "Parameters": { + "Intensity": 30, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 53, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 80, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 115, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 95, + "StartTime": 4910, + "Parameters": { + "Intensity": 39, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 59, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 95, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5033, + "Parameters": { + "Intensity": 16, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5080, + "Parameters": { + "Intensity": 19, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5278, + "Parameters": { + "Intensity": 16, + "Frequency": 0 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_m.json index be29158828..2c2b349422 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Snowdrift_m.json @@ -1,377 +1,377 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 433, - "StartTime": 785, - "Parameters": { - "Intensity": 64, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 184, - "Intensity": 0.54, - "Frequency": 0 - }, - { - "Time": 190, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 237, - "Intensity": 1, - "Frequency": -10 - }, - { - "Time": 249, - "Intensity": 0.53, - "Frequency": 5 - }, - { - "Time": 433, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1138, - "Parameters": { - "Intensity": 40, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1268, - "Parameters": { - "Intensity": 30, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1343, - "Parameters": { - "Intensity": 28, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1483, - "Parameters": { - "Intensity": 21, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1632, - "Parameters": { - "Intensity": 26, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1390, - "StartTime": 2103, - "Parameters": { - "Intensity": 64, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 591, - "Intensity": 0.38, - "Frequency": -5 - }, - { - "Time": 602, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 717, - "Intensity": 0.94, - "Frequency": 5 - }, - { - "Time": 848, - "Intensity": 0.52, - "Frequency": -10 - }, - { - "Time": 1315, - "Intensity": 0.31, - "Frequency": 5 - }, - { - "Time": 1390, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2200, - "Parameters": { - "Intensity": 29, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2410, - "Parameters": { - "Intensity": 36, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2503, - "Parameters": { - "Intensity": 24, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2548, - "Parameters": { - "Intensity": 40, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3135, - "Parameters": { - "Intensity": 38, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3350, - "Parameters": { - "Intensity": 36, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3490, - "Parameters": { - "Intensity": 24, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3558, - "Parameters": { - "Intensity": 25, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3830, - "Parameters": { - "Intensity": 40, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 220, - "StartTime": 3915, - "Parameters": { - "Intensity": 52, - "Frequency": 10, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 17, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 143, - "Intensity": 0.82, - "Frequency": 5 - }, - { - "Time": 220, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 115, - "StartTime": 4770, - "Parameters": { - "Intensity": 40, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 53, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 80, - "Intensity": 1, - "Frequency": 10 - }, - { - "Time": 115, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 95, - "StartTime": 4910, - "Parameters": { - "Intensity": 52, - "Frequency": 45, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 59, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 95, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5033, - "Parameters": { - "Intensity": 22, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5080, - "Parameters": { - "Intensity": 26, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5278, - "Parameters": { - "Intensity": 21, - "Frequency": 0 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 433, + "StartTime": 785, + "Parameters": { + "Intensity": 64, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 184, + "Intensity": 0.54, + "Frequency": 0 + }, + { + "Time": 190, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 237, + "Intensity": 1, + "Frequency": -10 + }, + { + "Time": 249, + "Intensity": 0.53, + "Frequency": 5 + }, + { + "Time": 433, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1138, + "Parameters": { + "Intensity": 40, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1268, + "Parameters": { + "Intensity": 30, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1343, + "Parameters": { + "Intensity": 28, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1483, + "Parameters": { + "Intensity": 21, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1632, + "Parameters": { + "Intensity": 26, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1390, + "StartTime": 2103, + "Parameters": { + "Intensity": 64, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 591, + "Intensity": 0.38, + "Frequency": -5 + }, + { + "Time": 602, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 717, + "Intensity": 0.94, + "Frequency": 5 + }, + { + "Time": 848, + "Intensity": 0.52, + "Frequency": -10 + }, + { + "Time": 1315, + "Intensity": 0.31, + "Frequency": 5 + }, + { + "Time": 1390, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2200, + "Parameters": { + "Intensity": 29, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2410, + "Parameters": { + "Intensity": 36, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2503, + "Parameters": { + "Intensity": 24, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2548, + "Parameters": { + "Intensity": 40, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3135, + "Parameters": { + "Intensity": 38, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3350, + "Parameters": { + "Intensity": 36, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3490, + "Parameters": { + "Intensity": 24, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3558, + "Parameters": { + "Intensity": 25, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3830, + "Parameters": { + "Intensity": 40, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 220, + "StartTime": 3915, + "Parameters": { + "Intensity": 52, + "Frequency": 10, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 17, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 143, + "Intensity": 0.82, + "Frequency": 5 + }, + { + "Time": 220, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 115, + "StartTime": 4770, + "Parameters": { + "Intensity": 40, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 53, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 80, + "Intensity": 1, + "Frequency": 10 + }, + { + "Time": 115, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 95, + "StartTime": 4910, + "Parameters": { + "Intensity": 52, + "Frequency": 45, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 59, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 95, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5033, + "Parameters": { + "Intensity": 22, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5080, + "Parameters": { + "Intensity": 26, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5278, + "Parameters": { + "Intensity": 21, + "Frequency": 0 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_h.json index 9067c09dad..ea981c10a6 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_h.json @@ -1,691 +1,691 @@ -{ - "MetaData": { - "Create": "2021-10-18", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 0, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 40.1532 - }, - { - "Time": 11, - "Intensity": 0.38, - "Frequency": 70 - }, - { - "Time": 33, - "Intensity": 0.044387, - "Frequency": 37.3798 - }, - { - "Time": 43, - "Intensity": 0.58, - "Frequency": 37.2261 - }, - { - "Time": 53, - "Intensity": 0.12, - "Frequency": 38.4537 - }, - { - "Time": 84, - "Intensity": 0.93, - "Frequency": 47 - }, - { - "Time": 133, - "Intensity": 0.15797, - "Frequency": 37.8403 - }, - { - "Time": 149, - "Intensity": 1, - "Frequency": 42 - }, - { - "Time": 167, - "Intensity": 0.33416, - "Frequency": 37.8405 - }, - { - "Time": 188, - "Intensity": 1, - "Frequency": 37.9941 - }, - { - "Time": 200, - "Intensity": 0.37425, - "Frequency": 38.3774 - }, - { - "Time": 220, - "Intensity": 1, - "Frequency": 32 - }, - { - "Time": 233, - "Intensity": 0.46612, - "Frequency": 38.0703 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.0703 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 233, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.0703 - }, - { - "Time": 21, - "Intensity": 0.89, - "Frequency": 70 - }, - { - "Time": 50, - "Intensity": 0.2731, - "Frequency": 38.5306 - }, - { - "Time": 73, - "Intensity": 0.89, - "Frequency": 70 - }, - { - "Time": 84, - "Intensity": 0.40483, - "Frequency": 40.1155 - }, - { - "Time": 106, - "Intensity": 1, - "Frequency": 70 - }, - { - "Time": 117, - "Intensity": 0.44912, - "Frequency": 38.1477 - }, - { - "Time": 137, - "Intensity": 1, - "Frequency": 58 - }, - { - "Time": 150, - "Intensity": 0.50406, - "Frequency": 38.4543 - }, - { - "Time": 167, - "Intensity": 0.79268, - "Frequency": 38.1473 - }, - { - "Time": 184, - "Intensity": 0.53455, - "Frequency": 37.9174 - }, - { - "Time": 200, - "Intensity": 1, - "Frequency": 37.9172 - }, - { - "Time": 217, - "Intensity": 0.69526, - "Frequency": 38.1476 - }, - { - "Time": 234, - "Intensity": 0.8526, - "Frequency": 38.2243 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.4541 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 467, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.2243 - }, - { - "Time": 16, - "Intensity": 0.31475, - "Frequency": 38.4541 - }, - { - "Time": 33, - "Intensity": 1, - "Frequency": 38.2232 - }, - { - "Time": 50, - "Intensity": 0.44752, - "Frequency": 38.2232 - }, - { - "Time": 66, - "Intensity": 0.29572, - "Frequency": 37.8401 - }, - { - "Time": 83, - "Intensity": 0.64702, - "Frequency": 37.7634 - }, - { - "Time": 100, - "Intensity": 0.64717, - "Frequency": 37.3793 - }, - { - "Time": 116, - "Intensity": 0.3679, - "Frequency": 37.2258 - }, - { - "Time": 133, - "Intensity": 0.24298, - "Frequency": 37.4567 - }, - { - "Time": 150, - "Intensity": 0.55359, - "Frequency": 37.6872 - }, - { - "Time": 166, - "Intensity": 0.67465, - "Frequency": 37.5334 - }, - { - "Time": 183, - "Intensity": 0.62278, - "Frequency": 37.4566 - }, - { - "Time": 200, - "Intensity": 0.69885, - "Frequency": 37.303 - }, - { - "Time": 216, - "Intensity": 0.32678, - "Frequency": 37.2261 - }, - { - "Time": 233, - "Intensity": 0.535, - "Frequency": 37.0724 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 36.9954 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 700, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37.0724 - }, - { - "Time": 17, - "Intensity": 0.33735, - "Frequency": 36.9954 - }, - { - "Time": 33, - "Intensity": 0.65451, - "Frequency": 37.3029 - }, - { - "Time": 50, - "Intensity": 0.42331, - "Frequency": 37.6869 - }, - { - "Time": 67, - "Intensity": 0.24668, - "Frequency": 37.9943 - }, - { - "Time": 83, - "Intensity": 0.38753, - "Frequency": 37.9943 - }, - { - "Time": 100, - "Intensity": 0.11651, - "Frequency": 38.224 - }, - { - "Time": 117, - "Intensity": 0.1304, - "Frequency": 38.3772 - }, - { - "Time": 133, - "Intensity": 0.49327, - "Frequency": 38.2242 - }, - { - "Time": 150, - "Intensity": 0.22527, - "Frequency": 38.3776 - }, - { - "Time": 167, - "Intensity": 0.21292, - "Frequency": 38.684 - }, - { - "Time": 183, - "Intensity": 0.26452, - "Frequency": 38.9137 - }, - { - "Time": 200, - "Intensity": 0.21029, - "Frequency": 38.9136 - }, - { - "Time": 217, - "Intensity": 0.18462, - "Frequency": 38.6836 - }, - { - "Time": 233, - "Intensity": 0.1114, - "Frequency": 38.7602 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.9133 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 933, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.7602 - }, - { - "Time": 17, - "Intensity": 0.11051, - "Frequency": 38.9133 - }, - { - "Time": 32, - "Intensity": 0.37, - "Frequency": 40.9583 - }, - { - "Time": 50, - "Intensity": 0.080825, - "Frequency": 40.805 - }, - { - "Time": 66, - "Intensity": 0.6, - "Frequency": 40.4219 - }, - { - "Time": 84, - "Intensity": 0.11637, - "Frequency": 38.3007 - }, - { - "Time": 114, - "Intensity": 0.25, - "Frequency": 38.0706 - }, - { - "Time": 150, - "Intensity": 0.084815, - "Frequency": 37.994 - }, - { - "Time": 184, - "Intensity": 0.18, - "Frequency": 38.0707 - }, - { - "Time": 234, - "Intensity": 0.041641, - "Frequency": 38.0707 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.0707 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1167, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.0707 - }, - { - "Time": 16, - "Intensity": 0.23, - "Frequency": 38.0707 - }, - { - "Time": 33, - "Intensity": 0.049233, - "Frequency": 38.0709 - }, - { - "Time": 50, - "Intensity": 0.15, - "Frequency": 37.9175 - }, - { - "Time": 66, - "Intensity": 0.028695, - "Frequency": 37.9173 - }, - { - "Time": 96, - "Intensity": 0.08, - "Frequency": 38.0708 - }, - { - "Time": 133, - "Intensity": 0.046483, - "Frequency": 37.8408 - }, - { - "Time": 150, - "Intensity": 0.037565, - "Frequency": 37.8408 - }, - { - "Time": 166, - "Intensity": 0.037006, - "Frequency": 38.2244 - }, - { - "Time": 183, - "Intensity": 0.031955, - "Frequency": 38.0709 - }, - { - "Time": 200, - "Intensity": 0.043736, - "Frequency": 37.9943 - }, - { - "Time": 216, - "Intensity": 0.025359, - "Frequency": 37.8409 - }, - { - "Time": 233, - "Intensity": 0.027193, - "Frequency": 37.9943 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 37.9942 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1400, - "Parameters": { - "Intensity": 45, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37.9943 - }, - { - "Time": 15, - "Intensity": 0.18, - "Frequency": 37.9942 - }, - { - "Time": 33, - "Intensity": 0.018389, - "Frequency": 37.9942 - }, - { - "Time": 50, - "Intensity": 0.020258, - "Frequency": 37.9942 - }, - { - "Time": 76, - "Intensity": 0.11, - "Frequency": 37.9942 - }, - { - "Time": 117, - "Intensity": 0.016523, - "Frequency": 38.1475 - }, - { - "Time": 136, - "Intensity": 0.14, - "Frequency": 37.9172 - }, - { - "Time": 150, - "Intensity": 0.016324, - "Frequency": 37.8405 - }, - { - "Time": 167, - "Intensity": 0.016409, - "Frequency": 37.9173 - }, - { - "Time": 190, - "Intensity": 0.08, - "Frequency": 37.9173 - }, - { - "Time": 217, - "Intensity": 7.2853e-05, - "Frequency": 38.2236 - }, - { - "Time": 233, - "Intensity": 0.00010155, - "Frequency": 38.1472 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.3008 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 234, - "StartTime": 1633, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.1472 - }, - { - "Time": 17, - "Intensity": 7.2025e-05, - "Frequency": 38.3008 - }, - { - "Time": 34, - "Intensity": 4.4664e-05, - "Frequency": 38.0708 - }, - { - "Time": 50, - "Intensity": 5.4972e-05, - "Frequency": 38.0708 - }, - { - "Time": 67, - "Intensity": 4.9011e-05, - "Frequency": 37.8409 - }, - { - "Time": 84, - "Intensity": 4.0321e-05, - "Frequency": 38.0706 - }, - { - "Time": 100, - "Intensity": 2.647e-05, - "Frequency": 38.1469 - }, - { - "Time": 117, - "Intensity": 1.4281e-05, - "Frequency": 38.0701 - }, - { - "Time": 134, - "Intensity": 5.3637e-06, - "Frequency": 37.917 - }, - { - "Time": 150, - "Intensity": 3.4715e-06, - "Frequency": 37.8405 - }, - { - "Time": 167, - "Intensity": 1.7078e-05, - "Frequency": 37.8406 - }, - { - "Time": 184, - "Intensity": 3.4403e-06, - "Frequency": 37.6101 - }, - { - "Time": 200, - "Intensity": 3.0648e-06, - "Frequency": 36.9629 - }, - { - "Time": 217, - "Intensity": 1.4176e-06, - "Frequency": 36.9629 - }, - { - "Time": 234, - "Intensity": 0, - "Frequency": 34.8347 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2021-10-18", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 0, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 40.1532 + }, + { + "Time": 11, + "Intensity": 0.38, + "Frequency": 70 + }, + { + "Time": 33, + "Intensity": 0.044387, + "Frequency": 37.3798 + }, + { + "Time": 43, + "Intensity": 0.58, + "Frequency": 37.2261 + }, + { + "Time": 53, + "Intensity": 0.12, + "Frequency": 38.4537 + }, + { + "Time": 84, + "Intensity": 0.93, + "Frequency": 47 + }, + { + "Time": 133, + "Intensity": 0.15797, + "Frequency": 37.8403 + }, + { + "Time": 149, + "Intensity": 1, + "Frequency": 42 + }, + { + "Time": 167, + "Intensity": 0.33416, + "Frequency": 37.8405 + }, + { + "Time": 188, + "Intensity": 1, + "Frequency": 37.9941 + }, + { + "Time": 200, + "Intensity": 0.37425, + "Frequency": 38.3774 + }, + { + "Time": 220, + "Intensity": 1, + "Frequency": 32 + }, + { + "Time": 233, + "Intensity": 0.46612, + "Frequency": 38.0703 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.0703 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 233, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.0703 + }, + { + "Time": 21, + "Intensity": 0.89, + "Frequency": 70 + }, + { + "Time": 50, + "Intensity": 0.2731, + "Frequency": 38.5306 + }, + { + "Time": 73, + "Intensity": 0.89, + "Frequency": 70 + }, + { + "Time": 84, + "Intensity": 0.40483, + "Frequency": 40.1155 + }, + { + "Time": 106, + "Intensity": 1, + "Frequency": 70 + }, + { + "Time": 117, + "Intensity": 0.44912, + "Frequency": 38.1477 + }, + { + "Time": 137, + "Intensity": 1, + "Frequency": 58 + }, + { + "Time": 150, + "Intensity": 0.50406, + "Frequency": 38.4543 + }, + { + "Time": 167, + "Intensity": 0.79268, + "Frequency": 38.1473 + }, + { + "Time": 184, + "Intensity": 0.53455, + "Frequency": 37.9174 + }, + { + "Time": 200, + "Intensity": 1, + "Frequency": 37.9172 + }, + { + "Time": 217, + "Intensity": 0.69526, + "Frequency": 38.1476 + }, + { + "Time": 234, + "Intensity": 0.8526, + "Frequency": 38.2243 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.4541 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 467, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.2243 + }, + { + "Time": 16, + "Intensity": 0.31475, + "Frequency": 38.4541 + }, + { + "Time": 33, + "Intensity": 1, + "Frequency": 38.2232 + }, + { + "Time": 50, + "Intensity": 0.44752, + "Frequency": 38.2232 + }, + { + "Time": 66, + "Intensity": 0.29572, + "Frequency": 37.8401 + }, + { + "Time": 83, + "Intensity": 0.64702, + "Frequency": 37.7634 + }, + { + "Time": 100, + "Intensity": 0.64717, + "Frequency": 37.3793 + }, + { + "Time": 116, + "Intensity": 0.3679, + "Frequency": 37.2258 + }, + { + "Time": 133, + "Intensity": 0.24298, + "Frequency": 37.4567 + }, + { + "Time": 150, + "Intensity": 0.55359, + "Frequency": 37.6872 + }, + { + "Time": 166, + "Intensity": 0.67465, + "Frequency": 37.5334 + }, + { + "Time": 183, + "Intensity": 0.62278, + "Frequency": 37.4566 + }, + { + "Time": 200, + "Intensity": 0.69885, + "Frequency": 37.303 + }, + { + "Time": 216, + "Intensity": 0.32678, + "Frequency": 37.2261 + }, + { + "Time": 233, + "Intensity": 0.535, + "Frequency": 37.0724 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 36.9954 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 700, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37.0724 + }, + { + "Time": 17, + "Intensity": 0.33735, + "Frequency": 36.9954 + }, + { + "Time": 33, + "Intensity": 0.65451, + "Frequency": 37.3029 + }, + { + "Time": 50, + "Intensity": 0.42331, + "Frequency": 37.6869 + }, + { + "Time": 67, + "Intensity": 0.24668, + "Frequency": 37.9943 + }, + { + "Time": 83, + "Intensity": 0.38753, + "Frequency": 37.9943 + }, + { + "Time": 100, + "Intensity": 0.11651, + "Frequency": 38.224 + }, + { + "Time": 117, + "Intensity": 0.1304, + "Frequency": 38.3772 + }, + { + "Time": 133, + "Intensity": 0.49327, + "Frequency": 38.2242 + }, + { + "Time": 150, + "Intensity": 0.22527, + "Frequency": 38.3776 + }, + { + "Time": 167, + "Intensity": 0.21292, + "Frequency": 38.684 + }, + { + "Time": 183, + "Intensity": 0.26452, + "Frequency": 38.9137 + }, + { + "Time": 200, + "Intensity": 0.21029, + "Frequency": 38.9136 + }, + { + "Time": 217, + "Intensity": 0.18462, + "Frequency": 38.6836 + }, + { + "Time": 233, + "Intensity": 0.1114, + "Frequency": 38.7602 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.9133 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 933, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.7602 + }, + { + "Time": 17, + "Intensity": 0.11051, + "Frequency": 38.9133 + }, + { + "Time": 32, + "Intensity": 0.37, + "Frequency": 40.9583 + }, + { + "Time": 50, + "Intensity": 0.080825, + "Frequency": 40.805 + }, + { + "Time": 66, + "Intensity": 0.6, + "Frequency": 40.4219 + }, + { + "Time": 84, + "Intensity": 0.11637, + "Frequency": 38.3007 + }, + { + "Time": 114, + "Intensity": 0.25, + "Frequency": 38.0706 + }, + { + "Time": 150, + "Intensity": 0.084815, + "Frequency": 37.994 + }, + { + "Time": 184, + "Intensity": 0.18, + "Frequency": 38.0707 + }, + { + "Time": 234, + "Intensity": 0.041641, + "Frequency": 38.0707 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.0707 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1167, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.0707 + }, + { + "Time": 16, + "Intensity": 0.23, + "Frequency": 38.0707 + }, + { + "Time": 33, + "Intensity": 0.049233, + "Frequency": 38.0709 + }, + { + "Time": 50, + "Intensity": 0.15, + "Frequency": 37.9175 + }, + { + "Time": 66, + "Intensity": 0.028695, + "Frequency": 37.9173 + }, + { + "Time": 96, + "Intensity": 0.08, + "Frequency": 38.0708 + }, + { + "Time": 133, + "Intensity": 0.046483, + "Frequency": 37.8408 + }, + { + "Time": 150, + "Intensity": 0.037565, + "Frequency": 37.8408 + }, + { + "Time": 166, + "Intensity": 0.037006, + "Frequency": 38.2244 + }, + { + "Time": 183, + "Intensity": 0.031955, + "Frequency": 38.0709 + }, + { + "Time": 200, + "Intensity": 0.043736, + "Frequency": 37.9943 + }, + { + "Time": 216, + "Intensity": 0.025359, + "Frequency": 37.8409 + }, + { + "Time": 233, + "Intensity": 0.027193, + "Frequency": 37.9943 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 37.9942 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1400, + "Parameters": { + "Intensity": 45, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37.9943 + }, + { + "Time": 15, + "Intensity": 0.18, + "Frequency": 37.9942 + }, + { + "Time": 33, + "Intensity": 0.018389, + "Frequency": 37.9942 + }, + { + "Time": 50, + "Intensity": 0.020258, + "Frequency": 37.9942 + }, + { + "Time": 76, + "Intensity": 0.11, + "Frequency": 37.9942 + }, + { + "Time": 117, + "Intensity": 0.016523, + "Frequency": 38.1475 + }, + { + "Time": 136, + "Intensity": 0.14, + "Frequency": 37.9172 + }, + { + "Time": 150, + "Intensity": 0.016324, + "Frequency": 37.8405 + }, + { + "Time": 167, + "Intensity": 0.016409, + "Frequency": 37.9173 + }, + { + "Time": 190, + "Intensity": 0.08, + "Frequency": 37.9173 + }, + { + "Time": 217, + "Intensity": 7.2853e-05, + "Frequency": 38.2236 + }, + { + "Time": 233, + "Intensity": 0.00010155, + "Frequency": 38.1472 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.3008 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 234, + "StartTime": 1633, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.1472 + }, + { + "Time": 17, + "Intensity": 7.2025e-05, + "Frequency": 38.3008 + }, + { + "Time": 34, + "Intensity": 4.4664e-05, + "Frequency": 38.0708 + }, + { + "Time": 50, + "Intensity": 5.4972e-05, + "Frequency": 38.0708 + }, + { + "Time": 67, + "Intensity": 4.9011e-05, + "Frequency": 37.8409 + }, + { + "Time": 84, + "Intensity": 4.0321e-05, + "Frequency": 38.0706 + }, + { + "Time": 100, + "Intensity": 2.647e-05, + "Frequency": 38.1469 + }, + { + "Time": 117, + "Intensity": 1.4281e-05, + "Frequency": 38.0701 + }, + { + "Time": 134, + "Intensity": 5.3637e-06, + "Frequency": 37.917 + }, + { + "Time": 150, + "Intensity": 3.4715e-06, + "Frequency": 37.8405 + }, + { + "Time": 167, + "Intensity": 1.7078e-05, + "Frequency": 37.8406 + }, + { + "Time": 184, + "Intensity": 3.4403e-06, + "Frequency": 37.6101 + }, + { + "Time": 200, + "Intensity": 3.0648e-06, + "Frequency": 36.9629 + }, + { + "Time": 217, + "Intensity": 1.4176e-06, + "Frequency": 36.9629 + }, + { + "Time": 234, + "Intensity": 0, + "Frequency": 34.8347 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_l.json index b354078c03..eeb144cb9e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_l.json @@ -1,691 +1,691 @@ -{ - "MetaData": { - "Create": "2021-10-18", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 0, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 40.1532 - }, - { - "Time": 11, - "Intensity": 0.38, - "Frequency": 70 - }, - { - "Time": 33, - "Intensity": 0.044387, - "Frequency": 37.3798 - }, - { - "Time": 43, - "Intensity": 0.58, - "Frequency": 37.2261 - }, - { - "Time": 53, - "Intensity": 0.12, - "Frequency": 38.4537 - }, - { - "Time": 84, - "Intensity": 0.93, - "Frequency": 47 - }, - { - "Time": 133, - "Intensity": 0.15797, - "Frequency": 37.8403 - }, - { - "Time": 149, - "Intensity": 1, - "Frequency": 42 - }, - { - "Time": 167, - "Intensity": 0.33416, - "Frequency": 37.8405 - }, - { - "Time": 188, - "Intensity": 1, - "Frequency": 37.9941 - }, - { - "Time": 200, - "Intensity": 0.37425, - "Frequency": 38.3774 - }, - { - "Time": 220, - "Intensity": 1, - "Frequency": 32 - }, - { - "Time": 233, - "Intensity": 0.46612, - "Frequency": 38.0703 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.0703 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 233, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.0703 - }, - { - "Time": 21, - "Intensity": 0.89, - "Frequency": 70 - }, - { - "Time": 50, - "Intensity": 0.2731, - "Frequency": 38.5306 - }, - { - "Time": 73, - "Intensity": 0.89, - "Frequency": 70 - }, - { - "Time": 84, - "Intensity": 0.40483, - "Frequency": 40.1155 - }, - { - "Time": 106, - "Intensity": 1, - "Frequency": 70 - }, - { - "Time": 117, - "Intensity": 0.44912, - "Frequency": 38.1477 - }, - { - "Time": 137, - "Intensity": 1, - "Frequency": 58 - }, - { - "Time": 150, - "Intensity": 0.50406, - "Frequency": 38.4543 - }, - { - "Time": 167, - "Intensity": 0.79268, - "Frequency": 38.1473 - }, - { - "Time": 184, - "Intensity": 0.53455, - "Frequency": 37.9174 - }, - { - "Time": 200, - "Intensity": 1, - "Frequency": 37.9172 - }, - { - "Time": 217, - "Intensity": 0.69526, - "Frequency": 38.1476 - }, - { - "Time": 234, - "Intensity": 0.8526, - "Frequency": 38.2243 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.4541 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 467, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.2243 - }, - { - "Time": 16, - "Intensity": 0.31475, - "Frequency": 38.4541 - }, - { - "Time": 33, - "Intensity": 1, - "Frequency": 38.2232 - }, - { - "Time": 50, - "Intensity": 0.44752, - "Frequency": 38.2232 - }, - { - "Time": 66, - "Intensity": 0.29572, - "Frequency": 37.8401 - }, - { - "Time": 83, - "Intensity": 0.64702, - "Frequency": 37.7634 - }, - { - "Time": 100, - "Intensity": 0.64717, - "Frequency": 37.3793 - }, - { - "Time": 116, - "Intensity": 0.3679, - "Frequency": 37.2258 - }, - { - "Time": 133, - "Intensity": 0.24298, - "Frequency": 37.4567 - }, - { - "Time": 150, - "Intensity": 0.55359, - "Frequency": 37.6872 - }, - { - "Time": 166, - "Intensity": 0.67465, - "Frequency": 37.5334 - }, - { - "Time": 183, - "Intensity": 0.62278, - "Frequency": 37.4566 - }, - { - "Time": 200, - "Intensity": 0.69885, - "Frequency": 37.303 - }, - { - "Time": 216, - "Intensity": 0.32678, - "Frequency": 37.2261 - }, - { - "Time": 233, - "Intensity": 0.535, - "Frequency": 37.0724 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 36.9954 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 700, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37.0724 - }, - { - "Time": 17, - "Intensity": 0.33735, - "Frequency": 36.9954 - }, - { - "Time": 33, - "Intensity": 0.65451, - "Frequency": 37.3029 - }, - { - "Time": 50, - "Intensity": 0.42331, - "Frequency": 37.6869 - }, - { - "Time": 67, - "Intensity": 0.24668, - "Frequency": 37.9943 - }, - { - "Time": 83, - "Intensity": 0.38753, - "Frequency": 37.9943 - }, - { - "Time": 100, - "Intensity": 0.11651, - "Frequency": 38.224 - }, - { - "Time": 117, - "Intensity": 0.1304, - "Frequency": 38.3772 - }, - { - "Time": 133, - "Intensity": 0.49327, - "Frequency": 38.2242 - }, - { - "Time": 150, - "Intensity": 0.22527, - "Frequency": 38.3776 - }, - { - "Time": 167, - "Intensity": 0.21292, - "Frequency": 38.684 - }, - { - "Time": 183, - "Intensity": 0.26452, - "Frequency": 38.9137 - }, - { - "Time": 200, - "Intensity": 0.21029, - "Frequency": 38.9136 - }, - { - "Time": 217, - "Intensity": 0.18462, - "Frequency": 38.6836 - }, - { - "Time": 233, - "Intensity": 0.1114, - "Frequency": 38.7602 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.9133 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 933, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.7602 - }, - { - "Time": 17, - "Intensity": 0.11051, - "Frequency": 38.9133 - }, - { - "Time": 32, - "Intensity": 0.37, - "Frequency": 40.9583 - }, - { - "Time": 50, - "Intensity": 0.080825, - "Frequency": 40.805 - }, - { - "Time": 66, - "Intensity": 0.6, - "Frequency": 40.4219 - }, - { - "Time": 84, - "Intensity": 0.11637, - "Frequency": 38.3007 - }, - { - "Time": 114, - "Intensity": 0.25, - "Frequency": 38.0706 - }, - { - "Time": 150, - "Intensity": 0.084815, - "Frequency": 37.994 - }, - { - "Time": 184, - "Intensity": 0.18, - "Frequency": 38.0707 - }, - { - "Time": 234, - "Intensity": 0.041641, - "Frequency": 38.0707 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.0707 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1167, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.0707 - }, - { - "Time": 16, - "Intensity": 0.23, - "Frequency": 38.0707 - }, - { - "Time": 33, - "Intensity": 0.049233, - "Frequency": 38.0709 - }, - { - "Time": 50, - "Intensity": 0.15, - "Frequency": 37.9175 - }, - { - "Time": 66, - "Intensity": 0.028695, - "Frequency": 37.9173 - }, - { - "Time": 96, - "Intensity": 0.08, - "Frequency": 38.0708 - }, - { - "Time": 133, - "Intensity": 0.046483, - "Frequency": 37.8408 - }, - { - "Time": 150, - "Intensity": 0.037565, - "Frequency": 37.8408 - }, - { - "Time": 166, - "Intensity": 0.037006, - "Frequency": 38.2244 - }, - { - "Time": 183, - "Intensity": 0.031955, - "Frequency": 38.0709 - }, - { - "Time": 200, - "Intensity": 0.043736, - "Frequency": 37.9943 - }, - { - "Time": 216, - "Intensity": 0.025359, - "Frequency": 37.8409 - }, - { - "Time": 233, - "Intensity": 0.027193, - "Frequency": 37.9943 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 37.9942 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1400, - "Parameters": { - "Intensity": 27, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37.9943 - }, - { - "Time": 15, - "Intensity": 0.18, - "Frequency": 37.9942 - }, - { - "Time": 33, - "Intensity": 0.018389, - "Frequency": 37.9942 - }, - { - "Time": 50, - "Intensity": 0.020258, - "Frequency": 37.9942 - }, - { - "Time": 76, - "Intensity": 0.11, - "Frequency": 37.9942 - }, - { - "Time": 117, - "Intensity": 0.016523, - "Frequency": 38.1475 - }, - { - "Time": 136, - "Intensity": 0.14, - "Frequency": 37.9172 - }, - { - "Time": 150, - "Intensity": 0.016324, - "Frequency": 37.8405 - }, - { - "Time": 167, - "Intensity": 0.016409, - "Frequency": 37.9173 - }, - { - "Time": 190, - "Intensity": 0.08, - "Frequency": 37.9173 - }, - { - "Time": 217, - "Intensity": 7.2853e-05, - "Frequency": 38.2236 - }, - { - "Time": 233, - "Intensity": 0.00010155, - "Frequency": 38.1472 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.3008 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 234, - "StartTime": 1633, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.1472 - }, - { - "Time": 17, - "Intensity": 7.2025e-05, - "Frequency": 38.3008 - }, - { - "Time": 34, - "Intensity": 4.4664e-05, - "Frequency": 38.0708 - }, - { - "Time": 50, - "Intensity": 5.4972e-05, - "Frequency": 38.0708 - }, - { - "Time": 67, - "Intensity": 4.9011e-05, - "Frequency": 37.8409 - }, - { - "Time": 84, - "Intensity": 4.0321e-05, - "Frequency": 38.0706 - }, - { - "Time": 100, - "Intensity": 2.647e-05, - "Frequency": 38.1469 - }, - { - "Time": 117, - "Intensity": 1.4281e-05, - "Frequency": 38.0701 - }, - { - "Time": 134, - "Intensity": 5.3637e-06, - "Frequency": 37.917 - }, - { - "Time": 150, - "Intensity": 3.4715e-06, - "Frequency": 37.8405 - }, - { - "Time": 167, - "Intensity": 1.7078e-05, - "Frequency": 37.8406 - }, - { - "Time": 184, - "Intensity": 3.4403e-06, - "Frequency": 37.6101 - }, - { - "Time": 200, - "Intensity": 3.0648e-06, - "Frequency": 36.9629 - }, - { - "Time": 217, - "Intensity": 1.4176e-06, - "Frequency": 36.9629 - }, - { - "Time": 234, - "Intensity": 0, - "Frequency": 34.8347 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2021-10-18", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 0, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 40.1532 + }, + { + "Time": 11, + "Intensity": 0.38, + "Frequency": 70 + }, + { + "Time": 33, + "Intensity": 0.044387, + "Frequency": 37.3798 + }, + { + "Time": 43, + "Intensity": 0.58, + "Frequency": 37.2261 + }, + { + "Time": 53, + "Intensity": 0.12, + "Frequency": 38.4537 + }, + { + "Time": 84, + "Intensity": 0.93, + "Frequency": 47 + }, + { + "Time": 133, + "Intensity": 0.15797, + "Frequency": 37.8403 + }, + { + "Time": 149, + "Intensity": 1, + "Frequency": 42 + }, + { + "Time": 167, + "Intensity": 0.33416, + "Frequency": 37.8405 + }, + { + "Time": 188, + "Intensity": 1, + "Frequency": 37.9941 + }, + { + "Time": 200, + "Intensity": 0.37425, + "Frequency": 38.3774 + }, + { + "Time": 220, + "Intensity": 1, + "Frequency": 32 + }, + { + "Time": 233, + "Intensity": 0.46612, + "Frequency": 38.0703 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.0703 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 233, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.0703 + }, + { + "Time": 21, + "Intensity": 0.89, + "Frequency": 70 + }, + { + "Time": 50, + "Intensity": 0.2731, + "Frequency": 38.5306 + }, + { + "Time": 73, + "Intensity": 0.89, + "Frequency": 70 + }, + { + "Time": 84, + "Intensity": 0.40483, + "Frequency": 40.1155 + }, + { + "Time": 106, + "Intensity": 1, + "Frequency": 70 + }, + { + "Time": 117, + "Intensity": 0.44912, + "Frequency": 38.1477 + }, + { + "Time": 137, + "Intensity": 1, + "Frequency": 58 + }, + { + "Time": 150, + "Intensity": 0.50406, + "Frequency": 38.4543 + }, + { + "Time": 167, + "Intensity": 0.79268, + "Frequency": 38.1473 + }, + { + "Time": 184, + "Intensity": 0.53455, + "Frequency": 37.9174 + }, + { + "Time": 200, + "Intensity": 1, + "Frequency": 37.9172 + }, + { + "Time": 217, + "Intensity": 0.69526, + "Frequency": 38.1476 + }, + { + "Time": 234, + "Intensity": 0.8526, + "Frequency": 38.2243 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.4541 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 467, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.2243 + }, + { + "Time": 16, + "Intensity": 0.31475, + "Frequency": 38.4541 + }, + { + "Time": 33, + "Intensity": 1, + "Frequency": 38.2232 + }, + { + "Time": 50, + "Intensity": 0.44752, + "Frequency": 38.2232 + }, + { + "Time": 66, + "Intensity": 0.29572, + "Frequency": 37.8401 + }, + { + "Time": 83, + "Intensity": 0.64702, + "Frequency": 37.7634 + }, + { + "Time": 100, + "Intensity": 0.64717, + "Frequency": 37.3793 + }, + { + "Time": 116, + "Intensity": 0.3679, + "Frequency": 37.2258 + }, + { + "Time": 133, + "Intensity": 0.24298, + "Frequency": 37.4567 + }, + { + "Time": 150, + "Intensity": 0.55359, + "Frequency": 37.6872 + }, + { + "Time": 166, + "Intensity": 0.67465, + "Frequency": 37.5334 + }, + { + "Time": 183, + "Intensity": 0.62278, + "Frequency": 37.4566 + }, + { + "Time": 200, + "Intensity": 0.69885, + "Frequency": 37.303 + }, + { + "Time": 216, + "Intensity": 0.32678, + "Frequency": 37.2261 + }, + { + "Time": 233, + "Intensity": 0.535, + "Frequency": 37.0724 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 36.9954 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 700, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37.0724 + }, + { + "Time": 17, + "Intensity": 0.33735, + "Frequency": 36.9954 + }, + { + "Time": 33, + "Intensity": 0.65451, + "Frequency": 37.3029 + }, + { + "Time": 50, + "Intensity": 0.42331, + "Frequency": 37.6869 + }, + { + "Time": 67, + "Intensity": 0.24668, + "Frequency": 37.9943 + }, + { + "Time": 83, + "Intensity": 0.38753, + "Frequency": 37.9943 + }, + { + "Time": 100, + "Intensity": 0.11651, + "Frequency": 38.224 + }, + { + "Time": 117, + "Intensity": 0.1304, + "Frequency": 38.3772 + }, + { + "Time": 133, + "Intensity": 0.49327, + "Frequency": 38.2242 + }, + { + "Time": 150, + "Intensity": 0.22527, + "Frequency": 38.3776 + }, + { + "Time": 167, + "Intensity": 0.21292, + "Frequency": 38.684 + }, + { + "Time": 183, + "Intensity": 0.26452, + "Frequency": 38.9137 + }, + { + "Time": 200, + "Intensity": 0.21029, + "Frequency": 38.9136 + }, + { + "Time": 217, + "Intensity": 0.18462, + "Frequency": 38.6836 + }, + { + "Time": 233, + "Intensity": 0.1114, + "Frequency": 38.7602 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.9133 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 933, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.7602 + }, + { + "Time": 17, + "Intensity": 0.11051, + "Frequency": 38.9133 + }, + { + "Time": 32, + "Intensity": 0.37, + "Frequency": 40.9583 + }, + { + "Time": 50, + "Intensity": 0.080825, + "Frequency": 40.805 + }, + { + "Time": 66, + "Intensity": 0.6, + "Frequency": 40.4219 + }, + { + "Time": 84, + "Intensity": 0.11637, + "Frequency": 38.3007 + }, + { + "Time": 114, + "Intensity": 0.25, + "Frequency": 38.0706 + }, + { + "Time": 150, + "Intensity": 0.084815, + "Frequency": 37.994 + }, + { + "Time": 184, + "Intensity": 0.18, + "Frequency": 38.0707 + }, + { + "Time": 234, + "Intensity": 0.041641, + "Frequency": 38.0707 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.0707 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1167, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.0707 + }, + { + "Time": 16, + "Intensity": 0.23, + "Frequency": 38.0707 + }, + { + "Time": 33, + "Intensity": 0.049233, + "Frequency": 38.0709 + }, + { + "Time": 50, + "Intensity": 0.15, + "Frequency": 37.9175 + }, + { + "Time": 66, + "Intensity": 0.028695, + "Frequency": 37.9173 + }, + { + "Time": 96, + "Intensity": 0.08, + "Frequency": 38.0708 + }, + { + "Time": 133, + "Intensity": 0.046483, + "Frequency": 37.8408 + }, + { + "Time": 150, + "Intensity": 0.037565, + "Frequency": 37.8408 + }, + { + "Time": 166, + "Intensity": 0.037006, + "Frequency": 38.2244 + }, + { + "Time": 183, + "Intensity": 0.031955, + "Frequency": 38.0709 + }, + { + "Time": 200, + "Intensity": 0.043736, + "Frequency": 37.9943 + }, + { + "Time": 216, + "Intensity": 0.025359, + "Frequency": 37.8409 + }, + { + "Time": 233, + "Intensity": 0.027193, + "Frequency": 37.9943 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 37.9942 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1400, + "Parameters": { + "Intensity": 27, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37.9943 + }, + { + "Time": 15, + "Intensity": 0.18, + "Frequency": 37.9942 + }, + { + "Time": 33, + "Intensity": 0.018389, + "Frequency": 37.9942 + }, + { + "Time": 50, + "Intensity": 0.020258, + "Frequency": 37.9942 + }, + { + "Time": 76, + "Intensity": 0.11, + "Frequency": 37.9942 + }, + { + "Time": 117, + "Intensity": 0.016523, + "Frequency": 38.1475 + }, + { + "Time": 136, + "Intensity": 0.14, + "Frequency": 37.9172 + }, + { + "Time": 150, + "Intensity": 0.016324, + "Frequency": 37.8405 + }, + { + "Time": 167, + "Intensity": 0.016409, + "Frequency": 37.9173 + }, + { + "Time": 190, + "Intensity": 0.08, + "Frequency": 37.9173 + }, + { + "Time": 217, + "Intensity": 7.2853e-05, + "Frequency": 38.2236 + }, + { + "Time": 233, + "Intensity": 0.00010155, + "Frequency": 38.1472 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.3008 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 234, + "StartTime": 1633, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.1472 + }, + { + "Time": 17, + "Intensity": 7.2025e-05, + "Frequency": 38.3008 + }, + { + "Time": 34, + "Intensity": 4.4664e-05, + "Frequency": 38.0708 + }, + { + "Time": 50, + "Intensity": 5.4972e-05, + "Frequency": 38.0708 + }, + { + "Time": 67, + "Intensity": 4.9011e-05, + "Frequency": 37.8409 + }, + { + "Time": 84, + "Intensity": 4.0321e-05, + "Frequency": 38.0706 + }, + { + "Time": 100, + "Intensity": 2.647e-05, + "Frequency": 38.1469 + }, + { + "Time": 117, + "Intensity": 1.4281e-05, + "Frequency": 38.0701 + }, + { + "Time": 134, + "Intensity": 5.3637e-06, + "Frequency": 37.917 + }, + { + "Time": 150, + "Intensity": 3.4715e-06, + "Frequency": 37.8405 + }, + { + "Time": 167, + "Intensity": 1.7078e-05, + "Frequency": 37.8406 + }, + { + "Time": 184, + "Intensity": 3.4403e-06, + "Frequency": 37.6101 + }, + { + "Time": 200, + "Intensity": 3.0648e-06, + "Frequency": 36.9629 + }, + { + "Time": 217, + "Intensity": 1.4176e-06, + "Frequency": 36.9629 + }, + { + "Time": 234, + "Intensity": 0, + "Frequency": 34.8347 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_m.json index 62b9546c80..30e2d9e73a 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/SpeedUp_m.json @@ -1,691 +1,691 @@ -{ - "MetaData": { - "Create": "2021-10-18", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 0, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 40.1532 - }, - { - "Time": 11, - "Intensity": 0.38, - "Frequency": 70 - }, - { - "Time": 33, - "Intensity": 0.044387, - "Frequency": 37.3798 - }, - { - "Time": 43, - "Intensity": 0.58, - "Frequency": 37.2261 - }, - { - "Time": 53, - "Intensity": 0.12, - "Frequency": 38.4537 - }, - { - "Time": 84, - "Intensity": 0.93, - "Frequency": 47 - }, - { - "Time": 133, - "Intensity": 0.15797, - "Frequency": 37.8403 - }, - { - "Time": 149, - "Intensity": 1, - "Frequency": 42 - }, - { - "Time": 167, - "Intensity": 0.33416, - "Frequency": 37.8405 - }, - { - "Time": 188, - "Intensity": 1, - "Frequency": 37.9941 - }, - { - "Time": 200, - "Intensity": 0.37425, - "Frequency": 38.3774 - }, - { - "Time": 220, - "Intensity": 1, - "Frequency": 32 - }, - { - "Time": 233, - "Intensity": 0.46612, - "Frequency": 38.0703 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.0703 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 233, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.0703 - }, - { - "Time": 21, - "Intensity": 0.89, - "Frequency": 70 - }, - { - "Time": 50, - "Intensity": 0.2731, - "Frequency": 38.5306 - }, - { - "Time": 73, - "Intensity": 0.89, - "Frequency": 70 - }, - { - "Time": 84, - "Intensity": 0.40483, - "Frequency": 40.1155 - }, - { - "Time": 106, - "Intensity": 1, - "Frequency": 70 - }, - { - "Time": 117, - "Intensity": 0.44912, - "Frequency": 38.1477 - }, - { - "Time": 137, - "Intensity": 1, - "Frequency": 58 - }, - { - "Time": 150, - "Intensity": 0.50406, - "Frequency": 38.4543 - }, - { - "Time": 167, - "Intensity": 0.79268, - "Frequency": 38.1473 - }, - { - "Time": 184, - "Intensity": 0.53455, - "Frequency": 37.9174 - }, - { - "Time": 200, - "Intensity": 1, - "Frequency": 37.9172 - }, - { - "Time": 217, - "Intensity": 0.69526, - "Frequency": 38.1476 - }, - { - "Time": 234, - "Intensity": 0.8526, - "Frequency": 38.2243 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.4541 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 467, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.2243 - }, - { - "Time": 16, - "Intensity": 0.31475, - "Frequency": 38.4541 - }, - { - "Time": 33, - "Intensity": 1, - "Frequency": 38.2232 - }, - { - "Time": 50, - "Intensity": 0.44752, - "Frequency": 38.2232 - }, - { - "Time": 66, - "Intensity": 0.29572, - "Frequency": 37.8401 - }, - { - "Time": 83, - "Intensity": 0.64702, - "Frequency": 37.7634 - }, - { - "Time": 100, - "Intensity": 0.64717, - "Frequency": 37.3793 - }, - { - "Time": 116, - "Intensity": 0.3679, - "Frequency": 37.2258 - }, - { - "Time": 133, - "Intensity": 0.24298, - "Frequency": 37.4567 - }, - { - "Time": 150, - "Intensity": 0.55359, - "Frequency": 37.6872 - }, - { - "Time": 166, - "Intensity": 0.67465, - "Frequency": 37.5334 - }, - { - "Time": 183, - "Intensity": 0.62278, - "Frequency": 37.4566 - }, - { - "Time": 200, - "Intensity": 0.69885, - "Frequency": 37.303 - }, - { - "Time": 216, - "Intensity": 0.32678, - "Frequency": 37.2261 - }, - { - "Time": 233, - "Intensity": 0.535, - "Frequency": 37.0724 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 36.9954 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 700, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37.0724 - }, - { - "Time": 17, - "Intensity": 0.33735, - "Frequency": 36.9954 - }, - { - "Time": 33, - "Intensity": 0.65451, - "Frequency": 37.3029 - }, - { - "Time": 50, - "Intensity": 0.42331, - "Frequency": 37.6869 - }, - { - "Time": 67, - "Intensity": 0.24668, - "Frequency": 37.9943 - }, - { - "Time": 83, - "Intensity": 0.38753, - "Frequency": 37.9943 - }, - { - "Time": 100, - "Intensity": 0.11651, - "Frequency": 38.224 - }, - { - "Time": 117, - "Intensity": 0.1304, - "Frequency": 38.3772 - }, - { - "Time": 133, - "Intensity": 0.49327, - "Frequency": 38.2242 - }, - { - "Time": 150, - "Intensity": 0.22527, - "Frequency": 38.3776 - }, - { - "Time": 167, - "Intensity": 0.21292, - "Frequency": 38.684 - }, - { - "Time": 183, - "Intensity": 0.26452, - "Frequency": 38.9137 - }, - { - "Time": 200, - "Intensity": 0.21029, - "Frequency": 38.9136 - }, - { - "Time": 217, - "Intensity": 0.18462, - "Frequency": 38.6836 - }, - { - "Time": 233, - "Intensity": 0.1114, - "Frequency": 38.7602 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.9133 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 933, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.7602 - }, - { - "Time": 17, - "Intensity": 0.11051, - "Frequency": 38.9133 - }, - { - "Time": 32, - "Intensity": 0.37, - "Frequency": 40.9583 - }, - { - "Time": 50, - "Intensity": 0.080825, - "Frequency": 40.805 - }, - { - "Time": 66, - "Intensity": 0.6, - "Frequency": 40.4219 - }, - { - "Time": 84, - "Intensity": 0.11637, - "Frequency": 38.3007 - }, - { - "Time": 114, - "Intensity": 0.25, - "Frequency": 38.0706 - }, - { - "Time": 150, - "Intensity": 0.084815, - "Frequency": 37.994 - }, - { - "Time": 184, - "Intensity": 0.18, - "Frequency": 38.0707 - }, - { - "Time": 234, - "Intensity": 0.041641, - "Frequency": 38.0707 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.0707 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1167, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.0707 - }, - { - "Time": 16, - "Intensity": 0.23, - "Frequency": 38.0707 - }, - { - "Time": 33, - "Intensity": 0.049233, - "Frequency": 38.0709 - }, - { - "Time": 50, - "Intensity": 0.15, - "Frequency": 37.9175 - }, - { - "Time": 66, - "Intensity": 0.028695, - "Frequency": 37.9173 - }, - { - "Time": 96, - "Intensity": 0.08, - "Frequency": 38.0708 - }, - { - "Time": 133, - "Intensity": 0.046483, - "Frequency": 37.8408 - }, - { - "Time": 150, - "Intensity": 0.037565, - "Frequency": 37.8408 - }, - { - "Time": 166, - "Intensity": 0.037006, - "Frequency": 38.2244 - }, - { - "Time": 183, - "Intensity": 0.031955, - "Frequency": 38.0709 - }, - { - "Time": 200, - "Intensity": 0.043736, - "Frequency": 37.9943 - }, - { - "Time": 216, - "Intensity": 0.025359, - "Frequency": 37.8409 - }, - { - "Time": 233, - "Intensity": 0.027193, - "Frequency": 37.9943 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 37.9942 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1400, - "Parameters": { - "Intensity": 36, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37.9943 - }, - { - "Time": 15, - "Intensity": 0.18, - "Frequency": 37.9942 - }, - { - "Time": 33, - "Intensity": 0.018389, - "Frequency": 37.9942 - }, - { - "Time": 50, - "Intensity": 0.020258, - "Frequency": 37.9942 - }, - { - "Time": 76, - "Intensity": 0.11, - "Frequency": 37.9942 - }, - { - "Time": 117, - "Intensity": 0.016523, - "Frequency": 38.1475 - }, - { - "Time": 136, - "Intensity": 0.14, - "Frequency": 37.9172 - }, - { - "Time": 150, - "Intensity": 0.016324, - "Frequency": 37.8405 - }, - { - "Time": 167, - "Intensity": 0.016409, - "Frequency": 37.9173 - }, - { - "Time": 190, - "Intensity": 0.08, - "Frequency": 37.9173 - }, - { - "Time": 217, - "Intensity": 7.2853e-05, - "Frequency": 38.2236 - }, - { - "Time": 233, - "Intensity": 0.00010155, - "Frequency": 38.1472 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 38.3008 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 234, - "StartTime": 1633, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 38.1472 - }, - { - "Time": 17, - "Intensity": 7.2025e-05, - "Frequency": 38.3008 - }, - { - "Time": 34, - "Intensity": 4.4664e-05, - "Frequency": 38.0708 - }, - { - "Time": 50, - "Intensity": 5.4972e-05, - "Frequency": 38.0708 - }, - { - "Time": 67, - "Intensity": 4.9011e-05, - "Frequency": 37.8409 - }, - { - "Time": 84, - "Intensity": 4.0321e-05, - "Frequency": 38.0706 - }, - { - "Time": 100, - "Intensity": 2.647e-05, - "Frequency": 38.1469 - }, - { - "Time": 117, - "Intensity": 1.4281e-05, - "Frequency": 38.0701 - }, - { - "Time": 134, - "Intensity": 5.3637e-06, - "Frequency": 37.917 - }, - { - "Time": 150, - "Intensity": 3.4715e-06, - "Frequency": 37.8405 - }, - { - "Time": 167, - "Intensity": 1.7078e-05, - "Frequency": 37.8406 - }, - { - "Time": 184, - "Intensity": 3.4403e-06, - "Frequency": 37.6101 - }, - { - "Time": 200, - "Intensity": 3.0648e-06, - "Frequency": 36.9629 - }, - { - "Time": 217, - "Intensity": 1.4176e-06, - "Frequency": 36.9629 - }, - { - "Time": 234, - "Intensity": 0, - "Frequency": 34.8347 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2021-10-18", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 0, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 40.1532 + }, + { + "Time": 11, + "Intensity": 0.38, + "Frequency": 70 + }, + { + "Time": 33, + "Intensity": 0.044387, + "Frequency": 37.3798 + }, + { + "Time": 43, + "Intensity": 0.58, + "Frequency": 37.2261 + }, + { + "Time": 53, + "Intensity": 0.12, + "Frequency": 38.4537 + }, + { + "Time": 84, + "Intensity": 0.93, + "Frequency": 47 + }, + { + "Time": 133, + "Intensity": 0.15797, + "Frequency": 37.8403 + }, + { + "Time": 149, + "Intensity": 1, + "Frequency": 42 + }, + { + "Time": 167, + "Intensity": 0.33416, + "Frequency": 37.8405 + }, + { + "Time": 188, + "Intensity": 1, + "Frequency": 37.9941 + }, + { + "Time": 200, + "Intensity": 0.37425, + "Frequency": 38.3774 + }, + { + "Time": 220, + "Intensity": 1, + "Frequency": 32 + }, + { + "Time": 233, + "Intensity": 0.46612, + "Frequency": 38.0703 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.0703 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 233, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.0703 + }, + { + "Time": 21, + "Intensity": 0.89, + "Frequency": 70 + }, + { + "Time": 50, + "Intensity": 0.2731, + "Frequency": 38.5306 + }, + { + "Time": 73, + "Intensity": 0.89, + "Frequency": 70 + }, + { + "Time": 84, + "Intensity": 0.40483, + "Frequency": 40.1155 + }, + { + "Time": 106, + "Intensity": 1, + "Frequency": 70 + }, + { + "Time": 117, + "Intensity": 0.44912, + "Frequency": 38.1477 + }, + { + "Time": 137, + "Intensity": 1, + "Frequency": 58 + }, + { + "Time": 150, + "Intensity": 0.50406, + "Frequency": 38.4543 + }, + { + "Time": 167, + "Intensity": 0.79268, + "Frequency": 38.1473 + }, + { + "Time": 184, + "Intensity": 0.53455, + "Frequency": 37.9174 + }, + { + "Time": 200, + "Intensity": 1, + "Frequency": 37.9172 + }, + { + "Time": 217, + "Intensity": 0.69526, + "Frequency": 38.1476 + }, + { + "Time": 234, + "Intensity": 0.8526, + "Frequency": 38.2243 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.4541 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 467, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.2243 + }, + { + "Time": 16, + "Intensity": 0.31475, + "Frequency": 38.4541 + }, + { + "Time": 33, + "Intensity": 1, + "Frequency": 38.2232 + }, + { + "Time": 50, + "Intensity": 0.44752, + "Frequency": 38.2232 + }, + { + "Time": 66, + "Intensity": 0.29572, + "Frequency": 37.8401 + }, + { + "Time": 83, + "Intensity": 0.64702, + "Frequency": 37.7634 + }, + { + "Time": 100, + "Intensity": 0.64717, + "Frequency": 37.3793 + }, + { + "Time": 116, + "Intensity": 0.3679, + "Frequency": 37.2258 + }, + { + "Time": 133, + "Intensity": 0.24298, + "Frequency": 37.4567 + }, + { + "Time": 150, + "Intensity": 0.55359, + "Frequency": 37.6872 + }, + { + "Time": 166, + "Intensity": 0.67465, + "Frequency": 37.5334 + }, + { + "Time": 183, + "Intensity": 0.62278, + "Frequency": 37.4566 + }, + { + "Time": 200, + "Intensity": 0.69885, + "Frequency": 37.303 + }, + { + "Time": 216, + "Intensity": 0.32678, + "Frequency": 37.2261 + }, + { + "Time": 233, + "Intensity": 0.535, + "Frequency": 37.0724 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 36.9954 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 700, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37.0724 + }, + { + "Time": 17, + "Intensity": 0.33735, + "Frequency": 36.9954 + }, + { + "Time": 33, + "Intensity": 0.65451, + "Frequency": 37.3029 + }, + { + "Time": 50, + "Intensity": 0.42331, + "Frequency": 37.6869 + }, + { + "Time": 67, + "Intensity": 0.24668, + "Frequency": 37.9943 + }, + { + "Time": 83, + "Intensity": 0.38753, + "Frequency": 37.9943 + }, + { + "Time": 100, + "Intensity": 0.11651, + "Frequency": 38.224 + }, + { + "Time": 117, + "Intensity": 0.1304, + "Frequency": 38.3772 + }, + { + "Time": 133, + "Intensity": 0.49327, + "Frequency": 38.2242 + }, + { + "Time": 150, + "Intensity": 0.22527, + "Frequency": 38.3776 + }, + { + "Time": 167, + "Intensity": 0.21292, + "Frequency": 38.684 + }, + { + "Time": 183, + "Intensity": 0.26452, + "Frequency": 38.9137 + }, + { + "Time": 200, + "Intensity": 0.21029, + "Frequency": 38.9136 + }, + { + "Time": 217, + "Intensity": 0.18462, + "Frequency": 38.6836 + }, + { + "Time": 233, + "Intensity": 0.1114, + "Frequency": 38.7602 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.9133 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 933, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.7602 + }, + { + "Time": 17, + "Intensity": 0.11051, + "Frequency": 38.9133 + }, + { + "Time": 32, + "Intensity": 0.37, + "Frequency": 40.9583 + }, + { + "Time": 50, + "Intensity": 0.080825, + "Frequency": 40.805 + }, + { + "Time": 66, + "Intensity": 0.6, + "Frequency": 40.4219 + }, + { + "Time": 84, + "Intensity": 0.11637, + "Frequency": 38.3007 + }, + { + "Time": 114, + "Intensity": 0.25, + "Frequency": 38.0706 + }, + { + "Time": 150, + "Intensity": 0.084815, + "Frequency": 37.994 + }, + { + "Time": 184, + "Intensity": 0.18, + "Frequency": 38.0707 + }, + { + "Time": 234, + "Intensity": 0.041641, + "Frequency": 38.0707 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.0707 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1167, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.0707 + }, + { + "Time": 16, + "Intensity": 0.23, + "Frequency": 38.0707 + }, + { + "Time": 33, + "Intensity": 0.049233, + "Frequency": 38.0709 + }, + { + "Time": 50, + "Intensity": 0.15, + "Frequency": 37.9175 + }, + { + "Time": 66, + "Intensity": 0.028695, + "Frequency": 37.9173 + }, + { + "Time": 96, + "Intensity": 0.08, + "Frequency": 38.0708 + }, + { + "Time": 133, + "Intensity": 0.046483, + "Frequency": 37.8408 + }, + { + "Time": 150, + "Intensity": 0.037565, + "Frequency": 37.8408 + }, + { + "Time": 166, + "Intensity": 0.037006, + "Frequency": 38.2244 + }, + { + "Time": 183, + "Intensity": 0.031955, + "Frequency": 38.0709 + }, + { + "Time": 200, + "Intensity": 0.043736, + "Frequency": 37.9943 + }, + { + "Time": 216, + "Intensity": 0.025359, + "Frequency": 37.8409 + }, + { + "Time": 233, + "Intensity": 0.027193, + "Frequency": 37.9943 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 37.9942 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1400, + "Parameters": { + "Intensity": 36, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37.9943 + }, + { + "Time": 15, + "Intensity": 0.18, + "Frequency": 37.9942 + }, + { + "Time": 33, + "Intensity": 0.018389, + "Frequency": 37.9942 + }, + { + "Time": 50, + "Intensity": 0.020258, + "Frequency": 37.9942 + }, + { + "Time": 76, + "Intensity": 0.11, + "Frequency": 37.9942 + }, + { + "Time": 117, + "Intensity": 0.016523, + "Frequency": 38.1475 + }, + { + "Time": 136, + "Intensity": 0.14, + "Frequency": 37.9172 + }, + { + "Time": 150, + "Intensity": 0.016324, + "Frequency": 37.8405 + }, + { + "Time": 167, + "Intensity": 0.016409, + "Frequency": 37.9173 + }, + { + "Time": 190, + "Intensity": 0.08, + "Frequency": 37.9173 + }, + { + "Time": 217, + "Intensity": 7.2853e-05, + "Frequency": 38.2236 + }, + { + "Time": 233, + "Intensity": 0.00010155, + "Frequency": 38.1472 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 38.3008 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 234, + "StartTime": 1633, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 38.1472 + }, + { + "Time": 17, + "Intensity": 7.2025e-05, + "Frequency": 38.3008 + }, + { + "Time": 34, + "Intensity": 4.4664e-05, + "Frequency": 38.0708 + }, + { + "Time": 50, + "Intensity": 5.4972e-05, + "Frequency": 38.0708 + }, + { + "Time": 67, + "Intensity": 4.9011e-05, + "Frequency": 37.8409 + }, + { + "Time": 84, + "Intensity": 4.0321e-05, + "Frequency": 38.0706 + }, + { + "Time": 100, + "Intensity": 2.647e-05, + "Frequency": 38.1469 + }, + { + "Time": 117, + "Intensity": 1.4281e-05, + "Frequency": 38.0701 + }, + { + "Time": 134, + "Intensity": 5.3637e-06, + "Frequency": 37.917 + }, + { + "Time": 150, + "Intensity": 3.4715e-06, + "Frequency": 37.8405 + }, + { + "Time": 167, + "Intensity": 1.7078e-05, + "Frequency": 37.8406 + }, + { + "Time": 184, + "Intensity": 3.4403e-06, + "Frequency": 37.6101 + }, + { + "Time": 200, + "Intensity": 3.0648e-06, + "Frequency": 36.9629 + }, + { + "Time": 217, + "Intensity": 1.4176e-06, + "Frequency": 36.9629 + }, + { + "Time": 234, + "Intensity": 0, + "Frequency": 34.8347 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Switch_App.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Switch_App.json index 5aec4af157..3158c313a1 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Switch_App.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Switch_App.json @@ -1,45 +1,45 @@ -{ - "Channels" : - [ - { - "Parameters" : - { - "Index" : 1 - }, - "Pattern" : - [ - { - "Event" : - { - "Parameters" : - { - "Frequency" : 100, - "Intensity" : 100 - }, - "StartTime" : 1000, - "Type" : "transient" - } - }, - { - "Event" : - { - "Parameters" : - { - "Frequency" : 100, - "Intensity" : 100 - }, - "StartTime" : 2750, - "Type" : "transient" - } - } - ] - } - ], - "MetaData" : - { - "ChannelNumber" : 1, - "Create" : "2023-03-17", - "Discription" : "A json file format demo", - "Version" : 1.0 - } -} +{ + "Channels" : + [ + { + "Parameters" : + { + "Index" : 1 + }, + "Pattern" : + [ + { + "Event" : + { + "Parameters" : + { + "Frequency" : 100, + "Intensity" : 100 + }, + "StartTime" : 1000, + "Type" : "transient" + } + }, + { + "Event" : + { + "Parameters" : + { + "Frequency" : 100, + "Intensity" : 100 + }, + "StartTime" : 2750, + "Type" : "transient" + } + } + ] + } + ], + "MetaData" : + { + "ChannelNumber" : 1, + "Create" : "2023-03-17", + "Discription" : "A json file format demo", + "Version" : 1.0 + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_h.json index 8483440ee1..2ad20b4283 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_h.json @@ -1,97 +1,97 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 76, - "Parameters": { - "Intensity": 50, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 150, - "Parameters": { - "Intensity": 98, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 449, - "Parameters": { - "Intensity": 60, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 617, - "Parameters": { - "Intensity": 98, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 955, - "Parameters": { - "Intensity": 60, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1157, - "Parameters": { - "Intensity": 98, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1346, - "Parameters": { - "Intensity": 60, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1567, - "Parameters": { - "Intensity": 98, - "Frequency": 60 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 76, + "Parameters": { + "Intensity": 50, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 150, + "Parameters": { + "Intensity": 98, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 449, + "Parameters": { + "Intensity": 60, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 617, + "Parameters": { + "Intensity": 98, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 955, + "Parameters": { + "Intensity": 60, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1157, + "Parameters": { + "Intensity": 98, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1346, + "Parameters": { + "Intensity": 60, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1567, + "Parameters": { + "Intensity": 98, + "Frequency": 60 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_l.json index d5f2ab7938..58b724bf3b 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_l.json @@ -1,97 +1,97 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 76, - "Parameters": { - "Intensity": 30, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 150, - "Parameters": { - "Intensity": 58, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 449, - "Parameters": { - "Intensity": 36, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 617, - "Parameters": { - "Intensity": 58, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 955, - "Parameters": { - "Intensity": 36, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1157, - "Parameters": { - "Intensity": 58, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1346, - "Parameters": { - "Intensity": 36, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1567, - "Parameters": { - "Intensity": 58, - "Frequency": 60 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 76, + "Parameters": { + "Intensity": 30, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 150, + "Parameters": { + "Intensity": 58, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 449, + "Parameters": { + "Intensity": 36, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 617, + "Parameters": { + "Intensity": 58, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 955, + "Parameters": { + "Intensity": 36, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1157, + "Parameters": { + "Intensity": 58, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1346, + "Parameters": { + "Intensity": 36, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1567, + "Parameters": { + "Intensity": 58, + "Frequency": 60 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_m.json index b6dedfbe36..4cd8439f3e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/TableTennis_m.json @@ -1,97 +1,97 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 76, - "Parameters": { - "Intensity": 40, - "Frequency": 30 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 150, - "Parameters": { - "Intensity": 78, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 449, - "Parameters": { - "Intensity": 48, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 617, - "Parameters": { - "Intensity": 78, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 955, - "Parameters": { - "Intensity": 48, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1157, - "Parameters": { - "Intensity": 78, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1346, - "Parameters": { - "Intensity": 48, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1567, - "Parameters": { - "Intensity": 78, - "Frequency": 60 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 76, + "Parameters": { + "Intensity": 40, + "Frequency": 30 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 150, + "Parameters": { + "Intensity": 78, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 449, + "Parameters": { + "Intensity": 48, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 617, + "Parameters": { + "Intensity": 78, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 955, + "Parameters": { + "Intensity": 48, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1157, + "Parameters": { + "Intensity": 78, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1346, + "Parameters": { + "Intensity": 48, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1567, + "Parameters": { + "Intensity": 78, + "Frequency": 60 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_h.json index 72ac4eaf49..091dcb8352 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_h.json @@ -1,170 +1,170 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 43, - "StartTime": 0, - "Parameters": { - "Intensity": 100, - "Frequency": 59, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": -63 - }, - { - "Time": 37, - "Intensity": 1, - "Frequency": 53 - }, - { - "Time": 43, - "Intensity": 0, - "Frequency": -77 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 64, - "Parameters": { - "Intensity": 100, - "Frequency": 88 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 130, - "Parameters": { - "Intensity": 78, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 163, - "Parameters": { - "Intensity": 46, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 197, - "Parameters": { - "Intensity": 60, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 256, - "Parameters": { - "Intensity": 45, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 280, - "Parameters": { - "Intensity": 23, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 339, - "Parameters": { - "Intensity": 39, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 397, - "Parameters": { - "Intensity": 25, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 585, - "Parameters": { - "Intensity": 49, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 617, - "Parameters": { - "Intensity": 35, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 652, - "Parameters": { - "Intensity": 25, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 687, - "Parameters": { - "Intensity": 18, - "Frequency": 95 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 43, + "StartTime": 0, + "Parameters": { + "Intensity": 100, + "Frequency": 59, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": -63 + }, + { + "Time": 37, + "Intensity": 1, + "Frequency": 53 + }, + { + "Time": 43, + "Intensity": 0, + "Frequency": -77 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 64, + "Parameters": { + "Intensity": 100, + "Frequency": 88 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 130, + "Parameters": { + "Intensity": 78, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 163, + "Parameters": { + "Intensity": 46, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 197, + "Parameters": { + "Intensity": 60, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 256, + "Parameters": { + "Intensity": 45, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 280, + "Parameters": { + "Intensity": 23, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 339, + "Parameters": { + "Intensity": 39, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 397, + "Parameters": { + "Intensity": 25, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 585, + "Parameters": { + "Intensity": 49, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 617, + "Parameters": { + "Intensity": 35, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 652, + "Parameters": { + "Intensity": 25, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 687, + "Parameters": { + "Intensity": 18, + "Frequency": 95 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_l.json index 657576d7c9..70f1786a52 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_l.json @@ -1,170 +1,170 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 43, - "StartTime": 0, - "Parameters": { - "Intensity": 60, - "Frequency": 59, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": -63 - }, - { - "Time": 37, - "Intensity": 1, - "Frequency": 53 - }, - { - "Time": 43, - "Intensity": 0, - "Frequency": -77 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 64, - "Parameters": { - "Intensity": 60, - "Frequency": 88 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 130, - "Parameters": { - "Intensity": 46, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 163, - "Parameters": { - "Intensity": 27, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 197, - "Parameters": { - "Intensity": 36, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 256, - "Parameters": { - "Intensity": 27, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 280, - "Parameters": { - "Intensity": 13, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 339, - "Parameters": { - "Intensity": 23, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 397, - "Parameters": { - "Intensity": 15, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 585, - "Parameters": { - "Intensity": 29, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 617, - "Parameters": { - "Intensity": 21, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 652, - "Parameters": { - "Intensity": 15, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 687, - "Parameters": { - "Intensity": 10, - "Frequency": 95 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 43, + "StartTime": 0, + "Parameters": { + "Intensity": 60, + "Frequency": 59, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": -63 + }, + { + "Time": 37, + "Intensity": 1, + "Frequency": 53 + }, + { + "Time": 43, + "Intensity": 0, + "Frequency": -77 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 64, + "Parameters": { + "Intensity": 60, + "Frequency": 88 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 130, + "Parameters": { + "Intensity": 46, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 163, + "Parameters": { + "Intensity": 27, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 197, + "Parameters": { + "Intensity": 36, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 256, + "Parameters": { + "Intensity": 27, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 280, + "Parameters": { + "Intensity": 13, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 339, + "Parameters": { + "Intensity": 23, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 397, + "Parameters": { + "Intensity": 15, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 585, + "Parameters": { + "Intensity": 29, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 617, + "Parameters": { + "Intensity": 21, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 652, + "Parameters": { + "Intensity": 15, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 687, + "Parameters": { + "Intensity": 10, + "Frequency": 95 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_m.json index d805be87d0..fb8aa7a894 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tambourine_m.json @@ -1,170 +1,170 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 43, - "StartTime": 0, - "Parameters": { - "Intensity": 80, - "Frequency": 59, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": -63 - }, - { - "Time": 37, - "Intensity": 1, - "Frequency": 53 - }, - { - "Time": 43, - "Intensity": 0, - "Frequency": -77 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 64, - "Parameters": { - "Intensity": 80, - "Frequency": 88 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 130, - "Parameters": { - "Intensity": 62, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 163, - "Parameters": { - "Intensity": 36, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 197, - "Parameters": { - "Intensity": 48, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 256, - "Parameters": { - "Intensity": 36, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 280, - "Parameters": { - "Intensity": 18, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 339, - "Parameters": { - "Intensity": 31, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 397, - "Parameters": { - "Intensity": 20, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 585, - "Parameters": { - "Intensity": 39, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 617, - "Parameters": { - "Intensity": 28, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 652, - "Parameters": { - "Intensity": 20, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 687, - "Parameters": { - "Intensity": 14, - "Frequency": 95 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 43, + "StartTime": 0, + "Parameters": { + "Intensity": 80, + "Frequency": 59, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": -63 + }, + { + "Time": 37, + "Intensity": 1, + "Frequency": 53 + }, + { + "Time": 43, + "Intensity": 0, + "Frequency": -77 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 64, + "Parameters": { + "Intensity": 80, + "Frequency": 88 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 130, + "Parameters": { + "Intensity": 62, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 163, + "Parameters": { + "Intensity": 36, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 197, + "Parameters": { + "Intensity": 48, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 256, + "Parameters": { + "Intensity": 36, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 280, + "Parameters": { + "Intensity": 18, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 339, + "Parameters": { + "Intensity": 31, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 397, + "Parameters": { + "Intensity": 20, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 585, + "Parameters": { + "Intensity": 39, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 617, + "Parameters": { + "Intensity": 28, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 652, + "Parameters": { + "Intensity": 20, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 687, + "Parameters": { + "Intensity": 14, + "Frequency": 95 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_h.json index 99d7fac13f..b8c1c06e33 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_h.json @@ -1,989 +1,989 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 80, - "StartTime": 145, - "Parameters": { - "Intensity": 60, - "Frequency": 67, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 37, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 39, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 80, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 220, - "Parameters": { - "Intensity": 53, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 124, - "StartTime": 324, - "Parameters": { - "Intensity": 96, - "Frequency": 73, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 54, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 65, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 124, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 349, - "Parameters": { - "Intensity": 95, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 123, - "StartTime": 358, - "Parameters": { - "Intensity": 100, - "Frequency": 73, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 54, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 123, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 533, - "Parameters": { - "Intensity": 92, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 578, - "Parameters": { - "Intensity": 51, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 734, - "Parameters": { - "Intensity": 60, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 138, - "StartTime": 756, - "Parameters": { - "Intensity": 97, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 70, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 138, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 152, - "StartTime": 786, - "Parameters": { - "Intensity": 100, - "Frequency": 76, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 77, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 152, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 975, - "Parameters": { - "Intensity": 91, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1022, - "Parameters": { - "Intensity": 97, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1076, - "Parameters": { - "Intensity": 81, - "Frequency": 72 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1155, - "Parameters": { - "Intensity": 71, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1185, - "Parameters": { - "Intensity": 86, - "Frequency": 63 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 63, - "StartTime": 1350, - "Parameters": { - "Intensity": 57, - "Frequency": 41, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 26, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 33, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 63, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1418, - "Parameters": { - "Intensity": 68, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 60, - "StartTime": 1561, - "Parameters": { - "Intensity": 57, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 30, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 32, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 60, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1630, - "Parameters": { - "Intensity": 44, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1693, - "Parameters": { - "Intensity": 29, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 1830, - "Parameters": { - "Intensity": 25, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 34, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1916, - "Parameters": { - "Intensity": 60, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1958, - "Parameters": { - "Intensity": 29, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 165, - "StartTime": 2072, - "Parameters": { - "Intensity": 100, - "Frequency": 65, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 28, - "Intensity": 0.21, - "Frequency": -30 - }, - { - "Time": 36, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 128, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 165, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 323, - "StartTime": 2249, - "Parameters": { - "Intensity": 100, - "Frequency": 69, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 2, - "Intensity": 0.71, - "Frequency": -30 - }, - { - "Time": 137, - "Intensity": 0.11, - "Frequency": 36 - }, - { - "Time": 323, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2384, - "Parameters": { - "Intensity": 78, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2477, - "Parameters": { - "Intensity": 59, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 103, - "StartTime": 2492, - "Parameters": { - "Intensity": 54, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 51, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 103, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2689, - "Parameters": { - "Intensity": 69, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2761, - "Parameters": { - "Intensity": 56, - "Frequency": 78 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 104, - "StartTime": 2895, - "Parameters": { - "Intensity": 86, - "Frequency": 67, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 47, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 104, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3011, - "Parameters": { - "Intensity": 50, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3101, - "Parameters": { - "Intensity": 33, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 80, - "StartTime": 3189, - "Parameters": { - "Intensity": 62, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 40, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 42, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 80, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 101, - "StartTime": 3209, - "Parameters": { - "Intensity": 48, - "Frequency": 53, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 51, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 52, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 101, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3388, - "Parameters": { - "Intensity": 39, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3439, - "Parameters": { - "Intensity": 32, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 52, - "StartTime": 3512, - "Parameters": { - "Intensity": 40, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 26, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 52, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3655, - "Parameters": { - "Intensity": 42, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 138, - "StartTime": 3755, - "Parameters": { - "Intensity": 91, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 70, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 138, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3929, - "Parameters": { - "Intensity": 97, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4024, - "Parameters": { - "Intensity": 65, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 119, - "StartTime": 4133, - "Parameters": { - "Intensity": 100, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 54, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 62, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 119, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4134, - "Parameters": { - "Intensity": 88, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4272, - "Parameters": { - "Intensity": 39, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4327, - "Parameters": { - "Intensity": 32, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4484, - "Parameters": { - "Intensity": 39, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4526, - "Parameters": { - "Intensity": 53, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 80, - "StartTime": 4613, - "Parameters": { - "Intensity": 40, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 41, - "Intensity": 0.45, - "Frequency": 0 - }, - { - "Time": 42, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 80, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4832, - "Parameters": { - "Intensity": 43, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4863, - "Parameters": { - "Intensity": 31, - "Frequency": 84 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5041, - "Parameters": { - "Intensity": 30, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 85, - "StartTime": 5155, - "Parameters": { - "Intensity": 21, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 44, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 45, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 85, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 80, + "StartTime": 145, + "Parameters": { + "Intensity": 60, + "Frequency": 67, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 37, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 39, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 80, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 220, + "Parameters": { + "Intensity": 53, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 124, + "StartTime": 324, + "Parameters": { + "Intensity": 96, + "Frequency": 73, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 54, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 65, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 124, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 349, + "Parameters": { + "Intensity": 95, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 123, + "StartTime": 358, + "Parameters": { + "Intensity": 100, + "Frequency": 73, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 54, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 123, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 533, + "Parameters": { + "Intensity": 92, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 578, + "Parameters": { + "Intensity": 51, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 734, + "Parameters": { + "Intensity": 60, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 138, + "StartTime": 756, + "Parameters": { + "Intensity": 97, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 70, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 138, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 152, + "StartTime": 786, + "Parameters": { + "Intensity": 100, + "Frequency": 76, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 77, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 152, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 975, + "Parameters": { + "Intensity": 91, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1022, + "Parameters": { + "Intensity": 97, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1076, + "Parameters": { + "Intensity": 81, + "Frequency": 72 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1155, + "Parameters": { + "Intensity": 71, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1185, + "Parameters": { + "Intensity": 86, + "Frequency": 63 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 63, + "StartTime": 1350, + "Parameters": { + "Intensity": 57, + "Frequency": 41, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 26, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 33, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 63, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1418, + "Parameters": { + "Intensity": 68, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 60, + "StartTime": 1561, + "Parameters": { + "Intensity": 57, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 30, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 32, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 60, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1630, + "Parameters": { + "Intensity": 44, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1693, + "Parameters": { + "Intensity": 29, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 1830, + "Parameters": { + "Intensity": 25, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 34, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1916, + "Parameters": { + "Intensity": 60, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1958, + "Parameters": { + "Intensity": 29, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 165, + "StartTime": 2072, + "Parameters": { + "Intensity": 100, + "Frequency": 65, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 28, + "Intensity": 0.21, + "Frequency": -30 + }, + { + "Time": 36, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 128, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 165, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 323, + "StartTime": 2249, + "Parameters": { + "Intensity": 100, + "Frequency": 69, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 2, + "Intensity": 0.71, + "Frequency": -30 + }, + { + "Time": 137, + "Intensity": 0.11, + "Frequency": 36 + }, + { + "Time": 323, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2384, + "Parameters": { + "Intensity": 78, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2477, + "Parameters": { + "Intensity": 59, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 103, + "StartTime": 2492, + "Parameters": { + "Intensity": 54, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 51, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 103, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2689, + "Parameters": { + "Intensity": 69, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2761, + "Parameters": { + "Intensity": 56, + "Frequency": 78 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 104, + "StartTime": 2895, + "Parameters": { + "Intensity": 86, + "Frequency": 67, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 47, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 104, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3011, + "Parameters": { + "Intensity": 50, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3101, + "Parameters": { + "Intensity": 33, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 80, + "StartTime": 3189, + "Parameters": { + "Intensity": 62, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 40, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 42, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 80, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 101, + "StartTime": 3209, + "Parameters": { + "Intensity": 48, + "Frequency": 53, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 51, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 52, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 101, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3388, + "Parameters": { + "Intensity": 39, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3439, + "Parameters": { + "Intensity": 32, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 52, + "StartTime": 3512, + "Parameters": { + "Intensity": 40, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 26, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 52, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3655, + "Parameters": { + "Intensity": 42, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 138, + "StartTime": 3755, + "Parameters": { + "Intensity": 91, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 70, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 138, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3929, + "Parameters": { + "Intensity": 97, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4024, + "Parameters": { + "Intensity": 65, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 119, + "StartTime": 4133, + "Parameters": { + "Intensity": 100, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 54, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 62, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 119, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4134, + "Parameters": { + "Intensity": 88, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4272, + "Parameters": { + "Intensity": 39, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4327, + "Parameters": { + "Intensity": 32, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4484, + "Parameters": { + "Intensity": 39, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4526, + "Parameters": { + "Intensity": 53, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 80, + "StartTime": 4613, + "Parameters": { + "Intensity": 40, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 41, + "Intensity": 0.45, + "Frequency": 0 + }, + { + "Time": 42, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 80, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4832, + "Parameters": { + "Intensity": 43, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4863, + "Parameters": { + "Intensity": 31, + "Frequency": 84 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5041, + "Parameters": { + "Intensity": 30, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 85, + "StartTime": 5155, + "Parameters": { + "Intensity": 21, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 44, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 45, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 85, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_l.json index 41804cdae8..882fda7fd3 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_l.json @@ -1,989 +1,989 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 80, - "StartTime": 145, - "Parameters": { - "Intensity": 36, - "Frequency": 67, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 37, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 39, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 80, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 220, - "Parameters": { - "Intensity": 31, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 124, - "StartTime": 324, - "Parameters": { - "Intensity": 57, - "Frequency": 73, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 54, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 65, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 124, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 349, - "Parameters": { - "Intensity": 57, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 123, - "StartTime": 358, - "Parameters": { - "Intensity": 60, - "Frequency": 73, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 54, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 123, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 533, - "Parameters": { - "Intensity": 55, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 578, - "Parameters": { - "Intensity": 30, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 734, - "Parameters": { - "Intensity": 36, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 138, - "StartTime": 756, - "Parameters": { - "Intensity": 58, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 70, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 138, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 152, - "StartTime": 786, - "Parameters": { - "Intensity": 60, - "Frequency": 76, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 77, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 152, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 975, - "Parameters": { - "Intensity": 54, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1022, - "Parameters": { - "Intensity": 58, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1076, - "Parameters": { - "Intensity": 48, - "Frequency": 72 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1155, - "Parameters": { - "Intensity": 42, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1185, - "Parameters": { - "Intensity": 51, - "Frequency": 63 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 63, - "StartTime": 1350, - "Parameters": { - "Intensity": 34, - "Frequency": 41, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 26, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 33, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 63, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1418, - "Parameters": { - "Intensity": 40, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 60, - "StartTime": 1561, - "Parameters": { - "Intensity": 34, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 30, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 32, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 60, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1630, - "Parameters": { - "Intensity": 26, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1693, - "Parameters": { - "Intensity": 17, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 1830, - "Parameters": { - "Intensity": 15, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 34, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1916, - "Parameters": { - "Intensity": 36, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1958, - "Parameters": { - "Intensity": 17, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 165, - "StartTime": 2072, - "Parameters": { - "Intensity": 60, - "Frequency": 65, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 28, - "Intensity": 0.21, - "Frequency": -30 - }, - { - "Time": 36, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 128, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 165, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 323, - "StartTime": 2249, - "Parameters": { - "Intensity": 60, - "Frequency": 69, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 2, - "Intensity": 0.71, - "Frequency": -30 - }, - { - "Time": 137, - "Intensity": 0.11, - "Frequency": 36 - }, - { - "Time": 323, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2384, - "Parameters": { - "Intensity": 46, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2477, - "Parameters": { - "Intensity": 35, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 103, - "StartTime": 2492, - "Parameters": { - "Intensity": 32, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 51, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 103, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2689, - "Parameters": { - "Intensity": 41, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2761, - "Parameters": { - "Intensity": 33, - "Frequency": 78 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 104, - "StartTime": 2895, - "Parameters": { - "Intensity": 51, - "Frequency": 67, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 47, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 104, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3011, - "Parameters": { - "Intensity": 30, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3101, - "Parameters": { - "Intensity": 19, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 80, - "StartTime": 3189, - "Parameters": { - "Intensity": 37, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 40, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 42, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 80, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 101, - "StartTime": 3209, - "Parameters": { - "Intensity": 28, - "Frequency": 53, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 51, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 52, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 101, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3388, - "Parameters": { - "Intensity": 23, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3439, - "Parameters": { - "Intensity": 19, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 52, - "StartTime": 3512, - "Parameters": { - "Intensity": 24, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 26, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 52, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3655, - "Parameters": { - "Intensity": 25, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 138, - "StartTime": 3755, - "Parameters": { - "Intensity": 54, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 70, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 138, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3929, - "Parameters": { - "Intensity": 58, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4024, - "Parameters": { - "Intensity": 39, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 119, - "StartTime": 4133, - "Parameters": { - "Intensity": 60, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 54, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 62, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 119, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4134, - "Parameters": { - "Intensity": 52, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4272, - "Parameters": { - "Intensity": 23, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4327, - "Parameters": { - "Intensity": 19, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4484, - "Parameters": { - "Intensity": 23, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4526, - "Parameters": { - "Intensity": 31, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 80, - "StartTime": 4613, - "Parameters": { - "Intensity": 24, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 41, - "Intensity": 0.45, - "Frequency": 0 - }, - { - "Time": 42, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 80, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4832, - "Parameters": { - "Intensity": 25, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4863, - "Parameters": { - "Intensity": 18, - "Frequency": 84 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5041, - "Parameters": { - "Intensity": 18, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 85, - "StartTime": 5155, - "Parameters": { - "Intensity": 12, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 44, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 45, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 85, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 80, + "StartTime": 145, + "Parameters": { + "Intensity": 36, + "Frequency": 67, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 37, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 39, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 80, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 220, + "Parameters": { + "Intensity": 31, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 124, + "StartTime": 324, + "Parameters": { + "Intensity": 57, + "Frequency": 73, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 54, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 65, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 124, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 349, + "Parameters": { + "Intensity": 57, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 123, + "StartTime": 358, + "Parameters": { + "Intensity": 60, + "Frequency": 73, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 54, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 123, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 533, + "Parameters": { + "Intensity": 55, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 578, + "Parameters": { + "Intensity": 30, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 734, + "Parameters": { + "Intensity": 36, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 138, + "StartTime": 756, + "Parameters": { + "Intensity": 58, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 70, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 138, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 152, + "StartTime": 786, + "Parameters": { + "Intensity": 60, + "Frequency": 76, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 77, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 152, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 975, + "Parameters": { + "Intensity": 54, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1022, + "Parameters": { + "Intensity": 58, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1076, + "Parameters": { + "Intensity": 48, + "Frequency": 72 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1155, + "Parameters": { + "Intensity": 42, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1185, + "Parameters": { + "Intensity": 51, + "Frequency": 63 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 63, + "StartTime": 1350, + "Parameters": { + "Intensity": 34, + "Frequency": 41, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 26, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 33, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 63, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1418, + "Parameters": { + "Intensity": 40, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 60, + "StartTime": 1561, + "Parameters": { + "Intensity": 34, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 30, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 32, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 60, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1630, + "Parameters": { + "Intensity": 26, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1693, + "Parameters": { + "Intensity": 17, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 1830, + "Parameters": { + "Intensity": 15, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 34, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1916, + "Parameters": { + "Intensity": 36, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1958, + "Parameters": { + "Intensity": 17, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 165, + "StartTime": 2072, + "Parameters": { + "Intensity": 60, + "Frequency": 65, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 28, + "Intensity": 0.21, + "Frequency": -30 + }, + { + "Time": 36, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 128, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 165, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 323, + "StartTime": 2249, + "Parameters": { + "Intensity": 60, + "Frequency": 69, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 2, + "Intensity": 0.71, + "Frequency": -30 + }, + { + "Time": 137, + "Intensity": 0.11, + "Frequency": 36 + }, + { + "Time": 323, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2384, + "Parameters": { + "Intensity": 46, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2477, + "Parameters": { + "Intensity": 35, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 103, + "StartTime": 2492, + "Parameters": { + "Intensity": 32, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 51, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 103, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2689, + "Parameters": { + "Intensity": 41, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2761, + "Parameters": { + "Intensity": 33, + "Frequency": 78 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 104, + "StartTime": 2895, + "Parameters": { + "Intensity": 51, + "Frequency": 67, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 47, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 104, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3011, + "Parameters": { + "Intensity": 30, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3101, + "Parameters": { + "Intensity": 19, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 80, + "StartTime": 3189, + "Parameters": { + "Intensity": 37, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 40, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 42, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 80, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 101, + "StartTime": 3209, + "Parameters": { + "Intensity": 28, + "Frequency": 53, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 51, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 52, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 101, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3388, + "Parameters": { + "Intensity": 23, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3439, + "Parameters": { + "Intensity": 19, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 52, + "StartTime": 3512, + "Parameters": { + "Intensity": 24, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 26, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 52, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3655, + "Parameters": { + "Intensity": 25, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 138, + "StartTime": 3755, + "Parameters": { + "Intensity": 54, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 70, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 138, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3929, + "Parameters": { + "Intensity": 58, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4024, + "Parameters": { + "Intensity": 39, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 119, + "StartTime": 4133, + "Parameters": { + "Intensity": 60, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 54, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 62, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 119, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4134, + "Parameters": { + "Intensity": 52, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4272, + "Parameters": { + "Intensity": 23, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4327, + "Parameters": { + "Intensity": 19, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4484, + "Parameters": { + "Intensity": 23, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4526, + "Parameters": { + "Intensity": 31, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 80, + "StartTime": 4613, + "Parameters": { + "Intensity": 24, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 41, + "Intensity": 0.45, + "Frequency": 0 + }, + { + "Time": 42, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 80, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4832, + "Parameters": { + "Intensity": 25, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4863, + "Parameters": { + "Intensity": 18, + "Frequency": 84 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5041, + "Parameters": { + "Intensity": 18, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 85, + "StartTime": 5155, + "Parameters": { + "Intensity": 12, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 44, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 45, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 85, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_m.json index 04bd203808..78d575bf9e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Thunder_m.json @@ -1,989 +1,989 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 80, - "StartTime": 145, - "Parameters": { - "Intensity": 48, - "Frequency": 67, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 37, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 39, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 80, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 220, - "Parameters": { - "Intensity": 42, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 124, - "StartTime": 324, - "Parameters": { - "Intensity": 76, - "Frequency": 73, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 54, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 65, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 124, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 349, - "Parameters": { - "Intensity": 76, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 123, - "StartTime": 358, - "Parameters": { - "Intensity": 80, - "Frequency": 73, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 54, - "Intensity": 0.12, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 123, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 533, - "Parameters": { - "Intensity": 73, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 578, - "Parameters": { - "Intensity": 40, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 734, - "Parameters": { - "Intensity": 48, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 138, - "StartTime": 756, - "Parameters": { - "Intensity": 77, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 70, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 138, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 152, - "StartTime": 786, - "Parameters": { - "Intensity": 80, - "Frequency": 76, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 77, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 79, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 152, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 975, - "Parameters": { - "Intensity": 72, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1022, - "Parameters": { - "Intensity": 77, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1076, - "Parameters": { - "Intensity": 64, - "Frequency": 72 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1155, - "Parameters": { - "Intensity": 56, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1185, - "Parameters": { - "Intensity": 68, - "Frequency": 63 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 63, - "StartTime": 1350, - "Parameters": { - "Intensity": 45, - "Frequency": 41, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 26, - "Intensity": 0.1, - "Frequency": 0 - }, - { - "Time": 33, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 63, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1418, - "Parameters": { - "Intensity": 54, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 60, - "StartTime": 1561, - "Parameters": { - "Intensity": 45, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 30, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 32, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 60, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1630, - "Parameters": { - "Intensity": 35, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1693, - "Parameters": { - "Intensity": 23, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 64, - "StartTime": 1830, - "Parameters": { - "Intensity": 20, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 33, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 34, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 64, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1916, - "Parameters": { - "Intensity": 48, - "Frequency": 70 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1958, - "Parameters": { - "Intensity": 23, - "Frequency": 65 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 165, - "StartTime": 2072, - "Parameters": { - "Intensity": 80, - "Frequency": 65, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 28, - "Intensity": 0.21, - "Frequency": -30 - }, - { - "Time": 36, - "Intensity": 1, - "Frequency": 5 - }, - { - "Time": 128, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 165, - "Intensity": 0, - "Frequency": -30 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 323, - "StartTime": 2249, - "Parameters": { - "Intensity": 80, - "Frequency": 69, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 2, - "Intensity": 0.71, - "Frequency": -30 - }, - { - "Time": 137, - "Intensity": 0.11, - "Frequency": 36 - }, - { - "Time": 323, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2384, - "Parameters": { - "Intensity": 62, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2477, - "Parameters": { - "Intensity": 47, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 103, - "StartTime": 2492, - "Parameters": { - "Intensity": 43, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 51, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 103, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2689, - "Parameters": { - "Intensity": 55, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2761, - "Parameters": { - "Intensity": 44, - "Frequency": 78 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 104, - "StartTime": 2895, - "Parameters": { - "Intensity": 68, - "Frequency": 67, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 47, - "Intensity": 0.2, - "Frequency": 0 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 104, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3011, - "Parameters": { - "Intensity": 40, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3101, - "Parameters": { - "Intensity": 26, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 80, - "StartTime": 3189, - "Parameters": { - "Intensity": 49, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 40, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 42, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 80, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 101, - "StartTime": 3209, - "Parameters": { - "Intensity": 38, - "Frequency": 53, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 51, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 52, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 101, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3388, - "Parameters": { - "Intensity": 31, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3439, - "Parameters": { - "Intensity": 25, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 52, - "StartTime": 3512, - "Parameters": { - "Intensity": 32, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 26, - "Intensity": 0.15, - "Frequency": 0 - }, - { - "Time": 27, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 52, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3655, - "Parameters": { - "Intensity": 33, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 138, - "StartTime": 3755, - "Parameters": { - "Intensity": 72, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 70, - "Intensity": 0.13, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 138, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3929, - "Parameters": { - "Intensity": 77, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4024, - "Parameters": { - "Intensity": 52, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 119, - "StartTime": 4133, - "Parameters": { - "Intensity": 80, - "Frequency": 64, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 54, - "Intensity": 0.11, - "Frequency": 0 - }, - { - "Time": 62, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 119, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4134, - "Parameters": { - "Intensity": 70, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4272, - "Parameters": { - "Intensity": 31, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4327, - "Parameters": { - "Intensity": 25, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4484, - "Parameters": { - "Intensity": 31, - "Frequency": 75 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4526, - "Parameters": { - "Intensity": 42, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 80, - "StartTime": 4613, - "Parameters": { - "Intensity": 32, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 41, - "Intensity": 0.45, - "Frequency": 0 - }, - { - "Time": 42, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 80, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4832, - "Parameters": { - "Intensity": 34, - "Frequency": 74 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 4863, - "Parameters": { - "Intensity": 24, - "Frequency": 84 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 5041, - "Parameters": { - "Intensity": 24, - "Frequency": 56 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 85, - "StartTime": 5155, - "Parameters": { - "Intensity": 16, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 25 - }, - { - "Time": 44, - "Intensity": 0.19, - "Frequency": 0 - }, - { - "Time": 45, - "Intensity": 1, - "Frequency": 50 - }, - { - "Time": 85, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 80, + "StartTime": 145, + "Parameters": { + "Intensity": 48, + "Frequency": 67, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 37, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 39, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 80, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 220, + "Parameters": { + "Intensity": 42, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 124, + "StartTime": 324, + "Parameters": { + "Intensity": 76, + "Frequency": 73, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 54, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 65, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 124, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 349, + "Parameters": { + "Intensity": 76, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 123, + "StartTime": 358, + "Parameters": { + "Intensity": 80, + "Frequency": 73, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 54, + "Intensity": 0.12, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 123, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 533, + "Parameters": { + "Intensity": 73, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 578, + "Parameters": { + "Intensity": 40, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 734, + "Parameters": { + "Intensity": 48, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 138, + "StartTime": 756, + "Parameters": { + "Intensity": 77, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 70, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 138, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 152, + "StartTime": 786, + "Parameters": { + "Intensity": 80, + "Frequency": 76, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 77, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 79, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 152, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 975, + "Parameters": { + "Intensity": 72, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1022, + "Parameters": { + "Intensity": 77, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1076, + "Parameters": { + "Intensity": 64, + "Frequency": 72 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1155, + "Parameters": { + "Intensity": 56, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1185, + "Parameters": { + "Intensity": 68, + "Frequency": 63 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 63, + "StartTime": 1350, + "Parameters": { + "Intensity": 45, + "Frequency": 41, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 26, + "Intensity": 0.1, + "Frequency": 0 + }, + { + "Time": 33, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 63, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1418, + "Parameters": { + "Intensity": 54, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 60, + "StartTime": 1561, + "Parameters": { + "Intensity": 45, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 30, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 32, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 60, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1630, + "Parameters": { + "Intensity": 35, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1693, + "Parameters": { + "Intensity": 23, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 64, + "StartTime": 1830, + "Parameters": { + "Intensity": 20, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 33, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 34, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 64, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1916, + "Parameters": { + "Intensity": 48, + "Frequency": 70 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1958, + "Parameters": { + "Intensity": 23, + "Frequency": 65 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 165, + "StartTime": 2072, + "Parameters": { + "Intensity": 80, + "Frequency": 65, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 28, + "Intensity": 0.21, + "Frequency": -30 + }, + { + "Time": 36, + "Intensity": 1, + "Frequency": 5 + }, + { + "Time": 128, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 165, + "Intensity": 0, + "Frequency": -30 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 323, + "StartTime": 2249, + "Parameters": { + "Intensity": 80, + "Frequency": 69, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 2, + "Intensity": 0.71, + "Frequency": -30 + }, + { + "Time": 137, + "Intensity": 0.11, + "Frequency": 36 + }, + { + "Time": 323, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2384, + "Parameters": { + "Intensity": 62, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2477, + "Parameters": { + "Intensity": 47, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 103, + "StartTime": 2492, + "Parameters": { + "Intensity": 43, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 51, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 103, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2689, + "Parameters": { + "Intensity": 55, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2761, + "Parameters": { + "Intensity": 44, + "Frequency": 78 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 104, + "StartTime": 2895, + "Parameters": { + "Intensity": 68, + "Frequency": 67, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 47, + "Intensity": 0.2, + "Frequency": 0 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 104, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3011, + "Parameters": { + "Intensity": 40, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3101, + "Parameters": { + "Intensity": 26, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 80, + "StartTime": 3189, + "Parameters": { + "Intensity": 49, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 40, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 42, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 80, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 101, + "StartTime": 3209, + "Parameters": { + "Intensity": 38, + "Frequency": 53, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 51, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 52, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 101, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3388, + "Parameters": { + "Intensity": 31, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3439, + "Parameters": { + "Intensity": 25, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 52, + "StartTime": 3512, + "Parameters": { + "Intensity": 32, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 26, + "Intensity": 0.15, + "Frequency": 0 + }, + { + "Time": 27, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 52, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3655, + "Parameters": { + "Intensity": 33, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 138, + "StartTime": 3755, + "Parameters": { + "Intensity": 72, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 70, + "Intensity": 0.13, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 138, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3929, + "Parameters": { + "Intensity": 77, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4024, + "Parameters": { + "Intensity": 52, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 119, + "StartTime": 4133, + "Parameters": { + "Intensity": 80, + "Frequency": 64, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 54, + "Intensity": 0.11, + "Frequency": 0 + }, + { + "Time": 62, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 119, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4134, + "Parameters": { + "Intensity": 70, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4272, + "Parameters": { + "Intensity": 31, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4327, + "Parameters": { + "Intensity": 25, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4484, + "Parameters": { + "Intensity": 31, + "Frequency": 75 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4526, + "Parameters": { + "Intensity": 42, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 80, + "StartTime": 4613, + "Parameters": { + "Intensity": 32, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 41, + "Intensity": 0.45, + "Frequency": 0 + }, + { + "Time": 42, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 80, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4832, + "Parameters": { + "Intensity": 34, + "Frequency": 74 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 4863, + "Parameters": { + "Intensity": 24, + "Frequency": 84 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 5041, + "Parameters": { + "Intensity": 24, + "Frequency": 56 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 85, + "StartTime": 5155, + "Parameters": { + "Intensity": 16, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 25 + }, + { + "Time": 44, + "Intensity": 0.19, + "Frequency": 0 + }, + { + "Time": 45, + "Intensity": 1, + "Frequency": 50 + }, + { + "Time": 85, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_h.json index d8a4f9ff6c..1a62e2eb5f 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_h.json @@ -1,357 +1,357 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 84, - "StartTime": 96, - "Parameters": { - "Intensity": 100, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 37, - "Intensity": 0.94, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 0.68, - "Frequency": 0 - }, - { - "Time": 84, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 101, - "StartTime": 193, - "Parameters": { - "Intensity": 69, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 25, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.89, - "Frequency": 0 - }, - { - "Time": 101, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 432, - "StartTime": 298, - "Parameters": { - "Intensity": 70, - "Frequency": 7, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 21, - "Intensity": 0.03, - "Frequency": 31 - }, - { - "Time": 45, - "Intensity": 0.12, - "Frequency": 31 - }, - { - "Time": 74, - "Intensity": 0.26, - "Frequency": 30 - }, - { - "Time": 107, - "Intensity": 0.62, - "Frequency": 30 - }, - { - "Time": 135, - "Intensity": 0.48, - "Frequency": 29 - }, - { - "Time": 166, - "Intensity": 0.23, - "Frequency": 29 - }, - { - "Time": 210, - "Intensity": 0.31, - "Frequency": 30 - }, - { - "Time": 232, - "Intensity": 0.38, - "Frequency": 30 - }, - { - "Time": 265, - "Intensity": 0.15, - "Frequency": 30 - }, - { - "Time": 294, - "Intensity": 0.07, - "Frequency": 30 - }, - { - "Time": 315, - "Intensity": 0.03, - "Frequency": 30 - }, - { - "Time": 340, - "Intensity": 0.01, - "Frequency": 29 - }, - { - "Time": 432, - "Intensity": 0, - "Frequency": 33 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 515, - "Parameters": { - "Intensity": 100, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 16, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 33, - "Intensity": 0, - "Frequency": 29 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 66, - "Intensity": 0, - "Frequency": 36 - }, - { - "Time": 83, - "Intensity": 0, - "Frequency": 36 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 116, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 133, - "Intensity": 0, - "Frequency": 32 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 34 - }, - { - "Time": 166, - "Intensity": 0, - "Frequency": 35 - }, - { - "Time": 183, - "Intensity": 0, - "Frequency": 35 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 216, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 233, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 31 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1215, - "Parameters": { - "Intensity": 100, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37 - }, - { - "Time": 16, - "Intensity": 0, - "Frequency": 35 - }, - { - "Time": 33, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 29 - }, - { - "Time": 66, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 83, - "Intensity": 0, - "Frequency": 32 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 36 - }, - { - "Time": 116, - "Intensity": 0, - "Frequency": 34 - }, - { - "Time": 133, - "Intensity": 0, - "Frequency": 34 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 166, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 183, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 216, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 233, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 30 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 84, + "StartTime": 96, + "Parameters": { + "Intensity": 100, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 37, + "Intensity": 0.94, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 0.68, + "Frequency": 0 + }, + { + "Time": 84, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 101, + "StartTime": 193, + "Parameters": { + "Intensity": 69, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 25, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.89, + "Frequency": 0 + }, + { + "Time": 101, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 432, + "StartTime": 298, + "Parameters": { + "Intensity": 70, + "Frequency": 7, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 21, + "Intensity": 0.03, + "Frequency": 31 + }, + { + "Time": 45, + "Intensity": 0.12, + "Frequency": 31 + }, + { + "Time": 74, + "Intensity": 0.26, + "Frequency": 30 + }, + { + "Time": 107, + "Intensity": 0.62, + "Frequency": 30 + }, + { + "Time": 135, + "Intensity": 0.48, + "Frequency": 29 + }, + { + "Time": 166, + "Intensity": 0.23, + "Frequency": 29 + }, + { + "Time": 210, + "Intensity": 0.31, + "Frequency": 30 + }, + { + "Time": 232, + "Intensity": 0.38, + "Frequency": 30 + }, + { + "Time": 265, + "Intensity": 0.15, + "Frequency": 30 + }, + { + "Time": 294, + "Intensity": 0.07, + "Frequency": 30 + }, + { + "Time": 315, + "Intensity": 0.03, + "Frequency": 30 + }, + { + "Time": 340, + "Intensity": 0.01, + "Frequency": 29 + }, + { + "Time": 432, + "Intensity": 0, + "Frequency": 33 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 515, + "Parameters": { + "Intensity": 100, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 16, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 33, + "Intensity": 0, + "Frequency": 29 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 66, + "Intensity": 0, + "Frequency": 36 + }, + { + "Time": 83, + "Intensity": 0, + "Frequency": 36 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 116, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 133, + "Intensity": 0, + "Frequency": 32 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 34 + }, + { + "Time": 166, + "Intensity": 0, + "Frequency": 35 + }, + { + "Time": 183, + "Intensity": 0, + "Frequency": 35 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 216, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 233, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 31 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1215, + "Parameters": { + "Intensity": 100, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37 + }, + { + "Time": 16, + "Intensity": 0, + "Frequency": 35 + }, + { + "Time": 33, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 29 + }, + { + "Time": 66, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 83, + "Intensity": 0, + "Frequency": 32 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 36 + }, + { + "Time": 116, + "Intensity": 0, + "Frequency": 34 + }, + { + "Time": 133, + "Intensity": 0, + "Frequency": 34 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 166, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 183, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 216, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 233, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 30 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_l.json index eadaa1ef30..6f25becea6 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_l.json @@ -1,357 +1,357 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 84, - "StartTime": 96, - "Parameters": { - "Intensity": 60, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 37, - "Intensity": 0.94, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 0.68, - "Frequency": 0 - }, - { - "Time": 84, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 101, - "StartTime": 193, - "Parameters": { - "Intensity": 41, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 25, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.89, - "Frequency": 0 - }, - { - "Time": 101, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 432, - "StartTime": 298, - "Parameters": { - "Intensity": 42, - "Frequency": 7, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 21, - "Intensity": 0.03, - "Frequency": 31 - }, - { - "Time": 45, - "Intensity": 0.12, - "Frequency": 31 - }, - { - "Time": 74, - "Intensity": 0.26, - "Frequency": 30 - }, - { - "Time": 107, - "Intensity": 0.62, - "Frequency": 30 - }, - { - "Time": 135, - "Intensity": 0.48, - "Frequency": 29 - }, - { - "Time": 166, - "Intensity": 0.23, - "Frequency": 29 - }, - { - "Time": 210, - "Intensity": 0.31, - "Frequency": 30 - }, - { - "Time": 232, - "Intensity": 0.38, - "Frequency": 30 - }, - { - "Time": 265, - "Intensity": 0.15, - "Frequency": 30 - }, - { - "Time": 294, - "Intensity": 0.07, - "Frequency": 30 - }, - { - "Time": 315, - "Intensity": 0.03, - "Frequency": 30 - }, - { - "Time": 340, - "Intensity": 0.01, - "Frequency": 29 - }, - { - "Time": 432, - "Intensity": 0, - "Frequency": 33 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 515, - "Parameters": { - "Intensity": 60, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 16, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 33, - "Intensity": 0, - "Frequency": 29 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 66, - "Intensity": 0, - "Frequency": 36 - }, - { - "Time": 83, - "Intensity": 0, - "Frequency": 36 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 116, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 133, - "Intensity": 0, - "Frequency": 32 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 34 - }, - { - "Time": 166, - "Intensity": 0, - "Frequency": 35 - }, - { - "Time": 183, - "Intensity": 0, - "Frequency": 35 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 216, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 233, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 31 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1215, - "Parameters": { - "Intensity": 60, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37 - }, - { - "Time": 16, - "Intensity": 0, - "Frequency": 35 - }, - { - "Time": 33, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 29 - }, - { - "Time": 66, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 83, - "Intensity": 0, - "Frequency": 32 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 36 - }, - { - "Time": 116, - "Intensity": 0, - "Frequency": 34 - }, - { - "Time": 133, - "Intensity": 0, - "Frequency": 34 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 166, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 183, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 216, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 233, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 30 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 84, + "StartTime": 96, + "Parameters": { + "Intensity": 60, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 37, + "Intensity": 0.94, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 0.68, + "Frequency": 0 + }, + { + "Time": 84, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 101, + "StartTime": 193, + "Parameters": { + "Intensity": 41, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 25, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.89, + "Frequency": 0 + }, + { + "Time": 101, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 432, + "StartTime": 298, + "Parameters": { + "Intensity": 42, + "Frequency": 7, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 21, + "Intensity": 0.03, + "Frequency": 31 + }, + { + "Time": 45, + "Intensity": 0.12, + "Frequency": 31 + }, + { + "Time": 74, + "Intensity": 0.26, + "Frequency": 30 + }, + { + "Time": 107, + "Intensity": 0.62, + "Frequency": 30 + }, + { + "Time": 135, + "Intensity": 0.48, + "Frequency": 29 + }, + { + "Time": 166, + "Intensity": 0.23, + "Frequency": 29 + }, + { + "Time": 210, + "Intensity": 0.31, + "Frequency": 30 + }, + { + "Time": 232, + "Intensity": 0.38, + "Frequency": 30 + }, + { + "Time": 265, + "Intensity": 0.15, + "Frequency": 30 + }, + { + "Time": 294, + "Intensity": 0.07, + "Frequency": 30 + }, + { + "Time": 315, + "Intensity": 0.03, + "Frequency": 30 + }, + { + "Time": 340, + "Intensity": 0.01, + "Frequency": 29 + }, + { + "Time": 432, + "Intensity": 0, + "Frequency": 33 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 515, + "Parameters": { + "Intensity": 60, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 16, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 33, + "Intensity": 0, + "Frequency": 29 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 66, + "Intensity": 0, + "Frequency": 36 + }, + { + "Time": 83, + "Intensity": 0, + "Frequency": 36 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 116, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 133, + "Intensity": 0, + "Frequency": 32 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 34 + }, + { + "Time": 166, + "Intensity": 0, + "Frequency": 35 + }, + { + "Time": 183, + "Intensity": 0, + "Frequency": 35 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 216, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 233, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 31 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1215, + "Parameters": { + "Intensity": 60, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37 + }, + { + "Time": 16, + "Intensity": 0, + "Frequency": 35 + }, + { + "Time": 33, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 29 + }, + { + "Time": 66, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 83, + "Intensity": 0, + "Frequency": 32 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 36 + }, + { + "Time": 116, + "Intensity": 0, + "Frequency": 34 + }, + { + "Time": 133, + "Intensity": 0, + "Frequency": 34 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 166, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 183, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 216, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 233, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 30 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_m.json index 0763f83555..1b34dbe8a0 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Tumble_m.json @@ -1,357 +1,357 @@ -{ - "MetaData": { - "Create": "2022-04-27", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 84, - "StartTime": 96, - "Parameters": { - "Intensity": 80, - "Frequency": 46, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 37, - "Intensity": 0.94, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 0.68, - "Frequency": 0 - }, - { - "Time": 84, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 101, - "StartTime": 193, - "Parameters": { - "Intensity": 55, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 25, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.89, - "Frequency": 0 - }, - { - "Time": 101, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 432, - "StartTime": 298, - "Parameters": { - "Intensity": 56, - "Frequency": 7, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 21, - "Intensity": 0.03, - "Frequency": 31 - }, - { - "Time": 45, - "Intensity": 0.12, - "Frequency": 31 - }, - { - "Time": 74, - "Intensity": 0.26, - "Frequency": 30 - }, - { - "Time": 107, - "Intensity": 0.62, - "Frequency": 30 - }, - { - "Time": 135, - "Intensity": 0.48, - "Frequency": 29 - }, - { - "Time": 166, - "Intensity": 0.23, - "Frequency": 29 - }, - { - "Time": 210, - "Intensity": 0.31, - "Frequency": 30 - }, - { - "Time": 232, - "Intensity": 0.38, - "Frequency": 30 - }, - { - "Time": 265, - "Intensity": 0.15, - "Frequency": 30 - }, - { - "Time": 294, - "Intensity": 0.07, - "Frequency": 30 - }, - { - "Time": 315, - "Intensity": 0.03, - "Frequency": 30 - }, - { - "Time": 340, - "Intensity": 0.01, - "Frequency": 29 - }, - { - "Time": 432, - "Intensity": 0, - "Frequency": 33 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 515, - "Parameters": { - "Intensity": 80, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 16, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 33, - "Intensity": 0, - "Frequency": 29 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 66, - "Intensity": 0, - "Frequency": 36 - }, - { - "Time": 83, - "Intensity": 0, - "Frequency": 36 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 116, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 133, - "Intensity": 0, - "Frequency": 32 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 34 - }, - { - "Time": 166, - "Intensity": 0, - "Frequency": 35 - }, - { - "Time": 183, - "Intensity": 0, - "Frequency": 35 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 216, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 233, - "Intensity": 0, - "Frequency": 30 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 31 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1215, - "Parameters": { - "Intensity": 80, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 37 - }, - { - "Time": 16, - "Intensity": 0, - "Frequency": 35 - }, - { - "Time": 33, - "Intensity": 0, - "Frequency": 33 - }, - { - "Time": 50, - "Intensity": 0, - "Frequency": 29 - }, - { - "Time": 66, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 83, - "Intensity": 0, - "Frequency": 32 - }, - { - "Time": 100, - "Intensity": 0, - "Frequency": 36 - }, - { - "Time": 116, - "Intensity": 0, - "Frequency": 34 - }, - { - "Time": 133, - "Intensity": 0, - "Frequency": 34 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 166, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 183, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 200, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 216, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 233, - "Intensity": 0, - "Frequency": 31 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 30 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-27", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 84, + "StartTime": 96, + "Parameters": { + "Intensity": 80, + "Frequency": 46, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 37, + "Intensity": 0.94, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 0.68, + "Frequency": 0 + }, + { + "Time": 84, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 101, + "StartTime": 193, + "Parameters": { + "Intensity": 55, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 25, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.89, + "Frequency": 0 + }, + { + "Time": 101, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 432, + "StartTime": 298, + "Parameters": { + "Intensity": 56, + "Frequency": 7, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 21, + "Intensity": 0.03, + "Frequency": 31 + }, + { + "Time": 45, + "Intensity": 0.12, + "Frequency": 31 + }, + { + "Time": 74, + "Intensity": 0.26, + "Frequency": 30 + }, + { + "Time": 107, + "Intensity": 0.62, + "Frequency": 30 + }, + { + "Time": 135, + "Intensity": 0.48, + "Frequency": 29 + }, + { + "Time": 166, + "Intensity": 0.23, + "Frequency": 29 + }, + { + "Time": 210, + "Intensity": 0.31, + "Frequency": 30 + }, + { + "Time": 232, + "Intensity": 0.38, + "Frequency": 30 + }, + { + "Time": 265, + "Intensity": 0.15, + "Frequency": 30 + }, + { + "Time": 294, + "Intensity": 0.07, + "Frequency": 30 + }, + { + "Time": 315, + "Intensity": 0.03, + "Frequency": 30 + }, + { + "Time": 340, + "Intensity": 0.01, + "Frequency": 29 + }, + { + "Time": 432, + "Intensity": 0, + "Frequency": 33 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 515, + "Parameters": { + "Intensity": 80, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 16, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 33, + "Intensity": 0, + "Frequency": 29 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 66, + "Intensity": 0, + "Frequency": 36 + }, + { + "Time": 83, + "Intensity": 0, + "Frequency": 36 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 116, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 133, + "Intensity": 0, + "Frequency": 32 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 34 + }, + { + "Time": 166, + "Intensity": 0, + "Frequency": 35 + }, + { + "Time": 183, + "Intensity": 0, + "Frequency": 35 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 216, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 233, + "Intensity": 0, + "Frequency": 30 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 31 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1215, + "Parameters": { + "Intensity": 80, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 37 + }, + { + "Time": 16, + "Intensity": 0, + "Frequency": 35 + }, + { + "Time": 33, + "Intensity": 0, + "Frequency": 33 + }, + { + "Time": 50, + "Intensity": 0, + "Frequency": 29 + }, + { + "Time": 66, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 83, + "Intensity": 0, + "Frequency": 32 + }, + { + "Time": 100, + "Intensity": 0, + "Frequency": 36 + }, + { + "Time": 116, + "Intensity": 0, + "Frequency": 34 + }, + { + "Time": 133, + "Intensity": 0, + "Frequency": 34 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 166, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 183, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 200, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 216, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 233, + "Intensity": 0, + "Frequency": 31 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 30 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_h.json index 90eec93ba5..0dcc26ca8c 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_h.json @@ -1,318 +1,318 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 195, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 88, - "StartTime": 222, - "Parameters": { - "Intensity": 32, - "Frequency": 60, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 49, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 88, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 370, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 85, - "StartTime": 394, - "Parameters": { - "Intensity": 36, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 47, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 85, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 674, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 108, - "StartTime": 799, - "Parameters": { - "Intensity": 34, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 3, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 60, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 108, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 932, - "Parameters": { - "Intensity": 67, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 84, - "StartTime": 964, - "Parameters": { - "Intensity": 31, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 46, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 84, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1105, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 84, - "StartTime": 1128, - "Parameters": { - "Intensity": 34, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 46, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 84, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1258, - "Parameters": { - "Intensity": 64, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 55, - "StartTime": 1279, - "Parameters": { - "Intensity": 27, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 30, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 55, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1358, - "Parameters": { - "Intensity": 35, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 57, - "StartTime": 1388, - "Parameters": { - "Intensity": 18, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 0.56666666, - "Frequency": 0 - }, - { - "Time": 57, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 195, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 88, + "StartTime": 222, + "Parameters": { + "Intensity": 32, + "Frequency": 60, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 49, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 88, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 370, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 85, + "StartTime": 394, + "Parameters": { + "Intensity": 36, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 47, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 85, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 674, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 108, + "StartTime": 799, + "Parameters": { + "Intensity": 34, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 3, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 60, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 108, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 932, + "Parameters": { + "Intensity": 67, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 84, + "StartTime": 964, + "Parameters": { + "Intensity": 31, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 46, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 84, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1105, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 84, + "StartTime": 1128, + "Parameters": { + "Intensity": 34, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 46, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 84, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1258, + "Parameters": { + "Intensity": 64, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 55, + "StartTime": 1279, + "Parameters": { + "Intensity": 27, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 30, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 55, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1358, + "Parameters": { + "Intensity": 35, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 57, + "StartTime": 1388, + "Parameters": { + "Intensity": 18, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 0.56666666, + "Frequency": 0 + }, + { + "Time": 57, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_l.json index f877a60837..732ed45037 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_l.json @@ -1,318 +1,318 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 195, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 88, - "StartTime": 222, - "Parameters": { - "Intensity": 19, - "Frequency": 60, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 49, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 88, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 370, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 85, - "StartTime": 394, - "Parameters": { - "Intensity": 21, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 47, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 85, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 674, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 108, - "StartTime": 799, - "Parameters": { - "Intensity": 20, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 3, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 60, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 108, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 932, - "Parameters": { - "Intensity": 40, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 84, - "StartTime": 964, - "Parameters": { - "Intensity": 18, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 46, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 84, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1105, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 84, - "StartTime": 1128, - "Parameters": { - "Intensity": 20, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 46, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 84, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1258, - "Parameters": { - "Intensity": 38, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 55, - "StartTime": 1279, - "Parameters": { - "Intensity": 16, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 30, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 55, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1358, - "Parameters": { - "Intensity": 21, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 57, - "StartTime": 1388, - "Parameters": { - "Intensity": 10, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 0.56666666, - "Frequency": 0 - }, - { - "Time": 57, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 195, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 88, + "StartTime": 222, + "Parameters": { + "Intensity": 19, + "Frequency": 60, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 49, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 88, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 370, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 85, + "StartTime": 394, + "Parameters": { + "Intensity": 21, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 47, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 85, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 674, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 108, + "StartTime": 799, + "Parameters": { + "Intensity": 20, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 3, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 60, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 108, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 932, + "Parameters": { + "Intensity": 40, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 84, + "StartTime": 964, + "Parameters": { + "Intensity": 18, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 46, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 84, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1105, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 84, + "StartTime": 1128, + "Parameters": { + "Intensity": 20, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 46, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 84, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1258, + "Parameters": { + "Intensity": 38, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 55, + "StartTime": 1279, + "Parameters": { + "Intensity": 16, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 30, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 55, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1358, + "Parameters": { + "Intensity": 21, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 57, + "StartTime": 1388, + "Parameters": { + "Intensity": 10, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 0.56666666, + "Frequency": 0 + }, + { + "Time": 57, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_m.json index 5d33225fd0..c525dec828 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Typewriter_m.json @@ -1,318 +1,318 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 195, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 88, - "StartTime": 222, - "Parameters": { - "Intensity": 25, - "Frequency": 60, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 49, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 88, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 370, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 85, - "StartTime": 394, - "Parameters": { - "Intensity": 28, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 47, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 85, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 674, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 108, - "StartTime": 799, - "Parameters": { - "Intensity": 27, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 3, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 60, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 108, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 932, - "Parameters": { - "Intensity": 53, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 84, - "StartTime": 964, - "Parameters": { - "Intensity": 24, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 46, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 84, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1105, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 84, - "StartTime": 1128, - "Parameters": { - "Intensity": 27, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 46, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 84, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1258, - "Parameters": { - "Intensity": 51, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 55, - "StartTime": 1279, - "Parameters": { - "Intensity": 21, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 30, - "Intensity": 0.39215687, - "Frequency": 0 - }, - { - "Time": 55, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1358, - "Parameters": { - "Intensity": 28, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 57, - "StartTime": 1388, - "Parameters": { - "Intensity": 14, - "Frequency": 58, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 0.56666666, - "Frequency": 0 - }, - { - "Time": 57, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 195, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 88, + "StartTime": 222, + "Parameters": { + "Intensity": 25, + "Frequency": 60, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 49, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 88, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 370, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 85, + "StartTime": 394, + "Parameters": { + "Intensity": 28, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 47, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 85, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 674, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 108, + "StartTime": 799, + "Parameters": { + "Intensity": 27, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 3, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 60, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 108, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 932, + "Parameters": { + "Intensity": 53, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 84, + "StartTime": 964, + "Parameters": { + "Intensity": 24, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 46, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 84, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1105, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 84, + "StartTime": 1128, + "Parameters": { + "Intensity": 27, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 46, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 84, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1258, + "Parameters": { + "Intensity": 51, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 55, + "StartTime": 1279, + "Parameters": { + "Intensity": 21, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 30, + "Intensity": 0.39215687, + "Frequency": 0 + }, + { + "Time": 55, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1358, + "Parameters": { + "Intensity": 28, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 57, + "StartTime": 1388, + "Parameters": { + "Intensity": 14, + "Frequency": 58, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 0.56666666, + "Frequency": 0 + }, + { + "Time": 57, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/UpSlide_Stop.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/UpSlide_Stop.json index 02dcf36d7d..81b0d9d853 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/UpSlide_Stop.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/UpSlide_Stop.json @@ -1,33 +1,33 @@ -{ - "Channels" : - [ - { - "Parameters" : - { - "Index" : 1 - }, - "Pattern" : - [ - { - "Event" : - { - "Parameters" : - { - "Frequency" : 100, - "Intensity" : 100 - }, - "StartTime" : 1000, - "Type" : "transient" - } - } - ] - } - ], - "MetaData" : - { - "ChannelNumber" : 1, - "Create" : "2023-03-17", - "Discription" : "A json file format demo", - "Version" : 1.0 - } -} +{ + "Channels" : + [ + { + "Parameters" : + { + "Index" : 1 + }, + "Pattern" : + [ + { + "Event" : + { + "Parameters" : + { + "Frequency" : 100, + "Intensity" : 100 + }, + "StartTime" : 1000, + "Type" : "transient" + } + } + ] + } + ], + "MetaData" : + { + "ChannelNumber" : 1, + "Create" : "2023-03-17", + "Discription" : "A json file format demo", + "Version" : 1.0 + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_h.json index 83343aefbe..6b5dedb438 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_h.json @@ -1,127 +1,127 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 176, - "Parameters": { - "Intensity": 100, - "Frequency": 73 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 265, - "Parameters": { - "Intensity": 62, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 833, - "Parameters": { - "Intensity": 90, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 890, - "Parameters": { - "Intensity": 51, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1448, - "Parameters": { - "Intensity": 77, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1513, - "Parameters": { - "Intensity": 47, - "Frequency": 1 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2074, - "Parameters": { - "Intensity": 68, - "Frequency": 24 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2148, - "Parameters": { - "Intensity": 41, - "Frequency": 7 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2771, - "Parameters": { - "Intensity": 52, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2839, - "Parameters": { - "Intensity": 33, - "Frequency": 0 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 176, + "Parameters": { + "Intensity": 100, + "Frequency": 73 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 265, + "Parameters": { + "Intensity": 62, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 833, + "Parameters": { + "Intensity": 90, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 890, + "Parameters": { + "Intensity": 51, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1448, + "Parameters": { + "Intensity": 77, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1513, + "Parameters": { + "Intensity": 47, + "Frequency": 1 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2074, + "Parameters": { + "Intensity": 68, + "Frequency": 24 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2148, + "Parameters": { + "Intensity": 41, + "Frequency": 7 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2771, + "Parameters": { + "Intensity": 52, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2839, + "Parameters": { + "Intensity": 33, + "Frequency": 0 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_l.json index 8d5e6895b7..271f7d01c0 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_l.json @@ -1,127 +1,127 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 176, - "Parameters": { - "Intensity": 60, - "Frequency": 73 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 265, - "Parameters": { - "Intensity": 37, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 833, - "Parameters": { - "Intensity": 54, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 890, - "Parameters": { - "Intensity": 30, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1448, - "Parameters": { - "Intensity": 46, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1513, - "Parameters": { - "Intensity": 28, - "Frequency": 1 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2074, - "Parameters": { - "Intensity": 40, - "Frequency": 24 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2148, - "Parameters": { - "Intensity": 24, - "Frequency": 7 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2771, - "Parameters": { - "Intensity": 31, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2839, - "Parameters": { - "Intensity": 19, - "Frequency": 0 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 176, + "Parameters": { + "Intensity": 60, + "Frequency": 73 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 265, + "Parameters": { + "Intensity": 37, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 833, + "Parameters": { + "Intensity": 54, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 890, + "Parameters": { + "Intensity": 30, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1448, + "Parameters": { + "Intensity": 46, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1513, + "Parameters": { + "Intensity": 28, + "Frequency": 1 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2074, + "Parameters": { + "Intensity": 40, + "Frequency": 24 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2148, + "Parameters": { + "Intensity": 24, + "Frequency": 7 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2771, + "Parameters": { + "Intensity": 31, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2839, + "Parameters": { + "Intensity": 19, + "Frequency": 0 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_m.json index 0f4f20c61b..99a0caffa4 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Walk_m.json @@ -1,127 +1,127 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 176, - "Parameters": { - "Intensity": 80, - "Frequency": 73 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 265, - "Parameters": { - "Intensity": 49, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 833, - "Parameters": { - "Intensity": 72, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 890, - "Parameters": { - "Intensity": 40, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1448, - "Parameters": { - "Intensity": 61, - "Frequency": 20 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1513, - "Parameters": { - "Intensity": 37, - "Frequency": 1 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2074, - "Parameters": { - "Intensity": 54, - "Frequency": 24 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2148, - "Parameters": { - "Intensity": 32, - "Frequency": 7 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2771, - "Parameters": { - "Intensity": 41, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 2839, - "Parameters": { - "Intensity": 26, - "Frequency": 0 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 176, + "Parameters": { + "Intensity": 80, + "Frequency": 73 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 265, + "Parameters": { + "Intensity": 49, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 833, + "Parameters": { + "Intensity": 72, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 890, + "Parameters": { + "Intensity": 40, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1448, + "Parameters": { + "Intensity": 61, + "Frequency": 20 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1513, + "Parameters": { + "Intensity": 37, + "Frequency": 1 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2074, + "Parameters": { + "Intensity": 54, + "Frequency": 24 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2148, + "Parameters": { + "Intensity": 32, + "Frequency": 7 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2771, + "Parameters": { + "Intensity": 41, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 2839, + "Parameters": { + "Intensity": 26, + "Frequency": 0 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_h.json index 9a1be2e783..99249439d2 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_h.json @@ -1,136 +1,136 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 0, - "Parameters": { - "Intensity": 45, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 120, - "Parameters": { - "Intensity": 100, - "Frequency": 7 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 226, - "StartTime": 167, - "Parameters": { - "Intensity": 89, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 6, - "Intensity": 1.0, - "Frequency": -25 - }, - { - "Time": 50, - "Intensity": 0.52, - "Frequency": -68 - }, - { - "Time": 226, - "Intensity": 0.0, - "Frequency": -100 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 147, - "StartTime": 579, - "Parameters": { - "Intensity": 33, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 42, - "Intensity": 0.83, - "Frequency": -31 - }, - { - "Time": 102, - "Intensity": 1.0, - "Frequency": -91 - }, - { - "Time": 147, - "Intensity": 0.0, - "Frequency": -81 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 731, - "Parameters": { - "Intensity": 48, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1.0, - "Frequency": -19 - }, - { - "Time": 71, - "Intensity": 1.0, - "Frequency": -86 - }, - { - "Time": 150, - "Intensity": 0.0, - "Frequency": -100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 0, + "Parameters": { + "Intensity": 45, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 120, + "Parameters": { + "Intensity": 100, + "Frequency": 7 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 226, + "StartTime": 167, + "Parameters": { + "Intensity": 89, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 6, + "Intensity": 1.0, + "Frequency": -25 + }, + { + "Time": 50, + "Intensity": 0.52, + "Frequency": -68 + }, + { + "Time": 226, + "Intensity": 0.0, + "Frequency": -100 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 147, + "StartTime": 579, + "Parameters": { + "Intensity": 33, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 42, + "Intensity": 0.83, + "Frequency": -31 + }, + { + "Time": 102, + "Intensity": 1.0, + "Frequency": -91 + }, + { + "Time": 147, + "Intensity": 0.0, + "Frequency": -81 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 731, + "Parameters": { + "Intensity": 48, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1.0, + "Frequency": -19 + }, + { + "Time": 71, + "Intensity": 1.0, + "Frequency": -86 + }, + { + "Time": 150, + "Intensity": 0.0, + "Frequency": -100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_l.json index e852bd9500..1ee47e53cc 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_l.json @@ -1,136 +1,136 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 0, - "Parameters": { - "Intensity": 27, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 120, - "Parameters": { - "Intensity": 60, - "Frequency": 7 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 226, - "StartTime": 167, - "Parameters": { - "Intensity": 53, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 6, - "Intensity": 1.0, - "Frequency": -25 - }, - { - "Time": 50, - "Intensity": 0.52, - "Frequency": -68 - }, - { - "Time": 226, - "Intensity": 0.0, - "Frequency": -100 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 147, - "StartTime": 579, - "Parameters": { - "Intensity": 19, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 42, - "Intensity": 0.83, - "Frequency": -31 - }, - { - "Time": 102, - "Intensity": 1.0, - "Frequency": -91 - }, - { - "Time": 147, - "Intensity": 0.0, - "Frequency": -81 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 731, - "Parameters": { - "Intensity": 28, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1.0, - "Frequency": -19 - }, - { - "Time": 71, - "Intensity": 1.0, - "Frequency": -86 - }, - { - "Time": 150, - "Intensity": 0.0, - "Frequency": -100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 0, + "Parameters": { + "Intensity": 27, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 120, + "Parameters": { + "Intensity": 60, + "Frequency": 7 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 226, + "StartTime": 167, + "Parameters": { + "Intensity": 53, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 6, + "Intensity": 1.0, + "Frequency": -25 + }, + { + "Time": 50, + "Intensity": 0.52, + "Frequency": -68 + }, + { + "Time": 226, + "Intensity": 0.0, + "Frequency": -100 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 147, + "StartTime": 579, + "Parameters": { + "Intensity": 19, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 42, + "Intensity": 0.83, + "Frequency": -31 + }, + { + "Time": 102, + "Intensity": 1.0, + "Frequency": -91 + }, + { + "Time": 147, + "Intensity": 0.0, + "Frequency": -81 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 731, + "Parameters": { + "Intensity": 28, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1.0, + "Frequency": -19 + }, + { + "Time": 71, + "Intensity": 1.0, + "Frequency": -86 + }, + { + "Time": 150, + "Intensity": 0.0, + "Frequency": -100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_m.json index 7a5298406f..6a48189286 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Water_m.json @@ -1,136 +1,136 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 0, - "Parameters": { - "Intensity": 36, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 120, - "Parameters": { - "Intensity": 80, - "Frequency": 7 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 226, - "StartTime": 167, - "Parameters": { - "Intensity": 71, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 6, - "Intensity": 1.0, - "Frequency": -25 - }, - { - "Time": 50, - "Intensity": 0.52, - "Frequency": -68 - }, - { - "Time": 226, - "Intensity": 0.0, - "Frequency": -100 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 147, - "StartTime": 579, - "Parameters": { - "Intensity": 26, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 42, - "Intensity": 0.83, - "Frequency": -31 - }, - { - "Time": 102, - "Intensity": 1.0, - "Frequency": -91 - }, - { - "Time": 147, - "Intensity": 0.0, - "Frequency": -81 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 150, - "StartTime": 731, - "Parameters": { - "Intensity": 38, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 18, - "Intensity": 1.0, - "Frequency": -19 - }, - { - "Time": 71, - "Intensity": 1.0, - "Frequency": -86 - }, - { - "Time": 150, - "Intensity": 0.0, - "Frequency": -100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 0, + "Parameters": { + "Intensity": 36, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 120, + "Parameters": { + "Intensity": 80, + "Frequency": 7 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 226, + "StartTime": 167, + "Parameters": { + "Intensity": 71, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 6, + "Intensity": 1.0, + "Frequency": -25 + }, + { + "Time": 50, + "Intensity": 0.52, + "Frequency": -68 + }, + { + "Time": 226, + "Intensity": 0.0, + "Frequency": -100 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 147, + "StartTime": 579, + "Parameters": { + "Intensity": 26, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 42, + "Intensity": 0.83, + "Frequency": -31 + }, + { + "Time": 102, + "Intensity": 1.0, + "Frequency": -91 + }, + { + "Time": 147, + "Intensity": 0.0, + "Frequency": -81 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 150, + "StartTime": 731, + "Parameters": { + "Intensity": 38, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 18, + "Intensity": 1.0, + "Frequency": -19 + }, + { + "Time": 71, + "Intensity": 1.0, + "Frequency": -86 + }, + { + "Time": 150, + "Intensity": 0.0, + "Frequency": -100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_h.json index 6fa192ad1e..7ee72ab110 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_h.json @@ -1,2304 +1,2304 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 0, - "Parameters": { - "Intensity": 38, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 120, - "Intensity": 0.32, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.68, - "Frequency": 8 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5, - "Parameters": { - "Intensity": 61, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0.45, - "Frequency": 3 - }, - { - "Time": 146, - "Intensity": 0.54, - "Frequency": -5 - }, - { - "Time": 223, - "Intensity": 0.67, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.69, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 256, - "Parameters": { - "Intensity": 94, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 3 - }, - { - "Time": 1, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 94, - "Intensity": 0.79, - "Frequency": -5 - }, - { - "Time": 201, - "Intensity": 0.68, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.48, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 258, - "Parameters": { - "Intensity": 77, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 23, - "Intensity": 0.71, - "Frequency": 55 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 95, - "Intensity": 0.48, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 153, - "Intensity": 0.7, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 222, - "Intensity": 0.48, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 506, - "Parameters": { - "Intensity": 77, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.61, - "Frequency": 3 - }, - { - "Time": 95, - "Intensity": 0.18, - "Frequency": -5 - }, - { - "Time": 201, - "Intensity": 0.29, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.65, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 508, - "Parameters": { - "Intensity": 42, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -33 - }, - { - "Time": 33, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 0.1, - "Frequency": -14 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 4 - }, - { - "Time": 149, - "Intensity": 0.13, - "Frequency": -13 - }, - { - "Time": 168, - "Intensity": 0.48, - "Frequency": 23 - }, - { - "Time": 194, - "Intensity": 0.22, - "Frequency": -15 - }, - { - "Time": 224, - "Intensity": 0.58, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 758, - "Parameters": { - "Intensity": 53, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 46, - "Intensity": 0.73, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 157, - "Intensity": 0.33, - "Frequency": 5 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 758, - "Parameters": { - "Intensity": 85, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.59, - "Frequency": 3 - }, - { - "Time": 52, - "Intensity": 0.57, - "Frequency": -5 - }, - { - "Time": 103, - "Intensity": 0.62, - "Frequency": 3 - }, - { - "Time": 203, - "Intensity": 0.18, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1008, - "Parameters": { - "Intensity": 24, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 120, - "Intensity": 0.32, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.68, - "Frequency": 8 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1008, - "Parameters": { - "Intensity": 55, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 23, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 68, - "Intensity": 0.38, - "Frequency": -5 - }, - { - "Time": 195, - "Intensity": 0.55, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.19, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1258, - "Parameters": { - "Intensity": 82, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 17, - "Intensity": 0.27, - "Frequency": 10 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 95, - "Intensity": 0.41, - "Frequency": 2 - }, - { - "Time": 130, - "Intensity": 0.17, - "Frequency": -15 - }, - { - "Time": 152, - "Intensity": 0.82, - "Frequency": 2 - }, - { - "Time": 191, - "Intensity": 0.19, - "Frequency": -13 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 27 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1258, - "Parameters": { - "Intensity": 100, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.12, - "Frequency": 3 - }, - { - "Time": 85, - "Intensity": 0.23, - "Frequency": -5 - }, - { - "Time": 124, - "Intensity": 0.71, - "Frequency": 3 - }, - { - "Time": 231, - "Intensity": 0.86, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1508, - "Parameters": { - "Intensity": 96, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 33, - "Intensity": 0.08, - "Frequency": -15 - }, - { - "Time": 50, - "Intensity": 0.03, - "Frequency": -13 - }, - { - "Time": 74, - "Intensity": 0.77, - "Frequency": 4 - }, - { - "Time": 97, - "Intensity": 0.22, - "Frequency": -16 - }, - { - "Time": 118, - "Intensity": 0.47, - "Frequency": -4 - }, - { - "Time": 156, - "Intensity": 0.09, - "Frequency": -3 - }, - { - "Time": 157, - "Intensity": 0.61, - "Frequency": 5 - }, - { - "Time": 203, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 235, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1508, - "Parameters": { - "Intensity": 92, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 0.44, - "Frequency": 3 - }, - { - "Time": 51, - "Intensity": 0.92, - "Frequency": -5 - }, - { - "Time": 203, - "Intensity": 1, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.8, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1758, - "Parameters": { - "Intensity": 93, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 49, - "Intensity": 0.57, - "Frequency": 10 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 92, - "Intensity": 0.75, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 155, - "Intensity": 0.32, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 225, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1758, - "Parameters": { - "Intensity": 96, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.77, - "Frequency": 3 - }, - { - "Time": 82, - "Intensity": 0.67, - "Frequency": -5 - }, - { - "Time": 159, - "Intensity": 0.3, - "Frequency": 3 - }, - { - "Time": 197, - "Intensity": 0.27, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2008, - "Parameters": { - "Intensity": 65, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -33 - }, - { - "Time": 33, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 50, - "Intensity": 0.1, - "Frequency": -14 - }, - { - "Time": 98, - "Intensity": 0.7, - "Frequency": 5 - }, - { - "Time": 150, - "Intensity": 0.09, - "Frequency": -13 - }, - { - "Time": 167, - "Intensity": 0.49, - "Frequency": 0 - }, - { - "Time": 194, - "Intensity": 0.22, - "Frequency": -15 - }, - { - "Time": 224, - "Intensity": 0.58, - "Frequency": 11 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2008, - "Parameters": { - "Intensity": 70, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 58, - "Intensity": 0.36, - "Frequency": 3 - }, - { - "Time": 98, - "Intensity": 0.86, - "Frequency": -5 - }, - { - "Time": 188, - "Intensity": 0.7, - "Frequency": 3 - }, - { - "Time": 246, - "Intensity": 0.28, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2258, - "Parameters": { - "Intensity": 21, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2258, - "Parameters": { - "Intensity": 51, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 0.25, - "Frequency": 3 - }, - { - "Time": 58, - "Intensity": 0.52, - "Frequency": -5 - }, - { - "Time": 119, - "Intensity": 0.63, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.45, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2508, - "Parameters": { - "Intensity": 20, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2508, - "Parameters": { - "Intensity": 52, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.45, - "Frequency": 3 - }, - { - "Time": 53, - "Intensity": 0.46, - "Frequency": -5 - }, - { - "Time": 120, - "Intensity": 0.53, - "Frequency": 3 - }, - { - "Time": 196, - "Intensity": 0.31, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2758, - "Parameters": { - "Intensity": 74, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 22, - "Intensity": 0.36, - "Frequency": 55 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 101, - "Intensity": 0.53, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 155, - "Intensity": 0.37, - "Frequency": 2 - }, - { - "Time": 187, - "Intensity": 0.09, - "Frequency": -13 - }, - { - "Time": 220, - "Intensity": 0.65, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2758, - "Parameters": { - "Intensity": 85, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 35, - "Intensity": 0.1, - "Frequency": 3 - }, - { - "Time": 83, - "Intensity": 0.15, - "Frequency": -5 - }, - { - "Time": 107, - "Intensity": 0.59, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.81, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3008, - "Parameters": { - "Intensity": 87, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 33, - "Intensity": 0.08, - "Frequency": -15 - }, - { - "Time": 50, - "Intensity": 0.03, - "Frequency": -13 - }, - { - "Time": 77, - "Intensity": 0.72, - "Frequency": 4 - }, - { - "Time": 97, - "Intensity": 0.22, - "Frequency": -16 - }, - { - "Time": 118, - "Intensity": 0.47, - "Frequency": -4 - }, - { - "Time": 156, - "Intensity": 0.09, - "Frequency": -3 - }, - { - "Time": 178, - "Intensity": 0.78, - "Frequency": 5 - }, - { - "Time": 203, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 235, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3008, - "Parameters": { - "Intensity": 100, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.69, - "Frequency": 3 - }, - { - "Time": 53, - "Intensity": 0.81, - "Frequency": -5 - }, - { - "Time": 124, - "Intensity": 0.83, - "Frequency": 3 - }, - { - "Time": 214, - "Intensity": 0.64, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3258, - "Parameters": { - "Intensity": 91, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 35, - "Intensity": 0.19, - "Frequency": 55 - }, - { - "Time": 68, - "Intensity": 0.05, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 0.23, - "Frequency": 2 - }, - { - "Time": 129, - "Intensity": 0.04, - "Frequency": -15 - }, - { - "Time": 154, - "Intensity": 0.51, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 225, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3258, - "Parameters": { - "Intensity": 81, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 0.21, - "Frequency": 3 - }, - { - "Time": 164, - "Intensity": 0.69, - "Frequency": -5 - }, - { - "Time": 212, - "Intensity": 0.75, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.58, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3508, - "Parameters": { - "Intensity": 63, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 0.66, - "Frequency": 3 - }, - { - "Time": 76, - "Intensity": 0.75, - "Frequency": -5 - }, - { - "Time": 168, - "Intensity": 0.54, - "Frequency": 3 - }, - { - "Time": 211, - "Intensity": 0.26, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3513, - "Parameters": { - "Intensity": 68, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 18, - "Intensity": 0.58, - "Frequency": 55 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 96, - "Intensity": 0.25, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 155, - "Intensity": 0.32, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3763, - "Parameters": { - "Intensity": 61, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.38, - "Frequency": 3 - }, - { - "Time": 80, - "Intensity": 0.39, - "Frequency": -5 - }, - { - "Time": 203, - "Intensity": 0.52, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.34, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3765, - "Parameters": { - "Intensity": 19, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4015, - "Parameters": { - "Intensity": 25, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 120, - "Intensity": 0.21, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4015, - "Parameters": { - "Intensity": 61, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.33, - "Frequency": 3 - }, - { - "Time": 50, - "Intensity": 0.67, - "Frequency": -5 - }, - { - "Time": 119, - "Intensity": 0.49, - "Frequency": 3 - }, - { - "Time": 225, - "Intensity": 0.46, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4265, - "Parameters": { - "Intensity": 68, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 21, - "Intensity": 0.22, - "Frequency": 3 - }, - { - "Time": 52, - "Intensity": 0.53, - "Frequency": -5 - }, - { - "Time": 183, - "Intensity": 0.56, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.36, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4265, - "Parameters": { - "Intensity": 24, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 16, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.36, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4516, - "Parameters": { - "Intensity": 55, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 0.54, - "Frequency": 3 - }, - { - "Time": 48, - "Intensity": 0.64, - "Frequency": -5 - }, - { - "Time": 119, - "Intensity": 0.63, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.45, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4518, - "Parameters": { - "Intensity": 18, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 33, - "Intensity": 0.08, - "Frequency": -15 - }, - { - "Time": 50, - "Intensity": 0.03, - "Frequency": -13 - }, - { - "Time": 77, - "Intensity": 0.72, - "Frequency": 4 - }, - { - "Time": 97, - "Intensity": 0.22, - "Frequency": -16 - }, - { - "Time": 118, - "Intensity": 0.47, - "Frequency": -4 - }, - { - "Time": 156, - "Intensity": 0.09, - "Frequency": -3 - }, - { - "Time": 178, - "Intensity": 0.78, - "Frequency": 5 - }, - { - "Time": 203, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 235, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4768, - "Parameters": { - "Intensity": 20, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4768, - "Parameters": { - "Intensity": 57, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 0.44, - "Frequency": 3 - }, - { - "Time": 48, - "Intensity": 0.64, - "Frequency": -5 - }, - { - "Time": 135, - "Intensity": 0.43, - "Frequency": 3 - }, - { - "Time": 247, - "Intensity": 0.29, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5022, - "Parameters": { - "Intensity": 52, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 63, - "Intensity": 0.41, - "Frequency": -5 - }, - { - "Time": 124, - "Intensity": 0.57, - "Frequency": 3 - }, - { - "Time": 240, - "Intensity": 0.25, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5024, - "Parameters": { - "Intensity": 16, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 445, - "StartTime": 5274, - "Parameters": { - "Intensity": 30, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 12, - "Intensity": 0.44, - "Frequency": 3 - }, - { - "Time": 142, - "Intensity": 0.79, - "Frequency": -5 - }, - { - "Time": 335, - "Intensity": 0.7, - "Frequency": 3 - }, - { - "Time": 376, - "Intensity": 0.26, - "Frequency": -3 - }, - { - "Time": 445, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5279, - "Parameters": { - "Intensity": 21, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 0, + "Parameters": { + "Intensity": 38, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 120, + "Intensity": 0.32, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.68, + "Frequency": 8 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5, + "Parameters": { + "Intensity": 61, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0.45, + "Frequency": 3 + }, + { + "Time": 146, + "Intensity": 0.54, + "Frequency": -5 + }, + { + "Time": 223, + "Intensity": 0.67, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.69, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 256, + "Parameters": { + "Intensity": 94, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 3 + }, + { + "Time": 1, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 94, + "Intensity": 0.79, + "Frequency": -5 + }, + { + "Time": 201, + "Intensity": 0.68, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.48, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 258, + "Parameters": { + "Intensity": 77, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 23, + "Intensity": 0.71, + "Frequency": 55 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 95, + "Intensity": 0.48, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 153, + "Intensity": 0.7, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 222, + "Intensity": 0.48, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 506, + "Parameters": { + "Intensity": 77, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.61, + "Frequency": 3 + }, + { + "Time": 95, + "Intensity": 0.18, + "Frequency": -5 + }, + { + "Time": 201, + "Intensity": 0.29, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.65, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 508, + "Parameters": { + "Intensity": 42, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -33 + }, + { + "Time": 33, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 0.1, + "Frequency": -14 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 4 + }, + { + "Time": 149, + "Intensity": 0.13, + "Frequency": -13 + }, + { + "Time": 168, + "Intensity": 0.48, + "Frequency": 23 + }, + { + "Time": 194, + "Intensity": 0.22, + "Frequency": -15 + }, + { + "Time": 224, + "Intensity": 0.58, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 758, + "Parameters": { + "Intensity": 53, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 46, + "Intensity": 0.73, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 157, + "Intensity": 0.33, + "Frequency": 5 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 758, + "Parameters": { + "Intensity": 85, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.59, + "Frequency": 3 + }, + { + "Time": 52, + "Intensity": 0.57, + "Frequency": -5 + }, + { + "Time": 103, + "Intensity": 0.62, + "Frequency": 3 + }, + { + "Time": 203, + "Intensity": 0.18, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1008, + "Parameters": { + "Intensity": 24, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 120, + "Intensity": 0.32, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.68, + "Frequency": 8 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1008, + "Parameters": { + "Intensity": 55, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 23, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 68, + "Intensity": 0.38, + "Frequency": -5 + }, + { + "Time": 195, + "Intensity": 0.55, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.19, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1258, + "Parameters": { + "Intensity": 82, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 17, + "Intensity": 0.27, + "Frequency": 10 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 95, + "Intensity": 0.41, + "Frequency": 2 + }, + { + "Time": 130, + "Intensity": 0.17, + "Frequency": -15 + }, + { + "Time": 152, + "Intensity": 0.82, + "Frequency": 2 + }, + { + "Time": 191, + "Intensity": 0.19, + "Frequency": -13 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 27 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1258, + "Parameters": { + "Intensity": 100, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.12, + "Frequency": 3 + }, + { + "Time": 85, + "Intensity": 0.23, + "Frequency": -5 + }, + { + "Time": 124, + "Intensity": 0.71, + "Frequency": 3 + }, + { + "Time": 231, + "Intensity": 0.86, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1508, + "Parameters": { + "Intensity": 96, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 33, + "Intensity": 0.08, + "Frequency": -15 + }, + { + "Time": 50, + "Intensity": 0.03, + "Frequency": -13 + }, + { + "Time": 74, + "Intensity": 0.77, + "Frequency": 4 + }, + { + "Time": 97, + "Intensity": 0.22, + "Frequency": -16 + }, + { + "Time": 118, + "Intensity": 0.47, + "Frequency": -4 + }, + { + "Time": 156, + "Intensity": 0.09, + "Frequency": -3 + }, + { + "Time": 157, + "Intensity": 0.61, + "Frequency": 5 + }, + { + "Time": 203, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 235, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1508, + "Parameters": { + "Intensity": 92, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 0.44, + "Frequency": 3 + }, + { + "Time": 51, + "Intensity": 0.92, + "Frequency": -5 + }, + { + "Time": 203, + "Intensity": 1, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.8, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1758, + "Parameters": { + "Intensity": 93, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 49, + "Intensity": 0.57, + "Frequency": 10 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 92, + "Intensity": 0.75, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 155, + "Intensity": 0.32, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 225, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1758, + "Parameters": { + "Intensity": 96, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.77, + "Frequency": 3 + }, + { + "Time": 82, + "Intensity": 0.67, + "Frequency": -5 + }, + { + "Time": 159, + "Intensity": 0.3, + "Frequency": 3 + }, + { + "Time": 197, + "Intensity": 0.27, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2008, + "Parameters": { + "Intensity": 65, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -33 + }, + { + "Time": 33, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 50, + "Intensity": 0.1, + "Frequency": -14 + }, + { + "Time": 98, + "Intensity": 0.7, + "Frequency": 5 + }, + { + "Time": 150, + "Intensity": 0.09, + "Frequency": -13 + }, + { + "Time": 167, + "Intensity": 0.49, + "Frequency": 0 + }, + { + "Time": 194, + "Intensity": 0.22, + "Frequency": -15 + }, + { + "Time": 224, + "Intensity": 0.58, + "Frequency": 11 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2008, + "Parameters": { + "Intensity": 70, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 58, + "Intensity": 0.36, + "Frequency": 3 + }, + { + "Time": 98, + "Intensity": 0.86, + "Frequency": -5 + }, + { + "Time": 188, + "Intensity": 0.7, + "Frequency": 3 + }, + { + "Time": 246, + "Intensity": 0.28, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2258, + "Parameters": { + "Intensity": 21, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2258, + "Parameters": { + "Intensity": 51, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 0.25, + "Frequency": 3 + }, + { + "Time": 58, + "Intensity": 0.52, + "Frequency": -5 + }, + { + "Time": 119, + "Intensity": 0.63, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.45, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2508, + "Parameters": { + "Intensity": 20, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2508, + "Parameters": { + "Intensity": 52, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.45, + "Frequency": 3 + }, + { + "Time": 53, + "Intensity": 0.46, + "Frequency": -5 + }, + { + "Time": 120, + "Intensity": 0.53, + "Frequency": 3 + }, + { + "Time": 196, + "Intensity": 0.31, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2758, + "Parameters": { + "Intensity": 74, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 22, + "Intensity": 0.36, + "Frequency": 55 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 101, + "Intensity": 0.53, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 155, + "Intensity": 0.37, + "Frequency": 2 + }, + { + "Time": 187, + "Intensity": 0.09, + "Frequency": -13 + }, + { + "Time": 220, + "Intensity": 0.65, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2758, + "Parameters": { + "Intensity": 85, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 35, + "Intensity": 0.1, + "Frequency": 3 + }, + { + "Time": 83, + "Intensity": 0.15, + "Frequency": -5 + }, + { + "Time": 107, + "Intensity": 0.59, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.81, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3008, + "Parameters": { + "Intensity": 87, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 33, + "Intensity": 0.08, + "Frequency": -15 + }, + { + "Time": 50, + "Intensity": 0.03, + "Frequency": -13 + }, + { + "Time": 77, + "Intensity": 0.72, + "Frequency": 4 + }, + { + "Time": 97, + "Intensity": 0.22, + "Frequency": -16 + }, + { + "Time": 118, + "Intensity": 0.47, + "Frequency": -4 + }, + { + "Time": 156, + "Intensity": 0.09, + "Frequency": -3 + }, + { + "Time": 178, + "Intensity": 0.78, + "Frequency": 5 + }, + { + "Time": 203, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 235, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3008, + "Parameters": { + "Intensity": 100, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.69, + "Frequency": 3 + }, + { + "Time": 53, + "Intensity": 0.81, + "Frequency": -5 + }, + { + "Time": 124, + "Intensity": 0.83, + "Frequency": 3 + }, + { + "Time": 214, + "Intensity": 0.64, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3258, + "Parameters": { + "Intensity": 91, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 35, + "Intensity": 0.19, + "Frequency": 55 + }, + { + "Time": 68, + "Intensity": 0.05, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 0.23, + "Frequency": 2 + }, + { + "Time": 129, + "Intensity": 0.04, + "Frequency": -15 + }, + { + "Time": 154, + "Intensity": 0.51, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 225, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3258, + "Parameters": { + "Intensity": 81, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 0.21, + "Frequency": 3 + }, + { + "Time": 164, + "Intensity": 0.69, + "Frequency": -5 + }, + { + "Time": 212, + "Intensity": 0.75, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.58, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3508, + "Parameters": { + "Intensity": 63, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 0.66, + "Frequency": 3 + }, + { + "Time": 76, + "Intensity": 0.75, + "Frequency": -5 + }, + { + "Time": 168, + "Intensity": 0.54, + "Frequency": 3 + }, + { + "Time": 211, + "Intensity": 0.26, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3513, + "Parameters": { + "Intensity": 68, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 18, + "Intensity": 0.58, + "Frequency": 55 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 96, + "Intensity": 0.25, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 155, + "Intensity": 0.32, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3763, + "Parameters": { + "Intensity": 61, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.38, + "Frequency": 3 + }, + { + "Time": 80, + "Intensity": 0.39, + "Frequency": -5 + }, + { + "Time": 203, + "Intensity": 0.52, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.34, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3765, + "Parameters": { + "Intensity": 19, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4015, + "Parameters": { + "Intensity": 25, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 120, + "Intensity": 0.21, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4015, + "Parameters": { + "Intensity": 61, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.33, + "Frequency": 3 + }, + { + "Time": 50, + "Intensity": 0.67, + "Frequency": -5 + }, + { + "Time": 119, + "Intensity": 0.49, + "Frequency": 3 + }, + { + "Time": 225, + "Intensity": 0.46, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4265, + "Parameters": { + "Intensity": 68, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 21, + "Intensity": 0.22, + "Frequency": 3 + }, + { + "Time": 52, + "Intensity": 0.53, + "Frequency": -5 + }, + { + "Time": 183, + "Intensity": 0.56, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.36, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4265, + "Parameters": { + "Intensity": 24, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 16, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.36, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4516, + "Parameters": { + "Intensity": 55, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 0.54, + "Frequency": 3 + }, + { + "Time": 48, + "Intensity": 0.64, + "Frequency": -5 + }, + { + "Time": 119, + "Intensity": 0.63, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.45, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4518, + "Parameters": { + "Intensity": 18, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 33, + "Intensity": 0.08, + "Frequency": -15 + }, + { + "Time": 50, + "Intensity": 0.03, + "Frequency": -13 + }, + { + "Time": 77, + "Intensity": 0.72, + "Frequency": 4 + }, + { + "Time": 97, + "Intensity": 0.22, + "Frequency": -16 + }, + { + "Time": 118, + "Intensity": 0.47, + "Frequency": -4 + }, + { + "Time": 156, + "Intensity": 0.09, + "Frequency": -3 + }, + { + "Time": 178, + "Intensity": 0.78, + "Frequency": 5 + }, + { + "Time": 203, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 235, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4768, + "Parameters": { + "Intensity": 20, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4768, + "Parameters": { + "Intensity": 57, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 0.44, + "Frequency": 3 + }, + { + "Time": 48, + "Intensity": 0.64, + "Frequency": -5 + }, + { + "Time": 135, + "Intensity": 0.43, + "Frequency": 3 + }, + { + "Time": 247, + "Intensity": 0.29, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5022, + "Parameters": { + "Intensity": 52, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 63, + "Intensity": 0.41, + "Frequency": -5 + }, + { + "Time": 124, + "Intensity": 0.57, + "Frequency": 3 + }, + { + "Time": 240, + "Intensity": 0.25, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5024, + "Parameters": { + "Intensity": 16, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 445, + "StartTime": 5274, + "Parameters": { + "Intensity": 30, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 12, + "Intensity": 0.44, + "Frequency": 3 + }, + { + "Time": 142, + "Intensity": 0.79, + "Frequency": -5 + }, + { + "Time": 335, + "Intensity": 0.7, + "Frequency": 3 + }, + { + "Time": 376, + "Intensity": 0.26, + "Frequency": -3 + }, + { + "Time": 445, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5279, + "Parameters": { + "Intensity": 21, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_l.json index 13a6718737..50c83156c7 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_l.json @@ -1,2304 +1,2304 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 0, - "Parameters": { - "Intensity": 22, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 120, - "Intensity": 0.32, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.68, - "Frequency": 8 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5, - "Parameters": { - "Intensity": 36, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0.45, - "Frequency": 3 - }, - { - "Time": 146, - "Intensity": 0.54, - "Frequency": -5 - }, - { - "Time": 223, - "Intensity": 0.67, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.69, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 256, - "Parameters": { - "Intensity": 56, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 3 - }, - { - "Time": 1, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 94, - "Intensity": 0.79, - "Frequency": -5 - }, - { - "Time": 201, - "Intensity": 0.68, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.48, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 258, - "Parameters": { - "Intensity": 46, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 23, - "Intensity": 0.71, - "Frequency": 55 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 95, - "Intensity": 0.48, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 153, - "Intensity": 0.7, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 222, - "Intensity": 0.48, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 506, - "Parameters": { - "Intensity": 46, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.61, - "Frequency": 3 - }, - { - "Time": 95, - "Intensity": 0.18, - "Frequency": -5 - }, - { - "Time": 201, - "Intensity": 0.29, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.65, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 508, - "Parameters": { - "Intensity": 25, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -33 - }, - { - "Time": 33, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 0.1, - "Frequency": -14 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 4 - }, - { - "Time": 149, - "Intensity": 0.13, - "Frequency": -13 - }, - { - "Time": 168, - "Intensity": 0.48, - "Frequency": 23 - }, - { - "Time": 194, - "Intensity": 0.22, - "Frequency": -15 - }, - { - "Time": 224, - "Intensity": 0.58, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 758, - "Parameters": { - "Intensity": 31, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 46, - "Intensity": 0.73, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 157, - "Intensity": 0.33, - "Frequency": 5 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 758, - "Parameters": { - "Intensity": 51, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.59, - "Frequency": 3 - }, - { - "Time": 52, - "Intensity": 0.57, - "Frequency": -5 - }, - { - "Time": 103, - "Intensity": 0.62, - "Frequency": 3 - }, - { - "Time": 203, - "Intensity": 0.18, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1008, - "Parameters": { - "Intensity": 14, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 120, - "Intensity": 0.32, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.68, - "Frequency": 8 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1008, - "Parameters": { - "Intensity": 33, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 23, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 68, - "Intensity": 0.38, - "Frequency": -5 - }, - { - "Time": 195, - "Intensity": 0.55, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.19, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1258, - "Parameters": { - "Intensity": 49, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 17, - "Intensity": 0.27, - "Frequency": 10 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 95, - "Intensity": 0.41, - "Frequency": 2 - }, - { - "Time": 130, - "Intensity": 0.17, - "Frequency": -15 - }, - { - "Time": 152, - "Intensity": 0.82, - "Frequency": 2 - }, - { - "Time": 191, - "Intensity": 0.19, - "Frequency": -13 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 27 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1258, - "Parameters": { - "Intensity": 60, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.12, - "Frequency": 3 - }, - { - "Time": 85, - "Intensity": 0.23, - "Frequency": -5 - }, - { - "Time": 124, - "Intensity": 0.71, - "Frequency": 3 - }, - { - "Time": 231, - "Intensity": 0.86, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1508, - "Parameters": { - "Intensity": 57, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 33, - "Intensity": 0.08, - "Frequency": -15 - }, - { - "Time": 50, - "Intensity": 0.03, - "Frequency": -13 - }, - { - "Time": 74, - "Intensity": 0.77, - "Frequency": 4 - }, - { - "Time": 97, - "Intensity": 0.22, - "Frequency": -16 - }, - { - "Time": 118, - "Intensity": 0.47, - "Frequency": -4 - }, - { - "Time": 156, - "Intensity": 0.09, - "Frequency": -3 - }, - { - "Time": 157, - "Intensity": 0.61, - "Frequency": 5 - }, - { - "Time": 203, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 235, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1508, - "Parameters": { - "Intensity": 55, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 0.44, - "Frequency": 3 - }, - { - "Time": 51, - "Intensity": 0.92, - "Frequency": -5 - }, - { - "Time": 203, - "Intensity": 1, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.8, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1758, - "Parameters": { - "Intensity": 55, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 49, - "Intensity": 0.57, - "Frequency": 10 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 92, - "Intensity": 0.75, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 155, - "Intensity": 0.32, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 225, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1758, - "Parameters": { - "Intensity": 57, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.77, - "Frequency": 3 - }, - { - "Time": 82, - "Intensity": 0.67, - "Frequency": -5 - }, - { - "Time": 159, - "Intensity": 0.3, - "Frequency": 3 - }, - { - "Time": 197, - "Intensity": 0.27, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2008, - "Parameters": { - "Intensity": 39, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -33 - }, - { - "Time": 33, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 50, - "Intensity": 0.1, - "Frequency": -14 - }, - { - "Time": 98, - "Intensity": 0.7, - "Frequency": 5 - }, - { - "Time": 150, - "Intensity": 0.09, - "Frequency": -13 - }, - { - "Time": 167, - "Intensity": 0.49, - "Frequency": 0 - }, - { - "Time": 194, - "Intensity": 0.22, - "Frequency": -15 - }, - { - "Time": 224, - "Intensity": 0.58, - "Frequency": 11 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2008, - "Parameters": { - "Intensity": 42, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 58, - "Intensity": 0.36, - "Frequency": 3 - }, - { - "Time": 98, - "Intensity": 0.86, - "Frequency": -5 - }, - { - "Time": 188, - "Intensity": 0.7, - "Frequency": 3 - }, - { - "Time": 246, - "Intensity": 0.28, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2258, - "Parameters": { - "Intensity": 12, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2258, - "Parameters": { - "Intensity": 30, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 0.25, - "Frequency": 3 - }, - { - "Time": 58, - "Intensity": 0.52, - "Frequency": -5 - }, - { - "Time": 119, - "Intensity": 0.63, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.45, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2508, - "Parameters": { - "Intensity": 12, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2508, - "Parameters": { - "Intensity": 31, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.45, - "Frequency": 3 - }, - { - "Time": 53, - "Intensity": 0.46, - "Frequency": -5 - }, - { - "Time": 120, - "Intensity": 0.53, - "Frequency": 3 - }, - { - "Time": 196, - "Intensity": 0.31, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2758, - "Parameters": { - "Intensity": 44, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 22, - "Intensity": 0.36, - "Frequency": 55 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 101, - "Intensity": 0.53, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 155, - "Intensity": 0.37, - "Frequency": 2 - }, - { - "Time": 187, - "Intensity": 0.09, - "Frequency": -13 - }, - { - "Time": 220, - "Intensity": 0.65, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2758, - "Parameters": { - "Intensity": 51, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 35, - "Intensity": 0.1, - "Frequency": 3 - }, - { - "Time": 83, - "Intensity": 0.15, - "Frequency": -5 - }, - { - "Time": 107, - "Intensity": 0.59, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.81, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3008, - "Parameters": { - "Intensity": 52, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 33, - "Intensity": 0.08, - "Frequency": -15 - }, - { - "Time": 50, - "Intensity": 0.03, - "Frequency": -13 - }, - { - "Time": 77, - "Intensity": 0.72, - "Frequency": 4 - }, - { - "Time": 97, - "Intensity": 0.22, - "Frequency": -16 - }, - { - "Time": 118, - "Intensity": 0.47, - "Frequency": -4 - }, - { - "Time": 156, - "Intensity": 0.09, - "Frequency": -3 - }, - { - "Time": 178, - "Intensity": 0.78, - "Frequency": 5 - }, - { - "Time": 203, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 235, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3008, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.69, - "Frequency": 3 - }, - { - "Time": 53, - "Intensity": 0.81, - "Frequency": -5 - }, - { - "Time": 124, - "Intensity": 0.83, - "Frequency": 3 - }, - { - "Time": 214, - "Intensity": 0.64, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3258, - "Parameters": { - "Intensity": 54, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 35, - "Intensity": 0.19, - "Frequency": 55 - }, - { - "Time": 68, - "Intensity": 0.05, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 0.23, - "Frequency": 2 - }, - { - "Time": 129, - "Intensity": 0.04, - "Frequency": -15 - }, - { - "Time": 154, - "Intensity": 0.51, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 225, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3258, - "Parameters": { - "Intensity": 48, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 0.21, - "Frequency": 3 - }, - { - "Time": 164, - "Intensity": 0.69, - "Frequency": -5 - }, - { - "Time": 212, - "Intensity": 0.75, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.58, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3508, - "Parameters": { - "Intensity": 37, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 0.66, - "Frequency": 3 - }, - { - "Time": 76, - "Intensity": 0.75, - "Frequency": -5 - }, - { - "Time": 168, - "Intensity": 0.54, - "Frequency": 3 - }, - { - "Time": 211, - "Intensity": 0.26, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3513, - "Parameters": { - "Intensity": 40, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 18, - "Intensity": 0.58, - "Frequency": 55 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 96, - "Intensity": 0.25, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 155, - "Intensity": 0.32, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3763, - "Parameters": { - "Intensity": 36, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.38, - "Frequency": 3 - }, - { - "Time": 80, - "Intensity": 0.39, - "Frequency": -5 - }, - { - "Time": 203, - "Intensity": 0.52, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.34, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3765, - "Parameters": { - "Intensity": 11, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4015, - "Parameters": { - "Intensity": 15, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 120, - "Intensity": 0.21, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4015, - "Parameters": { - "Intensity": 36, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.33, - "Frequency": 3 - }, - { - "Time": 50, - "Intensity": 0.67, - "Frequency": -5 - }, - { - "Time": 119, - "Intensity": 0.49, - "Frequency": 3 - }, - { - "Time": 225, - "Intensity": 0.46, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4265, - "Parameters": { - "Intensity": 40, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 21, - "Intensity": 0.22, - "Frequency": 3 - }, - { - "Time": 52, - "Intensity": 0.53, - "Frequency": -5 - }, - { - "Time": 183, - "Intensity": 0.56, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.36, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4265, - "Parameters": { - "Intensity": 14, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 16, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.36, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4516, - "Parameters": { - "Intensity": 33, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 0.54, - "Frequency": 3 - }, - { - "Time": 48, - "Intensity": 0.64, - "Frequency": -5 - }, - { - "Time": 119, - "Intensity": 0.63, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.45, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4518, - "Parameters": { - "Intensity": 10, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 33, - "Intensity": 0.08, - "Frequency": -15 - }, - { - "Time": 50, - "Intensity": 0.03, - "Frequency": -13 - }, - { - "Time": 77, - "Intensity": 0.72, - "Frequency": 4 - }, - { - "Time": 97, - "Intensity": 0.22, - "Frequency": -16 - }, - { - "Time": 118, - "Intensity": 0.47, - "Frequency": -4 - }, - { - "Time": 156, - "Intensity": 0.09, - "Frequency": -3 - }, - { - "Time": 178, - "Intensity": 0.78, - "Frequency": 5 - }, - { - "Time": 203, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 235, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4768, - "Parameters": { - "Intensity": 12, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4768, - "Parameters": { - "Intensity": 34, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 0.44, - "Frequency": 3 - }, - { - "Time": 48, - "Intensity": 0.64, - "Frequency": -5 - }, - { - "Time": 135, - "Intensity": 0.43, - "Frequency": 3 - }, - { - "Time": 247, - "Intensity": 0.29, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5022, - "Parameters": { - "Intensity": 31, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 63, - "Intensity": 0.41, - "Frequency": -5 - }, - { - "Time": 124, - "Intensity": 0.57, - "Frequency": 3 - }, - { - "Time": 240, - "Intensity": 0.25, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5024, - "Parameters": { - "Intensity": 9, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 445, - "StartTime": 5274, - "Parameters": { - "Intensity": 18, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 12, - "Intensity": 0.44, - "Frequency": 3 - }, - { - "Time": 142, - "Intensity": 0.79, - "Frequency": -5 - }, - { - "Time": 335, - "Intensity": 0.7, - "Frequency": 3 - }, - { - "Time": 376, - "Intensity": 0.26, - "Frequency": -3 - }, - { - "Time": 445, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5279, - "Parameters": { - "Intensity": 12, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 0, + "Parameters": { + "Intensity": 22, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 120, + "Intensity": 0.32, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.68, + "Frequency": 8 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5, + "Parameters": { + "Intensity": 36, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0.45, + "Frequency": 3 + }, + { + "Time": 146, + "Intensity": 0.54, + "Frequency": -5 + }, + { + "Time": 223, + "Intensity": 0.67, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.69, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 256, + "Parameters": { + "Intensity": 56, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 3 + }, + { + "Time": 1, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 94, + "Intensity": 0.79, + "Frequency": -5 + }, + { + "Time": 201, + "Intensity": 0.68, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.48, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 258, + "Parameters": { + "Intensity": 46, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 23, + "Intensity": 0.71, + "Frequency": 55 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 95, + "Intensity": 0.48, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 153, + "Intensity": 0.7, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 222, + "Intensity": 0.48, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 506, + "Parameters": { + "Intensity": 46, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.61, + "Frequency": 3 + }, + { + "Time": 95, + "Intensity": 0.18, + "Frequency": -5 + }, + { + "Time": 201, + "Intensity": 0.29, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.65, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 508, + "Parameters": { + "Intensity": 25, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -33 + }, + { + "Time": 33, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 0.1, + "Frequency": -14 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 4 + }, + { + "Time": 149, + "Intensity": 0.13, + "Frequency": -13 + }, + { + "Time": 168, + "Intensity": 0.48, + "Frequency": 23 + }, + { + "Time": 194, + "Intensity": 0.22, + "Frequency": -15 + }, + { + "Time": 224, + "Intensity": 0.58, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 758, + "Parameters": { + "Intensity": 31, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 46, + "Intensity": 0.73, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 157, + "Intensity": 0.33, + "Frequency": 5 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 758, + "Parameters": { + "Intensity": 51, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.59, + "Frequency": 3 + }, + { + "Time": 52, + "Intensity": 0.57, + "Frequency": -5 + }, + { + "Time": 103, + "Intensity": 0.62, + "Frequency": 3 + }, + { + "Time": 203, + "Intensity": 0.18, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1008, + "Parameters": { + "Intensity": 14, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 120, + "Intensity": 0.32, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.68, + "Frequency": 8 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1008, + "Parameters": { + "Intensity": 33, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 23, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 68, + "Intensity": 0.38, + "Frequency": -5 + }, + { + "Time": 195, + "Intensity": 0.55, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.19, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1258, + "Parameters": { + "Intensity": 49, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 17, + "Intensity": 0.27, + "Frequency": 10 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 95, + "Intensity": 0.41, + "Frequency": 2 + }, + { + "Time": 130, + "Intensity": 0.17, + "Frequency": -15 + }, + { + "Time": 152, + "Intensity": 0.82, + "Frequency": 2 + }, + { + "Time": 191, + "Intensity": 0.19, + "Frequency": -13 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 27 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1258, + "Parameters": { + "Intensity": 60, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.12, + "Frequency": 3 + }, + { + "Time": 85, + "Intensity": 0.23, + "Frequency": -5 + }, + { + "Time": 124, + "Intensity": 0.71, + "Frequency": 3 + }, + { + "Time": 231, + "Intensity": 0.86, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1508, + "Parameters": { + "Intensity": 57, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 33, + "Intensity": 0.08, + "Frequency": -15 + }, + { + "Time": 50, + "Intensity": 0.03, + "Frequency": -13 + }, + { + "Time": 74, + "Intensity": 0.77, + "Frequency": 4 + }, + { + "Time": 97, + "Intensity": 0.22, + "Frequency": -16 + }, + { + "Time": 118, + "Intensity": 0.47, + "Frequency": -4 + }, + { + "Time": 156, + "Intensity": 0.09, + "Frequency": -3 + }, + { + "Time": 157, + "Intensity": 0.61, + "Frequency": 5 + }, + { + "Time": 203, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 235, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1508, + "Parameters": { + "Intensity": 55, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 0.44, + "Frequency": 3 + }, + { + "Time": 51, + "Intensity": 0.92, + "Frequency": -5 + }, + { + "Time": 203, + "Intensity": 1, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.8, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1758, + "Parameters": { + "Intensity": 55, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 49, + "Intensity": 0.57, + "Frequency": 10 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 92, + "Intensity": 0.75, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 155, + "Intensity": 0.32, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 225, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1758, + "Parameters": { + "Intensity": 57, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.77, + "Frequency": 3 + }, + { + "Time": 82, + "Intensity": 0.67, + "Frequency": -5 + }, + { + "Time": 159, + "Intensity": 0.3, + "Frequency": 3 + }, + { + "Time": 197, + "Intensity": 0.27, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2008, + "Parameters": { + "Intensity": 39, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -33 + }, + { + "Time": 33, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 50, + "Intensity": 0.1, + "Frequency": -14 + }, + { + "Time": 98, + "Intensity": 0.7, + "Frequency": 5 + }, + { + "Time": 150, + "Intensity": 0.09, + "Frequency": -13 + }, + { + "Time": 167, + "Intensity": 0.49, + "Frequency": 0 + }, + { + "Time": 194, + "Intensity": 0.22, + "Frequency": -15 + }, + { + "Time": 224, + "Intensity": 0.58, + "Frequency": 11 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2008, + "Parameters": { + "Intensity": 42, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 58, + "Intensity": 0.36, + "Frequency": 3 + }, + { + "Time": 98, + "Intensity": 0.86, + "Frequency": -5 + }, + { + "Time": 188, + "Intensity": 0.7, + "Frequency": 3 + }, + { + "Time": 246, + "Intensity": 0.28, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2258, + "Parameters": { + "Intensity": 12, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2258, + "Parameters": { + "Intensity": 30, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 0.25, + "Frequency": 3 + }, + { + "Time": 58, + "Intensity": 0.52, + "Frequency": -5 + }, + { + "Time": 119, + "Intensity": 0.63, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.45, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2508, + "Parameters": { + "Intensity": 12, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2508, + "Parameters": { + "Intensity": 31, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.45, + "Frequency": 3 + }, + { + "Time": 53, + "Intensity": 0.46, + "Frequency": -5 + }, + { + "Time": 120, + "Intensity": 0.53, + "Frequency": 3 + }, + { + "Time": 196, + "Intensity": 0.31, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2758, + "Parameters": { + "Intensity": 44, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 22, + "Intensity": 0.36, + "Frequency": 55 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 101, + "Intensity": 0.53, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 155, + "Intensity": 0.37, + "Frequency": 2 + }, + { + "Time": 187, + "Intensity": 0.09, + "Frequency": -13 + }, + { + "Time": 220, + "Intensity": 0.65, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2758, + "Parameters": { + "Intensity": 51, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 35, + "Intensity": 0.1, + "Frequency": 3 + }, + { + "Time": 83, + "Intensity": 0.15, + "Frequency": -5 + }, + { + "Time": 107, + "Intensity": 0.59, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.81, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3008, + "Parameters": { + "Intensity": 52, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 33, + "Intensity": 0.08, + "Frequency": -15 + }, + { + "Time": 50, + "Intensity": 0.03, + "Frequency": -13 + }, + { + "Time": 77, + "Intensity": 0.72, + "Frequency": 4 + }, + { + "Time": 97, + "Intensity": 0.22, + "Frequency": -16 + }, + { + "Time": 118, + "Intensity": 0.47, + "Frequency": -4 + }, + { + "Time": 156, + "Intensity": 0.09, + "Frequency": -3 + }, + { + "Time": 178, + "Intensity": 0.78, + "Frequency": 5 + }, + { + "Time": 203, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 235, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3008, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.69, + "Frequency": 3 + }, + { + "Time": 53, + "Intensity": 0.81, + "Frequency": -5 + }, + { + "Time": 124, + "Intensity": 0.83, + "Frequency": 3 + }, + { + "Time": 214, + "Intensity": 0.64, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3258, + "Parameters": { + "Intensity": 54, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 35, + "Intensity": 0.19, + "Frequency": 55 + }, + { + "Time": 68, + "Intensity": 0.05, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 0.23, + "Frequency": 2 + }, + { + "Time": 129, + "Intensity": 0.04, + "Frequency": -15 + }, + { + "Time": 154, + "Intensity": 0.51, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 225, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3258, + "Parameters": { + "Intensity": 48, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 0.21, + "Frequency": 3 + }, + { + "Time": 164, + "Intensity": 0.69, + "Frequency": -5 + }, + { + "Time": 212, + "Intensity": 0.75, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.58, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3508, + "Parameters": { + "Intensity": 37, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 0.66, + "Frequency": 3 + }, + { + "Time": 76, + "Intensity": 0.75, + "Frequency": -5 + }, + { + "Time": 168, + "Intensity": 0.54, + "Frequency": 3 + }, + { + "Time": 211, + "Intensity": 0.26, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3513, + "Parameters": { + "Intensity": 40, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 18, + "Intensity": 0.58, + "Frequency": 55 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 96, + "Intensity": 0.25, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 155, + "Intensity": 0.32, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3763, + "Parameters": { + "Intensity": 36, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.38, + "Frequency": 3 + }, + { + "Time": 80, + "Intensity": 0.39, + "Frequency": -5 + }, + { + "Time": 203, + "Intensity": 0.52, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.34, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3765, + "Parameters": { + "Intensity": 11, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4015, + "Parameters": { + "Intensity": 15, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 120, + "Intensity": 0.21, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4015, + "Parameters": { + "Intensity": 36, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.33, + "Frequency": 3 + }, + { + "Time": 50, + "Intensity": 0.67, + "Frequency": -5 + }, + { + "Time": 119, + "Intensity": 0.49, + "Frequency": 3 + }, + { + "Time": 225, + "Intensity": 0.46, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4265, + "Parameters": { + "Intensity": 40, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 21, + "Intensity": 0.22, + "Frequency": 3 + }, + { + "Time": 52, + "Intensity": 0.53, + "Frequency": -5 + }, + { + "Time": 183, + "Intensity": 0.56, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.36, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4265, + "Parameters": { + "Intensity": 14, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 16, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.36, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4516, + "Parameters": { + "Intensity": 33, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 0.54, + "Frequency": 3 + }, + { + "Time": 48, + "Intensity": 0.64, + "Frequency": -5 + }, + { + "Time": 119, + "Intensity": 0.63, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.45, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4518, + "Parameters": { + "Intensity": 10, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 33, + "Intensity": 0.08, + "Frequency": -15 + }, + { + "Time": 50, + "Intensity": 0.03, + "Frequency": -13 + }, + { + "Time": 77, + "Intensity": 0.72, + "Frequency": 4 + }, + { + "Time": 97, + "Intensity": 0.22, + "Frequency": -16 + }, + { + "Time": 118, + "Intensity": 0.47, + "Frequency": -4 + }, + { + "Time": 156, + "Intensity": 0.09, + "Frequency": -3 + }, + { + "Time": 178, + "Intensity": 0.78, + "Frequency": 5 + }, + { + "Time": 203, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 235, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4768, + "Parameters": { + "Intensity": 12, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4768, + "Parameters": { + "Intensity": 34, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 0.44, + "Frequency": 3 + }, + { + "Time": 48, + "Intensity": 0.64, + "Frequency": -5 + }, + { + "Time": 135, + "Intensity": 0.43, + "Frequency": 3 + }, + { + "Time": 247, + "Intensity": 0.29, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5022, + "Parameters": { + "Intensity": 31, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 63, + "Intensity": 0.41, + "Frequency": -5 + }, + { + "Time": 124, + "Intensity": 0.57, + "Frequency": 3 + }, + { + "Time": 240, + "Intensity": 0.25, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5024, + "Parameters": { + "Intensity": 9, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 445, + "StartTime": 5274, + "Parameters": { + "Intensity": 18, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 12, + "Intensity": 0.44, + "Frequency": 3 + }, + { + "Time": 142, + "Intensity": 0.79, + "Frequency": -5 + }, + { + "Time": 335, + "Intensity": 0.7, + "Frequency": 3 + }, + { + "Time": 376, + "Intensity": 0.26, + "Frequency": -3 + }, + { + "Time": 445, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5279, + "Parameters": { + "Intensity": 12, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_m.json index f6c959e73e..5b4795eeec 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wave_m.json @@ -1,2304 +1,2304 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 0, - "Parameters": { - "Intensity": 30, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 120, - "Intensity": 0.32, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.68, - "Frequency": 8 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5, - "Parameters": { - "Intensity": 48, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0.45, - "Frequency": 3 - }, - { - "Time": 146, - "Intensity": 0.54, - "Frequency": -5 - }, - { - "Time": 223, - "Intensity": 0.67, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.69, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 256, - "Parameters": { - "Intensity": 75, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 3 - }, - { - "Time": 1, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 94, - "Intensity": 0.79, - "Frequency": -5 - }, - { - "Time": 201, - "Intensity": 0.68, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.48, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 258, - "Parameters": { - "Intensity": 61, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 23, - "Intensity": 0.71, - "Frequency": 55 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 95, - "Intensity": 0.48, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 153, - "Intensity": 0.7, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 222, - "Intensity": 0.48, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 506, - "Parameters": { - "Intensity": 61, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.61, - "Frequency": 3 - }, - { - "Time": 95, - "Intensity": 0.18, - "Frequency": -5 - }, - { - "Time": 201, - "Intensity": 0.29, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.65, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 508, - "Parameters": { - "Intensity": 33, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -33 - }, - { - "Time": 33, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 72, - "Intensity": 0.1, - "Frequency": -14 - }, - { - "Time": 100, - "Intensity": 0.24, - "Frequency": 4 - }, - { - "Time": 149, - "Intensity": 0.13, - "Frequency": -13 - }, - { - "Time": 168, - "Intensity": 0.48, - "Frequency": 23 - }, - { - "Time": 194, - "Intensity": 0.22, - "Frequency": -15 - }, - { - "Time": 224, - "Intensity": 0.58, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 758, - "Parameters": { - "Intensity": 42, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 46, - "Intensity": 0.73, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 157, - "Intensity": 0.33, - "Frequency": 5 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 758, - "Parameters": { - "Intensity": 68, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.59, - "Frequency": 3 - }, - { - "Time": 52, - "Intensity": 0.57, - "Frequency": -5 - }, - { - "Time": 103, - "Intensity": 0.62, - "Frequency": 3 - }, - { - "Time": 203, - "Intensity": 0.18, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1008, - "Parameters": { - "Intensity": 19, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 120, - "Intensity": 0.32, - "Frequency": -6 - }, - { - "Time": 128, - "Intensity": 0.68, - "Frequency": 8 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1008, - "Parameters": { - "Intensity": 44, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 23, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 68, - "Intensity": 0.38, - "Frequency": -5 - }, - { - "Time": 195, - "Intensity": 0.55, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.19, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1258, - "Parameters": { - "Intensity": 65, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 17, - "Intensity": 0.27, - "Frequency": 10 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 95, - "Intensity": 0.41, - "Frequency": 2 - }, - { - "Time": 130, - "Intensity": 0.17, - "Frequency": -15 - }, - { - "Time": 152, - "Intensity": 0.82, - "Frequency": 2 - }, - { - "Time": 191, - "Intensity": 0.19, - "Frequency": -13 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 27 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1258, - "Parameters": { - "Intensity": 80, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.12, - "Frequency": 3 - }, - { - "Time": 85, - "Intensity": 0.23, - "Frequency": -5 - }, - { - "Time": 124, - "Intensity": 0.71, - "Frequency": 3 - }, - { - "Time": 231, - "Intensity": 0.86, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1508, - "Parameters": { - "Intensity": 76, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 33, - "Intensity": 0.08, - "Frequency": -15 - }, - { - "Time": 50, - "Intensity": 0.03, - "Frequency": -13 - }, - { - "Time": 74, - "Intensity": 0.77, - "Frequency": 4 - }, - { - "Time": 97, - "Intensity": 0.22, - "Frequency": -16 - }, - { - "Time": 118, - "Intensity": 0.47, - "Frequency": -4 - }, - { - "Time": 156, - "Intensity": 0.09, - "Frequency": -3 - }, - { - "Time": 157, - "Intensity": 0.61, - "Frequency": 5 - }, - { - "Time": 203, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 235, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1508, - "Parameters": { - "Intensity": 73, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 0.44, - "Frequency": 3 - }, - { - "Time": 51, - "Intensity": 0.92, - "Frequency": -5 - }, - { - "Time": 203, - "Intensity": 1, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.8, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1758, - "Parameters": { - "Intensity": 74, - "Frequency": 33, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 49, - "Intensity": 0.57, - "Frequency": 10 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 92, - "Intensity": 0.75, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 155, - "Intensity": 0.32, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 225, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 1758, - "Parameters": { - "Intensity": 76, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.77, - "Frequency": 3 - }, - { - "Time": 82, - "Intensity": 0.67, - "Frequency": -5 - }, - { - "Time": 159, - "Intensity": 0.3, - "Frequency": 3 - }, - { - "Time": 197, - "Intensity": 0.27, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2008, - "Parameters": { - "Intensity": 52, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -33 - }, - { - "Time": 33, - "Intensity": 0.31, - "Frequency": 0 - }, - { - "Time": 50, - "Intensity": 0.1, - "Frequency": -14 - }, - { - "Time": 98, - "Intensity": 0.7, - "Frequency": 5 - }, - { - "Time": 150, - "Intensity": 0.09, - "Frequency": -13 - }, - { - "Time": 167, - "Intensity": 0.49, - "Frequency": 0 - }, - { - "Time": 194, - "Intensity": 0.22, - "Frequency": -15 - }, - { - "Time": 224, - "Intensity": 0.58, - "Frequency": 11 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -5 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2008, - "Parameters": { - "Intensity": 56, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 58, - "Intensity": 0.36, - "Frequency": 3 - }, - { - "Time": 98, - "Intensity": 0.86, - "Frequency": -5 - }, - { - "Time": 188, - "Intensity": 0.7, - "Frequency": 3 - }, - { - "Time": 246, - "Intensity": 0.28, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2258, - "Parameters": { - "Intensity": 16, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2258, - "Parameters": { - "Intensity": 40, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 40, - "Intensity": 0.25, - "Frequency": 3 - }, - { - "Time": 58, - "Intensity": 0.52, - "Frequency": -5 - }, - { - "Time": 119, - "Intensity": 0.63, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.45, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2508, - "Parameters": { - "Intensity": 16, - "Frequency": 20, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2508, - "Parameters": { - "Intensity": 41, - "Frequency": 0, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.45, - "Frequency": 3 - }, - { - "Time": 53, - "Intensity": 0.46, - "Frequency": -5 - }, - { - "Time": 120, - "Intensity": 0.53, - "Frequency": 3 - }, - { - "Time": 196, - "Intensity": 0.31, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2758, - "Parameters": { - "Intensity": 59, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 22, - "Intensity": 0.36, - "Frequency": 55 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 101, - "Intensity": 0.53, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 155, - "Intensity": 0.37, - "Frequency": 2 - }, - { - "Time": 187, - "Intensity": 0.09, - "Frequency": -13 - }, - { - "Time": 220, - "Intensity": 0.65, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 2758, - "Parameters": { - "Intensity": 68, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 35, - "Intensity": 0.1, - "Frequency": 3 - }, - { - "Time": 83, - "Intensity": 0.15, - "Frequency": -5 - }, - { - "Time": 107, - "Intensity": 0.59, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.81, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3008, - "Parameters": { - "Intensity": 69, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 33, - "Intensity": 0.08, - "Frequency": -15 - }, - { - "Time": 50, - "Intensity": 0.03, - "Frequency": -13 - }, - { - "Time": 77, - "Intensity": 0.72, - "Frequency": 4 - }, - { - "Time": 97, - "Intensity": 0.22, - "Frequency": -16 - }, - { - "Time": 118, - "Intensity": 0.47, - "Frequency": -4 - }, - { - "Time": 156, - "Intensity": 0.09, - "Frequency": -3 - }, - { - "Time": 178, - "Intensity": 0.78, - "Frequency": 5 - }, - { - "Time": 203, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 235, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3008, - "Parameters": { - "Intensity": 80, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.69, - "Frequency": 3 - }, - { - "Time": 53, - "Intensity": 0.81, - "Frequency": -5 - }, - { - "Time": 124, - "Intensity": 0.83, - "Frequency": 3 - }, - { - "Time": 214, - "Intensity": 0.64, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3258, - "Parameters": { - "Intensity": 72, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 35, - "Intensity": 0.19, - "Frequency": 55 - }, - { - "Time": 68, - "Intensity": 0.05, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 0.23, - "Frequency": 2 - }, - { - "Time": 129, - "Intensity": 0.04, - "Frequency": -15 - }, - { - "Time": 154, - "Intensity": 0.51, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 225, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3258, - "Parameters": { - "Intensity": 64, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 0.21, - "Frequency": 3 - }, - { - "Time": 164, - "Intensity": 0.69, - "Frequency": -5 - }, - { - "Time": 212, - "Intensity": 0.75, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.58, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3508, - "Parameters": { - "Intensity": 50, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 0.66, - "Frequency": 3 - }, - { - "Time": 76, - "Intensity": 0.75, - "Frequency": -5 - }, - { - "Time": 168, - "Intensity": 0.54, - "Frequency": 3 - }, - { - "Time": 211, - "Intensity": 0.26, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3513, - "Parameters": { - "Intensity": 54, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -15 - }, - { - "Time": 18, - "Intensity": 0.58, - "Frequency": 55 - }, - { - "Time": 67, - "Intensity": 0.14, - "Frequency": 0 - }, - { - "Time": 96, - "Intensity": 0.25, - "Frequency": 2 - }, - { - "Time": 131, - "Intensity": 0.11, - "Frequency": -15 - }, - { - "Time": 155, - "Intensity": 0.32, - "Frequency": 2 - }, - { - "Time": 171, - "Intensity": 0.11, - "Frequency": -13 - }, - { - "Time": 234, - "Intensity": 0.33, - "Frequency": 3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -16 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3763, - "Parameters": { - "Intensity": 48, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 28, - "Intensity": 0.38, - "Frequency": 3 - }, - { - "Time": 80, - "Intensity": 0.39, - "Frequency": -5 - }, - { - "Time": 203, - "Intensity": 0.52, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.34, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 3765, - "Parameters": { - "Intensity": 15, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4015, - "Parameters": { - "Intensity": 20, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 120, - "Intensity": 0.21, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4015, - "Parameters": { - "Intensity": 48, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.33, - "Frequency": 3 - }, - { - "Time": 50, - "Intensity": 0.67, - "Frequency": -5 - }, - { - "Time": 119, - "Intensity": 0.49, - "Frequency": 3 - }, - { - "Time": 225, - "Intensity": 0.46, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4265, - "Parameters": { - "Intensity": 54, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 21, - "Intensity": 0.22, - "Frequency": 3 - }, - { - "Time": 52, - "Intensity": 0.53, - "Frequency": -5 - }, - { - "Time": 183, - "Intensity": 0.56, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.36, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4265, - "Parameters": { - "Intensity": 19, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 16, - "Intensity": 0.46, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.36, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4516, - "Parameters": { - "Intensity": 44, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 2, - "Intensity": 0.54, - "Frequency": 3 - }, - { - "Time": 48, - "Intensity": 0.64, - "Frequency": -5 - }, - { - "Time": 119, - "Intensity": 0.63, - "Frequency": 3 - }, - { - "Time": 249, - "Intensity": 0.45, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4518, - "Parameters": { - "Intensity": 14, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 33, - "Intensity": 0.08, - "Frequency": -15 - }, - { - "Time": 50, - "Intensity": 0.03, - "Frequency": -13 - }, - { - "Time": 77, - "Intensity": 0.72, - "Frequency": 4 - }, - { - "Time": 97, - "Intensity": 0.22, - "Frequency": -16 - }, - { - "Time": 118, - "Intensity": 0.47, - "Frequency": -4 - }, - { - "Time": 156, - "Intensity": 0.09, - "Frequency": -3 - }, - { - "Time": 178, - "Intensity": 0.78, - "Frequency": 5 - }, - { - "Time": 203, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 235, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4768, - "Parameters": { - "Intensity": 16, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 4768, - "Parameters": { - "Intensity": 45, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 0.44, - "Frequency": 3 - }, - { - "Time": 48, - "Intensity": 0.64, - "Frequency": -5 - }, - { - "Time": 135, - "Intensity": 0.43, - "Frequency": 3 - }, - { - "Time": 247, - "Intensity": 0.29, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5022, - "Parameters": { - "Intensity": 41, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 0.35, - "Frequency": 3 - }, - { - "Time": 63, - "Intensity": 0.41, - "Frequency": -5 - }, - { - "Time": 124, - "Intensity": 0.57, - "Frequency": 3 - }, - { - "Time": 240, - "Intensity": 0.25, - "Frequency": -3 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5024, - "Parameters": { - "Intensity": 12, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -19 - }, - { - "Time": 51, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 67, - "Intensity": 0, - "Frequency": -9 - }, - { - "Time": 113, - "Intensity": 0.19, - "Frequency": 2 - }, - { - "Time": 150, - "Intensity": 0, - "Frequency": -17 - }, - { - "Time": 173, - "Intensity": 0.66, - "Frequency": 5 - }, - { - "Time": 205, - "Intensity": 0.38, - "Frequency": 0 - }, - { - "Time": 217, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 238, - "Intensity": 0.16, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -11 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 445, - "StartTime": 5274, - "Parameters": { - "Intensity": 24, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 12, - "Intensity": 0.44, - "Frequency": 3 - }, - { - "Time": 142, - "Intensity": 0.79, - "Frequency": -5 - }, - { - "Time": 335, - "Intensity": 0.7, - "Frequency": 3 - }, - { - "Time": 376, - "Intensity": 0.26, - "Frequency": -3 - }, - { - "Time": 445, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 250, - "StartTime": 5279, - "Parameters": { - "Intensity": 16, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -20 - }, - { - "Time": 17, - "Intensity": 0.45, - "Frequency": 5 - }, - { - "Time": 74, - "Intensity": 0.07, - "Frequency": -13 - }, - { - "Time": 100, - "Intensity": 0.61, - "Frequency": -6 - }, - { - "Time": 130, - "Intensity": 0.8, - "Frequency": 0 - }, - { - "Time": 167, - "Intensity": 0.1, - "Frequency": -16 - }, - { - "Time": 200, - "Intensity": 0.01, - "Frequency": 3 - }, - { - "Time": 232, - "Intensity": 0.18, - "Frequency": 0 - }, - { - "Time": 250, - "Intensity": 0, - "Frequency": -19 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 0, + "Parameters": { + "Intensity": 30, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 120, + "Intensity": 0.32, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.68, + "Frequency": 8 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5, + "Parameters": { + "Intensity": 48, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0.45, + "Frequency": 3 + }, + { + "Time": 146, + "Intensity": 0.54, + "Frequency": -5 + }, + { + "Time": 223, + "Intensity": 0.67, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.69, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 256, + "Parameters": { + "Intensity": 75, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 3 + }, + { + "Time": 1, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 94, + "Intensity": 0.79, + "Frequency": -5 + }, + { + "Time": 201, + "Intensity": 0.68, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.48, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 258, + "Parameters": { + "Intensity": 61, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 23, + "Intensity": 0.71, + "Frequency": 55 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 95, + "Intensity": 0.48, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 153, + "Intensity": 0.7, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 222, + "Intensity": 0.48, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 506, + "Parameters": { + "Intensity": 61, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.61, + "Frequency": 3 + }, + { + "Time": 95, + "Intensity": 0.18, + "Frequency": -5 + }, + { + "Time": 201, + "Intensity": 0.29, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.65, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 508, + "Parameters": { + "Intensity": 33, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -33 + }, + { + "Time": 33, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 72, + "Intensity": 0.1, + "Frequency": -14 + }, + { + "Time": 100, + "Intensity": 0.24, + "Frequency": 4 + }, + { + "Time": 149, + "Intensity": 0.13, + "Frequency": -13 + }, + { + "Time": 168, + "Intensity": 0.48, + "Frequency": 23 + }, + { + "Time": 194, + "Intensity": 0.22, + "Frequency": -15 + }, + { + "Time": 224, + "Intensity": 0.58, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 758, + "Parameters": { + "Intensity": 42, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 46, + "Intensity": 0.73, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 157, + "Intensity": 0.33, + "Frequency": 5 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 758, + "Parameters": { + "Intensity": 68, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.59, + "Frequency": 3 + }, + { + "Time": 52, + "Intensity": 0.57, + "Frequency": -5 + }, + { + "Time": 103, + "Intensity": 0.62, + "Frequency": 3 + }, + { + "Time": 203, + "Intensity": 0.18, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1008, + "Parameters": { + "Intensity": 19, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 120, + "Intensity": 0.32, + "Frequency": -6 + }, + { + "Time": 128, + "Intensity": 0.68, + "Frequency": 8 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1008, + "Parameters": { + "Intensity": 44, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 23, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 68, + "Intensity": 0.38, + "Frequency": -5 + }, + { + "Time": 195, + "Intensity": 0.55, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.19, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1258, + "Parameters": { + "Intensity": 65, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 17, + "Intensity": 0.27, + "Frequency": 10 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 95, + "Intensity": 0.41, + "Frequency": 2 + }, + { + "Time": 130, + "Intensity": 0.17, + "Frequency": -15 + }, + { + "Time": 152, + "Intensity": 0.82, + "Frequency": 2 + }, + { + "Time": 191, + "Intensity": 0.19, + "Frequency": -13 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 27 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1258, + "Parameters": { + "Intensity": 80, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.12, + "Frequency": 3 + }, + { + "Time": 85, + "Intensity": 0.23, + "Frequency": -5 + }, + { + "Time": 124, + "Intensity": 0.71, + "Frequency": 3 + }, + { + "Time": 231, + "Intensity": 0.86, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1508, + "Parameters": { + "Intensity": 76, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 33, + "Intensity": 0.08, + "Frequency": -15 + }, + { + "Time": 50, + "Intensity": 0.03, + "Frequency": -13 + }, + { + "Time": 74, + "Intensity": 0.77, + "Frequency": 4 + }, + { + "Time": 97, + "Intensity": 0.22, + "Frequency": -16 + }, + { + "Time": 118, + "Intensity": 0.47, + "Frequency": -4 + }, + { + "Time": 156, + "Intensity": 0.09, + "Frequency": -3 + }, + { + "Time": 157, + "Intensity": 0.61, + "Frequency": 5 + }, + { + "Time": 203, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 235, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1508, + "Parameters": { + "Intensity": 73, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 0.44, + "Frequency": 3 + }, + { + "Time": 51, + "Intensity": 0.92, + "Frequency": -5 + }, + { + "Time": 203, + "Intensity": 1, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.8, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1758, + "Parameters": { + "Intensity": 74, + "Frequency": 33, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 49, + "Intensity": 0.57, + "Frequency": 10 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 92, + "Intensity": 0.75, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 155, + "Intensity": 0.32, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 225, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 1758, + "Parameters": { + "Intensity": 76, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.77, + "Frequency": 3 + }, + { + "Time": 82, + "Intensity": 0.67, + "Frequency": -5 + }, + { + "Time": 159, + "Intensity": 0.3, + "Frequency": 3 + }, + { + "Time": 197, + "Intensity": 0.27, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2008, + "Parameters": { + "Intensity": 52, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -33 + }, + { + "Time": 33, + "Intensity": 0.31, + "Frequency": 0 + }, + { + "Time": 50, + "Intensity": 0.1, + "Frequency": -14 + }, + { + "Time": 98, + "Intensity": 0.7, + "Frequency": 5 + }, + { + "Time": 150, + "Intensity": 0.09, + "Frequency": -13 + }, + { + "Time": 167, + "Intensity": 0.49, + "Frequency": 0 + }, + { + "Time": 194, + "Intensity": 0.22, + "Frequency": -15 + }, + { + "Time": 224, + "Intensity": 0.58, + "Frequency": 11 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -5 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2008, + "Parameters": { + "Intensity": 56, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 58, + "Intensity": 0.36, + "Frequency": 3 + }, + { + "Time": 98, + "Intensity": 0.86, + "Frequency": -5 + }, + { + "Time": 188, + "Intensity": 0.7, + "Frequency": 3 + }, + { + "Time": 246, + "Intensity": 0.28, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2258, + "Parameters": { + "Intensity": 16, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2258, + "Parameters": { + "Intensity": 40, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 40, + "Intensity": 0.25, + "Frequency": 3 + }, + { + "Time": 58, + "Intensity": 0.52, + "Frequency": -5 + }, + { + "Time": 119, + "Intensity": 0.63, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.45, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2508, + "Parameters": { + "Intensity": 16, + "Frequency": 20, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2508, + "Parameters": { + "Intensity": 41, + "Frequency": 0, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.45, + "Frequency": 3 + }, + { + "Time": 53, + "Intensity": 0.46, + "Frequency": -5 + }, + { + "Time": 120, + "Intensity": 0.53, + "Frequency": 3 + }, + { + "Time": 196, + "Intensity": 0.31, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2758, + "Parameters": { + "Intensity": 59, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 22, + "Intensity": 0.36, + "Frequency": 55 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 101, + "Intensity": 0.53, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 155, + "Intensity": 0.37, + "Frequency": 2 + }, + { + "Time": 187, + "Intensity": 0.09, + "Frequency": -13 + }, + { + "Time": 220, + "Intensity": 0.65, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 2758, + "Parameters": { + "Intensity": 68, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 35, + "Intensity": 0.1, + "Frequency": 3 + }, + { + "Time": 83, + "Intensity": 0.15, + "Frequency": -5 + }, + { + "Time": 107, + "Intensity": 0.59, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.81, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3008, + "Parameters": { + "Intensity": 69, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 33, + "Intensity": 0.08, + "Frequency": -15 + }, + { + "Time": 50, + "Intensity": 0.03, + "Frequency": -13 + }, + { + "Time": 77, + "Intensity": 0.72, + "Frequency": 4 + }, + { + "Time": 97, + "Intensity": 0.22, + "Frequency": -16 + }, + { + "Time": 118, + "Intensity": 0.47, + "Frequency": -4 + }, + { + "Time": 156, + "Intensity": 0.09, + "Frequency": -3 + }, + { + "Time": 178, + "Intensity": 0.78, + "Frequency": 5 + }, + { + "Time": 203, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 235, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3008, + "Parameters": { + "Intensity": 80, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.69, + "Frequency": 3 + }, + { + "Time": 53, + "Intensity": 0.81, + "Frequency": -5 + }, + { + "Time": 124, + "Intensity": 0.83, + "Frequency": 3 + }, + { + "Time": 214, + "Intensity": 0.64, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3258, + "Parameters": { + "Intensity": 72, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 35, + "Intensity": 0.19, + "Frequency": 55 + }, + { + "Time": 68, + "Intensity": 0.05, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 0.23, + "Frequency": 2 + }, + { + "Time": 129, + "Intensity": 0.04, + "Frequency": -15 + }, + { + "Time": 154, + "Intensity": 0.51, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 225, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3258, + "Parameters": { + "Intensity": 64, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 0.21, + "Frequency": 3 + }, + { + "Time": 164, + "Intensity": 0.69, + "Frequency": -5 + }, + { + "Time": 212, + "Intensity": 0.75, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.58, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3508, + "Parameters": { + "Intensity": 50, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 0.66, + "Frequency": 3 + }, + { + "Time": 76, + "Intensity": 0.75, + "Frequency": -5 + }, + { + "Time": 168, + "Intensity": 0.54, + "Frequency": 3 + }, + { + "Time": 211, + "Intensity": 0.26, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3513, + "Parameters": { + "Intensity": 54, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -15 + }, + { + "Time": 18, + "Intensity": 0.58, + "Frequency": 55 + }, + { + "Time": 67, + "Intensity": 0.14, + "Frequency": 0 + }, + { + "Time": 96, + "Intensity": 0.25, + "Frequency": 2 + }, + { + "Time": 131, + "Intensity": 0.11, + "Frequency": -15 + }, + { + "Time": 155, + "Intensity": 0.32, + "Frequency": 2 + }, + { + "Time": 171, + "Intensity": 0.11, + "Frequency": -13 + }, + { + "Time": 234, + "Intensity": 0.33, + "Frequency": 3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -16 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3763, + "Parameters": { + "Intensity": 48, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 28, + "Intensity": 0.38, + "Frequency": 3 + }, + { + "Time": 80, + "Intensity": 0.39, + "Frequency": -5 + }, + { + "Time": 203, + "Intensity": 0.52, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.34, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 3765, + "Parameters": { + "Intensity": 15, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4015, + "Parameters": { + "Intensity": 20, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 120, + "Intensity": 0.21, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4015, + "Parameters": { + "Intensity": 48, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.33, + "Frequency": 3 + }, + { + "Time": 50, + "Intensity": 0.67, + "Frequency": -5 + }, + { + "Time": 119, + "Intensity": 0.49, + "Frequency": 3 + }, + { + "Time": 225, + "Intensity": 0.46, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4265, + "Parameters": { + "Intensity": 54, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 21, + "Intensity": 0.22, + "Frequency": 3 + }, + { + "Time": 52, + "Intensity": 0.53, + "Frequency": -5 + }, + { + "Time": 183, + "Intensity": 0.56, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.36, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4265, + "Parameters": { + "Intensity": 19, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 16, + "Intensity": 0.46, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.36, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4516, + "Parameters": { + "Intensity": 44, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 2, + "Intensity": 0.54, + "Frequency": 3 + }, + { + "Time": 48, + "Intensity": 0.64, + "Frequency": -5 + }, + { + "Time": 119, + "Intensity": 0.63, + "Frequency": 3 + }, + { + "Time": 249, + "Intensity": 0.45, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4518, + "Parameters": { + "Intensity": 14, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 33, + "Intensity": 0.08, + "Frequency": -15 + }, + { + "Time": 50, + "Intensity": 0.03, + "Frequency": -13 + }, + { + "Time": 77, + "Intensity": 0.72, + "Frequency": 4 + }, + { + "Time": 97, + "Intensity": 0.22, + "Frequency": -16 + }, + { + "Time": 118, + "Intensity": 0.47, + "Frequency": -4 + }, + { + "Time": 156, + "Intensity": 0.09, + "Frequency": -3 + }, + { + "Time": 178, + "Intensity": 0.78, + "Frequency": 5 + }, + { + "Time": 203, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 235, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4768, + "Parameters": { + "Intensity": 16, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 4768, + "Parameters": { + "Intensity": 45, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 0.44, + "Frequency": 3 + }, + { + "Time": 48, + "Intensity": 0.64, + "Frequency": -5 + }, + { + "Time": 135, + "Intensity": 0.43, + "Frequency": 3 + }, + { + "Time": 247, + "Intensity": 0.29, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5022, + "Parameters": { + "Intensity": 41, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 0.35, + "Frequency": 3 + }, + { + "Time": 63, + "Intensity": 0.41, + "Frequency": -5 + }, + { + "Time": 124, + "Intensity": 0.57, + "Frequency": 3 + }, + { + "Time": 240, + "Intensity": 0.25, + "Frequency": -3 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5024, + "Parameters": { + "Intensity": 12, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -19 + }, + { + "Time": 51, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 67, + "Intensity": 0, + "Frequency": -9 + }, + { + "Time": 113, + "Intensity": 0.19, + "Frequency": 2 + }, + { + "Time": 150, + "Intensity": 0, + "Frequency": -17 + }, + { + "Time": 173, + "Intensity": 0.66, + "Frequency": 5 + }, + { + "Time": 205, + "Intensity": 0.38, + "Frequency": 0 + }, + { + "Time": 217, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 238, + "Intensity": 0.16, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -11 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 445, + "StartTime": 5274, + "Parameters": { + "Intensity": 24, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 12, + "Intensity": 0.44, + "Frequency": 3 + }, + { + "Time": 142, + "Intensity": 0.79, + "Frequency": -5 + }, + { + "Time": 335, + "Intensity": 0.7, + "Frequency": 3 + }, + { + "Time": 376, + "Intensity": 0.26, + "Frequency": -3 + }, + { + "Time": 445, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 250, + "StartTime": 5279, + "Parameters": { + "Intensity": 16, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -20 + }, + { + "Time": 17, + "Intensity": 0.45, + "Frequency": 5 + }, + { + "Time": 74, + "Intensity": 0.07, + "Frequency": -13 + }, + { + "Time": 100, + "Intensity": 0.61, + "Frequency": -6 + }, + { + "Time": 130, + "Intensity": 0.8, + "Frequency": 0 + }, + { + "Time": 167, + "Intensity": 0.1, + "Frequency": -16 + }, + { + "Time": 200, + "Intensity": 0.01, + "Frequency": 3 + }, + { + "Time": 232, + "Intensity": 0.18, + "Frequency": 0 + }, + { + "Time": 250, + "Intensity": 0, + "Frequency": -19 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_h.json index 45009d55aa..6aa5ed699e 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_h.json @@ -1,60 +1,60 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 75, - "StartTime": 538, - "Parameters": { - "Intensity": 100, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 46, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 75, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 636, - "Parameters": { - "Intensity": 50, - "Frequency": 37 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 75, + "StartTime": 538, + "Parameters": { + "Intensity": 100, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 46, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 75, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 636, + "Parameters": { + "Intensity": 50, + "Frequency": 37 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_l.json index 05980341e2..5d1bc935ff 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_l.json @@ -1,60 +1,60 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 75, - "StartTime": 538, - "Parameters": { - "Intensity": 60, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 46, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 75, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 636, - "Parameters": { - "Intensity": 30, - "Frequency": 37 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 75, + "StartTime": 538, + "Parameters": { + "Intensity": 60, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 46, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 75, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 636, + "Parameters": { + "Intensity": 30, + "Frequency": 37 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_m.json index 1302c77d44..38a97f0d27 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Winchester_m.json @@ -1,60 +1,60 @@ -{ - "MetaData": { - "Create": "2022-04-13", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 75, - "StartTime": 538, - "Parameters": { - "Intensity": 80, - "Frequency": 56, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 1, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 46, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 75, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 636, - "Parameters": { - "Intensity": 40, - "Frequency": 37 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2022-04-13", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 75, + "StartTime": 538, + "Parameters": { + "Intensity": 80, + "Frequency": 56, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 1, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 46, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 75, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 636, + "Parameters": { + "Intensity": 40, + "Frequency": 37 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_h.json index a200efe9e1..6703e7e083 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_h.json @@ -1,259 +1,259 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 4460, - "StartTime": 0, - "Parameters": { - "Intensity": 76, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 602, - "Intensity": 0.76, - "Frequency": -20 - }, - { - "Time": 1351, - "Intensity": 0.66, - "Frequency": -50 - }, - { - "Time": 1510, - "Intensity": 1, - "Frequency": -20 - }, - { - "Time": 2377, - "Intensity": 0.69, - "Frequency": -50 - }, - { - "Time": 2457, - "Intensity": 0.95, - "Frequency": 0 - }, - { - "Time": 3287, - "Intensity": 0.67, - "Frequency": -50 - }, - { - "Time": 3381, - "Intensity": 0.93, - "Frequency": -20 - }, - { - "Time": 3898, - "Intensity": 0.65, - "Frequency": -50 - }, - { - "Time": 3985, - "Intensity": 0.91, - "Frequency": -20 - }, - { - "Time": 4456, - "Intensity": 0.63, - "Frequency": -40 - }, - { - "Time": 4460, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 3860, - "StartTime": 5, - "Parameters": { - "Intensity": 65, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 637, - "Intensity": 0.81, - "Frequency": -20 - }, - { - "Time": 1517, - "Intensity": 0.7, - "Frequency": -50 - }, - { - "Time": 1583, - "Intensity": 1, - "Frequency": -20 - }, - { - "Time": 2420, - "Intensity": 0.72, - "Frequency": -50 - }, - { - "Time": 2528, - "Intensity": 0.95, - "Frequency": 0 - }, - { - "Time": 3289, - "Intensity": 0.74, - "Frequency": -50 - }, - { - "Time": 3358, - "Intensity": 0.94, - "Frequency": -20 - }, - { - "Time": 3859, - "Intensity": 0.61, - "Frequency": -40 - }, - { - "Time": 3860, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 2668, - "StartTime": 3865, - "Parameters": { - "Intensity": 64, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.56, - "Frequency": 0 - }, - { - "Time": 152, - "Intensity": 0.84, - "Frequency": -20 - }, - { - "Time": 552, - "Intensity": 0.6, - "Frequency": -50 - }, - { - "Time": 819, - "Intensity": 0.74, - "Frequency": -20 - }, - { - "Time": 1706, - "Intensity": 0.35, - "Frequency": -50 - }, - { - "Time": 1817, - "Intensity": 0.54, - "Frequency": -20 - }, - { - "Time": 2449, - "Intensity": 0.25, - "Frequency": -30 - }, - { - "Time": 2668, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 2102, - "StartTime": 4460, - "Parameters": { - "Intensity": 71, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.66, - "Frequency": -50 - }, - { - "Time": 273, - "Intensity": 0.75, - "Frequency": -20 - }, - { - "Time": 1118, - "Intensity": 0.37, - "Frequency": -50 - }, - { - "Time": 1222, - "Intensity": 0.54, - "Frequency": -20 - }, - { - "Time": 1924, - "Intensity": 0.27, - "Frequency": -30 - }, - { - "Time": 2102, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 4460, + "StartTime": 0, + "Parameters": { + "Intensity": 76, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 602, + "Intensity": 0.76, + "Frequency": -20 + }, + { + "Time": 1351, + "Intensity": 0.66, + "Frequency": -50 + }, + { + "Time": 1510, + "Intensity": 1, + "Frequency": -20 + }, + { + "Time": 2377, + "Intensity": 0.69, + "Frequency": -50 + }, + { + "Time": 2457, + "Intensity": 0.95, + "Frequency": 0 + }, + { + "Time": 3287, + "Intensity": 0.67, + "Frequency": -50 + }, + { + "Time": 3381, + "Intensity": 0.93, + "Frequency": -20 + }, + { + "Time": 3898, + "Intensity": 0.65, + "Frequency": -50 + }, + { + "Time": 3985, + "Intensity": 0.91, + "Frequency": -20 + }, + { + "Time": 4456, + "Intensity": 0.63, + "Frequency": -40 + }, + { + "Time": 4460, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 3860, + "StartTime": 5, + "Parameters": { + "Intensity": 65, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 637, + "Intensity": 0.81, + "Frequency": -20 + }, + { + "Time": 1517, + "Intensity": 0.7, + "Frequency": -50 + }, + { + "Time": 1583, + "Intensity": 1, + "Frequency": -20 + }, + { + "Time": 2420, + "Intensity": 0.72, + "Frequency": -50 + }, + { + "Time": 2528, + "Intensity": 0.95, + "Frequency": 0 + }, + { + "Time": 3289, + "Intensity": 0.74, + "Frequency": -50 + }, + { + "Time": 3358, + "Intensity": 0.94, + "Frequency": -20 + }, + { + "Time": 3859, + "Intensity": 0.61, + "Frequency": -40 + }, + { + "Time": 3860, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 2668, + "StartTime": 3865, + "Parameters": { + "Intensity": 64, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.56, + "Frequency": 0 + }, + { + "Time": 152, + "Intensity": 0.84, + "Frequency": -20 + }, + { + "Time": 552, + "Intensity": 0.6, + "Frequency": -50 + }, + { + "Time": 819, + "Intensity": 0.74, + "Frequency": -20 + }, + { + "Time": 1706, + "Intensity": 0.35, + "Frequency": -50 + }, + { + "Time": 1817, + "Intensity": 0.54, + "Frequency": -20 + }, + { + "Time": 2449, + "Intensity": 0.25, + "Frequency": -30 + }, + { + "Time": 2668, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 2102, + "StartTime": 4460, + "Parameters": { + "Intensity": 71, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.66, + "Frequency": -50 + }, + { + "Time": 273, + "Intensity": 0.75, + "Frequency": -20 + }, + { + "Time": 1118, + "Intensity": 0.37, + "Frequency": -50 + }, + { + "Time": 1222, + "Intensity": 0.54, + "Frequency": -20 + }, + { + "Time": 1924, + "Intensity": 0.27, + "Frequency": -30 + }, + { + "Time": 2102, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_l.json index eee1c8044c..2fdc691598 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_l.json @@ -1,259 +1,259 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 4460, - "StartTime": 0, - "Parameters": { - "Intensity": 45, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 602, - "Intensity": 0.76, - "Frequency": -20 - }, - { - "Time": 1351, - "Intensity": 0.66, - "Frequency": -50 - }, - { - "Time": 1510, - "Intensity": 1, - "Frequency": -20 - }, - { - "Time": 2377, - "Intensity": 0.69, - "Frequency": -50 - }, - { - "Time": 2457, - "Intensity": 0.95, - "Frequency": 0 - }, - { - "Time": 3287, - "Intensity": 0.67, - "Frequency": -50 - }, - { - "Time": 3381, - "Intensity": 0.93, - "Frequency": -20 - }, - { - "Time": 3898, - "Intensity": 0.65, - "Frequency": -50 - }, - { - "Time": 3985, - "Intensity": 0.91, - "Frequency": -20 - }, - { - "Time": 4456, - "Intensity": 0.63, - "Frequency": -40 - }, - { - "Time": 4460, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 3860, - "StartTime": 5, - "Parameters": { - "Intensity": 39, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 637, - "Intensity": 0.81, - "Frequency": -20 - }, - { - "Time": 1517, - "Intensity": 0.7, - "Frequency": -50 - }, - { - "Time": 1583, - "Intensity": 1, - "Frequency": -20 - }, - { - "Time": 2420, - "Intensity": 0.72, - "Frequency": -50 - }, - { - "Time": 2528, - "Intensity": 0.95, - "Frequency": 0 - }, - { - "Time": 3289, - "Intensity": 0.74, - "Frequency": -50 - }, - { - "Time": 3358, - "Intensity": 0.94, - "Frequency": -20 - }, - { - "Time": 3859, - "Intensity": 0.61, - "Frequency": -40 - }, - { - "Time": 3860, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 2668, - "StartTime": 3865, - "Parameters": { - "Intensity": 38, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.56, - "Frequency": 0 - }, - { - "Time": 152, - "Intensity": 0.84, - "Frequency": -20 - }, - { - "Time": 552, - "Intensity": 0.6, - "Frequency": -50 - }, - { - "Time": 819, - "Intensity": 0.74, - "Frequency": -20 - }, - { - "Time": 1706, - "Intensity": 0.35, - "Frequency": -50 - }, - { - "Time": 1817, - "Intensity": 0.54, - "Frequency": -20 - }, - { - "Time": 2449, - "Intensity": 0.25, - "Frequency": -30 - }, - { - "Time": 2668, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 2102, - "StartTime": 4460, - "Parameters": { - "Intensity": 42, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.66, - "Frequency": -50 - }, - { - "Time": 273, - "Intensity": 0.75, - "Frequency": -20 - }, - { - "Time": 1118, - "Intensity": 0.37, - "Frequency": -50 - }, - { - "Time": 1222, - "Intensity": 0.54, - "Frequency": -20 - }, - { - "Time": 1924, - "Intensity": 0.27, - "Frequency": -30 - }, - { - "Time": 2102, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 4460, + "StartTime": 0, + "Parameters": { + "Intensity": 45, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 602, + "Intensity": 0.76, + "Frequency": -20 + }, + { + "Time": 1351, + "Intensity": 0.66, + "Frequency": -50 + }, + { + "Time": 1510, + "Intensity": 1, + "Frequency": -20 + }, + { + "Time": 2377, + "Intensity": 0.69, + "Frequency": -50 + }, + { + "Time": 2457, + "Intensity": 0.95, + "Frequency": 0 + }, + { + "Time": 3287, + "Intensity": 0.67, + "Frequency": -50 + }, + { + "Time": 3381, + "Intensity": 0.93, + "Frequency": -20 + }, + { + "Time": 3898, + "Intensity": 0.65, + "Frequency": -50 + }, + { + "Time": 3985, + "Intensity": 0.91, + "Frequency": -20 + }, + { + "Time": 4456, + "Intensity": 0.63, + "Frequency": -40 + }, + { + "Time": 4460, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 3860, + "StartTime": 5, + "Parameters": { + "Intensity": 39, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 637, + "Intensity": 0.81, + "Frequency": -20 + }, + { + "Time": 1517, + "Intensity": 0.7, + "Frequency": -50 + }, + { + "Time": 1583, + "Intensity": 1, + "Frequency": -20 + }, + { + "Time": 2420, + "Intensity": 0.72, + "Frequency": -50 + }, + { + "Time": 2528, + "Intensity": 0.95, + "Frequency": 0 + }, + { + "Time": 3289, + "Intensity": 0.74, + "Frequency": -50 + }, + { + "Time": 3358, + "Intensity": 0.94, + "Frequency": -20 + }, + { + "Time": 3859, + "Intensity": 0.61, + "Frequency": -40 + }, + { + "Time": 3860, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 2668, + "StartTime": 3865, + "Parameters": { + "Intensity": 38, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.56, + "Frequency": 0 + }, + { + "Time": 152, + "Intensity": 0.84, + "Frequency": -20 + }, + { + "Time": 552, + "Intensity": 0.6, + "Frequency": -50 + }, + { + "Time": 819, + "Intensity": 0.74, + "Frequency": -20 + }, + { + "Time": 1706, + "Intensity": 0.35, + "Frequency": -50 + }, + { + "Time": 1817, + "Intensity": 0.54, + "Frequency": -20 + }, + { + "Time": 2449, + "Intensity": 0.25, + "Frequency": -30 + }, + { + "Time": 2668, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 2102, + "StartTime": 4460, + "Parameters": { + "Intensity": 42, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.66, + "Frequency": -50 + }, + { + "Time": 273, + "Intensity": 0.75, + "Frequency": -20 + }, + { + "Time": 1118, + "Intensity": 0.37, + "Frequency": -50 + }, + { + "Time": 1222, + "Intensity": 0.54, + "Frequency": -20 + }, + { + "Time": 1924, + "Intensity": 0.27, + "Frequency": -30 + }, + { + "Time": 2102, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_m.json index b0138b1ddf..135fea6864 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/Wind_m.json @@ -1,259 +1,259 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 4460, - "StartTime": 0, - "Parameters": { - "Intensity": 60, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 602, - "Intensity": 0.76, - "Frequency": -20 - }, - { - "Time": 1351, - "Intensity": 0.66, - "Frequency": -50 - }, - { - "Time": 1510, - "Intensity": 1, - "Frequency": -20 - }, - { - "Time": 2377, - "Intensity": 0.69, - "Frequency": -50 - }, - { - "Time": 2457, - "Intensity": 0.95, - "Frequency": 0 - }, - { - "Time": 3287, - "Intensity": 0.67, - "Frequency": -50 - }, - { - "Time": 3381, - "Intensity": 0.93, - "Frequency": -20 - }, - { - "Time": 3898, - "Intensity": 0.65, - "Frequency": -50 - }, - { - "Time": 3985, - "Intensity": 0.91, - "Frequency": -20 - }, - { - "Time": 4456, - "Intensity": 0.63, - "Frequency": -40 - }, - { - "Time": 4460, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 3860, - "StartTime": 5, - "Parameters": { - "Intensity": 52, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 637, - "Intensity": 0.81, - "Frequency": -20 - }, - { - "Time": 1517, - "Intensity": 0.7, - "Frequency": -50 - }, - { - "Time": 1583, - "Intensity": 1, - "Frequency": -20 - }, - { - "Time": 2420, - "Intensity": 0.72, - "Frequency": -50 - }, - { - "Time": 2528, - "Intensity": 0.95, - "Frequency": 0 - }, - { - "Time": 3289, - "Intensity": 0.74, - "Frequency": -50 - }, - { - "Time": 3358, - "Intensity": 0.94, - "Frequency": -20 - }, - { - "Time": 3859, - "Intensity": 0.61, - "Frequency": -40 - }, - { - "Time": 3860, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 2668, - "StartTime": 3865, - "Parameters": { - "Intensity": 51, - "Frequency": 35, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.56, - "Frequency": 0 - }, - { - "Time": 152, - "Intensity": 0.84, - "Frequency": -20 - }, - { - "Time": 552, - "Intensity": 0.6, - "Frequency": -50 - }, - { - "Time": 819, - "Intensity": 0.74, - "Frequency": -20 - }, - { - "Time": 1706, - "Intensity": 0.35, - "Frequency": -50 - }, - { - "Time": 1817, - "Intensity": 0.54, - "Frequency": -20 - }, - { - "Time": 2449, - "Intensity": 0.25, - "Frequency": -30 - }, - { - "Time": 2668, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 2102, - "StartTime": 4460, - "Parameters": { - "Intensity": 56, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": -50 - }, - { - "Time": 1, - "Intensity": 0.66, - "Frequency": -50 - }, - { - "Time": 273, - "Intensity": 0.75, - "Frequency": -20 - }, - { - "Time": 1118, - "Intensity": 0.37, - "Frequency": -50 - }, - { - "Time": 1222, - "Intensity": 0.54, - "Frequency": -20 - }, - { - "Time": 1924, - "Intensity": 0.27, - "Frequency": -30 - }, - { - "Time": 2102, - "Intensity": 0, - "Frequency": -50 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 4460, + "StartTime": 0, + "Parameters": { + "Intensity": 60, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 602, + "Intensity": 0.76, + "Frequency": -20 + }, + { + "Time": 1351, + "Intensity": 0.66, + "Frequency": -50 + }, + { + "Time": 1510, + "Intensity": 1, + "Frequency": -20 + }, + { + "Time": 2377, + "Intensity": 0.69, + "Frequency": -50 + }, + { + "Time": 2457, + "Intensity": 0.95, + "Frequency": 0 + }, + { + "Time": 3287, + "Intensity": 0.67, + "Frequency": -50 + }, + { + "Time": 3381, + "Intensity": 0.93, + "Frequency": -20 + }, + { + "Time": 3898, + "Intensity": 0.65, + "Frequency": -50 + }, + { + "Time": 3985, + "Intensity": 0.91, + "Frequency": -20 + }, + { + "Time": 4456, + "Intensity": 0.63, + "Frequency": -40 + }, + { + "Time": 4460, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 3860, + "StartTime": 5, + "Parameters": { + "Intensity": 52, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 637, + "Intensity": 0.81, + "Frequency": -20 + }, + { + "Time": 1517, + "Intensity": 0.7, + "Frequency": -50 + }, + { + "Time": 1583, + "Intensity": 1, + "Frequency": -20 + }, + { + "Time": 2420, + "Intensity": 0.72, + "Frequency": -50 + }, + { + "Time": 2528, + "Intensity": 0.95, + "Frequency": 0 + }, + { + "Time": 3289, + "Intensity": 0.74, + "Frequency": -50 + }, + { + "Time": 3358, + "Intensity": 0.94, + "Frequency": -20 + }, + { + "Time": 3859, + "Intensity": 0.61, + "Frequency": -40 + }, + { + "Time": 3860, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 2668, + "StartTime": 3865, + "Parameters": { + "Intensity": 51, + "Frequency": 35, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.56, + "Frequency": 0 + }, + { + "Time": 152, + "Intensity": 0.84, + "Frequency": -20 + }, + { + "Time": 552, + "Intensity": 0.6, + "Frequency": -50 + }, + { + "Time": 819, + "Intensity": 0.74, + "Frequency": -20 + }, + { + "Time": 1706, + "Intensity": 0.35, + "Frequency": -50 + }, + { + "Time": 1817, + "Intensity": 0.54, + "Frequency": -20 + }, + { + "Time": 2449, + "Intensity": 0.25, + "Frequency": -30 + }, + { + "Time": 2668, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 2102, + "StartTime": 4460, + "Parameters": { + "Intensity": 56, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": -50 + }, + { + "Time": 1, + "Intensity": 0.66, + "Frequency": -50 + }, + { + "Time": 273, + "Intensity": 0.75, + "Frequency": -20 + }, + { + "Time": 1118, + "Intensity": 0.37, + "Frequency": -50 + }, + { + "Time": 1222, + "Intensity": 0.54, + "Frequency": -20 + }, + { + "Time": 1924, + "Intensity": 0.27, + "Frequency": -30 + }, + { + "Time": 2102, + "Intensity": 0, + "Frequency": -50 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_h.json index b50bbb7d72..15532ff8c3 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_h.json @@ -1,61 +1,61 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 60, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1281, - "StartTime": 84, - "Parameters": { - "Intensity": 53, - "Frequency": 67, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 0.9122486114501953, - "Frequency": 20 - }, - { - "Time": 218, - "Intensity": 0.6803921461105347, - "Frequency": -27 - }, - { - "Time": 1281, - "Intensity": 0, - "Frequency": -100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 60, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1281, + "StartTime": 84, + "Parameters": { + "Intensity": 53, + "Frequency": 67, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 0.9122486114501953, + "Frequency": 20 + }, + { + "Time": 218, + "Intensity": 0.6803921461105347, + "Frequency": -27 + }, + { + "Time": 1281, + "Intensity": 0, + "Frequency": -100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_l.json index 8a68fc2de5..0ce041ba42 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_l.json @@ -1,61 +1,61 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 60, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1281, - "StartTime": 84, - "Parameters": { - "Intensity": 31, - "Frequency": 67, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 0.9122486114501953, - "Frequency": 20 - }, - { - "Time": 218, - "Intensity": 0.6803921461105347, - "Frequency": -27 - }, - { - "Time": 1281, - "Intensity": 0, - "Frequency": -100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 60, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1281, + "StartTime": 84, + "Parameters": { + "Intensity": 31, + "Frequency": 67, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 0.9122486114501953, + "Frequency": 20 + }, + { + "Time": 218, + "Intensity": 0.6803921461105347, + "Frequency": -27 + }, + { + "Time": 1281, + "Intensity": 0, + "Frequency": -100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_m.json index 9fc1255ea8..6d2932184a 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/bell_m.json @@ -1,61 +1,61 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 60, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1281, - "StartTime": 84, - "Parameters": { - "Intensity": 42, - "Frequency": 67, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 0.9122486114501953, - "Frequency": 20 - }, - { - "Time": 218, - "Intensity": 0.6803921461105347, - "Frequency": -27 - }, - { - "Time": 1281, - "Intensity": 0, - "Frequency": -100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 60, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1281, + "StartTime": 84, + "Parameters": { + "Intensity": 42, + "Frequency": 67, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 0.9122486114501953, + "Frequency": 20 + }, + { + "Time": 218, + "Intensity": 0.6803921461105347, + "Frequency": -27 + }, + { + "Time": 1281, + "Intensity": 0, + "Frequency": -100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_h.json index 17d4414077..ca121d3cbd 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_h.json @@ -1,93 +1,93 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 133, - "StartTime": 30, - "Parameters": { - "Intensity": 67, - "Frequency": 36, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": -35 - }, - { - "Time": 65, - "Intensity": 0.35490197, - "Frequency": -26 - }, - { - "Time": 126, - "Intensity": 1.0, - "Frequency": 52 - }, - { - "Time": 133, - "Intensity": 0.0, - "Frequency": 54 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 177, - "Parameters": { - "Intensity": 100, - "Frequency": 58 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 200, - "StartTime": 325, - "Parameters": { - "Intensity": 19, - "Frequency": 83, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 159, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 200, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 133, + "StartTime": 30, + "Parameters": { + "Intensity": 67, + "Frequency": 36, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": -35 + }, + { + "Time": 65, + "Intensity": 0.35490197, + "Frequency": -26 + }, + { + "Time": 126, + "Intensity": 1.0, + "Frequency": 52 + }, + { + "Time": 133, + "Intensity": 0.0, + "Frequency": 54 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 177, + "Parameters": { + "Intensity": 100, + "Frequency": 58 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 200, + "StartTime": 325, + "Parameters": { + "Intensity": 19, + "Frequency": 83, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 159, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 200, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_l.json index 89b0bbc205..807e92a95f 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_l.json @@ -1,93 +1,93 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 133, - "StartTime": 30, - "Parameters": { - "Intensity": 40, - "Frequency": 36, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": -35 - }, - { - "Time": 65, - "Intensity": 0.35490197, - "Frequency": -26 - }, - { - "Time": 126, - "Intensity": 1.0, - "Frequency": 52 - }, - { - "Time": 133, - "Intensity": 0.0, - "Frequency": 54 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 177, - "Parameters": { - "Intensity": 60, - "Frequency": 58 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 200, - "StartTime": 325, - "Parameters": { - "Intensity": 11, - "Frequency": 83, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 159, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 200, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 133, + "StartTime": 30, + "Parameters": { + "Intensity": 40, + "Frequency": 36, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": -35 + }, + { + "Time": 65, + "Intensity": 0.35490197, + "Frequency": -26 + }, + { + "Time": 126, + "Intensity": 1.0, + "Frequency": 52 + }, + { + "Time": 133, + "Intensity": 0.0, + "Frequency": 54 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 177, + "Parameters": { + "Intensity": 60, + "Frequency": 58 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 200, + "StartTime": 325, + "Parameters": { + "Intensity": 11, + "Frequency": 83, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 159, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 200, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_m.json index 7ee849aebd..558172a5a6 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter2_m.json @@ -1,93 +1,93 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 133, - "StartTime": 30, - "Parameters": { - "Intensity": 53, - "Frequency": 36, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": -35 - }, - { - "Time": 65, - "Intensity": 0.35490197, - "Frequency": -26 - }, - { - "Time": 126, - "Intensity": 1.0, - "Frequency": 52 - }, - { - "Time": 133, - "Intensity": 0.0, - "Frequency": 54 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 177, - "Parameters": { - "Intensity": 80, - "Frequency": 58 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 200, - "StartTime": 325, - "Parameters": { - "Intensity": 15, - "Frequency": 83, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 159, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 200, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 133, + "StartTime": 30, + "Parameters": { + "Intensity": 53, + "Frequency": 36, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": -35 + }, + { + "Time": 65, + "Intensity": 0.35490197, + "Frequency": -26 + }, + { + "Time": 126, + "Intensity": 1.0, + "Frequency": 52 + }, + { + "Time": 133, + "Intensity": 0.0, + "Frequency": 54 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 177, + "Parameters": { + "Intensity": 80, + "Frequency": 58 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 200, + "StartTime": 325, + "Parameters": { + "Intensity": 15, + "Frequency": 83, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 159, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 200, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_h.json index 940d279c1d..93275702e9 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_h.json @@ -1,173 +1,173 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 90, - "Parameters": { - "Intensity": 100, - "Frequency": 38 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 185, - "Parameters": { - "Intensity": 65, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 216, - "Parameters": { - "Intensity": 46, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 244, - "Parameters": { - "Intensity": 65, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 277, - "Parameters": { - "Intensity": 46, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 983, - "Parameters": { - "Intensity": 64, - "Frequency": 66 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1042, - "Parameters": { - "Intensity": 78, - "Frequency": 76 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1091, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 132, - "StartTime": 1114, - "Parameters": { - "Intensity": 32, - "Frequency": 71, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0.57, - "Frequency": 0 - }, - { - "Time": 132, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1283, - "Parameters": { - "Intensity": 74, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 97, - "StartTime": 1312, - "Parameters": { - "Intensity": 30, - "Frequency": 71, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 3, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 53, - "Intensity": 0.57, - "Frequency": 0 - }, - { - "Time": 97, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 90, + "Parameters": { + "Intensity": 100, + "Frequency": 38 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 185, + "Parameters": { + "Intensity": 65, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 216, + "Parameters": { + "Intensity": 46, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 244, + "Parameters": { + "Intensity": 65, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 277, + "Parameters": { + "Intensity": 46, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 983, + "Parameters": { + "Intensity": 64, + "Frequency": 66 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1042, + "Parameters": { + "Intensity": 78, + "Frequency": 76 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1091, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 132, + "StartTime": 1114, + "Parameters": { + "Intensity": 32, + "Frequency": 71, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0.57, + "Frequency": 0 + }, + { + "Time": 132, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1283, + "Parameters": { + "Intensity": 74, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 97, + "StartTime": 1312, + "Parameters": { + "Intensity": 30, + "Frequency": 71, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 3, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 53, + "Intensity": 0.57, + "Frequency": 0 + }, + { + "Time": 97, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_l.json index 6faf72b988..98216c6165 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_l.json @@ -1,173 +1,173 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 90, - "Parameters": { - "Intensity": 60, - "Frequency": 38 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 185, - "Parameters": { - "Intensity": 39, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 216, - "Parameters": { - "Intensity": 27, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 244, - "Parameters": { - "Intensity": 39, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 277, - "Parameters": { - "Intensity": 27, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 983, - "Parameters": { - "Intensity": 38, - "Frequency": 66 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1042, - "Parameters": { - "Intensity": 46, - "Frequency": 76 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1091, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 132, - "StartTime": 1114, - "Parameters": { - "Intensity": 19, - "Frequency": 71, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0.57, - "Frequency": 0 - }, - { - "Time": 132, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1283, - "Parameters": { - "Intensity": 44, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 97, - "StartTime": 1312, - "Parameters": { - "Intensity": 18, - "Frequency": 71, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 3, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 53, - "Intensity": 0.57, - "Frequency": 0 - }, - { - "Time": 97, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 90, + "Parameters": { + "Intensity": 60, + "Frequency": 38 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 185, + "Parameters": { + "Intensity": 39, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 216, + "Parameters": { + "Intensity": 27, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 244, + "Parameters": { + "Intensity": 39, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 277, + "Parameters": { + "Intensity": 27, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 983, + "Parameters": { + "Intensity": 38, + "Frequency": 66 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1042, + "Parameters": { + "Intensity": 46, + "Frequency": 76 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1091, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 132, + "StartTime": 1114, + "Parameters": { + "Intensity": 19, + "Frequency": 71, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0.57, + "Frequency": 0 + }, + { + "Time": 132, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1283, + "Parameters": { + "Intensity": 44, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 97, + "StartTime": 1312, + "Parameters": { + "Intensity": 18, + "Frequency": 71, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 3, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 53, + "Intensity": 0.57, + "Frequency": 0 + }, + { + "Time": 97, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_m.json index 625fa5c6ea..a06052f550 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/camerashutter_m.json @@ -1,173 +1,173 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 90, - "Parameters": { - "Intensity": 80, - "Frequency": 38 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 185, - "Parameters": { - "Intensity": 52, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 216, - "Parameters": { - "Intensity": 36, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 244, - "Parameters": { - "Intensity": 52, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 277, - "Parameters": { - "Intensity": 36, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 983, - "Parameters": { - "Intensity": 51, - "Frequency": 66 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1042, - "Parameters": { - "Intensity": 62, - "Frequency": 76 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1091, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 132, - "StartTime": 1114, - "Parameters": { - "Intensity": 25, - "Frequency": 71, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 5, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 74, - "Intensity": 0.57, - "Frequency": 0 - }, - { - "Time": 132, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1283, - "Parameters": { - "Intensity": 59, - "Frequency": 90 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 97, - "StartTime": 1312, - "Parameters": { - "Intensity": 24, - "Frequency": 71, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 3, - "Intensity": 1, - "Frequency": 0 - }, - { - "Time": 53, - "Intensity": 0.57, - "Frequency": 0 - }, - { - "Time": 97, - "Intensity": 0, - "Frequency": 0 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 90, + "Parameters": { + "Intensity": 80, + "Frequency": 38 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 185, + "Parameters": { + "Intensity": 52, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 216, + "Parameters": { + "Intensity": 36, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 244, + "Parameters": { + "Intensity": 52, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 277, + "Parameters": { + "Intensity": 36, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 983, + "Parameters": { + "Intensity": 51, + "Frequency": 66 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1042, + "Parameters": { + "Intensity": 62, + "Frequency": 76 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1091, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 132, + "StartTime": 1114, + "Parameters": { + "Intensity": 25, + "Frequency": 71, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 5, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 74, + "Intensity": 0.57, + "Frequency": 0 + }, + { + "Time": 132, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1283, + "Parameters": { + "Intensity": 59, + "Frequency": 90 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 97, + "StartTime": 1312, + "Parameters": { + "Intensity": 24, + "Frequency": 71, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 3, + "Intensity": 1, + "Frequency": 0 + }, + { + "Time": 53, + "Intensity": 0.57, + "Frequency": 0 + }, + { + "Time": 97, + "Intensity": 0, + "Frequency": 0 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_h.json index 58ee0fbf5c..74b5a01a56 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_h.json @@ -1,146 +1,146 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 109, - "StartTime": 48, - "Parameters": { - "Intensity": 35, - "Frequency": 81, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.32941177, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 109, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 167, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 109, - "StartTime": 1057, - "Parameters": { - "Intensity": 32, - "Frequency": 81, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.32941177, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 109, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1182, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 108, - "StartTime": 2019, - "Parameters": { - "Intensity": 33, - "Frequency": 81, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 53, - "Intensity": 0.32941177, - "Frequency": 0 - }, - { - "Time": 104, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 108, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2138, - "Parameters": { - "Intensity": 100, - "Frequency": 60 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 109, + "StartTime": 48, + "Parameters": { + "Intensity": 35, + "Frequency": 81, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.32941177, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 109, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 167, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 109, + "StartTime": 1057, + "Parameters": { + "Intensity": 32, + "Frequency": 81, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.32941177, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 109, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1182, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 108, + "StartTime": 2019, + "Parameters": { + "Intensity": 33, + "Frequency": 81, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 53, + "Intensity": 0.32941177, + "Frequency": 0 + }, + { + "Time": 104, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 108, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2138, + "Parameters": { + "Intensity": 100, + "Frequency": 60 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_l.json index 62e421e185..3ba61dcb34 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_l.json @@ -1,146 +1,146 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 109, - "StartTime": 48, - "Parameters": { - "Intensity": 21, - "Frequency": 81, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.32941177, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 109, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 167, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 109, - "StartTime": 1057, - "Parameters": { - "Intensity": 19, - "Frequency": 81, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.32941177, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 109, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1182, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 108, - "StartTime": 2019, - "Parameters": { - "Intensity": 19, - "Frequency": 81, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 53, - "Intensity": 0.32941177, - "Frequency": 0 - }, - { - "Time": 104, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 108, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2138, - "Parameters": { - "Intensity": 60, - "Frequency": 60 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 109, + "StartTime": 48, + "Parameters": { + "Intensity": 21, + "Frequency": 81, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.32941177, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 109, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 167, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 109, + "StartTime": 1057, + "Parameters": { + "Intensity": 19, + "Frequency": 81, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.32941177, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 109, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1182, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 108, + "StartTime": 2019, + "Parameters": { + "Intensity": 19, + "Frequency": 81, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 53, + "Intensity": 0.32941177, + "Frequency": 0 + }, + { + "Time": 104, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 108, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2138, + "Parameters": { + "Intensity": 60, + "Frequency": 60 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_m.json index 91a785bd79..c852fed48c 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/clock_m.json @@ -1,146 +1,146 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "continuous", - "Duration": 109, - "StartTime": 48, - "Parameters": { - "Intensity": 28, - "Frequency": 81, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.32941177, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 109, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 167, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 109, - "StartTime": 1057, - "Parameters": { - "Intensity": 25, - "Frequency": 81, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 54, - "Intensity": 0.32941177, - "Frequency": 0 - }, - { - "Time": 105, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 109, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1182, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 108, - "StartTime": 2019, - "Parameters": { - "Intensity": 26, - "Frequency": 81, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 53, - "Intensity": 0.32941177, - "Frequency": 0 - }, - { - "Time": 104, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 108, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2138, - "Parameters": { - "Intensity": 80, - "Frequency": 60 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "continuous", + "Duration": 109, + "StartTime": 48, + "Parameters": { + "Intensity": 28, + "Frequency": 81, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.32941177, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 109, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 167, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 109, + "StartTime": 1057, + "Parameters": { + "Intensity": 25, + "Frequency": 81, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 54, + "Intensity": 0.32941177, + "Frequency": 0 + }, + { + "Time": 105, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 109, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1182, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 108, + "StartTime": 2019, + "Parameters": { + "Intensity": 26, + "Frequency": 81, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 53, + "Intensity": 0.32941177, + "Frequency": 0 + }, + { + "Time": 104, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 108, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2138, + "Parameters": { + "Intensity": 80, + "Frequency": 60 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_h.json index 11b80ce6a7..03446b5360 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_h.json @@ -1,229 +1,229 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 40, - "Parameters": { - "Intensity": 100, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 407, - "Parameters": { - "Intensity": 75, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 119, - "StartTime": 445, - "Parameters": { - "Intensity": 31, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 66, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 119, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1112, - "Parameters": { - "Intensity": 100, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1470, - "Parameters": { - "Intensity": 75, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 117, - "StartTime": 1513, - "Parameters": { - "Intensity": 31, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 6, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 117, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2127, - "Parameters": { - "Intensity": 100, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2475, - "Parameters": { - "Intensity": 60, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 185, - "StartTime": 2516, - "Parameters": { - "Intensity": 31, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 185, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3143, - "Parameters": { - "Intensity": 100, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3482, - "Parameters": { - "Intensity": 68, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 185, - "StartTime": 3544, - "Parameters": { - "Intensity": 31, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 185, - "Intensity": 0.0, - "Frequency": 30 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 40, + "Parameters": { + "Intensity": 100, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 407, + "Parameters": { + "Intensity": 75, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 119, + "StartTime": 445, + "Parameters": { + "Intensity": 31, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 66, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 119, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1112, + "Parameters": { + "Intensity": 100, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1470, + "Parameters": { + "Intensity": 75, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 117, + "StartTime": 1513, + "Parameters": { + "Intensity": 31, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 6, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 117, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2127, + "Parameters": { + "Intensity": 100, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2475, + "Parameters": { + "Intensity": 60, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 185, + "StartTime": 2516, + "Parameters": { + "Intensity": 31, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 185, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3143, + "Parameters": { + "Intensity": 100, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3482, + "Parameters": { + "Intensity": 68, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 185, + "StartTime": 3544, + "Parameters": { + "Intensity": 31, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 185, + "Intensity": 0.0, + "Frequency": 30 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_l.json index 2dedccf6cb..dd6334051f 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_l.json @@ -1,229 +1,229 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 40, - "Parameters": { - "Intensity": 60, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 407, - "Parameters": { - "Intensity": 45, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 119, - "StartTime": 445, - "Parameters": { - "Intensity": 18, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 66, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 119, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1112, - "Parameters": { - "Intensity": 60, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1470, - "Parameters": { - "Intensity": 45, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 117, - "StartTime": 1513, - "Parameters": { - "Intensity": 18, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 6, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 117, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2127, - "Parameters": { - "Intensity": 60, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2475, - "Parameters": { - "Intensity": 36, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 185, - "StartTime": 2516, - "Parameters": { - "Intensity": 18, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 185, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3143, - "Parameters": { - "Intensity": 60, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3482, - "Parameters": { - "Intensity": 40, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 185, - "StartTime": 3544, - "Parameters": { - "Intensity": 18, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 185, - "Intensity": 0.0, - "Frequency": 30 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 40, + "Parameters": { + "Intensity": 60, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 407, + "Parameters": { + "Intensity": 45, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 119, + "StartTime": 445, + "Parameters": { + "Intensity": 18, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 66, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 119, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1112, + "Parameters": { + "Intensity": 60, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1470, + "Parameters": { + "Intensity": 45, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 117, + "StartTime": 1513, + "Parameters": { + "Intensity": 18, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 6, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 117, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2127, + "Parameters": { + "Intensity": 60, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2475, + "Parameters": { + "Intensity": 36, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 185, + "StartTime": 2516, + "Parameters": { + "Intensity": 18, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 185, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3143, + "Parameters": { + "Intensity": 60, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3482, + "Parameters": { + "Intensity": 40, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 185, + "StartTime": 3544, + "Parameters": { + "Intensity": 18, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 185, + "Intensity": 0.0, + "Frequency": 30 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_m.json index 71d7b815a9..cc09f48489 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/heartbeat_m.json @@ -1,229 +1,229 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "StartTime": 40, - "Parameters": { - "Intensity": 80, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 407, - "Parameters": { - "Intensity": 60, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 119, - "StartTime": 445, - "Parameters": { - "Intensity": 24, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 7, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 66, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 119, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1112, - "Parameters": { - "Intensity": 80, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 1470, - "Parameters": { - "Intensity": 60, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 117, - "StartTime": 1513, - "Parameters": { - "Intensity": 24, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 6, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 64, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 117, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2127, - "Parameters": { - "Intensity": 80, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 2475, - "Parameters": { - "Intensity": 48, - "Frequency": 6 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 185, - "StartTime": 2516, - "Parameters": { - "Intensity": 24, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 185, - "Intensity": 0.0, - "Frequency": 0 - } - ] - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3143, - "Parameters": { - "Intensity": 80, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 3482, - "Parameters": { - "Intensity": 54, - "Frequency": 0 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 185, - "StartTime": 3544, - "Parameters": { - "Intensity": 24, - "Frequency": 30, - "Curve": [ - { - "Time": 0, - "Intensity": 0.0, - "Frequency": 0 - }, - { - "Time": 8, - "Intensity": 1.0, - "Frequency": 0 - }, - { - "Time": 100, - "Intensity": 0.31176472, - "Frequency": 0 - }, - { - "Time": 185, - "Intensity": 0.0, - "Frequency": 30 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 40, + "Parameters": { + "Intensity": 80, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 407, + "Parameters": { + "Intensity": 60, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 119, + "StartTime": 445, + "Parameters": { + "Intensity": 24, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 7, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 66, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 119, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1112, + "Parameters": { + "Intensity": 80, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 1470, + "Parameters": { + "Intensity": 60, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 117, + "StartTime": 1513, + "Parameters": { + "Intensity": 24, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 6, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 64, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 117, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2127, + "Parameters": { + "Intensity": 80, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 2475, + "Parameters": { + "Intensity": 48, + "Frequency": 6 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 185, + "StartTime": 2516, + "Parameters": { + "Intensity": 24, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 185, + "Intensity": 0.0, + "Frequency": 0 + } + ] + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3143, + "Parameters": { + "Intensity": 80, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 3482, + "Parameters": { + "Intensity": 54, + "Frequency": 0 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 185, + "StartTime": 3544, + "Parameters": { + "Intensity": 24, + "Frequency": 30, + "Curve": [ + { + "Time": 0, + "Intensity": 0.0, + "Frequency": 0 + }, + { + "Time": 8, + "Intensity": 1.0, + "Frequency": 0 + }, + { + "Time": 100, + "Intensity": 0.31176472, + "Frequency": 0 + }, + { + "Time": 185, + "Intensity": 0.0, + "Frequency": 30 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_h.json index fe535bcce8..224d59646a 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_h.json @@ -1,102 +1,102 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 68, - "Parameters": { - "Intensity": 23, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 103, - "Parameters": { - "Intensity": 52, - "Frequency": 84 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 140, - "Parameters": { - "Intensity": 100, - "Frequency": 94 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 157, - "Parameters": { - "Intensity": 7, - "Frequency": 85 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 175, - "Parameters": { - "Intensity": 60, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 195, - "Parameters": { - "Intensity": 30, - "Frequency": 99 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 245, - "Parameters": { - "Intensity": 53, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 268, - "Parameters": { - "Intensity": 16, - "Frequency": 53 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 68, + "Parameters": { + "Intensity": 23, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 103, + "Parameters": { + "Intensity": 52, + "Frequency": 84 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 140, + "Parameters": { + "Intensity": 100, + "Frequency": 94 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 157, + "Parameters": { + "Intensity": 7, + "Frequency": 85 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 175, + "Parameters": { + "Intensity": 60, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 195, + "Parameters": { + "Intensity": 30, + "Frequency": 99 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 245, + "Parameters": { + "Intensity": 53, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 268, + "Parameters": { + "Intensity": 16, + "Frequency": 53 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_l.json index a1394c8784..3261779102 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_l.json @@ -1,102 +1,102 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 68, - "Parameters": { - "Intensity": 13, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 103, - "Parameters": { - "Intensity": 31, - "Frequency": 84 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 140, - "Parameters": { - "Intensity": 60, - "Frequency": 94 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 157, - "Parameters": { - "Intensity": 4, - "Frequency": 85 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 175, - "Parameters": { - "Intensity": 36, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 195, - "Parameters": { - "Intensity": 18, - "Frequency": 99 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 245, - "Parameters": { - "Intensity": 31, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 268, - "Parameters": { - "Intensity": 9, - "Frequency": 53 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 68, + "Parameters": { + "Intensity": 13, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 103, + "Parameters": { + "Intensity": 31, + "Frequency": 84 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 140, + "Parameters": { + "Intensity": 60, + "Frequency": 94 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 157, + "Parameters": { + "Intensity": 4, + "Frequency": 85 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 175, + "Parameters": { + "Intensity": 36, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 195, + "Parameters": { + "Intensity": 18, + "Frequency": 99 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 245, + "Parameters": { + "Intensity": 31, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 268, + "Parameters": { + "Intensity": 9, + "Frequency": 53 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_m.json index 04027152d4..3eaa2b5ac4 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/ice_m.json @@ -1,102 +1,102 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 68, - "Parameters": { - "Intensity": 18, - "Frequency": 60 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 103, - "Parameters": { - "Intensity": 41, - "Frequency": 84 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 140, - "Parameters": { - "Intensity": 80, - "Frequency": 94 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 157, - "Parameters": { - "Intensity": 5, - "Frequency": 85 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 175, - "Parameters": { - "Intensity": 48, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "StartTime": 195, - "Parameters": { - "Intensity": 24, - "Frequency": 99 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 245, - "Parameters": { - "Intensity": 42, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 268, - "Parameters": { - "Intensity": 12, - "Frequency": 53 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 68, + "Parameters": { + "Intensity": 18, + "Frequency": 60 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 103, + "Parameters": { + "Intensity": 41, + "Frequency": 84 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 140, + "Parameters": { + "Intensity": 80, + "Frequency": 94 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 157, + "Parameters": { + "Intensity": 5, + "Frequency": 85 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 175, + "Parameters": { + "Intensity": 48, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "StartTime": 195, + "Parameters": { + "Intensity": 24, + "Frequency": 99 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 245, + "Parameters": { + "Intensity": 42, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 268, + "Parameters": { + "Intensity": 12, + "Frequency": 53 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_h.json index 43ffbe686e..9f0f3db7ff 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_h.json @@ -1,182 +1,182 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 0, - "Parameters": { - "Intensity": 36, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 131, - "Parameters": { - "Intensity": 78, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 243, - "Parameters": { - "Intensity": 36, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 360, - "Parameters": { - "Intensity": 78, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 465, - "Parameters": { - "Intensity": 36, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 569, - "Parameters": { - "Intensity": 81, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 677, - "Parameters": { - "Intensity": 36, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 779, - "Parameters": { - "Intensity": 80, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 890, - "Parameters": { - "Intensity": 36, - "Frequency": 84 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1001, - "Parameters": { - "Intensity": 80, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1107, - "Parameters": { - "Intensity": 37, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1219, - "Parameters": { - "Intensity": 80, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1330, - "Parameters": { - "Intensity": 36, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1439, - "Parameters": { - "Intensity": 80, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1543, - "Parameters": { - "Intensity": 35, - "Frequency": 82 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 0, + "Parameters": { + "Intensity": 36, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 131, + "Parameters": { + "Intensity": 78, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 243, + "Parameters": { + "Intensity": 36, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 360, + "Parameters": { + "Intensity": 78, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 465, + "Parameters": { + "Intensity": 36, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 569, + "Parameters": { + "Intensity": 81, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 677, + "Parameters": { + "Intensity": 36, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 779, + "Parameters": { + "Intensity": 80, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 890, + "Parameters": { + "Intensity": 36, + "Frequency": 84 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1001, + "Parameters": { + "Intensity": 80, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1107, + "Parameters": { + "Intensity": 37, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1219, + "Parameters": { + "Intensity": 80, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1330, + "Parameters": { + "Intensity": 36, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1439, + "Parameters": { + "Intensity": 80, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1543, + "Parameters": { + "Intensity": 35, + "Frequency": 82 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_l.json index 05b6293d16..392b190d7b 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_l.json @@ -1,182 +1,182 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 0, - "Parameters": { - "Intensity": 21, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 131, - "Parameters": { - "Intensity": 46, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 243, - "Parameters": { - "Intensity": 21, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 360, - "Parameters": { - "Intensity": 46, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 465, - "Parameters": { - "Intensity": 21, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 569, - "Parameters": { - "Intensity": 48, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 677, - "Parameters": { - "Intensity": 21, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 779, - "Parameters": { - "Intensity": 48, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 890, - "Parameters": { - "Intensity": 21, - "Frequency": 84 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1001, - "Parameters": { - "Intensity": 48, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1107, - "Parameters": { - "Intensity": 22, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1219, - "Parameters": { - "Intensity": 48, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1330, - "Parameters": { - "Intensity": 21, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1439, - "Parameters": { - "Intensity": 48, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1543, - "Parameters": { - "Intensity": 21, - "Frequency": 82 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 0, + "Parameters": { + "Intensity": 21, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 131, + "Parameters": { + "Intensity": 46, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 243, + "Parameters": { + "Intensity": 21, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 360, + "Parameters": { + "Intensity": 46, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 465, + "Parameters": { + "Intensity": 21, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 569, + "Parameters": { + "Intensity": 48, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 677, + "Parameters": { + "Intensity": 21, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 779, + "Parameters": { + "Intensity": 48, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 890, + "Parameters": { + "Intensity": 21, + "Frequency": 84 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1001, + "Parameters": { + "Intensity": 48, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1107, + "Parameters": { + "Intensity": 22, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1219, + "Parameters": { + "Intensity": 48, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1330, + "Parameters": { + "Intensity": 21, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1439, + "Parameters": { + "Intensity": 48, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1543, + "Parameters": { + "Intensity": 21, + "Frequency": 82 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_m.json index c96972cc28..f8d4fb7c25 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/timer_m.json @@ -1,182 +1,182 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 0, - "Parameters": { - "Intensity": 28, - "Frequency": 93 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 131, - "Parameters": { - "Intensity": 62, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 243, - "Parameters": { - "Intensity": 28, - "Frequency": 80 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 360, - "Parameters": { - "Intensity": 62, - "Frequency": 95 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 465, - "Parameters": { - "Intensity": 28, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 569, - "Parameters": { - "Intensity": 64, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 677, - "Parameters": { - "Intensity": 28, - "Frequency": 79 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 779, - "Parameters": { - "Intensity": 64, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 890, - "Parameters": { - "Intensity": 28, - "Frequency": 84 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1001, - "Parameters": { - "Intensity": 64, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1107, - "Parameters": { - "Intensity": 29, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1219, - "Parameters": { - "Intensity": 64, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1330, - "Parameters": { - "Intensity": 28, - "Frequency": 81 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1439, - "Parameters": { - "Intensity": 64, - "Frequency": 100 - } - } - }, - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 1543, - "Parameters": { - "Intensity": 28, - "Frequency": 82 - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 0, + "Parameters": { + "Intensity": 28, + "Frequency": 93 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 131, + "Parameters": { + "Intensity": 62, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 243, + "Parameters": { + "Intensity": 28, + "Frequency": 80 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 360, + "Parameters": { + "Intensity": 62, + "Frequency": 95 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 465, + "Parameters": { + "Intensity": 28, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 569, + "Parameters": { + "Intensity": 64, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 677, + "Parameters": { + "Intensity": 28, + "Frequency": 79 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 779, + "Parameters": { + "Intensity": 64, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 890, + "Parameters": { + "Intensity": 28, + "Frequency": 84 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1001, + "Parameters": { + "Intensity": 64, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1107, + "Parameters": { + "Intensity": 29, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1219, + "Parameters": { + "Intensity": 64, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1330, + "Parameters": { + "Intensity": 28, + "Frequency": 81 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1439, + "Parameters": { + "Intensity": 64, + "Frequency": 100 + } + } + }, + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 1543, + "Parameters": { + "Intensity": 28, + "Frequency": 82 + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_h.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_h.json index fbc8cf10c2..98be5f0417 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_h.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_h.json @@ -1,61 +1,61 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 42, - "Parameters": { - "Intensity": 100, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1277, - "StartTime": 66, - "Parameters": { - "Intensity": 33, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 63 - }, - { - "Time": 650, - "Intensity": 0.44509804248809814, - "Frequency": 93 - }, - { - "Time": 1277, - "Intensity": 0, - "Frequency": 100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 42, + "Parameters": { + "Intensity": 100, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1277, + "StartTime": 66, + "Parameters": { + "Intensity": 33, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 63 + }, + { + "Time": 650, + "Intensity": 0.44509804248809814, + "Frequency": 93 + }, + { + "Time": 1277, + "Intensity": 0, + "Frequency": 100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_l.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_l.json index 8a22e936a6..d5bc2d37ed 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_l.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_l.json @@ -1,61 +1,61 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 42, - "Parameters": { - "Intensity": 60, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1277, - "StartTime": 66, - "Parameters": { - "Intensity": 19, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 63 - }, - { - "Time": 650, - "Intensity": 0.44509804248809814, - "Frequency": 93 - }, - { - "Time": 1277, - "Intensity": 0, - "Frequency": 100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 42, + "Parameters": { + "Intensity": 60, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1277, + "StartTime": 66, + "Parameters": { + "Intensity": 19, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 63 + }, + { + "Time": 650, + "Intensity": 0.44509804248809814, + "Frequency": 93 + }, + { + "Time": 1277, + "Intensity": 0, + "Frequency": 100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_m.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_m.json index 28fdc45f3c..76eecaf0fb 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_m.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/rawfile/triangle_m.json @@ -1,61 +1,61 @@ -{ - "MetaData": { - "Create": "2023-11-29", - "Discription": "A json file effect", - "ChannelNumber": 1, - "Version": 1.0 - }, - "Channels": [ - { - "Parameters": { - "Index": 0 - }, - "Pattern": [ - { - "Event": { - "Type": "transient", - "Duration": 0, - "StartTime": 42, - "Parameters": { - "Intensity": 80, - "Frequency": 50 - } - } - }, - { - "Event": { - "Type": "continuous", - "Duration": 1277, - "StartTime": 66, - "Parameters": { - "Intensity": 26, - "Frequency": 50, - "Curve": [ - { - "Time": 0, - "Intensity": 0, - "Frequency": 0 - }, - { - "Time": 9, - "Intensity": 1, - "Frequency": 63 - }, - { - "Time": 650, - "Intensity": 0.44509804248809814, - "Frequency": 93 - }, - { - "Time": 1277, - "Intensity": 0, - "Frequency": 100 - } - ] - } - } - } - ] - } - ] +{ + "MetaData": { + "Create": "2023-11-29", + "Discription": "A json file effect", + "ChannelNumber": 1, + "Version": 1.0 + }, + "Channels": [ + { + "Parameters": { + "Index": 0 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "Duration": 0, + "StartTime": 42, + "Parameters": { + "Intensity": 80, + "Frequency": 50 + } + } + }, + { + "Event": { + "Type": "continuous", + "Duration": 1277, + "StartTime": 66, + "Parameters": { + "Intensity": 26, + "Frequency": 50, + "Curve": [ + { + "Time": 0, + "Intensity": 0, + "Frequency": 0 + }, + { + "Time": 9, + "Intensity": 1, + "Frequency": 63 + }, + { + "Time": 650, + "Intensity": 0.44509804248809814, + "Frequency": 93 + }, + { + "Time": 1277, + "Intensity": 0, + "Frequency": 100 + } + ] + } + } + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/ohosTest/module.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/ohosTest/module.json5 index 741bfbf578..22e2c611f3 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "visible": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/hvigor/hvigor-config.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/hvigor/hvigor-config.json5 index ac737cf85f..e75281b258 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/hvigor/hvigor-config.json5 @@ -1,6 +1,6 @@ -{ - "hvigorVersion": "3.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.2" - } +{ + "hvigorVersion": "3.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.2" + } } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/oh-package.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/oh-package.json5 index 04a043b233..f39b6b66fc 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/oh-package.json5 +++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "ISC", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "name": "Haptic Sample", - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "ISC", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "name": "Haptic Sample", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/.gitignore b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/.gitignore new file mode 100644 index 0000000000..fbabf77101 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/.gitignore @@ -0,0 +1,11 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/app.json5 b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/app.json5 new file mode 100644 index 0000000000..5470c22e22 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/resources/base/element/string.json b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..1080233f01 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + } + ] +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/resources/base/media/app_icon.png b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD_{QVu$(&K6H|C37TG1Am9Re{<<3gd zh@`>;BqkXMW&p0T6rt|iB$)~CvFe(XC)F9WgAZn*0@t$oZo;!*}r@_`h?KKH&6A@3= zISXoQB+~`op>NP-buiA*^0n{@i{_?MRG)&k)c)k_F+-2Lud!S9pc+i`s74NpBCaGF zXN+pHkubw*msGBTY27BKHv)RRh3;nMg4&$fD_6X9Vt~;_4D+5XPH~#Kn-yjcy!$}1 zigv#FNY>TqMhtIBb@UoF!cE~Q8~;!Pek>SQQwHnHuWKoVBosAiOr}q>!>aE*Krc)V zBUMEcJ5NU0g8}-h6i1zpMY9>m4ne?=U2~`w7K7Q0gB_=p@$5K7p6}thw z-~3dMj?YNX2X$lZ+7ngQ$=s}3mizNN@kE%OtB)?c&i~2L55z8^=yz;xMHLmlY>&Q# zJj?!)M#q_SyfkQh)k?j8IfLtB)ZCp|*vf4_B zos?73yd^h-Ac+;?E4*bpf=o*^3x3-`TVjbY4n6!EN10K6o@fxdyps05Vo3PU)otB} z`3kR+2w7_C#8Z!q`J)p{Vh!+m9-UP!$STp+Hb}}#@#_u^SsUQg<}59< zTvH3%XS4G+6FF^(m6bVF&nSUIXcl;nw{=H$%fgeJ>CgDYiLdpDXr{;-AnG z8dvcrHYVMI&`R6;GWekI@Ir3!uo)oz4^{6q0m^}@f2tM9&=YHNi6-?rh0-{+k@cQm zdp`g#YdQn%MDVg2GR>wZ`n2<0l4)9nx1Wfr&!Dvz=bPwU!h2S?ez6MVc5APE4-xLB zi&W9Q8k2@0w!C53g?iAIQ}~p*3O(@zja6KQ=M3zfW*_6o5SwR-)6VBh~m7{^-=MC-owYH5-u40a}a0liho3QZZ5L{bS_xM1)4}19)zTU$$MY zq3eZML1WC{K%YFd`Be0M-rkO^l?h{kM{$2oK1*A@HVJ57*yhDkUF!2WZ&oA4Y-sK( zCY69%#`mBCi6>6uw(x4gbFaP0+FD*JKJ-q!F1E?vLJ+d35!I5d7@^eU?(CS|C^tmI5?lv@s{{*|1F zFg|OzNpZ0hxljdjaW%45O0MOttRrd(Z?h{HYbB-KFUx&9GfFL3b8NwZ$zNu)WbBD` zYkj$^UB5%3Pj1MDr>S2Ejr9pUcgA!;ZG!@{uAy12)vG=*^9-|dNQBc8&`oxBlU~#y zs!anJX&T?57Jdr^sb>e+V`MVfY>Y0ESg7MG<7W0g&bR-ZYzzZ%2H&Etcp zcd6QeXO1D!5A#zM0lx*GH}`M)2~ZFLE;sP^RSB5wVMNfiZXPd(cmO>j=OSA3`o5r& zna(|^jGXbdN7PK)U8b7^zYtYkkeb%<%F~=OqB~kXMQkq}ii|skh@WSRt>5za;cjP0 zZ~nD%6)wzedqE}BMLt~qKwlvTr33))#uP~xyw#*Eaa|DbMQ_%mG0U8numf8)0DX`r zRoG2bM;#g|p-8gWnwRV5SCW0tLjLO&9Z?K>FImeIxlGUgo0Zk`9Qzhj1eco~7XZy+hXc@YF&ZQ=? zn*^1O56yK^x{y}q`j7}blGCx%dydV!c7)g~tJzmHhV=W~jbWRRR{1<^oDK+1clprm zz$eCy7y9+?{E|YgkW~}}iB#I4XoJ*xr8R?i_Hv$=Cof5bo-Nj~f`-DLebH}&0% zfQj9@WGd4;N~Y?mzQsHJTJq6!Qzl^-vwol(+fMt#Pl=Wh#lI5Vmu@QM0=_r+1wHt` z+8WZ~c2}KQQ+q)~2Ki77QvV&`xb|xVcTms99&cD$Zz4+-^R4kvUBxG8gDk7Y`K*)JZ^2rL(+ZWV~%W(@6 z)0bPArG#BROa_PHs~&WplQ_UIrpd)1N1QGPfv!J(Z9jNT#i%H?CE6|pPZb9hJ1JW4 z^q;ft#!HRNV0YgPojzIYT`8LuET2rUe-J|c!9l4`^*;4WtY@Ew@pL>wkjmMgGfN7 ze}}GtmU0@<_#08~I-Suk=^*9GLW=H4xhsml;vAV{%hy5Eegl@!6qKqbG024%n2HHw zCc@ivW_$@5ZoHP70(7D+(`PvgjW1Pd`wsiuv-aCukMrafwDm)B!xXVy*j2opohhoU zcJz%ADmj>i3`-3-$7nQKBQQuGY;2Qt&+(L~C>vSGFj5{Mlv?T_^dql;{zkpe4R1}R z%XfZyQ}wr*sr>jrKgm*PWLjuVc%6&&`Kbf1SuFpHPN&>W)$GmqC;pIoBC`=4-hPY8 zT*>%I2fP}vGW;R=^!1be?ta2UQd2>alOFFbVl;(SQJ4Jk#)4Z0^wpWEVvY4=vyDk@ zqlModi@iVPMC+{?rm=4(n+<;|lmUO@UKYA>EPTS~AndtK^Wy^%#3<;(dQdk3WaUkRtzSMC9}7x2||CNpF#(3T4C)@ z$~RWs`BNABKX|{cmBt>Q=&gkXl&x!!NK_%5hW0LS)Z4PB>%sV?F-{Wyj#s7W%$F{D zXdK^Fp3wvy+48+GP6F_|^PCRx=ddcTO3sG;B23A49~Qaw31SZ0Rc~`r4qqt%#OGW{ zCA_(LG5^N>yzUn&kAgVmxb=EA8s&tBXC}S1CZ(KoW)(%^JjLTPo^fs`Va;`=YlVPgmB$!yB}<(4ym6OeZ3xAJJ#;)2+B%p3P1Wt+d$eo`vz`T zXfUP2))kBDPoscH;Jc7I3NU<({|@wM$&GaDt`n7WLgIY3IA7A6-_R?z8N3mz|}*i z(zl5ot--Oq@f2-nv{X(ujT2T(k1vY_qh93pK@>H-qc%2Xta)IP0Q%zt%bqYgI`o!wv!0QerB`nCN^1n|@$sVOQ!V0teVG!I z_fD%JvfDeT1cK#-{o6Gv7}& zY0#NWin~kVaf$aufV&;63Hbs|`QVZWpDX6IMk1Hj2G}fiH9e-^6u2zf^FIr^BwD<6zjw63+{yUe8PUFvk8v{sJ=R{d#`O!sz`Q13~< zPT$JS(w=yQfU2`zPCNfSw=&zup@DXc(98afjhv@1w_f!m2Z>rMJ19AB&dB%P#Ls3b z=lK7OILM+SQ&VEd=1GN6o&>YVVtIzoZ%=Z_SdqJN2}E43{bE`>w+A;=y->@^k{oCC z$F*WTY&?34;kfyFV?b*Xb1Pq`Z=%OgwEg)Rz)tx=`f%5#w_INP=x&z5!jI;#;N$ma zhO)+MDm;SxOEVL15; zGq(v2pL3&P1Sl)8P*;G-fd{l1QJsv@e@d8)1PK4w2m*M%V3j-V~L^$i|&C@b?D?9tfwE{B^}Z$k8e5FmQ>v7Xz)sG32g9t}YBt zyR$+*_00RmPx+0mW+vVG4mxd(n$(eQf3-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { + 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/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..55bbfb6745 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,379 @@ +import { vibrator } from '@kit.SensorServiceKit'; +import { resourceManager } from '@kit.LocalizationKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +const fileName: string = 'vibrator.json.json'; +let TAG = 'vibrator:' + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + // @State test: Test = new Test() + @State timeout_10: number = 10 + @State timeout_20: number = 20 + @State + private vibratorStatusEvent: vibrator.VibratorStatusEvent = { + timestamp: 0, + deviceId: 0, + vibratorCount: 0, + isVibratorOnline: false + } + @State + private realEffectId: string = '' + @State + private realUsage: vibrator.Usage = 'unknown' + @State + private vibratorInfoContent: string = "" + private effectId: (string)[] = [ + 'haptic.notice.warning', + 'haptic.notice.fail', + 'haptic.notice.success', + 'haptic.effect.soft', + 'haptic.effect.hard', + 'haptic.effect.sharp', + ] + private usage: (string)[] = + ['unknown', 'alarm', 'ring', 'notification', 'communication', 'touch', 'media', 'physicalFeedback', + 'simulateReality'] + private usageMap = new Map([ + ['unknown', 'unknown'], + ['alarm', 'alarm'], + ['ring', 'ring'], + ['notification', 'notification'], + ['communication', 'communication'], + ['touch', 'touch'], + ['media', 'media'], + ['physicalFeedback', 'physicalFeedback'], + ['simulateReality', 'simulateReality'], + ]) + uiContext = this.getUIContext(); + VibratorStateChangeCallback = (data: vibrator.VibratorStatusEvent) => { + this.vibratorStatusEvent = data; + console.log('Vibrator plunged info:', JSON.stringify(data)); + console.log("on is end"); + } + + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + TextInput({ placeholder: 'Please select effectId', text: this.realEffectId }) + .placeholderColor("rgb(0,0,225)") + .placeholderFont({ + size: 20, + weight: 100, + family: 'cursive', + style: FontStyle.Italic + }) + .caretColor(Color.Blue) + .height(50) + .type(InputType.Normal) + .fontSize(20) + .fontWeight(FontWeight.Normal) + .fontFamily("sans-serif") + .fontStyle(FontStyle.Normal) + .fontColor(Color.Black) + .enableKeyboardOnFocus(false) + .textAlign(TextAlign.Center) + .borderStyle(BorderStyle.Solid) + .borderWidth(1) + .borderColor("rgb(0,0,225)") + .borderRadius(10) + .focusable(false) + .onClick(() => { + TextPickerDialog.show({ + range: this.effectId, + selected: 0, + onAccept: (result: TextPickerResult) => { + this.realEffectId = result.value.toString(); + console.info('Succeed in starting vibration' + this.effectId); + }, + onCancel: () => { + console.info('Succeed in starting vibration' + this.effectId); + } + }); + }) + .width('80%') + .margin({ top: 10 }) + + TextInput({ placeholder: 'Please select usage', text: this.realUsage }) + .placeholderColor("rgb(0,0,225)") + .placeholderFont({ + size: 20, + weight: 100, + family: 'cursive', + style: FontStyle.Italic + }) + .caretColor(Color.Blue) + .height(50) + .type(InputType.Normal) + .fontSize(20) + .fontWeight(FontWeight.Normal) + .fontFamily("sans-serif") + .fontStyle(FontStyle.Normal) + .fontColor(Color.Black) + .enableKeyboardOnFocus(false) + .textAlign(TextAlign.Center) + .borderStyle(BorderStyle.Solid) + .borderWidth(1) + .borderColor("rgb(0,0,225)") + .borderRadius(10) + .focusable(false) + .onClick(() => { + TextPickerDialog.show({ + range: this.usage, + selected: 0, + onAccept: (resultUsage: TextPickerResult) => { + this.realUsage = this.usageMap.get(resultUsage.value.toString()); + console.info('Succeed in starting vibration' + this.effectId); + }, + onCancel: () => { + console.info('Succeed in starting vibration' + this.effectId); + } + }); + }) + .width('100%') + .margin({ top: 10 }) + + Row() { + Column() { + Button('file') + .onClick(() => { + let rawFd: resourceManager.RawFileDescriptor | undefined = + this.uiContext.getHostContext()?.resourceManager.getRawFdSync(fileName); + try { + if (rawFd != undefined) { + vibrator.startVibration({ + type: "file", + hapticFd: { fd: rawFd.fd, offset: rawFd.offset, length: rawFd.length } + }, { + id: 1, + deviceId: -1, + usage: this.realUsage + }, (error) => { + if (error) { + console.info(TAG + "error in, msg:" + JSON.stringify(error)); + return; + } + console.info('Succeed in starting vibration'); + }); + } + } catch (e) { + console.info(TAG + "8888Exception:", e) + } + this.uiContext.getHostContext()?.resourceManager.closeRawFdSync(fileName) + }) + + Button('preset:' + this.realEffectId) + .onClick(() => { + try { + // 查询是否支持'haptic.clock.timer' + vibrator.isSupportEffect('haptic.clock.timer', (err: BusinessError, state: boolean) => { + if (err) { + console.error(`Failed to query effect. Code: ${err.code}, message: ${err.message}`); + return; + } + console.info('Succeed in querying effect'); + if (state) { + try { + // 使用startVibration需要添加ohos.permission.VIBRATE权限 + vibrator.startVibration({ + type: 'preset', + effectId: this.realEffectId, + count: 1, + intensity: 100 + }, { + id: 1, + deviceId: -1, + usage: this.realUsage // 根据实际选择类型归属不同的开关管控 + }, (error: BusinessError) => { + if (error) { + console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`); + } else { + console.info('Succeed in starting vibration'); + } + }); + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`); + } + } + }) + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`); + } + }) + + Button('time') + .onClick(() => { + try { + vibrator.startVibration( + { + type: "time", + duration: 2000, + }, { + id: 1, + deviceId: -1, + usage: this.realUsage + }, (error) => { + if (error) { + console.info(TAG + "error in, msg:" + JSON.stringify(error)); + return; + } + console.info('Succeed in starting vibration'); + }); + } catch (e) { + console.info(TAG + "8888Exception:", e) + } + }) + + Button('pattern:addTransientEvent') + .onClick(() => { + let builder = new vibrator.VibratorPatternBuilder(); + try { + let param: vibrator.TransientParam = { + intensity: 80, + frequency: 70, + index: 0 + } + builder.addTransientEvent(0, param); + console.log(`addTransientEvent builder is ${builder.build()}`); + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`); + } + try { + vibrator.startVibration({ + type: "pattern", + pattern: builder.build() + }, { + id: 1, + deviceId: -1, + usage: this.realUsage // 根据实际选择类型归属不同的开关管控 + }, (error) => { + if (error) { + let e: BusinessError = error as BusinessError; + console.error(`Vibrate fail. Code: ${e.code}, message: ${e.message}`); + } else { + console.info(`vibrate success`); + } + }); + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`); + } + }) + + Button('pattern:addContinuousEvent') + .onClick(() => { + let builder = new vibrator.VibratorPatternBuilder(); + try { + let pointsMe: vibrator.VibratorCurvePoint[] = [ + { time: 0, intensity: 0, frequency: -7 }, + { time: 42, intensity: 1, frequency: -6 }, + { time: 128, intensity: 0.94, frequency: -4 }, + { time: 217, intensity: 0.63, frequency: -14 }, + { time: 763, intensity: 0.48, frequency: -14 }, + { time: 1125, intensity: 0.53, frequency: -10 }, + { time: 1503, intensity: 0.42, frequency: -14 }, + { time: 1858, intensity: 0.39, frequency: -14 }, + { time: 2295, intensity: 0.34, frequency: -17 }, + { time: 2448, intensity: 0.21, frequency: -14 }, + { time: 2468, intensity: 0, frequency: -21 } + ] // VibratorCurvePoint参数最少设置4个,最大设置16个 + let param: vibrator.ContinuousParam = { + intensity: 97, + frequency: 34, + points: pointsMe, + index: 0 + } + builder.addContinuousEvent(0, 2468, param); + console.info(`addContinuousEvent builder is ${builder.build()}`); + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`Exception. Code ${e.code}`); + } + try { + vibrator.startVibration({ + type: "pattern", + pattern: builder.build() + }, { + id: 1, + deviceId: -1, + usage: this.realUsage, // 根据实际选择类型归属不同的开关管控 + }, (error) => { + if (error) { + let e: BusinessError = error as BusinessError; + console.error(`Vibrate fail. Code: ${e.code}, message: ${e.message}`); + } else { + console.info(`vibrate success`); + } + }); + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`); + } + }) + + Button('stopVibration') + .onClick(() => { + try { + vibrator.stopVibration({ + deviceId: -1, + vibratorId: 1 + }).then(() => { + console.log('振动停止成功'); + }).catch((error: Error) => { + console.error('振动停止失败:', error.name, error.message); + }); + } catch (error) { + console.error('停止异常:', error.code, error.message); + } + }) + + Button("on") + .onClick(() => { + try { + vibrator.on('vibratorStateChange', this.VibratorStateChangeCallback); + } catch (err) { + console.error("Error in GetVibratorList:", err); + } + }) + + Button("off") + .onClick(() => { + try { + vibrator.off('vibratorStateChange', this.VibratorStateChangeCallback); + } catch (err) { + console.error("Error in GetVibratorList:", err); + } + }) + + Button('getVibratorInfoSync') + .onClick(async () => { + try { + let vibratorInfoList: vibrator.VibratorInfo[] = vibrator.getVibratorInfoSync({ + deviceId: -1, + vibratorId: 1 + }); + this.vibratorInfoContent = JSON.stringify(vibratorInfoList) + } catch (err) { + console.error("Error in GetVibratorList:", err); + } + console.log("getVibratorInfoSync end"); + }) + + Text(`${this.VibratorStateChangeCallback}`) + .fontSize(20) + .margin({ top: 20 }) + + Text(`${this.vibratorInfoContent}`) + .fontSize(20) + .margin({ top: 20 }) + } + .width('100%') + } + .height('100%') + } + } +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/module.json5 b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/module.json5 new file mode 100644 index 0000000000..3e0fd3cee3 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/module.json5 @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/base/element/color.json b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/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/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/base/element/string.json b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..f94595515a --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/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": "label" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/base/media/icon.png b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD_{QVu$(&K6H|C37TG1Am9Re{<<3gd zh@`>;BqkXMW&p0T6rt|iB$)~CvFe(XC)F9WgAZn*0@t$oZo;!*}r@_`h?KKH&6A@3= zISXoQB+~`op>NP-buiA*^0n{@i{_?MRG)&k)c)k_F+-2Lud!S9pc+i`s74NpBCaGF zXN+pHkubw*msGBTY27BKHv)RRh3;nMg4&$fD_6X9Vt~;_4D+5XPH~#Kn-yjcy!$}1 zigv#FNY>TqMhtIBb@UoF!cE~Q8~;!Pek>SQQwHnHuWKoVBosAiOr}q>!>aE*Krc)V zBUMEcJ5NU0g8}-h6i1zpMY9>m4ne?=U2~`w7K7Q0gB_=p@$5K7p6}thw z-~3dMj?YNX2X$lZ+7ngQ$=s}3mizNN@kE%OtB)?c&i~2L55z8^=yz;xMHLmlY>&Q# zJj?!)M#q_SyfkQh)k?j8IfLtB)ZCp|*vf4_B zos?73yd^h-Ac+;?E4*bpf=o*^3x3-`TVjbY4n6!EN10K6o@fxdyps05Vo3PU)otB} z`3kR+2w7_C#8Z!q`J)p{Vh!+m9-UP!$STp+Hb}}#@#_u^SsUQg<}59< zTvH3%XS4G+6FF^(m6bVF&nSUIXcl;nw{=H$%fgeJ>CgDYiLdpDXr{;-AnG z8dvcrHYVMI&`R6;GWekI@Ir3!uo)oz4^{6q0m^}@f2tM9&=YHNi6-?rh0-{+k@cQm zdp`g#YdQn%MDVg2GR>wZ`n2<0l4)9nx1Wfr&!Dvz=bPwU!h2S?ez6MVc5APE4-xLB zi&W9Q8k2@0w!C53g?iAIQ}~p*3O(@zja6KQ=M3zfW*_6o5SwR-)6VBh~m7{^-=MC-owYH5-u40a}a0liho3QZZ5L{bS_xM1)4}19)zTU$$MY zq3eZML1WC{K%YFd`Be0M-rkO^l?h{kM{$2oK1*A@HVJ57*yhDkUF!2WZ&oA4Y-sK( zCY69%#`mBCi6>6uw(x4gbFaP0+FD*JKJ-q!F1E?vLJ+d35!I5d7@^eU?(CS|C^tmI5?lv@s{{*|1F zFg|OzNpZ0hxljdjaW%45O0MOttRrd(Z?h{HYbB-KFUx&9GfFL3b8NwZ$zNu)WbBD` zYkj$^UB5%3Pj1MDr>S2Ejr9pUcgA!;ZG!@{uAy12)vG=*^9-|dNQBc8&`oxBlU~#y zs!anJX&T?57Jdr^sb>e+V`MVfY>Y0ESg7MG<7W0g&bR-ZYzzZ%2H&Etcp zcd6QeXO1D!5A#zM0lx*GH}`M)2~ZFLE;sP^RSB5wVMNfiZXPd(cmO>j=OSA3`o5r& zna(|^jGXbdN7PK)U8b7^zYtYkkeb%<%F~=OqB~kXMQkq}ii|skh@WSRt>5za;cjP0 zZ~nD%6)wzedqE}BMLt~qKwlvTr33))#uP~xyw#*Eaa|DbMQ_%mG0U8numf8)0DX`r zRoG2bM;#g|p-8gWnwRV5SCW0tLjLO&9Z?K>FImeIxlGUgo0Zk`9Qzhj1eco~7XZy+hXc@YF&ZQ=? zn*^1O56yK^x{y}q`j7}blGCx%dydV!c7)g~tJzmHhV=W~jbWRRR{1<^oDK+1clprm zz$eCy7y9+?{E|YgkW~}}iB#I4XoJ*xr8R?i_Hv$=Cof5bo-Nj~f`-DLebH}&0% zfQj9@WGd4;N~Y?mzQsHJTJq6!Qzl^-vwol(+fMt#Pl=Wh#lI5Vmu@QM0=_r+1wHt` z+8WZ~c2}KQQ+q)~2Ki77QvV&`xb|xVcTms99&cD$Zz4+-^R4kvUBxG8gDk7Y`K*)JZ^2rL(+ZWV~%W(@6 z)0bPArG#BROa_PHs~&WplQ_UIrpd)1N1QGPfv!J(Z9jNT#i%H?CE6|pPZb9hJ1JW4 z^q;ft#!HRNV0YgPojzIYT`8LuET2rUe-J|c!9l4`^*;4WtY@Ew@pL>wkjmMgGfN7 ze}}GtmU0@<_#08~I-Suk=^*9GLW=H4xhsml;vAV{%hy5Eegl@!6qKqbG024%n2HHw zCc@ivW_$@5ZoHP70(7D+(`PvgjW1Pd`wsiuv-aCukMrafwDm)B!xXVy*j2opohhoU zcJz%ADmj>i3`-3-$7nQKBQQuGY;2Qt&+(L~C>vSGFj5{Mlv?T_^dql;{zkpe4R1}R z%XfZyQ}wr*sr>jrKgm*PWLjuVc%6&&`Kbf1SuFpHPN&>W)$GmqC;pIoBC`=4-hPY8 zT*>%I2fP}vGW;R=^!1be?ta2UQd2>alOFFbVl;(SQJ4Jk#)4Z0^wpWEVvY4=vyDk@ zqlModi@iVPMC+{?rm=4(n+<;|lmUO@UKYA>EPTS~AndtK^Wy^%#3<;(dQdk3WaUkRtzSMC9}7x2||CNpF#(3T4C)@ z$~RWs`BNABKX|{cmBt>Q=&gkXl&x!!NK_%5hW0LS)Z4PB>%sV?F-{Wyj#s7W%$F{D zXdK^Fp3wvy+48+GP6F_|^PCRx=ddcTO3sG;B23A49~Qaw31SZ0Rc~`r4qqt%#OGW{ zCA_(LG5^N>yzUn&kAgVmxb=EA8s&tBXC}S1CZ(KoW)(%^JjLTPo^fs`Va;`=YlVPgmB$!yB}<(4ym6OeZ3xAJJ#;)2+B%p3P1Wt+d$eo`vz`T zXfUP2))kBDPoscH;Jc7I3NU<({|@wM$&GaDt`n7WLgIY3IA7A6-_R?z8N3mz|}*i z(zl5ot--Oq@f2-nv{X(ujT2T(k1vY_qh93pK@>H-qc%2Xta)IP0Q%zt%bqYgI`o!wv!0QerB`nCN^1n|@$sVOQ!V0teVG!I z_fD%JvfDeT1cK#-{o6Gv7}& zY0#NWin~kVaf$aufV&;63Hbs|`QVZWpDX6IMk1Hj2G}fiH9e-^6u2zf^FIr^BwD<6zjw63+{yUe8PUFvk8v{sJ=R{d#`O!sz`Q13~< zPT$JS(w=yQfU2`zPCNfSw=&zup@DXc(98afjhv@1w_f!m2Z>rMJ19AB&dB%P#Ls3b z=lK7OILM+SQ&VEd=1GN6o&>YVVtIzoZ%=Z_SdqJN2}E43{bE`>w+A;=y->@^k{oCC z$F*WTY&?34;kfyFV?b*Xb1Pq`Z=%OgwEg)Rz)tx=`f%5#w_INP=x&z5!jI;#;N$ma zhO)+MDm;SxOEVL15; zGq(v2pL3&P1Sl)8P*;G-fd{l1QJsv@e@d8)1PK4w2m*M%V3j-V~L^$i|&C@b?D?9tfwE{B^}Z$k8e5FmQ>v7Xz)sG32g9t}YBt zyR$+*_00RmPx+0mW+vVG4mxd(n$(eQf3-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { + 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() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000000..166366593a --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,34 @@ +import hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000..92a16d84e8 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,49 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/module.json5 b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c031340ae7 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/module.json5 @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/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/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000000..65d8fa5a7c --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/media/icon.png b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD_{QVu$(&K6H|C37TG1Am9Re{<<3gd zh@`>;BqkXMW&p0T6rt|iB$)~CvFe(XC)F9WgAZn*0@t$oZo;!*}r@_`h?KKH&6A@3= zISXoQB+~`op>NP-buiA*^0n{@i{_?MRG)&k)c)k_F+-2Lud!S9pc+i`s74NpBCaGF zXN+pHkubw*msGBTY27BKHv)RRh3;nMg4&$fD_6X9Vt~;_4D+5XPH~#Kn-yjcy!$}1 zigv#FNY>TqMhtIBb@UoF!cE~Q8~;!Pek>SQQwHnHuWKoVBosAiOr}q>!>aE*Krc)V zBUMEcJ5NU0g8}-h6i1zpMY9>m4ne?=U2~`w7K7Q0gB_=p@$5K7p6}thw z-~3dMj?YNX2X$lZ+7ngQ$=s}3mizNN@kE%OtB)?c&i~2L55z8^=yz;xMHLmlY>&Q# zJj?!)M#q_SyfkQh)k?j8IfLtB)ZCp|*vf4_B zos?73yd^h-Ac+;?E4*bpf=o*^3x3-`TVjbY4n6!EN10K6o@fxdyps05Vo3PU)otB} z`3kR+2w7_C#8Z!q`J)p{Vh!+m9-UP!$STp+Hb}}#@#_u^SsUQg<}59< zTvH3%XS4G+6FF^(m6bVF&nSUIXcl;nw{=H$%fgeJ>CgDYiLdpDXr{;-AnG z8dvcrHYVMI&`R6;GWekI@Ir3!uo)oz4^{6q0m^}@f2tM9&=YHNi6-?rh0-{+k@cQm zdp`g#YdQn%MDVg2GR>wZ`n2<0l4)9nx1Wfr&!Dvz=bPwU!h2S?ez6MVc5APE4-xLB zi&W9Q8k2@0w!C53g?iAIQ}~p*3O(@zja6KQ=M3zfW*_6o5SwR-)6VBh~m7{^-=MC-owYH5-u40a}a0liho3QZZ5L{bS_xM1)4}19)zTU$$MY zq3eZML1WC{K%YFd`Be0M-rkO^l?h{kM{$2oK1*A@HVJ57*yhDkUF!2WZ&oA4Y-sK( zCY69%#`mBCi6>6uw(x4gbFaP0+FD*JKJ-q!F1E?vLJ+d35!I5d7@^eU?(CS|C^tmI5?lv@s{{*|1F zFg|OzNpZ0hxljdjaW%45O0MOttRrd(Z?h{HYbB-KFUx&9GfFL3b8NwZ$zNu)WbBD` zYkj$^UB5%3Pj1MDr>S2Ejr9pUcgA!;ZG!@{uAy12)vG=*^9-|dNQBc8&`oxBlU~#y zs!anJX&T?57Jdr^sb>e+V`MVfY>Y0ESg7MG<7W0g&bR-ZYzzZ%2H&Etcp zcd6QeXO1D!5A#zM0lx*GH}`M)2~ZFLE;sP^RSB5wVMNfiZXPd(cmO>j=OSA3`o5r& zna(|^jGXbdN7PK)U8b7^zYtYkkeb%<%F~=OqB~kXMQkq}ii|skh@WSRt>5za;cjP0 zZ~nD%6)wzedqE}BMLt~qKwlvTr33))#uP~xyw#*Eaa|DbMQ_%mG0U8numf8)0DX`r zRoG2bM;#g|p-8gWnwRV5SCW0tLjLO&9Z?K>FImeIxlGUgo0Zk`9Qzhj1eco~7XZy+hXc@YF&ZQ=? zn*^1O56yK^x{y}q`j7}blGCx%dydV!c7)g~tJzmHhV=W~jbWRRR{1<^oDK+1clprm zz$eCy7y9+?{E|YgkW~}}iB#I4XoJ*xr8R?i_Hv$=Cof5bo-Nj~f`-DLebH}&0% zfQj9@WGd4;N~Y?mzQsHJTJq6!Qzl^-vwol(+fMt#Pl=Wh#lI5Vmu@QM0=_r+1wHt` z+8WZ~c2}KQQ+q)~2Ki77QvV&`xb|xVcTms99&cD$Zz4+-^R4kvUBxG8gDk7Y`K*)JZ^2rL(+ZWV~%W(@6 z)0bPArG#BROa_PHs~&WplQ_UIrpd)1N1QGPfv!J(Z9jNT#i%H?CE6|pPZb9hJ1JW4 z^q;ft#!HRNV0YgPojzIYT`8LuET2rUe-J|c!9l4`^*;4WtY@Ew@pL>wkjmMgGfN7 ze}}GtmU0@<_#08~I-Suk=^*9GLW=H4xhsml;vAV{%hy5Eegl@!6qKqbG024%n2HHw zCc@ivW_$@5ZoHP70(7D+(`PvgjW1Pd`wsiuv-aCukMrafwDm)B!xXVy*j2opohhoU zcJz%ADmj>i3`-3-$7nQKBQQuGY;2Qt&+(L~C>vSGFj5{Mlv?T_^dql;{zkpe4R1}R z%XfZyQ}wr*sr>jrKgm*PWLjuVc%6&&`Kbf1SuFpHPN&>W)$GmqC;pIoBC`=4-hPY8 zT*>%I2fP}vGW;R=^!1be?ta2UQd2>alOFFbVl;(SQJ4Jk#)4Z0^wpWEVvY4=vyDk@ zqlModi@iVPMC+{?rm=4(n+<;|lmUO@UKYA>EPTS~AndtK^Wy^%#3<;(dQdk3WaUkRtzSMC9}7x2||CNpF#(3T4C)@ z$~RWs`BNABKX|{cmBt>Q=&gkXl&x!!NK_%5hW0LS)Z4PB>%sV?F-{Wyj#s7W%$F{D zXdK^Fp3wvy+48+GP6F_|^PCRx=ddcTO3sG;B23A49~Qaw31SZ0Rc~`r4qqt%#OGW{ zCA_(LG5^N>yzUn&kAgVmxb=EA8s&tBXC}S1CZ(KoW)(%^JjLTPo^fs`Va;`=YlVPgmB$!yB}<(4ym6OeZ3xAJJ#;)2+B%p3P1Wt+d$eo`vz`T zXfUP2))kBDPoscH;Jc7I3NU<({|@wM$&GaDt`n7WLgIY3IA7A6-_R?z8N3mz|}*i z(zl5ot--Oq@f2-nv{X(ujT2T(k1vY_qh93pK@>H-qc%2Xta)IP0Q%zt%bqYgI`o!wv!0QerB`nCN^1n|@$sVOQ!V0teVG!I z_fD%JvfDeT1cK#-{o6Gv7}& zY0#NWin~kVaf$aufV&;63Hbs|`QVZWpDX6IMk1Hj2G}fiH9e-^6u2zf^FIr^BwD<6zjw63+{yUe8PUFvk8v{sJ=R{d#`O!sz`Q13~< zPT$JS(w=yQfU2`zPCNfSw=&zup@DXc(98afjhv@1w_f!m2Z>rMJ19AB&dB%P#Ls3b z=lK7OILM+SQ&VEd=1GN6o&>YVVtIzoZ%=Z_SdqJN2}E43{bE`>w+A;=y->@^k{oCC z$F*WTY&?34;kfyFV?b*Xb1Pq`Z=%OgwEg)Rz)tx=`f%5#w_INP=x&z5!jI;#;N$ma zhO)+MDm;SxOEVL15; zGq(v2pL3&P1Sl)8P*;G-fd{l1QJsv@e@d8)1PK4w2m*M%V3j-V~L^$i|&C@b?D?9tfwE{B^}Z$k8e5FmQ>v7Xz)sG32g9t}YBt zyR$+*_00RmPx+0mW+vVG4mxd(n$(eQf3-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y="a"&&e<="z"||e>="A"&&e<="Z"||"$"===e||"_"===e||te.Unicode.ID_Start.test(e))}static isIdContinueChar(e){return"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"$"===e||"_"===e||"‌"===e||"‍"===e||te.Unicode.ID_Continue.test(e))}static isDigitWithoutZero(e){return/[1-9]/.test(e)}static isDigit(e){return"string"==typeof e&&/[0-9]/.test(e)}static isHexDigit(e){return"string"==typeof e&&/[0-9A-Fa-f]/.test(e)}};var ne={},re={fromCallback:function(e){return Object.defineProperty((function(...t){if("function"!=typeof t[t.length-1])return new Promise(((n,r)=>{e.call(this,...t,((e,t)=>null!=e?r(e):n(t)))}));e.apply(this,t)}),"name",{value:e.name})},fromPromise:function(e){return Object.defineProperty((function(...t){const n=t[t.length-1];if("function"!=typeof n)return e.apply(this,t);e.apply(this,t.slice(0,-1)).then((e=>n(null,e)),n)}),"name",{value:e.name})}},ue=y.default,oe=process.cwd,ie=null,se=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ie||(ie=oe.call(process)),ie};try{process.cwd()}catch(e){}if("function"==typeof process.chdir){var ce=process.chdir;process.chdir=function(e){ie=null,ce.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ce)}var ae=function(e){ue.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(e){e.lchmod=function(t,n,r){e.open(t,ue.O_WRONLY|ue.O_SYMLINK,n,(function(t,u){t?r&&r(t):e.fchmod(u,n,(function(t){e.close(u,(function(e){r&&r(t||e)}))}))}))},e.lchmodSync=function(t,n){var r,u=e.openSync(t,ue.O_WRONLY|ue.O_SYMLINK,n),o=!0;try{r=e.fchmodSync(u,n),o=!1}finally{if(o)try{e.closeSync(u)}catch(e){}else e.closeSync(u)}return r}}(e);e.lutimes||function(e){ue.hasOwnProperty("O_SYMLINK")&&e.futimes?(e.lutimes=function(t,n,r,u){e.open(t,ue.O_SYMLINK,(function(t,o){t?u&&u(t):e.futimes(o,n,r,(function(t){e.close(o,(function(e){u&&u(t||e)}))}))}))},e.lutimesSync=function(t,n,r){var u,o=e.openSync(t,ue.O_SYMLINK),i=!0;try{u=e.futimesSync(o,n,r),i=!1}finally{if(i)try{e.closeSync(o)}catch(e){}else e.closeSync(o)}return u}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}(e);e.chown=r(e.chown),e.fchown=r(e.fchown),e.lchown=r(e.lchown),e.chmod=t(e.chmod),e.fchmod=t(e.fchmod),e.lchmod=t(e.lchmod),e.chownSync=u(e.chownSync),e.fchownSync=u(e.fchownSync),e.lchownSync=u(e.lchownSync),e.chmodSync=n(e.chmodSync),e.fchmodSync=n(e.fchmodSync),e.lchmodSync=n(e.lchmodSync),e.stat=o(e.stat),e.fstat=o(e.fstat),e.lstat=o(e.lstat),e.statSync=i(e.statSync),e.fstatSync=i(e.fstatSync),e.lstatSync=i(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){});e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){});"win32"===se&&(e.rename="function"!=typeof e.rename?e.rename:function(t){function n(n,r,u){var o=Date.now(),i=0;t(n,r,(function s(c){if(c&&("EACCES"===c.code||"EPERM"===c.code||"EBUSY"===c.code)&&Date.now()-o<6e4)return setTimeout((function(){e.stat(r,(function(e,o){e&&"ENOENT"===e.code?t(n,r,s):u(c)}))}),i),void(i<100&&(i+=10));u&&u(c)}))}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.rename));function t(t){return t?function(n,r,u){return t.call(e,n,r,(function(e){s(e)&&(e=null),u&&u.apply(this,arguments)}))}:t}function n(t){return t?function(n,r){try{return t.call(e,n,r)}catch(e){if(!s(e))throw e}}:t}function r(t){return t?function(n,r,u,o){return t.call(e,n,r,u,(function(e){s(e)&&(e=null),o&&o.apply(this,arguments)}))}:t}function u(t){return t?function(n,r,u){try{return t.call(e,n,r,u)}catch(e){if(!s(e))throw e}}:t}function o(t){return t?function(n,r,u){function o(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),u&&u.apply(this,arguments)}return"function"==typeof r&&(u=r,r=null),r?t.call(e,n,r,o):t.call(e,n,o)}:t}function i(t){return t?function(n,r){var u=r?t.call(e,n,r):t.call(e,n);return u&&(u.uid<0&&(u.uid+=4294967296),u.gid<0&&(u.gid+=4294967296)),u}:t}function s(e){return!e||("ENOSYS"===e.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==e.code&&"EPERM"!==e.code))}e.read="function"!=typeof e.read?e.read:function(t){function n(n,r,u,o,i,s){var c;if(s&&"function"==typeof s){var a=0;c=function(l,f,d){if(l&&"EAGAIN"===l.code&&a<10)return a++,t.call(e,n,r,u,o,i,c);s.apply(this,arguments)}}return t.call(e,n,r,u,o,i,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.read),e.readSync="function"!=typeof e.readSync?e.readSync:(c=e.readSync,function(t,n,r,u,o){for(var i=0;;)try{return c.call(e,t,n,r,u,o)}catch(e){if("EAGAIN"===e.code&&i<10){i++;continue}throw e}});var c};var le=C.default.Stream,fe=function(e){return{ReadStream:function t(n,r){if(!(this instanceof t))return new t(n,r);le.call(this);var u=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var o=Object.keys(r),i=0,s=o.length;ithis.end)throw new Error("start must be <= end");this.pos=this.start}if(null!==this.fd)return void process.nextTick((function(){u._read()}));e.open(this.path,this.flags,this.mode,(function(e,t){if(e)return u.emit("error",e),void(u.readable=!1);u.fd=t,u.emit("open",t),u._read()}))},WriteStream:function t(n,r){if(!(this instanceof t))return new t(n,r);le.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var u=Object.keys(r),o=0,i=u.length;o= zero");this.pos=this.start}this.busy=!1,this._queue=[],null===this.fd&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}};var de=function(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Object)var t={__proto__:De(e)};else t=Object.create(null);return Object.getOwnPropertyNames(e).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})),t},De=Object.getPrototypeOf||function(e){return e.__proto__};var pe,Ee,me=D.default,he=ae,ye=fe,Ce=de,Fe=F.default;function ge(e,t){Object.defineProperty(e,pe,{get:function(){return t}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(pe=Symbol.for("graceful-fs.queue"),Ee=Symbol.for("graceful-fs.previous")):(pe="___graceful-fs.queue",Ee="___graceful-fs.previous");var Ae=function(){};if(Fe.debuglog?Ae=Fe.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Ae=function(){var e=Fe.format.apply(Fe,arguments);e="GFS4: "+e.split(/\n/).join("\nGFS4: "),console.error(e)}),!me[pe]){var ve=w[pe]||[];ge(me,ve),me.close=function(e){function t(t,n){return e.call(me,t,(function(e){e||_e(),"function"==typeof n&&n.apply(this,arguments)}))}return Object.defineProperty(t,Ee,{value:e}),t}(me.close),me.closeSync=function(e){function t(t){e.apply(me,arguments),_e()}return Object.defineProperty(t,Ee,{value:e}),t}(me.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",(function(){Ae(me[pe]),g.default.equal(me[pe].length,0)}))}w[pe]||ge(w,me[pe]);var Se,we=Oe(Ce(me));function Oe(e){he(e),e.gracefulify=Oe,e.createReadStream=function(t,n){return new e.ReadStream(t,n)},e.createWriteStream=function(t,n){return new e.WriteStream(t,n)};var t=e.readFile;e.readFile=function(e,n,r){"function"==typeof n&&(r=n,n=null);return function e(n,r,u,o){return t(n,r,(function(t){!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?"function"==typeof u&&u.apply(this,arguments):be([e,[n,r,u],t,o||Date.now(),Date.now()])}))}(e,n,r)};var n=e.writeFile;e.writeFile=function(e,t,r,u){"function"==typeof r&&(u=r,r=null);return function e(t,r,u,o,i){return n(t,r,u,(function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,r,u,o],n,i||Date.now(),Date.now()])}))}(e,t,r,u)};var r=e.appendFile;r&&(e.appendFile=function(e,t,n,u){"function"==typeof n&&(u=n,n=null);return function e(t,n,u,o,i){return r(t,n,u,(function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,n,u,o],r,i||Date.now(),Date.now()])}))}(e,t,n,u)});var u=e.copyFile;u&&(e.copyFile=function(e,t,n,r){"function"==typeof n&&(r=n,n=0);return function e(t,n,r,o,i){return u(t,n,r,(function(u){!u||"EMFILE"!==u.code&&"ENFILE"!==u.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,n,r,o],u,i||Date.now(),Date.now()])}))}(e,t,n,r)});var o=e.readdir;e.readdir=function(e,t,n){"function"==typeof t&&(n=t,t=null);var r=i.test(process.version)?function(e,t,n,r){return o(e,u(e,t,n,r))}:function(e,t,n,r){return o(e,t,u(e,t,n,r))};return r(e,t,n);function u(e,t,n,u){return function(o,i){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?(i&&i.sort&&i.sort(),"function"==typeof n&&n.call(this,o,i)):be([r,[e,t,n],o,u||Date.now(),Date.now()])}}};var i=/^v[0-5]\./;if("v0.8"===process.version.substr(0,4)){var s=ye(e);d=s.ReadStream,D=s.WriteStream}var c=e.ReadStream;c&&(d.prototype=Object.create(c.prototype),d.prototype.open=function(){var e=this;E(e.path,e.flags,e.mode,(function(t,n){t?(e.autoClose&&e.destroy(),e.emit("error",t)):(e.fd=n,e.emit("open",n),e.read())}))});var a=e.WriteStream;a&&(D.prototype=Object.create(a.prototype),D.prototype.open=function(){var e=this;E(e.path,e.flags,e.mode,(function(t,n){t?(e.destroy(),e.emit("error",t)):(e.fd=n,e.emit("open",n))}))}),Object.defineProperty(e,"ReadStream",{get:function(){return d},set:function(e){d=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return D},set:function(e){D=e},enumerable:!0,configurable:!0});var l=d;Object.defineProperty(e,"FileReadStream",{get:function(){return l},set:function(e){l=e},enumerable:!0,configurable:!0});var f=D;function d(e,t){return this instanceof d?(c.apply(this,arguments),this):d.apply(Object.create(d.prototype),arguments)}function D(e,t){return this instanceof D?(a.apply(this,arguments),this):D.apply(Object.create(D.prototype),arguments)}Object.defineProperty(e,"FileWriteStream",{get:function(){return f},set:function(e){f=e},enumerable:!0,configurable:!0});var p=e.open;function E(e,t,n,r){return"function"==typeof n&&(r=n,n=null),function e(t,n,r,u,o){return p(t,n,r,(function(i,s){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?"function"==typeof u&&u.apply(this,arguments):be([e,[t,n,r,u],i,o||Date.now(),Date.now()])}))}(e,t,n,r)}return e.open=E,e}function be(e){Ae("ENQUEUE",e[0].name,e[1]),me[pe].push(e),Be()}function _e(){for(var e=Date.now(),t=0;t2&&(me[pe][t][3]=e,me[pe][t][4]=e);Be()}function Be(){if(clearTimeout(Se),Se=void 0,0!==me[pe].length){var e=me[pe].shift(),t=e[0],n=e[1],r=e[2],u=e[3],o=e[4];if(void 0===u)Ae("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-u>=6e4){Ae("TIMEOUT",t.name,n);var i=n.pop();"function"==typeof i&&i.call(null,r)}else{var s=Date.now()-o,c=Math.max(o-u,1);s>=Math.min(1.2*c,100)?(Ae("RETRY",t.name,n),t.apply(null,n.concat([u]))):me[pe].push(e)}void 0===Se&&(Se=setTimeout(Be,0))}}process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!me.__patched&&(we=Oe(me),me.__patched=!0),function(e){const t=re.fromCallback,n=we,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter((e=>"function"==typeof n[e]));Object.assign(e,n),r.forEach((r=>{e[r]=t(n[r])})),e.realpath.native=t(n.realpath.native),e.exists=function(e,t){return"function"==typeof t?n.exists(e,t):new Promise((t=>n.exists(e,t)))},e.read=function(e,t,r,u,o,i){return"function"==typeof i?n.read(e,t,r,u,o,i):new Promise(((i,s)=>{n.read(e,t,r,u,o,((e,t,n)=>{if(e)return s(e);i({bytesRead:t,buffer:n})}))}))},e.write=function(e,t,...r){return"function"==typeof r[r.length-1]?n.write(e,t,...r):new Promise(((u,o)=>{n.write(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffer:n})}))}))},"function"==typeof n.writev&&(e.writev=function(e,t,...r){return"function"==typeof r[r.length-1]?n.writev(e,t,...r):new Promise(((u,o)=>{n.writev(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffers:n})}))}))})}(ne);var Pe={},ke={};const xe=p.default;ke.checkPath=function(e){if("win32"===process.platform){if(/[<>:"|?*]/.test(e.replace(xe.parse(e).root,""))){const t=new Error(`Path contains invalid characters: ${e}`);throw t.code="EINVAL",t}}};const Ne=ne,{checkPath:Ie}=ke,Te=e=>"number"==typeof e?e:{mode:511,...e}.mode;Pe.makeDir=async(e,t)=>(Ie(e),Ne.mkdir(e,{mode:Te(t),recursive:!0})),Pe.makeDirSync=(e,t)=>(Ie(e),Ne.mkdirSync(e,{mode:Te(t),recursive:!0}));const Re=re.fromPromise,{makeDir:Me,makeDirSync:Le}=Pe,je=Re(Me);var $e={mkdirs:je,mkdirsSync:Le,mkdirp:je,mkdirpSync:Le,ensureDir:je,ensureDirSync:Le};const He=re.fromPromise,Je=ne;var Ge={pathExists:He((function(e){return Je.access(e).then((()=>!0)).catch((()=>!1))})),pathExistsSync:Je.existsSync};const Ve=we;var Ue=function(e,t,n,r){Ve.open(e,"r+",((e,u)=>{if(e)return r(e);Ve.futimes(u,t,n,(e=>{Ve.close(u,(t=>{r&&r(e||t)}))}))}))},We=function(e,t,n){const r=Ve.openSync(e,"r+");return Ve.futimesSync(r,t,n),Ve.closeSync(r)};const ze=ne,Ke=p.default,qe=F.default;function Ye(e,t,n){const r=n.dereference?e=>ze.stat(e,{bigint:!0}):e=>ze.lstat(e,{bigint:!0});return Promise.all([r(e),r(t).catch((e=>{if("ENOENT"===e.code)return null;throw e}))]).then((([e,t])=>({srcStat:e,destStat:t})))}function Xe(e,t){return t.ino&&t.dev&&t.ino===e.ino&&t.dev===e.dev}function Ze(e,t){const n=Ke.resolve(e).split(Ke.sep).filter((e=>e)),r=Ke.resolve(t).split(Ke.sep).filter((e=>e));return n.reduce(((e,t,n)=>e&&r[n]===t),!0)}function Qe(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}var et={checkPaths:function(e,t,n,r,u){qe.callbackify(Ye)(e,t,r,((r,o)=>{if(r)return u(r);const{srcStat:i,destStat:s}=o;if(s){if(Xe(i,s)){const r=Ke.basename(e),o=Ke.basename(t);return"move"===n&&r!==o&&r.toLowerCase()===o.toLowerCase()?u(null,{srcStat:i,destStat:s,isChangingCase:!0}):u(new Error("Source and destination must not be the same."))}if(i.isDirectory()&&!s.isDirectory())return u(new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`));if(!i.isDirectory()&&s.isDirectory())return u(new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`))}return i.isDirectory()&&Ze(e,t)?u(new Error(Qe(e,t,n))):u(null,{srcStat:i,destStat:s})}))},checkPathsSync:function(e,t,n,r){const{srcStat:u,destStat:o}=function(e,t,n){let r;const u=n.dereference?e=>ze.statSync(e,{bigint:!0}):e=>ze.lstatSync(e,{bigint:!0}),o=u(e);try{r=u(t)}catch(e){if("ENOENT"===e.code)return{srcStat:o,destStat:null};throw e}return{srcStat:o,destStat:r}}(e,t,r);if(o){if(Xe(u,o)){const r=Ke.basename(e),i=Ke.basename(t);if("move"===n&&r!==i&&r.toLowerCase()===i.toLowerCase())return{srcStat:u,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(u.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!u.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(u.isDirectory()&&Ze(e,t))throw new Error(Qe(e,t,n));return{srcStat:u,destStat:o}},checkParentPaths:function e(t,n,r,u,o){const i=Ke.resolve(Ke.dirname(t)),s=Ke.resolve(Ke.dirname(r));if(s===i||s===Ke.parse(s).root)return o();ze.stat(s,{bigint:!0},((i,c)=>i?"ENOENT"===i.code?o():o(i):Xe(n,c)?o(new Error(Qe(t,r,u))):e(t,n,s,u,o)))},checkParentPathsSync:function e(t,n,r,u){const o=Ke.resolve(Ke.dirname(t)),i=Ke.resolve(Ke.dirname(r));if(i===o||i===Ke.parse(i).root)return;let s;try{s=ze.statSync(i,{bigint:!0})}catch(e){if("ENOENT"===e.code)return;throw e}if(Xe(n,s))throw new Error(Qe(t,r,u));return e(t,n,i,u)},isSrcSubdir:Ze,areIdentical:Xe};const tt=we,nt=p.default,rt=$e.mkdirs,ut=Ge.pathExists,ot=Ue,it=et;function st(e,t,n,r,u){const o=nt.dirname(n);ut(o,((i,s)=>i?u(i):s?at(e,t,n,r,u):void rt(o,(o=>o?u(o):at(e,t,n,r,u)))))}function ct(e,t,n,r,u,o){Promise.resolve(u.filter(n,r)).then((i=>i?e(t,n,r,u,o):o()),(e=>o(e)))}function at(e,t,n,r,u){(r.dereference?tt.stat:tt.lstat)(t,((o,i)=>o?u(o):i.isDirectory()?function(e,t,n,r,u,o){return t?Dt(n,r,u,o):function(e,t,n,r,u){tt.mkdir(n,(o=>{if(o)return u(o);Dt(t,n,r,(t=>t?u(t):dt(n,e,u)))}))}(e.mode,n,r,u,o)}(i,e,t,n,r,u):i.isFile()||i.isCharacterDevice()||i.isBlockDevice()?function(e,t,n,r,u,o){return t?function(e,t,n,r,u){if(!r.overwrite)return r.errorOnExist?u(new Error(`'${n}' already exists`)):u();tt.unlink(n,(o=>o?u(o):lt(e,t,n,r,u)))}(e,n,r,u,o):lt(e,n,r,u,o)}(i,e,t,n,r,u):i.isSymbolicLink()?function(e,t,n,r,u){tt.readlink(t,((t,o)=>t?u(t):(r.dereference&&(o=nt.resolve(process.cwd(),o)),e?void tt.readlink(n,((t,i)=>t?"EINVAL"===t.code||"UNKNOWN"===t.code?tt.symlink(o,n,u):u(t):(r.dereference&&(i=nt.resolve(process.cwd(),i)),it.isSrcSubdir(o,i)?u(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`)):e.isDirectory()&&it.isSrcSubdir(i,o)?u(new Error(`Cannot overwrite '${i}' with '${o}'.`)):function(e,t,n){tt.unlink(t,(r=>r?n(r):tt.symlink(e,t,n)))}(o,n,u)))):tt.symlink(o,n,u))))}(e,t,n,r,u):i.isSocket()?u(new Error(`Cannot copy a socket file: ${t}`)):i.isFIFO()?u(new Error(`Cannot copy a FIFO pipe: ${t}`)):u(new Error(`Unknown file: ${t}`))))}function lt(e,t,n,r,u){tt.copyFile(t,n,(o=>o?u(o):r.preserveTimestamps?function(e,t,n,r){if(function(e){return 0==(128&e)}(e))return function(e,t,n){return dt(e,128|t,n)}(n,e,(u=>u?r(u):ft(e,t,n,r)));return ft(e,t,n,r)}(e.mode,t,n,u):dt(n,e.mode,u)))}function ft(e,t,n,r){!function(e,t,n){tt.stat(e,((e,r)=>e?n(e):ot(t,r.atime,r.mtime,n)))}(t,n,(t=>t?r(t):dt(n,e,r)))}function dt(e,t,n){return tt.chmod(e,t,n)}function Dt(e,t,n,r){tt.readdir(e,((u,o)=>u?r(u):pt(o,e,t,n,r)))}function pt(e,t,n,r,u){const o=e.pop();return o?function(e,t,n,r,u,o){const i=nt.join(n,t),s=nt.join(r,t);it.checkPaths(i,s,"copy",u,((t,c)=>{if(t)return o(t);const{destStat:a}=c;!function(e,t,n,r,u){r.filter?ct(at,e,t,n,r,u):at(e,t,n,r,u)}(a,i,s,u,(t=>t?o(t):pt(e,n,r,u,o)))}))}(e,o,t,n,r,u):u()}var Et=function(e,t,n,r){"function"!=typeof n||r?"function"==typeof n&&(n={filter:n}):(r=n,n={}),r=r||function(){},(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),it.checkPaths(e,t,"copy",n,((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;it.checkParentPaths(e,i,t,"copy",(u=>u?r(u):n.filter?ct(st,s,e,t,n,r):st(s,e,t,n,r)))}))};const mt=we,ht=p.default,yt=$e.mkdirsSync,Ct=We,Ft=et;function gt(e,t,n,r){const u=(r.dereference?mt.statSync:mt.lstatSync)(t);if(u.isDirectory())return function(e,t,n,r,u){return t?St(n,r,u):function(e,t,n,r){return mt.mkdirSync(n),St(t,n,r),vt(n,e)}(e.mode,n,r,u)}(u,e,t,n,r);if(u.isFile()||u.isCharacterDevice()||u.isBlockDevice())return function(e,t,n,r,u){return t?function(e,t,n,r){if(r.overwrite)return mt.unlinkSync(n),At(e,t,n,r);if(r.errorOnExist)throw new Error(`'${n}' already exists`)}(e,n,r,u):At(e,n,r,u)}(u,e,t,n,r);if(u.isSymbolicLink())return function(e,t,n,r){let u=mt.readlinkSync(t);r.dereference&&(u=ht.resolve(process.cwd(),u));if(e){let e;try{e=mt.readlinkSync(n)}catch(e){if("EINVAL"===e.code||"UNKNOWN"===e.code)return mt.symlinkSync(u,n);throw e}if(r.dereference&&(e=ht.resolve(process.cwd(),e)),Ft.isSrcSubdir(u,e))throw new Error(`Cannot copy '${u}' to a subdirectory of itself, '${e}'.`);if(mt.statSync(n).isDirectory()&&Ft.isSrcSubdir(e,u))throw new Error(`Cannot overwrite '${e}' with '${u}'.`);return function(e,t){return mt.unlinkSync(t),mt.symlinkSync(e,t)}(u,n)}return mt.symlinkSync(u,n)}(e,t,n,r);if(u.isSocket())throw new Error(`Cannot copy a socket file: ${t}`);if(u.isFIFO())throw new Error(`Cannot copy a FIFO pipe: ${t}`);throw new Error(`Unknown file: ${t}`)}function At(e,t,n,r){return mt.copyFileSync(t,n),r.preserveTimestamps&&function(e,t,n){(function(e){return 0==(128&e)})(e)&&function(e,t){vt(e,128|t)}(n,e);(function(e,t){const n=mt.statSync(e);Ct(t,n.atime,n.mtime)})(t,n)}(e.mode,t,n),vt(n,e.mode)}function vt(e,t){return mt.chmodSync(e,t)}function St(e,t,n){mt.readdirSync(e).forEach((r=>function(e,t,n,r){const u=ht.join(t,e),o=ht.join(n,e),{destStat:i}=Ft.checkPathsSync(u,o,"copy",r);return function(e,t,n,r){if(!r.filter||r.filter(t,n))return gt(e,t,n,r)}(i,u,o,r)}(r,e,t,n)))}var wt=function(e,t,n){"function"==typeof n&&(n={filter:n}),(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:u}=Ft.checkPathsSync(e,t,"copy",n);return Ft.checkParentPathsSync(e,r,t,"copy"),function(e,t,n,r){if(r.filter&&!r.filter(t,n))return;const u=ht.dirname(n);mt.existsSync(u)||yt(u);return gt(e,t,n,r)}(u,e,t,n)};var Ot={copy:(0,re.fromCallback)(Et),copySync:wt};const bt=we,_t=p.default,Bt=g.default,Pt="win32"===process.platform;function kt(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach((t=>{e[t]=e[t]||bt[t],e[t+="Sync"]=e[t]||bt[t]})),e.maxBusyTries=e.maxBusyTries||3}function xt(e,t,n){let r=0;"function"==typeof t&&(n=t,t={}),Bt(e,"rimraf: missing path"),Bt.strictEqual(typeof e,"string","rimraf: path should be a string"),Bt.strictEqual(typeof n,"function","rimraf: callback function required"),Bt(t,"rimraf: invalid options argument provided"),Bt.strictEqual(typeof t,"object","rimraf: options should be object"),kt(t),Nt(e,t,(function u(o){if(o){if(("EBUSY"===o.code||"ENOTEMPTY"===o.code||"EPERM"===o.code)&&rNt(e,t,u)),100*r)}"ENOENT"===o.code&&(o=null)}n(o)}))}function Nt(e,t,n){Bt(e),Bt(t),Bt("function"==typeof n),t.lstat(e,((r,u)=>r&&"ENOENT"===r.code?n(null):r&&"EPERM"===r.code&&Pt?It(e,t,r,n):u&&u.isDirectory()?Rt(e,t,r,n):void t.unlink(e,(r=>{if(r){if("ENOENT"===r.code)return n(null);if("EPERM"===r.code)return Pt?It(e,t,r,n):Rt(e,t,r,n);if("EISDIR"===r.code)return Rt(e,t,r,n)}return n(r)}))))}function It(e,t,n,r){Bt(e),Bt(t),Bt("function"==typeof r),t.chmod(e,438,(u=>{u?r("ENOENT"===u.code?null:n):t.stat(e,((u,o)=>{u?r("ENOENT"===u.code?null:n):o.isDirectory()?Rt(e,t,n,r):t.unlink(e,r)}))}))}function Tt(e,t,n){let r;Bt(e),Bt(t);try{t.chmodSync(e,438)}catch(e){if("ENOENT"===e.code)return;throw n}try{r=t.statSync(e)}catch(e){if("ENOENT"===e.code)return;throw n}r.isDirectory()?Lt(e,t,n):t.unlinkSync(e)}function Rt(e,t,n,r){Bt(e),Bt(t),Bt("function"==typeof r),t.rmdir(e,(u=>{!u||"ENOTEMPTY"!==u.code&&"EEXIST"!==u.code&&"EPERM"!==u.code?u&&"ENOTDIR"===u.code?r(n):r(u):function(e,t,n){Bt(e),Bt(t),Bt("function"==typeof n),t.readdir(e,((r,u)=>{if(r)return n(r);let o,i=u.length;if(0===i)return t.rmdir(e,n);u.forEach((r=>{xt(_t.join(e,r),t,(r=>{if(!o)return r?n(o=r):void(0==--i&&t.rmdir(e,n))}))}))}))}(e,t,r)}))}function Mt(e,t){let n;kt(t=t||{}),Bt(e,"rimraf: missing path"),Bt.strictEqual(typeof e,"string","rimraf: path should be a string"),Bt(t,"rimraf: missing options"),Bt.strictEqual(typeof t,"object","rimraf: options should be object");try{n=t.lstatSync(e)}catch(n){if("ENOENT"===n.code)return;"EPERM"===n.code&&Pt&&Tt(e,t,n)}try{n&&n.isDirectory()?Lt(e,t,null):t.unlinkSync(e)}catch(n){if("ENOENT"===n.code)return;if("EPERM"===n.code)return Pt?Tt(e,t,n):Lt(e,t,n);if("EISDIR"!==n.code)throw n;Lt(e,t,n)}}function Lt(e,t,n){Bt(e),Bt(t);try{t.rmdirSync(e)}catch(r){if("ENOTDIR"===r.code)throw n;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(e,t){if(Bt(e),Bt(t),t.readdirSync(e).forEach((n=>Mt(_t.join(e,n),t))),!Pt){return t.rmdirSync(e,t)}{const n=Date.now();do{try{return t.rmdirSync(e,t)}catch{}}while(Date.now()-n<500)}}(e,t);else if("ENOENT"!==r.code)throw r}}var jt=xt;xt.sync=Mt;const $t=we,Ht=re.fromCallback,Jt=jt;var Gt={remove:Ht((function(e,t){if($t.rm)return $t.rm(e,{recursive:!0,force:!0},t);Jt(e,t)})),removeSync:function(e){if($t.rmSync)return $t.rmSync(e,{recursive:!0,force:!0});Jt.sync(e)}};const Vt=re.fromPromise,Ut=ne,Wt=p.default,zt=$e,Kt=Gt,qt=Vt((async function(e){let t;try{t=await Ut.readdir(e)}catch{return zt.mkdirs(e)}return Promise.all(t.map((t=>Kt.remove(Wt.join(e,t)))))}));function Yt(e){let t;try{t=Ut.readdirSync(e)}catch{return zt.mkdirsSync(e)}t.forEach((t=>{t=Wt.join(e,t),Kt.removeSync(t)}))}var Xt={emptyDirSync:Yt,emptydirSync:Yt,emptyDir:qt,emptydir:qt};const Zt=re.fromCallback,Qt=p.default,en=we,tn=$e;var nn={createFile:Zt((function(e,t){function n(){en.writeFile(e,"",(e=>{if(e)return t(e);t()}))}en.stat(e,((r,u)=>{if(!r&&u.isFile())return t();const o=Qt.dirname(e);en.stat(o,((e,r)=>{if(e)return"ENOENT"===e.code?tn.mkdirs(o,(e=>{if(e)return t(e);n()})):t(e);r.isDirectory()?n():en.readdir(o,(e=>{if(e)return t(e)}))}))}))})),createFileSync:function(e){let t;try{t=en.statSync(e)}catch{}if(t&&t.isFile())return;const n=Qt.dirname(e);try{en.statSync(n).isDirectory()||en.readdirSync(n)}catch(e){if(!e||"ENOENT"!==e.code)throw e;tn.mkdirsSync(n)}en.writeFileSync(e,"")}};const rn=re.fromCallback,un=p.default,on=we,sn=$e,cn=Ge.pathExists,{areIdentical:an}=et;var ln={createLink:rn((function(e,t,n){function r(e,t){on.link(e,t,(e=>{if(e)return n(e);n(null)}))}on.lstat(t,((u,o)=>{on.lstat(e,((u,i)=>{if(u)return u.message=u.message.replace("lstat","ensureLink"),n(u);if(o&&an(i,o))return n(null);const s=un.dirname(t);cn(s,((u,o)=>u?n(u):o?r(e,t):void sn.mkdirs(s,(u=>{if(u)return n(u);r(e,t)}))))}))}))})),createLinkSync:function(e,t){let n;try{n=on.lstatSync(t)}catch{}try{const t=on.lstatSync(e);if(n&&an(t,n))return}catch(e){throw e.message=e.message.replace("lstat","ensureLink"),e}const r=un.dirname(t);return on.existsSync(r)||sn.mkdirsSync(r),on.linkSync(e,t)}};const fn=p.default,dn=we,Dn=Ge.pathExists;var pn={symlinkPaths:function(e,t,n){if(fn.isAbsolute(e))return dn.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:e})));{const r=fn.dirname(t),u=fn.join(r,e);return Dn(u,((t,o)=>t?n(t):o?n(null,{toCwd:u,toDst:e}):dn.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:fn.relative(r,e)})))))}},symlinkPathsSync:function(e,t){let n;if(fn.isAbsolute(e)){if(n=dn.existsSync(e),!n)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}{const r=fn.dirname(t),u=fn.join(r,e);if(n=dn.existsSync(u),n)return{toCwd:u,toDst:e};if(n=dn.existsSync(e),!n)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:fn.relative(r,e)}}}};const En=we;var mn={symlinkType:function(e,t,n){if(n="function"==typeof t?t:n,t="function"!=typeof t&&t)return n(null,t);En.lstat(e,((e,r)=>{if(e)return n(null,"file");t=r&&r.isDirectory()?"dir":"file",n(null,t)}))},symlinkTypeSync:function(e,t){let n;if(t)return t;try{n=En.lstatSync(e)}catch{return"file"}return n&&n.isDirectory()?"dir":"file"}};const hn=re.fromCallback,yn=p.default,Cn=ne,Fn=$e.mkdirs,gn=$e.mkdirsSync,An=pn.symlinkPaths,vn=pn.symlinkPathsSync,Sn=mn.symlinkType,wn=mn.symlinkTypeSync,On=Ge.pathExists,{areIdentical:bn}=et;function _n(e,t,n,r){An(e,t,((u,o)=>{if(u)return r(u);e=o.toDst,Sn(o.toCwd,n,((n,u)=>{if(n)return r(n);const o=yn.dirname(t);On(o,((n,i)=>n?r(n):i?Cn.symlink(e,t,u,r):void Fn(o,(n=>{if(n)return r(n);Cn.symlink(e,t,u,r)}))))}))}))}var Bn={createSymlink:hn((function(e,t,n,r){r="function"==typeof n?n:r,n="function"!=typeof n&&n,Cn.lstat(t,((u,o)=>{!u&&o.isSymbolicLink()?Promise.all([Cn.stat(e),Cn.stat(t)]).then((([u,o])=>{if(bn(u,o))return r(null);_n(e,t,n,r)})):_n(e,t,n,r)}))})),createSymlinkSync:function(e,t,n){let r;try{r=Cn.lstatSync(t)}catch{}if(r&&r.isSymbolicLink()){const n=Cn.statSync(e),r=Cn.statSync(t);if(bn(n,r))return}const u=vn(e,t);e=u.toDst,n=wn(u.toCwd,n);const o=yn.dirname(t);return Cn.existsSync(o)||gn(o),Cn.symlinkSync(e,t,n)}};const{createFile:Pn,createFileSync:kn}=nn,{createLink:xn,createLinkSync:Nn}=ln,{createSymlink:In,createSymlinkSync:Tn}=Bn;var Rn={createFile:Pn,createFileSync:kn,ensureFile:Pn,ensureFileSync:kn,createLink:xn,createLinkSync:Nn,ensureLink:xn,ensureLinkSync:Nn,createSymlink:In,createSymlinkSync:Tn,ensureSymlink:In,ensureSymlinkSync:Tn};var Mn={stringify:function(e,{EOL:t="\n",finalEOL:n=!0,replacer:r=null,spaces:u}={}){const o=n?t:"";return JSON.stringify(e,r,u).replace(/\n/g,t)+o},stripBom:function(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}};let Ln;try{Ln=we}catch(e){Ln=D.default}const jn=re,{stringify:$n,stripBom:Hn}=Mn;const Jn=jn.fromPromise((async function(e,t={}){"string"==typeof t&&(t={encoding:t});const n=t.fs||Ln,r=!("throws"in t)||t.throws;let u,o=await jn.fromCallback(n.readFile)(e,t);o=Hn(o);try{u=JSON.parse(o,t?t.reviver:null)}catch(t){if(r)throw t.message=`${e}: ${t.message}`,t;return null}return u}));const Gn=jn.fromPromise((async function(e,t,n={}){const r=n.fs||Ln,u=$n(t,n);await jn.fromCallback(r.writeFile)(e,u,n)}));const Vn={readFile:Jn,readFileSync:function(e,t={}){"string"==typeof t&&(t={encoding:t});const n=t.fs||Ln,r=!("throws"in t)||t.throws;try{let r=n.readFileSync(e,t);return r=Hn(r),JSON.parse(r,t.reviver)}catch(t){if(r)throw t.message=`${e}: ${t.message}`,t;return null}},writeFile:Gn,writeFileSync:function(e,t,n={}){const r=n.fs||Ln,u=$n(t,n);return r.writeFileSync(e,u,n)}};var Un={readJson:Vn.readFile,readJsonSync:Vn.readFileSync,writeJson:Vn.writeFile,writeJsonSync:Vn.writeFileSync};const Wn=re.fromCallback,zn=we,Kn=p.default,qn=$e,Yn=Ge.pathExists;var Xn={outputFile:Wn((function(e,t,n,r){"function"==typeof n&&(r=n,n="utf8");const u=Kn.dirname(e);Yn(u,((o,i)=>o?r(o):i?zn.writeFile(e,t,n,r):void qn.mkdirs(u,(u=>{if(u)return r(u);zn.writeFile(e,t,n,r)}))))})),outputFileSync:function(e,...t){const n=Kn.dirname(e);if(zn.existsSync(n))return zn.writeFileSync(e,...t);qn.mkdirsSync(n),zn.writeFileSync(e,...t)}};const{stringify:Zn}=Mn,{outputFile:Qn}=Xn;var er=async function(e,t,n={}){const r=Zn(t,n);await Qn(e,r,n)};const{stringify:tr}=Mn,{outputFileSync:nr}=Xn;var rr=function(e,t,n){const r=tr(t,n);nr(e,r,n)};const ur=re.fromPromise,or=Un;or.outputJson=ur(er),or.outputJsonSync=rr,or.outputJSON=or.outputJson,or.outputJSONSync=or.outputJsonSync,or.writeJSON=or.writeJson,or.writeJSONSync=or.writeJsonSync,or.readJSON=or.readJson,or.readJSONSync=or.readJsonSync;var ir=or;const sr=we,cr=p.default,ar=Ot.copy,lr=Gt.remove,fr=$e.mkdirp,dr=Ge.pathExists,Dr=et;function pr(e,t,n,r,u){return r?Er(e,t,n,u):n?lr(t,(r=>r?u(r):Er(e,t,n,u))):void dr(t,((r,o)=>r?u(r):o?u(new Error("dest already exists.")):Er(e,t,n,u)))}function Er(e,t,n,r){sr.rename(e,t,(u=>u?"EXDEV"!==u.code?r(u):function(e,t,n,r){const u={overwrite:n,errorOnExist:!0};ar(e,t,u,(t=>t?r(t):lr(e,r)))}(e,t,n,r):r()))}var mr=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=n.overwrite||n.clobber||!1;Dr.checkPaths(e,t,"move",n,((n,o)=>{if(n)return r(n);const{srcStat:i,isChangingCase:s=!1}=o;Dr.checkParentPaths(e,i,t,"move",(n=>n?r(n):function(e){const t=cr.dirname(e);return cr.parse(t).root===t}(t)?pr(e,t,u,s,r):void fr(cr.dirname(t),(n=>n?r(n):pr(e,t,u,s,r)))))}))};const hr=we,yr=p.default,Cr=Ot.copySync,Fr=Gt.removeSync,gr=$e.mkdirpSync,Ar=et;function vr(e,t,n){try{hr.renameSync(e,t)}catch(r){if("EXDEV"!==r.code)throw r;return function(e,t,n){const r={overwrite:n,errorOnExist:!0};return Cr(e,t,r),Fr(e)}(e,t,n)}}var Sr=function(e,t,n){const r=(n=n||{}).overwrite||n.clobber||!1,{srcStat:u,isChangingCase:o=!1}=Ar.checkPathsSync(e,t,"move",n);return Ar.checkParentPathsSync(e,u,t,"move"),function(e){const t=yr.dirname(e);return yr.parse(t).root===t}(t)||gr(yr.dirname(t)),function(e,t,n,r){if(r)return vr(e,t,n);if(n)return Fr(t),vr(e,t,n);if(hr.existsSync(t))throw new Error("dest already exists.");return vr(e,t,n)}(e,t,r,o)};var wr,Or,br,_r,Br,Pr={move:(0,re.fromCallback)(mr),moveSync:Sr},kr={...ne,...Ot,...Xt,...Rn,...ir,...$e,...Pr,...Xn,...Ge,...Gt},xr={},Nr={exports:{}},Ir={exports:{}};function Tr(){if(Or)return wr;Or=1;var e=1e3,t=60*e,n=60*t,r=24*n,u=7*r,o=365.25*r;function i(e,t,n,r){var u=t>=1.5*n;return Math.round(e/n)+" "+r+(u?"s":"")}return wr=function(s,c){c=c||{};var a=typeof s;if("string"===a&&s.length>0)return function(i){if((i=String(i)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!s)return;var c=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*u;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(s);if("number"===a&&isFinite(s))return c.long?function(u){var o=Math.abs(u);if(o>=r)return i(u,o,r,"day");if(o>=n)return i(u,o,n,"hour");if(o>=t)return i(u,o,t,"minute");if(o>=e)return i(u,o,e,"second");return u+" ms"}(s):function(u){var o=Math.abs(u);if(o>=r)return Math.round(u/r)+"d";if(o>=n)return Math.round(u/n)+"h";if(o>=t)return Math.round(u/t)+"m";if(o>=e)return Math.round(u/e)+"s";return u+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}function Rr(){if(_r)return br;return _r=1,br=function(e){function t(e){let r,u,o,i=null;function s(...e){if(!s.enabled)return;const n=s,u=Number(new Date),o=u-(r||u);n.diff=o,n.prev=r,n.curr=u,r=u,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,u)=>{if("%%"===r)return"%";i++;const o=t.formatters[u];if("function"==typeof o){const t=e[i];r=o.call(n,t),e.splice(i,1),i--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(u!==t.namespaces&&(u=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(s),s}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),u=r.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{const n=e.startsWith("-")?"":1===e.length?"-":"--",r=t.indexOf(n+e),u=t.indexOf("--");return-1!==r&&(-1===u||r{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=function(){if($r)return jr;$r=1;const e=E.default,t=A.default,n=Vr(),{env:r}=process;let u;function o(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function i(t,o){if(0===u)return 0;if(n("color=16m")||n("color=full")||n("color=truecolor"))return 3;if(n("color=256"))return 2;if(t&&!o&&void 0===u)return 0;const i=u||0;if("dumb"===r.TERM)return i;if("win32"===process.platform){const t=e.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in r))||"codeship"===r.CI_NAME?1:i;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if("truecolor"===r.COLORTERM)return 3;if("TERM_PROGRAM"in r){const e=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:i}return n("no-color")||n("no-colors")||n("color=false")||n("color=never")?u=0:(n("color")||n("colors")||n("color=true")||n("color=always"))&&(u=1),"FORCE_COLOR"in r&&(u="true"===r.FORCE_COLOR?1:"false"===r.FORCE_COLOR?0:0===r.FORCE_COLOR.length?1:Math.min(parseInt(r.FORCE_COLOR,10),3)),jr={supportsColor:function(e){return o(i(e,e&&e.isTTY))},stdout:o(i(!0,t.isatty(1))),stderr:o(i(!0,t.isatty(2)))}}();e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let r=process.env[t];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),e[n]=r,e}),{}),e.exports=Rr()(t);const{formatters:u}=e.exports;u.o=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},u.O=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts)}}(Gr,Gr.exports)),Gr.exports}Jr=Nr,"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?Jr.exports=(Br||(Br=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,u=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(u=r))})),t.splice(u,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Rr()(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ir,Ir.exports)),Ir.exports):Jr.exports=Ur();var Wr=function(e){return(e=e||{}).circles?function(e){var t=[],n=[];return e.proto?function e(u){if("object"!=typeof u||null===u)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return r(u,e);if(u instanceof Map)return new Map(r(Array.from(u),e));if(u instanceof Set)return new Set(r(Array.from(u),e));var o={};for(var i in t.push(u),n.push(o),u){var s=u[i];if("object"!=typeof s||null===s)o[i]=s;else if(s instanceof Date)o[i]=new Date(s);else if(s instanceof Map)o[i]=new Map(r(Array.from(s),e));else if(s instanceof Set)o[i]=new Set(r(Array.from(s),e));else if(ArrayBuffer.isView(s))o[i]=zr(s);else{var c=t.indexOf(s);o[i]=-1!==c?n[c]:e(s)}}return t.pop(),n.pop(),o}:function e(u){if("object"!=typeof u||null===u)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return r(u,e);if(u instanceof Map)return new Map(r(Array.from(u),e));if(u instanceof Set)return new Set(r(Array.from(u),e));var o={};for(var i in t.push(u),n.push(o),u)if(!1!==Object.hasOwnProperty.call(u,i)){var s=u[i];if("object"!=typeof s||null===s)o[i]=s;else if(s instanceof Date)o[i]=new Date(s);else if(s instanceof Map)o[i]=new Map(r(Array.from(s),e));else if(s instanceof Set)o[i]=new Set(r(Array.from(s),e));else if(ArrayBuffer.isView(s))o[i]=zr(s);else{var c=t.indexOf(s);o[i]=-1!==c?n[c]:e(s)}}return t.pop(),n.pop(),o};function r(e,r){for(var u=Object.keys(e),o=new Array(u.length),i=0;i!e,Qr=e=>e&&"object"==typeof e&&!Array.isArray(e),eu=(e,t,n)=>{(Array.isArray(t)?t:[t]).forEach((t=>{if(t)throw new Error(`Problem with log4js configuration: (${Kr.inspect(e,{depth:5})}) - ${n}`)}))};var tu={configure:e=>{qr("New configuration to be validated: ",e),eu(e,Zr(Qr(e)),"must be an object."),qr(`Calling pre-processing listeners (${Yr.length})`),Yr.forEach((t=>t(e))),qr("Configuration pre-processing finished."),qr(`Calling configuration listeners (${Xr.length})`),Xr.forEach((t=>t(e))),qr("Configuration finished.")},addListener:e=>{Xr.push(e),qr(`Added listener, now ${Xr.length} listeners`)},addPreProcessingListener:e=>{Yr.push(e),qr(`Added pre-processing listener, now ${Yr.length} listeners`)},throwExceptionIf:eu,anObject:Qr,anInteger:e=>e&&"number"==typeof e&&Number.isInteger(e),validIdentifier:e=>/^[A-Za-z][A-Za-z0-9_]*$/g.test(e),not:Zr},nu={exports:{}};!function(e){function t(e,t){for(var n=e.toString();n.length-1?s:c,l=n(u.getHours()),f=n(u.getMinutes()),d=n(u.getSeconds()),D=t(u.getMilliseconds(),3),p=function(e){var t=Math.abs(e),n=String(Math.floor(t/60)),r=String(t%60);return n=("0"+n).slice(-2),r=("0"+r).slice(-2),0===e?"Z":(e<0?"+":"-")+n+":"+r}(u.getTimezoneOffset());return r.replace(/dd/g,o).replace(/MM/g,i).replace(/y{1,4}/g,a).replace(/hh/g,l).replace(/mm/g,f).replace(/ss/g,d).replace(/SSS/g,D).replace(/O/g,p)}function u(e,t,n,r){e["set"+(r?"":"UTC")+t](n)}e.exports=r,e.exports.asString=r,e.exports.parse=function(t,n,r){if(!t)throw new Error("pattern must be supplied");return function(t,n,r){var o=t.indexOf("O")<0,i=!1,s=[{pattern:/y{1,4}/,regexp:"\\d{1,4}",fn:function(e,t){u(e,"FullYear",t,o)}},{pattern:/MM/,regexp:"\\d{1,2}",fn:function(e,t){u(e,"Month",t-1,o),e.getMonth()!==t-1&&(i=!0)}},{pattern:/dd/,regexp:"\\d{1,2}",fn:function(e,t){i&&u(e,"Month",e.getMonth()-1,o),u(e,"Date",t,o)}},{pattern:/hh/,regexp:"\\d{1,2}",fn:function(e,t){u(e,"Hours",t,o)}},{pattern:/mm/,regexp:"\\d\\d",fn:function(e,t){u(e,"Minutes",t,o)}},{pattern:/ss/,regexp:"\\d\\d",fn:function(e,t){u(e,"Seconds",t,o)}},{pattern:/SSS/,regexp:"\\d\\d\\d",fn:function(e,t){u(e,"Milliseconds",t,o)}},{pattern:/O/,regexp:"[+-]\\d{1,2}:?\\d{2}?|Z",fn:function(e,t){t="Z"===t?0:t.replace(":","");var n=Math.abs(t),r=(t>0?-1:1)*(n%100+60*Math.floor(n/100));e.setUTCMinutes(e.getUTCMinutes()+r)}}],c=s.reduce((function(e,t){return t.pattern.test(e.regexp)?(t.index=e.regexp.match(t.pattern).index,e.regexp=e.regexp.replace(t.pattern,"("+t.regexp+")")):t.index=-1,e}),{regexp:t,index:[]}),a=s.filter((function(e){return e.index>-1}));a.sort((function(e,t){return e.index-t.index}));var l=new RegExp(c.regexp).exec(n);if(l){var f=r||e.exports.now();return a.forEach((function(e,t){e.fn(f,l[t+1])})),f}throw new Error("String '"+n+"' could not be parsed as '"+t+"'")}(t,n,r)},e.exports.now=function(){return new Date},e.exports.ISO8601_FORMAT="yyyy-MM-ddThh:mm:ss.SSS",e.exports.ISO8601_WITH_TZ_OFFSET_FORMAT="yyyy-MM-ddThh:mm:ss.SSSO",e.exports.DATETIME_FORMAT="dd MM yyyy hh:mm:ss.SSS",e.exports.ABSOLUTETIME_FORMAT="hh:mm:ss.SSS"}(nu);const ru=nu.exports,uu=E.default,ou=F.default,iu=p.default,su={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[90,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[91,39],yellow:[33,39]};function cu(e){return e?`[${su[e][0]}m`:""}function au(e){return e?`[${su[e][1]}m`:""}function lu(e,t){return n=ou.format("[%s] [%s] %s - ",ru.asString(e.startTime),e.level.toString(),e.categoryName),cu(r=t)+n+au(r);var n,r}function fu(e){return lu(e)+ou.format(...e.data)}function du(e){return lu(e,e.level.colour)+ou.format(...e.data)}function Du(e){return ou.format(...e.data)}function pu(e){return e.data[0]}function Eu(e,t){const n=/%(-?[0-9]+)?(\.?-?[0-9]+)?([[\]cdhmnprzxXyflos%])(\{([^}]+)\})?|([^%]+)/;function r(e){return e&&e.pid?e.pid.toString():process.pid.toString()}e=e||"%r %p %c - %m%n";const u={c:function(e,t){let n=e.categoryName;if(t){const e=parseInt(t,10),r=n.split(".");ee&&(n=r.slice(-e).join(iu.sep))}return n},l:function(e){return e.lineNumber?`${e.lineNumber}`:""},o:function(e){return e.columnNumber?`${e.columnNumber}`:""},s:function(e){return e.callStack||""}};function o(e,t,n){return u[e](t,n)}function i(e,t,n){let r=e;return r=function(e,t){let n;return e?(n=parseInt(e.substr(1),10),n>0?t.slice(0,n):t.slice(n)):t}(t,r),r=function(e,t){let n;if(e)if("-"===e.charAt(0))for(n=parseInt(e.substr(1),10);t.lengthDu,basic:()=>fu,colored:()=>du,coloured:()=>du,pattern:e=>Eu(e&&e.pattern,e&&e.tokens),dummy:()=>pu};var hu={basicLayout:fu,messagePassThroughLayout:Du,patternLayout:Eu,colouredLayout:du,coloredLayout:du,dummyLayout:pu,addLayout(e,t){mu[e]=t},layout:(e,t)=>mu[e]&&mu[e](t)};const yu=tu,Cu=["white","grey","black","blue","cyan","green","magenta","red","yellow"];class Fu{constructor(e,t,n){this.level=e,this.levelStr=t,this.colour=n}toString(){return this.levelStr}static getLevel(e,t){return e?e instanceof Fu?e:(e instanceof Object&&e.levelStr&&(e=e.levelStr),Fu[e.toString().toUpperCase()]||t):t}static addLevels(e){if(e){Object.keys(e).forEach((t=>{const n=t.toUpperCase();Fu[n]=new Fu(e[t].value,n,e[t].colour);const r=Fu.levels.findIndex((e=>e.levelStr===n));r>-1?Fu.levels[r]=Fu[n]:Fu.levels.push(Fu[n])})),Fu.levels.sort(((e,t)=>e.level-t.level))}}isLessThanOrEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level<=e.level}isGreaterThanOrEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level>=e.level}isEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level===e.level}}Fu.levels=[],Fu.addLevels({ALL:{value:Number.MIN_VALUE,colour:"grey"},TRACE:{value:5e3,colour:"blue"},DEBUG:{value:1e4,colour:"cyan"},INFO:{value:2e4,colour:"green"},WARN:{value:3e4,colour:"yellow"},ERROR:{value:4e4,colour:"red"},FATAL:{value:5e4,colour:"magenta"},MARK:{value:9007199254740992,colour:"grey"},OFF:{value:Number.MAX_VALUE,colour:"grey"}}),yu.addListener((e=>{const t=e.levels;if(t){yu.throwExceptionIf(e,yu.not(yu.anObject(t)),"levels must be an object");Object.keys(t).forEach((n=>{yu.throwExceptionIf(e,yu.not(yu.validIdentifier(n)),`level name "${n}" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)`),yu.throwExceptionIf(e,yu.not(yu.anObject(t[n])),`level "${n}" must be an object`),yu.throwExceptionIf(e,yu.not(t[n].value),`level "${n}" must have a 'value' property`),yu.throwExceptionIf(e,yu.not(yu.anInteger(t[n].value)),`level "${n}".value must have an integer value`),yu.throwExceptionIf(e,yu.not(t[n].colour),`level "${n}" must have a 'colour' property`),yu.throwExceptionIf(e,yu.not(Cu.indexOf(t[n].colour)>-1),`level "${n}".colour must be one of ${Cu.join(", ")}`)}))}})),yu.addListener((e=>{Fu.addLevels(e.levels)}));var gu=Fu,Au={exports:{}},vu={};/*! (c) 2020 Andrea Giammarchi */ +const{parse:Su,stringify:wu}=JSON,{keys:Ou}=Object,bu=String,_u="string",Bu={},Pu="object",ku=(e,t)=>t,xu=e=>e instanceof bu?bu(e):e,Nu=(e,t)=>typeof t===_u?new bu(t):t,Iu=(e,t,n,r)=>{const u=[];for(let o=Ou(n),{length:i}=o,s=0;s{const r=bu(t.push(n)-1);return e.set(n,r),r},Ru=(e,t)=>{const n=Su(e,Nu).map(xu),r=n[0],u=t||ku,o=typeof r===Pu&&r?Iu(n,new Set,r,u):r;return u.call({"":o},"",o)};vu.parse=Ru;const Mu=(e,t,n)=>{const r=t&&typeof t===Pu?(e,n)=>""===e||-1Su(Mu(e));vu.fromJSON=e=>Ru(wu(e));const Lu=vu,ju=gu;class $u{constructor(e,t,n,r,u){this.startTime=new Date,this.categoryName=e,this.data=n,this.level=t,this.context=Object.assign({},r),this.pid=process.pid,u&&(this.functionName=u.functionName,this.fileName=u.fileName,this.lineNumber=u.lineNumber,this.columnNumber=u.columnNumber,this.callStack=u.callStack)}serialise(){const e=this.data.map((e=>(e&&e.message&&e.stack&&(e=Object.assign({message:e.message,stack:e.stack},e)),e)));return this.data=e,Lu.stringify(this)}static deserialise(e){let t;try{const n=Lu.parse(e);n.data=n.data.map((e=>{if(e&&e.message&&e.stack){const t=new Error(e);Object.keys(e).forEach((n=>{t[n]=e[n]})),e=t}return e})),t=new $u(n.categoryName,ju.getLevel(n.level.levelStr),n.data,n.context),t.startTime=new Date(n.startTime),t.pid=n.pid,t.cluster=n.cluster}catch(n){t=new $u("log4js",ju.ERROR,["Unable to parse log:",e,"because: ",n])}return t}}var Hu=$u;const Ju=Nr.exports("log4js:clustering"),Gu=Hu,Vu=tu;let Uu=!1,Wu=null;try{Wu=require("cluster")}catch(e){Ju("cluster module not present"),Uu=!0}const zu=[];let Ku=!1,qu="NODE_APP_INSTANCE";const Yu=()=>Ku&&"0"===process.env[qu],Xu=()=>Uu||Wu.isMaster||Yu(),Zu=e=>{zu.forEach((t=>t(e)))},Qu=(e,t)=>{if(Ju("cluster message received from worker ",e,": ",t),e.topic&&e.data&&(t=e,e=void 0),t&&t.topic&&"log4js:message"===t.topic){Ju("received message: ",t.data);const e=Gu.deserialise(t.data);Zu(e)}};Uu||Vu.addListener((e=>{zu.length=0,({pm2:Ku,disableClustering:Uu,pm2InstanceVar:qu="NODE_APP_INSTANCE"}=e),Ju(`clustering disabled ? ${Uu}`),Ju(`cluster.isMaster ? ${Wu&&Wu.isMaster}`),Ju(`pm2 enabled ? ${Ku}`),Ju(`pm2InstanceVar = ${qu}`),Ju(`process.env[${qu}] = ${process.env[qu]}`),Ku&&process.removeListener("message",Qu),Wu&&Wu.removeListener&&Wu.removeListener("message",Qu),Uu||e.disableClustering?Ju("Not listening for cluster messages, because clustering disabled."):Yu()?(Ju("listening for PM2 broadcast messages"),process.on("message",Qu)):Wu.isMaster?(Ju("listening for cluster messages"),Wu.on("message",Qu)):Ju("not listening for messages, because we are not a master process")}));var eo={onlyOnMaster:(e,t)=>Xu()?e():t,isMaster:Xu,send:e=>{Xu()?Zu(e):(Ku||(e.cluster={workerId:Wu.worker.id,worker:process.pid}),process.send({topic:"log4js:message",data:e.serialise()}))},onMessage:e=>{zu.push(e)}},to={};function no(e){if("number"==typeof e&&Number.isInteger(e))return e;const t={K:1024,M:1048576,G:1073741824},n=Object.keys(t),r=e.substr(e.length-1).toLocaleUpperCase(),u=e.substring(0,e.length-1).trim();if(n.indexOf(r)<0||!Number.isInteger(Number(u)))throw Error(`maxLogSize: "${e}" is invalid`);return u*t[r]}function ro(e){return function(e,t){const n=Object.assign({},t);return Object.keys(e).forEach((r=>{n[r]&&(n[r]=e[r](t[r]))})),n}({maxLogSize:no},e)}const uo={file:ro,fileSync:ro};to.modifyConfig=e=>uo[e.type]?uo[e.type](e):e;var oo={};const io=console.log.bind(console);oo.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{io(e(n,t))}}(n,e.timezoneOffset)};var so={};so.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{process.stdout.write(`${e(n,t)}\n`)}}(n,e.timezoneOffset)};var co={};co.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{process.stderr.write(`${e(n,t)}\n`)}}(n,e.timezoneOffset)};var ao={};ao.configure=function(e,t,n,r){const u=n(e.appender);return function(e,t,n,r){const u=r.getLevel(e),o=r.getLevel(t,r.FATAL);return e=>{const t=e.level;t.isGreaterThanOrEqualTo(u)&&t.isLessThanOrEqualTo(o)&&n(e)}}(e.level,e.maxLevel,u,r)};var lo={};const fo=Nr.exports("log4js:categoryFilter");lo.configure=function(e,t,n){const r=n(e.appender);return function(e,t){return"string"==typeof e&&(e=[e]),n=>{fo(`Checking ${n.categoryName} against ${e}`),-1===e.indexOf(n.categoryName)&&(fo("Not excluded, sending to appender"),t(n))}}(e.exclude,r)};var Do={};const po=Nr.exports("log4js:noLogFilter");Do.configure=function(e,t,n){const r=n(e.appender);return function(e,t){return n=>{po(`Checking data: ${n.data} against filters: ${e}`),"string"==typeof e&&(e=[e]),e=e.filter((e=>null!=e&&""!==e));const r=new RegExp(e.join("|"),"i");(0===e.length||n.data.findIndex((e=>r.test(e)))<0)&&(po("Not excluded, sending to appender"),t(n))}}(e.exclude,r)};var Eo={},mo={exports:{}},ho={},yo={fromCallback:function(e){return Object.defineProperty((function(){if("function"!=typeof arguments[arguments.length-1])return new Promise(((t,n)=>{arguments[arguments.length]=(e,r)=>{if(e)return n(e);t(r)},arguments.length++,e.apply(this,arguments)}));e.apply(this,arguments)}),"name",{value:e.name})},fromPromise:function(e){return Object.defineProperty((function(){const t=arguments[arguments.length-1];if("function"!=typeof t)return e.apply(this,arguments);e.apply(this,arguments).then((e=>t(null,e)),t)}),"name",{value:e.name})}};!function(e){const t=yo.fromCallback,n=we,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchown","lchmod","link","lstat","mkdir","mkdtemp","open","readFile","readdir","readlink","realpath","rename","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter((e=>"function"==typeof n[e]));Object.keys(n).forEach((t=>{"promises"!==t&&(e[t]=n[t])})),r.forEach((r=>{e[r]=t(n[r])})),e.exists=function(e,t){return"function"==typeof t?n.exists(e,t):new Promise((t=>n.exists(e,t)))},e.read=function(e,t,r,u,o,i){return"function"==typeof i?n.read(e,t,r,u,o,i):new Promise(((i,s)=>{n.read(e,t,r,u,o,((e,t,n)=>{if(e)return s(e);i({bytesRead:t,buffer:n})}))}))},e.write=function(e,t,...r){return"function"==typeof r[r.length-1]?n.write(e,t,...r):new Promise(((u,o)=>{n.write(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffer:n})}))}))},"function"==typeof n.realpath.native&&(e.realpath.native=t(n.realpath.native))}(ho);const Co=p.default;function Fo(e){return(e=Co.normalize(Co.resolve(e)).split(Co.sep)).length>0?e[0]:null}const go=/[<>:"|?*]/;var Ao=function(e){const t=Fo(e);return e=e.replace(t,""),go.test(e)};const vo=we,So=p.default,wo=Ao,Oo=parseInt("0777",8);var bo=function e(t,n,r,u){if("function"==typeof n?(r=n,n={}):n&&"object"==typeof n||(n={mode:n}),"win32"===process.platform&&wo(t)){const e=new Error(t+" contains invalid WIN32 path characters.");return e.code="EINVAL",r(e)}let o=n.mode;const i=n.fs||vo;void 0===o&&(o=Oo&~process.umask()),u||(u=null),r=r||function(){},t=So.resolve(t),i.mkdir(t,o,(o=>{if(!o)return r(null,u=u||t);if("ENOENT"===o.code){if(So.dirname(t)===t)return r(o);e(So.dirname(t),n,((u,o)=>{u?r(u,o):e(t,n,r,o)}))}else i.stat(t,((e,t)=>{e||!t.isDirectory()?r(o,u):r(null,u)}))}))};const _o=we,Bo=p.default,Po=Ao,ko=parseInt("0777",8);var xo=function e(t,n,r){n&&"object"==typeof n||(n={mode:n});let u=n.mode;const o=n.fs||_o;if("win32"===process.platform&&Po(t)){const e=new Error(t+" contains invalid WIN32 path characters.");throw e.code="EINVAL",e}void 0===u&&(u=ko&~process.umask()),r||(r=null),t=Bo.resolve(t);try{o.mkdirSync(t,u),r=r||t}catch(u){if("ENOENT"===u.code){if(Bo.dirname(t)===t)throw u;r=e(Bo.dirname(t),n,r),e(t,n,r)}else{let e;try{e=o.statSync(t)}catch(e){throw u}if(!e.isDirectory())throw u}}return r};const No=(0,yo.fromCallback)(bo);var Io={mkdirs:No,mkdirsSync:xo,mkdirp:No,mkdirpSync:xo,ensureDir:No,ensureDirSync:xo};const To=we;E.default,p.default;var Ro=function(e,t,n,r){To.open(e,"r+",((e,u)=>{if(e)return r(e);To.futimes(u,t,n,(e=>{To.close(u,(t=>{r&&r(e||t)}))}))}))},Mo=function(e,t,n){const r=To.openSync(e,"r+");return To.futimesSync(r,t,n),To.closeSync(r)};const Lo=we,jo=p.default,$o=10,Ho=5,Jo=0,Go=process.versions.node.split("."),Vo=Number.parseInt(Go[0],10),Uo=Number.parseInt(Go[1],10),Wo=Number.parseInt(Go[2],10);function zo(){if(Vo>$o)return!0;if(Vo===$o){if(Uo>Ho)return!0;if(Uo===Ho&&Wo>=Jo)return!0}return!1}function Ko(e,t){const n=jo.resolve(e).split(jo.sep).filter((e=>e)),r=jo.resolve(t).split(jo.sep).filter((e=>e));return n.reduce(((e,t,n)=>e&&r[n]===t),!0)}function qo(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}var Yo,Xo,Zo={checkPaths:function(e,t,n,r){!function(e,t,n){zo()?Lo.stat(e,{bigint:!0},((e,r)=>{if(e)return n(e);Lo.stat(t,{bigint:!0},((e,t)=>e?"ENOENT"===e.code?n(null,{srcStat:r,destStat:null}):n(e):n(null,{srcStat:r,destStat:t})))})):Lo.stat(e,((e,r)=>{if(e)return n(e);Lo.stat(t,((e,t)=>e?"ENOENT"===e.code?n(null,{srcStat:r,destStat:null}):n(e):n(null,{srcStat:r,destStat:t})))}))}(e,t,((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;return s&&s.ino&&s.dev&&s.ino===i.ino&&s.dev===i.dev?r(new Error("Source and destination must not be the same.")):i.isDirectory()&&Ko(e,t)?r(new Error(qo(e,t,n))):r(null,{srcStat:i,destStat:s})}))},checkPathsSync:function(e,t,n){const{srcStat:r,destStat:u}=function(e,t){let n,r;n=zo()?Lo.statSync(e,{bigint:!0}):Lo.statSync(e);try{r=zo()?Lo.statSync(t,{bigint:!0}):Lo.statSync(t)}catch(e){if("ENOENT"===e.code)return{srcStat:n,destStat:null};throw e}return{srcStat:n,destStat:r}}(e,t);if(u&&u.ino&&u.dev&&u.ino===r.ino&&u.dev===r.dev)throw new Error("Source and destination must not be the same.");if(r.isDirectory()&&Ko(e,t))throw new Error(qo(e,t,n));return{srcStat:r,destStat:u}},checkParentPaths:function e(t,n,r,u,o){const i=jo.resolve(jo.dirname(t)),s=jo.resolve(jo.dirname(r));if(s===i||s===jo.parse(s).root)return o();zo()?Lo.stat(s,{bigint:!0},((i,c)=>i?"ENOENT"===i.code?o():o(i):c.ino&&c.dev&&c.ino===n.ino&&c.dev===n.dev?o(new Error(qo(t,r,u))):e(t,n,s,u,o))):Lo.stat(s,((i,c)=>i?"ENOENT"===i.code?o():o(i):c.ino&&c.dev&&c.ino===n.ino&&c.dev===n.dev?o(new Error(qo(t,r,u))):e(t,n,s,u,o)))},checkParentPathsSync:function e(t,n,r,u){const o=jo.resolve(jo.dirname(t)),i=jo.resolve(jo.dirname(r));if(i===o||i===jo.parse(i).root)return;let s;try{s=zo()?Lo.statSync(i,{bigint:!0}):Lo.statSync(i)}catch(e){if("ENOENT"===e.code)return;throw e}if(s.ino&&s.dev&&s.ino===n.ino&&s.dev===n.dev)throw new Error(qo(t,r,u));return e(t,n,i,u)},isSrcSubdir:Ko};const Qo=we,ei=p.default,ti=Io.mkdirsSync,ni=Mo,ri=Zo;function ui(e,t,n,r){if(!r.filter||r.filter(t,n))return function(e,t,n,r){const u=r.dereference?Qo.statSync:Qo.lstatSync,o=u(t);if(o.isDirectory())return function(e,t,n,r,u){if(!t)return function(e,t,n,r){return Qo.mkdirSync(n),ii(t,n,r),Qo.chmodSync(n,e.mode)}(e,n,r,u);if(t&&!t.isDirectory())throw new Error(`Cannot overwrite non-directory '${r}' with directory '${n}'.`);return ii(n,r,u)}(o,e,t,n,r);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return function(e,t,n,r,u){return t?function(e,t,n,r){if(r.overwrite)return Qo.unlinkSync(n),oi(e,t,n,r);if(r.errorOnExist)throw new Error(`'${n}' already exists`)}(e,n,r,u):oi(e,n,r,u)}(o,e,t,n,r);if(o.isSymbolicLink())return function(e,t,n,r){let u=Qo.readlinkSync(t);r.dereference&&(u=ei.resolve(process.cwd(),u));if(e){let e;try{e=Qo.readlinkSync(n)}catch(e){if("EINVAL"===e.code||"UNKNOWN"===e.code)return Qo.symlinkSync(u,n);throw e}if(r.dereference&&(e=ei.resolve(process.cwd(),e)),ri.isSrcSubdir(u,e))throw new Error(`Cannot copy '${u}' to a subdirectory of itself, '${e}'.`);if(Qo.statSync(n).isDirectory()&&ri.isSrcSubdir(e,u))throw new Error(`Cannot overwrite '${e}' with '${u}'.`);return function(e,t){return Qo.unlinkSync(t),Qo.symlinkSync(e,t)}(u,n)}return Qo.symlinkSync(u,n)}(e,t,n,r)}(e,t,n,r)}function oi(e,t,n,r){return"function"==typeof Qo.copyFileSync?(Qo.copyFileSync(t,n),Qo.chmodSync(n,e.mode),r.preserveTimestamps?ni(n,e.atime,e.mtime):void 0):function(e,t,n,r){const u=65536,o=(Xo?Yo:(Xo=1,Yo=function(e){if("function"==typeof Buffer.allocUnsafe)try{return Buffer.allocUnsafe(e)}catch(t){return new Buffer(e)}return new Buffer(e)}))(u),i=Qo.openSync(t,"r"),s=Qo.openSync(n,"w",e.mode);let c=0;for(;cfunction(e,t,n,r){const u=ei.join(t,e),o=ei.join(n,e),{destStat:i}=ri.checkPathsSync(u,o,"copy");return ui(i,u,o,r)}(r,e,t,n)))}var si=function(e,t,n){"function"==typeof n&&(n={filter:n}),(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:u}=ri.checkPathsSync(e,t,"copy");return ri.checkParentPathsSync(e,r,t,"copy"),function(e,t,n,r){if(r.filter&&!r.filter(t,n))return;const u=ei.dirname(n);Qo.existsSync(u)||ti(u);return ui(e,t,n,r)}(u,e,t,n)},ci={copySync:si};const ai=yo.fromPromise,li=ho;var fi={pathExists:ai((function(e){return li.access(e).then((()=>!0)).catch((()=>!1))})),pathExistsSync:li.existsSync};const di=we,Di=p.default,pi=Io.mkdirs,Ei=fi.pathExists,mi=Ro,hi=Zo;function yi(e,t,n,r,u){const o=Di.dirname(n);Ei(o,((i,s)=>i?u(i):s?Fi(e,t,n,r,u):void pi(o,(o=>o?u(o):Fi(e,t,n,r,u)))))}function Ci(e,t,n,r,u,o){Promise.resolve(u.filter(n,r)).then((i=>i?e(t,n,r,u,o):o()),(e=>o(e)))}function Fi(e,t,n,r,u){return r.filter?Ci(gi,e,t,n,r,u):gi(e,t,n,r,u)}function gi(e,t,n,r,u){(r.dereference?di.stat:di.lstat)(t,((o,i)=>o?u(o):i.isDirectory()?function(e,t,n,r,u,o){if(!t)return function(e,t,n,r,u){di.mkdir(n,(o=>{if(o)return u(o);Si(t,n,r,(t=>t?u(t):di.chmod(n,e.mode,u)))}))}(e,n,r,u,o);if(t&&!t.isDirectory())return o(new Error(`Cannot overwrite non-directory '${r}' with directory '${n}'.`));return Si(n,r,u,o)}(i,e,t,n,r,u):i.isFile()||i.isCharacterDevice()||i.isBlockDevice()?function(e,t,n,r,u,o){return t?function(e,t,n,r,u){if(!r.overwrite)return r.errorOnExist?u(new Error(`'${n}' already exists`)):u();di.unlink(n,(o=>o?u(o):Ai(e,t,n,r,u)))}(e,n,r,u,o):Ai(e,n,r,u,o)}(i,e,t,n,r,u):i.isSymbolicLink()?function(e,t,n,r,u){di.readlink(t,((t,o)=>t?u(t):(r.dereference&&(o=Di.resolve(process.cwd(),o)),e?void di.readlink(n,((t,i)=>t?"EINVAL"===t.code||"UNKNOWN"===t.code?di.symlink(o,n,u):u(t):(r.dereference&&(i=Di.resolve(process.cwd(),i)),hi.isSrcSubdir(o,i)?u(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`)):e.isDirectory()&&hi.isSrcSubdir(i,o)?u(new Error(`Cannot overwrite '${i}' with '${o}'.`)):function(e,t,n){di.unlink(t,(r=>r?n(r):di.symlink(e,t,n)))}(o,n,u)))):di.symlink(o,n,u))))}(e,t,n,r,u):void 0))}function Ai(e,t,n,r,u){return"function"==typeof di.copyFile?di.copyFile(t,n,(t=>t?u(t):vi(e,n,r,u))):function(e,t,n,r,u){const o=di.createReadStream(t);o.on("error",(e=>u(e))).once("open",(()=>{const t=di.createWriteStream(n,{mode:e.mode});t.on("error",(e=>u(e))).on("open",(()=>o.pipe(t))).once("close",(()=>vi(e,n,r,u)))}))}(e,t,n,r,u)}function vi(e,t,n,r){di.chmod(t,e.mode,(u=>u?r(u):n.preserveTimestamps?mi(t,e.atime,e.mtime,r):r()))}function Si(e,t,n,r){di.readdir(e,((u,o)=>u?r(u):wi(o,e,t,n,r)))}function wi(e,t,n,r,u){const o=e.pop();return o?function(e,t,n,r,u,o){const i=Di.join(n,t),s=Di.join(r,t);hi.checkPaths(i,s,"copy",((t,c)=>{if(t)return o(t);const{destStat:a}=c;Fi(a,i,s,u,(t=>t?o(t):wi(e,n,r,u,o)))}))}(e,o,t,n,r,u):u()}var Oi=function(e,t,n,r){"function"!=typeof n||r?"function"==typeof n&&(n={filter:n}):(r=n,n={}),r=r||function(){},(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),hi.checkPaths(e,t,"copy",((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;hi.checkParentPaths(e,i,t,"copy",(u=>u?r(u):n.filter?Ci(yi,s,e,t,n,r):yi(s,e,t,n,r)))}))};var bi={copy:(0,yo.fromCallback)(Oi)};const _i=we,Bi=p.default,Pi=g.default,ki="win32"===process.platform;function xi(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach((t=>{e[t]=e[t]||_i[t],e[t+="Sync"]=e[t]||_i[t]})),e.maxBusyTries=e.maxBusyTries||3}function Ni(e,t,n){let r=0;"function"==typeof t&&(n=t,t={}),Pi(e,"rimraf: missing path"),Pi.strictEqual(typeof e,"string","rimraf: path should be a string"),Pi.strictEqual(typeof n,"function","rimraf: callback function required"),Pi(t,"rimraf: invalid options argument provided"),Pi.strictEqual(typeof t,"object","rimraf: options should be object"),xi(t),Ii(e,t,(function u(o){if(o){if(("EBUSY"===o.code||"ENOTEMPTY"===o.code||"EPERM"===o.code)&&rIi(e,t,u)),100*r)}"ENOENT"===o.code&&(o=null)}n(o)}))}function Ii(e,t,n){Pi(e),Pi(t),Pi("function"==typeof n),t.lstat(e,((r,u)=>r&&"ENOENT"===r.code?n(null):r&&"EPERM"===r.code&&ki?Ti(e,t,r,n):u&&u.isDirectory()?Mi(e,t,r,n):void t.unlink(e,(r=>{if(r){if("ENOENT"===r.code)return n(null);if("EPERM"===r.code)return ki?Ti(e,t,r,n):Mi(e,t,r,n);if("EISDIR"===r.code)return Mi(e,t,r,n)}return n(r)}))))}function Ti(e,t,n,r){Pi(e),Pi(t),Pi("function"==typeof r),n&&Pi(n instanceof Error),t.chmod(e,438,(u=>{u?r("ENOENT"===u.code?null:n):t.stat(e,((u,o)=>{u?r("ENOENT"===u.code?null:n):o.isDirectory()?Mi(e,t,n,r):t.unlink(e,r)}))}))}function Ri(e,t,n){let r;Pi(e),Pi(t),n&&Pi(n instanceof Error);try{t.chmodSync(e,438)}catch(e){if("ENOENT"===e.code)return;throw n}try{r=t.statSync(e)}catch(e){if("ENOENT"===e.code)return;throw n}r.isDirectory()?ji(e,t,n):t.unlinkSync(e)}function Mi(e,t,n,r){Pi(e),Pi(t),n&&Pi(n instanceof Error),Pi("function"==typeof r),t.rmdir(e,(u=>{!u||"ENOTEMPTY"!==u.code&&"EEXIST"!==u.code&&"EPERM"!==u.code?u&&"ENOTDIR"===u.code?r(n):r(u):function(e,t,n){Pi(e),Pi(t),Pi("function"==typeof n),t.readdir(e,((r,u)=>{if(r)return n(r);let o,i=u.length;if(0===i)return t.rmdir(e,n);u.forEach((r=>{Ni(Bi.join(e,r),t,(r=>{if(!o)return r?n(o=r):void(0==--i&&t.rmdir(e,n))}))}))}))}(e,t,r)}))}function Li(e,t){let n;xi(t=t||{}),Pi(e,"rimraf: missing path"),Pi.strictEqual(typeof e,"string","rimraf: path should be a string"),Pi(t,"rimraf: missing options"),Pi.strictEqual(typeof t,"object","rimraf: options should be object");try{n=t.lstatSync(e)}catch(n){if("ENOENT"===n.code)return;"EPERM"===n.code&&ki&&Ri(e,t,n)}try{n&&n.isDirectory()?ji(e,t,null):t.unlinkSync(e)}catch(n){if("ENOENT"===n.code)return;if("EPERM"===n.code)return ki?Ri(e,t,n):ji(e,t,n);if("EISDIR"!==n.code)throw n;ji(e,t,n)}}function ji(e,t,n){Pi(e),Pi(t),n&&Pi(n instanceof Error);try{t.rmdirSync(e)}catch(r){if("ENOTDIR"===r.code)throw n;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(e,t){if(Pi(e),Pi(t),t.readdirSync(e).forEach((n=>Li(Bi.join(e,n),t))),!ki){return t.rmdirSync(e,t)}{const n=Date.now();do{try{return t.rmdirSync(e,t)}catch(e){}}while(Date.now()-n<500)}}(e,t);else if("ENOENT"!==r.code)throw r}}var $i=Ni;Ni.sync=Li;const Hi=$i;var Ji={remove:(0,yo.fromCallback)(Hi),removeSync:Hi.sync};const Gi=yo.fromCallback,Vi=we,Ui=p.default,Wi=Io,zi=Ji,Ki=Gi((function(e,t){t=t||function(){},Vi.readdir(e,((n,r)=>{if(n)return Wi.mkdirs(e,t);r=r.map((t=>Ui.join(e,t))),function e(){const n=r.pop();if(!n)return t();zi.remove(n,(n=>{if(n)return t(n);e()}))}()}))}));function qi(e){let t;try{t=Vi.readdirSync(e)}catch(t){return Wi.mkdirsSync(e)}t.forEach((t=>{t=Ui.join(e,t),zi.removeSync(t)}))}var Yi={emptyDirSync:qi,emptydirSync:qi,emptyDir:Ki,emptydir:Ki};const Xi=yo.fromCallback,Zi=p.default,Qi=we,es=Io,ts=fi.pathExists;var ns={createFile:Xi((function(e,t){function n(){Qi.writeFile(e,"",(e=>{if(e)return t(e);t()}))}Qi.stat(e,((r,u)=>{if(!r&&u.isFile())return t();const o=Zi.dirname(e);ts(o,((e,r)=>e?t(e):r?n():void es.mkdirs(o,(e=>{if(e)return t(e);n()}))))}))})),createFileSync:function(e){let t;try{t=Qi.statSync(e)}catch(e){}if(t&&t.isFile())return;const n=Zi.dirname(e);Qi.existsSync(n)||es.mkdirsSync(n),Qi.writeFileSync(e,"")}};const rs=yo.fromCallback,us=p.default,os=we,is=Io,ss=fi.pathExists;var cs={createLink:rs((function(e,t,n){function r(e,t){os.link(e,t,(e=>{if(e)return n(e);n(null)}))}ss(t,((u,o)=>u?n(u):o?n(null):void os.lstat(e,(u=>{if(u)return u.message=u.message.replace("lstat","ensureLink"),n(u);const o=us.dirname(t);ss(o,((u,i)=>u?n(u):i?r(e,t):void is.mkdirs(o,(u=>{if(u)return n(u);r(e,t)}))))}))))})),createLinkSync:function(e,t){if(os.existsSync(t))return;try{os.lstatSync(e)}catch(e){throw e.message=e.message.replace("lstat","ensureLink"),e}const n=us.dirname(t);return os.existsSync(n)||is.mkdirsSync(n),os.linkSync(e,t)}};const as=p.default,ls=we,fs=fi.pathExists;var ds={symlinkPaths:function(e,t,n){if(as.isAbsolute(e))return ls.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:e})));{const r=as.dirname(t),u=as.join(r,e);return fs(u,((t,o)=>t?n(t):o?n(null,{toCwd:u,toDst:e}):ls.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:as.relative(r,e)})))))}},symlinkPathsSync:function(e,t){let n;if(as.isAbsolute(e)){if(n=ls.existsSync(e),!n)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}{const r=as.dirname(t),u=as.join(r,e);if(n=ls.existsSync(u),n)return{toCwd:u,toDst:e};if(n=ls.existsSync(e),!n)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:as.relative(r,e)}}}};const Ds=we;var ps={symlinkType:function(e,t,n){if(n="function"==typeof t?t:n,t="function"!=typeof t&&t)return n(null,t);Ds.lstat(e,((e,r)=>{if(e)return n(null,"file");t=r&&r.isDirectory()?"dir":"file",n(null,t)}))},symlinkTypeSync:function(e,t){let n;if(t)return t;try{n=Ds.lstatSync(e)}catch(e){return"file"}return n&&n.isDirectory()?"dir":"file"}};const Es=yo.fromCallback,ms=p.default,hs=we,ys=Io.mkdirs,Cs=Io.mkdirsSync,Fs=ds.symlinkPaths,gs=ds.symlinkPathsSync,As=ps.symlinkType,vs=ps.symlinkTypeSync,Ss=fi.pathExists;var ws={createSymlink:Es((function(e,t,n,r){r="function"==typeof n?n:r,n="function"!=typeof n&&n,Ss(t,((u,o)=>u?r(u):o?r(null):void Fs(e,t,((u,o)=>{if(u)return r(u);e=o.toDst,As(o.toCwd,n,((n,u)=>{if(n)return r(n);const o=ms.dirname(t);Ss(o,((n,i)=>n?r(n):i?hs.symlink(e,t,u,r):void ys(o,(n=>{if(n)return r(n);hs.symlink(e,t,u,r)}))))}))}))))})),createSymlinkSync:function(e,t,n){if(hs.existsSync(t))return;const r=gs(e,t);e=r.toDst,n=vs(r.toCwd,n);const u=ms.dirname(t);return hs.existsSync(u)||Cs(u),hs.symlinkSync(e,t,n)}};var Os,bs={createFile:ns.createFile,createFileSync:ns.createFileSync,ensureFile:ns.createFile,ensureFileSync:ns.createFileSync,createLink:cs.createLink,createLinkSync:cs.createLinkSync,ensureLink:cs.createLink,ensureLinkSync:cs.createLinkSync,createSymlink:ws.createSymlink,createSymlinkSync:ws.createSymlinkSync,ensureSymlink:ws.createSymlink,ensureSymlinkSync:ws.createSymlinkSync};try{Os=we}catch(e){Os=D.default}function _s(e,t){var n,r="\n";return"object"==typeof t&&null!==t&&(t.spaces&&(n=t.spaces),t.EOL&&(r=t.EOL)),JSON.stringify(e,t?t.replacer:null,n).replace(/\n/g,r)+r}function Bs(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e=e.replace(/^\uFEFF/,"")}var Ps={readFile:function(e,t,n){null==n&&(n=t,t={}),"string"==typeof t&&(t={encoding:t});var r=(t=t||{}).fs||Os,u=!0;"throws"in t&&(u=t.throws),r.readFile(e,t,(function(r,o){if(r)return n(r);var i;o=Bs(o);try{i=JSON.parse(o,t?t.reviver:null)}catch(t){return u?(t.message=e+": "+t.message,n(t)):n(null,null)}n(null,i)}))},readFileSync:function(e,t){"string"==typeof(t=t||{})&&(t={encoding:t});var n=t.fs||Os,r=!0;"throws"in t&&(r=t.throws);try{var u=n.readFileSync(e,t);return u=Bs(u),JSON.parse(u,t.reviver)}catch(t){if(r)throw t.message=e+": "+t.message,t;return null}},writeFile:function(e,t,n,r){null==r&&(r=n,n={});var u=(n=n||{}).fs||Os,o="";try{o=_s(t,n)}catch(e){return void(r&&r(e,null))}u.writeFile(e,o,n,r)},writeFileSync:function(e,t,n){var r=(n=n||{}).fs||Os,u=_s(t,n);return r.writeFileSync(e,u,n)}},ks=Ps;const xs=yo.fromCallback,Ns=ks;var Is={readJson:xs(Ns.readFile),readJsonSync:Ns.readFileSync,writeJson:xs(Ns.writeFile),writeJsonSync:Ns.writeFileSync};const Ts=p.default,Rs=Io,Ms=fi.pathExists,Ls=Is;var js=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=Ts.dirname(e);Ms(u,((o,i)=>o?r(o):i?Ls.writeJson(e,t,n,r):void Rs.mkdirs(u,(u=>{if(u)return r(u);Ls.writeJson(e,t,n,r)}))))};const $s=we,Hs=p.default,Js=Io,Gs=Is;var Vs=function(e,t,n){const r=Hs.dirname(e);$s.existsSync(r)||Js.mkdirsSync(r),Gs.writeJsonSync(e,t,n)};const Us=yo.fromCallback,Ws=Is;Ws.outputJson=Us(js),Ws.outputJsonSync=Vs,Ws.outputJSON=Ws.outputJson,Ws.outputJSONSync=Ws.outputJsonSync,Ws.writeJSON=Ws.writeJson,Ws.writeJSONSync=Ws.writeJsonSync,Ws.readJSON=Ws.readJson,Ws.readJSONSync=Ws.readJsonSync;var zs=Ws;const Ks=we,qs=p.default,Ys=ci.copySync,Xs=Ji.removeSync,Zs=Io.mkdirpSync,Qs=Zo;function ec(e,t,n){try{Ks.renameSync(e,t)}catch(r){if("EXDEV"!==r.code)throw r;return function(e,t,n){const r={overwrite:n,errorOnExist:!0};return Ys(e,t,r),Xs(e)}(e,t,n)}}var tc=function(e,t,n){const r=(n=n||{}).overwrite||n.clobber||!1,{srcStat:u}=Qs.checkPathsSync(e,t,"move");return Qs.checkParentPathsSync(e,u,t,"move"),Zs(qs.dirname(t)),function(e,t,n){if(n)return Xs(t),ec(e,t,n);if(Ks.existsSync(t))throw new Error("dest already exists.");return ec(e,t,n)}(e,t,r)},nc={moveSync:tc};const rc=we,uc=p.default,oc=bi.copy,ic=Ji.remove,sc=Io.mkdirp,cc=fi.pathExists,ac=Zo;function lc(e,t,n,r){rc.rename(e,t,(u=>u?"EXDEV"!==u.code?r(u):function(e,t,n,r){const u={overwrite:n,errorOnExist:!0};oc(e,t,u,(t=>t?r(t):ic(e,r)))}(e,t,n,r):r()))}var fc=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=n.overwrite||n.clobber||!1;ac.checkPaths(e,t,"move",((n,o)=>{if(n)return r(n);const{srcStat:i}=o;ac.checkParentPaths(e,i,t,"move",(n=>{if(n)return r(n);sc(uc.dirname(t),(n=>n?r(n):function(e,t,n,r){if(n)return ic(t,(u=>u?r(u):lc(e,t,n,r)));cc(t,((u,o)=>u?r(u):o?r(new Error("dest already exists.")):lc(e,t,n,r)))}(e,t,u,r)))}))}))};var dc={move:(0,yo.fromCallback)(fc)};const Dc=yo.fromCallback,pc=we,Ec=p.default,mc=Io,hc=fi.pathExists;var yc={outputFile:Dc((function(e,t,n,r){"function"==typeof n&&(r=n,n="utf8");const u=Ec.dirname(e);hc(u,((o,i)=>o?r(o):i?pc.writeFile(e,t,n,r):void mc.mkdirs(u,(u=>{if(u)return r(u);pc.writeFile(e,t,n,r)}))))})),outputFileSync:function(e,...t){const n=Ec.dirname(e);if(pc.existsSync(n))return pc.writeFileSync(e,...t);mc.mkdirsSync(n),pc.writeFileSync(e,...t)}};!function(e){e.exports=Object.assign({},ho,ci,bi,Yi,bs,zs,Io,nc,dc,yc,fi,Ji);const t=D.default;Object.getOwnPropertyDescriptor(t,"promises")&&Object.defineProperty(e.exports,"promises",{get:()=>t.promises})}(mo);const Cc=Nr.exports("streamroller:fileNameFormatter"),Fc=p.default;const gc=Nr.exports("streamroller:fileNameParser"),Ac=nu.exports;const vc=Nr.exports("streamroller:moveAndMaybeCompressFile"),Sc=mo.exports,wc=v.default;var Oc=async(e,t,n)=>{if(n=function(e){const t={mode:parseInt("0600",8),compress:!1},n=Object.assign({},t,e);return vc(`_parseOption: moveAndMaybeCompressFile called with option=${JSON.stringify(n)}`),n}(n),e!==t){if(await Sc.pathExists(e))if(vc(`moveAndMaybeCompressFile: moving file from ${e} to ${t} ${n.compress?"with":"without"} compress`),n.compress)await new Promise(((r,u)=>{let o=!1;const i=Sc.createWriteStream(t,{mode:n.mode,flags:"wx"}).on("open",(()=>{o=!0;const t=Sc.createReadStream(e).on("open",(()=>{t.pipe(wc.createGzip()).pipe(i)})).on("error",(t=>{vc(`moveAndMaybeCompressFile: error reading ${e}`,t),i.destroy(t)}))})).on("finish",(()=>{vc(`moveAndMaybeCompressFile: finished compressing ${t}, deleting ${e}`),Sc.unlink(e).then(r).catch((t=>{vc(`moveAndMaybeCompressFile: error deleting ${e}, truncating instead`,t),Sc.truncate(e).then(r).catch((t=>{vc(`moveAndMaybeCompressFile: error truncating ${e}`,t),u(t)}))}))})).on("error",(e=>{o?(vc(`moveAndMaybeCompressFile: error writing ${t}, deleting`,e),Sc.unlink(t).then((()=>{u(e)})).catch((e=>{vc(`moveAndMaybeCompressFile: error deleting ${t}`,e),u(e)}))):(vc(`moveAndMaybeCompressFile: error creating ${t}`,e),u(e))}))})).catch((()=>{}));else{vc(`moveAndMaybeCompressFile: renaming ${e} to ${t}`);try{await Sc.move(e,t,{overwrite:!0})}catch(n){if(vc(`moveAndMaybeCompressFile: error renaming ${e} to ${t}`,n),"ENOENT"!==n.code){vc("moveAndMaybeCompressFile: trying copy+truncate instead");try{await Sc.copy(e,t,{overwrite:!0}),await Sc.truncate(e)}catch(e){vc("moveAndMaybeCompressFile: error copy+truncate",e)}}}}}else vc("moveAndMaybeCompressFile: source and target are the same, not doing anything")};const bc=Nr.exports("streamroller:RollingFileWriteStream"),_c=mo.exports,Bc=p.default,Pc=E.default,kc=()=>new Date,xc=nu.exports,{Writable:Nc}=C.default,Ic=({file:e,keepFileExt:t,needsIndex:n,alwaysIncludeDate:r,compress:u,fileNameSep:o})=>{let i=o||".";const s=Fc.join(e.dir,e.name),c=t=>t+e.ext,a=(e,t,r)=>!n&&r||!t?e:e+i+t,l=(e,t,n)=>(t>0||r)&&n?e+i+n:e,f=(e,t)=>t&&u?e+".gz":e,d=t?[l,a,c,f]:[c,l,a,f];return({date:e,index:t})=>(Cc(`_formatFileName: date=${e}, index=${t}`),d.reduce(((n,r)=>r(n,t,e)),s))},Tc=({file:e,keepFileExt:t,pattern:n,fileNameSep:r})=>{let u=r||".";const o="__NOT_MATCHING__";let i=[(e,t)=>e.endsWith(".gz")?(gc("it is gzipped"),t.isCompressed=!0,e.slice(0,-1*".gz".length)):e,t?t=>t.startsWith(e.name)&&t.endsWith(e.ext)?(gc("it starts and ends with the right things"),t.slice(e.name.length+1,-1*e.ext.length)):o:t=>t.startsWith(e.base)?(gc("it starts with the right things"),t.slice(e.base.length+1)):o,n?(e,t)=>{const r=e.split(u);let o=r[r.length-1];gc("items: ",r,", indexStr: ",o);let i=e;void 0!==o&&o.match(/^\d+$/)?(i=e.slice(0,-1*(o.length+1)),gc(`dateStr is ${i}`),n&&!i&&(i=o,o="0")):o="0";try{const r=Ac.parse(n,i,new Date(0,0));return Ac.asString(n,r)!==i?e:(t.index=parseInt(o,10),t.date=i,t.timestamp=r.getTime(),"")}catch(t){return gc(`Problem parsing ${i} as ${n}, error was: `,t),e}}:(e,t)=>e.match(/^\d+$/)?(gc("it has an index"),t.index=parseInt(e,10),""):e];return e=>{let t={filename:e,index:0,isCompressed:!1};return i.reduce(((e,n)=>n(e,t)),e)?null:t}},Rc=Oc;var Mc=class extends Nc{constructor(e,t){if(bc(`constructor: creating RollingFileWriteStream. path=${e}`),"string"!=typeof e||0===e.length)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(Bc.sep))throw new Error(`Filename is a directory: ${e}`);0===e.indexOf(`~${Bc.sep}`)&&(e=e.replace("~",Pc.homedir())),super(t),this.options=this._parseOption(t),this.fileObject=Bc.parse(e),""===this.fileObject.dir&&(this.fileObject=Bc.parse(Bc.join(process.cwd(),e))),this.fileFormatter=Ic({file:this.fileObject,alwaysIncludeDate:this.options.alwaysIncludePattern,needsIndex:this.options.maxSize 0`)}else delete n.maxSize;if(n.numBackups||0===n.numBackups){if(n.numBackups<0)throw new Error(`options.numBackups (${n.numBackups}) should be >= 0`);if(n.numBackups>=Number.MAX_SAFE_INTEGER)throw new Error(`options.numBackups (${n.numBackups}) should be < Number.MAX_SAFE_INTEGER`);n.numToKeep=n.numBackups+1}else if(n.numToKeep<=0)throw new Error(`options.numToKeep (${n.numToKeep}) should be > 0`);return bc(`_parseOption: creating stream with option=${JSON.stringify(n)}`),n}_final(e){this.currentFileStream.end("",this.options.encoding,e)}_write(e,t,n){this._shouldRoll().then((()=>{bc(`_write: writing chunk. file=${this.currentFileStream.path} state=${JSON.stringify(this.state)} chunk=${e}`),this.currentFileStream.write(e,t,(t=>{this.state.currentSize+=e.length,n(t)}))}))}async _shouldRoll(){(this._dateChanged()||this._tooBig())&&(bc(`_shouldRoll: rolling because dateChanged? ${this._dateChanged()} or tooBig? ${this._tooBig()}`),await this._roll())}_dateChanged(){return this.state.currentDate&&this.state.currentDate!==xc(this.options.pattern,kc())}_tooBig(){return this.state.currentSize>=this.options.maxSize}_roll(){return bc("_roll: closing the current stream"),new Promise(((e,t)=>{this.currentFileStream.end("",this.options.encoding,(()=>{this._moveOldFiles().then(e).catch(t)}))}))}async _moveOldFiles(){const e=await this._getExistingFiles();for(let t=(this.state.currentDate?e.filter((e=>e.date===this.state.currentDate)):e).length;t>=0;t--){bc(`_moveOldFiles: i = ${t}`);const e=this.fileFormatter({date:this.state.currentDate,index:t}),n=this.fileFormatter({date:this.state.currentDate,index:t+1}),r={compress:this.options.compress&&0===t,mode:this.options.mode};await Rc(e,n,r)}this.state.currentSize=0,this.state.currentDate=this.state.currentDate?xc(this.options.pattern,kc()):null,bc(`_moveOldFiles: finished rolling files. state=${JSON.stringify(this.state)}`),this._renewWriteStream(),await new Promise(((e,t)=>{this.currentFileStream.write("","utf8",(()=>{this._clean().then(e).catch(t)}))}))}async _getExistingFiles(){const e=await _c.readdir(this.fileObject.dir).catch((()=>[]));bc(`_getExistingFiles: files=${e}`);const t=e.map((e=>this.fileNameParser(e))).filter((e=>e)),n=e=>(e.timestamp?e.timestamp:kc().getTime())-e.index;return t.sort(((e,t)=>n(e)-n(t))),t}_renewWriteStream(){const e=this.fileFormatter({date:this.state.currentDate,index:0}),t=e=>{try{return _c.mkdirSync(e,{recursive:!0})}catch(n){if("ENOENT"===n.code)return t(Bc.dirname(e)),t(e);if("EEXIST"!==n.code&&"EROFS"!==n.code)throw n;try{if(_c.statSync(e).isDirectory())return e;throw n}catch(e){throw n}}};t(this.fileObject.dir);const n={flags:this.options.flags,encoding:this.options.encoding,mode:this.options.mode};var r,u;_c.appendFileSync(e,"",(r={...n},u="flags",r["flag"]=r[u],delete r[u],r)),this.currentFileStream=_c.createWriteStream(e,n),this.currentFileStream.on("error",(e=>{this.emit("error",e)}))}async _clean(){const e=await this._getExistingFiles();if(bc(`_clean: numToKeep = ${this.options.numToKeep}, existingFiles = ${e.length}`),bc("_clean: existing files are: ",e),this._tooManyFiles(e.length)){const n=e.slice(0,e.length-this.options.numToKeep).map((e=>Bc.format({dir:this.fileObject.dir,base:e.filename})));await(t=n,bc(`deleteFiles: files to delete: ${t}`),Promise.all(t.map((e=>_c.unlink(e).catch((t=>{bc(`deleteFiles: error when unlinking ${e}, ignoring. Error was ${t}`)}))))))}var t}_tooManyFiles(e){return this.options.numToKeep>0&&e>this.options.numToKeep}};const Lc=Mc;var jc=class extends Lc{constructor(e,t,n,r){r||(r={}),t&&(r.maxSize=t),r.numBackups||0===r.numBackups||(n||0===n||(n=1),r.numBackups=n),super(e,r),this.backups=r.numBackups,this.size=this.options.maxSize}get theStream(){return this.currentFileStream}};const $c=Mc;var Hc={RollingFileWriteStream:Mc,RollingFileStream:jc,DateRollingFileStream:class extends $c{constructor(e,t,n){t&&"object"==typeof t&&(n=t,t=null),n||(n={}),t||(t="yyyy-MM-dd"),n.pattern=t,n.numBackups||0===n.numBackups?n.daysToKeep=n.numBackups:(n.daysToKeep||0===n.daysToKeep?process.emitWarning("options.daysToKeep is deprecated due to the confusion it causes when used together with file size rolling. Please use options.numBackups instead.","DeprecationWarning","streamroller-DEP0001"):n.daysToKeep=1,n.numBackups=n.daysToKeep),super(e,n),this.mode=this.options.mode}get theStream(){return this.currentFileStream}}};const Jc=Nr.exports("log4js:file"),Gc=p.default,Vc=Hc,Uc=E.default.EOL;let Wc=!1;const zc=new Set;function Kc(){zc.forEach((e=>{e.sighupHandler()}))}function qc(e,t,n,r){const u=new Vc.RollingFileStream(e,t,n,r);return u.on("error",(t=>{console.error("log4js.fileAppender - Writing to file %s, error happened ",e,t)})),u.on("drain",(()=>{process.emit("log4js:pause",!1)})),u}Eo.configure=function(e,t){let n=t.basicLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),e.mode=e.mode||384,function(e,t,n,r,u,o){e=Gc.normalize(e),Jc("Creating file appender (",e,", ",n,", ",r=r||0===r?r:5,", ",u,", ",o,")");let i=qc(e,n,r,u);const s=function(e){if(i.writable){if(!0===u.removeColor){const t=/\x1b[[0-9;]*m/g;e.data=e.data.map((e=>"string"==typeof e?e.replace(t,""):e))}i.write(t(e,o)+Uc,"utf8")||process.emit("log4js:pause",!0)}};return s.reopen=function(){i.end((()=>{i=qc(e,n,r,u)}))},s.sighupHandler=function(){Jc("SIGHUP handler called."),s.reopen()},s.shutdown=function(e){zc.delete(s),0===zc.size&&Wc&&(process.removeListener("SIGHUP",Kc),Wc=!1),i.end("","utf-8",e)},zc.add(s),Wc||(process.on("SIGHUP",Kc),Wc=!0),s}(e.filename,n,e.maxLogSize,e.backups,e,e.timezoneOffset)};var Yc={};const Xc=Hc,Zc=E.default.EOL;function Qc(e,t,n,r,u){r.maxSize=r.maxLogSize;const o=function(e,t,n){const r=new Xc.DateRollingFileStream(e,t,n);return r.on("error",(t=>{console.error("log4js.dateFileAppender - Writing to file %s, error happened ",e,t)})),r.on("drain",(()=>{process.emit("log4js:pause",!1)})),r}(e,t,r),i=function(e){o.writable&&(o.write(n(e,u)+Zc,"utf8")||process.emit("log4js:pause",!0))};return i.shutdown=function(e){o.end("","utf-8",e)},i}Yc.configure=function(e,t){let n=t.basicLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),e.alwaysIncludePattern||(e.alwaysIncludePattern=!1),e.mode=e.mode||384,Qc(e.filename,e.pattern,n,e,e.timezoneOffset)};var ea={};const ta=Nr.exports("log4js:fileSync"),na=p.default,ra=D.default,ua=E.default.EOL||"\n";function oa(e,t){if(ra.existsSync(e))return;const n=ra.openSync(e,t.flags,t.mode);ra.closeSync(n)}class ia{constructor(e,t,n,r){ta("In RollingFileStream"),function(){if(!e||!t||t<=0)throw new Error("You must specify a filename and file size")}(),this.filename=e,this.size=t,this.backups=n,this.options=r,this.currentSize=0,this.currentSize=function(e){let t=0;try{t=ra.statSync(e).size}catch(t){oa(e,r)}return t}(this.filename)}shouldRoll(){return ta("should roll with current size %d, and max size %d",this.currentSize,this.size),this.currentSize>=this.size}roll(e){const t=this,n=new RegExp(`^${na.basename(e)}`);function r(e){return n.test(e)}function u(t){return parseInt(t.substring(`${na.basename(e)}.`.length),10)||0}function o(e,t){return u(e)>u(t)?1:u(e) ${e}.${r+1}`),ra.renameSync(na.join(na.dirname(e),n),`${e}.${r+1}`)}}ta("Rolling, rolling, rolling"),ta("Renaming the old files"),ra.readdirSync(na.dirname(e)).filter(r).sort(o).reverse().forEach(i)}write(e,t){const n=this;ta("in write"),this.shouldRoll()&&(this.currentSize=0,this.roll(this.filename)),ta("writing the chunk to the file"),n.currentSize+=e.length,ra.appendFileSync(n.filename,e)}}ea.configure=function(e,t){let n=t.basicLayout;e.layout&&(n=t.layout(e.layout.type,e.layout));const r={flags:e.flags||"a",encoding:e.encoding||"utf8",mode:e.mode||384};return function(e,t,n,r,u,o){ta("fileSync appender created");const i=function(e,t,n){let r;var u;return t?r=new ia(e,t,n,o):(oa(u=e,o),r={write(e){ra.appendFileSync(u,e)}}),r}(e=na.normalize(e),n,r=r||0===r?r:5);return e=>{i.write(t(e,u)+ua)}}(e.filename,n,e.maxLogSize,e.backups,e.timezoneOffset,r)};var sa={};const ca=Nr.exports("log4js:tcp"),aa=S.default;sa.configure=function(e,t){ca(`configure with config = ${e}`);let n=function(e){return e.serialise()};return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){let n=!1;const r=[];let u,o=3,i="__LOG4JS__";function s(e){ca("Writing log event to socket"),n=u.write(`${t(e)}${i}`,"utf8")}function c(){let e;for(ca("emptying buffer");e=r.shift();)s(e)}function a(e){n?s(e):(ca("buffering log event because it cannot write at the moment"),r.push(e))}return function t(){ca(`appender creating socket to ${e.host||"localhost"}:${e.port||5e3}`),i=`${e.endMsg||"__LOG4JS__"}`,u=aa.createConnection(e.port||5e3,e.host||"localhost"),u.on("connect",(()=>{ca("socket connected"),c(),n=!0})),u.on("drain",(()=>{ca("drain event received, emptying buffer"),n=!0,c()})),u.on("timeout",u.end.bind(u)),u.on("error",(e=>{ca("connection error",e),n=!1,c()})),u.on("close",t)}(),a.shutdown=function(e){ca("shutdown called"),r.length&&o?(ca("buffer has items, waiting 100ms to empty"),o-=1,setTimeout((()=>{a.shutdown(e)}),100)):(u.removeAllListeners("close"),u.end(e))},a}(e,n)};const la=p.default,fa=Nr.exports("log4js:appenders"),da=tu,Da=eo,pa=gu,Ea=hu,ma=to,ha=new Map;ha.set("console",oo),ha.set("stdout",so),ha.set("stderr",co),ha.set("logLevelFilter",ao),ha.set("categoryFilter",lo),ha.set("noLogFilter",Do),ha.set("file",Eo),ha.set("dateFile",Yc),ha.set("fileSync",ea),ha.set("tcp",sa);const ya=new Map,Ca=(e,t)=>{fa("Loading module from ",e);try{return require(e)}catch(n){return void da.throwExceptionIf(t,"MODULE_NOT_FOUND"!==n.code,`appender "${e}" could not be loaded (error was: ${n})`)}},Fa=new Set,ga=(e,t)=>{if(ya.has(e))return ya.get(e);if(!t.appenders[e])return!1;if(Fa.has(e))throw new Error(`Dependency loop detected for appender ${e}.`);Fa.add(e),fa(`Creating appender ${e}`);const n=Aa(e,t);return Fa.delete(e),ya.set(e,n),n},Aa=(e,t)=>{const n=t.appenders[e],r=n.type.configure?n.type:((e,t)=>ha.get(e)||Ca(`./${e}`,t)||Ca(e,t)||require.main&&Ca(la.join(la.dirname(require.main.filename),e),t)||Ca(la.join(process.cwd(),e),t))(n.type,t);return da.throwExceptionIf(t,da.not(r),`appender "${e}" is not valid (type "${n.type}" could not be found)`),r.appender&&fa(`DEPRECATION: Appender ${n.type} exports an appender function.`),r.shutdown&&fa(`DEPRECATION: Appender ${n.type} exports a shutdown function.`),fa(`${e}: clustering.isMaster ? ${Da.isMaster()}`),fa(`${e}: appenderModule is ${F.default.inspect(r)}`),Da.onlyOnMaster((()=>(fa(`calling appenderModule.configure for ${e} / ${n.type}`),r.configure(ma.modifyConfig(n),Ea,(e=>ga(e,t)),pa))),(()=>{}))},va=e=>{ya.clear(),Fa.clear();const t=[];Object.values(e.categories).forEach((e=>{t.push(...e.appenders)})),Object.keys(e.appenders).forEach((n=>{(t.includes(n)||"tcp-server"===e.appenders[n].type)&&ga(n,e)}))},Sa=()=>{va({appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"trace"}}})};Sa(),da.addListener((e=>{da.throwExceptionIf(e,da.not(da.anObject(e.appenders)),'must have a property "appenders" of type object.');const t=Object.keys(e.appenders);da.throwExceptionIf(e,da.not(t.length),"must define at least one appender."),t.forEach((t=>{da.throwExceptionIf(e,da.not(e.appenders[t].type),`appender "${t}" is not valid (must be an object with property "type")`)}))})),da.addListener(va),Au.exports=ya,Au.exports.init=Sa;var wa={exports:{}};!function(e){const t=Nr.exports("log4js:categories"),n=tu,r=gu,u=Au.exports,o=new Map;function i(e,t,n){if(!1===t.inherit)return;const r=n.lastIndexOf(".");if(r<0)return;const u=n.substring(0,r);let o=e.categories[u];o||(o={inherit:!0,appenders:[]}),i(e,o,u),!e.categories[u]&&o.appenders&&o.appenders.length&&o.level&&(e.categories[u]=o),t.appenders=t.appenders||[],t.level=t.level||o.level,o.appenders.forEach((e=>{t.appenders.includes(e)||t.appenders.push(e)})),t.parent=o}function s(e){if(!e.categories)return;Object.keys(e.categories).forEach((t=>{const n=e.categories[t];i(e,n,t)}))}n.addPreProcessingListener((e=>s(e))),n.addListener((e=>{n.throwExceptionIf(e,n.not(n.anObject(e.categories)),'must have a property "categories" of type object.');const t=Object.keys(e.categories);n.throwExceptionIf(e,n.not(t.length),"must define at least one category."),t.forEach((t=>{const o=e.categories[t];n.throwExceptionIf(e,[n.not(o.appenders),n.not(o.level)],`category "${t}" is not valid (must be an object with properties "appenders" and "level")`),n.throwExceptionIf(e,n.not(Array.isArray(o.appenders)),`category "${t}" is not valid (appenders must be an array of appender names)`),n.throwExceptionIf(e,n.not(o.appenders.length),`category "${t}" is not valid (appenders must contain at least one appender name)`),Object.prototype.hasOwnProperty.call(o,"enableCallStack")&&n.throwExceptionIf(e,"boolean"!=typeof o.enableCallStack,`category "${t}" is not valid (enableCallStack must be boolean type)`),o.appenders.forEach((r=>{n.throwExceptionIf(e,n.not(u.get(r)),`category "${t}" is not valid (appender "${r}" is not defined)`)})),n.throwExceptionIf(e,n.not(r.getLevel(o.level)),`category "${t}" is not valid (level "${o.level}" not recognised; valid levels are ${r.levels.join(", ")})`)})),n.throwExceptionIf(e,n.not(e.categories.default),'must define a "default" category.')}));const c=e=>{o.clear();Object.keys(e.categories).forEach((n=>{const i=e.categories[n],s=[];i.appenders.forEach((e=>{s.push(u.get(e)),t(`Creating category ${n}`),o.set(n,{appenders:s,level:r.getLevel(i.level),enableCallStack:i.enableCallStack||!1})}))}))},a=()=>{c({categories:{default:{appenders:["out"],level:"OFF"}}})};a(),n.addListener(c);const l=e=>(t(`configForCategory: searching for config for ${e}`),o.has(e)?(t(`configForCategory: ${e} exists in config, returning it`),o.get(e)):e.indexOf(".")>0?(t(`configForCategory: ${e} has hierarchy, searching for parents`),l(e.substring(0,e.lastIndexOf(".")))):(t("configForCategory: returning config for default category"),l("default")));e.exports=o,e.exports=Object.assign(e.exports,{appendersForCategory:e=>l(e).appenders,getLevelForCategory:e=>l(e).level,setLevelForCategory:(e,n)=>{let r=o.get(e);if(t(`setLevelForCategory: found ${r} for ${e}`),!r){const n=l(e);t(`setLevelForCategory: no config found for category, found ${n} for parents of ${e}`),r={appenders:n.appenders}}r.level=n,o.set(e,r)},getEnableCallStackForCategory:e=>!0===l(e).enableCallStack,setEnableCallStackForCategory:(e,t)=>{l(e).enableCallStack=t},init:a})}(wa);const Oa=Nr.exports("log4js:logger"),ba=Hu,_a=gu,Ba=eo,Pa=wa.exports,ka=tu,xa=/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/;function Na(e,t=4){const n=e.stack.split("\n").slice(t),r=xa.exec(n[0]);return r&&6===r.length?{functionName:r[1],fileName:r[2],lineNumber:parseInt(r[3],10),columnNumber:parseInt(r[4],10),callStack:n.join("\n")}:null}class Ia{constructor(e){if(!e)throw new Error("No category provided.");this.category=e,this.context={},this.parseCallStack=Na,Oa(`Logger created (${this.category}, ${this.level})`)}get level(){return _a.getLevel(Pa.getLevelForCategory(this.category),_a.TRACE)}set level(e){Pa.setLevelForCategory(this.category,_a.getLevel(e,this.level))}get useCallStack(){return Pa.getEnableCallStackForCategory(this.category)}set useCallStack(e){Pa.setEnableCallStackForCategory(this.category,!0===e)}log(e,...t){let n=_a.getLevel(e);n||(this._log(_a.WARN,"log4js:logger.log: invalid value for log-level as first parameter given: ",e),n=_a.INFO),this.isLevelEnabled(n)&&this._log(n,t)}isLevelEnabled(e){return this.level.isLessThanOrEqualTo(e)}_log(e,t){Oa(`sending log data (${e}) to appenders`);const n=new ba(this.category,e,t,this.context,this.useCallStack&&this.parseCallStack(new Error));Ba.send(n)}addContext(e,t){this.context[e]=t}removeContext(e){delete this.context[e]}clearContext(){this.context={}}setParseCallStackFunction(e){this.parseCallStack=e}}function Ta(e){const t=_a.getLevel(e),n=t.toString().toLowerCase().replace(/_([a-z])/g,(e=>e[1].toUpperCase())),r=n[0].toUpperCase()+n.slice(1);Ia.prototype[`is${r}Enabled`]=function(){return this.isLevelEnabled(t)},Ia.prototype[n]=function(...e){this.log(t,...e)}}_a.levels.forEach(Ta),ka.addListener((()=>{_a.levels.forEach(Ta)}));var Ra=Ia;const Ma=gu;function La(e){return e.originalUrl||e.url}function ja(e,t){for(let n=0;ne.source?e.source:e));t=new RegExp(n.join("|"))}return t}(t.nolog);return(e,i,s)=>{if(e._logging)return s();if(o&&o.test(e.originalUrl))return s();if(n.isLevelEnabled(r)||"auto"===t.level){const o=new Date,{writeHead:s}=i;e._logging=!0,i.writeHead=(e,t)=>{i.writeHead=s,i.writeHead(e,t),i.__statusCode=e,i.__headers=t||{}},i.on("finish",(()=>{i.responseTime=new Date-o,i.statusCode&&"auto"===t.level&&(r=Ma.INFO,i.statusCode>=300&&(r=Ma.WARN),i.statusCode>=400&&(r=Ma.ERROR)),r=function(e,t,n){let r=t;if(n){const t=n.find((t=>{let n=!1;return n=t.from&&t.to?e>=t.from&&e<=t.to:-1!==t.codes.indexOf(e),n}));t&&(r=Ma.getLevel(t.level,r))}return r}(i.statusCode,r,t.statusRules);const s=function(e,t,n){const r=[];return r.push({token:":url",replacement:La(e)}),r.push({token:":protocol",replacement:e.protocol}),r.push({token:":hostname",replacement:e.hostname}),r.push({token:":method",replacement:e.method}),r.push({token:":status",replacement:t.__statusCode||t.statusCode}),r.push({token:":response-time",replacement:t.responseTime}),r.push({token:":date",replacement:(new Date).toUTCString()}),r.push({token:":referrer",replacement:e.headers.referer||e.headers.referrer||""}),r.push({token:":http-version",replacement:`${e.httpVersionMajor}.${e.httpVersionMinor}`}),r.push({token:":remote-addr",replacement:e.headers["x-forwarded-for"]||e.ip||e._remoteAddress||e.socket&&(e.socket.remoteAddress||e.socket.socket&&e.socket.socket.remoteAddress)}),r.push({token:":user-agent",replacement:e.headers["user-agent"]}),r.push({token:":content-length",replacement:t.getHeader("content-length")||t.__headers&&t.__headers["Content-Length"]||"-"}),r.push({token:/:req\[([^\]]+)]/g,replacement:(t,n)=>e.headers[n.toLowerCase()]}),r.push({token:/:res\[([^\]]+)]/g,replacement:(e,n)=>t.getHeader(n.toLowerCase())||t.__headers&&t.__headers[n]}),(e=>{const t=e.concat();for(let e=0;eja(e,s)));t&&n.log(r,t)}else n.log(r,ja(u,s));t.context&&n.removeContext("res")}))}return s()}},nl=Va;let rl=!1;function ul(e){if(!rl)return;Ua("Received log event ",e);Za.appendersForCategory(e.categoryName).forEach((t=>{t(e)}))}function ol(e){rl&&il();let t=e;return"string"==typeof t&&(t=function(e){Ua(`Loading configuration from ${e}`);try{return JSON.parse(Wa.readFileSync(e,"utf8"))}catch(t){throw new Error(`Problem reading config from file "${e}". Error was ${t.message}`,t)}}(e)),Ua(`Configuration is ${t}`),Ka.configure(za(t)),el.onMessage(ul),rl=!0,sl}function il(e){Ua("Shutdown called. Disabling all log writing."),rl=!1;const t=Array.from(Xa.values());Xa.init(),Za.init();const n=t.reduceRight(((e,t)=>t.shutdown?e+1:e),0);if(0===n)return Ua("No appenders with shutdown functions found."),void 0!==e&&e();let r,u=0;function o(t){r=r||t,u+=1,Ua(`Appender shutdowns complete: ${u} / ${n}`),u>=n&&(Ua("All shutdown functions completed."),e&&e(r))}return Ua(`Found ${n} appenders with shutdown functions.`),t.filter((e=>e.shutdown)).forEach((e=>e.shutdown(o))),null}const sl={getLogger:function(e){return rl||ol(process.env.LOG4JS_CONFIG||{appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"OFF"}}}),new Qa(e||"default")},configure:ol,shutdown:il,connectLogger:tl,levels:Ya,addLayout:qa.addLayout,recording:function(){return nl}};var cl=sl,al={};Object.defineProperty(al,"__esModule",{value:!0}),al.levelMap=al.getLevel=al.setCategoriesLevel=al.getConfiguration=al.setConfiguration=void 0;const ll=cl;let fl={appenders:{debug:{type:"stdout",layout:{type:"pattern",pattern:"[%d] > hvigor %p %c %[%m%]"}},info:{type:"stdout",layout:{type:"pattern",pattern:"[%d] > hvigor %[%m%]"}},"no-pattern-info":{type:"stdout",layout:{type:"pattern",pattern:"%m"}},wrong:{type:"stderr",layout:{type:"pattern",pattern:"[%d] > hvigor %[%p: %m%]"}},"just-debug":{type:"logLevelFilter",appender:"debug",level:"debug",maxLevel:"debug"},"just-info":{type:"logLevelFilter",appender:"info",level:"info",maxLevel:"info"},"just-wrong":{type:"logLevelFilter",appender:"wrong",level:"warn",maxLevel:"error"}},categories:{default:{appenders:["just-debug","just-info","just-wrong"],level:"debug"},"no-pattern-info":{appenders:["no-pattern-info"],level:"info"}}};al.setConfiguration=e=>{fl=e};al.getConfiguration=()=>fl;let dl=ll.levels.DEBUG;al.setCategoriesLevel=(e,t)=>{dl=e;const n=fl.categories;for(const r in n)(null==t?void 0:t.includes(r))||Object.prototype.hasOwnProperty.call(n,r)&&(n[r].level=e.levelStr)};al.getLevel=()=>dl,al.levelMap=new Map([["ALL",ll.levels.ALL],["MARK",ll.levels.MARK],["TRACE",ll.levels.TRACE],["DEBUG",ll.levels.DEBUG],["INFO",ll.levels.INFO],["WARN",ll.levels.WARN],["ERROR",ll.levels.ERROR],["FATAL",ll.levels.FATAL],["OFF",ll.levels.OFF]]);var Dl=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),pl=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),El=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&Dl(t,e,n);return pl(t,e),t};Object.defineProperty(xr,"__esModule",{value:!0}),xr.evaluateLogLevel=xr.HvigorLogger=void 0;const ml=El(cl),hl=cl,yl=El(F.default),Cl=al;class Fl{constructor(e){ml.configure((0,Cl.getConfiguration)()),this._logger=ml.getLogger(e),this._logger.level=(0,Cl.getLevel)()}static getLogger(e){return new Fl(e)}log(e,...t){this._logger.log(e,...t)}debug(e,...t){this._logger.debug(e,...t)}info(e,...t){this._logger.info(e,...t)}warn(e,...t){void 0!==e&&""!==e&&this._logger.warn(e,...t)}error(e,...t){this._logger.error(e,...t)}_printTaskExecuteInfo(e,t){this.info(`Finished :${e}... after ${t}`)}_printFailedTaskInfo(e){this.error(`Failed :${e}... `)}_printDisabledTaskInfo(e){this.info(`Disabled :${e}... `)}_printUpToDateTaskInfo(e){this.info(`UP-TO-DATE :${e}... `)}errorMessageExit(e,...t){throw new Error(yl.format(e,...t))}errorExit(e,t,...n){t&&this._logger.error(t,n),this._logger.error(e.stack)}setLevel(e,t){(0,Cl.setCategoriesLevel)(e,t),ml.shutdown(),ml.configure((0,Cl.getConfiguration)())}getLevel(){return this._logger.level}configure(e){const t=(0,Cl.getConfiguration)(),n={appenders:{...t.appenders,...e.appenders},categories:{...t.categories,...e.categories}};(0,Cl.setConfiguration)(n),ml.shutdown(),ml.configure(n)}}xr.HvigorLogger=Fl,xr.evaluateLogLevel=function(e,t){t.debug?e.setLevel(hl.levels.DEBUG):t.warn?e.setLevel(hl.levels.WARN):t.error?e.setLevel(hl.levels.ERROR):e.setLevel(hl.levels.INFO)};var gl=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(X,"__esModule",{value:!0}),X.parseJsonText=X.parseJsonFile=void 0;const Al=Z,vl=gl(kr),Sl=gl(p.default),wl=gl(E.default),Ol=xr.HvigorLogger.getLogger("parse-json-util");var bl;!function(e){e[e.Char=0]="Char",e[e.EOF=1]="EOF",e[e.Identifier=2]="Identifier"}(bl||(bl={}));let _l,Bl,Pl,kl,xl,Nl,Il="start",Tl=[],Rl=0,Ml=1,Ll=0,jl=!1,$l="default",Hl="'",Jl=1;function Gl(e,t=!1){Bl=String(e),Il="start",Tl=[],Rl=0,Ml=1,Ll=0,kl=void 0,jl=t;do{_l=Vl(),Xl[Il]()}while("eof"!==_l.type);return kl}function Vl(){for($l="default",xl="",Hl="'",Jl=1;;){Nl=Ul();const e=zl[$l]();if(e)return e}}function Ul(){if(Bl[Rl])return String.fromCodePoint(Bl.codePointAt(Rl))}function Wl(){const e=Ul();return"\n"===e?(Ml++,Ll=0):e?Ll+=e.length:Ll++,e&&(Rl+=e.length),e}X.parseJsonFile=function(e,t=!1,n="utf-8"){const r=vl.default.readFileSync(Sl.default.resolve(e),{encoding:n});try{return Gl(r,t)}catch(t){if(t instanceof SyntaxError){const n=t.message.split("at");2===n.length&&Ol.errorMessageExit(`${n[0].trim()}${wl.default.EOL}\t at ${e}:${n[1].trim()}`)}Ol.errorMessageExit(`${e} is not in valid JSON/JSON5 format.`)}},X.parseJsonText=Gl;const zl={default(){switch(Nl){case"/":return Wl(),void($l="comment");case void 0:return Wl(),Kl("eof")}if(!Al.JudgeUtil.isIgnoreChar(Nl)&&!Al.JudgeUtil.isSpaceSeparator(Nl))return zl[Il]();Wl()},start(){$l="value"},beforePropertyName(){switch(Nl){case"$":case"_":return xl=Wl(),void($l="identifierName");case"\\":return Wl(),void($l="identifierNameStartEscape");case"}":return Kl("punctuator",Wl());case'"':case"'":return Hl=Nl,Wl(),void($l="string")}if(Al.JudgeUtil.isIdStartChar(Nl))return xl+=Wl(),void($l="identifierName");throw tf(bl.Char,Wl())},afterPropertyName(){if(":"===Nl)return Kl("punctuator",Wl());throw tf(bl.Char,Wl())},beforePropertyValue(){$l="value"},afterPropertyValue(){switch(Nl){case",":case"}":return Kl("punctuator",Wl())}throw tf(bl.Char,Wl())},beforeArrayValue(){if("]"===Nl)return Kl("punctuator",Wl());$l="value"},afterArrayValue(){switch(Nl){case",":case"]":return Kl("punctuator",Wl())}throw tf(bl.Char,Wl())},end(){throw tf(bl.Char,Wl())},comment(){switch(Nl){case"*":return Wl(),void($l="multiLineComment");case"/":return Wl(),void($l="singleLineComment")}throw tf(bl.Char,Wl())},multiLineComment(){switch(Nl){case"*":return Wl(),void($l="multiLineCommentAsterisk");case void 0:throw tf(bl.Char,Wl())}Wl()},multiLineCommentAsterisk(){switch(Nl){case"*":return void Wl();case"/":return Wl(),void($l="default");case void 0:throw tf(bl.Char,Wl())}Wl(),$l="multiLineComment"},singleLineComment(){switch(Nl){case"\n":case"\r":case"\u2028":case"\u2029":return Wl(),void($l="default");case void 0:return Wl(),Kl("eof")}Wl()},value(){switch(Nl){case"{":case"[":return Kl("punctuator",Wl());case"n":return Wl(),ql("ull"),Kl("null",null);case"t":return Wl(),ql("rue"),Kl("boolean",!0);case"f":return Wl(),ql("alse"),Kl("boolean",!1);case"-":case"+":return"-"===Wl()&&(Jl=-1),void($l="numerical");case".":case"0":case"I":case"N":return void($l="numerical");case'"':case"'":return Hl=Nl,Wl(),xl="",void($l="string")}if(void 0===Nl||!Al.JudgeUtil.isDigitWithoutZero(Nl))throw tf(bl.Char,Wl());$l="numerical"},numerical(){switch(Nl){case".":return xl=Wl(),void($l="decimalPointLeading");case"0":return xl=Wl(),void($l="zero");case"I":return Wl(),ql("nfinity"),Kl("numeric",Jl*(1/0));case"N":return Wl(),ql("aN"),Kl("numeric",NaN)}if(void 0!==Nl&&Al.JudgeUtil.isDigitWithoutZero(Nl))return xl=Wl(),void($l="decimalInteger");throw tf(bl.Char,Wl())},zero(){switch(Nl){case".":case"e":case"E":return void($l="decimal");case"x":case"X":return xl+=Wl(),void($l="hexadecimal")}return Kl("numeric",0)},decimalInteger(){switch(Nl){case".":case"e":case"E":return void($l="decimal")}if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},decimal(){switch(Nl){case".":xl+=Wl(),$l="decimalFraction";break;case"e":case"E":xl+=Wl(),$l="decimalExponent"}},decimalPointLeading(){if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalFraction");throw tf(bl.Char,Wl())},decimalFraction(){switch(Nl){case"e":case"E":return xl+=Wl(),void($l="decimalExponent")}if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},decimalExponent(){switch(Nl){case"+":case"-":return xl+=Wl(),void($l="decimalExponentSign")}if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalExponentInteger");throw tf(bl.Char,Wl())},decimalExponentSign(){if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalExponentInteger");throw tf(bl.Char,Wl())},decimalExponentInteger(){if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},hexadecimal(){if(Al.JudgeUtil.isHexDigit(Nl))return xl+=Wl(),void($l="hexadecimalInteger");throw tf(bl.Char,Wl())},hexadecimalInteger(){if(!Al.JudgeUtil.isHexDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},identifierNameStartEscape(){if("u"!==Nl)throw tf(bl.Char,Wl());Wl();const e=Yl();switch(e){case"$":case"_":break;default:if(!Al.JudgeUtil.isIdStartChar(e))throw tf(bl.Identifier)}xl+=e,$l="identifierName"},identifierName(){switch(Nl){case"$":case"_":case"‌":case"‍":return void(xl+=Wl());case"\\":return Wl(),void($l="identifierNameEscape")}if(!Al.JudgeUtil.isIdContinueChar(Nl))return Kl("identifier",xl);xl+=Wl()},identifierNameEscape(){if("u"!==Nl)throw tf(bl.Char,Wl());Wl();const e=Yl();switch(e){case"$":case"_":case"‌":case"‍":break;default:if(!Al.JudgeUtil.isIdContinueChar(e))throw tf(bl.Identifier)}xl+=e,$l="identifierName"},string(){switch(Nl){case"\\":return Wl(),void(xl+=function(){const e=Ul(),t=function(){switch(Ul()){case"b":return Wl(),"\b";case"f":return Wl(),"\f";case"n":return Wl(),"\n";case"r":return Wl(),"\r";case"t":return Wl(),"\t";case"v":return Wl(),"\v"}return}();if(t)return t;switch(e){case"0":if(Wl(),Al.JudgeUtil.isDigit(Ul()))throw tf(bl.Char,Wl());return"\0";case"x":return Wl(),function(){let e="",t=Ul();if(!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());if(e+=Wl(),t=Ul(),!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());return e+=Wl(),String.fromCodePoint(parseInt(e,16))}();case"u":return Wl(),Yl();case"\n":case"\u2028":case"\u2029":return Wl(),"";case"\r":return Wl(),"\n"===Ul()&&Wl(),""}if(void 0===e||Al.JudgeUtil.isDigitWithoutZero(e))throw tf(bl.Char,Wl());return Wl()}());case'"':case"'":if(Nl===Hl){const e=Kl("string",xl);return Wl(),e}return void(xl+=Wl());case"\n":case"\r":case void 0:throw tf(bl.Char,Wl());case"\u2028":case"\u2029":!function(e){Ol.warn(`JSON5: '${ef(e)}' in strings is not valid ECMAScript; consider escaping.`)}(Nl)}xl+=Wl()}};function Kl(e,t){return{type:e,value:t,line:Ml,column:Ll}}function ql(e){for(const t of e){if(Ul()!==t)throw tf(bl.Char,Wl());Wl()}}function Yl(){let e="",t=4;for(;t-- >0;){const t=Ul();if(!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());e+=Wl()}return String.fromCodePoint(parseInt(e,16))}const Xl={start(){if("eof"===_l.type)throw tf(bl.EOF);Zl()},beforePropertyName(){switch(_l.type){case"identifier":case"string":return Pl=_l.value,void(Il="afterPropertyName");case"punctuator":return void Ql();case"eof":throw tf(bl.EOF)}},afterPropertyName(){if("eof"===_l.type)throw tf(bl.EOF);Il="beforePropertyValue"},beforePropertyValue(){if("eof"===_l.type)throw tf(bl.EOF);Zl()},afterPropertyValue(){if("eof"===_l.type)throw tf(bl.EOF);switch(_l.value){case",":return void(Il="beforePropertyName");case"}":Ql()}},beforeArrayValue(){if("eof"===_l.type)throw tf(bl.EOF);"punctuator"!==_l.type||"]"!==_l.value?Zl():Ql()},afterArrayValue(){if("eof"===_l.type)throw tf(bl.EOF);switch(_l.value){case",":return void(Il="beforeArrayValue");case"]":Ql()}},end(){}};function Zl(){const e=function(){let e;switch(_l.type){case"punctuator":switch(_l.value){case"{":e={};break;case"[":e=[]}break;case"null":case"boolean":case"numeric":case"string":e=_l.value}return e}();if(jl&&"object"==typeof e&&(e._line=Ml,e._column=Ll),void 0===kl)kl=e;else{const t=Tl[Tl.length-1];Array.isArray(t)?jl&&"object"!=typeof e?t.push({value:e,_line:Ml,_column:Ll}):t.push(e):t[Pl]=jl&&"object"!=typeof e?{value:e,_line:Ml,_column:Ll}:e}!function(e){if(e&&"object"==typeof e)Tl.push(e),Il=Array.isArray(e)?"beforeArrayValue":"beforePropertyName";else{const e=Tl[Tl.length-1];Il=e?Array.isArray(e)?"afterArrayValue":"afterPropertyValue":"end"}}(e)}function Ql(){Tl.pop();const e=Tl[Tl.length-1];Il=e?Array.isArray(e)?"afterArrayValue":"afterPropertyValue":"end"}function ef(e){const t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){const t=e.charCodeAt(0).toString(16);return`\\x${`00${t}`.substring(t.length)}`}return e}function tf(e,t){let n="";switch(e){case bl.Char:n=void 0===t?`JSON5: invalid end of input at ${Ml}:${Ll}`:`JSON5: invalid character '${ef(t)}' at ${Ml}:${Ll}`;break;case bl.EOF:n=`JSON5: invalid end of input at ${Ml}:${Ll}`;break;case bl.Identifier:Ll-=5,n=`JSON5: invalid identifier character at ${Ml}:${Ll}`}const r=new nf(n);return r.lineNumber=Ml,r.columnNumber=Ll,r}class nf extends SyntaxError{}var rf=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),uf=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),of=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&rf(t,e,n);return uf(t,e),t};Object.defineProperty(Y,"__esModule",{value:!0});var sf=Y.cleanWorkSpace=Ff=Y.executeInstallHvigor=yf=Y.isHvigorInstalled=mf=Y.isAllDependenciesInstalled=void 0;const cf=of(D.default),af=of(p.default),lf=b,ff=j,df=$,Df=X;let pf,Ef;var mf=Y.isAllDependenciesInstalled=function(){function e(e){const t=null==e?void 0:e.dependencies;return void 0===t?0:Object.getOwnPropertyNames(t).length}if(pf=gf(),Ef=Af(),e(pf)+1!==e(Ef))return!1;for(const e in null==pf?void 0:pf.dependencies)if(!(0,ff.hasNpmPackInPaths)(e,[lf.HVIGOR_PROJECT_DEPENDENCIES_HOME])||!hf(e,pf,Ef))return!1;return!0};function hf(e,t,n){return void 0!==n.dependencies&&(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,t.dependencies[e])===n.dependencies[e]}var yf=Y.isHvigorInstalled=function(){return pf=gf(),Ef=Af(),(0,ff.hasNpmPackInPaths)(lf.HVIGOR_ENGINE_PACKAGE_NAME,[lf.HVIGOR_PROJECT_DEPENDENCIES_HOME])&&(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,pf.hvigorVersion)===Ef.dependencies[lf.HVIGOR_ENGINE_PACKAGE_NAME]};const Cf={cwd:lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,stdio:["inherit","inherit","inherit"]};var Ff=Y.executeInstallHvigor=function(){(0,df.logInfoPrintConsole)("Hvigor installing...");const e={dependencies:{}};e.dependencies[lf.HVIGOR_ENGINE_PACKAGE_NAME]=(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,pf.hvigorVersion);try{cf.mkdirSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,{recursive:!0});const t=af.resolve(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,lf.DEFAULT_PACKAGE_JSON);cf.writeFileSync(t,JSON.stringify(e))}catch(e){(0,df.logErrorAndExit)(e)}!function(){const e=["config","set","store-dir",lf.HVIGOR_PNPM_STORE_PATH];(0,ff.executeCommand)(lf.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,e,Cf)}(),(0,ff.executeCommand)(lf.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,["install"],Cf)};function gf(){const e=af.resolve(lf.HVIGOR_PROJECT_WRAPPER_HOME,lf.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);return cf.existsSync(e)||(0,df.logErrorAndExit)(`Error: Hvigor config file ${e} does not exist.`),(0,Df.parseJsonFile)(e)}function Af(){return cf.existsSync(lf.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH)?(0,Df.parseJsonFile)(lf.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH):{dependencies:{}}}sf=Y.cleanWorkSpace=function(){if((0,df.logInfoPrintConsole)("Hvigor cleaning..."),!cf.existsSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME))return;const e=cf.readdirSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME);if(e&&0!==e.length){cf.existsSync(lf.HVIGOR_BOOT_JS_FILE_PATH)&&(0,ff.executeCommand)(process.argv[0],[lf.HVIGOR_BOOT_JS_FILE_PATH,"--stop-daemon"],{});try{e.forEach((e=>{cf.rmSync(af.resolve(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,e),{recursive:!0})}))}catch(e){(0,df.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${lf.HVIGOR_PROJECT_DEPENDENCIES_HOME}.`)}}};var vf={},Sf=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),wf=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Of=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&Sf(t,e,n);return wf(t,e),t};Object.defineProperty(vf,"__esModule",{value:!0});var bf=vf.executeBuild=void 0;const _f=b,Bf=Of(D.default),Pf=Of(p.default),kf=$;bf=vf.executeBuild=function(){const e=Pf.resolve(_f.HVIGOR_PROJECT_DEPENDENCIES_HOME,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const t=Bf.realpathSync(e);require(t)}catch(t){(0,kf.logErrorAndExit)(`Error: ENOENT: no such file ${e},delete ${_f.HVIGOR_PROJECT_DEPENDENCIES_HOME} and retry.`)}},function(){if(O.checkNpmConifg(),O.environmentHandler(),O.isPnpmAvailable()||O.executeInstallPnpm(),yf()&&mf())bf();else{sf();try{Ff()}catch(e){return void sf()}bf()}}(); \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorfile.ts b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorfile.ts new file mode 100644 index 0000000000..6478186902 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorfile.ts @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorw b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorw new file mode 100644 index 0000000000..54aadd226b --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorw @@ -0,0 +1,48 @@ +#!/bin/bash + +# ---------------------------------------------------------------------------- +# Hvigor startup script, version 1.0.0 +# +# Required ENV vars: +# ------------------ +# NODE_HOME - location of a Node home dir +# or +# Add /usr/local/nodejs/bin to the PATH environment variable +# ---------------------------------------------------------------------------- + +HVIGOR_APP_HOME=$(dirname $(readlink -f $0)) +HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js +warn() { + echo "" + echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +error() { + echo "" + echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +fail() { + error "$@" + exit 1 +} + +# Determine node to start hvigor wrapper script +if [ -n "${NODE_HOME}" ];then + EXECUTABLE_NODE="${NODE_HOME}/bin/node" + if [ ! -x "$EXECUTABLE_NODE" ];then + fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" + fi +else + EXECUTABLE_NODE="node" + which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" +fi + +# Check hvigor wrapper script +if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then + fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" +fi + +# start hvigor-wrapper script +exec "${EXECUTABLE_NODE}" \ + "${HVIGOR_WRAPPER_SCRIPT}" "$@" diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorw.bat b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorw.bat new file mode 100644 index 0000000000..6861293e47 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/hvigorw.bat @@ -0,0 +1,64 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Hvigor startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js +set NODE_EXE=node.exe + +goto start + +:start +@rem Find node.exe +if defined NODE_HOME goto findNodeFromNodeHome + +%NODE_EXE% --version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:findNodeFromNodeHome +set NODE_HOME=%NODE_HOME:"=% +set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% + +if exist "%NODE_EXE_PATH%" goto execute +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:execute +@rem Execute hvigor +"%NODE_EXE%" %WRAPPER_MODULE_PATH% %* + +if "%ERRORLEVEL%" == "0" goto hvigorwEnd + +:fail +exit /b 1 + +:hvigorwEnd +if "%OS%" == "Windows_NT" endlocal + +:end diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/oh-package-lock.json5 b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/oh-package-lock.json5 new file mode 100644 index 0000000000..bc40219d5a --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/oh-package-lock.json5 @@ -0,0 +1,13 @@ +{ + "lockfileVersion": 1, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6" + }, + "packages": { + "@ohos/hypium@1.0.6": { + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", + "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" + } + } +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/JsApi/oh-package.json5 b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/oh-package.json5 new file mode 100644 index 0000000000..dbc2e2dc41 --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Vibrator/JsApi/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "name": "myapplication", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.6" + } +} diff --git a/code/BasicFeature/Graphics/DisplaySoloist/AppScope/app.json5 b/code/BasicFeature/Graphics/DisplaySoloist/AppScope/app.json5 index 396fc27e52..3669dcf813 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/AppScope/app.json5 +++ b/code/BasicFeature/Graphics/DisplaySoloist/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.DisplaySoloist", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.DisplaySoloist", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Graphics/DisplaySoloist/AppScope/resources/base/element/string.json b/code/BasicFeature/Graphics/DisplaySoloist/AppScope/resources/base/element/string.json index cf0ed8b528..8f27bbd636 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Graphics/DisplaySoloist/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "DisplaySoloist" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "DisplaySoloist" + } + ] +} diff --git a/code/BasicFeature/Graphics/DisplaySoloist/build-profile.json5 b/code/BasicFeature/Graphics/DisplaySoloist/build-profile.json5 index ab02bd0c01..43737f836e 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/build-profile.json5 +++ b/code/BasicFeature/Graphics/DisplaySoloist/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2024 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": [ - { - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, - "runtimeOS": "OpenHarmony", - "name": "default", - "signingConfig": "default", - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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": [ + { + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "runtimeOS": "OpenHarmony", + "name": "default", + "signingConfig": "default", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySoloist/entry/build-profile.json5 b/code/BasicFeature/Graphics/DisplaySoloist/entry/build-profile.json5 index 34df5bd5bf..cf2a53fd98 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/entry/build-profile.json5 +++ b/code/BasicFeature/Graphics/DisplaySoloist/entry/build-profile.json5 @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2024 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", "armeabi-v7a", "x86_64"] - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2024 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", "armeabi-v7a", "x86_64"] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySoloist/entry/oh-package.json5 b/code/BasicFeature/Graphics/DisplaySoloist/entry/oh-package.json5 index 0186d68634..0b39ac1a9a 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/entry/oh-package.json5 +++ b/code/BasicFeature/Graphics/DisplaySoloist/entry/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": { - "libentry.so": "file:./src/main/cpp/types/libentry" - } -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} diff --git a/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/pages/Index.ets index 7f71e4a843..dab5d6ff77 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/pages/Index.ets @@ -1,147 +1,147 @@ -/* - * Copyright (c) 2024 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 XComponentContext from '../interface/XComponentContext'; -import Logger from '../utils/Logger'; - -const TAG = '[XComponentDisplaySoloist]'; -const START = 'Start'; -const STOP = 'Stop'; - -@Entry -@Component -struct Index { - @State status1: string = START; - @State isOn1: boolean = false; - @State status2: string = START; - @State isOn2: boolean = false; - @State status3: string = START; - @State isOn3: boolean = false; - private xComponentContext1: XComponentContext | undefined = undefined; - private xComponentContext2: XComponentContext | undefined = undefined; - private xComponentContext3: XComponentContext | undefined = undefined; - - aboutToDisappear(): void { - // 离开当前页面时解除注册的回调,销毁申请的DisplaySoloist - Logger.info(TAG, 'aboutToDisappear'); - if (this.xComponentContext1) { - this.xComponentContext1.unregister(); - this.xComponentContext1.destroy(); - } - if (this.xComponentContext2) { - this.xComponentContext2.unregister(); - this.xComponentContext2.destroy(); - } - if (this.xComponentContext3) { - this.xComponentContext3.unregister(); - this.xComponentContext3.destroy(); - } - } - - Execute(component: XComponentContext, flg: boolean): string { - if (flg) { - // 注册回调函数并开启每帧回调 - component.register(); - return STOP; - } else { - // 解注册回调函数并停止启每帧回调 - component.unregister(); - return START; - } - } - - build() { - Column() { - Row() { - Text('30hz') - .fontWeight(FontWeight.Bold) - .fontSize(12) - .fontColor(Color.Red) - .textAlign(TextAlign.End) - .width(40) - .height(30) - - Button(this.status1) - .id('Start30') - .controlSize(ControlSize.SMALL) - .onClick((): void => { - if (this.xComponentContext1) { - // 每次点击切换按钮上的显示Start/Stop - this.isOn1 = !(this.isOn1); - this.status1 = this.Execute(this.xComponentContext1, this.isOn1); - } - }).margin(4) - - XComponent({ id: 'xcomponentId30', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext1 = xComponentContext as XComponentContext; - }).width('640px') - .backgroundColor(Color.White); - }.height('30%') - - Row() { - Text('60hz') - .fontWeight(FontWeight.Bold) - .fontSize(12) - .fontColor(Color.Red) - .textAlign(TextAlign.End) - .width(40) - .height(30) - - Button(this.status2) - .id('Start60') - .controlSize(ControlSize.SMALL) - .onClick((): void => { - if (this.xComponentContext2) { - this.isOn2 = !(this.isOn2); - this.status2 = this.Execute(this.xComponentContext2, this.isOn2); - } - }).margin(4) - - XComponent({ id: 'xcomponentId60', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext2 = xComponentContext as XComponentContext; - }).width('640px') - .backgroundColor(Color.White); - }.height('30%') - - Row() { - Text('120hz') - .fontWeight(FontWeight.Bold) - .fontSize(12) - .fontColor(Color.Red) - .textAlign(TextAlign.End) - .width(40) - .height(30) - - Button(this.status3) - .id('Start120') - .controlSize(ControlSize.SMALL) - .onClick((): void => { - if (this.xComponentContext3) { - this.isOn3 = !(this.isOn3); - this.status3 = this.Execute(this.xComponentContext3, this.isOn3); - } - }).margin(4) - - XComponent({ id: 'xcomponentId120', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext3 = xComponentContext as XComponentContext; - }).width('640px') - .backgroundColor(Color.White); - }.height('30%') - } - } +/* + * Copyright (c) 2024 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 XComponentContext from '../interface/XComponentContext'; +import Logger from '../utils/Logger'; + +const TAG = '[XComponentDisplaySoloist]'; +const START = 'Start'; +const STOP = 'Stop'; + +@Entry +@Component +struct Index { + @State status1: string = START; + @State isOn1: boolean = false; + @State status2: string = START; + @State isOn2: boolean = false; + @State status3: string = START; + @State isOn3: boolean = false; + private xComponentContext1: XComponentContext | undefined = undefined; + private xComponentContext2: XComponentContext | undefined = undefined; + private xComponentContext3: XComponentContext | undefined = undefined; + + aboutToDisappear(): void { + // 离开当前页面时解除注册的回调,销毁申请的DisplaySoloist + Logger.info(TAG, 'aboutToDisappear'); + if (this.xComponentContext1) { + this.xComponentContext1.unregister(); + this.xComponentContext1.destroy(); + } + if (this.xComponentContext2) { + this.xComponentContext2.unregister(); + this.xComponentContext2.destroy(); + } + if (this.xComponentContext3) { + this.xComponentContext3.unregister(); + this.xComponentContext3.destroy(); + } + } + + Execute(component: XComponentContext, flg: boolean): string { + if (flg) { + // 注册回调函数并开启每帧回调 + component.register(); + return STOP; + } else { + // 解注册回调函数并停止启每帧回调 + component.unregister(); + return START; + } + } + + build() { + Column() { + Row() { + Text('30hz') + .fontWeight(FontWeight.Bold) + .fontSize(12) + .fontColor(Color.Red) + .textAlign(TextAlign.End) + .width(40) + .height(30) + + Button(this.status1) + .id('Start30') + .controlSize(ControlSize.SMALL) + .onClick((): void => { + if (this.xComponentContext1) { + // 每次点击切换按钮上的显示Start/Stop + this.isOn1 = !(this.isOn1); + this.status1 = this.Execute(this.xComponentContext1, this.isOn1); + } + }).margin(4) + + XComponent({ id: 'xcomponentId30', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext1 = xComponentContext as XComponentContext; + }).width('640px') + .backgroundColor(Color.White); + }.height('30%') + + Row() { + Text('60hz') + .fontWeight(FontWeight.Bold) + .fontSize(12) + .fontColor(Color.Red) + .textAlign(TextAlign.End) + .width(40) + .height(30) + + Button(this.status2) + .id('Start60') + .controlSize(ControlSize.SMALL) + .onClick((): void => { + if (this.xComponentContext2) { + this.isOn2 = !(this.isOn2); + this.status2 = this.Execute(this.xComponentContext2, this.isOn2); + } + }).margin(4) + + XComponent({ id: 'xcomponentId60', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext2 = xComponentContext as XComponentContext; + }).width('640px') + .backgroundColor(Color.White); + }.height('30%') + + Row() { + Text('120hz') + .fontWeight(FontWeight.Bold) + .fontSize(12) + .fontColor(Color.Red) + .textAlign(TextAlign.End) + .width(40) + .height(30) + + Button(this.status3) + .id('Start120') + .controlSize(ControlSize.SMALL) + .onClick((): void => { + if (this.xComponentContext3) { + this.isOn3 = !(this.isOn3); + this.status3 = this.Execute(this.xComponentContext3, this.isOn3); + } + }).margin(4) + + XComponent({ id: 'xcomponentId120', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext3 = xComponentContext as XComponentContext; + }).width('640px') + .backgroundColor(Color.White); + }.height('30%') + } + } } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/utils/Logger.ets b/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/utils/Logger.ets index 221770b875..517c8134a9 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/utils/Logger.ets +++ b/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/utils/Logger.ets @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_DisplaySync]'); \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySoloist/entry/src/ohosTest/ets/utils/Logger.ets b/code/BasicFeature/Graphics/DisplaySoloist/entry/src/ohosTest/ets/utils/Logger.ets index 342d683b17..687ca76b70 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/entry/src/ohosTest/ets/utils/Logger.ets +++ b/code/BasicFeature/Graphics/DisplaySoloist/entry/src/ohosTest/ets/utils/Logger.ets @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number = 0xF811; - private prefix: string = ''; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xF811; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number = 0xF811; + private prefix: string = ''; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xF811; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_DisplaySync]'); \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySoloist/hvigor/hvigor-config.json5 b/code/BasicFeature/Graphics/DisplaySoloist/hvigor/hvigor-config.json5 index e1b617db91..0b5647c97e 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Graphics/DisplaySoloist/hvigor/hvigor-config.json5 @@ -1,6 +1,6 @@ -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySoloist/oh-package.json5 b/code/BasicFeature/Graphics/DisplaySoloist/oh-package.json5 index 28368a2c2e..d5793d0d26 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/oh-package.json5 +++ b/code/BasicFeature/Graphics/DisplaySoloist/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "drawing", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "drawing", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Graphics/DisplaySync/AppScope/app.json5 b/code/BasicFeature/Graphics/DisplaySync/AppScope/app.json5 index bdbb7e8f6b..2832c10c72 100644 --- a/code/BasicFeature/Graphics/DisplaySync/AppScope/app.json5 +++ b/code/BasicFeature/Graphics/DisplaySync/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.displaySync", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.displaySync", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Graphics/DisplaySync/AppScope/resources/base/element/string.json b/code/BasicFeature/Graphics/DisplaySync/AppScope/resources/base/element/string.json index 0daf22fb0a..ba13327659 100644 --- a/code/BasicFeature/Graphics/DisplaySync/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Graphics/DisplaySync/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "DisplaySync" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "DisplaySync" + } + ] +} diff --git a/code/BasicFeature/Graphics/DisplaySync/build-profile.json5 b/code/BasicFeature/Graphics/DisplaySync/build-profile.json5 index 5f507fb19d..6da2ab8c3f 100644 --- a/code/BasicFeature/Graphics/DisplaySync/build-profile.json5 +++ b/code/BasicFeature/Graphics/DisplaySync/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySync/entry/build-profile.json5 b/code/BasicFeature/Graphics/DisplaySync/entry/build-profile.json5 index 29f75c6b41..c011db99b4 100644 --- a/code/BasicFeature/Graphics/DisplaySync/entry/build-profile.json5 +++ b/code/BasicFeature/Graphics/DisplaySync/entry/build-profile.json5 @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2023-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" - ] - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023-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" + ] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySync/entry/oh-package.json5 b/code/BasicFeature/Graphics/DisplaySync/entry/oh-package.json5 index b9c1d4cca7..54cb066266 100644 --- a/code/BasicFeature/Graphics/DisplaySync/entry/oh-package.json5 +++ b/code/BasicFeature/Graphics/DisplaySync/entry/oh-package.json5 @@ -1,11 +1,11 @@ -{ - "name": "entry", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libentry.so": "file:./src/main/cpp/types/libentry" - } +{ + "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/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/CustomDrawDisplaySync.ets b/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/CustomDrawDisplaySync.ets index 190c139e6a..17f65dcaaf 100644 --- a/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/CustomDrawDisplaySync.ets +++ b/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/CustomDrawDisplaySync.ets @@ -1,190 +1,190 @@ -/* - * Copyright (c) 2023 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 displaySync from '@ohos.graphics.displaySync'; -import router from '@ohos.router'; -import Logger from '../utils/Logger'; -const TAG = '[CustomDrawDisplaySync]'; - -@Entry -@Component -struct Index { - @State drawFirstSize: number = 25; - @State drawSecondSize: number = 25; - private backDisplaySyncSlow: displaySync.DisplaySync | undefined = undefined; - private backDisplaySyncFast: displaySync.DisplaySync | undefined = undefined; - private isBigger_30:boolean = true; - private isBigger_60:boolean = true; - - @Builder doSomeRenderFirst() { - Text('30') - .fontSize(this.drawFirstSize) - } - - @Builder doSomeRenderSecond() { - Text('60') - .fontSize(this.drawSecondSize) - } - - CreateDisplaySyncSlow() { - let range : ExpectedFrameRateRange = { - expected: 30, - min: 0, - max: 120 - }; - - let draw30 = (ii: displaySync.IntervalInfo) => { - if (this.isBigger_30) { - this.drawFirstSize += 1; - if (this.drawFirstSize > 150) { - this.isBigger_30 = false; - } - } else { - this.drawFirstSize -= 1; - if (this.drawFirstSize < 25) { - this.isBigger_30 = true; - } - } - Logger.info(TAG, '[Draw30] Timestamp:' + ii.timestamp + ' TargetTimeStamp: ' + ii.targetTimestamp); - }; - - this.backDisplaySyncSlow = displaySync.create(); - this.backDisplaySyncSlow.setExpectedFrameRateRange(range); - this.backDisplaySyncSlow.on("frame", draw30); - } - - CreateDisplaySyncFast() { - let range : ExpectedFrameRateRange = { - expected: 60, - min: 0, - max: 120 - }; - - let draw60 = (ii: displaySync.IntervalInfo) => { - if (this.isBigger_60) { - this.drawSecondSize += 1; - if (this.drawSecondSize > 150) { - this.isBigger_60 = false; - } - } else { - this.drawSecondSize -= 1; - if (this.drawSecondSize < 25) { - this.isBigger_60 = true; - } - } - - Logger.info(TAG, '[Draw60] Timestamp:' + ii.timestamp + ' TargetTimeStamp: ' + ii.targetTimestamp); - }; - - this.backDisplaySyncFast= displaySync.create(); - this.backDisplaySyncFast.setExpectedFrameRateRange(range); - this.backDisplaySyncFast.on("frame", draw60); - } - - aboutToDisappear() { - if (this.backDisplaySyncSlow) { - this.backDisplaySyncSlow.stop(); - this.backDisplaySyncSlow = undefined; - } - if (this.backDisplaySyncFast) { - this.backDisplaySyncFast.stop(); - this.backDisplaySyncFast = undefined; - } - - Logger.info(TAG, 'DisplaySyncDestructor set all displaySync null'); - } - - build() { - Column() { - Row() { - this.doSomeRenderFirst(); - } - .height('40%') - - Row() { - this.doSomeRenderSecond(); - } - .height('40%') - - Row() { - Button('Start') - .id('CustomDrawStart') - .fontSize(14) - .fontWeight(500) - .margin({ bottom: 10, left: 5 }) - .fontColor(Color.White) - .onClick((): void => { - if (this.backDisplaySyncSlow == undefined) { - this.CreateDisplaySyncSlow(); - } - if (this.backDisplaySyncFast == undefined) { - this.CreateDisplaySyncFast(); - } - if (this.backDisplaySyncSlow) { - this.backDisplaySyncSlow.start(); - } - if (this.backDisplaySyncFast) { - this.backDisplaySyncFast.start(); - } - }) - .width('20%') - .height(40) - .shadow(ShadowStyle.OUTER_DEFAULT_LG) - - Button('Stop') - .id('CustomDrawStop') - .fontSize(14) - .fontWeight(500) - .margin({ bottom: 10, left: 5 }) - .fontColor(Color.White) - .onClick((): void => { - if (this.backDisplaySyncSlow) { - this.backDisplaySyncSlow.stop(); - } - if (this.backDisplaySyncFast) { - this.backDisplaySyncFast.stop(); - } - }) - .width('20%') - .height(40) - .shadow(ShadowStyle.OUTER_DEFAULT_LG) - - Button('Back') - .id('CustomDrawBack') - .fontSize(14) - .fontWeight(500) - .margin({ bottom: 10, left: 5 }) - .fontColor(Color.White) - .onClick((): void => { - if (this.backDisplaySyncSlow) { - this.backDisplaySyncSlow.stop(); - } - if (this.backDisplaySyncFast) { - this.backDisplaySyncFast.stop(); - } - router.back(); - }) - .width('20%') - .height(40) - .shadow(ShadowStyle.OUTER_DEFAULT_LG) - } - .width('100%') - .justifyContent(FlexAlign.Center) - .shadow(ShadowStyle.OUTER_DEFAULT_SM) - .alignItems(VerticalAlign.Bottom) - .layoutWeight(1) - } - } +/* + * Copyright (c) 2023 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 displaySync from '@ohos.graphics.displaySync'; +import router from '@ohos.router'; +import Logger from '../utils/Logger'; +const TAG = '[CustomDrawDisplaySync]'; + +@Entry +@Component +struct Index { + @State drawFirstSize: number = 25; + @State drawSecondSize: number = 25; + private backDisplaySyncSlow: displaySync.DisplaySync | undefined = undefined; + private backDisplaySyncFast: displaySync.DisplaySync | undefined = undefined; + private isBigger_30:boolean = true; + private isBigger_60:boolean = true; + + @Builder doSomeRenderFirst() { + Text('30') + .fontSize(this.drawFirstSize) + } + + @Builder doSomeRenderSecond() { + Text('60') + .fontSize(this.drawSecondSize) + } + + CreateDisplaySyncSlow() { + let range : ExpectedFrameRateRange = { + expected: 30, + min: 0, + max: 120 + }; + + let draw30 = (ii: displaySync.IntervalInfo) => { + if (this.isBigger_30) { + this.drawFirstSize += 1; + if (this.drawFirstSize > 150) { + this.isBigger_30 = false; + } + } else { + this.drawFirstSize -= 1; + if (this.drawFirstSize < 25) { + this.isBigger_30 = true; + } + } + Logger.info(TAG, '[Draw30] Timestamp:' + ii.timestamp + ' TargetTimeStamp: ' + ii.targetTimestamp); + }; + + this.backDisplaySyncSlow = displaySync.create(); + this.backDisplaySyncSlow.setExpectedFrameRateRange(range); + this.backDisplaySyncSlow.on("frame", draw30); + } + + CreateDisplaySyncFast() { + let range : ExpectedFrameRateRange = { + expected: 60, + min: 0, + max: 120 + }; + + let draw60 = (ii: displaySync.IntervalInfo) => { + if (this.isBigger_60) { + this.drawSecondSize += 1; + if (this.drawSecondSize > 150) { + this.isBigger_60 = false; + } + } else { + this.drawSecondSize -= 1; + if (this.drawSecondSize < 25) { + this.isBigger_60 = true; + } + } + + Logger.info(TAG, '[Draw60] Timestamp:' + ii.timestamp + ' TargetTimeStamp: ' + ii.targetTimestamp); + }; + + this.backDisplaySyncFast= displaySync.create(); + this.backDisplaySyncFast.setExpectedFrameRateRange(range); + this.backDisplaySyncFast.on("frame", draw60); + } + + aboutToDisappear() { + if (this.backDisplaySyncSlow) { + this.backDisplaySyncSlow.stop(); + this.backDisplaySyncSlow = undefined; + } + if (this.backDisplaySyncFast) { + this.backDisplaySyncFast.stop(); + this.backDisplaySyncFast = undefined; + } + + Logger.info(TAG, 'DisplaySyncDestructor set all displaySync null'); + } + + build() { + Column() { + Row() { + this.doSomeRenderFirst(); + } + .height('40%') + + Row() { + this.doSomeRenderSecond(); + } + .height('40%') + + Row() { + Button('Start') + .id('CustomDrawStart') + .fontSize(14) + .fontWeight(500) + .margin({ bottom: 10, left: 5 }) + .fontColor(Color.White) + .onClick((): void => { + if (this.backDisplaySyncSlow == undefined) { + this.CreateDisplaySyncSlow(); + } + if (this.backDisplaySyncFast == undefined) { + this.CreateDisplaySyncFast(); + } + if (this.backDisplaySyncSlow) { + this.backDisplaySyncSlow.start(); + } + if (this.backDisplaySyncFast) { + this.backDisplaySyncFast.start(); + } + }) + .width('20%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + + Button('Stop') + .id('CustomDrawStop') + .fontSize(14) + .fontWeight(500) + .margin({ bottom: 10, left: 5 }) + .fontColor(Color.White) + .onClick((): void => { + if (this.backDisplaySyncSlow) { + this.backDisplaySyncSlow.stop(); + } + if (this.backDisplaySyncFast) { + this.backDisplaySyncFast.stop(); + } + }) + .width('20%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + + Button('Back') + .id('CustomDrawBack') + .fontSize(14) + .fontWeight(500) + .margin({ bottom: 10, left: 5 }) + .fontColor(Color.White) + .onClick((): void => { + if (this.backDisplaySyncSlow) { + this.backDisplaySyncSlow.stop(); + } + if (this.backDisplaySyncFast) { + this.backDisplaySyncFast.stop(); + } + router.back(); + }) + .width('20%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .shadow(ShadowStyle.OUTER_DEFAULT_SM) + .alignItems(VerticalAlign.Bottom) + .layoutWeight(1) + } + } } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/PropertyAnimationDisplaySync.ets b/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/PropertyAnimationDisplaySync.ets index 11d325c75b..be1503ae3e 100644 --- a/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/PropertyAnimationDisplaySync.ets +++ b/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/PropertyAnimationDisplaySync.ets @@ -1,158 +1,158 @@ -/* - * Copyright (c) 2023 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 curves from '@ohos.curves'; -import router from '@ohos.router'; - -@Entry -@Component -struct AnimationToAnimationDemo { - @State isAnimation: boolean = false; - @State translateX1: number = -100; - @State translateX2: number = -100; - @State translateX3: number = -100; - uiContext: UIContext | undefined = undefined; - - aboutToAppear() { - this.uiContext = this.getUIContext(); - if (!this.uiContext) { - console.warn('no uiContext'); - return; - } - } - - build() { - Column() { - Row() { - Text('30') - .fontWeight(FontWeight.Bold) - .fontSize(16) - .fontColor(Color.White) - .textAlign(TextAlign.Center) - .borderRadius(10) - .backgroundColor(0xF56C6C) - .width(80) - .height(80) - .translate({ x: this.translateX1 }) - } - .height('20%') - - Row() { - Text('40') - .fontWeight(FontWeight.Bold) - .fontSize(16) - .fontColor(Color.White) - .textAlign(TextAlign.Center) - .borderRadius(10) - .backgroundColor(0x2E8B57) - .width(80) - .height(80) - .translate({ x: this.translateX2 }) - } - .height('20%') - - Row() { - Text('60') - .fontWeight(FontWeight.Bold) - .fontSize(16) - .fontColor(Color.White) - .textAlign(TextAlign.Center) - .borderRadius(10) - .backgroundColor(0x008B8B) - .width(80) - .height(80) - .translate({ x: this.translateX3 }) - .animation({ - duration: 1200, - iterations: 10, - curve: curves.springMotion(), - playMode: PlayMode.AlternateReverse, - expectedFrameRateRange: { - expected: 60, - min: 0, - max: 120 - }, - }) - } - .height('20%') - - Row() { - Button('Start') - .id('PropertyAnimationStart') - .fontSize(14) - .fontWeight(500) - .margin({ bottom: 10, left: 5 }) - .fontColor(Color.White) - .onClick(() => { - this.isAnimation = !this.isAnimation; - this.translateX3 = this.isAnimation ? 100 : -100; - - this.uiContext?.animateTo({ - duration: 1200, - iterations: 10, - curve: curves.springMotion(), - playMode: PlayMode.AlternateReverse, - expectedFrameRateRange: { - expected: 30, - min: 0, - max: 120, - }, - }, () => { - this.translateX1 = this.isAnimation ? 100 : -100; - }) - - this.uiContext?.animateTo({ - duration: 1200, - iterations: 10, - curve: curves.springMotion(), - playMode: PlayMode.AlternateReverse, - expectedFrameRateRange: { - expected: 40, - min: 0, - max: 120, - }, - }, () => { - this.translateX2 = this.isAnimation ? 100 : -100; - }) - }) - .width('40%') - .height(40) - .shadow(ShadowStyle.OUTER_DEFAULT_LG) - - Button('Back') - .id('PropertyAnimationBack') - .fontSize(14) - .fontWeight(500) - .margin({ bottom: 10, left: 5 }) - .fontColor(Color.White) - .onClick((): void => { - router.back(); - }) - .width('40%') - .height(40) - .shadow(ShadowStyle.OUTER_DEFAULT_LG) - } - .width('100%') - .justifyContent(FlexAlign.Center) - .shadow(ShadowStyle.OUTER_DEFAULT_SM) - .alignItems(VerticalAlign.Bottom) - .layoutWeight(1) - } - .width('100%') - .justifyContent(FlexAlign.Center) - .shadow(ShadowStyle.OUTER_DEFAULT_SM) - .layoutWeight(1) - } +/* + * Copyright (c) 2023 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 curves from '@ohos.curves'; +import router from '@ohos.router'; + +@Entry +@Component +struct AnimationToAnimationDemo { + @State isAnimation: boolean = false; + @State translateX1: number = -100; + @State translateX2: number = -100; + @State translateX3: number = -100; + uiContext: UIContext | undefined = undefined; + + aboutToAppear() { + this.uiContext = this.getUIContext(); + if (!this.uiContext) { + console.warn('no uiContext'); + return; + } + } + + build() { + Column() { + Row() { + Text('30') + .fontWeight(FontWeight.Bold) + .fontSize(16) + .fontColor(Color.White) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xF56C6C) + .width(80) + .height(80) + .translate({ x: this.translateX1 }) + } + .height('20%') + + Row() { + Text('40') + .fontWeight(FontWeight.Bold) + .fontSize(16) + .fontColor(Color.White) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0x2E8B57) + .width(80) + .height(80) + .translate({ x: this.translateX2 }) + } + .height('20%') + + Row() { + Text('60') + .fontWeight(FontWeight.Bold) + .fontSize(16) + .fontColor(Color.White) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0x008B8B) + .width(80) + .height(80) + .translate({ x: this.translateX3 }) + .animation({ + duration: 1200, + iterations: 10, + curve: curves.springMotion(), + playMode: PlayMode.AlternateReverse, + expectedFrameRateRange: { + expected: 60, + min: 0, + max: 120 + }, + }) + } + .height('20%') + + Row() { + Button('Start') + .id('PropertyAnimationStart') + .fontSize(14) + .fontWeight(500) + .margin({ bottom: 10, left: 5 }) + .fontColor(Color.White) + .onClick(() => { + this.isAnimation = !this.isAnimation; + this.translateX3 = this.isAnimation ? 100 : -100; + + this.uiContext?.animateTo({ + duration: 1200, + iterations: 10, + curve: curves.springMotion(), + playMode: PlayMode.AlternateReverse, + expectedFrameRateRange: { + expected: 30, + min: 0, + max: 120, + }, + }, () => { + this.translateX1 = this.isAnimation ? 100 : -100; + }) + + this.uiContext?.animateTo({ + duration: 1200, + iterations: 10, + curve: curves.springMotion(), + playMode: PlayMode.AlternateReverse, + expectedFrameRateRange: { + expected: 40, + min: 0, + max: 120, + }, + }, () => { + this.translateX2 = this.isAnimation ? 100 : -100; + }) + }) + .width('40%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + + Button('Back') + .id('PropertyAnimationBack') + .fontSize(14) + .fontWeight(500) + .margin({ bottom: 10, left: 5 }) + .fontColor(Color.White) + .onClick((): void => { + router.back(); + }) + .width('40%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .shadow(ShadowStyle.OUTER_DEFAULT_SM) + .alignItems(VerticalAlign.Bottom) + .layoutWeight(1) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .shadow(ShadowStyle.OUTER_DEFAULT_SM) + .layoutWeight(1) + } } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/XComponentDisplaySync.ets b/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/XComponentDisplaySync.ets index 396007ed69..627256c2ed 100644 --- a/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/XComponentDisplaySync.ets +++ b/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/pages/XComponentDisplaySync.ets @@ -1,128 +1,128 @@ -/* - * Copyright (c) 2023 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 XComponentContext from '../interface/XComponentContext'; -import router from '@ohos.router'; -import Logger from '../utils/Logger'; -const TAG = '[XComponentDisplaySync]'; - -@Entry -@Component -struct Index { - private xComponentContext1: XComponentContext | undefined = undefined; - private xComponentContext2: XComponentContext | undefined = undefined; - - build() { - Column() { - Row() { - Text('30fps') - .fontWeight(FontWeight.Bold) - .fontSize(12) - .fontColor(Color.Red) - .textAlign(TextAlign.End) - .width(40) - .height(30) - - XComponent({ id: 'xcomponentId_30', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext1 = xComponentContext as XComponentContext; - }).width('80%') - }.height('40%') - - Row() { - Text('120fps') - .fontWeight(FontWeight.Bold) - .fontSize(12) - .fontColor(Color.Red) - .textAlign(TextAlign.End) - .width(40) - .height(30) - - XComponent({ id: 'xcomponentId_120', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext2 = xComponentContext as XComponentContext; - }).width('80%')// Multiples of 64 - }.height('40%') - - Row() { - Button('Start') - .id('Start') - .fontSize(14) - .fontWeight(500) - .margin({ bottom: 20, right: 6, left: 6 }) - .onClick(() => { - Logger.info(TAG, "Start click"); - if (this.xComponentContext1) { - Logger.info(TAG, "Register1"); - this.xComponentContext1.register(); - } - if (this.xComponentContext2) { - Logger.info(TAG, "Register2"); - this.xComponentContext2.register(); - } - }) - .width('30%') - .height(40) - .shadow(ShadowStyle.OUTER_DEFAULT_LG) - - Button('Stop') - .id('Stop') - .fontSize(14) - .fontWeight(500) - .margin({ bottom: 20, left: 6 }) - .onClick(() => { - Logger.info(TAG, "Stop click"); - if (this.xComponentContext1) { - Logger.info(TAG, "Unregister1"); - this.xComponentContext1.unregister(); - } - if (this.xComponentContext2) { - Logger.info(TAG, "Unregister2"); - this.xComponentContext2.unregister(); - } - }) - .width('30%') - .height(40) - .shadow(ShadowStyle.OUTER_DEFAULT_LG) - - // 返回按钮 - Button('Back') - .id('Back') - .fontSize(14) - .fontWeight(500) - .margin({ bottom: 20, left: 6 }) - .onClick((): void => { - if (this.xComponentContext1) { - Logger.info(TAG, "Unregister1"); - this.xComponentContext1.unregister(); - } - if (this.xComponentContext2) { - Logger.info(TAG, "Unregister2"); - this.xComponentContext2.unregister(); - } - router.back(); - }) - .width('30%') - .height(40) - .shadow(ShadowStyle.OUTER_DEFAULT_LG) - } - .width('100%') - .justifyContent(FlexAlign.Center) - .shadow(ShadowStyle.OUTER_DEFAULT_SM) - .alignItems(VerticalAlign.Bottom) - .layoutWeight(1) - } - } +/* + * Copyright (c) 2023 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 XComponentContext from '../interface/XComponentContext'; +import router from '@ohos.router'; +import Logger from '../utils/Logger'; +const TAG = '[XComponentDisplaySync]'; + +@Entry +@Component +struct Index { + private xComponentContext1: XComponentContext | undefined = undefined; + private xComponentContext2: XComponentContext | undefined = undefined; + + build() { + Column() { + Row() { + Text('30fps') + .fontWeight(FontWeight.Bold) + .fontSize(12) + .fontColor(Color.Red) + .textAlign(TextAlign.End) + .width(40) + .height(30) + + XComponent({ id: 'xcomponentId_30', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext1 = xComponentContext as XComponentContext; + }).width('80%') + }.height('40%') + + Row() { + Text('120fps') + .fontWeight(FontWeight.Bold) + .fontSize(12) + .fontColor(Color.Red) + .textAlign(TextAlign.End) + .width(40) + .height(30) + + XComponent({ id: 'xcomponentId_120', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext2 = xComponentContext as XComponentContext; + }).width('80%')// Multiples of 64 + }.height('40%') + + Row() { + Button('Start') + .id('Start') + .fontSize(14) + .fontWeight(500) + .margin({ bottom: 20, right: 6, left: 6 }) + .onClick(() => { + Logger.info(TAG, "Start click"); + if (this.xComponentContext1) { + Logger.info(TAG, "Register1"); + this.xComponentContext1.register(); + } + if (this.xComponentContext2) { + Logger.info(TAG, "Register2"); + this.xComponentContext2.register(); + } + }) + .width('30%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + + Button('Stop') + .id('Stop') + .fontSize(14) + .fontWeight(500) + .margin({ bottom: 20, left: 6 }) + .onClick(() => { + Logger.info(TAG, "Stop click"); + if (this.xComponentContext1) { + Logger.info(TAG, "Unregister1"); + this.xComponentContext1.unregister(); + } + if (this.xComponentContext2) { + Logger.info(TAG, "Unregister2"); + this.xComponentContext2.unregister(); + } + }) + .width('30%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + + // 返回按钮 + Button('Back') + .id('Back') + .fontSize(14) + .fontWeight(500) + .margin({ bottom: 20, left: 6 }) + .onClick((): void => { + if (this.xComponentContext1) { + Logger.info(TAG, "Unregister1"); + this.xComponentContext1.unregister(); + } + if (this.xComponentContext2) { + Logger.info(TAG, "Unregister2"); + this.xComponentContext2.unregister(); + } + router.back(); + }) + .width('30%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .shadow(ShadowStyle.OUTER_DEFAULT_SM) + .alignItems(VerticalAlign.Bottom) + .layoutWeight(1) + } + } } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/utils/Logger.ets b/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/utils/Logger.ets index 813142fade..ded8133070 100644 --- a/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/utils/Logger.ets +++ b/code/BasicFeature/Graphics/DisplaySync/entry/src/main/ets/utils/Logger.ets @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_DisplaySync]'); \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySync/entry/src/ohosTest/ets/utils/Logger.ets b/code/BasicFeature/Graphics/DisplaySync/entry/src/ohosTest/ets/utils/Logger.ets index e67695fe16..cfc014b72c 100644 --- a/code/BasicFeature/Graphics/DisplaySync/entry/src/ohosTest/ets/utils/Logger.ets +++ b/code/BasicFeature/Graphics/DisplaySync/entry/src/ohosTest/ets/utils/Logger.ets @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number = 0xF811; - private prefix: string = ''; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xF811; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number = 0xF811; + private prefix: string = ''; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xF811; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_DisplaySync]'); \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySync/hvigor/hvigor-config.json5 b/code/BasicFeature/Graphics/DisplaySync/hvigor/hvigor-config.json5 index d9d361de48..58e6423f41 100644 --- a/code/BasicFeature/Graphics/DisplaySync/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Graphics/DisplaySync/hvigor/hvigor-config.json5 @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2023-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. - */ - -{ - "hvigorVersion": "4.1.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.1.2" - }, - "execution": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } +/* + * Copyright (c) 2023-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. + */ + +{ + "hvigorVersion": "4.1.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.1.2" + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/DisplaySync/oh-package.json5 b/code/BasicFeature/Graphics/DisplaySync/oh-package.json5 index 28368a2c2e..d5793d0d26 100644 --- a/code/BasicFeature/Graphics/DisplaySync/oh-package.json5 +++ b/code/BasicFeature/Graphics/DisplaySync/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "drawing", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "drawing", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Graphics/Graphics2d/ExpandText/AppScope/app.json5 b/code/BasicFeature/Graphics/Graphics2d/ExpandText/AppScope/app.json5 index 42cb3ab085..95df481dfc 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/AppScope/app.json5 +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.example.expandtext", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.example.expandtext", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Graphics/Graphics2d/ExpandText/AppScope/resources/base/element/string.json b/code/BasicFeature/Graphics/Graphics2d/ExpandText/AppScope/resources/base/element/string.json index a1cd6e41c9..72048ed2b2 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ExpandText" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ExpandText" + } + ] +} diff --git a/code/BasicFeature/Graphics/Graphics2d/ExpandText/build-profile.json5 b/code/BasicFeature/Graphics/Graphics2d/ExpandText/build-profile.json5 index ea6d3ca208..6ae38bd2fb 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/build-profile.json5 +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/build-profile.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2024 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", - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, - "runtimeOS": "OpenHarmony" - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "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/BasicFeature/Graphics/Graphics2d/ExpandText/entry/build-profile.json5 b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/build-profile.json5 index 7cae420966..0cd53ca643 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/build-profile.json5 +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2024 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", - } - ] +/* + * Copyright (c) 2024 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/BasicFeature/Graphics/Graphics2d/ExpandText/entry/oh-package.json5 b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/oh-package.json5 index 41a4755f66..4e54d14e1b 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/oh-package.json5 +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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": {} -} - +/* + * Copyright (c) 2024 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/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/entryability/EntryAbility.ets index aecc7ce556..5b89ce6e3e 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/TextCollapseEtsDemo', (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'); - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/TextCollapseEtsDemo', (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/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index 560fce1497..9afbfdf88d 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 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)); - } +/* + * Copyright (c) 2024 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/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/pages/TextCollapseEtsDemo.ets b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/pages/TextCollapseEtsDemo.ets index 00492d00b6..018efcb4e2 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/pages/TextCollapseEtsDemo.ets +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/ets/pages/TextCollapseEtsDemo.ets @@ -1,345 +1,345 @@ -/* - * Copyright (c) 2024 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 image from '@ohos.multimedia.image'; -import drawing from '@ohos.graphics.drawing'; -import font from '@ohos.font'; -import { text } from '@kit.ArkGraphics2D'; - -class TextViewModel { - public type: number = 0; - public content: string = ''; - public fontSize: number = 0; - public fontColor: Color = Color.Black; - public width: number = 0; - public height: number = 0; -} - -class Results { - public index: number = 0; - public lineCount: number = 0; -} - -@Entry -@Component -struct TextCollapseTest { - @State suffixStr: string = ''; - @State suffixStr2: string = ''; - EXPAND_STR: string = this.resourceToString($r('app.string.expand_str')); - COLLAPSE_STR: string = this.resourceToString($r('app.string.collapse_str')); - - expanded: Boolean = true; - needProcess: boolean = true; - lineCount: number = 0; - collapseIndex: number = 0; - @State pixelMap: image.PixelMap | undefined = undefined; - - originViewModelList: TextViewModel[] = [ - { - type: 0, - content: this.resourceToString($r('app.string.list_content1')), - fontSize: 8, - fontColor: Color.Black, - width: 0, - height: 0 - }, - { - type: 0, - content: this.resourceToString($r('app.string.list_content2')), - fontSize: 12, - fontColor: Color.Black, - width: 0, - height: 0 - }, - { - type: 1, - content: 'app.media.icon', - fontSize: 12, - fontColor: Color.Black, - width: 20, - height: 20 - }, - { - type: 0, - content: this.resourceToString($r('app.string.list_content3')), - fontSize: 12, - fontColor: Color.Black, - width: 0, - height: 0 - }, - { - type: 1, - content: 'app.media.icon', - fontSize: 12, - fontColor: Color.Black, - width: 20, - height: 20 - }, - ] - collapseViewModelList: TextViewModel[] = [] - @State textViewModelList: TextViewModel[] = [] - - aboutToAppear(): void { - this.getResultFromNdk(); - this.process(); - - font.registerFont({ // 自定义字体 - familyName: 'stxingka123', - familySrc: $rawfile('STXINGKA.ttf') // rawfile下 - }) - } - - resourceToString(resource: Resource): string { - return getContext(this).resourceManager.getStringSync(resource); - } - - layoutText() { - const color: ArrayBuffer = new ArrayBuffer(160000); - let opts: image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 200, width: 200 } }; - this.pixelMap = image.createPixelMapSync(color, opts); - let canvas = new drawing.Canvas(this.pixelMap); - let myTextStyle: text.TextStyle = { - color: { - alpha: 255, - red: 255, - green: 0, - blue: 0 - }, - fontSize: 33, - }; - let myParagraphStyle: text.ParagraphStyle = { - textStyle: myTextStyle, - align: 3, - } - let fontCollection = text.FontCollection.getGlobalInstance(); - let paragraphGraphBuilder = new text.ParagraphBuilder(myParagraphStyle, fontCollection); - paragraphGraphBuilder.pushStyle(myTextStyle); - paragraphGraphBuilder.addText('12312'); - paragraphGraphBuilder.pushStyle(myTextStyle); - paragraphGraphBuilder.addText('afdsss'); - - let paragraph = paragraphGraphBuilder.build(); - paragraph.layoutSync(100); - let maxWidth = paragraph.getMaxWidth(); - let height = paragraph.getHeight(); - let longestLine = paragraph.getLongestLine(); - let minIntrinsicWidth = paragraph.getMinIntrinsicWidth(); - let maxIntrinsicWidth = paragraph.getMaxIntrinsicWidth(); - let alphabeticBaseline = paragraph.getAlphabeticBaseline(); - let ideographicBaseline = paragraph.getIdeographicBaseline(); - let range: text.Range = { start: 0, end: 1 }; - let rects = paragraph.getRectsForRange(range, text.RectWidthStyle.TIGHT, text.RectHeightStyle.TIGHT); - let placeholderRects = paragraph.getRectsForPlaceholders(); - let positionWidthAffinity = paragraph.getGlyphPositionAtCoordinate(0, 0); - let wordRange = paragraph.getWordBoundary(0); - let lineCount = paragraph.getLineCount(); - if (lineCount > 0) { - let lineHeight = paragraph.getLineHeight(0); - let lineWidth = paragraph.getLineWidth(0); - } - let didExceed = paragraph.didExceedMaxLines(); - let lines = paragraph.getTextLines(); - paragraph.paint(canvas, 0, 0); - } - - GetSumbleLen() { - let myTextStyle: text.TextStyle = { - fontSize: 12*3.25, - }; - let myParagraphStyle: text.ParagraphStyle = { - textStyle: myTextStyle, - }; - let fontCollection = new text.FontCollection(); - let paragraphGraphBuilder = new text.ParagraphBuilder(myParagraphStyle, fontCollection); - paragraphGraphBuilder.pushStyle(myTextStyle); - paragraphGraphBuilder.addText(this.EXPAND_STR); - let paragraph = paragraphGraphBuilder.build(); - paragraph.layoutSync(200*3.25); - return paragraph.getLineWidth(0); - } - - getFoldIndex() { - let myTextStyle: text.TextStyle = { - color: { - alpha: 255, - red: 255, - green: 0, - blue: 0 - } - }; - let myParagraphStyle: text.ParagraphStyle = { - textStyle: myTextStyle, - }; - let fontCollection = text.FontCollection.getGlobalInstance(); - fontCollection.loadFontSync('123222', $rawfile('FZBWKSJW.TTF')); - let paragraphGraphBuilder = new text.ParagraphBuilder(myParagraphStyle, fontCollection); - for (let i = 0; i < 5; i++) { - let ret: TextViewModel = this.originViewModelList[i]; - let type: number = ret.type; - let content: string = ret.content; - let fontSize: number = ret.fontSize; - let width: number = ret.width; - let height: number = ret.height; - - if (type == 0) { - myTextStyle.fontSize = fontSize * 3.25; - paragraphGraphBuilder.pushStyle(myTextStyle); - paragraphGraphBuilder.addText(content); - } else if (type == 1) { - let myPlaceholderSpan: text.PlaceholderSpan = { - width: width * 3.25, - height: height * 3.25, - align: text.PlaceholderAlignment.ABOVE_BASELINE, - baseline: text.TextBaseline.ALPHABETIC, - baselineOffset: 0 - }; - paragraphGraphBuilder.addPlaceholder(myPlaceholderSpan); - } - } - let paragraph = paragraphGraphBuilder.build(); - paragraph.layoutSync(650); - let curWidth = this.GetSumbleLen(); - let i: number = 53; - if (paragraph.getLineCount() > 2) { - let x = 650 - curWidth; - let y = paragraph.getLineHeight(0) + paragraph.getLineHeight(1)/2; - let positionWithAffinity = paragraph.getGlyphPositionAtCoordinate(x, y); - if (positionWithAffinity.affinity == text.Affinity.UPSTREAM) { - i = positionWithAffinity.position; - } else { - i = positionWithAffinity.position + 1; - } - } - - const color: ArrayBuffer = new ArrayBuffer(650 * 300 * 4); - let opts: image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 300, width: 650 } } - this.pixelMap = image.createPixelMapSync(color, opts); - let canvas = new drawing.Canvas(this.pixelMap); - paragraph.paint(canvas, 0, 0); - - let ret: Results = { - index: i, - lineCount: paragraph.getLineCount(), - } - return ret; - } - - getResultFromNdk(): void { - let result: Results = this.getFoldIndex(); - console.log('GetFoldIndex result: ' + JSON.stringify(result)); - this.lineCount = result.lineCount; - this.collapseIndex = result.index; - if (this.lineCount <= 2) { - this.needProcess = false; - this.textViewModelList = this.originViewModelList; - return; - } - // 裁剪 - let currentIndex = 0; - for (let i = 0; i < this.originViewModelList.length; i++) { - let viewModel: TextViewModel = JSON.parse(JSON.stringify(this.originViewModelList[i])); - if (viewModel.type === 0) { - currentIndex += viewModel.content.length; - } else if (viewModel.type === 1) { - currentIndex += 1; - } - if (currentIndex < this.collapseIndex) { - this.collapseViewModelList.push(viewModel); - } else { - if (viewModel.type === 1) { - break; - } - let subLen = this.collapseIndex - (currentIndex - viewModel.content.length); - viewModel.content = viewModel.content.substring(0, subLen - 1); - this.collapseViewModelList.push(viewModel); - break; - } - } - } - - process(): void { - if (this.expanded) { - this.collapseText(); - } else { - this.expandText(); - } - } - - // 展开文本 - expandText(): void { - if (!this.needProcess) { - return; - } - this.expanded = true; - this.textViewModelList = this.originViewModelList; - this.suffixStr = this.COLLAPSE_STR; - this.suffixStr2 = ''; - } - - // 收起文本 - collapseText(): void { - if (!this.needProcess) { - return; - } - this.expanded = false; - this.textViewModelList = this.collapseViewModelList; - this.suffixStr = this.EXPAND_STR; - this.suffixStr2 = this.EXPAND_STR; - } - build() { - Row() { - Column() { - Text() { - ForEach(this.textViewModelList, (item: TextViewModel) => { - if (item.type === 0) { - Span(item.content) - .fontSize(item.fontSize) - .fontColor(item.height) - } else if (item.type === 1) { - ImageSpan($r(item.content)) - .height(item.height) - .width(item.width) - } - }) - if (this.needProcess) { - if (this.suffixStr == this.COLLAPSE_STR) { - Span('\n'); - } - Span(this.suffixStr) - .fontColor(Color.Orange) - .id('span_click') - .onClick(() => { - this.process(); - }) - } - } - .width('640px') - .borderWidth(1) - .id('text_click') - .onClick(() => { - this.process(); - }) - - Image(this.pixelMap) - .width('640px') - .height('300px') - .borderWidth(1) - .margin(50) - } - .width('100%') - } - .height('100%') - } +/* + * Copyright (c) 2024 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 image from '@ohos.multimedia.image'; +import drawing from '@ohos.graphics.drawing'; +import font from '@ohos.font'; +import { text } from '@kit.ArkGraphics2D'; + +class TextViewModel { + public type: number = 0; + public content: string = ''; + public fontSize: number = 0; + public fontColor: Color = Color.Black; + public width: number = 0; + public height: number = 0; +} + +class Results { + public index: number = 0; + public lineCount: number = 0; +} + +@Entry +@Component +struct TextCollapseTest { + @State suffixStr: string = ''; + @State suffixStr2: string = ''; + EXPAND_STR: string = this.resourceToString($r('app.string.expand_str')); + COLLAPSE_STR: string = this.resourceToString($r('app.string.collapse_str')); + + expanded: Boolean = true; + needProcess: boolean = true; + lineCount: number = 0; + collapseIndex: number = 0; + @State pixelMap: image.PixelMap | undefined = undefined; + + originViewModelList: TextViewModel[] = [ + { + type: 0, + content: this.resourceToString($r('app.string.list_content1')), + fontSize: 8, + fontColor: Color.Black, + width: 0, + height: 0 + }, + { + type: 0, + content: this.resourceToString($r('app.string.list_content2')), + fontSize: 12, + fontColor: Color.Black, + width: 0, + height: 0 + }, + { + type: 1, + content: 'app.media.icon', + fontSize: 12, + fontColor: Color.Black, + width: 20, + height: 20 + }, + { + type: 0, + content: this.resourceToString($r('app.string.list_content3')), + fontSize: 12, + fontColor: Color.Black, + width: 0, + height: 0 + }, + { + type: 1, + content: 'app.media.icon', + fontSize: 12, + fontColor: Color.Black, + width: 20, + height: 20 + }, + ] + collapseViewModelList: TextViewModel[] = [] + @State textViewModelList: TextViewModel[] = [] + + aboutToAppear(): void { + this.getResultFromNdk(); + this.process(); + + font.registerFont({ // 自定义字体 + familyName: 'stxingka123', + familySrc: $rawfile('STXINGKA.ttf') // rawfile下 + }) + } + + resourceToString(resource: Resource): string { + return getContext(this).resourceManager.getStringSync(resource); + } + + layoutText() { + const color: ArrayBuffer = new ArrayBuffer(160000); + let opts: image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 200, width: 200 } }; + this.pixelMap = image.createPixelMapSync(color, opts); + let canvas = new drawing.Canvas(this.pixelMap); + let myTextStyle: text.TextStyle = { + color: { + alpha: 255, + red: 255, + green: 0, + blue: 0 + }, + fontSize: 33, + }; + let myParagraphStyle: text.ParagraphStyle = { + textStyle: myTextStyle, + align: 3, + } + let fontCollection = text.FontCollection.getGlobalInstance(); + let paragraphGraphBuilder = new text.ParagraphBuilder(myParagraphStyle, fontCollection); + paragraphGraphBuilder.pushStyle(myTextStyle); + paragraphGraphBuilder.addText('12312'); + paragraphGraphBuilder.pushStyle(myTextStyle); + paragraphGraphBuilder.addText('afdsss'); + + let paragraph = paragraphGraphBuilder.build(); + paragraph.layoutSync(100); + let maxWidth = paragraph.getMaxWidth(); + let height = paragraph.getHeight(); + let longestLine = paragraph.getLongestLine(); + let minIntrinsicWidth = paragraph.getMinIntrinsicWidth(); + let maxIntrinsicWidth = paragraph.getMaxIntrinsicWidth(); + let alphabeticBaseline = paragraph.getAlphabeticBaseline(); + let ideographicBaseline = paragraph.getIdeographicBaseline(); + let range: text.Range = { start: 0, end: 1 }; + let rects = paragraph.getRectsForRange(range, text.RectWidthStyle.TIGHT, text.RectHeightStyle.TIGHT); + let placeholderRects = paragraph.getRectsForPlaceholders(); + let positionWidthAffinity = paragraph.getGlyphPositionAtCoordinate(0, 0); + let wordRange = paragraph.getWordBoundary(0); + let lineCount = paragraph.getLineCount(); + if (lineCount > 0) { + let lineHeight = paragraph.getLineHeight(0); + let lineWidth = paragraph.getLineWidth(0); + } + let didExceed = paragraph.didExceedMaxLines(); + let lines = paragraph.getTextLines(); + paragraph.paint(canvas, 0, 0); + } + + GetSumbleLen() { + let myTextStyle: text.TextStyle = { + fontSize: 12*3.25, + }; + let myParagraphStyle: text.ParagraphStyle = { + textStyle: myTextStyle, + }; + let fontCollection = new text.FontCollection(); + let paragraphGraphBuilder = new text.ParagraphBuilder(myParagraphStyle, fontCollection); + paragraphGraphBuilder.pushStyle(myTextStyle); + paragraphGraphBuilder.addText(this.EXPAND_STR); + let paragraph = paragraphGraphBuilder.build(); + paragraph.layoutSync(200*3.25); + return paragraph.getLineWidth(0); + } + + getFoldIndex() { + let myTextStyle: text.TextStyle = { + color: { + alpha: 255, + red: 255, + green: 0, + blue: 0 + } + }; + let myParagraphStyle: text.ParagraphStyle = { + textStyle: myTextStyle, + }; + let fontCollection = text.FontCollection.getGlobalInstance(); + fontCollection.loadFontSync('123222', $rawfile('FZBWKSJW.TTF')); + let paragraphGraphBuilder = new text.ParagraphBuilder(myParagraphStyle, fontCollection); + for (let i = 0; i < 5; i++) { + let ret: TextViewModel = this.originViewModelList[i]; + let type: number = ret.type; + let content: string = ret.content; + let fontSize: number = ret.fontSize; + let width: number = ret.width; + let height: number = ret.height; + + if (type == 0) { + myTextStyle.fontSize = fontSize * 3.25; + paragraphGraphBuilder.pushStyle(myTextStyle); + paragraphGraphBuilder.addText(content); + } else if (type == 1) { + let myPlaceholderSpan: text.PlaceholderSpan = { + width: width * 3.25, + height: height * 3.25, + align: text.PlaceholderAlignment.ABOVE_BASELINE, + baseline: text.TextBaseline.ALPHABETIC, + baselineOffset: 0 + }; + paragraphGraphBuilder.addPlaceholder(myPlaceholderSpan); + } + } + let paragraph = paragraphGraphBuilder.build(); + paragraph.layoutSync(650); + let curWidth = this.GetSumbleLen(); + let i: number = 53; + if (paragraph.getLineCount() > 2) { + let x = 650 - curWidth; + let y = paragraph.getLineHeight(0) + paragraph.getLineHeight(1)/2; + let positionWithAffinity = paragraph.getGlyphPositionAtCoordinate(x, y); + if (positionWithAffinity.affinity == text.Affinity.UPSTREAM) { + i = positionWithAffinity.position; + } else { + i = positionWithAffinity.position + 1; + } + } + + const color: ArrayBuffer = new ArrayBuffer(650 * 300 * 4); + let opts: image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 300, width: 650 } } + this.pixelMap = image.createPixelMapSync(color, opts); + let canvas = new drawing.Canvas(this.pixelMap); + paragraph.paint(canvas, 0, 0); + + let ret: Results = { + index: i, + lineCount: paragraph.getLineCount(), + } + return ret; + } + + getResultFromNdk(): void { + let result: Results = this.getFoldIndex(); + console.log('GetFoldIndex result: ' + JSON.stringify(result)); + this.lineCount = result.lineCount; + this.collapseIndex = result.index; + if (this.lineCount <= 2) { + this.needProcess = false; + this.textViewModelList = this.originViewModelList; + return; + } + // 裁剪 + let currentIndex = 0; + for (let i = 0; i < this.originViewModelList.length; i++) { + let viewModel: TextViewModel = JSON.parse(JSON.stringify(this.originViewModelList[i])); + if (viewModel.type === 0) { + currentIndex += viewModel.content.length; + } else if (viewModel.type === 1) { + currentIndex += 1; + } + if (currentIndex < this.collapseIndex) { + this.collapseViewModelList.push(viewModel); + } else { + if (viewModel.type === 1) { + break; + } + let subLen = this.collapseIndex - (currentIndex - viewModel.content.length); + viewModel.content = viewModel.content.substring(0, subLen - 1); + this.collapseViewModelList.push(viewModel); + break; + } + } + } + + process(): void { + if (this.expanded) { + this.collapseText(); + } else { + this.expandText(); + } + } + + // 展开文本 + expandText(): void { + if (!this.needProcess) { + return; + } + this.expanded = true; + this.textViewModelList = this.originViewModelList; + this.suffixStr = this.COLLAPSE_STR; + this.suffixStr2 = ''; + } + + // 收起文本 + collapseText(): void { + if (!this.needProcess) { + return; + } + this.expanded = false; + this.textViewModelList = this.collapseViewModelList; + this.suffixStr = this.EXPAND_STR; + this.suffixStr2 = this.EXPAND_STR; + } + build() { + Row() { + Column() { + Text() { + ForEach(this.textViewModelList, (item: TextViewModel) => { + if (item.type === 0) { + Span(item.content) + .fontSize(item.fontSize) + .fontColor(item.height) + } else if (item.type === 1) { + ImageSpan($r(item.content)) + .height(item.height) + .width(item.width) + } + }) + if (this.needProcess) { + if (this.suffixStr == this.COLLAPSE_STR) { + Span('\n'); + } + Span(this.suffixStr) + .fontColor(Color.Orange) + .id('span_click') + .onClick(() => { + this.process(); + }) + } + } + .width('640px') + .borderWidth(1) + .id('text_click') + .onClick(() => { + this.process(); + }) + + Image(this.pixelMap) + .width('640px') + .height('300px') + .borderWidth(1) + .margin(50) + } + .width('100%') + } + .height('100%') + } } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/module.json5 b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/module.json5 index f8f5350746..53d9f8844f 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/module.json5 +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/module.json5 @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2024 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:startIcon", - "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" - } - ] - } - ] - } +/* + * Copyright (c) 2024 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:startIcon", + "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/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/resources/base/profile/backup_config.json index d742c2f96e..78f40ae7c4 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/resources/base/profile/backup_config.json +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/Graphics2d/ExpandText/hvigor/hvigor-config.json5 b/code/BasicFeature/Graphics/Graphics2d/ExpandText/hvigor/hvigor-config.json5 index 1a924e9230..efe6aee6c8 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/hvigor/hvigor-config.json5 @@ -1,22 +1,22 @@ -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - }, - "execution": { - // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ - // "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": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ - } +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + }, + "execution": { + // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ + // "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": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ + } } \ No newline at end of file diff --git a/code/BasicFeature/Graphics/Graphics2d/ExpandText/oh-package.json5 b/code/BasicFeature/Graphics/Graphics2d/ExpandText/oh-package.json5 index d645a02be5..a941f44583 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/oh-package.json5 +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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" - } -} +/* + * Copyright (c) 2024 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/BasicFeature/Media/AVSession/VideoPlayer/ohosTest.md b/code/BasicFeature/Media/AVSession/VideoPlayer/ohosTest.md index 16890c1471..d802dfabec 100644 --- a/code/BasicFeature/Media/AVSession/VideoPlayer/ohosTest.md +++ b/code/BasicFeature/Media/AVSession/VideoPlayer/ohosTest.md @@ -1,14 +1,14 @@ -# VideoPlayer 测试用例归档 - -## 用例表 - -|测试功能|预置条件|输入|预期输出|测试结果| -|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------| -|拉起应用| 设备正常运行| |成功拉起应用|Pass| -|主页信息展示| 位于主页| |展示当前正在播放的视频信息|Pass| -|主页按钮展示| 位于主页| |展示上一个、下一个、播放暂停按钮|Pass| -|主页进度条展示| 位于主页| |展示播放当前位置时间、视频总时间、进度条|Pass| -|播放| 位于主页| 点击播放按钮| 应用进入播放状态|Pass| -|暂停| 位于主页| 点击暂停按钮| 应用进入暂停状态|Pass| -|上一个| 位于主页| 点击上一个按钮| 开始播放上一个视频|Pass| +# VideoPlayer 测试用例归档 + +## 用例表 + +|测试功能|预置条件|输入|预期输出|测试结果| +|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------| +|拉起应用| 设备正常运行| |成功拉起应用|Pass| +|主页信息展示| 位于主页| |展示当前正在播放的视频信息|Pass| +|主页按钮展示| 位于主页| |展示上一个、下一个、播放暂停按钮|Pass| +|主页进度条展示| 位于主页| |展示播放当前位置时间、视频总时间、进度条|Pass| +|播放| 位于主页| 点击播放按钮| 应用进入播放状态|Pass| +|暂停| 位于主页| 点击暂停按钮| 应用进入暂停状态|Pass| +|上一个| 位于主页| 点击上一个按钮| 开始播放上一个视频|Pass| |下一个| 位于主页| 点击下一个按钮| 开始播放下一个视频|Pass| \ No newline at end of file diff --git a/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/LiveCapturer.ets b/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/LiveCapturer.ets index db5a7c1b7c..fabcf28897 100644 --- a/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/LiveCapturer.ets +++ b/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/LiveCapturer.ets @@ -1,676 +1,676 @@ -/* -* 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 audio from '@ohos.multimedia.audio'; -import fs from '@ohos.file.fs'; -import router from '@ohos.router'; -import { BusinessError } from '@ohos.base'; -import Logger from '../../../ohosTest/ets/utils/Logger'; - -const MIN_RECORD_SECOND = 5; -const TOTAL_SECOND = 30; -const RANDOM_NUM = 10000; -const INTERVAL_TIME = 1000; -const READ_TIME_OUT = 0; -class Options { - offset: number = 0; - length: number = 0; -} - -@Entry -@Component -struct LiveCapturer { - @State fontColor: string = '#182431'; - @State selectedFontColor: string = '#007DFF'; - @State currentIndex: number = 2; - private audioCapturer?: audio.AudioCapturer; - private audioRenderer?: audio.AudioRenderer; - @State recordState: string = 'init'; // [init,started,continued,paused,stoped]; - private audioCapturerOptions: audio.AudioCapturerOptions = { - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - capturerInfo: { - source: audio.SourceType.SOURCE_TYPE_LIVE, - capturerFlags: 0 - } - }; - private audioRendererOptions: audio.AudioRendererOptions = { - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }; - @State title: string = ''; - @State date: string = ''; - @State playSec: number = 0; - @State renderState: number = 0; - @State recordSec: number = 0; - @State showTime: string = '00:00:00'; - private interval: number = 0; - private bufferSize = 0; - private path = ``; - private fd = 0; - @State isRecordOver: boolean = false; - @State start: number = 0; - @State capturerOffsetStart: number = 0; - - @Builder TabBuilder(index: number, btnId: string) { - Column() { - Text(index === 0 ? $r('app.string.NORMAL_CAPTURER') : - index === 1 ? $r('app.string.PARALLEL_CAPTURER') : - $r('app.string.LIVE_CAPTURER')) - .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) - .opacity(this.currentIndex === index ? 1 : 0.6) - .fontSize(16) - .fontWeight(this.currentIndex === index ? 500 : 400) - .lineHeight(22) - .margin({ top: 17, bottom: 7 }); - Divider() - .strokeWidth(2) - .color('#007DFF') - .opacity(this.currentIndex === index ? 1 : 0); - }.width(78).id('btn_' + btnId); - } - - async aboutToAppear(): Promise { - Logger.info('LiveCapturer aboutToAppear'); - await this.initResource(); - } - - async initResource(): Promise { - try { - let isSupportAec = audio.getAudioManager().getStreamManager() - .isAcousticEchoCancelerSupported(audio.SourceType.SOURCE_TYPE_LIVE); - if (!isSupportAec) { //not support echo cancellation, requiring implementation at the application layer - this.audioCapturerOptions.capturerInfo.source = audio.SourceType.SOURCE_TYPE_MIC; - } - this.audioCapturer = await audio.createAudioCapturer(this.audioCapturerOptions); - this.bufferSize = await this.audioCapturer.getBufferSize(); - this.recordState = 'init'; - this.title = `${this.getDate(2)}_${Math.floor(Math.random() * RANDOM_NUM)}`; - this.path = `/data/storage/el2/base/haps/entry/files/live_capturer_${this.title}.pcm`; - this.date = this.getDate(1); - await this.openFile(this.path); - } catch (err) { - let error = err as BusinessError; - Logger.error(`LiveCapturer:createAudioCapturer err=${JSON.stringify(error)}`); - } - } - - async releseResource(): Promise { - if (this.fd > 0) { - this.closeFile(); - this.fd = 0; - } - if (this.interval) { - clearInterval(this.interval); - } - if (this.audioCapturer) { - Logger.info('LiveCapturer,audioCapturer released'); - await this.audioCapturer.release(); - this.audioCapturer = undefined; - this.recordState = 'init'; - clearInterval(this.interval); - } - if (this.audioRenderer) { - Logger.info('LiveCapturer,audioRenderer released'); - await this.audioRenderer.release(); - this.audioRenderer = undefined; - } - } - - async aboutToDisappear(): Promise { - Logger.info('LiveCapturer,aboutToDisappear is called'); - await this.releseResource(); - } - - async openFile(path: string): Promise { - Logger.info(path); - try { - await fs.open(path, 0o100); - Logger.info('file created success'); - } catch (err) { - let error = err as BusinessError; - Logger.error('file created err:' + JSON.stringify(error)); - return; - } - - try { - let file = await fs.open(path, 0o2); - this.fd = file.fd; - Logger.info(`file open success for read and write mode,fd=${file.fd}`); - } catch (err) { - let error = err as BusinessError; - Logger.error('file open err:' + JSON.stringify(error)); - return; - } - } - - async closeFile(): Promise { - try { - await fs.close(this.fd); - Logger.info('file close success'); - } catch (err) { - let error = err as BusinessError; - Logger.error('file close err:' + JSON.stringify(error)); - return; - } - } - - async capturerStart(): Promise { - if (!this.audioCapturer) { - Logger.error(`LiveCapturer,capturerStart:audioCapturer is null`); - return; - } - - try { - await this.audioCapturer.start(); - // when start,init recordSec - this.recordSec = 0; - this.recordState = 'started'; - Logger.info('audioCapturer start ok'); - clearInterval(this.interval); - this.interval = setInterval(async () => { - if (this.recordSec >= TOTAL_SECOND) { - // over TOTAL_SECOND,need to stop auto - clearInterval(this.interval); - if (this.audioCapturer && this.audioCapturer.state === audio.AudioState.STATE_RUNNING) { - await this.capturerStop(); - } - return; - } - this.recordSec++; - this.showTime = this.getTimesBySecond(this.recordSec); - - }, INTERVAL_TIME); - setTimeout(async () => { - await this.readCapturer(); - }, READ_TIME_OUT); - } catch (err) { - let error = err as BusinessError; - Logger.error(`LiveCapturer:audioCapturer start err=${JSON.stringify(error)}`); - } - } - - async renderCreate(): Promise { - try { - this.audioRenderer = await audio.createAudioRenderer(this.audioRendererOptions); - this.renderState = this.audioRenderer.state; - this.audioRenderer.on('stateChange', (state) => { - this.renderState = state; - }); - } catch (err) { - let error = err as BusinessError; - Logger.error(`createAudioRenderer err=${JSON.stringify(error)}`); - } - } - - async renderStart(): Promise { - if (!this.audioRenderer) { - return; - } - let bufferSize = 0; - try { - bufferSize = await this.audioRenderer.getBufferSize(); - await this.audioRenderer.start(); - } catch (err) { - let error = err as BusinessError; - Logger.error(`start err:${JSON.stringify(error)}`); - } - - try { - let stat = await fs.stat(this.path); - let buf = new ArrayBuffer(bufferSize); - Logger.info(`audioRenderer write start..........`); - let startOffset = this.start; - while (startOffset <= stat.size) { - if (this.audioRenderer.state === audio.AudioState.STATE_PAUSED) { - break; - } - // change tag,to stop - if (this.audioRenderer.state === audio.AudioState.STATE_STOPPED) { - break; - } - if (this.audioRenderer.state === audio.AudioState.STATE_RELEASED) { - return; - } - let options: Options = { - offset: startOffset, - length: bufferSize - }; - Logger.info('renderStart,options=' + JSON.stringify(options)); - - await fs.read(this.fd, buf, options); - await this.audioRenderer.write(buf); - this.playSec = Math.round(startOffset / stat.size * this.recordSec); - startOffset = startOffset + bufferSize; - this.start = startOffset; - } - Logger.info(`audioRenderer write end..........`) - if (this.audioRenderer.state === audio.AudioState.STATE_RUNNING) { - this.start = 0; - await this.renderStop(); - } - } catch (err) { - let error = err as BusinessError; - Logger.error(`write err:${JSON.stringify(error)}`); - } - } - - async renderPause(): Promise { - if (!this.audioRenderer) { - return; - } - try { - await this.audioRenderer.pause(); - } catch (err) { - let error = err as BusinessError; - Logger.error(`pause err:${JSON.stringify(error)}`); - } - } - - async renderStop(): Promise { - if (!this.audioRenderer) { - return; - } - try { - await this.audioRenderer.stop(); - this.start = 0; - } catch (err) { - let error = err as BusinessError; - Logger.error(`stop err:${JSON.stringify(error)}`); - } - } - - async releaseStop(): Promise { - if (!this.audioRenderer) { - return; - } - try { - await this.audioRenderer.release(); - } catch (err) { - let error = err as BusinessError; - Logger.error(`release err:${JSON.stringify(error)}`); - } - } - - async capturerContinue(): Promise { - if (!this.audioCapturer) { - Logger.error(`LiveCapturer,capturerContinue:audioCapturer is null`); - return; - } - - try { - await this.audioCapturer.start() - this.recordState = 'continued'; - Logger.info('audioCapturer start ok'); - this.interval = setInterval(async () => { - if (this.recordSec >= TOTAL_SECOND) { - // over TOTAL_SECOND,need to stop auto - clearInterval(this.interval); - if (this.audioCapturer && this.audioCapturer.state === audio.AudioState.STATE_RUNNING) { - await this.capturerStop(); - } - return; - } - this.recordSec++; - this.showTime = this.getTimesBySecond(this.recordSec); - }, INTERVAL_TIME); - setTimeout(async () => { - await this.readCapturer(); - }, READ_TIME_OUT); - } catch (err) { - let error = err as BusinessError; - Logger.error(`LiveCapturer:audioCapturer start err=${JSON.stringify(error)}`); - } - } - - async capturerStop(): Promise { - if (!this.audioCapturer) { - Logger.error(`LiveCapturer,capturerStop:audioCapturer is null`); - return; - } - if (this.recordSec < MIN_RECORD_SECOND) { - return; - } - - try { - await this.audioCapturer.stop(); - // when recordState is started or continued - this.recordState = 'stopped'; - clearInterval(this.interval); - } catch (err) { - let error = err as BusinessError; - // when recordState is paused - this.recordState = 'stopped'; - Logger.info(`LiveCapturer:audioCapturer stop err=${JSON.stringify(error)}`); - } - this.isRecordOver = true; - await this.renderCreate(); - } - - async capturerPause(): Promise { - if (!this.audioCapturer) { - Logger.error(`LiveCapturer,capturerPause:audioCapturer is null`); - return; - } - - try { - await this.audioCapturer.stop(); - this.recordState = 'paused'; - - clearInterval(this.interval); - } catch (err) { - let error = err as BusinessError; - Logger.error(`LiveCapturer:audioCapturer stop err=${JSON.stringify(error)}`); - return; - } - } - - async readCapturer(): Promise { - Logger.info('LiveCapturer:readCapturer enter'); - if (!this.audioCapturer) { - Logger.error(`LiveCapturer,readCapturer:audioCapturer is null`); - return; - } - - try { - let startOffset = this.capturerOffsetStart; - while (true) { - if (this.audioCapturer.state === audio.AudioState.STATE_STOPPED) { - Logger.info('state is changed to be stopped'); - break; - } - let buffer = await this.audioCapturer.read(this.bufferSize, true); - Logger.info('LiveCapturer:readCapturer read success'); - let options: Options = { - offset: startOffset, - length: this.bufferSize - }; - let writen = await fs.write(this.fd, buffer, options); - Logger.info(`LiveCapturer:readCapturer,startOffset=${startOffset},writen=${writen}`); - startOffset += this.bufferSize; - this.capturerOffsetStart = startOffset; - } - } catch (err) { - let error = err as BusinessError; - Logger.error(`readCapturer err=${JSON.stringify(error)}`); - } - } - - formatNumber(num: number): string { - if (num <= 9) { - return '0' + num; - } else { - return '' + num; - } - } - - getDate(mode: number): string { - let date = new Date(); - if (mode === 1) { - return `${date.getFullYear()}/${this.formatNumber(date.getMonth() + 1)}/${this.formatNumber(date.getDate())}`; - } else { - return `${date.getFullYear()}${this.formatNumber(date.getMonth() + 1)}${this.formatNumber(date.getDate())}`; - } - } - - getTimesBySecond(t: number): string { - let h = Math.floor(t / 60 / 60 % 24); - let m = Math.floor(t / 60 % 60); - let s = Math.floor(t % 60); - let hs = h < 10 ? '0' + h : h; - let ms = m < 10 ? '0' + m : m; - let ss = s < 10 ? '0' + s : s; - return `${hs}:${ms}:${ss}`; - } - - @Builder InitRecord() { - Column() { - Image($r('app.media.ic_record')).width(56).height(56); - } - .width('100%') - .height(56) - .position({ y: 60 }) - .id('live_start_record_btn') - .onClick(() => { - this.capturerStart(); - }); - } - - @Builder StartedRecord() { - Column() { - Text(this.showTime).fontSize(21).fontWeight(500).margin({ bottom: 8 }) - }.width('100%').height(66).position({ y: 30 }).id('live_show_time_txt'); - - - Column() { - Image($r('app.media.ic_recording')).width(56).height(56); - } - .width('100%') - .height(56) - .position({ y: 60 }) - .id('live_stop_record_btn') - .onClick(() => { - this.capturerStop(); - }); - - Column() { - Image($r('app.media.ic_record_pause')).width(24).height(24); - Text($r('app.string.PAUSE')).fontSize(12).fontWeight(400).id('live_pause_record_btn').margin({ top: 2 }); - } - .height(56) - .width(56) - .position({ x: '80%', y: 60 }) - .alignItems(HorizontalAlign.Center) - .justifyContent(FlexAlign.Center) - .onClick(() => { - this.capturerPause(); - }); - } - - @Builder PausedRecord() { - Column() { - Text(this.showTime).fontSize(21).fontWeight(500).margin({ bottom: 8 }); - }.width('100%').height(66).position({ y: 30 }); - - Column() { - Image($r('app.media.ic_recording')).width(56).height(56); - }.width('100%').height(56).position({ y: 60 }) - .onClick(() => { - this.capturerStop(); - }); - - Column() { - Image($r('app.media.ic_record_continue')).width(24).height(24); - Text($r('app.string.CONTINUE')).fontSize(12).fontWeight(400).margin({ top: 2 }); - } - .height(56) - .width(56) - .position({ x: '80%', y: 60 }) - .alignItems(HorizontalAlign.Center) - .justifyContent(FlexAlign.Center) - .id('live_continue_record_btn') - .onClick(() => { - this.capturerContinue(); - }); - } - - @Builder FinishedRecord() { - Column() { - Image($r('app.media.ic_record')).width(56).height(56); - } - .width('100%') - .height(56) - .position({ y: 60 }) - .opacity(0.4) - .id('disalbe_btn'); - } - - build() { - Column() { - Column() { - Navigation() { - } - .width('100%') - .height('100%') - .hideBackButton(false) - .titleMode(NavigationTitleMode.Mini) - .title($r('app.string.AUDIO_CAPTURER')) - .mode(NavigationMode.Stack) - .backgroundColor('#F1F3F5'); - } - .id('live_capturer_back_btn') - .width('100%') - .height(56) - .onClick(async () => { - await router.replaceUrl({ url: 'pages/Index' }); - }); - - Column() { - Tabs({ barPosition: BarPosition.Start, index: 2 }) { - TabContent().tabBar(this.TabBuilder(0, 'normal_capturer')); - TabContent().tabBar(this.TabBuilder(1, 'parallel_capturer')); - TabContent().tabBar(this.TabBuilder(2, 'live_capturer')); - } - .vertical(false) - .barMode(BarMode.Fixed) - .barWidth(360) - .barHeight(56) - .animationDuration(400) - .onChange((index: number) => { - this.currentIndex = index; - if (this.currentIndex === 0) { - router.replaceUrl({ url: 'pages/NormalCapturer' }); - } else if (this.currentIndex === 1) { - router.replaceUrl({ url: 'pages/ParallelCapturer' }); - } - }) - .width('100%') - .height(56) - }.padding({ left: 12, right: 12 }); - - - if (this.isRecordOver === true) { - Column() { - Row() { - Text(this.title) - .fontSize(16) - .fontWeight(500) - .fontColor('#182431') - .fontFamily($r('sys.string.ohos_id_text_font_family_medium')); - if (this.renderState === audio.AudioState.STATE_RUNNING) { - Image($r('app.media.ic_record_playing')).width(24).height(24).id('playing_state'); - } else { - Image($r('app.media.ic_record_paused')).width(24).height(24).id('paused_state'); - } - - }.width('100%').height(24).justifyContent(FlexAlign.SpaceBetween).margin({ top: 16 }); - - Row() { - Text(this.date) - .fontSize(16) - .fontWeight(400) - .fontColor('#182431') - .opacity(0.6) - .fontFamily($r('sys.string.ohos_id_text_font_family_medium')); - Text(this.getTimesBySecond(this.recordSec) + '') - .fontSize(16) - .fontWeight(400) - .fontColor('#182431') - .opacity(0.6) - .fontFamily($r('sys.string.ohos_id_text_font_family_medium')); - }.width('100%').height(24).justifyContent(FlexAlign.SpaceBetween).margin({ top: 4 }); - - Row() { - Progress({ value: this.playSec, total: this.recordSec, type: ProgressType.Linear }) - .color('#007DFF') - .value(this.playSec) - .width('100%') - .height(4) - }.margin({ top: 23, bottom: 3 }); - - Row() { - Text(this.getTimesBySecond(this.playSec) + '') - .fontSize(12) - .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) - .fontColor('#182431') - .opacity(0.6) - .fontWeight(400); - Text(this.getTimesBySecond(this.recordSec) + '') - .fontSize(12) - .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) - .fontColor('#182431') - .opacity(0.6) - .fontWeight(400); - }.justifyContent(FlexAlign.SpaceBetween).width('100%'); - } - .width('100%') - .height(126) - .backgroundColor(Color.White) - .borderRadius(24) - .margin({ top: 12 }) - .padding({ left: 12, right: 12 }) - .id('live_player') - .onClick(() => { - if (this.renderState === audio.AudioState.STATE_PREPARED) { - this.renderStart(); - } - if (this.renderState === audio.AudioState.STATE_RUNNING) { - this.renderPause(); - } - if (this.renderState === audio.AudioState.STATE_PAUSED) { - this.renderStart(); - } - if (this.renderState === audio.AudioState.STATE_STOPPED) { - this.renderStart(); - } - }); - } - Row() { - if (this.recordState === 'init') { - this.InitRecord(); - } else if (this.recordState === 'started') { - this.StartedRecord(); - } else if (this.recordState === 'paused') { - this.PausedRecord(); - } else if (this.recordState === 'continued') { - this.StartedRecord(); - } else if (this.recordState === 'stopped') { - this.FinishedRecord(); - } - } - .width('100%') - .alignItems(VerticalAlign.Center) - .height(116) - .position({ y: '82%' }); - } - .width('100%') - .height('100%') - .justifyContent(FlexAlign.Start) - .backgroundColor('#F1F3F5') - .padding({ left: 12, right: 12 }); - } -} +/* +* 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 audio from '@ohos.multimedia.audio'; +import fs from '@ohos.file.fs'; +import router from '@ohos.router'; +import { BusinessError } from '@ohos.base'; +import Logger from '../../../ohosTest/ets/utils/Logger'; + +const MIN_RECORD_SECOND = 5; +const TOTAL_SECOND = 30; +const RANDOM_NUM = 10000; +const INTERVAL_TIME = 1000; +const READ_TIME_OUT = 0; +class Options { + offset: number = 0; + length: number = 0; +} + +@Entry +@Component +struct LiveCapturer { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF'; + @State currentIndex: number = 2; + private audioCapturer?: audio.AudioCapturer; + private audioRenderer?: audio.AudioRenderer; + @State recordState: string = 'init'; // [init,started,continued,paused,stoped]; + private audioCapturerOptions: audio.AudioCapturerOptions = { + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + capturerInfo: { + source: audio.SourceType.SOURCE_TYPE_LIVE, + capturerFlags: 0 + } + }; + private audioRendererOptions: audio.AudioRendererOptions = { + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }; + @State title: string = ''; + @State date: string = ''; + @State playSec: number = 0; + @State renderState: number = 0; + @State recordSec: number = 0; + @State showTime: string = '00:00:00'; + private interval: number = 0; + private bufferSize = 0; + private path = ``; + private fd = 0; + @State isRecordOver: boolean = false; + @State start: number = 0; + @State capturerOffsetStart: number = 0; + + @Builder TabBuilder(index: number, btnId: string) { + Column() { + Text(index === 0 ? $r('app.string.NORMAL_CAPTURER') : + index === 1 ? $r('app.string.PARALLEL_CAPTURER') : + $r('app.string.LIVE_CAPTURER')) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .opacity(this.currentIndex === index ? 1 : 0.6) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }); + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0); + }.width(78).id('btn_' + btnId); + } + + async aboutToAppear(): Promise { + Logger.info('LiveCapturer aboutToAppear'); + await this.initResource(); + } + + async initResource(): Promise { + try { + let isSupportAec = audio.getAudioManager().getStreamManager() + .isAcousticEchoCancelerSupported(audio.SourceType.SOURCE_TYPE_LIVE); + if (!isSupportAec) { //not support echo cancellation, requiring implementation at the application layer + this.audioCapturerOptions.capturerInfo.source = audio.SourceType.SOURCE_TYPE_MIC; + } + this.audioCapturer = await audio.createAudioCapturer(this.audioCapturerOptions); + this.bufferSize = await this.audioCapturer.getBufferSize(); + this.recordState = 'init'; + this.title = `${this.getDate(2)}_${Math.floor(Math.random() * RANDOM_NUM)}`; + this.path = `/data/storage/el2/base/haps/entry/files/live_capturer_${this.title}.pcm`; + this.date = this.getDate(1); + await this.openFile(this.path); + } catch (err) { + let error = err as BusinessError; + Logger.error(`LiveCapturer:createAudioCapturer err=${JSON.stringify(error)}`); + } + } + + async releseResource(): Promise { + if (this.fd > 0) { + this.closeFile(); + this.fd = 0; + } + if (this.interval) { + clearInterval(this.interval); + } + if (this.audioCapturer) { + Logger.info('LiveCapturer,audioCapturer released'); + await this.audioCapturer.release(); + this.audioCapturer = undefined; + this.recordState = 'init'; + clearInterval(this.interval); + } + if (this.audioRenderer) { + Logger.info('LiveCapturer,audioRenderer released'); + await this.audioRenderer.release(); + this.audioRenderer = undefined; + } + } + + async aboutToDisappear(): Promise { + Logger.info('LiveCapturer,aboutToDisappear is called'); + await this.releseResource(); + } + + async openFile(path: string): Promise { + Logger.info(path); + try { + await fs.open(path, 0o100); + Logger.info('file created success'); + } catch (err) { + let error = err as BusinessError; + Logger.error('file created err:' + JSON.stringify(error)); + return; + } + + try { + let file = await fs.open(path, 0o2); + this.fd = file.fd; + Logger.info(`file open success for read and write mode,fd=${file.fd}`); + } catch (err) { + let error = err as BusinessError; + Logger.error('file open err:' + JSON.stringify(error)); + return; + } + } + + async closeFile(): Promise { + try { + await fs.close(this.fd); + Logger.info('file close success'); + } catch (err) { + let error = err as BusinessError; + Logger.error('file close err:' + JSON.stringify(error)); + return; + } + } + + async capturerStart(): Promise { + if (!this.audioCapturer) { + Logger.error(`LiveCapturer,capturerStart:audioCapturer is null`); + return; + } + + try { + await this.audioCapturer.start(); + // when start,init recordSec + this.recordSec = 0; + this.recordState = 'started'; + Logger.info('audioCapturer start ok'); + clearInterval(this.interval); + this.interval = setInterval(async () => { + if (this.recordSec >= TOTAL_SECOND) { + // over TOTAL_SECOND,need to stop auto + clearInterval(this.interval); + if (this.audioCapturer && this.audioCapturer.state === audio.AudioState.STATE_RUNNING) { + await this.capturerStop(); + } + return; + } + this.recordSec++; + this.showTime = this.getTimesBySecond(this.recordSec); + + }, INTERVAL_TIME); + setTimeout(async () => { + await this.readCapturer(); + }, READ_TIME_OUT); + } catch (err) { + let error = err as BusinessError; + Logger.error(`LiveCapturer:audioCapturer start err=${JSON.stringify(error)}`); + } + } + + async renderCreate(): Promise { + try { + this.audioRenderer = await audio.createAudioRenderer(this.audioRendererOptions); + this.renderState = this.audioRenderer.state; + this.audioRenderer.on('stateChange', (state) => { + this.renderState = state; + }); + } catch (err) { + let error = err as BusinessError; + Logger.error(`createAudioRenderer err=${JSON.stringify(error)}`); + } + } + + async renderStart(): Promise { + if (!this.audioRenderer) { + return; + } + let bufferSize = 0; + try { + bufferSize = await this.audioRenderer.getBufferSize(); + await this.audioRenderer.start(); + } catch (err) { + let error = err as BusinessError; + Logger.error(`start err:${JSON.stringify(error)}`); + } + + try { + let stat = await fs.stat(this.path); + let buf = new ArrayBuffer(bufferSize); + Logger.info(`audioRenderer write start..........`); + let startOffset = this.start; + while (startOffset <= stat.size) { + if (this.audioRenderer.state === audio.AudioState.STATE_PAUSED) { + break; + } + // change tag,to stop + if (this.audioRenderer.state === audio.AudioState.STATE_STOPPED) { + break; + } + if (this.audioRenderer.state === audio.AudioState.STATE_RELEASED) { + return; + } + let options: Options = { + offset: startOffset, + length: bufferSize + }; + Logger.info('renderStart,options=' + JSON.stringify(options)); + + await fs.read(this.fd, buf, options); + await this.audioRenderer.write(buf); + this.playSec = Math.round(startOffset / stat.size * this.recordSec); + startOffset = startOffset + bufferSize; + this.start = startOffset; + } + Logger.info(`audioRenderer write end..........`) + if (this.audioRenderer.state === audio.AudioState.STATE_RUNNING) { + this.start = 0; + await this.renderStop(); + } + } catch (err) { + let error = err as BusinessError; + Logger.error(`write err:${JSON.stringify(error)}`); + } + } + + async renderPause(): Promise { + if (!this.audioRenderer) { + return; + } + try { + await this.audioRenderer.pause(); + } catch (err) { + let error = err as BusinessError; + Logger.error(`pause err:${JSON.stringify(error)}`); + } + } + + async renderStop(): Promise { + if (!this.audioRenderer) { + return; + } + try { + await this.audioRenderer.stop(); + this.start = 0; + } catch (err) { + let error = err as BusinessError; + Logger.error(`stop err:${JSON.stringify(error)}`); + } + } + + async releaseStop(): Promise { + if (!this.audioRenderer) { + return; + } + try { + await this.audioRenderer.release(); + } catch (err) { + let error = err as BusinessError; + Logger.error(`release err:${JSON.stringify(error)}`); + } + } + + async capturerContinue(): Promise { + if (!this.audioCapturer) { + Logger.error(`LiveCapturer,capturerContinue:audioCapturer is null`); + return; + } + + try { + await this.audioCapturer.start() + this.recordState = 'continued'; + Logger.info('audioCapturer start ok'); + this.interval = setInterval(async () => { + if (this.recordSec >= TOTAL_SECOND) { + // over TOTAL_SECOND,need to stop auto + clearInterval(this.interval); + if (this.audioCapturer && this.audioCapturer.state === audio.AudioState.STATE_RUNNING) { + await this.capturerStop(); + } + return; + } + this.recordSec++; + this.showTime = this.getTimesBySecond(this.recordSec); + }, INTERVAL_TIME); + setTimeout(async () => { + await this.readCapturer(); + }, READ_TIME_OUT); + } catch (err) { + let error = err as BusinessError; + Logger.error(`LiveCapturer:audioCapturer start err=${JSON.stringify(error)}`); + } + } + + async capturerStop(): Promise { + if (!this.audioCapturer) { + Logger.error(`LiveCapturer,capturerStop:audioCapturer is null`); + return; + } + if (this.recordSec < MIN_RECORD_SECOND) { + return; + } + + try { + await this.audioCapturer.stop(); + // when recordState is started or continued + this.recordState = 'stopped'; + clearInterval(this.interval); + } catch (err) { + let error = err as BusinessError; + // when recordState is paused + this.recordState = 'stopped'; + Logger.info(`LiveCapturer:audioCapturer stop err=${JSON.stringify(error)}`); + } + this.isRecordOver = true; + await this.renderCreate(); + } + + async capturerPause(): Promise { + if (!this.audioCapturer) { + Logger.error(`LiveCapturer,capturerPause:audioCapturer is null`); + return; + } + + try { + await this.audioCapturer.stop(); + this.recordState = 'paused'; + + clearInterval(this.interval); + } catch (err) { + let error = err as BusinessError; + Logger.error(`LiveCapturer:audioCapturer stop err=${JSON.stringify(error)}`); + return; + } + } + + async readCapturer(): Promise { + Logger.info('LiveCapturer:readCapturer enter'); + if (!this.audioCapturer) { + Logger.error(`LiveCapturer,readCapturer:audioCapturer is null`); + return; + } + + try { + let startOffset = this.capturerOffsetStart; + while (true) { + if (this.audioCapturer.state === audio.AudioState.STATE_STOPPED) { + Logger.info('state is changed to be stopped'); + break; + } + let buffer = await this.audioCapturer.read(this.bufferSize, true); + Logger.info('LiveCapturer:readCapturer read success'); + let options: Options = { + offset: startOffset, + length: this.bufferSize + }; + let writen = await fs.write(this.fd, buffer, options); + Logger.info(`LiveCapturer:readCapturer,startOffset=${startOffset},writen=${writen}`); + startOffset += this.bufferSize; + this.capturerOffsetStart = startOffset; + } + } catch (err) { + let error = err as BusinessError; + Logger.error(`readCapturer err=${JSON.stringify(error)}`); + } + } + + formatNumber(num: number): string { + if (num <= 9) { + return '0' + num; + } else { + return '' + num; + } + } + + getDate(mode: number): string { + let date = new Date(); + if (mode === 1) { + return `${date.getFullYear()}/${this.formatNumber(date.getMonth() + 1)}/${this.formatNumber(date.getDate())}`; + } else { + return `${date.getFullYear()}${this.formatNumber(date.getMonth() + 1)}${this.formatNumber(date.getDate())}`; + } + } + + getTimesBySecond(t: number): string { + let h = Math.floor(t / 60 / 60 % 24); + let m = Math.floor(t / 60 % 60); + let s = Math.floor(t % 60); + let hs = h < 10 ? '0' + h : h; + let ms = m < 10 ? '0' + m : m; + let ss = s < 10 ? '0' + s : s; + return `${hs}:${ms}:${ss}`; + } + + @Builder InitRecord() { + Column() { + Image($r('app.media.ic_record')).width(56).height(56); + } + .width('100%') + .height(56) + .position({ y: 60 }) + .id('live_start_record_btn') + .onClick(() => { + this.capturerStart(); + }); + } + + @Builder StartedRecord() { + Column() { + Text(this.showTime).fontSize(21).fontWeight(500).margin({ bottom: 8 }) + }.width('100%').height(66).position({ y: 30 }).id('live_show_time_txt'); + + + Column() { + Image($r('app.media.ic_recording')).width(56).height(56); + } + .width('100%') + .height(56) + .position({ y: 60 }) + .id('live_stop_record_btn') + .onClick(() => { + this.capturerStop(); + }); + + Column() { + Image($r('app.media.ic_record_pause')).width(24).height(24); + Text($r('app.string.PAUSE')).fontSize(12).fontWeight(400).id('live_pause_record_btn').margin({ top: 2 }); + } + .height(56) + .width(56) + .position({ x: '80%', y: 60 }) + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .onClick(() => { + this.capturerPause(); + }); + } + + @Builder PausedRecord() { + Column() { + Text(this.showTime).fontSize(21).fontWeight(500).margin({ bottom: 8 }); + }.width('100%').height(66).position({ y: 30 }); + + Column() { + Image($r('app.media.ic_recording')).width(56).height(56); + }.width('100%').height(56).position({ y: 60 }) + .onClick(() => { + this.capturerStop(); + }); + + Column() { + Image($r('app.media.ic_record_continue')).width(24).height(24); + Text($r('app.string.CONTINUE')).fontSize(12).fontWeight(400).margin({ top: 2 }); + } + .height(56) + .width(56) + .position({ x: '80%', y: 60 }) + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .id('live_continue_record_btn') + .onClick(() => { + this.capturerContinue(); + }); + } + + @Builder FinishedRecord() { + Column() { + Image($r('app.media.ic_record')).width(56).height(56); + } + .width('100%') + .height(56) + .position({ y: 60 }) + .opacity(0.4) + .id('disalbe_btn'); + } + + build() { + Column() { + Column() { + Navigation() { + } + .width('100%') + .height('100%') + .hideBackButton(false) + .titleMode(NavigationTitleMode.Mini) + .title($r('app.string.AUDIO_CAPTURER')) + .mode(NavigationMode.Stack) + .backgroundColor('#F1F3F5'); + } + .id('live_capturer_back_btn') + .width('100%') + .height(56) + .onClick(async () => { + await router.replaceUrl({ url: 'pages/Index' }); + }); + + Column() { + Tabs({ barPosition: BarPosition.Start, index: 2 }) { + TabContent().tabBar(this.TabBuilder(0, 'normal_capturer')); + TabContent().tabBar(this.TabBuilder(1, 'parallel_capturer')); + TabContent().tabBar(this.TabBuilder(2, 'live_capturer')); + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(56) + .animationDuration(400) + .onChange((index: number) => { + this.currentIndex = index; + if (this.currentIndex === 0) { + router.replaceUrl({ url: 'pages/NormalCapturer' }); + } else if (this.currentIndex === 1) { + router.replaceUrl({ url: 'pages/ParallelCapturer' }); + } + }) + .width('100%') + .height(56) + }.padding({ left: 12, right: 12 }); + + + if (this.isRecordOver === true) { + Column() { + Row() { + Text(this.title) + .fontSize(16) + .fontWeight(500) + .fontColor('#182431') + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')); + if (this.renderState === audio.AudioState.STATE_RUNNING) { + Image($r('app.media.ic_record_playing')).width(24).height(24).id('playing_state'); + } else { + Image($r('app.media.ic_record_paused')).width(24).height(24).id('paused_state'); + } + + }.width('100%').height(24).justifyContent(FlexAlign.SpaceBetween).margin({ top: 16 }); + + Row() { + Text(this.date) + .fontSize(16) + .fontWeight(400) + .fontColor('#182431') + .opacity(0.6) + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')); + Text(this.getTimesBySecond(this.recordSec) + '') + .fontSize(16) + .fontWeight(400) + .fontColor('#182431') + .opacity(0.6) + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')); + }.width('100%').height(24).justifyContent(FlexAlign.SpaceBetween).margin({ top: 4 }); + + Row() { + Progress({ value: this.playSec, total: this.recordSec, type: ProgressType.Linear }) + .color('#007DFF') + .value(this.playSec) + .width('100%') + .height(4) + }.margin({ top: 23, bottom: 3 }); + + Row() { + Text(this.getTimesBySecond(this.playSec) + '') + .fontSize(12) + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) + .fontColor('#182431') + .opacity(0.6) + .fontWeight(400); + Text(this.getTimesBySecond(this.recordSec) + '') + .fontSize(12) + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) + .fontColor('#182431') + .opacity(0.6) + .fontWeight(400); + }.justifyContent(FlexAlign.SpaceBetween).width('100%'); + } + .width('100%') + .height(126) + .backgroundColor(Color.White) + .borderRadius(24) + .margin({ top: 12 }) + .padding({ left: 12, right: 12 }) + .id('live_player') + .onClick(() => { + if (this.renderState === audio.AudioState.STATE_PREPARED) { + this.renderStart(); + } + if (this.renderState === audio.AudioState.STATE_RUNNING) { + this.renderPause(); + } + if (this.renderState === audio.AudioState.STATE_PAUSED) { + this.renderStart(); + } + if (this.renderState === audio.AudioState.STATE_STOPPED) { + this.renderStart(); + } + }); + } + Row() { + if (this.recordState === 'init') { + this.InitRecord(); + } else if (this.recordState === 'started') { + this.StartedRecord(); + } else if (this.recordState === 'paused') { + this.PausedRecord(); + } else if (this.recordState === 'continued') { + this.StartedRecord(); + } else if (this.recordState === 'stopped') { + this.FinishedRecord(); + } + } + .width('100%') + .alignItems(VerticalAlign.Center) + .height(116) + .position({ y: '82%' }); + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + .backgroundColor('#F1F3F5') + .padding({ left: 12, right: 12 }); + } +} diff --git a/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/SpatialAudio.ets b/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/SpatialAudio.ets index 59887fe93b..e38e685955 100644 --- a/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/SpatialAudio.ets +++ b/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/SpatialAudio.ets @@ -1,452 +1,452 @@ -/* -* 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 Logger from '../../../ohosTest/ets/utils/Logger'; -import common from '@ohos.app.ability.common'; -import fs from '@ohos.file.fs'; -import router from '@ohos.router'; -import audio from '@ohos.multimedia.audio'; -import promptAction from '@ohos.promptAction' -import { BusinessError } from '@ohos.base'; - -@Entry -@Component -struct SpatialAudio { - private audioRenderers: audio.AudioRenderer[] = []; - private audioRendererOptions: audio.AudioRendererOptions[] = [ - { - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - channelLayout: audio.AudioChannelLayout.CH_LAYOUT_STEREO - }, - - rendererInfo: { - usage: audio.StreamUsage.STREAM_USAGE_MUSIC, - rendererFlags: 0 - } - }, - { - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_6, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - channelLayout: audio.AudioChannelLayout.CH_LAYOUT_5POINT1 - }, - rendererInfo: { - usage: audio.StreamUsage.STREAM_USAGE_MOVIE, - rendererFlags: 0 - } - } - ]; - - private appContext?: common.Context; - private audioSources = ['/2p0.pcm', '/5p1.pcm']; - private audioSpatializationManager?: audio.AudioSpatializationManager; - private audioRoutingManager?: audio.AudioRoutingManager; - private curPos: number[] = [0, 0] - @State supportState: boolean = false; - @State spatializationEnabled: boolean = false; - @State musicState1: boolean = false; - @State musicState2: boolean = false; - - @Builder press2PlayDemo1() { - Image($r('app.media.ic_pause_spa')) - .height(36) - .width(36) - .margin({ right: 16 }) - .id('2P0_play_btn') - .fillColor('#182431') - .onClick(async () => { - this.musicState1 = !this.musicState1; - await this.playAudio(0); - }) - } - - @Builder press2PauseDemo1() { - Image($r('app.media.ic_play_spa')) - .height(36) - .width(36) - .margin({ right: 16 }) - .id('2P0_pause_btn') - .onClick(async () => { - this.musicState1 = !this.musicState1; - await this.pauseAudio(0); - }) - } - - @Builder press2PlayDemo2() { - Image($r('app.media.ic_pause_spa')) - .height(36) - .width(36) - .margin({ right: 16 }) - .id('5P1_play_btn') - .fillColor('#182431') - .onClick(async () => { - if (this.spatializationEnabled === true) { - this.musicState2 = !this.musicState2; - await this.playAudio(1); - } else { - promptAction.showToast({ - duration: 3000, - message: ('请开启空间音频') - }); - } - }) - } - - @Builder press2PauseDemo2() { - Image($r('app.media.ic_play_spa')) - .height(36) - .width(36) - .margin({ right: 16 }) - .id('5P1_pause_btn') - .onClick(async () => { - this.musicState2 = !this.musicState2; - await this.pauseAudio(1); - }) - - } - - @Builder audioVividIfNotSupport() { - Text($r('app.string.5P1_MUSIC')) - .fontSize(20) - .fontWeight(500) - .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) - .fontColor(Color.Grey) - .margin({ top: 21, bottom: 21, left: 16.5 }) - - Image($r('app.media.ic_pause_spa')) - .height(36) - .width(36) - .margin({ right: 16 }) - .id('5P1_play_btn') - } - - @Builder audioVividIfSupport() { - Text($r('app.string.5P1_MUSIC')) - .fontSize(20) - .fontWeight(500) - .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) - .margin({ top: 21, bottom: 21, left: 16.5 }) - } - - @Builder dIYTitle() { - Row() { - Text($r('app.string.SPATIAL_AUDIO')) - .fontWeight(700) - .fontSize(20) - } - .height('100%') - .justifyContent(FlexAlign.Center) - } - - showToastBySpatialEnabled(): void { - if (this.spatializationEnabled === true) { - promptAction.showToast({ - duration: 6000, - message: ('空间音频已开启') - }); - } else { - promptAction.showToast({ - duration: 6000, - message: ('空间音频已关闭') - }); - } - } - - updateSupportStateUI(): void { - this.supportState = this.supportStateQuery(); - if (this.audioSpatializationManager) { - try { - this.spatializationEnabled = this.audioSpatializationManager.isSpatializationEnabledForCurrentDevice(); - } catch (err) { - Logger.error(`update Support State UI failed ,Error: ${JSON.stringify(err)}`); - return; - } - } - } - - supportStateQuery(): boolean { - if (this.audioRoutingManager) { - let audioDeviceDescriptors: audio.AudioDeviceDescriptors = - this.audioRoutingManager.getPreferredOutputDeviceForRendererInfoSync(this.audioRendererOptions[0].rendererInfo); - audioDeviceDescriptors.forEach(audioDeviceDescriptor => { - Logger.info("Device Role:" + audioDeviceDescriptor.deviceRole + ", device Type:" + - audioDeviceDescriptor.deviceType + ", Macaddress:" + audioDeviceDescriptor.address + - ", Support:" + audioDeviceDescriptor.spatializationSupported); - }) - - let isSpaSupported: boolean = false; - if (this.audioSpatializationManager) { - try { - isSpaSupported = audioDeviceDescriptors[0].spatializationSupported as boolean; - } catch (err) { - Logger.error(`supportStateQuery ,Error: ${JSON.stringify(err)}`); - } - } else { - Logger.info('Get manager failed.'); - } - return isSpaSupported; - } - return false; - } - - async init(): Promise { - if (this.appContext) { - return; - } - this.appContext = getContext(this); - - for (let index = 0; index < 2; index++) { - try { - let renderer = await audio.createAudioRenderer(this.audioRendererOptions[index]); - Logger.info('Create renderer success'); - this.audioRenderers.push(renderer); - } catch (err) { - Logger.error(`audioRenderer_${index} create ,Error: ${JSON.stringify(err)}`); - return; - } - } - - let audioManager = audio.getAudioManager(); - try { - this.audioSpatializationManager = audioManager.getSpatializationManager(); - } catch (err) { - Logger.error(`Get Spatialization Manager failed, Error: ${JSON.stringify(err)}`); - return; - } - - this.audioRoutingManager = audioManager.getRoutingManager(); - this.updateSupportStateUI(); - let t_audioRendererInfo: audio.AudioRendererInfo = { - usage: audio.StreamUsage.STREAM_USAGE_MUSIC, - rendererFlags: 0 - } - if (this.audioRoutingManager) { - this.audioRoutingManager.on("preferOutputDeviceChangeForRendererInfo", t_audioRendererInfo, () => { - Logger.info('Output device changed'); - this.updateSupportStateUI(); - if (this.audioRenderers[1] && this.audioRenderers[1].state === audio.AudioState.STATE_RUNNING) { - this.audioRenderers[1].pause(); - this.musicState2 = false; - } - }) - } - if (this.audioSpatializationManager) { - this.audioSpatializationManager.on("spatializationEnabledChangeForCurrentDevice", (res) => { - this.spatializationEnabled = res; - this.showToastBySpatialEnabled(); - }) - } - } - - async over(): Promise { - this.appContext = undefined; - try { - this.audioRenderers[0].stop(); - this.audioRenderers[0].release(); - this.audioRenderers[1].stop(); - this.audioRenderers[1].release(); - } catch (err) { - let error = err as BusinessError; - Logger.error(`AudioRenderer stop or release : Error: ${JSON.stringify(error)}`); - return; - } - this.audioRenderers = []; - - if (this.audioRoutingManager) { - this.audioRoutingManager.off("deviceChange"); - } - - if (this.audioSpatializationManager) { - this.audioSpatializationManager.off("spatializationEnabledChangeForCurrentDevice"); - } - } - - async playAudio(index: number): Promise { - if (this.audioRenderers[index] === null) { - return; - } - - let bufferSize: number = 0; - try { - bufferSize = await this.audioRenderers[index].getBufferSize(); - await this.audioRenderers[index].start(); - } catch (err) { - let error = err as BusinessError; - Logger.error(`AudioRenderer start : Error: ${JSON.stringify(error)}`); - return; - } - - let buf = new ArrayBuffer(bufferSize); - let filePath: string = ""; - if (this.appContext) { - filePath = this.appContext.filesDir + this.audioSources[index]; - } - let stat = await fs.stat(filePath); - let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1); - let file = await fs.open(filePath, 0o0); - let i: number = this.curPos[index] - - while (true) { - if (!this.audioRenderers[index]) { - break; - } - Logger.info('start write'); - while (i < len) { - if (this.audioRenderers[index].state === audio.AudioState.STATE_RELEASED) { - return; - } - if (this.audioRenderers[index].state === audio.AudioState.STATE_PAUSED) { - this.curPos[index] = i; - return; - } - - class options { - offset: number = 0 - length: number = 0 - } - - let readOptions: options = { - offset: i * bufferSize, - length: bufferSize - } - await fs.read(file.fd, buf, readOptions); - await this.audioRenderers[index].write(buf); - i += 1; - } - i = 0; - } - - } - - async pauseAudio(index: number): Promise { - try { - if (this.audioRenderers[index]) { - await this.audioRenderers[index].pause(); - } - } catch (err) { - Logger.error(`Pause Error: ${JSON.stringify(err)}`); - return; - } - } - - async aboutToAppear(): Promise { - await this.init(); - } - - aboutToDisappear(): void { - this.over(); - } - - onPageShow(): void { - if (this.audioSpatializationManager === undefined) { - return; - } - this.updateSupportStateUI() - Logger.info('Page show'); - } - - onPageHide(): void { - Logger.info('Page Hide'); - if (this.audioRenderers[0] && this.audioRenderers[0].state === audio.AudioState.STATE_RUNNING) { - this.audioRenderers[0].pause(); - this.musicState1 = false; - } - if (this.audioRenderers[1] && this.audioRenderers[1].state === audio.AudioState.STATE_RUNNING) { - this.audioRenderers[1].pause(); - this.musicState2 = false; - } - } - - build() { - Column() { - Column() { - Row() { - Navigation() { - } - .hideBackButton(false) - .titleMode(NavigationTitleMode.Mini) - .title(this.dIYTitle()) - .mode(NavigationMode.Stack) - } - .height(56) - .width(360) - .id('spatial_audio_back_btn') - .onClick(async () => { - await router.replaceUrl({ url: 'pages/Index' }); - }) - - Row() { - Row() { - Text($r('app.string.2P0_MUSIC')) - .fontSize(20) - .fontWeight(500) - .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) - .margin({ top: 21, bottom: 21, left: 16.5 }) - if (!this.musicState1) { - this.press2PlayDemo1(); - } else { - this.press2PauseDemo1(); - } - } - .height('100%') - .width(336) - .backgroundColor('#FFFFFF') - .justifyContent(FlexAlign.SpaceBetween) - .borderRadius(24) - } - .justifyContent(FlexAlign.SpaceAround) - .height(68) - .width('100%') - .margin({ top: 8 }) - - Row() { - Row() { - if (this.supportState === false) { - this.audioVividIfNotSupport(); - } else { - this.audioVividIfSupport(); - if (!this.musicState2) { - this.press2PlayDemo2(); - } else { - this.press2PauseDemo2(); - } - } - } - .height('100%') - .width(336) - .backgroundColor('#FFFFFF') - .justifyContent(FlexAlign.SpaceBetween) - .borderRadius(24) - } - .justifyContent(FlexAlign.SpaceAround) - .height(68) - .width('100%') - .margin({ top: 12 }) - } - .width('100%') - .justifyContent(FlexAlign.Start) - } - .height('100%') - .width('100%') - .backgroundColor('#f1f3f5') - .justifyContent(FlexAlign.SpaceBetween) - } +/* +* 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 Logger from '../../../ohosTest/ets/utils/Logger'; +import common from '@ohos.app.ability.common'; +import fs from '@ohos.file.fs'; +import router from '@ohos.router'; +import audio from '@ohos.multimedia.audio'; +import promptAction from '@ohos.promptAction' +import { BusinessError } from '@ohos.base'; + +@Entry +@Component +struct SpatialAudio { + private audioRenderers: audio.AudioRenderer[] = []; + private audioRendererOptions: audio.AudioRendererOptions[] = [ + { + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + channelLayout: audio.AudioChannelLayout.CH_LAYOUT_STEREO + }, + + rendererInfo: { + usage: audio.StreamUsage.STREAM_USAGE_MUSIC, + rendererFlags: 0 + } + }, + { + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_6, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + channelLayout: audio.AudioChannelLayout.CH_LAYOUT_5POINT1 + }, + rendererInfo: { + usage: audio.StreamUsage.STREAM_USAGE_MOVIE, + rendererFlags: 0 + } + } + ]; + + private appContext?: common.Context; + private audioSources = ['/2p0.pcm', '/5p1.pcm']; + private audioSpatializationManager?: audio.AudioSpatializationManager; + private audioRoutingManager?: audio.AudioRoutingManager; + private curPos: number[] = [0, 0] + @State supportState: boolean = false; + @State spatializationEnabled: boolean = false; + @State musicState1: boolean = false; + @State musicState2: boolean = false; + + @Builder press2PlayDemo1() { + Image($r('app.media.ic_pause_spa')) + .height(36) + .width(36) + .margin({ right: 16 }) + .id('2P0_play_btn') + .fillColor('#182431') + .onClick(async () => { + this.musicState1 = !this.musicState1; + await this.playAudio(0); + }) + } + + @Builder press2PauseDemo1() { + Image($r('app.media.ic_play_spa')) + .height(36) + .width(36) + .margin({ right: 16 }) + .id('2P0_pause_btn') + .onClick(async () => { + this.musicState1 = !this.musicState1; + await this.pauseAudio(0); + }) + } + + @Builder press2PlayDemo2() { + Image($r('app.media.ic_pause_spa')) + .height(36) + .width(36) + .margin({ right: 16 }) + .id('5P1_play_btn') + .fillColor('#182431') + .onClick(async () => { + if (this.spatializationEnabled === true) { + this.musicState2 = !this.musicState2; + await this.playAudio(1); + } else { + promptAction.showToast({ + duration: 3000, + message: ('请开启空间音频') + }); + } + }) + } + + @Builder press2PauseDemo2() { + Image($r('app.media.ic_play_spa')) + .height(36) + .width(36) + .margin({ right: 16 }) + .id('5P1_pause_btn') + .onClick(async () => { + this.musicState2 = !this.musicState2; + await this.pauseAudio(1); + }) + + } + + @Builder audioVividIfNotSupport() { + Text($r('app.string.5P1_MUSIC')) + .fontSize(20) + .fontWeight(500) + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) + .fontColor(Color.Grey) + .margin({ top: 21, bottom: 21, left: 16.5 }) + + Image($r('app.media.ic_pause_spa')) + .height(36) + .width(36) + .margin({ right: 16 }) + .id('5P1_play_btn') + } + + @Builder audioVividIfSupport() { + Text($r('app.string.5P1_MUSIC')) + .fontSize(20) + .fontWeight(500) + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) + .margin({ top: 21, bottom: 21, left: 16.5 }) + } + + @Builder dIYTitle() { + Row() { + Text($r('app.string.SPATIAL_AUDIO')) + .fontWeight(700) + .fontSize(20) + } + .height('100%') + .justifyContent(FlexAlign.Center) + } + + showToastBySpatialEnabled(): void { + if (this.spatializationEnabled === true) { + promptAction.showToast({ + duration: 6000, + message: ('空间音频已开启') + }); + } else { + promptAction.showToast({ + duration: 6000, + message: ('空间音频已关闭') + }); + } + } + + updateSupportStateUI(): void { + this.supportState = this.supportStateQuery(); + if (this.audioSpatializationManager) { + try { + this.spatializationEnabled = this.audioSpatializationManager.isSpatializationEnabledForCurrentDevice(); + } catch (err) { + Logger.error(`update Support State UI failed ,Error: ${JSON.stringify(err)}`); + return; + } + } + } + + supportStateQuery(): boolean { + if (this.audioRoutingManager) { + let audioDeviceDescriptors: audio.AudioDeviceDescriptors = + this.audioRoutingManager.getPreferredOutputDeviceForRendererInfoSync(this.audioRendererOptions[0].rendererInfo); + audioDeviceDescriptors.forEach(audioDeviceDescriptor => { + Logger.info("Device Role:" + audioDeviceDescriptor.deviceRole + ", device Type:" + + audioDeviceDescriptor.deviceType + ", Macaddress:" + audioDeviceDescriptor.address + + ", Support:" + audioDeviceDescriptor.spatializationSupported); + }) + + let isSpaSupported: boolean = false; + if (this.audioSpatializationManager) { + try { + isSpaSupported = audioDeviceDescriptors[0].spatializationSupported as boolean; + } catch (err) { + Logger.error(`supportStateQuery ,Error: ${JSON.stringify(err)}`); + } + } else { + Logger.info('Get manager failed.'); + } + return isSpaSupported; + } + return false; + } + + async init(): Promise { + if (this.appContext) { + return; + } + this.appContext = getContext(this); + + for (let index = 0; index < 2; index++) { + try { + let renderer = await audio.createAudioRenderer(this.audioRendererOptions[index]); + Logger.info('Create renderer success'); + this.audioRenderers.push(renderer); + } catch (err) { + Logger.error(`audioRenderer_${index} create ,Error: ${JSON.stringify(err)}`); + return; + } + } + + let audioManager = audio.getAudioManager(); + try { + this.audioSpatializationManager = audioManager.getSpatializationManager(); + } catch (err) { + Logger.error(`Get Spatialization Manager failed, Error: ${JSON.stringify(err)}`); + return; + } + + this.audioRoutingManager = audioManager.getRoutingManager(); + this.updateSupportStateUI(); + let t_audioRendererInfo: audio.AudioRendererInfo = { + usage: audio.StreamUsage.STREAM_USAGE_MUSIC, + rendererFlags: 0 + } + if (this.audioRoutingManager) { + this.audioRoutingManager.on("preferOutputDeviceChangeForRendererInfo", t_audioRendererInfo, () => { + Logger.info('Output device changed'); + this.updateSupportStateUI(); + if (this.audioRenderers[1] && this.audioRenderers[1].state === audio.AudioState.STATE_RUNNING) { + this.audioRenderers[1].pause(); + this.musicState2 = false; + } + }) + } + if (this.audioSpatializationManager) { + this.audioSpatializationManager.on("spatializationEnabledChangeForCurrentDevice", (res) => { + this.spatializationEnabled = res; + this.showToastBySpatialEnabled(); + }) + } + } + + async over(): Promise { + this.appContext = undefined; + try { + this.audioRenderers[0].stop(); + this.audioRenderers[0].release(); + this.audioRenderers[1].stop(); + this.audioRenderers[1].release(); + } catch (err) { + let error = err as BusinessError; + Logger.error(`AudioRenderer stop or release : Error: ${JSON.stringify(error)}`); + return; + } + this.audioRenderers = []; + + if (this.audioRoutingManager) { + this.audioRoutingManager.off("deviceChange"); + } + + if (this.audioSpatializationManager) { + this.audioSpatializationManager.off("spatializationEnabledChangeForCurrentDevice"); + } + } + + async playAudio(index: number): Promise { + if (this.audioRenderers[index] === null) { + return; + } + + let bufferSize: number = 0; + try { + bufferSize = await this.audioRenderers[index].getBufferSize(); + await this.audioRenderers[index].start(); + } catch (err) { + let error = err as BusinessError; + Logger.error(`AudioRenderer start : Error: ${JSON.stringify(error)}`); + return; + } + + let buf = new ArrayBuffer(bufferSize); + let filePath: string = ""; + if (this.appContext) { + filePath = this.appContext.filesDir + this.audioSources[index]; + } + let stat = await fs.stat(filePath); + let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1); + let file = await fs.open(filePath, 0o0); + let i: number = this.curPos[index] + + while (true) { + if (!this.audioRenderers[index]) { + break; + } + Logger.info('start write'); + while (i < len) { + if (this.audioRenderers[index].state === audio.AudioState.STATE_RELEASED) { + return; + } + if (this.audioRenderers[index].state === audio.AudioState.STATE_PAUSED) { + this.curPos[index] = i; + return; + } + + class options { + offset: number = 0 + length: number = 0 + } + + let readOptions: options = { + offset: i * bufferSize, + length: bufferSize + } + await fs.read(file.fd, buf, readOptions); + await this.audioRenderers[index].write(buf); + i += 1; + } + i = 0; + } + + } + + async pauseAudio(index: number): Promise { + try { + if (this.audioRenderers[index]) { + await this.audioRenderers[index].pause(); + } + } catch (err) { + Logger.error(`Pause Error: ${JSON.stringify(err)}`); + return; + } + } + + async aboutToAppear(): Promise { + await this.init(); + } + + aboutToDisappear(): void { + this.over(); + } + + onPageShow(): void { + if (this.audioSpatializationManager === undefined) { + return; + } + this.updateSupportStateUI() + Logger.info('Page show'); + } + + onPageHide(): void { + Logger.info('Page Hide'); + if (this.audioRenderers[0] && this.audioRenderers[0].state === audio.AudioState.STATE_RUNNING) { + this.audioRenderers[0].pause(); + this.musicState1 = false; + } + if (this.audioRenderers[1] && this.audioRenderers[1].state === audio.AudioState.STATE_RUNNING) { + this.audioRenderers[1].pause(); + this.musicState2 = false; + } + } + + build() { + Column() { + Column() { + Row() { + Navigation() { + } + .hideBackButton(false) + .titleMode(NavigationTitleMode.Mini) + .title(this.dIYTitle()) + .mode(NavigationMode.Stack) + } + .height(56) + .width(360) + .id('spatial_audio_back_btn') + .onClick(async () => { + await router.replaceUrl({ url: 'pages/Index' }); + }) + + Row() { + Row() { + Text($r('app.string.2P0_MUSIC')) + .fontSize(20) + .fontWeight(500) + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) + .margin({ top: 21, bottom: 21, left: 16.5 }) + if (!this.musicState1) { + this.press2PlayDemo1(); + } else { + this.press2PauseDemo1(); + } + } + .height('100%') + .width(336) + .backgroundColor('#FFFFFF') + .justifyContent(FlexAlign.SpaceBetween) + .borderRadius(24) + } + .justifyContent(FlexAlign.SpaceAround) + .height(68) + .width('100%') + .margin({ top: 8 }) + + Row() { + Row() { + if (this.supportState === false) { + this.audioVividIfNotSupport(); + } else { + this.audioVividIfSupport(); + if (!this.musicState2) { + this.press2PlayDemo2(); + } else { + this.press2PauseDemo2(); + } + } + } + .height('100%') + .width(336) + .backgroundColor('#FFFFFF') + .justifyContent(FlexAlign.SpaceBetween) + .borderRadius(24) + } + .justifyContent(FlexAlign.SpaceAround) + .height(68) + .width('100%') + .margin({ top: 12 }) + } + .width('100%') + .justifyContent(FlexAlign.Start) + } + .height('100%') + .width('100%') + .backgroundColor('#f1f3f5') + .justifyContent(FlexAlign.SpaceBetween) + } } \ No newline at end of file diff --git a/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/VolumePanel.ets b/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/VolumePanel.ets index 741cab891d..9de568e387 100644 --- a/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/VolumePanel.ets +++ b/code/BasicFeature/Media/Audio/entry/src/main/ets/pages/VolumePanel.ets @@ -1,82 +1,82 @@ -/* -* Copyright (C) 2024 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 router from '@ohos.router'; -import audio from '@ohos.multimedia.audio'; -import display from '@ohos.display'; -import { AVVolumePanel } from '@ohos.multimedia.avVolumePanel'; - -@Entry -@Component -struct VolumePanel { - @State private curMediaVolume: number = 0; - private audioManager: audio.AudioManager = audio.getAudioManager(); - private audioVolumeManager: audio.AudioVolumeManager | undefined = undefined; - - aboutToAppear(): void { - this.audioVolumeManager = this.audioManager.getVolumeManager(); - this.audioVolumeManager?.on('volumeChange', async (data) => { - let event: audio.VolumeEvent = data; - this.curMediaVolume = event.volume; - }) - } - - build() { - Column() { - Row() { - Navigation() { - NavRouter() { - NavDestination() { - } - } - } - .height('100%') - .width('100%') - .hideBackButton(false) - .titleMode(NavigationTitleMode.Mini) - .title($r('app.string.AVVOLUME_PANEL_TITLE')) - .mode(NavigationMode.Stack); - }.height(56).width('100%').id('back_btn_focus') - .onClick(async () => { - await router.pushUrl({ url: 'pages/Index' }); - }); - - Column() { - Row() { - Button() { - Text($r('app.string.VOLUME_UP')).fontSize(22).fontColor(Color.White) - }.width('49%').height(60).onClick(() => { - this.curMediaVolume++; - }) - - Button() { - Text($r('app.string.VOLUME_DOWN')).fontSize(22).fontColor(Color.White) - }.width('49%').height(60).onClick(() => { - this.curMediaVolume--; - }) - }.margin(({ top: 10 })).width('100%').justifyContent(FlexAlign.SpaceBetween) - - AVVolumePanel({ - volumeLevel: this.curMediaVolume, - volumeParameter: { - position: { - x: display.getDefaultDisplaySync().width / 2 - vp2px(20), - y: display.getDefaultDisplaySync().height / 2 - vp2px(83) - } - } - }) - } - } - } +/* +* Copyright (C) 2024 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 router from '@ohos.router'; +import audio from '@ohos.multimedia.audio'; +import display from '@ohos.display'; +import { AVVolumePanel } from '@ohos.multimedia.avVolumePanel'; + +@Entry +@Component +struct VolumePanel { + @State private curMediaVolume: number = 0; + private audioManager: audio.AudioManager = audio.getAudioManager(); + private audioVolumeManager: audio.AudioVolumeManager | undefined = undefined; + + aboutToAppear(): void { + this.audioVolumeManager = this.audioManager.getVolumeManager(); + this.audioVolumeManager?.on('volumeChange', async (data) => { + let event: audio.VolumeEvent = data; + this.curMediaVolume = event.volume; + }) + } + + build() { + Column() { + Row() { + Navigation() { + NavRouter() { + NavDestination() { + } + } + } + .height('100%') + .width('100%') + .hideBackButton(false) + .titleMode(NavigationTitleMode.Mini) + .title($r('app.string.AVVOLUME_PANEL_TITLE')) + .mode(NavigationMode.Stack); + }.height(56).width('100%').id('back_btn_focus') + .onClick(async () => { + await router.pushUrl({ url: 'pages/Index' }); + }); + + Column() { + Row() { + Button() { + Text($r('app.string.VOLUME_UP')).fontSize(22).fontColor(Color.White) + }.width('49%').height(60).onClick(() => { + this.curMediaVolume++; + }) + + Button() { + Text($r('app.string.VOLUME_DOWN')).fontSize(22).fontColor(Color.White) + }.width('49%').height(60).onClick(() => { + this.curMediaVolume--; + }) + }.margin(({ top: 10 })).width('100%').justifyContent(FlexAlign.SpaceBetween) + + AVVolumePanel({ + volumeLevel: this.curMediaVolume, + volumeParameter: { + position: { + x: display.getDefaultDisplaySync().width / 2 - vp2px(20), + y: display.getDefaultDisplaySync().height / 2 - vp2px(83) + } + } + }) + } + } + } } \ No newline at end of file diff --git a/code/BasicFeature/Media/Camera/README.md b/code/BasicFeature/Media/Camera/README.md index 2b9b279add..91504c7513 100644 --- a/code/BasicFeature/Media/Camera/README.md +++ b/code/BasicFeature/Media/Camera/README.md @@ -1,141 +1,141 @@ - -# 相机 - -### 介绍 - -本示例主要展示了相机的相关功能,使用[libohcamera.so] -当前版本sample仅用作联调,最新sdk未带相机c接口头文件。 -接口实现相机的预览、拍照、录像、前后置摄像头切换进行拍照、录像,以及闪光灯、变焦、对焦、曝光等控制类功能。 - -### 效果预览 - -| 相机权限 | 图片和视频权限 | 麦克风权限 | 预览界面 | -|----------------------------|----------------------------|----------------------------|---------------------------------| -| ![auth](app_pic/auth1.jpg) | ![auth](app_pic/auth2.jpg) | ![auth](app_pic/auth3.jpg) | ![preview](app_pic/preview.jpg) | - -使用说明 -(因RK3568设备硬件能力,现仅支持验证1、2、3、9、10、13) -1. 弹出是否允许“CameraSample”使用相机?点击“允许” -2. 弹出是否允许“CameraSample”访问图片和视频?点击“允许” -3. 弹出是否允许“CameraSample”使用麦克风?点击“允许” -4. 进入预览界面,预览正常,滑动变焦按钮,同一画面远近变焦效果明显 -5. 进入预览界面,预览正常,点击画面模糊处,点击处画面会变得清晰,对焦效果明显 -6. 进入预览界面,预览正常,上下滑动屏幕,屏幕场景亮度发生变化,曝光效果明显 -7. 进入预览界面,预览正常,点击闪光灯按钮,打开闪光灯,闪光灯正常打开 -8. 进入预览界面,预览正常,点击闪光灯按钮,关闭闪光灯,闪光灯关闭 -9. 进入预览界面,预览正常,进入拍照模式,点击拍照按钮,拍照正常,左下角会生成照片缩略图,点击左下角缩略图,能够跳转到图库,图片保存正常,打开图片显示正常 -10. 进入预览界面,预览正常,切换到录像模式,点击录像,开始录像,再点击停止录像按钮,录像成功,左下角会生成视频缩略图,点击左下角缩略图,能够跳转到图库,录像文件保存正常,播放录像文件正常 -11. 进入预览界面,预览正常,切换到前置摄像头,点击拍照按钮,拍照正常,左下角会生成照片缩略图,点击左下角缩略图,能够跳转到图库,图片保存正常,打开图片显示正常 -12. 进入预览界面,预览正常,切换到前置摄像头,切换到录像模式,点击录像,开始录像,再点击停止录像按钮,录像成功,左下角会生成视频缩略图,点击左下角缩略图,能够跳转到图库,录像文件保存正常,播放录像文件正常 -13. 点击设置按钮,会弹出设置页面,仅验证UI。 - -### 工程目录 - -``` -entry/src/main -|-- cpp -| |-- CMakeLists.txt // Cmake打包配置文件,编译工程动态库脚本,依赖头文件、cpp以及相关依赖 -| |-- camera_manager.cpp // 相机基本功能接口定义cpp实现侧 -| |-- camera_manager.h // 相机基本功能接口定义头文件 -| |-- main.cpp // NAPI实现JS与C++通信的接口 -| |-- types -| `-- libentry -| |-- index.d.ts // 导入NAPI接口供JS调用 -| `-- oh-package.json5 // 接口注册配置文件 -|-- ets -| |-- Dialog -| | |-- mainDialog.ets // 打开相机APP弹出的网络权限设置 -| | `-- settingDialog.ets // 相机APP设置界面布局 -| |-- MainAbility -| | `-- MainAbility.ts // 对Ability生命周期管理 -| |-- common -| | |-- Constants.ts // 基本参数枚举:纵横比、设备类型、视频帧数 -| | |-- DisplayCalculator.ts // 计算界面宽高显示数值 -| | |-- settingItem.ets // 设置栏 -| | |-- settingPublicLayout.ets // 设置栏公共区域 -| | `-- settingRightLayout.ets // 设置栏右边区域 -| |-- entryability -| | `-- EntryAbility.ts // Ability的生命周期回调内容 -| |-- model -| | |-- DateTimeUtil.ts // 日期工具 -| | |-- Logger.ts // 日志工具 -| | `-- MediaUtils.ts // 媒体工具 -| |-- pages -| | `-- Index.ets // Ability实现的应用的入口页面,相机APP首页 -| `-- views -| |-- CountdownPage.ets // 倒计时UI页面布局 -| |-- FlashingLightPage.ets // 闪光灯UI界面布局 -| |-- SlidePage.ets // 滑动滑块UI界面布局 -| |-- dividerPage.ets // 分割线UI布局 -| |-- focusAreaPage.ets // 对焦区域设置(焦点、侧光点)、单指竖直方向拖动触发曝光补偿设置 -| |-- focusPage.ets // 变焦、对焦、曝光、刻度的图标设置、值的设置 -| `-- modeSwitchPage.ets // 相机功能模式切换,开启预览、拍照、录像 - -``` - -### 具体实现 -* 相机功能接口实现在CameraManager.cpp中,源码参考:[CameraManager.cpp](entry/src/main/cpp/camera_manager.cpp) - * 在NDKCamera构造函数里完成一个相机生命周期初始化的过程,包括调用OH_Camera_GetCameraMananger获取CameraMananger,调用OH_CameraManager_CreateCaptureSession创建CaptureSession,调用CaptureSessionRegisterCallback创建CaptureSession注册回调,调用GetSupportedCameras获取支持的camera设备,调用GetSupportedOutputCapability获取支持的camera设备能力集,调用CreatePreviewOutput创建预览输出,调用CreateCameraInput创建相机输入,调用CameraInputOpen打开相机输入,调用CameraManagerRegisterCallback创建CameraManager注册回调,最后调用SessionFlowFn开启Session。 - * 其中SessionFlowFn是一个开启预览的动作,主要流程包括:调用OH_CaptureSession_BeginConfig开始配置会话,调用OH_CaptureSession_AddInput把CameraInput加入到会话,调用OH_CaptureSession_AddPreviewOutput把previewOutput加入到会话,调用OH_CaptureSession_CommitConfig提交配置信息,调用OH_CaptureSession_Start开始会话工作,还有一步是在开启预览的同时调用IsFocusMode启动对焦功能,这边后面会涉及到。 - * 在NDKCamera析构函数里完成对相机生命周期释放的过程,调用OH_CameraManager_DeleteSupportedCameras删除支持的camera设备,调用OH_CameraManager_DeleteSupportedCameraOutputCapability删除支持的camera设备能力集,调用OH_Camera_DeleteCameraMananger删除camera manager。 - * 拍照功能相关接口封装在StartPhoto接口中,主要包含以下流程:调用SessionStop关闭session,调用SessionBegin做session的一个预置动作,调用CreatePhotoOutput创建相机输出,调用OH_CaptureSession_AddPhotoOutput将hotoOutput添加至session中,调用SessionCommitConfig提交session,在调用SessionStart开启session,最后调用TakePicture接口开启拍照动作。 - * 录像功能相关接口封装在StartVideo接口中,主要包含以下流程:调用SessionStop关闭session,调用SessionBegin做session的一个预置动作,调用OH_CaptureSession_RemovePhotoOutput移除相机拍照输出,再调用CreatePhotoOutput创建相机输出,调用AddPhotoOutput将相机输出添加至session中,调用CreateVideoOutput创建录像输出,调用AddVideoOutput将录像输出添加至session中,然后再调用SessionCommitConfig、SessionStart对session进行提交和开启,最后调用VideoOutputRegisterCallback对VideoOutput注册回调。 - * 闪光灯功能相关接口封装在HasFlashFn接口中,主要包含以下流程:调用OH_CaptureSession_HasFlash检测是否支持闪光灯设备,再调用OH_CaptureSession_IsFlashModeSupported检测闪光灯模式是否支持,然后调用OH_CaptureSession_SetFlashMode设置闪光灯模式,最后调用OH_CaptureSession_GetFlashMode获取当前设备的闪光灯模式。 - * 变焦功能相关接口封装在setZoomRatioFn接口中,主要包含以下流程:调用OH_CaptureSession_GetZoomRatioRange获取支持的变焦范围,调用OH_CaptureSession_SetZoomRatio设置变焦,调用OH_CaptureSession_GetZoomRatio获取当前设备的变焦值。 - * 曝光功能相关接口封装在IsExposureModeSupportedFn接口中,主要包含以下流程:调用OH_CaptureSession_IsExposureModeSupported判断是否支持曝光模式,然后调用OH_CaptureSession_SetExposureMode设置曝光模式,调用OH_CaptureSession_GetExposureMode获取设置后的曝光模式。调用IsExposureBiasRange接口获取曝光补偿,其中包含调用OH_CaptureSession_GetExposureBiasRange获取曝光补偿的范围,调用OH_CaptureSession_SetExposureBias设置曝光点,调用OH_CaptureSession_GetExposureBias获取曝光点。 - * 对焦功能相关接口封装在IsFocusMode接口中,主要包含以下流程:调用OH_CaptureSession_IsFocusModeSupported判断是否支持对焦模式,调用OH_CaptureSession_SetFocusMode设置对焦模式,调用OH_CaptureSession_GetFocusMode获取设置后的对焦模式。调用IsFocusPoint接口获取对焦点,其中包括调用OH_CaptureSession_SetFocusPoint获取JS侧下发来的对焦点位,然后调用OH_CaptureSession_GetFocusPoint获取设置后的对焦点位。 - * 视频防抖功能相关接口封装在IsVideoStabilizationModeSupportedFn接口中,主要包含以下流程:调用OH_CaptureSession_IsVideoStabilizationModeSupported接口查询是否支持指定的视频防抖模式,调用OH_CaptureSession_SetVideoStabilizationMode设置视频防抖,调用OH_CaptureSession_GetVideoStabilizationMode获取设置后的视频防抖模式。 - - * 回调接口设置: - * CameraManagerRegisterCallback:监听相机状态回调,在打开、退出相机,相机摄像头切换时会触发 - * CameraInputRegisterCallback:相机输入发生错误时触发回调 - * PreviewOutputRegisterCallback:开启预览流时触发回调 - * PhotoOutputRegisterCallback:开启拍照时触发回调 - * VideoOutputRegisterCallback:开启录像模式时触发回调 - * MetadataOutputRegisterCallback:有metadata流输出时触发回调 - * CaptureSessionRegisterCallback:session出现异常时以及开启对焦模式时触发回调 - - -* 相机预览、拍照、录像功能、前后置切换功能实现调用侧位于Index.ets,modeSwitchPage.ets,main.cpp中,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets),[ModeSwitchPage.ets](entry/src/main/ets/views/ModeSwitchPage.ets),[main.cpp](entry/src/main/cpp/main.cpp) - * 预览:开启预览位于Index.ets下的onPageShow接口,其中调用cameraDemo.initCamera接口,将预览的surfaceId,对焦模式的值,以及是前置还是后置摄像头设备作为入参啊传下去,实际调用的是main.cpp下的InitCamera接口,InitCamera接口将JS侧拿到的参数进行转换再传入cameraManager.cpp中的构造函数里去,完成开启相机的操作,开启预览并设置好对焦模式。 - * 拍照和录像:开启拍照位于ModeSwitchPage.ets下的isVideoPhotoFn接口,通过判断modelBagCol的值是photo还是video,将modelBagCol的值,videoId,拍照的surfaceID或者录像的surfaceId传入接口startPhotoOrVideo。如果是拍照模式,则通过modeSwitchPage.ets下的getPhotoSurfaceID接口获取photo surfaceId,跳转到main.cpp中的StartPhotoOrVideo接口,将传下来的参数进行格式转换,再调用CameraManager对象下的StartPhoto接口开启拍照操作;如果是录像模式,则通过modeSwitchPage.ets下的getVideoSurfaceID接口获取video surfaceId,跳转到main.cpp中的StartPhotoOrVideo接口,将传下来的参数进行格式转换,再调用CameraManager对象下的StartVideo接口开启录像操作 - * 前后置切换:前后置摄像头切换接口位于ModeSwitchPage.ets,切换cameraDeviceIndex,将先前的session配置释放,调用cameraDemo.releaseSession接口,实际上是main.cpp下的ReleaseSession接口,最终调用到CameraMangaer.cpp下的ReleaseSession接口。然后将预览的surfaceId,对焦模式的值以及cameraDeviceIndex传入cameraDemo.initCamera接口中,逻辑和预览一致。 - - -* 相机闪光灯、变焦、对焦、曝光功能实现调用侧位于FlashingLightPage.ets,SlidePage.ets,focusAreaPage.ets中,源码参考:[FlashingLightPage.ets](entry/src/main/ets/views/FlashingLightPage.ets),[SlidePage.ets](entry/src/main/ets/views/SlidePage.ets),[FocusAreaPage.ets](entry/src/main/ets/views/FocusAreaPage.ets),[main.cpp](entry/src/main/cpp/main.cpp) - * 闪光灯:闪光灯功能位于FlashingLightPage.ets,getImageDefault接口用作在点击闪光灯图标之后选择闪光灯模式,0代表关闭,1代表打开,2是自动,3是常亮。然后在build中通过cameraDemo.hasFlash接口调用到main.cpp中的HasFlash接口,最终调到CameraManager.cpp中的HasFlashFn接口,完成闪光灯功能的实现。 - * 变焦:变焦功能位于SlidePage.ets,通过调用slideChange接口设置slide滑块的值,目前只支持1-6.然后调用cameraDemo.setZoomRatio接口调用到main.cpp中的SetZoomRatio接口,最终调到CameraManager.cpp中的setZoomRatioFn接口,完成变焦功能的实现。 - * 对焦:对焦功能位于FocusAreaPage.ets,通过在build中将对焦焦点下发到cpp侧,在CameraManager.cpp文件中的SessionFlowFn函数中,会调用IsFocusMode接口来判断是否支持对焦模式,然后通过onTouch的方式将对焦点位通过cameraDemo.isFocusPoint接口下发到main.cpp侧的IsFocusPoint接口,最终调到CameraManager.cpp中的IsFocusPoint接口。以及调用OH_CaptureSession_SetFocusMode拿到对焦点位来设置对焦模式,最后调用OH_CaptureSession_GetFocusMode来获取对焦模式,完成对焦功能实现。 - * 曝光:曝光功能位于FocusAreaPage.ets,通过在build中将侧光点位下发到cpp侧,然后通过onTouch的方式将对焦点位以及侧光点位通过cameraDemo.isFocusPoint接口下发到main.cpp侧的isMeteringPoint接口,最终调到CameraManager.cpp中的IsMeteringPoint接口。然后设置曝光补偿,单指竖直方向拖动触发该手势事件,调用gesture中的cameraDemo.isExposureBiasRange接口将曝光值下发到main.cpp中的IsExposureBiasRange,然后经过napi转换后将值传到CameraManager.cpp中的IsExposureBiasRange接口,之后从native侧发到曝光补偿的范围,再调用OH_CaptureSession_SetExposureBias设置曝光值,最后调用OH_CaptureSession_GetExposureBias接口获取曝光值,完成曝光功能。 - -### 相关权限 - -[ohos.permission.CAMERA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-camera-kit/js-apis-camera.md) - -[ohos.permission.MICROPHONE](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionmicrophone) - -[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionread_media) - -[ohos.permission.WRITE_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionwrite_media) - -### 依赖 - -不涉及 - -### 约束与限制 - -1. 本示例支持标准系统上运行,支持设备:RK3568; -2. 本示例为Stage模型,已适配API version 12版本SDK,SDK版本号(API Version 12 Release),镜像版本号(5.0Release); -3. 本示例需要使用DevEco Studio 版本号(5.0)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/BasicFeature/Media/Camera > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master + +# 相机 + +### 介绍 + +本示例主要展示了相机的相关功能,使用[libohcamera.so] +当前版本sample仅用作联调,最新sdk未带相机c接口头文件。 +接口实现相机的预览、拍照、录像、前后置摄像头切换进行拍照、录像,以及闪光灯、变焦、对焦、曝光等控制类功能。 + +### 效果预览 + +| 相机权限 | 图片和视频权限 | 麦克风权限 | 预览界面 | +|----------------------------|----------------------------|----------------------------|---------------------------------| +| ![auth](app_pic/auth1.jpg) | ![auth](app_pic/auth2.jpg) | ![auth](app_pic/auth3.jpg) | ![preview](app_pic/preview.jpg) | + +使用说明 +(因RK3568设备硬件能力,现仅支持验证1、2、3、9、10、13) +1. 弹出是否允许“CameraSample”使用相机?点击“允许” +2. 弹出是否允许“CameraSample”访问图片和视频?点击“允许” +3. 弹出是否允许“CameraSample”使用麦克风?点击“允许” +4. 进入预览界面,预览正常,滑动变焦按钮,同一画面远近变焦效果明显 +5. 进入预览界面,预览正常,点击画面模糊处,点击处画面会变得清晰,对焦效果明显 +6. 进入预览界面,预览正常,上下滑动屏幕,屏幕场景亮度发生变化,曝光效果明显 +7. 进入预览界面,预览正常,点击闪光灯按钮,打开闪光灯,闪光灯正常打开 +8. 进入预览界面,预览正常,点击闪光灯按钮,关闭闪光灯,闪光灯关闭 +9. 进入预览界面,预览正常,进入拍照模式,点击拍照按钮,拍照正常,左下角会生成照片缩略图,点击左下角缩略图,能够跳转到图库,图片保存正常,打开图片显示正常 +10. 进入预览界面,预览正常,切换到录像模式,点击录像,开始录像,再点击停止录像按钮,录像成功,左下角会生成视频缩略图,点击左下角缩略图,能够跳转到图库,录像文件保存正常,播放录像文件正常 +11. 进入预览界面,预览正常,切换到前置摄像头,点击拍照按钮,拍照正常,左下角会生成照片缩略图,点击左下角缩略图,能够跳转到图库,图片保存正常,打开图片显示正常 +12. 进入预览界面,预览正常,切换到前置摄像头,切换到录像模式,点击录像,开始录像,再点击停止录像按钮,录像成功,左下角会生成视频缩略图,点击左下角缩略图,能够跳转到图库,录像文件保存正常,播放录像文件正常 +13. 点击设置按钮,会弹出设置页面,仅验证UI。 + +### 工程目录 + +``` +entry/src/main +|-- cpp +| |-- CMakeLists.txt // Cmake打包配置文件,编译工程动态库脚本,依赖头文件、cpp以及相关依赖 +| |-- camera_manager.cpp // 相机基本功能接口定义cpp实现侧 +| |-- camera_manager.h // 相机基本功能接口定义头文件 +| |-- main.cpp // NAPI实现JS与C++通信的接口 +| |-- types +| `-- libentry +| |-- index.d.ts // 导入NAPI接口供JS调用 +| `-- oh-package.json5 // 接口注册配置文件 +|-- ets +| |-- Dialog +| | |-- mainDialog.ets // 打开相机APP弹出的网络权限设置 +| | `-- settingDialog.ets // 相机APP设置界面布局 +| |-- MainAbility +| | `-- MainAbility.ts // 对Ability生命周期管理 +| |-- common +| | |-- Constants.ts // 基本参数枚举:纵横比、设备类型、视频帧数 +| | |-- DisplayCalculator.ts // 计算界面宽高显示数值 +| | |-- settingItem.ets // 设置栏 +| | |-- settingPublicLayout.ets // 设置栏公共区域 +| | `-- settingRightLayout.ets // 设置栏右边区域 +| |-- entryability +| | `-- EntryAbility.ts // Ability的生命周期回调内容 +| |-- model +| | |-- DateTimeUtil.ts // 日期工具 +| | |-- Logger.ts // 日志工具 +| | `-- MediaUtils.ts // 媒体工具 +| |-- pages +| | `-- Index.ets // Ability实现的应用的入口页面,相机APP首页 +| `-- views +| |-- CountdownPage.ets // 倒计时UI页面布局 +| |-- FlashingLightPage.ets // 闪光灯UI界面布局 +| |-- SlidePage.ets // 滑动滑块UI界面布局 +| |-- dividerPage.ets // 分割线UI布局 +| |-- focusAreaPage.ets // 对焦区域设置(焦点、侧光点)、单指竖直方向拖动触发曝光补偿设置 +| |-- focusPage.ets // 变焦、对焦、曝光、刻度的图标设置、值的设置 +| `-- modeSwitchPage.ets // 相机功能模式切换,开启预览、拍照、录像 + +``` + +### 具体实现 +* 相机功能接口实现在CameraManager.cpp中,源码参考:[CameraManager.cpp](entry/src/main/cpp/camera_manager.cpp) + * 在NDKCamera构造函数里完成一个相机生命周期初始化的过程,包括调用OH_Camera_GetCameraMananger获取CameraMananger,调用OH_CameraManager_CreateCaptureSession创建CaptureSession,调用CaptureSessionRegisterCallback创建CaptureSession注册回调,调用GetSupportedCameras获取支持的camera设备,调用GetSupportedOutputCapability获取支持的camera设备能力集,调用CreatePreviewOutput创建预览输出,调用CreateCameraInput创建相机输入,调用CameraInputOpen打开相机输入,调用CameraManagerRegisterCallback创建CameraManager注册回调,最后调用SessionFlowFn开启Session。 + * 其中SessionFlowFn是一个开启预览的动作,主要流程包括:调用OH_CaptureSession_BeginConfig开始配置会话,调用OH_CaptureSession_AddInput把CameraInput加入到会话,调用OH_CaptureSession_AddPreviewOutput把previewOutput加入到会话,调用OH_CaptureSession_CommitConfig提交配置信息,调用OH_CaptureSession_Start开始会话工作,还有一步是在开启预览的同时调用IsFocusMode启动对焦功能,这边后面会涉及到。 + * 在NDKCamera析构函数里完成对相机生命周期释放的过程,调用OH_CameraManager_DeleteSupportedCameras删除支持的camera设备,调用OH_CameraManager_DeleteSupportedCameraOutputCapability删除支持的camera设备能力集,调用OH_Camera_DeleteCameraMananger删除camera manager。 + * 拍照功能相关接口封装在StartPhoto接口中,主要包含以下流程:调用SessionStop关闭session,调用SessionBegin做session的一个预置动作,调用CreatePhotoOutput创建相机输出,调用OH_CaptureSession_AddPhotoOutput将hotoOutput添加至session中,调用SessionCommitConfig提交session,在调用SessionStart开启session,最后调用TakePicture接口开启拍照动作。 + * 录像功能相关接口封装在StartVideo接口中,主要包含以下流程:调用SessionStop关闭session,调用SessionBegin做session的一个预置动作,调用OH_CaptureSession_RemovePhotoOutput移除相机拍照输出,再调用CreatePhotoOutput创建相机输出,调用AddPhotoOutput将相机输出添加至session中,调用CreateVideoOutput创建录像输出,调用AddVideoOutput将录像输出添加至session中,然后再调用SessionCommitConfig、SessionStart对session进行提交和开启,最后调用VideoOutputRegisterCallback对VideoOutput注册回调。 + * 闪光灯功能相关接口封装在HasFlashFn接口中,主要包含以下流程:调用OH_CaptureSession_HasFlash检测是否支持闪光灯设备,再调用OH_CaptureSession_IsFlashModeSupported检测闪光灯模式是否支持,然后调用OH_CaptureSession_SetFlashMode设置闪光灯模式,最后调用OH_CaptureSession_GetFlashMode获取当前设备的闪光灯模式。 + * 变焦功能相关接口封装在setZoomRatioFn接口中,主要包含以下流程:调用OH_CaptureSession_GetZoomRatioRange获取支持的变焦范围,调用OH_CaptureSession_SetZoomRatio设置变焦,调用OH_CaptureSession_GetZoomRatio获取当前设备的变焦值。 + * 曝光功能相关接口封装在IsExposureModeSupportedFn接口中,主要包含以下流程:调用OH_CaptureSession_IsExposureModeSupported判断是否支持曝光模式,然后调用OH_CaptureSession_SetExposureMode设置曝光模式,调用OH_CaptureSession_GetExposureMode获取设置后的曝光模式。调用IsExposureBiasRange接口获取曝光补偿,其中包含调用OH_CaptureSession_GetExposureBiasRange获取曝光补偿的范围,调用OH_CaptureSession_SetExposureBias设置曝光点,调用OH_CaptureSession_GetExposureBias获取曝光点。 + * 对焦功能相关接口封装在IsFocusMode接口中,主要包含以下流程:调用OH_CaptureSession_IsFocusModeSupported判断是否支持对焦模式,调用OH_CaptureSession_SetFocusMode设置对焦模式,调用OH_CaptureSession_GetFocusMode获取设置后的对焦模式。调用IsFocusPoint接口获取对焦点,其中包括调用OH_CaptureSession_SetFocusPoint获取JS侧下发来的对焦点位,然后调用OH_CaptureSession_GetFocusPoint获取设置后的对焦点位。 + * 视频防抖功能相关接口封装在IsVideoStabilizationModeSupportedFn接口中,主要包含以下流程:调用OH_CaptureSession_IsVideoStabilizationModeSupported接口查询是否支持指定的视频防抖模式,调用OH_CaptureSession_SetVideoStabilizationMode设置视频防抖,调用OH_CaptureSession_GetVideoStabilizationMode获取设置后的视频防抖模式。 + + * 回调接口设置: + * CameraManagerRegisterCallback:监听相机状态回调,在打开、退出相机,相机摄像头切换时会触发 + * CameraInputRegisterCallback:相机输入发生错误时触发回调 + * PreviewOutputRegisterCallback:开启预览流时触发回调 + * PhotoOutputRegisterCallback:开启拍照时触发回调 + * VideoOutputRegisterCallback:开启录像模式时触发回调 + * MetadataOutputRegisterCallback:有metadata流输出时触发回调 + * CaptureSessionRegisterCallback:session出现异常时以及开启对焦模式时触发回调 + + +* 相机预览、拍照、录像功能、前后置切换功能实现调用侧位于Index.ets,modeSwitchPage.ets,main.cpp中,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets),[ModeSwitchPage.ets](entry/src/main/ets/views/ModeSwitchPage.ets),[main.cpp](entry/src/main/cpp/main.cpp) + * 预览:开启预览位于Index.ets下的onPageShow接口,其中调用cameraDemo.initCamera接口,将预览的surfaceId,对焦模式的值,以及是前置还是后置摄像头设备作为入参啊传下去,实际调用的是main.cpp下的InitCamera接口,InitCamera接口将JS侧拿到的参数进行转换再传入cameraManager.cpp中的构造函数里去,完成开启相机的操作,开启预览并设置好对焦模式。 + * 拍照和录像:开启拍照位于ModeSwitchPage.ets下的isVideoPhotoFn接口,通过判断modelBagCol的值是photo还是video,将modelBagCol的值,videoId,拍照的surfaceID或者录像的surfaceId传入接口startPhotoOrVideo。如果是拍照模式,则通过modeSwitchPage.ets下的getPhotoSurfaceID接口获取photo surfaceId,跳转到main.cpp中的StartPhotoOrVideo接口,将传下来的参数进行格式转换,再调用CameraManager对象下的StartPhoto接口开启拍照操作;如果是录像模式,则通过modeSwitchPage.ets下的getVideoSurfaceID接口获取video surfaceId,跳转到main.cpp中的StartPhotoOrVideo接口,将传下来的参数进行格式转换,再调用CameraManager对象下的StartVideo接口开启录像操作 + * 前后置切换:前后置摄像头切换接口位于ModeSwitchPage.ets,切换cameraDeviceIndex,将先前的session配置释放,调用cameraDemo.releaseSession接口,实际上是main.cpp下的ReleaseSession接口,最终调用到CameraMangaer.cpp下的ReleaseSession接口。然后将预览的surfaceId,对焦模式的值以及cameraDeviceIndex传入cameraDemo.initCamera接口中,逻辑和预览一致。 + + +* 相机闪光灯、变焦、对焦、曝光功能实现调用侧位于FlashingLightPage.ets,SlidePage.ets,focusAreaPage.ets中,源码参考:[FlashingLightPage.ets](entry/src/main/ets/views/FlashingLightPage.ets),[SlidePage.ets](entry/src/main/ets/views/SlidePage.ets),[FocusAreaPage.ets](entry/src/main/ets/views/FocusAreaPage.ets),[main.cpp](entry/src/main/cpp/main.cpp) + * 闪光灯:闪光灯功能位于FlashingLightPage.ets,getImageDefault接口用作在点击闪光灯图标之后选择闪光灯模式,0代表关闭,1代表打开,2是自动,3是常亮。然后在build中通过cameraDemo.hasFlash接口调用到main.cpp中的HasFlash接口,最终调到CameraManager.cpp中的HasFlashFn接口,完成闪光灯功能的实现。 + * 变焦:变焦功能位于SlidePage.ets,通过调用slideChange接口设置slide滑块的值,目前只支持1-6.然后调用cameraDemo.setZoomRatio接口调用到main.cpp中的SetZoomRatio接口,最终调到CameraManager.cpp中的setZoomRatioFn接口,完成变焦功能的实现。 + * 对焦:对焦功能位于FocusAreaPage.ets,通过在build中将对焦焦点下发到cpp侧,在CameraManager.cpp文件中的SessionFlowFn函数中,会调用IsFocusMode接口来判断是否支持对焦模式,然后通过onTouch的方式将对焦点位通过cameraDemo.isFocusPoint接口下发到main.cpp侧的IsFocusPoint接口,最终调到CameraManager.cpp中的IsFocusPoint接口。以及调用OH_CaptureSession_SetFocusMode拿到对焦点位来设置对焦模式,最后调用OH_CaptureSession_GetFocusMode来获取对焦模式,完成对焦功能实现。 + * 曝光:曝光功能位于FocusAreaPage.ets,通过在build中将侧光点位下发到cpp侧,然后通过onTouch的方式将对焦点位以及侧光点位通过cameraDemo.isFocusPoint接口下发到main.cpp侧的isMeteringPoint接口,最终调到CameraManager.cpp中的IsMeteringPoint接口。然后设置曝光补偿,单指竖直方向拖动触发该手势事件,调用gesture中的cameraDemo.isExposureBiasRange接口将曝光值下发到main.cpp中的IsExposureBiasRange,然后经过napi转换后将值传到CameraManager.cpp中的IsExposureBiasRange接口,之后从native侧发到曝光补偿的范围,再调用OH_CaptureSession_SetExposureBias设置曝光值,最后调用OH_CaptureSession_GetExposureBias接口获取曝光值,完成曝光功能。 + +### 相关权限 + +[ohos.permission.CAMERA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-camera-kit/js-apis-camera.md) + +[ohos.permission.MICROPHONE](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionmicrophone) + +[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionread_media) + +[ohos.permission.WRITE_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionwrite_media) + +### 依赖 + +不涉及 + +### 约束与限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; +2. 本示例为Stage模型,已适配API version 12版本SDK,SDK版本号(API Version 12 Release),镜像版本号(5.0Release); +3. 本示例需要使用DevEco Studio 版本号(5.0)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/BasicFeature/Media/Camera > .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/BasicFeature/Media/Camera/entry/oh-package.json5 b/code/BasicFeature/Media/Camera/entry/oh-package.json5 index 27af2fbb68..2ceaf0b016 100644 --- a/code/BasicFeature/Media/Camera/entry/oh-package.json5 +++ b/code/BasicFeature/Media/Camera/entry/oh-package.json5 @@ -1,11 +1,11 @@ -{ - "license": "ISC", - "devDependencies": { - "@types/libentry.so": "file:./src/main/cpp/types/libentry" - }, - "name": "entry", - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "ISC", + "devDependencies": { + "@types/libentry.so": "file:./src/main/cpp/types/libentry" + }, + "name": "entry", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Media/Camera/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/Media/Camera/entry/src/main/cpp/types/libentry/oh-package.json5 index 35079f7a3f..9c6929b0b2 100644 --- a/code/BasicFeature/Media/Camera/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/BasicFeature/Media/Camera/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,6 +1,6 @@ -{ - "types": "./index.d.ts", - "name": "libentry.so", - "description": "", - "version": "" +{ + "types": "./index.d.ts", + "name": "libentry.so", + "description": "", + "version": "" } \ No newline at end of file diff --git a/code/BasicFeature/Media/Camera/entry/src/ohosTest/ets/test/Logger.ts b/code/BasicFeature/Media/Camera/entry/src/ohosTest/ets/test/Logger.ts index 27b576b2c7..2837750d0e 100644 --- a/code/BasicFeature/Media/Camera/entry/src/ohosTest/ets/test/Logger.ts +++ b/code/BasicFeature/Media/Camera/entry/src/ohosTest/ets/test/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -const DOMAIN: number = 0xF811; - -class Logger { - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - } - - debug(...args: string[]): void { - hilog.debug(DOMAIN, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(DOMAIN, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(DOMAIN, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(DOMAIN, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +const DOMAIN: number = 0xF811; + +class Logger { + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + } + + debug(...args: string[]): void { + hilog.debug(DOMAIN, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(DOMAIN, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(DOMAIN, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(DOMAIN, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_Camera]'); \ No newline at end of file diff --git a/code/BasicFeature/Media/Camera/hvigor/hvigor-config.json5 b/code/BasicFeature/Media/Camera/hvigor/hvigor-config.json5 index 78fdbce3b0..cef1321d4c 100644 --- a/code/BasicFeature/Media/Camera/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Media/Camera/hvigor/hvigor-config.json5 @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2024 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": { - } +/* + * Copyright (c) 2024 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": { + } } \ No newline at end of file diff --git a/code/BasicFeature/Media/Camera/oh-package.json5 b/code/BasicFeature/Media/Camera/oh-package.json5 index 81fb75240c..d083bc9bd8 100644 --- a/code/BasicFeature/Media/Camera/oh-package.json5 +++ b/code/BasicFeature/Media/Camera/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 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", - "license": "ISC", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "name": "camerasample", - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} +/* + * Copyright (c) 2024 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", + "license": "ISC", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "name": "camerasample", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} } \ No newline at end of file diff --git a/code/BasicFeature/Media/VideoPlay/entry/src/main/resources/rawfile/test1.srt b/code/BasicFeature/Media/VideoPlay/entry/src/main/resources/rawfile/test1.srt index e7f5575c78..4c4c12f32f 100644 --- a/code/BasicFeature/Media/VideoPlay/entry/src/main/resources/rawfile/test1.srt +++ b/code/BasicFeature/Media/VideoPlay/entry/src/main/resources/rawfile/test1.srt @@ -1,123 +1,123 @@ -1 -00:00:00,470 --> 00:00:07,480 -(在空心地球的某处) - -2 -00:00:09,460 --> 00:00:12,670 -在大部分人类文明中 - -3 -00:00:13,840 --> 00:00:15,550 -我们都认为人类是地球上的优势物种 - -4 -00:00:15,920 --> 00:00:16,890 -更相信生命只能存在于地球表面 - -5 -00:00:16,890 --> 00:00:18,970 -但在某个时刻,大家一定会想 - -6 -00:00:19,140 --> 00:00:20,220 -(君主计划金刚研究负责人 艾琳安德鲁博士) - -7 -00:00:21,310 --> 00:00:23,140 -我们的认知还有哪些错误? - -8 -00:00:20,400 --> 00:00:24,690 -我们目前只探勘了空心地球 不到百分之五的区域 - -9 -00:00:25,280 --> 00:00:30,160 -但地表上下 生态系统的关系紧密超乎想像 - -10 -00:00:30,910 --> 00:00:34,160 -这不是两个不同世界,而是一体的 - -11 -00:00:34,330 --> 00:00:35,580 -(发现空心地球新入口) - -12 -00:00:37,540 --> 00:00:39,130 -金刚已在空心地球定居 - -13 -00:00:39,210 --> 00:00:39,960 -(金刚移居新栖地) - -14 -00:00:40,040 --> 00:00:42,210 -所以,这位大家伙喜欢它的新家 - -15 -00:00:42,500 --> 00:00:43,550 -应该没错 - -16 -00:00:44,010 --> 00:00:45,970 -它是高度社会化的物种 - -17 -00:00:46,550 --> 00:00:49,680 -金刚如此孤单并不正常 - -18 -00:00:52,470 --> 00:00:54,020 -它是同类中的最后一只 - -19 -00:00:54,180 --> 00:00:57,690 -它每天都在寻找永远找不到的家人 - -20 -00:00:59,730 --> 00:01:00,900 -那哥斯拉呢? - -21 -00:01:00,980 --> 00:01:01,650 -(哥斯拉领地) - -22 -00:01:01,730 --> 00:01:03,690 -哥斯拉在地表,金刚在地心 - -23 -00:01:03,780 --> 00:01:04,320 -(金刚领地) - -24 -00:01:04,400 --> 00:01:06,700 -只要它们不冒险进入对方领地 - -25 -00:01:06,820 --> 00:01:08,410 -就没什么好担心的 - -26 -00:01:08,910 --> 00:01:11,780 -我们很幸运有哥斯拉扞卫人类世界 - -27 -00:01:11,950 --> 00:01:12,780 -(罗马,泰坦24号) - -28 -00:01:17,870 --> 00:01:20,330 -(意大利,罗马) - -29 -00:01:22,860 --> 00:01:25,570 -部分论点批评君主计划 花费纳税人数十亿美元 - -30 -00:01:26,780 --> 00:01:28,120 -(君主一号基地,金刚观测站) - -31 -00:01:29,180 --> 00:01:49,120 +1 +00:00:00,470 --> 00:00:07,480 +(在空心地球的某处) + +2 +00:00:09,460 --> 00:00:12,670 +在大部分人类文明中 + +3 +00:00:13,840 --> 00:00:15,550 +我们都认为人类是地球上的优势物种 + +4 +00:00:15,920 --> 00:00:16,890 +更相信生命只能存在于地球表面 + +5 +00:00:16,890 --> 00:00:18,970 +但在某个时刻,大家一定会想 + +6 +00:00:19,140 --> 00:00:20,220 +(君主计划金刚研究负责人 艾琳安德鲁博士) + +7 +00:00:21,310 --> 00:00:23,140 +我们的认知还有哪些错误? + +8 +00:00:20,400 --> 00:00:24,690 +我们目前只探勘了空心地球 不到百分之五的区域 + +9 +00:00:25,280 --> 00:00:30,160 +但地表上下 生态系统的关系紧密超乎想像 + +10 +00:00:30,910 --> 00:00:34,160 +这不是两个不同世界,而是一体的 + +11 +00:00:34,330 --> 00:00:35,580 +(发现空心地球新入口) + +12 +00:00:37,540 --> 00:00:39,130 +金刚已在空心地球定居 + +13 +00:00:39,210 --> 00:00:39,960 +(金刚移居新栖地) + +14 +00:00:40,040 --> 00:00:42,210 +所以,这位大家伙喜欢它的新家 + +15 +00:00:42,500 --> 00:00:43,550 +应该没错 + +16 +00:00:44,010 --> 00:00:45,970 +它是高度社会化的物种 + +17 +00:00:46,550 --> 00:00:49,680 +金刚如此孤单并不正常 + +18 +00:00:52,470 --> 00:00:54,020 +它是同类中的最后一只 + +19 +00:00:54,180 --> 00:00:57,690 +它每天都在寻找永远找不到的家人 + +20 +00:00:59,730 --> 00:01:00,900 +那哥斯拉呢? + +21 +00:01:00,980 --> 00:01:01,650 +(哥斯拉领地) + +22 +00:01:01,730 --> 00:01:03,690 +哥斯拉在地表,金刚在地心 + +23 +00:01:03,780 --> 00:01:04,320 +(金刚领地) + +24 +00:01:04,400 --> 00:01:06,700 +只要它们不冒险进入对方领地 + +25 +00:01:06,820 --> 00:01:08,410 +就没什么好担心的 + +26 +00:01:08,910 --> 00:01:11,780 +我们很幸运有哥斯拉扞卫人类世界 + +27 +00:01:11,950 --> 00:01:12,780 +(罗马,泰坦24号) + +28 +00:01:17,870 --> 00:01:20,330 +(意大利,罗马) + +29 +00:01:22,860 --> 00:01:25,570 +部分论点批评君主计划 花费纳税人数十亿美元 + +30 +00:01:26,780 --> 00:01:28,120 +(君主一号基地,金刚观测站) + +31 +00:01:29,180 --> 00:01:49,120 结束 \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/.gitignore b/code/BasicFeature/Native/NdkNativeFence/.gitignore old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/AppScope/app.json5 b/code/BasicFeature/Native/NdkNativeFence/AppScope/app.json5 old mode 100755 new mode 100644 index 5381586847..2a5e7eee1b --- a/code/BasicFeature/Native/NdkNativeFence/AppScope/app.json5 +++ b/code/BasicFeature/Native/NdkNativeFence/AppScope/app.json5 @@ -1,25 +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.ndknativefence", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.ndknativefence", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/element/string.json b/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 84dbccd48b..9a05de13c1 --- a/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NdkNativeFence" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "NdkNativeFence" + } + ] +} diff --git a/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/media/app_icon.png b/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/README_zh.md b/code/BasicFeature/Native/NdkNativeFence/README_zh.md old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/build-profile.json5 b/code/BasicFeature/Native/NdkNativeFence/build-profile.json5 old mode 100755 new mode 100644 index c6a7ec09c5..18cabb057f --- a/code/BasicFeature/Native/NdkNativeFence/build-profile.json5 +++ b/code/BasicFeature/Native/NdkNativeFence/build-profile.json5 @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "app": { - "signingConfigs": [], - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 20, - // 指定OpenHarmony应用/服务编译时的版本 - "compatibleSdkVersion": 19, - // 指定OpenHarmony应用/服务兼容的最低版本。 - "targetSdkVersion": 20, - // 指定OpenHarmony应用/服务目标版本。若没有设置,默认为compatibleSdkVersion - "runtimeOS": "OpenHarmony", - // 指定为OpenHarmony - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 20, + // 指定OpenHarmony应用/服务编译时的版本 + "compatibleSdkVersion": 19, + // 指定OpenHarmony应用/服务兼容的最低版本。 + "targetSdkVersion": 20, + // 指定OpenHarmony应用/服务目标版本。若没有设置,默认为compatibleSdkVersion + "runtimeOS": "OpenHarmony", + // 指定为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/BasicFeature/Native/NdkNativeFence/code-linter.json5 b/code/BasicFeature/Native/NdkNativeFence/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/.gitignore b/code/BasicFeature/Native/NdkNativeFence/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/build-profile.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/build-profile.json5 old mode 100755 new mode 100644 index 29d984235f..efb21c8f5f --- a/code/BasicFeature/Native/NdkNativeFence/entry/build-profile.json5 +++ b/code/BasicFeature/Native/NdkNativeFence/entry/build-profile.json5 @@ -1,35 +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. - */ - -{ - "apiType": "stageMode", - "buildOption": { - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - "abiFilters": ["arm64-v8a", "armeabi-v7a", "x86_64"] - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * 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", "armeabi-v7a", "x86_64"] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/hvigorfile.ts b/code/BasicFeature/Native/NdkNativeFence/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/obfuscation-rules.txt b/code/BasicFeature/Native/NdkNativeFence/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/oh-package.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/BasicFeature/Native/NdkNativeFence/entry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkNativeFence/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 2017e5d3f8..c1b383856b --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/CMakeLists.txt +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/CMakeLists.txt @@ -1,26 +1,26 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(456) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) - -find_library( - # Sets the name of the path variable. - hilog-lib - # Specifies the name of the NDK library that - # you want CMake to locate. - hilog_ndk.z -) - -target_link_libraries(entry PUBLIC libace_napi.z.so) -target_link_libraries(entry PUBLIC ${hilog-lib}) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(456) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) + +find_library( + # Sets the name of the path variable. + hilog-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + hilog_ndk.z +) + +target_link_libraries(entry PUBLIC libace_napi.z.so) +target_link_libraries(entry PUBLIC ${hilog-lib}) target_link_libraries(entry PUBLIC libnative_fence.so) \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/common/log_common.h b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/common/log_common.h old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/napi_init.cpp b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index ce78552d58..2081c25ac5 --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/napi_init.cpp +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/napi_init.cpp @@ -1,167 +1,167 @@ -/* - * 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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "common/log_common.h" - -constexpr int INVALID_FD = -1; -constexpr uint32_t TIMEOUT_MS = 5000; - -static napi_value Add(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - - napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); - - napi_valuetype valuetype0; - napi_typeof(env, args[0], &valuetype0); - - napi_valuetype valuetype1; - napi_typeof(env, args[1], &valuetype1); - - double value0; - napi_get_value_double(env, args[0], &value0); - - double value1; - napi_get_value_double(env, args[1], &value1); - - napi_value sum; - napi_create_double(env, value0 + value1, &sum); - - return sum; -} - -static napi_value SyncFenceWait(napi_env env, napi_callback_info info) -{ - bool result = OH_NativeFence_Wait(INVALID_FD, TIMEOUT_MS); - DRAWING_LOGI("get result %{public}d", result); - bool isValid = OH_NativeFence_IsValid(INVALID_FD); - DRAWING_LOGI("input fenceFd is: %{public}d", isValid); - - std::atomic signaled(false); - sigset_t mask; - sigemptyset(&mask); - sigaddset(&mask, SIGINT); // Monitor SIGINT signal (Ctrl C) - sigaddset(&mask, SIGTERM); // Monitor SIGTERM signal (kill command) - sigprocmask(SIG_BLOCK, &mask, NULL); - int sfd = signalfd(-1, &mask, 0); - DRAWING_LOGI("input fenceFd is: %{public}d", sfd); - if (sfd == -1) { - perror("signalfd failed"); - exit(1); - } - isValid = OH_NativeFence_IsValid(sfd); - DRAWING_LOGI("input fenceFd is: %{public}d", isValid); - std::thread waitThread([&]() { - bool result2 = false; - auto startTime = std::chrono::steady_clock::now(); - result2 = OH_NativeFence_Wait(sfd, TIMEOUT_MS); - auto endTime = std::chrono::steady_clock::now(); - auto duration = std::chrono::duration_cast(endTime - startTime).count(); - DRAWING_LOGI("get result2 %{public}d, cost_time: %{public}d", result2, duration); - signaled.store(true); - }); - std::this_thread::sleep_for(std::chrono::seconds(3)); // 3 means main thread sleep 3 seconds. - pid_t target_pid = getpid(); - int ret = kill(target_pid, SIGINT); - if (ret < 0) { - DRAWING_LOGI("kill failed: %{public}d", strerror(errno)); - } - // Waiting for waitThread to complete - waitThread.join(); - // checks the signaled variable to ensure that OH_NativeFence_Wait has returned - DRAWING_LOGI("get signaled.load() %{public}d", signaled.load()); - OH_NativeFence_Close(sfd); -} - -static napi_value SyncFenceWaitForever(napi_env env, napi_callback_info info) -{ - bool result = OH_NativeFence_WaitForever(INVALID_FD); - DRAWING_LOGI("get result %{public}d", result); - - std::atomic signaled(false); - sigset_t mask; - sigemptyset(&mask); - sigaddset(&mask, SIGINT); // Monitor SIGINT signal (Ctrl C) - sigaddset(&mask, SIGTERM); // Monitor SIGTERM signal (kill command) - sigprocmask(SIG_BLOCK, &mask, NULL); - int sfd = signalfd(-1, &mask, 0); - if (sfd == -1) { - perror("signalfd failed"); - exit(1); - } - std::thread waitThread([&]() { - bool result2 = false; - auto startTime = std::chrono::steady_clock::now(); - result2 = OH_NativeFence_WaitForever(sfd); - auto endTime = std::chrono::steady_clock::now(); - auto duration = std::chrono::duration_cast(endTime - startTime).count(); - DRAWING_LOGI("get result2 %{public}d, cost_time: %{public}d", result2, duration); - signaled.store(true); - }); - std::this_thread::sleep_for(std::chrono::seconds(3)); // 3 means main thread sleep 3 seconds. - pid_t target_pid = getpid(); - int ret = kill(target_pid, SIGINT); - if (ret < 0) { - DRAWING_LOGI("kill failed: %{public}d", strerror(errno)); - } - // Waiting for waitThread to complete - waitThread.join(); - // checks the signaled variable to ensure that OH_NativeFence_Wait has returned - DRAWING_LOGI("get signaled.load() %{public}d", signaled.load()); - OH_NativeFence_Close(sfd); -} - -// EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr }, - { "syncFence_wait", nullptr, SyncFenceWait, nullptr, nullptr, nullptr, napi_default, nullptr }, - { "syncFence_waitForever", nullptr, SyncFenceWaitForever, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -// EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); +/* + * 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "common/log_common.h" + +constexpr int INVALID_FD = -1; +constexpr uint32_t TIMEOUT_MS = 5000; + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); + + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +static napi_value SyncFenceWait(napi_env env, napi_callback_info info) +{ + bool result = OH_NativeFence_Wait(INVALID_FD, TIMEOUT_MS); + DRAWING_LOGI("get result %{public}d", result); + bool isValid = OH_NativeFence_IsValid(INVALID_FD); + DRAWING_LOGI("input fenceFd is: %{public}d", isValid); + + std::atomic signaled(false); + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, SIGINT); // Monitor SIGINT signal (Ctrl C) + sigaddset(&mask, SIGTERM); // Monitor SIGTERM signal (kill command) + sigprocmask(SIG_BLOCK, &mask, NULL); + int sfd = signalfd(-1, &mask, 0); + DRAWING_LOGI("input fenceFd is: %{public}d", sfd); + if (sfd == -1) { + perror("signalfd failed"); + exit(1); + } + isValid = OH_NativeFence_IsValid(sfd); + DRAWING_LOGI("input fenceFd is: %{public}d", isValid); + std::thread waitThread([&]() { + bool result2 = false; + auto startTime = std::chrono::steady_clock::now(); + result2 = OH_NativeFence_Wait(sfd, TIMEOUT_MS); + auto endTime = std::chrono::steady_clock::now(); + auto duration = std::chrono::duration_cast(endTime - startTime).count(); + DRAWING_LOGI("get result2 %{public}d, cost_time: %{public}d", result2, duration); + signaled.store(true); + }); + std::this_thread::sleep_for(std::chrono::seconds(3)); // 3 means main thread sleep 3 seconds. + pid_t target_pid = getpid(); + int ret = kill(target_pid, SIGINT); + if (ret < 0) { + DRAWING_LOGI("kill failed: %{public}d", strerror(errno)); + } + // Waiting for waitThread to complete + waitThread.join(); + // checks the signaled variable to ensure that OH_NativeFence_Wait has returned + DRAWING_LOGI("get signaled.load() %{public}d", signaled.load()); + OH_NativeFence_Close(sfd); +} + +static napi_value SyncFenceWaitForever(napi_env env, napi_callback_info info) +{ + bool result = OH_NativeFence_WaitForever(INVALID_FD); + DRAWING_LOGI("get result %{public}d", result); + + std::atomic signaled(false); + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, SIGINT); // Monitor SIGINT signal (Ctrl C) + sigaddset(&mask, SIGTERM); // Monitor SIGTERM signal (kill command) + sigprocmask(SIG_BLOCK, &mask, NULL); + int sfd = signalfd(-1, &mask, 0); + if (sfd == -1) { + perror("signalfd failed"); + exit(1); + } + std::thread waitThread([&]() { + bool result2 = false; + auto startTime = std::chrono::steady_clock::now(); + result2 = OH_NativeFence_WaitForever(sfd); + auto endTime = std::chrono::steady_clock::now(); + auto duration = std::chrono::duration_cast(endTime - startTime).count(); + DRAWING_LOGI("get result2 %{public}d, cost_time: %{public}d", result2, duration); + signaled.store(true); + }); + std::this_thread::sleep_for(std::chrono::seconds(3)); // 3 means main thread sleep 3 seconds. + pid_t target_pid = getpid(); + int ret = kill(target_pid, SIGINT); + if (ret < 0) { + DRAWING_LOGI("kill failed: %{public}d", strerror(errno)); + } + // Waiting for waitThread to complete + waitThread.join(); + // checks the signaled variable to ensure that OH_NativeFence_Wait has returned + DRAWING_LOGI("get signaled.load() %{public}d", signaled.load()); + OH_NativeFence_Close(sfd); +} + +// EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "syncFence_wait", nullptr, SyncFenceWait, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "syncFence_waitForever", nullptr, SyncFenceWaitForever, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +// EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/Index.d.ts b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index 3a942ca1ec..439139e7c4 --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,18 +1,18 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export const add: (a: number, b: number) => number; -export const syncFence_wait: () => void; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const add: (a: number, b: number) => number; +export const syncFence_wait: () => void; export const syncFence_waitForever: () => void; \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 252b7dad74..c5539bddd7 --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 369e76b279..3b6dcd2d6d --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/pages/Index.ets @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { hilog } from '@kit.PerformanceAnalysisKit'; -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - build() { - Column() { - Row() { - Button($r("app.string.Button_label1")) - .fontSize('16fp') - .fontWeight(500) - .margin({ right: 82 }) - .onClick(() => { - hilog.info(0x0000, 'testTag', 'Test sync fence wait: ', testNapi.syncFence_wait()); - }) - .width('33.6%') - .height(40) - .shadow(ShadowStyle.OUTER_DEFAULT_LG) - - Button($r("app.string.Button_label2")) - .fontSize('16fp') - .fontWeight(500) - .margin({ left: 12 }) - .onClick(() => { - hilog.info(0x0000, 'testTag', 'Test sync fence waitForever: ', testNapi.syncFence_waitForever()); - }) - .width('43.6%') - .height(40) - .shadow(ShadowStyle.OUTER_DEFAULT_LG) - } - .width('100%') - .justifyContent(FlexAlign.Center) - .shadow(ShadowStyle.OUTER_DEFAULT_SM) - .alignItems(VerticalAlign.Center) - .layoutWeight(1) - } - } +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + build() { + Column() { + Row() { + Button($r("app.string.Button_label1")) + .fontSize('16fp') + .fontWeight(500) + .margin({ right: 82 }) + .onClick(() => { + hilog.info(0x0000, 'testTag', 'Test sync fence wait: ', testNapi.syncFence_wait()); + }) + .width('33.6%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + + Button($r("app.string.Button_label2")) + .fontSize('16fp') + .fontWeight(500) + .margin({ left: 12 }) + .onClick(() => { + hilog.info(0x0000, 'testTag', 'Test sync fence waitForever: ', testNapi.syncFence_waitForever()); + }) + .width('43.6%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .shadow(ShadowStyle.OUTER_DEFAULT_SM) + .alignItems(VerticalAlign.Center) + .layoutWeight(1) + } + } } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/module.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/module.json5 +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/string.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/background.png b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/foreground.png b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/layered_image.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/startIcon.png b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/backup_config.json +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/mock/Libentry.mock.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/mock/Libentry.mock.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/mock/mock-config.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/module.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index c8bd24faff..6b9889e8cc --- a/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/module.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/test/List.test.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/test/LocalUnit.test.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/hvigor/hvigor-config.json5 b/code/BasicFeature/Native/NdkNativeFence/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/BasicFeature/Native/NdkNativeFence/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Native/NdkNativeFence/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/BasicFeature/Native/NdkNativeFence/hvigorfile.ts b/code/BasicFeature/Native/NdkNativeFence/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/oh-package.json5 b/code/BasicFeature/Native/NdkNativeFence/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/BasicFeature/Native/NdkNativeFence/oh-package.json5 +++ b/code/BasicFeature/Native/NdkNativeFence/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/BasicFeature/Native/NdkNativeFence/ohosTest.md b/code/BasicFeature/Native/NdkNativeFence/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeFence/screenshots/SyncFence.jpeg b/code/BasicFeature/Native/NdkNativeFence/screenshots/SyncFence.jpeg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Native/NdkNativeImage/AppScope/app.json5 b/code/BasicFeature/Native/NdkNativeImage/AppScope/app.json5 index e99fd41e56..9e311fe1d8 100644 --- a/code/BasicFeature/Native/NdkNativeImage/AppScope/app.json5 +++ b/code/BasicFeature/Native/NdkNativeImage/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.ndknativeimage", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.ndknativeimage", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Native/NdkNativeImage/AppScope/resources/base/element/string.json b/code/BasicFeature/Native/NdkNativeImage/AppScope/resources/base/element/string.json index 0165b1d0bc..017dab4f47 100644 --- a/code/BasicFeature/Native/NdkNativeImage/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Native/NdkNativeImage/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NdkNativeImage" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "NdkNativeImage" + } + ] +} diff --git a/code/BasicFeature/Native/NdkNativeImage/build-profile.json5 b/code/BasicFeature/Native/NdkNativeImage/build-profile.json5 index c764cdfce8..60c9bfd9fb 100644 --- a/code/BasicFeature/Native/NdkNativeImage/build-profile.json5 +++ b/code/BasicFeature/Native/NdkNativeImage/build-profile.json5 @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2024 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", - "compileSdkVersion": 12, - // 指定OpenHarmony应用/服务编译时的版本 - "compatibleSdkVersion": 12, - // 指定OpenHarmony应用/服务兼容的最低版本。 - "targetSdkVersion": 12, - // 指定OpenHarmony应用/服务目标版本。若没有设置,默认为compatibleSdkVersion - "runtimeOS": "OpenHarmony", - // 指定为OpenHarmony - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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", + "compileSdkVersion": 12, + // 指定OpenHarmony应用/服务编译时的版本 + "compatibleSdkVersion": 12, + // 指定OpenHarmony应用/服务兼容的最低版本。 + "targetSdkVersion": 12, + // 指定OpenHarmony应用/服务目标版本。若没有设置,默认为compatibleSdkVersion + "runtimeOS": "OpenHarmony", + // 指定为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/BasicFeature/Native/NdkNativeImage/entry/build-profile.json5 b/code/BasicFeature/Native/NdkNativeImage/entry/build-profile.json5 index 34df5bd5bf..cf2a53fd98 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/build-profile.json5 +++ b/code/BasicFeature/Native/NdkNativeImage/entry/build-profile.json5 @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2024 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", "armeabi-v7a", "x86_64"] - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2024 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", "armeabi-v7a", "x86_64"] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/oh-package.json5 b/code/BasicFeature/Native/NdkNativeImage/entry/oh-package.json5 index 08d95ed186..a2e022f548 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkNativeImage/entry/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2024 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" - } +/* + * Copyright (c) 2024 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/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/CMakeLists.txt index 54bf859f34..1164df16f9 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/CMakeLists.txt +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/CMakeLists.txt @@ -1,37 +1,37 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NdkNativeImage) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp - render/image_render.cpp - render/native_render.cpp - render/render_engine.cpp -) - -target_link_libraries(entry PUBLIC - libace_napi.z.so - libace_ndk.z.so - libnative_buffer.so - libhilog_ndk.z.so - librawfile.z.so - libnative_vsync.so - ${native-drawing-lib} - ${native-window-lib} - ${hilog-lib} - ${libace-lib} - ${libnapi-lib} - libEGL.so - libGLESv3.so - libnative_image.so - libnative_window.so - libnative_buffer.so +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NdkNativeImage) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp + render/image_render.cpp + render/native_render.cpp + render/render_engine.cpp +) + +target_link_libraries(entry PUBLIC + libace_napi.z.so + libace_ndk.z.so + libnative_buffer.so + libhilog_ndk.z.so + librawfile.z.so + libnative_vsync.so + ${native-drawing-lib} + ${native-window-lib} + ${hilog-lib} + ${libace-lib} + ${libnapi-lib} + libEGL.so + libGLESv3.so + libnative_image.so + libnative_window.so + libnative_buffer.so ) \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/napi_init.cpp b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/napi_init.cpp index b3a0883e62..56cd9650b9 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/napi_init.cpp +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/napi_init.cpp @@ -1,136 +1,136 @@ -/* - * Copyright (c) 2024 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 -#include -#include "napi/native_api.h" -#include -#include -#include "common/common.h" -#include "render/image_render.h" -#include "render/render_engine.h" - -OH_NativeXComponent_Callback renderCallback_; -OH_NativeXComponent *g_nativeXComponent; -std::unique_ptr g_renderEngine = nullptr; -void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Callback", "OnSurfaceCreatedCB"); - if ((component == nullptr) || (window == nullptr)) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", - "OnSurfaceCreatedCB: component or window is null"); - return; - } - - uint64_t width; - uint64_t height; - int32_t xSize = OH_NativeXComponent_GetXComponentSize(component, window, &width, &height); - if (xSize != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", - "OnSurfaceCreatedCB: Unable to get XComponent size"); - return; - } - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", - "OnSurfaceCreatedCB: width = %{public}llu, height = %{public}llu", width, height); - - // 创建 ImageRender 实例 - std::shared_ptr imageRender = std::make_shared(); - - // 初始化 RenderEngine - g_renderEngine = std::make_unique(imageRender, width, height, window); - g_renderEngine->OnAppResume(); - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Callback", "RenderEngine started"); -} - -void OnSurfaceChangedCB(OH_NativeXComponent *component, void *window) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Callback", "OnSurfaceChangedCB"); - if ((component == nullptr) || (window == nullptr)) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", - "OnSurfaceChangedCB: component or window is null"); - return; - } - - uint64_t width; - uint64_t height; - int32_t xSize = OH_NativeXComponent_GetXComponentSize(component, window, &width, &height); - if (xSize != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", - "OnSurfaceChangedCB: Unable to get XComponent size"); - return; - } - - if (g_renderEngine) { - g_renderEngine->OnSurfaceChanged(width, height); - } -} - -void OnSurfaceDestroyedCB(OH_NativeXComponent* component, void* window) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Callback", "OnSurfaceDestroyedCB"); - if (g_renderEngine) { - g_renderEngine->OnAppPause(); - } -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "napi_init", "init start"); - napi_property_descriptor desc[] = {}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - napi_value exportInstance = nullptr; - if (napi_get_named_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance) != napi_ok) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "napi_init", "Export: napi_get_named_property fail"); - return nullptr; - } - - OH_NativeXComponent *nativeXComponent = nullptr; - if (napi_unwrap(env, exportInstance, reinterpret_cast(&nativeXComponent)) != napi_ok) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "napi_init", "Export: napi_unwrap fail"); - return nullptr; - } - g_nativeXComponent = nativeXComponent; - char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = {'\0'}; - uint64_t idSize = OH_XCOMPONENT_ID_LEN_MAX + 1; - if (OH_NativeXComponent_GetXComponentId(nativeXComponent, idStr, &idSize) != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "napi_init", - "Export: OH_NativeXComponent_GetXComponentId fail"); - return nullptr; - } - - renderCallback_.OnSurfaceCreated = OnSurfaceCreatedCB; - renderCallback_.OnSurfaceChanged = OnSurfaceChangedCB; - renderCallback_.OnSurfaceDestroyed = OnSurfaceDestroyedCB; - OH_NativeXComponent_RegisterCallback(nativeXComponent, &renderCallback_); - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "napi_init", "init end"); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2024 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 +#include +#include "napi/native_api.h" +#include +#include +#include "common/common.h" +#include "render/image_render.h" +#include "render/render_engine.h" + +OH_NativeXComponent_Callback renderCallback_; +OH_NativeXComponent *g_nativeXComponent; +std::unique_ptr g_renderEngine = nullptr; +void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Callback", "OnSurfaceCreatedCB"); + if ((component == nullptr) || (window == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", + "OnSurfaceCreatedCB: component or window is null"); + return; + } + + uint64_t width; + uint64_t height; + int32_t xSize = OH_NativeXComponent_GetXComponentSize(component, window, &width, &height); + if (xSize != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", + "OnSurfaceCreatedCB: Unable to get XComponent size"); + return; + } + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", + "OnSurfaceCreatedCB: width = %{public}llu, height = %{public}llu", width, height); + + // 创建 ImageRender 实例 + std::shared_ptr imageRender = std::make_shared(); + + // 初始化 RenderEngine + g_renderEngine = std::make_unique(imageRender, width, height, window); + g_renderEngine->OnAppResume(); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Callback", "RenderEngine started"); +} + +void OnSurfaceChangedCB(OH_NativeXComponent *component, void *window) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Callback", "OnSurfaceChangedCB"); + if ((component == nullptr) || (window == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", + "OnSurfaceChangedCB: component or window is null"); + return; + } + + uint64_t width; + uint64_t height; + int32_t xSize = OH_NativeXComponent_GetXComponentSize(component, window, &width, &height); + if (xSize != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", + "OnSurfaceChangedCB: Unable to get XComponent size"); + return; + } + + if (g_renderEngine) { + g_renderEngine->OnSurfaceChanged(width, height); + } +} + +void OnSurfaceDestroyedCB(OH_NativeXComponent* component, void* window) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Callback", "OnSurfaceDestroyedCB"); + if (g_renderEngine) { + g_renderEngine->OnAppPause(); + } +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "napi_init", "init start"); + napi_property_descriptor desc[] = {}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + napi_value exportInstance = nullptr; + if (napi_get_named_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "napi_init", "Export: napi_get_named_property fail"); + return nullptr; + } + + OH_NativeXComponent *nativeXComponent = nullptr; + if (napi_unwrap(env, exportInstance, reinterpret_cast(&nativeXComponent)) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "napi_init", "Export: napi_unwrap fail"); + return nullptr; + } + g_nativeXComponent = nativeXComponent; + char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = {'\0'}; + uint64_t idSize = OH_XCOMPONENT_ID_LEN_MAX + 1; + if (OH_NativeXComponent_GetXComponentId(nativeXComponent, idStr, &idSize) != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "napi_init", + "Export: OH_NativeXComponent_GetXComponentId fail"); + return nullptr; + } + + renderCallback_.OnSurfaceCreated = OnSurfaceCreatedCB; + renderCallback_.OnSurfaceChanged = OnSurfaceChangedCB; + renderCallback_.OnSurfaceDestroyed = OnSurfaceDestroyedCB; + OH_NativeXComponent_RegisterCallback(nativeXComponent, &renderCallback_); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "napi_init", "init end"); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/image_render.cpp b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/image_render.cpp index 5e736a5c5d..c73828fb10 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/image_render.cpp +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/image_render.cpp @@ -1,368 +1,368 @@ -/* - * Copyright (c) 2024 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 "image_render.h" -#include "common/common.h" -#include -#include -#include -#include -#include -#include - -namespace { - constexpr int MATRIX_SIZE = 16; - constexpr int MATRIX_DIAGONAL_STEP = 5; - constexpr float IDENTITY_DIAGONAL = 1.0f; - constexpr float IDENTITY_OTHER = 0.0f; - constexpr uint32_t NUM_VERTICES = 4; - constexpr uint32_t POSITION_COMPONENT_COUNT = 3; - constexpr uint32_t TEX_COORD_COMPONENT_COUNT = 2; - constexpr uint32_t STRIDE = (POSITION_COMPONENT_COUNT + TEX_COORD_COMPONENT_COUNT) * sizeof(GLfloat); - const char* g_vertexShaderSource = R"( - attribute vec4 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - uniform mat4 uTransformMatrix; - void main() { - gl_Position = aPosition; - vTexCoord = (uTransformMatrix * vec4(aTexCoord, 0.0, 1.0)).xy; - } - )"; - - const char* g_fragmentShaderSource = R"( - #extension GL_OES_EGL_image_external : require - precision mediump float; - uniform samplerExternalOES uTexture; - varying vec2 vTexCoord; - void main() { - gl_FragColor = texture2D(uTexture, vTexCoord); - } - )"; -} - -ImageRender::ImageRender() -{ - // Initialize transformMatrix_ as an identity matrix - for (int i = 0; i < MATRIX_SIZE; ++i) { - transformMatrix_[i] = (i % MATRIX_DIAGONAL_STEP == 0) ? IDENTITY_DIAGONAL : IDENTITY_OTHER; - } -} - -ImageRender::~ImageRender() -{ - Cleanup(); -} - -bool ImageRender::InitEGL(EGLNativeWindowType window, uint64_t width, uint64_t height) -{ - window_ = window; - width_ = width; - height_ = height; - - if (!InitializeEGLDisplay() || !ChooseEGLConfig() || !CreateEGLContext() || !CreateEGLSurface()) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to initialize EGL"); - return false; - } - - if (!MakeCurrentContext()) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to make EGL context current"); - return false; - } - - if (!CompileAndLinkShaders()) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to compile and link shaders"); - return false; - } - - UpdateViewport(); - - return true; -} - -void ImageRender::UpdateWindowInfo(uint64_t width, uint64_t height) -{ - width_ = width; - height_ = height; -} - -bool ImageRender::InitializeEGLDisplay() -{ - display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (display_ == EGL_NO_DISPLAY) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to get EGL display"); - return false; - } - - if (!eglInitialize(display_, nullptr, nullptr)) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to initialize EGL"); - return false; - } - - return true; -} - -bool ImageRender::ChooseEGLConfig() -{ - const EGLint attribs[] = { - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_NONE - }; - - EGLint numConfigs; - if (!eglChooseConfig(display_, attribs, &config_, 1, &numConfigs) || numConfigs == 0) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to choose EGL config"); - return false; - } - return true; -} - -bool ImageRender::CreateEGLContext() -{ - const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; - context_ = eglCreateContext(display_, config_, EGL_NO_CONTEXT, contextAttribs); - if (context_ == EGL_NO_CONTEXT) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to create EGL context"); - return false; - } - return true; -} - -bool ImageRender::CreateEGLSurface() -{ - surface_ = eglCreateWindowSurface(display_, config_, window_, nullptr); - if (surface_ == EGL_NO_SURFACE) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to create EGL surface"); - return false; - } - return true; -} - -bool ImageRender::MakeCurrentContext() -{ - if (!eglMakeCurrent(display_, surface_, surface_, context_)) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to make EGL context current"); - return false; - } - return true; -} - -void ImageRender::UpdateViewport() -{ - glViewport(0, 0, static_cast(width_), static_cast(height_)); - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ImageRender", - "Viewport updated to %{public}llu x %{public}llu", width_, height_); -} - -bool ImageRender::CompileAndLinkShaders() -{ - GLuint vertexShader = CompileShader(GL_VERTEX_SHADER, g_vertexShaderSource); - if (vertexShader == 0) { - return false; - } - - GLuint fragmentShader = CompileShader(GL_FRAGMENT_SHADER, g_fragmentShaderSource); - if (fragmentShader == 0) { - glDeleteShader(vertexShader); - return false; - } - - shaderProgram_ = glCreateProgram(); - glAttachShader(shaderProgram_, vertexShader); - glAttachShader(shaderProgram_, fragmentShader); - glLinkProgram(shaderProgram_); - - GLint linked; - glGetProgramiv(shaderProgram_, GL_LINK_STATUS, &linked); - if (!linked) { - PrintProgramLinkError(shaderProgram_); - glDeleteProgram(shaderProgram_); - glDeleteShader(vertexShader); - glDeleteShader(fragmentShader); - return false; - } - - glUseProgram(shaderProgram_); - - positionAttrib_ = glGetAttribLocation(shaderProgram_, "aPosition"); - texCoordAttrib_ = glGetAttribLocation(shaderProgram_, "aTexCoord"); - textureUniform_ = glGetUniformLocation(shaderProgram_, "uTexture"); - - glDeleteShader(vertexShader); - glDeleteShader(fragmentShader); - - return true; -} - -void ImageRender::PrintProgramLinkError(GLuint program) -{ - GLint infoLen = 0; - glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLen); - if (infoLen > 1) { - std::unique_ptr infoLog = std::make_unique(infoLen); - glGetProgramInfoLog(program, infoLen, nullptr, infoLog.get()); - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, - "ImageRender", "Error linking program: %{public}s", infoLog.get()); - } -} - -void ImageRender::SetTransformMatrix(const float matrix[MATRIX_SIZE]) -{ - std::copy(matrix, matrix + MATRIX_SIZE, transformMatrix_); -} - -void ImageRender::SetTexture(GLuint textureId, GLuint textureTarget) -{ - textureId_ = textureId; - textureTarget_ = textureTarget; -} - -void ImageRender::SetupVertexAttributes() -{ - static const GLfloat vertices[] = { - -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, // 左下 - 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, // 右下 - -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, // 左上 - 1.0f, 1.0f, 0.0f, 1.0f, 1.0f // 右上 - }; - - // Enable and set the position attribute - glEnableVertexAttribArray(positionAttrib_); - glVertexAttribPointer(positionAttrib_, POSITION_COMPONENT_COUNT, GL_FLOAT, GL_FALSE, - STRIDE, vertices); - - // Enable and set the texture coordinate attribute - glEnableVertexAttribArray(texCoordAttrib_); - glVertexAttribPointer(texCoordAttrib_, TEX_COORD_COMPONENT_COUNT, GL_FLOAT, GL_FALSE, - STRIDE, vertices + POSITION_COMPONENT_COUNT); -} - -void ImageRender::DisableVertexAttributes() -{ - // Disable the vertex attribute arrays after rendering - glDisableVertexAttribArray(positionAttrib_); - glDisableVertexAttribArray(texCoordAttrib_); -} - -void ImageRender::Render() -{ - if (surface_ == EGL_NO_SURFACE) { - return; - } - - if (!eglMakeCurrent(display_, surface_, surface_, context_)) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to make context current in Render"); - return; - } - - // Clear the color buffer - glClearColor(0.0f, 1.0f, 1.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - - // Use the shader program - glUseProgram(shaderProgram_); - - // Bind the texture - glActiveTexture(GL_TEXTURE0); - glBindTexture(textureTarget_, textureId_); - - // Set the texture sampler to texture unit 0 - glUniform1i(textureUniform_, 0); - - // Set the transformation matrix - GLint matrixLocation = glGetUniformLocation(shaderProgram_, "uTransformMatrix"); - if (matrixLocation != -1) { - glUniformMatrix4fv(matrixLocation, 1, GL_FALSE, transformMatrix_); - } - - // Set up vertex attributes - SetupVertexAttributes(); - - // Draw the textured quad - glDrawArrays(GL_TRIANGLE_STRIP, 0, NUM_VERTICES); - - // Disable vertex attributes - DisableVertexAttributes(); - - // Swap the buffers to display the rendered image - if (!eglSwapBuffers(display_, surface_)) { - EGLint error = eglGetError(); - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", - "eglSwapBuffers failed with error: %d", error); - } -} - -void ImageRender::Cleanup() -{ - if (display_ != EGL_NO_DISPLAY) { - eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - - if (context_ != EGL_NO_CONTEXT) { - eglDestroyContext(display_, context_); - context_ = EGL_NO_CONTEXT; - } - - if (surface_ != EGL_NO_SURFACE) { - eglDestroySurface(display_, surface_); - surface_ = EGL_NO_SURFACE; - } - - eglTerminate(display_); - display_ = EGL_NO_DISPLAY; - } - - if (shaderProgram_ != 0) { - glDeleteProgram(shaderProgram_); - shaderProgram_ = 0; - } -} - -GLuint ImageRender::CompileShader(GLenum type, const char* source) -{ - GLuint shader = glCreateShader(type); - if (shader == 0) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to create shader."); - return 0; - } - - glShaderSource(shader, 1, &source, nullptr); - glCompileShader(shader); - - GLint compiled; - glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); - if (!compiled) { - PrintShaderCompileError(shader); - glDeleteShader(shader); - return 0; - } - return shader; -} - -void ImageRender::PrintShaderCompileError(GLuint shader) -{ - GLint infoLen = 0; - glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen); - if (infoLen > 1) { - auto infoLog = std::make_unique(infoLen); - glGetShaderInfoLog(shader, infoLen, nullptr, infoLog.get()); - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", - "Error compiling shader: %{public}s", infoLog.get()); - } -} +/* + * Copyright (c) 2024 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 "image_render.h" +#include "common/common.h" +#include +#include +#include +#include +#include +#include + +namespace { + constexpr int MATRIX_SIZE = 16; + constexpr int MATRIX_DIAGONAL_STEP = 5; + constexpr float IDENTITY_DIAGONAL = 1.0f; + constexpr float IDENTITY_OTHER = 0.0f; + constexpr uint32_t NUM_VERTICES = 4; + constexpr uint32_t POSITION_COMPONENT_COUNT = 3; + constexpr uint32_t TEX_COORD_COMPONENT_COUNT = 2; + constexpr uint32_t STRIDE = (POSITION_COMPONENT_COUNT + TEX_COORD_COMPONENT_COUNT) * sizeof(GLfloat); + const char* g_vertexShaderSource = R"( + attribute vec4 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + uniform mat4 uTransformMatrix; + void main() { + gl_Position = aPosition; + vTexCoord = (uTransformMatrix * vec4(aTexCoord, 0.0, 1.0)).xy; + } + )"; + + const char* g_fragmentShaderSource = R"( + #extension GL_OES_EGL_image_external : require + precision mediump float; + uniform samplerExternalOES uTexture; + varying vec2 vTexCoord; + void main() { + gl_FragColor = texture2D(uTexture, vTexCoord); + } + )"; +} + +ImageRender::ImageRender() +{ + // Initialize transformMatrix_ as an identity matrix + for (int i = 0; i < MATRIX_SIZE; ++i) { + transformMatrix_[i] = (i % MATRIX_DIAGONAL_STEP == 0) ? IDENTITY_DIAGONAL : IDENTITY_OTHER; + } +} + +ImageRender::~ImageRender() +{ + Cleanup(); +} + +bool ImageRender::InitEGL(EGLNativeWindowType window, uint64_t width, uint64_t height) +{ + window_ = window; + width_ = width; + height_ = height; + + if (!InitializeEGLDisplay() || !ChooseEGLConfig() || !CreateEGLContext() || !CreateEGLSurface()) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to initialize EGL"); + return false; + } + + if (!MakeCurrentContext()) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to make EGL context current"); + return false; + } + + if (!CompileAndLinkShaders()) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to compile and link shaders"); + return false; + } + + UpdateViewport(); + + return true; +} + +void ImageRender::UpdateWindowInfo(uint64_t width, uint64_t height) +{ + width_ = width; + height_ = height; +} + +bool ImageRender::InitializeEGLDisplay() +{ + display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (display_ == EGL_NO_DISPLAY) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to get EGL display"); + return false; + } + + if (!eglInitialize(display_, nullptr, nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to initialize EGL"); + return false; + } + + return true; +} + +bool ImageRender::ChooseEGLConfig() +{ + const EGLint attribs[] = { + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_NONE + }; + + EGLint numConfigs; + if (!eglChooseConfig(display_, attribs, &config_, 1, &numConfigs) || numConfigs == 0) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to choose EGL config"); + return false; + } + return true; +} + +bool ImageRender::CreateEGLContext() +{ + const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; + context_ = eglCreateContext(display_, config_, EGL_NO_CONTEXT, contextAttribs); + if (context_ == EGL_NO_CONTEXT) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to create EGL context"); + return false; + } + return true; +} + +bool ImageRender::CreateEGLSurface() +{ + surface_ = eglCreateWindowSurface(display_, config_, window_, nullptr); + if (surface_ == EGL_NO_SURFACE) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to create EGL surface"); + return false; + } + return true; +} + +bool ImageRender::MakeCurrentContext() +{ + if (!eglMakeCurrent(display_, surface_, surface_, context_)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to make EGL context current"); + return false; + } + return true; +} + +void ImageRender::UpdateViewport() +{ + glViewport(0, 0, static_cast(width_), static_cast(height_)); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ImageRender", + "Viewport updated to %{public}llu x %{public}llu", width_, height_); +} + +bool ImageRender::CompileAndLinkShaders() +{ + GLuint vertexShader = CompileShader(GL_VERTEX_SHADER, g_vertexShaderSource); + if (vertexShader == 0) { + return false; + } + + GLuint fragmentShader = CompileShader(GL_FRAGMENT_SHADER, g_fragmentShaderSource); + if (fragmentShader == 0) { + glDeleteShader(vertexShader); + return false; + } + + shaderProgram_ = glCreateProgram(); + glAttachShader(shaderProgram_, vertexShader); + glAttachShader(shaderProgram_, fragmentShader); + glLinkProgram(shaderProgram_); + + GLint linked; + glGetProgramiv(shaderProgram_, GL_LINK_STATUS, &linked); + if (!linked) { + PrintProgramLinkError(shaderProgram_); + glDeleteProgram(shaderProgram_); + glDeleteShader(vertexShader); + glDeleteShader(fragmentShader); + return false; + } + + glUseProgram(shaderProgram_); + + positionAttrib_ = glGetAttribLocation(shaderProgram_, "aPosition"); + texCoordAttrib_ = glGetAttribLocation(shaderProgram_, "aTexCoord"); + textureUniform_ = glGetUniformLocation(shaderProgram_, "uTexture"); + + glDeleteShader(vertexShader); + glDeleteShader(fragmentShader); + + return true; +} + +void ImageRender::PrintProgramLinkError(GLuint program) +{ + GLint infoLen = 0; + glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) { + std::unique_ptr infoLog = std::make_unique(infoLen); + glGetProgramInfoLog(program, infoLen, nullptr, infoLog.get()); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, + "ImageRender", "Error linking program: %{public}s", infoLog.get()); + } +} + +void ImageRender::SetTransformMatrix(const float matrix[MATRIX_SIZE]) +{ + std::copy(matrix, matrix + MATRIX_SIZE, transformMatrix_); +} + +void ImageRender::SetTexture(GLuint textureId, GLuint textureTarget) +{ + textureId_ = textureId; + textureTarget_ = textureTarget; +} + +void ImageRender::SetupVertexAttributes() +{ + static const GLfloat vertices[] = { + -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, // 左下 + 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, // 右下 + -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, // 左上 + 1.0f, 1.0f, 0.0f, 1.0f, 1.0f // 右上 + }; + + // Enable and set the position attribute + glEnableVertexAttribArray(positionAttrib_); + glVertexAttribPointer(positionAttrib_, POSITION_COMPONENT_COUNT, GL_FLOAT, GL_FALSE, + STRIDE, vertices); + + // Enable and set the texture coordinate attribute + glEnableVertexAttribArray(texCoordAttrib_); + glVertexAttribPointer(texCoordAttrib_, TEX_COORD_COMPONENT_COUNT, GL_FLOAT, GL_FALSE, + STRIDE, vertices + POSITION_COMPONENT_COUNT); +} + +void ImageRender::DisableVertexAttributes() +{ + // Disable the vertex attribute arrays after rendering + glDisableVertexAttribArray(positionAttrib_); + glDisableVertexAttribArray(texCoordAttrib_); +} + +void ImageRender::Render() +{ + if (surface_ == EGL_NO_SURFACE) { + return; + } + + if (!eglMakeCurrent(display_, surface_, surface_, context_)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to make context current in Render"); + return; + } + + // Clear the color buffer + glClearColor(0.0f, 1.0f, 1.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + + // Use the shader program + glUseProgram(shaderProgram_); + + // Bind the texture + glActiveTexture(GL_TEXTURE0); + glBindTexture(textureTarget_, textureId_); + + // Set the texture sampler to texture unit 0 + glUniform1i(textureUniform_, 0); + + // Set the transformation matrix + GLint matrixLocation = glGetUniformLocation(shaderProgram_, "uTransformMatrix"); + if (matrixLocation != -1) { + glUniformMatrix4fv(matrixLocation, 1, GL_FALSE, transformMatrix_); + } + + // Set up vertex attributes + SetupVertexAttributes(); + + // Draw the textured quad + glDrawArrays(GL_TRIANGLE_STRIP, 0, NUM_VERTICES); + + // Disable vertex attributes + DisableVertexAttributes(); + + // Swap the buffers to display the rendered image + if (!eglSwapBuffers(display_, surface_)) { + EGLint error = eglGetError(); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", + "eglSwapBuffers failed with error: %d", error); + } +} + +void ImageRender::Cleanup() +{ + if (display_ != EGL_NO_DISPLAY) { + eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + if (context_ != EGL_NO_CONTEXT) { + eglDestroyContext(display_, context_); + context_ = EGL_NO_CONTEXT; + } + + if (surface_ != EGL_NO_SURFACE) { + eglDestroySurface(display_, surface_); + surface_ = EGL_NO_SURFACE; + } + + eglTerminate(display_); + display_ = EGL_NO_DISPLAY; + } + + if (shaderProgram_ != 0) { + glDeleteProgram(shaderProgram_); + shaderProgram_ = 0; + } +} + +GLuint ImageRender::CompileShader(GLenum type, const char* source) +{ + GLuint shader = glCreateShader(type); + if (shader == 0) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", "Failed to create shader."); + return 0; + } + + glShaderSource(shader, 1, &source, nullptr); + glCompileShader(shader); + + GLint compiled; + glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); + if (!compiled) { + PrintShaderCompileError(shader); + glDeleteShader(shader); + return 0; + } + return shader; +} + +void ImageRender::PrintShaderCompileError(GLuint shader) +{ + GLint infoLen = 0; + glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) { + auto infoLog = std::make_unique(infoLen); + glGetShaderInfoLog(shader, infoLen, nullptr, infoLog.get()); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRender", + "Error compiling shader: %{public}s", infoLog.get()); + } +} diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/image_render.h b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/image_render.h index 9c6d016da2..1636c5b6f4 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/image_render.h +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/image_render.h @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2024 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. - */ - -#ifndef IMAGE_RENDER_H -#define IMAGE_RENDER_H - -#include -#include - -class ImageRender { -public: - ImageRender(); - ~ImageRender(); - - bool InitEGL(EGLNativeWindowType window, uint64_t width, uint64_t height); - bool MakeCurrentContext(); - void UpdateViewport(); - void UpdateWindowInfo(uint64_t width, uint64_t height); - void SetTexture(GLuint textureId, GLuint textureTarget); - void Render(); - void Cleanup(); - void SetTransformMatrix(const float matrix[16]); - -private: - void SetupVertexAttributes(); - void DisableVertexAttributes(); - bool InitializeEGLDisplay(); - bool ChooseEGLConfig(); - bool CreateEGLContext(); - bool CreateEGLSurface(); - bool CompileAndLinkShaders(); - void PrintProgramLinkError(GLuint program); - GLuint CompileShader(GLenum type, const char* source); - void PrintShaderCompileError(GLuint shader); - - EGLDisplay display_ = EGL_NO_DISPLAY; - EGLSurface surface_ = EGL_NO_SURFACE; - EGLContext context_ = EGL_NO_CONTEXT; - EGLConfig config_ = nullptr; - EGLNativeWindowType window_ = 0; - uint64_t width_ = 0; - uint64_t height_ = 0; - GLuint shaderProgram_ = 0; - GLint positionAttrib_ = -1; - GLint texCoordAttrib_ = -1; - GLint textureUniform_ = -1; - GLuint textureId_ = 0; - GLuint textureTarget_ = 0; - float transformMatrix_[16] = { 0.0f }; -}; - -#endif // IMAGE_RENDER_H +/* + * Copyright (c) 2024 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. + */ + +#ifndef IMAGE_RENDER_H +#define IMAGE_RENDER_H + +#include +#include + +class ImageRender { +public: + ImageRender(); + ~ImageRender(); + + bool InitEGL(EGLNativeWindowType window, uint64_t width, uint64_t height); + bool MakeCurrentContext(); + void UpdateViewport(); + void UpdateWindowInfo(uint64_t width, uint64_t height); + void SetTexture(GLuint textureId, GLuint textureTarget); + void Render(); + void Cleanup(); + void SetTransformMatrix(const float matrix[16]); + +private: + void SetupVertexAttributes(); + void DisableVertexAttributes(); + bool InitializeEGLDisplay(); + bool ChooseEGLConfig(); + bool CreateEGLContext(); + bool CreateEGLSurface(); + bool CompileAndLinkShaders(); + void PrintProgramLinkError(GLuint program); + GLuint CompileShader(GLenum type, const char* source); + void PrintShaderCompileError(GLuint shader); + + EGLDisplay display_ = EGL_NO_DISPLAY; + EGLSurface surface_ = EGL_NO_SURFACE; + EGLContext context_ = EGL_NO_CONTEXT; + EGLConfig config_ = nullptr; + EGLNativeWindowType window_ = 0; + uint64_t width_ = 0; + uint64_t height_ = 0; + GLuint shaderProgram_ = 0; + GLint positionAttrib_ = -1; + GLint texCoordAttrib_ = -1; + GLint textureUniform_ = -1; + GLuint textureId_ = 0; + GLuint textureTarget_ = 0; + float transformMatrix_[16] = { 0.0f }; +}; + +#endif // IMAGE_RENDER_H diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/native_render.cpp b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/native_render.cpp index 2a00c38b26..2228850668 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/native_render.cpp +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/native_render.cpp @@ -1,223 +1,223 @@ -/* - * Copyright (c) 2024 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 "native_render.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { - // 动画相关 - constexpr double ANIMATION_SPEED_INCREMENT = 0.6; // 动画速度增量 - - // 文件描述符和轮询相关 - constexpr int INVALID_FD = -1; // 无效的文件描述符 - constexpr uint32_t POLL_TIMEOUT_MS = 3000; // poll 超时时间(毫秒) - constexpr nfds_t NUM_POLL_FDS = 1; // poll 的文件描述符数量 - constexpr int NO_FENCE = -1; // 无同步栅栏 - constexpr int MAX_RETRY = 3; // 最大重试次数 - - // 返回状态码 - constexpr int SUCCESS = 0; // 成功返回码 - constexpr int FAILURE = -1; // 失败返回码 - - // 颜色和像素相关 - constexpr uint8_t MAX_COLOR_VALUE = 255; // 颜色分量的最大值 - constexpr int32_t BYTES_PER_PIXEL = 4; // 每个像素的字节数 - - // 颜色通道位移 - constexpr uint8_t ALPHA_SHIFT = 24; // Alpha 通道位移 - constexpr uint8_t RED_SHIFT = 16; // Red 通道位移 - constexpr uint8_t GREEN_SHIFT = 8; // Green 通道位移 - constexpr uint8_t BLUE_SHIFT = 0; // Blue 通道位移 - - // 强度相关 - constexpr double MAX_INTENSITY = 1.0; // 最大强度值 - constexpr double MIN_INTENSITY = 0.5; // 最小强度值 - constexpr double INTENSITY_MULTIPLIER = 2.0; // 强度乘数 - constexpr double INTENSITY_LIMIT = 1.0; // 强度限制 - - // 箭头绘制相关 - constexpr int ARROW_SIZE_DIVISOR = 2; // 箭头大小的除数 - constexpr int STEM_WIDTH_DIVISOR = 6; // 箭头柄宽度的除数 - constexpr int HEAD_WIDTH_DIVISOR = 2; // 箭头头部宽度的除数 - constexpr int HEAD_LENGTH_DIVISOR = 3; // 箭头头部长度的除数 - constexpr double HEAD_SLOPE_MULTIPLIER = 0.5; // 箭头头部斜率的乘数 -} - -OHNativeRender::~OHNativeRender() -{ - if (nativeWindow_ != nullptr) { - (void)OH_NativeWindow_NativeObjectUnreference(nativeWindow_); - nativeWindow_ = nullptr; - } -} - -bool OHNativeRender::SetSurfaceWidthAndHeight(OH_NativeImage* image, uint64_t surfaceId, uint64_t width, uint64_t height) -{ - if (nativeWindow_ != nullptr) { - (void)OH_NativeWindow_NativeObjectUnreference(nativeWindow_); - nativeWindow_ = nullptr; - } - - // 保存宽度和高度 - width_ = width; - height_ = height; - //方式一: 从 NativeImage 创建 NativeWindow - nativeWindow_ = OH_NativeImage_AcquireNativeWindow(image); - //方式二: 从 SurfaceId 创建 NativeWindow - int ret = OH_NativeWindow_CreateNativeWindowFromSurfaceId(surfaceId, &nativeWindow_); - if (ret != SUCCESS) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "OHNativeRender", - "Failed to create NativeWindow from SurfaceId."); - return false; - } - (void)OH_NativeWindow_NativeObjectReference(nativeWindow_); - - // 设置缓冲区的大小等属性 - int32_t result = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_BUFFER_GEOMETRY, - static_cast(width_), static_cast(height_)); - if (result != SUCCESS) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "OHNativeRender", "Failed to set buffer geometry."); - return false; - } - - return true; -} - -void OHNativeRender::RenderFrame() -{ - OHNativeWindowBuffer *buffer = nullptr; - int releaseFenceFd = INVALID_FD; - int32_t result = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow_, &buffer, &releaseFenceFd); - if (result != SUCCESS || buffer == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, - "OHNativeRender", "Failed to request buffer, ret : %{public}d.", result); - return; - } - - int retCode = FAILURE; - uint32_t timeout = POLL_TIMEOUT_MS; - if (releaseFenceFd != INVALID_FD) { - struct pollfd pollfds = {}; - pollfds.fd = releaseFenceFd; - pollfds.events = POLLIN; - - int retryCount = 0; - - do { - retCode = poll(&pollfds, NUM_POLL_FDS, POLL_TIMEOUT_MS); - retryCount++; - - // 超过最大重试次数则退出 - if (retryCount >= MAX_RETRY) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, - "OHNativeRender", "Poll reached maximum retry count."); - break; - } - } while (retCode == FAILURE && (errno == EINTR || errno == EAGAIN)); - - close(releaseFenceFd); - } - - BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); - if (handle == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "OHNativeRender", "Failed to get buffer handle."); - return; - } - - // 使用 mmap 获取虚拟地址 - void *mappedAddr = mmap(nullptr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); - if (mappedAddr == MAP_FAILED) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "OHNativeRender", "Failed to mmap buffer."); - return; - } - - // 获取像素指针 - uint32_t *pixel = static_cast(mappedAddr); - - // 调用封装的函数来绘制渐变 - DrawGradient(pixel, handle->stride / BYTES_PER_PIXEL, height_); - - // 解除内存映射 - result = munmap(mappedAddr, handle->size); - if (result == FAILURE) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "OHNativeRender", "Failed to munmap buffer."); - } - - std::lock_guard lock(mutex_); - // 设置刷新区域 - Region region{nullptr, 0}; - // 提交给消费者 - result = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow_, buffer, NO_FENCE, region); - if (result != SUCCESS) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, - "OHNativeRender", "Failed to flush buffer, result : %{public}d.", result); - } -} - -void OHNativeRender::DrawGradient(uint32_t* pixel, uint64_t width, uint64_t height) -{ - static double time = 0.0; - time += ANIMATION_SPEED_INCREMENT; - double offset = (sin(time) + MAX_INTENSITY) / INTENSITY_MULTIPLIER; - - // 箭头参数 - const int arrowSize = std::min(width, height) / ARROW_SIZE_DIVISOR; - const int arrowX = width / ARROW_SIZE_DIVISOR; - const int arrowY = height / ARROW_SIZE_DIVISOR; - const int stemWidth = arrowSize / STEM_WIDTH_DIVISOR; - const int headWidth = arrowSize / HEAD_WIDTH_DIVISOR; - const int headLength = arrowSize / HEAD_LENGTH_DIVISOR; - const int stemStart = arrowX - arrowSize / ARROW_SIZE_DIVISOR; - const int stemEnd = arrowX + arrowSize / ARROW_SIZE_DIVISOR - headLength; - - for (uint64_t y = 0; y < height; y++) { - for (uint64_t x = 0; x < width; x++) { - double normalizedX = static_cast(x) / static_cast(width - 1); - bool isArrow = false; - - if ((x >= stemStart && x <= stemEnd && y >= arrowY - stemWidth * HEAD_SLOPE_MULTIPLIER && - y <= arrowY + stemWidth * HEAD_SLOPE_MULTIPLIER) || (x >= stemEnd && x <= stemEnd + headLength && - fabs(static_cast(y - arrowY)) <= (headWidth * HEAD_SLOPE_MULTIPLIER) * - (1.0 - static_cast(x - stemEnd) / headLength))) { - isArrow = true; - } - - uint8_t red = static_cast((1.0 - normalizedX) * MAX_COLOR_VALUE); - uint8_t blue = static_cast(normalizedX * MAX_COLOR_VALUE); - uint8_t green = 0; - uint8_t alpha = MAX_COLOR_VALUE; - if (isArrow) { - red = green = blue = MAX_COLOR_VALUE; - } - double intensity = fabs(normalizedX - offset); - intensity = MAX_INTENSITY - std::min(INTENSITY_MULTIPLIER * intensity, INTENSITY_LIMIT); - intensity = std::max(intensity, MIN_INTENSITY); - - red = static_cast(red * intensity); - green = static_cast(green * intensity); - blue = static_cast(blue * intensity); - - *pixel++ = (static_cast(alpha) << ALPHA_SHIFT) | (static_cast(red) << RED_SHIFT) | - (static_cast(green) << GREEN_SHIFT) | (static_cast(blue) << BLUE_SHIFT); - } - } +/* + * Copyright (c) 2024 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 "native_render.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + // 动画相关 + constexpr double ANIMATION_SPEED_INCREMENT = 0.6; // 动画速度增量 + + // 文件描述符和轮询相关 + constexpr int INVALID_FD = -1; // 无效的文件描述符 + constexpr uint32_t POLL_TIMEOUT_MS = 3000; // poll 超时时间(毫秒) + constexpr nfds_t NUM_POLL_FDS = 1; // poll 的文件描述符数量 + constexpr int NO_FENCE = -1; // 无同步栅栏 + constexpr int MAX_RETRY = 3; // 最大重试次数 + + // 返回状态码 + constexpr int SUCCESS = 0; // 成功返回码 + constexpr int FAILURE = -1; // 失败返回码 + + // 颜色和像素相关 + constexpr uint8_t MAX_COLOR_VALUE = 255; // 颜色分量的最大值 + constexpr int32_t BYTES_PER_PIXEL = 4; // 每个像素的字节数 + + // 颜色通道位移 + constexpr uint8_t ALPHA_SHIFT = 24; // Alpha 通道位移 + constexpr uint8_t RED_SHIFT = 16; // Red 通道位移 + constexpr uint8_t GREEN_SHIFT = 8; // Green 通道位移 + constexpr uint8_t BLUE_SHIFT = 0; // Blue 通道位移 + + // 强度相关 + constexpr double MAX_INTENSITY = 1.0; // 最大强度值 + constexpr double MIN_INTENSITY = 0.5; // 最小强度值 + constexpr double INTENSITY_MULTIPLIER = 2.0; // 强度乘数 + constexpr double INTENSITY_LIMIT = 1.0; // 强度限制 + + // 箭头绘制相关 + constexpr int ARROW_SIZE_DIVISOR = 2; // 箭头大小的除数 + constexpr int STEM_WIDTH_DIVISOR = 6; // 箭头柄宽度的除数 + constexpr int HEAD_WIDTH_DIVISOR = 2; // 箭头头部宽度的除数 + constexpr int HEAD_LENGTH_DIVISOR = 3; // 箭头头部长度的除数 + constexpr double HEAD_SLOPE_MULTIPLIER = 0.5; // 箭头头部斜率的乘数 +} + +OHNativeRender::~OHNativeRender() +{ + if (nativeWindow_ != nullptr) { + (void)OH_NativeWindow_NativeObjectUnreference(nativeWindow_); + nativeWindow_ = nullptr; + } +} + +bool OHNativeRender::SetSurfaceWidthAndHeight(OH_NativeImage* image, uint64_t surfaceId, uint64_t width, uint64_t height) +{ + if (nativeWindow_ != nullptr) { + (void)OH_NativeWindow_NativeObjectUnreference(nativeWindow_); + nativeWindow_ = nullptr; + } + + // 保存宽度和高度 + width_ = width; + height_ = height; + //方式一: 从 NativeImage 创建 NativeWindow + nativeWindow_ = OH_NativeImage_AcquireNativeWindow(image); + //方式二: 从 SurfaceId 创建 NativeWindow + int ret = OH_NativeWindow_CreateNativeWindowFromSurfaceId(surfaceId, &nativeWindow_); + if (ret != SUCCESS) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "OHNativeRender", + "Failed to create NativeWindow from SurfaceId."); + return false; + } + (void)OH_NativeWindow_NativeObjectReference(nativeWindow_); + + // 设置缓冲区的大小等属性 + int32_t result = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_BUFFER_GEOMETRY, + static_cast(width_), static_cast(height_)); + if (result != SUCCESS) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "OHNativeRender", "Failed to set buffer geometry."); + return false; + } + + return true; +} + +void OHNativeRender::RenderFrame() +{ + OHNativeWindowBuffer *buffer = nullptr; + int releaseFenceFd = INVALID_FD; + int32_t result = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow_, &buffer, &releaseFenceFd); + if (result != SUCCESS || buffer == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, + "OHNativeRender", "Failed to request buffer, ret : %{public}d.", result); + return; + } + + int retCode = FAILURE; + uint32_t timeout = POLL_TIMEOUT_MS; + if (releaseFenceFd != INVALID_FD) { + struct pollfd pollfds = {}; + pollfds.fd = releaseFenceFd; + pollfds.events = POLLIN; + + int retryCount = 0; + + do { + retCode = poll(&pollfds, NUM_POLL_FDS, POLL_TIMEOUT_MS); + retryCount++; + + // 超过最大重试次数则退出 + if (retryCount >= MAX_RETRY) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, + "OHNativeRender", "Poll reached maximum retry count."); + break; + } + } while (retCode == FAILURE && (errno == EINTR || errno == EAGAIN)); + + close(releaseFenceFd); + } + + BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); + if (handle == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "OHNativeRender", "Failed to get buffer handle."); + return; + } + + // 使用 mmap 获取虚拟地址 + void *mappedAddr = mmap(nullptr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); + if (mappedAddr == MAP_FAILED) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "OHNativeRender", "Failed to mmap buffer."); + return; + } + + // 获取像素指针 + uint32_t *pixel = static_cast(mappedAddr); + + // 调用封装的函数来绘制渐变 + DrawGradient(pixel, handle->stride / BYTES_PER_PIXEL, height_); + + // 解除内存映射 + result = munmap(mappedAddr, handle->size); + if (result == FAILURE) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "OHNativeRender", "Failed to munmap buffer."); + } + + std::lock_guard lock(mutex_); + // 设置刷新区域 + Region region{nullptr, 0}; + // 提交给消费者 + result = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow_, buffer, NO_FENCE, region); + if (result != SUCCESS) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, + "OHNativeRender", "Failed to flush buffer, result : %{public}d.", result); + } +} + +void OHNativeRender::DrawGradient(uint32_t* pixel, uint64_t width, uint64_t height) +{ + static double time = 0.0; + time += ANIMATION_SPEED_INCREMENT; + double offset = (sin(time) + MAX_INTENSITY) / INTENSITY_MULTIPLIER; + + // 箭头参数 + const int arrowSize = std::min(width, height) / ARROW_SIZE_DIVISOR; + const int arrowX = width / ARROW_SIZE_DIVISOR; + const int arrowY = height / ARROW_SIZE_DIVISOR; + const int stemWidth = arrowSize / STEM_WIDTH_DIVISOR; + const int headWidth = arrowSize / HEAD_WIDTH_DIVISOR; + const int headLength = arrowSize / HEAD_LENGTH_DIVISOR; + const int stemStart = arrowX - arrowSize / ARROW_SIZE_DIVISOR; + const int stemEnd = arrowX + arrowSize / ARROW_SIZE_DIVISOR - headLength; + + for (uint64_t y = 0; y < height; y++) { + for (uint64_t x = 0; x < width; x++) { + double normalizedX = static_cast(x) / static_cast(width - 1); + bool isArrow = false; + + if ((x >= stemStart && x <= stemEnd && y >= arrowY - stemWidth * HEAD_SLOPE_MULTIPLIER && + y <= arrowY + stemWidth * HEAD_SLOPE_MULTIPLIER) || (x >= stemEnd && x <= stemEnd + headLength && + fabs(static_cast(y - arrowY)) <= (headWidth * HEAD_SLOPE_MULTIPLIER) * + (1.0 - static_cast(x - stemEnd) / headLength))) { + isArrow = true; + } + + uint8_t red = static_cast((1.0 - normalizedX) * MAX_COLOR_VALUE); + uint8_t blue = static_cast(normalizedX * MAX_COLOR_VALUE); + uint8_t green = 0; + uint8_t alpha = MAX_COLOR_VALUE; + if (isArrow) { + red = green = blue = MAX_COLOR_VALUE; + } + double intensity = fabs(normalizedX - offset); + intensity = MAX_INTENSITY - std::min(INTENSITY_MULTIPLIER * intensity, INTENSITY_LIMIT); + intensity = std::max(intensity, MIN_INTENSITY); + + red = static_cast(red * intensity); + green = static_cast(green * intensity); + blue = static_cast(blue * intensity); + + *pixel++ = (static_cast(alpha) << ALPHA_SHIFT) | (static_cast(red) << RED_SHIFT) | + (static_cast(green) << GREEN_SHIFT) | (static_cast(blue) << BLUE_SHIFT); + } + } } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/native_render.h b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/native_render.h index eed4ec671f..33b7d498e3 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/native_render.h +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/native_render.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2024 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. - */ - -#ifndef NATIVE_IMAGE_NATIVE_RENDER_H -#define NATIVE_IMAGE_NATIVE_RENDER_H -#include -#include -#include -#include -#include - -class OHNativeRender { -public: - OHNativeRender() = default; - ~OHNativeRender(); - - bool SetSurfaceWidthAndHeight(OH_NativeImage* image, uint64_t surfaceId, uint64_t width, uint64_t height); - void RenderFrame(); - -private: - void DrawGradient(uint32_t* pixel, uint64_t width, uint64_t height); - - OHNativeWindow* nativeWindow_ = nullptr; - std::mutex mutex_; - uint64_t width_ = 0; - uint64_t height_ = 0; -}; -#endif // NATIVE_IMAGE_NATIVE_RENDER_H +/* + * Copyright (c) 2024 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. + */ + +#ifndef NATIVE_IMAGE_NATIVE_RENDER_H +#define NATIVE_IMAGE_NATIVE_RENDER_H +#include +#include +#include +#include +#include + +class OHNativeRender { +public: + OHNativeRender() = default; + ~OHNativeRender(); + + bool SetSurfaceWidthAndHeight(OH_NativeImage* image, uint64_t surfaceId, uint64_t width, uint64_t height); + void RenderFrame(); + +private: + void DrawGradient(uint32_t* pixel, uint64_t width, uint64_t height); + + OHNativeWindow* nativeWindow_ = nullptr; + std::mutex mutex_; + uint64_t width_ = 0; + uint64_t height_ = 0; +}; +#endif // NATIVE_IMAGE_NATIVE_RENDER_H diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/render_engine.cpp b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/render_engine.cpp index b3ac18e564..bdb99a1332 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/render_engine.cpp +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/render_engine.cpp @@ -1,400 +1,400 @@ -/* - * Copyright (c) 2024 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 "render_engine.h" -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { - constexpr int FRAME_RATE = 60; // 目标帧率 - constexpr int NANOSECONDS_IN_A_SECOND = 1000000000; // 一秒中的纳秒数 -} - -RenderEngine::RenderEngine(std::shared_ptr imageRender, uint64_t width, uint64_t height, void *window) - : imageRender_(std::move(imageRender)), width_(width), height_(height), window_(window) -{ - Start(); -} - -RenderEngine::~RenderEngine() -{ - Stop(); -} - -void RenderEngine::Start() -{ - if (running_) { - return; - } - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "start."); - running_ = true; - - thread_ = std::thread([this]() { - if (!imageRender_->InitEGL(reinterpret_cast(window_), width_, height_)) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Failed to initialize EGL"); - return; - } - if (!InitNativeVsync()) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Failed to initialize VSync"); - return; - } - if (!CreateNativeImage()) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Failed to create Native Image"); - return; - } - if (!StartNativeRenderThread()) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Failed to start NativeRender thread"); - return; - } - MainLoop(); - CleanupResources(); - }); -} - -void RenderEngine::CleanupResources() -{ - StopNativeRenderThread(); - DestroyNativeImage(); - DestroyNativeVsync(); - imageRender_->Cleanup(); -} - -void RenderEngine::Stop() -{ - if (!running_) { - return; - } - - running_ = false; - - if (thread_.joinable()) { - thread_.join(); - } - - CleanupResources(); -} - -void RenderEngine::UpdateNativeWindow(uint64_t width, uint64_t height) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "UpdateNativeWindow."); - PostTask([this, width, height](std::shared_ptr imageRender) { - imageRender->UpdateWindowInfo(width, height); - imageRender->UpdateViewport(); - }); -} - -void RenderEngine::MainLoop() -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "MainLoop start."); - - threadId_ = std::this_thread::get_id(); - - while (running_) { - WaitForNewFrame(); - if (!isPaused_) { - ExecuteRenderTasks(); - UpdateSurfaceImage(); - } - } - - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "MainLoop end."); -} - -void RenderEngine::WaitForNewFrame() -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "Waiting for new frame."); - std::unique_lock lock(frameMutex_); - frameCond_.wait(lock, [this] { return availableFrameCnt_ > 0 || !running_; }); -} - -void RenderEngine::WaitForVsync() -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "Waiting for vsync."); - std::unique_lock lock(wakeUpMutex_); - wakeUpCond_.wait(lock, [this]() { return wakeUp_ || vSyncCnt_ > 0; }); - wakeUp_ = false; - if (vSyncCnt_ > 0) { - vSyncCnt_--; - (void)OH_NativeVSync_RequestFrame(nativeVsync_, &RenderEngine::OnVsync, this); - OH_NativeVSync_GetPeriod(nativeVsync_, &period); - } -} - -void RenderEngine::OnVsync(long long timestamp, void *data) -{ - OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_PRINT_DOMAIN, "RenderEngine", "OnVsync %{public}lld.", timestamp); - auto renderEngine = reinterpret_cast(data); - if (renderEngine == nullptr) { - return; - } - - renderEngine->vSyncCnt_++; - renderEngine->wakeUpCond_.notify_one(); -} - -bool RenderEngine::InitNativeVsync() -{ - const char* demoName = "NativeImageSample"; - nativeVsync_ = OH_NativeVSync_Create(demoName, strlen(demoName)); - if (nativeVsync_ == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Create NativeVSync failed."); - return false; - } - (void)OH_NativeVSync_RequestFrame(nativeVsync_, &RenderEngine::OnVsync, this); - return true; -} - -void RenderEngine::DestroyNativeVsync() -{ - if (nativeVsync_ != nullptr) { - OH_NativeVSync_Destroy(nativeVsync_); - nativeVsync_ = nullptr; - } -} - -void RenderEngine::ExecuteRenderTasks() -{ - std::vector tasks; - { - std::lock_guard lock(taskMutex_); - tasks.swap(tasks_); - } - for (const auto &task : tasks) { - task(imageRender_); - } -} - -void RenderEngine::UpdateSurfaceImage() -{ - if (availableFrameCnt_ <= 0) { - return; - } - - if (!nativeImage_) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Native Image is null"); - return; - } - - int32_t ret = OH_NativeImage_UpdateSurfaceImage(nativeImage_); - if (ret != 0) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", - "OH_NativeImage_UpdateSurfaceImage failed, ret: %{public}d, texId: %{public}u", - ret, nativeImageTexId_); - return; - } - - UpdateTextureMatrix(); - if (imageRender_) { - imageRender_->Render(); - } else { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "ImageRender is null"); - } - availableFrameCnt_--; -} - -void RenderEngine::UpdateTextureMatrix() -{ - float matrix[16]; - int32_t ret = OH_NativeImage_GetTransformMatrixV2(nativeImage_, matrix); - if (ret != 0) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", - "OH_NativeImage_GetTransformMatrix failed, ret: %{public}d", ret); - return; - } - imageRender_->SetTransformMatrix(matrix); -} - -bool RenderEngine::CreateNativeImage() -{ - if (!GenerateTexture() || !CreateNativeImageObject() || !AttachContextAndGetSurfaceId()) { - return false; - } - - if (!SetFrameAvailableListener()) { - return false; - } - - imageRender_->SetTexture(nativeImageTexId_, GL_TEXTURE_EXTERNAL_OES); - - return true; -} - -bool RenderEngine::GenerateTexture() -{ - glGenTextures(1, &nativeImageTexId_); - glBindTexture(GL_TEXTURE_EXTERNAL_OES, nativeImageTexId_); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - return true; -} - -bool RenderEngine::CreateNativeImageObject() -{ - nativeImage_ = OH_NativeImage_Create(nativeImageTexId_, GL_TEXTURE_EXTERNAL_OES); - if (nativeImage_ == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Failed to create Native Image"); - return false; - } - return true; -} - -bool RenderEngine::AttachContextAndGetSurfaceId() -{ - int ret = OH_NativeImage_AttachContext(nativeImage_, nativeImageTexId_); - if (ret != 0) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", - "AttachContext failed for textureId: %{public}u, ret: %{public}d", nativeImageTexId_, ret); - return false; - } - - std::lock_guard lock(nativeImageSurfaceIdMutex_); - ret = OH_NativeImage_GetSurfaceId(nativeImage_, &nativeImageSurfaceId_); - if (ret != 0) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", - "OH_NativeImage_GetSurfaceId failed, ret: %{public}d", ret); - return false; - } - return true; -} - -bool RenderEngine::SetFrameAvailableListener() -{ - nativeImageFrameAvailableListener_.context = this; - nativeImageFrameAvailableListener_.onFrameAvailable = &RenderEngine::OnNativeImageFrameAvailable; - int ret = OH_NativeImage_SetOnFrameAvailableListener(nativeImage_, nativeImageFrameAvailableListener_); - if (ret != 0) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", - "OH_NativeImage_SetOnFrameAvailableListener failed, ret: %{public}d", ret); - return false; - } - return true; -} - -void RenderEngine::PostTask(const RenderTask &task) -{ - if (!running_) { - OH_LOG_Print(LOG_APP, LOG_WARN, LOG_PRINT_DOMAIN, "RenderEngine", - "PostTask failed: RenderEngine is not running"); - return; - } - - { - std::lock_guard lock(taskMutex_); - tasks_.push_back(task); - } - - frameCond_.notify_one(); -} - -void RenderEngine::OnNativeImageFrameAvailable(void *data) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "OnNativeImageFrameAvailable."); - auto renderEngine = reinterpret_cast(data); - if (renderEngine == nullptr) { - return; - } - { - std::lock_guard lock(renderEngine->frameMutex_); - renderEngine->availableFrameCnt_++; - } - renderEngine->frameCond_.notify_one(); -} - -void RenderEngine::DestroyNativeImage() -{ - if (nativeImageTexId_ != 0U) { - glDeleteTextures(1, &nativeImageTexId_); - nativeImageTexId_ = 0U; - } - - if (nativeImage_ != nullptr) { - OH_NativeImage_DetachContext(nativeImage_); - (void)OH_NativeImage_UnsetOnFrameAvailableListener(nativeImage_); - OH_NativeImage_Destroy(&nativeImage_); - nativeImage_ = nullptr; - } -} - -bool RenderEngine::StartNativeRenderThread() -{ - if (!nativeRender_) { - nativeRender_ = std::make_shared(); - } - - { - std::lock_guard lock(nativeImageSurfaceIdMutex_); - if (nativeImageSurfaceId_ == 0) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Invalid nativeImageSurfaceId_"); - return false; - } - - if (!nativeRender_->SetSurfaceWidthAndHeight(nativeImage_, nativeImageSurfaceId_, width_, height_)) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, - "RenderEngine", "Failed to set SurfaceId for NativeRender"); - return false; - } - } - - nativeRenderThread_ = std::thread([this]() { - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "Native Render Thread started"); - while (running_) { - // 等待 VSync 信号 - WaitForVsync(); - if (!isPaused_ && nativeRender_) { - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "Rendering Frame"); - nativeRender_->RenderFrame(); - } - } - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "Native Render Thread ended"); - }); - - return true; -} - -void RenderEngine::StopNativeRenderThread() -{ - if (nativeRenderThread_.joinable()) { - nativeRenderThread_.join(); - } -} - -void RenderEngine::OnSurfaceChanged(uint64_t width, uint64_t height) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", - "Surface changed to %{public}llu x %{public}lu", width, height); - - UpdateNativeWindow(width, height); -} - -void RenderEngine::OnAppResume() -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "App resumed"); - isPaused_ = false; -} - -void RenderEngine::OnAppPause() -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "App paused"); - isPaused_ = true; -} +/* + * Copyright (c) 2024 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 "render_engine.h" +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + constexpr int FRAME_RATE = 60; // 目标帧率 + constexpr int NANOSECONDS_IN_A_SECOND = 1000000000; // 一秒中的纳秒数 +} + +RenderEngine::RenderEngine(std::shared_ptr imageRender, uint64_t width, uint64_t height, void *window) + : imageRender_(std::move(imageRender)), width_(width), height_(height), window_(window) +{ + Start(); +} + +RenderEngine::~RenderEngine() +{ + Stop(); +} + +void RenderEngine::Start() +{ + if (running_) { + return; + } + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "start."); + running_ = true; + + thread_ = std::thread([this]() { + if (!imageRender_->InitEGL(reinterpret_cast(window_), width_, height_)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Failed to initialize EGL"); + return; + } + if (!InitNativeVsync()) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Failed to initialize VSync"); + return; + } + if (!CreateNativeImage()) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Failed to create Native Image"); + return; + } + if (!StartNativeRenderThread()) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Failed to start NativeRender thread"); + return; + } + MainLoop(); + CleanupResources(); + }); +} + +void RenderEngine::CleanupResources() +{ + StopNativeRenderThread(); + DestroyNativeImage(); + DestroyNativeVsync(); + imageRender_->Cleanup(); +} + +void RenderEngine::Stop() +{ + if (!running_) { + return; + } + + running_ = false; + + if (thread_.joinable()) { + thread_.join(); + } + + CleanupResources(); +} + +void RenderEngine::UpdateNativeWindow(uint64_t width, uint64_t height) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "UpdateNativeWindow."); + PostTask([this, width, height](std::shared_ptr imageRender) { + imageRender->UpdateWindowInfo(width, height); + imageRender->UpdateViewport(); + }); +} + +void RenderEngine::MainLoop() +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "MainLoop start."); + + threadId_ = std::this_thread::get_id(); + + while (running_) { + WaitForNewFrame(); + if (!isPaused_) { + ExecuteRenderTasks(); + UpdateSurfaceImage(); + } + } + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "MainLoop end."); +} + +void RenderEngine::WaitForNewFrame() +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "Waiting for new frame."); + std::unique_lock lock(frameMutex_); + frameCond_.wait(lock, [this] { return availableFrameCnt_ > 0 || !running_; }); +} + +void RenderEngine::WaitForVsync() +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "Waiting for vsync."); + std::unique_lock lock(wakeUpMutex_); + wakeUpCond_.wait(lock, [this]() { return wakeUp_ || vSyncCnt_ > 0; }); + wakeUp_ = false; + if (vSyncCnt_ > 0) { + vSyncCnt_--; + (void)OH_NativeVSync_RequestFrame(nativeVsync_, &RenderEngine::OnVsync, this); + OH_NativeVSync_GetPeriod(nativeVsync_, &period); + } +} + +void RenderEngine::OnVsync(long long timestamp, void *data) +{ + OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_PRINT_DOMAIN, "RenderEngine", "OnVsync %{public}lld.", timestamp); + auto renderEngine = reinterpret_cast(data); + if (renderEngine == nullptr) { + return; + } + + renderEngine->vSyncCnt_++; + renderEngine->wakeUpCond_.notify_one(); +} + +bool RenderEngine::InitNativeVsync() +{ + const char* demoName = "NativeImageSample"; + nativeVsync_ = OH_NativeVSync_Create(demoName, strlen(demoName)); + if (nativeVsync_ == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Create NativeVSync failed."); + return false; + } + (void)OH_NativeVSync_RequestFrame(nativeVsync_, &RenderEngine::OnVsync, this); + return true; +} + +void RenderEngine::DestroyNativeVsync() +{ + if (nativeVsync_ != nullptr) { + OH_NativeVSync_Destroy(nativeVsync_); + nativeVsync_ = nullptr; + } +} + +void RenderEngine::ExecuteRenderTasks() +{ + std::vector tasks; + { + std::lock_guard lock(taskMutex_); + tasks.swap(tasks_); + } + for (const auto &task : tasks) { + task(imageRender_); + } +} + +void RenderEngine::UpdateSurfaceImage() +{ + if (availableFrameCnt_ <= 0) { + return; + } + + if (!nativeImage_) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Native Image is null"); + return; + } + + int32_t ret = OH_NativeImage_UpdateSurfaceImage(nativeImage_); + if (ret != 0) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", + "OH_NativeImage_UpdateSurfaceImage failed, ret: %{public}d, texId: %{public}u", + ret, nativeImageTexId_); + return; + } + + UpdateTextureMatrix(); + if (imageRender_) { + imageRender_->Render(); + } else { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "ImageRender is null"); + } + availableFrameCnt_--; +} + +void RenderEngine::UpdateTextureMatrix() +{ + float matrix[16]; + int32_t ret = OH_NativeImage_GetTransformMatrixV2(nativeImage_, matrix); + if (ret != 0) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", + "OH_NativeImage_GetTransformMatrix failed, ret: %{public}d", ret); + return; + } + imageRender_->SetTransformMatrix(matrix); +} + +bool RenderEngine::CreateNativeImage() +{ + if (!GenerateTexture() || !CreateNativeImageObject() || !AttachContextAndGetSurfaceId()) { + return false; + } + + if (!SetFrameAvailableListener()) { + return false; + } + + imageRender_->SetTexture(nativeImageTexId_, GL_TEXTURE_EXTERNAL_OES); + + return true; +} + +bool RenderEngine::GenerateTexture() +{ + glGenTextures(1, &nativeImageTexId_); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, nativeImageTexId_); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + return true; +} + +bool RenderEngine::CreateNativeImageObject() +{ + nativeImage_ = OH_NativeImage_Create(nativeImageTexId_, GL_TEXTURE_EXTERNAL_OES); + if (nativeImage_ == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Failed to create Native Image"); + return false; + } + return true; +} + +bool RenderEngine::AttachContextAndGetSurfaceId() +{ + int ret = OH_NativeImage_AttachContext(nativeImage_, nativeImageTexId_); + if (ret != 0) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", + "AttachContext failed for textureId: %{public}u, ret: %{public}d", nativeImageTexId_, ret); + return false; + } + + std::lock_guard lock(nativeImageSurfaceIdMutex_); + ret = OH_NativeImage_GetSurfaceId(nativeImage_, &nativeImageSurfaceId_); + if (ret != 0) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", + "OH_NativeImage_GetSurfaceId failed, ret: %{public}d", ret); + return false; + } + return true; +} + +bool RenderEngine::SetFrameAvailableListener() +{ + nativeImageFrameAvailableListener_.context = this; + nativeImageFrameAvailableListener_.onFrameAvailable = &RenderEngine::OnNativeImageFrameAvailable; + int ret = OH_NativeImage_SetOnFrameAvailableListener(nativeImage_, nativeImageFrameAvailableListener_); + if (ret != 0) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", + "OH_NativeImage_SetOnFrameAvailableListener failed, ret: %{public}d", ret); + return false; + } + return true; +} + +void RenderEngine::PostTask(const RenderTask &task) +{ + if (!running_) { + OH_LOG_Print(LOG_APP, LOG_WARN, LOG_PRINT_DOMAIN, "RenderEngine", + "PostTask failed: RenderEngine is not running"); + return; + } + + { + std::lock_guard lock(taskMutex_); + tasks_.push_back(task); + } + + frameCond_.notify_one(); +} + +void RenderEngine::OnNativeImageFrameAvailable(void *data) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "OnNativeImageFrameAvailable."); + auto renderEngine = reinterpret_cast(data); + if (renderEngine == nullptr) { + return; + } + { + std::lock_guard lock(renderEngine->frameMutex_); + renderEngine->availableFrameCnt_++; + } + renderEngine->frameCond_.notify_one(); +} + +void RenderEngine::DestroyNativeImage() +{ + if (nativeImageTexId_ != 0U) { + glDeleteTextures(1, &nativeImageTexId_); + nativeImageTexId_ = 0U; + } + + if (nativeImage_ != nullptr) { + OH_NativeImage_DetachContext(nativeImage_); + (void)OH_NativeImage_UnsetOnFrameAvailableListener(nativeImage_); + OH_NativeImage_Destroy(&nativeImage_); + nativeImage_ = nullptr; + } +} + +bool RenderEngine::StartNativeRenderThread() +{ + if (!nativeRender_) { + nativeRender_ = std::make_shared(); + } + + { + std::lock_guard lock(nativeImageSurfaceIdMutex_); + if (nativeImageSurfaceId_ == 0) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RenderEngine", "Invalid nativeImageSurfaceId_"); + return false; + } + + if (!nativeRender_->SetSurfaceWidthAndHeight(nativeImage_, nativeImageSurfaceId_, width_, height_)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, + "RenderEngine", "Failed to set SurfaceId for NativeRender"); + return false; + } + } + + nativeRenderThread_ = std::thread([this]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "Native Render Thread started"); + while (running_) { + // 等待 VSync 信号 + WaitForVsync(); + if (!isPaused_ && nativeRender_) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "Rendering Frame"); + nativeRender_->RenderFrame(); + } + } + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "Native Render Thread ended"); + }); + + return true; +} + +void RenderEngine::StopNativeRenderThread() +{ + if (nativeRenderThread_.joinable()) { + nativeRenderThread_.join(); + } +} + +void RenderEngine::OnSurfaceChanged(uint64_t width, uint64_t height) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", + "Surface changed to %{public}llu x %{public}lu", width, height); + + UpdateNativeWindow(width, height); +} + +void RenderEngine::OnAppResume() +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "App resumed"); + isPaused_ = false; +} + +void RenderEngine::OnAppPause() +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "RenderEngine", "App paused"); + isPaused_ = true; +} diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/render_engine.h b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/render_engine.h index b2a57b8a57..14ef2567dd 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/render_engine.h +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/render/render_engine.h @@ -1,131 +1,131 @@ -/* - * Copyright (c) 2024 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. - */ - -#ifndef RENDER_ENGINE_H -#define RENDER_ENGINE_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include "image_render.h" -#include "native_render.h" - -class RenderEngine { -public: - using RenderTask = std::function render)>; - - RenderEngine(std::shared_ptr imageRender, uint64_t width, uint64_t height, void *window); - ~RenderEngine(); - - // 禁用拷贝和移动 - RenderEngine(const RenderEngine &other) = delete; - RenderEngine &operator=(const RenderEngine &other) = delete; - RenderEngine(RenderEngine &&other) = delete; - RenderEngine &operator=(RenderEngine &&other) = delete; - - // 启动渲染引擎 - void Start(); - - // 停止渲染引擎 - void Stop(); - - // 发布任务到渲染线程 - void PostTask(const RenderTask &task); - - // 更新 NativeWindow - void UpdateNativeWindow(uint64_t width, uint64_t height); - void OnSurfaceChanged(uint64_t width, uint64_t height); - void OnAppResume(); - void OnAppPause(); -private: - static void OnNativeImageFrameAvailable(void *data); - // Vsync 相关 - bool InitNativeVsync(); - void DestroyNativeVsync(); - static void OnVsync(long long timestamp, void *data); - - // 主循环 - void MainLoop(); - - // 渲染线程初始化 - void InitializeRendering(); - void CleanupResources(); - - // 渲染流程任务 - void WaitForNewFrame(); - void WaitForVsync(); - void ExecuteRenderTasks(); - void UpdateSurfaceImage(); - void UpdateTextureMatrix(); - - // 创建与销毁 NativeImage - bool CreateNativeImage(); - bool StartNativeRenderThread(); - void StopNativeRenderThread(); - void DestroyNativeImage(); - - bool GenerateTexture(); - bool CreateNativeImageObject(); - bool AttachContextAndGetSurfaceId(); - bool SetFrameAvailableListener(); - - // NativeRender 相关 - std::shared_ptr nativeRender_; - std::thread nativeRenderThread_; - - // NativeImage 相关 - OH_OnFrameAvailableListener nativeImageFrameAvailableListener_{}; - OH_NativeImage *nativeImage_ = nullptr; - GLuint nativeImageTexId_ = 0U; - std::mutex nativeImageSurfaceIdMutex_; - uint64_t nativeImageSurfaceId_ = 0; - std::atomic availableFrameCnt_{0}; - std::condition_variable frameCond_; - std::mutex frameMutex_; - - // 渲染引擎运行状态 - std::atomic running_{false}; - std::thread thread_; - std::thread::id threadId_; - - // 同步和任务队列 - std::mutex taskMutex_; - std::vector tasks_; - mutable std::mutex wakeUpMutex_; - std::condition_variable wakeUpCond_; - bool wakeUp_ = false; - std::atomic vSyncCnt_{0}; - OH_NativeVSync *nativeVsync_ = nullptr; - - // 关联的 ImageRender 实例 - std::shared_ptr imageRender_; - void *window_ = nullptr; - uint64_t width_ = 0; - uint64_t height_ = 0; - long long period = 0; - // 其他状态变量 - std::atomic isPaused_{false}; -}; - -#endif // RENDER_ENGINE_H +/* + * Copyright (c) 2024 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. + */ + +#ifndef RENDER_ENGINE_H +#define RENDER_ENGINE_H + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "image_render.h" +#include "native_render.h" + +class RenderEngine { +public: + using RenderTask = std::function render)>; + + RenderEngine(std::shared_ptr imageRender, uint64_t width, uint64_t height, void *window); + ~RenderEngine(); + + // 禁用拷贝和移动 + RenderEngine(const RenderEngine &other) = delete; + RenderEngine &operator=(const RenderEngine &other) = delete; + RenderEngine(RenderEngine &&other) = delete; + RenderEngine &operator=(RenderEngine &&other) = delete; + + // 启动渲染引擎 + void Start(); + + // 停止渲染引擎 + void Stop(); + + // 发布任务到渲染线程 + void PostTask(const RenderTask &task); + + // 更新 NativeWindow + void UpdateNativeWindow(uint64_t width, uint64_t height); + void OnSurfaceChanged(uint64_t width, uint64_t height); + void OnAppResume(); + void OnAppPause(); +private: + static void OnNativeImageFrameAvailable(void *data); + // Vsync 相关 + bool InitNativeVsync(); + void DestroyNativeVsync(); + static void OnVsync(long long timestamp, void *data); + + // 主循环 + void MainLoop(); + + // 渲染线程初始化 + void InitializeRendering(); + void CleanupResources(); + + // 渲染流程任务 + void WaitForNewFrame(); + void WaitForVsync(); + void ExecuteRenderTasks(); + void UpdateSurfaceImage(); + void UpdateTextureMatrix(); + + // 创建与销毁 NativeImage + bool CreateNativeImage(); + bool StartNativeRenderThread(); + void StopNativeRenderThread(); + void DestroyNativeImage(); + + bool GenerateTexture(); + bool CreateNativeImageObject(); + bool AttachContextAndGetSurfaceId(); + bool SetFrameAvailableListener(); + + // NativeRender 相关 + std::shared_ptr nativeRender_; + std::thread nativeRenderThread_; + + // NativeImage 相关 + OH_OnFrameAvailableListener nativeImageFrameAvailableListener_{}; + OH_NativeImage *nativeImage_ = nullptr; + GLuint nativeImageTexId_ = 0U; + std::mutex nativeImageSurfaceIdMutex_; + uint64_t nativeImageSurfaceId_ = 0; + std::atomic availableFrameCnt_{0}; + std::condition_variable frameCond_; + std::mutex frameMutex_; + + // 渲染引擎运行状态 + std::atomic running_{false}; + std::thread thread_; + std::thread::id threadId_; + + // 同步和任务队列 + std::mutex taskMutex_; + std::vector tasks_; + mutable std::mutex wakeUpMutex_; + std::condition_variable wakeUpCond_; + bool wakeUp_ = false; + std::atomic vSyncCnt_{0}; + OH_NativeVSync *nativeVsync_ = nullptr; + + // 关联的 ImageRender 实例 + std::shared_ptr imageRender_; + void *window_ = nullptr; + uint64_t width_ = 0; + uint64_t height_ = 0; + long long period = 0; + // 其他状态变量 + std::atomic isPaused_{false}; +}; + +#endif // RENDER_ENGINE_H diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/types/libentry/oh-package.json5 index 5819381415..05fea1c071 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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." +/* + * Copyright (c) 2024 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/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/entryability/EntryAbility.ets index ca45f40113..d96a7e268e 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,41 +1,41 @@ -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index b72fc477d9..dc55c03d3e 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,12 +1,12 @@ -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)); - } +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/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/pages/Index.ets index 030a410d21..c843f4f584 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/ets/pages/Index.ets @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2024 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'; - -@Entry -@Component -struct Index { - xComponentContext: XComponentController = new XComponentController() - xComponentAttrs: XComponentAttrs = { - id: 'xcomponentId', - type: XComponentType.SURFACE, - libraryname: 'entry' - } - - build() { - Column() { - XComponent(this.xComponentAttrs) - .onLoad((context: XComponentController) => { - this.xComponentContext = context; - }) - .padding(16) - } - } -} - -interface XComponentAttrs { - id: string; - type: number; - libraryname: string; +/* + * Copyright (c) 2024 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'; + +@Entry +@Component +struct Index { + xComponentContext: XComponentController = new XComponentController() + xComponentAttrs: XComponentAttrs = { + id: 'xcomponentId', + type: XComponentType.SURFACE, + libraryname: 'entry' + } + + build() { + Column() { + XComponent(this.xComponentAttrs) + .onLoad((context: XComponentController) => { + this.xComponentContext = context; + }) + .padding(16) + } + } +} + +interface XComponentAttrs { + id: string; + type: number; + libraryname: string; } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/module.json5 b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/module.json5 index b541792385..cb5df2316a 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/module.json5 +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/module.json5 @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2024 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" - } - ] - } - ] - } +/* + * Copyright (c) 2024 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/BasicFeature/Native/NdkNativeImage/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/resources/base/profile/backup_config.json index d742c2f96e..78f40ae7c4 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/main/resources/base/profile/backup_config.json +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/ohosTest/ets/test/NdkNativeImage.test.ets b/code/BasicFeature/Native/NdkNativeImage/entry/src/ohosTest/ets/test/NdkNativeImage.test.ets index b6f8c04314..576a711666 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/ohosTest/ets/test/NdkNativeImage.test.ets +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/ohosTest/ets/test/NdkNativeImage.test.ets @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2024 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; -import { describe, it, expect } from '@ohos/hypium'; -import { Driver, ON } from '@ohos.UiTest'; - -const TAG = '[Sample_NdkNativeImageAPI]'; - -export default function abilityTest() { - - describe('ActsAbilityTest', () => { - /** - * 打开应用 - */ - it('StartAbility_001', 0, async (done: Function) => { - console.info(TAG, 'StartAbility_001 begin'); - let driver = Driver.create(); - let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - try { - await abilityDelegator.startAbility({ - bundleName: 'com.samples.ndknativeimage', - abilityName: 'EntryAbility' - }); - } catch (exception) { - console.info(TAG, `StartAbility_001 exception = ${JSON.stringify(exception)}`); - expect().assertFail(); - } - await driver.delayMs(10000); - done(); - console.info(TAG, 'StartAbility_001 end'); - }) - }) +/* + * Copyright (c) 2024 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { describe, it, expect } from '@ohos/hypium'; +import { Driver, ON } from '@ohos.UiTest'; + +const TAG = '[Sample_NdkNativeImageAPI]'; + +export default function abilityTest() { + + describe('ActsAbilityTest', () => { + /** + * 打开应用 + */ + it('StartAbility_001', 0, async (done: Function) => { + console.info(TAG, 'StartAbility_001 begin'); + let driver = Driver.create(); + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + try { + await abilityDelegator.startAbility({ + bundleName: 'com.samples.ndknativeimage', + abilityName: 'EntryAbility' + }); + } catch (exception) { + console.info(TAG, `StartAbility_001 exception = ${JSON.stringify(exception)}`); + expect().assertFail(); + } + await driver.delayMs(10000); + done(); + console.info(TAG, 'StartAbility_001 end'); + }) + }) } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeImage/entry/src/ohosTest/module.json5 b/code/BasicFeature/Native/NdkNativeImage/entry/src/ohosTest/module.json5 index 1f646ea03f..5f63462032 100644 --- a/code/BasicFeature/Native/NdkNativeImage/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Native/NdkNativeImage/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/BasicFeature/Native/NdkNativeImage/hvigor/hvigor-config.json5 b/code/BasicFeature/Native/NdkNativeImage/hvigor/hvigor-config.json5 index e0bd0d8269..06b2783670 100644 --- a/code/BasicFeature/Native/NdkNativeImage/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Native/NdkNativeImage/hvigor/hvigor-config.json5 @@ -1,22 +1,22 @@ -{ - "modelVersion": "5.0.0", - "dependencies": { - }, - "execution": { - // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ - // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ - // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ - // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ - }, - "nodeOptions": { - // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ - // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ - } -} +{ + "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/BasicFeature/Native/NdkNativeImage/oh-package.json5 b/code/BasicFeature/Native/NdkNativeImage/oh-package.json5 index fb70d168e1..d7622199b7 100644 --- a/code/BasicFeature/Native/NdkNativeImage/oh-package.json5 +++ b/code/BasicFeature/Native/NdkNativeImage/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * Copyright (c) 2024 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/BasicFeature/Native/NdkNativeWindow/AppScope/app.json5 b/code/BasicFeature/Native/NdkNativeWindow/AppScope/app.json5 index 291c099713..6bc912cf46 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/AppScope/app.json5 +++ b/code/BasicFeature/Native/NdkNativeWindow/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.nativewindow", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.nativewindow", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Native/NdkNativeWindow/AppScope/resources/base/element/string.json b/code/BasicFeature/Native/NdkNativeWindow/AppScope/resources/base/element/string.json index 60d4f01fbc..0baed5e08b 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Native/NdkNativeWindow/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NdkNativeWindow" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "NdkNativeWindow" + } + ] +} diff --git a/code/BasicFeature/Native/NdkNativeWindow/build-profile.json5 b/code/BasicFeature/Native/NdkNativeWindow/build-profile.json5 index 4a6f21f792..2d6762ac07 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/build-profile.json5 +++ b/code/BasicFeature/Native/NdkNativeWindow/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023-2024 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023-2024 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "runtimeOS": "OpenHarmony", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeWindow/entry/build-profile.json5 b/code/BasicFeature/Native/NdkNativeWindow/entry/build-profile.json5 index 423fe90120..d6c9f348d4 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/entry/build-profile.json5 +++ b/code/BasicFeature/Native/NdkNativeWindow/entry/build-profile.json5 @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2023 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", "armeabi-v7a", "x86_64"] - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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", "armeabi-v7a", "x86_64"] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeWindow/entry/oh-package.json5 b/code/BasicFeature/Native/NdkNativeWindow/entry/oh-package.json5 index 0186d68634..0b39ac1a9a 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/entry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkNativeWindow/entry/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": { - "libentry.so": "file:./src/main/cpp/types/libentry" - } -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} diff --git a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/cpp/CMakeLists.txt index bb49635111..1242843979 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/cpp/CMakeLists.txt +++ b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/cpp/CMakeLists.txt @@ -1,30 +1,30 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.4.1) -project(NdkNativeWindow) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) -find_library( # Sets the name of the path variable. - hilog-lib - # Specifies the name of the NDK library that - # you want CMake to locate. - hilog_ndk.z ) -find_library( # Sets the name of the path variable. - libnapi-lib - # Specifies the name of the NDK library that - # you want CMake to locate. - ace_napi.z ) - -find_library( # Sets the name of the path variable. - libace-lib - # Specifies the name of the NDK library that - # you want CMake to locate. - ace_ndk.z ) -add_library(nativerender SHARED - plugin.cpp - NativeRender.cpp - NativeImageAdaptor.cpp) - +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(NdkNativeWindow) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) +find_library( # Sets the name of the path variable. + hilog-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + hilog_ndk.z ) +find_library( # Sets the name of the path variable. + libnapi-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + ace_napi.z ) + +find_library( # Sets the name of the path variable. + libace-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + ace_ndk.z ) +add_library(nativerender SHARED + plugin.cpp + NativeRender.cpp + NativeImageAdaptor.cpp) + target_link_libraries(nativerender PUBLIC ${hilog-lib} ${libnapi-lib} ${libace-lib} libnative_buffer.so libnative_window.so libnative_image.so libEGL.so libGLESv3.so libipc_capi.so) \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/cpp/types/libentry/oh-package.json5 index 124352dc7f..8c49cae229 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,6 +1,6 @@ -{ - "name": "libentry.so", - "types": "./index.d.ts", - "version": "", - "description": "Please describe the basic information." +{ + "name": "libentry.so", + "types": "./index.d.ts", + "version": "", + "description": "Please describe the basic information." } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/ets/entryability/EntryAbility.ts index 14b525aba9..4504c55460 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2024 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 from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, 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(): 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'); - } -}; +/* + * Copyright (c) 2024 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 from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, 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(): 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/BasicFeature/Native/NdkNativeWindow/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/ets/pages/Index.ets index ff69360f91..fdcaeb0de0 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/ets/pages/Index.ets @@ -1,185 +1,185 @@ -/* - * Copyright (c) 2023 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 NativeWindowContext from "../interface/NativeWindowContext"; -const TAG = '[Sample_NativeWindowAPI]'; - -@Entry -@Component -struct Index { - @State msg: string = 'OnFrameAvailable count:' - @State frameAvailableCount: number = 0; - @State producerCacheBufferCount: number = 0; - @State cacheBufferCount: number = 3; - @State bufferQueueSize: number = 3; - @State attachedBufferCount: number = 0; - @State frameFlushedCount: number = 0; - @State frameConsumerCount: number = 0; - @State isAutoConsumer: boolean = false; - private nativeWindowContext: NativeWindowContext | undefined = undefined; - private debounceTimer: number | null = null; - - // 防抖函数 - private debounceClick( action: () => void, delay: number = 500 ) { - if (this.debounceTimer) { - clearTimeout(this.debounceTimer); - } - this.debounceTimer = setTimeout(() => { - action(); - this.debounceTimer = null; - }, delay); - } - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Row() { - Button('Change Color') - .fontSize('14fp') - .fontWeight(500) - .margin({ bottom: 24 }) - .onClick(() => { - if (this.nativeWindowContext) { - this.nativeWindowContext.DrawColor(); - } - }) - .width('40%') - Button('Change ScalingMode') - .fontSize('14fp') - .fontWeight(500) - .margin({ bottom: 24 }) - .onClick(() => { - if (this.nativeWindowContext) { - this.nativeWindowContext.ChangeScalingMode(); - } - }) - .width('50%') - } - Column() { - Row() { - XComponent({ id: 'xcomponentId', type: 'texture', libraryname: 'nativerender' }) - .margin({ bottom: 26 }) - .onLoad((nativeWindowContext) => { - this.nativeWindowContext = nativeWindowContext as NativeWindowContext; - }) - } - } - .width('512px') - .height('50%') - Button(`produce buffer count=${this.frameFlushedCount}`) - .fontSize('14fp') - .fontWeight(500) - .margin({ bottom: 24 }) - .onClick(() => { - this.debounceClick(() => { - if (this.nativeWindowContext) { - console.log(TAG, "Produce Buffer"); - if (this.nativeWindowContext.ProduceBuffer() == 0) { - this.frameFlushedCount++; - } - setTimeout("GetCount", 1000); - } - }); - - }) - .height(40) - Row() { - Button(`auto consumer=${this.isAutoConsumer}`) - .fontSize('14fp') - .fontWeight(500) - .margin({ bottom: 24 }) - .onClick(() => { - if (this.nativeWindowContext) { - this.isAutoConsumer = this.nativeWindowContext.ChangeIsAutoConsumer(); - } - }) - .height(40) - Button(`consumer buffer count=${this.frameConsumerCount}`) - .fontSize('14fp') - .fontWeight(500) - .margin({ bottom: 24 }) - .onClick(() => { - if (this.nativeWindowContext) { - console.log(TAG, "Consumer Buffer"); - if (this.nativeWindowContext.ConsumerBuffer() == 0) { - this.frameConsumerCount++; - } - setTimeout("GetCount", 1000); - } - }) - .height(40) - } - Button(`update available buffer count=${this.frameAvailableCount}`) - .fontSize('14fp') - .fontWeight(500) - .margin({ bottom: 24 }) - .onClick(() => { - if (this.nativeWindowContext) { - console.log(TAG, "GetAvailableCount"); - this.frameAvailableCount = this.nativeWindowContext.GetAvailableCount(); - } - }) - .height(40) - Button() { - Column() { - Row() { - Text(`update bufferqueuesize =${this.bufferQueueSize}`) - .fontSize('14fp') - .fontWeight(500) - .fontColor(Color.White) - .margin({ bottom: 8 }) - } - Row() { - Text(`attachedbuffer =${this.attachedBufferCount},cachebuffer=${this.cacheBufferCount}`) - .fontSize('14fp') - .fontWeight(500) - .fontColor(Color.White) - } - } - .margin({ left: 12, right: 12, top: 8, bottom: 8 }) - } - .margin({ bottom: 24 }) - .onClick(() => { - if (this.nativeWindowContext) { - this.bufferQueueSize = this.nativeWindowContext.GetBufferQueueSize(); - this.attachedBufferCount = this.nativeWindowContext.GetAttachBufferCount(); - this.cacheBufferCount = this.nativeWindowContext.GetCacheBufferCount(); - } - }) - .height(60) - Button(`attach buffer`) - .fontSize('14fp') - .fontWeight(500) - .margin({ bottom: 24 }) - .onClick(() => { - if (this.nativeWindowContext) { - this.nativeWindowContext.AttachBuffer(); - } - }) - .height(40) - Button(`dettach buffer`) - .fontSize('14fp') - .fontWeight(500) - .margin({ bottom: 24 }) - .onClick(() => { - if (this.nativeWindowContext) { - this.nativeWindowContext.DettachBuffer(); - } - }) - .height(40) - } - .width('100%') - .height('100%') - } -} +/* + * Copyright (c) 2023 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 NativeWindowContext from "../interface/NativeWindowContext"; +const TAG = '[Sample_NativeWindowAPI]'; + +@Entry +@Component +struct Index { + @State msg: string = 'OnFrameAvailable count:' + @State frameAvailableCount: number = 0; + @State producerCacheBufferCount: number = 0; + @State cacheBufferCount: number = 3; + @State bufferQueueSize: number = 3; + @State attachedBufferCount: number = 0; + @State frameFlushedCount: number = 0; + @State frameConsumerCount: number = 0; + @State isAutoConsumer: boolean = false; + private nativeWindowContext: NativeWindowContext | undefined = undefined; + private debounceTimer: number | null = null; + + // 防抖函数 + private debounceClick( action: () => void, delay: number = 500 ) { + if (this.debounceTimer) { + clearTimeout(this.debounceTimer); + } + this.debounceTimer = setTimeout(() => { + action(); + this.debounceTimer = null; + }, delay); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Row() { + Button('Change Color') + .fontSize('14fp') + .fontWeight(500) + .margin({ bottom: 24 }) + .onClick(() => { + if (this.nativeWindowContext) { + this.nativeWindowContext.DrawColor(); + } + }) + .width('40%') + Button('Change ScalingMode') + .fontSize('14fp') + .fontWeight(500) + .margin({ bottom: 24 }) + .onClick(() => { + if (this.nativeWindowContext) { + this.nativeWindowContext.ChangeScalingMode(); + } + }) + .width('50%') + } + Column() { + Row() { + XComponent({ id: 'xcomponentId', type: 'texture', libraryname: 'nativerender' }) + .margin({ bottom: 26 }) + .onLoad((nativeWindowContext) => { + this.nativeWindowContext = nativeWindowContext as NativeWindowContext; + }) + } + } + .width('512px') + .height('50%') + Button(`produce buffer count=${this.frameFlushedCount}`) + .fontSize('14fp') + .fontWeight(500) + .margin({ bottom: 24 }) + .onClick(() => { + this.debounceClick(() => { + if (this.nativeWindowContext) { + console.log(TAG, "Produce Buffer"); + if (this.nativeWindowContext.ProduceBuffer() == 0) { + this.frameFlushedCount++; + } + setTimeout("GetCount", 1000); + } + }); + + }) + .height(40) + Row() { + Button(`auto consumer=${this.isAutoConsumer}`) + .fontSize('14fp') + .fontWeight(500) + .margin({ bottom: 24 }) + .onClick(() => { + if (this.nativeWindowContext) { + this.isAutoConsumer = this.nativeWindowContext.ChangeIsAutoConsumer(); + } + }) + .height(40) + Button(`consumer buffer count=${this.frameConsumerCount}`) + .fontSize('14fp') + .fontWeight(500) + .margin({ bottom: 24 }) + .onClick(() => { + if (this.nativeWindowContext) { + console.log(TAG, "Consumer Buffer"); + if (this.nativeWindowContext.ConsumerBuffer() == 0) { + this.frameConsumerCount++; + } + setTimeout("GetCount", 1000); + } + }) + .height(40) + } + Button(`update available buffer count=${this.frameAvailableCount}`) + .fontSize('14fp') + .fontWeight(500) + .margin({ bottom: 24 }) + .onClick(() => { + if (this.nativeWindowContext) { + console.log(TAG, "GetAvailableCount"); + this.frameAvailableCount = this.nativeWindowContext.GetAvailableCount(); + } + }) + .height(40) + Button() { + Column() { + Row() { + Text(`update bufferqueuesize =${this.bufferQueueSize}`) + .fontSize('14fp') + .fontWeight(500) + .fontColor(Color.White) + .margin({ bottom: 8 }) + } + Row() { + Text(`attachedbuffer =${this.attachedBufferCount},cachebuffer=${this.cacheBufferCount}`) + .fontSize('14fp') + .fontWeight(500) + .fontColor(Color.White) + } + } + .margin({ left: 12, right: 12, top: 8, bottom: 8 }) + } + .margin({ bottom: 24 }) + .onClick(() => { + if (this.nativeWindowContext) { + this.bufferQueueSize = this.nativeWindowContext.GetBufferQueueSize(); + this.attachedBufferCount = this.nativeWindowContext.GetAttachBufferCount(); + this.cacheBufferCount = this.nativeWindowContext.GetCacheBufferCount(); + } + }) + .height(60) + Button(`attach buffer`) + .fontSize('14fp') + .fontWeight(500) + .margin({ bottom: 24 }) + .onClick(() => { + if (this.nativeWindowContext) { + this.nativeWindowContext.AttachBuffer(); + } + }) + .height(40) + Button(`dettach buffer`) + .fontSize('14fp') + .fontWeight(500) + .margin({ bottom: 24 }) + .onClick(() => { + if (this.nativeWindowContext) { + this.nativeWindowContext.DettachBuffer(); + } + }) + .height(40) + } + .width('100%') + .height('100%') + } +} diff --git a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/module.json5 b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/module.json5 index 1354ce3a83..b2099192e9 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/module.json5 +++ b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Native/NdkNativeWindow/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeWindow/entry/src/ohosTest/module.json5 b/code/BasicFeature/Native/NdkNativeWindow/entry/src/ohosTest/module.json5 index 7e44e83cf9..e6a499c49e 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Native/NdkNativeWindow/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/Native/NdkNativeWindow/hvigor/hvigor-config.json5 b/code/BasicFeature/Native/NdkNativeWindow/hvigor/hvigor-config.json5 index 9576f51e28..b38f010922 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Native/NdkNativeWindow/hvigor/hvigor-config.json5 @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2023-2024 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": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } +/* + * Copyright (c) 2023-2024 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": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeWindow/oh-package.json5 b/code/BasicFeature/Native/NdkNativeWindow/oh-package.json5 index 155173103a..b0052ea878 100644 --- a/code/BasicFeature/Native/NdkNativeWindow/oh-package.json5 +++ b/code/BasicFeature/Native/NdkNativeWindow/oh-package.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2023-2024 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", - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.11" - }, - "author": "", - "name": "ndknativewindow", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} +/* + * Copyright (c) 2023-2024 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", + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.11" + }, + "author": "", + "name": "ndknativewindow", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkOpenGL/AppScope/app.json5 b/code/BasicFeature/Native/NdkOpenGL/AppScope/app.json5 index f0cb834a0d..f6876c43a8 100644 --- a/code/BasicFeature/Native/NdkOpenGL/AppScope/app.json5 +++ b/code/BasicFeature/Native/NdkOpenGL/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.ndkopengl", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.ndkopengl", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Native/NdkOpenGL/AppScope/resources/base/element/string.json b/code/BasicFeature/Native/NdkOpenGL/AppScope/resources/base/element/string.json index adcddd67a3..d93de68f4f 100644 --- a/code/BasicFeature/Native/NdkOpenGL/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Native/NdkOpenGL/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NdkOpenGL" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "NdkOpenGL" + } + ] +} diff --git a/code/BasicFeature/Native/NdkOpenGL/build-profile.json5 b/code/BasicFeature/Native/NdkOpenGL/build-profile.json5 index e521599d36..11ce79f476 100644 --- a/code/BasicFeature/Native/NdkOpenGL/build-profile.json5 +++ b/code/BasicFeature/Native/NdkOpenGL/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/build-profile.json5 b/code/BasicFeature/Native/NdkOpenGL/entry/build-profile.json5 index 012ddb732c..378d841968 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/build-profile.json5 +++ b/code/BasicFeature/Native/NdkOpenGL/entry/build-profile.json5 @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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": "", - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": "", + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/oh-package.json5 b/code/BasicFeature/Native/NdkOpenGL/entry/oh-package.json5 index f2c2bfc9a0..2bb0dcbd76 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkOpenGL/entry/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@types/libtriangles_napi.so": "file:./src/main/cpp/type/libentry" - }, - "author": "AlgoIdeas", - "name": "entry", - "description": "Please describe the basic information.", - "main": "1.0.0", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@types/libtriangles_napi.so": "file:./src/main/cpp/type/libentry" + }, + "author": "AlgoIdeas", + "name": "entry", + "description": "Please describe the basic information.", + "main": "1.0.0", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/CMakeLists.txt index 89dd4165cd..97bd6d04c1 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/CMakeLists.txt +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/CMakeLists.txt @@ -1,46 +1,46 @@ -# -# Copyright (c) 2023 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. -# - -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.4.1) - -# project -project(Tetrahedron) - -set(NATIVE_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -# include directory -include_directories(${NATIVE_ROOT_PATH} - ${NATIVE_ROOT_PATH}/include - ${NATIVE_ROOT_PATH}/include/util) - -# build shared library -add_library(tetrahedron_napi SHARED - module.cpp - app_napi.cpp - tetrahedron.cpp - napi_manager.cpp - napi_util.cpp) - -# link OpenHarmony native library (Use OpenGL) -target_link_libraries(tetrahedron_napi PUBLIC EGL) -target_link_libraries(tetrahedron_napi PUBLIC GLESv3) -target_link_libraries(tetrahedron_napi PUBLIC hilog_ndk.z) -target_link_libraries(tetrahedron_napi PUBLIC ace_ndk.z) -target_link_libraries(tetrahedron_napi PUBLIC ace_napi.z) -target_link_libraries(tetrahedron_napi PUBLIC libc++.a) -target_link_libraries(tetrahedron_napi PUBLIC z) -target_link_libraries(tetrahedron_napi PUBLIC uv) -target_link_libraries(tetrahedron_napi PUBLIC libace_napi.z.so) +# +# Copyright (c) 2023 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. +# + +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) + +# project +project(Tetrahedron) + +set(NATIVE_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +# include directory +include_directories(${NATIVE_ROOT_PATH} + ${NATIVE_ROOT_PATH}/include + ${NATIVE_ROOT_PATH}/include/util) + +# build shared library +add_library(tetrahedron_napi SHARED + module.cpp + app_napi.cpp + tetrahedron.cpp + napi_manager.cpp + napi_util.cpp) + +# link OpenHarmony native library (Use OpenGL) +target_link_libraries(tetrahedron_napi PUBLIC EGL) +target_link_libraries(tetrahedron_napi PUBLIC GLESv3) +target_link_libraries(tetrahedron_napi PUBLIC hilog_ndk.z) +target_link_libraries(tetrahedron_napi PUBLIC ace_ndk.z) +target_link_libraries(tetrahedron_napi PUBLIC ace_napi.z) +target_link_libraries(tetrahedron_napi PUBLIC libc++.a) +target_link_libraries(tetrahedron_napi PUBLIC z) +target_link_libraries(tetrahedron_napi PUBLIC uv) +target_link_libraries(tetrahedron_napi PUBLIC libace_napi.z.so) diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/tetrahedron.h b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/tetrahedron.h index 1d533b9ec1..87c10a04dd 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/tetrahedron.h +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/tetrahedron.h @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2023 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. - */ - -#ifndef TETRAHEDRON_H -#define TETRAHEDRON_H - -#include -#include -#include - -#include -#include - -#define TRIANGLES_POINT 3 -#define TETRAHEDRON_POINT 12 - -class Tetrahedron { -public: - explicit Tetrahedron(std::string& id) : id(id) {}; - int32_t Init(void* windowHandle, int windowWidth, int windowHeight); - void Update(float angleXOffset, float angleYOffset); - float GetAngleX(void); - float GetAngleY(void); - int32_t Quit(void); - -public: - std::string id; - -private: - GLuint LoadShader(GLenum type, const char *shaderSrc); - GLuint CreateProgram(const char *vertexShader, const char *fragShader); - - EGLNativeWindowType mEglWindow; - EGLDisplay mEGLDisplay = EGL_NO_DISPLAY; - EGLConfig mEGLConfig = nullptr; - EGLContext mEGLContext = EGL_NO_CONTEXT; - EGLContext mSharedEGLContext = EGL_NO_CONTEXT; - EGLSurface mEGLSurface = nullptr; - GLuint mProgramHandle; - float angleX = 30.0; /* default X angle */ - float angleY = 45.0; /* default Y angle */ - - GLint mRotationLocation; - GLint mTranslationLocation; - GLint mMoveOriginLocation; -}; - -#endif /* TETRAHEDRON_H */ +/* + * Copyright (c) 2023 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. + */ + +#ifndef TETRAHEDRON_H +#define TETRAHEDRON_H + +#include +#include +#include + +#include +#include + +#define TRIANGLES_POINT 3 +#define TETRAHEDRON_POINT 12 + +class Tetrahedron { +public: + explicit Tetrahedron(std::string& id) : id(id) {}; + int32_t Init(void* windowHandle, int windowWidth, int windowHeight); + void Update(float angleXOffset, float angleYOffset); + float GetAngleX(void); + float GetAngleY(void); + int32_t Quit(void); + +public: + std::string id; + +private: + GLuint LoadShader(GLenum type, const char *shaderSrc); + GLuint CreateProgram(const char *vertexShader, const char *fragShader); + + EGLNativeWindowType mEglWindow; + EGLDisplay mEGLDisplay = EGL_NO_DISPLAY; + EGLConfig mEGLConfig = nullptr; + EGLContext mEGLContext = EGL_NO_CONTEXT; + EGLContext mSharedEGLContext = EGL_NO_CONTEXT; + EGLSurface mEGLSurface = nullptr; + GLuint mProgramHandle; + float angleX = 30.0; /* default X angle */ + float angleY = 45.0; /* default Y angle */ + + GLint mRotationLocation; + GLint mTranslationLocation; + GLint mMoveOriginLocation; +}; + +#endif /* TETRAHEDRON_H */ diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/util/log.h b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/util/log.h index 774fe5979c..05e5df65d7 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/util/log.h +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/util/log.h @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2023 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. - */ - -#ifndef LOG_H -#define LOG_H - -#include - -#ifndef LOGI -#define LOGI(...) ((void)OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "[OpenGL]", __VA_ARGS__)) -#endif - -#ifndef LOGD -#define LOGD(...) ((void)OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN, "[OpenGL]", __VA_ARGS__)) -#endif - -#ifndef LOGW -#define LOGW(...) ((void)OH_LOG_Print(LOG_APP, LOG_WARN, LOG_DOMAIN, "[OpenGL]", __VA_ARGS__)) -#endif - -#ifndef LOGE -#define LOGE(...) ((void)OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_DOMAIN, "[OpenGL]", __VA_ARGS__)) -#endif +/* + * Copyright (c) 2023 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. + */ + +#ifndef LOG_H +#define LOG_H + +#include + +#ifndef LOGI +#define LOGI(...) ((void)OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "[OpenGL]", __VA_ARGS__)) +#endif + +#ifndef LOGD +#define LOGD(...) ((void)OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN, "[OpenGL]", __VA_ARGS__)) +#endif + +#ifndef LOGW +#define LOGW(...) ((void)OH_LOG_Print(LOG_APP, LOG_WARN, LOG_DOMAIN, "[OpenGL]", __VA_ARGS__)) +#endif + +#ifndef LOGE +#define LOGE(...) ((void)OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_DOMAIN, "[OpenGL]", __VA_ARGS__)) +#endif #endif // _LOG_H_ \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/util/napi_manager.h b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/util/napi_manager.h index 0f8176d991..de81eee3e1 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/util/napi_manager.h +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/include/util/napi_manager.h @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2023 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. - */ - -#ifndef NAPI_MANAGER_H -#define NAPI_MANAGER_H - -#include -#include - -#include -#include -#include - -#include "native_common.h" -#include "app_napi.h" - -class NapiManager { -public: - ~NapiManager() {} - - static NapiManager* GetInstance() - { - return &NapiManager::manager_; - } - - static napi_value GetContext(napi_env env, napi_callback_info info); - - /**APP Lifecycle**/ - static napi_value NapiOnCreate(napi_env env, napi_callback_info info); - static napi_value NapiOnShow(napi_env env, napi_callback_info info); - static napi_value NapiOnHide(napi_env env, napi_callback_info info); - static napi_value NapiOnDestroy(napi_env env, napi_callback_info info); - - void OnCreateNative(napi_env env, uv_loop_t* loop); - void OnShowNative(); - void OnHideNative(); - void OnDestroyNative(); - - /**JS Page Lifecycle**/ - static napi_value NapiOnPageShow(napi_env env, napi_callback_info info); - static napi_value NapiOnPageHide(napi_env env, napi_callback_info info); - - void OnPageShowNative(); - void OnPageHideNative(); - - OH_NativeXComponent* GetNativeXComponent(std::string& id); - void SetNativeXComponent(std::string& id, OH_NativeXComponent* nativeXComponent); - AppNapi* GetApp(std::string& id); - -public: - // Napi export - bool Export(napi_env env, napi_value exports); - -public: - napi_env mainEnv_ = nullptr; - uv_loop_t* mainLoop_ = nullptr; - uv_async_t mainOnMessageSignal_ {}; - -private: - static void MainOnMessage(const uv_async_t* req); - static NapiManager manager_; - - std::string id_; - std::unordered_map nativeXComponentMap_; - std::unordered_map appNapiMap_; -}; - -#endif // PLUGIN_MANAGER_H +/* + * Copyright (c) 2023 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. + */ + +#ifndef NAPI_MANAGER_H +#define NAPI_MANAGER_H + +#include +#include + +#include +#include +#include + +#include "native_common.h" +#include "app_napi.h" + +class NapiManager { +public: + ~NapiManager() {} + + static NapiManager* GetInstance() + { + return &NapiManager::manager_; + } + + static napi_value GetContext(napi_env env, napi_callback_info info); + + /**APP Lifecycle**/ + static napi_value NapiOnCreate(napi_env env, napi_callback_info info); + static napi_value NapiOnShow(napi_env env, napi_callback_info info); + static napi_value NapiOnHide(napi_env env, napi_callback_info info); + static napi_value NapiOnDestroy(napi_env env, napi_callback_info info); + + void OnCreateNative(napi_env env, uv_loop_t* loop); + void OnShowNative(); + void OnHideNative(); + void OnDestroyNative(); + + /**JS Page Lifecycle**/ + static napi_value NapiOnPageShow(napi_env env, napi_callback_info info); + static napi_value NapiOnPageHide(napi_env env, napi_callback_info info); + + void OnPageShowNative(); + void OnPageHideNative(); + + OH_NativeXComponent* GetNativeXComponent(std::string& id); + void SetNativeXComponent(std::string& id, OH_NativeXComponent* nativeXComponent); + AppNapi* GetApp(std::string& id); + +public: + // Napi export + bool Export(napi_env env, napi_value exports); + +public: + napi_env mainEnv_ = nullptr; + uv_loop_t* mainLoop_ = nullptr; + uv_async_t mainOnMessageSignal_ {}; + +private: + static void MainOnMessage(const uv_async_t* req); + static NapiManager manager_; + + std::string id_; + std::unordered_map nativeXComponentMap_; + std::unordered_map appNapiMap_; +}; + +#endif // PLUGIN_MANAGER_H diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/tetrahedron.cpp b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/tetrahedron.cpp index 828f60eb75..c1e077cb3c 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/tetrahedron.cpp +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/tetrahedron.cpp @@ -1,349 +1,349 @@ -/* - * Copyright (c) 2023 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 -#include -#include -#include "log.h" -#include "tetrahedron.h" - -static char g_vertexShader[] = - "attribute vec4 a_pos;\n" - "attribute vec4 a_color;\n" - "attribute vec4 a_normal;\n" - "uniform vec3 u_lightColor;\n" - "uniform vec3 u_lightDirection;\n" - "uniform mat4 a_mx;\n" - "uniform mat4 a_my;\n" - "varying vec4 v_color;\n" - "void main() {\n" - " float radian = radians(30.0);\n" - " float cos = cos(radian);\n" - " float sin = sin(radian);\n" - " gl_Position = a_mx * a_my * vec4(a_pos.x, a_pos.y, a_pos.z, 1.0);\n" - " vec3 normal = normalize((a_mx * a_my * a_normal).xyz);\n" - " float dot = max(dot(u_lightDirection, normal), 0.0);\n" - " vec3 reflectedLight = u_lightColor * a_color.rgb * dot;\n" - " v_color = vec4(reflectedLight, a_color.a);\n" - "}\n\0"; - -static char g_fragmentShader[] = - "precision mediump float;\n" - "varying vec4 v_color;\n" - "void main() {\n" - " gl_FragColor = v_color;\n" - "}\n\0"; - -/* 创建顶点位置数据数组vertexData */ -static float g_vertexData[] = { - -0.75, -0.50, -0.43, 0.75, -0.50, -0.43, 0.00, -0.50, 0.87, 0.75, -0.50, -0.43, - 0.00, -0.50, 0.87, 0.00, 1.00, 0.00, 0.00, -0.50, 0.87, 0.00, 1.00, 0.00, - -0.75, -0.50, -0.43, 0.00, 1.00, 0.00, -0.75, -0.50, -0.43, 0.75, -0.50, -0.43, -}; - -/* 创建顶点颜色数组colorData */ -static float g_colorData[] = { - 1, 0, 0, 1, 0, 0, 1, 0, 0, /* 红色——面1 */ - 1, 0, 0, 1, 0, 0, 1, 0, 0, /* 红色——面2 */ - 1, 0, 0, 1, 0, 0, 1, 0, 0, /* 红色——面3 */ - 1, 0, 0, 1, 0, 0, 1, 0, 0 /* 红色——面4 */ -}; - -/* 顶点法向量数组normalData */ -static float g_normalData[] = { - 0.00, -1.00, 0.00, 0.00, -1.00, 0.00, 0.00, -1.00, 0.00, -0.83, -0.28, -0.48, - -0.83, -0.28, -0.48, -0.83, -0.28, -0.48, -0.83, 0.28, 0.48, -0.83, 0.28, 0.48, - -0.83, 0.28, 0.48, 0.00, -0.28, 0.96, 0.00, -0.28, 0.96, 0.00, -0.28, 0.96, -}; - -namespace { - EGLConfig getConfig(int version, EGLDisplay eglDisplay) - { - int attribList[] = { - EGL_SURFACE_TYPE, - EGL_WINDOW_BIT, - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_RENDERABLE_TYPE, - EGL_OPENGL_ES2_BIT, - EGL_NONE - }; - EGLConfig configs = NULL; - int configsNum; - - if (!eglChooseConfig(eglDisplay, attribList, &configs, 1, &configsNum)) { - LOGE("eglChooseConfig ERROR"); - return NULL; - } - - return configs; - } - - void enableVertexAttrib(GLuint index, float *data, int32_t len) - { - GLuint buffer; - glGenBuffers(1, &buffer); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, len, data, GL_STATIC_DRAW); - glVertexAttribPointer(index, TRIANGLES_POINT, GL_FLOAT, GL_FALSE, 0, 0); - glEnableVertexAttribArray(index); - return; - } -} - -GLuint Tetrahedron::LoadShader(GLenum type, const char *shaderSrc) -{ - GLuint shader; - GLint compiled; - - shader = glCreateShader(type); - if (shader == 0) { - LOGE("LoadShader shader error"); - return 0; - } - - glShaderSource(shader, 1, &shaderSrc, nullptr); - glCompileShader(shader); - - glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); - - if (!compiled) { - GLint infoLen = 0; - glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen); - - if (infoLen > 1) { - std::string infoLog(infoLen, '\0'); - glGetShaderInfoLog(shader, infoLen, nullptr, (GLchar *)&infoLog); - LOGE("Error compiling shader:%{public}s\n", infoLog.c_str()); - } - - glDeleteShader(shader); - return 0; - } - - return shader; -} - -GLuint Tetrahedron::CreateProgram(const char *vertexShader, const char *fragShader) -{ - GLuint vertex; - GLuint fragment; - GLuint program; - GLint linked; - - vertex = LoadShader(GL_VERTEX_SHADER, vertexShader); - if (vertex == 0) { - LOGE("LoadShader: vertexShader error"); - return 0; - } - - fragment = LoadShader(GL_FRAGMENT_SHADER, fragShader); - if (fragment == 0) { - LOGE("LoadShader: fragShader error"); - glDeleteShader(vertex); - return 0; - } - - program = glCreateProgram(); - if (program == 0) { - LOGE("CreateProgram program error"); - glDeleteShader(vertex); - glDeleteShader(fragment); - return 0; - } - - glAttachShader(program, vertex); - glAttachShader(program, fragment); - glLinkProgram(program); - glGetProgramiv(program, GL_LINK_STATUS, &linked); - - if (!linked) { - LOGE("CreateProgram linked error"); - GLint infoLen = 0; - glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLen); - if (infoLen > 1) { - std::string infoLog(infoLen, '\0'); - glGetProgramInfoLog(program, infoLen, nullptr, (GLchar *)&infoLog); - LOGE("Error linking program:%{public}s\n", infoLog.c_str()); - } - glDeleteShader(vertex); - glDeleteShader(fragment); - glDeleteProgram(program); - return 0; - } - glDeleteShader(vertex); - glDeleteShader(fragment); - - return program; -} - -int32_t Tetrahedron::Init(void *window, int32_t width, int32_t height) -{ - LOGI("Init window = %{public}p, w = %{public}d, h = %{public}d.", window, width, height); - mEglWindow = reinterpret_cast(window); - - mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (mEGLDisplay == EGL_NO_DISPLAY) { - LOGE("unable to get EGL display."); - return -1; - } - - EGLint eglMajVers, eglMinVers; - if (!eglInitialize(mEGLDisplay, &eglMajVers, &eglMinVers)) { - mEGLDisplay = EGL_NO_DISPLAY; - LOGE("unable to initialize display"); - return -1; - } - - int version = 3; - mEGLConfig = getConfig(version, mEGLDisplay); - if (mEGLConfig == nullptr) { - LOGE("GLContextInit config ERROR"); - return -1; - } - - EGLint winAttribs[] = {EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR, EGL_NONE}; - if (mEglWindow) { - mEGLSurface = eglCreateWindowSurface(mEGLDisplay, mEGLConfig, mEglWindow, winAttribs); - if (mEGLSurface == nullptr) { - LOGE("eglCreateContext eglSurface is null"); - return -1; - } - } - - /* Create EGLContext from */ - int attrib3_list[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - - mEGLContext = eglCreateContext(mEGLDisplay, mEGLConfig, mSharedEGLContext, attrib3_list); - if (!eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext)) { - LOGE("eglMakeCurrent error = %{public}d", eglGetError()); - } - - mProgramHandle = CreateProgram(g_vertexShader, g_fragmentShader); - if (!mProgramHandle) { - LOGE("Could not create CreateProgram"); - return -1; - } - - LOGI("Init success."); - - return 0; -} - -void Tetrahedron::Update(float angleXOffset, float angleYOffset) -{ - const float pi = 3.141592; - - glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - glUseProgram(mProgramHandle); - - GLint aPos = glGetAttribLocation(mProgramHandle, "a_pos"); - GLint aColor = glGetAttribLocation(mProgramHandle, "a_color"); - GLint aNormal = glGetAttribLocation(mProgramHandle, "a_normal"); - GLint uLightColor = glGetUniformLocation(mProgramHandle, "u_lightColor"); - GLint uLightDirection = glGetUniformLocation(mProgramHandle, "u_lightDirection"); - GLint aMx = glGetUniformLocation(mProgramHandle, "a_mx"); - GLint aMy = glGetUniformLocation(mProgramHandle, "a_my"); - - angleX = angleXOffset; - angleY = angleYOffset; - - /* y轴旋转度 */ - float radianY = (angleY * pi) / 180.0; - float cosY = cosf(radianY); - float sinY = sinf(radianY); - float myArr[] = { - cosY, 0, -sinY, 0, - 0, 1, 0, 0, - sinY, 0, cosY, 0, - 0, 0, 0, 1 - }; - - glUniformMatrix4fv(aMy, 1, false, myArr); - - /* x轴旋转度 */ - float radianX = (angleX * pi) / 180.0; - float cosX = cosf(radianX); - float sinX = sinf(radianX); - float mxArr[] = { - 1, 0, 0, 0, 0, cosX, -sinX, 0, 0, sinX, cosX, 0, 0, 0, 0, 1 - }; - - glUniformMatrix4fv(aMx, 1, false, mxArr); - - /* 给平行光传入颜色和方向数据,RGB(1,1,1),单位向量(x,y,z) */ - glUniform3f(uLightColor, 1.0, 1.0, 1.0); - - /* 保证向量(x,y,z)的长度为1,即单位向量 */ - float x = 2.0 / sqrt(15); - float y = 2.0 / sqrt(15); - float z = 3.0 / sqrt(15); - - glUniform3f(uLightDirection, x, -y, z); - - /* 创建缓冲区buffer,传入顶点位置数据g_vertexData */ - enableVertexAttrib(aPos, g_vertexData, sizeof(g_vertexData)); - enableVertexAttrib(aNormal, g_normalData, sizeof(g_normalData)); - /* 创建缓冲区colorBuffer,传入顶点颜色数据g_colorData */ - enableVertexAttrib(aColor, g_colorData, sizeof(g_colorData)); - - /* 执行绘制之前,一定要开启深度测试,以免颜色混乱 */ - glEnable(GL_DEPTH_TEST); - - /* 执行绘制并更新 */ - glDrawArrays(GL_TRIANGLES, 0, TETRAHEDRON_POINT); - eglSwapBuffers(mEGLDisplay, mEGLSurface); -} - -float Tetrahedron::GetAngleX() -{ - return angleX; -} - -float Tetrahedron::GetAngleY() -{ - return angleY; -} - -int32_t Tetrahedron::Quit(void) -{ - EGLBoolean ret = eglDestroySurface(mEGLDisplay, mEGLSurface); - if (!ret) { - LOGW("eglDestroySurface failure."); - } - - ret = eglDestroyContext(mEGLDisplay, mEGLContext); - if (!ret) { - LOGW("eglDestroyContext failure."); - } - - ret = eglTerminate(mEGLDisplay); - if (!ret) { - LOGW("eglTerminate failure."); - } - - mEGLSurface = NULL; - mEGLContext = NULL; - mEGLDisplay = NULL; - - LOGE("Quit success."); - return 0; -} +/* + * Copyright (c) 2023 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 +#include +#include +#include "log.h" +#include "tetrahedron.h" + +static char g_vertexShader[] = + "attribute vec4 a_pos;\n" + "attribute vec4 a_color;\n" + "attribute vec4 a_normal;\n" + "uniform vec3 u_lightColor;\n" + "uniform vec3 u_lightDirection;\n" + "uniform mat4 a_mx;\n" + "uniform mat4 a_my;\n" + "varying vec4 v_color;\n" + "void main() {\n" + " float radian = radians(30.0);\n" + " float cos = cos(radian);\n" + " float sin = sin(radian);\n" + " gl_Position = a_mx * a_my * vec4(a_pos.x, a_pos.y, a_pos.z, 1.0);\n" + " vec3 normal = normalize((a_mx * a_my * a_normal).xyz);\n" + " float dot = max(dot(u_lightDirection, normal), 0.0);\n" + " vec3 reflectedLight = u_lightColor * a_color.rgb * dot;\n" + " v_color = vec4(reflectedLight, a_color.a);\n" + "}\n\0"; + +static char g_fragmentShader[] = + "precision mediump float;\n" + "varying vec4 v_color;\n" + "void main() {\n" + " gl_FragColor = v_color;\n" + "}\n\0"; + +/* 创建顶点位置数据数组vertexData */ +static float g_vertexData[] = { + -0.75, -0.50, -0.43, 0.75, -0.50, -0.43, 0.00, -0.50, 0.87, 0.75, -0.50, -0.43, + 0.00, -0.50, 0.87, 0.00, 1.00, 0.00, 0.00, -0.50, 0.87, 0.00, 1.00, 0.00, + -0.75, -0.50, -0.43, 0.00, 1.00, 0.00, -0.75, -0.50, -0.43, 0.75, -0.50, -0.43, +}; + +/* 创建顶点颜色数组colorData */ +static float g_colorData[] = { + 1, 0, 0, 1, 0, 0, 1, 0, 0, /* 红色——面1 */ + 1, 0, 0, 1, 0, 0, 1, 0, 0, /* 红色——面2 */ + 1, 0, 0, 1, 0, 0, 1, 0, 0, /* 红色——面3 */ + 1, 0, 0, 1, 0, 0, 1, 0, 0 /* 红色——面4 */ +}; + +/* 顶点法向量数组normalData */ +static float g_normalData[] = { + 0.00, -1.00, 0.00, 0.00, -1.00, 0.00, 0.00, -1.00, 0.00, -0.83, -0.28, -0.48, + -0.83, -0.28, -0.48, -0.83, -0.28, -0.48, -0.83, 0.28, 0.48, -0.83, 0.28, 0.48, + -0.83, 0.28, 0.48, 0.00, -0.28, 0.96, 0.00, -0.28, 0.96, 0.00, -0.28, 0.96, +}; + +namespace { + EGLConfig getConfig(int version, EGLDisplay eglDisplay) + { + int attribList[] = { + EGL_SURFACE_TYPE, + EGL_WINDOW_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_RENDERABLE_TYPE, + EGL_OPENGL_ES2_BIT, + EGL_NONE + }; + EGLConfig configs = NULL; + int configsNum; + + if (!eglChooseConfig(eglDisplay, attribList, &configs, 1, &configsNum)) { + LOGE("eglChooseConfig ERROR"); + return NULL; + } + + return configs; + } + + void enableVertexAttrib(GLuint index, float *data, int32_t len) + { + GLuint buffer; + glGenBuffers(1, &buffer); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glBufferData(GL_ARRAY_BUFFER, len, data, GL_STATIC_DRAW); + glVertexAttribPointer(index, TRIANGLES_POINT, GL_FLOAT, GL_FALSE, 0, 0); + glEnableVertexAttribArray(index); + return; + } +} + +GLuint Tetrahedron::LoadShader(GLenum type, const char *shaderSrc) +{ + GLuint shader; + GLint compiled; + + shader = glCreateShader(type); + if (shader == 0) { + LOGE("LoadShader shader error"); + return 0; + } + + glShaderSource(shader, 1, &shaderSrc, nullptr); + glCompileShader(shader); + + glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); + + if (!compiled) { + GLint infoLen = 0; + glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen); + + if (infoLen > 1) { + std::string infoLog(infoLen, '\0'); + glGetShaderInfoLog(shader, infoLen, nullptr, (GLchar *)&infoLog); + LOGE("Error compiling shader:%{public}s\n", infoLog.c_str()); + } + + glDeleteShader(shader); + return 0; + } + + return shader; +} + +GLuint Tetrahedron::CreateProgram(const char *vertexShader, const char *fragShader) +{ + GLuint vertex; + GLuint fragment; + GLuint program; + GLint linked; + + vertex = LoadShader(GL_VERTEX_SHADER, vertexShader); + if (vertex == 0) { + LOGE("LoadShader: vertexShader error"); + return 0; + } + + fragment = LoadShader(GL_FRAGMENT_SHADER, fragShader); + if (fragment == 0) { + LOGE("LoadShader: fragShader error"); + glDeleteShader(vertex); + return 0; + } + + program = glCreateProgram(); + if (program == 0) { + LOGE("CreateProgram program error"); + glDeleteShader(vertex); + glDeleteShader(fragment); + return 0; + } + + glAttachShader(program, vertex); + glAttachShader(program, fragment); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &linked); + + if (!linked) { + LOGE("CreateProgram linked error"); + GLint infoLen = 0; + glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) { + std::string infoLog(infoLen, '\0'); + glGetProgramInfoLog(program, infoLen, nullptr, (GLchar *)&infoLog); + LOGE("Error linking program:%{public}s\n", infoLog.c_str()); + } + glDeleteShader(vertex); + glDeleteShader(fragment); + glDeleteProgram(program); + return 0; + } + glDeleteShader(vertex); + glDeleteShader(fragment); + + return program; +} + +int32_t Tetrahedron::Init(void *window, int32_t width, int32_t height) +{ + LOGI("Init window = %{public}p, w = %{public}d, h = %{public}d.", window, width, height); + mEglWindow = reinterpret_cast(window); + + mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (mEGLDisplay == EGL_NO_DISPLAY) { + LOGE("unable to get EGL display."); + return -1; + } + + EGLint eglMajVers, eglMinVers; + if (!eglInitialize(mEGLDisplay, &eglMajVers, &eglMinVers)) { + mEGLDisplay = EGL_NO_DISPLAY; + LOGE("unable to initialize display"); + return -1; + } + + int version = 3; + mEGLConfig = getConfig(version, mEGLDisplay); + if (mEGLConfig == nullptr) { + LOGE("GLContextInit config ERROR"); + return -1; + } + + EGLint winAttribs[] = {EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR, EGL_NONE}; + if (mEglWindow) { + mEGLSurface = eglCreateWindowSurface(mEGLDisplay, mEGLConfig, mEglWindow, winAttribs); + if (mEGLSurface == nullptr) { + LOGE("eglCreateContext eglSurface is null"); + return -1; + } + } + + /* Create EGLContext from */ + int attrib3_list[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + + mEGLContext = eglCreateContext(mEGLDisplay, mEGLConfig, mSharedEGLContext, attrib3_list); + if (!eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext)) { + LOGE("eglMakeCurrent error = %{public}d", eglGetError()); + } + + mProgramHandle = CreateProgram(g_vertexShader, g_fragmentShader); + if (!mProgramHandle) { + LOGE("Could not create CreateProgram"); + return -1; + } + + LOGI("Init success."); + + return 0; +} + +void Tetrahedron::Update(float angleXOffset, float angleYOffset) +{ + const float pi = 3.141592; + + glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + glUseProgram(mProgramHandle); + + GLint aPos = glGetAttribLocation(mProgramHandle, "a_pos"); + GLint aColor = glGetAttribLocation(mProgramHandle, "a_color"); + GLint aNormal = glGetAttribLocation(mProgramHandle, "a_normal"); + GLint uLightColor = glGetUniformLocation(mProgramHandle, "u_lightColor"); + GLint uLightDirection = glGetUniformLocation(mProgramHandle, "u_lightDirection"); + GLint aMx = glGetUniformLocation(mProgramHandle, "a_mx"); + GLint aMy = glGetUniformLocation(mProgramHandle, "a_my"); + + angleX = angleXOffset; + angleY = angleYOffset; + + /* y轴旋转度 */ + float radianY = (angleY * pi) / 180.0; + float cosY = cosf(radianY); + float sinY = sinf(radianY); + float myArr[] = { + cosY, 0, -sinY, 0, + 0, 1, 0, 0, + sinY, 0, cosY, 0, + 0, 0, 0, 1 + }; + + glUniformMatrix4fv(aMy, 1, false, myArr); + + /* x轴旋转度 */ + float radianX = (angleX * pi) / 180.0; + float cosX = cosf(radianX); + float sinX = sinf(radianX); + float mxArr[] = { + 1, 0, 0, 0, 0, cosX, -sinX, 0, 0, sinX, cosX, 0, 0, 0, 0, 1 + }; + + glUniformMatrix4fv(aMx, 1, false, mxArr); + + /* 给平行光传入颜色和方向数据,RGB(1,1,1),单位向量(x,y,z) */ + glUniform3f(uLightColor, 1.0, 1.0, 1.0); + + /* 保证向量(x,y,z)的长度为1,即单位向量 */ + float x = 2.0 / sqrt(15); + float y = 2.0 / sqrt(15); + float z = 3.0 / sqrt(15); + + glUniform3f(uLightDirection, x, -y, z); + + /* 创建缓冲区buffer,传入顶点位置数据g_vertexData */ + enableVertexAttrib(aPos, g_vertexData, sizeof(g_vertexData)); + enableVertexAttrib(aNormal, g_normalData, sizeof(g_normalData)); + /* 创建缓冲区colorBuffer,传入顶点颜色数据g_colorData */ + enableVertexAttrib(aColor, g_colorData, sizeof(g_colorData)); + + /* 执行绘制之前,一定要开启深度测试,以免颜色混乱 */ + glEnable(GL_DEPTH_TEST); + + /* 执行绘制并更新 */ + glDrawArrays(GL_TRIANGLES, 0, TETRAHEDRON_POINT); + eglSwapBuffers(mEGLDisplay, mEGLSurface); +} + +float Tetrahedron::GetAngleX() +{ + return angleX; +} + +float Tetrahedron::GetAngleY() +{ + return angleY; +} + +int32_t Tetrahedron::Quit(void) +{ + EGLBoolean ret = eglDestroySurface(mEGLDisplay, mEGLSurface); + if (!ret) { + LOGW("eglDestroySurface failure."); + } + + ret = eglDestroyContext(mEGLDisplay, mEGLContext); + if (!ret) { + LOGW("eglDestroyContext failure."); + } + + ret = eglTerminate(mEGLDisplay); + if (!ret) { + LOGW("eglTerminate failure."); + } + + mEGLSurface = NULL; + mEGLContext = NULL; + mEGLDisplay = NULL; + + LOGE("Quit success."); + return 0; +} diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/type/libentry/oh-package.json5 b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/type/libentry/oh-package.json5 index ed7780160f..02724aa41e 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/type/libentry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/type/libentry/oh-package.json5 @@ -1,6 +1,6 @@ -{ - "name": "libtetrahedron_napi.so", - "types": "./tetrahedron_napi.d.ts", - "version": "", - "description": "Please describe the basic information." +{ + "name": "libtetrahedron_napi.so", + "types": "./tetrahedron_napi.d.ts", + "version": "", + "description": "Please describe the basic information." } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/type/libentry/tetrahedron_napi.d.ts b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/type/libentry/tetrahedron_napi.d.ts index 1c3ec45f99..c307b40198 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/type/libentry/tetrahedron_napi.d.ts +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/cpp/type/libentry/tetrahedron_napi.d.ts @@ -1,17 +1,17 @@ -/* - * Copyright (c) 2023 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. - */ - -//传入x,y偏移量并返回x,y旋转角 +/* + * Copyright (c) 2023 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. + */ + +//传入x,y偏移量并返回x,y旋转角 export const updateAngle:(offsetX:number, offsetY:number)=>Array; \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/ets/pages/Index.ets index 5654e55f0f..8333927464 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/ets/pages/Index.ets @@ -1,96 +1,96 @@ -/* - * Copyright (c) 2023 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 { Logger } from '../utils/Logger'; -import tetrahedron_napi from 'libtetrahedron_napi.so' - -@Entry -@Component -struct Index { - @State angleArray: Array = new Array(); - @State shaftRotation: string = ''; - private xcomponentId = 'tetrahedron'; - private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.All }); - - async aboutToAppear() { - Logger.info('aboutToAppear'); - this.angleArray[0] = 30; - this.angleArray[1] = 45; - let resourceManager = getContext(this).resourceManager; - this.shaftRotation = await resourceManager.getStringValue($r('app.string.shaftRotation').id); - } - - build() { - Column() { - Text($r('app.string.EntryAbility_desc')) - .fontSize($r('app.float.head_font_24')) - .lineHeight($r('app.float.wh_value_33')) - .fontFamily('HarmonyHeiTi-Bold') - .fontWeight(FontWeight.Bold) - .fontColor($r('app.color.font_color_182431')) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .textAlign(TextAlign.Start) - .margin({ top: $r('app.float.wh_value_13'), bottom: $r('app.float.wh_value_15') }) - - Text('X ' + this.shaftRotation + ':' + this.angleArray[0].toString() - + '°\nY ' + this.shaftRotation + ':' + this.angleArray[1].toString() + '°') - .fontSize($r('app.float.head_font_24')) - .lineHeight($r('app.float.wh_value_33')) - .fontFamily('HarmonyHeiTi-Bold') - .fontWeight(FontWeight.Bold) - .fontColor($r('app.color.font_color_182431')) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .textAlign(TextAlign.Start) - .margin({ top: $r('app.float.wh_value_13'), bottom: $r('app.float.wh_value_15') }) - - Column() { - XComponent({ id: this.xcomponentId, type: 'surface', libraryname: 'tetrahedron_napi' }) - .onLoad(() => { - Logger.info('onLoad'); - }) - .width($r('app.float.wh_value_360')) - .height($r('app.float.wh_value_360')) - .key('tetrahedron') - .onDestroy(() => { - Logger.info('onDestroy'); - }) - .id('xComponent') - .backgroundColor(Color.White) - } - .justifyContent(FlexAlign.SpaceAround) - .alignItems(HorizontalAlign.Center) - .height('80%') - .width('100%') - .backgroundColor(Color.White) - .borderRadius(24) - } - .gesture( - PanGesture(this.panOption) - .onActionStart((event: GestureEvent) => { - Logger.info('Gesture onActionStart'); - }) - .onActionUpdate((event: GestureEvent) => { - this.angleArray = tetrahedron_napi.updateAngle(event.offsetX, event.offsetY); - Logger.info('Gesture onActionUpdate : offSet ' + event.offsetX + ',' + event.offsetY); - }) - .onActionEnd(() => { - Logger.info('Gesture onActionEnd'); - }) - ) - .padding(12) - .backgroundColor('#f1f3f5') - .height('100%') - } -} +/* + * Copyright (c) 2023 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 { Logger } from '../utils/Logger'; +import tetrahedron_napi from 'libtetrahedron_napi.so' + +@Entry +@Component +struct Index { + @State angleArray: Array = new Array(); + @State shaftRotation: string = ''; + private xcomponentId = 'tetrahedron'; + private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.All }); + + async aboutToAppear() { + Logger.info('aboutToAppear'); + this.angleArray[0] = 30; + this.angleArray[1] = 45; + let resourceManager = getContext(this).resourceManager; + this.shaftRotation = await resourceManager.getStringValue($r('app.string.shaftRotation').id); + } + + build() { + Column() { + Text($r('app.string.EntryAbility_desc')) + .fontSize($r('app.float.head_font_24')) + .lineHeight($r('app.float.wh_value_33')) + .fontFamily('HarmonyHeiTi-Bold') + .fontWeight(FontWeight.Bold) + .fontColor($r('app.color.font_color_182431')) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .textAlign(TextAlign.Start) + .margin({ top: $r('app.float.wh_value_13'), bottom: $r('app.float.wh_value_15') }) + + Text('X ' + this.shaftRotation + ':' + this.angleArray[0].toString() + + '°\nY ' + this.shaftRotation + ':' + this.angleArray[1].toString() + '°') + .fontSize($r('app.float.head_font_24')) + .lineHeight($r('app.float.wh_value_33')) + .fontFamily('HarmonyHeiTi-Bold') + .fontWeight(FontWeight.Bold) + .fontColor($r('app.color.font_color_182431')) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .textAlign(TextAlign.Start) + .margin({ top: $r('app.float.wh_value_13'), bottom: $r('app.float.wh_value_15') }) + + Column() { + XComponent({ id: this.xcomponentId, type: 'surface', libraryname: 'tetrahedron_napi' }) + .onLoad(() => { + Logger.info('onLoad'); + }) + .width($r('app.float.wh_value_360')) + .height($r('app.float.wh_value_360')) + .key('tetrahedron') + .onDestroy(() => { + Logger.info('onDestroy'); + }) + .id('xComponent') + .backgroundColor(Color.White) + } + .justifyContent(FlexAlign.SpaceAround) + .alignItems(HorizontalAlign.Center) + .height('80%') + .width('100%') + .backgroundColor(Color.White) + .borderRadius(24) + } + .gesture( + PanGesture(this.panOption) + .onActionStart((event: GestureEvent) => { + Logger.info('Gesture onActionStart'); + }) + .onActionUpdate((event: GestureEvent) => { + this.angleArray = tetrahedron_napi.updateAngle(event.offsetX, event.offsetY); + Logger.info('Gesture onActionUpdate : offSet ' + event.offsetX + ',' + event.offsetY); + }) + .onActionEnd(() => { + Logger.info('Gesture onActionEnd'); + }) + ) + .padding(12) + .backgroundColor('#f1f3f5') + .height('100%') + } +} diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/ets/utils/Logger.ets b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/ets/utils/Logger.ets index ae067ff531..6236616588 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/ets/utils/Logger.ets +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/ets/utils/Logger.ets @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class LoggerModel { - private domain: number - private prefix: string - private format: string = '%{public}s' - - constructor(prefix: string) { - this.prefix = prefix - this.domain = 0xFF00 - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args) - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args) - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args) - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args) - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class LoggerModel { + private domain: number + private prefix: string + private format: string = '%{public}s' + + constructor(prefix: string) { + this.prefix = prefix + this.domain = 0xFF00 + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args) + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args) + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args) + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args) + } +} + export let Logger = new LoggerModel('[Sample_OpenGL]') \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/module.json5 b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/module.json5 index eed2be5236..9e973ce568 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/module.json5 +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 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" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ets", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/resources/base/element/color.json index 721b881014..9974d136ee 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/main/resources/base/element/color.json @@ -1,92 +1,92 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "color_333333_grey", - "value": "#333333" - }, - { - "name": "color_666666_grey", - "value": "#666666" - }, - { - "name": "color_999999_grey", - "value": "#999999" - }, - { - "name": "color_E3E3E3_grey", - "value": "#E3E3E3" - }, - { - "name": "color_D8D8D8_grey", - "value": "#D8D8D8" - }, - { - "name": "color_button_grey", - "value": "#1824310D" - }, - { - "name": "color_00000000_transparent", - "value": "#00000000" - }, - { - "name": "volume_bg_color", - "value": "#CCFFFFFF" - }, - { - "name": "white_bg_color", - "value": "#FFFFFF" - }, - { - "name": "font_color_182431", - "value": "#182431" - }, - { - "name": "font_color_007DFF", - "value": "#007DFF" - }, - { - "name": "toggle_selected_color_007DFF", - "value": "#007DFF" - }, - { - "name": "search_no_result_text_color", - "value": "$color:font_color_182431" - }, - { - "name": "search_result_text_color", - "value": "$color:font_color_182431" - }, - { - "name": "search_result_text_color_highlight", - "value": "$color:font_color_007DFF" - }, - { - "name": "bluetooth_text_color_highlight", - "value": "$color:font_color_007DFF" - }, - { - "name": "FAFAFA", - "value": "#FAFAFA" - }, - { - "name": "DCEAF9", - "value": "#DCEAF9" - }, - { - "name": "4C89F0", - "value": "#4C89F0" - }, - { - "name": "D1D0DB", - "value": "#D1D0DB" - }, - { - "name": "white", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "color_333333_grey", + "value": "#333333" + }, + { + "name": "color_666666_grey", + "value": "#666666" + }, + { + "name": "color_999999_grey", + "value": "#999999" + }, + { + "name": "color_E3E3E3_grey", + "value": "#E3E3E3" + }, + { + "name": "color_D8D8D8_grey", + "value": "#D8D8D8" + }, + { + "name": "color_button_grey", + "value": "#1824310D" + }, + { + "name": "color_00000000_transparent", + "value": "#00000000" + }, + { + "name": "volume_bg_color", + "value": "#CCFFFFFF" + }, + { + "name": "white_bg_color", + "value": "#FFFFFF" + }, + { + "name": "font_color_182431", + "value": "#182431" + }, + { + "name": "font_color_007DFF", + "value": "#007DFF" + }, + { + "name": "toggle_selected_color_007DFF", + "value": "#007DFF" + }, + { + "name": "search_no_result_text_color", + "value": "$color:font_color_182431" + }, + { + "name": "search_result_text_color", + "value": "$color:font_color_182431" + }, + { + "name": "search_result_text_color_highlight", + "value": "$color:font_color_007DFF" + }, + { + "name": "bluetooth_text_color_highlight", + "value": "$color:font_color_007DFF" + }, + { + "name": "FAFAFA", + "value": "#FAFAFA" + }, + { + "name": "DCEAF9", + "value": "#DCEAF9" + }, + { + "name": "4C89F0", + "value": "#4C89F0" + }, + { + "name": "D1D0DB", + "value": "#D1D0DB" + }, + { + "name": "white", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkOpenGL/entry/src/ohosTest/module.json5 b/code/BasicFeature/Native/NdkOpenGL/entry/src/ohosTest/module.json5 index 0511adbc86..c6ad62fbbd 100644 --- a/code/BasicFeature/Native/NdkOpenGL/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Native/NdkOpenGL/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/Native/NdkOpenGL/hvigor/hvigor-config.json5 b/code/BasicFeature/Native/NdkOpenGL/hvigor/hvigor-config.json5 index ac737cf85f..e75281b258 100644 --- a/code/BasicFeature/Native/NdkOpenGL/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Native/NdkOpenGL/hvigor/hvigor-config.json5 @@ -1,6 +1,6 @@ -{ - "hvigorVersion": "3.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.2" - } +{ + "hvigorVersion": "3.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.2" + } } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkOpenGL/oh-package.json5 b/code/BasicFeature/Native/NdkOpenGL/oh-package.json5 index d2e3b280b0..567e91cea6 100644 --- a/code/BasicFeature/Native/NdkOpenGL/oh-package.json5 +++ b/code/BasicFeature/Native/NdkOpenGL/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "NdkOpenGL", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "NdkOpenGL", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Native/NdkQoS/AppScope/app.json5 b/code/BasicFeature/Native/NdkQoS/AppScope/app.json5 index 835f4a6ae3..677efa72eb 100644 --- a/code/BasicFeature/Native/NdkQoS/AppScope/app.json5 +++ b/code/BasicFeature/Native/NdkQoS/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.example.qossample", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.example.qossample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Native/NdkQoS/AppScope/resources/base/element/string.json b/code/BasicFeature/Native/NdkQoS/AppScope/resources/base/element/string.json index 92f05a126a..71f7d544aa 100644 --- a/code/BasicFeature/Native/NdkQoS/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Native/NdkQoS/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "QoSSample" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "QoSSample" + } + ] +} diff --git a/code/BasicFeature/Native/NdkQoS/build-profile.json5 b/code/BasicFeature/Native/NdkQoS/build-profile.json5 index 6752bb1704..0a3aa13e21 100644 --- a/code/BasicFeature/Native/NdkQoS/build-profile.json5 +++ b/code/BasicFeature/Native/NdkQoS/build-profile.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2024 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", - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} +/* + * Copyright (c) 2024 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", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "runtimeOS": "OpenHarmony", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/BasicFeature/Native/NdkQoS/entry/build-profile.json5 b/code/BasicFeature/Native/NdkQoS/entry/build-profile.json5 index 1ee1465153..43c59a2208 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/build-profile.json5 +++ b/code/BasicFeature/Native/NdkQoS/entry/build-profile.json5 @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2024 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": [ - "armeabi-v7a", "arm64-v8a" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": true, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} +/* + * Copyright (c) 2024 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": [ + "armeabi-v7a", "arm64-v8a" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} diff --git a/code/BasicFeature/Native/NdkQoS/entry/oh-package.json5 b/code/BasicFeature/Native/NdkQoS/entry/oh-package.json5 index b9c1d4cca7..54cb066266 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkQoS/entry/oh-package.json5 @@ -1,11 +1,11 @@ -{ - "name": "entry", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libentry.so": "file:./src/main/cpp/types/libentry" - } +{ + "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/BasicFeature/Native/NdkQoS/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/CMakeLists.txt index f2595825a7..9bcaac120f 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/CMakeLists.txt +++ b/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.4.1) -project(rtbandwidth) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED main.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(rtbandwidth) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED main.cpp) target_link_libraries(entry libace_napi.z.so libqos.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/main.cpp b/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/main.cpp index 759457b8e1..8084c4f9d5 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/main.cpp +++ b/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/main.cpp @@ -1,209 +1,209 @@ -/* - * Copyright (c) 2024 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 -#include -#include -#include -#include -#include -#include "napi/native_api.h" -#include "qos/qos.h" - -const unsigned int LOG_PRINT_DOMAIN = 0xFF00; -constexpr int DEPTH = 34; -constexpr int TASKS = 6; // 负载线程个数 -constexpr long long ONE = 1; -constexpr long long TWO = 2; -constexpr int BOUND = 20000; - -constexpr int MASK = 2; -constexpr int CPUS = 4; - -static bool g_addLoad = false; // 负载线程是否加载 -static double g_durationTime = 0; // 计算任务耗时时间 - -// 执行 斐波那契数列 计算 -long long DoFib(double n) -{ - if (n == ONE) { - return ONE; - } - - if (n == TWO) { - return TWO; - } - return DoFib(n - ONE) + DoFib(n - TWO); -} - -void SetQoS(QoS_Level level) -{ - // 设置当前线程的QoS等级为level - int ret = OH_QoS_SetThreadQoS(level); - if (!ret) { // ret等于0说明设置成功 - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "set qos level success."); - // 查询当前的qos等级 - QoS_Level queryLevel = QoS_Level::QOS_DEFAULT; - ret = OH_QoS_GetThreadQoS(&queryLevel); - if (!ret) { // ret等于0说明查询成功 - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "the qos level of current thread : %{public}d", - queryLevel); - } else { // 否则说明查询失败 - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "get qos level failed."); - return; - } - } else { // ret不等于0说明设置失败 - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "get level qos failed!"); - return; - } - - // 绑定到特定cpu - cpu_set_t mask; - CPU_SET(MASK, &mask); - if (sched_setaffinity(0, sizeof(mask), &mask) != 0) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "bind work thread failed"); - } else { - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "bind work thread success."); - } - - // 执行斐波那契数列计算任务 - auto startTime = std::chrono::system_clock::now(); - long long res = DoFib(DEPTH); // 执行斐波那契数列计算任务 - auto endTime = std::chrono::system_clock::now(); - g_durationTime = std::chrono::duration(endTime - startTime).count(); - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "calculate res is: %{public}llu", res); - - // 重置线程QoS等级 - ret = OH_QoS_ResetThreadQoS(); - if (!ret) { // ret等于0说明重置成功 - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "reset qos level success."); - } else { // 否则说明重置失败 - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "reset qos level failed!"); - return; - } - - // 在重置QoS后,再次查询,此时查询会失败 - QoS_Level queryLevelTwo; - ret = OH_QoS_GetThreadQoS(&queryLevelTwo); - if (!ret) { // 正常路径 - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "the qos level after: %{public}d", queryLevelTwo); - return; - } else { // 异常路径 - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "query qos level failed after reset."); - return; - } -} - -// 负载任务 -void AddLoads(int n) -{ - int ret = OH_QoS_SetThreadQoS(QoS_Level::QOS_BACKGROUND); // 设置负载线程的QoS等级 - if (ret) { // ret不等于0说明设置失败 - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "set load thread QoS level failed."); - return; - } - - // 绑定到特定cpu - cpu_set_t mask; - CPU_SET(n, &mask); - if (sched_setaffinity(0, sizeof(mask), &mask) != 0) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "bind load thread failed"); - return; - } else { - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "bind load threads success."); - } - - // 执行负载计算 - for (int i = 0; i < BOUND; i++) { - for (int j = 0; j < BOUND; j++) { - int x = (i + j) - n; - printf("%d", x); - } - } - // 重新初始化负载线程 - g_addLoad = false; -} - -static napi_value highQoSCalculate(napi_env env, napi_callback_info info) -{ - g_durationTime = 0; - // 没有加载系统负载的情况下,开启TASKS个线程模拟系统负载 - if (!g_addLoad) { - std::vector loadThreads; - for (int i = 0; i < TASKS; i++) { - // 开启线程执行负载任务 - loadThreads.emplace_back(std::thread(AddLoads, i % CPUS)); - loadThreads[i].detach(); - } - g_addLoad = true; - } - // 开启 QOS_USER_INTERACTIVE 高 QoS 线程进行计算 - QoS_Level level = QoS_Level::QOS_USER_INTERACTIVE; - std::thread task(SetQoS, level); - task.join(); - - // 返回计算耗时 - napi_value res; - napi_create_double(env, g_durationTime, &res); - return res; -} - -static napi_value lowQoSCalculate(napi_env env, napi_callback_info info) -{ - g_durationTime = 0; - // 没有加载系统负载的情况下,开启TASKS个线程模拟系统负载 - if (!g_addLoad) { - std::vector loadThreads; - for (int i = 0; i < TASKS; i++) { - // 开启线程执行负载任务 - loadThreads.emplace_back(std::thread(AddLoads, i % CPUS)); - loadThreads[i].detach(); - } - g_addLoad = true; - } - - // 开启 QOS_BACKGROUND 低 QoS 线程进行计算 - QoS_Level level = QoS_Level::QOS_BACKGROUND; - std::thread task(SetQoS, level); - task.join(); - - // 返回计算耗时 - napi_value res; - napi_create_double(env, g_durationTime, &res); - return res; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"useHighQos", nullptr, highQoSCalculate, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"useLowQos", nullptr, lowQoSCalculate, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2024 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 +#include +#include +#include +#include +#include +#include "napi/native_api.h" +#include "qos/qos.h" + +const unsigned int LOG_PRINT_DOMAIN = 0xFF00; +constexpr int DEPTH = 34; +constexpr int TASKS = 6; // 负载线程个数 +constexpr long long ONE = 1; +constexpr long long TWO = 2; +constexpr int BOUND = 20000; + +constexpr int MASK = 2; +constexpr int CPUS = 4; + +static bool g_addLoad = false; // 负载线程是否加载 +static double g_durationTime = 0; // 计算任务耗时时间 + +// 执行 斐波那契数列 计算 +long long DoFib(double n) +{ + if (n == ONE) { + return ONE; + } + + if (n == TWO) { + return TWO; + } + return DoFib(n - ONE) + DoFib(n - TWO); +} + +void SetQoS(QoS_Level level) +{ + // 设置当前线程的QoS等级为level + int ret = OH_QoS_SetThreadQoS(level); + if (!ret) { // ret等于0说明设置成功 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "set qos level success."); + // 查询当前的qos等级 + QoS_Level queryLevel = QoS_Level::QOS_DEFAULT; + ret = OH_QoS_GetThreadQoS(&queryLevel); + if (!ret) { // ret等于0说明查询成功 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "the qos level of current thread : %{public}d", + queryLevel); + } else { // 否则说明查询失败 + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "get qos level failed."); + return; + } + } else { // ret不等于0说明设置失败 + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "get level qos failed!"); + return; + } + + // 绑定到特定cpu + cpu_set_t mask; + CPU_SET(MASK, &mask); + if (sched_setaffinity(0, sizeof(mask), &mask) != 0) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "bind work thread failed"); + } else { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "bind work thread success."); + } + + // 执行斐波那契数列计算任务 + auto startTime = std::chrono::system_clock::now(); + long long res = DoFib(DEPTH); // 执行斐波那契数列计算任务 + auto endTime = std::chrono::system_clock::now(); + g_durationTime = std::chrono::duration(endTime - startTime).count(); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "calculate res is: %{public}llu", res); + + // 重置线程QoS等级 + ret = OH_QoS_ResetThreadQoS(); + if (!ret) { // ret等于0说明重置成功 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "reset qos level success."); + } else { // 否则说明重置失败 + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "reset qos level failed!"); + return; + } + + // 在重置QoS后,再次查询,此时查询会失败 + QoS_Level queryLevelTwo; + ret = OH_QoS_GetThreadQoS(&queryLevelTwo); + if (!ret) { // 正常路径 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "the qos level after: %{public}d", queryLevelTwo); + return; + } else { // 异常路径 + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "query qos level failed after reset."); + return; + } +} + +// 负载任务 +void AddLoads(int n) +{ + int ret = OH_QoS_SetThreadQoS(QoS_Level::QOS_BACKGROUND); // 设置负载线程的QoS等级 + if (ret) { // ret不等于0说明设置失败 + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "set load thread QoS level failed."); + return; + } + + // 绑定到特定cpu + cpu_set_t mask; + CPU_SET(n, &mask); + if (sched_setaffinity(0, sizeof(mask), &mask) != 0) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "QoS", "bind load thread failed"); + return; + } else { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "QoS", "bind load threads success."); + } + + // 执行负载计算 + for (int i = 0; i < BOUND; i++) { + for (int j = 0; j < BOUND; j++) { + int x = (i + j) - n; + printf("%d", x); + } + } + // 重新初始化负载线程 + g_addLoad = false; +} + +static napi_value highQoSCalculate(napi_env env, napi_callback_info info) +{ + g_durationTime = 0; + // 没有加载系统负载的情况下,开启TASKS个线程模拟系统负载 + if (!g_addLoad) { + std::vector loadThreads; + for (int i = 0; i < TASKS; i++) { + // 开启线程执行负载任务 + loadThreads.emplace_back(std::thread(AddLoads, i % CPUS)); + loadThreads[i].detach(); + } + g_addLoad = true; + } + // 开启 QOS_USER_INTERACTIVE 高 QoS 线程进行计算 + QoS_Level level = QoS_Level::QOS_USER_INTERACTIVE; + std::thread task(SetQoS, level); + task.join(); + + // 返回计算耗时 + napi_value res; + napi_create_double(env, g_durationTime, &res); + return res; +} + +static napi_value lowQoSCalculate(napi_env env, napi_callback_info info) +{ + g_durationTime = 0; + // 没有加载系统负载的情况下,开启TASKS个线程模拟系统负载 + if (!g_addLoad) { + std::vector loadThreads; + for (int i = 0; i < TASKS; i++) { + // 开启线程执行负载任务 + loadThreads.emplace_back(std::thread(AddLoads, i % CPUS)); + loadThreads[i].detach(); + } + g_addLoad = true; + } + + // 开启 QOS_BACKGROUND 低 QoS 线程进行计算 + QoS_Level level = QoS_Level::QOS_BACKGROUND; + std::thread task(SetQoS, level); + task.join(); + + // 返回计算耗时 + napi_value res; + napi_create_double(env, g_durationTime, &res); + return res; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"useHighQos", nullptr, highQoSCalculate, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"useLowQos", nullptr, lowQoSCalculate, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/types/libentry/index.d.ts b/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/types/libentry/index.d.ts index 4cffcf618e..ec633cf850 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,17 +1,17 @@ -/* - * Copyright (c) 2024 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 useHighQos: () => number; +/* + * Copyright (c) 2024 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 useHighQos: () => number; export const useLowQos: () => number; \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/types/libentry/oh-package.json5 index 124352dc7f..8c49cae229 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkQoS/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,6 +1,6 @@ -{ - "name": "libentry.so", - "types": "./index.d.ts", - "version": "", - "description": "Please describe the basic information." +{ + "name": "libentry.so", + "types": "./index.d.ts", + "version": "", + "description": "Please describe the basic information." } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkQoS/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Native/NdkQoS/entry/src/main/ets/entryability/EntryAbility.ets index 14b525aba9..4504c55460 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Native/NdkQoS/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2024 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 from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, 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(): 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'); - } -}; +/* + * Copyright (c) 2024 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 from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, 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(): 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/BasicFeature/Native/NdkQoS/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Native/NdkQoS/entry/src/main/ets/pages/Index.ets index d85db4a7d6..36522ed927 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Native/NdkQoS/entry/src/main/ets/pages/Index.ets @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2024 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 { - @State message: string = 'QoS Sample'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - - Button('High level QoS test', { type: ButtonType.Normal }) - .margin({ top: 50 }) - .height('6%') - .width('50%') - .borderRadius(8) - .fontWeight(FontWeight.Bold) - .backgroundColor('#aabbcc') - .onClick(() => { - let ret: string = testNapi.useHighQos().toString(); - AlertDialog.show({ - title: this.message, - message: "High-level QoS calculation time: " + ret + " ms", - alignment: DialogAlignment.Center, - confirm: { - value: "OK", - action: () => { - console.info("High-QoS done") - } - } - }) - }) - - Button('Low level QoS test', { type: ButtonType.Normal }) - .margin({ top: 50 }) - .height('6%') - .borderRadius(8) - .width('50%') - .backgroundColor('#aabbcc') - .fontWeight(FontWeight.Bold) - .onClick(() => { - let ret: string = testNapi.useLowQos().toString(); - AlertDialog.show({ - title: this.message, - message: "Low-level QoS calculation time: " + ret + " ms", - alignment: DialogAlignment.Center, - confirm: { - value: "OK", - action: () => { - console.info("Low-QoS done") - } - } - }) - }) - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2024 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 { + @State message: string = 'QoS Sample'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + + Button('High level QoS test', { type: ButtonType.Normal }) + .margin({ top: 50 }) + .height('6%') + .width('50%') + .borderRadius(8) + .fontWeight(FontWeight.Bold) + .backgroundColor('#aabbcc') + .onClick(() => { + let ret: string = testNapi.useHighQos().toString(); + AlertDialog.show({ + title: this.message, + message: "High-level QoS calculation time: " + ret + " ms", + alignment: DialogAlignment.Center, + confirm: { + value: "OK", + action: () => { + console.info("High-QoS done") + } + } + }) + }) + + Button('Low level QoS test', { type: ButtonType.Normal }) + .margin({ top: 50 }) + .height('6%') + .borderRadius(8) + .width('50%') + .backgroundColor('#aabbcc') + .fontWeight(FontWeight.Bold) + .onClick(() => { + let ret: string = testNapi.useLowQos().toString(); + AlertDialog.show({ + title: this.message, + message: "Low-level QoS calculation time: " + ret + " ms", + alignment: DialogAlignment.Center, + confirm: { + value: "OK", + action: () => { + console.info("Low-QoS done") + } + } + }) + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/BasicFeature/Native/NdkQoS/entry/src/main/module.json5 b/code/BasicFeature/Native/NdkQoS/entry/src/main/module.json5 index fa5c974459..d8838feb85 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/src/main/module.json5 +++ b/code/BasicFeature/Native/NdkQoS/entry/src/main/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2024 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:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2024 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:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/Native/NdkQoS/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Native/NdkQoS/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Native/NdkQoS/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkQoS/entry/src/ohosTest/module.json5 b/code/BasicFeature/Native/NdkQoS/entry/src/ohosTest/module.json5 index 3613514e70..7690747eb4 100644 --- a/code/BasicFeature/Native/NdkQoS/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Native/NdkQoS/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/Native/NdkQoS/hvigor/hvigor-config.json5 b/code/BasicFeature/Native/NdkQoS/hvigor/hvigor-config.json5 index 55ef747264..eb0d70fb00 100644 --- a/code/BasicFeature/Native/NdkQoS/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Native/NdkQoS/hvigor/hvigor-config.json5 @@ -1,22 +1,22 @@ -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - }, - "execution": { - // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ - // "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": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ - } -} +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + }, + "execution": { + // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ + // "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": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ + } +} diff --git a/code/BasicFeature/Native/NdkQoS/oh-package.json5 b/code/BasicFeature/Native/NdkQoS/oh-package.json5 index 445b6f11ea..a364590a1d 100644 --- a/code/BasicFeature/Native/NdkQoS/oh-package.json5 +++ b/code/BasicFeature/Native/NdkQoS/oh-package.json5 @@ -1,14 +1,14 @@ -{ - "name": "qossample", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.15", - "@ohos/hamock": "1.0.0-rc" - } -} +{ + "name": "qossample", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.15", + "@ohos/hamock": "1.0.0-rc" + } +} diff --git a/code/BasicFeature/Native/NdkRawfile/AppScope/app.json5 b/code/BasicFeature/Native/NdkRawfile/AppScope/app.json5 index 6d1ff9f9db..e2675d587b 100644 --- a/code/BasicFeature/Native/NdkRawfile/AppScope/app.json5 +++ b/code/BasicFeature/Native/NdkRawfile/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.ndkrawfile", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.ndkrawfile", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Native/NdkRawfile/AppScope/resources/base/element/string.json b/code/BasicFeature/Native/NdkRawfile/AppScope/resources/base/element/string.json index b53f80dae8..bfde41be5a 100644 --- a/code/BasicFeature/Native/NdkRawfile/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Native/NdkRawfile/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NdkRawfile" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "NdkRawfile" + } + ] +} diff --git a/code/BasicFeature/Native/NdkRawfile/build-profile.json5 b/code/BasicFeature/Native/NdkRawfile/build-profile.json5 index 75bc91290c..f799f82b02 100644 --- a/code/BasicFeature/Native/NdkRawfile/build-profile.json5 +++ b/code/BasicFeature/Native/NdkRawfile/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 15, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 15, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkRawfile/entry/build-profile.json5 b/code/BasicFeature/Native/NdkRawfile/entry/build-profile.json5 index 7744ea3a05..fb84cfb682 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/build-profile.json5 +++ b/code/BasicFeature/Native/NdkRawfile/entry/build-profile.json5 @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2023 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", - "armeabi-v7a" - ] - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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", + "armeabi-v7a" + ] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkRawfile/entry/oh-package.json5 b/code/BasicFeature/Native/NdkRawfile/entry/oh-package.json5 index 1636ca03c1..df841c792e 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkRawfile/entry/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": { - "libentry.so": "file:./src/main/cpp/types/libentry" - } -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} diff --git a/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/CMakeLists.txt index 015bce56df..3fbb8db58e 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/CMakeLists.txt +++ b/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/CMakeLists.txt @@ -1,11 +1,11 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.4.1) -project(NdkRawfile2) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED rawfile_demo.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(NdkRawfile2) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED rawfile_demo.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so librawfile.z.so) \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/rawfile_demo.cpp b/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/rawfile_demo.cpp index f936b50584..9321257f7b 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/rawfile_demo.cpp +++ b/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/rawfile_demo.cpp @@ -1,365 +1,365 @@ -/* - * Copyright (c) 2023 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 -#include -#include -#include -#include -#include "napi/native_api.h" -#include "rawfile/raw_file_manager.h" -#include "rawfile/raw_file.h" -#include "rawfile/raw_dir.h" -#include "hilog/log.h" - -const int GLOBAL_RESMGR = 0xFF00; -const char *TAG = "[Sample_rawfile]"; -static napi_value GetFileList(napi_env env, napi_callback_info info) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetFileList Begin"); - size_t argc = 2; - napi_value argv[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - - NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); - size_t strSize; - char strBuf[256]; - napi_get_value_string_utf8(env, argv[1], strBuf, sizeof(strBuf), &strSize); - std::string filename(strBuf, strSize); - RawDir *rawDir = OH_ResourceManager_OpenRawDir(mNativeResMgr, filename.c_str()); - int count = OH_ResourceManager_GetRawFileCount(rawDir); - std::vector tempArray; - for (int i = 0; i < count; i++) { - std::string filename = OH_ResourceManager_GetRawFileName(rawDir, i); - tempArray.emplace_back(filename); - } - - napi_value fileList; - napi_create_array(env, &fileList); - for (size_t i = 0; i < tempArray.size(); i++) { - napi_value jsString; - napi_create_string_utf8(env, tempArray[i].c_str(), NAPI_AUTO_LENGTH, &jsString); - napi_set_element(env, fileList, i, jsString); - } - OH_ResourceManager_CloseRawDir(rawDir); - OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); - return fileList; -} - -namespace { - napi_value CreateJsArrayValue(napi_env env, std::unique_ptr &data, long length) - { - napi_value buffer; - napi_status status = napi_create_external_arraybuffer( - env, data.get(), length, - [](napi_env env, void *data, void *hint) { - delete[] static_cast(data); - }, - nullptr, &buffer); - if (status != napi_ok) { - OH_LOG_Print(LOG_APP, LOG_ERROR, GLOBAL_RESMGR, TAG, "Failed to create external array buffer"); - return nullptr; - } - napi_value result = nullptr; - status = napi_create_typedarray(env, napi_uint8_array, length, buffer, 0, &result); - if (status != napi_ok) { - OH_LOG_Print(LOG_APP, LOG_ERROR, GLOBAL_RESMGR, TAG, "Failed to create media typed array"); - return nullptr; - } - data.release(); - return result; - } -} - - -static napi_value GetRawFileContent(napi_env env, napi_callback_info info) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetFileContent Begin"); - size_t argc = 4; - napi_value argv[4] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - - NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); - size_t strSize; - char strBuf[256]; - napi_get_value_string_utf8(env, argv[1], strBuf, sizeof(strBuf), &strSize); - std::string filename(strBuf, strSize); - int64_t offset = 0; - int64_t length = 0; - napi_get_value_int64(env, argv[2], &offset); - napi_get_value_int64(env, argv[3], &length); - - RawFile *rawFile = OH_ResourceManager_OpenRawFile(mNativeResMgr, filename.c_str()); - if (rawFile != nullptr) { - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "OH_ResourceManager_OpenRawFile success"); - } - long fileSize = OH_ResourceManager_GetRawFileSize(rawFile); - long readLen = fileSize; - if (offset + length <= fileSize) { - OH_ResourceManager_SeekRawFile(rawFile, offset, 0); - if (length != 0) { - readLen = length; - } - long currentOffset = OH_ResourceManager_GetRawFileOffset(rawFile); - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetFileContent, current rawfile offset = %{public}ld", - currentOffset); - } - std::unique_ptr data = std::make_unique(readLen); - int res = OH_ResourceManager_ReadRawFile(rawFile, data.get(), readLen); - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetFileContent, read size = %{public}d", res); - OH_ResourceManager_CloseRawFile(rawFile); - OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); - return CreateJsArrayValue(env, data, fileSize); -} - -static napi_value GetRawFileContent64(napi_env env, napi_callback_info info) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetRawFileContent64 Begin"); - size_t argc = 4; - napi_value argv[4] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - - NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); - size_t strSize; - char strBuf[256]; - napi_get_value_string_utf8(env, argv[1], strBuf, sizeof(strBuf), &strSize); - std::string filename(strBuf, strSize); - int64_t offset = 0; - int64_t length = 0; - napi_get_value_int64(env, argv[2], &offset); - napi_get_value_int64(env, argv[3], &length); - - RawFile64 *rawFile = OH_ResourceManager_OpenRawFile64(mNativeResMgr, filename.c_str()); - if (rawFile != nullptr) { - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "OH_ResourceManager_OpenRawFile64 success"); - } - long fileSize = OH_ResourceManager_GetRawFileSize64(rawFile); - long readLen = fileSize; - if (offset + length <= fileSize) { - OH_ResourceManager_SeekRawFile64(rawFile, offset, 0); - if (length != 0) { - readLen = length; - } - long currentOffset = OH_ResourceManager_GetRawFileOffset64(rawFile); - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetRawFileContent64, current rawfile offset = %{public}ld", - currentOffset); - } - std::unique_ptr data = std::make_unique(readLen); - int res = OH_ResourceManager_ReadRawFile64(rawFile, data.get(), readLen); - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetRawFileContent64, read size = %{public}d", res); - OH_ResourceManager_CloseRawFile64(rawFile); - OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); - return CreateJsArrayValue(env, data, fileSize); -} - -namespace { - napi_value createJsFileDescriptor(napi_env env, int navtieFd, int64_t nativeOffset, int64_t nativeLength) - { - napi_value result; - napi_status status = napi_create_object(env, &result); - if (status != napi_ok) { - return result; - } - - napi_value fd; - status = napi_create_int32(env, navtieFd, &fd); - if (status != napi_ok) { - return result; - } - status = napi_set_named_property(env, result, "fd", fd); - if (status != napi_ok) { - return result; - } - - napi_value offset; - status = napi_create_int64(env, nativeOffset, &offset); - if (status != napi_ok) { - return result; - } - status = napi_set_named_property(env, result, "offset", offset); - if (status != napi_ok) { - return result; - } - - napi_value length; - status = napi_create_int64(env, nativeLength, &length); - if (status != napi_ok) { - return result; - } - status = napi_set_named_property(env, result, "length", length); - if (status != napi_ok) { - return result; - } - return result; - } -} - -static napi_value GetRawFileDescriptor(napi_env env, napi_callback_info info) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetRawFileDescriptor Begin"); - size_t argc = 2; - napi_value argv[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - - NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); - size_t strSize; - char strBuf[256]; - napi_get_value_string_utf8(env, argv[1], strBuf, sizeof(strBuf), &strSize); - std::string filename(strBuf, strSize); - RawFile *rawFile = OH_ResourceManager_OpenRawFile(mNativeResMgr, filename.c_str()); - if (rawFile != nullptr) { - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "OH_ResourceManager_OpenRawFile success"); - } - RawFileDescriptor descriptor; - OH_ResourceManager_GetRawFileDescriptor(rawFile, descriptor); - - OH_ResourceManager_CloseRawFile(rawFile); - OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); - return createJsFileDescriptor(env, descriptor.fd, descriptor.start, descriptor.length); -} - -static napi_value GetRawFileDescriptor64(napi_env env, napi_callback_info info) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetRawFileDescriptor64 Begin"); - size_t argc = 2; - napi_value argv[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - - NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); - size_t strSize; - char strBuf[256]; - napi_get_value_string_utf8(env, argv[1], strBuf, sizeof(strBuf), &strSize); - std::string filename(strBuf, strSize); - RawFile64 *rawFile = OH_ResourceManager_OpenRawFile64(mNativeResMgr, filename.c_str()); - if (rawFile != nullptr) { - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "OH_ResourceManager_OpenRawFile64 success"); - } - RawFileDescriptor64 descriptor; - OH_ResourceManager_GetRawFileDescriptor64(rawFile, &descriptor); - - OH_ResourceManager_CloseRawFile64(rawFile); - OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); - return createJsFileDescriptor(env, descriptor.fd, descriptor.start, descriptor.length); -} - -namespace { - napi_valuetype GetValueType(napi_env env, napi_value value) - { - napi_valuetype valueType = napi_valuetype::napi_undefined; - napi_typeof(env, value, &valueType); - return valueType; - } - - void GetRawFileDescritorObject(napi_env env, napi_value value, int &nativeFd, int64_t &nativeOffset, - int64_t &nativeLength) - { - napi_value fd; - napi_status status = napi_get_named_property(env, value, "fd", &fd); - if (status == napi_ok && fd != nullptr && GetValueType(env, fd) == napi_number) { - napi_get_value_int32(env, fd, &nativeFd); - } - - napi_value offset; - status = napi_get_named_property(env, value, "offset", &offset); - if (status == napi_ok && offset != nullptr && GetValueType(env, offset) == napi_number) { - napi_get_value_int64(env, offset, &nativeOffset); - } - - napi_value length; - status = napi_get_named_property(env, value, "length", &length); - if (status == napi_ok && length != nullptr && GetValueType(env, length) == napi_number) { - napi_get_value_int64(env, length, &nativeLength); - } - } -} - -static napi_value ReleaseRawFileDescriptor(napi_env env, napi_callback_info info) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "ReleaseRawFileDescriptor Begin"); - size_t argc = 2; - napi_value argv[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - - NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); - bool succeed = false; - if (GetValueType(env, argv[1]) == napi_object) { - RawFileDescriptor descriptor; - int64_t offset = 0; - int64_t length = 0; - GetRawFileDescritorObject(env, argv[1], descriptor.fd, offset, length); - descriptor.start = static_cast(offset); - descriptor.length = static_cast(length); - succeed = OH_ResourceManager_ReleaseRawFileDescriptor(descriptor); - } - OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); - napi_value result; - napi_get_boolean(env, succeed, &result); - return result; -} - -static napi_value ReleaseRawFileDescriptor64(napi_env env, napi_callback_info info) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "ReleaseRawFileDescriptor64 Begin"); - size_t argc = 2; - napi_value argv[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - - NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); - - bool succeed = false; - if (GetValueType(env, argv[1]) == napi_object) { - RawFileDescriptor64 descriptor; - GetRawFileDescritorObject(env, argv[1], descriptor.fd, descriptor.start, descriptor.length); - succeed = OH_ResourceManager_ReleaseRawFileDescriptor64(&descriptor); - } - OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); - napi_value result; - napi_get_boolean(env, succeed, &result); - return result; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"getFileList", nullptr, GetFileList, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getRawFileContent", nullptr, GetRawFileContent, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getRawFileContent64", nullptr, GetRawFileContent64, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getRawFileDescriptor", nullptr, GetRawFileDescriptor, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getRawFileDescriptor64", nullptr, GetRawFileDescriptor64, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"releaseRawFileDescriptor", nullptr, ReleaseRawFileDescriptor, nullptr, nullptr, nullptr, napi_default, - nullptr}, - {"releaseRawFileDescriptor64", nullptr, ReleaseRawFileDescriptor64, nullptr, nullptr, nullptr, napi_default, - nullptr}, - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2023 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 +#include +#include +#include +#include +#include "napi/native_api.h" +#include "rawfile/raw_file_manager.h" +#include "rawfile/raw_file.h" +#include "rawfile/raw_dir.h" +#include "hilog/log.h" + +const int GLOBAL_RESMGR = 0xFF00; +const char *TAG = "[Sample_rawfile]"; +static napi_value GetFileList(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetFileList Begin"); + size_t argc = 2; + napi_value argv[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); + size_t strSize; + char strBuf[256]; + napi_get_value_string_utf8(env, argv[1], strBuf, sizeof(strBuf), &strSize); + std::string filename(strBuf, strSize); + RawDir *rawDir = OH_ResourceManager_OpenRawDir(mNativeResMgr, filename.c_str()); + int count = OH_ResourceManager_GetRawFileCount(rawDir); + std::vector tempArray; + for (int i = 0; i < count; i++) { + std::string filename = OH_ResourceManager_GetRawFileName(rawDir, i); + tempArray.emplace_back(filename); + } + + napi_value fileList; + napi_create_array(env, &fileList); + for (size_t i = 0; i < tempArray.size(); i++) { + napi_value jsString; + napi_create_string_utf8(env, tempArray[i].c_str(), NAPI_AUTO_LENGTH, &jsString); + napi_set_element(env, fileList, i, jsString); + } + OH_ResourceManager_CloseRawDir(rawDir); + OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); + return fileList; +} + +namespace { + napi_value CreateJsArrayValue(napi_env env, std::unique_ptr &data, long length) + { + napi_value buffer; + napi_status status = napi_create_external_arraybuffer( + env, data.get(), length, + [](napi_env env, void *data, void *hint) { + delete[] static_cast(data); + }, + nullptr, &buffer); + if (status != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, GLOBAL_RESMGR, TAG, "Failed to create external array buffer"); + return nullptr; + } + napi_value result = nullptr; + status = napi_create_typedarray(env, napi_uint8_array, length, buffer, 0, &result); + if (status != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, GLOBAL_RESMGR, TAG, "Failed to create media typed array"); + return nullptr; + } + data.release(); + return result; + } +} + + +static napi_value GetRawFileContent(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetFileContent Begin"); + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); + size_t strSize; + char strBuf[256]; + napi_get_value_string_utf8(env, argv[1], strBuf, sizeof(strBuf), &strSize); + std::string filename(strBuf, strSize); + int64_t offset = 0; + int64_t length = 0; + napi_get_value_int64(env, argv[2], &offset); + napi_get_value_int64(env, argv[3], &length); + + RawFile *rawFile = OH_ResourceManager_OpenRawFile(mNativeResMgr, filename.c_str()); + if (rawFile != nullptr) { + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "OH_ResourceManager_OpenRawFile success"); + } + long fileSize = OH_ResourceManager_GetRawFileSize(rawFile); + long readLen = fileSize; + if (offset + length <= fileSize) { + OH_ResourceManager_SeekRawFile(rawFile, offset, 0); + if (length != 0) { + readLen = length; + } + long currentOffset = OH_ResourceManager_GetRawFileOffset(rawFile); + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetFileContent, current rawfile offset = %{public}ld", + currentOffset); + } + std::unique_ptr data = std::make_unique(readLen); + int res = OH_ResourceManager_ReadRawFile(rawFile, data.get(), readLen); + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetFileContent, read size = %{public}d", res); + OH_ResourceManager_CloseRawFile(rawFile); + OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); + return CreateJsArrayValue(env, data, fileSize); +} + +static napi_value GetRawFileContent64(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetRawFileContent64 Begin"); + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); + size_t strSize; + char strBuf[256]; + napi_get_value_string_utf8(env, argv[1], strBuf, sizeof(strBuf), &strSize); + std::string filename(strBuf, strSize); + int64_t offset = 0; + int64_t length = 0; + napi_get_value_int64(env, argv[2], &offset); + napi_get_value_int64(env, argv[3], &length); + + RawFile64 *rawFile = OH_ResourceManager_OpenRawFile64(mNativeResMgr, filename.c_str()); + if (rawFile != nullptr) { + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "OH_ResourceManager_OpenRawFile64 success"); + } + long fileSize = OH_ResourceManager_GetRawFileSize64(rawFile); + long readLen = fileSize; + if (offset + length <= fileSize) { + OH_ResourceManager_SeekRawFile64(rawFile, offset, 0); + if (length != 0) { + readLen = length; + } + long currentOffset = OH_ResourceManager_GetRawFileOffset64(rawFile); + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetRawFileContent64, current rawfile offset = %{public}ld", + currentOffset); + } + std::unique_ptr data = std::make_unique(readLen); + int res = OH_ResourceManager_ReadRawFile64(rawFile, data.get(), readLen); + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetRawFileContent64, read size = %{public}d", res); + OH_ResourceManager_CloseRawFile64(rawFile); + OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); + return CreateJsArrayValue(env, data, fileSize); +} + +namespace { + napi_value createJsFileDescriptor(napi_env env, int navtieFd, int64_t nativeOffset, int64_t nativeLength) + { + napi_value result; + napi_status status = napi_create_object(env, &result); + if (status != napi_ok) { + return result; + } + + napi_value fd; + status = napi_create_int32(env, navtieFd, &fd); + if (status != napi_ok) { + return result; + } + status = napi_set_named_property(env, result, "fd", fd); + if (status != napi_ok) { + return result; + } + + napi_value offset; + status = napi_create_int64(env, nativeOffset, &offset); + if (status != napi_ok) { + return result; + } + status = napi_set_named_property(env, result, "offset", offset); + if (status != napi_ok) { + return result; + } + + napi_value length; + status = napi_create_int64(env, nativeLength, &length); + if (status != napi_ok) { + return result; + } + status = napi_set_named_property(env, result, "length", length); + if (status != napi_ok) { + return result; + } + return result; + } +} + +static napi_value GetRawFileDescriptor(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetRawFileDescriptor Begin"); + size_t argc = 2; + napi_value argv[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); + size_t strSize; + char strBuf[256]; + napi_get_value_string_utf8(env, argv[1], strBuf, sizeof(strBuf), &strSize); + std::string filename(strBuf, strSize); + RawFile *rawFile = OH_ResourceManager_OpenRawFile(mNativeResMgr, filename.c_str()); + if (rawFile != nullptr) { + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "OH_ResourceManager_OpenRawFile success"); + } + RawFileDescriptor descriptor; + OH_ResourceManager_GetRawFileDescriptor(rawFile, descriptor); + + OH_ResourceManager_CloseRawFile(rawFile); + OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); + return createJsFileDescriptor(env, descriptor.fd, descriptor.start, descriptor.length); +} + +static napi_value GetRawFileDescriptor64(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "GetRawFileDescriptor64 Begin"); + size_t argc = 2; + napi_value argv[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); + size_t strSize; + char strBuf[256]; + napi_get_value_string_utf8(env, argv[1], strBuf, sizeof(strBuf), &strSize); + std::string filename(strBuf, strSize); + RawFile64 *rawFile = OH_ResourceManager_OpenRawFile64(mNativeResMgr, filename.c_str()); + if (rawFile != nullptr) { + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "OH_ResourceManager_OpenRawFile64 success"); + } + RawFileDescriptor64 descriptor; + OH_ResourceManager_GetRawFileDescriptor64(rawFile, &descriptor); + + OH_ResourceManager_CloseRawFile64(rawFile); + OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); + return createJsFileDescriptor(env, descriptor.fd, descriptor.start, descriptor.length); +} + +namespace { + napi_valuetype GetValueType(napi_env env, napi_value value) + { + napi_valuetype valueType = napi_valuetype::napi_undefined; + napi_typeof(env, value, &valueType); + return valueType; + } + + void GetRawFileDescritorObject(napi_env env, napi_value value, int &nativeFd, int64_t &nativeOffset, + int64_t &nativeLength) + { + napi_value fd; + napi_status status = napi_get_named_property(env, value, "fd", &fd); + if (status == napi_ok && fd != nullptr && GetValueType(env, fd) == napi_number) { + napi_get_value_int32(env, fd, &nativeFd); + } + + napi_value offset; + status = napi_get_named_property(env, value, "offset", &offset); + if (status == napi_ok && offset != nullptr && GetValueType(env, offset) == napi_number) { + napi_get_value_int64(env, offset, &nativeOffset); + } + + napi_value length; + status = napi_get_named_property(env, value, "length", &length); + if (status == napi_ok && length != nullptr && GetValueType(env, length) == napi_number) { + napi_get_value_int64(env, length, &nativeLength); + } + } +} + +static napi_value ReleaseRawFileDescriptor(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "ReleaseRawFileDescriptor Begin"); + size_t argc = 2; + napi_value argv[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); + bool succeed = false; + if (GetValueType(env, argv[1]) == napi_object) { + RawFileDescriptor descriptor; + int64_t offset = 0; + int64_t length = 0; + GetRawFileDescritorObject(env, argv[1], descriptor.fd, offset, length); + descriptor.start = static_cast(offset); + descriptor.length = static_cast(length); + succeed = OH_ResourceManager_ReleaseRawFileDescriptor(descriptor); + } + OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); + napi_value result; + napi_get_boolean(env, succeed, &result); + return result; +} + +static napi_value ReleaseRawFileDescriptor64(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, GLOBAL_RESMGR, TAG, "ReleaseRawFileDescriptor64 Begin"); + size_t argc = 2; + napi_value argv[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); + + bool succeed = false; + if (GetValueType(env, argv[1]) == napi_object) { + RawFileDescriptor64 descriptor; + GetRawFileDescritorObject(env, argv[1], descriptor.fd, descriptor.start, descriptor.length); + succeed = OH_ResourceManager_ReleaseRawFileDescriptor64(&descriptor); + } + OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); + napi_value result; + napi_get_boolean(env, succeed, &result); + return result; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"getFileList", nullptr, GetFileList, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getRawFileContent", nullptr, GetRawFileContent, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getRawFileContent64", nullptr, GetRawFileContent64, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getRawFileDescriptor", nullptr, GetRawFileDescriptor, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getRawFileDescriptor64", nullptr, GetRawFileDescriptor64, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"releaseRawFileDescriptor", nullptr, ReleaseRawFileDescriptor, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"releaseRawFileDescriptor64", nullptr, ReleaseRawFileDescriptor64, nullptr, nullptr, nullptr, napi_default, + nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/types/libentry/index.d.ts b/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/types/libentry/index.d.ts index 422a08e6bb..20bbd4be0b 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import resourceManager from '@ohos.resourceManager'; - -export const getFileList: (resmgr: resourceManager.ResourceManager, path: string) => Array; - -export const getRawFileContent: (resmgr: resourceManager.ResourceManager, path: string, offset?: number, - length?: number) => Uint8Array; - -export const getRawFileContent64: (resmgr: resourceManager.ResourceManager, path: string, offset?: number, - length?: number) => Uint8Array; - -export const getRawFileDescriptor: (resmgr: resourceManager.ResourceManager, - path: string) => resourceManager.RawFileDescriptor; - -export const getRawFileDescriptor64: (resmgr: resourceManager.ResourceManager, - path: string) => resourceManager.RawFileDescriptor; - -export const releaseRawFileDescriptor: (resmgr: resourceManager.ResourceManager, - fd: resourceManager.RawFileDescriptor) => boolean; - -export const releaseRawFileDescriptor64: (resmgr: resourceManager.ResourceManager, +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import resourceManager from '@ohos.resourceManager'; + +export const getFileList: (resmgr: resourceManager.ResourceManager, path: string) => Array; + +export const getRawFileContent: (resmgr: resourceManager.ResourceManager, path: string, offset?: number, + length?: number) => Uint8Array; + +export const getRawFileContent64: (resmgr: resourceManager.ResourceManager, path: string, offset?: number, + length?: number) => Uint8Array; + +export const getRawFileDescriptor: (resmgr: resourceManager.ResourceManager, + path: string) => resourceManager.RawFileDescriptor; + +export const getRawFileDescriptor64: (resmgr: resourceManager.ResourceManager, + path: string) => resourceManager.RawFileDescriptor; + +export const releaseRawFileDescriptor: (resmgr: resourceManager.ResourceManager, + fd: resourceManager.RawFileDescriptor) => boolean; + +export const releaseRawFileDescriptor64: (resmgr: resourceManager.ResourceManager, fd: resourceManager.RawFileDescriptor) => boolean; \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/types/libentry/oh-package.json5 index ed45298dd9..59c4439149 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/BasicFeature/Native/NdkRawfile/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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." +/* + * Copyright (c) 2023 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/BasicFeature/Native/NdkRawfile/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/entryability/EntryAbility.ets index 1e60fbb8de..90055cc7ff 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import { Logger } from '../utils/Logger'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - Logger.info('Ability onCreate'); - } - - onDestroy() { - Logger.info('Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - Logger.info('Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - Logger.error('Failed to load the content. Cause: ' + JSON.stringify(err)); - return; - } - Logger.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - Logger.info('Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - Logger.info('Ability onForeground'); - } - - onBackground() { - // Ability has back to background - Logger.info('Ability onBackground'); - } -}; +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import { Logger } from '../utils/Logger'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + Logger.info('Ability onCreate'); + } + + onDestroy() { + Logger.info('Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + Logger.info('Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error('Failed to load the content. Cause: ' + JSON.stringify(err)); + return; + } + Logger.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + Logger.info('Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + Logger.info('Ability onForeground'); + } + + onBackground() { + // Ability has back to background + Logger.info('Ability onBackground'); + } +}; diff --git a/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/pages/Index.ets index 89bee28fc4..5e11e2ddc8 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/pages/Index.ets @@ -1,139 +1,139 @@ -/* - * Copyright (c) 2023 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'; -import resourceManager from '@ohos.resourceManager'; -import { util } from '@kit.ArkTS'; -import { Logger } from '../utils/Logger'; - -@Entry -@Component -struct Index { - private resMgr: resourceManager.ResourceManager = getContext().resourceManager; - private rawFileList: string = ''; - private rawFileContent: string = ''; - private rawFileDescriptor: resourceManager.RawFileDescriptor | undefined = undefined; - private rawFileContentWithOffset: string = ''; - private rawFileContent64: string = ''; - private rawFileDescriptor64: resourceManager.RawFileDescriptor | undefined = undefined; - private rawFileContentWithOffset64: string = ''; - - aboutToAppear() { - let textDecoder = new util.TextDecoder(); - // get raw file list - this.rawFileList = JSON.stringify(testNapi.getFileList(this.resMgr, '')); - - // get content of rawfile.txt - let rawFileArray = testNapi.getRawFileContent(this.resMgr, 'rawfile.txt'); - this.rawFileContent = textDecoder.decodeToString(rawFileArray); - - // get raw file descriptor of rawfile.txt - this.rawFileDescriptor = testNapi.getRawFileDescriptor(this.resMgr, 'rawfile.txt'); - - // get content of rawfile.txt with offset 3 - rawFileArray = testNapi.getRawFileContent(this.resMgr, 'rawfile.txt', 3); - this.rawFileContentWithOffset = textDecoder.decodeToString(rawFileArray); - - // get content of rawfile1.txt by getRawFileContent64 - rawFileArray = testNapi.getRawFileContent64(this.resMgr, 'rawfile1.txt'); - this.rawFileContent64 = textDecoder.decodeToString(rawFileArray); - - // get raw file descriptor of rawfile1.txt by getRawFileDescriptor64 - this.rawFileDescriptor64 = testNapi.getRawFileDescriptor64(this.resMgr, 'rawfile1.txt'); - - // get content of rawfile1.txt by getRawFileContent64 with offset 6 - rawFileArray = testNapi.getRawFileContent64(this.resMgr, 'rawfile1.txt', 8); - this.rawFileContentWithOffset64 = textDecoder.decodeToString(rawFileArray); - } - - aboutToDisappear(): boolean | void { - Logger.info('aboutToDisappear'); - if (this.rawFileDescriptor) { - let result = testNapi.releaseRawFileDescriptor(this.resMgr, this.rawFileDescriptor); - Logger.info(`releaseRawFileDescriptor: ${result}`); - } - - if (this.rawFileDescriptor64) { - let result = testNapi.releaseRawFileDescriptor64(this.resMgr, this.rawFileDescriptor64); - Logger.info(`releaseRawFileDescriptor64: ${result}`); - } - } - - build() { - Row() { - Column() { - Text('file list: ' + this.rawFileList) - .id('raw_file_list') - .fontSize(20) - .width('100%') - .margin({ bottom: 15 }) - Text('rawfile.txt content: ' + this.rawFileContent) - .id('raw_file_content') - .fontSize(20) - .width('100%') - .margin({ bottom: 15 }) - Text('rawfile.txt content with offset: ' + this.rawFileContentWithOffset) - .id('raw_file_content_offset') - .fontSize(20) - .width('100%') - .margin({ bottom: 15 }) - Text('rawfile.txt fd: ' + this.rawFileDescriptor?.fd) - .id('raw_file_fd') - .fontSize(20) - .width('100%') - .margin({ bottom: 15 }) - Text('rawfile.txt fd.offset: ' + this.rawFileDescriptor?.offset) - .id('raw_file_fd_offset') - .fontSize(20) - .width('100%') - .margin({ bottom: 15 }) - Text('rawfile.txt fd.length: ' + this.rawFileDescriptor?.length) - .id('raw_file_fd_length') - .fontSize(20) - .width('100%') - .margin({ bottom: 15 }) - - Text('rawfile.txt content64: ' + this.rawFileContent64) - .id('raw_file_content64') - .fontSize(20) - .width('100%') - .margin({ bottom: 15, top: 15 }) - Text('rawfile.txt content with offset64: ' + this.rawFileContentWithOffset64) - .id('raw_file_content_offset64') - .fontSize(20) - .width('100%') - .margin({ bottom: 15 }) - Text('rawfile.txt fd64: ' + this.rawFileDescriptor64?.fd) - .id('raw_file_fd64') - .fontSize(20) - .width('100%') - .margin({ bottom: 15 }) - Text('rawfile.txt fd.offset64: ' + this.rawFileDescriptor64?.offset) - .id('raw_file_fd_offset64') - .fontSize(20) - .width('100%') - .margin({ bottom: 15 }) - Text('rawfile.txt fd.length64: ' + this.rawFileDescriptor64?.length) - .id('raw_file_fd_length64') - .fontSize(20) - .width('100%') - .margin({ bottom: 15 }) - } - .padding({ left: 15, right: 15 }) - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2023 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'; +import resourceManager from '@ohos.resourceManager'; +import { util } from '@kit.ArkTS'; +import { Logger } from '../utils/Logger'; + +@Entry +@Component +struct Index { + private resMgr: resourceManager.ResourceManager = getContext().resourceManager; + private rawFileList: string = ''; + private rawFileContent: string = ''; + private rawFileDescriptor: resourceManager.RawFileDescriptor | undefined = undefined; + private rawFileContentWithOffset: string = ''; + private rawFileContent64: string = ''; + private rawFileDescriptor64: resourceManager.RawFileDescriptor | undefined = undefined; + private rawFileContentWithOffset64: string = ''; + + aboutToAppear() { + let textDecoder = new util.TextDecoder(); + // get raw file list + this.rawFileList = JSON.stringify(testNapi.getFileList(this.resMgr, '')); + + // get content of rawfile.txt + let rawFileArray = testNapi.getRawFileContent(this.resMgr, 'rawfile.txt'); + this.rawFileContent = textDecoder.decodeToString(rawFileArray); + + // get raw file descriptor of rawfile.txt + this.rawFileDescriptor = testNapi.getRawFileDescriptor(this.resMgr, 'rawfile.txt'); + + // get content of rawfile.txt with offset 3 + rawFileArray = testNapi.getRawFileContent(this.resMgr, 'rawfile.txt', 3); + this.rawFileContentWithOffset = textDecoder.decodeToString(rawFileArray); + + // get content of rawfile1.txt by getRawFileContent64 + rawFileArray = testNapi.getRawFileContent64(this.resMgr, 'rawfile1.txt'); + this.rawFileContent64 = textDecoder.decodeToString(rawFileArray); + + // get raw file descriptor of rawfile1.txt by getRawFileDescriptor64 + this.rawFileDescriptor64 = testNapi.getRawFileDescriptor64(this.resMgr, 'rawfile1.txt'); + + // get content of rawfile1.txt by getRawFileContent64 with offset 6 + rawFileArray = testNapi.getRawFileContent64(this.resMgr, 'rawfile1.txt', 8); + this.rawFileContentWithOffset64 = textDecoder.decodeToString(rawFileArray); + } + + aboutToDisappear(): boolean | void { + Logger.info('aboutToDisappear'); + if (this.rawFileDescriptor) { + let result = testNapi.releaseRawFileDescriptor(this.resMgr, this.rawFileDescriptor); + Logger.info(`releaseRawFileDescriptor: ${result}`); + } + + if (this.rawFileDescriptor64) { + let result = testNapi.releaseRawFileDescriptor64(this.resMgr, this.rawFileDescriptor64); + Logger.info(`releaseRawFileDescriptor64: ${result}`); + } + } + + build() { + Row() { + Column() { + Text('file list: ' + this.rawFileList) + .id('raw_file_list') + .fontSize(20) + .width('100%') + .margin({ bottom: 15 }) + Text('rawfile.txt content: ' + this.rawFileContent) + .id('raw_file_content') + .fontSize(20) + .width('100%') + .margin({ bottom: 15 }) + Text('rawfile.txt content with offset: ' + this.rawFileContentWithOffset) + .id('raw_file_content_offset') + .fontSize(20) + .width('100%') + .margin({ bottom: 15 }) + Text('rawfile.txt fd: ' + this.rawFileDescriptor?.fd) + .id('raw_file_fd') + .fontSize(20) + .width('100%') + .margin({ bottom: 15 }) + Text('rawfile.txt fd.offset: ' + this.rawFileDescriptor?.offset) + .id('raw_file_fd_offset') + .fontSize(20) + .width('100%') + .margin({ bottom: 15 }) + Text('rawfile.txt fd.length: ' + this.rawFileDescriptor?.length) + .id('raw_file_fd_length') + .fontSize(20) + .width('100%') + .margin({ bottom: 15 }) + + Text('rawfile.txt content64: ' + this.rawFileContent64) + .id('raw_file_content64') + .fontSize(20) + .width('100%') + .margin({ bottom: 15, top: 15 }) + Text('rawfile.txt content with offset64: ' + this.rawFileContentWithOffset64) + .id('raw_file_content_offset64') + .fontSize(20) + .width('100%') + .margin({ bottom: 15 }) + Text('rawfile.txt fd64: ' + this.rawFileDescriptor64?.fd) + .id('raw_file_fd64') + .fontSize(20) + .width('100%') + .margin({ bottom: 15 }) + Text('rawfile.txt fd.offset64: ' + this.rawFileDescriptor64?.offset) + .id('raw_file_fd_offset64') + .fontSize(20) + .width('100%') + .margin({ bottom: 15 }) + Text('rawfile.txt fd.length64: ' + this.rawFileDescriptor64?.length) + .id('raw_file_fd_length64') + .fontSize(20) + .width('100%') + .margin({ bottom: 15 }) + } + .padding({ left: 15, right: 15 }) + .width('100%') + } + .height('100%') + } +} diff --git a/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/utils/Logger.ets b/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/utils/Logger.ets index 92d6c87204..727e11a9fe 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/utils/Logger.ets +++ b/code/BasicFeature/Native/NdkRawfile/entry/src/main/ets/utils/Logger.ets @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class LoggerModel { - private domain: number - private prefix: string - - constructor(prefix: string) { - this.prefix = prefix - this.domain = 0xFF00 - } - - debug(message: string): void { - hilog.debug(this.domain, this.prefix, message) - } - - info(message: string): void { - hilog.info(this.domain, this.prefix, message) - } - - warn(message: string): void { - hilog.warn(this.domain, this.prefix, message) - } - - error(message: string): void { - hilog.error(this.domain, this.prefix, message) - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class LoggerModel { + private domain: number + private prefix: string + + constructor(prefix: string) { + this.prefix = prefix + this.domain = 0xFF00 + } + + debug(message: string): void { + hilog.debug(this.domain, this.prefix, message) + } + + info(message: string): void { + hilog.info(this.domain, this.prefix, message) + } + + warn(message: string): void { + hilog.warn(this.domain, this.prefix, message) + } + + error(message: string): void { + hilog.error(this.domain, this.prefix, message) + } +} + export let Logger = new LoggerModel('[Sample_rawfile]') \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkRawfile/entry/src/main/module.json5 b/code/BasicFeature/Native/NdkRawfile/entry/src/main/module.json5 index d0ae81f782..7dadb23955 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/src/main/module.json5 +++ b/code/BasicFeature/Native/NdkRawfile/entry/src/main/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 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:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkRawfile/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Native/NdkRawfile/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Native/NdkRawfile/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkRawfile/entry/src/ohosTest/module.json5 b/code/BasicFeature/Native/NdkRawfile/entry/src/ohosTest/module.json5 index 404ccf0b4c..fb9aa43871 100644 --- a/code/BasicFeature/Native/NdkRawfile/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Native/NdkRawfile/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/Native/NdkRawfile/hvigor/hvigor-config.json5 b/code/BasicFeature/Native/NdkRawfile/hvigor/hvigor-config.json5 index b4886e292b..f70ecd4112 100644 --- a/code/BasicFeature/Native/NdkRawfile/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Native/NdkRawfile/hvigor/hvigor-config.json5 @@ -1,5 +1,5 @@ -{ - "modelVersion": "5.0.0", - "dependencies": { - } +{ + "modelVersion": "5.0.0", + "dependencies": { + } } \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkRawfile/oh-package.json5 b/code/BasicFeature/Native/NdkRawfile/oh-package.json5 index 1471fd4176..3aace6cb34 100644 --- a/code/BasicFeature/Native/NdkRawfile/oh-package.json5 +++ b/code/BasicFeature/Native/NdkRawfile/oh-package.json5 @@ -1,13 +1,13 @@ -{ - "modelVersion": "5.0.0", - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "ndkrawfile", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {}, +{ + "modelVersion": "5.0.0", + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "ndkrawfile", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {}, } \ No newline at end of file diff --git a/code/BasicFeature/Native/XComponent/AppScope/app.json5 b/code/BasicFeature/Native/XComponent/AppScope/app.json5 index 0a8fcde3de..2db2ac3fc1 100644 --- a/code/BasicFeature/Native/XComponent/AppScope/app.json5 +++ b/code/BasicFeature/Native/XComponent/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.xcomponent", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.xcomponent", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Native/XComponent/AppScope/resources/base/element/string.json b/code/BasicFeature/Native/XComponent/AppScope/resources/base/element/string.json index 2e13d1ee4a..001dc15a00 100644 --- a/code/BasicFeature/Native/XComponent/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Native/XComponent/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "XComponent" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "XComponent" + } + ] +} diff --git a/code/BasicFeature/Native/XComponent/build-profile.json5 b/code/BasicFeature/Native/XComponent/build-profile.json5 index e521599d36..11ce79f476 100644 --- a/code/BasicFeature/Native/XComponent/build-profile.json5 +++ b/code/BasicFeature/Native/XComponent/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/XComponent/entry/build-profile.json5 b/code/BasicFeature/Native/XComponent/entry/build-profile.json5 index 197f714fe6..5e7f93790e 100644 --- a/code/BasicFeature/Native/XComponent/entry/build-profile.json5 +++ b/code/BasicFeature/Native/XComponent/entry/build-profile.json5 @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2023-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" - ] - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023-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" + ] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Native/XComponent/entry/oh-package.json5 b/code/BasicFeature/Native/XComponent/entry/oh-package.json5 index 60744fdbc7..225946cb11 100644 --- a/code/BasicFeature/Native/XComponent/entry/oh-package.json5 +++ b/code/BasicFeature/Native/XComponent/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Native/XComponent/entry/src/main/module.json5 b/code/BasicFeature/Native/XComponent/entry/src/main/module.json5 index a61f5cbf7c..bac72d9592 100644 --- a/code/BasicFeature/Native/XComponent/entry/src/main/module.json5 +++ b/code/BasicFeature/Native/XComponent/entry/src/main/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 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" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Native/XComponent/hvigor/hvigor-config.json5 b/code/BasicFeature/Native/XComponent/hvigor/hvigor-config.json5 index 2e97c54288..a2eb20c67c 100644 --- a/code/BasicFeature/Native/XComponent/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Native/XComponent/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.1.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.1.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.1.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.1.2" + } } \ No newline at end of file diff --git a/code/BasicFeature/Native/XComponent/oh-package.json5 b/code/BasicFeature/Native/XComponent/oh-package.json5 index f1a08086d6..179cf11eec 100644 --- a/code/BasicFeature/Native/XComponent/oh-package.json5 +++ b/code/BasicFeature/Native/XComponent/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "ndkxcomponent", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "ndkxcomponent", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Notification/CustomCommonEvent/README_zh.md b/code/BasicFeature/Notification/CustomCommonEvent/README_zh.md index c33d04bc0e..998a783316 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/README_zh.md +++ b/code/BasicFeature/Notification/CustomCommonEvent/README_zh.md @@ -1,167 +1,167 @@ -# 事件的订阅和发布 - -### 介绍 - -本示例主要展示了公共事件相关的功能,实现了一个检测用户部分行为的应用。具体而言实现了如下几点功能: - -1.通过订阅系统公共事件,实现对用户操作行为(亮灭屏、锁屏和解锁屏幕、断联网)的监测; - -2.通过在用户主动停止监测行为时发布自定义有序公共事件,实现对用户主动触发监听行为的持久化记录; - -3.通过在用户设置对某一事件的监听状态时发布粘性事件,记录下本次应用运行期间允许监听的事件列表,同时在应用退出时将临时允许的修改为不允许; - -4.打开自定义订阅事件页面需先安装[CardEvent](lib/CardEvent-1.0.0.hap)应用,通过订阅指定应用事件,实现用户对指定卡片发送事件的监听。 - -### 效果预览 - -##### 订阅系统公共事件,主动停止监听行为及对某一事件的监听状态时发布粘性事件 - -| 主页 | 监控页面 | 设置页面 | 自定义订阅事件页面 | -| ------------------------------------ | ---------------------------------- | -------------------------------------- | ----------------------------------- | -| | | | | - -使用说明: - -1.安装编译生成的hap包,依赖包hap,桌面上显示应用图标如下,点击图标即可进入应用。 - - - - - -2.进入应用显示菜单页,可选择“进入”,“历史”,“设置”及“关于”几个选项。 - -3.点击“进入”后跳转至主页面,点击主页面“开始监控”按钮,将开始监听系统公共事件,并进行计时,此时按钮内容变更为“停止监听”;点击停止监听按钮,页面上将显示本次监听时长及监听期间收到的干扰信息汇总,并在页面右下角显示“查看详情”按钮,点击按钮将跳转至详情页,显示监听期间收到的干扰信息,应用当前仅监听了亮灭屏、锁屏和解锁屏幕、断联网等用户可操作的系统公共事件,后续可根据需求快速扩展。 - -4.返回至应用菜单页面,点击“历史”可查看用户操作监听的历史记录,当前支持每次运行期间最多存储10条历史记录,超过10条后将删除历史数据。 - -5.返回至应用菜单页面,点击“设置”可进行具体系统事件的监听配置,应用提供了“一直”、“仅本次”及“从不”三个选项,其中“仅本次”选项是指本次应用运行期间将监听特定系统公共事件,应用退出后该选项将自动调整为“从不”。 - -6.在设置页面,点击“自定义事件定向订阅”进入订阅页面, - -- 点击”订阅“按钮进行订阅事件,同时订阅指定本应用事件和订阅非指定应用事件。 - -- 点击应用内卡片发送事件或点击应用外卡片发送事件。 - -- 点击应用内卡片发送事件后,指定应用事件和非指定应用事件均会接收到卡片所发送的事件 ;点击应用外卡片发送事件后,非指定应用事件会被接收,指定应用事件不会被接收。 - -- 点击”取消订阅“ 页面中会提示当前事件取消订阅。 - -7.返回至应用菜单页面,点击“关于”可查看应用版本信息及本示例的说明。 - -### 工程目录 - -**CustomCommonEvent** - -``` -entry/src/main/ets/ -|---Application -| |---MyAbilityStage.ts -|---component -| |---Header.ets // 头部组件 -|---entryformability -| |---EntryFormAbility.ts // 卡片提供方 -|---feature -| |---HistoryFeature.ts -| |---LaunchFeature.ts -| |---MainFeature.ts -| |---SettingFeature.ts -|---LauncherAbility -| |---LauncherAbility.ts -|---MainAbility -| |---MainAbility.ts -|---model -| |---Consts.ts // 数据定义 -| |---Logger.ts // 日志打印 -| |---SurveillanceEventsManager.ts // 公共事件模块 -| |---Utils.ts -|---pages -| |---About.ets // 关于页面 -| |---Detail.ets // 详情页面 -| |---History.ets // 历史页面 -| |---jumpToCommonEvent.ets // 自定义订阅事件页面 -| |---Launch.ets // 发起页面 -| |---Main.ets // 进入页面 -| |---Setting.ets // 设置页面 -|---publishcard -| |---pages -| | |---PublishCard.ets // 卡片页面 -``` - -**CustomCommonEventRely** - -``` -entry/src/main/ets/ -|---entryformability -| |---EntryFormAbility.ts // 发布事件 -|---pages -| |---Index.ets -|---widget -| |---pages -| | |---PublishCard.ets // 发布事件的卡片 -``` - - - -### 具体实现 - -* 该示例entry部分分为五个模块: - * 进入模块 - * 使用到应用文上下文,createSubscriber方法创建订阅者,getCurrentTime获取获取自Unix纪元以来经过的时间进行对用户操作行为的监测功能页面开发。 - * 源码链接:[Consts.ts](entry/src/main/ets/module/Consts.ts),[LaunchFeature.ts](entry/src/main/ets/feature/LaunchFeature.ts),[LauncherAbility.ts](entry/src/main/ets/LauncherAbility/LauncherAbility.ts),[SurveillanceEventsManager.ts](entry/src/main/ets/module/SurveillanceEventsManager.ts) - * 参考接口:[@ohos.app.ability.common](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-common.md),[@ohos.commonEventManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-commonEventManager.md),[@ohos.data.preferences](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-data-preferences.md),[@ohos.commonEvent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-commonEvent.md),[@ohos.router](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-router.md),[@ohos.systemTime](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-system-timer-sys.md) - - * 历史模块 - * 使用到应用文上下文,getPreferences方法获取Preferences实例,组件Header进行历史页面开发。 - * 源码链接:[Header.ets](entry/src/main/ets/component/Header.ets),[Consts.ts](entry/src/main/ets/module/Consts.ts),[HistoryFeature.ts](entry/src/main/ets/feature/HistoryFeature.ts) - * 参考接口:[@ohos.app.ability.common](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-common.md),[@ohos.data.preferences](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-data-preferences.md) - - * 设置模块 - * 本模块分为三个事件,分别为记录联网事件,记录灭屏事件,记录亮屏事件,进行锁屏事件、进行解锁屏幕事件,每一个事件都可进行一直,仅本次和从不的单项选择,使用到应用文上下文吗,CommonEvent.publish发布公共事件,getPreferences方法获取Preferences实例进行功能页面开发。 - * 源码链接:[Header.ets](entry/src/main/ets/component/Header.ets),[Consts.ts](entry/src/main/ets/module/Consts.ts),[SettingFeature.ts](entry/src/main/ets/feature/SettingFeature.ts),[SurveillanceEventsManager.ts](entry/src/main/ets/module/SurveillanceEventsManager.ts) - * 参考接口:[@ohos.app.ability.common](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-common.md),[@ohos.data.preferences](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-data-preferences.md),[@ohos.commonEvent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-commonEvent.md),[@ohos.router](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-router.md),[@ohos.commonEvent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-commonEvent.md) - - * 关于模块 - * 该模块开发主要介绍了本示例的功能作用以及说明了什么情况下不能使用。 - * 源码链接:[Header.ets](https://gitee.com/openharmony/applications_app_samples/blob/master/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/component/Header.ets),[Consts.ts](https://gitee.com/openharmony/applications_app_samples/blob/master/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/module/Consts.ts) - - - 设置中订阅事件模块 - - 本模块主要支持指定应用订阅自定义事件。subScribeInfo新增可选属性publisherBundleName,创建订阅对象时可指定PublisherBundlerName,事件发布时,获取订阅者信息,增加校验bundleName是否等于publisherBundlerName,相等则加入事件回调方,达成只接收指定发布方发布的事件的效果。 - - 源码链接:[EntryFormAbility.ts](entry/src/main/ets/entryformability/EntryFormAbility.ts),[Main.ets](entry/src/main/ets/pages/Main.ets),[PublishCard.ets](entry/src/main/ets/publishcard/pages/PublishCard.ets) - - 参考接口:[@ohos.commonEventManager](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-commonEventManager.md),[@ohos.hilog](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-hilog.md),[@ohos.app.form.formInfo](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-form-kit/js-apis-app-form-formInfo.md),[@ohos.app.form.formBindingData](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-form-kit/js-apis-app-form-formBindingData.md),[@ohos.app.form.FormExtensionAbility](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-form-kit/js-apis-app-form-formExtensionAbility.md) - - - -### 相关权限 - -[ohos.permission.COMMONEVENT_STICKY](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioncommonevent_sticky) - -[ohos.permission.REQUIRE_FORM](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionrequire_form) - -[ohos.permission.GET_BUNDLE_INFO_PRIVILEGED](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_bundle_info_privileged) - -### 依赖 - -本应用依赖[CustomCommonEventRely](../CustomCommonEventRely)应用进行运行。 - - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568。 - -2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.3.1; - -3.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行; - -4.本示例涉及[ohos.permission.REQUIRE_FORM](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionrequire_form)和[ohos.permission.GET_BUNDLE_INFO_PRIVILEGED](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_bundle_info_privileged)权限为system_basic级别,需要配置高权限签名; - -### 下载 - -如需单独下载本工程,执行如下命令: -``` -git init -git config core.sparsecheckout true -echo code/BasicFeature/Notification/CustomCommonEvent/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master - +# 事件的订阅和发布 + +### 介绍 + +本示例主要展示了公共事件相关的功能,实现了一个检测用户部分行为的应用。具体而言实现了如下几点功能: + +1.通过订阅系统公共事件,实现对用户操作行为(亮灭屏、锁屏和解锁屏幕、断联网)的监测; + +2.通过在用户主动停止监测行为时发布自定义有序公共事件,实现对用户主动触发监听行为的持久化记录; + +3.通过在用户设置对某一事件的监听状态时发布粘性事件,记录下本次应用运行期间允许监听的事件列表,同时在应用退出时将临时允许的修改为不允许; + +4.打开自定义订阅事件页面需先安装[CardEvent](lib/CardEvent-1.0.0.hap)应用,通过订阅指定应用事件,实现用户对指定卡片发送事件的监听。 + +### 效果预览 + +##### 订阅系统公共事件,主动停止监听行为及对某一事件的监听状态时发布粘性事件 + +| 主页 | 监控页面 | 设置页面 | 自定义订阅事件页面 | +| ------------------------------------ | ---------------------------------- | -------------------------------------- | ----------------------------------- | +| | | | | + +使用说明: + +1.安装编译生成的hap包,依赖包hap,桌面上显示应用图标如下,点击图标即可进入应用。 + + + + + +2.进入应用显示菜单页,可选择“进入”,“历史”,“设置”及“关于”几个选项。 + +3.点击“进入”后跳转至主页面,点击主页面“开始监控”按钮,将开始监听系统公共事件,并进行计时,此时按钮内容变更为“停止监听”;点击停止监听按钮,页面上将显示本次监听时长及监听期间收到的干扰信息汇总,并在页面右下角显示“查看详情”按钮,点击按钮将跳转至详情页,显示监听期间收到的干扰信息,应用当前仅监听了亮灭屏、锁屏和解锁屏幕、断联网等用户可操作的系统公共事件,后续可根据需求快速扩展。 + +4.返回至应用菜单页面,点击“历史”可查看用户操作监听的历史记录,当前支持每次运行期间最多存储10条历史记录,超过10条后将删除历史数据。 + +5.返回至应用菜单页面,点击“设置”可进行具体系统事件的监听配置,应用提供了“一直”、“仅本次”及“从不”三个选项,其中“仅本次”选项是指本次应用运行期间将监听特定系统公共事件,应用退出后该选项将自动调整为“从不”。 + +6.在设置页面,点击“自定义事件定向订阅”进入订阅页面, + +- 点击”订阅“按钮进行订阅事件,同时订阅指定本应用事件和订阅非指定应用事件。 + +- 点击应用内卡片发送事件或点击应用外卡片发送事件。 + +- 点击应用内卡片发送事件后,指定应用事件和非指定应用事件均会接收到卡片所发送的事件 ;点击应用外卡片发送事件后,非指定应用事件会被接收,指定应用事件不会被接收。 + +- 点击”取消订阅“ 页面中会提示当前事件取消订阅。 + +7.返回至应用菜单页面,点击“关于”可查看应用版本信息及本示例的说明。 + +### 工程目录 + +**CustomCommonEvent** + +``` +entry/src/main/ets/ +|---Application +| |---MyAbilityStage.ts +|---component +| |---Header.ets // 头部组件 +|---entryformability +| |---EntryFormAbility.ts // 卡片提供方 +|---feature +| |---HistoryFeature.ts +| |---LaunchFeature.ts +| |---MainFeature.ts +| |---SettingFeature.ts +|---LauncherAbility +| |---LauncherAbility.ts +|---MainAbility +| |---MainAbility.ts +|---model +| |---Consts.ts // 数据定义 +| |---Logger.ts // 日志打印 +| |---SurveillanceEventsManager.ts // 公共事件模块 +| |---Utils.ts +|---pages +| |---About.ets // 关于页面 +| |---Detail.ets // 详情页面 +| |---History.ets // 历史页面 +| |---jumpToCommonEvent.ets // 自定义订阅事件页面 +| |---Launch.ets // 发起页面 +| |---Main.ets // 进入页面 +| |---Setting.ets // 设置页面 +|---publishcard +| |---pages +| | |---PublishCard.ets // 卡片页面 +``` + +**CustomCommonEventRely** + +``` +entry/src/main/ets/ +|---entryformability +| |---EntryFormAbility.ts // 发布事件 +|---pages +| |---Index.ets +|---widget +| |---pages +| | |---PublishCard.ets // 发布事件的卡片 +``` + + + +### 具体实现 + +* 该示例entry部分分为五个模块: + * 进入模块 + * 使用到应用文上下文,createSubscriber方法创建订阅者,getCurrentTime获取获取自Unix纪元以来经过的时间进行对用户操作行为的监测功能页面开发。 + * 源码链接:[Consts.ts](entry/src/main/ets/module/Consts.ts),[LaunchFeature.ts](entry/src/main/ets/feature/LaunchFeature.ts),[LauncherAbility.ts](entry/src/main/ets/LauncherAbility/LauncherAbility.ts),[SurveillanceEventsManager.ts](entry/src/main/ets/module/SurveillanceEventsManager.ts) + * 参考接口:[@ohos.app.ability.common](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-common.md),[@ohos.commonEventManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-commonEventManager.md),[@ohos.data.preferences](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-data-preferences.md),[@ohos.commonEvent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-commonEvent.md),[@ohos.router](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-router.md),[@ohos.systemTime](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-system-timer-sys.md) + + * 历史模块 + * 使用到应用文上下文,getPreferences方法获取Preferences实例,组件Header进行历史页面开发。 + * 源码链接:[Header.ets](entry/src/main/ets/component/Header.ets),[Consts.ts](entry/src/main/ets/module/Consts.ts),[HistoryFeature.ts](entry/src/main/ets/feature/HistoryFeature.ts) + * 参考接口:[@ohos.app.ability.common](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-common.md),[@ohos.data.preferences](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-data-preferences.md) + + * 设置模块 + * 本模块分为三个事件,分别为记录联网事件,记录灭屏事件,记录亮屏事件,进行锁屏事件、进行解锁屏幕事件,每一个事件都可进行一直,仅本次和从不的单项选择,使用到应用文上下文吗,CommonEvent.publish发布公共事件,getPreferences方法获取Preferences实例进行功能页面开发。 + * 源码链接:[Header.ets](entry/src/main/ets/component/Header.ets),[Consts.ts](entry/src/main/ets/module/Consts.ts),[SettingFeature.ts](entry/src/main/ets/feature/SettingFeature.ts),[SurveillanceEventsManager.ts](entry/src/main/ets/module/SurveillanceEventsManager.ts) + * 参考接口:[@ohos.app.ability.common](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-common.md),[@ohos.data.preferences](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-data-preferences.md),[@ohos.commonEvent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-commonEvent.md),[@ohos.router](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-router.md),[@ohos.commonEvent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-commonEvent.md) + + * 关于模块 + * 该模块开发主要介绍了本示例的功能作用以及说明了什么情况下不能使用。 + * 源码链接:[Header.ets](https://gitee.com/openharmony/applications_app_samples/blob/master/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/component/Header.ets),[Consts.ts](https://gitee.com/openharmony/applications_app_samples/blob/master/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/module/Consts.ts) + + - 设置中订阅事件模块 + - 本模块主要支持指定应用订阅自定义事件。subScribeInfo新增可选属性publisherBundleName,创建订阅对象时可指定PublisherBundlerName,事件发布时,获取订阅者信息,增加校验bundleName是否等于publisherBundlerName,相等则加入事件回调方,达成只接收指定发布方发布的事件的效果。 + - 源码链接:[EntryFormAbility.ts](entry/src/main/ets/entryformability/EntryFormAbility.ts),[Main.ets](entry/src/main/ets/pages/Main.ets),[PublishCard.ets](entry/src/main/ets/publishcard/pages/PublishCard.ets) + - 参考接口:[@ohos.commonEventManager](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-commonEventManager.md),[@ohos.hilog](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-hilog.md),[@ohos.app.form.formInfo](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-form-kit/js-apis-app-form-formInfo.md),[@ohos.app.form.formBindingData](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-form-kit/js-apis-app-form-formBindingData.md),[@ohos.app.form.FormExtensionAbility](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-form-kit/js-apis-app-form-formExtensionAbility.md) + + + +### 相关权限 + +[ohos.permission.COMMONEVENT_STICKY](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioncommonevent_sticky) + +[ohos.permission.REQUIRE_FORM](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionrequire_form) + +[ohos.permission.GET_BUNDLE_INFO_PRIVILEGED](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_bundle_info_privileged) + +### 依赖 + +本应用依赖[CustomCommonEventRely](../CustomCommonEventRely)应用进行运行。 + + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568。 + +2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.3.1; + +3.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行; + +4.本示例涉及[ohos.permission.REQUIRE_FORM](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionrequire_form)和[ohos.permission.GET_BUNDLE_INFO_PRIVILEGED](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_bundle_info_privileged)权限为system_basic级别,需要配置高权限签名; + +### 下载 + +如需单独下载本工程,执行如下命令: +``` +git init +git config core.sparsecheckout true +echo code/BasicFeature/Notification/CustomCommonEvent/ > .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/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/entryformability/EntryFormAbility.ts b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/entryformability/EntryFormAbility.ts index f9904eb38e..a300710819 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/entryformability/EntryFormAbility.ts +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/entryformability/EntryFormAbility.ts @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2023 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 formInfo from '@ohos.app.form.formInfo'; -import formBindingData from '@ohos.app.form.formBindingData'; -import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; -import commonEvent from '@ohos.commonEventManager'; -import Logger from '../module/Logger'; - -export default class EntryFormAbility extends FormExtensionAbility { - onAddForm(want) { - // Called to return a FormBindingData object. - let formData = {}; - return formBindingData.createFormBindingData(formData); - } - - onCastToNormalForm(formId) { - // Called when the form provider is notified that a temporary form is successfully - // converted to a normal form. - } - - onUpdateForm(formId) { - // Called to notify the form provider to update a specified form. - } - - onChangeFormVisibility(newStatus) { - // Called when the form provider receives form events from the system. - } - - onFormEvent(formId, message) { - let options = { - data: 'InApp' - }; - commonEvent.publish('Acts_CommonEvent_Test', options, async () => { - Logger.info('publish Acts_CommonEvent_Test InApp'); - }); - // Called when a specified message event defined by the form provider is triggered. - } - - onRemoveForm(formId) { - // Called to notify the form provider that a specified form has been destroyed. - } - - onAcquireFormState(want) { - // Called to return a {@link FormState} object. - return formInfo.FormState.READY; - } +/* + * Copyright (c) 2023 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 formInfo from '@ohos.app.form.formInfo'; +import formBindingData from '@ohos.app.form.formBindingData'; +import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; +import commonEvent from '@ohos.commonEventManager'; +import Logger from '../module/Logger'; + +export default class EntryFormAbility extends FormExtensionAbility { + onAddForm(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormalForm(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdateForm(formId) { + // Called to notify the form provider to update a specified form. + } + + onChangeFormVisibility(newStatus) { + // Called when the form provider receives form events from the system. + } + + onFormEvent(formId, message) { + let options = { + data: 'InApp' + }; + commonEvent.publish('Acts_CommonEvent_Test', options, async () => { + Logger.info('publish Acts_CommonEvent_Test InApp'); + }); + // Called when a specified message event defined by the form provider is triggered. + } + + onRemoveForm(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } }; \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/publishcard/pages/PublishCard.ets b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/publishcard/pages/PublishCard.ets index 3431c14729..1b8ede6adc 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/publishcard/pages/PublishCard.ets +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/publishcard/pages/PublishCard.ets @@ -1,124 +1,124 @@ -/* - * Copyright (c) 2023 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 WidgetCard { - /* - * The title. - */ - readonly TITLE: Resource = $r('app.string.FormTitle'); - /* - * The subtext. - */ - readonly SUBTEXT: Resource = $r('app.string.FormThemes'); - /* - * The action topic. - */ - readonly TOPIC: Resource = $r('app.string.Topic'); - /* - * The action topic. - */ - readonly TOPIC_AGAIN: Resource = $r('app.string.Topic_Again'); - /* - * The action type. - */ - readonly ACTION_TYPE: string = 'message'; - /* - * The message. - */ - readonly MESSAGE: string = 'message'; - /* - * The width percentage setting. - */ - readonly FULL_WIDTH_PERCENT: string = '100%'; - /* - * The height percentage setting. - */ - readonly FULL_HEIGHT_PERCENT: string = '100%'; - @State isClick: Boolean = false - - build() { - Row() { - Column() { - Row() { - Column() { - Text(this.TITLE) - .fontColor($r('app.color.fount_color')) - .fontSize($r('app.float.16fp')) - .width($r('app.float.240vp')) - .height($r('app.float.22vp')) - .fontWeight(500) - .textAlign(TextAlign.Start) - .margin({ - top: $r('app.float.14vp') - }) - Text(this.SUBTEXT) - .fontColor($r('app.color.fount_color')) - .opacity(0.6) - .fontSize($r('app.float.14fp')) - .width($r('app.float.240vp')) - .height($r('app.float.19vp')) - .fontWeight(400) - .textAlign(TextAlign.Start) - .margin({ - top: $r('app.float.2vp'), - bottom: $r('app.float.15vp') - }) - } - .margin({ - left: $r('app.float.12vp') - }) - - Column() { - if (this.isClick) { - Button(this.TOPIC_AGAIN) - .backgroundColor($r('app.color.subscribe_events_background')) - .fontSize($r('app.float.button_fount_size')) - .fontColor($r('app.color.subscribe_events_fount')) - .width($r('app.float.72vp')) - .height($r('app.float.28vp')) - .margin({ - right: $r('app.float.12vp') - }) - } else { - Button(this.TOPIC) - .backgroundColor($r('app.color.subscribe_events_background')) - .fontSize($r('app.float.button_fount_size')) - .fontColor($r('app.color.subscribe_events_fount')) - .width($r('app.float.72vp')) - .height($r('app.float.28vp')) - .margin({ - right: $r('app.float.12vp') - }) - } - } - } - } - .backgroundColor($r('app.color.start_window_background')) - .width(this.FULL_WIDTH_PERCENT) - } - .height(this.FULL_HEIGHT_PERCENT) - .onClick(() => { - this.isClick = true - postCardAction(this, { - 'action': this.ACTION_TYPE, - 'params': { - message: this.MESSAGE - } - }); - }) - } +/* + * Copyright (c) 2023 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 WidgetCard { + /* + * The title. + */ + readonly TITLE: Resource = $r('app.string.FormTitle'); + /* + * The subtext. + */ + readonly SUBTEXT: Resource = $r('app.string.FormThemes'); + /* + * The action topic. + */ + readonly TOPIC: Resource = $r('app.string.Topic'); + /* + * The action topic. + */ + readonly TOPIC_AGAIN: Resource = $r('app.string.Topic_Again'); + /* + * The action type. + */ + readonly ACTION_TYPE: string = 'message'; + /* + * The message. + */ + readonly MESSAGE: string = 'message'; + /* + * The width percentage setting. + */ + readonly FULL_WIDTH_PERCENT: string = '100%'; + /* + * The height percentage setting. + */ + readonly FULL_HEIGHT_PERCENT: string = '100%'; + @State isClick: Boolean = false + + build() { + Row() { + Column() { + Row() { + Column() { + Text(this.TITLE) + .fontColor($r('app.color.fount_color')) + .fontSize($r('app.float.16fp')) + .width($r('app.float.240vp')) + .height($r('app.float.22vp')) + .fontWeight(500) + .textAlign(TextAlign.Start) + .margin({ + top: $r('app.float.14vp') + }) + Text(this.SUBTEXT) + .fontColor($r('app.color.fount_color')) + .opacity(0.6) + .fontSize($r('app.float.14fp')) + .width($r('app.float.240vp')) + .height($r('app.float.19vp')) + .fontWeight(400) + .textAlign(TextAlign.Start) + .margin({ + top: $r('app.float.2vp'), + bottom: $r('app.float.15vp') + }) + } + .margin({ + left: $r('app.float.12vp') + }) + + Column() { + if (this.isClick) { + Button(this.TOPIC_AGAIN) + .backgroundColor($r('app.color.subscribe_events_background')) + .fontSize($r('app.float.button_fount_size')) + .fontColor($r('app.color.subscribe_events_fount')) + .width($r('app.float.72vp')) + .height($r('app.float.28vp')) + .margin({ + right: $r('app.float.12vp') + }) + } else { + Button(this.TOPIC) + .backgroundColor($r('app.color.subscribe_events_background')) + .fontSize($r('app.float.button_fount_size')) + .fontColor($r('app.color.subscribe_events_fount')) + .width($r('app.float.72vp')) + .height($r('app.float.28vp')) + .margin({ + right: $r('app.float.12vp') + }) + } + } + } + } + .backgroundColor($r('app.color.start_window_background')) + .width(this.FULL_WIDTH_PERCENT) + } + .height(this.FULL_HEIGHT_PERCENT) + .onClick(() => { + this.isClick = true + postCardAction(this, { + 'action': this.ACTION_TYPE, + 'params': { + message: this.MESSAGE + } + }); + }) + } } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/resources/base/element/float.json b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/resources/base/element/float.json index 92e4b44751..23e7abcf9e 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/resources/base/element/float.json +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/resources/base/element/float.json @@ -1,116 +1,116 @@ -{ - "float": [ - { - "name": "font_size", - "value": "14fp" - }, - { - "name": "subtext_size", - "value": "12fp" - }, - { - "name": "title_size", - "value": "20fp" - }, - { - "name": "button_fount_size", - "value": "12fp" - }, - { - "name": "button_card_fount_size", - "value": "12fp" - }, - { - "name": "button_margin", - "value": "15" - }, - { - "name": "button_width", - "value": "200" - }, - { - "name": "2vp", - "value": "2px" - }, - { - "name": "22vp", - "value": "44px" - }, - { - "name": "19vp", - "value": "38px" - }, - { - "name": "14fp", - "value": "14fp" - }, - { - "name": "16fp", - "value": "16fp" - }, - { - "name": "312vp", - "value": "624px" - }, - { - "name": "336vp", - "value": "672px" - }, - { - "name": "72vp", - "value": "144px" - }, - { - "name": "12vp", - "value": "24px" - }, - { - "name": "14vp", - "value": "28px" - }, - { - "name": "15vp", - "value": "30px" - }, - { - "name": "33vp", - "value": "66px" - }, - { - "name": "4vp", - "value": "8px" - }, - { - "name": "240vp", - "value": "480px" - }, - { - "name": "64vp", - "value": "128px" - }, - { - "name": "28vp", - "value": "56px" - }, - { - "name": "6vp", - "value": "12px" - }, - { - "name": "8vp", - "value": "16px" - }, - { - "name": "24vp", - "value": "48px" - }, - { - "name": "24fp", - "value": "24fp" - }, - { - "name": "11vp", - "value": "22px" - } - ] +{ + "float": [ + { + "name": "font_size", + "value": "14fp" + }, + { + "name": "subtext_size", + "value": "12fp" + }, + { + "name": "title_size", + "value": "20fp" + }, + { + "name": "button_fount_size", + "value": "12fp" + }, + { + "name": "button_card_fount_size", + "value": "12fp" + }, + { + "name": "button_margin", + "value": "15" + }, + { + "name": "button_width", + "value": "200" + }, + { + "name": "2vp", + "value": "2px" + }, + { + "name": "22vp", + "value": "44px" + }, + { + "name": "19vp", + "value": "38px" + }, + { + "name": "14fp", + "value": "14fp" + }, + { + "name": "16fp", + "value": "16fp" + }, + { + "name": "312vp", + "value": "624px" + }, + { + "name": "336vp", + "value": "672px" + }, + { + "name": "72vp", + "value": "144px" + }, + { + "name": "12vp", + "value": "24px" + }, + { + "name": "14vp", + "value": "28px" + }, + { + "name": "15vp", + "value": "30px" + }, + { + "name": "33vp", + "value": "66px" + }, + { + "name": "4vp", + "value": "8px" + }, + { + "name": "240vp", + "value": "480px" + }, + { + "name": "64vp", + "value": "128px" + }, + { + "name": "28vp", + "value": "56px" + }, + { + "name": "6vp", + "value": "12px" + }, + { + "name": "8vp", + "value": "16px" + }, + { + "name": "24vp", + "value": "48px" + }, + { + "name": "24fp", + "value": "24fp" + }, + { + "name": "11vp", + "value": "22px" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/resources/base/profile/form_config.json b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/resources/base/profile/form_config.json index 6b9cc2e44c..9cbf66c9a2 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/resources/base/profile/form_config.json +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/resources/base/profile/form_config.json @@ -1,23 +1,23 @@ -{ - "forms": [ - { - "name": "publishCard", - "description": "This is a service widget.", - "src": "./ets/publishcard/pages/PublishCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": true, - "updateEnabled": false, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - } - ] +{ + "forms": [ + { + "name": "publishCard", + "description": "This is a service widget.", + "src": "./ets/publishcard/pages/PublishCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": false, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/AppScope/app.json5 b/code/BasicFeature/Notification/CustomCommonEventRely/AppScope/app.json5 index 0a1b1a3500..942f44ac17 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/AppScope/app.json5 +++ b/code/BasicFeature/Notification/CustomCommonEventRely/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.customcommoneventrely", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.customcommoneventrely", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/AppScope/resources/base/element/string.json b/code/BasicFeature/Notification/CustomCommonEventRely/AppScope/resources/base/element/string.json index 1b25b22303..1565f4c4b0 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Notification/CustomCommonEventRely/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "CustomCommonEventRely" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "CustomCommonEventRely" + } + ] +} diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/build-profile.json5 b/code/BasicFeature/Notification/CustomCommonEventRely/build-profile.json5 index 0c2b0b857b..5a3b9287e9 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/build-profile.json5 +++ b/code/BasicFeature/Notification/CustomCommonEventRely/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/entry/build-profile.json5 b/code/BasicFeature/Notification/CustomCommonEventRely/entry/build-profile.json5 index 0c8525dfdd..910cc991f5 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/entry/build-profile.json5 +++ b/code/BasicFeature/Notification/CustomCommonEventRely/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/entry/oh-package.json5 b/code/BasicFeature/Notification/CustomCommonEventRely/entry/oh-package.json5 index 60744fdbc7..225946cb11 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/entry/oh-package.json5 +++ b/code/BasicFeature/Notification/CustomCommonEventRely/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/entryability/EntryAbility.ts index 202b948c9e..7370b8f327 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import hilog from '@ohos.hilog'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - 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'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + 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/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/entryformability/EntryFormAbility.ts b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/entryformability/EntryFormAbility.ts index f566199b10..f71a47e36a 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/entryformability/EntryFormAbility.ts +++ b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/entryformability/EntryFormAbility.ts @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2023 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 formInfo from '@ohos.app.form.formInfo'; -import formBindingData from '@ohos.app.form.formBindingData'; -import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; -import commonEvent from '@ohos.commonEventManager'; -import hilog from '@ohos.hilog'; - -export default class EntryFormAbility extends FormExtensionAbility { - onAddForm(want) { - // Called to return a FormBindingData object. - let formData = {}; - return formBindingData.createFormBindingData(formData); - } - - onCastToNormalForm(formId) { - // Called when the form provider is notified that a temporary form is successfully - // converted to a normal form. - } - - onUpdateForm(formId) { - // Called to notify the form provider to update a specified form. - } - - onChangeFormVisibility(newStatus) { - // Called when the form provider receives form events from the system. - } - - onFormEvent(formId, message) { - // Called when a specified message event defined by the form provider is triggered. - let options = { - data: 'OutApp' - }; - commonEvent.publish('Acts_CommonEvent_Test', options, async () => {}); - } - - onRemoveForm(formId) { - // Called to notify the form provider that a specified form has been destroyed. - } - - onAcquireFormState(want) { - // Called to return a {@link FormState} object. - return formInfo.FormState.READY; - } +/* + * Copyright (c) 2023 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 formInfo from '@ohos.app.form.formInfo'; +import formBindingData from '@ohos.app.form.formBindingData'; +import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; +import commonEvent from '@ohos.commonEventManager'; +import hilog from '@ohos.hilog'; + +export default class EntryFormAbility extends FormExtensionAbility { + onAddForm(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormalForm(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdateForm(formId) { + // Called to notify the form provider to update a specified form. + } + + onChangeFormVisibility(newStatus) { + // Called when the form provider receives form events from the system. + } + + onFormEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + let options = { + data: 'OutApp' + }; + commonEvent.publish('Acts_CommonEvent_Test', options, async () => {}); + } + + onRemoveForm(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } }; \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/widget/pages/PublishCard.ets b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/widget/pages/PublishCard.ets index 0ab4cecad2..683f935ac9 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/widget/pages/PublishCard.ets +++ b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/ets/widget/pages/PublishCard.ets @@ -1,124 +1,124 @@ -/* - * Copyright (c) 2023 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 WidgetCard { - /* - * The title. - */ - readonly TITLE: Resource = $r('app.string.FormTitle'); - /* - * The subtext. - */ - readonly SUBTEXT: Resource = $r('app.string.FormThemes'); - /* - * The action type. - */ - readonly ACTION_TYPE: string = 'message'; - /* - * The action topic. - */ - readonly TOPIC: Resource = $r('app.string.Topic'); - /* - * The action topic. - */ - readonly TOPIC_AGAIN: Resource = $r('app.string.Topic_Again'); - /* - * The message. - */ - readonly MESSAGE: string = 'message'; - /* - * The width percentage setting. - */ - readonly FULL_WIDTH_PERCENT: string = '100%'; - /* - * The height percentage setting. - */ - readonly FULL_HEIGHT_PERCENT: string = '100%'; - @State isClick: Boolean = false - - build() { - Row() { - Column() { - Row() { - Column() { - Text(this.TITLE) - .fontColor($r('app.color.fount_color')) - .fontSize($r('app.float.16fp')) - .height($r('app.float.22vp')) - .width($r('app.float.240vp')) - .fontWeight(500) - .textAlign(TextAlign.Start) - .margin({ - top: $r('app.float.14vp') - }) - Text(this.SUBTEXT) - .fontColor($r('app.color.fount_color')) - .opacity(0.6) - .fontSize($r('app.float.14fp')) - .width($r('app.float.240vp')) - .height($r('app.float.19vp')) - .fontWeight(400) - .textAlign(TextAlign.Start) - .margin({ - top: $r('app.float.2vp'), - bottom: $r('app.float.15vp') - }) - } - .margin({ - left: $r('app.float.12vp') - }) - - Column() { - if (this.isClick) { - Button(this.TOPIC_AGAIN) - .backgroundColor($r('app.color.subscribe_events_background')) - .fontSize($r('app.float.button_fount_size')) - .fontColor($r('app.color.subscribe_events_fount')) - .width($r('app.float.72vp')) - .height($r('app.float.28vp')) - .margin({ - right: $r('app.float.12vp') - }) - } else { - Button(this.TOPIC) - .backgroundColor($r('app.color.subscribe_events_background')) - .fontSize($r('app.float.button_fount_size')) - .fontColor($r('app.color.subscribe_events_fount')) - .width($r('app.float.72vp')) - .height($r('app.float.28vp')) - .margin({ - right: $r('app.float.12vp') - }) - } - } - } - } - .backgroundColor($r('app.color.start_window_background')) - .width(this.FULL_WIDTH_PERCENT) - } - .height(this.FULL_HEIGHT_PERCENT) - .onClick(() => { - this.isClick = true - postCardAction(this, { - 'action': this.ACTION_TYPE, - 'params': { - message: this.MESSAGE - } - }); - }) - } +/* + * Copyright (c) 2023 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 WidgetCard { + /* + * The title. + */ + readonly TITLE: Resource = $r('app.string.FormTitle'); + /* + * The subtext. + */ + readonly SUBTEXT: Resource = $r('app.string.FormThemes'); + /* + * The action type. + */ + readonly ACTION_TYPE: string = 'message'; + /* + * The action topic. + */ + readonly TOPIC: Resource = $r('app.string.Topic'); + /* + * The action topic. + */ + readonly TOPIC_AGAIN: Resource = $r('app.string.Topic_Again'); + /* + * The message. + */ + readonly MESSAGE: string = 'message'; + /* + * The width percentage setting. + */ + readonly FULL_WIDTH_PERCENT: string = '100%'; + /* + * The height percentage setting. + */ + readonly FULL_HEIGHT_PERCENT: string = '100%'; + @State isClick: Boolean = false + + build() { + Row() { + Column() { + Row() { + Column() { + Text(this.TITLE) + .fontColor($r('app.color.fount_color')) + .fontSize($r('app.float.16fp')) + .height($r('app.float.22vp')) + .width($r('app.float.240vp')) + .fontWeight(500) + .textAlign(TextAlign.Start) + .margin({ + top: $r('app.float.14vp') + }) + Text(this.SUBTEXT) + .fontColor($r('app.color.fount_color')) + .opacity(0.6) + .fontSize($r('app.float.14fp')) + .width($r('app.float.240vp')) + .height($r('app.float.19vp')) + .fontWeight(400) + .textAlign(TextAlign.Start) + .margin({ + top: $r('app.float.2vp'), + bottom: $r('app.float.15vp') + }) + } + .margin({ + left: $r('app.float.12vp') + }) + + Column() { + if (this.isClick) { + Button(this.TOPIC_AGAIN) + .backgroundColor($r('app.color.subscribe_events_background')) + .fontSize($r('app.float.button_fount_size')) + .fontColor($r('app.color.subscribe_events_fount')) + .width($r('app.float.72vp')) + .height($r('app.float.28vp')) + .margin({ + right: $r('app.float.12vp') + }) + } else { + Button(this.TOPIC) + .backgroundColor($r('app.color.subscribe_events_background')) + .fontSize($r('app.float.button_fount_size')) + .fontColor($r('app.color.subscribe_events_fount')) + .width($r('app.float.72vp')) + .height($r('app.float.28vp')) + .margin({ + right: $r('app.float.12vp') + }) + } + } + } + } + .backgroundColor($r('app.color.start_window_background')) + .width(this.FULL_WIDTH_PERCENT) + } + .height(this.FULL_HEIGHT_PERCENT) + .onClick(() => { + this.isClick = true + postCardAction(this, { + 'action': this.ACTION_TYPE, + 'params': { + message: this.MESSAGE + } + }); + }) + } } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/module.json5 b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/module.json5 index 0642f436c5..8decf3d279 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/module.json5 +++ b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/module.json5 @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2023 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" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "EntryFormAbility", - "srcEntry": "./ets/entryformability/EntryFormAbility.ts", - "label": "$string:EntryFormAbility_label", - "description": "$string:EntryFormAbility_desc", - "type": "form", - "metadata": [ - { - "name": "ohos.extension.form", - "resource": "$profile:form_config" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.REQUIRE_FORM" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - } - ] - } +/* + * Copyright (c) 2023 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" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryFormAbility", + "srcEntry": "./ets/entryformability/EntryFormAbility.ts", + "label": "$string:EntryFormAbility_label", + "description": "$string:EntryFormAbility_desc", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.REQUIRE_FORM" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/element/color.json index cf2fe10d4f..5b7399050a 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/element/color.json @@ -1,24 +1,24 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "item_title_font", - "value": "#E6000000" - }, - { - "name": "fount_color", - "value": "#FF182431" - }, - { - "name": "subscribe_events_background", - "value": "#FF007DFF" - }, - { - "name": "subscribe_events_fount", - "value": "#FFFFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "item_title_font", + "value": "#E6000000" + }, + { + "name": "fount_color", + "value": "#FF182431" + }, + { + "name": "subscribe_events_background", + "value": "#FF007DFF" + }, + { + "name": "subscribe_events_fount", + "value": "#FFFFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/element/float.json b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/element/float.json index 9b58c97d1b..e3f77cb6c3 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/element/float.json +++ b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/element/float.json @@ -1,60 +1,60 @@ -{ - "float": [ - { - "name": "title_size", - "value": "20fp" - }, - { - "name": "22vp", - "value": "44px" - }, - { - "name": "14fp", - "value": "14fp" - }, - { - "name": "240vp", - "value": "480px" - }, - { - "name": "14vp", - "value": "28px" - }, - { - "name": "16fp", - "value": "16fp" - }, - { - "name": "2vp", - "value": "4px" - }, - { - "name": "5vp", - "value": "10px" - }, - { - "name": "19vp", - "value": "38px" - }, - { - "name": "15vp", - "value": "30px" - }, - { - "name": "72vp", - "value": "144px" - }, - { - "name": "28vp", - "value": "56px" - }, - { - "name": "12vp", - "value": "24px" - }, - { - "name": "button_fount_size", - "value": "12fp" - } - ] +{ + "float": [ + { + "name": "title_size", + "value": "20fp" + }, + { + "name": "22vp", + "value": "44px" + }, + { + "name": "14fp", + "value": "14fp" + }, + { + "name": "240vp", + "value": "480px" + }, + { + "name": "14vp", + "value": "28px" + }, + { + "name": "16fp", + "value": "16fp" + }, + { + "name": "2vp", + "value": "4px" + }, + { + "name": "5vp", + "value": "10px" + }, + { + "name": "19vp", + "value": "38px" + }, + { + "name": "15vp", + "value": "30px" + }, + { + "name": "72vp", + "value": "144px" + }, + { + "name": "28vp", + "value": "56px" + }, + { + "name": "12vp", + "value": "24px" + }, + { + "name": "button_fount_size", + "value": "12fp" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/profile/form_config.json b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/profile/form_config.json index afe032d13e..07725f60a9 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/profile/form_config.json +++ b/code/BasicFeature/Notification/CustomCommonEventRely/entry/src/main/resources/base/profile/form_config.json @@ -1,23 +1,23 @@ -{ - "forms": [ - { - "name": "publishCard", - "description": "This is a service widget.", - "src": "./ets/widget/pages/PublishCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": true, - "updateEnabled": false, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - } - ] +{ + "forms": [ + { + "name": "publishCard", + "description": "This is a service widget.", + "src": "./ets/widget/pages/PublishCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": false, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/hvigor/hvigor-config.json5 b/code/BasicFeature/Notification/CustomCommonEventRely/hvigor/hvigor-config.json5 index fb29482d10..9a79085076 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Notification/CustomCommonEventRely/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEventRely/oh-package.json5 b/code/BasicFeature/Notification/CustomCommonEventRely/oh-package.json5 index c2bd3ab5bb..032a2c1f4d 100644 --- a/code/BasicFeature/Notification/CustomCommonEventRely/oh-package.json5 +++ b/code/BasicFeature/Notification/CustomCommonEventRely/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "customcommoneventrely", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "customcommoneventrely", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/AppScope/app.json5 b/code/BasicFeature/Print/ScanNapiInterfaceDemo/AppScope/app.json5 index 9585610ca8..6c54ddbb93 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/AppScope/app.json5 +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.example.scannapiinterfacedemo", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.example.scannapiinterfacedemo", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/AppScope/resources/base/element/string.json b/code/BasicFeature/Print/ScanNapiInterfaceDemo/AppScope/resources/base/element/string.json index 2d59d2015e..e1a3abcd1c 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ScanNapiInterfaceDemo" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ScanNapiInterfaceDemo" + } + ] +} diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/README_zh.md b/code/BasicFeature/Print/ScanNapiInterfaceDemo/README_zh.md index 66a22277e0..4e812996e9 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/README_zh.md +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/README_zh.md @@ -1,134 +1,134 @@ -# 扫描仪应用demo - -### 介绍 -本示例使用@ohos.scan接口拉起[打印框架](https://gitee.com/openharmony/print_print_fwk)下的扫描服务,由扫描服务加载扫描仪驱动,完成扫描仪的发现与连接、获取扫描仪选项、设置扫描仪参数、启动扫描仪、获取扫描图片进度、取消扫描的功能。 - -### 界面预览 -![扫描demo](sceenshots/scandemo.png) - -使用说明 - -1.本示例是测试扫描框架接口能力,扫描仪驱动基于sane-backends开发。 - -2.首页的按钮点击后调用扫描框架对应的接口。 - -3.启动扫描后,可以通过图片预览按钮查看扫描出的图片。 - -### 工程目录 - -``` -ScanNapiInterfaceDemo -├── AppScope -│ └── app.json5 //APP信息配置文件 -├── entry/src/main -│ ├── ets -│ │ ├── entryability -│ │ ├── scan -│ │ │ ├── log.ts //日志库 -│ │ │ ├── scan.ts //扫描接口库 -│ │ ├── pages -│ │ │ ├── Index.ets //应用界面 -│ └── module.json5 -│ -├── entry/src/ohosTest //测试用例 -│ ├── ets/test -│ │ ├── Ability.test.ets -│ │ ├── List.test.ets //测试列表 -│ │ ├── Scan.test.ets //扫描接口测试 -│ └── module.json5 -``` - -### 具体实现 - -* 该示例分为7个接口: - * 搜索扫描仪 - * 使用@ohos.scan中API 12接口scan.on注册发现回调函数,然后调用@ohos.scan中的scan.getScannerList接口开启扫描仪搜索,当发现到扫描仪时,会通过on注册的回调函数,将扫描仪设备信息回调到应用。 - * 源码链接:[scan.ts](./entry/src/main/ets/scan/scan.ts) - * 参考接口:[@ohos.scan] - - * 连接扫描仪 - - * 使用@ohos.scan中API 12接口scan.openScanner连接扫描仪,传入的参数是扫描仪的id。 - * 源码链接:[scan.ts](./entry/src/main/ets/scan/scan.ts) - * 参考接口:[@ohos.scan] - - * 启动扫描仪 - - * 使用@ohos.scan中API 12接口scan.startScan启动扫描任务,传入的参数是扫描仪的id和是否开启批处理扫描模式。 - - * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) - - * 参考接口:[@ohos.scan] - - * 取消扫描 - - * 使用@ohos.scan中API 12接口scan.cancelScan取消扫描任务,传入的参数是扫描仪的id。 - - * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) - - * 参考接口:[@ohos.scan] - * 查询扫描进度 - - * 使用@ohos.scan中API 12接口scan.getScanProgress查询扫描仪扫描图片的进度。 - - * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) - - * 参考接口:@ohos.scan - * 获取扫描仪选项 - - * 使用@ohos.scan中API 12接口scan.getScanOption查询扫描仪有多少个选项,getScanOptionDesc获取每一个选项具体的描述信息。 - - * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) - - * 参考接口:@ohos.scan - * 设置扫描仪参数 - - * 使用@ohos.scan中API 12接口scan.setScanOption设置某一台扫描仪的选项参数。 - - * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) - - * 参考接口:@ohos.scan - -### 相关权限 - -[ohos.permission.PRINT] - -[ohos.permission.MANAGE_PRINT_JOB] - -### 依赖 - -1.API12版本SDK的@ohos.scan接口。 - -2.基于[sane-backends](https://gitee.com/openharmony-sig/third_party_backends)开发的扫描仪驱动以及对应厂商型号的扫描仪设备。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568。 - -2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12),镜像版本号(5.0) - -3.本示例需要使用DevEco Studio 版本号(5.0.3.403)及以上版本才可编译运行。 - -4.运行本示例需要连接扫描仪,下载扫描仪对应的驱动。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/BasicFeature/Print/ScanNapiInterfaceDemo/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull -``` - -### 构建说明 - -1.需要基于[sane-backends](https://gitee.com/openharmony-sig/third_party_backends/)完成扫描仪驱动的开发。 - -2.扫描仪驱动通过驱动安装应用安装到指定路径。 - -3.本工程通过Build Hap(s)/APP(s)完成编译构建,然后安装。 - +# 扫描仪应用demo + +### 介绍 +本示例使用@ohos.scan接口拉起[打印框架](https://gitee.com/openharmony/print_print_fwk)下的扫描服务,由扫描服务加载扫描仪驱动,完成扫描仪的发现与连接、获取扫描仪选项、设置扫描仪参数、启动扫描仪、获取扫描图片进度、取消扫描的功能。 + +### 界面预览 +![扫描demo](sceenshots/scandemo.png) + +使用说明 + +1.本示例是测试扫描框架接口能力,扫描仪驱动基于sane-backends开发。 + +2.首页的按钮点击后调用扫描框架对应的接口。 + +3.启动扫描后,可以通过图片预览按钮查看扫描出的图片。 + +### 工程目录 + +``` +ScanNapiInterfaceDemo +├── AppScope +│ └── app.json5 //APP信息配置文件 +├── entry/src/main +│ ├── ets +│ │ ├── entryability +│ │ ├── scan +│ │ │ ├── log.ts //日志库 +│ │ │ ├── scan.ts //扫描接口库 +│ │ ├── pages +│ │ │ ├── Index.ets //应用界面 +│ └── module.json5 +│ +├── entry/src/ohosTest //测试用例 +│ ├── ets/test +│ │ ├── Ability.test.ets +│ │ ├── List.test.ets //测试列表 +│ │ ├── Scan.test.ets //扫描接口测试 +│ └── module.json5 +``` + +### 具体实现 + +* 该示例分为7个接口: + * 搜索扫描仪 + * 使用@ohos.scan中API 12接口scan.on注册发现回调函数,然后调用@ohos.scan中的scan.getScannerList接口开启扫描仪搜索,当发现到扫描仪时,会通过on注册的回调函数,将扫描仪设备信息回调到应用。 + * 源码链接:[scan.ts](./entry/src/main/ets/scan/scan.ts) + * 参考接口:[@ohos.scan] + + * 连接扫描仪 + + * 使用@ohos.scan中API 12接口scan.openScanner连接扫描仪,传入的参数是扫描仪的id。 + * 源码链接:[scan.ts](./entry/src/main/ets/scan/scan.ts) + * 参考接口:[@ohos.scan] + + * 启动扫描仪 + + * 使用@ohos.scan中API 12接口scan.startScan启动扫描任务,传入的参数是扫描仪的id和是否开启批处理扫描模式。 + + * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) + + * 参考接口:[@ohos.scan] + + * 取消扫描 + + * 使用@ohos.scan中API 12接口scan.cancelScan取消扫描任务,传入的参数是扫描仪的id。 + + * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) + + * 参考接口:[@ohos.scan] + * 查询扫描进度 + + * 使用@ohos.scan中API 12接口scan.getScanProgress查询扫描仪扫描图片的进度。 + + * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) + + * 参考接口:@ohos.scan + * 获取扫描仪选项 + + * 使用@ohos.scan中API 12接口scan.getScanOption查询扫描仪有多少个选项,getScanOptionDesc获取每一个选项具体的描述信息。 + + * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) + + * 参考接口:@ohos.scan + * 设置扫描仪参数 + + * 使用@ohos.scan中API 12接口scan.setScanOption设置某一台扫描仪的选项参数。 + + * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) + + * 参考接口:@ohos.scan + +### 相关权限 + +[ohos.permission.PRINT] + +[ohos.permission.MANAGE_PRINT_JOB] + +### 依赖 + +1.API12版本SDK的@ohos.scan接口。 + +2.基于[sane-backends](https://gitee.com/openharmony-sig/third_party_backends)开发的扫描仪驱动以及对应厂商型号的扫描仪设备。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568。 + +2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12),镜像版本号(5.0) + +3.本示例需要使用DevEco Studio 版本号(5.0.3.403)及以上版本才可编译运行。 + +4.运行本示例需要连接扫描仪,下载扫描仪对应的驱动。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/BasicFeature/Print/ScanNapiInterfaceDemo/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull +``` + +### 构建说明 + +1.需要基于[sane-backends](https://gitee.com/openharmony-sig/third_party_backends/)完成扫描仪驱动的开发。 + +2.扫描仪驱动通过驱动安装应用安装到指定路径。 + +3.本工程通过Build Hap(s)/APP(s)完成编译构建,然后安装。 + 4.通过局域网或有线等物理方式连接扫描仪后即可通过主界面的相关按钮实现扫描仪的发现和连接等功能。 \ No newline at end of file diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/build-profile.json5 b/code/BasicFeature/Print/ScanNapiInterfaceDemo/build-profile.json5 index 1cfea753aa..82472ef2cf 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/build-profile.json5 +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/build-profile.json5 @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2024 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compatibleSdkVersion": 12, - "compileSdkVersion": 12, - "runtimeOS": "OpenHarmony" - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": 12, + "compileSdkVersion": 12, + "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/BasicFeature/Print/ScanNapiInterfaceDemo/entry/build-profile.json5 b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/build-profile.json5 index 97f563b45a..63b88fb1a0 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/build-profile.json5 +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2024 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", - } - ] +/* + * Copyright (c) 2024 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/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/entryability/EntryAbility.ets index eaf0e1105c..a32a8361c7 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index 14b37a8537..be794f48cc 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2024 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)); - } +/* + * Copyright (c) 2024 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/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/scan/log.ts b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/scan/log.ts index 6b3a6f77e0..b39805830e 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/scan/log.ts +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/scan/log.ts @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -export class ScanLog { - private static readonly SETTING_DOMAIN:number = 0x0000; - static debug(msg) :void { - hilog.debug(ScanLog.SETTING_DOMAIN, 'scanDemo',msg); - } - static info(msg) :void { - hilog.info(ScanLog.SETTING_DOMAIN,'scanDemo',msg); - } - static warn(msg) :void{ - hilog.warn(ScanLog.SETTING_DOMAIN,'scanDemo',msg); - } - static fatal(msg) :void{ - hilog.fatal(ScanLog.SETTING_DOMAIN,'scanDemo',msg); - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +export class ScanLog { + private static readonly SETTING_DOMAIN:number = 0x0000; + static debug(msg) :void { + hilog.debug(ScanLog.SETTING_DOMAIN, 'scanDemo',msg); + } + static info(msg) :void { + hilog.info(ScanLog.SETTING_DOMAIN,'scanDemo',msg); + } + static warn(msg) :void{ + hilog.warn(ScanLog.SETTING_DOMAIN,'scanDemo',msg); + } + static fatal(msg) :void{ + hilog.fatal(ScanLog.SETTING_DOMAIN,'scanDemo',msg); + } +} diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/scan/scan.ts b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/scan/scan.ts index b4f6fef9c4..bcf5ebea92 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/scan/scan.ts +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/ets/scan/scan.ts @@ -1,162 +1,162 @@ -/* - * Copyright (c) 2024 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. - */ - -// @ts-ignore -import scan from '@ohos.scan' -import { BusinessError} from '@kit.BasicServicesKit'; -import { ScanLog } from './log'; - -export interface ScannerDevice { - deviceId : string, - manufacturer :string, - deviceType : string, - deviceState : string, - discoverMode : string, - serialNumber : string, - address : string, - deviceName : string, -} - -export interface ScanProgress { - progress : number, - pictureFd :number, - isFinal : boolean, -} - -export interface ScanOptionValue { - valueType:number, - valueSize:number, - numValue?:number, - numListValue?:Array, - strValue?:string, - boolValue?:boolean, -} - -export enum ScanOptionValueType { - SCAN_VALUE_NONE, - SCAN_VALUE_NUM, - SCAN_VALUE_NUM_LIST, - SCAN_VALUE_STR, - SCAN_VALUE_BOOL, -} - -export class Scan { - static initScan():Promise{ - return new Promise((resolve,reject)=>{ - scan.initScan().then((data:number)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } - static exitScan():Promise{ - return new Promise((resolve,reject)=>{ - scan.exitScan().then((data:number)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } - static openScanner(scannerId:string):Promise{ - return new Promise((resolve,reject)=>{ - scan.openScanner(scannerId).then((data:number)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } - static closeScanner(scannerId:string):Promise{ - return new Promise((resolve,reject)=>{ - scan.closeScanner(scannerId).then((data:number)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } - static startScan(scannerId:string, isBatch:boolean):Promise{ - return new Promise((resolve,reject)=>{ - scan.startScan(scannerId, isBatch).then((data:number)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } - static getScannerList():Promise{ - return new Promise((resolve,reject)=>{ - scan.getScannerList().then((data:boolean)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } - static on(type:string, callBackRef):void{ - try { - scan.on(type, callBackRef); - } catch (error) { - ScanLog.warn('scan on error'); - } - } - static cancelScan(scannerId :string):Promise{ - return new Promise((resolve,reject)=>{ - scan.cancelScan(scannerId).then((data:boolean)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } - static getProgress(scannerId :string):Promise { - return new Promise((resolve,reject)=>{ - scan.getScanProgress(scannerId).then((data:ScanProgress)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } - static setScanOption(scannerId :string, optionIndex : number, optionValue : ScanOptionValue):Promise { - return new Promise((resolve,reject)=>{ - scan.setScanOption(scannerId, optionIndex, optionValue).then((data:boolean)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } - static getScanOption(scannerId :string, optionIndex : number, optionValueType : ScanOptionValueType, valueSize : number):Promise { - return new Promise((resolve,reject)=>{ - scan.getScanOption(scannerId, optionIndex, optionValueType, valueSize).then((data)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } - static getScanOptionDesc(scannerId :string, optionIndex : number):Promise { - return new Promise((resolve,reject)=>{ - scan.getScanOptionDesc(scannerId, optionIndex).then((data)=>{ - resolve(data); - }).catch((error:BusinessError)=>{ - reject(error); - }) - }); - } -} +/* + * Copyright (c) 2024 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. + */ + +// @ts-ignore +import scan from '@ohos.scan' +import { BusinessError} from '@kit.BasicServicesKit'; +import { ScanLog } from './log'; + +export interface ScannerDevice { + deviceId : string, + manufacturer :string, + deviceType : string, + deviceState : string, + discoverMode : string, + serialNumber : string, + address : string, + deviceName : string, +} + +export interface ScanProgress { + progress : number, + pictureFd :number, + isFinal : boolean, +} + +export interface ScanOptionValue { + valueType:number, + valueSize:number, + numValue?:number, + numListValue?:Array, + strValue?:string, + boolValue?:boolean, +} + +export enum ScanOptionValueType { + SCAN_VALUE_NONE, + SCAN_VALUE_NUM, + SCAN_VALUE_NUM_LIST, + SCAN_VALUE_STR, + SCAN_VALUE_BOOL, +} + +export class Scan { + static initScan():Promise{ + return new Promise((resolve,reject)=>{ + scan.initScan().then((data:number)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } + static exitScan():Promise{ + return new Promise((resolve,reject)=>{ + scan.exitScan().then((data:number)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } + static openScanner(scannerId:string):Promise{ + return new Promise((resolve,reject)=>{ + scan.openScanner(scannerId).then((data:number)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } + static closeScanner(scannerId:string):Promise{ + return new Promise((resolve,reject)=>{ + scan.closeScanner(scannerId).then((data:number)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } + static startScan(scannerId:string, isBatch:boolean):Promise{ + return new Promise((resolve,reject)=>{ + scan.startScan(scannerId, isBatch).then((data:number)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } + static getScannerList():Promise{ + return new Promise((resolve,reject)=>{ + scan.getScannerList().then((data:boolean)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } + static on(type:string, callBackRef):void{ + try { + scan.on(type, callBackRef); + } catch (error) { + ScanLog.warn('scan on error'); + } + } + static cancelScan(scannerId :string):Promise{ + return new Promise((resolve,reject)=>{ + scan.cancelScan(scannerId).then((data:boolean)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } + static getProgress(scannerId :string):Promise { + return new Promise((resolve,reject)=>{ + scan.getScanProgress(scannerId).then((data:ScanProgress)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } + static setScanOption(scannerId :string, optionIndex : number, optionValue : ScanOptionValue):Promise { + return new Promise((resolve,reject)=>{ + scan.setScanOption(scannerId, optionIndex, optionValue).then((data:boolean)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } + static getScanOption(scannerId :string, optionIndex : number, optionValueType : ScanOptionValueType, valueSize : number):Promise { + return new Promise((resolve,reject)=>{ + scan.getScanOption(scannerId, optionIndex, optionValueType, valueSize).then((data)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } + static getScanOptionDesc(scannerId :string, optionIndex : number):Promise { + return new Promise((resolve,reject)=>{ + scan.getScanOptionDesc(scannerId, optionIndex).then((data)=>{ + resolve(data); + }).catch((error:BusinessError)=>{ + reject(error); + }) + }); + } +} diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/module.json5 b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/module.json5 index 5ec48b140a..f170a2a47b 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/module.json5 +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2024 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" - } - ] - } - ], - "requestPermissions": [ - { - "name" : "ohos.permission.MANAGE_PRINT_JOB" - } - ] - } +/* + * Copyright (c) 2024 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" + } + ] + } + ], + "requestPermissions": [ + { + "name" : "ohos.permission.MANAGE_PRINT_JOB" + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/profile/backup_config.json index d742c2f96e..78f40ae7c4 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/profile/backup_config.json +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/ohosTest/ets/test/Scan.test.ets b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/ohosTest/ets/test/Scan.test.ets index b852441185..4567fb489c 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/ohosTest/ets/test/Scan.test.ets +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/ohosTest/ets/test/Scan.test.ets @@ -1,115 +1,115 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { describe, it, expect } from '@ohos/hypium'; -import { Scan } from '../../../main/ets/scan/scan' -import { ScanLog } from '../../../main/ets/scan/log' -import { ScannerDevice } from '../../../main/ets/scan/scan' -import { ScanOptionValue } from '../../../main/ets/scan/scan' -export function scanTest() { - describe('ScanAbilityTest', () => { - it('ScanTest_000', 0, ()=>{ - Scan.initScan().then((data:number)=>{ - ScanLog.info('init scan successful') - }).catch(() => { - ScanLog.warn('init scan error') - }) - }); - it('ScanTest_001', 0, ()=>{ - Scan.exitScan().then(()=>{ - ScanLog.info('exitScan scan successful') - }).catch(() => { - ScanLog.warn('exitScan scan error') - }) - }); - it('ScanTest_002', 0, ()=>{ - let scannerId : string = ""; - Scan.openScanner(scannerId).then(()=>{ - ScanLog.info('openScanner scan successful') - }).catch(() => { - ScanLog.warn('openScanner scan error') - }) - }); - it('ScanTest_003', 0, ()=>{ - let scannerId : string = ""; - Scan.closeScanner(scannerId).then(()=>{ - ScanLog.info('closeScanner scan successful') - }).catch(() => { - ScanLog.warn('closeScanner scan error') - }) - }); - it('ScanTest_004', 0, ()=>{ - let scannerId : string = "" - Scan.startScan(scannerId, false).then(()=>{ - ScanLog.info('startScan scan successful') - }).catch(() => { - ScanLog.warn('startScan scan error') - }) - }); - it('ScanTest_005', 0, ()=>{ - let scannerId : string = ""; - Scan.cancelScan(scannerId).then(()=>{ - ScanLog.info('cancelScan scan successful') - }).catch(() => { - ScanLog.warn('cancelScan scan error') - }) - }); - it('ScanTest_006', 0, ()=>{ - let scannerId : string = ""; - Scan.getProgress(scannerId).then(()=>{ - ScanLog.info('getProgress scan successful') - }).catch(() => { - ScanLog.warn('getProgress scan error') - }) - }); - it('ScanTest_007', 0, ()=>{ - let scannerId : string = ""; - let value : ScanOptionValue = { - valueType : 3, - valueSize : 0, - strValue : 'Automatic Document Feeder', - }; - Scan.setScanOption(scannerId, 6, value).then(()=>{ - ScanLog.info('getProgress scan successful') - }).catch(() => { - ScanLog.warn('getProgress scan error') - }) - }); - it('ScanTest_008', 0, ()=>{ - let scannerId : string = ""; - Scan.getScanOption(scannerId, 0 ,1, 4).then(() => { - }).catch(() => { - ScanLog.warn('scan getScanOption error'); - }) - }); - it('ScanTest_009', 0, ()=>{ - Scan.on('scanDeviceFound', (device: ScannerDevice | string) => { - ScanLog.info('scanner info : ' + JSON.stringify(device)); - }) - Scan.getScannerList().then(() => { - ScanLog.info('scan getScannerList successful'); - }).catch(() => { - ScanLog.warn('scan getScannerList error') - }) - }); - it('ScanTest_010', 0, ()=>{ - let scannerId : string = ""; - Scan.getScanOptionDesc(scannerId, 0).then(() => { - ScanLog.info('scan getScanOptionDesc successful'); - }).catch(() => { - ScanLog.warn('scan getScanOptionDesc error') - }) - }); - }) +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { Scan } from '../../../main/ets/scan/scan' +import { ScanLog } from '../../../main/ets/scan/log' +import { ScannerDevice } from '../../../main/ets/scan/scan' +import { ScanOptionValue } from '../../../main/ets/scan/scan' +export function scanTest() { + describe('ScanAbilityTest', () => { + it('ScanTest_000', 0, ()=>{ + Scan.initScan().then((data:number)=>{ + ScanLog.info('init scan successful') + }).catch(() => { + ScanLog.warn('init scan error') + }) + }); + it('ScanTest_001', 0, ()=>{ + Scan.exitScan().then(()=>{ + ScanLog.info('exitScan scan successful') + }).catch(() => { + ScanLog.warn('exitScan scan error') + }) + }); + it('ScanTest_002', 0, ()=>{ + let scannerId : string = ""; + Scan.openScanner(scannerId).then(()=>{ + ScanLog.info('openScanner scan successful') + }).catch(() => { + ScanLog.warn('openScanner scan error') + }) + }); + it('ScanTest_003', 0, ()=>{ + let scannerId : string = ""; + Scan.closeScanner(scannerId).then(()=>{ + ScanLog.info('closeScanner scan successful') + }).catch(() => { + ScanLog.warn('closeScanner scan error') + }) + }); + it('ScanTest_004', 0, ()=>{ + let scannerId : string = "" + Scan.startScan(scannerId, false).then(()=>{ + ScanLog.info('startScan scan successful') + }).catch(() => { + ScanLog.warn('startScan scan error') + }) + }); + it('ScanTest_005', 0, ()=>{ + let scannerId : string = ""; + Scan.cancelScan(scannerId).then(()=>{ + ScanLog.info('cancelScan scan successful') + }).catch(() => { + ScanLog.warn('cancelScan scan error') + }) + }); + it('ScanTest_006', 0, ()=>{ + let scannerId : string = ""; + Scan.getProgress(scannerId).then(()=>{ + ScanLog.info('getProgress scan successful') + }).catch(() => { + ScanLog.warn('getProgress scan error') + }) + }); + it('ScanTest_007', 0, ()=>{ + let scannerId : string = ""; + let value : ScanOptionValue = { + valueType : 3, + valueSize : 0, + strValue : 'Automatic Document Feeder', + }; + Scan.setScanOption(scannerId, 6, value).then(()=>{ + ScanLog.info('getProgress scan successful') + }).catch(() => { + ScanLog.warn('getProgress scan error') + }) + }); + it('ScanTest_008', 0, ()=>{ + let scannerId : string = ""; + Scan.getScanOption(scannerId, 0 ,1, 4).then(() => { + }).catch(() => { + ScanLog.warn('scan getScanOption error'); + }) + }); + it('ScanTest_009', 0, ()=>{ + Scan.on('scanDeviceFound', (device: ScannerDevice | string) => { + ScanLog.info('scanner info : ' + JSON.stringify(device)); + }) + Scan.getScannerList().then(() => { + ScanLog.info('scan getScannerList successful'); + }).catch(() => { + ScanLog.warn('scan getScannerList error') + }) + }); + it('ScanTest_010', 0, ()=>{ + let scannerId : string = ""; + Scan.getScanOptionDesc(scannerId, 0).then(() => { + ScanLog.info('scan getScanOptionDesc successful'); + }).catch(() => { + ScanLog.warn('scan getScanOptionDesc error') + }) + }); + }) } \ No newline at end of file diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/ohosTest/module.json5 b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/ohosTest/module.json5 index 20226beba8..944ed99859 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/ohosTest/module.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/hvigor/hvigor-config.json5 b/code/BasicFeature/Print/ScanNapiInterfaceDemo/hvigor/hvigor-config.json5 index 7dbbeb138a..87990affc4 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/hvigor/hvigor-config.json5 @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2024 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*/ - } -} +/* + * Copyright (c) 2024 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/BasicFeature/Print/ScanNapiInterfaceDemo/oh-package-lock.json5 b/code/BasicFeature/Print/ScanNapiInterfaceDemo/oh-package-lock.json5 index fb9ffcf195..90b58fc0fd 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/oh-package-lock.json5 +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/oh-package-lock.json5 @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "meta": { - "stableOrder": true - }, - "lockfileVersion": 3, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", - "@ohos/hypium@1.0.18": "@ohos/hypium@1.0.18" - }, - "packages": { - "@ohos/hamock@1.0.0": { - "name": "@ohos/hamock", - "version": "1.0.0", - "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", - "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", - "registryType": "ohpm" - }, - "@ohos/hypium@1.0.18": { - "name": "@ohos/hypium", - "version": "1.0.18", - "integrity": "sha512-RGe/iLGdeywdQilMWZsHKUoiE9OJ+9QxQsorF92R2ImLNVHVhbpSePNITGpW7TnvLgOIP/jscOqfIOhk6X7XRQ==", - "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.18.har", - "registryType": "ohpm" - } - } +/* + * Copyright (c) 2024 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. + */ + +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.18": "@ohos/hypium@1.0.18" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.18": { + "name": "@ohos/hypium", + "version": "1.0.18", + "integrity": "sha512-RGe/iLGdeywdQilMWZsHKUoiE9OJ+9QxQsorF92R2ImLNVHVhbpSePNITGpW7TnvLgOIP/jscOqfIOhk6X7XRQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.18.har", + "registryType": "ohpm" + } + } } \ No newline at end of file diff --git a/code/BasicFeature/Print/ScanNapiInterfaceDemo/oh-package.json5 b/code/BasicFeature/Print/ScanNapiInterfaceDemo/oh-package.json5 index 55feb3193b..d1294a3e36 100644 --- a/code/BasicFeature/Print/ScanNapiInterfaceDemo/oh-package.json5 +++ b/code/BasicFeature/Print/ScanNapiInterfaceDemo/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2024 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" - } -} +/* + * Copyright (c) 2024 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/BasicFeature/Resource/ResourceManager/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Resource/ResourceManager/entry/src/main/ets/entryability/EntryAbility.ets index caf1535339..c619b99702 100644 --- a/code/BasicFeature/Resource/ResourceManager/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Resource/ResourceManager/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; - -const TAG = '[Sample_ResourceManager]'; -const DOMAIN = 0xFF00; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate'); - } - - onDestroy() { - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); - } - - onBackground() { - // Ability has back to background - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +const TAG = '[Sample_ResourceManager]'; +const DOMAIN = 0xFF00; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/BasicFeature/Resource/ResourceManager/libraryOverlay/build-profile.json5 b/code/BasicFeature/Resource/ResourceManager/libraryOverlay/build-profile.json5 index 571f75bc54..71198c168f 100644 --- a/code/BasicFeature/Resource/ResourceManager/libraryOverlay/build-profile.json5 +++ b/code/BasicFeature/Resource/ResourceManager/libraryOverlay/build-profile.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default" - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Resource/ResourceManager/libraryOverlay/oh-package.json5 b/code/BasicFeature/Resource/ResourceManager/libraryOverlay/oh-package.json5 index ab614db178..c3805d3263 100644 --- a/code/BasicFeature/Resource/ResourceManager/libraryOverlay/oh-package.json5 +++ b/code/BasicFeature/Resource/ResourceManager/libraryOverlay/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "Apache-2.0", - "devDependencies": {}, - "author": "", - "name": "libraryoverlay", - "description": "Please describe the basic information.", - "main": "./src/main/ets/Index.ets", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "Apache-2.0", + "devDependencies": {}, + "author": "", + "name": "libraryoverlay", + "description": "Please describe the basic information.", + "main": "./src/main/ets/Index.ets", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/ets/Index.ets b/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/ets/Index.ets index f022fd889a..8c3af06cb8 100644 --- a/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/ets/Index.ets +++ b/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/ets/Index.ets @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2023 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. - */ - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export { add } from "./utils/Calc" \ No newline at end of file diff --git a/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/module.json5 b/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/module.json5 index 5b0b8ce38f..8957711d47 100644 --- a/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/module.json5 +++ b/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/module.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": "libraryOverlay", - "type": "shared", - "description": "$string:shared_desc", - "targetModuleName":"entry", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" - } +/* + * Copyright (c) 2023 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": "libraryOverlay", + "type": "shared", + "description": "$string:shared_desc", + "targetModuleName":"entry", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "pages": "$profile:main_pages" + } } \ No newline at end of file diff --git a/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/resources/base/element/string.json b/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/resources/base/element/string.json index 8ff4fc989c..e5e5574f73 100644 --- a/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/resources/base/element/string.json +++ b/code/BasicFeature/Resource/ResourceManager/libraryOverlay/src/main/resources/base/element/string.json @@ -1,12 +1,12 @@ -{ - "string": [ - { - "name": "shared_desc", - "value": "description" - }, - { - "name": "test_string", - "value": "base_overlay_test" - } - ] +{ + "string": [ + { + "name": "shared_desc", + "value": "description" + }, + { + "name": "test_string", + "value": "base_overlay_test" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/build-profile.json5 b/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/build-profile.json5 index 571f75bc54..71198c168f 100644 --- a/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/build-profile.json5 +++ b/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/build-profile.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default" - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/oh-package.json5 b/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/oh-package.json5 index 977be1c13e..606c415bd5 100644 --- a/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/oh-package.json5 +++ b/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "Apache-2.0", - "devDependencies": {}, - "author": "", - "name": "libraryruntimeoverlay", - "description": "Please describe the basic information.", - "main": "./src/main/ets/Index.ets", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "Apache-2.0", + "devDependencies": {}, + "author": "", + "name": "libraryruntimeoverlay", + "description": "Please describe the basic information.", + "main": "./src/main/ets/Index.ets", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/ets/Index.ets b/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/ets/Index.ets index f022fd889a..8c3af06cb8 100644 --- a/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/ets/Index.ets +++ b/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/ets/Index.ets @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2023 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. - */ - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export { add } from "./utils/Calc" \ No newline at end of file diff --git a/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/module.json5 b/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/module.json5 index e24f6cb56b..f8615ef2e9 100644 --- a/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/module.json5 +++ b/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/module.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2023 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": "libraryRuntimeOverlay", - "type": "shared", - "description": "$string:shared_desc", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" - } +/* + * Copyright (c) 2023 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": "libraryRuntimeOverlay", + "type": "shared", + "description": "$string:shared_desc", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "pages": "$profile:main_pages" + } } \ No newline at end of file diff --git a/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/resources/base/element/string.json b/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/resources/base/element/string.json index 6175c8ac06..9996631913 100644 --- a/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/resources/base/element/string.json +++ b/code/BasicFeature/Resource/ResourceManager/libraryRuntimeOverlay/src/main/resources/base/element/string.json @@ -1,12 +1,12 @@ -{ - "string": [ - { - "name": "shared_desc", - "value": "description" - }, - { - "name": "test_string", - "value": "en_US_overlay_RUNTIME" - } - ] +{ + "string": [ + { + "name": "shared_desc", + "value": "description" + }, + { + "name": "test_string", + "value": "en_US_overlay_RUNTIME" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/.gitignore b/code/BasicFeature/Security/Asset/.gitignore old mode 100755 new mode 100644 index f11a3ee29a..0e158c3f26 --- a/code/BasicFeature/Security/Asset/.gitignore +++ b/code/BasicFeature/Security/Asset/.gitignore @@ -1,11 +1,11 @@ -/node_modules -/oh_modules -/local.properties -/.idea -**/build -/.hvigor -.cxx -/.clangd -/.clang-format -/.clang-tidy -**/.test +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test diff --git a/code/BasicFeature/Security/Asset/AppScope/app.json5 b/code/BasicFeature/Security/Asset/AppScope/app.json5 old mode 100755 new mode 100644 index bd5d03e2ed..4defd2d32e --- a/code/BasicFeature/Security/Asset/AppScope/app.json5 +++ b/code/BasicFeature/Security/Asset/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.example.asset_sample", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.example.asset_sample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Security/Asset/AppScope/resources/base/element/string.json b/code/BasicFeature/Security/Asset/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 8c7764091f..416dd17f2b --- a/code/BasicFeature/Security/Asset/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Security/Asset/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "asset_sample" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "asset_sample" + } + ] +} diff --git a/code/BasicFeature/Security/Asset/AppScope/resources/base/media/app_icon.png b/code/BasicFeature/Security/Asset/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/AppScope/resources/base/media/back.png b/code/BasicFeature/Security/Asset/AppScope/resources/base/media/back.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/AppScope/resources/base/media/forward.png b/code/BasicFeature/Security/Asset/AppScope/resources/base/media/forward.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/README_zh.md b/code/BasicFeature/Security/Asset/README_zh.md old mode 100755 new mode 100644 index e006f1c7bb..aaef098d85 --- a/code/BasicFeature/Security/Asset/README_zh.md +++ b/code/BasicFeature/Security/Asset/README_zh.md @@ -1,110 +1,110 @@ -# 关键资产存储服务 -## 介绍 -本示例使用[@kit.AssetStoreKit](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/security/AssetStoreKit)相关接口实现了对敏感数据的保存、更新、查询、删除操作。 - -实现场景如下: - -1)用户使用本应用保存密码或信用卡号。 - -2)用户更新本应用管理的密码或信用卡号。 - -3)用户查询本应用管理的密码或信用卡号。 - -4)用户删除本应用管理的密码或信用卡号。 - -## 效果预览 -| **保存页面** | **删除页面** | **更新列表页面** | **更新编辑页面** | -|---------|----------|------------|----------| -|![](screenshots/save.jpeg)|![](screenshots/delete.jpeg)|![](screenshots/update_list.jpeg)|![](screenshots/update_edit.jpeg)| -| **查询页面** | **批量查询结果页面** | **单个查询结果页面** | -![](screenshots/query.jpeg)|![](screenshots/batch_query_result.jpeg)|![](screenshots/single_query_result.jpeg)| - -使用说明: -* 保存敏感数据: - * 输入账号、密码、标签,其中标签可以填写多个,但不超过4个 - * 点击“保存”按钮 - -* 删除敏感数据,可使用以下任意一种方式删除: - * 批量删除:不输入任何信息,或输入单个或多个标签),点击“删除”按钮 - * 单个删除:输入账号、标签(可选),点击“删除”按钮 -* 更新敏感数据: - * 点击标题栏的“更新”,进入更新页面 - * 在显示的账号列表中,点击待更新的账号 - * 输入锁屏密码,进入编辑界面 - * 输入更新后的密码和标签,点击“更新” -* 查询敏感数据,可使用以下任意一种方式删除: - * 批量查询:不输入任何信息,或输入单个或多个标签),点击“查询”按钮,显示保存的信息列表,不含“密码/信用卡号” - * 单个查询:输入账号、标签(可选),点击“查询”按钮,输入锁屏密码,显示该账号详细信息,含“密码/信用卡号” - -## 工程目录 -``` -entry/src/main/ets/ -|---entryAbility -| |---EntryAbility.ts -|---model -| |---AssetModel.ets // 关键资产存储模型文件 -|---pages -| |---Index.ets // 主页面 -| |---QueryResultPage.ets // 查询结果界面 -| |---UpdatePage.ets // 更新页面 -``` -## 具体实现 -本应用分为四个主页面:保存、删除、更新、查询,通过TabBuilder组件实现页面直接的切换。 -* **保存页面**:解析用户输入的账号、密码、标签信息,传入@kit.AssetStoreKit提供的add接口,从而实现将短敏感数据存储到关键资产存储服务中。 - -* **删除页面**:解析用户输入的账号、标签信息,传入@kit.AssetStoreKit提供的remove接口,删除满足条件的短敏感数据。 - -* **更新页面**: - - 1)调用@kit.AssetStoreKit提供的query接口,查询关键资产中存储的全量账号。 - - 2)调用@kit.AssetStoreKit提供的preQuery接口,将返回的challenge传给@kit.UserAuthenticationKit提供的on接口。 - - 3)待用户输入锁屏密码后,将onResult接口返回的AuthToken传给@kit.AssetStoreKit提供的query接口,用以查询旧的敏感数据明文。 - - 4)解析用户输入的账号、标签信息,传入@kit.AssetStoreKit提供的update接口,更新关键资产存储服务中存储的敏感数据。 - - 5)退出更新界面时,调用@kit.AssetStoreKit提供的postQuery接口清理资源 - -* **查询页面**: - - 用户未输入账号: - - 解析用户输入的标签信息,传入@kit.AssetStoreKit提供的query接口,查询关键资产存储服务中存储的账号、标签。 - - 用户输入了账号: - - 1)调用@kit.AssetStoreKit提供的preQuery接口,将返回的challenge传给@kit.UserAuthenticationKit提供的on接口。 - - 2)待用户输入锁屏密码后,将onResult接口返回的AuthToken、用户输入的账号、标签信息传给@kit.AssetStoreKit提供的query接口,用以查询敏感数据明文。 - - 3)调用@kit.AssetStoreKit提供的postQuery接口清理资源。 - -## 相关权限 -[ohos.permission.ACCESS_BIOMETRIC](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionaccess_biometric) - -[ohos.permission.STORE_PERSISTENT_DATA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionstore_persistent_data) - -## 依赖 -不涉及 - -## 约束与限制 -1.本示例仅支持标准系统上运行。 - -2.本示例支持API11版本SDK,SDK版本号(API Version 11 Release), 镜像版本号(4.1Release)。 - -3.本示例需要使用DevEco Studio版本号(4.1Release)及以上版本才可编译运行。 - -4.本示例需要在设备设置锁屏密码后使用。其中,更新、查询结果页面输入锁屏密码方可进入。 - -## 下载 -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/BasicFeature/Security/Asset/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master - +# 关键资产存储服务 +## 介绍 +本示例使用[@kit.AssetStoreKit](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/security/AssetStoreKit)相关接口实现了对敏感数据的保存、更新、查询、删除操作。 + +实现场景如下: + +1)用户使用本应用保存密码或信用卡号。 + +2)用户更新本应用管理的密码或信用卡号。 + +3)用户查询本应用管理的密码或信用卡号。 + +4)用户删除本应用管理的密码或信用卡号。 + +## 效果预览 +| **保存页面** | **删除页面** | **更新列表页面** | **更新编辑页面** | +|---------|----------|------------|----------| +|![](screenshots/save.jpeg)|![](screenshots/delete.jpeg)|![](screenshots/update_list.jpeg)|![](screenshots/update_edit.jpeg)| +| **查询页面** | **批量查询结果页面** | **单个查询结果页面** | +![](screenshots/query.jpeg)|![](screenshots/batch_query_result.jpeg)|![](screenshots/single_query_result.jpeg)| + +使用说明: +* 保存敏感数据: + * 输入账号、密码、标签,其中标签可以填写多个,但不超过4个 + * 点击“保存”按钮 + +* 删除敏感数据,可使用以下任意一种方式删除: + * 批量删除:不输入任何信息,或输入单个或多个标签),点击“删除”按钮 + * 单个删除:输入账号、标签(可选),点击“删除”按钮 +* 更新敏感数据: + * 点击标题栏的“更新”,进入更新页面 + * 在显示的账号列表中,点击待更新的账号 + * 输入锁屏密码,进入编辑界面 + * 输入更新后的密码和标签,点击“更新” +* 查询敏感数据,可使用以下任意一种方式删除: + * 批量查询:不输入任何信息,或输入单个或多个标签),点击“查询”按钮,显示保存的信息列表,不含“密码/信用卡号” + * 单个查询:输入账号、标签(可选),点击“查询”按钮,输入锁屏密码,显示该账号详细信息,含“密码/信用卡号” + +## 工程目录 +``` +entry/src/main/ets/ +|---entryAbility +| |---EntryAbility.ts +|---model +| |---AssetModel.ets // 关键资产存储模型文件 +|---pages +| |---Index.ets // 主页面 +| |---QueryResultPage.ets // 查询结果界面 +| |---UpdatePage.ets // 更新页面 +``` +## 具体实现 +本应用分为四个主页面:保存、删除、更新、查询,通过TabBuilder组件实现页面直接的切换。 +* **保存页面**:解析用户输入的账号、密码、标签信息,传入@kit.AssetStoreKit提供的add接口,从而实现将短敏感数据存储到关键资产存储服务中。 + +* **删除页面**:解析用户输入的账号、标签信息,传入@kit.AssetStoreKit提供的remove接口,删除满足条件的短敏感数据。 + +* **更新页面**: + + 1)调用@kit.AssetStoreKit提供的query接口,查询关键资产中存储的全量账号。 + + 2)调用@kit.AssetStoreKit提供的preQuery接口,将返回的challenge传给@kit.UserAuthenticationKit提供的on接口。 + + 3)待用户输入锁屏密码后,将onResult接口返回的AuthToken传给@kit.AssetStoreKit提供的query接口,用以查询旧的敏感数据明文。 + + 4)解析用户输入的账号、标签信息,传入@kit.AssetStoreKit提供的update接口,更新关键资产存储服务中存储的敏感数据。 + + 5)退出更新界面时,调用@kit.AssetStoreKit提供的postQuery接口清理资源 + +* **查询页面**: + + 用户未输入账号: + + 解析用户输入的标签信息,传入@kit.AssetStoreKit提供的query接口,查询关键资产存储服务中存储的账号、标签。 + + 用户输入了账号: + + 1)调用@kit.AssetStoreKit提供的preQuery接口,将返回的challenge传给@kit.UserAuthenticationKit提供的on接口。 + + 2)待用户输入锁屏密码后,将onResult接口返回的AuthToken、用户输入的账号、标签信息传给@kit.AssetStoreKit提供的query接口,用以查询敏感数据明文。 + + 3)调用@kit.AssetStoreKit提供的postQuery接口清理资源。 + +## 相关权限 +[ohos.permission.ACCESS_BIOMETRIC](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionaccess_biometric) + +[ohos.permission.STORE_PERSISTENT_DATA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionstore_persistent_data) + +## 依赖 +不涉及 + +## 约束与限制 +1.本示例仅支持标准系统上运行。 + +2.本示例支持API11版本SDK,SDK版本号(API Version 11 Release), 镜像版本号(4.1Release)。 + +3.本示例需要使用DevEco Studio版本号(4.1Release)及以上版本才可编译运行。 + +4.本示例需要在设备设置锁屏密码后使用。其中,更新、查询结果页面输入锁屏密码方可进入。 + +## 下载 +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/BasicFeature/Security/Asset/ > .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/BasicFeature/Security/Asset/build-profile.json5 b/code/BasicFeature/Security/Asset/build-profile.json5 old mode 100755 new mode 100644 index bba5ac612e..4ed303e76d --- a/code/BasicFeature/Security/Asset/build-profile.json5 +++ b/code/BasicFeature/Security/Asset/build-profile.json5 @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2024 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} +/* + * Copyright (c) 2024 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/BasicFeature/Security/Asset/entry/.gitignore b/code/BasicFeature/Security/Asset/entry/.gitignore old mode 100755 new mode 100644 index 32abf8fd5e..e2713a2779 --- a/code/BasicFeature/Security/Asset/entry/.gitignore +++ b/code/BasicFeature/Security/Asset/entry/.gitignore @@ -1,6 +1,6 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx +/node_modules +/oh_modules +/.preview +/build +/.cxx /.test \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/build-profile.json5 b/code/BasicFeature/Security/Asset/entry/build-profile.json5 old mode 100755 new mode 100644 index 8830cfe9f6..ba27ce5b78 --- a/code/BasicFeature/Security/Asset/entry/build-profile.json5 +++ b/code/BasicFeature/Security/Asset/entry/build-profile.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 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', - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2024 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', + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/hvigorfile.ts b/code/BasicFeature/Security/Asset/entry/hvigorfile.ts old mode 100755 new mode 100644 index ba9480d0a9..c6edcd9048 --- a/code/BasicFeature/Security/Asset/entry/hvigorfile.ts +++ b/code/BasicFeature/Security/Asset/entry/hvigorfile.ts @@ -1,6 +1,6 @@ -import { hapTasks } from '@ohos/hvigor-ohos-plugin'; - -export default { - system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ - plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ -} +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/BasicFeature/Security/Asset/entry/oh-package.json5 b/code/BasicFeature/Security/Asset/entry/oh-package.json5 old mode 100755 new mode 100644 index 7dca654ad8..f18954a32b --- a/code/BasicFeature/Security/Asset/entry/oh-package.json5 +++ b/code/BasicFeature/Security/Asset/entry/oh-package.json5 @@ -1,11 +1,11 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dynamicDependencies": {}, - "dependencies": {} -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dynamicDependencies": {}, + "dependencies": {} +} diff --git a/code/BasicFeature/Security/Asset/entry/src/main/ets/common/Logger.ts b/code/BasicFeature/Security/Asset/entry/src/main/ets/common/Logger.ts old mode 100755 new mode 100644 index c4389eead5..e434dc8aa9 --- a/code/BasicFeature/Security/Asset/entry/src/main/ets/common/Logger.ts +++ b/code/BasicFeature/Security/Asset/entry/src/main/ets/common/Logger.ts @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import hilog from '@ohos.hilog'; - -/** - * Common log for all features. - */ -export class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } - - fatal(...args: string[]): void { - hilog.fatal(this.domain, this.prefix, this.format, args); - } - - isLoggable(level: number): void { - hilog.isLoggable(this.domain, this.prefix, level); - } -} - -export let logger = new Logger('[Sample_FileManager]'); - -export function myparseInt(s: string, n: number) { - return parseInt(s, n) +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import hilog from '@ohos.hilog'; + +/** + * Common log for all features. + */ +export class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } + + fatal(...args: string[]): void { + hilog.fatal(this.domain, this.prefix, this.format, args); + } + + isLoggable(level: number): void { + hilog.isLoggable(this.domain, this.prefix, level); + } +} + +export let logger = new Logger('[Sample_FileManager]'); + +export function myparseInt(s: string, n: number) { + return parseInt(s, n) } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/Security/Asset/entry/src/main/ets/entryability/EntryAbility.ts old mode 100755 new mode 100644 index ebb6ff604e..83b1c4540d --- a/code/BasicFeature/Security/Asset/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/Security/Asset/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2024 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 } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { UIAbility } from '@kit.AbilityKit'; -import { Want } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - 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'); - } -} +/* + * Copyright (c) 2024 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 } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { UIAbility } from '@kit.AbilityKit'; +import { Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + 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/BasicFeature/Security/Asset/entry/src/main/ets/model/AssetModel.ets b/code/BasicFeature/Security/Asset/entry/src/main/ets/model/AssetModel.ets old mode 100755 new mode 100644 index 9d0f2b701c..f61218649a --- a/code/BasicFeature/Security/Asset/entry/src/main/ets/model/AssetModel.ets +++ b/code/BasicFeature/Security/Asset/entry/src/main/ets/model/AssetModel.ets @@ -1,333 +1,333 @@ -/* - * Copyright (c) 2024 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 { asset } from '@kit.AssetStoreKit'; -import { promptAction } from '@kit.ArkUI'; -import { util } from '@kit.ArkTS'; -import { logger } from '../common/Logger'; -import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; - -let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - -function removeDuplicateAndSort(arr: string[]): string[] { - let newArr = new Array(); - for (let i = 0; i < arr.length; i++) { - if (newArr.indexOf(arr[i]) === -1 && arr[i] != '') { - newArr.push(arr[i]); - } - } - return newArr.sort(); -} - -export function log(resource: Resource) { - promptAction.showToast({ message: resource }) - logger.info(getContext().resourceManager.getStringSync(resource)); -} - -export function stringToArray(str: string): Uint8Array { - let textEncoder = new util.TextEncoder(); - return textEncoder.encodeInto(str); -} - -function newNullArray(): Uint8Array { - return new Uint8Array([0]); -} - -function arrayToString(arr: Uint8Array): string { - let textDecoder = util.TextDecoder.create("utf-8", { - ignoreBOM: true - }); - let str = textDecoder.decodeWithStream(arr, { - stream: false - }) - return str; -} - -export async function addAssetPromise(account: string, password: string, label: string) { - let labelList: Array = label.split(';'); - labelList = removeDuplicateAndSort(labelList); - if (labelList.length > 4) { - log($r('app.string.save_failed_for_label')) - return; - } - let attr: asset.AssetMap = new Map(); - attr.set(asset.Tag.ALIAS, stringToArray(account)) - attr.set(asset.Tag.SECRET, stringToArray(password)) - if (labelList[0]) { - attr.set(asset.Tag.DATA_LABEL_NORMAL_1, stringToArray(labelList[0])) - } - if (labelList[1]) { - attr.set(asset.Tag.DATA_LABEL_NORMAL_2, stringToArray(labelList[1])) - } - if (labelList[2]) { - attr.set(asset.Tag.DATA_LABEL_NORMAL_3, stringToArray(labelList[2])) - } - if (labelList[3]) { - attr.set(asset.Tag.DATA_LABEL_NORMAL_4, stringToArray(labelList[3])) - } - attr.set(asset.Tag.AUTH_TYPE, asset.AuthType.ANY) - attr.set(asset.Tag.IS_PERSISTENT, true) - try { - await asset.add(attr); - log($r('app.string.save_success')) - } catch (error) { - if (error.code === 24000003) { - log($r('app.string.save_failed_for_account_exist')); - } else { - log($r('app.string.save_failed')) - } - } -} - -export async function removeAssetPromise(deleteAccount: string, deleteLabel: string) { - let attr: asset.AssetMap = new Map(); - if (deleteAccount.length > 0) { - attr.set(asset.Tag.ALIAS, stringToArray(deleteAccount)) - } - if (deleteLabel.length == 0) { - try { - await asset.remove(attr); - log($r('app.string.remove_success')) - } catch (error) { - if (error.code === 24000002) { - log($r('app.string.remove_failed_for_account_not_exist')); - } else { - log($r('app.string.remove_failed')) - } - } - } else { - let labelList = deleteLabel.split(';'); - labelList = removeDuplicateAndSort(labelList); - let assetList: asset.AssetMap[] = await getArrangedMap(deleteAccount, labelList) - if (assetList.length == 0) { - log($r('app.string.remove_failed_for_account_not_exist')); - return; - } - let map: Map = new Map(); - for (let i = 0; i < assetList.length; i++) { - map.set(asset.Tag.ALIAS, assetList[i].get(asset.Tag.ALIAS) as Uint8Array); - try { - await asset.remove(map) - } catch (error) { - log($r('app.string.remove_failed')) - return; - } - } - log($r('app.string.remove_success')) - } -} - -function compareArray(array1: Uint8Array, array2: Uint8Array): boolean { - return JSON.stringify(array1) == JSON.stringify(array2); -} - -function addLabelInfo(label: string, tag: asset.Tag, account: asset.AssetMap, emptyArray: Uint8Array): string { - if (account.has(tag) && !compareArray(account.get(tag) as Uint8Array, emptyArray)) { - label += arrayToString(account.get(tag) as Uint8Array) + ';' - } - return label; -} - -function addElement(attr: asset.AssetMap, label: string, key: asset.Tag) { - if (label){ - attr.set(key, stringToArray(label)) - } else { - attr.set(key, newNullArray()) - } -} - -let normalLabelList: Array = new Array(asset.Tag.DATA_LABEL_NORMAL_1, - asset.Tag.DATA_LABEL_NORMAL_2, asset.Tag.DATA_LABEL_NORMAL_3, asset.Tag.DATA_LABEL_NORMAL_4); - -// asset获取的map转换为显示map -function convertAssetList(assetList: asset.AssetMap[], accountList: Map[]): Array> { - for (let account of assetList) { - let map: Map = new Map(); - let alias = arrayToString(account.get(asset.Tag.ALIAS) as Uint8Array); - if (account.has(asset.Tag.SECRET)) { - let secret = arrayToString(account.get(asset.Tag.SECRET) as Uint8Array); - map.set('secret', secret); - } - let label = '' - let emptyArray = newNullArray(); - for (let currentLabel of normalLabelList) { - label = addLabelInfo(label, currentLabel, account, emptyArray); - } - label = label.slice(0, label.length - 1) - map.set('alias', alias); - map.set('label', label) - accountList.push(map); - } - return accountList; -} - -export async function updateAssetPromise(reserveAccount: string, reservePassword: string, reserveLabel: string) { - let labelList = reserveLabel.split(';'); - labelList = removeDuplicateAndSort(labelList); - if (labelList.length > 4) { - log($r('app.string.update_failed_for_label_over_4')) - return; - } - - let attr: asset.AssetMap = new Map(); - attr.set(asset.Tag.SECRET, stringToArray(reservePassword)) - normalLabelList.forEach((element: asset.Tag, index: number) => { - addElement(attr, labelList[index], element); - }); - - let attr2: asset.AssetMap = new Map(); - attr2.set(asset.Tag.ALIAS, stringToArray(reserveAccount)) - - try { - await asset.update(attr2, attr) - log($r('app.string.update_success')) - } catch (error) { - log($r('app.string.update_failed')); - } -} - -async function getFirstQuery(alias: string, label: string): Promise -{ - let res: Array = new Array(); - let options: asset.Tag[] = [ asset.Tag.DATA_LABEL_NORMAL_1, asset.Tag.DATA_LABEL_NORMAL_2, - asset.Tag.DATA_LABEL_NORMAL_3, asset.Tag.DATA_LABEL_NORMAL_4 ]; - for (let i = 0; i < options.length; i++) { - let map: asset.AssetMap = new Map(); - if (alias.length > 0) { - map.set(asset.Tag.ALIAS, stringToArray(alias)); - map.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL) - } - map.set(options[i], stringToArray(label)); - try { - let temp: Array = await asset.query(map) - res = res.concat(temp); - } catch(e) { - // skip the error: not found - } - } - return res; -} - -function getLabelList(input: asset.AssetMap): Array -{ - let tmp = new Array(); - if (input.has(asset.Tag.DATA_LABEL_NORMAL_1)) { - tmp.push(arrayToString(input.get(asset.Tag.DATA_LABEL_NORMAL_1) as Uint8Array)); - } - if (input.has(asset.Tag.DATA_LABEL_NORMAL_2)) { - tmp.push(arrayToString(input.get(asset.Tag.DATA_LABEL_NORMAL_2) as Uint8Array)); - } - if (input.has(asset.Tag.DATA_LABEL_NORMAL_3)) { - tmp.push(arrayToString(input.get(asset.Tag.DATA_LABEL_NORMAL_3) as Uint8Array)); - } - if (input.has(asset.Tag.DATA_LABEL_NORMAL_4)) { - tmp.push(arrayToString(input.get(asset.Tag.DATA_LABEL_NORMAL_4) as Uint8Array)); - } - return tmp; -} - -async function getArrangedMap(alias: string, labels: string[]): Promise -{ - let first_query: asset.AssetMap[] = await getFirstQuery(alias, labels[0]); - let res: asset.AssetMap[] = first_query.filter((map: asset.AssetMap) => { - let list: Array = getLabelList(map); - for (let i = 1; i < labels.length; i++) { - if (list.indexOf(labels[i]) < 0) { - return false; - } - } - return true; - }); - return res; -} - -export async function queryAssetPromise(checkAccount: string, checkLabel: string): Promise>> { - let accountList: Map[] = new Array>(); - let assetMap: asset.AssetMap = new Map(); - if (checkAccount.length > 0) { - assetMap.set(asset.Tag.ALIAS, stringToArray(checkAccount)) - assetMap.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL) - } - if (checkLabel.length == 0) { // query condition do not contain label. - try { - let assetList: Array = await asset.query(assetMap); - return convertAssetList(assetList, accountList); - } catch (error) { - if (error.code === 24000002) { - log($r('app.string.query_no_result')); - } else { - log($r('app.string.query_failed')); - } - return new Array>(); - } - } else { - let labelList: Array = checkLabel.split(';'); - labelList = removeDuplicateAndSort(labelList); - let assetList: asset.AssetMap[] = await getArrangedMap(checkAccount, labelList) - if (assetList.length == 0) { - log($r('app.string.query_no_result')); - return new Array>(); - } - return convertAssetList(assetList, accountList); - } -} - -export async function preQueryAssetPromise(checkAccount: string): Promise { - let assetMap: asset.AssetMap = new Map(); - assetMap.set(asset.Tag.AUTH_VALIDITY_PERIOD, 10 * 60) - assetMap.set(asset.Tag.AUTH_TYPE, asset.AuthType.ANY) - if (checkAccount.length > 0) { - assetMap.set(asset.Tag.ALIAS, stringToArray(checkAccount)) - } - try { - return await asset.preQuery(assetMap) - } catch (error) { - return new Uint8Array(0) - } -} - -export async function queryAuthAssetPromise(checkAccount: string, challenge: Uint8Array, - authToken: Uint8Array): Promise> { - let attr: asset.AssetMap = new Map(); - let account: Map = new Map(); - if (checkAccount.length > 0) { - attr.set(asset.Tag.ALIAS, stringToArray(checkAccount)); - attr.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL); - attr.set(asset.Tag.AUTH_CHALLENGE, challenge); - attr.set(asset.Tag.AUTH_TOKEN, authToken) - } - try { - let data: Array = await asset.query(attr); - let accountList: Map[] = new Array>(); - accountList = convertAssetList(data, accountList); - return accountList[0] - } catch (error) { - if (error.code === 24000002) { - log($r('app.string.query_no_result')); - } else { - log($r('app.string.query_failed')); - } - return account; - } -} - -export async function postQueryAssetPromise(challenge: Uint8Array) { - let attr: asset.AssetMap = new Map(); - attr.set(asset.Tag.AUTH_CHALLENGE, challenge); - try { - await asset.postQuery(attr); - } catch (error) { - } -} +/* + * Copyright (c) 2024 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 { asset } from '@kit.AssetStoreKit'; +import { promptAction } from '@kit.ArkUI'; +import { util } from '@kit.ArkTS'; +import { logger } from '../common/Logger'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + +function removeDuplicateAndSort(arr: string[]): string[] { + let newArr = new Array(); + for (let i = 0; i < arr.length; i++) { + if (newArr.indexOf(arr[i]) === -1 && arr[i] != '') { + newArr.push(arr[i]); + } + } + return newArr.sort(); +} + +export function log(resource: Resource) { + promptAction.showToast({ message: resource }) + logger.info(getContext().resourceManager.getStringSync(resource)); +} + +export function stringToArray(str: string): Uint8Array { + let textEncoder = new util.TextEncoder(); + return textEncoder.encodeInto(str); +} + +function newNullArray(): Uint8Array { + return new Uint8Array([0]); +} + +function arrayToString(arr: Uint8Array): string { + let textDecoder = util.TextDecoder.create("utf-8", { + ignoreBOM: true + }); + let str = textDecoder.decodeWithStream(arr, { + stream: false + }) + return str; +} + +export async function addAssetPromise(account: string, password: string, label: string) { + let labelList: Array = label.split(';'); + labelList = removeDuplicateAndSort(labelList); + if (labelList.length > 4) { + log($r('app.string.save_failed_for_label')) + return; + } + let attr: asset.AssetMap = new Map(); + attr.set(asset.Tag.ALIAS, stringToArray(account)) + attr.set(asset.Tag.SECRET, stringToArray(password)) + if (labelList[0]) { + attr.set(asset.Tag.DATA_LABEL_NORMAL_1, stringToArray(labelList[0])) + } + if (labelList[1]) { + attr.set(asset.Tag.DATA_LABEL_NORMAL_2, stringToArray(labelList[1])) + } + if (labelList[2]) { + attr.set(asset.Tag.DATA_LABEL_NORMAL_3, stringToArray(labelList[2])) + } + if (labelList[3]) { + attr.set(asset.Tag.DATA_LABEL_NORMAL_4, stringToArray(labelList[3])) + } + attr.set(asset.Tag.AUTH_TYPE, asset.AuthType.ANY) + attr.set(asset.Tag.IS_PERSISTENT, true) + try { + await asset.add(attr); + log($r('app.string.save_success')) + } catch (error) { + if (error.code === 24000003) { + log($r('app.string.save_failed_for_account_exist')); + } else { + log($r('app.string.save_failed')) + } + } +} + +export async function removeAssetPromise(deleteAccount: string, deleteLabel: string) { + let attr: asset.AssetMap = new Map(); + if (deleteAccount.length > 0) { + attr.set(asset.Tag.ALIAS, stringToArray(deleteAccount)) + } + if (deleteLabel.length == 0) { + try { + await asset.remove(attr); + log($r('app.string.remove_success')) + } catch (error) { + if (error.code === 24000002) { + log($r('app.string.remove_failed_for_account_not_exist')); + } else { + log($r('app.string.remove_failed')) + } + } + } else { + let labelList = deleteLabel.split(';'); + labelList = removeDuplicateAndSort(labelList); + let assetList: asset.AssetMap[] = await getArrangedMap(deleteAccount, labelList) + if (assetList.length == 0) { + log($r('app.string.remove_failed_for_account_not_exist')); + return; + } + let map: Map = new Map(); + for (let i = 0; i < assetList.length; i++) { + map.set(asset.Tag.ALIAS, assetList[i].get(asset.Tag.ALIAS) as Uint8Array); + try { + await asset.remove(map) + } catch (error) { + log($r('app.string.remove_failed')) + return; + } + } + log($r('app.string.remove_success')) + } +} + +function compareArray(array1: Uint8Array, array2: Uint8Array): boolean { + return JSON.stringify(array1) == JSON.stringify(array2); +} + +function addLabelInfo(label: string, tag: asset.Tag, account: asset.AssetMap, emptyArray: Uint8Array): string { + if (account.has(tag) && !compareArray(account.get(tag) as Uint8Array, emptyArray)) { + label += arrayToString(account.get(tag) as Uint8Array) + ';' + } + return label; +} + +function addElement(attr: asset.AssetMap, label: string, key: asset.Tag) { + if (label){ + attr.set(key, stringToArray(label)) + } else { + attr.set(key, newNullArray()) + } +} + +let normalLabelList: Array = new Array(asset.Tag.DATA_LABEL_NORMAL_1, + asset.Tag.DATA_LABEL_NORMAL_2, asset.Tag.DATA_LABEL_NORMAL_3, asset.Tag.DATA_LABEL_NORMAL_4); + +// asset获取的map转换为显示map +function convertAssetList(assetList: asset.AssetMap[], accountList: Map[]): Array> { + for (let account of assetList) { + let map: Map = new Map(); + let alias = arrayToString(account.get(asset.Tag.ALIAS) as Uint8Array); + if (account.has(asset.Tag.SECRET)) { + let secret = arrayToString(account.get(asset.Tag.SECRET) as Uint8Array); + map.set('secret', secret); + } + let label = '' + let emptyArray = newNullArray(); + for (let currentLabel of normalLabelList) { + label = addLabelInfo(label, currentLabel, account, emptyArray); + } + label = label.slice(0, label.length - 1) + map.set('alias', alias); + map.set('label', label) + accountList.push(map); + } + return accountList; +} + +export async function updateAssetPromise(reserveAccount: string, reservePassword: string, reserveLabel: string) { + let labelList = reserveLabel.split(';'); + labelList = removeDuplicateAndSort(labelList); + if (labelList.length > 4) { + log($r('app.string.update_failed_for_label_over_4')) + return; + } + + let attr: asset.AssetMap = new Map(); + attr.set(asset.Tag.SECRET, stringToArray(reservePassword)) + normalLabelList.forEach((element: asset.Tag, index: number) => { + addElement(attr, labelList[index], element); + }); + + let attr2: asset.AssetMap = new Map(); + attr2.set(asset.Tag.ALIAS, stringToArray(reserveAccount)) + + try { + await asset.update(attr2, attr) + log($r('app.string.update_success')) + } catch (error) { + log($r('app.string.update_failed')); + } +} + +async function getFirstQuery(alias: string, label: string): Promise +{ + let res: Array = new Array(); + let options: asset.Tag[] = [ asset.Tag.DATA_LABEL_NORMAL_1, asset.Tag.DATA_LABEL_NORMAL_2, + asset.Tag.DATA_LABEL_NORMAL_3, asset.Tag.DATA_LABEL_NORMAL_4 ]; + for (let i = 0; i < options.length; i++) { + let map: asset.AssetMap = new Map(); + if (alias.length > 0) { + map.set(asset.Tag.ALIAS, stringToArray(alias)); + map.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL) + } + map.set(options[i], stringToArray(label)); + try { + let temp: Array = await asset.query(map) + res = res.concat(temp); + } catch(e) { + // skip the error: not found + } + } + return res; +} + +function getLabelList(input: asset.AssetMap): Array +{ + let tmp = new Array(); + if (input.has(asset.Tag.DATA_LABEL_NORMAL_1)) { + tmp.push(arrayToString(input.get(asset.Tag.DATA_LABEL_NORMAL_1) as Uint8Array)); + } + if (input.has(asset.Tag.DATA_LABEL_NORMAL_2)) { + tmp.push(arrayToString(input.get(asset.Tag.DATA_LABEL_NORMAL_2) as Uint8Array)); + } + if (input.has(asset.Tag.DATA_LABEL_NORMAL_3)) { + tmp.push(arrayToString(input.get(asset.Tag.DATA_LABEL_NORMAL_3) as Uint8Array)); + } + if (input.has(asset.Tag.DATA_LABEL_NORMAL_4)) { + tmp.push(arrayToString(input.get(asset.Tag.DATA_LABEL_NORMAL_4) as Uint8Array)); + } + return tmp; +} + +async function getArrangedMap(alias: string, labels: string[]): Promise +{ + let first_query: asset.AssetMap[] = await getFirstQuery(alias, labels[0]); + let res: asset.AssetMap[] = first_query.filter((map: asset.AssetMap) => { + let list: Array = getLabelList(map); + for (let i = 1; i < labels.length; i++) { + if (list.indexOf(labels[i]) < 0) { + return false; + } + } + return true; + }); + return res; +} + +export async function queryAssetPromise(checkAccount: string, checkLabel: string): Promise>> { + let accountList: Map[] = new Array>(); + let assetMap: asset.AssetMap = new Map(); + if (checkAccount.length > 0) { + assetMap.set(asset.Tag.ALIAS, stringToArray(checkAccount)) + assetMap.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL) + } + if (checkLabel.length == 0) { // query condition do not contain label. + try { + let assetList: Array = await asset.query(assetMap); + return convertAssetList(assetList, accountList); + } catch (error) { + if (error.code === 24000002) { + log($r('app.string.query_no_result')); + } else { + log($r('app.string.query_failed')); + } + return new Array>(); + } + } else { + let labelList: Array = checkLabel.split(';'); + labelList = removeDuplicateAndSort(labelList); + let assetList: asset.AssetMap[] = await getArrangedMap(checkAccount, labelList) + if (assetList.length == 0) { + log($r('app.string.query_no_result')); + return new Array>(); + } + return convertAssetList(assetList, accountList); + } +} + +export async function preQueryAssetPromise(checkAccount: string): Promise { + let assetMap: asset.AssetMap = new Map(); + assetMap.set(asset.Tag.AUTH_VALIDITY_PERIOD, 10 * 60) + assetMap.set(asset.Tag.AUTH_TYPE, asset.AuthType.ANY) + if (checkAccount.length > 0) { + assetMap.set(asset.Tag.ALIAS, stringToArray(checkAccount)) + } + try { + return await asset.preQuery(assetMap) + } catch (error) { + return new Uint8Array(0) + } +} + +export async function queryAuthAssetPromise(checkAccount: string, challenge: Uint8Array, + authToken: Uint8Array): Promise> { + let attr: asset.AssetMap = new Map(); + let account: Map = new Map(); + if (checkAccount.length > 0) { + attr.set(asset.Tag.ALIAS, stringToArray(checkAccount)); + attr.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL); + attr.set(asset.Tag.AUTH_CHALLENGE, challenge); + attr.set(asset.Tag.AUTH_TOKEN, authToken) + } + try { + let data: Array = await asset.query(attr); + let accountList: Map[] = new Array>(); + accountList = convertAssetList(data, accountList); + return accountList[0] + } catch (error) { + if (error.code === 24000002) { + log($r('app.string.query_no_result')); + } else { + log($r('app.string.query_failed')); + } + return account; + } +} + +export async function postQueryAssetPromise(challenge: Uint8Array) { + let attr: asset.AssetMap = new Map(); + attr.set(asset.Tag.AUTH_CHALLENGE, challenge); + try { + await asset.postQuery(attr); + } catch (error) { + } +} diff --git a/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 1a72b1df8d..ad01ccfdce --- a/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/Index.ets @@ -1,700 +1,700 @@ -/* - * Copyright (c) 2024 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 { router } from '@kit.ArkUI'; -import { promptAction } from '@kit.ArkUI'; -import { userAuth } from '@kit.UserAuthenticationKit'; -import { logger } from '../common/Logger'; -import { addAssetPromise, removeAssetPromise, queryAssetPromise, queryAuthAssetPromise, preQueryAssetPromise, log, - postQueryAssetPromise } from '../model/AssetModel'; - -interface AssetItem { - alias: string; - secret: string; - dataLabel: string; -} - -function isReserveClickable(reserveAccount: string, reservePassword: string, reserveLabel: string): boolean { - return reserveAccount !== '' && reservePassword !== '' && reserveLabel != ''; -} - -async function getAuthTokenCallback(challenge: Uint8Array, - callback: (isSuccess: boolean, challenge: Uint8Array) => void) { - const authParam: userAuth.AuthParam = { - challenge: challenge, - authType: [userAuth.UserAuthType.PIN,userAuth.UserAuthType.FACE,userAuth.UserAuthType.FINGERPRINT], - authTrustLevel: userAuth.AuthTrustLevel.ATL1, - }; - const widgetParam: userAuth.WidgetParam = { - title: '请输入锁屏密码', - }; - try { - let userAuthInstance = userAuth.getUserAuthInstance(authParam, widgetParam); - userAuthInstance.on('result', { - onResult(result) { - logger.info('userAuthInstance callback result = ' + JSON.stringify(result)); - if (result.result == 12500000) { - logger.info('userAuthInstance callback result success'); - callback(true, result.token) - } else if (result.result == 12500010) { - promptAction.showToast({ message: $r('app.string.please_set_pwd') }) - callback(false, new Uint8Array(0)) - } - } - }); - userAuthInstance.start(); - } catch (error) { - logger.info('auth catch error: ' + JSON.stringify(error)); - promptAction.showToast({ message: $r('app.string.auth_failed') }) - callback(false, new Uint8Array(0)) - } -} - -function convertMapArrayToMapItem(array: Array>): Array -{ - let res = new Array(); - for (let dataElement of array) { - let tmp: AssetItem = { - alias: dataElement.get('alias') as string, - secret: dataElement.get('secret') as string, - dataLabel: dataElement.get('label') as string, - }; - res.push(tmp) - } - return res; -} - -@Entry -@Component -struct Page { - private challenge: Uint8Array = new Uint8Array; - private authToken: Uint8Array = new Uint8Array; - @State reserveAccount: string = ''; - @State reservePassword: string = ''; - @State reserveLabel: string = ''; - @State deleteAccount: string = ''; - @State deleteLabel: string = ''; - @State checkAccount: string = ''; - @State checkLabel: string = ''; - @State eventType: string = '' - @State index: number = 0 - @State assetArr: string[] = new Array(); - private tabsController: TabsController = new TabsController(); - @State view: Visibility[] = [Visibility.Hidden, Visibility.Visible, Visibility.None]; - @State indexView: number = 0 - - @Builder TabBuilder(index: number, name: string) { - Column() { - Row().height(this.index === index ? 8 : 17) - Text(name) - .fontColor(0x182413) - .fontSize(this.index === index ? 30 : 20) - .fontWeight(this.index === index ? 700 : 500) - .lineHeight(this.index === index ? 41 : 28) - .opacity(this.index === index ? 1 : 0.7) - .fontFamily(this.index === index ? 'HarmonyHeiTi-Bold' : 'HarmonyHeiTi-Medium') - .margin(this.index == 0 ? {left: 24} : {left: 0}) - Row().height(this.index === index ? 7 : 11) - } - .width('100%') - } - - build() { - Tabs({ - index: 0, - controller: this.tabsController }) { - /* 保存页面 */ - TabContent() { - Column() { - Column() { - /* 账号 */ - Row() { - Text("*").fontColor(0xFFE84026) - Text($r('app.string.account')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .margin({ top: "2.3%", bottom: "1.1%" }) - } - .width('86.7%').height('7.14%') - .margin({ top: 4 }) - - /* 账号输入 */ - Row() { - TextInput({ placeholder: $r('app.string.please_input_account') }) - .fontColor(0x182431) - .defaultFocus(false) - .id('account_input') - .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0.00px' }) - .backgroundColor(Color.Transparent) - .borderRadius(0) - .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) - .onChange((value: string) => { - this.reserveAccount = value; - }) - .onEditChange((isEditing: boolean) => { - if (isEditing === true) { - this.eventType = 'Down1'; - } - }) - } - .width('86.7%').height('7.14%') - - if (this.eventType === 'Down1') { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: 12, - right: 12 - }) - .backgroundColor(0x182431) - } else { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431') - } - - /* 密码 */ - Row() { - Text("*").fontColor(0xFFE84026) - Text($r('app.string.secret_or_card_num')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .fontWeight(500) - .margin({ top: "2.3%", bottom: "1.1%" }) - } - .width('86.7%').height('7.14%') - - /* 密码输入 */ - Row() { - TextInput({ placeholder: $r('app.string.please_input_secret_or_card_num') }) - .type(InputType.Password) - .defaultFocus(false) - .id('secret_input') - .fontColor(0x182431) - .padding({ top: '1.70%', right: '0', bottom: '1.70%', left: '0.00px' }) - .backgroundColor(Color.Transparent) - .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) - .onChange((value: string) => { - this.reservePassword = value; - }) - .onTouch((event: TouchEvent) => { - if (event.type === TouchType.Down) { - this.eventType = 'Down2'; - } - }) - .margin({ top: '0.00vp', right: '-12vp', bottom: '4.00vp', left: '0.00vp' }) - } - .width('86.7%').height('7.14%') - if (this.eventType === 'Down2') { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor(0x182431) - } else { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431') - } - - /* 标签 */ - Row() { - Text("*").fontColor(0xFFE84026) - Text($r('app.string.label')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .fontWeight(500) - .id('label') - .margin({ top: "2.3%", bottom: "1.1%" }) - } - .width('86.7%').height('7.14%') - - /* 标签输入 */ - Row() { - TextInput({ placeholder: $r('app.string.please_input_label') }) - .fontColor(0x182431) - .defaultFocus(false) - .id('label_input') - .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0.00px' }) - .backgroundColor(Color.Transparent) - .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) - .onChange((value: string) => { - this.reserveLabel = value; - }) - .onTouch((event: TouchEvent) => { - if (event.type === TouchType.Down) { - this.eventType = 'Down3'; - } - }) - } - .width('86.7%').height('7.14%') - if (this.eventType === 'Down3') { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor(0x182431).margin({ bottom: 4}) - } else { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431').margin({ bottom: 4}) - } - } - .backgroundColor(0xFFFFFF).borderRadius(16) - - Blank() - - Row() { - /* 底部按钮 */ - Button($r('app.string.save'), { type: ButtonType.Capsule, stateEffect: false }) - .backgroundColor(0x007DFF).fontColor('white') - .borderRadius(20) - .width('86.7%') - .height(40) - .id('save') - .enabled(isReserveClickable(this.reserveAccount, this.reservePassword, this.reserveLabel)) - .onClick(() => { - addAssetPromise(this.reserveAccount, this.reservePassword, this.reserveLabel) - }) - } - .margin({ bottom: '8.1%' }) - } - .height('100%') - } - .tabBar(this.TabBuilder(0, "保存")) - - /* 删除页面 */ - TabContent() { - Column() { - Column() { - /* 账号 */ - Row() { - Text($r('app.string.account')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .margin({ top: '2.3%', bottom: '1.1%' }) - } - .width('86.7%').height('7.14%') - .margin({ top: 4 }) - - /* 用户名输入 */ - Row() { - TextInput({ placeholder: $r('app.string.please_input_account') }) - .fontColor(0x182431) - .defaultFocus(false) - .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) - .backgroundColor(Color.Transparent) - .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) - .onChange((value: string) => { - this.deleteAccount = value; - }) - .onTouch((event: TouchEvent) => { - if (event.type === TouchType.Down) { - this.eventType = 'Down4'; - } - }) - } - .width('86.7%').height('7.14%') - - if (this.eventType === 'Down4') { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor(0x182431) - } else { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431') - } - - /* 标签 */ - Row() { - Text($r('app.string.label')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .fontWeight(500) - .margin({ top: '2.3%', bottom: '1.1%' }) - } - .width('86.7%').height('7.14%') - - /* 标签输入 */ - Row() { - TextInput({ placeholder: $r('app.string.please_input_label') }) - .fontColor(0x182431) - .defaultFocus(false) - .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) - .backgroundColor(Color.Transparent) - .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) - .onChange((value: string) => { - this.deleteLabel = value; - }) - .onTouch((event: TouchEvent) => { - if (event.type === TouchType.Down) { - this.eventType = 'Down5'; - } - }) - } - .width('86.7%').height('7.14%') - - if (this.eventType === 'Down5') { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor(0x182431).margin({ bottom: 4}) - } else { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431').margin({ bottom: 4}) - } - } - .backgroundColor(0xFFFFFF).borderRadius(16) - - Blank() - Row() { - /* 底部按钮 */ - Button($r('app.string.delete'), { type: ButtonType.Capsule, stateEffect: false }) - .backgroundColor(0x007DFF).fontColor('white') - .borderRadius(20) - .width('86.7%') - .height(40) - .onClick(() => { - removeAssetPromise(this.deleteAccount, this.deleteLabel) - }) - } - .margin({ bottom: '8.1%' }) - } - .height('100%') - } - .tabBar(this.TabBuilder(1, "删除")) - - /* 更新页面 */ - TabContent() { - Column() { - Column() { - List({ space: 0, initialIndex: 0 }) { // 查询列表 - ForEach(this.assetArr, (item: string) => { - ListItem() { - Column() { - /* 账号 */ - Row() { - Row() { - Text(item) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .textAlign(TextAlign.Start) - .margin({ top: '2.3%', bottom: '1.1%' }) - } - - Blank() - Row() { - Image($r('app.media.forward')) - .height(18) - .width(9) - .fillColor('#182431') - } - } - .width('100%').height('7.14%') - .onClick(async () => { - let account = await queryAuthAssetPromise(item, this.challenge, this.authToken); - router.pushUrl({ - url: 'pages/UpdatePage', - params: { name: item, pwd: account.get('secret'), label: account.get("label") } - }, router.RouterMode.Standard, (err) => { - if (err) { - logger.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); - return; - } - }); - }); - } - .margin({ right: 12, left: 12 }) - } - }, (item: string) => item) - } - .listDirection(Axis.Vertical) // 排列方向 - .divider({ strokeWidth: 1, color: '#0D182431', startMargin: 12, endMargin: 12 }) // 每行之间的分界线 - .edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果 - } - .margin({ right: 12, left: 12 }) - .backgroundColor(0xFFFFFF).borderRadius(16) - } - .height('100%') - } - .tabBar(this.TabBuilder(2, "更新")) - - /* 查询页面 */ - TabContent() { - Column() { - Column() { - /* 账号 */ - Row() { - Text($r('app.string.account')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .textAlign(TextAlign.Start) - .margin({ top: '2.3%', bottom: '1.1%' }) - } - .width('86.7%').height('7.14%') - .margin({ top: 4 }) - - /* 用户名输入 */ - Row() { - TextInput({ placeholder: $r('app.string.please_input_account') }) - .fontColor(0x182431) - .defaultFocus(false) - .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) - .backgroundColor(Color.Transparent) - .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) - .onChange((value: string) => { - this.checkAccount = value; - }) - .onTouch((event: TouchEvent) => { - if (event.type === TouchType.Down) { - this.eventType = 'Down6'; - } - }) - } - .width('86.7%').height('7.14%') - - if (this.eventType === 'Down6') { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor(0x182431) - } else { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431') - } - - /* 标签 */ - Row() { - Text($r('app.string.label')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .textAlign(TextAlign.Start) - .margin({ top: '2.3%', bottom: '1.1%' }) - } - .width('86.7%').height('7.14%') - - /* 标签输入 */ - Row() { - TextInput({ placeholder: $r('app.string.please_input_label') }) - .fontColor(0x182431) - .defaultFocus(false) - .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) - .backgroundColor(Color.Transparent) - .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) - .onChange((value: string) => { - this.checkLabel = value; - }) - .onTouch((event: TouchEvent) => { - if (event.type === TouchType.Down) { - this.eventType = 'Down7'; - } - }) - } - .width('86.7%').height('7.14%') - - if (this.eventType === 'Down7') { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor(0x182431).margin({bottom: 4}) - } else { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431').margin({bottom: 4}) - } - } - .backgroundColor(0xFFFFFF).borderRadius(16) - - Blank() - Row() { - /* 底部按钮 */ - Button($r('app.string.search'), { type: ButtonType.Capsule, stateEffect: false }) - .backgroundColor(0x007DFF) - .borderRadius(20) - .width('86.7%') - .height(40) - .id('search') - .onClick(async () => { - // 需要执行的操作 - // 如果查询的时候输入了账号 则表示精确查询 进行二次访问控制 - if (this.checkAccount.length > 0) { - let challenge = await preQueryAssetPromise(this.checkAccount); - if (challenge.length == 0) { - log($r('app.string.query_failed')) - return - } - this.challenge = challenge - getAuthTokenCallback(this.challenge, async (isSuccess: boolean, authToken: Uint8Array) => { - if (isSuccess) { - logger.info('get auth token success!') - this.authToken = authToken - - let account = await queryAuthAssetPromise(this.checkAccount, this.challenge, this.authToken); - postQueryAssetPromise(this.challenge) - this.challenge = new Uint8Array; - this.authToken = new Uint8Array; - router.pushUrl({ - url: 'pages/QueryResultPage', - params: { - data_array_map: convertMapArrayToMapItem(new Array>(account)) - } - }, router.RouterMode.Standard, (err) => { - if (err) { - logger.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); - return; - } - }); - } - }); - } - else { - let accountList = queryAssetPromise(this.checkAccount, this.checkLabel); - accountList.then(data => { - router.pushUrl({ - url: 'pages/QueryResultPage', // 目标url - params: { - data_array_map: convertMapArrayToMapItem(data) - } - }, router.RouterMode.Standard, (err) => { - if (err) { - logger.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); - return; - } - logger.info('Invoke pushUrl succeeded.'); - }); - }) - } - }) - } - .margin({ bottom: '8.1%' }) - } - .height('100%') - - } - .tabBar(this.TabBuilder(3, "查询")) - } - .scrollable(true) - .backgroundColor(0xf1f3f5) - .barMode(BarMode.Fixed) - .barHeight(56) - .onChange(async (index: number) => { - if (index == 2 && this.index != 2) { - let challenge = await preQueryAssetPromise(""); - logger.info('get challenge success!') - this.challenge = challenge - // get auth token - getAuthTokenCallback(this.challenge, async (isSuccess: boolean, authToken: Uint8Array) => { - if (isSuccess) { - logger.info('get auth token success!') - this.authToken = authToken - let resultList = await queryAssetPromise('', ''); - for (let accountListElement of resultList) { - let str = accountListElement.get('alias'); - if (str !== undefined) { - this.assetArr.push(str) - } - } - } - }); - } else if (this.challenge.length > 0) { - postQueryAssetPromise(this.challenge) - this.challenge = new Uint8Array; - this.authToken = new Uint8Array; - this.assetArr = new Array(); - } - this.index = index; - }) - } -} +/* + * Copyright (c) 2024 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 { router } from '@kit.ArkUI'; +import { promptAction } from '@kit.ArkUI'; +import { userAuth } from '@kit.UserAuthenticationKit'; +import { logger } from '../common/Logger'; +import { addAssetPromise, removeAssetPromise, queryAssetPromise, queryAuthAssetPromise, preQueryAssetPromise, log, + postQueryAssetPromise } from '../model/AssetModel'; + +interface AssetItem { + alias: string; + secret: string; + dataLabel: string; +} + +function isReserveClickable(reserveAccount: string, reservePassword: string, reserveLabel: string): boolean { + return reserveAccount !== '' && reservePassword !== '' && reserveLabel != ''; +} + +async function getAuthTokenCallback(challenge: Uint8Array, + callback: (isSuccess: boolean, challenge: Uint8Array) => void) { + const authParam: userAuth.AuthParam = { + challenge: challenge, + authType: [userAuth.UserAuthType.PIN,userAuth.UserAuthType.FACE,userAuth.UserAuthType.FINGERPRINT], + authTrustLevel: userAuth.AuthTrustLevel.ATL1, + }; + const widgetParam: userAuth.WidgetParam = { + title: '请输入锁屏密码', + }; + try { + let userAuthInstance = userAuth.getUserAuthInstance(authParam, widgetParam); + userAuthInstance.on('result', { + onResult(result) { + logger.info('userAuthInstance callback result = ' + JSON.stringify(result)); + if (result.result == 12500000) { + logger.info('userAuthInstance callback result success'); + callback(true, result.token) + } else if (result.result == 12500010) { + promptAction.showToast({ message: $r('app.string.please_set_pwd') }) + callback(false, new Uint8Array(0)) + } + } + }); + userAuthInstance.start(); + } catch (error) { + logger.info('auth catch error: ' + JSON.stringify(error)); + promptAction.showToast({ message: $r('app.string.auth_failed') }) + callback(false, new Uint8Array(0)) + } +} + +function convertMapArrayToMapItem(array: Array>): Array +{ + let res = new Array(); + for (let dataElement of array) { + let tmp: AssetItem = { + alias: dataElement.get('alias') as string, + secret: dataElement.get('secret') as string, + dataLabel: dataElement.get('label') as string, + }; + res.push(tmp) + } + return res; +} + +@Entry +@Component +struct Page { + private challenge: Uint8Array = new Uint8Array; + private authToken: Uint8Array = new Uint8Array; + @State reserveAccount: string = ''; + @State reservePassword: string = ''; + @State reserveLabel: string = ''; + @State deleteAccount: string = ''; + @State deleteLabel: string = ''; + @State checkAccount: string = ''; + @State checkLabel: string = ''; + @State eventType: string = '' + @State index: number = 0 + @State assetArr: string[] = new Array(); + private tabsController: TabsController = new TabsController(); + @State view: Visibility[] = [Visibility.Hidden, Visibility.Visible, Visibility.None]; + @State indexView: number = 0 + + @Builder TabBuilder(index: number, name: string) { + Column() { + Row().height(this.index === index ? 8 : 17) + Text(name) + .fontColor(0x182413) + .fontSize(this.index === index ? 30 : 20) + .fontWeight(this.index === index ? 700 : 500) + .lineHeight(this.index === index ? 41 : 28) + .opacity(this.index === index ? 1 : 0.7) + .fontFamily(this.index === index ? 'HarmonyHeiTi-Bold' : 'HarmonyHeiTi-Medium') + .margin(this.index == 0 ? {left: 24} : {left: 0}) + Row().height(this.index === index ? 7 : 11) + } + .width('100%') + } + + build() { + Tabs({ + index: 0, + controller: this.tabsController }) { + /* 保存页面 */ + TabContent() { + Column() { + Column() { + /* 账号 */ + Row() { + Text("*").fontColor(0xFFE84026) + Text($r('app.string.account')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .margin({ top: "2.3%", bottom: "1.1%" }) + } + .width('86.7%').height('7.14%') + .margin({ top: 4 }) + + /* 账号输入 */ + Row() { + TextInput({ placeholder: $r('app.string.please_input_account') }) + .fontColor(0x182431) + .defaultFocus(false) + .id('account_input') + .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0.00px' }) + .backgroundColor(Color.Transparent) + .borderRadius(0) + .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) + .onChange((value: string) => { + this.reserveAccount = value; + }) + .onEditChange((isEditing: boolean) => { + if (isEditing === true) { + this.eventType = 'Down1'; + } + }) + } + .width('86.7%').height('7.14%') + + if (this.eventType === 'Down1') { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: 12, + right: 12 + }) + .backgroundColor(0x182431) + } else { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431') + } + + /* 密码 */ + Row() { + Text("*").fontColor(0xFFE84026) + Text($r('app.string.secret_or_card_num')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .fontWeight(500) + .margin({ top: "2.3%", bottom: "1.1%" }) + } + .width('86.7%').height('7.14%') + + /* 密码输入 */ + Row() { + TextInput({ placeholder: $r('app.string.please_input_secret_or_card_num') }) + .type(InputType.Password) + .defaultFocus(false) + .id('secret_input') + .fontColor(0x182431) + .padding({ top: '1.70%', right: '0', bottom: '1.70%', left: '0.00px' }) + .backgroundColor(Color.Transparent) + .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) + .onChange((value: string) => { + this.reservePassword = value; + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down2'; + } + }) + .margin({ top: '0.00vp', right: '-12vp', bottom: '4.00vp', left: '0.00vp' }) + } + .width('86.7%').height('7.14%') + if (this.eventType === 'Down2') { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor(0x182431) + } else { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431') + } + + /* 标签 */ + Row() { + Text("*").fontColor(0xFFE84026) + Text($r('app.string.label')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .fontWeight(500) + .id('label') + .margin({ top: "2.3%", bottom: "1.1%" }) + } + .width('86.7%').height('7.14%') + + /* 标签输入 */ + Row() { + TextInput({ placeholder: $r('app.string.please_input_label') }) + .fontColor(0x182431) + .defaultFocus(false) + .id('label_input') + .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0.00px' }) + .backgroundColor(Color.Transparent) + .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) + .onChange((value: string) => { + this.reserveLabel = value; + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down3'; + } + }) + } + .width('86.7%').height('7.14%') + if (this.eventType === 'Down3') { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor(0x182431).margin({ bottom: 4}) + } else { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431').margin({ bottom: 4}) + } + } + .backgroundColor(0xFFFFFF).borderRadius(16) + + Blank() + + Row() { + /* 底部按钮 */ + Button($r('app.string.save'), { type: ButtonType.Capsule, stateEffect: false }) + .backgroundColor(0x007DFF).fontColor('white') + .borderRadius(20) + .width('86.7%') + .height(40) + .id('save') + .enabled(isReserveClickable(this.reserveAccount, this.reservePassword, this.reserveLabel)) + .onClick(() => { + addAssetPromise(this.reserveAccount, this.reservePassword, this.reserveLabel) + }) + } + .margin({ bottom: '8.1%' }) + } + .height('100%') + } + .tabBar(this.TabBuilder(0, "保存")) + + /* 删除页面 */ + TabContent() { + Column() { + Column() { + /* 账号 */ + Row() { + Text($r('app.string.account')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .margin({ top: '2.3%', bottom: '1.1%' }) + } + .width('86.7%').height('7.14%') + .margin({ top: 4 }) + + /* 用户名输入 */ + Row() { + TextInput({ placeholder: $r('app.string.please_input_account') }) + .fontColor(0x182431) + .defaultFocus(false) + .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) + .backgroundColor(Color.Transparent) + .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) + .onChange((value: string) => { + this.deleteAccount = value; + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down4'; + } + }) + } + .width('86.7%').height('7.14%') + + if (this.eventType === 'Down4') { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor(0x182431) + } else { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431') + } + + /* 标签 */ + Row() { + Text($r('app.string.label')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .fontWeight(500) + .margin({ top: '2.3%', bottom: '1.1%' }) + } + .width('86.7%').height('7.14%') + + /* 标签输入 */ + Row() { + TextInput({ placeholder: $r('app.string.please_input_label') }) + .fontColor(0x182431) + .defaultFocus(false) + .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) + .backgroundColor(Color.Transparent) + .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) + .onChange((value: string) => { + this.deleteLabel = value; + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down5'; + } + }) + } + .width('86.7%').height('7.14%') + + if (this.eventType === 'Down5') { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor(0x182431).margin({ bottom: 4}) + } else { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431').margin({ bottom: 4}) + } + } + .backgroundColor(0xFFFFFF).borderRadius(16) + + Blank() + Row() { + /* 底部按钮 */ + Button($r('app.string.delete'), { type: ButtonType.Capsule, stateEffect: false }) + .backgroundColor(0x007DFF).fontColor('white') + .borderRadius(20) + .width('86.7%') + .height(40) + .onClick(() => { + removeAssetPromise(this.deleteAccount, this.deleteLabel) + }) + } + .margin({ bottom: '8.1%' }) + } + .height('100%') + } + .tabBar(this.TabBuilder(1, "删除")) + + /* 更新页面 */ + TabContent() { + Column() { + Column() { + List({ space: 0, initialIndex: 0 }) { // 查询列表 + ForEach(this.assetArr, (item: string) => { + ListItem() { + Column() { + /* 账号 */ + Row() { + Row() { + Text(item) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .textAlign(TextAlign.Start) + .margin({ top: '2.3%', bottom: '1.1%' }) + } + + Blank() + Row() { + Image($r('app.media.forward')) + .height(18) + .width(9) + .fillColor('#182431') + } + } + .width('100%').height('7.14%') + .onClick(async () => { + let account = await queryAuthAssetPromise(item, this.challenge, this.authToken); + router.pushUrl({ + url: 'pages/UpdatePage', + params: { name: item, pwd: account.get('secret'), label: account.get("label") } + }, router.RouterMode.Standard, (err) => { + if (err) { + logger.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + }); + }); + } + .margin({ right: 12, left: 12 }) + } + }, (item: string) => item) + } + .listDirection(Axis.Vertical) // 排列方向 + .divider({ strokeWidth: 1, color: '#0D182431', startMargin: 12, endMargin: 12 }) // 每行之间的分界线 + .edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果 + } + .margin({ right: 12, left: 12 }) + .backgroundColor(0xFFFFFF).borderRadius(16) + } + .height('100%') + } + .tabBar(this.TabBuilder(2, "更新")) + + /* 查询页面 */ + TabContent() { + Column() { + Column() { + /* 账号 */ + Row() { + Text($r('app.string.account')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .textAlign(TextAlign.Start) + .margin({ top: '2.3%', bottom: '1.1%' }) + } + .width('86.7%').height('7.14%') + .margin({ top: 4 }) + + /* 用户名输入 */ + Row() { + TextInput({ placeholder: $r('app.string.please_input_account') }) + .fontColor(0x182431) + .defaultFocus(false) + .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) + .backgroundColor(Color.Transparent) + .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) + .onChange((value: string) => { + this.checkAccount = value; + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down6'; + } + }) + } + .width('86.7%').height('7.14%') + + if (this.eventType === 'Down6') { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor(0x182431) + } else { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431') + } + + /* 标签 */ + Row() { + Text($r('app.string.label')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .textAlign(TextAlign.Start) + .margin({ top: '2.3%', bottom: '1.1%' }) + } + .width('86.7%').height('7.14%') + + /* 标签输入 */ + Row() { + TextInput({ placeholder: $r('app.string.please_input_label') }) + .fontColor(0x182431) + .defaultFocus(false) + .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) + .backgroundColor(Color.Transparent) + .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) + .onChange((value: string) => { + this.checkLabel = value; + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down7'; + } + }) + } + .width('86.7%').height('7.14%') + + if (this.eventType === 'Down7') { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor(0x182431).margin({bottom: 4}) + } else { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431').margin({bottom: 4}) + } + } + .backgroundColor(0xFFFFFF).borderRadius(16) + + Blank() + Row() { + /* 底部按钮 */ + Button($r('app.string.search'), { type: ButtonType.Capsule, stateEffect: false }) + .backgroundColor(0x007DFF) + .borderRadius(20) + .width('86.7%') + .height(40) + .id('search') + .onClick(async () => { + // 需要执行的操作 + // 如果查询的时候输入了账号 则表示精确查询 进行二次访问控制 + if (this.checkAccount.length > 0) { + let challenge = await preQueryAssetPromise(this.checkAccount); + if (challenge.length == 0) { + log($r('app.string.query_failed')) + return + } + this.challenge = challenge + getAuthTokenCallback(this.challenge, async (isSuccess: boolean, authToken: Uint8Array) => { + if (isSuccess) { + logger.info('get auth token success!') + this.authToken = authToken + + let account = await queryAuthAssetPromise(this.checkAccount, this.challenge, this.authToken); + postQueryAssetPromise(this.challenge) + this.challenge = new Uint8Array; + this.authToken = new Uint8Array; + router.pushUrl({ + url: 'pages/QueryResultPage', + params: { + data_array_map: convertMapArrayToMapItem(new Array>(account)) + } + }, router.RouterMode.Standard, (err) => { + if (err) { + logger.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + }); + } + }); + } + else { + let accountList = queryAssetPromise(this.checkAccount, this.checkLabel); + accountList.then(data => { + router.pushUrl({ + url: 'pages/QueryResultPage', // 目标url + params: { + data_array_map: convertMapArrayToMapItem(data) + } + }, router.RouterMode.Standard, (err) => { + if (err) { + logger.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + logger.info('Invoke pushUrl succeeded.'); + }); + }) + } + }) + } + .margin({ bottom: '8.1%' }) + } + .height('100%') + + } + .tabBar(this.TabBuilder(3, "查询")) + } + .scrollable(true) + .backgroundColor(0xf1f3f5) + .barMode(BarMode.Fixed) + .barHeight(56) + .onChange(async (index: number) => { + if (index == 2 && this.index != 2) { + let challenge = await preQueryAssetPromise(""); + logger.info('get challenge success!') + this.challenge = challenge + // get auth token + getAuthTokenCallback(this.challenge, async (isSuccess: boolean, authToken: Uint8Array) => { + if (isSuccess) { + logger.info('get auth token success!') + this.authToken = authToken + let resultList = await queryAssetPromise('', ''); + for (let accountListElement of resultList) { + let str = accountListElement.get('alias'); + if (str !== undefined) { + this.assetArr.push(str) + } + } + } + }); + } else if (this.challenge.length > 0) { + postQueryAssetPromise(this.challenge) + this.challenge = new Uint8Array; + this.authToken = new Uint8Array; + this.assetArr = new Array(); + } + this.index = index; + }) + } +} diff --git a/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/QueryResultPage.ets b/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/QueryResultPage.ets old mode 100755 new mode 100644 index 1dddce07a7..feffc8072b --- a/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/QueryResultPage.ets +++ b/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/QueryResultPage.ets @@ -1,182 +1,182 @@ -/* - * Copyright (c) 2024 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 { router } from '@kit.ArkUI'; - -interface AssetItem { - alias: string; - secret: string; - dataLabel: string; -} - -@Entry -@Component -struct QueryResultPage { - @State param: Record> = router.getParams() as Record>; - @State data: Array = this.param.data_array_map as Array; - - build() { - Column() { - Row() { - Image($r('app.media.back')) - .height(18) - .width(20) - .onClick(() => { - // 返回到上一页面,相当于pop操作 - router.back(); - }) - - Text($r('app.string.search_result')) - .fontFamily("HarmonyHeiTi") - .fontSize(20) - .fontColor(0x182431) - .lineHeight(28) - .fontWeight(700) - .margin({ left: '5%' }) - .textAlign(TextAlign.Center) - } - .width('86.7%').height(56) - - Column() { - List({ space: 0, initialIndex: 0 }) { - ForEach(this.data, (item: AssetItem) => { - ListItem() { - Column() { - Row() { - Row() { - Text($r('app.string.account')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .margin({ top: '2.3%', bottom: '1.1%' }) - } - Blank() - Row() { - Text(item.alias.toString()) - .opacity(0.6) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(19) - .fontWeight(400) - .baselineOffset(0) - .margin({ top: '2.3%', bottom: '1.1%' }) - } - } - .width('86.7%').height('7.14%') - - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431') - - /* 密码/信用卡号 */ - if (item.secret) { - Row() { - Row() { - Text($r('app.string.secret_or_card_num')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .textAlign(TextAlign.Start) - .padding({ top: '2.3%', bottom: '1.1%' }) - } - - Blank() - Row() { - Text(item.secret.toString()) - .opacity(0.6) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(19) - .fontWeight(400) - .textAlign(TextAlign.End) - .padding({ top: '2.3%', bottom: '1.1%' }) - } - }.width('86.7%').height('6.7%') - } - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431') - /* 标签 */ - Row() { - Row() { - Text($r('app.string.label2')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .baselineOffset(0) - .textAlign(TextAlign.Start) - .padding({ top: '2.3%', bottom: '1.1%' }) - } - - Blank() - Row() { - Text(item.dataLabel.toString()) - .opacity(0.6) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(19) - .fontWeight(400) - .baselineOffset(0) - .textAlign(TextAlign.End) - .padding({ top: '2.3%', bottom: '1.1%' }) - } - }.width('86.7%').height('7.14%') - } - .margin({ left: 12, right: -12, bottom: 12 }) - .backgroundColor(0xFFFFFF).borderRadius(16) - } - }, (item: AssetItem) => JSON.stringify(item)) - } - .listDirection(Axis.Vertical) // 排列方向 - .edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果 - } - } - .width("100%").height("100%").backgroundColor(0xf1f3f5) - } - - pageTransition() { - // 定义页面进入时的效果,从右侧滑入,时长为1000ms,页面栈发生push操作时该效果才生效 - PageTransitionEnter({ type: RouteType.Push, duration: 300 }) - .slide(SlideEffect.Right) - // 定义页面进入时的效果,从左侧滑入,时长为1000ms,页面栈发生pop操作时该效果才生效 - PageTransitionEnter({ type: RouteType.Pop, duration: 300 }) - .slide(SlideEffect.Left) - // 定义页面退出时的效果,向左侧滑出,时长为1000ms,页面栈发生push操作时该效果才生效 - PageTransitionExit({ type: RouteType.Push, duration: 300 }) - .slide(SlideEffect.Left) - // 定义页面退出时的效果,向右侧滑出,时长为1000ms,页面栈发生pop操作时该效果才生效 - PageTransitionExit({ type: RouteType.Pop, duration: 300 }) - .slide(SlideEffect.Right) - } +/* + * Copyright (c) 2024 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 { router } from '@kit.ArkUI'; + +interface AssetItem { + alias: string; + secret: string; + dataLabel: string; +} + +@Entry +@Component +struct QueryResultPage { + @State param: Record> = router.getParams() as Record>; + @State data: Array = this.param.data_array_map as Array; + + build() { + Column() { + Row() { + Image($r('app.media.back')) + .height(18) + .width(20) + .onClick(() => { + // 返回到上一页面,相当于pop操作 + router.back(); + }) + + Text($r('app.string.search_result')) + .fontFamily("HarmonyHeiTi") + .fontSize(20) + .fontColor(0x182431) + .lineHeight(28) + .fontWeight(700) + .margin({ left: '5%' }) + .textAlign(TextAlign.Center) + } + .width('86.7%').height(56) + + Column() { + List({ space: 0, initialIndex: 0 }) { + ForEach(this.data, (item: AssetItem) => { + ListItem() { + Column() { + Row() { + Row() { + Text($r('app.string.account')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .margin({ top: '2.3%', bottom: '1.1%' }) + } + Blank() + Row() { + Text(item.alias.toString()) + .opacity(0.6) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(19) + .fontWeight(400) + .baselineOffset(0) + .margin({ top: '2.3%', bottom: '1.1%' }) + } + } + .width('86.7%').height('7.14%') + + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431') + + /* 密码/信用卡号 */ + if (item.secret) { + Row() { + Row() { + Text($r('app.string.secret_or_card_num')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .textAlign(TextAlign.Start) + .padding({ top: '2.3%', bottom: '1.1%' }) + } + + Blank() + Row() { + Text(item.secret.toString()) + .opacity(0.6) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(19) + .fontWeight(400) + .textAlign(TextAlign.End) + .padding({ top: '2.3%', bottom: '1.1%' }) + } + }.width('86.7%').height('6.7%') + } + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431') + /* 标签 */ + Row() { + Row() { + Text($r('app.string.label2')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .baselineOffset(0) + .textAlign(TextAlign.Start) + .padding({ top: '2.3%', bottom: '1.1%' }) + } + + Blank() + Row() { + Text(item.dataLabel.toString()) + .opacity(0.6) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(19) + .fontWeight(400) + .baselineOffset(0) + .textAlign(TextAlign.End) + .padding({ top: '2.3%', bottom: '1.1%' }) + } + }.width('86.7%').height('7.14%') + } + .margin({ left: 12, right: -12, bottom: 12 }) + .backgroundColor(0xFFFFFF).borderRadius(16) + } + }, (item: AssetItem) => JSON.stringify(item)) + } + .listDirection(Axis.Vertical) // 排列方向 + .edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果 + } + } + .width("100%").height("100%").backgroundColor(0xf1f3f5) + } + + pageTransition() { + // 定义页面进入时的效果,从右侧滑入,时长为1000ms,页面栈发生push操作时该效果才生效 + PageTransitionEnter({ type: RouteType.Push, duration: 300 }) + .slide(SlideEffect.Right) + // 定义页面进入时的效果,从左侧滑入,时长为1000ms,页面栈发生pop操作时该效果才生效 + PageTransitionEnter({ type: RouteType.Pop, duration: 300 }) + .slide(SlideEffect.Left) + // 定义页面退出时的效果,向左侧滑出,时长为1000ms,页面栈发生push操作时该效果才生效 + PageTransitionExit({ type: RouteType.Push, duration: 300 }) + .slide(SlideEffect.Left) + // 定义页面退出时的效果,向右侧滑出,时长为1000ms,页面栈发生pop操作时该效果才生效 + PageTransitionExit({ type: RouteType.Pop, duration: 300 }) + .slide(SlideEffect.Right) + } } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/UpdatePage.ets b/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/UpdatePage.ets old mode 100755 new mode 100644 index fc578515cf..521eb2e666 --- a/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/UpdatePage.ets +++ b/code/BasicFeature/Security/Asset/entry/src/main/ets/pages/UpdatePage.ets @@ -1,220 +1,220 @@ -/* - * Copyright (c) 2024 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 { router } from '@kit.ArkUI'; -import { updateAssetPromise } from '../model/AssetModel'; - -function isUpdateClickable(reservePassword: string): boolean { - return reservePassword !== ''; -} - -@Entry -@Component -struct UpdatePage { - @State params: Record = router.getParams() as Record; - @State user: string = this.params.name as string; - @State pwd: string = this.params.pwd as string; - @State label: string = this.params.label as string; - @State reservePassword: string = this.pwd; - @State reserveLabel: string = this.label; - @State eventType: string = '' - - build() { - Column() { - Row() { - Image($r('app.media.back')) - .height(18) - .width(20) - .onClick(() => { - // 返回到上一页面,相当于pop操作 - router.back(); - }) - Text($r('app.string.update')) - .fontFamily("HarmonyHeiTi") - .fontSize(20) - .fontColor(0x182431) - .lineHeight(28) - .fontWeight(700) - .margin({ left: '5%' }) - .textAlign(TextAlign.Center) - }.width('86.7%').height(56) - - Column() { - /* 账号 */ - Row() { - Text($r('app.string.account')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .textAlign(TextAlign.Start) - .padding({ top: '2.3%', bottom: '1.1%' }) - } - .width('86.7%').height('6.7%') - - /* 用户名输入 */ - Row() { - Text(this.user) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .opacity(0.6) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(400) - .textAlign(TextAlign.Start) - .padding({ top: '2.3%', bottom: '1.1%' }) - } - .width('86.7%').height('6.7%') - - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431') - - /* 密码 */ - Row() { - Text("*").fontColor(0xFFE84026) - Text($r('app.string.secret_or_card_num')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .padding({ top: '2.3%', bottom: '1.1%' }) - } - .width('86.7%').height('6.7%') - - /* 密码输入 */ - Row() { - TextInput({ text: this.pwd }) - .type(InputType.Password) - .defaultFocus(false) - .fontColor(0x182431) - .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) - .backgroundColor(Color.Transparent) - .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) - .onChange((value: string) => { - this.reservePassword = value; - }) - .onTouch((event: TouchEvent) => { - if (event.type === TouchType.Down) { - this.eventType = 'Down9'; - } - }) - .margin({ right: -12 }) - } - .width('86.7%').height('6.7%') - - if (this.eventType === 'Down9') { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor(0x182431) - } else { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431') - } - - /* 标签 */ - Row() { - Text($r('app.string.label')) - .fontFamily("HarmonyHeiTi") - .fontSize(16) - .fontColor(0x182431) - .lineHeight(22) - .fontWeight(500) - .baselineOffset(0) - .textAlign(TextAlign.Start) - .padding({ top: '2.3%', bottom: '1.1%' }) - } - .width('86.7%').height('6.7%') - - /* 标签输入 */ - Row() { - TextInput({ text: this.label }) - .defaultFocus(false) - .fontColor(0x182431) - .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) - .backgroundColor(Color.Transparent) - .id('label_input') - .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) - .onChange((value: string) => { - this.reserveLabel = value; - }) - .onTouch((event: TouchEvent) => { - if (event.type === TouchType.Down) { - this.eventType = 'Down10'; - } - }) - } - .width('86.7%').height('6.7%') - - if (this.eventType === 'Down10') { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor(0x182431).margin({ bottom: 4 }) - } else { - Line() - .width('86.7%') - .height('0.5vp') - .margin({ - left: '12vp', - right: '12vp' - }) - .backgroundColor('#0D182431').margin({ bottom: 4 }) - } - } - .backgroundColor(0xFFFFFF).borderRadius(16) - - Blank() - Row() { - /* 底部按钮 */ - Button($r('app.string.update'), { type: ButtonType.Capsule, stateEffect: false }) - .backgroundColor(0x007DFF).fontColor('white') - .borderRadius(20) - .width('86.7%') - .height(40) - .id('update_button') - .enabled(isUpdateClickable(this.reservePassword)) - .onClick(() => { - updateAssetPromise(this.user, this.reservePassword, this.reserveLabel) - }) - } - .margin({ bottom: '8.1%' }) - } - // .margin({ right: 12, left: 12 }) - .width("100%").height('100%').backgroundColor(0xf1f3f5) - } +/* + * Copyright (c) 2024 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 { router } from '@kit.ArkUI'; +import { updateAssetPromise } from '../model/AssetModel'; + +function isUpdateClickable(reservePassword: string): boolean { + return reservePassword !== ''; +} + +@Entry +@Component +struct UpdatePage { + @State params: Record = router.getParams() as Record; + @State user: string = this.params.name as string; + @State pwd: string = this.params.pwd as string; + @State label: string = this.params.label as string; + @State reservePassword: string = this.pwd; + @State reserveLabel: string = this.label; + @State eventType: string = '' + + build() { + Column() { + Row() { + Image($r('app.media.back')) + .height(18) + .width(20) + .onClick(() => { + // 返回到上一页面,相当于pop操作 + router.back(); + }) + Text($r('app.string.update')) + .fontFamily("HarmonyHeiTi") + .fontSize(20) + .fontColor(0x182431) + .lineHeight(28) + .fontWeight(700) + .margin({ left: '5%' }) + .textAlign(TextAlign.Center) + }.width('86.7%').height(56) + + Column() { + /* 账号 */ + Row() { + Text($r('app.string.account')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .textAlign(TextAlign.Start) + .padding({ top: '2.3%', bottom: '1.1%' }) + } + .width('86.7%').height('6.7%') + + /* 用户名输入 */ + Row() { + Text(this.user) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .opacity(0.6) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(400) + .textAlign(TextAlign.Start) + .padding({ top: '2.3%', bottom: '1.1%' }) + } + .width('86.7%').height('6.7%') + + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431') + + /* 密码 */ + Row() { + Text("*").fontColor(0xFFE84026) + Text($r('app.string.secret_or_card_num')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .padding({ top: '2.3%', bottom: '1.1%' }) + } + .width('86.7%').height('6.7%') + + /* 密码输入 */ + Row() { + TextInput({ text: this.pwd }) + .type(InputType.Password) + .defaultFocus(false) + .fontColor(0x182431) + .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) + .backgroundColor(Color.Transparent) + .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) + .onChange((value: string) => { + this.reservePassword = value; + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down9'; + } + }) + .margin({ right: -12 }) + } + .width('86.7%').height('6.7%') + + if (this.eventType === 'Down9') { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor(0x182431) + } else { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431') + } + + /* 标签 */ + Row() { + Text($r('app.string.label')) + .fontFamily("HarmonyHeiTi") + .fontSize(16) + .fontColor(0x182431) + .lineHeight(22) + .fontWeight(500) + .baselineOffset(0) + .textAlign(TextAlign.Start) + .padding({ top: '2.3%', bottom: '1.1%' }) + } + .width('86.7%').height('6.7%') + + /* 标签输入 */ + Row() { + TextInput({ text: this.label }) + .defaultFocus(false) + .fontColor(0x182431) + .padding({ top: '1.70%', right: '48.00px', bottom: '1.70%', left: '0' }) + .backgroundColor(Color.Transparent) + .id('label_input') + .placeholderFont({ size: 16, weight: 400, family: 'HarmonyHeiTi', style: FontStyle.Normal }) + .onChange((value: string) => { + this.reserveLabel = value; + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down10'; + } + }) + } + .width('86.7%').height('6.7%') + + if (this.eventType === 'Down10') { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor(0x182431).margin({ bottom: 4 }) + } else { + Line() + .width('86.7%') + .height('0.5vp') + .margin({ + left: '12vp', + right: '12vp' + }) + .backgroundColor('#0D182431').margin({ bottom: 4 }) + } + } + .backgroundColor(0xFFFFFF).borderRadius(16) + + Blank() + Row() { + /* 底部按钮 */ + Button($r('app.string.update'), { type: ButtonType.Capsule, stateEffect: false }) + .backgroundColor(0x007DFF).fontColor('white') + .borderRadius(20) + .width('86.7%') + .height(40) + .id('update_button') + .enabled(isUpdateClickable(this.reservePassword)) + .onClick(() => { + updateAssetPromise(this.user, this.reservePassword, this.reserveLabel) + }) + } + .margin({ bottom: '8.1%' }) + } + // .margin({ right: 12, left: 12 }) + .width("100%").height('100%').backgroundColor(0xf1f3f5) + } } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/main/module.json5 b/code/BasicFeature/Security/Asset/entry/src/main/module.json5 old mode 100755 new mode 100644 index 1b25b5ea0b..6d653a18b3 --- a/code/BasicFeature/Security/Asset/entry/src/main/module.json5 +++ b/code/BasicFeature/Security/Asset/entry/src/main/module.json5 @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2024 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:app_icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:app_icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.ACCESS_BIOMETRIC" - }, - { - "name": "ohos.permission.STORE_PERSISTENT_DATA" - } - ] - } +/* + * Copyright (c) 2024 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:app_icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:app_icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.ACCESS_BIOMETRIC" + }, + { + "name": "ohos.permission.STORE_PERSISTENT_DATA" + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index 9cd507c238..8a31531e1f --- a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/color.json @@ -1,32 +1,32 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "column_background_color", - "value": "#F5F5F5" - }, - { - "name": "custom_color", - "value": "#182431" - }, - { - "name": "custom_button_color", - "value": "#007DFF" - }, - { - "name": "custom_blank_color", - "value": "#F2F2F2" - }, - { - "name": "place_color", - "value": "#99000000" - }, - { - "name": "divider_color", - "value": "#0D182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "column_background_color", + "value": "#F5F5F5" + }, + { + "name": "custom_color", + "value": "#182431" + }, + { + "name": "custom_button_color", + "value": "#007DFF" + }, + { + "name": "custom_blank_color", + "value": "#F2F2F2" + }, + { + "name": "place_color", + "value": "#99000000" + }, + { + "name": "divider_color", + "value": "#0D182431" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/float.json b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/float.json old mode 100755 new mode 100644 index bab9e1ffcd..e4140f7cac --- a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/float.json +++ b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/float.json @@ -1,188 +1,188 @@ -{ - "float": [ - { - "name": "image_back_size", - "value": "26vp" - }, - { - "name": "avatar_size", - "value": "56vp" - }, - { - "name": "personal_font_size", - "value": "16fp" - }, - { - "name": "title_hobbies_size", - "value": "20fp" - }, - { - "name": "title_line_height", - "value": "28vp" - }, - { - "name": "label_size", - "value": "16fp" - }, - { - "name": "options_height", - "value": "22vp" - }, - { - "name": "toggle_size", - "value": "20vp" - }, - { - "name": "options_top_distance", - "value": "13vp" - }, - { - "name": "options_bottom_distance", - "value": "13vp" - }, - { - "name": "divider_height", - "value": "0.5vp" - }, - { - "name": "list_top_distance", - "value": "14vp" - }, - { - "name": "list_bottom_distance", - "value": "8vp" - }, - { - "name": "options_list_height", - "value": "242vp" - }, - { - "name": "blank_width", - "value": "1vp" - }, - { - "name": "blank_opacity", - "value": "1vp" - }, - { - "name": "blank_height", - "value": "25vp" - }, - { - "name": "dialog_radius", - "value": "32vp" - }, - { - "name": "title_left_distance", - "value": "24vp" - }, - { - "name": "label_left_distance", - "value": "24vp" - }, - { - "name": "dialog_left_distance", - "value": "24vp" - }, - { - "name": "dialog_top_distance", - "value": "14vp" - }, - { - "name": "toggle_right_distance", - "value": "24vp" - }, - { - "name": "dialog_bottom_distance", - "value": "16vp" - }, - { - "name": "button_text_size", - "value": "16fp" - }, - { - "name": "button_height", - "value": "40vp" - }, - { - "name": "text_image_size", - "value": "24vp" - }, - { - "name": "image_left_distance", - "value": "12vp" - }, - { - "name": "text_size", - "value": "16vp" - }, - { - "name": "content_left_distance", - "value": "16vp" - }, - { - "name": "content_right_distance", - "value": "7vp" - }, - { - "name": "arrow_image_width", - "value": "12vp" - }, - { - "name": "arrow_image_height", - "value": "24vp" - }, - { - "name": "arrow_right_distance", - "value": "14vp" - }, - { - "name": "row_top_distance", - "value": "24vp" - }, - { - "name": "row_radius", - "value": "24vp" - }, - { - "name": "row_height", - "value": "64vp" - }, - { - "name": "input_image_size", - "value": "24vp" - }, - { - "name": "input_image_left", - "value": "12vp" - }, - { - "name": "input_text_size", - "value": "16fp" - }, - { - "name": "input_left_inside", - "value": "12vp" - }, - { - "name": "input_right_inside", - "value": "32vp" - }, - { - "name": "text_input_height", - "value": "48vp" - }, - { - "name": "input_row_top", - "value": "24vp" - }, - { - "name": "input_row_radius", - "value": "24vp" - }, - { - "name": "input_row_height", - "value": "64vp" - } - ] +{ + "float": [ + { + "name": "image_back_size", + "value": "26vp" + }, + { + "name": "avatar_size", + "value": "56vp" + }, + { + "name": "personal_font_size", + "value": "16fp" + }, + { + "name": "title_hobbies_size", + "value": "20fp" + }, + { + "name": "title_line_height", + "value": "28vp" + }, + { + "name": "label_size", + "value": "16fp" + }, + { + "name": "options_height", + "value": "22vp" + }, + { + "name": "toggle_size", + "value": "20vp" + }, + { + "name": "options_top_distance", + "value": "13vp" + }, + { + "name": "options_bottom_distance", + "value": "13vp" + }, + { + "name": "divider_height", + "value": "0.5vp" + }, + { + "name": "list_top_distance", + "value": "14vp" + }, + { + "name": "list_bottom_distance", + "value": "8vp" + }, + { + "name": "options_list_height", + "value": "242vp" + }, + { + "name": "blank_width", + "value": "1vp" + }, + { + "name": "blank_opacity", + "value": "1vp" + }, + { + "name": "blank_height", + "value": "25vp" + }, + { + "name": "dialog_radius", + "value": "32vp" + }, + { + "name": "title_left_distance", + "value": "24vp" + }, + { + "name": "label_left_distance", + "value": "24vp" + }, + { + "name": "dialog_left_distance", + "value": "24vp" + }, + { + "name": "dialog_top_distance", + "value": "14vp" + }, + { + "name": "toggle_right_distance", + "value": "24vp" + }, + { + "name": "dialog_bottom_distance", + "value": "16vp" + }, + { + "name": "button_text_size", + "value": "16fp" + }, + { + "name": "button_height", + "value": "40vp" + }, + { + "name": "text_image_size", + "value": "24vp" + }, + { + "name": "image_left_distance", + "value": "12vp" + }, + { + "name": "text_size", + "value": "16vp" + }, + { + "name": "content_left_distance", + "value": "16vp" + }, + { + "name": "content_right_distance", + "value": "7vp" + }, + { + "name": "arrow_image_width", + "value": "12vp" + }, + { + "name": "arrow_image_height", + "value": "24vp" + }, + { + "name": "arrow_right_distance", + "value": "14vp" + }, + { + "name": "row_top_distance", + "value": "24vp" + }, + { + "name": "row_radius", + "value": "24vp" + }, + { + "name": "row_height", + "value": "64vp" + }, + { + "name": "input_image_size", + "value": "24vp" + }, + { + "name": "input_image_left", + "value": "12vp" + }, + { + "name": "input_text_size", + "value": "16fp" + }, + { + "name": "input_left_inside", + "value": "12vp" + }, + { + "name": "input_right_inside", + "value": "32vp" + }, + { + "name": "text_input_height", + "value": "48vp" + }, + { + "name": "input_row_top", + "value": "24vp" + }, + { + "name": "input_row_radius", + "value": "24vp" + }, + { + "name": "input_row_height", + "value": "64vp" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/images.json b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/images.json old mode 100755 new mode 100644 index 882cd74e44..75452889f2 --- a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/images.json +++ b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/images.json @@ -1,8 +1,8 @@ -{ - "boolean": [ - { - "name": "boolean_1", - "value": true - } - ] +{ + "boolean": [ + { + "name": "boolean_1", + "value": true + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/string.json b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index c7e9aa74c3..d4172851bc --- a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/string.json +++ b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/string.json @@ -1,120 +1,120 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "Main program entry" - }, - { - "name": "EntryAbility_label", - "value": "MultipleWindow" - }, - { - "name": "please_set_pwd", - "value": "please set screen password" - }, - { - "name": "auth_failed", - "value": "auth failed" - }, - { - "name": "account", - "value": "account" - }, - { - "name": "please_input_account", - "value": "please input account" - }, - { - "name": "secret_or_card_num", - "value": "secret or card number" - }, - { - "name": "please_input_secret_or_card_num", - "value": "please input secret or card number" - }, - { - "name": "label", - "value": "label(max 4, split by ;)" - }, - { - "name": "label2", - "value": "label" - }, - { - "name": "please_input_label", - "value": "please input label" - }, - { - "name": "save", - "value": "save" - }, - { - "name": "delete", - "value": "delete" - }, - { - "name": "search", - "value": "search" - }, - { - "name": "search_result", - "value": "search result" - }, - { - "name": "update", - "value": "update" - }, - { - "name": "save_failed_for_label", - "value": "save failed, label num over 4" - }, - { - "name": "save_success", - "value": "save success" - }, - { - "name": "save_failed_for_account_exist", - "value": "save failed for account exist" - }, - { - "name": "save_failed", - "value": "save failed" - }, - { - "name": "remove_success", - "value": "remove success" - }, - { - "name": "remove_failed_for_account_not_exist", - "value": "remove failed for account not exist" - }, - { - "name": "remove_failed", - "value": "remove failed" - }, - { - "name": "update_failed", - "value": "update failed" - }, - { - "name": "update_success", - "value": "update success" - }, - { - "name": "update_failed_for_label_over_4", - "value": "update failed for label over 4" - }, - { - "name": "query_no_result", - "value": "query no result" - }, - { - "name": "query_failed", - "value": "query failed" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "Main program entry" + }, + { + "name": "EntryAbility_label", + "value": "MultipleWindow" + }, + { + "name": "please_set_pwd", + "value": "please set screen password" + }, + { + "name": "auth_failed", + "value": "auth failed" + }, + { + "name": "account", + "value": "account" + }, + { + "name": "please_input_account", + "value": "please input account" + }, + { + "name": "secret_or_card_num", + "value": "secret or card number" + }, + { + "name": "please_input_secret_or_card_num", + "value": "please input secret or card number" + }, + { + "name": "label", + "value": "label(max 4, split by ;)" + }, + { + "name": "label2", + "value": "label" + }, + { + "name": "please_input_label", + "value": "please input label" + }, + { + "name": "save", + "value": "save" + }, + { + "name": "delete", + "value": "delete" + }, + { + "name": "search", + "value": "search" + }, + { + "name": "search_result", + "value": "search result" + }, + { + "name": "update", + "value": "update" + }, + { + "name": "save_failed_for_label", + "value": "save failed, label num over 4" + }, + { + "name": "save_success", + "value": "save success" + }, + { + "name": "save_failed_for_account_exist", + "value": "save failed for account exist" + }, + { + "name": "save_failed", + "value": "save failed" + }, + { + "name": "remove_success", + "value": "remove success" + }, + { + "name": "remove_failed_for_account_not_exist", + "value": "remove failed for account not exist" + }, + { + "name": "remove_failed", + "value": "remove failed" + }, + { + "name": "update_failed", + "value": "update failed" + }, + { + "name": "update_success", + "value": "update success" + }, + { + "name": "update_failed_for_label_over_4", + "value": "update failed for label over 4" + }, + { + "name": "query_no_result", + "value": "query no result" + }, + { + "name": "query_failed", + "value": "query failed" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/stringarray.json b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/stringarray.json old mode 100755 new mode 100644 index 1e5f24381c..d94f89c6f4 --- a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/stringarray.json +++ b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/element/stringarray.json @@ -1,35 +1,35 @@ -{ - "strarray": [ - { - "name": "sex_array", - "value": [ - { - "value": "male" - }, - { - "value": "female" - } - ] - }, - { - "name": "hobbies_data", - "value": [ - { - "value": "Soccer" - }, - { - "value": "Badminton" - }, - { - "value": "Travelling" - }, - { - "value": "Playing games" - }, - { - "value": "Reading books" - } - ] - } - ] +{ + "strarray": [ + { + "name": "sex_array", + "value": [ + { + "value": "male" + }, + { + "value": "female" + } + ] + }, + { + "name": "hobbies_data", + "value": [ + { + "value": "Soccer" + }, + { + "value": "Badminton" + }, + { + "value": "Travelling" + }, + { + "value": "Playing games" + }, + { + "value": "Reading books" + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 3b2fc05da7..2a125db99d --- a/code/BasicFeature/Security/Asset/entry/src/main/resources/base/profile/main_pages.json +++ b/code/BasicFeature/Security/Asset/entry/src/main/resources/base/profile/main_pages.json @@ -1,7 +1,7 @@ -{ - "src": [ - "pages/Index", - "pages/QueryResultPage", - "pages/UpdatePage" - ] -} +{ + "src": [ + "pages/Index", + "pages/QueryResultPage", + "pages/UpdatePage" + ] +} diff --git a/code/BasicFeature/Security/Asset/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/Security/Asset/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 index 63ea3ee50b..6f3c0f004d --- a/code/BasicFeature/Security/Asset/entry/src/main/resources/en_US/element/string.json +++ b/code/BasicFeature/Security/Asset/entry/src/main/resources/en_US/element/string.json @@ -1,120 +1,120 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "label" - }, - { - "name": "please_set_pwd", - "value": "please set screen password" - }, - { - "name": "auth_failed", - "value": "auth failed" - }, - { - "name": "account", - "value": "account" - }, - { - "name": "please_input_account", - "value": "please input account" - }, - { - "name": "secret_or_card_num", - "value": "secret or card number" - }, - { - "name": "please_input_secret_or_card_num", - "value": "please input secret or card number" - }, - { - "name": "label", - "value": "label(max 4, split by ;)" - }, - { - "name": "label2", - "value": "label" - }, - { - "name": "please_input_label", - "value": "please input label" - }, - { - "name": "save", - "value": "save" - }, - { - "name": "delete", - "value": "delete" - }, - { - "name": "search", - "value": "search" - }, - { - "name": "search_result", - "value": "search result" - }, - { - "name": "update", - "value": "update" - }, - { - "name": "save_failed_for_label", - "value": "save failed, label num over 4" - }, - { - "name": "save_success", - "value": "save success" - }, - { - "name": "save_failed_for_account_exist", - "value": "save failed for account exist" - }, - { - "name": "save_failed", - "value": "save failed" - }, - { - "name": "remove_success", - "value": "remove success" - }, - { - "name": "remove_failed_for_account_not_exist", - "value": "remove failed for account not exist" - }, - { - "name": "remove_failed", - "value": "remove failed" - }, - { - "name": "update_failed", - "value": "update failed" - }, - { - "name": "update_success", - "value": "update success" - }, - { - "name": "update_failed_for_label_over_4", - "value": "update failed for label over 4" - }, - { - "name": "query_no_result", - "value": "query no result" - }, - { - "name": "query_failed", - "value": "query failed" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "please_set_pwd", + "value": "please set screen password" + }, + { + "name": "auth_failed", + "value": "auth failed" + }, + { + "name": "account", + "value": "account" + }, + { + "name": "please_input_account", + "value": "please input account" + }, + { + "name": "secret_or_card_num", + "value": "secret or card number" + }, + { + "name": "please_input_secret_or_card_num", + "value": "please input secret or card number" + }, + { + "name": "label", + "value": "label(max 4, split by ;)" + }, + { + "name": "label2", + "value": "label" + }, + { + "name": "please_input_label", + "value": "please input label" + }, + { + "name": "save", + "value": "save" + }, + { + "name": "delete", + "value": "delete" + }, + { + "name": "search", + "value": "search" + }, + { + "name": "search_result", + "value": "search result" + }, + { + "name": "update", + "value": "update" + }, + { + "name": "save_failed_for_label", + "value": "save failed, label num over 4" + }, + { + "name": "save_success", + "value": "save success" + }, + { + "name": "save_failed_for_account_exist", + "value": "save failed for account exist" + }, + { + "name": "save_failed", + "value": "save failed" + }, + { + "name": "remove_success", + "value": "remove success" + }, + { + "name": "remove_failed_for_account_not_exist", + "value": "remove failed for account not exist" + }, + { + "name": "remove_failed", + "value": "remove failed" + }, + { + "name": "update_failed", + "value": "update failed" + }, + { + "name": "update_success", + "value": "update success" + }, + { + "name": "update_failed_for_label_over_4", + "value": "update failed for label over 4" + }, + { + "name": "query_no_result", + "value": "query no result" + }, + { + "name": "query_failed", + "value": "query failed" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/Security/Asset/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 index f31c7688c0..12438c7377 --- a/code/BasicFeature/Security/Asset/entry/src/main/resources/zh_CN/element/string.json +++ b/code/BasicFeature/Security/Asset/entry/src/main/resources/zh_CN/element/string.json @@ -1,120 +1,120 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "模块描述" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "label" - }, - { - "name": "please_set_pwd", - "value": "请设置锁屏密码" - }, - { - "name": "auth_failed", - "value": "认证失败" - }, - { - "name": "account", - "value": "账号" - }, - { - "name": "please_input_account", - "value": "请输入账号" - }, - { - "name": "secret_or_card_num", - "value": "密码/信用卡号" - }, - { - "name": "please_input_secret_or_card_num", - "value": "请输入密码/信用卡号" - }, - { - "name": "label", - "value": "标签(最多4个,以;分隔)" - }, - { - "name": "label2", - "value": "标签" - }, - { - "name": "please_input_label", - "value": "请输入标签名称" - }, - { - "name": "save", - "value": "保存" - }, - { - "name": "delete", - "value": "删除" - }, - { - "name": "search", - "value": "查询" - }, - { - "name": "search_result", - "value": "查询结果" - }, - { - "name": "update", - "value": "更新" - }, - { - "name": "save_failed_for_label", - "value": "保存失败,标签数量超过4个" - }, - { - "name": "save_success", - "value": "保存成功" - }, - { - "name": "save_failed_for_account_exist", - "value": "保存失败,账号已存在" - }, - { - "name": "save_failed", - "value": "保存失败" - }, - { - "name": "remove_success", - "value": "删除成功" - }, - { - "name": "remove_failed_for_account_not_exist", - "value": "删除失败,账号不存在" - }, - { - "name": "remove_failed", - "value": "删除失败" - }, - { - "name": "update_failed", - "value": "更新失败" - }, - { - "name": "update_success", - "value": "更新成功" - }, - { - "name": "update_failed_for_label_over_4", - "value": "更新失败,标签数量超过4个" - }, - { - "name": "query_no_result", - "value": "未查询到结果" - }, - { - "name": "query_failed", - "value": "查询失败" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "please_set_pwd", + "value": "请设置锁屏密码" + }, + { + "name": "auth_failed", + "value": "认证失败" + }, + { + "name": "account", + "value": "账号" + }, + { + "name": "please_input_account", + "value": "请输入账号" + }, + { + "name": "secret_or_card_num", + "value": "密码/信用卡号" + }, + { + "name": "please_input_secret_or_card_num", + "value": "请输入密码/信用卡号" + }, + { + "name": "label", + "value": "标签(最多4个,以;分隔)" + }, + { + "name": "label2", + "value": "标签" + }, + { + "name": "please_input_label", + "value": "请输入标签名称" + }, + { + "name": "save", + "value": "保存" + }, + { + "name": "delete", + "value": "删除" + }, + { + "name": "search", + "value": "查询" + }, + { + "name": "search_result", + "value": "查询结果" + }, + { + "name": "update", + "value": "更新" + }, + { + "name": "save_failed_for_label", + "value": "保存失败,标签数量超过4个" + }, + { + "name": "save_success", + "value": "保存成功" + }, + { + "name": "save_failed_for_account_exist", + "value": "保存失败,账号已存在" + }, + { + "name": "save_failed", + "value": "保存失败" + }, + { + "name": "remove_success", + "value": "删除成功" + }, + { + "name": "remove_failed_for_account_not_exist", + "value": "删除失败,账号不存在" + }, + { + "name": "remove_failed", + "value": "删除失败" + }, + { + "name": "update_failed", + "value": "更新失败" + }, + { + "name": "update_success", + "value": "更新成功" + }, + { + "name": "update_failed_for_label_over_4", + "value": "更新失败,标签数量超过4个" + }, + { + "name": "query_no_result", + "value": "未查询到结果" + }, + { + "name": "query_failed", + "value": "查询失败" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/testability/TestAbility.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/testability/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets b/code/BasicFeature/Security/Asset/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/entry/src/ohosTest/module.json5 b/code/BasicFeature/Security/Asset/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 271c8c41ae..a7685a59ea --- a/code/BasicFeature/Security/Asset/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Security/Asset/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/element/color.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/media/icon.png b/code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/media/icon.png old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/BasicFeature/Security/Asset/entry/src/ohosTest/resources/base/profile/test_pages.json old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/hvigor/hvigor-config.json5 b/code/BasicFeature/Security/Asset/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index 2e24124434..ead0794f85 --- a/code/BasicFeature/Security/Asset/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Security/Asset/hvigor/hvigor-config.json5 @@ -1,18 +1,18 @@ -{ - "hvigorVersion": "4.0.1", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.1" - }, - "execution": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } +{ + "hvigorVersion": "4.0.1", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.1" + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } } \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/hvigor/hvigor-wrapper.js b/code/BasicFeature/Security/Asset/hvigor/hvigor-wrapper.js old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/hvigorfile.ts b/code/BasicFeature/Security/Asset/hvigorfile.ts old mode 100755 new mode 100644 index 159890e9ee..f3cb9f1a87 --- a/code/BasicFeature/Security/Asset/hvigorfile.ts +++ b/code/BasicFeature/Security/Asset/hvigorfile.ts @@ -1,6 +1,6 @@ -import { appTasks } from '@ohos/hvigor-ohos-plugin'; - -export default { - system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ - plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ -} +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/BasicFeature/Security/Asset/hvigorw b/code/BasicFeature/Security/Asset/hvigorw old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/hvigorw.bat b/code/BasicFeature/Security/Asset/hvigorw.bat old mode 100755 new mode 100644 index afaca73582..40079ee7bf --- a/code/BasicFeature/Security/Asset/hvigorw.bat +++ b/code/BasicFeature/Security/Asset/hvigorw.bat @@ -1,77 +1,77 @@ -:: Copyright (c) 2024 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. - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Hvigor startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js -set NODE_EXE=node.exe - -goto start - -:start -@rem Find node.exe -if defined NODE_HOME goto findNodeFromNodeHome - -%NODE_EXE% --version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. -echo. -echo Please set the NODE_HOME variable in your environment to match the -echo location of your NodeJs installation. - -goto fail - -:findNodeFromNodeHome -set NODE_HOME=%NODE_HOME:"=% -set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% - -if exist "%NODE_EXE_PATH%" goto execute -echo. -echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. -echo. -echo Please set the NODE_HOME variable in your environment to match the -echo location of your NodeJs installation. - -goto fail - -:execute -@rem Execute hvigor -"%NODE_EXE%" "%WRAPPER_MODULE_PATH%" %* - -if "%ERRORLEVEL%" == "0" goto hvigorwEnd - -:fail -exit /b 1 - -:hvigorwEnd -if "%OS%" == "Windows_NT" endlocal - -:end +:: Copyright (c) 2024 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. + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Hvigor startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js +set NODE_EXE=node.exe + +goto start + +:start +@rem Find node.exe +if defined NODE_HOME goto findNodeFromNodeHome + +%NODE_EXE% --version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:findNodeFromNodeHome +set NODE_HOME=%NODE_HOME:"=% +set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% + +if exist "%NODE_EXE_PATH%" goto execute +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:execute +@rem Execute hvigor +"%NODE_EXE%" "%WRAPPER_MODULE_PATH%" %* + +if "%ERRORLEVEL%" == "0" goto hvigorwEnd + +:fail +exit /b 1 + +:hvigorwEnd +if "%OS%" == "Windows_NT" endlocal + +:end diff --git a/code/BasicFeature/Security/Asset/oh-package.json5 b/code/BasicFeature/Security/Asset/oh-package.json5 old mode 100755 new mode 100644 index bb904bde41..e1ab333921 --- a/code/BasicFeature/Security/Asset/oh-package.json5 +++ b/code/BasicFeature/Security/Asset/oh-package.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "asset_sample", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dynamicDependencies": {}, - "dependencies": {} -} +/* + * Copyright (c) 2024 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "asset_sample", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dynamicDependencies": {}, + "dependencies": {} +} diff --git a/code/BasicFeature/Security/Asset/ohosTest.md b/code/BasicFeature/Security/Asset/ohosTest.md old mode 100755 new mode 100644 index 0bf4f5abcb..17e38556d1 --- a/code/BasicFeature/Security/Asset/ohosTest.md +++ b/code/BasicFeature/Security/Asset/ohosTest.md @@ -1,11 +1,11 @@ -# 关键资产存储服务测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 |是否自动|测试结果| -|------|---------------|-------------------------------------|----------------------------|--------------------------------|--------------------------------| -| 拉起应用 | 设备正常运行 | | 成功拉起应用 |是|Pass| -| 添加数据 | 成功拉起应用 | 输入账号密码以及标签 | 弹出保存成功 |是|Pass| -| 更新数据 | 成功拉起应用并存入一条数据 | 点击更新页签,输入锁屏密码,进入其中一条查询结果,修改标签信息,点击保存 | 弹出更新成功 |是|Pass| -| 查询数据 | 成功拉起应用并存入一条数据| 点击查询页签,点击底下的查询按钮 | 跳转到查询页面并且显示查询结果,包含账号标签至少一条 |是|Pass| +# 关键资产存储服务测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 |是否自动|测试结果| +|------|---------------|-------------------------------------|----------------------------|--------------------------------|--------------------------------| +| 拉起应用 | 设备正常运行 | | 成功拉起应用 |是|Pass| +| 添加数据 | 成功拉起应用 | 输入账号密码以及标签 | 弹出保存成功 |是|Pass| +| 更新数据 | 成功拉起应用并存入一条数据 | 点击更新页签,输入锁屏密码,进入其中一条查询结果,修改标签信息,点击保存 | 弹出更新成功 |是|Pass| +| 查询数据 | 成功拉起应用并存入一条数据| 点击查询页签,点击底下的查询按钮 | 跳转到查询页面并且显示查询结果,包含账号标签至少一条 |是|Pass| | 删除数据 | 成功拉起应用并存入一条数据| 点击删除页签,点击底下的删除按钮 | 弹出删除成功 |是|Pass| \ No newline at end of file diff --git a/code/BasicFeature/Security/Asset/screenshots/batch_query_result.jpeg b/code/BasicFeature/Security/Asset/screenshots/batch_query_result.jpeg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/screenshots/delete.jpeg b/code/BasicFeature/Security/Asset/screenshots/delete.jpeg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/screenshots/query.jpeg b/code/BasicFeature/Security/Asset/screenshots/query.jpeg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/screenshots/save.jpeg b/code/BasicFeature/Security/Asset/screenshots/save.jpeg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/screenshots/single_query_result.jpeg b/code/BasicFeature/Security/Asset/screenshots/single_query_result.jpeg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/screenshots/update_edit.jpeg b/code/BasicFeature/Security/Asset/screenshots/update_edit.jpeg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/Asset/screenshots/update_list.jpeg b/code/BasicFeature/Security/Asset/screenshots/update_list.jpeg old mode 100755 new mode 100644 diff --git a/code/BasicFeature/Security/CryptoFramework/AppScope/app.json5 b/code/BasicFeature/Security/CryptoFramework/AppScope/app.json5 index 50f2e32383..eaf26bde08 100644 --- a/code/BasicFeature/Security/CryptoFramework/AppScope/app.json5 +++ b/code/BasicFeature/Security/CryptoFramework/AppScope/app.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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.cryptoframework", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name", - "distributedNotificationEnabled": true - } -} +/* + * Copyright (c) 2023 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.cryptoframework", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/code/BasicFeature/Security/CryptoFramework/AppScope/resources/base/element/string.json b/code/BasicFeature/Security/CryptoFramework/AppScope/resources/base/element/string.json index 45d2fa5fde..5f3defbb3f 100644 --- a/code/BasicFeature/Security/CryptoFramework/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Security/CryptoFramework/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "cryptoFramework" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "cryptoFramework" + } + ] +} diff --git a/code/BasicFeature/Security/CryptoFramework/README.md b/code/BasicFeature/Security/CryptoFramework/README.md index 2fd9930f91..0e7ffad35c 100644 --- a/code/BasicFeature/Security/CryptoFramework/README.md +++ b/code/BasicFeature/Security/CryptoFramework/README.md @@ -1,52 +1,52 @@ -# Crypto Framework - -### Introduction - -This sample shows how [@ohos.security.cryptoFramework](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-crypto-architecture-kit/js-apis-cryptoFramework.md) works to implement the function of encrypting, decrypting, signing and verifying text file. The implementation scenario is as follows: - -1. The software needs to encrypt and store the local text file, and it needs to call Crypto Framework to select the key text file and encrypt the local text file, among which the key text file can be generated by Crypto Framework. - -2. The software needs to decrypt and store the local text file, and needs to call Crypto Framework to select the key text file and decrypt the local text file, where the key text file can be generated by Crypto Framework. - -3. The software needs to sign the stored local text file, call the encryption and Crypto Framework to select the key text file, and sign the integrity of the local text file, among which the key text file can be generated by Crypto Framework. - -4. The software needs to verify the signature integrity of the stored local text file, and needs to call Crypto Framework to select the key text file and the signature file, and verify and sign the file, among which the key text file can be generated by Crypto Framework. - -### Usage - -1. Click **Encrypted** in the tab bar of the main page, click **Open File** in the encrypt interface, select the text file through the file chooser, and automatically return to the encrypt interface after selection. - Its contents are displayed in the **File Content** text box, - Click **Select Key** to select the key file, if there is no key file, you can generate and save the key file through the file chooser by clicking **Generate AES Key Randomly** on the encryption interface. - After selecting the text file and key file, click the **Encrypt** button to complete the encryption and save the ciphertext file through the file chooser.s - The encrypted message content is displayed in the **Encrypted Content** text box below. - -2. Click **Decrypt** in the tab bar of the main page, click **Open File** on the decrypt interface, select the text file through the file chooser, and automatically return to the decrypt interface after selection. - Its contents are displayed in the **File Content** text box, - Click **Select Key** to select the same key file as Encryption. - After selecting the text file and key file, click the **Decrypt** button to complete the decryption and save the plaintext file through the file chooser. - The decrypted message content is displayed in the **Decrypted Content** text box below. - -3. Click **Signature** in the tab bar of the main page, click **Open File** on the sign interface, select the text file through the file chooser, and automatically return to the sign interface after selection. - Its contents are displayed in the **File Content** text box, - Click **Select Key** to select the key file, if there is no key file, you can generate and save the key file through the file selector by clicking **Generate RSA Key Randomly** on the signature interface, note that RSA key generation takes a long time. - After selecting the text file and key file, click the **Sign** button to complete the integrity signature and save the signature file through the file chooser. - -4. Click the **Verify** tab bar of the main page, click **Open File** on the verify interface, select the text file through the file chooser, and automatically return to the verify interface after selection. - Its contents are displayed in the **File Content** text box, - Click **Select Key** to select a key file that matches the signature. Click **Select Signature File** to select the signature file saved when signing through the file chooser, - After selecting the text file, key file, and signature file, click the **Verify** button to complete the signature verification. - -### Dependency - -* filePicker[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) -* fileManager[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) -* UI Ability Context[@ohos.app.ability.common](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-ability-kit/js-apis-app-ability-common.md) - -### Constraints - -1. This sample can only be run on standard-system devices. -2. This sample has been adapted to the API version 9 SDK, version number 3.2.12.2. -3. This sample requires DevEco Studio 3.1 Release(Build Version: 3.1.0.500) to compile and run. -4. This sample uses filePicker to select file, the files saved with filePicker, such as new keys generated, can be updated in real time, but the files directly pushed to the folder, they requires reboot the device and refresh the display. -5. This sample supports text file currently only English characters, and as a demonstration, the length of text that can be used successfully does not exceed 8,000 bytes. - +# Crypto Framework + +### Introduction + +This sample shows how [@ohos.security.cryptoFramework](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-crypto-architecture-kit/js-apis-cryptoFramework.md) works to implement the function of encrypting, decrypting, signing and verifying text file. The implementation scenario is as follows: + +1. The software needs to encrypt and store the local text file, and it needs to call Crypto Framework to select the key text file and encrypt the local text file, among which the key text file can be generated by Crypto Framework. + +2. The software needs to decrypt and store the local text file, and needs to call Crypto Framework to select the key text file and decrypt the local text file, where the key text file can be generated by Crypto Framework. + +3. The software needs to sign the stored local text file, call the encryption and Crypto Framework to select the key text file, and sign the integrity of the local text file, among which the key text file can be generated by Crypto Framework. + +4. The software needs to verify the signature integrity of the stored local text file, and needs to call Crypto Framework to select the key text file and the signature file, and verify and sign the file, among which the key text file can be generated by Crypto Framework. + +### Usage + +1. Click **Encrypted** in the tab bar of the main page, click **Open File** in the encrypt interface, select the text file through the file chooser, and automatically return to the encrypt interface after selection. + Its contents are displayed in the **File Content** text box, + Click **Select Key** to select the key file, if there is no key file, you can generate and save the key file through the file chooser by clicking **Generate AES Key Randomly** on the encryption interface. + After selecting the text file and key file, click the **Encrypt** button to complete the encryption and save the ciphertext file through the file chooser.s + The encrypted message content is displayed in the **Encrypted Content** text box below. + +2. Click **Decrypt** in the tab bar of the main page, click **Open File** on the decrypt interface, select the text file through the file chooser, and automatically return to the decrypt interface after selection. + Its contents are displayed in the **File Content** text box, + Click **Select Key** to select the same key file as Encryption. + After selecting the text file and key file, click the **Decrypt** button to complete the decryption and save the plaintext file through the file chooser. + The decrypted message content is displayed in the **Decrypted Content** text box below. + +3. Click **Signature** in the tab bar of the main page, click **Open File** on the sign interface, select the text file through the file chooser, and automatically return to the sign interface after selection. + Its contents are displayed in the **File Content** text box, + Click **Select Key** to select the key file, if there is no key file, you can generate and save the key file through the file selector by clicking **Generate RSA Key Randomly** on the signature interface, note that RSA key generation takes a long time. + After selecting the text file and key file, click the **Sign** button to complete the integrity signature and save the signature file through the file chooser. + +4. Click the **Verify** tab bar of the main page, click **Open File** on the verify interface, select the text file through the file chooser, and automatically return to the verify interface after selection. + Its contents are displayed in the **File Content** text box, + Click **Select Key** to select a key file that matches the signature. Click **Select Signature File** to select the signature file saved when signing through the file chooser, + After selecting the text file, key file, and signature file, click the **Verify** button to complete the signature verification. + +### Dependency + +* filePicker[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) +* fileManager[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) +* UI Ability Context[@ohos.app.ability.common](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-ability-kit/js-apis-app-ability-common.md) + +### Constraints + +1. This sample can only be run on standard-system devices. +2. This sample has been adapted to the API version 9 SDK, version number 3.2.12.2. +3. This sample requires DevEco Studio 3.1 Release(Build Version: 3.1.0.500) to compile and run. +4. This sample uses filePicker to select file, the files saved with filePicker, such as new keys generated, can be updated in real time, but the files directly pushed to the folder, they requires reboot the device and refresh the display. +5. This sample supports text file currently only English characters, and as a demonstration, the length of text that can be used successfully does not exceed 8,000 bytes. + diff --git a/code/BasicFeature/Security/CryptoFramework/build-profile.json5 b/code/BasicFeature/Security/CryptoFramework/build-profile.json5 index cd63244ded..4a54f2a9a5 100644 --- a/code/BasicFeature/Security/CryptoFramework/build-profile.json5 +++ b/code/BasicFeature/Security/CryptoFramework/build-profile.json5 @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2023 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": [], - "compileSdkVersion": 9, - "compatibleSdkVersion": 9, - "products": [ - { - "name": "default", - "signingConfig": "default" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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": [], + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, + "products": [ + { + "name": "default", + "signingConfig": "default" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/CryptoFramework/entry/build-profile.json5 b/code/BasicFeature/Security/CryptoFramework/entry/build-profile.json5 index 3c09a4cef2..ddd6e5f1ac 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/build-profile.json5 +++ b/code/BasicFeature/Security/CryptoFramework/entry/build-profile.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/CryptoFramework/entry/oh-package.json5 b/code/BasicFeature/Security/CryptoFramework/entry/oh-package.json5 index 46187dd2f7..907d65a0ae 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/oh-package.json5 +++ b/code/BasicFeature/Security/CryptoFramework/entry/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "ISC", - "devDependencies": {}, - "name": "entry", - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/cryptoframework/CryptoOperation.ts b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/cryptoframework/CryptoOperation.ts index d1a5c995a8..7b3ddc2d32 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/cryptoframework/CryptoOperation.ts +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/cryptoframework/CryptoOperation.ts @@ -1,385 +1,385 @@ -/* - * Copyright (c) 2023 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 cryptoFramework from '@ohos.security.cryptoFramework'; -import promptAction from '@ohos.promptAction'; -import Logger from '../util/Logger'; - -const TAG: string = '[Crypto_Framework]'; -const BASE_16: number = 16; -const SLICE_NUMBER: number = -2; - -// 字节流以16进制字符串输出 -function uint8ArrayToShowStr(uint8Array: Uint8Array): string { - let ret: string = Array.prototype.map - .call(uint8Array, (x) => ('00' + x.toString(BASE_16)).slice(SLICE_NUMBER)).join(''); - return ret; -} - -// 16进制字符串转字节流 -function fromHexString(hexString: string): Uint8Array { - let ret: Uint8Array = new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, BASE_16))); - return ret; -} - - -// 字节流转字符串 -function arrayBufferToString(buffer: ArrayBuffer): string { - let ret: string = String.fromCharCode.apply(null, new Uint8Array(buffer)); - return ret; -} - -// 可理解的字符串转成字节流 -function stringToUint8Array(str: string): Uint8Array { - let arr = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - let ret: Uint8Array = new Uint8Array(arr); - return ret; -} - -function genGcmParamsSpec(): cryptoFramework.GcmParamsSpec { - let arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 12 bytes - let dataIv = new Uint8Array(arr); - let ivBlob = { data: dataIv }; - - arr = [0, 0, 0, 0, 0, 0, 0, 0]; // 8 bytes - let dataAad = new Uint8Array(arr); - let aadBlob = { data: dataAad }; - - arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes - let dataTag = new Uint8Array(arr); - let tagBlob = { data: dataTag }; // GCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 - - let gcmParamsSpec = { iv: ivBlob, aad: aadBlob, authTag: tagBlob, algName: 'GcmParamsSpec' }; - return gcmParamsSpec; -} - -export class CryptoOperation { - async generateAesKey(): Promise { - let symKeyGenerator; - let encodedKey; - // 创建对称密钥生成器 - try { - symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256'); - } catch (error) { - Logger.error(TAG, 'create generator failed'); - return null; - } - - // 通过密钥生成器随机生成对称密钥 - try { - let symKey = await symKeyGenerator.generateSymKey(); - // 获取对称密钥的二进制数据,输出长度为256bit的字节流 - encodedKey = symKey.getEncoded(); - let data: Uint8Array = encodedKey.data; - Logger.info('success, key bytes: ' + data); - Logger.info('success, key hex:' + uint8ArrayToShowStr(data)); - // 将二进制数据转为16进制string。 - return uint8ArrayToShowStr(data); - } catch (error) { - Logger.error(TAG, 'create symKey failed'); - return null; - } - } - - async convertAesKey(aesKeyBlobString: string): Promise { - let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256'); - Logger.info(TAG, 'success, read key string' + aesKeyBlobString); - Logger.info(TAG, 'success, blob key ' + fromHexString(aesKeyBlobString)); - let symKeyBlob = { data: fromHexString(aesKeyBlobString) }; - try { - let key = await symKeyGenerator.convertKey(symKeyBlob); - let aesKey: cryptoFramework.SymKey = key; - return aesKey; - } catch (error) { - Logger.error(TAG, `convert aes key failed, ${error.code}, ${error.message}`); - return null; - } - } - - async aesGcmEncrypt(globalKey, textString: string): Promise { - let cipherAlgName = 'AES256|GCM|PKCS7'; - let cipher; - let cipherText: string; - let globalGcmParams = genGcmParamsSpec(); - let aesEncryptJsonStr = null; - try { - cipher = cryptoFramework.createCipher(cipherAlgName); - Logger.info(TAG, `cipher algName: ${cipher.algName}`); - } catch (error) { - Logger.error(TAG, `createCipher failed, ${error.code}, ${error.message}`); - return aesEncryptJsonStr; - } - let mode = cryptoFramework.CryptoMode.ENCRYPT_MODE; - try { - await cipher.init(mode, globalKey, globalGcmParams); - } catch (error) { - Logger.error(TAG, `init cipher failed, ${error.code}, ${error.message}`); - return aesEncryptJsonStr; - } - let plainText = { data: stringToUint8Array(textString) }; - Logger.info(TAG, `plain text: ${plainText.data}`); - try { - let cipherTextBlob = await cipher.update(plainText); - let tmpArr: Uint8Array = cipherTextBlob.data; - cipherText = uint8ArrayToShowStr(tmpArr); - Logger.info(TAG, `cipher text: ${cipherText}`); - } catch (error) { - Logger.error(TAG, `update cipher failed, ${error.code}, ${error.message}`); - return aesEncryptJsonStr; - } - try { - let authTag = await cipher.doFinal(null); - let tmoTagArr: Uint8Array = authTag.data; - let aesEncryptJson = ({ aesGcmTag: uint8ArrayToShowStr(tmoTagArr), encryptedText: cipherText }); - aesEncryptJsonStr = JSON.stringify(aesEncryptJson); - Logger.info(TAG, `success, authTag blob ${authTag.data}`); - Logger.info(TAG, `success, authTag blob.length = ${authTag.data.length}`); - return aesEncryptJsonStr; - } catch (error) { - Logger.error(TAG, `doFinal cipher failed, ${error.code}, ${error.message}`); - return aesEncryptJsonStr; - } - } - - async aesGcmDecrypt(globalKey, aesEncryptJsonStr: string): Promise { - let cipherAlgName = 'AES256|GCM|PKCS7'; - let decode; - let plainTextBlob; - let plainText: string; - let aesEncryptJson; - try { - aesEncryptJson = JSON.parse(aesEncryptJsonStr); - } catch (error) { - Logger.error(TAG, `trans from json string failed, ${error.code}, ${error.message}`); - return null; - } - let authTagStr: string = aesEncryptJson.aesGcmTag; - let textString: string = aesEncryptJson.encryptedText; - let globalGcmParams = genGcmParamsSpec(); - globalGcmParams.authTag = { data: fromHexString(authTagStr) }; - Logger.info(TAG, 'success, decrypt authTag string' + authTagStr); - Logger.info(TAG, 'success, decrypt authTag blob' + globalGcmParams.authTag.data); - Logger.info(TAG, 'success, decrypt authTag blob.length = ' + globalGcmParams.authTag.data.length); - try { - decode = cryptoFramework.createCipher(cipherAlgName); - } catch (error) { - Logger.error(TAG, `createCipher failed, ${error.code}, ${error.message}`); - return null; - } - let mode = cryptoFramework.CryptoMode.DECRYPT_MODE; - try { - await decode.init(mode, globalKey, globalGcmParams); - } catch (error) { - Logger.error(TAG, `init decode failed, ${error.code}, ${error.message}`); - return null; - } - let cipherText = { data: fromHexString(textString) }; - Logger.info(TAG, `success, cipher text: ${cipherText.data}`); - try { - plainTextBlob = await decode.update(cipherText); - let tmpArr: Uint8Array = plainTextBlob.data; - plainText = arrayBufferToString(tmpArr); - Logger.info(TAG, `success, plain text: ${plainText}`); - } catch (error) { - Logger.error(TAG, `update decode failed, ${error.code}, ${error.message}`); - return null; - } - try { - let finalOut = await decode.doFinal(null); - } catch (error) { - Logger.error(TAG, `doFinal decode failed, ${error.code}, ${error.message}`); - return null; - } - return plainText; - } - - async aesConvertAndEncrypt(aesKeyBlobString: string, textString: string): Promise { - let aesEncryptJsonStr = ''; - try { - let key = await this.convertAesKey(aesKeyBlobString); - try { - aesEncryptJsonStr = await this.aesGcmEncrypt(key, textString); - } catch (error) { - Logger.error(TAG, `encrypt error, ${error.code}, ${error.message}`); - } - } catch (error) { - Logger.error(TAG, `convert key error, ${error.code}, ${error.message}`); - return null; - } - return aesEncryptJsonStr; - } - - async aesConvertAndDecrypt(aesKeyBlobString: string, textString: string): Promise { - let plainText = ''; - try { - let key = await this.convertAesKey(aesKeyBlobString); - try { - plainText = await this.aesGcmDecrypt(key, textString); - } catch (error) { - Logger.error(TAG, `encrypt error, ${error.code}, ${error.message}`); - } - } catch (error) { - Logger.error(TAG, `convert key error, ${error.code}, ${error.message}`); - return null; - } - return plainText; - } - - async generateRsaKey(): Promise { - // 创建非对称密钥生成器 - let rsaKeyGenerator; - let jsonStr; - // 创建对称密钥生成器 - try { - rsaKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA3072'); - } catch (error) { - Logger.error(TAG, 'create generator failed'); - return null; - } - // 通过密钥生成器随机生成非对称密钥 - try { - // 通过密钥生成器随机生成非对称密钥 - let keyPair = await rsaKeyGenerator.generateKeyPair(); - // 获取非对称密钥的二进制数据 - let encodedPriKey = keyPair.priKey.getEncoded(); - let priKeyData: Uint8Array = encodedPriKey.data; - let encodedPubKey = keyPair.pubKey.getEncoded(); - let pubKeyData: Uint8Array = encodedPubKey.data; - let rsaKeyJson = ({ priKey: uint8ArrayToShowStr(priKeyData), pubKey: uint8ArrayToShowStr(pubKeyData) }); - jsonStr = JSON.stringify(rsaKeyJson); - Logger.info(TAG, 'success, key string: ' + jsonStr.length); - return jsonStr; - } catch (error) { - Logger.error(TAG, 'create symKey failed'); - return null; - } - } - - async convertRsaKey(rsaJsonString: string): Promise { - let rsaKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA3072'); - Logger.info(TAG, 'success, read key string' + rsaJsonString.length); - let jsonRsaKeyBlob; - try { - jsonRsaKeyBlob = JSON.parse(rsaJsonString); - } catch (error) { - Logger.error(TAG, `trans from json string failed, ${error.code}, ${error.message}`); - return null; - } - let priKeyStr: string = jsonRsaKeyBlob.priKey; - let pubKeyStr: string = jsonRsaKeyBlob.pubKey; - Logger.info(TAG, 'success, read rsa pri str ' + priKeyStr.length); - Logger.info(TAG, 'success, read rsa pub str ' + pubKeyStr.length); - let priKeyBlob = fromHexString(priKeyStr); - let pubKeyBlob = fromHexString(pubKeyStr); - Logger.info(TAG, 'success, read rsa pri blob key ' + priKeyBlob.length); - Logger.info(TAG, 'success, read rsa pub blob key ' + pubKeyBlob.length); - try { - let key: cryptoFramework.KeyPair = await rsaKeyGenerator.convertKey({ data: pubKeyBlob }, { data: priKeyBlob }); - return key; - Logger.info(TAG, 'success, read and convert key'); - } catch (error) { - Logger.error(TAG, `convert rsa key failed, ${error.code}, ${error.message}`); - return null; - } - } - - async rsaSign(globalKey, textString: string): Promise { - let signer = cryptoFramework.createSign('RSA3072|PKCS1|SHA256'); - let keyPair = globalKey; - try { - await signer.init(keyPair.priKey); - let signBlob = stringToUint8Array(textString); - try { - let signedBlob = await signer.sign({ data: signBlob }); - let tmpArr: Uint8Array = signedBlob.data; - Logger.info(TAG, 'success,RSA sign output is' + signedBlob.data.length); - let rsaSignedBlobString = uint8ArrayToShowStr(tmpArr); - Logger.info(TAG, 'success,RSA sign string is' + rsaSignedBlobString); - return rsaSignedBlobString; - } catch (error1) { - Logger.error(TAG, `sign text failed, ${error1.code}, ${error1.message}`); - return null; - } - } catch (error) { - Logger.error(TAG, `sign init failed, ${error.code}, ${error.message}`); - return null; - } - } - - async rsaVerify(globalKey, textString: string, rsaSignedText: string): Promise { - let verifyer = cryptoFramework.createVerify('RSA3072|PKCS1|SHA256'); - let keyPair = globalKey; - let signBlob = stringToUint8Array(textString); - let signedBlob = fromHexString(rsaSignedText); - Logger.info('success,RSA sign input is ' + signBlob); - Logger.info('success,RSA signed file length ' + signedBlob.length); - try { - await verifyer.init(keyPair.pubKey); - try { - let result: Boolean = await verifyer.verify({ data: signBlob }, { data: signedBlob }); - if (result === false) { - // flag = false; - Logger.error(TAG, 'RSA Verify result = fail'); - } else { - Logger.info(TAG, 'success, RSA Verify result = success'); - } - return result; - } catch (error) { - Logger.error(TAG, `verify dofinal failed, ${error.code}, ${error.message}`); - } - } catch (err) { - Logger.error(TAG, `verify init failed, ${err.code}, ${err.message}`); - } - return null; - } - - async rsaConvertAndSign(rsaJsonString: string, textString: string): Promise { - let rsaSignString; - try { - let key = await this.convertRsaKey(rsaJsonString); - try { - rsaSignString = await this.rsaSign(key, textString); - } catch (error) { - Logger.error(TAG, `sign error, ${error.code}, ${error.message}`); - return null; - } - } catch (error) { - Logger.error(TAG, `convert rsa key error, ${error.code}, ${error.message}`); - return null; - } - return rsaSignString; - } - - async rsaConvertAndVerify(rsaJsonString: string, textString: string, rsaSignedText: string): Promise { - let rsaVerifyRes; - try { - let key = await this.convertRsaKey(rsaJsonString); - try { - rsaVerifyRes = await this.rsaVerify(key, textString, rsaSignedText); - } catch (error) { - Logger.error(TAG, `sign error, ${error.code}, ${error.message}`); - return null; - } - } catch (error) { - Logger.error(TAG, `convert rsa key error, ${error.code}, ${error.message}`); - return null; - } - return rsaVerifyRes; - } -} - +/* + * Copyright (c) 2023 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 cryptoFramework from '@ohos.security.cryptoFramework'; +import promptAction from '@ohos.promptAction'; +import Logger from '../util/Logger'; + +const TAG: string = '[Crypto_Framework]'; +const BASE_16: number = 16; +const SLICE_NUMBER: number = -2; + +// 字节流以16进制字符串输出 +function uint8ArrayToShowStr(uint8Array: Uint8Array): string { + let ret: string = Array.prototype.map + .call(uint8Array, (x) => ('00' + x.toString(BASE_16)).slice(SLICE_NUMBER)).join(''); + return ret; +} + +// 16进制字符串转字节流 +function fromHexString(hexString: string): Uint8Array { + let ret: Uint8Array = new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, BASE_16))); + return ret; +} + + +// 字节流转字符串 +function arrayBufferToString(buffer: ArrayBuffer): string { + let ret: string = String.fromCharCode.apply(null, new Uint8Array(buffer)); + return ret; +} + +// 可理解的字符串转成字节流 +function stringToUint8Array(str: string): Uint8Array { + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + let ret: Uint8Array = new Uint8Array(arr); + return ret; +} + +function genGcmParamsSpec(): cryptoFramework.GcmParamsSpec { + let arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 12 bytes + let dataIv = new Uint8Array(arr); + let ivBlob = { data: dataIv }; + + arr = [0, 0, 0, 0, 0, 0, 0, 0]; // 8 bytes + let dataAad = new Uint8Array(arr); + let aadBlob = { data: dataAad }; + + arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes + let dataTag = new Uint8Array(arr); + let tagBlob = { data: dataTag }; // GCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 + + let gcmParamsSpec = { iv: ivBlob, aad: aadBlob, authTag: tagBlob, algName: 'GcmParamsSpec' }; + return gcmParamsSpec; +} + +export class CryptoOperation { + async generateAesKey(): Promise { + let symKeyGenerator; + let encodedKey; + // 创建对称密钥生成器 + try { + symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256'); + } catch (error) { + Logger.error(TAG, 'create generator failed'); + return null; + } + + // 通过密钥生成器随机生成对称密钥 + try { + let symKey = await symKeyGenerator.generateSymKey(); + // 获取对称密钥的二进制数据,输出长度为256bit的字节流 + encodedKey = symKey.getEncoded(); + let data: Uint8Array = encodedKey.data; + Logger.info('success, key bytes: ' + data); + Logger.info('success, key hex:' + uint8ArrayToShowStr(data)); + // 将二进制数据转为16进制string。 + return uint8ArrayToShowStr(data); + } catch (error) { + Logger.error(TAG, 'create symKey failed'); + return null; + } + } + + async convertAesKey(aesKeyBlobString: string): Promise { + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256'); + Logger.info(TAG, 'success, read key string' + aesKeyBlobString); + Logger.info(TAG, 'success, blob key ' + fromHexString(aesKeyBlobString)); + let symKeyBlob = { data: fromHexString(aesKeyBlobString) }; + try { + let key = await symKeyGenerator.convertKey(symKeyBlob); + let aesKey: cryptoFramework.SymKey = key; + return aesKey; + } catch (error) { + Logger.error(TAG, `convert aes key failed, ${error.code}, ${error.message}`); + return null; + } + } + + async aesGcmEncrypt(globalKey, textString: string): Promise { + let cipherAlgName = 'AES256|GCM|PKCS7'; + let cipher; + let cipherText: string; + let globalGcmParams = genGcmParamsSpec(); + let aesEncryptJsonStr = null; + try { + cipher = cryptoFramework.createCipher(cipherAlgName); + Logger.info(TAG, `cipher algName: ${cipher.algName}`); + } catch (error) { + Logger.error(TAG, `createCipher failed, ${error.code}, ${error.message}`); + return aesEncryptJsonStr; + } + let mode = cryptoFramework.CryptoMode.ENCRYPT_MODE; + try { + await cipher.init(mode, globalKey, globalGcmParams); + } catch (error) { + Logger.error(TAG, `init cipher failed, ${error.code}, ${error.message}`); + return aesEncryptJsonStr; + } + let plainText = { data: stringToUint8Array(textString) }; + Logger.info(TAG, `plain text: ${plainText.data}`); + try { + let cipherTextBlob = await cipher.update(plainText); + let tmpArr: Uint8Array = cipherTextBlob.data; + cipherText = uint8ArrayToShowStr(tmpArr); + Logger.info(TAG, `cipher text: ${cipherText}`); + } catch (error) { + Logger.error(TAG, `update cipher failed, ${error.code}, ${error.message}`); + return aesEncryptJsonStr; + } + try { + let authTag = await cipher.doFinal(null); + let tmoTagArr: Uint8Array = authTag.data; + let aesEncryptJson = ({ aesGcmTag: uint8ArrayToShowStr(tmoTagArr), encryptedText: cipherText }); + aesEncryptJsonStr = JSON.stringify(aesEncryptJson); + Logger.info(TAG, `success, authTag blob ${authTag.data}`); + Logger.info(TAG, `success, authTag blob.length = ${authTag.data.length}`); + return aesEncryptJsonStr; + } catch (error) { + Logger.error(TAG, `doFinal cipher failed, ${error.code}, ${error.message}`); + return aesEncryptJsonStr; + } + } + + async aesGcmDecrypt(globalKey, aesEncryptJsonStr: string): Promise { + let cipherAlgName = 'AES256|GCM|PKCS7'; + let decode; + let plainTextBlob; + let plainText: string; + let aesEncryptJson; + try { + aesEncryptJson = JSON.parse(aesEncryptJsonStr); + } catch (error) { + Logger.error(TAG, `trans from json string failed, ${error.code}, ${error.message}`); + return null; + } + let authTagStr: string = aesEncryptJson.aesGcmTag; + let textString: string = aesEncryptJson.encryptedText; + let globalGcmParams = genGcmParamsSpec(); + globalGcmParams.authTag = { data: fromHexString(authTagStr) }; + Logger.info(TAG, 'success, decrypt authTag string' + authTagStr); + Logger.info(TAG, 'success, decrypt authTag blob' + globalGcmParams.authTag.data); + Logger.info(TAG, 'success, decrypt authTag blob.length = ' + globalGcmParams.authTag.data.length); + try { + decode = cryptoFramework.createCipher(cipherAlgName); + } catch (error) { + Logger.error(TAG, `createCipher failed, ${error.code}, ${error.message}`); + return null; + } + let mode = cryptoFramework.CryptoMode.DECRYPT_MODE; + try { + await decode.init(mode, globalKey, globalGcmParams); + } catch (error) { + Logger.error(TAG, `init decode failed, ${error.code}, ${error.message}`); + return null; + } + let cipherText = { data: fromHexString(textString) }; + Logger.info(TAG, `success, cipher text: ${cipherText.data}`); + try { + plainTextBlob = await decode.update(cipherText); + let tmpArr: Uint8Array = plainTextBlob.data; + plainText = arrayBufferToString(tmpArr); + Logger.info(TAG, `success, plain text: ${plainText}`); + } catch (error) { + Logger.error(TAG, `update decode failed, ${error.code}, ${error.message}`); + return null; + } + try { + let finalOut = await decode.doFinal(null); + } catch (error) { + Logger.error(TAG, `doFinal decode failed, ${error.code}, ${error.message}`); + return null; + } + return plainText; + } + + async aesConvertAndEncrypt(aesKeyBlobString: string, textString: string): Promise { + let aesEncryptJsonStr = ''; + try { + let key = await this.convertAesKey(aesKeyBlobString); + try { + aesEncryptJsonStr = await this.aesGcmEncrypt(key, textString); + } catch (error) { + Logger.error(TAG, `encrypt error, ${error.code}, ${error.message}`); + } + } catch (error) { + Logger.error(TAG, `convert key error, ${error.code}, ${error.message}`); + return null; + } + return aesEncryptJsonStr; + } + + async aesConvertAndDecrypt(aesKeyBlobString: string, textString: string): Promise { + let plainText = ''; + try { + let key = await this.convertAesKey(aesKeyBlobString); + try { + plainText = await this.aesGcmDecrypt(key, textString); + } catch (error) { + Logger.error(TAG, `encrypt error, ${error.code}, ${error.message}`); + } + } catch (error) { + Logger.error(TAG, `convert key error, ${error.code}, ${error.message}`); + return null; + } + return plainText; + } + + async generateRsaKey(): Promise { + // 创建非对称密钥生成器 + let rsaKeyGenerator; + let jsonStr; + // 创建对称密钥生成器 + try { + rsaKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA3072'); + } catch (error) { + Logger.error(TAG, 'create generator failed'); + return null; + } + // 通过密钥生成器随机生成非对称密钥 + try { + // 通过密钥生成器随机生成非对称密钥 + let keyPair = await rsaKeyGenerator.generateKeyPair(); + // 获取非对称密钥的二进制数据 + let encodedPriKey = keyPair.priKey.getEncoded(); + let priKeyData: Uint8Array = encodedPriKey.data; + let encodedPubKey = keyPair.pubKey.getEncoded(); + let pubKeyData: Uint8Array = encodedPubKey.data; + let rsaKeyJson = ({ priKey: uint8ArrayToShowStr(priKeyData), pubKey: uint8ArrayToShowStr(pubKeyData) }); + jsonStr = JSON.stringify(rsaKeyJson); + Logger.info(TAG, 'success, key string: ' + jsonStr.length); + return jsonStr; + } catch (error) { + Logger.error(TAG, 'create symKey failed'); + return null; + } + } + + async convertRsaKey(rsaJsonString: string): Promise { + let rsaKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA3072'); + Logger.info(TAG, 'success, read key string' + rsaJsonString.length); + let jsonRsaKeyBlob; + try { + jsonRsaKeyBlob = JSON.parse(rsaJsonString); + } catch (error) { + Logger.error(TAG, `trans from json string failed, ${error.code}, ${error.message}`); + return null; + } + let priKeyStr: string = jsonRsaKeyBlob.priKey; + let pubKeyStr: string = jsonRsaKeyBlob.pubKey; + Logger.info(TAG, 'success, read rsa pri str ' + priKeyStr.length); + Logger.info(TAG, 'success, read rsa pub str ' + pubKeyStr.length); + let priKeyBlob = fromHexString(priKeyStr); + let pubKeyBlob = fromHexString(pubKeyStr); + Logger.info(TAG, 'success, read rsa pri blob key ' + priKeyBlob.length); + Logger.info(TAG, 'success, read rsa pub blob key ' + pubKeyBlob.length); + try { + let key: cryptoFramework.KeyPair = await rsaKeyGenerator.convertKey({ data: pubKeyBlob }, { data: priKeyBlob }); + return key; + Logger.info(TAG, 'success, read and convert key'); + } catch (error) { + Logger.error(TAG, `convert rsa key failed, ${error.code}, ${error.message}`); + return null; + } + } + + async rsaSign(globalKey, textString: string): Promise { + let signer = cryptoFramework.createSign('RSA3072|PKCS1|SHA256'); + let keyPair = globalKey; + try { + await signer.init(keyPair.priKey); + let signBlob = stringToUint8Array(textString); + try { + let signedBlob = await signer.sign({ data: signBlob }); + let tmpArr: Uint8Array = signedBlob.data; + Logger.info(TAG, 'success,RSA sign output is' + signedBlob.data.length); + let rsaSignedBlobString = uint8ArrayToShowStr(tmpArr); + Logger.info(TAG, 'success,RSA sign string is' + rsaSignedBlobString); + return rsaSignedBlobString; + } catch (error1) { + Logger.error(TAG, `sign text failed, ${error1.code}, ${error1.message}`); + return null; + } + } catch (error) { + Logger.error(TAG, `sign init failed, ${error.code}, ${error.message}`); + return null; + } + } + + async rsaVerify(globalKey, textString: string, rsaSignedText: string): Promise { + let verifyer = cryptoFramework.createVerify('RSA3072|PKCS1|SHA256'); + let keyPair = globalKey; + let signBlob = stringToUint8Array(textString); + let signedBlob = fromHexString(rsaSignedText); + Logger.info('success,RSA sign input is ' + signBlob); + Logger.info('success,RSA signed file length ' + signedBlob.length); + try { + await verifyer.init(keyPair.pubKey); + try { + let result: Boolean = await verifyer.verify({ data: signBlob }, { data: signedBlob }); + if (result === false) { + // flag = false; + Logger.error(TAG, 'RSA Verify result = fail'); + } else { + Logger.info(TAG, 'success, RSA Verify result = success'); + } + return result; + } catch (error) { + Logger.error(TAG, `verify dofinal failed, ${error.code}, ${error.message}`); + } + } catch (err) { + Logger.error(TAG, `verify init failed, ${err.code}, ${err.message}`); + } + return null; + } + + async rsaConvertAndSign(rsaJsonString: string, textString: string): Promise { + let rsaSignString; + try { + let key = await this.convertRsaKey(rsaJsonString); + try { + rsaSignString = await this.rsaSign(key, textString); + } catch (error) { + Logger.error(TAG, `sign error, ${error.code}, ${error.message}`); + return null; + } + } catch (error) { + Logger.error(TAG, `convert rsa key error, ${error.code}, ${error.message}`); + return null; + } + return rsaSignString; + } + + async rsaConvertAndVerify(rsaJsonString: string, textString: string, rsaSignedText: string): Promise { + let rsaVerifyRes; + try { + let key = await this.convertRsaKey(rsaJsonString); + try { + rsaVerifyRes = await this.rsaVerify(key, textString, rsaSignedText); + } catch (error) { + Logger.error(TAG, `sign error, ${error.code}, ${error.message}`); + return null; + } + } catch (error) { + Logger.error(TAG, `convert rsa key error, ${error.code}, ${error.message}`); + return null; + } + return rsaVerifyRes; + } +} + diff --git a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/entryability/EntryAbility.ts index 202b948c9e..7370b8f327 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import hilog from '@ohos.hilog'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - 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'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + 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/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Decrypt.ets b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Decrypt.ets index 2e505fabbe..f6b8e62bfb 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Decrypt.ets +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Decrypt.ets @@ -1,330 +1,330 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import promptAction from '@ohos.promptAction'; -import Logger from '../util/Logger'; -import picker from '@ohos.file.picker'; -import { CryptoOperation } from '../cryptoframework/CryptoOperation'; -import TextFileManager from '../textfilemanager/TextFileManager'; -import common from '@ohos.app.ability.common'; - -const TAG: string = '[Crypto_Framework]'; - -@Component -export struct Decrypt { - @State keyFileName: string = ''; - @State keyFileUri: string = ''; - @State textFileUri: string = ''; - @State textFileName: string = ''; - @State keyString: string = ''; - @State cipherText: string = ''; - @State plainText: string = ''; - @State message: string = ''; - @State decryptedFileUri: string = ''; - private CryptoOperation: CryptoOperation = new CryptoOperation(); - - build() { - Stack({ alignContent: Alignment.Center }) { - Column() { - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - List() { - ListItem() { - Row() { - Text($r('app.string.open_file')) - .fontSize(16) - .textAlign(TextAlign.Start) - .lineHeight(22) - - Blank() - - Text(this.textFileName === '' ? $r('app.string.please_choose') : this.textFileName) - .fontSize(14) - .textAlign(TextAlign.Start) - .lineHeight(19) - - Image($r('app.media.right_arrow')) - .height('19vp') - .width('10vp') - .margin({ left: 9, right: 9, top: 6, bottom: 6 }) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('52vp') - .padding({ top: 4, left: 12, right: 12 }) - }.onClick(() => { - this.selectTextFileAndRead(); - }) - - ListItem() { - Row() { - Text($r('app.string.select_key_file')) - .fontSize(16) - .textAlign(TextAlign.Start) - .lineHeight(22) - - Blank() - - Text(this.keyFileName === '' ? $r('app.string.please_choose') : this.keyFileName) - .fontSize(14) - .textAlign(TextAlign.Start) - .lineHeight(19) - - Image($r('app.media.right_arrow')) - .height('19vp') - .width('10vp') - .margin({ left: 9, right: 9, top: 6, bottom: 6 }) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('48vp') - .padding({ left: 12, right: 12 }) - }.onClick(() => { - this.selectAesKeyFileAndRead(); - }) - } - .width('100%') - .height('100%') - .borderRadius(16) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Column() { - Row() { - Text($r('app.string.text_context')) - .fontSize(16) - .textAlign(TextAlign.Start) - .fontWeight(500) - .lineHeight(22) - } - .padding({ left: 12, right: 12 }) - .width('100%') - .height('48vp') - - Row() { - Text() { - Span(this.cipherText) - .fontSize(16) - .fontWeight(400) - .fontColor('#182431') - }.textAlign(TextAlign.Start) - } - .padding({ left: 12, right: 12, bottom: 4 }) - .width('100%') - .height('52vp') - } - .borderRadius(16) - .width('100%') - .height('100') - .backgroundColor(0xFFFFFF) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Column() { - Row() { - Text($r('app.string.decrypted_context')) - .fontSize(16) - .textAlign(TextAlign.Start) - .fontWeight(500) - .lineHeight(22) - } - .padding({ left: 12, right: 12 }) - .width('100%') - .height('48vp') - - Row() { - Text() { - Span(this.plainText) - .fontSize(16) - .fontWeight(400) - .fontColor('#182431') - }.textAlign(TextAlign.Start) - } - .padding({ left: 12, right: 12, bottom: 4 }) - .width('100%') - .height('52vp') - } - .borderRadius(16) - .width('100%') - .height('100') - .backgroundColor(0xFFFFFF) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - Column() { - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Column() { - Button() { - Text($r('app.string.decrypt')).fontSize(16).fontWeight(500) - .lineHeight(22) - .fontColor('#FFFFFF') - } - .borderRadius(20) - .id('decryptionBtn') - .type(ButtonType.Capsule) - .margin({ left: 24, right: 24 }) - .width('100%') - .height('40vp') - .backgroundColor('#007DFF') - .onClick(() => { - if (this.textFileUri === '' || this.keyFileUri === '') { - promptAction.showToast({ - message: $r('app.string.null_message') - }); - } else { - this.decryptFunc(); - } - }); - } - } - }.margin({ left: 24, right: 24 }) - }.width('100%').height('296vp').justifyContent(FlexAlign.End) - } - .width('100%') - .height('100%') - } - } - - async selectAesKeyFileAndRead() { - let config = { - action: 'ohos.want.action.OPEN_FILE', - parameters: { - startMode: 'choose', - } - } - let context = getContext(this) as common.UIAbilityContext; - let result = await context.startAbilityForResult(config); - if (result === null || result === undefined) { - Logger.error(TAG, `result is null or undefined!`); - return; - } - if (result.resultCode !== 0) { - Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); - return; - } - if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { - Logger.error(TAG, `result uri is null or undefined!`); - return; - } - if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { - Logger.error(TAG, `result file name is null or undefined!`); - return; - } - // 获取到密钥文档文件的URI - this.keyFileUri = result.want.parameters.select_item_list.toString(); - // 获取到密钥文档文件的文件名称 - this.keyFileName = result.want.parameters.file_name_list.toString(); - await TextFileManager.readTextFile(this.keyFileUri); - this.keyString = TextFileManager.getString(); - } - - async selectTextFileAndRead() { - let config = { - action: 'ohos.want.action.OPEN_FILE', - parameters: { - startMode: 'choose', - } - } - let context = getContext(this) as common.UIAbilityContext; - let result = await context.startAbilityForResult(config); - if (result === null || result === undefined) { - Logger.error(TAG, `result is null or undefined!`); - return; - } - if (result.resultCode !== 0) { - Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); - return; - } - if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { - Logger.error(TAG, `result uri is null or undefined!`); - return; - } - if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { - Logger.error(TAG, `result file name is null or undefined!`); - return; - } - // 获取到文档文件的URI - this.textFileUri = result.want.parameters.select_item_list.toString(); - // 获取到文档文件的文件名称 - this.textFileName = result.want.parameters.file_name_list.toString(); - await TextFileManager.readTextFile(this.textFileUri); - this.cipherText = TextFileManager.getString(); - } - - async createTextFileAndWrite() { - let documentSaveOptions = new picker.DocumentSaveOptions(); - documentSaveOptions.newFileNames = ['plainText.txt']; - let documentPicker = new picker.DocumentViewPicker(); - let documentSaveResult = await documentPicker.save(documentSaveOptions); - this.decryptedFileUri = documentSaveResult[0]; - await TextFileManager.writeTextFile(this.decryptedFileUri, this.plainText); - } - - async decryptFunc() { - if (this.cipherText === '' || this.keyFileUri === '') { - promptAction.showToast({ - message: $r('app.string.null_message') - }); - return; - } - try { - this.plainText = await this.CryptoOperation.aesConvertAndDecrypt(this.keyString, this.cipherText); - } catch (error) { - Logger.error(TAG, `decrypt failed, ${error.code}, ${error.message}`); - promptAction.showToast({ - message: $r('app.string.decrypt_fail') - }); - return; - } - if (this.plainText === '' || this.plainText === null || this.plainText === undefined) { - promptAction.showToast({ - message: $r('app.string.decrypt_fail') - }); - return; - } else { - try { - await this.createTextFileAndWrite(); - } catch (error) { - Logger.error(TAG, `decrypt failed, ${error.code}, ${error.message}`); - } - } - if (this.decryptedFileUri === '' || typeof (this.decryptedFileUri) == 'undefined') { - promptAction.showToast({ - message: $r('app.string.decrypt_fail') - }); - } else { - promptAction.showToast({ - message: $r('app.string.decrypt_success') - }); - } - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import promptAction from '@ohos.promptAction'; +import Logger from '../util/Logger'; +import picker from '@ohos.file.picker'; +import { CryptoOperation } from '../cryptoframework/CryptoOperation'; +import TextFileManager from '../textfilemanager/TextFileManager'; +import common from '@ohos.app.ability.common'; + +const TAG: string = '[Crypto_Framework]'; + +@Component +export struct Decrypt { + @State keyFileName: string = ''; + @State keyFileUri: string = ''; + @State textFileUri: string = ''; + @State textFileName: string = ''; + @State keyString: string = ''; + @State cipherText: string = ''; + @State plainText: string = ''; + @State message: string = ''; + @State decryptedFileUri: string = ''; + private CryptoOperation: CryptoOperation = new CryptoOperation(); + + build() { + Stack({ alignContent: Alignment.Center }) { + Column() { + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + List() { + ListItem() { + Row() { + Text($r('app.string.open_file')) + .fontSize(16) + .textAlign(TextAlign.Start) + .lineHeight(22) + + Blank() + + Text(this.textFileName === '' ? $r('app.string.please_choose') : this.textFileName) + .fontSize(14) + .textAlign(TextAlign.Start) + .lineHeight(19) + + Image($r('app.media.right_arrow')) + .height('19vp') + .width('10vp') + .margin({ left: 9, right: 9, top: 6, bottom: 6 }) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('52vp') + .padding({ top: 4, left: 12, right: 12 }) + }.onClick(() => { + this.selectTextFileAndRead(); + }) + + ListItem() { + Row() { + Text($r('app.string.select_key_file')) + .fontSize(16) + .textAlign(TextAlign.Start) + .lineHeight(22) + + Blank() + + Text(this.keyFileName === '' ? $r('app.string.please_choose') : this.keyFileName) + .fontSize(14) + .textAlign(TextAlign.Start) + .lineHeight(19) + + Image($r('app.media.right_arrow')) + .height('19vp') + .width('10vp') + .margin({ left: 9, right: 9, top: 6, bottom: 6 }) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('48vp') + .padding({ left: 12, right: 12 }) + }.onClick(() => { + this.selectAesKeyFileAndRead(); + }) + } + .width('100%') + .height('100%') + .borderRadius(16) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Row() { + Text($r('app.string.text_context')) + .fontSize(16) + .textAlign(TextAlign.Start) + .fontWeight(500) + .lineHeight(22) + } + .padding({ left: 12, right: 12 }) + .width('100%') + .height('48vp') + + Row() { + Text() { + Span(this.cipherText) + .fontSize(16) + .fontWeight(400) + .fontColor('#182431') + }.textAlign(TextAlign.Start) + } + .padding({ left: 12, right: 12, bottom: 4 }) + .width('100%') + .height('52vp') + } + .borderRadius(16) + .width('100%') + .height('100') + .backgroundColor(0xFFFFFF) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Row() { + Text($r('app.string.decrypted_context')) + .fontSize(16) + .textAlign(TextAlign.Start) + .fontWeight(500) + .lineHeight(22) + } + .padding({ left: 12, right: 12 }) + .width('100%') + .height('48vp') + + Row() { + Text() { + Span(this.plainText) + .fontSize(16) + .fontWeight(400) + .fontColor('#182431') + }.textAlign(TextAlign.Start) + } + .padding({ left: 12, right: 12, bottom: 4 }) + .width('100%') + .height('52vp') + } + .borderRadius(16) + .width('100%') + .height('100') + .backgroundColor(0xFFFFFF) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + Column() { + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Column() { + Button() { + Text($r('app.string.decrypt')).fontSize(16).fontWeight(500) + .lineHeight(22) + .fontColor('#FFFFFF') + } + .borderRadius(20) + .id('decryptionBtn') + .type(ButtonType.Capsule) + .margin({ left: 24, right: 24 }) + .width('100%') + .height('40vp') + .backgroundColor('#007DFF') + .onClick(() => { + if (this.textFileUri === '' || this.keyFileUri === '') { + promptAction.showToast({ + message: $r('app.string.null_message') + }); + } else { + this.decryptFunc(); + } + }); + } + } + }.margin({ left: 24, right: 24 }) + }.width('100%').height('296vp').justifyContent(FlexAlign.End) + } + .width('100%') + .height('100%') + } + } + + async selectAesKeyFileAndRead() { + let config = { + action: 'ohos.want.action.OPEN_FILE', + parameters: { + startMode: 'choose', + } + } + let context = getContext(this) as common.UIAbilityContext; + let result = await context.startAbilityForResult(config); + if (result === null || result === undefined) { + Logger.error(TAG, `result is null or undefined!`); + return; + } + if (result.resultCode !== 0) { + Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); + return; + } + if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { + Logger.error(TAG, `result uri is null or undefined!`); + return; + } + if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { + Logger.error(TAG, `result file name is null or undefined!`); + return; + } + // 获取到密钥文档文件的URI + this.keyFileUri = result.want.parameters.select_item_list.toString(); + // 获取到密钥文档文件的文件名称 + this.keyFileName = result.want.parameters.file_name_list.toString(); + await TextFileManager.readTextFile(this.keyFileUri); + this.keyString = TextFileManager.getString(); + } + + async selectTextFileAndRead() { + let config = { + action: 'ohos.want.action.OPEN_FILE', + parameters: { + startMode: 'choose', + } + } + let context = getContext(this) as common.UIAbilityContext; + let result = await context.startAbilityForResult(config); + if (result === null || result === undefined) { + Logger.error(TAG, `result is null or undefined!`); + return; + } + if (result.resultCode !== 0) { + Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); + return; + } + if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { + Logger.error(TAG, `result uri is null or undefined!`); + return; + } + if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { + Logger.error(TAG, `result file name is null or undefined!`); + return; + } + // 获取到文档文件的URI + this.textFileUri = result.want.parameters.select_item_list.toString(); + // 获取到文档文件的文件名称 + this.textFileName = result.want.parameters.file_name_list.toString(); + await TextFileManager.readTextFile(this.textFileUri); + this.cipherText = TextFileManager.getString(); + } + + async createTextFileAndWrite() { + let documentSaveOptions = new picker.DocumentSaveOptions(); + documentSaveOptions.newFileNames = ['plainText.txt']; + let documentPicker = new picker.DocumentViewPicker(); + let documentSaveResult = await documentPicker.save(documentSaveOptions); + this.decryptedFileUri = documentSaveResult[0]; + await TextFileManager.writeTextFile(this.decryptedFileUri, this.plainText); + } + + async decryptFunc() { + if (this.cipherText === '' || this.keyFileUri === '') { + promptAction.showToast({ + message: $r('app.string.null_message') + }); + return; + } + try { + this.plainText = await this.CryptoOperation.aesConvertAndDecrypt(this.keyString, this.cipherText); + } catch (error) { + Logger.error(TAG, `decrypt failed, ${error.code}, ${error.message}`); + promptAction.showToast({ + message: $r('app.string.decrypt_fail') + }); + return; + } + if (this.plainText === '' || this.plainText === null || this.plainText === undefined) { + promptAction.showToast({ + message: $r('app.string.decrypt_fail') + }); + return; + } else { + try { + await this.createTextFileAndWrite(); + } catch (error) { + Logger.error(TAG, `decrypt failed, ${error.code}, ${error.message}`); + } + } + if (this.decryptedFileUri === '' || typeof (this.decryptedFileUri) == 'undefined') { + promptAction.showToast({ + message: $r('app.string.decrypt_fail') + }); + } else { + promptAction.showToast({ + message: $r('app.string.decrypt_success') + }); + } + } +} diff --git a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Encrypt.ets b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Encrypt.ets index 48788fceeb..ebccaae38e 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Encrypt.ets +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Encrypt.ets @@ -1,381 +1,381 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import promptAction from '@ohos.promptAction'; -import Logger from '../util/Logger'; -import picker from '@ohos.file.picker'; -import { CryptoOperation } from '../cryptoframework/CryptoOperation'; -import TextFileManager from '../textfilemanager/TextFileManager'; -import common from '@ohos.app.ability.common'; - -const TAG: string = '[Crypto_Framework]'; - -@Component -export struct Encrypt { - @State keyFileName: string = ''; - @State keyFileUri: string = ''; - @State textFileUri: string = ''; - @State textFileName: string = ''; - @State keyString: string = ''; - @State cipherText: string = ''; - @State plainText: string = ''; - @State message: string = ''; - @State createKeyUri: string = ''; - @State encryptedFileUri: string = ''; - private CryptoOperation: CryptoOperation = new CryptoOperation(); - - build() { - Stack({ alignContent: Alignment.Center }) { - Column() { - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - List() { - ListItem() { - Row() { - Text($r('app.string.open_file')) - .fontSize(16) - .textAlign(TextAlign.Start) - .lineHeight(22) - - Blank() - - Text(this.textFileName === '' ? $r('app.string.please_choose') : this.textFileName) - .fontSize(14) - .textAlign(TextAlign.Start) - .lineHeight(19) - - Image($r('app.media.right_arrow')) - .height('19vp') - .width('10vp') - .margin({ left: 9, right: 9, top: 6, bottom: 6 }) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('52vp') - .padding({ top: 4, left: 12, right: 12 }) - }.onClick(() => { - this.selectTextFileAndRead(); - }) - - ListItem() { - Row() { - Text($r('app.string.select_key_file')) - .fontSize(16) - .textAlign(TextAlign.Start) - .lineHeight(22) - - Blank() - - Text(this.keyFileName === '' ? $r('app.string.please_choose') : this.keyFileName) - .fontSize(14) - .textAlign(TextAlign.Start) - .lineHeight(19) - - Image($r('app.media.right_arrow')) - .height('19vp') - .width('10vp') - .margin({ left: 9, right: 9, top: 6, bottom: 6 }) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('48vp') - .padding({ left: 12, right: 12 }) - }.onClick(() => { - this.selectAesKeyFileAndRead(); - }) - } - .width('100%') - .height('100%') - .borderRadius(16) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Column() { - Row() { - Text($r('app.string.text_context')) - .fontSize(16) - .textAlign(TextAlign.Start) - .fontWeight(500) - .lineHeight(22) - } - .padding({ left: 12, right: 12 }) - .width('100%') - .height('48vp') - - Row() { - Text() { - Span(this.plainText) - .fontSize(16) - .fontWeight(400) - .fontColor('#182431') - }.textAlign(TextAlign.Start) - } - .padding({ left: 12, right: 12, bottom: 4 }) - .width('100%') - .height('52vp') - } - .borderRadius(16) - .width('100%') - .height('100') - .backgroundColor(0xFFFFFF) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Column() { - Row() { - Text($r('app.string.encrypted_context')) - .fontSize(16) - .textAlign(TextAlign.Start) - .fontWeight(500) - .lineHeight(22) - } - .padding({ left: 12, right: 12 }) - .width('100%') - .height('48vp') - - Row() { - Text() { - Span(this.cipherText) - .fontSize(16) - .fontWeight(400) - .fontColor('#182431') - }.textAlign(TextAlign.Start) - } - .padding({ left: 12, right: 12, bottom: 4 }) - .width('100%') - .height('52vp') - } - .borderRadius(16) - .width('100%') - .height('100') - .backgroundColor(0xFFFFFF) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - Column() { - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Column() { - Button() { - Text($r('app.string.generate_aes_key_randomly')).fontSize(16).fontWeight(500) - .lineHeight(22) - .fontColor('#FFFFFF') - } - .id('encryptAesGenKey') - .borderRadius(20) - .type(ButtonType.Capsule) - .width('100%') - .height('40vp') - .margin({ bottom: 16 }) - .backgroundColor('#007DFF') - .onClick(() => { - this.genAesKey(); - }); - - Button() { - Text($r('app.string.encrypt')).fontSize(16).fontWeight(500) - .lineHeight(22) - .fontColor('#FFFFFF') - } - .borderRadius(20) - .id('encryptionBtn') - .type(ButtonType.Capsule) - .margin({ left: 24, right: 24 }) - .width('100%') - .height('40vp') - .backgroundColor('#007DFF') - .onClick(() => { - if (this.textFileUri === '' || this.keyFileUri === '') { - promptAction.showToast({ - message: $r('app.string.null_message') - }); - } else { - this.encryptFunc(); - } - }); - } - } - }.margin({ left: 24, right: 24 }) - }.width('100%').height('296vp').justifyContent(FlexAlign.End) - } - .width('100%') - .height('100%') - } - } - - async selectAesKeyFileAndRead() { - let config = { - action: 'ohos.want.action.OPEN_FILE', - parameters: { - startMode: 'choose', - } - } - let context = getContext(this) as common.UIAbilityContext; - let result = await context.startAbilityForResult(config); - if (result === null || result === undefined) { - Logger.error(TAG, `result is null or undefined!`); - return; - } - if (result.resultCode !== 0) { - Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); - return; - } - if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { - Logger.error(TAG, `result uri is null or undefined!`); - return; - } - if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { - Logger.error(TAG, `result file name is null or undefined!`); - return; - } - // 获取到密钥文档文件的URI - this.keyFileUri = result.want.parameters.select_item_list.toString(); - // 获取到密钥文档文件的文件名称 - this.keyFileName = result.want.parameters.file_name_list.toString(); - await TextFileManager.readTextFile(this.keyFileUri); - this.keyString = TextFileManager.getString(); - } - - async selectTextFileAndRead() { - let config = { - action: 'ohos.want.action.OPEN_FILE', - parameters: { - startMode: 'choose', - } - } - let context = getContext(this) as common.UIAbilityContext; - let result = await context.startAbilityForResult(config); - if (result.resultCode !== 0) { - Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); - return; - } - if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { - Logger.error(TAG, `result uri is null or undefined!`); - return; - } - if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { - Logger.error(TAG, `result file name is null or undefined!`); - return; - } - // 获取到文档文件的URI - this.textFileUri = result.want.parameters.select_item_list.toString(); - // 获取到文档文件的文件名称 - this.textFileName = result.want.parameters.file_name_list.toString(); - await TextFileManager.readTextFile(this.textFileUri); - this.plainText = TextFileManager.getString(); - } - - async createTextFileAndWrite() { - let documentSaveOptions = new picker.DocumentSaveOptions(); - documentSaveOptions.newFileNames = ['cipherText.txt']; - let documentPicker = new picker.DocumentViewPicker(); - let documentSaveResult = await documentPicker.save(documentSaveOptions); - this.encryptedFileUri = documentSaveResult[0]; - await TextFileManager.writeTextFile(this.encryptedFileUri, this.cipherText); - } - - async createKeyFileAndWrite() { - let documentSaveOptions = new picker.DocumentSaveOptions(); - documentSaveOptions.newFileNames = ['aesKey.txt']; - let documentPicker = new picker.DocumentViewPicker(); - let documentSaveResult = await documentPicker.save(documentSaveOptions); - this.createKeyUri = documentSaveResult[0]; - await TextFileManager.writeTextFile(this.createKeyUri, this.keyString); - } - - async encryptFunc() { - if (this.plainText === '' || this.keyFileUri === '') { - promptAction.showToast({ - message: $r('app.string.null_message') - }); - return; - } - try { - this.cipherText = await this.CryptoOperation.aesConvertAndEncrypt(this.keyString, this.plainText); - } catch (error) { - Logger.error(TAG, `encrypt failed, ${error.code}, ${error.message}`); - promptAction.showToast({ - message: $r('app.string.encrypt_fail') - }); - } - if (this.cipherText === '' || this.cipherText === undefined || this.cipherText === null) { - promptAction.showToast({ - message: $r('app.string.encrypt_fail') - }); - return; - } else { - try { - await this.createTextFileAndWrite(); - } catch (error) { - Logger.error(TAG, `encrypt failed, ${error.code}, ${error.message}`); - } - } - if (this.encryptedFileUri === '' || typeof (this.encryptedFileUri) == 'undefined') { - promptAction.showToast({ - message: $r('app.string.encrypt_fail') - }); - } else { - promptAction.showToast({ - message: $r('app.string.encrypt_success') - }); - } - } - - async genAesKey() { - try { - this.keyString = await this.CryptoOperation.generateAesKey(); - } catch (error) { - Logger.error(TAG, `gen aes key failed, ${error.code}, ${error.message}`); - } - if (this.keyString === '' || typeof (this.keyString) == 'undefined') { - promptAction.showToast({ - message: $r('app.string.gen_key_fail') - }); - return; - } else { - try { - await this.createKeyFileAndWrite(); - } catch (error) { - Logger.error(TAG, `write aes key failed, ${error.code}, ${error.message}`); - } - } - if (this.createKeyUri === '' || typeof (this.createKeyUri) == 'undefined') { - promptAction.showToast({ - message: $r('app.string.gen_key_fail') - }); - } else { - promptAction.showToast({ - message: $r('app.string.gen_key_success') - }); - } - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import promptAction from '@ohos.promptAction'; +import Logger from '../util/Logger'; +import picker from '@ohos.file.picker'; +import { CryptoOperation } from '../cryptoframework/CryptoOperation'; +import TextFileManager from '../textfilemanager/TextFileManager'; +import common from '@ohos.app.ability.common'; + +const TAG: string = '[Crypto_Framework]'; + +@Component +export struct Encrypt { + @State keyFileName: string = ''; + @State keyFileUri: string = ''; + @State textFileUri: string = ''; + @State textFileName: string = ''; + @State keyString: string = ''; + @State cipherText: string = ''; + @State plainText: string = ''; + @State message: string = ''; + @State createKeyUri: string = ''; + @State encryptedFileUri: string = ''; + private CryptoOperation: CryptoOperation = new CryptoOperation(); + + build() { + Stack({ alignContent: Alignment.Center }) { + Column() { + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + List() { + ListItem() { + Row() { + Text($r('app.string.open_file')) + .fontSize(16) + .textAlign(TextAlign.Start) + .lineHeight(22) + + Blank() + + Text(this.textFileName === '' ? $r('app.string.please_choose') : this.textFileName) + .fontSize(14) + .textAlign(TextAlign.Start) + .lineHeight(19) + + Image($r('app.media.right_arrow')) + .height('19vp') + .width('10vp') + .margin({ left: 9, right: 9, top: 6, bottom: 6 }) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('52vp') + .padding({ top: 4, left: 12, right: 12 }) + }.onClick(() => { + this.selectTextFileAndRead(); + }) + + ListItem() { + Row() { + Text($r('app.string.select_key_file')) + .fontSize(16) + .textAlign(TextAlign.Start) + .lineHeight(22) + + Blank() + + Text(this.keyFileName === '' ? $r('app.string.please_choose') : this.keyFileName) + .fontSize(14) + .textAlign(TextAlign.Start) + .lineHeight(19) + + Image($r('app.media.right_arrow')) + .height('19vp') + .width('10vp') + .margin({ left: 9, right: 9, top: 6, bottom: 6 }) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('48vp') + .padding({ left: 12, right: 12 }) + }.onClick(() => { + this.selectAesKeyFileAndRead(); + }) + } + .width('100%') + .height('100%') + .borderRadius(16) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Row() { + Text($r('app.string.text_context')) + .fontSize(16) + .textAlign(TextAlign.Start) + .fontWeight(500) + .lineHeight(22) + } + .padding({ left: 12, right: 12 }) + .width('100%') + .height('48vp') + + Row() { + Text() { + Span(this.plainText) + .fontSize(16) + .fontWeight(400) + .fontColor('#182431') + }.textAlign(TextAlign.Start) + } + .padding({ left: 12, right: 12, bottom: 4 }) + .width('100%') + .height('52vp') + } + .borderRadius(16) + .width('100%') + .height('100') + .backgroundColor(0xFFFFFF) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Row() { + Text($r('app.string.encrypted_context')) + .fontSize(16) + .textAlign(TextAlign.Start) + .fontWeight(500) + .lineHeight(22) + } + .padding({ left: 12, right: 12 }) + .width('100%') + .height('48vp') + + Row() { + Text() { + Span(this.cipherText) + .fontSize(16) + .fontWeight(400) + .fontColor('#182431') + }.textAlign(TextAlign.Start) + } + .padding({ left: 12, right: 12, bottom: 4 }) + .width('100%') + .height('52vp') + } + .borderRadius(16) + .width('100%') + .height('100') + .backgroundColor(0xFFFFFF) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + Column() { + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Column() { + Button() { + Text($r('app.string.generate_aes_key_randomly')).fontSize(16).fontWeight(500) + .lineHeight(22) + .fontColor('#FFFFFF') + } + .id('encryptAesGenKey') + .borderRadius(20) + .type(ButtonType.Capsule) + .width('100%') + .height('40vp') + .margin({ bottom: 16 }) + .backgroundColor('#007DFF') + .onClick(() => { + this.genAesKey(); + }); + + Button() { + Text($r('app.string.encrypt')).fontSize(16).fontWeight(500) + .lineHeight(22) + .fontColor('#FFFFFF') + } + .borderRadius(20) + .id('encryptionBtn') + .type(ButtonType.Capsule) + .margin({ left: 24, right: 24 }) + .width('100%') + .height('40vp') + .backgroundColor('#007DFF') + .onClick(() => { + if (this.textFileUri === '' || this.keyFileUri === '') { + promptAction.showToast({ + message: $r('app.string.null_message') + }); + } else { + this.encryptFunc(); + } + }); + } + } + }.margin({ left: 24, right: 24 }) + }.width('100%').height('296vp').justifyContent(FlexAlign.End) + } + .width('100%') + .height('100%') + } + } + + async selectAesKeyFileAndRead() { + let config = { + action: 'ohos.want.action.OPEN_FILE', + parameters: { + startMode: 'choose', + } + } + let context = getContext(this) as common.UIAbilityContext; + let result = await context.startAbilityForResult(config); + if (result === null || result === undefined) { + Logger.error(TAG, `result is null or undefined!`); + return; + } + if (result.resultCode !== 0) { + Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); + return; + } + if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { + Logger.error(TAG, `result uri is null or undefined!`); + return; + } + if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { + Logger.error(TAG, `result file name is null or undefined!`); + return; + } + // 获取到密钥文档文件的URI + this.keyFileUri = result.want.parameters.select_item_list.toString(); + // 获取到密钥文档文件的文件名称 + this.keyFileName = result.want.parameters.file_name_list.toString(); + await TextFileManager.readTextFile(this.keyFileUri); + this.keyString = TextFileManager.getString(); + } + + async selectTextFileAndRead() { + let config = { + action: 'ohos.want.action.OPEN_FILE', + parameters: { + startMode: 'choose', + } + } + let context = getContext(this) as common.UIAbilityContext; + let result = await context.startAbilityForResult(config); + if (result.resultCode !== 0) { + Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); + return; + } + if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { + Logger.error(TAG, `result uri is null or undefined!`); + return; + } + if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { + Logger.error(TAG, `result file name is null or undefined!`); + return; + } + // 获取到文档文件的URI + this.textFileUri = result.want.parameters.select_item_list.toString(); + // 获取到文档文件的文件名称 + this.textFileName = result.want.parameters.file_name_list.toString(); + await TextFileManager.readTextFile(this.textFileUri); + this.plainText = TextFileManager.getString(); + } + + async createTextFileAndWrite() { + let documentSaveOptions = new picker.DocumentSaveOptions(); + documentSaveOptions.newFileNames = ['cipherText.txt']; + let documentPicker = new picker.DocumentViewPicker(); + let documentSaveResult = await documentPicker.save(documentSaveOptions); + this.encryptedFileUri = documentSaveResult[0]; + await TextFileManager.writeTextFile(this.encryptedFileUri, this.cipherText); + } + + async createKeyFileAndWrite() { + let documentSaveOptions = new picker.DocumentSaveOptions(); + documentSaveOptions.newFileNames = ['aesKey.txt']; + let documentPicker = new picker.DocumentViewPicker(); + let documentSaveResult = await documentPicker.save(documentSaveOptions); + this.createKeyUri = documentSaveResult[0]; + await TextFileManager.writeTextFile(this.createKeyUri, this.keyString); + } + + async encryptFunc() { + if (this.plainText === '' || this.keyFileUri === '') { + promptAction.showToast({ + message: $r('app.string.null_message') + }); + return; + } + try { + this.cipherText = await this.CryptoOperation.aesConvertAndEncrypt(this.keyString, this.plainText); + } catch (error) { + Logger.error(TAG, `encrypt failed, ${error.code}, ${error.message}`); + promptAction.showToast({ + message: $r('app.string.encrypt_fail') + }); + } + if (this.cipherText === '' || this.cipherText === undefined || this.cipherText === null) { + promptAction.showToast({ + message: $r('app.string.encrypt_fail') + }); + return; + } else { + try { + await this.createTextFileAndWrite(); + } catch (error) { + Logger.error(TAG, `encrypt failed, ${error.code}, ${error.message}`); + } + } + if (this.encryptedFileUri === '' || typeof (this.encryptedFileUri) == 'undefined') { + promptAction.showToast({ + message: $r('app.string.encrypt_fail') + }); + } else { + promptAction.showToast({ + message: $r('app.string.encrypt_success') + }); + } + } + + async genAesKey() { + try { + this.keyString = await this.CryptoOperation.generateAesKey(); + } catch (error) { + Logger.error(TAG, `gen aes key failed, ${error.code}, ${error.message}`); + } + if (this.keyString === '' || typeof (this.keyString) == 'undefined') { + promptAction.showToast({ + message: $r('app.string.gen_key_fail') + }); + return; + } else { + try { + await this.createKeyFileAndWrite(); + } catch (error) { + Logger.error(TAG, `write aes key failed, ${error.code}, ${error.message}`); + } + } + if (this.createKeyUri === '' || typeof (this.createKeyUri) == 'undefined') { + promptAction.showToast({ + message: $r('app.string.gen_key_fail') + }); + } else { + promptAction.showToast({ + message: $r('app.string.gen_key_success') + }); + } + } +} + diff --git a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Sign.ets b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Sign.ets index bc0fd76d69..a446d7af3a 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Sign.ets +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Sign.ets @@ -1,352 +1,352 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import promptAction from '@ohos.promptAction'; -import Logger from '../util/Logger'; -import picker from '@ohos.file.picker'; -import { CryptoOperation } from '../cryptoframework/CryptoOperation'; -import TextFileManager from '../textfilemanager/TextFileManager'; -import common from '@ohos.app.ability.common'; - -const TAG: string = '[Crypto_Framework]'; - -@Component -export struct Sign { - @State keyFileName: string = ''; - @State keyFileUri: string = ''; - @State textFileUri: string = ''; - @State textFileName: string = ''; - @State keyString: string = ''; - @State cipherText: string = ''; - @State plainText: string = ''; - @State message: string = ''; - @State signFileUri: string = ''; - @State createKeyUri: string = ''; - private CryptoOperation: CryptoOperation = new CryptoOperation(); - - build() { - Stack({ alignContent: Alignment.Center }) { - Column() { - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - List() { - ListItem() { - Row() { - Text($r('app.string.open_file')) - .fontSize(16) - .textAlign(TextAlign.Start) - .lineHeight(22) - - Blank() - - Text(this.textFileName === '' ? $r('app.string.please_choose') : this.textFileName) - .fontSize(14) - .textAlign(TextAlign.Start) - .lineHeight(19) - - Image($r('app.media.right_arrow')) - .height('19vp') - .width('10vp') - .margin({ left: 9, right: 9, top: 6, bottom: 6 }) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('52vp') - .padding({ top: 4, left: 12, right: 12 }) - }.onClick(() => { - this.selectTextFileAndRead(); - }) - - ListItem() { - Row() { - Text($r('app.string.select_key_file')) - .fontSize(16) - .textAlign(TextAlign.Start) - .lineHeight(22) - - Blank() - - Text(this.keyFileName === '' ? $r('app.string.please_choose') : this.keyFileName) - .fontSize(14) - .textAlign(TextAlign.Start) - .lineHeight(19) - - Image($r('app.media.right_arrow')) - .height('19vp') - .width('10vp') - .margin({ left: 9, right: 9, top: 6, bottom: 6 }) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('48vp') - .padding({ left: 12, right: 12 }) - }.onClick(() => { - this.selectRsaKeyFileAndRead(); - }) - } - .width('100%') - .height('100%') - .borderRadius(16) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Column() { - Row() { - Text($r('app.string.text_context')) - .fontSize(16) - .textAlign(TextAlign.Start) - .fontWeight(500) - .lineHeight(22) - } - .padding({ left: 12, right: 12 }) - .width('100%') - .height('48vp') - - Row() { - Text() { - Span(this.plainText) - .fontSize(16) - .fontWeight(400) - .fontColor('#182431') - }.textAlign(TextAlign.Start) - } - .padding({ left: 12, right: 12, bottom: 4 }) - .width('100%') - .height('52vp') - } - .borderRadius(16) - .width('100%') - .height('100') - .backgroundColor(0xFFFFFF) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - Column() { - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Column() { - Button() { - Text($r('app.string.generate_rsa_key_randomly')).fontSize(16).fontWeight(500) - .lineHeight(22) - .fontColor('#FFFFFF') - } - .id('encryptRsaGenKey') - .borderRadius(20) - .type(ButtonType.Capsule) - .width('100%') - .height('40vp') - .margin({ bottom: 16 }) - .backgroundColor('#007DFF') - .onClick(() => { - this.genRsaKey(); - }); - - Button() { - Text($r('app.string.sign')).fontSize(16).fontWeight(500) - .lineHeight(22) - .fontColor('#FFFFFF') - } - .borderRadius(20) - .id('signBtn') - .type(ButtonType.Capsule) - .margin({ left: 24, right: 24 }) - .width('100%') - .height('40vp') - .backgroundColor('#007DFF') - .onClick(() => { - if (this.textFileUri === '' || this.keyFileUri === '') { - promptAction.showToast({ - message: $r('app.string.null_message') - }); - } else { - this.signFunc(); - } - }); - } - } - }.margin({ left: 24, right: 24 }) - }.width('100%').height('412vp').justifyContent(FlexAlign.End) - } - .width('100%') - .height('100%') - } - } - - async selectRsaKeyFileAndRead() { - let config = { - action: 'ohos.want.action.OPEN_FILE', - parameters: { - startMode: 'choose', - } - } - let context = getContext(this) as common.UIAbilityContext; - let result = await context.startAbilityForResult(config); - if (result === null || result === undefined) { - Logger.error(TAG, `result is null or undefined!`); - return; - } - if (result.resultCode !== 0) { - Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); - return; - } - if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { - Logger.error(TAG, `result uri is null or undefined!`); - return; - } - if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { - Logger.error(TAG, `result file name is null or undefined!`); - return; - } - // 获取到密钥文档文件的URI - this.keyFileUri = result.want.parameters.select_item_list.toString(); - // 获取到密钥文档文件的文件名称 - this.keyFileName = result.want.parameters.file_name_list.toString(); - await TextFileManager.readTextFile(this.keyFileUri); - this.keyString = TextFileManager.getString(); - } - - async selectTextFileAndRead() { - let config = { - action: 'ohos.want.action.OPEN_FILE', - parameters: { - startMode: 'choose', - } - } - let context = getContext(this) as common.UIAbilityContext; - let result = await context.startAbilityForResult(config); - if (result === null || result === undefined) { - Logger.error(TAG, `result is null or undefined!`); - return; - } - if (result.resultCode !== 0) { - Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); - return; - } - if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { - Logger.error(TAG, `result uri is null or undefined!`); - return; - } - if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { - Logger.error(TAG, `result file name is null or undefined!`); - return; - } - // 获取到文档文件的URI - this.textFileUri = result.want.parameters.select_item_list.toString(); - // 获取到文档文件的文件名称 - this.textFileName = result.want.parameters.file_name_list.toString(); - await TextFileManager.readTextFile(this.textFileUri); - this.plainText = TextFileManager.getString(); - } - - async createTextFileAndWrite() { - let documentSaveOptions = new picker.DocumentSaveOptions(); - documentSaveOptions.newFileNames = ['signText.txt']; - let documentPicker = new picker.DocumentViewPicker(); - let documentSaveResult = await documentPicker.save(documentSaveOptions); - this.signFileUri = documentSaveResult[0]; - await TextFileManager.writeTextFile(this.signFileUri, this.cipherText); - } - - async createKeyFileAndWrite() { - let documentSaveOptions = new picker.DocumentSaveOptions(); - documentSaveOptions.newFileNames = ['rsaKey.txt']; - let documentPicker = new picker.DocumentViewPicker(); - try { - let documentSaveResult = await documentPicker.save(documentSaveOptions); - this.createKeyUri = documentSaveResult[0]; - await TextFileManager.writeTextFile(this.createKeyUri, this.keyString); - } catch (error) { - Logger.error(TAG, `save key failed, ${error.code}, ${error.message}`); - } - - } - - async signFunc() { - if (this.plainText === '' || this.keyFileUri === '') { - promptAction.showToast({ - message: $r('app.string.null_message') - }); - return; - } - try { - this.cipherText = await this.CryptoOperation.rsaConvertAndSign(this.keyString, this.plainText); - } catch (error) { - promptAction.showToast({ - message: $r('app.string.sign_fail') - }); - Logger.error(TAG, `sign failed, ${error.code}, ${error.message}`); - } - if (this.cipherText === '' || this.cipherText === null || this.cipherText === undefined) { - promptAction.showToast({ - message: $r('app.string.sign_fail') - }); - return; - } else { - await this.createTextFileAndWrite(); - } - if (this.signFileUri === '' || typeof (this.signFileUri) == 'undefined') { - promptAction.showToast({ - message: $r('app.string.sign_fail') - }); - } else { - promptAction.showToast({ - message: $r('app.string.sign_success') - }); - } - } - - async genRsaKey() { - promptAction.showToast({ - message: $r('app.string.slow_rsa_key_gen') - }); - try { - this.keyString = await this.CryptoOperation.generateRsaKey(); - } catch (error) { - Logger.error(TAG, `gen rsa key failed, ${error.code}, ${error.message}`); - } - if (this.keyString === '' || typeof (this.keyString) == 'undefined') { - promptAction.showToast({ - message: $r('app.string.gen_key_fail') - }); - return; - } else { - try { - await this.createKeyFileAndWrite(); - } catch (error) { - Logger.error(TAG, `write rsa key failed, ${error.code}, ${error.message}`); - } - } - if (this.createKeyUri === '' || typeof (this.createKeyUri) == 'undefined') { - promptAction.showToast({ - message: $r('app.string.gen_key_fail') - }); - } else { - promptAction.showToast({ - message: $r('app.string.gen_key_success') - }); - } - - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import promptAction from '@ohos.promptAction'; +import Logger from '../util/Logger'; +import picker from '@ohos.file.picker'; +import { CryptoOperation } from '../cryptoframework/CryptoOperation'; +import TextFileManager from '../textfilemanager/TextFileManager'; +import common from '@ohos.app.ability.common'; + +const TAG: string = '[Crypto_Framework]'; + +@Component +export struct Sign { + @State keyFileName: string = ''; + @State keyFileUri: string = ''; + @State textFileUri: string = ''; + @State textFileName: string = ''; + @State keyString: string = ''; + @State cipherText: string = ''; + @State plainText: string = ''; + @State message: string = ''; + @State signFileUri: string = ''; + @State createKeyUri: string = ''; + private CryptoOperation: CryptoOperation = new CryptoOperation(); + + build() { + Stack({ alignContent: Alignment.Center }) { + Column() { + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + List() { + ListItem() { + Row() { + Text($r('app.string.open_file')) + .fontSize(16) + .textAlign(TextAlign.Start) + .lineHeight(22) + + Blank() + + Text(this.textFileName === '' ? $r('app.string.please_choose') : this.textFileName) + .fontSize(14) + .textAlign(TextAlign.Start) + .lineHeight(19) + + Image($r('app.media.right_arrow')) + .height('19vp') + .width('10vp') + .margin({ left: 9, right: 9, top: 6, bottom: 6 }) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('52vp') + .padding({ top: 4, left: 12, right: 12 }) + }.onClick(() => { + this.selectTextFileAndRead(); + }) + + ListItem() { + Row() { + Text($r('app.string.select_key_file')) + .fontSize(16) + .textAlign(TextAlign.Start) + .lineHeight(22) + + Blank() + + Text(this.keyFileName === '' ? $r('app.string.please_choose') : this.keyFileName) + .fontSize(14) + .textAlign(TextAlign.Start) + .lineHeight(19) + + Image($r('app.media.right_arrow')) + .height('19vp') + .width('10vp') + .margin({ left: 9, right: 9, top: 6, bottom: 6 }) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('48vp') + .padding({ left: 12, right: 12 }) + }.onClick(() => { + this.selectRsaKeyFileAndRead(); + }) + } + .width('100%') + .height('100%') + .borderRadius(16) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Row() { + Text($r('app.string.text_context')) + .fontSize(16) + .textAlign(TextAlign.Start) + .fontWeight(500) + .lineHeight(22) + } + .padding({ left: 12, right: 12 }) + .width('100%') + .height('48vp') + + Row() { + Text() { + Span(this.plainText) + .fontSize(16) + .fontWeight(400) + .fontColor('#182431') + }.textAlign(TextAlign.Start) + } + .padding({ left: 12, right: 12, bottom: 4 }) + .width('100%') + .height('52vp') + } + .borderRadius(16) + .width('100%') + .height('100') + .backgroundColor(0xFFFFFF) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + Column() { + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Column() { + Button() { + Text($r('app.string.generate_rsa_key_randomly')).fontSize(16).fontWeight(500) + .lineHeight(22) + .fontColor('#FFFFFF') + } + .id('encryptRsaGenKey') + .borderRadius(20) + .type(ButtonType.Capsule) + .width('100%') + .height('40vp') + .margin({ bottom: 16 }) + .backgroundColor('#007DFF') + .onClick(() => { + this.genRsaKey(); + }); + + Button() { + Text($r('app.string.sign')).fontSize(16).fontWeight(500) + .lineHeight(22) + .fontColor('#FFFFFF') + } + .borderRadius(20) + .id('signBtn') + .type(ButtonType.Capsule) + .margin({ left: 24, right: 24 }) + .width('100%') + .height('40vp') + .backgroundColor('#007DFF') + .onClick(() => { + if (this.textFileUri === '' || this.keyFileUri === '') { + promptAction.showToast({ + message: $r('app.string.null_message') + }); + } else { + this.signFunc(); + } + }); + } + } + }.margin({ left: 24, right: 24 }) + }.width('100%').height('412vp').justifyContent(FlexAlign.End) + } + .width('100%') + .height('100%') + } + } + + async selectRsaKeyFileAndRead() { + let config = { + action: 'ohos.want.action.OPEN_FILE', + parameters: { + startMode: 'choose', + } + } + let context = getContext(this) as common.UIAbilityContext; + let result = await context.startAbilityForResult(config); + if (result === null || result === undefined) { + Logger.error(TAG, `result is null or undefined!`); + return; + } + if (result.resultCode !== 0) { + Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); + return; + } + if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { + Logger.error(TAG, `result uri is null or undefined!`); + return; + } + if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { + Logger.error(TAG, `result file name is null or undefined!`); + return; + } + // 获取到密钥文档文件的URI + this.keyFileUri = result.want.parameters.select_item_list.toString(); + // 获取到密钥文档文件的文件名称 + this.keyFileName = result.want.parameters.file_name_list.toString(); + await TextFileManager.readTextFile(this.keyFileUri); + this.keyString = TextFileManager.getString(); + } + + async selectTextFileAndRead() { + let config = { + action: 'ohos.want.action.OPEN_FILE', + parameters: { + startMode: 'choose', + } + } + let context = getContext(this) as common.UIAbilityContext; + let result = await context.startAbilityForResult(config); + if (result === null || result === undefined) { + Logger.error(TAG, `result is null or undefined!`); + return; + } + if (result.resultCode !== 0) { + Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); + return; + } + if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { + Logger.error(TAG, `result uri is null or undefined!`); + return; + } + if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { + Logger.error(TAG, `result file name is null or undefined!`); + return; + } + // 获取到文档文件的URI + this.textFileUri = result.want.parameters.select_item_list.toString(); + // 获取到文档文件的文件名称 + this.textFileName = result.want.parameters.file_name_list.toString(); + await TextFileManager.readTextFile(this.textFileUri); + this.plainText = TextFileManager.getString(); + } + + async createTextFileAndWrite() { + let documentSaveOptions = new picker.DocumentSaveOptions(); + documentSaveOptions.newFileNames = ['signText.txt']; + let documentPicker = new picker.DocumentViewPicker(); + let documentSaveResult = await documentPicker.save(documentSaveOptions); + this.signFileUri = documentSaveResult[0]; + await TextFileManager.writeTextFile(this.signFileUri, this.cipherText); + } + + async createKeyFileAndWrite() { + let documentSaveOptions = new picker.DocumentSaveOptions(); + documentSaveOptions.newFileNames = ['rsaKey.txt']; + let documentPicker = new picker.DocumentViewPicker(); + try { + let documentSaveResult = await documentPicker.save(documentSaveOptions); + this.createKeyUri = documentSaveResult[0]; + await TextFileManager.writeTextFile(this.createKeyUri, this.keyString); + } catch (error) { + Logger.error(TAG, `save key failed, ${error.code}, ${error.message}`); + } + + } + + async signFunc() { + if (this.plainText === '' || this.keyFileUri === '') { + promptAction.showToast({ + message: $r('app.string.null_message') + }); + return; + } + try { + this.cipherText = await this.CryptoOperation.rsaConvertAndSign(this.keyString, this.plainText); + } catch (error) { + promptAction.showToast({ + message: $r('app.string.sign_fail') + }); + Logger.error(TAG, `sign failed, ${error.code}, ${error.message}`); + } + if (this.cipherText === '' || this.cipherText === null || this.cipherText === undefined) { + promptAction.showToast({ + message: $r('app.string.sign_fail') + }); + return; + } else { + await this.createTextFileAndWrite(); + } + if (this.signFileUri === '' || typeof (this.signFileUri) == 'undefined') { + promptAction.showToast({ + message: $r('app.string.sign_fail') + }); + } else { + promptAction.showToast({ + message: $r('app.string.sign_success') + }); + } + } + + async genRsaKey() { + promptAction.showToast({ + message: $r('app.string.slow_rsa_key_gen') + }); + try { + this.keyString = await this.CryptoOperation.generateRsaKey(); + } catch (error) { + Logger.error(TAG, `gen rsa key failed, ${error.code}, ${error.message}`); + } + if (this.keyString === '' || typeof (this.keyString) == 'undefined') { + promptAction.showToast({ + message: $r('app.string.gen_key_fail') + }); + return; + } else { + try { + await this.createKeyFileAndWrite(); + } catch (error) { + Logger.error(TAG, `write rsa key failed, ${error.code}, ${error.message}`); + } + } + if (this.createKeyUri === '' || typeof (this.createKeyUri) == 'undefined') { + promptAction.showToast({ + message: $r('app.string.gen_key_fail') + }); + } else { + promptAction.showToast({ + message: $r('app.string.gen_key_success') + }); + } + + } +} diff --git a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Verify.ets b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Verify.ets index b273311c18..cd9ea39ee0 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Verify.ets +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/tab/Verify.ets @@ -1,358 +1,358 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import promptAction from '@ohos.promptAction'; -import Logger from '../util/Logger'; -import picker from '@ohos.file.picker'; -import { CryptoOperation } from '../cryptoframework/CryptoOperation'; -import TextFileManager from '../textfilemanager/TextFileManager'; -import common from '@ohos.app.ability.common'; - -const TAG: string = '[Crypto_Framework]'; - -@Component -export struct Verify { - @State keyFileName: string = ''; - @State keyFileUri: string = ''; - @State textFileUri: string = ''; - @State textFileName: string = ''; - @State keyString: string = ''; - @State plainText: string = ''; - @State message: string = ''; - @State signFileUri: string = ''; - @State signFileName: string = ''; - @State signText: string = ''; - @State createKeyUri: string = ''; - private CryptoOperation: CryptoOperation = new CryptoOperation(); - - build() { - Stack({ alignContent: Alignment.Center }) { - Column() { - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - List() { - ListItem() { - Row() { - Text($r('app.string.open_file')) - .fontSize(16) - .textAlign(TextAlign.Start) - .lineHeight(22) - - Blank() - - Text(this.textFileName === '' ? $r('app.string.please_choose') : this.textFileName) - .fontSize(14) - .textAlign(TextAlign.Start) - .lineHeight(19) - - Image($r('app.media.right_arrow')) - .height('19vp') - .width('10vp') - .margin({ left: 9, right: 9, top: 6, bottom: 6 }) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('52vp') - .padding({ top: 4, left: 12, right: 12 }) - }.onClick(() => { - this.selectTextFileAndRead(); - }) - - ListItem() { - Row() { - Text($r('app.string.select_key_file')) - .fontSize(16) - .textAlign(TextAlign.Start) - .lineHeight(22) - - Blank() - - Text(this.keyFileName === '' ? $r('app.string.please_choose') : this.keyFileName) - .fontSize(14) - .textAlign(TextAlign.Start) - .lineHeight(19) - - Image($r('app.media.right_arrow')) - .height('19vp') - .width('10vp') - .margin({ left: 9, right: 9, top: 6, bottom: 6 }) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('48vp') - .padding({ left: 12, right: 12 }) - }.onClick(() => { - this.selectRsaKeyFileAndRead(); - }) - } - .width('100%') - .height('100%') - .borderRadius(16) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - List() { - ListItem() { - Row() { - Text($r('app.string.select_signature_file')) - .fontSize(16) - .textAlign(TextAlign.Start) - .lineHeight(22) - - Blank() - - Text(this.signFileName === '' ? $r('app.string.please_choose') : this.signFileName) - .fontSize(14) - .textAlign(TextAlign.Start) - .lineHeight(19) - - Image($r('app.media.right_arrow')) - .height('19vp') - .width('10vp') - .margin({ left: 9, right: 9, top: 6, bottom: 6 }) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('56vp') - .padding({ left: 12, right: 12, top: 4, bottom: 4 }) - }.onClick(() => { - this.selectSignFileAndRead(); - }) - } - .width('100%') - .borderRadius(16) - } - } - } - .height('56vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Column() { - Row() { - Text($r('app.string.text_context')) - .fontSize(16) - .textAlign(TextAlign.Start) - .fontWeight(500) - .lineHeight(22) - } - .padding({ left: 12, right: 12 }) - .width('100%') - .height('48vp') - - Row() { - Text() { - Span(this.plainText) - .fontSize(16) - .fontWeight(400) - .fontColor('#182431') - }.textAlign(TextAlign.Start) - } - .padding({ left: 12, right: 12, bottom: 4 }) - .width('100%') - .height('52vp') - } - .borderRadius(16) - .width('100%') - .height('100') - .backgroundColor(0xFFFFFF) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - Column() { - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Column() { - Button() { - Text($r('app.string.verify')).fontSize(16).fontWeight(500) - .lineHeight(22) - .fontColor('#FFFFFF') - } - .borderRadius(20) - .id('verifyBtn') - .type(ButtonType.Capsule) - .margin({ left: 24, right: 24 }) - .width('100%') - .height('40vp') - .backgroundColor('#007DFF') - .onClick(() => { - if (this.textFileUri === '' || this.keyFileUri === '' || this.signFileUri === '') { - promptAction.showToast({ - message: $r('app.string.null_message') - }); - } else { - this.verifyFunc(); - } - }); - } - } - }.margin({ left: 24, right: 24 }) - }.width('100%').height('340vp').justifyContent(FlexAlign.End) - } - .width('100%') - .height('100%') - } - } - - async selectRsaKeyFileAndRead() { - let config = { - action: 'ohos.want.action.OPEN_FILE', - parameters: { - startMode: 'choose', - } - } - let context = getContext(this) as common.UIAbilityContext; - let result = await context.startAbilityForResult(config); - if (result === null || result === undefined) { - Logger.error(TAG, `result is null or undefined!`); - return; - } - if (result.resultCode !== 0) { - Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); - return; - } - if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { - Logger.error(TAG, `result uri is null or undefined!`); - return; - } - if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { - Logger.error(TAG, `result file name is null or undefined!`); - return; - } - // 获取到密钥文档文件的URI - this.keyFileUri = result.want.parameters.select_item_list.toString(); - // 获取到密钥文档文件的文件名称 - this.keyFileName = result.want.parameters.file_name_list.toString(); - await TextFileManager.readTextFile(this.keyFileUri); - this.keyString = TextFileManager.getString(); - } - - async selectTextFileAndRead() { - let config = { - action: 'ohos.want.action.OPEN_FILE', - parameters: { - startMode: 'choose', - } - } - let context = getContext(this) as common.UIAbilityContext; - let result = await context.startAbilityForResult(config); - if (result === null || result === undefined) { - Logger.error(TAG, `result is null or undefined!`); - return; - } - if (result.resultCode !== 0) { - Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); - return; - } - if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { - Logger.error(TAG, `result uri is null or undefined!`); - return; - } - if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { - Logger.error(TAG, `result file name is null or undefined!`); - return; - } - // 获取到文档文件的URI - this.textFileUri = result.want.parameters.select_item_list.toString(); - // 获取到文档文件的文件名称 - this.textFileName = result.want.parameters.file_name_list.toString(); - await TextFileManager.readTextFile(this.textFileUri); - this.plainText = TextFileManager.getString(); - } - - async selectSignFileAndRead() { - let config = { - action: 'ohos.want.action.OPEN_FILE', - parameters: { - startMode: 'choose', - } - } - let context = getContext(this) as common.UIAbilityContext; - let result = await context.startAbilityForResult(config); - if (result === null || result === undefined) { - Logger.error(TAG, `result is null or undefined!`); - return; - } - if (result.resultCode !== 0) { - Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); - return; - } - if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { - Logger.error(TAG, `result uri is null or undefined!`); - return; - } - if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { - Logger.error(TAG, `result file name is null or undefined!`); - return; - } - // 获取到文档文件的URI - this.signFileUri = result.want.parameters.select_item_list.toString(); - // 获取到文档文件的文件名称 - this.signFileName = result.want.parameters.file_name_list.toString(); - await TextFileManager.readTextFile(this.signFileUri); - this.signText = TextFileManager.getString(); - } - - async createKeyFileAndWrite() { - let documentSaveOptions = new picker.DocumentSaveOptions(); - documentSaveOptions.newFileNames = ['rsaKey.txt']; - let documentPicker = new picker.DocumentViewPicker(); - try { - let documentSaveResult = await documentPicker.save(documentSaveOptions); - this.createKeyUri = documentSaveResult[0]; - await TextFileManager.writeTextFile(this.createKeyUri, this.keyString); - } catch (error) { - Logger.error(TAG, `save key failed, ${error.code}, ${error.message}`); - } - - } - - async verifyFunc() { - let verifyRes; - if (this.plainText === '' || this.keyFileUri === '' || this.signText === '') { - promptAction.showToast({ - message: $r('app.string.null_message') - }); - return; - } - try { - verifyRes = await this.CryptoOperation.rsaConvertAndVerify(this.keyString, this.plainText, this.signText); - } catch (error) { - Logger.error(TAG, `verify failed, ${error.code}, ${error.message}`); - } - if (verifyRes != true) { - promptAction.showToast({ - message: $r('app.string.verify_fail') - }); - return; - } else { - promptAction.showToast({ - message: $r('app.string.verify_success') - }); - } - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import promptAction from '@ohos.promptAction'; +import Logger from '../util/Logger'; +import picker from '@ohos.file.picker'; +import { CryptoOperation } from '../cryptoframework/CryptoOperation'; +import TextFileManager from '../textfilemanager/TextFileManager'; +import common from '@ohos.app.ability.common'; + +const TAG: string = '[Crypto_Framework]'; + +@Component +export struct Verify { + @State keyFileName: string = ''; + @State keyFileUri: string = ''; + @State textFileUri: string = ''; + @State textFileName: string = ''; + @State keyString: string = ''; + @State plainText: string = ''; + @State message: string = ''; + @State signFileUri: string = ''; + @State signFileName: string = ''; + @State signText: string = ''; + @State createKeyUri: string = ''; + private CryptoOperation: CryptoOperation = new CryptoOperation(); + + build() { + Stack({ alignContent: Alignment.Center }) { + Column() { + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + List() { + ListItem() { + Row() { + Text($r('app.string.open_file')) + .fontSize(16) + .textAlign(TextAlign.Start) + .lineHeight(22) + + Blank() + + Text(this.textFileName === '' ? $r('app.string.please_choose') : this.textFileName) + .fontSize(14) + .textAlign(TextAlign.Start) + .lineHeight(19) + + Image($r('app.media.right_arrow')) + .height('19vp') + .width('10vp') + .margin({ left: 9, right: 9, top: 6, bottom: 6 }) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('52vp') + .padding({ top: 4, left: 12, right: 12 }) + }.onClick(() => { + this.selectTextFileAndRead(); + }) + + ListItem() { + Row() { + Text($r('app.string.select_key_file')) + .fontSize(16) + .textAlign(TextAlign.Start) + .lineHeight(22) + + Blank() + + Text(this.keyFileName === '' ? $r('app.string.please_choose') : this.keyFileName) + .fontSize(14) + .textAlign(TextAlign.Start) + .lineHeight(19) + + Image($r('app.media.right_arrow')) + .height('19vp') + .width('10vp') + .margin({ left: 9, right: 9, top: 6, bottom: 6 }) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('48vp') + .padding({ left: 12, right: 12 }) + }.onClick(() => { + this.selectRsaKeyFileAndRead(); + }) + } + .width('100%') + .height('100%') + .borderRadius(16) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + List() { + ListItem() { + Row() { + Text($r('app.string.select_signature_file')) + .fontSize(16) + .textAlign(TextAlign.Start) + .lineHeight(22) + + Blank() + + Text(this.signFileName === '' ? $r('app.string.please_choose') : this.signFileName) + .fontSize(14) + .textAlign(TextAlign.Start) + .lineHeight(19) + + Image($r('app.media.right_arrow')) + .height('19vp') + .width('10vp') + .margin({ left: 9, right: 9, top: 6, bottom: 6 }) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('56vp') + .padding({ left: 12, right: 12, top: 4, bottom: 4 }) + }.onClick(() => { + this.selectSignFileAndRead(); + }) + } + .width('100%') + .borderRadius(16) + } + } + } + .height('56vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Row() { + Text($r('app.string.text_context')) + .fontSize(16) + .textAlign(TextAlign.Start) + .fontWeight(500) + .lineHeight(22) + } + .padding({ left: 12, right: 12 }) + .width('100%') + .height('48vp') + + Row() { + Text() { + Span(this.plainText) + .fontSize(16) + .fontWeight(400) + .fontColor('#182431') + }.textAlign(TextAlign.Start) + } + .padding({ left: 12, right: 12, bottom: 4 }) + .width('100%') + .height('52vp') + } + .borderRadius(16) + .width('100%') + .height('100') + .backgroundColor(0xFFFFFF) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + Column() { + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Column() { + Button() { + Text($r('app.string.verify')).fontSize(16).fontWeight(500) + .lineHeight(22) + .fontColor('#FFFFFF') + } + .borderRadius(20) + .id('verifyBtn') + .type(ButtonType.Capsule) + .margin({ left: 24, right: 24 }) + .width('100%') + .height('40vp') + .backgroundColor('#007DFF') + .onClick(() => { + if (this.textFileUri === '' || this.keyFileUri === '' || this.signFileUri === '') { + promptAction.showToast({ + message: $r('app.string.null_message') + }); + } else { + this.verifyFunc(); + } + }); + } + } + }.margin({ left: 24, right: 24 }) + }.width('100%').height('340vp').justifyContent(FlexAlign.End) + } + .width('100%') + .height('100%') + } + } + + async selectRsaKeyFileAndRead() { + let config = { + action: 'ohos.want.action.OPEN_FILE', + parameters: { + startMode: 'choose', + } + } + let context = getContext(this) as common.UIAbilityContext; + let result = await context.startAbilityForResult(config); + if (result === null || result === undefined) { + Logger.error(TAG, `result is null or undefined!`); + return; + } + if (result.resultCode !== 0) { + Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); + return; + } + if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { + Logger.error(TAG, `result uri is null or undefined!`); + return; + } + if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { + Logger.error(TAG, `result file name is null or undefined!`); + return; + } + // 获取到密钥文档文件的URI + this.keyFileUri = result.want.parameters.select_item_list.toString(); + // 获取到密钥文档文件的文件名称 + this.keyFileName = result.want.parameters.file_name_list.toString(); + await TextFileManager.readTextFile(this.keyFileUri); + this.keyString = TextFileManager.getString(); + } + + async selectTextFileAndRead() { + let config = { + action: 'ohos.want.action.OPEN_FILE', + parameters: { + startMode: 'choose', + } + } + let context = getContext(this) as common.UIAbilityContext; + let result = await context.startAbilityForResult(config); + if (result === null || result === undefined) { + Logger.error(TAG, `result is null or undefined!`); + return; + } + if (result.resultCode !== 0) { + Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); + return; + } + if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { + Logger.error(TAG, `result uri is null or undefined!`); + return; + } + if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { + Logger.error(TAG, `result file name is null or undefined!`); + return; + } + // 获取到文档文件的URI + this.textFileUri = result.want.parameters.select_item_list.toString(); + // 获取到文档文件的文件名称 + this.textFileName = result.want.parameters.file_name_list.toString(); + await TextFileManager.readTextFile(this.textFileUri); + this.plainText = TextFileManager.getString(); + } + + async selectSignFileAndRead() { + let config = { + action: 'ohos.want.action.OPEN_FILE', + parameters: { + startMode: 'choose', + } + } + let context = getContext(this) as common.UIAbilityContext; + let result = await context.startAbilityForResult(config); + if (result === null || result === undefined) { + Logger.error(TAG, `result is null or undefined!`); + return; + } + if (result.resultCode !== 0) { + Logger.error(TAG, `DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); + return; + } + if (result.want.parameters.select_item_list === null || result.want.parameters.select_item_list === undefined) { + Logger.error(TAG, `result uri is null or undefined!`); + return; + } + if (result.want.parameters.file_name_list === null || result.want.parameters.file_name_list === undefined) { + Logger.error(TAG, `result file name is null or undefined!`); + return; + } + // 获取到文档文件的URI + this.signFileUri = result.want.parameters.select_item_list.toString(); + // 获取到文档文件的文件名称 + this.signFileName = result.want.parameters.file_name_list.toString(); + await TextFileManager.readTextFile(this.signFileUri); + this.signText = TextFileManager.getString(); + } + + async createKeyFileAndWrite() { + let documentSaveOptions = new picker.DocumentSaveOptions(); + documentSaveOptions.newFileNames = ['rsaKey.txt']; + let documentPicker = new picker.DocumentViewPicker(); + try { + let documentSaveResult = await documentPicker.save(documentSaveOptions); + this.createKeyUri = documentSaveResult[0]; + await TextFileManager.writeTextFile(this.createKeyUri, this.keyString); + } catch (error) { + Logger.error(TAG, `save key failed, ${error.code}, ${error.message}`); + } + + } + + async verifyFunc() { + let verifyRes; + if (this.plainText === '' || this.keyFileUri === '' || this.signText === '') { + promptAction.showToast({ + message: $r('app.string.null_message') + }); + return; + } + try { + verifyRes = await this.CryptoOperation.rsaConvertAndVerify(this.keyString, this.plainText, this.signText); + } catch (error) { + Logger.error(TAG, `verify failed, ${error.code}, ${error.message}`); + } + if (verifyRes != true) { + promptAction.showToast({ + message: $r('app.string.verify_fail') + }); + return; + } else { + promptAction.showToast({ + message: $r('app.string.verify_success') + }); + } + } +} diff --git a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/textfilemanager/TextFileManager.ts b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/textfilemanager/TextFileManager.ts index 0e1fae6742..dfdbabd349 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/textfilemanager/TextFileManager.ts +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/textfilemanager/TextFileManager.ts @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2023 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 fs from '@ohos.file.fs'; -import Logger from '../util/Logger'; - -const TAG: string = '[Crypto_Framework]'; -const FILE_SLEEP_TIME: number = 100; -const TEXT_MAX_READ_LEN: number = 8192; -// filePicker和文件管理,在OH 4.0.8.2镜像版本,读取uri后,无法直接read、write文件内容,需要sleep几十ms,这里sleep100毫秒 -function sleep(time: number): Promise { - return new Promise((resolve) => setTimeout(resolve, time)); -} - -class TextFileManager { - public static readString: string = ''; - public static readResult: number = 0; - public static writeResult: number = 0; - - async readTextFile(textFileUri: string): Promise { - await sleep(FILE_SLEEP_TIME); - try { - // 读取 - let file = fs.openSync(textFileUri, fs.OpenMode.READ_ONLY); - Logger.info(TAG, 'success, read only file ' + file.fd); - // 从文件读取一段内容,限制最大长度为8192 - let buf = new ArrayBuffer(TEXT_MAX_READ_LEN); - try { - let readLen: number = fs.readSync(file.fd, buf, { offset: 0 }); - TextFileManager.readString = String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen))); - TextFileManager.readResult = readLen; - } catch (error1) { - Logger.error(TAG, `file read failed, ${error1.code}, ${error1.message}`); - } - fs.closeSync(file); - } catch (error) { - Logger.error(TAG, `file open failed, ${error.code}, ${error.message}`); - return; - } - } - - async writeTextFile(textFileUri: string, textString: string): Promise { - await sleep(FILE_SLEEP_TIME); - try { - // 读写 - let file = fs.openSync(textFileUri, fs.OpenMode.READ_WRITE); - Logger.info(TAG, 'success, read write file' + file.fd); - try { - // 写入 - let writeLen = fs.writeSync(file.fd, textString); - Logger.info(TAG, 'success, The length of str is: ' + writeLen); - TextFileManager.writeResult = writeLen; - } catch (error1) { - Logger.error(TAG, `file write failed, ${error1.code}, ${error1.message}`); - } - fs.closeSync(file); - } catch (error) { - Logger.error(TAG, `file open failed, ${error.code}, ${error.message}`); - return; - } - } - - getString(): string { - return TextFileManager.readString; - } -} - +/* + * Copyright (c) 2023 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 fs from '@ohos.file.fs'; +import Logger from '../util/Logger'; + +const TAG: string = '[Crypto_Framework]'; +const FILE_SLEEP_TIME: number = 100; +const TEXT_MAX_READ_LEN: number = 8192; +// filePicker和文件管理,在OH 4.0.8.2镜像版本,读取uri后,无法直接read、write文件内容,需要sleep几十ms,这里sleep100毫秒 +function sleep(time: number): Promise { + return new Promise((resolve) => setTimeout(resolve, time)); +} + +class TextFileManager { + public static readString: string = ''; + public static readResult: number = 0; + public static writeResult: number = 0; + + async readTextFile(textFileUri: string): Promise { + await sleep(FILE_SLEEP_TIME); + try { + // 读取 + let file = fs.openSync(textFileUri, fs.OpenMode.READ_ONLY); + Logger.info(TAG, 'success, read only file ' + file.fd); + // 从文件读取一段内容,限制最大长度为8192 + let buf = new ArrayBuffer(TEXT_MAX_READ_LEN); + try { + let readLen: number = fs.readSync(file.fd, buf, { offset: 0 }); + TextFileManager.readString = String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen))); + TextFileManager.readResult = readLen; + } catch (error1) { + Logger.error(TAG, `file read failed, ${error1.code}, ${error1.message}`); + } + fs.closeSync(file); + } catch (error) { + Logger.error(TAG, `file open failed, ${error.code}, ${error.message}`); + return; + } + } + + async writeTextFile(textFileUri: string, textString: string): Promise { + await sleep(FILE_SLEEP_TIME); + try { + // 读写 + let file = fs.openSync(textFileUri, fs.OpenMode.READ_WRITE); + Logger.info(TAG, 'success, read write file' + file.fd); + try { + // 写入 + let writeLen = fs.writeSync(file.fd, textString); + Logger.info(TAG, 'success, The length of str is: ' + writeLen); + TextFileManager.writeResult = writeLen; + } catch (error1) { + Logger.error(TAG, `file write failed, ${error1.code}, ${error1.message}`); + } + fs.closeSync(file); + } catch (error) { + Logger.error(TAG, `file open failed, ${error.code}, ${error.message}`); + return; + } + } + + getString(): string { + return TextFileManager.readString; + } +} + export default new TextFileManager(); \ No newline at end of file diff --git a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/util/Logger.ts b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/util/Logger.ts index 835b34e2eb..3a7c27e433 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/util/Logger.ts +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/main/ets/util/Logger.ts @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xF811; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - return; - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - return; - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - return; - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - return; - } - - fatal(...args: string[]): void { - hilog.fatal(this.domain, this.prefix, this.format, args); - return; - } - - isLoggable(level: number): void { - hilog.isLoggable(this.domain, this.prefix, level); - return; - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xF811; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + return; + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + return; + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + return; + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + return; + } + + fatal(...args: string[]): void { + hilog.fatal(this.domain, this.prefix, this.format, args); + return; + } + + isLoggable(level: number): void { + hilog.isLoggable(this.domain, this.prefix, level); + return; + } +} + export default new Logger('[Sample_Crypto_framework]'); \ No newline at end of file diff --git a/code/BasicFeature/Security/CryptoFramework/entry/src/main/module.json5 b/code/BasicFeature/Security/CryptoFramework/entry/src/main/module.json5 index e8105a7505..8377d805fa 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/main/module.json5 +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/main/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 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", - "srcEntrance": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/BasicFeature/Security/CryptoFramework/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Security/CryptoFramework/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/BasicFeature/Security/CryptoFramework/entry/src/ohosTest/module.json5 b/code/BasicFeature/Security/CryptoFramework/entry/src/ohosTest/module.json5 index 741bfbf578..22e2c611f3 100644 --- a/code/BasicFeature/Security/CryptoFramework/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/Security/CryptoFramework/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "visible": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/Security/CryptoFramework/hvigor/hvigor-config.json5 b/code/BasicFeature/Security/CryptoFramework/hvigor/hvigor-config.json5 index 32f6d6f512..6128b5c55e 100644 --- a/code/BasicFeature/Security/CryptoFramework/hvigor/hvigor-config.json5 +++ b/code/BasicFeature/Security/CryptoFramework/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "hvigorVersion": "2.1.1", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "2.1.1" - } -} +/* + * Copyright (c) 2023 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. + */ + +{ + "hvigorVersion": "2.1.1", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "2.1.1" + } +} diff --git a/code/BasicFeature/Security/CryptoFramework/oh-package.json5 b/code/BasicFeature/Security/CryptoFramework/oh-package.json5 index 5616a894a7..0634a04762 100644 --- a/code/BasicFeature/Security/CryptoFramework/oh-package.json5 +++ b/code/BasicFeature/Security/CryptoFramework/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "ISC", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "name": "com.samples.cryptoFramework", - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "ISC", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "name": "com.samples.cryptoFramework", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/BasicFeature/Security/CryptoFramework/ohosTest.md b/code/BasicFeature/Security/CryptoFramework/ohosTest.md index a6457f84e3..127df7c7ec 100644 --- a/code/BasicFeature/Security/CryptoFramework/ohosTest.md +++ b/code/BasicFeature/Security/CryptoFramework/ohosTest.md @@ -1,25 +1,25 @@ -# CryptoFramework 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 |是否自动|测试结果| -|--------------|--------------------------|-----------------------------------------------------------------|---------------------------------|--------------------------------|--------------------------------| -| 拉起应用 | 设备正常运行 | | 成功拉起应用 |是|Pass| -| 主页tabs选择 | 成功拉起应用 | 点击加密tab | 跳转至加密页面 |是|Pass| -| 主页tabs选择 | 成功拉起应用 | 点击解密tab | 跳转至解密页面 |是|Pass| -| 主页tabs选择 | 成功拉起应用 | 点击签名tab | 跳转至签名页面 |是|Pass| -| 主页tabs选择 | 成功拉起应用 | 点击验签tab | 跳转至签名页面 |是|Pass| -| 加密按钮点击 | 位于加密页面 | 不选择文件、密钥,点击加密按钮 | 提示文件或密钥为空 |是|Pass| -| 解密按钮点击 | 位于解密页面 | 不选择文件、密钥,点击解密按钮 | 提示文件或密钥为空 |是|Pass| -| 签名按钮点击 | 位于签名页面 | 不选择文件、密钥,点击签名按钮 | 提示文件或密钥为空 |是|Pass| -| 验签按钮点击 | 位于验签页面 | 不选择文件、密钥、签名文件,点击验签按钮 | 提示文件或密钥为空 |是|Pass| -| 加密功能,生成AES密钥 | 位于加密页面 | 点击随机生成AES密钥按钮,跳转至filepicker界面,默认密钥文件名为aesKey,可自定义文件命名,点击确认 | 提示已生成AES密钥 |否|Pass| -| 签名功能,生成RSA密钥 | 位于签名页面 | 点击随机生成RSA密钥按钮,然后跳转至filepicker界面,默认密钥文件名为rsaKey,可自定义文件命名,点击确认 | 先提示"RSA密钥生成较慢,请稍等", 再提示已生成RSA密钥 |否|Pass| -| 选择密钥 | 位于加密、解密、签名、验签页面 | 点击选择密钥按钮,跳转至filepicker界面,选择密钥文本文件,加密解密采用aes密钥,签名验签采用rsa密钥 | 文本栏显示选择的密钥文件名 |否|Pass| -| 打开文件 | 位于加密、解密、签名、验签页面 | 点击选择文件按钮,跳转至filepicker界面,选择文本文件 | 文本栏显示选择的文本文件名 |否|Pass| -| 选择签名文件 | 位于验签页面 | 点击选择签名文件按钮,跳转至filepicker界面,选择签名文本文件 | 文本栏显示选择的签名文本文件名 |否|Pass| -| 加密功能 | 位于加密页面,已选择文件、密钥 | 点击加密按钮,跳转至filepicker界面,默认加密得到的密文文本文件名为cipherText,可自定义文件命名,点击确认 | 提示加密成功,加密内容文本栏显示密文文本内容 |否|Pass| -| 解密功能 | 位于解密页面,已选择正确的文件、密钥 | 点击解密按钮,跳转至filepicker界面,默认解密得到的明文文本文件名为plainText,可自定义文件命名,点击确认 | 提示解密成功,解密内容文本栏显示明文文本内容 |否|Pass| -| 签名功能 | 位于签名页面,已选择文件、密钥 | 点击签名按钮,跳转至filepicker界面,默认签名得到的签名文本文件名为signText,可自定义文件命名,点击确认 | 提示签名成功 |否|Pass| -| 验签功能 | 位于验签页面,已选择正确的文件、密钥、签名文件 | 点击验签按钮 | 提示验签成功 |否|Pass| +# CryptoFramework 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 |是否自动|测试结果| +|--------------|--------------------------|-----------------------------------------------------------------|---------------------------------|--------------------------------|--------------------------------| +| 拉起应用 | 设备正常运行 | | 成功拉起应用 |是|Pass| +| 主页tabs选择 | 成功拉起应用 | 点击加密tab | 跳转至加密页面 |是|Pass| +| 主页tabs选择 | 成功拉起应用 | 点击解密tab | 跳转至解密页面 |是|Pass| +| 主页tabs选择 | 成功拉起应用 | 点击签名tab | 跳转至签名页面 |是|Pass| +| 主页tabs选择 | 成功拉起应用 | 点击验签tab | 跳转至签名页面 |是|Pass| +| 加密按钮点击 | 位于加密页面 | 不选择文件、密钥,点击加密按钮 | 提示文件或密钥为空 |是|Pass| +| 解密按钮点击 | 位于解密页面 | 不选择文件、密钥,点击解密按钮 | 提示文件或密钥为空 |是|Pass| +| 签名按钮点击 | 位于签名页面 | 不选择文件、密钥,点击签名按钮 | 提示文件或密钥为空 |是|Pass| +| 验签按钮点击 | 位于验签页面 | 不选择文件、密钥、签名文件,点击验签按钮 | 提示文件或密钥为空 |是|Pass| +| 加密功能,生成AES密钥 | 位于加密页面 | 点击随机生成AES密钥按钮,跳转至filepicker界面,默认密钥文件名为aesKey,可自定义文件命名,点击确认 | 提示已生成AES密钥 |否|Pass| +| 签名功能,生成RSA密钥 | 位于签名页面 | 点击随机生成RSA密钥按钮,然后跳转至filepicker界面,默认密钥文件名为rsaKey,可自定义文件命名,点击确认 | 先提示"RSA密钥生成较慢,请稍等", 再提示已生成RSA密钥 |否|Pass| +| 选择密钥 | 位于加密、解密、签名、验签页面 | 点击选择密钥按钮,跳转至filepicker界面,选择密钥文本文件,加密解密采用aes密钥,签名验签采用rsa密钥 | 文本栏显示选择的密钥文件名 |否|Pass| +| 打开文件 | 位于加密、解密、签名、验签页面 | 点击选择文件按钮,跳转至filepicker界面,选择文本文件 | 文本栏显示选择的文本文件名 |否|Pass| +| 选择签名文件 | 位于验签页面 | 点击选择签名文件按钮,跳转至filepicker界面,选择签名文本文件 | 文本栏显示选择的签名文本文件名 |否|Pass| +| 加密功能 | 位于加密页面,已选择文件、密钥 | 点击加密按钮,跳转至filepicker界面,默认加密得到的密文文本文件名为cipherText,可自定义文件命名,点击确认 | 提示加密成功,加密内容文本栏显示密文文本内容 |否|Pass| +| 解密功能 | 位于解密页面,已选择正确的文件、密钥 | 点击解密按钮,跳转至filepicker界面,默认解密得到的明文文本文件名为plainText,可自定义文件命名,点击确认 | 提示解密成功,解密内容文本栏显示明文文本内容 |否|Pass| +| 签名功能 | 位于签名页面,已选择文件、密钥 | 点击签名按钮,跳转至filepicker界面,默认签名得到的签名文本文件名为signText,可自定义文件命名,点击确认 | 提示签名成功 |否|Pass| +| 验签功能 | 位于验签页面,已选择正确的文件、密钥、签名文件 | 点击验签按钮 | 提示验签成功 |否|Pass| **** \ No newline at end of file diff --git a/code/BasicFeature/Security/Huks/entry/src/main/ets/common/MinAccessControl.ets b/code/BasicFeature/Security/Huks/entry/src/main/ets/common/MinAccessControl.ets index 199f47be4e..b02706984a 100644 --- a/code/BasicFeature/Security/Huks/entry/src/main/ets/common/MinAccessControl.ets +++ b/code/BasicFeature/Security/Huks/entry/src/main/ets/common/MinAccessControl.ets @@ -1,220 +1,220 @@ -/* - * Copyright (c) 2023 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 prompt from '@ohos.prompt' -import Logger from '../model/Logger' -import { HuksModel } from '../model/HuksModel' - -const TAG: string = '[HUKS]' - -@Component -export struct MinAccessControl { - @State cipherTextinfo: string = '' - @State plainTextinfo: string = '' - @State inputPassword: string = '' - huksModel: HuksModel = new HuksModel() - - build() { - Stack({ alignContent: Alignment.Center }) { - Column() { - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - List() { - ListItem() { - Row() { - Text($r('app.string.input_save_password')) - .fontSize(16) - .textAlign(TextAlign.Start) - .lineHeight(22) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('52vp') - .padding({ top: 4, left: 12, right: 12 }) - } - - ListItem() { - Row() { - TextInput() - .enableKeyboardOnFocus(false) - .margin(4) - .width('90%') - .id('passwordInput') - .fontSize(16) - .textAlign(TextAlign.Start) - .onChange((value: string) => { - this.inputPassword = value - }) - } - .backgroundColor(0xFFFFFF) - .width('100%') - .height('48vp') - .padding({ left: 12, right: 12 }) - } - } - .width('100%') - .height('100%') - .borderRadius(16) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Column() { - Row() { - Text($r('app.string.cipher_text')) - .fontSize(16) - .textAlign(TextAlign.Start) - .fontWeight(500) - .lineHeight(22) - } - .padding({ left: 12, right: 12 }) - .width('100%') - .height('48vp') - - Row() { - Text() { - Span(this.cipherTextinfo) - .fontSize(16) - .fontWeight(400) - .fontColor(0x808080) - .fontColor('#182431') - }.textAlign(TextAlign.Start) - .id('cipherTextinfo') - } - .padding({ left: 12, right: 12, bottom: 4 }) - .width('100%') - .height('52vp') - } - .borderRadius(16) - .width('100%') - .height('100') - .backgroundColor(0xFFFFFF) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Column() { - Row() { - Text($r('app.string.plain_text')) - .fontSize(16) - .textAlign(TextAlign.Start) - .fontWeight(500) - .lineHeight(22) - } - .padding({ left: 12, right: 12 }) - .width('100%') - .height('48vp') - - Row() { - Text() { - Span(this.plainTextinfo) - .fontSize(16) - .fontWeight(400) - .fontColor(0x808080) - .fontColor('#182431') - }.textAlign(TextAlign.Start) - .id('plainTextinfo') - } - .padding({ left: 12, right: 12, bottom: 4 }) - .width('100%') - .height('52vp') - } - .borderRadius(16) - .width('100%') - .height('100') - .backgroundColor(0xFFFFFF) - } - } - } - .height('100vp') - .margin({ left: 12, right: 12, bottom: 12 }) - - Column() { - GridRow() { - GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { - Column() { - Button() { - Text($r('app.string.save_password')).fontSize(16).fontWeight(500) - .lineHeight(22) - .fontColor('#FFFFFF') - } - .id('save_password') - .borderRadius(20) - .type(ButtonType.Capsule) - .width('100%') - .height('40vp') - .margin({ bottom: 16 }) - .backgroundColor('#007DFF') - .onClick(() => { - if (this.inputPassword === '') { - prompt.showToast({ - message: 'This message is null.' - }) - } else { - this.huksModel.encryptDataUseSm2(this.inputPassword, (result: string) => { - Logger.info(TAG, `this result = ${result}`) - this.cipherTextinfo = `${result}` - }) - } - }); - - Button() { - Text($r('app.string.read_password')).fontSize(16).fontWeight(500) - .lineHeight(22) - .fontColor('#FFFFFF') - } - .borderRadius(20) - .id('read_password') - .type(ButtonType.Capsule) - .margin({ left: 24, right: 24 }) - .width('100%') - .height('40vp') - .backgroundColor('#007DFF') - .onClick(() => { - - if (this.inputPassword === '') { - prompt.showToast({ - message: 'This message is null.' - }) - } else { - this.huksModel.decryptDataUseSm2((result: string) => { - Logger.info(TAG, `this result = ${result}`) - this.plainTextinfo = `${result}` - }) - } - - }); - } - } - }.margin({ left: 24, right: 24 }) - }.width('100%').height('296vp').justifyContent(FlexAlign.End) - } - .width('100%') - .height('100%') - } - } -} - +/* + * Copyright (c) 2023 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 prompt from '@ohos.prompt' +import Logger from '../model/Logger' +import { HuksModel } from '../model/HuksModel' + +const TAG: string = '[HUKS]' + +@Component +export struct MinAccessControl { + @State cipherTextinfo: string = '' + @State plainTextinfo: string = '' + @State inputPassword: string = '' + huksModel: HuksModel = new HuksModel() + + build() { + Stack({ alignContent: Alignment.Center }) { + Column() { + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + List() { + ListItem() { + Row() { + Text($r('app.string.input_save_password')) + .fontSize(16) + .textAlign(TextAlign.Start) + .lineHeight(22) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('52vp') + .padding({ top: 4, left: 12, right: 12 }) + } + + ListItem() { + Row() { + TextInput() + .enableKeyboardOnFocus(false) + .margin(4) + .width('90%') + .id('passwordInput') + .fontSize(16) + .textAlign(TextAlign.Start) + .onChange((value: string) => { + this.inputPassword = value + }) + } + .backgroundColor(0xFFFFFF) + .width('100%') + .height('48vp') + .padding({ left: 12, right: 12 }) + } + } + .width('100%') + .height('100%') + .borderRadius(16) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Row() { + Text($r('app.string.cipher_text')) + .fontSize(16) + .textAlign(TextAlign.Start) + .fontWeight(500) + .lineHeight(22) + } + .padding({ left: 12, right: 12 }) + .width('100%') + .height('48vp') + + Row() { + Text() { + Span(this.cipherTextinfo) + .fontSize(16) + .fontWeight(400) + .fontColor(0x808080) + .fontColor('#182431') + }.textAlign(TextAlign.Start) + .id('cipherTextinfo') + } + .padding({ left: 12, right: 12, bottom: 4 }) + .width('100%') + .height('52vp') + } + .borderRadius(16) + .width('100%') + .height('100') + .backgroundColor(0xFFFFFF) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Row() { + Text($r('app.string.plain_text')) + .fontSize(16) + .textAlign(TextAlign.Start) + .fontWeight(500) + .lineHeight(22) + } + .padding({ left: 12, right: 12 }) + .width('100%') + .height('48vp') + + Row() { + Text() { + Span(this.plainTextinfo) + .fontSize(16) + .fontWeight(400) + .fontColor(0x808080) + .fontColor('#182431') + }.textAlign(TextAlign.Start) + .id('plainTextinfo') + } + .padding({ left: 12, right: 12, bottom: 4 }) + .width('100%') + .height('52vp') + } + .borderRadius(16) + .width('100%') + .height('100') + .backgroundColor(0xFFFFFF) + } + } + } + .height('100vp') + .margin({ left: 12, right: 12, bottom: 12 }) + + Column() { + GridRow() { + GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 12 } }) { + Column() { + Button() { + Text($r('app.string.save_password')).fontSize(16).fontWeight(500) + .lineHeight(22) + .fontColor('#FFFFFF') + } + .id('save_password') + .borderRadius(20) + .type(ButtonType.Capsule) + .width('100%') + .height('40vp') + .margin({ bottom: 16 }) + .backgroundColor('#007DFF') + .onClick(() => { + if (this.inputPassword === '') { + prompt.showToast({ + message: 'This message is null.' + }) + } else { + this.huksModel.encryptDataUseSm2(this.inputPassword, (result: string) => { + Logger.info(TAG, `this result = ${result}`) + this.cipherTextinfo = `${result}` + }) + } + }); + + Button() { + Text($r('app.string.read_password')).fontSize(16).fontWeight(500) + .lineHeight(22) + .fontColor('#FFFFFF') + } + .borderRadius(20) + .id('read_password') + .type(ButtonType.Capsule) + .margin({ left: 24, right: 24 }) + .width('100%') + .height('40vp') + .backgroundColor('#007DFF') + .onClick(() => { + + if (this.inputPassword === '') { + prompt.showToast({ + message: 'This message is null.' + }) + } else { + this.huksModel.decryptDataUseSm2((result: string) => { + Logger.info(TAG, `this result = ${result}`) + this.plainTextinfo = `${result}` + }) + } + + }); + } + } + }.margin({ left: 24, right: 24 }) + }.width('100%').height('296vp').justifyContent(FlexAlign.End) + } + .width('100%') + .height('100%') + } + } +} + diff --git a/code/DocsSample/Ability/Performance/Startup/AppScope/app.json5 b/code/DocsSample/Ability/Performance/Startup/AppScope/app.json5 index a1e316bd0d..cca1228f50 100644 --- a/code/DocsSample/Ability/Performance/Startup/AppScope/app.json5 +++ b/code/DocsSample/Ability/Performance/Startup/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.startup", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.startup", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Ability/Performance/Startup/AppScope/resources/base/element/string.json b/code/DocsSample/Ability/Performance/Startup/AppScope/resources/base/element/string.json index 6dbee75ce9..e2c5787e95 100644 --- a/code/DocsSample/Ability/Performance/Startup/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Ability/Performance/Startup/AppScope/resources/base/element/string.json @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "string": [ - { - "name": "app_name", - "value": "startup" - } - ] -} +/* + * Copyright (c) 2023 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. + */ + +{ + "string": [ + { + "name": "app_name", + "value": "startup" + } + ] +} diff --git a/code/DocsSample/Ability/Performance/Startup/README_zh.md b/code/DocsSample/Ability/Performance/Startup/README_zh.md index bb5023963a..47518692dd 100644 --- a/code/DocsSample/Ability/Performance/Startup/README_zh.md +++ b/code/DocsSample/Ability/Performance/Startup/README_zh.md @@ -1,230 +1,230 @@ -# 提升应用冷启动速度示例 - -### 介绍 - -本示例展示了[提升应用冷启动速度](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md)的五种方式: - -1. 缩短应用进程创建&初始化阶段耗时; -2. 缩短Application&Ability初始化阶段耗时; -3. 缩短AbilityStage生命周期阶段耗时; -4. 缩短Ability生命周期阶段耗时; -5. 缩短加载绘制首页阶段耗时。 - -### 效果预览 - -| 应用初始页面 | 任务完成界面 | -| ------------------------------- | --------------------------------- | -| ![](screenshots/helloworld.png) | ![](screenshots/taskcomplete.png) | - -使用说明 - -应用在启动后显示文本"hello world";几秒后耗时操作完成,文本变更为"task complete"。 - -### 工程目录 -``` -entry/src/main/ -├── ets -│   ├── common -│   │   └── Logger.ts // 日志工具 -│   ├── entryability -│   │   └── EntryAbility.ts // UIAbility类 -│   ├── myabilitystage -│   │   └── MyAbilityStage.ts // AbilityStage类 -│   └── pages -│   └── Index.ets // 首页 -├── module.json5 -└── resources - ├── base - │   ├── element - │   │   ├── color.json - │   │   └── string.json - │   ├── media - │   │   ├── highResolutionIcon.png // 高分辨率图标 - │   │   ├── icon.png - │   │   └── startIcon.png - │   └── profile - │   └── main_pages.json - ├── en_US - │   └── element - │   └── string.json - └── zh_CN - └── element - └── string.json - -``` -### 具体实现 - -#### 1. 缩短应用进程创建&初始化阶段耗时 - -通过设置合适分辨率的startWindowIcon,缩短应用进程创建&初始化阶段耗时,进而提升应用冷启动速度。 - -entry/src/main/module.json5 - -```json -{ - "module": { - "name": "entry", - "type": "entry", - "srcEntry": "./ets/myabilitystage/MyAbilityStage.ts", - "description": "$string:module_desc", - "mainElement": "EntryAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", // 优化前为"$media:highResolutionIcon" - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } -} -``` - -详情可参见:[设置合适分辨率的startWindowIcon](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md/#设置合适分辨率的startwindowicon) - -#### 2. 缩短Application&Ability初始化阶段耗时 - -通过减少import的模块,可以缩短Application&Ability初始化阶段耗时,进而提升应用冷启动速度。 - -entry/src/main/ets/entryability/EntryAbility.ts - -```ts -// 优化减少import的模块 -// import ability from '@ohos.ability.ability'; -// import dataUriUtils from '@ohos.ability.dataUriUtils'; -// import errorCode from '@ohos.ability.errorCode'; -// import featureAbility from '@ohos.ability.featureAbility'; -// import particleAbility from '@ohos.ability.particleAbility'; -// import wantConstant from '@ohos.ability.wantConstant'; -// import common from '@ohos.app.ability.common'; -// import Configuration from '@ohos.app.ability.Configuration'; -// import contextConstant from '@ohos.app.ability.contextConstant'; -// import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; -// import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; -// import GesturePath from '@ohos.accessibility.GesturePath'; -// import GesturePoint from '@ohos.accessibility.GesturePoint'; -// import distributedAccount from '@ohos.account.distributedAccount'; -// import osAccount from '@ohos.account.osAccount'; - -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; -import logger from '../common/Logger'; -``` - -详情可参见:[减少import的模块](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md/#减少import的模块) - -#### 3. 缩短AbilityStage生命周期阶段耗时 - -通过将AbilityStage生命周期回调接口中的耗时操作改为异步延迟执行,可以缩短AbilityStage生命周期阶段耗时,进而提升应用冷启动速度。 - -entry/src/main/ets/myabilitystage/MyAbilityStage.ts - -```ts -export default class MyAbilityStage extends AbilityStage { - onCreate(): void { - // 应用的HAP在首次加载的时,为该Module初始化操作 - // 耗时操作 - // this.computeTask(); - this.computeTaskAsync(); // 异步任务 - } - // ... -} -``` - -详情可参见:[避免在AbilityStage生命周期回调接口进行耗时操作](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md/#避免在abilitystage生命周期回调接口进行耗时操作) - -#### 4. 缩短Ability生命周期阶段耗时 - -通过将Ability生命周期回调接口中的耗时操作改为异步延迟执行,可以缩短Ability生命周期阶段耗时,进而提升应用冷启动速度。 - -通常与应用冷启动速度相关的生命周期回调为onCreate、onWindowStageCreate和onForeground,以下以onCreate为例进行说明。 - -entry/src/main/ets/entryability/EntryAbility.ts - -```ts -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - logger.info('Ability onCreate'); - // 耗时操作 - // this.computeTask(); - this.computeTaskAsync(); // 异步任务 - } - // ... -} -``` - -详情可参见:[避免在Ability生命周期回调接口进行耗时操作](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md/#避免在ability生命周期回调接口进行耗时操作) - -#### 5. 缩短加载绘制首页阶段耗时 - -通过将自定义组件的生命周期回调接口中的耗时操作改为异步延迟执行,可以缩短加载绘制首页阶段耗时,进而提升应用冷启动速度。 - -entry/src/main/ets/pages/Index.ets - -```ts -@Entry -@Component -struct Index { - // ... - aboutToAppear() { - // 耗时操作 - // this.computeTask(); - this.computeTaskAsync(); // 异步任务 - let context = getContext(this) as Context; - this.text = context.resourceManager.getStringSync($r('app.string.startup_text')); - } - // ... -} -``` - -详情可参见:[自定义组件生命周期回调接口里避免耗时操作](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md/#自定义组件生命周期回调接口里避免耗时操作) - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568。 - -2.本示例已适配API version 10版本SDK,版本号:4.0.10.13。 - -3.本示例需要使用DevEco Studio 4.0 (Build Version: 4.0.0.600 构建 2023年10月17日)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/Ability/Performance/Startup/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 提升应用冷启动速度示例 + +### 介绍 + +本示例展示了[提升应用冷启动速度](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md)的五种方式: + +1. 缩短应用进程创建&初始化阶段耗时; +2. 缩短Application&Ability初始化阶段耗时; +3. 缩短AbilityStage生命周期阶段耗时; +4. 缩短Ability生命周期阶段耗时; +5. 缩短加载绘制首页阶段耗时。 + +### 效果预览 + +| 应用初始页面 | 任务完成界面 | +| ------------------------------- | --------------------------------- | +| ![](screenshots/helloworld.png) | ![](screenshots/taskcomplete.png) | + +使用说明 + +应用在启动后显示文本"hello world";几秒后耗时操作完成,文本变更为"task complete"。 + +### 工程目录 +``` +entry/src/main/ +├── ets +│   ├── common +│   │   └── Logger.ts // 日志工具 +│   ├── entryability +│   │   └── EntryAbility.ts // UIAbility类 +│   ├── myabilitystage +│   │   └── MyAbilityStage.ts // AbilityStage类 +│   └── pages +│   └── Index.ets // 首页 +├── module.json5 +└── resources + ├── base + │   ├── element + │   │   ├── color.json + │   │   └── string.json + │   ├── media + │   │   ├── highResolutionIcon.png // 高分辨率图标 + │   │   ├── icon.png + │   │   └── startIcon.png + │   └── profile + │   └── main_pages.json + ├── en_US + │   └── element + │   └── string.json + └── zh_CN + └── element + └── string.json + +``` +### 具体实现 + +#### 1. 缩短应用进程创建&初始化阶段耗时 + +通过设置合适分辨率的startWindowIcon,缩短应用进程创建&初始化阶段耗时,进而提升应用冷启动速度。 + +entry/src/main/module.json5 + +```json +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntry": "./ets/myabilitystage/MyAbilityStage.ts", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", // 优化前为"$media:highResolutionIcon" + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} +``` + +详情可参见:[设置合适分辨率的startWindowIcon](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md/#设置合适分辨率的startwindowicon) + +#### 2. 缩短Application&Ability初始化阶段耗时 + +通过减少import的模块,可以缩短Application&Ability初始化阶段耗时,进而提升应用冷启动速度。 + +entry/src/main/ets/entryability/EntryAbility.ts + +```ts +// 优化减少import的模块 +// import ability from '@ohos.ability.ability'; +// import dataUriUtils from '@ohos.ability.dataUriUtils'; +// import errorCode from '@ohos.ability.errorCode'; +// import featureAbility from '@ohos.ability.featureAbility'; +// import particleAbility from '@ohos.ability.particleAbility'; +// import wantConstant from '@ohos.ability.wantConstant'; +// import common from '@ohos.app.ability.common'; +// import Configuration from '@ohos.app.ability.Configuration'; +// import contextConstant from '@ohos.app.ability.contextConstant'; +// import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; +// import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; +// import GesturePath from '@ohos.accessibility.GesturePath'; +// import GesturePoint from '@ohos.accessibility.GesturePoint'; +// import distributedAccount from '@ohos.account.distributedAccount'; +// import osAccount from '@ohos.account.osAccount'; + +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import logger from '../common/Logger'; +``` + +详情可参见:[减少import的模块](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md/#减少import的模块) + +#### 3. 缩短AbilityStage生命周期阶段耗时 + +通过将AbilityStage生命周期回调接口中的耗时操作改为异步延迟执行,可以缩短AbilityStage生命周期阶段耗时,进而提升应用冷启动速度。 + +entry/src/main/ets/myabilitystage/MyAbilityStage.ts + +```ts +export default class MyAbilityStage extends AbilityStage { + onCreate(): void { + // 应用的HAP在首次加载的时,为该Module初始化操作 + // 耗时操作 + // this.computeTask(); + this.computeTaskAsync(); // 异步任务 + } + // ... +} +``` + +详情可参见:[避免在AbilityStage生命周期回调接口进行耗时操作](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md/#避免在abilitystage生命周期回调接口进行耗时操作) + +#### 4. 缩短Ability生命周期阶段耗时 + +通过将Ability生命周期回调接口中的耗时操作改为异步延迟执行,可以缩短Ability生命周期阶段耗时,进而提升应用冷启动速度。 + +通常与应用冷启动速度相关的生命周期回调为onCreate、onWindowStageCreate和onForeground,以下以onCreate为例进行说明。 + +entry/src/main/ets/entryability/EntryAbility.ts + +```ts +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + logger.info('Ability onCreate'); + // 耗时操作 + // this.computeTask(); + this.computeTaskAsync(); // 异步任务 + } + // ... +} +``` + +详情可参见:[避免在Ability生命周期回调接口进行耗时操作](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md/#避免在ability生命周期回调接口进行耗时操作) + +#### 5. 缩短加载绘制首页阶段耗时 + +通过将自定义组件的生命周期回调接口中的耗时操作改为异步延迟执行,可以缩短加载绘制首页阶段耗时,进而提升应用冷启动速度。 + +entry/src/main/ets/pages/Index.ets + +```ts +@Entry +@Component +struct Index { + // ... + aboutToAppear() { + // 耗时操作 + // this.computeTask(); + this.computeTaskAsync(); // 异步任务 + let context = getContext(this) as Context; + this.text = context.resourceManager.getStringSync($r('app.string.startup_text')); + } + // ... +} +``` + +详情可参见:[自定义组件生命周期回调接口里避免耗时操作](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/improve-application-cold-start-speed.md/#自定义组件生命周期回调接口里避免耗时操作) + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568。 + +2.本示例已适配API version 10版本SDK,版本号:4.0.10.13。 + +3.本示例需要使用DevEco Studio 4.0 (Build Version: 4.0.0.600 构建 2023年10月17日)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Ability/Performance/Startup/ > .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/Ability/Performance/Startup/build-profile.json5 b/code/DocsSample/Ability/Performance/Startup/build-profile.json5 index f095c27219..31a7e1deb5 100644 --- a/code/DocsSample/Ability/Performance/Startup/build-profile.json5 +++ b/code/DocsSample/Ability/Performance/Startup/build-profile.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "targetSdkVersion": 10, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "targetSdkVersion": 10, + "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/Ability/Performance/Startup/entry/build-profile.json5 b/code/DocsSample/Ability/Performance/Startup/entry/build-profile.json5 index 2eabd9fec3..8e1d0657b6 100644 --- a/code/DocsSample/Ability/Performance/Startup/entry/build-profile.json5 +++ b/code/DocsSample/Ability/Performance/Startup/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Ability/Performance/Startup/entry/oh-package.json5 b/code/DocsSample/Ability/Performance/Startup/entry/oh-package.json5 index 3dbfd8cb93..1423587fdb 100644 --- a/code/DocsSample/Ability/Performance/Startup/entry/oh-package.json5 +++ b/code/DocsSample/Ability/Performance/Startup/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Application launch example.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Application launch example.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/common/Logger.ts b/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/common/Logger.ts index 065783fc2c..b4b85d3857 100644 --- a/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/common/Logger.ts +++ b/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/common/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: any[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: any[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: any[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: any[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: any[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: any[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: any[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: any[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_Startup]'); \ No newline at end of file diff --git a/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/entryability/EntryAbility.ts index 969b454a9c..6ca4e1f1d4 100644 --- a/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,102 +1,102 @@ -/* - * Copyright (c) 2023 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. - */ - -// EntryAbility.ets - -// import ability from '@ohos.ability.ability'; -// import dataUriUtils from '@ohos.ability.dataUriUtils'; -// import errorCode from '@ohos.ability.errorCode'; -// import featureAbility from '@ohos.ability.featureAbility'; -// import particleAbility from '@ohos.ability.particleAbility'; -// import wantConstant from '@ohos.ability.wantConstant'; -// import common from '@ohos.app.ability.common'; -// import Configuration from '@ohos.app.ability.Configuration'; -// import contextConstant from '@ohos.app.ability.contextConstant'; -// import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; -// import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; -// import GesturePath from '@ohos.accessibility.GesturePath'; -// import GesturePoint from '@ohos.accessibility.GesturePoint'; -// import distributedAccount from '@ohos.account.distributedAccount'; -// import osAccount from '@ohos.account.osAccount'; - -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; -import logger from '../common/Logger'; - -const LARGE_NUMBER = 10000000; -const DELAYED_TIME = 1000; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - logger.info('Ability onCreate'); - // 耗时操作 - // this.computeTask(); - this.computeTaskAsync(); // 异步任务 - } - - onDestroy(): void { - logger.info('Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - logger.info('Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - logger.error('Failed to load the content. Cause: ' + JSON.stringify(err) ?? ''); - return; - } - logger.info('Succeeded in loading the content. Data: ' + JSON.stringify(data) ?? ''); - }); - - // 耗时操作 - // this.computeTask(); - this.computeTaskAsync(); // 异步任务 - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - logger.info('Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - logger.info('Ability onForeground'); - // 耗时操作 - // this.computeTask(); - this.computeTaskAsync(); // 异步任务 - } - - onBackground(): void { - // Ability has back to background - logger.info('Ability onBackground'); - } - - computeTask(): void { - let count = 0; - while (count < LARGE_NUMBER) { - count++; - } - } - - private computeTaskAsync(): void { - setTimeout(() => { // 这里使用setTimeout来实现异步延迟运行 - this.computeTask(); - }, DELAYED_TIME); - } -} +/* + * Copyright (c) 2023 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. + */ + +// EntryAbility.ets + +// import ability from '@ohos.ability.ability'; +// import dataUriUtils from '@ohos.ability.dataUriUtils'; +// import errorCode from '@ohos.ability.errorCode'; +// import featureAbility from '@ohos.ability.featureAbility'; +// import particleAbility from '@ohos.ability.particleAbility'; +// import wantConstant from '@ohos.ability.wantConstant'; +// import common from '@ohos.app.ability.common'; +// import Configuration from '@ohos.app.ability.Configuration'; +// import contextConstant from '@ohos.app.ability.contextConstant'; +// import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; +// import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; +// import GesturePath from '@ohos.accessibility.GesturePath'; +// import GesturePoint from '@ohos.accessibility.GesturePoint'; +// import distributedAccount from '@ohos.account.distributedAccount'; +// import osAccount from '@ohos.account.osAccount'; + +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import logger from '../common/Logger'; + +const LARGE_NUMBER = 10000000; +const DELAYED_TIME = 1000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + logger.info('Ability onCreate'); + // 耗时操作 + // this.computeTask(); + this.computeTaskAsync(); // 异步任务 + } + + onDestroy(): void { + logger.info('Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + logger.info('Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + logger.error('Failed to load the content. Cause: ' + JSON.stringify(err) ?? ''); + return; + } + logger.info('Succeeded in loading the content. Data: ' + JSON.stringify(data) ?? ''); + }); + + // 耗时操作 + // this.computeTask(); + this.computeTaskAsync(); // 异步任务 + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + logger.info('Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + logger.info('Ability onForeground'); + // 耗时操作 + // this.computeTask(); + this.computeTaskAsync(); // 异步任务 + } + + onBackground(): void { + // Ability has back to background + logger.info('Ability onBackground'); + } + + computeTask(): void { + let count = 0; + while (count < LARGE_NUMBER) { + count++; + } + } + + private computeTaskAsync(): void { + setTimeout(() => { // 这里使用setTimeout来实现异步延迟运行 + this.computeTask(); + }, DELAYED_TIME); + } +} diff --git a/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/myabilitystage/MyAbilityStage.ts b/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/myabilitystage/MyAbilityStage.ts index 90795eb76a..9d0813219e 100644 --- a/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/myabilitystage/MyAbilityStage.ts +++ b/code/DocsSample/Ability/Performance/Startup/entry/src/main/ets/myabilitystage/MyAbilityStage.ts @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2023 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 AbilityStage from '@ohos.app.ability.AbilityStage'; -import type Want from '@ohos.app.ability.Want'; - -const LARGE_NUMBER = 10000000; -const DELAYED_TIME = 1000; - -export default class MyAbilityStage extends AbilityStage { - onCreate(): void { - // 应用的HAP在首次加载的时,为该Module初始化操作 - // 耗时操作 - // this.computeTask(); - this.computeTaskAsync(); // 异步任务 - } - - onAcceptWant(want: Want): string { - // 仅specified模式下触发 - return 'MyAbilityStage'; - } - - computeTask(): void { - let count = 0; - while (count < LARGE_NUMBER) { - count++; - } - } - - private computeTaskAsync(): void { - setTimeout(() => { // 这里使用setTimeout来实现异步延迟运行 - this.computeTask(); - }, DELAYED_TIME); - } +/* + * Copyright (c) 2023 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 AbilityStage from '@ohos.app.ability.AbilityStage'; +import type Want from '@ohos.app.ability.Want'; + +const LARGE_NUMBER = 10000000; +const DELAYED_TIME = 1000; + +export default class MyAbilityStage extends AbilityStage { + onCreate(): void { + // 应用的HAP在首次加载的时,为该Module初始化操作 + // 耗时操作 + // this.computeTask(); + this.computeTaskAsync(); // 异步任务 + } + + onAcceptWant(want: Want): string { + // 仅specified模式下触发 + return 'MyAbilityStage'; + } + + computeTask(): void { + let count = 0; + while (count < LARGE_NUMBER) { + count++; + } + } + + private computeTaskAsync(): void { + setTimeout(() => { // 这里使用setTimeout来实现异步延迟运行 + this.computeTask(); + }, DELAYED_TIME); + } } \ No newline at end of file diff --git a/code/DocsSample/Ability/Performance/Startup/entry/src/main/module.json5 b/code/DocsSample/Ability/Performance/Startup/entry/src/main/module.json5 index eada4f9ead..219bdf4d5b 100644 --- a/code/DocsSample/Ability/Performance/Startup/entry/src/main/module.json5 +++ b/code/DocsSample/Ability/Performance/Startup/entry/src/main/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 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", - "srcEntry": "./ets/myabilitystage/MyAbilityStage.ts", - "description": "$string:module_desc", - "mainElement": "EntryAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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", + "srcEntry": "./ets/myabilitystage/MyAbilityStage.ts", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/Ability/Performance/Startup/entry/src/main/resources/base/element/color.json b/code/DocsSample/Ability/Performance/Startup/entry/src/main/resources/base/element/color.json index 47181af109..0c30b0d30c 100644 --- a/code/DocsSample/Ability/Performance/Startup/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Ability/Performance/Startup/entry/src/main/resources/base/element/color.json @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +/* + * Copyright (c) 2023 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. + */ + +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Ability/Performance/Startup/entry/src/ohosTest/ets/util/Logger.ts b/code/DocsSample/Ability/Performance/Startup/entry/src/ohosTest/ets/util/Logger.ts index be87e331db..1b35c2f2b3 100644 --- a/code/DocsSample/Ability/Performance/Startup/entry/src/ohosTest/ets/util/Logger.ts +++ b/code/DocsSample/Ability/Performance/Startup/entry/src/ohosTest/ets/util/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xF811; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xF811; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export const logger = new Logger('[Sample_Startup]'); \ No newline at end of file diff --git a/code/DocsSample/Ability/Performance/Startup/entry/src/ohosTest/module.json5 b/code/DocsSample/Ability/Performance/Startup/entry/src/ohosTest/module.json5 index 0511adbc86..c6ad62fbbd 100644 --- a/code/DocsSample/Ability/Performance/Startup/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Ability/Performance/Startup/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/DocsSample/Ability/Performance/Startup/hvigor/hvigor-config.json5 b/code/DocsSample/Ability/Performance/Startup/hvigor/hvigor-config.json5 index f5310200cf..efd98bc375 100644 --- a/code/DocsSample/Ability/Performance/Startup/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Ability/Performance/Startup/hvigor/hvigor-config.json5 @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "hvigorVersion": "3.0.9", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.9" - }, - "execution": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } -} +/* + * Copyright (c) 2023 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. + */ + +{ + "hvigorVersion": "3.0.9", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.9" + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } +} diff --git a/code/DocsSample/Ability/Performance/Startup/oh-package.json5 b/code/DocsSample/Ability/Performance/Startup/oh-package.json5 index 0754c4cd2b..f049d09753 100644 --- a/code/DocsSample/Ability/Performance/Startup/oh-package.json5 +++ b/code/DocsSample/Ability/Performance/Startup/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.11" - }, - "author": "", - "name": "startup", - "description": "Application launch example.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.11" + }, + "author": "", + "name": "startup", + "description": "Application launch example.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/Ability/Performance/Startup/ohosTest.md b/code/DocsSample/Ability/Performance/Startup/ohosTest.md index e8e4ff4fe9..4b4c676189 100644 --- a/code/DocsSample/Ability/Performance/Startup/ohosTest.md +++ b/code/DocsSample/Ability/Performance/Startup/ohosTest.md @@ -1,8 +1,8 @@ -# 提升应用冷启动速度示例测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------- | ------------ | ---- | ------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | - +# 提升应用冷启动速度示例测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------- | ------------ | ---- | ------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | + diff --git a/code/DocsSample/Account/DomainAccount/.gitignore b/code/DocsSample/Account/DomainAccount/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/AppScope/app.json5 b/code/DocsSample/Account/DomainAccount/AppScope/app.json5 old mode 100755 new mode 100644 index 2daf34b835..4055b54e63 --- a/code/DocsSample/Account/DomainAccount/AppScope/app.json5 +++ b/code/DocsSample/Account/DomainAccount/AppScope/app.json5 @@ -1,25 +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.domainaccount", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.domainaccount", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Account/DomainAccount/AppScope/resources/base/element/string.json b/code/DocsSample/Account/DomainAccount/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 1cbfc016cb..da3774353b --- a/code/DocsSample/Account/DomainAccount/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Account/DomainAccount/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "DomainAccount" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "DomainAccount" + } + ] +} diff --git a/code/DocsSample/Account/DomainAccount/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Account/DomainAccount/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/README.md b/code/DocsSample/Account/DomainAccount/README.md index df95cacd34..66af6c93d3 100644 --- a/code/DocsSample/Account/DomainAccount/README.md +++ b/code/DocsSample/Account/DomainAccount/README.md @@ -1,92 +1,92 @@ -# DomainAccount - -### 介绍 - -用户可以在系统中添加域账号,后续可以使用该账号登录、使用系统。 - -当需要验证域账号身份(比如屏幕解锁、登录会话失效等场景)时,可以使用系统提供的接口对域账号进行身份认证。 - -OEM厂商可以采用插件方式定制化域账号管理能力,系统提供了域账号插件注册和注销能能力。 - -实现对以下指南文件中[管理域账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-domain-account.md) [域账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/auth-domain-account.md) [管理域账号插件](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-domain-plugin.md) 示例代码片段的工程化。保证指南中示例代码与sample工程文件同源。 - -### 效果预览 - -| 首页 | 域账号插件管理页面 | 注册插件及结果 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | ------------------------------------------------------------ | -| | | | -| 注销插件及结果 | 域账号管理页面 | 判断指定域账号是否存在及结果 | -| | | | -| 添加域账号及结果 | 删除域账号及结果 | 查询域账号信息和认证结果 | -| | | | -| 域账号认证页面 | 使用密码认证域账号及结果 | 弹窗验证域账号及结果 | -| | | | - -### 使用说明 - -1. 在主界面,点击ManageDomainAccountsPlugin,进入域账号插件管理页面。 -2. 点击注册插件按钮,进行插件注册。 -3. 进入管理域账号管理页面。 -4. 点击判断指定域账号是否存在。 -5. 点击添加域账号。 -6. 点击删除域账号。 -7. 点击查询域账号信息。 -8. 进入认证域账号界面。 -9. 点击使用密码认证域账号。 -10. 点击使用弹窗验证域账号。 -11. 回到域账号插件管理页面。 -12. 点击注销插件按钮,进行注销插件。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - | | ├──DomainAccount - | | | ├──AuthenticationDomainAccount // 域账号管理示例代码 - | | | ├──ManageDomainAccounts // 域处理示例代码 - | | | └──ManageDomainAccountsPlugin // 域账号插件示例代码 - │ │ ├── Index.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -[ohos.permission.MANAGE_LOCAL_ACCOUNTS](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanagelocalaccounts) - -[ohos.permission.GET_DOMAIN_ACCOUNTS](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissiongetdomainaccounts) - -[ohos.permission.ACCESS_USER_AUTH_INTERNAL](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionaccessuserauthinternal) - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Account/DomainAccount > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# DomainAccount + +### 介绍 + +用户可以在系统中添加域账号,后续可以使用该账号登录、使用系统。 + +当需要验证域账号身份(比如屏幕解锁、登录会话失效等场景)时,可以使用系统提供的接口对域账号进行身份认证。 + +OEM厂商可以采用插件方式定制化域账号管理能力,系统提供了域账号插件注册和注销能能力。 + +实现对以下指南文件中[管理域账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-domain-account.md) [域账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/auth-domain-account.md) [管理域账号插件](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-domain-plugin.md) 示例代码片段的工程化。保证指南中示例代码与sample工程文件同源。 + +### 效果预览 + +| 首页 | 域账号插件管理页面 | 注册插件及结果 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | ------------------------------------------------------------ | +| | | | +| 注销插件及结果 | 域账号管理页面 | 判断指定域账号是否存在及结果 | +| | | | +| 添加域账号及结果 | 删除域账号及结果 | 查询域账号信息和认证结果 | +| | | | +| 域账号认证页面 | 使用密码认证域账号及结果 | 弹窗验证域账号及结果 | +| | | | + +### 使用说明 + +1. 在主界面,点击ManageDomainAccountsPlugin,进入域账号插件管理页面。 +2. 点击注册插件按钮,进行插件注册。 +3. 进入管理域账号管理页面。 +4. 点击判断指定域账号是否存在。 +5. 点击添加域账号。 +6. 点击删除域账号。 +7. 点击查询域账号信息。 +8. 进入认证域账号界面。 +9. 点击使用密码认证域账号。 +10. 点击使用弹窗验证域账号。 +11. 回到域账号插件管理页面。 +12. 点击注销插件按钮,进行注销插件。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + | | ├──DomainAccount + | | | ├──AuthenticationDomainAccount // 域账号管理示例代码 + | | | ├──ManageDomainAccounts // 域处理示例代码 + | | | └──ManageDomainAccountsPlugin // 域账号插件示例代码 + │ │ ├── Index.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +[ohos.permission.MANAGE_LOCAL_ACCOUNTS](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanagelocalaccounts) + +[ohos.permission.GET_DOMAIN_ACCOUNTS](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissiongetdomainaccounts) + +[ohos.permission.ACCESS_USER_AUTH_INTERNAL](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionaccessuserauthinternal) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Account/DomainAccount > .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/Account/DomainAccount/build-profile.json5 b/code/DocsSample/Account/DomainAccount/build-profile.json5 old mode 100755 new mode 100644 index a33a4782e9..3777455b48 --- a/code/DocsSample/Account/DomainAccount/build-profile.json5 +++ b/code/DocsSample/Account/DomainAccount/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/DomainAccount/code-linter.json5 b/code/DocsSample/Account/DomainAccount/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/.gitignore b/code/DocsSample/Account/DomainAccount/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/build-profile.json5 b/code/DocsSample/Account/DomainAccount/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Account/DomainAccount/entry/build-profile.json5 +++ b/code/DocsSample/Account/DomainAccount/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/DomainAccount/entry/hvigorfile.ts b/code/DocsSample/Account/DomainAccount/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/obfuscation-rules.txt b/code/DocsSample/Account/DomainAccount/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/oh-package.json5 b/code/DocsSample/Account/DomainAccount/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Account/DomainAccount/entry/oh-package.json5 +++ b/code/DocsSample/Account/DomainAccount/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Account/DomainAccount/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Account/DomainAccount/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Account/DomainAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/AuthenticationDomainAccount.ets b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/AuthenticationDomainAccount.ets old mode 100755 new mode 100644 index 38417a1cd6..bd8de78cf0 --- a/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/AuthenticationDomainAccount.ets +++ b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/AuthenticationDomainAccount.ets @@ -1,115 +1,115 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start import_the_system_account_module] -import { osAccount } from '@kit.BasicServicesKit'; -// [End import_the_system_account_module] -import { router } from '@kit.ArkUI'; - -@Entry -@Component -struct AuthenticationDomainAccount { - @State message: string = 'No Message'; - - private async passwordAuthenticateDomainAccount(): Promise { - // [Start get_user_input] - let domainAccountInfo: osAccount.DomainAccountInfo = { - domain: 'CHINA', - accountName: 'zhangsan' - }; - let credential: Uint8Array = new Uint8Array([0]); - // [End get_user_input] - // [Start define_the_callback_for_the_authentication_result] - let callback: osAccount.IUserAuthCallback = { - onResult: (resultCode: number, authResult: osAccount.AuthResult) => { - console.log('auth resultCode = ' + resultCode); - console.log('auth authResult = ' + JSON.stringify(authResult)); - // [StartExclude define_the_callback_for_the_authentication_result] - if(resultCode == 0) { - this.message = 'Successfully authenticated domain account using password'; - } else { - this.message = 'Failed to authenticate domain account using password: ' + resultCode; - } - // [EndExclude define_the_callback_for_the_authentication_result] - - } - }; - // [End define_the_callback_for_the_authentication_result] - // [Start perform_password_authentication] - try { - osAccount.DomainAccountManager.auth(domainAccountInfo, credential, callback); - } catch (err) { - console.error('auth exception = ' + JSON.stringify(err)); - } - // [End perform_password_authentication] - } - - private async popupAuthenticateDomainAccount(): Promise { - // [Start define_the_callback_object_of_the_authentication_result] - let callback: osAccount.IUserAuthCallback = { - onResult: (resultCode: number, authResult: osAccount.AuthResult) => { - console.log('authWithPopup resultCode = ' + resultCode); - console.log('authWithPopup authResult = ' + JSON.stringify(authResult)); - // [StartExclude define_the_callback_object_of_the_authentication_result] - if(resultCode == 0) { - this.message = 'Successfully authenticated domain account using popup'; - } else if(resultCode == 12300003) { - this.message = 'No domain account is bound'; - } else { - this.message = 'Failed to authenticate domain account using popup: ' + resultCode; - } - // [EndExclude define_the_callback_object_of_the_authentication_result] - } - } - // [End define_the_callback_object_of_the_authentication_result] - // [Start call_operation_to_authenticate_the_current_domain_account] - try { - osAccount.DomainAccountManager.authWithPopup(callback) - } catch (err) { - console.error('authWithPopup exception = ' + JSON.stringify(err)); - // [StartExclude call_operation_to_authenticate_the_current_domain_account] - this.message = 'Exception occurred during popup authentication: ' + JSON.stringify(err); - // [EndExclude call_operation_to_authenticate_the_current_domain_account] - } - // [End call_operation_to_authenticate_the_current_domain_account] - } - - build() { - Column() { - Text(this.message) - .id('show') - .fontSize(36) - .fontWeight(FontWeight.Bold) - Button($r('app.string.Domain1')) - .margin(10) - .id('button1') - .onClick(() => this.passwordAuthenticateDomainAccount()) - Button($r('app.string.Domain2')) - .margin(10) - .id('button2') - .onClick(() => this.popupAuthenticateDomainAccount()) - Button('Go to plugin') - .margin(10) - .id('button3') - .onClick(() => { - router.pushUrl({ - url: 'pages/DomainAccount/ManageDomainAccountsPlugin' - }) - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start import_the_system_account_module] +import { osAccount } from '@kit.BasicServicesKit'; +// [End import_the_system_account_module] +import { router } from '@kit.ArkUI'; + +@Entry +@Component +struct AuthenticationDomainAccount { + @State message: string = 'No Message'; + + private async passwordAuthenticateDomainAccount(): Promise { + // [Start get_user_input] + let domainAccountInfo: osAccount.DomainAccountInfo = { + domain: 'CHINA', + accountName: 'zhangsan' + }; + let credential: Uint8Array = new Uint8Array([0]); + // [End get_user_input] + // [Start define_the_callback_for_the_authentication_result] + let callback: osAccount.IUserAuthCallback = { + onResult: (resultCode: number, authResult: osAccount.AuthResult) => { + console.log('auth resultCode = ' + resultCode); + console.log('auth authResult = ' + JSON.stringify(authResult)); + // [StartExclude define_the_callback_for_the_authentication_result] + if(resultCode == 0) { + this.message = 'Successfully authenticated domain account using password'; + } else { + this.message = 'Failed to authenticate domain account using password: ' + resultCode; + } + // [EndExclude define_the_callback_for_the_authentication_result] + + } + }; + // [End define_the_callback_for_the_authentication_result] + // [Start perform_password_authentication] + try { + osAccount.DomainAccountManager.auth(domainAccountInfo, credential, callback); + } catch (err) { + console.error('auth exception = ' + JSON.stringify(err)); + } + // [End perform_password_authentication] + } + + private async popupAuthenticateDomainAccount(): Promise { + // [Start define_the_callback_object_of_the_authentication_result] + let callback: osAccount.IUserAuthCallback = { + onResult: (resultCode: number, authResult: osAccount.AuthResult) => { + console.log('authWithPopup resultCode = ' + resultCode); + console.log('authWithPopup authResult = ' + JSON.stringify(authResult)); + // [StartExclude define_the_callback_object_of_the_authentication_result] + if(resultCode == 0) { + this.message = 'Successfully authenticated domain account using popup'; + } else if(resultCode == 12300003) { + this.message = 'No domain account is bound'; + } else { + this.message = 'Failed to authenticate domain account using popup: ' + resultCode; + } + // [EndExclude define_the_callback_object_of_the_authentication_result] + } + } + // [End define_the_callback_object_of_the_authentication_result] + // [Start call_operation_to_authenticate_the_current_domain_account] + try { + osAccount.DomainAccountManager.authWithPopup(callback) + } catch (err) { + console.error('authWithPopup exception = ' + JSON.stringify(err)); + // [StartExclude call_operation_to_authenticate_the_current_domain_account] + this.message = 'Exception occurred during popup authentication: ' + JSON.stringify(err); + // [EndExclude call_operation_to_authenticate_the_current_domain_account] + } + // [End call_operation_to_authenticate_the_current_domain_account] + } + + build() { + Column() { + Text(this.message) + .id('show') + .fontSize(36) + .fontWeight(FontWeight.Bold) + Button($r('app.string.Domain1')) + .margin(10) + .id('button1') + .onClick(() => this.passwordAuthenticateDomainAccount()) + Button($r('app.string.Domain2')) + .margin(10) + .id('button2') + .onClick(() => this.popupAuthenticateDomainAccount()) + Button('Go to plugin') + .margin(10) + .id('button3') + .onClick(() => { + router.pushUrl({ + url: 'pages/DomainAccount/ManageDomainAccountsPlugin' + }) + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/ManageDomainAccounts.ets b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/ManageDomainAccounts.ets old mode 100755 new mode 100644 index dc886e8430..cc092ac305 --- a/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/ManageDomainAccounts.ets +++ b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/ManageDomainAccounts.ets @@ -1,180 +1,180 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start import_the_system_account_module] -import { osAccount, BusinessError } from '@kit.BasicServicesKit'; -// [End import_the_system_account_module] -import { router } from '@kit.ArkUI'; - -// [Start obtain_the_system_account_management_object] -let osAccountMgr = osAccount.getAccountManager(); -// [End obtain_the_system_account_management_object] - -@Entry -@Component -struct ManageDomainAccounts { - @State message: string = 'Hello World'; - - private async domainAccountExists(): Promise { - // [Start define_the_domain_account_information_to_be_determined] - let domainAccountInfo: osAccount.DomainAccountInfo = { - accountName: 'testAccountName', - domain: 'testDomain' - } - // [End define_the_domain_account_information_to_be_determined] - - // [Start call_the_hasaccount_operation] - let isAccountExisted: boolean = await osAccount.DomainAccountManager.hasAccount(domainAccountInfo); - // [End call_the_hasaccount_operation] - console.log('domainAccount isAccountExisted:' + isAccountExisted); - if(isAccountExisted) { - this.message = 'Domain account already exists'; - } else { - this.message = 'Domain account does not exist'; - } - } - - private async createDomainAccount(): Promise { - // [Start define_the_domain_account_information] - let domainInfo: osAccount.DomainAccountInfo = { - domain: 'testDomain', - accountName: 'testAccountName' - }; - // [End define_the_domain_account_information] - - // [Start create_a_domain_account] - try { - osAccountMgr.createOsAccountForDomain(osAccount.OsAccountType.NORMAL, domainInfo, - (err: BusinessError, osAccountInfo: osAccount.OsAccountInfo)=>{ - console.log('createOsAccountForDomain err:' + JSON.stringify(err)); - console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo)); - // [StartExclude create_a_domain_account] - this.message = 'Account creation information: ' + JSON.stringify(osAccountInfo.localName); - // [EndExclude create_a_domain_account] - }); - } catch (e) { - console.error('createOsAccountForDomain exception: ' + JSON.stringify(e)); - // [StartExclude create_a_domain_account] - this.message = 'Account creation failed: ' + JSON.stringify(e); - // [EndExclude create_a_domain_account] - } - // [End create_a_domain_account] - } - - private async deleteDomainAccount(): Promise { - // [Start obtain_the_system_account_id_based_on_the_domain_account_information] - let domainInfo: osAccount.DomainAccountInfo = { - domain: 'testDomain', - accountName: 'testAccountName' - }; - let localId: number = 0; - try { - localId = await osAccountMgr.getOsAccountLocalIdForDomain(domainInfo); - } catch (err) { - console.error('getOsAccountLocalIdForDomain exception: ' + JSON.stringify(err)); - // [StartExclude obtain_the_system_account_id_based_on_the_domain_account_information] - this.message = 'Failed to get account deletion information: ' + JSON.stringify(err); - // [EndExclude obtain_the_system_account_id_based_on_the_domain_account_information] - } - // [End obtain_the_system_account_id_based_on_the_domain_account_information] - // [Start delete_the_domain_account] - try { - osAccountMgr.removeOsAccount(localId, (err: BusinessError)=>{ - if (err) { - console.log('removeOsAccount failed, error: ' + JSON.stringify(err)); - // [StartExclude delete_the_domain_account] - this.message = 'Failed to delete account: ' + JSON.stringify(err); - // [EndExclude delete_the_domain_account] - } else { - console.log('removeOsAccount successfully'); - // [StartExclude delete_the_domain_account] - this.message = 'Successfully deleted account'; - // [EndExclude delete_the_domain_account] - } - }); - } catch (err) { - console.error('removeOsAccount exception: ' + JSON.stringify(err)); - } - // [End delete_the_domain_account] - - } - - private async queryDomainAccount(): Promise { - // [Start define_query_options] - let options: osAccount.GetDomainAccountInfoOptions = { - domain: 'testDomain', - accountName: 'testAccountName' - } - // [End define_query_options] - // [Start query_the_domain_account_information] - try { - osAccount.DomainAccountManager.getAccountInfo(options, - (err: BusinessError, result: osAccount.DomainAccountInfo) => { - if (err) { - console.log('call getAccountInfo failed, error: ' + JSON.stringify(err)); - // [StartExclude query_the_domain_account_information] - this.message = 'Query failed: ' + JSON.stringify(err); - // [EndExclude query_the_domain_account_information] - } else { - console.log('getAccountInfo result: ' + result); - // [StartExclude query_the_domain_account_information] - this.message = 'Queried account information: ' + JSON.stringify(result.accountName); - // [EndExclude query_the_domain_account_information] - } - }); - } catch (err) { - console.error('getAccountInfo exception = ' + JSON.stringify(err)); - // [StartExclude query_the_domain_account_information] - this.message = 'Failed to query account information: ' + JSON.stringify(err); - // [EndExclude query_the_domain_account_information] - } - // [End query_the_domain_account_information] - } - - build() { - Column() { - Text(this.message) - .id('show') - .fontSize(36) - .fontWeight(FontWeight.Bold) - Button($r('app.string.Domain5')) - .margin(10) - .id('button1') - .onClick(() => this.domainAccountExists()) - Button($r('app.string.Domain6')) - .margin(10) - .id('button2') - .onClick(() => this.createDomainAccount()) - Button($r('app.string.Domain7')) - .margin(10) - .id('button3') - .onClick(() => this.deleteDomainAccount()) - Button($r('app.string.Domain8')) - .margin(10) - .id('button4') - .onClick(() => this.queryDomainAccount()) - Button('Go to AuthenticationDomainAccount') - .margin(10) - .id('button5') - .onClick(() => { - router.pushUrl({ - url: 'pages/DomainAccount/AuthenticationDomainAccount' - }) - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start import_the_system_account_module] +import { osAccount, BusinessError } from '@kit.BasicServicesKit'; +// [End import_the_system_account_module] +import { router } from '@kit.ArkUI'; + +// [Start obtain_the_system_account_management_object] +let osAccountMgr = osAccount.getAccountManager(); +// [End obtain_the_system_account_management_object] + +@Entry +@Component +struct ManageDomainAccounts { + @State message: string = 'Hello World'; + + private async domainAccountExists(): Promise { + // [Start define_the_domain_account_information_to_be_determined] + let domainAccountInfo: osAccount.DomainAccountInfo = { + accountName: 'testAccountName', + domain: 'testDomain' + } + // [End define_the_domain_account_information_to_be_determined] + + // [Start call_the_hasaccount_operation] + let isAccountExisted: boolean = await osAccount.DomainAccountManager.hasAccount(domainAccountInfo); + // [End call_the_hasaccount_operation] + console.log('domainAccount isAccountExisted:' + isAccountExisted); + if(isAccountExisted) { + this.message = 'Domain account already exists'; + } else { + this.message = 'Domain account does not exist'; + } + } + + private async createDomainAccount(): Promise { + // [Start define_the_domain_account_information] + let domainInfo: osAccount.DomainAccountInfo = { + domain: 'testDomain', + accountName: 'testAccountName' + }; + // [End define_the_domain_account_information] + + // [Start create_a_domain_account] + try { + osAccountMgr.createOsAccountForDomain(osAccount.OsAccountType.NORMAL, domainInfo, + (err: BusinessError, osAccountInfo: osAccount.OsAccountInfo)=>{ + console.log('createOsAccountForDomain err:' + JSON.stringify(err)); + console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo)); + // [StartExclude create_a_domain_account] + this.message = 'Account creation information: ' + JSON.stringify(osAccountInfo.localName); + // [EndExclude create_a_domain_account] + }); + } catch (e) { + console.error('createOsAccountForDomain exception: ' + JSON.stringify(e)); + // [StartExclude create_a_domain_account] + this.message = 'Account creation failed: ' + JSON.stringify(e); + // [EndExclude create_a_domain_account] + } + // [End create_a_domain_account] + } + + private async deleteDomainAccount(): Promise { + // [Start obtain_the_system_account_id_based_on_the_domain_account_information] + let domainInfo: osAccount.DomainAccountInfo = { + domain: 'testDomain', + accountName: 'testAccountName' + }; + let localId: number = 0; + try { + localId = await osAccountMgr.getOsAccountLocalIdForDomain(domainInfo); + } catch (err) { + console.error('getOsAccountLocalIdForDomain exception: ' + JSON.stringify(err)); + // [StartExclude obtain_the_system_account_id_based_on_the_domain_account_information] + this.message = 'Failed to get account deletion information: ' + JSON.stringify(err); + // [EndExclude obtain_the_system_account_id_based_on_the_domain_account_information] + } + // [End obtain_the_system_account_id_based_on_the_domain_account_information] + // [Start delete_the_domain_account] + try { + osAccountMgr.removeOsAccount(localId, (err: BusinessError)=>{ + if (err) { + console.log('removeOsAccount failed, error: ' + JSON.stringify(err)); + // [StartExclude delete_the_domain_account] + this.message = 'Failed to delete account: ' + JSON.stringify(err); + // [EndExclude delete_the_domain_account] + } else { + console.log('removeOsAccount successfully'); + // [StartExclude delete_the_domain_account] + this.message = 'Successfully deleted account'; + // [EndExclude delete_the_domain_account] + } + }); + } catch (err) { + console.error('removeOsAccount exception: ' + JSON.stringify(err)); + } + // [End delete_the_domain_account] + + } + + private async queryDomainAccount(): Promise { + // [Start define_query_options] + let options: osAccount.GetDomainAccountInfoOptions = { + domain: 'testDomain', + accountName: 'testAccountName' + } + // [End define_query_options] + // [Start query_the_domain_account_information] + try { + osAccount.DomainAccountManager.getAccountInfo(options, + (err: BusinessError, result: osAccount.DomainAccountInfo) => { + if (err) { + console.log('call getAccountInfo failed, error: ' + JSON.stringify(err)); + // [StartExclude query_the_domain_account_information] + this.message = 'Query failed: ' + JSON.stringify(err); + // [EndExclude query_the_domain_account_information] + } else { + console.log('getAccountInfo result: ' + result); + // [StartExclude query_the_domain_account_information] + this.message = 'Queried account information: ' + JSON.stringify(result.accountName); + // [EndExclude query_the_domain_account_information] + } + }); + } catch (err) { + console.error('getAccountInfo exception = ' + JSON.stringify(err)); + // [StartExclude query_the_domain_account_information] + this.message = 'Failed to query account information: ' + JSON.stringify(err); + // [EndExclude query_the_domain_account_information] + } + // [End query_the_domain_account_information] + } + + build() { + Column() { + Text(this.message) + .id('show') + .fontSize(36) + .fontWeight(FontWeight.Bold) + Button($r('app.string.Domain5')) + .margin(10) + .id('button1') + .onClick(() => this.domainAccountExists()) + Button($r('app.string.Domain6')) + .margin(10) + .id('button2') + .onClick(() => this.createDomainAccount()) + Button($r('app.string.Domain7')) + .margin(10) + .id('button3') + .onClick(() => this.deleteDomainAccount()) + Button($r('app.string.Domain8')) + .margin(10) + .id('button4') + .onClick(() => this.queryDomainAccount()) + Button('Go to AuthenticationDomainAccount') + .margin(10) + .id('button5') + .onClick(() => { + router.pushUrl({ + url: 'pages/DomainAccount/AuthenticationDomainAccount' + }) + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/ManageDomainAccountsPlugin.ets b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/ManageDomainAccountsPlugin.ets index 9b1421aa70..8c9ad0bae9 100644 --- a/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/ManageDomainAccountsPlugin.ets +++ b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/DomainAccount/ManageDomainAccountsPlugin.ets @@ -1,207 +1,207 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start import_the_system_account_module] -import { osAccount, AsyncCallback, BusinessError } from '@kit.BasicServicesKit'; -// [End import_the_system_account_module] -import { router } from '@kit.ArkUI'; - -// [Start define_the_plug_in] -let plugin: osAccount.DomainPlugin = { - auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array, - callback: osAccount.IUserAuthCallback) => { - console.info('plugin auth domain' + domainAccountInfo.domain); - console.info('plugin auth accountName' + domainAccountInfo.accountName); - console.info('plugin auth accountId' + domainAccountInfo.accountId); - - let result: osAccount.AuthResult = { - token: new Uint8Array([0]), - remainTimes: 5, - freezingTime: 0 - }; - callback.onResult(0, result); - }, - authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo, - callback: osAccount.IUserAuthCallback) => { - console.info('plugin authWithPopup domain' + domainAccountInfo.domain); - console.info('plugin authWithPopup accountName' + domainAccountInfo.accountName); - console.info('plugin authWithPopup accountId' + domainAccountInfo.accountId); - - let result: osAccount.AuthResult = { - token: new Uint8Array([0]), - remainTimes: 5, - freezingTime: 0 - }; - callback.onResult(0, result); - }, - authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, - token: Uint8Array, callback: osAccount.IUserAuthCallback) => { - console.info('plugin authWithToken domain' + domainAccountInfo.domain); - console.info('plugin authWithToken accountName' + domainAccountInfo.accountName); - console.info('plugin authWithToken accountId' + domainAccountInfo.accountId); - let result: osAccount.AuthResult = { - token: new Uint8Array([0]), - remainTimes: 5, - freezingTime: 0 - }; - callback.onResult(0, result); - }, - getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions, - callback: AsyncCallback) => { - console.info('plugin getAccountInfo domain'); - let domainAccountId = Date.now().toString(); - let code: BusinessError = { - code: 0, - name: 'mock_name', - message: 'mock_message' - }; - let domainStr: string = ''; - if (options.domain != undefined) { - domainStr = options.domain - } - let accountInfo: osAccount.DomainAccountInfo = { - domain: domainStr, - accountName: options.accountName, - accountId: domainAccountId, - isAuthenticated: false - }; - callback(code, accountInfo); - }, - getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo, - callback: AsyncCallback) => { - - console.info('plugin getAuthStatusInfo domain' + domainAccountInfo.domain); - console.info('plugin getAuthStatusInfo accountName' + domainAccountInfo.accountName); - console.info('plugin getAuthStatusInfo accountId' + domainAccountInfo.accountId); - - let code: BusinessError = { - code: 0, - name: 'mock_name', - message: 'mock_message' - }; - let statusInfo: osAccount.AuthStatusInfo = { - remainTimes: 5, - freezingTime: 0 - }; - callback(code, statusInfo); - }, - bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number, - callback: AsyncCallback) => { - console.info('plugin bindAccount domain' + domainAccountInfo.domain); - console.info('plugin bindAccount accountName' + domainAccountInfo.accountName); - console.info('plugin bindAccount accountId' + domainAccountInfo.accountId); - let code: BusinessError = { - code: 0, - name: 'mock_name', - message: 'mock_message' - }; - callback(code); - }, - unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback) => { - console.info('plugin unbindAccount domain' + domainAccountInfo.domain); - console.info('plugin unbindAccount accountName' + domainAccountInfo.accountName); - console.info('plugin unbindAccount accountId' + domainAccountInfo.accountId); - }, - isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array, - callback: AsyncCallback) => { - console.info('plugin isAccountTokenValid domain' + domainAccountInfo.domain); - console.info('plugin isAccountTokenValid accountName' + domainAccountInfo.accountName); - console.info('plugin isAccountTokenValid accountId' + domainAccountInfo.accountId); - let code: BusinessError = { - code: 0, - name: 'mock_name', - message: 'mock_message' - }; - callback(code, true); - }, - getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback) => { - console.info('plugin getAccessToken domain') - let code: BusinessError = { - code: 0, - name: 'mock_name', - message: 'mock_message' - }; - let token: Uint8Array = new Uint8Array([0]); - callback(code, token); - } -} -// [End define_the_plug_in] - - -@Entry -@Component -struct ManageDomainAccountsPlugin { - @State message: string = 'Manage domain account plugin'; - - private async registrationPlugin(): Promise { - // [Start call_the_api_to_register_the_plug_in] - try { - osAccount.DomainAccountManager.registerPlugin(plugin) - console.info('registerPlugin success'); - // [StartExclude call_the_api_to_register_the_plug_in] - this.message = 'Successfully registered plugin'; - // [EndExclude call_the_api_to_register_the_plug_in] - } catch (err) { - console.error('registerPlugin err: ' + JSON.stringify(err)); - // [StartExclude call_the_api_to_register_the_plug_in] - this.message = 'Failed to register plugin: ' + JSON.stringify(err); - // [EndExclude call_the_api_to_register_the_plug_in] - } - // [End call_the_api_to_register_the_plug_in] - } - - private async logoutPlugin(): Promise { - // [Start call_the_api_to_log_out_the_plug_in] - try { - osAccount.DomainAccountManager.unregisterPlugin(); - console.log('unregisterPlugin success.'); - // [StartExclude call_the_api_to_log_out_the_plug_in] - this.message = 'unregisterPlugin success'; - // [EndExclude call_the_api_to_log_out_the_plug_in] - } catch(err) { - console.error('unregisterPlugin err:' + JSON.stringify(err)); - // [StartExclude call_the_api_to_log_out_the_plug_in] - this.message = 'Failed to unregister plugin: ' + JSON.stringify(err); - // [EndExclude call_the_api_to_log_out_the_plug_in] - } - // [End call_the_api_to_log_out_the_plug_in] - } - - build() { - Column() { - Text(this.message) - .id('show') - .fontSize(36) - .fontWeight(FontWeight.Bold) - Button($r('app.string.Domain3')) - .margin(10) - .id('button1') - .onClick(() => this.registrationPlugin()) - Button($r('app.string.Domain4')) - .margin(10) - .id('button2') - .onClick(() => this.logoutPlugin()) - Button('Return back') - .id('button3') - .onClick(() => { - router.pushUrl({ - url: 'pages/DomainAccount/ManageDomainAccounts' - }) - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start import_the_system_account_module] +import { osAccount, AsyncCallback, BusinessError } from '@kit.BasicServicesKit'; +// [End import_the_system_account_module] +import { router } from '@kit.ArkUI'; + +// [Start define_the_plug_in] +let plugin: osAccount.DomainPlugin = { + auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array, + callback: osAccount.IUserAuthCallback) => { + console.info('plugin auth domain' + domainAccountInfo.domain); + console.info('plugin auth accountName' + domainAccountInfo.accountName); + console.info('plugin auth accountId' + domainAccountInfo.accountId); + + let result: osAccount.AuthResult = { + token: new Uint8Array([0]), + remainTimes: 5, + freezingTime: 0 + }; + callback.onResult(0, result); + }, + authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo, + callback: osAccount.IUserAuthCallback) => { + console.info('plugin authWithPopup domain' + domainAccountInfo.domain); + console.info('plugin authWithPopup accountName' + domainAccountInfo.accountName); + console.info('plugin authWithPopup accountId' + domainAccountInfo.accountId); + + let result: osAccount.AuthResult = { + token: new Uint8Array([0]), + remainTimes: 5, + freezingTime: 0 + }; + callback.onResult(0, result); + }, + authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, + token: Uint8Array, callback: osAccount.IUserAuthCallback) => { + console.info('plugin authWithToken domain' + domainAccountInfo.domain); + console.info('plugin authWithToken accountName' + domainAccountInfo.accountName); + console.info('plugin authWithToken accountId' + domainAccountInfo.accountId); + let result: osAccount.AuthResult = { + token: new Uint8Array([0]), + remainTimes: 5, + freezingTime: 0 + }; + callback.onResult(0, result); + }, + getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions, + callback: AsyncCallback) => { + console.info('plugin getAccountInfo domain'); + let domainAccountId = Date.now().toString(); + let code: BusinessError = { + code: 0, + name: 'mock_name', + message: 'mock_message' + }; + let domainStr: string = ''; + if (options.domain != undefined) { + domainStr = options.domain + } + let accountInfo: osAccount.DomainAccountInfo = { + domain: domainStr, + accountName: options.accountName, + accountId: domainAccountId, + isAuthenticated: false + }; + callback(code, accountInfo); + }, + getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo, + callback: AsyncCallback) => { + + console.info('plugin getAuthStatusInfo domain' + domainAccountInfo.domain); + console.info('plugin getAuthStatusInfo accountName' + domainAccountInfo.accountName); + console.info('plugin getAuthStatusInfo accountId' + domainAccountInfo.accountId); + + let code: BusinessError = { + code: 0, + name: 'mock_name', + message: 'mock_message' + }; + let statusInfo: osAccount.AuthStatusInfo = { + remainTimes: 5, + freezingTime: 0 + }; + callback(code, statusInfo); + }, + bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number, + callback: AsyncCallback) => { + console.info('plugin bindAccount domain' + domainAccountInfo.domain); + console.info('plugin bindAccount accountName' + domainAccountInfo.accountName); + console.info('plugin bindAccount accountId' + domainAccountInfo.accountId); + let code: BusinessError = { + code: 0, + name: 'mock_name', + message: 'mock_message' + }; + callback(code); + }, + unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback) => { + console.info('plugin unbindAccount domain' + domainAccountInfo.domain); + console.info('plugin unbindAccount accountName' + domainAccountInfo.accountName); + console.info('plugin unbindAccount accountId' + domainAccountInfo.accountId); + }, + isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array, + callback: AsyncCallback) => { + console.info('plugin isAccountTokenValid domain' + domainAccountInfo.domain); + console.info('plugin isAccountTokenValid accountName' + domainAccountInfo.accountName); + console.info('plugin isAccountTokenValid accountId' + domainAccountInfo.accountId); + let code: BusinessError = { + code: 0, + name: 'mock_name', + message: 'mock_message' + }; + callback(code, true); + }, + getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback) => { + console.info('plugin getAccessToken domain') + let code: BusinessError = { + code: 0, + name: 'mock_name', + message: 'mock_message' + }; + let token: Uint8Array = new Uint8Array([0]); + callback(code, token); + } +} +// [End define_the_plug_in] + + +@Entry +@Component +struct ManageDomainAccountsPlugin { + @State message: string = 'Manage domain account plugin'; + + private async registrationPlugin(): Promise { + // [Start call_the_api_to_register_the_plug_in] + try { + osAccount.DomainAccountManager.registerPlugin(plugin) + console.info('registerPlugin success'); + // [StartExclude call_the_api_to_register_the_plug_in] + this.message = 'Successfully registered plugin'; + // [EndExclude call_the_api_to_register_the_plug_in] + } catch (err) { + console.error('registerPlugin err: ' + JSON.stringify(err)); + // [StartExclude call_the_api_to_register_the_plug_in] + this.message = 'Failed to register plugin: ' + JSON.stringify(err); + // [EndExclude call_the_api_to_register_the_plug_in] + } + // [End call_the_api_to_register_the_plug_in] + } + + private async logoutPlugin(): Promise { + // [Start call_the_api_to_log_out_the_plug_in] + try { + osAccount.DomainAccountManager.unregisterPlugin(); + console.log('unregisterPlugin success.'); + // [StartExclude call_the_api_to_log_out_the_plug_in] + this.message = 'unregisterPlugin success'; + // [EndExclude call_the_api_to_log_out_the_plug_in] + } catch(err) { + console.error('unregisterPlugin err:' + JSON.stringify(err)); + // [StartExclude call_the_api_to_log_out_the_plug_in] + this.message = 'Failed to unregister plugin: ' + JSON.stringify(err); + // [EndExclude call_the_api_to_log_out_the_plug_in] + } + // [End call_the_api_to_log_out_the_plug_in] + } + + build() { + Column() { + Text(this.message) + .id('show') + .fontSize(36) + .fontWeight(FontWeight.Bold) + Button($r('app.string.Domain3')) + .margin(10) + .id('button1') + .onClick(() => this.registrationPlugin()) + Button($r('app.string.Domain4')) + .margin(10) + .id('button2') + .onClick(() => this.logoutPlugin()) + Button('Return back') + .id('button3') + .onClick(() => { + router.pushUrl({ + url: 'pages/DomainAccount/ManageDomainAccounts' + }) + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/Account/DomainAccount/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/module.json5 b/code/DocsSample/Account/DomainAccount/entry/src/main/module.json5 old mode 100755 new mode 100644 index 269eca939a..ce3f0e8582 --- a/code/DocsSample/Account/DomainAccount/entry/src/main/module.json5 +++ b/code/DocsSample/Account/DomainAccount/entry/src/main/module.json5 @@ -1,76 +1,76 @@ -/* - * 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": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "requestPermissions": [{ - "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", - }, - { - "name": "ohos.permission.GET_DOMAIN_ACCOUNTS", - }, - { - "name": "ohos.permission.ACCESS_USER_AUTH_INTERNAL", - }], - "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" - } - ], - } - ] - } +/* + * 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": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "requestPermissions": [{ + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", + }, + { + "name": "ohos.permission.GET_DOMAIN_ACCOUNTS", + }, + { + "name": "ohos.permission.ACCESS_USER_AUTH_INTERNAL", + }], + "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/Account/DomainAccount/entry/src/main/resources/base/element/color.json b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/element/string.json b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/background.png b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Account/DomainAccount/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Account/DomainAccount/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/DomainAccount/entry/src/mock/mock-config.json5 b/code/DocsSample/Account/DomainAccount/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Account/DomainAccount/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/ohosTest/module.json5 b/code/DocsSample/Account/DomainAccount/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index c8bd24faff..6b9889e8cc --- a/code/DocsSample/Account/DomainAccount/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Account/DomainAccount/entry/src/ohosTest/module.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Account/DomainAccount/entry/src/test/List.test.ets b/code/DocsSample/Account/DomainAccount/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Account/DomainAccount/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/hvigor/hvigor-config.json5 b/code/DocsSample/Account/DomainAccount/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Account/DomainAccount/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Account/DomainAccount/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Account/DomainAccount/hvigorfile.ts b/code/DocsSample/Account/DomainAccount/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/oh-package.json5 b/code/DocsSample/Account/DomainAccount/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Account/DomainAccount/oh-package.json5 +++ b/code/DocsSample/Account/DomainAccount/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Account/DomainAccount/ohosTest.md b/code/DocsSample/Account/DomainAccount/ohosTest.md old mode 100755 new mode 100644 index 3145d43fc6..0631be022a --- a/code/DocsSample/Account/DomainAccount/ohosTest.md +++ b/code/DocsSample/Account/DomainAccount/ohosTest.md @@ -1,15 +1,15 @@ -# DomainAccount 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------- | ----------------------------------------------- | ----------------------------- | --------------------------------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 注册插件 | 位于ManageDomainAccountsPlugin页面 | 点击‘Register plugin’ | 页面显示“Successfully registered plugin” | 是 | Pass | -| 注销插件 | 位于ManageDomainAccountsPlugin页面 | 点击‘Register plugin’ | 页面显示“unregisterPlugin success“ | 是 | Pass | -| Check if the specified domain account exists | 位于ManageDomainAccounts页面,已注册插件 | 点击‘ Check if the specified domain account exists’ | 页面显示“Domain account already exists“ | 是 | Pass | -| Add domain account | 位于ManageDomainAccounts页面,已注册插件 | 点击‘Add domain account’ | 页面显示“Account creation information: "testAccountName"“ | 是 | Pass | -| Delete domain account | 位于ManageDomainAccounts页面,已注册插件 | 点击‘Delete domain account’ | 页面显示“Successfully deleted account“ | 是 | Pass | -| Query domain account information | 位于ManageDomainAccounts页面,已注册插件 | 点击‘Query domain account information’ | 页面显示“Queried account information: "testAccountName"“ | 是 | Pass | -| Authenticate domain account using password | 位于AuthenticationDomainAccount页面,已注册插件 | 点击‘使用密码进行认证’ | 页面显示“Successfully authenticated domain account using password“ | 是 | Pass | +# DomainAccount 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------- | ----------------------------------------------- | ----------------------------- | --------------------------------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 注册插件 | 位于ManageDomainAccountsPlugin页面 | 点击‘Register plugin’ | 页面显示“Successfully registered plugin” | 是 | Pass | +| 注销插件 | 位于ManageDomainAccountsPlugin页面 | 点击‘Register plugin’ | 页面显示“unregisterPlugin success“ | 是 | Pass | +| Check if the specified domain account exists | 位于ManageDomainAccounts页面,已注册插件 | 点击‘ Check if the specified domain account exists’ | 页面显示“Domain account already exists“ | 是 | Pass | +| Add domain account | 位于ManageDomainAccounts页面,已注册插件 | 点击‘Add domain account’ | 页面显示“Account creation information: "testAccountName"“ | 是 | Pass | +| Delete domain account | 位于ManageDomainAccounts页面,已注册插件 | 点击‘Delete domain account’ | 页面显示“Successfully deleted account“ | 是 | Pass | +| Query domain account information | 位于ManageDomainAccounts页面,已注册插件 | 点击‘Query domain account information’ | 页面显示“Queried account information: "testAccountName"“ | 是 | Pass | +| Authenticate domain account using password | 位于AuthenticationDomainAccount页面,已注册插件 | 点击‘使用密码进行认证’ | 页面显示“Successfully authenticated domain account using password“ | 是 | Pass | | Authenticate domain account using popup | 位于AuthenticationDomainAccount页面,已注册插件 | 点击‘Authenticate domain account using popup’ | 页面显示"No domain account is bound" | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_1.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_10.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_10.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_11.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_11.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_12.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_12.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_2.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_3.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_3.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_4.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_4.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_5.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_5.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_6.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_6.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_7.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_7.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_8.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_8.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_9.png b/code/DocsSample/Account/DomainAccount/screenshots/DomainAccount_9.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/.gitignore b/code/DocsSample/Account/ManageDistributedAccount/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/AppScope/app.json5 b/code/DocsSample/Account/ManageDistributedAccount/AppScope/app.json5 old mode 100755 new mode 100644 index d6cb5185f0..c95d19eb65 --- a/code/DocsSample/Account/ManageDistributedAccount/AppScope/app.json5 +++ b/code/DocsSample/Account/ManageDistributedAccount/AppScope/app.json5 @@ -1,25 +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.managedistributedaccount", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.managedistributedaccount", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Account/ManageDistributedAccount/AppScope/resources/base/element/string.json b/code/DocsSample/Account/ManageDistributedAccount/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 975d8e8814..9d32d7a58a --- a/code/DocsSample/Account/ManageDistributedAccount/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Account/ManageDistributedAccount/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ManageDistributedAccount" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ManageDistributedAccount" + } + ] +} diff --git a/code/DocsSample/Account/ManageDistributedAccount/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Account/ManageDistributedAccount/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/README.md b/code/DocsSample/Account/ManageDistributedAccount/README.md index 1bfe0aeada..bdbf9664ff 100644 --- a/code/DocsSample/Account/ManageDistributedAccount/README.md +++ b/code/DocsSample/Account/ManageDistributedAccount/README.md @@ -1,71 +1,71 @@ -# 管理分布式账号(仅对系统应用开放) - -### 介绍 - -1.OEM厂商可以通过[分布式账号SDK](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-distributed-account.md)将自有账号与本地系统账号建立关联关系。 - -2.实现对以下指南文档中 [管理分布式账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-distributed-account.md) 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。 - -### 效果预览 - -| 首页 | 执行Log in and bind distributed account on the current system account | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | -| **执行Log out and unbind distributed account on the current system account** | **执行Log in and bind distributed account on the specified system account** | -| | | -| **执行Log out and unbind distributed account on the specified system account** | | -| | | - -### 使用说明 - -1. 在主界面,点击'Log in and bind distributed account on the current system account',执行Log in and bind distributed account on the current system account。 -2. 点击'Log out and unbind distributed account on the current system account',执行Log out and unbind distributed account on the current system account。 -3. 点击'Log in and bind distributed account on the specified system account',执行Log in and bind distributed account on the specified system account。 -4. 点击'Log out and unbind distributed account on the specified system account',执行Log out and unbind distributed account on the specified system account。 -5. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ └── pages - │ │ └── Index.ets // 管理分布式账号示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ └── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -[ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanagedistributedaccounts) - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Account/ManageDistributedAccount > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 管理分布式账号(仅对系统应用开放) + +### 介绍 + +1.OEM厂商可以通过[分布式账号SDK](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-distributed-account.md)将自有账号与本地系统账号建立关联关系。 + +2.实现对以下指南文档中 [管理分布式账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-distributed-account.md) 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。 + +### 效果预览 + +| 首页 | 执行Log in and bind distributed account on the current system account | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | +| **执行Log out and unbind distributed account on the current system account** | **执行Log in and bind distributed account on the specified system account** | +| | | +| **执行Log out and unbind distributed account on the specified system account** | | +| | | + +### 使用说明 + +1. 在主界面,点击'Log in and bind distributed account on the current system account',执行Log in and bind distributed account on the current system account。 +2. 点击'Log out and unbind distributed account on the current system account',执行Log out and unbind distributed account on the current system account。 +3. 点击'Log in and bind distributed account on the specified system account',执行Log in and bind distributed account on the specified system account。 +4. 点击'Log out and unbind distributed account on the specified system account',执行Log out and unbind distributed account on the specified system account。 +5. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ └── pages + │ │ └── Index.ets // 管理分布式账号示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ └── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +[ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanagedistributedaccounts) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Account/ManageDistributedAccount > .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/Account/ManageDistributedAccount/build-profile.json5 b/code/DocsSample/Account/ManageDistributedAccount/build-profile.json5 old mode 100755 new mode 100644 index 3c1dc3a4c6..5f84e07910 --- a/code/DocsSample/Account/ManageDistributedAccount/build-profile.json5 +++ b/code/DocsSample/Account/ManageDistributedAccount/build-profile.json5 @@ -1,52 +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" - ] - } - ] - } - ] +/* + * 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/Account/ManageDistributedAccount/code-linter.json5 b/code/DocsSample/Account/ManageDistributedAccount/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/.gitignore b/code/DocsSample/Account/ManageDistributedAccount/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/build-profile.json5 b/code/DocsSample/Account/ManageDistributedAccount/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Account/ManageDistributedAccount/entry/build-profile.json5 +++ b/code/DocsSample/Account/ManageDistributedAccount/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/hvigorfile.ts b/code/DocsSample/Account/ManageDistributedAccount/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/obfuscation-rules.txt b/code/DocsSample/Account/ManageDistributedAccount/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/oh-package.json5 b/code/DocsSample/Account/ManageDistributedAccount/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Account/ManageDistributedAccount/entry/oh-package.json5 +++ b/code/DocsSample/Account/ManageDistributedAccount/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Account/ManageDistributedAccount/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Account/ManageDistributedAccount/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/module.json5 b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/module.json5 old mode 100755 new mode 100644 index f16c302eb9..a54bd3996e --- a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/module.json5 +++ b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/module.json5 @@ -1,70 +1,70 @@ -/* - * 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": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "requestPermissions": [{ - "name": "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS", - }], - "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" - } - ], - } - ] - } +/* + * 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": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "requestPermissions": [{ + "name": "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS", + }], + "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/Account/ManageDistributedAccount/entry/src/main/resources/base/element/color.json b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/element/string.json b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/background.png b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Account/ManageDistributedAccount/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/mock/mock-config.json5 b/code/DocsSample/Account/ManageDistributedAccount/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Account/ManageDistributedAccount/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/ohosTest/module.json5 b/code/DocsSample/Account/ManageDistributedAccount/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index c8bd24faff..6b9889e8cc --- a/code/DocsSample/Account/ManageDistributedAccount/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Account/ManageDistributedAccount/entry/src/ohosTest/module.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/test/List.test.ets b/code/DocsSample/Account/ManageDistributedAccount/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Account/ManageDistributedAccount/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/hvigor/hvigor-config.json5 b/code/DocsSample/Account/ManageDistributedAccount/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Account/ManageDistributedAccount/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Account/ManageDistributedAccount/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Account/ManageDistributedAccount/hvigorfile.ts b/code/DocsSample/Account/ManageDistributedAccount/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/oh-package.json5 b/code/DocsSample/Account/ManageDistributedAccount/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Account/ManageDistributedAccount/oh-package.json5 +++ b/code/DocsSample/Account/ManageDistributedAccount/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Account/ManageDistributedAccount/ohosTest.md b/code/DocsSample/Account/ManageDistributedAccount/ohosTest.md old mode 100755 new mode 100644 index 6a829ef97b..364f669fd1 --- a/code/DocsSample/Account/ManageDistributedAccount/ohosTest.md +++ b/code/DocsSample/Account/ManageDistributedAccount/ohosTest.md @@ -1,11 +1,11 @@ -# ManageDistributedAccount 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------ | ------------ | ------------------------------------------ | -------------------------------------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| Log in and bind distributed account on the current system account | 位于首页 | 点击'Log in and bind distributed account on the current system account' | 页面显示'Bind distributed account: ZhangSan' | 是 | Pass | -| Log out and unbind distributed account on the current system account | 位于首页 | 点击'Log out and unbind distributed account on the current system account' | 页面显示'Successfully unbound distributed account' | 是 | Pass | -| Log in and bind distributed account on the specified system account | 位于首页 | 点击'Log in and bind distributed account on the specified system account' | 页面显示'指定的系统账号上Bind distributed account: ZhangSan' | 是 | Pass | +# ManageDistributedAccount 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------ | ------------ | ------------------------------------------ | -------------------------------------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| Log in and bind distributed account on the current system account | 位于首页 | 点击'Log in and bind distributed account on the current system account' | 页面显示'Bind distributed account: ZhangSan' | 是 | Pass | +| Log out and unbind distributed account on the current system account | 位于首页 | 点击'Log out and unbind distributed account on the current system account' | 页面显示'Successfully unbound distributed account' | 是 | Pass | +| Log in and bind distributed account on the specified system account | 位于首页 | 点击'Log in and bind distributed account on the specified system account' | 页面显示'指定的系统账号上Bind distributed account: ZhangSan' | 是 | Pass | | Log out and unbind distributed account on the specified system account | 位于首页 | 点击'Log out and unbind distributed account on the specified system account' | 页面显示'指定系统账号上登出Successfully unbound distributed account' | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_1.png b/code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_2.png b/code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_3.png b/code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_3.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_4.png b/code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_4.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_5.png b/code/DocsSample/Account/ManageDistributedAccount/screenshots/ManageDistributedAccount_5.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/.gitignore b/code/DocsSample/Account/ManageSystemAccountCredentials/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/app.json5 b/code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/app.json5 old mode 100755 new mode 100644 index d3142d219c..67a573f300 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/app.json5 +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/app.json5 @@ -1,25 +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.managesystemaccountcredentials", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.managesystemaccountcredentials", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/resources/base/element/string.json b/code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index ed0031b272..249189f140 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ManageSystemAccountCredentials" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ManageSystemAccountCredentials" + } + ] +} diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Account/ManageSystemAccountCredentials/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/README.md b/code/DocsSample/Account/ManageSystemAccountCredentials/README.md index cda2b5fac4..d136ff0b61 100644 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/README.md +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/README.md @@ -1,80 +1,80 @@ -# 管理系统账号凭据 - -### 介绍 - -凭据可用于认证用户的身份,本文档将介绍如何录入、认证、更新、查询和删除指定系统账号的凭据。 - -该工程中展示的代码详细描述可查如下链接: - -- [ 管理系统账号凭据](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-os-account-credential.md) - -### 效果预览 - -| 首页 | 执行录入PIN码 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | -| 执行认证PIN码 | 执行更新凭据 | -| | | -| 执行查询凭据信息 | 执行删除凭据 | -| | | - -### 使用说明 - -1. 在主界面,点击'Enter PIN code',执行录入PIN码。 -2. 点击'Authenticate PIN code',执行认证PIN码。 -3. 点击'Update credentials',执行更新凭据。 -4. 点击'Query credential information',执行查询凭据信息。 -5. 点击'Delete credentials',执行删除凭据。 -6. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 管理系统账号凭据示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -[ohos.permission.MANAGE_USER_IDM](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanageuseridm) - -[ohos.permission.ACCESS_PIN_AUTH](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionaccesspinauth) - -[ohos.permission.ACCESS_USER_AUTH_INTERNAL](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionaccessuserauthinternal) - -[ohos.permission.USE_USER_IDM](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionuseuseridm) - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Account/ManageSystemAccountCredentials > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 管理系统账号凭据 + +### 介绍 + +凭据可用于认证用户的身份,本文档将介绍如何录入、认证、更新、查询和删除指定系统账号的凭据。 + +该工程中展示的代码详细描述可查如下链接: + +- [ 管理系统账号凭据](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-os-account-credential.md) + +### 效果预览 + +| 首页 | 执行录入PIN码 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | +| 执行认证PIN码 | 执行更新凭据 | +| | | +| 执行查询凭据信息 | 执行删除凭据 | +| | | + +### 使用说明 + +1. 在主界面,点击'Enter PIN code',执行录入PIN码。 +2. 点击'Authenticate PIN code',执行认证PIN码。 +3. 点击'Update credentials',执行更新凭据。 +4. 点击'Query credential information',执行查询凭据信息。 +5. 点击'Delete credentials',执行删除凭据。 +6. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 管理系统账号凭据示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +[ohos.permission.MANAGE_USER_IDM](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanageuseridm) + +[ohos.permission.ACCESS_PIN_AUTH](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionaccesspinauth) + +[ohos.permission.ACCESS_USER_AUTH_INTERNAL](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionaccessuserauthinternal) + +[ohos.permission.USE_USER_IDM](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionuseuseridm) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Account/ManageSystemAccountCredentials > .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/Account/ManageSystemAccountCredentials/build-profile.json5 b/code/DocsSample/Account/ManageSystemAccountCredentials/build-profile.json5 old mode 100755 new mode 100644 index a33a4782e9..3777455b48 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/build-profile.json5 +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/code-linter.json5 b/code/DocsSample/Account/ManageSystemAccountCredentials/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/.gitignore b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/build-profile.json5 b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/build-profile.json5 +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/hvigorfile.ts b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/obfuscation-rules.txt b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/oh-package.json5 b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/oh-package.json5 +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Account/ManageSystemAccountCredentials/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Account/ManageSystemAccountCredentials/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/module.json5 b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/module.json5 index 347fa0676c..8cd8b933e3 100644 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/module.json5 +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/module.json5 @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry", - "type": "entry", - "description": "$string:module_desc", - "mainElement": "EntryAbility", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "requestPermissions": [{ - "name": "ohos.permission.MANAGE_USER_IDM", - }, - { - "name": "ohos.permission.ACCESS_PIN_AUTH", - }, - { - "name": "ohos.permission.ACCESS_USER_AUTH_INTERNAL", - }, - { - "name": "ohos.permission.USE_USER_IDM", - } - ], - "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" - } - ] - } - ] - } +/* + * 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": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "requestPermissions": [{ + "name": "ohos.permission.MANAGE_USER_IDM", + }, + { + "name": "ohos.permission.ACCESS_PIN_AUTH", + }, + { + "name": "ohos.permission.ACCESS_USER_AUTH_INTERNAL", + }, + { + "name": "ohos.permission.USE_USER_IDM", + } + ], + "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/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/element/color.json b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/element/string.json b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/background.png b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/mock/mock-config.json5 b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/ohosTest/module.json5 b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index c8bd24faff..6b9889e8cc --- a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/ohosTest/module.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/test/List.test.ets b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Account/ManageSystemAccountCredentials/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/hvigor/hvigor-config.json5 b/code/DocsSample/Account/ManageSystemAccountCredentials/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Account/ManageSystemAccountCredentials/hvigorfile.ts b/code/DocsSample/Account/ManageSystemAccountCredentials/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/oh-package.json5 b/code/DocsSample/Account/ManageSystemAccountCredentials/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Account/ManageSystemAccountCredentials/oh-package.json5 +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/ohosTest.md b/code/DocsSample/Account/ManageSystemAccountCredentials/ohosTest.md old mode 100755 new mode 100644 index 8cb7ede0ab..2268c1c905 --- a/code/DocsSample/Account/ManageSystemAccountCredentials/ohosTest.md +++ b/code/DocsSample/Account/ManageSystemAccountCredentials/ohosTest.md @@ -1,12 +1,12 @@ -# ManageSystemAccountCredentials 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------ | ------------ | ------------------ | --------------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| Enter PIN code | 位于首页 | 点击'Enter PIN code' | 页面显示“PIN code entry successful” | 是 | Pass | -| Authenticate PIN code | 位于首页 | 点击'Authenticate PIN code' | 页面显示“PIN code entry successful” | 是 | Pass | -| Update credentials | 位于首页 | 点击'Update credentials' | 页面显示“Successfully updated PIN code credentials” | 是 | Pass | -| Query credential information | 位于首页 | 点击'Query credential information' | 页面显示“Query information length:1” | 是 | Pass | +# ManageSystemAccountCredentials 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------ | ------------ | ------------------ | --------------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| Enter PIN code | 位于首页 | 点击'Enter PIN code' | 页面显示“PIN code entry successful” | 是 | Pass | +| Authenticate PIN code | 位于首页 | 点击'Authenticate PIN code' | 页面显示“PIN code entry successful” | 是 | Pass | +| Update credentials | 位于首页 | 点击'Update credentials' | 页面显示“Successfully updated PIN code credentials” | 是 | Pass | +| Query credential information | 位于首页 | 点击'Query credential information' | 页面显示“Query information length:1” | 是 | Pass | | Delete credentials | 位于首页 | 点击'Delete credentials' | 页面显示“Successfully deleted PIN code credentials” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_1.png b/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_2.png b/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_3.png b/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_3.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_4.png b/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_4.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_5.png b/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_5.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_6.png b/code/DocsSample/Account/ManageSystemAccountCredentials/screenshots/AccountCredentials_6.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/.gitignore b/code/DocsSample/Account/ManagerApplicationAccount/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/AppScope/app.json5 b/code/DocsSample/Account/ManagerApplicationAccount/AppScope/app.json5 old mode 100755 new mode 100644 index 04e9307b8b..aeff47f52a --- a/code/DocsSample/Account/ManagerApplicationAccount/AppScope/app.json5 +++ b/code/DocsSample/Account/ManagerApplicationAccount/AppScope/app.json5 @@ -1,25 +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.managerapplicationaccount", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.managerapplicationaccount", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Account/ManagerApplicationAccount/AppScope/resources/base/element/string.json b/code/DocsSample/Account/ManagerApplicationAccount/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 4e396ec1fb..f6d7ea2428 --- a/code/DocsSample/Account/ManagerApplicationAccount/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Account/ManagerApplicationAccount/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ManagerApplicationAccount" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ManagerApplicationAccount" + } + ] +} diff --git a/code/DocsSample/Account/ManagerApplicationAccount/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Account/ManagerApplicationAccount/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/README.md b/code/DocsSample/Account/ManagerApplicationAccount/README.md old mode 100755 new mode 100644 index 0f4ea32c21..c496eeb3d6 --- a/code/DocsSample/Account/ManagerApplicationAccount/README.md +++ b/code/DocsSample/Account/ManagerApplicationAccount/README.md @@ -1,77 +1,77 @@ -# 管理应用账号 - -### 介绍 - -1.应用开发者可以使用[应用账号SDK](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-appAccount.md)管理本应用的账号数据。 - -能力限制:应用卸载场景下,被卸载应用的账号数据会被删除;本地账号删除场景下,被删除本地账号下的所有应用的账号数据会被删除。 - -2.实现对以下指南文件中 [管理应用账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-application-account.md#/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-appAccount.md) 示例代码片段的工程化。保证指南中示例代码与sample工程文件同源。 - -### 效果预览 - -| 首页 | **执行创建应用账号** | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | -| **执行查询应用账号** | **执行存取账号的凭据** | -| | | -| **执行存取账号的自定义数据** | **执行存取账号的授权令牌** | -| | | -| **执行删除应用账号** | | -| | | - -### 使用说明 - -1. 在主界面,可以点击’Create application account‘,创建应用账号。 -2. 点击’Query application account‘,查询应用账号。 -3. 点击’Access account credentials‘,存取账号的凭据。 -4. 点击’Access custom data of the account‘,存取账号的自定义数据。 -5. 点击’Access account authorization token‘,存取账号的授权令牌。 -6. 点击’Delete application account‘,删除应用账号。 -7. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ └── pages - │ │ └── Index.ets // 管理应用账号示例代码 - │ ├── module.json5 - │ └── resources - └── ohosTest - └── ets - └── test - └── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Account/ApplicationAccount > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 管理应用账号 + +### 介绍 + +1.应用开发者可以使用[应用账号SDK](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-appAccount.md)管理本应用的账号数据。 + +能力限制:应用卸载场景下,被卸载应用的账号数据会被删除;本地账号删除场景下,被删除本地账号下的所有应用的账号数据会被删除。 + +2.实现对以下指南文件中 [管理应用账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-application-account.md#/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-appAccount.md) 示例代码片段的工程化。保证指南中示例代码与sample工程文件同源。 + +### 效果预览 + +| 首页 | **执行创建应用账号** | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | +| **执行查询应用账号** | **执行存取账号的凭据** | +| | | +| **执行存取账号的自定义数据** | **执行存取账号的授权令牌** | +| | | +| **执行删除应用账号** | | +| | | + +### 使用说明 + +1. 在主界面,可以点击’Create application account‘,创建应用账号。 +2. 点击’Query application account‘,查询应用账号。 +3. 点击’Access account credentials‘,存取账号的凭据。 +4. 点击’Access custom data of the account‘,存取账号的自定义数据。 +5. 点击’Access account authorization token‘,存取账号的授权令牌。 +6. 点击’Delete application account‘,删除应用账号。 +7. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ └── pages + │ │ └── Index.ets // 管理应用账号示例代码 + │ ├── module.json5 + │ └── resources + └── ohosTest + └── ets + └── test + └── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Account/ApplicationAccount > .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/Account/ManagerApplicationAccount/build-profile.json5 b/code/DocsSample/Account/ManagerApplicationAccount/build-profile.json5 old mode 100755 new mode 100644 index a33a4782e9..3777455b48 --- a/code/DocsSample/Account/ManagerApplicationAccount/build-profile.json5 +++ b/code/DocsSample/Account/ManagerApplicationAccount/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManagerApplicationAccount/code-linter.json5 b/code/DocsSample/Account/ManagerApplicationAccount/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/.gitignore b/code/DocsSample/Account/ManagerApplicationAccount/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/build-profile.json5 b/code/DocsSample/Account/ManagerApplicationAccount/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Account/ManagerApplicationAccount/entry/build-profile.json5 +++ b/code/DocsSample/Account/ManagerApplicationAccount/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/hvigorfile.ts b/code/DocsSample/Account/ManagerApplicationAccount/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/obfuscation-rules.txt b/code/DocsSample/Account/ManagerApplicationAccount/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/oh-package.json5 b/code/DocsSample/Account/ManagerApplicationAccount/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Account/ManagerApplicationAccount/entry/oh-package.json5 +++ b/code/DocsSample/Account/ManagerApplicationAccount/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Account/ManagerApplicationAccount/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Account/ManagerApplicationAccount/entry/src/main/module.json5 b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/module.json5 old mode 100755 new mode 100644 index dece7db447..9bed6e6fd2 --- a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/module.json5 +++ b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/module.json5 @@ -1,67 +1,67 @@ -/* - * 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": [ - "phone", - "tablet", - "2in1" - ], - "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" - } - ], - } - ] - } +/* + * 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": [ + "phone", + "tablet", + "2in1" + ], + "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/Account/ManagerApplicationAccount/entry/src/main/resources/base/element/color.json b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/element/string.json b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/background.png b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/mock/mock-config.json5 b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/module.json5 b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index c8bd24faff..6b9889e8cc --- a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/ohosTest/module.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/test/List.test.ets b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Account/ManagerApplicationAccount/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/hvigor/hvigor-config.json5 b/code/DocsSample/Account/ManagerApplicationAccount/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Account/ManagerApplicationAccount/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Account/ManagerApplicationAccount/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Account/ManagerApplicationAccount/hvigorfile.ts b/code/DocsSample/Account/ManagerApplicationAccount/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/oh-package.json5 b/code/DocsSample/Account/ManagerApplicationAccount/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Account/ManagerApplicationAccount/oh-package.json5 +++ b/code/DocsSample/Account/ManagerApplicationAccount/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Account/ManagerApplicationAccount/ohosTest.md b/code/DocsSample/Account/ManagerApplicationAccount/ohosTest.md old mode 100755 new mode 100644 index d2d8495a3d..cad8a8315a --- a/code/DocsSample/Account/ManagerApplicationAccount/ohosTest.md +++ b/code/DocsSample/Account/ManagerApplicationAccount/ohosTest.md @@ -1,13 +1,13 @@ -# AsyncConcurrencyOverview 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------------------- | ------------ | -------------------------- | --------------------------------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| Create application account | 位于首页 | 点击'Create application account' | 页面显示'Account creation successful' | 是 | Pass | -| Query application account | 位于首页 | 点击'Query application account' | 页面显示'Query account result: ZhangSan' | 是 | Pass | -| Access account credentials | 位于首页 | 点击'Access account credentials' | 页面显示'Successfully set account credentials: xxxxxx' | 是 | Pass | -| Access custom data of the account | 位于首页 | 点击'Access custom data of the account’ | 页面显示'Successfully set custom account credentials, age is 12‘ | 是 | Pass | -| Access account authorization token | 位于首页 | 点击'Access account authorization token’ | 页面显示'Successfully stored account authorization token: xxxxxx‘ | 是 | Pass | +# AsyncConcurrencyOverview 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------- | ------------ | -------------------------- | --------------------------------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| Create application account | 位于首页 | 点击'Create application account' | 页面显示'Account creation successful' | 是 | Pass | +| Query application account | 位于首页 | 点击'Query application account' | 页面显示'Query account result: ZhangSan' | 是 | Pass | +| Access account credentials | 位于首页 | 点击'Access account credentials' | 页面显示'Successfully set account credentials: xxxxxx' | 是 | Pass | +| Access custom data of the account | 位于首页 | 点击'Access custom data of the account’ | 页面显示'Successfully set custom account credentials, age is 12‘ | 是 | Pass | +| Access account authorization token | 位于首页 | 点击'Access account authorization token’ | 页面显示'Successfully stored account authorization token: xxxxxx‘ | 是 | Pass | | Delete application account | 位于首页 | 点击'Delete application account’ | 页面显示'removeAccount successfully‘ | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_1.png b/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_2.png b/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_3.png b/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_3.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_4.png b/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_4.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_5.png b/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_5.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_6.png b/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_6.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_7.png b/code/DocsSample/Account/ManagerApplicationAccount/screenshots/ManagerApplicationAccount_7.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/.gitignore b/code/DocsSample/Account/SystemAccount/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/AppScope/app.json5 b/code/DocsSample/Account/SystemAccount/AppScope/app.json5 old mode 100755 new mode 100644 index c35b144d7b..ffb36aacd6 --- a/code/DocsSample/Account/SystemAccount/AppScope/app.json5 +++ b/code/DocsSample/Account/SystemAccount/AppScope/app.json5 @@ -1,25 +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.systemaccount", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.systemaccount", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Account/SystemAccount/AppScope/resources/base/element/string.json b/code/DocsSample/Account/SystemAccount/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index baaa541dcb..4b7f6c1491 --- a/code/DocsSample/Account/SystemAccount/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Account/SystemAccount/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SystemAccount" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SystemAccount" + } + ] +} diff --git a/code/DocsSample/Account/SystemAccount/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Account/SystemAccount/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/README.md b/code/DocsSample/Account/SystemAccount/README.md index c9fdd597ca..0de44739d8 100644 --- a/code/DocsSample/Account/SystemAccount/README.md +++ b/code/DocsSample/Account/SystemAccount/README.md @@ -1,95 +1,95 @@ -# 系统账号 (管理系统账号和使用约束管控系统账号) - -### 介绍 - -1.管理系统账号: - -系统提供了用于管理系统账号的接口。 系统应用开发者在申请对应的权限后,可以创建、激活、修改和删除系统账号,实现对系统账号的生命周期管理;三方应用开发者可以查询系统账号的基本信息,以完成与系统账号相关的业务逻辑开发。 - -2.使用约束管控系统账号: - -账号管理模块提供了基于角色的访问控制机制,用户可以为系统账号设置约束,以限制目标账号的行为。 - -预定义的账号约束条件,可以参考 :[系统账号约束列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-osAccount.md#系统账号约束列表) - -3.实现对以下指南文件中 [管理系统账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-os-account.md) [使用约束管控系统账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/control-os-account-by-constraints.md) 示例代码片段的工程化。保证指南中示例代码与sample工程文件同源。 - -### 效果预览 - -| 首页 | 使用约束管控系统账号页面 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | -| 执行Set the constraint list for the specified system account | 执行Determine if the specified constraint for the target system account is enabled | -| | | -| 管理系统账号首页 | 执行Create system account | -| | | -| 执行Query all system accounts | 执行Query specified system account information | -| | | -| 执行Modify system account avatar | 执行Modify system account nickname | -| | | -| 执行Delete system account | | -| | | - -### 使用说明 - -1. 在主界面,点击’UseConstraintManagementSystemAccount‘,进入约束管控系统账号页面。 -2. 点击’Set the constraint list for the specified system account‘,Set the constraint list for the specified system account。 -3. 点击’Determine if the specified constraint for the target system account is enabled‘,Determine if the specified constraint for the target system account is enabled。 -4. 点击’Go to ManageSystem‘,进入管理系统账号首页。 -5. 点击’Create system account‘,Create system account。 -6. 点击’Query all system accounts‘,Query all system accounts。 -7. 点击’Query specified system account information‘,Query specified system account information。 -8. 点击’Modify system account avatar‘,Modify system account avatar。 -9. 点击’Modify system account nickname‘,Modify system account nickname。 -10. 点击’Delete system account‘,Delete system account。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ └── pages - | | ├──SystemAccount - | | | ├── ManageSystemAccounts // 管理系统账号示例代码 - | | | └── UseConstraintManagementSystemAccount // 使用约束管控系统账号示例代码 - │ │ └── Index.ets // 系统账号首页 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ └── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -[ohos.permission.MANAGE_LOCAL_ACCOUNTS](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanagelocalaccounts) - -[ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissioninteractacrosslocalaccountsextension) - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Account/SystemAccount > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 系统账号 (管理系统账号和使用约束管控系统账号) + +### 介绍 + +1.管理系统账号: + +系统提供了用于管理系统账号的接口。 系统应用开发者在申请对应的权限后,可以创建、激活、修改和删除系统账号,实现对系统账号的生命周期管理;三方应用开发者可以查询系统账号的基本信息,以完成与系统账号相关的业务逻辑开发。 + +2.使用约束管控系统账号: + +账号管理模块提供了基于角色的访问控制机制,用户可以为系统账号设置约束,以限制目标账号的行为。 + +预定义的账号约束条件,可以参考 :[系统账号约束列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-osAccount.md#系统账号约束列表) + +3.实现对以下指南文件中 [管理系统账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/manage-os-account.md) [使用约束管控系统账号](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/basic-services/account/control-os-account-by-constraints.md) 示例代码片段的工程化。保证指南中示例代码与sample工程文件同源。 + +### 效果预览 + +| 首页 | 使用约束管控系统账号页面 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | +| 执行Set the constraint list for the specified system account | 执行Determine if the specified constraint for the target system account is enabled | +| | | +| 管理系统账号首页 | 执行Create system account | +| | | +| 执行Query all system accounts | 执行Query specified system account information | +| | | +| 执行Modify system account avatar | 执行Modify system account nickname | +| | | +| 执行Delete system account | | +| | | + +### 使用说明 + +1. 在主界面,点击’UseConstraintManagementSystemAccount‘,进入约束管控系统账号页面。 +2. 点击’Set the constraint list for the specified system account‘,Set the constraint list for the specified system account。 +3. 点击’Determine if the specified constraint for the target system account is enabled‘,Determine if the specified constraint for the target system account is enabled。 +4. 点击’Go to ManageSystem‘,进入管理系统账号首页。 +5. 点击’Create system account‘,Create system account。 +6. 点击’Query all system accounts‘,Query all system accounts。 +7. 点击’Query specified system account information‘,Query specified system account information。 +8. 点击’Modify system account avatar‘,Modify system account avatar。 +9. 点击’Modify system account nickname‘,Modify system account nickname。 +10. 点击’Delete system account‘,Delete system account。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ └── pages + | | ├──SystemAccount + | | | ├── ManageSystemAccounts // 管理系统账号示例代码 + | | | └── UseConstraintManagementSystemAccount // 使用约束管控系统账号示例代码 + │ │ └── Index.ets // 系统账号首页 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ └── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +[ohos.permission.MANAGE_LOCAL_ACCOUNTS](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanagelocalaccounts) + +[ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissioninteractacrosslocalaccountsextension) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Account/SystemAccount > .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/Account/SystemAccount/build-profile.json5 b/code/DocsSample/Account/SystemAccount/build-profile.json5 old mode 100755 new mode 100644 index a33a4782e9..3777455b48 --- a/code/DocsSample/Account/SystemAccount/build-profile.json5 +++ b/code/DocsSample/Account/SystemAccount/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/SystemAccount/code-linter.json5 b/code/DocsSample/Account/SystemAccount/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/.gitignore b/code/DocsSample/Account/SystemAccount/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/build-profile.json5 b/code/DocsSample/Account/SystemAccount/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Account/SystemAccount/entry/build-profile.json5 +++ b/code/DocsSample/Account/SystemAccount/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/SystemAccount/entry/hvigorfile.ts b/code/DocsSample/Account/SystemAccount/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/obfuscation-rules.txt b/code/DocsSample/Account/SystemAccount/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/oh-package.json5 b/code/DocsSample/Account/SystemAccount/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Account/SystemAccount/entry/oh-package.json5 +++ b/code/DocsSample/Account/SystemAccount/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Account/SystemAccount/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Account/SystemAccount/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Account/SystemAccount/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Account/SystemAccount/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Account/SystemAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Account/SystemAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Account/SystemAccount/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Account/SystemAccount/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/SystemAccount/ManageSystemAccounts.ets b/code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/SystemAccount/ManageSystemAccounts.ets old mode 100755 new mode 100644 index fd65d482db..5a1080220c --- a/code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/SystemAccount/ManageSystemAccounts.ets +++ b/code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/SystemAccount/ManageSystemAccounts.ets @@ -1,210 +1,210 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start import_system_account_module] -import { osAccount, BusinessError } from '@kit.BasicServicesKit'; -// [End import_system_account_module] - -// [Start obtain_account_management_single_instance_object] -let accountManager = osAccount.getAccountManager(); -// [End obtain_account_management_single_instance_object] - -@Entry -@Component -struct ManageSystemAccounts { - @State message: string = 'No work done'; - @State createLocalId: number = -1; - - private async createOsAccount(): Promise { - // [Start specify_nickname_and_type_information_to_create_system_account] - let name: string = 'Bob'; - let type: osAccount.OsAccountType = osAccount.OsAccountType.NORMAL; - - accountManager.createOsAccount(name, type, (err: BusinessError, osAccountInfo: osAccount.OsAccountInfo)=>{ - console.log('createOsAccount err:' + JSON.stringify(err)); - console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo)); - // [StartExclude specify_nickname_and_type_information_to_create_system_account] - if (!err) { - this.message = 'Account creation successful. Account name: ' + JSON.stringify(osAccountInfo.localName); - this.createLocalId = osAccountInfo.localId; - } else { - this.message = 'Failed to create account: ' + JSON.stringify(err); - } - // [EndExclude specify_nickname_and_type_information_to_create_system_account] - }); - // [End specify_nickname_and_type_information_to_create_system_account] - } - - private async findAllOsAccount(): Promise { - // [Start query_the_full_account] - accountManager.queryAllCreatedOsAccounts((err: BusinessError, accountArr: osAccount.OsAccountInfo[])=>{ - console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err)); - console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr)); - // [StartExclude query_the_full_account] - if (!err) { - this.message = 'Query account successful. Account name:' + JSON.stringify(accountArr[0].localName); - } else { - this.message = 'Query account failed: ' + JSON.stringify(err); - } - // [EndExclude query_the_full_account] - }); - // [End query_the_full_account] - } - - private async findOsAccount(): Promise { - // [Start query_information_of_the_specified_account] - let localId: number = 100; - accountManager.queryOsAccountById(localId, (err: BusinessError, accountInfo: osAccount.OsAccountInfo)=>{ - console.log('queryOsAccountById err:' + JSON.stringify(err)); - console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo)); - // [StartExclude query_information_of_the_specified_account] - if (!err) { - this.message = 'Query account successful. Account name for account 100: ' + JSON.stringify(accountInfo.localName); - } else { - this.message = 'Query account failed: ' + JSON.stringify(err); - } - // [EndExclude query_information_of_the_specified_account] - }); - // [End query_information_of_the_specified_account] - } - - private async changeOsAccountHead(): Promise { - // [Start change_system_account_avatar] - let localId: number = 100; - // [StartExclude change_system_account_avatar] - localId = this.createLocalId; - // [EndExclude change_system_account_avatar] - let newPhoto: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+ - 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ - 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+ - '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==' - - accountManager.setOsAccountProfilePhoto(localId, newPhoto, (err: BusinessError)=>{ - console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err)); - // [StartExclude change_system_account_avatar] - if(!err) { - this.message = 'Successfully updated system account avatar' - } else { - this.message = 'Failed to update system account avatar: ' + JSON.stringify(err); - } - // [EndExclude change_system_account_avatar] - }); - // [End change_system_account_avatar] - } - - private async changeOsAccountName(): Promise { - // [Start change_system_account_name] - let localId: number = 100; - // [StartExclude change_system_account_name] - localId = this.createLocalId; - // [EndExclude change_system_account_name] - let newName: string = 'Tom'; - accountManager.setOsAccountName(localId, newName, (err: BusinessError) => { - if (err) { - console.error('setOsAccountName failed, error: ' + JSON.stringify(err)); - // [StartExclude change_system_account_name] - this.message = 'Failed to modify system account name: ' + JSON.stringify(err); - // [EndExclude change_system_account_name] - } else { - console.log('setOsAccountName successfully'); - // [StartExclude change_system_account_name] - this.message = 'Successfully modified system account name'; - // [EndExclude change_system_account_name] - } - }); - // [End change_system_account_name] - } - - private async activateOsAccount(): Promise { - // [Start activate_system_account] - let localId: number = 101; - // [StartExclude activate_system_account] - localId = this.createLocalId; - // [EndExclude activate_system_account] - accountManager.activateOsAccount(localId, (err: BusinessError)=>{ - if (err) { - console.error(`activateOsAccount failed, code is ${err.code}, message is ${err.message}`); - // [StartExclude activate_system_account] - this.message = 'Failed to activate system account: ' + err.code; - // [EndExclude activate_system_account] - } else { - console.log('activateOsAccount successfully'); - // [StartExclude activate_system_account] - this.message = 'Successfully activated system account' - // [EndExclude activate_system_account] - } - }); - // [End activate_system_account] - } - - private async deleteOsAccount(): Promise { - // [Start delete_the_specified_account] - let localId: number = 101; - localId = this.createLocalId; - accountManager.removeOsAccount(localId, (err: BusinessError)=>{ - if (err) { - console.error('removeOsAccount failed, error: ' + JSON.stringify(err)); - // [StartExclude delete_the_specified_account] - this.message = 'Failed to delete system account: ' + JSON.stringify(err); - // [EndExclude delete_the_specified_account] - } else { - console.log('removeOsAccount successfully'); - // [StartExclude delete_the_specified_account] - this.message = 'Successfully deleted system account' - // [EndExclude delete_the_specified_account] - } - }); - // [End delete_the_specified_account] - } - - build() { - Column() { - Text(this.message) - .id('show') - .fontSize(36) - .fontWeight(FontWeight.Bold) - Button($r('app.string.Manager1')) - .margin(10) - .id('button1') - .onClick(() => this.createOsAccount()) - Button($r('app.string.Manager2')) - .margin(10) - .id('button2') - .onClick(() => this.findAllOsAccount()) - Button($r('app.string.Manager3')) - .margin(10) - .id('button3') - .onClick(() => this.findOsAccount()) - Button($r('app.string.Manager4')) - .margin(10) - .id('button4') - .onClick(() => this.changeOsAccountHead()) - Button($r('app.string.Manager5')) - .margin(10) - .id('button5') - .onClick(() => this.changeOsAccountName()) - Button($r('app.string.Manager6')) - .margin(10) - .id('button6') - .onClick(() => this.activateOsAccount()) - Button($r('app.string.Manager7')) - .margin(10) - .id('button7') - .onClick(() => this.deleteOsAccount()) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start import_system_account_module] +import { osAccount, BusinessError } from '@kit.BasicServicesKit'; +// [End import_system_account_module] + +// [Start obtain_account_management_single_instance_object] +let accountManager = osAccount.getAccountManager(); +// [End obtain_account_management_single_instance_object] + +@Entry +@Component +struct ManageSystemAccounts { + @State message: string = 'No work done'; + @State createLocalId: number = -1; + + private async createOsAccount(): Promise { + // [Start specify_nickname_and_type_information_to_create_system_account] + let name: string = 'Bob'; + let type: osAccount.OsAccountType = osAccount.OsAccountType.NORMAL; + + accountManager.createOsAccount(name, type, (err: BusinessError, osAccountInfo: osAccount.OsAccountInfo)=>{ + console.log('createOsAccount err:' + JSON.stringify(err)); + console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo)); + // [StartExclude specify_nickname_and_type_information_to_create_system_account] + if (!err) { + this.message = 'Account creation successful. Account name: ' + JSON.stringify(osAccountInfo.localName); + this.createLocalId = osAccountInfo.localId; + } else { + this.message = 'Failed to create account: ' + JSON.stringify(err); + } + // [EndExclude specify_nickname_and_type_information_to_create_system_account] + }); + // [End specify_nickname_and_type_information_to_create_system_account] + } + + private async findAllOsAccount(): Promise { + // [Start query_the_full_account] + accountManager.queryAllCreatedOsAccounts((err: BusinessError, accountArr: osAccount.OsAccountInfo[])=>{ + console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err)); + console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr)); + // [StartExclude query_the_full_account] + if (!err) { + this.message = 'Query account successful. Account name:' + JSON.stringify(accountArr[0].localName); + } else { + this.message = 'Query account failed: ' + JSON.stringify(err); + } + // [EndExclude query_the_full_account] + }); + // [End query_the_full_account] + } + + private async findOsAccount(): Promise { + // [Start query_information_of_the_specified_account] + let localId: number = 100; + accountManager.queryOsAccountById(localId, (err: BusinessError, accountInfo: osAccount.OsAccountInfo)=>{ + console.log('queryOsAccountById err:' + JSON.stringify(err)); + console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo)); + // [StartExclude query_information_of_the_specified_account] + if (!err) { + this.message = 'Query account successful. Account name for account 100: ' + JSON.stringify(accountInfo.localName); + } else { + this.message = 'Query account failed: ' + JSON.stringify(err); + } + // [EndExclude query_information_of_the_specified_account] + }); + // [End query_information_of_the_specified_account] + } + + private async changeOsAccountHead(): Promise { + // [Start change_system_account_avatar] + let localId: number = 100; + // [StartExclude change_system_account_avatar] + localId = this.createLocalId; + // [EndExclude change_system_account_avatar] + let newPhoto: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+ + 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ + 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+ + '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==' + + accountManager.setOsAccountProfilePhoto(localId, newPhoto, (err: BusinessError)=>{ + console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err)); + // [StartExclude change_system_account_avatar] + if(!err) { + this.message = 'Successfully updated system account avatar' + } else { + this.message = 'Failed to update system account avatar: ' + JSON.stringify(err); + } + // [EndExclude change_system_account_avatar] + }); + // [End change_system_account_avatar] + } + + private async changeOsAccountName(): Promise { + // [Start change_system_account_name] + let localId: number = 100; + // [StartExclude change_system_account_name] + localId = this.createLocalId; + // [EndExclude change_system_account_name] + let newName: string = 'Tom'; + accountManager.setOsAccountName(localId, newName, (err: BusinessError) => { + if (err) { + console.error('setOsAccountName failed, error: ' + JSON.stringify(err)); + // [StartExclude change_system_account_name] + this.message = 'Failed to modify system account name: ' + JSON.stringify(err); + // [EndExclude change_system_account_name] + } else { + console.log('setOsAccountName successfully'); + // [StartExclude change_system_account_name] + this.message = 'Successfully modified system account name'; + // [EndExclude change_system_account_name] + } + }); + // [End change_system_account_name] + } + + private async activateOsAccount(): Promise { + // [Start activate_system_account] + let localId: number = 101; + // [StartExclude activate_system_account] + localId = this.createLocalId; + // [EndExclude activate_system_account] + accountManager.activateOsAccount(localId, (err: BusinessError)=>{ + if (err) { + console.error(`activateOsAccount failed, code is ${err.code}, message is ${err.message}`); + // [StartExclude activate_system_account] + this.message = 'Failed to activate system account: ' + err.code; + // [EndExclude activate_system_account] + } else { + console.log('activateOsAccount successfully'); + // [StartExclude activate_system_account] + this.message = 'Successfully activated system account' + // [EndExclude activate_system_account] + } + }); + // [End activate_system_account] + } + + private async deleteOsAccount(): Promise { + // [Start delete_the_specified_account] + let localId: number = 101; + localId = this.createLocalId; + accountManager.removeOsAccount(localId, (err: BusinessError)=>{ + if (err) { + console.error('removeOsAccount failed, error: ' + JSON.stringify(err)); + // [StartExclude delete_the_specified_account] + this.message = 'Failed to delete system account: ' + JSON.stringify(err); + // [EndExclude delete_the_specified_account] + } else { + console.log('removeOsAccount successfully'); + // [StartExclude delete_the_specified_account] + this.message = 'Successfully deleted system account' + // [EndExclude delete_the_specified_account] + } + }); + // [End delete_the_specified_account] + } + + build() { + Column() { + Text(this.message) + .id('show') + .fontSize(36) + .fontWeight(FontWeight.Bold) + Button($r('app.string.Manager1')) + .margin(10) + .id('button1') + .onClick(() => this.createOsAccount()) + Button($r('app.string.Manager2')) + .margin(10) + .id('button2') + .onClick(() => this.findAllOsAccount()) + Button($r('app.string.Manager3')) + .margin(10) + .id('button3') + .onClick(() => this.findOsAccount()) + Button($r('app.string.Manager4')) + .margin(10) + .id('button4') + .onClick(() => this.changeOsAccountHead()) + Button($r('app.string.Manager5')) + .margin(10) + .id('button5') + .onClick(() => this.changeOsAccountName()) + Button($r('app.string.Manager6')) + .margin(10) + .id('button6') + .onClick(() => this.activateOsAccount()) + Button($r('app.string.Manager7')) + .margin(10) + .id('button7') + .onClick(() => this.deleteOsAccount()) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/SystemAccount/UseConstraintManagementSystemAccount.ets b/code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/SystemAccount/UseConstraintManagementSystemAccount.ets old mode 100755 new mode 100644 index 49edb54335..078ee1310f --- a/code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/SystemAccount/UseConstraintManagementSystemAccount.ets +++ b/code/DocsSample/Account/SystemAccount/entry/src/main/ets/pages/SystemAccount/UseConstraintManagementSystemAccount.ets @@ -1,95 +1,95 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start import_system_account_module] -import { osAccount } from '@kit.BasicServicesKit'; -// [End import_system_account_module] -import { router } from '@kit.ArkUI'; - -// [Start obtain_account_single_instance_object] -let accountManager = osAccount.getAccountManager(); -// [End obtain_account_single_instance_object] - -@Entry -@Component -struct UseConstraintManagementSystemAccount { - @State message: string = 'No work done'; - - private async setOsAccountConstraints(): Promise { - // [Start constraint_collections] - let localId: number = 100; - let constraint: string[] = [ 'constraint.wifi.set' ]; - // [End constraint_collections] - // [Start system_account_constraint] - try { - accountManager.setOsAccountConstraints(localId, constraint, true); - console.log('setOsAccountConstraints successfully'); - // [StartExclude system_account_constraint] - this.message = 'Successfully set the constraint list for the specified system account'; - // [EndExclude system_account_constraint] - } catch (err) { - console.error('setOsAccountConstraints failed, error: ' + JSON.stringify(err)); - // [StartExclude system_account_constraint] - this.message = 'Failed to set the constraint list for the specified system account'; - // [EndExclude system_account_constraint] - } - // [End system_account_constraint] - } - - private async isOsAccountConstraintEnabled(): Promise { - // [Start specify_the_system_account_id_and_constraint_name] - let localId: number = 100; - let constraint: string = 'constraint.wifi.set'; - // [End specify_the_system_account_id_and_constraint_name] - // [Start check_whether_the_specified_constraint_is_enabled] - let isEnabled: boolean = await accountManager.isOsAccountConstraintEnabled(localId, constraint); - if (isEnabled) { - // your business logic - // [StartExclude check_whether_the_specified_constraint_is_enabled] - this.message = 'Set the constraint list for the specified system account'; - } else { - this.message = 'Can not set the constraint list for the specified system account'; - // [EndExclude check_whether_the_specified_constraint_is_enabled] - } - // [End check_whether_the_specified_constraint_is_enabled] - } - - build() { - Column() { - Text(this.message) - .id('show') - .fontSize(36) - .fontWeight(FontWeight.Bold) - Button($r('app.string.Use1')) - .margin(10) - .id('button1') - .onClick(() => this.setOsAccountConstraints()) - Button($r('app.string.Use2')) - .margin(10) - .id('button2') - .onClick(() => this.isOsAccountConstraintEnabled()) - Button($r('app.string.Use3')) - .margin(10) - .id('button3') - .onClick(() => { - router.pushUrl({ - url: 'pages/SystemAccount/ManageSystemAccounts' - }) - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start import_system_account_module] +import { osAccount } from '@kit.BasicServicesKit'; +// [End import_system_account_module] +import { router } from '@kit.ArkUI'; + +// [Start obtain_account_single_instance_object] +let accountManager = osAccount.getAccountManager(); +// [End obtain_account_single_instance_object] + +@Entry +@Component +struct UseConstraintManagementSystemAccount { + @State message: string = 'No work done'; + + private async setOsAccountConstraints(): Promise { + // [Start constraint_collections] + let localId: number = 100; + let constraint: string[] = [ 'constraint.wifi.set' ]; + // [End constraint_collections] + // [Start system_account_constraint] + try { + accountManager.setOsAccountConstraints(localId, constraint, true); + console.log('setOsAccountConstraints successfully'); + // [StartExclude system_account_constraint] + this.message = 'Successfully set the constraint list for the specified system account'; + // [EndExclude system_account_constraint] + } catch (err) { + console.error('setOsAccountConstraints failed, error: ' + JSON.stringify(err)); + // [StartExclude system_account_constraint] + this.message = 'Failed to set the constraint list for the specified system account'; + // [EndExclude system_account_constraint] + } + // [End system_account_constraint] + } + + private async isOsAccountConstraintEnabled(): Promise { + // [Start specify_the_system_account_id_and_constraint_name] + let localId: number = 100; + let constraint: string = 'constraint.wifi.set'; + // [End specify_the_system_account_id_and_constraint_name] + // [Start check_whether_the_specified_constraint_is_enabled] + let isEnabled: boolean = await accountManager.isOsAccountConstraintEnabled(localId, constraint); + if (isEnabled) { + // your business logic + // [StartExclude check_whether_the_specified_constraint_is_enabled] + this.message = 'Set the constraint list for the specified system account'; + } else { + this.message = 'Can not set the constraint list for the specified system account'; + // [EndExclude check_whether_the_specified_constraint_is_enabled] + } + // [End check_whether_the_specified_constraint_is_enabled] + } + + build() { + Column() { + Text(this.message) + .id('show') + .fontSize(36) + .fontWeight(FontWeight.Bold) + Button($r('app.string.Use1')) + .margin(10) + .id('button1') + .onClick(() => this.setOsAccountConstraints()) + Button($r('app.string.Use2')) + .margin(10) + .id('button2') + .onClick(() => this.isOsAccountConstraintEnabled()) + Button($r('app.string.Use3')) + .margin(10) + .id('button3') + .onClick(() => { + router.pushUrl({ + url: 'pages/SystemAccount/ManageSystemAccounts' + }) + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/Account/SystemAccount/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/module.json5 b/code/DocsSample/Account/SystemAccount/entry/src/main/module.json5 old mode 100755 new mode 100644 index 08ab0350ec..909bed2772 --- a/code/DocsSample/Account/SystemAccount/entry/src/main/module.json5 +++ b/code/DocsSample/Account/SystemAccount/entry/src/main/module.json5 @@ -1,73 +1,73 @@ -/* - * 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": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "requestPermissions": [{ - "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", - }, - { - "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION", - }], - "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" - } - ], - } - ] - } +/* + * 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": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "requestPermissions": [{ + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", + }, + { + "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION", + }], + "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/Account/SystemAccount/entry/src/main/resources/base/element/color.json b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/element/string.json b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/background.png b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Account/SystemAccount/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Account/SystemAccount/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Account/SystemAccount/entry/src/mock/mock-config.json5 b/code/DocsSample/Account/SystemAccount/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Account/SystemAccount/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/ohosTest/module.json5 b/code/DocsSample/Account/SystemAccount/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index c8bd24faff..6b9889e8cc --- a/code/DocsSample/Account/SystemAccount/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Account/SystemAccount/entry/src/ohosTest/module.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Account/SystemAccount/entry/src/test/List.test.ets b/code/DocsSample/Account/SystemAccount/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Account/SystemAccount/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/hvigor/hvigor-config.json5 b/code/DocsSample/Account/SystemAccount/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Account/SystemAccount/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Account/SystemAccount/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Account/SystemAccount/hvigorfile.ts b/code/DocsSample/Account/SystemAccount/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/oh-package.json5 b/code/DocsSample/Account/SystemAccount/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Account/SystemAccount/oh-package.json5 +++ b/code/DocsSample/Account/SystemAccount/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Account/SystemAccount/ohosTest.md b/code/DocsSample/Account/SystemAccount/ohosTest.md old mode 100755 new mode 100644 index 8d85ddec95..95675252d0 --- a/code/DocsSample/Account/SystemAccount/ohosTest.md +++ b/code/DocsSample/Account/SystemAccount/ohosTest.md @@ -1,15 +1,15 @@ -# SystemAccount 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------- | -------------------------------------------- | ---------------------------------------- | -------------------------------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| Set the constraint list for the specified system account | 位于UseConstraintManagementSystemAccount页面 | 点击'Set the constraint list for the specified system account' | 页面显示“Successfully set the constraint list for the specified system account” | 是 | Pass | -| Determine if the specified constraint for the target system account is enabled | 位于UseConstraintManagementSystemAccount页面 | 点击'Determine if the specified constraint for the target system account is enabled' | 页面显示“Set the constraint list for the specified system account” | 是 | Pass | -| Create system account | 位于ManageSystemAccounts页面 | 点击'Create system account' | 页面显示“Account creation successful. Account name:: "Bob"” | 是 | Pass | -| Query all system accounts | 位于ManageSystemAccounts页面 | 点击'Query all system accounts' | 页面显示“Query account successful. Account name:"user"” | 是 | Pass | -| Query specified system account information | 位于ManageSystemAccounts页面 | 点击'Query specified system account information' | 页面显示“Query account successful. Account name for account 100: "user"” | 是 | Pass | -| Modify system account avatar | 位于ManageSystemAccounts页面 | 点击'Modify system account avatar' | 页面显示“Successfully updated system account avatar” | 是 | Pass | -| Modify system account nickname | 位于ManageSystemAccounts页面 | 点击'Modify system account nickname' | 页面显示“Successfully modified system account name” | 是 | Pass | +# SystemAccount 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------- | -------------------------------------------- | ---------------------------------------- | -------------------------------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| Set the constraint list for the specified system account | 位于UseConstraintManagementSystemAccount页面 | 点击'Set the constraint list for the specified system account' | 页面显示“Successfully set the constraint list for the specified system account” | 是 | Pass | +| Determine if the specified constraint for the target system account is enabled | 位于UseConstraintManagementSystemAccount页面 | 点击'Determine if the specified constraint for the target system account is enabled' | 页面显示“Set the constraint list for the specified system account” | 是 | Pass | +| Create system account | 位于ManageSystemAccounts页面 | 点击'Create system account' | 页面显示“Account creation successful. Account name:: "Bob"” | 是 | Pass | +| Query all system accounts | 位于ManageSystemAccounts页面 | 点击'Query all system accounts' | 页面显示“Query account successful. Account name:"user"” | 是 | Pass | +| Query specified system account information | 位于ManageSystemAccounts页面 | 点击'Query specified system account information' | 页面显示“Query account successful. Account name for account 100: "user"” | 是 | Pass | +| Modify system account avatar | 位于ManageSystemAccounts页面 | 点击'Modify system account avatar' | 页面显示“Successfully updated system account avatar” | 是 | Pass | +| Modify system account nickname | 位于ManageSystemAccounts页面 | 点击'Modify system account nickname' | 页面显示“Successfully modified system account name” | 是 | Pass | | Delete system account | 位于ManageSystemAccounts页面 | 点击'Delete system account' | 页面显示“Successfully deleted system account” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_1.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_10.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_10.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_11.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_11.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_2.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_3.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_3.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_4.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_4.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_5.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_5.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_6.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_6.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_7.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_7.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_8.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_8.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_9.png b/code/DocsSample/Account/SystemAccount/screenshots/SystemAccount_9.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/AppScope/app.json5 b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/AppScope/app.json5 index a03139a0d8..be11a102a5 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/AppScope/app.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/AppScope/app.json5 @@ -1,26 +1,26 @@ -/* -* Copyright (c) 2024 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.implicitstartbytyperely", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name", - "distributedNotificationEnabled": true - } -} +/* +* Copyright (c) 2024 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.implicitstartbytyperely", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/AppScope/resources/base/element/string.json b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/AppScope/resources/base/element/string.json index d71e5ead1c..1080233f01 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MyApplication" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + } + ] +} diff --git a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/build-profile.json5 b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/build-profile.json5 index ee5fc3b62c..eff1762870 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/build-profile.json5 @@ -1,43 +1,43 @@ -/* -* Copyright (c) 2024 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", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* +* Copyright (c) 2024 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", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/build-profile.json5 b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/build-profile.json5 index f6cbf2f1e1..85d986b1fc 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/build-profile.json5 @@ -1,28 +1,28 @@ -/* -* Copyright (c) 2024 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": { - }, - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* +* Copyright (c) 2024 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": { + }, + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/oh-package.json5 b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/oh-package.json5 index beb2ba7c83..a7afd4ec10 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/oh-package.json5 @@ -1,9 +1,9 @@ -{ - "license": "ISC", - "devDependencies": {}, - "name": "entry", - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/ets/entryability/EntryAbility.ts index 6d1d184dbb..1fea9577f6 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,59 +1,59 @@ -/* -* Copyright (c) 2024 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 UIAbility from '@ohos.app.ability.UIAbility'; -import hilog from '@ohos.hilog'; -import window from '@ohos.window'; -import type Want from '@ohos.app.ability.Want'; -import type AbilityConstant from '@ohos.app.ability.AbilityConstant'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, 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(): 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'); - } - -} +/* +* Copyright (c) 2024 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; +import type Want from '@ohos.app.ability.Want'; +import type AbilityConstant from '@ohos.app.ability.AbilityConstant'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, 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(): 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/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/module.json5 b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/module.json5 index 3a7f1d0279..082405f6ed 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/module.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/module.json5 @@ -1,68 +1,68 @@ -/* -* Copyright (c) 2024 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", - "srcEntrance": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home", - 'entity.system.browsable' - ], - "actions": [ - "action.system.home", - 'ohos.want.action.search', - 'ohos.want.action.viewData' - ], - "uris": [ - { - "scheme": "https", - "host": "www.test.com", - "port": "8080", - // prefix matching - "pathStartWith": "query", - "type": "application/http" - }, - { - "scheme": "http", - } - ] - } - ] - } - ] - } +/* +* Copyright (c) 2024 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", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home", + 'entity.system.browsable' + ], + "actions": [ + "action.system.home", + 'ohos.want.action.search', + 'ohos.want.action.viewData' + ], + "uris": [ + { + "scheme": "https", + "host": "www.test.com", + "port": "8080", + // prefix matching + "pathStartWith": "query", + "type": "application/http" + }, + { + "scheme": "http", + } + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/resources/base/element/color.json b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/hvigor/hvigor-config.json5 b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/hvigor/hvigor-config.json5 index d3c66f0a45..a9a23b0b2e 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* -* Copyright (c) 2024 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. -*/ - -{ - "hvigorVersion": "4.1.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.1.2" - } +/* +* Copyright (c) 2024 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. +*/ + +{ + "hvigorVersion": "4.1.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.1.2" + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/oh-package.json5 b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/oh-package.json5 index bccaf227d7..37453be12b 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartByTypeRely/oh-package.json5 @@ -1,11 +1,11 @@ -{ - "license": "ISC", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "name": "myapplication", - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "ISC", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "name": "myapplication", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/ImplicitStartRely/AppScope/app.json5 b/code/DocsSample/ApplicationModels/ImplicitStartRely/AppScope/app.json5 index 0f21f2197a..02489bdb81 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartRely/AppScope/app.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartRely/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* -* Copyright (c) 2024 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.implicitstartrely", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* +* Copyright (c) 2024 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.implicitstartrely", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ApplicationModels/ImplicitStartRely/AppScope/resources/base/element/string.json b/code/DocsSample/ApplicationModels/ImplicitStartRely/AppScope/resources/base/element/string.json index dde739a8ab..e279195f0e 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartRely/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/ImplicitStartRely/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "browser" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "browser" + } + ] +} diff --git a/code/DocsSample/ApplicationModels/ImplicitStartRely/build-profile.json5 b/code/DocsSample/ApplicationModels/ImplicitStartRely/build-profile.json5 index ee5fc3b62c..eff1762870 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartRely/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartRely/build-profile.json5 @@ -1,43 +1,43 @@ -/* -* Copyright (c) 2024 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", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* +* Copyright (c) 2024 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", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/build-profile.json5 b/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/build-profile.json5 index a39f19549a..9ac1d52c56 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* -* Copyright (c) 2024 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* +* Copyright (c) 2024 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/oh-package.json5 b/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/oh-package.json5 index 60744fdbc7..225946cb11 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/ets/entryability/EntryAbility.ts index 5de02b4dca..7597d44bac 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,58 +1,58 @@ -/* -* Copyright (c) 2024 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 UIAbility from '@ohos.app.ability.UIAbility'; -import hilog from '@ohos.hilog'; -import window from '@ohos.window'; -import type Want from '@ohos.app.ability.Want'; -import type AbilityConstant from '@ohos.app.ability.AbilityConstant'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, 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(): 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'); - } -} +/* +* Copyright (c) 2024 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; +import type Want from '@ohos.app.ability.Want'; +import type AbilityConstant from '@ohos.app.ability.AbilityConstant'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, 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(): 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/ApplicationModels/ImplicitStartRely/entry/src/main/module.json5 b/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/module.json5 index 131be46d84..4546951138 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/module.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/module.json5 @@ -1,65 +1,65 @@ -/* -* Copyright (c) 2024 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home", - 'entity.system.browsable' - ], - "actions": [ - "action.system.home", - 'ohos.want.action.viewData' - ], - "uris": [ - { - "scheme": "https", - "host": "www.test.com", - "port": "8080", - "pathStartWith": "query", - }, - { - "scheme": "http", - } - ] - } - ] - } - ] - } +/* +* Copyright (c) 2024 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home", + 'entity.system.browsable' + ], + "actions": [ + "action.system.home", + 'ohos.want.action.viewData' + ], + "uris": [ + { + "scheme": "https", + "host": "www.test.com", + "port": "8080", + "pathStartWith": "query", + }, + { + "scheme": "http", + } + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/resources/base/element/color.json b/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ApplicationModels/ImplicitStartRely/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/ImplicitStartRely/hvigor/hvigor-config.json5 b/code/DocsSample/ApplicationModels/ImplicitStartRely/hvigor/hvigor-config.json5 index d3c66f0a45..a9a23b0b2e 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartRely/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartRely/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* -* Copyright (c) 2024 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. -*/ - -{ - "hvigorVersion": "4.1.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.1.2" - } +/* +* Copyright (c) 2024 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. +*/ + +{ + "hvigorVersion": "4.1.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.1.2" + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/ImplicitStartRely/oh-package.json5 b/code/DocsSample/ApplicationModels/ImplicitStartRely/oh-package.json5 index bac4c43f05..3313a2cb07 100644 --- a/code/DocsSample/ApplicationModels/ImplicitStartRely/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/ImplicitStartRely/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "browser", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "browser", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/AppScope/app.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/AppScope/app.json5 index 0de07f31f5..9aee09e72b 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/AppScope/app.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* -* Copyright (c) 2024 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.mindsporelitearktsdemo", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* +* Copyright (c) 2024 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.mindsporelitearktsdemo", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/AppScope/resources/base/element/string.json b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/AppScope/resources/base/element/string.json index 7d862f19d5..d26dc6c578 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MindSporeLiteArkTSDemo" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "MindSporeLiteArkTSDemo" + } + ] +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/README_zh.md b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/README_zh.md index 2b0a8c1723..51539f53cb 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/README_zh.md +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/README_zh.md @@ -1,76 +1,76 @@ -# **基于ArkTS接口的MindSpore Lite应用开发** - -### 介绍 - -本文基于MindSpore Lite提供的ArkTS API,实现“端侧图像分类”示例程序,来演示端侧部署的流程。 - -1. 选择图像分类模型。 -2. 将模型转换成MindSpore Lite模型格式。 -3. 在端侧使用MindSpore Lite推理模型,显示出可能的分类结果。 - -### 效果预览 - -| 主页 | -|-----------------------------------------------------| -| | - -#### 使用说明 - -1. 在主界面,可以点击photo按钮,进入相册选择图片界面; -2. 在相册界面,选择图片,点击确定按钮; -3. 自动进行选择图片的图像分类模型推理,部分推理结果显示在主界面。 - -### 工程目录 - -``` -entry -├── src/main -│   ├── etc# -|   |   └── pages -|   |       └── Index.ets // 首页,获取图片及预处理 -|   |       └── model.ets // 推理 -│   ├── resources // 资源文件 -|   |   └── rawfile -|   |       └── mobilenetv2.ms // 存放的模型文件 -``` - -### 具体实现 - -* 本示例程序中使用的终端图像分类模型文件为mobilenetv2.ms,放置在entry\src\main\resources\rawfile工程目录下。 - - 注:开发者可按需手工下载[MindSpore Model Zoo中图像分类模型](https://download.mindspore.cn/model_zoo/official/lite/mobilenetv2_openimage_lite/1.5/mobilenetv2.ms)。 - -* 调用[@ohos.file.picker](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) (图片文件选择)、[@ohos.multimedia.image](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md) (图片处理效果)、[@ohos.file.fs](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) (基础文件操作) 等API实现相册图片获取及图片处理。完整代码请参见Index.ets - -* 调用[@ohos.ai.mindSporeLite](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-mindspore-lite-kit/js-apis-mindSporeLite.md) (推理能力) API实现端侧推理。完整代码请参见model.ets - -* 调用推理函数并处理结果。完整代码请参见Index.ets - -### 相关权限 - -ohos.permission.READ_IMAGEVIDEO - -### 依赖 - -无。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568; - -2.本示例为Stage模型,已适配API version 11版本SDK; - -3.本示例需要使用DevEco Studio 4.1 Release及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/BasicFeature/ApplicationModels/MindSporeLiteArkTSDemo/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` - +# **基于ArkTS接口的MindSpore Lite应用开发** + +### 介绍 + +本文基于MindSpore Lite提供的ArkTS API,实现“端侧图像分类”示例程序,来演示端侧部署的流程。 + +1. 选择图像分类模型。 +2. 将模型转换成MindSpore Lite模型格式。 +3. 在端侧使用MindSpore Lite推理模型,显示出可能的分类结果。 + +### 效果预览 + +| 主页 | +|-----------------------------------------------------| +| | + +#### 使用说明 + +1. 在主界面,可以点击photo按钮,进入相册选择图片界面; +2. 在相册界面,选择图片,点击确定按钮; +3. 自动进行选择图片的图像分类模型推理,部分推理结果显示在主界面。 + +### 工程目录 + +``` +entry +├── src/main +│   ├── etc# +|   |   └── pages +|   |       └── Index.ets // 首页,获取图片及预处理 +|   |       └── model.ets // 推理 +│   ├── resources // 资源文件 +|   |   └── rawfile +|   |       └── mobilenetv2.ms // 存放的模型文件 +``` + +### 具体实现 + +* 本示例程序中使用的终端图像分类模型文件为mobilenetv2.ms,放置在entry\src\main\resources\rawfile工程目录下。 + + 注:开发者可按需手工下载[MindSpore Model Zoo中图像分类模型](https://download.mindspore.cn/model_zoo/official/lite/mobilenetv2_openimage_lite/1.5/mobilenetv2.ms)。 + +* 调用[@ohos.file.picker](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) (图片文件选择)、[@ohos.multimedia.image](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md) (图片处理效果)、[@ohos.file.fs](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) (基础文件操作) 等API实现相册图片获取及图片处理。完整代码请参见Index.ets + +* 调用[@ohos.ai.mindSporeLite](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-mindspore-lite-kit/js-apis-mindSporeLite.md) (推理能力) API实现端侧推理。完整代码请参见model.ets + +* 调用推理函数并处理结果。完整代码请参见Index.ets + +### 相关权限 + +ohos.permission.READ_IMAGEVIDEO + +### 依赖 + +无。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568; + +2.本示例为Stage模型,已适配API version 11版本SDK; + +3.本示例需要使用DevEco Studio 4.1 Release及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/BasicFeature/ApplicationModels/MindSporeLiteArkTSDemo/ > .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/ApplicationModels/MindSporeLiteArkTSDemo/build-profile.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/build-profile.json5 index db00d928f7..04f968869f 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/build-profile.json5 @@ -1,52 +1,52 @@ -/* -* Copyright (c) 2024 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": 11, - "compileSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* +* Copyright (c) 2024 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": 11, + "compileSdkVersion": 11, + "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/ApplicationModels/MindSporeLiteArkTSDemo/entry/build-profile.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/build-profile.json5 index b2ad240f2a..609159dd69 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/build-profile.json5 @@ -1,43 +1,43 @@ -/* -* Copyright (c) 2024 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", - } - ] +/* +* Copyright (c) 2024 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/ApplicationModels/MindSporeLiteArkTSDemo/entry/oh-package.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/oh-package.json5 index 2959d78c50..248c3b7541 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "name": "entry", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/ets/entryability/EntryAbility.ets index 58056ae245..8335b7692d 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,41 +1,41 @@ -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/ets/pages/model.ets b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/ets/pages/model.ets index 7fb05a8730..cdc00f3c4e 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/ets/pages/model.ets +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/ets/pages/model.ets @@ -1,34 +1,34 @@ -import { mindSporeLite } from '@kit.MindSporeLiteKit' - -export default async function modelPredict( - modelBuffer: ArrayBuffer, inputsBuffer: ArrayBuffer[]): Promise { - - //1.创建上下文 - let context: mindSporeLite.Context = {}; - context.target = ['cpu']; - context.cpu = {} - context.cpu.threadNum = 2; - context.cpu.threadAffinityMode = 1; - context.cpu.precisionMode = 'enforce_fp32'; - - //2.加载模型 - let msLiteModel: mindSporeLite.Model = await mindSporeLite.loadModelFromBuffer(modelBuffer, context); - - //3.设置输入数据 - let modelInputs: mindSporeLite.MSTensor[] = msLiteModel.getInputs(); - - // 本模型不支持其他shape resize - for (let i = 0; i < inputsBuffer.length; i++) { - let inputBuffer = inputsBuffer[i]; - if (inputBuffer != null) { - modelInputs[i].setData(inputBuffer as ArrayBuffer); - } - } - - //4.执行推理 - console.info('=========MS_LITE_LOG: MS_LITE predict start====='); - let modelOutputs: mindSporeLite.MSTensor[] = await msLiteModel.predict(modelInputs); - return modelOutputs; -} - - +import { mindSporeLite } from '@kit.MindSporeLiteKit' + +export default async function modelPredict( + modelBuffer: ArrayBuffer, inputsBuffer: ArrayBuffer[]): Promise { + + //1.创建上下文 + let context: mindSporeLite.Context = {}; + context.target = ['cpu']; + context.cpu = {} + context.cpu.threadNum = 2; + context.cpu.threadAffinityMode = 1; + context.cpu.precisionMode = 'enforce_fp32'; + + //2.加载模型 + let msLiteModel: mindSporeLite.Model = await mindSporeLite.loadModelFromBuffer(modelBuffer, context); + + //3.设置输入数据 + let modelInputs: mindSporeLite.MSTensor[] = msLiteModel.getInputs(); + + // 本模型不支持其他shape resize + for (let i = 0; i < inputsBuffer.length; i++) { + let inputBuffer = inputsBuffer[i]; + if (inputBuffer != null) { + modelInputs[i].setData(inputBuffer as ArrayBuffer); + } + } + + //4.执行推理 + console.info('=========MS_LITE_LOG: MS_LITE predict start====='); + let modelOutputs: mindSporeLite.MSTensor[] = await msLiteModel.predict(modelInputs); + return modelOutputs; +} + + diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/module.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/module.json5 index fcd2d37ece..07bd623c85 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/module.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/module.json5 @@ -1,61 +1,61 @@ -/* -* Copyright (c) 2024-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:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.READ_IMAGEVIDEO", - "reason": "$string:read_image_video_permission", - "usedScene": { - "when": "inuse" - } - } - ] - } +/* +* Copyright (c) 2024-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:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.READ_IMAGEVIDEO", + "reason": "$string:read_image_video_permission", + "usedScene": { + "when": "inuse" + } + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/resources/base/element/color.json b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/ets/utils/Logger.ts b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/ets/utils/Logger.ts index 533c3b5b8c..db37c29936 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/ets/utils/Logger.ts +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/ets/utils/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xF811; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xF811; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('Sample_Image'); \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/ets/utils/ResourceUtil.ets b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/ets/utils/ResourceUtil.ets index 4091055493..15057e0141 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/ets/utils/ResourceUtil.ets +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/ets/utils/ResourceUtil.ets @@ -1,23 +1,23 @@ -/* -* Copyright (c) 2024 Hunan OpenValley Digital Industry Development 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; - -const delegator = AbilityDelegatorRegistry.getAbilityDelegator(); - -export function getString(resourceData: Resource): string { - let manage = delegator.getAppContext().resourceManager - return manage.getStringSync(resourceData) +/* +* Copyright (c) 2024 Hunan OpenValley Digital Industry Development 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +const delegator = AbilityDelegatorRegistry.getAbilityDelegator(); + +export function getString(resourceData: Resource): string { + let manage = delegator.getAppContext().resourceManager + return manage.getStringSync(resourceData) } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/module.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/module.json5 index adc1f0eda9..141839900c 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* -* Copyright (c) 2024 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/resources/base/element/string.json b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/resources/base/element/string.json index c3f097d6be..5955cede45 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/entry/src/ohosTest/resources/base/element/string.json @@ -1,24 +1,24 @@ -{ - "string": [ - { - "name": "module_test_desc", - "value": "test ability description" - }, - { - "name": "TestAbility_desc", - "value": "the test ability" - }, - { - "name": "TestAbility_label", - "value": "test label" - }, - { - "name": "completed", - "value": "完成" - }, - { - "name": "allow", - "value": "允许" - } - ] +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "completed", + "value": "完成" + }, + { + "name": "allow", + "value": "允许" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/hvigor/hvigor-config.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/hvigor/hvigor-config.json5 index 940738da04..2fcddb4906 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/hvigor/hvigor-config.json5 @@ -1,37 +1,37 @@ -/* -* Copyright (c) 2024 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. -*/ - -{ - "hvigorVersion": "4.1.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.1.2" - }, - "execution": { - // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ - // "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": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ - } -} +/* +* Copyright (c) 2024 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. +*/ + +{ + "hvigorVersion": "4.1.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.1.2" + }, + "execution": { + // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ + // "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": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ + } +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/oh-package.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/oh-package.json5 index e843e3734d..0fa5a5b641 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/oh-package.json5 @@ -1,29 +1,29 @@ -/* -* Copyright (c) 2024 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": "mindsporelitearktsdemo", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.16", - "@ohos/hamock": "1.0.0" - } -} +/* +* Copyright (c) 2024 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": "mindsporelitearktsdemo", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.16", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/ohosTest.md b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/ohosTest.md index bdac6d7a13..095f1d955b 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/ohosTest.md +++ b/code/DocsSample/ApplicationModels/MindSporeLiteArkTSDemo/ohosTest.md @@ -1,9 +1,9 @@ -# MindSporeLiteArkTSDemo 测试用例归档 - -## 用例表 - -|测试功能|预置条件|输入|预期输出|是否自动|测试结果| -|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------| -|拉起应用| 设备正常运行| |成功拉起应用|是|Pass| -|查看预览界面Text和Button| 进入预览界面 | |预览界面存在Text和Button|是|Pass| +# MindSporeLiteArkTSDemo 测试用例归档 + +## 用例表 + +|测试功能|预置条件|输入|预期输出|是否自动|测试结果| +|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------| +|拉起应用| 设备正常运行| |成功拉起应用|是|Pass| +|查看预览界面Text和Button| 进入预览界面 | |预览界面存在Text和Button|是|Pass| |选取图片推理功能测试| 进入预览界面 | 点击photo按钮 |选取图片后进行推理|是|Pass| \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/AppScope/app.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/AppScope/app.json5 index f61e2c4034..91270bcf39 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/AppScope/app.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* -* Copyright (c) 2024 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.mindsporelitecdemo", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* +* Copyright (c) 2024 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.mindsporelitecdemo", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/AppScope/resources/base/element/string.json b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/AppScope/resources/base/element/string.json index fd9fe25b38..8621f2cb1f 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MindSporeLiteCDemo" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "MindSporeLiteCDemo" + } + ] +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/README_zh.md b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/README_zh.md index 23d9dd4a55..cc5fcea02f 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/README_zh.md +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/README_zh.md @@ -1,85 +1,85 @@ -# **基于**Native**接口的MindSpore Lite应用开发** - -### 介绍 - -本文基于MindSpore Lite提供的[Native API](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-mindspore-lite-kit/_mind_spore.md),实现“图像分类”示例程序,来演示端侧部署的流程。 - -1. 选择图像分类模型。 -2. 将模型转换成MindSpore Lite模型格式。 -3. 使用MindSpore Lite推理模型,显示出可能的分类结果。 - -### 效果预览 - -| 主页 | -| -------------------------------------------------- | -| | - -#### 使用说明 - -1. 在主界面,可以点击photo按钮,进入相册选择图片界面; -2. 在相册界面,选择图片,点击确定按钮; -3. 自动进行选择图片的图像分类模型推理,部分推理结果显示在主界面。 - -### 工程目录 - -``` -entry -├── src/main -│   ├── etc -|   |   └── pages -|   |       └── Index.ets // 首页,获取图片及预处理 -│   ├── cpp -|   |   └── mslite_napi.cpp // 推理函数 -|   |   └── CMakeLists.txt // 编译脚本 -|   |   └── types -|   |   └── libentry -|   |       └── Index.t.ts // 将C++动态库封装成JS模块 -│   ├── resources // 资源文件 -|   |   └── rawfile -|   |       └── mobilenetv2.ms // 存放的模型文件 -``` - -### 具体实现 - -* 本示例程序中使用的终端图像分类模型文件为mobilenetv2.ms,放置在entry\src\main\resources\rawfile工程目录下。 - - 注:开发者可按需手工下载[MindSpore Model Zoo中图像分类模型](https://download.mindspore.cn/model_zoo/official/lite/mobilenetv2_openimage_lite/1.5/mobilenetv2.ms)。 - -* 调用[@ohos.file.picker](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) (图片文件选择)、[@ohos.multimedia.image](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md) (图片处理效果)、[@ohos.file.fs](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) (基础文件操作) 等API实现相册图片获取及图片处理。完整代码请参见Index.ets。 - -* 调用[MindSpore Lite Native API](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-mindspore-lite-kit/_mind_spore.md)实现推理。完整代码请参见mslite_napi.cpp。 - -* 编写CMake脚本。链接MindSpore Lite动态库,完整代码请参见CMakeLists.txt。 - -* 使用N-API将C++动态库封装成JS模块。在 entry/src/main/cpp/types/libentry/index.d.ts,定义JS接口`runDemo()` 。 - -* 调用推理函数并处理结果。完整代码请参见Index.ets - -### 相关权限 - -ohos.permission.READ_IMAGEVIDEO - -### 依赖 - -无。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,测试设备:RK3568; - -2.本示例为Stage模型,已适配API version 11版本SDK; - -3.本示例需要使用DevEco Studio 4.1 Release及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/BasicFeature/ApplicationModels/MindSporeLiteCDemo/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` - +# **基于**Native**接口的MindSpore Lite应用开发** + +### 介绍 + +本文基于MindSpore Lite提供的[Native API](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-mindspore-lite-kit/_mind_spore.md),实现“图像分类”示例程序,来演示端侧部署的流程。 + +1. 选择图像分类模型。 +2. 将模型转换成MindSpore Lite模型格式。 +3. 使用MindSpore Lite推理模型,显示出可能的分类结果。 + +### 效果预览 + +| 主页 | +| -------------------------------------------------- | +| | + +#### 使用说明 + +1. 在主界面,可以点击photo按钮,进入相册选择图片界面; +2. 在相册界面,选择图片,点击确定按钮; +3. 自动进行选择图片的图像分类模型推理,部分推理结果显示在主界面。 + +### 工程目录 + +``` +entry +├── src/main +│   ├── etc +|   |   └── pages +|   |       └── Index.ets // 首页,获取图片及预处理 +│   ├── cpp +|   |   └── mslite_napi.cpp // 推理函数 +|   |   └── CMakeLists.txt // 编译脚本 +|   |   └── types +|   |   └── libentry +|   |       └── Index.t.ts // 将C++动态库封装成JS模块 +│   ├── resources // 资源文件 +|   |   └── rawfile +|   |       └── mobilenetv2.ms // 存放的模型文件 +``` + +### 具体实现 + +* 本示例程序中使用的终端图像分类模型文件为mobilenetv2.ms,放置在entry\src\main\resources\rawfile工程目录下。 + + 注:开发者可按需手工下载[MindSpore Model Zoo中图像分类模型](https://download.mindspore.cn/model_zoo/official/lite/mobilenetv2_openimage_lite/1.5/mobilenetv2.ms)。 + +* 调用[@ohos.file.picker](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) (图片文件选择)、[@ohos.multimedia.image](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md) (图片处理效果)、[@ohos.file.fs](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) (基础文件操作) 等API实现相册图片获取及图片处理。完整代码请参见Index.ets。 + +* 调用[MindSpore Lite Native API](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-mindspore-lite-kit/_mind_spore.md)实现推理。完整代码请参见mslite_napi.cpp。 + +* 编写CMake脚本。链接MindSpore Lite动态库,完整代码请参见CMakeLists.txt。 + +* 使用N-API将C++动态库封装成JS模块。在 entry/src/main/cpp/types/libentry/index.d.ts,定义JS接口`runDemo()` 。 + +* 调用推理函数并处理结果。完整代码请参见Index.ets + +### 相关权限 + +ohos.permission.READ_IMAGEVIDEO + +### 依赖 + +无。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,测试设备:RK3568; + +2.本示例为Stage模型,已适配API version 11版本SDK; + +3.本示例需要使用DevEco Studio 4.1 Release及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/BasicFeature/ApplicationModels/MindSporeLiteCDemo/ > .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/ApplicationModels/MindSporeLiteCDemo/build-profile.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/build-profile.json5 index db00d928f7..04f968869f 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/build-profile.json5 @@ -1,52 +1,52 @@ -/* -* Copyright (c) 2024 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": 11, - "compileSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* +* Copyright (c) 2024 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": 11, + "compileSdkVersion": 11, + "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/ApplicationModels/MindSporeLiteCDemo/entry/build-profile.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/build-profile.json5 index 88ef1ccf3c..a327053464 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/build-profile.json5 @@ -1,55 +1,55 @@ -/* -* Copyright (c) 2024 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", - "abiFilters": ['arm64-v8a', 'armeabi-v7a', 'x86_64'], - "arguments": "", - "cppFlags": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": true, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* +* Copyright (c) 2024 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", + "abiFilters": ['arm64-v8a', 'armeabi-v7a', 'x86_64'], + "arguments": "", + "cppFlags": "", + } + }, + "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/ApplicationModels/MindSporeLiteCDemo/entry/oh-package.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/oh-package.json5 index b9c1d4cca7..54cb066266 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/oh-package.json5 @@ -1,11 +1,11 @@ -{ - "name": "entry", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libentry.so": "file:./src/main/cpp/types/libentry" - } +{ + "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/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/CMakeLists.txt index 879e35c6e0..f7c8404bac 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/CMakeLists.txt @@ -1,18 +1,18 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.4.1) -project(MindSporeLiteCDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED mslite_napi.cpp) -target_link_libraries(entry PUBLIC mindspore_lite_ndk) -target_link_libraries(entry PUBLIC hilog_ndk.z) -target_link_libraries(entry PUBLIC rawfile.z) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(MindSporeLiteCDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED mslite_napi.cpp) +target_link_libraries(entry PUBLIC mindspore_lite_ndk) +target_link_libraries(entry PUBLIC hilog_ndk.z) +target_link_libraries(entry PUBLIC rawfile.z) target_link_libraries(entry PUBLIC ace_napi.z) \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/mslite_napi.cpp b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/mslite_napi.cpp index b3680d1535..25128b15aa 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/mslite_napi.cpp +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/mslite_napi.cpp @@ -1,230 +1,230 @@ -/* - * Copyright (c) 2024 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define LOGI(...) ((void)OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "[MSLiteNapi]", __VA_ARGS__)) -#define LOGD(...) ((void)OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN, "[MSLiteNapi]", __VA_ARGS__)) -#define LOGW(...) ((void)OH_LOG_Print(LOG_APP, LOG_WARN, LOG_DOMAIN, "[MSLiteNapi]", __VA_ARGS__)) -#define LOGE(...) ((void)OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_DOMAIN, "[MSLiteNapi]", __VA_ARGS__)) - -constexpr int K_NUM_PRINT_OF_OUT_DATA = 20; - -int FillInputTensor(OH_AI_TensorHandle input, std::vector input_data) -{ - if (OH_AI_TensorGetDataType(input) == OH_AI_DATATYPE_NUMBERTYPE_FLOAT32) { - float *data = (float *)OH_AI_TensorGetMutableData(input); - for (size_t i = 0; i < OH_AI_TensorGetElementNum(input); i++) { - data[i] = input_data[i]; - } - return OH_AI_STATUS_SUCCESS; - } else { - return OH_AI_STATUS_LITE_ERROR; - } -} - -void *ReadModelFile(NativeResourceManager *nativeResourceManager, const std::string &modelName, size_t *modelSize) -{ - auto rawFile = OH_ResourceManager_OpenRawFile(nativeResourceManager, modelName.c_str()); - if (rawFile == nullptr) { - LOGE("MS_LITE_ERR: Open model file failed"); - return nullptr; - } - long fileSize = OH_ResourceManager_GetRawFileSize(rawFile); - if (fileSize <= 0) { - LOGE("MS_LITE_ERR: FileSize not correct"); - } - void *modelBuffer = malloc(fileSize); - if (modelBuffer == nullptr) { - LOGE("MS_LITE_ERR: OH_ResourceManager_ReadRawFile failed"); - } - int ret = OH_ResourceManager_ReadRawFile(rawFile, modelBuffer, fileSize); - if (ret == 0) { - LOGI("MS_LITE_LOG: OH_ResourceManager_ReadRawFile failed"); - OH_ResourceManager_CloseRawFile(rawFile); - return nullptr; - } - OH_ResourceManager_CloseRawFile(rawFile); - *modelSize = fileSize; - return modelBuffer; -} - -void DestroyModelBuffer(void **buffer) -{ - if (buffer == nullptr) { - return; - } - free(*buffer); - *buffer = nullptr; -} - -OH_AI_ModelHandle CreateMSLiteModel(void *modelBuffer, size_t modelSize) -{ - // Set executing context for model. - auto context = OH_AI_ContextCreate(); - if (context == nullptr) { - DestroyModelBuffer(&modelBuffer); - LOGE("MS_LITE_ERR: Create MSLite context failed.\n"); - return nullptr; - } - auto cpu_device_info = OH_AI_DeviceInfoCreate(OH_AI_DEVICETYPE_CPU); - OH_AI_DeviceInfoSetEnableFP16(cpu_device_info, true); - OH_AI_ContextAddDeviceInfo(context, cpu_device_info); - - // Create model - auto model = OH_AI_ModelCreate(); - if (model == nullptr) { - DestroyModelBuffer(&modelBuffer); - LOGE("MS_LITE_ERR: Allocate MSLite Model failed.\n"); - return nullptr; - } - - // Build model object - auto build_ret = OH_AI_ModelBuild(model, modelBuffer, modelSize, OH_AI_MODELTYPE_MINDIR, context); - DestroyModelBuffer(&modelBuffer); - if (build_ret != OH_AI_STATUS_SUCCESS) { - OH_AI_ModelDestroy(&model); - LOGE("MS_LITE_ERR: Build MSLite model failed.\n"); - return nullptr; - } - LOGI("MS_LITE_LOG: Build MSLite model success.\n"); - return model; -} - -int RunMSLiteModel(OH_AI_ModelHandle model, std::vector input_data) -{ - // Set input data for model. - auto inputs = OH_AI_ModelGetInputs(model); - auto ret = FillInputTensor(inputs.handle_list[0], input_data); - if (ret != OH_AI_STATUS_SUCCESS) { - LOGE("MS_LITE_ERR: RunMSLiteModel set input error.\n"); - return OH_AI_STATUS_LITE_ERROR; - } - - // Get model output. - auto outputs = OH_AI_ModelGetOutputs(model); - - // Predict model. - auto predict_ret = OH_AI_ModelPredict(model, inputs, &outputs, nullptr, nullptr); - if (predict_ret != OH_AI_STATUS_SUCCESS) { - OH_AI_ModelDestroy(&model); - LOGE("MS_LITE_ERR: MSLite Predict error.\n"); - return OH_AI_STATUS_LITE_ERROR; - } - LOGI("MS_LITE_LOG: Run MSLite model Predict success.\n"); - - // Print output tensor data. - LOGI("MS_LITE_LOG: Get model outputs:\n"); - for (size_t i = 0; i < outputs.handle_num; i++) { - auto tensor = outputs.handle_list[i]; - LOGI("MS_LITE_LOG: - Tensor %{public}d name is: %{public}s.\n", static_cast(i), - OH_AI_TensorGetName(tensor)); - LOGI("MS_LITE_LOG: - Tensor %{public}d size is: %{public}d.\n", static_cast(i), - (int)OH_AI_TensorGetDataSize(tensor)); - LOGI("MS_LITE_LOG: - Tensor data is:\n"); - auto out_data = reinterpret_cast(OH_AI_TensorGetData(tensor)); - std::stringstream outStr; - for (int i = 0; (i < OH_AI_TensorGetElementNum(tensor)) && (i <= K_NUM_PRINT_OF_OUT_DATA); i++) { - outStr << out_data[i] << " "; - } - LOGI("MS_LITE_LOG: %{public}s", outStr.str().c_str()); - } - return OH_AI_STATUS_SUCCESS; -} - -static napi_value RunDemo(napi_env env, napi_callback_info info) -{ - // run demo - napi_value error_ret; - napi_create_int32(env, -1, &error_ret); - // 传入数据处理 - size_t argc = 2; - napi_value argv[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - bool isArray = false; - napi_is_array(env, argv[0], &isArray); - uint32_t length = 0; - // 获取数组的长度 - napi_get_array_length(env, argv[0], &length); - std::vector input_data; - double param = 0; - for (int i = 0; i < length; i++) { - napi_value value; - napi_get_element(env, argv[0], i, &value); - napi_get_value_double(env, value, ¶m); - input_data.push_back(static_cast(param)); - } - std::stringstream outstr; - for (int i = 0; i < K_NUM_PRINT_OF_OUT_DATA; i++) { - outstr << input_data[i] << " "; - } - // Read model file - const std::string modelName = "mobilenetv2.ms"; - size_t modelSize; - auto resourcesManager = OH_ResourceManager_InitNativeResourceManager(env, argv[1]); - auto modelBuffer = ReadModelFile(resourcesManager, modelName, &modelSize); - if (modelBuffer == nullptr) { - return error_ret; - } - auto model = CreateMSLiteModel(modelBuffer, modelSize); - int ret = RunMSLiteModel(model, input_data); - if (ret != OH_AI_STATUS_SUCCESS) { - OH_AI_ModelDestroy(&model); - return error_ret; - } - napi_value out_data; - napi_create_array(env, &out_data); - auto outputs = OH_AI_ModelGetOutputs(model); - OH_AI_TensorHandle output_0 = outputs.handle_list[0]; - float *output0Data = reinterpret_cast(OH_AI_TensorGetMutableData(output_0)); - for (size_t i = 0; i < OH_AI_TensorGetElementNum(output_0); i++) { - napi_value element; - napi_create_double(env, static_cast(output0Data[i]), &element); - napi_set_element(env, out_data, i, element); - } - OH_AI_ModelDestroy(&model); - return out_data; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runDemo", nullptr, RunDemo, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2024 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOGI(...) ((void)OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "[MSLiteNapi]", __VA_ARGS__)) +#define LOGD(...) ((void)OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN, "[MSLiteNapi]", __VA_ARGS__)) +#define LOGW(...) ((void)OH_LOG_Print(LOG_APP, LOG_WARN, LOG_DOMAIN, "[MSLiteNapi]", __VA_ARGS__)) +#define LOGE(...) ((void)OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_DOMAIN, "[MSLiteNapi]", __VA_ARGS__)) + +constexpr int K_NUM_PRINT_OF_OUT_DATA = 20; + +int FillInputTensor(OH_AI_TensorHandle input, std::vector input_data) +{ + if (OH_AI_TensorGetDataType(input) == OH_AI_DATATYPE_NUMBERTYPE_FLOAT32) { + float *data = (float *)OH_AI_TensorGetMutableData(input); + for (size_t i = 0; i < OH_AI_TensorGetElementNum(input); i++) { + data[i] = input_data[i]; + } + return OH_AI_STATUS_SUCCESS; + } else { + return OH_AI_STATUS_LITE_ERROR; + } +} + +void *ReadModelFile(NativeResourceManager *nativeResourceManager, const std::string &modelName, size_t *modelSize) +{ + auto rawFile = OH_ResourceManager_OpenRawFile(nativeResourceManager, modelName.c_str()); + if (rawFile == nullptr) { + LOGE("MS_LITE_ERR: Open model file failed"); + return nullptr; + } + long fileSize = OH_ResourceManager_GetRawFileSize(rawFile); + if (fileSize <= 0) { + LOGE("MS_LITE_ERR: FileSize not correct"); + } + void *modelBuffer = malloc(fileSize); + if (modelBuffer == nullptr) { + LOGE("MS_LITE_ERR: OH_ResourceManager_ReadRawFile failed"); + } + int ret = OH_ResourceManager_ReadRawFile(rawFile, modelBuffer, fileSize); + if (ret == 0) { + LOGI("MS_LITE_LOG: OH_ResourceManager_ReadRawFile failed"); + OH_ResourceManager_CloseRawFile(rawFile); + return nullptr; + } + OH_ResourceManager_CloseRawFile(rawFile); + *modelSize = fileSize; + return modelBuffer; +} + +void DestroyModelBuffer(void **buffer) +{ + if (buffer == nullptr) { + return; + } + free(*buffer); + *buffer = nullptr; +} + +OH_AI_ModelHandle CreateMSLiteModel(void *modelBuffer, size_t modelSize) +{ + // Set executing context for model. + auto context = OH_AI_ContextCreate(); + if (context == nullptr) { + DestroyModelBuffer(&modelBuffer); + LOGE("MS_LITE_ERR: Create MSLite context failed.\n"); + return nullptr; + } + auto cpu_device_info = OH_AI_DeviceInfoCreate(OH_AI_DEVICETYPE_CPU); + OH_AI_DeviceInfoSetEnableFP16(cpu_device_info, true); + OH_AI_ContextAddDeviceInfo(context, cpu_device_info); + + // Create model + auto model = OH_AI_ModelCreate(); + if (model == nullptr) { + DestroyModelBuffer(&modelBuffer); + LOGE("MS_LITE_ERR: Allocate MSLite Model failed.\n"); + return nullptr; + } + + // Build model object + auto build_ret = OH_AI_ModelBuild(model, modelBuffer, modelSize, OH_AI_MODELTYPE_MINDIR, context); + DestroyModelBuffer(&modelBuffer); + if (build_ret != OH_AI_STATUS_SUCCESS) { + OH_AI_ModelDestroy(&model); + LOGE("MS_LITE_ERR: Build MSLite model failed.\n"); + return nullptr; + } + LOGI("MS_LITE_LOG: Build MSLite model success.\n"); + return model; +} + +int RunMSLiteModel(OH_AI_ModelHandle model, std::vector input_data) +{ + // Set input data for model. + auto inputs = OH_AI_ModelGetInputs(model); + auto ret = FillInputTensor(inputs.handle_list[0], input_data); + if (ret != OH_AI_STATUS_SUCCESS) { + LOGE("MS_LITE_ERR: RunMSLiteModel set input error.\n"); + return OH_AI_STATUS_LITE_ERROR; + } + + // Get model output. + auto outputs = OH_AI_ModelGetOutputs(model); + + // Predict model. + auto predict_ret = OH_AI_ModelPredict(model, inputs, &outputs, nullptr, nullptr); + if (predict_ret != OH_AI_STATUS_SUCCESS) { + OH_AI_ModelDestroy(&model); + LOGE("MS_LITE_ERR: MSLite Predict error.\n"); + return OH_AI_STATUS_LITE_ERROR; + } + LOGI("MS_LITE_LOG: Run MSLite model Predict success.\n"); + + // Print output tensor data. + LOGI("MS_LITE_LOG: Get model outputs:\n"); + for (size_t i = 0; i < outputs.handle_num; i++) { + auto tensor = outputs.handle_list[i]; + LOGI("MS_LITE_LOG: - Tensor %{public}d name is: %{public}s.\n", static_cast(i), + OH_AI_TensorGetName(tensor)); + LOGI("MS_LITE_LOG: - Tensor %{public}d size is: %{public}d.\n", static_cast(i), + (int)OH_AI_TensorGetDataSize(tensor)); + LOGI("MS_LITE_LOG: - Tensor data is:\n"); + auto out_data = reinterpret_cast(OH_AI_TensorGetData(tensor)); + std::stringstream outStr; + for (int i = 0; (i < OH_AI_TensorGetElementNum(tensor)) && (i <= K_NUM_PRINT_OF_OUT_DATA); i++) { + outStr << out_data[i] << " "; + } + LOGI("MS_LITE_LOG: %{public}s", outStr.str().c_str()); + } + return OH_AI_STATUS_SUCCESS; +} + +static napi_value RunDemo(napi_env env, napi_callback_info info) +{ + // run demo + napi_value error_ret; + napi_create_int32(env, -1, &error_ret); + // 传入数据处理 + size_t argc = 2; + napi_value argv[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + bool isArray = false; + napi_is_array(env, argv[0], &isArray); + uint32_t length = 0; + // 获取数组的长度 + napi_get_array_length(env, argv[0], &length); + std::vector input_data; + double param = 0; + for (int i = 0; i < length; i++) { + napi_value value; + napi_get_element(env, argv[0], i, &value); + napi_get_value_double(env, value, ¶m); + input_data.push_back(static_cast(param)); + } + std::stringstream outstr; + for (int i = 0; i < K_NUM_PRINT_OF_OUT_DATA; i++) { + outstr << input_data[i] << " "; + } + // Read model file + const std::string modelName = "mobilenetv2.ms"; + size_t modelSize; + auto resourcesManager = OH_ResourceManager_InitNativeResourceManager(env, argv[1]); + auto modelBuffer = ReadModelFile(resourcesManager, modelName, &modelSize); + if (modelBuffer == nullptr) { + return error_ret; + } + auto model = CreateMSLiteModel(modelBuffer, modelSize); + int ret = RunMSLiteModel(model, input_data); + if (ret != OH_AI_STATUS_SUCCESS) { + OH_AI_ModelDestroy(&model); + return error_ret; + } + napi_value out_data; + napi_create_array(env, &out_data); + auto outputs = OH_AI_ModelGetOutputs(model); + OH_AI_TensorHandle output_0 = outputs.handle_list[0]; + float *output0Data = reinterpret_cast(OH_AI_TensorGetMutableData(output_0)); + for (size_t i = 0; i < OH_AI_TensorGetElementNum(output_0); i++) { + napi_value element; + napi_create_double(env, static_cast(output0Data[i]), &element); + napi_set_element(env, out_data, i, element); + } + OH_AI_ModelDestroy(&model); + return out_data; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runDemo", nullptr, RunDemo, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/types/libentry/index.d.ts index 62f0867c03..9a1eb15f2c 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* -* Copyright (c) 2024 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. -*/ - +/* +* Copyright (c) 2024 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 runDemo: (a: number[], b:Object) => Array; \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/types/libentry/oh-package.json5 index b1ec375f51..87f95d0079 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,6 +1,6 @@ -{ - "name": "libentry.so", - "types": "./index.d.ts", - "version": "", - "description": "MindSpore Lite inference module" +{ + "name": "libentry.so", + "types": "./index.d.ts", + "version": "", + "description": "MindSpore Lite inference module" } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/ets/entryability/EntryAbility.ets index ca45f40113..d96a7e268e 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,41 +1,41 @@ -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/ets/pages/Index.ets index 3beb044cd4..e03f7051b4 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/ets/pages/Index.ets @@ -1,299 +1,299 @@ -/* -* Copyright (c) 2024-2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import resourceManager from '@ohos.resourceManager' -import fileIo from '@ohos.file.fs'; -import msliteNapi from 'libentry.so' -import { photoAccessHelper } from '@kit.MediaLibraryKit'; -import { BusinessError } from '@ohos.base'; -import image from '@ohos.multimedia.image'; -import { abilityAccessCtrl, Permissions } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG = 'MindSporeLite'; -const PERMISSIONS: Permissions[] = ['ohos.permission.READ_IMAGEVIDEO']; - -@Entry -@Component -struct Index { - @State message: string = 'MindSporeLite C Demo'; - @State modelName: string = 'mobilenetv2.ms'; - @State modelInputHeight: number = 224; - @State modelInputWidth: number = 224; - @State uris: Array = []; - @State max: number = 0; - @State maxIndex: number = 0; - @State maxArray: Array = []; - @State maxIndexArray: Array = []; - @State labelsNameMap: string[] = [ - 'Herd', 'Safari', 'Bangle', 'Cushion', 'Countertop', - 'Prom', 'Branch', 'Sports', 'Sky', 'Community', - 'Wheel', 'Cola', 'Tuxedo', 'Flowerpot', 'Team', - 'Computer', 'Unicycle', 'Brig', 'Aerospace engineering', 'Scuba diving', - 'Goggles', 'Fruit', 'Badminton', 'Horse', 'Sunglasses', - 'Fun', 'Prairie', 'Poster', 'Flag', 'Speedboat', - 'Eyelash', 'Veil', 'Mobile phone', 'Wheelbarrow', 'Saucer', - 'Leather', 'Drawer', 'Paper', 'Pier', 'Waterfowl', - 'Tights', 'Rickshaw', 'Vegetable', 'Handrail', 'Ice', - 'Metal', 'Flower', 'Wing', 'Silverware', 'Event', - 'Skyline', 'Money', 'Comics', 'Handbag', 'Porcelain', - 'Rodeo', 'Curtain', 'Tile', 'Human mouth', 'Army', - 'Menu', 'Boat', 'Snowboarding', 'Cairn terrier', 'Net', - 'Pasteles', 'Cup', 'Rugby', 'Pho', 'Cap', - 'Human hair', 'Surfing', 'Loveseat', 'Museum', 'Shipwreck', - 'Trunk (Tree)', 'Plush', 'Monochrome', 'Volcano', 'Rock', - 'Pillow', 'Presentation', 'Nebula', 'Subwoofer', 'Lake', - 'Sledding', 'Bangs', 'Tablecloth', 'Necklace', 'Swimwear', - 'Standing', 'Jeans', 'Carnival', 'Softball', 'Centrepiece', - 'Skateboarder', 'Cake', 'Dragon', 'Aurora', 'Skiing', - 'Bathroom', 'Dog', 'Needlework', 'Umbrella', 'Church', - 'Fire', 'Piano', 'Denim', 'Bridle', 'Cabinetry', - 'Lipstick', 'Ring', 'Television', 'Roller', 'Seal', - 'Concert', 'Product', 'News', 'Fast food', 'Horn (Animal)', - 'Tattoo', 'Bird', 'Bridegroom', 'Love', 'Helmet', - 'Dinosaur', 'Icing', 'Miniature', 'Tire', 'Toy', - 'Icicle', 'Jacket', 'Coffee', 'Mosque', 'Rowing', - 'Wetsuit', 'Camping', 'Underwater', 'Christmas', 'Gelato', - 'Whiteboard', 'Field', 'Ragdoll', 'Construction', 'Lampshade', - 'Palace', 'Meal', 'Factory', 'Cage', 'Clipper (Boat)', - 'Gymnastics', 'Turtle', 'Human foot', 'Marriage', 'Web page', - 'Human beard', 'Fog', 'Wool', 'Cappuccino', 'Lighthouse', - 'Lego', 'Sparkler', 'Sari', 'Model', 'Temple', - 'Beanie', 'Building', 'Waterfall', 'Penguin', 'Cave', - 'Stadium', 'Smile', 'Human hand', 'Park', 'Desk', - 'Shetland sheepdog', 'Bar', 'Eating', 'Neon', 'Dalmatian', - 'Crocodile', 'Wakeboarding', 'Longboard', 'Road', 'Race', - 'Kitchen', 'Odometer', 'Cliff', 'Fiction', 'School', - 'Interaction', 'Bullfighting', 'Boxer', 'Gown', 'Aquarium', - 'Superhero', 'Pie', 'Asphalt', 'Surfboard', 'Cheeseburger', - 'Screenshot', 'Supper', 'Laugh', 'Lunch', 'Party ', - 'Glacier', 'Bench', 'Grandparent', 'Sink', 'Pomacentridae', - 'Blazer', 'Brick', 'Space', 'Backpacking', 'Stuffed toy', - 'Sushi', 'Glitter', 'Bonfire', 'Castle', 'Marathon', - 'Pizza', 'Beach', 'Human ear', 'Racing', 'Sitting', - 'Iceberg', 'Shelf', 'Vehicle', 'Pop music', 'Playground', - 'Clown', 'Car', 'Rein', 'Fur', 'Musician', - 'Casino', 'Baby', 'Alcohol', 'Strap', 'Reef', - 'Balloon', 'Outerwear', 'Cathedral', 'Competition', 'Joker', - 'Blackboard', 'Bunk bed', 'Bear', 'Moon', 'Archery', - 'Polo', 'River', 'Fishing', 'Ferris wheel', 'Mortarboard', - 'Bracelet', 'Flesh', 'Statue', 'Farm', 'Desert', - 'Chain', 'Aircraft', 'Textile', 'Hot dog', 'Knitting', - 'Singer', 'Juice', 'Circus', 'Chair', 'Musical instrument', - 'Room', 'Crochet', 'Sailboat', 'Newspaper', 'Santa claus', - 'Swamp', 'Skyscraper', 'Skin', 'Rocket', 'Aviation', - 'Airliner', 'Garden', 'Ruins', 'Storm', 'Glasses', - 'Balance', 'Nail (Body part)', 'Rainbow', 'Soil ', 'Vacation ', - 'Moustache', 'Doily', 'Food', 'Bride ', 'Cattle', - 'Pocket', 'Infrastructure', 'Train', 'Gerbil', 'Fireworks', - 'Pet', 'Dam', 'Crew', 'Couch', 'Bathing', - 'Quilting', 'Motorcycle', 'Butterfly', 'Sled', 'Watercolor paint', - 'Rafting', 'Monument', 'Lightning', 'Sunset', 'Bumper', - 'Shoe', 'Waterskiing', 'Sneakers', 'Tower', 'Insect', - 'Pool', 'Placemat', 'Airplane', 'Plant', 'Jungle', - 'Armrest', 'Duck', 'Dress', 'Tableware', 'Petal', - 'Bus', 'Hanukkah', 'Forest', 'Hat', 'Barn', - 'Tubing', 'Snorkeling', 'Cool', 'Cookware and bakeware', 'Cycling', - 'Swing (Seat)', 'Muscle', 'Cat', 'Skateboard', 'Star', - 'Toe', 'Junk', 'Bicycle', 'Bedroom', 'Person', - 'Sand', 'Canyon', 'Tie', 'Twig', 'Sphynx', - 'Supervillain', 'Nightclub', 'Ranch', 'Pattern', 'Shorts', - 'Himalayan', 'Wall', 'Leggings', 'Windsurfing', 'Deejay', - 'Dance', 'Van', 'Bento', 'Sleep', 'Wine', - 'Picnic', 'Leisure', 'Dune', 'Crowd', 'Kayak', - 'Ballroom', 'Selfie', 'Graduation', 'Frigate', 'Mountain', - 'Dude', 'Windshield', 'Skiff', 'Class', 'Scarf', - 'Bull', 'Soccer', 'Bag', 'Basset hound', 'Tractor', - 'Swimming', 'Running', 'Track', 'Helicopter', 'Pitch', - 'Clock', 'Song', 'Jersey', 'Stairs', 'Flap', - 'Jewellery', 'Bridge', 'Cuisine', 'Bread', 'Caving', - 'Shell', 'Wreath', 'Roof', 'Cookie', 'Canoe' - ]; - - aboutToAppear() { - abilityAccessCtrl.createAtManager().requestPermissionsFromUser(getContext(this), PERMISSIONS).then((data) => { - if (data.authResults[0] == 0) { - hilog.info(0xFF00, TAG, '%{public}s', 'request permission success'); - } else { - hilog.info(0xFF00, TAG, '%{public}s', 'user rejected'); - } - }).catch((err: BusinessError) => { - hilog.error(0xFF00, TAG, '%{public}s', - `request permission failed, error message: ${(err as BusinessError).message}`); - }); - } - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold); - //图片显示 - Image(this.uris[0]).width(320).height(540).margin(15) - //显示分类最大值 - if (this.max) { - Text(this.labelsNameMap[this.maxIndexArray[0]] + - ': ' + - (this.maxArray[0] / 100).toString() + - '%\n' + - this.labelsNameMap[this.maxIndexArray[1]] + - ': ' + - (this.maxArray[1] / 100).toString() + - '%\n' + - this.labelsNameMap[this.maxIndexArray[2]] + - ': ' + - (this.maxArray[2] / 100).toString() + - '%\n' + - this.labelsNameMap[this.maxIndexArray[3]] + - ': ' + - (this.maxArray[3] / 100).toString() + - '%').focusable(true).fontSize(20) - } - Button() { - Text('photo') - .fontSize(30) - .fontWeight(FontWeight.Bold) - } - .type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('40%') - .height('5%') - .onClick(() => { - let resMgr: resourceManager.ResourceManager = getContext().getApplicationContext().resourceManager; - - //获取相册图片 - //1.创建图片-视频类型文件选择选项实例 - let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions(); - - //2.选择媒体文件类型和选择媒体文件的最大数目 - PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE; // 过滤选择媒体文件类型为IMAGE - PhotoSelectOptions.maxSelectNumber = 1; // 选择媒体文件的最大数目 - - //3.创建图库选择器实例,调用select()接口拉起图库界面进行文件选择。文件选择成功后,返回 photoSelectResult 结果集。 - let photoPicker = new photoAccessHelper.PhotoViewPicker(); - photoPicker.select(PhotoSelectOptions, - async (err: BusinessError, photoSelectResult: photoAccessHelper.PhotoSelectResult) => { - if (err) { - console.error('MS_LITE_ERR: PhotoViewPicker.select failed with err: ' + JSON.stringify(err)); - return; - } - console.info('MS_LITE_LOG: PhotoViewPicker.select successfully, photoSelectResult uri: ' + - JSON.stringify(photoSelectResult)); - this.uris = photoSelectResult.photoUris; - console.info('MS_LITE_LOG: uri: ' + this.uris); - try { - // 预处理图片数据 - // 1.使用fs.openSync接口,通过uri打开这个文件得到fd - let file = fileIo.openSync(this.uris[0], fileIo.OpenMode.READ_ONLY); - console.info('MS_LITE_LOG: file fd: ' + file.fd); - - // 2.通过fd使用fs.readSync接口读取这个文件内的数据 - let inputBuffer = new ArrayBuffer(4096000); - let readLen = fileIo.readSync(file.fd, inputBuffer); - console.info('MS_LITE_LOG: readSync data to file succeed and inputBuffer size is:' + readLen); - - // 3.通过 PixelMap 预处理 - let imageSource = image.createImageSource(file.fd); - let pixelMap = await imageSource.createPixelMap({ editable: true }); - let info = await pixelMap.getImageInfo(); - console.info('MS_LITE_LOG: info.width = ' + info.size.width); - console.info('MS_LITE_LOG: info.height = ' + info.size.height); - - // 4. 获取图片buffer数据readBuffer,并进行处理 - pixelMap.scale(256.0 / info.size.width, 256.0 / info.size.height).then(() => { - pixelMap.crop({ - x: 16, - y: 16, - size: { height: this.modelInputHeight, width: this.modelInputWidth } - }) - .then(async () => { - let info = await pixelMap.getImageInfo(); - console.info('MS_LITE_LOG: crop info.width = ' + info.size.width); - console.info('MS_LITE_LOG: crop info.height = ' + info.size.height); - // 需要创建的像素buffer大小 - let readBuffer = new ArrayBuffer(this.modelInputHeight * this.modelInputWidth * 4); - await pixelMap.readPixelsToBuffer(readBuffer); - console.info('MS_LITE_LOG: Succeeded in reading image pixel data, buffer: ' + readBuffer.byteLength); - - // 处理readBuffer - const imageArr = - new Uint8Array(readBuffer.slice(0, this.modelInputHeight * this.modelInputWidth * 4)); - console.info('MS_LITE_LOG: imageArr length: ' + imageArr.length); - let means = [0.485, 0.456, 0.406]; - let stds = [0.229, 0.224, 0.225]; - let float32View = new Float32Array(this.modelInputHeight * this.modelInputWidth * 3); - let index = 0; - for (let i = 0; i < imageArr.length; i++) { - if ((i + 1) % 4 == 0) { - float32View[index] = (imageArr[i - 3] / 255.0 - means[0]) / stds[0]; // B - float32View[index+1] = (imageArr[i - 2] / 255.0 - means[1]) / stds[1]; // G - float32View[index+2] = (imageArr[i - 1] / 255.0 - means[2]) / stds[2]; // R - index += 3; - } - } - console.info('MS_LITE_LOG: float32View length: ' + float32View.length); - let printStr = 'float32View data:'; - for (let i = 0; i < 20; i++) { - printStr += ' ' + float32View[i]; - } - console.info('MS_LITE_LOG: float32View data: ' + printStr); - - // 调用c++的runDemo - console.info('MS_LITE_LOG: *** Start MSLite Demo ***'); - let output: Array = msliteNapi.runDemo(Array.from(float32View), resMgr); - console.warn('MS_LITE_WARN: output length = ', output.length, ';value = ', output.slice(0, 20)); - - // 取分类最大值top5 - this.max = 0; - this.maxIndex = 0; - this.maxArray = []; - this.maxIndexArray = []; - let newArray = output.filter(value => value !== this.max); - for (let n = 0; n < 5; n++) { - this.max = output[0]; - this.maxIndex = 0; - // 取最大值 - for (let m = 0; m < newArray.length; m++) { - if (newArray[m] > this.max) { - this.max = newArray[m]; - this.maxIndex = m; - } - } - this.maxArray.push(Math.round(this.max * 10000)); - this.maxIndexArray.push(this.maxIndex); - // filter函数 数组过滤函数 - newArray = newArray.filter(value => value !== this.max); - } - console.info('MS_LITE_LOG: max:' + this.maxArray); - console.info('MS_LITE_LOG: maxIndex:' + this.maxIndexArray); - console.info('MS_LITE_LOG: *** Finished MSLite Demo ***'); - }) - }) - // 5.关闭文件 - fileIo.closeSync(file); - } catch (err) { - console.error('MS_LITE_LOG: uri: open file fd failed.' + err); - } - }) - }) - }.width('100%') - } - .height('100%') - } +/* +* Copyright (c) 2024-2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import resourceManager from '@ohos.resourceManager' +import fileIo from '@ohos.file.fs'; +import msliteNapi from 'libentry.so' +import { photoAccessHelper } from '@kit.MediaLibraryKit'; +import { BusinessError } from '@ohos.base'; +import image from '@ohos.multimedia.image'; +import { abilityAccessCtrl, Permissions } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = 'MindSporeLite'; +const PERMISSIONS: Permissions[] = ['ohos.permission.READ_IMAGEVIDEO']; + +@Entry +@Component +struct Index { + @State message: string = 'MindSporeLite C Demo'; + @State modelName: string = 'mobilenetv2.ms'; + @State modelInputHeight: number = 224; + @State modelInputWidth: number = 224; + @State uris: Array = []; + @State max: number = 0; + @State maxIndex: number = 0; + @State maxArray: Array = []; + @State maxIndexArray: Array = []; + @State labelsNameMap: string[] = [ + 'Herd', 'Safari', 'Bangle', 'Cushion', 'Countertop', + 'Prom', 'Branch', 'Sports', 'Sky', 'Community', + 'Wheel', 'Cola', 'Tuxedo', 'Flowerpot', 'Team', + 'Computer', 'Unicycle', 'Brig', 'Aerospace engineering', 'Scuba diving', + 'Goggles', 'Fruit', 'Badminton', 'Horse', 'Sunglasses', + 'Fun', 'Prairie', 'Poster', 'Flag', 'Speedboat', + 'Eyelash', 'Veil', 'Mobile phone', 'Wheelbarrow', 'Saucer', + 'Leather', 'Drawer', 'Paper', 'Pier', 'Waterfowl', + 'Tights', 'Rickshaw', 'Vegetable', 'Handrail', 'Ice', + 'Metal', 'Flower', 'Wing', 'Silverware', 'Event', + 'Skyline', 'Money', 'Comics', 'Handbag', 'Porcelain', + 'Rodeo', 'Curtain', 'Tile', 'Human mouth', 'Army', + 'Menu', 'Boat', 'Snowboarding', 'Cairn terrier', 'Net', + 'Pasteles', 'Cup', 'Rugby', 'Pho', 'Cap', + 'Human hair', 'Surfing', 'Loveseat', 'Museum', 'Shipwreck', + 'Trunk (Tree)', 'Plush', 'Monochrome', 'Volcano', 'Rock', + 'Pillow', 'Presentation', 'Nebula', 'Subwoofer', 'Lake', + 'Sledding', 'Bangs', 'Tablecloth', 'Necklace', 'Swimwear', + 'Standing', 'Jeans', 'Carnival', 'Softball', 'Centrepiece', + 'Skateboarder', 'Cake', 'Dragon', 'Aurora', 'Skiing', + 'Bathroom', 'Dog', 'Needlework', 'Umbrella', 'Church', + 'Fire', 'Piano', 'Denim', 'Bridle', 'Cabinetry', + 'Lipstick', 'Ring', 'Television', 'Roller', 'Seal', + 'Concert', 'Product', 'News', 'Fast food', 'Horn (Animal)', + 'Tattoo', 'Bird', 'Bridegroom', 'Love', 'Helmet', + 'Dinosaur', 'Icing', 'Miniature', 'Tire', 'Toy', + 'Icicle', 'Jacket', 'Coffee', 'Mosque', 'Rowing', + 'Wetsuit', 'Camping', 'Underwater', 'Christmas', 'Gelato', + 'Whiteboard', 'Field', 'Ragdoll', 'Construction', 'Lampshade', + 'Palace', 'Meal', 'Factory', 'Cage', 'Clipper (Boat)', + 'Gymnastics', 'Turtle', 'Human foot', 'Marriage', 'Web page', + 'Human beard', 'Fog', 'Wool', 'Cappuccino', 'Lighthouse', + 'Lego', 'Sparkler', 'Sari', 'Model', 'Temple', + 'Beanie', 'Building', 'Waterfall', 'Penguin', 'Cave', + 'Stadium', 'Smile', 'Human hand', 'Park', 'Desk', + 'Shetland sheepdog', 'Bar', 'Eating', 'Neon', 'Dalmatian', + 'Crocodile', 'Wakeboarding', 'Longboard', 'Road', 'Race', + 'Kitchen', 'Odometer', 'Cliff', 'Fiction', 'School', + 'Interaction', 'Bullfighting', 'Boxer', 'Gown', 'Aquarium', + 'Superhero', 'Pie', 'Asphalt', 'Surfboard', 'Cheeseburger', + 'Screenshot', 'Supper', 'Laugh', 'Lunch', 'Party ', + 'Glacier', 'Bench', 'Grandparent', 'Sink', 'Pomacentridae', + 'Blazer', 'Brick', 'Space', 'Backpacking', 'Stuffed toy', + 'Sushi', 'Glitter', 'Bonfire', 'Castle', 'Marathon', + 'Pizza', 'Beach', 'Human ear', 'Racing', 'Sitting', + 'Iceberg', 'Shelf', 'Vehicle', 'Pop music', 'Playground', + 'Clown', 'Car', 'Rein', 'Fur', 'Musician', + 'Casino', 'Baby', 'Alcohol', 'Strap', 'Reef', + 'Balloon', 'Outerwear', 'Cathedral', 'Competition', 'Joker', + 'Blackboard', 'Bunk bed', 'Bear', 'Moon', 'Archery', + 'Polo', 'River', 'Fishing', 'Ferris wheel', 'Mortarboard', + 'Bracelet', 'Flesh', 'Statue', 'Farm', 'Desert', + 'Chain', 'Aircraft', 'Textile', 'Hot dog', 'Knitting', + 'Singer', 'Juice', 'Circus', 'Chair', 'Musical instrument', + 'Room', 'Crochet', 'Sailboat', 'Newspaper', 'Santa claus', + 'Swamp', 'Skyscraper', 'Skin', 'Rocket', 'Aviation', + 'Airliner', 'Garden', 'Ruins', 'Storm', 'Glasses', + 'Balance', 'Nail (Body part)', 'Rainbow', 'Soil ', 'Vacation ', + 'Moustache', 'Doily', 'Food', 'Bride ', 'Cattle', + 'Pocket', 'Infrastructure', 'Train', 'Gerbil', 'Fireworks', + 'Pet', 'Dam', 'Crew', 'Couch', 'Bathing', + 'Quilting', 'Motorcycle', 'Butterfly', 'Sled', 'Watercolor paint', + 'Rafting', 'Monument', 'Lightning', 'Sunset', 'Bumper', + 'Shoe', 'Waterskiing', 'Sneakers', 'Tower', 'Insect', + 'Pool', 'Placemat', 'Airplane', 'Plant', 'Jungle', + 'Armrest', 'Duck', 'Dress', 'Tableware', 'Petal', + 'Bus', 'Hanukkah', 'Forest', 'Hat', 'Barn', + 'Tubing', 'Snorkeling', 'Cool', 'Cookware and bakeware', 'Cycling', + 'Swing (Seat)', 'Muscle', 'Cat', 'Skateboard', 'Star', + 'Toe', 'Junk', 'Bicycle', 'Bedroom', 'Person', + 'Sand', 'Canyon', 'Tie', 'Twig', 'Sphynx', + 'Supervillain', 'Nightclub', 'Ranch', 'Pattern', 'Shorts', + 'Himalayan', 'Wall', 'Leggings', 'Windsurfing', 'Deejay', + 'Dance', 'Van', 'Bento', 'Sleep', 'Wine', + 'Picnic', 'Leisure', 'Dune', 'Crowd', 'Kayak', + 'Ballroom', 'Selfie', 'Graduation', 'Frigate', 'Mountain', + 'Dude', 'Windshield', 'Skiff', 'Class', 'Scarf', + 'Bull', 'Soccer', 'Bag', 'Basset hound', 'Tractor', + 'Swimming', 'Running', 'Track', 'Helicopter', 'Pitch', + 'Clock', 'Song', 'Jersey', 'Stairs', 'Flap', + 'Jewellery', 'Bridge', 'Cuisine', 'Bread', 'Caving', + 'Shell', 'Wreath', 'Roof', 'Cookie', 'Canoe' + ]; + + aboutToAppear() { + abilityAccessCtrl.createAtManager().requestPermissionsFromUser(getContext(this), PERMISSIONS).then((data) => { + if (data.authResults[0] == 0) { + hilog.info(0xFF00, TAG, '%{public}s', 'request permission success'); + } else { + hilog.info(0xFF00, TAG, '%{public}s', 'user rejected'); + } + }).catch((err: BusinessError) => { + hilog.error(0xFF00, TAG, '%{public}s', + `request permission failed, error message: ${(err as BusinessError).message}`); + }); + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold); + //图片显示 + Image(this.uris[0]).width(320).height(540).margin(15) + //显示分类最大值 + if (this.max) { + Text(this.labelsNameMap[this.maxIndexArray[0]] + + ': ' + + (this.maxArray[0] / 100).toString() + + '%\n' + + this.labelsNameMap[this.maxIndexArray[1]] + + ': ' + + (this.maxArray[1] / 100).toString() + + '%\n' + + this.labelsNameMap[this.maxIndexArray[2]] + + ': ' + + (this.maxArray[2] / 100).toString() + + '%\n' + + this.labelsNameMap[this.maxIndexArray[3]] + + ': ' + + (this.maxArray[3] / 100).toString() + + '%').focusable(true).fontSize(20) + } + Button() { + Text('photo') + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + .onClick(() => { + let resMgr: resourceManager.ResourceManager = getContext().getApplicationContext().resourceManager; + + //获取相册图片 + //1.创建图片-视频类型文件选择选项实例 + let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions(); + + //2.选择媒体文件类型和选择媒体文件的最大数目 + PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE; // 过滤选择媒体文件类型为IMAGE + PhotoSelectOptions.maxSelectNumber = 1; // 选择媒体文件的最大数目 + + //3.创建图库选择器实例,调用select()接口拉起图库界面进行文件选择。文件选择成功后,返回 photoSelectResult 结果集。 + let photoPicker = new photoAccessHelper.PhotoViewPicker(); + photoPicker.select(PhotoSelectOptions, + async (err: BusinessError, photoSelectResult: photoAccessHelper.PhotoSelectResult) => { + if (err) { + console.error('MS_LITE_ERR: PhotoViewPicker.select failed with err: ' + JSON.stringify(err)); + return; + } + console.info('MS_LITE_LOG: PhotoViewPicker.select successfully, photoSelectResult uri: ' + + JSON.stringify(photoSelectResult)); + this.uris = photoSelectResult.photoUris; + console.info('MS_LITE_LOG: uri: ' + this.uris); + try { + // 预处理图片数据 + // 1.使用fs.openSync接口,通过uri打开这个文件得到fd + let file = fileIo.openSync(this.uris[0], fileIo.OpenMode.READ_ONLY); + console.info('MS_LITE_LOG: file fd: ' + file.fd); + + // 2.通过fd使用fs.readSync接口读取这个文件内的数据 + let inputBuffer = new ArrayBuffer(4096000); + let readLen = fileIo.readSync(file.fd, inputBuffer); + console.info('MS_LITE_LOG: readSync data to file succeed and inputBuffer size is:' + readLen); + + // 3.通过 PixelMap 预处理 + let imageSource = image.createImageSource(file.fd); + let pixelMap = await imageSource.createPixelMap({ editable: true }); + let info = await pixelMap.getImageInfo(); + console.info('MS_LITE_LOG: info.width = ' + info.size.width); + console.info('MS_LITE_LOG: info.height = ' + info.size.height); + + // 4. 获取图片buffer数据readBuffer,并进行处理 + pixelMap.scale(256.0 / info.size.width, 256.0 / info.size.height).then(() => { + pixelMap.crop({ + x: 16, + y: 16, + size: { height: this.modelInputHeight, width: this.modelInputWidth } + }) + .then(async () => { + let info = await pixelMap.getImageInfo(); + console.info('MS_LITE_LOG: crop info.width = ' + info.size.width); + console.info('MS_LITE_LOG: crop info.height = ' + info.size.height); + // 需要创建的像素buffer大小 + let readBuffer = new ArrayBuffer(this.modelInputHeight * this.modelInputWidth * 4); + await pixelMap.readPixelsToBuffer(readBuffer); + console.info('MS_LITE_LOG: Succeeded in reading image pixel data, buffer: ' + readBuffer.byteLength); + + // 处理readBuffer + const imageArr = + new Uint8Array(readBuffer.slice(0, this.modelInputHeight * this.modelInputWidth * 4)); + console.info('MS_LITE_LOG: imageArr length: ' + imageArr.length); + let means = [0.485, 0.456, 0.406]; + let stds = [0.229, 0.224, 0.225]; + let float32View = new Float32Array(this.modelInputHeight * this.modelInputWidth * 3); + let index = 0; + for (let i = 0; i < imageArr.length; i++) { + if ((i + 1) % 4 == 0) { + float32View[index] = (imageArr[i - 3] / 255.0 - means[0]) / stds[0]; // B + float32View[index+1] = (imageArr[i - 2] / 255.0 - means[1]) / stds[1]; // G + float32View[index+2] = (imageArr[i - 1] / 255.0 - means[2]) / stds[2]; // R + index += 3; + } + } + console.info('MS_LITE_LOG: float32View length: ' + float32View.length); + let printStr = 'float32View data:'; + for (let i = 0; i < 20; i++) { + printStr += ' ' + float32View[i]; + } + console.info('MS_LITE_LOG: float32View data: ' + printStr); + + // 调用c++的runDemo + console.info('MS_LITE_LOG: *** Start MSLite Demo ***'); + let output: Array = msliteNapi.runDemo(Array.from(float32View), resMgr); + console.warn('MS_LITE_WARN: output length = ', output.length, ';value = ', output.slice(0, 20)); + + // 取分类最大值top5 + this.max = 0; + this.maxIndex = 0; + this.maxArray = []; + this.maxIndexArray = []; + let newArray = output.filter(value => value !== this.max); + for (let n = 0; n < 5; n++) { + this.max = output[0]; + this.maxIndex = 0; + // 取最大值 + for (let m = 0; m < newArray.length; m++) { + if (newArray[m] > this.max) { + this.max = newArray[m]; + this.maxIndex = m; + } + } + this.maxArray.push(Math.round(this.max * 10000)); + this.maxIndexArray.push(this.maxIndex); + // filter函数 数组过滤函数 + newArray = newArray.filter(value => value !== this.max); + } + console.info('MS_LITE_LOG: max:' + this.maxArray); + console.info('MS_LITE_LOG: maxIndex:' + this.maxIndexArray); + console.info('MS_LITE_LOG: *** Finished MSLite Demo ***'); + }) + }) + // 5.关闭文件 + fileIo.closeSync(file); + } catch (err) { + console.error('MS_LITE_LOG: uri: open file fd failed.' + err); + } + }) + }) + }.width('100%') + } + .height('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/module.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/module.json5 index fcd2d37ece..07bd623c85 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/module.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/module.json5 @@ -1,61 +1,61 @@ -/* -* Copyright (c) 2024-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:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.READ_IMAGEVIDEO", - "reason": "$string:read_image_video_permission", - "usedScene": { - "when": "inuse" - } - } - ] - } +/* +* Copyright (c) 2024-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:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.READ_IMAGEVIDEO", + "reason": "$string:read_image_video_permission", + "usedScene": { + "when": "inuse" + } + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/resources/base/element/color.json b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/ets/utils/ResourceUtil.ets b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/ets/utils/ResourceUtil.ets index 974d871dde..02ea87bfcb 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/ets/utils/ResourceUtil.ets +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/ets/utils/ResourceUtil.ets @@ -1,23 +1,23 @@ -/* -* Copyright (c) 2024 Hunan OpenValley Digital Industry Development 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; - -const delegator = AbilityDelegatorRegistry.getAbilityDelegator(); - -export function getString(resourceData: Resource): string { - let manage = delegator.getAppContext().resourceManager; - return manage.getStringSync(resourceData); +/* +* Copyright (c) 2024 Hunan OpenValley Digital Industry Development 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +const delegator = AbilityDelegatorRegistry.getAbilityDelegator(); + +export function getString(resourceData: Resource): string { + let manage = delegator.getAppContext().resourceManager; + return manage.getStringSync(resourceData); } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/module.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/module.json5 index adc1f0eda9..141839900c 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* -* Copyright (c) 2024 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/resources/base/element/string.json b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/resources/base/element/string.json index c3f097d6be..5955cede45 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/entry/src/ohosTest/resources/base/element/string.json @@ -1,24 +1,24 @@ -{ - "string": [ - { - "name": "module_test_desc", - "value": "test ability description" - }, - { - "name": "TestAbility_desc", - "value": "the test ability" - }, - { - "name": "TestAbility_label", - "value": "test label" - }, - { - "name": "completed", - "value": "完成" - }, - { - "name": "allow", - "value": "允许" - } - ] +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "completed", + "value": "完成" + }, + { + "name": "allow", + "value": "允许" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/hvigor/hvigor-config.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/hvigor/hvigor-config.json5 index 940738da04..2fcddb4906 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/hvigor/hvigor-config.json5 @@ -1,37 +1,37 @@ -/* -* Copyright (c) 2024 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. -*/ - -{ - "hvigorVersion": "4.1.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.1.2" - }, - "execution": { - // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ - // "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": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ - } -} +/* +* Copyright (c) 2024 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. +*/ + +{ + "hvigorVersion": "4.1.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.1.2" + }, + "execution": { + // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ + // "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": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ + } +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/oh-package.json5 b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/oh-package.json5 index 506c2e28d7..46a1e640b5 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/oh-package.json5 @@ -1,29 +1,29 @@ -/* -* Copyright (c) 2024 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": "mindsporelitecdemo", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.16", - "@ohos/hamock": "1.0.0" - } -} +/* +* Copyright (c) 2024 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": "mindsporelitecdemo", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.16", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/ohosTest.md b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/ohosTest.md index d05c51db3e..4adddf5499 100644 --- a/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/ohosTest.md +++ b/code/DocsSample/ApplicationModels/MindSporeLiteCDemo/ohosTest.md @@ -1,9 +1,9 @@ -# MindSporeLiteCDemo 测试用例归档 - -## 用例表 - -|测试功能|预置条件|输入|预期输出|是否自动|测试结果| -|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------| -|拉起应用| 设备正常运行| |成功拉起应用|是|Pass| -|查看预览界面Text和Button| 进入预览界面 | |预览界面存在Text和Button|是|Pass| +# MindSporeLiteCDemo 测试用例归档 + +## 用例表 + +|测试功能|预置条件|输入|预期输出|是否自动|测试结果| +|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------| +|拉起应用| 设备正常运行| |成功拉起应用|是|Pass| +|查看预览界面Text和Button| 进入预览界面 | |预览界面存在Text和Button|是|Pass| |选取图片推理功能测试| 进入预览界面 | 点击photo按钮 |选取图片后进行推理|是|Pass| \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/AppScope/app.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/AppScope/app.json5 index 2492cc660e..3c846ef8bd 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/AppScope/app.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.stagemodelabilitydevelop", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.stagemodelabilitydevelop", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/AppScope/resources/base/element/string.json b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/AppScope/resources/base/element/string.json index a7353b08cd..86a92ba52c 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "StageModelAbilityDevelop" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "StageModelAbilityDevelop" + } + ] +} diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/build-profile.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/build-profile.json5 index b4ed08ad14..9ab0a5df27 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/build-profile.json5 @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ], - "signingConfigs": [ - - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ], + "signingConfigs": [ + + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/build-profile.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/build-profile.json5 index 32345d66a3..8296d8e04d 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/oh-package.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/oh-package.json5 index 60d792bb92..413a75299a 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/i_idl_service_ext.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/i_idl_service_ext.ts index dfe2d12447..f597be317d 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/i_idl_service_ext.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/i_idl_service_ext.ts @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2023 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 default interface IIdlServiceExt { - processData(data: number, callback: ProcessDataCallback): void; - insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void; -} - -export type ProcessDataCallback = (errCode: number, returnValue: number) => void; - -export type InsertDataToMapCallback = (errCode: number) => void; +/* + * Copyright (c) 2023 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 default interface IIdlServiceExt { + processData(data: number, callback: ProcessDataCallback): void; + insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void; +} + +export type ProcessDataCallback = (errCode: number, returnValue: number) => void; + +export type InsertDataToMapCallback = (errCode: number) => void; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts index bf39e5c408..729991942b 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2023 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import bundleManager from '@ohos.bundle.bundleManager'; -import IdlServiceExtStub from './idl_service_ext_stub'; -import hilog from '@ohos.hilog'; -import rpc from '@ohos.rpc'; -import type { BusinessError } from '@ohos.base'; -import type { InsertDataToMapCallback } from './i_idl_service_ext'; -import type { ProcessDataCallback } from './i_idl_service_ext'; - -const ERR_OK = 0; -const TAG: string = '[IdlServiceExtImpl]'; -const DOMAIN_NUMBER: number = 0xFF00; -const ERR_DENY = -1; - -// 开发者需要在这个类型里对接口进行实现 -export default class ServiceExtImpl extends IdlServiceExtStub { - processData(data: number, callback: ProcessDataCallback): void { - // 开发者自行实现业务逻辑 - hilog.info(DOMAIN_NUMBER, TAG, `processData: ${data}`); - - let callerUid = rpc.IPCSkeleton.getCallingUid(); - bundleManager.getBundleNameByUid(callerUid).then((callerBundleName) => { - hilog.info(DOMAIN_NUMBER, TAG, 'getBundleNameByUid: ' + callerBundleName); - // 对客户端包名进行识别 - if (callerBundleName !== 'com.samples.stagemodelabilitydevelop') { // 识别不通过 - hilog.info(DOMAIN_NUMBER, TAG, 'The caller bundle is not in trustlist, reject'); - return; - } - // 识别通过,执行正常业务逻辑 - }).catch((err: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, 'getBundleNameByUid failed: ' + err.message); - }); - - let callerTokenId = rpc.IPCSkeleton.getCallingTokenId(); - let accessManger = abilityAccessCtrl.createAtManager(); - // 所校验的具体权限由开发者自行选择,此处ohos.permission.GET_BUNDLE_INFO_PRIVILEGED只作为示例 - let grantStatus = accessManger.verifyAccessTokenSync(callerTokenId, 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'); - if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) { - hilog.info(DOMAIN_NUMBER, TAG, 'PERMISSION_DENIED'); - callback(ERR_DENY, data); // 鉴权失败,返回错误 - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'verify access token success.'); - callback(ERR_OK, data + 1); // 鉴权通过,执行正常业务逻辑 - }; - - insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { - // 开发者自行实现业务逻辑 - hilog.info(DOMAIN_NUMBER, TAG, `insertDataToMap, key: ${key} val: ${val}`); - callback(ERR_OK); - }; +/* + * Copyright (c) 2023 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import bundleManager from '@ohos.bundle.bundleManager'; +import IdlServiceExtStub from './idl_service_ext_stub'; +import hilog from '@ohos.hilog'; +import rpc from '@ohos.rpc'; +import type { BusinessError } from '@ohos.base'; +import type { InsertDataToMapCallback } from './i_idl_service_ext'; +import type { ProcessDataCallback } from './i_idl_service_ext'; + +const ERR_OK = 0; +const TAG: string = '[IdlServiceExtImpl]'; +const DOMAIN_NUMBER: number = 0xFF00; +const ERR_DENY = -1; + +// 开发者需要在这个类型里对接口进行实现 +export default class ServiceExtImpl extends IdlServiceExtStub { + processData(data: number, callback: ProcessDataCallback): void { + // 开发者自行实现业务逻辑 + hilog.info(DOMAIN_NUMBER, TAG, `processData: ${data}`); + + let callerUid = rpc.IPCSkeleton.getCallingUid(); + bundleManager.getBundleNameByUid(callerUid).then((callerBundleName) => { + hilog.info(DOMAIN_NUMBER, TAG, 'getBundleNameByUid: ' + callerBundleName); + // 对客户端包名进行识别 + if (callerBundleName !== 'com.samples.stagemodelabilitydevelop') { // 识别不通过 + hilog.info(DOMAIN_NUMBER, TAG, 'The caller bundle is not in trustlist, reject'); + return; + } + // 识别通过,执行正常业务逻辑 + }).catch((err: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, 'getBundleNameByUid failed: ' + err.message); + }); + + let callerTokenId = rpc.IPCSkeleton.getCallingTokenId(); + let accessManger = abilityAccessCtrl.createAtManager(); + // 所校验的具体权限由开发者自行选择,此处ohos.permission.GET_BUNDLE_INFO_PRIVILEGED只作为示例 + let grantStatus = accessManger.verifyAccessTokenSync(callerTokenId, 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'); + if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) { + hilog.info(DOMAIN_NUMBER, TAG, 'PERMISSION_DENIED'); + callback(ERR_DENY, data); // 鉴权失败,返回错误 + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'verify access token success.'); + callback(ERR_OK, data + 1); // 鉴权通过,执行正常业务逻辑 + }; + + insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { + // 开发者自行实现业务逻辑 + hilog.info(DOMAIN_NUMBER, TAG, `insertDataToMap, key: ${key} val: ${val}`); + callback(ERR_OK); + }; }; \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_proxy.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_proxy.ts index cffa32373c..d777730206 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_proxy.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_proxy.ts @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2023 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 type { ProcessDataCallback } from './i_idl_service_ext'; -import type { InsertDataToMapCallback } from './i_idl_service_ext'; -import type IIdlServiceExt from './i_idl_service_ext'; -import hilog from '@ohos.hilog'; -import rpc from '@ohos.rpc'; - -const TAG: string = '[IdlServiceExtProxy]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class IdlServiceExtProxy implements IIdlServiceExt { - static readonly COMMAND_PROCESS_DATA = 1; - static readonly COMMAND_INSERT_DATA_TO_MAP = 2; - private proxy; - - constructor(proxy) { - this.proxy = proxy; - }; - - processData(data: number, callback: ProcessDataCallback): void { - let option = new rpc.MessageOption(); - let dataSequence = rpc.MessageSequence.create(); - let replySequence = rpc.MessageSequence.create(); - try { - dataSequence.writeInt(data); - this.proxy.sendMessageRequest(IdlServiceExtProxy.COMMAND_PROCESS_DATA, dataSequence, replySequence, option).then(function (result) { - if (result.errCode === 0) { - let errCodeVar = result.reply.readInt(); - if (errCodeVar !== 0) { - let returnValueVar = undefined; - callback(errCodeVar, returnValueVar); - return; - } - let returnValueVar = result.reply.readInt(); - callback(errCodeVar, returnValueVar); - } else { - hilog.info(DOMAIN_NUMBER, TAG, 'sendMessageRequest failed, errCode: ' + result.errCode); - } - }); - } finally { - dataSequence.reclaim(); - replySequence.reclaim(); - }; - }; - - insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { - let option = new rpc.MessageOption(); - let dataSequence = rpc.MessageSequence.create(); - let replySequence = rpc.MessageSequence.create(); - try { - dataSequence.writeString(key); - dataSequence.writeInt(val); - this.proxy.sendMessageRequest(IdlServiceExtProxy.COMMAND_INSERT_DATA_TO_MAP, dataSequence, replySequence, option).then(function (result) { - if (result.errCode === 0) { - let errCodeVar = result.reply.readInt(); - callback(errCodeVar); - } else { - hilog.info(DOMAIN_NUMBER, TAG, 'sendMessageRequest failed, errCode: ' + result.errCode); - } - }); - } finally { - dataSequence.reclaim(); - replySequence.reclaim(); - }; - }; -}; - +/* + * Copyright (c) 2023 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 type { ProcessDataCallback } from './i_idl_service_ext'; +import type { InsertDataToMapCallback } from './i_idl_service_ext'; +import type IIdlServiceExt from './i_idl_service_ext'; +import hilog from '@ohos.hilog'; +import rpc from '@ohos.rpc'; + +const TAG: string = '[IdlServiceExtProxy]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class IdlServiceExtProxy implements IIdlServiceExt { + static readonly COMMAND_PROCESS_DATA = 1; + static readonly COMMAND_INSERT_DATA_TO_MAP = 2; + private proxy; + + constructor(proxy) { + this.proxy = proxy; + }; + + processData(data: number, callback: ProcessDataCallback): void { + let option = new rpc.MessageOption(); + let dataSequence = rpc.MessageSequence.create(); + let replySequence = rpc.MessageSequence.create(); + try { + dataSequence.writeInt(data); + this.proxy.sendMessageRequest(IdlServiceExtProxy.COMMAND_PROCESS_DATA, dataSequence, replySequence, option).then(function (result) { + if (result.errCode === 0) { + let errCodeVar = result.reply.readInt(); + if (errCodeVar !== 0) { + let returnValueVar = undefined; + callback(errCodeVar, returnValueVar); + return; + } + let returnValueVar = result.reply.readInt(); + callback(errCodeVar, returnValueVar); + } else { + hilog.info(DOMAIN_NUMBER, TAG, 'sendMessageRequest failed, errCode: ' + result.errCode); + } + }); + } finally { + dataSequence.reclaim(); + replySequence.reclaim(); + }; + }; + + insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { + let option = new rpc.MessageOption(); + let dataSequence = rpc.MessageSequence.create(); + let replySequence = rpc.MessageSequence.create(); + try { + dataSequence.writeString(key); + dataSequence.writeInt(val); + this.proxy.sendMessageRequest(IdlServiceExtProxy.COMMAND_INSERT_DATA_TO_MAP, dataSequence, replySequence, option).then(function (result) { + if (result.errCode === 0) { + let errCodeVar = result.reply.readInt(); + callback(errCodeVar); + } else { + hilog.info(DOMAIN_NUMBER, TAG, 'sendMessageRequest failed, errCode: ' + result.errCode); + } + }); + } finally { + dataSequence.reclaim(); + replySequence.reclaim(); + }; + }; +}; + diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_stub.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_stub.ts index 9d200b2327..5a20eae5c8 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_stub.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/IdlServiceExt/idl_service_ext_stub.ts @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2023 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 type { ProcessDataCallback } from './i_idl_service_ext'; -import type { InsertDataToMapCallback } from './i_idl_service_ext'; -import type IIdlServiceExt from './i_idl_service_ext'; -import hilog from '@ohos.hilog'; -import rpc from '@ohos.rpc'; - -const TAG: string = '[IdlServiceExtStub]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class IdlServiceExtStub extends rpc.RemoteObject implements IIdlServiceExt { - constructor(des: string) { - super(des); - }; - - async onRemoteMessageRequest(code: number, data: rpc.MessageSequence, reply: rpc.MessageSequence, option: rpc.MessageOption): Promise { - hilog.info(DOMAIN_NUMBER, TAG, 'onRemoteMessageRequest called, code = ' + code); - switch (code) { - case IdlServiceExtStub.COMMAND_PROCESS_DATA: { - let dataVar = data.readInt(); - let promise = new Promise((resolve, reject) => { - this.processData(dataVar, (errCode, returnValue) => { - reply.writeInt(errCode); - if (errCode === 0) { - reply.writeInt(returnValue); - } - resolve(); - }); - }); - await promise; - return true; - }; - case IdlServiceExtStub.COMMAND_INSERT_DATA_TO_MAP: { - let keyVar = data.readString(); - let valVar = data.readInt(); - let promise = new Promise((resolve, reject) => { - this.insertDataToMap(keyVar, valVar, (errCode) => { - reply.writeInt(errCode); - resolve(); - }); - }); - await promise; - return true; - }; - default: { - hilog.info(DOMAIN_NUMBER, TAG, 'invalid request code' + code); - break; - } - } - return false; - } - - processData(data: number, callback: ProcessDataCallback): void { - }; - - insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { - }; - - static readonly COMMAND_PROCESS_DATA = 1; - static readonly COMMAND_INSERT_DATA_TO_MAP = 2; +/* + * Copyright (c) 2023 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 type { ProcessDataCallback } from './i_idl_service_ext'; +import type { InsertDataToMapCallback } from './i_idl_service_ext'; +import type IIdlServiceExt from './i_idl_service_ext'; +import hilog from '@ohos.hilog'; +import rpc from '@ohos.rpc'; + +const TAG: string = '[IdlServiceExtStub]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class IdlServiceExtStub extends rpc.RemoteObject implements IIdlServiceExt { + constructor(des: string) { + super(des); + }; + + async onRemoteMessageRequest(code: number, data: rpc.MessageSequence, reply: rpc.MessageSequence, option: rpc.MessageOption): Promise { + hilog.info(DOMAIN_NUMBER, TAG, 'onRemoteMessageRequest called, code = ' + code); + switch (code) { + case IdlServiceExtStub.COMMAND_PROCESS_DATA: { + let dataVar = data.readInt(); + let promise = new Promise((resolve, reject) => { + this.processData(dataVar, (errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode === 0) { + reply.writeInt(returnValue); + } + resolve(); + }); + }); + await promise; + return true; + }; + case IdlServiceExtStub.COMMAND_INSERT_DATA_TO_MAP: { + let keyVar = data.readString(); + let valVar = data.readInt(); + let promise = new Promise((resolve, reject) => { + this.insertDataToMap(keyVar, valVar, (errCode) => { + reply.writeInt(errCode); + resolve(); + }); + }); + await promise; + return true; + }; + default: { + hilog.info(DOMAIN_NUMBER, TAG, 'invalid request code' + code); + break; + } + } + return false; + } + + processData(data: number, callback: ProcessDataCallback): void { + }; + + insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { + }; + + static readonly COMMAND_PROCESS_DATA = 1; + static readonly COMMAND_INSERT_DATA_TO_MAP = 2; }; \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/collaborateability/CollaborateAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/collaborateability/CollaborateAbility.ts index 078734e912..bd938d896a 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/collaborateability/CollaborateAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/collaborateability/CollaborateAbility.ts @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type Want from '@ohos.app.ability.Want'; -import type window from '@ohos.window'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import type { BusinessError } from '@ohos.base'; -import type { Context } from '@ohos.abilityAccessCtrl'; -import type { PermissionRequestResult } from '@ohos.abilityAccessCtrl'; -import type { Permissions } from '@ohos.abilityAccessCtrl'; - -const permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; - -const TAG: string = '[CollaborateAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class CollaborateAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - // Main window is created, set main page for this ability - let context: Context = this.context; - let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); - // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 - atManager.requestPermissionsFromUser(context, permissions).then((data: PermissionRequestResult) => { - let grantStatus: Array = data.authResults; - let length: number = grantStatus.length; - for (let i = 0; i < length; i++) { - if (grantStatus[i] === 0) { - // 用户授权,可以继续访问目标操作 - } else { - // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 - return; - } - } - // 授权成功 - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); - }); - }; - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/page_collaborateability/Page_CollaborateAbility', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - }; -}; +/* + * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type Want from '@ohos.app.ability.Want'; +import type window from '@ohos.window'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import type { BusinessError } from '@ohos.base'; +import type { Context } from '@ohos.abilityAccessCtrl'; +import type { PermissionRequestResult } from '@ohos.abilityAccessCtrl'; +import type { Permissions } from '@ohos.abilityAccessCtrl'; + +const permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; + +const TAG: string = '[CollaborateAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class CollaborateAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + // Main window is created, set main page for this ability + let context: Context = this.context; + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); + // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 + atManager.requestPermissionsFromUser(context, permissions).then((data: PermissionRequestResult) => { + let grantStatus: Array = data.authResults; + let length: number = grantStatus.length; + for (let i = 0; i < length; i++) { + if (grantStatus[i] === 0) { + // 用户授权,可以继续访问目标操作 + } else { + // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 + return; + } + } + // 授权成功 + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); + }); + }; + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + windowStage.loadContent('pages/page_collaborateability/Page_CollaborateAbility', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + }; +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/MultitonAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/MultitonAbility.ts index b2aed9ae4d..8afc4d47bf 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/MultitonAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/MultitonAbility.ts @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type window from '@ohos.window'; - -const TAG: string = '[MultitonAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class MultitonAbility extends UIAbility { - onCreate(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/page_startupability/Page_Multiton', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } -}; +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; + +const TAG: string = '[MultitonAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class MultitonAbility extends UIAbility { + onCreate(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + windowStage.loadContent('pages/page_startupability/Page_Multiton', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SingletonAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SingletonAbility.ts index f27bf7a689..6ca907f751 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SingletonAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SingletonAbility.ts @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type window from '@ohos.window'; - -const TAG: string = '[SingletonAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class SingletonAbility extends UIAbility { - onCreate(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/page_startupability/Page_Singleton', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } -}; +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; + +const TAG: string = '[SingletonAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class SingletonAbility extends UIAbility { + onCreate(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + windowStage.loadContent('pages/page_startupability/Page_Singleton', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SpecifiedFirstAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SpecifiedFirstAbility.ts index a97f18a328..233b088557 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SpecifiedFirstAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SpecifiedFirstAbility.ts @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import type window from '@ohos.window'; - -export default class SpecifiedFirstAbility extends UIAbility { - - onWindowStageCreate(windowStage: window.WindowStage): void { - // 设置UI加载 - windowStage.loadContent('pages/page_startupability/Page_Specified_First', (err, data) => { - }); - } +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; + +export default class SpecifiedFirstAbility extends UIAbility { + + onWindowStageCreate(windowStage: window.WindowStage): void { + // 设置UI加载 + windowStage.loadContent('pages/page_startupability/Page_Specified_First', (err, data) => { + }); + } }; \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SpecifiedSecondAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SpecifiedSecondAbility.ts index 493b77bd22..aad0077087 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SpecifiedSecondAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/componentstartupability/SpecifiedSecondAbility.ts @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import type window from '@ohos.window'; - -export default class SpecifiedSecondAbility extends UIAbility { - - onWindowStageCreate(windowStage: window.WindowStage): void { - // 设置UI加载 - windowStage.loadContent('pages/page_startupability/Page_Specified_Second', (err, data) => { - }); - } +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; + +export default class SpecifiedSecondAbility extends UIAbility { + + onWindowStageCreate(windowStage: window.WindowStage): void { + // 设置UI加载 + windowStage.loadContent('pages/page_startupability/Page_Specified_Second', (err, data) => { + }); + } }; \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/contextability/ContextAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/contextability/ContextAbility.ts index cf3278aacf..a8e30282bc 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/contextability/ContextAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/contextability/ContextAbility.ts @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type Want from '@ohos.app.ability.Want'; -import type window from '@ohos.window'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import type { Context } from '@ohos.abilityAccessCtrl'; -import type { PermissionRequestResult } from '@ohos.abilityAccessCtrl'; -import type { Permissions } from '@ohos.abilityAccessCtrl'; -import type { BusinessError } from '@ohos.base'; - -const permissions: Array = ['ohos.permission.GET_BUNDLE_INFO_PRIVILEGED']; -const TAG: string = '[ContextAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class ContextAbility extends UIAbility { - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - windowStage.loadContent('pages/page_contextability/Page_ContextAbility', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - - // Main window is created, set main page for this ability - let context: Context = this.context; - let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); - // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 - atManager.requestPermissionsFromUser(context, permissions).then((data: PermissionRequestResult) => { - let grantStatus: Array = data.authResults; - let length: number = grantStatus.length; - for (let i = 0; i < length; i++) { - if (grantStatus[i] === 0) { - // 用户授权,可以继续访问目标操作 - } else { - // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 - return; - } - } - // 授权成功 - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); - }); - } -}; +/* + * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type Want from '@ohos.app.ability.Want'; +import type window from '@ohos.window'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import type { Context } from '@ohos.abilityAccessCtrl'; +import type { PermissionRequestResult } from '@ohos.abilityAccessCtrl'; +import type { Permissions } from '@ohos.abilityAccessCtrl'; +import type { BusinessError } from '@ohos.base'; + +const permissions: Array = ['ohos.permission.GET_BUNDLE_INFO_PRIVILEGED']; +const TAG: string = '[ContextAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class ContextAbility extends UIAbility { + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/page_contextability/Page_ContextAbility', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + + // Main window is created, set main page for this ability + let context: Context = this.context; + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); + // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 + atManager.requestPermissionsFromUser(context, permissions).then((data: PermissionRequestResult) => { + let grantStatus: Array = data.authResults; + let length: number = grantStatus.length; + for (let i = 0; i < length; i++) { + if (grantStatus[i] === 0) { + // 用户授权,可以继续访问目标操作 + } else { + // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 + return; + } + } + // 授权成功 + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); + }); + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/entryability/EntryAbility.ts index 082e8ee9d6..7105fbba70 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,122 +1,122 @@ -/* - * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; -import type { BusinessError } from '@ohos.base'; -import type { Configuration } from '@ohos.app.ability.Configuration'; - -const TAG: string = '[EntryAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -let systemLanguage: string | undefined; // 系统当前语言 - -export default class EntryAbility extends UIAbility { - windowStage: window.WindowStage | undefined = undefined; - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - // Main window is created, set main page for this ability - let uiAbilityContext = this.context; - let applicationContext = this.context.getApplicationContext(); - systemLanguage = this.context.config.language; // UIAbility实例首次加载时,获取系统当前语言 - hilog.info(DOMAIN_NUMBER, TAG, `systemLanguage is ${systemLanguage}`); - } - - onDestroy(): void { - // 系统资源的释放、数据的保存等 - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - this.windowStage = windowStage; - // 设置WindowStage的事件订阅(获焦/失焦、可见/不可见) - try { - windowStage.on('windowStageEvent', (data) => { - let stageEventType: window.WindowStageEventType = data; - switch (stageEventType) { - case window.WindowStageEventType.SHOWN: // 切到前台 - hilog.info(DOMAIN_NUMBER, TAG, 'windowStage foreground.'); - break; - case window.WindowStageEventType.ACTIVE: // 获焦状态 - hilog.info(DOMAIN_NUMBER, TAG, 'windowStage active.'); - break; - case window.WindowStageEventType.INACTIVE: // 失焦状态 - hilog.info(DOMAIN_NUMBER, TAG, 'windowStage inactive.'); - break; - case window.WindowStageEventType.HIDDEN: // 切到后台 - hilog.info(DOMAIN_NUMBER, TAG, 'windowStage background.'); - break; - default: - break; - } - }); - } catch (exception) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to enable the listener for window stage event changes. Cause:' + JSON.stringify(exception)); - }; - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - // 设置UI加载 - // Main window is created, set main page for this ability - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy'); - // 释放UI资源 - // 例如在onWindowStageDestroy()中注销获焦/失焦等WindowStage事件 - try { - if (this.windowStage) { - this.windowStage.off('windowStageEvent'); - } - } catch (err) { - let code = (err as BusinessError).code; - let message = (err as BusinessError).message; - hilog.error(DOMAIN_NUMBER, TAG, `Failed to disable the listener for windowStageEvent. Code is ${code}, message is ${message}`); - }; - } - - onForeground(): void { - // 申请系统需要的资源,或者重新申请在onBackground()中释放的资源 - // Ability has brought to foreground - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // 释放UI不可见时无用的资源,或者在此回调中执行较为耗时的操作 - // 例如状态保存等 - // Ability has back to background - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground'); - } - - onConfigurationUpdate(newConfig: Configuration): void { - hilog.info(DOMAIN_NUMBER, TAG, `onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`); - - if (systemLanguage !== newConfig.language) { - hilog.info(DOMAIN_NUMBER, TAG, `systemLanguage from ${systemLanguage} changed to ${newConfig.language}`); - systemLanguage = newConfig.language; // 将变化之后的系统语言保存,作为下一次变化前的系统语言 - } - } -}; +/* + * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import type { BusinessError } from '@ohos.base'; +import type { Configuration } from '@ohos.app.ability.Configuration'; + +const TAG: string = '[EntryAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +let systemLanguage: string | undefined; // 系统当前语言 + +export default class EntryAbility extends UIAbility { + windowStage: window.WindowStage | undefined = undefined; + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + // Main window is created, set main page for this ability + let uiAbilityContext = this.context; + let applicationContext = this.context.getApplicationContext(); + systemLanguage = this.context.config.language; // UIAbility实例首次加载时,获取系统当前语言 + hilog.info(DOMAIN_NUMBER, TAG, `systemLanguage is ${systemLanguage}`); + } + + onDestroy(): void { + // 系统资源的释放、数据的保存等 + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + this.windowStage = windowStage; + // 设置WindowStage的事件订阅(获焦/失焦、可见/不可见) + try { + windowStage.on('windowStageEvent', (data) => { + let stageEventType: window.WindowStageEventType = data; + switch (stageEventType) { + case window.WindowStageEventType.SHOWN: // 切到前台 + hilog.info(DOMAIN_NUMBER, TAG, 'windowStage foreground.'); + break; + case window.WindowStageEventType.ACTIVE: // 获焦状态 + hilog.info(DOMAIN_NUMBER, TAG, 'windowStage active.'); + break; + case window.WindowStageEventType.INACTIVE: // 失焦状态 + hilog.info(DOMAIN_NUMBER, TAG, 'windowStage inactive.'); + break; + case window.WindowStageEventType.HIDDEN: // 切到后台 + hilog.info(DOMAIN_NUMBER, TAG, 'windowStage background.'); + break; + default: + break; + } + }); + } catch (exception) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to enable the listener for window stage event changes. Cause:' + JSON.stringify(exception)); + }; + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + // 设置UI加载 + // Main window is created, set main page for this ability + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + // 释放UI资源 + // 例如在onWindowStageDestroy()中注销获焦/失焦等WindowStage事件 + try { + if (this.windowStage) { + this.windowStage.off('windowStageEvent'); + } + } catch (err) { + let code = (err as BusinessError).code; + let message = (err as BusinessError).message; + hilog.error(DOMAIN_NUMBER, TAG, `Failed to disable the listener for windowStageEvent. Code is ${code}, message is ${message}`); + }; + } + + onForeground(): void { + // 申请系统需要的资源,或者重新申请在onBackground()中释放的资源 + // Ability has brought to foreground + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // 释放UI不可见时无用的资源,或者在此回调中执行较为耗时的操作 + // 例如状态保存等 + // Ability has back to background + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground'); + } + + onConfigurationUpdate(newConfig: Configuration): void { + hilog.info(DOMAIN_NUMBER, TAG, `onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`); + + if (systemLanguage !== newConfig.language) { + hilog.info(DOMAIN_NUMBER, TAG, `systemLanguage from ${systemLanguage} changed to ${newConfig.language}`); + systemLanguage = newConfig.language; // 将变化之后的系统语言保存,作为下一次变化前的系统语言 + } + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/eventability/EventAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/eventability/EventAbility.ts index 34175f6a1b..d39e41e3fa 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/eventability/EventAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/eventability/EventAbility.ts @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type window from '@ohos.window'; -import type Want from '@ohos.app.ability.Want'; -import type { Context } from '@ohos.abilityAccessCtrl'; - -const TAG: string = '[EventAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class EventAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - // 获取UIAbility实例的上下文 - let context = this.context; - // 获取eventHub - let eventhub = this.context.eventHub; - // 执行订阅操作 - eventhub.on('event1', this.eventFunc); - eventhub.on('event1', (data: string) => { - // 触发事件,完成相应的业务操作 - }); - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Page_EventHub', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } - - eventFunc(argOne: Context, argTwo: Context): void { - hilog.info(DOMAIN_NUMBER, TAG, '1. ' + `${argOne}, ${argTwo}`); - return; - } -}; +/* + * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; +import type Want from '@ohos.app.ability.Want'; +import type { Context } from '@ohos.abilityAccessCtrl'; + +const TAG: string = '[EventAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class EventAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // 获取UIAbility实例的上下文 + let context = this.context; + // 获取eventHub + let eventhub = this.context.eventHub; + // 执行订阅操作 + eventhub.on('event1', this.eventFunc); + eventhub.on('event1', (data: string) => { + // 触发事件,完成相应的业务操作 + }); + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Page_EventHub', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + eventFunc(argOne: Context, argTwo: Context): void { + hilog.info(DOMAIN_NUMBER, TAG, '1. ' + `${argOne}, ${argTwo}`); + return; + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/funcability/FuncAbilityA.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/funcability/FuncAbilityA.ts index 0bf0b7e121..54c7737bf5 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/funcability/FuncAbilityA.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/funcability/FuncAbilityA.ts @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type window from '@ohos.window'; -import type Want from '@ohos.app.ability.Want'; - -export default class FuncAbilityA extends UIAbility { - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - // 接收调用方UIAbility传过来的参数 - let funcAbilityWant = want; - let info = funcAbilityWant?.parameters?.info; - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // 设置UI加载 - windowStage.loadContent('pages/page_funcability/Page_FuncAbilityA', (err, data) => { - }); - } -}; +/* + * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; +import type Want from '@ohos.app.ability.Want'; + +export default class FuncAbilityA extends UIAbility { + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // 接收调用方UIAbility传过来的参数 + let funcAbilityWant = want; + let info = funcAbilityWant?.parameters?.info; + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // 设置UI加载 + windowStage.loadContent('pages/page_funcability/Page_FuncAbilityA', (err, data) => { + }); + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/funcability/FuncAbilityB.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/funcability/FuncAbilityB.ts index ea9e64845f..327885f7cf 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/funcability/FuncAbilityB.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/funcability/FuncAbilityB.ts @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import type window from '@ohos.window'; - -export default class FuncAbilityB extends UIAbility { - onWindowStageCreate(windowStage: window.WindowStage): void { - // 设置UI加载 - windowStage.loadContent('pages/page_funcability/Page_FuncAbilityB', (err, data) => { - }); - } -}; +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; + +export default class FuncAbilityB extends UIAbility { + onWindowStageCreate(windowStage: window.WindowStage): void { + // 设置UI加载 + windowStage.loadContent('pages/page_funcability/Page_FuncAbilityB', (err, data) => { + }); + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/lifecycleability/LifecycleAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/lifecycleability/LifecycleAbility.ts index 8fc5a9312c..e00ecf84bf 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/lifecycleability/LifecycleAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/lifecycleability/LifecycleAbility.ts @@ -1,93 +1,93 @@ -/* - * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import type AbilityLifecycleCallback from '@ohos.app.ability.AbilityLifecycleCallback'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type Want from '@ohos.app.ability.Want'; -import type window from '@ohos.window'; - -const TAG: string = '[LifecycleAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class LifecycleAbility extends UIAbility { - // 定义生命周期ID - lifecycleId: number = -1; - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - // 定义生命周期回调对象 - let abilityLifecycleCallback: AbilityLifecycleCallback = { - // 当UIAbility创建时被调用 - onAbilityCreate(uiAbility) { - hilog.info(DOMAIN_NUMBER, TAG, `onAbilityCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); - }, - // 当窗口创建时被调用 - onWindowStageCreate(uiAbility, windowStage: window.WindowStage) { - hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); - hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageCreate windowStage: ${JSON.stringify(windowStage)}`); - }, - // 当窗口处于活动状态时被调用 - onWindowStageActive(uiAbility, windowStage: window.WindowStage) { - hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageActive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); - hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageActive windowStage: ${JSON.stringify(windowStage)}`); - }, - // 当窗口处于非活动状态时被调用 - onWindowStageInactive(uiAbility, windowStage: window.WindowStage) { - hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageInactive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); - hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageInactive windowStage: ${JSON.stringify(windowStage)}`); - }, - // 当窗口被销毁时被调用 - onWindowStageDestroy(uiAbility, windowStage: window.WindowStage) { - hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); - hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageDestroy windowStage: ${JSON.stringify(windowStage)}`); - }, - // 当UIAbility被销毁时被调用 - onAbilityDestroy(uiAbility) { - hilog.info(DOMAIN_NUMBER, TAG, `onAbilityDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); - }, - // 当UIAbility从后台转到前台时触发回调 - onAbilityForeground(uiAbility) { - hilog.info(DOMAIN_NUMBER, TAG, `onAbilityForeground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); - }, - // 当UIAbility从前台转到后台时触发回调 - onAbilityBackground(uiAbility) { - hilog.info(DOMAIN_NUMBER, TAG, `onAbilityBackground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); - }, - // 当UIAbility迁移时被调用 - onAbilityContinue(uiAbility) { - hilog.info(DOMAIN_NUMBER, TAG, `onAbilityContinue uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); - } - }; - // 获取应用上下文 - let applicationContext = this.context.getApplicationContext(); - // 注册应用内生命周期回调 - this.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); - hilog.info(DOMAIN_NUMBER, TAG, `register callback number: ${this.lifecycleId}`); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // 设置UI加载 - windowStage.loadContent('pages/page_funcability/Page_FuncAbilityA', (err, data) => { - }); - } - - onDestroy() : void { - // 获取应用上下文 - let applicationContext = this.context.getApplicationContext(); - // 取消应用内生命周期回调 - applicationContext.off('abilityLifecycle', this.lifecycleId); - } -}; +/* + * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import type AbilityLifecycleCallback from '@ohos.app.ability.AbilityLifecycleCallback'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type Want from '@ohos.app.ability.Want'; +import type window from '@ohos.window'; + +const TAG: string = '[LifecycleAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class LifecycleAbility extends UIAbility { + // 定义生命周期ID + lifecycleId: number = -1; + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // 定义生命周期回调对象 + let abilityLifecycleCallback: AbilityLifecycleCallback = { + // 当UIAbility创建时被调用 + onAbilityCreate(uiAbility) { + hilog.info(DOMAIN_NUMBER, TAG, `onAbilityCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + }, + // 当窗口创建时被调用 + onWindowStageCreate(uiAbility, windowStage: window.WindowStage) { + hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageCreate windowStage: ${JSON.stringify(windowStage)}`); + }, + // 当窗口处于活动状态时被调用 + onWindowStageActive(uiAbility, windowStage: window.WindowStage) { + hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageActive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageActive windowStage: ${JSON.stringify(windowStage)}`); + }, + // 当窗口处于非活动状态时被调用 + onWindowStageInactive(uiAbility, windowStage: window.WindowStage) { + hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageInactive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageInactive windowStage: ${JSON.stringify(windowStage)}`); + }, + // 当窗口被销毁时被调用 + onWindowStageDestroy(uiAbility, windowStage: window.WindowStage) { + hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + hilog.info(DOMAIN_NUMBER, TAG, `onWindowStageDestroy windowStage: ${JSON.stringify(windowStage)}`); + }, + // 当UIAbility被销毁时被调用 + onAbilityDestroy(uiAbility) { + hilog.info(DOMAIN_NUMBER, TAG, `onAbilityDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + }, + // 当UIAbility从后台转到前台时触发回调 + onAbilityForeground(uiAbility) { + hilog.info(DOMAIN_NUMBER, TAG, `onAbilityForeground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + }, + // 当UIAbility从前台转到后台时触发回调 + onAbilityBackground(uiAbility) { + hilog.info(DOMAIN_NUMBER, TAG, `onAbilityBackground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + }, + // 当UIAbility迁移时被调用 + onAbilityContinue(uiAbility) { + hilog.info(DOMAIN_NUMBER, TAG, `onAbilityContinue uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + } + }; + // 获取应用上下文 + let applicationContext = this.context.getApplicationContext(); + // 注册应用内生命周期回调 + this.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); + hilog.info(DOMAIN_NUMBER, TAG, `register callback number: ${this.lifecycleId}`); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // 设置UI加载 + windowStage.loadContent('pages/page_funcability/Page_FuncAbilityA', (err, data) => { + }); + } + + onDestroy() : void { + // 获取应用上下文 + let applicationContext = this.context.getApplicationContext(); + // 取消应用内生命周期回调 + applicationContext.off('abilityLifecycle', this.lifecycleId); + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/migrationability/MigrationAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/migrationability/MigrationAbility.ts index db20d3fc37..d4f0a9ea1e 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/migrationability/MigrationAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/migrationability/MigrationAbility.ts @@ -1,142 +1,142 @@ -/* - * Copyright (c) 2023-2024 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 from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type Want from '@ohos.app.ability.Want'; -import wantConstant from '@ohos.app.ability.wantConstant'; -import type window from '@ohos.window'; -import type { Context, PermissionRequestResult, Permissions } from '@ohos.abilityAccessCtrl'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import type { BusinessError } from '@ohos.base'; - -const permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; -const TAG: string = '[MigrationAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class MigrationAbility extends UIAbility { - storage: LocalStorage = new LocalStorage(); - - // 对端恢复 - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - - // 获取分布式数据 - if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { - // 将want保存的数据取出恢复 - let continueInput = ''; - if (want.parameters !== undefined) { - continueInput = JSON.stringify(want.parameters.data); - hilog.info(DOMAIN_NUMBER, TAG, `continue input ${continueInput}`); - } - // 将数据显示当前页面 - this.context.restoreWindowStage(this.storage); - } - // 调用原因为迁移时,设置状态为可迁移,应对冷启动情况 - this.context.setMissionContinueState(AbilityConstant.ContinueState.ACTIVE, (result) => { - hilog.info(DOMAIN_NUMBER, TAG, `setMissionContinueState ACTIVE result: ${JSON.stringify(result)}`); - }); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/page_migrationability/Page_MigrationAbilityFirst', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - // Main window is created, set main page for this ability - let context: Context = this.context; - let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); - // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 - atManager.requestPermissionsFromUser(context, permissions).then((data: PermissionRequestResult) => { - let grantStatus: Array = data.authResults; - let length: number = grantStatus.length; - for (let i = 0; i < length; i++) { - if (grantStatus[i] === 0) { - // 用户授权,可以继续访问目标操作 - } else { - // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 - return; - } - } - // 授权成功 - }).catch((err: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, `Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); - }); - } - - // 源端保存 - onContinue(wantParam: Record): AbilityConstant.OnContinueResult { - let version = wantParam.version; - let targetDevice = wantParam.targetDevice; - hilog.info(DOMAIN_NUMBER, TAG, `onContinue version = ${version}, targetDevice: ${targetDevice}`); // 准备迁移数据 - - // 获取源端版本号 - let versionSrc: number = -1; // 请填充具体获取版本号的代码 - - // 兼容性校验 - if (version !== versionSrc) { - // 在兼容性校验不通过时返回MISMATCH - return AbilityConstant.OnContinueResult.MISMATCH; - } - - // 将要迁移的数据保存在wantParam的自定义字段(例如data)中 - const continueInput = '迁移的数据'; - wantParam['data'] = continueInput; - - //设置不迁移页面栈&迁移后源端不退出 - wantParam[wantConstant.Params.SUPPORT_CONTINUE_PAGE_STACK_KEY] = false; - wantParam[wantConstant.Params.SUPPORT_CONTINUE_SOURCE_EXIT_KEY] = false; - - return AbilityConstant.OnContinueResult.AGREE; - } - - onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN_NUMBER, TAG, 'onNewWant'); - - if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { - // get user data from want params - let continueInput = ''; - if (want.parameters !== undefined) { - continueInput = JSON.stringify(want.parameters.data); - hilog.info(DOMAIN_NUMBER, TAG, `continue input ${JSON.stringify(continueInput)}`); - } - this.context.restoreWindowStage(this.storage); - } - - // 调用原因为迁移时,设置状态为可迁移,应对热启动情况 - if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { - this.context.setMissionContinueState(AbilityConstant.ContinueState.ACTIVE, (result) => { - hilog.info(DOMAIN_NUMBER, TAG, `setMissionContinueState ACTIVE result: ${JSON.stringify(result)}`); - }); - } - } - - onWindowStageRestore(windowStage: window.WindowStage): void { - // 若不需要自动迁移页面栈信息,则需要在此处设置应用迁移后进入的页面 - windowStage.loadContent('pages/page_migrationability/Page_MigrationAbilityThird', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - }); - } -}; +/* + * Copyright (c) 2023-2024 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 from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type Want from '@ohos.app.ability.Want'; +import wantConstant from '@ohos.app.ability.wantConstant'; +import type window from '@ohos.window'; +import type { Context, PermissionRequestResult, Permissions } from '@ohos.abilityAccessCtrl'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import type { BusinessError } from '@ohos.base'; + +const permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; +const TAG: string = '[MigrationAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class MigrationAbility extends UIAbility { + storage: LocalStorage = new LocalStorage(); + + // 对端恢复 + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + + // 获取分布式数据 + if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { + // 将want保存的数据取出恢复 + let continueInput = ''; + if (want.parameters !== undefined) { + continueInput = JSON.stringify(want.parameters.data); + hilog.info(DOMAIN_NUMBER, TAG, `continue input ${continueInput}`); + } + // 将数据显示当前页面 + this.context.restoreWindowStage(this.storage); + } + // 调用原因为迁移时,设置状态为可迁移,应对冷启动情况 + this.context.setMissionContinueState(AbilityConstant.ContinueState.ACTIVE, (result) => { + hilog.info(DOMAIN_NUMBER, TAG, `setMissionContinueState ACTIVE result: ${JSON.stringify(result)}`); + }); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/page_migrationability/Page_MigrationAbilityFirst', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + // Main window is created, set main page for this ability + let context: Context = this.context; + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); + // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 + atManager.requestPermissionsFromUser(context, permissions).then((data: PermissionRequestResult) => { + let grantStatus: Array = data.authResults; + let length: number = grantStatus.length; + for (let i = 0; i < length; i++) { + if (grantStatus[i] === 0) { + // 用户授权,可以继续访问目标操作 + } else { + // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 + return; + } + } + // 授权成功 + }).catch((err: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, `Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); + }); + } + + // 源端保存 + onContinue(wantParam: Record): AbilityConstant.OnContinueResult { + let version = wantParam.version; + let targetDevice = wantParam.targetDevice; + hilog.info(DOMAIN_NUMBER, TAG, `onContinue version = ${version}, targetDevice: ${targetDevice}`); // 准备迁移数据 + + // 获取源端版本号 + let versionSrc: number = -1; // 请填充具体获取版本号的代码 + + // 兼容性校验 + if (version !== versionSrc) { + // 在兼容性校验不通过时返回MISMATCH + return AbilityConstant.OnContinueResult.MISMATCH; + } + + // 将要迁移的数据保存在wantParam的自定义字段(例如data)中 + const continueInput = '迁移的数据'; + wantParam['data'] = continueInput; + + //设置不迁移页面栈&迁移后源端不退出 + wantParam[wantConstant.Params.SUPPORT_CONTINUE_PAGE_STACK_KEY] = false; + wantParam[wantConstant.Params.SUPPORT_CONTINUE_SOURCE_EXIT_KEY] = false; + + return AbilityConstant.OnContinueResult.AGREE; + } + + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN_NUMBER, TAG, 'onNewWant'); + + if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { + // get user data from want params + let continueInput = ''; + if (want.parameters !== undefined) { + continueInput = JSON.stringify(want.parameters.data); + hilog.info(DOMAIN_NUMBER, TAG, `continue input ${JSON.stringify(continueInput)}`); + } + this.context.restoreWindowStage(this.storage); + } + + // 调用原因为迁移时,设置状态为可迁移,应对热启动情况 + if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { + this.context.setMissionContinueState(AbilityConstant.ContinueState.ACTIVE, (result) => { + hilog.info(DOMAIN_NUMBER, TAG, `setMissionContinueState ACTIVE result: ${JSON.stringify(result)}`); + }); + } + } + + onWindowStageRestore(windowStage: window.WindowStage): void { + // 若不需要自动迁移页面栈信息,则需要在此处设置应用迁移后进入的页面 + windowStage.loadContent('pages/page_migrationability/Page_MigrationAbilityThird', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + }); + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/myabilitystage/MyAbilityStage.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/myabilitystage/MyAbilityStage.ts index b9ce6c7071..d7738ef4b0 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/myabilitystage/MyAbilityStage.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/myabilitystage/MyAbilityStage.ts @@ -1,63 +1,63 @@ -/* - * Copyright (c) 2023 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 AbilityStage from '@ohos.app.ability.AbilityStage'; -import type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import type Want from '@ohos.app.ability.Want'; -import type { Configuration } from '@ohos.app.ability.Configuration'; - -const TAG: string = '[MyAbilityStage]'; -const DOMAIN_NUMBER: number = 0xFF00; - -let systemLanguage: string | undefined; // 系统当前语言 - -export default class MyAbilityStage extends AbilityStage { - onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN_NUMBER, TAG, `onNewWant, want: ${want.abilityName}`); - hilog.info(DOMAIN_NUMBER, TAG, `onNewWant, launchParam: ${JSON.stringify(launchParam)}`); - } - onCreate(): void { - // 应用的HAP在首次加载的时,为该Module初始化操作 - systemLanguage = this.context.config.language; // Module首次加载时,获取系统当前语言 - hilog.info(DOMAIN_NUMBER, TAG, `systemLanguage is ${systemLanguage}`); - let abilityStageContext = this.context; - } - onAcceptWant(want: Want): string { - // 仅specified模式下触发 - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting SpecifiedAbility'); - // 在被调用方的AbilityStage中,针对启动模式为specified的UIAbility返回一个UIAbility实例对应的一个Key值 - // 当前示例指的是module1 Module的SpecifiedAbility - if (want.abilityName === 'SpecifiedFirstAbility' || want.abilityName === 'SpecifiedSecondAbility') { - // 返回的字符串Key标识为自定义拼接的字符串内容 - if (want.parameters) { - return `SpecifiedAbilityInstance_${want.parameters.instanceKey}`; - } - } - return 'MyAbilityStage'; - } - onMemoryLevel(level: AbilityConstant.MemoryLevel): void { - // 根据系统可用内存的变化情况,释放不必要的内存 - } - onConfigurationUpdate(newConfig: Configuration): void { - hilog.info(DOMAIN_NUMBER, TAG, `onConfigurationUpdate, language: ${newConfig.language}`); - hilog.info(DOMAIN_NUMBER, TAG, `onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`); - - if (systemLanguage !== newConfig.language) { - hilog.info(DOMAIN_NUMBER, TAG, `systemLanguage from ${systemLanguage} changed to ${newConfig.language}`); - systemLanguage = newConfig.language; // 将变化之后的系统语言保存,作为下一次变化前的系统语言 - } - } -}; +/* + * Copyright (c) 2023 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 AbilityStage from '@ohos.app.ability.AbilityStage'; +import type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import type Want from '@ohos.app.ability.Want'; +import type { Configuration } from '@ohos.app.ability.Configuration'; + +const TAG: string = '[MyAbilityStage]'; +const DOMAIN_NUMBER: number = 0xFF00; + +let systemLanguage: string | undefined; // 系统当前语言 + +export default class MyAbilityStage extends AbilityStage { + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN_NUMBER, TAG, `onNewWant, want: ${want.abilityName}`); + hilog.info(DOMAIN_NUMBER, TAG, `onNewWant, launchParam: ${JSON.stringify(launchParam)}`); + } + onCreate(): void { + // 应用的HAP在首次加载的时,为该Module初始化操作 + systemLanguage = this.context.config.language; // Module首次加载时,获取系统当前语言 + hilog.info(DOMAIN_NUMBER, TAG, `systemLanguage is ${systemLanguage}`); + let abilityStageContext = this.context; + } + onAcceptWant(want: Want): string { + // 仅specified模式下触发 + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting SpecifiedAbility'); + // 在被调用方的AbilityStage中,针对启动模式为specified的UIAbility返回一个UIAbility实例对应的一个Key值 + // 当前示例指的是module1 Module的SpecifiedAbility + if (want.abilityName === 'SpecifiedFirstAbility' || want.abilityName === 'SpecifiedSecondAbility') { + // 返回的字符串Key标识为自定义拼接的字符串内容 + if (want.parameters) { + return `SpecifiedAbilityInstance_${want.parameters.instanceKey}`; + } + } + return 'MyAbilityStage'; + } + onMemoryLevel(level: AbilityConstant.MemoryLevel): void { + // 根据系统可用内存的变化情况,释放不必要的内存 + } + onConfigurationUpdate(newConfig: Configuration): void { + hilog.info(DOMAIN_NUMBER, TAG, `onConfigurationUpdate, language: ${newConfig.language}`); + hilog.info(DOMAIN_NUMBER, TAG, `onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`); + + if (systemLanguage !== newConfig.language) { + hilog.info(DOMAIN_NUMBER, TAG, `systemLanguage from ${systemLanguage} changed to ${newConfig.language}`); + systemLanguage = newConfig.language; // 将变化之后的系统语言保存,作为下一次变化前的系统语言 + } + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_Context.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_Context.ets index 7b35f87160..898658313c 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_Context.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_Context.ets @@ -1,274 +1,274 @@ -/* - * Copyright (c) 2023 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 contextConstant from '@ohos.app.ability.contextConstant'; -import common from '@ohos.app.ability.common'; -import hilog from '@ohos.hilog'; -import promptAction from '@ohos.promptAction' -import Want from '@ohos.app.ability.Want'; -import { BusinessError } from '@ohos.base'; - -const TAG: string = '[Page_Context]'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct Page_Context { - - private context = getContext(this) as common.UIAbilityContext; - - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.Context01')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row(){ - Text($r('app.string.MethodOneForObtainingApplicationFilePath')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let applicationContext = this.context.getApplicationContext(); - let cacheDir = applicationContext.cacheDir; - let tempDir = applicationContext.tempDir; - let filesDir = applicationContext.filesDir; - let databaseDir = applicationContext.databaseDir; - let bundleCodeDir = applicationContext.bundleCodeDir; - let distributedFilesDir = applicationContext.distributedFilesDir; - let preferencesDir = applicationContext.preferencesDir; - // 获取应用文件路径 - let filePath = tempDir + 'test.txt'; - hilog.info(DOMAIN_NUMBER, TAG, `filePath: ${filePath}`); - if (filePath !== null) { - promptAction.showToast({ - message: filePath - }); - } - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.MethodOneTwoObtainingApplicationFilePath')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let cacheDir = this.context.cacheDir; - let tempDir = this.context.tempDir; - let filesDir = this.context.filesDir; - let databaseDir = this.context.databaseDir; - let bundleCodeDir = this.context.bundleCodeDir; - let distributedFilesDir = this.context.distributedFilesDir; - let preferencesDir = this.context.preferencesDir; - // 获取应用文件路径 - let filePath = tempDir + 'test.txt'; - hilog.info(DOMAIN_NUMBER, TAG, `filePath: ${filePath}`); - if (filePath !== null) { - promptAction.showToast({ - message: filePath - }); - } - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.SwitchToEL1')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - // 存储普通信息前,切换到EL1设备级加密 - if (this.context.area === contextConstant.AreaMode.EL2) { // 获取area - this.context.area = contextConstant.AreaMode.EL1; // 修改area - promptAction.showToast({ - message: $r('app.string.SwitchToEL1') - }); - } - // 存储普通信息 - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.SwitchToEL2')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - // 存储敏感信息前,切换到EL2用户级加密 - if (this.context.area === contextConstant.AreaMode.EL1) { // 获取area - this.context.area = contextConstant.AreaMode.EL2; // 修改area - promptAction.showToast({ - message: $r('app.string.SwitchToEL2') - }); - } - // 存储敏感信息 - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.Context04')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(304) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'ContextAbility', - }; - // context为调用方UIAbility的UIAbilityContext - context.startAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting ContextAbility.'); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ContextAbility. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.Context05')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(304) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'LifecycleAbility', - }; - // context为调用方UIAbility的UIAbilityContext - context.startAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting LifecycleAbility.'); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start LifecycleAbility. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 contextConstant from '@ohos.app.ability.contextConstant'; +import common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; +import promptAction from '@ohos.promptAction' +import Want from '@ohos.app.ability.Want'; +import { BusinessError } from '@ohos.base'; + +const TAG: string = '[Page_Context]'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct Page_Context { + + private context = getContext(this) as common.UIAbilityContext; + + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.Context01')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row(){ + Text($r('app.string.MethodOneForObtainingApplicationFilePath')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let applicationContext = this.context.getApplicationContext(); + let cacheDir = applicationContext.cacheDir; + let tempDir = applicationContext.tempDir; + let filesDir = applicationContext.filesDir; + let databaseDir = applicationContext.databaseDir; + let bundleCodeDir = applicationContext.bundleCodeDir; + let distributedFilesDir = applicationContext.distributedFilesDir; + let preferencesDir = applicationContext.preferencesDir; + // 获取应用文件路径 + let filePath = tempDir + 'test.txt'; + hilog.info(DOMAIN_NUMBER, TAG, `filePath: ${filePath}`); + if (filePath !== null) { + promptAction.showToast({ + message: filePath + }); + } + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.MethodOneTwoObtainingApplicationFilePath')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let cacheDir = this.context.cacheDir; + let tempDir = this.context.tempDir; + let filesDir = this.context.filesDir; + let databaseDir = this.context.databaseDir; + let bundleCodeDir = this.context.bundleCodeDir; + let distributedFilesDir = this.context.distributedFilesDir; + let preferencesDir = this.context.preferencesDir; + // 获取应用文件路径 + let filePath = tempDir + 'test.txt'; + hilog.info(DOMAIN_NUMBER, TAG, `filePath: ${filePath}`); + if (filePath !== null) { + promptAction.showToast({ + message: filePath + }); + } + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.SwitchToEL1')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + // 存储普通信息前,切换到EL1设备级加密 + if (this.context.area === contextConstant.AreaMode.EL2) { // 获取area + this.context.area = contextConstant.AreaMode.EL1; // 修改area + promptAction.showToast({ + message: $r('app.string.SwitchToEL1') + }); + } + // 存储普通信息 + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.SwitchToEL2')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + // 存储敏感信息前,切换到EL2用户级加密 + if (this.context.area === contextConstant.AreaMode.EL1) { // 获取area + this.context.area = contextConstant.AreaMode.EL2; // 修改area + promptAction.showToast({ + message: $r('app.string.SwitchToEL2') + }); + } + // 存储敏感信息 + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.Context04')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(304) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'ContextAbility', + }; + // context为调用方UIAbility的UIAbilityContext + context.startAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting ContextAbility.'); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ContextAbility. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.Context05')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(304) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'LifecycleAbility', + }; + // context为调用方UIAbility的UIAbilityContext + context.startAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting LifecycleAbility.'); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start LifecycleAbility. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_EventHub.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_EventHub.ets index 27617c5614..57ef928ae6 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_EventHub.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_EventHub.ets @@ -1,127 +1,127 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import promptAction from '@ohos.promptAction' -import Want from '@ohos.app.ability.Want'; - -@Entry -@Component -struct Page_EventHub { - - private context = getContext(this) as common.UIAbilityContext; - - eventHubFunc() : void { - // 不带参数触发自定义“event1”事件 - this.context.eventHub.emit('event1'); - // 带1个参数触发自定义“event1”事件 - this.context.eventHub.emit('event1', 1); - // 带2个参数触发自定义“event1”事件 - this.context.eventHub.emit('event1', 2, 'test'); - // 开发者可以根据实际的业务场景设计事件传递的参数 - } - - startAbilityTest() : void { - let want: Want = { - // Want参数信息 - }; - this.context.startAbility(want); - } - - // 页面展示 - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.DataSynchronization')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row(){ - Text($r('app.string.EventHubFuncA')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - this.eventHubFunc(); - promptAction.showToast({ - message: $r('app.string.EventHubFuncA') - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.EventHubFuncB')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - // context为UIAbility实例的AbilityContext - this.context.eventHub.off('event1'); - promptAction.showToast({ - message: $r('app.string.EventHubFuncB') - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import promptAction from '@ohos.promptAction' +import Want from '@ohos.app.ability.Want'; + +@Entry +@Component +struct Page_EventHub { + + private context = getContext(this) as common.UIAbilityContext; + + eventHubFunc() : void { + // 不带参数触发自定义“event1”事件 + this.context.eventHub.emit('event1'); + // 带1个参数触发自定义“event1”事件 + this.context.eventHub.emit('event1', 1); + // 带2个参数触发自定义“event1”事件 + this.context.eventHub.emit('event1', 2, 'test'); + // 开发者可以根据实际的业务场景设计事件传递的参数 + } + + startAbilityTest() : void { + let want: Want = { + // Want参数信息 + }; + this.context.startAbility(want); + } + + // 页面展示 + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.DataSynchronization')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row(){ + Text($r('app.string.EventHubFuncA')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + this.eventHubFunc(); + promptAction.showToast({ + message: $r('app.string.EventHubFuncA') + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.EventHubFuncB')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + // context为UIAbility实例的AbilityContext + this.context.eventHub.off('event1'); + promptAction.showToast({ + message: $r('app.string.EventHubFuncB') + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_ServiceExtensionAbility.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_ServiceExtensionAbility.ets index 29228d1554..94a433b750 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_ServiceExtensionAbility.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_ServiceExtensionAbility.ets @@ -1,295 +1,295 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import deviceManager from '@ohos.distributedDeviceManager'; -import hilog from '@ohos.hilog'; -import promptAction from '@ohos.promptAction'; -import rpc from '@ohos.rpc'; -import Want from '@ohos.app.ability.Want'; -// 客户端需要将服务端对外提供的idl_service_ext_proxy.ts导入到本地工程中 -import IdlServiceExtProxy from '../IdlServiceExt/idl_service_ext_proxy'; - -import { BusinessError } from '@ohos.base'; - -const TAG: string = '[Page_ServiceExtensionAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -let connectionId: number; -let dmClass: deviceManager.DeviceManager; - -let want: Want = { - deviceId: '', - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'ServiceExtAbility' -}; - -let options: common.ConnectOptions = { - onConnect(elementName, remote: rpc.IRemoteObject): void { - hilog.info(DOMAIN_NUMBER, TAG, 'onConnect callback'); - if (remote === null) { - hilog.info(DOMAIN_NUMBER, TAG, `onConnect remote is null`); - return; - } - let serviceExtProxy: IdlServiceExtProxy = new IdlServiceExtProxy(remote); - // 通过接口调用的方式进行通信,屏蔽了RPC通信的细节,简洁明了 - serviceExtProxy.processData(1, (errorCode: number, retVal: number) => { - hilog.info(DOMAIN_NUMBER, TAG, `processData, errorCode: ${errorCode}, retVal: ${retVal}`); - }); - serviceExtProxy.insertDataToMap('theKey', 1, (errorCode: number) => { - hilog.info(DOMAIN_NUMBER, TAG, `insertDataToMap, errorCode: ${errorCode}`); - }) - }, - onDisconnect(elementName): void { - hilog.info(DOMAIN_NUMBER, TAG, 'onDisconnect callback'); - }, - onFailed(code: number): void { - hilog.info(DOMAIN_NUMBER, TAG, 'onFailed callback', JSON.stringify(code)); - } -}; - -function getRemoteDeviceId(): string | undefined { - if (typeof dmClass === 'object' && dmClass !== null) { - let list = dmClass.getAvailableDeviceListSync(); - hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(dmClass), JSON.stringify(list)); - if (typeof (list) === 'undefined' || typeof (list.length) === 'undefined') { - hilog.info(DOMAIN_NUMBER, TAG, 'getRemoteDeviceId err: list is null'); - return; - } - if (list.length === 0) { - hilog.info(DOMAIN_NUMBER, TAG, `getRemoteDeviceId err: list is empty`); - return; - } - return list[0].networkId; - } else { - hilog.info(DOMAIN_NUMBER, TAG, 'getRemoteDeviceId err: dmClass is null'); - return; - } -} - -@Entry -@Component -struct Page_ServiceExtensionAbility { - private context = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.ServiceExtension')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12, bottom: 11, right: 24, left: 24 }) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row() { - Text($r('app.string.StartBackendService')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - deviceId: '', - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'ServiceExtAbility' - }; - context.startServiceExtensionAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting ServiceExtensionAbility.'); - // 成功启动后台服务 - promptAction.showToast({ - message: $r('app.string.SuccessfullyStartBackendService') - }); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ServiceExtensionAbility. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.StopStartedBackendService')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - deviceId: '', - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'ServiceExtAbility' - }; - context.stopServiceExtensionAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in stopping ServiceExtensionAbility.'); - promptAction.showToast({ - message: $r('app.string.SuccessfullyStoppedAStartedBackendService') - }); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to stop ServiceExtensionAbility. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.StopBackendServices')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - context.terminateSelf().then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in terminating self.'); - // 成功停止当前后台服务 - promptAction.showToast({ - message: $r('app.string.SuccessfullyStopStartedBackendService') - }); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to terminate self. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.ConnectBackendService')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - // 建立连接后返回的Id需要保存下来,在解绑服务时需要作为参数传入 - connectionId = context.connectServiceExtensionAbility(want, options); - // 成功连接后台服务 - promptAction.showToast({ - message: $r('app.string.SuccessfullyConnectBackendService') - }); - // connectionId = context.connectAbility(want, options); - hilog.info(DOMAIN_NUMBER, TAG, `connectionId is : ${connectionId}`); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.DisconnectBackendService')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - // connectionId为调用connectServiceExtensionAbility接口时的返回值,需开发者自行维护 - context.disconnectServiceExtensionAbility(connectionId).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'disconnectServiceExtensionAbility success'); - // 成功断连后台服务 - promptAction.showToast({ - message: $r('app.string.SuccessfullyDisconnectBackendService') - }); - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, 'disconnectServiceExtensionAbility failed'); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import deviceManager from '@ohos.distributedDeviceManager'; +import hilog from '@ohos.hilog'; +import promptAction from '@ohos.promptAction'; +import rpc from '@ohos.rpc'; +import Want from '@ohos.app.ability.Want'; +// 客户端需要将服务端对外提供的idl_service_ext_proxy.ts导入到本地工程中 +import IdlServiceExtProxy from '../IdlServiceExt/idl_service_ext_proxy'; + +import { BusinessError } from '@ohos.base'; + +const TAG: string = '[Page_ServiceExtensionAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +let connectionId: number; +let dmClass: deviceManager.DeviceManager; + +let want: Want = { + deviceId: '', + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'ServiceExtAbility' +}; + +let options: common.ConnectOptions = { + onConnect(elementName, remote: rpc.IRemoteObject): void { + hilog.info(DOMAIN_NUMBER, TAG, 'onConnect callback'); + if (remote === null) { + hilog.info(DOMAIN_NUMBER, TAG, `onConnect remote is null`); + return; + } + let serviceExtProxy: IdlServiceExtProxy = new IdlServiceExtProxy(remote); + // 通过接口调用的方式进行通信,屏蔽了RPC通信的细节,简洁明了 + serviceExtProxy.processData(1, (errorCode: number, retVal: number) => { + hilog.info(DOMAIN_NUMBER, TAG, `processData, errorCode: ${errorCode}, retVal: ${retVal}`); + }); + serviceExtProxy.insertDataToMap('theKey', 1, (errorCode: number) => { + hilog.info(DOMAIN_NUMBER, TAG, `insertDataToMap, errorCode: ${errorCode}`); + }) + }, + onDisconnect(elementName): void { + hilog.info(DOMAIN_NUMBER, TAG, 'onDisconnect callback'); + }, + onFailed(code: number): void { + hilog.info(DOMAIN_NUMBER, TAG, 'onFailed callback', JSON.stringify(code)); + } +}; + +function getRemoteDeviceId(): string | undefined { + if (typeof dmClass === 'object' && dmClass !== null) { + let list = dmClass.getAvailableDeviceListSync(); + hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(dmClass), JSON.stringify(list)); + if (typeof (list) === 'undefined' || typeof (list.length) === 'undefined') { + hilog.info(DOMAIN_NUMBER, TAG, 'getRemoteDeviceId err: list is null'); + return; + } + if (list.length === 0) { + hilog.info(DOMAIN_NUMBER, TAG, `getRemoteDeviceId err: list is empty`); + return; + } + return list[0].networkId; + } else { + hilog.info(DOMAIN_NUMBER, TAG, 'getRemoteDeviceId err: dmClass is null'); + return; + } +} + +@Entry +@Component +struct Page_ServiceExtensionAbility { + private context = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.ServiceExtension')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12, bottom: 11, right: 24, left: 24 }) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row() { + Text($r('app.string.StartBackendService')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + deviceId: '', + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'ServiceExtAbility' + }; + context.startServiceExtensionAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting ServiceExtensionAbility.'); + // 成功启动后台服务 + promptAction.showToast({ + message: $r('app.string.SuccessfullyStartBackendService') + }); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ServiceExtensionAbility. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.StopStartedBackendService')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + deviceId: '', + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'ServiceExtAbility' + }; + context.stopServiceExtensionAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in stopping ServiceExtensionAbility.'); + promptAction.showToast({ + message: $r('app.string.SuccessfullyStoppedAStartedBackendService') + }); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to stop ServiceExtensionAbility. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.StopBackendServices')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + context.terminateSelf().then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in terminating self.'); + // 成功停止当前后台服务 + promptAction.showToast({ + message: $r('app.string.SuccessfullyStopStartedBackendService') + }); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to terminate self. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.ConnectBackendService')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + // 建立连接后返回的Id需要保存下来,在解绑服务时需要作为参数传入 + connectionId = context.connectServiceExtensionAbility(want, options); + // 成功连接后台服务 + promptAction.showToast({ + message: $r('app.string.SuccessfullyConnectBackendService') + }); + // connectionId = context.connectAbility(want, options); + hilog.info(DOMAIN_NUMBER, TAG, `connectionId is : ${connectionId}`); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.DisconnectBackendService')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + // connectionId为调用connectServiceExtensionAbility接口时的返回值,需开发者自行维护 + context.disconnectServiceExtensionAbility(connectionId).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'disconnectServiceExtensionAbility success'); + // 成功断连后台服务 + promptAction.showToast({ + message: $r('app.string.SuccessfullyDisconnectBackendService') + }); + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, 'disconnectServiceExtensionAbility failed'); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_StartFAModel.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_StartFAModel.ets index 7060240199..b36a7138e6 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_StartFAModel.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_StartFAModel.ets @@ -1,208 +1,208 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import hilog from '@ohos.hilog'; -import promptAction from '@ohos.promptAction' -import Want from '@ohos.app.ability.Want'; - -import { BusinessError } from '@ohos.base'; - -const TAG: string = '[Page_StartFAModel]'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct Page_StartFAModel { - private context = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.StageModelinteractiveWithFAModel')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row(){ - Text($r('app.string.StartFAModel')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let want: Want = { - bundleName: 'com.samples.famodelabilitydevelop', - abilityName: 'com.samples.famodelabilitydevelop.MainAbility' - }; - this.context.startAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Start Ability successfully.'); - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Ability failed: ` + JSON.stringify(error)); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.StartFAModelWithResult')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let want: Want = { - bundleName: 'com.samples.famodelabilitydevelop', - abilityName: 'com.samples.famodelabilitydevelop.MainAbility', - }; - this.context.startAbilityForResult(want).then((result) => { - hilog.info(DOMAIN_NUMBER, TAG, 'Ability verify result: ' + JSON.stringify(result)); - if (result !== null) { - promptAction.showToast({ - message : JSON.stringify(result) - }); - } - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Ability failed: ` + JSON.stringify(error)); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.ServiceAbility')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(304) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - let want: Want = { - bundleName: 'com.samples.famodelabilitydevelop', - abilityName: 'com.samples.famodelabilitydevelop.ServiceAbility', - } - let options: common.ConnectOptions = { - onConnect: (elementName, proxy) => { - hilog.info(DOMAIN_NUMBER, TAG, 'onConnect called.'); - promptAction.showToast({ - message: $r('app.string.ConnectFAServiceAbility') - }); - }, - onDisconnect: (elementName) => { - hilog.info(DOMAIN_NUMBER, TAG, 'onDisconnect called.'); - }, - onFailed: (code) => { - hilog.info(DOMAIN_NUMBER, TAG, 'onFailed code is: ' + code); - } - }; - let connectionId = this.context.connectServiceExtensionAbility(want, options); - hilog.info(DOMAIN_NUMBER, TAG, 'connectionId is ' + JSON.stringify(connectionId)); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.PageAbility')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(304) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - let want: Want = { - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'ServiceExtAbility', - parameters:{ - key: 'ConnectFaPageAbility' - } - } - this.context.startServiceExtensionAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'startServiceExtensionAbility successfully'); - }).catch((err: BusinessError) =>{ - hilog.info(DOMAIN_NUMBER, TAG, 'startServiceExtensionAbility fail, err is: ' + JSON.stringify(err)); - }) - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; +import promptAction from '@ohos.promptAction' +import Want from '@ohos.app.ability.Want'; + +import { BusinessError } from '@ohos.base'; + +const TAG: string = '[Page_StartFAModel]'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct Page_StartFAModel { + private context = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.StageModelinteractiveWithFAModel')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row(){ + Text($r('app.string.StartFAModel')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let want: Want = { + bundleName: 'com.samples.famodelabilitydevelop', + abilityName: 'com.samples.famodelabilitydevelop.MainAbility' + }; + this.context.startAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Start Ability successfully.'); + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Ability failed: ` + JSON.stringify(error)); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.StartFAModelWithResult')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let want: Want = { + bundleName: 'com.samples.famodelabilitydevelop', + abilityName: 'com.samples.famodelabilitydevelop.MainAbility', + }; + this.context.startAbilityForResult(want).then((result) => { + hilog.info(DOMAIN_NUMBER, TAG, 'Ability verify result: ' + JSON.stringify(result)); + if (result !== null) { + promptAction.showToast({ + message : JSON.stringify(result) + }); + } + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Ability failed: ` + JSON.stringify(error)); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.ServiceAbility')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(304) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + let want: Want = { + bundleName: 'com.samples.famodelabilitydevelop', + abilityName: 'com.samples.famodelabilitydevelop.ServiceAbility', + } + let options: common.ConnectOptions = { + onConnect: (elementName, proxy) => { + hilog.info(DOMAIN_NUMBER, TAG, 'onConnect called.'); + promptAction.showToast({ + message: $r('app.string.ConnectFAServiceAbility') + }); + }, + onDisconnect: (elementName) => { + hilog.info(DOMAIN_NUMBER, TAG, 'onDisconnect called.'); + }, + onFailed: (code) => { + hilog.info(DOMAIN_NUMBER, TAG, 'onFailed code is: ' + code); + } + }; + let connectionId = this.context.connectServiceExtensionAbility(want, options); + hilog.info(DOMAIN_NUMBER, TAG, 'connectionId is ' + JSON.stringify(connectionId)); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.PageAbility')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(304) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + let want: Want = { + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'ServiceExtAbility', + parameters:{ + key: 'ConnectFaPageAbility' + } + } + this.context.startServiceExtensionAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'startServiceExtensionAbility successfully'); + }).catch((err: BusinessError) =>{ + hilog.info(DOMAIN_NUMBER, TAG, 'startServiceExtensionAbility fail, err is: ' + JSON.stringify(err)); + }) + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_StartModel.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_StartModel.ets index 8eb88c1618..e31eb76639 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_StartModel.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_StartModel.ets @@ -1,213 +1,213 @@ -/* - * Copyright (c) 2023 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. - */ - -// 在启动指定实例模式的UIAbility时,给每一个UIAbility实例配置一个独立的Key标识 -// 例如在文档使用场景中,可以用文档路径作为Key标识 -import common from '@ohos.app.ability.common'; -import hilog from '@ohos.hilog'; -import Want from '@ohos.app.ability.Want'; -import { BusinessError } from '@ohos.base'; - -const TAG: string = '[Page_StartModel]'; -const DOMAIN_NUMBER: number = 0xFF00; - -function getInstance() : string { - return 'KEY'; -} - -@Entry -@Component -struct Page_StartModel { - private KEY_NEW = 'KEY'; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIAbilityComponentsStartModel')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row(){ - Text($r('app.string.singleton')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'SingletonAbility', - moduleName: 'entry', // moduleName非必选 - }; - context.startAbility(want).then(() => { - }).catch((err: BusinessError) => { - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.multiton')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'MultitonAbility', - moduleName: 'entry', // moduleName非必选 - }; - context.startAbility(want).then(() => { - }).catch((err: BusinessError) => { - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.SpecifiedA')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - // context为调用方UIAbility的UIAbilityContext; - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'SpecifiedFirstAbility', - moduleName: 'entry', // moduleName非必选 - parameters: { // 自定义信息 - instanceKey: this.KEY_NEW - } - }; - context.startAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting SpecifiedAbility.'); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start SpecifiedAbility. Code is ${err.code}, message is ${err.message}`); - }); - this.KEY_NEW = this.KEY_NEW + 'a'; - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.SpecifiedB')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - // context为调用方UIAbility的UIAbilityContext; - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'SpecifiedSecondAbility', - moduleName: 'entry', // moduleName非必选 - parameters: { // 自定义信息 - instanceKey: getInstance() - } - }; - context.startAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting SpecifiedAbility.'); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start SpecifiedAbility. Code is ${err.code}, message is ${err.message}`); - }); - this.KEY_NEW = this.KEY_NEW + 'a'; - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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. + */ + +// 在启动指定实例模式的UIAbility时,给每一个UIAbility实例配置一个独立的Key标识 +// 例如在文档使用场景中,可以用文档路径作为Key标识 +import common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; +import Want from '@ohos.app.ability.Want'; +import { BusinessError } from '@ohos.base'; + +const TAG: string = '[Page_StartModel]'; +const DOMAIN_NUMBER: number = 0xFF00; + +function getInstance() : string { + return 'KEY'; +} + +@Entry +@Component +struct Page_StartModel { + private KEY_NEW = 'KEY'; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIAbilityComponentsStartModel')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row(){ + Text($r('app.string.singleton')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'SingletonAbility', + moduleName: 'entry', // moduleName非必选 + }; + context.startAbility(want).then(() => { + }).catch((err: BusinessError) => { + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.multiton')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'MultitonAbility', + moduleName: 'entry', // moduleName非必选 + }; + context.startAbility(want).then(() => { + }).catch((err: BusinessError) => { + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.SpecifiedA')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + // context为调用方UIAbility的UIAbilityContext; + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'SpecifiedFirstAbility', + moduleName: 'entry', // moduleName非必选 + parameters: { // 自定义信息 + instanceKey: this.KEY_NEW + } + }; + context.startAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting SpecifiedAbility.'); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start SpecifiedAbility. Code is ${err.code}, message is ${err.message}`); + }); + this.KEY_NEW = this.KEY_NEW + 'a'; + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.SpecifiedB')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + // context为调用方UIAbility的UIAbilityContext; + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'SpecifiedSecondAbility', + moduleName: 'entry', // moduleName非必选 + parameters: { // 自定义信息 + instanceKey: getInstance() + } + }; + context.startAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting SpecifiedAbility.'); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start SpecifiedAbility. Code is ${err.code}, message is ${err.message}`); + }); + this.KEY_NEW = this.KEY_NEW + 'a'; + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_UIAbilityComponentsBasicUsage.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_UIAbilityComponentsBasicUsage.ets index 649b07f8c2..457f91f088 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_UIAbilityComponentsBasicUsage.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_UIAbilityComponentsBasicUsage.ets @@ -1,89 +1,89 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import EnvironmentCallback from '@ohos.app.ability.EnvironmentCallback'; -import hilog from '@ohos.hilog'; -import Want from '@ohos.app.ability.Want'; -import { Configuration } from '@ohos.app.ability.Configuration'; - -const TAG: string = '[Page_UIAbilityComponentsBasicUsage]'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct Page_UIAbilityComponentsBasicUsage { - private context = getContext(this) as common.UIAbilityContext; - private callbackId: number = 0; // 注册订阅系统环境变化的ID - - startAbilityTest(): void { - let context = getContext(this) as common.UIAbilityContext; - let want: Want = { - // Want参数信息 - }; - context.startAbility(want); - } - - subscribeConfigurationUpdate(): void { - let systemLanguage: string | undefined = this.context.config.language; // 获取系统当前语言 - // 1.获取ApplicationContext - let applicationContext = this.context.getApplicationContext(); - // 2.通过applicationContext订阅环境变量变化 - let environmentCallback: EnvironmentCallback = { - onConfigurationUpdated(newConfig: Configuration): void { - hilog.info(DOMAIN_NUMBER, TAG, `onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`); - if (this.systemLanguage !== newConfig.language) { - hilog.info(DOMAIN_NUMBER, TAG, `systemLanguage from ${systemLanguage} changed to ${newConfig.language}`); - systemLanguage = newConfig.language; // 将变化之后的系统语言保存,作为下一次变化前的系统语言 - } - }, - onMemoryLevel(level): void { - hilog.info(DOMAIN_NUMBER, TAG, `onMemoryLevel level: ${level}`); - } - } - this.callbackId = applicationContext.on('environment', environmentCallback); - } - - // 页面展示 - build() { - Column() { - Row() { - Text($r('app.string.UIAbilityComponentsBasicUsage')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12, bottom: 11, right: 24, left: 24 }) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224 }) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8, bottom: 317, right: 152, left: 152 }) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - .fontWeight(400) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import EnvironmentCallback from '@ohos.app.ability.EnvironmentCallback'; +import hilog from '@ohos.hilog'; +import Want from '@ohos.app.ability.Want'; +import { Configuration } from '@ohos.app.ability.Configuration'; + +const TAG: string = '[Page_UIAbilityComponentsBasicUsage]'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct Page_UIAbilityComponentsBasicUsage { + private context = getContext(this) as common.UIAbilityContext; + private callbackId: number = 0; // 注册订阅系统环境变化的ID + + startAbilityTest(): void { + let context = getContext(this) as common.UIAbilityContext; + let want: Want = { + // Want参数信息 + }; + context.startAbility(want); + } + + subscribeConfigurationUpdate(): void { + let systemLanguage: string | undefined = this.context.config.language; // 获取系统当前语言 + // 1.获取ApplicationContext + let applicationContext = this.context.getApplicationContext(); + // 2.通过applicationContext订阅环境变量变化 + let environmentCallback: EnvironmentCallback = { + onConfigurationUpdated(newConfig: Configuration): void { + hilog.info(DOMAIN_NUMBER, TAG, `onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`); + if (this.systemLanguage !== newConfig.language) { + hilog.info(DOMAIN_NUMBER, TAG, `systemLanguage from ${systemLanguage} changed to ${newConfig.language}`); + systemLanguage = newConfig.language; // 将变化之后的系统语言保存,作为下一次变化前的系统语言 + } + }, + onMemoryLevel(level): void { + hilog.info(DOMAIN_NUMBER, TAG, `onMemoryLevel level: ${level}`); + } + } + this.callbackId = applicationContext.on('environment', environmentCallback); + } + + // 页面展示 + build() { + Column() { + Row() { + Text($r('app.string.UIAbilityComponentsBasicUsage')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12, bottom: 11, right: 24, left: 24 }) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224 }) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8, bottom: 317, right: 152, left: 152 }) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + .fontWeight(400) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_UIAbilityComponentsInteractive.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_UIAbilityComponentsInteractive.ets index 496b3131e5..58d6e718f4 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_UIAbilityComponentsInteractive.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_UIAbilityComponentsInteractive.ets @@ -1,516 +1,516 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import common from '@ohos.app.ability.common'; -import hilog from '@ohos.hilog'; -import promptAction from '@ohos.promptAction' -import Want from '@ohos.app.ability.Want'; -import StartOptions from '@ohos.app.ability.StartOptions'; -import { BusinessError } from '@ohos.base'; -import { Caller } from '@ohos.app.ability.UIAbility'; - -const TAG: string = '[Page_UIAbilityComponentsInteractive]'; -const DOMAIN_NUMBER: number = 0xFF00; - - -@Entry -@Component -struct Page_UIAbilityComponentsInteractive { - private context = getContext(this) as common.UIAbilityContext; - private callbackId: number = 0; // 注册订阅系统环境变化的ID - - unsubscribeConfigurationUpdate() { - let applicationContext = this.context.getApplicationContext(); - applicationContext.off('environment', this.callbackId); - } - - caller: Caller | undefined = undefined; - // 注册caller的release监听 - private regOnRelease(caller: Caller): void { - hilog.info(DOMAIN_NUMBER, TAG, `caller is ${caller}`); - try { - caller.on('release', (msg: string) => { - hilog.info(DOMAIN_NUMBER, TAG, `caller onRelease is called ${msg}`); - }) - hilog.info(DOMAIN_NUMBER, TAG, 'succeeded in registering on release.'); - } catch (err) { - let code = (err as BusinessError).code; - let message = (err as BusinessError).message; - hilog.error(DOMAIN_NUMBER, TAG, `Failed to caller register on release. Code is ${code}, message is ${message}`); - }; - }; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIAbilityComponentsInteractive')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row(){ - Text($r('app.string.UIAbilityComponentsInteractionA')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - // context为Ability对象的成员,在非Ability对象内部调用需要 - // 将Context对象传递过去 - let wantInfo: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.stagemodelabilitydevelop', - moduleName: 'entry', // moduleName非必选 - abilityName: 'FuncAbilityA', - parameters: { // 自定义信息 - info: '来自EntryAbility Page_UIAbilityComponentsInteractive页面' - }, - }; - // context为调用方UIAbility的UIAbilityContext - this.context.startAbility(wantInfo).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'startAbility success.'); - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, 'startAbility failed.'); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.UIAbilityComponentsInteractionB')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(304) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - const RESULT_CODE: number = 1001; - - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.stagemodelabilitydevelop', - moduleName: 'entry', // moduleName非必选 - abilityName: 'FuncAbilityA', - parameters: { // 自定义信息 - info: '来自EntryAbility UIAbilityComponentsInteractive页面' - } - }; - context.startAbilityForResult(want).then((data) => { - if (data?.resultCode === RESULT_CODE) { - // 解析被调用方UIAbility返回的信息 - let info = data.want?.parameters?.info; - hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(info) ?? ''); - if (info !== null) { - promptAction.showToast({ - message : JSON.stringify(info) - }); - } - } - hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(data.resultCode) ?? ''); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability for result. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.UIAbilityComponentsInteractionC')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - // uncomment line below if wish to implicitly query only in the specific bundle. - // bundleName: 'com.samples.stagemodelabilityinteraction', - action: 'ohos.want.action.viewData', - // entities can be omitted. - entities: ['entity.system.default'] - }; - // context为调用方UIAbility的UIAbilityContext - context.startAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting FuncAbility.'); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start FuncAbility. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.UIAbilityComponentsInteractionE')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.stagemodelabilitydevelop', - moduleName: 'entry', // moduleName非必选 - abilityName: 'FuncAbilityB', - parameters: { // 自定义信息 - info: '来自EntryAbility Index页面' - } - }; - let options: StartOptions = { - windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FLOATING - }; - // context为调用方UIAbility的UIAbilityContext - context.startAbility(want, options).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting ability.'); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.UIAbilityComponentsInteractionF')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.stagemodelabilityinteraction', - moduleName: 'entry', // moduleName非必选 - abilityName: 'FuncAbility', - parameters: { // 自定义参数传递页面信息 - router: 'FuncA' - } - }; - // context为调用方UIAbility的UIAbilityContext - context.startAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting ability.'); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.UIAbilityComponentsInteractionG')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context = getContext(this) as common.UIAbilityContext; - let wantInfo: Want = { - // uncomment line below if wish to implicitly query only in the specific bundle. - // bundleName: 'com.samples.stagemodelabilityinteraction', - action: 'ohos.want.action.viewData', - // entities can be omitted. - entities: ['entity.system.browsable'], - uri: 'https://www.test.com:8080/query/student' - }; - context.startAbility(wantInfo).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting TUri.'); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start Uri. Code is ${err.code}, message is ${err.message}`); - }) - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.UIAbilityComponentsInteractionH')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context = getContext(this) as common.UIAbilityContext; - let wantInfo: Want = { - // uncomment line below if wish to implicitly query only in the specific bundle. - // bundleName: 'com.samples.stagemodelabilityinteraction', - action: 'ohos.want.action.search', - // entities can be omitted. - entities: ['entity.system.browsable'], - uri: 'https://www.test.com:8080/query/student', - type: 'application/http' - }; - context.startAbility(wantInfo).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting tjyUri.'); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start Uri. Code is ${err.code}, message is ${err.message}`); - }) - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.UIAbilityComponentsInteractionOnCreate')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.stagemodelabilityinteraction', - moduleName: 'entry', // moduleName非必选 - abilityName: 'EntryAbility', - parameters: { // 自定义参数传递页面信息 - router: 'funcA' - } - }; - // context为调用方UIAbility的UIAbilityContext - context.startAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting ability.'); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.UIAbilityComponentsInteractionOnNewWant')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.stagemodelabilityinteraction', - moduleName: 'entry', // moduleName非必选 - abilityName: 'EntryAbility', - parameters: { // 自定义参数传递页面信息 - router: 'funcB' - } - }; - // context为调用方UIAbility的UIAbilityContext - context.startAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in starting ability.`); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - - ListItem() { - Row() { - Row(){ - Text($r('app.string.Caller')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - bundleName: 'com.samples.stagemodelabilityinteraction', - abilityName: 'CalleeAbility', - parameters: { // 自定义信息 - info: 'CallSendMsg' - } - }; - - context.startAbilityByCall(want).then((caller: Caller) => { - hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in starting ability.Code is ${caller}`); - if (caller === undefined) { - hilog.info(DOMAIN_NUMBER, TAG, 'get caller failed'); - return; - } - else { - hilog.info(DOMAIN_NUMBER, TAG, 'get caller success'); - this.regOnRelease(caller); - promptAction.showToast({ - message: $r('app.string.CallerSuccess') - }); - try { - caller.release(); - } catch (releaseErr) { - console.log('Caller.release catch error, error.code: ' + JSON.stringify(releaseErr.code) + - ' error.message: ' + JSON.stringify(releaseErr.message)); - } - } - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability. Code is ${err.code}, message is ${err.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; +import promptAction from '@ohos.promptAction' +import Want from '@ohos.app.ability.Want'; +import StartOptions from '@ohos.app.ability.StartOptions'; +import { BusinessError } from '@ohos.base'; +import { Caller } from '@ohos.app.ability.UIAbility'; + +const TAG: string = '[Page_UIAbilityComponentsInteractive]'; +const DOMAIN_NUMBER: number = 0xFF00; + + +@Entry +@Component +struct Page_UIAbilityComponentsInteractive { + private context = getContext(this) as common.UIAbilityContext; + private callbackId: number = 0; // 注册订阅系统环境变化的ID + + unsubscribeConfigurationUpdate() { + let applicationContext = this.context.getApplicationContext(); + applicationContext.off('environment', this.callbackId); + } + + caller: Caller | undefined = undefined; + // 注册caller的release监听 + private regOnRelease(caller: Caller): void { + hilog.info(DOMAIN_NUMBER, TAG, `caller is ${caller}`); + try { + caller.on('release', (msg: string) => { + hilog.info(DOMAIN_NUMBER, TAG, `caller onRelease is called ${msg}`); + }) + hilog.info(DOMAIN_NUMBER, TAG, 'succeeded in registering on release.'); + } catch (err) { + let code = (err as BusinessError).code; + let message = (err as BusinessError).message; + hilog.error(DOMAIN_NUMBER, TAG, `Failed to caller register on release. Code is ${code}, message is ${message}`); + }; + }; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIAbilityComponentsInteractive')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row(){ + Text($r('app.string.UIAbilityComponentsInteractionA')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + // context为Ability对象的成员,在非Ability对象内部调用需要 + // 将Context对象传递过去 + let wantInfo: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.stagemodelabilitydevelop', + moduleName: 'entry', // moduleName非必选 + abilityName: 'FuncAbilityA', + parameters: { // 自定义信息 + info: '来自EntryAbility Page_UIAbilityComponentsInteractive页面' + }, + }; + // context为调用方UIAbility的UIAbilityContext + this.context.startAbility(wantInfo).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'startAbility success.'); + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, 'startAbility failed.'); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.UIAbilityComponentsInteractionB')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(304) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + const RESULT_CODE: number = 1001; + + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.stagemodelabilitydevelop', + moduleName: 'entry', // moduleName非必选 + abilityName: 'FuncAbilityA', + parameters: { // 自定义信息 + info: '来自EntryAbility UIAbilityComponentsInteractive页面' + } + }; + context.startAbilityForResult(want).then((data) => { + if (data?.resultCode === RESULT_CODE) { + // 解析被调用方UIAbility返回的信息 + let info = data.want?.parameters?.info; + hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(info) ?? ''); + if (info !== null) { + promptAction.showToast({ + message : JSON.stringify(info) + }); + } + } + hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(data.resultCode) ?? ''); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability for result. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.UIAbilityComponentsInteractionC')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + // uncomment line below if wish to implicitly query only in the specific bundle. + // bundleName: 'com.samples.stagemodelabilityinteraction', + action: 'ohos.want.action.viewData', + // entities can be omitted. + entities: ['entity.system.default'] + }; + // context为调用方UIAbility的UIAbilityContext + context.startAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting FuncAbility.'); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start FuncAbility. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.UIAbilityComponentsInteractionE')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.stagemodelabilitydevelop', + moduleName: 'entry', // moduleName非必选 + abilityName: 'FuncAbilityB', + parameters: { // 自定义信息 + info: '来自EntryAbility Index页面' + } + }; + let options: StartOptions = { + windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FLOATING + }; + // context为调用方UIAbility的UIAbilityContext + context.startAbility(want, options).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting ability.'); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.UIAbilityComponentsInteractionF')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.stagemodelabilityinteraction', + moduleName: 'entry', // moduleName非必选 + abilityName: 'FuncAbility', + parameters: { // 自定义参数传递页面信息 + router: 'FuncA' + } + }; + // context为调用方UIAbility的UIAbilityContext + context.startAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting ability.'); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.UIAbilityComponentsInteractionG')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context = getContext(this) as common.UIAbilityContext; + let wantInfo: Want = { + // uncomment line below if wish to implicitly query only in the specific bundle. + // bundleName: 'com.samples.stagemodelabilityinteraction', + action: 'ohos.want.action.viewData', + // entities can be omitted. + entities: ['entity.system.browsable'], + uri: 'https://www.test.com:8080/query/student' + }; + context.startAbility(wantInfo).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting TUri.'); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start Uri. Code is ${err.code}, message is ${err.message}`); + }) + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.UIAbilityComponentsInteractionH')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context = getContext(this) as common.UIAbilityContext; + let wantInfo: Want = { + // uncomment line below if wish to implicitly query only in the specific bundle. + // bundleName: 'com.samples.stagemodelabilityinteraction', + action: 'ohos.want.action.search', + // entities can be omitted. + entities: ['entity.system.browsable'], + uri: 'https://www.test.com:8080/query/student', + type: 'application/http' + }; + context.startAbility(wantInfo).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting tjyUri.'); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start Uri. Code is ${err.code}, message is ${err.message}`); + }) + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.UIAbilityComponentsInteractionOnCreate')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.stagemodelabilityinteraction', + moduleName: 'entry', // moduleName非必选 + abilityName: 'EntryAbility', + parameters: { // 自定义参数传递页面信息 + router: 'funcA' + } + }; + // context为调用方UIAbility的UIAbilityContext + context.startAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in starting ability.'); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.UIAbilityComponentsInteractionOnNewWant')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.stagemodelabilityinteraction', + moduleName: 'entry', // moduleName非必选 + abilityName: 'EntryAbility', + parameters: { // 自定义参数传递页面信息 + router: 'funcB' + } + }; + // context为调用方UIAbility的UIAbilityContext + context.startAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in starting ability.`); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + + ListItem() { + Row() { + Row(){ + Text($r('app.string.Caller')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + bundleName: 'com.samples.stagemodelabilityinteraction', + abilityName: 'CalleeAbility', + parameters: { // 自定义信息 + info: 'CallSendMsg' + } + }; + + context.startAbilityByCall(want).then((caller: Caller) => { + hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in starting ability.Code is ${caller}`); + if (caller === undefined) { + hilog.info(DOMAIN_NUMBER, TAG, 'get caller failed'); + return; + } + else { + hilog.info(DOMAIN_NUMBER, TAG, 'get caller success'); + this.regOnRelease(caller); + promptAction.showToast({ + message: $r('app.string.CallerSuccess') + }); + try { + caller.release(); + } catch (releaseErr) { + console.log('Caller.release catch error, error.code: ' + JSON.stringify(releaseErr.code) + + ' error.message: ' + JSON.stringify(releaseErr.message)); + } + } + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to start ability. Code is ${err.code}, message is ${err.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_collaborateability/Page_CollaborateAbility.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_collaborateability/Page_CollaborateAbility.ets index 50767a94c3..b72a0c8832 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_collaborateability/Page_CollaborateAbility.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_collaborateability/Page_CollaborateAbility.ets @@ -1,446 +1,446 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import deviceManager from '@ohos.distributedDeviceManager'; -import hilog from '@ohos.hilog'; -import promptAction from '@ohos.promptAction'; -import rpc from '@ohos.rpc'; -import Want from '@ohos.app.ability.Want'; -import { BusinessError } from '@ohos.base'; -import { Caller } from '@ohos.app.ability.UIAbility'; - -const TAG: string = '[Page_CollaborateAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; -const REQUEST_CODE = 1; - -let dmClass: deviceManager.DeviceManager; - -let connectionId: number; -let options: common.ConnectOptions = { - onConnect(elementName, remote): void { - hilog.info(DOMAIN_NUMBER, TAG, 'onConnect callback'); - if (remote === null) { - hilog.info(DOMAIN_NUMBER, TAG, `onConnect remote is null`); - return; - } - let option = new rpc.MessageOption(); - let data = new rpc.MessageSequence(); - let reply = new rpc.MessageSequence(); - data.writeInt(99); - // 开发者可发送data到目标端应用进行相应操作 - // @param code 表示客户端发送的服务请求代码。 - // @param data 表示客户端发送的{@link MessageSequence}对象。 - // @param reply 表示远程服务发送的响应消息对象。 - // @param options 指示操作是同步的还是异步的。 - // @return 如果操作成功返回{@code true}; 否则返回 {@code false}。 - remote.sendMessageRequest(REQUEST_CODE, data, reply, option).then((ret: rpc.RequestResult) => { - let errCode = reply.readInt(); // 在成功连接的情况下,会收到来自目标端返回的信息(100) - let msg: number = 0; - if (errCode === 0) { - msg = reply.readInt(); - } - hilog.info(DOMAIN_NUMBER, TAG, `sendRequest msg:${msg}`); - // 成功连接后台服务 - promptAction.showToast({ - message: `sendRequest msg:${msg}` - }); - }).catch((error: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, `sendRequest failed, ${JSON.stringify(error)}`); - }); - }, - onDisconnect(elementName): void { - hilog.info(DOMAIN_NUMBER, TAG, 'onDisconnect callback'); - }, - onFailed(code): void { - hilog.info(DOMAIN_NUMBER, TAG, 'onFailed callback'); - } -}; - -function initDmClass(): void { - // 其中createDeviceManager接口为系统API - try { - dmClass = deviceManager.createDeviceManager('com.samples.stagemodelabilitydevelop'); - hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(dmClass) ?? ''); - promptAction.showToast({ - message: $r('app.string.InitializedSuccessfully') - }); - } catch (err) { - hilog.error(DOMAIN_NUMBER, TAG, 'createDeviceManager err: ' + JSON.stringify(err)); - }; -}; - -function getRemoteDeviceId(): string | undefined { - if (typeof dmClass === 'object' && dmClass !== null) { - let list = dmClass.getAvailableDeviceListSync(); - hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(dmClass), JSON.stringify(list)); - if (typeof (list) === 'undefined' || typeof (list.length) === 'undefined') { - hilog.info(DOMAIN_NUMBER, TAG, 'getRemoteDeviceId err: list is null'); - return; - } - if (list.length === 0) { - hilog.info(DOMAIN_NUMBER, TAG, `getRemoteDeviceId err: list is empty`); - return; - } - return list[0].networkId; - } else { - hilog.info(DOMAIN_NUMBER, TAG, 'getRemoteDeviceId err: dmClass is null'); - return; - } -}; - -@Entry -@Component -struct Page_CollaborateAbility { - private context = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.MultiDeviceCollaboration')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row(){ - Text($r('app.string.CollaborativeInitialization')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - initDmClass() - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.MultiDeviceCollaborationWithoutReturningData')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let want: Want = { - deviceId: getRemoteDeviceId(), - bundleName: 'com.samples.stagemodelabilityinteraction', - abilityName: 'CollaborateAbility' - }; - this.context.startAbility(want).then(() => { - promptAction.showToast({ - message: $r('app.string.SuccessfulCollaboration') - }); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `startAbility err: ` + JSON.stringify(err)); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.MultiDeviceCollaborationWithReturningData')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let want: Want = { - deviceId: getRemoteDeviceId(), - bundleName: 'com.samples.stagemodelabilityinteraction', - abilityName: 'CollaborateAbility', - moduleName: 'entry' // moduleName非必选 - }; - const RESULT_CODE: number = 1001; - // context为调用方UIAbility的UIAbilityContext - this.context.startAbilityForResult(want).then((data) => { - if (data?.resultCode === RESULT_CODE) { - // 解析目标端UIAbility返回的信息 - let info = data.want?.parameters?.info; - hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(info) ?? ''); - if (info !== null) { - promptAction.showToast({ - message : JSON.stringify(info) - }); - } - } - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `startAbilityForResult err: ` + JSON.stringify(error)); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.StartServiceExtensionAbility')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let want: Want = { - deviceId: getRemoteDeviceId(), - bundleName: 'com.samples.stagemodelabilityinteraction', - abilityName: 'ServiceExtAbility', - moduleName: 'entry' // moduleName非必选 - }; - // context为发起端UIAbility的AbilityContext - this.context.startAbility(want).then(() => { - // ... - promptAction.showToast({ - message: $r('app.string.SuccessfullyStart') - }); - }).catch((err: BusinessError) => { - // ... - hilog.error(DOMAIN_NUMBER, TAG, `startAbility err: ` + JSON.stringify(err)); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.StopServiceExtensionAbility')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let want: Want = { - deviceId: getRemoteDeviceId(), - bundleName: 'com.samples.stagemodelabilityinteraction', - abilityName: 'ServiceExtAbility', - moduleName: 'entry' // moduleName非必选 - }; - // 退出由startAbility接口启动的ServiceExtensionAbility - this.context.stopServiceExtensionAbility(want).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, "stop service extension ability success") - promptAction.showToast({ - message: $r('app.string.SuccessfullyStop') - }); - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `stop service extension ability err is ` + JSON.stringify(err)); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.Caller')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let caller: Caller | undefined; - let context = this.context; - - context.startAbilityByCall({ - deviceId: getRemoteDeviceId(), - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'CollaborateAbility', - }).then((data) => { - if (data !== null) { - caller = data; - hilog.info(DOMAIN_NUMBER, TAG, 'get remote caller success'); - // 注册caller的release监听 - caller.onRelease((msg) => { - hilog.info(DOMAIN_NUMBER, TAG, `remote caller onRelease is called ${msg}`); - }); - hilog.info(DOMAIN_NUMBER, TAG, 'remote caller register OnRelease succeed'); - promptAction.showToast({ - message: $r('app.string.CallerSuccess') - }); - // 注册caller的协同场景下跨设备组件状态变化监听通知 - try { - caller.onRemoteStateChange((str) => { - hilog.info(DOMAIN_NUMBER, TAG, 'Remote state changed ' + str); - }); - } catch (error) { - hilog.info(DOMAIN_NUMBER, TAG, `Caller.onRemoteStateChange catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}`); - }; - } - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `get remote caller failed with ${error}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.ConnectBackendService')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let want: Want = { - 'deviceId': getRemoteDeviceId(), - 'bundleName': 'com.samples.stagemodelabilityinteraction', - 'abilityName': 'ServiceExtAbility' - }; - // 建立连接后返回的Id需要保存下来,在解绑服务时需要作为参数传入 - connectionId = this.context.connectServiceExtensionAbility(want, options); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.DisconnectBackendService')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - this.context.disconnectServiceExtensionAbility(connectionId).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'disconnectServiceExtensionAbility success'); - // 成功断连后台服务 - promptAction.showToast({ - message: $r('app.string.SuccessfullyDisconnectBackendService') - }) - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, 'disconnectServiceExtensionAbility failed'); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import deviceManager from '@ohos.distributedDeviceManager'; +import hilog from '@ohos.hilog'; +import promptAction from '@ohos.promptAction'; +import rpc from '@ohos.rpc'; +import Want from '@ohos.app.ability.Want'; +import { BusinessError } from '@ohos.base'; +import { Caller } from '@ohos.app.ability.UIAbility'; + +const TAG: string = '[Page_CollaborateAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; +const REQUEST_CODE = 1; + +let dmClass: deviceManager.DeviceManager; + +let connectionId: number; +let options: common.ConnectOptions = { + onConnect(elementName, remote): void { + hilog.info(DOMAIN_NUMBER, TAG, 'onConnect callback'); + if (remote === null) { + hilog.info(DOMAIN_NUMBER, TAG, `onConnect remote is null`); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageSequence(); + let reply = new rpc.MessageSequence(); + data.writeInt(99); + // 开发者可发送data到目标端应用进行相应操作 + // @param code 表示客户端发送的服务请求代码。 + // @param data 表示客户端发送的{@link MessageSequence}对象。 + // @param reply 表示远程服务发送的响应消息对象。 + // @param options 指示操作是同步的还是异步的。 + // @return 如果操作成功返回{@code true}; 否则返回 {@code false}。 + remote.sendMessageRequest(REQUEST_CODE, data, reply, option).then((ret: rpc.RequestResult) => { + let errCode = reply.readInt(); // 在成功连接的情况下,会收到来自目标端返回的信息(100) + let msg: number = 0; + if (errCode === 0) { + msg = reply.readInt(); + } + hilog.info(DOMAIN_NUMBER, TAG, `sendRequest msg:${msg}`); + // 成功连接后台服务 + promptAction.showToast({ + message: `sendRequest msg:${msg}` + }); + }).catch((error: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, `sendRequest failed, ${JSON.stringify(error)}`); + }); + }, + onDisconnect(elementName): void { + hilog.info(DOMAIN_NUMBER, TAG, 'onDisconnect callback'); + }, + onFailed(code): void { + hilog.info(DOMAIN_NUMBER, TAG, 'onFailed callback'); + } +}; + +function initDmClass(): void { + // 其中createDeviceManager接口为系统API + try { + dmClass = deviceManager.createDeviceManager('com.samples.stagemodelabilitydevelop'); + hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(dmClass) ?? ''); + promptAction.showToast({ + message: $r('app.string.InitializedSuccessfully') + }); + } catch (err) { + hilog.error(DOMAIN_NUMBER, TAG, 'createDeviceManager err: ' + JSON.stringify(err)); + }; +}; + +function getRemoteDeviceId(): string | undefined { + if (typeof dmClass === 'object' && dmClass !== null) { + let list = dmClass.getAvailableDeviceListSync(); + hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(dmClass), JSON.stringify(list)); + if (typeof (list) === 'undefined' || typeof (list.length) === 'undefined') { + hilog.info(DOMAIN_NUMBER, TAG, 'getRemoteDeviceId err: list is null'); + return; + } + if (list.length === 0) { + hilog.info(DOMAIN_NUMBER, TAG, `getRemoteDeviceId err: list is empty`); + return; + } + return list[0].networkId; + } else { + hilog.info(DOMAIN_NUMBER, TAG, 'getRemoteDeviceId err: dmClass is null'); + return; + } +}; + +@Entry +@Component +struct Page_CollaborateAbility { + private context = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.MultiDeviceCollaboration')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row(){ + Text($r('app.string.CollaborativeInitialization')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + initDmClass() + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.MultiDeviceCollaborationWithoutReturningData')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let want: Want = { + deviceId: getRemoteDeviceId(), + bundleName: 'com.samples.stagemodelabilityinteraction', + abilityName: 'CollaborateAbility' + }; + this.context.startAbility(want).then(() => { + promptAction.showToast({ + message: $r('app.string.SuccessfulCollaboration') + }); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `startAbility err: ` + JSON.stringify(err)); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.MultiDeviceCollaborationWithReturningData')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let want: Want = { + deviceId: getRemoteDeviceId(), + bundleName: 'com.samples.stagemodelabilityinteraction', + abilityName: 'CollaborateAbility', + moduleName: 'entry' // moduleName非必选 + }; + const RESULT_CODE: number = 1001; + // context为调用方UIAbility的UIAbilityContext + this.context.startAbilityForResult(want).then((data) => { + if (data?.resultCode === RESULT_CODE) { + // 解析目标端UIAbility返回的信息 + let info = data.want?.parameters?.info; + hilog.info(DOMAIN_NUMBER, TAG, JSON.stringify(info) ?? ''); + if (info !== null) { + promptAction.showToast({ + message : JSON.stringify(info) + }); + } + } + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `startAbilityForResult err: ` + JSON.stringify(error)); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.StartServiceExtensionAbility')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let want: Want = { + deviceId: getRemoteDeviceId(), + bundleName: 'com.samples.stagemodelabilityinteraction', + abilityName: 'ServiceExtAbility', + moduleName: 'entry' // moduleName非必选 + }; + // context为发起端UIAbility的AbilityContext + this.context.startAbility(want).then(() => { + // ... + promptAction.showToast({ + message: $r('app.string.SuccessfullyStart') + }); + }).catch((err: BusinessError) => { + // ... + hilog.error(DOMAIN_NUMBER, TAG, `startAbility err: ` + JSON.stringify(err)); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.StopServiceExtensionAbility')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let want: Want = { + deviceId: getRemoteDeviceId(), + bundleName: 'com.samples.stagemodelabilityinteraction', + abilityName: 'ServiceExtAbility', + moduleName: 'entry' // moduleName非必选 + }; + // 退出由startAbility接口启动的ServiceExtensionAbility + this.context.stopServiceExtensionAbility(want).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, "stop service extension ability success") + promptAction.showToast({ + message: $r('app.string.SuccessfullyStop') + }); + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `stop service extension ability err is ` + JSON.stringify(err)); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.Caller')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let caller: Caller | undefined; + let context = this.context; + + context.startAbilityByCall({ + deviceId: getRemoteDeviceId(), + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'CollaborateAbility', + }).then((data) => { + if (data !== null) { + caller = data; + hilog.info(DOMAIN_NUMBER, TAG, 'get remote caller success'); + // 注册caller的release监听 + caller.onRelease((msg) => { + hilog.info(DOMAIN_NUMBER, TAG, `remote caller onRelease is called ${msg}`); + }); + hilog.info(DOMAIN_NUMBER, TAG, 'remote caller register OnRelease succeed'); + promptAction.showToast({ + message: $r('app.string.CallerSuccess') + }); + // 注册caller的协同场景下跨设备组件状态变化监听通知 + try { + caller.onRemoteStateChange((str) => { + hilog.info(DOMAIN_NUMBER, TAG, 'Remote state changed ' + str); + }); + } catch (error) { + hilog.info(DOMAIN_NUMBER, TAG, `Caller.onRemoteStateChange catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}`); + }; + } + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `get remote caller failed with ${error}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.ConnectBackendService')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let want: Want = { + 'deviceId': getRemoteDeviceId(), + 'bundleName': 'com.samples.stagemodelabilityinteraction', + 'abilityName': 'ServiceExtAbility' + }; + // 建立连接后返回的Id需要保存下来,在解绑服务时需要作为参数传入 + connectionId = this.context.connectServiceExtensionAbility(want, options); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.DisconnectBackendService')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + this.context.disconnectServiceExtensionAbility(connectionId).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'disconnectServiceExtensionAbility success'); + // 成功断连后台服务 + promptAction.showToast({ + message: $r('app.string.SuccessfullyDisconnectBackendService') + }) + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, 'disconnectServiceExtensionAbility failed'); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_contextability/Page_ContextAbility.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_contextability/Page_ContextAbility.ets index a7676b7306..e82a982553 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_contextability/Page_ContextAbility.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_contextability/Page_ContextAbility.ets @@ -1,152 +1,152 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import hilog from '@ohos.hilog'; -import promptAction from '@ohos.promptAction' - -const TAG: string = '[Page_ContextAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct Page_ContextAbility { - private context = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.Context04')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12, bottom: 11, right: 24, left: 24 }) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row() { - Text($r('app.string.CreateContextMethodOne')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let bundleName2: string = 'com.samples.stagemodelabilityinteraction'; - let bundleContext: Context = this.context.createBundleContext(bundleName2); - let label2: string = bundleContext.applicationInfo.label; - hilog.info(DOMAIN_NUMBER, TAG, `bundleContext is : ${JSON.stringify(bundleContext.createBundleContext(bundleName2))}`); - hilog.info(DOMAIN_NUMBER, TAG, `label2 is : ${JSON.stringify(label2)}`); - if (bundleContext && label2 !== null) { - promptAction.showToast({ - message: ('成功获取Context') - }); - } - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.CreateContextMethodTwo')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let bundleName2: string = 'com.samples.stagemodelabilityinteraction'; - let moduleName2: string = 'entry'; - let moduleContext: Context = this.context.createModuleContext(bundleName2, moduleName2); - if (moduleContext !== null) { - promptAction.showToast({ - message: ('成功获取Context') - }); - } - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.CreateContextMethodThree')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let moduleName2: string = 'entry'; - let moduleContext: Context = this.context.createModuleContext(moduleName2); - if (moduleContext !== null) { - promptAction.showToast({ - message: ('成功获取Context') - }); - } - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; +import promptAction from '@ohos.promptAction' + +const TAG: string = '[Page_ContextAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct Page_ContextAbility { + private context = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.Context04')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12, bottom: 11, right: 24, left: 24 }) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row() { + Text($r('app.string.CreateContextMethodOne')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let bundleName2: string = 'com.samples.stagemodelabilityinteraction'; + let bundleContext: Context = this.context.createBundleContext(bundleName2); + let label2: string = bundleContext.applicationInfo.label; + hilog.info(DOMAIN_NUMBER, TAG, `bundleContext is : ${JSON.stringify(bundleContext.createBundleContext(bundleName2))}`); + hilog.info(DOMAIN_NUMBER, TAG, `label2 is : ${JSON.stringify(label2)}`); + if (bundleContext && label2 !== null) { + promptAction.showToast({ + message: ('成功获取Context') + }); + } + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.CreateContextMethodTwo')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let bundleName2: string = 'com.samples.stagemodelabilityinteraction'; + let moduleName2: string = 'entry'; + let moduleContext: Context = this.context.createModuleContext(bundleName2, moduleName2); + if (moduleContext !== null) { + promptAction.showToast({ + message: ('成功获取Context') + }); + } + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.CreateContextMethodThree')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let moduleName2: string = 'entry'; + let moduleContext: Context = this.context.createModuleContext(moduleName2); + if (moduleContext !== null) { + promptAction.showToast({ + message: ('成功获取Context') + }); + } + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_funcability/Page_FuncAbilityA.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_funcability/Page_FuncAbilityA.ets index b996b650d3..f8fadd48b6 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_funcability/Page_FuncAbilityA.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_funcability/Page_FuncAbilityA.ets @@ -1,139 +1,139 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import hilog from '@ohos.hilog'; - -const TAG: string = '[Page_FuncAbilityA]'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct Page_FuncAbilityA { - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.SpecifiedPageA')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row(){ - Text($r('app.string.CloseSpecifiedPage')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - const RESULT_CODE: number = 1001; - let abilityResult: common.AbilityResult = { - resultCode: RESULT_CODE, - want: { - bundleName: 'com.samples.stagemodelabilitydevelop', - moduleName: 'entry', // moduleName非必选 - abilityName: 'FuncAbilityB', - parameters: { - info: '来自FuncAbility Index页面' - }, - }, - }; - context.terminateSelfWithResult(abilityResult, (err) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to terminate self with result. Code is ${err.code}, message is ${err.message}`); - return; - } - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - - ListItem() { - Row() { - Row(){ - Text($r('app.string.CloseSpecifiedPageA')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - const RESULT_CODE: number = 1001; - let abilityResult: common.AbilityResult = { - resultCode: RESULT_CODE, - want: { - bundleName: 'com.samples.stagemodelabilitydevelop', - moduleName: 'entry', // moduleName非必选 - abilityName: 'FuncAbilityB', - parameters: { - info: '来自FuncAbility Index页面' - }, - }, - }; - context.terminateSelfWithResult(abilityResult, (err) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to terminate self with result. Code is ${err.code}, message is ${err.message}`); - return; - } - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; + +const TAG: string = '[Page_FuncAbilityA]'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct Page_FuncAbilityA { + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.SpecifiedPageA')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row(){ + Text($r('app.string.CloseSpecifiedPage')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + const RESULT_CODE: number = 1001; + let abilityResult: common.AbilityResult = { + resultCode: RESULT_CODE, + want: { + bundleName: 'com.samples.stagemodelabilitydevelop', + moduleName: 'entry', // moduleName非必选 + abilityName: 'FuncAbilityB', + parameters: { + info: '来自FuncAbility Index页面' + }, + }, + }; + context.terminateSelfWithResult(abilityResult, (err) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to terminate self with result. Code is ${err.code}, message is ${err.message}`); + return; + } + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + + ListItem() { + Row() { + Row(){ + Text($r('app.string.CloseSpecifiedPageA')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + const RESULT_CODE: number = 1001; + let abilityResult: common.AbilityResult = { + resultCode: RESULT_CODE, + want: { + bundleName: 'com.samples.stagemodelabilitydevelop', + moduleName: 'entry', // moduleName非必选 + abilityName: 'FuncAbilityB', + parameters: { + info: '来自FuncAbility Index页面' + }, + }, + }; + context.terminateSelfWithResult(abilityResult, (err) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to terminate self with result. Code is ${err.code}, message is ${err.message}`); + return; + } + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_funcability/Page_FuncAbilityB.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_funcability/Page_FuncAbilityB.ets index 835d35ff99..73975c6c83 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_funcability/Page_FuncAbilityB.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_funcability/Page_FuncAbilityB.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 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 Page_FuncAbilityB { - - build() { - Column() { - Row() { - Text($r('app.string.SpecifiedPageC')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224}) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - .fontWeight(400) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 Page_FuncAbilityB { + + build() { + Column() { + Row() { + Text($r('app.string.SpecifiedPageC')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224}) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + .fontWeight(400) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_lifecycleability/Page_LifecycleAbility.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_lifecycleability/Page_LifecycleAbility.ets index 26558c4629..1c5dcbba59 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_lifecycleability/Page_LifecycleAbility.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_lifecycleability/Page_LifecycleAbility.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 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 Page_LifecycleAbility { - - build() { - Column() { - Row() { - Text($r('app.string.Context05')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224}) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - .fontWeight(400) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 Page_LifecycleAbility { + + build() { + Column() { + Row() { + Text($r('app.string.Context05')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224}) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + .fontWeight(400) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilityFirst.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilityFirst.ets index 90ea8848c9..0ee5ad1504 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilityFirst.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilityFirst.ets @@ -1,149 +1,149 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import common from '@ohos.app.ability.common'; -import hilog from '@ohos.hilog'; -import promptAction from '@ohos.promptAction' -import router from '@ohos.router'; - -const TAG: string = '[MigrationAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct Page_MigrationAbilityFirst { - private context = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.DeviceCrossMigration')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12, bottom: 11, right: 24, left: 24 }) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row() { - Text($r('app.string.Page_MigrationAbilitySecond')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - router.pushUrl({ - url: 'pages/page_migrationability/Page_MigrationAbilitySecond' - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.Page_MigrationAbilityThird')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - router.pushUrl({ - url: 'pages/page_migrationability/Page_MigrationAbilityThird' - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.Page_MigrationAbilityFourth')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 12 }) - } - .onClick(() => { - // 点击该按钮时,将应用设置为可迁移状态 - this.context.setMissionContinueState(AbilityConstant.ContinueState.ACTIVE, (result) => { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', `setMissionContinueState ACTIVE result: ${JSON.stringify(result)}`); - promptAction.showToast({ - message: $r('app.string.Success') - }); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } - - onPageShow(){ - // 进入该页面时,将应用设置为可迁移状态 - this.context.setMissionContinueState(AbilityConstant.ContinueState.ACTIVE, (result) => { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', `setMissionContinueState ACTIVE result: ${JSON.stringify(result)}`); - }); - } +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; +import promptAction from '@ohos.promptAction' +import router from '@ohos.router'; + +const TAG: string = '[MigrationAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct Page_MigrationAbilityFirst { + private context = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.DeviceCrossMigration')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12, bottom: 11, right: 24, left: 24 }) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row() { + Text($r('app.string.Page_MigrationAbilitySecond')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + router.pushUrl({ + url: 'pages/page_migrationability/Page_MigrationAbilitySecond' + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.Page_MigrationAbilityThird')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + router.pushUrl({ + url: 'pages/page_migrationability/Page_MigrationAbilityThird' + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.Page_MigrationAbilityFourth')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 12 }) + } + .onClick(() => { + // 点击该按钮时,将应用设置为可迁移状态 + this.context.setMissionContinueState(AbilityConstant.ContinueState.ACTIVE, (result) => { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', `setMissionContinueState ACTIVE result: ${JSON.stringify(result)}`); + promptAction.showToast({ + message: $r('app.string.Success') + }); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } + + onPageShow(){ + // 进入该页面时,将应用设置为可迁移状态 + this.context.setMissionContinueState(AbilityConstant.ContinueState.ACTIVE, (result) => { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', `setMissionContinueState ACTIVE result: ${JSON.stringify(result)}`); + }); + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilitySecond.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilitySecond.ets index 1e7a1412c4..6491b85c0c 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilitySecond.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilitySecond.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 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 Page_MigrationAbilityTSecond { - - build() { - Column() { - Row() { - Text($r('app.string.Page_MigrationAbilitySecond')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224}) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - .fontWeight(400) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 Page_MigrationAbilityTSecond { + + build() { + Column() { + Row() { + Text($r('app.string.Page_MigrationAbilitySecond')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224}) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + .fontWeight(400) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilityThird.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilityThird.ets index f62e88536d..de96fb337b 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilityThird.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_migrationability/Page_MigrationAbilityThird.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 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 Page_MigrationAbilityThird { - - build() { - Column() { - Row() { - Text($r('app.string.Page_MigrationAbilityThird')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224}) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - .fontWeight(400) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 Page_MigrationAbilityThird { + + build() { + Column() { + Row() { + Text($r('app.string.Page_MigrationAbilityThird')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224}) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + .fontWeight(400) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Multiton.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Multiton.ets index d365e06d83..7554b9c83d 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Multiton.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Multiton.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 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 Page_multiton { - - build() { - Column() { - Row() { - Text($r('app.string.multiton')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224}) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - .fontWeight(400) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 Page_multiton { + + build() { + Column() { + Row() { + Text($r('app.string.multiton')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224}) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + .fontWeight(400) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Singleton.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Singleton.ets index 15bc6d4c04..a8b246cf41 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Singleton.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Singleton.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 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 Page_singleton { - - build() { - Column() { - Row() { - Text($r('app.string.singleton')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224}) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - .fontWeight(400) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 Page_singleton { + + build() { + Column() { + Row() { + Text($r('app.string.singleton')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224}) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + .fontWeight(400) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Specified_First.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Specified_First.ets index fc5e79ecbd..9378ec5206 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Specified_First.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Specified_First.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 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 Page_Specified { - - build() { - Column() { - Row() { - Text($r('app.string.Newpage')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224}) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - .fontWeight(400) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 Page_Specified { + + build() { + Column() { + Row() { + Text($r('app.string.Newpage')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224}) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + .fontWeight(400) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Specified_Second.ets b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Specified_Second.ets index 64989ddc69..5f8a159b07 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Specified_Second.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/page_startupability/Page_Specified_Second.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 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 Page_Specified_Second { - - build() { - Column() { - Row() { - Text($r('app.string.Savedpage')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224}) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - .fontWeight(400) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 Page_Specified_Second { + + build() { + Column() { + Row() { + Text($r('app.string.Savedpage')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224}) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8 , bottom: 317 , right: 152 , left: 152}) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + .fontWeight(400) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/utils/Logger.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/utils/Logger.ts index 3168d4e7a9..c0d05b9282 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/utils/Logger.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/utils/Logger.ts @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - /** - * debug - * @param args - */ - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - /** - * info - * @param args - */ - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - /** - * warn - * @param args - */ - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - /** - * error - * @param args - */ - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + /** + * debug + * @param args + */ + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + /** + * info + * @param args + */ + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + /** + * warn + * @param args + */ + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + /** + * error + * @param args + */ + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[stageuiabilitydevelop]'); \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/module.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/module.json5 index ead18a2c36..0870234a49 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/module.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/module.json5 @@ -1,223 +1,223 @@ -/* - * Copyright (c) 2024 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", - "srcEntry": "./ets/myabilitystage/MyAbilityStage.ts", - "description": "$string:module_desc", - "mainElement": "EntryAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - // UIAbility组件的名称 - "srcEntry": "./ets/entryability/EntryAbility.ts", - // UIAbility组件的代码路径 - "description": "$string:EntryAbility_desc", - // UIAbility组件的描述信息 - "icon": "$media:icon", - // UIAbility组件的图标 - "label": "$string:EntryAbility_label", - // UIAbility组件的标签 - "startWindowIcon": "$media:icon", - // UIAbility组件启动页面图标资源文件的索引 - "startWindowBackground": "$color:start_window_background", - // UIAbility组件启动页面背景颜色资源文件的索引 - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "ohos.want.action.home" - ] - } - ] - }, - { - "name": "SingletonAbility", - "srcEntry": "./ets/componentstartupability/SingletonAbility.ts", - "description": "$string:SingletonAbility_desc", - "icon": "$media:icon", - "label": "$string:SingletonAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "launchType": "singleton" - }, - { - "name": "MultitonAbility", - "srcEntry": "./ets/componentstartupability/MultitonAbility.ts", - "description": "$string:SingletonAbility_desc", - "icon": "$media:icon", - "label": "$string:SingletonAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "launchType": "multiton" - }, - { - "name": "SpecifiedFirstAbility", - "srcEntry": "./ets/componentstartupability/SpecifiedFirstAbility.ts", - "description": "$string:SingletonAbility_desc", - "icon": "$media:icon", - "label": "$string:SingletonAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "launchType": "specified" - }, - { - "name": "SpecifiedSecondAbility", - "srcEntry": "./ets/componentstartupability/SpecifiedSecondAbility.ts", - "description": "$string:SingletonAbility_desc", - "icon": "$media:icon", - "label": "$string:SingletonAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "launchType": "specified" - }, - { - "name": "MyAbilityStage", - "srcEntry": "./ets/myabilitystage/MyAbilityStage.ts", - "description": "$string:MyAbilityStage_desc", - "icon": "$media:icon", - "label": "$string:MyAbilityStage_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "launchType": "specified" - }, - { - "name": "EventAbility", - "srcEntry": "./ets/eventability/EventAbility.ts", - "description": "$string:EventAbility_desc", - "icon": "$media:icon", - "label": "$string:EventAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - }, - { - "name": "FuncAbilityA", - "srcEntry": "./ets/funcability/FuncAbilityA.ts", - "description": "$string:FuncAbility_desc", - "icon": "$media:icon", - "label": "$string:FuncAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - }, - { - "name": "FuncAbilityB", - "srcEntry": "./ets/funcability/FuncAbilityB.ts", - "description": "$string:FuncAbility_desc", - "icon": "$media:icon", - "label": "$string:FuncAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "supportWindowMode": [ - "floating" - ] - }, - { - "name": "LifecycleAbility", - "srcEntry": "./ets/lifecycleability/LifecycleAbility.ts", - "description": "$string:LifecycleAbility_desc", - "icon": "$media:icon", - "label": "$string:LifecycleAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - }, - { - "name": "ContextAbility", - "srcEntry": "./ets/contextability/ContextAbility.ts", - "description": "$string:ContextAbility_desc", - "icon": "$media:icon", - "label": "$string:ContextAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - }, - { - "name": "MigrationAbility", - "srcEntry": "./ets/migrationability/MigrationAbility.ts", - "description": "$string:MigrationAbility_desc", - "icon": "$media:icon", - "label": "$string:MigrationAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "continuable": true - // 配置UIAbility支持迁移 - }, - { - "name": "CollaborateAbility", - "srcEntry": "./ets/collaborateability/CollaborateAbility.ts", - "description": "$string:CollaborateAbility_desc", - "icon": "$media:icon", - "label": "$string:CollaborateAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.DISTRIBUTED_DATASYNC", - "reason": "$string:DISTRIBUTED_DATASYNC", - "usedScene": { - "abilities": [ - "MigrationAbility", - "CollaborateAbility" - ], - "when": "inuse" - } - }, - { - "name": "ohos.permission.READ_CALENDAR", - "reason": "$string:READ_CALENDAR", - "usedScene": { - "abilities": [ - "MigrationAbility" - ], - "when": "inuse" - } - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - }, - { - "name": "ohos.permission.START_INVISIBLE_ABILITY", - }, - { - "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", - }, - { - "name": "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION", - } - ], - "extensionAbilities": [ - { - "name": "ServiceExtAbility", - "srcEntry": "./ets/serviceextability/ServiceExtAbility.ts", - "description": "$string:ServiceExtAbility_desc", - "label": "$string:ServiceExtAbility_label", - "type": "service" - } - ] - } +/* + * Copyright (c) 2024 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", + "srcEntry": "./ets/myabilitystage/MyAbilityStage.ts", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + // UIAbility组件的名称 + "srcEntry": "./ets/entryability/EntryAbility.ts", + // UIAbility组件的代码路径 + "description": "$string:EntryAbility_desc", + // UIAbility组件的描述信息 + "icon": "$media:icon", + // UIAbility组件的图标 + "label": "$string:EntryAbility_label", + // UIAbility组件的标签 + "startWindowIcon": "$media:icon", + // UIAbility组件启动页面图标资源文件的索引 + "startWindowBackground": "$color:start_window_background", + // UIAbility组件启动页面背景颜色资源文件的索引 + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ] + } + ] + }, + { + "name": "SingletonAbility", + "srcEntry": "./ets/componentstartupability/SingletonAbility.ts", + "description": "$string:SingletonAbility_desc", + "icon": "$media:icon", + "label": "$string:SingletonAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "launchType": "singleton" + }, + { + "name": "MultitonAbility", + "srcEntry": "./ets/componentstartupability/MultitonAbility.ts", + "description": "$string:SingletonAbility_desc", + "icon": "$media:icon", + "label": "$string:SingletonAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "launchType": "multiton" + }, + { + "name": "SpecifiedFirstAbility", + "srcEntry": "./ets/componentstartupability/SpecifiedFirstAbility.ts", + "description": "$string:SingletonAbility_desc", + "icon": "$media:icon", + "label": "$string:SingletonAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "launchType": "specified" + }, + { + "name": "SpecifiedSecondAbility", + "srcEntry": "./ets/componentstartupability/SpecifiedSecondAbility.ts", + "description": "$string:SingletonAbility_desc", + "icon": "$media:icon", + "label": "$string:SingletonAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "launchType": "specified" + }, + { + "name": "MyAbilityStage", + "srcEntry": "./ets/myabilitystage/MyAbilityStage.ts", + "description": "$string:MyAbilityStage_desc", + "icon": "$media:icon", + "label": "$string:MyAbilityStage_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "launchType": "specified" + }, + { + "name": "EventAbility", + "srcEntry": "./ets/eventability/EventAbility.ts", + "description": "$string:EventAbility_desc", + "icon": "$media:icon", + "label": "$string:EventAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "FuncAbilityA", + "srcEntry": "./ets/funcability/FuncAbilityA.ts", + "description": "$string:FuncAbility_desc", + "icon": "$media:icon", + "label": "$string:FuncAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "FuncAbilityB", + "srcEntry": "./ets/funcability/FuncAbilityB.ts", + "description": "$string:FuncAbility_desc", + "icon": "$media:icon", + "label": "$string:FuncAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "supportWindowMode": [ + "floating" + ] + }, + { + "name": "LifecycleAbility", + "srcEntry": "./ets/lifecycleability/LifecycleAbility.ts", + "description": "$string:LifecycleAbility_desc", + "icon": "$media:icon", + "label": "$string:LifecycleAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "ContextAbility", + "srcEntry": "./ets/contextability/ContextAbility.ts", + "description": "$string:ContextAbility_desc", + "icon": "$media:icon", + "label": "$string:ContextAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "MigrationAbility", + "srcEntry": "./ets/migrationability/MigrationAbility.ts", + "description": "$string:MigrationAbility_desc", + "icon": "$media:icon", + "label": "$string:MigrationAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "continuable": true + // 配置UIAbility支持迁移 + }, + { + "name": "CollaborateAbility", + "srcEntry": "./ets/collaborateability/CollaborateAbility.ts", + "description": "$string:CollaborateAbility_desc", + "icon": "$media:icon", + "label": "$string:CollaborateAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC", + "reason": "$string:DISTRIBUTED_DATASYNC", + "usedScene": { + "abilities": [ + "MigrationAbility", + "CollaborateAbility" + ], + "when": "inuse" + } + }, + { + "name": "ohos.permission.READ_CALENDAR", + "reason": "$string:READ_CALENDAR", + "usedScene": { + "abilities": [ + "MigrationAbility" + ], + "when": "inuse" + } + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + }, + { + "name": "ohos.permission.START_INVISIBLE_ABILITY", + }, + { + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", + }, + { + "name": "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION", + } + ], + "extensionAbilities": [ + { + "name": "ServiceExtAbility", + "srcEntry": "./ets/serviceextability/ServiceExtAbility.ts", + "description": "$string:ServiceExtAbility_desc", + "label": "$string:ServiceExtAbility_label", + "type": "service" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/resources/base/element/color.json b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/resources/base/element/color.json index 940b8e80b7..eb1a630dc3 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/resources/base/element/color.json @@ -1,24 +1,24 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "background", - "value": "#f1f3f5" - }, - { - "name": "backGrounding", - "value": "#f1f3f5" - }, - { - "name": "text_color", - "value": "#182431" - }, - { - "name": "button_color", - "value": "#027DFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "background", + "value": "#f1f3f5" + }, + { + "name": "backGrounding", + "value": "#f1f3f5" + }, + { + "name": "text_color", + "value": "#182431" + }, + { + "name": "button_color", + "value": "#027DFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/ohosTest/ets/utils/Logger.ts b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/ohosTest/ets/utils/Logger.ts index 3168d4e7a9..c0d05b9282 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/ohosTest/ets/utils/Logger.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/ohosTest/ets/utils/Logger.ts @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - /** - * debug - * @param args - */ - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - /** - * info - * @param args - */ - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - /** - * warn - * @param args - */ - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - /** - * error - * @param args - */ - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + /** + * debug + * @param args + */ + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + /** + * info + * @param args + */ + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + /** + * warn + * @param args + */ + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + /** + * error + * @param args + */ + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[stageuiabilitydevelop]'); \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/ohosTest/module.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/ohosTest/module.json5 index 0bea9afb74..038f15faf5 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/hvigor/hvigor-config.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/hvigor/hvigor-config.json5 index fb29482d10..9a79085076 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/oh-package.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/oh-package.json5 index 844aa70c43..c337cd08b0 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "stagemodelabilitydevelop", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "stagemodelabilitydevelop", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/AppScope/app.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/AppScope/app.json5 index ae3f80fc67..a2220d43c1 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/AppScope/app.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.stagemodelabilityinteraction", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.stagemodelabilityinteraction", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/AppScope/resources/base/element/string.json b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/AppScope/resources/base/element/string.json index 1700d67d6d..35a81dba98 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "StageModelAbilityInteraction" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "StageModelAbilityInteraction" + } + ] +} diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/build-profile.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/build-profile.json5 index b4ed08ad14..9ab0a5df27 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/build-profile.json5 @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ], - "signingConfigs": [ - - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ], + "signingConfigs": [ + + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/build-profile.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/build-profile.json5 index 32345d66a3..8296d8e04d 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/oh-package.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/oh-package.json5 index 60d792bb92..413a75299a 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/i_idl_service_ext.ts b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/i_idl_service_ext.ts index dfe2d12447..f597be317d 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/i_idl_service_ext.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/i_idl_service_ext.ts @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2023 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 default interface IIdlServiceExt { - processData(data: number, callback: ProcessDataCallback): void; - insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void; -} - -export type ProcessDataCallback = (errCode: number, returnValue: number) => void; - -export type InsertDataToMapCallback = (errCode: number) => void; +/* + * Copyright (c) 2023 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 default interface IIdlServiceExt { + processData(data: number, callback: ProcessDataCallback): void; + insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void; +} + +export type ProcessDataCallback = (errCode: number, returnValue: number) => void; + +export type InsertDataToMapCallback = (errCode: number) => void; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts index aa665b7dc6..cdb00c7c7d 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2023 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import bundleManager from '@ohos.bundle.bundleManager'; -import IdlServiceExtStub from './idl_service_ext_stub'; -import rpc from '@ohos.rpc'; -import type { BusinessError } from '@ohos.base'; -import type { InsertDataToMapCallback } from './i_idl_service_ext'; -import type { ProcessDataCallback } from './i_idl_service_ext'; -import hilog from '@ohos.hilog'; - -const ERR_OK = 0; -const TAG: string = '[IdlServiceExtImpl]'; -const ERR_DENY = -1; -const DOMAIN_NUMBER: number = 0xFF00; - -// 开发者需要在这个类型里对接口进行实现 -export default class ServiceExtImpl extends IdlServiceExtStub { - processData(data: number, callback: ProcessDataCallback): void { - // 开发者自行实现业务逻辑 - hilog.info(DOMAIN_NUMBER, TAG, `processData: ${data}`); - - let callerUid = rpc.IPCSkeleton.getCallingUid(); - bundleManager.getBundleNameByUid(callerUid).then((callerBundleName) => { - hilog.info(DOMAIN_NUMBER, TAG, 'getBundleNameByUid: ' + callerBundleName); - // 对客户端包名进行识别 - if (callerBundleName !== 'com.samples.stagemodelabilitydevelop') { // 识别不通过 - hilog.info(DOMAIN_NUMBER, TAG, 'The caller bundle is not in trustlist, reject'); - return; - } - // 识别通过,执行正常业务逻辑 - }).catch((err: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, 'getBundleNameByUid failed: ' + err.message); - }); - - let callerTokenId = rpc.IPCSkeleton.getCallingTokenId(); - let accessManger = abilityAccessCtrl.createAtManager(); - // 所校验的具体权限由开发者自行选择,此处ohos.permission.GET_BUNDLE_INFO_PRIVILEGED只作为示例 - let grantStatus = accessManger.verifyAccessTokenSync(callerTokenId, 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'); - if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) { - hilog.info(DOMAIN_NUMBER, TAG, 'PERMISSION_DENIED'); - callback(ERR_DENY, data); // 鉴权失败,返回错误 - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'verify access token success.'); - callback(ERR_OK, data + 1); // 鉴权通过,执行正常业务逻辑 - }; - - insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { - // 开发者自行实现业务逻辑 - hilog.info(DOMAIN_NUMBER, TAG, `insertDataToMap, key: ${key} val: ${val}`); - callback(ERR_OK); - }; +/* + * Copyright (c) 2023 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import bundleManager from '@ohos.bundle.bundleManager'; +import IdlServiceExtStub from './idl_service_ext_stub'; +import rpc from '@ohos.rpc'; +import type { BusinessError } from '@ohos.base'; +import type { InsertDataToMapCallback } from './i_idl_service_ext'; +import type { ProcessDataCallback } from './i_idl_service_ext'; +import hilog from '@ohos.hilog'; + +const ERR_OK = 0; +const TAG: string = '[IdlServiceExtImpl]'; +const ERR_DENY = -1; +const DOMAIN_NUMBER: number = 0xFF00; + +// 开发者需要在这个类型里对接口进行实现 +export default class ServiceExtImpl extends IdlServiceExtStub { + processData(data: number, callback: ProcessDataCallback): void { + // 开发者自行实现业务逻辑 + hilog.info(DOMAIN_NUMBER, TAG, `processData: ${data}`); + + let callerUid = rpc.IPCSkeleton.getCallingUid(); + bundleManager.getBundleNameByUid(callerUid).then((callerBundleName) => { + hilog.info(DOMAIN_NUMBER, TAG, 'getBundleNameByUid: ' + callerBundleName); + // 对客户端包名进行识别 + if (callerBundleName !== 'com.samples.stagemodelabilitydevelop') { // 识别不通过 + hilog.info(DOMAIN_NUMBER, TAG, 'The caller bundle is not in trustlist, reject'); + return; + } + // 识别通过,执行正常业务逻辑 + }).catch((err: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, 'getBundleNameByUid failed: ' + err.message); + }); + + let callerTokenId = rpc.IPCSkeleton.getCallingTokenId(); + let accessManger = abilityAccessCtrl.createAtManager(); + // 所校验的具体权限由开发者自行选择,此处ohos.permission.GET_BUNDLE_INFO_PRIVILEGED只作为示例 + let grantStatus = accessManger.verifyAccessTokenSync(callerTokenId, 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'); + if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) { + hilog.info(DOMAIN_NUMBER, TAG, 'PERMISSION_DENIED'); + callback(ERR_DENY, data); // 鉴权失败,返回错误 + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'verify access token success.'); + callback(ERR_OK, data + 1); // 鉴权通过,执行正常业务逻辑 + }; + + insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { + // 开发者自行实现业务逻辑 + hilog.info(DOMAIN_NUMBER, TAG, `insertDataToMap, key: ${key} val: ${val}`); + callback(ERR_OK); + }; }; \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_proxy.ts b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_proxy.ts index bed2370f6c..bd80611542 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_proxy.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_proxy.ts @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2023 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 type { ProcessDataCallback } from './i_idl_service_ext'; -import type { InsertDataToMapCallback } from './i_idl_service_ext'; -import type IIdlServiceExt from './i_idl_service_ext'; -import rpc from '@ohos.rpc'; -import hilog from '@ohos.hilog'; - -const TAG: string = '[IdlServiceExtProxy]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class IdlServiceExtProxy implements IIdlServiceExt { - static readonly COMMAND_PROCESS_DATA = 1; - static readonly COMMAND_INSERT_DATA_TO_MAP = 2; - private proxy; - - constructor(proxy) { - this.proxy = proxy; - }; - - processData(data: number, callback: ProcessDataCallback): void { - let option = new rpc.MessageOption(); - let dataSequence = rpc.MessageSequence.create(); - let replySequence = rpc.MessageSequence.create(); - try { - dataSequence.writeInt(data); - this.proxy.sendMessageRequest(IdlServiceExtProxy.COMMAND_PROCESS_DATA, dataSequence, replySequence, option).then(function (result) { - if (result.errCode === 0) { - let errCodeVar = result.reply.readInt(); - if (errCodeVar !== 0) { - let returnValueVar = undefined; - callback(errCodeVar, returnValueVar); - return; - } - let returnValueVar = result.reply.readInt(); - callback(errCodeVar, returnValueVar); - } else { - hilog.info(DOMAIN_NUMBER, TAG, 'sendMessageRequest failed, errCode: ' + result.errCode); - } - }); - } finally { - dataSequence.reclaim(); - replySequence.reclaim(); - }; - }; - - insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { - let option = new rpc.MessageOption(); - let dataSequence = rpc.MessageSequence.create(); - let replySequence = rpc.MessageSequence.create(); - try { - dataSequence.writeString(key); - dataSequence.writeInt(val); - this.proxy.sendMessageRequest(IdlServiceExtProxy.COMMAND_INSERT_DATA_TO_MAP, dataSequence, replySequence, option).then(function (result) { - if (result.errCode === 0) { - let errCodeVar = result.reply.readInt(); - callback(errCodeVar); - } else { - hilog.info(DOMAIN_NUMBER, TAG, 'sendMessageRequest failed, errCode: ' + result.errCode); - } - }); - } finally { - dataSequence.reclaim(); - replySequence.reclaim(); - }; - }; -}; - +/* + * Copyright (c) 2023 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 type { ProcessDataCallback } from './i_idl_service_ext'; +import type { InsertDataToMapCallback } from './i_idl_service_ext'; +import type IIdlServiceExt from './i_idl_service_ext'; +import rpc from '@ohos.rpc'; +import hilog from '@ohos.hilog'; + +const TAG: string = '[IdlServiceExtProxy]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class IdlServiceExtProxy implements IIdlServiceExt { + static readonly COMMAND_PROCESS_DATA = 1; + static readonly COMMAND_INSERT_DATA_TO_MAP = 2; + private proxy; + + constructor(proxy) { + this.proxy = proxy; + }; + + processData(data: number, callback: ProcessDataCallback): void { + let option = new rpc.MessageOption(); + let dataSequence = rpc.MessageSequence.create(); + let replySequence = rpc.MessageSequence.create(); + try { + dataSequence.writeInt(data); + this.proxy.sendMessageRequest(IdlServiceExtProxy.COMMAND_PROCESS_DATA, dataSequence, replySequence, option).then(function (result) { + if (result.errCode === 0) { + let errCodeVar = result.reply.readInt(); + if (errCodeVar !== 0) { + let returnValueVar = undefined; + callback(errCodeVar, returnValueVar); + return; + } + let returnValueVar = result.reply.readInt(); + callback(errCodeVar, returnValueVar); + } else { + hilog.info(DOMAIN_NUMBER, TAG, 'sendMessageRequest failed, errCode: ' + result.errCode); + } + }); + } finally { + dataSequence.reclaim(); + replySequence.reclaim(); + }; + }; + + insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { + let option = new rpc.MessageOption(); + let dataSequence = rpc.MessageSequence.create(); + let replySequence = rpc.MessageSequence.create(); + try { + dataSequence.writeString(key); + dataSequence.writeInt(val); + this.proxy.sendMessageRequest(IdlServiceExtProxy.COMMAND_INSERT_DATA_TO_MAP, dataSequence, replySequence, option).then(function (result) { + if (result.errCode === 0) { + let errCodeVar = result.reply.readInt(); + callback(errCodeVar); + } else { + hilog.info(DOMAIN_NUMBER, TAG, 'sendMessageRequest failed, errCode: ' + result.errCode); + } + }); + } finally { + dataSequence.reclaim(); + replySequence.reclaim(); + }; + }; +}; + diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_stub.ts b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_stub.ts index f94652f844..9cb80f7415 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_stub.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/IdlServiceExt/idl_service_ext_stub.ts @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2023 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 type { ProcessDataCallback } from './i_idl_service_ext'; -import type { InsertDataToMapCallback } from './i_idl_service_ext'; -import type IIdlServiceExt from './i_idl_service_ext'; -import rpc from '@ohos.rpc'; -import hilog from '@ohos.hilog'; - -const TAG: string = '[IdlServiceExtStub]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class IdlServiceExtStub extends rpc.RemoteObject implements IIdlServiceExt { - constructor(des: string) { - super(des); - }; - - async onRemoteMessageRequest(code: number, data: rpc.MessageSequence, reply: rpc.MessageSequence, option: rpc.MessageOption): Promise { - hilog.info(DOMAIN_NUMBER, TAG, 'onRemoteMessageRequest called, code = ' + code); - switch (code) { - case IdlServiceExtStub.COMMAND_PROCESS_DATA: { - let dataVar = data.readInt(); - let promise = new Promise((resolve, reject) => { - this.processData(dataVar, (errCode, returnValue) => { - reply.writeInt(errCode); - if (errCode === 0) { - reply.writeInt(returnValue); - } - resolve(); - }); - }); - await promise; - return true; - }; - case IdlServiceExtStub.COMMAND_INSERT_DATA_TO_MAP: { - let keyVar = data.readString(); - let valVar = data.readInt(); - let promise = new Promise((resolve, reject) => { - this.insertDataToMap(keyVar, valVar, (errCode) => { - reply.writeInt(errCode); - resolve(); - }); - }); - await promise; - return true; - }; - default: { - hilog.info(DOMAIN_NUMBER, TAG, 'invalid request code' + code); - break; - } - } - return false; - } - - processData(data: number, callback: ProcessDataCallback): void { - }; - - insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { - }; - - static readonly COMMAND_PROCESS_DATA = 1; - static readonly COMMAND_INSERT_DATA_TO_MAP = 2; +/* + * Copyright (c) 2023 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 type { ProcessDataCallback } from './i_idl_service_ext'; +import type { InsertDataToMapCallback } from './i_idl_service_ext'; +import type IIdlServiceExt from './i_idl_service_ext'; +import rpc from '@ohos.rpc'; +import hilog from '@ohos.hilog'; + +const TAG: string = '[IdlServiceExtStub]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class IdlServiceExtStub extends rpc.RemoteObject implements IIdlServiceExt { + constructor(des: string) { + super(des); + }; + + async onRemoteMessageRequest(code: number, data: rpc.MessageSequence, reply: rpc.MessageSequence, option: rpc.MessageOption): Promise { + hilog.info(DOMAIN_NUMBER, TAG, 'onRemoteMessageRequest called, code = ' + code); + switch (code) { + case IdlServiceExtStub.COMMAND_PROCESS_DATA: { + let dataVar = data.readInt(); + let promise = new Promise((resolve, reject) => { + this.processData(dataVar, (errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode === 0) { + reply.writeInt(returnValue); + } + resolve(); + }); + }); + await promise; + return true; + }; + case IdlServiceExtStub.COMMAND_INSERT_DATA_TO_MAP: { + let keyVar = data.readString(); + let valVar = data.readInt(); + let promise = new Promise((resolve, reject) => { + this.insertDataToMap(keyVar, valVar, (errCode) => { + reply.writeInt(errCode); + resolve(); + }); + }); + await promise; + return true; + }; + default: { + hilog.info(DOMAIN_NUMBER, TAG, 'invalid request code' + code); + break; + } + } + return false; + } + + processData(data: number, callback: ProcessDataCallback): void { + }; + + insertDataToMap(key: string, val: number, callback: InsertDataToMapCallback): void { + }; + + static readonly COMMAND_PROCESS_DATA = 1; + static readonly COMMAND_INSERT_DATA_TO_MAP = 2; }; \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/calleeability/CalleeAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/calleeability/CalleeAbility.ts index 43226caade..85dcb24126 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/calleeability/CalleeAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/calleeability/CalleeAbility.ts @@ -1,134 +1,134 @@ -/* - * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type Want from '@ohos.app.ability.Want'; -import hilog from '@ohos.hilog'; -import type rpc from '@ohos.rpc'; -import type window from '@ohos.window'; -import type { Caller } from '@ohos.app.ability.UIAbility'; - -const TAG: string = '[CalleeAbility]'; -const MSG_SEND_METHOD: string = 'CallSendMsg'; -const DOMAIN_NUMBER: number = 0xFF00; - -class MyParcelable { - num: number = 0; - str: string = ''; - - constructor(num: number, string: string) { - this.num = num; - this.str = string; - }; - - mySequenceable(num, string): void { - this.num = num; - this.str = string; - }; - - marshalling(messageSequence: rpc.MessageSequence): boolean { - messageSequence.writeInt(this.num); - messageSequence.writeString(this.str); - return true; - }; - - unmarshalling(messageSequence: rpc.MessageSequence): boolean { - this.num = messageSequence.readInt(); - this.str = messageSequence.readString(); - return true; - }; -}; - -function sendMsgCallback(data: rpc.MessageSequence): rpc.Parcelable { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'CalleeSortFunc called'); - - // 获取Caller发送的序列化数据 - let receivedData: MyParcelable = new MyParcelable(0, ''); - data.readParcelable(receivedData); - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', `receiveData[${receivedData.num}, ${receivedData.str}]`); - let num: number = receivedData.num; - - // 作相应处理 - // 返回序列化数据result给Caller - return new MyParcelable(num + 1, `send ${receivedData.str} succeed`) as rpc.Parcelable; -}; - -export default class CalleeAbility extends UIAbility { - caller: Caller | undefined; - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - try { - this.callee.on(MSG_SEND_METHOD, sendMsgCallback); - } catch (error) { - hilog.error(DOMAIN_NUMBER, TAG, '%{public}s', `Failed to register. Error is ${error}`); - }; - }; - - async onButtonCall(): Promise { - try { - let msg: MyParcelable = new MyParcelable(1, 'origin_Msg'); - if (this.caller) { - await this.caller.call(MSG_SEND_METHOD, msg); - } - } catch (error) { - hilog.info(DOMAIN_NUMBER, TAG, `caller call failed with ${error}`); - }; - }; - - async onButtonCallWithResult(originMsg: string, backMsg: string): Promise { - try { - let msg: MyParcelable = new MyParcelable(1, originMsg); - if (this.caller) { - const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg); - hilog.info(DOMAIN_NUMBER, TAG, 'caller callWithResult succeed'); - let result: MyParcelable = new MyParcelable(0, ''); - data.readParcelable(result); - backMsg = result.str; - hilog.info(DOMAIN_NUMBER, TAG, `caller result is [${result.num}, ${result.str}]`); - } - } catch (error) { - hilog.info(DOMAIN_NUMBER, TAG, `caller callWithResult failed with ${error}`); - }; - }; - - releaseCall(): void { - try { - if (this.caller) { - this.caller.release(); - this.caller = undefined; - } - hilog.info(DOMAIN_NUMBER, TAG, 'caller release succeed'); - } catch (error) { - hilog.info(DOMAIN_NUMBER, TAG, `caller release failed with ${error}`); - }; - }; - - onWindowStageCreate(windowStage: window.WindowStage): void { - // 设置UI加载 - windowStage.loadContent('pages/Page_CalleeAbility', (err, data) => { - }); - }; - - onDestroy(): void { - try { - this.callee.off(MSG_SEND_METHOD); - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Callee OnDestroy'); - this.releaseCall(); - } catch (error) { - hilog.error(DOMAIN_NUMBER, TAG, '%{public}s', `Failed to register. Error is ${error}`); - }; - }; -}; +/* + * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type Want from '@ohos.app.ability.Want'; +import hilog from '@ohos.hilog'; +import type rpc from '@ohos.rpc'; +import type window from '@ohos.window'; +import type { Caller } from '@ohos.app.ability.UIAbility'; + +const TAG: string = '[CalleeAbility]'; +const MSG_SEND_METHOD: string = 'CallSendMsg'; +const DOMAIN_NUMBER: number = 0xFF00; + +class MyParcelable { + num: number = 0; + str: string = ''; + + constructor(num: number, string: string) { + this.num = num; + this.str = string; + }; + + mySequenceable(num, string): void { + this.num = num; + this.str = string; + }; + + marshalling(messageSequence: rpc.MessageSequence): boolean { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); + return true; + }; + + unmarshalling(messageSequence: rpc.MessageSequence): boolean { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); + return true; + }; +}; + +function sendMsgCallback(data: rpc.MessageSequence): rpc.Parcelable { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'CalleeSortFunc called'); + + // 获取Caller发送的序列化数据 + let receivedData: MyParcelable = new MyParcelable(0, ''); + data.readParcelable(receivedData); + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', `receiveData[${receivedData.num}, ${receivedData.str}]`); + let num: number = receivedData.num; + + // 作相应处理 + // 返回序列化数据result给Caller + return new MyParcelable(num + 1, `send ${receivedData.str} succeed`) as rpc.Parcelable; +}; + +export default class CalleeAbility extends UIAbility { + caller: Caller | undefined; + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + try { + this.callee.on(MSG_SEND_METHOD, sendMsgCallback); + } catch (error) { + hilog.error(DOMAIN_NUMBER, TAG, '%{public}s', `Failed to register. Error is ${error}`); + }; + }; + + async onButtonCall(): Promise { + try { + let msg: MyParcelable = new MyParcelable(1, 'origin_Msg'); + if (this.caller) { + await this.caller.call(MSG_SEND_METHOD, msg); + } + } catch (error) { + hilog.info(DOMAIN_NUMBER, TAG, `caller call failed with ${error}`); + }; + }; + + async onButtonCallWithResult(originMsg: string, backMsg: string): Promise { + try { + let msg: MyParcelable = new MyParcelable(1, originMsg); + if (this.caller) { + const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg); + hilog.info(DOMAIN_NUMBER, TAG, 'caller callWithResult succeed'); + let result: MyParcelable = new MyParcelable(0, ''); + data.readParcelable(result); + backMsg = result.str; + hilog.info(DOMAIN_NUMBER, TAG, `caller result is [${result.num}, ${result.str}]`); + } + } catch (error) { + hilog.info(DOMAIN_NUMBER, TAG, `caller callWithResult failed with ${error}`); + }; + }; + + releaseCall(): void { + try { + if (this.caller) { + this.caller.release(); + this.caller = undefined; + } + hilog.info(DOMAIN_NUMBER, TAG, 'caller release succeed'); + } catch (error) { + hilog.info(DOMAIN_NUMBER, TAG, `caller release failed with ${error}`); + }; + }; + + onWindowStageCreate(windowStage: window.WindowStage): void { + // 设置UI加载 + windowStage.loadContent('pages/Page_CalleeAbility', (err, data) => { + }); + }; + + onDestroy(): void { + try { + this.callee.off(MSG_SEND_METHOD); + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Callee OnDestroy'); + this.releaseCall(); + } catch (error) { + hilog.error(DOMAIN_NUMBER, TAG, '%{public}s', `Failed to register. Error is ${error}`); + }; + }; +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/collaborateability/CollaborateAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/collaborateability/CollaborateAbility.ts index 0075a932e4..3a7cf3dc4f 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/collaborateability/CollaborateAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/collaborateability/CollaborateAbility.ts @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type window from '@ohos.window'; - -const DOMAIN_NUMBER: number = 0xFF00; -const TAG: string = '[CollaborateAbility]'; - -export default class CollaborateAbility extends UIAbility { - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Page_CollaborateAbility', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; + +const DOMAIN_NUMBER: number = 0xFF00; +const TAG: string = '[CollaborateAbility]'; + +export default class CollaborateAbility extends UIAbility { + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Page_CollaborateAbility', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } +} diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/entryability/EntryAbility.ts index 5137a3c831..e978e8c94a 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import type Want from '@ohos.app.ability.Want'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type window from '@ohos.window'; - -import type { Router, UIContext } from '@ohos.arkui.UIContext'; -import type { BusinessError } from '@ohos.base'; - -const DOMAIN_NUMBER: number = 0xFF00; -const TAG: string = '[EntryAbility]'; - -export default class EntryAbility extends UIAbility { - funcAbilityWant: Want | undefined = undefined; - uiContext: UIContext | undefined = undefined; - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - // 接收调用方UIAbility传过来的参数 - this.funcAbilityWant = want; - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - // Main window is created, set main page for this ability - let url = 'pages/Index'; - if (this.funcAbilityWant?.parameters?.router && this.funcAbilityWant.parameters.router === 'funcA') { - url = 'pages/Page_ColdStartUp'; - } - - windowStage.loadContent(url, (err, data) => { - if (err.code) { - return; - } - - let windowClass: window.Window; - windowStage.getMainWindow((err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to obtain the main window. Code is ${err.code}, message is ${err.message}`); - return; - } - windowClass = data; - this.uiContext = windowClass.getUIContext(); - }); - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } - - onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { - if (want?.parameters?.router && want.parameters.router === 'funcB') { - let funcAUrl = 'pages/Page_HotStartUp'; - if (this.uiContext) { - let router: Router = this.uiContext.getRouter(); - router.pushUrl({ - url: funcAUrl - }).catch((err: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to push url. Code is ${err.code}, message is ${err.message}`); - }); - } - } - }; -}; +/* + * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import type Want from '@ohos.app.ability.Want'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; + +import type { Router, UIContext } from '@ohos.arkui.UIContext'; +import type { BusinessError } from '@ohos.base'; + +const DOMAIN_NUMBER: number = 0xFF00; +const TAG: string = '[EntryAbility]'; + +export default class EntryAbility extends UIAbility { + funcAbilityWant: Want | undefined = undefined; + uiContext: UIContext | undefined = undefined; + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // 接收调用方UIAbility传过来的参数 + this.funcAbilityWant = want; + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + // Main window is created, set main page for this ability + let url = 'pages/Index'; + if (this.funcAbilityWant?.parameters?.router && this.funcAbilityWant.parameters.router === 'funcA') { + url = 'pages/Page_ColdStartUp'; + } + + windowStage.loadContent(url, (err, data) => { + if (err.code) { + return; + } + + let windowClass: window.Window; + windowStage.getMainWindow((err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to obtain the main window. Code is ${err.code}, message is ${err.message}`); + return; + } + windowClass = data; + this.uiContext = windowClass.getUIContext(); + }); + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + if (want?.parameters?.router && want.parameters.router === 'funcB') { + let funcAUrl = 'pages/Page_HotStartUp'; + if (this.uiContext) { + let router: Router = this.uiContext.getRouter(); + router.pushUrl({ + url: funcAUrl + }).catch((err: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to push url. Code is ${err.code}, message is ${err.message}`); + }); + } + } + }; +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/funcability/FuncAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/funcability/FuncAbility.ts index 1e930b8926..652084d1df 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/funcability/FuncAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/funcability/FuncAbility.ts @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type Want from '@ohos.app.ability.Want'; -import type window from '@ohos.window'; -import type { UIContext } from '@ohos.arkui.UIContext'; - -const DOMAIN_NUMBER: number = 0xFF00; -const TAG: string = '[FuncAbility]'; - -export default class FuncAbility extends UIAbility { - - funcAbilityWant: Want | undefined = undefined; - uiContext: UIContext | undefined = undefined; - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Page_FromStageModel', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } -}; +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type Want from '@ohos.app.ability.Want'; +import type window from '@ohos.window'; +import type { UIContext } from '@ohos.arkui.UIContext'; + +const DOMAIN_NUMBER: number = 0xFF00; +const TAG: string = '[FuncAbility]'; + +export default class FuncAbility extends UIAbility { + + funcAbilityWant: Want | undefined = undefined; + uiContext: UIContext | undefined = undefined; + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Page_FromStageModel', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } +}; diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/funcbability/FuncBAbility.ts b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/funcbability/FuncBAbility.ts index b174e10333..a51fdddc38 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/funcbability/FuncBAbility.ts +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/funcbability/FuncBAbility.ts @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type window from '@ohos.window'; - -const DOMAIN_NUMBER: number = 0xFF00; -const TAG: string = '[FuncAbility]'; - -export default class FuncAbility extends UIAbility { - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Page_ColdStartUp', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; + +const DOMAIN_NUMBER: number = 0xFF00; +const TAG: string = '[FuncAbility]'; + +export default class FuncAbility extends UIAbility { + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Page_ColdStartUp', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } +} diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_CalleeAbility.ets b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_CalleeAbility.ets index e1dc78961b..9edc297739 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_CalleeAbility.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_CalleeAbility.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 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 Page_CalleeAbility { - - build() { - Column() { - Row() { - Text($r('app.string.CalleePage')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12, bottom: 11, right: 24, left: 24 }) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224 }) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8, bottom: 317, right: 152, left: 152 }) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - .fontWeight(400) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 Page_CalleeAbility { + + build() { + Column() { + Row() { + Text($r('app.string.CalleePage')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12, bottom: 11, right: 24, left: 24 }) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224 }) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8, bottom: 317, right: 152, left: 152 }) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + .fontWeight(400) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_ColdStartUp.ets b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_ColdStartUp.ets index 0a9a0b84d5..aa6cdd4d37 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_ColdStartUp.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_ColdStartUp.ets @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import hilog from '@ohos.hilog'; - -const TAG: string = '[Page_ColdStartUp]'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct Page_ColdStartUp { - - build() { - Column() { - Row() { - Text($r('app.string.FunctionA')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12, bottom: 11, right: 24, left: 24 }) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Button($r('app.string.FuncAbilityD')) - .fontFamily('HarmonyHeiTi') - .height(48) - .width('624px') - .margin({ top: 550 }) - .type(ButtonType.Capsule) - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('app.color.button_color')) - .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - // 绑定点击事件 - .onClick(() => { - let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - // context为需要停止的UIAbility实例的AbilityContext - context.terminateSelf((err) => { - if (err.code) { - hilog.error(0x0000, TAG, `Failed to terminate self. Code is ${err.code}, message is ${err.message}`); - return; - } - }); - }) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; + +const TAG: string = '[Page_ColdStartUp]'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct Page_ColdStartUp { + + build() { + Column() { + Row() { + Text($r('app.string.FunctionA')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12, bottom: 11, right: 24, left: 24 }) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Button($r('app.string.FuncAbilityD')) + .fontFamily('HarmonyHeiTi') + .height(48) + .width('624px') + .margin({ top: 550 }) + .type(ButtonType.Capsule) + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('app.color.button_color')) + .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + // 绑定点击事件 + .onClick(() => { + let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + // context为需要停止的UIAbility实例的AbilityContext + context.terminateSelf((err) => { + if (err.code) { + hilog.error(0x0000, TAG, `Failed to terminate self. Code is ${err.code}, message is ${err.message}`); + return; + } + }); + }) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_CollaborateAbility.ets b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_CollaborateAbility.ets index 965f0025b8..4267db1eae 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_CollaborateAbility.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_CollaborateAbility.ets @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import hilog from '@ohos.hilog'; -import { BusinessError } from '@ohos.base'; - -const DOMAIN_NUMBER: number = 0xFF00; -const TAG: string = '[Page_CollaborateAbility]'; - -@Entry -@Component -struct Page_CollaborateAbility { - - private context = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Text($r('app.string.Page_CollaborateAbility')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12, bottom: 11, right: 24, left: 24 }) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Button($r('app.string.ClosePage_CollaborateAbility')) - .fontFamily('HarmonyHeiTi') - .height(48) - .width('624px') - .margin({ top: 550 }) - .type(ButtonType.Capsule) - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('app.color.button_color')) - .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .onClick(()=>{ - const RESULT_CODE: number = 1001; - // context为目标端UIAbility的AbilityContext - this.context.terminateSelfWithResult( - { - resultCode: RESULT_CODE, - want: { - bundleName: 'com.samples.stagemodelabilitydevelop', - abilityName: 'CollaborateAbility', - moduleName: 'entry', - parameters: { - info: '来自Page_CollaborateAbility页面' - } - } - }, - (err: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, `terminateSelfWithResult err: ` + JSON.stringify(err)); - }); - }) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; +import { BusinessError } from '@ohos.base'; + +const DOMAIN_NUMBER: number = 0xFF00; +const TAG: string = '[Page_CollaborateAbility]'; + +@Entry +@Component +struct Page_CollaborateAbility { + + private context = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Text($r('app.string.Page_CollaborateAbility')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12, bottom: 11, right: 24, left: 24 }) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Button($r('app.string.ClosePage_CollaborateAbility')) + .fontFamily('HarmonyHeiTi') + .height(48) + .width('624px') + .margin({ top: 550 }) + .type(ButtonType.Capsule) + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('app.color.button_color')) + .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .onClick(()=>{ + const RESULT_CODE: number = 1001; + // context为目标端UIAbility的AbilityContext + this.context.terminateSelfWithResult( + { + resultCode: RESULT_CODE, + want: { + bundleName: 'com.samples.stagemodelabilitydevelop', + abilityName: 'CollaborateAbility', + moduleName: 'entry', + parameters: { + info: '来自Page_CollaborateAbility页面' + } + } + }, + (err: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, `terminateSelfWithResult err: ` + JSON.stringify(err)); + }); + }) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_FromStageModel.ets b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_FromStageModel.ets index d12d754a10..ef516cb938 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_FromStageModel.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_FromStageModel.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import hilog from '@ohos.hilog'; - -const DOMAIN_NUMBER: number = 0xFF00; -const TAG: string = '[Page_FromStageModel]'; - -@Entry -@Component -struct Page_FromStageModel { - - build() { - Column() { - Row() { - Text($r('app.string.FuncAbilityA')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12, bottom: 11, right: 24, left: 24 }) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Button($r('app.string.FuncAbilityB')) - .fontFamily('HarmonyHeiTi') - .height(48) - .width('624px') - .margin({ top: 550 }) - .type(ButtonType.Capsule) - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('app.color.button_color')) - .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .onClick(() => { - let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - // context为需要停止的UIAbility实例的AbilityContext - context.terminateSelf((err) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to terminate self. Code is ${err.code}, message is ${err.message}`); - return; - } - }); - }) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; + +const DOMAIN_NUMBER: number = 0xFF00; +const TAG: string = '[Page_FromStageModel]'; + +@Entry +@Component +struct Page_FromStageModel { + + build() { + Column() { + Row() { + Text($r('app.string.FuncAbilityA')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12, bottom: 11, right: 24, left: 24 }) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Button($r('app.string.FuncAbilityB')) + .fontFamily('HarmonyHeiTi') + .height(48) + .width('624px') + .margin({ top: 550 }) + .type(ButtonType.Capsule) + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('app.color.button_color')) + .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .onClick(() => { + let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + // context为需要停止的UIAbility实例的AbilityContext + context.terminateSelf((err) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to terminate self. Code is ${err.code}, message is ${err.message}`); + return; + } + }); + }) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_HotStartUp.ets b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_HotStartUp.ets index 9a283aa577..88862e6cbd 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_HotStartUp.ets +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/ets/pages/Page_HotStartUp.ets @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2023 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 Page_HotStartUp { - - build() { - Column() { - Row() { - Text($r('app.string.FunctionB')) - .fontSize(24) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ top: 12, bottom: 11, right: 24, left: 24 }) - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - - Image($r('app.media.pic_empty')) - .width(120) - .height(120) - .margin({ top: 224 }) - - Text($r('app.string.NoContentAvailable')) - .fontSize(14) - .margin({ top: 8, bottom: 317, right: 152, left: 152 }) - .fontColor($r('app.color.text_color')) - .opacity(0.4) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 Page_HotStartUp { + + build() { + Column() { + Row() { + Text($r('app.string.FunctionB')) + .fontSize(24) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ top: 12, bottom: 11, right: 24, left: 24 }) + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + + Image($r('app.media.pic_empty')) + .width(120) + .height(120) + .margin({ top: 224 }) + + Text($r('app.string.NoContentAvailable')) + .fontSize(14) + .margin({ top: 8, bottom: 317, right: 152, left: 152 }) + .fontColor($r('app.color.text_color')) + .opacity(0.4) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/module.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/module.json5 index 040ce9cb63..c653608483 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/module.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/module.json5 @@ -1,143 +1,143 @@ -/* - * Copyright (c) 2023 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "FuncAbility", - "srcEntry": "./ets/funcability/FuncAbility.ts", - "description": "$string:FuncAbility_desc", - "icon": "$media:icon", - "label": "$string:FuncAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.default" - ], - "actions": [ - "ohos.want.action.viewData" - ] - } - ] - }, - { - "name": "CollaborateAbility", - "srcEntry": "./ets/collaborateability/CollaborateAbility.ts", - "description": "$string:CollaborateAbility_desc", - "icon": "$media:icon", - "label": "$string:CollaborateAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true - }, - { - "name": "CalleeAbility", - "srcEntry": "./ets/calleeability/CalleeAbility.ts", - "description": "$string:CalleeAbility_desc", - "icon": "$media:icon", - "label": "$string:CalleeAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "launchType": "singleton", - "exported": true - }, - { - "name": "FuncBAbility", - "srcEntry": "./ets/funcbability/FuncBAbility.ts", - "description": "$string:FuncBAbility_desc", - "icon": "$media:icon", - "label": "$string:FuncBAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.default" - ], - "actions": [ - "ohos.want.action.editData" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - }, - { - "name": "ohos.permission.START_INVISIBLE_ABILITY", - }, - { - "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", - }, - { - "name": "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION", - } - ], - "extensionAbilities": [ - { - "name": "ServiceExtAbility", - "srcEntry": "./ets/serviceextability/ServiceExtAbility.ts", - "description": "$string:ServiceExtAbility_desc", - "label": "$string:ServiceExtAbility_label", - "type": "service", - "exported": true, - "metadata": [ - { - "name": "ohos.extension.service", - "resource": "$profile:serviceextability" - } - ] - } - ] - } +/* + * Copyright (c) 2023 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "FuncAbility", + "srcEntry": "./ets/funcability/FuncAbility.ts", + "description": "$string:FuncAbility_desc", + "icon": "$media:icon", + "label": "$string:FuncAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.default" + ], + "actions": [ + "ohos.want.action.viewData" + ] + } + ] + }, + { + "name": "CollaborateAbility", + "srcEntry": "./ets/collaborateability/CollaborateAbility.ts", + "description": "$string:CollaborateAbility_desc", + "icon": "$media:icon", + "label": "$string:CollaborateAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true + }, + { + "name": "CalleeAbility", + "srcEntry": "./ets/calleeability/CalleeAbility.ts", + "description": "$string:CalleeAbility_desc", + "icon": "$media:icon", + "label": "$string:CalleeAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "launchType": "singleton", + "exported": true + }, + { + "name": "FuncBAbility", + "srcEntry": "./ets/funcbability/FuncBAbility.ts", + "description": "$string:FuncBAbility_desc", + "icon": "$media:icon", + "label": "$string:FuncBAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.default" + ], + "actions": [ + "ohos.want.action.editData" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + }, + { + "name": "ohos.permission.START_INVISIBLE_ABILITY", + }, + { + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", + }, + { + "name": "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION", + } + ], + "extensionAbilities": [ + { + "name": "ServiceExtAbility", + "srcEntry": "./ets/serviceextability/ServiceExtAbility.ts", + "description": "$string:ServiceExtAbility_desc", + "label": "$string:ServiceExtAbility_label", + "type": "service", + "exported": true, + "metadata": [ + { + "name": "ohos.extension.service", + "resource": "$profile:serviceextability" + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/resources/base/element/color.json b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/resources/base/element/color.json index 940b8e80b7..eb1a630dc3 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/resources/base/element/color.json @@ -1,24 +1,24 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "background", - "value": "#f1f3f5" - }, - { - "name": "backGrounding", - "value": "#f1f3f5" - }, - { - "name": "text_color", - "value": "#182431" - }, - { - "name": "button_color", - "value": "#027DFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "background", + "value": "#f1f3f5" + }, + { + "name": "backGrounding", + "value": "#f1f3f5" + }, + { + "name": "text_color", + "value": "#182431" + }, + { + "name": "button_color", + "value": "#027DFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/resources/base/profile/serviceextability.json b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/resources/base/profile/serviceextability.json index ea55737120..85c3d8af6f 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/resources/base/profile/serviceextability.json +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/entry/src/main/resources/base/profile/serviceextability.json @@ -1,8 +1,8 @@ -{ - "accessibilityCapabilities": [ - "retrieve", - "keyEventObserver", - "gesture", - "touchGuide" - ] +{ + "accessibilityCapabilities": [ + "retrieve", + "keyEventObserver", + "gesture", + "touchGuide" + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/hvigor/hvigor-config.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/hvigor/hvigor-config.json5 index 7fcecec159..dba571014f 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/oh-package.json5 b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/oh-package.json5 index f9e69b7bf0..4cc27b5a49 100644 --- a/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/StageModelAbilityInteraction/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "stagemodelabilityinteraction", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "stagemodelabilityinteraction", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/AppScope/app.json5 b/code/DocsSample/ApplicationModels/StageProcessThread/AppScope/app.json5 index f0eacd2abb..31c4b28f77 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/AppScope/app.json5 +++ b/code/DocsSample/ApplicationModels/StageProcessThread/AppScope/app.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2023 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.stageprocessthread", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.stageprocessthread", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/AppScope/resources/base/element/string.json b/code/DocsSample/ApplicationModels/StageProcessThread/AppScope/resources/base/element/string.json index 7ec9f9eae0..0bc5f90425 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/StageProcessThread/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "StageProcessThread" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "StageProcessThread" + } + ] +} diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/build-profile.json5 b/code/DocsSample/ApplicationModels/StageProcessThread/build-profile.json5 index b3c7006645..2549e47021 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/StageProcessThread/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/build-profile.json5 b/code/DocsSample/ApplicationModels/StageProcessThread/entry/build-profile.json5 index 9cd0b63f73..b2e1b5ba3f 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/build-profile.json5 @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2023 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": { - "sourceOption": { - "workers": [ - "./src/main/ets/workers/Worker.ts" - ] - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + "sourceOption": { + "workers": [ + "./src/main/ets/workers/Worker.ts" + ] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/oh-package.json5 b/code/DocsSample/ApplicationModels/StageProcessThread/entry/oh-package.json5 index b31d93383c..6876164b6a 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2023 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. - */ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/entryability/EntryAbility.ts index a4b5f95b55..d5f2afce2f 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,87 +1,87 @@ -/* - * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import type common from '@ohos.app.ability.common'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type Want from '@ohos.app.ability.Want'; -import type { BusinessError } from '@ohos.base'; -import image from '@ohos.multimedia.image'; -import type resourceManager from '@ohos.resourceManager'; -import type window from '@ohos.window'; -import hilog from '@ohos.hilog'; -import commonEventManager from '@ohos.commonEventManager'; - -const DOMAIN_NUMBER: number = 0xFF00; -const TAG: string = 'EntryAbility'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - let context: common.UIAbilityContext = this.context; // UIAbilityContext - // 设置任务快照的名称 - context.setMissionLabel('test').then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in seting mission label.'); - }).catch((err: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, `Failed to set mission label. Code is ${err.code}, message is ${err.message}`); - }); - - // 获取resourceManager资源管理 - const resourceMgr: resourceManager.ResourceManager = this.context.resourceManager; - resourceMgr.getRawFileContent('test.jpg').then((data) => { - hilog.info(DOMAIN_NUMBER, TAG, 'data.length = ' + data.byteLength); - // 获取图片的ArrayBuffer - const imageSource: image.ImageSource = image.createImageSource(data.buffer); - imageSource.createPixelMap().then((pixelMap) => { - // 设置任务快照的图标 - context.setMissionIcon(pixelMap, (err) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to set mission icon. Code is ${err.code}, message is ${err.message}`); - } else { - hilog.info(DOMAIN_NUMBER, TAG, 'Success to set mission icon.'); - } - }) - pixelMap.release(); - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, 'setMissionIcon failed: ' + JSON.stringify(error)); - }); - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, 'getRawFileContent failed: ' + JSON.stringify(error)); - }); - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onCreate'); - } - - // onDestroy():void { - // commonEventManager.removeStickyCommonEvent('usual.event.SCREEN_OFF', (err: Base.BusinessError) => { - // // sticky_event粘性公共事件名 - // if (err) { - // hilog.error(DOMAIN_NUMBER, TAG, `Failed to remove sticky common event. Code is ${err.code}, message is ${err.message}`); - // return; - // } - // hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in removeing sticky event.`); - // }); - // } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause:', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data:', JSON.stringify(data) ?? ''); - }); - } -} +/* + * Copyright (c) 2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import type common from '@ohos.app.ability.common'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type Want from '@ohos.app.ability.Want'; +import type { BusinessError } from '@ohos.base'; +import image from '@ohos.multimedia.image'; +import type resourceManager from '@ohos.resourceManager'; +import type window from '@ohos.window'; +import hilog from '@ohos.hilog'; +import commonEventManager from '@ohos.commonEventManager'; + +const DOMAIN_NUMBER: number = 0xFF00; +const TAG: string = 'EntryAbility'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + let context: common.UIAbilityContext = this.context; // UIAbilityContext + // 设置任务快照的名称 + context.setMissionLabel('test').then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in seting mission label.'); + }).catch((err: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, `Failed to set mission label. Code is ${err.code}, message is ${err.message}`); + }); + + // 获取resourceManager资源管理 + const resourceMgr: resourceManager.ResourceManager = this.context.resourceManager; + resourceMgr.getRawFileContent('test.jpg').then((data) => { + hilog.info(DOMAIN_NUMBER, TAG, 'data.length = ' + data.byteLength); + // 获取图片的ArrayBuffer + const imageSource: image.ImageSource = image.createImageSource(data.buffer); + imageSource.createPixelMap().then((pixelMap) => { + // 设置任务快照的图标 + context.setMissionIcon(pixelMap, (err) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to set mission icon. Code is ${err.code}, message is ${err.message}`); + } else { + hilog.info(DOMAIN_NUMBER, TAG, 'Success to set mission icon.'); + } + }) + pixelMap.release(); + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, 'setMissionIcon failed: ' + JSON.stringify(error)); + }); + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, 'getRawFileContent failed: ' + JSON.stringify(error)); + }); + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onCreate'); + } + + // onDestroy():void { + // commonEventManager.removeStickyCommonEvent('usual.event.SCREEN_OFF', (err: Base.BusinessError) => { + // // sticky_event粘性公共事件名 + // if (err) { + // hilog.error(DOMAIN_NUMBER, TAG, `Failed to remove sticky common event. Code is ${err.code}, message is ${err.message}`); + // return; + // } + // hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in removeing sticky event.`); + // }); + // } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onWindowStageCreate'); + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause:', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data:', JSON.stringify(data) ?? ''); + }); + } +} diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageProcessModel.ets b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageProcessModel.ets index 35903cd7de..513dc7ff17 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageProcessModel.ets +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageProcessModel.ets @@ -1,332 +1,332 @@ -/* - * Copyright (c) 2023 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 Base from '@ohos.base'; -import commonEventManager from '@ohos.commonEventManager'; -import promptAction from '@ohos.promptAction'; -import hilog from '@ohos.hilog'; - -const DOMAIN_NUMBER: number = 0xFF00; -const TAG: string = 'ProcessModel'; - -@Entry -@Component -struct PageProcessModel { - // 用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 - private subscriber: commonEventManager.CommonEventSubscriber | null = null; - // 订阅者信息 - private subscribeInfo: commonEventManager.CommonEventSubscribeInfo = { - events: ['usual.event.SCREEN_OFF'], // 订阅灭屏公共事件 - }; - // 判断当前是否发送过粘性公共事件 - private ifSendStickyKey: boolean = false; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.process_button')) - .fontSize(24) - .fontWeight(FontWeight.Bold) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row(){ - Text($r('app.string.subscribe_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - - } - .onClick(() => { - if (this.subscriber !== null) { - promptAction.showToast({ - message: $r('app.string.subscribe_failed_toast') - }); - return; - } - // 创建订阅者回调 - commonEventManager.createSubscriber(this.subscribeInfo, (err: Base.BusinessError, data: commonEventManager.CommonEventSubscriber) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to create subscriber. Code is ${err.code}, message is ${err.message}`); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in creating subscriber.'); - this.subscriber = data; - - // 订阅公共事件回调 - if (this.subscriber !== null) { - commonEventManager.subscribe(this.subscriber, (err: Base.BusinessError, data: commonEventManager.CommonEventData) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to subscribe common event. Code is ${err.code}, message is ${err.message}`); - return; - } - promptAction.showToast({ - message: JSON.stringify(data) - }); - hilog.info(DOMAIN_NUMBER, TAG, `Receive CommonEventData = ` + JSON.stringify(data)); - }) - if (this.ifSendStickyKey === false) { - promptAction.showToast({ - message: $r('app.string.subscribe_success_toast') - }); - } - } else { - hilog.error(DOMAIN_NUMBER, TAG, `Need create subscriber`); - } - }) - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - - ListItem() { - Row() { - Row(){ - Text($r('app.string.unsubscribe_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // subscriber为订阅事件时创建的订阅者对象 - if (this.subscriber !== null) { - commonEventManager.unsubscribe(this.subscriber, (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, `UnsubscribeCallBack err = ${JSON.stringify(err)}`); - } else { - promptAction.showToast({ - message: $r('app.string.unsubscribe_success_toast') - }); - hilog.info(DOMAIN_NUMBER, TAG, `Unsubscribe success`); - this.subscriber = null; - } - }) - } else { - promptAction.showToast({ - message: $r('app.string.unsubscribe_failed_toast') - }); - } - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.publish_noinfo_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 发布公共事件 - commonEventManager.publish('usual.event.SCREEN_OFF', (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, `PublishCallBack err = ${JSON.stringify(err)}`); - } else { - if (this.subscriber === null) { - promptAction.showToast({ - message: $r('app.string.publish_noinfo_success_toast') - }); - } - hilog.info(DOMAIN_NUMBER, TAG, `Publish success`); - } - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.publish_haveinfo_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 公共事件相关信息 - let options: commonEventManager.CommonEventPublishData = { - code: 1, // 公共事件的初始代码 - data: 'initial data', // 公共事件的初始数据 - }; - - // 发布公共事件 - commonEventManager.publish('usual.event.SCREEN_OFF', options, (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, 'PublishCallBack err = ' + JSON.stringify(err)); - } else { - if (this.subscriber === null) { - promptAction.showToast({ - message: $r('app.string.publish_haveinfo_success_toast') - }); - } - hilog.info(DOMAIN_NUMBER, TAG, 'Publish success'); - } - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.publish_sticky_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 公共事件相关信息 - let options: commonEventManager.CommonEventPublishData = { - code: 1, // 公共事件的初始代码 - data: 'initial Sticky data', // 公共事件的初始数据 - isSticky: true - }; - - // 发布公共事件 - commonEventManager.publish('usual.event.SCREEN_OFF', options, (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, 'PublishCallBack err=' + JSON.stringify(err)); - } else { - promptAction.showToast({ - message: $r('app.string.publish_sticky_success_toast') - }); - this.ifSendStickyKey = true; - hilog.info(DOMAIN_NUMBER, TAG, 'Publish success'); - } - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.remove_sticky_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - commonEventManager.removeStickyCommonEvent('usual.event.SCREEN_OFF', (err: Base.BusinessError) => { - // sticky_event粘性公共事件名 - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to remove sticky common event. Code is ${err.code}, message is ${err.message}`); - return; - } - promptAction.showToast({ - message: $r('app.string.remove_sticky_success_toast') - }); - this.ifSendStickyKey = false; - hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in removeing sticky event.`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } - +/* + * Copyright (c) 2023 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 Base from '@ohos.base'; +import commonEventManager from '@ohos.commonEventManager'; +import promptAction from '@ohos.promptAction'; +import hilog from '@ohos.hilog'; + +const DOMAIN_NUMBER: number = 0xFF00; +const TAG: string = 'ProcessModel'; + +@Entry +@Component +struct PageProcessModel { + // 用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 + private subscriber: commonEventManager.CommonEventSubscriber | null = null; + // 订阅者信息 + private subscribeInfo: commonEventManager.CommonEventSubscribeInfo = { + events: ['usual.event.SCREEN_OFF'], // 订阅灭屏公共事件 + }; + // 判断当前是否发送过粘性公共事件 + private ifSendStickyKey: boolean = false; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.process_button')) + .fontSize(24) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row(){ + Text($r('app.string.subscribe_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + + } + .onClick(() => { + if (this.subscriber !== null) { + promptAction.showToast({ + message: $r('app.string.subscribe_failed_toast') + }); + return; + } + // 创建订阅者回调 + commonEventManager.createSubscriber(this.subscribeInfo, (err: Base.BusinessError, data: commonEventManager.CommonEventSubscriber) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to create subscriber. Code is ${err.code}, message is ${err.message}`); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in creating subscriber.'); + this.subscriber = data; + + // 订阅公共事件回调 + if (this.subscriber !== null) { + commonEventManager.subscribe(this.subscriber, (err: Base.BusinessError, data: commonEventManager.CommonEventData) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to subscribe common event. Code is ${err.code}, message is ${err.message}`); + return; + } + promptAction.showToast({ + message: JSON.stringify(data) + }); + hilog.info(DOMAIN_NUMBER, TAG, `Receive CommonEventData = ` + JSON.stringify(data)); + }) + if (this.ifSendStickyKey === false) { + promptAction.showToast({ + message: $r('app.string.subscribe_success_toast') + }); + } + } else { + hilog.error(DOMAIN_NUMBER, TAG, `Need create subscriber`); + } + }) + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + + ListItem() { + Row() { + Row(){ + Text($r('app.string.unsubscribe_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // subscriber为订阅事件时创建的订阅者对象 + if (this.subscriber !== null) { + commonEventManager.unsubscribe(this.subscriber, (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, `UnsubscribeCallBack err = ${JSON.stringify(err)}`); + } else { + promptAction.showToast({ + message: $r('app.string.unsubscribe_success_toast') + }); + hilog.info(DOMAIN_NUMBER, TAG, `Unsubscribe success`); + this.subscriber = null; + } + }) + } else { + promptAction.showToast({ + message: $r('app.string.unsubscribe_failed_toast') + }); + } + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.publish_noinfo_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 发布公共事件 + commonEventManager.publish('usual.event.SCREEN_OFF', (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, `PublishCallBack err = ${JSON.stringify(err)}`); + } else { + if (this.subscriber === null) { + promptAction.showToast({ + message: $r('app.string.publish_noinfo_success_toast') + }); + } + hilog.info(DOMAIN_NUMBER, TAG, `Publish success`); + } + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.publish_haveinfo_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 公共事件相关信息 + let options: commonEventManager.CommonEventPublishData = { + code: 1, // 公共事件的初始代码 + data: 'initial data', // 公共事件的初始数据 + }; + + // 发布公共事件 + commonEventManager.publish('usual.event.SCREEN_OFF', options, (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, 'PublishCallBack err = ' + JSON.stringify(err)); + } else { + if (this.subscriber === null) { + promptAction.showToast({ + message: $r('app.string.publish_haveinfo_success_toast') + }); + } + hilog.info(DOMAIN_NUMBER, TAG, 'Publish success'); + } + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.publish_sticky_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 公共事件相关信息 + let options: commonEventManager.CommonEventPublishData = { + code: 1, // 公共事件的初始代码 + data: 'initial Sticky data', // 公共事件的初始数据 + isSticky: true + }; + + // 发布公共事件 + commonEventManager.publish('usual.event.SCREEN_OFF', options, (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, 'PublishCallBack err=' + JSON.stringify(err)); + } else { + promptAction.showToast({ + message: $r('app.string.publish_sticky_success_toast') + }); + this.ifSendStickyKey = true; + hilog.info(DOMAIN_NUMBER, TAG, 'Publish success'); + } + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.remove_sticky_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + commonEventManager.removeStickyCommonEvent('usual.event.SCREEN_OFF', (err: Base.BusinessError) => { + // sticky_event粘性公共事件名 + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to remove sticky common event. Code is ${err.code}, message is ${err.message}`); + return; + } + promptAction.showToast({ + message: $r('app.string.remove_sticky_success_toast') + }); + this.ifSendStickyKey = false; + hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in removeing sticky event.`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } + } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageTaskManager.ets b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageTaskManager.ets index 81e0357faa..22327b239a 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageTaskManager.ets +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageTaskManager.ets @@ -1,462 +1,462 @@ -/* - * Copyright (c) 2023 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 missionManager from '@ohos.app.ability.missionManager'; -import { BusinessError } from '@ohos.base'; -import image from '@ohos.multimedia.image'; -import promptAction from '@ohos.promptAction'; -import hilog from '@ohos.hilog'; - -const DOMAIN_NUMBER: number = 0xFF00; -const TAG: string = 'TaskManager'; - -@Entry -@Component -struct PageTaskManager { - private listenerId: number = 0; - private missionId: number = 0; - private listener: missionManager.MissionListener = { - // 任务创建 - onMissionCreated: (mission: number) => { - hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionCreated-------'); - }, - // 任务销毁 - onMissionDestroyed: (mission: number) => { - hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionDestroyed-------'); - }, - // 任务快照变化 - onMissionSnapshotChanged: (mission: number) => { - hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionSnapshotChanged-------'); - }, - // 任务被移动到前台 - onMissionMovedToFront: (mission: number) => { - hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionMovedToFront-------'); - }, - // 任务图标变化 - onMissionIconUpdated: (mission: number, icon: image.PixelMap) => { - hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionIconUpdated-------'); - }, - // 任务名称变化 - onMissionLabelUpdated: (mission: number) => { - hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionLabelUpdated-------'); - }, - // 任务实例被关闭 - onMissionClosed: (mission: number) => { - hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionClosed-------'); - } - }; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.taskmanager_button')) - .fontSize(24) - .fontWeight(FontWeight.Bold) - .textAlign(TextAlign.Start) - .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row(){ - Text($r('app.string.register_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - - } - .onClick(() => { - // 1.注册任务变化通知 - this.listenerId = missionManager.on('mission', this.listener); - promptAction.showToast({ - message: $r('app.string.register_success_toast') - }); - hilog.info(DOMAIN_NUMBER, TAG, `missionManager.on success, listenerId = ${this.listenerId}`); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - - ListItem() { - Row() { - Row(){ - Text($r('app.string.obtain_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 2.获取系统最近20个任务 - missionManager.getMissionInfos('', 20, (error: BusinessError, missions: Array) => { - hilog.info(DOMAIN_NUMBER, TAG, 'getMissionInfos is called, error = ' + JSON.stringify(error)); - hilog.info(DOMAIN_NUMBER, TAG, 'size = ' + missions.length); - hilog.info(DOMAIN_NUMBER, TAG, 'missions = ' + JSON.stringify(missions)); - - // 判断系统最近任务中是否包含etsclock - for (let i = 0;i < missions.length; i++) { - if (missions[i].want.bundleName === 'ohos.samples.etsclock') { - promptAction.showToast({ - message: $r('app.string.obtain_success_toast') - }); - hilog.info(DOMAIN_NUMBER, TAG, `getMissionInfos.find etsclock, missionId = ${missions[i].missionId}`); - this.missionId = missions[i].missionId; - return; - } - } - promptAction.showToast({ - message: $r('app.string.obtain_failed_toast') - }); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.obtain_one_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 3.获取单个任务的详细信息() - missionManager.getMissionInfo('', this.missionId).then((data: missionManager.MissionInfo) => { - promptAction.showToast({ - message: JSON.stringify(data.want.bundleName) - }); - hilog.info(DOMAIN_NUMBER, TAG, `getMissionInfo successfully. Data: ${JSON.stringify(data)}`); - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `getMissionInfo failed. Cause: ${error.message}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.obtain_snapshot_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - - } - .onClick(() => { - // 4.获取任务快照 - missionManager.getMissionSnapShot('', this.missionId, (error: BusinessError, snapshot: missionManager.MissionSnapshot) => { - if (error === null) { - promptAction.showToast({ - message: $r('app.string.obtain_snapshot_success_toast') - }); - } - hilog.info(DOMAIN_NUMBER, TAG, 'getMissionSnapShot is called, error = ' + JSON.stringify(error)); - hilog.info(DOMAIN_NUMBER, TAG, 'bundleName = ' + snapshot.ability.bundleName); - }) - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - - ListItem() { - Row() { - Row(){ - Text($r('app.string.obtain_low_snapshot_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 5.获取低分辨任务快照 - missionManager.getLowResolutionMissionSnapShot('', this.missionId, (error: BusinessError, snapshot: missionManager.MissionSnapshot) => { - if (error === null) { - promptAction.showToast({ - message: $r('app.string.obtain_low_snapshot_success_toast') - }); - } - hilog.info(DOMAIN_NUMBER, TAG, 'getLowResolutionMissionSnapShot is called, error = ' + JSON.stringify(error)); - hilog.info(DOMAIN_NUMBER, TAG, 'bundleName = ' + snapshot.ability.bundleName); - }) - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.lock_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 6-1 加锁任务 - missionManager.lockMission(this.missionId).then(() => { - promptAction.showToast({ - message: $r('app.string.lock_success_toast') - }); - hilog.info(DOMAIN_NUMBER, TAG, 'lockMission is called '); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.unlock_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - - } - .onClick(() => { - // 6-2 解锁任务 - missionManager.unlockMission(this.missionId).then(() => { - promptAction.showToast({ - message: $r('app.string.unlock_success_toast') - }); - hilog.info(DOMAIN_NUMBER, TAG, 'unlockMission is called '); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - - ListItem() { - Row() { - Row(){ - Text($r('app.string.front_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 7.把任务切到前台 - missionManager.moveMissionToFront(this.missionId).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'moveMissionToFront is called '); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.delete_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 8.删除单个任务 - missionManager.clearMission(this.missionId).then(() => { - promptAction.showToast({ - message: $r('app.string.delete_success_toast') - }); - hilog.info(DOMAIN_NUMBER, TAG, 'clearMission is called '); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.delete_all_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 9.删除全部任务 - missionManager.clearAllMissions().catch((err: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, `${err.code}`); - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row(){ - Text($r('app.string.unregister_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .width(232) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 10.解注册任务变化通知 - missionManager.off('mission', this.listenerId, (error: BusinessError) => { - if (error === null) { - promptAction.showToast({ - message: $r('app.string.unregister_success_toast') - }); - } - hilog.info(DOMAIN_NUMBER, TAG, 'unregisterMissionListener'); - }) - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - } - .height('92%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 missionManager from '@ohos.app.ability.missionManager'; +import { BusinessError } from '@ohos.base'; +import image from '@ohos.multimedia.image'; +import promptAction from '@ohos.promptAction'; +import hilog from '@ohos.hilog'; + +const DOMAIN_NUMBER: number = 0xFF00; +const TAG: string = 'TaskManager'; + +@Entry +@Component +struct PageTaskManager { + private listenerId: number = 0; + private missionId: number = 0; + private listener: missionManager.MissionListener = { + // 任务创建 + onMissionCreated: (mission: number) => { + hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionCreated-------'); + }, + // 任务销毁 + onMissionDestroyed: (mission: number) => { + hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionDestroyed-------'); + }, + // 任务快照变化 + onMissionSnapshotChanged: (mission: number) => { + hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionSnapshotChanged-------'); + }, + // 任务被移动到前台 + onMissionMovedToFront: (mission: number) => { + hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionMovedToFront-------'); + }, + // 任务图标变化 + onMissionIconUpdated: (mission: number, icon: image.PixelMap) => { + hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionIconUpdated-------'); + }, + // 任务名称变化 + onMissionLabelUpdated: (mission: number) => { + hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionLabelUpdated-------'); + }, + // 任务实例被关闭 + onMissionClosed: (mission: number) => { + hilog.info(DOMAIN_NUMBER, TAG, '--------onMissionClosed-------'); + } + }; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.taskmanager_button')) + .fontSize(24) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + .margin({ top: 12 , bottom: 11 , right: 24 , left: 24}) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row(){ + Text($r('app.string.register_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + + } + .onClick(() => { + // 1.注册任务变化通知 + this.listenerId = missionManager.on('mission', this.listener); + promptAction.showToast({ + message: $r('app.string.register_success_toast') + }); + hilog.info(DOMAIN_NUMBER, TAG, `missionManager.on success, listenerId = ${this.listenerId}`); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + + ListItem() { + Row() { + Row(){ + Text($r('app.string.obtain_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 2.获取系统最近20个任务 + missionManager.getMissionInfos('', 20, (error: BusinessError, missions: Array) => { + hilog.info(DOMAIN_NUMBER, TAG, 'getMissionInfos is called, error = ' + JSON.stringify(error)); + hilog.info(DOMAIN_NUMBER, TAG, 'size = ' + missions.length); + hilog.info(DOMAIN_NUMBER, TAG, 'missions = ' + JSON.stringify(missions)); + + // 判断系统最近任务中是否包含etsclock + for (let i = 0;i < missions.length; i++) { + if (missions[i].want.bundleName === 'ohos.samples.etsclock') { + promptAction.showToast({ + message: $r('app.string.obtain_success_toast') + }); + hilog.info(DOMAIN_NUMBER, TAG, `getMissionInfos.find etsclock, missionId = ${missions[i].missionId}`); + this.missionId = missions[i].missionId; + return; + } + } + promptAction.showToast({ + message: $r('app.string.obtain_failed_toast') + }); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.obtain_one_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 3.获取单个任务的详细信息() + missionManager.getMissionInfo('', this.missionId).then((data: missionManager.MissionInfo) => { + promptAction.showToast({ + message: JSON.stringify(data.want.bundleName) + }); + hilog.info(DOMAIN_NUMBER, TAG, `getMissionInfo successfully. Data: ${JSON.stringify(data)}`); + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `getMissionInfo failed. Cause: ${error.message}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.obtain_snapshot_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + + } + .onClick(() => { + // 4.获取任务快照 + missionManager.getMissionSnapShot('', this.missionId, (error: BusinessError, snapshot: missionManager.MissionSnapshot) => { + if (error === null) { + promptAction.showToast({ + message: $r('app.string.obtain_snapshot_success_toast') + }); + } + hilog.info(DOMAIN_NUMBER, TAG, 'getMissionSnapShot is called, error = ' + JSON.stringify(error)); + hilog.info(DOMAIN_NUMBER, TAG, 'bundleName = ' + snapshot.ability.bundleName); + }) + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + + ListItem() { + Row() { + Row(){ + Text($r('app.string.obtain_low_snapshot_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 5.获取低分辨任务快照 + missionManager.getLowResolutionMissionSnapShot('', this.missionId, (error: BusinessError, snapshot: missionManager.MissionSnapshot) => { + if (error === null) { + promptAction.showToast({ + message: $r('app.string.obtain_low_snapshot_success_toast') + }); + } + hilog.info(DOMAIN_NUMBER, TAG, 'getLowResolutionMissionSnapShot is called, error = ' + JSON.stringify(error)); + hilog.info(DOMAIN_NUMBER, TAG, 'bundleName = ' + snapshot.ability.bundleName); + }) + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.lock_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 6-1 加锁任务 + missionManager.lockMission(this.missionId).then(() => { + promptAction.showToast({ + message: $r('app.string.lock_success_toast') + }); + hilog.info(DOMAIN_NUMBER, TAG, 'lockMission is called '); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.unlock_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + + } + .onClick(() => { + // 6-2 解锁任务 + missionManager.unlockMission(this.missionId).then(() => { + promptAction.showToast({ + message: $r('app.string.unlock_success_toast') + }); + hilog.info(DOMAIN_NUMBER, TAG, 'unlockMission is called '); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + + ListItem() { + Row() { + Row(){ + Text($r('app.string.front_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 7.把任务切到前台 + missionManager.moveMissionToFront(this.missionId).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'moveMissionToFront is called '); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.delete_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 8.删除单个任务 + missionManager.clearMission(this.missionId).then(() => { + promptAction.showToast({ + message: $r('app.string.delete_success_toast') + }); + hilog.info(DOMAIN_NUMBER, TAG, 'clearMission is called '); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.delete_all_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 9.删除全部任务 + missionManager.clearAllMissions().catch((err: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, `${err.code}`); + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row(){ + Text($r('app.string.unregister_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .width(232) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 10.解注册任务变化通知 + missionManager.off('mission', this.listenerId, (error: BusinessError) => { + if (error === null) { + promptAction.showToast({ + message: $r('app.string.unregister_success_toast') + }); + } + hilog.info(DOMAIN_NUMBER, TAG, 'unregisterMissionListener'); + }) + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + } + .height('92%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageThreadModel.ets b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageThreadModel.ets index 835fa534e6..cd88089ee4 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageThreadModel.ets +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/pages/PageThreadModel.ets @@ -1,175 +1,175 @@ -/* - * Copyright (c) 2023 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 emitter from '@ohos.events.emitter'; -import promptAction from '@ohos.promptAction'; -import worker from '@ohos.worker'; -import hilog from '@ohos.hilog'; - -const DOMAIN_NUMBER: number = 0xFF00; -const TAG: string = 'ThreadModel'; - -@Entry -@Component -struct PageThreadModel { - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.thread_button')) - .fontSize(24) - .fontWeight(FontWeight.Bold) - .textAlign(TextAlign.Start) - .margin({ top: 12, bottom: 11, right: 24, left: 24 }) - } - } - .width('100%') - .height(56) - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - - List({ initialIndex: 0 }) { - ListItem() { - Row() { - Row() { - Text($r('app.string.emitter_subscribe_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - - } - .onClick(() => { - // 定义一个eventId为1的事件 - let event: emitter.InnerEvent = { - eventId: 1 - }; - - // 收到eventId为1的事件后执行该回调 - let callback = (eventData: emitter.EventData): void => { - promptAction.showToast({ - message: JSON.stringify(eventData) - }); - hilog.info(DOMAIN_NUMBER, TAG, 'event callback:' + JSON.stringify(eventData)); - }; - - // 订阅eventId为1的事件 - emitter.on(event, callback); - promptAction.showToast({ - message: $r('app.string.emitter_subscribe_success_toast') - }); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 8, right: 12, left: 12 }) - - - ListItem() { - Row() { - Row() { - Text($r('app.string.emitter_sending_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - // 定义一个eventId为1的事件,事件优先级为Low - let event: emitter.InnerEvent = { - eventId: 1, - priority: emitter.EventPriority.LOW - }; - - let eventData: emitter.EventData = { - data: { - content: 'c', - id: 1, - isEmpty: false - } - }; - - // 发送eventId为1的事件,事件内容为eventData - emitter.emit(event, eventData); - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Row() { - Row() { - Text($r('app.string.worker_button')) - .textAlign(TextAlign.Start) - .fontWeight(FontWeight.Medium) - .margin({ top: 13, bottom: 13, left: 0, right: 8 }) - .fontSize(16) - .height(22) - .fontColor($r('app.color.text_color')) - } - .height(48) - .width('100%') - .borderRadius(24) - .margin({ top: 4, bottom: 4, left: 12, right: 84 }) - } - .onClick(() => { - let wk = new worker.ThreadWorker('entry/ets/workers/Worker.ts'); - // 发送消息到worker线程 - wk.postMessage('message from main thread.'); - - // 处理来自worker线程的消息 - wk.onmessage = (message): void => { - promptAction.showToast({ - message: JSON.stringify(message) - }); - hilog.info(DOMAIN_NUMBER, TAG, 'message from worker: ' + JSON.stringify(message)); - - // 根据业务按需停止worker线程 - wk.terminate(); - } - }) - } - .height(56) - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - } - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .margin({ top: 8 }) - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2023 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 emitter from '@ohos.events.emitter'; +import promptAction from '@ohos.promptAction'; +import worker from '@ohos.worker'; +import hilog from '@ohos.hilog'; + +const DOMAIN_NUMBER: number = 0xFF00; +const TAG: string = 'ThreadModel'; + +@Entry +@Component +struct PageThreadModel { + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.thread_button')) + .fontSize(24) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + .margin({ top: 12, bottom: 11, right: 24, left: 24 }) + } + } + .width('100%') + .height(56) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + + List({ initialIndex: 0 }) { + ListItem() { + Row() { + Row() { + Text($r('app.string.emitter_subscribe_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + + } + .onClick(() => { + // 定义一个eventId为1的事件 + let event: emitter.InnerEvent = { + eventId: 1 + }; + + // 收到eventId为1的事件后执行该回调 + let callback = (eventData: emitter.EventData): void => { + promptAction.showToast({ + message: JSON.stringify(eventData) + }); + hilog.info(DOMAIN_NUMBER, TAG, 'event callback:' + JSON.stringify(eventData)); + }; + + // 订阅eventId为1的事件 + emitter.on(event, callback); + promptAction.showToast({ + message: $r('app.string.emitter_subscribe_success_toast') + }); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 8, right: 12, left: 12 }) + + + ListItem() { + Row() { + Row() { + Text($r('app.string.emitter_sending_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + // 定义一个eventId为1的事件,事件优先级为Low + let event: emitter.InnerEvent = { + eventId: 1, + priority: emitter.EventPriority.LOW + }; + + let eventData: emitter.EventData = { + data: { + content: 'c', + id: 1, + isEmpty: false + } + }; + + // 发送eventId为1的事件,事件内容为eventData + emitter.emit(event, eventData); + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Row() { + Row() { + Text($r('app.string.worker_button')) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Medium) + .margin({ top: 13, bottom: 13, left: 0, right: 8 }) + .fontSize(16) + .height(22) + .fontColor($r('app.color.text_color')) + } + .height(48) + .width('100%') + .borderRadius(24) + .margin({ top: 4, bottom: 4, left: 12, right: 84 }) + } + .onClick(() => { + let wk = new worker.ThreadWorker('entry/ets/workers/Worker.ts'); + // 发送消息到worker线程 + wk.postMessage('message from main thread.'); + + // 处理来自worker线程的消息 + wk.onmessage = (message): void => { + promptAction.showToast({ + message: JSON.stringify(message) + }); + hilog.info(DOMAIN_NUMBER, TAG, 'message from worker: ' + JSON.stringify(message)); + + // 根据业务按需停止worker线程 + wk.terminate(); + } + }) + } + .height(56) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + } + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .margin({ top: 8 }) + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/workers/Worker.ts b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/workers/Worker.ts index 9506a11e71..b3132c3eb6 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/workers/Worker.ts +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/ets/workers/Worker.ts @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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 worker from '@ohos.worker'; -import hilog from '@ohos.hilog'; - -let parent = worker.workerPort; -const DOMAIN_NUMBER: number = 0xFF00; - -// 处理来自主线程的消息 -parent.onmessage = (message): void => { - hilog.info(DOMAIN_NUMBER, 'Worker', 'onmessage: ' + JSON.stringify(message)); - // 发送消息到主线程 - parent.postMessage('message from worker thread.'); +/* + * Copyright (c) 2023 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 worker from '@ohos.worker'; +import hilog from '@ohos.hilog'; + +let parent = worker.workerPort; +const DOMAIN_NUMBER: number = 0xFF00; + +// 处理来自主线程的消息 +parent.onmessage = (message): void => { + hilog.info(DOMAIN_NUMBER, 'Worker', 'onmessage: ' + JSON.stringify(message)); + // 发送消息到主线程 + parent.postMessage('message from worker thread.'); }; \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/module.json5 b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/module.json5 index ea18183df8..e4c6026025 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/module.json5 +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/module.json5 @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2023 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "StaticSubscriber", - "srcEntry": "./ets/staticsubscriber/StaticSubscriber.ts", - "description": "$string:StaticSubscriber_desc", - "icon": "$media:icon", - "label": "$string:StaticSubscriber_label", - "type": "staticSubscriber", - "metadata": [ - { - "name": "ohos.extension.staticSubscriber", - "resource": "$profile:staticsubscriber" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.COMMONEVENT_STICKY" - }, - { - "name": "ohos.permission.MANAGE_MISSIONS" - }, - { - "name": "ohos.permission.NOTIFICATION_CONTROLLER" - } - ] - } +/* + * Copyright (c) 2023 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "StaticSubscriber", + "srcEntry": "./ets/staticsubscriber/StaticSubscriber.ts", + "description": "$string:StaticSubscriber_desc", + "icon": "$media:icon", + "label": "$string:StaticSubscriber_label", + "type": "staticSubscriber", + "metadata": [ + { + "name": "ohos.extension.staticSubscriber", + "resource": "$profile:staticsubscriber" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.COMMONEVENT_STICKY" + }, + { + "name": "ohos.permission.MANAGE_MISSIONS" + }, + { + "name": "ohos.permission.NOTIFICATION_CONTROLLER" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/resources/base/element/color.json b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/resources/base/element/color.json index e1691a2f31..59da6fd48a 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/resources/base/element/color.json @@ -1,20 +1,20 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "background", - "value": "#f1f3f5" - }, - { - "name": "backGrounding", - "value": "#f1f3f5" - }, - { - "name": "text_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "background", + "value": "#f1f3f5" + }, + { + "name": "backGrounding", + "value": "#f1f3f5" + }, + { + "name": "text_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/resources/base/profile/staticsubscriber.json b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/resources/base/profile/staticsubscriber.json index 56d7385453..ed7f558865 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/resources/base/profile/staticsubscriber.json +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/main/resources/base/profile/staticsubscriber.json @@ -1,11 +1,11 @@ -{ - "commonEvents": [ - { - "name": "StaticSubscriber", - "permission": "", - "events": [ - "usual.event.AIRPLANE_MODE" - ] - } - ] +{ + "commonEvents": [ + { + "name": "StaticSubscriber", + "permission": "", + "events": [ + "usual.event.AIRPLANE_MODE" + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/ohosTest/module.json5 b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/ohosTest/module.json5 index 931a761b1e..520003bf20 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ApplicationModels/StageProcessThread/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/hvigor/hvigor-config.json5 b/code/DocsSample/ApplicationModels/StageProcessThread/hvigor/hvigor-config.json5 index 7fcecec159..dba571014f 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ApplicationModels/StageProcessThread/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageProcessThread/oh-package.json5 b/code/DocsSample/ApplicationModels/StageProcessThread/oh-package.json5 index afa4c1e419..85da103065 100644 --- a/code/DocsSample/ApplicationModels/StageProcessThread/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/StageProcessThread/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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. - */ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "stageprocessthread", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "stageprocessthread", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/AppScope/app.json5 b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/AppScope/app.json5 index d5fac8aeb4..5fd2b05487 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/AppScope/app.json5 +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.stageservicewidgetcards", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.stageservicewidgetcards", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/AppScope/resources/base/element/string.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/AppScope/resources/base/element/string.json index e2c37fdcf2..db52f2f875 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "StageServiceWidgetCards" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "StageServiceWidgetCards" + } + ] +} diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/README_zh.md b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/README_zh.md index 1a7a0475b3..e100791e37 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/README_zh.md +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/README_zh.md @@ -1,248 +1,248 @@ -# 服务卡片开发指导(Stage模型) - -### 介绍 - -本示例展示了在一个Stage模型中,开发基于ArkTS UI及JS UI的卡片指导。 - -本示例参考[应用模型](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/application-models)。 - -### 效果预览 - -| 开发卡片事件 | 卡片数据交互 | -| ------------------------------------------ | ---------------------------------------------- | -| | | - -#### 使用说明 - -**开发基于ArkTS UI的卡片** - -1.开发卡片页面 - -1)长按应用图标并点击<服务卡片>; - -2)选择卡片属性动画示例并点击添加到桌面; - -3)点击“改变旋转角度”按钮,按钮产生旋转动画效果; - -4)回到主页,长按应用图标并点击<服务卡片>,选择卡片使用自定义绘制能力示例并点击添加到桌面; - -5)示例代码实现了通过CanvasRenderingContext2D对象在画布的中心绘制一个笑脸。 - -2.开发卡片事件 - -1)回到主页,长按应用图标并点击<服务卡片>,选择卡片使用router事件跳转到指定UIAbility示例并点击添加到桌面; - -2)点击“功能A”按钮,在UIAbility中接收router事件并获取参数,根据传递的params不同,选择拉起功能A页面; - -3)点击“功能B”按钮,在UIAbility中接收router事件并获取参数,根据传递的params不同,选择拉起功能B页面; - -4)回到主页,长按应用图标并点击<服务卡片>,选择通过message事件刷新卡片示例并点击添加到桌面; - -5)在卡片页面点击“Update”按钮,观察卡片页面,其中title信息更新为'Title Update.'文字信息更新为'Description update success.'; - -6)回到主页,长按应用图标并点击<服务卡片>,选择通过router事件刷新卡片内容示例并点击添加到桌面; - -7)点击“router事件跳转”按钮;点击Home键返回桌面,查看卡片内容从“init”更新为“RouterFromCard”:UIAbility;当按home键的方式回到卡片界面点击按钮时,内容则更新为“RouterFromCard”:onNewWant UIAbility.; - -8)回到主页,长按应用图标并点击<服务卡片>,选择通过call事件刷新卡片内容示例并点击添加到桌面; - -9)点击“callee拉至后台”按钮,查看卡片文字,内容从“init”更新为“CallFrom”; - -10)回到主页,长按应用图标并点击<服务卡片>,选择使用call事件拉起指定UIAbility到后台卡片示例并点击添加到桌面; - -11)先后点击“功能A”,“功能B”按钮,先后分别后台打印FunACall param及FunBCall param信息; - -3.卡片数据交互 - -1)回到主页,长按应用图标并点击<服务卡片>,选择卡片定时刷新示例并点击添加到桌面; - -2)等待1小时后观察卡片显示,标题从‘Title default’更新为'Title Update.'文字从‘定时刷新’更新为'Description update success.'; - -3)回到主页,长按应用图标并点击<服务卡片>,选择卡片定点刷新示例并点击添加到桌面; - -4)等待到指定时间10:30后观察卡片显示,标题从‘Title default’更新为'Title Update.'文字从‘定点刷新’更新为'Description update success.' - -5)回到主页,长按应用图标并点击<服务卡片>,选择固定时间后刷新示例并点击添加到桌面; - -6)点击“Update”按钮,等待5min后观察卡片显示; - -7)标题从‘Title default’更新为'Title Update.'文字从‘Description default’更新为'Description update success.'; - -8)回到主页,长按应用图标并点击<服务卡片>,选择刷新本地图片和网络图片示例并点击添加到桌面; - -9)此时卡片上图片显示默认图片,点击添加到桌面。此时显示为本地图片; - -10)点击“刷新”按钮 图片更新为网络下载图片; - -11)回到主页,长按应用图标并点击<服务卡片>,选择根据卡片状态刷新不同内容示例并点击添加到桌面; - -12)勾选“状态A”,等待30min后观察卡片显示,卡片中只更新状态A文字“待刷新”为“AAA”; - -13)勾选“状态B”,等待30min后观察卡片显示,卡片中只更新状态B文字“待刷新”为“BBB”; - -14)回到主页,安装<共享数据>应用并点击打开,页面显示有“更新过程数据”,“更新持久化数据”按钮; - -15)长按应用图标并点击<服务卡片>,选择<卡片代理刷新(过程数据)>示例;添加后观察卡片显示,卡片中央内容显示“加载中”; - -16)返回“代理刷新卡片”应用主页面,点击<更新过程数据>,弹出“更新过程数据成功”提示。点击Home键返回桌面,观察卡片显示。卡片中央内容刷新,从“加载中”更新为”Qing“,且卡片提供方应用没有被拉起; - -17)长按应用图标并点击<服务卡片>,选择<卡片代理刷新(持久化数据)>示例;添加后观察卡片显示,卡片中央内容显示“a”; - -18)返回“共享数据”应用主页面,点击<更新持久化数据>,弹出“更新持久化数据成功”提示。点击Home键返回桌面,观察卡片显示。卡片中央内容刷新,从“a”更新为”snow“,该过程卡片提供方应用没有被拉起; - -19)使用方刷新卡片内容:已确认无法在卡片内主动更新卡片,故该功能无法实现。 - -**开发基于JS UI的卡片** - -1)回到主页,长按应用图标并点击<服务卡片>,选择开发基于JS UI的卡片示例并点击添加到桌面; - -2)等待30min后观察卡片显示,title从“titleOnCreate”刷新为“titleOnUpdate”,文字内容从“detailOnCreat”刷新为“detailOnUpdate”; - -### 工程目录 -``` -entry/src/main/ets/ -├── attranimation -│   └── pages -│   └── AttrAnimationCard.ets //属性动画示例 -├── customcanvasdrawing -│   └── pages -│   └── CustomCanvasDrawingCard.ets //卡片使用自定义绘制能力示例 -├── entryability -│   └── EntryAbility.ts //router事件跳转到指定UIAbility逻辑 -├── entryformability -│   └── EntryFormAbility.ts //卡片业务逻辑模块,提供卡片创建、销毁、刷新等生命周期回调。 -├── funpages -│   ├── FunA.ets //router调起ability页面A -│   └── FunB.ets //router调起ability页面B -├── jscardentryability -│   └── JsCardEntryAbility.ts //JS卡片UIAbility实例 -├── jscardformability -│   └── JsCardFormAbility.ts //JS卡片业务逻辑模块 -├── nextrefreshtime -│   └── pages -│   └── NextRefreshTimeCard.ets //固定时间后刷新卡片页面 -├── pages -│   └── Index.ets //应用的默认页面 -├── persistentdataformability -│   └── PersistentDataFormAbility.ts //持久化数据下代理刷新卡片业务逻辑模块 -├── processdataentryability -│   └── ProcessDataFormAbility.ts //基于过程数据的卡片代理刷新订阅逻辑 -├── scheduledupdatetime -│   └── pages -│   └── ScheduledUpdateTimeCard.ets //定点刷新卡片页面 -├── updatebymessage -│   └── pages -│   └── UpdateByMessageCard.ets //message事件刷新卡片内容页面 -├── updatebystatusformability -│   └── UpdateByStatusFormAbility.ts //根据卡片状态刷新不同内容业务逻辑模块 -├── updatebytimeformability -│   └── UpdateByTimeFormAbility.ts //定时刷新卡片业务逻辑模块 -├── updateduration -│   └── pages -│   └── UpdateDurationCard.ets //定时刷新卡片页面 -├── wgtimgupdateentryformability -│   └── WgtImgUpdateEntryFormAbility.ts //本地图片和网络图片更新逻辑模块 -├── widgetcalleeentryability -│   └── WidgetCalleeEntryAbility.ts //通过call事件刷新卡片内容订阅逻辑 -├── widgetcalleeformability -│   └── WidgetCalleeFormAbility.ts //通过router或call事件刷新卡片内容页面更新逻辑 -├── widgeteventcall -│   └── pages -│   └── WidgetEventCallCard.ets //使用call事件拉起指定UIAbility到后台卡片页面 -├── widgeteventcallentryability -│   └── WidgetEventCallEntryAbility.ts //使用call事件拉起指定UIAbility到后台订阅逻辑 -├── widgetevententryability -│   └── WidgetEventRouterEntryAbility.ts //通过router事件刷新卡片内容逻辑入口 -├── widgeteventrouter -│   └── pages -│   └── WidgetEventRouterCard.ets //使用router事件跳转到指定UIAbility示例页面 -├── widgetimageupdate -│   └── pages -│   └── WidgetImageUpdateCard.ets //本地图片和网络图片更新示例页面 -├── widgetpersistentdata -│   └── pages -│   └── WidgetPersistentDataCard.ets //持久化数据下卡片代理刷新示例页面 -├── widgetprocessdata -│   └── pages -│   └── WidgetProcessDataCard.ets //基于过程数据的卡片代理刷新示例页面 -├── widgetupdatebystatus -│   └── pages -│   └── WidgetUpdateByStatusCard.ets //根据卡片状态刷新不同内容示例页面 -├── widgetupdatecall -│   └── pages -│   └── WidgetUpdateCallCard.ets //通过call事件刷新卡片内容示例页面 -└── widgetupdaterouter - └── pages - └── WidgetUpdateRouterCard.ets //通过router事件刷新卡片内容示例页面 -``` -### 具体实现 - -* 本示例分为基于ArkTS UI的卡片,基于JS UI的卡片两部分。其中ArkTS UI卡片下分为卡片页面,卡片事件,卡片数据交互三部分。 - * 开发卡片页面: - - * ArkTS卡片具备JS卡片的全量能力,并且新增了动效能力和自定义绘制的能力,支持声明式范式的部分组件、事件、动效、数据管理、状态管理能力。 - - * 示例分别展示了animation动效及自定义绘制的能力。 - - * 开发卡片事件: - - * 针对动态卡片,ArkTS卡片中提供了postCardAction()接口用于卡片内部和提供方应用间的交互,当前支持router、message和call三种类型的事件,仅在卡片中可以调用。 - * 接口定义:postCardAction(component: Object, action: Object): void - - * 卡片数据交互: - - * ArkTS卡片框架提供了updateForm()接口和requestForm()接口主动触发卡片的页面刷新,通过[LocalStorageProp](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/state-management/arkts-localstorage.md#localstorageprop)确认需要刷新的卡片数据。 - * 介绍了按时间刷新方式(通过form_config.json配置文件的updateDuration字段中进行设置),代理刷新,刷新网络数据等能力。 - - -### 相关权限 - -[ohos.permission.KEEP_BACKGROUND_RUNNING](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionkeep_background_running) - -[ohos.permission.INTERNET](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) - -[ohos.permission.GET_BUNDLE_INFO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionget_bundle_info) - -[ohos.permission.START_ABILITIES_FROM_BACKGROUND](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionstart_abilities_from_background) - -### 依赖 - -1.本示例依赖共享数据的更新,由另一应用<共享数据>完成。测试代理刷新卡片功能时需要优先安装该应用。 - -- `app_signature`字段配置为应用的指纹信息,指纹信息的配置请参见[应用特权配置指南](https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md#install_list_capabilityjson中配置)。 - - ``` - [ - ... - { - "signingConfigs": ["****"], // 指纹信息 - } - ] - ``` - - -### 约束与限制 - -1. 本示例支持标准系统上运行,支持设备:RK3568; - -2. 本示例支持API14版本SDK,版本号:5.0.2.57; - -3. 本示例已支持使DevEco Studio 5.0.1 Release (构建版本:5.0.5.306,构建 2024年12月12日)编译运行; - -4. 高等级APL特殊签名说明:无; - - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ApplicationModels/StageServiceWidgetCards/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` - - - +# 服务卡片开发指导(Stage模型) + +### 介绍 + +本示例展示了在一个Stage模型中,开发基于ArkTS UI及JS UI的卡片指导。 + +本示例参考[应用模型](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/application-models)。 + +### 效果预览 + +| 开发卡片事件 | 卡片数据交互 | +| ------------------------------------------ | ---------------------------------------------- | +| | | + +#### 使用说明 + +**开发基于ArkTS UI的卡片** + +1.开发卡片页面 + +1)长按应用图标并点击<服务卡片>; + +2)选择卡片属性动画示例并点击添加到桌面; + +3)点击“改变旋转角度”按钮,按钮产生旋转动画效果; + +4)回到主页,长按应用图标并点击<服务卡片>,选择卡片使用自定义绘制能力示例并点击添加到桌面; + +5)示例代码实现了通过CanvasRenderingContext2D对象在画布的中心绘制一个笑脸。 + +2.开发卡片事件 + +1)回到主页,长按应用图标并点击<服务卡片>,选择卡片使用router事件跳转到指定UIAbility示例并点击添加到桌面; + +2)点击“功能A”按钮,在UIAbility中接收router事件并获取参数,根据传递的params不同,选择拉起功能A页面; + +3)点击“功能B”按钮,在UIAbility中接收router事件并获取参数,根据传递的params不同,选择拉起功能B页面; + +4)回到主页,长按应用图标并点击<服务卡片>,选择通过message事件刷新卡片示例并点击添加到桌面; + +5)在卡片页面点击“Update”按钮,观察卡片页面,其中title信息更新为'Title Update.'文字信息更新为'Description update success.'; + +6)回到主页,长按应用图标并点击<服务卡片>,选择通过router事件刷新卡片内容示例并点击添加到桌面; + +7)点击“router事件跳转”按钮;点击Home键返回桌面,查看卡片内容从“init”更新为“RouterFromCard”:UIAbility;当按home键的方式回到卡片界面点击按钮时,内容则更新为“RouterFromCard”:onNewWant UIAbility.; + +8)回到主页,长按应用图标并点击<服务卡片>,选择通过call事件刷新卡片内容示例并点击添加到桌面; + +9)点击“callee拉至后台”按钮,查看卡片文字,内容从“init”更新为“CallFrom”; + +10)回到主页,长按应用图标并点击<服务卡片>,选择使用call事件拉起指定UIAbility到后台卡片示例并点击添加到桌面; + +11)先后点击“功能A”,“功能B”按钮,先后分别后台打印FunACall param及FunBCall param信息; + +3.卡片数据交互 + +1)回到主页,长按应用图标并点击<服务卡片>,选择卡片定时刷新示例并点击添加到桌面; + +2)等待1小时后观察卡片显示,标题从‘Title default’更新为'Title Update.'文字从‘定时刷新’更新为'Description update success.'; + +3)回到主页,长按应用图标并点击<服务卡片>,选择卡片定点刷新示例并点击添加到桌面; + +4)等待到指定时间10:30后观察卡片显示,标题从‘Title default’更新为'Title Update.'文字从‘定点刷新’更新为'Description update success.' + +5)回到主页,长按应用图标并点击<服务卡片>,选择固定时间后刷新示例并点击添加到桌面; + +6)点击“Update”按钮,等待5min后观察卡片显示; + +7)标题从‘Title default’更新为'Title Update.'文字从‘Description default’更新为'Description update success.'; + +8)回到主页,长按应用图标并点击<服务卡片>,选择刷新本地图片和网络图片示例并点击添加到桌面; + +9)此时卡片上图片显示默认图片,点击添加到桌面。此时显示为本地图片; + +10)点击“刷新”按钮 图片更新为网络下载图片; + +11)回到主页,长按应用图标并点击<服务卡片>,选择根据卡片状态刷新不同内容示例并点击添加到桌面; + +12)勾选“状态A”,等待30min后观察卡片显示,卡片中只更新状态A文字“待刷新”为“AAA”; + +13)勾选“状态B”,等待30min后观察卡片显示,卡片中只更新状态B文字“待刷新”为“BBB”; + +14)回到主页,安装<共享数据>应用并点击打开,页面显示有“更新过程数据”,“更新持久化数据”按钮; + +15)长按应用图标并点击<服务卡片>,选择<卡片代理刷新(过程数据)>示例;添加后观察卡片显示,卡片中央内容显示“加载中”; + +16)返回“代理刷新卡片”应用主页面,点击<更新过程数据>,弹出“更新过程数据成功”提示。点击Home键返回桌面,观察卡片显示。卡片中央内容刷新,从“加载中”更新为”Qing“,且卡片提供方应用没有被拉起; + +17)长按应用图标并点击<服务卡片>,选择<卡片代理刷新(持久化数据)>示例;添加后观察卡片显示,卡片中央内容显示“a”; + +18)返回“共享数据”应用主页面,点击<更新持久化数据>,弹出“更新持久化数据成功”提示。点击Home键返回桌面,观察卡片显示。卡片中央内容刷新,从“a”更新为”snow“,该过程卡片提供方应用没有被拉起; + +19)使用方刷新卡片内容:已确认无法在卡片内主动更新卡片,故该功能无法实现。 + +**开发基于JS UI的卡片** + +1)回到主页,长按应用图标并点击<服务卡片>,选择开发基于JS UI的卡片示例并点击添加到桌面; + +2)等待30min后观察卡片显示,title从“titleOnCreate”刷新为“titleOnUpdate”,文字内容从“detailOnCreat”刷新为“detailOnUpdate”; + +### 工程目录 +``` +entry/src/main/ets/ +├── attranimation +│   └── pages +│   └── AttrAnimationCard.ets //属性动画示例 +├── customcanvasdrawing +│   └── pages +│   └── CustomCanvasDrawingCard.ets //卡片使用自定义绘制能力示例 +├── entryability +│   └── EntryAbility.ts //router事件跳转到指定UIAbility逻辑 +├── entryformability +│   └── EntryFormAbility.ts //卡片业务逻辑模块,提供卡片创建、销毁、刷新等生命周期回调。 +├── funpages +│   ├── FunA.ets //router调起ability页面A +│   └── FunB.ets //router调起ability页面B +├── jscardentryability +│   └── JsCardEntryAbility.ts //JS卡片UIAbility实例 +├── jscardformability +│   └── JsCardFormAbility.ts //JS卡片业务逻辑模块 +├── nextrefreshtime +│   └── pages +│   └── NextRefreshTimeCard.ets //固定时间后刷新卡片页面 +├── pages +│   └── Index.ets //应用的默认页面 +├── persistentdataformability +│   └── PersistentDataFormAbility.ts //持久化数据下代理刷新卡片业务逻辑模块 +├── processdataentryability +│   └── ProcessDataFormAbility.ts //基于过程数据的卡片代理刷新订阅逻辑 +├── scheduledupdatetime +│   └── pages +│   └── ScheduledUpdateTimeCard.ets //定点刷新卡片页面 +├── updatebymessage +│   └── pages +│   └── UpdateByMessageCard.ets //message事件刷新卡片内容页面 +├── updatebystatusformability +│   └── UpdateByStatusFormAbility.ts //根据卡片状态刷新不同内容业务逻辑模块 +├── updatebytimeformability +│   └── UpdateByTimeFormAbility.ts //定时刷新卡片业务逻辑模块 +├── updateduration +│   └── pages +│   └── UpdateDurationCard.ets //定时刷新卡片页面 +├── wgtimgupdateentryformability +│   └── WgtImgUpdateEntryFormAbility.ts //本地图片和网络图片更新逻辑模块 +├── widgetcalleeentryability +│   └── WidgetCalleeEntryAbility.ts //通过call事件刷新卡片内容订阅逻辑 +├── widgetcalleeformability +│   └── WidgetCalleeFormAbility.ts //通过router或call事件刷新卡片内容页面更新逻辑 +├── widgeteventcall +│   └── pages +│   └── WidgetEventCallCard.ets //使用call事件拉起指定UIAbility到后台卡片页面 +├── widgeteventcallentryability +│   └── WidgetEventCallEntryAbility.ts //使用call事件拉起指定UIAbility到后台订阅逻辑 +├── widgetevententryability +│   └── WidgetEventRouterEntryAbility.ts //通过router事件刷新卡片内容逻辑入口 +├── widgeteventrouter +│   └── pages +│   └── WidgetEventRouterCard.ets //使用router事件跳转到指定UIAbility示例页面 +├── widgetimageupdate +│   └── pages +│   └── WidgetImageUpdateCard.ets //本地图片和网络图片更新示例页面 +├── widgetpersistentdata +│   └── pages +│   └── WidgetPersistentDataCard.ets //持久化数据下卡片代理刷新示例页面 +├── widgetprocessdata +│   └── pages +│   └── WidgetProcessDataCard.ets //基于过程数据的卡片代理刷新示例页面 +├── widgetupdatebystatus +│   └── pages +│   └── WidgetUpdateByStatusCard.ets //根据卡片状态刷新不同内容示例页面 +├── widgetupdatecall +│   └── pages +│   └── WidgetUpdateCallCard.ets //通过call事件刷新卡片内容示例页面 +└── widgetupdaterouter + └── pages + └── WidgetUpdateRouterCard.ets //通过router事件刷新卡片内容示例页面 +``` +### 具体实现 + +* 本示例分为基于ArkTS UI的卡片,基于JS UI的卡片两部分。其中ArkTS UI卡片下分为卡片页面,卡片事件,卡片数据交互三部分。 + * 开发卡片页面: + + * ArkTS卡片具备JS卡片的全量能力,并且新增了动效能力和自定义绘制的能力,支持声明式范式的部分组件、事件、动效、数据管理、状态管理能力。 + + * 示例分别展示了animation动效及自定义绘制的能力。 + + * 开发卡片事件: + + * 针对动态卡片,ArkTS卡片中提供了postCardAction()接口用于卡片内部和提供方应用间的交互,当前支持router、message和call三种类型的事件,仅在卡片中可以调用。 + * 接口定义:postCardAction(component: Object, action: Object): void + + * 卡片数据交互: + + * ArkTS卡片框架提供了updateForm()接口和requestForm()接口主动触发卡片的页面刷新,通过[LocalStorageProp](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/state-management/arkts-localstorage.md#localstorageprop)确认需要刷新的卡片数据。 + * 介绍了按时间刷新方式(通过form_config.json配置文件的updateDuration字段中进行设置),代理刷新,刷新网络数据等能力。 + + +### 相关权限 + +[ohos.permission.KEEP_BACKGROUND_RUNNING](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionkeep_background_running) + +[ohos.permission.INTERNET](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) + +[ohos.permission.GET_BUNDLE_INFO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionget_bundle_info) + +[ohos.permission.START_ABILITIES_FROM_BACKGROUND](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionstart_abilities_from_background) + +### 依赖 + +1.本示例依赖共享数据的更新,由另一应用<共享数据>完成。测试代理刷新卡片功能时需要优先安装该应用。 + +- `app_signature`字段配置为应用的指纹信息,指纹信息的配置请参见[应用特权配置指南](https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md#install_list_capabilityjson中配置)。 + + ``` + [ + ... + { + "signingConfigs": ["****"], // 指纹信息 + } + ] + ``` + + +### 约束与限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API14版本SDK,版本号:5.0.2.57; + +3. 本示例已支持使DevEco Studio 5.0.1 Release (构建版本:5.0.5.306,构建 2024年12月12日)编译运行; + +4. 高等级APL特殊签名说明:无; + + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ApplicationModels/StageServiceWidgetCards/ > .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/ApplicationModels/StageServiceWidgetCards/build-profile.json5 b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/build-profile.json5 index 4617f664e5..346cfe6d81 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/build-profile.json5 @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2022-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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 14, - "targetSdkVersion": 14, - "compatibleSdkVersion": 14, - "runtimeOS": "OpenHarmony" - } - ], - "signingConfigs": [ - - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2022-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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 14, + "targetSdkVersion": 14, + "compatibleSdkVersion": 14, + "runtimeOS": "OpenHarmony" + } + ], + "signingConfigs": [ + + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/build-profile.json5 b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/build-profile.json5 index 86224cda6f..fde30086fc 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/build-profile.json5 @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2022-2023 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', - "showInServiceCenter": true, - "buildOption": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2022-2023 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', + "showInServiceCenter": true, + "buildOption": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/attranimation/pages/AttrAnimationCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/attranimation/pages/AttrAnimationCard.ets index 5f4f532e30..f1c99554a3 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/attranimation/pages/AttrAnimationCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/attranimation/pages/AttrAnimationCard.ets @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2022-2023 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 AttrAnimationCard { - @State rotateAngle: number = 0; - - build() { - Column() { - Button() { - Text($r('app.string.change_rotate_angle')) - .fontColor('#45A6F4') - .fontSize(12) - } - .width(120) - .height(32) - .backgroundColor('#FFFFFF') - .borderRadius(16) - .onClick(() => { - this.rotateAngle = (this.rotateAngle === 0 ? 90 : 0); - }) - .rotate({ angle: this.rotateAngle }) - .animation({ - curve: Curve.EaseOut, - playMode: PlayMode.Normal, - }) - }.height('100%').width('100%') - .justifyContent(FlexAlign.Center) - .backgroundImage($r('app.media.CardExampleBkg')) - .backgroundImageSize(ImageSize.Cover) - } +/* + * Copyright (c) 2022-2023 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 AttrAnimationCard { + @State rotateAngle: number = 0; + + build() { + Column() { + Button() { + Text($r('app.string.change_rotate_angle')) + .fontColor('#45A6F4') + .fontSize(12) + } + .width(120) + .height(32) + .backgroundColor('#FFFFFF') + .borderRadius(16) + .onClick(() => { + this.rotateAngle = (this.rotateAngle === 0 ? 90 : 0); + }) + .rotate({ angle: this.rotateAngle }) + .animation({ + curve: Curve.EaseOut, + playMode: PlayMode.Normal, + }) + }.height('100%').width('100%') + .justifyContent(FlexAlign.Center) + .backgroundImage($r('app.media.CardExampleBkg')) + .backgroundImageSize(ImageSize.Cover) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/customcanvasdrawing/pages/CustomCanvasDrawingCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/customcanvasdrawing/pages/CustomCanvasDrawingCard.ets index f14e23596d..9f75a48b63 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/customcanvasdrawing/pages/CustomCanvasDrawingCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/customcanvasdrawing/pages/CustomCanvasDrawingCard.ets @@ -1,92 +1,92 @@ -/* - * Copyright (c) 2022-2023 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 CustomCanvasDrawingCard { - private canvasWidth: number = 0; - private canvasHeight: number = 0; - // 初始化CanvasRenderingContext2D和RenderingContextSettings - private settings: RenderingContextSettings = new RenderingContextSettings(true); - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); - - build() { - Column() { - Row() { - Canvas(this.context) - .width('100%') - .height('100%') - .onReady(() => { - // 在onReady回调中获取画布的实际宽和高 - this.canvasWidth = this.context.width; - this.canvasHeight = this.context.height; - // 绘制画布的背景 - this.context.fillStyle = '#EEF0FF'; - this.context.fillRect(0, 0, this.canvasWidth, this.canvasHeight); - // 在画布的中心绘制一个圆 - this.context.beginPath(); - let radius = this.context.width / 3; - let circleX = this.context.width / 2; - let circleY = this.context.height / 2; - this.context.moveTo(circleX - radius, circleY); - this.context.arc(circleX, circleY, radius, 2 * Math.PI, 0, true); - this.context.closePath(); - this.context.fillStyle = '#5A5FFF'; - this.context.fill(); - // 绘制笑脸的左眼 - let leftR = radius / 13; - let leftX = circleX - (radius / 2.3); - let leftY = circleY - (radius / 4.5); - this.context.beginPath(); - this.context.arc(leftX, leftY, leftR, 0, 2 * Math.PI, true); - this.context.strokeStyle = '#FFFFFF'; - this.context.lineWidth = 15; - this.context.stroke(); - // 绘制笑脸的右眼 - let rightR = radius / 13; - let rightX = circleX + (radius / 2.3); - let rightY = circleY - (radius / 4.5); - this.context.beginPath(); - this.context.arc(rightX, rightY, rightR, 0, 2 * Math.PI, true); - this.context.strokeStyle = '#FFFFFF'; - this.context.lineWidth = 15; - this.context.stroke(); - // 绘制笑脸的鼻子 - let startX = circleX; - let startY = circleY - 20; - this.context.beginPath(); - this.context.moveTo(startX, startY); - this.context.lineTo(startX - 8, startY + 40); - this.context.lineTo(startX + 8, startY + 40); - this.context.strokeStyle = '#FFFFFF'; - this.context.lineWidth = 15; - this.context.lineCap = 'round'; - this.context.lineJoin = 'round'; - this.context.stroke(); - // 绘制笑脸的嘴巴 - let mouthR = radius / 2; - let mouthX = circleX; - let mouthY = circleY + 10; - this.context.beginPath(); - this.context.arc(mouthX, mouthY, mouthR, Math.PI / 1.4, Math.PI / 3.4, true); - this.context.strokeStyle = '#FFFFFF'; - this.context.lineWidth = 15; - this.context.stroke(); - this.context.closePath(); - }) - } - }.height('100%').width('100%') - } +/* + * Copyright (c) 2022-2023 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 CustomCanvasDrawingCard { + private canvasWidth: number = 0; + private canvasHeight: number = 0; + // 初始化CanvasRenderingContext2D和RenderingContextSettings + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + + build() { + Column() { + Row() { + Canvas(this.context) + .width('100%') + .height('100%') + .onReady(() => { + // 在onReady回调中获取画布的实际宽和高 + this.canvasWidth = this.context.width; + this.canvasHeight = this.context.height; + // 绘制画布的背景 + this.context.fillStyle = '#EEF0FF'; + this.context.fillRect(0, 0, this.canvasWidth, this.canvasHeight); + // 在画布的中心绘制一个圆 + this.context.beginPath(); + let radius = this.context.width / 3; + let circleX = this.context.width / 2; + let circleY = this.context.height / 2; + this.context.moveTo(circleX - radius, circleY); + this.context.arc(circleX, circleY, radius, 2 * Math.PI, 0, true); + this.context.closePath(); + this.context.fillStyle = '#5A5FFF'; + this.context.fill(); + // 绘制笑脸的左眼 + let leftR = radius / 13; + let leftX = circleX - (radius / 2.3); + let leftY = circleY - (radius / 4.5); + this.context.beginPath(); + this.context.arc(leftX, leftY, leftR, 0, 2 * Math.PI, true); + this.context.strokeStyle = '#FFFFFF'; + this.context.lineWidth = 15; + this.context.stroke(); + // 绘制笑脸的右眼 + let rightR = radius / 13; + let rightX = circleX + (radius / 2.3); + let rightY = circleY - (radius / 4.5); + this.context.beginPath(); + this.context.arc(rightX, rightY, rightR, 0, 2 * Math.PI, true); + this.context.strokeStyle = '#FFFFFF'; + this.context.lineWidth = 15; + this.context.stroke(); + // 绘制笑脸的鼻子 + let startX = circleX; + let startY = circleY - 20; + this.context.beginPath(); + this.context.moveTo(startX, startY); + this.context.lineTo(startX - 8, startY + 40); + this.context.lineTo(startX + 8, startY + 40); + this.context.strokeStyle = '#FFFFFF'; + this.context.lineWidth = 15; + this.context.lineCap = 'round'; + this.context.lineJoin = 'round'; + this.context.stroke(); + // 绘制笑脸的嘴巴 + let mouthR = radius / 2; + let mouthX = circleX; + let mouthY = circleY + 10; + this.context.beginPath(); + this.context.arc(mouthX, mouthY, mouthR, Math.PI / 1.4, Math.PI / 3.4, true); + this.context.strokeStyle = '#FFFFFF'; + this.context.lineWidth = 15; + this.context.stroke(); + this.context.closePath(); + }) + } + }.height('100%').width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryability/EntryAbility.ts index 3525105f63..aff3ea25ce 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start entry_ability] -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'EntryAbility'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class EntryAbility extends UIAbility { - private selectPage: string = 'funA'; - private currentWindowStage: window.WindowStage | null = null; - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - // 获取router事件中传递的targetPage参数 - hilog.info(DOMAIN_NUMBER, TAG, `Ability onCreate, ${JSON.stringify(want)}`); - if (want?.parameters?.params) { - // want.parameters.params 对应 postCardAction() 中 params 内容 - let params: Record = JSON.parse(want.parameters.params as string); - this.selectPage = params.targetPage as string; - hilog.info(DOMAIN_NUMBER, TAG, `onCreate selectPage: ${this.selectPage}`); - } - } - - // 如果UIAbility已在后台运行,在收到Router事件后会触发onNewWant生命周期回调 - onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN_NUMBER, TAG, `onNewWant Want: ${JSON.stringify(want)}`); - if (want?.parameters?.params) { - // want.parameters.params 对应 postCardAction() 中 params 内容 - let params: Record = JSON.parse(want.parameters.params as string); - this.selectPage = params.targetPage as string; - hilog.info(DOMAIN_NUMBER, TAG, `onNewWant selectPage: ${this.selectPage}`); - } - if (this.currentWindowStage !== null) { - this.onWindowStageCreate(this.currentWindowStage); - } - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - let targetPage: string; - // 根据传递的targetPage不同,选择拉起不同的页面 - switch (this.selectPage) { - case 'funA': - targetPage = 'funpages/FunA'; - break; - case 'funB': - targetPage = 'funpages/FunB'; - break; - default: - targetPage = 'pages/Index'; - } - if (this.currentWindowStage === null) { - this.currentWindowStage = windowStage; - } - windowStage.loadContent(targetPage, (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } -} +/* + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start entry_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'EntryAbility'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class EntryAbility extends UIAbility { + private selectPage: string = 'funA'; + private currentWindowStage: window.WindowStage | null = null; + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // 获取router事件中传递的targetPage参数 + hilog.info(DOMAIN_NUMBER, TAG, `Ability onCreate, ${JSON.stringify(want)}`); + if (want?.parameters?.params) { + // want.parameters.params 对应 postCardAction() 中 params 内容 + let params: Record = JSON.parse(want.parameters.params as string); + this.selectPage = params.targetPage as string; + hilog.info(DOMAIN_NUMBER, TAG, `onCreate selectPage: ${this.selectPage}`); + } + } + + // 如果UIAbility已在后台运行,在收到Router事件后会触发onNewWant生命周期回调 + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN_NUMBER, TAG, `onNewWant Want: ${JSON.stringify(want)}`); + if (want?.parameters?.params) { + // want.parameters.params 对应 postCardAction() 中 params 内容 + let params: Record = JSON.parse(want.parameters.params as string); + this.selectPage = params.targetPage as string; + hilog.info(DOMAIN_NUMBER, TAG, `onNewWant selectPage: ${this.selectPage}`); + } + if (this.currentWindowStage !== null) { + this.onWindowStageCreate(this.currentWindowStage); + } + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + let targetPage: string; + // 根据传递的targetPage不同,选择拉起不同的页面 + switch (this.selectPage) { + case 'funA': + targetPage = 'funpages/FunA'; + break; + case 'funB': + targetPage = 'funpages/FunB'; + break; + default: + targetPage = 'pages/Index'; + } + if (this.currentWindowStage === null) { + this.currentWindowStage = windowStage; + } + windowStage.loadContent(targetPage, (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } +} // [End entry_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryformability/EntryFormAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryformability/EntryFormAbility.ts index 450aa79cb6..cc503ab486 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryformability/EntryFormAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryformability/EntryFormAbility.ts @@ -1,108 +1,108 @@ -/* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start import_entry_form_ability] -// [Start update_form_interface] -import { formBindingData, FormExtensionAbility, formInfo, formProvider } from '@kit.FormKit'; -// [StartExclude update_form_interface] -import { Configuration, Want } from '@kit.AbilityKit'; -// [EndExclude update_form_interface] -import { BusinessError } from '@kit.BasicServicesKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -// [End import_entry_form_ability] - -// [Start form_extension_ability_interface] -const TAG: string = 'EntryFormAbility'; -const DOMAIN_NUMBER: number = 0xFF00; - -// [Start form_extension_lifecycle_interface] -export default class EntryFormAbility extends FormExtensionAbility { - // [StartExclude update_form_interface] - onAddForm(want: Want): formBindingData.FormBindingData { - hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onAddForm'); - hilog.info(DOMAIN_NUMBER, TAG, want.parameters?.[formInfo.FormParam.NAME_KEY] as string); - // Called to return a FormBindingData object. - let formData = {}; - return formBindingData.createFormBindingData(formData); - } - - onCastToNormalForm(formId: string): void { - // 使用方将临时卡片转换为常态卡片触发,提供方需要做相应的处理 - hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onCastToNormalForm'); - } - - onUpdateForm(formId: string): void { - // 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要重写该方法以支持数据更新 - hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onUpdateForm'); - let obj: Record = { - 'title': 'titleOnUpdateForm', - 'detail': 'detailOnUpdateForm' - }; - let formData: formBindingData.FormBindingData = formBindingData.createFormBindingData(obj); - formProvider.updateForm(formId, formData).catch((error: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] updateForm, error:' + JSON.stringify(error)); - }); - } - - onChangeFormVisibility(newStatus: Record): void { - // 使用方发起可见或者不可见通知触发,提供方需要做相应的处理,仅系统应用生效 - hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onChangeFormVisibility'); - } - - // [EndExclude update_form_interface] - onFormEvent(formId: string, message: string): void { - // Called when a specified message event defined by the form provider is triggered. - hilog.info(DOMAIN_NUMBER, TAG, `FormAbility onFormEvent, formId = ${formId}, message: ${JSON.stringify(message)}`); - // [StartExclude form_extension_lifecycle_interface] - class FormDataClass { - title: string = 'Title Update.'; // 和卡片布局中对应 - detail: string = 'Description update success.'; // 和卡片布局中对应 - } - - let formData = new FormDataClass(); - let formInfo: formBindingData.FormBindingData = formBindingData.createFormBindingData(formData); - formProvider.updateForm(formId, formInfo).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'FormAbility updateForm success.'); - }).catch((error) => { - hilog.error(DOMAIN_NUMBER, TAG, `Operation updateForm failed. Cause: ${JSON.stringify(error)}`); - }); - // [EndExclude form_extension_lifecycle_interface] - } - - // [StartExclude update_form_interface] - onRemoveForm(formId: string): void { - // 删除卡片实例数据 - hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onRemoveForm'); - // 删除之前持久化的卡片实例数据 - // 此接口请根据实际情况实现,具体请参考:FormExtAbility Stage模型卡片实例 - } - - // [StartExclude form_extension_lifecycle_interface] - onConfigurationUpdate(config: Configuration) { - // 当前formExtensionAbility存活时更新系统配置信息时触发的回调。 - // 需注意:formExtensionAbility创建后10秒内无操作将会被清理。 - hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onConfigurationUpdate:' + JSON.stringify(config)); - } - // [EndExclude form_extension_lifecycle_interface] - - onAcquireFormState(want: Want): formInfo.FormState { - // Called to return a {@link FormState} object. - return formInfo.FormState.READY; - } - // [EndExclude update_form_interface] -} -// [End form_extension_ability_interface] -// [End update_form_interface] +/* + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start import_entry_form_ability] +// [Start update_form_interface] +import { formBindingData, FormExtensionAbility, formInfo, formProvider } from '@kit.FormKit'; +// [StartExclude update_form_interface] +import { Configuration, Want } from '@kit.AbilityKit'; +// [EndExclude update_form_interface] +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +// [End import_entry_form_ability] + +// [Start form_extension_ability_interface] +const TAG: string = 'EntryFormAbility'; +const DOMAIN_NUMBER: number = 0xFF00; + +// [Start form_extension_lifecycle_interface] +export default class EntryFormAbility extends FormExtensionAbility { + // [StartExclude update_form_interface] + onAddForm(want: Want): formBindingData.FormBindingData { + hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onAddForm'); + hilog.info(DOMAIN_NUMBER, TAG, want.parameters?.[formInfo.FormParam.NAME_KEY] as string); + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormalForm(formId: string): void { + // 使用方将临时卡片转换为常态卡片触发,提供方需要做相应的处理 + hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onCastToNormalForm'); + } + + onUpdateForm(formId: string): void { + // 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要重写该方法以支持数据更新 + hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onUpdateForm'); + let obj: Record = { + 'title': 'titleOnUpdateForm', + 'detail': 'detailOnUpdateForm' + }; + let formData: formBindingData.FormBindingData = formBindingData.createFormBindingData(obj); + formProvider.updateForm(formId, formData).catch((error: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] updateForm, error:' + JSON.stringify(error)); + }); + } + + onChangeFormVisibility(newStatus: Record): void { + // 使用方发起可见或者不可见通知触发,提供方需要做相应的处理,仅系统应用生效 + hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onChangeFormVisibility'); + } + + // [EndExclude update_form_interface] + onFormEvent(formId: string, message: string): void { + // Called when a specified message event defined by the form provider is triggered. + hilog.info(DOMAIN_NUMBER, TAG, `FormAbility onFormEvent, formId = ${formId}, message: ${JSON.stringify(message)}`); + // [StartExclude form_extension_lifecycle_interface] + class FormDataClass { + title: string = 'Title Update.'; // 和卡片布局中对应 + detail: string = 'Description update success.'; // 和卡片布局中对应 + } + + let formData = new FormDataClass(); + let formInfo: formBindingData.FormBindingData = formBindingData.createFormBindingData(formData); + formProvider.updateForm(formId, formInfo).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'FormAbility updateForm success.'); + }).catch((error) => { + hilog.error(DOMAIN_NUMBER, TAG, `Operation updateForm failed. Cause: ${JSON.stringify(error)}`); + }); + // [EndExclude form_extension_lifecycle_interface] + } + + // [StartExclude update_form_interface] + onRemoveForm(formId: string): void { + // 删除卡片实例数据 + hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onRemoveForm'); + // 删除之前持久化的卡片实例数据 + // 此接口请根据实际情况实现,具体请参考:FormExtAbility Stage模型卡片实例 + } + + // [StartExclude form_extension_lifecycle_interface] + onConfigurationUpdate(config: Configuration) { + // 当前formExtensionAbility存活时更新系统配置信息时触发的回调。 + // 需注意:formExtensionAbility创建后10秒内无操作将会被清理。 + hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onConfigurationUpdate:' + JSON.stringify(config)); + } + // [EndExclude form_extension_lifecycle_interface] + + onAcquireFormState(want: Want): formInfo.FormState { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } + // [EndExclude update_form_interface] +} +// [End form_extension_ability_interface] +// [End update_form_interface] // [End form_extension_lifecycle_interface] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardentryability/JsCardEntryAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardentryability/JsCardEntryAbility.ts index 50606008c4..8b9be84111 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardentryability/JsCardEntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardentryability/JsCardEntryAbility.ts @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start js_card_entry_ability] -// [Start receive_router_event] -import type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type Want from '@ohos.app.ability.Want'; -import type window from '@ohos.window'; - -const TAG: string = 'JsCardEntryAbility'; -const DOMAIN_NUMBER: number = 0xFF00; -// [End js_card_entry_ability] - -export default class JsCardEntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - if (want.parameters) { - let params: Record = JSON.parse(JSON.stringify(want.parameters.params)); - if (params.info === 'router info') { - hilog.info(DOMAIN_NUMBER, TAG, `router info: ${params.info}`); - } - if (params.message === 'router message') { - hilog.info(DOMAIN_NUMBER, TAG, `router message: ${params.message}`); - } - } - } - - // [StartExclude receive_router_event] - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } - // [EndExclude receive_router_event] -} +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start js_card_entry_ability] +// [Start receive_router_event] +import type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type Want from '@ohos.app.ability.Want'; +import type window from '@ohos.window'; + +const TAG: string = 'JsCardEntryAbility'; +const DOMAIN_NUMBER: number = 0xFF00; +// [End js_card_entry_ability] + +export default class JsCardEntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + if (want.parameters) { + let params: Record = JSON.parse(JSON.stringify(want.parameters.params)); + if (params.info === 'router info') { + hilog.info(DOMAIN_NUMBER, TAG, `router info: ${params.info}`); + } + if (params.message === 'router message') { + hilog.info(DOMAIN_NUMBER, TAG, `router message: ${params.message}`); + } + } + } + + // [StartExclude receive_router_event] + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + // [EndExclude receive_router_event] +} // [End receive_router_event] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/nextrefreshtime/pages/NextRefreshTimeCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/nextrefreshtime/pages/NextRefreshTimeCard.ets index 25f1de4d67..4b5af0b3c6 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/nextrefreshtime/pages/NextRefreshTimeCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/nextrefreshtime/pages/NextRefreshTimeCard.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -let storageNextRefreshTime = new LocalStorage(); - -@Entry(storageNextRefreshTime) -@Component -struct NextRefreshTimeCard { - @LocalStorageProp('title') title: ResourceStr = $r('app.string.default_title'); - @LocalStorageProp('detail') detail: ResourceStr = $r('app.string.DescriptionDefault'); - - build() { - Column() { - Column() { - Text(this.title) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(1) - .margin({ top: '8%', left: '10%' }) - Text(this.detail) - .fontColor('#FFFFFF') - .opacity(0.6) - .fontSize(12) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(2) - .margin({ top: '5%', left: '10%' }) - }.width('100%').height('50%') - .alignItems(HorizontalAlign.Start) - - Row() { - Button() { - Text($r('app.string.update')) - .fontColor('#45A6F4') - .fontSize(12) - } - .width(120) - .height(32) - .margin({ top: '30%', bottom: '10%' }) - .backgroundColor('#FFFFFF') - .borderRadius(16) - .onClick(() => { - postCardAction(this, { - action: 'message', - params: { - msgTest: 'messageEvent' - } - }); - }) - }.width('100%').height('40%') - .justifyContent(FlexAlign.Center) - } - .width('100%') - .height('100%') - .alignItems(HorizontalAlign.Start) - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - } +/* + * Copyright (c) 2022-2023 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. + */ + +let storageNextRefreshTime = new LocalStorage(); + +@Entry(storageNextRefreshTime) +@Component +struct NextRefreshTimeCard { + @LocalStorageProp('title') title: ResourceStr = $r('app.string.default_title'); + @LocalStorageProp('detail') detail: ResourceStr = $r('app.string.DescriptionDefault'); + + build() { + Column() { + Column() { + Text(this.title) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(1) + .margin({ top: '8%', left: '10%' }) + Text(this.detail) + .fontColor('#FFFFFF') + .opacity(0.6) + .fontSize(12) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(2) + .margin({ top: '5%', left: '10%' }) + }.width('100%').height('50%') + .alignItems(HorizontalAlign.Start) + + Row() { + Button() { + Text($r('app.string.update')) + .fontColor('#45A6F4') + .fontSize(12) + } + .width(120) + .height(32) + .margin({ top: '30%', bottom: '10%' }) + .backgroundColor('#FFFFFF') + .borderRadius(16) + .onClick(() => { + postCardAction(this, { + action: 'message', + params: { + msgTest: 'messageEvent' + } + }); + }) + }.width('100%').height('40%') + .justifyContent(FlexAlign.Center) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Start) + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/requestForm/pages/RequestFormCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/requestForm/pages/RequestFormCard.ets index 2ae05bd751..32df4f642f 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/requestForm/pages/RequestFormCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/requestForm/pages/RequestFormCard.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -let storageRequestFormCard = new LocalStorage(); - -@Entry(storageRequestFormCard) -@Component -struct RequestFormCard { - @LocalStorageProp('title') title: ResourceStr = $r('app.string.default_title'); - @LocalStorageProp('detail') detail: ResourceStr = $r('app.string.widget_requestForm_desc'); - - build() { - Column() { - Column() { - Text(this.title) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(1) - .margin({ top: '8%', left: '10%' }) - Text(this.detail) - .fontColor('#FFFFFF') - .opacity(0.6) - .fontSize(12) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(2) - .margin({ top: '5%', left: '10%' }) - }.width('100%') - .alignItems(HorizontalAlign.Start) - }.width('100%').height('100%') - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - } +/* + * Copyright (c) 2022-2023 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. + */ + +let storageRequestFormCard = new LocalStorage(); + +@Entry(storageRequestFormCard) +@Component +struct RequestFormCard { + @LocalStorageProp('title') title: ResourceStr = $r('app.string.default_title'); + @LocalStorageProp('detail') detail: ResourceStr = $r('app.string.widget_requestForm_desc'); + + build() { + Column() { + Column() { + Text(this.title) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(1) + .margin({ top: '8%', left: '10%' }) + Text(this.detail) + .fontColor('#FFFFFF') + .opacity(0.6) + .fontSize(12) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(2) + .margin({ top: '5%', left: '10%' }) + }.width('100%') + .alignItems(HorizontalAlign.Start) + }.width('100%').height('100%') + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/scheduledupdatetime/pages/ScheduledUpdateTimeCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/scheduledupdatetime/pages/ScheduledUpdateTimeCard.ets index 86d91bccf2..eb0cb4076a 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/scheduledupdatetime/pages/ScheduledUpdateTimeCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/scheduledupdatetime/pages/ScheduledUpdateTimeCard.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -let storageScheUpdate = new LocalStorage(); - -@Entry(storageScheUpdate) -@Component -struct ScheduledUpdateTimeCard { - @LocalStorageProp('title') title: ResourceStr = $r('app.string.default_title'); - @LocalStorageProp('detail') detail: ResourceStr = $r('app.string.widget_scheupdatetime_desc'); - - build() { - Column() { - Column() { - Text(this.title) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(1) - .margin({ top: '8%', left: '10%' }) - Text(this.detail) - .fontColor('#FFFFFF') - .opacity(0.6) - .fontSize(12) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(2) - .margin({ top: '5%', left: '10%' }) - }.width('100%') - .alignItems(HorizontalAlign.Start) - }.width('100%').height('100%') - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - } +/* + * Copyright (c) 2022-2023 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. + */ + +let storageScheUpdate = new LocalStorage(); + +@Entry(storageScheUpdate) +@Component +struct ScheduledUpdateTimeCard { + @LocalStorageProp('title') title: ResourceStr = $r('app.string.default_title'); + @LocalStorageProp('detail') detail: ResourceStr = $r('app.string.widget_scheupdatetime_desc'); + + build() { + Column() { + Column() { + Text(this.title) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(1) + .margin({ top: '8%', left: '10%' }) + Text(this.detail) + .fontColor('#FFFFFF') + .opacity(0.6) + .fontSize(12) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(2) + .margin({ top: '5%', left: '10%' }) + }.width('100%') + .alignItems(HorizontalAlign.Start) + }.width('100%').height('100%') + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebymessage/pages/UpdateByMessageCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebymessage/pages/UpdateByMessageCard.ets index 22ddf550c3..16eff904ac 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebymessage/pages/UpdateByMessageCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebymessage/pages/UpdateByMessageCard.ets @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start update_by_message_card] -let storageUpdateByMsg = new LocalStorage(); - -@Entry(storageUpdateByMsg) -@Component -struct UpdateByMessageCard { - @LocalStorageProp('title') title: ResourceStr = $r('app.string.default_title'); - @LocalStorageProp('detail') detail: ResourceStr = $r('app.string.DescriptionDefault'); - - build() { - Column() { - Column() { - Text(this.title) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .margin({ top: '8%', left: '10%' }) - Text(this.detail) - .fontColor('#FFFFFF') - .opacity(0.6) - .fontSize(12) - .margin({ top: '5%', left: '10%' }) - }.width('100%').height('50%') - .alignItems(HorizontalAlign.Start) - - Row() { - Button() { - Text($r('app.string.update')) - .fontColor('#45A6F4') - .fontSize(12) - } - .width(120) - .height(32) - .margin({ top: '30%', bottom: '10%' }) - .backgroundColor('#FFFFFF') - .borderRadius(16) - .onClick(() => { - postCardAction(this, { - action: 'message', - params: { msgTest: 'messageEvent' } - }); - }) - }.width('100%').height('40%') - .justifyContent(FlexAlign.Center) - } - .width('100%') - .height('100%') - .alignItems(HorizontalAlign.Start) - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start update_by_message_card] +let storageUpdateByMsg = new LocalStorage(); + +@Entry(storageUpdateByMsg) +@Component +struct UpdateByMessageCard { + @LocalStorageProp('title') title: ResourceStr = $r('app.string.default_title'); + @LocalStorageProp('detail') detail: ResourceStr = $r('app.string.DescriptionDefault'); + + build() { + Column() { + Column() { + Text(this.title) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .margin({ top: '8%', left: '10%' }) + Text(this.detail) + .fontColor('#FFFFFF') + .opacity(0.6) + .fontSize(12) + .margin({ top: '5%', left: '10%' }) + }.width('100%').height('50%') + .alignItems(HorizontalAlign.Start) + + Row() { + Button() { + Text($r('app.string.update')) + .fontColor('#45A6F4') + .fontSize(12) + } + .width(120) + .height(32) + .margin({ top: '30%', bottom: '10%' }) + .backgroundColor('#FFFFFF') + .borderRadius(16) + .onClick(() => { + postCardAction(this, { + action: 'message', + params: { msgTest: 'messageEvent' } + }); + }) + }.width('100%').height('40%') + .justifyContent(FlexAlign.Center) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Start) + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + } +} // [End update_by_message_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updateduration/pages/UpdateDurationCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updateduration/pages/UpdateDurationCard.ets index 15b84e8774..b0e73bfd85 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updateduration/pages/UpdateDurationCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updateduration/pages/UpdateDurationCard.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -let storageUpdateDurationCard = new LocalStorage(); - -@Entry(storageUpdateDurationCard) -@Component -struct UpdateDurationCard { - @LocalStorageProp('title') title: ResourceStr = $r('app.string.default_title'); - @LocalStorageProp('detail') detail: ResourceStr = $r('app.string.widget_updateduration_desc'); - - build() { - Column() { - Column() { - Text(this.title) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(1) - .margin({ top: '8%', left: '10%' }) - Text(this.detail) - .fontColor('#FFFFFF') - .opacity(0.6) - .fontSize(12) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(2) - .margin({ top: '5%', left: '10%' }) - }.width('100%') - .alignItems(HorizontalAlign.Start) - }.width('100%').height('100%') - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - } +/* + * Copyright (c) 2022-2023 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. + */ + +let storageUpdateDurationCard = new LocalStorage(); + +@Entry(storageUpdateDurationCard) +@Component +struct UpdateDurationCard { + @LocalStorageProp('title') title: ResourceStr = $r('app.string.default_title'); + @LocalStorageProp('detail') detail: ResourceStr = $r('app.string.widget_updateduration_desc'); + + build() { + Column() { + Column() { + Text(this.title) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(1) + .margin({ top: '8%', left: '10%' }) + Text(this.detail) + .fontColor('#FFFFFF') + .opacity(0.6) + .fontSize(12) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(2) + .margin({ top: '5%', left: '10%' }) + }.width('100%') + .alignItems(HorizontalAlign.Start) + }.width('100%').height('100%') + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetcalleeentryability/WidgetCalleeEntryAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetcalleeentryability/WidgetCalleeEntryAbility.ts index 2dc0631465..d8a2c3f3af 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetcalleeentryability/WidgetCalleeEntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetcalleeentryability/WidgetCalleeEntryAbility.ts @@ -1,96 +1,96 @@ -/* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start widget_callee_entry_ability] -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { formBindingData, formProvider } from '@kit.FormKit'; -import { rpc } from '@kit.IPCKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'WidgetCalleeEntryAbility'; -const DOMAIN_NUMBER: number = 0xFF00; -const MSG_SEND_METHOD: string = 'funA'; -const CONST_NUMBER_1: number = 1; - -class MyParcelable implements rpc.Parcelable { - num: number; - str: string; - - constructor(num: number, str: string) { - this.num = num; - this.str = str; - }; - - marshalling(messageSequence: rpc.MessageSequence): boolean { - messageSequence.writeInt(this.num); - messageSequence.writeString(this.str); - return true; - }; - - unmarshalling(messageSequence: rpc.MessageSequence): boolean { - this.num = messageSequence.readInt(); - this.str = messageSequence.readString(); - return true; - }; -} - -// 在收到call事件后会触发callee监听的方法 -let funACall = (data: rpc.MessageSequence): MyParcelable => { - // 获取call事件中传递的所有参数 - let params: Record = JSON.parse(data.readString()); - if (params.formId !== undefined) { - let curFormId: string = params.formId; - let message: string = params.calleeDetail; - hilog.info(DOMAIN_NUMBER, TAG, `UpdateForm formId: ${curFormId}, message: ${message}`); - let formData: Record = { - 'calleeDetail': message - }; - let formMsg: formBindingData.FormBindingData = formBindingData.createFormBindingData(formData); - formProvider.updateForm(curFormId, formMsg).then((data) => { - hilog.info(DOMAIN_NUMBER, TAG, `updateForm success. ${JSON.stringify(data)}`); - }).catch((error: BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `updateForm failed: ${JSON.stringify(error)}`); - }); - } - return new MyParcelable(CONST_NUMBER_1, 'aaa'); -}; - -export default class WidgetCalleeEntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - try { - // 监听call事件所需的方法 - this.callee.on(MSG_SEND_METHOD, funACall); - } catch (error) { - hilog.error(DOMAIN_NUMBER, TAG, `${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`); - } - ; - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } -} +/* + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start widget_callee_entry_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { formBindingData, formProvider } from '@kit.FormKit'; +import { rpc } from '@kit.IPCKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'WidgetCalleeEntryAbility'; +const DOMAIN_NUMBER: number = 0xFF00; +const MSG_SEND_METHOD: string = 'funA'; +const CONST_NUMBER_1: number = 1; + +class MyParcelable implements rpc.Parcelable { + num: number; + str: string; + + constructor(num: number, str: string) { + this.num = num; + this.str = str; + }; + + marshalling(messageSequence: rpc.MessageSequence): boolean { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); + return true; + }; + + unmarshalling(messageSequence: rpc.MessageSequence): boolean { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); + return true; + }; +} + +// 在收到call事件后会触发callee监听的方法 +let funACall = (data: rpc.MessageSequence): MyParcelable => { + // 获取call事件中传递的所有参数 + let params: Record = JSON.parse(data.readString()); + if (params.formId !== undefined) { + let curFormId: string = params.formId; + let message: string = params.calleeDetail; + hilog.info(DOMAIN_NUMBER, TAG, `UpdateForm formId: ${curFormId}, message: ${message}`); + let formData: Record = { + 'calleeDetail': message + }; + let formMsg: formBindingData.FormBindingData = formBindingData.createFormBindingData(formData); + formProvider.updateForm(curFormId, formMsg).then((data) => { + hilog.info(DOMAIN_NUMBER, TAG, `updateForm success. ${JSON.stringify(data)}`); + }).catch((error: BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `updateForm failed: ${JSON.stringify(error)}`); + }); + } + return new MyParcelable(CONST_NUMBER_1, 'aaa'); +}; + +export default class WidgetCalleeEntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + try { + // 监听call事件所需的方法 + this.callee.on(MSG_SEND_METHOD, funACall); + } catch (error) { + hilog.error(DOMAIN_NUMBER, TAG, `${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`); + } + ; + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } +} // [End widget_callee_entry_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcall/pages/WidgetEventCallCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcall/pages/WidgetEventCallCard.ets index 99bac245a8..1d8f4730ec 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcall/pages/WidgetEventCallCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcall/pages/WidgetEventCallCard.ets @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -let storageEventCall = new LocalStorage(); - -// [Start widget_event_call_card] -@Entry(storageEventCall) -@Component -struct WidgetEventCallCard { - @LocalStorageProp('formId') formId: string = '12400633174999288'; - - build() { - Column() { - // [StartExclude widget_event_call_card] - Text($r('app.string.WidgetEventCallEntryAbility_desc')) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .margin({ top: '8%', left: '10%' }) - // [EndExclude widget_event_call_card] - Row() { - Column() { - Button() { - // [StartExclude widget_event_call_card] - Text($r('app.string.ButtonA_label')) - .fontColor('#45A6F4') - .fontSize(12) - // [EndExclude widget_event_call_card] - } - // [StartExclude widget_event_call_card] - .width(120) - .height(32) - .margin({ top: '20%' }) - .backgroundColor('#FFFFFF') - .borderRadius(16) - // [EndExclude widget_event_call_card] - .onClick(() => { - postCardAction(this, { - action: 'call', - abilityName: 'WidgetEventCallEntryAbility', // 只能跳转到当前应用下的UIAbility - params: { - formId: this.formId, - method: 'funA' // 在EntryAbility中调用的方法名 - } - }); - }) - - Button() { - // [StartExclude widget_event_call_card] - Text($r('app.string.ButtonB_label')) - .fontColor('#45A6F4') - .fontSize(12) - // [EndExclude widget_event_call_card] - } - // [StartExclude widget_event_call_card] - .width(120) - .height(32) - .margin({ top: '8%', bottom: '15vp' }) - .backgroundColor('#FFFFFF') - .borderRadius(16) - // [EndExclude widget_event_call_card] - .onClick(() => { - postCardAction(this, { - action: 'call', - abilityName: 'WidgetEventCallEntryAbility', // 只能跳转到当前应用下的UIAbility - params: { - formId: this.formId, - method: 'funB', // 在EntryAbility中调用的方法名 - num: 1 // 需要传递的其他参数 - } - }); - }) - } - }.width('100%').height('80%') - .justifyContent(FlexAlign.Center) - } - .width('100%') - .height('100%') - .alignItems(HorizontalAlign.Start) - // [StartExclude widget_event_call_card] - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - // [EndExclude widget_event_call_card] - } -} +/* + * Copyright (c) 2022-2023 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. + */ + +let storageEventCall = new LocalStorage(); + +// [Start widget_event_call_card] +@Entry(storageEventCall) +@Component +struct WidgetEventCallCard { + @LocalStorageProp('formId') formId: string = '12400633174999288'; + + build() { + Column() { + // [StartExclude widget_event_call_card] + Text($r('app.string.WidgetEventCallEntryAbility_desc')) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .margin({ top: '8%', left: '10%' }) + // [EndExclude widget_event_call_card] + Row() { + Column() { + Button() { + // [StartExclude widget_event_call_card] + Text($r('app.string.ButtonA_label')) + .fontColor('#45A6F4') + .fontSize(12) + // [EndExclude widget_event_call_card] + } + // [StartExclude widget_event_call_card] + .width(120) + .height(32) + .margin({ top: '20%' }) + .backgroundColor('#FFFFFF') + .borderRadius(16) + // [EndExclude widget_event_call_card] + .onClick(() => { + postCardAction(this, { + action: 'call', + abilityName: 'WidgetEventCallEntryAbility', // 只能跳转到当前应用下的UIAbility + params: { + formId: this.formId, + method: 'funA' // 在EntryAbility中调用的方法名 + } + }); + }) + + Button() { + // [StartExclude widget_event_call_card] + Text($r('app.string.ButtonB_label')) + .fontColor('#45A6F4') + .fontSize(12) + // [EndExclude widget_event_call_card] + } + // [StartExclude widget_event_call_card] + .width(120) + .height(32) + .margin({ top: '8%', bottom: '15vp' }) + .backgroundColor('#FFFFFF') + .borderRadius(16) + // [EndExclude widget_event_call_card] + .onClick(() => { + postCardAction(this, { + action: 'call', + abilityName: 'WidgetEventCallEntryAbility', // 只能跳转到当前应用下的UIAbility + params: { + formId: this.formId, + method: 'funB', // 在EntryAbility中调用的方法名 + num: 1 // 需要传递的其他参数 + } + }); + }) + } + }.width('100%').height('80%') + .justifyContent(FlexAlign.Center) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Start) + // [StartExclude widget_event_call_card] + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + // [EndExclude widget_event_call_card] + } +} // [End widget_event_call_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts index ee3a633151..355b67f827 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts @@ -1,86 +1,86 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start widget_event_call_card_entry_ability] -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { promptAction } from '@kit.ArkUI'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { rpc } from '@kit.IPCKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'WidgetEventCallEntryAbility'; -const DOMAIN_NUMBER: number = 0xFF00; -const CONST_NUMBER_1: number = 1; -const CONST_NUMBER_2: number = 2; - -class MyParcelable implements rpc.Parcelable { - num: number; - str: string; - - constructor(num: number, str: string) { - this.num = num; - this.str = str; - } - - marshalling(messageSequence: rpc.MessageSequence): boolean { - messageSequence.writeInt(this.num); - messageSequence.writeString(this.str); - return true; - } - - unmarshalling(messageSequence: rpc.MessageSequence): boolean { - this.num = messageSequence.readInt(); - this.str = messageSequence.readString(); - return true; - } -} - -export default class WidgetEventCallEntryAbility extends UIAbility { - // 如果UIAbility第一次启动,在收到call事件后会触发onCreate生命周期回调 - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - try { - // 监听call事件所需的方法 - this.callee.on('funA', (data: rpc.MessageSequence) => { - // 获取call事件中传递的所有参数 - hilog.info(DOMAIN_NUMBER, TAG, `FunACall param: ${JSON.stringify(data.readString())}`); - promptAction.showToast({ - message: 'FunACall param:' + JSON.stringify(data.readString()) - }); - return new MyParcelable(CONST_NUMBER_1, 'aaa'); - }); - this.callee.on('funB', (data: rpc.MessageSequence) => { - // 获取call事件中传递的所有参数 - hilog.info(DOMAIN_NUMBER, TAG, `FunBCall param: ${JSON.stringify(data.readString())}`); - promptAction.showToast({ - message: 'FunBCall param:' + JSON.stringify(data.readString()) - }); - return new MyParcelable(CONST_NUMBER_2, 'bbb'); - }); - } catch (err) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to register callee on. Cause: ${JSON.stringify(err as BusinessError)}`); - }; - } - - // 进程退出时,解除监听 - onDestroy(): void | Promise { - try { - this.callee.off('funA'); - this.callee.off('funB'); - } catch (err) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to register callee off. Cause: ${JSON.stringify(err as BusinessError)}`); - }; - } -} +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start widget_event_call_card_entry_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { promptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { rpc } from '@kit.IPCKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'WidgetEventCallEntryAbility'; +const DOMAIN_NUMBER: number = 0xFF00; +const CONST_NUMBER_1: number = 1; +const CONST_NUMBER_2: number = 2; + +class MyParcelable implements rpc.Parcelable { + num: number; + str: string; + + constructor(num: number, str: string) { + this.num = num; + this.str = str; + } + + marshalling(messageSequence: rpc.MessageSequence): boolean { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); + return true; + } + + unmarshalling(messageSequence: rpc.MessageSequence): boolean { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); + return true; + } +} + +export default class WidgetEventCallEntryAbility extends UIAbility { + // 如果UIAbility第一次启动,在收到call事件后会触发onCreate生命周期回调 + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + try { + // 监听call事件所需的方法 + this.callee.on('funA', (data: rpc.MessageSequence) => { + // 获取call事件中传递的所有参数 + hilog.info(DOMAIN_NUMBER, TAG, `FunACall param: ${JSON.stringify(data.readString())}`); + promptAction.showToast({ + message: 'FunACall param:' + JSON.stringify(data.readString()) + }); + return new MyParcelable(CONST_NUMBER_1, 'aaa'); + }); + this.callee.on('funB', (data: rpc.MessageSequence) => { + // 获取call事件中传递的所有参数 + hilog.info(DOMAIN_NUMBER, TAG, `FunBCall param: ${JSON.stringify(data.readString())}`); + promptAction.showToast({ + message: 'FunBCall param:' + JSON.stringify(data.readString()) + }); + return new MyParcelable(CONST_NUMBER_2, 'bbb'); + }); + } catch (err) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to register callee on. Cause: ${JSON.stringify(err as BusinessError)}`); + }; + } + + // 进程退出时,解除监听 + onDestroy(): void | Promise { + try { + this.callee.off('funA'); + this.callee.off('funB'); + } catch (err) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to register callee off. Cause: ${JSON.stringify(err as BusinessError)}`); + }; + } +} // [Start widget_event_call_card_entry_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetevententryability/WidgetEventRouterEntryAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetevententryability/WidgetEventRouterEntryAbility.ts index b5b6d2b257..de8ffc4a3e 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetevententryability/WidgetEventRouterEntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetevententryability/WidgetEventRouterEntryAbility.ts @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start widget_event_router_entry_ability] -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { formBindingData, formInfo, formProvider } from '@kit.FormKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'WidgetEventRouterEntryAbility'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class WidgetEventRouterEntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.handleFormRouterEvent(want); - } - - handleFormRouterEvent(want: Want): void { - hilog.info(DOMAIN_NUMBER, TAG, 'handleFormRouterEvent, Want:', JSON.stringify(want)); - if (want.parameters && want.parameters[formInfo.FormParam.IDENTITY_KEY] !== undefined) { - let curFormId = JSON.stringify(want.parameters[formInfo.FormParam.IDENTITY_KEY]); - let message: string = JSON.stringify(want.parameters.routerDetail); - hilog.info(DOMAIN_NUMBER, TAG, `UpdateForm formId: ${curFormId}, message: ${message}`); - let formData: Record = { - routerDetail: message + 'UIAbility.', // 和卡片布局中对应 - }; - let formMsg = formBindingData.createFormBindingData(formData); - formProvider.updateForm(want.parameters[formInfo.FormParam.IDENTITY_KEY] + '', formMsg).then((data) => { - hilog.info(DOMAIN_NUMBER, TAG, 'updateForm success.', JSON.stringify(data)); - }).catch((error: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, 'updateForm failed.', JSON.stringify(error)); - }); - } - } - - // 如果UIAbility已在后台运行,在收到Router事件后会触发onNewWant生命周期回调 - onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN_NUMBER, TAG, 'onNewWant Want:', JSON.stringify(want)); - if (want.parameters && want.parameters[formInfo.FormParam.IDENTITY_KEY] !== undefined) { - let curFormId = JSON.stringify(want.parameters[formInfo.FormParam.IDENTITY_KEY]); - let message: string = JSON.stringify(want.parameters.routerDetail); - hilog.info(DOMAIN_NUMBER, TAG, `UpdateForm formId: ${curFormId}, message: ${message}`); - let formData: Record = { - routerDetail: message + 'onNewWant UIAbility.', // 和卡片布局中对应 - }; - let formMsg = formBindingData.createFormBindingData(formData); - formProvider.updateForm(want.parameters[formInfo.FormParam.IDENTITY_KEY] + '', formMsg).then((data) => { - hilog.info(DOMAIN_NUMBER, TAG, 'updateForm success.', JSON.stringify(data)); - }).catch((error: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, 'updateForm failed.', JSON.stringify(error)); - }); - } - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } -} +/* + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start widget_event_router_entry_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { formBindingData, formInfo, formProvider } from '@kit.FormKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'WidgetEventRouterEntryAbility'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class WidgetEventRouterEntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.handleFormRouterEvent(want); + } + + handleFormRouterEvent(want: Want): void { + hilog.info(DOMAIN_NUMBER, TAG, 'handleFormRouterEvent, Want:', JSON.stringify(want)); + if (want.parameters && want.parameters[formInfo.FormParam.IDENTITY_KEY] !== undefined) { + let curFormId = JSON.stringify(want.parameters[formInfo.FormParam.IDENTITY_KEY]); + let message: string = JSON.stringify(want.parameters.routerDetail); + hilog.info(DOMAIN_NUMBER, TAG, `UpdateForm formId: ${curFormId}, message: ${message}`); + let formData: Record = { + routerDetail: message + 'UIAbility.', // 和卡片布局中对应 + }; + let formMsg = formBindingData.createFormBindingData(formData); + formProvider.updateForm(want.parameters[formInfo.FormParam.IDENTITY_KEY] + '', formMsg).then((data) => { + hilog.info(DOMAIN_NUMBER, TAG, 'updateForm success.', JSON.stringify(data)); + }).catch((error: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, 'updateForm failed.', JSON.stringify(error)); + }); + } + } + + // 如果UIAbility已在后台运行,在收到Router事件后会触发onNewWant生命周期回调 + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN_NUMBER, TAG, 'onNewWant Want:', JSON.stringify(want)); + if (want.parameters && want.parameters[formInfo.FormParam.IDENTITY_KEY] !== undefined) { + let curFormId = JSON.stringify(want.parameters[formInfo.FormParam.IDENTITY_KEY]); + let message: string = JSON.stringify(want.parameters.routerDetail); + hilog.info(DOMAIN_NUMBER, TAG, `UpdateForm formId: ${curFormId}, message: ${message}`); + let formData: Record = { + routerDetail: message + 'onNewWant UIAbility.', // 和卡片布局中对应 + }; + let formMsg = formBindingData.createFormBindingData(formData); + formProvider.updateForm(want.parameters[formInfo.FormParam.IDENTITY_KEY] + '', formMsg).then((data) => { + hilog.info(DOMAIN_NUMBER, TAG, 'updateForm success.', JSON.stringify(data)); + }).catch((error: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, 'updateForm failed.', JSON.stringify(error)); + }); + } + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } +} // [End widget_event_router_entry_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventrouter/pages/WidgetEventRouterCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventrouter/pages/WidgetEventRouterCard.ets index dc7da7ef54..c77500b275 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventrouter/pages/WidgetEventRouterCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventrouter/pages/WidgetEventRouterCard.ets @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start widget_event_router_card] -@Entry -@Component -struct WidgetEventRouterCard { - build() { - Column() { - Text($r('app.string.JumpLabel')) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .margin({ top: '8%', left: '10%' }) - Row() { - Column() { - Button() { - Text($r('app.string.ButtonA_label')) - .fontColor('#45A6F4') - .fontSize(12) - } - .width(120) - .height(32) - .margin({ top: '20%' }) - .backgroundColor('#FFFFFF') - .borderRadius(16) - .onClick(() => { - postCardAction(this, { - action: 'router', - abilityName: 'EntryAbility', - params: { targetPage: 'funA' } - }); - }) - - Button() { - Text($r('app.string.ButtonB_label')) - .fontColor('#45A6F4') - .fontSize(12) - } - .width(120) - .height(32) - .margin({ top: '8%', bottom: '15vp' }) - .backgroundColor('#FFFFFF') - .borderRadius(16) - .onClick(() => { - postCardAction(this, { - action: 'router', - abilityName: 'EntryAbility', - params: { targetPage: 'funB' } - }); - }) - } - }.width('100%').height('80%') - .justifyContent(FlexAlign.Center) - } - .width('100%') - .height('100%') - .alignItems(HorizontalAlign.Start) - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - } -} +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start widget_event_router_card] +@Entry +@Component +struct WidgetEventRouterCard { + build() { + Column() { + Text($r('app.string.JumpLabel')) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .margin({ top: '8%', left: '10%' }) + Row() { + Column() { + Button() { + Text($r('app.string.ButtonA_label')) + .fontColor('#45A6F4') + .fontSize(12) + } + .width(120) + .height(32) + .margin({ top: '20%' }) + .backgroundColor('#FFFFFF') + .borderRadius(16) + .onClick(() => { + postCardAction(this, { + action: 'router', + abilityName: 'EntryAbility', + params: { targetPage: 'funA' } + }); + }) + + Button() { + Text($r('app.string.ButtonB_label')) + .fontColor('#45A6F4') + .fontSize(12) + } + .width(120) + .height(32) + .margin({ top: '8%', bottom: '15vp' }) + .backgroundColor('#FFFFFF') + .borderRadius(16) + .onClick(() => { + postCardAction(this, { + action: 'router', + abilityName: 'EntryAbility', + params: { targetPage: 'funB' } + }); + }) + } + }.width('100%').height('80%') + .justifyContent(FlexAlign.Center) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Start) + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + } +} // [End widget_event_router_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetimageupdate/pages/WidgetImageUpdateCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetimageupdate/pages/WidgetImageUpdateCard.ets index 0d79cde7a9..44fe500e5d 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetimageupdate/pages/WidgetImageUpdateCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetimageupdate/pages/WidgetImageUpdateCard.ets @@ -1,108 +1,108 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start widget_image_update_card] -let storageWidgetImageUpdate = new LocalStorage(); - -@Entry(storageWidgetImageUpdate) -@Component -struct WidgetImageUpdateCard { - @LocalStorageProp('text') text: ResourceStr = $r('app.string.loading'); - @LocalStorageProp('loaded') loaded: boolean = false; - @LocalStorageProp('imgName') imgName: ResourceStr = $r('app.string.imgName'); - - build() { - if (this.loaded) { - Column() { - Column() { - Text(this.text) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(12) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(1) - .margin({ top: '8%', left: '10%' }) - }.width('100%').height('50%') - .alignItems(HorizontalAlign.Start) - - Row() { - Button() { - Text($r('app.string.update')) - .fontColor('#45A6F4') - .fontSize(12) - } - .width(120) - .height(32) - .margin({ top: '30%', bottom: '10%' }) - .backgroundColor('#FFFFFF') - .borderRadius(16) - .onClick(() => { - postCardAction(this, { - action: 'message', - params: { - info: 'refreshImage' - } - }); - }) - }.width('100%').height('40%') - .justifyContent(FlexAlign.Center) - } - .width('100%').height('100%') - .backgroundImage('memory://' + this.imgName) - .backgroundImageSize(ImageSize.Cover) - } - // [StartExclude widget_image_update_card] - else { - Column() { - Column() { - Text(this.text) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(12) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(1) - .margin({ top: '8%', left: '10%' }) - }.width('100%').height('50%') - .alignItems(HorizontalAlign.Start) - - Row() { - Button() { - Text($r('app.string.update')) - .fontColor('#45A6F4') - .fontSize(12) - } - .width(120) - .height(32) - .margin({ top: '30%', bottom: '10%' }) - .backgroundColor('#FFFFFF') - .borderRadius(16) - .onClick(() => { - postCardAction(this, { - action: 'message', - params: { - info: 'refreshImage' - } - }); - }) - }.width('100%').height('40%') - .justifyContent(FlexAlign.Center) - }.width('100%').height('100%') - .backgroundImage($r('app.media.ImageDisp')) - .backgroundImageSize(ImageSize.Cover) - } - // [EndExclude widget_image_update_card] - } -} +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start widget_image_update_card] +let storageWidgetImageUpdate = new LocalStorage(); + +@Entry(storageWidgetImageUpdate) +@Component +struct WidgetImageUpdateCard { + @LocalStorageProp('text') text: ResourceStr = $r('app.string.loading'); + @LocalStorageProp('loaded') loaded: boolean = false; + @LocalStorageProp('imgName') imgName: ResourceStr = $r('app.string.imgName'); + + build() { + if (this.loaded) { + Column() { + Column() { + Text(this.text) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(12) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(1) + .margin({ top: '8%', left: '10%' }) + }.width('100%').height('50%') + .alignItems(HorizontalAlign.Start) + + Row() { + Button() { + Text($r('app.string.update')) + .fontColor('#45A6F4') + .fontSize(12) + } + .width(120) + .height(32) + .margin({ top: '30%', bottom: '10%' }) + .backgroundColor('#FFFFFF') + .borderRadius(16) + .onClick(() => { + postCardAction(this, { + action: 'message', + params: { + info: 'refreshImage' + } + }); + }) + }.width('100%').height('40%') + .justifyContent(FlexAlign.Center) + } + .width('100%').height('100%') + .backgroundImage('memory://' + this.imgName) + .backgroundImageSize(ImageSize.Cover) + } + // [StartExclude widget_image_update_card] + else { + Column() { + Column() { + Text(this.text) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(12) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(1) + .margin({ top: '8%', left: '10%' }) + }.width('100%').height('50%') + .alignItems(HorizontalAlign.Start) + + Row() { + Button() { + Text($r('app.string.update')) + .fontColor('#45A6F4') + .fontSize(12) + } + .width(120) + .height(32) + .margin({ top: '30%', bottom: '10%' }) + .backgroundColor('#FFFFFF') + .borderRadius(16) + .onClick(() => { + postCardAction(this, { + action: 'message', + params: { + info: 'refreshImage' + } + }); + }) + }.width('100%').height('40%') + .justifyContent(FlexAlign.Center) + }.width('100%').height('100%') + .backgroundImage($r('app.media.ImageDisp')) + .backgroundImageSize(ImageSize.Cover) + } + // [EndExclude widget_image_update_card] + } +} // [End widget_image_update_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetpersistentdata/pages/WidgetPersistentDataCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetpersistentdata/pages/WidgetPersistentDataCard.ets index 7aeae32d8f..7525a913a9 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetpersistentdata/pages/WidgetPersistentDataCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetpersistentdata/pages/WidgetPersistentDataCard.ets @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start widget_persistent_data_card] -let storagePersis = new LocalStorage(); - -@Entry(storagePersis) -@Component -struct WidgetPersistentDataCard { - readonly FULL_WIDTH_PERCENT: string = '100%'; - readonly FULL_HEIGHT_PERCENT: string = '100%'; - @LocalStorageProp('list') list: Record[] = [{ 'type': 'a' }]; - - build() { - Column() { - Column() { - Text((this.list[0]['type'])) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .margin({ top: '8%', left: '10%' }) - }.width('100%') - .alignItems(HorizontalAlign.Start) - }.width(this.FULL_WIDTH_PERCENT).height(this.FULL_HEIGHT_PERCENT) - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start widget_persistent_data_card] +let storagePersis = new LocalStorage(); + +@Entry(storagePersis) +@Component +struct WidgetPersistentDataCard { + readonly FULL_WIDTH_PERCENT: string = '100%'; + readonly FULL_HEIGHT_PERCENT: string = '100%'; + @LocalStorageProp('list') list: Record[] = [{ 'type': 'a' }]; + + build() { + Column() { + Column() { + Text((this.list[0]['type'])) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .margin({ top: '8%', left: '10%' }) + }.width('100%') + .alignItems(HorizontalAlign.Start) + }.width(this.FULL_WIDTH_PERCENT).height(this.FULL_HEIGHT_PERCENT) + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + } +} // [End widget_persistent_data_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetprocessdata/pages/WidgetProcessDataCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetprocessdata/pages/WidgetProcessDataCard.ets index 1d02842434..094f8f0eab 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetprocessdata/pages/WidgetProcessDataCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetprocessdata/pages/WidgetProcessDataCard.ets @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start widget_process_data_card] -let storageProcess = new LocalStorage(); - -@Entry(storageProcess) -@Component -struct WidgetProcessDataCard { - @LocalStorageProp('datashareproxy://com.samples.widgetupdatebyproxy/weather') city: ResourceStr = - $r('app.string.loading'); - - build() { - Column() { - Column() { - Text(this.city) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .margin({ top: '8%', left: '10%' }) - }.width('100%') - .alignItems(HorizontalAlign.Start) - }.width('100%').height('100%') - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - } -} +/* + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start widget_process_data_card] +let storageProcess = new LocalStorage(); + +@Entry(storageProcess) +@Component +struct WidgetProcessDataCard { + @LocalStorageProp('datashareproxy://com.samples.widgetupdatebyproxy/weather') city: ResourceStr = + $r('app.string.loading'); + + build() { + Column() { + Column() { + Text(this.city) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .margin({ top: '8%', left: '10%' }) + }.width('100%') + .alignItems(HorizontalAlign.Start) + }.width('100%').height('100%') + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + } +} // [End widget_process_data_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatebystatus/pages/WidgetUpdateByStatusCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatebystatus/pages/WidgetUpdateByStatusCard.ets index c4663f6713..683d92e447 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatebystatus/pages/WidgetUpdateByStatusCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatebystatus/pages/WidgetUpdateByStatusCard.ets @@ -1,114 +1,114 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start widget_update_by_status_card] -let storageUpdateByStatus = new LocalStorage(); - -@Entry(storageUpdateByStatus) -@Component -struct WidgetUpdateByStatusCard { - @LocalStorageProp('textA') textA: Resource = $r('app.string.to_be_refreshed'); - @LocalStorageProp('textB') textB: Resource = $r('app.string.to_be_refreshed'); - @State selectA: boolean = false; - @State selectB: boolean = false; - - build() { - Column() { - Column() { - Row() { - Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) - .padding(0) - .select(false) - .margin({ left: 26 }) - .onChange((value: boolean) => { - this.selectA = value; - postCardAction(this, { - action: 'message', - params: { - selectA: JSON.stringify(value) - } - }); - }) - Text($r('app.string.status_a')) - .fontColor('#000000') - .opacity(0.9) - .fontSize(14) - .margin({ left: 8 }) - } - .width('100%') - .padding(0) - .justifyContent(FlexAlign.Start) - - Row() { - Checkbox({ name: 'checkbox2', group: 'checkboxGroup' }) - .padding(0) - .select(false) - .margin({ left: 26 }) - .onChange((value: boolean) => { - this.selectB = value; - postCardAction(this, { - action: 'message', - params: { - selectB: JSON.stringify(value) - } - }); - }) - Text($r('app.string.status_b')) - .fontColor('#000000') - .opacity(0.9) - .fontSize(14) - .margin({ left: 8 }) - } - .width('100%') - .position({ y: 32 }) - .padding(0) - .justifyContent(FlexAlign.Start) - } - .position({ y: 12 }) - - Column() { - Row() { // 选中状态A才会进行刷新的内容 - Text($r('app.string.status_a')) - .fontColor('#000000') - .opacity(0.4) - .fontSize(12) - - Text(this.textA) - .fontColor('#000000') - .opacity(0.4) - .fontSize(12) - } - .margin({ top: '12px', left: 26, right: '26px' }) - - Row() { // 选中状态B才会进行刷新的内容 - Text($r('app.string.status_b')) - .fontColor('#000000') - .opacity(0.4) - .fontSize(12) - Text(this.textB) - .fontColor('#000000') - .opacity(0.4) - .fontSize(12) - }.margin({ top: '12px', bottom: '21px', left: 26, right: '26px' }) - } - .margin({ top: 80 }) - .width('100%') - .alignItems(HorizontalAlign.Start) - }.width('100%').height('100%') - .backgroundImage($r('app.media.CardUpdateByStatus')) - .backgroundImageSize(ImageSize.Cover) - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start widget_update_by_status_card] +let storageUpdateByStatus = new LocalStorage(); + +@Entry(storageUpdateByStatus) +@Component +struct WidgetUpdateByStatusCard { + @LocalStorageProp('textA') textA: Resource = $r('app.string.to_be_refreshed'); + @LocalStorageProp('textB') textB: Resource = $r('app.string.to_be_refreshed'); + @State selectA: boolean = false; + @State selectB: boolean = false; + + build() { + Column() { + Column() { + Row() { + Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) + .padding(0) + .select(false) + .margin({ left: 26 }) + .onChange((value: boolean) => { + this.selectA = value; + postCardAction(this, { + action: 'message', + params: { + selectA: JSON.stringify(value) + } + }); + }) + Text($r('app.string.status_a')) + .fontColor('#000000') + .opacity(0.9) + .fontSize(14) + .margin({ left: 8 }) + } + .width('100%') + .padding(0) + .justifyContent(FlexAlign.Start) + + Row() { + Checkbox({ name: 'checkbox2', group: 'checkboxGroup' }) + .padding(0) + .select(false) + .margin({ left: 26 }) + .onChange((value: boolean) => { + this.selectB = value; + postCardAction(this, { + action: 'message', + params: { + selectB: JSON.stringify(value) + } + }); + }) + Text($r('app.string.status_b')) + .fontColor('#000000') + .opacity(0.9) + .fontSize(14) + .margin({ left: 8 }) + } + .width('100%') + .position({ y: 32 }) + .padding(0) + .justifyContent(FlexAlign.Start) + } + .position({ y: 12 }) + + Column() { + Row() { // 选中状态A才会进行刷新的内容 + Text($r('app.string.status_a')) + .fontColor('#000000') + .opacity(0.4) + .fontSize(12) + + Text(this.textA) + .fontColor('#000000') + .opacity(0.4) + .fontSize(12) + } + .margin({ top: '12px', left: 26, right: '26px' }) + + Row() { // 选中状态B才会进行刷新的内容 + Text($r('app.string.status_b')) + .fontColor('#000000') + .opacity(0.4) + .fontSize(12) + Text(this.textB) + .fontColor('#000000') + .opacity(0.4) + .fontSize(12) + }.margin({ top: '12px', bottom: '21px', left: 26, right: '26px' }) + } + .margin({ top: 80 }) + .width('100%') + .alignItems(HorizontalAlign.Start) + }.width('100%').height('100%') + .backgroundImage($r('app.media.CardUpdateByStatus')) + .backgroundImageSize(ImageSize.Cover) + } +} // [End widget_update_by_status_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatecall/pages/WidgetUpdateCallCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatecall/pages/WidgetUpdateCallCard.ets index 783b8a6161..ff674f138c 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatecall/pages/WidgetUpdateCallCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatecall/pages/WidgetUpdateCallCard.ets @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start widget_update_call_card] -let storageUpdtCall = new LocalStorage(); - -@Entry(storageUpdtCall) -@Component -struct WidgetUpdateCallCard { - @LocalStorageProp('formId') formId: string = '12400633174999288'; - @LocalStorageProp('calleeDetail') calleeDetail: ResourceStr = $r('app.string.init'); - - build() { - Column() { - Column() { - Text(this.calleeDetail) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .margin({ top: '8%', left: '10%' }) - }.width('100%').height('50%') - .alignItems(HorizontalAlign.Start) - - Row() { - Button() { - Text($r('app.string.CalleeJumpLabel')) - .fontColor('#45A6F4') - .fontSize(12) - } - .width(120) - .height(32) - .margin({ top: '30%', bottom: '10%' }) - .backgroundColor('#FFFFFF') - .borderRadius(16) - .onClick(() => { - postCardAction(this, { - action: 'call', - abilityName: 'WidgetCalleeEntryAbility', // 只能拉起当前应用下的UIAbility - params: { - method: 'funA', - formId: this.formId, - calleeDetail: 'CallFrom' - } - }); - }) - }.width('100%').height('40%') - .justifyContent(FlexAlign.Center) - } - .width('100%') - .height('100%') - .alignItems(HorizontalAlign.Start) - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - } -} +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start widget_update_call_card] +let storageUpdtCall = new LocalStorage(); + +@Entry(storageUpdtCall) +@Component +struct WidgetUpdateCallCard { + @LocalStorageProp('formId') formId: string = '12400633174999288'; + @LocalStorageProp('calleeDetail') calleeDetail: ResourceStr = $r('app.string.init'); + + build() { + Column() { + Column() { + Text(this.calleeDetail) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .margin({ top: '8%', left: '10%' }) + }.width('100%').height('50%') + .alignItems(HorizontalAlign.Start) + + Row() { + Button() { + Text($r('app.string.CalleeJumpLabel')) + .fontColor('#45A6F4') + .fontSize(12) + } + .width(120) + .height(32) + .margin({ top: '30%', bottom: '10%' }) + .backgroundColor('#FFFFFF') + .borderRadius(16) + .onClick(() => { + postCardAction(this, { + action: 'call', + abilityName: 'WidgetCalleeEntryAbility', // 只能拉起当前应用下的UIAbility + params: { + method: 'funA', + formId: this.formId, + calleeDetail: 'CallFrom' + } + }); + }) + }.width('100%').height('40%') + .justifyContent(FlexAlign.Center) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Start) + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + } +} // [End widget_update_call_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdaterouter/pages/WidgetUpdateRouterCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdaterouter/pages/WidgetUpdateRouterCard.ets index fd242beab4..d71cc14809 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdaterouter/pages/WidgetUpdateRouterCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdaterouter/pages/WidgetUpdateRouterCard.ets @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start widget_updt_router_card] -let storageUpdtRouter = new LocalStorage(); - -@Entry(storageUpdtRouter) -@Component -struct WidgetUpdtRouterCard { - @LocalStorageProp('routerDetail') routerDetail: ResourceStr = $r('app.string.init'); - - build() { - Column() { - Column() { - Text(this.routerDetail) - .fontColor('#FFFFFF') - .opacity(0.9) - .fontSize(14) - .margin({ top: '8%', left: '10%', right: '10%' }) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(2) - }.width('100%').height('50%') - .alignItems(HorizontalAlign.Start) - - Row() { - Button() { - Text($r('app.string.JumpLabel')) - .fontColor('#45A6F4') - .fontSize(12) - } - .width(120) - .height(32) - .margin({ top: '30%', bottom: '10%' }) - .backgroundColor('#FFFFFF') - .borderRadius(16) - .onClick(() => { - postCardAction(this, { - action: 'router', - abilityName: 'WidgetEventRouterEntryAbility', // 只能跳转到当前应用下的UIAbility - params: { - routerDetail: 'RouterFromCard', - } - }); - }) - }.width('100%').height('40%') - .justifyContent(FlexAlign.Center) - } - .width('100%') - .height('100%') - .alignItems(HorizontalAlign.Start) - .backgroundImage($r('app.media.CardEvent')) - .backgroundImageSize(ImageSize.Cover) - } -} +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start widget_updt_router_card] +let storageUpdtRouter = new LocalStorage(); + +@Entry(storageUpdtRouter) +@Component +struct WidgetUpdtRouterCard { + @LocalStorageProp('routerDetail') routerDetail: ResourceStr = $r('app.string.init'); + + build() { + Column() { + Column() { + Text(this.routerDetail) + .fontColor('#FFFFFF') + .opacity(0.9) + .fontSize(14) + .margin({ top: '8%', left: '10%', right: '10%' }) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(2) + }.width('100%').height('50%') + .alignItems(HorizontalAlign.Start) + + Row() { + Button() { + Text($r('app.string.JumpLabel')) + .fontColor('#45A6F4') + .fontSize(12) + } + .width(120) + .height(32) + .margin({ top: '30%', bottom: '10%' }) + .backgroundColor('#FFFFFF') + .borderRadius(16) + .onClick(() => { + postCardAction(this, { + action: 'router', + abilityName: 'WidgetEventRouterEntryAbility', // 只能跳转到当前应用下的UIAbility + params: { + routerDetail: 'RouterFromCard', + } + }); + }) + }.width('100%').height('40%') + .justifyContent(FlexAlign.Center) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Start) + .backgroundImage($r('app.media.CardEvent')) + .backgroundImageSize(ImageSize.Cover) + } +} // [End widget_updt_router_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/js/WidgetJS/pages/index/index.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/js/WidgetJS/pages/index/index.json index 5cac48220e..c7ea46e15d 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/js/WidgetJS/pages/index/index.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/js/WidgetJS/pages/index/index.json @@ -1,22 +1,22 @@ -{ - "data": { - "title": "TitleDefault", - "detail": "TextDefault" - }, - "actions": { - "routerEvent": { - "action": "router", - "abilityName": "JSCardEntryAbility", - "params": { - "info": "router info", - "message": "router message" - } - }, - "messageEvent": { - "action": "message", - "params": { - "detail": "message detail" - } - } - } +{ + "data": { + "title": "TitleDefault", + "detail": "TextDefault" + }, + "actions": { + "routerEvent": { + "action": "router", + "abilityName": "JSCardEntryAbility", + "params": { + "info": "router info", + "message": "router message" + } + }, + "messageEvent": { + "action": "message", + "params": { + "detail": "message detail" + } + } + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/module.json5 b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/module.json5 index 5402420b4d..ed75ec5545 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/module.json5 +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/module.json5 @@ -1,230 +1,230 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start jscard_extension_ability] -{ - "module": { - // [StartExclude jscard_extension_ability] - "name": "entry", - "type": "entry", - "description": "$string:module_desc", - "mainElement": "EntryAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - // [Start module_json5_abilities] - "abilities": [ - // [StartExclude module_json5_abilities] - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "WidgetEventRouterEntryAbility", - "srcEntry": "./ets/widgetevententryability/WidgetEventRouterEntryAbility.ts", - "description": "$string:WidgetEventEntryAbility_desc", - "icon": "$media:icon", - "label": "$string:WidgetEventEntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - }, - { - "name": "JsCardEntryAbility", - "srcEntry": "./ets/jscardentryability/JsCardEntryAbility.ts", - "description": "$string:JSCardEntryAbility_desc", - "icon": "$media:icon", - "label": "$string:JSCardEntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - }, - { - "name": "WidgetCalleeEntryAbility", - "srcEntry": "./ets/widgetcalleeentryability/WidgetCalleeEntryAbility.ts", - "description": "$string:WidgetCalleeEntryAbility_desc", - "icon": "$media:icon", - "label": "$string:WidgetCalleeEntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - }, - // [EndExclude module_json5_abilities] - { - "name": "WidgetEventCallEntryAbility", - "srcEntry": "./ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts", - "description": "$string:WidgetEventCallEntryAbility_desc", - "icon": "$media:icon", - "label": "$string:WidgetEventCallEntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - } - ], - // [End module_json5_abilities] - // [EndExclude jscard_extension_ability] - "extensionAbilities": [ - // [StartExclude jscard_extension_ability] - { - "name": "EntryFormAbility", - "srcEntry": "./ets/entryformability/EntryFormAbility.ts", - "label": "$string:EntryFormAbility_label", - "description": "$string:EntryFormAbility_desc", - "type": "form", - "metadata": [ - { - "name": "ohos.extension.form", - "resource": "$profile:form_config" - } - ] - }, - { - "name": "WgtImgUpdateEntryFormAbility", - "srcEntry": "./ets/wgtimgupdateentryformability/WgtImgUpdateEntryFormAbility.ts", - "description": "$string:WgtImgUpdateEntryFormAbility_desc", - "label": "$string:WgtImgUpdateEntryFormAbility_label", - "type": "form", - "metadata": [ - { - "name": "ohos.extension.form", - "resource": "$profile:form_imgupdate_config" - } - ] - }, - { - "name": "UpdateByTimeFormAbility", - "srcEntry": "./ets/updatebytimeformability/UpdateByTimeFormAbility.ts", - "description": "$string:UpdateByTimeFormAbility_desc", - "label": "$string:UpdateByTimeFormAbility_label", - "type": "form", - "metadata": [ - { - "name": "ohos.extension.form", - "resource": "$profile:form_updatebytime_config" - } - ] - }, - { - "name": "UpdateByStatusFormAbility", - "srcEntry": "./ets/updatebystatusformability/UpdateByStatusFormAbility.ts", - "description": "$string:UpdateByStatusFormAbility_desc", - "label": "$string:UpdateByStatusFormAbility_label", - "type": "form", - "metadata": [ - { - "name": "ohos.extension.form", - "resource": "$profile:form_updatebystatus_config" - } - ] - }, - // [EndExclude jscard_extension_ability] - { - "name": "JsCardFormAbility", - "srcEntry": "./ets/jscardformability/JsCardFormAbility.ts", - "description": "$string:JSCardFormAbility_desc", - "label": "$string:JSCardFormAbility_label", - "type": "form", - "metadata": [ - { - "name": "ohos.extension.form", - "resource": "$profile:form_jscard_config" - } - ] - }, - // [StartExclude jscard_extension_ability] - { - "name": "ProcessDataFormAbility", - "srcEntry": "./ets/processdataentryability/ProcessDataFormAbility.ts", - "description": "$string:ProcessDataEntryAbility_desc", - "label": "$string:ProcessDataEntryAbility_label", - "type": "form", - "metadata": [ - { - "name": "ohos.extension.form", - "resource": "$profile:form_processdata_config" - } - ] - }, - { - "name": "WidgetCalleeFormAbility", - "srcEntry": "./ets/widgetcalleeformability/WidgetCalleeFormAbility.ts", - "description": "$string:WidgetCalleeFormAbility_desc", - "label": "$string:WidgetCalleeFormAbility_label", - "type": "form", - "metadata": [ - { - "name": "ohos.extension.form", - "resource": "$profile:form_widgetcallee_config" - } - ] - }, - { - "name": "PersistentDataFormAbility", - "srcEntry": "./ets/persistentdataformability/PersistentDataFormAbility.ts", - "description": "$string:PersistentDataFormAbility_desc", - "label": "$string:PersistentDataFormAbility_label", - "type": "form", - "metadata": [ - { - "name": "ohos.extension.form", - "resource": "$profile:form_persistentdata_config" - } - ] - } - ], - // [Start module_json5_request_permissions] - "requestPermissions": [ - { - "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", - }, - // [StartExclude module_json5_request_permissions] - { - "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO", - }, - { - "name": "ohos.permission.INTERNET", - "usedScene": { - "abilities": [ - "WgtImgUpdateEntryFormAbility" - ], - "when": "inuse", - } - } - // [EndExclude module_json5_request_permissions] - // [EndExclude jscard_extension_ability] - ] - // [End module_json5_request_permissions] - } -} +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start jscard_extension_ability] +{ + "module": { + // [StartExclude jscard_extension_ability] + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + // [Start module_json5_abilities] + "abilities": [ + // [StartExclude module_json5_abilities] + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "WidgetEventRouterEntryAbility", + "srcEntry": "./ets/widgetevententryability/WidgetEventRouterEntryAbility.ts", + "description": "$string:WidgetEventEntryAbility_desc", + "icon": "$media:icon", + "label": "$string:WidgetEventEntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "JsCardEntryAbility", + "srcEntry": "./ets/jscardentryability/JsCardEntryAbility.ts", + "description": "$string:JSCardEntryAbility_desc", + "icon": "$media:icon", + "label": "$string:JSCardEntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "WidgetCalleeEntryAbility", + "srcEntry": "./ets/widgetcalleeentryability/WidgetCalleeEntryAbility.ts", + "description": "$string:WidgetCalleeEntryAbility_desc", + "icon": "$media:icon", + "label": "$string:WidgetCalleeEntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + }, + // [EndExclude module_json5_abilities] + { + "name": "WidgetEventCallEntryAbility", + "srcEntry": "./ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts", + "description": "$string:WidgetEventCallEntryAbility_desc", + "icon": "$media:icon", + "label": "$string:WidgetEventCallEntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + } + ], + // [End module_json5_abilities] + // [EndExclude jscard_extension_ability] + "extensionAbilities": [ + // [StartExclude jscard_extension_ability] + { + "name": "EntryFormAbility", + "srcEntry": "./ets/entryformability/EntryFormAbility.ts", + "label": "$string:EntryFormAbility_label", + "description": "$string:EntryFormAbility_desc", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ] + }, + { + "name": "WgtImgUpdateEntryFormAbility", + "srcEntry": "./ets/wgtimgupdateentryformability/WgtImgUpdateEntryFormAbility.ts", + "description": "$string:WgtImgUpdateEntryFormAbility_desc", + "label": "$string:WgtImgUpdateEntryFormAbility_label", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_imgupdate_config" + } + ] + }, + { + "name": "UpdateByTimeFormAbility", + "srcEntry": "./ets/updatebytimeformability/UpdateByTimeFormAbility.ts", + "description": "$string:UpdateByTimeFormAbility_desc", + "label": "$string:UpdateByTimeFormAbility_label", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_updatebytime_config" + } + ] + }, + { + "name": "UpdateByStatusFormAbility", + "srcEntry": "./ets/updatebystatusformability/UpdateByStatusFormAbility.ts", + "description": "$string:UpdateByStatusFormAbility_desc", + "label": "$string:UpdateByStatusFormAbility_label", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_updatebystatus_config" + } + ] + }, + // [EndExclude jscard_extension_ability] + { + "name": "JsCardFormAbility", + "srcEntry": "./ets/jscardformability/JsCardFormAbility.ts", + "description": "$string:JSCardFormAbility_desc", + "label": "$string:JSCardFormAbility_label", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_jscard_config" + } + ] + }, + // [StartExclude jscard_extension_ability] + { + "name": "ProcessDataFormAbility", + "srcEntry": "./ets/processdataentryability/ProcessDataFormAbility.ts", + "description": "$string:ProcessDataEntryAbility_desc", + "label": "$string:ProcessDataEntryAbility_label", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_processdata_config" + } + ] + }, + { + "name": "WidgetCalleeFormAbility", + "srcEntry": "./ets/widgetcalleeformability/WidgetCalleeFormAbility.ts", + "description": "$string:WidgetCalleeFormAbility_desc", + "label": "$string:WidgetCalleeFormAbility_label", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_widgetcallee_config" + } + ] + }, + { + "name": "PersistentDataFormAbility", + "srcEntry": "./ets/persistentdataformability/PersistentDataFormAbility.ts", + "description": "$string:PersistentDataFormAbility_desc", + "label": "$string:PersistentDataFormAbility_label", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_persistentdata_config" + } + ] + } + ], + // [Start module_json5_request_permissions] + "requestPermissions": [ + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", + }, + // [StartExclude module_json5_request_permissions] + { + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO", + }, + { + "name": "ohos.permission.INTERNET", + "usedScene": { + "abilities": [ + "WgtImgUpdateEntryFormAbility" + ], + "when": "inuse", + } + } + // [EndExclude module_json5_request_permissions] + // [EndExclude jscard_extension_ability] + ] + // [End module_json5_request_permissions] + } +} // [End jscard_extension_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/element/color.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/element/color.json index 45df772f39..79695d2275 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/element/color.json @@ -1,24 +1,24 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "text_font_color", - "value": "#FFFFFF" - }, - { - "name": "background", - "value": "#f1f3f5" - }, - { - "name": "backGrounding", - "value": "#f1f3f5" - }, - { - "name": "text_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "text_font_color", + "value": "#FFFFFF" + }, + { + "name": "background", + "value": "#f1f3f5" + }, + { + "name": "backGrounding", + "value": "#f1f3f5" + }, + { + "name": "text_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/element/float.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/element/float.json index edb7816076..d50ddbfab2 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/element/float.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/element/float.json @@ -1,28 +1,28 @@ -{ - "float": [ - { - "name": "title_immersive_font_size", - "value": "19fp" - }, - { - "name": "detail_immersive_font_size", - "value": "16fp" - }, - { - "name": "detail_immersive_margin_top", - "value": "6vp" - }, - { - "name": "detail_immersive_opacity", - "value": "0.66" - }, - { - "name": "column_padding", - "value": "12vp" - }, - { - "name": "font_size", - "value": "16fp" - } - ] +{ + "float": [ + { + "name": "title_immersive_font_size", + "value": "19fp" + }, + { + "name": "detail_immersive_font_size", + "value": "16fp" + }, + { + "name": "detail_immersive_margin_top", + "value": "6vp" + }, + { + "name": "detail_immersive_opacity", + "value": "0.66" + }, + { + "name": "column_padding", + "value": "12vp" + }, + { + "name": "font_size", + "value": "16fp" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_config.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_config.json index e49d008bf2..42dd8d2041 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_config.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_config.json @@ -1,80 +1,80 @@ -{ - "forms": [ - { - "name": "AttrAnimation", - "description": "$string:widget_animation_desc", - "src": "./ets/attranimation/pages/AttrAnimationCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": false, - "updateEnabled": false, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - }, - { - "name": "CustomCanvasDrawing", - "description": "$string:widget_custom_desc", - "src": "./ets/customcanvasdrawing/pages/CustomCanvasDrawingCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": false, - "updateEnabled": false, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "4*4", - "supportDimensions": [ - "4*4" - ] - }, - { - "name": "WidgetEventRouter", - "description": "$string:widget_eventrouter_desc", - "src": "./ets/widgeteventrouter/pages/WidgetEventRouterCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": false, - "updateEnabled": false, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - }, - { - "name": "UpdateByMessage", - "description": "$string:widget_updatebymsg_desc", - "src": "./ets/updatebymessage/pages/UpdateByMessageCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": false, - "updateEnabled": false, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - } - ] +{ + "forms": [ + { + "name": "AttrAnimation", + "description": "$string:widget_animation_desc", + "src": "./ets/attranimation/pages/AttrAnimationCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": false, + "updateEnabled": false, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + }, + { + "name": "CustomCanvasDrawing", + "description": "$string:widget_custom_desc", + "src": "./ets/customcanvasdrawing/pages/CustomCanvasDrawingCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": false, + "updateEnabled": false, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "4*4", + "supportDimensions": [ + "4*4" + ] + }, + { + "name": "WidgetEventRouter", + "description": "$string:widget_eventrouter_desc", + "src": "./ets/widgeteventrouter/pages/WidgetEventRouterCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": false, + "updateEnabled": false, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + }, + { + "name": "UpdateByMessage", + "description": "$string:widget_updatebymsg_desc", + "src": "./ets/updatebymessage/pages/UpdateByMessageCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": false, + "updateEnabled": false, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_imgupdate_config.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_imgupdate_config.json index 703dba1eba..c1ef6609cd 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_imgupdate_config.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_imgupdate_config.json @@ -1,23 +1,23 @@ -{ - "forms": [ - { - "name": "WidgetImageUpdate", - "description": "$string:WgtImgUpdateEntryFormAbility_desc", - "src": "./ets/widgetimageupdate/pages/WidgetImageUpdateCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": false, - "updateEnabled": false, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - } - ] +{ + "forms": [ + { + "name": "WidgetImageUpdate", + "description": "$string:WgtImgUpdateEntryFormAbility_desc", + "src": "./ets/widgetimageupdate/pages/WidgetImageUpdateCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": false, + "updateEnabled": false, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_jscard_config.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_jscard_config.json index ab56d5a657..3d2afc0a92 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_jscard_config.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_jscard_config.json @@ -1,22 +1,22 @@ -{ - "forms": [ - { - "name": "WidgetJS", - "description": "$string:JSCardEntryAbility_desc", - "src": "./js/WidgetJS/pages/index/index", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": true, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - } - ] +{ + "forms": [ + { + "name": "WidgetJS", + "description": "$string:JSCardEntryAbility_desc", + "src": "./js/WidgetJS/pages/index/index", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_persistentdata_config.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_persistentdata_config.json index 0e037ca24c..5eaba8e39d 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_persistentdata_config.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_persistentdata_config.json @@ -1,24 +1,24 @@ -{ - "forms": [ - { - "name": "WidgetPersistentData", - "description": "This is a service widget update by proxy using persistent data.", - "src": "./ets/widgetpersistentdata/pages/WidgetPersistentDataCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": true, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ], - "dataProxyEnabled": true - } - ] +{ + "forms": [ + { + "name": "WidgetPersistentData", + "description": "This is a service widget update by proxy using persistent data.", + "src": "./ets/widgetpersistentdata/pages/WidgetPersistentDataCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ], + "dataProxyEnabled": true + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_processdata_config.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_processdata_config.json index febbffd6a3..fb01577423 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_processdata_config.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_processdata_config.json @@ -1,23 +1,23 @@ -{ - "forms": [ - { - "name": "WidgetProcessData", - "description": "$string:ProcessDataEntryAbility_desc", - "src": "./ets/widgetprocessdata/pages/WidgetProcessDataCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": true, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ], - "dataProxyEnabled": true - } - ] +{ + "forms": [ + { + "name": "WidgetProcessData", + "description": "$string:ProcessDataEntryAbility_desc", + "src": "./ets/widgetprocessdata/pages/WidgetProcessDataCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ], + "dataProxyEnabled": true + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_updatebystatus_config.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_updatebystatus_config.json index 1447bd49a3..ecbeee5473 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_updatebystatus_config.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_updatebystatus_config.json @@ -1,23 +1,23 @@ -{ - "forms": [ - { - "name": "WidgetUpdateByStatus", - "description": "$string:UpdateByStatusFormAbility_desc", - "src": "./ets/widgetupdatebystatus/pages/WidgetUpdateByStatusCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": true, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - } - ] +{ + "forms": [ + { + "name": "WidgetUpdateByStatus", + "description": "$string:UpdateByStatusFormAbility_desc", + "src": "./ets/widgetupdatebystatus/pages/WidgetUpdateByStatusCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_updatebytime_config.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_updatebytime_config.json index b84a54f2db..26ade10d74 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_updatebytime_config.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_updatebytime_config.json @@ -1,85 +1,85 @@ -{ - "forms": [ - { - "name": "UpdateDuration", - "description": "$string:widget_updateduration_desc", - "src": "./ets/updateduration/pages/UpdateDurationCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": true, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 2, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - }, - { - "name": "ScheduledUpdateTime", - "description": "$string:widget_scheupdatetime_desc", - "src": "./ets/scheduledupdatetime/pages/ScheduledUpdateTimeCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": false, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 0, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - }, - { - "name": "NextRefreshTime", - "description": "$string:widget_nextrefreshtime_desc", - "src": "./ets/nextrefreshtime/pages/NextRefreshTimeCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": false, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 0, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - }, - { - "name": "RequestForm", - "description": "$string:widget_requestForm_desc", - "src": "./ets/requestForm/pages/RequestFormCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": false, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 2, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ], - "formConfigAbility": "ability://com.example.entry.EntryAbility", - "dataProxyEnabled": false, - "isDynamic": true, - "transparencyEnabled": false, - "metadata": [] - } - ] +{ + "forms": [ + { + "name": "UpdateDuration", + "description": "$string:widget_updateduration_desc", + "src": "./ets/updateduration/pages/UpdateDurationCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 2, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + }, + { + "name": "ScheduledUpdateTime", + "description": "$string:widget_scheupdatetime_desc", + "src": "./ets/scheduledupdatetime/pages/ScheduledUpdateTimeCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": false, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 0, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + }, + { + "name": "NextRefreshTime", + "description": "$string:widget_nextrefreshtime_desc", + "src": "./ets/nextrefreshtime/pages/NextRefreshTimeCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": false, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 0, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + }, + { + "name": "RequestForm", + "description": "$string:widget_requestForm_desc", + "src": "./ets/requestForm/pages/RequestFormCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": false, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 2, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ], + "formConfigAbility": "ability://com.example.entry.EntryAbility", + "dataProxyEnabled": false, + "isDynamic": true, + "transparencyEnabled": false, + "metadata": [] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_widgetcallee_config.json b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_widgetcallee_config.json index 76684446af..beef5ffda6 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_widgetcallee_config.json +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/resources/base/profile/form_widgetcallee_config.json @@ -1,61 +1,61 @@ -{ - "forms": [ - { - "name": "WidgetUpdateRouter", - "description": "$string:WidgetEventEntryAbility_desc", - "src": "./ets/widgetupdaterouter/pages/WidgetUpdateRouterCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": false, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - }, - { - "name": "WidgetEventCall", - "description": "$string:WidgetEventCallEntryAbility_desc", - "src": "./ets/widgeteventcall/pages/WidgetEventCallCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": false, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - }, - { - "name": "WidgetUpdateCall", - "description": "$string:WidgetCalleeEntryAbility_desc", - "src": "./ets/widgetupdatecall/pages/WidgetUpdateCallCard.ets", - "uiSyntax": "arkts", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "isDefault": true, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2" - ] - } - ] +{ + "forms": [ + { + "name": "WidgetUpdateRouter", + "description": "$string:WidgetEventEntryAbility_desc", + "src": "./ets/widgetupdaterouter/pages/WidgetUpdateRouterCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": false, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + }, + { + "name": "WidgetEventCall", + "description": "$string:WidgetEventCallEntryAbility_desc", + "src": "./ets/widgeteventcall/pages/WidgetEventCallCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": false, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + }, + { + "name": "WidgetUpdateCall", + "description": "$string:WidgetCalleeEntryAbility_desc", + "src": "./ets/widgetupdatecall/pages/WidgetUpdateCallCard.ets", + "uiSyntax": "arkts", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/ohosTest/ets/test/Form.test.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/ohosTest/ets/test/Form.test.ets index e298772fd8..8ccf92546d 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/ohosTest/ets/test/Form.test.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/ohosTest/ets/test/Form.test.ets @@ -1,1275 +1,1275 @@ -/* - * Copyright (c) 2022-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 { abilityDelegatorRegistry, Driver, MatchPattern, ON } from '@kit.TestKit'; -import { beforeAll, describe, expect, it } from '@ohos/hypium'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -const TAG = '[Sample_ServiceCard_Test]'; -const DOMAIN = 0xF811; -const BUNDLE = 'ServiceCard_'; -const DELAYTIME01 = 1000; -const DELAYTIME02 = 2000; -const DELAYTIME03 = 3000; -let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -let resourceManager = abilityDelegator.getAppContext().resourceManager; -let cardArkTsWidgetEventRouter = 'WidgetEventRouter'; -let cardWidgetUpdateRouter = 'WidgetUpdateRouter'; -let cardWidgetUpdateCallCard = 'WidgetUpdateCall'; -let cardWidgetEventCall = 'WidgetEventCall' -let cardUpdateByMessage = 'UpdateByMessage'; -let cardAttrAnimation = 'AttrAnimation'; -let cardCustomCanvasDrawing = 'CustomCanvasDrawing'; -let cardUpdateDuration = 'UpdateDuration'; -let cardScheduledUpdateTime = 'ScheduledUpdateTime'; -let cardNextRefreshTimeCard = 'NextRefreshTime'; -let cardWidgetImageUpdate = 'WidgetImageUpdate'; -let cardWidgetUpdateByStatus = 'WidgetUpdateByStatus'; -let cardWidgetProcessData = 'WidgetProcessData'; -let cardWidgetPersistentData = 'WidgetPersistentData'; -let cardWidgetJS = 'WidgetJS'; -let driver = Driver.create(); -// Sliding coordinate -const START_SLIDING_X = 700; -const FINISH_SLIDING_X = 50; -const SLIDING_COORDINATE_Y = 300; -// Add to desktop coordinate -const ADD_TO_DESKTOP_X = 300; -const ADD_TO_DESKTOP_Y = 1200; - -export default function formTest() { - describe('ActsFormTest', () => { - beforeAll(async () => { - // Exit the test interface to execute the test case - await driver.pressHome(); - await driver.delayMs(DELAYTIME01); - }) - - /* - * @tc.number: ServiceCard_ArkTS_001 - * @tc.name: Add WidgetEventRouter cards to desktop. - * @tc.desc: Add WidgetEventRouter cards to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 begin'); - await driver.delayMs(DELAYTIME01); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_001 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardArkTsWidgetEventRouter).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_001 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_001 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME02); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_001 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 2; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.add_to_desktop')), - MatchPattern.CONTAINS)); - let addCard = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.add_to_desktop')), - MatchPattern.CONTAINS)); - await addCard.click(); - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_001 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardArkTsWidgetEventRouter).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_001 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_002 - * @tc.name: Add cardWidgetUpdateRouter card to desktop. - * @tc.desc: Add cardWidgetUpdateRouter card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_002', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_002 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardWidgetUpdateRouter).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_002 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_002 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_002 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 12; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_002 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardWidgetUpdateRouter).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_002 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_003 - * @tc.name: Add UpdateByMessage card to desktop. - * @tc.desc: Add UpdateByMessage card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_003', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_003 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardUpdateByMessage).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_003 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_003 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_003 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 3; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_003 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardUpdateByMessage).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_003 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_004 - * @tc.name: Add CustomCanvasDrawing card to desktop. - * @tc.desc: Add CustomCanvasDrawing card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_004', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_004 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardCustomCanvasDrawing).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_004 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_004 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_004 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_004 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardCustomCanvasDrawing).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_004 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_005 - * @tc.name: Add Animation card to desktop. - * @tc.desc: Add Animation card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_005', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_005 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardAttrAnimation).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_005 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_005 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_005 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 addCardToDesktop'); - await driver.delayMs(2000); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_005 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardAttrAnimation).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_005 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_006 - * @tc.name: Add WidgetUpdateByStatus card to desktop. - * @tc.desc: Add WidgetUpdateByStatus card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_006', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_006 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardWidgetUpdateByStatus).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_006 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_006 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_006 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 7; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - /// Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_006 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardWidgetUpdateByStatus).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_006 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME01); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_007 - * @tc.name: Add WidgetProcessData card to desktop. - * @tc.desc: Add WidgetProcessData card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_007', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_007 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardWidgetProcessData).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_007 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_007 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_007 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 6; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_007 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardWidgetProcessData).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_007 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME01); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_008 - * @tc.name: Add UpdateDuration card to desktop. - * @tc.desc: Add UpdateDuration card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_008', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_008 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardUpdateDuration).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_008 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_008 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_008 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 8; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_008 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardUpdateDuration).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_008 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME01); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_009 - * @tc.name: Add ScheduledUpdateTime card to desktop. - * @tc.desc: Add ScheduledUpdateTime card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_009', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_009 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardScheduledUpdateTime).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_009 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_009 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_009 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 9; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_009 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardScheduledUpdateTime).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_009 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_010 - * @tc.name: Add NextRefreshTimeCard card to desktop. - * @tc.desc: Add NextRefreshTimeCard card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_010', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_010 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardNextRefreshTimeCard).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_010 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_010 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_010 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 10; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_010 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardNextRefreshTimeCard).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_010 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_011 - * @tc.name: Add WidgetImageUpdate card to desktop. - * @tc.desc: Add WidgetImageUpdate card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_011', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_011 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardWidgetImageUpdate).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_011 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_011 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_011 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 11; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_011 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardWidgetImageUpdate).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_011 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_012 - * @tc.name: Add WidgetEventCall card to desktop. - * @tc.desc: Add WidgetEventCall card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_012', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_012 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardWidgetEventCall).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_012 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_012 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_012 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 13; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_012 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardWidgetEventCall).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_012 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_013 - * @tc.name: Add WidgetUpdateCall card to desktop. - * @tc.desc: Add WidgetUpdateCall card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_013', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_013 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardWidgetUpdateCallCard).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_013 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_013 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_013 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - - for (let i = 0; i < 14; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_013 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardWidgetUpdateCallCard).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_013 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_ArkTS_014 - * @tc.name: Add WidgetPersistentData card to desktop. - * @tc.desc: Add WidgetPersistentData card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'ArkTS_014', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_014 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardWidgetPersistentData).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_014 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_014 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_014 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 5; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_014 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardWidgetPersistentData).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_014 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - - /* - * @tc.number: ServiceCard_JS_UI_001 - * @tc.name: Add WidgetJS card to desktop. - * @tc.desc: Add WidgetJS card to desktop. - * @tc.size: MediumTest - * @tc.type: Function - * @tc.level Level 1 - */ - it(BUNDLE + 'JS_UI_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 begin'); - await driver.delayMs(DELAYTIME03); - // Confirm the number of cards on the desktop - let cardArkTsCount = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `JS_UI_001 getFormData data: ${JSON.stringify(data)}`); - expect(result !== null).assertTrue(); - cardArkTsCount = result.split(cardWidgetJS).length - 1; - hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 cardArkTsCount:' + cardArkTsCount); - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'JS_UI_001 hilog err is: ' + JSON.stringify(err)); - }); - await driver.delayMs(DELAYTIME01); - - // Long click the application - await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - let app = - await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), - MatchPattern.CONTAINS)); - // Get the text control border - let rect = await app.getBounds(); - // Calculate the height of the text control - let height = rect.bottom - rect.top; - // Get the center point of the text control - let point = await app.getBoundsCenter(); - await driver.longClick(point.x, point.y - height); - hilog.info(DOMAIN, TAG, BUNDLE + `JS_UI_001 long click app, coordinate:(${point.x},` + `${point.y - height})`); - await driver.delayMs(DELAYTIME01); - - // Add an ArkTs card to launcher - await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); - let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); - await serviceCard.click(); - hilog.info(DOMAIN, TAG, BUNDLE + `JS_UI_001 Start to fling cards)`); - await driver.delayMs(DELAYTIME02); - for (let i = 0; i < 4; i++) { - await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); - await driver.delayMs(DELAYTIME01); - } - // Click to add to desktop - await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); - hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 addCardToDesktop'); - await driver.delayMs(DELAYTIME02); - - // Verify that only one card has been added - let cardArkTsCountSecond = 0; - await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") - .then((data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 hilog data success'); - let result = JSON.stringify(data); - hilog.info(DOMAIN, TAG, BUNDLE + `JS_UI_001 getFormData data: ${JSON.stringify(data)}`); - cardArkTsCountSecond = result.split(cardWidgetJS).length; - }) - .catch((err: BusinessError) => { - hilog.error(DOMAIN, TAG, BUNDLE + 'JS_UI_001 hilog err is: ' + JSON.stringify(err)); - }); - - // Assert an ArkTs card has been added - hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 assert an ArkTs card has been added, ' + - 'cardArkTsCountSecond:' + cardArkTsCountSecond); - expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); - hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); - await driver.delayMs(DELAYTIME02); - done(); - }) - }) +/* + * Copyright (c) 2022-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 { abilityDelegatorRegistry, Driver, MatchPattern, ON } from '@kit.TestKit'; +import { beforeAll, describe, expect, it } from '@ohos/hypium'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +const TAG = '[Sample_ServiceCard_Test]'; +const DOMAIN = 0xF811; +const BUNDLE = 'ServiceCard_'; +const DELAYTIME01 = 1000; +const DELAYTIME02 = 2000; +const DELAYTIME03 = 3000; +let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +let resourceManager = abilityDelegator.getAppContext().resourceManager; +let cardArkTsWidgetEventRouter = 'WidgetEventRouter'; +let cardWidgetUpdateRouter = 'WidgetUpdateRouter'; +let cardWidgetUpdateCallCard = 'WidgetUpdateCall'; +let cardWidgetEventCall = 'WidgetEventCall' +let cardUpdateByMessage = 'UpdateByMessage'; +let cardAttrAnimation = 'AttrAnimation'; +let cardCustomCanvasDrawing = 'CustomCanvasDrawing'; +let cardUpdateDuration = 'UpdateDuration'; +let cardScheduledUpdateTime = 'ScheduledUpdateTime'; +let cardNextRefreshTimeCard = 'NextRefreshTime'; +let cardWidgetImageUpdate = 'WidgetImageUpdate'; +let cardWidgetUpdateByStatus = 'WidgetUpdateByStatus'; +let cardWidgetProcessData = 'WidgetProcessData'; +let cardWidgetPersistentData = 'WidgetPersistentData'; +let cardWidgetJS = 'WidgetJS'; +let driver = Driver.create(); +// Sliding coordinate +const START_SLIDING_X = 700; +const FINISH_SLIDING_X = 50; +const SLIDING_COORDINATE_Y = 300; +// Add to desktop coordinate +const ADD_TO_DESKTOP_X = 300; +const ADD_TO_DESKTOP_Y = 1200; + +export default function formTest() { + describe('ActsFormTest', () => { + beforeAll(async () => { + // Exit the test interface to execute the test case + await driver.pressHome(); + await driver.delayMs(DELAYTIME01); + }) + + /* + * @tc.number: ServiceCard_ArkTS_001 + * @tc.name: Add WidgetEventRouter cards to desktop. + * @tc.desc: Add WidgetEventRouter cards to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 begin'); + await driver.delayMs(DELAYTIME01); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_001 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardArkTsWidgetEventRouter).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_001 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_001 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME02); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_001 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 2; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.add_to_desktop')), + MatchPattern.CONTAINS)); + let addCard = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.add_to_desktop')), + MatchPattern.CONTAINS)); + await addCard.click(); + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_001 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardArkTsWidgetEventRouter).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_001 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_001 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_002 + * @tc.name: Add cardWidgetUpdateRouter card to desktop. + * @tc.desc: Add cardWidgetUpdateRouter card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_002', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_002 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardWidgetUpdateRouter).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_002 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_002 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_002 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 12; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_002 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardWidgetUpdateRouter).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_002 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_002 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_003 + * @tc.name: Add UpdateByMessage card to desktop. + * @tc.desc: Add UpdateByMessage card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_003', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_003 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardUpdateByMessage).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_003 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_003 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_003 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 3; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_003 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardUpdateByMessage).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_003 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_003 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_004 + * @tc.name: Add CustomCanvasDrawing card to desktop. + * @tc.desc: Add CustomCanvasDrawing card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_004', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_004 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardCustomCanvasDrawing).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_004 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_004 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_004 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_004 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardCustomCanvasDrawing).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_004 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_004 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_005 + * @tc.name: Add Animation card to desktop. + * @tc.desc: Add Animation card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_005', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_005 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardAttrAnimation).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_005 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_005 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_005 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 addCardToDesktop'); + await driver.delayMs(2000); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_005 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardAttrAnimation).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_005 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_005 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_006 + * @tc.name: Add WidgetUpdateByStatus card to desktop. + * @tc.desc: Add WidgetUpdateByStatus card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_006', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_006 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardWidgetUpdateByStatus).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_006 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_006 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_006 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 7; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + /// Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_006 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardWidgetUpdateByStatus).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_006 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_006 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME01); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_007 + * @tc.name: Add WidgetProcessData card to desktop. + * @tc.desc: Add WidgetProcessData card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_007', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_007 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardWidgetProcessData).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_007 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_007 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_007 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 6; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_007 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardWidgetProcessData).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_007 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_007 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME01); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_008 + * @tc.name: Add UpdateDuration card to desktop. + * @tc.desc: Add UpdateDuration card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_008', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_008 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardUpdateDuration).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_008 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_008 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_008 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 8; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_008 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardUpdateDuration).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_008 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_008 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME01); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_009 + * @tc.name: Add ScheduledUpdateTime card to desktop. + * @tc.desc: Add ScheduledUpdateTime card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_009', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_009 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardScheduledUpdateTime).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_009 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_009 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_009 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 9; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_009 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardScheduledUpdateTime).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_009 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_009 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_010 + * @tc.name: Add NextRefreshTimeCard card to desktop. + * @tc.desc: Add NextRefreshTimeCard card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_010', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_010 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardNextRefreshTimeCard).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_010 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_010 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_010 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 10; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_010 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardNextRefreshTimeCard).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_010 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_010 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_011 + * @tc.name: Add WidgetImageUpdate card to desktop. + * @tc.desc: Add WidgetImageUpdate card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_011', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_011 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardWidgetImageUpdate).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_011 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_011 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_011 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 11; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_011 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardWidgetImageUpdate).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_011 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_011 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_012 + * @tc.name: Add WidgetEventCall card to desktop. + * @tc.desc: Add WidgetEventCall card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_012', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_012 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardWidgetEventCall).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_012 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_012 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_012 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 13; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_012 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardWidgetEventCall).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_012 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_012 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_013 + * @tc.name: Add WidgetUpdateCall card to desktop. + * @tc.desc: Add WidgetUpdateCall card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_013', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_013 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardWidgetUpdateCallCard).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_013 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_013 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_013 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + + for (let i = 0; i < 14; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_013 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardWidgetUpdateCallCard).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_013 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_013 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_ArkTS_014 + * @tc.name: Add WidgetPersistentData card to desktop. + * @tc.desc: Add WidgetPersistentData card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ArkTS_014', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_014 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardWidgetPersistentData).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_014 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_014 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_014 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 5; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `ArkTS_014 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardWidgetPersistentData).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'ArkTS_014 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'ArkTS_014 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + + /* + * @tc.number: ServiceCard_JS_UI_001 + * @tc.name: Add WidgetJS card to desktop. + * @tc.desc: Add WidgetJS card to desktop. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'JS_UI_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 begin'); + await driver.delayMs(DELAYTIME03); + // Confirm the number of cards on the desktop + let cardArkTsCount = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `JS_UI_001 getFormData data: ${JSON.stringify(data)}`); + expect(result !== null).assertTrue(); + cardArkTsCount = result.split(cardWidgetJS).length - 1; + hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 cardArkTsCount:' + cardArkTsCount); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'JS_UI_001 hilog err is: ' + JSON.stringify(err)); + }); + await driver.delayMs(DELAYTIME01); + + // Long click the application + await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + let app = + await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.EntryAbility_label')), + MatchPattern.CONTAINS)); + // Get the text control border + let rect = await app.getBounds(); + // Calculate the height of the text control + let height = rect.bottom - rect.top; + // Get the center point of the text control + let point = await app.getBoundsCenter(); + await driver.longClick(point.x, point.y - height); + hilog.info(DOMAIN, TAG, BUNDLE + `JS_UI_001 long click app, coordinate:(${point.x},` + `${point.y - height})`); + await driver.delayMs(DELAYTIME01); + + // Add an ArkTs card to launcher + await driver.assertComponentExist(ON.text('服务卡片', MatchPattern.CONTAINS)); + let serviceCard = await driver.findComponent(ON.text('服务卡片', MatchPattern.CONTAINS)); + await serviceCard.click(); + hilog.info(DOMAIN, TAG, BUNDLE + `JS_UI_001 Start to fling cards)`); + await driver.delayMs(DELAYTIME02); + for (let i = 0; i < 4; i++) { + await driver.swipe(START_SLIDING_X, SLIDING_COORDINATE_Y, FINISH_SLIDING_X, SLIDING_COORDINATE_Y, DELAYTIME03); + await driver.delayMs(DELAYTIME01); + } + // Click to add to desktop + await driver.click(ADD_TO_DESKTOP_X, ADD_TO_DESKTOP_Y); + hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 addCardToDesktop'); + await driver.delayMs(DELAYTIME02); + + // Verify that only one card has been added + let cardArkTsCountSecond = 0; + await abilityDelegator.executeShellCommand("hidumper -s FormMgr -a '-n com.samples.stageservicewidgetcards'") + .then((data) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 hilog data success'); + let result = JSON.stringify(data); + hilog.info(DOMAIN, TAG, BUNDLE + `JS_UI_001 getFormData data: ${JSON.stringify(data)}`); + cardArkTsCountSecond = result.split(cardWidgetJS).length; + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, BUNDLE + 'JS_UI_001 hilog err is: ' + JSON.stringify(err)); + }); + + // Assert an ArkTs card has been added + hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 assert an ArkTs card has been added, ' + + 'cardArkTsCountSecond:' + cardArkTsCountSecond); + expect(cardArkTsCount + 1).assertEqual(cardArkTsCountSecond); + hilog.info(DOMAIN, TAG, BUNDLE + 'JS_UI_001 ' + (cardArkTsCountSecond - cardArkTsCount) + ' card has been added'); + await driver.delayMs(DELAYTIME02); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/ohosTest/module.json5 b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/ohosTest/module.json5 index 2ef997b857..7090c9c82d 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/hvigor/hvigor-config.json5 b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/hvigor/hvigor-config.json5 index 5046d5d3d2..ba6fd68095 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/hvigor/hvigor-config.json5 @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2024-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": { - } +/* + * Copyright (c) 2024-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": { + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/AppScope/app.json5 b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/AppScope/app.json5 index 524fea75c6..58e0e3fe06 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/AppScope/app.json5 +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2022-2023 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.widgetupdatebyproxy", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2022-2023 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.widgetupdatebyproxy", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/AppScope/resources/base/element/string.json b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/AppScope/resources/base/element/string.json index bdc95ce2a4..c01da4826f 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "WidgetUpdateByProxy" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "WidgetUpdateByProxy" + } + ] +} diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/build-profile.json5 b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/build-profile.json5 index 4c924ac935..ce622b8905 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/build-profile.json5 @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2022-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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 14, - "targetSdkVersion": 14, - "compatibleSdkVersion": 14, - "runtimeOS": "OpenHarmony" - } - ], - "signingConfigs": [ - - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2022-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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 14, + "targetSdkVersion": 14, + "compatibleSdkVersion": 14, + "runtimeOS": "OpenHarmony" + } + ], + "signingConfigs": [ + + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/build-profile.json5 b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/build-profile.json5 index 86224cda6f..fde30086fc 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/build-profile.json5 +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/build-profile.json5 @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2022-2023 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', - "showInServiceCenter": true, - "buildOption": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2022-2023 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', + "showInServiceCenter": true, + "buildOption": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/oh-package.json5 b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/oh-package.json5 index 220a000b93..08ac4501e6 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/oh-package.json5 @@ -1,25 +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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts index d7c9cb368a..903e3e028c 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts @@ -1,92 +1,92 @@ -/* - * Copyright (c) 2022-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 type dataSharePredicates from '@ohos.data.dataSharePredicates'; -import Extension from '@ohos.application.DataShareExtensionAbility'; -import hilog from '@ohos.hilog'; -import rdb from '@ohos.data.relationalStore'; -import type Want from '@ohos.app.ability.Want'; -import type { AsyncCallback } from '@ohos.base'; -import type { ValuesBucket } from '@ohos.data.ValuesBucket'; - -const DB_NAME = 'DB00.db'; -const TBL_NAME = 'TBL00'; -const DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' + TBL_NAME + - ' (cityId INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT)'; - -let rdbStore; -let result; -const TAG: string = 'DataShareExtAbility'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class DataShareExtAbility extends Extension { - private rdbStore_; - - // 重写onCreate接口 - async onCreate(want: Want, callback: AsyncCallback): Promise { - result = this.context.cacheDir + '/datashare.txt'; - hilog.info(DOMAIN_NUMBER, TAG, `result : ${result}`); - // 业务实现使用RDB - rdb.getRdbStore(this.context, { - name: DB_NAME, - securityLevel: rdb.SecurityLevel.S1 - }, function (err, data) { - hilog.info(DOMAIN_NUMBER, TAG, `getRdbStore done, data : ${data}`); - rdbStore = data; - rdbStore.executeSql(DDL_TBL_CREATE, [], (err) => { - hilog.info(DOMAIN_NUMBER, TAG, `DataShareExtAbility onCreate, executeSql done err: ${JSON.stringify(err)}`); - }); - }); - } - - async insert(uri: string, valueBucket: ValuesBucket, callback: Function): Promise { - if (valueBucket === null) { - hilog.error(DOMAIN_NUMBER, TAG, 'invalid valueBuckets'); - return; - } else { - hilog.info(DOMAIN_NUMBER, TAG, `valueBucket, ${JSON.stringify(valueBucket)}`); - } - - rdbStore.insert(TBL_NAME, valueBucket, (err, ret) => { - hilog.info(DOMAIN_NUMBER, TAG, `callback ret: ${ret}`, JSON.stringify(err)); - if (callback !== undefined) { - callback(err, ret); - } - }); - } - - async update(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueBucket: ValuesBucket, - callback: Function): Promise { - hilog.info(DOMAIN_NUMBER, TAG, '[ttt] [DataShareTest] <> [update] enter'); - if (predicates === null || predicates === undefined) { - hilog.info(DOMAIN_NUMBER, TAG, '[ttt] [DataShareTest] <> [update] invalid predicates'); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, `[update] values = ${valueBucket}`); - hilog.info(DOMAIN_NUMBER, TAG, `[update] [update] predicates = ${predicates}`); - try { - await rdbStore.update(TBL_NAME, valueBucket, predicates, function (err, ret) { - hilog.info(DOMAIN_NUMBER, TAG, `[update] callback ret: ${ret}`); - hilog.info(DOMAIN_NUMBER, TAG, `[update] callback err: ${err}`); - if (callback !== undefined) { - callback(err, ret); - } - }); - } catch (err) { - hilog.error(DOMAIN_NUMBER, TAG, `[update] error: ${err}`); - }; - hilog.info(DOMAIN_NUMBER, TAG, '[update] leave'); - } +/* + * Copyright (c) 2022-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 type dataSharePredicates from '@ohos.data.dataSharePredicates'; +import Extension from '@ohos.application.DataShareExtensionAbility'; +import hilog from '@ohos.hilog'; +import rdb from '@ohos.data.relationalStore'; +import type Want from '@ohos.app.ability.Want'; +import type { AsyncCallback } from '@ohos.base'; +import type { ValuesBucket } from '@ohos.data.ValuesBucket'; + +const DB_NAME = 'DB00.db'; +const TBL_NAME = 'TBL00'; +const DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' + TBL_NAME + + ' (cityId INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT)'; + +let rdbStore; +let result; +const TAG: string = 'DataShareExtAbility'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class DataShareExtAbility extends Extension { + private rdbStore_; + + // 重写onCreate接口 + async onCreate(want: Want, callback: AsyncCallback): Promise { + result = this.context.cacheDir + '/datashare.txt'; + hilog.info(DOMAIN_NUMBER, TAG, `result : ${result}`); + // 业务实现使用RDB + rdb.getRdbStore(this.context, { + name: DB_NAME, + securityLevel: rdb.SecurityLevel.S1 + }, function (err, data) { + hilog.info(DOMAIN_NUMBER, TAG, `getRdbStore done, data : ${data}`); + rdbStore = data; + rdbStore.executeSql(DDL_TBL_CREATE, [], (err) => { + hilog.info(DOMAIN_NUMBER, TAG, `DataShareExtAbility onCreate, executeSql done err: ${JSON.stringify(err)}`); + }); + }); + } + + async insert(uri: string, valueBucket: ValuesBucket, callback: Function): Promise { + if (valueBucket === null) { + hilog.error(DOMAIN_NUMBER, TAG, 'invalid valueBuckets'); + return; + } else { + hilog.info(DOMAIN_NUMBER, TAG, `valueBucket, ${JSON.stringify(valueBucket)}`); + } + + rdbStore.insert(TBL_NAME, valueBucket, (err, ret) => { + hilog.info(DOMAIN_NUMBER, TAG, `callback ret: ${ret}`, JSON.stringify(err)); + if (callback !== undefined) { + callback(err, ret); + } + }); + } + + async update(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueBucket: ValuesBucket, + callback: Function): Promise { + hilog.info(DOMAIN_NUMBER, TAG, '[ttt] [DataShareTest] <> [update] enter'); + if (predicates === null || predicates === undefined) { + hilog.info(DOMAIN_NUMBER, TAG, '[ttt] [DataShareTest] <> [update] invalid predicates'); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, `[update] values = ${valueBucket}`); + hilog.info(DOMAIN_NUMBER, TAG, `[update] [update] predicates = ${predicates}`); + try { + await rdbStore.update(TBL_NAME, valueBucket, predicates, function (err, ret) { + hilog.info(DOMAIN_NUMBER, TAG, `[update] callback ret: ${ret}`); + hilog.info(DOMAIN_NUMBER, TAG, `[update] callback err: ${err}`); + if (callback !== undefined) { + callback(err, ret); + } + }); + } catch (err) { + hilog.error(DOMAIN_NUMBER, TAG, `[update] error: ${err}`); + }; + hilog.info(DOMAIN_NUMBER, TAG, '[update] leave'); + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/ets/entryability/EntryAbility.ts index 49d5e00818..588996f655 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2022-2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import type Want from '@ohos.app.ability.Want'; -import type window from '@ohos.window'; - -const TAG: string = 'EntryAbility'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } +/* + * Copyright (c) 2022-2023 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 type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import type Want from '@ohos.app.ability.Want'; +import type window from '@ohos.window'; + +const TAG: string = 'EntryAbility'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/module.json5 b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/module.json5 index ee02e886d2..676d3ccf41 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/module.json5 +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/module.json5 @@ -1,112 +1,112 @@ -/* - * Copyright (c) 2022-2023 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "DataShareExtAbility", - "srcEntry": "./ets/DataShareExtAbility/DataShareExtAbility.ts", - "icon": "$media:icon", - "description": "$string:description_datashareextability", - "type": "dataShare", - "uri": "datashare://com.samples.widgetupdatebyproxy.DataShare", - "exported": true, - "metadata": [ - { - "name": "ohos.extension.dataShare", - "resource": "$profile:data_share_config" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO", - }, - { - "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" - }, - { - "name": "ohos.permission.START_INVISIBLE_ABILITY" - }, - { - "name": "ohos.permission.INTERNET", - "usedScene": { - "abilities": [ - "WgtImgUpdateEntryFormAbility" - ], - "when": "inuse", - } - } - ], - "proxyData": [ - { - "uri": "datashareproxy://com.samples.widgetupdatebyproxy/test", - "requiredReadPermission": "ohos.permission.GET_BUNDLE_INFO", - "requiredWritePermission": "ohos.permission.KEEP_BACKGROUND_RUNNING", - "metadata": { - "name": "dataProperties", - "resource": "$profile:my_config" - } - }, - { - "uri": "datashareproxy://com.samples.widgetupdatebyproxy/weather", - "requiredReadPermission": "ohos.permission.GET_BUNDLE_INFO", - "requiredWritePermission": "ohos.permission.KEEP_BACKGROUND_RUNNING", - "metadata": { - "name": "dataProperties", - "resource": "$profile:my_config" - } - } - ] - } +/* + * Copyright (c) 2022-2023 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "DataShareExtAbility", + "srcEntry": "./ets/DataShareExtAbility/DataShareExtAbility.ts", + "icon": "$media:icon", + "description": "$string:description_datashareextability", + "type": "dataShare", + "uri": "datashare://com.samples.widgetupdatebyproxy.DataShare", + "exported": true, + "metadata": [ + { + "name": "ohos.extension.dataShare", + "resource": "$profile:data_share_config" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO", + }, + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" + }, + { + "name": "ohos.permission.START_INVISIBLE_ABILITY" + }, + { + "name": "ohos.permission.INTERNET", + "usedScene": { + "abilities": [ + "WgtImgUpdateEntryFormAbility" + ], + "when": "inuse", + } + } + ], + "proxyData": [ + { + "uri": "datashareproxy://com.samples.widgetupdatebyproxy/test", + "requiredReadPermission": "ohos.permission.GET_BUNDLE_INFO", + "requiredWritePermission": "ohos.permission.KEEP_BACKGROUND_RUNNING", + "metadata": { + "name": "dataProperties", + "resource": "$profile:my_config" + } + }, + { + "uri": "datashareproxy://com.samples.widgetupdatebyproxy/weather", + "requiredReadPermission": "ohos.permission.GET_BUNDLE_INFO", + "requiredWritePermission": "ohos.permission.KEEP_BACKGROUND_RUNNING", + "metadata": { + "name": "dataProperties", + "resource": "$profile:my_config" + } + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/element/color.json b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/element/color.json index afc173f8d5..074928deab 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/element/color.json @@ -1,12 +1,12 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "text_font_color", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "text_font_color", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/element/float.json b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/element/float.json index edb7816076..d50ddbfab2 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/element/float.json +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/element/float.json @@ -1,28 +1,28 @@ -{ - "float": [ - { - "name": "title_immersive_font_size", - "value": "19fp" - }, - { - "name": "detail_immersive_font_size", - "value": "16fp" - }, - { - "name": "detail_immersive_margin_top", - "value": "6vp" - }, - { - "name": "detail_immersive_opacity", - "value": "0.66" - }, - { - "name": "column_padding", - "value": "12vp" - }, - { - "name": "font_size", - "value": "16fp" - } - ] +{ + "float": [ + { + "name": "title_immersive_font_size", + "value": "19fp" + }, + { + "name": "detail_immersive_font_size", + "value": "16fp" + }, + { + "name": "detail_immersive_margin_top", + "value": "6vp" + }, + { + "name": "detail_immersive_opacity", + "value": "0.66" + }, + { + "name": "column_padding", + "value": "12vp" + }, + { + "name": "font_size", + "value": "16fp" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/profile/data_share_config.json b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/profile/data_share_config.json index 6ed549c101..d014aa3fcd 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/profile/data_share_config.json +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/profile/data_share_config.json @@ -1,16 +1,16 @@ -{ - "tableConfig": [ - { - "uri": "*", - "crossUserMode": 1 - }, - { - "uri": "datashareproxy://com.samples.widgetupdatebyproxy/entry/DB00", - "crossUserMode": 1 - }, - { - "uri": "datashareproxy://com.samples.widgetupdatebyproxy/entry/DB00/TBL00", - "crossUserMode": 2 - } - ] +{ + "tableConfig": [ + { + "uri": "*", + "crossUserMode": 1 + }, + { + "uri": "datashareproxy://com.samples.widgetupdatebyproxy/entry/DB00", + "crossUserMode": 1 + }, + { + "uri": "datashareproxy://com.samples.widgetupdatebyproxy/entry/DB00/TBL00", + "crossUserMode": 2 + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/profile/my_config.json b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/profile/my_config.json index ff029cea65..c48ee18052 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/profile/my_config.json +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/main/resources/base/profile/my_config.json @@ -1,5 +1,5 @@ -{ - "path": "DB00/TBL00", - "type": "rdb", - "scope": "application" +{ + "path": "DB00/TBL00", + "type": "rdb", + "scope": "application" } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/ohosTest/module.json5 b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/ohosTest/module.json5 index c3051ee7a3..075f09072e 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/hvigor/hvigor-config.json5 b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/hvigor/hvigor-config.json5 index 5046d5d3d2..ba6fd68095 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/hvigor/hvigor-config.json5 @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2024-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": { - } +/* + * Copyright (c) 2024-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": { + } } \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/oh-package.json5 b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/oh-package.json5 index d88534a412..63689954a1 100644 --- a/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/oh-package.json5 +++ b/code/DocsSample/ApplicationModels/WidgetUpdateByProxy/oh-package.json5 @@ -1,13 +1,13 @@ -{ - "modelVersion": "5.0.0", - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "widgetupdatebyproxy", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} +{ + "modelVersion": "5.0.0", + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "widgetupdatebyproxy", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/app.json5 new file mode 100644 index 0000000000..78ddc4311e --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/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.dynamicimport", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..5b7aa338c6 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "DynamicImport" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/README.md b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/README.md new file mode 100644 index 0000000000..c84429cdb5 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/README.md @@ -0,0 +1,111 @@ +# ArkTS动态加载 + +### 介绍 + +动态import支持条件延迟加载,支持部分反射功能,可以提升页面的加载速度;动态import支持加载HSP模块/HAR模块/OHPM包/Native库等,并且HAR模块间只有变量动态import时还可以进行模块解耦 + +本示例主要展示了动态加载的业务拓展场景介绍、动态加载常量表达式、动态加载变量表达式以及HAR模块间动态加载依赖解耦这些场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [动态加载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-dynamic-import.md) + +### 效果预览 + +| 执行结果图 | +| ------------------------------------------------------------ | +| | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,分别点击ListItem组件可以执行对应文本内容的操作,然后在控制台中打印出对应日志。 +3. 运行测试用例DynamicImport.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 动态加载示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── DynamicImport.test.ets // 自动化测试代码 + │ │ └── List.test.ets + har1 // har1模块函数实现 + ├── src + │ ├── main + │ │ ├── ets + │ │ │ ├── utils + │ │ │ │ └── Calc.ets + │ │ │ └── components + │ │ │ │ └── MainPage.ets + har2 // har1模块函数实现 + ├── src + │ ├── main + │ │ ├── ets + │ │ │ ├── utils + │ │ │ │ └── Calc.ets + │ │ │ └── components + │ │ │ │ └── MainPage.ets + ├── index.ets + harlibrary // harlibrary模块函数实现 + ├── src + │ ├── main + │ │ ├── ets + │ │ │ ├── utils + │ │ │ │ └── Calc.ets + │ │ │ └── components + │ │ │ │ └── MainPage.ets + ├── index.ets + myHar // myHar模块函数实现 + ├── src + │ ├── main + │ │ ├── ets + │ │ │ └── components + │ │ │ │ └── MainPage.ets + ├── index.ets + myHsp // myHsp模块函数实现 + ├── src + │ ├── main + │ │ ├── ets + │ │ │ ├── pages + │ │ │ │ └── Index.ets + │ │ │ └── utils + │ │ │ │ └── Calc.ets + ├── index.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport > .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/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/build-profile.json5 new file mode 100644 index 0000000000..feb4b2f6e8 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/build-profile.json5 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "harlibrary", + "srcPath": "./harlibrary", + }, + { + "name": "myHar", + "srcPath": "./myHar", + }, + { + "name": "myHsp", + "srcPath": "./myHsp", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "har1", + "srcPath": "./har1", + }, + { + "name": "har2", + "srcPath": "./har2", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/code-linter.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/code-linter.json5 rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/code-linter.json5 diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/build-profile.json5 new file mode 100644 index 0000000000..6dae4488bd --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/build-profile.json5 @@ -0,0 +1,81 @@ +/* + * 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": { + "arkOptions": { + "runtimeOnly": { + "packages": [ + "myhar", + // 仅用于使用变量动态import其他模块名场景,静态import或常量动态import无需配置。 + "myhsp", + // 仅用于使用变量动态import其他模块名场景,静态import或常量动态import无需配置。 + "@ohos/hypium", + "@ohos/crypto-js", + "libentry.so", + "har1", + "har2" + ], + // 配置本模块变量动态import其他模块名,要求与dependencies中配置的名字一致。 + "sources": [ + // 仅用于使用变量动态import模块自己单文件场景,静态import或常量动态import无需配置。 + "./src/main/ets/utils/Calc.ets", + "./src/main/ets/Calc.ets" + ] + // 配置本模块变量动态import自己的文件路径,路径相对于当前build-profile.json5文件。 + } + }, + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "arm64-v8a", + "x86_64", + "armeabi-v7a" + ] + }, + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + } + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/oh-package.json5 new file mode 100644 index 0000000000..76e9a20fd2 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/oh-package.json5 @@ -0,0 +1,38 @@ +/* + * 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": { + "harlibrary": "file:../harlibrary", + "myhar": "file:../myHar", + //HAP常量动态import HAR模块名 HAP常量动态import HAR模块文件路径 + "myhsp": "file:../myHsp", + //HAP常量动态import HSP模块名 HAP常量动态import HSP模块名文件路径 + "@ohos/crypto-js": "2.0.3-rc.0", + //HAP常量动态import远程HAR模块名 + "@ohos/hypium": "1.0.19", + //HAP常量动态import ohpm包 + "libentry.so": "file:./src/main/cpp/types/libentry", + //HAP常量动态import自己的Native库 + "har1": "file:../har1", + "har2": "file:../har2" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..9042897daf --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,15 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(DynamicImport) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..3b0593c2c0 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + double value0; + napi_get_value_double(env, args[0], &value0); + double value1; + napi_get_value_double(env, args[1], &value1); + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/index.d.ts new file mode 100644 index 0000000000..914e7b4167 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start hap_const_dynamic_import_native] +export const add: (a: number, b: number) => number; +// [End hap_const_dynamic_import_native] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..2826cc7d6b --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/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/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/Calc.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/Calc.ets new file mode 100644 index 0000000000..e9a691411d --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/Calc.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. + */ + +// [Start hap_const_dynamic_import_add] +export function add(a: number, b: number): number { + let c = a + b; + console.info('DynamicImport I am a HAP, %d + %d = %d', a, b, c); + return c; +} +// [End hap_const_dynamic_import_add] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..edc2839f20 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/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/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Calc.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Calc.ets new file mode 100644 index 0000000000..3cba60bf37 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Calc.ets @@ -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. + */ + +export function add(a: number, b: number): number { + let c = a + b; + console.info('DynamicImport I am a HAP, %d + %d = %d', a, b, c); + return c; +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/utils/Calc.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/utils/Calc.ets new file mode 100644 index 0000000000..3cba60bf37 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/utils/Calc.ets @@ -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. + */ + +export function add(a: number, b: number): number { + let c = a + b; + console.info('DynamicImport I am a HAP, %d + %d = %d', a, b, c); + return c; +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/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/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/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/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/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/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/DynamicImport.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/DynamicImport.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/DynamicImport.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/DynamicImport.test.ets index bb30af241a..bc0df7fe9a --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/DynamicImport.test.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/DynamicImport.test.ets @@ -1,228 +1,228 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; - -export default function dynamicImportTest() { - describe('dynamicImportTest', () => { - - it('testDynamicImport001', 0, async () => { - console.info('uitest: testDynamicImport001 begin'); - let har: ESObject = await import('harlibrary'); - expect(har.Calc.staticAdd(8, 9)).assertEqual(17); - let calc: ESObject = new har.Calc(); - expect(calc.instanceAdd(10, 11)).assertEqual(21); - expect(har.addHarlibrary(6, 7)).assertEqual(13); - - let className = 'Calc'; - let methodName = 'instanceAdd'; - let staticMethod = 'staticAdd'; - let functionName = 'addHarlibrary'; - expect(har[className][staticMethod](12, 13)).assertEqual(25); - let calc1: ESObject = new har[className](); - expect(calc1[methodName](14, 15)).assertEqual(29); - expect(har[functionName](16, 17)).assertEqual(33); - console.info('uitest: testDynamicImport001 end'); - }) - - it('testDynamicImport002', 0, async () => { - console.info('uitest: testDynamicImport002 begin'); - let har: ESObject = await import('myhar'); - expect(har.add(2, 3)).assertEqual(5); - console.info('uitest: testDynamicImport002 end'); - }) - - it('testDynamicImport003', 0, async () => { - console.info('uitest: testDynamicImport003 begin'); - let har: ESObject = await import('myhar/Index'); - expect(har.add(2, 3)).assertEqual(5); - console.info('uitest: testDynamicImport003 end'); - }) - - it('testDynamicImport004', 0, async () => { - console.info('uitest: testDynamicImport004 begin'); - let hsp: ESObject = await import('myhsp'); - expect(hsp.add(2, 3)).assertEqual(5); - console.info('uitest: testDynamicImport004 end'); - }) - - it('testDynamicImport005', 0, async () => { - console.info('uitest: testDynamicImport005 begin'); - let hsp: ESObject = await import('myhsp/Index'); - expect(hsp.add(2, 3)).assertEqual(5); - console.info('uitest: testDynamicImport005 end'); - }) - - it('testDynamicImport006', 0, async () => { - console.info('uitest: testDynamicImport006 begin'); - let har: ESObject = await import('@ohos/crypto-js'); - expect(har.CryptoJS.src).assertUndefined(); - console.info('uitest: testDynamicImport006 end'); - }) - - it('testDynamicImport007', 0, async () => { - console.info('uitest: testDynamicImport007 begin'); - let ohpm: ESObject = await import('@ohos/hypium'); - expect(ohpm.TestType.FUNCTION).assertEqual(1); - console.info('uitest: testDynamicImport007 end'); - }) - - it('testDynamicImport008', 0, async () => { - console.info('uitest: testDynamicImport008 begin'); - let singleFile: ESObject = await import('../../../../src/main/ets/Calc'); - expect(singleFile.add(3, 5)).assertEqual(8); - console.info('uitest: testDynamicImport008 end'); - }) - - it('testDynamicImport009', 0, async () => { - console.info('uitest: testDynamicImport009 begin'); - let native: ESObject = await import('libentry.so'); - expect(native.default.add(2, 3)).assertEqual(5); - console.info('uitest: testDynamicImport009 end'); - }) - - it('testDynamicImport010', 0, async () => { - console.info('uitest: testDynamicImport010 begin'); - let systemApp: ESObject = await import('@system.app'); - expect(systemApp.default.getInfo()).assertNull(); - console.info('uitest: testDynamicImport010 end'); - }) - - it('testDynamicImport011', 0, async () => { - console.info('uitest: testDynamicImport011 begin'); - let curves: ESObject = await import('@ohos.curves'); - expect(curves.default.springMotion(0.555, 0.75, 0.001).interpolate(1)).assertEqual(0); - console.info('uitest: testDynamicImport011 end'); - }) - - it('testDynamicImport012', 0, async () => { - console.info('uitest: testDynamicImport012 begin'); - let matrix4: ESObject = await import('@ohos.matrix4'); - expect(matrix4.default.identity().transformPoint([1, 2])[0]).assertEqual(1); - console.info('uitest: testDynamicImport012 end'); - }) - - it('testDynamicImport013', 0, async () => { - console.info('uitest: testDynamicImport013 begin'); - let hilog: ESObject = await import('@ohos.hilog'); - expect(hilog.default.LogLevel.DEBUG).assertEqual(3); - console.info('uitest: testDynamicImport013 end'); - }) - - it('testDynamicImport014', 0, async () => { - console.info('uitest: testDynamicImport014 begin'); - let harName = 'myhar'; - let har: ESObject = await import(harName); - expect(har.add(3, 5)).assertEqual(8); - console.info('uitest: testDynamicImport014 end'); - }) - - it('testDynamicImport015', 0, async () => { - console.info('uitest: testDynamicImport015 begin'); - let filePath = '../../../main/ets/utils/Calc'; - let file: ESObject = await import(filePath); - expect(file.add(3, 5)).assertEqual(8); - console.info('uitest: testDynamicImport015 end'); - }) - - it('testDynamicImport016', 0, async () => { - console.info('uitest: testDynamicImport016 begin'); - let harPackageName = 'myhar'; - let har: ESObject = await import(harPackageName); - expect(har.add(3, 5)).assertEqual(8); - console.info('uitest: testDynamicImport016 end'); - }) - - it('testDynamicImport017', 0, async () => { - console.info('uitest: testDynamicImport017 begin'); - let hspPackageName = 'myhsp'; - let hsp: ESObject = await import(hspPackageName); - expect(hsp.add(3, 5)).assertEqual(8); - console.info('uitest: testDynamicImport017 end'); - }) - - it('testDynamicImport018', 0, async () => { - console.info('uitest: testDynamicImport018 begin'); - let remoteHarPackageName = '@ohos/crypto-js'; - let har: ESObject = await import(remoteHarPackageName); - expect(har.CryptoJS.src).assertUndefined(); - console.info('uitest: testDynamicImport018 end'); - }) - - it('testDynamicImport019', 0, async () => { - console.info('uitest: testDynamicImport019 begin'); - let ohpmPackageName = '@ohos/hypium'; - let ohpm: ESObject = await import(ohpmPackageName); - expect(ohpm.TestType.FUNCTION).assertEqual(1); - console.info('uitest: testDynamicImport019 end'); - }) - - it('testDynamicImport020', 0, async () => { - console.info('uitest: testDynamicImport020 begin'); - let calcFilePath = '../../../../src/main/ets/Calc'; - let singleFile: ESObject = await import(calcFilePath); - expect(singleFile.add(3, 5)).assertEqual(8); - console.info('uitest: testDynamicImport020 end'); - }) - - it('testDynamicImport021', 0, async () => { - console.info('uitest: testDynamicImport021 begin'); - let soName = 'libentry.so'; - let native: ESObject = await import(soName); - expect(native.default.add(2, 3)).assertEqual(5); - console.info('uitest: testDynamicImport021 end'); - }) - - it('testDynamicImport022', 0, async () => { - console.info('uitest: testDynamicImport022 begin'); - let packageName = '@system.app'; - let systemApp: ESObject = await import(packageName); - expect(systemApp.default.getInfo()).assertNull(); - console.info('uitest: testDynamicImport022 end'); - }) - - it('testDynamicImport023', 0, async () => { - console.info('uitest: testDynamicImport023 begin'); - let packageName = '@ohos.curves'; - let curves: ESObject = await import(packageName); - expect(curves.default.springMotion(0.555, 0.75, 0.001).interpolate(1)).assertEqual(0); - console.info('uitest: testDynamicImport023 end'); - }) - - it('testDynamicImport024', 0, async () => { - console.info('uitest: testDynamicImport024 begin'); - let packageName = '@ohos.matrix4'; - let matrix4: ESObject = await import(packageName); - expect(matrix4.default.identity().transformPoint([1, 2])[0]).assertEqual(1); - console.info('uitest: testDynamicImport024 end'); - }) - - it('testDynamicImport025', 0, async () => { - console.info('uitest: testDynamicImport025 begin'); - let packageName = '@ohos.hilog'; - let hilog: ESObject = await import(packageName); - expect(hilog.default.LogLevel.DEBUG).assertEqual(3); - console.info('uitest: testDynamicImport025 end'); - }) - - it('testDynamicImport026', 0, async () => { - console.info('uitest: testDynamicImport026 begin'); - let harName = 'har1'; - let har: ESObject = await import(harName); - expect(har.addHar1(4, 5)).assertEqual(9); - console.info('uitest: testDynamicImport026 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium'; + +export default function dynamicImportTest() { + describe('dynamicImportTest', () => { + + it('testDynamicImport001', 0, async () => { + console.info('uitest: testDynamicImport001 begin'); + let har: ESObject = await import('harlibrary'); + expect(har.Calc.staticAdd(8, 9)).assertEqual(17); + let calc: ESObject = new har.Calc(); + expect(calc.instanceAdd(10, 11)).assertEqual(21); + expect(har.addHarlibrary(6, 7)).assertEqual(13); + + let className = 'Calc'; + let methodName = 'instanceAdd'; + let staticMethod = 'staticAdd'; + let functionName = 'addHarlibrary'; + expect(har[className][staticMethod](12, 13)).assertEqual(25); + let calc1: ESObject = new har[className](); + expect(calc1[methodName](14, 15)).assertEqual(29); + expect(har[functionName](16, 17)).assertEqual(33); + console.info('uitest: testDynamicImport001 end'); + }) + + it('testDynamicImport002', 0, async () => { + console.info('uitest: testDynamicImport002 begin'); + let har: ESObject = await import('myhar'); + expect(har.add(2, 3)).assertEqual(5); + console.info('uitest: testDynamicImport002 end'); + }) + + it('testDynamicImport003', 0, async () => { + console.info('uitest: testDynamicImport003 begin'); + let har: ESObject = await import('myhar/Index'); + expect(har.add(2, 3)).assertEqual(5); + console.info('uitest: testDynamicImport003 end'); + }) + + it('testDynamicImport004', 0, async () => { + console.info('uitest: testDynamicImport004 begin'); + let hsp: ESObject = await import('myhsp'); + expect(hsp.add(2, 3)).assertEqual(5); + console.info('uitest: testDynamicImport004 end'); + }) + + it('testDynamicImport005', 0, async () => { + console.info('uitest: testDynamicImport005 begin'); + let hsp: ESObject = await import('myhsp/Index'); + expect(hsp.add(2, 3)).assertEqual(5); + console.info('uitest: testDynamicImport005 end'); + }) + + it('testDynamicImport006', 0, async () => { + console.info('uitest: testDynamicImport006 begin'); + let har: ESObject = await import('@ohos/crypto-js'); + expect(har.CryptoJS.src).assertUndefined(); + console.info('uitest: testDynamicImport006 end'); + }) + + it('testDynamicImport007', 0, async () => { + console.info('uitest: testDynamicImport007 begin'); + let ohpm: ESObject = await import('@ohos/hypium'); + expect(ohpm.TestType.FUNCTION).assertEqual(1); + console.info('uitest: testDynamicImport007 end'); + }) + + it('testDynamicImport008', 0, async () => { + console.info('uitest: testDynamicImport008 begin'); + let singleFile: ESObject = await import('../../../../src/main/ets/Calc'); + expect(singleFile.add(3, 5)).assertEqual(8); + console.info('uitest: testDynamicImport008 end'); + }) + + it('testDynamicImport009', 0, async () => { + console.info('uitest: testDynamicImport009 begin'); + let native: ESObject = await import('libentry.so'); + expect(native.default.add(2, 3)).assertEqual(5); + console.info('uitest: testDynamicImport009 end'); + }) + + it('testDynamicImport010', 0, async () => { + console.info('uitest: testDynamicImport010 begin'); + let systemApp: ESObject = await import('@system.app'); + expect(systemApp.default.getInfo()).assertNull(); + console.info('uitest: testDynamicImport010 end'); + }) + + it('testDynamicImport011', 0, async () => { + console.info('uitest: testDynamicImport011 begin'); + let curves: ESObject = await import('@ohos.curves'); + expect(curves.default.springMotion(0.555, 0.75, 0.001).interpolate(1)).assertEqual(0); + console.info('uitest: testDynamicImport011 end'); + }) + + it('testDynamicImport012', 0, async () => { + console.info('uitest: testDynamicImport012 begin'); + let matrix4: ESObject = await import('@ohos.matrix4'); + expect(matrix4.default.identity().transformPoint([1, 2])[0]).assertEqual(1); + console.info('uitest: testDynamicImport012 end'); + }) + + it('testDynamicImport013', 0, async () => { + console.info('uitest: testDynamicImport013 begin'); + let hilog: ESObject = await import('@ohos.hilog'); + expect(hilog.default.LogLevel.DEBUG).assertEqual(3); + console.info('uitest: testDynamicImport013 end'); + }) + + it('testDynamicImport014', 0, async () => { + console.info('uitest: testDynamicImport014 begin'); + let harName = 'myhar'; + let har: ESObject = await import(harName); + expect(har.add(3, 5)).assertEqual(8); + console.info('uitest: testDynamicImport014 end'); + }) + + it('testDynamicImport015', 0, async () => { + console.info('uitest: testDynamicImport015 begin'); + let filePath = '../../../main/ets/utils/Calc'; + let file: ESObject = await import(filePath); + expect(file.add(3, 5)).assertEqual(8); + console.info('uitest: testDynamicImport015 end'); + }) + + it('testDynamicImport016', 0, async () => { + console.info('uitest: testDynamicImport016 begin'); + let harPackageName = 'myhar'; + let har: ESObject = await import(harPackageName); + expect(har.add(3, 5)).assertEqual(8); + console.info('uitest: testDynamicImport016 end'); + }) + + it('testDynamicImport017', 0, async () => { + console.info('uitest: testDynamicImport017 begin'); + let hspPackageName = 'myhsp'; + let hsp: ESObject = await import(hspPackageName); + expect(hsp.add(3, 5)).assertEqual(8); + console.info('uitest: testDynamicImport017 end'); + }) + + it('testDynamicImport018', 0, async () => { + console.info('uitest: testDynamicImport018 begin'); + let remoteHarPackageName = '@ohos/crypto-js'; + let har: ESObject = await import(remoteHarPackageName); + expect(har.CryptoJS.src).assertUndefined(); + console.info('uitest: testDynamicImport018 end'); + }) + + it('testDynamicImport019', 0, async () => { + console.info('uitest: testDynamicImport019 begin'); + let ohpmPackageName = '@ohos/hypium'; + let ohpm: ESObject = await import(ohpmPackageName); + expect(ohpm.TestType.FUNCTION).assertEqual(1); + console.info('uitest: testDynamicImport019 end'); + }) + + it('testDynamicImport020', 0, async () => { + console.info('uitest: testDynamicImport020 begin'); + let calcFilePath = '../../../../src/main/ets/Calc'; + let singleFile: ESObject = await import(calcFilePath); + expect(singleFile.add(3, 5)).assertEqual(8); + console.info('uitest: testDynamicImport020 end'); + }) + + it('testDynamicImport021', 0, async () => { + console.info('uitest: testDynamicImport021 begin'); + let soName = 'libentry.so'; + let native: ESObject = await import(soName); + expect(native.default.add(2, 3)).assertEqual(5); + console.info('uitest: testDynamicImport021 end'); + }) + + it('testDynamicImport022', 0, async () => { + console.info('uitest: testDynamicImport022 begin'); + let packageName = '@system.app'; + let systemApp: ESObject = await import(packageName); + expect(systemApp.default.getInfo()).assertNull(); + console.info('uitest: testDynamicImport022 end'); + }) + + it('testDynamicImport023', 0, async () => { + console.info('uitest: testDynamicImport023 begin'); + let packageName = '@ohos.curves'; + let curves: ESObject = await import(packageName); + expect(curves.default.springMotion(0.555, 0.75, 0.001).interpolate(1)).assertEqual(0); + console.info('uitest: testDynamicImport023 end'); + }) + + it('testDynamicImport024', 0, async () => { + console.info('uitest: testDynamicImport024 begin'); + let packageName = '@ohos.matrix4'; + let matrix4: ESObject = await import(packageName); + expect(matrix4.default.identity().transformPoint([1, 2])[0]).assertEqual(1); + console.info('uitest: testDynamicImport024 end'); + }) + + it('testDynamicImport025', 0, async () => { + console.info('uitest: testDynamicImport025 begin'); + let packageName = '@ohos.hilog'; + let hilog: ESObject = await import(packageName); + expect(hilog.default.LogLevel.DEBUG).assertEqual(3); + console.info('uitest: testDynamicImport025 end'); + }) + + it('testDynamicImport026', 0, async () => { + console.info('uitest: testDynamicImport026 begin'); + let harName = 'har1'; + let har: ESObject = await import(harName); + expect(har.addHar1(4, 5)).assertEqual(9); + console.info('uitest: testDynamicImport026 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/Index.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/Index.ets new file mode 100644 index 0000000000..99b93d0d0b --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/Index.ets @@ -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. + */ + +export { MainPage } from './src/main/ets/components/MainPage'; + +// [Start export_add_har1] +export { addHar1 } from './src/main/ets/utils/Calc'; +// [End export_add_har1] diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/build-profile.json5 new file mode 100644 index 0000000000..aefa5f6959 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/build-profile.json5 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/oh-package.json5 new file mode 100644 index 0000000000..24a5f32b5a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "har1", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000..7dc1a0d257 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/components/MainPage.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/utils/Calc.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/utils/Calc.ets new file mode 100644 index 0000000000..ad7bec2228 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/utils/Calc.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. + */ + +// [Start function_add_har1] +export function addHar1(a: number, b: number): number { + let c = a + b; + console.info('DynamicImport I am har1, %d + %d = %d', a, b, c); + + let harName = 'har2'; + import(harName).then((ns: ESObject) => { + console.info('DynamicImport addHar2 4 + 5 = ' + ns.addHar2(4, 5)); + }); + return c; +} +// [End function_add_har1] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/module.json5 new file mode 100644 index 0000000000..f14a04c447 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "har1", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/module.json5 new file mode 100644 index 0000000000..acef8e5105 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "har1_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/Index.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/Index.ets new file mode 100644 index 0000000000..63672b2a46 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/Index.ets @@ -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. + */ + +export { MainPage } from './src/main/ets/components/MainPage'; + +// [Start export_add_har2] +export { addHar2 } from './src/main/ets/utils/Calc' +// [End export_add_har2] diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/build-profile.json5 new file mode 100644 index 0000000000..aefa5f6959 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/build-profile.json5 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/oh-package.json5 new file mode 100644 index 0000000000..d778bf2ab9 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "har2", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000..7dc1a0d257 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/components/MainPage.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/utils/Calc.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/utils/Calc.ets new file mode 100644 index 0000000000..72e3c50f49 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/utils/Calc.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. + */ + +// [Start function_add_har2] +export function addHar2(a: number, b: number): number { + let c = a + b; + console.info('DynamicImport I am har2, %d + %d = %d', a, b, c); + return c; +} +// [End function_add_har2] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/module.json5 new file mode 100644 index 0000000000..cadd1c0171 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "har2", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/module.json5 new file mode 100644 index 0000000000..280914cdf0 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "har2_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/Index.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/Index.ets new file mode 100644 index 0000000000..9b782d958c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/Index.ets @@ -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. + */ + +export { MainPage } from './src/main/ets/components/MainPage' + +// [Start module_members_export] +export { Calc, addHarlibrary } from './src/main/ets/utils/Calc' +// [End module_members_export] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/build-profile.json5 new file mode 100644 index 0000000000..aefa5f6959 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/build-profile.json5 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/oh-package.json5 new file mode 100644 index 0000000000..fb0db50295 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "harlibrary", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000..7dc1a0d257 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/components/MainPage.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/utils/Calc.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/utils/Calc.ets new file mode 100644 index 0000000000..cc34273737 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/utils/Calc.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start dynamic_call_add] +export class Calc { + public static staticAdd(a: number, b: number): number { + let c = a + b; + console.info('DynamicImport I am harlibrary in staticAdd, %d + %d = %d', a, b, c); + return c; + } + + public instanceAdd(a: number, b: number): number { + let c = a + b; + console.info('DynamicImport I am harlibrary in instanceAdd, %d + %d = %d', a, b, c); + return c; + } +} + +export function addHarlibrary(a: number, b: number): number { + let c = a + b; + console.info('DynamicImport I am harlibrary in addHarlibrary, %d + %d = %d', a, b, c); + return c; +} +// [End dynamic_call_add] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/module.json5 new file mode 100644 index 0000000000..6b2ff2e561 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "harlibrary", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/module.json5 new file mode 100644 index 0000000000..8d8baae08c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "harlibrary_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/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.1", + "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/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/Index.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/Index.ets new file mode 100644 index 0000000000..c7e6b0d1aa --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/Index.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { MainPage } from './src/main/ets/components/MainPage' + +// [Start const_dynamic_import_har] +export function add(a: number, b: number): number { + let c = a + b; + console.info('DynamicImport I am a HAR, %d + %d = %d', a, b, c); + return c; +} +// [End const_dynamic_import_har] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/build-profile.json5 new file mode 100644 index 0000000000..aefa5f6959 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/build-profile.json5 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/oh-package.json5 new file mode 100644 index 0000000000..d3bb3dc439 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "myhar", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000..7dc1a0d257 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/ets/components/MainPage.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/module.json5 new file mode 100644 index 0000000000..a48a33b6c9 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "myHar", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/module.json5 new file mode 100644 index 0000000000..ad42bd787b --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "myHar_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/Index.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/Index.ets new file mode 100644 index 0000000000..b5c710086a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/Index.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. + */ + +// [Start const_dynamic_import_hsp] +export function add(a: number, b: number): number { + let c = a + b; + console.info('DynamicImport I am a HSP, %d + %d = %d', a, b, c); + return c; +} +// [End const_dynamic_import_hsp] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/build-profile.json5 new file mode 100644 index 0000000000..4b63399df4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/oh-package.json5 new file mode 100644 index 0000000000..fafa5e8a4d --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/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": "myhsp", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "packageType": "InterfaceHar", + "dependencies": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/ets/utils/Calc.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/ets/utils/Calc.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/ets/utils/Calc.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/ets/utils/Calc.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/module.json5 new file mode 100644 index 0000000000..3605312132 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "myHsp", + "type": "shared", + "description": "$string:shared_desc", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "pages": "$profile:main_pages" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..98e1d8a84b --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "shared_desc", + "value": "description" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/module.json5 new file mode 100644 index 0000000000..06e0923828 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "myHsp_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/ohosTest.md b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/ohosTest.md new file mode 100644 index 0000000000..e1a49c74cf --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/ohosTest.md @@ -0,0 +1,27 @@ +# 动态加载测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------------- | ------------ | ---- | ---------------------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 动态加载harlibrary模块调用函数 | 成功拉起应用 | | 输出日志 | 是 | Pass | +| HAP常量动态import HAR模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP常量动态import HAR模块文件路径 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP常量动态import HSP模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP常量动态import HSP模块名文件路径 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP常量动态import远程HAR模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP常量动态import ohpm包 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP常量动态import自己的单文件 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP常量动态import自己的Native库 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP常量动态import加载API | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP变量动态import HAR模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP变量动态import HAR模块文件路径 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP变量动态import HSP模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP变量动态import HSP模块名文件路径 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP变量动态import远程HAR模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP变量动态import ohpm包 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP变量动态import自己的单文件 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP变量动态import自己的Native库 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| HAP变量动态import加载API | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | +| 动态加载耦合har包 | 成功拉起应用 | | 加载har1可以调用har2函数并打印日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/screenshots/DynamicImport.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/screenshots/DynamicImport.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/screenshots/DynamicImport.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/screenshots/DynamicImport.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/app.json5 new file mode 100644 index 0000000000..575ac506f5 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/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.jsapisloadnativemodule", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..ffe5bc881d --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsApisLoadNativeModule" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/README.md b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/README.md new file mode 100644 index 0000000000..ae2360ed70 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/README.md @@ -0,0 +1,73 @@ +# ArkTS同步方式动态加载native模块 + +### 介绍 + +本工程主要展示了使用loadNativeModule接口能力进行同步方式加载native模块。该工程中展示的代码详细描述可查如下链接部分。 + +- [同步方式动态加载native模块](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/js-apis-load-native-module.md) + +### 效果预览 + +| 首页 | 点击HAP加载系统库模块按钮后 | 点击HAP加载Native库按钮后 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面中Text组件文本呈现LoadNativeModule效果并有两个按钮,分别点击之后第两个个按钮Text文本变化如上图并在工作台打印日志。 +3. 运行测试用例JsApisLoadNativeModule.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── index.d.ts + │ │ │ ├── CMakeList.txt + │ │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 同步方式动态加载native模块 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── JsApisLoadNativeModule.test.ets // 自动化测试代码 + │ │ └── List.test +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule > .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/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/code-linter.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/code-linter.json5 rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/code-linter.json5 diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/build-profile.json5 new file mode 100644 index 0000000000..048216bab1 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/build-profile.json5 @@ -0,0 +1,70 @@ +/* + * 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", + // [Start hap_load_native_dependence_01] + "buildOption": { + "arkOptions": { + "runtimeOnly": { + "packages": [ + "libentry.so" + ] + } + }, + // [StartExclude hap_load_native_dependence_01] + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "arm64-v8a", + "x86_64", + "armeabi-v7a" + ] + }, + // [EndExclude hap_load_native_dependence_01] + }, + // [End hap_load_native_dependence_01] + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/oh-package.json5 new file mode 100644 index 0000000000..118460b308 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/oh-package.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + // [Start hap_load_native_dependence] + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + }, + // [End hap_load_native_dependence] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..c8b20f552c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,15 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(syncNative) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..0fd6bae0c2 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/index.d.ts new file mode 100644 index 0000000000..3604285cc2 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start hap_load_native] +export const add: (a: number, b: number) => number; +// [End hap_load_native] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..1033f7062a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/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/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..0f2f8b94aa --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/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/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/module.json5 new file mode 100644 index 0000000000..9f7f873fbc --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/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/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/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/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/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/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/JsApisLoadNativeModule.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/JsApisLoadNativeModule.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/JsApisLoadNativeModule.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/JsApisLoadNativeModule.test.ets index b8706a4d4f..9926c94a43 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/JsApisLoadNativeModule.test.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/JsApisLoadNativeModule.test.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function JsApisLoadNativeModuleTest() { - describe('jsApisLoadNativeModuleTest', () => { - - it('testJsApisLoadNativeModule001', 0, async () => { - console.info('uitest: testJsApisLoadNativeModule001 begin'); - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - await driver.delayMs(1000); - - const button1 = await driver.findComponent(ON.text('LoadSystemModule')); - const button2 = await driver.findComponent(ON.text('LoadNativeModule')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('loadNativeModule ohos.hilog success')); - - await driver.delayMs(1000); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('loadNativeModule libentry.so success result: 3')); - console.info('uitest: testJsApisLoadNativeModule001 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function JsApisLoadNativeModuleTest() { + describe('jsApisLoadNativeModuleTest', () => { + + it('testJsApisLoadNativeModule001', 0, async () => { + console.info('uitest: testJsApisLoadNativeModule001 begin'); + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + await driver.delayMs(1000); + + const button1 = await driver.findComponent(ON.text('LoadSystemModule')); + const button2 = await driver.findComponent(ON.text('LoadNativeModule')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('loadNativeModule ohos.hilog success')); + + await driver.delayMs(1000); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('loadNativeModule libentry.so success result: 3')); + console.info('uitest: testJsApisLoadNativeModule001 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..f11cb9fd6c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..a2c44fdf8f --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/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/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/oh-package.json5 new file mode 100644 index 0000000000..37c22b202a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/ohosTest.md b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/ohosTest.md new file mode 100644 index 0000000000..338b5a2815 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/ohosTest.md @@ -0,0 +1,9 @@ +# 同步方式动态加载Native模块测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------ | ------------ | ------------------------- | ------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| 主页按钮点击 | 位于主页 | 点击HAP加载系统库模块按钮 | 页面文本变化 | Pass | +| 主页按钮点击 | 位于主页 | 点击HAP加载Native库按钮 | 页面文本变化 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule1.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule1.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule1.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule2.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule2.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule2.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule3.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule3.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule3.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/screenshots/JsApisLoadNativeModule3.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/app.json5 new file mode 100644 index 0000000000..7124fa63c7 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/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.lazyimport", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..36c2d06b26 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "LazyImport" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/README.md b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/README.md new file mode 100644 index 0000000000..9755c18b8c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/README.md @@ -0,0 +1,75 @@ +# ArkTS延迟加载(lazy import) + +### 介绍 + +本工程主要对比了延迟加载与普通加载的区别,并展示延迟加载的错误使用方法。该工程中展示的代码详细描述可查如下链接部分。 + +- [延迟加载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-lazy-import.md) + +### 效果预览 + +| 首页 | 依次点击按钮后结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面中Text组件呈现LazyImport效果,依次点击五个button,Text依次现实显示‘Call a success result: a = mod1 a executed’,‘‘Call b success result: b = mod1 b executed’, ‘‘Call c success result: c = mod2 c executed’, ‘Not advisable to use one error: ReferenceError: c is not initialized’, ‘Not advisable to use two error: ReferenceError: module environment is undefined’。 +3. 运行测试用例LazyImport.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── A.ets + │ │ ├── A_ns.ets + │ │ ├── B.ets + │ │ ├── C.ets + │ │ ├── fail_example.ets + │ │ ├── Index.ets // 延迟加载 + │ │ ├── middle.ets + │ │ ├── mod1.ets + │ │ ├── mod2.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── LazyImport.test.ets // 自动化测试代码 + │ │ └── List.test +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport > .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/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/code-linter.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/code-linter.json5 rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/code-linter.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/build-profile.json5 new file mode 100644 index 0000000000..88b78d11f0 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/oh-package.json5 new file mode 100644 index 0000000000..dbacc308e4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/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/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..cd39a5616f --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/main', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/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/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A.ets index b26b2ae478..7b753cb569 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A.ets @@ -1,22 +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. - */ - -// [Start export_variable_a] -import { c } from './B'; - -console.info(c); -// [End export_variable_a] - -export { c }; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start export_variable_a] +import { c } from './B'; + +console.info(c); +// [End export_variable_a] + +export { c }; diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A_ns.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A_ns.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A_ns.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A_ns.ets index 4928cba69d..dd739af27b --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A_ns.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/A_ns.ets @@ -1,22 +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. - */ - -// [Start export_variable_a_ns] -import * as ns from './B'; - -console.info(ns.c); -// [End export_variable_a_ns] - +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start export_variable_a_ns] +import * as ns from './B'; + +console.info(ns.c); +// [End export_variable_a_ns] + export { ns }; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/B.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/B.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/B.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/B.ets index 4a67139893..168cd24062 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/B.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/B.ets @@ -1,20 +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. - */ - -// [Start export_variable_b] -import lazy { c } from './C'; // 从'C'内获取c对象,标记为延迟加载 - -export { c }; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start export_variable_b] +import lazy { c } from './C'; // 从'C'内获取c对象,标记为延迟加载 + +export { c }; // [End export_variable_b] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/C.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/C.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/C.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/C.ets index 0e13c989d5..7fff38a46b --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/C.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/C.ets @@ -1,20 +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. - */ - -// [Start export_variable_c] -let c = 'c'; - -export { c }; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start export_variable_c] +let c = 'c'; + +export { c }; // [End export_variable_c] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/fail_example.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/fail_example.ets old mode 100755 new mode 100644 similarity index 98% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/fail_example.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/fail_example.ets index f90b53a476..02b43de9c6 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/fail_example.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/fail_example.ets @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// export lazy var v; // 编译器提示报错:应用编译报错 -// export lazy default function f(){}; // 编译器提示报错:应用编译报错 -// export lazy default function(){}; // 编译器提示报错:应用编译报错 -// export lazy default 42; // 编译器提示报错:应用编译报错 -// export lazy { x }; // 编译器提示报错:应用编译报错 -// export lazy { x as v }; // 编译器提示报错:应用编译报错 -// export lazy { x } from 'mod'; // 编译器提示报错:应用编译报错 -// export lazy { x as v } from 'mod'; // 编译器提示报错:应用编译报错 -// export lazy * from 'mod'; // 编译器提示报错:应用编译报错 - -// import lazy v from 'mod'; // 编译器提示报错:应用编译报错 -// import lazy * as ns from 'mod'; // 编译器提示报错:应用编译报错 -// -// import lazy type { obj } from './mod'; // 不支持,编译器、应用编译报错 +/* + * 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 lazy var v; // 编译器提示报错:应用编译报错 +// export lazy default function f(){}; // 编译器提示报错:应用编译报错 +// export lazy default function(){}; // 编译器提示报错:应用编译报错 +// export lazy default 42; // 编译器提示报错:应用编译报错 +// export lazy { x }; // 编译器提示报错:应用编译报错 +// export lazy { x as v }; // 编译器提示报错:应用编译报错 +// export lazy { x } from 'mod'; // 编译器提示报错:应用编译报错 +// export lazy { x as v } from 'mod'; // 编译器提示报错:应用编译报错 +// export lazy * from 'mod'; // 编译器提示报错:应用编译报错 + +// import lazy v from 'mod'; // 编译器提示报错:应用编译报错 +// import lazy * as ns from 'mod'; // 编译器提示报错:应用编译报错 +// +// import lazy type { obj } from './mod'; // 不支持,编译器、应用编译报错 // import type lazy { obj } from './mod'; // 不支持,编译器、应用编译报错 \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/main.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/main.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/main.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/main.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/middle.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/middle.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/middle.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/middle.ets index fdff5d3d3f..14e7e73459 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/middle.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/middle.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { c } from './A'; // 不推荐用法 -import { ns } from './A_ns'; // 不推荐用法 - - +/* + * 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 { c } from './A'; // 不推荐用法 +import { ns } from './A_ns'; // 不推荐用法 + + export { c, ns }; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod1.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod1.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod1.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod1.ets index 520baeafa3..037aca4cb5 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod1.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod1.ets @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start export_module_variable_01] -export let a = 'mod1 a executed'; - -console.info(a); - -export let b = 'mod1 b executed'; - -console.info(b); +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start export_module_variable_01] +export let a = 'mod1 a executed'; + +console.info(a); + +export let b = 'mod1 b executed'; + +console.info(b); // [End export_module_variable_01] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod2.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod2.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod2.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod2.ets index bab31537ac..b1a5022d65 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod2.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/pages/mod2.ets @@ -1,20 +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. - */ - -// [Start export_module_variable_02] -export let c = 'mod2 c executed'; - -console.info(c); +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start export_module_variable_02] +export let c = 'mod2 c executed'; + +console.info(c); // [End export_module_variable_02] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/module.json5 new file mode 100644 index 0000000000..9f7f873fbc --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/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/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/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/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/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/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/LazyImport.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/LazyImport.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/LazyImport.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/LazyImport.test.ets index f1288468bf..84c6997036 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/LazyImport.test.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/LazyImport.test.ets @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function lazyImportTest() { - describe('lazyImportTest', () => { - - it('testLazyImport001', 0, async (done: Function) => { - console.info('uitest: testLazyImport001 begin'); - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - await driver.delayMs(1000); - - await driver.assertComponentExist(ON.text('LazyImport')); - const button1 = await driver.findComponent(ON.text('Call a')); - const button2 = await driver.findComponent(ON.text('Call b')); - const button3 = await driver.findComponent(ON.text('Call c')); - const button4 = await driver.findComponent(ON.text('Not advisable to use one')); - const button5 = await driver.findComponent(ON.text('Not advisable to use two')); - - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call a success result: a = mod1 a executed')); - - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call b success result: b = mod1 b executed')); - - await button3.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call c success result: c = mod2 c executed')); - - await button4.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Not advisable to use one error: ReferenceError: c is not initialized')); - - await button5.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Not advisable to use two error: ReferenceError: module environment is undefined')); - console.info('uitest: testLazyImport001 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function lazyImportTest() { + describe('lazyImportTest', () => { + + it('testLazyImport001', 0, async (done: Function) => { + console.info('uitest: testLazyImport001 begin'); + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + await driver.delayMs(1000); + + await driver.assertComponentExist(ON.text('LazyImport')); + const button1 = await driver.findComponent(ON.text('Call a')); + const button2 = await driver.findComponent(ON.text('Call b')); + const button3 = await driver.findComponent(ON.text('Call c')); + const button4 = await driver.findComponent(ON.text('Not advisable to use one')); + const button5 = await driver.findComponent(ON.text('Not advisable to use two')); + + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call a success result: a = mod1 a executed')); + + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call b success result: b = mod1 b executed')); + + await button3.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call c success result: c = mod2 c executed')); + + await button4.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Not advisable to use one error: ReferenceError: c is not initialized')); + + await button5.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Not advisable to use two error: ReferenceError: module environment is undefined')); + console.info('uitest: testLazyImport001 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..f11cb9fd6c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..3511c6358c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/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.1", + "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/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/oh-package.json5 new file mode 100644 index 0000000000..14655ea1c0 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/ohosTest.md b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/ohosTest.md new file mode 100644 index 0000000000..21e7812c01 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/ohosTest.md @@ -0,0 +1,12 @@ +# 延迟加载测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------ | ------------ | ------------------- | ------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| 主页按钮点击 | 位于主页 | 点击触发a按钮 | 页面文本变化 | Pass | +| 主页按钮点击 | 位于主页 | 点击触发b按钮 | 页面文本变化 | Pass | +| 主页按钮点击 | 位于主页 | 点击触发c按钮 | 页面文本变化 | Pass | +| 主页按钮点击 | 位于主页 | 点击不推荐用法1按钮 | 页面文本变化 | Pass | +| 主页按钮点击 | 位于主页 | 点击不推荐用法2按钮 | 页面文本变化 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/screenshots/LazyImport1.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/screenshots/LazyImport1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/screenshots/LazyImport1.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/screenshots/LazyImport1.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/screenshots/LazyImport2.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/screenshots/LazyImport2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/screenshots/LazyImport2.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/LazyImport/screenshots/LazyImport2.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/app.json5 new file mode 100644 index 0000000000..2bb30c7089 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/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.moduleloadingsideeffects", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..d9d56cd3c1 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ModuleLoadingSideEffects" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/README.md b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/README.md new file mode 100644 index 0000000000..89b5b5a0fe --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/README.md @@ -0,0 +1,74 @@ +# ArkTS模块加载副作用及优化 + +### 介绍 + +当使用ArkTS模块化时,模块的加载和执行可能会引发副作用。副作用是指在模块导入过程中,除了导出功能或对象之外,还产生了额外的行为或状态变化。这些行为可能影响程序别的部分,并导致非预期的顶层代码执行、全局状态变化、原型链修改、导入内容未定义等问题。 + +本项目展现了模块加载副作用及优化,包括模块执行顶层代码、修改全局对象、修改应用级ArkUI组件的状态变量信息、修改内置全局变量或原型链、循环依赖和延迟加载改变模块执行顺序等场景,对比产生副作用的场景和优化后场景。代码详细描述可查如下链接。 + +- [模块加载副作用及优化](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-module-side-effects.md) + +### 效果预览 + +| 首页 | +| ------------------------------------------------------------ | +| | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面中呈现五个按钮分别对应介绍中五个场景,分别点击按钮可以跳转到各个场景的页面,页面中有副作用以及优化后结果进行对比,并在工作台打印日志。 +3. 运行测试用例ModuleLoadingSideEffects.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── LazyImportChangeExecutionOrder // 延迟加载改变模块执行顺序 + │ │ ├── ModifyGlobalObject // 修改全局对象 + │ │ ├── ModifyingGlobalVariables // 修改内置全局变量或原型链 + │ │ ├── ModifyTheApplicationLevelArkUI // 修改应用级ArkUI组件的状态变量信息 + │ │ ├── TopCodeModification // 模块执行顶层代码 + │ │ └── Index.ets // 首页 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── ModuleLoadingSideEffects.test.ets // 自动化测试代码 + │ │ └── List.test +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects > .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/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/code-linter.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/code-linter.json5 rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/code-linter.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/.gitignore b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/.gitignore rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/build-profile.json5 new file mode 100644 index 0000000000..e7569e3056 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/oh-package.json5 new file mode 100644 index 0000000000..c9cb6c8174 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/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/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..edc2839f20 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/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/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/module.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/module.ets new file mode 100644 index 0000000000..6be7578e26 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/module.ets @@ -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. + */ + +// [Start import_global_module_data] +export let data = 'data from module'; + +globalThis.someGlobalVar = 100; +// [End import_global_module_data] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleOptimize.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleOptimize.ets new file mode 100644 index 0000000000..44c8c0b9b7 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleOptimize.ets @@ -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. + */ + +export let dataOptimize = 'data from module'; + +export function initialize() { + globalThis.someGlobalVar = 100; // 延迟到函数调用时执行 +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleUseGlobalVar.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleUseGlobalVar.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleUseGlobalVar.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleUseGlobalVar.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/main.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/main.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/main.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/main.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/module.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/module.ets new file mode 100644 index 0000000000..138e8b5ed2 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/module.ets @@ -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. + */ + +// [Start export_change_global_data_100] +export let data1 = 'data from module'; + +globalThis.someGlobalVar = 100; // 改变了全局状态 +// [End export_change_global_data_100] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleOptimize.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleOptimize.ets new file mode 100644 index 0000000000..dbe9638578 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleOptimize.ets @@ -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. + */ + +export let dataOptimize1 = 'data from module'; + +export function changeGlobalVar() { + globalThis.someGlobalVar = 100; +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVar.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVar.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVar.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVar.ets index 91c18c7516..4bb2bf0359 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVar.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVar.ets @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start export_change_some_global_var] -import { data1 } from './module'; // 此时可能预期全局变量someGlobalVar的值为100 - -export function useGlobalVar() { - console.log(data1); - console.log(globalThis.someGlobalVar); // 此时由于main.ets中加载了sideEffectModule模块,someGlobalVar的值已经被改为200 -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start export_change_some_global_var] +import { data1 } from './module'; // 此时可能预期全局变量someGlobalVar的值为100 + +export function useGlobalVar() { + console.log(data1); + console.log(globalThis.someGlobalVar); // 此时由于main.ets中加载了sideEffectModule模块,someGlobalVar的值已经被改为200 +} // [End export_change_some_global_var] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVarOptimize.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVarOptimize.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVarOptimize.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVarOptimize.ets index a1d76f4f75..bb5ed7f6ed --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVarOptimize.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleUseGlobalVarOptimize.ets @@ -1,22 +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. - */ - -import { dataOptimize1, changeGlobalVar } from './moduleOptimize'; - -export function useGlobalVarOptimize() { - console.log(dataOptimize1); - changeGlobalVar(); // 在需要的时候执行代码,而不是模块加载时执行。 - console.log(globalThis.someGlobalVar); +/* + * 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 { dataOptimize1, changeGlobalVar } from './moduleOptimize'; + +export function useGlobalVarOptimize() { + console.log(dataOptimize1); + changeGlobalVar(); // 在需要的时候执行代码,而不是模块加载时执行。 + console.log(globalThis.someGlobalVar); } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModule.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModule.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModule.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModule.ets index 1f401a0dfd..dc3c50caae --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModule.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModule.ets @@ -1,20 +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. - */ - -// [Start export_change_global_data_200] -export let data2 = 'data from side effect module'; - -globalThis.someGlobalVar = 200; // 也变了全局状态 +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start export_change_global_data_200] +export let data2 = 'data from side effect module'; + +globalThis.someGlobalVar = 200; // 也变了全局状态 // [End export_change_global_data_200] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModuleOptimize.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModuleOptimize.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModuleOptimize.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModuleOptimize.ets index 18368b9a53..8e7b8b4d08 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModuleOptimize.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/sideEffectModuleOptimize.ets @@ -1,20 +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. - */ - -export let dataOptimize2 = 'data from side effect module'; - -export function changeGlobalVar() { - globalThis.someGlobalVar = 200; +/* + * 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 let dataOptimize2 = 'data from side effect module'; + +export function changeGlobalVar() { + globalThis.someGlobalVar = 200; } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/Index.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/Index.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/Index.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/module.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/module.ets new file mode 100644 index 0000000000..4f22295fa7 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/module.ets @@ -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. + */ + +// [Start set_app_storage_var] +export let data = 'data from module'; + +AppStorage.setOrCreate('SomeAppStorageVar1', 200); // 修改应用全局的UI状态 +// [End set_app_storage_var] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/moduleOptimize.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/moduleOptimize.ets new file mode 100644 index 0000000000..3f3eb44a10 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/moduleOptimize.ets @@ -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. + */ + +export let dataOptimize = 'data from module'; + +export function initialize() { + AppStorage.setOrCreate('SomeAppStorageVar2', 200); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/a.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/a.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/a.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/a.ets index 2d5fc12b08..f6f29f149d --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/a.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/a.ets @@ -1,22 +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. - */ - -// [Start module_cycle_dependence_a] -import { b } from './b'; - -console.log('Module A: ', b); - -export const a = 'A'; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start module_cycle_dependence_a] +import { b } from './b'; + +console.log('Module A: ', b); + +export const a = 'A'; // [End module_cycle_dependence_a] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/b.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/b.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/b.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/b.ets index 106641288a..429b760ccd --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/b.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/b.ets @@ -1,22 +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. - */ - -// [Start module_cycle_dependence_b] -import { a } from './a'; - -console.log('Module B: ', a); - -export const b = 'B'; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start module_cycle_dependence_b] +import { a } from './a'; + +console.log('Module B: ', a); + +export const b = 'B'; // [End module_cycle_dependence_b] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/main.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/main.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/main.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/main.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/modifyPrototype.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/modifyPrototype.ts old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/modifyPrototype.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/modifyPrototype.ts index e67a973072..fcd1cf7e79 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/modifyPrototype.ts +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyingGlobalVariables/modifyPrototype.ts @@ -1,22 +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. - */ - -// [Start array_prototype_include] -export let data = 'data from modifyPrototype'; - -Array.prototype.includes = function (value) { - return this.indexOf(value) == -1; -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start array_prototype_include] +export let data = 'data from modifyPrototype'; + +Array.prototype.includes = function (value) { + return this.indexOf(value) == -1; +}; // [End array_prototype_include] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/main.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/main.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/main.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/main.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/module.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/module.ets new file mode 100644 index 0000000000..78a1749bda --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/module.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start module_load_directly] +export function initialize() { + console.log('Module loaded!'); +} +// [End module_load_directly] + +// [Start module_load_optimize] +export const dataOptimizeTwo = 1; +// [End module_load_optimize] diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModule.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModule.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModule.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModule.ets index 7c4d4ad681..0881065f6e --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModule.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModule.ets @@ -1,18 +1,18 @@ -/* - * 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. - */ - -console.log('Module loaded!'); // 这段代码在导入时会立即执行,可能会导致副作用。 - +/* + * 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. + */ + +console.log('Module loaded!'); // 这段代码在导入时会立即执行,可能会导致副作用。 + export const data = 1; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModuleOptimize.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModuleOptimize.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModuleOptimize.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModuleOptimize.ets index d375625a09..5a8ab7a8dc --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModuleOptimize.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/topCodeModuleOptimize.ets @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 dataOptimizeOne = 1; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/CommonButton.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/CommonButton.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/resource.ets new file mode 100644 index 0000000000..a0f1755b8c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/resource.ets @@ -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. + */ + +export class P2PManager { + public resourceToString(resource: Resource):string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + +export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/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/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/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/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/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/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/ModuleLoadingSideEffects.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/ModuleLoadingSideEffects.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/ModuleLoadingSideEffects.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/ModuleLoadingSideEffects.test.ets index a0d89ffb53..883d68ee9d --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/ModuleLoadingSideEffects.test.ets +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/ets/test/ModuleLoadingSideEffects.test.ets @@ -1,156 +1,156 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} - -export default function moduleLoadingSideEffectsTest() { - describe('moduleLoadingSideEffectsTest', () => { - - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - it('testModuleLoadingSideEffects001', 0, async () => { - console.info('uitest: testModuleLoadingSideEffects001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('LazyImport')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('LazyImportSideEffect')); - const button3 = await driver.findComponent(ON.text('LazyImportOptimize')); - await driver.delayMs(1000); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SideEffect: undefined')); - await driver.delayMs(1000); - await button3.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Optimize: 100')); - console.info('uitest: testModuleLoadingSideEffects001 end'); - await driver.pressBack(); - }) - - it('testModuleLoadingSideEffects002', 0, async () => { - console.info('uitest: testModuleLoadingSideEffects002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('ModifyGlobalObject')); - await driver.delayMs(1000); - await button1.click(); - - const button2 = await driver.findComponent(ON.text('SideEffect').type('Button')); - const button3 = await driver.findComponent(ON.text('Optimize').type('Button')); - await driver.delayMs(1000); - - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('sideEffect result: 200')); - await driver.delayMs(1000); - - await button3.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('optimize result: 100')); - console.info('uitest: testModuleLoadingSideEffects002 end'); - await driver.pressBack(); - }) - - it('testModuleLoadingSideEffects003', 0, async () => { - console.info('uitest: testModuleLoadingSideEffects003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('ModifyingGlobalVariables')); - await driver.delayMs(1000); - await button1.click(); - - const button2 = await driver.findComponent(ON.text(resourceToString($r('app.string.circular_dependency')))); - const button3 = await driver.findComponent(ON.text('Not Call modifyPrototype')); - const button4 = await driver.findComponent(ON.text('Call modifyPrototype')); - await driver.delayMs(1000); - - await button2.click(); - await button3.click(); - await driver.delayMs(1000); - - await driver.assertComponentExist(ON.text(resourceToString($r( - 'app.string.circular_dependency')) + 'error: ReferenceError: a is not initialized')); - await driver.assertComponentExist(ON.text('SideEffect: true')); - - await driver.delayMs(1000); - await button4.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Optimize: false')); - console.info('uitest: testModuleLoadingSideEffects003 end'); - await driver.pressBack(); - }) - - it('testModuleLoadingSideEffects004', 0, async () => { - console.info('uitest: testModuleLoadingSideEffects004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('ModifyTheApplicationLevelArkUI')); - await driver.delayMs(1000); - await button.click(); - - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('test100')); - await driver.assertComponentExist(ON.text('test200')); - console.info('uitest: testModuleLoadingSideEffects004 end'); - await driver.pressBack(); - }) - - it('testModuleLoadingSideEffects005', 0, async () => { - console.info('uitest: testModuleLoadingSideEffects005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('TopCodeModification')); - await driver.delayMs(1000); - await button1.click(); - - await driver.delayMs(1000); - - const button2 = await driver.findComponent(ON.text('Call top code')); - await driver.delayMs(1000); - - await button2.click(); - await driver.delayMs(1000); - - await driver.assertComponentExist(ON.text('sideEffect: Module loaded!1')); - await driver.assertComponentExist(ON.text('optimize one: 1')); - await driver.assertComponentExist(ON.text('optimize two: 1')); - console.info('uitest: testModuleLoadingSideEffects005 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} + +export default function moduleLoadingSideEffectsTest() { + describe('moduleLoadingSideEffectsTest', () => { + + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + it('testModuleLoadingSideEffects001', 0, async () => { + console.info('uitest: testModuleLoadingSideEffects001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('LazyImport')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('LazyImportSideEffect')); + const button3 = await driver.findComponent(ON.text('LazyImportOptimize')); + await driver.delayMs(1000); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SideEffect: undefined')); + await driver.delayMs(1000); + await button3.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Optimize: 100')); + console.info('uitest: testModuleLoadingSideEffects001 end'); + await driver.pressBack(); + }) + + it('testModuleLoadingSideEffects002', 0, async () => { + console.info('uitest: testModuleLoadingSideEffects002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('ModifyGlobalObject')); + await driver.delayMs(1000); + await button1.click(); + + const button2 = await driver.findComponent(ON.text('SideEffect').type('Button')); + const button3 = await driver.findComponent(ON.text('Optimize').type('Button')); + await driver.delayMs(1000); + + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('sideEffect result: 200')); + await driver.delayMs(1000); + + await button3.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('optimize result: 100')); + console.info('uitest: testModuleLoadingSideEffects002 end'); + await driver.pressBack(); + }) + + it('testModuleLoadingSideEffects003', 0, async () => { + console.info('uitest: testModuleLoadingSideEffects003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('ModifyingGlobalVariables')); + await driver.delayMs(1000); + await button1.click(); + + const button2 = await driver.findComponent(ON.text(resourceToString($r('app.string.circular_dependency')))); + const button3 = await driver.findComponent(ON.text('Not Call modifyPrototype')); + const button4 = await driver.findComponent(ON.text('Call modifyPrototype')); + await driver.delayMs(1000); + + await button2.click(); + await button3.click(); + await driver.delayMs(1000); + + await driver.assertComponentExist(ON.text(resourceToString($r( + 'app.string.circular_dependency')) + 'error: ReferenceError: a is not initialized')); + await driver.assertComponentExist(ON.text('SideEffect: true')); + + await driver.delayMs(1000); + await button4.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Optimize: false')); + console.info('uitest: testModuleLoadingSideEffects003 end'); + await driver.pressBack(); + }) + + it('testModuleLoadingSideEffects004', 0, async () => { + console.info('uitest: testModuleLoadingSideEffects004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('ModifyTheApplicationLevelArkUI')); + await driver.delayMs(1000); + await button.click(); + + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('test100')); + await driver.assertComponentExist(ON.text('test200')); + console.info('uitest: testModuleLoadingSideEffects004 end'); + await driver.pressBack(); + }) + + it('testModuleLoadingSideEffects005', 0, async () => { + console.info('uitest: testModuleLoadingSideEffects005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('TopCodeModification')); + await driver.delayMs(1000); + await button1.click(); + + await driver.delayMs(1000); + + const button2 = await driver.findComponent(ON.text('Call top code')); + await driver.delayMs(1000); + + await button2.click(); + await driver.delayMs(1000); + + await driver.assertComponentExist(ON.text('sideEffect: Module loaded!1')); + await driver.assertComponentExist(ON.text('optimize one: 1')); + await driver.assertComponentExist(ON.text('optimize two: 1')); + console.info('uitest: testModuleLoadingSideEffects005 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/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.1", + "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/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/oh-package.json5 b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/ohosTest.md b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/ohosTest.md new file mode 100644 index 0000000000..7673093ea5 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/ohosTest.md @@ -0,0 +1,12 @@ +# 模块加载副作用及优化测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动化 | 测试结果 | +| ------------------------------ | ---------------- | -------------------------------------- | ------------ | ---------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 主页按钮点击跳转按钮后按钮点击 | 跳转按钮位于主页 | 点击LazyImport按钮 | 页面文本变化 | 是 | Pass | +| 主页按钮点击跳转按钮后按钮点击 | 跳转按钮位于主页 | 点击ModifyGlobalObject按钮 | 页面文本变化 | 是 | Pass | +| 主页按钮点击跳转按钮后按钮点击 | 跳转按钮位于主页 | 点击ModifyingGlobalVariables按钮 | 页面文本变化 | 是 | Pass | +| 主页按钮点击跳转按钮后文本显示 | 跳转按钮位于主页 | 点击ModifyTheApplicationLevelArkUI按钮 | 页面文本变化 | 是 | Pass | +| 主页按钮点击跳转按钮后按钮点击 | 跳转按钮位于主页 | 点击TopCodeModification按钮 | 页面文本变化 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/screenshots/ModuleLoadingSideEffects.png b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/screenshots/ModuleLoadingSideEffects.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/screenshots/ModuleLoadingSideEffects.png rename to code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/screenshots/ModuleLoadingSideEffects.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/app.json5 old mode 100755 new mode 100644 index 935ada1e78..a52c889c4f --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/app.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/app.json5 @@ -1,25 +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.applicationmultithreading", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.applicationmultithreading", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index fa9c7dd415..2a444165a5 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ApplicationMultithreading" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ApplicationMultithreading" + } + ] +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/README.md old mode 100755 new mode 100644 index 8643222d9c..359285278c --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/README.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/README.md @@ -1,95 +1,95 @@ -# ArkTS 应用多线程开发 - -### 介绍 - -ArkTS应用开发过程中,需要用到并发能力的业务场景很多,不同业务场景需要使用的并发能力不同,对应的主要任务类型也不同。 - -针对常见的业务场景,主要可以对应分为三种并发任务: - -[耗时任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/time-consuming-task-overview.md):业务逻辑包含较大计算量或多次I/O读写等需要长时间执行的任务。 - -[长时任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/long-time-task-overview.md):业务逻辑包含监听或定期采集数据等需要长时间保持运行的任务。 - -[常驻任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/resident-task-overview.md):业务逻辑跟随主线程生命周期或与主线程绑定的任务。 - -不同任务类型下可再细划分,比如典型的耗时任务有CPU密集型任务、I/O密集型任务以及同步任务,分别对应的典型业务场景也不相同。请开发者根据场景任务类型对应选择并发能力。 - -该工程中展示的代码详细描述可查如下链接: - -- [CPU密集型任务开发指导 (TaskPool和Worker)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/cpu-intensive-task-development.md) -- [I/O密集型任务开发指导 (TaskPool)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/io-intensive-task-development.md) -- [同步任务开发指导 (TaskPool和Worker)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/sync-task-development.md) -- [长时任务开发指导(TaskPool)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/long-time-task-guide.md) -- [常驻任务开发指导(Worker)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/resident-task-guide.md) - -### 效果预览 - -| 首页 | 执行及结果即时反 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── managers - │ │ ├── CpuIntensiveTaskDevelopment.ets // CPU密集型任务开发指导 - │ │ ├── IoIntensiveTaskDevelopment.ets // I/O密集型任务开发指导 - │ │ ├── LongTimeTaskGuide.ets // 长时任务开发指导 - │ │ ├── ResidentTaskGuide.ets // 常驻任务开发指导 - │ │ ├── SyncTaskDevelopment.ets // 同步任务开发指导 - │ │ ├── write.ets // I/O密集型任务开发指导 - │ │ ├── pages - │ │ ├── Index.ets // 首页 - │ │ ├── util - │ │ ├── CommonButton.ets // 首页跳转UI - │ │ ├── resource.ets // 资源引用转换 - │ │ ├── workers - │ │ ├── handle.ts // 同步任务开发指导 - │ │ ├── MyWorker1.ts // CPU密集型任务开发指导 - │ │ ├── MyWorker2.ts // 同步任务开发指导 - │ │ ├── Worker.ets // 常驻任务开发指导 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# ArkTS 应用多线程开发 + +### 介绍 + +ArkTS应用开发过程中,需要用到并发能力的业务场景很多,不同业务场景需要使用的并发能力不同,对应的主要任务类型也不同。 + +针对常见的业务场景,主要可以对应分为三种并发任务: + +[耗时任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/time-consuming-task-overview.md):业务逻辑包含较大计算量或多次I/O读写等需要长时间执行的任务。 + +[长时任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/long-time-task-overview.md):业务逻辑包含监听或定期采集数据等需要长时间保持运行的任务。 + +[常驻任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/resident-task-overview.md):业务逻辑跟随主线程生命周期或与主线程绑定的任务。 + +不同任务类型下可再细划分,比如典型的耗时任务有CPU密集型任务、I/O密集型任务以及同步任务,分别对应的典型业务场景也不相同。请开发者根据场景任务类型对应选择并发能力。 + +该工程中展示的代码详细描述可查如下链接: + +- [CPU密集型任务开发指导 (TaskPool和Worker)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/cpu-intensive-task-development.md) +- [I/O密集型任务开发指导 (TaskPool)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/io-intensive-task-development.md) +- [同步任务开发指导 (TaskPool和Worker)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/sync-task-development.md) +- [长时任务开发指导(TaskPool)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/long-time-task-guide.md) +- [常驻任务开发指导(Worker)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/resident-task-guide.md) + +### 效果预览 + +| 首页 | 执行及结果即时反 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── managers + │ │ ├── CpuIntensiveTaskDevelopment.ets // CPU密集型任务开发指导 + │ │ ├── IoIntensiveTaskDevelopment.ets // I/O密集型任务开发指导 + │ │ ├── LongTimeTaskGuide.ets // 长时任务开发指导 + │ │ ├── ResidentTaskGuide.ets // 常驻任务开发指导 + │ │ ├── SyncTaskDevelopment.ets // 同步任务开发指导 + │ │ ├── write.ets // I/O密集型任务开发指导 + │ │ ├── pages + │ │ ├── Index.ets // 首页 + │ │ ├── util + │ │ ├── CommonButton.ets // 首页跳转UI + │ │ ├── resource.ets // 资源引用转换 + │ │ ├── workers + │ │ ├── handle.ts // 同步任务开发指导 + │ │ ├── MyWorker1.ts // CPU密集型任务开发指导 + │ │ ├── MyWorker2.ts // 同步任务开发指导 + │ │ ├── Worker.ets // 常驻任务开发指导 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading > .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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/build-profile.json5 old mode 100755 new mode 100644 index a67b28bc7e..bc0de2c6ef --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/build-profile.json5 @@ -1,50 +1,50 @@ -/* - * 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": { - "sourceOption": { - "workers": [ - "./src/main/ets/workers/MyWorker1.ts", - "./src/main/ets/workers/MyWorker2.ts", - "./src/main/ets/workers/Worker.ets" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": { + "sourceOption": { + "workers": [ + "./src/main/ets/workers/MyWorker1.ts", + "./src/main/ets/workers/MyWorker2.ts", + "./src/main/ets/workers/Worker.ets" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/CpuIntensiveTaskDevelopment.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/CpuIntensiveTaskDevelopment.ets old mode 100755 new mode 100644 index 788f7e957d..4f734900b5 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/CpuIntensiveTaskDevelopment.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/CpuIntensiveTaskDevelopment.ets @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start process_image_histogram] -import { taskpool } from '@kit.ArkTS'; -// [StartExclude process_image_histogram] -// [Start call_worker_message] -import { worker } from '@kit.ArkTS'; - -const workerInstance: worker.ThreadWorker = new worker.ThreadWorker('entry/ets/workers/MyWorker1.ts'); - -let done = false; - -// 接收Worker子线程的结果 -workerInstance.onmessage = (() => { - console.info('MyWorker.ts onmessage'); - if (!done) { - workerInstance.postMessage({ 'type': 1, 'value': 0 }); - done = true; - } -}) - -workerInstance.onerror = (() => { - // 接收Worker子线程的错误信息 -}) - -// 向Worker子线程发送训练消息 -workerInstance.postMessage({ 'type': 0 }); -// [End call_worker_message] - -// [Start after_destroy_callback] -// Worker线程销毁后,执行onexit回调方法 -workerInstance.onexit = (): void => { - console.info('main thread terminate'); -} -// [End after_destroy_callback] -// [EndExclude process_image_histogram] - -@Concurrent -function imageProcessing(dataSlice: ArrayBuffer): ArrayBuffer { - // 步骤1: 具体的图像处理操作及其他耗时操作 - return dataSlice; -} - -function histogramStatistic(pixelBuffer: ArrayBuffer): void { - // 步骤2: 分成三段并发调度 - let number: number = pixelBuffer.byteLength / 3; - let buffer1: ArrayBuffer = pixelBuffer.slice(0, number); - let buffer2: ArrayBuffer = pixelBuffer.slice(number, number * 2); - let buffer3: ArrayBuffer = pixelBuffer.slice(number * 2); - - let group: taskpool.TaskGroup = new taskpool.TaskGroup(); - group.addTask(imageProcessing, buffer1); - group.addTask(imageProcessing, buffer2); - group.addTask(imageProcessing, buffer3); - - taskpool.execute(group, taskpool.Priority.HIGH).then((ret: Object) => { - // 步骤3: 结果数组汇总处理 - }) -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World' - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - let buffer: ArrayBuffer = new ArrayBuffer(24); - histogramStatistic(buffer); - this.message = 'success'; - // 销毁Worker线程 - workerInstance.terminate(); - }) - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start process_image_histogram] +import { taskpool } from '@kit.ArkTS'; +// [StartExclude process_image_histogram] +// [Start call_worker_message] +import { worker } from '@kit.ArkTS'; + +const workerInstance: worker.ThreadWorker = new worker.ThreadWorker('entry/ets/workers/MyWorker1.ts'); + +let done = false; + +// 接收Worker子线程的结果 +workerInstance.onmessage = (() => { + console.info('MyWorker.ts onmessage'); + if (!done) { + workerInstance.postMessage({ 'type': 1, 'value': 0 }); + done = true; + } +}) + +workerInstance.onerror = (() => { + // 接收Worker子线程的错误信息 +}) + +// 向Worker子线程发送训练消息 +workerInstance.postMessage({ 'type': 0 }); +// [End call_worker_message] + +// [Start after_destroy_callback] +// Worker线程销毁后,执行onexit回调方法 +workerInstance.onexit = (): void => { + console.info('main thread terminate'); +} +// [End after_destroy_callback] +// [EndExclude process_image_histogram] + +@Concurrent +function imageProcessing(dataSlice: ArrayBuffer): ArrayBuffer { + // 步骤1: 具体的图像处理操作及其他耗时操作 + return dataSlice; +} + +function histogramStatistic(pixelBuffer: ArrayBuffer): void { + // 步骤2: 分成三段并发调度 + let number: number = pixelBuffer.byteLength / 3; + let buffer1: ArrayBuffer = pixelBuffer.slice(0, number); + let buffer2: ArrayBuffer = pixelBuffer.slice(number, number * 2); + let buffer3: ArrayBuffer = pixelBuffer.slice(number * 2); + + let group: taskpool.TaskGroup = new taskpool.TaskGroup(); + group.addTask(imageProcessing, buffer1); + group.addTask(imageProcessing, buffer2); + group.addTask(imageProcessing, buffer3); + + taskpool.execute(group, taskpool.Priority.HIGH).then((ret: Object) => { + // 步骤3: 结果数组汇总处理 + }) +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + let buffer: ArrayBuffer = new ArrayBuffer(24); + histogramStatistic(buffer); + this.message = 'success'; + // 销毁Worker线程 + workerInstance.terminate(); + }) + } + .width('100%') + } + .height('100%') + } +} // [End process_image_histogram] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/IoIntensiveTaskDevelopment.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/IoIntensiveTaskDevelopment.ets old mode 100755 new mode 100644 index c3427c184d..9284a71332 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/IoIntensiveTaskDevelopment.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/IoIntensiveTaskDevelopment.ets @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start define_concurrent_function] -import { write } from './write' -import { BusinessError } from '@kit.BasicServicesKit'; -import { taskpool } from '@kit.ArkTS'; -import { common } from '@kit.AbilityKit'; - -@Concurrent -async function concurrentTest(context: common.UIAbilityContext): Promise { - let filePath1: string = context.filesDir + '/path1.txt'; // 应用文件路径 - let filePath2: string = context.filesDir + '/path2.txt'; - // 循环写文件操作 - let fileList: string[] = []; - fileList.push(filePath1); - fileList.push(filePath2) - for (let i: number = 0; i < fileList.length; i++) { - write('Hello World!', fileList[i]).then(() => { - console.info(`Succeeded in writing the file. FileList: ${fileList[i]}`); - }).catch((err: BusinessError) => { - console.error(`Failed to write the file. Code is ${err.code}, message is ${err.message}`) - return false; - }) - } - return true; -} -// [End define_concurrent_function] - -// [Start taskpool_execute_concurrent_function] -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - let context = getContext() as common.UIAbilityContext; - // 使用TaskPool执行包含密集I/O的并发函数 - // 数组较大时,I/O密集型任务任务分发也会抢占UI主线程,需要使用多线程能力 - taskpool.execute(concurrentTest, context).then(() => { - // 调度结果处理 - console.info('taskpool: execute success') - }) - this.message = 'success'; - }) - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start define_concurrent_function] +import { write } from './write' +import { BusinessError } from '@kit.BasicServicesKit'; +import { taskpool } from '@kit.ArkTS'; +import { common } from '@kit.AbilityKit'; + +@Concurrent +async function concurrentTest(context: common.UIAbilityContext): Promise { + let filePath1: string = context.filesDir + '/path1.txt'; // 应用文件路径 + let filePath2: string = context.filesDir + '/path2.txt'; + // 循环写文件操作 + let fileList: string[] = []; + fileList.push(filePath1); + fileList.push(filePath2) + for (let i: number = 0; i < fileList.length; i++) { + write('Hello World!', fileList[i]).then(() => { + console.info(`Succeeded in writing the file. FileList: ${fileList[i]}`); + }).catch((err: BusinessError) => { + console.error(`Failed to write the file. Code is ${err.code}, message is ${err.message}`) + return false; + }) + } + return true; +} +// [End define_concurrent_function] + +// [Start taskpool_execute_concurrent_function] +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + let context = getContext() as common.UIAbilityContext; + // 使用TaskPool执行包含密集I/O的并发函数 + // 数组较大时,I/O密集型任务任务分发也会抢占UI主线程,需要使用多线程能力 + taskpool.execute(concurrentTest, context).then(() => { + // 调度结果处理 + console.info('taskpool: execute success') + }) + this.message = 'success'; + }) + } + .width('100%') + } + .height('100%') + } +} // [End taskpool_execute_concurrent_function] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/LongTimeTaskGuide.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/LongTimeTaskGuide.ets old mode 100755 new mode 100644 index fb99d63f4f..8258d4a0aa --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/LongTimeTaskGuide.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/LongTimeTaskGuide.ets @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start taskpool_listen_sensor_data] -import { sensor } from '@kit.SensorServiceKit'; -import { taskpool } from '@kit.ArkTS'; -import { BusinessError, emitter } from '@kit.BasicServicesKit'; - -@Concurrent -async function sensorListener(): Promise { - sensor.on(sensor.SensorId.ACCELEROMETER, (data) => { - emitter.emit({ eventId: 0 }, { data: data }); - }, { interval: 1000000000 }); - - emitter.on({ eventId: 1 }, () => { - sensor.off(sensor.SensorId.ACCELEROMETER) - emitter.off(1) - }) -} - -@Entry -@Component -struct Index { - sensorTask?: taskpool.LongTask - @State addListener: string = 'Add listener'; - @State deleteListener: string = 'Delete listener'; - - build() { - Column() { - Text(this.addListener) - .id('Add listener') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - this.sensorTask = new taskpool.LongTask(sensorListener); - emitter.on({ eventId: 0 }, (data) => { - // Do something here - console.info(`Receive ACCELEROMETER data: {${data.data?.x}, ${data.data?.y}, ${data.data?.z}`); - }); - taskpool.execute(this.sensorTask).then(() => { - console.info('Add listener of ACCELEROMETER success'); - }).catch((e: BusinessError) => { - // Process error - }) - this.addListener = 'success'; - }) - Text(this.deleteListener) - .id('Delete listener') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - emitter.emit({ eventId: 1 }); - emitter.off(0); - if (this.sensorTask != undefined) { - taskpool.terminateTask(this.sensorTask); - } else { - console.error('sensorTask is undefined.'); - } - this.deleteListener = 'success'; - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start taskpool_listen_sensor_data] +import { sensor } from '@kit.SensorServiceKit'; +import { taskpool } from '@kit.ArkTS'; +import { BusinessError, emitter } from '@kit.BasicServicesKit'; + +@Concurrent +async function sensorListener(): Promise { + sensor.on(sensor.SensorId.ACCELEROMETER, (data) => { + emitter.emit({ eventId: 0 }, { data: data }); + }, { interval: 1000000000 }); + + emitter.on({ eventId: 1 }, () => { + sensor.off(sensor.SensorId.ACCELEROMETER) + emitter.off(1) + }) +} + +@Entry +@Component +struct Index { + sensorTask?: taskpool.LongTask + @State addListener: string = 'Add listener'; + @State deleteListener: string = 'Delete listener'; + + build() { + Column() { + Text(this.addListener) + .id('Add listener') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.sensorTask = new taskpool.LongTask(sensorListener); + emitter.on({ eventId: 0 }, (data) => { + // Do something here + console.info(`Receive ACCELEROMETER data: {${data.data?.x}, ${data.data?.y}, ${data.data?.z}`); + }); + taskpool.execute(this.sensorTask).then(() => { + console.info('Add listener of ACCELEROMETER success'); + }).catch((e: BusinessError) => { + // Process error + }) + this.addListener = 'success'; + }) + Text(this.deleteListener) + .id('Delete listener') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + emitter.emit({ eventId: 1 }); + emitter.off(0); + if (this.sensorTask != undefined) { + taskpool.terminateTask(this.sensorTask); + } else { + console.error('sensorTask is undefined.'); + } + this.deleteListener = 'success'; + }) + } + .height('100%') + .width('100%') + } +} // [End taskpool_listen_sensor_data] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/ResidentTaskGuide.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/ResidentTaskGuide.ets old mode 100755 new mode 100644 index 8acafb33dd..beed792392 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/ResidentTaskGuide.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/ResidentTaskGuide.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start worker_receive_child_thread_message] -import { worker } from '@kit.ArkTS'; -import resource from '../util/resource'; - -const workerInstance: worker.ThreadWorker = new worker.ThreadWorker('entry/ets/workers/Worker.ets'); - -@Entry -@Component -struct Index { - @State message: string = 'Listener task'; - - build() { - Column() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - workerInstance.postMessage({ type: 'End' }); - workerInstance.onmessage = (event) => { - console.info(resource.resourceToString($r('app.string.Information')), event.data); - } - // 10秒后停止worker - setTimeout(() => { - workerInstance.postMessage({ type: 'stop' }); - }, 10000); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start worker_receive_child_thread_message] +import { worker } from '@kit.ArkTS'; +import resource from '../util/resource'; + +const workerInstance: worker.ThreadWorker = new worker.ThreadWorker('entry/ets/workers/Worker.ets'); + +@Entry +@Component +struct Index { + @State message: string = 'Listener task'; + + build() { + Column() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + workerInstance.postMessage({ type: 'End' }); + workerInstance.onmessage = (event) => { + console.info(resource.resourceToString($r('app.string.Information')), event.data); + } + // 10秒后停止worker + setTimeout(() => { + workerInstance.postMessage({ type: 'stop' }); + }, 10000); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} // [End worker_receive_child_thread_message] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/SyncTaskDevelopment.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/SyncTaskDevelopment.ets old mode 100755 new mode 100644 index 7d8b8ebdf5..af8005c9a9 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/SyncTaskDevelopment.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/SyncTaskDevelopment.ets @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start taskpool_handle_sync_task] -import { worker } from '@kit.ArkTS'; -import { taskpool } from '@kit.ArkTS'; - -// 步骤1: 定义并发函数,实现业务逻辑 -@Concurrent -async function taskpoolFunc(num: number): Promise { - // 根据业务逻辑实现相应的功能 - let tmpNum: number = num + 100; - return tmpNum; -} - -async function mainFunc(): Promise { - // 步骤2: 创建任务并执行 - let task1: taskpool.Task = new taskpool.Task(taskpoolFunc, 1); - let res1: number = await taskpool.execute(task1) as number; - let task2: taskpool.Task = new taskpool.Task(taskpoolFunc, res1); - let res2: number = await taskpool.execute(task2) as number; - // 步骤3: 对任务返回的结果进行操作 - console.info('taskpool: task res1 is: ' + res1); - console.info('taskpool: task res2 is: ' + res2); -} - -// [Start worker_handle_associated_sync_task] -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(async () => { - mainFunc(); - let w: worker.ThreadWorker = new worker.ThreadWorker('entry/ets/workers/MyWorker2.ts'); - w.onmessage = (): void => { - // 接收Worker子线程的结果 - } - w.onerror = (): void => { - // 接收Worker子线程的错误信息 - } - // 向Worker子线程发送Set消息 - w.postMessage({ 'type': 0, 'data': 'data' }); - // 向Worker子线程发送Get消息 - w.postMessage({ 'type': 1 }); - // ... - // 根据实际业务,选择时机以销毁线程 - w.terminate(); - this.message = 'success'; - }) - } - .width('100%') - } - .height('100%') - } -} -// [End worker_handle_associated_sync_task] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start taskpool_handle_sync_task] +import { worker } from '@kit.ArkTS'; +import { taskpool } from '@kit.ArkTS'; + +// 步骤1: 定义并发函数,实现业务逻辑 +@Concurrent +async function taskpoolFunc(num: number): Promise { + // 根据业务逻辑实现相应的功能 + let tmpNum: number = num + 100; + return tmpNum; +} + +async function mainFunc(): Promise { + // 步骤2: 创建任务并执行 + let task1: taskpool.Task = new taskpool.Task(taskpoolFunc, 1); + let res1: number = await taskpool.execute(task1) as number; + let task2: taskpool.Task = new taskpool.Task(taskpoolFunc, res1); + let res2: number = await taskpool.execute(task2) as number; + // 步骤3: 对任务返回的结果进行操作 + console.info('taskpool: task res1 is: ' + res1); + console.info('taskpool: task res2 is: ' + res2); +} + +// [Start worker_handle_associated_sync_task] +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(async () => { + mainFunc(); + let w: worker.ThreadWorker = new worker.ThreadWorker('entry/ets/workers/MyWorker2.ts'); + w.onmessage = (): void => { + // 接收Worker子线程的结果 + } + w.onerror = (): void => { + // 接收Worker子线程的错误信息 + } + // 向Worker子线程发送Set消息 + w.postMessage({ 'type': 0, 'data': 'data' }); + // 向Worker子线程发送Get消息 + w.postMessage({ 'type': 1 }); + // ... + // 根据实际业务,选择时机以销毁线程 + w.terminate(); + this.message = 'success'; + }) + } + .width('100%') + } + .height('100%') + } +} +// [End worker_handle_associated_sync_task] // [End taskpool_handle_sync_task] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/write.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/write.ets old mode 100755 new mode 100644 index 080687d4cd..ddc321a216 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/write.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/managers/write.ets @@ -1,26 +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. - */ - -// [Start define_concurrent_function] -import { fileIo } from '@kit.CoreFileKit'; - -// 定义并发函数,内部密集调用I/O能力 -// 写入文件的实现 -export async function write(data: string, filePath: string): Promise { - let file: fileIo.File = await fileIo.open(filePath, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); - await fileIo.write(file.fd, data); - fileIo.close(file); -} -// [End define_concurrent_function] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start define_concurrent_function] +import { fileIo } from '@kit.CoreFileKit'; + +// 定义并发函数,内部密集调用I/O能力 +// 写入文件的实现 +export async function write(data: string, filePath: string): Promise { + let file: fileIo.File = await fileIo.open(filePath, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); + await fileIo.write(file.fd, data); + fileIo.close(file); +} +// [End define_concurrent_function] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/util/resource.ets old mode 100755 new mode 100644 index de30eb4b1b..723a394265 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/util/resource.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/util/resource.ets @@ -1,25 +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. - */ - -export class P2PManager { - public resourceToString(resource: Resource): string { - return getContext(this).resourceManager.getStringSync(resource); - } -} - -// 默认导出let -let p2pManager = new P2PManager(); - +/* + * 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 class P2PManager { + public resourceToString(resource: Resource): string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/MyWorker1.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/MyWorker1.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/MyWorker2.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/MyWorker2.ts old mode 100755 new mode 100644 index 305484954b..bcfa8e43c3 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/MyWorker2.ts +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/MyWorker2.ts @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start worker_handle_associated_sync_task] -import { worker, ThreadWorkerGlobalScope, MessageEvents } from '@kit.ArkTS'; -import Handle from './handle'; // 返回句柄 - -let workerPort: ThreadWorkerGlobalScope = worker.workerPort; - -// 无法传输的句柄,所有操作依赖此句柄 -let handler: Handle = new Handle() - -// Worker线程的onmessage逻辑 -workerPort.onmessage = (e: MessageEvents): void => { - switch (e.data.type as number) { - case 0: - handler.syncSet(e.data.data); - workerPort.postMessage('success set'); - break; - case 1: - handler.syncGet(); - workerPort.postMessage('success get'); - break; - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start worker_handle_associated_sync_task] +import { worker, ThreadWorkerGlobalScope, MessageEvents } from '@kit.ArkTS'; +import Handle from './handle'; // 返回句柄 + +let workerPort: ThreadWorkerGlobalScope = worker.workerPort; + +// 无法传输的句柄,所有操作依赖此句柄 +let handler: Handle = new Handle() + +// Worker线程的onmessage逻辑 +workerPort.onmessage = (e: MessageEvents): void => { + switch (e.data.type as number) { + case 0: + handler.syncSet(e.data.data); + workerPort.postMessage('success set'); + break; + case 1: + handler.syncGet(); + workerPort.postMessage('success get'); + break; + } +} // [End worker_handle_associated_sync_task] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/Worker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/Worker.ets old mode 100755 new mode 100644 index 5284d6d013..a6f690fd65 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/Worker.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/Worker.ets @@ -1,43 +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. - */ - -// [Start worker_correspond_main_thread] -import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; -const workerPort: ThreadWorkerGlobalScope = worker.workerPort; -let isRunning = false; -workerPort.onmessage = (e: MessageEvents) => { - const type = e.data.type as string; - if (type === 'End') { - if (!isRunning) { - isRunning = true; - // 开始常驻任务 - performTask(); - } - } else if (type === 'stop') { - isRunning = false; - workerPort.close(); // 关闭Worker - } -} -// 模拟常驻任务 -function performTask() { - if (isRunning) { - // 模拟某个长期运行的任务 - workerPort.postMessage('Worker is performing a task'); - // 1秒后再次执行任务 - setTimeout(performTask, 1000); - } - workerPort.postMessage('Worker is stop performing a task'); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start worker_correspond_main_thread] +import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; +const workerPort: ThreadWorkerGlobalScope = worker.workerPort; +let isRunning = false; +workerPort.onmessage = (e: MessageEvents) => { + const type = e.data.type as string; + if (type === 'End') { + if (!isRunning) { + isRunning = true; + // 开始常驻任务 + performTask(); + } + } else if (type === 'stop') { + isRunning = false; + workerPort.close(); // 关闭Worker + } +} +// 模拟常驻任务 +function performTask() { + if (isRunning) { + // 模拟某个长期运行的任务 + workerPort.postMessage('Worker is performing a task'); + // 1秒后再次执行任务 + setTimeout(performTask, 1000); + } + workerPort.postMessage('Worker is stop performing a task'); +} // [End worker_correspond_main_thread] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/handle.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/handle.ts old mode 100755 new mode 100644 index 2483125087..0fa31c5bcb --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/handle.ts +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/ets/workers/handle.ts @@ -1,26 +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. - */ - -// [Start worker_handle_associated_sync_task] -export default class Handle { - syncGet() { - return; - } - - syncSet(num: number) { - return; - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start worker_handle_associated_sync_task] +export default class Handle { + syncGet() { + return; + } + + syncSet(num: number) { + return; + } +} // [End worker_handle_associated_sync_task] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/ohosTest.md old mode 100755 new mode 100644 index 980b4e8b35..8d9208aab9 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/ohosTest.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/ohosTest.md @@ -1,12 +1,12 @@ -# ApplicationMultithreading 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------- | ----------------------------------- | ----------------------------------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| CPU密集型任务开发指导 | 位于CpuIntensiveTaskDevelopment.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| I/O密集型任务开发指导 | 位于IoIntensiveTaskDevelopment.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 同步任务开发指导 | 位于SyncTaskDevelopment.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 长时任务开发指导 | 位于LongTimeTaskGuide.ets | 点击Add listener,然后点击Delete listener | 1秒后页面显示“success” | Pass | Pass | +# ApplicationMultithreading 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------- | ----------------------------------- | ----------------------------------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| CPU密集型任务开发指导 | 位于CpuIntensiveTaskDevelopment.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| I/O密集型任务开发指导 | 位于IoIntensiveTaskDevelopment.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 同步任务开发指导 | 位于SyncTaskDevelopment.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 长时任务开发指导 | 位于LongTimeTaskGuide.ets | 点击Add listener,然后点击Delete listener | 1秒后页面显示“success” | Pass | Pass | | 常驻任务开发指导 | 位于ResidentTaskGuide.ets | 点击Listener task | 1秒后页面显示“success” | Pass | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/screenshots/ApplicationMultithreading_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/screenshots/ApplicationMultithreading_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/screenshots/ApplicationMultithreading_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/ApplicationMultithreading/screenshots/ApplicationMultithreading_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/app.json5 new file mode 100644 index 0000000000..d17398e521 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/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.nativeinterthreadshared", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..a7b49bb830 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NativeInterthreadShared" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/README.md new file mode 100644 index 0000000000..10db80f66c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/README.md @@ -0,0 +1,78 @@ +# ArkTS C++线程间数据共享场景 + +### 介绍 + +当应用在C++层进行多线程的并发计算时,因为ArkTS的API需要在ArkTS的环境执行,为了避免在非UI主线程每次回调等待UI主线程ArkTS环境中执行的API调用结果,需要在这些C++线程上创建ArkTS执行环境和直接调用API,并且可能需要在C++线程之间对Sendable对象进行共享和操作。 + +为了支持此类场景,需要实现在C++线程上创建调用ArkTS的能力,其次还需要对Sendable对象进行多线程共享和操作。 + +该工程中展示的代码详细描述可查如下链接: + +- [C++线程间数据共享场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/native-interthread-shared.md) + +### 效果预览 + +| 首页 | 执行结果 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击hello world,开始执行。 +2. 执行结果会即时反馈在屏幕中央。 + +### 工程目录 + +``` +entry/src + ├──main + │ ├── cpp + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp // Naitve实现加载ArkTS模块的能力示例代码 + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 暴露接口 + │ │ │ │ ├── oh-package.json5 + │ ├── ets + │ │ ├── entryability + │ │ │ ├── EntryAbility.ets + │ │ ├── entrybackupability + │ │ │ ├── EntryBackupAbility.ets + │ │ ├── pages + │ │ ├── Index.ets // UI主线程发起调用示例代码 + │ │ ├── SendableObjTest.ets // ArkTS文件定义示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖s + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared > .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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/code-linter.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/code-linter.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/build-profile.json5 new file mode 100644 index 0000000000..471250ade0 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/build-profile.json5 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["arm64-v8a", "x86_64", "armeabi-v7a"] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "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/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/obfuscation-rules.txt rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..c0d30fecd1 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,15 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(MyApplication) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..e14476cf28 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start native_deserialize_sendable] +// [Start native_load_arkts_module] +#include + +#include "napi/native_api.h" + +static void* g_serializationData = nullptr; +static void* CreateEnvAndSendSendable(void*) +{ + // 1. 创建基础运行环境 + napi_env env = nullptr; + napi_status ret = napi_create_ark_runtime(&env); + if (ret != napi_ok) { + std::abort(); + } + // 2. 加载自定义模块,假定SendableObjTest中提供创建sendable对象的方法newSendable + napi_value test = nullptr; + ret = napi_load_module_with_info( + env, "entry/src/main/ets/pages/SendableObjTest", "com.example.myapplication/entry", &test); + if (ret != napi_ok) { + std::abort(); + } + napi_value sendableObjTest = nullptr; + ret = napi_get_named_property(env, test, "SendableObjTest", &sendableObjTest); + if (ret != napi_ok) { + std::abort(); + } + // 3. 使用ArkTS中的newSendable,假设sendableObjTest中有一个函数newSendable能返回sendable对象 + napi_value newSendable = nullptr; + ret = napi_get_named_property(env, sendableObjTest, "newSendable", &newSendable); + if (ret != napi_ok) { + std::abort(); + } + // 4. 调用newSendable函数返回新创建的sendable对象,并保存在result中 + napi_value result = nullptr; + ret = napi_call_function(env, sendableObjTest, newSendable, 0, nullptr, &result); + if (ret != napi_ok) { + std::abort(); + } + // 5. 序列化sendable对象 + napi_value undefined; + napi_get_undefined(env, &undefined); + ret = napi_serialize(env, result, undefined, undefined, &g_serializationData); + if (ret != napi_ok) { + std::abort(); + } + return nullptr; +} +// [End native_load_arkts_module] + +static void* CreateEnvAndReceiveSendable(void*) +{ + // 1. 创建基础运行环境 + napi_env env = nullptr; + napi_status ret = napi_create_ark_runtime(&env); + if (ret != napi_ok) { + std::abort(); + } + // 2. 反序列化获取sendable共享对象,结果保存在result中,这个result就可以通过napi接口进行各种操作了 + napi_value result = nullptr; + ret = napi_deserialize(env, g_serializationData, &result); + if (ret != napi_ok) { + std::abort(); + } + // 3. 删除序列化数据 + ret = napi_delete_serialization_data(env, g_serializationData); + if (ret != napi_ok) { + std::abort(); + } + napi_valuetype valuetype0; + napi_typeof(env, result, &valuetype0); + if (valuetype0 != napi_number) { + std::abort(); + } + int value0; + napi_get_value_int32(env, result, &value0); + // 1024是判断ArkTS返回的结果是否正确 + if (value0 != 1024) { + std::abort(); + } + return nullptr; +} + +static napi_value TestSendSendable([[maybe_unused]] napi_env env, [[maybe_unused]] napi_callback_info info) +{ + std::thread t1(CreateEnvAndSendSendable, nullptr); + t1.join(); + std::thread t2(CreateEnvAndReceiveSendable, nullptr); + t2.join(); + return nullptr; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { { "testSendSendable", nullptr, TestSendSendable, nullptr, nullptr, nullptr, + napi_default, nullptr } }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} +// [End native_deserialize_sendable] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..f0e869789e --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start native_deserialize_sendable] +export const testSendSendable: () => void; +// [End native_deserialize_sendable] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..a650926654 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start main_thread_init_call] +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; +import { SendableObjTest } from './SendableObjTest' + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + SendableObjTest.newSendable() + hilog.info(0x0000, 'testTag', 'Test send Sendable begin'); + testNapi.testSendSendable(); + hilog.info(0x0000, 'testTag', 'Test send Sendable end'); + this.message = 'success'; + }) + } + .width('100%') + } + .height('100%') + } +} +// [End main_thread_init_call] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/SendableObjTest.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/SendableObjTest.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/SendableObjTest.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/SendableObjTest.ets index 81525e7578..4980f9ffd0 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/SendableObjTest.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/SendableObjTest.ets @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start arkts_define_obj] -@Sendable -export class SendableObjTest { - static newSendable() { - return 1024; - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start arkts_define_obj] +@Sendable +export class SendableObjTest { + static newSendable() { + return 1024; + } +} // [End arkts_define_obj] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/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/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/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.1", + "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/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/ohosTest.md new file mode 100644 index 0000000000..87004cca5e --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/ohosTest.md @@ -0,0 +1,8 @@ +# NativeInterthreadShared 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| C++线程间数据共享场景 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/screenshots/NativeInterthreadShared_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/screenshots/NativeInterthreadShared_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/screenshots/NativeInterthreadShared_1.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/screenshots/NativeInterthreadShared_1.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/screenshots/NativeInterthreadShared_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/screenshots/NativeInterthreadShared_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/screenshots/NativeInterthreadShared_2.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/screenshots/NativeInterthreadShared_2.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/app.json5 old mode 100755 new mode 100644 index ad1c26ecc3..84ee501b79 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/app.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/app.json5 @@ -1,25 +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.practicalcases", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.practicalcases", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 73a3c2a9cb..1f9360e433 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "PracticalCases" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "PracticalCases" + } + ] +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/README.md old mode 100755 new mode 100644 index 5c89060bda..28a3f6b9df --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/README.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/README.md @@ -1,110 +1,110 @@ -# ArkTS 应用多线程开发实践案例 - -### 介绍 - -#### 使用TaskPool进行频繁数据库操作 - -对于需要频繁数据库操作的场景,由于读写数据库存在耗时,因此推荐在子线程中操作,避免阻塞UI线程。 - -通过ArkTS提供的TaskPool能力,可以将数据库操作任务移到子线程中。 - -#### 业务模块并发加载场景 - -在应用启动过程中,会有多个业务模块需要加载,例如应用的定位、打车、导航等不同的模块,如果全部在UI主线程初始化,则会严重影响冷启动耗时。此时需要在不同子线程并行化加载这些模块功能,降低启动耗时。 - -通过使用ArkTS提供的TaskPool能力,可以将不同业务初始化任务移到子线程中,业务模块通过下沉C++实现成[NativeBinding对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/transferabled-object.md)、或者在ArkTS层定义[Sendable对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-sendable.md),就可以将初始化的模块返回UI主线程调用,实现如下。 - -#### 全局配置项功能场景 - -对于需要使用进程单例的场景,例如不同并发实例间需要数据保持一致的全局配置项业务,可以采用共享模块来实现。 - -#### ArkUI数据更新场景 - -当需要网络下载或者本地生成的数据需要发送到UI线程进行展示时,因为ArkUI的标注和[@Sendable装饰器](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-sendable.md#sendable装饰器)不能同时修饰变量和对象,所以对于此类场景,需要使用[makeObserved](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/quick-start/arkts-new-makeObserved.md)在ArkUI中导入可观察的Sendable共享数据。 - -#### ArkUI瀑布流渲染场景 - -此处提供使用任务池[TaskPool](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-taskpool.md)提升[WaterFlow瀑布流](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-container-waterflow.md)渲染性能的开发指导。UI线程查询数据库数据,并将数据渲染到瀑布流组件,数据过大时会导致UI线程长时间等待,影响用户体验。因此,可以将数据查询操作放到子线程中,并通过TaskPool的接口返回数据给UI线程。 - -该工程中展示的代码详细描述可查如下链接: - -- [批量数据写数据库场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/batch-database-operations-guide.md) -- [业务模块并发加载场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/concurrent-loading-modules-guide.md) -- [全局配置项功能场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/global-configuration-guide.md) -- [ArkUI数据更新场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/makeobserved-sendable.md) -- [ArkUI瀑布流渲染场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/taskpool-waterflow.md) - -### 效果预览 - -| 首页 | 执行及结果 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── managers - │ │ ├── ConcurrentLoadingModulesGuide.ets // 业务模块并发加载场景示例代码 - │ │ ├── Config.ets // 全局配置项功能场景资源代码 - │ │ ├── GlobalConfigurationGuide.ets // 全局配置项功能场景示例代码 - │ │ ├── MakeobservedSendable.ets // ArkUI数据更新场景示例代码 - │ │ ├── Mock.ets // ArkUI瀑布流渲染场景资源代码 - │ │ ├── SendableData.ets // ArkUI数据更新场景资源代码 - │ │ ├── SharedValuesBucket.ets // 使用Sendable进行大容量数据库操作 - │ │ ├── UsingSendable.ets // 使用Sendable进行大容量数据库操作示例代码 - │ │ ├── UsingTaskPool.ets // 使用TaskPool进行频繁数据库操作示例代码 - │ │ ├── WaterfallRendering.ets // ArkUI瀑布流渲染场景示例代码资源代码 - │ │ ├── WaterFlowDataSource.ets // ArkUI瀑布流渲染场景资源代码 - │ │ ├── pages - │ │ ├── Index.ets // 首页 - │ │ ├── sdk - │ │ ├── Calculator.ets // 业务模块并发加载场景资源代码 - │ │ ├── TimerSdk.ets // 业务模块并发加载场景资源代码 - │ │ ├── util - │ │ ├── CommonButton.ets // 首页跳转UI - │ │ ├── resource.ets // 资源引用转换 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# ArkTS 应用多线程开发实践案例 + +### 介绍 + +#### 使用TaskPool进行频繁数据库操作 + +对于需要频繁数据库操作的场景,由于读写数据库存在耗时,因此推荐在子线程中操作,避免阻塞UI线程。 + +通过ArkTS提供的TaskPool能力,可以将数据库操作任务移到子线程中。 + +#### 业务模块并发加载场景 + +在应用启动过程中,会有多个业务模块需要加载,例如应用的定位、打车、导航等不同的模块,如果全部在UI主线程初始化,则会严重影响冷启动耗时。此时需要在不同子线程并行化加载这些模块功能,降低启动耗时。 + +通过使用ArkTS提供的TaskPool能力,可以将不同业务初始化任务移到子线程中,业务模块通过下沉C++实现成[NativeBinding对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/transferabled-object.md)、或者在ArkTS层定义[Sendable对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-sendable.md),就可以将初始化的模块返回UI主线程调用,实现如下。 + +#### 全局配置项功能场景 + +对于需要使用进程单例的场景,例如不同并发实例间需要数据保持一致的全局配置项业务,可以采用共享模块来实现。 + +#### ArkUI数据更新场景 + +当需要网络下载或者本地生成的数据需要发送到UI线程进行展示时,因为ArkUI的标注和[@Sendable装饰器](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-sendable.md#sendable装饰器)不能同时修饰变量和对象,所以对于此类场景,需要使用[makeObserved](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/quick-start/arkts-new-makeObserved.md)在ArkUI中导入可观察的Sendable共享数据。 + +#### ArkUI瀑布流渲染场景 + +此处提供使用任务池[TaskPool](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-taskpool.md)提升[WaterFlow瀑布流](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-container-waterflow.md)渲染性能的开发指导。UI线程查询数据库数据,并将数据渲染到瀑布流组件,数据过大时会导致UI线程长时间等待,影响用户体验。因此,可以将数据查询操作放到子线程中,并通过TaskPool的接口返回数据给UI线程。 + +该工程中展示的代码详细描述可查如下链接: + +- [批量数据写数据库场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/batch-database-operations-guide.md) +- [业务模块并发加载场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/concurrent-loading-modules-guide.md) +- [全局配置项功能场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/global-configuration-guide.md) +- [ArkUI数据更新场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/makeobserved-sendable.md) +- [ArkUI瀑布流渲染场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/taskpool-waterflow.md) + +### 效果预览 + +| 首页 | 执行及结果 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── managers + │ │ ├── ConcurrentLoadingModulesGuide.ets // 业务模块并发加载场景示例代码 + │ │ ├── Config.ets // 全局配置项功能场景资源代码 + │ │ ├── GlobalConfigurationGuide.ets // 全局配置项功能场景示例代码 + │ │ ├── MakeobservedSendable.ets // ArkUI数据更新场景示例代码 + │ │ ├── Mock.ets // ArkUI瀑布流渲染场景资源代码 + │ │ ├── SendableData.ets // ArkUI数据更新场景资源代码 + │ │ ├── SharedValuesBucket.ets // 使用Sendable进行大容量数据库操作 + │ │ ├── UsingSendable.ets // 使用Sendable进行大容量数据库操作示例代码 + │ │ ├── UsingTaskPool.ets // 使用TaskPool进行频繁数据库操作示例代码 + │ │ ├── WaterfallRendering.ets // ArkUI瀑布流渲染场景示例代码资源代码 + │ │ ├── WaterFlowDataSource.ets // ArkUI瀑布流渲染场景资源代码 + │ │ ├── pages + │ │ ├── Index.ets // 首页 + │ │ ├── sdk + │ │ ├── Calculator.ets // 业务模块并发加载场景资源代码 + │ │ ├── TimerSdk.ets // 业务模块并发加载场景资源代码 + │ │ ├── util + │ │ ├── CommonButton.ets // 首页跳转UI + │ │ ├── resource.ets // 资源引用转换 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases > .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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/ConcurrentLoadingModulesGuide.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/ConcurrentLoadingModulesGuide.ets old mode 100755 new mode 100644 index d28b227f74..89275d0f58 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/ConcurrentLoadingModulesGuide.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/ConcurrentLoadingModulesGuide.ets @@ -1,97 +1,97 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start distribute_child_thread] -import { Calculator } from '../sdk/Calculator'; -import { TimerSdk } from '../sdk/TimerSdk'; -import { taskpool } from '@kit.ArkTS'; - -@Concurrent -function initCalculator(): Calculator { - return Calculator.init(); -} - -@Concurrent -function initTimerSdk(): TimerSdk { - return TimerSdk.init(); -} - -@Entry -@Component -struct Index { - @State calculateAdd: string = 'calculate add'; - @State showHistory: string = 'show history'; - @State countdown: string = 'countdown'; - calc?: Calculator; - timer?: TimerSdk; - - aboutToAppear(): void { - taskpool.execute(initCalculator).then((ret) => { - this.calc = ret as Calculator; - }) - taskpool.execute(initTimerSdk).then((ret) => { - this.timer = ret as TimerSdk; - }) - } - - build() { - Row() { - Column() { - Text(this.calculateAdd) - .id('add') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(async () => { - let result = this.calc?.add(1, 2) - console.info(`Result is ${result}`) - this.calculateAdd = 'success'; - }) - Text(this.showHistory) - .id('show') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(async () => { - this.calc?.showHistory(); - this.showHistory = 'success'; - }) - Text(this.countdown) - .id('get') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(async () => { - console.info(`Timer start`); - await this.timer?.Countdown(1000); - console.info(`Timer end`); - this.countdown = 'success'; - }) - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start distribute_child_thread] +import { Calculator } from '../sdk/Calculator'; +import { TimerSdk } from '../sdk/TimerSdk'; +import { taskpool } from '@kit.ArkTS'; + +@Concurrent +function initCalculator(): Calculator { + return Calculator.init(); +} + +@Concurrent +function initTimerSdk(): TimerSdk { + return TimerSdk.init(); +} + +@Entry +@Component +struct Index { + @State calculateAdd: string = 'calculate add'; + @State showHistory: string = 'show history'; + @State countdown: string = 'countdown'; + calc?: Calculator; + timer?: TimerSdk; + + aboutToAppear(): void { + taskpool.execute(initCalculator).then((ret) => { + this.calc = ret as Calculator; + }) + taskpool.execute(initTimerSdk).then((ret) => { + this.timer = ret as TimerSdk; + }) + } + + build() { + Row() { + Column() { + Text(this.calculateAdd) + .id('add') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(async () => { + let result = this.calc?.add(1, 2) + console.info(`Result is ${result}`) + this.calculateAdd = 'success'; + }) + Text(this.showHistory) + .id('show') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(async () => { + this.calc?.showHistory(); + this.showHistory = 'success'; + }) + Text(this.countdown) + .id('get') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(async () => { + console.info(`Timer start`); + await this.timer?.Countdown(1000); + console.info(`Timer end`); + this.countdown = 'success'; + }) + } + .width('100%') + } + .height('100%') + } +} // [End distribute_child_thread] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/Config.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/Config.ets old mode 100755 new mode 100644 index d96061ebb1..17b26eb443 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/Config.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/Config.ets @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start global_config] -import { ArkTSUtils } from '@kit.ArkTS'; - -'use shared' - -@Sendable -class Config { - public lock: ArkTSUtils.locks.AsyncLock = new ArkTSUtils.locks.AsyncLock; - public isLogin: boolean = false; - public loginUser?: string; - public wifiOn: boolean = false; - - async login(user: string) { - return this.lock.lockAsync(() => { - this.isLogin = true; - this.loginUser = user; - }, ArkTSUtils.locks.AsyncLockMode.EXCLUSIVE) - } - - async logout(user?: string) { - return this.lock.lockAsync(() => { - this.isLogin = false; - this.loginUser = ''; - }, ArkTSUtils.locks.AsyncLockMode.EXCLUSIVE) - } - - async getIsLogin(): Promise { - return this.lock.lockAsync(() => { - return this.isLogin; - }, ArkTSUtils.locks.AsyncLockMode.SHARED) - } - - async getUser(): Promise { - return this.lock.lockAsync(() => { - return this.loginUser!; - }, ArkTSUtils.locks.AsyncLockMode.SHARED) - } - - async setWifiState(state: boolean) { - return this.lock.lockAsync(() => { - this.wifiOn = state; - }, ArkTSUtils.locks.AsyncLockMode.EXCLUSIVE) - } - - async isWifiOn() { - return this.lock.lockAsync(() => { - return this.wifiOn; - }, ArkTSUtils.locks.AsyncLockMode.SHARED) - } -} - -export let config = new Config(); +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start global_config] +import { ArkTSUtils } from '@kit.ArkTS'; + +'use shared' + +@Sendable +class Config { + public lock: ArkTSUtils.locks.AsyncLock = new ArkTSUtils.locks.AsyncLock; + public isLogin: boolean = false; + public loginUser?: string; + public wifiOn: boolean = false; + + async login(user: string) { + return this.lock.lockAsync(() => { + this.isLogin = true; + this.loginUser = user; + }, ArkTSUtils.locks.AsyncLockMode.EXCLUSIVE) + } + + async logout(user?: string) { + return this.lock.lockAsync(() => { + this.isLogin = false; + this.loginUser = ''; + }, ArkTSUtils.locks.AsyncLockMode.EXCLUSIVE) + } + + async getIsLogin(): Promise { + return this.lock.lockAsync(() => { + return this.isLogin; + }, ArkTSUtils.locks.AsyncLockMode.SHARED) + } + + async getUser(): Promise { + return this.lock.lockAsync(() => { + return this.loginUser!; + }, ArkTSUtils.locks.AsyncLockMode.SHARED) + } + + async setWifiState(state: boolean) { + return this.lock.lockAsync(() => { + this.wifiOn = state; + }, ArkTSUtils.locks.AsyncLockMode.EXCLUSIVE) + } + + async isWifiOn() { + return this.lock.lockAsync(() => { + return this.wifiOn; + }, ArkTSUtils.locks.AsyncLockMode.SHARED) + } +} + +export let config = new Config(); // [End global_config] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/GlobalConfigurationGuide.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/GlobalConfigurationGuide.ets old mode 100755 new mode 100644 index cc6e65b43e..7dae8a9ab8 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/GlobalConfigurationGuide.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/GlobalConfigurationGuide.ets @@ -1,127 +1,127 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start access_global_config] -import { config } from './Config'; -import { taskpool } from '@kit.ArkTS'; - -@Concurrent -async function download() { - if (!await config.isWifiOn()) { - console.info('wifi is off'); - return false; - } - if (!await config.getIsLogin()) { - console.info('not login'); - return false; - } - console.info(`User[${await config.getUser()}] start download ...`); - return true; -} - -@Entry -@Component -struct Index { - @State message: string = 'not login'; - @State wifiState: string = 'wifi off'; - @State downloadResult: string = ''; - input: string = ''; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - TextInput({ placeholder: '请输入用户名' }) - .id('textInput') - .fontSize(20) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onChange((value) => { - this.input = value; - }) - Text('login') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(async () => { - if (!await config.getIsLogin() && this.input) { - this.message = 'login: ' + this.input; - config.login(this.input); - } - }) - .backgroundColor(0xcccccc) - Text('logout') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(async () => { - if (await config.getIsLogin()) { - this.message = 'not login'; - config.logout(); - } - }) - .backgroundColor(0xcccccc) - Text(this.wifiState) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - Toggle({ type: ToggleType.Switch }) - .onChange(async (isOn: boolean) => { - await config.setWifiState(isOn) - this.wifiState = isOn ? 'wifi on' : 'wifi off'; - }) - Text('download') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(async () => { - let ret = await taskpool.execute(download); - this.downloadResult = ret ? 'download success' : 'download fail'; - }) - Text(this.downloadResult) - .fontSize(20) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start access_global_config] +import { config } from './Config'; +import { taskpool } from '@kit.ArkTS'; + +@Concurrent +async function download() { + if (!await config.isWifiOn()) { + console.info('wifi is off'); + return false; + } + if (!await config.getIsLogin()) { + console.info('not login'); + return false; + } + console.info(`User[${await config.getUser()}] start download ...`); + return true; +} + +@Entry +@Component +struct Index { + @State message: string = 'not login'; + @State wifiState: string = 'wifi off'; + @State downloadResult: string = ''; + input: string = ''; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + TextInput({ placeholder: '请输入用户名' }) + .id('textInput') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onChange((value) => { + this.input = value; + }) + Text('login') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(async () => { + if (!await config.getIsLogin() && this.input) { + this.message = 'login: ' + this.input; + config.login(this.input); + } + }) + .backgroundColor(0xcccccc) + Text('logout') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(async () => { + if (await config.getIsLogin()) { + this.message = 'not login'; + config.logout(); + } + }) + .backgroundColor(0xcccccc) + Text(this.wifiState) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + Toggle({ type: ToggleType.Switch }) + .onChange(async (isOn: boolean) => { + await config.setWifiState(isOn) + this.wifiState = isOn ? 'wifi on' : 'wifi off'; + }) + Text('download') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(async () => { + let ret = await taskpool.execute(download); + this.downloadResult = ret ? 'download success' : 'download fail'; + }) + Text(this.downloadResult) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + } + .width('100%') + } + .height('100%') + } +} // [End access_global_config] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/MakeobservedSendable.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/MakeobservedSendable.ets old mode 100755 new mode 100644 index d6343f2db6..f35e630a98 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/MakeobservedSendable.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/MakeobservedSendable.ets @@ -1,59 +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. - */ - -// [Start update_arkui_data] -import { taskpool } from '@kit.ArkTS'; -import { SendableData } from './SendableData'; -import { UIUtils } from '@kit.ArkUI'; - -@Concurrent -function threadGetData(param: string): SendableData { - // 在子线程处理数据 - let ret = new SendableData(); - console.info(`Concurrent threadGetData, param ${param}`); - ret.name = param + '-o'; - ret.age = Math.floor(Math.random() * 40); - ret.likes = Math.floor(Math.random() * 100); - return ret; -} - -@Entry -@ComponentV2 -struct Index { - // 通过makeObserved给普通对象或是Sendable对象添加可观察能力 - @Local send: SendableData = UIUtils.makeObserved(new SendableData()); - - build() { - Column() { - Text(this.send.name) - Button('change name').onClick(() => { - // 可以观察到属性的改变 - this.send.name += '0'; - }) - .id('change name') - Button('task').onClick(() => { - // 将待执行的函数放入taskpool内部任务队列等待,等待分发到工作线程执行。 - // 因为数据的构建和处理可以在子线程中完成,但有观察能力的数据不能传给子线程,只有在UI主线程里才可以操作可观察的数据。 - // 所以这里只是将`this.send`的属性`name`传给子线程操作。 - taskpool.execute(threadGetData, this.send.name).then(val => { - // 和@Local一起使用,可以观察this.send的变化 - this.send = UIUtils.makeObserved(val as SendableData); - }) - }) - .id('task') - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start update_arkui_data] +import { taskpool } from '@kit.ArkTS'; +import { SendableData } from './SendableData'; +import { UIUtils } from '@kit.ArkUI'; + +@Concurrent +function threadGetData(param: string): SendableData { + // 在子线程处理数据 + let ret = new SendableData(); + console.info(`Concurrent threadGetData, param ${param}`); + ret.name = param + '-o'; + ret.age = Math.floor(Math.random() * 40); + ret.likes = Math.floor(Math.random() * 100); + return ret; +} + +@Entry +@ComponentV2 +struct Index { + // 通过makeObserved给普通对象或是Sendable对象添加可观察能力 + @Local send: SendableData = UIUtils.makeObserved(new SendableData()); + + build() { + Column() { + Text(this.send.name) + Button('change name').onClick(() => { + // 可以观察到属性的改变 + this.send.name += '0'; + }) + .id('change name') + Button('task').onClick(() => { + // 将待执行的函数放入taskpool内部任务队列等待,等待分发到工作线程执行。 + // 因为数据的构建和处理可以在子线程中完成,但有观察能力的数据不能传给子线程,只有在UI主线程里才可以操作可观察的数据。 + // 所以这里只是将`this.send`的属性`name`传给子线程操作。 + taskpool.execute(threadGetData, this.send.name).then(val => { + // 和@Local一起使用,可以观察this.send的变化 + this.send = UIUtils.makeObserved(val as SendableData); + }) + }) + .id('task') + } + } +} // [End update_arkui_data] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/Mock.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/Mock.ets old mode 100755 new mode 100644 index 575da5e6cf..6a170811d4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/Mock.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/Mock.ets @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start query_database_return_main_thread] -import { taskpool } from '@kit.ArkTS'; -import { fillImg } from './WaterfallRendering'; - -@Concurrent -function query() { - console.info('TaskPoolTest-this is query'); - let result = new Array(33); - for (let i = 0; i < 33; i++) { - result[i] = 'Image' + i; - } - taskpool.Task.sendData(result); -} - -export function getImgFromDB() { - //此处模拟查询数据库,并返回数据 - let task = new taskpool.Task(query); - task.onReceiveData(fillImg); - taskpool.execute(task); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start query_database_return_main_thread] +import { taskpool } from '@kit.ArkTS'; +import { fillImg } from './WaterfallRendering'; + +@Concurrent +function query() { + console.info('TaskPoolTest-this is query'); + let result = new Array(33); + for (let i = 0; i < 33; i++) { + result[i] = 'Image' + i; + } + taskpool.Task.sendData(result); +} + +export function getImgFromDB() { + //此处模拟查询数据库,并返回数据 + let task = new taskpool.Task(query); + task.onReceiveData(fillImg); + taskpool.execute(task); +} // [End query_database_return_main_thread] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/SendableData.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/SendableData.ets old mode 100755 new mode 100644 index 257afb98c3..017a3125fa --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/SendableData.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/SendableData.ets @@ -1,25 +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. - */ - -// [Start define_sendable_class] -@Sendable -export class SendableData { - public name: string = 'Tom'; - public age: number = 20; - public gender: number = 1; - public likes: number = 1; - public follow: boolean = false; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start define_sendable_class] +@Sendable +export class SendableData { + public name: string = 'Tom'; + public age: number = 20; + public gender: number = 1; + public likes: number = 1; + public follow: boolean = false; +} // [End define_sendable_class] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/SharedValuesBucket.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/SharedValuesBucket.ets old mode 100755 new mode 100644 index e8b0c3eb41..aef09be5aa --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/SharedValuesBucket.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/SharedValuesBucket.ets @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start define_data_format] -export interface IValueBucket { - id: number; - name: string; - age: number; - salary: number; -} - -@Sendable -export class SharedValuesBucket implements IValueBucket { - public id: number = 0; - public name: string = ''; - public age: number = 0; - public salary: number = 0; - - constructor(v: IValueBucket) { - this.id = v.id; - this.name = v.name; - this.age = v.age; - this.salary = v.salary; - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start define_data_format] +export interface IValueBucket { + id: number; + name: string; + age: number; + salary: number; +} + +@Sendable +export class SharedValuesBucket implements IValueBucket { + public id: number = 0; + public name: string = ''; + public age: number = 0; + public salary: number = 0; + + constructor(v: IValueBucket) { + this.id = v.id; + this.name = v.name; + this.age = v.age; + this.salary = v.salary; + } +} // [End define_data_format] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/UsingSendable.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/UsingSendable.ets old mode 100755 new mode 100644 index 128dfa970b..9afb261926 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/UsingSendable.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/UsingSendable.ets @@ -1,145 +1,145 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start taskpool_frequently_operate_database] -import { relationalStore, ValuesBucket } from '@kit.ArkData'; -import { collections, taskpool } from '@kit.ArkTS'; -import { IValueBucket, SharedValuesBucket } from './SharedValuesBucket'; - -@Concurrent -async function create(context: Context) { - const CONFIG: relationalStore.StoreConfig = { - name: 'Store.db', - securityLevel: relationalStore.SecurityLevel.S1, - }; - - // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name - let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); - console.info(`Create Store.db successfully!`); - - // 创建表 - const CREATE_TABLE_SQL = 'CREATE TABLE IF NOT EXISTS test (' + - 'id INTEGER PRIMARY KEY AUTOINCREMENT, ' + - 'name TEXT NOT NULL, ' + - 'age INTEGER, ' + - 'salary REAL, ' + - 'blobType BLOB)'; - await store.executeSql(CREATE_TABLE_SQL); - console.info(`Create table test successfully!`); -} - -@Concurrent -async function insert(context: Context, valueBucketArray: Array) { - const CONFIG: relationalStore.StoreConfig = { - name: 'Store.db', - securityLevel: relationalStore.SecurityLevel.S1, - }; - - // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name - let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); - console.info(`Create Store.db successfully!`); - - // 数据插入 - await store.batchInsert('test', valueBucketArray as Object as Array); -} - -@Concurrent -async function query(context: Context): Promise> { - const CONFIG: relationalStore.StoreConfig = { - name: 'Store.db', - securityLevel: relationalStore.SecurityLevel.S1, - }; - - // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name - let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); - console.info(`Create Store.db successfully!`); - - // 获取结果集 - let predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('test'); - let resultSet = await store.query(predicates); // 查询所有数据 - console.info(`Query data successfully! row count:${resultSet.rowCount}`); - let index = 0; - let result = new Array(resultSet.rowCount); - resultSet.goToFirstRow(); - do { - result[index++] = resultSet.getRow(); - } while (resultSet.goToNextRow()); - resultSet.close(); - return result; -} - -@Concurrent -async function clear(context: Context) { - const CONFIG: relationalStore.StoreConfig = { - name: 'Store.db', - securityLevel: relationalStore.SecurityLevel.S1, - }; - - // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name - await relationalStore.deleteRdbStore(context, CONFIG); - console.info(`Delete Store.db successfully!`); -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(async () => { - let context = getContext(this); - - // 数据准备 - const count = 5 - let valueBucketArray = collections.Array.create(count, undefined); - for (let i = 0; i < count; i++) { - let v: IValueBucket = { - id: i, - name: 'zhangsan' + i, - age: 20, - salary: 5000 + 50 * i - }; - valueBucketArray[i] = new SharedValuesBucket(v); - } - await taskpool.execute(create, context); - await taskpool.execute(insert, context, valueBucketArray); - let index = 0; - let ret: collections.Array = - await taskpool.execute(query, context) as collections.Array; - for (let v of ret.values()) { - console.info(`Row[${index}].id = ${v.id}`) - console.info(`Row[${index}].name = ${v.name}`) - console.info(`Row[${index}].age = ${v.age}`) - console.info(`Row[${index}].salary = ${v.salary}`) - index++ - }; - await taskpool.execute(clear, context); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End taskpool_frequently_operate_database] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start taskpool_frequently_operate_database] +import { relationalStore, ValuesBucket } from '@kit.ArkData'; +import { collections, taskpool } from '@kit.ArkTS'; +import { IValueBucket, SharedValuesBucket } from './SharedValuesBucket'; + +@Concurrent +async function create(context: Context) { + const CONFIG: relationalStore.StoreConfig = { + name: 'Store.db', + securityLevel: relationalStore.SecurityLevel.S1, + }; + + // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name + let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); + console.info(`Create Store.db successfully!`); + + // 创建表 + const CREATE_TABLE_SQL = 'CREATE TABLE IF NOT EXISTS test (' + + 'id INTEGER PRIMARY KEY AUTOINCREMENT, ' + + 'name TEXT NOT NULL, ' + + 'age INTEGER, ' + + 'salary REAL, ' + + 'blobType BLOB)'; + await store.executeSql(CREATE_TABLE_SQL); + console.info(`Create table test successfully!`); +} + +@Concurrent +async function insert(context: Context, valueBucketArray: Array) { + const CONFIG: relationalStore.StoreConfig = { + name: 'Store.db', + securityLevel: relationalStore.SecurityLevel.S1, + }; + + // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name + let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); + console.info(`Create Store.db successfully!`); + + // 数据插入 + await store.batchInsert('test', valueBucketArray as Object as Array); +} + +@Concurrent +async function query(context: Context): Promise> { + const CONFIG: relationalStore.StoreConfig = { + name: 'Store.db', + securityLevel: relationalStore.SecurityLevel.S1, + }; + + // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name + let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); + console.info(`Create Store.db successfully!`); + + // 获取结果集 + let predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('test'); + let resultSet = await store.query(predicates); // 查询所有数据 + console.info(`Query data successfully! row count:${resultSet.rowCount}`); + let index = 0; + let result = new Array(resultSet.rowCount); + resultSet.goToFirstRow(); + do { + result[index++] = resultSet.getRow(); + } while (resultSet.goToNextRow()); + resultSet.close(); + return result; +} + +@Concurrent +async function clear(context: Context) { + const CONFIG: relationalStore.StoreConfig = { + name: 'Store.db', + securityLevel: relationalStore.SecurityLevel.S1, + }; + + // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name + await relationalStore.deleteRdbStore(context, CONFIG); + console.info(`Delete Store.db successfully!`); +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(async () => { + let context = getContext(this); + + // 数据准备 + const count = 5 + let valueBucketArray = collections.Array.create(count, undefined); + for (let i = 0; i < count; i++) { + let v: IValueBucket = { + id: i, + name: 'zhangsan' + i, + age: 20, + salary: 5000 + 50 * i + }; + valueBucketArray[i] = new SharedValuesBucket(v); + } + await taskpool.execute(create, context); + await taskpool.execute(insert, context, valueBucketArray); + let index = 0; + let ret: collections.Array = + await taskpool.execute(query, context) as collections.Array; + for (let v of ret.values()) { + console.info(`Row[${index}].id = ${v.id}`) + console.info(`Row[${index}].name = ${v.name}`) + console.info(`Row[${index}].age = ${v.age}`) + console.info(`Row[${index}].salary = ${v.salary}`) + index++ + }; + await taskpool.execute(clear, context); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End taskpool_frequently_operate_database] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/UsingTaskPool.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/UsingTaskPool.ets old mode 100755 new mode 100644 index 903ef2869d..f8c31644e5 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/UsingTaskPool.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/UsingTaskPool.ets @@ -1,143 +1,143 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start operate_child_thread_data] -import { relationalStore, ValuesBucket } from '@kit.ArkData'; -import { taskpool } from '@kit.ArkTS'; - -@Concurrent -async function create(context: Context) { - const CONFIG: relationalStore.StoreConfig = { - name: 'Store.db', - securityLevel: relationalStore.SecurityLevel.S1, - }; - - // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name - let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); - console.info(`Create Store.db successfully!`); - - // 创建表 - const CREATE_TABLE_SQL = 'CREATE TABLE IF NOT EXISTS test (' + - 'id INTEGER PRIMARY KEY AUTOINCREMENT, ' + - 'name TEXT NOT NULL, ' + - 'age INTEGER, ' + - 'salary REAL, ' + - 'blobType BLOB)'; - await store.executeSql(CREATE_TABLE_SQL); - console.info(`Create table test successfully!`); -} - -@Concurrent -async function insert(context: Context, valueBucketArray: Array) { - const CONFIG: relationalStore.StoreConfig = { - name: 'Store.db', - securityLevel: relationalStore.SecurityLevel.S1, - }; - - // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name - let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); - console.info(`Create Store.db successfully!`); - - // 数据插入 - await store.batchInsert('test', valueBucketArray as Object as Array); -} - -@Concurrent -async function query(context: Context): Promise> { - const CONFIG: relationalStore.StoreConfig = { - name: 'Store.db', - securityLevel: relationalStore.SecurityLevel.S1, - }; - - // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name - let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); - console.info(`Create Store.db successfully!`); - - // 获取结果集 - let predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('test'); - let resultSet = await store.query(predicates); // 查询所有数据 - console.info(`Query data successfully! row count:${resultSet.rowCount}`); - let index = 0; - let result = new Array(resultSet.rowCount) - resultSet.goToFirstRow() - do { - result[index++] = resultSet.getRow(); - } while (resultSet.goToNextRow()); - resultSet.close(); - return result; -} - -@Concurrent -async function clear(context: Context) { - const CONFIG: relationalStore.StoreConfig = { - name: 'Store.db', - securityLevel: relationalStore.SecurityLevel.S1, - }; - - // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name - await relationalStore.deleteRdbStore(context, CONFIG); - console.info(`Delete Store.db successfully!`); -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(async () => { - let context = getContext(this); - - // 数据准备 - const count = 5 - let valueBucketArray = new Array(count); - for (let i = 0; i < count; i++) { - let v: relationalStore.ValuesBucket = { - id: i, - name: 'zhangsan' + i, - age: 20, - salary: 5000 + 50 * i - }; - valueBucketArray[i] = v; - } - await taskpool.execute(create, context); - await taskpool.execute(insert, context, valueBucketArray); - let index = 0; - let ret = await taskpool.execute(query, context) as Array; - for (let v of ret) { - console.info(`Row[${index}].id = ${v.id}`) - console.info(`Row[${index}].name = ${v.name}`) - console.info(`Row[${index}].age = ${v.age}`) - console.info(`Row[${index}].salary = ${v.salary}`) - index++ - }; - await taskpool.execute(clear, context); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End operate_child_thread_data] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start operate_child_thread_data] +import { relationalStore, ValuesBucket } from '@kit.ArkData'; +import { taskpool } from '@kit.ArkTS'; + +@Concurrent +async function create(context: Context) { + const CONFIG: relationalStore.StoreConfig = { + name: 'Store.db', + securityLevel: relationalStore.SecurityLevel.S1, + }; + + // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name + let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); + console.info(`Create Store.db successfully!`); + + // 创建表 + const CREATE_TABLE_SQL = 'CREATE TABLE IF NOT EXISTS test (' + + 'id INTEGER PRIMARY KEY AUTOINCREMENT, ' + + 'name TEXT NOT NULL, ' + + 'age INTEGER, ' + + 'salary REAL, ' + + 'blobType BLOB)'; + await store.executeSql(CREATE_TABLE_SQL); + console.info(`Create table test successfully!`); +} + +@Concurrent +async function insert(context: Context, valueBucketArray: Array) { + const CONFIG: relationalStore.StoreConfig = { + name: 'Store.db', + securityLevel: relationalStore.SecurityLevel.S1, + }; + + // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name + let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); + console.info(`Create Store.db successfully!`); + + // 数据插入 + await store.batchInsert('test', valueBucketArray as Object as Array); +} + +@Concurrent +async function query(context: Context): Promise> { + const CONFIG: relationalStore.StoreConfig = { + name: 'Store.db', + securityLevel: relationalStore.SecurityLevel.S1, + }; + + // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name + let store: relationalStore.RdbStore = await relationalStore.getRdbStore(context, CONFIG); + console.info(`Create Store.db successfully!`); + + // 获取结果集 + let predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('test'); + let resultSet = await store.query(predicates); // 查询所有数据 + console.info(`Query data successfully! row count:${resultSet.rowCount}`); + let index = 0; + let result = new Array(resultSet.rowCount) + resultSet.goToFirstRow() + do { + result[index++] = resultSet.getRow(); + } while (resultSet.goToNextRow()); + resultSet.close(); + return result; +} + +@Concurrent +async function clear(context: Context) { + const CONFIG: relationalStore.StoreConfig = { + name: 'Store.db', + securityLevel: relationalStore.SecurityLevel.S1, + }; + + // 默认数据库文件路径为 context.databaseDir + rdb + StoreConfig.name + await relationalStore.deleteRdbStore(context, CONFIG); + console.info(`Delete Store.db successfully!`); +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(async () => { + let context = getContext(this); + + // 数据准备 + const count = 5 + let valueBucketArray = new Array(count); + for (let i = 0; i < count; i++) { + let v: relationalStore.ValuesBucket = { + id: i, + name: 'zhangsan' + i, + age: 20, + salary: 5000 + 50 * i + }; + valueBucketArray[i] = v; + } + await taskpool.execute(create, context); + await taskpool.execute(insert, context, valueBucketArray); + let index = 0; + let ret = await taskpool.execute(query, context) as Array; + for (let v of ret) { + console.info(`Row[${index}].id = ${v.id}`) + console.info(`Row[${index}].name = ${v.name}`) + console.info(`Row[${index}].age = ${v.age}`) + console.info(`Row[${index}].salary = ${v.salary}`) + index++ + }; + await taskpool.execute(clear, context); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End operate_child_thread_data] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/WaterFlowDataSource.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/WaterFlowDataSource.ets old mode 100755 new mode 100644 index 95d9ebdbff..ea630b8ba1 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/WaterFlowDataSource.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/WaterFlowDataSource.ets @@ -1,144 +1,144 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start encapsulate_waterfall_data_source] -// 实现IDataSource接口的对象,用于瀑布流组件加载数据 -export class WaterFlowDataSource implements IDataSource { - private dataArray: number[] = []; - private listeners: DataChangeListener[] = []; - - constructor() { - for (let i = 0; i < 100; i++) { - this.dataArray.push(i); - } - } - - // 获取索引对应的数据 - public getData(index: number): number { - return this.dataArray[index]; - } - - // 通知控制器数据重新加载 - notifyDataReload(): void { - this.listeners.forEach(listener => { - listener.onDataReloaded(); - }) - } - - // 通知控制器数据增加 - notifyDataAdd(index: number): void { - this.listeners.forEach(listener => { - listener.onDataAdd(index); - }) - } - - // 通知控制器数据变化 - notifyDataChange(index: number): void { - this.listeners.forEach(listener => { - listener.onDataChange(index); - }) - } - - // 通知控制器数据删除 - notifyDataDelete(index: number): void { - this.listeners.forEach(listener => { - listener.onDataDelete(index); - }) - } - - // 通知控制器数据位置变化 - notifyDataMove(from: number, to: number): void { - this.listeners.forEach(listener => { - listener.onDataMove(from, to); - }) - } - - //通知控制器数据批量修改 - notifyDatasetChange(operations: DataOperation[]): void { - this.listeners.forEach(listener => { - listener.onDatasetChange(operations); - }) - } - - // 获取数据总数 - public totalCount(): number { - return this.dataArray.length; - } - - // 注册改变数据的控制器 - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - this.listeners.push(listener); - } - } - - // 注销改变数据的控制器 - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener); - if (pos >= 0) { - this.listeners.splice(pos, 1); - } - } - - // 增加数据 - public add1stItem(): void { - this.dataArray.splice(0, 0, this.dataArray.length); - this.notifyDataAdd(0); - } - - // 在数据尾部增加一个元素 - public addLastItem(): void { - this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length); - this.notifyDataAdd(this.dataArray.length - 1); - } - - // 在指定索引位置增加一个元素 - public addItem(index: number): void { - this.dataArray.splice(index, 0, this.dataArray.length); - this.notifyDataAdd(index); - } - - // 删除第一个元素 - public delete1stItem(): void { - this.dataArray.splice(0, 1); - this.notifyDataDelete(0); - } - - // 删除第二个元素 - public delete2ndItem(): void { - this.dataArray.splice(1, 1); - this.notifyDataDelete(1); - } - - // 删除最后一个元素 - public deleteLastItem(): void { - this.dataArray.splice(-1, 1); - this.notifyDataDelete(this.dataArray.length); - } - - // 在指定索引位置删除一个元素 - public deleteItem(index: number): void { - this.dataArray.splice(index, 1); - this.notifyDataDelete(index); - } - - // 重新加载数据 - public reload(): void { - this.dataArray.splice(1, 1); - this.dataArray.splice(3, 2); - this.notifyDataReload(); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start encapsulate_waterfall_data_source] +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = []; + private listeners: DataChangeListener[] = []; + + constructor() { + for (let i = 0; i < 100; i++) { + this.dataArray.push(i); + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index]; + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length; + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener); + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + this.listeners.splice(pos, 1); + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length); + this.notifyDataAdd(0); + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length); + this.notifyDataAdd(this.dataArray.length - 1); + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length); + this.notifyDataAdd(index); + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1); + this.notifyDataDelete(0); + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1); + this.notifyDataDelete(1); + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1); + this.notifyDataDelete(this.dataArray.length); + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1); + this.notifyDataDelete(index); + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1); + this.dataArray.splice(3, 2); + this.notifyDataReload(); + } +} // [End encapsulate_waterfall_data_source] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/WaterfallRendering.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/WaterfallRendering.ets old mode 100755 new mode 100644 index 2708bae45a..55528d6862 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/WaterfallRendering.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/managers/WaterfallRendering.ets @@ -1,133 +1,133 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start receive_child_thread_data_render_waterfall_component] -import { WaterFlowDataSource } from './WaterFlowDataSource'; -import { getImgFromDB } from './Mock'; -import resource from '../util/resource'; - -// 模拟图片数组 -let img = new Array(33); - -export function fillImg(imgArr: Array) { - img = imgArr; -} - -@Entry -@Component -struct WaterFlowDemo { - @State minSize: number = 80; - @State maxSize: number = 180; - @State fontSize: number = 24; - @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; - scroller: Scroller = new Scroller(); - dataSource: WaterFlowDataSource = new WaterFlowDataSource(); - private itemWidthArray: number[] = []; - private itemHeightArray: number[] = []; - - // 计算FlowItem宽/高 - getSize() { - let ret = Math.floor(Math.random() * this.maxSize); - return (ret > this.minSize ? ret : this.minSize); - } - - // 设置FlowItem的宽/高数组 - setItemSizeArray() { - for (let i = 0; i < 100; i++) { - this.itemWidthArray.push(this.getSize()); - this.itemHeightArray.push(this.getSize()); - } - } - - aboutToAppear() { - this.setItemSizeArray(); - } - - @Builder - itemFoot() { - Column() { - Text(`Footer`) - .fontSize(10) - .backgroundColor(Color.Red) - .width(50) - .height(50) - .align(Alignment.Center) - .margin({ top: 2 }); - } - } - - build() { - Column({ space: 2 }) { - Text('ArkUI WaterFlow Demo') - .onAppear(() => { - getImgFromDB(); - }) - WaterFlow() { - LazyForEach(this.dataSource, (item: number) => { - FlowItem() { - Column() { - Text('N' + item) - .fontSize(12) - .height('16') - .onClick(() => { - }); - // 为了模拟图片加载,使用Text组件显示,正常加载jpg文件时,可以直接使用Image组件 - // 参考 Image(this.img[item % 33]).objectFit(ImageFit.Contain).width('100%').layoutWeight(1) - if (img[item % 33] == null) { - Text(resource.resourceToString($r('app.string.Image_loading'))) - .width('100%') - .layoutWeight(1); - } - Text(img[item % 33]) - .width('100%') - .layoutWeight(1); - } - } - .onAppear(() => { - // 即将触底时提前增加数据 - if (item + 20 == this.dataSource.totalCount()) { - for (let i = 0; i < 100; i++) { - this.dataSource.addLastItem(); - } - } - }) - .width('100%') - .height(this.itemHeightArray[item % 100]) - .backgroundColor(this.colors[item % 5]) - }, (item: string) => item) - } - .columnsTemplate('1fr 1fr') - .columnsGap(10) - .rowsGap(5) - .backgroundColor(0xFAEEE0) - .width('100%') - .height('100%') - .onReachStart(() => { - console.info('TaskPoolTest-waterFlow reach start'); - }) - .onScrollStart(() => { - console.info('TaskPoolTest-waterFlow scroll start'); - }) - .onScrollStop(() => { - console.info('TaskPoolTest-waterFlow scroll stop'); - }) - .onScrollFrameBegin((offset: number, state: ScrollState) => { - console.info('TaskPoolTest-waterFlow scrollFrameBegin offset: ' + offset + ' state: ' + state.toString()); - return { offsetRemain: offset }; - }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start receive_child_thread_data_render_waterfall_component] +import { WaterFlowDataSource } from './WaterFlowDataSource'; +import { getImgFromDB } from './Mock'; +import resource from '../util/resource'; + +// 模拟图片数组 +let img = new Array(33); + +export function fillImg(imgArr: Array) { + img = imgArr; +} + +@Entry +@Component +struct WaterFlowDemo { + @State minSize: number = 80; + @State maxSize: number = 180; + @State fontSize: number = 24; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + scroller: Scroller = new Scroller(); + dataSource: WaterFlowDataSource = new WaterFlowDataSource(); + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + this.setItemSizeArray(); + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }); + } + } + + build() { + Column({ space: 2 }) { + Text('ArkUI WaterFlow Demo') + .onAppear(() => { + getImgFromDB(); + }) + WaterFlow() { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text('N' + item) + .fontSize(12) + .height('16') + .onClick(() => { + }); + // 为了模拟图片加载,使用Text组件显示,正常加载jpg文件时,可以直接使用Image组件 + // 参考 Image(this.img[item % 33]).objectFit(ImageFit.Contain).width('100%').layoutWeight(1) + if (img[item % 33] == null) { + Text(resource.resourceToString($r('app.string.Image_loading'))) + .width('100%') + .layoutWeight(1); + } + Text(img[item % 33]) + .width('100%') + .layoutWeight(1); + } + } + .onAppear(() => { + // 即将触底时提前增加数据 + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem(); + } + } + }) + .width('100%') + .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .columnsTemplate('1fr 1fr') + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onReachStart(() => { + console.info('TaskPoolTest-waterFlow reach start'); + }) + .onScrollStart(() => { + console.info('TaskPoolTest-waterFlow scroll start'); + }) + .onScrollStop(() => { + console.info('TaskPoolTest-waterFlow scroll stop'); + }) + .onScrollFrameBegin((offset: number, state: ScrollState) => { + console.info('TaskPoolTest-waterFlow scrollFrameBegin offset: ' + offset + ' state: ' + state.toString()); + return { offsetRemain: offset }; + }) + } + } +} // [End receive_child_thread_data_render_waterfall_component] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/sdk/Calculator.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/sdk/Calculator.ets old mode 100755 new mode 100644 index 500bd8d995..cb5916ba30 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/sdk/Calculator.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/sdk/Calculator.ets @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start define_calculator_module] -import { collections } from '@kit.ArkTS'; - -@Sendable -export class Calculator { - public history?: collections.Array>; - public totalCount: number = 0; - - static init(): Calculator { - let calc = new Calculator(); - calc.totalCount = 0; - calc.history = collections.Array.create(calc.totalCount, collections.Array.create(2, '')); - return calc; - } - - add(a: number, b: number) { - let result = a + b; - this.newCalc(`${a} + ${b}`, `${result}`); - return result; - } - - sub(a: number, b: number) { - let result = a - b; - this.newCalc(`${a} - ${b}`, `${result}`); - return result; - } - - mul(a: number, b: number) { - let result = a * b; - this.newCalc(`${a} * ${b}`, `${result}`); - return result; - } - - div(a: number, b: number) { - let result = a / b; - this.newCalc(`${a} / ${b}`, `${result}`); - return result; - } - - getHistory(): collections.Array> { - return this.history!; - } - - showHistory() { - for (let i = 0; i < this.totalCount; i++) { - console.info(`${i}: ${this.history![i][0]} = ${this.history![i][1]}`); - } - } - - private newCalc(opt: string, ret: string) { - let newRecord = new collections.Array(opt, ret); - this.totalCount = this.history!.unshift(newRecord); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start define_calculator_module] +import { collections } from '@kit.ArkTS'; + +@Sendable +export class Calculator { + public history?: collections.Array>; + public totalCount: number = 0; + + static init(): Calculator { + let calc = new Calculator(); + calc.totalCount = 0; + calc.history = collections.Array.create(calc.totalCount, collections.Array.create(2, '')); + return calc; + } + + add(a: number, b: number) { + let result = a + b; + this.newCalc(`${a} + ${b}`, `${result}`); + return result; + } + + sub(a: number, b: number) { + let result = a - b; + this.newCalc(`${a} - ${b}`, `${result}`); + return result; + } + + mul(a: number, b: number) { + let result = a * b; + this.newCalc(`${a} * ${b}`, `${result}`); + return result; + } + + div(a: number, b: number) { + let result = a / b; + this.newCalc(`${a} / ${b}`, `${result}`); + return result; + } + + getHistory(): collections.Array> { + return this.history!; + } + + showHistory() { + for (let i = 0; i < this.totalCount; i++) { + console.info(`${i}: ${this.history![i][0]} = ${this.history![i][1]}`); + } + } + + private newCalc(opt: string, ret: string) { + let newRecord = new collections.Array(opt, ret); + this.totalCount = this.history!.unshift(newRecord); + } +} // [End define_calculator_module] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/sdk/TimerSdk.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/sdk/TimerSdk.ets old mode 100755 new mode 100644 index 4e6ffde121..dd41af4f39 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/sdk/TimerSdk.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/sdk/TimerSdk.ets @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start define_timer_module] -@Sendable -export class TimerSdk { - static init(): TimerSdk { - let timer = new TimerSdk(); - return timer; - } - - async Countdown(time: number) { - return new Promise((resolve: (value: boolean) => void) => { - setTimeout(() => { - resolve(true); - }, time); - }); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start define_timer_module] +@Sendable +export class TimerSdk { + static init(): TimerSdk { + let timer = new TimerSdk(); + return timer; + } + + async Countdown(time: number) { + return new Promise((resolve: (value: boolean) => void) => { + setTimeout(() => { + resolve(true); + }, time); + }); + } +} // [End define_timer_module] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/util/resource.ets old mode 100755 new mode 100644 index de30eb4b1b..723a394265 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/util/resource.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/ets/util/resource.ets @@ -1,25 +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. - */ - -export class P2PManager { - public resourceToString(resource: Resource): string { - return getContext(this).resourceManager.getStringSync(resource); - } -} - -// 默认导出let -let p2pManager = new P2PManager(); - +/* + * 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 class P2PManager { + public resourceToString(resource: Resource): string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/ohosTest.md old mode 100755 new mode 100644 index 1f5d4346f5..9ce35f6fce --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/ohosTest.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/ohosTest.md @@ -1,13 +1,13 @@ -# PracticalCases 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------------------------------- | ------------------------------------- | ------------------------------------------------------------ | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 使用TaskPool进行频繁数据库操作 | 位于UsingTaskPool.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 使用Sendable进行大容量数据库操作 | 位于UsingSendable.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 业务模块并发加载场景 | 位于ConcurrentLoadingModulesGuide.ets | 点击calculate add,show history,countdown | 1秒后页面显示“success” | 是 | Pass | -| 全局配置项功能场景 | 位于GlobalConfigurationGuide.ets | 点击change name,task | 1秒后页面显示“success” | 是 | Pass | -| ArkUI数据更新场景 | 位于MakeobservedSendable.ets | 滑动屏幕 | 瀑布流形式加载信息 | 是 | Pass | +# PracticalCases 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------------------- | ------------------------------------- | ------------------------------------------------------------ | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 使用TaskPool进行频繁数据库操作 | 位于UsingTaskPool.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 使用Sendable进行大容量数据库操作 | 位于UsingSendable.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 业务模块并发加载场景 | 位于ConcurrentLoadingModulesGuide.ets | 点击calculate add,show history,countdown | 1秒后页面显示“success” | 是 | Pass | +| 全局配置项功能场景 | 位于GlobalConfigurationGuide.ets | 点击change name,task | 1秒后页面显示“success” | 是 | Pass | +| ArkUI数据更新场景 | 位于MakeobservedSendable.ets | 滑动屏幕 | 瀑布流形式加载信息 | 是 | Pass | | ArkUI瀑布流渲染场景 | 位于WaterfallRendering.ets | 点击wifi on,download,在输入框输入信息,点击login显示信息,点击not login清除信息 | 输入信息显示上方 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/screenshots/PracticalCases_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/screenshots/PracticalCases_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/screenshots/PracticalCases_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/PracticalCases/screenshots/PracticalCases_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/app.json5 new file mode 100644 index 0000000000..ab34d7c0df --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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.asyncconcurrencyoverview", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..69253cafe8 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AsyncConcurrencyOverview" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/README.md new file mode 100644 index 0000000000..5d33a1047d --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/README.md @@ -0,0 +1,66 @@ +# ArkTS 异步并发 (Promise和async/await) + +### 介绍 + +Promise和async/await提供异步并发能力,是标准的JS异步语法。异步代码会被挂起并在之后继续执行,同一时间只有一段代码执行,适用于单次I/O任务的场景开发,例如一次网络请求、一次文件读写等操作。无需另外启动线程执行。 + +异步语法是一种编程语言的特性,允许程序在执行某些操作时不必等待其完成,而是可以继续执行其他操作。该工程中展示的代码详细描述可查如下链接: + +- [异步并发 (Promise和async/await)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/async-concurrency-overview.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击hello world,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 异步并发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview > .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/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/build-profile.json5 new file mode 100644 index 0000000000..69cbbedca4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 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", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/code-linter.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/code-linter.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/build-profile.json5 new file mode 100644 index 0000000000..31bf2f4c4d --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/obfuscation-rules.txt rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/oh-package.json5 new file mode 100644 index 0000000000..4e54d14e1b --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..51bdf85846 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..6b744d7eaa --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 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/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/module.json5 new file mode 100644 index 0000000000..cb5df2316a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 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/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/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/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..5f63462032 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..0df4e83ad0 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 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.1", + "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/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/oh-package.json5 new file mode 100644 index 0000000000..936cf43ead --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/ohosTest.md new file mode 100644 index 0000000000..d1a317c1ac --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/ohosTest.md @@ -0,0 +1,8 @@ +# AsyncConcurrencyOverview 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------- | ------------ | --------------- |------------------| -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 异步并发 | 位于首页 | 点击Hello World | 3秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/screenshots/AsyncConcurrencyOverview_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/screenshots/AsyncConcurrencyOverview_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/screenshots/AsyncConcurrencyOverview_1.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/screenshots/AsyncConcurrencyOverview_1.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/screenshots/AsyncConcurrencyOverview_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/screenshots/AsyncConcurrencyOverview_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/screenshots/AsyncConcurrencyOverview_2.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/AsyncConcurrencyOverview/screenshots/AsyncConcurrencyOverview_2.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/app.json5 new file mode 100644 index 0000000000..f59e115f8c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/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.communicationobjects", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..481db99605 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "CommunicationObjects" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/README.md new file mode 100644 index 0000000000..c623cdfa53 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/README.md @@ -0,0 +1,93 @@ +# ArkTS 线程间通信对象 + +### 介绍 + +#### 普通对象 + +普通对象跨线程时通过拷贝形式传递,两个线程的对象内容一致,但是指向各自线程的隔离内存区间,被分配在各自线程的虚拟机本地堆(LocalHeap)。例如Ecmascript262规范定义的Object、Array、Map等对象是通过这种方式实现跨并发实例通信的。 + +#### ArrayBuffer对象 + +ArrayBuffer内部包含一块Native内存,该ArrayBuffer的JS对象壳被分配在虚拟机本地堆(LocalHeap)。与普通对象一样,需要经过序列化与反序列化拷贝传递,但是Native内存有两种传输方式:拷贝和转移。 + +#### SharedArrayBuffer对象 + +SharedArrayBuffer内部包含一块Native内存,其JS对象壳被分配在虚拟机本地堆(LocalHeap)。支持跨并发实例间共享,但是访问及修改需要采用Atomics类,防止数据竞争。SharedArrayBuffer可以用于多个并发实例间的状态共享或者数据共享。 + +#### Transferable对象(NativeBinding对象) + +Transferable对象(也称为NativeBinding对象)指的是一个JS对象,绑定了一个C++对象,且主体功能由C++提供,其JS对象壳被分配在虚拟机本地堆(LocalHeap)。跨线程传输时可以直接复用同一个C++对象,相比于JS对象的拷贝模式,传输效率较高。因此,可共享或转移的NativeBinding对象也被称为Transferable对象。 + +该工程中展示的代码详细描述可查如下链接: + +- [普通对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/normal-object.md) +- [ArrayBuffer对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arraybuffer-object.md) +- [SharedArrayBuffer对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/shared-arraybuffer-object.md) +- [Transferable对象(NativeBinding对象)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/transferabled-object.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── managers + │ │ ├── ArrayBufferObject.ets // ArrayBuffer对象示例代码 + │ │ ├── NormalObject.ets // 普通对象示例代码 + │ │ ├── pixelMapTest.ets // Transferable对象示例代码 + │ │ ├── SharedArrayBufferObject.ets // SharedArrayBuffer对象示例代码 + │ │ ├── Test.ets // 普通对象示例代码 + │ │ ├── TransferabledObject.ets // Transferable对象示例代码 + │ │ ├── pages + │ │ ├── Index.ets // 首页 + │ │ ├── util + │ │ ├── CommonButton.ets // 首页跳转UI + │ │ ├── resource.ets // 资源引用转换 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects > .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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/code-linter.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/code-linter.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/build-profile.json5 new file mode 100644 index 0000000000..e7569e3056 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/obfuscation-rules.txt rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/oh-package.json5 new file mode 100644 index 0000000000..c9cb6c8174 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..edc2839f20 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/ArrayBufferObject.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/ArrayBufferObject.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/ArrayBufferObject.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/ArrayBufferObject.ets index efe2417d38..cf5c6e3158 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/ArrayBufferObject.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/ArrayBufferObject.ets @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start copy_arraybuffer_transfer] -import { taskpool } from '@kit.ArkTS'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Concurrent -function adjustImageValue(arrayBuffer: ArrayBuffer): ArrayBuffer { - // 对arrayBuffer进行操作 - return arrayBuffer; // 返回值默认转移 -} - -function createImageTask(arrayBuffer: ArrayBuffer, isParamsByTransfer: boolean): taskpool.Task { - let task: taskpool.Task = new taskpool.Task(adjustImageValue, arrayBuffer); - if (!isParamsByTransfer) { // 是否使用转移方式 - // 传递空数组[],全部arrayBuffer参数传递均采用拷贝方式 - task.setTransferList([]); - } - return task; -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - let taskNum = 4; - let arrayBuffer = new ArrayBuffer(1024 * 1024); - let taskPoolGroup = new taskpool.TaskGroup(); - // 创建taskNum个Task - for (let i: number = 0; i < taskNum; i++) { - let arrayBufferSlice: ArrayBuffer = - arrayBuffer.slice(arrayBuffer.byteLength / taskNum * i, arrayBuffer.byteLength / taskNum * (i + 1)); - // 使用拷贝方式传入ArrayBuffer,所以isParamsByTransfer为false - taskPoolGroup.addTask(createImageTask(arrayBufferSlice, false)); - } - // 执行Task - taskpool.execute(taskPoolGroup).then((data) => { - // 返回结果,对数组拼接,获得最终结果 - }).catch((e: BusinessError) => { - console.error(e.message); - }) - // [StartExclude copy_arraybuffer_transfer] - this.message = 'success'; - // [EndExclude copy_arraybuffer_transfer] - }) - } - .height('100%') - .width('100%') - } -} -// [End copy_arraybuffer_transfer] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start copy_arraybuffer_transfer] +import { taskpool } from '@kit.ArkTS'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Concurrent +function adjustImageValue(arrayBuffer: ArrayBuffer): ArrayBuffer { + // 对arrayBuffer进行操作 + return arrayBuffer; // 返回值默认转移 +} + +function createImageTask(arrayBuffer: ArrayBuffer, isParamsByTransfer: boolean): taskpool.Task { + let task: taskpool.Task = new taskpool.Task(adjustImageValue, arrayBuffer); + if (!isParamsByTransfer) { // 是否使用转移方式 + // 传递空数组[],全部arrayBuffer参数传递均采用拷贝方式 + task.setTransferList([]); + } + return task; +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + let taskNum = 4; + let arrayBuffer = new ArrayBuffer(1024 * 1024); + let taskPoolGroup = new taskpool.TaskGroup(); + // 创建taskNum个Task + for (let i: number = 0; i < taskNum; i++) { + let arrayBufferSlice: ArrayBuffer = + arrayBuffer.slice(arrayBuffer.byteLength / taskNum * i, arrayBuffer.byteLength / taskNum * (i + 1)); + // 使用拷贝方式传入ArrayBuffer,所以isParamsByTransfer为false + taskPoolGroup.addTask(createImageTask(arrayBufferSlice, false)); + } + // 执行Task + taskpool.execute(taskPoolGroup).then((data) => { + // 返回结果,对数组拼接,获得最终结果 + }).catch((e: BusinessError) => { + console.error(e.message); + }) + // [StartExclude copy_arraybuffer_transfer] + this.message = 'success'; + // [EndExclude copy_arraybuffer_transfer] + }) + } + .height('100%') + .width('100%') + } +} +// [End copy_arraybuffer_transfer] diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/NormalObject.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/NormalObject.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/NormalObject.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/NormalObject.ets index c509943842..367ff95a2c --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/NormalObject.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/NormalObject.ets @@ -1,59 +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. - */ - -// [Start example_normal_obj] -import { taskpool } from '@kit.ArkTS'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { TestA } from './Test'; - -@Concurrent -async function test1(arg: TestA) { - console.info('TestA name is: ' + arg.name); -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - // 1. 创建Test实例objA - let objA = new TestA('TestA'); - // 2. 创建任务task,将objA传递给该任务,objA非sendable对象,通过序列化传递给子线程 - let task = new taskpool.Task(test1, objA); - // 3. 执行任务 - taskpool.execute(task).then(() => { - console.info('taskpool: execute task success!'); - }).catch((e:BusinessError) => { - console.error(`taskpool: execute task: Code: ${e.code}, message: ${e.message}`); - }) - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End example_normal_obj] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start example_normal_obj] +import { taskpool } from '@kit.ArkTS'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { TestA } from './Test'; + +@Concurrent +async function test1(arg: TestA) { + console.info('TestA name is: ' + arg.name); +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + // 1. 创建Test实例objA + let objA = new TestA('TestA'); + // 2. 创建任务task,将objA传递给该任务,objA非sendable对象,通过序列化传递给子线程 + let task = new taskpool.Task(test1, objA); + // 3. 执行任务 + taskpool.execute(task).then(() => { + console.info('taskpool: execute task success!'); + }).catch((e:BusinessError) => { + console.error(`taskpool: execute task: Code: ${e.code}, message: ${e.message}`); + }) + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End example_normal_obj] diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/SharedArrayBufferObject.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/SharedArrayBufferObject.ets old mode 100755 new mode 100644 similarity index 96% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/SharedArrayBufferObject.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/SharedArrayBufferObject.ets index d535b4450f..29141a392d --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/SharedArrayBufferObject.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/SharedArrayBufferObject.ets @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start example_pass_obj] -import { taskpool } from '@kit.ArkTS'; - -@Concurrent -function transferAtomics(arg1: Int32Array) { - console.info('wait begin::'); - // 使用Atomics进行操作 - let res = Atomics.wait(arg1, 0, 0, 3000); - return res; -} - -@Entry -@Component -struct sharedArrayBuffer { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - // 定义可共享对象 - let sab: SharedArrayBuffer = new SharedArrayBuffer(20); - let int32 = new Int32Array(sab); - let task: taskpool.Task = new taskpool.Task(transferAtomics, int32); - taskpool.execute(task).then((res) => { - console.info('this res is: ' + res); - }); - setTimeout(() => { - Atomics.notify(int32, 0, 1); - }, 1000); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End example_pass_obj] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start example_pass_obj] +import { taskpool } from '@kit.ArkTS'; + +@Concurrent +function transferAtomics(arg1: Int32Array) { + console.info('wait begin::'); + // 使用Atomics进行操作 + let res = Atomics.wait(arg1, 0, 0, 3000); + return res; +} + +@Entry +@Component +struct sharedArrayBuffer { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + // 定义可共享对象 + let sab: SharedArrayBuffer = new SharedArrayBuffer(20); + let int32 = new Int32Array(sab); + let task: taskpool.Task = new taskpool.Task(transferAtomics, int32); + taskpool.execute(task).then((res) => { + console.info('this res is: ' + res); + }); + setTimeout(() => { + Atomics.notify(int32, 0, 1); + }, 1000); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End example_pass_obj] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/Test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/Test.ets new file mode 100644 index 0000000000..6520ec0a23 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/Test.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start define_test_class] +// 自定义class TestA +export class TestA { + constructor(name: string) { + this.name = name; + } + name: string = 'ClassA'; +} +// [End define_test_class] diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/TransferabledObject.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/TransferabledObject.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/TransferabledObject.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/TransferabledObject.ets index 3fb9c8d73b..afaea9ae5c --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/TransferabledObject.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/TransferabledObject.ets @@ -1,66 +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. - */ - -// [Start example_pass_obj] -import { taskpool } from '@kit.ArkTS'; -import { loadPixelMap } from './pixelMapTest'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - @State pixelMap: PixelMap | undefined = undefined; - - private loadImageFromThread(): void { - const resourceMgr = getContext(this).resourceManager; - // 此处‘startIcon.png’为media下复制到rawfile文件夹中,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 - resourceMgr.getRawFd('startIcon.png').then(rawFileDescriptor => { - taskpool.execute(loadPixelMap, rawFileDescriptor).then(pixelMap => { - if (pixelMap) { - this.pixelMap = pixelMap as PixelMap; - console.log('Succeeded in creating pixelMap.'); - // 主线程释放pixelMap。由于子线程返回pixelMap时已调用setTransferDetached,所以此处能够立即释放pixelMap。 - this.pixelMap.release(); - } else { - console.error('Failed to create pixelMap.'); - } - }).catch((e: BusinessError) => { - console.error('taskpool execute loadPixelMap failed. Code: ' + e.code + ', message: ' + e.message); - }); - }); - } - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - this.loadImageFromThread(); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End example_pass_obj] - +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start example_pass_obj] +import { taskpool } from '@kit.ArkTS'; +import { loadPixelMap } from './pixelMapTest'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + @State pixelMap: PixelMap | undefined = undefined; + + private loadImageFromThread(): void { + const resourceMgr = getContext(this).resourceManager; + // 此处‘startIcon.png’为media下复制到rawfile文件夹中,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + resourceMgr.getRawFd('startIcon.png').then(rawFileDescriptor => { + taskpool.execute(loadPixelMap, rawFileDescriptor).then(pixelMap => { + if (pixelMap) { + this.pixelMap = pixelMap as PixelMap; + console.log('Succeeded in creating pixelMap.'); + // 主线程释放pixelMap。由于子线程返回pixelMap时已调用setTransferDetached,所以此处能够立即释放pixelMap。 + this.pixelMap.release(); + } else { + console.error('Failed to create pixelMap.'); + } + }).catch((e: BusinessError) => { + console.error('taskpool execute loadPixelMap failed. Code: ' + e.code + ', message: ' + e.message); + }); + }); + } + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.loadImageFromThread(); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End example_pass_obj] + diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/pixelMapTest.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/pixelMapTest.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/pixelMapTest.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/pixelMapTest.ets index 333d036a1d..ebae20a4bd --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/pixelMapTest.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/pixelMapTest.ets @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start example_pass_obj] -import { image } from '@kit.ImageKit'; - -@Concurrent -export async function loadPixelMap(rawFileDescriptor: number): Promise { - // 创建imageSource。 - const imageSource = image.createImageSource(rawFileDescriptor); - // 创建pixelMap。 - const pixelMap = imageSource.createPixelMapSync(); - // 释放imageSource。 - imageSource.release(); - // 使pixelMap在跨线程传输完成后,断开原线程的引用。 - pixelMap.setTransferDetached(true); - // 返回pixelMap给主线程。 - return pixelMap; -} -// [End example_pass_obj] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start example_pass_obj] +import { image } from '@kit.ImageKit'; + +@Concurrent +export async function loadPixelMap(rawFileDescriptor: number): Promise { + // 创建imageSource。 + const imageSource = image.createImageSource(rawFileDescriptor); + // 创建pixelMap。 + const pixelMap = imageSource.createPixelMapSync(); + // 释放imageSource。 + imageSource.release(); + // 使pixelMap在跨线程传输完成后,断开原线程的引用。 + pixelMap.setTransferDetached(true); + // 返回pixelMap给主线程。 + return pixelMap; +} +// [End example_pass_obj] diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/CommonButton.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/CommonButton.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/resource.ets new file mode 100644 index 0000000000..a0f1755b8c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/resource.ets @@ -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. + */ + +export class P2PManager { + public resourceToString(resource: Resource):string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + +export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/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.1", + "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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/ohosTest.md new file mode 100644 index 0000000000..17230e4b4c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/ohosTest.md @@ -0,0 +1,11 @@ +# CommunicationObjects 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------- | ------------------------------- | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 普通对象 | 位于NormalObject.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| ArrayBuffer对象 | 位于ArrayBufferObject.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| SharedArrayBuffer对象 | 位于SharedArrayBufferObject.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| Transferable对象 | 位于TransferabledObject.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/screenshots/CommunicationObjects_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/screenshots/CommunicationObjects_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/screenshots/CommunicationObjects_1.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/screenshots/CommunicationObjects_1.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/screenshots/CommunicationObjects_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/screenshots/CommunicationObjects_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/screenshots/CommunicationObjects_2.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/screenshots/CommunicationObjects_2.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/app.json5 old mode 100755 new mode 100644 index 3983e609fa..67e0031a60 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/app.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/app.json5 @@ -1,25 +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.rulesandrestrictions", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.rulesandrestrictions", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index c5886e23bd..1c313db608 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "RulesAndRestrictions" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "RulesAndRestrictions" + } + ] +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/README.md old mode 100755 new mode 100644 index 13b3282247..75d65c542b --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/README.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/README.md @@ -1,181 +1,181 @@ -# ArkTS Sendable使用规则与约束 - -该工程中展示的代码详细描述可查如下链接: - -- [Sendable使用规则与约束](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/sendable-constraints.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,点击Hello World执行程序 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -achievenon/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // 非Sendable class只能实现非Sendable interface和Sendable装饰器修饰类型时仅支持修饰函数类型 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -arrowfunctions/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // 箭头函数不支持共享 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -cannotbeused/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // Sendable class和Sendable function不能使用除了@Sendable的其它装饰器 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -inheritedfromnon/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // 非Sendable class只能继承自非Sendable class - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -inheritonly/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // Sendable class只能继承自Sendable class - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -nocalculationsupport/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // Sendable class/interface的成员变量不支持使用计算属性名 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -notallowedInside/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // Sendable class的内部不允许使用当前模块内上下文环境中定义的变量 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -objectliterals/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // 不能使用对象字面量/数组字面量初始化Sendable类型 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -templatetype/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // 泛型类中的Sendable class,collections.Array/Map/Set的模板类型必须是Sendable类型 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -typecannot/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // 非Sendable类型不可以as成Sendable类型 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -variablenotsupported/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // Sendable class/interface的成员变量不支持使用!断言 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -variablesupport/src/ - ├── main - │ ├── ets - │ │ ├── pages - │ │ ├── Index.ets // Sendable class/interface成员变量必须是Sendable支持的数据类型 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# ArkTS Sendable使用规则与约束 + +该工程中展示的代码详细描述可查如下链接: + +- [Sendable使用规则与约束](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/sendable-constraints.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,点击Hello World执行程序 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +achievenon/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // 非Sendable class只能实现非Sendable interface和Sendable装饰器修饰类型时仅支持修饰函数类型 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +arrowfunctions/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // 箭头函数不支持共享 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +cannotbeused/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // Sendable class和Sendable function不能使用除了@Sendable的其它装饰器 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +inheritedfromnon/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // 非Sendable class只能继承自非Sendable class + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +inheritonly/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // Sendable class只能继承自Sendable class + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +nocalculationsupport/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // Sendable class/interface的成员变量不支持使用计算属性名 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +notallowedInside/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // Sendable class的内部不允许使用当前模块内上下文环境中定义的变量 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +objectliterals/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // 不能使用对象字面量/数组字面量初始化Sendable类型 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +templatetype/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // 泛型类中的Sendable class,collections.Array/Map/Set的模板类型必须是Sendable类型 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +typecannot/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // 非Sendable类型不可以as成Sendable类型 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +variablenotsupported/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // Sendable class/interface的成员变量不支持使用!断言 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +variablesupport/src/ + ├── main + │ ├── ets + │ │ ├── pages + │ │ ├── Index.ets // Sendable class/interface成员变量必须是Sendable支持的数据类型 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions > .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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/oh-package.json5 old mode 100755 new mode 100644 index 53aaf83c43..3cb95eb922 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/oh-package.json5 @@ -1,25 +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": "achievenon", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "achievenon", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/ets/achievenonability/AchievenonAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/ets/achievenonability/AchievenonAbility.ets old mode 100755 new mode 100644 index 27da643e42..45dc888f87 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/ets/achievenonability/AchievenonAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/ets/achievenonability/AchievenonAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class AchievenonAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class AchievenonAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/module.json5 old mode 100755 new mode 100644 index 036b9b6093..c9efe22050 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/module.json5 @@ -1,42 +1,42 @@ -/* - * 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": "achievenon", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "AchievenonAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "AchievenonAbility", - "srcEntry": "./ets/achievenonability/AchievenonAbility.ets", - "description": "$string:AchievenonAbility_desc", - "icon": "$media:layered_image", - "label": "$string:AchievenonAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } +/* + * 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": "achievenon", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "AchievenonAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "AchievenonAbility", + "srcEntry": "./ets/achievenonability/AchievenonAbility.ets", + "description": "$string:AchievenonAbility_desc", + "icon": "$media:layered_image", + "label": "$string:AchievenonAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/module.json5 old mode 100755 new mode 100644 index aab900c170..63ed494102 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "achievenon_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "achievenon_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/achievenon/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/oh-package.json5 old mode 100755 new mode 100644 index 3bfbbecab2..84e7269a19 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/oh-package.json5 @@ -1,25 +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": "arrowfunctions", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "arrowfunctions", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/ets/arrowfunctionsability/ArrowfunctionsAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/ets/arrowfunctionsability/ArrowfunctionsAbility.ets deleted file mode 100755 index 278f4b7314..0000000000 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/ets/arrowfunctionsability/ArrowfunctionsAbility.ets +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class ArrowfunctionsAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/module.json5 old mode 100755 new mode 100644 index 249019badd..10a4927907 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/module.json5 @@ -1,42 +1,42 @@ -/* - * 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": "arrowfunctions", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "ArrowfunctionsAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ArrowfunctionsAbility", - "srcEntry": "./ets/arrowfunctionsability/ArrowfunctionsAbility.ets", - "description": "$string:ArrowfunctionsAbility_desc", - "icon": "$media:layered_image", - "label": "$string:ArrowfunctionsAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } +/* + * 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": "arrowfunctions", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "ArrowfunctionsAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ArrowfunctionsAbility", + "srcEntry": "./ets/arrowfunctionsability/ArrowfunctionsAbility.ets", + "description": "$string:ArrowfunctionsAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ArrowfunctionsAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9e14e199fb..4fba8e77ac --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "arrowfunctions_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "arrowfunctions_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/arrowfunctions/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/build-profile.json5 old mode 100755 new mode 100644 index cf90707418..63a72fc5f3 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/build-profile.json5 @@ -1,190 +1,190 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "inheritonly", - "srcPath": "./inheritonly", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "achievenon", - "srcPath": "./achievenon", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "arrowfunctions", - "srcPath": "./arrowfunctions", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "cannotbeused", - "srcPath": "./cannotbeused", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "inheritedfromnon", - "srcPath": "./inheritedfromnon", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "nocalculationsupport", - "srcPath": "./nocalculationsupport", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "notallowedInside", - "srcPath": "./notallowedInside", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "objectliterals", - "srcPath": "./objectliterals", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "templatetype", - "srcPath": "./templatetype", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "typecannot", - "srcPath": "./typecannot", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "variablenotsupported", - "srcPath": "./variablenotsupported", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "variablesupport", - "srcPath": "./variablesupport", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "inheritonly", + "srcPath": "./inheritonly", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "achievenon", + "srcPath": "./achievenon", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "arrowfunctions", + "srcPath": "./arrowfunctions", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "cannotbeused", + "srcPath": "./cannotbeused", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "inheritedfromnon", + "srcPath": "./inheritedfromnon", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "nocalculationsupport", + "srcPath": "./nocalculationsupport", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "notallowedInside", + "srcPath": "./notallowedInside", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "objectliterals", + "srcPath": "./objectliterals", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "templatetype", + "srcPath": "./templatetype", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "typecannot", + "srcPath": "./typecannot", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "variablenotsupported", + "srcPath": "./variablenotsupported", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "variablesupport", + "srcPath": "./variablesupport", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/oh-package.json5 old mode 100755 new mode 100644 index b8a1d53f8c..8b289874ec --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/oh-package.json5 @@ -1,25 +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": "cannotbeused", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "cannotbeused", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/ets/cannotbeusedability/CannotbeusedAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/ets/cannotbeusedability/CannotbeusedAbility.ets old mode 100755 new mode 100644 index c4334fc2e0..903e0a0b16 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/ets/cannotbeusedability/CannotbeusedAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/ets/cannotbeusedability/CannotbeusedAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CannotbeusedAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CannotbeusedAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/module.json5 old mode 100755 new mode 100644 index 23b37e40c6..d7efe94a51 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/module.json5 @@ -1,42 +1,42 @@ -/* - * 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": "cannotbeused", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CannotbeusedAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CannotbeusedAbility", - "srcEntry": "./ets/cannotbeusedability/CannotbeusedAbility.ets", - "description": "$string:CannotbeusedAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CannotbeusedAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } +/* + * 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": "cannotbeused", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CannotbeusedAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CannotbeusedAbility", + "srcEntry": "./ets/cannotbeusedability/CannotbeusedAbility.ets", + "description": "$string:CannotbeusedAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CannotbeusedAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 1cd43069cd..df5ccbe556 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "cannotbeused_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "cannotbeused_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/cannotbeused/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/oh-package.json5 old mode 100755 new mode 100644 index 262be992a4..5f2ff23668 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/oh-package.json5 @@ -1,25 +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": "inheritedfromnon", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "inheritedfromnon", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/module.json5 old mode 100755 new mode 100644 index 5c75f9db02..bd1c9d7e10 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/module.json5 @@ -1,42 +1,42 @@ -/* - * 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": "inheritedfromnon", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "InheritedfromnonAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "InheritedfromnonAbility", - "srcEntry": "./ets/inheritedfromnonability/InheritedfromnonAbility.ets", - "description": "$string:InheritedfromnonAbility_desc", - "icon": "$media:layered_image", - "label": "$string:InheritedfromnonAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } +/* + * 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": "inheritedfromnon", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "InheritedfromnonAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "InheritedfromnonAbility", + "srcEntry": "./ets/inheritedfromnonability/InheritedfromnonAbility.ets", + "description": "$string:InheritedfromnonAbility_desc", + "icon": "$media:layered_image", + "label": "$string:InheritedfromnonAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 503c18e274..a6c65cce07 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "inheritedfromnon_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "inheritedfromnon_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritedfromnon/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/oh-package.json5 old mode 100755 new mode 100644 index 68b4292235..1094343a30 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "name": "inheritonly", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} +/* + * 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": "inheritonly", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/module.json5 old mode 100755 new mode 100644 index 11cddab776..f88f96e831 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/module.json5 @@ -1,66 +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": "inheritonly", - "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" - } - ] - } - ] - } +/* + * 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": "inheritonly", + "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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/dark/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/module.json5 old mode 100755 new mode 100644 index db2a111054..e087c148e4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "inheritonly_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } +/* + * 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": "inheritonly_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/inheritonly/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/oh-package.json5 old mode 100755 new mode 100644 index 0262fd556f..36774f109a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/oh-package.json5 @@ -1,25 +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": "nocalculationsupport", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "nocalculationsupport", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/module.json5 old mode 100755 new mode 100644 index 840daa891a..d34e7ac344 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/module.json5 @@ -1,42 +1,42 @@ -/* - * 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": "nocalculationsupport", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "NocalculationsupportAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "NocalculationsupportAbility", - "srcEntry": "./ets/nocalculationsupportability/NocalculationsupportAbility.ets", - "description": "$string:NocalculationsupportAbility_desc", - "icon": "$media:layered_image", - "label": "$string:NocalculationsupportAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } +/* + * 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": "nocalculationsupport", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "NocalculationsupportAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "NocalculationsupportAbility", + "srcEntry": "./ets/nocalculationsupportability/NocalculationsupportAbility.ets", + "description": "$string:NocalculationsupportAbility_desc", + "icon": "$media:layered_image", + "label": "$string:NocalculationsupportAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 46644b9a12..b4f93f658b --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "nocalculationsupport_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "nocalculationsupport_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/nocalculationsupport/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/build-profile.json5 new file mode 100644 index 0000000000..e7569e3056 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/obfuscation-rules.txt rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/oh-package.json5 new file mode 100644 index 0000000000..be3bb1d96d --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/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": "notallowedinside", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/module.json5 new file mode 100644 index 0000000000..57ade9d605 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "notallowedInside", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "NotallowedInsideAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "NotallowedInsideAbility", + "srcEntry": "./ets/notallowedinsideability/NotallowedInsideAbility.ets", + "description": "$string:NotallowedInsideAbility_desc", + "icon": "$media:layered_image", + "label": "$string:NotallowedInsideAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/module.json5 new file mode 100644 index 0000000000..3944d28a05 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "notallowedInside_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/build-profile.json5 new file mode 100644 index 0000000000..e7569e3056 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/obfuscation-rules.txt rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/oh-package.json5 new file mode 100644 index 0000000000..b311b1744f --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/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": "objectliterals", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/module.json5 new file mode 100644 index 0000000000..46d71b3c4d --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "objectliterals", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "ObjectliteralsAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ObjectliteralsAbility", + "srcEntry": "./ets/objectliteralsability/ObjectliteralsAbility.ets", + "description": "$string:ObjectliteralsAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ObjectliteralsAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/module.json5 new file mode 100644 index 0000000000..d1f7bfe9e8 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "objectliterals_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/ohosTest.md old mode 100755 new mode 100644 index 6b863f0d75..145f148d7a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/ohosTest.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/ohosTest.md @@ -1,20 +1,20 @@ -# RulesAndRestrictions 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------------ | ------------------------------------- | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| Sendable class只能继承自Sendable class | 位于InheritOnly模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 非Sendable class只能继承自非Sendable class | 位于InheritedFromNon模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 非Sendable class只能实现非Sendable interface | 位于AchieveNon模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| Sendable class/interface成员变量必须是Sendable支持的数据类型 | 位于VariableSupport模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| Sendable class/interface的成员变量不支持使用!断言 | 位于VariableNotSupported模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| Sendable class/interface的成员变量不支持使用计算属性名 | 位于NoCalculationSupport模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 泛型类中的Sendable class,collections.Array,collections.Map,collections.Set的模板类型必须是Sendable类型 | 位于TemplateType模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| Sendable class的内部不允许使用当前模块内上下文环境中定义的变量 | 位于NotAllowedInside模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| Sendable class和Sendable function不能使用除了@Sendable的其它装饰器 | 位于CannotBeUsed模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 不能使用对象字面量/数组字面量初始化Sendable类型 | 位于ObjectLiterals模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 非Sendable类型不可以as成Sendable类型 | 位于TypeCannot模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 箭头函数不支持共享 | 位于ArrowFunctions模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +# RulesAndRestrictions 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------------ | ------------------------------------- | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| Sendable class只能继承自Sendable class | 位于InheritOnly模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 非Sendable class只能继承自非Sendable class | 位于InheritedFromNon模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 非Sendable class只能实现非Sendable interface | 位于AchieveNon模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| Sendable class/interface成员变量必须是Sendable支持的数据类型 | 位于VariableSupport模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| Sendable class/interface的成员变量不支持使用!断言 | 位于VariableNotSupported模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| Sendable class/interface的成员变量不支持使用计算属性名 | 位于NoCalculationSupport模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 泛型类中的Sendable class,collections.Array,collections.Map,collections.Set的模板类型必须是Sendable类型 | 位于TemplateType模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| Sendable class的内部不允许使用当前模块内上下文环境中定义的变量 | 位于NotAllowedInside模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| Sendable class和Sendable function不能使用除了@Sendable的其它装饰器 | 位于CannotBeUsed模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 不能使用对象字面量/数组字面量初始化Sendable类型 | 位于ObjectLiterals模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 非Sendable类型不可以as成Sendable类型 | 位于TypeCannot模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 箭头函数不支持共享 | 位于ArrowFunctions模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | | Sendable装饰器修饰类型时仅支持修饰函数类型 | 位于achievenon模块Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/screenshots/RulesAndRestrictions_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/screenshots/RulesAndRestrictions_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/screenshots/RulesAndRestrictions_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/screenshots/RulesAndRestrictions_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/build-profile.json5 new file mode 100644 index 0000000000..e7569e3056 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/obfuscation-rules.txt rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/oh-package.json5 new file mode 100644 index 0000000000..64ef1bba31 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/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": "templatetype", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/templatetypeability/TemplatetypeAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/templatetypeability/TemplatetypeAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/templatetypeability/TemplatetypeAbility.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/templatetypeability/TemplatetypeAbility.ets index ff03d624a5..a4c8713244 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/templatetypeability/TemplatetypeAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/ets/templatetypeability/TemplatetypeAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class TemplatetypeAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class TemplatetypeAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/module.json5 new file mode 100644 index 0000000000..7ddbad453f --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "templatetype", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "TemplatetypeAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "TemplatetypeAbility", + "srcEntry": "./ets/templatetypeability/TemplatetypeAbility.ets", + "description": "$string:TemplatetypeAbility_desc", + "icon": "$media:layered_image", + "label": "$string:TemplatetypeAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/module.json5 new file mode 100644 index 0000000000..e3217fd777 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "templatetype_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/build-profile.json5 new file mode 100644 index 0000000000..e7569e3056 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/obfuscation-rules.txt rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/oh-package.json5 new file mode 100644 index 0000000000..95280a463f --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/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": "typecannot", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/typecannotability/TypecannotAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/typecannotability/TypecannotAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/typecannotability/TypecannotAbility.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/typecannotability/TypecannotAbility.ets index 6f994d2ad4..b63370a2df --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/typecannotability/TypecannotAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/ets/typecannotability/TypecannotAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class TypecannotAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class TypecannotAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/module.json5 new file mode 100644 index 0000000000..fd63f3981f --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "typecannot", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "TypecannotAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "TypecannotAbility", + "srcEntry": "./ets/typecannotability/TypecannotAbility.ets", + "description": "$string:TypecannotAbility_desc", + "icon": "$media:layered_image", + "label": "$string:TypecannotAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/module.json5 new file mode 100644 index 0000000000..5e0f529495 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "typecannot_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/build-profile.json5 new file mode 100644 index 0000000000..e7569e3056 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/obfuscation-rules.txt rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/oh-package.json5 new file mode 100644 index 0000000000..c9fee383a0 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/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": "variablenotsupported", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/module.json5 new file mode 100644 index 0000000000..7f3312c028 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "variablenotsupported", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "VariablenotsupportedAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "VariablenotsupportedAbility", + "srcEntry": "./ets/variablenotsupportedability/VariablenotsupportedAbility.ets", + "description": "$string:VariablenotsupportedAbility_desc", + "icon": "$media:layered_image", + "label": "$string:VariablenotsupportedAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/module.json5 new file mode 100644 index 0000000000..d370f02796 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "variablenotsupported_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/build-profile.json5 new file mode 100644 index 0000000000..e7569e3056 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/obfuscation-rules.txt rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/oh-package.json5 new file mode 100644 index 0000000000..2b90c7a5d1 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/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": "variablesupport", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/module.json5 new file mode 100644 index 0000000000..839e0588ab --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "variablesupport", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "VariablesupportAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "VariablesupportAbility", + "srcEntry": "./ets/variablesupportability/VariablesupportAbility.ets", + "description": "$string:VariablesupportAbility_desc", + "icon": "$media:layered_image", + "label": "$string:VariablesupportAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/module.json5 new file mode 100644 index 0000000000..487ec34ffd --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "variablesupport_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/app.json5 old mode 100755 new mode 100644 index 6475b5b34f..f70d9468b2 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/app.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/app.json5 @@ -1,25 +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.sendableobjectintroduction", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.sendableobjectintroduction", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 709001d41d..5ed25c150b --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SendableObjectIntroduction" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SendableObjectIntroduction" + } + ] +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/README.md old mode 100755 new mode 100644 index 226690ade5..66f6f0edff --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/README.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/README.md @@ -1,74 +1,74 @@ -# ArkTS Sendable对象简介 - -### 介绍 - -在传统JS引擎上,对象的并发通信开销的优化方式只有一种,就是把实现下沉到Native侧,通过[Transferable对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/transferabled-object.md)的转移或共享方式降低并发通信开销。而开发者仍然还有大量对象并发通信的诉求,这个问题在业界的JS引擎实现上并没有得到解决。 - -该工程中展示的代码详细描述可查如下链接: - -- [Sendable对象简介](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-sendable.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -class - ├── Index.ets // 装饰器修饰Class使用示例 -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── managers - │ │ ├── classusage.ets // 装饰器修饰Class使用示例 - │ │ ├── functionusage.ets // 装饰器修饰Function使用示例 - │ │ ├── pages - │ │ ├── Index.ets // 首页 - │ │ ├── util - │ │ ├── CommonButton.ets // 首页跳转UI - │ │ ├── resource.ets // 资源引用转换 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# ArkTS Sendable对象简介 + +### 介绍 + +在传统JS引擎上,对象的并发通信开销的优化方式只有一种,就是把实现下沉到Native侧,通过[Transferable对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/transferabled-object.md)的转移或共享方式降低并发通信开销。而开发者仍然还有大量对象并发通信的诉求,这个问题在业界的JS引擎实现上并没有得到解决。 + +该工程中展示的代码详细描述可查如下链接: + +- [Sendable对象简介](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-sendable.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +class + ├── Index.ets // 装饰器修饰Class使用示例 +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── managers + │ │ ├── classusage.ets // 装饰器修饰Class使用示例 + │ │ ├── functionusage.ets // 装饰器修饰Function使用示例 + │ │ ├── pages + │ │ ├── Index.ets // 首页 + │ │ ├── util + │ │ ├── CommonButton.ets // 首页跳转UI + │ │ ├── resource.ets // 资源引用转换 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction > .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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/build-profile.json5 old mode 100755 new mode 100644 index b56192b6cc..199bbcdd07 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/build-profile.json5 @@ -1,62 +1,62 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "class", - "srcPath": "./class", - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "class", + "srcPath": "./class", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/BuildProfile.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/BuildProfile.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/Index.ets old mode 100755 new mode 100644 index 9faaffcefc..beab0dd0f9 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/Index.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/Index.ets @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start example_modify_class] -export { MainPage } from './src/main/ets/components/MainPage'; - -@Sendable -class SendableTestClass { - desc: string = 'sendable: this is SendableTestClass '; - num: number = 5; - printName() { - console.info('sendable: SendableTestClass desc is: ' + this.desc); - } - get getNum(): number { - return this.num; - } -} - -let object = new SendableTestClass; -export { object } -// [End example_modify_class] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start example_modify_class] +export { MainPage } from './src/main/ets/components/MainPage'; + +@Sendable +class SendableTestClass { + desc: string = 'sendable: this is SendableTestClass '; + num: number = 5; + printName() { + console.info('sendable: SendableTestClass desc is: ' + this.desc); + } + get getNum(): number { + return this.num; + } +} + +let object = new SendableTestClass; +export { object } +// [End example_modify_class] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/build-profile.json5 old mode 100755 new mode 100644 index 5552c941de..aefa5f6959 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/build-profile.json5 @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "apiType": "stageMode", - "buildOption": { - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - }, - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/consumer-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/consumer-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/oh-package.json5 old mode 100755 new mode 100644 index f5b1cfe4d1..281d417ae9 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "name": "class", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - "dependencies": {} -} +/* + * 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": "class", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/ets/components/MainPage.ets old mode 100755 new mode 100644 index 1243a59406..7dc1a0d257 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/ets/components/MainPage.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/ets/components/MainPage.ets @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MainPage { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/module.json5 old mode 100755 new mode 100644 index cccbe50138..e2be6bfb8b --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/module.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "class", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} +/* + * 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": "class", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 6bd546c8e8..66ecfa7e86 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "class_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "class_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/class/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/oh-package.json5 old mode 100755 new mode 100644 index c38f46740d..047c5afc10 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "name": "entry", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "class": "file:../class" - } -} - +/* + * 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": { + "class": "file:../class" + } +} + diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/managers/classusage.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/managers/classusage.ets old mode 100755 new mode 100644 index 0ec63eed40..2d4b84f753 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/managers/classusage.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/managers/classusage.ets @@ -1,42 +1,42 @@ -/* - * 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 ClassUsage { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - import('class').then((ns: ESObject) => { - ns.object.printName(); - }) - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } +/* + * 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 ClassUsage { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + import('class').then((ns: ESObject) => { + ns.object.printName(); + }) + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/managers/functionusage.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/managers/functionusage.ets old mode 100755 new mode 100644 index ba9bdb75e0..8f7dc518be --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/managers/functionusage.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/managers/functionusage.ets @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start example_modify_function] -@Sendable -type SendableFuncType = () => void; - -@Sendable -class TopLevelSendableClass { - num: number = 1; - - PrintNum() { - console.info('Top level sendable class'); - } -} - -@Sendable -function topLevelSendableFunction() { - console.info('Top level sendable function'); -} - -@Sendable -function sendableTestFunction() { - const topClass = new TopLevelSendableClass(); // 顶层sendable class - topClass.PrintNum(); - topLevelSendableFunction(); // 顶层sendable function - console.info('Sendable test function'); -} - -@Sendable -class SendableTestClass { - constructor(func: SendableFuncType) { - this.callback = func; - } - - callback: SendableFuncType; // 顶层sendable function - - CallSendableFunc() { - sendableTestFunction(); // 顶层sendable function - } -} -// [End example_modify_function] - -@Entry -@Component -struct FunctionUsage { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - let sendableClass = new SendableTestClass(sendableTestFunction); - sendableClass.callback(); - sendableClass.CallSendableFunc(); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start example_modify_function] +@Sendable +type SendableFuncType = () => void; + +@Sendable +class TopLevelSendableClass { + num: number = 1; + + PrintNum() { + console.info('Top level sendable class'); + } +} + +@Sendable +function topLevelSendableFunction() { + console.info('Top level sendable function'); +} + +@Sendable +function sendableTestFunction() { + const topClass = new TopLevelSendableClass(); // 顶层sendable class + topClass.PrintNum(); + topLevelSendableFunction(); // 顶层sendable function + console.info('Sendable test function'); +} + +@Sendable +class SendableTestClass { + constructor(func: SendableFuncType) { + this.callback = func; + } + + callback: SendableFuncType; // 顶层sendable function + + CallSendableFunc() { + sendableTestFunction(); // 顶层sendable function + } +} +// [End example_modify_function] + +@Entry +@Component +struct FunctionUsage { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + let sendableClass = new SendableTestClass(sendableTestFunction); + sendableClass.callback(); + sendableClass.CallSendableFunc(); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/util/resource.ets old mode 100755 new mode 100644 index 79a04af93b..a0f1755b8c --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/util/resource.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/ets/util/resource.ets @@ -1,25 +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. - */ - -export class P2PManager { - public resourceToString(resource: Resource):string { - return getContext(this).resourceManager.getStringSync(resource); - } -} - -// 默认导出let -let p2pManager = new P2PManager(); - +/* + * 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 class P2PManager { + public resourceToString(resource: Resource):string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/ohosTest.md old mode 100755 new mode 100644 index 146fe477fc..262265b7a5 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/ohosTest.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/ohosTest.md @@ -1,9 +1,9 @@ -# SendableObjectIntroduction 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------------------------- | --------------------- | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 装饰器修饰Class使用示例 | 位于classusage.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +# SendableObjectIntroduction 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------------- | --------------------- | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 装饰器修饰Class使用示例 | 位于classusage.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | | 装饰器修饰Function使用示例 | 位于functionusage.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/screenshots/SendableObjectIntroduction_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/screenshots/SendableObjectIntroduction_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/screenshots/SendableObjectIntroduction_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectIntroduction/screenshots/SendableObjectIntroduction_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/app.json5 old mode 100755 new mode 100644 index 6c008d7cf3..9cde574c4a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/app.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/app.json5 @@ -1,25 +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.sendableobjectrelated", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.sendableobjectrelated", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 266194dd18..5851a8ec04 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SendableObjectRelated" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SendableObjectRelated" + } + ] +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/README.md old mode 100755 new mode 100644 index c779b9c44f..774f387378 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/README.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/README.md @@ -1,112 +1,112 @@ -# ArkTS Sendable对象相关 - -### 介绍 - -#### 异步锁 - -为了解决多线程并发任务间的数据竞争问题,ArkTS引入了异步锁能力。异步锁可能会被类对象持有,因此为了更方便地在并发实例间获取同一个异步锁对象,[AsyncLock对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-utils.md#asynclock)支持跨线程引用传递。 - -由于ArkTS语言支持异步操作,阻塞锁容易产生死锁问题,因此在ArkTS中仅支持异步锁(非阻塞式锁)。同时,异步锁还可以用于保证单线程内的异步任务时序一致性,防止异步任务时序不确定导致的同步问题。 - -#### ASON解析与生成 - -[ASON工具](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-utils.md#arktsutilsason)与JS提供的JSON工具类似,JSON用于进行JS对象的序列化(stringify)、反序列化(parse)。ASON则提供了[Sendable对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-sendable.md)的序列化、反序列化能力。可以通过ASON.stringify方法将对象转换成字符串,也可以通过ASON.parse方法将字符串转成Sendable对象,以便此对象在并发任务间进行高性能引用传递。 - -#### 共享容器 - -ArkTS共享容器([@arkts.collections (ArkTS容器集)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md))是一种在并发任务间共享传输的容器类,可以用于并发场景下的高性能数据传递。功能与Ecmascript262规范定义的容器类似,但仍然有部分差异,具体可见[共享容器与原生API方法的行为差异对比](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-collections-introduction.md#共享容器与原生api方法的行为差异对比)。 - -ArkTS共享容器在多个并发任务间传递时,其默认行为是引用传递,支持多个并发任务可以操作同一个容器实例。另外,也支持拷贝传递,即每个并发任务持有一个ArkTS容器实例。 - -ArkTS共享容器并不是线程安全的,内部使用了fail-fast(快速失败)机制,即当检测多个并发实例同时对容器进行结构性改变时,会触发异常。因此,在容器内修改属性的场景下,开发者需要使用ArkTS提供的[异步锁](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-async-lock-introduction.md)机制保证ArkTS容器的安全访问。 - -ArkTS共享容器包含如下几种:[Array](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionsarray)、[Map](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionsmap)、[Set](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionsset)、[TypedArray](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionstypedarray)(Int8Array、Uint8Array、Int16Array、Uint16Array、Int32Array、Uint32Array、Uint8ClampedArray、Float32Array)、[ArrayBuffer](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionsarraybuffer)等,具体可见[@arkts.collections (ArkTS容器集)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md)。 - -#### 共享模块 - -共享模块是进程内只会加载一次的模块,使用"use shared"这一指令来标记一个模块是否为共享模块。 - -非共享模块在同一线程内只加载一次,在不同线程间会加载多次,在不同的线程内都会产生新的模块对象。因此可以使用共享模块来实现进程单例。 - -#### Sendable对象冻结 - -Sendable对象支持冻结操作,冻结后的对象变成只读对象,不能增删改属性,因此在多个并发实例间访问均不需要加锁,可以通过调用[Object.freeze](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)接口冻结对象。 - -该工程中展示的代码详细描述可查如下链接: - -- [异步锁](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-async-lock-introduction.md) -- [ASON解析与生成](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/ason-parsing-generation.md) -- [共享容器](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-collections-introduction.md) -- [共享模块](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-sendable-module.md) -- [Sendable对象冻结](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/sendable-freeze.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── managers - │ │ ├── ArktsAsyncLockIntroduction.ets // 异步锁示例代码 - │ │ ├── ArktsCollectionsIntroduction.ets // 共享容器示例代码 - │ │ ├── ArktsSendableModule.ets // 共享模块示例代码 - │ │ ├── AsonParsingGeneration.ets // ASON解析与生成示例代码 - │ │ ├── helper.ts // Sendable对象冻结示例代码 - │ │ ├── SendableFreeze.ets // Sendable对象冻结示例代码 - │ │ ├── sharedModule.ets // 共享模块示例代码 - │ │ ├── test.ets // 共享模块示例代码 - │ │ ├── pages - │ │ ├── Index.ets // 首页 - │ │ ├── util - │ │ ├── CommonButton.ets // 首页跳转UI - │ │ ├── resource.ets // 资源引用转换 - │ │ ├── workers - │ │ ├── Worker.ets // Sendable对象冻结示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# ArkTS Sendable对象相关 + +### 介绍 + +#### 异步锁 + +为了解决多线程并发任务间的数据竞争问题,ArkTS引入了异步锁能力。异步锁可能会被类对象持有,因此为了更方便地在并发实例间获取同一个异步锁对象,[AsyncLock对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-utils.md#asynclock)支持跨线程引用传递。 + +由于ArkTS语言支持异步操作,阻塞锁容易产生死锁问题,因此在ArkTS中仅支持异步锁(非阻塞式锁)。同时,异步锁还可以用于保证单线程内的异步任务时序一致性,防止异步任务时序不确定导致的同步问题。 + +#### ASON解析与生成 + +[ASON工具](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-utils.md#arktsutilsason)与JS提供的JSON工具类似,JSON用于进行JS对象的序列化(stringify)、反序列化(parse)。ASON则提供了[Sendable对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-sendable.md)的序列化、反序列化能力。可以通过ASON.stringify方法将对象转换成字符串,也可以通过ASON.parse方法将字符串转成Sendable对象,以便此对象在并发任务间进行高性能引用传递。 + +#### 共享容器 + +ArkTS共享容器([@arkts.collections (ArkTS容器集)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md))是一种在并发任务间共享传输的容器类,可以用于并发场景下的高性能数据传递。功能与Ecmascript262规范定义的容器类似,但仍然有部分差异,具体可见[共享容器与原生API方法的行为差异对比](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-collections-introduction.md#共享容器与原生api方法的行为差异对比)。 + +ArkTS共享容器在多个并发任务间传递时,其默认行为是引用传递,支持多个并发任务可以操作同一个容器实例。另外,也支持拷贝传递,即每个并发任务持有一个ArkTS容器实例。 + +ArkTS共享容器并不是线程安全的,内部使用了fail-fast(快速失败)机制,即当检测多个并发实例同时对容器进行结构性改变时,会触发异常。因此,在容器内修改属性的场景下,开发者需要使用ArkTS提供的[异步锁](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-async-lock-introduction.md)机制保证ArkTS容器的安全访问。 + +ArkTS共享容器包含如下几种:[Array](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionsarray)、[Map](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionsmap)、[Set](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionsset)、[TypedArray](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionstypedarray)(Int8Array、Uint8Array、Int16Array、Uint16Array、Int32Array、Uint32Array、Uint8ClampedArray、Float32Array)、[ArrayBuffer](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionsarraybuffer)等,具体可见[@arkts.collections (ArkTS容器集)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-collections.md)。 + +#### 共享模块 + +共享模块是进程内只会加载一次的模块,使用"use shared"这一指令来标记一个模块是否为共享模块。 + +非共享模块在同一线程内只加载一次,在不同线程间会加载多次,在不同的线程内都会产生新的模块对象。因此可以使用共享模块来实现进程单例。 + +#### Sendable对象冻结 + +Sendable对象支持冻结操作,冻结后的对象变成只读对象,不能增删改属性,因此在多个并发实例间访问均不需要加锁,可以通过调用[Object.freeze](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)接口冻结对象。 + +该工程中展示的代码详细描述可查如下链接: + +- [异步锁](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-async-lock-introduction.md) +- [ASON解析与生成](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/ason-parsing-generation.md) +- [共享容器](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-collections-introduction.md) +- [共享模块](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-sendable-module.md) +- [Sendable对象冻结](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/sendable-freeze.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── managers + │ │ ├── ArktsAsyncLockIntroduction.ets // 异步锁示例代码 + │ │ ├── ArktsCollectionsIntroduction.ets // 共享容器示例代码 + │ │ ├── ArktsSendableModule.ets // 共享模块示例代码 + │ │ ├── AsonParsingGeneration.ets // ASON解析与生成示例代码 + │ │ ├── helper.ts // Sendable对象冻结示例代码 + │ │ ├── SendableFreeze.ets // Sendable对象冻结示例代码 + │ │ ├── sharedModule.ets // 共享模块示例代码 + │ │ ├── test.ets // 共享模块示例代码 + │ │ ├── pages + │ │ ├── Index.ets // 首页 + │ │ ├── util + │ │ ├── CommonButton.ets // 首页跳转UI + │ │ ├── resource.ets // 资源引用转换 + │ │ ├── workers + │ │ ├── Worker.ets // Sendable对象冻结示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated > .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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/build-profile.json5 old mode 100755 new mode 100644 index 59aacbbe9d..9308c2de5f --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/build-profile.json5 @@ -1,48 +1,48 @@ - -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -{ - "apiType": "stageMode", - "buildOption": { - "sourceOption": { - "workers": [ - "./src/main/ets/workers/Worker.ets" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] + +/* + * 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": { + "sourceOption": { + "workers": [ + "./src/main/ets/workers/Worker.ets" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsAsyncLockIntroduction.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsAsyncLockIntroduction.ets old mode 100755 new mode 100644 index 4aa790451d..7fbe66b90d --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsAsyncLockIntroduction.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsAsyncLockIntroduction.ets @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start example_protect] -import { ArkTSUtils, taskpool } from '@kit.ArkTS'; - -@Sendable -export class A { - private count_: number = 0; - public lock_: ArkTSUtils.locks.AsyncLock = new ArkTSUtils.locks.AsyncLock(); - - public async getCount(): Promise { - // 对需要保护的数据加异步锁 - return this.lock_.lockAsync(() => { - return this.count_; - }) - } - - public async increaseCount() { - // 对需要保护的数据加异步锁 - await this.lock_.lockAsync(() => { - this.count_++; - }) - } -} - -@Concurrent -async function printCount(a: A) { - console.info('InputModule: count is:' + await a.getCount()); -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(async () => { - // 创建sendable对象a - let a: A = new A(); - // 将实例a传递给子线程 - await taskpool.execute(printCount, a); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End example_protect] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start example_protect] +import { ArkTSUtils, taskpool } from '@kit.ArkTS'; + +@Sendable +export class A { + private count_: number = 0; + public lock_: ArkTSUtils.locks.AsyncLock = new ArkTSUtils.locks.AsyncLock(); + + public async getCount(): Promise { + // 对需要保护的数据加异步锁 + return this.lock_.lockAsync(() => { + return this.count_; + }) + } + + public async increaseCount() { + // 对需要保护的数据加异步锁 + await this.lock_.lockAsync(() => { + this.count_++; + }) + } +} + +@Concurrent +async function printCount(a: A) { + console.info('InputModule: count is:' + await a.getCount()); +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(async () => { + // 创建sendable对象a + let a: A = new A(); + // 将实例a传递给子线程 + await taskpool.execute(printCount, a); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End example_protect] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsCollectionsIntroduction.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsCollectionsIntroduction.ets old mode 100755 new mode 100644 index 08bc354d33..0e7507a4db --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsCollectionsIntroduction.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsCollectionsIntroduction.ets @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start example_use] -import { ArkTSUtils, collections, taskpool } from '@kit.ArkTS'; - -@Concurrent -async function add(arr: collections.Array, lock: ArkTSUtils.locks.AsyncLock) { - await lock.lockAsync(() => { // 如果不添加异步锁,任务会因为数据竞争冲突,导致抛异常失败 - arr[0]++; - }) -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - let taskGroup = new taskpool.TaskGroup(); - let lock = new ArkTSUtils.locks.AsyncLock(); - let arr = collections.Array.create(1, 0); - let count = 1000; - while (count--) { - taskGroup.addTask(add, arr, lock); - } - taskpool.execute(taskGroup).then(() => { - console.info(`Return success: ${arr[0]} === ${count}`); - }).catch((e: Error) => { - console.error('Return error.'); - }) - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End example_use] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start example_use] +import { ArkTSUtils, collections, taskpool } from '@kit.ArkTS'; + +@Concurrent +async function add(arr: collections.Array, lock: ArkTSUtils.locks.AsyncLock) { + await lock.lockAsync(() => { // 如果不添加异步锁,任务会因为数据竞争冲突,导致抛异常失败 + arr[0]++; + }) +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + let taskGroup = new taskpool.TaskGroup(); + let lock = new ArkTSUtils.locks.AsyncLock(); + let arr = collections.Array.create(1, 0); + let count = 1000; + while (count--) { + taskGroup.addTask(add, arr, lock); + } + taskpool.execute(taskGroup).then(() => { + console.info(`Return success: ${arr[0]} === ${count}`); + }).catch((e: Error) => { + console.error('Return error.'); + }) + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End example_use] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsSendableModule.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsSendableModule.ets old mode 100755 new mode 100644 index d1ec1cef13..a93bfd3d07 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsSendableModule.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsSendableModule.ets @@ -1,93 +1,93 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start multi_thread_operate_exported_obj] -import { ArkTSUtils, taskpool } from '@kit.ArkTS'; -import { singletonA } from './sharedModule'; - -export { num, str } from './test'; // 正确示例,导出对象合集 - -@Sendable -export class A { - private count_: number = 0; - public lock_: ArkTSUtils.locks.AsyncLock = new ArkTSUtils.locks.AsyncLock(); - - public async getCount(): Promise { - return this.lock_.lockAsync(() => { - return this.count_; - }) - } - - public async increaseCount() { - await this.lock_.lockAsync(() => { - this.count_++; - }) - } -} - -@Concurrent -async function increaseCount() { - await singletonA.increaseCount(); - console.info('SharedModule: count is:' + await singletonA.getCount()); -} - -@Concurrent -async function printCount() { - console.info('SharedModule: count is:' + await singletonA.getCount()); -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - @State mainThreadPrint: string = 'MainThread print count'; - @State taskpoolPrint: string = 'Taskpool print count'; - @State mainThreadIncrease: string = 'MainThread increase count'; - @State taskpoolIncrease: string = 'Taskpool increase count'; - - build() { - Row() { - Column() { - Button(this.mainThreadPrint) - .id('MainThread print count') - .onClick(async () => { - await printCount(); - this.mainThreadPrint = 'success'; - }) - Button(this.taskpoolPrint) - .id('Taskpool print count') - .onClick(async () => { - await taskpool.execute(printCount); - this.taskpoolPrint = 'success'; - }) - Button(this.mainThreadIncrease) - .id('MainThread increase count') - .onClick(async () => { - await increaseCount(); - this.mainThreadIncrease = 'success'; - }) - Button(this.taskpoolIncrease) - .id('Taskpool increase count') - .onClick(async () => { - await taskpool.execute(increaseCount); - this.taskpoolIncrease = 'success'; - }) - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start multi_thread_operate_exported_obj] +import { ArkTSUtils, taskpool } from '@kit.ArkTS'; +import { singletonA } from './sharedModule'; + +export { num, str } from './test'; // 正确示例,导出对象合集 + +@Sendable +export class A { + private count_: number = 0; + public lock_: ArkTSUtils.locks.AsyncLock = new ArkTSUtils.locks.AsyncLock(); + + public async getCount(): Promise { + return this.lock_.lockAsync(() => { + return this.count_; + }) + } + + public async increaseCount() { + await this.lock_.lockAsync(() => { + this.count_++; + }) + } +} + +@Concurrent +async function increaseCount() { + await singletonA.increaseCount(); + console.info('SharedModule: count is:' + await singletonA.getCount()); +} + +@Concurrent +async function printCount() { + console.info('SharedModule: count is:' + await singletonA.getCount()); +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + @State mainThreadPrint: string = 'MainThread print count'; + @State taskpoolPrint: string = 'Taskpool print count'; + @State mainThreadIncrease: string = 'MainThread increase count'; + @State taskpoolIncrease: string = 'Taskpool increase count'; + + build() { + Row() { + Column() { + Button(this.mainThreadPrint) + .id('MainThread print count') + .onClick(async () => { + await printCount(); + this.mainThreadPrint = 'success'; + }) + Button(this.taskpoolPrint) + .id('Taskpool print count') + .onClick(async () => { + await taskpool.execute(printCount); + this.taskpoolPrint = 'success'; + }) + Button(this.mainThreadIncrease) + .id('MainThread increase count') + .onClick(async () => { + await increaseCount(); + this.mainThreadIncrease = 'success'; + }) + Button(this.taskpoolIncrease) + .id('Taskpool increase count') + .onClick(async () => { + await taskpool.execute(increaseCount); + this.taskpoolIncrease = 'success'; + }) + } + .width('100%') + } + .height('100%') + } +} // [End multi_thread_operate_exported_obj] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/AsonParsingGeneration.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/AsonParsingGeneration.ets old mode 100755 new mode 100644 index 406d1c3bf0..04d7088514 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/AsonParsingGeneration.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/AsonParsingGeneration.ets @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start example_serialize] -import { ArkTSUtils, collections } from '@kit.ArkTS'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - ArkTSUtils.ASON.parse('{}'); - ArkTSUtils.ASON.stringify(new collections.Array(1, 2, 3)); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End example_serialize] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start example_serialize] +import { ArkTSUtils, collections } from '@kit.ArkTS'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + ArkTSUtils.ASON.parse('{}'); + ArkTSUtils.ASON.stringify(new collections.Array(1, 2, 3)); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End example_serialize] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/SendableFreeze.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/SendableFreeze.ets old mode 100755 new mode 100644 index 08054f6674..88bce935a6 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/SendableFreeze.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/SendableFreeze.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start freeze_obj_send_child_thread] -import { freezeObj } from './helper'; -import { worker } from '@kit.ArkTS'; - -@Sendable -export class GlobalConfig { - // 一些配置属性与方法 - init() { - // 初始化相关逻辑 - freezeObj(this); // 初始化完成后冻结当前对象 - } -} - -@Entry -@Component -struct Index { - @State message: string = 'Sendable freezeObj Test'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - let gConifg = new GlobalConfig(); - gConifg.init(); - const workerInstance = new worker.ThreadWorker('entry/ets/workers/Worker.ets', { name: 'Worker1' }); - workerInstance.postMessage(gConifg); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End freeze_obj_send_child_thread] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start freeze_obj_send_child_thread] +import { freezeObj } from './helper'; +import { worker } from '@kit.ArkTS'; + +@Sendable +export class GlobalConfig { + // 一些配置属性与方法 + init() { + // 初始化相关逻辑 + freezeObj(this); // 初始化完成后冻结当前对象 + } +} + +@Entry +@Component +struct Index { + @State message: string = 'Sendable freezeObj Test'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + let gConifg = new GlobalConfig(); + gConifg.init(); + const workerInstance = new worker.ThreadWorker('entry/ets/workers/Worker.ets', { name: 'Worker1' }); + workerInstance.postMessage(gConifg); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End freeze_obj_send_child_thread] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/helper.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/helper.ts old mode 100755 new mode 100644 index a79139165c..1b512fdcfc --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/helper.ts +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/helper.ts @@ -1,20 +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. - */ - -// [Start provide_encapsulate_method] -export function freezeObj(obj: any) { - Object.freeze(obj); -} -// [End provide_encapsulate_method] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start provide_encapsulate_method] +export function freezeObj(obj: any) { + Object.freeze(obj); +} +// [End provide_encapsulate_method] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/sharedModule.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/sharedModule.ets old mode 100755 new mode 100644 index 400e8d095f..aced6a41d1 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/sharedModule.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/sharedModule.ets @@ -1,43 +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. - */ - -// [Start export_sendable_object] -// 共享模块 -import { ArkTSUtils } from '@kit.ArkTS'; - -// 声明当前模块为共享模块,只能导出可Sendable数据 -'use shared' - -// 共享模块,SingletonA全局唯一 -@Sendable -class SingletonA { - private count_: number = 0; - public lock_: ArkTSUtils.locks.AsyncLock = new ArkTSUtils.locks.AsyncLock(); - - public async getCount(): Promise { - return this.lock_.lockAsync(() => { - return this.count_; - }) - } - - public async increaseCount() { - await this.lock_.lockAsync(() => { - this.count_++; - }) - } -} - -export let singletonA = new SingletonA(); -// [End export_sendable_object] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start export_sendable_object] +// 共享模块 +import { ArkTSUtils } from '@kit.ArkTS'; + +// 声明当前模块为共享模块,只能导出可Sendable数据 +'use shared' + +// 共享模块,SingletonA全局唯一 +@Sendable +class SingletonA { + private count_: number = 0; + public lock_: ArkTSUtils.locks.AsyncLock = new ArkTSUtils.locks.AsyncLock(); + + public async getCount(): Promise { + return this.lock_.lockAsync(() => { + return this.count_; + }) + } + + public async increaseCount() { + await this.lock_.lockAsync(() => { + this.count_++; + }) + } +} + +export let singletonA = new SingletonA(); +// [End export_sendable_object] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/test.ets old mode 100755 new mode 100644 index b8d2e46c3d..2a511a29df --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/test.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/test.ets @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// 不允许使用side-effects-import -// [Start constrained_test] -// import "./sharedModule" - -export let num = 1; -export let str = 'aaa'; - -// 共享模块 -'use shared' - -// export * from './test'; // 编译报错,不允许直接导出模块 -// export {num, str} from './test'; // 正确示例,导出对象合集 -// [End constrained_test] +/* + * 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. + */ + +// 不允许使用side-effects-import +// [Start constrained_test] +// import "./sharedModule" + +export let num = 1; +export let str = 'aaa'; + +// 共享模块 +'use shared' + +// export * from './test'; // 编译报错,不允许直接导出模块 +// export {num, str} from './test'; // 正确示例,导出对象合集 +// [End constrained_test] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/util/resource.ets old mode 100755 new mode 100644 index 79a04af93b..a0f1755b8c --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/util/resource.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/util/resource.ets @@ -1,25 +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. - */ - -export class P2PManager { - public resourceToString(resource: Resource):string { - return getContext(this).resourceManager.getStringSync(resource); - } -} - -// 默认导出let -let p2pManager = new P2PManager(); - +/* + * 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 class P2PManager { + public resourceToString(resource: Resource):string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/workers/Worker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/workers/Worker.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/ohosTest.md old mode 100755 new mode 100644 index 2b6334d9e4..52a5619b38 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/ohosTest.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/ohosTest.md @@ -1,12 +1,12 @@ -# SendableObjectRelated 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------- | ------------------------------------ | ------------------------------------------------------------ | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 异步锁 | 位于ArktsAsyncLockIntroduction.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| ASON解析与生成 | 位于AsonParsingGeneration.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 共享容器 | 位于ArktsCollectionsIntroduction.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 共享模块 | 位于ArktsSendableModule.ets | 点击MainThread print count;
点击Taskpool print count;
点击MainThread increase count
点击Taskpool increase count | 1秒后页面显示“success” | 是 | Pass | +# SendableObjectRelated 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------- | ------------------------------------ | ------------------------------------------------------------ | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 异步锁 | 位于ArktsAsyncLockIntroduction.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| ASON解析与生成 | 位于AsonParsingGeneration.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 共享容器 | 位于ArktsCollectionsIntroduction.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 共享模块 | 位于ArktsSendableModule.ets | 点击MainThread print count;
点击Taskpool print count;
点击MainThread increase count
点击Taskpool increase count | 1秒后页面显示“success” | 是 | Pass | | Sendable对象冻结 | 位于SendableFreeze.ets | 点击Sendable freezeObj Test | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/screenshots/SendableObjectRelated_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/screenshots/SendableObjectRelated_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/screenshots/SendableObjectRelated_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/screenshots/SendableObjectRelated_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/app.json5 old mode 100755 new mode 100644 index d64880256f..7ad9c602c4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/app.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/app.json5 @@ -1,25 +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.sendablescenarios", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.sendablescenarios", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 22710ded99..2d7136e3a9 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SendableScenarios" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SendableScenarios" + } + ] +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/README.md old mode 100755 new mode 100644 index e2db0e7115..7fcabaa134 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/README.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/README.md @@ -1,85 +1,85 @@ -# ArkTS Sendable使用场景 - -### 介绍 - -Sendable对象可以在不同并发实例间通过引用传递。通过引用传递方式传输对象相比序列化方式更加高效,同时不会丢失class上携带的成员方法。因此,Sendable主要可以解决两个场景的问题: - -- 跨并发实例传输大数据(例如可能达到100KB以上的数据)。 -- 跨并发实例传递带方法的class实例对象。 - -该工程中展示的代码详细描述可查如下链接: - -- [Sendable使用场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/sendable-guide.md) - -### 效果预览 - -| bigdata模块 | crossconcurrency模块 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 运行bigdata模块,分别点击Listener task和Data processing task执行程序 -2. 执行结果会即时反馈在屏幕中,并在控制台打印log。 -3. 运行crossconcurrency模块,点击Hello World执行程序 -4. 执行结果会即时反馈在屏幕中,并在控制台打印log。 - -### 工程目录 - -``` -bigdata/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 跨并发实例传输大数据场景示例代码 - │ │ ├── sendable.ets // 跨并发实例传输大数据场景示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 - crossconcurrency/src/ - ├── main - │ ├── ets - │ │ ├── crossconcurrencyability - │ │ ├── pages - │ │ ├── Index.ets // 跨并发实例传递带方法的class实例对象示例代码 - │ │ ├── sendable.ets // 跨并发实例传递带方法的class实例对象示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# ArkTS Sendable使用场景 + +### 介绍 + +Sendable对象可以在不同并发实例间通过引用传递。通过引用传递方式传输对象相比序列化方式更加高效,同时不会丢失class上携带的成员方法。因此,Sendable主要可以解决两个场景的问题: + +- 跨并发实例传输大数据(例如可能达到100KB以上的数据)。 +- 跨并发实例传递带方法的class实例对象。 + +该工程中展示的代码详细描述可查如下链接: + +- [Sendable使用场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/sendable-guide.md) + +### 效果预览 + +| bigdata模块 | crossconcurrency模块 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 运行bigdata模块,分别点击Listener task和Data processing task执行程序 +2. 执行结果会即时反馈在屏幕中,并在控制台打印log。 +3. 运行crossconcurrency模块,点击Hello World执行程序 +4. 执行结果会即时反馈在屏幕中,并在控制台打印log。 + +### 工程目录 + +``` +bigdata/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 跨并发实例传输大数据场景示例代码 + │ │ ├── sendable.ets // 跨并发实例传输大数据场景示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 + crossconcurrency/src/ + ├── main + │ ├── ets + │ │ ├── crossconcurrencyability + │ │ ├── pages + │ │ ├── Index.ets // 跨并发实例传递带方法的class实例对象示例代码 + │ │ ├── sendable.ets // 跨并发实例传递带方法的class实例对象示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios > .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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/oh-package.json5 old mode 100755 new mode 100644 index 92738004f0..93ac2c522a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "name": "bigdata", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} +/* + * 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": "bigdata", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/pages/sendable.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/pages/sendable.ets old mode 100755 new mode 100644 index cb2558af92..ed1e51ff99 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/pages/sendable.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/ets/pages/sendable.ets @@ -1,43 +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. - */ - -// [Start across_concurrent_instance_transfer_large_data] -// 将数据量较大的数据在Sendable class中组装 -@Sendable -export class TestTypeA { - public name: string = 'A'; - constructor(name: string) { - this.name = name; - } -} - -@Sendable -export class TestTypeB { - public name: string = 'B'; - constructor(name: string) { - this.name = name; - } -} - -@Sendable -export class Test { - public data1: TestTypeA; - public data2: TestTypeB; - constructor(arg1: TestTypeA, arg2: TestTypeB) { - this.data1 = arg1; - this.data2 = arg2; - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start across_concurrent_instance_transfer_large_data] +// 将数据量较大的数据在Sendable class中组装 +@Sendable +export class TestTypeA { + public name: string = 'A'; + constructor(name: string) { + this.name = name; + } +} + +@Sendable +export class TestTypeB { + public name: string = 'B'; + constructor(name: string) { + this.name = name; + } +} + +@Sendable +export class Test { + public data1: TestTypeA; + public data2: TestTypeB; + constructor(arg1: TestTypeA, arg2: TestTypeB) { + this.data1 = arg1; + this.data2 = arg2; + } +} // [End across_concurrent_instance_transfer_large_data] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/module.json5 old mode 100755 new mode 100644 index c10f0015f2..8833eaf553 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/module.json5 @@ -1,66 +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": "bigdata", - "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" - } - ] - } - ] - } +/* + * 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": "bigdata", + "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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/dark/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/module.json5 old mode 100755 new mode 100644 index de812daa8b..32a2233605 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "bigdata_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } +/* + * 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": "bigdata_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/bigdata/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/build-profile.json5 old mode 100755 new mode 100644 index becf2418c8..9708d03bca --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/build-profile.json5 @@ -1,70 +1,70 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "bigdata", - "srcPath": "./bigdata", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "crossconcurrency", - "srcPath": "./crossconcurrency", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "bigdata", + "srcPath": "./bigdata", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "crossconcurrency", + "srcPath": "./crossconcurrency", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/oh-package.json5 old mode 100755 new mode 100644 index 7b0402b938..2153ed2bf1 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/oh-package.json5 @@ -1,25 +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": "crossconcurrency", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "crossconcurrency", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/crossconcurrencyability/CrossconcurrencyAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/crossconcurrencyability/CrossconcurrencyAbility.ets deleted file mode 100755 index 500f3aa377..0000000000 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/crossconcurrencyability/CrossconcurrencyAbility.ets +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CrossconcurrencyAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/pages/sendable.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/pages/sendable.ets old mode 100755 new mode 100644 index b48d806bf6..37de2cd3c3 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/pages/sendable.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/ets/pages/sendable.ets @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start across_concurrent_instance_pass_class_method] -// 定义模拟类Test,模仿开发过程中需传递带方法的class -import { lang, collections } from '@kit.ArkTS' - -export type ISendable = lang.ISendable; - -@Sendable -export class SendableTestClass { - public name: string = 'John'; - public age: number = 20; - public sex: string = 'man'; - public arr: collections.Array = new collections.Array(1, 2, 3); - - constructor() { - } - - setAge(age: number): void { - this.age = age; - } - - printName(): string { - return this.name; - } - - printAge(): number { - return this.age; - } - - printSex(): string { - return this.sex; - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start across_concurrent_instance_pass_class_method] +// 定义模拟类Test,模仿开发过程中需传递带方法的class +import { lang, collections } from '@kit.ArkTS' + +export type ISendable = lang.ISendable; + +@Sendable +export class SendableTestClass { + public name: string = 'John'; + public age: number = 20; + public sex: string = 'man'; + public arr: collections.Array = new collections.Array(1, 2, 3); + + constructor() { + } + + setAge(age: number): void { + this.age = age; + } + + printName(): string { + return this.name; + } + + printAge(): number { + return this.age; + } + + printSex(): string { + return this.sex; + } +} // [End across_concurrent_instance_pass_class_method] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/module.json5 old mode 100755 new mode 100644 index b3eab50bcf..c643ef9a33 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/module.json5 @@ -1,42 +1,42 @@ -/* - * 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": "crossconcurrency", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CrossconcurrencyAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CrossconcurrencyAbility", - "srcEntry": "./ets/crossconcurrencyability/CrossconcurrencyAbility.ets", - "description": "$string:CrossconcurrencyAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CrossconcurrencyAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } +/* + * 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": "crossconcurrency", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CrossconcurrencyAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CrossconcurrencyAbility", + "srcEntry": "./ets/crossconcurrencyability/CrossconcurrencyAbility.ets", + "description": "$string:CrossconcurrencyAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CrossconcurrencyAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 98e8196377..c530a9ac5d --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "crossconcurrency_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "crossconcurrency_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/crossconcurrency/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/ohosTest.md old mode 100755 new mode 100644 index 3417c4410d..5dabaf7c7e --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/ohosTest.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/ohosTest.md @@ -1,9 +1,9 @@ -# SendableScenarios 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------------- | ----------------------------------- | ----------------------------------------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 跨并发实例传输大数据场景 | 位于bigdata模块下Index.ets | 点击Listener task
点击Data processing task | 1秒后页面显示“success” | 是 | Pass | +# SendableScenarios 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------------- | ----------------------------------- | ----------------------------------------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 跨并发实例传输大数据场景 | 位于bigdata模块下Index.ets | 点击Listener task
点击Data processing task | 1秒后页面显示“success” | 是 | Pass | | 跨并发实例传递带方法的class实例对象 | 位于crossconcurrency模块下Index.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/screenshots/SendableScenarios_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/screenshots/SendableScenarios_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/screenshots/SendableScenarios_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableScenarios/screenshots/SendableScenarios_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/app.json5 old mode 100755 new mode 100644 index 09128953cd..f91bd56379 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/app.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/app.json5 @@ -1,25 +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.interthreadcommunicationscenario", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.interthreadcommunicationscenario", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index d77691b8db..6f3d5184db --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "InterThreadCommunicationScenario" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "InterThreadCommunicationScenario" + } + ] +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/README.md old mode 100755 new mode 100644 index ee03667195..bd8425b283 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/README.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/README.md @@ -1,104 +1,104 @@ -# ArkTS 线程间通信场景 - -### 介绍 - -#### 使用TaskPool执行独立的耗时任务 - -对于一个独立运行的耗时任务,只需要在任务执行完毕后将结果返回给宿主线程,没有上下文依赖 - -#### 使用TaskPool执行多个耗时任务 - -如果有多个任务同时执行,由于任务的复杂度不同,执行时间会不一样,返回数据的时间也是不可控的。如果宿主线程需要所有任务执行完毕的数据,那么可以通过下面这种方式实现。 - -除此以外,如果需要处理的数据量较大(比如一个列表中有10000条数据),把这些数据都放在一个Task中处理也是比较耗时的。那么就可以将原始数据拆分成多个列表,并将每个子列表分配给一个独立的Task进行执行,并且等待全部执行完毕后拼成完整的数据,这样可以节省处理时间,提升用户体验。 - -#### TaskPool任务与宿主线程通信 - -如果一个Task不仅需要返回的执行结果,还需要定时向宿主线状态或数据的变化,或者需要分段返回大量数据(例如从数据库中读取大量数据)。 - -#### Worker和宿主线程的即时消息通信 - -在ArkTS中,Worker相对于Taskpool存在一定的差异性,有数量限制但是可以长时间存在。一个[Worker](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/worker-introduction.md)中可能会执行多个不同的任务,每个任务执行的时长或者返回的结果可能都不相同,宿主线程需要根据情况调用Worker中的不同方法,Worker则需要及时地将结果返回给宿主线程。 - -#### Worker同步调用宿主线程的接口 - -如果一个接口在主线程中已经实现了,Worker需要调用该接口。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用TaskPool执行独立的耗时任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/independent-time-consuming-task.md) -- [使用TaskPool执行多个耗时任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/multi-time-consuming-tasks.md) -- [TaskPool任务与宿主线程通信](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/taskpool-communicates-with-mainthread.md) -- [Worker和宿主线程的即时消息通信](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/worker-communicates-with-mainthread.md) -- [Worker同步调用宿主线程的接口](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/worker-invoke-mainthread-interface.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── managers - │ │ ├── IconItemSource.ets // 公共资源文件 - │ │ ├── IndependentTask.ets // 公共资源文件 - │ │ ├── IndependentTimeConsumingTask.ets // 使用TaskPool执行独立的耗时任务 - │ │ ├── MultiTask.ets // 公共资源文件 - │ │ ├── MultiTimeConsumingTasks.ets // 使用TaskPool执行多个耗时任务 - │ │ ├── TaskSendDataUsage.ets // TaskPool任务与宿主线程通信 - │ │ ├── WorkerCallGlobalUsage.ets // Worker同步调用宿主线程的接口 - │ │ ├── WorkerCommunicatesWithMainthread.ets // Worker和宿主线程的即时消息通信 - │ │ ├── pages - │ │ ├── Index.ets // 首页 - │ │ ├── util - │ │ ├── CommonButton.ets // 首页跳转UI - │ │ ├── resource.ets // 资源引用转换 - │ │ ├── workers - │ │ ├── Worker.ets // 公共资源文件 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# ArkTS 线程间通信场景 + +### 介绍 + +#### 使用TaskPool执行独立的耗时任务 + +对于一个独立运行的耗时任务,只需要在任务执行完毕后将结果返回给宿主线程,没有上下文依赖 + +#### 使用TaskPool执行多个耗时任务 + +如果有多个任务同时执行,由于任务的复杂度不同,执行时间会不一样,返回数据的时间也是不可控的。如果宿主线程需要所有任务执行完毕的数据,那么可以通过下面这种方式实现。 + +除此以外,如果需要处理的数据量较大(比如一个列表中有10000条数据),把这些数据都放在一个Task中处理也是比较耗时的。那么就可以将原始数据拆分成多个列表,并将每个子列表分配给一个独立的Task进行执行,并且等待全部执行完毕后拼成完整的数据,这样可以节省处理时间,提升用户体验。 + +#### TaskPool任务与宿主线程通信 + +如果一个Task不仅需要返回的执行结果,还需要定时向宿主线状态或数据的变化,或者需要分段返回大量数据(例如从数据库中读取大量数据)。 + +#### Worker和宿主线程的即时消息通信 + +在ArkTS中,Worker相对于Taskpool存在一定的差异性,有数量限制但是可以长时间存在。一个[Worker](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/worker-introduction.md)中可能会执行多个不同的任务,每个任务执行的时长或者返回的结果可能都不相同,宿主线程需要根据情况调用Worker中的不同方法,Worker则需要及时地将结果返回给宿主线程。 + +#### Worker同步调用宿主线程的接口 + +如果一个接口在主线程中已经实现了,Worker需要调用该接口。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用TaskPool执行独立的耗时任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/independent-time-consuming-task.md) +- [使用TaskPool执行多个耗时任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/multi-time-consuming-tasks.md) +- [TaskPool任务与宿主线程通信](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/taskpool-communicates-with-mainthread.md) +- [Worker和宿主线程的即时消息通信](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/worker-communicates-with-mainthread.md) +- [Worker同步调用宿主线程的接口](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/worker-invoke-mainthread-interface.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── managers + │ │ ├── IconItemSource.ets // 公共资源文件 + │ │ ├── IndependentTask.ets // 公共资源文件 + │ │ ├── IndependentTimeConsumingTask.ets // 使用TaskPool执行独立的耗时任务 + │ │ ├── MultiTask.ets // 公共资源文件 + │ │ ├── MultiTimeConsumingTasks.ets // 使用TaskPool执行多个耗时任务 + │ │ ├── TaskSendDataUsage.ets // TaskPool任务与宿主线程通信 + │ │ ├── WorkerCallGlobalUsage.ets // Worker同步调用宿主线程的接口 + │ │ ├── WorkerCommunicatesWithMainthread.ets // Worker和宿主线程的即时消息通信 + │ │ ├── pages + │ │ ├── Index.ets // 首页 + │ │ ├── util + │ │ ├── CommonButton.ets // 首页跳转UI + │ │ ├── resource.ets // 资源引用转换 + │ │ ├── workers + │ │ ├── Worker.ets // 公共资源文件 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario > .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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/build-profile.json5 old mode 100755 new mode 100644 index 51a699665a..18d36695db --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/build-profile.json5 @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "apiType": "stageMode", - "buildOption": { - "sourceOption": { - "workers": [ - "./src/main/ets/workers/Worker.ets" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": { + "sourceOption": { + "workers": [ + "./src/main/ets/workers/Worker.ets" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IconItemSource.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IconItemSource.ets old mode 100755 new mode 100644 index 6737d0bea5..8793b876b4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IconItemSource.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IconItemSource.ets @@ -1,26 +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. - */ - -// [Start implement_child_thread_task] -export class IconItemSource { - image: string | Resource = ''; - text: string | Resource = ''; - - constructor(image: string | Resource = '', text: string | Resource = '') { - this.image = image; - this.text = text; - } -} -// [End implement_child_thread_task] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start implement_child_thread_task] +export class IconItemSource { + image: string | Resource = ''; + text: string | Resource = ''; + + constructor(image: string | Resource = '', text: string | Resource = '') { + this.image = image; + this.text = text; + } +} +// [End implement_child_thread_task] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IndependentTask.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IndependentTask.ets old mode 100755 new mode 100644 index d673a99ffa..4140b18fa3 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IndependentTask.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IndependentTask.ets @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start implement_child_thread_task] -import { IconItemSource } from './IconItemSource'; - -// 在Task中执行的方法,需要添加@Concurrent注解,否则无法正常调用。 -@Concurrent -export function loadPicture(count: number): IconItemSource[] { - let iconItemSourceList: IconItemSource[] = []; - // 遍历添加6*count个IconItem的数据 - for (let index = 0; index < count; index++) { - const numStart: number = index * 6; - // 此处循环使用6张图片资源 - iconItemSourceList.push(new IconItemSource('$media:startIcon', `item${numStart + 1}`)); - iconItemSourceList.push(new IconItemSource('$media:background', `item${numStart + 2}`)); - iconItemSourceList.push(new IconItemSource('$media:foreground', `item${numStart + 3}`)); - iconItemSourceList.push(new IconItemSource('$media:startIcon', `item${numStart + 4}`)); - iconItemSourceList.push(new IconItemSource('$media:background', `item${numStart + 5}`)); - iconItemSourceList.push(new IconItemSource('$media:foreground', `item${numStart + 6}`)); - } - return iconItemSourceList; -} -// [End implement_child_thread_task] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start implement_child_thread_task] +import { IconItemSource } from './IconItemSource'; + +// 在Task中执行的方法,需要添加@Concurrent注解,否则无法正常调用。 +@Concurrent +export function loadPicture(count: number): IconItemSource[] { + let iconItemSourceList: IconItemSource[] = []; + // 遍历添加6*count个IconItem的数据 + for (let index = 0; index < count; index++) { + const numStart: number = index * 6; + // 此处循环使用6张图片资源 + iconItemSourceList.push(new IconItemSource('$media:startIcon', `item${numStart + 1}`)); + iconItemSourceList.push(new IconItemSource('$media:background', `item${numStart + 2}`)); + iconItemSourceList.push(new IconItemSource('$media:foreground', `item${numStart + 3}`)); + iconItemSourceList.push(new IconItemSource('$media:startIcon', `item${numStart + 4}`)); + iconItemSourceList.push(new IconItemSource('$media:background', `item${numStart + 5}`)); + iconItemSourceList.push(new IconItemSource('$media:foreground', `item${numStart + 6}`)); + } + return iconItemSourceList; +} +// [End implement_child_thread_task] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IndependentTimeConsumingTask.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IndependentTimeConsumingTask.ets old mode 100755 new mode 100644 index 9f5858f4a2..86799a2f84 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IndependentTimeConsumingTask.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/IndependentTimeConsumingTask.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start execute_task] -import { taskpool } from '@kit.ArkTS'; -import { IconItemSource } from './IconItemSource'; -import { loadPicture } from './IndependentTask'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - let iconItemSourceList: IconItemSource[] = []; - // 创建Task - let lodePictureTask: taskpool.Task = new taskpool.Task(loadPicture, 30); - // 执行Task,并返回结果 - taskpool.execute(lodePictureTask).then((res: object) => { - // loadPicture方法的执行结果 - iconItemSourceList = res as IconItemSource[]; - }) - this.message = 'success'; - }) - } - .width('100%') - } - .height('100%') - } -} -// [End execute_task] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start execute_task] +import { taskpool } from '@kit.ArkTS'; +import { IconItemSource } from './IconItemSource'; +import { loadPicture } from './IndependentTask'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + let iconItemSourceList: IconItemSource[] = []; + // 创建Task + let lodePictureTask: taskpool.Task = new taskpool.Task(loadPicture, 30); + // 执行Task,并返回结果 + taskpool.execute(lodePictureTask).then((res: object) => { + // loadPicture方法的执行结果 + iconItemSourceList = res as IconItemSource[]; + }) + this.message = 'success'; + }) + } + .width('100%') + } + .height('100%') + } +} +// [End execute_task] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/MultiTask.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/MultiTask.ets old mode 100755 new mode 100644 index 659fdce4a8..96765cce24 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/MultiTask.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/MultiTask.ets @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start execute_task_group] -import { taskpool } from '@kit.ArkTS'; -import { IconItemSource } from './IconItemSource'; -import { loadPicture } from './IndependentTask'; - -let iconItemSourceList: IconItemSource[][]; - -let taskGroup: taskpool.TaskGroup = new taskpool.TaskGroup(); -taskGroup.addTask(new taskpool.Task(loadPicture, 30)); -taskGroup.addTask(new taskpool.Task(loadPicture, 20)); -taskGroup.addTask(new taskpool.Task(loadPicture, 10)); -taskpool.execute(taskGroup).then((ret: object) => { - let tmpLength = (ret as IconItemSource[][]).length - for (let i = 0; i < tmpLength; i++) { - for (let j = 0; j < ret[i].length; j++) { - iconItemSourceList.push(ret[i][j]); - } - } -}) -// [End execute_task_group] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start execute_task_group] +import { taskpool } from '@kit.ArkTS'; +import { IconItemSource } from './IconItemSource'; +import { loadPicture } from './IndependentTask'; + +let iconItemSourceList: IconItemSource[][]; + +let taskGroup: taskpool.TaskGroup = new taskpool.TaskGroup(); +taskGroup.addTask(new taskpool.Task(loadPicture, 30)); +taskGroup.addTask(new taskpool.Task(loadPicture, 20)); +taskGroup.addTask(new taskpool.Task(loadPicture, 10)); +taskpool.execute(taskGroup).then((ret: object) => { + let tmpLength = (ret as IconItemSource[][]).length + for (let i = 0; i < tmpLength; i++) { + for (let j = 0; j < ret[i].length; j++) { + iconItemSourceList.push(ret[i][j]); + } + } +}) +// [End execute_task_group] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/MultiTimeConsumingTasks.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/MultiTimeConsumingTasks.ets old mode 100755 new mode 100644 index 99d736c041..1c9a488278 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/MultiTimeConsumingTasks.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/MultiTimeConsumingTasks.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { taskpool } from '@kit.ArkTS'; -import { IconItemSource } from './IconItemSource'; -import { loadPicture } from './IndependentTask'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - let iconItemSourceList: IconItemSource[] = []; - // 创建Task - let lodePictureTask: taskpool.Task = new taskpool.Task(loadPicture, 30); - // 执行Task,并返回结果 - taskpool.execute(lodePictureTask).then((res: object) => { - // loadPicture方法的执行结果 - iconItemSourceList = res as IconItemSource[]; - }) - this.message = 'success'; - }) - } - .width('100%') - } - .height('100%') - } -} +/* + * 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 { taskpool } from '@kit.ArkTS'; +import { IconItemSource } from './IconItemSource'; +import { loadPicture } from './IndependentTask'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + let iconItemSourceList: IconItemSource[] = []; + // 创建Task + let lodePictureTask: taskpool.Task = new taskpool.Task(loadPicture, 30); + // 执行Task,并返回结果 + taskpool.execute(lodePictureTask).then((res: object) => { + // loadPicture方法的执行结果 + iconItemSourceList = res as IconItemSource[]; + }) + this.message = 'success'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/TaskSendDataUsage.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/TaskSendDataUsage.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/WorkerCallGlobalUsage.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/WorkerCallGlobalUsage.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/WorkerCommunicatesWithMainthread.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/WorkerCommunicatesWithMainthread.ets old mode 100755 new mode 100644 index f961776160..47cd27b9c8 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/WorkerCommunicatesWithMainthread.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/managers/WorkerCommunicatesWithMainthread.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start respond_worker_instant_message] -import { worker } from '@kit.ArkTS'; -import { BusinessError } from '@kit.BasicServicesKit'; - -function promiseCase() { - let p: Promise = new Promise((resolve: Function, reject: Function) => { - setTimeout(() => { - resolve(1); - }, 100) - }).then(undefined, (error: BusinessError) => { - }) - return p; -} - -async function postMessageTest() { - let ss = new worker.ThreadWorker('entry/ets/workers/Worker.ets'); - let res = undefined; - let flag = false; - let isTerminate = false; - ss.onexit = () => { - isTerminate = true; - } - // 接收Worker线程发送的消息 - ss.onmessage = (e) => { - res = e.data; - flag = true; - console.info('worker:: res is ' + res); - } - // 给Worker线程发送消息 - ss.postMessage('hello world'); - while (!flag) { - await promiseCase(); - } - - ss.terminate(); - while (!isTerminate) { - await promiseCase(); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - postMessageTest(); - this.message = 'success'; - }) - } - .width('100%') - } - .height('100%') - } -} -// [End respond_worker_instant_message] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start respond_worker_instant_message] +import { worker } from '@kit.ArkTS'; +import { BusinessError } from '@kit.BasicServicesKit'; + +function promiseCase() { + let p: Promise = new Promise((resolve: Function, reject: Function) => { + setTimeout(() => { + resolve(1); + }, 100) + }).then(undefined, (error: BusinessError) => { + }) + return p; +} + +async function postMessageTest() { + let ss = new worker.ThreadWorker('entry/ets/workers/Worker.ets'); + let res = undefined; + let flag = false; + let isTerminate = false; + ss.onexit = () => { + isTerminate = true; + } + // 接收Worker线程发送的消息 + ss.onmessage = (e) => { + res = e.data; + flag = true; + console.info('worker:: res is ' + res); + } + // 给Worker线程发送消息 + ss.postMessage('hello world'); + while (!flag) { + await promiseCase(); + } + + ss.terminate(); + while (!isTerminate) { + await promiseCase(); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + postMessageTest(); + this.message = 'success'; + }) + } + .width('100%') + } + .height('100%') + } +} +// [End respond_worker_instant_message] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/util/resource.ets old mode 100755 new mode 100644 index de30eb4b1b..723a394265 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/util/resource.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/util/resource.ets @@ -1,25 +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. - */ - -export class P2PManager { - public resourceToString(resource: Resource): string { - return getContext(this).resourceManager.getStringSync(resource); - } -} - -// 默认导出let -let p2pManager = new P2PManager(); - +/* + * 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 class P2PManager { + public resourceToString(resource: Resource): string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/workers/Worker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/ets/workers/Worker.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/ohosTest.md old mode 100755 new mode 100644 index 0c2dd961dd..d1ad03d05b --- a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/ohosTest.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/ohosTest.md @@ -1,12 +1,12 @@ -# InterThreadCommunicationScenario 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------ | ---------------------------------------- | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 使用TaskPool执行独立的耗时任务 | 位于IndependentTimeConsumingTask.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 使用TaskPool执行多个耗时任务 | 位于MultiTimeConsumingTasks.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| TaskPool任务与宿主线程通信 | 位于TaskSendDataUsage.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| Worker同步调用宿主线程的接口 | 位于WorkerCallGlobalUsage.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +# InterThreadCommunicationScenario 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------ | ---------------------------------------- | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 使用TaskPool执行独立的耗时任务 | 位于IndependentTimeConsumingTask.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 使用TaskPool执行多个耗时任务 | 位于MultiTimeConsumingTasks.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| TaskPool任务与宿主线程通信 | 位于TaskSendDataUsage.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| Worker同步调用宿主线程的接口 | 位于WorkerCallGlobalUsage.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | | Worker和宿主线程的即时消息通信 | 位于WorkerCommunicatesWithMainthread.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/screenshots/InterThreadCommunicationScenario_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/screenshots/InterThreadCommunicationScenario_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/screenshots/InterThreadCommunicationScenario_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationScenario/screenshots/InterThreadCommunicationScenario_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/app.json5 new file mode 100644 index 0000000000..8e962e1c58 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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.multithreadconcurrencyoverview", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..4edacd4b6b --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MultiThreadConcurrencyOverview" + } + ] +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/README.md new file mode 100644 index 0000000000..b645f7de86 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/README.md @@ -0,0 +1,72 @@ +# ArkTS 多线程并发概述 + +### 介绍 + +并发模型是用来实现不同应用场景中并发任务的编程模型,常见的并发模型分为基于内存共享的并发模型和基于消息通信的并发模型。 + +Actor并发模型作为基于消息通信并发模型的典型代表,不需要开发者去面对锁带来的一系列复杂偶发的问题,同时并发度也相对较高,因此得到了广泛的支持和使用。 + +当前ArkTS提供了TaskPool和Worker两种并发能力,TaskPool和Worker都基于Actor并发模型实现。 + +Actor并发模型和内存共享并发模型的具体对比请见[多线程并发模型](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/multi-thread-concurrency-overview.md#多线程并发模型)。 + +该工程中展示的代码详细描述可查如下链接: + +- [多线程并发概述](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/multi-thread-concurrency-overview.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击start,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 多线程并发概述示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview > .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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/build-profile.json5 new file mode 100644 index 0000000000..6d9dd7fe7c --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/code-linter.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/code-linter.json5 diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/.gitignore rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/.gitignore diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/build-profile.json5 new file mode 100644 index 0000000000..31bf2f4c4d --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/obfuscation-rules.txt rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/oh-package.json5 new file mode 100644 index 0000000000..4e54d14e1b --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..51bdf85846 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..6b744d7eaa --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 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/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/module.json5 new file mode 100644 index 0000000000..cb5df2316a --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/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/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/mock/mock-config.json5 rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/mock/mock-config.json5 diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..5f63462032 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..0df4e83ad0 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 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.1", + "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/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigorfile.ts rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/oh-package.json5 new file mode 100644 index 0000000000..936cf43ead --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/ohosTest.md new file mode 100644 index 0000000000..92c98cb4a7 --- /dev/null +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/ohosTest.md @@ -0,0 +1,9 @@ +# MultiThreadConcurrencyOverview 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------------------------------------------- | ------------ | --------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 使用基于Actor模型的TaskPool并发能力来解决生产者消费者问题 | 位于首页 | 点击start | 1秒后页面显示“success” | 是 | Pass | + diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/screenshots/MultiThreadConcurrencyOverview_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/screenshots/MultiThreadConcurrencyOverview_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/screenshots/MultiThreadConcurrencyOverview_1.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/screenshots/MultiThreadConcurrencyOverview_1.png diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/screenshots/MultiThreadConcurrencyOverview_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/screenshots/MultiThreadConcurrencyOverview_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/screenshots/MultiThreadConcurrencyOverview_2.png rename to code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/screenshots/MultiThreadConcurrencyOverview_2.png diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/app.json5 old mode 100755 new mode 100644 index b731438608..b298ce16ef --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/app.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/app.json5 @@ -1,25 +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.taskpoolintroduction", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.taskpoolintroduction", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 32e39cdbf9..31939aac3a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "TaskPoolIntroduction" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "TaskPoolIntroduction" + } + ] +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/README.md old mode 100755 new mode 100644 index aa74a6fc4b..6da606f8ad --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/README.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/README.md @@ -1,75 +1,75 @@ -# ArkTS TaskPool简介 - -### 介绍 - -任务池(TaskPool)作用是为应用程序提供一个多线程的运行环境,降低整体资源的消耗、提高系统的整体性能,且您无需关心线程实例的生命周期。具体接口信息及使用方法详情请见[TaskPool](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-taskpool.md)。 - -该工程中展示的代码详细描述可查如下链接: - -- [TaskPool简介](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/taskpool-introduction.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── managers - │ │ ├── asynchronousfunctions.ets // 并发异步函数中使用Promise - │ │ ├── customclasses.ets // 并发函数中使用自定义类或函数 - │ │ ├── generaluse.ets // 并发函数一般使用 - │ │ ├── returnpromise.ets // 并发函数返回Promise - │ │ ├── Test.ets // 并发函数中使用自定义类或函数 - │ │ ├── pages - │ │ ├── Index.ets // 首页 - │ │ ├── util - │ │ ├── CommonButton.ets // 首页跳转UI - │ │ ├── resource.ets // 资源引用转换 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# ArkTS TaskPool简介 + +### 介绍 + +任务池(TaskPool)作用是为应用程序提供一个多线程的运行环境,降低整体资源的消耗、提高系统的整体性能,且您无需关心线程实例的生命周期。具体接口信息及使用方法详情请见[TaskPool](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-taskpool.md)。 + +该工程中展示的代码详细描述可查如下链接: + +- [TaskPool简介](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/taskpool-introduction.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── managers + │ │ ├── asynchronousfunctions.ets // 并发异步函数中使用Promise + │ │ ├── customclasses.ets // 并发函数中使用自定义类或函数 + │ │ ├── generaluse.ets // 并发函数一般使用 + │ │ ├── returnpromise.ets // 并发函数返回Promise + │ │ ├── Test.ets // 并发函数中使用自定义类或函数 + │ │ ├── pages + │ │ ├── Index.ets // 首页 + │ │ ├── util + │ │ ├── CommonButton.ets // 首页跳转UI + │ │ ├── resource.ets // 资源引用转换 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction > .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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/Test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/Test.ets old mode 100755 new mode 100644 index 89d67c53a3..4146580945 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/Test.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/Test.ets @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start concurrent_taskpool_test_resources] -export function testAdd(arg: number) { - return ++arg; -} - -@Sendable -export class MyTestA { - constructor(name: string) { - this.name = name; - } - name: string = 'MyTestA'; -} - -export class MyTestB { - static nameStr:string = 'MyTestB'; -} -// [End concurrent_taskpool_test_resources] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start concurrent_taskpool_test_resources] +export function testAdd(arg: number) { + return ++arg; +} + +@Sendable +export class MyTestA { + constructor(name: string) { + this.name = name; + } + name: string = 'MyTestA'; +} + +export class MyTestB { + static nameStr:string = 'MyTestB'; +} +// [End concurrent_taskpool_test_resources] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/asynchronousfunctions.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/asynchronousfunctions.ets old mode 100755 new mode 100644 index c98d1ccdec..d8c8842d89 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/asynchronousfunctions.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/asynchronousfunctions.ets @@ -1,89 +1,89 @@ -/* - * 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. - */ - -// 并发异步函数中使用Promise -// 并发异步函数中如果使用Promise,建议搭配await使用捕获Promise中可能发生的异常。推荐使用示例如下。 -// [Start concurrent_taskpool_async_promise_usage] -import { taskpool } from '@kit.ArkTS'; - -@Concurrent -async function testPromiseError() { - await new Promise((resolve, reject) => { - resolve(1); - }).then(()=>{ - throw new Error('testPromise Error'); - }) -} - -@Concurrent -async function testPromiseError1() { - await new Promise((resolve, reject) => { - reject('testPromiseError1 Error msg'); - }) -} - -@Concurrent -function testPromiseError2() { - return new Promise((resolve, reject) => { - reject('testPromiseError2 Error msg'); - }) -} - -async function testConcurrentFunc() { - let task1: taskpool.Task = new taskpool.Task(testPromiseError); - let task2: taskpool.Task = new taskpool.Task(testPromiseError1); - let task3: taskpool.Task = new taskpool.Task(testPromiseError2); - - taskpool.execute(task1).then((d:object)=>{ - console.info('task1 res is: ' + d); - }).catch((e:object)=>{ - console.info('task1 catch e: ' + e); - }) - taskpool.execute(task2).then((d:object)=>{ - console.info('task2 res is: ' + d); - }).catch((e:object)=>{ - console.info('task2 catch e: ' + e); - }) - taskpool.execute(task3).then((d:object)=>{ - console.info('task3 res is: ' + d); - }).catch((e:object)=>{ - console.info('task3 catch e: ' + e); - }) -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Button(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - testConcurrentFunc(); - // [StartExclude concurrent_taskpool_async_promise_usage] - this.message = 'success'; - // [EndExclude concurrent_taskpool_async_promise_usage] - }) - } - .width('100%') - } - .height('100%') - } -} +/* + * 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. + */ + +// 并发异步函数中使用Promise +// 并发异步函数中如果使用Promise,建议搭配await使用捕获Promise中可能发生的异常。推荐使用示例如下。 +// [Start concurrent_taskpool_async_promise_usage] +import { taskpool } from '@kit.ArkTS'; + +@Concurrent +async function testPromiseError() { + await new Promise((resolve, reject) => { + resolve(1); + }).then(()=>{ + throw new Error('testPromise Error'); + }) +} + +@Concurrent +async function testPromiseError1() { + await new Promise((resolve, reject) => { + reject('testPromiseError1 Error msg'); + }) +} + +@Concurrent +function testPromiseError2() { + return new Promise((resolve, reject) => { + reject('testPromiseError2 Error msg'); + }) +} + +async function testConcurrentFunc() { + let task1: taskpool.Task = new taskpool.Task(testPromiseError); + let task2: taskpool.Task = new taskpool.Task(testPromiseError1); + let task3: taskpool.Task = new taskpool.Task(testPromiseError2); + + taskpool.execute(task1).then((d:object)=>{ + console.info('task1 res is: ' + d); + }).catch((e:object)=>{ + console.info('task1 catch e: ' + e); + }) + taskpool.execute(task2).then((d:object)=>{ + console.info('task2 res is: ' + d); + }).catch((e:object)=>{ + console.info('task2 catch e: ' + e); + }) + taskpool.execute(task3).then((d:object)=>{ + console.info('task3 res is: ' + d); + }).catch((e:object)=>{ + console.info('task3 catch e: ' + e); + }) +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Button(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + testConcurrentFunc(); + // [StartExclude concurrent_taskpool_async_promise_usage] + this.message = 'success'; + // [EndExclude concurrent_taskpool_async_promise_usage] + }) + } + .width('100%') + } + .height('100%') + } +} // [End concurrent_taskpool_async_promise_usage] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/customclasses.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/customclasses.ets old mode 100755 new mode 100644 index 6170a31b69..16c7dd8bce --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/customclasses.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/customclasses.ets @@ -1,95 +1,95 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// 并发函数中使用自定义类或函数 -// 并发函数中使用自定义类或函数时需定义在不同文件,否则会被认为是闭包,如下例所示。 -// [Start concurrent_taskpool_custom_class_function] -import { taskpool } from '@kit.ArkTS'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { testAdd, MyTestA, MyTestB } from './Test'; - -function add(arg: number) { - return ++arg; -} - -class TestA { - constructor(name: string) { - this.name = name; - } - name: string = 'ClassA'; -} - -class TestB { - static nameStr: string = 'ClassB'; -} - -@Concurrent -function testFunc() { - // case1:在并发函数中直接调用同文件内定义的类或函数 - - // 直接调用同文件定义的函数add(),add飘红报错: - // Only imported variables and local variables can be used in @Concurrent decorated functions. - // add(1); - // 直接使用同文件定义的TestA构造,TestA飘红报错: - // Only imported variables and local variables can be used in @Concurrent decorated functions. - // let a = new TestA('aaa'); - // 直接访问同文件定义的TestB的成员nameStr,TestB飘红报错: - // Only imported variables and local variables can be used in @Concurrent decorated functions. - // console.info('TestB name is: ' + TestB.nameStr); - - // case2:在并发函数中调用定义在Test.ets文件并导入当前文件的类或函数 - - // 输出结果:res1 is: 2 - console.info('res1 is: ' + testAdd(1)); - let tmpStr = new MyTestA('TEST A'); - // 输出结果:res2 is: TEST A - console.info('res2 is: ' + tmpStr.name); - // 输出结果:res3 is: MyTestB - console.info('res3 is: ' + MyTestB.nameStr); -} - - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - let task = new taskpool.Task(testFunc); - taskpool.execute(task).then(() => { - console.info('taskpool: execute task success!'); - }).catch((e:BusinessError) => { - console.error(`taskpool: execute: Code: ${e.code}, message: ${e.message}`); - }) - // [StartExclude update_message_on_success] - this.message = 'success'; - // [EndExclude update_message_on_success] - }) - } - .height('100%') - .width('100%') - } -} -// [End concurrent_taskpool_custom_class_function] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// 并发函数中使用自定义类或函数 +// 并发函数中使用自定义类或函数时需定义在不同文件,否则会被认为是闭包,如下例所示。 +// [Start concurrent_taskpool_custom_class_function] +import { taskpool } from '@kit.ArkTS'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { testAdd, MyTestA, MyTestB } from './Test'; + +function add(arg: number) { + return ++arg; +} + +class TestA { + constructor(name: string) { + this.name = name; + } + name: string = 'ClassA'; +} + +class TestB { + static nameStr: string = 'ClassB'; +} + +@Concurrent +function testFunc() { + // case1:在并发函数中直接调用同文件内定义的类或函数 + + // 直接调用同文件定义的函数add(),add飘红报错: + // Only imported variables and local variables can be used in @Concurrent decorated functions. + // add(1); + // 直接使用同文件定义的TestA构造,TestA飘红报错: + // Only imported variables and local variables can be used in @Concurrent decorated functions. + // let a = new TestA('aaa'); + // 直接访问同文件定义的TestB的成员nameStr,TestB飘红报错: + // Only imported variables and local variables can be used in @Concurrent decorated functions. + // console.info('TestB name is: ' + TestB.nameStr); + + // case2:在并发函数中调用定义在Test.ets文件并导入当前文件的类或函数 + + // 输出结果:res1 is: 2 + console.info('res1 is: ' + testAdd(1)); + let tmpStr = new MyTestA('TEST A'); + // 输出结果:res2 is: TEST A + console.info('res2 is: ' + tmpStr.name); + // 输出结果:res3 is: MyTestB + console.info('res3 is: ' + MyTestB.nameStr); +} + + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + let task = new taskpool.Task(testFunc); + taskpool.execute(task).then(() => { + console.info('taskpool: execute task success!'); + }).catch((e:BusinessError) => { + console.error(`taskpool: execute: Code: ${e.code}, message: ${e.message}`); + }) + // [StartExclude update_message_on_success] + this.message = 'success'; + // [EndExclude update_message_on_success] + }) + } + .height('100%') + .width('100%') + } +} +// [End concurrent_taskpool_custom_class_function] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/generaluse.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/generaluse.ets old mode 100755 new mode 100644 index 8eaeb92949..4d293c8748 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/generaluse.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/generaluse.ets @@ -1,58 +1,58 @@ -/* - * 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. - */ - -// 并发函数一般使用 -// 并发函数为一个计算两数之和的普通函数,taskpool执行该函数并返回结果。 -// [Start concurrent_taskpool_common_usage] -import { taskpool } from '@kit.ArkTS'; - -@Concurrent -function add(num1: number, num2: number): number { - return num1 + num2; -} - -async function concurrentFunc(): Promise { - try { - let task: taskpool.Task = new taskpool.Task(add, 1, 2); - console.info('taskpool res is: ' + await taskpool.execute(task)); - } catch (e) { - console.error('taskpool execute error is: ' + e); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - concurrentFunc(); - // [StartExclude update_message_on_success] - this.message = 'success'; - // [EndExclude update_message_on_success] - }) - } - .width('100%') - } - .height('100%') - } -} -// [End concurrent_taskpool_common_usage] +/* + * 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. + */ + +// 并发函数一般使用 +// 并发函数为一个计算两数之和的普通函数,taskpool执行该函数并返回结果。 +// [Start concurrent_taskpool_common_usage] +import { taskpool } from '@kit.ArkTS'; + +@Concurrent +function add(num1: number, num2: number): number { + return num1 + num2; +} + +async function concurrentFunc(): Promise { + try { + let task: taskpool.Task = new taskpool.Task(add, 1, 2); + console.info('taskpool res is: ' + await taskpool.execute(task)); + } catch (e) { + console.error('taskpool execute error is: ' + e); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + concurrentFunc(); + // [StartExclude update_message_on_success] + this.message = 'success'; + // [EndExclude update_message_on_success] + }) + } + .width('100%') + } + .height('100%') + } +} +// [End concurrent_taskpool_common_usage] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/returnpromise.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/returnpromise.ets old mode 100755 new mode 100644 index df1443fc33..7ea74e162d --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/returnpromise.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/returnpromise.ets @@ -1,124 +1,124 @@ -/* - * 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. - */ - -// 并发函数返回Promise -// 并发函数中返回Promise的表现需关注,其中并发同步函数会处理返回该Promise并返回结果,如下例所示。 -// [Start concurrent_taskpool_promise_return] -import { taskpool } from '@kit.ArkTS'; - -@Concurrent -function testPromise(args1: number, args2: number): Promise { - return new Promise((testFuncA, testFuncB) => { - testFuncA(args1 + args2); - }); -} - -@Concurrent -async function testPromise1(args1: number, args2: number): Promise { - return new Promise((testFuncA, testFuncB) => { - testFuncA(args1 + args2); - }); -} - -@Concurrent -async function testPromise2(args1: number, args2: number): Promise { - return await new Promise((testFuncA, testFuncB) => { - testFuncA(args1 + args2); - }); -} - -@Concurrent -function testPromise3() { - return Promise.resolve(1); -} - -@Concurrent -async function testPromise4(): Promise { - return 1; -} - -@Concurrent -async function testPromise5(): Promise { - return await new Promise((resolve) => { - setTimeout(() => { - resolve('Promise setTimeout after resolve'); - }, 1000) - }); -} - -async function testConcurrentFunc() { - let task1: taskpool.Task = new taskpool.Task(testPromise, 1, 2); - let task2: taskpool.Task = new taskpool.Task(testPromise1, 1, 2); - let task3: taskpool.Task = new taskpool.Task(testPromise2, 1, 2); - let task4: taskpool.Task = new taskpool.Task(testPromise3); - let task5: taskpool.Task = new taskpool.Task(testPromise4); - let task6: taskpool.Task = new taskpool.Task(testPromise5); - - taskpool.execute(task1).then((d: object) => { - console.info('task1 res is: ' + d); - }).catch((e: object) => { - console.info('task1 catch e: ' + e); - }) - taskpool.execute(task2).then((d: object) => { - console.info('task2 res is: ' + d); - }).catch((e: object) => { - console.info('task2 catch e: ' + e); - }) - taskpool.execute(task3).then((d: object) => { - console.info('task3 res is: ' + d); - }).catch((e: object) => { - console.info('task3 catch e: ' + e); - }) - taskpool.execute(task4).then((d: object) => { - console.info('task4 res is: ' + d); - }).catch((e: object) => { - console.info('task4 catch e: ' + e); - }) - taskpool.execute(task5).then((d: object) => { - console.info('task5 res is: ' + d); - }).catch((e: object) => { - console.info('task5 catch e: ' + e); - }) - taskpool.execute(task6).then((d: object) => { - console.info('task6 res is: ' + d); - }).catch((e: object) => { - console.info('task6 catch e: ' + e); - }) -} - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Button(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - testConcurrentFunc(); - // [StartExclude update_message_on_success] - this.message = 'success'; - // [EndExclude update_message_on_success] - }) - } - .width('100%') - } - .height('100%') - } -} -// [End concurrent_taskpool_promise_return] +/* + * 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. + */ + +// 并发函数返回Promise +// 并发函数中返回Promise的表现需关注,其中并发同步函数会处理返回该Promise并返回结果,如下例所示。 +// [Start concurrent_taskpool_promise_return] +import { taskpool } from '@kit.ArkTS'; + +@Concurrent +function testPromise(args1: number, args2: number): Promise { + return new Promise((testFuncA, testFuncB) => { + testFuncA(args1 + args2); + }); +} + +@Concurrent +async function testPromise1(args1: number, args2: number): Promise { + return new Promise((testFuncA, testFuncB) => { + testFuncA(args1 + args2); + }); +} + +@Concurrent +async function testPromise2(args1: number, args2: number): Promise { + return await new Promise((testFuncA, testFuncB) => { + testFuncA(args1 + args2); + }); +} + +@Concurrent +function testPromise3() { + return Promise.resolve(1); +} + +@Concurrent +async function testPromise4(): Promise { + return 1; +} + +@Concurrent +async function testPromise5(): Promise { + return await new Promise((resolve) => { + setTimeout(() => { + resolve('Promise setTimeout after resolve'); + }, 1000) + }); +} + +async function testConcurrentFunc() { + let task1: taskpool.Task = new taskpool.Task(testPromise, 1, 2); + let task2: taskpool.Task = new taskpool.Task(testPromise1, 1, 2); + let task3: taskpool.Task = new taskpool.Task(testPromise2, 1, 2); + let task4: taskpool.Task = new taskpool.Task(testPromise3); + let task5: taskpool.Task = new taskpool.Task(testPromise4); + let task6: taskpool.Task = new taskpool.Task(testPromise5); + + taskpool.execute(task1).then((d: object) => { + console.info('task1 res is: ' + d); + }).catch((e: object) => { + console.info('task1 catch e: ' + e); + }) + taskpool.execute(task2).then((d: object) => { + console.info('task2 res is: ' + d); + }).catch((e: object) => { + console.info('task2 catch e: ' + e); + }) + taskpool.execute(task3).then((d: object) => { + console.info('task3 res is: ' + d); + }).catch((e: object) => { + console.info('task3 catch e: ' + e); + }) + taskpool.execute(task4).then((d: object) => { + console.info('task4 res is: ' + d); + }).catch((e: object) => { + console.info('task4 catch e: ' + e); + }) + taskpool.execute(task5).then((d: object) => { + console.info('task5 res is: ' + d); + }).catch((e: object) => { + console.info('task5 catch e: ' + e); + }) + taskpool.execute(task6).then((d: object) => { + console.info('task6 res is: ' + d); + }).catch((e: object) => { + console.info('task6 catch e: ' + e); + }) +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Button(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + testConcurrentFunc(); + // [StartExclude update_message_on_success] + this.message = 'success'; + // [EndExclude update_message_on_success] + }) + } + .width('100%') + } + .height('100%') + } +} +// [End concurrent_taskpool_promise_return] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/util/resource.ets old mode 100755 new mode 100644 index 6f34fb425d..40f1ea99bf --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/util/resource.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/util/resource.ets @@ -1,27 +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. - */ - -// [StartExclude p2p_manager_resource] -export class P2PManager { - public resourceToString(resource: Resource):string { - return getContext(this).resourceManager.getStringSync(resource); - } -} - -// 默认导出let -let p2pManager = new P2PManager(); - -export default p2pManager as P2PManager; -// [EndExclude p2p_manager_resource] +/* + * 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. + */ + +// [StartExclude p2p_manager_resource] +export class P2PManager { + public resourceToString(resource: Resource):string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + +export default p2pManager as P2PManager; +// [EndExclude p2p_manager_resource] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/ohosTest.md old mode 100755 new mode 100644 index 69c9a1c1b6..006d184890 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/ohosTest.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/ohosTest.md @@ -1,11 +1,11 @@ -# TaskPoolIntroduction 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------- | ----------------------------- | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 并发函数一般使用 | 位于generaluse.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 并发函数返回Promise | 位于returnpromise.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 并发函数中使用自定义类或函数 | 位于customclasses.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +# TaskPoolIntroduction 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------- | ----------------------------- | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 并发函数一般使用 | 位于generaluse.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 并发函数返回Promise | 位于returnpromise.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 并发函数中使用自定义类或函数 | 位于customclasses.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | | 并发异步函数中使用Promise | 位于asynchronousfunctions.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/screenshots/TaskPoolIntroduction_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/screenshots/TaskPoolIntroduction_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/screenshots/TaskPoolIntroduction_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/screenshots/TaskPoolIntroduction_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/app.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/app.json5 old mode 100755 new mode 100644 index e4e34e86f3..889e27c848 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/app.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/app.json5 @@ -1,25 +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.workerIntroduction", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.workerIntroduction", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index b440180aef..c79ba2d1da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "WorkerIntroduction" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "WorkerIntroduction" + } + ] +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/README.md b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/README.md old mode 100755 new mode 100644 index 88a673e8cb..96a3046faf --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/README.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/README.md @@ -1,86 +1,86 @@ -# ArkTS Worker简介 - -### 介绍 - -Worker主要作用是为应用程序提供一个多线程的运行环境,可满足应用程序在执行过程中与宿主线程分离,在后台线程中运行一个脚本进行耗时操作,极大避免类似于计算密集型或高延迟的任务阻塞宿主线程的运行。具体接口信息及使用方法详情请见[Worker](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-worker.md)。 - -该工程中展示的代码详细描述可查如下链接: - -- [Worker简介](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/worker-introduction.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── managers - │ │ ├── basicusage.ets // Worker基本用法示例 - │ │ ├── crosshar.ets // 跨har包加载Worker - │ │ ├── notrecommendedone.ets // 不推荐使用示例1 - │ │ ├── notrecommendedtwo.ets // 不推荐使用示例2 - │ │ ├── recommend.ets // 推荐使用示例 - │ │ ├── notrecommendedoneworker - │ │ ├── childworker.ets // 不推荐使用示例1 - │ │ ├── parentworker.ets // 不推荐使用示例1 - │ │ ├── notrecommendedtwoworker - │ │ ├── childworker.ets // 不推荐使用示例2 - │ │ ├── parentworker.ets // 不推荐使用示例2 - │ │ ├── pages - │ │ ├── Index.ets // 首页 - │ │ ├── recommendworkers - │ │ ├── childworker.ets // 推荐使用示例 - │ │ ├── parentworker.ets // 推荐使用示例 - │ │ ├── util - │ │ ├── CommonButton.ets // 首页跳转UI - │ │ ├── resource.ets // 资源引用转换 - │ │ ├── workers - │ │ ├── worker.ets // Worker基本用法示例 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# ArkTS Worker简介 + +### 介绍 + +Worker主要作用是为应用程序提供一个多线程的运行环境,可满足应用程序在执行过程中与宿主线程分离,在后台线程中运行一个脚本进行耗时操作,极大避免类似于计算密集型或高延迟的任务阻塞宿主线程的运行。具体接口信息及使用方法详情请见[Worker](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-arkts/js-apis-worker.md)。 + +该工程中展示的代码详细描述可查如下链接: + +- [Worker简介](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/worker-introduction.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------: | :----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── managers + │ │ ├── basicusage.ets // Worker基本用法示例 + │ │ ├── crosshar.ets // 跨har包加载Worker + │ │ ├── notrecommendedone.ets // 不推荐使用示例1 + │ │ ├── notrecommendedtwo.ets // 不推荐使用示例2 + │ │ ├── recommend.ets // 推荐使用示例 + │ │ ├── notrecommendedoneworker + │ │ ├── childworker.ets // 不推荐使用示例1 + │ │ ├── parentworker.ets // 不推荐使用示例1 + │ │ ├── notrecommendedtwoworker + │ │ ├── childworker.ets // 不推荐使用示例2 + │ │ ├── parentworker.ets // 不推荐使用示例2 + │ │ ├── pages + │ │ ├── Index.ets // 首页 + │ │ ├── recommendworkers + │ │ ├── childworker.ets // 推荐使用示例 + │ │ ├── parentworker.ets // 推荐使用示例 + │ │ ├── util + │ │ ├── CommonButton.ets // 首页跳转UI + │ │ ├── resource.ets // 资源引用转换 + │ │ ├── workers + │ │ ├── worker.ets // Worker基本用法示例 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction > .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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/build-profile.json5 old mode 100755 new mode 100644 index fcdcb832b7..505aa8efb9 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/build-profile.json5 @@ -1,62 +1,62 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "har", - "srcPath": "./har", - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "har", + "srcPath": "./har", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/code-linter.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/build-profile.json5 old mode 100755 new mode 100644 index 4d9432aa4f..e5ef097c7e --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/build-profile.json5 @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "apiType": "stageMode", - // [Start manual_create_worker] - "buildOption": { - "sourceOption": { - "workers": [ - "./src/main/ets/recommendworkers/parentworker.ets", - "./src/main/ets/recommendworkers/childworker.ets", - "./src/main/ets/notrecommendedoneworker/parentworker.ets", - "./src/main/ets/notrecommendedoneworker/childworker.ets", - "./src/main/ets/notrecommendedtwoworker/parentworker.ets", - "./src/main/ets/notrecommendedtwoworker/childworker.ets", - './src/main/ets/workers/worker.ets' - ] - } - }, - // [End manual_create_worker] - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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", + // [Start manual_create_worker] + "buildOption": { + "sourceOption": { + "workers": [ + "./src/main/ets/recommendworkers/parentworker.ets", + "./src/main/ets/recommendworkers/childworker.ets", + "./src/main/ets/notrecommendedoneworker/parentworker.ets", + "./src/main/ets/notrecommendedoneworker/childworker.ets", + "./src/main/ets/notrecommendedtwoworker/parentworker.ets", + "./src/main/ets/notrecommendedtwoworker/childworker.ets", + './src/main/ets/workers/worker.ets' + ] + } + }, + // [End manual_create_worker] + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/oh-package.json5 old mode 100755 new mode 100644 index 9a2f7b5dfd..c13df0e926 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/oh-package.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start config_har_dependency] -{ - "name": "entry", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "har": "file:../har" - } -} -// [End config_har_dependency] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start config_har_dependency] +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "har": "file:../har" + } +} +// [End config_har_dependency] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/basicusage.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/basicusage.ets old mode 100755 new mode 100644 index 9d98b565c2..cd58974766 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/basicusage.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/basicusage.ets @@ -1,69 +1,69 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// {Start create_worker_object_register_callback_function] -import { ErrorEvent, MessageEvents, worker } from '@kit.ArkTS'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - // 创建Worker对象 - let workerInstance = new worker.ThreadWorker('entry/ets/workers/worker.ets'); - - // 注册onmessage回调,当宿主线程接收到来自其创建的Worker通过workerPort.postMessage接口发送的消息时被调用,在宿主线程执行 - workerInstance.onmessage = (e: MessageEvents) => { - let data: string = e.data; - console.info('workerInstance onmessage is: ', data); - } - - // 注册onerror回调,当Worker在执行过程中发生异常时被调用,在宿主线程执行 - workerInstance.onerror = (err: ErrorEvent) => { - console.info('workerInstance onerror message is: ' + err.message); - } - - // 注册onmessageerror回调,当Worker对象接收到一条无法被序列化的消息时被调用,在宿主线程执行 - workerInstance.onmessageerror = () => { - console.info('workerInstance onmessageerror'); - } - - // 注册onexit回调,当Worker销毁时被调用,在宿主线程执行 - workerInstance.onexit = (e: number) => { - // 当Worker正常退出时code为0,异常退出时code为1 - console.info('workerInstance onexit code is: ', e); - } - - // 向Worker线程发送消息 - workerInstance.postMessage('1'); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// {End create_worker_object_register_callback_function] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// {Start create_worker_object_register_callback_function] +import { ErrorEvent, MessageEvents, worker } from '@kit.ArkTS'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + // 创建Worker对象 + let workerInstance = new worker.ThreadWorker('entry/ets/workers/worker.ets'); + + // 注册onmessage回调,当宿主线程接收到来自其创建的Worker通过workerPort.postMessage接口发送的消息时被调用,在宿主线程执行 + workerInstance.onmessage = (e: MessageEvents) => { + let data: string = e.data; + console.info('workerInstance onmessage is: ', data); + } + + // 注册onerror回调,当Worker在执行过程中发生异常时被调用,在宿主线程执行 + workerInstance.onerror = (err: ErrorEvent) => { + console.info('workerInstance onerror message is: ' + err.message); + } + + // 注册onmessageerror回调,当Worker对象接收到一条无法被序列化的消息时被调用,在宿主线程执行 + workerInstance.onmessageerror = () => { + console.info('workerInstance onmessageerror'); + } + + // 注册onexit回调,当Worker销毁时被调用,在宿主线程执行 + workerInstance.onexit = (e: number) => { + // 当Worker正常退出时code为0,异常退出时code为1 + console.info('workerInstance onexit code is: ', e); + } + + // 向Worker线程发送消息 + workerInstance.postMessage('1'); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// {End create_worker_object_register_callback_function] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/crosshar.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/crosshar.ets old mode 100755 new mode 100644 index 0283114af2..1756627224 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/crosshar.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/crosshar.ets @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start load_har_worker] -import { worker } from '@kit.ArkTS'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - // 通过@标识路径加载形式,加载har中Worker线程文件 - let workerInstance = new worker.ThreadWorker('@har/ets/workers/worker.ets'); - workerInstance.onmessage = () => { - console.info('main thread onmessage'); - }; - workerInstance.postMessage('hello world'); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End load_har_worker] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start load_har_worker] +import { worker } from '@kit.ArkTS'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + // 通过@标识路径加载形式,加载har中Worker线程文件 + let workerInstance = new worker.ThreadWorker('@har/ets/workers/worker.ets'); + workerInstance.onmessage = () => { + console.info('main thread onmessage'); + }; + workerInstance.postMessage('hello world'); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End load_har_worker] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/notrecommendedone.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/notrecommendedone.ets old mode 100755 new mode 100644 index 2135ba6313..3a52ca6216 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/notrecommendedone.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/notrecommendedone.ets @@ -1,59 +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. - */ - -// [Start not_recommended_example] -import resource from '../util/resource'; -import { worker, MessageEvents, ErrorEvent } from '@kit.ArkTS'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - // 主线程中创建父worker对象 - const parentworker = new worker.ThreadWorker('entry/ets/notrecommendedoneworker/parentworker.ets'); - - parentworker.onmessage = (e: MessageEvents) => { - console.info(resource.resourceToString($r('app.string.Not_recommended1')) + e.data); - } - - parentworker.onexit = () => { - console.info(resource.resourceToString($r('app.string.Not_recommended2'))); - } - - parentworker.onerror = (err: ErrorEvent) => { - console.info(resource.resourceToString($r('app.string.Not_recommended3')) + err); - } - - parentworker.postMessage(resource.resourceToString($r('app.string.Not_recommended4'))); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End not_recommended_example] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start not_recommended_example] +import resource from '../util/resource'; +import { worker, MessageEvents, ErrorEvent } from '@kit.ArkTS'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + // 主线程中创建父worker对象 + const parentworker = new worker.ThreadWorker('entry/ets/notrecommendedoneworker/parentworker.ets'); + + parentworker.onmessage = (e: MessageEvents) => { + console.info(resource.resourceToString($r('app.string.Not_recommended1')) + e.data); + } + + parentworker.onexit = () => { + console.info(resource.resourceToString($r('app.string.Not_recommended2'))); + } + + parentworker.onerror = (err: ErrorEvent) => { + console.info(resource.resourceToString($r('app.string.Not_recommended3')) + err); + } + + parentworker.postMessage(resource.resourceToString($r('app.string.Not_recommended4'))); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End not_recommended_example] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/notrecommendedtwo.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/notrecommendedtwo.ets old mode 100755 new mode 100644 index 80c99d81e3..06c3b06789 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/notrecommendedtwo.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/notrecommendedtwo.ets @@ -1,59 +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. - */ - -// [Start not_recommended_example] -import resource from '../util/resource'; -import { worker, MessageEvents, ErrorEvent } from '@kit.ArkTS'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - // 主线程中创建父worker对象 - const parentworker = new worker.ThreadWorker('entry/ets/notrecommendedtwoworker/parentworker.ets'); - - parentworker.onmessage = (e: MessageEvents) => { - console.info(resource.resourceToString($r('app.string.Not_recommended1')) + e.data); - } - - parentworker.onexit = () => { - console.info(resource.resourceToString($r('app.string.Not_recommended2'))); - } - - parentworker.onerror = (err: ErrorEvent) => { - console.info(resource.resourceToString($r('app.string.Not_recommended3')) + err); - } - - parentworker.postMessage(resource.resourceToString($r('app.string.Not_recommended4'))); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End not_recommended_example] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start not_recommended_example] +import resource from '../util/resource'; +import { worker, MessageEvents, ErrorEvent } from '@kit.ArkTS'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + // 主线程中创建父worker对象 + const parentworker = new worker.ThreadWorker('entry/ets/notrecommendedtwoworker/parentworker.ets'); + + parentworker.onmessage = (e: MessageEvents) => { + console.info(resource.resourceToString($r('app.string.Not_recommended1')) + e.data); + } + + parentworker.onexit = () => { + console.info(resource.resourceToString($r('app.string.Not_recommended2'))); + } + + parentworker.onerror = (err: ErrorEvent) => { + console.info(resource.resourceToString($r('app.string.Not_recommended3')) + err); + } + + parentworker.postMessage(resource.resourceToString($r('app.string.Not_recommended4'))); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End not_recommended_example] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/recommend.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/recommend.ets old mode 100755 new mode 100644 index 0266902ba5..57ae48a862 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/recommend.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/managers/recommend.ets @@ -1,59 +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. - */ - -// [Start recommended_example] -import resource from '../util/resource'; -import { worker, MessageEvents, ErrorEvent } from '@kit.ArkTS'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - RelativeContainer() { - Text(this.message) - .id('HelloWorld') - .fontSize(50) - .fontWeight(FontWeight.Bold) - .alignRules({ - center: { anchor: '__container__', align: VerticalAlign.Center }, - middle: { anchor: '__container__', align: HorizontalAlign.Center } - }) - .onClick(() => { - // 主线程中创建父worker对象 - const parentworker = new worker.ThreadWorker('entry/ets/recommendworkers/parentworker.ets'); - - parentworker.onmessage = (e: MessageEvents) => { - console.info(resource.resourceToString($r('app.string.recommend1')) + e.data); - } - - parentworker.onexit = () => { - console.info(resource.resourceToString($r('app.string.recommend2'))); - } - - parentworker.onerror = (err: ErrorEvent) => { - console.info(resource.resourceToString($r('app.string.recommend3')) + err); - } - - parentworker.postMessage(resource.resourceToString($r('app.string.recommend4'))); - this.message = 'success'; - }) - } - .height('100%') - .width('100%') - } -} -// [End recommended_example] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start recommended_example] +import resource from '../util/resource'; +import { worker, MessageEvents, ErrorEvent } from '@kit.ArkTS'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + // 主线程中创建父worker对象 + const parentworker = new worker.ThreadWorker('entry/ets/recommendworkers/parentworker.ets'); + + parentworker.onmessage = (e: MessageEvents) => { + console.info(resource.resourceToString($r('app.string.recommend1')) + e.data); + } + + parentworker.onexit = () => { + console.info(resource.resourceToString($r('app.string.recommend2'))); + } + + parentworker.onerror = (err: ErrorEvent) => { + console.info(resource.resourceToString($r('app.string.recommend3')) + err); + } + + parentworker.postMessage(resource.resourceToString($r('app.string.recommend4'))); + this.message = 'success'; + }) + } + .height('100%') + .width('100%') + } +} +// [End recommended_example] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedoneworker/childworker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedoneworker/childworker.ets old mode 100755 new mode 100644 index aaa52b70d5..a79e899790 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedoneworker/childworker.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedoneworker/childworker.ets @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start not_recommended_example] -import resource from '../util/resource'; -import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; - -const workerPort: ThreadWorkerGlobalScope = worker.workerPort; - -workerPort.onmessage = (e: MessageEvents) => { - console.info(resource.resourceToString($r('app.string.Not_one_childworker_worker1')) + e.data); - - // 父Worker销毁后,子Worker向父Worker发送信息,行为不可预期 - workerPort.postMessage(resource.resourceToString($r('app.string.Not_one_childworker_worker2'))); - setTimeout(() => { - workerPort.postMessage(resource.resourceToString($r('app.string.Not_one_childworker_worker2'))); - }, 1000); -} -// [End not_recommended_example] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start not_recommended_example] +import resource from '../util/resource'; +import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; + +const workerPort: ThreadWorkerGlobalScope = worker.workerPort; + +workerPort.onmessage = (e: MessageEvents) => { + console.info(resource.resourceToString($r('app.string.Not_one_childworker_worker1')) + e.data); + + // 父Worker销毁后,子Worker向父Worker发送信息,行为不可预期 + workerPort.postMessage(resource.resourceToString($r('app.string.Not_one_childworker_worker2'))); + setTimeout(() => { + workerPort.postMessage(resource.resourceToString($r('app.string.Not_one_childworker_worker2'))); + }, 1000); +} +// [End not_recommended_example] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedoneworker/parentworker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedoneworker/parentworker.ets old mode 100755 new mode 100644 index 61bbf3fc3c..5403dbc76d --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedoneworker/parentworker.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedoneworker/parentworker.ets @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start not_recommended_example] -import resource from '../util/resource'; -import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; - -const workerPort: ThreadWorkerGlobalScope = worker.workerPort; - -workerPort.onmessage = (e: MessageEvents) => { - console.info(resource.resourceToString($r('app.string.Not_one_parentworker_worker1')) + e.data); - - let childworker = new worker.ThreadWorker('entry/ets/workers/childworker.ets'); - - childworker.onmessage = (e: MessageEvents) => { - console.info(resource.resourceToString($r('app.string.Not_one_parentworker_worker2')) + e.data); - } - - childworker.onexit = () => { - console.info(resource.resourceToString($r('app.string.Not_one_parentworker_worker3'))); - workerPort.postMessage(resource.resourceToString($r('app.string.Not_one_parentworker_worker4'))); - } - - childworker.onerror = (err: ErrorEvent) => { - console.info(resource.resourceToString($r('app.string.Not_one_parentworker_worker5')) + err); - } - - childworker.postMessage(resource.resourceToString($r('app.string.Not_one_parentworker_worker6'))); - - // 创建子Worker后,销毁父Worker - workerPort.close(); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start not_recommended_example] +import resource from '../util/resource'; +import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; + +const workerPort: ThreadWorkerGlobalScope = worker.workerPort; + +workerPort.onmessage = (e: MessageEvents) => { + console.info(resource.resourceToString($r('app.string.Not_one_parentworker_worker1')) + e.data); + + let childworker = new worker.ThreadWorker('entry/ets/workers/childworker.ets'); + + childworker.onmessage = (e: MessageEvents) => { + console.info(resource.resourceToString($r('app.string.Not_one_parentworker_worker2')) + e.data); + } + + childworker.onexit = () => { + console.info(resource.resourceToString($r('app.string.Not_one_parentworker_worker3'))); + workerPort.postMessage(resource.resourceToString($r('app.string.Not_one_parentworker_worker4'))); + } + + childworker.onerror = (err: ErrorEvent) => { + console.info(resource.resourceToString($r('app.string.Not_one_parentworker_worker5')) + err); + } + + childworker.postMessage(resource.resourceToString($r('app.string.Not_one_parentworker_worker6'))); + + // 创建子Worker后,销毁父Worker + workerPort.close(); +} // [End not_recommended_example] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedtwoworker/childworker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedtwoworker/childworker.ets old mode 100755 new mode 100644 index 991e2a67b0..ebdea6679f --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedtwoworker/childworker.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedtwoworker/childworker.ets @@ -1,25 +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. - */ - -// [Start not_recommended_example] -import resource from '../util/resource'; -import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; - -const workerPort: ThreadWorkerGlobalScope = worker.workerPort; - -workerPort.onmessage = (e: MessageEvents) => { - console.info(resource.resourceToString($r('app.string.Not_two_childworker_worker')) + e.data); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start not_recommended_example] +import resource from '../util/resource'; +import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; + +const workerPort: ThreadWorkerGlobalScope = worker.workerPort; + +workerPort.onmessage = (e: MessageEvents) => { + console.info(resource.resourceToString($r('app.string.Not_two_childworker_worker')) + e.data); +} // [End not_recommended_example] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedtwoworker/parentworker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedtwoworker/parentworker.ets old mode 100755 new mode 100644 index 24e94626b8..25419ef119 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedtwoworker/parentworker.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/notrecommendedtwoworker/parentworker.ets @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start not_recommended_example] -import resource from '../util/resource'; -import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; - -const workerPort: ThreadWorkerGlobalScope = worker.workerPort; - -workerPort.onmessage = (e: MessageEvents) => { - console.info(resource.resourceToString($r('app.string.Not_two_parentworker_worker1')) + e.data); - - // 父Worker销毁后创建子Worker,行为不可预期 - workerPort.close(); - let childworker = new worker.ThreadWorker('entry/ets/notrecommendedtwoworker/childworker.ets'); - - // 子Worker线程未确认创建成功前销毁父Worker,行为不可预期 - // let childworker = new worker.ThreadWorker('entry/ets/workers/childworker.ets'); - // workerPort.close(); - - childworker.onmessage = (e: MessageEvents) => { - console.info(resource.resourceToString($r('app.string.Not_two_parentworker_worker2')) + e.data); - } - - childworker.onexit = () => { - console.info(resource.resourceToString($r('app.string.Not_two_parentworker_worker3'))); - workerPort.postMessage(resource.resourceToString($r('app.string.Not_two_parentworker_worker4'))); - } - - childworker.onerror = (err: ErrorEvent) => { - console.info(resource.resourceToString($r('app.string.Not_two_parentworker_worker5')) + err); - } - - childworker.postMessage(resource.resourceToString($r('app.string.Not_two_parentworker_worker6'))); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start not_recommended_example] +import resource from '../util/resource'; +import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; + +const workerPort: ThreadWorkerGlobalScope = worker.workerPort; + +workerPort.onmessage = (e: MessageEvents) => { + console.info(resource.resourceToString($r('app.string.Not_two_parentworker_worker1')) + e.data); + + // 父Worker销毁后创建子Worker,行为不可预期 + workerPort.close(); + let childworker = new worker.ThreadWorker('entry/ets/notrecommendedtwoworker/childworker.ets'); + + // 子Worker线程未确认创建成功前销毁父Worker,行为不可预期 + // let childworker = new worker.ThreadWorker('entry/ets/workers/childworker.ets'); + // workerPort.close(); + + childworker.onmessage = (e: MessageEvents) => { + console.info(resource.resourceToString($r('app.string.Not_two_parentworker_worker2')) + e.data); + } + + childworker.onexit = () => { + console.info(resource.resourceToString($r('app.string.Not_two_parentworker_worker3'))); + workerPort.postMessage(resource.resourceToString($r('app.string.Not_two_parentworker_worker4'))); + } + + childworker.onerror = (err: ErrorEvent) => { + console.info(resource.resourceToString($r('app.string.Not_two_parentworker_worker5')) + err); + } + + childworker.postMessage(resource.resourceToString($r('app.string.Not_two_parentworker_worker6'))); +} // [End not_recommended_example] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/recommendworkers/childworker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/recommendworkers/childworker.ets old mode 100755 new mode 100644 index fb2424b61d..8e14b97d6c --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/recommendworkers/childworker.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/recommendworkers/childworker.ets @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start recommended_example] -import resource from '../util/resource'; -import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; - -// 创建子Worker线程中与父Worker线程通信的对象 -const workerPort: ThreadWorkerGlobalScope = worker.workerPort; - -workerPort.onmessage = (e: MessageEvents) => { - if (e.data == resource.resourceToString($r('app.string.Recommend_child_worker1'))) { - // 子Worker线程业务逻辑... - console.info(resource.resourceToString($r('app.string.Recommend_child_worker2'))); - workerPort.close(); - } -} -// [End recommended_example] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start recommended_example] +import resource from '../util/resource'; +import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; + +// 创建子Worker线程中与父Worker线程通信的对象 +const workerPort: ThreadWorkerGlobalScope = worker.workerPort; + +workerPort.onmessage = (e: MessageEvents) => { + if (e.data == resource.resourceToString($r('app.string.Recommend_child_worker1'))) { + // 子Worker线程业务逻辑... + console.info(resource.resourceToString($r('app.string.Recommend_child_worker2'))); + workerPort.close(); + } +} +// [End recommended_example] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/recommendworkers/parentworker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/recommendworkers/parentworker.ets old mode 100755 new mode 100644 index 90bebf6519..f4b7f8a480 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/recommendworkers/parentworker.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/recommendworkers/parentworker.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start recommended_example] -import resource from '../util/resource'; -import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; - -// 创建父Worker线程中与主线程通信的对象 -const workerPort: ThreadWorkerGlobalScope = worker.workerPort; - -workerPort.onmessage = (e: MessageEvents) => { - if (e.data == resource.resourceToString($r('app.string.Recommend_parentworker_worker1'))) { - let childworker = new worker.ThreadWorker('entry/ets/recommendworkers/childworker.ets'); - - childworker.onmessage = (e: MessageEvents) => { - console.info(resource.resourceToString($r('app.string.Recommend_parentworker_worker2')) + e.data); - if (e.data == resource.resourceToString($r('app.string.Recommend_parentworker_worker3'))) { - workerPort.postMessage(resource.resourceToString($r('app.string.Recommend_parentworker_worker4'))); - } - } - - childworker.onexit = () => { - console.info(resource.resourceToString($r('app.string.Recommend_parentworker_worker5'))); - // 子Worker退出后再销毁父Worker - workerPort.close(); - } - - childworker.onerror = (err: ErrorEvent) => { - console.info(resource.resourceToString($r('app.string.Recommend_parentworker_worker6')) + err); - } - - childworker.postMessage(resource.resourceToString($r('app.string.Recommend_parentworker_worker7'))); - } -} -// [End recommended_example] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start recommended_example] +import resource from '../util/resource'; +import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; + +// 创建父Worker线程中与主线程通信的对象 +const workerPort: ThreadWorkerGlobalScope = worker.workerPort; + +workerPort.onmessage = (e: MessageEvents) => { + if (e.data == resource.resourceToString($r('app.string.Recommend_parentworker_worker1'))) { + let childworker = new worker.ThreadWorker('entry/ets/recommendworkers/childworker.ets'); + + childworker.onmessage = (e: MessageEvents) => { + console.info(resource.resourceToString($r('app.string.Recommend_parentworker_worker2')) + e.data); + if (e.data == resource.resourceToString($r('app.string.Recommend_parentworker_worker3'))) { + workerPort.postMessage(resource.resourceToString($r('app.string.Recommend_parentworker_worker4'))); + } + } + + childworker.onexit = () => { + console.info(resource.resourceToString($r('app.string.Recommend_parentworker_worker5'))); + // 子Worker退出后再销毁父Worker + workerPort.close(); + } + + childworker.onerror = (err: ErrorEvent) => { + console.info(resource.resourceToString($r('app.string.Recommend_parentworker_worker6')) + err); + } + + childworker.postMessage(resource.resourceToString($r('app.string.Recommend_parentworker_worker7'))); + } +} +// [End recommended_example] diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/util/CommonButton.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/util/CommonButton.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/util/resource.ets old mode 100755 new mode 100644 index 79a04af93b..a0f1755b8c --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/util/resource.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/util/resource.ets @@ -1,25 +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. - */ - -export class P2PManager { - public resourceToString(resource: Resource):string { - return getContext(this).resourceManager.getStringSync(resource); - } -} - -// 默认导出let -let p2pManager = new P2PManager(); - +/* + * 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 class P2PManager { + public resourceToString(resource: Resource):string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/workers/worker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/ets/workers/worker.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/.gitignore b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/BuildProfile.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/BuildProfile.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/Index.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/Index.ets old mode 100755 new mode 100644 index 0c4e469d33..e5366a9d16 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/Index.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/Index.ets @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { MainPage } from './src/main/ets/components/MainPage'; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/build-profile.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/build-profile.json5 old mode 100755 new mode 100644 index 9681515781..39a0c7e7c2 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/build-profile.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/build-profile.json5 @@ -1,51 +1,51 @@ -/* - * 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": { - "sourceOption": { - "workers": [ - './src/main/ets/workers/worker.ets' - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - }, - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] +/* + * 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": { + "sourceOption": { + "workers": [ + './src/main/ets/workers/worker.ets' + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/consumer-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/consumer-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/obfuscation-rules.txt b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/oh-package.json5 old mode 100755 new mode 100644 index 08c9c66275..15ebac7026 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "name": "har", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - "dependencies": {} -} +/* + * 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": "har", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/ets/components/MainPage.ets old mode 100755 new mode 100644 index 1243a59406..7dc1a0d257 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/ets/components/MainPage.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/ets/components/MainPage.ets @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MainPage { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/ets/workers/worker.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/ets/workers/worker.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/module.json5 old mode 100755 new mode 100644 index 7e826fa368..08e47d7196 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/module.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "har", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} +/* + * 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": "har", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 6469ce25bb..fdb1caba1f --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "har_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "har_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/test/List.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/har/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/hvigorfile.ts b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/oh-package.json5 b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/oh-package.json5 +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/ohosTest.md b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/ohosTest.md old mode 100755 new mode 100644 index a5f3ba2d40..bca2a5aa47 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/ohosTest.md +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/ohosTest.md @@ -1,12 +1,12 @@ -# WorkerIntroduction 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------ | ------------------------- | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| Worker基本用法示例 | 位于basicusage.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 跨har包加载Worker | 位于crosshar.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 推荐使用示例 | 位于recommend.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 不推荐使用示例1 | 位于notrecommendedone.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +# WorkerIntroduction 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------ | ------------------------- | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| Worker基本用法示例 | 位于basicusage.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 跨har包加载Worker | 位于crosshar.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 推荐使用示例 | 位于recommend.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 不推荐使用示例1 | 位于notrecommendedone.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | | 不推荐使用示例2 | 位于notrecommendedtwo.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/screenshots/WorkerIntroduction_1.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/screenshots/WorkerIntroduction_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/screenshots/WorkerIntroduction_2.png b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/WorkerIntroduction/screenshots/WorkerIntroduction_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/AppScope/app.json5 new file mode 100644 index 0000000000..703f9ed9ba --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/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.jsvmdebug", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..f9ac3bc9d5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmDebug" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/README.md new file mode 100644 index 0000000000..192afb1732 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/README.md @@ -0,0 +1,138 @@ +# ArkTS JSVM-API典型使用场景指导 + +### 介绍 + +使用JSVM-API实现跨语言交互,首先需要按照JSVM-API的机制实现模块的注册和加载等相关动作。 + +- ArkTS/JS侧:实现C++方法的调用。代码比较简单,import一个对应的so库后,即可调用C++方法。 +- Native侧:.cpp文件,实现模块的注册。需要提供注册lib库的名称,并在注册回调方法中定义接口的映射关系,即Native方法及对应的JS/ArkTS接口名称等。 + +该工程中展示的代码详细描述可查如下链接: + +- [JSVM-API调试&定位](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/jsvm-debugger-cpuprofiler-heapsnapshot.md) +- [使用 code cache 加速编译](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-code-cache.md) +- [使用JSVM-API接口创建多个引擎执行JS代码并销毁](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-runtime-task.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :-----------------------------------------------------------: | :-----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +aboutcodecache/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +openinspector/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +snapshot/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +runtimetask/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmDebug > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/.gitignore diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/build-profile.json5 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/build-profile.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/build-profile.json5 diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/obfuscation-rules.txt rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/oh-package.json5 new file mode 100644 index 0000000000..a1d266f456 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/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": "aboutcodecache", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libaboutcodecache.so": "file:./src/main/cpp/types/libaboutcodecache" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..cc20c12512 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmDebug) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(aboutcodecache SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(aboutcodecache PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..6cb5634570 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/hello.cpp @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start jsvm_code_cache] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +#include +// [StartExclude jsvm_code_cache] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude jsvm_code_cache] + +JSVM_Value UseCodeCache(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 编译参数准备 + JSVM_Value jsSrc; + JSVM_Script script; + JSVM_Value result; + size_t length = 0; + const uint8_t* dataPtr = nullptr; + bool cacheRejected = true; + static std::string src = R"JS( + a = 65536; + b = 32768; + c = a + b; + )JS"; + + // 生成 code cache + { + JSVM_HandleScope handleScope; + OH_JSVM_OpenHandleScope(env, &handleScope); + + // 源码字符串转换为 js 字符串 + OH_JSVM_CreateStringUtf8(env, src.c_str(), src.size(), &jsSrc); + + // 编译js代码 + OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script); + + // 执行js代码 + OH_JSVM_RunScript(env, script, &result); + int value = 0; + OH_JSVM_GetValueInt32(env, result, &value); + OH_LOG_INFO(LOG_APP, "first run result: %{public}d\n", value); + + if (dataPtr == nullptr) { + // 将js源码编译出的脚本保存到 cache, 可以避免重复编译, 带来性能提升 + OH_JSVM_CreateCodeCache(env, script, &dataPtr, &length); + } + + OH_JSVM_CloseHandleScope(env, handleScope); + } + + // 使用 code cache + { + JSVM_HandleScope handleScope; + OH_JSVM_OpenHandleScope(env, &handleScope); + + // 源码字符串转换为 js 字符串 + OH_JSVM_CreateStringUtf8(env, src.c_str(), src.size(), &jsSrc); + + // 使用 code cache 编译js代码 + OH_JSVM_CompileScript(env, jsSrc, dataPtr, length, true, &cacheRejected, &script); + + // 执行js代码 + OH_JSVM_RunScript(env, script, &result); + int value = 0; + OH_JSVM_GetValueInt32(env, result, &value); + OH_LOG_INFO(LOG_APP, "second run result: %{public}d\n", value); + + OH_JSVM_CloseHandleScope(env, handleScope); + } + OH_LOG_INFO(LOG_APP, "cache rejected: %{public}d\n", cacheRejected); + return result; +} + +// Register a callback. +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = UseCodeCache} +}; +static JSVM_CallbackStruct *method = param; +// Register the C++ callback as a JSVM globalThis.UseCodeCache property for the JS to call. +static JSVM_PropertyDescriptor descriptor[] = { + {"UseCodeCache", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// [End jsvm_code_cache] + +// 样例测试JS +const char *SRC_CALL_NATIVE = R"JS(UseCodeCache();)JS"; + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "aboutcodecache", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/Index.d.ts similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/Index.d.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/Index.d.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/oh-package.json5 new file mode 100644 index 0000000000..864f45f378 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/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": "libaboutcodecache.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/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/aboutcodecacheability/AboutcodecacheAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/aboutcodecacheability/AboutcodecacheAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/aboutcodecacheability/AboutcodecacheAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/aboutcodecacheability/AboutcodecacheAbility.ets index 980a321581..6cd7641edc --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/aboutcodecacheability/AboutcodecacheAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/aboutcodecacheability/AboutcodecacheAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class AboutcodecacheAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class AboutcodecacheAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..51ba8ce977 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libaboutcodecache.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/module.json5 new file mode 100644 index 0000000000..6e64e7c3a2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "aboutcodecache", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "AboutcodecacheAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "AboutcodecacheAbility", + "srcEntry": "./ets/aboutcodecacheability/AboutcodecacheAbility.ets", + "description": "$string:AboutcodecacheAbility_desc", + "icon": "$media:layered_image", + "label": "$string:AboutcodecacheAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/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/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..7466d16a61 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "AboutcodecacheAbility_desc", + "value": "description" + }, + { + "name": "AboutcodecacheAbility_label", + "value": "JsvmDebug" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..51e57c0df4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testcodecache', 0, async (done: Function) => { + console.log('uitest: Testcodecache begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'AboutcodecacheAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('AboutcodecacheAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: Testcodecache end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/module.json5 new file mode 100644 index 0000000000..435ff848b6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "aboutcodecache_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/build-profile.json5 new file mode 100644 index 0000000000..565c3bc4d0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/build-profile.json5 @@ -0,0 +1,94 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "openinspector", + "srcPath": "./openinspector", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "snapshot", + "srcPath": "./snapshot", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "aboutcodecache", + "srcPath": "./aboutcodecache", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "runtimetask", + "srcPath": "./runtimetask", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..47b1a9ebd0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/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.1", + "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*/ + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/hvigorfile.ts new file mode 100644 index 0000000000..acb5922f46 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/hvigorfile.ts @@ -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. + */ + +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/ArkTS/JSVMAPI/JsvmDebug/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/ohosTest.md new file mode 100644 index 0000000000..5a1b7ca5d2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/ohosTest.md @@ -0,0 +1,11 @@ +# JsvmDebug 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 在指定的主机和端口上激活inspector,将用来调试JS代码 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取当前堆快照并将其输出到流 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 使用 code cache 加速编译 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| JSVM-API接口创建多个引擎执行JS代码并销毁 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/obfuscation-rules.txt rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/oh-package.json5 new file mode 100644 index 0000000000..d92ed452ae --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/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": "openinspector", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libopeninspector.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..fafdfa0936 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmDebug) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(openinspector SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(openinspector PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..665b23ced4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_open_inspector] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" +#include +// [StartExclude oh_jsvm_open_inspector] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_open_inspector] + +// 待调试的JS源码 +static std::string g_srcDebugger = R"JS( +const concat = (...args) => args.reduce((a, b) => a + b); +var dialogue = concat('"What ', 'is ', 'your ', 'name ', '?"'); +dialogue = concat(dialogue, ' --', '"My ', 'name ', 'is ', 'Bob ', '."'); +)JS"; + +// 开启debugger +static const int INSPECTOR_PORT = 9225; +static void EnableInspector(JSVM_Env env) +{ + // 在指定的主机和端口上激活inspector,创建socket。 + OH_JSVM_OpenInspector(env, "localhost", INSPECTOR_PORT); + // 等待建立socket连接。 + OH_JSVM_WaitForDebugger(env, true); +} + +// 关闭debugger +static void CloseInspector(JSVM_Env env) +{ + // 关闭inspector,结束socket连接。 + OH_JSVM_CloseInspector(env); +} + +static void RunScript(JSVM_Env env) +{ + JSVM_HandleScope handleScope; + OH_JSVM_OpenHandleScope(env, &handleScope); + + JSVM_Value jsSrc; + OH_JSVM_CreateStringUtf8(env, g_srcDebugger.c_str(), g_srcDebugger.size(), &jsSrc); + + JSVM_Script script; + OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script); + + JSVM_Value result; + OH_JSVM_RunScript(env, script, &result); + + OH_JSVM_CloseHandleScope(env, handleScope); +} + +void TestJSVM() +{ + JSVM_InitOptions initOptions{}; + OH_JSVM_Init(&initOptions); + + JSVM_VM vm; + OH_JSVM_CreateVM(nullptr, &vm); + JSVM_VMScope vmScope; + OH_JSVM_OpenVMScope(vm, &vmScope); + + JSVM_Env env; + OH_JSVM_CreateEnv(vm, 0, nullptr, &env); + // 执行JS代码之前打开debugger。 + EnableInspector(env); + JSVM_EnvScope envScope; + OH_JSVM_OpenEnvScope(env, &envScope); + + // 执行JS代码。 + RunScript(env); + + OH_JSVM_CloseEnvScope(env, envScope); + // 执行JS代码之后关闭debugger。 + CloseInspector(env); + OH_JSVM_DestroyEnv(env); + OH_JSVM_CloseVMScope(vm, vmScope); + OH_JSVM_DestroyVM(vm); +} +// [End jsvm_open_inspector] + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "openinspector", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/Index.d.ts similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/Index.d.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/Index.d.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..8547e3a114 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/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": "libopeninspector.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/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/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/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..a3c889cdea --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libopeninspector.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/module.json5 new file mode 100644 index 0000000000..71598eafd4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/module.json5 @@ -0,0 +1,78 @@ +/* + * 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": "openinspector", + "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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET", + "reason": "$string:app_name", + "usedScene": { + "abilities": [ + "FromAbility" + ], + "when": "inuse" + } + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/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/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..e093041b1b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/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": "JsvmDebug" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..7cea7ff3d3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testOpenInspector', 0, async (done: Function) => { + console.log('uitest: TestOpenInspector begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestOpenInspector end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/module.json5 new file mode 100644 index 0000000000..d709d9cb6a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "openinspector_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/obfuscation-rules.txt rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/oh-package.json5 new file mode 100644 index 0000000000..52c578358c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/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": "runtimetask", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libruntimetask.so": "file:./src/main/cpp/types/libruntimetask" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..196f881cee --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmDebug) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(runtimetask SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(runtimetask PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..4cb6a95e0d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/hello.cpp @@ -0,0 +1,425 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +// [Start runtime_task] +#include +#include +#include +using namespace std; +// 定义map管理每个独立vm环境 +static map g_vmMap; +static map g_envMap; +static map g_callBackStructMap; +static uint32_t g_envtagNumber = 0; +static std::mutex g_envMapLock; +// [StartExclude runtime_task] + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude runtime_task] + +#define CHECK_COND(cond) \ + do { \ + if (!(cond)) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = false", __FILE__, __LINE__); \ + return -1; \ + } \ + } while (0) + +class Task { +public: + virtual ~Task() = default; + virtual void Run() = 0; +}; +static map> g_taskQueueMap; + +// 自定义Consoleinfo方法 +static JSVM_Value Consoleinfo(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1]; + #define MAX_LOG_LENGTH 255 + char log[MAX_LOG_LENGTH + 1] = ""; + size_t logLength; + JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, NULL, NULL)); + + JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, args[0], log, MAX_LOG_LENGTH, &logLength)); + log[MAX_LOG_LENGTH] = 0; + OH_LOG_INFO(LOG_APP, "JSVM API TEST: %{public}s", log); + return nullptr; +} + +// 自定义创建Promise方法用以在JS代码中创建Promise +static JSVM_Value CreatePromise(JSVM_Env env, JSVM_CallbackInfo info) +{ + OH_LOG_INFO(LOG_APP, "JSVM API TEST: CreatePromise start"); + int envID = -1; + // 通过当前env获取envID + for (auto it = g_envMap.begin(); it != g_envMap.end(); ++it) { + if (*it->second == env) { + envID = it->first; + break; + } + } + if (envID == -1) { + OH_LOG_ERROR(LOG_APP, "JSVM API TEST: CreatePromise envID failed"); + return nullptr; + } + JSVM_Value promise; + JSVM_Deferred deferred; + JSVM_CALL(OH_JSVM_CreatePromise(env, &deferred, &promise)); + // 设计ReadTask类用以将promise对象的deferred加入执行队列 + class ReadTask : public Task { + public: + ReadTask(JSVM_Env env, JSVM_Deferred deferred, int envNum) : env_(env), envID_(envNum), deferred_(deferred) {} + void Run() override + { + // string str = "TEST RUN OH_JSVM_ResolveDeferred"; + int envID = 0; + for (auto it = g_envMap.begin(); it != g_envMap.end(); ++it) { + if (*it->second == env_) { + envID = it->first; + break; + } + } + OH_LOG_INFO(LOG_APP, "JSVM API TEST: CreatePromise %{public}d", envID); + JSVM_Value result; + if (OH_JSVM_CreateInt32(env_, envID, &result) != JSVM_OK) { + return; + } + if (OH_JSVM_ResolveDeferred(env_, deferred_, result) != JSVM_OK) { + return; + } + } + + private: + JSVM_Env env_; + int envID_; + JSVM_Deferred deferred_; + }; + g_taskQueueMap[envID].push_back(new ReadTask(env, deferred, envID)); + OH_LOG_INFO(LOG_APP, "JSVM API TEST: CreatePromise end"); + return promise; +} + +// 自定义Add方法 +static JSVM_Value Add(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 2; + JSVM_Value args[2]; + JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, NULL, NULL)); + double num1; + double num2; + JSVM_CALL(OH_JSVM_GetValueDouble(env, args[0], &num1)); + JSVM_CALL(OH_JSVM_GetValueDouble(env, args[1], &num2)); + JSVM_Value sum = nullptr; + JSVM_CALL(OH_JSVM_CreateDouble(env, num1 + num2, &sum)); + return sum; +} + +// 自定义AssertEqual方法 +static JSVM_Value AssertEqual(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 2; + JSVM_Value args[2]; + JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, NULL, NULL)); + + bool isStrictEquals = false; + JSVM_CALL(OH_JSVM_StrictEquals(env, args[0], args[1], &isStrictEquals)); + + if (isStrictEquals) { + OH_LOG_INFO(LOG_APP, "JSVM API TEST RESULT: PASS"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM API TEST RESULT: FAILED"); + } + return nullptr; +} + +static int fromOHStringValue(JSVM_Env &env, JSVM_Value &value, std::string &result) +{ + size_t size; + CHECK_RET(OH_JSVM_GetValueStringUtf8(env, value, nullptr, 0, &size)); + char resultStr[size + 1]; + CHECK_RET(OH_JSVM_GetValueStringUtf8(env, value, resultStr, size + 1, &size)); + result = resultStr; + return 0; +} + +// 提供创建JSVM运行环境的对外接口并返回对应唯一ID +static int CreateJsCore(uint32_t *result) +{ + OH_LOG_INFO(LOG_APP, "JSVM CreateJsCore START"); + g_taskQueueMap[g_envtagNumber] = deque {}; + + if (g_aa == 0) { + JSVM_InitOptions init_options; + memset(&init_options, 0, sizeof(init_options)); + CHECK(OH_JSVM_Init(&init_options)); + g_aa++; + } + std::lock_guard lock_guard(g_envMapLock); + + // 虚拟机实例 + g_vmMap[g_envtagNumber] = new JSVM_VM; + JSVM_CreateVMOptions options; + JSVM_VMScope vmScope; + memset(&options, 0, sizeof(options)); + CHECK(OH_JSVM_CreateVM(&options, g_vmMap[g_envtagNumber])); + CHECK(OH_JSVM_OpenVMScope(*g_vmMap[g_envtagNumber], &vmScope)); + + // 新环境 + g_envMap[g_envtagNumber] = new JSVM_Env; + g_callBackStructMap[g_envtagNumber] = new JSVM_CallbackStruct[4]; + + // 注册用户提供的本地函数的回调函数指针和数据,通过JSVM-API暴露给js + constexpr int kLoopCount = 4; + for (int i = 0; i < kLoopCount; i++) { + g_callBackStructMap[g_envtagNumber][i].data = nullptr; + } + g_callBackStructMap[g_envtagNumber][0].callback = Consoleinfo; + g_callBackStructMap[g_envtagNumber][1].callback = Add; + g_callBackStructMap[g_envtagNumber][2].callback = AssertEqual; + g_callBackStructMap[g_envtagNumber][3].callback = CreatePromise; + JSVM_PropertyDescriptor descriptors[] = { + { "consoleinfo", NULL, &g_callBackStructMap[g_envtagNumber][0], NULL, NULL, NULL, JSVM_DEFAULT }, + { "add", NULL, &g_callBackStructMap[g_envtagNumber][1], NULL, NULL, NULL, JSVM_DEFAULT }, + { "assertEqual", NULL, &g_callBackStructMap[g_envtagNumber][2], NULL, NULL, NULL, JSVM_DEFAULT }, + { "createPromise", NULL, &g_callBackStructMap[g_envtagNumber][3], NULL, NULL, NULL, JSVM_DEFAULT }, + }; + CHECK(OH_JSVM_CreateEnv( + *g_vmMap[g_envtagNumber], sizeof(descriptors) / sizeof(descriptors[0]), descriptors, g_envMap[g_envtagNumber])); + CHECK(OH_JSVM_CloseVMScope(*g_vmMap[g_envtagNumber], vmScope)); + + OH_LOG_INFO(LOG_APP, "JSVM CreateJsCore END"); + *result = g_envtagNumber; + g_envtagNumber++; + return 0; +} + +// 对外提供释放JSVM环境接口,通过envId释放对应环境 +static int ReleaseJsCore(uint32_t coreEnvId) +{ + OH_LOG_INFO(LOG_APP, "JSVM ReleaseJsCore START"); + CHECK_COND(g_envMap.count(coreEnvId) != 0 && g_envMap[coreEnvId] != nullptr); + + std::lock_guard lock_guard(g_envMapLock); + + CHECK(OH_JSVM_DestroyEnv(*g_envMap[coreEnvId])); + g_envMap[coreEnvId] = nullptr; + g_envMap.erase(coreEnvId); + CHECK(OH_JSVM_DestroyVM(*g_vmMap[coreEnvId])); + g_vmMap[coreEnvId] = nullptr; + g_vmMap.erase(coreEnvId); + delete[] g_callBackStructMap[coreEnvId]; + g_callBackStructMap[coreEnvId] = nullptr; + g_callBackStructMap.erase(coreEnvId); + g_taskQueueMap.erase(coreEnvId); + + OH_LOG_INFO(LOG_APP, "JSVM ReleaseJsCore END"); + return 0; +} + +static std::mutex g_mutexLock; +// 对外提供执行JS代码接口,通过coreID在对应的JSVN环境中执行JS代码 +static int EvaluateJS(uint32_t envId, const char *source, std::string &res) +{ + OH_LOG_INFO(LOG_APP, "JSVM EvaluateJS START"); + + CHECK_COND(g_envMap.count(envId) != 0 && g_envMap[envId] != nullptr); + + JSVM_Env env = *g_envMap[envId]; + JSVM_VM vm = *g_vmMap[envId]; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + + std::lock_guard lock_guard(g_mutexLock); + { + // 创建JSVM环境 + CHECK_RET(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(*g_envMap[envId], &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(*g_envMap[envId], &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, source, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + JSVM_ValueType type; + CHECK_RET(OH_JSVM_Typeof(env, result, &type)); + OH_LOG_INFO(LOG_APP, "JSVM API TEST type: %{public}d", type); + // Execute tasks in the current env event queue + while (!g_taskQueueMap[envId].empty()) { + auto task = g_taskQueueMap[envId].front(); + g_taskQueueMap[envId].pop_front(); + task->Run(); + delete task; + } + + if (type == JSVM_STRING) { + CHECK_COND(fromOHStringValue(env, result, res) != -1); + } else if (type == JSVM_BOOLEAN) { + bool ret = false; + CHECK_RET(OH_JSVM_GetValueBool(env, result, &ret)); + ret ? res = "true" : res = "false"; + } else if (type == JSVM_NUMBER) { + int32_t num; + CHECK_RET(OH_JSVM_GetValueInt32(env, result, &num)); + res = std::to_string(num); + } else if (type == JSVM_OBJECT) { + JSVM_Value objResult; + CHECK_RET(OH_JSVM_JsonStringify(env, result, &objResult)); + CHECK_COND(fromOHStringValue(env, objResult, res) != -1); + } + } + { + bool aal = false; + CHECK_RET(OH_JSVM_PumpMessageLoop(*g_vmMap[envId], &aal)); + CHECK_RET(OH_JSVM_PerformMicrotaskCheckpoint(*g_vmMap[envId])); + CHECK_RET(OH_JSVM_CloseHandleScope(*g_envMap[envId], handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(*g_envMap[envId], envScope)); + CHECK_RET(OH_JSVM_CloseVMScope(*g_vmMap[envId], vmScope)); + } + OH_LOG_INFO(LOG_APP, "JSVM EvaluateJS END"); + return 0; +} + +static int32_t TestJSVM() +{ + const char source1[] = "{\ + let a = \"hello World\";\ + consoleinfo(a);\ + const mPromise = createPromise();\ + mPromise.then((result) => {\ + assertEqual(result, 0);\ + });\ + a;\ + };"; + + const char source2[] = "{\ + let a = \"second hello\";\ + consoleinfo(a);\ + let b = add(99, 1);\ + assertEqual(100, b);\ + assertEqual(add(99, 1), 100);\ + createPromise().then((result) => {\ + assertEqual(result, 1);\ + });\ + a;\ + };"; + + // 创建首个运行环境,并绑定TS回调 + uint32_t coreId1; + CHECK_COND(CreateJsCore(&coreId1) == 0); + OH_LOG_INFO(LOG_APP, "TEST coreId: %{public}d", coreId1); + // 在首个运行环境中执行JS代码 + std::string result1; + CHECK_COND(EvaluateJS(coreId1, source1, result1) == 0); + OH_LOG_INFO(LOG_APP, "TEST evaluateJS: %{public}s", result1.c_str()); + + // 创建第二个运行环境,并绑定TS回调 + uint32_t coreId2; + CHECK_COND(CreateJsCore(&coreId2) == 0); + OH_LOG_INFO(LOG_APP, "TEST coreId: %{public}d", coreId2); + // 在第二个运行环境中执行JS代码 + std::string result2; + CHECK_COND(EvaluateJS(coreId2, source2, result2) == 0); + OH_LOG_INFO(LOG_APP, "TEST evaluateJS: %{public}s", result2.c_str()); + + // 释放首个运行环境 + CHECK_COND(ReleaseJsCore(coreId1) == 0); + // 释放第二个运行环境 + CHECK_COND(ReleaseJsCore(coreId2) == 0); + OH_LOG_INFO(LOG_APP, "Test NAPI end"); + + return 0; +} +// [End runtime_task] + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "runtimetask", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/oh-package.json5 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/oh-package.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/types/libruntimetask/oh-package.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..18d41e69dc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libruntimetask.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/runtimetaskability/RuntimetaskAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/runtimetaskability/RuntimetaskAbility.ets similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/runtimetaskability/RuntimetaskAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/runtimetaskability/RuntimetaskAbility.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/module.json5 new file mode 100644 index 0000000000..e0917b7889 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/module.json5 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "runtimetask", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "RuntimetaskAbility", + "deviceTypes": [ + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "RuntimetaskAbility", + "srcEntry": "./ets/runtimetaskability/RuntimetaskAbility.ets", + "description": "$string:RuntimetaskAbility_desc", + "icon": "$media:layered_image", + "label": "$string:RuntimetaskAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/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/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/float.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/float.json similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/float.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/float.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/module.json5 new file mode 100644 index 0000000000..99fd7b9e81 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/module.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. + */ + +{ + "module": { + "name": "runtimetask_test", + "type": "feature", + "deviceTypes": [ + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/screenshots/JsvmDebug_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/screenshots/JsvmDebug_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/screenshots/JsvmDebug_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/screenshots/JsvmDebug_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/screenshots/JsvmDebug_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/screenshots/JsvmDebug_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/screenshots/JsvmDebug_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/screenshots/JsvmDebug_2.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/hvigorfile.ts new file mode 100644 index 0000000000..bbb00a28e0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/obfuscation-rules.txt rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/oh-package.json5 new file mode 100644 index 0000000000..dee921dd01 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/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": "snapshot", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libsnapshot.so": "file:./src/main/cpp/types/libsnapshot" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6730c6ce01 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmDebug) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(snapshot SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(snapshot PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..afa8fdaf11 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/hello.cpp @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start heap_snapshot] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" +#include +// [StartExclude heap_snapshot] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude heap_snapshot] + +using namespace std; + +// 待调优的JS代码。 +static string g_srcProf = R"JS( +function sleep(delay) { + var start = (new Date()).getTime(); + while ((new Date()).getTime() - start < delay) { + continue; + } +} + +function work3() { + sleep(300); +} + +function work2() { + work3(); + sleep(200); +} + +function work1() { + work2(); + sleep(100); +} + +work1(); +)JS"; + +// 数据输出流回调,用户自定义,处理返回的调优数据,此处以写入文件为例。 +static bool OutputStream(const char *data, int size, void *streamData) +{ + auto &os = *reinterpret_cast(streamData); + if (data) { + os.write(data, size); + } else { + os.close(); + } + return true; +} + +static JSVM_CpuProfiler ProfilingBegin(JSVM_VM vm) +{ + // 文件输出流,保存调优数据,/data/storage/el2/base/files为沙箱路径。以包名为com.example.helloworld为例。 + // 实际文件会保存到/data/app/el2/100/base/com.example.helloworld/files/heap-snapshot-begin.heapsnapshot。 + ofstream heapSnapshot("/data/storage/el2/base/files/heap-snapshot-begin.heapsnapshot", + ios::out | ios::binary | ios::trunc); + // 执行JS前获取一次Heap Snapshot数据。 + OH_JSVM_TakeHeapSnapshot(vm, OutputStream, &heapSnapshot); + JSVM_CpuProfiler cpuProfiler; + // 开启CPU Profiler。 + OH_JSVM_StartCpuProfiler(vm, &cpuProfiler); + return cpuProfiler; +} + +// 关闭调优数据采集工具 +static void ProfilingEnd(JSVM_VM vm, JSVM_CpuProfiler cpuProfiler) +{ + // 文件输出流,保存调优数据,/data/storage/el2/base/files为沙箱路径。以包名为com.example.helloworld为例。 + // 实际文件会保存到/data/app/el2/100/base/com.example.helloworld/files/cpu-profile.cpuprofile。 + ofstream cpuProfile("/data/storage/el2/base/files/cpu-profile.cpuprofile", + ios::out | ios::binary | ios::trunc); + // 关闭CPU Profiler,获取数据。 + OH_JSVM_StopCpuProfiler(vm, cpuProfiler, OutputStream, &cpuProfile); + ofstream heapSnapshot("/data/storage/el2/base/files/heap-snapshot-end.heapsnapshot", + ios::out | ios::binary | ios::trunc); + // 执行JS后再获取一次Heap Snapshot数据,与执行前数据作对比,以分析内存问题或者进行内存调优。 + OH_JSVM_TakeHeapSnapshot(vm, OutputStream, &heapSnapshot); +} + +static JSVM_Value RunScriptWithStatistics(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_VM vm; + OH_JSVM_GetVM(env, &vm); + + // 开始调优。 + auto cpuProfiler = ProfilingBegin(vm); + + JSVM_HandleScope handleScope; + OH_JSVM_OpenHandleScope(env, &handleScope); + + JSVM_Value jsSrc; + OH_JSVM_CreateStringUtf8(env, g_srcProf.c_str(), g_srcProf.size(), &jsSrc); + + JSVM_Script script; + OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script); + + JSVM_Value result; + // 执行JS代码。 + OH_JSVM_RunScript(env, script, &result); + + OH_JSVM_CloseHandleScope(env, handleScope); + + // 结束调优。 + ProfilingEnd(vm, cpuProfiler); + return nullptr; +} +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = RunScriptWithStatistics}, +}; +static JSVM_CallbackStruct *method = param; +// runScriptWithStatistics方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"runScriptWithStatistics", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +const char *SRC_CALL_NATIVE = R"JS(runScriptWithStatistics();)JS"; + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} +// [End heap_snapshot] + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "snapshot", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/oh-package.json5 new file mode 100644 index 0000000000..16c3808c95 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/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": "libsnapshot.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/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..c4b31cda95 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libsnapshot.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/ets/snapshotability/SnapshotAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/ets/snapshotability/SnapshotAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/ets/snapshotability/SnapshotAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/ets/snapshotability/SnapshotAbility.ets index e11c5aafc0..1c4217cc16 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/ets/snapshotability/SnapshotAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/ets/snapshotability/SnapshotAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class SnapshotAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class SnapshotAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/module.json5 new file mode 100644 index 0000000000..0c4cda92ed --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "snapshot", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "SnapshotAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "SnapshotAbility", + "srcEntry": "./ets/snapshotability/SnapshotAbility.ets", + "description": "$string:SnapshotAbility_desc", + "icon": "$media:layered_image", + "label": "$string:SnapshotAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/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/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..ac0d6697ee --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "SnapshotAbility_desc", + "value": "description" + }, + { + "name": "SnapshotAbility_label", + "value": "JsvmDebug" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..9f1801beec --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testSnapshot', 0, async (done: Function) => { + console.log('uitest: TestSnapshot begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'SnapshotAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('SnapshotAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestSnapshot end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/module.json5 new file mode 100644 index 0000000000..2c8526b385 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "snapshot_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/AppScope/app.json5 new file mode 100644 index 0000000000..c70654c811 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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.jsvmprocess", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..6c4c265d8c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmProcess" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/README.md new file mode 100644 index 0000000000..8398ee3c91 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/README.md @@ -0,0 +1,76 @@ +# ArkTS使用JSVM-API实现JS与C/C++语言交互开发流程 + +### 介绍 + +使用JSVM-API实现跨语言交互,首先需要按照JSVM-API的机制实现模块的注册和加载等相关动作。 + +- ArkTS/JS侧:实现C++方法的调用。代码比较简单,import一个对应的so库后,即可调用C++方法。 +- Native侧:.cpp文件,实现模块的注册。需要提供注册lib库的名称,并在注册回调方法中定义接口的映射关系,即Native方法及对应的JS/ArkTS接口名称等。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API实现JS与C/C++语言交互开发流程](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-process.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :-------------------------------------------------------------: | :-------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击hello world,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 使用JSVM-API实现JS与C/C++语言交互开发流程示例代码 + │ │ │ │ ├── oh-package.json5 // 使用JSVM-API实现JS与C/C++语言交互开发流程示例代码 + │ │ ├── CMakeLists.txt // 使用JSVM-API实现JS与C/C++语言交互开发流程示例代码 + │ │ ├── hello.cpp // 使用JSVM-API实现JS与C/C++语言交互开发流程示例代码 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用JSVM-API实现JS与C/C++语言交互开发流程示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmProcess > .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/ArkTS/JSVMAPI/JsvmProcess/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/build-profile.json5 new file mode 100644 index 0000000000..dfff3e654a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/code-linter.json5 diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/build-profile.json5 new file mode 100644 index 0000000000..fea31f4580 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/build-profile.json5 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["arm64-v8a", "x86_64"] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/obfuscation-rules.txt rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..27bd6f5841 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(entry SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(entry PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..c0031cf180 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/hello.cpp @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_process] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// OH_JSVM_StrictEquals的样例方法 +static JSVM_Value IsStrictEquals(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 接受两个入参 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr)); + // 调用OH_JSVM_StrictEquals接口判断给定的两个JavaScript value是否严格相等 + bool result = false; + JSVM_Status status = OH_JSVM_StrictEquals(env, args[0], args[1], &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_StrictEquals: failed"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_StrictEquals: success: %{public}d", result); + } + JSVM_Value isStrictEqual; + JSVM_CALL(OH_JSVM_GetBoolean(env, result, &isStrictEqual)); + return isStrictEqual; +} +// IsStrictEquals注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = IsStrictEquals}, +}; +static JSVM_CallbackStruct *method = param; +// IsStrictEquals方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"isStrictEquals", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( let data = '123'; + let value = 123; + isStrictEquals(data, value);)JS"; + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +// [End oh_jsvm_process] diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..15f72a84a7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start export_native] +export const runTest: () => void; +// [End export_native] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..280db53c57 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start call_native_cpp] +import napitest from 'libentry.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} +// [End call_native_cpp] diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..8002e233e6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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": "JsvmProcess" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000..8002e233e6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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": "JsvmProcess" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000..52d5186346 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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": "JsvmProcess" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..8564892624 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testJsvmProcess', 0, async (done: Function) => { + console.log('uitest: TestJsvmProcess begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestJsvmProcess end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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.1", + "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/ohosTest.md new file mode 100644 index 0000000000..679da07e5c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/ohosTest.md @@ -0,0 +1,8 @@ +# JsvmProcess 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 使用JSVM-API实现JS与C/C++语言交互开发流程 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/screenshots/JsvmProcess_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/screenshots/JsvmProcess_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/screenshots/JsvmProcess_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/screenshots/JsvmProcess_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/screenshots/JsvmProcess_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/screenshots/JsvmProcess_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/screenshots/JsvmProcess_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmProcess/screenshots/JsvmProcess_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/app.json5 new file mode 100644 index 0000000000..e4a86a1d71 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/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.jsvmaboutarray", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..fc7ee24f91 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmAboutArray" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/README.md new file mode 100644 index 0000000000..0c45183983 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/README.md @@ -0,0 +1,333 @@ +# ArkTS使用JSVM-API接口进行array相关开发 + +### 介绍 + +使用 JSVM-API 接口进行数组(array)相关开发时,调用相关接口可以在 JSVM 模块中直接操作和处理 JavaScript 中的数组。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口进行array相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-array.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------------: | :----------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +createarray/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createarraywithlength/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createdataview/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createtypedarray/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +deleteelement/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getarraylength/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getdataviewinfo/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getelement/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +gettypedarrayinfo/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +haselement/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +isarray/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +isdataview/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +istypedarray/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +setelement/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/build-profile.json5 new file mode 100644 index 0000000000..d76069bbe0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/build-profile.json5 @@ -0,0 +1,214 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "createarray", + "srcPath": "./createarray", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createarraywithlength", + "srcPath": "./createarraywithlength", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createtypedarray", + "srcPath": "./createtypedarray", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createdataview", + "srcPath": "./createdataview", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getarraylength", + "srcPath": "./getarraylength", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getdataviewinfo", + "srcPath": "./getdataviewinfo", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "deleteelement", + "srcPath": "./deleteelement", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getelement", + "srcPath": "./getelement", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "gettypedarrayinfo", + "srcPath": "./gettypedarrayinfo", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "haselement", + "srcPath": "./haselement", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "isarray", + "srcPath": "./isarray", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "isdataview", + "srcPath": "./isdataview", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "istypedarray", + "srcPath": "./istypedarray", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "setelement", + "srcPath": "./setelement", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/code-linter.json5 diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/.gitignore similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/obfuscation-rules.txt rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/oh-package.json5 new file mode 100644 index 0000000000..ecbf3d7359 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/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": "createarray", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatearray.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..71ffbe12ac --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createarray SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createarray PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..bc034ea8e0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/hello.cpp @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_array] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_create_array] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_array] + +// CreateArray注册回调 +static int g_diffValueFive = 5; +// OH_JSVM_CreateArray的样例方法 +static JSVM_Value CreateArray(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 创建一个空数组 + JSVM_Value array = nullptr; + JSVM_Status status = OH_JSVM_CreateArray(env, &array); + // 对创建的数组进行赋值 + for (int i = 0; i < g_diffValueFive; i++) { + JSVM_Value element; + OH_JSVM_CreateInt32(env, i, &element); + OH_JSVM_SetElement(env, array, i, element); + } + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateArray fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateArray success"); + } + return array; +} +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateArray}, +}; +static JSVM_CallbackStruct *method = param; +// CreateArray方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createArray", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + function testCreateArray() { + return createArray(); + } + testCreateArray(); +)JS"; +// [End oh_jsvm_create_array] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createarray", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..9c1310bc79 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/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": "libcreatearray.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..1ad949a727 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatearray.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/module.json5 new file mode 100644 index 0000000000..d3596cb1a4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/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": "createarray", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..cab53b2b24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/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": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/main_pages.json similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..16d656e846 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateArray', 0, async (done: Function) => { + console.log('uitest: TestCreateArray begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateArray end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/module.json5 new file mode 100644 index 0000000000..011ac94ef8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createarray_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/obfuscation-rules.txt old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/obfuscation-rules.txt rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/oh-package.json5 new file mode 100644 index 0000000000..10bc7b2060 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/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": "createarraywithlength", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatearraywithlength.so": "file:./src/main/cpp/types/libcreatearraywithlength" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..e6511b9265 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createarraywithlength SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createarraywithlength PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..f28007a213 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/hello.cpp @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_array_with_length] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_create_array_with_length] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_array_with_length] + +// OH_JSVM_CreateArrayWithLength的样例方法 +static JSVM_Value CreateArrayWithLength(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + JSVM_Value result = nullptr; + // 解析传递的参数OH_JSVM_GetCbInfo + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + // 获取传递的数组长度 + int32_t length; + OH_JSVM_GetValueInt32(env, argv[0], &length); + // 使用OH_JSVM_CreateArrayWithLength创建传递固定长度的数组 + JSVM_Status status = OH_JSVM_CreateArrayWithLength(env, length, &result); + if (status == JSVM_OK) { + // 给创建的数组设置值 + for (int32_t i = 0; i < length; i++) { + JSVM_Value value; + OH_JSVM_CreateInt32(env, i, &value); + OH_JSVM_SetElement(env, result, i, value); + } + OH_LOG_INFO(LOG_APP, "JSVM CreateArrayWithLength success"); + } else { + OH_LOG_ERROR(LOG_APP, "JSVM CreateArrayWithLength fail"); + } + return result; +} +// CreateArrayWithLength注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateArrayWithLength}, +}; +static JSVM_CallbackStruct *method = param; +// CreateArrayWithLength方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createArrayWithLength", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +let num = 7; +function testCreateArrayWithLength(num) { + return createArrayWithLength(num); +} +testCreateArrayWithLength(num); +)JS"; +// [End oh_jsvm_create_array_with_length] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createarraywithlength", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/oh-package.json5 new file mode 100644 index 0000000000..e5fb57edaa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/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": "libcreatearraywithlength.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/createarraywithlengthability/CreatearraywithlengthAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/createarraywithlengthability/CreatearraywithlengthAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/createarraywithlengthability/CreatearraywithlengthAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/createarraywithlengthability/CreatearraywithlengthAbility.ets index 767c2d4d44..09df711e0f --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/createarraywithlengthability/CreatearraywithlengthAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/createarraywithlengthability/CreatearraywithlengthAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreatearraywithlengthAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreatearraywithlengthAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..40855f4280 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatearraywithlength.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/module.json5 new file mode 100644 index 0000000000..e5012073cc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createarraywithlength", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreatearraywithlengthAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreatearraywithlengthAbility", + "srcEntry": "./ets/createarraywithlengthability/CreatearraywithlengthAbility.ets", + "description": "$string:CreatearraywithlengthAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreatearraywithlengthAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..c887db6610 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreatearraywithlengthAbility_desc", + "value": "description" + }, + { + "name": "CreatearraywithlengthAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..b1aa404cb8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateArrayWithLength', 0, async (done: Function) => { + console.log('uitest: TestCreateArrayWithLength begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreatearraywithlengthAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreatearraywithlengthAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateArrayWithLength end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/List.test.ets similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/module.json5 new file mode 100644 index 0000000000..ead9aad517 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createarraywithlength_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/obfuscation-rules.txt similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/obfuscation-rules.txt rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/obfuscation-rules.txt diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/oh-package.json5 new file mode 100644 index 0000000000..50d711d2fb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/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": "createdataview", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatedataview.so": "file:./src/main/cpp/types/libcreatedataview" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..2e38321151 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createdataview SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createdataview PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..653b95f9cc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/hello.cpp @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_dataview] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_create_dataview] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +static int g_diffValueFour = 4; +static int g_diffValueTwelve = 12; +// [EndExclude oh_jsvm_create_dataview] + +// OH_JSVM_CreateDataview的样例方法 +static JSVM_Value CreateDataView(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取js侧传入的两个参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + JSVM_Value arrayBuffer = nullptr; + JSVM_Value result = nullptr; + // DataView的字节长度 + size_t byteLength = g_diffValueFour; + // 字节偏移量 + size_t byteOffset = g_diffValueTwelve; + // 获取回调函数的参数信息 + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 将参数转换为对象类型 + OH_JSVM_CoerceToObject(env, args[0], &arrayBuffer); + // 创建一个数据视图对象,并指定字节长度和字节偏移量 + JSVM_Status status = OH_JSVM_CreateDataview(env, byteLength, arrayBuffer, byteOffset, &result); + // 获取DataView的指针和长度信息 + uint8_t *data = nullptr; + size_t length = 0; + // 为DataView赋值 + for (size_t i = 0; i < length; i++) { + data[i] = static_cast(i + 1); + } + int32_t infoType; + OH_JSVM_GetValueInt32(env, args[1], &infoType); + size_t returnLength; + JSVM_Value returnArrayBuffer = nullptr; + size_t returnOffset; + enum InfoType { BYTE_LENGTHE, ARRAY_BUFFERE, BYTE_OFFSET }; + // 获取dataview信息 + OH_JSVM_GetDataviewInfo(env, result, &returnLength, (void **)&data, &returnArrayBuffer, &returnOffset); + JSVM_Value returnResult = nullptr; + switch (infoType) { + case BYTE_LENGTHE: + JSVM_Value len; + OH_JSVM_CreateInt32(env, returnLength, &len); + returnResult = len; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateDataView fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateDataView success, returnLength: %{public}d", returnLength); + } + break; + case ARRAY_BUFFERE: + bool isArraybuffer; + OH_JSVM_IsArraybuffer(env, returnArrayBuffer, &isArraybuffer); + JSVM_Value isArray; + OH_JSVM_GetBoolean(env, isArraybuffer, &isArray); + returnResult = isArray; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateDataView fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateDataView success, isArraybuffer: %{public}d", isArraybuffer); + } + break; + case BYTE_OFFSET: + JSVM_Value offset; + OH_JSVM_CreateInt32(env, returnOffset, &offset); + returnResult = offset; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateDataView fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateDataView success, returnOffset: %{public}d", returnOffset); + } + break; + default: + break; + } + return returnResult; +} +// CreateDataView注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateDataView}, +}; +static JSVM_CallbackStruct *method = param; +// CreateDataView方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createDataView", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let BYTE_LENGTH = 0; + createDataView(new ArrayBuffer(16), BYTE_LENGTH); + let IS_ARRAYBUFFER = 1; + createDataView(new ArrayBuffer(16), IS_ARRAYBUFFER); + let BYTE_OFFSET = 2; + createDataView(new ArrayBuffer(16), BYTE_OFFSET); +)JS"; +// [End oh_jsvm_create_dataview] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createdataview", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/oh-package.json5 new file mode 100644 index 0000000000..6d5f067aff --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/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": "libcreatedataview.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/createdataviewability/CreatedataviewAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/createdataviewability/CreatedataviewAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/createdataviewability/CreatedataviewAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/createdataviewability/CreatedataviewAbility.ets index 3097d59ba6..f3329ad686 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/createdataviewability/CreatedataviewAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/createdataviewability/CreatedataviewAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreatedataviewAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreatedataviewAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..1e0e837599 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatedataview.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/module.json5 new file mode 100644 index 0000000000..2edbae32ff --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createdataview", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreatedataviewAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreatedataviewAbility", + "srcEntry": "./ets/createdataviewability/CreatedataviewAbility.ets", + "description": "$string:CreatedataviewAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreatedataviewAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..9587b21cf6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreatedataviewAbility_desc", + "value": "description" + }, + { + "name": "CreatedataviewAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/layered_image.json similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..3d76e81375 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateDataview', 0, async (done: Function) => { + console.log('uitest: TestCreateDataview begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreatedataviewAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreatedataviewAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateDataview end'); + done(); + }) + }) +} + + diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/module.json5 new file mode 100644 index 0000000000..ad513a5815 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createdataview_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/oh-package.json5 new file mode 100644 index 0000000000..0d18bda7bb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/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": "createtypedarray", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatetypedarray.so": "file:./src/main/cpp/types/libcreatetypedarray" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..68979498b9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createtypedarray SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createtypedarray PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..5cde47efc8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/hello.cpp @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_typedarray] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_create_typedarray] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_typedarray] + +// OH_JSVM_CreateTypedarray的样例方法 +static int g_diffValueThree = 3; +static JSVM_Value CreateTypedArray(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + int32_t typeNum; + OH_JSVM_GetValueInt32(env, args[0], &typeNum); + JSVM_TypedarrayType arrayType; + // 用于存储每个元素的大小 + size_t elementSize = 0; + // 转换为JSVM_TypedarrayType类型 + arrayType = static_cast(typeNum); + switch (typeNum) { + case JSVM_INT8_ARRAY: + case JSVM_UINT8_ARRAY: + case JSVM_UINT8_CLAMPED_ARRAY: + elementSize = sizeof(int8_t); + break; + case JSVM_INT16_ARRAY: + case JSVM_UINT16_ARRAY: + elementSize = sizeof(int16_t); + break; + case JSVM_INT32_ARRAY: + case JSVM_UINT32_ARRAY: + elementSize = sizeof(int32_t); + break; + case JSVM_FLOAT32_ARRAY: + elementSize = sizeof(float); + break; + case JSVM_FLOAT64_ARRAY: + elementSize = sizeof(double); + break; + case JSVM_BIGINT64_ARRAY: + case JSVM_BIGUINT64_ARRAY: + elementSize = sizeof(int64_t); + break; + default: + // 默认创建JSVM_INT8_ARRAY类型 + arrayType = JSVM_INT8_ARRAY; + elementSize = sizeof(int8_t); + break; + } + size_t length = g_diffValueThree; + JSVM_Value arrayBuffer = nullptr; + JSVM_Value typedArray = nullptr; + void *data; + // 创建一个ArrayBuffer + OH_JSVM_CreateArraybuffer(env, length * elementSize, (void **)&data, &arrayBuffer); + // 根据给定类型创建TypedArray + JSVM_Status status = OH_JSVM_CreateTypedarray(env, arrayType, length, arrayBuffer, 0, &typedArray); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateTypedArray fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateTypedArray success"); + } + return typedArray; +} +// CreateTypedArray注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateTypedArray}, +}; +static JSVM_CallbackStruct *method = param; +// CreateTypedArray方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createTypedArray", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +const type = { + INT8_ARRAY: 0, + UINT8_ARRAY: 1, + UINT8_CLAMPED_ARRAY: 2, + INT16_ARRAY: 3, + UINT16_ARRAY: 4, + INT32_ARRAY: 5, + UINT32_ARRAY: 6, + FLOAT32_ARRAY: 7, + FLOAT64_ARRAY: 8, + BIGINT64_ARRAY: 9, + BIGUINT64_ARRAY: 10 +}; +createTypedArray(type.INT8_ARRAY); +createTypedArray(type.INT32_ARRAY); +)JS"; +// [End oh_jsvm_create_typedarray] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createtypedarray", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/oh-package.json5 new file mode 100644 index 0000000000..fcf561ebde --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/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": "libcreatetypedarray.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/createtypedarrayability/CreatetypedarrayAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/createtypedarrayability/CreatetypedarrayAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/createtypedarrayability/CreatetypedarrayAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/createtypedarrayability/CreatetypedarrayAbility.ets index f397f464aa..fe363aaad2 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/createtypedarrayability/CreatetypedarrayAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/createtypedarrayability/CreatetypedarrayAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreatetypedarrayAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreatetypedarrayAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..b466214307 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatetypedarray.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/module.json5 new file mode 100644 index 0000000000..1e02d76dcd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createtypedarray", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreatetypedarrayAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreatetypedarrayAbility", + "srcEntry": "./ets/createtypedarrayability/CreatetypedarrayAbility.ets", + "description": "$string:CreatetypedarrayAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreatetypedarrayAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..7082e7bcf9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreatetypedarrayAbility_desc", + "value": "description" + }, + { + "name": "CreatetypedarrayAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..d7162797f5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateTypedarray', 0, async (done: Function) => { + console.log('uitest: TestCreateTypedarray begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreatetypedarrayAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreatetypedarrayAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateTypedarray end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/module.json5 new file mode 100644 index 0000000000..f1f3f7cf1d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createtypedarray_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/oh-package.json5 new file mode 100644 index 0000000000..1af11c0643 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/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": "deleteelement", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libdeleteelement.so": "file:./src/main/cpp/types/libdeleteelement" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..c799add86d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(deleteelement SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(deleteelement PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..f06c3ab788 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/hello.cpp @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_delete_element] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_delete_element] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_delete_element] + +// OH_JSVM_DeleteElement的样例方法 +static JSVM_Value DeleteElement(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取js侧传入的两个参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 获取要删除的元素的索引 + uint32_t index; + OH_JSVM_GetValueUint32(env, args[1], &index); + // 尝试删除请求索引位置的元素 + bool deleted = true; + JSVM_Status status = OH_JSVM_DeleteElement(env, args[0], index, &deleted); + // 将boolean结果转换为JSVM_Value并返回 + JSVM_Value result = nullptr; + OH_JSVM_GetBoolean(env, deleted, &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM DeleteElement fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM DeleteElement: %{public}d", deleted); + } + return result; +} +// DeleteElement注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = DeleteElement}, +}; +static JSVM_CallbackStruct *method = param; +// DeleteElement方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"deleteElement", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +let arr = [10, 'hello', null, true]; +deleteElement(arr, 0); +)JS"; +// [End oh_jsvm_delete_element] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "deleteelement", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/oh-package.json5 new file mode 100644 index 0000000000..e8875dabd0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/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": "libdeleteelement.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/deleteelementability/DeleteelementAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/deleteelementability/DeleteelementAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/deleteelementability/DeleteelementAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/deleteelementability/DeleteelementAbility.ets index 4e8791a928..e313dd21ca --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/deleteelementability/DeleteelementAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/deleteelementability/DeleteelementAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class DeleteelementAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class DeleteelementAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..c371ac6ee6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libdeleteelement.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/module.json5 new file mode 100644 index 0000000000..163d1935ef --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "deleteelement", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "DeleteelementAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "DeleteelementAbility", + "srcEntry": "./ets/deleteelementability/DeleteelementAbility.ets", + "description": "$string:DeleteelementAbility_desc", + "icon": "$media:layered_image", + "label": "$string:DeleteelementAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..4c5c74c7ac --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "DeleteelementAbility_desc", + "value": "description" + }, + { + "name": "DeleteelementAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..fb6563dcb6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testDeleteElement', 0, async (done: Function) => { + console.log('uitest: TestDeleteElement begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'DeleteelementAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('DeleteelementAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestDeleteElement end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/module.json5 new file mode 100644 index 0000000000..cb29a6bf4e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "deleteelement_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/oh-package.json5 new file mode 100644 index 0000000000..f2e5e8ee3b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/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": "getarraylength", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetarraylength.so": "file:./src/main/cpp/types/libgetarraylength" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..78e4ce4f5d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(getarraylength SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getarraylength PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..2c703610d0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/hello.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_array_length] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_get_array_length] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_array_length] + +// OH_JSVM_GetArrayLength的样例方法 +static JSVM_Value GetArrayLength(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + JSVM_Value result = nullptr; + uint32_t length; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 检查参数是否为数组 + bool isArray = false; + OH_JSVM_IsArray(env, args[0], &isArray); + if (!isArray) { + OH_LOG_INFO(LOG_APP, "JSVM Argument must be an array"); + return nullptr; + } + OH_JSVM_GetArrayLength(env, args[0], &length); + // 创建返回值 + OH_JSVM_CreateInt32(env, length, &result); + OH_LOG_INFO(LOG_APP, "JSVM length: %{public}d", length); + return result; +} +// GetArrayLength注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetArrayLength}, +}; +static JSVM_CallbackStruct *method = param; +// GetArrayLength方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getArrayLength", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +let data = [0, 1, 2, 3, 4, 5]; +getArrayLength(data); +)JS"; +// [End oh_jsvm_get_array_length] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getarraylength", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/oh-package.json5 new file mode 100644 index 0000000000..671224c598 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/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": "libgetarraylength.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/getarraylengthability/GetarraylengthAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/getarraylengthability/GetarraylengthAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/getarraylengthability/GetarraylengthAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/getarraylengthability/GetarraylengthAbility.ets index 9d7f472795..bc99f07f17 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/getarraylengthability/GetarraylengthAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/getarraylengthability/GetarraylengthAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetarraylengthAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetarraylengthAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..a681948298 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetarraylength.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/module.json5 new file mode 100644 index 0000000000..f07b6deaa2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getarraylength", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetarraylengthAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetarraylengthAbility", + "srcEntry": "./ets/getarraylengthability/GetarraylengthAbility.ets", + "description": "$string:GetarraylengthAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetarraylengthAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..75b181bc89 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetarraylengthAbility_desc", + "value": "description" + }, + { + "name": "GetarraylengthAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..510d3dc814 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetArrayLength', 0, async (done: Function) => { + console.log('uitest: TestGetArrayLength begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetarraylengthAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetarraylengthAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetArrayLength end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/module.json5 new file mode 100644 index 0000000000..14ad84f0a9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getarraylength_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/oh-package.json5 new file mode 100644 index 0000000000..d23005f492 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/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": "getdataviewinfo", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetdataviewinfo.so": "file:./src/main/cpp/types/libgetdataviewinfo" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..ede5023178 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getdataviewinfo SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getdataviewinfo PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..55257eb654 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/hello.cpp @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_dataview_info] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_get_dataview_info] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_dataview_info] + +// OH_JSVM_GetDataviewInfo的样例方法 +static JSVM_Value GetDataViewInfo(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取并解析参数,第一个参数为需要获得的信息的DataView类型数据,第二个参数为需要获得的信息类型的枚举值 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 将第二个参数转为int32类型的数字 + int32_t infoType; + OH_JSVM_GetValueInt32(env, args[1], &infoType); + size_t byteLength; + void *data; + JSVM_Value arrayBuffer = nullptr; + size_t byteOffset; + // 定义枚举类型与ArkTS侧枚举类型infoType顺序含义一致 + enum InfoTypeEnum { BYTE_LENGTHE, ARRAY_BUFFERE, BYTE_OFFSET }; + // 获取dataview信息 + JSVM_Status status = OH_JSVM_GetDataviewInfo(env, args[0], &byteLength, &data, &arrayBuffer, &byteOffset); + JSVM_Value result = nullptr; + switch (infoType) { + case BYTE_LENGTHE: + // 返回查询DataView的长度 + JSVM_Value len; + OH_JSVM_CreateInt32(env, byteLength, &len); + result = len; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetDataViewInfo fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetDataViewInfo success, byteLength: %{public}d", byteLength); + } + break; + case ARRAY_BUFFERE: + // 判断DataView的Info里的arraybuffer是否为arraybuffer + bool isArrayBuffer; + OH_JSVM_IsArraybuffer(env, arrayBuffer, &isArrayBuffer); + JSVM_Value isArray; + OH_JSVM_GetBoolean(env, isArrayBuffer, &isArray); + result = isArray; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetDataViewInfo fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetDataViewInfo success, isArrayBuffer: %{public}d", isArrayBuffer); + } + break; + case BYTE_OFFSET: + // 返回查询DataView的偏移量 + JSVM_Value offset; + OH_JSVM_CreateInt32(env, byteOffset, &offset); + result = offset; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetDataViewInfo fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetDataViewInfo success, byteOffset: %{public}d", byteOffset); + } + break; + default: + break; + } + return result; +} +// GetDataViewInfo注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetDataViewInfo}, +}; +static JSVM_CallbackStruct *method = param; +// GetDataViewInfo方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getDataViewInfo", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +// bytelength +getDataViewInfo(new DataView(new Int8Array([2, 5]).buffer), 0); +// is arraybuffer +let data = 'a'; +let isarraybuffer = 1; +getDataViewInfo(data, isarraybuffer); +// is arraybuffer +data = new DataView(new Int8Array([2, 5, 3]).buffer); +isarraybuffer = 1; +getDataViewInfo(data, isarraybuffer); +// byte_offset +data = new DataView(new Int8Array([2, 5, 3]).buffer); +isarraybuffer = 2; +getDataViewInfo(data, isarraybuffer); +)JS"; +// [End oh_jsvm_get_dataview_info] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getdataviewinfo", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/oh-package.json5 new file mode 100644 index 0000000000..c878cd453d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/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": "libgetdataviewinfo.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/getdataviewinfoability/GetdataviewinfoAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/getdataviewinfoability/GetdataviewinfoAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/getdataviewinfoability/GetdataviewinfoAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/getdataviewinfoability/GetdataviewinfoAbility.ets index 3ac062e2ca..58476b71f0 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/getdataviewinfoability/GetdataviewinfoAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/getdataviewinfoability/GetdataviewinfoAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetdataviewinfoAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetdataviewinfoAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..86ffd8964e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetdataviewinfo.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/module.json5 new file mode 100644 index 0000000000..9b95016bac --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getdataviewinfo", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetdataviewinfoAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetdataviewinfoAbility", + "srcEntry": "./ets/getdataviewinfoability/GetdataviewinfoAbility.ets", + "description": "$string:GetdataviewinfoAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetdataviewinfoAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..6439e36e10 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetdataviewinfoAbility_desc", + "value": "description" + }, + { + "name": "GetdataviewinfoAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..adbf66523c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetDataviewInfo', 0, async (done: Function) => { + console.log('uitest: TestGetDataviewInfo begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetdataviewinfoAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetdataviewinfoAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetDataviewInfo end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/module.json5 new file mode 100644 index 0000000000..714dbba2ae --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getdataviewinfo_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/oh-package.json5 new file mode 100644 index 0000000000..694ee70e9d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/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": "getelement", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetelement.so": "file:./src/main/cpp/types/libgetelement" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..dea780a7ac --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getelement SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getelement PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..0e75b7e408 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/hello.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_element] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_get_element] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_element] + +// OH_JSVM_GetElement的样例方法 +static JSVM_Value GetElement(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取js侧传入的两个参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 获取请求元素的索引值 + uint32_t index; + OH_JSVM_GetValueUint32(env, args[1], &index); + // 获取请求索引位置的元素值并存储在result中 + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_GetElement(env, args[0], index, &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetElement fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetElement success"); + } + return result; +} +// GetElement注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetElement}, +}; +static JSVM_CallbackStruct *method = param; +// GetElement方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getElement", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +let arr = [10, 'hello', null, true]; +getElement(arr, 3); +)JS"; +// [End oh_jsvm_get_element] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getelement", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/oh-package.json5 new file mode 100644 index 0000000000..c617e658fb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/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": "libgetelement.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/getelementability/GetelementAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/getelementability/GetelementAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/getelementability/GetelementAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/getelementability/GetelementAbility.ets index 217add1603..01f96a258a --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/getelementability/GetelementAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/getelementability/GetelementAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetelementAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetelementAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..cd716c1b4c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetelement.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/module.json5 new file mode 100644 index 0000000000..8b4f09b208 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getelement", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetelementAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetelementAbility", + "srcEntry": "./ets/getelementability/GetelementAbility.ets", + "description": "$string:GetelementAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetelementAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..5652fa10a1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetelementAbility_desc", + "value": "description" + }, + { + "name": "GetelementAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..5ce5cae884 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetElement', 0, async (done: Function) => { + console.log('uitest: TestGetElement begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetelementAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetelementAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetElement end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/module.json5 new file mode 100644 index 0000000000..10c17dc864 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getelement_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/oh-package.json5 new file mode 100644 index 0000000000..a7ec9c7d0a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/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": "gettypedarrayinfo", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgettypedarrayinfo.so": "file:./src/main/cpp/types/libgettypedarrayinfo" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..30a71205c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(gettypedarrayinfo SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(gettypedarrayinfo PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..ffe8187719 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/hello.cpp @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_typedarray_info] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_get_typedarray_info] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_typedarray_info] + +// OH_JSVM_GetTypedarrayInfo的样例方法 +static JSVM_Value GetTypedArrayInfo(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取并解析参数,第一个参数为需要获得的信息的TypedArray类型数据,第二个参数为需要获得的信息类型的枚举值 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + + // 将第二个参数转为int32类型便于比较 + int32_t infoTypeParam; + OH_JSVM_GetValueInt32(env, args[1], &infoTypeParam); + // 定义枚举类型与ArkTS侧枚举类型infoType顺序含义一致 + enum InfoType { INFO_TYPE, INFO_LENGTH, INFO_ARRAY_BUFFER, INFO_BYTE_OFFSET }; + void *data; + JSVM_TypedarrayType type; + size_t byteOffset; + size_t length; + JSVM_Value arrayBuffer = nullptr; + // 调用接口OH_JSVM_GetTypedarrayInfo获得TypedArray类型数据的信息 + JSVM_Status status = OH_JSVM_GetTypedarrayInfo(env, args[0], &type, &length, &data, &arrayBuffer, &byteOffset); + JSVM_Value result = nullptr; + // 根据属性名,返回TypedArray对应的属性值 + switch (infoTypeParam) { + case INFO_TYPE: + // 如果传入的参数是int8类型的TypedArray数据,它的类型(type)为JSVM_INT8_ARRAY + JSVM_Value int8_type; + OH_JSVM_GetBoolean(env, type == JSVM_INT8_ARRAY, &int8_type); + result = int8_type; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetTypedArrayInfo fail"); + } else { + OH_LOG_INFO( + LOG_APP, "JSVM GetTypedArrayInfo success, JSVM_INT8_ARRAY: %{public}d", type == JSVM_INT8_ARRAY); + } + break; + case INFO_LENGTH: + // TypedArray中的元素数 + JSVM_Value jsvmLength; + OH_JSVM_CreateInt32(env, length, &jsvmLength); + result = jsvmLength; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetTypedArrayInfo fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetTypedArrayInfo success, length: %{public}d", length); + } + break; + case INFO_BYTE_OFFSET: + // TypedArray数组的第一个元素所在的基础原生数组中的字节偏移量 + JSVM_Value jsvmOffset; + OH_JSVM_CreateInt32(env, byteOffset, &jsvmOffset); + result = jsvmOffset; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetTypedArrayInfo fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetTypedArrayInfo success, byteOffset: %{public}d", byteOffset); + } + break; + case INFO_ARRAY_BUFFER: + // TypedArray下的ArrayBuffer + bool isArrayBuffer; + OH_JSVM_IsArraybuffer(env, arrayBuffer, &isArrayBuffer); + JSVM_Value isArray; + OH_JSVM_GetBoolean(env, isArrayBuffer, &isArray); + result = isArray; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetTypedArrayInfo fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetTypedArrayInfo success, isArrayBuffer: %{public}d", isArrayBuffer); + } + break; + default: + break; + } + return result; +} +// GetTypedArrayInfo注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetTypedArrayInfo}, +}; +static JSVM_CallbackStruct *method = param; +// GetTypedArrayInfo方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getTypedArrayInfo", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +// is JSVM_INT8_ARRAY +getTypedArrayInfo(new Int8Array(3), 0); +// length +getTypedArrayInfo(new Int8Array(5), 1); +// is_arraybuffer +getTypedArrayInfo(new Int8Array(5), 2); +// byteoffset +getTypedArrayInfo(new Int8Array(1), 3); +)JS"; +// [End oh_jsvm_get_typedarray_info] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "gettypedarrayinfo", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/oh-package.json5 new file mode 100644 index 0000000000..31378eaf06 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/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": "libgettypedarrayinfo.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/gettypedarrayinfoability/GettypedarrayinfoAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/gettypedarrayinfoability/GettypedarrayinfoAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/gettypedarrayinfoability/GettypedarrayinfoAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/gettypedarrayinfoability/GettypedarrayinfoAbility.ets index a1f4288be6..f58741051a --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/gettypedarrayinfoability/GettypedarrayinfoAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/gettypedarrayinfoability/GettypedarrayinfoAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GettypedarrayinfoAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GettypedarrayinfoAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..4031589907 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgettypedarrayinfo.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/module.json5 new file mode 100644 index 0000000000..0916244dcb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "gettypedarrayinfo", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GettypedarrayinfoAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GettypedarrayinfoAbility", + "srcEntry": "./ets/gettypedarrayinfoability/GettypedarrayinfoAbility.ets", + "description": "$string:GettypedarrayinfoAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GettypedarrayinfoAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..7a7172a828 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GettypedarrayinfoAbility_desc", + "value": "description" + }, + { + "name": "GettypedarrayinfoAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..d450093559 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetTypedarrayInfo', 0, async (done: Function) => { + console.log('uitest: TestGetTypedarrayInfo begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GettypedarrayinfoAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GettypedarrayinfoAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetTypedarrayInfo end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/module.json5 new file mode 100644 index 0000000000..8c2115c22b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "gettypedarrayinfo_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/oh-package.json5 new file mode 100644 index 0000000000..146d18ff70 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/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": "haselement", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libhaselement.so": "file:./src/main/cpp/types/libhaselement" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..2090b5c9a0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(haselement SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(haselement PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..fb477ae473 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/hello.cpp @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_has_element] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_has_element] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_has_element] + +// OH_JSVM_HasElement的样例方法 +static JSVM_Value HasElement(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取js侧传入的两个参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 获取要判断的元素的索引 + uint32_t index; + OH_JSVM_GetValueUint32(env, args[1], &index); + // 判断指定索引位置的元素是否存在 + bool hasElement = true; + JSVM_Status status = OH_JSVM_HasElement(env, args[0], index, &hasElement); + // 将boolean结果转换为JSVM_Value并返回 + JSVM_Value result = nullptr; + OH_JSVM_GetBoolean(env, hasElement, &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM hasElement fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM hasElement: %{public}d", hasElement); + } + return result; +} +// HasElement注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = HasElement}, +}; +static JSVM_CallbackStruct *method = param; +// HasElement方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"hasElement", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *srcCallNative = R"JS( +let arr = [10, 'hello', null, true]; +hasElement(arr, 0); +hasElement(arr, 4); +)JS"; +// [End oh_jsvm_has_element] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, srcCallNative, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "haselement", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/oh-package.json5 new file mode 100644 index 0000000000..f096725231 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/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": "libhaselement.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/haselementability/HaselementAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/haselementability/HaselementAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/haselementability/HaselementAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/haselementability/HaselementAbility.ets index 07ad3bee1f..3a3d098ca7 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/haselementability/HaselementAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/haselementability/HaselementAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class HaselementAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class HaselementAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..0eddb902d3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libhaselement.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/module.json5 new file mode 100644 index 0000000000..c4df04c786 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "haselement", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "HaselementAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "HaselementAbility", + "srcEntry": "./ets/haselementability/HaselementAbility.ets", + "description": "$string:HaselementAbility_desc", + "icon": "$media:layered_image", + "label": "$string:HaselementAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..0f181f5fe6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "HaselementAbility_desc", + "value": "description" + }, + { + "name": "HaselementAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..9907a4623b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testHasElement', 0, async (done: Function) => { + console.log('uitest: TestHasElement begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'HaselementAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('HaselementAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestHasElement end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/module.json5 new file mode 100644 index 0000000000..8c4f4995a8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "haselement_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/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.1", + "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/oh-package.json5 new file mode 100644 index 0000000000..ab38673af0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/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": "isarray", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libisarray.so": "file:./src/main/cpp/types/libisarray" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..deb9a0bd24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(isarray SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(isarray PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..6572e09cf4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_is_array] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_is_array] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_is_array] + +// OH_JSVM_IsArray的样例方法 +static JSVM_Value IsArray(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + bool result = false; + JSVM_Status status = OH_JSVM_IsArray(env, args[0], &result); + JSVM_Value returnValue = nullptr; + OH_JSVM_GetBoolean(env, result, &returnValue); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM IsArray fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM IsArray success, IsArray: %{public}d", result); + } + return returnValue; +} +// IsArray注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = IsArray}, +}; +static JSVM_CallbackStruct *method = param; +// IsArray方法别名,TS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"isArray", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *srcCallNative = R"JS( +let data = [1, 2, 3, 4, 5]; +isArray(data); +)JS"; +// [End oh_jsvm_is_array] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, srcCallNative, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "isarray", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/oh-package.json5 new file mode 100644 index 0000000000..5565a148eb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/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": "libisarray.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/isarrayability/IsarrayAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/isarrayability/IsarrayAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/isarrayability/IsarrayAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/isarrayability/IsarrayAbility.ets index 45c7e40a72..adb10e1e66 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/isarrayability/IsarrayAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/isarrayability/IsarrayAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class IsarrayAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class IsarrayAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..b5d5708e83 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libisarray.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/module.json5 new file mode 100644 index 0000000000..74147792b4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "isarray", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "IsarrayAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "IsarrayAbility", + "srcEntry": "./ets/isarrayability/IsarrayAbility.ets", + "description": "$string:IsarrayAbility_desc", + "icon": "$media:layered_image", + "label": "$string:IsarrayAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..8eff575f5e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "IsarrayAbility_desc", + "value": "description" + }, + { + "name": "IsarrayAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..d47f60af1d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testIsArray', 0, async (done: Function) => { + console.log('uitest: TestIsArray begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'IsarrayAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('IsarrayAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestIsArray end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/module.json5 new file mode 100644 index 0000000000..f91518e902 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "isarray_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/oh-package.json5 new file mode 100644 index 0000000000..8459e56f4a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/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": "isdataview", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libisdataview.so": "file:./src/main/cpp/types/libisdataview" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..2ffaa819a2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(isdataview SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(isdataview PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..aaeab782df --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/hello.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_is_dataview] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_is_dataview] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_is_dataview] + +// OH_JSVM_IsDataview的样例方法 +static JSVM_Value IsDataView(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 调用OH_JSVM_IsDataview接口判断给定入参是否为DataView数据。 + bool result = false; + JSVM_Status status = OH_JSVM_IsDataview(env, args[0], &result); + JSVM_Value isDateView = nullptr; + OH_JSVM_GetBoolean(env, result, &isDateView); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM IsDataView fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM IsDataView: %{public}d", result); + } + return isDateView; +} +// IsDataView注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = IsDataView}, +}; +static JSVM_CallbackStruct *method = param; +// IsDataView方法别名,TS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"isDataView", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *srcCallNative = R"JS( +let buffer = new ArrayBuffer(16); +let dataView = new DataView(buffer); +isDataView(dataView); +)JS"; +// [End oh_jsvm_is_dataview] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, srcCallNative, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "isdataview", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/oh-package.json5 new file mode 100644 index 0000000000..2294105979 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/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": "libisdataview.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/isdataviewability/IsdataviewAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/isdataviewability/IsdataviewAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/isdataviewability/IsdataviewAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/isdataviewability/IsdataviewAbility.ets index cb0b5d78dc..460ad01950 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/isdataviewability/IsdataviewAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/isdataviewability/IsdataviewAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class IsdataviewAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class IsdataviewAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..1f2d7cee54 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libisdataview.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/module.json5 new file mode 100644 index 0000000000..bad4d68535 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "isdataview", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "IsdataviewAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "IsdataviewAbility", + "srcEntry": "./ets/isdataviewability/IsdataviewAbility.ets", + "description": "$string:IsdataviewAbility_desc", + "icon": "$media:layered_image", + "label": "$string:IsdataviewAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..df24b674f0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "IsdataviewAbility_desc", + "value": "description" + }, + { + "name": "IsdataviewAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..ee817cc5d0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testIsDataview', 0, async (done: Function) => { + console.log('uitest: TestIsDataview begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'IsdataviewAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('IsdataviewAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestIsDataview end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/module.json5 new file mode 100644 index 0000000000..4bbbdf0034 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "isdataview_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/oh-package.json5 new file mode 100644 index 0000000000..107934447f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/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": "istypedarray", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libistypedarray.so": "file:./src/main/cpp/types/libistypedarray" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..f13755fac9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(istypedarray SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(istypedarray PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..54e342f3f6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/hello.cpp @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_is_typedarray] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_is_typedarray] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_is_typedarray] + +// OH_JSVM_IsTypedarray的样例方法 +static JSVM_Value IsTypedarray(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + bool result = false; + JSVM_Status status = OH_JSVM_IsTypedarray(env, args[0], &result); + JSVM_Value isTypedArray = nullptr; + OH_JSVM_GetBoolean(env, result, &isTypedArray); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM IsTypedarray fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM IsTypedarray: %{public}d", result); + } + return isTypedArray; +} +// IsTypedarray注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = IsTypedarray}, +}; +static JSVM_CallbackStruct *method = param; +// IsTypedarray方法别名,TS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"isTypedarray", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *srcCallNative = R"JS( +isTypedarray(new Uint16Array([1, 2, 3, 4])); +)JS"; +// [End oh_jsvm_is_typedarray] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, srcCallNative, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "istypedarray", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/oh-package.json5 new file mode 100644 index 0000000000..435fcd9766 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/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": "libistypedarray.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/istypedarrayability/IstypedarrayAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/istypedarrayability/IstypedarrayAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/istypedarrayability/IstypedarrayAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/istypedarrayability/IstypedarrayAbility.ets index fd64cb185a..586d03f960 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/istypedarrayability/IstypedarrayAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/istypedarrayability/IstypedarrayAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class IstypedarrayAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class IstypedarrayAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..7d3f74513a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libistypedarray.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/module.json5 new file mode 100644 index 0000000000..875e3d13a1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "istypedarray", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "IstypedarrayAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "IstypedarrayAbility", + "srcEntry": "./ets/istypedarrayability/IstypedarrayAbility.ets", + "description": "$string:IstypedarrayAbility_desc", + "icon": "$media:layered_image", + "label": "$string:IstypedarrayAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..01682acd0d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "IstypedarrayAbility_desc", + "value": "description" + }, + { + "name": "IstypedarrayAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..9fee65d72c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testIsTypedarray', 0, async (done: Function) => { + console.log('uitest: TestIsTypedarray begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'IstypedarrayAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('IstypedarrayAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestIsTypedarray end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/module.json5 new file mode 100644 index 0000000000..eb1d73b688 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "istypedarray_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/ohosTest.md new file mode 100644 index 0000000000..2d5caf585d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/ohosTest.md @@ -0,0 +1,21 @@ +# JsvmAboutArray 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 创建一个新的 JavaScript 数组对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 创建一个指定长度的 JavaScript 数组对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 在现有的 ArrayBuffer 上创建一个 JavaScript DataView 对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 在现有的 ArrayBuffer 上创建一个 JavaScript TypedArray 对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 尝试删除给定对象的指定索引处的元素 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 返回 Array 对象的长度 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取 Dataview 对象的信息 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定对象指定索引处的元素 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取 TypedArray(类型化数组)对象的信息 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 若给定对象的指定索引处拥有属性,获取该元素 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 判断一个 JavaScript 对象是否为 Array 类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 判断一个 JavaScript 对象是否为 Dataview 类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 判断一个 JavaScript 对象是否为 Typedarray 类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 在给定对象的指定索引处设置元素 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/screenshots/JsvmAboutArray_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/screenshots/JsvmAboutArray_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/screenshots/JsvmAboutArray_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/screenshots/JsvmAboutArray_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/screenshots/JsvmAboutArray_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/screenshots/JsvmAboutArray_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/screenshots/JsvmAboutArray_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/screenshots/JsvmAboutArray_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/oh-package.json5 new file mode 100644 index 0000000000..0cef4be6a3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/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": "setelement", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libsetelement.so": "file:./src/main/cpp/types/libsetelement" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..98f3e8a2dd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(setelement SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(setelement PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..018496ac65 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/hello.cpp @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_set_element] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_set_element] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_set_element] + +// OH_JSVM_SetElement的样例方法 +static int g_diffValueThree = 3; +static JSVM_Value SetElement(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = g_diffValueThree; + JSVM_Value args[3] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + int32_t index = 0; + OH_JSVM_GetValueInt32(env, args[1], &index); + JSVM_Status status = OH_JSVM_SetElement(env, args[0], index, args[2]); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM SetElement fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM SetElement success"); + } + return args[0]; +} +// SetElement注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = SetElement}, +}; +static JSVM_CallbackStruct *method = param; +// SetElement方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"setElement", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +setElement(3); +)JS"; +// [End oh_jsvm_set_element] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "setelement", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/oh-package.json5 new file mode 100644 index 0000000000..2d7971a31d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/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": "libsetelement.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..34ff1332d8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libsetelement.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/setelementability/SetelementAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/setelementability/SetelementAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/setelementability/SetelementAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/setelementability/SetelementAbility.ets index a8a457f34d..53e8ce06e1 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/setelementability/SetelementAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/setelementability/SetelementAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class SetelementAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class SetelementAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/module.json5 new file mode 100644 index 0000000000..a23090f1df --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "setelement", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "SetelementAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "SetelementAbility", + "srcEntry": "./ets/setelementability/SetelementAbility.ets", + "description": "$string:SetelementAbility_desc", + "icon": "$media:layered_image", + "label": "$string:SetelementAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..7a34b15ba7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "SetelementAbility_desc", + "value": "description" + }, + { + "name": "SetelementAbility_label", + "value": "JsvmAboutArray" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..83482007ce --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testSetElement', 0, async (done: Function) => { + console.log('uitest: TestSetElement begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'SetelementAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('SetelementAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestSetElement end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/module.json5 new file mode 100644 index 0000000000..ff765a5fcb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "setelement_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/app.json5 new file mode 100644 index 0000000000..dd76d37978 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/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.jsvmaboutarraybuffer", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..be2a53f0f3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmAboutArraybuffer" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/README.md new file mode 100644 index 0000000000..6b9d389b07 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/README.md @@ -0,0 +1,133 @@ +# ArkTS使用JSVM-API接口进行ArrayBuffer相关开发 + +### 介绍 + +ArrayBuffer 是 JavaScript 中的一种数据类型,用于表示通用的、固定长度的原始二进制数据缓冲区。它提供了一种在 JavaScript 中有效地表示和操作原始二进制数据的方式。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口进行ArrayBuffer相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-arraybuffer.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------------------: | :----------------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +createarraybuffer/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getarraybufferinfo/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +isarraybuffer/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +isdetachedarraybuffer/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/build-profile.json5 new file mode 100644 index 0000000000..19692da56f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/build-profile.json5 @@ -0,0 +1,94 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "getarraybufferinfo", + "srcPath": "./getarraybufferinfo", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "isarraybuffer", + "srcPath": "./isarraybuffer", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "isdetachedarraybuffer", + "srcPath": "./isdetachedarraybuffer", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createarraybuffer", + "srcPath": "./createarraybuffer", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/code-linter.json5 diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/oh-package.json5 new file mode 100644 index 0000000000..c7ef987202 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/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": "createarraybuffer", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatearraybuffer.so": "file:./src/main/cpp/types/libcreatearraybuffer" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..8b6769decf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsFive) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createarraybuffer SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createarraybuffer PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..12e9f4072b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/hello.cpp @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_arraybuffer] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_create_arraybuffer] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_arraybuffer] + +// OH_JSVM_CreateArraybuffer的样例方法 +static JSVM_Value CreateArraybuffer(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + JSVM_Value result = nullptr; + // 解析传递的参数 + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + int32_t value; + size_t length; + OH_JSVM_GetValueInt32(env, argv[0], &value); + length = size_t(value); + void *data; + // 创建一个新的ArrayBuffer + JSVM_Status status = OH_JSVM_CreateArraybuffer(env, length, &data, &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateArraybuffer: failed"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateArraybuffer: success"); + OH_LOG_INFO(LOG_APP, "JSVM ArrayBuffer length: %{public}d", length); + } + // 返回创建好的ArrayBuffer + return result; +} +// CreateArraybuffer注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateArraybuffer}, +}; +static JSVM_CallbackStruct *method = param; +// CreateArraybuffer方法别名,供TS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createArraybuffer", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +createArraybuffer(8); +)JS"; +// [End oh_jsvm_create_arraybuffer] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createarraybuffer", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/oh-package.json5 new file mode 100644 index 0000000000..ebcd307a4a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/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": "libcreatearraybuffer.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/createarraybufferability/CreatearraybufferAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/createarraybufferability/CreatearraybufferAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/createarraybufferability/CreatearraybufferAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/createarraybufferability/CreatearraybufferAbility.ets index 4fc9d4f58c..e0536f2782 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/createarraybufferability/CreatearraybufferAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/createarraybufferability/CreatearraybufferAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreatearraybufferAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreatearraybufferAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..9ddd7c89c0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatearraybuffer.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/module.json5 new file mode 100644 index 0000000000..15287f7711 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createarraybuffer", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreatearraybufferAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreatearraybufferAbility", + "srcEntry": "./ets/createarraybufferability/CreatearraybufferAbility.ets", + "description": "$string:CreatearraybufferAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreatearraybufferAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..6f0babdfaa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreatearraybufferAbility_desc", + "value": "description" + }, + { + "name": "CreatearraybufferAbility_label", + "value": "JsvmAboutArraybuffer" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..d3343ee782 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateArraybuffer', 0, async (done: Function) => { + console.log('uitest: TestCreateArraybuffer begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreatearraybufferAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreatearraybufferAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateArraybuffer end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/module.json5 new file mode 100644 index 0000000000..0423124595 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createarraybuffer_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/oh-package.json5 new file mode 100644 index 0000000000..7525bbe93f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/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": "getarraybufferinfo", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetarraybufferinfo.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..d05b01552c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsFive) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(getarraybufferinfo SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getarraybufferinfo PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..97834ceb65 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/hello.cpp @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_arraybuffer_info] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_get_arraybuffer_info] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_arraybuffer_info] + +// OH_JSVM_GetArraybufferInfo的样例方法 +static JSVM_Value GetArraybufferInfo(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + // 解析传递的参数 + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 检查参数是否为ArrayBuffer + bool isArrayBuffer = false; + OH_JSVM_IsArraybuffer(env, args[0], &isArrayBuffer); + if (!isArrayBuffer) { + OH_LOG_ERROR(LOG_APP, "JSVM GetArraybufferInfo isArrayBuffer:false"); + } + void *data; + size_t byteLength; + // 获取ArrayBuffer的底层数据缓冲区和长度 + JSVM_Status status = OH_JSVM_GetArraybufferInfo(env, args[0], &data, &byteLength); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetArraybufferInfo: failed"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetArraybufferInfo: success"); + } + return args[0]; +} +// GetArraybufferInfo注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetArraybufferInfo}, +}; +static JSVM_CallbackStruct *method = param; +// GetArraybufferInfo方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getArraybufferInfo", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +getArraybufferInfo(new ArrayBuffer(10)); +)JS"; +// [End oh_jsvm_get_arraybuffer_info] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getarraybufferinfo", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..36110c3808 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/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": "libgetarraybufferinfo.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..a654430123 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetarraybufferinfo.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/module.json5 new file mode 100644 index 0000000000..15f1044e02 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/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": "getarraybufferinfo", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..0878d32004 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/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": "JsvmAboutArraybuffer" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..904159f6e6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetArraybufferInfo', 0, async (done: Function) => { + console.log('uitest: TestGetArraybufferInfo begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetArraybufferInfo end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/module.json5 new file mode 100644 index 0000000000..90eb73f573 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getarraybufferinfo_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/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.1", + "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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/oh-package.json5 new file mode 100644 index 0000000000..accae1ce0d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/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": "isarraybuffer", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libisarraybuffer.so": "file:./src/main/cpp/types/libisarraybuffer" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..38a29ee6fc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsFive) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(isarraybuffer SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(isarraybuffer PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..95abdfe935 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_is_arraybuffer] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_is_arraybuffer] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_is_arraybuffer] + +// OH_JSVM_IsArraybuffer的样例方法 +static JSVM_Value IsArrayBuffer(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 调用OH_JSVM_IsArraybuffer接口判断给定入参是否为ArrayBuffer数据 + bool isArrayBuffer = false; + JSVM_Status status = OH_JSVM_IsArraybuffer(env, args[0], &isArrayBuffer); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM IsArrayBuffer: failed"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM IsArrayBuffer: success"); + OH_LOG_INFO(LOG_APP, "JSVM IsArrayBuffer: %{public}d", isArrayBuffer); + } + JSVM_Value boolean = nullptr; + OH_JSVM_GetBoolean(env, isArrayBuffer, &boolean); + return boolean; +} +// IsArrayBuffer注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = IsArrayBuffer}, +}; +static JSVM_CallbackStruct *method = param; +// IsArrayBuffer方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"isArrayBuffer", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +isArrayBuffer(new ArrayBuffer(8)); +)JS"; +// [End oh_jsvm_is_arraybuffer] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "isarraybuffer", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/oh-package.json5 new file mode 100644 index 0000000000..0d0f89ea18 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/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": "libisarraybuffer.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/isarraybufferability/IsarraybufferAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/isarraybufferability/IsarraybufferAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/isarraybufferability/IsarraybufferAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/isarraybufferability/IsarraybufferAbility.ets index db8d5c53f7..92e42cd7cd --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/isarraybufferability/IsarraybufferAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/isarraybufferability/IsarraybufferAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class IsarraybufferAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class IsarraybufferAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..92986da4b5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libisarraybuffer.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/module.json5 new file mode 100644 index 0000000000..f9f4a0a746 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "isarraybuffer", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "IsarraybufferAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "IsarraybufferAbility", + "srcEntry": "./ets/isarraybufferability/IsarraybufferAbility.ets", + "description": "$string:IsarraybufferAbility_desc", + "icon": "$media:layered_image", + "label": "$string:IsarraybufferAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..dd0e15f88b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "IsarraybufferAbility_desc", + "value": "description" + }, + { + "name": "IsarraybufferAbility_label", + "value": "JsvmAboutArraybuffer" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..5a25784b7e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testIsArraybuffer', 0, async (done: Function) => { + console.log('uitest: TestIsArraybuffer begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'IsarraybufferAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('IsarraybufferAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestIsArraybuffer end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/module.json5 new file mode 100644 index 0000000000..cfae646a7d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "isarraybuffer_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/oh-package.json5 new file mode 100644 index 0000000000..e08f1de466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/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": "isdetachedarraybuffer", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libisdetachedarraybuffer.so": "file:./src/main/cpp/types/libisdetachedarraybuffer" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..d61b43a65c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsFive) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(isdetachedarraybuffer SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(isdetachedarraybuffer PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..9af5afe26d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/hello.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_is_detached_arraybuffer] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_is_detached_arraybuffer] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_is_detached_arraybuffer] + +// OH_JSVM_DetachArraybuffer、OH_JSVM_IsDetachedArraybuffer的样例方法 +static JSVM_Value DetachArraybuffer(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + JSVM_Value arraybuffer = args[0]; + JSVM_Status status = OH_JSVM_DetachArraybuffer(env, arraybuffer); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM DetachArraybuffer: failed"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM DetachArraybuffer: success"); + } + return arraybuffer; +} +static JSVM_Value IsDetachedArraybuffer(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + JSVM_Value arraybuffer = args[0]; + OH_JSVM_DetachArraybuffer(env, arraybuffer); + bool result = false; + JSVM_Status status = OH_JSVM_IsDetachedArraybuffer(env, arraybuffer, &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM IsDetachedArraybuffer: failed"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM IsDetachedArraybuffer: success"); + OH_LOG_INFO(LOG_APP, "JSVM IsArrayBuffer: %{public}d", result); + } + JSVM_Value isDetached = nullptr; + OH_JSVM_GetBoolean(env, result, &isDetached); + return isDetached; +} +// DetachArraybuffer、IsDetachedArraybuffer注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = DetachArraybuffer}, + {.data = nullptr, .callback = IsDetachedArraybuffer}, +}; +static JSVM_CallbackStruct *method = param; +// DetachArraybuffer、IsDetachedArraybuffer方法别名,TS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"detachArraybuffer", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, + {"isDetachedArraybuffer", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( +let arrayBuffer = new ArrayBuffer(10); +detachArraybuffer(arrayBuffer); +isDetachedArraybuffer(arrayBuffer); +)JS"; +// [End oh_jsvm_is_detached_arraybuffer] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "isdetachedarraybuffer", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/oh-package.json5 new file mode 100644 index 0000000000..4d43e7fc61 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/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": "libisdetachedarraybuffer.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/isdetachedarraybufferability/IsdetachedarraybufferAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/isdetachedarraybufferability/IsdetachedarraybufferAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/isdetachedarraybufferability/IsdetachedarraybufferAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/isdetachedarraybufferability/IsdetachedarraybufferAbility.ets index 636f1cadc0..115ea549e9 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/isdetachedarraybufferability/IsdetachedarraybufferAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/isdetachedarraybufferability/IsdetachedarraybufferAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class IsdetachedarraybufferAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class IsdetachedarraybufferAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..d169c6584a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libisdetachedarraybuffer.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/module.json5 new file mode 100644 index 0000000000..e8d00d6116 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "isdetachedarraybuffer", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "IsdetachedarraybufferAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "IsdetachedarraybufferAbility", + "srcEntry": "./ets/isdetachedarraybufferability/IsdetachedarraybufferAbility.ets", + "description": "$string:IsdetachedarraybufferAbility_desc", + "icon": "$media:layered_image", + "label": "$string:IsdetachedarraybufferAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..350c9cfa5c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "IsdetachedarraybufferAbility_desc", + "value": "description" + }, + { + "name": "IsdetachedarraybufferAbility_label", + "value": "JsvmAboutArraybuffer" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..8a80ca2026 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testIsDetachedArraybuffer', 0, async (done: Function) => { + console.log('uitest: TestIsDetachedArraybuffer begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'IsdetachedarraybufferAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('IsdetachedarraybufferAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestIsDetachedArraybuffer end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/module.json5 new file mode 100644 index 0000000000..7140dc8946 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "isdetachedarraybuffer_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/ohosTest.md new file mode 100644 index 0000000000..ff22838956 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/ohosTest.md @@ -0,0 +1,11 @@ +# JsvmAboutArraybuffer 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 创建一个指定大小的 ArrayBuffer 对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 检索 ArrayBuffer 的底层数据缓冲区及其长度 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 判断一个 JavaScript 对象是否为 ArrayBuffer 类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 检查给定的 ArrayBuffer 是否已被分离(detached) | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/screenshots/JsvmAboutArraybuffer_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/screenshots/JsvmAboutArraybuffer_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/screenshots/JsvmAboutArraybuffer_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/screenshots/JsvmAboutArraybuffer_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/screenshots/JsvmAboutArraybuffer_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/screenshots/JsvmAboutArraybuffer_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/screenshots/JsvmAboutArraybuffer_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/screenshots/JsvmAboutArraybuffer_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/app.json5 new file mode 100644 index 0000000000..b2d9a92730 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/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.jsvmaboutbigint", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..e240af11ba --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmAboutBigint" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/README.md new file mode 100644 index 0000000000..76af84a747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/README.md @@ -0,0 +1,173 @@ +# ArkTS使用JSVM-API接口操作bigint类型值 + +### 介绍 + +BigInt是JavaScript中用于表示任意精度整数的数据类型,它能够处理比Number类型更大范围的整数值。通过JSVM-API提供的接口,可以在JSVM模块中创建、获取和操作BigInt类型值,从而实现与BigInt相关的功能扩展。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口操作bigint类型值](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-bigint.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :-----------------------------------------------------------------: | :-----------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +createbigintint64/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createbigintuint64/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createbigintwords/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvaluebigintint64/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvaluebigintuint64/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvaluebigintwords/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/build-profile.json5 new file mode 100644 index 0000000000..2294a3e611 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/build-profile.json5 @@ -0,0 +1,118 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "getvaluebigintwords", + "srcPath": "./getvaluebigintwords", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createbigintwords", + "srcPath": "./createbigintwords", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createbigintuint64", + "srcPath": "./createbigintuint64", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getvaluebigintuint64", + "srcPath": "./getvaluebigintuint64", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createbigintint64", + "srcPath": "./createbigintint64", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getvaluebigintint64", + "srcPath": "./getvaluebigintint64", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/code-linter.json5 diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/oh-package.json5 new file mode 100644 index 0000000000..24310f1b2b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/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": "createbigintint64", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatebigintint64.so": "file:./src/main/cpp/types/libcreatebigintint64" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..66e21840c8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createbigintint64 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createbigintint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..10a8ab8a93 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/hello.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_bigint_int64] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_create_bigint_int64] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_bigint_int64] + +// 声明int64_t的变量value +static int64_t g_testValueDemo = -5555555555555555555; +// OH_JSVM_CreateBigintInt64的样例方法 +static JSVM_Value CreateBigintInt64(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_Value returnValue = nullptr; + JSVM_Status status = OH_JSVM_CreateBigintInt64(env, g_testValueDemo, &returnValue); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CreateBigintInt64 fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CreateBigintInt64 success"); + } + return returnValue; +} +// CreateBigintInt64注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateBigintInt64}, +}; +static JSVM_CallbackStruct *method = param; +// CreateBigintInt64方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createBigintInt64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(createBigintInt64())JS"; +// [End oh_jsvm_create_bigint_int64] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createbigintint64", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/oh-package.json5 new file mode 100644 index 0000000000..1039157d9b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/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": "libcreatebigintint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/createbigintint64ability/Createbigintint64Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/createbigintint64ability/Createbigintint64Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/createbigintint64ability/Createbigintint64Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/createbigintint64ability/Createbigintint64Ability.ets index 29246bb9bc..54b0d127ef --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/createbigintint64ability/Createbigintint64Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/createbigintint64ability/Createbigintint64Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Createbigintint64Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Createbigintint64Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..6fbeb81a91 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatebigintint64.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/module.json5 new file mode 100644 index 0000000000..2e973d7dea --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createbigintint64", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Createbigintint64Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Createbigintint64Ability", + "srcEntry": "./ets/createbigintint64ability/Createbigintint64Ability.ets", + "description": "$string:Createbigintint64Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Createbigintint64Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..3734dc3222 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Createbigintint64Ability_desc", + "value": "description" + }, + { + "name": "Createbigintint64Ability_label", + "value": "JsvmAboutBigint" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..a9a5af9fce --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateBigintInt64', 0, async (done: Function) => { + console.log('uitest: TestCreateBigintInt64 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Createbigintint64Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Createbigintint64Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateBigintInt64 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/module.json5 new file mode 100644 index 0000000000..d4b914b9dc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createbigintint64_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/oh-package.json5 new file mode 100644 index 0000000000..adc4499157 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/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": "createbigintuint64", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatebigintuint64.so": "file:./src/main/cpp/types/libcreatebigintuint64" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..f920b2ca45 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsSix) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createbigintuint64 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createbigintuint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..7bb92d66bc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/hello.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_bigint_uint64] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_create_bigint_uint64] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_bigint_uint64] + +// 声明uint64_t的变量value +static uint64_t g_testValue = 5555555555555555555; +// OH_JSVM_CreateBigintUint64的样例方法 +static JSVM_Value CreateBigintUint64(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 将value转化为JSVM_Value类型返回 + JSVM_Value returnValue = nullptr; + JSVM_Status status = OH_JSVM_CreateBigintUint64(env, g_testValue, &returnValue); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CreateBigintUint64 fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CreateBigintUint64 success"); + } + return returnValue; +} +// CreateBigintUint64注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateBigintUint64}, +}; +static JSVM_CallbackStruct *method = param; +// CreateBigintUint64方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createBigintUint64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(createBigintUint64())JS"; +// [End oh_jsvm_create_bigint_uint64] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createbigintuint64", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/oh-package.json5 new file mode 100644 index 0000000000..60767790c0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/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": "libcreatebigintuint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/createbigintuint64ability/Createbigintuint64Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/createbigintuint64ability/Createbigintuint64Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/createbigintuint64ability/Createbigintuint64Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/createbigintuint64ability/Createbigintuint64Ability.ets index 9796156190..2cd000ac84 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/createbigintuint64ability/Createbigintuint64Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/createbigintuint64ability/Createbigintuint64Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Createbigintuint64Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Createbigintuint64Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..86c3436cf2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatebigintuint64.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/module.json5 new file mode 100644 index 0000000000..5d90e5c19e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createbigintuint64", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Createbigintuint64Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Createbigintuint64Ability", + "srcEntry": "./ets/createbigintuint64ability/Createbigintuint64Ability.ets", + "description": "$string:Createbigintuint64Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Createbigintuint64Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..453a15bb9e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Createbigintuint64Ability_desc", + "value": "description" + }, + { + "name": "Createbigintuint64Ability_label", + "value": "JsvmAboutBigint" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..15db66924a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateBigintUint64', 0, async (done: Function) => { + console.log('uitest: TestCreateBigintUint64 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Createbigintuint64Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Createbigintuint64Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateBigintUint64 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/module.json5 new file mode 100644 index 0000000000..22b19149cf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createbigintuint64_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/oh-package.json5 new file mode 100644 index 0000000000..a2d75a437a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/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": "createbigintwords", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatebigintwords.so": "file:./src/main/cpp/types/libcreatebigintwords" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..cfcf91bc15 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsSix) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createbigintwords SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createbigintwords PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..4854cc0729 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/hello.cpp @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_bigint_words] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_create_bigint_words] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_bigint_words] + +// OH_JSVM_CreateBigintWords的样例方法 +static int g_diffValueThree = 3; +static JSVM_Value CreateBigintWords(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 使用OH_JSVM_CreateBigintWords接口创建一个BigInt对象 + int signBit = 0; + size_t wordCount = g_diffValueThree; + uint64_t words[] = {12ULL, 34ULL, 56ULL}; + JSVM_Value returnValue = nullptr; + JSVM_Status status = OH_JSVM_CreateBigintWords(env, signBit, wordCount, words, &returnValue); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CreateBigintWords fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CreateBigintWords success"); + } + return returnValue; +} +// CreateBigintWords注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateBigintWords}, +}; +static JSVM_CallbackStruct *method = param; +// CreateBigintWords方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createBigintWords", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(createBigintWords())JS"; +// [EndExclude oh_jsvm_create_bigint_words] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createbigintwords", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/oh-package.json5 new file mode 100644 index 0000000000..8139562209 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/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": "libcreatebigintwords.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/createbigintwordsability/CreatebigintwordsAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/createbigintwordsability/CreatebigintwordsAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/createbigintwordsability/CreatebigintwordsAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/createbigintwordsability/CreatebigintwordsAbility.ets index 3e3a9544d9..6882d87f82 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/createbigintwordsability/CreatebigintwordsAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/createbigintwordsability/CreatebigintwordsAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreatebigintwordsAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreatebigintwordsAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..eaa34dcf8d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatebigintwords.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/module.json5 new file mode 100644 index 0000000000..70ae7e137f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createbigintwords", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreatebigintwordsAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreatebigintwordsAbility", + "srcEntry": "./ets/createbigintwordsability/CreatebigintwordsAbility.ets", + "description": "$string:CreatebigintwordsAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreatebigintwordsAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..19ddee92e5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreatebigintwordsAbility_desc", + "value": "description" + }, + { + "name": "CreatebigintwordsAbility_label", + "value": "JsvmAboutBigint" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..6660d833f3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateBigintWords', 0, async (done: Function) => { + console.log('uitest: TestCreateBigintWords begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreatebigintwordsAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreatebigintwordsAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateBigintWords end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/module.json5 new file mode 100644 index 0000000000..ef673a26fe --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createbigintwords_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/oh-package.json5 new file mode 100644 index 0000000000..61f2056b38 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/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": "getvaluebigintint64", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvaluebigintint64.so": "file:./src/main/cpp/types/libgetvaluebigintint64" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..3b70a939a1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getvaluebigintint64 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvaluebigintint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..dba3632d4a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_bigint_int64] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_get_value_bigint_int64] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_bigint_int64] + +// OH_JSVM_GetValueBigintInt64的样例方法 +static JSVM_Value GetBigintInt64(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 从传入的参数中提取64位整数的BigInt数据 + int64_t value; + bool lossLess; + OH_JSVM_GetValueBigintInt64(env, args[0], &value, &lossLess); + // 判断从JS侧获取bigint是否为无损转换,如果不是抛出异常 + if (!lossLess) { + OH_JSVM_ThrowError(env, nullptr, "BigInt values have no lossless converted"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetBigintInt64 success:%{public}d", lossLess); + } + JSVM_Value returnValue = nullptr; + OH_JSVM_CreateBigintInt64(env, value, &returnValue); + return returnValue; +} +// GetBigintInt64注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetBigintInt64}, +}; +static JSVM_CallbackStruct *method = param; +// GetBigintInt64方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getBigintInt64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(getBigintInt64(BigInt(-5555555555555555)))JS"; +// [End oh_jsvm_get_value_bigint_int64] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvaluebigintint64", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/oh-package.json5 new file mode 100644 index 0000000000..76d755dfeb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/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": "libgetvaluebigintint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/getvaluebigintint64ability/Getvaluebigintint64Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/getvaluebigintint64ability/Getvaluebigintint64Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/getvaluebigintint64ability/Getvaluebigintint64Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/getvaluebigintint64ability/Getvaluebigintint64Ability.ets index e8ea958a63..b0db1a92df --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/getvaluebigintint64ability/Getvaluebigintint64Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/getvaluebigintint64ability/Getvaluebigintint64Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Getvaluebigintint64Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Getvaluebigintint64Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..8cfef82a52 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvaluebigintint64.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/module.json5 new file mode 100644 index 0000000000..16def6fbe4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getvaluebigintint64", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Getvaluebigintint64Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Getvaluebigintint64Ability", + "srcEntry": "./ets/getvaluebigintint64ability/Getvaluebigintint64Ability.ets", + "description": "$string:Getvaluebigintint64Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Getvaluebigintint64Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..b1099263f5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Getvaluebigintint64Ability_desc", + "value": "description" + }, + { + "name": "Getvaluebigintint64Ability_label", + "value": "JsvmAboutBigint" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..8e520467a8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueBigintInt64', 0, async (done: Function) => { + console.log('uitest: TestGetValueBigintInt64 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Getvaluebigintint64Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Getvaluebigintint64Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueBigintInt64 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/module.json5 new file mode 100644 index 0000000000..8fa9a60e6c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvaluebigintint64_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/oh-package.json5 new file mode 100644 index 0000000000..e13b723471 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/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": "getvaluebigintuint64", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvaluebigintuint64.so": "file:./src/main/cpp/types/libgetvaluebigintuint64" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..1380e03daf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getvaluebigintuint64 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvaluebigintuint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..a264a73f72 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_bigint_uint64] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_get_value_bigint_uint64] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_bigint_uint64] + +// OH_JSVM_GetValueBigintUint64的样例方法 +static JSVM_Value GetValueBigintUint64(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 从参数值中获取BigInt的数值 + uint64_t value = 0; + bool lossLess = false; + OH_JSVM_GetValueBigintUint64(env, args[0], &value, &lossLess); + // 判断从JS侧获取bigint是否为无损转换,如果不是抛出异常 + if (!lossLess) { + OH_JSVM_ThrowError(env, nullptr, "BigInt values have no lossless converted"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetValueBigintUint64 success:%{public}d", lossLess); + } + JSVM_Value returnValue = nullptr; + OH_JSVM_CreateBigintUint64(env, value, &returnValue); + return returnValue; +} +// GetValueBigintUint64注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetValueBigintUint64}, +}; +static JSVM_CallbackStruct *method = param; +// GetValueBigintUint64方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getValueBigintUint64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(getValueBigintUint64(BigInt(5555555555555555)))JS"; +// [End oh_jsvm_get_value_bigint_uint64] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvaluebigintuint64", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/oh-package.json5 new file mode 100644 index 0000000000..5a4b69ee6d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/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": "libgetvaluebigintuint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/getvaluebigintuint64ability/Getvaluebigintuint64Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/getvaluebigintuint64ability/Getvaluebigintuint64Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/getvaluebigintuint64ability/Getvaluebigintuint64Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/getvaluebigintuint64ability/Getvaluebigintuint64Ability.ets index 9355277907..aa335815c8 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/getvaluebigintuint64ability/Getvaluebigintuint64Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/getvaluebigintuint64ability/Getvaluebigintuint64Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Getvaluebigintuint64Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Getvaluebigintuint64Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..990bc7b00c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvaluebigintuint64.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/module.json5 new file mode 100644 index 0000000000..e96cb22303 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getvaluebigintuint64", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Getvaluebigintuint64Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Getvaluebigintuint64Ability", + "srcEntry": "./ets/getvaluebigintuint64ability/Getvaluebigintuint64Ability.ets", + "description": "$string:Getvaluebigintuint64Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Getvaluebigintuint64Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..fadfd15d2a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Getvaluebigintuint64Ability_desc", + "value": "description" + }, + { + "name": "Getvaluebigintuint64Ability_label", + "value": "JsvmAboutBigint" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..a066752b3f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueBigintUint64', 0, async (done: Function) => { + console.log('uitest: TestGetValueBigintUint64 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Getvaluebigintuint64Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Getvaluebigintuint64Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueBigintUint64 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/module.json5 new file mode 100644 index 0000000000..e2f7820c6d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvaluebigintuint64_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/oh-package.json5 new file mode 100644 index 0000000000..adcecf185d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/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": "getvaluebigintwords", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvaluebigintwords.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..f8d4d03e59 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsSix) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(getvaluebigintwords SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvaluebigintwords PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..162e9835af --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/hello.cpp @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_bigint_words] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" +#include +// [StartExclude oh_jsvm_get_value_bigint_words] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" +#define MAX_MALLOC_SIZE 0x800000 + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_bigint_words] + +// OH_JSVM_GetValueBigintWords的样例方法 +static JSVM_Value GetValueBigintWords(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + int signBit = 0; + size_t wordCount = 0; + uint64_t* words{nullptr}; + // 调用OH_JSVM_GetValueBigintWords接口获取wordCount + JSVM_Status status = OH_JSVM_GetValueBigintWords(env, args[0], nullptr, &wordCount, nullptr); + OH_LOG_INFO(LOG_APP, "OH_JSVM_GetValueBigintWords wordCount:%{public}d.", wordCount); + if (wordCount == 0 || wordCount > SOME_REASONABLE_MAX) { + OH_LOG_ERROR(LOG_APP, "Invalid wordCount: %{public}zu", wordCount); + return nullptr; + } + words = (uint64_t*)malloc(wordCount*sizeof(uint64_t)); + if (words == nullptr) { + OH_LOG_ERROR(LOG_APP, "OH_JSVM_GetValueBigintWords malloc failed."); + return nullptr; + } + // 调用OH_JSVM_GetValueBigintWords接口获取传入bigInt相关信息,如:signBit传入bigInt正负信息 + status = OH_JSVM_GetValueBigintWords(env, args[0], &signBit, &wordCount, words); + free(words); + words = nullptr; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "OH_JSVM_GetValueBigintWords fail, status:%{public}d.", status); + } else { + OH_LOG_INFO(LOG_APP, "OH_JSVM_GetValueBigintWords signBit: %{public}d.", signBit); + } + // 将符号位转化为int类型传出去 + JSVM_Value returnValue = nullptr; + OH_JSVM_CreateInt32(env, signBit, &returnValue); + return returnValue; +} +// GetValueBigintWords注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetValueBigintWords}, +}; +static JSVM_CallbackStruct *method = param; +// GetValueBigintWords方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getValueBigintWords", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(getValueBigintWords(BigInt(5555555555555555)))JS"; +// [End oh_jsvm_get_value_bigint_words] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvaluebigintwords", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..9049a01a9c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/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": "libgetvaluebigintwords.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..2a4f046ebf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvaluebigintwords.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/module.json5 new file mode 100644 index 0000000000..8860dbc775 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/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": "getvaluebigintwords", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..4954adb219 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/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": "JsvmAboutBigint" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/main_pages.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/main_pages.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..6c136a7eeb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueBigintWords', 0, async (done: Function) => { + console.log('uitest: TestGetValueBigintWords begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueBigintWords end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/module.json5 new file mode 100644 index 0000000000..0cb4f1d1cd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvaluebigintwords_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/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.1", + "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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/ohosTest.md new file mode 100644 index 0000000000..fc40b5f95e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/ohosTest.md @@ -0,0 +1,13 @@ +# JsvmAboutBigint 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 将C int64_t类型的值转换为JavaScript BigInt类型 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 将C uint64_t类型的值转换为JavaScript BigInt类型 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 将一组无符号64位字转换为单个BigInt值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 返回给定JavaScript BigInt的C int64_t基础类型等价值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 返回给定JavaScript BigInt的C uint64_t基础类型等价值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 将单个BigInt值转换为一个符号位、一个64位的小端数组和该数组的长度 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/screenshots/JsvmAboutBigint_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/screenshots/JsvmAboutBigint_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/screenshots/JsvmAboutBigint_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/screenshots/JsvmAboutBigint_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/screenshots/JsvmAboutBigint_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/screenshots/JsvmAboutBigint_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/screenshots/JsvmAboutBigint_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/screenshots/JsvmAboutBigint_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/app.json5 new file mode 100644 index 0000000000..40f0a262da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/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.jsvmaboutclass", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..ebd7615cae --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmAboutClass" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/README.md new file mode 100644 index 0000000000..0a5473cf1e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/README.md @@ -0,0 +1,113 @@ +# ArkTS使用JSVM接口进行class相关开发 + +### 介绍 + +使用JSVM-API接口进行class相关开发,处理JavaScript中的类,例如定义类、构造实例等。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM进行class相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-class.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +|:------------------------------------------------------------------:|:------------------------------------------------------------------:| +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +defineclass/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +newinstance/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +removewrap/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/build-profile.json5 new file mode 100644 index 0000000000..2b6d0c3ba4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/build-profile.json5 @@ -0,0 +1,82 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "newinstance", + "srcPath": "./newinstance", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "defineclass", + "srcPath": "./defineclass", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "removewrap", + "srcPath": "./removewrap", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/code-linter.json5 diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/oh-package.json5 new file mode 100644 index 0000000000..64b19291d0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/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": "defineclass", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libdefineclass.so": "file:./src/main/cpp/types/libdefineclass" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..59145d6c51 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutClass) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(defineclass SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(defineclass PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..6bdc26d598 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/hello.cpp @@ -0,0 +1,207 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" +// [Start oh_jsvm_defineclass] +#include +// [StartExclude oh_jsvm_defineclass] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_defineclass] + +JSVM_Value CreateInstance(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_Value newTarget; + // 获取构造函数的new.target值 + JSVM_CALL(OH_JSVM_GetNewTarget(env, info, &newTarget)); + OH_LOG_INFO(LOG_APP, "Create Instance"); + OH_LOG_INFO(LOG_APP, + "NAPI MyObject::New %{public}s", + newTarget != nullptr ? "newTarget != nullptr" : "newTarget == nullptr"); + JSVM_Value jsObject = nullptr; + JSVM_CALL(OH_JSVM_CreateObject(env, &jsObject)); + JSVM_Value jsName = nullptr; + JSVM_CALL(OH_JSVM_CreateStringUtf8(env, "name", JSVM_AUTO_LENGTH, &jsName)); + JSVM_Value jsValue = nullptr; + JSVM_CALL(OH_JSVM_CreateStringUtf8(env, "lilei", JSVM_AUTO_LENGTH, &jsValue)); + JSVM_CALL(OH_JSVM_SetProperty(env, jsObject, jsName, jsValue)); + return jsObject; +} + +std::string ToString(JSVM_Env env, JSVM_Value val) +{ + JSVM_Value jsonString; + JSVM_CALL(OH_JSVM_JsonStringify(env, val, &jsonString)); + size_t totalLen = 0; + JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, nullptr, 0, &totalLen)); + size_t needLen = totalLen + 1; + char* buff = new char[needLen]; + std::memset(buff, 0, needLen); + JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, buff, needLen, &totalLen)); + std::string str(buff); + delete[] buff; + return str; +} + +// 封装c++中的自定义数据结构 +JSVM_Value DefineClass(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_CallbackStruct param; + param.data = nullptr; + param.callback = CreateInstance; + JSVM_Value cons; + // 用于在JavaScript中定义一个类 + JSVM_CALL(OH_JSVM_DefineClass(env, "MyObject", JSVM_AUTO_LENGTH, ¶m, 0, nullptr, &cons)); + JSVM_Value instanceValue = nullptr; + // 作为class的构造函数调用 + JSVM_CALL(OH_JSVM_NewInstance(env, cons, 0, nullptr, &instanceValue)); + std::string str = ToString(env, instanceValue); + OH_LOG_INFO(LOG_APP, "NewInstance:%{public}s", str.c_str()); + + // 作为普通的函数调用 + JSVM_Value global; + JSVM_CALL(OH_JSVM_GetGlobal(env, &global)); + JSVM_Value key; + JSVM_CALL(OH_JSVM_CreateStringUtf8(env, "Constructor", JSVM_AUTO_LENGTH, &key)); + JSVM_CALL(OH_JSVM_SetProperty(env, global, key, cons)); + JSVM_Value result; + JSVM_CALL(OH_JSVM_CallFunction(env, global, cons, 0, nullptr, &result)); + std::string buf = ToString(env, result); + OH_LOG_INFO(LOG_APP, "NewInstance:%{public}s", buf.c_str()); + return nullptr; +} + +// 注册DefineClass的方法 +JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = DefineClass}, +}; + +static JSVM_CallbackStruct *method = param; + +// DefineClass方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"defineClass", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// [End oh_jsvm_defineclass] + +const char *SRC_CALL_NATIVE = R"JS( defineClass(); )JS"; + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "defineclass", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/oh-package.json5 new file mode 100644 index 0000000000..d658bf92ef --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/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": "libdefineclass.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/defineclassability/DefineclassAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/defineclassability/DefineclassAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/defineclassability/DefineclassAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/defineclassability/DefineclassAbility.ets index 8d53596cef..98602fa428 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/defineclassability/DefineclassAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/defineclassability/DefineclassAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class DefineclassAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class DefineclassAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..f7a286b6ee --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libdefineclass.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/module.json5 new file mode 100644 index 0000000000..98a4883aad --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "defineclass", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "DefineclassAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "DefineclassAbility", + "srcEntry": "./ets/defineclassability/DefineclassAbility.ets", + "description": "$string:DefineclassAbility_desc", + "icon": "$media:layered_image", + "label": "$string:DefineclassAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/module.json5 new file mode 100644 index 0000000000..2ca6465546 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "defineclass_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/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.1", + "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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigorfile.ts diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/oh-package.json5 new file mode 100644 index 0000000000..8cdef9667a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/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": "newinstance", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libnewinstance.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..bbd46b2a34 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutClass) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(newinstance SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(newinstance PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..5f41d96861 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/hello.cpp @@ -0,0 +1,176 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" +// [Start oh_jsvm_newinstance] +#include +// [StartExclude oh_jsvm_newinstance] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_newinstance] + +std::string ToString(JSVM_Env env, JSVM_Value val) +{ + JSVM_Value jsonString; + JSVM_CALL(OH_JSVM_JsonStringify(env, val, &jsonString)); + size_t totalLen = 0; + JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, nullptr, 0, &totalLen)); + size_t needLen = totalLen + 1; + char* buff = new char[needLen]; + std::memset(buff, 0, needLen); + JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, buff, needLen, &totalLen)); + std::string str(buff); + delete[] buff; + return str; +} + +// OH_JSVM_NewInstance的样例方法 +static JSVM_Value NewInstance(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取js侧传入的两个参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr)); + JSVM_Value result = nullptr; + // 调用OH_JSVM_NewInstance接口,实例化一个对象,将这个对象返回 + JSVM_CALL(OH_JSVM_NewInstance(env, args[0], 1, &args[1], &result)); + std::string str = ToString(env, result); + OH_LOG_INFO(LOG_APP, "NewInstance:%{public}s", str.c_str()); + return nullptr; +} + +// 通过给定的构造函数,构建一个实例。 +// NewInstance注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = NewInstance}, +}; + +static JSVM_CallbackStruct *method = param; + +// NewInstance方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"newInstance", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// [End oh_jsvm_newinstance] + +const char *SRC_CALL_NATIVE = R"JS( function Fruit(name) { this.name = name; } newInstance(Fruit, "apple"); )JS"; + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "newinstance", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..87c3109518 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/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": "libnewinstance.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..072eebfa6b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libnewinstance.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/module.json5 new file mode 100644 index 0000000000..c62425b62d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/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": "newinstance", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/layered_image.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/layered_image.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/module.json5 new file mode 100644 index 0000000000..9ce5eb8c27 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "newinstance_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/ohosTest.md new file mode 100644 index 0000000000..837470505b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/ohosTest.md @@ -0,0 +1,10 @@ +# JsvmAboutClass 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|------------------------------------| ------------ |------------------------| ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 在JavaScript中定义一个类,并与对应的C类进行封装和交互 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 通过给定的构造函数,构建一个实例 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 解包先前封装在JavaScript对象中的原生实例并释放封装 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/oh-package.json5 new file mode 100644 index 0000000000..9c974bf11b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/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": "removewrap", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libremovewrap.so": "file:./src/main/cpp/types/libremovewrap" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..a0d5309512 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutClass) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(removewrap SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(removewrap PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..f60452cc78 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/hello.cpp @@ -0,0 +1,209 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" +// [Start oh_jsvm_removewrap] +#include +// [StartExclude oh_jsvm_removewrap] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_removewrap] + +// OH_JSVM_GetNewTarget、OH_JSVM_DefineClass、OH_JSVM_Wrap、OH_JSVM_Unwrap、OH_JSVM_RemoveWrap的样例方法 + +// 自定义类结构体Object +struct Object { + std::string name; + int32_t age; +}; + +// 定义一个回调函数 +static void DerefItem(JSVM_Env env, void *data, void *hint) +{ + OH_LOG_INFO(LOG_APP, "JSVM deref_item"); + (void)hint; +} + +static JSVM_Value WrapObject(JSVM_Env env, JSVM_CallbackInfo info) +{ + OH_LOG_INFO(LOG_APP, "JSVM wrap"); + Object obj; + // 设置Object属性 + obj.name = "lilei"; + const int adultAge = 18; + obj.age = adultAge; + Object *objPointer = &obj; + // 获取回调信息中的参数数量和将要被封装的值 + size_t argc = 1; + JSVM_Value toWrap = nullptr; + JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, &toWrap, nullptr, nullptr)); + // OH_JSVM_Wrap将自定义结构Object进行封装 + JSVM_CALL(OH_JSVM_Wrap(env, toWrap, reinterpret_cast(objPointer), DerefItem, NULL, NULL)); + Object *data; + // OH_JSVM_UnWrap解包先前封装在JavaScript对象中的原生实例 + JSVM_CALL(OH_JSVM_Unwrap(env, toWrap, reinterpret_cast(&data))); + OH_LOG_INFO(LOG_APP, "JSVM name: %{public}s", data->name.c_str()); + OH_LOG_INFO(LOG_APP, "JSVM age: %{public}d", data->age); + return nullptr; +} + +static JSVM_Value RemoveWrap(JSVM_Env env, JSVM_CallbackInfo info) +{ + OH_LOG_INFO(LOG_APP, "JSVM removeWrap"); + Object obj; + // 设置Object属性 + obj.name = "lilei"; + const int adultAge = 18; + obj.age = adultAge; + Object *objPointer = &obj; + // 获取回调信息中的参数数量和将要被封装的值 + size_t argc = 1; + JSVM_Value toWrap = nullptr; + JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, &toWrap, nullptr, nullptr)); + // 将自定义结构Object封装 + JSVM_CALL(OH_JSVM_Wrap(env, toWrap, reinterpret_cast(objPointer), DerefItem, NULL, NULL)); + Object *data; + // 解包先前封装的object,并移除封装 + JSVM_CALL(OH_JSVM_RemoveWrap(env, toWrap, reinterpret_cast(&objPointer))); + // 检查是否已被移除 + JSVM_Status status = OH_JSVM_Unwrap(env, toWrap, reinterpret_cast(&data)); + if (status != JSVM_OK) { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_RemoveWrap success"); + } + return nullptr; +} + +// WrapObject、RemoveWrap注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = WrapObject}, + {.data = nullptr, .callback = RemoveWrap}, +}; +static JSVM_CallbackStruct *method = param; +// WrapObject、RemoveWrap方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"wrapObject", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, + {"removeWrap", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// [End oh_jsvm_removewrap] + +const char *SRC_CALL_NATIVE = R"JS( class Obj {}; wrapObject(new Obj()); removeWrap(new Obj()); )JS"; + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "removewrap", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/oh-package.json5 new file mode 100644 index 0000000000..8d69688ce4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/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": "libremovewrap.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..59959343b3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libremovewrap.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/removewrapability/RemovewrapAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/removewrapability/RemovewrapAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/removewrapability/RemovewrapAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/removewrapability/RemovewrapAbility.ets index e2615e64a5..2baa653836 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/removewrapability/RemovewrapAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/removewrapability/RemovewrapAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class RemovewrapAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class RemovewrapAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/module.json5 new file mode 100644 index 0000000000..dba5b8b160 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "removewrap", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "RemovewrapAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "RemovewrapAbility", + "srcEntry": "./ets/removewrapability/RemovewrapAbility.ets", + "description": "$string:RemovewrapAbility_desc", + "icon": "$media:layered_image", + "label": "$string:RemovewrapAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/module.json5 new file mode 100644 index 0000000000..89b6b4602d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "removewrap_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/screenshots/JsvmAboutClass_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/screenshots/JsvmAboutClass_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/screenshots/JsvmAboutClass_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/screenshots/JsvmAboutClass_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/screenshots/JsvmAboutClass_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/screenshots/JsvmAboutClass_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/screenshots/JsvmAboutClass_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/screenshots/JsvmAboutClass_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/app.json5 new file mode 100644 index 0000000000..7dc0586640 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/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.jsvmaboutdate", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..5afae2877f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmAboutDate" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/README.md new file mode 100644 index 0000000000..c738d7bf6a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/README.md @@ -0,0 +1,113 @@ +# ArkTS使用JSVM-API接口进行Date相关开发 + +### 介绍 + +JSVM-API中date相关接口用于处理JavaScript Date对象,并在JSVM模块和JavaScript代码之间进行日期数据的转换和处理。这对于在JSVM模块中处理时间和日期相关逻辑非常有用。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口进行Date相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-date.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :---------------------------------------------------------------: | :---------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +createdate/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getdatevalue/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +isdate/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/build-profile.json5 new file mode 100644 index 0000000000..6cbe1b8c78 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/build-profile.json5 @@ -0,0 +1,82 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "createdate", + "srcPath": "./createdate", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getdatevalue", + "srcPath": "./getdatevalue", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "isdate", + "srcPath": "./isdate", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/oh-package.json5 new file mode 100644 index 0000000000..85cea6f4b8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/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": "createdate", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatedate.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..554f98f9c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutDate) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createdate SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createdate PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..cea5b52e7c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/hello.cpp @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_date] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" +#include +// [StartExclude oh_jsvm_create_date] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_date] + +// OH_JSVM_CreateDate的样例方法 +static JSVM_Value CreateDate(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 通过c接口获取Unix纪元以来经过的秒数,并转化为毫秒数为单位 + double value = static_cast(time(nullptr) * 1000); + // 调用OH_JSVM_CreateDate接口将double值转换成表示日期时间的JavaScript值返回出去 + JSVM_Value returnValue = nullptr; + + JSVM_CALL(OH_JSVM_CreateDate(env, value, &returnValue)); + + bool isDate; + JSVM_CALL(OH_JSVM_IsDate(env, returnValue, &isDate)); + if (isDate == false) { + OH_LOG_ERROR(LOG_APP, "JSVM IsDate fail"); + return returnValue; + } + + value = 0; + JSVM_CALL(OH_JSVM_GetDateValue(env, returnValue, &value)); + + uint64_t time = static_cast(value) / 1000; + char *date = ctime(reinterpret_cast(&time)); + OH_LOG_INFO(LOG_APP, "JSVM CreateDate success:%{public}s", date); + + return returnValue; +} + +// CreateDate注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateDate}, +}; +static JSVM_CallbackStruct *method = param; +// CreateDate方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createDate", nullptr, method, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(createDate())JS"; +// [End oh_jsvm_create_date] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createdate", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..98100150ef --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/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": "libcreatedate.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..49fca32a24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatedate.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/module.json5 new file mode 100644 index 0000000000..340f4e73ed --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/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": "createdate", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..460a69fe45 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/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": "JsvmAboutDate" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..09099662a5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateDate', 0, async (done: Function) => { + console.log('uitest: TestCreateDate begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateDate end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/module.json5 new file mode 100644 index 0000000000..7e1ae01ec3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createdate_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/oh-package.json5 new file mode 100644 index 0000000000..d87886f1cc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/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": "getdatevalue", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetdatevalue.so": "file:./src/main/cpp/types/libgetdatevalue" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..519bebf639 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutDate) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(getdatevalue SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getdatevalue PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..b45bc5a637 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" +// [Stat oh_jsvm_get_date_value] +#include +// [StartExclude oh_jsvm_get_date_value] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_date_value] + +// OH_JSVM_GetDateValue的样例方法 +static JSVM_Value GetDateValue(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr)); + // 获取传入的Unix Time Stamp时间 + double value; + JSVM_CALL(OH_JSVM_GetDateValue(env, args[0], &value)); + + // 将获取到的Unix Time Stamp时间转化为日期字符串打印 + uint64_t time = static_cast(value) / 1000; + char *date = ctime(reinterpret_cast(&time)); + OH_LOG_INFO(LOG_APP, "JSVM GetDateValue success:%{public}s", date); + + JSVM_Value returnValue = nullptr; + JSVM_CALL(OH_JSVM_CreateDouble(env, value, &returnValue)); + return returnValue; +} + +// CreateDate注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetDateValue}, +}; +static JSVM_CallbackStruct *method = param; +// CreateDate方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getDateValue", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(getDateValue(new Date(Date.now())))JS"; +// [End oh_jsvm_get_date_value] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getdatevalue", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/oh-package.json5 new file mode 100644 index 0000000000..a4f8967b57 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/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": "libgetdatevalue.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/getdatevalueability/GetdatevalueAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/getdatevalueability/GetdatevalueAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/getdatevalueability/GetdatevalueAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/getdatevalueability/GetdatevalueAbility.ets index 0761432481..4197cee54f --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/getdatevalueability/GetdatevalueAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/getdatevalueability/GetdatevalueAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetdatevalueAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetdatevalueAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..fedabe9554 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetdatevalue.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/module.json5 new file mode 100644 index 0000000000..54da6858a0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getdatevalue", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetdatevalueAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetdatevalueAbility", + "srcEntry": "./ets/getdatevalueability/GetdatevalueAbility.ets", + "description": "$string:GetdatevalueAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetdatevalueAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..56aaf0feaa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetdatevalueAbility_desc", + "value": "description" + }, + { + "name": "GetdatevalueAbility_label", + "value": "JsvmAboutDate" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..8740d051bd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetDateValue', 0, async (done: Function) => { + console.log('uitest: TestGetDateValue begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetdatevalueAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetdatevalueAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetDateValue end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/module.json5 new file mode 100644 index 0000000000..7029c62d68 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getdatevalue_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/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.1", + "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/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/oh-package.json5 new file mode 100644 index 0000000000..66e0533be2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/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": "isdate", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libisdate.so": "file:./src/main/cpp/types/libisdate" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..ecb3665d33 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutDate) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(isdate SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(isdate PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..fb7e36d3aa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/hello.cpp @@ -0,0 +1,155 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_is_date] +// OH_JSVM_IsDate的样例方法 +static JSVM_Value IsDate(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr)); + bool isData; + JSVM_CALL(OH_JSVM_IsDate(env, args[0], &isData)); + OH_LOG_INFO(LOG_APP, "JSVM IsDate success:%{public}d", isData); + + JSVM_Value result = nullptr; + JSVM_CALL(OH_JSVM_GetBoolean(env, isData, &result)); + return result; +} +// CreateDate注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = IsDate}, +}; +static JSVM_CallbackStruct *method = param; +// CreateDate方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"isDate", nullptr, method, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(isDate(new Date(Date.now())))JS"; +// [End oh_jsvm_is_date] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "isdate", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/Index.d.ts new file mode 100644 index 0000000000..f5bb4004b0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/oh-package.json5 new file mode 100644 index 0000000000..1e49a449d5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/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": "libisdate.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/isdateability/IsdateAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/isdateability/IsdateAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/isdateability/IsdateAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/isdateability/IsdateAbility.ets index 823473d99a..29f9cd7504 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/isdateability/IsdateAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/isdateability/IsdateAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class IsdateAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class IsdateAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..9114e76f35 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libisdate.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/module.json5 new file mode 100644 index 0000000000..7d8595bb96 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "isdate", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "IsdateAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "IsdateAbility", + "srcEntry": "./ets/isdateability/IsdateAbility.ets", + "description": "$string:IsdateAbility_desc", + "icon": "$media:layered_image", + "label": "$string:IsdateAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..c52973df98 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "IsdateAbility_desc", + "value": "description" + }, + { + "name": "IsdateAbility_label", + "value": "JsvmAboutDate" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..cc16b02e16 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testIsDate', 0, async (done: Function) => { + console.log('uitest: TestIsDate begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'IsdateAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('IsdateAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestIsDate end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/module.json5 new file mode 100644 index 0000000000..70177e87b6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "isdate_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/ohosTest.md new file mode 100644 index 0000000000..1e30ecb80f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/ohosTest.md @@ -0,0 +1,10 @@ +# JsvmAboutDate 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 创建了一个表示给定毫秒数的Date对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定JavaScript Date的时间值的Double基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 判断一个JavaScript对象是否为Date类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/screenshots/JsvmAboutDate_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/screenshots/JsvmAboutDate_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/screenshots/JsvmAboutDate_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/screenshots/JsvmAboutDate_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/screenshots/JsvmAboutDate_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/screenshots/JsvmAboutDate_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/screenshots/JsvmAboutDate_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/screenshots/JsvmAboutDate_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/app.json5 new file mode 100644 index 0000000000..dda9643653 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/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.jsvmaboutobject", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..ef233ddf99 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmAboutObject" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/README.md new file mode 100644 index 0000000000..54b11900f7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/README.md @@ -0,0 +1,273 @@ +# ArkTS使用JSVM-API接口进行object相关开发 + +### 介绍 + +使用JSVM-API接口进行object相关开发,处理JavaScript对象的基本操作的功能,例如创建对象、获取原型、冻结和密封对象,检查对象的类型等。这些操作是在处理JavaScript对象时非常常见的,提供了一种与JavaScript对象交互的方式。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口进行object相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-object.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :-----------------------------------------------------------------: | :-----------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +checkobjecttypetag/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createexternal/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createobject/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createsymbol/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getprototype/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvalueexternal/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +instanceof/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +objectfreeze/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +objectseal/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +symbolfor/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +typeof/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/build-profile.json5 new file mode 100644 index 0000000000..71d1cf384f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/build-profile.json5 @@ -0,0 +1,178 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "getprototype", + "srcPath": "./getprototype", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createobject", + "srcPath": "./createobject", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "objectfreeze", + "srcPath": "./objectfreeze", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "objectseal", + "srcPath": "./objectseal", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "typeof", + "srcPath": "./typeof", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "instanceof", + "srcPath": "./instanceof", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "checkobjecttypetag", + "srcPath": "./checkobjecttypetag", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createexternal", + "srcPath": "./createexternal", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getvalueexternal", + "srcPath": "./getvalueexternal", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createsymbol", + "srcPath": "./createsymbol", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "symbolfor", + "srcPath": "./symbolfor", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/oh-package.json5 new file mode 100644 index 0000000000..2ca9a7fcfe --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/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": "checkobjecttypetag", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcheckobjecttypetag.so": "file:./src/main/cpp/types/libcheckobjecttypetag" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..ededd4e117 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(checkobjecttypetag SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(checkobjecttypetag PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..c27886bdfc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/hello.cpp @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_check_object_type_tag] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" +#define NUMBERINT_FOUR +// [StartExclude oh_jsvm_check_object_type_tag] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_check_object_type_tag] + +// 定义一个静态常量JSVM_TypeTag数组存储类型标签 +static const JSVM_TypeTag TagsData[NUMBERINT_FOUR] = { + {0x9e4b2449547061b3, 0x33999f8a6516c499}, + {0x1d55a794c53a726d, 0x43633f509f9c944e}, + {0, 0}, // 用于表示无标签或默认标签 + {0x6a971439f5b2e5d7, 0x531dc28a7e5317c0}, +}; +// OH_JSVM_TypeTagObject的样例方法 +static JSVM_Value SetTypeTagToObject(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取两个JavaScript侧传入的参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 获取索引数字转换为JSVM_Value + int32_t index = 0; + OH_JSVM_GetValueInt32(env, args[1], &index); + // 给参数(对象)设置类型标签 + JSVM_Status status = OH_JSVM_TypeTagObject(env, args[0], &TagsData[index]); + // 将bool结果转换为JSVM_Value并返回 + JSVM_Value result = nullptr; + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM SetTypeTagToObject fail"); + OH_JSVM_GetBoolean(env, false, &result); + } else { + OH_LOG_INFO(LOG_APP, "JSVM SetTypeTagToObject success"); + OH_JSVM_GetBoolean(env, true, &result); + } + return result; +} +// OH_JSVM_CheckObjectTypeTag的样例方法 +static JSVM_Value CheckObjectTypeTag(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取两个JavaScript侧传入的参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 获取索引数字转换为JSVM_Value + int32_t index = 0; + OH_JSVM_GetValueInt32(env, args[1], &index); + // 检查对象的类型标签 + bool checkResult = false; + JSVM_Status status = OH_JSVM_CheckObjectTypeTag(env, args[0], &TagsData[index], &checkResult); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM SetTypeTagToObject fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM SetTypeTagToObject:%{public}d", checkResult); + } + // 将bool结果转换为JSVM_Value并返回 + JSVM_Value checked = nullptr; + OH_JSVM_GetBoolean(env, checkResult, &checked); + return checked; +} +// SetTypeTagToObject,CheckObjectTypeTag注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = SetTypeTagToObject}, + {.data = nullptr, .callback = CheckObjectTypeTag}, +}; +static JSVM_CallbackStruct *method = param; +// SetTypeTagToObject,CheckObjectTypeTag方法别名,TS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"setTypeTagToObject", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, + {"checkObjectTypeTag", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS( + class Obj { + data; + message; + } + let obj= { data: 0, message: "hello world"}; + setTypeTagToObject(obj, 0); + checkObjectTypeTag(obj, 0);)JS"; +// [End oh_jsvm_check_object_type_tag] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "checkobjecttypetag", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/oh-package.json5 new file mode 100644 index 0000000000..0e9da98204 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/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": "libcheckobjecttypetag.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/checkobjecttypetagability/CheckobjecttypetagAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/checkobjecttypetagability/CheckobjecttypetagAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/checkobjecttypetagability/CheckobjecttypetagAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/checkobjecttypetagability/CheckobjecttypetagAbility.ets index 01897d10b7..d4572bdd88 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/checkobjecttypetagability/CheckobjecttypetagAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/checkobjecttypetagability/CheckobjecttypetagAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CheckobjecttypetagAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CheckobjecttypetagAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..79ccd79a8e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcheckobjecttypetag.so'; + +@Entry +@Component +struct Index { + @State message: string = 'OH_JSVM_CheckObjectTypeTag'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/module.json5 new file mode 100644 index 0000000000..146fe9ab4a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "checkobjecttypetag", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CheckobjecttypetagAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CheckobjecttypetagAbility", + "srcEntry": "./ets/checkobjecttypetagability/CheckobjecttypetagAbility.ets", + "description": "$string:CheckobjecttypetagAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CheckobjecttypetagAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..31eca34aa4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CheckobjecttypetagAbility_desc", + "value": "description" + }, + { + "name": "CheckobjecttypetagAbility_label", + "value": "JsvmAboutObject" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..e718a6bda7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCheckObjectTypeTag', 0, async (done: Function) => { + console.log('uitest: TestCheckObjectTypeTag begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CheckobjecttypetagAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CheckobjecttypetagAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCheckObjectTypeTag end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/module.json5 new file mode 100644 index 0000000000..12d16b4f61 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "checkobjecttypetag_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/oh-package.json5 new file mode 100644 index 0000000000..a08c514223 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/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": "createexternal", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreateexternal.so": "file:./src/main/cpp/types/libcreateexternal" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..97202c0cfa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createexternal SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createexternal PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..6eb4034c4a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/hello.cpp @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_external] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" +#include +#include +// [StartExclude oh_jsvm_create_external] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_external] + +// OH_JSVM_CreateExternal的样例方法 +static JSVM_Value CreateExternal(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t dataSize = 10; + void *data = malloc(dataSize); + if (data == nullptr) { + OH_LOG_ERROR(LOG_APP, "JSVM Failed to malloc."); + return nullptr; + } + memset(data, 0, dataSize); + const char* testStr = "test"; + JSVM_Value external = nullptr; + JSVM_Status status = OH_JSVM_CreateExternal( + env, data, [](JSVM_Env env, void *data, void *hint) {free(data);}, (void *)testStr, &external); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM Failed to create external data, status:%{public}d.", status); + free(data); + data = nullptr; + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateExternal success"); + } + return external; +} +// CreateExternal注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateExternal}, +}; +static JSVM_CallbackStruct *method = param; +// CreateExternal方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createExternal", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(createExternal())JS"; +// [End oh_jsvm_create_external] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createexternal", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/oh-package.json5 new file mode 100644 index 0000000000..be27396720 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/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": "libcreateexternal.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/createexternalability/CreateexternalAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/createexternalability/CreateexternalAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/createexternalability/CreateexternalAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/createexternalability/CreateexternalAbility.ets index 0b554dac92..a1d7aa147c --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/createexternalability/CreateexternalAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/createexternalability/CreateexternalAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreateexternalAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreateexternalAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..895125b49b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreateexternal.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/module.json5 new file mode 100644 index 0000000000..7cfef6f75e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createexternal", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreateexternalAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreateexternalAbility", + "srcEntry": "./ets/createexternalability/CreateexternalAbility.ets", + "description": "$string:CreateexternalAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreateexternalAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..477cec44f8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreateexternalAbility_desc", + "value": "description" + }, + { + "name": "CreateexternalAbility_label", + "value": "JsvmAboutObject" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..67f1a8df72 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateExternal', 0, async (done: Function) => { + console.log('uitest: TestCreateExternal begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreateexternalAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreateexternalAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateExternal end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/module.json5 new file mode 100644 index 0000000000..3d00fb89ec --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createexternal_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/oh-package.json5 new file mode 100644 index 0000000000..92e42ff1a8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/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": "createobject", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreateobject.so": "file:./src/main/cpp/types/libcreateobject" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..bf64802363 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createobject SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createobject PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..2f0966b941 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/hello.cpp @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_object] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_create_object] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_object] + +// OH_JSVM_CreateObject的样例方法 +static JSVM_Value CreateObject(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_Value object = nullptr; + // 创建一个空对象 + JSVM_Status status = OH_JSVM_CreateObject(env, &object); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateObject fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateObject success"); + } + // 设置对象的属性 + JSVM_Value name = nullptr; + // 设置属性名为 "name" + OH_JSVM_CreateStringUtf8(env, "name", JSVM_AUTO_LENGTH, &name); + JSVM_Value value = nullptr; + // 设置属性值为 "Hello from N-API!" + OH_JSVM_CreateStringUtf8(env, "Hello OH_JSVM_CreateObject!", JSVM_AUTO_LENGTH, &value); + // 将属性设置到对象上 + OH_JSVM_SetProperty(env, object, name, value); + return object; +} +// CreateObject注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateObject}, +}; +static JSVM_CallbackStruct *method = param; +// CreateObject方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createObject", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(createObject())JS"; +// [End oh_jsvm_create_object] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createobject", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/oh-package.json5 new file mode 100644 index 0000000000..f3b6325712 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/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": "libcreateobject.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/createobjectability/CreateobjectAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/createobjectability/CreateobjectAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/createobjectability/CreateobjectAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/createobjectability/CreateobjectAbility.ets index 28e01f58b9..7ba5ff339f --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/createobjectability/CreateobjectAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/createobjectability/CreateobjectAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreateobjectAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreateobjectAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..81c6c22b04 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreateobject.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/module.json5 new file mode 100644 index 0000000000..80b23bf8c7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createobject", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreateobjectAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreateobjectAbility", + "srcEntry": "./ets/createobjectability/CreateobjectAbility.ets", + "description": "$string:CreateobjectAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreateobjectAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..bb24ee9ff9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreateobjectAbility_desc", + "value": "description" + }, + { + "name": "CreateobjectAbility_label", + "value": "JsvmAboutObject" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..9eaa609e06 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateObject', 0, async (done: Function) => { + console.log('uitest: TestCreateObject begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreateobjectAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreateobjectAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateObject end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/module.json5 new file mode 100644 index 0000000000..34d9e19e41 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createobject_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/oh-package.json5 new file mode 100644 index 0000000000..b4e40ae109 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/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": "createsymbol", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatesymbol.so": "file:./src/main/cpp/types/libcreatesymbol" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..5aab5eaaa2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createsymbol SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createsymbol PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..82f0935c3e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/hello.cpp @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_symbol] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" +// [StartExclude oh_jsvm_create_symbol] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_symbol] + +// OH_JSVM_CreateSymbol的样例方法 +static JSVM_Value CreateSymbol(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_Value result = nullptr; + const char *des = "only"; + OH_JSVM_CreateStringUtf8(env, des, JSVM_AUTO_LENGTH, &result); + JSVM_Value returnSymbol = nullptr; + OH_JSVM_CreateSymbol(env, result, &returnSymbol); + JSVM_ValueType valuetypeSymbol; + OH_JSVM_Typeof(env, returnSymbol, &valuetypeSymbol); + if (valuetypeSymbol == JSVM_SYMBOL) { + OH_LOG_INFO(LOG_APP, "JSVM CreateSymbol Success"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateSymbol fail"); + } + return returnSymbol; +} +// CreateSymbol注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateSymbol}, +}; +static JSVM_CallbackStruct *method = param; +// CreateSymbol方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createSymbol", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(createSymbol())JS"; +// [End oh_jsvm_create_symbol] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createsymbol", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/oh-package.json5 new file mode 100644 index 0000000000..3a1844f0f4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/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": "libcreatesymbol.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/createsymbolability/CreatesymbolAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/createsymbolability/CreatesymbolAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/createsymbolability/CreatesymbolAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/createsymbolability/CreatesymbolAbility.ets index 6b997d7434..c1ec919eeb --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/createsymbolability/CreatesymbolAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/createsymbolability/CreatesymbolAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreatesymbolAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreatesymbolAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..7aea0e0474 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatesymbol.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/module.json5 new file mode 100644 index 0000000000..5bd3807a9e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createsymbol", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreatesymbolAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreatesymbolAbility", + "srcEntry": "./ets/createsymbolability/CreatesymbolAbility.ets", + "description": "$string:CreatesymbolAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreatesymbolAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..51f7a08669 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreatesymbolAbility_desc", + "value": "description" + }, + { + "name": "CreatesymbolAbility_label", + "value": "JsvmAboutObject" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..ecf83c2a13 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateSymbol', 0, async (done: Function) => { + console.log('uitest: TestCreateSymbol begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreatesymbolAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreatesymbolAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateSymbol end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/module.json5 new file mode 100644 index 0000000000..fea12ddaa8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createsymbol_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/oh-package.json5 new file mode 100644 index 0000000000..74058a69ff --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/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": "getprototype", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetprototype.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..f95e3b6e48 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(getprototype SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getprototype PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..aa7698ee35 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/hello.cpp @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_prototype] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" +// [StartExclude oh_jsvm_get_prototype] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_prototype] + +// GetPrototype注册回调 +// OH_JSVM_GetPrototype的样例方法 +static JSVM_Value GetPrototype(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + JSVM_Value result{nullptr}; + JSVM_Status status = OH_JSVM_GetPrototype(env, argv[0], &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetPrototype fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetPrototype success"); + } + return result; +} +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetPrototype}, +}; +static JSVM_CallbackStruct *method = param; +// GetPrototype方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getPrototype", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(const myObject = {}; + const proto = getPrototype(myObject); + console.log(proto === Object.prototype);)JS"; +// [End oh_jsvm_get_prototype] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getprototype", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..dc2fbe8986 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/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": "libgetprototype.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..52727f910a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetprototype.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/module.json5 new file mode 100644 index 0000000000..8e78e77d7e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/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": "getprototype", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..3da670abdb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/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": "JsvmAboutObject" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..9064d60bce --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetPrototype', 0, async (done: Function) => { + console.log('uitest: TestGetPrototype begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetPrototype end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/module.json5 new file mode 100644 index 0000000000..8d28f054f1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getprototype_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/oh-package.json5 new file mode 100644 index 0000000000..e3853ee142 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/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": "getvalueexternal", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvalueexternal.so": "file:./src/main/cpp/types/libgetvalueexternal" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..c5b9dd4661 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getvalueexternal SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvalueexternal PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..ff0511a632 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/hello.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_external] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_get_value_external] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_external] + +// OH_JSVM_GetValueExternal的样例方法 +static JSVM_Value GetValueExternal(JSVM_Env env, JSVM_CallbackInfo info) +{ + static int data = 0x12345; + JSVM_Value externalValue = nullptr; + JSVM_Status status = OH_JSVM_CreateExternal(env, (void*)&data, nullptr, nullptr, &externalValue); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CreateExternal fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CreateExternal success"); + } + void *dataValue; + status = OH_JSVM_GetValueExternal(env, externalValue, &dataValue); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetValueExternal fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetValueExternal success"); + } + // 将符号位转化为int类型传出去 + JSVM_Value returnValue = nullptr; + int retData = *static_cast(dataValue); + OH_JSVM_CreateInt32(env, retData, &returnValue); + return returnValue; +} +// GetValueExternal注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetValueExternal}, +}; +static JSVM_CallbackStruct *method = param; +// GetValueExternal方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getValueExternal", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(getValueExternal())JS"; +// [End oh_jsvm_get_value_external] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvalueexternal", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/oh-package.json5 new file mode 100644 index 0000000000..3a52b5b551 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/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": "libgetvalueexternal.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/getvalueexternalability/GetvalueexternalAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/getvalueexternalability/GetvalueexternalAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/getvalueexternalability/GetvalueexternalAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/getvalueexternalability/GetvalueexternalAbility.ets index e7c7abb34e..854e76dae7 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/getvalueexternalability/GetvalueexternalAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/getvalueexternalability/GetvalueexternalAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetvalueexternalAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetvalueexternalAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..75b4b1456e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvalueexternal.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/module.json5 new file mode 100644 index 0000000000..478a853dbc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getvalueexternal", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetvalueexternalAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetvalueexternalAbility", + "srcEntry": "./ets/getvalueexternalability/GetvalueexternalAbility.ets", + "description": "$string:GetvalueexternalAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetvalueexternalAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..15cee882c6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetvalueexternalAbility_desc", + "value": "description" + }, + { + "name": "GetvalueexternalAbility_label", + "value": "JsvmAboutObject" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..8a0d1cd86e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueExternal', 0, async (done: Function) => { + console.log('uitest: TestGetValueExternal begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetvalueexternalAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetvalueexternalAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueExternal end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/module.json5 new file mode 100644 index 0000000000..73f83efdaf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvalueexternal_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/oh-package.json5 new file mode 100644 index 0000000000..84060f7221 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/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": "instanceof", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libinstanceof.so": "file:./src/main/cpp/types/libinstanceof" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..d584dc0bec --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(instanceof SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(instanceof PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..673e900837 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/hello.cpp @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_instanceof] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_instanceof] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_instanceof] + +// OH_JSVM_Instanceof的样例方法 +static JSVM_Value InstanceOf(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取两个JavaScript侧传入的参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + bool result = false; + JSVM_Status status = OH_JSVM_Instanceof(env, args[0], args[1], &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM InstanceOf fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM InstanceOf:%{public}d", result); + } + JSVM_Value returnValue = nullptr; + OH_JSVM_GetBoolean(env, result, &returnValue); + return returnValue; +} +// InstanceOf注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = InstanceOf}, +}; +static JSVM_CallbackStruct *method = param; +// InstanceOf方法别名,TS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"instanceOf", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(class Person { + name; + age; + constructor(name, age) { + this.name = name; + this.age = age; + } + } + instanceOf(new Person('Alice', 30), Person); + ;)JS"; +// [End oh_jsvm_instanceof] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "instanceof", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/oh-package.json5 new file mode 100644 index 0000000000..c5074f7260 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/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": "libinstanceof.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/instanceofability/InstanceofAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/instanceofability/InstanceofAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/instanceofability/InstanceofAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/instanceofability/InstanceofAbility.ets index c4e9fc4ba7..9031c4e9cc --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/instanceofability/InstanceofAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/instanceofability/InstanceofAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class InstanceofAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class InstanceofAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..4c1efd2b97 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libinstanceof.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/module.json5 new file mode 100644 index 0000000000..4a40496aa1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "instanceof", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "InstanceofAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "InstanceofAbility", + "srcEntry": "./ets/instanceofability/InstanceofAbility.ets", + "description": "$string:InstanceofAbility_desc", + "icon": "$media:layered_image", + "label": "$string:InstanceofAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..d9adfa2b71 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "InstanceofAbility_desc", + "value": "description" + }, + { + "name": "InstanceofAbility_label", + "value": "JsvmAboutObject" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..ad4b59a559 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testInstanceof', 0, async (done: Function) => { + console.log('uitest: TestInstanceof begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'InstanceofAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('InstanceofAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestInstanceof end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/module.json5 new file mode 100644 index 0000000000..579d34e1b8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "instanceof_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/oh-package.json5 new file mode 100644 index 0000000000..e0961a7515 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/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": "objectfreeze", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libobjectfreeze.so": "file:./src/main/cpp/types/libobjectfreeze" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..0d091da41a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(objectfreeze SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(objectfreeze PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..9d56b978b5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_object_freeze] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_object_freeze] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_object_freeze] + +// OH_JSVM_ObjectFreeze的样例方法 +const int FREEZE_TEST_VALUE = 111111; +static JSVM_Value ObjectFreeze(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 接受一个JavaScript侧传入的object + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + // 调用接口OH_JSVM_ObjectFreeze将传入的object冻结 + JSVM_Status status = OH_JSVM_ObjectFreeze(env, argv[0]); + if (status == JSVM_OK) { + OH_LOG_INFO(LOG_APP, "Test JSVM OH_JSVM_ObjectFreeze success"); + } + // 测试冻结后的对象中属性能否修改 + JSVM_Value value = nullptr; + OH_JSVM_CreateInt32(env, FREEZE_TEST_VALUE, &value); + OH_JSVM_SetNamedProperty(env, argv[0], "data", value); + // 将冻结后修改过的属性返回JavaScript侧 + return argv[0]; +} +// ObjectFreeze注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = ObjectFreeze}, +}; +static JSVM_CallbackStruct *method = param; +// ObjectFreeze方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"objectFreeze", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(let obj = { data: 55, message: "hello world"}; + objectFreeze(obj))JS"; +// [End oh_jsvm_object_freeze] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "objectfreeze", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/oh-package.json5 new file mode 100644 index 0000000000..bb8749ef3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/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": "libobjectfreeze.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/objectfreezeability/ObjectfreezeAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/objectfreezeability/ObjectfreezeAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/objectfreezeability/ObjectfreezeAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/objectfreezeability/ObjectfreezeAbility.ets index d154be7b09..4f071e4b9a --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/objectfreezeability/ObjectfreezeAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/objectfreezeability/ObjectfreezeAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class ObjectfreezeAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class ObjectfreezeAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..9855c7bcc8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libobjectfreeze.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/module.json5 new file mode 100644 index 0000000000..20e2ca5492 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "objectfreeze", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "ObjectfreezeAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ObjectfreezeAbility", + "srcEntry": "./ets/objectfreezeability/ObjectfreezeAbility.ets", + "description": "$string:ObjectfreezeAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ObjectfreezeAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..127d4344fc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "ObjectfreezeAbility_desc", + "value": "description" + }, + { + "name": "ObjectfreezeAbility_label", + "value": "JsvmAboutObject" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..6f02636e2b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testObjectFreeze', 0, async (done: Function) => { + console.log('uitest: TestObjectFreeze begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'ObjectfreezeAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('ObjectfreezeAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestObjectFreeze end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/module.json5 new file mode 100644 index 0000000000..fb3e6f9ad1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "objectfreeze_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/oh-package.json5 new file mode 100644 index 0000000000..7c69b69ab1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/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": "objectseal", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libobjectseal.so": "file:./src/main/cpp/types/libobjectseal" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..eba25f767d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(objectseal SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(objectseal PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..1bc0cf6af5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/hello.cpp @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_object_seal] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_object_seal] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_object_seal] + +// OH_JSVM_ObjectSeal的样例方法 +const int TEST_VALUE = 111111; +static JSVM_Value ObjectSeal(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 接受一个JavaScript侧传入的object + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + // 调用接口OH_JSVM_ObjectSeal将传入的object封闭,使其无法添加新的属性 + JSVM_Status status = OH_JSVM_ObjectSeal(env, argv[0]); + if (status == JSVM_OK) { + OH_LOG_INFO(LOG_APP, "Test JSVM OH_JSVM_ObjectSeal success"); + } + // 检查封闭后的对象中属性能否修改、删除、新增 + // 封闭后对象修改 + JSVM_Value changeValue = nullptr; + OH_JSVM_CreateInt32(env, TEST_VALUE, &changeValue); + OH_JSVM_SetNamedProperty(env, argv[0], "data", changeValue); + // 封闭后对象删除 + JSVM_Value deleteProperty = nullptr; + OH_JSVM_CreateStringUtf8(env, "message", JSVM_AUTO_LENGTH, &deleteProperty); + bool result = false; + OH_JSVM_DeleteProperty(env, argv[0], deleteProperty, &result); + if (result) { + OH_LOG_INFO(LOG_APP, "Test JSVM OH_JSVM_ObjectSeal failed"); + } + // 封闭后对象新增 + JSVM_Value addValue = nullptr; + OH_JSVM_CreateStringUtf8(env, "addValue", JSVM_AUTO_LENGTH, &addValue); + OH_JSVM_SetNamedProperty(env, argv[0], "newProperty", addValue); + // 将封闭后改动过的对象返回JavaScript侧 + return argv[0]; +} +// ObjectSeal注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = ObjectSeal}, +}; +static JSVM_CallbackStruct *method = param; +// ObjectSeal方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"objectSeal", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS( let obj = { data: 55, message: "hello world"}; + objectSeal(obj))JS"; +// [End oh_jsvm_object_seal] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "objectseal", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/oh-package.json5 new file mode 100644 index 0000000000..913f2ad794 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/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": "libobjectseal.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/objectsealability/ObjectsealAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/objectsealability/ObjectsealAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/objectsealability/ObjectsealAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/objectsealability/ObjectsealAbility.ets index 5a7738b9e8..6a4926e705 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/objectsealability/ObjectsealAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/objectsealability/ObjectsealAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class ObjectsealAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class ObjectsealAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..5a0d8d097e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libobjectseal.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/module.json5 new file mode 100644 index 0000000000..ba8e2d0bce --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "objectseal", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "ObjectsealAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ObjectsealAbility", + "srcEntry": "./ets/objectsealability/ObjectsealAbility.ets", + "description": "$string:ObjectsealAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ObjectsealAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..d3b4bf96f9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "ObjectsealAbility_desc", + "value": "description" + }, + { + "name": "ObjectsealAbility_label", + "value": "JsvmAboutObject" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..4c9c7dc2d9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testObjectSeal', 0, async (done: Function) => { + console.log('uitest: TestObjectSeal begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'ObjectsealAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('ObjectsealAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestObjectSeal end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/module.json5 new file mode 100644 index 0000000000..4f94ebe342 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "objectseal_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/ohosTest.md new file mode 100644 index 0000000000..3e518f73a7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/ohosTest.md @@ -0,0 +1,18 @@ +# JsvmAboutObject 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------------------------------------------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 检查给定的类型标签是否与对象上的类型标签匹配 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 创建一个包装了外部指针的JavaScript对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 创建一个默认的JavaScript Object对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 根据给定的描述符创建一个Symbol对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定JavaScript对象的原型 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取先前传递给Hello World的外部数据指针 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 判断一个对象是否是某个构造函数的实例 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 冻结给定的对象,防止向其添加新属性,删除现有属性,防止更改现有属性的可枚举性、可配置性或可写性,并防止更改现有属性的值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 密封给定的对象。这可以防止向其添加新属性,以及将所有现有属性标记为不可配置 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 在全局注册表中搜索具有给定描述的现有Symbol,如果该Symbol已经存在,它将被返回,否则将在注册表中创建一个新Symbol | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 返回JavaScript对象的类型 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/screenshots/JsvmAboutObject_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/screenshots/JsvmAboutObject_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/screenshots/JsvmAboutObject_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/screenshots/JsvmAboutObject_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/screenshots/JsvmAboutObject_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/screenshots/JsvmAboutObject_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/screenshots/JsvmAboutObject_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/screenshots/JsvmAboutObject_2.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/oh-package.json5 new file mode 100644 index 0000000000..6c503d8ba3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/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": "symbolfor", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libsymbolfor.so": "file:./src/main/cpp/types/libsymbolfor" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..7a64d446b3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(symbolfor SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(symbolfor PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..50cd55a55c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/hello.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_symbol_for] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_symbol_for] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_symbol_for] + +static const size_t TESTMO_LENGTH = 9; +// 定义一个常量,用于存储最大字符串长度 +static const int MAX_BUFFER_SIZE = 128; +// OH_JSVM_SymbolFor的样例方法 +static JSVM_Value SymbolFor(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_Value description = nullptr; + OH_JSVM_CreateStringUtf8(env, "test_demo", TESTMO_LENGTH, &description); + char buffer[MAX_BUFFER_SIZE]; + size_t bufferSize = MAX_BUFFER_SIZE; + size_t copied = 0; + OH_JSVM_GetValueStringUtf8(env, description, buffer, bufferSize, &copied); + JSVM_Value symbol = nullptr; + OH_JSVM_CreateSymbol(env, description, &symbol); + JSVM_Value result_symbol = nullptr; + JSVM_Status status = OH_JSVM_SymbolFor(env, buffer, copied, &result_symbol); + JSVM_ValueType valuetypeSymbol; + OH_JSVM_Typeof(env, result_symbol, &valuetypeSymbol); + if (valuetypeSymbol == JSVM_SYMBOL && status == JSVM_OK) { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_SymbolFor success"); + } + // 返回结果 + return result_symbol; +} +// SymbolFor注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = SymbolFor}, +}; +static JSVM_CallbackStruct *method = param; +// SymbolFor方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"symbolFor", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(symbolFor())JS"; +// [End oh_jsvm_symbol_for] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "symbolfor", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/oh-package.json5 new file mode 100644 index 0000000000..f7836eab0c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/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": "libsymbolfor.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..7e319a64c0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libsymbolfor.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/symbolforability/SymbolforAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/symbolforability/SymbolforAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/symbolforability/SymbolforAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/symbolforability/SymbolforAbility.ets index 94d3777200..619d5e0e81 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/symbolforability/SymbolforAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/symbolforability/SymbolforAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class SymbolforAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class SymbolforAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/module.json5 new file mode 100644 index 0000000000..990e56565d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/module.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. + */ + +{ + "module": { + "name": "symbolfor", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "SymbolforAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "SymbolforAbility", + "srcEntry": "./ets/symbolforability/SymbolforAbility.ets", + "description": "$string:SymbolforAbility_desc", + "icon": "$media:layered_image", + "label": "$string:SymbolforAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..a1845a148f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "SymbolforAbility_desc", + "value": "description" + }, + { + "name": "SymbolforAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..d4c204adf7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testSymbolFor', 0, async (done: Function) => { + console.log('uitest: TestSymbolFor begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestSymbolFor end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/module.json5 new file mode 100644 index 0000000000..26ee7cdcb3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "symbolfor_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/oh-package.json5 new file mode 100644 index 0000000000..c9c59fc830 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/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": "typeof", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libtypeof.so": "file:./src/main/cpp/types/libtypeof" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..5281c648ba --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(typeof SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(typeof PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..20882f1bb7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/hello.cpp @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_typeof] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_typeof] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_typeof] + +// OH_JSVM_Typeof的样例方法 +static JSVM_Value GetTypeof(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + JSVM_ValueType valueType; + OH_JSVM_Typeof(env, args[0], &valueType); + JSVM_Value type = nullptr; + switch (valueType) { + case JSVM_UNDEFINED: + OH_LOG_INFO(LOG_APP, "JSVM Input type is undefined"); + OH_JSVM_CreateStringUtf8(env, "Input type is undefined", JSVM_AUTO_LENGTH, &type); + break; + case JSVM_NULL: + OH_LOG_INFO(LOG_APP, "JSVM Input type is null"); + OH_JSVM_CreateStringUtf8(env, "Input type is null", JSVM_AUTO_LENGTH, &type); + break; + case JSVM_BOOLEAN: + OH_LOG_INFO(LOG_APP, "JSVM Input type is boolean"); + OH_JSVM_CreateStringUtf8(env, "Input type is boolean", JSVM_AUTO_LENGTH, &type); + break; + case JSVM_NUMBER: + OH_LOG_INFO(LOG_APP, "JSVM Input type is number"); + OH_JSVM_CreateStringUtf8(env, "Input type is number", JSVM_AUTO_LENGTH, &type); + break; + case JSVM_STRING: + OH_LOG_INFO(LOG_APP, "JSVM Input type is string"); + OH_JSVM_CreateStringUtf8(env, "Input type is string", JSVM_AUTO_LENGTH, &type); + break; + case JSVM_SYMBOL: + OH_LOG_INFO(LOG_APP, "JSVM Input type is symbol"); + OH_JSVM_CreateStringUtf8(env, "Input type is symbol", JSVM_AUTO_LENGTH, &type); + break; + case JSVM_OBJECT: + OH_LOG_INFO(LOG_APP, "JSVM Input type is object"); + OH_JSVM_CreateStringUtf8(env, "Input type is object", JSVM_AUTO_LENGTH, &type); + break; + case JSVM_FUNCTION: + OH_LOG_INFO(LOG_APP, "JSVM Input type is function"); + OH_JSVM_CreateStringUtf8(env, "Input type is function", JSVM_AUTO_LENGTH, &type); + break; + case JSVM_EXTERNAL: + OH_LOG_INFO(LOG_APP, "JSVM Input type is external"); + OH_JSVM_CreateStringUtf8(env, "Input type is external", JSVM_AUTO_LENGTH, &type); + break; + case JSVM_BIGINT: + OH_LOG_INFO(LOG_APP, "JSVM Input type is bigint"); + OH_JSVM_CreateStringUtf8(env, "Input type is bigint", JSVM_AUTO_LENGTH, &type); + break; + default: + OH_LOG_INFO(LOG_APP, "JSVM Input type does not match any"); + OH_JSVM_CreateStringUtf8(env, " ", JSVM_AUTO_LENGTH, &type); + break; + } + return type; +} +// GetTypeof注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetTypeof}, +}; +static JSVM_CallbackStruct *method = param; +// GetTypeof方法别名,TS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getTypeof", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(getTypeof(true);)JS"; +// [End oh_jsvm_typeof] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "typeof", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/oh-package.json5 new file mode 100644 index 0000000000..cc8c098483 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/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": "libtypeof.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..ba0644d764 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libtypeof.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/typeofability/TypeofAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/typeofability/TypeofAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/typeofability/TypeofAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/typeofability/TypeofAbility.ets index 0a4dd741d4..5db4403ad0 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/typeofability/TypeofAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/typeofability/TypeofAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class TypeofAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class TypeofAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/module.json5 new file mode 100644 index 0000000000..dfeabf17a1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "typeof", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "TypeofAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "TypeofAbility", + "srcEntry": "./ets/typeofability/TypeofAbility.ets", + "description": "$string:TypeofAbility_desc", + "icon": "$media:layered_image", + "label": "$string:TypeofAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..99c1866e9c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "TypeofAbility_desc", + "value": "description" + }, + { + "name": "TypeofAbility_label", + "value": "JsvmAboutObject" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..99908a153b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testTypeof', 0, async (done: Function) => { + console.log('uitest: TestTypeof begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'TypeofAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('TypeofAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestTypeof end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/module.json5 new file mode 100644 index 0000000000..589903faa0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "typeof_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/app.json5 new file mode 100644 index 0000000000..951d28629e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/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.jsvmaboutprimitive", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..5fc6906c32 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmAboutPrimitive" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/README.md new file mode 100644 index 0000000000..56fb04bde9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/README.md @@ -0,0 +1,233 @@ +# ArkTs使用JSVM-API接口进行primitive类相关开发 + +### 介绍 + +在使用JSVM-API接口时,开发人员可以实现在JSVM模块中与JavaScript对象的交互,并进行数据转换和获取特定对象的操作,它们在不同的场景中发挥着重要的作用,使开发人员能够更灵活地处理JavaScript值和对象。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口进行primitive类相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-primitive.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :--------------------------------------------------------------------: | :--------------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +coercetobool/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +coercetonumber/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +coercetoobject/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +coercetostring/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getboolean/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getglobal/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getnull/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getundefined/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvaluebool/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/build-profile.json5 new file mode 100644 index 0000000000..7bed37cdaf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/build-profile.json5 @@ -0,0 +1,154 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "coercetobool", + "srcPath": "./coercetobool", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "coercetonumber", + "srcPath": "./coercetonumber", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "coercetoobject", + "srcPath": "./coercetoobject", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "coercetostring", + "srcPath": "./coercetostring", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getboolean", + "srcPath": "./getboolean", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getvaluebool", + "srcPath": "./getvaluebool", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getglobal", + "srcPath": "./getglobal", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getnull", + "srcPath": "./getnull", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getundefined", + "srcPath": "./getundefined", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/oh-package.json5 new file mode 100644 index 0000000000..520ffbdd0b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/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": "coercetobool", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcoercetobool.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..c196aec3cc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutPrimitiveOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(coercetobool SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(coercetobool PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..49bd5a10b1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/hello.cpp @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_coerce_to_bool] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_coerce_to_bool] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_coerce_to_bool] + +// OH_JSVM_CoerceToBool的样例方法 +static JSVM_Value CoerceToBool(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + JSVM_Value boolean = nullptr; + JSVM_Status status = OH_JSVM_CoerceToBool(env, args[0], &boolean); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CoerceToBool failed"); + } else { + bool result = false; + OH_JSVM_GetValueBool(env, boolean, &result); + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CoerceToBool success:%{public}d", result); + } + return boolean; +} +// CoerceToBool注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CoerceToBool}, +}; +static JSVM_CallbackStruct *method = param; +// CoerceToBool方法别名,ArkTS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"coerceToBool", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(coerceToBool("123"))JS"; +// [End oh_jsvm_coerce_to_bool] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "coercetobool", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..10a24b2643 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/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": "libcoercetobool.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..1c2933b563 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcoercetobool.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/module.json5 new file mode 100644 index 0000000000..574c7b77d7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/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": "coercetobool", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..7c00d4195f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/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": "JsvmAboutPrimitive" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..68479d14f5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCoerceToBool', 0, async (done: Function) => { + console.log('uitest: TestCoerceToBool begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCoerceToBool end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/module.json5 new file mode 100644 index 0000000000..ae9cbd3f31 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "coercetobool_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/oh-package.json5 new file mode 100644 index 0000000000..1c31ed541d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/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": "coercetonumber", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcoercetonumber.so": "file:./src/main/cpp/types/libcoercetonumber" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..c17bb3eff7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutPrimitiveOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(coercetonumber SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(coercetonumber PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..9e0d5f5ac7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/hello.cpp @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_coerce_to_number] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" +// [StartExclude oh_jsvm_coerce_to_number] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_coerce_to_number] + +// OH_JSVM_CoerceToNumber的样例方法 +static JSVM_Value CoerceToNumber(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + JSVM_Value number = nullptr; + JSVM_Status status = OH_JSVM_CoerceToNumber(env, args[0], &number); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CoerceToNumber failed"); + } else { + int32_t result = 0; + OH_JSVM_GetValueInt32(env, number, &result); + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CoerceToNumber success:%{public}d", result); + } + return number; +} +// CoerceToNumber注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CoerceToNumber}, +}; +static JSVM_CallbackStruct *method = param; +// CoerceToNumber方法别名,ArkTS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"coerceToNumber", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(coerceToNumber(true))JS"; +// [End oh_jsvm_coerce_to_number] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "coercetonumber", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/oh-package.json5 new file mode 100644 index 0000000000..417e718843 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/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": "libcoercetonumber.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/coercetonumberability/CoercetonumberAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/coercetonumberability/CoercetonumberAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/coercetonumberability/CoercetonumberAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/coercetonumberability/CoercetonumberAbility.ets index d6963dabfa..fc2c75d969 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/coercetonumberability/CoercetonumberAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/coercetonumberability/CoercetonumberAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CoercetonumberAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CoercetonumberAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..baccd05bd1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcoercetonumber.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/module.json5 new file mode 100644 index 0000000000..4c714c1d57 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "coercetonumber", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CoercetonumberAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CoercetonumberAbility", + "srcEntry": "./ets/coercetonumberability/CoercetonumberAbility.ets", + "description": "$string:CoercetonumberAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CoercetonumberAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..50f8113573 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CoercetonumberAbility_desc", + "value": "description" + }, + { + "name": "CoercetonumberAbility_label", + "value": "JsvmAboutPrimitive" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..01f8e96410 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCoerceToNumber', 0, async (done: Function) => { + console.log('uitest: TestCoerceToNumber begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CoercetonumberAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CoercetonumberAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCoerceToNumber end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/module.json5 new file mode 100644 index 0000000000..3f1fb390b3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "coercetonumber_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/oh-package.json5 new file mode 100644 index 0000000000..d0290aa78b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/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": "coercetoobject", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcoercetoobject.so": "file:./src/main/cpp/types/libcoercetoobject" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..39a94fca6d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutPrimitiveOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(coercetoobject SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(coercetoobject PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..b926aab814 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/hello.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_coerce_to_object] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_coerce_to_object] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_coerce_to_object] + +// OH_JSVM_CoerceToObject的样例方法 +static JSVM_Value CoerceToObject(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + JSVM_Value obj = nullptr; + JSVM_Status status = OH_JSVM_CoerceToObject(env, args[0], &obj); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_CoerceToObject failed"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CoerceToObject success"); + } + return obj; +} +// CoerceToObjec注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CoerceToObject}, +}; +static JSVM_CallbackStruct *method = param; +// CoerceToObject方法别名,ArkTS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"coerceToObject", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(coerceToObject(123))JS"; +// [End oh_jsvm_coerce_to_object] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "coercetoobject", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/oh-package.json5 new file mode 100644 index 0000000000..c8f5a61056 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/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": "libcoercetoobject.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/coercetoobjectability/CoercetoobjectAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/coercetoobjectability/CoercetoobjectAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/coercetoobjectability/CoercetoobjectAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/coercetoobjectability/CoercetoobjectAbility.ets index 5c56350555..e4f782d492 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/coercetoobjectability/CoercetoobjectAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/coercetoobjectability/CoercetoobjectAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CoercetoobjectAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CoercetoobjectAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..0d412b0978 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcoercetoobject.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/module.json5 new file mode 100644 index 0000000000..90d5f155b2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "coercetoobject", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CoercetoobjectAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CoercetoobjectAbility", + "srcEntry": "./ets/coercetoobjectability/CoercetoobjectAbility.ets", + "description": "$string:CoercetoobjectAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CoercetoobjectAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..15bf2a9043 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CoercetoobjectAbility_desc", + "value": "description" + }, + { + "name": "CoercetoobjectAbility_label", + "value": "JsvmAboutPrimitive" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..88e013b83f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCoerceToObject', 0, async (done: Function) => { + console.log('uitest: TestCoerceToObject begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CoercetoobjectAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CoercetoobjectAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCoerceToObject end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/module.json5 new file mode 100644 index 0000000000..6bd3133055 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "coercetoobject_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/oh-package.json5 new file mode 100644 index 0000000000..0e658fa97f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/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": "coercetostring", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcoercetostring.so": "file:./src/main/cpp/types/libcoercetostring" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..33b18fc510 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(coercetostring SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(coercetostring PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..78878510f4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/hello.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_coerce_to_string] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_coerce_to_string] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_coerce_to_string] + +// OH_JSVM_CoerceToString的样例方法 +static JSVM_Value CoerceToString(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + JSVM_Value str = nullptr; + JSVM_Status status = OH_JSVM_CoerceToString(env, args[0], &str); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_CoerceToString fail"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CoerceToString success"); + } + return str; +} +// CoerceToString注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CoerceToString}, +}; +static JSVM_CallbackStruct *method = param; +// CoerceToString方法别名,ArkTS侧调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"coerceToString", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(coerceToString(22222))JS"; +// [End oh_jsvm_coerce_to_string] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "coercetostring", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/oh-package.json5 new file mode 100644 index 0000000000..c239252cc9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/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": "libcoercetostring.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/coercetostringability/CoercetostringAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/coercetostringability/CoercetostringAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/coercetostringability/CoercetostringAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/coercetostringability/CoercetostringAbility.ets index da349f67a8..ffbafce1af --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/coercetostringability/CoercetostringAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/coercetostringability/CoercetostringAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CoercetostringAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CoercetostringAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..ce2d63125e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcoercetostring.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/module.json5 new file mode 100644 index 0000000000..10e89833e3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "coercetostring", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CoercetostringAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CoercetostringAbility", + "srcEntry": "./ets/coercetostringability/CoercetostringAbility.ets", + "description": "$string:CoercetostringAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CoercetostringAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..bd1a49726a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CoercetostringAbility_desc", + "value": "description" + }, + { + "name": "CoercetostringAbility_label", + "value": "JsvmAboutPrimitive" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..6d19394ce5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCoerceToString', 0, async (done: Function) => { + console.log('uitest: TestCoerceToString begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CoercetostringAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CoercetostringAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCoerceToString end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/module.json5 new file mode 100644 index 0000000000..6b5ba124ce --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "coercetostring_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/oh-package.json5 new file mode 100644 index 0000000000..3654c8deca --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/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": "getboolean", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetboolean.so": "file:./src/main/cpp/types/libgetboolean" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..5434154e39 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getboolean SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getboolean PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..7dd3258853 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/hello.cpp @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_boolean] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_get_boolean] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_boolean] + +// OH_JSVM_GetBoolean的样例方法 +static JSVM_Value GetBoolean(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 传入两个参数并解析 + size_t argc = 2; + JSVM_Value argv[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + int32_t paramData = 0; + OH_JSVM_GetValueInt32(env, argv[0], ¶mData); + int32_t paramValue = 0; + OH_JSVM_GetValueInt32(env, argv[1], ¶mValue); + JSVM_Value returnValue = nullptr; + bool type = false; + if (paramData == paramValue) { + OH_LOG_INFO(LOG_APP, "JSVM resultType equal"); + type = true; + } + JSVM_Status status = OH_JSVM_GetBoolean(env, type, &returnValue); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_CoerceToNumber fail"); + } else { + bool result = false; + OH_JSVM_GetValueBool(env, returnValue, &result); + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CoerceToNumber success:%{public}d", result); + } + // 返回结果 + return returnValue; +} +// GetBoolean注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetBoolean}, +}; +static JSVM_CallbackStruct *method = param; +// GetBoolean方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getBoolean", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(getBoolean(1, 2))JS"; +// const char *SRC_CALL_NATIVE = R"JS(getBoolean(1, 1))JS"; +// [End oh_jsvm_get_boolean] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getboolean", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/oh-package.json5 new file mode 100644 index 0000000000..c62d32f5c3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/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": "libgetboolean.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/getbooleanability/GetbooleanAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/getbooleanability/GetbooleanAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/getbooleanability/GetbooleanAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/getbooleanability/GetbooleanAbility.ets index c0d77c7733..261b6b314d --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/getbooleanability/GetbooleanAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/getbooleanability/GetbooleanAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetbooleanAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetbooleanAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..43b51fe15c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetboolean.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/module.json5 new file mode 100644 index 0000000000..65f18d7732 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getboolean", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetbooleanAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetbooleanAbility", + "srcEntry": "./ets/getbooleanability/GetbooleanAbility.ets", + "description": "$string:GetbooleanAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetbooleanAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..b154bf6f56 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetbooleanAbility_desc", + "value": "description" + }, + { + "name": "GetbooleanAbility_label", + "value": "JsvmAboutPrimitive" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..ca2482aa3c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetBoolean', 0, async (done: Function) => { + console.log('uitest: TestGetBoolean begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetbooleanAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetbooleanAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetBoolean end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/module.json5 new file mode 100644 index 0000000000..fd95e84ec9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getboolean_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/oh-package.json5 new file mode 100644 index 0000000000..7b5841f36f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/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": "getglobal", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetglobal.so": "file:./src/main/cpp/types/libgetglobal" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..17a1189530 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getglobal SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getglobal PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..337416b4d7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/hello.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_global] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_get_global] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_global] + +// OH_JSVM_GetGlobal的样例方法 +static JSVM_Value GetGlobal(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取全局对象 + JSVM_Value value = nullptr; + JSVM_Value global = nullptr; + OH_JSVM_CreateInt32(env, 1, &value); + JSVM_Status status = OH_JSVM_GetGlobal(env, &global); + OH_JSVM_SetNamedProperty(env, global, "Row", value); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetGlobal fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetGlobal success"); + } + return global; +} +// GetGlobal注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetGlobal}, +}; +static JSVM_CallbackStruct *method = param; +// GetGlobal方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getGlobal", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(getGlobal())JS"; +// [End oh_jsvm_get_global] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getglobal", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/oh-package.json5 new file mode 100644 index 0000000000..88e8f331ac --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/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": "libgetglobal.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/getglobalability/GetglobalAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/getglobalability/GetglobalAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/getglobalability/GetglobalAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/getglobalability/GetglobalAbility.ets index 9b526c52aa..c61f2cc27a --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/getglobalability/GetglobalAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/getglobalability/GetglobalAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetglobalAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetglobalAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..7d0605383b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetglobal.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/module.json5 new file mode 100644 index 0000000000..b5e64105cc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getglobal", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetglobalAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetglobalAbility", + "srcEntry": "./ets/getglobalability/GetglobalAbility.ets", + "description": "$string:GetglobalAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetglobalAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..cdd44b9aa0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetglobalAbility_desc", + "value": "description" + }, + { + "name": "GetglobalAbility_label", + "value": "JsvmAboutPrimitive" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..1068e96531 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetGlobal', 0, async (done: Function) => { + console.log('uitest: TestGetGlobal begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetglobalAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetglobalAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetGlobal end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/module.json5 new file mode 100644 index 0000000000..6fe66615a4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getglobal_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/oh-package.json5 new file mode 100644 index 0000000000..aa2c7261d9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/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": "getnull", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetnull.so": "file:./src/main/cpp/types/libgetnull" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..b4921e4229 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getnull SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getnull PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..3e8d5f1efd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/hello.cpp @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_null] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_get_null] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_null] + +// GetNull注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetNull}, +}; +static JSVM_CallbackStruct *method = param; +// GetNull方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getNull", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// OH_JSVM_GetNull的样例方法 +static JSVM_Value GetNull(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_Value nullValue = nullptr; + JSVM_Status status = OH_JSVM_GetNull(env, &nullValue); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetNull fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetNull success"); + } + return nullValue; +} +// [End oh_jsvm_get_null] +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(getNull())JS"; + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getnull", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/oh-package.json5 new file mode 100644 index 0000000000..5dfd54979d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/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": "libgetnull.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/getnullability/GetnullAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/getnullability/GetnullAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/getnullability/GetnullAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/getnullability/GetnullAbility.ets index d4cbef99ba..3b1db3c5dc --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/getnullability/GetnullAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/getnullability/GetnullAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetnullAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetnullAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..09ba916ba7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetnull.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/module.json5 new file mode 100644 index 0000000000..086197ee7b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getnull", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetnullAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetnullAbility", + "srcEntry": "./ets/getnullability/GetnullAbility.ets", + "description": "$string:GetnullAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetnullAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..335bb4cf16 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetnullAbility_desc", + "value": "description" + }, + { + "name": "GetnullAbility_label", + "value": "JsvmAboutPrimitive" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..f203e4a5c8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetNull', 0, async (done: Function) => { + console.log('uitest: TestGetNull begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetnullAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetnullAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetNull end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/module.json5 new file mode 100644 index 0000000000..3ebc4f2954 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getnull_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/oh-package.json5 new file mode 100644 index 0000000000..2704b7a1c2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/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": "getundefined", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetundefined.so": "file:./src/main/cpp/types/libgetundefined" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..62d2397b12 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getundefined SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getundefined PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..886c13bf8e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/hello.cpp @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_undefined] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_get_undefined] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_undefined] + +// GetUndefined注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetUndefined}, +}; +static JSVM_CallbackStruct *method = param; +// GetUndefined方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getUndefined", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// OH_JSVM_GetUndefined的样例方法 +static JSVM_Value GetUndefined(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取并解析传进的参数 + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 创建一个undefined值 + JSVM_Value value = nullptr; + JSVM_Status status = OH_JSVM_GetUndefined(env, &value); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetUndefined failed"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetUndefined success"); + } + return value; +} +// [End oh_jsvm_get_undefined] +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(getUndefined())JS"; + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getundefined", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/oh-package.json5 new file mode 100644 index 0000000000..5390bebd13 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/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": "libgetundefined.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/getundefinedability/GetundefinedAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/getundefinedability/GetundefinedAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/getundefinedability/GetundefinedAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/getundefinedability/GetundefinedAbility.ets index 514e61f539..1dcce03642 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/getundefinedability/GetundefinedAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/getundefinedability/GetundefinedAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetundefinedAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetundefinedAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..0b300a0a34 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetundefined.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/module.json5 new file mode 100644 index 0000000000..80aaf8561e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getundefined", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetundefinedAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetundefinedAbility", + "srcEntry": "./ets/getundefinedability/GetundefinedAbility.ets", + "description": "$string:GetundefinedAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetundefinedAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..fc76dbea40 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetundefinedAbility_desc", + "value": "description" + }, + { + "name": "GetundefinedAbility_label", + "value": "JsvmAboutPrimitive" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..4c92820a1e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetUndefined', 0, async (done: Function) => { + console.log('uitest: TestGetUndefined begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetundefinedAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetundefinedAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetUndefined end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/module.json5 new file mode 100644 index 0000000000..fca546749f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getundefined_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/oh-package.json5 new file mode 100644 index 0000000000..cac566efdb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/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": "getvaluebool", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvaluebool.so": "file:./src/main/cpp/types/libgetvaluebool" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6e30c606ab --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JSVMDemo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getvaluebool SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvaluebool PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..b5a600134c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_bool] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_get_value_bool] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_bool] + +// GetValueBool注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetValueBool}, +}; +static JSVM_CallbackStruct *method = param; +// GetValueBool方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getValueBool", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// OH_JSVM_GetValueBool的样例方法 +static JSVM_Value GetValueBool(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + bool result = false; + JSVM_Status status = OH_JSVM_GetValueBool(env, args[0], &result); + if (status == JSVM_BOOLEAN_EXPECTED || status != JSVM_OK) { + // 如果OH_JSVM_GetValueBool成功会返回JSVM_OK,如果传入一个非布尔值则会返回JSVM_BOOLEAN_EXPECTED + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetValueBool fail:%{public}d", status); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetValueBool success:%{public}d", result); + } + JSVM_Value boolJv = nullptr; + OH_JSVM_GetBoolean(env, result, &boolJv); + return boolJv; +} +// [End oh_jsvm_get_value_bool] +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(getValueBool("abc"))JS"; +// const char *SRC_CALL_NATIVE = R"JS(getValueBool(true))JS"; +// const char *SRC_CALL_NATIVE = R"JS(getValueBool(false))JS"; + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvaluebool", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/oh-package.json5 new file mode 100644 index 0000000000..4d7135bafa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/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": "libgetvaluebool.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/getvalueboolability/GetvalueboolAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/getvalueboolability/GetvalueboolAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/getvalueboolability/GetvalueboolAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/getvalueboolability/GetvalueboolAbility.ets index 9b932f8861..db1edcc600 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/getvalueboolability/GetvalueboolAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/getvalueboolability/GetvalueboolAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetvalueboolAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetvalueboolAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..839aea8595 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvaluebool.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/module.json5 new file mode 100644 index 0000000000..c53c24198f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvaluebool", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetvalueboolAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetvalueboolAbility", + "srcEntry": "./ets/getvalueboolability/GetvalueboolAbility.ets", + "description": "$string:GetvalueboolAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetvalueboolAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..8b441c7402 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetvalueboolAbility_desc", + "value": "description" + }, + { + "name": "GetvalueboolAbility_label", + "value": "JsvmAboutPrimitive" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..e81c81c336 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueBool', 0, async (done: Function) => { + console.log('uitest: TestGetValueBool begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetvalueboolAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetvalueboolAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueBool end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/module.json5 new file mode 100644 index 0000000000..6bbc2c38a3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvaluebool_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/ohosTest.md new file mode 100644 index 0000000000..55b42fcca9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/ohosTest.md @@ -0,0 +1,16 @@ +# JsvmAboutPrimitive 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 将目标值转换为Boolean类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 将目标值转换为Number类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 将目标值转换为Object类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 将目标值转换为String类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取JavaScript单例对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取当前环境中的全局global对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取JavaScript null | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取JavaScript undefined | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定JavaScript Boolean的C布尔基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/screenshots/JsvmAboutPrimitive_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/screenshots/JsvmAboutPrimitive_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/screenshots/JsvmAboutPrimitive_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/screenshots/JsvmAboutPrimitive_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/screenshots/JsvmAboutPrimitive_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/screenshots/JsvmAboutPrimitive_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/screenshots/JsvmAboutPrimitive_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/screenshots/JsvmAboutPrimitive_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/app.json5 new file mode 100644 index 0000000000..71b860edb4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/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.jsvmaboutpromise", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..a511031646 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmAboutPromise" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/README.md new file mode 100644 index 0000000000..1bb1c761bf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/README.md @@ -0,0 +1,93 @@ +# ArkTS使用JSVM-API接口处理异步操作 + +### 介绍 + +使用JSVM-API接口处理异步操作。异步操作是指需要一定时间才能完成的操作,例如从网络下载数据或读取大型文件。与同步操作不同,异步操作不会阻塞主线程,而是会在后台执行。当异步操作完成后,事件循环将把它放入任务队列中,等待主线程空闲时执行。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口处理异步操作](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-promise.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +|:--------------------------------------------------------------------:|:--------------------------------------------------------------------:| +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +ispromise/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +resolvereject/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/build-profile.json5 new file mode 100644 index 0000000000..a0f429ebde --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/build-profile.json5 @@ -0,0 +1,70 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "ispromise", + "srcPath": "./ispromise", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "resolvereject", + "srcPath": "./resolvereject", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/oh-package.json5 new file mode 100644 index 0000000000..bcc8778338 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/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": "ispromise", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libispromise.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..e647ce8e15 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutPromise) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(ispromise SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(ispromise PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..f945813dfa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/hello.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_ispromise] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [EndExclude oh_jsvm_ispromise] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_ispromise] + +// OH_JSVM_IsPromise的样例方法 +static JSVM_Value IsPromise(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + bool isPromise = false; + JSVM_Status status = OH_JSVM_IsPromise(env, args[0], &isPromise); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_IsPromise fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_IsPromise success:%{public}d", isPromise); + } + JSVM_Value result = nullptr; + OH_JSVM_GetBoolean(env, isPromise, &result); + return result; +} +// IsPromise注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = IsPromise}, +}; +static JSVM_CallbackStruct *method = param; +// IsPromise方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"isPromise", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(isPromise())JS"; +// [End oh_jsvm_ispromise] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "ispromise", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..707408e357 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/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": "libispromise.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..6b05ea2e7e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libispromise.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/module.json5 new file mode 100644 index 0000000000..71b05a2821 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/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": "ispromise", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/module.json5 new file mode 100644 index 0000000000..fff774cdd3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "ispromise_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ohosTest.md new file mode 100644 index 0000000000..55a0808573 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ohosTest.md @@ -0,0 +1,9 @@ +# JsvmAboutDate 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------- | ------------ | ------------------------ | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 查询Promise是否为Promise对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 通过与之关联的延迟对象来解析JavaScript promise | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/oh-package.json5 new file mode 100644 index 0000000000..b3562ec8fe --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/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": "resolvereject", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libresolvereject.so": "file:./src/main/cpp/types/libresolvereject" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..5d08cc789e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutPromise) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(resolvereject SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(resolvereject PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..e5bef1b375 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/hello.cpp @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_resolvedeferred_and_rejectdeferred] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_resolvedeferred_and_rejectdeferred] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_resolvedeferred_and_rejectdeferred] + +// OH_JSVM_CreatePromise、OH_JSVM_ResolveDeferred、OH_JSVM_RejectDeferred的样例方法 +static JSVM_Value CreatePromise(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_Deferred defer = nullptr; + JSVM_Value promise = nullptr; + JSVM_Status status = OH_JSVM_CreatePromise(env, &defer, &promise); + bool isPromise = false; + JSVM_Value returnIsPromise = nullptr; + OH_JSVM_IsPromise(env, promise, &isPromise); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreatePromise fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreatePromise success:%{public}d", isPromise); + } + // 将布尔值转为可以返回的JSVM_Value + OH_JSVM_GetBoolean(env, isPromise, &returnIsPromise); + return returnIsPromise; +} + +static JSVM_Value ResolveRejectDeferred(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获得并解析参数 + size_t argc = 3; + JSVM_Value args[3] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 第一个参数为向resolve传入的信息,第二个参数为向reject传入的信息,第三个参数为Promise的状态 + bool status = false; + OH_JSVM_GetValueBool(env, args[2], &status); + // 创建Promise对象 + JSVM_Deferred deferred = nullptr; + JSVM_Value promise = nullptr; + JSVM_Status createStatus = OH_JSVM_CreatePromise(env, &deferred, &promise); + if (createStatus != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "Create promise failed"); + return nullptr; + } + // 根据第三个参数设置resolve或reject + if (status) { + OH_JSVM_ResolveDeferred(env, deferred, args[0]); + OH_LOG_INFO(LOG_APP, "OH_JSVM_ResolveDeferred resolve"); + } else { + OH_JSVM_RejectDeferred(env, deferred, args[1]); + OH_LOG_INFO(LOG_APP, "OH_JSVM_RejectDeferred reject"); + } + JSVM_Value result = nullptr; + OH_JSVM_GetBoolean(env, true, &result); + return result; +} +// CreatePromise,ResolveRejectDeferred注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreatePromise}, + {.data = nullptr, .callback = ResolveRejectDeferred}, +}; +static JSVM_CallbackStruct *method = param; +// CreatePromise,ResolveRejectDeferred方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createPromise", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, + {"resolveRejectDeferred", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE_CREATE_PROMISE = R"JS(createPromise())JS"; +const char *SRC_CALL_NATIVE_RESOLVE_REJECT_DEFERRED1 = R"JS(resolveRejectDeferred('success','fail', true))JS"; +const char *SRC_CALL_NATIVE_RESOLVE_REJECT_DEFERRED2 = R"JS(resolveRejectDeferred('success','fail', false))JS"; +// [End oh_jsvm_resolvedeferred_and_rejectdeferred] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE_CREATE_PROMISE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE_RESOLVE_REJECT_DEFERRED1, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE_RESOLVE_REJECT_DEFERRED2, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "resolvereject", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/oh-package.json5 new file mode 100644 index 0000000000..7d2e60a9d6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/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": "libresolvereject.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..88be5d10c0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libresolvereject.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/resolverejectability/ResolverejectAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/resolverejectability/ResolverejectAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/resolverejectability/ResolverejectAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/resolverejectability/ResolverejectAbility.ets index d0c5f17885..ab6c16a445 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/resolverejectability/ResolverejectAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/resolverejectability/ResolverejectAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class ResolverejectAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class ResolverejectAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/module.json5 new file mode 100644 index 0000000000..4ca7fde00d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "resolvereject", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "ResolverejectAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ResolverejectAbility", + "srcEntry": "./ets/resolverejectability/ResolverejectAbility.ets", + "description": "$string:ResolverejectAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ResolverejectAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/module.json5 new file mode 100644 index 0000000000..76eb1ad89d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "resolvereject_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/screenshots/JsvmAboutPromise_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/screenshots/JsvmAboutPromise_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/screenshots/JsvmAboutPromise_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/screenshots/JsvmAboutPromise_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/screenshots/JsvmAboutPromise_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/screenshots/JsvmAboutPromise_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/screenshots/JsvmAboutPromise_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/screenshots/JsvmAboutPromise_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/app.json5 new file mode 100644 index 0000000000..0c4891ad14 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/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.jsvmaboutproperty", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..64d18ea938 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmAboutProperty" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/README.md new file mode 100644 index 0000000000..1fbf681171 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/README.md @@ -0,0 +1,273 @@ +# ArkTs使用JSVM-API接口设置JavaScript对象的属性 + +### 介绍 + +使用JSVM-API接口获取和设置JavaScript对象的属性。通过合理使用这些函数,实现更复杂的功能和逻辑。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口设置JavaScript对象的属性](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-property.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :-------------------------------------------------------------------: | :-------------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +defineproperties/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +deleteproperty/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getallpropertynames/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getnamedproperty/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getproperty/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getpropertynames/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +hasnamedproperty/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +hasownproperty/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +hasproperty/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +setnamedproperty/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +setproperty/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/build-profile.json5 new file mode 100644 index 0000000000..c36837826c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/build-profile.json5 @@ -0,0 +1,178 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "getpropertynames", + "srcPath": "./getpropertynames", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getproperty", + "srcPath": "./getproperty", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "deleteproperty", + "srcPath": "./deleteproperty", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getnamedproperty", + "srcPath": "./getnamedproperty", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "defineproperties", + "srcPath": "./defineproperties", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getallpropertynames", + "srcPath": "./getallpropertynames", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "setproperty", + "srcPath": "./setproperty", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "hasproperty", + "srcPath": "./hasproperty", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "hasownproperty", + "srcPath": "./hasownproperty", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "setnamedproperty", + "srcPath": "./setnamedproperty", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "hasnamedproperty", + "srcPath": "./hasnamedproperty", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/oh-package.json5 new file mode 100644 index 0000000000..25cd3b5355 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/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": "defineproperties", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libdefineproperties.so": "file:./src/main/cpp/types/libdefineproperties" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6dab316b05 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutProperty) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(defineproperties SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(defineproperties PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..0816302d41 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/hello.cpp @@ -0,0 +1,257 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" +#include +#include + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" +#define MAX_MALLOC_SIZE 0x800000 + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_define_properties] +// 属性描述符列表中defineMethodPropertiesExample属性的回调函数 +static JSVM_Value DefineMethodPropertiesExample(JSVM_Env env, JSVM_CallbackInfo info) +{ + int32_t propValue = 26; + JSVM_Value returnValue; + OH_JSVM_CreateInt32(env, propValue, &returnValue); + return returnValue; +} +// 属性描述符列表中getterCallback属性的回调函数 +static JSVM_Value GetterCallback(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_Value result; + const char *str = "Hello world!"; + size_t length = strlen(str); + // 创建属性的值 + OH_JSVM_CreateStringUtf8(env, str, length, &result); + return result; +} + +// 执行JavaScript字符串的函数 +static JSVM_Value RunScriptAndLogResult(JSVM_Env env, const std::string &srcCode) +{ + JSVM_Value sourceCodeValue; + OH_JSVM_CreateStringUtf8(env, srcCode.c_str(), srcCode.size(), &sourceCodeValue); + JSVM_Script script; + // 编译JavaScript代码字符串并返回编译后的脚本 + OH_JSVM_CompileScript(env, sourceCodeValue, nullptr, 0, true, nullptr, &script); + JSVM_Value jsVmResult; + // 执行JavaScript代码字符串 + OH_JSVM_RunScript(env, script, &jsVmResult); + return jsVmResult; +} + +// OH_JSVM_DefineProperties的样例方法 +static JSVM_Value DefineProperties(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 接受一个JavaScript侧传入的空object + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + // 创建一个string类型的属性值 + JSVM_Value stringValue; + OH_JSVM_CreateStringUtf8(env, "Hello!", JSVM_AUTO_LENGTH, &stringValue); + // 创建属性描述符对应的回调函数列表 + JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = DefineMethodPropertiesExample}, + {.data = nullptr, .callback = GetterCallback}, + + }; + // 创建属性描述符列表,不同类型属性值添加位置参考JSVM_PropertyDescriptor定义 + JSVM_PropertyDescriptor descriptor[] = { + // 定义method类型的属性值 + {"defineMethodPropertiesExample", nullptr, ¶m[0], nullptr, nullptr, nullptr, JSVM_DEFAULT}, + // 定义string类型的属性值 + {"defineStringPropertiesExample", nullptr, nullptr, nullptr, nullptr, stringValue, JSVM_DEFAULT}, + // 定义getter类型的属性值 + {"getterCallback", nullptr, nullptr, ¶m[1], nullptr, nullptr, JSVM_DEFAULT}}; + // 根据属性描述符列表为obj对象创建属性 + JSVM_Status statusProperty = OH_JSVM_DefineProperties(env, + *argv, + sizeof(descriptor) / sizeof(descriptor[0]), + descriptor); + if (statusProperty != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM DefineProperties fail"); + return nullptr; + } + // 调用obj对象中添加的属性 + // 运行obj.defineMethodPropertiesExample()并将结果返回给JavaScript + std::string srcMethod = R"JS(obj.defineMethodPropertiesExample();)JS"; + JSVM_Value jsVmResult = RunScriptAndLogResult(env, srcMethod); + if (jsVmResult != nullptr) { + int32_t number; + OH_JSVM_GetValueInt32(env, jsVmResult, &number); + OH_LOG_INFO(LOG_APP, "JSVM DefineMethodPropertiesExample success:%{public}d", number); + } + // 运行obj.defineStringPropertiesExample()并将结果返回给JavaScript + static std::string srcString = R"JS(obj.defineStringPropertiesExample;)JS"; + JSVM_Value jsVmResult1 = RunScriptAndLogResult(env, srcString); + if (jsVmResult1 != nullptr) { + size_t length = 0; + OH_JSVM_GetValueStringUtf8(env, jsVmResult1, nullptr, 0, &length); + if (length == 0 || length > MAX_MALLOC_SIZE) { + OH_LOG_ERROR(LOG_APP, "Invalid string length: %{public}zu", length); + return jsVmResult; + } + char *buf = (char *)malloc(length + 1); + OH_JSVM_GetValueStringUtf8(env, jsVmResult1, buf, length + 1, &length); + OH_LOG_INFO(LOG_APP, "JSVM defineStringPropertiesExample success:%{public}s", buf); + free(buf); + } + // 调用obj的getterCallback()并将结果字符串返回给JavaScript + static std::string srcGetter = R"JS(obj.getterCallback;)JS"; + JSVM_Value jsVmResult2 = RunScriptAndLogResult(env, srcGetter); + if (jsVmResult2 != nullptr) { + size_t length = 0; + OH_JSVM_GetValueStringUtf8(env, jsVmResult2, nullptr, 0, &length); + OH_JSVM_GetValueStringUtf8(env, jsVmResult1, nullptr, 0, &length); + if (length == 0 || length > MAX_MALLOC_SIZE) { + OH_LOG_ERROR(LOG_APP, "Invalid string length: %{public}zu", length); + return jsVmResult; + } + char *buf = (char *)malloc(length + 1); + OH_JSVM_GetValueStringUtf8(env, jsVmResult2, buf, length + 1, &length); + OH_LOG_INFO(LOG_APP, "JSVM getterCallback success:%{public}s", buf); + free(buf); + } + return jsVmResult; +} + +// DefineProperties注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = DefineProperties}, +}; +static JSVM_CallbackStruct *method = param; +// DefineProperties方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"defineProperties", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let obj = {}; + defineProperties(obj) +)JS"; +// [End oh_jsvm_define_properties] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "defineproperties", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/oh-package.json5 new file mode 100644 index 0000000000..710ab15309 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/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": "libdefineproperties.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/definepropertiesability/DefinepropertiesAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/definepropertiesability/DefinepropertiesAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/definepropertiesability/DefinepropertiesAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/definepropertiesability/DefinepropertiesAbility.ets index 009e78ebcd..749d8a72ea --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/definepropertiesability/DefinepropertiesAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/definepropertiesability/DefinepropertiesAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class DefinepropertiesAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class DefinepropertiesAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..852bf54d05 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libdefineproperties.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/module.json5 new file mode 100644 index 0000000000..a83b27d312 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "defineproperties", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "DefinepropertiesAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "DefinepropertiesAbility", + "srcEntry": "./ets/definepropertiesability/DefinepropertiesAbility.ets", + "description": "$string:DefinepropertiesAbility_desc", + "icon": "$media:layered_image", + "label": "$string:DefinepropertiesAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..f18a7b148c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "DefinepropertiesAbility_desc", + "value": "description" + }, + { + "name": "DefinepropertiesAbility_label", + "value": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..d008fe4931 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testDefineProperties', 0, async (done: Function) => { + console.log('uitest: TestDefineProperties begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'DefinepropertiesAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('DefinepropertiesAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestDefineProperties end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/module.json5 new file mode 100644 index 0000000000..7f0304213f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "defineproperties_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/oh-package.json5 new file mode 100644 index 0000000000..e7fb26b79c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/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": "deleteproperty", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libdeleteproperty.so": "file:./src/main/cpp/types/libdeleteproperty" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..ae8663537b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutProperty) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(deleteproperty SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(deleteproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..8d37554584 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/hello.cpp @@ -0,0 +1,172 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_delete_property] +// OH_JSVM_DeleteProperty的样例方法 +static JSVM_Value DeleteProperty(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取js侧传入的两个参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + JSVM_ValueType valueType; + OH_JSVM_Typeof(env, args[0], &valueType); + if (valueType != JSVM_OBJECT) { + OH_JSVM_ThrowError(env, nullptr, "Expects an object as argument."); + return nullptr; + } + // 从传入的Object对象中删除指定属性,返回是否删除成功的bool结果值 + bool result = false; + JSVM_Status status = OH_JSVM_DeleteProperty(env, args[0], args[1], &result); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_DeleteProperty failed"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_DeleteProperty success:%{public}d", result); + } + // 将bool结果转换为JSVM_value并返回 + JSVM_Value ret; + OH_JSVM_GetBoolean(env, result, &ret); + return ret; +} +// DeleteProperty注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = DeleteProperty}, +}; +static JSVM_CallbackStruct *method = param; +// DeleteProperty方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"deleteProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let obj = { data: 0, message: "hello world", 50: 1}; + deleteProperty(obj, "message") +)JS"; +// [End oh_jsvm_delete_property] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "deleteproperty", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/oh-package.json5 new file mode 100644 index 0000000000..c7abd6bc79 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/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": "libdeleteproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/deletepropertyability/DeletepropertyAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/deletepropertyability/DeletepropertyAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/deletepropertyability/DeletepropertyAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/deletepropertyability/DeletepropertyAbility.ets index 65df077589..d8c5eb9716 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/deletepropertyability/DeletepropertyAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/deletepropertyability/DeletepropertyAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class DeletepropertyAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class DeletepropertyAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..b94ebea742 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libdeleteproperty.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/module.json5 new file mode 100644 index 0000000000..f7ba360423 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "deleteproperty", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "DeletepropertyAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "DeletepropertyAbility", + "srcEntry": "./ets/deletepropertyability/DeletepropertyAbility.ets", + "description": "$string:DeletepropertyAbility_desc", + "icon": "$media:layered_image", + "label": "$string:DeletepropertyAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..8465ed8521 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "DeletepropertyAbility_desc", + "value": "description" + }, + { + "name": "DeletepropertyAbility_label", + "value": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..54839fe37e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testDeleteProperty', 0, async (done: Function) => { + console.log('uitest: TestDeleteProperty begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'DeletepropertyAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('DeletepropertyAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestDeleteProperty end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/module.json5 new file mode 100644 index 0000000000..d2f9fb4e8d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "deleteproperty_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/oh-package.json5 new file mode 100644 index 0000000000..42c4974bcb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/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": "getallpropertynames", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetallpropertynames.so": "file:./src/main/cpp/types/libgetallpropertynames" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..dddd5f5e20 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutProperty) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getallpropertynames SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getallpropertynames PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..6f3603c467 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/hello.cpp @@ -0,0 +1,166 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_get_all_property_names] +// OH_JSVM_GetAllPropertyNames的样例方法 +static JSVM_Value GetAllPropertyNames(JSVM_Env env, JSVM_CallbackInfo info) +{ + // // 获取js侧传入的一个参数 + size_t argc = 1; + JSVM_Value args[1]; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 获取给定对象的所有属性名称(自有属性) + JSVM_Value result; + JSVM_Status status = OH_JSVM_GetAllPropertyNames(env, args[0], + JSVM_KeyCollectionMode::JSVM_KEY_O_ONLY, + JSVM_KeyFilter::JSVM_KEY_WRITABLE, + JSVM_KeyConversion::JSVM_KEY_NUMBERS_TO_STRINGS, &result); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "Failed to get allpropertynames"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetAllPropertyNames success"); + } + return result; +} +// GetAllPropertyNames注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetAllPropertyNames}, +}; +static JSVM_CallbackStruct *method = param; +// GetAllPropertyNames方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getAllPropertyNames", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let obj = '{ data: 0, message: "hello world", 50: 1}'; + let script = getAllPropertyNames(obj); +)JS"; +// [End oh_jsvm_get_all_property_names] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getallpropertynames", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/oh-package.json5 new file mode 100644 index 0000000000..bf650222f6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/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": "libgetallpropertynames.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/getallpropertynamesability/GetallpropertynamesAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/getallpropertynamesability/GetallpropertynamesAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/getallpropertynamesability/GetallpropertynamesAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/getallpropertynamesability/GetallpropertynamesAbility.ets index 7721b55d68..12dcb64dcc --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/getallpropertynamesability/GetallpropertynamesAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/getallpropertynamesability/GetallpropertynamesAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetallpropertynamesAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetallpropertynamesAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..6f9b27ce3d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetallpropertynames.so'; + +@Entry +@Component +struct Index { + @State message: string = 'OH_JSVM_GetAllPropertyNames'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/module.json5 new file mode 100644 index 0000000000..b93bf158ee --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getallpropertynames", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetallpropertynamesAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetallpropertynamesAbility", + "srcEntry": "./ets/getallpropertynamesability/GetallpropertynamesAbility.ets", + "description": "$string:GetallpropertynamesAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetallpropertynamesAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..5312574924 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetallpropertynamesAbility_desc", + "value": "description" + }, + { + "name": "GetallpropertynamesAbility_label", + "value": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..568b414f12 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetAllPropertyNames', 0, async (done: Function) => { + console.log('uitest: TestGetAllPropertyNames begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetallpropertynamesAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetallpropertynamesAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetAllPropertyNames end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/module.json5 new file mode 100644 index 0000000000..74e9dc18bc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getallpropertynames_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/oh-package.json5 new file mode 100644 index 0000000000..d9a8c8ec95 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/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": "getnamedproperty", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetnamedproperty.so": "file:./src/main/cpp/types/libgetnamedproperty" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..56df704efe --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutProperty) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getnamedproperty SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getnamedproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..27e398df1f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/hello.cpp @@ -0,0 +1,168 @@ +/* + * 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 "ark_runtime/jsvm.h" +#include "hilog/log.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_get_named_property] +// OH_JSVM_GetNamedProperty的样例方法 +const size_t MAX_KEY_LENGTH = 32; +static JSVM_Value GetNamedProperty(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取js侧传入的两个参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + char strKey[MAX_KEY_LENGTH] = ""; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 获取要获取的属性名 + size_t keyLength; + OH_JSVM_GetValueStringUtf8(env, args[1], strKey, MAX_KEY_LENGTH, &keyLength); + // 获取指定属性的值并存储在result中 + JSVM_Value result; + JSVM_Status status = OH_JSVM_GetNamedProperty(env, args[0], strKey, &result); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_GetNamedProperty failed"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetNamedProperty success"); + } + return result; +} +// GetNamedProperty注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetNamedProperty}, +}; +static JSVM_CallbackStruct *method = param; +// GetNamedProperty方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getNamedProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let obj = { data: 0, message: "hello world", 50: 1}; + getNamedProperty(obj, "message") +)JS"; +// [End oh_jsvm_get_named_property] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getnamedproperty", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/oh-package.json5 new file mode 100644 index 0000000000..86fbcae9a1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/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": "libgetnamedproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/getnamedpropertyability/GetnamedpropertyAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/getnamedpropertyability/GetnamedpropertyAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/getnamedpropertyability/GetnamedpropertyAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/getnamedpropertyability/GetnamedpropertyAbility.ets index 8a5e585206..da89e63993 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/getnamedpropertyability/GetnamedpropertyAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/getnamedpropertyability/GetnamedpropertyAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetnamedpropertyAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetnamedpropertyAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..6e6d8624a9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetnamedproperty.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/module.json5 new file mode 100644 index 0000000000..5ee6d3e7e3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getnamedproperty", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetnamedpropertyAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetnamedpropertyAbility", + "srcEntry": "./ets/getnamedpropertyability/GetnamedpropertyAbility.ets", + "description": "$string:GetnamedpropertyAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetnamedpropertyAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..d26d517716 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetnamedpropertyAbility_desc", + "value": "description" + }, + { + "name": "GetnamedpropertyAbility_label", + "value": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..653253a107 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetNamedProperty', 0, async (done: Function) => { + console.log('uitest: TestGetNamedProperty begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetnamedpropertyAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetnamedpropertyAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetNamedProperty end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/module.json5 new file mode 100644 index 0000000000..b3e3350a84 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getnamedproperty_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/oh-package.json5 new file mode 100644 index 0000000000..e92939fc44 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/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": "getproperty", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetproperty.so": "file:./src/main/cpp/types/libgetproperty" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..dc0ca19546 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutPropertyOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getproperty SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..0c4a205210 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_get_property] +// OH_JSVM_GetProperty的样例方法 +static JSVM_Value GetProperty(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 接收两个js传来的参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 传入的第一个参数为要检测的object,第二个对象为要检测的属性,通过调用OH_JSVM_GetProperty接口获取对应的值 + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_GetProperty(env, args[0], args[1], &result); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_GetProperty fail"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetProperty success"); + } + return result; +} +// GetProperty注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetProperty}, +}; +static JSVM_CallbackStruct *method = param; +// GetProperty方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let obj = { data: 0, message: "hello world", 50: 1}; + getProperty(obj, "message") +)JS"; +// [End oh_jsvm_get_property] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getproperty", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/oh-package.json5 new file mode 100644 index 0000000000..7d7e246640 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/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": "libgetproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/getpropertyability/GetpropertyAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/getpropertyability/GetpropertyAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/getpropertyability/GetpropertyAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/getpropertyability/GetpropertyAbility.ets index 555f5ba18a..ee69dcb61d --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/getpropertyability/GetpropertyAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/getpropertyability/GetpropertyAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetpropertyAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetpropertyAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..b32ce360e2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetproperty.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/module.json5 new file mode 100644 index 0000000000..06ee603a1b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getproperty", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetpropertyAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetpropertyAbility", + "srcEntry": "./ets/getpropertyability/GetpropertyAbility.ets", + "description": "$string:GetpropertyAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetpropertyAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..c402a0e575 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetpropertyAbility_desc", + "value": "description" + }, + { + "name": "GetpropertyAbility_label", + "value": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..c5af891cc6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetProperty', 0, async (done: Function) => { + console.log('uitest: TestGetProperty begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetpropertyAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetpropertyAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetProperty end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/module.json5 new file mode 100644 index 0000000000..2bc62a8afd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getproperty_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/oh-package.json5 new file mode 100644 index 0000000000..d8ac2accaf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/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": "getpropertynames", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetpropertynames.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..4546d46454 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutPropertyOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getpropertynames SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getpropertynames PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..bbf79e1814 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_get_property_names] +// OH_JSVM_GetPropertyNames的样例方法 +static JSVM_Value GetPropertyNames(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 将obj作为参数传入 + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 以字符串数组的形式获取对象的可枚举属性的名称,以result传出 + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_GetPropertyNames(env, args[0], &result); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "Failed to get propertynames"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetPropertyNames success"); + } + return result; +} +// GetPropertyNames注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetPropertyNames}, +}; +static JSVM_CallbackStruct *method = param; +// GetPropertyNames方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getPropertyNames", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let obj = '{ data: 0, message: "hello world"}'; + let script = getPropertyNames(obj); +)JS"; +// [End oh_jsvm_get_property_names] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getpropertynames", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..a55ca35c9e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/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": "libgetpropertynames.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..b9f77ef80a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetpropertynames.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/module.json5 new file mode 100644 index 0000000000..778f1d8bd1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/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": "getpropertynames", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..1fb1f94157 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/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": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..668e57697d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetPropertyNames', 0, async (done: Function) => { + console.log('uitest: TestGetPropertyNames begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetPropertyNames end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/module.json5 new file mode 100644 index 0000000000..08449f7be7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getpropertynames_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/oh-package.json5 new file mode 100644 index 0000000000..cf1fafa36b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/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": "hasnamedproperty", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libhasnamedproperty.so": "file:./src/main/cpp/types/libhasnamedproperty" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..395b46e09c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutProperty) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(hasnamedproperty SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(hasnamedproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..d75ad1e0ba --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/hello.cpp @@ -0,0 +1,171 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_has_named_property] +// OH_JSVM_HasNamedProperty的样例方法 +const size_t STR_KEY_LEN = 32; +static JSVM_Value HasNamedProperty(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取js侧传入的两个参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + char strKey[STR_KEY_LEN] = ""; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 获取要检查的属性名 + size_t keyLength; + OH_JSVM_GetValueStringUtf8(env, args[1], strKey, STR_KEY_LEN, &keyLength); + // 检查对象是否具有指定命名的属性,并将结果存储在hasProperty中 + bool hasProperty = false; + JSVM_Status status = OH_JSVM_HasNamedProperty(env, args[0], strKey, &hasProperty); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_HasNamedProperty failed"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_HasNamedProperty success:%{public}d", hasProperty); + } + // 将bool结果转换为JSVM_Value并返回 + JSVM_Value result; + OH_JSVM_GetBoolean(env, hasProperty, &result); + return result; +} +// HasNamedProperty注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = HasNamedProperty}, +}; +static JSVM_CallbackStruct *method = param; +// HasNamedProperty方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"hasNamedProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let obj = { data: 0, message: "hello world", 50: 1}; + hasNamedProperty(obj, "message") +)JS"; +// [End oh_jsvm_has_named_property] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "hasnamedproperty", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/oh-package.json5 new file mode 100644 index 0000000000..cec57929cd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/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": "libhasnamedproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/hasnamedpropertyability/HasnamedpropertyAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/hasnamedpropertyability/HasnamedpropertyAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/hasnamedpropertyability/HasnamedpropertyAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/hasnamedpropertyability/HasnamedpropertyAbility.ets index 3818d1d9b5..f0a3a72706 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/hasnamedpropertyability/HasnamedpropertyAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/hasnamedpropertyability/HasnamedpropertyAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class HasnamedpropertyAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class HasnamedpropertyAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..f700231cbe --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libhasnamedproperty.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/module.json5 new file mode 100644 index 0000000000..5ce858194f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "hasnamedproperty", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "HasnamedpropertyAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "HasnamedpropertyAbility", + "srcEntry": "./ets/hasnamedpropertyability/HasnamedpropertyAbility.ets", + "description": "$string:HasnamedpropertyAbility_desc", + "icon": "$media:layered_image", + "label": "$string:HasnamedpropertyAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..a5607b54b5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "HasnamedpropertyAbility_desc", + "value": "description" + }, + { + "name": "HasnamedpropertyAbility_label", + "value": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..584048aa60 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testHasNamedProperty', 0, async (done: Function) => { + console.log('uitest: TestHasNamedProperty begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'HasnamedpropertyAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('HasnamedpropertyAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestHasNamedProperty end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/module.json5 new file mode 100644 index 0000000000..ce195d251d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "hasnamedproperty_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/oh-package.json5 new file mode 100644 index 0000000000..a276285db6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/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": "hasownproperty", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libhasownproperty.so": "file:./src/main/cpp/types/libhasownproperty" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..945aa4eaab --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutProperty) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(hasownproperty SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(hasownproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..45d47c5364 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/hello.cpp @@ -0,0 +1,181 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_has_own_property] +// OH_JSVM_HasOwnProperty的样例方法 +static JSVM_Value HasOwnProperty(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取js侧传入的两个参数 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 检查第一个参数是否为对象 + JSVM_ValueType valueType1; + OH_JSVM_Typeof(env, args[0], &valueType1); + if (valueType1 != JSVM_OBJECT) { + OH_JSVM_ThrowError(env, nullptr, "First argument must be an object."); + return nullptr; + } + // 检查第二个参数是否为string + JSVM_ValueType valuetype2; + OH_JSVM_Typeof(env, args[1], &valuetype2); + if (valuetype2 != JSVM_STRING) { + OH_JSVM_ThrowError(env, nullptr, "Second argument must be a string."); + return nullptr; + } + // 检查对象是否具有指定属性,结果存储在hasProperty中 + bool hasProperty; + JSVM_Status status = OH_JSVM_HasOwnProperty(env, args[0], args[1], &hasProperty); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_HasOwnProperty failed"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_HasOwnProperty success:%{public}d", hasProperty); + } + // 将bool结果转换为JSVM_Value并返回 + JSVM_Value result; + OH_JSVM_GetBoolean(env, hasProperty, &result); + return result; +} +// HasOwnProperty注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = HasOwnProperty}, +}; +static JSVM_CallbackStruct *method = param; +// HasOwnProperty方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"hasOwnProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let obj = { data: 0, message: "hello world", 50: 1}; + hasOwnProperty(obj, "message") + hasOwnProperty(obj, "__defineGetter__") +)JS"; +// [End oh_jsvm_has_own_property] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "hasownproperty", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/oh-package.json5 new file mode 100644 index 0000000000..b759b773e7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/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": "libhasownproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/hasownpropertyability/HasownpropertyAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/hasownpropertyability/HasownpropertyAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/hasownpropertyability/HasownpropertyAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/hasownpropertyability/HasownpropertyAbility.ets index 6f5d549b4e..cd36fd79e3 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/hasownpropertyability/HasownpropertyAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/hasownpropertyability/HasownpropertyAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class HasownpropertyAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class HasownpropertyAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..199480e7dc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libhasownproperty.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/module.json5 new file mode 100644 index 0000000000..39f936321a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "hasownproperty", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "HasownpropertyAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "HasownpropertyAbility", + "srcEntry": "./ets/hasownpropertyability/HasownpropertyAbility.ets", + "description": "$string:HasownpropertyAbility_desc", + "icon": "$media:layered_image", + "label": "$string:HasownpropertyAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..b96f1cf66c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "HasownpropertyAbility_desc", + "value": "description" + }, + { + "name": "HasownpropertyAbility_label", + "value": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..c219ee8317 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testHasOwnProperty', 0, async (done: Function) => { + console.log('uitest: TestHasOwnProperty begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'HasownpropertyAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('HasownpropertyAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestHasOwnProperty end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/module.json5 new file mode 100644 index 0000000000..0112adaed8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "hasownproperty_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/oh-package.json5 new file mode 100644 index 0000000000..516888132a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/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": "hasproperty", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libhasproperty.so": "file:./src/main/cpp/types/libhasproperty" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..e6f672a727 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutPropertyOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(hasproperty SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(hasproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..e8106190d3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/hello.cpp @@ -0,0 +1,167 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_has_property] +// OH_JSVM_HasProperty的样例方法 +static JSVM_Value HasProperty(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 从js侧传入两个参数:第一个参数为要检验的对象,第二个参数为要检测是否存在对象的属性 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 将参数传入OH_JSVM_HasProperty方法中,若接口调用成功则将结果转化为JSVM_Value类型抛出,否则抛出错误 + bool result; + JSVM_Status status = OH_JSVM_HasProperty(env, args[0], args[1], &result); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_HasProperty fail"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_HasProperty success:%{public}d", result); + } + // 若传入属性存在传入对象中,则输出true将结果转化为JSVM_Value类型抛出 + JSVM_Value returnReslut = nullptr; + OH_JSVM_GetBoolean(env, result, &returnReslut); + return returnReslut; +} +// HasProperty注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = HasProperty}, +}; +static JSVM_CallbackStruct *method = param; +// HasProperty方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"hasProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let obj = { data: 0, message: "hello world", 50: 1}; + hasProperty(obj, "data") + hasProperty(obj, 0) +)JS"; +// [End oh_jsvm_has_property] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "hasproperty", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/oh-package.json5 new file mode 100644 index 0000000000..b0b7775d9c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/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": "libhasproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/haspropertyability/HaspropertyAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/haspropertyability/HaspropertyAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/haspropertyability/HaspropertyAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/haspropertyability/HaspropertyAbility.ets index 038f1b97e4..3702f7f57b --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/haspropertyability/HaspropertyAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/haspropertyability/HaspropertyAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class HaspropertyAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class HaspropertyAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..e36318dd0e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libhasproperty.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/module.json5 new file mode 100644 index 0000000000..9333bc5583 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "hasproperty", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "HaspropertyAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "HaspropertyAbility", + "srcEntry": "./ets/haspropertyability/HaspropertyAbility.ets", + "description": "$string:HaspropertyAbility_desc", + "icon": "$media:layered_image", + "label": "$string:HaspropertyAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..1703bf5a8c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "HaspropertyAbility_desc", + "value": "description" + }, + { + "name": "HaspropertyAbility_label", + "value": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..89128f7bb3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testHasProperty', 0, async (done: Function) => { + console.log('uitest: TestHasProperty begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'HaspropertyAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('HaspropertyAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestHasProperty end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/module.json5 new file mode 100644 index 0000000000..3f1c5ae200 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "hasproperty_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/ohosTest.md new file mode 100644 index 0000000000..9a9dbf391e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/ohosTest.md @@ -0,0 +1,18 @@ +# JsvmAboutProperty 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 批量的向给定对象中定义属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 用给定的属性的名称,删除目标对象属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定对象的所有可用属性名称 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 用给定的属性的名称,检索目标对象的属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 用给定的属性的名称,检索目标对象的属性,此方法等效于调用Hello World | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定对象的所有可枚举属性名称 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 用给定的属性的名称,查询目标对象是否有此属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 判断给定Object中是否有名为key的own property | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 用给定的属性的名称,查询目标对象是否有此属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 为给定对象设置一个属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 用给定的属性的名称为目标对象设置属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/screenshots/JsvmAboutProperty_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/screenshots/JsvmAboutProperty_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/screenshots/JsvmAboutProperty_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/screenshots/JsvmAboutProperty_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/screenshots/JsvmAboutProperty_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/screenshots/JsvmAboutProperty_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/screenshots/JsvmAboutProperty_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/screenshots/JsvmAboutProperty_2.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/oh-package.json5 new file mode 100644 index 0000000000..4b22f0c7b5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/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": "setnamedproperty", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libsetnamedproperty.so": "file:./src/main/cpp/types/libsetnamedproperty" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..b1aaa08d4e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutProperty) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(setnamedproperty SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(setnamedproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..5b9eef9575 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/hello.cpp @@ -0,0 +1,174 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_set_named_property] +// OH_JSVM_SetNamedProperty的样例方法 +const size_t STR_KEY_LEN = 32; +static JSVM_Value SetNamedProperty(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取js侧传入的一个参数 + size_t argc = 1; + JSVM_Value str; + char strKey[STR_KEY_LEN] = ""; + OH_JSVM_GetCbInfo(env, info, &argc, &str, nullptr, nullptr); + // 获取传入参数字符串并存储在strKey中 + size_t keyLength; + OH_JSVM_GetValueStringUtf8(env, str, strKey, STR_KEY_LEN, &keyLength); + // 创建一个新对象 + JSVM_Value newObj; + OH_JSVM_CreateObject(env, &newObj); + // 设置整数值1234为属性值 + int32_t value = 1234; + JSVM_Value numValue; + OH_JSVM_CreateInt32(env, value, &numValue); + // 将整数值与指定属性名关联 + JSVM_Status status = OH_JSVM_SetNamedProperty(env, newObj, strKey, numValue); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_SetNamedProperty failed"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_SetNamedProperty success"); + } + // 返回新创建并设置命名属性的对象 + return newObj; +} +// SetNamedProperty注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = SetNamedProperty}, +}; +static JSVM_CallbackStruct *method = param; +// SetNamedProperty方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"setNamedProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + setNamedProperty("message") +)JS"; +// [End oh_jsvm_set_named_property] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "setnamedproperty", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/oh-package.json5 new file mode 100644 index 0000000000..4993f42700 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/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": "libsetnamedproperty.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..4f83d35959 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libsetnamedproperty.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/setnamedpropertyability/SetnamedpropertyAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/setnamedpropertyability/SetnamedpropertyAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/setnamedpropertyability/SetnamedpropertyAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/setnamedpropertyability/SetnamedpropertyAbility.ets index f7239079bb..f3a650e561 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/setnamedpropertyability/SetnamedpropertyAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/setnamedpropertyability/SetnamedpropertyAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class SetnamedpropertyAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class SetnamedpropertyAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/module.json5 new file mode 100644 index 0000000000..be0003bbef --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "setnamedproperty", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "SetnamedpropertyAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "SetnamedpropertyAbility", + "srcEntry": "./ets/setnamedpropertyability/SetnamedpropertyAbility.ets", + "description": "$string:SetnamedpropertyAbility_desc", + "icon": "$media:layered_image", + "label": "$string:SetnamedpropertyAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..00edf98c8a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "SetnamedpropertyAbility_desc", + "value": "description" + }, + { + "name": "SetnamedpropertyAbility_label", + "value": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..01c28a2092 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testSetNamedProperty', 0, async (done: Function) => { + console.log('uitest: TestSetNamedProperty begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'SetnamedpropertyAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('SetnamedpropertyAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestSetNamedProperty end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/module.json5 new file mode 100644 index 0000000000..e494eccaee --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "setnamedproperty_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/oh-package.json5 new file mode 100644 index 0000000000..84d963dd85 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/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": "setproperty", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libsetproperty.so": "file:./src/main/cpp/types/libsetproperty" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..4bf4840ac3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutPropertyOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(setproperty SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(setproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..c0702ef3d2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/hello.cpp @@ -0,0 +1,167 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_set_property] +// OH_JSVM_SetProperty的样例方法 +static JSVM_Value SetProperty(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 接收js侧传入的三个参数:第一个参数为想要设置的object,第二个参数为属性,第三个参数为属性对应的值 + size_t argc = 3; + JSVM_Value args[3] = {nullptr}; + JSVM_Status status = OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_GetCbInfo fail"); + return nullptr; + } + // 通过调用OH_JSVM_SetProperty接口将属性与值设置入object如果失败,直接抛出错误 + status = OH_JSVM_SetProperty(env, args[0], args[1], args[2]); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_SetProperty fail"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_SetProperty success"); + } + // 将设置成功后的object返回出去 + return args[0]; +} +// SetProperty注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = SetProperty}, +}; +static JSVM_CallbackStruct *method = param; +// SetProperty方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"setProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let obj = { data: 0, message: "hello world", 50: 1}; + setProperty(obj, "code", "hi") +)JS"; +// [End oh_jsvm_set_property] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "setproperty", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/oh-package.json5 new file mode 100644 index 0000000000..57e01ed73a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/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": "libsetproperty.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..b5547fa7ca --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libsetproperty.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/setpropertyability/SetpropertyAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/setpropertyability/SetpropertyAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/setpropertyability/SetpropertyAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/setpropertyability/SetpropertyAbility.ets index 615301b220..210466c53c --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/setpropertyability/SetpropertyAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/setpropertyability/SetpropertyAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class SetpropertyAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class SetpropertyAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/module.json5 new file mode 100644 index 0000000000..f3e301cdbe --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "setproperty", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "SetpropertyAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "SetpropertyAbility", + "srcEntry": "./ets/setpropertyability/SetpropertyAbility.ets", + "description": "$string:SetpropertyAbility_desc", + "icon": "$media:layered_image", + "label": "$string:SetpropertyAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..b44128d457 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "SetpropertyAbility_desc", + "value": "description" + }, + { + "name": "SetpropertyAbility_label", + "value": "JsvmAboutProperty" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..fe705bf04e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testSetProperty', 0, async (done: Function) => { + console.log('uitest: TestSetProperty begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'SetpropertyAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('SetpropertyAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestSetProperty end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/module.json5 new file mode 100644 index 0000000000..17ccc65377 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "setproperty_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/app.json5 new file mode 100644 index 0000000000..01ae5288a1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/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.jsvmaboutstring", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..1e583037fa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmAboutString" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/README.md new file mode 100644 index 0000000000..502e9ae176 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/README.md @@ -0,0 +1,173 @@ +# ArkTs使用JSVM-API接口创建和获取string值 + +### 介绍 + +使用JSVM-API接口获取和设置JavaScript对象的属性。通过合理使用这些函数,实现更复杂的功能和逻辑。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口创建和获取string值](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-string.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :-----------------------------------------------------------------: | :-----------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +createstringlatin1/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createstringutf8/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createstringutf16/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvaluestringlatin1/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvaluestringutf8/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvaluestringutf16/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/build-profile.json5 new file mode 100644 index 0000000000..db53f869ad --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/build-profile.json5 @@ -0,0 +1,118 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "getvaluestringutf8", + "srcPath": "./getvaluestringutf8", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createstringutf8", + "srcPath": "./createstringutf8", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getvaluestringutf16", + "srcPath": "./getvaluestringutf16", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createstringutf16", + "srcPath": "./createstringutf16", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getvaluestringlatin1", + "srcPath": "./getvaluestringlatin1", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createstringlatin1", + "srcPath": "./createstringlatin1", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/oh-package.json5 new file mode 100644 index 0000000000..fb21c08f45 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/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": "createstringlatin1", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatestringlatin1.so": "file:./src/main/cpp/types/libcreatestringlatin1" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..981566719f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutString) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createstringlatin1 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createstringlatin1 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..e32e98cebd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/hello.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_string_latin1] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +#include +// [StartExclude oh_jsvm_create_string_latin1] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_string_latin1] + +// CreateStringLatin1注册回调 +// 定义字符串缓冲区的最大长度 +static const int MAX_BUFFER_SIZE = 128; +// OH_JSVM_CreateStringLatin1的样例方法 +static JSVM_Value CreateStringLatin1(JSVM_Env env, JSVM_CallbackInfo info) +{ + const char *str = "Hello, World! éçñ, successes to create Latin1 string!"; + size_t length = JSVM_AUTO_LENGTH; + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_CreateStringLatin1(env, str, length, &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateStringLatin1 fail"); + } else { + char buf[MAX_BUFFER_SIZE]; + size_t lengthInner; + OH_JSVM_GetValueStringLatin1(env, result, buf, MAX_BUFFER_SIZE, &lengthInner); + OH_LOG_INFO(LOG_APP, "JSVM CreateStringLatin1 success: %{public}s", buf); + } + return result; +} +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateStringLatin1}, +}; +static JSVM_CallbackStruct *method = param; +// CreateStringLatin1方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createStringLatin1", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let script = createStringLatin1(); +)JS"; +// [End oh_jsvm_create_string_latin1] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createstringlatin1", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/oh-package.json5 new file mode 100644 index 0000000000..8ae5b27af5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/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": "libcreatestringlatin1.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/createstringlatin1ability/Createstringlatin1Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/createstringlatin1ability/Createstringlatin1Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/createstringlatin1ability/Createstringlatin1Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/createstringlatin1ability/Createstringlatin1Ability.ets index b149539887..7018945a85 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/createstringlatin1ability/Createstringlatin1Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/createstringlatin1ability/Createstringlatin1Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Createstringlatin1Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Createstringlatin1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..5effaba83d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatestringlatin1.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/module.json5 new file mode 100644 index 0000000000..db113bbf97 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createstringlatin1", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Createstringlatin1Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Createstringlatin1Ability", + "srcEntry": "./ets/createstringlatin1ability/Createstringlatin1Ability.ets", + "description": "$string:Createstringlatin1Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Createstringlatin1Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..9e79474145 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Createstringlatin1Ability_desc", + "value": "description" + }, + { + "name": "Createstringlatin1Ability_label", + "value": "JsvmAboutString" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..0d89fd15b4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateStringLatin1', 0, async (done: Function) => { + console.log('uitest: TestCreateStringLatin1 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Createstringlatin1Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Createstringlatin1Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateStringLatin1 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c4bb7f2254 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createstringlatin1_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/oh-package.json5 new file mode 100644 index 0000000000..4db4fec0aa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/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": "createstringutf16", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatestringutf16.so": "file:./src/main/cpp/types/libcreatestringutf16" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..c27fcc77ef --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutString) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createstringutf16 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createstringutf16 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..119ab953c9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/hello.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_string_utf16] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +#include +#include +#include +// [StartExclude oh_jsvm_create_string_utf16] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_string_utf16] + +// OH_JSVM_CreateStringUtf16的样例方法 +static JSVM_Value CreateStringUtf16(JSVM_Env env, JSVM_CallbackInfo info) +{ + const char16_t *str = u"你好, World!, successes to create UTF-16 string!"; + std::u16string ustr(str); + size_t length = ustr.length(); + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_CreateStringUtf16(env, str, length, &result); + std::u16string u16str = {str}; + // 将 std::u16string 转换为 std::string + std::wstring_convert, char16_t> converter; + std::string strResult = converter.to_bytes(u16str); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateStringUtf16 fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateStringUtf16 success: %{public}s", strResult.c_str()); + } + return result; +} +// CreateStringUtf16注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateStringUtf16}, +}; +static JSVM_CallbackStruct *method = param; +// CreateStringUtf16方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createStringUtf16", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let script = createStringUtf16(); +)JS"; +// [End oh_jsvm_create_string_utf16] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createstringutf16", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/oh-package.json5 new file mode 100644 index 0000000000..e78b723bbb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/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": "libcreatestringutf16.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/createstringutf16ability/Createstringutf16Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/createstringutf16ability/Createstringutf16Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/createstringutf16ability/Createstringutf16Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/createstringutf16ability/Createstringutf16Ability.ets index 1f7d012757..f55281a973 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/createstringutf16ability/Createstringutf16Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/createstringutf16ability/Createstringutf16Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Createstringutf16Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Createstringutf16Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..a5d7bf8bf2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatestringutf16.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/module.json5 new file mode 100644 index 0000000000..67d9698b62 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createstringutf16", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Createstringutf16Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Createstringutf16Ability", + "srcEntry": "./ets/createstringutf16ability/Createstringutf16Ability.ets", + "description": "$string:Createstringutf16Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Createstringutf16Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..1890388e76 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Createstringutf16Ability_desc", + "value": "description" + }, + { + "name": "Createstringutf16Ability_label", + "value": "JsvmAboutString" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..92b42b3c86 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateStringUtf16', 0, async (done: Function) => { + console.log('uitest: TestCreateStringUtf16 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Createstringutf16Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Createstringutf16Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateStringUtf16 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c67774b7b3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createstringutf16_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/oh-package.json5 new file mode 100644 index 0000000000..ed9c77f4d3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/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": "createstringutf8", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatestringutf8.so": "file:./src/main/cpp/types/libcreatestringutf8" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..2a5952976c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutString) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createstringutf8 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createstringutf8 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..2f3abfc46f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/hello.cpp @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_string_utf8] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +#include +// [StartExclude oh_jsvm_create_string_utf8] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_string_utf8] + +// OH_JSVM_CreateStringUtf8的样例方法 +static JSVM_Value CreateStringUtf8(JSVM_Env env, JSVM_CallbackInfo info) +{ + const char *str = u8"你好, World!, successes to create UTF-8 string!"; + size_t length = strlen(str); + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_CreateStringUtf8(env, str, length, &result); + if (status != JSVM_OK) { + OH_JSVM_ThrowError(env, nullptr, "Failed to create UTF-8 string"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM CreateStringUtf8 success: %{public}s", str); + } + return result; +} +// CreateStringUtf8注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateStringUtf8}, +}; +static JSVM_CallbackStruct *method = param; +// CreateStringUtf8方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createStringUtf8", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let script = createStringUtf8(); +)JS"; +// [End oh_jsvm_create_string_utf8] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createstringutf8", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/oh-package.json5 new file mode 100644 index 0000000000..01e8bf5dfc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/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": "libcreatestringutf8.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/createstringutf8ability/Createstringutf8Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/createstringutf8ability/Createstringutf8Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/createstringutf8ability/Createstringutf8Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/createstringutf8ability/Createstringutf8Ability.ets index 5feed4e3d0..33326532fe --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/createstringutf8ability/Createstringutf8Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/createstringutf8ability/Createstringutf8Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Createstringutf8Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Createstringutf8Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..7ef1c87772 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatestringutf8.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/module.json5 new file mode 100644 index 0000000000..beb50ecab6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createstringutf8", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Createstringutf8Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Createstringutf8Ability", + "srcEntry": "./ets/createstringutf8ability/Createstringutf8Ability.ets", + "description": "$string:Createstringutf8Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Createstringutf8Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..e36fc0a2bc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Createstringutf8Ability_desc", + "value": "description" + }, + { + "name": "Createstringutf8Ability_label", + "value": "JsvmAboutString" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..bcf5447dcc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateStringUtf8', 0, async (done: Function) => { + console.log('uitest: TestCreateStringUtf8 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Createstringutf8Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Createstringutf8Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateStringUtf8 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/module.json5 new file mode 100644 index 0000000000..0413d85c14 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createstringutf8_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/oh-package.json5 new file mode 100644 index 0000000000..660b85226f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/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": "getvaluestringlatin1", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvaluestringlatin1.so": "file:./src/main/cpp/types/libgetvaluestringlatin1" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..c2cd6e19ea --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutString) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getvaluestringlatin1 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvaluestringlatin1 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..60652f22ec --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/hello.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_string_latin1] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +#include +// [StartExclude oh_jsvm_get_value_string_latin1] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_string_latin1] + +// OH_JSVM_GetValueStringLatin1的样例方法 +// 定义字符串缓冲区的最大长度 +static const int MAX_BUFFER_SIZE = 128; +static JSVM_Value GetValueStringLatin1(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + char buf[MAX_BUFFER_SIZE]; + size_t length; + JSVM_Value jsvmRes = nullptr; + JSVM_Status status = OH_JSVM_GetValueStringLatin1(env, args[0], buf, MAX_BUFFER_SIZE, &length); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetValueStringLatin1 fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetValueStringLatin1 success: %{public}s", buf); + } + OH_JSVM_CreateStringLatin1(env, buf, length, &jsvmRes); + return jsvmRes; +} +// GetValueStringLatin1注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetValueStringLatin1}, +}; +static JSVM_CallbackStruct *method = param; +// GetValueStringLatin1方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getValueStringLatin1", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let data = "中文"; + let script = getValueStringLatin1(data); +)JS"; +// [End oh_jsvm_get_value_string_latin1] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvaluestringlatin1", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/oh-package.json5 new file mode 100644 index 0000000000..501d4bb9f1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/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": "libgetvaluestringlatin1.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/getvaluestringlatin1ability/Getvaluestringlatin1Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/getvaluestringlatin1ability/Getvaluestringlatin1Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/getvaluestringlatin1ability/Getvaluestringlatin1Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/getvaluestringlatin1ability/Getvaluestringlatin1Ability.ets index 8fa795619c..3f4cf52e7f --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/getvaluestringlatin1ability/Getvaluestringlatin1Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/getvaluestringlatin1ability/Getvaluestringlatin1Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Getvaluestringlatin1Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Getvaluestringlatin1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..99242bf94b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvaluestringlatin1.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/module.json5 new file mode 100644 index 0000000000..ef50187133 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getvaluestringlatin1", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Getvaluestringlatin1Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Getvaluestringlatin1Ability", + "srcEntry": "./ets/getvaluestringlatin1ability/Getvaluestringlatin1Ability.ets", + "description": "$string:Getvaluestringlatin1Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Getvaluestringlatin1Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..c6341d8d9a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Getvaluestringlatin1Ability_desc", + "value": "description" + }, + { + "name": "Getvaluestringlatin1Ability_label", + "value": "JsvmAboutString" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..c4a92abdc0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueStringLatin1', 0, async (done: Function) => { + console.log('uitest: TestGetValueStringLatin1 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Getvaluestringlatin1Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Getvaluestringlatin1Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueStringLatin1 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/module.json5 new file mode 100644 index 0000000000..f7c2891020 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvaluestringlatin1_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/oh-package.json5 new file mode 100644 index 0000000000..8c3af9b148 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/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": "getvaluestringutf16", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvaluestringutf16.so": "file:./src/main/cpp/types/libgetvaluestringutf16" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..0617721e65 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutString) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getvaluestringutf16 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvaluestringutf16 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..00f7732f0b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/hello.cpp @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_string_utf16] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +#include +#include +#include +// [StartExclude oh_jsvm_get_value_string_utf16] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_string_utf16] + +// OH_JSVM_GetValueStringUtf16的样例方法 +// 定义字符串缓冲区的最大长度 +static const int MAX_BUFFER_SIZE = 128; +static JSVM_Value GetValueStringUtf16(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + JSVM_Value result = nullptr; + size_t length = 0; + char16_t buffer[MAX_BUFFER_SIZE] = {0}; + // 字符串的缓冲区大小 + size_t bufferSize = MAX_BUFFER_SIZE; + JSVM_Status status = OH_JSVM_GetValueStringUtf16(env, args[0], buffer, bufferSize, &length); + // 将 char16_t 转换为 std::u16string + std::u16string u16str = {buffer}; + // 将 std::u16string 转换为 std::string + std::wstring_convert, char16_t> converter; + std::string str = converter.to_bytes(u16str); + // 获取字符串返回结果 + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetValueStringUtf16 fail"); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetValueStringUtf16 success: %{public}s", str.c_str()); + } + return result; +} +// GetValueStringUtf16注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetValueStringUtf16}, +}; +static JSVM_CallbackStruct *method = param; +// GetValueStringUtf16方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getValueStringUtf16", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let data = "ahello。"; + let script = getValueStringUtf16(data); +)JS"; +// [End oh_jsvm_get_value_string_utf16] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvaluestringutf16", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/oh-package.json5 new file mode 100644 index 0000000000..31443c0527 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/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": "libgetvaluestringutf16.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/getvaluestringutf16ability/Getvaluestringutf16Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/getvaluestringutf16ability/Getvaluestringutf16Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/getvaluestringutf16ability/Getvaluestringutf16Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/getvaluestringutf16ability/Getvaluestringutf16Ability.ets index ce6acc4a78..441c2bd280 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/getvaluestringutf16ability/Getvaluestringutf16Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/getvaluestringutf16ability/Getvaluestringutf16Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Getvaluestringutf16Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Getvaluestringutf16Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..1fbf0916d6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvaluestringutf16.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/module.json5 new file mode 100644 index 0000000000..80dce385f3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getvaluestringutf16", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Getvaluestringutf16Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Getvaluestringutf16Ability", + "srcEntry": "./ets/getvaluestringutf16ability/Getvaluestringutf16Ability.ets", + "description": "$string:Getvaluestringutf16Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Getvaluestringutf16Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..a4979b2c4b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Getvaluestringutf16Ability_desc", + "value": "description" + }, + { + "name": "Getvaluestringutf16Ability_label", + "value": "JsvmAboutString" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..133fc2bb86 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueStringUtf16', 0, async (done: Function) => { + console.log('uitest: TestGetValueStringUtf16 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Getvaluestringutf16Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Getvaluestringutf16Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueStringUtf16 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/module.json5 new file mode 100644 index 0000000000..ef448862dd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvaluestringutf16_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/oh-package.json5 new file mode 100644 index 0000000000..f2c7b354dc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/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": "getvaluestringutf8", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvaluestringutf8.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..7250a3ad6a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmAboutString) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getvaluestringutf8 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvaluestringutf8 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..bb15b60d2c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/hello.cpp @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_string_utf8] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +#include +// [StartExclude oh_jsvm_get_value_string_utf8] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" +#define MAX_MALLOC_SIZE 0x800000 + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_string_utf8] + +// OH_JSVM_GetValueStringUtf8的样例方法 +static JSVM_Value GetValueStringUtf8(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + size_t length = 0; + JSVM_Status status = OH_JSVM_GetValueStringUtf8(env, args[0], nullptr, 0, &length); + if (length == 0 || length > MAX_MALLOC_SIZE) { + OH_LOG_ERROR(LOG_APP, "Invalid string length: %{public}zu", length); + return jsVmResult; + } + char *buf = (char *)malloc(length + 1); + status = OH_JSVM_GetValueStringUtf8(env, args[0], buf, length + 1, &length); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetValueStringUtf8 fail"); + free(buf); + return nullptr; + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetValueStringUtf8 success: %{public}s", buf); + } + JSVM_Value result = nullptr; + OH_JSVM_CreateStringUtf8(env, buf, length, &result); + free(buf); + return result; +} +// GetValueStringUtf8注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetValueStringUtf8}, +}; +static JSVM_CallbackStruct *method = param; +// GetValueStringUtf8方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getValueStringUtf8", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS( + let data = "aaBC+-$%^你好123"; + let script = getValueStringUtf8(data); +)JS"; +// [End oh_jsvm_get_value_string_utf8] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvaluestringutf8", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..a4238e7158 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/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": "libgetvaluestringutf8.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..090a5c31a8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvaluestringutf8.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/module.json5 new file mode 100644 index 0000000000..a57554c5fa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/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": "getvaluestringutf8", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..3c9edea49a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/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": "JsvmAboutString" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..c627e81499 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueStringUtf8', 0, async (done: Function) => { + console.log('uitest: TestGetValueStringUtf8 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueStringUtf8 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/module.json5 new file mode 100644 index 0000000000..a0a873074e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvaluestringutf8_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/ohosTest.md new file mode 100644 index 0000000000..079f6083c7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/ohosTest.md @@ -0,0 +1,13 @@ +# JsvmAboutString 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 获取给定JavaScript string对象的Utf8编码字符串 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 根据Utf8编码的字符串创建一个JavaScript string对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定JavaScript string对象的Utf16编码字符串 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 根据Utf16编码的字符串数据创建JavaScript string对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定JavaScript string对象的Latin1编码字符串 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 根据Latin-1编码的字符串创建一个JavaScript string对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/screenshots/JsvmAboutString_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/screenshots/JsvmAboutString_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/screenshots/JsvmAboutString_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/screenshots/JsvmAboutString_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/screenshots/JsvmAboutString_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/screenshots/JsvmAboutString_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/screenshots/JsvmAboutString_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutString/screenshots/JsvmAboutString_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/app.json5 new file mode 100644 index 0000000000..fdbab31b67 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/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.jsvmbasicdatatypes", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..0717d1aaf4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmBasicDataTypes" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/README.md new file mode 100644 index 0000000000..2d839421de --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/README.md @@ -0,0 +1,213 @@ +# ArkTS使用JSVM-API接口创建基本数据类型 + +### 介绍 + +在JavaScript中,整数类型是一种基本数据类型,用于表示没有小数部分的数值。double类型用于表示有小数的数值。JavaScript的数值存储方式会导致在某些情况下无法准确表示非常大或非常小的数值,在这种情况下,需要使用BigInt对应的JSVM-API接口来处理更大范围的整数。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口创建基本数据类型](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-basic-data-types.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :--------------------------------------------------------------------: | :--------------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World ,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +createdouble/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createint32/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createint64/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createuint32/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvaluedouble/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvalueint32/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvalueint64/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvalueuint32/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/build-profile.json5 new file mode 100644 index 0000000000..8fd6419e1a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/build-profile.json5 @@ -0,0 +1,142 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "getvalueuint32", + "srcPath": "./getvalueuint32", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getvalueint32", + "srcPath": "./getvalueint32", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getvalueint64", + "srcPath": "./getvalueint64", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getvaluedouble", + "srcPath": "./getvaluedouble", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createint32", + "srcPath": "./createint32", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createuint32", + "srcPath": "./createuint32", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createint64", + "srcPath": "./createint64", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createdouble", + "srcPath": "./createdouble", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/code-linter.json5 new file mode 100644 index 0000000000..ed05653cca --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/code-linter.json5 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/oh-package.json5 new file mode 100644 index 0000000000..c6d0dac73b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/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": "createdouble", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatedouble.so": "file:./src/main/cpp/types/libcreatedouble" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..364ccbf29e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createdouble SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createdouble PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..4a822e9807 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/hello.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_double] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_create_double] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_double] + +// OH_JSVM_CreateDouble的样例方法 +static JSVM_Value CreateDouble(JSVM_Env env, JSVM_CallbackInfo info) +{ + double value = 1.234; + // 创建JavaScript中的double数字 + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_CreateDouble(env, value, &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateDouble fail"); + } else { + double number = 0; + OH_JSVM_GetValueDouble(env, result, &number); + OH_LOG_INFO(LOG_APP, "JSVM CreateDouble success: %{public}f", number); + } + return result; +} + +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateDouble}, +}; +static JSVM_CallbackStruct *method = param; +// CreateDouble方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createDouble", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(createDouble())JS"; +// [End oh_jsvm_create_double] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createdouble", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/oh-package.json5 new file mode 100644 index 0000000000..07112ef05d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/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": "libcreatedouble.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/createdoubleability/CreatedoubleAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/createdoubleability/CreatedoubleAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/createdoubleability/CreatedoubleAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/createdoubleability/CreatedoubleAbility.ets index d67f550837..6a9c2cbcc4 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/createdoubleability/CreatedoubleAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/createdoubleability/CreatedoubleAbility.ets @@ -1,58 +1,58 @@ -/* - * 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'; - -const DOMAIN = 0x0000; - -export default class CreatedoubleAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); - return; - } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * 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'; + +const DOMAIN = 0x0000; + +export default class CreatedoubleAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..a8e8874ef0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatedouble.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/module.json5 new file mode 100644 index 0000000000..9b58e4ac83 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createdouble", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreatedoubleAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreatedoubleAbility", + "srcEntry": "./ets/createdoubleability/CreatedoubleAbility.ets", + "description": "$string:CreatedoubleAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreatedoubleAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/float.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/float.json similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/float.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/float.json diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..e1275bfb92 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreatedoubleAbility_desc", + "value": "description" + }, + { + "name": "CreatedoubleAbility_label", + "value": "JsvmBasicDataTypes" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..884353874a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateDouble', 0, async (done: Function) => { + console.log('uitest: TestCreateDouble begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreatedoubleAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreatedoubleAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateDouble end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/module.json5 new file mode 100644 index 0000000000..7b241d74d3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createdouble_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/oh-package.json5 new file mode 100644 index 0000000000..4507a2ecd4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/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": "createint32", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreateint32.so": "file:./src/main/cpp/types/libcreateint32" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..f9bdf9271d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createint32 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createint32 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..4f671f5ead --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/hello.cpp @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_int32] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_create_int32] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_int32] + +// OH_JSVM_CreateInt32的样例方法 +static JSVM_Value CreateInt32(JSVM_Env env, JSVM_CallbackInfo info) +{ + int32_t value = -20; + // 创建JavaScript中的int32数字 + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_CreateInt32(env, value, &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateInt32 fail"); + } else { + int32_t number = 0; + OH_JSVM_GetValueInt32(env, result, &number); + OH_LOG_INFO(LOG_APP, "JSVM CreateInt32 success: %{public}d", number); + } + return result; +} + +// CreateInt32注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateInt32}, +}; +static JSVM_CallbackStruct *method = param; +// CreateInt32方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createInt32", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(createInt32())JS"; +// [End oh_jsvm_create_int32] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createint32", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/oh-package.json5 new file mode 100644 index 0000000000..37d87a3282 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/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": "libcreateint32.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/createint32ability/Createint32Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/createint32ability/Createint32Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/createint32ability/Createint32Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/createint32ability/Createint32Ability.ets index 19e4b37789..d76b52b1c9 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/createint32ability/Createint32Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/createint32ability/Createint32Ability.ets @@ -1,58 +1,58 @@ -/* - * 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'; - -const DOMAIN = 0x0000; - -export default class Createint32Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); - return; - } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * 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'; + +const DOMAIN = 0x0000; + +export default class Createint32Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..6bb339635e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreateint32.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/module.json5 new file mode 100644 index 0000000000..a684705ce0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createint32", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Createint32Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Createint32Ability", + "srcEntry": "./ets/createint32ability/Createint32Ability.ets", + "description": "$string:Createint32Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Createint32Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/float.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/float.json new file mode 100644 index 0000000000..33ea22304f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..19b814ed2a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Createint32Ability_desc", + "value": "description" + }, + { + "name": "Createint32Ability_label", + "value": "JsvmBasicDataTypes" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..f4230efd09 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateInt32', 0, async (done: Function) => { + console.log('uitest: TestCreateInt32 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Createint32Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Createint32Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateInt32 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/module.json5 new file mode 100644 index 0000000000..67190c9e5c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createint32_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/oh-package.json5 new file mode 100644 index 0000000000..0ca706152a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/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": "createint64", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreateint64.so": "file:./src/main/cpp/types/libcreateint64" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..0c59239f03 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createint64 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..241ad92c3e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/hello.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_int64] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_create_int64] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_int64] + +// OH_JSVM_CreateInt64的样例方法 +static JSVM_Value CreateInt64(JSVM_Env env, JSVM_CallbackInfo info) +{ + // int64是有符号的64位整数类型,可以表示范围从-2^63到2^63 - 1的整数,即 -9223372036854775808到9223372036854775807 + // 要表示的整数值 + int64_t value = 2147483648; + // 创建JavaScript中的int64数字 + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_CreateInt64(env, value, &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateInt64 fail"); + } else { + int64_t number = 0; + OH_JSVM_GetValueInt64(env, result, &number); + OH_LOG_INFO(LOG_APP, "JSVM CreateInt64 success: %{public}ld", number); + } + return result; +} + +// CreateInt64注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateInt64}, +}; +static JSVM_CallbackStruct *method = param; +// CreateInt64方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createInt64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(createInt64())JS"; +// [End oh_jsvm_create_int64] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createint64", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/oh-package.json5 new file mode 100644 index 0000000000..82ec484662 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/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": "libcreateint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/createint64ability/Createint64Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/createint64ability/Createint64Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/createint64ability/Createint64Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/createint64ability/Createint64Ability.ets index 48e34d5cef..f65ac599b5 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/createint64ability/Createint64Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/createint64ability/Createint64Ability.ets @@ -1,58 +1,58 @@ -/* - * 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'; - -const DOMAIN = 0x0000; - -export default class Createint64Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); - return; - } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * 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'; + +const DOMAIN = 0x0000; + +export default class Createint64Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..d84dc3c2e9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreateint64.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/module.json5 new file mode 100644 index 0000000000..aff59ba550 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createint64", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Createint64Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Createint64Ability", + "srcEntry": "./ets/createint64ability/Createint64Ability.ets", + "description": "$string:Createint64Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Createint64Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/float.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/float.json new file mode 100644 index 0000000000..33ea22304f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..1e3a4cefa2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Createint64Ability_desc", + "value": "description" + }, + { + "name": "Createint64Ability_label", + "value": "JsvmBasicDataTypes" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..c266475a27 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateInt64', 0, async (done: Function) => { + console.log('uitest: TestCreateInt64 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Createint64Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Createint64Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateInt64 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/module.json5 new file mode 100644 index 0000000000..61457fd3f6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createint64_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/oh-package.json5 new file mode 100644 index 0000000000..daa6d3f06a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/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": "createuint32", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreateuint32.so": "file:./src/main/cpp/types/libcreateuint32" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..184deeb980 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(createuint32 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createuint32 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..09e64074d6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/hello.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_uint32] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_create_uint32] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_create_uint32] + +// OH_JSVM_CreateUint32的样例方法 +static JSVM_Value CreateUInt32(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 如果使用 + // uint32_t类型来定义-26,会发生溢出,溢出时会对结果进行模运算,将负数的二进制补码转换为相应的正数。-26输出4294967270 + // uint32_t是无符号的32位整数类型,只能表示非负整数。它的范围是从0到2 ^32 - 1,即0到4294967295 + // 要表示的整数值 + uint32_t value = 26; + // 创建JavaScript中的uint32数字 + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_CreateUint32(env, value, &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM CreateUInt32 fail"); + } else { + uint32_t number = 0; + OH_JSVM_GetValueUint32(env, result, &number); + OH_LOG_INFO(LOG_APP, "JSVM CreateUInt32 success: %{public}u", number); + } + return result; +} + +// CreateUInt32注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = CreateUInt32}, +}; +static JSVM_CallbackStruct *method = param; +// CreateUInt32方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"createUInt32", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(createUInt32())JS"; +// [End oh_jsvm_create_uint32] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createuint32", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/oh-package.json5 new file mode 100644 index 0000000000..6203cb2eab --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/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": "libcreateuint32.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/createuint32ability/Createuint32Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/createuint32ability/Createuint32Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/createuint32ability/Createuint32Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/createuint32ability/Createuint32Ability.ets index efcda6ddd2..32d30a9079 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/createuint32ability/Createuint32Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/createuint32ability/Createuint32Ability.ets @@ -1,58 +1,58 @@ -/* - * 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'; - -const DOMAIN = 0x0000; - -export default class Createuint32Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); - return; - } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * 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'; + +const DOMAIN = 0x0000; + +export default class Createuint32Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..dbbbbfde9a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreateuint32.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/module.json5 new file mode 100644 index 0000000000..6136e1848e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createuint32", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Createuint32Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Createuint32Ability", + "srcEntry": "./ets/createuint32ability/Createuint32Ability.ets", + "description": "$string:Createuint32Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Createuint32Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/float.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/float.json new file mode 100644 index 0000000000..33ea22304f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..45dd30e382 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Createuint32Ability_desc", + "value": "description" + }, + { + "name": "Createuint32Ability_label", + "value": "JsvmBasicDataTypes" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..cb8fb3e4fe --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateUint32', 0, async (done: Function) => { + console.log('uitest: TestCreateUint32 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Createuint32Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Createuint32Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateUint32 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/module.json5 new file mode 100644 index 0000000000..b1a963b6af --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createuint32_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/oh-package.json5 new file mode 100644 index 0000000000..4adebc3b57 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/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": "getvaluedouble", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvaluedouble.so": "file:./src/main/cpp/types/libgetvaluedouble" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6e49d0fbcd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(getvaluedouble SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvaluedouble PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..a9ac2f18ce --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/hello.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_double] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_get_value_double] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_double] + +// OH_JSVM_GetValueDouble的样例方法 +static JSVM_Value GetDouble(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + double value; + JSVM_Status status = OH_JSVM_GetValueDouble(env, args[0], &value); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetDouble fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetDouble success: %{public}f", value); + } + return args[0]; +} + +// GetDouble注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetDouble}, +}; +static JSVM_CallbackStruct *method = param; +// GetDouble方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getDouble", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(getDouble(-110.0456))JS"; +// [EndExclude oh_jsvm_get_value_double] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvaluedouble", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/oh-package.json5 new file mode 100644 index 0000000000..1cba47eb32 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/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": "libgetvaluedouble.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/getvaluedoubleability/GetvaluedoubleAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/getvaluedoubleability/GetvaluedoubleAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/getvaluedoubleability/GetvaluedoubleAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/getvaluedoubleability/GetvaluedoubleAbility.ets index dba7397253..cfbdba57fe --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/getvaluedoubleability/GetvaluedoubleAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/getvaluedoubleability/GetvaluedoubleAbility.ets @@ -1,58 +1,58 @@ -/* - * 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'; - -const DOMAIN = 0x0000; - -export default class GetvaluedoubleAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); - return; - } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * 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'; + +const DOMAIN = 0x0000; + +export default class GetvaluedoubleAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..6ef860f004 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvaluedouble.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/module.json5 new file mode 100644 index 0000000000..c62508cb0e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getvaluedouble", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetvaluedoubleAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetvaluedoubleAbility", + "srcEntry": "./ets/getvaluedoubleability/GetvaluedoubleAbility.ets", + "description": "$string:GetvaluedoubleAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetvaluedoubleAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/float.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/float.json new file mode 100644 index 0000000000..33ea22304f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..0ee636b385 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetvaluedoubleAbility_desc", + "value": "description" + }, + { + "name": "GetvaluedoubleAbility_label", + "value": "JsvmBasicDataTypes" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..a59ff4a6e1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueDouble', 0, async (done: Function) => { + console.log('uitest: TestGetValueDouble begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetvaluedoubleAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetvaluedoubleAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueDouble end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/module.json5 new file mode 100644 index 0000000000..081f77bc27 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvaluedouble_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/oh-package.json5 new file mode 100644 index 0000000000..559beb0fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/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": "getvalueint32", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvalueint32.so": "file:./src/main/cpp/types/libgetvalueint32" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6eebe42c37 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(getvalueint32 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvalueint32 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..9cf74aea08 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/hello.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_int32] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_get_value_int32] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_int32] + +// OH_JSVM_GetValueInt32的样例方法 +static JSVM_Value GetValueInt32(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + int32_t result32 = 0; + // 解析传递的参数 + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 将前端传过来的参数转为JSVM模块的int32类型 + JSVM_Status status = OH_JSVM_GetValueInt32(env, args[0], &result32); + if (status != JSVM_OK) { + return nullptr; + } + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetValueInt32 fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetValueInt32 success: %{public}d", result32); + } + return args[0]; +} + +// GetValueInt32注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetValueInt32}, +}; +static JSVM_CallbackStruct *method = param; +// GetValueInt32方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getValueInt32", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(getValueInt32(-123))JS"; +// [EndExclude oh_jsvm_get_value_int32] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvalueint32", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/oh-package.json5 new file mode 100644 index 0000000000..b16c22eb97 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/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": "libgetvalueint32.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/getvalueint32ability/Getvalueint32Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/getvalueint32ability/Getvalueint32Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/getvalueint32ability/Getvalueint32Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/getvalueint32ability/Getvalueint32Ability.ets index 7607c46816..95250ef034 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/getvalueint32ability/Getvalueint32Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/getvalueint32ability/Getvalueint32Ability.ets @@ -1,58 +1,58 @@ -/* - * 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'; - -const DOMAIN = 0x0000; - -export default class Getvalueint32Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); - return; - } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * 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'; + +const DOMAIN = 0x0000; + +export default class Getvalueint32Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..7805ff2515 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvalueint32.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/module.json5 new file mode 100644 index 0000000000..102c5ee189 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getvalueint32", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Getvalueint32Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Getvalueint32Ability", + "srcEntry": "./ets/getvalueint32ability/Getvalueint32Ability.ets", + "description": "$string:Getvalueint32Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Getvalueint32Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/float.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/float.json new file mode 100644 index 0000000000..33ea22304f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..74660f7434 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Getvalueint32Ability_desc", + "value": "description" + }, + { + "name": "Getvalueint32Ability_label", + "value": "JsvmBasicDataTypes" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..51cfa97040 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueInt32', 0, async (done: Function) => { + console.log('uitest: TestGetValueInt32 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Getvalueint32Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Getvalueint32Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueInt32 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/module.json5 new file mode 100644 index 0000000000..3cf8a9cf57 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvalueint32_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/oh-package.json5 new file mode 100644 index 0000000000..3a300d3190 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/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": "getvalueint64", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvalueint64.so": "file:./src/main/cpp/types/libgetvalueint64" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..de7a3ca788 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(getvalueint64 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvalueint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..0b2f7c5d3d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/hello.cpp @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_int64] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_get_value_int64] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_int64] + +// OH_JSVM_GetValueInt64的样例方法 +static JSVM_Value GetValueInt64(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + int64_t result64 = 0; + // 解析传递的值 + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 将前端传过来的参数分别转为JSVM模块的int64类型 + JSVM_Status status = OH_JSVM_GetValueInt64(env, args[0], &result64); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetValueInt64 fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetValueInt64 success: %{public}d", result64); + } + return args[0]; +} + +// GetValueInt64注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetValueInt64}, +}; +static JSVM_CallbackStruct *method = param; +// GetValueInt64方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getValueInt64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(getValueInt64(-123))JS"; +// [End oh_jsvm_get_value_int64] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvalueint64", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/oh-package.json5 new file mode 100644 index 0000000000..675da76204 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/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": "libgetvalueint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/getvalueint64ability/Getvalueint64Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/getvalueint64ability/Getvalueint64Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/getvalueint64ability/Getvalueint64Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/getvalueint64ability/Getvalueint64Ability.ets index bbfbf5bedb..6f8befe424 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/getvalueint64ability/Getvalueint64Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/getvalueint64ability/Getvalueint64Ability.ets @@ -1,58 +1,58 @@ -/* - * 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'; - -const DOMAIN = 0x0000; - -export default class Getvalueint64Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); - return; - } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * 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'; + +const DOMAIN = 0x0000; + +export default class Getvalueint64Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..eb9f302146 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvalueint64.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/module.json5 new file mode 100644 index 0000000000..2ca98d368a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getvalueint64", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Getvalueint64Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Getvalueint64Ability", + "srcEntry": "./ets/getvalueint64ability/Getvalueint64Ability.ets", + "description": "$string:Getvalueint64Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Getvalueint64Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/float.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/float.json new file mode 100644 index 0000000000..33ea22304f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..7c45a2953a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Getvalueint64Ability_desc", + "value": "description" + }, + { + "name": "Getvalueint64Ability_label", + "value": "JsvmBasicDataTypes" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..0fca3488df --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueInt64', 0, async (done: Function) => { + console.log('uitest: TestGetValueInt64 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Getvalueint64Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Getvalueint64Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueInt64 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/module.json5 new file mode 100644 index 0000000000..2aedd60cbf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvalueint64_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/oh-package.json5 new file mode 100644 index 0000000000..a988e9ec7e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/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": "getvalueuint32", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvalueuint32.so": "file:./src/main/cpp/types/libgetvalueuint32" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..67c7b08956 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(GetValueUint32) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(getvalueuint32 SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvalueuint32 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..fb130e8f4a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/hello.cpp @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_value_uint32] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" + +// [StartExclude oh_jsvm_get_value_uint32] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_value_uint32] + +// OH_JSVM_GetValueUint32的样例方法 +static JSVM_Value GetValueUint32(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取传入的数字类型参数 + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + // 解析传入的参数 + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + uint32_t number = 0; + // 获取传入参数的值中的无符号32位整数 + JSVM_Status status = OH_JSVM_GetValueUint32(env, argv[0], &number); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM GetValueUint32 fail"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM GetValueUint32 success: %{public}u", number); + } + return argv[0]; +} + +// GetValueUint32注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetValueUint32}, +}; +static JSVM_CallbackStruct *method = param; + +// GetValueUint32方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getValueUint32", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(getValueUint32(123))JS"; +// [End oh_jsvm_get_value_uint32] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvalueuint32", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/oh-package.json5 new file mode 100644 index 0000000000..1892cf3f4c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/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": "libgetvalueuint32.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32ability/Getvalueuint32Ability.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32ability/Getvalueuint32Ability.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32ability/Getvalueuint32Ability.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32ability/Getvalueuint32Ability.ets index 672434b365..d7c77ef51d --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32ability/Getvalueuint32Ability.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32ability/Getvalueuint32Ability.ets @@ -1,59 +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, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -const DOMAIN = 0x0000; - -export default class Getvalueuint32Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); - return; - } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class Getvalueuint32Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32backupability/Getvalueuint32BackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32backupability/Getvalueuint32BackupAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32backupability/Getvalueuint32BackupAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32backupability/Getvalueuint32BackupAbility.ets index b2f0e204ac..3e2a11e2be --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32backupability/Getvalueuint32BackupAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/getvalueuint32backupability/Getvalueuint32BackupAbility.ets @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; - -const DOMAIN = 0x0000; - -export default class Getvalueuint32BackupAbility extends BackupExtensionAbility { - async onBackup() { - hilog.info(DOMAIN, 'testTag', 'onBackup ok'); - await Promise.resolve(); - } - - async onRestore(bundleVersion: BundleVersion) { - hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); - await Promise.resolve(); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class Getvalueuint32BackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..7407f72a43 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvalueuint32.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/module.json5 new file mode 100644 index 0000000000..ab01538bd6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/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": "getvalueuint32", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "Getvalueuint32Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Getvalueuint32Ability", + "srcEntry": "./ets/getvalueuint32ability/Getvalueuint32Ability.ets", + "description": "$string:Getvalueuint32Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Getvalueuint32Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "Getvalueuint32BackupAbility", + "srcEntry": "./ets/getvalueuint32backupability/Getvalueuint32BackupAbility.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/float.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/float.json new file mode 100644 index 0000000000..33ea22304f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..010d3b35e8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "Getvalueuint32Ability_desc", + "value": "description" + }, + { + "name": "Getvalueuint32Ability_label", + "value": "JsvmBasicDataTypes" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..21603bee15 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetValueUint32', 0, async (done: Function) => { + console.log('uitest: TestGetValueUint32 begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'Getvalueuint32Ability' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('Getvalueuint32Ability'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetValueUint32 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/module.json5 new file mode 100644 index 0000000000..705f3fe838 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvalueuint32_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..0bbbb33b0b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/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.2", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/oh-package.json5 new file mode 100644 index 0000000000..3b555a4269 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/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.2", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/ohosTest.md new file mode 100644 index 0000000000..2fd61feb9d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/ohosTest.md @@ -0,0 +1,15 @@ +# JsvmBasicDataTypes 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 根据Double类型对象创建JavaScript number对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 根据Int32_t类型对象创建JavaScript number对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 根据Int64_t类型对象创建JavaScript number对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 根据Uint32_t类型对象创建JavaScript number对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定JavaScript number的Double基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定JavaScript number的Int32基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定JavaScript number的Int64基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取给定JavaScript number的Uint32基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/screenshots/JsvmBasicDataTypes_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/screenshots/JsvmBasicDataTypes_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/screenshots/JsvmBasicDataTypes_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/screenshots/JsvmBasicDataTypes_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/screenshots/JsvmBasicDataTypes_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/screenshots/JsvmBasicDataTypes_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/screenshots/JsvmBasicDataTypes_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/screenshots/JsvmBasicDataTypes_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/app.json5 new file mode 100644 index 0000000000..185fc255b0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/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.jsvmerror", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..4fd0266eeb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmError" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/README.md new file mode 100644 index 0000000000..5048cf4f47 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/README.md @@ -0,0 +1,293 @@ +# ArkTs使用JSVM-API接口进行错误处理开发 + +### 介绍 + +使用JSVM-API接口进行错误处理开发,使得在JSVM-API模块中能够更好地管理和响应错误情况。通过合理使用这些函数,可以提高模块的稳定性和可靠性。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口进行错误处理开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-error.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :-----------------------------------------------------------: | :-----------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +createerror/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createrangeerror/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createsyntaxerror/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createtypeerror/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getandclearlastexception/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getlasterrorinfo/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +iserror/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +isexceptionpending/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +throwerror/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +throwrangeerror/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +throwsyntaxerror/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +throwtypeerror/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/build-profile.json5 new file mode 100644 index 0000000000..d347235e59 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/build-profile.json5 @@ -0,0 +1,190 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "createerror", + "srcPath": "./createerror", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "throwerror", + "srcPath": "./throwerror", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "throwtypeerror", + "srcPath": "./throwtypeerror", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "throwrangeerror", + "srcPath": "./throwrangeerror", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "throwsyntaxerror", + "srcPath": "./throwsyntaxerror", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "iserror", + "srcPath": "./iserror", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createtypeerror", + "srcPath": "./createtypeerror", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createrangeerror", + "srcPath": "./createrangeerror", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "createsyntaxerror", + "srcPath": "./createsyntaxerror", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getandclearlastexception", + "srcPath": "./getandclearlastexception", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "isexceptionpending", + "srcPath": "./isexceptionpending", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getlasterrorinfo", + "srcPath": "./getlasterrorinfo", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/oh-package.json5 new file mode 100644 index 0000000000..45fc020f21 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/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": "createerror", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreateerror.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..646502a8b6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createerror SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..b4724bf8d7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/hello.cpp @@ -0,0 +1,179 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_create_error] +// 捕获清除并打印错误,该函数作为公共函数,在本文档后续样例中不再声明和定义 +static void GetLastErrorAndClean(JSVM_Env env) +{ + // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); + // 打印错误信息 + JSVM_Value message; + JSVM_Value errorCode; + OH_JSVM_GetNamedProperty((env), result, "message", &message); + OH_JSVM_GetNamedProperty((env), result, "code", &errorCode); + const int maxMessageLength = 256; + const int maxCodeLength = 256; + char messagestr[maxMessageLength]; + char codeStr[maxCodeLength]; + OH_JSVM_GetValueStringUtf8(env, message, messagestr, maxMessageLength, nullptr); + OH_JSVM_GetValueStringUtf8(env, errorCode, codeStr, maxCodeLength, nullptr); + OH_LOG_INFO(LOG_APP, "JSVM error message: %{public}s, error code: %{public}s", messagestr, codeStr); +} + +// OH_JSVM_CreateError的样例方法 +static JSVM_Value JsVmCreateThrowError(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 在JSVM环境中创建一个字符串,并将其存储在errorCode变量中 + JSVM_Value errorCode = nullptr; + OH_JSVM_CreateStringUtf8(env, "-1", JSVM_AUTO_LENGTH, &errorCode); + // 在JSVM环境中创建一个字符串,并将其存储在errorMessage变量中 + JSVM_Value errorMessage = nullptr; + OH_JSVM_CreateStringUtf8(env, "HasError", JSVM_AUTO_LENGTH, &errorMessage); + // 创建一个JavaScript对象error + JSVM_Value error = nullptr; + OH_JSVM_CreateError(env, errorCode, errorMessage, &error); + // 通过OH_JSVM_Throw接口将对象抛出 + OH_JSVM_Throw(env, error); + GetLastErrorAndClean(env); + return nullptr; +} + +// JsVmThrow注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmCreateThrowError}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmThrow方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmCreateThrowError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmCreateThrowError();)JS"; +// [End oh_jsvm_create_error] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createerror", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..08ccb34006 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/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": "libcreateerror.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..0adc1a4d40 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreateerror.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/module.json5 new file mode 100644 index 0000000000..1afc6e120a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/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": "createerror", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..05c747fe96 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/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": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..7dd6267a0d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateError', 0, async (done: Function) => { + console.log('uitest: TestCreateError begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateError end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/module.json5 new file mode 100644 index 0000000000..4afacccb72 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createerror_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/oh-package.json5 new file mode 100644 index 0000000000..794eed302f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/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": "createrangeerror", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreaterangeerror.so": "file:./src/main/cpp/types/libcreaterangeerror" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..d408997169 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createrangeerror SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createrangeerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..b63e5932bb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/hello.cpp @@ -0,0 +1,159 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_create_range_error] +// OH_JSVM_CreateRangeError的样例方法 +static JSVM_Value JsVmCreateRangeError(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 在JSVM环境中创建一个字符串,并将其存储在errorCode变量中 + JSVM_Value errorCode = nullptr; + OH_JSVM_CreateStringUtf8(env, "-1", JSVM_AUTO_LENGTH, &errorCode); + // 在JSVM环境中创建一个字符串,并将其存储在errorMessage变量中 + JSVM_Value errorMessage = nullptr; + OH_JSVM_CreateStringUtf8(env, "HasError", JSVM_AUTO_LENGTH, &errorMessage); + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_CreateRangeError(env, errorCode, errorMessage, &result); + if (status == JSVM_OK) { + OH_LOG_INFO(LOG_APP, "JSVM API CreateRangeError SUCCESS"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM API CreateRangeError FAILED"); + } + return result; +} +// JsVmCreateRangeError注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmCreateRangeError}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmCreateRangeError方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmCreateRangeError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmCreateRangeError();)JS"; +// [End oh_jsvm_create_range_error] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createrangeerror", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/oh-package.json5 new file mode 100644 index 0000000000..f4ae2861bc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/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": "libcreaterangeerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/createrangeerrorability/CreaterangeerrorAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/createrangeerrorability/CreaterangeerrorAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/createrangeerrorability/CreaterangeerrorAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/createrangeerrorability/CreaterangeerrorAbility.ets index 394253f1bc..c22cc9d906 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/createrangeerrorability/CreaterangeerrorAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/createrangeerrorability/CreaterangeerrorAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreaterangeerrorAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreaterangeerrorAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..32026a9b1f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreaterangeerror.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/module.json5 new file mode 100644 index 0000000000..0c27fd2f39 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createrangeerror", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreaterangeerrorAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreaterangeerrorAbility", + "srcEntry": "./ets/createrangeerrorability/CreaterangeerrorAbility.ets", + "description": "$string:CreaterangeerrorAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreaterangeerrorAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..cb358fc78c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreaterangeerrorAbility_desc", + "value": "description" + }, + { + "name": "CreaterangeerrorAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..7a80e0145e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateRangeError', 0, async (done: Function) => { + console.log('uitest: TestCreateRangeError begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreaterangeerrorAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreaterangeerrorAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateRangeError end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/module.json5 new file mode 100644 index 0000000000..efa99ca79b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createrangeerror_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/oh-package.json5 new file mode 100644 index 0000000000..cc5e28cfd2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/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": "createsyntaxerror", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatesyntaxerror.so": "file:./src/main/cpp/types/libcreatesyntaxerror" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..69e1f39691 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createsyntaxerror SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createsyntaxerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..a42ca8818f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/hello.cpp @@ -0,0 +1,159 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_create_syntax_error] +// OH_JSVM_CreateSyntaxError的样例方法 +static JSVM_Value JsVmCreateSyntaxError(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 在JSVM环境中创建一个字符串,并将其存储在errorCode变量中 + JSVM_Value errorCode = nullptr; + OH_JSVM_CreateStringUtf8(env, "-1", JSVM_AUTO_LENGTH, &errorCode); + // 在JSVM环境中创建一个字符串,并将其存储在errorMessage变量中 + JSVM_Value errorMessage = nullptr; + OH_JSVM_CreateStringUtf8(env, "HasError", JSVM_AUTO_LENGTH, &errorMessage); + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_CreateSyntaxError(env, errorCode, errorMessage, &result); + if (status == JSVM_OK) { + OH_LOG_INFO(LOG_APP, "JSVM API CreateSyntaxError SUCCESS"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM API CreateSyntaxError FAILED"); + } + return result; +} +// JsVmCreateSyntaxError注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmCreateSyntaxError}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmThrow方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmCreateSyntaxError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmCreateSyntaxError();)JS"; +// [End oh_jsvm_create_syntax_error] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createsyntaxerror", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/oh-package.json5 new file mode 100644 index 0000000000..1bae7049ef --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/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": "libcreatesyntaxerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/createsyntaxerrorability/CreatesyntaxerrorAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/createsyntaxerrorability/CreatesyntaxerrorAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/createsyntaxerrorability/CreatesyntaxerrorAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/createsyntaxerrorability/CreatesyntaxerrorAbility.ets index 4d3b9b1116..b9fa178374 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/createsyntaxerrorability/CreatesyntaxerrorAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/createsyntaxerrorability/CreatesyntaxerrorAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreatesyntaxerrorAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreatesyntaxerrorAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..8680f3871c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatesyntaxerror.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/module.json5 new file mode 100644 index 0000000000..751d118ee6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createsyntaxerror", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreatesyntaxerrorAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreatesyntaxerrorAbility", + "srcEntry": "./ets/createsyntaxerrorability/CreatesyntaxerrorAbility.ets", + "description": "$string:CreatesyntaxerrorAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreatesyntaxerrorAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..f1a5b4372d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreatesyntaxerrorAbility_desc", + "value": "description" + }, + { + "name": "CreatesyntaxerrorAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..724e339a2a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateSyntaxError', 0, async (done: Function) => { + console.log('uitest: TestCreateSyntaxError begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreatesyntaxerrorAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreatesyntaxerrorAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateSyntaxError end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/module.json5 new file mode 100644 index 0000000000..17a8fd92c1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createsyntaxerror_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/oh-package.json5 new file mode 100644 index 0000000000..d3699fb551 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/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": "createtypeerror", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatetypeerror.so": "file:./src/main/cpp/types/libcreatetypeerror" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..fd081f46ea --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createtypeerror SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createtypeerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..b914e402bb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/hello.cpp @@ -0,0 +1,159 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_create_type_error] +// OH_JSVM_CreateTypeError的样例方法 +static JSVM_Value JsVmCreateTypeError(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 在JSVM环境中创建一个字符串,并将其存储在errorCode变量中 + JSVM_Value errorCode = nullptr; + OH_JSVM_CreateStringUtf8(env, "-1", JSVM_AUTO_LENGTH, &errorCode); + // 在JSVM环境中创建一个字符串,并将其存储在errorMessage变量中 + JSVM_Value errorMessage = nullptr; + OH_JSVM_CreateStringUtf8(env, "HasError", JSVM_AUTO_LENGTH, &errorMessage); + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_CreateTypeError(env, errorCode, errorMessage, &result); + if (status == JSVM_OK) { + OH_LOG_INFO(LOG_APP, "JSVM API Create TypeError SUCCESS"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM API Create TypeError FAILED"); + } + return result; +} +// JsVmCreateTypeError注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmCreateTypeError}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmCreateTypeError方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmCreateTypeError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmCreateTypeError();)JS"; +// [End oh_jsvm_create_type_error] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createtypeerror", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/oh-package.json5 new file mode 100644 index 0000000000..fddd88934e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/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": "libcreatetypeerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/createtypeerrorability/CreateTypeErrorAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/createtypeerrorability/CreateTypeErrorAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/createtypeerrorability/CreateTypeErrorAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/createtypeerrorability/CreateTypeErrorAbility.ets index ef0e54189b..60e7992c8f --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/createtypeerrorability/CreateTypeErrorAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/createtypeerrorability/CreateTypeErrorAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class CreateTypeErrorAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class CreateTypeErrorAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..5561ff42c3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libcreatetypeerror.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/module.json5 new file mode 100644 index 0000000000..0635f75816 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "createtypeerror", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "CreateTypeErrorAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "CreateTypeErrorAbility", + "srcEntry": "./ets/createtypeerrorability/CreateTypeErrorAbility.ets", + "description": "$string:CreateTypeErrorAbility_desc", + "icon": "$media:layered_image", + "label": "$string:CreateTypeErrorAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..1b0fb6f666 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "CreateTypeErrorAbility_desc", + "value": "description" + }, + { + "name": "CreateTypeErrorAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..23b7bc2384 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testCreateTypeError', 0, async (done: Function) => { + console.log('uitest: TestCreateTypeError begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'CreateTypeErrorAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('CreateTypeErrorAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestCreateTypeError end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/module.json5 new file mode 100644 index 0000000000..47c64e9faf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createtypeerror_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/oh-package.json5 new file mode 100644 index 0000000000..ce9fb1f628 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/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": "getandclearlastexception", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetandclearlastexception.so": "file:./src/main/cpp/types/libgetandclearlastexception" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..1f3a62ea91 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getandclearlastexception SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getandclearlastexception PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..a64b404d11 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/hello.cpp @@ -0,0 +1,156 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_get_and_clear_last_exception] +// OH_JSVM_GetAndClearLastException的样例方法 +static JSVM_Value JsVmGetAndClearLastException(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 抛出异常,创造异常情况 + OH_JSVM_ThrowError(env, "OH_JSVM_ThrowError errorCode", "OH_JSVM_ThrowError errorMessage"); + // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); + if (status != JSVM_OK) { + OH_LOG_INFO(LOG_APP, "JSVM API OH_JSVM_GetAndClearLastException FAILED"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM API OH_JSVM_GetAndClearLastException SUCCESS"); + } + return result; +} +// JsVmGetAndClearLastException注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmGetAndClearLastException}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmGetAndClearLastException方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmGetAndClearLastException", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmGetAndClearLastException();)JS"; +// [End oh_jsvm_get_and_clear_last_exception] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getandclearlastexception", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/oh-package.json5 new file mode 100644 index 0000000000..4ff65b223c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/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": "libgetandclearlastexception.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/getandclearlastexceptionability/GetandclearlastexceptionAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/getandclearlastexceptionability/GetandclearlastexceptionAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/getandclearlastexceptionability/GetandclearlastexceptionAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/getandclearlastexceptionability/GetandclearlastexceptionAbility.ets index 8209ef96f0..e23d25077c --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/getandclearlastexceptionability/GetandclearlastexceptionAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/getandclearlastexceptionability/GetandclearlastexceptionAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetandclearlastexceptionAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetandclearlastexceptionAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..cd32c82679 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetandclearlastexception.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/module.json5 new file mode 100644 index 0000000000..4891dbbfde --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getandclearlastexception", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetandclearlastexceptionAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetandclearlastexceptionAbility", + "srcEntry": "./ets/getandclearlastexceptionability/GetandclearlastexceptionAbility.ets", + "description": "$string:GetandclearlastexceptionAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetandclearlastexceptionAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..c7016b49b9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetandclearlastexceptionAbility_desc", + "value": "description" + }, + { + "name": "GetandclearlastexceptionAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..ae265192b6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetAndClearLastException', 0, async (done: Function) => { + console.log('uitest: TestGetAndClearLastException begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetandclearlastexceptionAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetandclearlastexceptionAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetAndClearLastException end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/module.json5 new file mode 100644 index 0000000000..e8a5853c79 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getandclearlastexception_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/oh-package.json5 new file mode 100644 index 0000000000..027afee4c3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/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": "getlasterrorinfo", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetlasterrorinfo.so": "file:./src/main/cpp/types/libgetlasterrorinfo" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..89a61c4de9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getlasterrorinfo SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getlasterrorinfo PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..6f7b3f1237 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/hello.cpp @@ -0,0 +1,166 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_get_last_error_info] +// OH_JSVM_GetLastErrorInfo的样例方法 +static JSVM_Value JsVmGetLastErrorInfo(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取输入参数(这里以字符串message作为参数传入) + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 将传入的字符串参数以OH_JSVM_GetValueInt32取出,主动制造错误 + int32_t value = 0; + OH_JSVM_GetValueInt32(env, args[0], &value); + // 调用接口OH_JSVM_GetLastErrorInfo获取最后一次错误信息 + const JSVM_ExtendedErrorInfo *errorInfo; + OH_JSVM_GetLastErrorInfo(env, &errorInfo); + + // 取出错误消息作为返回值带出去打印 + JSVM_Value result = nullptr; + OH_LOG_INFO(LOG_APP, + "JSVM API OH_JSVM_GetLastErrorInfo: SUCCESS, error message is %{public}s, error code is %{public}d", + errorInfo->errorMessage, errorInfo->errorCode); + // 对异常进行处理,防止程序由于抛异常而退出 + JSVM_Value result1 = nullptr; + OH_JSVM_GetAndClearLastException(env, &result1); + OH_JSVM_CreateInt32(env, errorInfo->errorCode, &result); + return result; +} +// JsVmGetLastErrorInfo注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmGetLastErrorInfo}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmGetLastErrorInfo方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmGetLastErrorInfo", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmGetLastErrorInfo();)JS"; +// [End oh_jsvm_get_last_error_info] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getlasterrorinfo", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/oh-package.json5 new file mode 100644 index 0000000000..cd07d9e1ff --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/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": "libgetlasterrorinfo.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/getlasterrorinfoability/GetlasterrorInfoAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/getlasterrorinfoability/GetlasterrorInfoAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/getlasterrorinfoability/GetlasterrorInfoAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/getlasterrorinfoability/GetlasterrorInfoAbility.ets index c1df8a88e9..70352007a6 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/getlasterrorinfoability/GetlasterrorInfoAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/getlasterrorinfoability/GetlasterrorInfoAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetlasterrorInfoAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetlasterrorInfoAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..b1e488f428 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetlasterrorinfo.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/module.json5 new file mode 100644 index 0000000000..a4923980f3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getlasterrorinfo", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetlasterrorInfoAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetlasterrorInfoAbility", + "srcEntry": "./ets/getlasterrorinfoability/GetlasterrorInfoAbility.ets", + "description": "$string:GetlasterrorInfoAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetlasterrorInfoAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..16097cf655 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetlasterrorInfoAbility_desc", + "value": "description" + }, + { + "name": "GetlasterrorInfoAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..79afcc5677 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetLastErrorInfo', 0, async (done: Function) => { + console.log('uitest: TestGetLastErrorInfo begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetlasterrorInfoAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetlasterrorInfoAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetLastErrorInfo end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c8353f7027 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getlasterrorinfo_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/oh-package.json5 new file mode 100644 index 0000000000..7e807ee8cd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/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": "iserror", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libiserror.so": "file:./src/main/cpp/types/libiserror" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..0688691815 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(iserror SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(iserror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..bf50296c12 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/hello.cpp @@ -0,0 +1,161 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_is_error] +// OH_JSVM_IsError的样例方法 +static JSVM_Value JsVmIsError(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 调用接口OH_JSVM_IsError判断入参是否为一个error对象 + bool result = false; + // 如果JSVM_Value为一个error对象,则设置result为true的布尔值,否则设置为false + JSVM_Status status = OH_JSVM_IsError(env, args[0], &result); + if (status == JSVM_OK) { + OH_LOG_INFO(LOG_APP, "JSVM API call OH_JSVM_IsError success, result is %{public}d", result); + } else { + OH_LOG_INFO(LOG_APP, "JSVM API call OH_JSVM_IsError failed"); + } + // 取出result通过OH_JSVM_GetBoolean接口将取出的bool值转换为JSVM_Value类型的值返回出去 + JSVM_Value returnValue = nullptr; + OH_JSVM_GetBoolean(env, result, &returnValue); + return returnValue; +} +// JsVmIsError注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmIsError}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmIsError方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmIsError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmIsError(Error()))JS"; +// [End oh_jsvm_is_error] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "iserror", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/oh-package.json5 new file mode 100644 index 0000000000..926afa1287 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/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": "libiserror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/iserrorability/IserrorAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/iserrorability/IserrorAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/iserrorability/IserrorAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/iserrorability/IserrorAbility.ets index c7c66b070a..fef24b4d9e --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/iserrorability/IserrorAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/iserrorability/IserrorAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class IserrorAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class IserrorAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..59cc37cf11 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libiserror.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/module.json5 new file mode 100644 index 0000000000..54300ca15b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "iserror", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "IserrorAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "IserrorAbility", + "srcEntry": "./ets/iserrorability/IserrorAbility.ets", + "description": "$string:IserrorAbility_desc", + "icon": "$media:layered_image", + "label": "$string:IserrorAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..6b8f8fce3d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "IserrorAbility_desc", + "value": "description" + }, + { + "name": "IserrorAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..09dd8628c0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testIsError', 0, async (done: Function) => { + console.log('uitest: TestIsError begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'IserrorAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('IserrorAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestIsError end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/module.json5 new file mode 100644 index 0000000000..378102b3e7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "iserror_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/oh-package.json5 new file mode 100644 index 0000000000..52141205c9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/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": "isexceptionpending", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libisexceptionpending.so": "file:./src/main/cpp/types/libisexceptionpending" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..c31f3153cc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(isexceptionpending SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(isexceptionpending PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..15530e8edf --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/hello.cpp @@ -0,0 +1,168 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_is_exception_pending] +// OH_JSVM_GetAndClearLastException的样例方法 +static JSVM_Value JsVmIsExceptionPending(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_Status status; + bool isExceptionPending = false; + // 在执行一些可能引发异常的操作后 + OH_JSVM_ThrowError(env, "OH_JSVM_ThrowError errorCode", "OH_JSVM_ThrowError errorMessage"); + // 检查当前环境中是否有异常挂起 + status = OH_JSVM_IsExceptionPending(env, &isExceptionPending); + if (status != JSVM_OK) { + return nullptr; + } + if (isExceptionPending) { + OH_LOG_INFO(LOG_APP, "JSVM API OH_JSVM_IsExceptionPending: SUCCESS"); + // 处理异常挂起的情况 + JSVM_Value result = nullptr; + status = OH_JSVM_GetAndClearLastException(env, &result); + if (status != JSVM_OK) { + return nullptr; + } + // 将处理的异常返回出去 + return result; + } else { + OH_LOG_INFO(LOG_APP, "JSVM API OH_JSVM_IsExceptionPending: FAILED"); + } + return nullptr; +} +// JsVmIsExceptionPending注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmIsExceptionPending}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmIsExceptionPending方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmIsExceptionPending", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmIsExceptionPending();)JS"; +// [End oh_jsvm_is_exception_pending] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "isexceptionpending", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/oh-package.json5 new file mode 100644 index 0000000000..93b0b1126a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/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": "libisexceptionpending.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/isexceptionpendingability/IsexceptionpendingAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/isexceptionpendingability/IsexceptionpendingAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/isexceptionpendingability/IsexceptionpendingAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/isexceptionpendingability/IsexceptionpendingAbility.ets index 509b469f69..257fee01bd --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/isexceptionpendingability/IsexceptionpendingAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/isexceptionpendingability/IsexceptionpendingAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class IsexceptionpendingAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class IsexceptionpendingAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..8898b91ea2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libisexceptionpending.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/module.json5 new file mode 100644 index 0000000000..7a33aebf39 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "isexceptionpending", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "IsexceptionpendingAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "IsexceptionpendingAbility", + "srcEntry": "./ets/isexceptionpendingability/IsexceptionpendingAbility.ets", + "description": "$string:IsexceptionpendingAbility_desc", + "icon": "$media:layered_image", + "label": "$string:IsexceptionpendingAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..3399f5a2fa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "IsexceptionpendingAbility_desc", + "value": "description" + }, + { + "name": "IsexceptionpendingAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..eb34bd8401 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testIsExceptionPending', 0, async (done: Function) => { + console.log('uitest: TestIsExceptionPending begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'IsexceptionpendingAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('IsexceptionpendingAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestIsExceptionPending end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c86b2c326c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "isexceptionpending_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/ohosTest.md new file mode 100644 index 0000000000..8e25fa8cc7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/ohosTest.md @@ -0,0 +1,20 @@ +# JsvmError 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------ | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 创建并获取一个带文本信息的JavaScript Error | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 创建并获取一个带文本信息的JavaScript RangeError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 创建并获取一个带文本信息的JavaScript SyntaxError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 创建并获取一个带文本信息的JavaScript TypeError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取并清除最近一次出现的异常 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 获取调用JSVM接口最后一次发生的错误信息 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 判断给定的JSVM_Value是否表示一个error对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 判断是否出现了异常 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 抛出一个带文本信息的JS Error | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 创建并获取一个带文本信息的JavaScript RangeError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 创建并获取一个带文本信息的JavaScript SyntaxError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 创建并获取一个带文本信息的JavaScript SyntaxError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 创建并获取一个带文本信息的JavaScript TypeError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/screenshots/JsvmError_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/screenshots/JsvmError_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/screenshots/JsvmError_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/screenshots/JsvmError_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/screenshots/JsvmError_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/screenshots/JsvmError_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/screenshots/JsvmError_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/screenshots/JsvmError_2.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/oh-package.json5 new file mode 100644 index 0000000000..aba6265ae5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/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": "throwerror", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libthrowerror.so": "file:./src/main/cpp/types/libthrowerror" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..561b1fafd2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(throwerror SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(throwerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..f1ae595fa1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/hello.cpp @@ -0,0 +1,183 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +static void GetLastErrorAndClean(JSVM_Env env) +{ + // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); + // 打印错误信息 + JSVM_Value message; + JSVM_Value errorCode; + OH_JSVM_GetNamedProperty((env), result, "message", &message); + OH_JSVM_GetNamedProperty((env), result, "code", &errorCode); + const int maxMessageLength = 256; + const int maxCodeLength = 256; + char messagestr[maxMessageLength]; + char codeStr[maxCodeLength]; + OH_JSVM_GetValueStringUtf8(env, message, messagestr, maxMessageLength, nullptr); + OH_JSVM_GetValueStringUtf8(env, errorCode, codeStr, maxCodeLength, nullptr); + OH_LOG_INFO(LOG_APP, "JSVM error message: %{public}s, error code: %{public}s", messagestr, codeStr); +} + +// [Start oh_jsvm_throw_error] +// OH_JSVM_ThrowError的样例方法 +static JSVM_Value JsVmThrowError(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + if (argc == 0) { + // 如果没有传递参数,直接抛出错误 + OH_JSVM_ThrowError(env, "-1", "has Error"); + } else if (argc == 1) { + size_t length; + // 通过入参获取到javaScript侧传入的字符串长度。 + OH_JSVM_GetValueStringUtf8(env, argv[0], nullptr, 0, &length); + char *buffer = new char[length + 1]; + // 获取入参的字符串内容。 + OH_JSVM_GetValueStringUtf8(env, argv[0], buffer, length + 1, nullptr); + // 作为error信息填入到OH_JSVM_ThrowError接口中。 + OH_JSVM_ThrowError(env, "self defined error code", buffer); + delete[] buffer; + } + GetLastErrorAndClean(env); + return nullptr; +} +// JsVmThrowError注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmThrowError}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmThrowError方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmThrowError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmThrowError();jsVmThrowError("self defined error message");)JS"; +// [End oh_jsvm_throw_error] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "throwerror", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/oh-package.json5 new file mode 100644 index 0000000000..e44e55f900 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/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": "libthrowerror.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..bb4f2484d2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libthrowerror.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/throwerrorability/ThrowerrorAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/throwerrorability/ThrowerrorAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/throwerrorability/ThrowerrorAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/throwerrorability/ThrowerrorAbility.ets index 897f255f8c..ec0453fc4d --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/throwerrorability/ThrowerrorAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/throwerrorability/ThrowerrorAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class ThrowerrorAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class ThrowerrorAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/module.json5 new file mode 100644 index 0000000000..bb657a31b5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "throwerror", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "ThrowerrorAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ThrowerrorAbility", + "srcEntry": "./ets/throwerrorability/ThrowerrorAbility.ets", + "description": "$string:ThrowerrorAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ThrowerrorAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..d7fcd5ad6f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "ThrowerrorAbility_desc", + "value": "description" + }, + { + "name": "ThrowerrorAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..56ee265205 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testThrowError', 0, async (done: Function) => { + console.log('uitest: TestThrowError begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'ThrowerrorAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('ThrowerrorAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestThrowError end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/module.json5 new file mode 100644 index 0000000000..8d6e408d5f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "throwerror_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/oh-package.json5 new file mode 100644 index 0000000000..6366a341fe --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/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": "throwrangeerror", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libthrowrangeerror.so": "file:./src/main/cpp/types/libthrowrangeerror" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..bb0d5f352b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(throwrangeerror SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(throwrangeerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..4269865e3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/hello.cpp @@ -0,0 +1,179 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// 捕获清除并打印错误,该函数作为公共函数,在本文档后续样例中不再声明和定义 +static void GetLastErrorAndClean(JSVM_Env env) +{ + // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); + // 打印错误信息 + JSVM_Value message; + JSVM_Value errorCode; + OH_JSVM_GetNamedProperty((env), result, "message", &message); + OH_JSVM_GetNamedProperty((env), result, "code", &errorCode); + const int maxMessageLength = 256; + const int maxCodeLength = 256; + char messagestr[maxMessageLength]; + char codeStr[maxCodeLength]; + OH_JSVM_GetValueStringUtf8(env, message, messagestr, maxMessageLength, nullptr); + OH_JSVM_GetValueStringUtf8(env, errorCode, codeStr, maxCodeLength, nullptr); + OH_LOG_INFO(LOG_APP, "JSVM error message: %{public}s, error code: %{public}s", messagestr, codeStr); +} + +// [Start oh_jsvm_throw_range_error] +// OH_JSVM_ThrowRangeError的样例方法 +static JSVM_Value JsVmThrowRangeError(JSVM_Env env, JSVM_CallbackInfo info) +{ + // js侧传入两个参数 + size_t argc = 2; + JSVM_Value argv[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + // 如果传入参数个数不为2 + if (argc != 2) { + // 这里抛出一个RangeError + OH_JSVM_ThrowRangeError(env, "OH_JSVM_ThrowRangeError", "Expected two numbers as arguments"); + GetLastErrorAndClean(env); + return nullptr; + } + JSVM_Value result = nullptr; + OH_JSVM_GetBoolean(env, true, &result); + return result; +} +// JsVmThrowRangeError注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmThrowRangeError}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmThrowRangeError方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmThrowRangeError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmThrowRangeError(1);)JS"; +// [End oh_jsvm_throw_range_error] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "throwrangeerror", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/oh-package.json5 new file mode 100644 index 0000000000..fc45dc27dc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/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": "libthrowrangeerror.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..51c64d091a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libthrowrangeerror.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/throwrangeerrorability/ThrowrangeerrorAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/throwrangeerrorability/ThrowrangeerrorAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/throwrangeerrorability/ThrowrangeerrorAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/throwrangeerrorability/ThrowrangeerrorAbility.ets index 05e9c0d253..3d02deea27 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/throwrangeerrorability/ThrowrangeerrorAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/throwrangeerrorability/ThrowrangeerrorAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class ThrowrangeerrorAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class ThrowrangeerrorAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/module.json5 new file mode 100644 index 0000000000..19f876193a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "throwrangeerror", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "ThrowrangeerrorAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ThrowrangeerrorAbility", + "srcEntry": "./ets/throwrangeerrorability/ThrowrangeerrorAbility.ets", + "description": "$string:ThrowrangeerrorAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ThrowrangeerrorAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..136d4395f2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "ThrowrangeerrorAbility_desc", + "value": "description" + }, + { + "name": "ThrowrangeerrorAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..424cae4a7f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testThrowRangeError', 0, async (done: Function) => { + console.log('uitest: TestThrowRangeError begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'ThrowrangeerrorAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('ThrowrangeerrorAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestThrowRangeError end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/module.json5 new file mode 100644 index 0000000000..20b06c3ea7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "throwrangeerror_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/oh-package.json5 new file mode 100644 index 0000000000..53f860259f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/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": "throwsyntaxerror", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libthrowsyntaxerror.so": "file:./src/main/cpp/types/libthrowsyntaxerror" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..680ef809be --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(throwsyntaxerror SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(throwsyntaxerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..ba54e14270 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/hello.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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// 捕获清除并打印错误,该函数作为公共函数,在本文档后续样例中不再声明和定义 +static void GetLastErrorAndClean(JSVM_Env env) +{ + // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); + // 打印错误信息 + JSVM_Value message; + JSVM_Value errorCode; + OH_JSVM_GetNamedProperty((env), result, "message", &message); + OH_JSVM_GetNamedProperty((env), result, "code", &errorCode); + const int maxMessageLength = 256; + const int maxCodeLength = 256; + char messagestr[maxMessageLength]; + char codeStr[maxCodeLength]; + OH_JSVM_GetValueStringUtf8(env, message, messagestr, maxMessageLength, nullptr); + OH_JSVM_GetValueStringUtf8(env, errorCode, codeStr, maxCodeLength, nullptr); + OH_LOG_INFO(LOG_APP, "JSVM error message: %{public}s, error code: %{public}s", messagestr, codeStr); +} + +// [Start oh_jsvm_throw_syntax_error] +// OH_JSVM_ThrowSyntaxError的样例方法 +static JSVM_Value JsVmThrowSyntaxError(JSVM_Env env, JSVM_CallbackInfo info) +{ + // JS侧传入运行的JS代码 + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + JSVM_Script script = nullptr; + // 通过OH_JSVM_CompileScript接口编译JS代码 + OH_JSVM_CompileScript(env, argv[0], nullptr, 0, true, nullptr, &script); + JSVM_Value scriptResult = nullptr; + // 通过OH_JSVM_RunScript接口运行JS代码 + JSVM_Status status = OH_JSVM_RunScript(env, script, &scriptResult); + if (status != JSVM_OK) { + // 如果JSVM_RunScript接口返回状态不为JSVM_OK,则抛出一个SyntaxError + OH_JSVM_ThrowSyntaxError(env, "JsVmThrowSyntaxError", "throw syntax error"); + GetLastErrorAndClean(env); + return nullptr; + } + JSVM_Value result = nullptr; + OH_JSVM_GetBoolean(env, true, &result); + return result; +} +// JsVmThrowSyntaxError注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmThrowSyntaxError}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmThrowSyntaxError方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmThrowSyntaxError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmThrowSyntaxError();)JS"; +// [End oh_jsvm_throw_syntax_error] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "throwsyntaxerror", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/oh-package.json5 new file mode 100644 index 0000000000..da7cb3b77c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/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": "libthrowsyntaxerror.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..b527e27d96 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libthrowsyntaxerror.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/throwsyntaxerrorability/ThrowsyntaxerrorAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/throwsyntaxerrorability/ThrowsyntaxerrorAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/throwsyntaxerrorability/ThrowsyntaxerrorAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/throwsyntaxerrorability/ThrowsyntaxerrorAbility.ets index acb971da27..1e16c210f1 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/throwsyntaxerrorability/ThrowsyntaxerrorAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/throwsyntaxerrorability/ThrowsyntaxerrorAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class ThrowsyntaxerrorAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class ThrowsyntaxerrorAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/module.json5 new file mode 100644 index 0000000000..a9c59db7c7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "throwsyntaxerror", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "ThrowsyntaxerrorAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ThrowsyntaxerrorAbility", + "srcEntry": "./ets/throwsyntaxerrorability/ThrowsyntaxerrorAbility.ets", + "description": "$string:ThrowsyntaxerrorAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ThrowsyntaxerrorAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..1cb0b10b44 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "ThrowsyntaxerrorAbility_desc", + "value": "description" + }, + { + "name": "ThrowsyntaxerrorAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..3bf8f3e6d0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testThrowSyntaxError', 0, async (done: Function) => { + console.log('uitest: TestThrowSyntaxError begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'ThrowsyntaxerrorAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('ThrowsyntaxerrorAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestThrowSyntaxError end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/module.json5 new file mode 100644 index 0000000000..88f620e849 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "throwsyntaxerror_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/oh-package.json5 new file mode 100644 index 0000000000..e0ee682a34 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/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": "throwtypeerror", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libthrowtypeerror.so": "file:./src/main/cpp/types/libthrowtypeerror" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..48f97e21c2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(throwtypeerror SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(throwtypeerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..49d8898f15 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/hello.cpp @@ -0,0 +1,183 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +static void GetLastErrorAndClean(JSVM_Env env) +{ + // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API + JSVM_Value result = nullptr; + JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); + // 打印错误信息 + JSVM_Value message; + JSVM_Value errorCode; + OH_JSVM_GetNamedProperty((env), result, "message", &message); + OH_JSVM_GetNamedProperty((env), result, "code", &errorCode); + const int maxMessageLength = 256; + const int maxCodeLength = 256; + char messagestr[maxMessageLength]; + char codeStr[maxCodeLength]; + OH_JSVM_GetValueStringUtf8(env, message, messagestr, maxMessageLength, nullptr); + OH_JSVM_GetValueStringUtf8(env, errorCode, codeStr, maxCodeLength, nullptr); + OH_LOG_INFO(LOG_APP, "JSVM error message: %{public}s, error code: %{public}s", messagestr, codeStr); +} + +// [Start oh_jsvm_throw_type_error] +// OH_JSVM_ThrowTypeError的样例方法 +static JSVM_Value JsVmThrowTypeError(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); + if (argc == 0) { + // 如果没有传递参数,直接抛出错误 + OH_JSVM_ThrowTypeError(env, "-1", "throwing type error"); + } else if (argc == 1) { + size_t length; + // 通过入参获取到javaScript侧传入的字符串长度 + OH_JSVM_GetValueStringUtf8(env, argv[0], nullptr, 0, &length); + char *buffer = new char[length + 1]; + // 获取入参的字符串内容 + OH_JSVM_GetValueStringUtf8(env, argv[0], buffer, length + 1, nullptr); + // 作为error信息填入到OH_JSVM_ThrowError接口中 + OH_JSVM_ThrowTypeError(env, "self defined error code", buffer); + delete[] buffer; + } + GetLastErrorAndClean(env); + return nullptr; +} +// JsVmThrowTypeError注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsVmThrowTypeError}, +}; +static JSVM_CallbackStruct *method = param; +// JsVmThrowTypeError方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"jsVmThrowTypeError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char *SRC_CALL_NATIVE = R"JS(jsVmThrowTypeError();jsVmThrowTypeError("self defined error message");)JS"; +// [End oh_jsvm_throw_type_error] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "throwtypeerror", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/oh-package.json5 new file mode 100644 index 0000000000..f14a6db9ce --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/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": "libthrowtypeerror.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..a49adff02a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libthrowtypeerror.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/throwtypeerrorability/ThrowtypeerrorAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/throwtypeerrorability/ThrowtypeerrorAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/throwtypeerrorability/ThrowtypeerrorAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/throwtypeerrorability/ThrowtypeerrorAbility.ets index 2d14d456ad..2c1dab4730 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/throwtypeerrorability/ThrowtypeerrorAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/throwtypeerrorability/ThrowtypeerrorAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class ThrowtypeerrorAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class ThrowtypeerrorAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/module.json5 new file mode 100644 index 0000000000..6a7f7e1f3c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/module.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "throwtypeerror", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "ThrowtypeerrorAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ThrowtypeerrorAbility", + "srcEntry": "./ets/throwtypeerrorability/ThrowtypeerrorAbility.ets", + "description": "$string:ThrowtypeerrorAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ThrowtypeerrorAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..908e0f170b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "ThrowtypeerrorAbility_desc", + "value": "description" + }, + { + "name": "ThrowtypeerrorAbility_label", + "value": "JsvmError" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..5b234d6ecd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testThrowTypeError', 0, async (done: Function) => { + console.log('uitest: TestThrowTypeError begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'ThrowtypeerrorAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('ThrowtypeerrorAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestThrowTypeError end'); + done(); + }) + }) +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/module.json5 new file mode 100644 index 0000000000..4d18ae367f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "throwtypeerror_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/app.json5 new file mode 100644 index 0000000000..03f0b7aac0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/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.jsvmlifecycle", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..a81a963d2c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JsvmLifeCycle" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/README.md new file mode 100644 index 0000000000..fb56535ae3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/README.md @@ -0,0 +1,141 @@ +# ArkTs使用JSVM-API接口进行生命周期相关开发 + +### 介绍 + +在JSVM-API中,JSVM_Value是一个表示JavaScript值的抽象类型,它可以表示任何JavaScript值,包括基本类型(如数字、字符串、布尔值)和对象类型(如数组、函数、对象等)。 JSVM_Value的生命周期与其在JavaScript中的对应值的生命周期紧密相关。当JavaScript值被垃圾回收时,与之关联的JSVM_Value也将不再有效。重要的是不要在JavaScript值不再存在时尝试使用JSVM_Value。 + +框架层的scope通常用于管理JSVM_Value的生命周期。在JSVM-API中,可以使用OH_JSVM_OpenHandleScope和OH_JSVM_CloseHandleScope函数来创建和销毁scope。通过在scope内创建JSVM_Value,可以确保在scope结束时自动释放JSVM_Value,避免内存泄漏。 + +JSVM_Ref是一个JSVM-API类型,用于管理JSVM_Value的生命周期。JSVM_Ref允许您在JSVM_Value的生命周期内保持对其的引用,即使它已经超出了其原始上下文的范围。这使得您可以在不同的上下文中共享JSVM_Value,并确保在不再需要时正确释放其内存。 + +合理使用OH_JSVM_OpenHandleScope和OH_JSVM_CloseHandleScope管理JSVM_Value的生命周期,做到生命周期最小化,避免发生内存泄漏问题。 + +每个JSVM_Value属于特定的HandleScope,HandleScope通过OH_JSVM_OpenHandleScope和OH_JSVM_CloseHandleScope来建立和关闭,HandleScope关闭后,所属的JSVM_Value就会自动释放。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口进行生命周期相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-life-cycle.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :---------------------------------------------------------------: | :---------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +addfinalizer/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +openescapablehandlescope/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +openhandlescope/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +referenceref/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle > .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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/oh-package.json5 new file mode 100644 index 0000000000..8f7a117b0c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/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": "addfinalizer", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libaddfinalizer.so": "file:./src/main/cpp/types/libaddfinalizer" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6b5f8e4813 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmLifeCycle) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(addfinalizer SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(addfinalizer PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..f21dfdd8c5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/hello.cpp @@ -0,0 +1,126 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_add_finalizer] +static int AddFinalizer(JSVM_VM vm, JSVM_Env env) +{ + // 打开 handlescope + JSVM_HandleScope handleScope; + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + // 创建 object 并设置回调 + JSVM_Value obj; + CHECK_RET(OH_JSVM_CreateObject(env, &obj)); + CHECK_RET(OH_JSVM_AddFinalizer( + env, obj, nullptr, + [](JSVM_Env env, void *data, void *hint) -> void { + // Finalizer 方法,可在该方法中清理 Native 对象 + OH_LOG_INFO(LOG_APP, "JSVM: finalizer called."); + }, + nullptr, nullptr)); + OH_LOG_INFO(LOG_APP, "JSVM: finalizer added."); + // 关闭 handlescope,触发 GC,GC 时 Finalizer 会被调用 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + OH_LOG_INFO(LOG_APP, "JSVM: before call gc."); + CHECK_RET(OH_JSVM_MemoryPressureNotification(env, JSVM_MemoryPressureLevel::JSVM_MEMORY_PRESSURE_LEVEL_CRITICAL)); + OH_LOG_INFO(LOG_APP, "JSVM: after call gc."); + + return 0; +} + +static void RunDemo(JSVM_VM vm, JSVM_Env env) +{ + if (AddFinalizer(vm, env) != 0) { + OH_LOG_INFO(LOG_APP, "Run PromiseRegisterHandler failed"); + } +} +// [End oh_jsvm_add_finalizer] + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + JSVM_VM vm; + JSVM_Env envs = nullptr; + RunDemo(vm, envs); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "addfinalizer", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/oh-package.json5 new file mode 100644 index 0000000000..2c7b363db4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/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": "libaddfinalizer.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/addfinalizerability/AddfinalizerAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/addfinalizerability/AddfinalizerAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/addfinalizerability/AddfinalizerAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/addfinalizerability/AddfinalizerAbility.ets index 8e9507b136..3f175ec34f --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/addfinalizerability/AddfinalizerAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/addfinalizerability/AddfinalizerAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class AddfinalizerAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class AddfinalizerAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..4ecafb6e1a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libaddfinalizer.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/module.json5 new file mode 100644 index 0000000000..d7637b4bad --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "addfinalizer", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "AddfinalizerAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "AddfinalizerAbility", + "srcEntry": "./ets/addfinalizerability/AddfinalizerAbility.ets", + "description": "$string:AddfinalizerAbility_desc", + "icon": "$media:layered_image", + "label": "$string:AddfinalizerAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..07298009eb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "AddfinalizerAbility_desc", + "value": "description" + }, + { + "name": "AddfinalizerAbility_label", + "value": "JsvmLifeCycle" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..856c055bab --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testAddFinalizer', 0, async (done: Function) => { + console.log('uitest: TestAddFinalizer begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'AddfinalizerAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('AddfinalizerAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestAddFinalizer end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/module.json5 new file mode 100644 index 0000000000..cbed882e35 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "addfinalizer_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/build-profile.json5 new file mode 100644 index 0000000000..e7cfbd6f62 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/build-profile.json5 @@ -0,0 +1,94 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "openhandlescope", + "srcPath": "./openhandlescope", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "openescapablehandlescope", + "srcPath": "./openescapablehandlescope", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "referenceref", + "srcPath": "./referenceref", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "addfinalizer", + "srcPath": "./addfinalizer", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..1e473e4243 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/ohosTest.md new file mode 100644 index 0000000000..d07a4aa352 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/ohosTest.md @@ -0,0 +1,11 @@ +# JsvmLifeCycle 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 为对象添加JSVM_Finalize回调,以便在JavaScript对象被垃圾回收时调用来释放原生对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 打开一个新的scope逃逸Handle scope,在关闭该scope之前创建的对象与父作用域有相同的生命周期 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 打开一个Handle scope,确保scope范围内的JSVM_Value不被GC回收 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 增加由Hello World创建的引用的引用计数,以确保对象在有引用时不会被提前释放 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/oh-package.json5 new file mode 100644 index 0000000000..f0cdca7079 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/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": "openescapablehandlescope", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libopenescapablehandlescope.so": "file:./src/main/cpp/types/libopenescapablehandlescope" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6009db0025 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmLifeCycle) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(openescapablehandlescope SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(openescapablehandlescope PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..dbf119d706 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/hello.cpp @@ -0,0 +1,177 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_open_escapable_handle_scope_close_escapable_handle_scope_escape_handle] +// OH_JSVM_OpenEscapableHandleScope、OH_JSVM_CloseEscapableHandleScope、OH_JSVM_EscapeHandle的样例方法 +static JSVM_Value EscapableHandleScopeTest(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 创建一个可逃逸的句柄作用域 + JSVM_EscapableHandleScope scope = nullptr; + JSVM_Status status = OH_JSVM_OpenEscapableHandleScope(env, &scope); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_OpenEscapableHandleScope: failed"); + return nullptr; + } + // 在可逃逸的句柄作用域内创建一个obj + JSVM_Value obj; + OH_JSVM_CreateObject(env, &obj); + // 在对象中添加属性 + JSVM_Value value = nullptr; + OH_JSVM_CreateStringUtf8(env, "Test jsvm_escapable_handle_scope", JSVM_AUTO_LENGTH, &value); + OH_JSVM_SetNamedProperty(env, obj, "name", value); + // 调用OH_JSVM_EscapeHandle将对象逃逸到作用域之外 + JSVM_Value escapedObj = nullptr; + OH_JSVM_EscapeHandle(env, scope, obj, &escapedObj); + // 关闭可逃逸的句柄作用域,清理资源 + status = OH_JSVM_CloseEscapableHandleScope(env, scope); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CloseEscapableHandleScope: failed"); + return nullptr; + } + // 此时的escapedObj已逃逸,可以在作用域外继续使用escapedObj + bool result = false; + OH_JSVM_CreateStringUtf8(env, "name", JSVM_AUTO_LENGTH, &value); + OH_JSVM_HasProperty(env, escapedObj, value, &result); + if (result) { + OH_LOG_INFO(LOG_APP, "JSVM EscapableHandleScopeTest: success"); + } + return escapedObj; +} + +// EscapableHandleScopeTest注册回调 +static JSVM_CallbackStruct param[] = { + {.callback = EscapableHandleScopeTest, .data = nullptr}, +}; +static JSVM_CallbackStruct *method = param; +// EscapableHandleScopeTest方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"escapableHandleScopeTest", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +const char *SRC_CALL_NATIVE = "escapableHandleScopeTest()"; +// [End oh_jsvm_open_escapable_handle_scope_close_escapable_handle_scope_escape_handle] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "openescapablehandlescope", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/oh-package.json5 new file mode 100644 index 0000000000..fdf2122962 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/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": "libopenescapablehandlescope.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/openescapablehandlescopeability/OpenescapablehandlescopeAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/openescapablehandlescopeability/OpenescapablehandlescopeAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/openescapablehandlescopeability/OpenescapablehandlescopeAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/openescapablehandlescopeability/OpenescapablehandlescopeAbility.ets index ca71248535..6802668c14 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/openescapablehandlescopeability/OpenescapablehandlescopeAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/openescapablehandlescopeability/OpenescapablehandlescopeAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class OpenescapablehandlescopeAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class OpenescapablehandlescopeAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..25099de28d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libopenescapablehandlescope.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/module.json5 new file mode 100644 index 0000000000..ac31360dee --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "openescapablehandlescope", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "OpenescapablehandlescopeAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "OpenescapablehandlescopeAbility", + "srcEntry": "./ets/openescapablehandlescopeability/OpenescapablehandlescopeAbility.ets", + "description": "$string:OpenescapablehandlescopeAbility_desc", + "icon": "$media:layered_image", + "label": "$string:OpenescapablehandlescopeAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..603926c5ce --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "OpenescapablehandlescopeAbility_desc", + "value": "description" + }, + { + "name": "OpenescapablehandlescopeAbility_label", + "value": "JsvmLifeCycle" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..a4b372d04b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testOpenEscapableHandleScope', 0, async (done: Function) => { + console.log('uitest: TestOpenEscapableHandleScope begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'OpenescapablehandlescopeAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('OpenescapablehandlescopeAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestOpenEscapableHandleScope end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/module.json5 new file mode 100644 index 0000000000..99aacbc46a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "openescapablehandlescope_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/oh-package.json5 new file mode 100644 index 0000000000..7afe9b6f36 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/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": "openhandlescope", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libopenhandlescope.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..14b6929491 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmLifeCycle) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(openhandlescope SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(openhandlescope PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..e6cbf9a8b3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/hello.cpp @@ -0,0 +1,169 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_open_handle_scope_and_oh_jsvm_close_handle_scope] +// OH_JSVM_OpenHandleScope、OH_JSVM_CloseHandleScope的三种样例方法 +static JSVM_Value HandleScopeFor(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 在for循环中频繁调用JSVM接口创建js对象时,要加handle_scope及时释放不再使用的资源。 + // 下面例子中,每次循环结束局部变量res的生命周期已结束,因此加scope及时释放其持有的js对象,防止内存泄漏 + constexpr uint32_t DIFF_VALUE_HUNDRED_THOUSAND = 10000; + JSVM_Value checked = nullptr; + for (int i = 0; i < DIFF_VALUE_HUNDRED_THOUSAND; i++) { + JSVM_HandleScope scope = nullptr; + JSVM_Status status = OH_JSVM_OpenHandleScope(env, &scope); + if (status != JSVM_OK || scope == nullptr) { + OH_JSVM_GetBoolean(env, false, &checked); + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_OpenHandleScope: failed"); + return checked; + } + JSVM_Value res = nullptr; + OH_JSVM_CreateObject(env, &res); + status = OH_JSVM_CloseHandleScope(env, scope); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CloseHandleScope: failed"); + } + } + OH_JSVM_GetBoolean(env, true, &checked); + OH_LOG_INFO(LOG_APP, "JSVM HandleScopeFor: success"); + return checked; +} + +// HandleScopeFor注册回调 +static JSVM_CallbackStruct param[] = { + {.callback = HandleScopeFor, .data = nullptr}, +}; + +static JSVM_CallbackStruct *method = param; +// HandleScopeFor方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"HandleScopeFor", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +const char *SRC_CALL_NATIVE = "HandleScopeFor()"; +// [End oh_jsvm_open_handle_scope_and_oh_jsvm_close_handle_scope] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "openhandlescope", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..7d6e6febff --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/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": "libopenhandlescope.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..8a8cd1c9b4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libopenhandlescope.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/module.json5 new file mode 100644 index 0000000000..1c9a28b2fa --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/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": "openhandlescope", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..b6f5d69fa1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/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": "JsvmLifeCycle" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..da98ac03f9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testOpenHandleScope', 0, async (done: Function) => { + console.log('uitest: TestOpenHandleScope begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestOpenHandleScope end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/module.json5 new file mode 100644 index 0000000000..d34e999239 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "openhandlescope_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/oh-package.json5 new file mode 100644 index 0000000000..1b0a19f319 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/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": "referenceref", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libreferenceref.so": "file:./src/main/cpp/types/libreferenceref" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..cfff8a97cd --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(JsvmLifeCycle) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(referenceref SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(referenceref PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..09fa88cbb0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/hello.cpp @@ -0,0 +1,195 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_reference_ref_and_oh_jsvm_reference_unref] +static JSVM_Value UseReference(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 创建 JavaScript 对象 + JSVM_Value obj = nullptr; + OH_JSVM_CreateObject(env, &obj); + JSVM_Value value = nullptr; + OH_JSVM_CreateStringUtf8(env, "UseReference", JSVM_AUTO_LENGTH, &value); + OH_JSVM_SetNamedProperty(env, obj, "name", value); + + JSVM_Ref g_ref = nullptr; + // 创建对JavaScript对象的引用 + JSVM_Status status = OH_JSVM_CreateReference(env, obj, 1, &g_ref); + if (status != JSVM_OK) { + return nullptr; + } + + // 增加传入引用的引用计数并返回生成的引用计数 + uint32_t result; + OH_JSVM_ReferenceRef(env, g_ref, &result); + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_ReferenceRef, count = %{public}d.", result); + const int resultValue = 2; + if (result != resultValue) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_ReferenceRef: failed"); + return nullptr; + } + + // 减少传入引用的引用计数并返回生成的引用计数 + uint32_t num; + OH_JSVM_ReferenceUnref(env, g_ref, &num); + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_ReferenceUnref, count = %{public}d.", num); + if (num != 1) { + return nullptr; + } + + JSVM_Value object = nullptr; + // 通过调用OH_JSVM_GetReferenceValue获取引用的JavaScript对象 + status = OH_JSVM_GetReferenceValue(env, g_ref, &object); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetReferenceValue: failed"); + return nullptr; + } + + // 不再使用引用,通过调用OH_JSVM_DeleteReference删除对JavaScript对象的引用 + status = OH_JSVM_DeleteReference(env, g_ref); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_DeleteReference: failed"); + return nullptr; + } + + // 将获取到的对象返回 + OH_LOG_INFO(LOG_APP, "JSVM UseReference success"); + return object; +} + +// CreateReference、UseReference、DeleteReference注册回调 +static JSVM_CallbackStruct param[] = { + {.callback = UseReference, .data = nullptr}, +}; +static JSVM_CallbackStruct *method = param; +// CreateReference、UseReference、DeleteReference方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"useReference", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +const char *SRC_CALL_NATIVE = "useReference()"; +// [End oh_jsvm_reference_ref_and_oh_jsvm_reference_unref] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "referenceref", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/oh-package.json5 new file mode 100644 index 0000000000..00b60dcce9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/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": "libreferenceref.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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..19bc6dba18 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libreferenceref.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/referencerefability/ReferencerefAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/referencerefability/ReferencerefAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/referencerefability/ReferencerefAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/referencerefability/ReferencerefAbility.ets index 0b6a17a068..5d3dd16cee --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/referencerefability/ReferencerefAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/referencerefability/ReferencerefAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class ReferencerefAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class ReferencerefAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/module.json5 new file mode 100644 index 0000000000..ab9624e612 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "referenceref", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "ReferencerefAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ReferencerefAbility", + "srcEntry": "./ets/referencerefability/ReferencerefAbility.ets", + "description": "$string:ReferencerefAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ReferencerefAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/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/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..de9920cf09 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "ReferencerefAbility_desc", + "value": "description" + }, + { + "name": "ReferencerefAbility_label", + "value": "JsvmLifeCycle" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..b6cc3c556a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testReferenceRef', 0, async (done: Function) => { + console.log('uitest: TestReferenceRef begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'ReferencerefAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('ReferencerefAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestReferenceRef end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/module.json5 new file mode 100644 index 0000000000..59eb234df7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "referenceref_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/screenshots/JsvmLifeCycle_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/screenshots/JsvmLifeCycle_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/screenshots/JsvmLifeCycle_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/screenshots/JsvmLifeCycle_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/screenshots/JsvmLifeCycle_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/screenshots/JsvmLifeCycle_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/screenshots/JsvmLifeCycle_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/screenshots/JsvmLifeCycle_2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/app.json5 new file mode 100644 index 0000000000..ad92f03cd6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/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.usageinstructionsone", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..16413e8d31 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "UsageInstructionsOne" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/README.md new file mode 100644 index 0000000000..dffd83b7c7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/README.md @@ -0,0 +1,160 @@ +# ArkTS JSVM-API使用指导 + +### 介绍 + +使用JSVM-API实现跨语言交互,首先需要按照JSVM-API的机制实现模块的注册和加载等相关动作。 + +- ArkTS/JS侧:实现C++方法的调用。代码比较简单,import一个对应的so库后,即可调用C++方法。 +- Native侧:.cpp文件,实现模块的注册。需要提供注册lib库的名称,并在注册回调方法中定义接口的映射关系,即Native方法及对应的JS/ArkTS接口名称等。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口进行函数创建和调用](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-function-call.md) +- [使用JSVM-API接口进行虚拟机快照相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-create-snapshot.md) +- [使用JSVM-API接口进行JSON操作](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-JSON.md) +- [使用JSVM-API接口进行任务队列相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-execute_tasks.md) +- [使用JSVM-API接口进行WebAssembly模块相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-wasm.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------------------: | :----------------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击hello world,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +aboutjson/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +createsnapshot/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +functioncall/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +pumpmessageloop/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 + webassembly/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/UsageInstructionsOne > .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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/oh-package.json5 new file mode 100644 index 0000000000..3eef1a4384 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/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": "aboutjson", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libaboutjson.so": "file:./src/main/cpp/types/libaboutjson" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..7e4c935ba6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(aboutjson SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(aboutjson PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..965823b684 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/hello.cpp @@ -0,0 +1,185 @@ +/* + * 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 "ark_runtime/jsvm.h" +#include +#include + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_json_parse_and_json_stringify] +// 解析JSON数字 +static JSVM_Value JsonParseNumber(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 设置要解析的JSON数字 + std::string strNumber = "10.555"; + JSVM_Value jsonString; + JSVM_CALL(OH_JSVM_CreateStringUtf8(env, strNumber.c_str(), strNumber.size(), &jsonString)); + JSVM_Value jsonObject; + // 调用OH_JSVM_JsonParse函数解析JSON数字,并将结果存储在JSON对象中 + JSVM_CALL(OH_JSVM_JsonParse(env, jsonString, &jsonObject)); + double number; + JSVM_CALL(OH_JSVM_GetValueDouble(env, jsonObject, &number)); + OH_LOG_INFO(LOG_APP, "Test JSVM jsonParseNumber: %{public}f", number); + return nullptr; +} + +// 解析JSON字符串中的对象 +static JSVM_Value JsonParseObject(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 设置要解析的JSON对象字符串 + std::string strObject = "{\"first\": \"one\", \"second\": \"two\", \"third\": \"three\"}"; + JSVM_Value strJson; + JSVM_CALL(OH_JSVM_CreateStringUtf8(env, strObject.c_str(), strObject.size(), &strJson)); + JSVM_Value jsonObject; + // 调用OH_JSVM_JsonParse函数解析JSON对象字符串,并将结果存储在JSON对象中 + JSVM_CALL(OH_JSVM_JsonParse(env, strJson, &jsonObject)); + JSVM_Value jsonString; + // 调用OH_JSVM_JsonStringify函数将对象转换为字符串格式,并将结果存储在JSVM字符串对象中 + JSVM_CALL(OH_JSVM_JsonStringify(env, jsonObject, &jsonString)); + size_t totalLen = 0; + JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, nullptr, 0, &totalLen)); + size_t needLen = totalLen + 1; + char* buff = new char[needLen]; + JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, buff, needLen, &totalLen)); + OH_LOG_INFO(LOG_APP, "Test JSVM jsonParseNumber: %{public}s", buff); + delete[] buff; + return nullptr; +} + +// JsonParse注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = JsonParseNumber}, + {.data = nullptr, .callback = JsonParseObject}, +}; + +static JSVM_CallbackStruct *method = param; + +JSVM_PropertyDescriptor descriptor[] = { + {"jsonParseNumber", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, + {"jsonParseObject", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 待执行的js代码 +static const char *STR_TASK = R"JS(jsonParseNumber();jsonParseObject();)JS"; +// [End oh_jsvm_json_parse_and_json_stringify] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, STR_TASK, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "aboutjson", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/oh-package.json5 new file mode 100644 index 0000000000..4186c9f033 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/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": "libaboutjson.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/aboutjsonability/AboutjsonAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/aboutjsonability/AboutjsonAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/aboutjsonability/AboutjsonAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/aboutjsonability/AboutjsonAbility.ets index 62594c6b94..ac9499d7d3 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/aboutjsonability/AboutjsonAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/aboutjsonability/AboutjsonAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class AboutjsonAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class AboutjsonAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..4ba46b0d01 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libaboutjson.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/module.json5 new file mode 100644 index 0000000000..6cb67f9f71 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "aboutjson", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "AboutjsonAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "AboutjsonAbility", + "srcEntry": "./ets/aboutjsonability/AboutjsonAbility.ets", + "description": "$string:AboutjsonAbility_desc", + "icon": "$media:layered_image", + "label": "$string:AboutjsonAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..e2fa38f441 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "AboutjsonAbility_desc", + "value": "description" + }, + { + "name": "AboutjsonAbility_label", + "value": "UsageInstructionsOne" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..e91a9e1ef8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testAboutJSON', 0, async (done: Function) => { + console.log('uitest: TestAboutJSON begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'AboutjsonAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('AboutjsonAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestAboutJSON end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/module.json5 new file mode 100644 index 0000000000..5b74fd35ad --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/module.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. + */ + +{ + "module": { + "name": "aboutjson_test", + "type": "feature", + "deviceTypes": [ + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/build-profile.json5 new file mode 100644 index 0000000000..73c8c74ee0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/build-profile.json5 @@ -0,0 +1,106 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "createsnapshot", + "srcPath": "./createsnapshot", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "functioncall", + "srcPath": "./functioncall", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "aboutjson", + "srcPath": "./aboutjson", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "pumpmessageloop", + "srcPath": "./pumpmessageloop", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "webassembly", + "srcPath": "./webassembly", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/oh-package.json5 new file mode 100644 index 0000000000..23894ad544 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/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": "createsnapshot", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libcreatesnapshot.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..d48847ce59 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(createsnapshot SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(createsnapshot PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..ca726795ad --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/hello.cpp @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_create_snapshot_and_create_env_from_snapshot] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include +#include + +#define LOG_DEMAIN 0x0202 +#define LOG_TAG "TEST_TAG" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用GET_AND_THROW_LAST_ERROR处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +static const int MAX_BUFFER_SIZE = 128; +// CreateHelloString()函数需绑定到JSVM虚拟机, 用于OH_JSVM_CreateSnapshot虚拟机快照的正常创建 +static JSVM_Value CreateHelloString(JSVM_Env env, JSVM_CallbackInfo info) +{ + JSVM_Value outPut; + OH_JSVM_CreateStringUtf8(env, "Hello world!", JSVM_AUTO_LENGTH, &outPut); + return outPut; +} +// 提供外部引用的方式以便JavaScript环境可以调用绑定的函数 +static JSVM_CallbackStruct helloCb = {CreateHelloString, nullptr}; + +static intptr_t g_externals[] = { + (intptr_t)&helloCb, + 0, +}; + +static JSVM_Value RunVMScript(JSVM_Env env, std::string &src) +{ + // 打开handleScope作用域 + JSVM_HandleScope handleScope; + OH_JSVM_OpenHandleScope(env, &handleScope); + JSVM_Value jsStr = nullptr; + OH_JSVM_CreateStringUtf8(env, src.c_str(), src.size(), &jsStr); + // 编译JavaScript代码 + JSVM_Script script; + OH_JSVM_CompileScript(env, jsStr, nullptr, 0, true, nullptr, &script); + // 执行JavaScript代码 + JSVM_Value result = nullptr; + OH_JSVM_RunScript(env, script, &result); + // 关闭handleScope作用域 + OH_JSVM_CloseHandleScope(env, handleScope); + return result; +} +// OH_JSVM_CreateSnapshot的样例方法 +static void CreateVMSnapshot() +{ + // 创建JavaScript虚拟机实例,打开虚拟机作用域 + JSVM_VM vm; + JSVM_CreateVMOptions vmOptions; + memset(&vmOptions, 0, sizeof(vmOptions)); + // isForSnapshotting设置该虚拟机是否用于创建快照 + vmOptions.isForSnapshotting = true; + OH_JSVM_CreateVM(&vmOptions, &vm); + JSVM_VMScope vmScope; + OH_JSVM_OpenVMScope(vm, &vmScope); + // 创建JavaScript环境,打开环境作用域 + JSVM_Env env; + // 将native函数注册成JavaScript可调用的方法 + JSVM_PropertyDescriptor descriptor[] = { + {"createHelloString", nullptr, &helloCb, nullptr, nullptr, nullptr, JSVM_DEFAULT}, + }; + OH_JSVM_CreateEnv(vm, 1, descriptor, &env); + JSVM_EnvScope envScope; + OH_JSVM_OpenEnvScope(env, &envScope); + // 使用OH_JSVM_CreateSnapshot创建虚拟机的启动快照 + const char *blobData = nullptr; + size_t blobSize = 0; + JSVM_Env envs[1] = {env}; + OH_JSVM_CreateSnapshot(vm, 1, envs, &blobData, &blobSize); + // 将snapshot保存到文件中 + // 保存快照数据,/data/storage/el2/base/files/test_blob.bin为沙箱路径 + // 以包名为com.example.jsvm为例,实际文件会保存到/data/app/el2/100/base/com.example.jsvm/files/test_blob.bin + std::ofstream file("/data/storage/el2/base/files/test_blob.bin", + std::ios::out | std::ios::binary | std::ios::trunc); + file.write(blobData, blobSize); + file.close(); + // 关闭并销毁环境和虚拟机 + OH_JSVM_CloseEnvScope(env, envScope); + OH_JSVM_DestroyEnv(env); + OH_JSVM_CloseVMScope(vm, vmScope); + OH_JSVM_DestroyVM(vm); +} + +static void RunVMSnapshot() +{ + // blobData的生命周期不能短于vm的生命周期 + // 从文件中读取snapshot + std::vector blobData; + std::ifstream file("/data/storage/el2/base/files/test_blob.bin", std::ios::in | std::ios::binary | std::ios::ate); + size_t blobSize = file.tellg(); + blobData.resize(blobSize); + file.seekg(0, std::ios::beg); + file.read(blobData.data(), blobSize); + file.close(); + OH_LOG_INFO(LOG_APP, "Test JSVM RunVMSnapshot read file blobSize = : %{public}ld", blobSize); + // 使用快照数据创建虚拟机实例 + JSVM_VM vm; + JSVM_CreateVMOptions vmOptions; + memset(&vmOptions, 0, sizeof(vmOptions)); + vmOptions.snapshotBlobData = blobData.data(); + vmOptions.snapshotBlobSize = blobSize; + OH_JSVM_CreateVM(&vmOptions, &vm); + JSVM_VMScope vmScope; + OH_JSVM_OpenVMScope(vm, &vmScope); + // 从快照中创建环境env + JSVM_Env env; + OH_JSVM_CreateEnvFromSnapshot(vm, 0, &env); + JSVM_EnvScope envScope; + OH_JSVM_OpenEnvScope(env, &envScope); + // 执行js脚本,快照记录的env中定义了createHelloString() + std::string src = "createHelloString()"; + JSVM_Value result = RunVMScript(env, src); + // 环境关闭前检查脚本运行结果 + char str[MAX_BUFFER_SIZE]; + OH_JSVM_GetValueStringUtf8(env, result, str, MAX_BUFFER_SIZE, nullptr); + if (strcmp(str, "Hello world!") != 0) { + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d", __FILE__, __LINE__); + } + // 关闭并销毁环境和虚拟机 + OH_JSVM_CloseEnvScope(env, envScope); + OH_JSVM_DestroyEnv(env); + OH_JSVM_CloseVMScope(vm, vmScope); + OH_JSVM_DestroyVM(vm); + return; +} + +static JSVM_Value AdjustExternalMemory(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 在创建虚拟机快照时,如果存在对外部的依赖,需要在OH_JSVM_Init时,将外部依赖注册到initOptions.externalReferences中 + // 创建虚拟机快照并将快照保存到文件中 + CreateVMSnapshot(); + // snapshot可以记录下特定的js执行环境,可以跨进程通过snapshot快速还原出js执行上下文环境 + RunVMSnapshot(); + JSVM_Value result = nullptr; + OH_JSVM_CreateInt32(env, 0, &result); + return result; +} + +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = AdjustExternalMemory}, +}; +static JSVM_CallbackStruct *method = param; +// AdjustExternalMemory方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"adjustExternalMemory", nullptr, method, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试JS +const char *SRC_CALL_NATIVE = R"JS(adjustExternalMemory();)JS"; + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + initOptions.externalReferences = g_externals; + int argc = 0; + char **argv = nullptr; + initOptions.argc = &argc; + initOptions.argv = argv; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + OH_LOG_INFO(LOG_APP, "JSVM Init"); + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "createsnapshot", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +// [End oh_jsvm_create_snapshot_and_create_env_from_snapshot] diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..dfb4b188c2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/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": "libcreatesnapshot.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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..0e181902f3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/pages/Index.ets @@ -0,0 +1,45 @@ +/* + * 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 napitest from 'libcreatesnapshot.so'; + +// [Start create_snapshot_call_native] +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} +// [End create_snapshot_call_native] diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/module.json5 new file mode 100644 index 0000000000..769e893b6b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/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": "createsnapshot", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..3b974782ef --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/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": "UsageInstructionsOne" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..4b108b49b4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testVirtualMachine', 0, async (done: Function) => { + console.log('uitest: TestVirtualMachine begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestVirtualMachine end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/module.json5 new file mode 100644 index 0000000000..6350e0f5d3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "createsnapshot_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/oh-package.json5 new file mode 100644 index 0000000000..d615c36619 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/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": "functioncall", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libfunctioncall.so": "file:./src/main/cpp/types/libfunctioncall" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..a93514b123 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 添加名为entry的库 +add_library(functioncall SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(functioncall PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..ecb51ba893 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/hello.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start jsvm_function_call] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +#define CHECK_RET(cond) \ + if ((cond)) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } + +#define CHECK(cond) \ + if (!(cond)) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } + +JSVM_Value NativeCreateFunctionTest(JSVM_Env env, JSVM_CallbackInfo info) +{ + void *data; + size_t argc = 1; + JSVM_Value argv[1] = {nullptr}; + JSVM_Value thisArg; + // 获取callback 参数信息 + JSVM_Status ret = OH_JSVM_GetCbInfo(env, info, &argc, &argv[0], &thisArg, &data); + if (ret != JSVM_OK) { + const JSVM_ExtendedErrorInfo *info; + OH_JSVM_GetLastErrorInfo(env, &info); + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", + __FILE__, __LINE__, ret, info != nullptr ? info->errorMessage : ""); + return nullptr; + } + const int maxMessageLength = 256; + char message[256]; + OH_JSVM_GetValueStringLatin1(env, argv[0], message, maxMessageLength, nullptr); + if (data == nullptr) { + OH_LOG_ERROR(LOG_APP, "jsvm: %{public}s; callback data null", message); + } else { + OH_LOG_INFO(LOG_APP, "jsvm: %{public}s; %{public}s", message, (char *)data); + } + return nullptr; +} + +static int32_t TEST_FUNC() +{ + JSVM_InitOptions initOptions{}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + static bool isVMInit = false; + if (!isVMInit) { + isVMInit = true; + // 单个进程只用初始化一次 + OH_JSVM_Init(&initOptions); + } + CHECK_RET(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK_RET(OH_JSVM_CreateEnv(vm, 0, nullptr, &env)); + CHECK_RET(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 创建并检查函数 + char hello[] = "Hello World!"; + JSVM_CallbackStruct cb = {NativeCreateFunctionTest, (void *)hello}; + JSVM_Value func; + CHECK_RET(OH_JSVM_CreateFunction(env, "", JSVM_AUTO_LENGTH, &cb, &func)); + bool isFunction = false; + CHECK_RET(OH_JSVM_IsFunction(env, func, &isFunction)); + CHECK(isFunction); + + // 将函数设置到全局对象中 + JSVM_Value global; + CHECK_RET(OH_JSVM_GetGlobal(env, &global)); + JSVM_Value key; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, "NativeFunc", JSVM_AUTO_LENGTH, &key)); + CHECK_RET(OH_JSVM_SetProperty(env, global, key, func)); + + // 通过call 接口调用函数 + JSVM_Value argv[1] = {nullptr}; + OH_JSVM_CreateStringUtf8(env, "jsvm api call function", JSVM_AUTO_LENGTH, &argv[0]); + CHECK_RET(OH_JSVM_CallFunction(env, global, func, 1, argv, &result)); + + // 通过script调用函数 + JSVM_Script script; + JSVM_Value jsSrc; + const char *srcCallNative = R"JS(NativeFunc('js source call function');)JS"; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, srcCallNative, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK_RET(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK_RET(OH_JSVM_DestroyEnv(env)); + CHECK_RET(OH_JSVM_DestroyVM(vm)); + return 0; +} +// [End jsvm_function_call] + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TEST_FUNC(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "functioncall", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/oh-package.json5 new file mode 100644 index 0000000000..701827d530 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/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": "libfunctioncall.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/functioncallability/FunctioncallAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/functioncallability/FunctioncallAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/functioncallability/FunctioncallAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/functioncallability/FunctioncallAbility.ets index 71439a2d3e..308ebdac21 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/functioncallability/FunctioncallAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/functioncallability/FunctioncallAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class FunctioncallAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class FunctioncallAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..13de3baa1d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libfunctioncall.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/module.json5 new file mode 100644 index 0000000000..79be9255c5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "functioncall", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "FunctioncallAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "FunctioncallAbility", + "srcEntry": "./ets/functioncallability/FunctioncallAbility.ets", + "description": "$string:FunctioncallAbility_desc", + "icon": "$media:layered_image", + "label": "$string:FunctioncallAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..ed9da58e52 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "FunctioncallAbility_desc", + "value": "description" + }, + { + "name": "FunctioncallAbility_label", + "value": "UsageInstructionsOne" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..43bdcbc5c7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testFunctionCall', 0, async (done: Function) => { + console.log('uitest: TestFunctionCall begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'FunctioncallAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('FunctioncallAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestFunctionCall end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/module.json5 new file mode 100644 index 0000000000..71d4c586d9 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/module.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. + */ + +{ + "module": { + "name": "functioncall_test", + "type": "feature", + "deviceTypes": [ + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/ohosTest.md new file mode 100644 index 0000000000..343302a3ad --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/ohosTest.md @@ -0,0 +1,12 @@ +# UsageInstructionsOne 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|---------------------------------|--------|---------------|------------------|------|------| +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 使用JSVM-API接口进行JSON操作 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 使用JSVM-API接口进行函数创建和调用 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 使用JSVM-API接口进行虚拟机快照相关开发 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 使用JSVM-API接口进行任务队列相关开发 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 使用JSVM-API接口进行WebAssembly模块相关开发 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/build-profile.json5 new file mode 100644 index 0000000000..38bdcc9929 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/build-profile.json5 @@ -0,0 +1,39 @@ +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/oh-package.json5 new file mode 100644 index 0000000000..ca0dd64ef5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "pumpmessageloop", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libpumpmessageloop.so": "file:./src/main/cpp/types/libpumpmessageloop" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6a1aee019c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsOne) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(pumpmessageloop SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(pumpmessageloop PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..c925e81524 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/hello.cpp @@ -0,0 +1,197 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" +// [Start oh_jsvm_pump_message_loop_and_perform_microtask_checkpoint] +#include +#include +// [StartExclude oh_jsvm_pump_message_loop_and_perform_microtask_checkpoint] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_pump_message_loop_and_perform_microtask_checkpoint] + +// 待执行的js代码 +static const char *STR_TASK = R"JS( + // wasm 字节码 (以add 模块为例) + // 以下 wasmBuffer 对应的 wasm 字节码文本格式如下所示,只包含了一个函数 add + // (module + // (func $add (param $lhs i32) (param $rhs i32) (result i32) + // local.get $lhs + // local.get $rhs + // i32.add + // ) + // (export "add" (func $add)) + // ) + var wasmBytes = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, + 0x60, 0x02, 0x7f, 0x7f, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x07, + 0x07, 0x01, 0x03, 0x61, 0x64, 0x64, 0x00, 0x00, 0x0a, 0x09, 0x01, + 0x07, 0x00, 0x20, 0x00, 0x20, 0x01, 0x6a, 0x0b]); + + var p = WebAssembly.instantiate(wasmBytes, {}); + p.then((result) => { + consoleinfo("Called with instance " + result); + }); + p.finally(() => { + consoleinfo("Called Finally"); + }); +)JS"; + +// 保证js代码中的打印信息可以正常输出 +static JSVM_Value ConsoleInfo(JSVM_Env env, JSVM_CallbackInfo info) +{ + size_t argc = 1; + JSVM_Value args[1]; + #define MAX_LOG_LENGTH 255 + char log[MAX_LOG_LENGTH + 1] = ""; + size_t logLength; + JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, NULL, NULL)); + + OH_JSVM_GetValueStringUtf8(env, args[0], log, MAX_LOG_LENGTH, &logLength); + log[MAX_LOG_LENGTH] = 0; + OH_LOG_INFO(LOG_APP, "JSVM API TEST: %{public}s", log); + return nullptr; +} + +// 注册consoleinfo的方法 +JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = ConsoleInfo}, +}; +JSVM_PropertyDescriptor descriptor[] = { + {"consoleinfo", NULL, ¶m[0], NULL, NULL, NULL, JSVM_DEFAULT}, +}; + +static int32_t TestJSVM() +{ + JSVM_InitOptions init_options; + memset(&init_options, 0, sizeof(init_options)); + if (g_aa == 0) { + OH_JSVM_Init(&init_options); + g_aa++; + } + // 创建JavaScript虚拟机实例,打开虚拟机作用域 + JSVM_VM vm; + JSVM_CreateVMOptions options; + memset(&options, 0, sizeof(options)); + CHECK(OH_JSVM_CreateVM(&options, &vm)); + JSVM_VMScope vm_scope; + CHECK(OH_JSVM_OpenVMScope(vm, &vm_scope)); + + JSVM_Env env; + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + JSVM_EnvScope envScope; + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + JSVM_HandleScope handlescope; + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handlescope)); + JSVM_Value sourcecodevalue; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, STR_TASK, strlen(STR_TASK), &sourcecodevalue)); + JSVM_Script script; + CHECK_RET(OH_JSVM_CompileScript(env, sourcecodevalue, nullptr, 0, true, nullptr, &script)); + JSVM_Value result; + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + bool rst = false; + auto start = std::chrono::system_clock::now(); + while (true) { + // 如果任务队列中没有任务启动,则rst设置为false + CHECK_RET(OH_JSVM_PumpMessageLoop(vm, &rst)); + CHECK_RET(OH_JSVM_PerformMicrotaskCheckpoint(vm)); + // 定时退出 + auto now = std::chrono::system_clock::now(); + auto cost = std::chrono::duration_cast(now - start).count(); + const int timeoutMs = 100; + if (cost > timeoutMs) { + break; + } + } + + // 关闭并销毁环境和虚拟机 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handlescope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_CloseVMScope(vm, vm_scope)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} +// [End oh_jsvm_pump_message_loop_and_perform_microtask_checkpoint] + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "pumpmessageloop", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/oh-package.json5 new file mode 100644 index 0000000000..24f6bafaba --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/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": "libpumpmessageloop.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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..7ac85077e7 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libpumpmessageloop.so'; + +@Entry +@Component +struct Index { + @State message: string = 'OH_JSVM_PumpMessageLoop'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pumpmessageloopability/PumpmessageloopAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pumpmessageloopability/PumpmessageloopAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pumpmessageloopability/PumpmessageloopAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pumpmessageloopability/PumpmessageloopAbility.ets index 1c50f39a72..ce70b476cb --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pumpmessageloopability/PumpmessageloopAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pumpmessageloopability/PumpmessageloopAbility.ets @@ -1,41 +1,41 @@ -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class PumpmessageloopAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class PumpmessageloopAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/module.json5 new file mode 100644 index 0000000000..36fe86318c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/module.json5 @@ -0,0 +1,27 @@ +{ + "module": { + "name": "pumpmessageloop", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "PumpmessageloopAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "PumpmessageloopAbility", + "srcEntry": "./ets/pumpmessageloopability/PumpmessageloopAbility.ets", + "description": "$string:PumpmessageloopAbility_desc", + "icon": "$media:layered_image", + "label": "$string:PumpmessageloopAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/module.json5 new file mode 100644 index 0000000000..1631939700 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "pumpmessageloop_test", + "type": "feature", + "deviceTypes": [ + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/screenshots/UsageInstructionsOne_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/screenshots/UsageInstructionsOne_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/screenshots/UsageInstructionsOne_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/screenshots/UsageInstructionsOne_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/screenshots/UsageInstructionsOne_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/screenshots/UsageInstructionsOne_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/screenshots/UsageInstructionsOne_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/screenshots/UsageInstructionsOne_2.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/hvigorfile.ts similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/oh-package.json5 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/oh-package.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/oh-package.json5 diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/CMakeLists.txt similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/CMakeLists.txt rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/CMakeLists.txt diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/hello.cpp similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/hello.cpp rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/hello.cpp diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/oh-package.json5 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/oh-package.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/cpp/types/libwebassembly/oh-package.json5 diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/ets/pages/Index.ets similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/ets/pages/Index.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/ets/pages/Index.ets diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/ets/webassemblyability/WebassemblyAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/ets/webassemblyability/WebassemblyAbility.ets similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/ets/webassemblyability/WebassemblyAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/ets/webassemblyability/WebassemblyAbility.ets diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/module.json5 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/module.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/module.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/float.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/float.json new file mode 100644 index 0000000000..33ea22304f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/string.json similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/background.png similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/foreground.png similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/startIcon.png similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/Ability.test.ets similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/module.json5 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/module.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/webassembly/src/ohosTest/module.json5 diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/.gitignore rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/.gitignore diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/app.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/app.json5 new file mode 100644 index 0000000000..c845cc69ba --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/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.usageinstructionstwo", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..0ecae715a5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "UsageInstructionsTwo" + } + ] +} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/README.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/README.md new file mode 100644 index 0000000000..690d9c4d6f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/README.md @@ -0,0 +1,179 @@ +# ArkTS JSVM-API使用指导 + +### 介绍 + +使用JSVM-API实现跨语言交互,首先需要按照JSVM-API的机制实现模块的注册和加载等相关动作。 + +- ArkTS/JS侧:实现C++方法的调用。代码比较简单,import一个对应的so库后,即可调用C++方法。 +- Native侧:.cpp文件,实现模块的注册。需要提供注册lib库的名称,并在注册回调方法中定义接口的映射关系,即Native方法及对应的JS/ArkTS接口名称等。 + +该工程中展示的代码详细描述可查如下链接: + +- [使用JSVM-API接口获取JSVM API的版本号](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-version.md) +- [使用JSVM-API接口进行JavaScript代码调试调优](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-heapstatistics-debugger-cpuprofiler-heapsnapshot.md) +- [使用JSVM-API判断给定的两个JS value是否严格相等](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-strict-equals.md) +- [使用JSVM-API进行内存管理](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-memory-management.md) + +### 效果预览 + +| 首页 | 执行及结果即时反馈 | +| :----------------------------------------------------------------------: | :----------------------------------------------------------------------: | +| | | + +### 使用说明 + +1. 在主界面,可以点击Hello World,开始执行。 +2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 + +### 工程目录 + +``` +adjustexternalmemory/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getheapstatistics/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接口 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getversion/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +getvm/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +memorypressurenotification/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +strictequals/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ │ ├── libentry + │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 + │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 + │ │ ├── CMakeLists.txt // 配置CMake打包参数 + │ │ ├── hello.cpp // 实现Native侧的runTest接 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ ├── test + │ │ ├── Ability.test.ets // 自动化测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:Phone。 + +2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 + +3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo > .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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/oh-package.json5 new file mode 100644 index 0000000000..60036cd797 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/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": "adjustexternalmemory", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libadjustexternalmemory.so": "file:./src/main/cpp/types/libadjustexternalmemory" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..fcb47014e0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(adjustexternalmemory SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(adjustexternalmemory PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..34f3d637c6 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/hello.cpp @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_adjust_external_memory] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_adjust_external_memory] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_adjust_external_memory] + +// OH_JSVM_AdjustExternalMemory的样例方法 +static JSVM_Value AdjustExternalMemory(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 分配1MB的内存 + int64_t change = 1024 * 1024; + int64_t adjustedValue = 0; + JSVM_Status status = OH_JSVM_AdjustExternalMemory(env, change, &adjustedValue); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_AdjustExternalMemory: failed"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_AdjustExternalMemory: success"); + OH_LOG_INFO(LOG_APP, "JSVM Allocate memory size: %{public}d", adjustedValue); + } + JSVM_Value checked; + OH_JSVM_GetBoolean(env, true, &checked); + return checked; +} +// AdjustExternalMemory注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = AdjustExternalMemory}, +}; +static JSVM_CallbackStruct *method = param; +// AdjustExternalMemory方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"adjustExternalMemory", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +const char *SRC_CALL_NATIVE = R"JS(adjustExternalMemory())JS"; +// [End oh_jsvm_adjust_external_memory] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "adjustexternalmemory", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/oh-package.json5 new file mode 100644 index 0000000000..1255828d1d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/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": "libadjustexternalmemory.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/adjustexternalmemoryability/AdjustexternalmemoryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/adjustexternalmemoryability/AdjustexternalmemoryAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/adjustexternalmemoryability/AdjustexternalmemoryAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/adjustexternalmemoryability/AdjustexternalmemoryAbility.ets index d61ee4ac32..56cc3a6fa6 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/adjustexternalmemoryability/AdjustexternalmemoryAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/adjustexternalmemoryability/AdjustexternalmemoryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class AdjustexternalmemoryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class AdjustexternalmemoryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..3eeda3302a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libadjustexternalmemory.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/module.json5 new file mode 100644 index 0000000000..15384a3f96 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "adjustexternalmemory", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "AdjustexternalmemoryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "AdjustexternalmemoryAbility", + "srcEntry": "./ets/adjustexternalmemoryability/AdjustexternalmemoryAbility.ets", + "description": "$string:AdjustexternalmemoryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:AdjustexternalmemoryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..625d290483 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "AdjustexternalmemoryAbility_desc", + "value": "description" + }, + { + "name": "AdjustexternalmemoryAbility_label", + "value": "UsageInstructionsTwo" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..f6ba6ddb80 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testAdjustExternalMemory', 0, async (done: Function) => { + console.log('uitest: TestAdjustExternalMemory begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'AdjustexternalmemoryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('AdjustexternalmemoryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestAdjustExternalMemory end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/module.json5 new file mode 100644 index 0000000000..7627e73168 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "adjustexternalmemory_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/build-profile.json5 new file mode 100644 index 0000000000..8d2d2e894f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/build-profile.json5 @@ -0,0 +1,118 @@ +/* + * 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", + "compileSdkVersion": "5.0.3(15)", + "compatibleSdkVersion": "5.0.3(15)", + "targetSdkVersion": "5.0.3(15)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "getvm", + "srcPath": "./getvm", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getheapstatistics", + "srcPath": "./getheapstatistics", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "getversion", + "srcPath": "./getversion", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "adjustexternalmemory", + "srcPath": "./adjustexternalmemory", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "memorypressurenotification", + "srcPath": "./memorypressurenotification", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "strictequals", + "srcPath": "./strictequals", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/code-linter.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/code-linter.json5 rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/code-linter.json5 diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/oh-package.json5 new file mode 100644 index 0000000000..e7b0d2fc88 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/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": "getheapstatistics", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetheapstatistics.so": "file:./src/main/cpp/types/libgetheapstatistics" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..9a635c1954 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getheapstatistics SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getheapstatistics PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..350ab85ce4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/hello.cpp @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_heap_statistics] +#include "napi/native_api.h" +#include "hilog/log.h" +#include "ark_runtime/jsvm.h" +// [StartExclude oh_jsvm_get_heap_statistics] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_heap_statistics] + +// OH_JSVM_GetHeapStatistics的样例方法 +void PrintHeapStatistics(JSVM_HeapStatistics result) +{ + OH_LOG_INFO(LOG_APP, "JSVM API heap totalHeapSize: %{public}zu", result.totalHeapSize); + OH_LOG_INFO(LOG_APP, "JSVM API heap totalHeapSizeExecutable: %{public}zu", result.totalHeapSizeExecutable); + OH_LOG_INFO(LOG_APP, "JSVM API heap totalPhysicalSize: %{public}zu", result.totalPhysicalSize); + OH_LOG_INFO(LOG_APP, "JSVM API heap totalAvailableSize: %{public}zu", result.totalAvailableSize); + OH_LOG_INFO(LOG_APP, "JSVM API heap usedHeapSize: %{public}zu", result.usedHeapSize); + OH_LOG_INFO(LOG_APP, "JSVM API heap heapSizeLimit: %{public}zu", result.heapSizeLimit); + OH_LOG_INFO(LOG_APP, "JSVM API heap mallocedMemory: %{public}zu", result.mallocedMemory); + OH_LOG_INFO(LOG_APP, "JSVM API heap externalMemory: %{public}zu", result.externalMemory); + OH_LOG_INFO(LOG_APP, "JSVM API heap peakMallocedMemory: %{public}zu", result.peakMallocedMemory); + OH_LOG_INFO(LOG_APP, "JSVM API heap numberOfNativeContexts: %{public}zu", result.numberOfNativeContexts); + OH_LOG_INFO(LOG_APP, "JSVM API heap numberOfDetachedContexts: %{public}zu", result.numberOfDetachedContexts); + OH_LOG_INFO(LOG_APP, "JSVM API heap totalGlobalHandlesSize: %{public}zu", result.totalGlobalHandlesSize); + OH_LOG_INFO(LOG_APP, "JSVM API heap usedGlobalHandlesSize: %{public}zu", result.usedGlobalHandlesSize); +} + +static JSVM_Value GetHeapStatistics(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取当前虚拟机对象 + JSVM_VM testVm; + OH_JSVM_GetVM(env, &testVm); + // 获取虚拟机的堆统计信息 + JSVM_HeapStatistics result; + OH_JSVM_GetHeapStatistics(testVm, &result); + // 打印虚拟机堆统计信息 + PrintHeapStatistics(result); + // 返回虚拟机堆统计信息中‘本机上下文数量’ + JSVM_Value nativeContextsCnt = nullptr; + OH_JSVM_CreateInt64(env, result.numberOfNativeContexts, &nativeContextsCnt); + return nativeContextsCnt; +} +// GetHeapStatistics注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetHeapStatistics}, +}; +static JSVM_CallbackStruct *method = param; +// GetHeapStatistics方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getHeapStatistics", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +const char *SRC_CALL_NATIVE = R"JS(getHeapStatistics())JS"; +// [End oh_jsvm_get_heap_statistics] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getheapstatistics", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/oh-package.json5 new file mode 100644 index 0000000000..6740937c4b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/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": "libgetheapstatistics.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/getheapstatisticsability/GetheapstatisticsAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/getheapstatisticsability/GetheapstatisticsAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/getheapstatisticsability/GetheapstatisticsAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/getheapstatisticsability/GetheapstatisticsAbility.ets index 498f8ee440..eb8b50a8fb --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/getheapstatisticsability/GetheapstatisticsAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/getheapstatisticsability/GetheapstatisticsAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetheapstatisticsAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetheapstatisticsAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..3181546265 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetheapstatistics.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/module.json5 new file mode 100644 index 0000000000..81c388c0a4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getheapstatistics", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetheapstatisticsAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetheapstatisticsAbility", + "srcEntry": "./ets/getheapstatisticsability/GetheapstatisticsAbility.ets", + "description": "$string:GetheapstatisticsAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetheapstatisticsAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..cff501cf69 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetheapstatisticsAbility_desc", + "value": "description" + }, + { + "name": "GetheapstatisticsAbility_label", + "value": "UsageInstructionsTwo" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..043966859f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetHeapStatistics', 0, async (done: Function) => { + console.log('uitest: TestGetHeapStatistics begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetheapstatisticsAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetheapstatisticsAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetHeapStatistics end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/module.json5 new file mode 100644 index 0000000000..f9931db74f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getheapstatistics_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/oh-package.json5 new file mode 100644 index 0000000000..d21aec9076 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/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": "getversion", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetversion.so": "file:./src/main/cpp/types/libgetversion" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..eb90367e4b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getversion SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getversion PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..2f2b4431df --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/hello.cpp @@ -0,0 +1,175 @@ +/* + * 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 "hilog/log.h" +#include "ark_runtime/jsvm.h" + +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) + +// [Start oh_jsvm_get_version_and_vm_info] +// OH_JSVM_GetVersion的样例方法 +static JSVM_Value GetVersion(JSVM_Env env, JSVM_CallbackInfo info) +{ + uint32_t jsVersion = 0; + // 调用接口,获取当前JSVM运行时支持的最高JSVM API版本 + JSVM_CALL(OH_JSVM_GetVersion(env, &jsVersion)); + int value = static_cast(jsVersion); + OH_LOG_INFO(LOG_APP, "JSVM GetVersion success:%{public}d", value); + return nullptr; +} + +// OH_JSVM_GetVMInfo的样例方法 +// 打印JSVM(JavaScript虚拟机)的各项信息 +void PrintVmInfo(JSVM_VMInfo vmInfo) +{ + OH_LOG_INFO(LOG_APP, "JSVM API apiVersion: %{public}d", vmInfo.apiVersion); + OH_LOG_INFO(LOG_APP, "JSVM API engine: %{public}s", vmInfo.engine); + OH_LOG_INFO(LOG_APP, "JSVM API version: %{public}s", vmInfo.version); + OH_LOG_INFO(LOG_APP, "JSVM API cachedDataVersionTag: 0x%{public}x", vmInfo.cachedDataVersionTag); +} + +static JSVM_Value GetVMInfo(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 调用接口,获取虚拟机的信息 + JSVM_VMInfo result; + JSVM_CALL(OH_JSVM_GetVMInfo(&result)); + // 输出VM虚拟机信息 + PrintVmInfo(result); + return nullptr; +} + +// IsStrictEquals注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetVersion}, + {.data = nullptr, .callback = GetVMInfo}, +}; +static JSVM_CallbackStruct *method = param; +// IsStrictEquals方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getVersion", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, + {"getVMInfo", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +// 样例测试js +static const char *STR_TASK = R"JS(getVersion();getVMInfo();)JS"; +// [End oh_jsvm_get_version_and_vm_info] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, STR_TASK, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getversion", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/oh-package.json5 new file mode 100644 index 0000000000..045101c18b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/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": "libgetversion.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/getversionability/GetversionAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/getversionability/GetversionAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/getversionability/GetversionAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/getversionability/GetversionAbility.ets index 6f019158d7..10f2c73bb6 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/getversionability/GetversionAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/getversionability/GetversionAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class GetversionAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class GetversionAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..a403e9baf2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetversion.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/module.json5 new file mode 100644 index 0000000000..72d3193068 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "getversion", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "GetversionAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "GetversionAbility", + "srcEntry": "./ets/getversionability/GetversionAbility.ets", + "description": "$string:GetversionAbility_desc", + "icon": "$media:layered_image", + "label": "$string:GetversionAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..274263abc0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "GetversionAbility_desc", + "value": "description" + }, + { + "name": "GetversionAbility_label", + "value": "UsageInstructionsTwo" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..89734ba4ea --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetVersion', 0, async (done: Function) => { + console.log('uitest: TestGetVersion begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'GetversionAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('GetversionAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetVersion end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/module.json5 new file mode 100644 index 0000000000..84f25198a2 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getversion_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/oh-package.json5 new file mode 100644 index 0000000000..265dbe9f72 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/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": "getvm", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libgetvm.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..4f4d6b6d9e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(getvm SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(getvm PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..acb683d7dc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_get_vm] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_get_vm] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_get_vm] + +// OH_JSVM_GetVM的样例方法 +static JSVM_Value GetVM(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 获取当前虚拟机对象,后续可以进行与虚拟机相关的操作或分析 + JSVM_VM testVm; + JSVM_Status status = OH_JSVM_GetVM(env, &testVm); + JSVM_Value result = nullptr; + if (status != JSVM_OK || testVm == nullptr) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetVM: failed"); + OH_JSVM_GetBoolean(env, true, &result); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetVM: success"); + OH_JSVM_GetBoolean(env, false, &result); + } + return result; +} +// GetVM注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = GetVM}, +}; +static JSVM_CallbackStruct *method = param; +// GetVM方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"getVM", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +const char *SRC_CALL_NATIVE = R"JS(getVM())JS"; +// [End oh_jsvm_get_vm] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "getvm", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..05c7308f96 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/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": "libgetvm.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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..3cf4799224 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libgetvm.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/module.json5 new file mode 100644 index 0000000000..73807e1bab --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/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": "getvm", + "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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..da67aa185b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/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": "UsageInstructionsTwo" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..e98c7d6386 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testGetVM', 0, async (done: Function) => { + console.log('uitest: TestGetVM begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestGetVM end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/module.json5 new file mode 100644 index 0000000000..d01da0917d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "getvm_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/hvigorfile.ts rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/oh-package.json5 new file mode 100644 index 0000000000..216aeb4f7b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/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": "memorypressurenotification", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libmemorypressurenotification.so": "file:./src/main/cpp/types/libmemorypressurenotification" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..2afdde30dc --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(memorypressurenotification SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(memorypressurenotification PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..45d1e997e5 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/hello.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_memory_pressure_notification] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_memory_pressure_notification] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_memory_pressure_notification] + +// OH_JSVM_MemoryPressureNotification的样例方法 +static JSVM_Value MemoryPressureNotification(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 设置当前JSVM的内存压力级别 + JSVM_Status status = OH_JSVM_MemoryPressureNotification(env, JSVM_MEMORY_PRESSURE_LEVEL_CRITICAL); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_MemoryPressureNotification: failed"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_MemoryPressureNotification: success"); + OH_LOG_INFO(LOG_APP, "JSVM Current JSVM memory pressure level: %{public}d", + JSVM_MEMORY_PRESSURE_LEVEL_CRITICAL); + } + return nullptr; +} +// MemoryPressureNotification注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = MemoryPressureNotification}, +}; +static JSVM_CallbackStruct *method = param; +// MemoryPressureNotification方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"memoryPressureNotification", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; + +const char *SRC_CALL_NATIVE = R"JS(memoryPressureNotification())JS"; +// [End oh_jsvm_memory_pressure_notification] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "memorypressurenotification", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/oh-package.json5 new file mode 100644 index 0000000000..29adc05a8d --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/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": "libmemorypressurenotification.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/memorypressurenotificationability/MemorypressurenotificationAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/memorypressurenotificationability/MemorypressurenotificationAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/memorypressurenotificationability/MemorypressurenotificationAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/memorypressurenotificationability/MemorypressurenotificationAbility.ets index 330268c766..1f29e75384 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/memorypressurenotificationability/MemorypressurenotificationAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/memorypressurenotificationability/MemorypressurenotificationAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class MemorypressurenotificationAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class MemorypressurenotificationAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..c672c52f29 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libmemorypressurenotification.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/module.json5 new file mode 100644 index 0000000000..9537498798 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "memorypressurenotification", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "MemorypressurenotificationAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "MemorypressurenotificationAbility", + "srcEntry": "./ets/memorypressurenotificationability/MemorypressurenotificationAbility.ets", + "description": "$string:MemorypressurenotificationAbility_desc", + "icon": "$media:layered_image", + "label": "$string:MemorypressurenotificationAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..49248b372c --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "MemorypressurenotificationAbility_desc", + "value": "description" + }, + { + "name": "MemorypressurenotificationAbility_label", + "value": "UsageInstructionsTwo" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..dd181e4cf1 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击Hello World执行 + */ + it('testMemoryPressureNotification', 0, async (done: Function) => { + console.log('uitest: TestMemoryPressureNotification begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'MemorypressurenotificationAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('MemorypressurenotificationAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('Hello World')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestMemoryPressureNotification end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/module.json5 new file mode 100644 index 0000000000..3177bcc11a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "memorypressurenotification_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/ohosTest.md b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/ohosTest.md new file mode 100644 index 0000000000..0634982710 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/ohosTest.md @@ -0,0 +1,13 @@ +# UsageInstructionsTwo 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 使用JSVM-API接口获取JSVM API的版本号 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 设置JavaScript对象保持活动状态的外部分配内存的数量 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 通知虚拟机系统内存不足并有选择地触发垃圾回收 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 判断给定的两个JS value是否严格相等 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 检索给定环境的虚拟机实例 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | +| 返回一组虚拟机堆的统计数据 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/screenshots/UsageInstructionsTwo_1.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/screenshots/UsageInstructionsTwo_1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/screenshots/UsageInstructionsTwo_1.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/screenshots/UsageInstructionsTwo_1.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/screenshots/UsageInstructionsTwo_2.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/screenshots/UsageInstructionsTwo_2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/screenshots/UsageInstructionsTwo_2.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/screenshots/UsageInstructionsTwo_2.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/.gitignore b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/build-profile.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/build-profile.json5 new file mode 100644 index 0000000000..01bed8940f --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/hvigorfile.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/obfuscation-rules.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/obfuscation-rules.txt new file mode 100644 index 0000000000..272efb6ca3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/oh-package.json5 new file mode 100644 index 0000000000..e1a669d623 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/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": "strictequals", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libstrictequals.so": "file:./src/main/cpp/types/libstrictequals" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..9c4f5b36c3 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4.1) +project(UsageInstructionsTwo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# 日志打印配置 +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(strictequals SHARED hello.cpp) +# 构建此可执行文件需要链接的库 +target_link_libraries(strictequals PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/hello.cpp b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/hello.cpp new file mode 100644 index 0000000000..422c3d54e8 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/hello.cpp @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start oh_jsvm_strict_equals] +#include "napi/native_api.h" +#include "ark_runtime/jsvm.h" +#include "hilog/log.h" +// [StartExclude oh_jsvm_strict_equals] +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "APP" + +static int g_aa = 0; + +#define CHECK_RET(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return -1; \ + } \ + } while (0) + +#define CHECK(theCall) \ + do { \ + JSVM_Status cond = theCall; \ + if ((cond) != JSVM_OK) { \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ + cond); \ + return -1; \ + } \ + } while (0) + +// 用于调用theCall并检查其返回值是否为JSVM_OK。 +// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 +#define JSVM_CALL_BASE(env, theCall, retVal) \ + do { \ + JSVM_Status cond = theCall; \ + if (cond != JSVM_OK) { \ + const JSVM_ExtendedErrorInfo *info; \ + OH_JSVM_GetLastErrorInfo(env, &info); \ + OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ + __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ + return retVal; \ + } \ + } while (0) + +// JSVM_CALL_BASE的简化版本,返回nullptr +#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) +// [EndExclude oh_jsvm_strict_equals] + +// OH_JSVM_StrictEquals的样例方法 +static JSVM_Value IsStrictEquals(JSVM_Env env, JSVM_CallbackInfo info) +{ + // 接受两个入参 + size_t argc = 2; + JSVM_Value args[2] = {nullptr}; + OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); + // 调用OH_JSVM_StrictEquals接口判断给定的两个JavaScript value是否严格相等 + bool result = false; + JSVM_Status status = OH_JSVM_StrictEquals(env, args[0], args[1], &result); + if (status != JSVM_OK) { + OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_StrictEquals: failed"); + } else { + OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_StrictEquals: success: %{public}d", result); + } + JSVM_Value isStrictEqual; + OH_JSVM_GetBoolean(env, result, &isStrictEqual); + return isStrictEqual; +} +// IsStrictEquals注册回调 +static JSVM_CallbackStruct param[] = { + {.data = nullptr, .callback = IsStrictEquals}, +}; +static JSVM_CallbackStruct *method = param; +// IsStrictEquals方法别名,供JS调用 +static JSVM_PropertyDescriptor descriptor[] = { + {"isStrictEquals", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, +}; +// 样例测试js +const char* SRC_CALL_NATIVE = R"JS(data = '123';value = '123';isStrictEquals(data,value);)JS"; +// [End oh_jsvm_strict_equals] + +static int32_t TestJSVM() +{ + JSVM_InitOptions initOptions = {0}; + JSVM_VM vm; + JSVM_Env env = nullptr; + JSVM_VMScope vmScope; + JSVM_EnvScope envScope; + JSVM_HandleScope handleScope; + JSVM_Value result; + // 初始化JavaScript引擎实例 + if (g_aa == 0) { + g_aa++; + CHECK(OH_JSVM_Init(&initOptions)); + } + // 创建JSVM环境 + CHECK(OH_JSVM_CreateVM(nullptr, &vm)); + CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); + CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); + CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); + CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); + + // 通过script调用测试函数 + JSVM_Script script; + JSVM_Value jsSrc; + CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); + CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); + CHECK_RET(OH_JSVM_RunScript(env, script, &result)); + + // 销毁JSVM环境 + CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); + CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); + CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); + CHECK(OH_JSVM_DestroyEnv(env)); + CHECK(OH_JSVM_DestroyVM(vm)); + return 0; +} + +static napi_value RunTest(napi_env env, napi_callback_info info) +{ + TestJSVM(); + return nullptr; +} + +// 模块注册信息,供arkts侧调用 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "strictequals", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/Index.d.ts b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/Index.d.ts new file mode 100644 index 0000000000..87c2a3033b --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/oh-package.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/oh-package.json5 new file mode 100644 index 0000000000..58028a5e32 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/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": "libstrictequals.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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..caf23cac32 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/pages/Index.ets @@ -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. + */ + +import napitest from 'libstrictequals.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + napitest.runTest(); + this.message = 'success'; + } catch (error) { + console.error('An error occurred: ', error); + this.message = 'fail'; + } + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/strictequalsability/StrictequalsAbility.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/strictequalsability/StrictequalsAbility.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/strictequalsability/StrictequalsAbility.ets rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/strictequalsability/StrictequalsAbility.ets index 20282d42a9..01c4665b17 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/strictequalsability/StrictequalsAbility.ets +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/strictequalsability/StrictequalsAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class StrictequalsAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class StrictequalsAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/module.json5 new file mode 100644 index 0000000000..e01d7becac --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/module.json5 @@ -0,0 +1,42 @@ +/* + * 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": "strictequals", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "StrictequalsAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "StrictequalsAbility", + "srcEntry": "./ets/strictequalsability/StrictequalsAbility.ets", + "description": "$string:StrictequalsAbility_desc", + "icon": "$media:layered_image", + "label": "$string:StrictequalsAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/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/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/string.json new file mode 100644 index 0000000000..74779e5a2e --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "StrictequalsAbility_desc", + "value": "description" + }, + { + "name": "StrictequalsAbility_label", + "value": "UsageInstructionsTwo" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000..7ffdae3020 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/Ability.test.ets @@ -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. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * 打开应用,点击OH_JSVM_StrictEquals执行 + */ + it('testStrictEquals', 0, async (done: Function) => { + console.log('uitest: TestStrictEquals begin'); + + const want: Want = { + bundleName: bundleName, + abilityName: 'StrictequalsAbility' + } + const driver = Driver.create(); + await delegator.startAbility(want); + await driver.delayMs(1000); + + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.log('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('StrictequalsAbility'); + + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('OH_JSVM_StrictEquals')); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('success')); + console.log('uitest: TestStrictEquals end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/module.json5 new file mode 100644 index 0000000000..409f7a46b0 --- /dev/null +++ b/code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "strictequals_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/.gitignore rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/.gitignore diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/app.json5 new file mode 100644 index 0000000000..fc6fef3c84 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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.nodeapiasynchronoustask", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..7174a1f89e --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIAsynchronousTask" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/README.md new file mode 100644 index 0000000000..a4fbd95a30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/README.md @@ -0,0 +1,74 @@ +# ArkTS使用Node-API接口进行异步任务开发 + +### 介绍 + +本工程展示了使用Node-API接口进行异步任务开发中的Promise方式和callback方式,详细描述可查如下链接。 + +- [使用Node-API接口进行异步任务开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-asynchronous-task.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现如上图效果,和两个按钮,依次点击按钮后可以调用Promise方式和callback方式的方法,并将结果呈现到text文本中,并在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIAsynchronousTask.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── libentry + │ │ └── libentry1 + │ │ ├── callback.cpp // callback方式实现 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp // Promise方式实现 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 异步任务 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIAsynchronousTask.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeAPIAsynchronousTask > .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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/code-linter.json5 rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/code-linter.json5 diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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": false, + "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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/oh-package.json5 new file mode 100644 index 0000000000..a26930aada --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/oh-package.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry", + "libentry1.so": "file:./src/main/cpp/types/libentry1" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..cffbe7f528 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,18 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIAsynchronousTask) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) + +add_library(entry1 SHARED callback.cpp) +target_link_libraries(entry1 PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/callback.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/callback.cpp old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/callback.cpp rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/callback.cpp index a8f6b91fab..a749dbe7fe --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/callback.cpp +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/callback.cpp @@ -1,105 +1,105 @@ -/* - * 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" - -// [Start napi_create_queue_async_work] -static constexpr int INT_ARGS_2 = 2; // 入参索引 - -struct CallbackData { - napi_async_work asyncWork = nullptr; - napi_ref callbackRef = nullptr; - double args[2] = {0}; - double result = 0; -}; - -// [StartExclude napi_create_queue_async_work] -// [Start napi_async_first_call_back_work] -static void ExecuteCB(napi_env env, void *data) -{ - CallbackData *callbackData = reinterpret_cast(data); - callbackData->result = callbackData->args[0] + callbackData->args[1]; -} -// [End napi_async_first_call_back_work] - -// [Start napi_async_second_call_back_work] -static void CompleteCB(napi_env env, napi_status status, void *data) -{ - CallbackData *callbackData = reinterpret_cast(data); - napi_value callbackArg[1] = {nullptr}; - napi_create_double(env, callbackData->result, &callbackArg[0]); - napi_value callback = nullptr; - napi_get_reference_value(env, callbackData->callbackRef, &callback); - // 执行回调函数 - napi_value result; - napi_value undefined; - napi_get_undefined(env, &undefined); - napi_call_function(env, undefined, callback, 1, callbackArg, &result); - // 删除napi_ref对象以及异步任务 - napi_delete_reference(env, callbackData->callbackRef); - napi_delete_async_work(env, callbackData->asyncWork); - delete callbackData; -} -// [End napi_async_second_call_back_work] -// [EndExclude napi_create_queue_async_work] - -napi_value AsyncWork(napi_env env, napi_callback_info info) -{ - size_t argc = 3; - napi_value args[3]; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - auto asyncContext = new CallbackData(); - // 将接收到的参数保存到callbackData - napi_get_value_double(env, args[0], &asyncContext->args[0]); - napi_get_value_double(env, args[1], &asyncContext->args[1]); - // 将传入的callback转换为napi_ref延长其生命周期,防止被GC掉 - napi_create_reference(env, args[INT_ARGS_2], 1, &asyncContext->callbackRef); - napi_value resourceName = nullptr; - napi_create_string_utf8(env, "asyncWorkCallback", NAPI_AUTO_LENGTH, &resourceName); - // 创建异步任务 - napi_create_async_work(env, nullptr, resourceName, ExecuteCB, CompleteCB, - asyncContext, &asyncContext->asyncWork); - // 将异步任务加入队列 - napi_queue_async_work(env, asyncContext->asyncWork); - return nullptr; -} -// [End napi_create_queue_async_work] - -// [Start napi_value_init] -// 模块初始化 -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "asyncWork", nullptr, AsyncWork, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -// [End napi_value_init] - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry1", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); +/* + * 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" + +// [Start napi_create_queue_async_work] +static constexpr int INT_ARGS_2 = 2; // 入参索引 + +struct CallbackData { + napi_async_work asyncWork = nullptr; + napi_ref callbackRef = nullptr; + double args[2] = {0}; + double result = 0; +}; + +// [StartExclude napi_create_queue_async_work] +// [Start napi_async_first_call_back_work] +static void ExecuteCB(napi_env env, void *data) +{ + CallbackData *callbackData = reinterpret_cast(data); + callbackData->result = callbackData->args[0] + callbackData->args[1]; +} +// [End napi_async_first_call_back_work] + +// [Start napi_async_second_call_back_work] +static void CompleteCB(napi_env env, napi_status status, void *data) +{ + CallbackData *callbackData = reinterpret_cast(data); + napi_value callbackArg[1] = {nullptr}; + napi_create_double(env, callbackData->result, &callbackArg[0]); + napi_value callback = nullptr; + napi_get_reference_value(env, callbackData->callbackRef, &callback); + // 执行回调函数 + napi_value result; + napi_value undefined; + napi_get_undefined(env, &undefined); + napi_call_function(env, undefined, callback, 1, callbackArg, &result); + // 删除napi_ref对象以及异步任务 + napi_delete_reference(env, callbackData->callbackRef); + napi_delete_async_work(env, callbackData->asyncWork); + delete callbackData; +} +// [End napi_async_second_call_back_work] +// [EndExclude napi_create_queue_async_work] + +napi_value AsyncWork(napi_env env, napi_callback_info info) +{ + size_t argc = 3; + napi_value args[3]; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + auto asyncContext = new CallbackData(); + // 将接收到的参数保存到callbackData + napi_get_value_double(env, args[0], &asyncContext->args[0]); + napi_get_value_double(env, args[1], &asyncContext->args[1]); + // 将传入的callback转换为napi_ref延长其生命周期,防止被GC掉 + napi_create_reference(env, args[INT_ARGS_2], 1, &asyncContext->callbackRef); + napi_value resourceName = nullptr; + napi_create_string_utf8(env, "asyncWorkCallback", NAPI_AUTO_LENGTH, &resourceName); + // 创建异步任务 + napi_create_async_work(env, nullptr, resourceName, ExecuteCB, CompleteCB, + asyncContext, &asyncContext->asyncWork); + // 将异步任务加入队列 + napi_queue_async_work(env, asyncContext->asyncWork); + return nullptr; +} +// [End napi_create_queue_async_work] + +// [Start napi_value_init] +// 模块初始化 +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "asyncWork", nullptr, AsyncWork, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +// [End napi_value_init] + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry1", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..8527a2bca8 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,99 @@ +/* + * 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" + +// [Start napi_create_async_work] +struct CallbackData { + napi_async_work asyncWork = nullptr; + napi_deferred deferred = nullptr; + napi_ref callback = nullptr; + double args = 0; + double result = 0; +}; + +// [StartExclude napi_create_async_work] +// [Start napi_first_call_back_work] +static void ExecuteCB(napi_env env, void *data) +{ + CallbackData *callbackData = reinterpret_cast(data); + callbackData->result = callbackData->args; +} +// [End napi_first_call_back_work] + +// [Start napi_second_call_back_main] +static void CompleteCB(napi_env env, napi_status status, void *data) +{ + CallbackData *callbackData = reinterpret_cast(data); + napi_value result = nullptr; + napi_create_double(env, callbackData->result, &result); + if (callbackData->result > 0) { + napi_resolve_deferred(env, callbackData->deferred, result); + } else { + napi_reject_deferred(env, callbackData->deferred, result); + } + + napi_delete_async_work(env, callbackData->asyncWork); + delete callbackData; +} +// [End napi_second_call_back_main] +// [EndExclude napi_create_async_work] + +static napi_value AsyncWork(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1]; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_value promise = nullptr; + napi_deferred deferred = nullptr; + napi_create_promise(env, &deferred, &promise); + + auto callbackData = new CallbackData(); + callbackData->deferred = deferred; + napi_get_value_double(env, args[0], &callbackData->args); + + napi_value resourceName = nullptr; + napi_create_string_utf8(env, "AsyncCallback", NAPI_AUTO_LENGTH, &resourceName); + // 创建异步任务 + napi_create_async_work(env, nullptr, resourceName, ExecuteCB, CompleteCB, callbackData, &callbackData->asyncWork); + // 将异步任务加入队列 + napi_queue_async_work(env, callbackData->asyncWork); + + return promise; +} +// [End napi_create_async_work] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"asyncWork", nullptr, AsyncWork, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..8da6054c9d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const asyncWork: (data: number) => Promise; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/Index.d.ts new file mode 100644 index 0000000000..d89e141e55 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const asyncWork: (arg1: number, arg2: number, callback: (result: number) => void) => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/oh-package.json5 new file mode 100644 index 0000000000..f6d9ff0107 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/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": "libentry1.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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..13102ac26e --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; +import nativeModule from 'libentry1.so'; + +let num1: number = 123; +let num2: number = 456; + +@Entry +@Component +struct Index { + @State message: string = 'AsyncWork'; + + build() { + Column({space: 5}) { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + Button($r('app.string.AsyncWorkPromise')) + .margin(3) + .onClick(() => { + testNapi.asyncWork(1024).then((result) => { + hilog.info(0x0000, 'XXX', 'result is %{public}d', result); + this.message = 'result is ' + result.toString(); + }); + }) + Button($r('app.string.AsyncWorkCallback')) + .margin(3) + .onClick(() => { + nativeModule.asyncWork(num1, num2, (result) => { + hilog.info(0x0000, 'XXX', 'result is %{public}d', result); + this.message = 'result is ' + result.toString(); + }); + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/NodeAPIAsynchronousTask.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/NodeAPIAsynchronousTask.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/NodeAPIAsynchronousTask.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/NodeAPIAsynchronousTask.test.ets index ec6dfa380f..1e0ec01bda --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/NodeAPIAsynchronousTask.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/ets/test/NodeAPIAsynchronousTask.test.ets @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIAsynchronousTaskTest() { - describe('nodeAPIAsynchronousTaskTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用nAsyncWorkPromise相关函数 - */ - it('testNodeAPIAsynchronousTask001', 0, async () => { - console.info('uitest: testNodeAPIAsynchronousTask001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call AsyncWorkPromise')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('result is 1024')); - console.info('uitest: testNodeAPIAsynchronousTask001 end'); - }) - - /** - * 点击按钮,调用AsyncWorkCallback相关函数 - */ - it('testNodeAPIAsynchronousTask002', 0, async () => { - console.info('uitest: testNodeAPIAsynchronousTask002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call AsyncWorkCallback')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('result is 579')); - console.info('uitest: testNodeAPIAsynchronousTask002 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIAsynchronousTaskTest() { + describe('nodeAPIAsynchronousTaskTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用nAsyncWorkPromise相关函数 + */ + it('testNodeAPIAsynchronousTask001', 0, async () => { + console.info('uitest: testNodeAPIAsynchronousTask001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call AsyncWorkPromise')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('result is 1024')); + console.info('uitest: testNodeAPIAsynchronousTask001 end'); + }) + + /** + * 点击按钮,调用AsyncWorkCallback相关函数 + */ + it('testNodeAPIAsynchronousTask002', 0, async () => { + console.info('uitest: testNodeAPIAsynchronousTask002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call AsyncWorkCallback')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('result is 579')); + console.info('uitest: testNodeAPIAsynchronousTask002 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/ohosTest.md new file mode 100644 index 0000000000..2563e5f7d9 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/ohosTest.md @@ -0,0 +1,9 @@ +# 使用Node-API接口进行异步任务开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| --------------------------------------- | ------------ | -------------------------------------- | ---------------------------------------------------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 asyncWork | 位于主页 | 点击Call AsyncWorkCallback的Button组件 | 成功调用函数输出日志,页面顶端文本变为result is 579 | Pass | +| ArkTS端成功调用native侧接口 asyncWork | 位于主页 | 点击Call AsyncWorkPromise的Button组件 | 成功调用函数输出日志,页面顶端文本变为result is 1024 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/screenshots/NodeAPIAsynchronousTask1.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/screenshots/NodeAPIAsynchronousTask1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/screenshots/NodeAPIAsynchronousTask1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/screenshots/NodeAPIAsynchronousTask1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/screenshots/NodeAPIAsynchronousTask2.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/screenshots/NodeAPIAsynchronousTask2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/screenshots/NodeAPIAsynchronousTask2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/screenshots/NodeAPIAsynchronousTask2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/.gitignore rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/.gitignore diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/AppScope/app.json5 new file mode 100644 index 0000000000..32cec47a1c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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.nodeapiapplicationscenario", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..8bbf5ef474 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeApiApplicationScenario" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/README.md new file mode 100644 index 0000000000..19ccb5ce33 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/README.md @@ -0,0 +1,87 @@ +# ArkTSNode-API使用场景 + +### 介绍 + +开发者通过pthread_create创建新线程后,可以通过napi_create_ark_runtime来创建一个新的ArkTS基础运行时环境,并通过该运行时环境加载ArkTS模块。当使用结束后,开发者需要通过napi_destroy_ark_runtime来销毁所创建的ArkTS基础运行时环境。 + +napi_create_threadsafe_function是Node-API接口之一,用于创建一个线程安全的JavaScript函数。主要用于在多个线程之间共享和调用,而不会出现竞争条件或死锁。例如异步计算、数据共享、多线程编程场景。 + +Node-API中的napi_call_threadsafe_function_with_priority接口的功能是从异步线程向ArkTS线程投递任务,底层队列会根据任务的优先级和入队方式来处理任务。 + +在自己创建的ArkTS运行环境中调用异步的ArkTS接口时,可以通过使用Node-API中的扩展接口napi_run_event_loop和napi_stop_event_loop来运行和停止ArkTS实例中的事件循环,该工程中展示的代码详细描述可查如下链接。 + +- [使用Node-API接口创建ArkTS运行时环境](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-ark-runtime.md) +- [使用Node-API接口进行线程安全开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-thread-safety.md) +- [使用Node-API接口从异步线程向ArkTS线程投递指定优先级和入队方式的的任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-call-threadsafe-function-with-priority.md) +- [使用扩展的Node-API接口在异步线程中运行和停止事件循环](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-event-loop.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击button组件可以执行对应文本内容的Node-API接口并将文本NodeAPI改为执行成功结果。 +3. 运行测试用例NodeApiApplicationScenario.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── libentry + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── libentry1 + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ │ ├── thread_safety.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // Node-API使用场景 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeApiApplicationScenario.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario > .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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/code-linter.json5 rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/code-linter.json5 diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/build-profile.json5 new file mode 100644 index 0000000000..4cc3a2d6c6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/build-profile.json5 @@ -0,0 +1,70 @@ +/* + * 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", +// [Start napi_event_loop_build] +// [Start napi_ark_runtime_build] + "buildOption": { + "arkOptions" : { + "runtimeOnly" : { + "sources": [ + "./src/main/ets/pages/ObjectUtils.ets" + ] + } + }, +// [End napi_event_loop_build] +// [Start napi_ark_runtime_build] + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "arm64-v8a", + "x86_64", + "armeabi-v7a" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/oh-package.json5 new file mode 100644 index 0000000000..a26930aada --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/oh-package.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry", + "libentry1.so": "file:./src/main/cpp/types/libentry1" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..86fbdf5e67 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,12 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(MyApplication) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) +add_library(entry1 SHARED thread_safety.cpp) +target_link_libraries(entry1 PUBLIC libace_napi.z.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..3a06f1f626 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start napi_call_threadsafe_function_with_priority_cpp] +// [Start napi_ark_runtime_cpp] +#include +#include "napi/native_api.h" +// [StartExclute napi_ark_runtime_cpp] +#include +#include +#include + +static constexpr int INT_ARG_2 = 2; // 入参索引 +static constexpr int INT_ARG_12 = 12; // 入参索引 +static constexpr int INT_ARG_15 = 15; // 入参索引 +// [EndExclute napi_ark_runtime_cpp] +// [StartExclute napi_call_threadsafe_function_with_priority_cpp] +static void *CreateArkRuntimeFunc(void *arg) +{ + // 1. 创建基础运行环境 + napi_env env; + napi_status ret = napi_create_ark_runtime(&env); + if (ret != napi_ok) { + return nullptr; + } + + // 2. 加载自定义模块 + napi_value objUtils; + ret = napi_load_module_with_info(env, "entry/src/main/ets/pages/ObjectUtils", "com.example.myapplication/entry", + &objUtils); + if (ret != napi_ok) { + return nullptr; + } + + // 3. 使用ArkTS中的logger + napi_value logger; + ret = napi_get_named_property(env, objUtils, "Logger", &logger); + if (ret != napi_ok) { + return nullptr; + } + ret = napi_call_function(env, objUtils, logger, 0, nullptr, nullptr); + + // 4. 销毁ArkTS环境 + ret = napi_destroy_ark_runtime(&env); + + return nullptr; +} + +static napi_value CreateArkRuntime(napi_env env, napi_callback_info info) +{ + pthread_t tid; + pthread_create(&tid, nullptr, CreateArkRuntimeFunc, nullptr); + pthread_join(tid, nullptr); + return nullptr; +} +// [StartExclute napi_ark_runtime_cpp] +// [Start napi_event_loop_cpp] +static napi_value ResolvedCallback(napi_env env, napi_callback_info info) +{ + napi_stop_event_loop(env); + return nullptr; +} + +static napi_value RejectedCallback(napi_env env, napi_callback_info info) +{ + napi_stop_event_loop(env); + return nullptr; +} + +static void *RunEventLoopFunc(void *arg) +{ + // 1. 创建ArkTS实例 + napi_env env; + napi_status ret = napi_create_ark_runtime(&env); + if (ret != napi_ok) { + return nullptr; + } + + // 2. 加载自定义的模块 + napi_value objectUtils; + // 'com.example.myapplication' 为当前应用的bundleName + ret = napi_load_module_with_info(env, "ets/pages/ObjectUtils", "com.example.myapplication/entry", &objectUtils); + if (ret != napi_ok) { + return nullptr; + } + + // 3. 调用异步SetTimeout接口 + napi_value setTimeout = nullptr; + napi_value promise = nullptr; + + napi_get_named_property(env, objectUtils, "SetTimeout", &setTimeout); + napi_call_function(env, objectUtils, setTimeout, 0, nullptr, &promise); + + napi_value theFunc = nullptr; + if (napi_get_named_property(env, promise, "then", &theFunc) != napi_ok) { + return nullptr; + } + + napi_value resolvedCallback = nullptr; + napi_value rejectedCallback = nullptr; + napi_create_function(env, "resolvedCallback", NAPI_AUTO_LENGTH, ResolvedCallback, nullptr, &resolvedCallback); + napi_create_function(env, "rejectedCallback", NAPI_AUTO_LENGTH, RejectedCallback, nullptr, &rejectedCallback); + napi_value argv[2] = {resolvedCallback, rejectedCallback}; + napi_call_function(env, promise, theFunc, INT_ARG_2, argv, nullptr); + + auto flag = reinterpret_cast(arg); + if (*flag == true) { + napi_run_event_loop(env, napi_event_mode_default); + } else { + // 非阻塞式的处理任务,有可能队列中还没有任务就已经返回了 + napi_run_event_loop(env, napi_event_mode_nowait); + } + return nullptr; +} + +static napi_value RunEventLoop(napi_env env, napi_callback_info info) +{ + pthread_t tid; + size_t argc = 1; + napi_value argv[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + bool flag = false; + napi_get_value_bool(env, argv[0], &flag); + // 创建异步线程 + pthread_create(&tid, nullptr, RunEventLoopFunc, &flag); + pthread_join(tid, nullptr); + + return nullptr; +} +// [StartExclute napi_event_loop_cpp] +// [EndExclute napi_call_threadsafe_function_with_priority_cpp] +struct CallbackData { + napi_threadsafe_function tsfn; + napi_async_work work; +}; +// ArkTS线程的回调实现 +static void CallJs(napi_env env, napi_value jsCb, void *context, void *data) +{ + if (env == nullptr) { + return; + } + napi_value resultNumber = nullptr; + napi_value undefined = nullptr; + napi_get_undefined(env, &undefined); + napi_value number1 = nullptr; + napi_create_int32(env, INT_ARG_12, &number1); + napi_value number2 = nullptr; + napi_create_int32(env, INT_ARG_15, &number2); + napi_value argv[2] = {number1, number2}; + napi_call_function(env, undefined, jsCb, INT_ARG_2, argv, &resultNumber); + int32_t res = 0; + napi_get_value_int32(env, resultNumber, &res); +} + +// 异步线程中调用该接口向ArkTS线程投递指定优先级和入队方式的任务 +static void ExecuteWork(napi_env env, void *data) +{ + CallbackData *callbackData = reinterpret_cast(data); + // 执行任务为napi_priority_idle优先级,入队方式为队列尾部入队 + napi_call_threadsafe_function_with_priority(callbackData->tsfn, nullptr, napi_priority_idle, true); + napi_call_threadsafe_function_with_priority(callbackData->tsfn, nullptr, napi_priority_low, true); + napi_call_threadsafe_function_with_priority(callbackData->tsfn, nullptr, napi_priority_high, true); + napi_call_threadsafe_function_with_priority(callbackData->tsfn, nullptr, napi_priority_immediate, true); + // 执行任务为napi_priority_high优先级,入队方式为队列头部入队 + napi_call_threadsafe_function_with_priority(callbackData->tsfn, nullptr, napi_priority_high, false); +} + +static void WorkComplete(napi_env env, napi_status status, void *data) +{ + CallbackData *callbackData = reinterpret_cast(data); + napi_release_threadsafe_function(callbackData->tsfn, napi_tsfn_release); + napi_delete_async_work(env, callbackData->work); + callbackData->work = nullptr; + callbackData->tsfn = nullptr; +} + +static napi_value CallThreadSafeWithPriority(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value jsCb = nullptr; + CallbackData *callbackData = nullptr; + napi_get_cb_info(env, info, &argc, &jsCb, nullptr, reinterpret_cast(&callbackData)); + napi_value resourceName = nullptr; + napi_create_string_utf8(env, "Thread-safe Function Demo", NAPI_AUTO_LENGTH, &resourceName); + napi_create_threadsafe_function(env, jsCb, nullptr, resourceName, 0, 1, callbackData, nullptr, callbackData, CallJs, + &callbackData->tsfn); + napi_create_async_work(env, nullptr, resourceName, ExecuteWork, WorkComplete, callbackData, &callbackData->work); + napi_queue_async_work(env, callbackData->work); + return nullptr; +} +// [EndExclute napi_event_loop_cpp] +// [EndExclute napi_ark_runtime_cpp] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + CallbackData *callbackData = new CallbackData(); + napi_property_descriptor desc[] = { + {"createArkRuntime", nullptr, CreateArkRuntime, nullptr, nullptr, nullptr, napi_static, nullptr}, + {"runEventLoop", nullptr, RunEventLoop, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"callThreadSafeWithPriority", nullptr, CallThreadSafeWithPriority, nullptr, nullptr, nullptr, + napi_default, callbackData}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module nativeModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = nullptr, + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterQueueWorkModule() { napi_module_register(&nativeModule); } +// [End napi_call_threadsafe_function_with_priority_cpp] +// [End napi_event_loop_cpp] +// [End napi_ark_runtime_cpp] diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/thread_safety.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/thread_safety.cpp old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/thread_safety.cpp rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/thread_safety.cpp index dc5e4f08e1..e76b91ce31 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/thread_safety.cpp +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/thread_safety.cpp @@ -1,146 +1,146 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start napi_thread_safety_cpp] -#include "napi/native_api.h" -#include "hilog/log.h" -#include - -static constexpr int INT_ARG_2 = 2; // 入参索引 -static constexpr int INT_BUF_32 = 32; // 入参索引 - -struct CallbackData { - napi_threadsafe_function tsfn; - napi_async_work work; -}; - -static void ExecuteWork(napi_env env, void *data) -{ - CallbackData *callbackData = reinterpret_cast(data); - std::promise promise; - auto future = promise.get_future(); - napi_call_threadsafe_function(callbackData->tsfn, &promise, napi_tsfn_nonblocking); - try { - auto result = future.get(); - OH_LOG_INFO(LOG_APP, "XXX, Result from JS %{public}s", result.c_str()); - } catch (const std::exception &e) { - OH_LOG_INFO(LOG_APP, "XXX, Result from JS %{public}s", e.what()); - } -} - -static napi_value ResolvedCallback(napi_env env, napi_callback_info info) -{ - void *data = nullptr; - size_t argc = 1; - napi_value argv[1]; - if (napi_get_cb_info(env, info, &argc, argv, nullptr, &data) != napi_ok) { - return nullptr; - } - size_t result = 0; - char buf[32] = {0}; - napi_get_value_string_utf8(env, argv[0], buf, INT_BUF_32, &result); - reinterpret_cast *>(data)->set_value(std::string(buf)); - return nullptr; -} - -static napi_value RejectedCallback(napi_env env, napi_callback_info info) -{ - void *data = nullptr; - if (napi_get_cb_info(env, info, nullptr, nullptr, nullptr, &data) != napi_ok) { - return nullptr; - } - reinterpret_cast *>(data)->set_exception( - std::make_exception_ptr(std::runtime_error("Error in jsCallback"))); - return nullptr; -} - -static void CallJs(napi_env env, napi_value jsCb, void *context, void *data) -{ - if (env == nullptr) { - return; - } - napi_value undefined = nullptr; - napi_value promise = nullptr; - napi_get_undefined(env, &undefined); - napi_call_function(env, undefined, jsCb, 0, nullptr, &promise); - napi_value thenFunc = nullptr; - if (napi_get_named_property(env, promise, "then", &thenFunc) != napi_ok) { - return; - } - napi_value resolvedCallback; - napi_value rejectedCallback; - napi_create_function(env, "resolvedCallback", NAPI_AUTO_LENGTH, ResolvedCallback, data, &resolvedCallback); - napi_create_function(env, "rejectedCallback", NAPI_AUTO_LENGTH, RejectedCallback, data, &rejectedCallback); - napi_value argv[2] = {resolvedCallback, rejectedCallback}; - napi_call_function(env, promise, thenFunc, INT_ARG_2, argv, nullptr); -} - -static void WorkComplete(napi_env env, napi_status status, void *data) -{ - CallbackData *callbackData = reinterpret_cast(data); - napi_release_threadsafe_function(callbackData->tsfn, napi_tsfn_release); - napi_delete_async_work(env, callbackData->work); - callbackData->tsfn = nullptr; - callbackData->work = nullptr; -} - - -static napi_value StartThread(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value jsCb = nullptr; - CallbackData *callbackData = nullptr; - napi_get_cb_info(env, info, &argc, &jsCb, nullptr, reinterpret_cast(&callbackData)); - - // 创建一个线程安全函数 - napi_value resourceName = nullptr; - napi_create_string_utf8(env, "Thread-safe Function Demo", NAPI_AUTO_LENGTH, &resourceName); - napi_create_threadsafe_function(env, jsCb, nullptr, resourceName, 0, 1, callbackData, nullptr, callbackData, CallJs, - &callbackData->tsfn); - - // 创建一个异步任务 - // ExecuteWork会执行在一个由libuv创建的非JS线程上 - // 此处使用napi_create_async_work是为了模拟在非JS线程场景使用napi_call_threadsafe_function接口向JS线程提交任务 - napi_create_async_work(env, nullptr, resourceName, ExecuteWork, WorkComplete, callbackData, &callbackData->work); - - // 将异步任务加入到异步队列中 - napi_queue_async_work(env, callbackData->work); - return nullptr; -} - - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - CallbackData *callbackData = new CallbackData(); // 可在线程退出时释放 - napi_property_descriptor desc[] = { - {"startThread", nullptr, StartThread, nullptr, nullptr, nullptr, napi_default, callbackData}, - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END -// [End napi_thread_safety_cpp] - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry1", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start napi_thread_safety_cpp] +#include "napi/native_api.h" +#include "hilog/log.h" +#include + +static constexpr int INT_ARG_2 = 2; // 入参索引 +static constexpr int INT_BUF_32 = 32; // 入参索引 + +struct CallbackData { + napi_threadsafe_function tsfn; + napi_async_work work; +}; + +static void ExecuteWork(napi_env env, void *data) +{ + CallbackData *callbackData = reinterpret_cast(data); + std::promise promise; + auto future = promise.get_future(); + napi_call_threadsafe_function(callbackData->tsfn, &promise, napi_tsfn_nonblocking); + try { + auto result = future.get(); + OH_LOG_INFO(LOG_APP, "XXX, Result from JS %{public}s", result.c_str()); + } catch (const std::exception &e) { + OH_LOG_INFO(LOG_APP, "XXX, Result from JS %{public}s", e.what()); + } +} + +static napi_value ResolvedCallback(napi_env env, napi_callback_info info) +{ + void *data = nullptr; + size_t argc = 1; + napi_value argv[1]; + if (napi_get_cb_info(env, info, &argc, argv, nullptr, &data) != napi_ok) { + return nullptr; + } + size_t result = 0; + char buf[32] = {0}; + napi_get_value_string_utf8(env, argv[0], buf, INT_BUF_32, &result); + reinterpret_cast *>(data)->set_value(std::string(buf)); + return nullptr; +} + +static napi_value RejectedCallback(napi_env env, napi_callback_info info) +{ + void *data = nullptr; + if (napi_get_cb_info(env, info, nullptr, nullptr, nullptr, &data) != napi_ok) { + return nullptr; + } + reinterpret_cast *>(data)->set_exception( + std::make_exception_ptr(std::runtime_error("Error in jsCallback"))); + return nullptr; +} + +static void CallJs(napi_env env, napi_value jsCb, void *context, void *data) +{ + if (env == nullptr) { + return; + } + napi_value undefined = nullptr; + napi_value promise = nullptr; + napi_get_undefined(env, &undefined); + napi_call_function(env, undefined, jsCb, 0, nullptr, &promise); + napi_value thenFunc = nullptr; + if (napi_get_named_property(env, promise, "then", &thenFunc) != napi_ok) { + return; + } + napi_value resolvedCallback; + napi_value rejectedCallback; + napi_create_function(env, "resolvedCallback", NAPI_AUTO_LENGTH, ResolvedCallback, data, &resolvedCallback); + napi_create_function(env, "rejectedCallback", NAPI_AUTO_LENGTH, RejectedCallback, data, &rejectedCallback); + napi_value argv[2] = {resolvedCallback, rejectedCallback}; + napi_call_function(env, promise, thenFunc, INT_ARG_2, argv, nullptr); +} + +static void WorkComplete(napi_env env, napi_status status, void *data) +{ + CallbackData *callbackData = reinterpret_cast(data); + napi_release_threadsafe_function(callbackData->tsfn, napi_tsfn_release); + napi_delete_async_work(env, callbackData->work); + callbackData->tsfn = nullptr; + callbackData->work = nullptr; +} + + +static napi_value StartThread(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value jsCb = nullptr; + CallbackData *callbackData = nullptr; + napi_get_cb_info(env, info, &argc, &jsCb, nullptr, reinterpret_cast(&callbackData)); + + // 创建一个线程安全函数 + napi_value resourceName = nullptr; + napi_create_string_utf8(env, "Thread-safe Function Demo", NAPI_AUTO_LENGTH, &resourceName); + napi_create_threadsafe_function(env, jsCb, nullptr, resourceName, 0, 1, callbackData, nullptr, callbackData, CallJs, + &callbackData->tsfn); + + // 创建一个异步任务 + // ExecuteWork会执行在一个由libuv创建的非JS线程上 + // 此处使用napi_create_async_work是为了模拟在非JS线程场景使用napi_call_threadsafe_function接口向JS线程提交任务 + napi_create_async_work(env, nullptr, resourceName, ExecuteWork, WorkComplete, callbackData, &callbackData->work); + + // 将异步任务加入到异步队列中 + napi_queue_async_work(env, callbackData->work); + return nullptr; +} + + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + CallbackData *callbackData = new CallbackData(); // 可在线程退出时释放 + napi_property_descriptor desc[] = { + {"startThread", nullptr, StartThread, nullptr, nullptr, nullptr, napi_default, callbackData}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END +// [End napi_thread_safety_cpp] + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry1", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..3f830fc284 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start napi_ark_runtime_dts] +export const createArkRuntime: () => object; +// [End napi_ark_runtime_dts] +// [Start napi_event_loop_dts] +export const runEventLoop: (isDefault: boolean) => object; +// [End napi_event_loop_dts] +// [Start napi_call_threadsafe_function_with_priority_dts] +export const callThreadSafeWithPriority: (cb: (a: number, b: number) => number) => void; +// [End napi_call_threadsafe_function_with_priority_dts] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/Index.d.ts new file mode 100644 index 0000000000..a3708a31b1 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/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. + */ +// [Start napi_thread_safety_dts] +export const startThread: (a: () => Promise) => void; +// [End napi_thread_safety_dts] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/oh-package.json5 new file mode 100644 index 0000000000..f6d9ff0107 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/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": "libentry1.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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..75f20730a7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start napi_call_threadsafe_function_with_priority_ets] +// [Start napi_event_loop_ets] +// [Start napi_ark_runtime_ets] +import testNapi from 'libentry.so'; +// [StartExclute napi_call_threadsafe_function_with_priority_ets] +// [StartExclute napi_event_loop_ets] +// [StartExclute napi_ark_runtime_ets] +// [Start napi_thread_safety_ets] +import nativeModule from 'libentry1.so'; +// [StartExclute napi_thread_safety_ets] +@Entry +@Component +struct Index { + @State message: string = 'NodeAPI'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + Button($r('app.string.createArkRuntime')) + .width('70%') + .onClick(() => { + // [EndExclute napi_ark_runtime_ets] + testNapi.createArkRuntime(); + // [End napi_ark_runtime_ets] + this.message = 'ArkRuntime success'; + }) + Button($r('app.string.runEventLoop')) + .width('70%') + .onClick(() => { + // [EndExclute napi_event_loop_ets] + testNapi.runEventLoop(true); + // [End napi_event_loop_ets] + this.message = 'EventLoop success'; + }) + Button($r('app.string.CallThreadSafeWithPriority')) + .width('70%') + .onClick(() => { + // [EndExclute napi_call_threadsafe_function_with_priority_ets] + let callback = (a: number, b: number): number => { + console.info('result is ' + (a + b)) + return a + b; + } + testNapi.callThreadSafeWithPriority(callback); + // [End napi_call_threadsafe_function_with_priority_ets] + this.message = 'ThreadSafeWithPriority success'; + }) + Button($r('app.string.startThread')) + .width('70%') + .onClick(() => { + // [EndExclute napi_thread_safety_ets] + let callback = (): Promise => { + return new Promise((resolve) => { + setTimeout(() => { + resolve('string from promise'); + }, 5000); + }); + } + nativeModule.startThread(callback); + // [End napi_thread_safety_ets] + this.message = 'StartThread success'; + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/ObjectUtils.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/ObjectUtils.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/ObjectUtils.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/ObjectUtils.ets index 7dc7cf1eea..893ce0d23b --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/ObjectUtils.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/ObjectUtils.ets @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start napi_ark_runtime_utils] -export function Logger() { - console.log('print log'); -} -// [End napi_ark_runtime_utils] -// [Start napi_event_loop_utils] -export function SetTimeout(): Promise { - return new Promise((resolve) => { - setTimeout(() => { - console.info('set timer delay 1s'); - // attempt to stop the event loop at napi terminal - resolve(); - }, 1000) - }) -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start napi_ark_runtime_utils] +export function Logger() { + console.log('print log'); +} +// [End napi_ark_runtime_utils] +// [Start napi_event_loop_utils] +export function SetTimeout(): Promise { + return new Promise((resolve) => { + setTimeout(() => { + console.info('set timer delay 1s'); + // attempt to stop the event loop at napi terminal + resolve(); + }, 1000) + }) +} // [End napi_event_loop_utils] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/NodeApiApplicationScenario.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/NodeApiApplicationScenario.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/NodeApiApplicationScenario.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/NodeApiApplicationScenario.test.ets index 25017f5581..92fe3c0399 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/NodeApiApplicationScenario.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/NodeApiApplicationScenario.test.ets @@ -1,108 +1,108 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeApiApplicationScenarioTest() { - describe('nodeApiApplicationScenarioTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用createArkRuntime相关函数 - */ - it('testNodeApiArkTSRuntime001', 0, async (done: Function) => { - console.info('uitest: testNodeApiArkTSRuntime001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call createArkRuntime')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ArkRuntime success')); - console.info('uitest: testNodeApiArkTSRuntime001 end'); - done(); - }) - - /** - * 点击按钮,调用runEventLoop相关函数 - */ - it('testNodeAPIEventLoop001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIEventLoop001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call runEventLoop')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('EventLoop success')); - console.info('uitest: testNodeAPIEventLoop001 end'); - done(); - }) - - /** - * 点击按钮,调用CallThreadSafeWithPriority相关函数 - */ - it('testNodeAPICallThreadsafeFunctionWithPriority001', 0, async (done: Function) => { - console.info('uitest: testNodeAPICallThreadsafeFunctionWithPriority001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call CallThreadSafeWithPriority')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ThreadSafeWithPriority success')); - console.info('uitest: testNodeAPIArray001 end'); - done(); - }) - - /** - * 点击按钮,调用startThread相关函数 - */ - it('testNodeAPIThreadSafety001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIThreadSafety001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call startThread')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('StartThread success')); - console.info('uitest: testNodeAPIThreadSafety001 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeApiApplicationScenarioTest() { + describe('nodeApiApplicationScenarioTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用createArkRuntime相关函数 + */ + it('testNodeApiArkTSRuntime001', 0, async (done: Function) => { + console.info('uitest: testNodeApiArkTSRuntime001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call createArkRuntime')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ArkRuntime success')); + console.info('uitest: testNodeApiArkTSRuntime001 end'); + done(); + }) + + /** + * 点击按钮,调用runEventLoop相关函数 + */ + it('testNodeAPIEventLoop001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIEventLoop001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call runEventLoop')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('EventLoop success')); + console.info('uitest: testNodeAPIEventLoop001 end'); + done(); + }) + + /** + * 点击按钮,调用CallThreadSafeWithPriority相关函数 + */ + it('testNodeAPICallThreadsafeFunctionWithPriority001', 0, async (done: Function) => { + console.info('uitest: testNodeAPICallThreadsafeFunctionWithPriority001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call CallThreadSafeWithPriority')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ThreadSafeWithPriority success')); + console.info('uitest: testNodeAPIArray001 end'); + done(); + }) + + /** + * 点击按钮,调用startThread相关函数 + */ + it('testNodeAPIThreadSafety001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIThreadSafety001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call startThread')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('StartThread success')); + console.info('uitest: testNodeAPIThreadSafety001 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/ohosTest.md new file mode 100644 index 0000000000..f8877f53e5 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/ohosTest.md @@ -0,0 +1,11 @@ +# Node-API使用场景用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| -------------------------------------------------------- | ------------ | ----------------------------------------------- | --------------------------------------------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口createArkRuntime | 位于主页 | 点击Call createArkRuntime的Button组件 | 成功调用函数输出日志,页面顶端文本变为success | Pass | +| ArkTS端成功调用native侧接口 callThreadSafeWithPriority | 位于主页 | 点击Call CallThreadSafeWithPriority的Button组件 | 成功调用函数输出日志,页面顶端文本变为success | Pass | +| ArkTS端成功调用native侧接口runEventLoop | 位于主页 | 点击按钮为调用runEventLoop的Button组件 | 成功调用函数输出日志,页面顶端文本变为success | Pass | +| ArkTS端成功调用native侧接口startThread | 位于主页 | 点击按钮为调用startThread的Button组件 | 成功调用函数输出日志,页面顶端文本变为success | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/screenshots/NodeApiApplicationScenario1.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/screenshots/NodeApiApplicationScenario1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/screenshots/NodeApiApplicationScenario1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/screenshots/NodeApiApplicationScenario1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/screenshots/NodeApiApplicationScenario2.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/screenshots/NodeApiApplicationScenario2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/screenshots/NodeApiApplicationScenario2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiApplicationScenario/screenshots/NodeApiApplicationScenario2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/.gitignore rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/.gitignore diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/app.json5 new file mode 100644 index 0000000000..14d4a8aecf --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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.nodeapiloadmodule", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..f11975d7ca --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeApiLoadModule" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/README.md new file mode 100644 index 0000000000..304c37ec9a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/README.md @@ -0,0 +1,75 @@ +# ArkTS使用Node-API接口在主线程中进行模块加载 + +### 介绍 + +本工程展示了使用Node-API接口在主线程中进行系统模块加载与ArkTS单文件加载。详细描述可查如下链接中。 + +- [使用Node-API接口在主线程中进行模块加载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-load-module.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现如上图效果和两个按钮,依次点击按钮后可以加载系统模块和单文件模块,并将成功结果呈现到text文本中。 +3. 运行测试用例NodeApiLoadModule.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── libentry + │ │ └── libentry1 + │ │ ├── file.cpp // ArkTS单文件加载 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp // 系统模块加载 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 加载模块 + │ │ ├── Test.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeApiLoadModule.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiLoadModule > .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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/code-linter.json5 rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/code-linter.json5 diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/build-profile.json5 new file mode 100644 index 0000000000..7aad2ac11a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/build-profile.json5 @@ -0,0 +1,68 @@ +/* + * 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", + // [Start napi_load_module_napi_build] + "buildOption": { + "arkOptions" : { + "runtimeOnly" : { + "sources": [ + "./src/main/ets/Test.ets" + ] + } + }, + // [End napi_load_module_napi_build] + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "arm64-v8a", + "x86_64", + "armeabi-v7a" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/oh-package.json5 new file mode 100644 index 0000000000..a26930aada --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/oh-package.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry", + "libentry1.so": "file:./src/main/cpp/types/libentry1" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..4848d2f549 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,18 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeApiLoadModule) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) + +add_library(entry1 SHARED file.cpp) +target_link_libraries(entry1 PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/file.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/file.cpp new file mode 100644 index 0000000000..a1b77c615f --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/file.cpp @@ -0,0 +1,60 @@ +/* + * 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 +// [Start napi_load_module_napi_file] +static napi_value loadModule(napi_env env, napi_callback_info info) +{ + napi_value result; + // 1. 使用napi_load_module加载Test文件中的模块 + napi_status status = napi_load_module(env, "ets/Test", &result); + + napi_value testFn; + // 2. 使用napi_get_named_property获取test函数 + napi_get_named_property(env, result, "test", &testFn); + // 3. 使用napi_call_function调用函数test + napi_call_function(env, result, testFn, 0, nullptr, nullptr); + + napi_value value; + napi_value key; + std::string keyStr = "value"; + napi_create_string_utf8(env, keyStr.c_str(), keyStr.size(), &key); + // 4. 使用napi_get_property获取变量value + napi_get_property(env, result, key, &value); + return result; +} +// [End napi_load_module_napi_file] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry1", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..8049c17efa --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" +#include +// [Start napi_load_module_napi_init] +static napi_value loadModule(napi_env env, napi_callback_info info) +{ + // 1. 使用napi_load_module加载模块@ohos.hilog + napi_value result; + napi_status status = napi_load_module(env, "@ohos.hilog", &result); + + // 2. 使用napi_get_named_property获取info函数 + napi_value infoFn; + napi_get_named_property(env, result, "info", &infoFn); + + napi_value tag; + std::string formatStr = "test"; + napi_create_string_utf8(env, formatStr.c_str(), formatStr.size(), &tag); + + napi_value outputString; + std::string str = "Hello OpenHarmony"; + napi_create_string_utf8(env, str.c_str(), str.size(), &outputString); + + napi_value flag; + napi_create_int32(env, 0, &flag); + + napi_value args[3] = {flag, tag, outputString}; + // 3. 使用napi_call_function调用info函数 + napi_call_function(env, result, infoFn, 3, args, nullptr); + return result; +} +// [End napi_load_module_napi_init] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..e289d9bde6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/Index.d.ts new file mode 100644 index 0000000000..e289d9bde6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/oh-package.json5 new file mode 100644 index 0000000000..f6d9ff0107 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/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": "libentry1.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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/Test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/Test.ets new file mode 100644 index 0000000000..d212d171e4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/Test.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start napi_load_module_napi_test] +let value = 123; +function test() { + console.log('Hello OpenHarmony'); +} +export {value, test}; +// [End napi_load_module_napi_test] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..0b0bf4e26b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import testNapi from 'libentry.so'; +import test from 'libentry1.so'; + +@Entry +@Component +struct Index { + @State message: string = 'LoudModule'; + + build() { + Column() { + Text(this.message) + .fontSize(30) + Button($r('app.string.loadModuleSystem')) + .margin(3) + .width('70%') + .onClick(() => { + testNapi.loadModule(); + this.message = 'loadModuleSystem success'; + }) + Button($r('app.string.loadModuleFile')) + .margin(3) + .width('70%') + .onClick(() => { + test.loadModule(); + this.message = 'loadModuleFile success'; + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/NodeApiLoadModule.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/NodeApiLoadModule.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/NodeApiLoadModule.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/NodeApiLoadModule.test.ets index faf4dd5f2b..917767907b --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/NodeApiLoadModule.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/ets/test/NodeApiLoadModule.test.ets @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeApiLoadModuleTest() { - describe('nodeApiLoadModuleTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用loadModuleFile相关函数 - */ - it('testNodeApiLoadModuleTest001', 0, async () => { - console.info('uitest: testNodeApiLoadModuleTest001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call loadModuleFile')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('loadModuleFile success')); - console.info('uitest: testNodeApiLoadModuleTest001 end'); - }) - - /** - * 点击按钮,调用loadModuleSystem相关函数 - */ - it('testNodeApiLoadModuleTest002', 0, async () => { - console.info('uitest: testNodeApiLoadModuleTest002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call loadModuleSystem')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('loadModuleSystem success')); - console.info('uitest: testNodeApiLoadModuleTest002 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeApiLoadModuleTest() { + describe('nodeApiLoadModuleTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用loadModuleFile相关函数 + */ + it('testNodeApiLoadModuleTest001', 0, async () => { + console.info('uitest: testNodeApiLoadModuleTest001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call loadModuleFile')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('loadModuleFile success')); + console.info('uitest: testNodeApiLoadModuleTest001 end'); + }) + + /** + * 点击按钮,调用loadModuleSystem相关函数 + */ + it('testNodeApiLoadModuleTest002', 0, async () => { + console.info('uitest: testNodeApiLoadModuleTest002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call loadModuleSystem')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('loadModuleSystem success')); + console.info('uitest: testNodeApiLoadModuleTest002 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/ohosTest.md new file mode 100644 index 0000000000..8d1aaa6c11 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/ohosTest.md @@ -0,0 +1,9 @@ +# 使用Node-API接口在主线程中进行模块加载测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ---------------------------------------- | ------------ | ----------------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleSystem的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleSystem success | Pass | +| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleFile的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleFile success | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/screenshots/NodeApiLoadModule1.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/screenshots/NodeApiLoadModule1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/screenshots/NodeApiLoadModule1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/screenshots/NodeApiLoadModule1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/screenshots/NodeApiLoadModule2.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/screenshots/NodeApiLoadModule2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/screenshots/NodeApiLoadModule2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/screenshots/NodeApiLoadModule2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/.gitignore rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/.gitignore diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/app.json5 new file mode 100644 index 0000000000..e0db583f68 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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.nodeapiloadmodulewithinfo", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..e99e874233 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeApiLoadModuleWithInfo" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/README.md new file mode 100644 index 0000000000..16bfb3e320 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/README.md @@ -0,0 +1,86 @@ +# ArkTS使用Node-API接口进行模块加载 + +### 介绍 + + Node-API中的napi_load_module_with_info接口的功能是进行模块的加载,当模块加载出来之后,可以使用函数napi_get_property获取模块导出的变量,也可以使用napi_get_named_property获取模块导出的函数,该函数可以在新创建的ArkTS基础运行时环境中使用。 + + 本工程展示了使用napi_load_module_with_info接口进行对不同内容的加载,代码详细描述可查如下链接。 + +- [使用Node-API接口进行模块加载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-load-module-with-info.md) + +### 效果预览 + +| 首页图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现LoadModule效果和六个按钮,点击按钮后可以调用napi_load_module_with_info接口进行对不同内容进行加载,并修改Text文本内容。 +3. 运行测试用例NodeApiLoadModuleWithInfo.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── libentry + │ │ └── libentryone + │ │ └── libentrytwo + │ │ └── libentrythree + │ │ └── libentryfour + │ │ ├── api.cpp // 加载API模块 + │ │ ├── har_name.cpp // 加载HAR模块名 + │ │ ├── file.cpp // 加载模块内文件路径 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp // 加载Native库 + │ │ ├── remote_har.cpp // 加载远程HAR模块名 + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 加载模块 + │ │ ├── Test.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeApiLoadModuleWithInfo.test.ets // 自动化测试代码 + │ │ └── List.test.ets + har1/ // HAR加载HAR模块名 + har2/ // HAR加载HAR模块名 + library/ // 加载HAR模块名 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiLoadModuleWithInfo > .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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/build-profile.json5 new file mode 100644 index 0000000000..81e44eac1b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/build-profile.json5 @@ -0,0 +1,70 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "library", + "srcPath": "./library", + }, + { + "name": "har1", + "srcPath": "./har1", + }, + { + "name": "har2", + "srcPath": "./har2", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/code-linter.json5 rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/code-linter.json5 diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/build-profile.json5 new file mode 100644 index 0000000000..865bd3b2e3 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/build-profile.json5 @@ -0,0 +1,94 @@ +/* + * 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", + // [Start napi_load_module_with_info_entry_build] + // [Start napi_load_module_with_info_entry_build2] + // [Start napi_load_module_with_info_entry_build3] + // [Start napi_load_module_with_info_entry_build4] + "buildOption": { + "arkOptions" : { + "runtimeOnly" : { + // [StartExclute napi_load_module_with_info_entry_build2] + // [StartExclute napi_load_module_with_info_entry_build3] + // [StartExclute napi_load_module_with_info_entry_build4] + "sources": [ + "./src/main/ets/Test.ets", + ], + // [EndExclute napi_load_module_with_info_entry_build2] + // [EndExclute napi_load_module_with_info_entry_build3] + // [EndExclute napi_load_module_with_info_entry_build4] + // [End napi_load_module_with_info_entry_build] + "packages": [ + // [StartExclute napi_load_module_with_info_entry_build3] + // [StartExclute napi_load_module_with_info_entry_build4] + "library", + // [End napi_load_module_with_info_entry_build2] + // [EndExclute napi_load_module_with_info_entry_build4] + "libentry.so", + // [End napi_load_module_with_info_entry_build4] + "libentryone.so", + "libentrytwo.so", + "libentrythree.so", + "libentryfour.so", + "har1", + // [EndExclute napi_load_module_with_info_entry_build3] + "@ohos/hypium" + // [End napi_load_module_with_info_entry_build3] + ] + } + }, + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "arm64-v8a", + "x86_64", + "armeabi-v7a" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/oh-package.json5 new file mode 100644 index 0000000000..39c5cb8b47 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/oh-package.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. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + // [Start napi_load_module_with_info_entry_oh] + // [Start napi_load_module_with_info_entry_oh2] + // [Start napi_load_module_with_info_entry_oh3] + "dependencies": { + // [StartExclute napi_load_module_with_info_entry_oh] + // [StartExclute napi_load_module_with_info_entry_oh2] + "libentry.so": "file:./src/main/cpp/types/libentry", + // [Start napi_load_module_with_info_entry_oh3] + "libentryone.so": "file:./src/main/cpp/types/libentryone", + "libentrytwo.so": "file:./src/main/cpp/types/libentrytwo", + "libentrythree.so": "file:./src/main/cpp/types/libentrythree", + "libentryfour.so": "file:./src/main/cpp/types/libentryfour", + // [EndExclute napi_load_module_with_info_entry_oh] + "library": "file:../library", + // [End napi_load_module_with_info_entry_oh] + // [EndExclute napi_load_module_with_info_entry_oh2] + "@ohos/hypium": "1.0.16", + // [End napi_load_module_with_info_entry_oh2] + "har1": "file:../har1" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..9b07592f9d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,27 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeApiLoadModuleWithInfo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) + +add_library(entryone SHARED har_name.cpp) +target_link_libraries(entryone PUBLIC libace_napi.z.so) + +add_library(entrytwo SHARED remote_har.cpp) +target_link_libraries(entrytwo PUBLIC libace_napi.z.so) + +add_library(entrythree SHARED api.cpp) +target_link_libraries(entrythree PUBLIC libace_napi.z.so) + +add_library(entryfour SHARED file.cpp) +target_link_libraries(entryfour PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/api.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/api.cpp old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/api.cpp rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/api.cpp index 2530344957..756e39601e --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/api.cpp +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/api.cpp @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "napi/native_api.h" -// [Start napi_load_module_with_info_entry_api] -static napi_value loadModule(napi_env env, napi_callback_info info) -{ - // 1. 使用napi_load_module_with_info加载模块@ohos.hilog - napi_value result; - napi_status status = napi_load_module_with_info(env, "@ohos.hilog", nullptr, &result); - - // 2. 使用napi_get_named_property获取info函数 - napi_value infoFn; - napi_get_named_property(env, result, "info", &infoFn); - - napi_value tag; - std::string formatStr = "test"; - napi_create_string_utf8(env, formatStr.c_str(), formatStr.size(), &tag); - - napi_value outputString; - std::string str = "Hello OpenHarmony"; - napi_create_string_utf8(env, str.c_str(), str.size(), &outputString); - - napi_value flag; - napi_create_int32(env, 0, &flag); - - napi_value args[3] = {flag, tag, outputString}; - // 3. 使用napi_call_function调用info函数 - napi_call_function(env, result, infoFn, 3, args, nullptr); - return result; -} -// [End napi_load_module_with_info_entry_api] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entrythree", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 +#include "napi/native_api.h" +// [Start napi_load_module_with_info_entry_api] +static napi_value loadModule(napi_env env, napi_callback_info info) +{ + // 1. 使用napi_load_module_with_info加载模块@ohos.hilog + napi_value result; + napi_status status = napi_load_module_with_info(env, "@ohos.hilog", nullptr, &result); + + // 2. 使用napi_get_named_property获取info函数 + napi_value infoFn; + napi_get_named_property(env, result, "info", &infoFn); + + napi_value tag; + std::string formatStr = "test"; + napi_create_string_utf8(env, formatStr.c_str(), formatStr.size(), &tag); + + napi_value outputString; + std::string str = "Hello OpenHarmony"; + napi_create_string_utf8(env, str.c_str(), str.size(), &outputString); + + napi_value flag; + napi_create_int32(env, 0, &flag); + + napi_value args[3] = {flag, tag, outputString}; + // 3. 使用napi_call_function调用info函数 + napi_call_function(env, result, infoFn, 3, args, nullptr); + return result; +} +// [End napi_load_module_with_info_entry_api] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entrythree", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/file.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/file.cpp new file mode 100644 index 0000000000..5738fb4c5f --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/file.cpp @@ -0,0 +1,61 @@ +/* + * 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 +#include "napi/native_api.h" +// [Start napi_load_module_with_info_entry_file] +static napi_value loadModule(napi_env env, napi_callback_info info) +{ + napi_value result; + // 1. 使用napi_load_module_with_info加载Test文件中的模块 + napi_status status = + napi_load_module_with_info(env, "entry/src/main/ets/Test", "com.example.application/entry", &result); + + napi_value testFn; + // 2. 使用napi_get_named_property获取test函数 + napi_get_named_property(env, result, "test", &testFn); + // 3. 使用napi_call_function调用函数test + napi_call_function(env, result, testFn, 0, nullptr, nullptr); + + napi_value value; + napi_value key; + std::string keyStr = "value"; + napi_create_string_utf8(env, keyStr.c_str(), keyStr.size(), &key); + // 4. 使用napi_get_property获取变量value + napi_get_property(env, result, key, &value); + return result; +} +// [End napi_load_module_with_info_entry_file] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entryfour", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/har_name.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/har_name.cpp old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/har_name.cpp rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/har_name.cpp index f89cf21d3e..422e4ccfe8 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/har_name.cpp +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/har_name.cpp @@ -1,60 +1,60 @@ -/* - * 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 -#include "napi/native_api.h" -// [Start napi_load_module_with_info_entry_har_name] -static napi_value loadModule(napi_env env, napi_callback_info info) -{ - napi_value result; - // 1. 使用napi_load_module_with_info加载library - napi_status status = napi_load_module_with_info(env, "library", "com.example.application/entry", &result); - - napi_value testFn; - // 2. 使用napi_get_named_property获取test函数 - napi_get_named_property(env, result, "test", &testFn); - // 3. 使用napi_call_function调用函数test - napi_call_function(env, result, testFn, 0, nullptr, nullptr); - - napi_value value; - napi_value key; - std::string keyStr = "value"; - napi_create_string_utf8(env, keyStr.c_str(), keyStr.size(), &key); - // 4. 使用napi_get_property获取变量value - napi_get_property(env, result, key, &value); - return result; -} -// [End napi_load_module_with_info_entry_har_name] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entryone", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 +#include "napi/native_api.h" +// [Start napi_load_module_with_info_entry_har_name] +static napi_value loadModule(napi_env env, napi_callback_info info) +{ + napi_value result; + // 1. 使用napi_load_module_with_info加载library + napi_status status = napi_load_module_with_info(env, "library", "com.example.application/entry", &result); + + napi_value testFn; + // 2. 使用napi_get_named_property获取test函数 + napi_get_named_property(env, result, "test", &testFn); + // 3. 使用napi_call_function调用函数test + napi_call_function(env, result, testFn, 0, nullptr, nullptr); + + napi_value value; + napi_value key; + std::string keyStr = "value"; + napi_create_string_utf8(env, keyStr.c_str(), keyStr.size(), &key); + // 4. 使用napi_get_property获取变量value + napi_get_property(env, result, key, &value); + return result; +} +// [End napi_load_module_with_info_entry_har_name] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entryone", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..6b9981d7ae --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,62 @@ +/* + * 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" +// [Start napi_load_module_with_info_entry_napi_init] +static constexpr int INT_ARG_2 = 2; // 入参索引 +static constexpr int INT_ARG_3 = 3; // 入参索引 + +static napi_value loadModule(napi_env env, napi_callback_info info) +{ + napi_value result; + // 1. 使用napi_load_module_with_info加载libentry.so + napi_status status = napi_load_module_with_info(env, "libentry.so", "com.example.application/entry", &result); + + napi_value addFn; + // 2. 使用napi_get_named_property获取add函数 + napi_get_named_property(env, result, "add", &addFn); + + napi_value a; + napi_value b; + napi_create_int32(env, INT_ARG_2, &a); + napi_create_int32(env, INT_ARG_3, &b); + napi_value args[2] = {a, b}; + // 3. 使用napi_call_function调用函数add + napi_value returnValue; + napi_call_function(env, result, addFn, INT_ARG_2, args, &returnValue); + return result; +} +// [End napi_load_module_with_info_entry_napi_init] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/remote_har.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/remote_har.cpp old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/remote_har.cpp rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/remote_har.cpp index bd1fbfb301..80badfb253 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/remote_har.cpp +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/remote_har.cpp @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "napi/native_api.h" -// [Start napi_load_module_with_info_entry_remote_har] -static napi_value loadModule(napi_env env, napi_callback_info info) -{ - napi_value result; - // 1. 使用napi_load_module_with_info加载@ohos/hypium - napi_status status = napi_load_module_with_info(env, "@ohos/hypium", "com.example.application/entry", &result); - - napi_value key; - std::string keyStr = "DEFAULT"; - napi_create_string_utf8(env, keyStr.c_str(), keyStr.size(), &key); - // 2. 使用napi_get_property获取DEFAULT变量 - napi_value defaultValue; - napi_get_property(env, result, key, &defaultValue); - return result; -} -// [End napi_load_module_with_info_entry_remote_har] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entrytwo", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 +#include "napi/native_api.h" +// [Start napi_load_module_with_info_entry_remote_har] +static napi_value loadModule(napi_env env, napi_callback_info info) +{ + napi_value result; + // 1. 使用napi_load_module_with_info加载@ohos/hypium + napi_status status = napi_load_module_with_info(env, "@ohos/hypium", "com.example.application/entry", &result); + + napi_value key; + std::string keyStr = "DEFAULT"; + napi_create_string_utf8(env, keyStr.c_str(), keyStr.size(), &key); + // 2. 使用napi_get_property获取DEFAULT变量 + napi_value defaultValue; + napi_get_property(env, result, key, &defaultValue); + return result; +} +// [End napi_load_module_with_info_entry_remote_har] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entrytwo", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..e289d9bde6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/Index.d.ts new file mode 100644 index 0000000000..e289d9bde6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/oh-package.json5 new file mode 100644 index 0000000000..4a1ffa1d0b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/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": "libentryfour.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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/Index.d.ts new file mode 100644 index 0000000000..e289d9bde6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/oh-package.json5 new file mode 100644 index 0000000000..579c7f166e --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/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": "libentryone.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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/Index.d.ts new file mode 100644 index 0000000000..e289d9bde6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/oh-package.json5 new file mode 100644 index 0000000000..1a698bc1fb --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/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": "libentrythree.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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/Index.d.ts new file mode 100644 index 0000000000..e289d9bde6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/oh-package.json5 new file mode 100644 index 0000000000..414b54bb32 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/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": "libentrytwo.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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/Test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/Test.ets new file mode 100644 index 0000000000..546907f37c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/Test.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start napi_load_module_with_info_entry_test] +let value = 123; + +function test() { + console.log('Hello OpenHarmony'); +} + +export { value, test }; +// [End napi_load_module_with_info_entry_test] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..6ca2ad0cbc --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,73 @@ +/* + * 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'; +import napiHar from 'libentryone.so'; +import napiRemoteHar from 'libentrytwo.so'; +import napiAPI from 'libentrythree.so'; +import napiFile from 'libentryfour.so' +import { tests } from 'har1'; + +@Entry +@Component +struct Index { + @State message: string = 'LoadModule'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bolder) + Button($r('app.string.loadModuleFile')) + .width('70%') + .onClick(() => { + napiFile.loadModule(); + this.message = 'loadModuleFile success'; + }) + Button($r('app.string.loadModuleHarName')) + .width('70%') + .onClick(() => { + napiHar.loadModule(); + this.message = 'loadModuleHarName success'; + }) + Button($r('app.string.loadModuleRemoteHar')) + .width('70%') + .onClick(() => { + napiRemoteHar.loadModule(); + this.message = 'loadModuleRemoteHar success'; + }) + Button($r('app.string.loadModuleAPI')) + .width('70%') + .onClick(() => { + napiAPI.loadModule(); + this.message = 'loadModuleAPI success'; + }) + Button($r('app.string.loadModuleNative')) + .width('70%') + .onClick(() => { + testNapi.loadModule(); + this.message = 'loadModuleNative success'; + }) + Button($r('app.string.loadModuleHarToHar')) + .width('70%') + .onClick(() => { + tests(); + this.message = 'loadModuleHarToHar success'; + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/NodeApiLoadModuleWithInfo.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/NodeApiLoadModuleWithInfo.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/NodeApiLoadModuleWithInfo.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/NodeApiLoadModuleWithInfo.test.ets index 5de842ae29..2b44cc7776 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/NodeApiLoadModuleWithInfo.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/ets/test/NodeApiLoadModuleWithInfo.test.ets @@ -1,133 +1,133 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeApiLoadModuleWithInfoTest() { - describe('nodeApiLoadModuleWithInfoTest', () => { - - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,加载模块内文件路径 - */ - it('testNodeApiLoadModuleWithInfo001', 0, async () => { - console.info('uitest: testNodeApiLoadModuleWithInfo001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call loadModuleFile')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('loadModuleFile success')); - console.info('uitest: testNodeApiLoadModuleWithInfo001 end'); - }) - - /** - * 点击按钮,加载HAR模块名 - */ - it('testNodeApiLoadModuleWithInfo002', 0, async () => { - console.info('uitest: testNodeApiLoadModuleWithInfo002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call loadModuleHarName')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('loadModuleHarName success')); - console.info('uitest: testNodeApiLoadModuleWithInfo002 end'); - }) - - /** - * 点击按钮,加载远程HAR模块名 - */ - it('testNodeApiLoadModuleWithInfo003', 0, async () => { - console.info('uitest: testNodeApiLoadModuleWithInfo003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call loadModuleRemoteHar')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('loadModuleRemoteHar success')); - console.info('uitest: testNodeApiLoadModuleWithInfo003 end'); - }) - - /** - * 点击按钮,加载API模块 - */ - it('testNodeApiLoadModuleWithInfo004', 0, async () => { - console.info('uitest: testNodeApiLoadModuleWithInfo004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call loadModuleAPI')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('loadModuleAPI success')); - console.info('uitest: testNodeApiLoadModuleWithInfo004 end'); - }) - - /** - * 点击按钮,加载Native库 - */ - it('testNodeApiLoadModuleWithInfo005', 0, async () => { - console.info('uitest: testNodeApiLoadModuleWithInfo005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call loadModuleNative')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('loadModuleNative success')); - console.info('uitest: testNodeApiLoadModuleWithInfo005 end'); - }) - - /** - * 点击按钮,调用loadModuleHarToHar相关函数 - */ - it('testNodeApiLoadModuleWithInfo006', 0, async (done: Function) => { - console.info('uitest: testNodeApiLoadModuleWithInfo006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button = await driver.findComponent(ON.text('Call loadModuleHarToHar')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('loadModuleHarToHar success')); - console.info('uitest: testNodeApiLoadModuleWithInfo006 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeApiLoadModuleWithInfoTest() { + describe('nodeApiLoadModuleWithInfoTest', () => { + + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,加载模块内文件路径 + */ + it('testNodeApiLoadModuleWithInfo001', 0, async () => { + console.info('uitest: testNodeApiLoadModuleWithInfo001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call loadModuleFile')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('loadModuleFile success')); + console.info('uitest: testNodeApiLoadModuleWithInfo001 end'); + }) + + /** + * 点击按钮,加载HAR模块名 + */ + it('testNodeApiLoadModuleWithInfo002', 0, async () => { + console.info('uitest: testNodeApiLoadModuleWithInfo002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call loadModuleHarName')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('loadModuleHarName success')); + console.info('uitest: testNodeApiLoadModuleWithInfo002 end'); + }) + + /** + * 点击按钮,加载远程HAR模块名 + */ + it('testNodeApiLoadModuleWithInfo003', 0, async () => { + console.info('uitest: testNodeApiLoadModuleWithInfo003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call loadModuleRemoteHar')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('loadModuleRemoteHar success')); + console.info('uitest: testNodeApiLoadModuleWithInfo003 end'); + }) + + /** + * 点击按钮,加载API模块 + */ + it('testNodeApiLoadModuleWithInfo004', 0, async () => { + console.info('uitest: testNodeApiLoadModuleWithInfo004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call loadModuleAPI')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('loadModuleAPI success')); + console.info('uitest: testNodeApiLoadModuleWithInfo004 end'); + }) + + /** + * 点击按钮,加载Native库 + */ + it('testNodeApiLoadModuleWithInfo005', 0, async () => { + console.info('uitest: testNodeApiLoadModuleWithInfo005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call loadModuleNative')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('loadModuleNative success')); + console.info('uitest: testNodeApiLoadModuleWithInfo005 end'); + }) + + /** + * 点击按钮,调用loadModuleHarToHar相关函数 + */ + it('testNodeApiLoadModuleWithInfo006', 0, async (done: Function) => { + console.info('uitest: testNodeApiLoadModuleWithInfo006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button = await driver.findComponent(ON.text('Call loadModuleHarToHar')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('loadModuleHarToHar success')); + console.info('uitest: testNodeApiLoadModuleWithInfo006 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/Index.ets new file mode 100644 index 0000000000..5d546ed066 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/Index.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import testNapi from 'libhar1.so'; + +export { MainPage } from './src/main/ets/components/MainPage'; + +function tests() { + testNapi.loadModule(); +} + +export { tests }; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/build-profile.json5 new file mode 100644 index 0000000000..5eb0ae7fbd --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/build-profile.json5 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + // [Start napi_load_module_with_info_har1_build] + "buildOption": { + "arkOptions": { + "runtimeOnly": { + "packages": [ + "har2", + // [End napi_load_module_with_info_har1_build] + "libhar1.so" + ] + } + }, + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "arm64-v8a", + "x86_64", + "armeabi-v7a" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/oh-package.json5 new file mode 100644 index 0000000000..71a986edbe --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/oh-package.json5 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "har1", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + // [Start napi_load_module_with_info_har1_oh] + "dependencies": { + "har2": "file:../har2", + // [End napi_load_module_with_info_har1_oh] + "libhar1.so": "file:./src/main/cpp/types/libhar1" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6d0ae00003 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/CMakeLists.txt @@ -0,0 +1,15 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeApiLoadModuleWithInfo) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(har1 SHARED napi_init.cpp) +target_link_libraries(har1 PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..42b1317cde --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/napi_init.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" +#include + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} +// [Start napi_load_module_with_info_har1_napi_init] +static napi_value loadModule(napi_env env, napi_callback_info info) +{ + napi_value result; + // 1. 使用napi_load_module_with_info加载har2,注意这里的moduleName为模块所在HAP包的moduleName + napi_status status = napi_load_module_with_info(env, "har2", "com.example.application/entry", &result); + + napi_value testFn; + // 2. 使用napi_get_named_property获取test函数 + napi_get_named_property(env, result, "test", &testFn); + // 3. 使用napi_call_function调用函数test + napi_call_function(env, result, testFn, 0, nullptr, nullptr); + + napi_value value; + napi_value key; + std::string keyStr = "value"; + napi_create_string_utf8(env, keyStr.c_str(), keyStr.size(), &key); + // 4. 使用napi_get_property获取变量value + napi_get_property(env, result, key, &value); + return result; +} +// [End napi_load_module_with_info_har1_napi_init] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "har1", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterHar1Module(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/index.d.ts new file mode 100644 index 0000000000..6d71322a73 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start napi_load_module_with_info_har1_dts] +export const add: (a: number, b: number) => number; +// [End napi_load_module_with_info_har1_dts] +export const loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/oh-package.json5 new file mode 100644 index 0000000000..a356d1c4b6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/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": "libhar1.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/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000..7dc1a0d257 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/ets/components/MainPage.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/module.json5 new file mode 100644 index 0000000000..f14a04c447 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "har1", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/module.json5 new file mode 100644 index 0000000000..acef8e5105 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "har1_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/Index.ets new file mode 100644 index 0000000000..9f732c3b8d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/Index.ets @@ -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. + */ + +export { MainPage } from './src/main/ets/components/MainPage' +// [Start napi_load_module_with_info_har2_index] +let value = 123; + +function test() { + console.log('Hello OpenHarmony'); +} + +export { value, test }; +// [End napi_load_module_with_info_har2_index] diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/build-profile.json5 new file mode 100644 index 0000000000..aefa5f6959 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/build-profile.json5 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/oh-package.json5 new file mode 100644 index 0000000000..d778bf2ab9 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "har2", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000..7dc1a0d257 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/ets/components/MainPage.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/module.json5 new file mode 100644 index 0000000000..cadd1c0171 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "har2", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/module.json5 new file mode 100644 index 0000000000..280914cdf0 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "har2_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/Index.ets new file mode 100644 index 0000000000..35eea49ec6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/Index.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start napi_load_module_with_info_library_index] +export { MainPage } from './src/main/ets/components/MainPage'; + +let value = 123; +function test() { + console.log('Hello OpenHarmony'); +} +export {value, test}; +// [End napi_load_module_with_info_library_index] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/build-profile.json5 new file mode 100644 index 0000000000..aefa5f6959 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/build-profile.json5 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/oh-package.json5 new file mode 100644 index 0000000000..4a133b6457 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "library", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000..7dc1a0d257 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/ets/components/MainPage.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/module.json5 new file mode 100644 index 0000000000..3c26b263b0 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "library", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000..1eac52fceb --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/module.json5 new file mode 100644 index 0000000000..412ad2e266 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "library_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/ohosTest.md new file mode 100644 index 0000000000..ca5e692c3d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/ohosTest.md @@ -0,0 +1,13 @@ +# 使用Node-API接口进行模块加载测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ---------------------------------------- | ------------ | -------------------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleFile的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleFile success | Pass | +| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleHarName的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleHarName success | Pass | +| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleRemoteHar的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleRemoteHar success | Pass | +| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleAPI的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleAPI success | Pass | +| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleNative的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleNative success | Pass | +| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleHarToHar的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleHarToHar success | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/screenshots/NodeApiLoadModuleWithInfo1.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/screenshots/NodeApiLoadModuleWithInfo1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/screenshots/NodeApiLoadModuleWithInfo1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/screenshots/NodeApiLoadModuleWithInfo1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/screenshots/NodeApiLoadModuleWithInfo2.png b/code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/screenshots/NodeApiLoadModuleWithInfo2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/screenshots/NodeApiLoadModuleWithInfo2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/screenshots/NodeApiLoadModuleWithInfo2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/.gitignore rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/.gitignore diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/app.json5 new file mode 100644 index 0000000000..468e2de069 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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.nodeapiarray", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..287d800ee7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIArray" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/README.md new file mode 100644 index 0000000000..459d9f9070 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/README.md @@ -0,0 +1,75 @@ +# ArkTS使用Node-API接口进行array相关开发 + +### 介绍 + +使用Node-API接口进行array相关开发时,调用相关接口可以在Node-API模块中直接操作和处理ArkTS中的数组,使用Node-API接口进行数组(array)相关开发时,涉及的基本概念主要包括数组的创建、访问、修改、遍历以及与数组相关的操作。 + +该工程中展示了在Node-API模块中进行数组创建、获取数组长度、通过索引获得对应值等场景,其中代码详细描述可查如下链接。 + +- [使用Node-API接口进行array相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-array.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIArray.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API接口进行array相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIArray.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/code-linter.json5 rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/code-linter.json5 diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..3ff3d42ffa --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPI_array) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..0e39963a3d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,475 @@ +/* + * 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 +#include "napi/native_api.h" + +// [Start napi_create_array] +static constexpr int INT_NUMBER_5 = 5; // 入参索引 +static constexpr int INT_ARGS_2 = 2; // 入参索引 + +// 使用Node-API接口进行array相关开发 napi_create_array +static napi_value CreateArray(napi_env env, napi_callback_info info) +{ + // 创建一个空数组 + napi_value jsArray = nullptr; + napi_create_array(env, &jsArray); + // 将创建好的数组进行赋值 + for (int i = 0; i < INT_NUMBER_5; i++) { + napi_value element; + napi_create_int32(env, i, &element); + napi_set_element(env, jsArray, i, element); + } + // 返回已创建好的数组 + return jsArray; +} +// [End napi_create_array] + +// [Start napi_create_array_with_length] +// 使用Node-API接口进行array相关开发 napi_create_array_with_length +static napi_value CreateArrayWithLength(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 1; + napi_value argv[1] = {nullptr}; + napi_value jsArray = nullptr; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + // 获取传递的数组长度 + int32_t length = 0; + napi_get_value_int32(env, argv[0], &length); + // 使用napi_create_array_with_length创建指定长度的数组 + napi_create_array_with_length(env, length, &jsArray); + // 返回数组 + return jsArray; +} +// [End napi_create_array_with_length] + +// [Start napi_get_array_length] +// 使用Node-API接口进行array相关开发 napi_get_array_length +static napi_value GetArrayLength(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_value result; + uint32_t length; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 检查参数是否为数组 + bool isArray; + napi_is_array(env, args[0], &isArray); + if (!isArray) { + napi_throw_type_error(env, nullptr, "Argument must be an array"); + return nullptr; + } + napi_get_array_length(env, args[0], &length); + // 创建返回值 + napi_create_uint32(env, length, &result); + return result; +} +// [End napi_get_array_length] + +// [Start napi_is_array] +// 使用Node-API接口进行array相关开发 napi_is_array +static napi_value IsArray(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 调用napi_is_array接口判断给定入参是否为array数组 + bool result; + napi_status status = napi_is_array(env, args[0], &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_is_array fail"); + return nullptr; + } + // 将结果转成napi_value类型返回 + napi_value returnValue; + napi_get_boolean(env, result, &returnValue); + + return returnValue; +} +// [End napi_is_array] + +// [Start napi_set_element] +// 使用Node-API接口进行array相关开发 napi_set_element +static napi_value NapiSetElement(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 3; + napi_value args[3] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 检查第一个参数是否为数组 + bool isArr = false; + napi_is_array(env, args[0], &isArr); + if (!isArr) { + napi_throw_type_error(env, nullptr, "Argument should be an object of type array"); + return nullptr; + } + // 获取要设置的元素索引 + double index = 0; + napi_get_value_double(env, args[1], &index); + // 将传入的值设置到数组指定索引位置 + napi_set_element(env, args[0], static_cast(index), args[INT_ARGS_2]); + + return nullptr; +} +// [End napi_set_element] + +// [Start napi_get_element] +// 使用Node-API接口进行array相关开发 napi_get_element +static napi_value NapiGetElement(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取请求元素的索引值 + uint32_t index; + napi_get_value_uint32(env, args[1], &index); + // 获取请求索引位置的元素值并存储在result中 + napi_value result; + napi_get_element(env, args[0], index, &result); + + return result; +} +// [End napi_get_element] + +// [Start napi_has_element] +// 使用Node-API接口进行array相关开发 napi_has_element +static napi_value NapiHasElement(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取要判断的元素的索引 + uint32_t index; + napi_get_value_uint32(env, args[1], &index); + // 判断指定索引位置的元素是否存在 + bool hasElement = true; + napi_has_element(env, args[0], index, &hasElement); + // 将bool结果转换为napi_value并返回 + napi_value result; + napi_get_boolean(env, hasElement, &result); + return result; +} +// [End napi_has_element] + +// [Start napi_delete_element] +// 使用Node-API接口进行array相关开发 napi_delete_element +static napi_value NapiDeleteElement(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取要删除的元素的索引 + uint32_t index; + napi_get_value_uint32(env, args[1], &index); + // 尝试删除请求索引位置的元素 + bool deleted = true; + napi_delete_element(env, args[0], index, &deleted); + // 将bool结果转换为napi_value并返回 + napi_value result; + napi_get_boolean(env, deleted, &result); + return result; +} +// [End napi_delete_element] + +// [Start napi_create_typed_array] +// 使用Node-API接口进行array相关开发 napi_create_typedarray +static napi_value CreateTypedArray(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + int32_t typeNum = 0; + napi_get_value_int32(env, args[0], &typeNum); + napi_typedarray_type arrayType; + // 用于存储每个元素的大小 + size_t elementSize = 0; + // 根据传递的类型值选择创建对应的类型数组 + arrayType = static_cast(typeNum); + switch (typeNum) { + case napi_int8_array: + case napi_uint8_array: + case napi_uint8_clamped_array: + elementSize = sizeof(int8_t); + break; + case napi_int16_array: + case napi_uint16_array: + elementSize = sizeof(int16_t); + break; + case napi_int32_array: + case napi_uint32_array: + elementSize = sizeof(int32_t); + break; + case napi_float32_array: + elementSize = sizeof(float); + break; + case napi_float64_array: + elementSize = sizeof(double); + break; + case napi_bigint64_array: + case napi_biguint64_array: + elementSize = sizeof(int64_t); + break; + default: + // 默认创建napi_int8_array类型 + arrayType = napi_int8_array; + elementSize = sizeof(int8_t); + break; + } + size_t length = 3; + napi_value arrayBuffer = nullptr; + napi_value typedArray = nullptr; + void *data; + // 创建一个ArrayBuffer + napi_create_arraybuffer(env, length * elementSize, (void **)&data, &arrayBuffer); + // 根据给定类型创建TypedArray + napi_create_typedarray(env, arrayType, length, arrayBuffer, 0, &typedArray); + return typedArray; +} +// [End napi_create_typed_array] + +// [Start napi_is_typed_array] +// 使用Node-API接口进行array相关开发 napi_is_typedarray +static napi_value IsTypedarray(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 调用napi_is_typedarray接口判断给定入参类型是否为TypedArray。 + bool result = false; + napi_status status = napi_is_typedarray(env, args[0], &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_is_typedarray fail"); + return nullptr; + } + // 将结果转成napi_value类型返回。 + napi_value returnValue = nullptr; + napi_get_boolean(env, result, &returnValue); + + return returnValue; +} +// [End napi_is_typed_array] + +// [Start napi_get_typed_array_info] +// 使用Node-API接口进行array相关开发 napi_get_typedarray_info +static napi_value GetTypedarrayInfo(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数,第一个参数为需要获得的信息的TypedArray类型数据,第二个参数为需要获得的信息类型的枚举值 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 将第二个参数转为int32类型便于比较 + int32_t infoTypeParam; + napi_get_value_int32(env, args[1], &infoTypeParam); + // 定义枚举类型与ArkTS侧枚举类型InfoType顺序含义一致 + enum InfoType { INFO_TYPE = 1, INFO_LENGTH, INFO_ARRAY_BUFFER, INFO_BYTE_OFFSET }; + void *data; + napi_typedarray_type type; + size_t byteOffset; + size_t length; + napi_value arraybuffer; + // 调用接口napi_get_typedarray_info获得TypedArray类型数据的信息 + napi_get_typedarray_info(env, args[0], &type, &length, &data, &arraybuffer, &byteOffset); + napi_value result; + // 根据属性名,返回TypedArray对应的属性值 + switch (infoTypeParam) { + case INFO_TYPE: + // 如果传入的参数是int8类型的TypedArray数据,它的类型(type)为napi_int8_array + napi_value int8_type; + napi_get_boolean(env, type == napi_int8_array, &int8_type); + result = int8_type; + break; + case INFO_LENGTH: + // TypedArray中的元素数 + napi_value napiLength; + napi_create_int32(env, length, &napiLength); + result = napiLength; + break; + case INFO_BYTE_OFFSET: + // TypedArray数组的第一个元素所在的基础原生数组中的字节偏移量 + napi_value napiByteOffset; + napi_create_int32(env, byteOffset, &napiByteOffset); + result = napiByteOffset; + break; + case INFO_ARRAY_BUFFER: + // TypedArray下的ArrayBuffer + result = arraybuffer; + break; + default: + break; + } + return result; +} +// [End napi_get_typed_array_info] + +// [Start napi_create_data_view] +// 使用Node-API接口进行array相关开发 napi_create_dataview +static napi_value CreateDataView(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_value arraybuffer = nullptr; + napi_value result = nullptr; + // DataView的字节长度 + size_t byteLength = 12; + // 字节偏移量 + size_t byteOffset = 4; + // 获取回调函数的参数信息 + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 将参数转换为对象类型 + napi_coerce_to_object(env, args[0], &arraybuffer); + // 创建一个数据视图对象,并指定字节长度和字节偏移量 + napi_status status = napi_create_dataview(env, byteLength, arraybuffer, byteOffset, &result); + if (status != napi_ok) { + // 抛出创建DataView内容失败的错误 + napi_throw_error(env, nullptr, "Failed to create DataView"); + return nullptr; + } + // 获取DataView的指针和长度信息 + uint8_t *data = nullptr; + size_t length = 0; + napi_get_dataview_info(env, result, &length, (void **)&data, nullptr, nullptr); + // 为DataView赋值 + for (size_t i = 0; i < length; i++) { + data[i] = static_cast(i + 1); + } + return result; +} +// [End napi_create_data_view] + +// [Start napi_is_data_view] +// 使用Node-API接口进行array相关开发 napi_is_dataview +static napi_value IsDataView(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 调用napi_is_dataview接口判断给定入参是否为DataView数据。 + bool result; + napi_status status = napi_is_dataview(env, args[0], &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_is_dataview fail"); + return nullptr; + } + // 将结果转成napi_value类型返回。 + napi_value returnValue; + napi_get_boolean(env, result, &returnValue); + + return returnValue; +} +// [End napi_is_data_view] + +// [Start napi_get_data_view_info] +// 使用Node-API接口进行array相关开发 napi_get_dataview_info +static napi_value GetDataViewInfo(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传入的参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 将第二个参数转为int32类型的数字 + int32_t infoType; + napi_get_value_int32(env, args[1], &infoType); + size_t byteLength; + void *data; + napi_value arrayBuffer; + size_t byteOffset; + // 定义枚举类型与ArkTS侧枚举类型InfoType顺序含义一致 + enum InfoType { BYTE_LENGTH = 0, ARRAY_BUFFER, BYTE_OFFSET }; + // 获取dataview信息 + napi_get_dataview_info(env, args[0], &byteLength, &data, &arrayBuffer, &byteOffset); + napi_value result; + switch (infoType) { + case BYTE_LENGTH: + // 返回查询DataView的字节数 + napi_value napiByteLength; + napi_create_int32(env, byteLength, &napiByteLength); + result = napiByteLength; + break; + case ARRAY_BUFFER: + // 返回查询DataView的arraybuffer + result = arrayBuffer; + break; + case BYTE_OFFSET: + // 返回查询DataView的偏移字节量 + napi_value napiByteOffset; + napi_create_int32(env, byteOffset, &napiByteOffset); + result = napiByteOffset; + break; + default: + break; + } + return result; +} +// [End napi_get_data_view_info] + +// [Start change_use_napi_process] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_value typedArrayTypes; + napi_create_object(env, &typedArrayTypes); + napi_value typeIndex; + std::string typeKeys[] = { + "INT8_ARRAY", "UINT8_ARRAY", "UINT8_CLAMPED_ARRAY", "INT16_ARRAY", "UINT16_ARRAY", "INT32_ARRAY", + "UINT32_ARRAY", "FLOAT32_ARRAY", "FLOAT64_ARRAY", "BIGINT64_ARRAY", "BIGUINT64_ARRAY", + }; + for (int32_t i = 0; i < sizeof(typeKeys) / sizeof(typeKeys[0]); i++) { + napi_create_int32(env, i, &typeIndex); + napi_set_named_property(env, typedArrayTypes, typeKeys[i].c_str(), typeIndex); + } + napi_property_descriptor desc[] = { + {"createArray", nullptr, CreateArray, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createArrayWithLength", nullptr, CreateArrayWithLength, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getArrayLength", nullptr, GetArrayLength, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"isArray", nullptr, IsArray, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiSetElement", nullptr, NapiSetElement, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiGetElement", nullptr, NapiGetElement, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiHasElement", nullptr, NapiHasElement, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiDeleteElement", nullptr, NapiDeleteElement, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createTypedArray", nullptr, CreateTypedArray, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"TypedArrayTypes", nullptr, nullptr, nullptr, nullptr, typedArrayTypes, napi_default, nullptr}, + {"isTypedarray", nullptr, IsTypedarray, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getTypedarrayInfo", nullptr, GetTypedarrayInfo, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createDataView", nullptr, CreateDataView, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"isDataView", nullptr, IsDataView, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getDataViewInfo", nullptr, GetDataViewInfo, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END +// [End change_use_napi_process] + +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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..68e3ae88c2 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_create_array_api] +export const createArray: () => number[]; // 使用Node-API接口进行array相关开发 napi_create_array +// [End napi_create_array_api] + +// [Start napi_create_array_with_length_api] +export const createArrayWithLength: (length: number) => void[]; // 使用Node-API接口进行array相关开发 napi_create_array_with_length +// [End napi_create_array_with_length_api] + +// [Start napi_get_array_length_api] +export const getArrayLength: (arr: Array) => number | void; // 使用Node-API接口进行array相关开发 napi_get_array_length +// [End napi_get_array_length_api] + +// [Start napi_is_array_api] +export const isArray: (data: Array | T) => boolean | void; // 使用Node-API接口进行array相关开发 napi_is_array +// [End napi_is_array_api] + +// [Start napi_set_element_api] +export const napiSetElement: (arr: Array, index: number, + value: T) => void; // 使用Node-API接口进行array相关开发 napi_set_element +// [End napi_set_element_api] + +// [Start napi_get_element_api] +export const napiGetElement: (arr: Array, + index: number) => number | string | Object | boolean | undefined; // 使用Node-API接口进行array相关开发 napi_get_element +// [End napi_get_element_api] + +// [Start napi_has_element_api] +export const napiHasElement: (arr: Array, index: number) => boolean; // 使用Node-API接口进行array相关开发 napi_has_element +// [End napi_has_element_api] + +// [Start napi_delete_element_api] +export const napiDeleteElement: (arr: Array, + index: number) => boolean; // 使用Node-API接口进行array相关开发 napi_delete_element +// [End napi_delete_element_api] + +// [Start napi_create_typed_array_api] +export const enum TypedArrayTypes { + INT8_ARRAY = 0, + UINT8_ARRAY, + UINT8_CLAMPED_ARRAY, + INT16_ARRAY, + UINT16_ARRAY, + INT32_ARRAY, + UINT32_ARRAY, + FLOAT32_ARRAY, + FLOAT64_ARRAY, + BIGINT64_ARRAY, + BIGuINT64_ARRAY, +} + +export const createTypedArray: (type: TypedArrayTypes) => T; // 使用Node-API接口进行array相关开发 napi_create_typedarray +// [End napi_create_typed_array_api] + +// [Start napi_is_typed_array_api] +export const isTypedarray: (data: Object) => boolean | void; // 使用Node-API接口进行array相关开发 napi_is_typedarray +// [End napi_is_typed_array_api] + +// [Start napi_get_typed_array_info_api] +export const getTypedarrayInfo: (typeArray: T, + infoType: number) => ArrayBuffer | number | boolean; // 使用Node-API接口进行array相关开发 napi_get_typedarray_info +// [End napi_get_typed_array_info_api] + +// [Start napi_create_data_view_api] +export const createDataView: (arraybuffer: ArrayBuffer) => DataView | void; // 使用Node-API接口进行array相关开发 napi_create_dataview +// [End napi_create_data_view_api] + +// [Start napi_is_data_view_api] +export const isDataView: (date: DataView | string) => boolean | void; // 使用Node-API接口进行array相关开发 napi_is_dataview +// [End napi_is_data_view_api] + +// [Start napi_get_data_view_info_api] +export const getDataViewInfo: (dataView: DataView, + infoType: number) => ArrayBuffer | number; // 使用Node-API接口进行array相关开发 napi_get_dataview_info +// [End napi_get_data_view_info_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..36cf2e6c68 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,310 @@ +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiCreateArray', + '2.napiCreateArrayWithLength', + '3.napiGetArrayLength', + '4.napiIsArray', + '5.napiSetElement', + '6.napiGetElement', + '7.napiHasElement', + '8.napiDeleteElement', + '9.napiCreateTypedArray', + '10.napiIsTypedArray', + '11.napiGetTypedArrayInfo', + '12.napiCreateDataView', + '13.napiIsDataView', + '14.napiGetDataViewInfo' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(23) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 4 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiCreateArray') { + // [Start ark_napi_create_array] + //使用Node-API接口进行array相关开发 napi_create_array + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_array:%{public}s', + JSON.stringify(testNapi.createArray())); + // [End ark_napi_create_array] + this.result = 'napiCreateArraySuccess'; + } else if (item === '2.napiCreateArrayWithLength') { + // [Start ark_napi_create_array_with_length] + // 使用Node-API接口进行array相关开发 napi_create_array_with_length + let array = testNapi.createArrayWithLength(6); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_array_with_length:%{public}d', array.length); + // [End ark_napi_create_array_with_length] + this.result = 'napiCreateArrayWithLengthSuccess'; + } else if (item === '3.napiGetArrayLength') { + // [Start ark_napi_get_array_length] + // 使用Node-API接口进行array相关开发 napi_get_array_length + const arr = [0, 1, 2, 3, 4, 5]; + hilog.info(0x0000, 'testTag', 'Test Node-API get_array_length:%{public}d', + testNapi.getArrayLength(arr)); + // [End ark_napi_get_array_length] + this.result = 'napiGetArrayLengthSuccess'; + } else if (item === '4.napiIsArray') { + // [Start ark_napi_is_array] + // 使用Node-API接口进行array相关开发 napi_is_array + try { + let value = new Array(1); + let data = "123"; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_array: %{public}s', + testNapi.isArray(value)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_array: %{public}s', + testNapi.isArray(data)); + // [StartExclude ark_napi_is_array] + this.result = 'napiIsArraySuccess'; + // [EndExclude ark_napi_is_array] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_array error: %{public}s', error.message); + // [StartExclude ark_napi_is_array] + this.result = 'napiIsArrayFail'; + // [EndExclude ark_napi_is_array] + } + // [End ark_napi_is_array] + } else if (item === '5.napiSetElement') { + // [Start ark_napi_set_element] + // 使用Node-API接口进行array相关开发 napi_set_element + let arr = [10, 20, 30]; + testNapi.napiSetElement(arr, 1, 'newElement'); + testNapi.napiSetElement(arr, 2, 50); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_element arr: %{public}s', arr.toString()); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_element arr[3]: %{public}s', arr[3]); + + interface MyObject { + first: number; + second: number; + } + + let obj: MyObject = { + first: 1, + second: 2 + }; + testNapi.napiSetElement(arr, 4, obj); + let objAsString = JSON.stringify(arr[4]); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_element arr[4]: %{public}s', objAsString); + // [End ark_napi_set_element] + this.result = 'napiSetElementSuccess'; + } else if (item === '6.napiGetElement') { + // [Start ark_napi_get_element] + // 使用Node-API接口进行array相关开发 napi_get_element + interface MyObject { + first: number; + second: number; + } + + let obj: MyObject = { + first: 1, + second: 2 + }; + let arr = [10, 'hello', null, obj]; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[0]: %{public}d', + testNapi.napiGetElement(arr, 0)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[1]: %{public}s', + testNapi.napiGetElement(arr, 1)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[2]: %{public}s', + testNapi.napiGetElement(arr, 2)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[3]: %{public}s', + testNapi.napiGetElement(arr, 3)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[4]: %{public}s', + JSON.stringify(testNapi.napiGetElement(arr, 4))); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[null]: %{public}s', + testNapi.napiGetElement(arr, 5)); + // [End ark_napi_get_element] + this.result = 'napiGetElementSuccess'; + } else if (item === '7.napiHasElement') { + // [Start ark_napi_has_element] + // 使用Node-API接口进行array相关开发 napi_has_element + let arr = [10, 'hello', null, 'world']; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element arr[0]: %{public}s', + testNapi.napiHasElement(arr, 0)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element arr[7]: %{public}s', + testNapi.napiHasElement(arr, 7)); + // [End ark_napi_has_element] + this.result = 'napiHasElementSuccess'; + } else if (item === '8.napiDeleteElement') { + // [Start ark_napi_delete_element] + // 使用Node-API接口进行array相关开发 napi_delete_element + let arr = [10, 'hello', null, 'world']; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element arr[0]: %{public}s', + testNapi.napiHasElement(arr, 0)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_delete_element arr[0]: %{public}s', + testNapi.napiDeleteElement(arr, 0)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element deleted arr[0]: %{public}s', + testNapi.napiHasElement(arr, 0)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[0]: %{public}d', + testNapi.napiGetElement(arr, 0)); + // [End ark_napi_delete_element] + this.result = 'napiDeleteElementSuccess'; + } else if (item === '9.napiCreateTypedArray') { + // [Start ark_napi_create_typed_array] + // 使用Node-API接口进行array相关开发 napi_create_typedarray + let typedArray = testNapi.createTypedArray(testNapi.TypedArrayTypes["INT8_ARRAY"]); + if (typedArray instanceof Int8Array) { + hilog.info(0x0000, 'testTag', ' Node-API napi_create_typedarray: Int8Array'); + // [StartExclude ark_napi_create_typed_array] + this.result = 'napiCreateInt8ArraySuccess'; + // [EndExclude ark_napi_create_typed_array] + } + let uint8Array = testNapi.createTypedArray(testNapi.TypedArrayTypes["UINT8_ARRAY"]); + if (uint8Array instanceof Uint8Array) { + hilog.info(0x0000, 'testTag', ' Node-API napi_create_typedarray: Uint8Array'); + // [StartExclude ark_napi_create_typed_array] + this.result = 'napiCreateUint8ArraySuccess'; + // [EndExclude ark_napi_create_typed_array] + } + // [End ark_napi_create_typed_array] + } else if (item === '10.napiIsTypedArray') { + // [Start ark_napi_is_typed_array] + // 使用Node-API接口进行array相关开发 napi_is_typedarray + try { + let value = new Uint8Array([1, 2, 3, 4]); + let data = "123"; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_typedarray: %{public}s', + testNapi.isTypedarray(value)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_typedarray: %{public}s', + testNapi.isTypedarray(data)); + // [StartExclude ark_napi_is_typed_array] + this.result = 'napiIsTypedArraySuccess'; + // [EndExclude ark_napi_is_typed_array] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_typedarray error: %{public}s', error.message); + // [StartExclude ark_napi_is_typed_array] + this.result = 'napiIsTypedArrayFail'; + // [EndExclude ark_napi_is_typed_array] + } + // [End ark_napi_is_typed_array] + } else if (item === '11.napiGetTypedArrayInfo') { + // [Start ark_napi_get_typed_array_info] + // 使用Node-API接口进行array相关开发 napi_get_typedarray_info + // 传入TypedArray类型数据。TypedArray是一种用来描述二进制数据的类数组数据视图,没有直接构造器,可以用其子类构造类数组 + // TypedArray的子类有: Int8Array Uint8Array Uint8ClampedArray Int16Array Int32Array等 + let int8Array = new Int8Array([15, 7]); + // 定义枚举类型 这些都是TypedArray的属性 + enum InfoType { + TYPE = 1, // 传入的TypedArray的类型 + LENGTH = 2, // 传入的TypedArray的长度 + ARRAY_BUFFER = 3, // TypedArray下的ArrayBuffer + BYTE_OFFSET = 4 // 数组的第一个元素所在的基础原生数组中的字节偏移量 + }; + let arrbuff = testNapi.getTypedarrayInfo(int8Array, InfoType.ARRAY_BUFFER) as ArrayBuffer; + // 将arraybuffer转为数组 + let arr = new Array(new Int8Array(arrbuff)); + hilog.info(0x0000, 'Node-API', 'get_typedarray_info_arraybuffer: %{public}s', arr.toString()); + hilog.info(0x0000, 'Node-API', 'get_typedarray_info_isIn8Array: %{public}s', + testNapi.getTypedarrayInfo(int8Array, InfoType.TYPE).toString()); + hilog.info(0x0000, 'Node-API', 'get_typedarray_info_length: %{public}d', + testNapi.getTypedarrayInfo(int8Array, InfoType.LENGTH)); + hilog.info(0x0000, 'Node-API', 'get_typedarray_info_byte_offset: %{public}d', + testNapi.getTypedarrayInfo(int8Array, InfoType.BYTE_OFFSET)); + // [End ark_napi_get_typed_array_info] + this.result = 'napiGetTypedArrayInfoSuccess'; + } else if (item === '12.napiCreateDataView') { + // [Start ark_napi_create_data_view] + // 使用Node-API接口进行array相关开发 napi_create_dataview + const arrayBuffer = new ArrayBuffer(16); + const dataView = testNapi.createDataView(arrayBuffer) as DataView; + hilog.info(0x0000, 'testTag', 'Test Node-API dataView:%{public}d', dataView.byteLength); + hilog.info(0x0000, 'testTag', 'Test Node-API dataView第一个数据:%{public}d', dataView.getInt8(0)); + // [End ark_napi_create_data_view] + this.result = 'napiCreateDataViewSuccess'; + } else if (item === '13.napiIsDataView') { + // [Start ark_napi_is_data_view] + // 使用Node-API接口进行array相关开发 napi_is_dataview + try { + let buffer = new ArrayBuffer(16); + let dataView = new DataView(buffer); + let data = "123"; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_dataview: %{public}s', + testNapi.isDataView(dataView)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_dataview: %{public}s', + testNapi.isDataView(data)); + // [StartExclude ark_napi_is_data_view] + this.result = 'napiIsDataViewSuccess'; + // [EndExclude ark_napi_is_data_view] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_dataview error: %{public}s', error.message); + // [StartExclude ark_napi_is_data_view] + this.result = 'napiIsDataViewFail'; + // [EndExclude ark_napi_is_data_view] + } + // [End ark_napi_is_data_view] + } else if (item === '14.napiGetDataViewInfo') { + // [Start ark_napi_get_data_view_info] + // 使用Node-API接口进行array相关开发 napi_get_dataview_info + // 创建一个ArrayBuffer + let arrayBuffer = new Int8Array([2, 5]).buffer; + // 使用arrayBuffer创建一个dataView + let dataView = new DataView(arrayBuffer); + // 定义一个枚举类型 + enum InfoType { + BYTE_LENGTH = 0, + ARRAY_BUFFER = 1, + BYTE_OFFSET = 2, + }; + // 传入DataView类型参数查询DataView的字节数 + hilog.info(0x0000, 'Node-API', 'get_dataview_info_bytelength %{public}d', + testNapi.getDataViewInfo(dataView, InfoType.BYTE_LENGTH)); + // 传入DataView类型参数查询DataView的ArrayBuffer + let arrbuff = testNapi.getDataViewInfo(dataView, InfoType.ARRAY_BUFFER) as ArrayBuffer; + // 将arraybuffer转为数组 + let arr = Array.from(new Int8Array(arrbuff)); + hilog.info(0x0000, 'Node-API', 'get_dataview_info_arraybuffer %{public}s', arr.toString()); + // 传入DataView类型参数查询DataView开始投影的数据缓冲区中的字节偏移量 + hilog.info(0x0000, 'Node-API', 'get_dataview_info_byteoffset %{public}d', + testNapi.getDataViewInfo(dataView, InfoType.BYTE_OFFSET)); + // [End ark_napi_get_data_view_info] + this.result = 'napiGetDataViewInfoSuccess'; + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + .id('List') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} + diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/NodeAPIArray.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/NodeAPIArray.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/NodeAPIArray.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/NodeAPIArray.test.ets index dd42061a08..86db0eafed --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/NodeAPIArray.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/ets/test/NodeAPIArray.test.ets @@ -1,270 +1,270 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIArrayTest() { - describe('nodeAPIArrayTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiCreateArray相关函数 - */ - it('testNodeAPIArray001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiCreateArray')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateArraySuccess')); - console.info('uitest: testNodeAPIArray001 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateArrayWithLength相关函数 - */ - it('testNodeAPIArray002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiCreateArrayWithLength')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateArrayWithLengthSuccess')); - console.info('uitest: testNodeAPIArray002 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetArrayLength相关函数 - */ - it('testNodeAPIArray003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiGetArrayLength')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetArrayLengthSuccess')); - console.info('uitest: testNodeAPIArray003 end'); - done(); - }) - - /** - * 点击按钮,调用napiIsArray相关函数 - */ - it('testNodeAPIArray004', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('4.napiIsArray')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiIsArraySuccess')); - console.info('uitest: testNodeAPIArray004 end'); - done(); - }) - - /** - * 点击按钮,调用napiSetElement相关函数 - */ - it('testNodeAPIArray005', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('5.napiSetElement')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiSetElementSuccess')); - console.info('uitest: testNodeAPIArray005 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetElement相关函数 - */ - it('testNodeAPIArray006', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('6.napiGetElement')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetElementSuccess')); - console.info('uitest: testNodeAPIArray006 end'); - done(); - }) - - /** - * 点击按钮,调用napiHasElement相关函数 - */ - it('testNodeAPIArray007', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray007 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('7.napiHasElement')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiHasElementSuccess')); - console.info('uitest: testNodeAPIArray007 end'); - done(); - }) - - /** - * 点击按钮,调用napiDeleteElement相关函数 - */ - it('testNodeAPIArray008', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray008 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('8.napiDeleteElement')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiDeleteElementSuccess')); - console.info('uitest: testNodeAPIArray008 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateTypedArray相关函数 - */ - it('testNodeAPIArray009', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray009 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('9.napiCreateTypedArray')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateUint8ArraySuccess')); - console.info('uitest: testNodeAPIArray009 end'); - done(); - }) - - /** - * 点击按钮,调用napiIsTypedArray相关函数 - */ - it('testNodeAPIArray010', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray010 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const list = await driver.findComponent(ON.id('List')) - await list.scrollToBottom(); - const text = await driver.findComponent(ON.text('10.napiIsTypedArray')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiIsTypedArraySuccess')); - console.info('uitest: testNodeAPIArray010 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetTypedArrayInfo相关函数 - */ - it('testNodeAPIArray011', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray011 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('11.napiGetTypedArrayInfo')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetTypedArrayInfoSuccess')); - console.info('uitest: testNodeAPIArray011 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateDataView相关函数 - */ - it('testNodeAPIArray012', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray012 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('12.napiCreateDataView')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateDataViewSuccess')); - console.info('uitest: testNodeAPIArray012 end'); - done(); - }) - - /** - * 点击按钮,调用napiIsDataView相关函数 - */ - it('testNodeAPIArray013', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray013 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('13.napiIsDataView')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiIsDataViewSuccess')); - console.info('uitest: testNodeAPIArray013 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetDataViewInfo相关函数 - */ - it('testNodeAPIArray014', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray014 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('14.napiGetDataViewInfo')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetDataViewInfoSuccess')); - console.info('uitest: testNodeAPIArray014 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIArrayTest() { + describe('nodeAPIArrayTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiCreateArray相关函数 + */ + it('testNodeAPIArray001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiCreateArray')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateArraySuccess')); + console.info('uitest: testNodeAPIArray001 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateArrayWithLength相关函数 + */ + it('testNodeAPIArray002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiCreateArrayWithLength')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateArrayWithLengthSuccess')); + console.info('uitest: testNodeAPIArray002 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetArrayLength相关函数 + */ + it('testNodeAPIArray003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiGetArrayLength')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetArrayLengthSuccess')); + console.info('uitest: testNodeAPIArray003 end'); + done(); + }) + + /** + * 点击按钮,调用napiIsArray相关函数 + */ + it('testNodeAPIArray004', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('4.napiIsArray')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiIsArraySuccess')); + console.info('uitest: testNodeAPIArray004 end'); + done(); + }) + + /** + * 点击按钮,调用napiSetElement相关函数 + */ + it('testNodeAPIArray005', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('5.napiSetElement')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiSetElementSuccess')); + console.info('uitest: testNodeAPIArray005 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetElement相关函数 + */ + it('testNodeAPIArray006', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('6.napiGetElement')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetElementSuccess')); + console.info('uitest: testNodeAPIArray006 end'); + done(); + }) + + /** + * 点击按钮,调用napiHasElement相关函数 + */ + it('testNodeAPIArray007', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray007 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('7.napiHasElement')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiHasElementSuccess')); + console.info('uitest: testNodeAPIArray007 end'); + done(); + }) + + /** + * 点击按钮,调用napiDeleteElement相关函数 + */ + it('testNodeAPIArray008', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray008 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('8.napiDeleteElement')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiDeleteElementSuccess')); + console.info('uitest: testNodeAPIArray008 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateTypedArray相关函数 + */ + it('testNodeAPIArray009', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray009 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('9.napiCreateTypedArray')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateUint8ArraySuccess')); + console.info('uitest: testNodeAPIArray009 end'); + done(); + }) + + /** + * 点击按钮,调用napiIsTypedArray相关函数 + */ + it('testNodeAPIArray010', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray010 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const list = await driver.findComponent(ON.id('List')) + await list.scrollToBottom(); + const text = await driver.findComponent(ON.text('10.napiIsTypedArray')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiIsTypedArraySuccess')); + console.info('uitest: testNodeAPIArray010 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetTypedArrayInfo相关函数 + */ + it('testNodeAPIArray011', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray011 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('11.napiGetTypedArrayInfo')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetTypedArrayInfoSuccess')); + console.info('uitest: testNodeAPIArray011 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateDataView相关函数 + */ + it('testNodeAPIArray012', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray012 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('12.napiCreateDataView')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateDataViewSuccess')); + console.info('uitest: testNodeAPIArray012 end'); + done(); + }) + + /** + * 点击按钮,调用napiIsDataView相关函数 + */ + it('testNodeAPIArray013', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray013 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('13.napiIsDataView')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiIsDataViewSuccess')); + console.info('uitest: testNodeAPIArray013 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetDataViewInfo相关函数 + */ + it('testNodeAPIArray014', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray014 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('14.napiGetDataViewInfo')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetDataViewInfoSuccess')); + console.info('uitest: testNodeAPIArray014 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/ohosTest.md new file mode 100644 index 0000000000..427fd83742 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/ohosTest.md @@ -0,0 +1,21 @@ +# 使用Node-API进行array相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------ | ------------ | ----------------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 createArray | 位于主页 | 点击文本为1.napiCreateArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateArraySuccess | Pass | +| ArkTS端成功调用native侧接口createArrayWithLength | 位于主页 | 点击文本为2.napiCreateArrayWithLength的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateArrayWithLengthSuccess | Pass | +| ArkTS端成功调用native侧接口getArrayLength | 位于主页 | 点击文本为3.napiGetArrayLength的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetArrayLengthSuccess | Pass | +| ArkTS端成功调用native侧接口isArray | 位于主页 | 点击文本为4.napiIsArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsArraySuccess | Pass | +| ArkTS端成功调用native侧接口napiSetElement | 位于主页 | 点击文本为5.napiSetElement的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiSetElementSuccess | Pass | +| ArkTS端成功调用native侧接口napiGetElement | 位于主页 | 点击文本为6.napiGetElement的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetElementSuccess | Pass | +| ArkTS端成功调用native侧接口napiHasElement | 位于主页 | 点击文本为7.napiHasElement的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiHasElementSuccess | Pass | +| ArkTS端成功调用native侧接口napiDeleteElement | 位于主页 | 点击文本为8.napiDeleteElement的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDeleteElementSuccess | Pass | +| ArkTS端成功调用native侧接口createTypedArray | 位于主页 | 点击文本为9.napiCreateTypedArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateUint8ArraySuccess | Pass | +| ArkTS端成功调用native侧接口isTypedarray | 位于主页 | 点击文本为10.napiIsTypedArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsTypedArraySuccess | Pass | +| ArkTS端成功调用native侧接口getTypedarrayInfo | 位于主页 | 点击文本为11.napiGetTypedArrayInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetTypedArrayInfoSuccess | Pass | +| ArkTS端成功调用native侧接口createDataView | 位于主页 | 点击文本为12.napiCreateDataView的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateDataViewSuccess | Pass | +| ArkTS端成功调用native侧接口isDataView | 位于主页 | 点击文本为13.napiIsDataView的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsDataViewSuccess | Pass | +| ArkTS端成功调用native侧接口getDataViewInfo | 位于主页 | 点击文本为14.napiGetDataViewInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetDataViewInfoSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/screenshots/NodeAPIArray1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/screenshots/NodeAPIArray1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/screenshots/NodeAPIArray1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/screenshots/NodeAPIArray1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/screenshots/NodeAPIArray2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/screenshots/NodeAPIArray2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/screenshots/NodeAPIArray2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArray/screenshots/NodeAPIArray2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/.gitignore rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/.gitignore diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/app.json5 new file mode 100644 index 0000000000..3c06c351a9 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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.nodeapiarraybuffer", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..ecb3d6a55f --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIArraybuffer" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/README.md new file mode 100644 index 0000000000..8194990926 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/README.md @@ -0,0 +1,75 @@ +# ArkTS使用Node-API接口进行ArrayBuffer相关开发 + +### 介绍 + +ArrayBuffer是ArkTS中的一种数据类型,用于表示通用的、固定长度的原始二进制数据缓冲区。它提供了一种在ArkTS中有效地表示和操作原始二进制数据的方式 + +该工程主要展示了使用Node-API接口进行检查值是否为ArrayBuffer、获取给定的ArrayBuffer对象信息、分离ArrayBuffer信息、判定是否分离ArrayBuffer以及创建指定长度的ArrayBuffer对象,其中展示的代码详细描述可查如下链接。 + +- [使用Node-API接口进行ArrayBuffer相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-arraybuffer.md) + +### 效果预览 + +| 首页 | 执行效果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIArraybuffer.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API接口进行Arraybuffer相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIArraybuffer.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/code-linter.json5 rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/code-linter.json5 diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6286d6e380 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPI_arraybuffer) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..3ce1932066 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,157 @@ +/* + * 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" + +// [Start napi_is_arraybuffer] +// napi_is_arraybuffer +static napi_value IsArrayBuffer(napi_env env, napi_callback_info info) +{ + // 接受一个入参 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 调用napi_is_arraybuffer接口判断给定入参是否为ArrayBuffer数据 + bool result = false; + napi_status status = napi_is_arraybuffer(env, args[0], &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_is_arraybuffer fail"); + return nullptr; + } + // 将结果转成napi_value类型返回 + napi_value returnValue = nullptr; + napi_get_boolean(env, result, &returnValue); + return returnValue; +} +// [End napi_is_arraybuffer] + +// [Start napi_get_arraybuffer_info] +// napi_get_arraybuffer_info +static napi_value GetArraybufferInfo(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 检查参数是否为ArrayBuffer + bool isArraybuffer = false; + napi_is_arraybuffer(env, args[0], &isArraybuffer); + if (!isArraybuffer) { + napi_throw_type_error(env, nullptr, "Argument must be an ArrayBuffer"); + return nullptr; + } + + void *data = nullptr; + size_t byteLength = 0; + // 获取ArrayBuffer的底层数据缓冲区和长度 + napi_status status = napi_get_arraybuffer_info(env, args[0], &data, &byteLength); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to get ArrayBuffer info"); + return nullptr; + } + // 创建结果对象 + napi_value result = nullptr; + napi_create_object(env, &result); + // 创建数据缓冲区的字节长度属性 + napi_value byteLengthValue = nullptr; + napi_create_uint32(env, byteLength, &byteLengthValue); + napi_set_named_property(env, result, "byteLength", byteLengthValue); + napi_value bufferData; + napi_create_arraybuffer(env, byteLength, &data, &bufferData); + napi_set_named_property(env, result, "buffer", bufferData); + return result; +} +// [End napi_get_arraybuffer_info] + +// [Start napi_detach_arraybuffer] +// napi_detach_arraybuffer +static napi_value DetachedArraybuffer(napi_env env, napi_callback_info info) +{ + // 调用napi_detach_arraybuffer接口分离给定ArrayBuffer的底层数据 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + napi_value arrayBuffer = args[0]; + napi_detach_arraybuffer(env, arrayBuffer); + // 将分离后的arraybuffer传出去 + return arrayBuffer; +} + +// napi_is_detach_arraybuffer +static napi_value IsDetachedArraybuffer(napi_env env, napi_callback_info info) +{ + // 调用napi_is_detached_arraybuffer判断给定的arraybuffer是否已被分离 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + napi_value arrayBuffer = args[0]; + bool result = false; + napi_is_detached_arraybuffer(env, arrayBuffer, &result); + // 将返回值通过napi_get_boolean接口转成napi_value传出去做打印 + napi_value returnValue; + napi_get_boolean(env, result, &returnValue); + return returnValue; +} +// [End napi_detach_arraybuffer] + +// [Start napi_create_arraybuffer] +// napi_create_arraybuffer +static napi_value CreateArraybuffer(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value argv[1] = {nullptr}; + napi_value result = nullptr; + // 解析传递的参数 + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + int32_t value; + size_t length; + // 将ArkTS侧传递的参数转换为size_t类型,作为napi_create_arraybuffer的参数 + napi_get_value_int32(env, argv[0], &value); + length = size_t(value); + void *data; + // 创建一个新的ArrayBuffer + napi_create_arraybuffer(env, length, &data, &result); + if (data != nullptr) { + // 确保安全后才能使用data进行操作 + } + // 返回ArrayBuffer + return result; +} +// [End napi_create_arraybuffer] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"isArrayBuffer", nullptr, IsArrayBuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getArraybufferInfo", nullptr, GetArraybufferInfo, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"detachedArraybuffer", nullptr, DetachedArraybuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"isDetachedArraybuffer", nullptr, IsDetachedArraybuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createArraybuffer", nullptr, CreateArraybuffer, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..876dc91404 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/Index.d.ts @@ -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. + */ + +// [Start napi_is_arraybuffer_api] +export const isArrayBuffer: (arrayBuffer: T) => boolean | void; // napi_is_arraybuffer +// [End napi_is_arraybuffer_api] + +// [Start napi_get_arraybuffer_info_api] +export class ArrayBufferInfo { + byteLength: number; + buffer: Object; +} + +export const getArraybufferInfo: (data: ArrayBuffer) => ArrayBufferInfo | void; // napi_get_arraybuffer_info +// [End napi_get_arraybuffer_info_api] + +// [Start napi_detach_arraybuffer_api] +export const detachedArraybuffer: (buffer: ArrayBuffer) => ArrayBuffer; // napi_detach_arraybuffer + +export const isDetachedArraybuffer: (arrarBeffer: ArrayBuffer) => boolean; //napi_is_detached_arraybuffer +// [End napi_detach_arraybuffer_api] + +// [Start napi_create_arraybuffer_api] +export const createArraybuffer: (size: number) => ArrayBuffer; // napi_create_arraybuffer +// [End napi_create_arraybuffer_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..46aaf9a998 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,118 @@ +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiIsArraybuffer', + '2.napiGetArraybufferInfo', + '3.napiDetachArraybuffer', + '4.napiCreateArraybuffer' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(25) + .fontWeight(FontWeight.Bold) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiIsArraybuffer') { + // [Start ark_napi_is_arraybuffer] + // napi_is_arraybuffer + try { + let value = new ArrayBuffer(1); + let data = "123"; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_arraybuffer: %{public}s', + testNapi.isArrayBuffer(value)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_arraybuffer: %{public}s', + testNapi.isArrayBuffer(data)); + // [StartExclude ark_napi_is_arraybuffer] + this.result = 'napiIsArraybufferSuccess'; + // [EndExclude ark_napi_is_arraybuffer] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_arraybuffer error: %{public}s', + error.message); + // [StartExclude ark_napi_is_arraybuffer] + this.result = 'napiIsArraybufferFail'; + // [EndExclude ark_napi_is_arraybuffer] + } + // [End ark_napi_is_arraybuffer] + } else if (item === '2.napiGetArraybufferInfo') { + // [Start ark_napi_get_arraybuffer_info + // napi_get_arraybuffer_info + const buffer = new ArrayBuffer(10); + hilog.info(0x0000, 'testTag', 'Test Node-API get_arraybuffer_info:%{public}s ', + JSON.stringify(testNapi.getArraybufferInfo(buffer))); + // [End ark_napi_get_arraybuffer_info] + this.result = 'napiGetArraybufferInfoSuccess'; + } else if (item === '3.napiDetachArraybuffer') { + // [Start ark_napi_detach_arraybuffer] + // napi_detach_arraybuffer and napi_is_detached_arraybuffer + try { + const bufferArray = new ArrayBuffer(8); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_detached_arraybuffer one: %{public}s', + testNapi.isDetachedArraybuffer(bufferArray)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_detached_arraybuffer two: %{public}s ', + testNapi.isDetachedArraybuffer(testNapi.detachedArraybuffer(bufferArray))); + // [StartExclude ark_napi_detach_arraybuffer] + this.result = 'napiDetachArraybufferSuccess'; + // [EndExclude ark_napi_detach_arraybuffer] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_detached_arraybuffer error: %{public}s', + error.message); + // [StartExclude ark_napi_detach_arraybuffer] + this.result = 'napiDetachArraybufferFail'; + // [EndExclude ark_napi_detach_arraybuffer] + } + // [End ark_napi_detach_arraybuffer] + } else if (item === '4.napiCreateArraybuffer') { + // [Start ark_napi_create_arraybuffer] + // napi_create_arraybuffer + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_arraybuffer:%{public}s', + testNapi.createArraybuffer(10).toString()); + // [End ark_napi_create_arraybuffer] + this.result = 'napiCreateArraybufferSuccess'; + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/NodeAPIArraybuffer.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/NodeAPIArraybuffer.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/NodeAPIArraybuffer.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/NodeAPIArraybuffer.test.ets index b60c400c9a..690d990b49 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/NodeAPIArraybuffer.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/ets/test/NodeAPIArraybuffer.test.ets @@ -1,103 +1,103 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIArraybufferTest() { - describe('nodeAPIArraybufferTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiIsArraybuffer相关函数 - */ - it('testNodeAPIArraybuffer001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArraybuffer001 begin'); - const driver = Driver.create(); - const text = await driver.findComponent(ON.text('1.napiIsArraybuffer')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiIsArraybufferSuccess')); - console.info('uitest: testNodeAPIArraybuffer001 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetArraybufferInfo相关函数 - */ - it('testNodeAPIArraybuffer002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArraybuffer002 begin'); - const driver = Driver.create(); - const text = await driver.findComponent(ON.text('2.napiGetArraybufferInfo')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetArraybufferInfoSuccess')); - console.info('uitest: testNodeAPIArraybuffer002 end'); - done(); - }) - - /** - * 点击按钮,调用napiDetachArraybuffer相关函数 - */ - it('testNodeAPIArraybuffer003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArraybuffer003 begin'); - const driver = Driver.create(); - const text = await driver.findComponent(ON.text('3.napiDetachArraybuffer')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiDetachArraybufferSuccess')); - console.info('uitest: testNodeAPIArraybuffer003 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateArraybuffer相关函数 - */ - it('testNodeAPIArraybuffer004', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArraybuffer004 begin'); - const driver = Driver.create(); - const text = await driver.findComponent(ON.text('4.napiCreateArraybuffer')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateArraybufferSuccess')); - console.info('uitest: testNodeAPIArraybuffer004 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIArraybufferTest() { + describe('nodeAPIArraybufferTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiIsArraybuffer相关函数 + */ + it('testNodeAPIArraybuffer001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArraybuffer001 begin'); + const driver = Driver.create(); + const text = await driver.findComponent(ON.text('1.napiIsArraybuffer')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiIsArraybufferSuccess')); + console.info('uitest: testNodeAPIArraybuffer001 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetArraybufferInfo相关函数 + */ + it('testNodeAPIArraybuffer002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArraybuffer002 begin'); + const driver = Driver.create(); + const text = await driver.findComponent(ON.text('2.napiGetArraybufferInfo')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetArraybufferInfoSuccess')); + console.info('uitest: testNodeAPIArraybuffer002 end'); + done(); + }) + + /** + * 点击按钮,调用napiDetachArraybuffer相关函数 + */ + it('testNodeAPIArraybuffer003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArraybuffer003 begin'); + const driver = Driver.create(); + const text = await driver.findComponent(ON.text('3.napiDetachArraybuffer')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiDetachArraybufferSuccess')); + console.info('uitest: testNodeAPIArraybuffer003 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateArraybuffer相关函数 + */ + it('testNodeAPIArraybuffer004', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArraybuffer004 begin'); + const driver = Driver.create(); + const text = await driver.findComponent(ON.text('4.napiCreateArraybuffer')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateArraybufferSuccess')); + console.info('uitest: testNodeAPIArraybuffer004 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/ohosTest.md new file mode 100644 index 0000000000..acc3a88253 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/ohosTest.md @@ -0,0 +1,11 @@ +# 使用Node-API进行arraybuffer相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------ | ------------ | -------------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口isArrayBuffer | 位于主页 | 点击文本为1.napiIsArraybuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsArraybufferSuccess | Pass | +| ArkTS端成功调用native侧接口getArraybufferInfo | 位于主页 | 点击文本为2.napiGetArraybufferInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetArraybufferInfoSuccess | Pass | +| ArkTS端成功调用native侧接口isDetachedArraybuffer | 位于主页 | 点击文本为3.napiDetachArraybuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDetachArraybufferSuccess | Pass | +| ArkTS端成功调用native侧接口createArraybuffer | 位于主页 | 点击文本为4.napiCreateArraybuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateArraybufferSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/screenshots/NodeAPIArraybuffer1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/screenshots/NodeAPIArraybuffer1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/screenshots/NodeAPIArraybuffer1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/screenshots/NodeAPIArraybuffer1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/screenshots/NodeAPIArraybuffer2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/screenshots/NodeAPIArraybuffer2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/screenshots/NodeAPIArraybuffer2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIArraybuffer/screenshots/NodeAPIArraybuffer2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/.gitignore rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/.gitignore diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/app.json5 new file mode 100644 index 0000000000..fb7248cc0f --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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.nodeapibasicdatatypes", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..35e276d0d7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIBasicDataTypes" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/README.md new file mode 100644 index 0000000000..0e53ee9d1b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/README.md @@ -0,0 +1,75 @@ +# ArkTS使用Node-API进行basic_data_types相关开发 + +### 介绍 + +ArkTS的Number类型是一个双精度64位二进制格式IEEE 754值。只有在-2^53+1到2^53-1范围内(闭区间)的整数才能在不丢失精度的情况下被表示,在超过该取值范围的情况下,需要使用BigInt对应的NPI接口来处理更大范围的整数。 + +该工程主要展示了使用Node-API接口将number类型转换为uint32、int32、int64、double以及前述四种类型转换回number类型,其中展示的代码详细描述可查如下链接。 + +- [使用Node-API进行basic_data_types相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-basic-data-types.md) + +### 效果预览 + +| 首页 | 执行效果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIBasicDataTypes.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API接口进行basic_data_types相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIBasicDataTypes.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/code-linter.json5 rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/code-linter.json5 diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..05a6c8b00b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIBasicDataTypes) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..fe51be316c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,204 @@ +/* + * 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" + +// [Start napi_get_value_uint32] +// napi_get_value_uint32 +static napi_value GetValueUint32(napi_env env, napi_callback_info info) +{ + // 获取传入的数字类型参数 + size_t argc = 1; + napi_value argv[1] = {nullptr}; + // 解析传入的参数 + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + uint32_t number = 0; + // 获取传入参数的值中的无符号32位整数 + napi_status status = napi_get_value_uint32(env, argv[0], &number); + // 如果传递的参数不是数字,将会返回napi_number_expected,设置函数返回nullptr + if (status == napi_number_expected) { + return nullptr; + } + napi_value result = nullptr; + // 创建传入参数无符号32位整数,并传出 + napi_create_uint32(env, number, &result); + return result; +} +// [End napi_get_value_uint32] + +// [Start napi_get_value_int32] +// napi_get_value_int32 +static napi_value GetValueInt32(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + int32_t result32 = 0; + // 解析传递的参数 + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 将前端传过来的参数转为Node-API模块的int32类型 + napi_status status = napi_get_value_int32(env, args[0], &result32); + // 如果传递的参数不是数字napi_get_value_int32接口将会返回napi_number_expected,设置函数返回nullptr + if (status == napi_number_expected) { + return nullptr; + } + // 调用napi_create_int32接口将int32类型的数据转为napi_value返回 + napi_value napiResult32 = nullptr; + napi_create_int32(env, result32, &napiResult32); + return napiResult32; +} +// [End napi_get_value_int32] + +// [Start napi_get_value_int64] +// napi_get_value_int64 +static napi_value GetValueInt64(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + int64_t result64 = 0; + // 解析传递的值 + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 将前端传过来的参数转为Node-API模块的int64类型 + napi_status status = napi_get_value_int64(env, args[0], &result64); + // 如果传递的参数不是数字, 返回napi_number_expected. + if (status == napi_number_expected) { + return nullptr; + } + // 调用napi_create_int64接口将int64类型的数据转为napi_value返回前端 + napi_value napiResult64 = nullptr; + napi_create_int64(env, result64, &napiResult64); + return napiResult64; +} +// [End napi_get_value_int64] + +// [Start napi_get_value_double] +// napi_get_value_double +static napi_value GetDouble(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + double value = 0; + napi_status status = napi_get_value_double(env, args[0], &value); + // 传入非数字接口返回napi_number_expected + if (status == napi_number_expected) { + return nullptr; + } + napi_value result = nullptr; + napi_create_double(env, value, &result); + return result; +} +// [End napi_get_value_double] + +// [Start napi_create_int32] +// napi_create_int32 +static napi_value CreateInt32(napi_env env, napi_callback_info info) +{ + // int32_t是有符号的32位整数类型,表示带有符号的整数,它的范围是从-2^31到2^31 - 1,也就是-2147483648到2147483647 + // 要表示的整数值 + int32_t value = -26; + // 创建ArkTS中的int32数字 + napi_value result = nullptr; + napi_status status = napi_create_int32(env, value, &result); + if (status != napi_ok) { + // 处理错误 + napi_throw_error(env, nullptr, "Failed to create int32 value"); + } + return result; +} +// [End napi_create_int32] + +// [Start napi_create_uint32] +// napi_create_uint32 +static napi_value CreateUInt32(napi_env env, napi_callback_info info) +{ + // 如果使用 + // uint32_t类型来定义-26,会发生溢出,溢出时会对结果进行模运算,将负数的二进制补码转换为相应的正数。-26输出4294967270 + // uint32_t是无符号的32位整数类型,只能表示非负整数。它的范围是从0到2 ^32 - 1,即0到4294967295 + // 要表示的整数值 + uint32_t value = 26; + // 创建ArkTS中的uint32数字 + napi_value result = nullptr; + napi_status status = napi_create_uint32(env, value, &result); + if (status != napi_ok) { + // 处理错误 + napi_throw_error(env, nullptr, "Failed to create uint32 value"); + } + return result; +} +// [End napi_create_uint32] + +// [Start napi_create_int64] +// napi_create_int64 +static napi_value CreateInt64(napi_env env, napi_callback_info info) +{ + // int64是有符号的64位整数类型,可以表示范围从-2^63到2^63 - 1的整数,即 -9223372036854775808到9223372036854775807 + // 要表示的整数值 + int64_t value = 2147483648; + // 创建ArkTS中的int64数字 + napi_value result = nullptr; + napi_status status = napi_create_int64(env, value, &result); + if (status != napi_ok) { + // 处理错误 + napi_throw_error(env, nullptr, "Failed to create int64 value"); + } + return result; +} +// [End napi_create_int64] + +// [Start napi_create_double] +// napi_create_double +static napi_value CreateDouble(napi_env env, napi_callback_info info) +{ + double value = 1.234; + // 创建ArkTS中的double数字 + napi_value result = nullptr; + napi_status status = napi_create_double(env, value, &result); + if (status != napi_ok) { + // 处理错误 + napi_throw_error(env, nullptr, "Failed to create double value"); + } + return result; +} +// [End napi_create_double] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"getValueUint32", nullptr, GetValueUint32, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getValueInt32", nullptr, GetValueInt32, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getValueInt64", nullptr, GetValueInt64, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getDouble", nullptr, GetDouble, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createInt32", nullptr, CreateInt32, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createUInt32", nullptr, CreateUInt32, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createInt64", nullptr, CreateInt64, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createDouble", nullptr, CreateDouble, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..a2d502bc37 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_get_value_uint32_api] +export const getValueUint32: (data: T) => number | void; // napi_get_value_uint32 +// [End napi_get_value_uint32_api] + +// [Start napi_get_value_int32_api] +export const getValueInt32: (value: number | string) => number | void; // napi_get_value_int32 +// [End napi_get_value_int32_api] + +// [Start napi_get_value_int64_api] +export const getValueInt64: (value: number | string) => number | void; // napi_get_value_int64 +// [End napi_get_value_int64_api] + +// [Start napi_get_value_double_api] +export const getDouble: (value: number | string) => number | void; // napi_get_value_double +// [End napi_get_value_double_api] + +// [Start napi_create_int32_api] +export const createInt32: () => number; // napi_create_int32 +// [End napi_create_int32_api] + +// [Start napi_create_uint32_api] +export const createUInt32: () => number; // napi_create_uint32 +// [End napi_create_uint32_api] + +// [Start napi_create_int64_api] +export const createInt64: () => number; // napi_create_int64 +// [End napi_create_int64_api] + +// [Start napi_create_double_api] +export const createDouble: () => number; // napi_create_double +// [End napi_create_double_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..a3e91ea528 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,152 @@ +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiGetValueUint32', + '2.napiGetValueInt32', + '3.napiGetValueInt64', + '4.napiGetValueDouble', + '5.napiCreateInt32', + '6.napiCreateUint32', + '7.napiCreateInt64', + '8.napiCreateDouble' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(25) + .fontWeight(FontWeight.Bold) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiGetValueUint32') { + // [Start ark_napi_get_value_uint32] + // napi_get_value_uint32 + let value = testNapi.getValueUint32(111111111111); + let data = testNapi.getValueUint32("sssss"); + hilog.info(0x0000, 'Node-API', 'get_value_uint32_number %{public}d', value); + // 传入非数字"sssss"时函数返回undefined + hilog.info(0x0000, 'Node-API', 'get_value_uint32_number %{public}s', data); + // 传入uint32范围内的数字100时函数返回原数字 + hilog.info(0x0000, 'Node-API', 'get_value_uint32_number %{public}d', + testNapi.getValueUint32(100)); + // [End ark_napi_get_value_uint32] + this.result = 'napiGetValueUint32Success'; + } else if (item === '2.napiGetValueInt32') { + // [Start ark_napi_get_value_int32] + // napi_get_value_int32 + // 传入非数字“ss”时函数返回undefined + hilog.info(0x0000, 'Node-API', 'get_value_int32_not_number %{public}s', testNapi.getValueInt32('ss')); + // 传入int32范围内的数字100时函数返回原数字 + hilog.info(0x0000, 'Node-API', 'get_value_int32_number %{public}d', testNapi.getValueInt32(100)); + // 传入68719476735,此数字的二进制为111111111111111111111111111111111111,在int32类型中此二进制代表数字-1 + hilog.info(0x0000, 'Node-API', 'get_value_int32_oversize %{public}d', + testNapi.getValueInt32(68719476735)); + // 大于2的31次-1的数字且不是二进制为111111111111111111111111111111111111这样的在int32中有特殊含义的数字也会溢出,导致数值发生改变,返回值按后32位二进制编码解码 + hilog.info(0x0000, 'Node-API', 'get_value_int32_oversize %{public}d', + testNapi.getValueInt32(687194767355)); + // 传入NAN(not a number)、+Infinity(正无穷)或-Infinity(负无穷),会返回数字0 + hilog.info(0x0000, 'Node-API', 'get_value_int32_number_NAN %{public}d', testNapi.getValueInt32(NaN)); + hilog.info(0x0000, 'Node-API', 'get_value_int32_number_+Infinity %{public}d', + testNapi.getValueInt32(+Infinity)); + hilog.info(0x0000, 'Node-API', 'get_value_int32_number_-Infinity %{public}d', + testNapi.getValueInt32(-Infinity)); + // [End ark_napi_get_value_int32] + this.result = 'napiGetValueInt32Success'; + } else if (item === '3.napiGetValueInt64') { + // [Start ark_napi_get_value_int64] + // napi_get_value_int64 + // 输入不超过int64表示范围的数字,会返回该数字 + hilog.info(0x0000, 'Node-API', 'get_value_int64_number %{public}d', testNapi.getValueInt64(80)); + // 传入非数字“ss”,获得函数返回的值应为undefined + hilog.info(0x0000, 'Node-API', 'get_value_int64_not_number %{public}s', + testNapi.getValueInt64('sAs')); + // 输入超过int64表示范围的数字会溢出,失去精度,导致输入数字与返回数字不相等 + hilog.info(0x0000, 'Node-API', 'get_value_int64_number_oversize %{public}d', + testNapi.getValueInt64(9223372036854775809)); + // 传入NAN(not a number)、+Infinity(正无穷)或-Infinity(负无穷)接口返回数字0 + hilog.info(0x0000, 'Node-API', 'get_value_int64_number_NAN %{public}d', testNapi.getValueInt64(NaN)); + hilog.info(0x0000, 'Node-API', 'get_value_int64_number_+Infinity %{public}d', + testNapi.getValueInt64(+Infinity)); + hilog.info(0x0000, 'Node-API', 'get_value_int64_number_-Infinity %{public}d', + testNapi.getValueInt64(-Infinity)); + // [End ark_napi_get_value_int64] + this.result = 'napiGetValueInt64Success'; + } else if (item === '4.napiGetValueDouble') { + // [Start ark_napi_get_value_double] + // napi_get_value_double + // 输入数字,返回该数字 + hilog.info(0x0000, 'Node-API', 'get_value_double_number %{public}d', testNapi.getDouble(80.885)); + // 传入非数字,获得函数返回的值应为undefined + hilog.info(0x0000, 'Node-API', 'get_value_double_not_number %{public}s', testNapi.getDouble('sAs')); + // [End ark_napi_get_value_double] + this.result = 'napiGetValueDoubleSuccess'; + } else if (item === '5.napiCreateInt32') { + // [Start ark_napi_create_int32] + // napi_create_int32 + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_int32:' + testNapi.createInt32()); + // [End ark_napi_create_int32] + this.result = 'napiCreateInt32Success'; + } else if (item === '6.napiCreateUint32') { + // [Start ark_napi_create_uint32] + // napi_create_uint32 + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_uint32: ' + testNapi.createUInt32()); + // [End ark_napi_create_uint32] + this.result = 'napiCreateUint32Success'; + } else if (item === '7.napiCreateInt64') { + // [Start ark_napi_create_int64] + // napi_create_int64 + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_int64: ' + testNapi.createInt64()); + // [End ark_napi_create_int64] + this.result = 'napiCreateInt64Success'; + } else if (item === '8.napiCreateDouble') { + // [Start ark_napi_create_double] + // napi_create_double + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_double: ' + testNapi.createDouble()); + // [End ark_napi_create_double] + this.result = 'napiCreateDoubleSuccess'; + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/NodeAPIBasicDataTypes.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/NodeAPIBasicDataTypes.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/NodeAPIBasicDataTypes.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/NodeAPIBasicDataTypes.test.ets index d975c99e53..ba4c97320d --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/NodeAPIBasicDataTypes.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/ets/test/NodeAPIBasicDataTypes.test.ets @@ -1,172 +1,172 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIBasicDataTypesTest() { - describe('nodeAPIBasicDataTypesTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiGetValueUint32相关函数 - */ - it('testNodeAPIBasicDataTypes001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBasicDataTypes001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiGetValueUint32')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetValueUint32Success')); - console.info('uitest: testNodeAPIBasicDataTypes001 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetValueInt32相关函数 - */ - it('testNodeAPIBasicDataTypes002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBasicDataTypes002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiGetValueInt32')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetValueInt32Success')); - console.info('uitest: testNodeAPIBasicDataTypes002 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetValueInt64相关函数 - */ - it('testNodeAPIBasicDataTypes003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBasicDataTypes003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiGetValueInt64')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetValueInt64Success')); - console.info('uitest: testNodeAPIBasicDataTypes003 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetValueDouble相关函数 - */ - it('testNodeAPIBasicDataTypes004', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBasicDataTypes004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('4.napiGetValueDouble')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetValueDoubleSuccess')); - console.info('uitest: testNodeAPIBasicDataTypes004 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateInt32相关函数 - */ - it('testNodeAPIBasicDataTypes005', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBasicDataTypes005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('5.napiCreateInt32')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateInt32Success')); - console.info('uitest: testNodeAPIBasicDataTypes005 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateUint32相关函数 - */ - it('testNodeAPIBasicDataTypes006', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBasicDataTypes006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('6.napiCreateUint32')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateUint32Success')); - console.info('uitest: testNodeAPIBasicDataTypes006 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateInt64相关函数 - */ - it('testNodeAPIBasicDataTypes007', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBasicDataTypes007 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('7.napiCreateInt64')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateInt64Success')); - console.info('uitest: testNodeAPIBasicDataTypes007 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateDouble相关函数 - */ - it('testNodeAPIBasicDataTypes008', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBasicDataTypes008 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('8.napiCreateDouble')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateDoubleSuccess')); - console.info('uitest: testNodeAPIBasicDataTypes008 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIBasicDataTypesTest() { + describe('nodeAPIBasicDataTypesTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiGetValueUint32相关函数 + */ + it('testNodeAPIBasicDataTypes001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBasicDataTypes001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiGetValueUint32')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetValueUint32Success')); + console.info('uitest: testNodeAPIBasicDataTypes001 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetValueInt32相关函数 + */ + it('testNodeAPIBasicDataTypes002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBasicDataTypes002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiGetValueInt32')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetValueInt32Success')); + console.info('uitest: testNodeAPIBasicDataTypes002 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetValueInt64相关函数 + */ + it('testNodeAPIBasicDataTypes003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBasicDataTypes003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiGetValueInt64')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetValueInt64Success')); + console.info('uitest: testNodeAPIBasicDataTypes003 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetValueDouble相关函数 + */ + it('testNodeAPIBasicDataTypes004', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBasicDataTypes004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('4.napiGetValueDouble')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetValueDoubleSuccess')); + console.info('uitest: testNodeAPIBasicDataTypes004 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateInt32相关函数 + */ + it('testNodeAPIBasicDataTypes005', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBasicDataTypes005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('5.napiCreateInt32')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateInt32Success')); + console.info('uitest: testNodeAPIBasicDataTypes005 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateUint32相关函数 + */ + it('testNodeAPIBasicDataTypes006', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBasicDataTypes006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('6.napiCreateUint32')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateUint32Success')); + console.info('uitest: testNodeAPIBasicDataTypes006 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateInt64相关函数 + */ + it('testNodeAPIBasicDataTypes007', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBasicDataTypes007 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('7.napiCreateInt64')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateInt64Success')); + console.info('uitest: testNodeAPIBasicDataTypes007 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateDouble相关函数 + */ + it('testNodeAPIBasicDataTypes008', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBasicDataTypes008 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('8.napiCreateDouble')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateDoubleSuccess')); + console.info('uitest: testNodeAPIBasicDataTypes008 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/ohosTest.md new file mode 100644 index 0000000000..8f2b1c917e --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/ohosTest.md @@ -0,0 +1,15 @@ +# 使用Node-API进行basic_data_types相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ----------------------------------------- | ------------ | ---------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口getValueUint32 | 位于主页 | 点击文本为1.napiGetValueUint32的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueUint32Success | Pass | +| ArkTS端成功调用native侧接口getValueInt32 | 位于主页 | 点击文本为2.napiGetValueInt32的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueInt32Success | Pass | +| ArkTS端成功调用native侧接口getValueInt64 | 位于主页 | 点击文本为3.napiGetValueInt64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueInt64Success | Pass | +| ArkTS端成功调用native侧接口getDouble | 位于主页 | 点击文本为4.napiGetValueDouble的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueDoubleSuccess | Pass | +| ArkTS端成功调用native侧接口createInt32 | 位于主页 | 点击文本为5.napiCreateInt32的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateInt32Success | Pass | +| ArkTS端成功调用native侧接口createUInt32 | 位于主页 | 点击文本为6.napiCreateUint32的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateUint32Success | Pass | +| ArkTS端成功调用native侧接口createInt64 | 位于主页 | 点击文本为7.napiCreateInt64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateInt64Success | Pass | +| ArkTS端成功调用native侧接口createDouble | 位于主页 | 点击文本为8.napiCreateDouble的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateDoubleSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/screenshots/NodeAPIBasicDataTypes1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/screenshots/NodeAPIBasicDataTypes1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/screenshots/NodeAPIBasicDataTypes1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/screenshots/NodeAPIBasicDataTypes1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/screenshots/NodeAPIBasicDataTypes2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/screenshots/NodeAPIBasicDataTypes2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/screenshots/NodeAPIBasicDataTypes2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/screenshots/NodeAPIBasicDataTypes2.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/.gitignore rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/.gitignore diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/app.json5 new file mode 100644 index 0000000000..7ed0906f6a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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.nodeapibigint", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..deea143082 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIBigint" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/README.md new file mode 100644 index 0000000000..e1c04cfd44 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/README.md @@ -0,0 +1,75 @@ +# ArkTS使用Node-API进行bigint相关开发 + +### 介绍 + +BigInt是ArkTS中用于表示任意精度整数的数据类型,它能够处理比Number类型更大范围的整数值。通过Node-API提供的接口,可以在Node-API模块中创建、获取和操作BigInt类型值,从而实现与BigInt相关的功能扩展。 + +该工程主要展示使用Node-API创建中展示使用int64、uint64类型和给定字节数的uint64创建BigInt对象等场景。其中代码详细描述可查如下链接。 + +- [使用Node-API进行bigint相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-bigint.md) + +### 效果预览 + +| 执行结果图 | | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIBigint.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行bigint相关开发 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIBigint.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/code-linter.json5 rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/code-linter.json5 diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..ea844a3416 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIBigint) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..d06064f2e2 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,162 @@ +/* + * 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 "hilog/log.h" + +// [Start napi_create_bigint_int64] +// napi_create_bigint_int64 +static napi_value CreateBigintInt64t(napi_env env, napi_callback_info info) +{ + // 声明int64_t的变量value + int64_t value = -5555555555555555555; + // 将value转化为napi_value类型返回 + napi_value returnValue = nullptr; + napi_create_bigint_int64(env, value, &returnValue); + return returnValue; +} +// [End napi_create_bigint_int64] + +// [Start napi_create_bigint_uint64] +// napi_create_bigint_uint64 +static napi_value CreateBigintUint64t(napi_env env, napi_callback_info info) +{ + // 声明uint64_t的变量value + uint64_t value = 5555555555555555555; + // 将value转化为napi_value类型返回 + napi_value returnValue = nullptr; + napi_create_bigint_uint64(env, value, &returnValue); + return returnValue; +} +// [End napi_create_bigint_uint64] + +// [Start napi_create_bigint_words] +// napi_create_bigint_words +static napi_value CreateBigintWords(napi_env env, napi_callback_info info) +{ + // 使用napi_create_bigint_words接口创建一个BigInt对象 + int signBit = 0; + size_t wordCount = 3; + uint64_t words[] = {12ULL, 34ULL, 56ULL}; + napi_value returnValue = nullptr; + napi_status status = napi_create_bigint_words(env, signBit, wordCount, words, &returnValue); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_create_bigint_words fail"); + return nullptr; + } + return returnValue; +} +// [End napi_create_bigint_words] + +// [Start napi_get_value_bigint_int64] +// napi_get_value_bigint_int64 +static napi_value GetValueBigintInt64t(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 从传入的参数中提取64位整数的BigInt数据 + int64_t value = 0; + bool lossLess = false; + napi_status status = napi_get_value_bigint_int64(env, args[0], &value, &lossLess); + // 判断从ArkTS侧获取bigint是否为无损转换,如果不是抛出异常 + if (!lossLess) { + napi_throw_error(env, nullptr, "BigInt values have not been lossless converted"); + return nullptr; + } + // 如果接口调用成功正常调用则返回true给ArkTS侧 + napi_value returnValue = nullptr; + napi_get_boolean(env, status == napi_ok, &returnValue); + return returnValue; +} +// [End napi_get_value_bigint_int64] + +// [Start napi_get_value_bigint_uint64] +// napi_get_value_bigint_uint64 +static napi_value GetValueBigintUint64t(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 从参数值中获取BigInt的数值 + uint64_t value = 0; + bool lossLess = false; + napi_status status = napi_get_value_bigint_uint64(env, args[0], &value, &lossLess); + // 判断从ArkTS侧获取bigint是否为无损转换,如果不是抛出异常 + if (!lossLess) { + napi_throw_error(env, nullptr, "BigInt values have no lossless converted"); + return nullptr; + } + // 如果接口调用成功正常调用则返回true给ArkTS侧 + napi_value returnValue = nullptr; + napi_get_boolean(env, status == napi_ok, &returnValue); + return returnValue; +} +// [End napi_get_value_bigint_uint64] + +// [Start napi_get_value_bigint_words] +// napi_get_value_bigint_words +static napi_value GetValueBigintWords(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + int signBit = 0; + size_t wordCount = 0; + uint64_t words = 0; + // 调用napi_get_value_bigint_words接口获取wordCount + napi_status status = napi_get_value_bigint_words(env, args[0], nullptr, &wordCount, nullptr); + OH_LOG_INFO(LOG_APP, "Node-API , wordCount:%{public}d.", wordCount); + // 调用napi_get_value_bigint_words接口获取传入bigInt相关信息,如:signBit传入bigInt正负信息 + status = napi_get_value_bigint_words(env, args[0], &signBit, &wordCount, &words); + OH_LOG_INFO(LOG_APP, "Node-API , signBit: %{public}d.", signBit); + if (status != napi_ok) { + OH_LOG_ERROR(LOG_APP, "Node-API , reason:%{public}d.", status); + napi_throw_error(env, nullptr, "napi_get_date_value fail"); + return nullptr; + } + // 将符号位转化为int类型传出去 + napi_value returnValue = nullptr; + napi_create_int32(env, signBit, &returnValue); + return returnValue; +} +// [End napi_get_value_bigint_words] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"createBigintInt64t", nullptr, CreateBigintInt64t, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createBigintUint64t", nullptr, CreateBigintUint64t, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createBigintWords", nullptr, CreateBigintWords, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getValueBigintInt64t", nullptr, GetValueBigintInt64t, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getValueBigintUint64t", nullptr, GetValueBigintUint64t, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getValueBigintWords", nullptr, GetValueBigintWords, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..744aef778a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_create_bigint_int64_api] +export const createBigintInt64t: () => bigint; // napi_create_bigint_int64 +// [End napi_create_bigint_int64_api] + +// [Start napi_create_bigint_uint64_api] +export const createBigintUint64t: () => bigint; // napi_create_bigint_uint64 +// [End napi_create_bigint_uint64_api] + +// [Start napi_create_bigint_words_api] +export const createBigintWords: () => bigint | void; // napi_create_bigint_words +// [End napi_create_bigint_words_api] + +// [Start napi_get_value_bigint_int64_api] +export const getValueBigintInt64t: (bigInt64: bigint) => boolean | void; // napi_get_value_bigint_int64 +// [End napi_get_value_bigint_int64_api] + +// [Start napi_get_value_bigint_uint64_api] +export const getValueBigintUint64t: (bigUint64: bigint) => boolean | void; // napi_get_value_bigint_uint64 +// [End napi_get_value_bigint_uint64_api] + +// [Start napi_get_value_bigint_words_api] +export const getValueBigintWords: (bigIntWords: bigint) => bigint | void; // napi_get_value_bigint_words +// [End napi_get_value_bigint_words_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..3427679cc0 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,149 @@ +/* + * 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 testNapi from 'libentry.so'; + + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiCreateBigintInt64', + '2.napiCreateBigintUint64', + '3.napiCreateBigintWords', + '4.napiGetValueBigintInt64', + '5.napiGetValueBigintUint64', + '6.napiGetValueBigintWords' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(22) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiCreateBigintInt64') { + // [Start ark_napi_create_bigint_int64] + // napi_create_bigint_int64 + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_bigint_int64: %{public}d', + testNapi.createBigintInt64t()); + // [End ark_napi_create_bigint_int64] + this.result = 'napiCreateBigintInt64Success'; + } else if (item === '2.napiCreateBigintUint64') { + // [Start ark_napi_create_bigint_uint64] + // napi_create_bigint_uint64 + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_bigint_uint64: %{public}d', + testNapi.createBigintUint64t()); + // [End ark_napi_create_bigint_uint64] + this.result = 'napiCreateBigintUint64Success'; + } else if (item === '3.napiCreateBigintWords') { + // [Start ark_napi_create_bigint_words] + // napi_create_bigint_words + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_bigint_words: %{public}d', + testNapi.createBigintWords()); + // [StartExclude ark_napi_create_bigint_words] + this.result = 'napiCreateBigintWordsSuccess'; + // [EndExclude ark_napi_create_bigint_words] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API NapiGetValueBigint: %{public}s', error.message); + // [StartExclude ark_napi_create_bigint_words] + this.result = 'napiCreateBigintWordsFail'; + // [EndExclude ark_napi_create_bigint_words] + } + // [End ark_napi_create_bigint_words] + } else if (item === '4.napiGetValueBigintInt64') { + // [Start ark_napi_get_value_bigint_int64] + // napi_get_value_bigint_int64 + let bigInt = BigInt(-5555555555555555); + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_int64: %{public}s', + JSON.stringify(testNapi.getValueBigintInt64t(bigInt))); + // [StartExclude ark_napi_get_value_bigint_int64] + this.result = 'napiGetValueBigintInt64Success'; + // [EndExclude ark_napi_get_value_bigint_int64] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API NapiGetValueBigint: %{public}s', error.message); + // [StartExclude ark_napi_get_value_bigint_int64] + this.result = 'napiGetValueBigintInt64Fail'; + // [EndExclude ark_napi_get_value_bigint_int64] + } + // [End ark_napi_get_value_bigint_int64] + } else if (item === '5.napiGetValueBigintUint64') { + // [Start ark_napi_get_value_bigint_uint64] + // napi_get_value_bigint_uint64 + let bigUint = BigInt(5555555555555555); + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_uint64: %{public}s', + JSON.stringify(testNapi.getValueBigintUint64t(bigUint))); + // [StartExclude ark_napi_get_value_bigint_uint64] + this.result = 'napiGetValueBigintUint64Success'; + // [EndExclude ark_napi_get_value_bigint_uint64] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API NapiGetValueBigint: %{public}s', error.message); + // [StartExclude ark_napi_get_value_bigint_uint64] + this.result = 'napiGetValueBigintUint64Fail'; + // [EndExclude ark_napi_get_value_bigint_uint64] + } + // [End ark_napi_get_value_bigint_uint64] + } else if (item === '6.napiGetValueBigintWords') { + // [Start ark_napi_get_value_bigint_words] + // napi_get_value_bigint_words + let bigInt = BigInt(-5555555555555555); + let bigUint = BigInt(5555555555555555); + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_words signBit is: %{public}d', + testNapi.getValueBigintWords(bigInt)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_words signBit is: %{public}d', + testNapi.getValueBigintWords(bigUint)); + // [StartExclude ark_napi_get_value_bigint_words] + this.result = 'napiGetValueBigintWordsSuccess'; + // [EndExclude ark_napi_get_value_bigint_words] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API NapiGetValueBigint: %{public}s', error.message); + // [StartExclude ark_napi_get_value_bigint_words] + this.result = 'napiGetValueBigintWordsFail'; + // [EndExclude ark_napi_get_value_bigint_words] + } + // [End ark_napi_get_value_bigint_words] + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/NodeAPIBigint.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/NodeAPIBigint.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/NodeAPIBigint.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/NodeAPIBigint.test.ets index f7ce867cb9..2caac72b07 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/NodeAPIBigint.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/ets/test/NodeAPIBigint.test.ets @@ -1,140 +1,140 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIBigintTest() { - describe('nodeAPIBigintTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiCreateBigintInt64相关函数 - */ - it('testNodeAPIBigint001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBigint001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiCreateBigintInt64')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateBigintInt64Success')); - console.info('uitest: testNodeAPIBigint001 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateBigintUint64相关函数 - */ - it('testNodeAPIBigint002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBigint002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiCreateBigintUint64')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateBigintUint64Success')); - console.info('uitest: testNodeAPIBigint002 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateBigintWords相关函数 - */ - it('testNodeAPIBigint003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBigint003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiCreateBigintWords')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateBigintWordsSuccess')); - console.info('uitest: testNodeAPIBigint003 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetValueBigintInt64相关函数 - */ - it('testNodeAPIBigint004', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBigint004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('4.napiGetValueBigintInt64')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetValueBigintInt64Success')); - console.info('uitest: testNodeAPIBigint004 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetValueBigintUint64相关函数 - */ - it('testNodeAPIBigint005', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBigint005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('5.napiGetValueBigintUint64')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetValueBigintUint64Success')); - console.info('uitest: testNodeAPIBigint005 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetValueBigintWords相关函数 - */ - it('testNodeAPIBigint006', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBigint006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('6.napiGetValueBigintWords')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetValueBigintWordsSuccess')); - console.info('uitest: testNodeAPIBigint006 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIBigintTest() { + describe('nodeAPIBigintTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiCreateBigintInt64相关函数 + */ + it('testNodeAPIBigint001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBigint001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiCreateBigintInt64')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateBigintInt64Success')); + console.info('uitest: testNodeAPIBigint001 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateBigintUint64相关函数 + */ + it('testNodeAPIBigint002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBigint002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiCreateBigintUint64')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateBigintUint64Success')); + console.info('uitest: testNodeAPIBigint002 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateBigintWords相关函数 + */ + it('testNodeAPIBigint003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBigint003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiCreateBigintWords')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateBigintWordsSuccess')); + console.info('uitest: testNodeAPIBigint003 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetValueBigintInt64相关函数 + */ + it('testNodeAPIBigint004', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBigint004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('4.napiGetValueBigintInt64')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetValueBigintInt64Success')); + console.info('uitest: testNodeAPIBigint004 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetValueBigintUint64相关函数 + */ + it('testNodeAPIBigint005', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBigint005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('5.napiGetValueBigintUint64')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetValueBigintUint64Success')); + console.info('uitest: testNodeAPIBigint005 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetValueBigintWords相关函数 + */ + it('testNodeAPIBigint006', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBigint006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('6.napiGetValueBigintWords')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetValueBigintWordsSuccess')); + console.info('uitest: testNodeAPIBigint006 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/ohosTest.md new file mode 100644 index 0000000000..c6b0c615b9 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/ohosTest.md @@ -0,0 +1,13 @@ +# 使用Node-API进行bigInt相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------ | ------------ | ---------------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口createBigintInt64t | 位于主页 | 点击文本为1.napiCreateBigintInt64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateBigintInt64Success | Pass | +| ArkTS端成功调用native侧接口createBigintUint64t | 位于主页 | 点击文本为2.napiCreateBigintUint64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateBigintUint64Success | Pass | +| ArkTS端成功调用native侧接口createBigintWords | 位于主页 | 点击文本为3.napiCreateBigintWords的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateBigintWordsSuccess | Pass | +| ArkTS端成功调用native侧接口getValueBigintInt64t | 位于主页 | 点击文本为4.napiGetValueBigintInt64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueBigintInt64Success | Pass | +| ArkTS端成功调用native侧接口getValueBigintUint64t | 位于主页 | 点击文本为5.napiGetValueBigintUint64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueBigintUint64Success | Pass | +| ArkTS端成功调用native侧接口getValueBigintWords | 位于主页 | 点击文本为6.napiGetValueBigintWords的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueBigintWordsSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/screenshots/NodeAPIBigint1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/screenshots/NodeAPIBigint1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/screenshots/NodeAPIBigint1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/screenshots/NodeAPIBigint1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/screenshots/NodeAPIBigint2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/screenshots/NodeAPIBigint2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/screenshots/NodeAPIBigint2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBigint/screenshots/NodeAPIBigint2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/app.json5 new file mode 100644 index 0000000000..0f22d3635c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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.nodeapibuffer", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..b65e358d5a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIBuffer" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/README.md new file mode 100644 index 0000000000..b7924bf845 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/README.md @@ -0,0 +1,75 @@ +# ArkTS使用Node-API进行buffer相关开发 + +### 介绍 + +在ArkTS中,Buffer是一种用于处理二进制数据的数据类型,使用Node-API接口进行buffer相关开发时,使用Buffer对象与ArkTS代码之间进行二进制数据的有效交互,以便在Node-API模块创建、操纵和传递Buffer对象到ArkTS,从而处理和传递二进制数据,比如文件I/O、网络传输等。 + +该工程主要展示了使用Node-API进行创建指定大小ArkTS Buffer、创建并获取指定大小ArkTS Buffer、判断给定value是否为Buffer对象等功能场景,其中代码详细描述可查如下链接。 + +- [使用Node-API进行buffer相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-buffer.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIBuffer.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API接口进行array相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIBuffer.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/code-linter.json5 old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/code-linter.json5 rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/code-linter.json5 diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..84934e6047 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIBuffer) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..67edc5118d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,181 @@ +/* + * 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 +#include "hilog/log.h" +#include "napi/native_api.h" + +static constexpr int INT_ARG_5 = 5; // 入参索引 + +// napi_create_buffer +static napi_value CreateBuffer(napi_env env, napi_callback_info info) +{ + std::string str("CreateBuffer"); + void *bufferPtr = nullptr; + size_t bufferSize = str.size(); + napi_value buffer = nullptr; + // 调用napi_create_buffer接口创建并获取一个指定大小的ArkTS Buffer + napi_create_buffer(env, bufferSize, &bufferPtr, &buffer); + // 将字符串str的值复制到buffer的内存中 + strcpy((char *)bufferPtr, str.data()); + return buffer; +} + +// napi_create_buffer_copy +static napi_value CreateBufferCopy(napi_env env, napi_callback_info info) +{ + // 要copy的内容 + std::string str("CreateBufferCopy"); + napi_value buffer = nullptr; + // 调用napi_create_buffer_copy接口创建buffer并将str的内容copy到buffer + void *resultData = nullptr; + napi_create_buffer_copy(env, str.size(), str.data(), &resultData, &buffer); + OH_LOG_INFO(LOG_APP, "Node-API resultData is : %{public}s.", resultData); + return buffer; +} + +// 回调函数,用于释放内存 +void FinalizeCallback(napi_env env, void *data, void *hint) +{ + if (data == nullptr) { + return; + } + free(data); + data = nullptr; +} + +// napi_create_external_buffer +static napi_value CreateExternalBuffer(napi_env env, napi_callback_info info) +{ + // 创建一个字符串 + std::string str("CreateExternalBuffer"); + // 在堆上分配内存,大小为字符串的长度 + void *data = malloc(str.size()); + // 将字符串复制到分配的内存中 + strcpy(static_cast(data), str.data()); + // 使用napi_create_external_buffer接口创建并获取一个指定大小buffer + napi_value buffer = nullptr; + napi_create_external_buffer(env, str.size(), data, FinalizeCallback, nullptr, &buffer); + return buffer; +} + +// napi_get_buffer_info +static napi_value GetBufferInfo(napi_env env, napi_callback_info info) +{ + // 创建一个字符串 + std::string str("GetBufferInfo"); + napi_value buffer = nullptr; + void *bufferPtr = nullptr; + size_t bufferSize = str.size(); + napi_create_buffer(env, bufferSize, &bufferPtr, &buffer); + strcpy((char *)bufferPtr, str.data()); + + // 获取Buffer的信息 + void *tmpBufferPtr = nullptr; + size_t bufferLength = 0; + napi_get_buffer_info(env, buffer, &tmpBufferPtr, &bufferLength); + + // 创建一个新的ArkTS字符串来保存Buffer的内容并返出去 + napi_value returnValue = nullptr; + napi_create_string_utf8(env, (char *)tmpBufferPtr, bufferLength, &returnValue); + return returnValue; +} + +// napi_is_buffer +static napi_value IsBuffer(napi_env env, napi_callback_info info) +{ + // 创建一个Buffer对象 + std::string str = "buffer"; + napi_value buffer = nullptr; + napi_create_buffer(env, strlen(str.data()), (void **)(str.data()), &buffer); + + // 调用napi_is_buffer接口判断创建的对象是否为buffer + bool result = false; + napi_is_buffer(env, buffer, &result); + // 将结果返回出去 + napi_value returnValue = nullptr; + napi_get_boolean(env, result, &returnValue); + return returnValue; +} + +typedef struct { + uint8_t *data; + size_t length; +} BufferData; + +void FinalizeCallback1(napi_env env, void *finalizeData, void *finalizeHint) +{ + // 获取终结时的数据 + BufferData *bufferData = static_cast(finalizeData); + + // 执行清理操作,比如释放资源 + delete[] bufferData->data; + delete bufferData; +} + +// napi_create_external_arraybuffer +napi_value CreateExternalArraybuffer(napi_env env, napi_callback_info info) +{ + // 创建一个有五个元素的C++数组 + uint8_t *dataArray = new uint8_t[5]{1, 2, 3, 4, 5}; + napi_value externalBuffer = nullptr; + BufferData *bufferData = new BufferData{dataArray, 5}; + + // 使用napi_create_external_arraybuffer创建一个外部Array Buffer对象,并指定终结回调函数 + napi_status status = + napi_create_external_arraybuffer(env, dataArray, 5, FinalizeCallback1, bufferData, &externalBuffer); + if (status != napi_ok) { + // 处理错误 + napi_throw_error(env, nullptr, "Node-API napi_create_external_arraybuffer fail"); + return nullptr; + } + napi_value outputArray; + // 使用napi_create_typedarray创建一个Array对象,并将externalBuffer对象作为参数传入 + status = napi_create_typedarray(env, napi_int8_array, INT_ARG_5, externalBuffer, 0, &outputArray); + if (status != napi_ok) { + // 处理错误 + napi_throw_error(env, nullptr, "Node-API napi_create_typedarray fail"); + return nullptr; + } + return outputArray; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"createBuffer", nullptr, CreateBuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createBufferCopy", nullptr, CreateBufferCopy, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createExternalBuffer", nullptr, CreateExternalBuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getBufferInfo", nullptr, GetBufferInfo, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"isBuffer", nullptr, IsBuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createExternalArraybuffer", nullptr, CreateExternalArraybuffer, nullptr, nullptr, nullptr, napi_default, + nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..cdb09fd249 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/Index.d.ts @@ -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. + */ + +export const createBuffer: () => string; // napi_create_buffer + +export const createBufferCopy: () => string; // napi_create_buffer_copy + +export const createExternalBuffer: () => string; // napi_create_external_buffer + +export const getBufferInfo: () => string; // napi_get_buffer_info + +export const isBuffer: () => boolean; // napi_is_buffer + +export const createExternalArraybuffer: () => ArrayBuffer | void; // napi_create_external_arraybuffer \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..4383e4a33d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,120 @@ +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiCreateBuffer', + '2.napiCreateBufferCopy', + '3.napiCreateExternalBuffer', + '4.napiGetBufferInfo', + '5.napiIsBuffer', + '6.napiCreateExternalArraybuffer' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiCreateBuffer') { + // napi_create_buffer + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_buffer: %{public}s', + testNapi.createBuffer().toString()); + this.result = 'napiCreateBufferSuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_buffer error'); + this.result = 'napiCreateBufferFail'; + } + } else if (item === '2.napiCreateBufferCopy') { + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_buffer_copy: %{public}s', + testNapi.createBufferCopy().toString()); + this.result = 'napiCreateBufferCopySuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_buffer_copy error'); + this.result = 'napiCreateBufferCopyFail'; + } + } else if (item === '3.napiCreateExternalBuffer') { + // napi_create_external_buffer + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_external_buffer: %{public}s', + testNapi.createExternalBuffer() + .toString()); + this.result = 'napiCreateExternalBufferSuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_external_buffer error'); + this.result = 'napiCreateExternalBufferFail'; + } + } else if (item === '4.napiGetBufferInfo') { + // napi_get_buffer_info + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_buffer_info: %{public}s', + testNapi.getBufferInfo().toString()); + this.result = 'napiGetBufferInfoSuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_get_buffer_info error'); + this.result = 'napiGetBufferInfoFail'; + } + } else if (item === '5.napiIsBuffer') { + // napi_is_buffer + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_buffer: %{public}s', + JSON.stringify(testNapi.isBuffer())); + this.result = 'napiIsBufferSuccess'; + } catch (error) { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_buffer error'); + this.result = 'napiIsBufferFail'; + } + } else if (item === '6.napiCreateExternalArraybuffer') { + // napi_create_external_arraybuffer + hilog.info(0x0000, 'testTag', 'Node-API createExternalArraybuffer: %{public}s', + JSON.stringify(testNapi.createExternalArraybuffer())); + this.result = 'napiCreateExternalArraybufferSuccess'; + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/NodeAPIBuffer.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/NodeAPIBuffer.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/NodeAPIBuffer.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/NodeAPIBuffer.test.ets index e25baf1c96..c608ca72ed --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/NodeAPIBuffer.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/ets/test/NodeAPIBuffer.test.ets @@ -1,140 +1,140 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIBufferTest() { - describe('nodeAPIBufferTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiCreateBuffer相关函数 - */ - it('testNodeAPIBuffer001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBuffer001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiCreateBuffer')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateBufferSuccess')); - console.info('uitest: testNodeAPIBuffer001 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateBufferCopy相关函数 - */ - it('testNodeAPIBuffer002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBuffer002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiCreateBufferCopy')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateBufferCopySuccess')); - console.info('uitest: testNodeAPIBuffer002 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateExternalBuffer相关函数 - */ - it('testNodeAPIBuffer003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBuffer003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiCreateExternalBuffer')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateExternalBufferSuccess')); - console.info('uitest: testNodeAPIBuffer003 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetBufferInfo相关函数 - */ - it('testNodeAPIBuffer004', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBuffer004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('4.napiGetBufferInfo')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetBufferInfoSuccess')); - console.info('uitest: testNodeAPIBuffer004 end'); - done(); - }) - - /** - * 点击按钮,调用napiIsBuffer相关函数 - */ - it('testNodeAPIBuffer005', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBuffer005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('5.napiIsBuffer')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiIsBufferSuccess')); - console.info('uitest: testNodeAPIBuffer005 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateExternalArraybuffer相关函数 - */ - it('testNodeAPIBuffer006', 0, async (done: Function) => { - console.info('uitest: testNodeAPIBuffer006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('6.napiCreateExternalArraybuffer')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateExternalArraybufferSuccess')); - console.info('uitest: testNodeAPIBuffer006 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIBufferTest() { + describe('nodeAPIBufferTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiCreateBuffer相关函数 + */ + it('testNodeAPIBuffer001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBuffer001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiCreateBuffer')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateBufferSuccess')); + console.info('uitest: testNodeAPIBuffer001 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateBufferCopy相关函数 + */ + it('testNodeAPIBuffer002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBuffer002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiCreateBufferCopy')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateBufferCopySuccess')); + console.info('uitest: testNodeAPIBuffer002 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateExternalBuffer相关函数 + */ + it('testNodeAPIBuffer003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBuffer003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiCreateExternalBuffer')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateExternalBufferSuccess')); + console.info('uitest: testNodeAPIBuffer003 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetBufferInfo相关函数 + */ + it('testNodeAPIBuffer004', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBuffer004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('4.napiGetBufferInfo')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetBufferInfoSuccess')); + console.info('uitest: testNodeAPIBuffer004 end'); + done(); + }) + + /** + * 点击按钮,调用napiIsBuffer相关函数 + */ + it('testNodeAPIBuffer005', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBuffer005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('5.napiIsBuffer')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiIsBufferSuccess')); + console.info('uitest: testNodeAPIBuffer005 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateExternalArraybuffer相关函数 + */ + it('testNodeAPIBuffer006', 0, async (done: Function) => { + console.info('uitest: testNodeAPIBuffer006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('6.napiCreateExternalArraybuffer')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateExternalArraybufferSuccess')); + console.info('uitest: testNodeAPIBuffer006 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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.1", + "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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigorfile.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/hvigorfile.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigorfile.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/ohosTest.md new file mode 100644 index 0000000000..c07c6db136 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/ohosTest.md @@ -0,0 +1,12 @@ +# 使用Node-API进行buffer相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ---------------------------------------------------- | ------------ | --------------------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口createBuffer | 位于主页 | 点击文本为1.napiCreateBuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateBufferSuccess | Pass | +| ArkTS端成功调用native侧接口createExternalBuffer | 位于主页 | 点击文本为2.napiCreateExternalBuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateExternalBufferSuccess | Pass | +| ArkTS端成功调用native侧接口getBufferInfo | 位于主页 | 点击文本为3.napiGetBufferInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetBufferInfoSuccess | Pass | +| ArkTS端成功调用native侧接口isBuffer | 位于主页 | 点击文本为4.napiIsBuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsBufferSuccess | Pass | +| ArkTS端成功调用native侧接口createExternalArraybuffer | 位于主页 | 点击文本为5.napiCreateExternalArraybuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateExternalArraybufferSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/screenshots/NodeAPIBuffer1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/screenshots/NodeAPIBuffer1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/screenshots/NodeAPIBuffer1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/screenshots/NodeAPIBuffer1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/screenshots/NodeAPIBuffer2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/screenshots/NodeAPIBuffer2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/screenshots/NodeAPIBuffer2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIBuffer/screenshots/NodeAPIBuffer2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/app.json5 new file mode 100644 index 0000000000..85431f44a1 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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.nodeapiclass", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..bb35b0f80c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIClass" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/README.md new file mode 100644 index 0000000000..75df20dd5e --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行class相关开发 + +### 介绍 + +该工程主要展示了使用Node-API接口进行class相关开发,处理ArkTS中的类,例如定义类、构造实例等,其中代码详细描述可查如下链接。 + +- [使用Node-API进行class相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-class.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIClass.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行class相关开发 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIClass.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..e2ef75281e --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIClass) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..646bf14367 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,120 @@ +/* + * 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 +#include +#include "napi/native_api.h" + +static constexpr int INT_ARG_18 = 18; // 入参索引 + +// [Start napi_new_instance] +// napi_new_instance +static napi_value NewInstance(napi_env env, napi_callback_info info) +{ + // 传入并解析参数,第一个参数为传入的构造函数,第二个参数为需要传入构造函数的参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 调用napi_new_instance接口,实例化一个对象,将这个对象返回 + napi_value result = nullptr; + napi_new_instance(env, args[0], 1, &args[1], &result); + return result; +} +// [End napi_new_instance] + +// [Start napi_wrap_unwrap_remove_wrap] +struct Object { + std::string name; + int32_t age; +}; + +static void DerefItem(napi_env env, void *data, void *hint) +{ + // 可选的原生回调,用于在ArkTS对象被垃圾回收时释放原生实例 + OH_LOG_INFO(LOG_APP, "Node-API DerefItem"); + (void)hint; +} + +// napi_wrap +static napi_value Wrap(napi_env env, napi_callback_info info) +{ + OH_LOG_INFO(LOG_APP, "Node-API wrap"); + // 初始化Node-API模块的object + struct Object *obj = new struct Object(); + obj->name = "lilei"; + obj->age = INT_ARG_18; + size_t argc = 1; + napi_value toWrap; + // 调用napi_wrap将Node-API模块的object绑定到ArkTS object上 + napi_get_cb_info(env, info, &argc, &toWrap, NULL, NULL); + napi_wrap(env, toWrap, reinterpret_cast(obj), DerefItem, NULL, NULL); + + return toWrap; +} + +// napi_remove_wrap +static napi_value RemoveWrap(napi_env env, napi_callback_info info) +{ + OH_LOG_INFO(LOG_APP, "Node-API removeWrap"); + size_t argc = 1; + napi_value wrapped = nullptr; + void *data = nullptr; + // 调用napi_remove_wrap从一个被包装的对象中解除包装 + napi_get_cb_info(env, info, &argc, &wrapped, nullptr, nullptr); + napi_remove_wrap(env, wrapped, &data); + + return nullptr; +} + +// napi_unwrap +static napi_value UnWrap(napi_env env, napi_callback_info info) +{ + OH_LOG_INFO(LOG_APP, "Node-API unWrap"); + size_t argc = 1; + napi_value wrapped = nullptr; + napi_get_cb_info(env, info, &argc, &wrapped, nullptr, nullptr); + // 调用napi_unwrap取出绑定在ArkTS object中的数据并打印 + struct Object *data; + napi_unwrap(env, wrapped, reinterpret_cast(&data)); + OH_LOG_INFO(LOG_APP, "Node-API name: %{public}s", data->name.c_str()); + OH_LOG_INFO(LOG_APP, "Node-API age: %{public}d", data->age); + return nullptr; +} +// [End napi_wrap_unwrap_remove_wrap] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"newInstance", nullptr, NewInstance, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"wrap", nullptr, Wrap, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"removeWrap", nullptr, RemoveWrap, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"unWrap", nullptr, UnWrap, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..afe70ce826 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/Index.d.ts @@ -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. + */ + +// [Start napi_new_instance_api] +export const newInstance: (obj: Object, param: string) => Object // napi_new_instance +// [End napi_new_instance_api] + +// [Start napi_wrap_unwrap_remove_wrap_api] +export const wrap: (obj: Object) => Object; // napi_wrap + +export const unWrap: (obj: Object) => void; // napi_unwrap + +export const removeWrap: (obj: Object) => void; // napi_remove_wrap +// [End napi_wrap_unwrap_remove_wrap_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..4af3327267 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,99 @@ +/* + * 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 testNapi from 'libentry.so'; + +// [Start ark_napi_new_instance] +class Fruit { + name: string; + + constructor(name: string) { + this.name = name; + } +} + +// [StartExclude ark_napi_new_instance] +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiNewInstance', + '2.napiRemoveWrap' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(25) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiNewInstance') { + // [EndExclude ark_napi_new_instance] + // napi_new_instance + // 调用函数,用变量obj接收函数返回的实例化对象 + let obj = testNapi.newInstance(Fruit, 'test'); + // 打印实例化对象obj的信息 + hilog.info(0x0000, 'Node-API', 'napi_new_instance %{public}s', JSON.stringify(obj)); + // [End ark_napi_new_instance] + this.result = 'napiNewInstanceSuccess'; + } else if (item === '2.napiRemoveWrap') { + // [Start ark_napi_wrap_unwrap_remove_wrap] + try { + class Obj { + } + + let obj: Obj = {}; + testNapi.wrap(obj) // napi_wrap + testNapi.unWrap(obj) // napi_unwrap + testNapi.removeWrap(obj) // napi_remove_wrap + // [StartExclude ark_napi_wrap_unwrap_remove_wrap] + this.result = 'napiRemoveWrapSuccess'; + // [EndExclude ark_napi_wrap_unwrap_remove_wrap] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API error: %{public}s', error.message); + // [StartExclude ark_napi_wrap_unwrap_remove_wrap] + this.result = 'napiRemoveWrapFail'; + // [EndExclude ark_napi_wrap_unwrap_remove_wrap] + } + // [End ark_napi_wrap_unwrap_remove_wrap] + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/NodeAPIClass.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/NodeAPIClass.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/NodeAPIClass.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/NodeAPIClass.test.ets index 196d2e9397..a491589973 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/NodeAPIClass.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/ets/test/NodeAPIClass.test.ets @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIClassTest() { - describe('nodeAPIClassTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiNewInstance相关函数 - */ - it('testNodeAPIClass001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIClass001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiNewInstance')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiNewInstanceSuccess')); - console.info('uitest: testNodeAPIClass001 end'); - done(); - }) - - /** - * 点击按钮,调用napiRemoveWrap相关函数 - */ - it('testNodeAPIClass002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIClass002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiRemoveWrap')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiRemoveWrapSuccess')); - console.info('uitest: testNodeAPIClass002 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIClassTest() { + describe('nodeAPIClassTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiNewInstance相关函数 + */ + it('testNodeAPIClass001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIClass001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiNewInstance')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiNewInstanceSuccess')); + console.info('uitest: testNodeAPIClass001 end'); + done(); + }) + + /** + * 点击按钮,调用napiRemoveWrap相关函数 + */ + it('testNodeAPIClass002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIClass002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiRemoveWrap')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiRemoveWrapSuccess')); + console.info('uitest: testNodeAPIClass002 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/ohosTest.md new file mode 100644 index 0000000000..dcc1bfe10b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/ohosTest.md @@ -0,0 +1,9 @@ +# 使用Node-API进行class相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------- | ------------ | ------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口newInstance | 位于主页 | 点击文本为1.napiNewInstance的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiNewInstanceSuccess | Pass | +| ArkTS端成功调用native侧接口wrap,unWrap,removeWrap | 位于主页 | 点击文本为2.napiRemoveWrap的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiRemoveWrapSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/screenshots/NodeAPIClass1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/screenshots/NodeAPIClass1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/screenshots/NodeAPIClass1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/screenshots/NodeAPIClass1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/screenshots/NodeAPIClass2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/screenshots/NodeAPIClass2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/screenshots/NodeAPIClass2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIClass/screenshots/NodeAPIClass2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/app.json5 new file mode 100644 index 0000000000..b633624a3b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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.nodeapicleanuphook", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..c29b6d22df --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPICleanuphook" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/README.md new file mode 100644 index 0000000000..bcd6d07107 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/README.md @@ -0,0 +1,75 @@ +# ArkTS使用Node-API进行cleanuphook相关开发 + +### 介绍 + +使用Node-API接口在进程退出时处理未释放资源,在Node-API模块注册清理钩子,一旦当前环境退出,这些钩子就会运行,使所有资源都被正确释放。 + +本工程主要展示了使用Node-API注册钩子函数、取消钩子函数等场景,其中代码详细描述可查如下链接。 + +- [使用Node-API进行cleanuphook相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-cleanuphook.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPICleanuphook.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行cleanuphook相关开发 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPICleanuphook.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/build-profile.json5 new file mode 100644 index 0000000000..f2183d9fd7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/build-profile.json5 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "arm64-v8a", + "x86_64", + "armeabi-v7a" + ] + }, + "sourceOption": { + "workers": [ + "./src/main/ets/workers/worker.ts" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..65ee02bda5 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPICleanuphook) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libuv.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..65368b7617 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_remove_add_env_cleanup_hook] +#include +#include +#include +#include "napi/native_api.h" +#include "uv.h" + +// 定义内存结构,包含指向数据的指针和数据的大小 +typedef struct { + char *data; + size_t size; +} Memory; + +// 外部缓冲区清理回调函数,用于释放分配的内存 +void ExternalFinalize(napi_env env, void *finalizeData, void *finalizeHint) +{ + Memory *wrapper = (Memory *)finalizeHint; + // [StartExclude napi_remove_add_env_cleanup_hook] + if (wrapper == nullptr) { + //处理内存分配失败的情况 + return; + } + // [EndExclude napi_remove_add_env_cleanup_hook] + free(wrapper->data); + free(wrapper); + OH_LOG_INFO(LOG_APP, "Node-API napi_add_env_cleanup_hook ExternalFinalize"); +} + +// 在环境关闭时执行一些清理操作,如清理全局变量或其他需要在环境关闭时处理的资源 +static void Cleanup(void *arg) +{ + // 执行清理操作 + OH_LOG_INFO(LOG_APP, "Node-API napi_add_env_cleanup_hook cleanuped: %{public}d", *(int *)(arg)); +} + +// 创建外部缓冲区并注册环境清理钩子函数 +static napi_value NapiEnvCleanUpHook(napi_env env, napi_callback_info info) +{ + // 分配内存并复制字符串数据到内存中 + std::string str("Hello from Node-API!"); + Memory *wrapper = (Memory *)malloc(sizeof(Memory)); + // [StartExclude napi_remove_add_env_cleanup_hook] + if (wrapper == nullptr) { + //处理内存分配失败的情况 + return nullptr; + } + // [End napi_remove_add_env_cleanup_hook] + wrapper->data = static_cast(malloc(str.size())); + strcpy(wrapper->data, str.c_str()); + wrapper->size = str.size(); + // 创建外部缓冲区对象,并指定清理回调函数 + napi_value buffer = nullptr; + napi_create_external_buffer(env, wrapper->size, (void *)wrapper->data, ExternalFinalize, wrapper, &buffer); + // 静态变量作为钩子函数参数 + static int hookArg = 42; + static int hookParameter = 1; + // 注册环境清理钩子函数 + napi_status status = napi_add_env_cleanup_hook(env, Cleanup, &hookArg); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Test Node-API napi_add_env_cleanup_hook failed."); + return nullptr; + } + // 注册环境清理钩子函数,此处不移除环境清理钩子,为了在Java环境被销毁时,这个钩子函数被调用,用来模拟执行一些清理操作,例如释放资源、关闭文件等。 + status = napi_add_env_cleanup_hook(env, Cleanup, &hookParameter); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Test Node-API napi_add_env_cleanup_hook failed."); + return nullptr; + } + // 立即移除环境清理钩子函数,确保不会在后续环境清理时被调用 + // 通常,当为其添加此钩子的资源无论如何都被拆除时调用这个接口 + napi_remove_env_cleanup_hook(env, Cleanup, &hookArg); + // 返回创建的外部缓冲区对象 + return buffer; +} +// [End napi_remove_add_env_cleanup_hook] + +// [Start napi_add_remove_async_cleanup_hook] +typedef struct { + napi_env env; + void *testData; + uv_async_s asyncUv; + napi_async_cleanup_hook_handle cleanupHandle; +} AsyncContent; + +// 删除异步工作对象并注销钩子函数 +static void FinalizeWork(uv_handle_s *handle) +{ + AsyncContent *asyncData = reinterpret_cast(handle->data); + // 不再需要异步清理钩子函数的情况下,尝试将其从环境中移除 + napi_status result = napi_remove_async_cleanup_hook(asyncData->cleanupHandle); + if (result != napi_ok) { + napi_throw_error(asyncData->env, nullptr, "Test Node-API napi_remove_async_cleanup_hook failed"); + } + // 释放AsyncContent + free(asyncData); +} + +// 异步执行环境清理工作 +static void AsyncWork(uv_async_s *async) +{ + // 执行一些清理工作,比如释放动态分配的内存 + AsyncContent *asyncData = reinterpret_cast(async->data); + if (asyncData->testData != nullptr) { + free(asyncData->testData); + asyncData->testData = nullptr; + } + // 关闭libuv句柄,并触发FinalizeWork回调清理 + uv_close((uv_handle_s *)async, FinalizeWork); +} + +// 异步清理钩子函数,创建异步工作对象并执行 +static void AsyncCleanup(napi_async_cleanup_hook_handle handle, void *info) +{ + AsyncContent *data = reinterpret_cast(info); + // 获取libUv循环实例并初始化一个异步句柄,以便后续执行异步工作 + uv_loop_s *uvLoop; + napi_get_uv_event_loop(data->env, &uvLoop); + uv_async_init(uvLoop, &data->asyncUv, AsyncWork); + + data->asyncUv.data = data; + data->cleanupHandle = handle; + // 发送异步信号触发AsyncWork函数执行清理工作 + uv_async_send(&data->asyncUv); +} + +static napi_value NapiAsyncCleanUpHook(napi_env env, napi_callback_info info) +{ + // 分配AsyncContent内存 + AsyncContent *data = reinterpret_cast(malloc(sizeof(AsyncContent))); + // StartExclude napi_add_remove_async_cleanup_hook] + if (data == nullptr) { + //处理内存分配失败的情况 + return nullptr; + } + // [EndExclude napi_add_remove_async_cleanup_hook] + data->env = env; + data->cleanupHandle = nullptr; + // 分配内存并复制字符串数据 + const char *testDataStr = "TestNapiAsyncCleanUpHook"; + data->testData = strdup(testDataStr); + if (data->testData == nullptr) { + napi_throw_error(env, nullptr, "Test Node-API data->testData is nullptr"); + } + // 添加异步清理钩子函数 + napi_status status = napi_add_async_cleanup_hook(env, AsyncCleanup, data, &data->cleanupHandle); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Test Node-API napi_add_async_cleanup_hook failed"); + } + napi_value result = nullptr; + napi_get_boolean(env, true, &result); + return result; +} +// [End napi_add_remove_async_cleanup_hook] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"napiEnvCleanUpHook", nullptr, NapiEnvCleanUpHook, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiAsyncCleanUpHook", nullptr, NapiAsyncCleanUpHook, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..3eb2054062 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/Index.d.ts @@ -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. + */ + +// [Start napi_remove_add_env_cleanup_hook_api] +export const napiEnvCleanUpHook: () => Object | void; +// [End napi_remove_add_env_cleanup_hook_api] + +// [Start napi_add_remove_async_cleanup_hook_api] +export const napiAsyncCleanUpHook: () => boolean | void; +// [End napi_add_remove_async_cleanup_hook_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..28e1689452 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import worker from '@ohos.worker'; +import testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = ''; + private items: string[] = [ + 'Reset Result Message', + '1.napiRemoveEnvCleanupHook', + '2.napiRemoveAsyncCleanupHook' + ]; + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiRemoveEnvCleanupHook') { + // [Start connect_with_worker] + let wk = new worker.ThreadWorker('entry/ets/workers/worker.ts'); + // 发送消息到worker线程 + wk.postMessage('test NapiEnvCleanUpHook'); + // 处理来自worker线程的消息 + wk.onmessage = (message) => { + hilog.info(0x0000, 'testTag', 'Test Node-API message from worker: %{public}s', + JSON.stringify(message)); + wk.terminate(); + }; + // [End connect_with_worker] + this.result = 'napiRemoveEnvCleanupHookSuccess'; + } else if (item === '2.napiRemoveAsyncCleanupHook') { + // [Start ark_napi_remove_add_env_cleanup_hook] + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_add_async_cleanup_hook: %{public}s', + testNapi.napiAsyncCleanUpHook()); + // [StartExclude ark_napi_remove_add_env_cleanup_hook] + this.result = 'napiRemoveAsyncCleanupHookSuccess'; + // [EndExclude ark_napi_remove_add_env_cleanup_hook] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_add_async_cleanup_hook error.message: %{public}s', + error.message); + // [StartExclude ark_napi_remove_add_env_cleanup_hook] + this.result = 'napiRemoveAsyncCleanupHookFail'; + // [EndExclude ark_napi_remove_add_env_cleanup_hook] + } + // [End ark_napi_remove_add_env_cleanup_hook] + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/workers/worker.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/workers/worker.ts old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/workers/worker.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/workers/worker.ts diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/NodeAPICleanuphook.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/NodeAPICleanuphook.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/NodeAPICleanuphook.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/NodeAPICleanuphook.test.ets index d37ce1a0b3..52eb13f571 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/NodeAPICleanuphook.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/ets/test/NodeAPICleanuphook.test.ets @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPICleanUpHookTest() { - describe('nodeAPICleanUpHookTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiRemoveEnvCleanupHook相关函数 - */ - it('testNodeAPICleanUpHook001', 0, async (done: Function) => { - console.info('uitest: testNodeAPICleanUpHook001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiRemoveEnvCleanupHook')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiRemoveEnvCleanupHookSuccess')); - console.info('uitest: testNodeAPICleanUpHook001 end'); - done(); - }) - - /** - * 点击按钮,调用napiRemoveAsyncCleanupHook相关函数 - */ - it('testNodeAPICleanUpHook002', 0, async (done: Function) => { - console.info('uitest: testNodeAPICleanUpHook002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiRemoveAsyncCleanupHook')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiRemoveAsyncCleanupHookSuccess')); - console.info('uitest: testNodeAPICleanUpHook002 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPICleanUpHookTest() { + describe('nodeAPICleanUpHookTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiRemoveEnvCleanupHook相关函数 + */ + it('testNodeAPICleanUpHook001', 0, async (done: Function) => { + console.info('uitest: testNodeAPICleanUpHook001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiRemoveEnvCleanupHook')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiRemoveEnvCleanupHookSuccess')); + console.info('uitest: testNodeAPICleanUpHook001 end'); + done(); + }) + + /** + * 点击按钮,调用napiRemoveAsyncCleanupHook相关函数 + */ + it('testNodeAPICleanUpHook002', 0, async (done: Function) => { + console.info('uitest: testNodeAPICleanUpHook002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiRemoveAsyncCleanupHook')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiRemoveAsyncCleanupHookSuccess')); + console.info('uitest: testNodeAPICleanUpHook002 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/ohosTest.md new file mode 100644 index 0000000000..ad29bd34c0 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/ohosTest.md @@ -0,0 +1,9 @@ +# 使用Node-API进行cleanuphook相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ----------------------------------------------- | ------------ | ------------------------------------------------ | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口napiEnvCleanUpHook | 位于主页 | 点击文本为1.napiRemoveEnvCleanupHook的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiRemoveEnvCleanupHookSuccess | Pass | +| ArkTS端成功调用native侧接口napiAsyncCleanUpHook | 位于主页 | 点击文本为2.napiRemoveAsyncCleanupHook的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiRemoveAsyncCleanupHookSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/screenshots/NodeAPICleanuphook1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/screenshots/NodeAPICleanuphook1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/screenshots/NodeAPICleanuphook1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/screenshots/NodeAPICleanuphook1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/screenshots/NodeAPICleanuphook2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/screenshots/NodeAPICleanuphook2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/screenshots/NodeAPICleanuphook2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPICleanuphook/screenshots/NodeAPICleanuphook2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/app.json5 new file mode 100644 index 0000000000..fa13ae7af0 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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.nodeapidate", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..6494c478d0 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIDate" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/README.md new file mode 100644 index 0000000000..9309937e1b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行Date相关开发 + +### 介绍 + +Node-API中date相关接口用于处理ArkTS Date对象,并在Node-API模块和ArkTS代码之间进行日期数据的转换和处理。这对于在Node-API模块中处理时间和日期相关逻辑非常有用,工程中展示的代码详细描述可查如下链接。 + +- [使用Node-API进行Date相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-date.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIDate.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行Date相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIDate.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..2730fd3d23 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIDate) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..929ee77210 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_create_date] +#include +#include "napi/native_api.h" + +// napi_create_date +static napi_value CreateDate(napi_env env, napi_callback_info info) +{ + // 获取传入的Unix Time Stamp时间 + double value = 1501924876711; + // 调用napi_create_date接口将double值转换成表示日期时间,并创建成一个ArkTS对象放入returnValue中 + napi_value returnValue = nullptr; + napi_create_date(env, value, &returnValue); + return returnValue; +} +// [End napi_create_date] + +// [Start napi_get_date_value] +// napi_get_date_value +static napi_value GetDateValue(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取传入的Unix Time Stamp时间 + double value = 0; + napi_status status = napi_get_date_value(env, args[0], &value); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_get_date_value fail"); + return nullptr; + } + + // 将获取到的Unix Time Stamp时间打印 + OH_LOG_INFO(LOG_APP, "Node-API gets unix time stamp is:%{public}lf.", value); + + // 把转换后的Unix Time Stamp时间创建成ArkTS double数值,并放入returnValue中 + napi_value returnValue = nullptr; + napi_create_double(env, value, &returnValue); + return returnValue; +} +// [End napi_get_date_value] + +// [Start napi_is_date] +// napi_is_date +static napi_value IsDate(napi_env env, napi_callback_info info) +{ + // 接受一个入参 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 调用napi_is_date接口判断给定入参是否为Date数据 + bool result = false; + napi_status status = napi_is_date(env, args[0], &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_is_date fail"); + return nullptr; + } + // 将结果转成napi_value类型返回 + napi_value returnValue = nullptr; + napi_get_boolean(env, result, &returnValue); + + return returnValue; +} +// [End napi_is_date] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"createDate", nullptr, CreateDate, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getDateValue", nullptr, GetDateValue, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"isDate", nullptr, IsDate, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..487a558af1 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/Index.d.ts @@ -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. + */ + +// [Start napi_create_date_api] +export const createDate: () => Date; // napi_create_date +// [End napi_create_date_api] + +// [Start napi_get_date_value_api] +export const getDateValue: (date: Date) => number | void; // napi_get_date_value +// [End napi_get_date_value_api] + +// [Start napi_is_date_api] +export const isDate: (date: T) => boolean | void; // napi_is_date +// [End napi_is_date_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..1b43488237 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,105 @@ +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiCreateDate', + '2.napiGetDateValue', + '3.napiIsDate' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(25) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiCreateDate') { + // [Start ark_napi_create_date] + // napi_create_date + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_date: %{public}s', + testNapi.createDate().toString()); + // [End ark_napi_create_date] + this.result = 'napiCreateDateSuccess'; + } else if (item === '2.napiGetDateValue') { + // [Start ark_napi_get_date_value] + // napi_get_date_value + try { + const date = new Date(); + hilog.info(0x0000, 'testTag', 'Node-API: output the Unix Time Stamp: %{public}d', date.getTime()); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_date_value: %{public}d', + testNapi.getDateValue(date)); + // [StartExclude ark_napi_get_date_value] + this.result = 'napiGetDateValueSuccess'; + // [EndExclude ark_napi_get_date_value] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_get_date_value error: %{public}s', + error.message); + // [StartExclude ark_napi_get_date_value] + this.result = 'napiGetDateValueFail'; + // [EndExclude ark_napi_get_date_value] + } + // [End ark_napi_get_date_value] + } else if (item === '3.napiIsDate') { + // [Start ark_napi_is_date] + // napi_is_date + try { + let now: Date = new Date(); + let date = "123"; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_date: %{public}s', testNapi.isDate(now)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_date: %{public}s', testNapi.isDate(date)); + // [StartExclude ark_napi_is_date] + this.result = 'napiIsDateSuccess'; + // [EndExclude ark_napi_is_date] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_date error: %{public}s', error.message); + // [StartExclude ark_napi_is_date] + this.result = 'napiIsDateFail'; + // [EndExclude ark_napi_is_date] + } + // [End ark_napi_is_date] + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/NodeAPIDate.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/NodeAPIDate.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/NodeAPIDate.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/NodeAPIDate.test.ets index 876fec5e8d..be15ef4548 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/NodeAPIDate.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/ets/test/NodeAPIDate.test.ets @@ -1,92 +1,92 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIDateTest() { - describe('nodeAPIDateTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiCreateDate相关函数 - */ - it('testNodeAPIDate001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIDate001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiCreateDate')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateDateSuccess')); - console.info('uitest: testNodeAPIDate001 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetDateValue相关函数 - */ - it('testNodeAPIDate002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIDate002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiGetDateValue')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetDateValueSuccess')); - console.info('uitest: testNodeAPIDate002 end'); - done(); - }) - - /** - * 点击按钮,调用napiIsDate相关函数 - */ - it('testNodeAPIDate003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIDate003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiIsDate')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiIsDateSuccess')); - console.info('uitest: testNodeAPIDate003 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIDateTest() { + describe('nodeAPIDateTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiCreateDate相关函数 + */ + it('testNodeAPIDate001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIDate001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiCreateDate')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateDateSuccess')); + console.info('uitest: testNodeAPIDate001 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetDateValue相关函数 + */ + it('testNodeAPIDate002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIDate002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiGetDateValue')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetDateValueSuccess')); + console.info('uitest: testNodeAPIDate002 end'); + done(); + }) + + /** + * 点击按钮,调用napiIsDate相关函数 + */ + it('testNodeAPIDate003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIDate003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiIsDate')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiIsDateSuccess')); + console.info('uitest: testNodeAPIDate003 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/ohosTest.md new file mode 100644 index 0000000000..65f6734124 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/ohosTest.md @@ -0,0 +1,10 @@ +# 使用Node-API进行date相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| --------------------------------------- | ------------ | -------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口createDate | 位于主页 | 点击文本为1.napiCreateDate的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateDateSuccess | Pass | +| ArkTS端成功调用native侧接口getDateValue | 位于主页 | 点击文本为2.napiGetDateValue的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetDateValueSuccess | Pass | +| ArkTS端成功调用native侧接口isDate | 位于主页 | 点击文本为3.napiIsDate的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsDateSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/screenshots/NodeAPIDate1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/screenshots/NodeAPIDate1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/screenshots/NodeAPIDate1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/screenshots/NodeAPIDate1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/screenshots/NodeAPIDate2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/screenshots/NodeAPIDate2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/screenshots/NodeAPIDate2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIDate/screenshots/NodeAPIDate2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/app.json5 new file mode 100644 index 0000000000..a932871591 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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.nodeapienvironmentallifecycle", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..284c1c7cb8 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIEnvironmentalLifeCycle" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/README.md new file mode 100644 index 0000000000..da3acf2b58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行environmental-life-cycle相关开发 + +### 介绍 + +在Node-API模块中,可以使用Node-API接口将特定数据与当前的环境相关联,并在需要时检索该数据,本工程主要展示绑定和检索与当前运行环境相关联的数据项,其中代码详细描述可查如下链接。 + +- [使用Node-API进行environmental-life-cycle相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-environmental-life-cycle.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| :----------------------------------------------------------- | :----------------------------------------------------------- | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIEnvironmentalLifeCycle.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行environmental-life-cycle相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIEnvironmentalLifeCycle.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..59ead807ce --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIEnviornmentalLifeCycle) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..1fd25dbe91 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_set_instance_data] +#include +#include "napi/native_api.h" + +// 定义一个结构来存储实例数据 +struct InstanceData { + int32_t value; +}; + +// 对象被释放时的回调函数,用于清理实例数据 +void FinalizeCallback(napi_env env, void *finalizeData, void *finalizeHint) +{ + if (finalizeData) { + InstanceData *data = reinterpret_cast(finalizeData); + // 释放内存,清除指针指向地址 + delete (data); + *(InstanceData **)finalizeData = nullptr; + } +} + +// napi_set_instance_data +static napi_value SetInstanceData(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value argv[1]; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + int32_t instanceDataValue; + napi_get_value_int32(env, argv[0], &instanceDataValue); + InstanceData *instanceData = new InstanceData; + instanceData->value = instanceDataValue; + // 调用napi_set_instance_data将实例数据关联到Node-API环境,并指定FinalizeCallback函数 + napi_status status = napi_set_instance_data(env, instanceData, FinalizeCallback, nullptr); + bool success = true; + napi_value result; + if (status == napi_ok) { + napi_get_boolean(env, success, &result); + } + return result; +} +// [End napi_set_instance_data] + +// [Start napi_get_instance_data] +// napi_get_instance_data +static napi_value GetInstanceData(napi_env env, napi_callback_info info) +{ + InstanceData *resData = nullptr; + // napi_get_instance_data获取之前想关联的数据项 + napi_get_instance_data(env, (void **)&resData); + napi_value result; + napi_create_int32(env, resData->value, &result); + return result; +} +// [End napi_get_instance_data] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"setInstanceData", nullptr, SetInstanceData, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getInstanceData", nullptr, GetInstanceData, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..11b146eb4a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts @@ -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. + */ + +// [Start napi_set_instance_data_api] +export const setInstanceData: (data: number) => boolean; // napi_set_instance_data +// [End napi_set_instance_data_api] + +// [Start napi_get_instance_data_api] +export const getInstanceData: () => number; // napi_get_instance_data +// [End napi_get_instance_data_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..83c5f01412 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiSetInstanceData', + '2.napiGetInstanceData' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(22) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiSetInstanceData') { + // [Start ark_napi_set_instance_data] + // napi_set_instance_data + let data = 5; + let value = testNapi.setInstanceData(data); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_instance_data:%{public}s', value); + // [End ark_napi_set_instance_data] + this.result = 'napiSetInstanceDataSuccess'; + } else if (item === '2.napiGetInstanceData') { + // [Start ark_napi_get_instance_data] + // napi_get_instance_data + let data = 5; + testNapi.setInstanceData(data); + let value = testNapi.getInstanceData(); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_instance_data:%{public}d', value); + // [End ark_napi_get_instance_data] + this.result = 'napiGetInstanceDataSuccess'; + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/NodeAPIEnvironmentalLifeCycle.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/NodeAPIEnvironmentalLifeCycle.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/NodeAPIEnvironmentalLifeCycle.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/NodeAPIEnvironmentalLifeCycle.test.ets index e26b8bde87..52e7cf03ff --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/NodeAPIEnvironmentalLifeCycle.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/ets/test/NodeAPIEnvironmentalLifeCycle.test.ets @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIEnvironmentalLifeCycleTest() { - describe('nodeAPIEnvironmentalLifeCycleTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiSetInstanceData相关函数 - */ - it('testNodeAPIEnvironmentalLifeCycle001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIEnvironmentalLifeCycle001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiSetInstanceData')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiSetInstanceDataSuccess')); - console.info('uitest: testNodeAPIEnvironmentalLifeCycle001 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetInstanceData相关函数 - */ - it('testNodeAPIEnvironmentalLifeCycle002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIEnvironmentalLifeCycle002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiGetInstanceData')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetInstanceDataSuccess')); - console.info('uitest: testNodeAPIEnvironmentalLifeCycle002 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIEnvironmentalLifeCycleTest() { + describe('nodeAPIEnvironmentalLifeCycleTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiSetInstanceData相关函数 + */ + it('testNodeAPIEnvironmentalLifeCycle001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIEnvironmentalLifeCycle001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiSetInstanceData')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiSetInstanceDataSuccess')); + console.info('uitest: testNodeAPIEnvironmentalLifeCycle001 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetInstanceData相关函数 + */ + it('testNodeAPIEnvironmentalLifeCycle002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIEnvironmentalLifeCycle002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiGetInstanceData')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetInstanceDataSuccess')); + console.info('uitest: testNodeAPIEnvironmentalLifeCycle002 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/ohosTest.md new file mode 100644 index 0000000000..0d3d2bb4a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/ohosTest.md @@ -0,0 +1,9 @@ +# 使用Node-API进行environmental-life-cycle相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| --------------------------------------------- | ------------ | ----------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 setInstanceData | 位于主页 | 点击文本为1.napiSetInstanceData的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiSetInstanceDataSuccess | Pass | +| ArkTS端成功调用native侧接口getInstanceData | 位于主页 | 点击文本为2.napiGetInstanceData的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetInstanceDataSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/screenshots/NodeAPIEnvironmentalLifeCycle1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/screenshots/NodeAPIEnvironmentalLifeCycle1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/screenshots/NodeAPIEnvironmentalLifeCycle1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/screenshots/NodeAPIEnvironmentalLifeCycle1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/screenshots/NodeAPIEnvironmentalLifeCycle2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/screenshots/NodeAPIEnvironmentalLifeCycle2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/screenshots/NodeAPIEnvironmentalLifeCycle2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/screenshots/NodeAPIEnvironmentalLifeCycle2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/AppScope/app.json5 new file mode 100644 index 0000000000..5e4fc240f9 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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.nodeapierror", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..7863ec920d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIError" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/README.md new file mode 100644 index 0000000000..e6f0304bc6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行错误处理开发 + +### 介绍 + +使用Node-API接口进行错误处理开发,使得在Node-API模块中能够更好地管理和响应错误情况。通过合理使用这些函数,可以提高模块的稳定性和可靠性,本工程主要展示使用Node-API进行创建错误对象并抛出、获取错误对象、检查napi_value是否代表错误对象和抛出致命异常终止进程等场景,其中代码详细描述可查如下链接。 + +- [使用Node-API进行错误处理开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-error.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIError.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行错误处理开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIError.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..42d85db3cb --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIError) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..ea24d692ae --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,324 @@ +/* + * 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 "hilog/log.h" +#include "napi/native_api.h" + +// [Start napi_get_last_error_info] +// napi_get_last_error_info +static napi_value GetLastErrorInfo(napi_env env, napi_callback_info info) +{ + // 获取输入参数(这里以字符串message作为参数传入) + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 将传入的字符串参数以napi_get_value_int32取出,主动制造错误 + int32_t value = 0; + napi_status status = napi_get_value_int32(env, args[0], &value); + // 接口使用错误,故返回值不为napi_ok + if (status != napi_ok) { + OH_LOG_INFO(LOG_APP, "napi_get_value_int32 return status, status is not equal to napi_ok."); + } + // 调用接口napi_get_last_error_info获取最后一次错误信息 + const napi_extended_error_info *errorInfo; + napi_get_last_error_info(env, &errorInfo); + // 取出错误码与接口调用错误后其返回值作比较 + if (errorInfo->error_code == status) { + OH_LOG_INFO(LOG_APP, "napi_get_last_error_info return errorInfo, error_code equal to status."); + } + // 取出错误消息作为返回值带出去打印 + napi_value result = nullptr; + napi_create_string_utf8(env, errorInfo->error_message, NAPI_AUTO_LENGTH, &result); + return result; +} +// [End napi_get_last_error_info] + +// [Start napi_create_type_error] +// napi_create_type_error +static napi_value CreatTypeError(napi_env env, napi_callback_info info) +{ + // 构造errorCode和errorMessage + napi_value errorCode = nullptr; + napi_create_string_utf8(env, "napi_create_error errorCode", NAPI_AUTO_LENGTH, &errorCode); + napi_value errorMessage = nullptr; + napi_create_string_utf8(env, "napi_create_error errorMessage", NAPI_AUTO_LENGTH, &errorMessage); + // 调用napi_create_type_error创建一个typeError错误对象 + napi_value error = nullptr; + napi_create_type_error(env, errorCode, errorMessage, &error); + return error; +} +// [End napi_create_type_error] + +// [Start napi_create_range_error] +// napi_create_range_error +static napi_value CreatRangeError(napi_env env, napi_callback_info info) +{ + // 构造errorCode和errorMessage + napi_value errorCode = nullptr; + napi_create_string_utf8(env, "napi_create_error errorCode", NAPI_AUTO_LENGTH, &errorCode); + napi_value errorMessage = nullptr; + napi_create_string_utf8(env, "napi_create_error errorMessage", NAPI_AUTO_LENGTH, &errorMessage); + // 调用napi_create_range_error创建一个typeError错误对象 + napi_value error = nullptr; + napi_create_range_error(env, errorCode, errorMessage, &error); + return error; +} +// [End napi_create_range_error] + +// [Start napi_create_error] +// napi_create_error and napi_throw +static napi_value NapiThrow(napi_env env, napi_callback_info info) +{ + // 代码中发生某些错误后,可执行以下操作抛出异常 + // 在Node-API环境中创建一个字符串,并将其存储在errorCode变量中 + napi_value errorCode = nullptr; + napi_create_string_utf8(env, "throw errorCode", NAPI_AUTO_LENGTH, &errorCode); + // 在Node-API环境中创建一个字符串,并将其存储在errorMessage变量中 + napi_value errorMessage = nullptr; + napi_create_string_utf8(env, "throw errorMessage", NAPI_AUTO_LENGTH, &errorMessage); + // 创建一个ArkTS对象error + napi_value error = nullptr; + napi_create_error(env, errorCode, errorMessage, &error); + // 通过napi_throw接口将对象抛出 + napi_throw(env, error); + return nullptr; +} +// [End napi_create_error] + +// [Start napi_throw_error] +// napi_throw_error +// 这里直接抛出一个带有errorMessage的错误 +static napi_value NapiThrowErrorMessage(napi_env env, napi_callback_info info) +{ + napi_throw_error(env, nullptr, "napi_throw_error throwing an error"); + return nullptr; +} + +// 传入两个参数,在第二个参数,也就是除数为0的时候抛出一个错误 +static napi_value NapiThrowError(napi_env env, napi_callback_info info) +{ + // ArkTS侧传入两个参数 + size_t argc = 2; + napi_value argv[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + // 将其转换为double类型的值作为被除数和除数 + double dividend; + double divisor; + napi_get_value_double(env, argv[0], ÷nd); + napi_get_value_double(env, argv[1], &divisor); + // 在这里判断除数如果为0则直接抛出一个错误,errorCode为:DIVIDE_BY_ZERO,errorMessage为:Cannot divide by zero + if (divisor == 0) { + napi_throw_error(env, "DIVIDE_BY_ZERO", "Cannot divide by zero"); + } + return nullptr; +} +// [End napi_throw_error] + +// [Start napi_throw_type_error] +// napi_throw_type_error +// 这里直接抛出一个带有errorMessage的TypeError +static napi_value ThrowTypeErrorMessage(napi_env env, napi_callback_info info) +{ + napi_throw_type_error(env, nullptr, "napi_throw_type_error throwing an error"); + return nullptr; +} + +// 传入一个类型不匹配的参数,判断类型不匹配之后抛出typeError +static napi_value ThrowTypeError(napi_env env, napi_callback_info info) +{ + // ArkTS侧传入一个参数 + size_t argc = 1; + napi_value argv[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + // 将传入参数转换为napi_valuetype类型的值 + napi_valuetype valueType; + napi_typeof(env, argv[0], &valueType); + // 如果传入参数不为napi_number类型的值则抛出TypeError + if (valueType != napi_number) { + // 这里抛出一个既带有errorCode也带有errorMessage的TypeError + napi_throw_type_error(env, "napi_throw_type_error", "Argument must be a number"); + } + return nullptr; +} +// [End napi_throw_type_error] + +// [Start napi_throw_range_error] +// napi_throw_range_error +// 这里直接抛出一个带有errorMessage的RangeError +static napi_value ThrowRangeErrorMessage(napi_env env, napi_callback_info info) +{ + napi_throw_range_error(env, nullptr, "napi_throw_range_error one"); + return nullptr; +} + +// 传入不匹配的参数个数,判断不匹配之后抛出rangeError +static napi_value ThrowRangeError(napi_env env, napi_callback_info info) +{ + // ArkTS侧传入两个参数 + size_t argc = 2; + napi_value argv[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + // 如果传入参数个数不为2 + if (argc != 2) { + // 这里抛出一个RangeError + napi_throw_range_error(env, "napi_throw_range_error", "Expected two numbers as arguments"); + return nullptr; + } + // 下面将传入的两值相加并传出去 + double numOne = 0; + double numTwo = 0; + napi_get_value_double(env, argv[0], &numOne); + napi_get_value_double(env, argv[1], &numTwo); + double result = numOne + numTwo; + napi_value resultValue; + napi_create_double(env, result, &resultValue); + return resultValue; +} +// [End napi_throw_range_error] + +// [Start napi_is_error] +// napi_is_error +static napi_value NapiIsError(napi_env env, napi_callback_info info) +{ + // 接收一个入参 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 调用接口napi_is_error判断入参是否为一个error对象 + bool result = false; + // 如果napi_value为一个error对象,则设置result为true的布尔值,否则设置为false + napi_is_error(env, args[0], &result); + // 取出result通过napi_get_boolean接口将取出的bool值转换为napi_value类型的值返回出去 + napi_value returnValue = nullptr; + napi_get_boolean(env, result, &returnValue); + return returnValue; +} +// [End napi_is_error] + +// [Start napi_get_and_clear_last_exception] +// napi_get_and_clear_last_exception +static napi_value GetAndClearLastException(napi_env env, napi_callback_info info) +{ + // 抛出异常,创造异常情况 + napi_throw_error(env, "napi_create_error errorCode", "napi_create_error errorMessage"); + // 调用napi_get_and_clear_last_exception接口获取并清除最后一个未处理的异常。即使存在挂起的ArkTS异常,也可以调用此API + napi_value result = nullptr; + napi_status status = napi_get_and_clear_last_exception(env, &result); + if (status != napi_ok) { + return nullptr; + } + return result; +} +// [End napi_get_and_clear_last_exception] + +// [Start napi_is_exception_pending] +// napi_is_exception_pending +static napi_value IsExceptionPending(napi_env env, napi_callback_info info) +{ + napi_status status; + bool isExceptionPending = false; + // 在执行一些可能引发异常的操作后 + napi_throw_error(env, "napi_create_error errorCode", "napi_create_error errorMessage"); + // 检查当前环境中是否有异常挂起 + status = napi_is_exception_pending(env, &isExceptionPending); + if (status != napi_ok) { + return nullptr; + } + if (isExceptionPending) { + // 处理异常挂起的情况 + napi_value result = nullptr; + status = napi_get_and_clear_last_exception(env, &result); + if (status != napi_ok) { + return nullptr; + } + // 将处理的异常返回出去 + return result; + } + return nullptr; +} +// [End napi_is_exception_pending] + +// [Start napi_fatal_error] +// napi_fatal_error +static napi_value FatalError(napi_env env, napi_callback_info info) +{ + // 请注意,使用napi_fatal_error函数会导致应用进程直接终止,因此应该谨慎使用,仅在遇到无法恢复的严重错误时才应该调用该函数 + // 模拟一个致命错误条件 + bool errorCondition = true; + if (errorCondition) { + // 创建一个致命错误信息 + napi_fatal_error("napi_fatal_error test", NAPI_AUTO_LENGTH, "napi_create_error errorMessage", NAPI_AUTO_LENGTH); + } + return nullptr; +} +// [End napi_fatal_error] + +// [Start napi_fatal_exception] +// napi_fatal_exception +static napi_value FatalException(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + + napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + if (status != napi_ok) { + return nullptr; + } + // 请注意,使用napi_fatal_exception函数会导致应用进程直接终止,因此应该谨慎使用,仅在主线程遇到无法恢复的严重错误时才应该调用该函数 + // 模拟一个致命错误条件 + status = napi_fatal_exception(env, args[0]); + if (status != napi_ok) { + return nullptr; + } + return nullptr; +} +// [End napi_fatal_exception] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"getLastErrorInfo", nullptr, GetLastErrorInfo, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"creatTypeError", nullptr, CreatTypeError, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"creatRangeError", nullptr, CreatRangeError, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiThrow", nullptr, NapiThrow, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiThrowErrorMessage", nullptr, NapiThrowErrorMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiThrowError", nullptr, NapiThrowError, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"throwTypeErrorMessage", nullptr, ThrowTypeErrorMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"throwTypeError", nullptr, ThrowTypeError, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"throwRangeErrorMessage", nullptr, ThrowRangeErrorMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"throwRangeError", nullptr, ThrowRangeError, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiIsError", nullptr, NapiIsError, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getAndClearLastException", nullptr, GetAndClearLastException, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"isExceptionPending", nullptr, IsExceptionPending, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"fatalError", nullptr, FatalError, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"fatalException", nullptr, FatalException, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..fa36b9c531 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_get_last_error_info_api] +export const getLastErrorInfo: (str: string) => string; // napi_get_last_error_info +// [End napi_get_last_error_info_api] + +// [Start napi_create_type_error_api] +export const creatTypeError: () => Error; // napi_create_type_error +// [End napi_create_type_error_api] + +// [Start napi_create_range_error_api] +export const creatRangeError: () => Error; // napi_create_range_error +// [End napi_create_range_error_api] + +// [Start napi_create_error_api] +export const napiThrow: () => void; // napi_create_error and napi_throw +// [End napi_create_error_api] + +// [Start napi_throw_error_api] +export const napiThrowErrorMessage: () => void; // napi_throw_error + +export const napiThrowError: (dividend: number, divisor: number) => void; // napi_throw_error +// [End napi_throw_error_api] + +// [Start napi_throw_type_error_api] +export const throwTypeErrorMessage: () => void; // napi_throw_type_error + +export const throwTypeError: (message: string) => void; // napi_throw_type_error +// [End napi_throw_type_error_api] + +// [Start napi_throw_range_error_api] +export const throwRangeErrorMessage: () => void; // napi_throw_range_error + +export const throwRangeError: (num: number) => number | void; // napi_throw_range_error +// [End napi_throw_range_error_api] + +// [Start napi_is_error_api] +export const napiIsError: (obj: T) => boolean; // napi_is_error +// [End napi_is_error_api] + +// [Start napi_get_and_clear_last_exception_api] +export const getAndClearLastException: () => Error | void; // napi_get_and_clear_last_exception +// [End napi_get_and_clear_last_exception_api] + +// [Start ark_napi_is_exception_pending_interface] +export interface MyObject { + code: string; + message: string; +} +// [End ark_napi_is_exception_pending_interface] + +// [Start napi_is_exception_pending_api] +export const isExceptionPending: () => Object | void; // napi_is_exception_pending +// [End napi_is_exception_pending_api] + +// [Start napi_fatal_error_api] +export const fatalError: () => void; // napi_fatal_error +// [End napi_fatal_error_api] + +// [Start napi_fatal_exception_api] +export const fatalException: (err: Error) => void; // napi_fatal_exception +// [End napi_fatal_exception_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..5aee78b856 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,308 @@ +/* + * 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 testNapi, { MyObject } from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiGetLastErrorInfo', + '2.napiCreateTypeError', + '3.napiCreateRangeError', + '4.napiCreateErrorAndNapiThrow', + '5.napiThrowError', + '6.napiThrowTypeError', + '7.napiThrowRangeError', + '8.napiIsError', + '9.napiGetAndClearLastException', + '10.napiIsExceptionPending', + '11.napiFatalError', + '12.napiFatalException' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiGetLastErrorInfo') { + // [Start ark_napi_get_last_error_info] + // napi_get_last_error_info + try { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_last_error_info: %{public}s', + testNapi.getLastErrorInfo('message')); + // [StartExclude ark_napi_get_last_error_info] + this.result = 'napiGetLastErrorInfoSuccess'; + // [EndExclude ark_napi_get_last_error_info] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_get_last_error_info error: %{public}s', error); + // [StartExclude ark_napi_get_last_error_info] + this.result = 'napiGetLastErrorInfoFail'; + // [EndExclude ark_napi_get_last_error_info] + } + // [End ark_napi_get_last_error_info] + } else if (item === '2.napiCreateTypeError') { + // [Start ark_napi_create_type_error] + try { + // [StartExclude ark_napi_create_type_error] + this.result = 'napiCreateTypeErrorSuccess'; + // [EndExclude ark_napi_create_type_error] + throw testNapi.creatTypeError(); + } catch (error) { // napi_create_type_error + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_create_type_error errorCode: %{public}s, errorMessage %{public}s', error.code, + error.message); + // [StartExclude ark_napi_create_type_error] + this.result = 'napiCreateTypeErrorFail'; + // [EndExclude ark_napi_create_type_error] + } + // [End ark_napi_create_type_error] + } else if (item === '3.napiCreateRangeError') { + // [Start ark_napi_create_range_error] + // napi_create_range_error + try { + // [StartExclude ark_napi_create_range_error] + this.result = 'napiCreateRangeErrorSuccess'; + // [EndExclude ark_napi_create_range_error] + throw testNapi.creatRangeError(); + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_create_range_error errorCode: %{public}s, errorMessage: %{public}s', + error.code, + error.message); + // [StartExclude ark_napi_create_range_error] + this.result = 'napiCreateRangeErrorFail'; + // [EndExclude ark_napi_create_range_error] + } + // [End ark_napi_create_range_error] + } else if (item === '4.napiCreateErrorAndNapiThrow') { + // [Start ark_napi_create_error] + // napi_create_error and napi_throw + try { + testNapi.napiThrow(); + // [StartExclude ark_napi_create_error] + this.result = 'napiCreateErrorAndNapiThrowSuccess'; + // [EndExclude ark_napi_create_error] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_throw errorCode: %{public}s, errorMessage: %{public}s', + error.code, error.message); + // [StartExclude ark_napi_create_error] + this.result = 'napiCreateErrorAndNapiThrowFail'; + // [EndExclude ark_napi_create_error] + } + // [End ark_napi_create_error] + } else if (item === '5.napiThrowError') { + // [Start ark_napi_throw_error] + // napi_throw_error + try { + testNapi.napiThrowErrorMessage(); + // [StartExclude ark_napi_throw_error] + this.result = 'napiThrowErrorMessageSuccess'; + // [EndExclude ark_napi_throw_error] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_throw_error error code: %{public}s , message: %{public}s', error.code, + error.message); + // [StartExclude ark_napi_throw_error] + this.result = 'napiThrowErrorMessageFail'; + // [EndExclude ark_napi_throw_error] + } + try { + testNapi.napiThrowError(5, 0); + // [StartExclude ark_napi_throw_error] + this.result = 'napiThrowErrorSuccess'; + // [EndExclude ark_napi_throw_error] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_throw_error errorCode: %{public}s , errorManager: %{public}s', error.code, + error.message); + // [StartExclude ark_napi_throw_error] + this.result = 'napiThrowErrorFail'; + // [EndExclude ark_napi_throw_error] + } + // [End ark_napi_throw_error] + } else if (item === '6.napiThrowTypeError') { + // [Start ark_napi_throw_type_error] + // napi_throw_type_error + try { + testNapi.throwTypeErrorMessage(); + // [StartExclude ark_napi_throw_type_error] + this.result = 'throwTypeErrorMessageSuccess'; + // [EndExclude ark_napi_throw_type_error] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_throw_type_error errorCode: %{public}s, errorMessage: %{public}s', + error.code, + error.message); + // [StartExclude ark_napi_throw_type_error] + this.result = 'throwTypeErrorMessageFail'; + // [EndExclude ark_napi_throw_type_error] + } + try { + testNapi.throwTypeError('str'); + // [StartExclude ark_napi_throw_type_error] + this.result = 'throwTypeErrorSuccess'; + // [EndExclude ark_napi_throw_type_error] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_throw_type_error errorCode: %{public}s, errorMessage: %{public}s', + error.code, + error.message); + // [StartExclude ark_napi_throw_type_error] + this.result = 'throwTypeErrorFail'; + // [EndExclude ark_napi_throw_type_error] + } + // [End ark_napi_throw_type_error] + } else if (item === '7.napiThrowRangeError') { + // [Start ark_napi_throw_range_error] + // napi_throw_range_error + try { + testNapi.throwRangeErrorMessage(); + // [StartExclude ark_napi_throw_range_error] + this.result = 'throwRangeErrorMessageSuccess'; + // [EndExclude ark_napi_throw_range_error] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_throw_range_error errorCode: %{public}s, errorMessage: %{public}s', + error.code, + error.message); + // [StartExclude ark_napi_throw_range_error] + this.result = 'throwRangeErrorMessageFail'; + // [EndExclude ark_napi_throw_range_error] + } + + try { + testNapi.throwRangeError(1); + // [StartExclude ark_napi_throw_range_error] + this.result = 'throwRangeErrorSuccess'; + // [EndExclude ark_napi_throw_range_error] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_throw_range_error errorCode: %{public}s, errorMessage: %{public}s', + error.code, + error.message); + // [StartExclude ark_napi_throw_range_error] + this.result = 'throwRangeErrorFail'; + // [EndExclude ark_napi_throw_range_error] + } + // [End ark_napi_throw_range_error] + } else if (item === '8.napiIsError') { + // [Start ark_napi_is_error] + // napi_is_error + try { + // [StartExclude ark_napi_is_error] + this.result = 'napiIsErrorSuccess'; + // [EndExclude ark_napi_is_error] + throw new Error("throwing an error"); + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_error error: %{public}s', + testNapi.napiIsError(error) + .toString()); + hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_error error: %{public}s', + testNapi.napiIsError(1) + .toString()); + // [StartExclude ark_napi_is_error] + this.result = 'napiIsErrorFail'; + // [EndExclude ark_napi_is_error] + } + // [End ark_napi_is_error] + } else if (item === '9.napiGetAndClearLastException') { + // [Start ark_napi_get_and_clear_last_exception] + // napi_get_and_clear_last_exception + // 这里获取到最后一个未处理的异常 + hilog.info(0x0000, 'testTag', + 'Test Node-API napi_get_and_clear_last_exception, error.message: %{public}s', + testNapi.getAndClearLastException()); + // [End ark_napi_get_and_clear_last_exception] + this.result = 'napiGetAndClearLastExceptionSuccess'; + } else if (item === '10.napiIsExceptionPending') { + // [Start ark_napi_is_exception_pending] + // napi_is_exception_pending + try { + let result = testNapi.isExceptionPending() as MyObject; + hilog.info(0x0000, 'testTag', + 'Test Node-API napi_is_exception_pending, error.Code: %{public}s, error.message: %{public}s', + result.code, result.message); + // [StartExclude ark_napi_is_exception_pending] + this.result = 'napiIsExceptionPendingSuccess'; + // [EndExclude ark_napi_is_exception_pending] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_exception_pending error'); + // [StartExclude ark_napi_is_exception_pending] + this.result = 'napiIsExceptionPendingFail'; + // [EndExclude ark_napi_is_exception_pending] + } + // [End ark_napi_is_exception_pending] + } else if (item === '11.napiFatalError') { + // [Start ark_napi_fatal_error] + // napi_fatal_error 请注意,使用napi_fatal_error函数会导致应用进程直接终止,因此应该谨慎使用,仅在遇到无法恢复的严重错误时才应该调用该函数 + // 模拟一个致命错误条件 + try { + testNapi.fatalError(); + // [StartExclude ark_napi_fatal_error] + this.result = 'napiFatalErrorSuccess'; + // [EndExclude ark_napi_fatal_error] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_fatal_error error'); + // [StartExclude ark_napi_fatal_error] + this.result = 'napiFatalErrorFail'; + // [EndExclude ark_napi_fatal_error] + } + // [End ark_napi_fatal_error] + } else if (item === '12.napiFatalException') { + // napi_fatal_exception 请注意,使用napi_fatal_error函数会导致应用进程直接终止,因此应该谨慎使用,仅在遇到无法恢复的严重错误时才应该调用该函数 + // 模拟一个致命错误条件 + try { + // [Start ark_napi_fatal_exception] + const err = new Error("a fatal exception occurred"); + testNapi.fatalException(err); + // [End ark_napi_fatal_exception] + this.result = 'napiFatalExceptionSuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_fatal_exception error'); + this.result = 'napiFatalExceptionFail'; + } + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/NodeAPIError.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/NodeAPIError.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/NodeAPIError.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/NodeAPIError.test.ets index 8e66b792f5..843a51cf0d --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/NodeAPIError.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/ets/test/NodeAPIError.test.ets @@ -1,204 +1,204 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIErrorTest() { - describe('nodeAPIErrorTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiGetLastErrorInfo相关函数 - */ - it('testNodeAPIError001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIError001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiGetLastErrorInfo')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetLastErrorInfoSuccess')); - console.info('uitest: testNodeAPIError001 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateTypeError相关函数 - */ - it('testNodeAPIError002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIError002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiCreateTypeError')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateTypeErrorFail')); - console.info('uitest: testNodeAPIError002 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateRangeError相关函数 - */ - it('testNodeAPIError003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIError003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiCreateRangeError')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateRangeErrorFail')); - console.info('uitest: testNodeAPIError003 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateErrorAndNapiThrow相关函数 - */ - it('testNodeAPIError004', 0, async (done: Function) => { - console.info('uitest: testNodeAPIError004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('4.napiCreateErrorAndNapiThrow')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateErrorAndNapiThrowFail')); - console.info('uitest: testNodeAPIError004 end'); - done(); - }) - - /** - * 点击按钮,调用napiThrowError相关函数 - */ - it('testNodeAPIError005', 0, async (done: Function) => { - console.info('uitest: testNodeAPIError005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('5.napiThrowError')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiThrowErrorFail')); - console.info('uitest: testNodeAPIError005 end'); - done(); - }) - - /** - * 点击按钮,调用napiThrowTypeError相关函数 - */ - it('testNodeAPIError006', 0, async (done: Function) => { - console.info('uitest: testNodeAPIError006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('6.napiThrowTypeError')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: throwTypeErrorFail')); - console.info('uitest: testNodeAPIError006 end'); - done(); - }) - - /** - * 点击按钮,调用napiThrowRangeError相关函数 - */ - it('testNodeAPIError007', 0, async (done: Function) => { - console.info('uitest: testNodeAPIError007 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('7.napiThrowRangeError')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: throwRangeErrorFail')); - console.info('uitest: testNodeAPIError007 end'); - done(); - }) - - /** - * 点击按钮,调用napiIsError相关函数 - */ - it('testNodeAPIError008', 0, async (done: Function) => { - console.info('uitest: testNodeAPIError008 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('8.napiIsError')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiIsErrorFail')); - console.info('uitest: testNodeAPIError008 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetAndClearLastException相关函数 - */ - it('testNodeAPIError009', 0, async (done: Function) => { - console.info('uitest: testNodeAPIError009 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('9.napiGetAndClearLastException')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetAndClearLastExceptionSuccess')); - console.info('uitest: testNodeAPIError009 end'); - done(); - }) - - /** - * 点击按钮,调用napiIsExceptionPending相关函数 - */ - it('testNodeAPIError010', 0, async (done: Function) => { - console.info('uitest: testNodeAPIError010 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('10.napiIsExceptionPending')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiIsExceptionPendingSuccess')); - console.info('uitest: testNodeAPIError010 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIErrorTest() { + describe('nodeAPIErrorTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiGetLastErrorInfo相关函数 + */ + it('testNodeAPIError001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIError001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiGetLastErrorInfo')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetLastErrorInfoSuccess')); + console.info('uitest: testNodeAPIError001 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateTypeError相关函数 + */ + it('testNodeAPIError002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIError002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiCreateTypeError')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateTypeErrorFail')); + console.info('uitest: testNodeAPIError002 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateRangeError相关函数 + */ + it('testNodeAPIError003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIError003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiCreateRangeError')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateRangeErrorFail')); + console.info('uitest: testNodeAPIError003 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateErrorAndNapiThrow相关函数 + */ + it('testNodeAPIError004', 0, async (done: Function) => { + console.info('uitest: testNodeAPIError004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('4.napiCreateErrorAndNapiThrow')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateErrorAndNapiThrowFail')); + console.info('uitest: testNodeAPIError004 end'); + done(); + }) + + /** + * 点击按钮,调用napiThrowError相关函数 + */ + it('testNodeAPIError005', 0, async (done: Function) => { + console.info('uitest: testNodeAPIError005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('5.napiThrowError')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiThrowErrorFail')); + console.info('uitest: testNodeAPIError005 end'); + done(); + }) + + /** + * 点击按钮,调用napiThrowTypeError相关函数 + */ + it('testNodeAPIError006', 0, async (done: Function) => { + console.info('uitest: testNodeAPIError006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('6.napiThrowTypeError')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: throwTypeErrorFail')); + console.info('uitest: testNodeAPIError006 end'); + done(); + }) + + /** + * 点击按钮,调用napiThrowRangeError相关函数 + */ + it('testNodeAPIError007', 0, async (done: Function) => { + console.info('uitest: testNodeAPIError007 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('7.napiThrowRangeError')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: throwRangeErrorFail')); + console.info('uitest: testNodeAPIError007 end'); + done(); + }) + + /** + * 点击按钮,调用napiIsError相关函数 + */ + it('testNodeAPIError008', 0, async (done: Function) => { + console.info('uitest: testNodeAPIError008 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('8.napiIsError')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiIsErrorFail')); + console.info('uitest: testNodeAPIError008 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetAndClearLastException相关函数 + */ + it('testNodeAPIError009', 0, async (done: Function) => { + console.info('uitest: testNodeAPIError009 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('9.napiGetAndClearLastException')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetAndClearLastExceptionSuccess')); + console.info('uitest: testNodeAPIError009 end'); + done(); + }) + + /** + * 点击按钮,调用napiIsExceptionPending相关函数 + */ + it('testNodeAPIError010', 0, async (done: Function) => { + console.info('uitest: testNodeAPIError010 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('10.napiIsExceptionPending')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiIsExceptionPendingSuccess')); + console.info('uitest: testNodeAPIError010 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/ohosTest.md new file mode 100644 index 0000000000..00c324b80d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/ohosTest.md @@ -0,0 +1,17 @@ +# 使用Node-API进行错误处理开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| --------------------------------------------------- | ------------ | -------------------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 getLastErrorInfo | 位于主页 | 点击文本为1.napiGetLastErrorInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetLastErrorInfoSuccess | Pass | +| ArkTS端成功调用native侧接口creatTypeError | 位于主页 | 点击文本为2.napiCreateTypeError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateTypeErrorSuccess | Pass | +| ArkTS端成功调用native侧接口creatRangeError | 位于主页 | 点击文本为3.napiCreateRangeError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateRangeErrorSuccess | Pass | +| ArkTS端成功调用native侧接口napiThrow | 位于主页 | 点击文本为4.napiCreateErrorAndNapiThrow的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateErrorAndNapiThrowSuccess | Pass | +| ArkTS端成功调用native侧接口napiThrowError | 位于主页 | 点击文本为5.napiThrowError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiThrowErrorSuccess | Pass | +| ArkTS端成功调用native侧接口throwTypeError | 位于主页 | 点击文本为6.napiThrowTypeError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: throwTypeErrorSuccess | Pass | +| ArkTS端成功调用native侧接口throwRangeError | 位于主页 | 点击文本为7.napiThrowRangeError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: throwRangeErrorSuccess | Pass | +| ArkTS端成功调用native侧接口napiIsError | 位于主页 | 点击文本为8.napiIsError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsErrorSuccess | Pass | +| ArkTS端成功调用native侧接口getAndClearLastException | 位于主页 | 点击文本为9.napiGetAndClearLastException的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetAndClearLastExceptionSuccess | Pass | +| ArkTS端成功调用native侧接口isExceptionPending | 位于主页 | 点击文本为10.napiIsExceptionPending的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsExceptionPendingSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/screenshots/NodeAPIError1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/screenshots/NodeAPIError1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/screenshots/NodeAPIError1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/screenshots/NodeAPIError1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/screenshots/NodeAPIError2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/screenshots/NodeAPIError2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/screenshots/NodeAPIError2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIError/screenshots/NodeAPIError2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/app.json5 new file mode 100644 index 0000000000..d82f431489 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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.nodeapiextendcapabilities", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..0c07424d46 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIExtendCapabilities" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/README.md new file mode 100644 index 0000000000..977d66194b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行扩展能力功能开发 + +### 介绍 + +扩展能力接口进一步扩展了Node-API的功能,提供了一些额外的接口,用于在Node-API模块中与ArkTS进行更灵活的交互和定制,这些接口可以用于创建自定义ArkTS对象等场景,本工程主要展示了使用Node-API对模块加载、ArkTS Object相关、运行指定abc文件、异步工作对象加入队列并指定优先级、给ArkTS对象绑定回调和回调所需的参数等场景,其中展示的代码详细描述可查如下链接。 + +- [使用Node-API进行扩展能力功能开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-extension.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIExtendCapabilities.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行扩展能力功能开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIExtendCapabilities.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..577025fb9d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,18 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(using_NodeAPI_extend_capabilities) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..dc093e6fc1 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,578 @@ +/* + * 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 +#include +#include +#include +#include "hilog/log.h" + +static constexpr int INT_ARG_100 = 100; // 入参索引 + +// [Start node_api_module_add] +// 模块加载 +static napi_value Add(napi_env env, napi_callback_info info) +{ + // 接受传入两个参数 + size_t requireArgc = 2; + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 将传入的napi_value类型的参数转化为double类型 + double valueLeft; + double valueRight; + napi_get_value_double(env, args[0], &valueLeft); + napi_get_value_double(env, args[1], &valueRight); + + // 将转化后的double值相加并转成napi_value返回给ArkTS代码使用 + napi_value sum; + napi_create_double(env, valueLeft + valueRight, &sum); + + return sum; +} + +// [StartExclude node_api_module_add] +// [Start node_api_module_create_object_properties] +// ArkTS Object相关 napi_create_object_with_properties +static napi_value CreateObjectWithProperties(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value argv[1] = {nullptr}; + // 获取解析传递的参数 + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + // 声明了一个napi_property_descriptor数组desc,其中包含了一个名为"name"的属性,其值为传入的第一个参数argv[0]。 + napi_property_descriptor desc[] = { + {"name", nullptr, nullptr, nullptr, nullptr, argv[0], napi_default_jsproperty, nullptr}}; + napi_value object = nullptr; + // 调用napi_create_object_with_properties来创建一个新的ArkTS对象,并将属性值添加到该对象中。 + napi_create_object_with_properties(env, &object, sizeof(desc) / sizeof(desc[0]), desc); + napi_valuetype valueType; + napi_typeof(env, object, &valueType); + if (valueType == napi_object) { + return object; + } +} +// [End node_api_module_create_object_properties] +// [Start node_api_module_create_object_name_properties] +// ArkTS Object相关 napi_create_object_with_named_properties +static napi_value CreateObjectWithNameProperties(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value argv[1] = {nullptr}; + // 获取解析传递的参数 + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + napi_value obj = nullptr; + const char *key[] = { + "name", + }; + const napi_value values[] = { + argv[0], + }; + napi_property_descriptor desc[] = {{"name", nullptr, nullptr, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_status status = napi_create_object_with_named_properties( + env, &obj, sizeof(desc) / sizeof(desc[0]), key, values); + if (status != napi_ok) { + return argv[0]; + } + return obj; +} +// [End node_api_module_create_object_name_properties] +// [Start node_api_module_run_script_path] +// 运行指定abc文件 napi_run_script_path +static napi_value RunScriptPath(napi_env env, napi_callback_info info) +{ + napi_value value = nullptr; + // 注意:记得在应用rawfile目录下放置.abc文件 + const char *scriptPath = "/entry/src/main/resources/rawfile/test.abc"; + // 使用napi_run_script_path函数执行指定路径中的文件 + napi_status status = napi_run_script_path(env, scriptPath, &value); + // 检查是否执行成功,如果失败,返回false + napi_value returnValue = nullptr; + if (value == nullptr || status != napi_ok) { + napi_get_boolean(env, false, &returnValue); + } else { + napi_get_boolean(env, true, &returnValue); + } + return returnValue; +} +// [End node_api_module_run_script_path] +// 给ArkTS对象绑定回调和回调所需的参数 napi_coerce_to_native_binding_object +// [Start napi_coerce_to_native_binding_object] +class Object { +public: + Object() = default; + ~Object() = default; + + static Object *GetInstance() + { + Object *instance = new Object(); + return instance; + } + + static napi_value GetAddress(napi_env env, napi_callback_info info) + { + napi_value thisVar = nullptr; + napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); + if (thisVar == nullptr) { + return nullptr; + } + void *object = nullptr; + napi_unwrap(env, thisVar, &object); + if (object == nullptr) { + return nullptr; + } + uint64_t addressVal = reinterpret_cast(object); + napi_value address = nullptr; + napi_create_bigint_uint64(env, addressVal, &address); + return address; + } + + // 获取数组大小 + static napi_value GetSetSize(napi_env env, napi_callback_info info) + { + napi_value thisVar = nullptr; + napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); + if (thisVar == nullptr) { + return nullptr; + } + void *object = nullptr; + napi_unwrap(env, thisVar, &object); + if (object == nullptr) { + return nullptr; + } + std::lock_guard lock(reinterpret_cast(object)->numberSetMutex_); + uint32_t setSize = reinterpret_cast(object)->numberSet_.size(); + napi_value napiSize = nullptr; + napi_create_uint32(env, setSize, &napiSize); + return napiSize; + } + + // 往数组里插入元素 + static napi_value Store(napi_env env, napi_callback_info info) + { + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_value thisVar = nullptr; + napi_get_cb_info(env, info, &argc, args, &thisVar, nullptr); + if (argc != 1) { + napi_throw_error(env, nullptr, "Store args number must be one."); + return nullptr; + } + napi_valuetype type = napi_undefined; + napi_typeof(env, args[0], &type); + if (type != napi_number) { + napi_throw_error(env, nullptr, "Store args is not number."); + return nullptr; + } + if (thisVar == nullptr) { + return nullptr; + } + uint32_t value = 0; + napi_get_value_uint32(env, args[0], &value); + void *object = nullptr; + napi_unwrap(env, thisVar, &object); + if (object == nullptr) { + return nullptr; + } + std::lock_guard lock(reinterpret_cast(object)->numberSetMutex_); + reinterpret_cast(object)->numberSet_.insert(value); + return nullptr; + } + + // 删除数组元素 + static napi_value Erase(napi_env env, napi_callback_info info) + { + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_value thisVar = nullptr; + napi_get_cb_info(env, info, &argc, args, &thisVar, nullptr); + if (argc != 1) { + napi_throw_error(env, nullptr, "Erase args number must be one."); + return nullptr; + } + napi_valuetype type = napi_undefined; + napi_typeof(env, args[0], &type); + if (type != napi_number) { + napi_throw_error(env, nullptr, "Erase args is not number."); + return nullptr; + } + if (thisVar == nullptr) { + return nullptr; + } + uint32_t value = 0; + napi_get_value_uint32(env, args[0], &value); + void *object = nullptr; + napi_unwrap(env, thisVar, &object); + if (object == nullptr) { + return nullptr; + } + std::lock_guard lock(reinterpret_cast(object)->numberSetMutex_); + reinterpret_cast(object)->numberSet_.erase(value); + return nullptr; + } + + // 清空数组 + static napi_value Clear(napi_env env, napi_callback_info info) + { + napi_value thisVar = nullptr; + napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); + if (thisVar == nullptr) { + return nullptr; + } + void *object = nullptr; + napi_unwrap(env, thisVar, &object); + if (object == nullptr) { + return nullptr; + } + std::lock_guard lock(reinterpret_cast(object)->numberSetMutex_); + reinterpret_cast(object)->numberSet_.clear(); + return nullptr; + } + +private: + Object(const Object &) = delete; + Object &operator=(const Object &) = delete; + + std::unordered_set numberSet_{}; + std::mutex numberSetMutex_{}; +}; + +void FinializeCallback(napi_env env, void *data, void *hint) { return; } + +// 解绑回调,在序列化时调用,可在对象解绑时执行一些清理操作 +void *DetachCallback(napi_env env, void *value, void *hint) { return value; } + +// 绑定回调,在反序列化时调用 +napi_value AttachCallback(napi_env env, void *value, void *hint) +{ + napi_value object = nullptr; + napi_create_object(env, &object); + napi_property_descriptor desc[] = { + {"getAddress", nullptr, Object::GetAddress, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getSetSize", nullptr, Object::GetSetSize, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"store", nullptr, Object::Store, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"erase", nullptr, Object::Erase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"clear", nullptr, Object::Clear, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, object, sizeof(desc) / sizeof(desc[0]), desc); + // 将JS对象object和native对象value生命周期进行绑定 + napi_wrap(env, object, value, FinializeCallback, nullptr, nullptr); + // JS对象携带native信息 + napi_coerce_to_native_binding_object(env, object, DetachCallback, AttachCallback, value, hint); + return object; +} +// [StartExclude napi_coerce_to_native_binding_object] +// [Start napi_serialize_deserialize_delete_serialization_data] +// 序列化和反序列化 +static napi_value AboutSerialize(napi_env env, napi_callback_info info) +{ + // 获取传入的ts的一个对象作为参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + napi_value undefined = nullptr; + // 构造napi_serialize方法所需参数 + napi_get_undefined(env, &undefined); + void *data = nullptr; + // 调用napi_serialize方法将ts对象转化为native数据 + napi_status status = napi_serialize(env, args[0], undefined, undefined, &data); + if (status != napi_ok || data == nullptr) { + napi_throw_error(env, nullptr, "Node-API napi_serialize fail"); + return nullptr; + } + // 构造napi_value类型的数据,用于接收将native数据转化为ts对象后的数据 + napi_value result = nullptr; + napi_deserialize(env, data, &result); + napi_value number = nullptr; + // 获取native数据转化为ts对象后的数据中的numKey属性的值 + napi_get_named_property(env, result, "numKey", &number); + // 判断获取到的属性值是否为number类型 + napi_valuetype valuetype; + napi_typeof(env, number, &valuetype); + if (valuetype != napi_number) { + napi_throw_error(env, nullptr, "Node-API Wrong type of argment. Expects a number."); + return nullptr; + } + // 调用napi_delete_serialization_data方法删除序列化数据 + napi_delete_serialization_data(env, data); + // 返回获取到的属性值 + return number; +} +// [End napi_serialize_deserialize_delete_serialization_data] +// [Start napi_is_sendable] +// Sendable相关 napi_is_sendable +static napi_value IsSendable(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + bool isSendable = false; + napi_is_sendable(env, args[0], &isSendable); + napi_value result; + napi_get_boolean(env, isSendable, &result); + return result; +} +// [End napi_is_sendable] + +// [Start napi_define_sendable_class] +static napi_value func(napi_env env, napi_callback_info info) +{ + napi_value val; + napi_create_string_utf8(env, "func result", NAPI_AUTO_LENGTH, &val); + return val; +} + +static napi_value DefineSendableClass(napi_env env) +{ + napi_value str; + napi_create_string_utf8(env, "str", NAPI_AUTO_LENGTH, &str); + + napi_property_descriptor props[] = { + {"staticStr", nullptr, nullptr, nullptr, nullptr, str, + static_cast(napi_static | napi_writable), nullptr}, + {"staticFunc", nullptr, func, nullptr, nullptr, nullptr, napi_static, nullptr}, + {"str", nullptr, nullptr, nullptr, nullptr, str, static_cast(1 << 9 | napi_writable), + nullptr}, + {"func", nullptr, nullptr, nullptr, nullptr, nullptr, + static_cast(1 << 11 | napi_writable), nullptr}, + }; + + napi_value sendableClass = nullptr; + napi_define_sendable_class( + env, "SendableClass", NAPI_AUTO_LENGTH, + [](napi_env env, napi_callback_info info) -> napi_value { + napi_value thisVar = nullptr; + napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); + napi_value str; + napi_create_string_utf8(env, "instance str", NAPI_AUTO_LENGTH, &str); + napi_property_descriptor props[] = { + {"str", nullptr, nullptr, nullptr, nullptr, str, napi_default, nullptr}, + {"func", nullptr, func, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + napi_define_properties(env, thisVar, sizeof(props) / sizeof(props[0]), props); + return thisVar; + }, + nullptr, sizeof(props) / sizeof(props[0]), props, nullptr, &sendableClass); + + return sendableClass; +} +// [End napi_define_sendable_class] +// [Start napi_create_sendable_object_with_properties] +// Sendable相关 napi_create_sendable_object_with_properties +static napi_value GetSendableObject(napi_env env, napi_callback_info info) +{ + napi_value val_true; + napi_get_boolean(env, true, &val_true); + napi_property_descriptor desc1[] = { + {"x", nullptr, nullptr, nullptr, nullptr, val_true, napi_default_jsproperty, nullptr}, + }; + napi_value obj; + napi_create_sendable_object_with_properties(env, 1, desc1, &obj); + return obj; +} +// [End napi_create_sendable_object_with_properties +// [Start napi_create_sendable_array] +// Sendable相关 napi_create_sendable_array +static napi_value GetSendableArray(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_create_sendable_array(env, &result); + return result; +} +// [End napi_create_sendable_array] +// [Start napi_create_sendable_array_with_length] +// Sendable相关 napi_create_sendable_array_with_length +static napi_value GetSendableArrayWithLength(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_create_sendable_array_with_length(env, 1, &result); + return result; +} +// End napi_create_sendable_array_with_length] +// [Start napi_create_sendable_arraybuffer] +// Sendable相关 napi_create_sendable_arraybuffer +static napi_value GetSendableArrayBuffer(napi_env env, napi_callback_info info) +{ + static size_t length = 1024; + void *data; + napi_value result = nullptr; + napi_create_sendable_arraybuffer(env, length, &data, &result); + bool isArrayBuffer = false; + napi_is_arraybuffer(env, result, &isArrayBuffer); + OH_LOG_INFO(LOG_APP, "isArrayBuffer: %{public}d", isArrayBuffer); + return result; +} +// [End napi_create_sendable_arraybuffer] +// [Start napi_create_sendable_typed_array] +// Sendable相关 napi_create_sendable_typedarray +static napi_value GetSendableTypedArray(napi_env env, napi_callback_info info) +{ + static size_t length = 1024; + static size_t offset = 0; + void *data; + napi_value arraybuffer = nullptr; + napi_create_sendable_arraybuffer(env, length, &data, &arraybuffer); + + napi_value result = nullptr; + napi_create_sendable_typedarray(env, napi_uint8_array, length, arraybuffer, offset, &result); + bool isTypedArray = false; + napi_is_typedarray(env, result, &isTypedArray); + OH_LOG_INFO(LOG_APP, "isTypedArray: %{public}d", isTypedArray); + return result; +} +// [End napi_create_sendable_typed_array] +// [Start napi_wrap_sendable] +// Sendable相关 napi_wrap_sendable +static napi_value WrapSendable(napi_env env, napi_callback_info info) +{ + napi_value val_true; + napi_get_boolean(env, true, &val_true); + napi_property_descriptor desc1[] = { + {"x", nullptr, nullptr, nullptr, nullptr, val_true, napi_default_jsproperty, nullptr}, + }; + napi_value obj; + napi_create_sendable_object_with_properties(env, 1, desc1, &obj); + + const char *testStr = "test"; + napi_wrap_sendable( + env, obj, (void *)testStr, [](napi_env env, void *data, void *hint) {}, nullptr); + + return nullptr; +} +// [End napi_wrap_sendable] +// [Start napi_wrap_sendable_with_size] +// Sendable相关 napi_wrap_sendable_with_size +static napi_value WrapSendableWithSize(napi_env env, napi_callback_info info) +{ + napi_value val_true; + napi_get_boolean(env, true, &val_true); + napi_property_descriptor desc1[] = { + {"x", nullptr, nullptr, nullptr, nullptr, val_true, napi_default_jsproperty, nullptr}, + }; + napi_value obj; + napi_create_sendable_object_with_properties(env, 1, desc1, &obj); + + const char *testStr = "test"; + napi_wrap_sendable_with_size( + env, obj, (void *)testStr, [](napi_env env, void *data, void *hint) {}, nullptr, INT_ARG_100); + + return nullptr; +} +// [End napi_wrap_sendable_with_size] +// [Start napi_unwrap_sendable] +// Sendable相关 napi_unwrap_sendable +static napi_value UnwrapSendable(napi_env env, napi_callback_info info) +{ + napi_value val_true; + napi_get_boolean(env, true, &val_true); + napi_property_descriptor desc1[] = { + {"x", nullptr, nullptr, nullptr, nullptr, val_true, napi_default_jsproperty, nullptr}, + }; + napi_value obj; + napi_create_sendable_object_with_properties(env, 1, desc1, &obj); + + const char *testStr = "test"; + napi_wrap_sendable( + env, obj, (void *)testStr, [](napi_env env, void *data, void *hint) {}, nullptr); + + char *tmpTestStr = nullptr; + napi_unwrap_sendable(env, obj, (void **)&tmpTestStr); + OH_LOG_INFO(LOG_APP, "native value is %{public}s", tmpTestStr); + + return nullptr; +} +// [End napi_unwrap_sendable] +// [Start napi_remove_wrap_sendable] +// Sendable相关 napi_remove_wrap_sendable +static napi_value RemoveWrapSendable(napi_env env, napi_callback_info info) +{ + napi_value val_true; + napi_get_boolean(env, true, &val_true); + napi_property_descriptor desc1[] = { + {"x", nullptr, nullptr, nullptr, nullptr, val_true, napi_default_jsproperty, nullptr}, + }; + napi_value obj; + napi_create_sendable_object_with_properties(env, 1, desc1, &obj); + + const char *testStr = "test"; + napi_wrap_sendable( + env, obj, (void *)testStr, [](napi_env env, void *data, void *hint) {}, nullptr); + + char *tmpTestStr = nullptr; + napi_remove_wrap_sendable(env, obj, (void **)&tmpTestStr); + OH_LOG_INFO(LOG_APP, "native value is %{public}s", tmpTestStr); + + return nullptr; +} +// [End napi_remove_wrap_sendable] +// [EndExclude napi_coerce_to_native_binding_object] +// [EndExclude node_api_module_add] + +// C++函数Init用于初始化插件,用于将ArkTS层的函数或属性与C++层的函数进行关联 +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + // 通过napi_property_descriptor结构体,可以定义需要导出的属性,并在Node-API模块中使用。napi_define_properties将属性与实际的C++函数进行关联,使其可以被ArkTS层访问和调用 + napi_property_descriptor desc[] = { + {"add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createObjectWithProperties", nullptr, CreateObjectWithProperties, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"createObjectWithNameProperties", nullptr, CreateObjectWithNameProperties, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"runScriptPath", nullptr, RunScriptPath, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getAddress", nullptr, Object::GetAddress, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getSetSize", nullptr, Object::GetSetSize, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"store", nullptr, Object::Store, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"erase", nullptr, Object::Erase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"clear", nullptr, Object::Clear, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"aboutSerialize", nullptr, AboutSerialize, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"isSendable", nullptr, IsSendable, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getSendableObject", nullptr, GetSendableObject, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getSendableArray", nullptr, GetSendableArray, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getSendableArrayWithLength", nullptr, GetSendableArrayWithLength, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"getSendableArrayBuffer", nullptr, GetSendableArrayBuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getSendableTypedArray", nullptr, GetSendableTypedArray, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"wrapSendable", nullptr, WrapSendable, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"wrapSendableWithSize", nullptr, WrapSendableWithSize, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"unwrapSendable", nullptr, UnwrapSendable, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"removeWrapSendable", nullptr, RemoveWrapSendable, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + auto object = Object::GetInstance(); + napi_wrap(env, exports, reinterpret_cast(object), FinializeCallback, nullptr, nullptr); + napi_coerce_to_native_binding_object(env, exports, DetachCallback, AttachCallback, reinterpret_cast(object), + nullptr); + napi_value cons = DefineSendableClass(env); + napi_set_named_property(env, exports, "SendableClass", cons); + return exports; +} +EXTERN_C_END + +// 插件的初始化被定义在一个名为demoModule的结构体中,其中包含了模块的基本信息,比如模块的版本号、注册函数等 +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}, +}; + +// 在RegisterEntryModule函数中,使用napi_module_register函数注册并导出了这个插件 +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +// [End napi_coerce_to_native_binding_object] +// [End node_api_module_add] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..92396c6fc7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start node_api_module_add_api] +export const add: (a: number, b: number) => number; // 模块加载 +// [End node_api_module_add_api] + +// [Start node_api_module_create_object_properties_api] +export const createObjectWithProperties: (data: string) => Object; // ArkTS Object相关 napi_create_object_with_properties +// [End node_api_module_create_object_properties_api] + +// [Start node_api_module_create_object_name_properties_api] +export const createObjectWithNameProperties: (data: string) => string | { name: string }; // ArkTS Object相关 napi_create_object_with_named_properties +// [End node_api_module_create_object_name_properties_api] + +// [Start node_api_module_run_script_path_api] +export const runScriptPath: () => boolean; // 运行指定abc文件 napi_run_script_path +// [End node_api_module_run_script_path_api] +// [Start napi_coerce_to_native_binding_object_api] +// 给ArkTS对象绑定回调和回调所需的参数 napi_coerce_to_native_binding_object +export const getAddress: () => number; + +export const getSetSize: () => number; + +export const store: (a: number) => void; + +export const erase: (a: number) => void; + +export const clear: () => void; +// [End napi_coerce_to_native_binding_object_api] + +// [Start napi_serialize_deserialize_delete_serialization_data_api] +export const aboutSerialize: (obj: Object) => number; // 序列化和反序列化 +// [End napi_serialize_deserialize_delete_serialization_data_api] + +// [Start napi_is_sendable_api] +export const isSendable: (a: T) => boolean; // Sendable相关 napi_is_sendable +// [End napi_is_sendable_api] + +// [Start napi_define_sendable_class_api] +@Sendable +export class SendableClass { + static staticStr: string; + static staticFunc(): string; + str: string; + func(): string; +} // Sendable相关 napi_define_sendable_class +// [End napi_define_sendable_class_api] + +// [Start napi_create_sendable_object_with_properties_api] +export const getSendableObject: () => { x: true }; // Sendable相关 napi_create_sendable_object_with_properties +// [End napi_create_sendable_object_with_properties_api] + +// [Start napi_create_sendable_array_api] +export const getSendableArray: () => []; // Sendable相关 napi_create_sendable_array +// [End napi_create_sendable_array_api] + +// [Start napi_create_sendable_array_with_length_api] +export const getSendableArrayWithLength: () => []; // Sendable相关 napi_create_sendable_array_with_length +// [End napi_create_sendable_array_with_length_api] + +// [Start napi_create_sendable_arraybuffer_api] +export const getSendableArrayBuffer: () => void; // Sendable相关 napi_create_sendable_arraybuffer +// [End napi_create_sendable_arraybuffer_api] + +// [Start napi_create_sendable_typed_array_api] +export const getSendableTypedArray: () => void; // Sendable相关 napi_create_sendable_typedarray +// [End napi_create_sendable_typed_array_api] + +// [Start napi_wrap_sendable_api] +export const wrapSendable: () => void; // Sendable相关 napi_wrap_sendable +// [End napi_wrap_sendable_api] + +// [Start napi_wrap_sendable_with_size_api] +export const wrapSendableWithSize: () => void; // Sendable相关 napi_wrap_sendable_with_size +// [End napi_wrap_sendable_with_size_api] + +// [Start napi_unwrap_sendable_api] +export const unwrapSendable: () => void; // Sendable相关 napi_unwrap_sendable +// [End napi_unwrap_sendable_api] + +// [Start napi_remove_wrap_sendable_api] +export const removeWrapSendable: () => void; // Sendable相关 napi_remove_wrap_sendable +// [End napi_remove_wrap_sendable_api] diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..a673344ac3 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,267 @@ +/* + * 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 testNapi from 'libentry.so'; +import taskpool from '@ohos.taskpool'; + +// [Start ark_napi_coerce_to_native_binding_object] +@Concurrent +function getAddress() { + let address: number = testNapi.getAddress(); + console.info('taskpool:: address is' + address); +} + +@Concurrent +function store(a: number, b: number, c: number) { + let size: number = testNapi.getSetSize(); + console.info('set size is' + size + 'before store'); + testNapi.store(a); + testNapi.store(b); + testNapi.store(c); + size = testNapi.getSetSize(); + console.info('set size is' + size + 'after store'); +} + +@Concurrent +function erase(a: number) { + let size: number = testNapi.getSetSize(); + console.info('set size is' + size + 'before erase'); + testNapi.erase(a); + size = testNapi.getSetSize(); + console.info('set size is' + size + 'after erase'); +} + +@Concurrent +function clear() { + let size: number = testNapi.getSetSize(); + console.info('set size is' + size + 'before clear'); + testNapi.clear(); + size = testNapi.getSetSize(); + console.info('set size is' + size + 'after clear'); +} + +async function test01(): Promise { + let address: number = testNapi.getAddress(); + console.info('host thread address is' + address); + + let task1 = new taskpool.Task(getAddress); + await taskpool.execute(task1); + + let task2 = new taskpool.Task(store, 1, 2, 3); + await taskpool.execute(task2); + + let task3 = new taskpool.Task(store, 4, 5, 6); + await taskpool.execute(task3); + + let task4 = new taskpool.Task(erase, 3); + await taskpool.execute(task4); + + let task5 = new taskpool.Task(erase, 5); + await taskpool.execute(task5); + + let task6 = new taskpool.Task(clear); + await taskpool.execute(task6); +} +// [End ark_napi_coerce_to_native_binding_object] + +// [Start ark_napi_serialize_deserialize_delete_serialization_data] +class Obj { + numKey: number = 0; +} +// [StartExclude ark_napi_serialize_deserialize_delete_serialization_data] + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiLoadModule', + '2.napiCreateObjectWithProperties', + '3.napiCreateObjectWithNamedProperties', + '4.napiRunScriptPath', + '5.napiCoerceToNativeBindingObject', + '6.napiAboutSerialize', + '7.napiIsSendable', + '8.napiDefineSendableClass', + '9.napiCreateSendableObjectWithProperties', + '10.napiCreateSendableArray', + '11.napiCreateSendableArrayWithLength', + '12.napiCreateSendableArraybuffer', + '13.napiCreateSendableTypedArray', + '14.napiWrapSendable', + '15.napiWrapSendableWithSize', + '16.napiUnwrapSendable', + '17.napiRemoveWrapSendable' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(17) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiLoadModule') { + // [Start ark_node_api_module_add] + hilog.info(0x0000, 'testTag', 'Test Node-API 2 + 3 = %{public}d', testNapi.add(2, 3)); + // [End ark_node_api_module_add] + this.result = 'napiLoadModuleSuccess'; + } else if (item === '2.napiCreateObjectWithProperties') { + // [Start ark_node_api_module_create_object_properties] + // ArkTS Object相关 napi_create_object_with_properties + let value1 = testNapi.createObjectWithProperties('createObject'); + hilog.info(0x0000, 'testTag', 'Node-API napi_create_object_with_properties:%{public}s', + JSON.stringify(value1)); + // [End ark_node_api_module_create_object_properties] + this.result = 'napiCreateObjectWithPropertiesSuccess'; + } else if (item === '3.napiCreateObjectWithNamedProperties') { + // [Start ark_node_api_module_create_object_name_properties] + // ArkTS Object相关 napi_create_object_with_named_properties + let value2 = testNapi.createObjectWithNameProperties('ls'); + hilog.info(0x0000, 'testTag', 'Node-API napi_create_object_with_named_properties:%{public}s', + JSON.stringify(value2)); + // [End ark_node_api_module_create_object_name_properties] + this.result = 'napiCreateObjectWithNamedPropertiesSuccess'; + } else if (item === '4.napiRunScriptPath') { + // [Start ark_node_api_module_run_script_path] + // 运行指定abc文件 napi_run_script_path + try { // 在此处执行错误返回false,成功就返回true + hilog.info(0x0000, 'testTag', 'Test Node-API napi_run_script_path: %{public}s', + testNapi.runScriptPath()); + // [StartExclude ark_node_api_module_run_script_path] + this.result = 'napiRunScriptPathSuccess'; + // [EndExclude ark_node_api_module_run_script_path] + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_run_script_path errorMessage: %{public}s', + error.message); + // [StartExclude ark_node_api_module_run_script_path] + this.result = 'napiRunScriptPathFail'; + // [EndExclude ark_node_api_module_run_script_path] + } + // [End ark_node_api_module_run_script_path] + } else if (item === '5.napiCoerceToNativeBindingObject') { + // 给ArkTS对象绑定回调和回调所需的参数 napi_coerce_to_native_binding_object + test01(); + this.result = 'napiCoerceToNativeBindingObjectSuccess'; + } else if (item === '6.napiAboutSerialize') { + // [EndExclude ark_napi_serialize_deserialize_delete_serialization_data] + // 序列化和反序列化 + let obj: Obj = { numKey: 500 }; + hilog.info(0x0000, 'testTag', ' Node-API aboutSerialize: %{public}d', testNapi.aboutSerialize(obj)); + // [End ark_napi_serialize_deserialize_delete_serialization_data] + this.result = 'napiAboutSerializeSuccess'; + } else if (item === '7.napiIsSendable') { + // [Start ark_napi_is_sendable] + // Sendable相关 napi_is_sendable + let value = testNapi.isSendable('createObject'); + hilog.info(0x0000, 'testTag', 'Node-API napi_is_sendable: %{public}s', JSON.stringify(value)); + // [End ark_napi_is_sendable] + this.result = 'napiIsSendableSuccess'; + } else if (item === '8.napiDefineSendableClass') { + // [Start ark_napi_define_sendable_class] + // Sendable相关 napi_define_sendable_class + let value = new testNapi.SendableClass(); + hilog.info(0x0000, 'testTag', 'Node-API napi_define_sendable_class: %{public}s', value.str); + // [End ark_napi_define_sendable_class] + this.result = 'napiDefineSendableClassSuccess'; + } else if (item === '9.napiCreateSendableObjectWithProperties') { + // [Start ark_napi_create_sendable_object_with_properties] + // Sendable相关 napi_create_sendable_object_with_properties + let value = testNapi.getSendableObject(); + hilog.info(0x0000, 'testTag', 'Node-API napi_create_sendable_object_with_properties: %{public}s', + JSON.stringify(value)); + // [End ark_napi_create_sendable_object_with_properties] + this.result = 'napiCreateSendableObjectWithPropertiesSuccess'; + } else if (item === '10.napiCreateSendableArray') { + // [Start ark_napi_create_sendable_array] + // Sendable相关 napi_create_sendable_array + let value = testNapi.getSendableArray(); + hilog.info(0x0000, 'testTag', 'Node-API napi_create_sendable_array: %{public}s', + JSON.stringify(value)); + // [End ark_napi_create_sendable_array] + this.result = 'napiCreateSendableArraySuccess'; + } else if (item === '11.napiCreateSendableArrayWithLength') { + // [Start ark_napi_create_sendable_array_with_length] + // Sendable相关 napi_create_sendable_array_with_length + let value = testNapi.getSendableArrayWithLength(); + hilog.info(0x0000, 'testTag', 'Node-API napi_create_sendable_array_with_length: %{public}s', + JSON.stringify(value.length)); + // [End ark_napi_create_sendable_array_with_length] + this.result = 'napiCreateSendableArrayWithLengthSuccess'; + } else if (item === '12.napiCreateSendableArraybuffer') { + // [Start ark_napi_create_sendable_arraybuffer] + // Sendable相关 napi_create_sendable_arraybuffer + testNapi.getSendableArrayBuffer(); + // [End ark_napi_create_sendable_arraybuffer] + this.result = 'napiCreateSendableArraybufferSuccess'; + } else if (item === '13.napiCreateSendableTypedArray') { + // [Start ark_napi_create_sendable_typed_array] + // Sendable相关 napi_create_sendable_typedarray + testNapi.getSendableTypedArray(); + // [End ark_napi_create_sendable_typed_array] + this.result = 'napiCreateSendableTypedArraySuccess'; + } else if (item === '14.napiWrapSendable') { + // [Start ark_napi_wrap_sendable] + // Sendable相关 napi_wrap_sendable + testNapi.wrapSendable(); + // [End ark_napi_wrap_sendable] + this.result = 'napiWrapSendableSuccess'; + } else if (item === '15.napiWrapSendableWithSize') { + // [Start ark_napi_wrap_sendable_with_size] + // Sendable相关 napi_wrap_sendable_with_size + testNapi.wrapSendableWithSize(); + // [End ark_napi_wrap_sendable_with_size] + this.result = 'napiWrapSendableWithSizeSuccess'; + } else if (item === '16.napiUnwrapSendable') { + // [Start ark_napi_unwrap_sendable] + // Sendable相关 napi_unwrap_sendable + testNapi.unwrapSendable(); + // [End ark_napi_unwrap_sendable] + this.result = 'napiUnwrapSendableSuccess'; + } else if (item === '17.napiRemoveWrapSendable') { + // [Start ark_napi_remove_wrap_sendable] + // Sendable相关 napi_remove_wrap_sendable + testNapi.removeWrapSendable(); + // [End ark_napi_remove_wrap_sendable] + this.result = 'napiRemoveWrapSendableSuccess'; + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + .id('List') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/rawfile/test.abc b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/rawfile/test.abc old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/rawfile/test.abc rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/rawfile/test.abc diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/NodeAPIExtendCapabilities.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/NodeAPIExtendCapabilities.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/NodeAPIExtendCapabilities.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/NodeAPIExtendCapabilities.test.ets index 77950eed60..9d921ccf59 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/NodeAPIExtendCapabilities.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/ets/test/NodeAPIExtendCapabilities.test.ets @@ -1,318 +1,318 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIExtendCapabilitiesTest() { - describe('nodeAPIExtendCapabilitiesTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击,调用napiLoadModule相关函数 - */ - it('testNodeAPIExtendCapabilities001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiLoadModule')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiLoadModuleSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities001 end'); - done(); - }) - - /** - * 点击,调用napiCreateObjectWithProperties相关函数 - */ - it('testNodeAPIExtendCapabilities002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiCreateObjectWithProperties')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateObjectWithPropertiesSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities002 end'); - done(); - }) - - /** - * 点击,调用napiCreateObjectWithNamedProperties相关函数 - */ - it('testNodeAPIExtendCapabilities003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiCreateObjectWithNamedProperties')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateObjectWithNamedPropertiesSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities003 end'); - done(); - }) - - /** - * 点击,调用napiRunScriptPath相关函数 - */ - it('testNodeAPIExtendCapabilities004', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('4.napiRunScriptPath')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiRunScriptPathSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities004 end'); - done(); - }) - - /** - * 点击,调用napiCoerceToNativeBindingObject相关函数 - */ - it('testNodeAPIExtendCapabilities005', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('5.napiCoerceToNativeBindingObject')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCoerceToNativeBindingObjectSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities005 end'); - done(); - }) - - /** - * 点击,调用napiAboutSerialize相关函数 - */ - it('testNodeAPIExtendCapabilities006', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('6.napiAboutSerialize')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiAboutSerializeSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities006 end'); - done(); - }) - - /** - * 点击,调用napiIsSendable相关函数 - */ - it('testNodeAPIExtendCapabilities007', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities007 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('7.napiIsSendable')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiIsSendableSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities007 end'); - done(); - }) - - /** - * 点击,调用napiDefineSendableClass相关函数 - */ - it('testNodeAPIExtendCapabilities008', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities008 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('8.napiDefineSendableClass')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiDefineSendableClassSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities008 end'); - done(); - }) - - /** - * 点击,调用napiCreateSendableObjectWithProperties相关函数 - */ - it('testNodeAPIExtendCapabilities009', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities009 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('9.napiCreateSendableObjectWithProperties')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateSendableObjectWithPropertiesSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities009 end'); - done(); - }) - - /** - * 点击,调用napiCreateSendableArray相关函数 - */ - it('testNodeAPIExtendCapabilities010', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities010 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('10.napiCreateSendableArray')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateSendableArraySuccess')); - console.info('uitest: testNodeAPIExtendCapabilities010 end'); - done(); - }) - - /** - * 点击,调用napiCreateSendableArrayWithLength相关函数 - */ - it('testNodeAPIExtendCapabilities011', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities011 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const list = await driver.findComponent(ON.id('List')) - await list.scrollToBottom(); - const text = await driver.findComponent(ON.text('11.napiCreateSendableArrayWithLength')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateSendableArrayWithLengthSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities011 end'); - done(); - }) - - /** - * 点击,调用napiCreateSendableArraybuffer相关函数 - */ - it('testNodeAPIExtendCapabilities012', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities012 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('12.napiCreateSendableArraybuffer')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateSendableArraybufferSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities012 end'); - done(); - }) - - /** - * 点击,调用napiCreateSendableTypedArray相关函数 - */ - it('testNodeAPIExtendCapabilities013', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray013 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('13.napiCreateSendableTypedArray')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateSendableTypedArraySuccess')); - console.info('uitest: testNodeAPIArray013 end'); - done(); - }) - - /** - * 点击,调用napiWrapSendable相关函数 - */ - it('testNodeAPIExtendCapabilities014', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities014 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('14.napiWrapSendable')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiWrapSendableSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities014 end'); - done(); - }) - - /** - * 点击,调用napiWrapSendableWithSize相关函数 - */ - it('testNodeAPIExtendCapabilities015', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities015 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('15.napiWrapSendableWithSize')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiWrapSendableWithSizeSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities015 end'); - done(); - }) - - /** - * 点击,调用napiUnwrapSendable相关函数 - */ - it('testNodeAPIExtendCapabilities016', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities016 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('16.napiUnwrapSendable')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiUnwrapSendableSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities016 end'); - done(); - }) - - /** - * 点击,调用napiRemoveWrapSendable相关函数 - */ - it('testNodeAPIExtendCapabilities017', 0, async (done: Function) => { - console.info('uitest: testNodeAPIExtendCapabilities017 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('17.napiRemoveWrapSendable')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiRemoveWrapSendableSuccess')); - console.info('uitest: testNodeAPIExtendCapabilities017 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIExtendCapabilitiesTest() { + describe('nodeAPIExtendCapabilitiesTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击,调用napiLoadModule相关函数 + */ + it('testNodeAPIExtendCapabilities001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiLoadModule')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiLoadModuleSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities001 end'); + done(); + }) + + /** + * 点击,调用napiCreateObjectWithProperties相关函数 + */ + it('testNodeAPIExtendCapabilities002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiCreateObjectWithProperties')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateObjectWithPropertiesSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities002 end'); + done(); + }) + + /** + * 点击,调用napiCreateObjectWithNamedProperties相关函数 + */ + it('testNodeAPIExtendCapabilities003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiCreateObjectWithNamedProperties')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateObjectWithNamedPropertiesSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities003 end'); + done(); + }) + + /** + * 点击,调用napiRunScriptPath相关函数 + */ + it('testNodeAPIExtendCapabilities004', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('4.napiRunScriptPath')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiRunScriptPathSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities004 end'); + done(); + }) + + /** + * 点击,调用napiCoerceToNativeBindingObject相关函数 + */ + it('testNodeAPIExtendCapabilities005', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('5.napiCoerceToNativeBindingObject')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCoerceToNativeBindingObjectSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities005 end'); + done(); + }) + + /** + * 点击,调用napiAboutSerialize相关函数 + */ + it('testNodeAPIExtendCapabilities006', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('6.napiAboutSerialize')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiAboutSerializeSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities006 end'); + done(); + }) + + /** + * 点击,调用napiIsSendable相关函数 + */ + it('testNodeAPIExtendCapabilities007', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities007 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('7.napiIsSendable')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiIsSendableSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities007 end'); + done(); + }) + + /** + * 点击,调用napiDefineSendableClass相关函数 + */ + it('testNodeAPIExtendCapabilities008', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities008 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('8.napiDefineSendableClass')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiDefineSendableClassSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities008 end'); + done(); + }) + + /** + * 点击,调用napiCreateSendableObjectWithProperties相关函数 + */ + it('testNodeAPIExtendCapabilities009', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities009 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('9.napiCreateSendableObjectWithProperties')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateSendableObjectWithPropertiesSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities009 end'); + done(); + }) + + /** + * 点击,调用napiCreateSendableArray相关函数 + */ + it('testNodeAPIExtendCapabilities010', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities010 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('10.napiCreateSendableArray')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateSendableArraySuccess')); + console.info('uitest: testNodeAPIExtendCapabilities010 end'); + done(); + }) + + /** + * 点击,调用napiCreateSendableArrayWithLength相关函数 + */ + it('testNodeAPIExtendCapabilities011', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities011 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const list = await driver.findComponent(ON.id('List')) + await list.scrollToBottom(); + const text = await driver.findComponent(ON.text('11.napiCreateSendableArrayWithLength')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateSendableArrayWithLengthSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities011 end'); + done(); + }) + + /** + * 点击,调用napiCreateSendableArraybuffer相关函数 + */ + it('testNodeAPIExtendCapabilities012', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities012 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('12.napiCreateSendableArraybuffer')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateSendableArraybufferSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities012 end'); + done(); + }) + + /** + * 点击,调用napiCreateSendableTypedArray相关函数 + */ + it('testNodeAPIExtendCapabilities013', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray013 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('13.napiCreateSendableTypedArray')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateSendableTypedArraySuccess')); + console.info('uitest: testNodeAPIArray013 end'); + done(); + }) + + /** + * 点击,调用napiWrapSendable相关函数 + */ + it('testNodeAPIExtendCapabilities014', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities014 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('14.napiWrapSendable')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiWrapSendableSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities014 end'); + done(); + }) + + /** + * 点击,调用napiWrapSendableWithSize相关函数 + */ + it('testNodeAPIExtendCapabilities015', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities015 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('15.napiWrapSendableWithSize')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiWrapSendableWithSizeSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities015 end'); + done(); + }) + + /** + * 点击,调用napiUnwrapSendable相关函数 + */ + it('testNodeAPIExtendCapabilities016', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities016 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('16.napiUnwrapSendable')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiUnwrapSendableSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities016 end'); + done(); + }) + + /** + * 点击,调用napiRemoveWrapSendable相关函数 + */ + it('testNodeAPIExtendCapabilities017', 0, async (done: Function) => { + console.info('uitest: testNodeAPIExtendCapabilities017 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('17.napiRemoveWrapSendable')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiRemoveWrapSendableSuccess')); + console.info('uitest: testNodeAPIExtendCapabilities017 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/ohosTest.md new file mode 100644 index 0000000000..607ec76e71 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/ohosTest.md @@ -0,0 +1,23 @@ +# 使用Node-API进行扩展能力功能开发测试用例归档 + +## 用例表 + +| 测试功能 | 预 置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------------------ | ------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 createObjectWithProperties | 位于主页 | 点击文本为1.napiCreateObjectWithProperties的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateObjectWithPropertiesSuccess | Pass | +| ArkTS端成功调用native侧接口createObjectWithNameProperties | 位于主页 | 点击文本为2.napiCreateObjectWithNamedProperties的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateObjectWithNamedPropertiesSuccess | Pass | +| ArkTS端成功调用native侧接口runScriptPath | 位于主页 | 点击文本为3.napiRunScriptPath的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiRunScriptPathSuccess | Pass | +| ArkTS端成功调用native侧接口getAddress,getSetSize,store,erase,clear | 位于主页 | 点击文本为4.napiCoerceToNativeBindingObject的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCoerceToNativeBindingObjectSuccess | Pass | +| ArkTS端成功调用native侧接口aboutSerialize | 位于主页 | 点击文本为5.napiAboutSerialize的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiAboutSerializeSuccess | Pass | +| ArkTS端成功调用native侧接口isSendable | 位于主页 | 点击文本为6.napiIsSendable的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsSendableSuccess | Pass | +| ArkTS端成功调用native侧接口SendableClass | 位于主页 | 点击文本为7.napiDefineSendableClass的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDefineSendableClassSuccess | Pass | +| ArkTS端成功调用native侧接口getSendableObject | 位于主页 | 点击文本为8.napiCreateSendableObjectWithProperties的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSendableObjectWithPropertiesSuccess | Pass | +| ArkTS端成功调用native侧接口getSendableArray | 位于主页 | 点击文本为9.napiCreateSendableArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSendableArraySuccess | Pass | +| ArkTS端成功调用native侧接口getSendableArrayWithLength | 位于主页 | 点击文本为10.napiCreateSendableArrayWithLength的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSendableArrayWithLengthSuccess | Pass | +| ArkTS端成功调用native侧接口getSendableArrayBuffer | 位于主页 | 点击文本为11.napiCreateSendableArraybuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSendableArraybufferSuccess | Pass | +| ArkTS端成功调用native侧接口getSendableTypedArray | 位于主页 | 点击文本为12.napiCreateSendableTypedArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSendableTypedArraySuccess | Pass | +| ArkTS端成功调用native侧接口wrapSendable | 位于主页 | 点击文本为13.napiWrapSendable的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiWrapSendableSuccess | Pass | +| ArkTS端成功调用native侧接口wrapSendableWithSize | 位于主页 | 点击文本为14.napiWrapSendableWithSize的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiWrapSendableWithSizeSuccess | Pass | +| ArkTS端成功调用native侧接口unwrapSendable | 位于主页 | 点击文本为15.napiUnwrapSendable的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiUnwrapSendableSuccess | Pass | +| ArkTS端成功调用native侧接口removeWrapSendable | 位于主页 | 点击文本为16.napiRemoveWrapSendable的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiRemoveWrapSendableSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/screenshots/NodeAPIExtendCapabilities1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/screenshots/NodeAPIExtendCapabilities1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/screenshots/NodeAPIExtendCapabilities1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/screenshots/NodeAPIExtendCapabilities1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/screenshots/NodeAPIExtendCapabilities2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/screenshots/NodeAPIExtendCapabilities2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/screenshots/NodeAPIExtendCapabilities2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/screenshots/NodeAPIExtendCapabilities2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/app.json5 new file mode 100644 index 0000000000..387aa7412d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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.nodeapifunction", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..1ed347339c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIFunction" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/README.md new file mode 100644 index 0000000000..153bb70af4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行function相关开发 + +### 介绍 + +函数调用允许开发者从Node-API模块中调用ArkTS函数,并传递参数进行调用,或者直接在Node-API模块中创建一个ArkTS方法,本工程中展示的代码详细描述可查如下链接。 + +- [使用Node-API进行function相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-function.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIFunction.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行function相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIFunction.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..3e73eccd5e --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIFunctio) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..3ad39888a6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_get_cb_info] +#include "napi/native_api.h" + +// napi_get_cb_info +// 获取ArkTS侧入参的的参数信息 +static napi_value GetCbArgs(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + return args[0]; +} + +// 获取ArkTS侧入参的参数个数 +static napi_value GetCbArgQuantity(napi_env env, napi_callback_info info) +{ + size_t argc = 0; + napi_value result = nullptr; + napi_get_cb_info(env, info, &argc, nullptr, nullptr, nullptr); + napi_create_int32(env, argc, &result); + return result; +} + +// 获取ArkTS侧this参数 +static napi_value GetCbContext(napi_env env, napi_callback_info info) +{ + napi_value thisArg = nullptr; + napi_get_cb_info(env, info, nullptr, nullptr, &thisArg, nullptr); + return thisArg; +} +// [End napi_get_cb_info] + +// [Start napi_call_function] +// napi_call_function +static napi_value CallFunction(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value argv[1] = {nullptr}; + // 获取ArkTS侧入参 + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + // 获取全局对象,这里用global是因为napi_call_function的第二个参数是JS函数的this入参。 + napi_value global = nullptr; + napi_get_global(env, &global); + // 调用ArkTS方法 + napi_value result = nullptr; + // 调用napi_call_function时传入的argv的长度必须大于等于argc声明的数量,且被初始化成nullptr + napi_call_function(env, global, argv[0], argc, argv, &result); + return result; +} + +static napi_value ObjCallFunction(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传递的两个参数 + size_t argc = 2; + napi_value argv[2] = {nullptr}; + // 获取ArkTS侧入参 + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + // 调用ArkTS方法 + napi_value result = nullptr; + // 调用napi_call_function时传入的argv的长度必须大于等于argc声明的数量,且被初始化成nullptr + napi_call_function(env, argv[0], argv[1], argc, argv, &result); + return result; +} +// [End napi_call_function] + +// [Start napi_create_function] +// napi_create_function +static napi_value CalculateArea(napi_env env, napi_callback_info info) +{ + // 获取ArkTS侧传递的两个参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + double width = 0; + napi_get_value_double(env, args[0], &width); + double height = 0; + napi_get_value_double(env, args[1], &height); + napi_value area = nullptr; + napi_create_double(env, width * height, &area); + return area; +} +// [End napi_create_function] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"getCbArgs", nullptr, GetCbArgs, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getCbArgQuantity", nullptr, GetCbArgQuantity, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getCbContext", nullptr, GetCbContext, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"callFunction", nullptr, CallFunction, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"objCallFunction", nullptr, ObjCallFunction, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_value fn = nullptr; + napi_create_function(env, nullptr, 0, CalculateArea, nullptr, &fn); + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + napi_set_named_property(env, exports, "calculateArea", fn); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..2c93ee618e --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_get_cb_info_api] +export const getCbArgs: (arg: T) => T; // napi_get_cb_info + +// getCbArgQuantity的入参由用户自定义,在此用例中,我们用两个入参,一个是string,一个是number +export const getCbArgQuantity: (str: string, num: number) => number; + +export const getCbContext: () => Object; +// [End napi_get_cb_info_api] + +// [Start napi_call_function_api] +export const callFunction: (func: Function) => number; // napi_call_function + +export const objCallFunction: (obj: Object, func: Function) => number; +// [End napi_call_function_api] + +// [Start napi_create_function_api] +export const calculateArea: (width: number, height: number) => number; // napi_create_function +// [End napi_create_function_api] diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..17e4121c9f --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start ark_napi_get_cb_info] +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; + +function summation(arr: Array) { + let sum: number = 0; + for (let i = 0; i < arr.length; i++) { + sum += arr[i]; + } + return sum; +} + +const str = 'message'; +const arr = [0, 1, 2, 3, 4, 5]; +const num = 526; + +class Student { + name: string; + age: number; + score: number; + + constructor(name: string, age: number, score: number) { + this.name = name; + this.age = age; + this.score = score; + } +} + +// [StartExclude ark_napi_get_cb_info] +// [Start ark_napi_call_function] +function returnNumber() { + return 10; +} + +class Person { + age(): number { + return 11; + } +} + +// [StartExclude ark_napi_call_function] +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiGetCbInfo', + '2.napiCallFunction', + '3.napiCreateFunction' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(25) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiGetCbInfo') { + // [EndExclude ark_napi_get_cb_info] + // napi_get_cb_info + let student = new Student('Alice', 18, 100); + // 获取参数 + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get string arg:%{public}s', + testNapi.getCbArgs(str)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get array arg:%{public}s ', + testNapi.getCbArgs(arr).toString()); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get num arg:%{public}d ', + testNapi.getCbArgs(num)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get undefined arg:%{public}s ', + testNapi.getCbArgs(undefined)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get object arg:%{public}s ', + JSON.stringify(testNapi.getCbArgs(student))); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get function arg:%{public}d ', + testNapi.getCbArgs(summation(arr))); + // 获取参数个数 + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get arg quantity:%{public}d ', + testNapi.getCbArgQuantity(str, num)); + // 获取上下文 + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get thisArg:%{public}s ', + testNapi.getCbContext().toString()); + // [End ark_napi_get_cb_info] + this.result = 'napiGetCbInfoSuccess'; + } else if (item === '2.napiCallFunction') { + // [EndExclude ark_napi_call_function] + // napi_call_function + const person = new Person(); + hilog.info(0x0000, 'testTag', 'Test Node-API call_function:%{public}d', + testNapi.callFunction(returnNumber)); + hilog.info(0x0000, 'testTag', 'Test Node-API call_function:%{public}d', + testNapi.objCallFunction(person, person.age)); + // [End ark_napi_call_function] + this.result = 'napiCallFunctionSuccess'; + } else if (item === '3.napiCreateFunction') { + // [Start ark_napi_create_function] + // napi_create_function + hilog.info(0x0000, 'testTag', 'Test Node-API create_function:%{public}d ', + testNapi.calculateArea(1.2, 4)); + // [End ark_napi_create_function] + this.result = 'napiCreateFunctionSuccess'; + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/NodeAPIFunction.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/NodeAPIFunction.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/NodeAPIFunction.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/NodeAPIFunction.test.ets index e96bf7cf14..a6c99e1554 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/NodeAPIFunction.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/ets/test/NodeAPIFunction.test.ets @@ -1,92 +1,92 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIFunctionTest() { - describe('nodeAPIFunctionTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击,调用napiGetCbInfo相关函数 - */ - it('testNodeAPIFunction001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiGetCbInfo')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetCbInfoSuccess')); - console.info('uitest: testNodeAPIArray001 end'); - done(); - }) - - /** - * 点击,调用napiCallFunction相关函数 - */ - it('testNodeAPIFunction002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIFunction002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiCallFunction')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCallFunctionSuccess')); - console.info('uitest: testNodeAPIFunction002 end'); - done(); - }) - - /** - * 点击,调用napiCreateFunction相关函数 - */ - it('testNodeAPIFunction003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIFunction003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiCreateFunction')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateFunctionSuccess')); - console.info('uitest: testNodeAPIFunction003 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIFunctionTest() { + describe('nodeAPIFunctionTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击,调用napiGetCbInfo相关函数 + */ + it('testNodeAPIFunction001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiGetCbInfo')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetCbInfoSuccess')); + console.info('uitest: testNodeAPIArray001 end'); + done(); + }) + + /** + * 点击,调用napiCallFunction相关函数 + */ + it('testNodeAPIFunction002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIFunction002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiCallFunction')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCallFunctionSuccess')); + console.info('uitest: testNodeAPIFunction002 end'); + done(); + }) + + /** + * 点击,调用napiCreateFunction相关函数 + */ + it('testNodeAPIFunction003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIFunction003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiCreateFunction')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateFunctionSuccess')); + console.info('uitest: testNodeAPIFunction003 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/ohosTest.md new file mode 100644 index 0000000000..2185351bc1 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/ohosTest.md @@ -0,0 +1,10 @@ +# 使用Node-API进行function相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------------------ | ------------ | ---------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 getCbArgs,getCbArgQuantity,getCbContext | 位于主页 | 点击文本为1.napiGetCbInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetCbInfoSuccess | Pass | +| ArkTS端成功调用native侧接口callFunction,objCallFunction | 位于主页 | 点击文本为2.napiCallFunction的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCallFunctionSuccess | Pass | +| ArkTS端成功调用native侧接口calculateArea | 位于主页 | 点击文本为3.napiCreateFunction的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateFunctionSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/screenshots/NodeAPIFunction1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/screenshots/NodeAPIFunction1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/screenshots/NodeAPIFunction1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/screenshots/NodeAPIFunction1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/screenshots/NodeAPIFunction2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/screenshots/NodeAPIFunction2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/screenshots/NodeAPIFunction2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIFunction/screenshots/NodeAPIFunction2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/app.json5 new file mode 100644 index 0000000000..3c4059b649 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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.nodeapilifecycle", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..614dd49c77 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPILifeCycle" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/README.md new file mode 100644 index 0000000000..9b33a55933 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行life-cycle相关开发 + +### 介绍 + +在Node-API中,napi_value是一个表示ArkTS值的抽象类型,它可以表示任何ArkTS值,包括基本类型(如数字、字符串、布尔值)和复杂对象类型(如数组、函数、对象等),napi_value的生命周期与其在ArkTS中的对应值的生命周期紧密相关。当ArkTS值被垃圾回收时,与之关联的napi_value也将不再有效。重要的是不要在ArkTS值不再存在时尝试使用napi_value,框架层的scope通常用于管理napi_value的生命周期。在Node-API中,可以使用napi_open_handle_scope和napi_close_handle_scope函数来创建和销毁scope。通过在scope内创建napi_value,可以确保在scope结束时自动释放napi_value,避免内存泄漏,napi_ref是一个Node-API类型,用于管理napi_value的生命周期。napi_ref允许您在napi_value的生命周期内保持对其的引用,即使它已经超出了其原始上下文的范围。这使得您可以在不同的上下文中共享napi_value,并确保在不再需要时正确释放其内存,本工程中展示的代码详细描述可查如下链接。 + +- [使用Node-API进行life-cycle相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-life-cycle.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPILifeCycle.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行life-cycle相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPILifeCycle.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..14f9035365 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPILifeCycle) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..11d42cc90b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,196 @@ +/* + * 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 "hilog/log.h" +#include "napi/native_api.h" + +// [Start napi_open_close_handle_scope] +// napi_open_handle_scope、napi_close_handle_scope +static napi_value HandleScopeTest(napi_env env, napi_callback_info info) +{ + // 通过调用napi_open_handle_scope来创建一个句柄作用域 + napi_handle_scope scope; + napi_open_handle_scope(env, &scope); + // 在句柄作用域内创建一个obj + napi_value obj = nullptr; + napi_create_object(env, &obj); + // 在对象中添加属性 + napi_value value = nullptr; + napi_create_string_utf8(env, "handleScope", NAPI_AUTO_LENGTH, &value); + napi_set_named_property(env, obj, "key", value); + // 在作用域内获取obj的属性并返回 + napi_value result = nullptr; + napi_get_named_property(env, obj, "key", &result); + // 关闭句柄作用域,自动释放在该作用域内创建的对象句柄 + napi_close_handle_scope(env, scope); + // 此处的result能够得到值“handleScope” + return result; +} + +static napi_value HandleScope(napi_env env, napi_callback_info info) +{ + // 通过调用napi_open_handle_scope来创建一个句柄作用域 + napi_handle_scope scope; + napi_open_handle_scope(env, &scope); + // 在句柄作用域内创建一个obj + napi_value obj = nullptr; + napi_create_object(env, &obj); + // 在对象中添加属性 + napi_value value = nullptr; + napi_create_string_utf8(env, "handleScope", NAPI_AUTO_LENGTH, &value); + napi_set_named_property(env, obj, "key", value); + // 关闭句柄作用域,自动释放在该作用域内创建的对象句柄 + napi_close_handle_scope(env, scope); + // 在作用域外获取obj的属性并返回,此处只能得到“undefined” + napi_value result = nullptr; + napi_get_named_property(env, obj, "key", &result); + return result; +} +// [End napi_open_close_handle_scope] + +// [Start napi_open_close_escapable_handle_scope] +// napi_open_escapable_handle_scope、napi_close_escapable_handle_scope、napi_escape_handle +static napi_value EscapableHandleScopeTest(napi_env env, napi_callback_info info) +{ + // 创建一个可逃逸的句柄作用域 + napi_escapable_handle_scope scope; + napi_open_escapable_handle_scope(env, &scope); + // 在可逃逸的句柄作用域内创建一个obj + napi_value obj = nullptr; + napi_create_object(env, &obj); + // 在对象中添加属性 + napi_value value = nullptr; + napi_create_string_utf8(env, "Test napi_escapable_handle_scope", NAPI_AUTO_LENGTH, &value); + napi_set_named_property(env, obj, "key", value); + // 调用napi_escape_handle将对象逃逸到作用域之外 + napi_value escapedObj = nullptr; + napi_escape_handle(env, scope, obj, &escapedObj); + // 关闭可逃逸的句柄作用域,清理资源 + napi_close_escapable_handle_scope(env, scope); + // 在获取逃逸后的obj:escapedObj的属性并返回,此处也能够得到“napi_escapable_handle_scope” + napi_value result = nullptr; + // 为了验证逃逸的实现,可以在此处获取obj的属性,此处会得到“undefined” + napi_get_named_property(env, escapedObj, "key", &result); + return result; +} +// [End napi_open_close_escapable_handle_scope] + +// [Start napi_create_delete_reference] +// 创建一个指向napi_ref类型的指针,用于存储创建的引用。在调用napi_create_reference函数之前,你需要分配一个napi_ref类型的变量,并将其地址传递给result位置的参数 +napi_ref g_ref; + +void Finalizer(napi_env env, void *data, void *hint) +{ + // 执行资源清理操作 + OH_LOG_INFO(LOG_APP, "Node-API: Use terminators to release resources."); +} + +static napi_value CreateReference(napi_env env, napi_callback_info info) +{ + napi_value obj = nullptr; + napi_create_object(env, &obj); + napi_value value = nullptr; + napi_create_string_utf8(env, "CreateReference", NAPI_AUTO_LENGTH, &value); + // 将键值对添加到对象中 + napi_set_named_property(env, obj, "key", value); + // [StartExclude napi_create_delete_reference] + // 创建对ArkTS对象的引用 + napi_status status = napi_create_reference(env, obj, 1, &g_ref); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_create_reference fail"); + return nullptr; + } + // [EndExclude napi_create_delete_reference] + // 添加终结器 + void *data = {}; + napi_add_finalizer(env, obj, data, Finalizer, nullptr, &g_ref); + // 增加传入引用的引用计数并返回生成的引用计数 + uint32_t result = 0; + napi_reference_ref(env, g_ref, &result); + OH_LOG_INFO(LOG_APP, "napi_reference_ref, count = %{public}d.", result); + uint32_t numCount = 2; + if (result != numCount) { + // 若传入引用的引用计数未增加,则抛出错误 + napi_throw_error(env, nullptr, "napi_reference_ref fail"); + return nullptr; + } + return obj; +} + +static napi_value UseReference(napi_env env, napi_callback_info info) +{ + napi_value obj = nullptr; + // 通过调用napi_get_reference_value获取引用的ArkTS对象 + napi_status status = napi_get_reference_value(env, g_ref, &obj); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_get_reference_value fail"); + return nullptr; + } + // 将获取到的对象返回 + return obj; +} + +static napi_value DeleteReference(napi_env env, napi_callback_info info) +{ + // 减少传入引用的引用计数并返回生成的引用计数 + uint32_t result = 0; + napi_value count = nullptr; + napi_reference_unref(env, g_ref, &result); + OH_LOG_INFO(LOG_APP, "napi_reference_ref, count = %{public}d.", result); + uint32_t numCount = 1; + if (result != numCount) { + // 若传入引用的引用计数未减少,则抛出错误 + napi_throw_error(env, nullptr, "napi_reference_unref fail"); + return nullptr; + } + // 通过调用napi_delete_reference删除对ArkTS对象的引用 + napi_status status = napi_delete_reference(env, g_ref); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_delete_reference fail"); + return nullptr; + } + napi_value returnResult = nullptr; + napi_create_string_utf8(env, "napi_delete_reference success", NAPI_AUTO_LENGTH, &returnResult); + return returnResult; +} +// [End napi_create_delete_reference] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"handleScopeTest", nullptr, HandleScopeTest, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"handleScope", nullptr, HandleScope, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"escapableHandleScopeTest", nullptr, EscapableHandleScopeTest, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"createReference", nullptr, CreateReference, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"useReference", nullptr, UseReference, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"deleteReference", nullptr, DeleteReference, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..83a3655c86 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_open_close_handle_scope_api] +export const handleScopeTest: () => string; // napi_open_handle_scope、napi_close_handle_scope + +export const handleScope: () => string; +// [End napi_open_close_handle_scope_api] + +// [Start napi_open_close_escapable_handle_scope_api] +export const escapableHandleScopeTest: () => string; // napi_open_escapable_handle_scope、napi_close_escapable_handle_scope、napi_escape_handle +// [End napi_open_close_escapable_handle_scope_api] + +// [Start napi_create_delete_reference_api] +export const createReference: () => Object | void; // napi_add_finalizer + +export const useReference: () => Object | void; + +export const deleteReference: () => string | void; +// [End napi_create_delete_reference_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..dfca35ef52 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,121 @@ +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiOpenHandleScope', + '2.napiOpenEscapableHandleScope', + '3.napiAddFinalizer' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiOpenHandleScope') { + // [Start ark_napi_open_close_handle_scope] + // napi_open_handle_scope napi_close_handle_scope + try { + hilog.info(0x0000, 'testTag', 'Test Node-API handleScopeTest: %{public}s', + testNapi.handleScopeTest()); + hilog.info(0x0000, 'testTag', 'Test Node-API handleScope: %{public}s', testNapi.handleScope()); + // [StartExclude ark_napi_open_close_handle_scope] + this.result = 'napiOpenHandleScopeSuccess'; + // [EndExclude ark_napi_open_close_handle_scope] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API handleScopeTest errorCode: %{public}s, errorMessage: %{public}s', error.code, + error.message); + // [StartExclude ark_napi_open_close_handle_scope] + this.result = 'napiOpenHandleScopeFail'; + // [EndExclude ark_napi_open_close_handle_scope] + } + // [End ark_napi_open_close_handle_scope] + } else if (item === '2.napiOpenEscapableHandleScope') { + // [Start ark_napi_open_close_escapable_handle_scope] + // napi_open_escapable_handle_scope napi_close_escapable_handle_scope、napi_escape_handle + try { + hilog.info(0x0000, 'testTag', 'Test Node-API EscapableHandleScopeTest: %{public}s', + testNapi.escapableHandleScopeTest()); + // [StartExclude ark_napi_open_close_escapable_handle_scope] + this.result = 'napiOpenEscapableHandleScopeSuccess'; + // [EndExclude ark_napi_open_close_escapable_handle_scope] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API EscapableHandleScopeTest errorCode: %{public}s, errorMessage: %{public}s', + error.code, + error.message); + // [StartExclude ark_napi_open_close_escapable_handle_scope] + this.result = 'napiOpenEscapableHandleScopeFail'; + // [EndExclude ark_napi_open_close_escapable_handle_scope] + } + // [End ark_napi_open_close_escapable_handle_scope] + } else if (item === '3.napiAddFinalizer') { + // [Start ark_napi_create_delete_reference] + // napi_add_finalizer + try { + hilog.info(0x0000, 'testTag', 'Test Node-API createReference: %{public}s', + JSON.stringify(testNapi.createReference())); + hilog.info(0x0000, 'testTag', 'Test Node-API useReference: %{public}s', + JSON.stringify(testNapi.useReference())); + hilog.info(0x0000, 'testTag', 'Test Node-API deleteReference: %{public}s', + testNapi.deleteReference()); + // [StartExclude ark_napi_create_delete_reference] + this.result = 'napiAddFinalizerSuccess'; + // [EndExclude ark_napi_create_delete_reference] + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API ReferenceTest errorCode: %{public}s, errorMessage: %{public}s', error.code, + error.message); + // [StartExclude ark_napi_create_delete_reference] + this.result = 'napiAddFinalizerFail'; + // [EndExclude ark_napi_create_delete_reference] + } + // [End ark_napi_create_delete_reference] + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/NodeAPILifeCycle.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/NodeAPILifeCycle.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/NodeAPILifeCycle.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/NodeAPILifeCycle.test.ets index f87901c5c8..09225b5744 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/NodeAPILifeCycle.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/ets/test/NodeAPILifeCycle.test.ets @@ -1,92 +1,92 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPILifeCycleTest() { - describe('nodeAPILifeCycleTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiOpenHandleScope相关函数 - */ - it('testNodeAPILifeCycle001', 0, async (done: Function) => { - console.info('uitest: testNodeAPILifeCycle001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiOpenHandleScope')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiOpenHandleScopeSuccess')); - console.info('uitest: testNodeAPILifeCycle001 end'); - done(); - }) - - /** - * 点击按钮,调用napiOpenEscapableHandleScope相关函数 - */ - it('testNodeAPILifeCycle002', 0, async (done: Function) => { - console.info('uitest: testNodeAPILifeCycle002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiOpenEscapableHandleScope')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiOpenEscapableHandleScopeSuccess')); - console.info('uitest: testNodeAPILifeCycle002 end'); - done(); - }) - - /** - * 点击按钮,调用napiAddFinalizer相关函数 - */ - it('testNodeAPILifeCycle003', 0, async (done: Function) => { - console.info('uitest: testNodeAPILifeCycle003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiAddFinalizer')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiAddFinalizerSuccess')); - console.info('uitest: testNodeAPILifeCycle003 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPILifeCycleTest() { + describe('nodeAPILifeCycleTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiOpenHandleScope相关函数 + */ + it('testNodeAPILifeCycle001', 0, async (done: Function) => { + console.info('uitest: testNodeAPILifeCycle001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiOpenHandleScope')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiOpenHandleScopeSuccess')); + console.info('uitest: testNodeAPILifeCycle001 end'); + done(); + }) + + /** + * 点击按钮,调用napiOpenEscapableHandleScope相关函数 + */ + it('testNodeAPILifeCycle002', 0, async (done: Function) => { + console.info('uitest: testNodeAPILifeCycle002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiOpenEscapableHandleScope')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiOpenEscapableHandleScopeSuccess')); + console.info('uitest: testNodeAPILifeCycle002 end'); + done(); + }) + + /** + * 点击按钮,调用napiAddFinalizer相关函数 + */ + it('testNodeAPILifeCycle003', 0, async (done: Function) => { + console.info('uitest: testNodeAPILifeCycle003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiAddFinalizer')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiAddFinalizerSuccess')); + console.info('uitest: testNodeAPILifeCycle003 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/ohosTest.md new file mode 100644 index 0000000000..a9e8fe658d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/ohosTest.md @@ -0,0 +1,10 @@ +# 使用Node-API进行life-cycle相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------------------ | ------------ | ---------------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 handleScopeTest,handleScope | 位于主页 | 点击文本为1.napiOpenHandleScope的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiOpenHandleScopeSuccess | Pass | +| ArkTS端成功调用native侧接口createArrayWithLength | 位于主页 | 点击文本为2.escapableHandleScopeTest的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiOpenEscapableHandleScopeSuccess | Pass | +| ArkTS端成功调用native侧接口createReference,useReference,deleteReference | 位于主页 | 点击文本为3.napiAddFinalizer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiAddFinalizerSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/screenshots/NodeAPILifeCycle1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/screenshots/NodeAPILifeCycle1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/screenshots/NodeAPILifeCycle1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/screenshots/NodeAPILifeCycle1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/screenshots/NodeAPILifeCycle2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/screenshots/NodeAPILifeCycle2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/screenshots/NodeAPILifeCycle2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPILifeCycle/screenshots/NodeAPILifeCycle2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/app.json5 new file mode 100644 index 0000000000..0decfcbcf4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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.nodeapiobject", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..7e559b881b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIObject" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/README.md new file mode 100644 index 0000000000..5e8579cd0a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行object相关开发 + +### 介绍 + +使用Node-API接口进行object相关开发,处理ArkTS对象的基本操作的功能,例如创建对象、获取原型、冻结和密封对象,检查对象的类型等。这些操作是在处理ArkTS对象时非常常见的,提供了一种与ArkTS对象交互的方式,本工程中展示的代码详细描述可查如下链接。 + +- [使用Node-API进行object相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-object.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIObject.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行object相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIObject.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..20682a016d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIObject) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..719f648475 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,303 @@ +/* + * 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 +#include +#include "hilog/log.h" +#include "napi/native_api.h" + +// napi_get_prototype +static napi_value GetPrototype(napi_env env, napi_callback_info info) +{ + // 获取并解析传参 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + napi_value result = nullptr; + // 获取此对象的原型对象,将结果返回到napi_value类型的变量result中 + napi_get_prototype(env, args[0], &result); + return result; +} +// napi_create_object +napi_value NewObject(napi_env env, napi_callback_info info) +{ + napi_value object = nullptr; + // 创建一个空对象 + napi_create_object(env, &object); + // 设置对象的属性 + napi_value name = nullptr; + // 设置属性名为"name" + napi_create_string_utf8(env, "name", NAPI_AUTO_LENGTH, &name); + napi_value value = nullptr; + // 设置属性值为"Hello from Node-API!" + napi_create_string_utf8(env, "Hello from Node-API!", NAPI_AUTO_LENGTH, &value); + // 将属性设置到对象上 + napi_set_property(env, object, name, value); + return object; +} +// napi_object_freeze +static napi_value ObjectFreeze(napi_env env, napi_callback_info info) +{ + // 接受一个ArkTS侧传入的object + size_t argc = 1; + napi_value argv[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + // 调用接口napi_object_freeze将传入的object冻结 + napi_value objFreeze = argv[0]; + napi_status status = napi_object_freeze(env, objFreeze); + if (status == napi_ok) { + OH_LOG_INFO(LOG_APP, "Node-API napi_object_freeze success"); + } + // 将冻结后的object传回ArkTS侧 + return objFreeze; +} +// napi_object_seal +static napi_value ObjectSeal(napi_env env, napi_callback_info info) +{ + // 接受一个ArkTS侧传入的object + size_t argc = 1; + napi_value argv[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + // 调用接口napi_object_seal将传入的object封闭,使其无法添加新的属性 + napi_value objSeal = argv[0]; + napi_status status = napi_object_seal(env, objSeal); + if (status == napi_ok) { + OH_LOG_INFO(LOG_APP, "Node-API napi_object_seal success"); + } + // 将封闭后的object传回ArkTS侧 + return objSeal; +} +// napi_typeof +static napi_value NapiTypeof(napi_env env, napi_callback_info info) +{ + // 接受一个入参 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 调用napi_typeof判断传入ArkTS参数类型 + napi_valuetype valueType; + napi_status status = napi_typeof(env, args[0], &valueType); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_typeof fail"); + return nullptr; + } + // 将结果转成napi_value类型返回。 + napi_value returnValue = nullptr; + switch (valueType) { + case napi_undefined: + napi_create_string_utf8(env, "Input type is napi_undefined", NAPI_AUTO_LENGTH, &returnValue); + break; + case napi_null: + napi_create_string_utf8(env, "Input type is napi_null", NAPI_AUTO_LENGTH, &returnValue); + break; + case napi_boolean: + napi_create_string_utf8(env, "Input type is napi_boolean", NAPI_AUTO_LENGTH, &returnValue); + break; + case napi_number: + napi_create_string_utf8(env, "Input type is napi_number", NAPI_AUTO_LENGTH, &returnValue); + break; + case napi_string: + napi_create_string_utf8(env, "Input type is napi_string", NAPI_AUTO_LENGTH, &returnValue); + break; + case napi_object: + napi_create_string_utf8(env, "Input type is napi_object", NAPI_AUTO_LENGTH, &returnValue); + break; + case napi_function: + napi_create_string_utf8(env, "Input type is napi_function", NAPI_AUTO_LENGTH, &returnValue); + break; + case napi_bigint: + napi_create_string_utf8(env, "Input type is napi_bigint", NAPI_AUTO_LENGTH, &returnValue); + break; + default: + napi_create_string_utf8(env, "unknown", NAPI_AUTO_LENGTH, &returnValue); + } + return returnValue; +} +// napi_instanceof +static napi_value NapiInstanceof(napi_env env, napi_callback_info info) +{ + // 接受两个入参 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 调用napi_instanceof接口判断给定object是否为给定constructor的实例 + bool result = true; + napi_status status = napi_instanceof(env, args[0], args[1], &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_instanceof fail"); + return nullptr; + } + // 将结果转成napi_value类型返回 + napi_value returnValue = nullptr; + napi_get_boolean(env, result, &returnValue); + + return returnValue; +} + +#define NUMBERINT_FOUR 4 +// 定义一个静态常量napi_type_tag数组存储类型标签 +static const napi_type_tag TagsData[NUMBERINT_FOUR] = { + {0x9e4b2449547061b3, 0x33999f8a6516c499}, + {0x1d55a794c53a726d, 0x43633f509f9c944e}, + // 用于表示无标签或默认标签 + {0, 0}, + {0x6a971439f5b2e5d7, 0x531dc28a7e5317c0}, +}; +// napi_type_tag_object +static napi_value SetTypeTagToObject(napi_env env, napi_callback_info info) +{ + // 获取函数调用信息和参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取索引数字转换为napi_value + int32_t index = 0; + napi_get_value_int32(env, args[1], &index); + // 给参数(对象)设置类型标签 + napi_status status = napi_type_tag_object(env, args[0], &TagsData[index]); + if (status != napi_ok) { + napi_throw_error(env, "Reconnect error", "napi_type_tag_object failed"); + return nullptr; + } + // 将bool结果转换为napi_value并返回 + napi_value result = nullptr; + napi_get_boolean(env, true, &result); + return result; +} +// napi_check_object_type_tag +static napi_value CheckObjectTypeTag(napi_env env, napi_callback_info info) +{ + // 获取函数调用信息和参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取索引数字转换为napi_value + int32_t index = 0; + napi_get_value_int32(env, args[1], &index); + // 检查对象的类型标签 + bool checkResult = true; + napi_check_object_type_tag(env, args[0], &TagsData[index], &checkResult); + // 将bool结果转换为napi_value并返回 + napi_value checked = nullptr; + napi_get_boolean(env, checkResult, &checked); + + return checked; +} + +// 用于释放外部数据的回调函数 +void finalizeCallback(napi_env env, void *data, void *hint) +{ + // 释放外部数据 + free(data); +} +// napi_create_external +static napi_value GetExternalType(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取参数的数据类型 + napi_valuetype valueType; + napi_typeof(env, args[0], &valueType); + napi_value returnValue = nullptr; + if (valueType == napi_external) { + // 如果数据类型是napi_external,则返回true + napi_get_boolean(env, true, &returnValue); + } else { + napi_get_boolean(env, false, &returnValue); + } + return returnValue; +} + +static napi_value CreateExternal(napi_env env, napi_callback_info info) +{ + // 设置外部数据大小为10 + const size_t dataSize = 10; + // 分配外部数据 + void *data = malloc(dataSize); + // 初始化外部数据 + memset(data, 0, dataSize); + napi_value result = nullptr; + // 返回带有外部数据的对象 + napi_status status = napi_create_external(env, data, finalizeCallback, nullptr, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, " Node-API Failed to create external data"); + return nullptr; + } + return result; +} +// napi_get_value_external +static int g_external = 5; +static napi_value GetValueExternal(napi_env env, napi_callback_info info) +{ + // 创建外部数据 + int *data = &g_external; + napi_value setExternal = nullptr; + napi_create_external(env, data, nullptr, nullptr, &setExternal); + // 获得外部数据的值 + void *getExternal; + napi_get_value_external(env, setExternal, &getExternal); + // 返回获得到的外部数据 + napi_value result = nullptr; + napi_create_int32(env, *(int *)getExternal, &result); + return result; +} +// napi_create_symbol +static napi_value CreateSymbol(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + const char *des = "only"; + // 使用napi_create_string_utf8创建描述字符串 + napi_create_string_utf8(env, des, NAPI_AUTO_LENGTH, &result); + napi_value returnSymbol = nullptr; + // 创建一个symbol类型,并返回 + napi_create_symbol(env, result, &returnSymbol); + return returnSymbol; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"getPrototype", nullptr, GetPrototype, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createObject", nullptr, NewObject, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"objectFreeze", nullptr, ObjectFreeze, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"objectSeal", nullptr, ObjectSeal, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiTypeof", nullptr, NapiTypeof, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiInstanceof", nullptr, NapiInstanceof, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"setTypeTagToObject", nullptr, SetTypeTagToObject, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"checkObjectTypeTag", nullptr, CheckObjectTypeTag, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createExternal", nullptr, GetExternalType, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getExternalType", nullptr, CreateExternal, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getValueExternal", nullptr, GetValueExternal, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createSymbol", nullptr, CreateSymbol, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..e7e9471558 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const getPrototype: (object: Object) => Object; // napi_get_prototype + +export const createObject: () => { name: string }; // napi_create_object + +export interface Obj { + data: number + message: string +} + +export const objectFreeze: (objFreeze: Object) => Obj; // napi_object_freeze + +export interface Obj1 { + data: number + message: string + id: number +} + +export const objectSeal: (objSeal: Object) => Obj1; // napi_object_seal + +export const napiTypeof: (value: T) => string | void; // napi_typeof + +export const napiInstanceof: (date: Object, construct: Object) => boolean | void; // napi_instanceof + +export const setTypeTagToObject: (obj: Object, index: number) => boolean | void; // napi_type_tag_object + +export const checkObjectTypeTag: (obj: Object, index: number) => boolean; // napi_check_object_type_tag + +export const createExternal: () => Object; // napi_create_external + +export const getExternalType: (externalData: Object) => boolean; // napi_create_external + +export const getValueExternal: () => number; // napi_get_value_external + +export const createSymbol: () => symbol; // napi_create_symbol \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..e09c966fc6 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,234 @@ +/* + * 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 testNapi from 'libentry.so'; +import { napiGetPrototype } from './napiGetPrototype'; + +// 定义一个类 +class Person { + // 属性 + name: string; + age: number; + + // 构造函数 + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } +} + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiGetPrototype', + '2.napiCreateObject', + '3.napiObjectFreeze', + '4.napiObjectSeal', + '5.napiTypeof', + '6.napiInstanceof', + '7.napiTypeTagObject', + '8.napiCreateExternal', + '9.napiGetValueExternal', + '10.napiCreateSymbol' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(22) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiGetPrototype') { + napiGetPrototype(); + this.result = 'napiGetPrototypeSuccess'; + } else if (item === '2.napiCreateObject') { + // napi_create_object + try { + const myObject = testNapi.createObject(); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_object: %{public}s', myObject.name); + this.result = 'napiCreateObjectSuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', + 'Test Node-API napi_create_object errorCode: %{public}s, errorMessage: %{public}s', error.code, + error.message); + this.result = 'napiCreateObjectFail'; + } + } else if (item === '3.napiObjectFreeze') { + // napi_object_freeze + try { + class Obj { + public data: number = 0 + public message: string = '' + } + + let obj: Obj = { data: 0, message: 'hello world' }; + let objFreeze = testNapi.objectFreeze(obj); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_object_freeze: %{public}s', (objFreeze.data = 1)); + this.result = 'napiObjectFreezeSuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_object_freeze error: %{public}s', error.message); + this.result = 'napiObjectFreezeFail'; + } + } else if (item === '4.napiObjectSeal') { + // napi_object_seal + try { + class Obj { + public data: number = 0 + public message: string = '' + // 可选属性 + public address?: number = 0 + } + + let obj: Obj = { data: 0, message: 'hello world' }; + let objSeal = testNapi.objectSeal(obj); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_object_seal: %{public}s', objSeal.message); + objSeal.data = 1; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_object_seal: %{public}d', objSeal.data); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_object_seal: %{public}d', (objSeal.id = 1)); + this.result = 'napiObjectSealSuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_object_seal error: %{public}s', error.message); + this.result = 'napiObjectSealFail'; + } + } else if (item === '5.napiTypeof') { + // napi_typeof + try { + let varUndefined: undefined; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', + testNapi.napiTypeof(varUndefined)); + let varNull: null = null; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', + testNapi.napiTypeof(varNull)); + let varTrue = true; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', + testNapi.napiTypeof(varTrue)); + let varNum = 1; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', testNapi.napiTypeof(varNum)); + let varString = 'str'; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', + testNapi.napiTypeof(varString)); + + class Obj { + public id: number = 0 + public name: string = '' + } + + let varObject: Obj = { id: 1, name: 'LiLei' }; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', + testNapi.napiTypeof(varObject)); + const addNum = (a: number, b: number): number => a * b; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', testNapi.napiTypeof(addNum)); + let varBigint = BigInt('1234567890123456789012345678901234567890'); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', + testNapi.napiTypeof(varBigint)); + this.result = 'napiTypeofSuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_typeof error: %{public}s', error.message); + this.result = 'napiTypeofFail'; + } + } else if (item === '6.napiInstanceof') { + // napi_instanceof + try { + class Person { + public name: string; + public age: number; + + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } + } + + const person = new Person('Alice', 30); + + class Obj { + public data: number = 0 + public message: string = '' + } + + let obj: Obj = { data: 0, message: 'hello world' }; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_instanceof: %{public}s', + testNapi.napiInstanceof(person, Person)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_instanceof: %{public}s', + testNapi.napiInstanceof(obj, Person)); + this.result = 'napiInstanceofSuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_instanceof error: %{public}s', error.message); + this.result = 'napiInstanceofFail'; + } + } else if (item === '7.napiTypeTagObject') { + + // napi_type_tag_object and napi_check_object_type_tag + class Obj { + public data: number = 0 + public message: string = '' + } + + let objA: Obj = { data: 0, message: 'hello world' }; + let objB: Obj = { data: 10, message: 'typetag' }; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_type_tag_object objA -> 0: %{public}s', + testNapi.setTypeTagToObject(objA, 0)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_type_tag_object objB -> 0: %{public}s', + testNapi.setTypeTagToObject(objB, 0)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_check_object_type_tag objA -> 0: %{public}s', + testNapi.checkObjectTypeTag(objA, 0)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_check_object_type_tag objB -> 1: %{public}s', + testNapi.checkObjectTypeTag(objB, 1)); + this.result = 'napiTypeTagObjectSuccess'; + } else if (item === '8.napiCreateExternal') { + // napi_create_external + const externalData = testNapi.createExternal(); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_external:%{public}s', + testNapi.getExternalType(externalData)); + this.result = 'napiCreateExternalSuccess'; + } else if (item === '9.napiGetValueExternal') { + // napi_get_value_external + hilog.info(0x0000, 'Node-API', 'get_value_external:%{public}d', testNapi.getValueExternal()); + this.result = 'napiGetValueExternalSuccess'; + } else if (item === '10.napiCreateSymbol') { + // napi_create_symbol + let varSymbol = testNapi.createSymbol(); + hilog.info(0x0000, 'Node-API', 'createSymbol:%{public}s', typeof varSymbol); + this.result = 'napiCreateSymbolSuccess'; + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/napiGetPrototype.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/napiGetPrototype.ts old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/napiGetPrototype.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/napiGetPrototype.ts index 64a5b11f3b..27a5176ac2 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/napiGetPrototype.ts +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/napiGetPrototype.ts @@ -1,43 +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. - */ - -import testNapi from 'libentry.so'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -export function napiGetPrototype() { - class Person { - // 属性 - name: string; - age: number; - - // 构造函数 - constructor(name: string, age: number) { - this.name = name; - this.age = age; - } - } - - //创建类的实例 - const person = new Person('Alice', 30); - // 传入实例对象,获取该对象的原型 - let applePrototype = testNapi.getPrototype(person); - // 判断通过testNapi.getPrototype()函数获取到的原型是不是apple的原型 - // 在DevEco Studio 4.1及以后的版本中,由于ArkTS没有原型的概念,因此尝试进行原型赋值或相关操作时,将会触发错误提示'Prototype assignment is not supported (arkts-no-prototype-assignment)',以下代码需在ts文件中执行 - if (applePrototype === Person.prototype) { - hilog.info(0x0000, 'Node-API', 'get_prototype_success'); - } else { - hilog.info(0x0000, 'Node-API', 'get_prototype_fail'); - } +/* + * 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'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +export function napiGetPrototype() { + class Person { + // 属性 + name: string; + age: number; + + // 构造函数 + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } + } + + //创建类的实例 + const person = new Person('Alice', 30); + // 传入实例对象,获取该对象的原型 + let applePrototype = testNapi.getPrototype(person); + // 判断通过testNapi.getPrototype()函数获取到的原型是不是apple的原型 + // 在DevEco Studio 4.1及以后的版本中,由于ArkTS没有原型的概念,因此尝试进行原型赋值或相关操作时,将会触发错误提示'Prototype assignment is not supported (arkts-no-prototype-assignment)',以下代码需在ts文件中执行 + if (applePrototype === Person.prototype) { + hilog.info(0x0000, 'Node-API', 'get_prototype_success'); + } else { + hilog.info(0x0000, 'Node-API', 'get_prototype_fail'); + } }; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/NodeAPIObject.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/NodeAPIObject.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/NodeAPIObject.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/NodeAPIObject.test.ets index 21bcb3d083..b0da8a29b4 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/NodeAPIObject.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/ets/test/NodeAPIObject.test.ets @@ -1,204 +1,204 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIObjectTest() { - describe('nodeAPIObjectTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiGetPrototype相关函数 - */ - it('testNodeAPIObject001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIObject001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiGetPrototype')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetPrototypeSuccess')); - console.info('uitest: testNodeAPIObject001 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateObject相关函数 - */ - it('testNodeAPIObject002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIObject002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiCreateObject')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateObjectSuccess')); - console.info('uitest: testNodeAPIObject002 end'); - done(); - }) - - /** - * 点击按钮,调用napiObjectFreeze相关函数 - */ - it('testNodeAPIObject003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIObject003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiObjectFreeze')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiObjectFreezeFail')); - console.info('uitest: testNodeAPIObject003 end'); - done(); - }) - - /** - * 点击按钮,调用napiObjectSeal相关函数 - */ - it('testNodeAPIObject004', 0, async (done: Function) => { - console.info('uitest: testNodeAPIObject004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('4.napiObjectSeal')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiObjectSealFail')); - console.info('uitest: testNodeAPIObject004 end'); - done(); - }) - - /** - * 点击按钮,调用napiTypeof相关函数 - */ - it('testNodeAPIObject005', 0, async (done: Function) => { - console.info('uitest: testNodeAPIObject005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('5.napiTypeof')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiTypeofSuccess')); - console.info('uitest: testNodeAPIObject005 end'); - done(); - }) - - /** - * 点击按钮,调用napiInstanceof相关函数 - */ - it('testNodeAPIObject006', 0, async (done: Function) => { - console.info('uitest: testNodeAPIObject006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('6.napiInstanceof')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiInstanceofSuccess')); - console.info('uitest: testNodeAPIObject006 end'); - done(); - }) - - /** - * 点击按钮,调用napiTypeTagObject相关函数 - */ - it('testNodeAPIObject007', 0, async (done: Function) => { - console.info('uitest: testNodeAPIObject007 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('7.napiTypeTagObject')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiTypeTagObjectSuccess')); - console.info('uitest: testNodeAPIObject007 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateExternal相关函数 - */ - it('testNodeAPIObject008', 0, async (done: Function) => { - console.info('uitest: testNodeAPIObject008 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('8.napiCreateExternal')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateExternalSuccess')); - console.info('uitest: testNodeAPIObject008 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetValueExternal相关函数 - */ - it('testNodeAPIObject009', 0, async (done: Function) => { - console.info('uitest: testNodeAPIObject009 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('9.napiGetValueExternal')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetValueExternalSuccess')); - console.info('uitest: testNodeAPIObject009 end'); - done(); - }) - - /** - * 点击按钮,调用napiCreateSymbol相关函数 - */ - it('testNodeAPIObject010', 0, async (done: Function) => { - console.info('uitest: testNodeAPIObject010 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('10.napiCreateSymbol')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCreateSymbolSuccess')); - console.info('uitest: testNodeAPIObject010 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIObjectTest() { + describe('nodeAPIObjectTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiGetPrototype相关函数 + */ + it('testNodeAPIObject001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIObject001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiGetPrototype')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetPrototypeSuccess')); + console.info('uitest: testNodeAPIObject001 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateObject相关函数 + */ + it('testNodeAPIObject002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIObject002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiCreateObject')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateObjectSuccess')); + console.info('uitest: testNodeAPIObject002 end'); + done(); + }) + + /** + * 点击按钮,调用napiObjectFreeze相关函数 + */ + it('testNodeAPIObject003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIObject003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiObjectFreeze')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiObjectFreezeFail')); + console.info('uitest: testNodeAPIObject003 end'); + done(); + }) + + /** + * 点击按钮,调用napiObjectSeal相关函数 + */ + it('testNodeAPIObject004', 0, async (done: Function) => { + console.info('uitest: testNodeAPIObject004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('4.napiObjectSeal')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiObjectSealFail')); + console.info('uitest: testNodeAPIObject004 end'); + done(); + }) + + /** + * 点击按钮,调用napiTypeof相关函数 + */ + it('testNodeAPIObject005', 0, async (done: Function) => { + console.info('uitest: testNodeAPIObject005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('5.napiTypeof')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiTypeofSuccess')); + console.info('uitest: testNodeAPIObject005 end'); + done(); + }) + + /** + * 点击按钮,调用napiInstanceof相关函数 + */ + it('testNodeAPIObject006', 0, async (done: Function) => { + console.info('uitest: testNodeAPIObject006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('6.napiInstanceof')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiInstanceofSuccess')); + console.info('uitest: testNodeAPIObject006 end'); + done(); + }) + + /** + * 点击按钮,调用napiTypeTagObject相关函数 + */ + it('testNodeAPIObject007', 0, async (done: Function) => { + console.info('uitest: testNodeAPIObject007 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('7.napiTypeTagObject')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiTypeTagObjectSuccess')); + console.info('uitest: testNodeAPIObject007 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateExternal相关函数 + */ + it('testNodeAPIObject008', 0, async (done: Function) => { + console.info('uitest: testNodeAPIObject008 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('8.napiCreateExternal')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateExternalSuccess')); + console.info('uitest: testNodeAPIObject008 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetValueExternal相关函数 + */ + it('testNodeAPIObject009', 0, async (done: Function) => { + console.info('uitest: testNodeAPIObject009 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('9.napiGetValueExternal')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetValueExternalSuccess')); + console.info('uitest: testNodeAPIObject009 end'); + done(); + }) + + /** + * 点击按钮,调用napiCreateSymbol相关函数 + */ + it('testNodeAPIObject010', 0, async (done: Function) => { + console.info('uitest: testNodeAPIObject010 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('10.napiCreateSymbol')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCreateSymbolSuccess')); + console.info('uitest: testNodeAPIObject010 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/ohosTest.md new file mode 100644 index 0000000000..3a03dabf0e --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/ohosTest.md @@ -0,0 +1,17 @@ +# 使用Node-API进行object相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------------------ | ------------ | ------------------------------------------ | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 napiGetPrototype | 位于主页 | 点击文本为1.napiGetPrototype的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetPrototypeSuccess | Pass | +| ArkTS端成功调用native侧接口createObject | 位于主页 | 点击文本为2.napiCreateObject的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateObjectSuccess | Pass | +| ArkTS端成功调用native侧接口objectFreeze | 位于主页 | 点击文本为3.napiObjectFreeze的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiObjectFreezeSuccess | Pass | +| ArkTS端成功调用native侧接口objectSeal | 位于主页 | 点击文本为4.napiObjectSeal的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiObjectSealSuccess | Pass | +| ArkTS端成功调用native侧接口napiTypeOf | 位于主页 | 点击文本为5.napiTypeof的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiTypeofSuccess | Pass | +| ArkTS端成功调用native侧接口napiInstanceof | 位于主页 | 点击文本为6.napiInstanceof的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiInstanceofSuccess | Pass | +| ArkTS端成功调用native侧接口setTypeTagToObject,checkObjectTypeTag | 位于主页 | 点击文本为7.napiTypeTagObject的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiTypeTagObjectSuccess | Pass | +| ArkTS端成功调用native侧接口createExternal,getExternalType | 位于主页 | 点击文本为8.napiCreateExternal的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateExternalSuccess | Pass | +| ArkTS端成功调用native侧接口getValueExternal | 位于主页 | 点击文本为9.napiGetValueExternal的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueExternalSuccess | Pass | +| ArkTS端成功调用native侧接口createSymbol | 位于主页 | 点击文本为10.napiCreateSymbol的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSymbolSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/screenshots/NodeAPIObject1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/screenshots/NodeAPIObject1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/screenshots/NodeAPIObject1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/screenshots/NodeAPIObject1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/screenshots/NodeAPIObject2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/screenshots/NodeAPIObject2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/screenshots/NodeAPIObject2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIObject/screenshots/NodeAPIObject2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/app.json5 new file mode 100644 index 0000000000..73fa2769f1 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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.nodeapiprimitive", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..3c78d5cd71 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIPrimitive" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/README.md new file mode 100644 index 0000000000..4e3b689642 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API接口进行primitiv类相关开发 + +### 介绍 + +在使用Node-API接口时,开发人员可以实现在Node-API模块中与ArkTS对象的交互,并进行数据转换和获取特定对象的操作,它们在不同的场景中发挥着重要的作用,使开发人员能够更灵活地处理ArkTS值和对象,本工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [使用Node-API接口进行primitiv类相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-primitive.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIPrimitive.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API接口进行primitiv类相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIPrimitive.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..073d9270fb --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIPrimitive) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..5f637edcfb --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,192 @@ +/* + * 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" + +// [Start napi_coerce_to_bool] +// napi_coerce_to_bool +static napi_value CoerceToBool(napi_env env, napi_callback_info info) +{ + // 获取并解析传进的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 将传入的值转换为布尔值 + napi_value result = nullptr; + napi_coerce_to_bool(env, args[0], &result); + // 返回强转之后的ArkTS boolean值 + return result; +} +// [End napi_coerce_to_bool] + +// [Start napi_coerce_to_number] +// napi_coerce_to_number +static napi_value CoerceToNumber(napi_env env, napi_callback_info info) +{ + // 获取并解析传进的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 将传入的值转换为number值 + napi_value result = nullptr; + napi_coerce_to_number(env, args[0], &result); + return result; +} +// [End napi_coerce_to_number] + +// [Start napi_coerce_to_object] +// napi_coerce_to_object +static napi_value CoerceToObject(napi_env env, napi_callback_info info) +{ + // 获取并解析传进的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_value obj = nullptr; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 将传入的值转换为Object值 + napi_coerce_to_object(env, args[0], &obj); + return obj; +} +// [End napi_coerce_to_object] + +// [Start napi_coerce_to_string] +// napi_coerce_to_string +static napi_value CoerceToString(napi_env env, napi_callback_info info) +{ + // 获取并解析传进的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 将传入的值转换为string + napi_value str = nullptr; + napi_coerce_to_string(env, args[0], &str); + return str; +} +// [End napi_coerce_to_string] + +// [Start napi_get_boolean] +// napi_get_boolean +static napi_value GetBoolean(napi_env env, napi_callback_info info) +{ + // 传入两个参数并解析 + size_t argc = 2; + napi_value argv[2]; + napi_valuetype data; + napi_valuetype value; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + // 判断两个参数类型值 + napi_typeof(env, argv[0], &data); + napi_typeof(env, argv[1], &value); + + napi_value returnValue = nullptr; + // 判断两个类型值是否相等,获取结果的布尔值 + napi_get_boolean(env, data == value, &returnValue); + // 返回结果 + return returnValue; +} +// [End napi_get_boolean] + +// [Start napi_get_value_bool] +// napi_get_value_bool +static napi_value GetValueBool(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + bool boolC = false; + napi_status status = napi_get_value_bool(env, args[0], &boolC); + if (status == napi_boolean_expected) { + // 如果napi_get_value_bool成功会返回napi_ok,如果传入一个非布尔值则会返回napi_boolean_expected + return nullptr; + } + napi_value boolNapi = nullptr; + napi_get_boolean(env, boolC, &boolNapi); + return boolNapi; +} +// [End napi_get_value_bool] + +// [Start napi_get_global] +// napi_get_global +static napi_value GetGlobal(napi_env env, napi_callback_info info) +{ + napi_value global = nullptr; + // 获取global对象 + napi_get_global(env, &global); + return global; +} +// [End napi_get_global] + +// [Start napi_get_null] +// napi_get_null +static napi_value GetNull(napi_env env, napi_callback_info info) +{ + napi_value nullValue = nullptr; + napi_get_null(env, &nullValue); + return nullValue; +} +// [End napi_get_null] + +// [Start napi_get_undefined] +// napi_get_undefined +static napi_value GetUndefined(napi_env env, napi_callback_info info) +{ + // 获取并解析传进的参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_value value = nullptr; + napi_get_undefined(env, &value); + // 判断传入参数的类型与undefined值的类型是否一致 + bool isEqual = false; + napi_strict_equals(env, args[0], value, &isEqual); + // 参数与undefined值相等 + napi_value result = nullptr; + // 返回判断类型之后的结果,相等返回为true,不等则为false + napi_get_boolean(env, isEqual, &result); + return result; +} +// [End napi_get_undefined] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"coerceToBool", nullptr, CoerceToBool, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"coerceToNumber", nullptr, CoerceToNumber, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"coerceToObject", nullptr, CoerceToObject, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"coerceToString", nullptr, CoerceToString, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getBoolean", nullptr, GetBoolean, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getValueBool", nullptr, GetValueBool, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getGlobal", nullptr, GetGlobal, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getNull", nullptr, GetNull, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getUndefined", nullptr, GetUndefined, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..82d04677a8 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_coerce_to_bool_api] +export const coerceToBool: (data: T) => boolean; // napi_coerce_to_bool +// [End napi_coerce_to_bool_api] + +// [Start napi_coerce_to_number_api] +export const coerceToNumber: (data: T) => number; // napi_coerce_to_number +// [End napi_coerce_to_number_api] + +// [Start napi_coerce_to_object_api] +export const coerceToObject: (data: T) => Object; // napi_coerce_to_object +// [End napi_coerce_to_object_api] + +// [Start napi_coerce_to_string_api] +export const coerceToString: (data: T) => string; // napi_coerce_to_string +// [End napi_coerce_to_string_api] + +// [Start napi_get_boolean_api] +export const getBoolean: (data: T, value: String) => boolean; // napi_get_boolean +// [End napi_get_boolean_api] + +// [Start napi_get_value_bool_api] +export const getValueBool: (value: boolean | string) => boolean | void; // napi_get_value_bool +// [End napi_get_value_bool_api] + +// [Start napi_get_global_api] +export const getGlobal: () => Object; // napi_get_global +// [End napi_get_global_api] + +// [Start napi_get_null_api] +export const getNull: () => null; // napi_get_null +// [End napi_get_null_api] + +// [Start napi_get_undefined_api] +export const getUndefined: (value: undefined) => boolean; // napi_get_undefined +// [End napi_get_undefined_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..0e03007cd5 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,166 @@ +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiCoerceToBool', + '2.napiCoerceToNumber', + '3.napiCoerceToObject', + '4.napiCoerceToString', + '5.napiGetBoolean', + '6.napiGetValueBool', + '7.napiGetGlobal', + '8.napiGetNull', + '9.napiGetUndefined' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(22) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiCoerceToBool') { + // [Start ark_napi_coerce_to_bool] + // napi_coerce_to_bool + let value = testNapi.coerceToBool(0); + let str = testNapi.coerceToBool('111111111'); + let obj = new Object(); + let res = testNapi.coerceToBool(obj); + let result = testNapi.coerceToBool(null); + // false + hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_bool:%{public}s', value); + // true + hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_bool:%{public}s', str); + // true + hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_bool:%{public}s', res); + // false + hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_bool:%{public}s', result); + // [End ark_napi_coerce_to_bool] + this.result = 'napiCoerceToBoolSuccess'; + } else if (item === '2.napiCoerceToNumber') { + // [Start ark_napi_coerce_to_number] + // napi_coerce_to_number + let value = testNapi.coerceToNumber('2556'); + let str = testNapi.coerceToNumber('sssss'); + let bool = testNapi.coerceToNumber(true); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_number:%{public}d', value); + // 返回的为NAN + hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_number:%{public}d', str); + // 返回的是1 + hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_number:%{public}d', bool); + // [End ark_napi_coerce_to_number] + this.result = 'napiCoerceToNumberSuccess'; + } else if (item === '3.napiCoerceToObject') { + // [Start ark_napi_coerce_to_object] + // napi_coerce_to_object + let value = testNapi.coerceToObject('222222'); + let result = testNapi.coerceToObject(111); + hilog.info(0x0000, 'testTag', 'Node-API coerceToObject:%{public}s.', typeof result); + if (typeof value === 'object') { + hilog.info(0x0000, 'testTag', 'Node-API The value is an object.'); + } else { + hilog.info(0x0000, 'testTag', 'Node-API The value is not an object.'); + } + // [End ark_napi_coerce_to_object] + this.result = 'napiCoerceToObjectSuccess'; + } else if (item === '4.napiCoerceToString') { + // [Start ark_napi_coerce_to_string] + // napi_coerce_to_string + let value = testNapi.coerceToString(212); + let obj = new Object(); + let res = testNapi.coerceToString(obj); + let bool = testNapi.coerceToString(false); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_string:%{public}s', value); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_string:%{public}s', typeof res); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_string:%{public}s', bool); + // [End ark_napi_coerce_to_string] + this.result = 'napiCoerceToStringSuccess'; + } else if (item === '5.napiGetBoolean') { + // [Start ark_napi_get_boolean] + // napi_get_boolean + let value = testNapi.getBoolean(1, '1'); + let data = testNapi.getBoolean('sss', '1'); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_boolean:%{public}s', value); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_boolean:%{public}s', data); + // [End ark_napi_get_boolean] + this.result = 'napiGetBooleanSuccess'; + } else if (item === '6.napiGetValueBool') { + // [Start ark_napi_get_value_bool] + // napi_get_value_bool + // // 分别传入布尔值和非布尔值检测接口,传入布尔值将返回原布尔值,传入其他类型返回undefined + hilog.info(0x0000, 'Node-API', 'get_value_bool_not_bool %{public}s', + testNapi.getValueBool('你好123')); + hilog.info(0x0000, 'Node-API', 'get_value_bool_true %{public}s', testNapi.getValueBool(true)); + hilog.info(0x0000, 'Node-API', 'get_value_bool_false %{public}s', testNapi.getValueBool(false)); + // [End ark_napi_get_value_bool] + this.result = 'napiGetValueBoolSuccess'; + } else if (item === '7.napiGetGlobal') { + // [Start ark_napi_get_global] + // napi_get_global + let globalObj = testNapi.getGlobal(); + // 判断获取的global是否具有global的自身属性 + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_global:%{public}s', + globalObj.hasOwnProperty!("undefined")); + // [End ark_napi_get_global] + this.result = 'napiGetGlobalSuccess'; + } else if (item === '8.napiGetNull') { + // [Start ark_napi_get_null] + // napi_get_null + let value = testNapi.getNull(); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_null:%{public}s', value); + // [End ark_napi_get_null] + this.result = 'napiGetNullSuccess'; + } else if (item === '9.napiGetUndefined') { + // [Start ark_napi_get_undefined] + // napi_get_undefined + let data: undefined = undefined; + let value = testNapi.getUndefined(data); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_undefined:%{public}s', value); + // [End ark_napi_get_undefined] + this.result = 'napiGetUndefinedSuccess'; + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/NodeAPIPrimitive.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/NodeAPIPrimitive.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/NodeAPIPrimitive.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/NodeAPIPrimitive.test.ets index cc579bc71f..0c7a70e6ef --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/NodeAPIPrimitive.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/ets/test/NodeAPIPrimitive.test.ets @@ -1,188 +1,188 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIPrimitiveTest() { - describe('nodeAPIPrimitiveTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiCoerceToBool相关函数 - */ - it('testNodeAPIPrimitive001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPrimitive001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiCoerceToBool')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCoerceToBoolSuccess')); - console.info('uitest: testNodeAPIPrimitive001 end'); - done(); - }) - - /** - * 点击按钮,调用napiCoerceToNumber相关函数 - */ - it('testNodeAPIPrimitive002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPrimitive002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiCoerceToNumber')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCoerceToNumberSuccess')); - console.info('uitest: testNodeAPIPrimitive002 end'); - done(); - }) - - /** - * 点击按钮,调用napiCoerceToObject相关函数 - */ - it('testNodeAPIPrimitive003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPrimitive003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiCoerceToObject')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCoerceToObjectSuccess')); - console.info('uitest: testNodeAPIPrimitive003 end'); - done(); - }) - - /** - * 点击按钮,调用napiCoerceToString相关函数 - */ - it('testNodeAPIPrimitive004', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPrimitive004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('4.napiCoerceToString')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiCoerceToStringSuccess')); - console.info('uitest: testNodeAPIPrimitive004 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetBoolean相关函数 - */ - it('testNodeAPIPrimitive005', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPrimitive005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('5.napiGetBoolean')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetBooleanSuccess')); - console.info('uitest: testNodeAPIPrimitive005 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetValueBool相关函数 - */ - it('testNodeAPIPrimitive006', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPrimitive006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('6.napiGetValueBool')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetValueBoolSuccess')); - console.info('uitest: testNodeAPIPrimitive006 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetGlobal相关函数 - */ - it('testNodeAPIPrimitive007', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPrimitive007 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('7.napiGetGlobal')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetGlobalSuccess')); - console.info('uitest: testNodeAPIPrimitive007 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetNull相关函数 - */ - it('testNodeAPIPrimitive008', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPrimitive008 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('8.napiGetNull')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetNullSuccess')); - console.info('uitest: testNodeAPIPrimitive008 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetUndefined相关函数 - */ - it('testNodeAPIPrimitive009', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPrimitive009 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('9.napiGetUndefined')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetUndefinedSuccess')); - console.info('uitest: testNodeAPIPrimitive009 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIPrimitiveTest() { + describe('nodeAPIPrimitiveTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiCoerceToBool相关函数 + */ + it('testNodeAPIPrimitive001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPrimitive001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiCoerceToBool')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCoerceToBoolSuccess')); + console.info('uitest: testNodeAPIPrimitive001 end'); + done(); + }) + + /** + * 点击按钮,调用napiCoerceToNumber相关函数 + */ + it('testNodeAPIPrimitive002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPrimitive002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiCoerceToNumber')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCoerceToNumberSuccess')); + console.info('uitest: testNodeAPIPrimitive002 end'); + done(); + }) + + /** + * 点击按钮,调用napiCoerceToObject相关函数 + */ + it('testNodeAPIPrimitive003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPrimitive003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiCoerceToObject')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCoerceToObjectSuccess')); + console.info('uitest: testNodeAPIPrimitive003 end'); + done(); + }) + + /** + * 点击按钮,调用napiCoerceToString相关函数 + */ + it('testNodeAPIPrimitive004', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPrimitive004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('4.napiCoerceToString')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiCoerceToStringSuccess')); + console.info('uitest: testNodeAPIPrimitive004 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetBoolean相关函数 + */ + it('testNodeAPIPrimitive005', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPrimitive005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('5.napiGetBoolean')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetBooleanSuccess')); + console.info('uitest: testNodeAPIPrimitive005 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetValueBool相关函数 + */ + it('testNodeAPIPrimitive006', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPrimitive006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('6.napiGetValueBool')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetValueBoolSuccess')); + console.info('uitest: testNodeAPIPrimitive006 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetGlobal相关函数 + */ + it('testNodeAPIPrimitive007', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPrimitive007 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('7.napiGetGlobal')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetGlobalSuccess')); + console.info('uitest: testNodeAPIPrimitive007 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetNull相关函数 + */ + it('testNodeAPIPrimitive008', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPrimitive008 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('8.napiGetNull')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetNullSuccess')); + console.info('uitest: testNodeAPIPrimitive008 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetUndefined相关函数 + */ + it('testNodeAPIPrimitive009', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPrimitive009 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('9.napiGetUndefined')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetUndefinedSuccess')); + console.info('uitest: testNodeAPIPrimitive009 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/ohosTest.md new file mode 100644 index 0000000000..08943f1064 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/ohosTest.md @@ -0,0 +1,16 @@ +# 使用Node-API进行primitive相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------ | ------------ | ---------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 coerceToBool | 位于主页 | 点击文本为1.napiCoerceToBool的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCoerceToBoolSuccess | Pass | +| ArkTS端成功调用native侧接口coerceToNumber | 位于主页 | 点击文本为2.napiCoerceToNumber的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCoerceToNumberSuccess | Pass | +| ArkTS端成功调用native侧接口coerceToObject | 位于主页 | 点击文本为3.napiCoerceToObject的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCoerceToObjectSuccess | Pass | +| ArkTS端成功调用native侧接口coerceToString | 位于主页 | 点击文本为4.napiCoerceToString的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCoerceToStringSuccess | Pass | +| ArkTS端成功调用native侧接口getBoolean | 位于主页 | 点击文本为5.napiGetBoolean的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetBooleanSuccess | Pass | +| ArkTS端成功调用native侧接口getValueBool | 位于主页 | 点击文本为6.napiGetValueBool的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueBoolSuccess | Pass | +| ArkTS端成功调用native侧接口getGlobal | 位于主页 | 点击文本为7.napiGetGlobal的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetGlobalSuccess | Pass | +| ArkTS端成功调用native侧接口getNull | 位于主页 | 点击文本为8.napiGetNull的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetNullSuccess | Pass | +| ArkTS端成功调用native侧接口getUndefined | 位于主页 | 点击文本为9.napiGetUndefined的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetUndefinedSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/screenshots/NodeAPIPrimitive1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/screenshots/NodeAPIPrimitive1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/screenshots/NodeAPIPrimitive1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/screenshots/NodeAPIPrimitive1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/screenshots/NodeAPIPrimitive2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/screenshots/NodeAPIPrimitive2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/screenshots/NodeAPIPrimitive2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPrimitive/screenshots/NodeAPIPrimitive2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/app.json5 new file mode 100644 index 0000000000..ca8d0359b9 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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.nodeapipromise", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..06dbe37097 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIPromise" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/README.md new file mode 100644 index 0000000000..9f8919605c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行promise相关开发 + +### 介绍 + +使用Node-API接口处理异步操作。异步操作是指需要一定时间才能完成的操作,例如从网络下载数据或读取大型文件。与同步操作不同,异步操作不会阻塞主线程,而是会在后台执行。当异步操作完成后,事件循环将把它放入任务队列中,等待主线程空闲时执行,本工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [使用Node-API进行promise相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-promise.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIPromise.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行promise相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIPromise.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6054d42587 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIPromise) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..d8c0799115 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" + +static constexpr int INT_ARGS_2 = 2; // 入参索引 + +// [Start napi_is_promise] +// napi_is_promise +static napi_value IsPromise(napi_env env, napi_callback_info info) +{ + napi_value argv[1] = {nullptr}; + size_t argc = 1; + napi_status status; + // 获取传入的参数 + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + bool isPromise = false; + // 检查给定的入参是否为Promise对象,将结果保存在isPromise变量中 + status = napi_is_promise(env, argv[0], &isPromise); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_is_promise failed"); + return nullptr; + } + napi_value result = nullptr; + // 将isPromise的值转换为napi_value中的类型返回 + napi_get_boolean(env, isPromise, &result); + return result; +} +// [End napi_is_promise] + +// [Start napi_resolve_reject_deferred] +// napi_resolve_deferred & napi_reject_deferred +static napi_value CreatePromise(napi_env env, napi_callback_info info) +{ + // deferred是一个延迟对象,作用是将函数延迟一定时间再执行 + napi_deferred deferred = nullptr; + napi_value promise = nullptr; + // 调用接口创建Promise对象 + napi_status status = napi_create_promise(env, &deferred, &promise); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Create promise failed"); + return nullptr; + } + // 调用napi_is_promise判断napi_create_promise接口创建的是不是Promise对象 + bool isPromise = false; + napi_value returnIsPromise = nullptr; + napi_is_promise(env, promise, &isPromise); + // 将布尔值转为可以返回的napi_value + napi_get_boolean(env, isPromise, &returnIsPromise); + return returnIsPromise; +} + +static napi_value ResolveRejectDeferred(napi_env env, napi_callback_info info) +{ + // 获得并解析参数 + size_t argc = 3; + napi_value args[3] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 第一个参数为向resolve传入的信息,第二个参数为向reject传入的信息,第三个参数为Promise的状态 + bool status; + napi_get_value_bool(env, args[INT_ARGS_2], &status); + // 创建Promise对象 + napi_deferred deferred = nullptr; + napi_value promise = nullptr; + napi_status createStatus = napi_create_promise(env, &deferred, &promise); + if (createStatus != napi_ok) { + napi_throw_error(env, nullptr, "Create promise failed"); + return nullptr; + } + // 根据第三个参数设置resolve或reject + if (status) { + napi_resolve_deferred(env, deferred, args[0]); + } else { + napi_reject_deferred(env, deferred, args[1]); + } + // 返回设置了resolve或reject的Promise对象 + return promise; +} +// [End napi_resolve_reject_deferred] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"isPromise", nullptr, IsPromise, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createPromise", nullptr, CreatePromise, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"resolveRejectDeferred", nullptr, ResolveRejectDeferred, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..fe905bc14b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_is_promise_api] +export const isPromise: (value: T) => boolean; // napi_is_promise +// [End napi_is_promise_api] + +// [Start napi_resolve_reject_deferred_api] +export const createPromise: () => boolean | void; // napi_resolve_deferred & napi_reject_deferred + +export const resolveRejectDeferred: (resolve: string, reject: string, status: boolean) => Promise | void; +// [End napi_resolve_reject_deferred_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..25c2d5b949 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,104 @@ +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiIsPromise', + '2.napiDeferred' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(22) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiIsPromise') { + // [Start ark_napi_is_promise] + // napi_is_promise + let value = Promise.resolve(); + // 传入的对象为Promise时,返回true,否则返回false + hilog.info(0x0000, 'Node-API', 'napi_is_promise %{public}s', testNapi.isPromise(value)); + hilog.info(0x0000, 'Node-API', 'napi_is_promise string %{public}s', testNapi.isPromise('')); + // [End ark_napi_is_promise] + this.result = 'napiIsPromiseSuccess'; + } else if (item === '2.napiDeferred') { + // [Start ark_napi_resolve_reject_deferred] + // napi_resolve_deferred & napi_reject_deferred + // 创建promise如果创建成功返回true,创建失败返回false + hilog.info(0x0000, 'Node-API', 'napi_create_promise %{public}s', testNapi.createPromise()); + // 调用resolveRejectDeferred函数设置resolve和reject的返回结果以及Promise状态 + // Promise状态为true时设置resolve,返回结果在then函数中获得 + let promiseSuccess: Promise = + testNapi.resolveRejectDeferred('success', 'fail', true) as Promise; + promiseSuccess.then((res) => { + hilog.info(0x0000, 'Node-API', 'get_resolve_deferred resolve %{public}s', res) + // [StartExclude ark_napi_resolve_reject_deferred] + this.result = 'napiDeferredSuccess'; + // [EndExclude ark_napi_resolve_reject_deferred] + }).catch((err: Error) => { + hilog.info(0x0000, 'Node-API', 'get_resolve_deferred reject %{public}s', err) + // [StartExclude ark_napi_resolve_reject_deferred] + this.result = 'napiDeferredFail'; + // [EndExclude ark_napi_resolve_reject_deferred] + }) + // Promise状态为false时设置reject,返回结果在catch函数中获得 + let promiseFail: Promise = + testNapi.resolveRejectDeferred('success', 'fail', false) as Promise; + promiseFail.then((res) => { + hilog.info(0x0000, 'Node-API', 'get_resolve_deferred resolve %{public}s', res) + // [StartExclude ark_napi_resolve_reject_deferred] + this.result = 'napiDeferredSuccess'; + // [EndExclude ark_napi_resolve_reject_deferred] + }).catch((err: Error) => { + hilog.info(0x0000, 'Node-API', 'get_resolve_deferred reject %{public}s', err) + // [StartExclude ark_napi_resolve_reject_deferred] + this.result = 'napiDeferredFail'; + // [EndExclude ark_napi_resolve_reject_deferred] + }) + // [End ark_napi_resolve_reject_deferred] + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/NodeAPIPromise.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/NodeAPIPromise.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/NodeAPIPromise.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/NodeAPIPromise.test.ets index c2eb468f14..aabae590ad --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/NodeAPIPromise.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/ets/test/NodeAPIPromise.test.ets @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIPromiseTest() { - describe('nodeAPIPromiseTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiIsPromise相关函数 - */ - it('testNodeAPIPromise001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPromise001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiIsPromise')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiIsPromiseSuccess')); - console.info('uitest: testNodeAPIPromise001 end'); - done(); - }) - - /** - * 点击按钮,调用napiDeferred相关函数 - */ - it('testNodeAPIPromise002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIPromise002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiDeferred')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiDeferredFail')); - console.info('uitest: testNodeAPIPromise002 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIPromiseTest() { + describe('nodeAPIPromiseTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiIsPromise相关函数 + */ + it('testNodeAPIPromise001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPromise001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiIsPromise')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiIsPromiseSuccess')); + console.info('uitest: testNodeAPIPromise001 end'); + done(); + }) + + /** + * 点击按钮,调用napiDeferred相关函数 + */ + it('testNodeAPIPromise002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIPromise002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiDeferred')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiDeferredFail')); + console.info('uitest: testNodeAPIPromise002 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/ohosTest.md new file mode 100644 index 0000000000..c7529c64a5 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/ohosTest.md @@ -0,0 +1,9 @@ +# 使用Node-API进行promise相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------------------ | ------------ | ----------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口isPromise | 位于主页 | 点击文本为1.napiIsPromise的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsPromiseSuccess | Pass | +| ArkTS端成功调用native侧接口createPromise,resolveRejectDeferred | 位于主页 | 点击文本为2.napiDeferred的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDeferredSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/screenshots/NodeAPIPromise1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/screenshots/NodeAPIPromise1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/screenshots/NodeAPIPromise1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/screenshots/NodeAPIPromise1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/screenshots/NodeAPIPromise2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/screenshots/NodeAPIPromise2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/screenshots/NodeAPIPromise2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIPromise/screenshots/NodeAPIPromise2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/.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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/app.json5 new file mode 100644 index 0000000000..11f7f25a80 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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.nodeapiproperty", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..17605199d5 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeAPIProperty" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/README.md new file mode 100644 index 0000000000..1f5ee2d295 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行property相关开发 + +### 介绍 + +使用Node-API接口获取和设置ArkTS对象的属性。通过合理使用这些函数,实现更复杂的功能和逻辑,本工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [使用Node-API进行property相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-property.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeAPIProperty.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行property相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeAPIProperty.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty > .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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..8fa817241b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NodeAPIProperty) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..97ecb669a7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,391 @@ +/* + * 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 +#include "napi/native_api.h" + +static constexpr int INT_ARG_2 = 2; // 入参索引 + +// [Start napi_get_property_names] +// napi_get_property_names +static napi_value GetPropertyNames(napi_env env, napi_callback_info info) +{ + // 解析ArkTS的传参 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 以字符串数组的形式获取对象的可枚举属性的名称,以result传出 + napi_value result; + napi_status status = napi_get_property_names(env, args[0], &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_get_property_names fail"); + return nullptr; + } + return result; +} +// [End napi_get_property_names] + +// [Start napi_set_property] +// napi_set_property +static napi_value SetProperty(napi_env env, napi_callback_info info) +{ + // 接收ArkTS侧传入的三个参数:第一个参数为想要设置的object,第二个参数为属性,第三个参数为属性对应的值 + size_t argc = 3; + napi_value args[3] = {nullptr}; + napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_get_cb_info fail"); + } + // 通过调用napi_set_property接口将属性与值设置入object,如果失败,直接抛出错误 + status = napi_set_property(env, args[0], args[1], args[INT_ARG_2]); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_set_property fail"); + return nullptr; + } + // 返回设置成功的object对象 + return args[0]; +} +// [End napi_set_property] + +// [Start napi_get_property] +// napi_get_property +static napi_value GetProperty(napi_env env, napi_callback_info info) +{ + // 接收两个ArkTS传来的参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 传入的第一个参数为要检测的object,第二个对象为要检测的属性,通过调用napi_get_property接口获取对应的值 + napi_value result; + napi_status status = napi_get_property(env, args[0], args[1], &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_get_property fail"); + return nullptr; + } + return result; +} +// [End napi_get_property] + +// [Start napi_has_property] +// napi_has_property +static napi_value HasProperty(napi_env env, napi_callback_info info) +{ + // 从ArkTS侧传入两个参数:第一个参数为要检验的对象,第二个参数为要检测是否存在对象的属性 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 将参数传入napi_has_property方法中,若接口调用成功则将结果转化为napi_value类型抛出,否则抛出错误 + bool result; + napi_status status = napi_has_property(env, args[0], args[1], &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_has_property fail"); + return nullptr; + } + + // 若传入属性存在传入对象中,则输出true将结果转化为napi_value类型抛出 + napi_value returnResult; + napi_get_boolean(env, result, &returnResult); + return returnResult; +} +// [End napi_has_property] + +// [Start napi_delete_property] +// napi_delete_property +// 从传入的Object对象中删除指定属性,返回是否删除成功的bool结果值 +static napi_value DeleteProperty(napi_env env, napi_callback_info info) +{ + // 接收两个ArkTS传来的参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_valuetype valueType; + napi_typeof(env, args[0], &valueType); + if (valueType != napi_object) { + napi_throw_error(env, nullptr, "Expects an object as argument."); + return nullptr; + } + // 删除指定属性,结果存储在result中 + bool result = false; + napi_status status = napi_delete_property(env, args[0], args[1], &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_delete_property failed"); + return nullptr; + } + // 将bool结果转换为napi_value并返回 + napi_value ret; + napi_get_boolean(env, result, &ret); + return ret; +} +// [End napi_delete_property] + +// [Start napi_has_own_property] +// napi_has_own_property +static napi_value NapiHasOwnProperty(napi_env env, napi_callback_info info) +{ + // 接收两个ArkTS传来的参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 检查第一个参数是否为对象 + napi_valuetype valueTypeObj; + napi_typeof(env, args[0], &valueTypeObj); + if (valueTypeObj != napi_object) { + napi_throw_error(env, nullptr, "First argument must be an object."); + return nullptr; + } + // 检查第二个参数是否为string + napi_valuetype valuetypeStr; + napi_typeof(env, args[1], &valuetypeStr); + if (valuetypeStr != napi_string) { + napi_throw_error(env, nullptr, "Second argument must be a string."); + return nullptr; + } + // 检查对象是否具有指定属性,结果存储在hasProperty中 + bool hasProperty; + napi_status status = napi_has_own_property(env, args[0], args[1], &hasProperty); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_has_own_property failed"); + return nullptr; + } + // 将bool结果转换为napi_value并返回 + napi_value result; + napi_get_boolean(env, hasProperty, &result); + return result; +} +// [End napi_has_own_property] + +// [Start napi_set_named_property] +// napi_set_named_property +static napi_value NapiSetNamedProperty(napi_env env, napi_callback_info info) +{ + // 接收一个ArkTS传来的参数 + size_t argc = 1; + napi_value str; + const int32_t strLength = 32; + char strKey[strLength] = ""; + napi_get_cb_info(env, info, &argc, &str, nullptr, nullptr); + // 获取传入参数字符串并存储在strKey中 + size_t keyLength; + napi_get_value_string_utf8(env, str, strKey, strLength, &keyLength); + // 创建一个新对象 + napi_value newObj; + napi_create_object(env, &newObj); + // 设置整数值1234为属性值 + int32_t value = 1234; + napi_value numValue; + napi_create_int32(env, value, &numValue); + // 将整数值与指定属性名关联 + napi_status status = napi_set_named_property(env, newObj, strKey, numValue); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_set_named_property failed"); + return nullptr; + } + // 返回设置了命名属性的对象newObj + return newObj; +} +// [End napi_set_named_property] + +// [Start napi_get_named_property] +// napi_get_named_property +static napi_value NapiGetNamedProperty(napi_env env, napi_callback_info info) +{ + // 接收两个ArkTS传来的参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + const int32_t strLength = 32; + char strKey[strLength] = ""; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取要获取的属性名 + size_t keyLength; + napi_get_value_string_utf8(env, args[1], strKey, strLength, &keyLength); + // 获取指定属性的值并存储在result中 + napi_value result; + napi_status status = napi_get_named_property(env, args[0], strKey, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_get_named_property failed"); + return nullptr; + } + // 返回result + return result; +} +// [End napi_get_named_property] + +// [Start napi_has_named_property] +// napi_has_named_property +static napi_value NapiHasNamedProperty(napi_env env, napi_callback_info info) +{ + // 接收两个ArkTS传来的参数 + size_t argc = 2; + napi_value args[2] = {nullptr}; + const int32_t strLength = 32; + char strKey[strLength] = ""; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取要检查的属性名 + size_t keyLength; + napi_get_value_string_utf8(env, args[1], strKey, strLength, &keyLength); + // 检查对象是否具有指定命名的属性,并将结果存储在hasProperty中 + bool hasProperty = false; + napi_status status = napi_has_named_property(env, args[0], strKey, &hasProperty); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_has_named_property failed"); + return nullptr; + } + // 将bool结果转换为napi_value并返回 + napi_value result; + napi_get_boolean(env, hasProperty, &result); + return result; +} +// [End napi_has_named_property] + +// [Start napi_define_properties] +// napi_define_properties +static napi_value DefineMethodPropertiesExample(napi_env env, napi_callback_info info) +{ + // 创建一个int32类型的属性值 + int32_t propValue = 26; + napi_value returnValue = nullptr; + napi_create_int32(env, propValue, &returnValue); + return returnValue; +} + +// Getter回调函数 +static napi_value GetterCallback(napi_env env, napi_callback_info info) +{ + napi_value result; + const char *str = u8"World!"; + size_t length = strlen(str); + // 创建属性的值 + napi_create_string_utf8(env, str, length, &result); + return result; +} + +// Setter回调函数 +static napi_value SetterCallback(napi_env env, napi_callback_info info) +{ + // 获取传递给setter的参数 + size_t argc = 1; + napi_value argv[1] = {nullptr}; + napi_value result; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + std::string buf; + size_t length; + napi_get_value_string_utf8(env, argv[0], (char *)buf.c_str(), NAPI_AUTO_LENGTH, &length); + napi_create_string_utf8(env, buf.c_str(), length, &result); + return result; +} + +static napi_value DefineMethodProperties(napi_env env, napi_callback_info info) +{ + napi_value obj; + napi_create_object(env, &obj); + // 在obj对象上定义了一个函数defineMethodPropertiesExample,在函数defineMethodPropertiesExample中定义了一个变量并返回,在调用obj的这个对象时可以调用这个函数 + napi_property_descriptor descriptor[] = {{"defineMethodPropertiesExample", nullptr, DefineMethodPropertiesExample, + nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, obj, sizeof(descriptor) / sizeof(descriptor[0]), descriptor); + return obj; +} + +static napi_value DefineStringProperties(napi_env env, napi_callback_info info) +{ + napi_value obj; + napi_create_object(env, &obj); + // 创建一个string类型的属性值 + napi_value string_value; + napi_create_string_utf8(env, "Hello!", NAPI_AUTO_LENGTH, &string_value); + napi_property_descriptor descriptor[] = { + {"defineStringPropertiesExample", nullptr, nullptr, nullptr, nullptr, string_value, napi_default, nullptr}}; + napi_define_properties(env, obj, sizeof(descriptor) / sizeof(descriptor[0]), descriptor); + return obj; +} + +static napi_value CreateStringWithGetterSetter(napi_env env, napi_callback_info info) +{ + napi_value obj; + napi_create_object(env, &obj); + // 定义getter函数 + napi_value getterFn; + napi_create_function(env, nullptr, 0, GetterCallback, nullptr, &getterFn); + napi_set_named_property(env, obj, "getterCallback", getterFn); + // 定义setter函数 + napi_value setterFn; + napi_create_function(env, nullptr, 0, SetterCallback, nullptr, &setterFn); + napi_set_named_property(env, obj, "setterCallback", setterFn); + // 定义带有getter和setter的属性 + napi_property_descriptor desc = {"defineGetterSetter", nullptr, GetterCallback, SetterCallback, nullptr, obj, + napi_enumerable, nullptr}; + napi_define_properties(env, obj, 1, &desc); + return obj; +} +// [End napi_define_properties] + +// [Start napi_get_all_property_names] +// napi_get_all_property_names +static napi_value GetAllPropertyNames(napi_env env, napi_callback_info info) +{ + // 传入一个参数 + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取给定对象的所有属性名称 + napi_value result; + napi_status status = napi_get_all_property_names(env, args[0], napi_key_own_only, napi_key_writable, + napi_key_numbers_to_strings, &result); + // 如果获取属性名失败,抛出一个错误 + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Node-API napi_get_all_property_names fail"); + return nullptr; + } + + return result; +} +// [End napi_get_all_property_names] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"getPropertyNames", nullptr, GetPropertyNames, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"setProperty", nullptr, SetProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getProperty", nullptr, GetProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"hasProperty", nullptr, HasProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"deleteProperty", nullptr, DeleteProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiHasOwnProperty", nullptr, NapiHasOwnProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiSetNamedProperty", nullptr, NapiSetNamedProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiGetNamedProperty", nullptr, NapiGetNamedProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"napiHasNamedProperty", nullptr, NapiHasNamedProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"defineMethodProperties", nullptr, DefineMethodProperties, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"defineStringProperties", nullptr, DefineStringProperties, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createStringWithGetterSetter", nullptr, CreateStringWithGetterSetter, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"getAllPropertyNames", nullptr, GetAllPropertyNames, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..fa257f4b31 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_get_property_names_api] +export const getPropertyNames: (obj: Object) => Array | void; // napi_get_property_names +// [End napi_get_property_names_api] + +// [Start napi_set_property_api] +export const setProperty: (obj: Object, key: String, value: string) => Object | void; // napi_set_property +// [End napi_set_property_api] + +// [Start napi_get_property_api] +export const getProperty: (obj: Object, key: string) => string | void; // napi_get_property +// [End napi_get_property_api] + +// [Start napi_has_property_api] +export const hasProperty: (obj: Object, key: number | string) => boolean | void; // napi_has_property +// [End napi_has_property_api] + +// [Start napi_delete_property_api] +export const deleteProperty: (obj: Object, key: string) => boolean; // napi_delete_property +// [End napi_delete_property_api] + +// [Start napi_has_own_property_api] +export const napiHasOwnProperty: (obj: Object, key: string) => boolean | void; // napi_has_own_property +// [End napi_has_own_property_api] + +// [Start napi_set_named_property_api] +export const napiSetNamedProperty: (key: string) => Object | void; // napi_set_named_property +// [End napi_set_named_property_api] + +// [Start napi_get_named_property_api] +export const napiGetNamedProperty: (obj: Object, + key: string) => boolean | number | string | Object | void; // napi_get_named_property +// [End napi_get_named_property_api] + +// [Start napi_has_named_property_api] +export const napiHasNamedProperty: (obj: Object, key: string) => boolean | void; // napi_has_named_property +// [End napi_has_named_property_api] + +// [Start napi_define_properties_api] +export class DefineMethodObj { + defineMethodPropertiesExample: Function; +} + +export class DefineStringObj { + defineStringPropertiesExample: string; +} + +export class DefineGetterSetterObj { + getterCallback: Function; + setterCallback: Function; +} + +export const defineMethodProperties: () => DefineMethodObj; // napi_define_properties + +export const defineStringProperties: () => DefineStringObj; + +export const createStringWithGetterSetter: () => DefineGetterSetterObj; +// [End napi_define_properties_api] + +// [Start napi_get_all_property_names_api] +export const getAllPropertyNames: (obj: Object) => Array | void; // napi_get_all_property_names +// [End napi_get_all_property_names_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..aa572de2fd --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,294 @@ +/* + * 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 testNapi from 'libentry.so'; +import { napiDeleteProperty } from './napiDeleteProperty'; +import { napiHasOwnProperty } from './napiHasOwnProperty'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiGetPropertyNames', + '2.napiSetProperty', + '3.napiGetProperty', + '4.napiHasProperty', + '5.napiDeleteProperty', + '6.napiHasOwnProperty', + '7.napiSetNamedProperty', + '8.napiGetNamedProperty', + '9.napiHasNamedProperty', + '10.napiDefineProperties', + '11.napiGetAllPropertyNames' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 4 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiGetPropertyNames') { + // [Start ark_napi_get_property_names] + // napi_get_property_names + try { + class Obj { + public data: number = 0 + public message: string = '' + } + + let obj: Obj = { data: 0, message: 'hello world' }; + let propertyNames = testNapi.getPropertyNames(obj); + if (Array.isArray(propertyNames) && propertyNames.length > 0) { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_property_names: %{public}s', + propertyNames[0]); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_property_names: %{public}s', + propertyNames[1]); + // [StartExclude ark_napi_get_property_names] + this.result = 'napiGetPropertyNamesSuccess'; + // [EndExclude ark_napi_get_property_names] + } + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API napi_get_property_names error: %{public}s', + error.message); + // [StartExclude ark_napi_get_property_names] + this.result = 'napiGetPropertyNamesFail'; + // [EndExclude ark_napi_get_property_names] + } + // [End ark_napi_get_property_names] + } else if (item === '2.napiSetProperty') { + // [Start ark_napi_set_property] + // napi_set_property + try { + class Obj { + public data: number = 0 + public message: string = '' + } + + let obj: Obj = { data: 0, message: 'hello world' }; + let result = testNapi.setProperty(obj, 'code', 'hi'); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_property: %{public}s', + JSON.stringify(result)); + // [StartExclude ark_napi_set_property] + this.result = 'napiSetPropertySuccess'; + // [EndExclude ark_napi_set_property] + } catch (error) { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_property error: %{public}s', error.message); + // [StartExclude ark_napi_set_property] + this.result = 'napiSetPropertyFail'; + // [EndExclude ark_napi_set_property] + } + // [End ark_napi_set_property] + } else if (item === '3.napiGetProperty') { + // [Start ark_napi_get_property] + // napi_get_property + try { + class Obj { + public data: number = 0 + public message: string = '' + } + + let obj: Obj = { data: 0, message: 'hello world' }; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_property: %{public}s', + testNapi.getProperty(obj, 'message')); + // [StartExclude ark_napi_get_property] + this.result = 'napiGetPropertySuccess'; + // [EndExclude ark_napi_get_property] + } catch (error) { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_property error: %{public}s', error.message); + // [StartExclude ark_napi_get_property] + this.result = 'napiGetPropertyFail'; + // [EndExclude ark_napi_get_property] + } + // [End ark_napi_get_property] + } else if (item === '4.napiHasProperty') { + // [Start ark_napi_has_property] + // napi_has_property + try { + class Obj { + public data: number = 0 + public message: string = '' + } + + let obj: Obj = { data: 0, message: 'hello world' }; + let resultFalse = testNapi.hasProperty(obj, 0); + let resultTrue = testNapi.hasProperty(obj, 'data'); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_property: %{public}s', + JSON.stringify(resultFalse)); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_property: %{public}s', + JSON.stringify(resultTrue)); + // [StartExclude ark_napi_has_property] + this.result = 'napiHasPropertySuccess'; + // [EndExclude ark_napi_has_property] + } catch (error) { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_property error: %{public}s', error.message); + // [StartExclude ark_napi_has_property] + this.result = 'napiHasPropertyFail'; + // [EndExclude ark_napi_has_property] + } + // [End ark_napi_has_property] + } else if (item === '5.napiDeleteProperty') { + // napi_delete_property + napiDeleteProperty(); + this.result = 'napiDeletePropertySuccess'; + } else if (item === '6.napiHasOwnProperty') { + // napi_has_own_property + napiHasOwnProperty(); + this.result = 'napiHasOwnPropertySuccess'; + } else if (item === '7.napiSetNamedProperty') { + // [Start ark_napi_set_named_property] + // napi_set_named_property + let obj = testNapi.napiSetNamedProperty('myProperty'); + let objAsString = JSON.stringify(obj); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_named_property: %{public}s', objAsString); + // [End ark_napi_set_named_property] + this.result = 'napiSetNamedPropertySuccess'; + } else if (item === '8.napiGetNamedProperty') { + // [Start ark_napi_get_named_property] + // napi_get_named_property + interface NestedObj { + nestedStr: string; + nestedNum: number; + } + + class Obj { + public str: string = ''; + public num: number = 0; + public bol: boolean = false; + public nestedObj: NestedObj = { nestedStr: '', nestedNum: 0 }; + } + + let obj: Obj = { + str: 'bar', + num: 42, + bol: true, + nestedObj: { nestedStr: 'nestedValue', nestedNum: 123 } + }; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_named_property : %{public}s', + testNapi.napiGetNamedProperty(obj, 'str')); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_named_property : %{public}d', + testNapi.napiGetNamedProperty(obj, 'num')); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_named_property : %{public}s', + testNapi.napiGetNamedProperty(obj, 'bol')); + let nestedObj = testNapi.napiGetNamedProperty(obj, 'nestedObj'); + let objAsString = JSON.stringify(nestedObj); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_named_property : %{public}s', objAsString); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_named_property : %{public}s', + testNapi.napiGetNamedProperty(obj, 'null')); + // [End ark_napi_get_named_property] + this.result = 'napiGetNamedPropertySuccess'; + } else if (item === '9.napiHasNamedProperty') { + // [Start ark_napi_has_named_property] + // napi_has_named_property + interface NestedObj { + nestedStr: string; + nestedNum: number; + } + + class Obj { + public str: string = ''; + public num: number = 0; + public bol: boolean = false; + public nestedObj: NestedObj = { nestedStr: '', nestedNum: 0 }; + } + + let obj: Obj = { + str: 'bar', + num: 42, + bol: true, + nestedObj: { nestedStr: 'nestedValue', nestedNum: 123 } + }; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_named_property : %{public}s', + testNapi.napiHasNamedProperty(obj, 'str')); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_named_property : %{public}s', + testNapi.napiHasNamedProperty(obj, 'nestedStr')); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_named_property : %{public}s', + testNapi.napiHasNamedProperty(obj, 'bol')); + // [End ark_napi_has_named_property] + this.result = 'napiHasNamedPropertySuccess'; + } else if (item === '10.napiDefineProperties') { + // [Start ark_napi_define_properties] + // napi_define_properties + // 定义method类型的属性 + hilog.info(0x0000, 'testTag', 'Test Node-API define_method_properties:%{public}d', + testNapi.defineMethodProperties() + .defineMethodPropertiesExample()); + // 定义string类型的属性 + hilog.info(0x0000, 'testTag', 'Test Node-API define_string_properties::%{public}s ', + testNapi.defineStringProperties() + .defineStringPropertiesExample); + // getter和setter + hilog.info(0x0000, 'testTag', 'Test Node-API get::%{public}s ', + testNapi.createStringWithGetterSetter() + .getterCallback()); + hilog.info(0x0000, 'testTag', 'Test Node-API setter::%{public}s ', + testNapi.createStringWithGetterSetter() + .setterCallback('set data')); + // [End ark_napi_define_properties] + this.result = 'napiDefinePropertiesSuccess'; + } else if (item === '11.napiGetAllPropertyNames') { + // [Start ark_napi_get_all_property_names] + // napi_get_all_property_names + try { + class Obj { + public data: number = 0 + public message: string = '' + } + + let obj: Obj = { data: 0, message: 'hello world' }; + let propertyNames = testNapi.getAllPropertyNames(obj); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_all_property_names: %{public}s', + JSON.stringify(propertyNames)); + // [StartExclude ark_napi_get_all_property_names] + this.result = 'napiGetAllPropertyNamesSuccess'; + // [EndExclude ark_napi_get_all_property_names] + } catch (error) { + hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_all_property_names error: %{public}s', + error.message); + // [StartExclude ark_napi_get_all_property_names] + this.result = 'napiGetAllPropertyNamesFail'; + // [EndExclude ark_napi_get_all_property_names] + } + // [End ark_napi_get_all_property_names] + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + .id('List') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiDeleteProperty.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiDeleteProperty.ts old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiDeleteProperty.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiDeleteProperty.ts index 9c3a8b3383..7524a5a37e --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiDeleteProperty.ts +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiDeleteProperty.ts @@ -1,37 +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. - */ - -// [Start ark_napi_delete_property] -import testNapi from 'libentry.so'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -export function napiDeleteProperty() { - class Obj { - first: number = 0; - } - - let obj: Obj = { first: 1 }; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_delete_property first: %{public}s', - testNapi.deleteProperty(obj, 'first')); - //设置新的属性为不可配置 - //这里的Object.defineProperty方法在DevEco Studio 4.1.0.400及其以上版本不支持,需在ts使用 - Object.defineProperty(obj, 'config', { - configurable: false, - value: 'value' - }) - hilog.info(0x0000, 'testTag', 'Test Node-API napi_delete_property config: %{public}s', - testNapi.deleteProperty(obj, 'config')); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start ark_napi_delete_property] +import testNapi from 'libentry.so'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +export function napiDeleteProperty() { + class Obj { + first: number = 0; + } + + let obj: Obj = { first: 1 }; + hilog.info(0x0000, 'testTag', 'Test Node-API napi_delete_property first: %{public}s', + testNapi.deleteProperty(obj, 'first')); + //设置新的属性为不可配置 + //这里的Object.defineProperty方法在DevEco Studio 4.1.0.400及其以上版本不支持,需在ts使用 + Object.defineProperty(obj, 'config', { + configurable: false, + value: 'value' + }) + hilog.info(0x0000, 'testTag', 'Test Node-API napi_delete_property config: %{public}s', + testNapi.deleteProperty(obj, 'config')); +} // [End ark_napi_delete_property] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiHasOwnProperty.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiHasOwnProperty.ts old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiHasOwnProperty.ts rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiHasOwnProperty.ts index ada41ab320..33a517269d --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiHasOwnProperty.ts +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/napiHasOwnProperty.ts @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start ark_napi_has_own_property] -import { hilog } from '@kit.PerformanceAnalysisKit'; -import testNapi from 'libentry.so'; - -export function napiHasOwnProperty() { - let myObj = { 'myProperty': 1 }; - let inheritedObj = { 'inheritedProperty': 2 }; - // 这里的Object.setPrototypeOf方法在DevEco Studio 4.1.0.400及其以上版本不支持,需在ts使用 - Object.setPrototypeOf(myObj, inheritedObj); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_own_property my: %{public}s', - testNapi.napiHasOwnProperty(myObj, 'myProperty')); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_own_property inherited: %{public}s', - testNapi.napiHasOwnProperty(myObj, 'inheritedProperty')); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start ark_napi_has_own_property] +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; + +export function napiHasOwnProperty() { + let myObj = { 'myProperty': 1 }; + let inheritedObj = { 'inheritedProperty': 2 }; + // 这里的Object.setPrototypeOf方法在DevEco Studio 4.1.0.400及其以上版本不支持,需在ts使用 + Object.setPrototypeOf(myObj, inheritedObj); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_own_property my: %{public}s', + testNapi.napiHasOwnProperty(myObj, 'myProperty')); + hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_own_property inherited: %{public}s', + testNapi.napiHasOwnProperty(myObj, 'inheritedProperty')); +} // [End ark_napi_has_own_property] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/NodeAPIProperty.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/NodeAPIProperty.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/NodeAPIProperty.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/NodeAPIProperty.test.ets index 9db2e798cd..839c0c16aa --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/NodeAPIProperty.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/ets/test/NodeAPIProperty.test.ets @@ -1,223 +1,223 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIPropertyTest() { - describe('nodeAPIPropertyTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用napiGetPropertyNames相关函数 - */ - it('testNodeAPIProperty001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiGetPropertyNames')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetPropertyNamesSuccess')); - console.info('uitest: testNodeAPIArray001 end'); - done(); - }) - - /** - * 点击按钮,调用napiSetProperty相关函数 - */ - it('testNodeAPIProperty002', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('2.napiSetProperty')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiSetPropertySuccess')); - console.info('uitest: testNodeAPIArray002 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetProperty相关函数 - */ - it('testNodeAPIProperty003', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('3.napiGetProperty')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetPropertySuccess')); - console.info('uitest: testNodeAPIArray003 end'); - done(); - }) - - /** - * 点击按钮,调用napiHasProperty相关函数 - */ - it('testNodeAPIProperty004', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('4.napiHasProperty')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiHasPropertySuccess')); - console.info('uitest: testNodeAPIArray004 end'); - done(); - }) - - /** - * 点击按钮,调用napiDeleteProperty相关函数 - */ - it('testNodeAPIProperty005', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('5.napiDeleteProperty')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiDeletePropertySuccess')); - console.info('uitest: testNodeAPIArray005 end'); - done(); - }) - - /** - * 点击按钮,调用napiHasOwnProperty相关函数 - */ - it('testNodeAPIProperty006', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('6.napiHasOwnProperty')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiHasOwnPropertySuccess')); - console.info('uitest: testNodeAPIArray006 end'); - done(); - }) - - /** - * 点击按钮,调用napiSetNamedProperty相关函数 - */ - it('testNodeAPIProperty007', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray007 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('7.napiSetNamedProperty')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiSetNamedPropertySuccess')); - console.info('uitest: testNodeAPIArray007 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetNamedProperty相关函数 - */ - it('testNodeAPIProperty008', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray008 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('8.napiGetNamedProperty')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetNamedPropertySuccess')); - console.info('uitest: testNodeAPIArray008 end'); - done(); - }) - - /** - * 点击按钮,调用napiHasNamedProperty相关函数 - */ - it('testNodeAPIProperty009', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray009 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('9.napiHasNamedProperty')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiHasNamedPropertySuccess')); - console.info('uitest: testNodeAPIArray009 end'); - done(); - }) - - /** - * 点击按钮,调用napiDefineProperties相关函数 - */ - it('testNodeAPIProperty010', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray010 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('10.napiDefineProperties')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiDefinePropertiesSuccess')); - console.info('uitest: testNodeAPIArray010 end'); - done(); - }) - - /** - * 点击按钮,调用napiGetAllPropertyNames相关函数 - */ - it('testNodeAPIProperty011', 0, async (done: Function) => { - console.info('uitest: testNodeAPIArray011 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const list = await driver.findComponent(ON.id('List')) - await list.scrollToBottom(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('11.napiGetAllPropertyNames')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiGetAllPropertyNamesSuccess')); - console.info('uitest: testNodeAPIArray011 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIPropertyTest() { + describe('nodeAPIPropertyTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用napiGetPropertyNames相关函数 + */ + it('testNodeAPIProperty001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiGetPropertyNames')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetPropertyNamesSuccess')); + console.info('uitest: testNodeAPIArray001 end'); + done(); + }) + + /** + * 点击按钮,调用napiSetProperty相关函数 + */ + it('testNodeAPIProperty002', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('2.napiSetProperty')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiSetPropertySuccess')); + console.info('uitest: testNodeAPIArray002 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetProperty相关函数 + */ + it('testNodeAPIProperty003', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('3.napiGetProperty')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetPropertySuccess')); + console.info('uitest: testNodeAPIArray003 end'); + done(); + }) + + /** + * 点击按钮,调用napiHasProperty相关函数 + */ + it('testNodeAPIProperty004', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('4.napiHasProperty')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiHasPropertySuccess')); + console.info('uitest: testNodeAPIArray004 end'); + done(); + }) + + /** + * 点击按钮,调用napiDeleteProperty相关函数 + */ + it('testNodeAPIProperty005', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('5.napiDeleteProperty')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiDeletePropertySuccess')); + console.info('uitest: testNodeAPIArray005 end'); + done(); + }) + + /** + * 点击按钮,调用napiHasOwnProperty相关函数 + */ + it('testNodeAPIProperty006', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('6.napiHasOwnProperty')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiHasOwnPropertySuccess')); + console.info('uitest: testNodeAPIArray006 end'); + done(); + }) + + /** + * 点击按钮,调用napiSetNamedProperty相关函数 + */ + it('testNodeAPIProperty007', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray007 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('7.napiSetNamedProperty')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiSetNamedPropertySuccess')); + console.info('uitest: testNodeAPIArray007 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetNamedProperty相关函数 + */ + it('testNodeAPIProperty008', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray008 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('8.napiGetNamedProperty')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetNamedPropertySuccess')); + console.info('uitest: testNodeAPIArray008 end'); + done(); + }) + + /** + * 点击按钮,调用napiHasNamedProperty相关函数 + */ + it('testNodeAPIProperty009', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray009 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('9.napiHasNamedProperty')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiHasNamedPropertySuccess')); + console.info('uitest: testNodeAPIArray009 end'); + done(); + }) + + /** + * 点击按钮,调用napiDefineProperties相关函数 + */ + it('testNodeAPIProperty010', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray010 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('10.napiDefineProperties')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiDefinePropertiesSuccess')); + console.info('uitest: testNodeAPIArray010 end'); + done(); + }) + + /** + * 点击按钮,调用napiGetAllPropertyNames相关函数 + */ + it('testNodeAPIProperty011', 0, async (done: Function) => { + console.info('uitest: testNodeAPIArray011 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const list = await driver.findComponent(ON.id('List')) + await list.scrollToBottom(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('11.napiGetAllPropertyNames')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiGetAllPropertyNamesSuccess')); + console.info('uitest: testNodeAPIArray011 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/ohosTest.md new file mode 100644 index 0000000000..39ca296385 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/ohosTest.md @@ -0,0 +1,18 @@ +# 使用Node-API进行property相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------- | ------------ | ---------------------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 getPropertyNames | 位于主页 | 点击文本为1.napiGetPropertyNames的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetPropertyNamesSuccess | Pass | +| ArkTS端成功调用native侧接口setProperty | 位于主页 | 点击文本为2.napiSetProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiSetPropertySuccess | Pass | +| ArkTS端成功调用native侧接口getProperty | 位于主页 | 点击文本为3.napiGetProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetPropertySuccess | Pass | +| ArkTS端成功调用native侧接口hasProperty | 位于主页 | 点击文本为4.napiHasProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiHasPropertySuccess | Pass | +| ArkTS端成功调用native侧接口napiDeleteProperty | 位于主页 | 点击文本为5.napiDeleteProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDeletePropertySuccess | Pass | +| ArkTS端成功调用native侧接口napiHasOwnProperty | 位于主页 | 点击文本为6.napiHasOwnProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiHasOwnPropertySuccess | Pass | +| ArkTS端成功调用native侧接口napiSetNamedProperty | 位于主页 | 点击文本为7.napiSetNamedProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiSetNamedPropertySuccess | Pass | +| ArkTS端成功调用native侧接口napiGetNamedProperty | 位于主页 | 点击文本为8.napiGetNamedProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetNamedPropertySuccess | Pass | +| ArkTS端成功调用native侧接口napiHasNamedProperty | 位于主页 | 点击文本为9.napiHasNamedProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiHasNamedPropertySuccess | Pass | +| ArkTS端成功调用native侧接口defineStringProperties | 位于主页 | 点击文本为10.napiDefineProperties的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDefinePropertiesSuccess | Pass | +| ArkTS端成功调用native侧接口getAllPropertyNames | 位于主页 | 点击文本为11.napiGetAllPropertyNames的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetAllPropertyNamesSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/screenshots/NodeAPIProperty1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/screenshots/NodeAPIProperty1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/screenshots/NodeAPIProperty1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/screenshots/NodeAPIProperty1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/screenshots/NodeAPIProperty2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/screenshots/NodeAPIProperty2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/screenshots/NodeAPIProperty2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeAPIProperty/screenshots/NodeAPIProperty2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/.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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/app.json5 new file mode 100644 index 0000000000..eafb1afea5 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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.nodeapicustomasynchronousoperations", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..e56ec1a57c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeApiCustomAsynchronousOperations" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/README.md new file mode 100644 index 0000000000..472269d2e0 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/README.md @@ -0,0 +1,75 @@ +# ArkTS使用Node-API进行自定义异步操作相关开发 + +### 介绍 + +使用Node-API的自定义异步操作功能,可以使ArkTS的使用更加灵活和高效,可以处理那些可能阻塞事件循环的长时间运行任务,同时保持ArkTS应用的响应性和性能。 + +本工程主要展示了使用Node-API进行创建和销毁异步资源上下文环境、在异步资源上下文环境中执行ArkTS回调函数和创建关闭回调作用域实现场景,其中代码详细描述可查如下链接。 + +- [使用Node-API进行自定义异步操作相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-custom-asynchronous-operations.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeApiCustomAsynchronousOperations.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行自定义异步操作相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeApiCustomAsynchronousOperations.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations > .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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..c921de18a8 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,19 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(use_napi_about_custom_asynchronous_operations) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) + +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libhilog_ndk.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..fec57c3c1d --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_async_open_close_callback_scope] +#include "napi/native_api.h" + +static constexpr int INT_ARG_3 = 3; // 入参索引 + +static napi_value AsynchronousWork(napi_env env, napi_callback_info info) +{ + // 接受四个参数 + size_t argc = 4; + napi_value args[4] = {nullptr}; + // 从回调信息中获取参数 + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 提取参数中的资源、接收器对象和函数 + napi_value resource = args[0]; + napi_value recv = args[1]; + napi_value func = args[2]; + napi_value argv[1] = {nullptr}; + argv[0] = args[INT_ARG_3]; + // 获取函数的类型 + napi_valuetype funcType; + napi_typeof(env, func, &funcType); + // 创建一个资源名称为"test"的字符串 + napi_value resourceName = nullptr; + napi_create_string_utf8(env, "test", NAPI_AUTO_LENGTH, &resourceName); + // 初始化异步上下文 + napi_async_context context; + napi_status status = napi_async_init(env, resource, resourceName, &context); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_async_init fail"); + return nullptr; + } + // 打开回调作用域 + napi_callback_scope scope = nullptr; + napi_open_callback_scope(env, resource, context, &scope); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_open_callback_scope fail"); + return nullptr; + } + // 调用回调函数 + napi_value result = nullptr; + if (funcType == napi_function) { + napi_make_callback(env, context, recv, func, 1, argv, &result); + } else { + napi_throw_error(env, nullptr, "Unexpected argument type"); + return nullptr; + } + // 关闭回调作用域 + napi_close_callback_scope(env, scope); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "napi_close_callback_scope fail"); + return nullptr; + } + // 销毁异步上下文 + napi_async_destroy(env, context); + return result; +} +// [End napi_async_open_close_callback_scope] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"asynchronousWork", nullptr, AsynchronousWork, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..7cba3716d7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_async_open_close_callback_scope_api] +export const asynchronousWork: (object: Object, obj: Object, fun: Function, num: number) => number | void; +// [End napi_async_open_close_callback_scope_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..4764c2b12c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/pages/Index.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. + */ + +// [Start ark_napi_async_open_close_callback_scope] +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; +import process from '@ohos.process'; + +// [StartExclude ark_napi_async_open_close_callback_scope] +@Entry +@Component +struct Index { + @State result: string = ''; + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(25) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 3 }) + List({ space: '10vp' }) { + ListItem() { + Text('1.customAsync') + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + // [EndExclude ark_napi_async_open_close_callback_scope] + try { + hilog.info(0x0000, 'testTag', 'Test Node-API asynchronousWork: %{public}d', + testNapi.asynchronousWork({}, process.ProcessManager, (num: number) => { + return num; + }, 123)); + this.result = 'customAsyncSuccess'; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Test Node-API asynchronousWork error: %{public}s', error.message); + this.result = 'customAsyncFail'; + } + // [End ark_napi_async_open_close_callback_scope] + }) + } + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/NodeApiCustomAsynchronousOperations.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/NodeApiCustomAsynchronousOperations.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/NodeApiCustomAsynchronousOperations.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/NodeApiCustomAsynchronousOperations.test.ets index d74879a7e4..5a937534d2 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/NodeApiCustomAsynchronousOperations.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/ets/test/NodeApiCustomAsynchronousOperations.test.ets @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeApiCustomAsynchronousOperationsTest() { - describe('nodeApiCustomAsynchronousOperationsTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用customAsync相关函数 - */ - it('testNodeApiCustomAsynchronousOperations001', 0, async (done: Function) => { - console.info('uitest: testNodeApiCustomAsynchronousOperations001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.customAsync')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: customAsyncSuccess')); - console.info('uitest: testNodeApiCustomAsynchronousOperations001 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeApiCustomAsynchronousOperationsTest() { + describe('nodeApiCustomAsynchronousOperationsTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用customAsync相关函数 + */ + it('testNodeApiCustomAsynchronousOperations001', 0, async (done: Function) => { + console.info('uitest: testNodeApiCustomAsynchronousOperations001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.customAsync')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: customAsyncSuccess')); + console.info('uitest: testNodeApiCustomAsynchronousOperations001 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/ohosTest.md new file mode 100644 index 0000000000..7bb5b0bb69 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/ohosTest.md @@ -0,0 +1,8 @@ +# 使用Node-API进行自定义异步操作相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------- | ------------ | --------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口asynchronousWork | 位于主页 | 点击文本为1.customAsync的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: customAsyncSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/screenshots/NodeApiCustomAsynchronousOperations1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/screenshots/NodeApiCustomAsynchronousOperations1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/screenshots/NodeApiCustomAsynchronousOperations1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/screenshots/NodeApiCustomAsynchronousOperations1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/screenshots/NodeApiCustomAsynchronousOperations2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/screenshots/NodeApiCustomAsynchronousOperations2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/screenshots/NodeApiCustomAsynchronousOperations2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/screenshots/NodeApiCustomAsynchronousOperations2.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/.gitignore new file mode 100644 index 0000000000..d2ff20141c --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/.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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/AppScope/app.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/AppScope/app.json5 new file mode 100644 index 0000000000..468b1ae0de --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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.nodeapistring", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000..14cc24af14 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NodeApiString" + } + ] +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/media/app_icon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/media/app_icon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/README.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/README.md new file mode 100644 index 0000000000..45a7b9643b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/README.md @@ -0,0 +1,73 @@ +# ArkTS使用Node-API进行string相关开发 + +### 介绍 + +使用Node-API关于string的六个接口,可以让Node-API模块和ArkTS字符串进行交互,本工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [使用Node-API进行string相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-string.md) + +### 效果预览 + +| 首页 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 +3. 运行测试用例NodeApiString.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── Index.d.ts + │ │ ├── oh-package.json5 + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用Node-API进行string相关开发示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── NodeApiString.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString > .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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/build-profile.json5 new file mode 100644 index 0000000000..9a067264a4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/code-linter.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/code-linter.json5 new file mode 100644 index 0000000000..28586467ee --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/.gitignore b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/.gitignore new file mode 100644 index 0000000000..e2713a2779 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/build-profile.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/build-profile.json5 new file mode 100644 index 0000000000..3186225747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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": false, + "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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/hvigorfile.ts new file mode 100644 index 0000000000..e4f43d5466 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/oh-package.json5 new file mode 100644 index 0000000000..118bdd4fe7 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000..5d1147dffa --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(use_napi_about_string) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +add_definitions( "-DLOG_DOMAIN=0xd0d0" ) +add_definitions( "-DLOG_TAG=\"testTag\"" ) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000..218e221670 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,162 @@ +/* + * 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 +#include + +static const int MAX_BUFFER_SIZE = 128; + +// [Start napi_get_value_string_utf8] +static napi_value GetValueStringUtf8(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取字符串的长度 + size_t length = 0; + napi_status status = napi_get_value_string_utf8(env, args[0], nullptr, 0, &length); + // 传入一个非字符串 napi_get_value_string_utf8接口会返回napi_string_expected + if (status != napi_ok) { + return nullptr; + } + char *buf = new char[length + 1]; + std::memset(buf, 0, length + 1); + napi_get_value_string_utf8(env, args[0], buf, length + 1, &length); + napi_value result = nullptr; + status = napi_create_string_utf8(env, buf, length, &result); + delete buf; + if (status != napi_ok) { + return nullptr; + }; + return result; +} +// [End napi_get_value_string_utf8] + +// [Start napi_create_string_utf8] +static napi_value CreateStringUtf8(napi_env env, napi_callback_info info) +{ + const char *str = u8"你好, World!, successes to create UTF-8 string! 111"; + size_t length = strlen(str); + napi_value result = nullptr; + napi_status status = napi_create_string_utf8(env, str, length, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to create UTF-8 string"); + return nullptr; + } + return result; +} +// [End napi_create_string_utf8] + +// [Start napi_get_value_string_utf16] +static napi_value GetValueStringUtf16(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1]; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + napi_value result = nullptr; + // 字符串的缓冲区 + char16_t buffer[MAX_BUFFER_SIZE]; + // 字符串的缓冲区大小 + size_t bufferSize = MAX_BUFFER_SIZE; + // 字符串的长度 + size_t stringLen; + // 获取字符串的数据和长度 + napi_get_value_string_utf16(env, args[0], buffer, bufferSize, &stringLen); + // 获取字符串返回结果 + napi_create_string_utf16(env, buffer, stringLen, &result); + // 返回结果 + return result; +} +// [End napi_get_value_string_utf16] + +// [Start napi_create_string_utf16] +static napi_value CreateStringUtf16(napi_env env, napi_callback_info info) +{ + const char16_t *str = u"你好, World!, successes to create UTF-16 string! 111"; + size_t length = NAPI_AUTO_LENGTH; + napi_value result = nullptr; + napi_status status = napi_create_string_utf16(env, str, length, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to create UTF-16 string"); + return nullptr; + } + return result; +} +// [End napi_create_string_utf16] + +// [Start napi_get_value_string_latin1] +static napi_value GetValueStringLatin1(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + char buf[MAX_BUFFER_SIZE]; + size_t length = 0; + napi_value napi_Res = nullptr; + napi_status status = napi_get_value_string_latin1(env, args[0], buf, MAX_BUFFER_SIZE, &length); + // 当输入的值不是字符串时,接口会返回napi_string_expected + if (status == napi_string_expected) { + return nullptr; + } + napi_create_string_latin1(env, buf, length, &napi_Res); + return napi_Res; +} +// [End napi_get_value_string_latin1] + +// [Start napi_create_string_latin1] +static napi_value CreateStringLatin1(napi_env env, napi_callback_info info) +{ + const char *str = "Hello, World! éçñ, successes to create Latin1 string! 111"; + size_t length = NAPI_AUTO_LENGTH; + napi_value result = nullptr; + napi_status status = napi_create_string_latin1(env, str, length, &result); + if (status != napi_ok) { + // 处理错误 + napi_throw_error(env, nullptr, "Failed to create Latin1 string"); + return nullptr; + } + return result; +} +// [End napi_create_string_latin1] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"getValueStringUtf8", nullptr, GetValueStringUtf8, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createStringUtf8", nullptr, CreateStringUtf8, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getValueStringUtf16", nullptr, GetValueStringUtf16, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createStringUtf16", nullptr, CreateStringUtf16, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getValueStringLatin1", nullptr, GetValueStringLatin1, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createStringLatin1", nullptr, CreateStringLatin1, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000..3c26ca99ce --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start napi_get_value_string_utf8_api] +export const getValueStringUtf8: (param: string | number) => string | void; +// [End napi_get_value_string_utf8_api] + +// [Start napi_create_string_utf8_api] +export const createStringUtf8: () => string | void; +// [End napi_create_string_utf8_api] + +// [Start napi_get_value_string_utf16_api] +export const getValueStringUtf16: (data: string) => string; +// [End napi_get_value_string_utf16_api] + +// [Start napi_create_string_utf16_api] +export const createStringUtf16: () => string | void; +// [End napi_create_string_utf16_api] + +// [Start napi_get_value_string_latin1_api] +export const getValueStringLatin1: (param: number | string) => string | void; +// [End napi_get_value_string_latin1_api] + +// [Start napi_create_string_latin1_api] +export const createStringLatin1: () => string | void; +// [End napi_create_string_latin1_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000..6abf3b7c20 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000..965554bb3a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000..b1e2129472 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000..23a4e3141b --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,95 @@ +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State result: string = '' + private items: string[] = [ + 'Reset Result Message', + '1.napiString' + ] + + build() { + Column() { + Text('Result: ' + this.result) + .fontSize(22) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 4 }) + List({ space: '10vp' }) { + ForEach(this.items, (item: string) => { + ListItem() { + Text(item) + .fontSize(16) + .width('100%') + .height(60) + .textAlign(TextAlign.Center) + .fontWeight(FontWeight.Bold) + .borderRadius(30) + .backgroundColor(Color.White) + .onClick(() => { + if (item === 'Reset Result Message') { + this.result = ''; + } else if (item === '1.napiString') { + // [Start ark_napi_get_value_string_utf8] + // 分别传入字符和非字符检测接口,传入字符串类型的数据将返回原字符串,传入其他类型返回undefined + hilog.info(0x0000, 'testTag', 'Test Node-API get_value_string_utf8_string %{public}s', + testNapi.getValueStringUtf8('aaBC+-$%^你好123')); + hilog.info(0x0000, 'testTag', 'Test Node-API get_value_string_utf8_not_string %{public}s', + testNapi.getValueStringUtf8(50)); + // [End ark_napi_get_value_string_utf8] + // [Start ark_napi_create_string_utf8] + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_string_utf8:%{public}s', + testNapi.createStringUtf8()); + // [End ark_napi_create_string_utf8] + // [Start ark_napi_get_value_string_utf16] + let result = testNapi.getValueStringUtf16('hello,'); + hilog.info(0x0000, 'testTag', 'Node-API napi_get_value_string_utf16:%{public}s', result); + // [End ark_napi_get_value_string_utf16] + // [Start ark_napi_create_string_utf16] + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_string_utf16:%{public}s ', + testNapi.createStringUtf16()); + // [End ark_napi_create_string_utf16] + // [Start ark_napi_get_value_string_latin1] + // 传入非字符型数据,函数返回undefined + hilog.info(0x0000, 'testTag', 'Test Node-API get_value_string_latin1_not_string %{public}s', + testNapi.getValueStringLatin1(10)); + // ISO-8859-1编码不支持中文,传入中文字符会乱码 + hilog.info(0x0000, 'testTag', 'Test Node-API get_value_string_latin1_string_chinese %{public}s', + testNapi.getValueStringLatin1('中文')); + // 传入其他字符,不会乱码 + hilog.info(0x0000, 'testTag', 'Test Node-API get_value_string_latin1_string %{public}s', + testNapi.getValueStringLatin1('abo ABP=-&*/')); + // [End ark_napi_get_value_string_latin1] + // [Start ark_napi_create_string_latin1] + hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_string_latin1:%{public}s', + testNapi.createStringLatin1()); + // End ark_napi_create_string_latin1] + this.result = 'napiStringSuccess'; + } + }) + } + }) + }.scrollBar(BarState.Off) + .width('90%') + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/module.json5 new file mode 100644 index 0000000000..4144486d1a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000..3c712962da --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/background.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/background.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/foreground.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/foreground.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000..fb49920440 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/startIcon.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/media/startIcon.png diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000..78f40ae7c4 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000..1898d94f58 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000..79b11c2747 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/en_US/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/en_US/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/zh_CN/element/string.json rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/NodeApiString.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/NodeApiString.test.ets old mode 100755 new mode 100644 similarity index 97% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/NodeApiString.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/NodeApiString.test.ets index 7e36a6a717..989f22c481 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/NodeApiString.test.ets +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/ets/test/NodeApiString.test.ets @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nodeAPIStringTest() { - describe('nodeAPIStringTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,调用Node-API关于string的方法 - */ - it('testNodeAPIString001', 0, async (done: Function) => { - console.info('uitest: testNodeAPIString001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('1.napiString')); - await driver.delayMs(1000); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Result: napiStringSuccess')); - console.info('uitest: testNodeAPIString001 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nodeAPIStringTest() { + describe('nodeAPIStringTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,调用Node-API关于string的方法 + */ + it('testNodeAPIString001', 0, async (done: Function) => { + console.info('uitest: testNodeAPIString001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const text = await driver.findComponent(ON.text('1.napiString')); + await driver.delayMs(1000); + await text.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Result: napiStringSuccess')); + console.info('uitest: testNodeAPIString001 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000..c3fd9dda30 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/test/List.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/test/List.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/test/List.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/test/List.test.ets diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/test/LocalUnit.test.ets rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/entry/src/test/LocalUnit.test.ets diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000..d584c19c24 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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.1", + "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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/hvigorfile.ts b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/hvigorfile.ts new file mode 100644 index 0000000000..2a5e543f19 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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/ArkTS/NodeAPI/NodeApiUse/NodeApiString/oh-package.json5 b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/oh-package.json5 new file mode 100644 index 0000000000..e41bae026a --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/ohosTest.md b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/ohosTest.md new file mode 100644 index 0000000000..0b01563969 --- /dev/null +++ b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/ohosTest.md @@ -0,0 +1,8 @@ +# 使用Node-API进行string相关开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +| ------------------------------------------------------------ | ------------ | -------------------------------- | ------------------------------------------------------------ | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | +| ArkTS端成功调用native侧接口 getValueStringUtf8,createStringUtf8,getValueStringUtf16, createStringUtf16, getValueStringLatin1,createStringLatin1 | 位于主页 | 点击文本为1.napiString的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiStringSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/screenshots/NodeApiString1.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/screenshots/NodeApiString1.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/screenshots/NodeApiString1.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/screenshots/NodeApiString1.png diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/screenshots/NodeApiString2.png b/code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/screenshots/NodeApiString2.png old mode 100755 new mode 100644 similarity index 100% rename from code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/screenshots/NodeApiString2.png rename to code/DocsSample/ArkTS/NodeAPI/NodeApiUse/NodeApiString/screenshots/NodeApiString2.png diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/app.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/app.json5 deleted file mode 100755 index a5a836facd..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.dynamicimport", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/element/string.json deleted file mode 100755 index c33ab7f153..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "DynamicImport" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/README.md b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/README.md deleted file mode 100755 index c5e1069415..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/README.md +++ /dev/null @@ -1,111 +0,0 @@ -# ArkTS动态加载 - -### 介绍 - -动态import支持条件延迟加载,支持部分反射功能,可以提升页面的加载速度;动态import支持加载HSP模块/HAR模块/OHPM包/Native库等,并且HAR模块间只有变量动态import时还可以进行模块解耦 - -本示例主要展示了动态加载的业务拓展场景介绍、动态加载常量表达式、动态加载变量表达式以及HAR模块间动态加载依赖解耦这些场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [动态加载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-dynamic-import.md) - -### 效果预览 - -| 执行结果图 | -| ------------------------------------------------------------ | -| | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,分别点击ListItem组件可以执行对应文本内容的操作,然后在控制台中打印出对应日志。 -3. 运行测试用例DynamicImport.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 动态加载示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── DynamicImport.test.ets // 自动化测试代码 - │ │ └── List.test.ets - har1 // har1模块函数实现 - ├── src - │ ├── main - │ │ ├── ets - │ │ │ ├── utils - │ │ │ │ └── Calc.ets - │ │ │ └── components - │ │ │ │ └── MainPage.ets - har2 // har1模块函数实现 - ├── src - │ ├── main - │ │ ├── ets - │ │ │ ├── utils - │ │ │ │ └── Calc.ets - │ │ │ └── components - │ │ │ │ └── MainPage.ets - ├── index.ets - harlibrary // harlibrary模块函数实现 - ├── src - │ ├── main - │ │ ├── ets - │ │ │ ├── utils - │ │ │ │ └── Calc.ets - │ │ │ └── components - │ │ │ │ └── MainPage.ets - ├── index.ets - myHar // myHar模块函数实现 - ├── src - │ ├── main - │ │ ├── ets - │ │ │ └── components - │ │ │ │ └── MainPage.ets - ├── index.ets - myHsp // myHsp模块函数实现 - ├── src - │ ├── main - │ │ ├── ets - │ │ │ ├── pages - │ │ │ │ └── Index.ets - │ │ │ └── utils - │ │ │ │ └── Calc.ets - ├── index.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport > .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/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/build-profile.json5 deleted file mode 100755 index a8c3e30b26..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/build-profile.json5 +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "harlibrary", - "srcPath": "./harlibrary", - }, - { - "name": "myHar", - "srcPath": "./myHar", - }, - { - "name": "myHsp", - "srcPath": "./myHsp", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "har1", - "srcPath": "./har1", - }, - { - "name": "har2", - "srcPath": "./har2", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/build-profile.json5 deleted file mode 100755 index 9deb3b133d..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/build-profile.json5 +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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": { - "arkOptions": { - "runtimeOnly": { - "packages": [ - "myhar", - // 仅用于使用变量动态import其他模块名场景,静态import或常量动态import无需配置。 - "myhsp", - // 仅用于使用变量动态import其他模块名场景,静态import或常量动态import无需配置。 - "@ohos/hypium", - "@ohos/crypto-js", - "libentry.so", - "har1", - "har2" - ], - // 配置本模块变量动态import其他模块名,要求与dependencies中配置的名字一致。 - "sources": [ - // 仅用于使用变量动态import模块自己单文件场景,静态import或常量动态import无需配置。 - "./src/main/ets/utils/Calc.ets", - "./src/main/ets/Calc.ets" - ] - // 配置本模块变量动态import自己的文件路径,路径相对于当前build-profile.json5文件。 - } - }, - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - "abiFilters": [ - "arm64-v8a", - "x86_64", - "armeabi-v7a" - ] - }, - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - } - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/oh-package.json5 deleted file mode 100755 index e3ec659f19..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/oh-package.json5 +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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": { - "harlibrary": "file:../harlibrary", - "myhar": "file:../myHar", - //HAP常量动态import HAR模块名 HAP常量动态import HAR模块文件路径 - "myhsp": "file:../myHsp", - //HAP常量动态import HSP模块名 HAP常量动态import HSP模块名文件路径 - "@ohos/crypto-js": "2.0.3-rc.0", - //HAP常量动态import远程HAR模块名 - "@ohos/hypium": "1.0.19", - //HAP常量动态import ohpm包 - "libentry.so": "file:./src/main/cpp/types/libentry", - //HAP常量动态import自己的Native库 - "har1": "file:../har1", - "har2": "file:../har2" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 47d73d8977..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(DynamicImport) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index fd3f2e882c..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" - -static napi_value Add(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - napi_valuetype valuetype0; - napi_typeof(env, args[0], &valuetype0); - napi_valuetype valuetype1; - napi_typeof(env, args[1], &valuetype1); - double value0; - napi_get_value_double(env, args[0], &value0); - double value1; - napi_get_value_double(env, args[1], &value1); - napi_value sum; - napi_create_double(env, value0 + value1, &sum); - return sum; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/index.d.ts deleted file mode 100755 index 27eb9617d2..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start hap_const_dynamic_import_native] -export const add: (a: number, b: number) => number; -// [End hap_const_dynamic_import_native] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index e8f69f3d76..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/Calc.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/Calc.ets deleted file mode 100755 index 606453a50d..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/Calc.ets +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start hap_const_dynamic_import_add] -export function add(a: number, b: number): number { - let c = a + b; - console.info('DynamicImport I am a HAP, %d + %d = %d', a, b, c); - return c; -} -// [End hap_const_dynamic_import_add] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index 3e77e4b9f7..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Calc.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Calc.ets deleted file mode 100755 index 591ad6994e..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Calc.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export function add(a: number, b: number): number { - let c = a + b; - console.info('DynamicImport I am a HAP, %d + %d = %d', a, b, c); - return c; -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/utils/Calc.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/utils/Calc.ets deleted file mode 100755 index 591ad6994e..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/utils/Calc.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export function add(a: number, b: number): number { - let c = a + b; - console.info('DynamicImport I am a HAP, %d + %d = %d', a, b, c); - return c; -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/Index.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/Index.ets deleted file mode 100755 index e0345cb61d..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/Index.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { MainPage } from './src/main/ets/components/MainPage'; - -// [Start export_add_har1] -export { addHar1 } from './src/main/ets/utils/Calc'; -// [End export_add_har1] diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/build-profile.json5 deleted file mode 100755 index 5552c941de..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/build-profile.json5 +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - }, - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/oh-package.json5 deleted file mode 100755 index 0768095555..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/oh-package.json5 +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "name": "har1", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - "dependencies": {} -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/components/MainPage.ets deleted file mode 100755 index 1243a59406..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/components/MainPage.ets +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MainPage { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/utils/Calc.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/utils/Calc.ets deleted file mode 100755 index 7cc5071259..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/utils/Calc.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start function_add_har1] -export function addHar1(a: number, b: number): number { - let c = a + b; - console.info('DynamicImport I am har1, %d + %d = %d', a, b, c); - - let harName = 'har2'; - import(harName).then((ns: ESObject) => { - console.info('DynamicImport addHar2 4 + 5 = ' + ns.addHar2(4, 5)); - }); - return c; -} -// [End function_add_har1] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/module.json5 deleted file mode 100755 index bdac60be9a..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/module.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "har1", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/module.json5 deleted file mode 100755 index 49d7bcb9fe..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "har1_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/Index.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/Index.ets deleted file mode 100755 index 248cad021d..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/Index.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { MainPage } from './src/main/ets/components/MainPage'; - -// [Start export_add_har2] -export { addHar2 } from './src/main/ets/utils/Calc' -// [End export_add_har2] diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/build-profile.json5 deleted file mode 100755 index 5552c941de..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/build-profile.json5 +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - }, - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/oh-package.json5 deleted file mode 100755 index 39e87d1423..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/oh-package.json5 +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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": "har2", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - "dependencies": {} -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/components/MainPage.ets deleted file mode 100755 index 1243a59406..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/components/MainPage.ets +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MainPage { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/utils/Calc.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/utils/Calc.ets deleted file mode 100755 index 13cc0fe20a..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/ets/utils/Calc.ets +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start function_add_har2] -export function addHar2(a: number, b: number): number { - let c = a + b; - console.info('DynamicImport I am har2, %d + %d = %d', a, b, c); - return c; -} -// [End function_add_har2] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/module.json5 deleted file mode 100755 index 26b32e3ff5..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/main/module.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "har2", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/module.json5 deleted file mode 100755 index 68ada365ca..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/har2/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "har2_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/Index.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/Index.ets deleted file mode 100755 index ce8819144b..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/Index.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { MainPage } from './src/main/ets/components/MainPage' - -// [Start module_members_export] -export { Calc, addHarlibrary } from './src/main/ets/utils/Calc' -// [End module_members_export] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/build-profile.json5 deleted file mode 100755 index 5552c941de..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/build-profile.json5 +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - }, - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/oh-package.json5 deleted file mode 100755 index fd559b8421..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/oh-package.json5 +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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": "harlibrary", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - "dependencies": {} -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/components/MainPage.ets deleted file mode 100755 index 1243a59406..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/components/MainPage.ets +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MainPage { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/utils/Calc.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/utils/Calc.ets deleted file mode 100755 index 022d3ccd82..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/ets/utils/Calc.ets +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start dynamic_call_add] -export class Calc { - public static staticAdd(a: number, b: number): number { - let c = a + b; - console.info('DynamicImport I am harlibrary in staticAdd, %d + %d = %d', a, b, c); - return c; - } - - public instanceAdd(a: number, b: number): number { - let c = a + b; - console.info('DynamicImport I am harlibrary in instanceAdd, %d + %d = %d', a, b, c); - return c; - } -} - -export function addHarlibrary(a: number, b: number): number { - let c = a + b; - console.info('DynamicImport I am harlibrary in addHarlibrary, %d + %d = %d', a, b, c); - return c; -} -// [End dynamic_call_add] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/module.json5 deleted file mode 100755 index 1bb4d3be02..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/main/module.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "harlibrary", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/module.json5 deleted file mode 100755 index 5e30fc1307..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/harlibrary/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "harlibrary_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/Index.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/Index.ets deleted file mode 100755 index 04b0c49812..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/Index.ets +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { MainPage } from './src/main/ets/components/MainPage' - -// [Start const_dynamic_import_har] -export function add(a: number, b: number): number { - let c = a + b; - console.info('DynamicImport I am a HAR, %d + %d = %d', a, b, c); - return c; -} -// [End const_dynamic_import_har] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/build-profile.json5 deleted file mode 100755 index 5552c941de..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/build-profile.json5 +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - }, - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/oh-package.json5 deleted file mode 100755 index f920fe0def..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/oh-package.json5 +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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": "myhar", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - "dependencies": {} -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/ets/components/MainPage.ets deleted file mode 100755 index 1243a59406..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/ets/components/MainPage.ets +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MainPage { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/module.json5 deleted file mode 100755 index 99a54418fd..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/main/module.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "myHar", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/module.json5 deleted file mode 100755 index fdacb0b459..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHar/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "myHar_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/Index.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/Index.ets deleted file mode 100755 index 5166a860b1..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/Index.ets +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start const_dynamic_import_hsp] -export function add(a: number, b: number): number { - let c = a + b; - console.info('DynamicImport I am a HSP, %d + %d = %d', a, b, c); - return c; -} -// [End const_dynamic_import_hsp] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/build-profile.json5 deleted file mode 100755 index fc9f620cc7..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/oh-package.json5 deleted file mode 100755 index 74befca1b5..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "myhsp", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - "packageType": "InterfaceHar", - "dependencies": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/module.json5 deleted file mode 100755 index 3dd3c21994..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "myHsp", - "type": "shared", - "description": "$string:shared_desc", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/resources/base/element/string.json deleted file mode 100755 index 95ba6cbabb..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/main/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "shared_desc", - "value": "description" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/module.json5 deleted file mode 100755 index 3c711dbadd..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/myHsp/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "myHsp_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/ohosTest.md b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/ohosTest.md deleted file mode 100755 index e75996f677..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/DynamicImport/ohosTest.md +++ /dev/null @@ -1,27 +0,0 @@ -# 动态加载测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------------- | ------------ | ---- | ---------------------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 动态加载harlibrary模块调用函数 | 成功拉起应用 | | 输出日志 | 是 | Pass | -| HAP常量动态import HAR模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP常量动态import HAR模块文件路径 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP常量动态import HSP模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP常量动态import HSP模块名文件路径 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP常量动态import远程HAR模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP常量动态import ohpm包 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP常量动态import自己的单文件 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP常量动态import自己的Native库 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP常量动态import加载API | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP变量动态import HAR模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP变量动态import HAR模块文件路径 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP变量动态import HSP模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP变量动态import HSP模块名文件路径 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP变量动态import远程HAR模块名 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP变量动态import ohpm包 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP变量动态import自己的单文件 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP变量动态import自己的Native库 | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| HAP变量动态import加载API | 成功拉起应用 | | 成功调用模块函数输出日志 | 是 | Pass | -| 动态加载耦合har包 | 成功拉起应用 | | 加载har1可以调用har2函数并打印日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/app.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/app.json5 deleted file mode 100755 index fb8e60ca1c..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsapisloadnativemodule", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/element/string.json deleted file mode 100755 index 0965d737f8..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsApisLoadNativeModule" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/README.md b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/README.md deleted file mode 100755 index e3ee2fcaaa..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS同步方式动态加载native模块 - -### 介绍 - -本工程主要展示了使用loadNativeModule接口能力进行同步方式加载native模块。该工程中展示的代码详细描述可查如下链接部分。 - -- [同步方式动态加载native模块](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/js-apis-load-native-module.md) - -### 效果预览 - -| 首页 | 点击HAP加载系统库模块按钮后 | 点击HAP加载Native库按钮后 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面中Text组件文本呈现LoadNativeModule效果并有两个按钮,分别点击之后第两个个按钮Text文本变化如上图并在工作台打印日志。 -3. 运行测试用例JsApisLoadNativeModule.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── index.d.ts - │ │ │ ├── CMakeList.txt - │ │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 同步方式动态加载native模块 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── JsApisLoadNativeModule.test.ets // 自动化测试代码 - │ │ └── List.test -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule > .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/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/build-profile.json5 deleted file mode 100755 index 472a926042..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/build-profile.json5 +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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", - // [Start hap_load_native_dependence_01] - "buildOption": { - "arkOptions": { - "runtimeOnly": { - "packages": [ - "libentry.so" - ] - } - }, - // [StartExclude hap_load_native_dependence_01] - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - "abiFilters": [ - "arm64-v8a", - "x86_64", - "armeabi-v7a" - ] - }, - // [EndExclude hap_load_native_dependence_01] - }, - // [End hap_load_native_dependence_01] - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/oh-package.json5 deleted file mode 100755 index d11c699914..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/oh-package.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "", - // [Start hap_load_native_dependence] - "dependencies": { - "libentry.so": "file:./src/main/cpp/types/libentry" - }, - // [End hap_load_native_dependence] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index bcfe2e711d..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(syncNative) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 797f8cde78..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" - -static napi_value Add(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - napi_valuetype valuetype0; - napi_typeof(env, args[0], &valuetype0); - - napi_valuetype valuetype1; - napi_typeof(env, args[1], &valuetype1); - - double value0; - napi_get_value_double(env, args[0], &value0); - - double value1; - napi_get_value_double(env, args[1], &value1); - - napi_value sum; - napi_create_double(env, value0 + value1, &sum); - - return sum; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/index.d.ts deleted file mode 100755 index 0069b64ba2..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start hap_load_native] -export const add: (a: number, b: number) => number; -// [End hap_load_native] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 908bff690b..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index b23d2fe946..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/module.json5 deleted file mode 100755 index d777a889f6..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/module.json5 deleted file mode 100755 index cb58bf6e31..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigor/hvigor-config.json5 deleted file mode 100755 index b839e93945..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/oh-package.json5 deleted file mode 100755 index 95bf2b62b5..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/ohosTest.md b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/ohosTest.md deleted file mode 100755 index 7918401ea1..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule/ohosTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# 同步方式动态加载Native模块测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------ | ------------ | ------------------------- | ------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| 主页按钮点击 | 位于主页 | 点击HAP加载系统库模块按钮 | 页面文本变化 | Pass | -| 主页按钮点击 | 位于主页 | 点击HAP加载Native库按钮 | 页面文本变化 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/app.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/app.json5 deleted file mode 100755 index 836ca10004..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.lazyimport", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/element/string.json deleted file mode 100755 index 3f16263846..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "LazyImport" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/README.md b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/README.md deleted file mode 100755 index 4f92135947..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# ArkTS延迟加载(lazy import) - -### 介绍 - -本工程主要对比了延迟加载与普通加载的区别,并展示延迟加载的错误使用方法。该工程中展示的代码详细描述可查如下链接部分。 - -- [延迟加载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-lazy-import.md) - -### 效果预览 - -| 首页 | 依次点击按钮后结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面中Text组件呈现LazyImport效果,依次点击五个button,Text依次现实显示‘Call a success result: a = mod1 a executed’,‘‘Call b success result: b = mod1 b executed’, ‘‘Call c success result: c = mod2 c executed’, ‘Not advisable to use one error: ReferenceError: c is not initialized’, ‘Not advisable to use two error: ReferenceError: module environment is undefined’。 -3. 运行测试用例LazyImport.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── A.ets - │ │ ├── A_ns.ets - │ │ ├── B.ets - │ │ ├── C.ets - │ │ ├── fail_example.ets - │ │ ├── Index.ets // 延迟加载 - │ │ ├── middle.ets - │ │ ├── mod1.ets - │ │ ├── mod2.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── LazyImport.test.ets // 自动化测试代码 - │ │ └── List.test -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport > .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/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/build-profile.json5 deleted file mode 100755 index f618d79883..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/oh-package.json5 deleted file mode 100755 index d6e4d8eaef..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index 16a6312a0f..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/main', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/module.json5 deleted file mode 100755 index d777a889f6..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/module.json5 deleted file mode 100755 index cb58bf6e31..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/hvigor/hvigor-config.json5 deleted file mode 100755 index f8c80644ca..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/oh-package.json5 deleted file mode 100755 index 7b54e25c41..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/ohosTest.md b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/ohosTest.md deleted file mode 100755 index 8cd3385f9d..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/LazyImport/ohosTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# 延迟加载测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------ | ------------ | ------------------- | ------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| 主页按钮点击 | 位于主页 | 点击触发a按钮 | 页面文本变化 | Pass | -| 主页按钮点击 | 位于主页 | 点击触发b按钮 | 页面文本变化 | Pass | -| 主页按钮点击 | 位于主页 | 点击触发c按钮 | 页面文本变化 | Pass | -| 主页按钮点击 | 位于主页 | 点击不推荐用法1按钮 | 页面文本变化 | Pass | -| 主页按钮点击 | 位于主页 | 点击不推荐用法2按钮 | 页面文本变化 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/app.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/app.json5 deleted file mode 100755 index 8337e040e4..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.moduleloadingsideeffects", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/element/string.json deleted file mode 100755 index c453d4b6b7..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ModuleLoadingSideEffects" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/README.md b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/README.md deleted file mode 100755 index a62807bdc7..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/README.md +++ /dev/null @@ -1,74 +0,0 @@ -# ArkTS模块加载副作用及优化 - -### 介绍 - -当使用ArkTS模块化时,模块的加载和执行可能会引发副作用。副作用是指在模块导入过程中,除了导出功能或对象之外,还产生了额外的行为或状态变化。这些行为可能影响程序别的部分,并导致非预期的顶层代码执行、全局状态变化、原型链修改、导入内容未定义等问题。 - -本项目展现了模块加载副作用及优化,包括模块执行顶层代码、修改全局对象、修改应用级ArkUI组件的状态变量信息、修改内置全局变量或原型链、循环依赖和延迟加载改变模块执行顺序等场景,对比产生副作用的场景和优化后场景。代码详细描述可查如下链接。 - -- [模块加载副作用及优化](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arkts-module-side-effects.md) - -### 效果预览 - -| 首页 | -| ------------------------------------------------------------ | -| | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面中呈现五个按钮分别对应介绍中五个场景,分别点击按钮可以跳转到各个场景的页面,页面中有副作用以及优化后结果进行对比,并在工作台打印日志。 -3. 运行测试用例ModuleLoadingSideEffects.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── LazyImportChangeExecutionOrder // 延迟加载改变模块执行顺序 - │ │ ├── ModifyGlobalObject // 修改全局对象 - │ │ ├── ModifyingGlobalVariables // 修改内置全局变量或原型链 - │ │ ├── ModifyTheApplicationLevelArkUI // 修改应用级ArkUI组件的状态变量信息 - │ │ ├── TopCodeModification // 模块执行顶层代码 - │ │ └── Index.ets // 首页 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── ModuleLoadingSideEffects.test.ets // 自动化测试代码 - │ │ └── List.test -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects > .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/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/build-profile.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/build-profile.json5 deleted file mode 100755 index b4d65d490e..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/oh-package.json5 deleted file mode 100755 index 4bf3e2a9b1..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index 3e77e4b9f7..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/module.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/module.ets deleted file mode 100755 index 77afe81b29..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/module.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start import_global_module_data] -export let data = 'data from module'; - -globalThis.someGlobalVar = 100; -// [End import_global_module_data] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleOptimize.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleOptimize.ets deleted file mode 100755 index 1a5e5366d9..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/LazyImportChangeExecutionOrder/moduleOptimize.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 let dataOptimize = 'data from module'; - -export function initialize() { - globalThis.someGlobalVar = 100; // 延迟到函数调用时执行 -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/module.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/module.ets deleted file mode 100755 index 78c9caab64..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/module.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start export_change_global_data_100] -export let data1 = 'data from module'; - -globalThis.someGlobalVar = 100; // 改变了全局状态 -// [End export_change_global_data_100] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleOptimize.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleOptimize.ets deleted file mode 100755 index 72ac72eafc..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/moduleOptimize.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 let dataOptimize1 = 'data from module'; - -export function changeGlobalVar() { - globalThis.someGlobalVar = 100; -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/module.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/module.ets deleted file mode 100755 index 8d84ffea49..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/module.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start set_app_storage_var] -export let data = 'data from module'; - -AppStorage.setOrCreate('SomeAppStorageVar1', 200); // 修改应用全局的UI状态 -// [End set_app_storage_var] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/moduleOptimize.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/moduleOptimize.ets deleted file mode 100755 index eb397654b2..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyTheApplicationLevelArkUI/moduleOptimize.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 let dataOptimize = 'data from module'; - -export function initialize() { - AppStorage.setOrCreate('SomeAppStorageVar2', 200); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/module.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/module.ets deleted file mode 100755 index d83291a974..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/module.ets +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start module_load_directly] -export function initialize() { - console.log('Module loaded!'); -} -// [End module_load_directly] - -// [Start module_load_optimize] -export const dataOptimizeTwo = 1; -// [End module_load_optimize] diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/resource.ets deleted file mode 100755 index 79a04af93b..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/util/resource.ets +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 class P2PManager { - public resourceToString(resource: Resource):string { - return getContext(this).resourceManager.getStringSync(resource); - } -} - -// 默认导出let -let p2pManager = new P2PManager(); - -export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/oh-package.json5 b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/ohosTest.md b/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/ohosTest.md deleted file mode 100755 index 35810afe64..0000000000 --- a/code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/ohosTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# 模块加载副作用及优化测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动化 | 测试结果 | -| ------------------------------ | ---------------- | -------------------------------------- | ------------ | ---------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 主页按钮点击跳转按钮后按钮点击 | 跳转按钮位于主页 | 点击LazyImport按钮 | 页面文本变化 | 是 | Pass | -| 主页按钮点击跳转按钮后按钮点击 | 跳转按钮位于主页 | 点击ModifyGlobalObject按钮 | 页面文本变化 | 是 | Pass | -| 主页按钮点击跳转按钮后按钮点击 | 跳转按钮位于主页 | 点击ModifyingGlobalVariables按钮 | 页面文本变化 | 是 | Pass | -| 主页按钮点击跳转按钮后文本显示 | 跳转按钮位于主页 | 点击ModifyTheApplicationLevelArkUI按钮 | 页面文本变化 | 是 | Pass | -| 主页按钮点击跳转按钮后按钮点击 | 跳转按钮位于主页 | 点击TopCodeModification按钮 | 页面文本变化 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/app.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/app.json5 deleted file mode 100755 index f316134900..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nativeinterthreadshared", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/element/string.json deleted file mode 100755 index f600c1a224..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NativeInterthreadShared" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/README.md b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/README.md deleted file mode 100755 index 67f2e86e27..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# ArkTS C++线程间数据共享场景 - -### 介绍 - -当应用在C++层进行多线程的并发计算时,因为ArkTS的API需要在ArkTS的环境执行,为了避免在非UI主线程每次回调等待UI主线程ArkTS环境中执行的API调用结果,需要在这些C++线程上创建ArkTS执行环境和直接调用API,并且可能需要在C++线程之间对Sendable对象进行共享和操作。 - -为了支持此类场景,需要实现在C++线程上创建调用ArkTS的能力,其次还需要对Sendable对象进行多线程共享和操作。 - -该工程中展示的代码详细描述可查如下链接: - -- [C++线程间数据共享场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/native-interthread-shared.md) - -### 效果预览 - -| 首页 | 执行结果 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击hello world,开始执行。 -2. 执行结果会即时反馈在屏幕中央。 - -### 工程目录 - -``` -entry/src - ├──main - │ ├── cpp - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp // Naitve实现加载ArkTS模块的能力示例代码 - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 暴露接口 - │ │ │ │ ├── oh-package.json5 - │ ├── ets - │ │ ├── entryability - │ │ │ ├── EntryAbility.ets - │ │ ├── entrybackupability - │ │ │ ├── EntryBackupAbility.ets - │ │ ├── pages - │ │ ├── Index.ets // UI主线程发起调用示例代码 - │ │ ├── SendableObjTest.ets // ArkTS文件定义示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖s - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared > .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/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/build-profile.json5 deleted file mode 100755 index 21cff55421..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/build-profile.json5 +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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": false, - "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/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index cf003100b1..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(MyApplication) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 6c257d1c7f..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start native_deserialize_sendable] -// [Start native_load_arkts_module] -#include - -#include "napi/native_api.h" - -static void* g_serializationData = nullptr; -static void* CreateEnvAndSendSendable(void*) -{ - // 1. 创建基础运行环境 - napi_env env = nullptr; - napi_status ret = napi_create_ark_runtime(&env); - if (ret != napi_ok) { - std::abort(); - } - // 2. 加载自定义模块,假定SendableObjTest中提供创建sendable对象的方法newSendable - napi_value test = nullptr; - ret = napi_load_module_with_info( - env, "entry/src/main/ets/pages/SendableObjTest", "com.example.myapplication/entry", &test); - if (ret != napi_ok) { - std::abort(); - } - napi_value sendableObjTest = nullptr; - ret = napi_get_named_property(env, test, "SendableObjTest", &sendableObjTest); - if (ret != napi_ok) { - std::abort(); - } - // 3. 使用ArkTS中的newSendable,假设sendableObjTest中有一个函数newSendable能返回sendable对象 - napi_value newSendable = nullptr; - ret = napi_get_named_property(env, sendableObjTest, "newSendable", &newSendable); - if (ret != napi_ok) { - std::abort(); - } - // 4. 调用newSendable函数返回新创建的sendable对象,并保存在result中 - napi_value result = nullptr; - ret = napi_call_function(env, sendableObjTest, newSendable, 0, nullptr, &result); - if (ret != napi_ok) { - std::abort(); - } - // 5. 序列化sendable对象 - napi_value undefined; - napi_get_undefined(env, &undefined); - ret = napi_serialize(env, result, undefined, undefined, &g_serializationData); - if (ret != napi_ok) { - std::abort(); - } - return nullptr; -} -// [End native_load_arkts_module] - -static void* CreateEnvAndReceiveSendable(void*) -{ - // 1. 创建基础运行环境 - napi_env env = nullptr; - napi_status ret = napi_create_ark_runtime(&env); - if (ret != napi_ok) { - std::abort(); - } - // 2. 反序列化获取sendable共享对象,结果保存在result中,这个result就可以通过napi接口进行各种操作了 - napi_value result = nullptr; - ret = napi_deserialize(env, g_serializationData, &result); - if (ret != napi_ok) { - std::abort(); - } - // 3. 删除序列化数据 - ret = napi_delete_serialization_data(env, g_serializationData); - if (ret != napi_ok) { - std::abort(); - } - napi_valuetype valuetype0; - napi_typeof(env, result, &valuetype0); - if (valuetype0 != napi_number) { - std::abort(); - } - int value0; - napi_get_value_int32(env, result, &value0); - // 1024是判断ArkTS返回的结果是否正确 - if (value0 != 1024) { - std::abort(); - } - return nullptr; -} - -static napi_value TestSendSendable([[maybe_unused]] napi_env env, [[maybe_unused]] napi_callback_info info) -{ - std::thread t1(CreateEnvAndSendSendable, nullptr); - t1.join(); - std::thread t2(CreateEnvAndReceiveSendable, nullptr); - t2.join(); - return nullptr; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { { "testSendSendable", nullptr, TestSendSendable, nullptr, nullptr, nullptr, - napi_default, nullptr } }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} -// [End native_deserialize_sendable] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index d0d1a44b65..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start native_deserialize_sendable] -export const testSendSendable: () => void; -// [End native_deserialize_sendable] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index cc485abc9a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start main_thread_init_call] -import { hilog } from '@kit.PerformanceAnalysisKit'; -import testNapi from 'libentry.so'; -import { SendableObjTest } from './SendableObjTest' - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - SendableObjTest.newSendable() - hilog.info(0x0000, 'testTag', 'Test send Sendable begin'); - testNapi.testSendSendable(); - hilog.info(0x0000, 'testTag', 'Test send Sendable end'); - this.message = 'success'; - }) - } - .width('100%') - } - .height('100%') - } -} -// [End main_thread_init_call] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/ohosTest.md b/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/ohosTest.md deleted file mode 100755 index cf0c529a0f..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared/ohosTest.md +++ /dev/null @@ -1,8 +0,0 @@ -# NativeInterthreadShared 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| C++线程间数据共享场景 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/app.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/app.json5 deleted file mode 100755 index eb5e9df120..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 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.asyncconcurrencyoverview", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/element/string.json deleted file mode 100755 index efeed98b51..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AsyncConcurrencyOverview" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/README.md b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/README.md deleted file mode 100755 index 8e17cab11e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# ArkTS 异步并发 (Promise和async/await) - -### 介绍 - -Promise和async/await提供异步并发能力,是标准的JS异步语法。异步代码会被挂起并在之后继续执行,同一时间只有一段代码执行,适用于单次I/O任务的场景开发,例如一次网络请求、一次文件读写等操作。无需另外启动线程执行。 - -异步语法是一种编程语言的特性,允许程序在执行某些操作时不必等待其完成,而是可以继续执行其他操作。该工程中展示的代码详细描述可查如下链接: - -- [异步并发 (Promise和async/await)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/async-concurrency-overview.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击hello world,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 异步并发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview > .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/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/build-profile.json5 deleted file mode 100755 index 66e9c20152..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2024 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", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/build-profile.json5 deleted file mode 100755 index 90b14923bf..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2024 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/oh-package.json5 deleted file mode 100755 index 41a4755f66..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 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/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index 0cccf06465..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1755a4686c..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 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/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/module.json5 deleted file mode 100755 index b541792385..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2024 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/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/module.json5 deleted file mode 100755 index 1f646ea03f..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/hvigor/hvigor-config.json5 deleted file mode 100755 index 794f9e19ba..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2024 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.1", - "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/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/oh-package.json5 deleted file mode 100755 index c60577dcc2..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/ohosTest.md b/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/ohosTest.md deleted file mode 100755 index e8643e78fe..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/AsyncConcurrencyOverview/ohosTest.md +++ /dev/null @@ -1,8 +0,0 @@ -# AsyncConcurrencyOverview 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------- | ------------ | --------------- |------------------| -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 异步并发 | 位于首页 | 点击Hello World | 3秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/app.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/app.json5 deleted file mode 100755 index acc133aae3..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.communicationobjects", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/element/string.json deleted file mode 100755 index 8b6ecf1b41..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "CommunicationObjects" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/README.md b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/README.md deleted file mode 100755 index d01e95dbbe..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/README.md +++ /dev/null @@ -1,93 +0,0 @@ -# ArkTS 线程间通信对象 - -### 介绍 - -#### 普通对象 - -普通对象跨线程时通过拷贝形式传递,两个线程的对象内容一致,但是指向各自线程的隔离内存区间,被分配在各自线程的虚拟机本地堆(LocalHeap)。例如Ecmascript262规范定义的Object、Array、Map等对象是通过这种方式实现跨并发实例通信的。 - -#### ArrayBuffer对象 - -ArrayBuffer内部包含一块Native内存,该ArrayBuffer的JS对象壳被分配在虚拟机本地堆(LocalHeap)。与普通对象一样,需要经过序列化与反序列化拷贝传递,但是Native内存有两种传输方式:拷贝和转移。 - -#### SharedArrayBuffer对象 - -SharedArrayBuffer内部包含一块Native内存,其JS对象壳被分配在虚拟机本地堆(LocalHeap)。支持跨并发实例间共享,但是访问及修改需要采用Atomics类,防止数据竞争。SharedArrayBuffer可以用于多个并发实例间的状态共享或者数据共享。 - -#### Transferable对象(NativeBinding对象) - -Transferable对象(也称为NativeBinding对象)指的是一个JS对象,绑定了一个C++对象,且主体功能由C++提供,其JS对象壳被分配在虚拟机本地堆(LocalHeap)。跨线程传输时可以直接复用同一个C++对象,相比于JS对象的拷贝模式,传输效率较高。因此,可共享或转移的NativeBinding对象也被称为Transferable对象。 - -该工程中展示的代码详细描述可查如下链接: - -- [普通对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/normal-object.md) -- [ArrayBuffer对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/arraybuffer-object.md) -- [SharedArrayBuffer对象](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/shared-arraybuffer-object.md) -- [Transferable对象(NativeBinding对象)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/transferabled-object.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,点击任意按钮进行跳转,点击Hello World执行程序 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── managers - │ │ ├── ArrayBufferObject.ets // ArrayBuffer对象示例代码 - │ │ ├── NormalObject.ets // 普通对象示例代码 - │ │ ├── pixelMapTest.ets // Transferable对象示例代码 - │ │ ├── SharedArrayBufferObject.ets // SharedArrayBuffer对象示例代码 - │ │ ├── Test.ets // 普通对象示例代码 - │ │ ├── TransferabledObject.ets // Transferable对象示例代码 - │ │ ├── pages - │ │ ├── Index.ets // 首页 - │ │ ├── util - │ │ ├── CommonButton.ets // 首页跳转UI - │ │ ├── resource.ets // 资源引用转换 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects > .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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/build-profile.json5 deleted file mode 100755 index b4d65d490e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/oh-package.json5 deleted file mode 100755 index 4bf3e2a9b1..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index 3e77e4b9f7..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/Test.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/Test.ets deleted file mode 100755 index 2e652f5499..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/Test.ets +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start define_test_class] -// 自定义class TestA -export class TestA { - constructor(name: string) { - this.name = name; - } - name: string = 'ClassA'; -} -// [End define_test_class] diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/resource.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/resource.ets deleted file mode 100755 index 79a04af93b..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/util/resource.ets +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 class P2PManager { - public resourceToString(resource: Resource):string { - return getContext(this).resourceManager.getStringSync(resource); - } -} - -// 默认导出let -let p2pManager = new P2PManager(); - -export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/ohosTest.md b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/ohosTest.md deleted file mode 100755 index e914f669f2..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/ohosTest.md +++ /dev/null @@ -1,11 +0,0 @@ -# CommunicationObjects 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------- | ------------------------------- | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 普通对象 | 位于NormalObject.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| ArrayBuffer对象 | 位于ArrayBufferObject.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| SharedArrayBuffer对象 | 位于SharedArrayBufferObject.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| Transferable对象 | 位于TransferabledObject.ets | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/build-profile.json5 deleted file mode 100755 index b4d65d490e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/oh-package.json5 deleted file mode 100755 index 0f6e4f8db5..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "notallowedinside", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/module.json5 deleted file mode 100755 index a27e9f18c9..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "notallowedInside", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "NotallowedInsideAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "NotallowedInsideAbility", - "srcEntry": "./ets/notallowedinsideability/NotallowedInsideAbility.ets", - "description": "$string:NotallowedInsideAbility_desc", - "icon": "$media:layered_image", - "label": "$string:NotallowedInsideAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/module.json5 deleted file mode 100755 index 98cf2c71b0..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/notallowedInside/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "notallowedInside_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/build-profile.json5 deleted file mode 100755 index b4d65d490e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/oh-package.json5 deleted file mode 100755 index c04ca7fbd7..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "objectliterals", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/ets/objectliteralsability/ObjectliteralsAbility.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/ets/objectliteralsability/ObjectliteralsAbility.ets deleted file mode 100755 index a047bbfadf..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/ets/objectliteralsability/ObjectliteralsAbility.ets +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class ObjectliteralsAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/module.json5 deleted file mode 100755 index 9461e70f73..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "objectliterals", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "ObjectliteralsAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ObjectliteralsAbility", - "srcEntry": "./ets/objectliteralsability/ObjectliteralsAbility.ets", - "description": "$string:ObjectliteralsAbility_desc", - "icon": "$media:layered_image", - "label": "$string:ObjectliteralsAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/module.json5 deleted file mode 100755 index 400184ab71..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/objectliterals/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "objectliterals_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/build-profile.json5 deleted file mode 100755 index b4d65d490e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/oh-package.json5 deleted file mode 100755 index dbb5d03319..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "templatetype", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/module.json5 deleted file mode 100755 index f8d35fed0b..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "templatetype", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "TemplatetypeAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "TemplatetypeAbility", - "srcEntry": "./ets/templatetypeability/TemplatetypeAbility.ets", - "description": "$string:TemplatetypeAbility_desc", - "icon": "$media:layered_image", - "label": "$string:TemplatetypeAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/module.json5 deleted file mode 100755 index 7ead18e3f6..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/templatetype/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "templatetype_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/build-profile.json5 deleted file mode 100755 index b4d65d490e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/oh-package.json5 deleted file mode 100755 index c40faf81af..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "typecannot", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/module.json5 deleted file mode 100755 index 31ad2bd9ab..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "typecannot", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "TypecannotAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "TypecannotAbility", - "srcEntry": "./ets/typecannotability/TypecannotAbility.ets", - "description": "$string:TypecannotAbility_desc", - "icon": "$media:layered_image", - "label": "$string:TypecannotAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/module.json5 deleted file mode 100755 index d1c5eb7265..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/typecannot/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "typecannot_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/build-profile.json5 deleted file mode 100755 index b4d65d490e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/oh-package.json5 deleted file mode 100755 index c5eb5718c9..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "variablenotsupported", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/module.json5 deleted file mode 100755 index ad5c0a436a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "variablenotsupported", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "VariablenotsupportedAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "VariablenotsupportedAbility", - "srcEntry": "./ets/variablenotsupportedability/VariablenotsupportedAbility.ets", - "description": "$string:VariablenotsupportedAbility_desc", - "icon": "$media:layered_image", - "label": "$string:VariablenotsupportedAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/module.json5 deleted file mode 100755 index ceaac6ea8f..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablenotsupported/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "variablenotsupported_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/build-profile.json5 deleted file mode 100755 index b4d65d490e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/oh-package.json5 deleted file mode 100755 index f44dd71404..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "variablesupport", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/module.json5 deleted file mode 100755 index ba603c0fa7..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "variablesupport", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "VariablesupportAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "VariablesupportAbility", - "srcEntry": "./ets/variablesupportability/VariablesupportAbility.ets", - "description": "$string:VariablesupportAbility_desc", - "icon": "$media:layered_image", - "label": "$string:VariablesupportAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/module.json5 deleted file mode 100755 index 53359bf4e2..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/RulesAndRestrictions/variablesupport/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "variablesupport_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/app.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/app.json5 deleted file mode 100755 index 57ca40f75f..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 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.multithreadconcurrencyoverview", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/element/string.json deleted file mode 100755 index d867317044..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MultiThreadConcurrencyOverview" - } - ] -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/README.md b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/README.md deleted file mode 100755 index 16920a8501..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# ArkTS 多线程并发概述 - -### 介绍 - -并发模型是用来实现不同应用场景中并发任务的编程模型,常见的并发模型分为基于内存共享的并发模型和基于消息通信的并发模型。 - -Actor并发模型作为基于消息通信并发模型的典型代表,不需要开发者去面对锁带来的一系列复杂偶发的问题,同时并发度也相对较高,因此得到了广泛的支持和使用。 - -当前ArkTS提供了TaskPool和Worker两种并发能力,TaskPool和Worker都基于Actor并发模型实现。 - -Actor并发模型和内存共享并发模型的具体对比请见[多线程并发模型](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/multi-thread-concurrency-overview.md#多线程并发模型)。 - -该工程中展示的代码详细描述可查如下链接: - -- [多线程并发概述](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/multi-thread-concurrency-overview.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------: | :----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击start,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 多线程并发概述示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview > .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/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/build-profile.json5 deleted file mode 100755 index dc186a2884..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2024 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/build-profile.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/build-profile.json5 deleted file mode 100755 index 90b14923bf..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2024 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/oh-package.json5 deleted file mode 100755 index 41a4755f66..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 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/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index 0cccf06465..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1755a4686c..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 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/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/module.json5 deleted file mode 100755 index b541792385..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2024 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/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/module.json5 deleted file mode 100755 index 1f646ea03f..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigor/hvigor-config.json5 deleted file mode 100755 index 794f9e19ba..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2024 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.1", - "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/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/oh-package.json5 b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/oh-package.json5 deleted file mode 100755 index c60577dcc2..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/ohosTest.md b/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/ohosTest.md deleted file mode 100755 index 40ef257503..0000000000 --- a/code/DocsSample/ArkTs/ArkTsConcurrent/MultithreadedConcurrency/MultiThreadConcurrencyOverview/ohosTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# MultiThreadConcurrencyOverview 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------------------------------------------- | ------------ | --------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 使用基于Actor模型的TaskPool并发能力来解决生产者消费者问题 | 位于首页 | 点击start | 1秒后页面显示“success” | 是 | Pass | - diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmDebug/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/AppScope/app.json5 deleted file mode 100755 index 66e2875f1a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmdebug", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/AppScope/resources/base/element/string.json deleted file mode 100755 index 9f1ea061be..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmDebug" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/README.md deleted file mode 100755 index ed914e07b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/README.md +++ /dev/null @@ -1,138 +0,0 @@ -# ArkTS JSVM-API典型使用场景指导 - -### 介绍 - -使用JSVM-API实现跨语言交互,首先需要按照JSVM-API的机制实现模块的注册和加载等相关动作。 - -- ArkTS/JS侧:实现C++方法的调用。代码比较简单,import一个对应的so库后,即可调用C++方法。 -- Native侧:.cpp文件,实现模块的注册。需要提供注册lib库的名称,并在注册回调方法中定义接口的映射关系,即Native方法及对应的JS/ArkTS接口名称等。 - -该工程中展示的代码详细描述可查如下链接: - -- [JSVM-API调试&定位](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/jsvm-debugger-cpuprofiler-heapsnapshot.md) -- [使用 code cache 加速编译](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-code-cache.md) -- [使用JSVM-API接口创建多个引擎执行JS代码并销毁](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-runtime-task.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :-----------------------------------------------------------: | :-----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -aboutcodecache/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -openinspector/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -snapshot/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -runtimetask/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmDebug > .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/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/oh-package.json5 deleted file mode 100755 index 5e36a9bb95..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "aboutcodecache", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libaboutcodecache.so": "file:./src/main/cpp/types/libaboutcodecache" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/CMakeLists.txt deleted file mode 100755 index cf0fc258d8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmDebug) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(aboutcodecache SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(aboutcodecache PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/hello.cpp deleted file mode 100755 index 3ebce1b1a9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/hello.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start jsvm_code_cache] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -#include -// [StartExclude jsvm_code_cache] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude jsvm_code_cache] - -JSVM_Value UseCodeCache(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 编译参数准备 - JSVM_Value jsSrc; - JSVM_Script script; - JSVM_Value result; - size_t length = 0; - const uint8_t* dataPtr = nullptr; - bool cacheRejected = true; - static std::string src = R"JS( - a = 65536; - b = 32768; - c = a + b; - )JS"; - - // 生成 code cache - { - JSVM_HandleScope handleScope; - OH_JSVM_OpenHandleScope(env, &handleScope); - - // 源码字符串转换为 js 字符串 - OH_JSVM_CreateStringUtf8(env, src.c_str(), src.size(), &jsSrc); - - // 编译js代码 - OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script); - - // 执行js代码 - OH_JSVM_RunScript(env, script, &result); - int value = 0; - OH_JSVM_GetValueInt32(env, result, &value); - OH_LOG_INFO(LOG_APP, "first run result: %{public}d\n", value); - - if (dataPtr == nullptr) { - // 将js源码编译出的脚本保存到 cache, 可以避免重复编译, 带来性能提升 - OH_JSVM_CreateCodeCache(env, script, &dataPtr, &length); - } - - OH_JSVM_CloseHandleScope(env, handleScope); - } - - // 使用 code cache - { - JSVM_HandleScope handleScope; - OH_JSVM_OpenHandleScope(env, &handleScope); - - // 源码字符串转换为 js 字符串 - OH_JSVM_CreateStringUtf8(env, src.c_str(), src.size(), &jsSrc); - - // 使用 code cache 编译js代码 - OH_JSVM_CompileScript(env, jsSrc, dataPtr, length, true, &cacheRejected, &script); - - // 执行js代码 - OH_JSVM_RunScript(env, script, &result); - int value = 0; - OH_JSVM_GetValueInt32(env, result, &value); - OH_LOG_INFO(LOG_APP, "second run result: %{public}d\n", value); - - OH_JSVM_CloseHandleScope(env, handleScope); - } - OH_LOG_INFO(LOG_APP, "cache rejected: %{public}d\n", cacheRejected); - return result; -} - -// Register a callback. -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = UseCodeCache} -}; -static JSVM_CallbackStruct *method = param; -// Register the C++ callback as a JSVM globalThis.UseCodeCache property for the JS to call. -static JSVM_PropertyDescriptor descriptor[] = { - {"UseCodeCache", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// [End jsvm_code_cache] - -// 样例测试JS -const char *SRC_CALL_NATIVE = R"JS(UseCodeCache();)JS"; - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "aboutcodecache", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/oh-package.json5 deleted file mode 100755 index 066c7380fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/cpp/types/libaboutcodecache/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libaboutcodecache.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/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/pages/Index.ets deleted file mode 100755 index c28a78dc14..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libaboutcodecache.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/module.json5 deleted file mode 100755 index 3025d78a54..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "aboutcodecache", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "AboutcodecacheAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "AboutcodecacheAbility", - "srcEntry": "./ets/aboutcodecacheability/AboutcodecacheAbility.ets", - "description": "$string:AboutcodecacheAbility_desc", - "icon": "$media:layered_image", - "label": "$string:AboutcodecacheAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/string.json deleted file mode 100755 index d473a265a9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "AboutcodecacheAbility_desc", - "value": "description" - }, - { - "name": "AboutcodecacheAbility_label", - "value": "JsvmDebug" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 184840bf0c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testcodecache', 0, async (done: Function) => { - console.log('uitest: Testcodecache begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'AboutcodecacheAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('AboutcodecacheAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: Testcodecache end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/module.json5 deleted file mode 100755 index a6f6070ce4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/aboutcodecache/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "aboutcodecache_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/build-profile.json5 deleted file mode 100755 index 92fc4e620d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/build-profile.json5 +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "openinspector", - "srcPath": "./openinspector", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "snapshot", - "srcPath": "./snapshot", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "aboutcodecache", - "srcPath": "./aboutcodecache", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "runtimetask", - "srcPath": "./runtimetask", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/hvigor/hvigor-config.json5 deleted file mode 100755 index 9507fa00ff..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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*/ - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/hvigorfile.ts deleted file mode 100755 index e8e1ecbc43..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/hvigorfile.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmDebug/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/ohosTest.md deleted file mode 100755 index 352aa27ee1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/ohosTest.md +++ /dev/null @@ -1,11 +0,0 @@ -# JsvmDebug 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 在指定的主机和端口上激活inspector,将用来调试JS代码 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取当前堆快照并将其输出到流 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 使用 code cache 加速编译 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| JSVM-API接口创建多个引擎执行JS代码并销毁 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmDebug/openinspector/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmDebug/openinspector/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/oh-package.json5 deleted file mode 100755 index fa4a03ee86..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "openinspector", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libopeninspector.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 4777357731..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmDebug) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(openinspector SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(openinspector PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/hello.cpp deleted file mode 100755 index 2d39c18999..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_open_inspector] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" -#include -// [StartExclude oh_jsvm_open_inspector] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_open_inspector] - -// 待调试的JS源码 -static std::string g_srcDebugger = R"JS( -const concat = (...args) => args.reduce((a, b) => a + b); -var dialogue = concat('"What ', 'is ', 'your ', 'name ', '?"'); -dialogue = concat(dialogue, ' --', '"My ', 'name ', 'is ', 'Bob ', '."'); -)JS"; - -// 开启debugger -static const int INSPECTOR_PORT = 9225; -static void EnableInspector(JSVM_Env env) -{ - // 在指定的主机和端口上激活inspector,创建socket。 - OH_JSVM_OpenInspector(env, "localhost", INSPECTOR_PORT); - // 等待建立socket连接。 - OH_JSVM_WaitForDebugger(env, true); -} - -// 关闭debugger -static void CloseInspector(JSVM_Env env) -{ - // 关闭inspector,结束socket连接。 - OH_JSVM_CloseInspector(env); -} - -static void RunScript(JSVM_Env env) -{ - JSVM_HandleScope handleScope; - OH_JSVM_OpenHandleScope(env, &handleScope); - - JSVM_Value jsSrc; - OH_JSVM_CreateStringUtf8(env, g_srcDebugger.c_str(), g_srcDebugger.size(), &jsSrc); - - JSVM_Script script; - OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script); - - JSVM_Value result; - OH_JSVM_RunScript(env, script, &result); - - OH_JSVM_CloseHandleScope(env, handleScope); -} - -void TestJSVM() -{ - JSVM_InitOptions initOptions{}; - OH_JSVM_Init(&initOptions); - - JSVM_VM vm; - OH_JSVM_CreateVM(nullptr, &vm); - JSVM_VMScope vmScope; - OH_JSVM_OpenVMScope(vm, &vmScope); - - JSVM_Env env; - OH_JSVM_CreateEnv(vm, 0, nullptr, &env); - // 执行JS代码之前打开debugger。 - EnableInspector(env); - JSVM_EnvScope envScope; - OH_JSVM_OpenEnvScope(env, &envScope); - - // 执行JS代码。 - RunScript(env); - - OH_JSVM_CloseEnvScope(env, envScope); - // 执行JS代码之后关闭debugger。 - CloseInspector(env); - OH_JSVM_DestroyEnv(env); - OH_JSVM_CloseVMScope(vm, vmScope); - OH_JSVM_DestroyVM(vm); -} -// [End jsvm_open_inspector] - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "openinspector", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index b9c45d876c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libopeninspector.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/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/pages/Index.ets deleted file mode 100755 index 32fadce71f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libopeninspector.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/module.json5 deleted file mode 100755 index a6b879bea1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/module.json5 +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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": "openinspector", - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET", - "reason": "$string:app_name", - "usedScene": { - "abilities": [ - "FromAbility" - ], - "when": "inuse" - } - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/string.json deleted file mode 100755 index 6382470c42..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmDebug" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 4b4a8880b4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testOpenInspector', 0, async (done: Function) => { - console.log('uitest: TestOpenInspector begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestOpenInspector end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/module.json5 deleted file mode 100755 index 61bb03e80e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/openinspector/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "openinspector_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmDebug/runtimetask/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/oh-package.json5 deleted file mode 100755 index 2b6a6afd09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "runtimetask", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libruntimetask.so": "file:./src/main/cpp/types/libruntimetask" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/CMakeLists.txt deleted file mode 100755 index fb9c66c70b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmDebug) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(runtimetask SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(runtimetask PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/hello.cpp deleted file mode 100755 index 94174827aa..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/cpp/hello.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -// [Start runtime_task] -#include -#include -#include -using namespace std; -// 定义map管理每个独立vm环境 -static map g_vmMap; -static map g_envMap; -static map g_callBackStructMap; -static uint32_t g_envtagNumber = 0; -static std::mutex g_envMapLock; -// [StartExclude runtime_task] - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude runtime_task] - -#define CHECK_COND(cond) \ - do { \ - if (!(cond)) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = false", __FILE__, __LINE__); \ - return -1; \ - } \ - } while (0) - -class Task { -public: - virtual ~Task() = default; - virtual void Run() = 0; -}; -static map> g_taskQueueMap; - -// 自定义Consoleinfo方法 -static JSVM_Value Consoleinfo(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1]; - #define MAX_LOG_LENGTH 255 - char log[MAX_LOG_LENGTH + 1] = ""; - size_t logLength; - JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, NULL, NULL)); - - JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, args[0], log, MAX_LOG_LENGTH, &logLength)); - log[MAX_LOG_LENGTH] = 0; - OH_LOG_INFO(LOG_APP, "JSVM API TEST: %{public}s", log); - return nullptr; -} - -// 自定义创建Promise方法用以在JS代码中创建Promise -static JSVM_Value CreatePromise(JSVM_Env env, JSVM_CallbackInfo info) -{ - OH_LOG_INFO(LOG_APP, "JSVM API TEST: CreatePromise start"); - int envID = -1; - // 通过当前env获取envID - for (auto it = g_envMap.begin(); it != g_envMap.end(); ++it) { - if (*it->second == env) { - envID = it->first; - break; - } - } - if (envID == -1) { - OH_LOG_ERROR(LOG_APP, "JSVM API TEST: CreatePromise envID failed"); - return nullptr; - } - JSVM_Value promise; - JSVM_Deferred deferred; - JSVM_CALL(OH_JSVM_CreatePromise(env, &deferred, &promise)); - // 设计ReadTask类用以将promise对象的deferred加入执行队列 - class ReadTask : public Task { - public: - ReadTask(JSVM_Env env, JSVM_Deferred deferred, int envNum) : env_(env), envID_(envNum), deferred_(deferred) {} - void Run() override - { - // string str = "TEST RUN OH_JSVM_ResolveDeferred"; - int envID = 0; - for (auto it = g_envMap.begin(); it != g_envMap.end(); ++it) { - if (*it->second == env_) { - envID = it->first; - break; - } - } - OH_LOG_INFO(LOG_APP, "JSVM API TEST: CreatePromise %{public}d", envID); - JSVM_Value result; - if (OH_JSVM_CreateInt32(env_, envID, &result) != JSVM_OK) { - return; - } - if (OH_JSVM_ResolveDeferred(env_, deferred_, result) != JSVM_OK) { - return; - } - } - - private: - JSVM_Env env_; - int envID_; - JSVM_Deferred deferred_; - }; - g_taskQueueMap[envID].push_back(new ReadTask(env, deferred, envID)); - OH_LOG_INFO(LOG_APP, "JSVM API TEST: CreatePromise end"); - return promise; -} - -// 自定义Add方法 -static JSVM_Value Add(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 2; - JSVM_Value args[2]; - JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, NULL, NULL)); - double num1; - double num2; - JSVM_CALL(OH_JSVM_GetValueDouble(env, args[0], &num1)); - JSVM_CALL(OH_JSVM_GetValueDouble(env, args[1], &num2)); - JSVM_Value sum = nullptr; - JSVM_CALL(OH_JSVM_CreateDouble(env, num1 + num2, &sum)); - return sum; -} - -// 自定义AssertEqual方法 -static JSVM_Value AssertEqual(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 2; - JSVM_Value args[2]; - JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, NULL, NULL)); - - bool isStrictEquals = false; - JSVM_CALL(OH_JSVM_StrictEquals(env, args[0], args[1], &isStrictEquals)); - - if (isStrictEquals) { - OH_LOG_INFO(LOG_APP, "JSVM API TEST RESULT: PASS"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM API TEST RESULT: FAILED"); - } - return nullptr; -} - -static int fromOHStringValue(JSVM_Env &env, JSVM_Value &value, std::string &result) -{ - size_t size; - CHECK_RET(OH_JSVM_GetValueStringUtf8(env, value, nullptr, 0, &size)); - char resultStr[size + 1]; - CHECK_RET(OH_JSVM_GetValueStringUtf8(env, value, resultStr, size + 1, &size)); - result = resultStr; - return 0; -} - -// 提供创建JSVM运行环境的对外接口并返回对应唯一ID -static int CreateJsCore(uint32_t *result) -{ - OH_LOG_INFO(LOG_APP, "JSVM CreateJsCore START"); - g_taskQueueMap[g_envtagNumber] = deque {}; - - if (g_aa == 0) { - JSVM_InitOptions init_options; - memset(&init_options, 0, sizeof(init_options)); - CHECK(OH_JSVM_Init(&init_options)); - g_aa++; - } - std::lock_guard lock_guard(g_envMapLock); - - // 虚拟机实例 - g_vmMap[g_envtagNumber] = new JSVM_VM; - JSVM_CreateVMOptions options; - JSVM_VMScope vmScope; - memset(&options, 0, sizeof(options)); - CHECK(OH_JSVM_CreateVM(&options, g_vmMap[g_envtagNumber])); - CHECK(OH_JSVM_OpenVMScope(*g_vmMap[g_envtagNumber], &vmScope)); - - // 新环境 - g_envMap[g_envtagNumber] = new JSVM_Env; - g_callBackStructMap[g_envtagNumber] = new JSVM_CallbackStruct[4]; - - // 注册用户提供的本地函数的回调函数指针和数据,通过JSVM-API暴露给js - constexpr int kLoopCount = 4; - for (int i = 0; i < kLoopCount; i++) { - g_callBackStructMap[g_envtagNumber][i].data = nullptr; - } - g_callBackStructMap[g_envtagNumber][0].callback = Consoleinfo; - g_callBackStructMap[g_envtagNumber][1].callback = Add; - g_callBackStructMap[g_envtagNumber][2].callback = AssertEqual; - g_callBackStructMap[g_envtagNumber][3].callback = CreatePromise; - JSVM_PropertyDescriptor descriptors[] = { - { "consoleinfo", NULL, &g_callBackStructMap[g_envtagNumber][0], NULL, NULL, NULL, JSVM_DEFAULT }, - { "add", NULL, &g_callBackStructMap[g_envtagNumber][1], NULL, NULL, NULL, JSVM_DEFAULT }, - { "assertEqual", NULL, &g_callBackStructMap[g_envtagNumber][2], NULL, NULL, NULL, JSVM_DEFAULT }, - { "createPromise", NULL, &g_callBackStructMap[g_envtagNumber][3], NULL, NULL, NULL, JSVM_DEFAULT }, - }; - CHECK(OH_JSVM_CreateEnv( - *g_vmMap[g_envtagNumber], sizeof(descriptors) / sizeof(descriptors[0]), descriptors, g_envMap[g_envtagNumber])); - CHECK(OH_JSVM_CloseVMScope(*g_vmMap[g_envtagNumber], vmScope)); - - OH_LOG_INFO(LOG_APP, "JSVM CreateJsCore END"); - *result = g_envtagNumber; - g_envtagNumber++; - return 0; -} - -// 对外提供释放JSVM环境接口,通过envId释放对应环境 -static int ReleaseJsCore(uint32_t coreEnvId) -{ - OH_LOG_INFO(LOG_APP, "JSVM ReleaseJsCore START"); - CHECK_COND(g_envMap.count(coreEnvId) != 0 && g_envMap[coreEnvId] != nullptr); - - std::lock_guard lock_guard(g_envMapLock); - - CHECK(OH_JSVM_DestroyEnv(*g_envMap[coreEnvId])); - g_envMap[coreEnvId] = nullptr; - g_envMap.erase(coreEnvId); - CHECK(OH_JSVM_DestroyVM(*g_vmMap[coreEnvId])); - g_vmMap[coreEnvId] = nullptr; - g_vmMap.erase(coreEnvId); - delete[] g_callBackStructMap[coreEnvId]; - g_callBackStructMap[coreEnvId] = nullptr; - g_callBackStructMap.erase(coreEnvId); - g_taskQueueMap.erase(coreEnvId); - - OH_LOG_INFO(LOG_APP, "JSVM ReleaseJsCore END"); - return 0; -} - -static std::mutex g_mutexLock; -// 对外提供执行JS代码接口,通过coreID在对应的JSVN环境中执行JS代码 -static int EvaluateJS(uint32_t envId, const char *source, std::string &res) -{ - OH_LOG_INFO(LOG_APP, "JSVM EvaluateJS START"); - - CHECK_COND(g_envMap.count(envId) != 0 && g_envMap[envId] != nullptr); - - JSVM_Env env = *g_envMap[envId]; - JSVM_VM vm = *g_vmMap[envId]; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - - std::lock_guard lock_guard(g_mutexLock); - { - // 创建JSVM环境 - CHECK_RET(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(*g_envMap[envId], &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(*g_envMap[envId], &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, source, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - JSVM_ValueType type; - CHECK_RET(OH_JSVM_Typeof(env, result, &type)); - OH_LOG_INFO(LOG_APP, "JSVM API TEST type: %{public}d", type); - // Execute tasks in the current env event queue - while (!g_taskQueueMap[envId].empty()) { - auto task = g_taskQueueMap[envId].front(); - g_taskQueueMap[envId].pop_front(); - task->Run(); - delete task; - } - - if (type == JSVM_STRING) { - CHECK_COND(fromOHStringValue(env, result, res) != -1); - } else if (type == JSVM_BOOLEAN) { - bool ret = false; - CHECK_RET(OH_JSVM_GetValueBool(env, result, &ret)); - ret ? res = "true" : res = "false"; - } else if (type == JSVM_NUMBER) { - int32_t num; - CHECK_RET(OH_JSVM_GetValueInt32(env, result, &num)); - res = std::to_string(num); - } else if (type == JSVM_OBJECT) { - JSVM_Value objResult; - CHECK_RET(OH_JSVM_JsonStringify(env, result, &objResult)); - CHECK_COND(fromOHStringValue(env, objResult, res) != -1); - } - } - { - bool aal = false; - CHECK_RET(OH_JSVM_PumpMessageLoop(*g_vmMap[envId], &aal)); - CHECK_RET(OH_JSVM_PerformMicrotaskCheckpoint(*g_vmMap[envId])); - CHECK_RET(OH_JSVM_CloseHandleScope(*g_envMap[envId], handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(*g_envMap[envId], envScope)); - CHECK_RET(OH_JSVM_CloseVMScope(*g_vmMap[envId], vmScope)); - } - OH_LOG_INFO(LOG_APP, "JSVM EvaluateJS END"); - return 0; -} - -static int32_t TestJSVM() -{ - const char source1[] = "{\ - let a = \"hello World\";\ - consoleinfo(a);\ - const mPromise = createPromise();\ - mPromise.then((result) => {\ - assertEqual(result, 0);\ - });\ - a;\ - };"; - - const char source2[] = "{\ - let a = \"second hello\";\ - consoleinfo(a);\ - let b = add(99, 1);\ - assertEqual(100, b);\ - assertEqual(add(99, 1), 100);\ - createPromise().then((result) => {\ - assertEqual(result, 1);\ - });\ - a;\ - };"; - - // 创建首个运行环境,并绑定TS回调 - uint32_t coreId1; - CHECK_COND(CreateJsCore(&coreId1) == 0); - OH_LOG_INFO(LOG_APP, "TEST coreId: %{public}d", coreId1); - // 在首个运行环境中执行JS代码 - std::string result1; - CHECK_COND(EvaluateJS(coreId1, source1, result1) == 0); - OH_LOG_INFO(LOG_APP, "TEST evaluateJS: %{public}s", result1.c_str()); - - // 创建第二个运行环境,并绑定TS回调 - uint32_t coreId2; - CHECK_COND(CreateJsCore(&coreId2) == 0); - OH_LOG_INFO(LOG_APP, "TEST coreId: %{public}d", coreId2); - // 在第二个运行环境中执行JS代码 - std::string result2; - CHECK_COND(EvaluateJS(coreId2, source2, result2) == 0); - OH_LOG_INFO(LOG_APP, "TEST evaluateJS: %{public}s", result2.c_str()); - - // 释放首个运行环境 - CHECK_COND(ReleaseJsCore(coreId1) == 0); - // 释放第二个运行环境 - CHECK_COND(ReleaseJsCore(coreId2) == 0); - OH_LOG_INFO(LOG_APP, "Test NAPI end"); - - return 0; -} -// [End runtime_task] - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "runtimetask", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/pages/Index.ets deleted file mode 100755 index bf5a1eb34d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libruntimetask.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/module.json5 deleted file mode 100755 index 1c36e13715..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/module.json5 +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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": "runtimetask", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "RuntimetaskAbility", - "deviceTypes": [ - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "RuntimetaskAbility", - "srcEntry": "./ets/runtimetaskability/RuntimetaskAbility.ets", - "description": "$string:RuntimetaskAbility_desc", - "icon": "$media:layered_image", - "label": "$string:RuntimetaskAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/module.json5 deleted file mode 100755 index 245968a2c3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/runtimetask/src/ohosTest/module.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "runtimetask_test", - "type": "feature", - "deviceTypes": [ - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/hvigorfile.ts deleted file mode 100755 index 080a923d0f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmDebug/snapshot/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmDebug/snapshot/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/oh-package.json5 deleted file mode 100755 index b6f16febec..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "snapshot", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libsnapshot.so": "file:./src/main/cpp/types/libsnapshot" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/CMakeLists.txt deleted file mode 100755 index b0e6007926..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmDebug) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(snapshot SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(snapshot PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/hello.cpp deleted file mode 100755 index 10bd63dab2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/hello.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start heap_snapshot] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" -#include -// [StartExclude heap_snapshot] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude heap_snapshot] - -using namespace std; - -// 待调优的JS代码。 -static string g_srcProf = R"JS( -function sleep(delay) { - var start = (new Date()).getTime(); - while ((new Date()).getTime() - start < delay) { - continue; - } -} - -function work3() { - sleep(300); -} - -function work2() { - work3(); - sleep(200); -} - -function work1() { - work2(); - sleep(100); -} - -work1(); -)JS"; - -// 数据输出流回调,用户自定义,处理返回的调优数据,此处以写入文件为例。 -static bool OutputStream(const char *data, int size, void *streamData) -{ - auto &os = *reinterpret_cast(streamData); - if (data) { - os.write(data, size); - } else { - os.close(); - } - return true; -} - -static JSVM_CpuProfiler ProfilingBegin(JSVM_VM vm) -{ - // 文件输出流,保存调优数据,/data/storage/el2/base/files为沙箱路径。以包名为com.example.helloworld为例。 - // 实际文件会保存到/data/app/el2/100/base/com.example.helloworld/files/heap-snapshot-begin.heapsnapshot。 - ofstream heapSnapshot("/data/storage/el2/base/files/heap-snapshot-begin.heapsnapshot", - ios::out | ios::binary | ios::trunc); - // 执行JS前获取一次Heap Snapshot数据。 - OH_JSVM_TakeHeapSnapshot(vm, OutputStream, &heapSnapshot); - JSVM_CpuProfiler cpuProfiler; - // 开启CPU Profiler。 - OH_JSVM_StartCpuProfiler(vm, &cpuProfiler); - return cpuProfiler; -} - -// 关闭调优数据采集工具 -static void ProfilingEnd(JSVM_VM vm, JSVM_CpuProfiler cpuProfiler) -{ - // 文件输出流,保存调优数据,/data/storage/el2/base/files为沙箱路径。以包名为com.example.helloworld为例。 - // 实际文件会保存到/data/app/el2/100/base/com.example.helloworld/files/cpu-profile.cpuprofile。 - ofstream cpuProfile("/data/storage/el2/base/files/cpu-profile.cpuprofile", - ios::out | ios::binary | ios::trunc); - // 关闭CPU Profiler,获取数据。 - OH_JSVM_StopCpuProfiler(vm, cpuProfiler, OutputStream, &cpuProfile); - ofstream heapSnapshot("/data/storage/el2/base/files/heap-snapshot-end.heapsnapshot", - ios::out | ios::binary | ios::trunc); - // 执行JS后再获取一次Heap Snapshot数据,与执行前数据作对比,以分析内存问题或者进行内存调优。 - OH_JSVM_TakeHeapSnapshot(vm, OutputStream, &heapSnapshot); -} - -static JSVM_Value RunScriptWithStatistics(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_VM vm; - OH_JSVM_GetVM(env, &vm); - - // 开始调优。 - auto cpuProfiler = ProfilingBegin(vm); - - JSVM_HandleScope handleScope; - OH_JSVM_OpenHandleScope(env, &handleScope); - - JSVM_Value jsSrc; - OH_JSVM_CreateStringUtf8(env, g_srcProf.c_str(), g_srcProf.size(), &jsSrc); - - JSVM_Script script; - OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script); - - JSVM_Value result; - // 执行JS代码。 - OH_JSVM_RunScript(env, script, &result); - - OH_JSVM_CloseHandleScope(env, handleScope); - - // 结束调优。 - ProfilingEnd(vm, cpuProfiler); - return nullptr; -} -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = RunScriptWithStatistics}, -}; -static JSVM_CallbackStruct *method = param; -// runScriptWithStatistics方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"runScriptWithStatistics", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -const char *SRC_CALL_NATIVE = R"JS(runScriptWithStatistics();)JS"; - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} -// [End heap_snapshot] - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "snapshot", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/oh-package.json5 deleted file mode 100755 index bfedb5325a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/cpp/types/libsnapshot/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libsnapshot.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/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/ets/pages/Index.ets deleted file mode 100755 index 2f98bef4cb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libsnapshot.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/module.json5 deleted file mode 100755 index 5c1459e55a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "snapshot", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "SnapshotAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "SnapshotAbility", - "srcEntry": "./ets/snapshotability/SnapshotAbility.ets", - "description": "$string:SnapshotAbility_desc", - "icon": "$media:layered_image", - "label": "$string:SnapshotAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/string.json deleted file mode 100755 index 64866d03cc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "SnapshotAbility_desc", - "value": "description" - }, - { - "name": "SnapshotAbility_label", - "value": "JsvmDebug" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 95bb1ec3a6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testSnapshot', 0, async (done: Function) => { - console.log('uitest: TestSnapshot begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'SnapshotAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('SnapshotAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestSnapshot end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/module.json5 deleted file mode 100755 index 31599f4aa8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmDebug/snapshot/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "snapshot_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmProcess/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/AppScope/app.json5 deleted file mode 100755 index 4c34bddd1e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmprocess", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/AppScope/resources/base/element/string.json deleted file mode 100755 index 7b8d90ea32..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmProcess" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/README.md deleted file mode 100755 index 3b5babcca6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# ArkTS使用JSVM-API实现JS与C/C++语言交互开发流程 - -### 介绍 - -使用JSVM-API实现跨语言交互,首先需要按照JSVM-API的机制实现模块的注册和加载等相关动作。 - -- ArkTS/JS侧:实现C++方法的调用。代码比较简单,import一个对应的so库后,即可调用C++方法。 -- Native侧:.cpp文件,实现模块的注册。需要提供注册lib库的名称,并在注册回调方法中定义接口的映射关系,即Native方法及对应的JS/ArkTS接口名称等。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API实现JS与C/C++语言交互开发流程](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-process.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :-------------------------------------------------------------: | :-------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击hello world,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 使用JSVM-API实现JS与C/C++语言交互开发流程示例代码 - │ │ │ │ ├── oh-package.json5 // 使用JSVM-API实现JS与C/C++语言交互开发流程示例代码 - │ │ ├── CMakeLists.txt // 使用JSVM-API实现JS与C/C++语言交互开发流程示例代码 - │ │ ├── hello.cpp // 使用JSVM-API实现JS与C/C++语言交互开发流程示例代码 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用JSVM-API实现JS与C/C++语言交互开发流程示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmProcess > .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/ArkTs/JSVMAPI/JsvmProcess/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/build-profile.json5 deleted file mode 100755 index a21d5afe88..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/build-profile.json5 deleted file mode 100755 index d27072efd7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/build-profile.json5 +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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"] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmProcess/entry/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmProcess/entry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index a481b73ee5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(entry SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(entry PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/hello.cpp deleted file mode 100755 index 8abb3222db..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/hello.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_process] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// OH_JSVM_StrictEquals的样例方法 -static JSVM_Value IsStrictEquals(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 接受两个入参 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr)); - // 调用OH_JSVM_StrictEquals接口判断给定的两个JavaScript value是否严格相等 - bool result = false; - JSVM_Status status = OH_JSVM_StrictEquals(env, args[0], args[1], &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_StrictEquals: failed"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_StrictEquals: success: %{public}d", result); - } - JSVM_Value isStrictEqual; - JSVM_CALL(OH_JSVM_GetBoolean(env, result, &isStrictEqual)); - return isStrictEqual; -} -// IsStrictEquals注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = IsStrictEquals}, -}; -static JSVM_CallbackStruct *method = param; -// IsStrictEquals方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"isStrictEquals", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( let data = '123'; - let value = 123; - isStrictEquals(data, value);)JS"; - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } -// [End oh_jsvm_process] diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 0368d3ca46..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start export_native] -export const runTest: () => void; -// [End export_native] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 2404bc1f46..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start call_native_cpp] -import napitest from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} -// [End call_native_cpp] diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/string.json deleted file mode 100755 index 7ea79fc923..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmProcess" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/en_US/element/string.json deleted file mode 100755 index 7ea79fc923..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/en_US/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmProcess" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/zh_CN/element/string.json deleted file mode 100755 index 16fcf0c75f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/resources/zh_CN/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "模块描述" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmProcess" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index b0690e03ef..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testJsvmProcess', 0, async (done: Function) => { - console.log('uitest: TestJsvmProcess begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestJsvmProcess end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmProcess/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmProcess/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/ohosTest.md deleted file mode 100755 index a5e25bbf87..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/ohosTest.md +++ /dev/null @@ -1,8 +0,0 @@ -# JsvmProcess 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 使用JSVM-API实现JS与C/C++语言交互开发流程 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/app.json5 deleted file mode 100755 index dbc4b79b12..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmaboutarray", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/element/string.json deleted file mode 100755 index d832880742..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmAboutArray" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/README.md deleted file mode 100755 index 5a5a98bfc2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/README.md +++ /dev/null @@ -1,333 +0,0 @@ -# ArkTS使用JSVM-API接口进行array相关开发 - -### 介绍 - -使用 JSVM-API 接口进行数组(array)相关开发时,调用相关接口可以在 JSVM 模块中直接操作和处理 JavaScript 中的数组。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口进行array相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-array.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------------: | :----------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -createarray/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createarraywithlength/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createdataview/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createtypedarray/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -deleteelement/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getarraylength/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getdataviewinfo/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getelement/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -gettypedarrayinfo/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -haselement/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -isarray/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -isdataview/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -istypedarray/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -setelement/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/build-profile.json5 deleted file mode 100755 index 37ccc69960..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/build-profile.json5 +++ /dev/null @@ -1,214 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "createarray", - "srcPath": "./createarray", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createarraywithlength", - "srcPath": "./createarraywithlength", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createtypedarray", - "srcPath": "./createtypedarray", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createdataview", - "srcPath": "./createdataview", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getarraylength", - "srcPath": "./getarraylength", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getdataviewinfo", - "srcPath": "./getdataviewinfo", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "deleteelement", - "srcPath": "./deleteelement", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getelement", - "srcPath": "./getelement", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "gettypedarrayinfo", - "srcPath": "./gettypedarrayinfo", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "haselement", - "srcPath": "./haselement", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "isarray", - "srcPath": "./isarray", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "isdataview", - "srcPath": "./isdataview", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "istypedarray", - "srcPath": "./istypedarray", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "setelement", - "srcPath": "./setelement", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/oh-package.json5 deleted file mode 100755 index 63c8d0c03a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createarray", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatearray.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 0d5cbba172..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createarray SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createarray PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/hello.cpp deleted file mode 100755 index 41151a4fc1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/hello.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_array] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_create_array] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_array] - -// CreateArray注册回调 -static int g_diffValueFive = 5; -// OH_JSVM_CreateArray的样例方法 -static JSVM_Value CreateArray(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 创建一个空数组 - JSVM_Value array = nullptr; - JSVM_Status status = OH_JSVM_CreateArray(env, &array); - // 对创建的数组进行赋值 - for (int i = 0; i < g_diffValueFive; i++) { - JSVM_Value element; - OH_JSVM_CreateInt32(env, i, &element); - OH_JSVM_SetElement(env, array, i, element); - } - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateArray fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateArray success"); - } - return array; -} -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateArray}, -}; -static JSVM_CallbackStruct *method = param; -// CreateArray方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createArray", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - function testCreateArray() { - return createArray(); - } - testCreateArray(); -)JS"; -// [End oh_jsvm_create_array] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createarray", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index d7e437a094..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatearray.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/pages/Index.ets deleted file mode 100755 index 9c5aecdf2b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatearray.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/module.json5 deleted file mode 100755 index 346442d217..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "createarray", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/string.json deleted file mode 100755 index 3d8bf57436..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index d3c1e1ff83..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateArray', 0, async (done: Function) => { - console.log('uitest: TestCreateArray begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateArray end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/module.json5 deleted file mode 100755 index d488a0eabc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarray/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createarray_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/oh-package.json5 deleted file mode 100755 index cc11ce7222..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createarraywithlength", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatearraywithlength.so": "file:./src/main/cpp/types/libcreatearraywithlength" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 47e014b43e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createarraywithlength SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createarraywithlength PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/hello.cpp deleted file mode 100755 index 9dcc8c5817..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/hello.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_array_with_length] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_create_array_with_length] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_array_with_length] - -// OH_JSVM_CreateArrayWithLength的样例方法 -static JSVM_Value CreateArrayWithLength(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - JSVM_Value result = nullptr; - // 解析传递的参数OH_JSVM_GetCbInfo - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - // 获取传递的数组长度 - int32_t length; - OH_JSVM_GetValueInt32(env, argv[0], &length); - // 使用OH_JSVM_CreateArrayWithLength创建传递固定长度的数组 - JSVM_Status status = OH_JSVM_CreateArrayWithLength(env, length, &result); - if (status == JSVM_OK) { - // 给创建的数组设置值 - for (int32_t i = 0; i < length; i++) { - JSVM_Value value; - OH_JSVM_CreateInt32(env, i, &value); - OH_JSVM_SetElement(env, result, i, value); - } - OH_LOG_INFO(LOG_APP, "JSVM CreateArrayWithLength success"); - } else { - OH_LOG_ERROR(LOG_APP, "JSVM CreateArrayWithLength fail"); - } - return result; -} -// CreateArrayWithLength注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateArrayWithLength}, -}; -static JSVM_CallbackStruct *method = param; -// CreateArrayWithLength方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createArrayWithLength", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -let num = 7; -function testCreateArrayWithLength(num) { - return createArrayWithLength(num); -} -testCreateArrayWithLength(num); -)JS"; -// [End oh_jsvm_create_array_with_length] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createarraywithlength", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/oh-package.json5 deleted file mode 100755 index c1f86fcff0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/cpp/types/libcreatearraywithlength/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatearraywithlength.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/pages/Index.ets deleted file mode 100755 index c676a7579d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatearraywithlength.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(20) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/module.json5 deleted file mode 100755 index cefadbebfd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createarraywithlength", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreatearraywithlengthAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreatearraywithlengthAbility", - "srcEntry": "./ets/createarraywithlengthability/CreatearraywithlengthAbility.ets", - "description": "$string:CreatearraywithlengthAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreatearraywithlengthAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/string.json deleted file mode 100755 index 9e620f6625..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreatearraywithlengthAbility_desc", - "value": "description" - }, - { - "name": "CreatearraywithlengthAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index a049f3c66a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateArrayWithLength', 0, async (done: Function) => { - console.log('uitest: TestCreateArrayWithLength begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreatearraywithlengthAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreatearraywithlengthAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateArrayWithLength end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/module.json5 deleted file mode 100755 index 04a223f6f4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createarraywithlength/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createarraywithlength_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/oh-package.json5 deleted file mode 100755 index 7f4bd7b093..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createdataview", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatedataview.so": "file:./src/main/cpp/types/libcreatedataview" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 75bce4b0ca..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createdataview SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createdataview PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/hello.cpp deleted file mode 100755 index a09b5c67b6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/hello.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_dataview] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_create_dataview] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -static int g_diffValueFour = 4; -static int g_diffValueTwelve = 12; -// [EndExclude oh_jsvm_create_dataview] - -// OH_JSVM_CreateDataview的样例方法 -static JSVM_Value CreateDataView(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取js侧传入的两个参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - JSVM_Value arrayBuffer = nullptr; - JSVM_Value result = nullptr; - // DataView的字节长度 - size_t byteLength = g_diffValueFour; - // 字节偏移量 - size_t byteOffset = g_diffValueTwelve; - // 获取回调函数的参数信息 - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 将参数转换为对象类型 - OH_JSVM_CoerceToObject(env, args[0], &arrayBuffer); - // 创建一个数据视图对象,并指定字节长度和字节偏移量 - JSVM_Status status = OH_JSVM_CreateDataview(env, byteLength, arrayBuffer, byteOffset, &result); - // 获取DataView的指针和长度信息 - uint8_t *data = nullptr; - size_t length = 0; - // 为DataView赋值 - for (size_t i = 0; i < length; i++) { - data[i] = static_cast(i + 1); - } - int32_t infoType; - OH_JSVM_GetValueInt32(env, args[1], &infoType); - size_t returnLength; - JSVM_Value returnArrayBuffer = nullptr; - size_t returnOffset; - enum InfoType { BYTE_LENGTHE, ARRAY_BUFFERE, BYTE_OFFSET }; - // 获取dataview信息 - OH_JSVM_GetDataviewInfo(env, result, &returnLength, (void **)&data, &returnArrayBuffer, &returnOffset); - JSVM_Value returnResult = nullptr; - switch (infoType) { - case BYTE_LENGTHE: - JSVM_Value len; - OH_JSVM_CreateInt32(env, returnLength, &len); - returnResult = len; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateDataView fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateDataView success, returnLength: %{public}d", returnLength); - } - break; - case ARRAY_BUFFERE: - bool isArraybuffer; - OH_JSVM_IsArraybuffer(env, returnArrayBuffer, &isArraybuffer); - JSVM_Value isArray; - OH_JSVM_GetBoolean(env, isArraybuffer, &isArray); - returnResult = isArray; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateDataView fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateDataView success, isArraybuffer: %{public}d", isArraybuffer); - } - break; - case BYTE_OFFSET: - JSVM_Value offset; - OH_JSVM_CreateInt32(env, returnOffset, &offset); - returnResult = offset; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateDataView fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateDataView success, returnOffset: %{public}d", returnOffset); - } - break; - default: - break; - } - return returnResult; -} -// CreateDataView注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateDataView}, -}; -static JSVM_CallbackStruct *method = param; -// CreateDataView方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createDataView", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let BYTE_LENGTH = 0; - createDataView(new ArrayBuffer(16), BYTE_LENGTH); - let IS_ARRAYBUFFER = 1; - createDataView(new ArrayBuffer(16), IS_ARRAYBUFFER); - let BYTE_OFFSET = 2; - createDataView(new ArrayBuffer(16), BYTE_OFFSET); -)JS"; -// [End oh_jsvm_create_dataview] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createdataview", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/oh-package.json5 deleted file mode 100755 index 9653374a74..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/cpp/types/libcreatedataview/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatedataview.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/pages/Index.ets deleted file mode 100755 index f5ffe06ef0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatedataview.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/module.json5 deleted file mode 100755 index cba8ebfc17..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createdataview", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreatedataviewAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreatedataviewAbility", - "srcEntry": "./ets/createdataviewability/CreatedataviewAbility.ets", - "description": "$string:CreatedataviewAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreatedataviewAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/string.json deleted file mode 100755 index 1428955362..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreatedataviewAbility_desc", - "value": "description" - }, - { - "name": "CreatedataviewAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 3e65b7fc13..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateDataview', 0, async (done: Function) => { - console.log('uitest: TestCreateDataview begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreatedataviewAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreatedataviewAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateDataview end'); - done(); - }) - }) -} - - diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/module.json5 deleted file mode 100755 index 981100fb5a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createdataview/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createdataview_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/oh-package.json5 deleted file mode 100755 index cedcd93b55..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createtypedarray", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatetypedarray.so": "file:./src/main/cpp/types/libcreatetypedarray" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 8dc6f9cca7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createtypedarray SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createtypedarray PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/hello.cpp deleted file mode 100755 index 0600c70a8b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/hello.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_typedarray] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_create_typedarray] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_typedarray] - -// OH_JSVM_CreateTypedarray的样例方法 -static int g_diffValueThree = 3; -static JSVM_Value CreateTypedArray(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - int32_t typeNum; - OH_JSVM_GetValueInt32(env, args[0], &typeNum); - JSVM_TypedarrayType arrayType; - // 用于存储每个元素的大小 - size_t elementSize = 0; - // 转换为JSVM_TypedarrayType类型 - arrayType = static_cast(typeNum); - switch (typeNum) { - case JSVM_INT8_ARRAY: - case JSVM_UINT8_ARRAY: - case JSVM_UINT8_CLAMPED_ARRAY: - elementSize = sizeof(int8_t); - break; - case JSVM_INT16_ARRAY: - case JSVM_UINT16_ARRAY: - elementSize = sizeof(int16_t); - break; - case JSVM_INT32_ARRAY: - case JSVM_UINT32_ARRAY: - elementSize = sizeof(int32_t); - break; - case JSVM_FLOAT32_ARRAY: - elementSize = sizeof(float); - break; - case JSVM_FLOAT64_ARRAY: - elementSize = sizeof(double); - break; - case JSVM_BIGINT64_ARRAY: - case JSVM_BIGUINT64_ARRAY: - elementSize = sizeof(int64_t); - break; - default: - // 默认创建JSVM_INT8_ARRAY类型 - arrayType = JSVM_INT8_ARRAY; - elementSize = sizeof(int8_t); - break; - } - size_t length = g_diffValueThree; - JSVM_Value arrayBuffer = nullptr; - JSVM_Value typedArray = nullptr; - void *data; - // 创建一个ArrayBuffer - OH_JSVM_CreateArraybuffer(env, length * elementSize, (void **)&data, &arrayBuffer); - // 根据给定类型创建TypedArray - JSVM_Status status = OH_JSVM_CreateTypedarray(env, arrayType, length, arrayBuffer, 0, &typedArray); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateTypedArray fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateTypedArray success"); - } - return typedArray; -} -// CreateTypedArray注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateTypedArray}, -}; -static JSVM_CallbackStruct *method = param; -// CreateTypedArray方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createTypedArray", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -const type = { - INT8_ARRAY: 0, - UINT8_ARRAY: 1, - UINT8_CLAMPED_ARRAY: 2, - INT16_ARRAY: 3, - UINT16_ARRAY: 4, - INT32_ARRAY: 5, - UINT32_ARRAY: 6, - FLOAT32_ARRAY: 7, - FLOAT64_ARRAY: 8, - BIGINT64_ARRAY: 9, - BIGUINT64_ARRAY: 10 -}; -createTypedArray(type.INT8_ARRAY); -createTypedArray(type.INT32_ARRAY); -)JS"; -// [End oh_jsvm_create_typedarray] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createtypedarray", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/oh-package.json5 deleted file mode 100755 index 5f27f7ae47..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/cpp/types/libcreatetypedarray/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatetypedarray.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/pages/Index.ets deleted file mode 100755 index 79511e92a6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatetypedarray.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/module.json5 deleted file mode 100755 index 85350c9d34..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createtypedarray", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreatetypedarrayAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreatetypedarrayAbility", - "srcEntry": "./ets/createtypedarrayability/CreatetypedarrayAbility.ets", - "description": "$string:CreatetypedarrayAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreatetypedarrayAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/string.json deleted file mode 100755 index 9789b9bc24..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreatetypedarrayAbility_desc", - "value": "description" - }, - { - "name": "CreatetypedarrayAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 590ae770a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateTypedarray', 0, async (done: Function) => { - console.log('uitest: TestCreateTypedarray begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreatetypedarrayAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreatetypedarrayAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateTypedarray end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/module.json5 deleted file mode 100755 index 2d81b3fa67..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/createtypedarray/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createtypedarray_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/oh-package.json5 deleted file mode 100755 index fbde561706..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "deleteelement", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libdeleteelement.so": "file:./src/main/cpp/types/libdeleteelement" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 5b12e77768..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(deleteelement SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(deleteelement PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/hello.cpp deleted file mode 100755 index 2e9f870a41..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/hello.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_delete_element] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_delete_element] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_delete_element] - -// OH_JSVM_DeleteElement的样例方法 -static JSVM_Value DeleteElement(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取js侧传入的两个参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 获取要删除的元素的索引 - uint32_t index; - OH_JSVM_GetValueUint32(env, args[1], &index); - // 尝试删除请求索引位置的元素 - bool deleted = true; - JSVM_Status status = OH_JSVM_DeleteElement(env, args[0], index, &deleted); - // 将boolean结果转换为JSVM_Value并返回 - JSVM_Value result = nullptr; - OH_JSVM_GetBoolean(env, deleted, &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM DeleteElement fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM DeleteElement: %{public}d", deleted); - } - return result; -} -// DeleteElement注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = DeleteElement}, -}; -static JSVM_CallbackStruct *method = param; -// DeleteElement方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"deleteElement", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -let arr = [10, 'hello', null, true]; -deleteElement(arr, 0); -)JS"; -// [End oh_jsvm_delete_element] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "deleteelement", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/oh-package.json5 deleted file mode 100755 index 0350dbeaf7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/cpp/types/libdeleteelement/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libdeleteelement.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/pages/Index.ets deleted file mode 100755 index 4247687554..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libdeleteelement.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/module.json5 deleted file mode 100755 index e526710824..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "deleteelement", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "DeleteelementAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "DeleteelementAbility", - "srcEntry": "./ets/deleteelementability/DeleteelementAbility.ets", - "description": "$string:DeleteelementAbility_desc", - "icon": "$media:layered_image", - "label": "$string:DeleteelementAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/string.json deleted file mode 100755 index 8e16870578..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "DeleteelementAbility_desc", - "value": "description" - }, - { - "name": "DeleteelementAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 25f031b236..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testDeleteElement', 0, async (done: Function) => { - console.log('uitest: TestDeleteElement begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'DeleteelementAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('DeleteelementAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestDeleteElement end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/module.json5 deleted file mode 100755 index 38e4466021..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/deleteelement/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "deleteelement_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/oh-package.json5 deleted file mode 100755 index afb6398939..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getarraylength", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetarraylength.so": "file:./src/main/cpp/types/libgetarraylength" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 4c38cc2bfb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(getarraylength SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getarraylength PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/hello.cpp deleted file mode 100755 index 812652590c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/hello.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_array_length] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_get_array_length] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_array_length] - -// OH_JSVM_GetArrayLength的样例方法 -static JSVM_Value GetArrayLength(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - JSVM_Value result = nullptr; - uint32_t length; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 检查参数是否为数组 - bool isArray = false; - OH_JSVM_IsArray(env, args[0], &isArray); - if (!isArray) { - OH_LOG_INFO(LOG_APP, "JSVM Argument must be an array"); - return nullptr; - } - OH_JSVM_GetArrayLength(env, args[0], &length); - // 创建返回值 - OH_JSVM_CreateInt32(env, length, &result); - OH_LOG_INFO(LOG_APP, "JSVM length: %{public}d", length); - return result; -} -// GetArrayLength注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetArrayLength}, -}; -static JSVM_CallbackStruct *method = param; -// GetArrayLength方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getArrayLength", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -let data = [0, 1, 2, 3, 4, 5]; -getArrayLength(data); -)JS"; -// [End oh_jsvm_get_array_length] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getarraylength", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/oh-package.json5 deleted file mode 100755 index 9d5b523f89..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/cpp/types/libgetarraylength/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetarraylength.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/pages/Index.ets deleted file mode 100755 index d8feb8fc99..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetarraylength.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/module.json5 deleted file mode 100755 index 4b52aff246..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getarraylength", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetarraylengthAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetarraylengthAbility", - "srcEntry": "./ets/getarraylengthability/GetarraylengthAbility.ets", - "description": "$string:GetarraylengthAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetarraylengthAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/string.json deleted file mode 100755 index 88de37e1f0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetarraylengthAbility_desc", - "value": "description" - }, - { - "name": "GetarraylengthAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 957bffe8a8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetArrayLength', 0, async (done: Function) => { - console.log('uitest: TestGetArrayLength begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetarraylengthAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetarraylengthAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetArrayLength end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/module.json5 deleted file mode 100755 index 093ea39273..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getarraylength/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getarraylength_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/oh-package.json5 deleted file mode 100755 index 240fac3600..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getdataviewinfo", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetdataviewinfo.so": "file:./src/main/cpp/types/libgetdataviewinfo" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 7c755c1887..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getdataviewinfo SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getdataviewinfo PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/hello.cpp deleted file mode 100755 index f33e8c4b21..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/hello.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_dataview_info] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_get_dataview_info] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_dataview_info] - -// OH_JSVM_GetDataviewInfo的样例方法 -static JSVM_Value GetDataViewInfo(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取并解析参数,第一个参数为需要获得的信息的DataView类型数据,第二个参数为需要获得的信息类型的枚举值 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 将第二个参数转为int32类型的数字 - int32_t infoType; - OH_JSVM_GetValueInt32(env, args[1], &infoType); - size_t byteLength; - void *data; - JSVM_Value arrayBuffer = nullptr; - size_t byteOffset; - // 定义枚举类型与ArkTS侧枚举类型infoType顺序含义一致 - enum InfoTypeEnum { BYTE_LENGTHE, ARRAY_BUFFERE, BYTE_OFFSET }; - // 获取dataview信息 - JSVM_Status status = OH_JSVM_GetDataviewInfo(env, args[0], &byteLength, &data, &arrayBuffer, &byteOffset); - JSVM_Value result = nullptr; - switch (infoType) { - case BYTE_LENGTHE: - // 返回查询DataView的长度 - JSVM_Value len; - OH_JSVM_CreateInt32(env, byteLength, &len); - result = len; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetDataViewInfo fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetDataViewInfo success, byteLength: %{public}d", byteLength); - } - break; - case ARRAY_BUFFERE: - // 判断DataView的Info里的arraybuffer是否为arraybuffer - bool isArrayBuffer; - OH_JSVM_IsArraybuffer(env, arrayBuffer, &isArrayBuffer); - JSVM_Value isArray; - OH_JSVM_GetBoolean(env, isArrayBuffer, &isArray); - result = isArray; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetDataViewInfo fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetDataViewInfo success, isArrayBuffer: %{public}d", isArrayBuffer); - } - break; - case BYTE_OFFSET: - // 返回查询DataView的偏移量 - JSVM_Value offset; - OH_JSVM_CreateInt32(env, byteOffset, &offset); - result = offset; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetDataViewInfo fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetDataViewInfo success, byteOffset: %{public}d", byteOffset); - } - break; - default: - break; - } - return result; -} -// GetDataViewInfo注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetDataViewInfo}, -}; -static JSVM_CallbackStruct *method = param; -// GetDataViewInfo方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getDataViewInfo", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -// bytelength -getDataViewInfo(new DataView(new Int8Array([2, 5]).buffer), 0); -// is arraybuffer -let data = 'a'; -let isarraybuffer = 1; -getDataViewInfo(data, isarraybuffer); -// is arraybuffer -data = new DataView(new Int8Array([2, 5, 3]).buffer); -isarraybuffer = 1; -getDataViewInfo(data, isarraybuffer); -// byte_offset -data = new DataView(new Int8Array([2, 5, 3]).buffer); -isarraybuffer = 2; -getDataViewInfo(data, isarraybuffer); -)JS"; -// [End oh_jsvm_get_dataview_info] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getdataviewinfo", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/oh-package.json5 deleted file mode 100755 index 9a0cc23ab2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/cpp/types/libgetdataviewinfo/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetdataviewinfo.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/pages/Index.ets deleted file mode 100755 index 32d6f917d4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetdataviewinfo.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/module.json5 deleted file mode 100755 index 001ee524e9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getdataviewinfo", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetdataviewinfoAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetdataviewinfoAbility", - "srcEntry": "./ets/getdataviewinfoability/GetdataviewinfoAbility.ets", - "description": "$string:GetdataviewinfoAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetdataviewinfoAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/string.json deleted file mode 100755 index b619521694..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetdataviewinfoAbility_desc", - "value": "description" - }, - { - "name": "GetdataviewinfoAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 1be7cecf36..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetDataviewInfo', 0, async (done: Function) => { - console.log('uitest: TestGetDataviewInfo begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetdataviewinfoAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetdataviewinfoAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetDataviewInfo end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/module.json5 deleted file mode 100755 index c595eab4d4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getdataviewinfo/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getdataviewinfo_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/oh-package.json5 deleted file mode 100755 index c1f8854b4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getelement", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetelement.so": "file:./src/main/cpp/types/libgetelement" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/CMakeLists.txt deleted file mode 100755 index e464c31a37..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getelement SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getelement PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/hello.cpp deleted file mode 100755 index 366f032f34..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/hello.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_element] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_get_element] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_element] - -// OH_JSVM_GetElement的样例方法 -static JSVM_Value GetElement(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取js侧传入的两个参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 获取请求元素的索引值 - uint32_t index; - OH_JSVM_GetValueUint32(env, args[1], &index); - // 获取请求索引位置的元素值并存储在result中 - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_GetElement(env, args[0], index, &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetElement fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetElement success"); - } - return result; -} -// GetElement注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetElement}, -}; -static JSVM_CallbackStruct *method = param; -// GetElement方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getElement", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -let arr = [10, 'hello', null, true]; -getElement(arr, 3); -)JS"; -// [End oh_jsvm_get_element] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getelement", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/oh-package.json5 deleted file mode 100755 index 0e846c8c7b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/cpp/types/libgetelement/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetelement.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/pages/Index.ets deleted file mode 100755 index 187a0cf28e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetelement.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/module.json5 deleted file mode 100755 index 657a5d71ff..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "getelement", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetelementAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetelementAbility", - "srcEntry": "./ets/getelementability/GetelementAbility.ets", - "description": "$string:GetelementAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetelementAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/string.json deleted file mode 100755 index b3ad9820da..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetelementAbility_desc", - "value": "description" - }, - { - "name": "GetelementAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 4619cbc4aa..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetElement', 0, async (done: Function) => { - console.log('uitest: TestGetElement begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetelementAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetelementAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetElement end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/module.json5 deleted file mode 100755 index ab78ec4839..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/getelement/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "getelement_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/oh-package.json5 deleted file mode 100755 index 09fce729c0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "gettypedarrayinfo", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgettypedarrayinfo.so": "file:./src/main/cpp/types/libgettypedarrayinfo" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/CMakeLists.txt deleted file mode 100755 index b393844fb4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(gettypedarrayinfo SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(gettypedarrayinfo PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/hello.cpp deleted file mode 100755 index f1cf8ff32d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/hello.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_typedarray_info] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_get_typedarray_info] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_typedarray_info] - -// OH_JSVM_GetTypedarrayInfo的样例方法 -static JSVM_Value GetTypedArrayInfo(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取并解析参数,第一个参数为需要获得的信息的TypedArray类型数据,第二个参数为需要获得的信息类型的枚举值 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - - // 将第二个参数转为int32类型便于比较 - int32_t infoTypeParam; - OH_JSVM_GetValueInt32(env, args[1], &infoTypeParam); - // 定义枚举类型与ArkTS侧枚举类型infoType顺序含义一致 - enum InfoType { INFO_TYPE, INFO_LENGTH, INFO_ARRAY_BUFFER, INFO_BYTE_OFFSET }; - void *data; - JSVM_TypedarrayType type; - size_t byteOffset; - size_t length; - JSVM_Value arrayBuffer = nullptr; - // 调用接口OH_JSVM_GetTypedarrayInfo获得TypedArray类型数据的信息 - JSVM_Status status = OH_JSVM_GetTypedarrayInfo(env, args[0], &type, &length, &data, &arrayBuffer, &byteOffset); - JSVM_Value result = nullptr; - // 根据属性名,返回TypedArray对应的属性值 - switch (infoTypeParam) { - case INFO_TYPE: - // 如果传入的参数是int8类型的TypedArray数据,它的类型(type)为JSVM_INT8_ARRAY - JSVM_Value int8_type; - OH_JSVM_GetBoolean(env, type == JSVM_INT8_ARRAY, &int8_type); - result = int8_type; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetTypedArrayInfo fail"); - } else { - OH_LOG_INFO( - LOG_APP, "JSVM GetTypedArrayInfo success, JSVM_INT8_ARRAY: %{public}d", type == JSVM_INT8_ARRAY); - } - break; - case INFO_LENGTH: - // TypedArray中的元素数 - JSVM_Value jsvmLength; - OH_JSVM_CreateInt32(env, length, &jsvmLength); - result = jsvmLength; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetTypedArrayInfo fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetTypedArrayInfo success, length: %{public}d", length); - } - break; - case INFO_BYTE_OFFSET: - // TypedArray数组的第一个元素所在的基础原生数组中的字节偏移量 - JSVM_Value jsvmOffset; - OH_JSVM_CreateInt32(env, byteOffset, &jsvmOffset); - result = jsvmOffset; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetTypedArrayInfo fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetTypedArrayInfo success, byteOffset: %{public}d", byteOffset); - } - break; - case INFO_ARRAY_BUFFER: - // TypedArray下的ArrayBuffer - bool isArrayBuffer; - OH_JSVM_IsArraybuffer(env, arrayBuffer, &isArrayBuffer); - JSVM_Value isArray; - OH_JSVM_GetBoolean(env, isArrayBuffer, &isArray); - result = isArray; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetTypedArrayInfo fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetTypedArrayInfo success, isArrayBuffer: %{public}d", isArrayBuffer); - } - break; - default: - break; - } - return result; -} -// GetTypedArrayInfo注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetTypedArrayInfo}, -}; -static JSVM_CallbackStruct *method = param; -// GetTypedArrayInfo方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getTypedArrayInfo", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -// is JSVM_INT8_ARRAY -getTypedArrayInfo(new Int8Array(3), 0); -// length -getTypedArrayInfo(new Int8Array(5), 1); -// is_arraybuffer -getTypedArrayInfo(new Int8Array(5), 2); -// byteoffset -getTypedArrayInfo(new Int8Array(1), 3); -)JS"; -// [End oh_jsvm_get_typedarray_info] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "gettypedarrayinfo", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/oh-package.json5 deleted file mode 100755 index a2a823c548..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/cpp/types/libgettypedarrayinfo/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgettypedarrayinfo.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/pages/Index.ets deleted file mode 100755 index ee70840b9e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgettypedarrayinfo.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/module.json5 deleted file mode 100755 index 954fdd8390..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "gettypedarrayinfo", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GettypedarrayinfoAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GettypedarrayinfoAbility", - "srcEntry": "./ets/gettypedarrayinfoability/GettypedarrayinfoAbility.ets", - "description": "$string:GettypedarrayinfoAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GettypedarrayinfoAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/string.json deleted file mode 100755 index b839e5008f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GettypedarrayinfoAbility_desc", - "value": "description" - }, - { - "name": "GettypedarrayinfoAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 1a47c5d0c6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetTypedarrayInfo', 0, async (done: Function) => { - console.log('uitest: TestGetTypedarrayInfo begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GettypedarrayinfoAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GettypedarrayinfoAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetTypedarrayInfo end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/module.json5 deleted file mode 100755 index 7e4bee2e69..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/gettypedarrayinfo/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "gettypedarrayinfo_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/oh-package.json5 deleted file mode 100755 index 91f1cc6de8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "haselement", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libhaselement.so": "file:./src/main/cpp/types/libhaselement" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/CMakeLists.txt deleted file mode 100755 index e1d5fe2b8d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(haselement SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(haselement PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/hello.cpp deleted file mode 100755 index 4370926d0c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/hello.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_has_element] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_has_element] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_has_element] - -// OH_JSVM_HasElement的样例方法 -static JSVM_Value HasElement(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取js侧传入的两个参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 获取要判断的元素的索引 - uint32_t index; - OH_JSVM_GetValueUint32(env, args[1], &index); - // 判断指定索引位置的元素是否存在 - bool hasElement = true; - JSVM_Status status = OH_JSVM_HasElement(env, args[0], index, &hasElement); - // 将boolean结果转换为JSVM_Value并返回 - JSVM_Value result = nullptr; - OH_JSVM_GetBoolean(env, hasElement, &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM hasElement fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM hasElement: %{public}d", hasElement); - } - return result; -} -// HasElement注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = HasElement}, -}; -static JSVM_CallbackStruct *method = param; -// HasElement方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"hasElement", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *srcCallNative = R"JS( -let arr = [10, 'hello', null, true]; -hasElement(arr, 0); -hasElement(arr, 4); -)JS"; -// [End oh_jsvm_has_element] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, srcCallNative, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "haselement", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/oh-package.json5 deleted file mode 100755 index bd4584f9ef..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/cpp/types/libhaselement/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libhaselement.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/pages/Index.ets deleted file mode 100755 index 071a12fc4f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libhaselement.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/module.json5 deleted file mode 100755 index e2c9317fe1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "haselement", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "HaselementAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "HaselementAbility", - "srcEntry": "./ets/haselementability/HaselementAbility.ets", - "description": "$string:HaselementAbility_desc", - "icon": "$media:layered_image", - "label": "$string:HaselementAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/string.json deleted file mode 100755 index 246a5cc3b9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "HaselementAbility_desc", - "value": "description" - }, - { - "name": "HaselementAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 6912c5387c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testHasElement', 0, async (done: Function) => { - console.log('uitest: TestHasElement begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'HaselementAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('HaselementAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestHasElement end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/module.json5 deleted file mode 100755 index b9f3e45cb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/haselement/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "haselement_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/oh-package.json5 deleted file mode 100755 index c92fdff954..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "isarray", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libisarray.so": "file:./src/main/cpp/types/libisarray" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 36f0d152c2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(isarray SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(isarray PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/hello.cpp deleted file mode 100755 index 7eed0f9d06..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_is_array] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_is_array] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_is_array] - -// OH_JSVM_IsArray的样例方法 -static JSVM_Value IsArray(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - bool result = false; - JSVM_Status status = OH_JSVM_IsArray(env, args[0], &result); - JSVM_Value returnValue = nullptr; - OH_JSVM_GetBoolean(env, result, &returnValue); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM IsArray fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM IsArray success, IsArray: %{public}d", result); - } - return returnValue; -} -// IsArray注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = IsArray}, -}; -static JSVM_CallbackStruct *method = param; -// IsArray方法别名,TS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"isArray", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *srcCallNative = R"JS( -let data = [1, 2, 3, 4, 5]; -isArray(data); -)JS"; -// [End oh_jsvm_is_array] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, srcCallNative, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "isarray", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/oh-package.json5 deleted file mode 100755 index f11e22fde6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/cpp/types/libisarray/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libisarray.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/pages/Index.ets deleted file mode 100755 index 95d272e3df..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libisarray.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/module.json5 deleted file mode 100755 index d3492384bf..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "isarray", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "IsarrayAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "IsarrayAbility", - "srcEntry": "./ets/isarrayability/IsarrayAbility.ets", - "description": "$string:IsarrayAbility_desc", - "icon": "$media:layered_image", - "label": "$string:IsarrayAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/string.json deleted file mode 100755 index 0bb38989cc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "IsarrayAbility_desc", - "value": "description" - }, - { - "name": "IsarrayAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 5bcfe8950d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testIsArray', 0, async (done: Function) => { - console.log('uitest: TestIsArray begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'IsarrayAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('IsarrayAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestIsArray end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/module.json5 deleted file mode 100755 index 356ab988c0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isarray/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "isarray_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/oh-package.json5 deleted file mode 100755 index 476e6736cc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "isdataview", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libisdataview.so": "file:./src/main/cpp/types/libisdataview" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 564b50cfe3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(isdataview SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(isdataview PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/hello.cpp deleted file mode 100755 index 762ea1f572..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/hello.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_is_dataview] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_is_dataview] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_is_dataview] - -// OH_JSVM_IsDataview的样例方法 -static JSVM_Value IsDataView(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 调用OH_JSVM_IsDataview接口判断给定入参是否为DataView数据。 - bool result = false; - JSVM_Status status = OH_JSVM_IsDataview(env, args[0], &result); - JSVM_Value isDateView = nullptr; - OH_JSVM_GetBoolean(env, result, &isDateView); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM IsDataView fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM IsDataView: %{public}d", result); - } - return isDateView; -} -// IsDataView注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = IsDataView}, -}; -static JSVM_CallbackStruct *method = param; -// IsDataView方法别名,TS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"isDataView", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *srcCallNative = R"JS( -let buffer = new ArrayBuffer(16); -let dataView = new DataView(buffer); -isDataView(dataView); -)JS"; -// [End oh_jsvm_is_dataview] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, srcCallNative, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "isdataview", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/oh-package.json5 deleted file mode 100755 index b6302ca5ec..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/cpp/types/libisdataview/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libisdataview.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/pages/Index.ets deleted file mode 100755 index f7f14d9729..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libisdataview.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/module.json5 deleted file mode 100755 index 5c8abef952..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "isdataview", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "IsdataviewAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "IsdataviewAbility", - "srcEntry": "./ets/isdataviewability/IsdataviewAbility.ets", - "description": "$string:IsdataviewAbility_desc", - "icon": "$media:layered_image", - "label": "$string:IsdataviewAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/string.json deleted file mode 100755 index 8603514ee5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "IsdataviewAbility_desc", - "value": "description" - }, - { - "name": "IsdataviewAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index a3dec8ed2b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testIsDataview', 0, async (done: Function) => { - console.log('uitest: TestIsDataview begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'IsdataviewAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('IsdataviewAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestIsDataview end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/module.json5 deleted file mode 100755 index 758fddc1c9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/isdataview/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "isdataview_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/oh-package.json5 deleted file mode 100755 index 38ca37b6db..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "istypedarray", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libistypedarray.so": "file:./src/main/cpp/types/libistypedarray" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 7af3080ae7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(istypedarray SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(istypedarray PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/hello.cpp deleted file mode 100755 index ecf31b201e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/hello.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_is_typedarray] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_is_typedarray] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_is_typedarray] - -// OH_JSVM_IsTypedarray的样例方法 -static JSVM_Value IsTypedarray(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - bool result = false; - JSVM_Status status = OH_JSVM_IsTypedarray(env, args[0], &result); - JSVM_Value isTypedArray = nullptr; - OH_JSVM_GetBoolean(env, result, &isTypedArray); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM IsTypedarray fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM IsTypedarray: %{public}d", result); - } - return isTypedArray; -} -// IsTypedarray注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = IsTypedarray}, -}; -static JSVM_CallbackStruct *method = param; -// IsTypedarray方法别名,TS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"isTypedarray", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *srcCallNative = R"JS( -isTypedarray(new Uint16Array([1, 2, 3, 4])); -)JS"; -// [End oh_jsvm_is_typedarray] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, srcCallNative, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "istypedarray", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/oh-package.json5 deleted file mode 100755 index db3279c30a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/cpp/types/libistypedarray/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libistypedarray.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/pages/Index.ets deleted file mode 100755 index e93f657328..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libistypedarray.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/module.json5 deleted file mode 100755 index 8a0d306d78..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "istypedarray", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "IstypedarrayAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "IstypedarrayAbility", - "srcEntry": "./ets/istypedarrayability/IstypedarrayAbility.ets", - "description": "$string:IstypedarrayAbility_desc", - "icon": "$media:layered_image", - "label": "$string:IstypedarrayAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/string.json deleted file mode 100755 index 305ffc3c42..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "IstypedarrayAbility_desc", - "value": "description" - }, - { - "name": "IstypedarrayAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 16f2c7c380..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testIsTypedarray', 0, async (done: Function) => { - console.log('uitest: TestIsTypedarray begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'IstypedarrayAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('IstypedarrayAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestIsTypedarray end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/module.json5 deleted file mode 100755 index ea68795375..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/istypedarray/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "istypedarray_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/ohosTest.md deleted file mode 100755 index e12b05ad3d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/ohosTest.md +++ /dev/null @@ -1,21 +0,0 @@ -# JsvmAboutArray 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 创建一个新的 JavaScript 数组对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 创建一个指定长度的 JavaScript 数组对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 在现有的 ArrayBuffer 上创建一个 JavaScript DataView 对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 在现有的 ArrayBuffer 上创建一个 JavaScript TypedArray 对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 尝试删除给定对象的指定索引处的元素 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 返回 Array 对象的长度 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取 Dataview 对象的信息 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定对象指定索引处的元素 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取 TypedArray(类型化数组)对象的信息 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 若给定对象的指定索引处拥有属性,获取该元素 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 判断一个 JavaScript 对象是否为 Array 类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 判断一个 JavaScript 对象是否为 Dataview 类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 判断一个 JavaScript 对象是否为 Typedarray 类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 在给定对象的指定索引处设置元素 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/oh-package.json5 deleted file mode 100755 index 0c59a43f39..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "setelement", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libsetelement.so": "file:./src/main/cpp/types/libsetelement" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 19fe43ea27..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(setelement SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(setelement PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/hello.cpp deleted file mode 100755 index c81c3737da..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/hello.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_set_element] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_set_element] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_set_element] - -// OH_JSVM_SetElement的样例方法 -static int g_diffValueThree = 3; -static JSVM_Value SetElement(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = g_diffValueThree; - JSVM_Value args[3] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - int32_t index = 0; - OH_JSVM_GetValueInt32(env, args[1], &index); - JSVM_Status status = OH_JSVM_SetElement(env, args[0], index, args[2]); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM SetElement fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM SetElement success"); - } - return args[0]; -} -// SetElement注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = SetElement}, -}; -static JSVM_CallbackStruct *method = param; -// SetElement方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"setElement", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -setElement(3); -)JS"; -// [End oh_jsvm_set_element] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "setelement", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/oh-package.json5 deleted file mode 100755 index 029e1bf80d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/cpp/types/libsetelement/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libsetelement.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/pages/Index.ets deleted file mode 100755 index 559532bd15..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libsetelement.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/module.json5 deleted file mode 100755 index e5b86c801b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "setelement", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "SetelementAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "SetelementAbility", - "srcEntry": "./ets/setelementability/SetelementAbility.ets", - "description": "$string:SetelementAbility_desc", - "icon": "$media:layered_image", - "label": "$string:SetelementAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/string.json deleted file mode 100755 index cbd9e537b8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "SetelementAbility_desc", - "value": "description" - }, - { - "name": "SetelementAbility_label", - "value": "JsvmAboutArray" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 062ebfc4fd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testSetElement', 0, async (done: Function) => { - console.log('uitest: TestSetElement begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'SetelementAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('SetelementAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestSetElement end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/module.json5 deleted file mode 100755 index 46b5e93fff..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArray/setelement/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "setelement_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/app.json5 deleted file mode 100755 index eb29f6aefa..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmaboutarraybuffer", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/element/string.json deleted file mode 100755 index 613535572c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmAboutArraybuffer" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/README.md deleted file mode 100755 index 15dd8d2044..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/README.md +++ /dev/null @@ -1,133 +0,0 @@ -# ArkTS使用JSVM-API接口进行ArrayBuffer相关开发 - -### 介绍 - -ArrayBuffer 是 JavaScript 中的一种数据类型,用于表示通用的、固定长度的原始二进制数据缓冲区。它提供了一种在 JavaScript 中有效地表示和操作原始二进制数据的方式。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口进行ArrayBuffer相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-arraybuffer.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------------------: | :----------------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -createarraybuffer/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getarraybufferinfo/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -isarraybuffer/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -isdetachedarraybuffer/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/build-profile.json5 deleted file mode 100755 index fb1425aa3a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/build-profile.json5 +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "getarraybufferinfo", - "srcPath": "./getarraybufferinfo", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "isarraybuffer", - "srcPath": "./isarraybuffer", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "isdetachedarraybuffer", - "srcPath": "./isdetachedarraybuffer", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createarraybuffer", - "srcPath": "./createarraybuffer", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/oh-package.json5 deleted file mode 100755 index b60ae4861e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createarraybuffer", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatearraybuffer.so": "file:./src/main/cpp/types/libcreatearraybuffer" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/CMakeLists.txt deleted file mode 100755 index e5d69ce760..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsFive) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createarraybuffer SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createarraybuffer PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/hello.cpp deleted file mode 100755 index 449f21385f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/hello.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_arraybuffer] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_create_arraybuffer] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_arraybuffer] - -// OH_JSVM_CreateArraybuffer的样例方法 -static JSVM_Value CreateArraybuffer(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - JSVM_Value result = nullptr; - // 解析传递的参数 - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - int32_t value; - size_t length; - OH_JSVM_GetValueInt32(env, argv[0], &value); - length = size_t(value); - void *data; - // 创建一个新的ArrayBuffer - JSVM_Status status = OH_JSVM_CreateArraybuffer(env, length, &data, &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateArraybuffer: failed"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateArraybuffer: success"); - OH_LOG_INFO(LOG_APP, "JSVM ArrayBuffer length: %{public}d", length); - } - // 返回创建好的ArrayBuffer - return result; -} -// CreateArraybuffer注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateArraybuffer}, -}; -static JSVM_CallbackStruct *method = param; -// CreateArraybuffer方法别名,供TS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createArraybuffer", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -createArraybuffer(8); -)JS"; -// [End oh_jsvm_create_arraybuffer] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createarraybuffer", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/oh-package.json5 deleted file mode 100755 index a103e5b560..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/cpp/types/libcreatearraybuffer/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatearraybuffer.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/pages/Index.ets deleted file mode 100755 index caada64d53..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatearraybuffer.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/module.json5 deleted file mode 100755 index e7e9dbbb9e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createarraybuffer", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreatearraybufferAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreatearraybufferAbility", - "srcEntry": "./ets/createarraybufferability/CreatearraybufferAbility.ets", - "description": "$string:CreatearraybufferAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreatearraybufferAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/string.json deleted file mode 100755 index 238c217e3e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreatearraybufferAbility_desc", - "value": "description" - }, - { - "name": "CreatearraybufferAbility_label", - "value": "JsvmAboutArraybuffer" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index efccdafb50..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateArraybuffer', 0, async (done: Function) => { - console.log('uitest: TestCreateArraybuffer begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreatearraybufferAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreatearraybufferAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateArraybuffer end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/module.json5 deleted file mode 100755 index a7ac6ba864..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/createarraybuffer/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createarraybuffer_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/oh-package.json5 deleted file mode 100755 index cf14f3f986..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getarraybufferinfo", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetarraybufferinfo.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/CMakeLists.txt deleted file mode 100755 index af0cebc3fb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsFive) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(getarraybufferinfo SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getarraybufferinfo PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/hello.cpp deleted file mode 100755 index e8af36eeb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/hello.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_arraybuffer_info] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_get_arraybuffer_info] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_arraybuffer_info] - -// OH_JSVM_GetArraybufferInfo的样例方法 -static JSVM_Value GetArraybufferInfo(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - // 解析传递的参数 - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 检查参数是否为ArrayBuffer - bool isArrayBuffer = false; - OH_JSVM_IsArraybuffer(env, args[0], &isArrayBuffer); - if (!isArrayBuffer) { - OH_LOG_ERROR(LOG_APP, "JSVM GetArraybufferInfo isArrayBuffer:false"); - } - void *data; - size_t byteLength; - // 获取ArrayBuffer的底层数据缓冲区和长度 - JSVM_Status status = OH_JSVM_GetArraybufferInfo(env, args[0], &data, &byteLength); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetArraybufferInfo: failed"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetArraybufferInfo: success"); - } - return args[0]; -} -// GetArraybufferInfo注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetArraybufferInfo}, -}; -static JSVM_CallbackStruct *method = param; -// GetArraybufferInfo方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getArraybufferInfo", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -getArraybufferInfo(new ArrayBuffer(10)); -)JS"; -// [End oh_jsvm_get_arraybuffer_info] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getarraybufferinfo", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index b5305705ea..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetarraybufferinfo.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/pages/Index.ets deleted file mode 100755 index 7c4cb291d7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetarraybufferinfo.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/module.json5 deleted file mode 100755 index cfe4a3f064..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "getarraybufferinfo", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/string.json deleted file mode 100755 index 1e692e6c95..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmAboutArraybuffer" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 968c88ee64..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetArraybufferInfo', 0, async (done: Function) => { - console.log('uitest: TestGetArraybufferInfo begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetArraybufferInfo end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/module.json5 deleted file mode 100755 index 4a8d6b5d44..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/getarraybufferinfo/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getarraybufferinfo_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/oh-package.json5 deleted file mode 100755 index 6ee87b9f96..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "isarraybuffer", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libisarraybuffer.so": "file:./src/main/cpp/types/libisarraybuffer" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 466812669b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsFive) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(isarraybuffer SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(isarraybuffer PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/hello.cpp deleted file mode 100755 index f80157fc47..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_is_arraybuffer] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_is_arraybuffer] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_is_arraybuffer] - -// OH_JSVM_IsArraybuffer的样例方法 -static JSVM_Value IsArrayBuffer(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 调用OH_JSVM_IsArraybuffer接口判断给定入参是否为ArrayBuffer数据 - bool isArrayBuffer = false; - JSVM_Status status = OH_JSVM_IsArraybuffer(env, args[0], &isArrayBuffer); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM IsArrayBuffer: failed"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM IsArrayBuffer: success"); - OH_LOG_INFO(LOG_APP, "JSVM IsArrayBuffer: %{public}d", isArrayBuffer); - } - JSVM_Value boolean = nullptr; - OH_JSVM_GetBoolean(env, isArrayBuffer, &boolean); - return boolean; -} -// IsArrayBuffer注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = IsArrayBuffer}, -}; -static JSVM_CallbackStruct *method = param; -// IsArrayBuffer方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"isArrayBuffer", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -isArrayBuffer(new ArrayBuffer(8)); -)JS"; -// [End oh_jsvm_is_arraybuffer] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "isarraybuffer", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/oh-package.json5 deleted file mode 100755 index 9a2ed9e1fa..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/cpp/types/libisarraybuffer/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libisarraybuffer.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/pages/Index.ets deleted file mode 100755 index aa30c7724e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libisarraybuffer.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/module.json5 deleted file mode 100755 index 36ef91299a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "isarraybuffer", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "IsarraybufferAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "IsarraybufferAbility", - "srcEntry": "./ets/isarraybufferability/IsarraybufferAbility.ets", - "description": "$string:IsarraybufferAbility_desc", - "icon": "$media:layered_image", - "label": "$string:IsarraybufferAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/string.json deleted file mode 100755 index b915f12904..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "IsarraybufferAbility_desc", - "value": "description" - }, - { - "name": "IsarraybufferAbility_label", - "value": "JsvmAboutArraybuffer" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 5a93f6e730..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testIsArraybuffer', 0, async (done: Function) => { - console.log('uitest: TestIsArraybuffer begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'IsarraybufferAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('IsarraybufferAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestIsArraybuffer end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/module.json5 deleted file mode 100755 index 882df228c3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isarraybuffer/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "isarraybuffer_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/oh-package.json5 deleted file mode 100755 index 092dfbf9c6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "isdetachedarraybuffer", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libisdetachedarraybuffer.so": "file:./src/main/cpp/types/libisdetachedarraybuffer" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 9e883e92c1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsFive) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(isdetachedarraybuffer SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(isdetachedarraybuffer PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/hello.cpp deleted file mode 100755 index bbb0ebfec9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/hello.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_is_detached_arraybuffer] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_is_detached_arraybuffer] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_is_detached_arraybuffer] - -// OH_JSVM_DetachArraybuffer、OH_JSVM_IsDetachedArraybuffer的样例方法 -static JSVM_Value DetachArraybuffer(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - JSVM_Value arraybuffer = args[0]; - JSVM_Status status = OH_JSVM_DetachArraybuffer(env, arraybuffer); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM DetachArraybuffer: failed"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM DetachArraybuffer: success"); - } - return arraybuffer; -} -static JSVM_Value IsDetachedArraybuffer(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - JSVM_Value arraybuffer = args[0]; - OH_JSVM_DetachArraybuffer(env, arraybuffer); - bool result = false; - JSVM_Status status = OH_JSVM_IsDetachedArraybuffer(env, arraybuffer, &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM IsDetachedArraybuffer: failed"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM IsDetachedArraybuffer: success"); - OH_LOG_INFO(LOG_APP, "JSVM IsArrayBuffer: %{public}d", result); - } - JSVM_Value isDetached = nullptr; - OH_JSVM_GetBoolean(env, result, &isDetached); - return isDetached; -} -// DetachArraybuffer、IsDetachedArraybuffer注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = DetachArraybuffer}, - {.data = nullptr, .callback = IsDetachedArraybuffer}, -}; -static JSVM_CallbackStruct *method = param; -// DetachArraybuffer、IsDetachedArraybuffer方法别名,TS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"detachArraybuffer", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, - {"isDetachedArraybuffer", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( -let arrayBuffer = new ArrayBuffer(10); -detachArraybuffer(arrayBuffer); -isDetachedArraybuffer(arrayBuffer); -)JS"; -// [End oh_jsvm_is_detached_arraybuffer] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "isdetachedarraybuffer", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/oh-package.json5 deleted file mode 100755 index 31a656a2e7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/cpp/types/libisdetachedarraybuffer/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libisdetachedarraybuffer.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/pages/Index.ets deleted file mode 100755 index 4e614955a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libisdetachedarraybuffer.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/module.json5 deleted file mode 100755 index aef2750cb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "isdetachedarraybuffer", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "IsdetachedarraybufferAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "IsdetachedarraybufferAbility", - "srcEntry": "./ets/isdetachedarraybufferability/IsdetachedarraybufferAbility.ets", - "description": "$string:IsdetachedarraybufferAbility_desc", - "icon": "$media:layered_image", - "label": "$string:IsdetachedarraybufferAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/string.json deleted file mode 100755 index 90d9dedcda..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "IsdetachedarraybufferAbility_desc", - "value": "description" - }, - { - "name": "IsdetachedarraybufferAbility_label", - "value": "JsvmAboutArraybuffer" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 0ba626d6a6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testIsDetachedArraybuffer', 0, async (done: Function) => { - console.log('uitest: TestIsDetachedArraybuffer begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'IsdetachedarraybufferAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('IsdetachedarraybufferAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestIsDetachedArraybuffer end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/module.json5 deleted file mode 100755 index c2f3415f60..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/isdetachedarraybuffer/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "isdetachedarraybuffer_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/ohosTest.md deleted file mode 100755 index 4694515986..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutArraybuffer/ohosTest.md +++ /dev/null @@ -1,11 +0,0 @@ -# JsvmAboutArraybuffer 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 创建一个指定大小的 ArrayBuffer 对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 检索 ArrayBuffer 的底层数据缓冲区及其长度 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 判断一个 JavaScript 对象是否为 ArrayBuffer 类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 检查给定的 ArrayBuffer 是否已被分离(detached) | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/app.json5 deleted file mode 100755 index 6f47fb9017..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmaboutbigint", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/element/string.json deleted file mode 100755 index 2b02ed2259..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmAboutBigint" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/README.md deleted file mode 100755 index 63b4751b25..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/README.md +++ /dev/null @@ -1,173 +0,0 @@ -# ArkTS使用JSVM-API接口操作bigint类型值 - -### 介绍 - -BigInt是JavaScript中用于表示任意精度整数的数据类型,它能够处理比Number类型更大范围的整数值。通过JSVM-API提供的接口,可以在JSVM模块中创建、获取和操作BigInt类型值,从而实现与BigInt相关的功能扩展。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口操作bigint类型值](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-bigint.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :-----------------------------------------------------------------: | :-----------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -createbigintint64/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createbigintuint64/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createbigintwords/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvaluebigintint64/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvaluebigintuint64/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvaluebigintwords/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/build-profile.json5 deleted file mode 100755 index 1e50db2443..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/build-profile.json5 +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "getvaluebigintwords", - "srcPath": "./getvaluebigintwords", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createbigintwords", - "srcPath": "./createbigintwords", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createbigintuint64", - "srcPath": "./createbigintuint64", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getvaluebigintuint64", - "srcPath": "./getvaluebigintuint64", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createbigintint64", - "srcPath": "./createbigintint64", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getvaluebigintint64", - "srcPath": "./getvaluebigintint64", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/oh-package.json5 deleted file mode 100755 index 92a4bca939..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createbigintint64", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatebigintint64.so": "file:./src/main/cpp/types/libcreatebigintint64" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/CMakeLists.txt deleted file mode 100755 index d22b827470..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createbigintint64 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createbigintint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/hello.cpp deleted file mode 100755 index 113a5ae258..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/hello.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_bigint_int64] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_create_bigint_int64] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_bigint_int64] - -// 声明int64_t的变量value -static int64_t g_testValueDemo = -5555555555555555555; -// OH_JSVM_CreateBigintInt64的样例方法 -static JSVM_Value CreateBigintInt64(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_Value returnValue = nullptr; - JSVM_Status status = OH_JSVM_CreateBigintInt64(env, g_testValueDemo, &returnValue); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CreateBigintInt64 fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CreateBigintInt64 success"); - } - return returnValue; -} -// CreateBigintInt64注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateBigintInt64}, -}; -static JSVM_CallbackStruct *method = param; -// CreateBigintInt64方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createBigintInt64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(createBigintInt64())JS"; -// [End oh_jsvm_create_bigint_int64] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createbigintint64", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/oh-package.json5 deleted file mode 100755 index fdb5a8211d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/cpp/types/libcreatebigintint64/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatebigintint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/pages/Index.ets deleted file mode 100755 index 8992c78422..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatebigintint64.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/module.json5 deleted file mode 100755 index af0e3d8c4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createbigintint64", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Createbigintint64Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Createbigintint64Ability", - "srcEntry": "./ets/createbigintint64ability/Createbigintint64Ability.ets", - "description": "$string:Createbigintint64Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Createbigintint64Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/string.json deleted file mode 100755 index 6f8e92b416..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Createbigintint64Ability_desc", - "value": "description" - }, - { - "name": "Createbigintint64Ability_label", - "value": "JsvmAboutBigint" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index b939d7ce06..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateBigintInt64', 0, async (done: Function) => { - console.log('uitest: TestCreateBigintInt64 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Createbigintint64Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Createbigintint64Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateBigintInt64 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/module.json5 deleted file mode 100755 index b2d5ceed63..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintint64/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createbigintint64_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/oh-package.json5 deleted file mode 100755 index 87d61adb9d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createbigintuint64", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatebigintuint64.so": "file:./src/main/cpp/types/libcreatebigintuint64" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 38af960d61..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsSix) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createbigintuint64 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createbigintuint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/hello.cpp deleted file mode 100755 index 26640be625..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/hello.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_bigint_uint64] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_create_bigint_uint64] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_bigint_uint64] - -// 声明uint64_t的变量value -static uint64_t g_testValue = 5555555555555555555; -// OH_JSVM_CreateBigintUint64的样例方法 -static JSVM_Value CreateBigintUint64(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 将value转化为JSVM_Value类型返回 - JSVM_Value returnValue = nullptr; - JSVM_Status status = OH_JSVM_CreateBigintUint64(env, g_testValue, &returnValue); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CreateBigintUint64 fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CreateBigintUint64 success"); - } - return returnValue; -} -// CreateBigintUint64注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateBigintUint64}, -}; -static JSVM_CallbackStruct *method = param; -// CreateBigintUint64方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createBigintUint64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(createBigintUint64())JS"; -// [End oh_jsvm_create_bigint_uint64] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createbigintuint64", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/oh-package.json5 deleted file mode 100755 index 088b2dfe01..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/cpp/types/libcreatebigintuint64/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatebigintuint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/pages/Index.ets deleted file mode 100755 index 78544b5aa9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatebigintuint64.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/module.json5 deleted file mode 100755 index 28da694d72..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createbigintuint64", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Createbigintuint64Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Createbigintuint64Ability", - "srcEntry": "./ets/createbigintuint64ability/Createbigintuint64Ability.ets", - "description": "$string:Createbigintuint64Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Createbigintuint64Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/string.json deleted file mode 100755 index e057632eb6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Createbigintuint64Ability_desc", - "value": "description" - }, - { - "name": "Createbigintuint64Ability_label", - "value": "JsvmAboutBigint" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 4c80c81976..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateBigintUint64', 0, async (done: Function) => { - console.log('uitest: TestCreateBigintUint64 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Createbigintuint64Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Createbigintuint64Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateBigintUint64 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/module.json5 deleted file mode 100755 index 465522865f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintuint64/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createbigintuint64_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/oh-package.json5 deleted file mode 100755 index 18dc047ed6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createbigintwords", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatebigintwords.so": "file:./src/main/cpp/types/libcreatebigintwords" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/CMakeLists.txt deleted file mode 100755 index af39e3ec98..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsSix) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createbigintwords SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createbigintwords PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/hello.cpp deleted file mode 100755 index b66ede418b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/hello.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_bigint_words] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_create_bigint_words] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_bigint_words] - -// OH_JSVM_CreateBigintWords的样例方法 -static int g_diffValueThree = 3; -static JSVM_Value CreateBigintWords(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 使用OH_JSVM_CreateBigintWords接口创建一个BigInt对象 - int signBit = 0; - size_t wordCount = g_diffValueThree; - uint64_t words[] = {12ULL, 34ULL, 56ULL}; - JSVM_Value returnValue = nullptr; - JSVM_Status status = OH_JSVM_CreateBigintWords(env, signBit, wordCount, words, &returnValue); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CreateBigintWords fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CreateBigintWords success"); - } - return returnValue; -} -// CreateBigintWords注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateBigintWords}, -}; -static JSVM_CallbackStruct *method = param; -// CreateBigintWords方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createBigintWords", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(createBigintWords())JS"; -// [EndExclude oh_jsvm_create_bigint_words] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createbigintwords", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/oh-package.json5 deleted file mode 100755 index 6076c74a8f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/cpp/types/libcreatebigintwords/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatebigintwords.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/pages/Index.ets deleted file mode 100755 index b41ea33b63..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatebigintwords.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/module.json5 deleted file mode 100755 index 873f21cc0e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createbigintwords", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreatebigintwordsAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreatebigintwordsAbility", - "srcEntry": "./ets/createbigintwordsability/CreatebigintwordsAbility.ets", - "description": "$string:CreatebigintwordsAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreatebigintwordsAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/string.json deleted file mode 100755 index bfc445306b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreatebigintwordsAbility_desc", - "value": "description" - }, - { - "name": "CreatebigintwordsAbility_label", - "value": "JsvmAboutBigint" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index ed20536c53..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateBigintWords', 0, async (done: Function) => { - console.log('uitest: TestCreateBigintWords begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreatebigintwordsAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreatebigintwordsAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateBigintWords end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/module.json5 deleted file mode 100755 index a1b15147e6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/createbigintwords/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createbigintwords_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/oh-package.json5 deleted file mode 100755 index 3caa8c90f8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvaluebigintint64", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvaluebigintint64.so": "file:./src/main/cpp/types/libgetvaluebigintint64" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 29b45613e4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getvaluebigintint64 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvaluebigintint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/hello.cpp deleted file mode 100755 index da556acb02..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_bigint_int64] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_get_value_bigint_int64] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_bigint_int64] - -// OH_JSVM_GetValueBigintInt64的样例方法 -static JSVM_Value GetBigintInt64(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 从传入的参数中提取64位整数的BigInt数据 - int64_t value; - bool lossLess; - OH_JSVM_GetValueBigintInt64(env, args[0], &value, &lossLess); - // 判断从JS侧获取bigint是否为无损转换,如果不是抛出异常 - if (!lossLess) { - OH_JSVM_ThrowError(env, nullptr, "BigInt values have no lossless converted"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetBigintInt64 success:%{public}d", lossLess); - } - JSVM_Value returnValue = nullptr; - OH_JSVM_CreateBigintInt64(env, value, &returnValue); - return returnValue; -} -// GetBigintInt64注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetBigintInt64}, -}; -static JSVM_CallbackStruct *method = param; -// GetBigintInt64方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getBigintInt64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(getBigintInt64(BigInt(-5555555555555555)))JS"; -// [End oh_jsvm_get_value_bigint_int64] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvaluebigintint64", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/oh-package.json5 deleted file mode 100755 index ddd0695d32..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/cpp/types/libgetvaluebigintint64/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvaluebigintint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/pages/Index.ets deleted file mode 100755 index 6d63a3a7f9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvaluebigintint64.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/module.json5 deleted file mode 100755 index 7b4e39aaf6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getvaluebigintint64", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Getvaluebigintint64Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Getvaluebigintint64Ability", - "srcEntry": "./ets/getvaluebigintint64ability/Getvaluebigintint64Ability.ets", - "description": "$string:Getvaluebigintint64Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Getvaluebigintint64Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/string.json deleted file mode 100755 index 69b8e9e8e6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Getvaluebigintint64Ability_desc", - "value": "description" - }, - { - "name": "Getvaluebigintint64Ability_label", - "value": "JsvmAboutBigint" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 33f4b1bcd3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueBigintInt64', 0, async (done: Function) => { - console.log('uitest: TestGetValueBigintInt64 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Getvaluebigintint64Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Getvaluebigintint64Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueBigintInt64 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/module.json5 deleted file mode 100755 index fa0d11ffb3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintint64/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvaluebigintint64_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/oh-package.json5 deleted file mode 100755 index c0b9bf1800..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvaluebigintuint64", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvaluebigintuint64.so": "file:./src/main/cpp/types/libgetvaluebigintuint64" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/CMakeLists.txt deleted file mode 100755 index c3e6c71d98..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getvaluebigintuint64 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvaluebigintuint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/hello.cpp deleted file mode 100755 index 8ffb85d058..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_bigint_uint64] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_get_value_bigint_uint64] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_bigint_uint64] - -// OH_JSVM_GetValueBigintUint64的样例方法 -static JSVM_Value GetValueBigintUint64(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 从参数值中获取BigInt的数值 - uint64_t value = 0; - bool lossLess = false; - OH_JSVM_GetValueBigintUint64(env, args[0], &value, &lossLess); - // 判断从JS侧获取bigint是否为无损转换,如果不是抛出异常 - if (!lossLess) { - OH_JSVM_ThrowError(env, nullptr, "BigInt values have no lossless converted"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetValueBigintUint64 success:%{public}d", lossLess); - } - JSVM_Value returnValue = nullptr; - OH_JSVM_CreateBigintUint64(env, value, &returnValue); - return returnValue; -} -// GetValueBigintUint64注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetValueBigintUint64}, -}; -static JSVM_CallbackStruct *method = param; -// GetValueBigintUint64方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getValueBigintUint64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(getValueBigintUint64(BigInt(5555555555555555)))JS"; -// [End oh_jsvm_get_value_bigint_uint64] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvaluebigintuint64", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/oh-package.json5 deleted file mode 100755 index cde1660770..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/cpp/types/libgetvaluebigintuint64/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvaluebigintuint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/pages/Index.ets deleted file mode 100755 index 25cabb17b2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvaluebigintuint64.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/module.json5 deleted file mode 100755 index 0fc31b23ee..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getvaluebigintuint64", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Getvaluebigintuint64Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Getvaluebigintuint64Ability", - "srcEntry": "./ets/getvaluebigintuint64ability/Getvaluebigintuint64Ability.ets", - "description": "$string:Getvaluebigintuint64Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Getvaluebigintuint64Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/string.json deleted file mode 100755 index abf5fdc5e9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Getvaluebigintuint64Ability_desc", - "value": "description" - }, - { - "name": "Getvaluebigintuint64Ability_label", - "value": "JsvmAboutBigint" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 51b5a5b06c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueBigintUint64', 0, async (done: Function) => { - console.log('uitest: TestGetValueBigintUint64 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Getvaluebigintuint64Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Getvaluebigintuint64Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueBigintUint64 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/module.json5 deleted file mode 100755 index 36a09b2ba6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintuint64/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvaluebigintuint64_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/oh-package.json5 deleted file mode 100755 index c5d26d5634..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvaluebigintwords", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvaluebigintwords.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 9fa94ef3a7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsSix) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(getvaluebigintwords SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvaluebigintwords PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/hello.cpp deleted file mode 100755 index 91c1992fbb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/hello.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_bigint_words] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" -#include -// [StartExclude oh_jsvm_get_value_bigint_words] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" -#define MAX_MALLOC_SIZE 0x800000 - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_bigint_words] - -// OH_JSVM_GetValueBigintWords的样例方法 -static JSVM_Value GetValueBigintWords(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - int signBit = 0; - size_t wordCount = 0; - uint64_t* words{nullptr}; - // 调用OH_JSVM_GetValueBigintWords接口获取wordCount - JSVM_Status status = OH_JSVM_GetValueBigintWords(env, args[0], nullptr, &wordCount, nullptr); - OH_LOG_INFO(LOG_APP, "OH_JSVM_GetValueBigintWords wordCount:%{public}d.", wordCount); - if (wordCount == 0 || wordCount > SOME_REASONABLE_MAX) { - OH_LOG_ERROR(LOG_APP, "Invalid wordCount: %{public}zu", wordCount); - return nullptr; - } - words = (uint64_t*)malloc(wordCount*sizeof(uint64_t)); - if (words == nullptr) { - OH_LOG_ERROR(LOG_APP, "OH_JSVM_GetValueBigintWords malloc failed."); - return nullptr; - } - // 调用OH_JSVM_GetValueBigintWords接口获取传入bigInt相关信息,如:signBit传入bigInt正负信息 - status = OH_JSVM_GetValueBigintWords(env, args[0], &signBit, &wordCount, words); - free(words); - words = nullptr; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "OH_JSVM_GetValueBigintWords fail, status:%{public}d.", status); - } else { - OH_LOG_INFO(LOG_APP, "OH_JSVM_GetValueBigintWords signBit: %{public}d.", signBit); - } - // 将符号位转化为int类型传出去 - JSVM_Value returnValue = nullptr; - OH_JSVM_CreateInt32(env, signBit, &returnValue); - return returnValue; -} -// GetValueBigintWords注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetValueBigintWords}, -}; -static JSVM_CallbackStruct *method = param; -// GetValueBigintWords方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getValueBigintWords", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(getValueBigintWords(BigInt(5555555555555555)))JS"; -// [End oh_jsvm_get_value_bigint_words] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvaluebigintwords", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index c982cc057c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvaluebigintwords.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/pages/Index.ets deleted file mode 100755 index 7aae1b4697..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvaluebigintwords.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/module.json5 deleted file mode 100755 index 2ed4f63667..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "getvaluebigintwords", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/string.json deleted file mode 100755 index 6c46470373..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmAboutBigint" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 7548b34b75..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueBigintWords', 0, async (done: Function) => { - console.log('uitest: TestGetValueBigintWords begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueBigintWords end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/module.json5 deleted file mode 100755 index 0161218335..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/getvaluebigintwords/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvaluebigintwords_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/ohosTest.md deleted file mode 100755 index cde850b057..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutBigint/ohosTest.md +++ /dev/null @@ -1,13 +0,0 @@ -# JsvmAboutBigint 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 将C int64_t类型的值转换为JavaScript BigInt类型 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 将C uint64_t类型的值转换为JavaScript BigInt类型 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 将一组无符号64位字转换为单个BigInt值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 返回给定JavaScript BigInt的C int64_t基础类型等价值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 返回给定JavaScript BigInt的C uint64_t基础类型等价值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 将单个BigInt值转换为一个符号位、一个64位的小端数组和该数组的长度 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/app.json5 deleted file mode 100755 index 0351d86ed7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmaboutclass", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/element/string.json deleted file mode 100755 index c702a3d2a5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmAboutClass" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/README.md deleted file mode 100755 index 39235c3b64..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/README.md +++ /dev/null @@ -1,113 +0,0 @@ -# ArkTS使用JSVM接口进行class相关开发 - -### 介绍 - -使用JSVM-API接口进行class相关开发,处理JavaScript中的类,例如定义类、构造实例等。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM进行class相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-class.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -|:------------------------------------------------------------------:|:------------------------------------------------------------------:| -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -defineclass/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -newinstance/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -removewrap/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/build-profile.json5 deleted file mode 100755 index 31b64e85fc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/build-profile.json5 +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "newinstance", - "srcPath": "./newinstance", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "defineclass", - "srcPath": "./defineclass", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "removewrap", - "srcPath": "./removewrap", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/oh-package.json5 deleted file mode 100755 index 81dff615f8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "defineclass", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libdefineclass.so": "file:./src/main/cpp/types/libdefineclass" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/CMakeLists.txt deleted file mode 100755 index d4e489efa7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutClass) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(defineclass SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(defineclass PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/hello.cpp deleted file mode 100755 index d12f29d611..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/hello.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" -// [Start oh_jsvm_defineclass] -#include -// [StartExclude oh_jsvm_defineclass] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_defineclass] - -JSVM_Value CreateInstance(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_Value newTarget; - // 获取构造函数的new.target值 - JSVM_CALL(OH_JSVM_GetNewTarget(env, info, &newTarget)); - OH_LOG_INFO(LOG_APP, "Create Instance"); - OH_LOG_INFO(LOG_APP, - "NAPI MyObject::New %{public}s", - newTarget != nullptr ? "newTarget != nullptr" : "newTarget == nullptr"); - JSVM_Value jsObject = nullptr; - JSVM_CALL(OH_JSVM_CreateObject(env, &jsObject)); - JSVM_Value jsName = nullptr; - JSVM_CALL(OH_JSVM_CreateStringUtf8(env, "name", JSVM_AUTO_LENGTH, &jsName)); - JSVM_Value jsValue = nullptr; - JSVM_CALL(OH_JSVM_CreateStringUtf8(env, "lilei", JSVM_AUTO_LENGTH, &jsValue)); - JSVM_CALL(OH_JSVM_SetProperty(env, jsObject, jsName, jsValue)); - return jsObject; -} - -std::string ToString(JSVM_Env env, JSVM_Value val) -{ - JSVM_Value jsonString; - JSVM_CALL(OH_JSVM_JsonStringify(env, val, &jsonString)); - size_t totalLen = 0; - JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, nullptr, 0, &totalLen)); - size_t needLen = totalLen + 1; - char* buff = new char[needLen]; - std::memset(buff, 0, needLen); - JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, buff, needLen, &totalLen)); - std::string str(buff); - delete[] buff; - return str; -} - -// 封装c++中的自定义数据结构 -JSVM_Value DefineClass(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_CallbackStruct param; - param.data = nullptr; - param.callback = CreateInstance; - JSVM_Value cons; - // 用于在JavaScript中定义一个类 - JSVM_CALL(OH_JSVM_DefineClass(env, "MyObject", JSVM_AUTO_LENGTH, ¶m, 0, nullptr, &cons)); - JSVM_Value instanceValue = nullptr; - // 作为class的构造函数调用 - JSVM_CALL(OH_JSVM_NewInstance(env, cons, 0, nullptr, &instanceValue)); - std::string str = ToString(env, instanceValue); - OH_LOG_INFO(LOG_APP, "NewInstance:%{public}s", str.c_str()); - - // 作为普通的函数调用 - JSVM_Value global; - JSVM_CALL(OH_JSVM_GetGlobal(env, &global)); - JSVM_Value key; - JSVM_CALL(OH_JSVM_CreateStringUtf8(env, "Constructor", JSVM_AUTO_LENGTH, &key)); - JSVM_CALL(OH_JSVM_SetProperty(env, global, key, cons)); - JSVM_Value result; - JSVM_CALL(OH_JSVM_CallFunction(env, global, cons, 0, nullptr, &result)); - std::string buf = ToString(env, result); - OH_LOG_INFO(LOG_APP, "NewInstance:%{public}s", buf.c_str()); - return nullptr; -} - -// 注册DefineClass的方法 -JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = DefineClass}, -}; - -static JSVM_CallbackStruct *method = param; - -// DefineClass方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"defineClass", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// [End oh_jsvm_defineclass] - -const char *SRC_CALL_NATIVE = R"JS( defineClass(); )JS"; - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "defineclass", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/oh-package.json5 deleted file mode 100755 index d6f41bb534..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/cpp/types/libdefineclass/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libdefineclass.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/pages/Index.ets deleted file mode 100755 index 9038232de9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libdefineclass.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/module.json5 deleted file mode 100755 index ec48d787bc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "defineclass", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "DefineclassAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "DefineclassAbility", - "srcEntry": "./ets/defineclassability/DefineclassAbility.ets", - "description": "$string:DefineclassAbility_desc", - "icon": "$media:layered_image", - "label": "$string:DefineclassAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/module.json5 deleted file mode 100755 index d4e8cded06..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/defineclass/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "defineclass_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/oh-package.json5 deleted file mode 100755 index aa232b1285..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "newinstance", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libnewinstance.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 30433259d4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutClass) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(newinstance SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(newinstance PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/hello.cpp deleted file mode 100755 index 6cf85832d0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/hello.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" -// [Start oh_jsvm_newinstance] -#include -// [StartExclude oh_jsvm_newinstance] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_newinstance] - -std::string ToString(JSVM_Env env, JSVM_Value val) -{ - JSVM_Value jsonString; - JSVM_CALL(OH_JSVM_JsonStringify(env, val, &jsonString)); - size_t totalLen = 0; - JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, nullptr, 0, &totalLen)); - size_t needLen = totalLen + 1; - char* buff = new char[needLen]; - std::memset(buff, 0, needLen); - JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, buff, needLen, &totalLen)); - std::string str(buff); - delete[] buff; - return str; -} - -// OH_JSVM_NewInstance的样例方法 -static JSVM_Value NewInstance(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取js侧传入的两个参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr)); - JSVM_Value result = nullptr; - // 调用OH_JSVM_NewInstance接口,实例化一个对象,将这个对象返回 - JSVM_CALL(OH_JSVM_NewInstance(env, args[0], 1, &args[1], &result)); - std::string str = ToString(env, result); - OH_LOG_INFO(LOG_APP, "NewInstance:%{public}s", str.c_str()); - return nullptr; -} - -// 通过给定的构造函数,构建一个实例。 -// NewInstance注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = NewInstance}, -}; - -static JSVM_CallbackStruct *method = param; - -// NewInstance方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"newInstance", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// [End oh_jsvm_newinstance] - -const char *SRC_CALL_NATIVE = R"JS( function Fruit(name) { this.name = name; } newInstance(Fruit, "apple"); )JS"; - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "newinstance", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index d5493ca971..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libnewinstance.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/pages/Index.ets deleted file mode 100755 index b14cc2db21..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libnewinstance.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/module.json5 deleted file mode 100755 index 031e8f89eb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "newinstance", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/module.json5 deleted file mode 100755 index 0871f6c08f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/newinstance/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "newinstance_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/ohosTest.md deleted file mode 100755 index 0eea433059..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/ohosTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# JsvmAboutClass 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -|------------------------------------| ------------ |------------------------| ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 在JavaScript中定义一个类,并与对应的C类进行封装和交互 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 通过给定的构造函数,构建一个实例 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 解包先前封装在JavaScript对象中的原生实例并释放封装 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/oh-package.json5 deleted file mode 100755 index 9db3e411de..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "removewrap", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libremovewrap.so": "file:./src/main/cpp/types/libremovewrap" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/CMakeLists.txt deleted file mode 100755 index ecd841228b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutClass) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(removewrap SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(removewrap PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/hello.cpp deleted file mode 100755 index b5875b48b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/hello.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" -// [Start oh_jsvm_removewrap] -#include -// [StartExclude oh_jsvm_removewrap] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_removewrap] - -// OH_JSVM_GetNewTarget、OH_JSVM_DefineClass、OH_JSVM_Wrap、OH_JSVM_Unwrap、OH_JSVM_RemoveWrap的样例方法 - -// 自定义类结构体Object -struct Object { - std::string name; - int32_t age; -}; - -// 定义一个回调函数 -static void DerefItem(JSVM_Env env, void *data, void *hint) -{ - OH_LOG_INFO(LOG_APP, "JSVM deref_item"); - (void)hint; -} - -static JSVM_Value WrapObject(JSVM_Env env, JSVM_CallbackInfo info) -{ - OH_LOG_INFO(LOG_APP, "JSVM wrap"); - Object obj; - // 设置Object属性 - obj.name = "lilei"; - const int adultAge = 18; - obj.age = adultAge; - Object *objPointer = &obj; - // 获取回调信息中的参数数量和将要被封装的值 - size_t argc = 1; - JSVM_Value toWrap = nullptr; - JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, &toWrap, nullptr, nullptr)); - // OH_JSVM_Wrap将自定义结构Object进行封装 - JSVM_CALL(OH_JSVM_Wrap(env, toWrap, reinterpret_cast(objPointer), DerefItem, NULL, NULL)); - Object *data; - // OH_JSVM_UnWrap解包先前封装在JavaScript对象中的原生实例 - JSVM_CALL(OH_JSVM_Unwrap(env, toWrap, reinterpret_cast(&data))); - OH_LOG_INFO(LOG_APP, "JSVM name: %{public}s", data->name.c_str()); - OH_LOG_INFO(LOG_APP, "JSVM age: %{public}d", data->age); - return nullptr; -} - -static JSVM_Value RemoveWrap(JSVM_Env env, JSVM_CallbackInfo info) -{ - OH_LOG_INFO(LOG_APP, "JSVM removeWrap"); - Object obj; - // 设置Object属性 - obj.name = "lilei"; - const int adultAge = 18; - obj.age = adultAge; - Object *objPointer = &obj; - // 获取回调信息中的参数数量和将要被封装的值 - size_t argc = 1; - JSVM_Value toWrap = nullptr; - JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, &toWrap, nullptr, nullptr)); - // 将自定义结构Object封装 - JSVM_CALL(OH_JSVM_Wrap(env, toWrap, reinterpret_cast(objPointer), DerefItem, NULL, NULL)); - Object *data; - // 解包先前封装的object,并移除封装 - JSVM_CALL(OH_JSVM_RemoveWrap(env, toWrap, reinterpret_cast(&objPointer))); - // 检查是否已被移除 - JSVM_Status status = OH_JSVM_Unwrap(env, toWrap, reinterpret_cast(&data)); - if (status != JSVM_OK) { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_RemoveWrap success"); - } - return nullptr; -} - -// WrapObject、RemoveWrap注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = WrapObject}, - {.data = nullptr, .callback = RemoveWrap}, -}; -static JSVM_CallbackStruct *method = param; -// WrapObject、RemoveWrap方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"wrapObject", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, - {"removeWrap", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// [End oh_jsvm_removewrap] - -const char *SRC_CALL_NATIVE = R"JS( class Obj {}; wrapObject(new Obj()); removeWrap(new Obj()); )JS"; - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "removewrap", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/oh-package.json5 deleted file mode 100755 index 3907e7f0b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/cpp/types/libremovewrap/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libremovewrap.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/pages/Index.ets deleted file mode 100755 index 923196f81b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libremovewrap.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/module.json5 deleted file mode 100755 index 3df97ea0c1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "removewrap", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "RemovewrapAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "RemovewrapAbility", - "srcEntry": "./ets/removewrapability/RemovewrapAbility.ets", - "description": "$string:RemovewrapAbility_desc", - "icon": "$media:layered_image", - "label": "$string:RemovewrapAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/module.json5 deleted file mode 100755 index 21f6f9895d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutClass/removewrap/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "removewrap_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/app.json5 deleted file mode 100755 index 9461965784..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmaboutdate", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/element/string.json deleted file mode 100755 index 4c140066d6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmAboutDate" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/README.md deleted file mode 100755 index 052e3de06d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/README.md +++ /dev/null @@ -1,113 +0,0 @@ -# ArkTS使用JSVM-API接口进行Date相关开发 - -### 介绍 - -JSVM-API中date相关接口用于处理JavaScript Date对象,并在JSVM模块和JavaScript代码之间进行日期数据的转换和处理。这对于在JSVM模块中处理时间和日期相关逻辑非常有用。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口进行Date相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-date.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :---------------------------------------------------------------: | :---------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -createdate/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getdatevalue/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -isdate/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/build-profile.json5 deleted file mode 100755 index f21d0c342c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/build-profile.json5 +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "createdate", - "srcPath": "./createdate", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getdatevalue", - "srcPath": "./getdatevalue", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "isdate", - "srcPath": "./isdate", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/oh-package.json5 deleted file mode 100755 index ba430b1725..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createdate", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatedate.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/CMakeLists.txt deleted file mode 100755 index b767168144..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutDate) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createdate SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createdate PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/hello.cpp deleted file mode 100755 index 9f3162b40b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/hello.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_date] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" -#include -// [StartExclude oh_jsvm_create_date] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_date] - -// OH_JSVM_CreateDate的样例方法 -static JSVM_Value CreateDate(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 通过c接口获取Unix纪元以来经过的秒数,并转化为毫秒数为单位 - double value = static_cast(time(nullptr) * 1000); - // 调用OH_JSVM_CreateDate接口将double值转换成表示日期时间的JavaScript值返回出去 - JSVM_Value returnValue = nullptr; - - JSVM_CALL(OH_JSVM_CreateDate(env, value, &returnValue)); - - bool isDate; - JSVM_CALL(OH_JSVM_IsDate(env, returnValue, &isDate)); - if (isDate == false) { - OH_LOG_ERROR(LOG_APP, "JSVM IsDate fail"); - return returnValue; - } - - value = 0; - JSVM_CALL(OH_JSVM_GetDateValue(env, returnValue, &value)); - - uint64_t time = static_cast(value) / 1000; - char *date = ctime(reinterpret_cast(&time)); - OH_LOG_INFO(LOG_APP, "JSVM CreateDate success:%{public}s", date); - - return returnValue; -} - -// CreateDate注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateDate}, -}; -static JSVM_CallbackStruct *method = param; -// CreateDate方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createDate", nullptr, method, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(createDate())JS"; -// [End oh_jsvm_create_date] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createdate", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index ecdf0a0890..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatedate.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/pages/Index.ets deleted file mode 100755 index 49705bc91e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatedate.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/module.json5 deleted file mode 100755 index 4fe8e8a71b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "createdate", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/string.json deleted file mode 100755 index 7c277b0d71..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmAboutDate" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 33f66ded20..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateDate', 0, async (done: Function) => { - console.log('uitest: TestCreateDate begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateDate end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/module.json5 deleted file mode 100755 index 479fba6ab5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/createdate/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createdate_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/oh-package.json5 deleted file mode 100755 index 131758b389..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getdatevalue", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetdatevalue.so": "file:./src/main/cpp/types/libgetdatevalue" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 25203265ca..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutDate) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(getdatevalue SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getdatevalue PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/hello.cpp deleted file mode 100755 index ea80d807e3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" -// [Stat oh_jsvm_get_date_value] -#include -// [StartExclude oh_jsvm_get_date_value] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_date_value] - -// OH_JSVM_GetDateValue的样例方法 -static JSVM_Value GetDateValue(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr)); - // 获取传入的Unix Time Stamp时间 - double value; - JSVM_CALL(OH_JSVM_GetDateValue(env, args[0], &value)); - - // 将获取到的Unix Time Stamp时间转化为日期字符串打印 - uint64_t time = static_cast(value) / 1000; - char *date = ctime(reinterpret_cast(&time)); - OH_LOG_INFO(LOG_APP, "JSVM GetDateValue success:%{public}s", date); - - JSVM_Value returnValue = nullptr; - JSVM_CALL(OH_JSVM_CreateDouble(env, value, &returnValue)); - return returnValue; -} - -// CreateDate注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetDateValue}, -}; -static JSVM_CallbackStruct *method = param; -// CreateDate方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getDateValue", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(getDateValue(new Date(Date.now())))JS"; -// [End oh_jsvm_get_date_value] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getdatevalue", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/oh-package.json5 deleted file mode 100755 index 60b9e733b7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/cpp/types/libgetdatevalue/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetdatevalue.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/pages/Index.ets deleted file mode 100755 index e640483145..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetdatevalue.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/module.json5 deleted file mode 100755 index 57141d1fcd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getdatevalue", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetdatevalueAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetdatevalueAbility", - "srcEntry": "./ets/getdatevalueability/GetdatevalueAbility.ets", - "description": "$string:GetdatevalueAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetdatevalueAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/string.json deleted file mode 100755 index 9bc8a91530..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetdatevalueAbility_desc", - "value": "description" - }, - { - "name": "GetdatevalueAbility_label", - "value": "JsvmAboutDate" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 5c01d454c9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetDateValue', 0, async (done: Function) => { - console.log('uitest: TestGetDateValue begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetdatevalueAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetdatevalueAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetDateValue end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/module.json5 deleted file mode 100755 index a6d1eaeb4f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/getdatevalue/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getdatevalue_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/oh-package.json5 deleted file mode 100755 index 044f1e59f0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "isdate", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libisdate.so": "file:./src/main/cpp/types/libisdate" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 0759422fb2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutDate) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(isdate SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(isdate PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/hello.cpp deleted file mode 100755 index 97281822a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/hello.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_is_date] -// OH_JSVM_IsDate的样例方法 -static JSVM_Value IsDate(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr)); - bool isData; - JSVM_CALL(OH_JSVM_IsDate(env, args[0], &isData)); - OH_LOG_INFO(LOG_APP, "JSVM IsDate success:%{public}d", isData); - - JSVM_Value result = nullptr; - JSVM_CALL(OH_JSVM_GetBoolean(env, isData, &result)); - return result; -} -// CreateDate注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = IsDate}, -}; -static JSVM_CallbackStruct *method = param; -// CreateDate方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"isDate", nullptr, method, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(isDate(new Date(Date.now())))JS"; -// [End oh_jsvm_is_date] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "isdate", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/Index.d.ts deleted file mode 100755 index 10585337c7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/oh-package.json5 deleted file mode 100755 index 18f3703cd6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/cpp/types/libisdate/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libisdate.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/pages/Index.ets deleted file mode 100755 index c922180449..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libisdate.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/module.json5 deleted file mode 100755 index 2765162faf..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "isdate", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "IsdateAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "IsdateAbility", - "srcEntry": "./ets/isdateability/IsdateAbility.ets", - "description": "$string:IsdateAbility_desc", - "icon": "$media:layered_image", - "label": "$string:IsdateAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/string.json deleted file mode 100755 index 46f7b89b29..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "IsdateAbility_desc", - "value": "description" - }, - { - "name": "IsdateAbility_label", - "value": "JsvmAboutDate" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index de324b42f7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testIsDate', 0, async (done: Function) => { - console.log('uitest: TestIsDate begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'IsdateAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('IsdateAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestIsDate end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/module.json5 deleted file mode 100755 index 1e0e371636..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/isdate/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "isdate_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/ohosTest.md deleted file mode 100755 index 6c803df253..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutDate/ohosTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# JsvmAboutDate 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 创建了一个表示给定毫秒数的Date对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定JavaScript Date的时间值的Double基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 判断一个JavaScript对象是否为Date类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/app.json5 deleted file mode 100755 index 2cd6d6c499..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmaboutobject", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/element/string.json deleted file mode 100755 index 5459d567d9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmAboutObject" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/README.md deleted file mode 100755 index 035f3ab236..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/README.md +++ /dev/null @@ -1,273 +0,0 @@ -# ArkTS使用JSVM-API接口进行object相关开发 - -### 介绍 - -使用JSVM-API接口进行object相关开发,处理JavaScript对象的基本操作的功能,例如创建对象、获取原型、冻结和密封对象,检查对象的类型等。这些操作是在处理JavaScript对象时非常常见的,提供了一种与JavaScript对象交互的方式。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口进行object相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-object.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :-----------------------------------------------------------------: | :-----------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -checkobjecttypetag/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createexternal/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createobject/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createsymbol/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getprototype/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvalueexternal/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -instanceof/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -objectfreeze/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -objectseal/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -symbolfor/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -typeof/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/build-profile.json5 deleted file mode 100755 index 18fd83aa12..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/build-profile.json5 +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "getprototype", - "srcPath": "./getprototype", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createobject", - "srcPath": "./createobject", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "objectfreeze", - "srcPath": "./objectfreeze", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "objectseal", - "srcPath": "./objectseal", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "typeof", - "srcPath": "./typeof", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "instanceof", - "srcPath": "./instanceof", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "checkobjecttypetag", - "srcPath": "./checkobjecttypetag", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createexternal", - "srcPath": "./createexternal", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getvalueexternal", - "srcPath": "./getvalueexternal", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createsymbol", - "srcPath": "./createsymbol", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "symbolfor", - "srcPath": "./symbolfor", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/oh-package.json5 deleted file mode 100755 index ff47b6be87..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "checkobjecttypetag", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcheckobjecttypetag.so": "file:./src/main/cpp/types/libcheckobjecttypetag" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/CMakeLists.txt deleted file mode 100755 index ac9bca7d70..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(checkobjecttypetag SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(checkobjecttypetag PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/hello.cpp deleted file mode 100755 index 05beaffab6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/hello.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_check_object_type_tag] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" -#define NUMBERINT_FOUR -// [StartExclude oh_jsvm_check_object_type_tag] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_check_object_type_tag] - -// 定义一个静态常量JSVM_TypeTag数组存储类型标签 -static const JSVM_TypeTag TagsData[NUMBERINT_FOUR] = { - {0x9e4b2449547061b3, 0x33999f8a6516c499}, - {0x1d55a794c53a726d, 0x43633f509f9c944e}, - {0, 0}, // 用于表示无标签或默认标签 - {0x6a971439f5b2e5d7, 0x531dc28a7e5317c0}, -}; -// OH_JSVM_TypeTagObject的样例方法 -static JSVM_Value SetTypeTagToObject(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取两个JavaScript侧传入的参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 获取索引数字转换为JSVM_Value - int32_t index = 0; - OH_JSVM_GetValueInt32(env, args[1], &index); - // 给参数(对象)设置类型标签 - JSVM_Status status = OH_JSVM_TypeTagObject(env, args[0], &TagsData[index]); - // 将bool结果转换为JSVM_Value并返回 - JSVM_Value result = nullptr; - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM SetTypeTagToObject fail"); - OH_JSVM_GetBoolean(env, false, &result); - } else { - OH_LOG_INFO(LOG_APP, "JSVM SetTypeTagToObject success"); - OH_JSVM_GetBoolean(env, true, &result); - } - return result; -} -// OH_JSVM_CheckObjectTypeTag的样例方法 -static JSVM_Value CheckObjectTypeTag(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取两个JavaScript侧传入的参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 获取索引数字转换为JSVM_Value - int32_t index = 0; - OH_JSVM_GetValueInt32(env, args[1], &index); - // 检查对象的类型标签 - bool checkResult = false; - JSVM_Status status = OH_JSVM_CheckObjectTypeTag(env, args[0], &TagsData[index], &checkResult); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM SetTypeTagToObject fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM SetTypeTagToObject:%{public}d", checkResult); - } - // 将bool结果转换为JSVM_Value并返回 - JSVM_Value checked = nullptr; - OH_JSVM_GetBoolean(env, checkResult, &checked); - return checked; -} -// SetTypeTagToObject,CheckObjectTypeTag注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = SetTypeTagToObject}, - {.data = nullptr, .callback = CheckObjectTypeTag}, -}; -static JSVM_CallbackStruct *method = param; -// SetTypeTagToObject,CheckObjectTypeTag方法别名,TS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"setTypeTagToObject", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, - {"checkObjectTypeTag", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS( - class Obj { - data; - message; - } - let obj= { data: 0, message: "hello world"}; - setTypeTagToObject(obj, 0); - checkObjectTypeTag(obj, 0);)JS"; -// [End oh_jsvm_check_object_type_tag] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "checkobjecttypetag", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/oh-package.json5 deleted file mode 100755 index b0f6513e2a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/cpp/types/libcheckobjecttypetag/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcheckobjecttypetag.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/pages/Index.ets deleted file mode 100755 index 08042f2a2f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcheckobjecttypetag.so'; - -@Entry -@Component -struct Index { - @State message: string = 'OH_JSVM_CheckObjectTypeTag'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/module.json5 deleted file mode 100755 index 7cc3ba1ab6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "checkobjecttypetag", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CheckobjecttypetagAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CheckobjecttypetagAbility", - "srcEntry": "./ets/checkobjecttypetagability/CheckobjecttypetagAbility.ets", - "description": "$string:CheckobjecttypetagAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CheckobjecttypetagAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/string.json deleted file mode 100755 index 0da352112b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CheckobjecttypetagAbility_desc", - "value": "description" - }, - { - "name": "CheckobjecttypetagAbility_label", - "value": "JsvmAboutObject" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 8f274542bb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCheckObjectTypeTag', 0, async (done: Function) => { - console.log('uitest: TestCheckObjectTypeTag begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CheckobjecttypetagAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CheckobjecttypetagAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCheckObjectTypeTag end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/module.json5 deleted file mode 100755 index 209bcba3d6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/checkobjecttypetag/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "checkobjecttypetag_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/oh-package.json5 deleted file mode 100755 index 924171b714..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createexternal", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreateexternal.so": "file:./src/main/cpp/types/libcreateexternal" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 3d50aec22d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createexternal SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createexternal PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/hello.cpp deleted file mode 100755 index 05da3a8243..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/hello.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_external] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" -#include -#include -// [StartExclude oh_jsvm_create_external] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_external] - -// OH_JSVM_CreateExternal的样例方法 -static JSVM_Value CreateExternal(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t dataSize = 10; - void *data = malloc(dataSize); - if (data == nullptr) { - OH_LOG_ERROR(LOG_APP, "JSVM Failed to malloc."); - return nullptr; - } - memset(data, 0, dataSize); - const char* testStr = "test"; - JSVM_Value external = nullptr; - JSVM_Status status = OH_JSVM_CreateExternal( - env, data, [](JSVM_Env env, void *data, void *hint) {free(data);}, (void *)testStr, &external); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM Failed to create external data, status:%{public}d.", status); - free(data); - data = nullptr; - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateExternal success"); - } - return external; -} -// CreateExternal注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateExternal}, -}; -static JSVM_CallbackStruct *method = param; -// CreateExternal方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createExternal", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(createExternal())JS"; -// [End oh_jsvm_create_external] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createexternal", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/oh-package.json5 deleted file mode 100755 index 936b81b38a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/cpp/types/libcreateexternal/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreateexternal.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/pages/Index.ets deleted file mode 100755 index ceb34830cc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreateexternal.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/module.json5 deleted file mode 100755 index fc04e24793..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createexternal", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreateexternalAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreateexternalAbility", - "srcEntry": "./ets/createexternalability/CreateexternalAbility.ets", - "description": "$string:CreateexternalAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreateexternalAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/string.json deleted file mode 100755 index ff9902b3b9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreateexternalAbility_desc", - "value": "description" - }, - { - "name": "CreateexternalAbility_label", - "value": "JsvmAboutObject" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index b81e1ce2d6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateExternal', 0, async (done: Function) => { - console.log('uitest: TestCreateExternal begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreateexternalAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreateexternalAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateExternal end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/module.json5 deleted file mode 100755 index fa0252cf17..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createexternal/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createexternal_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/oh-package.json5 deleted file mode 100755 index 2b2930c134..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createobject", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreateobject.so": "file:./src/main/cpp/types/libcreateobject" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 76f5f20565..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createobject SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createobject PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/hello.cpp deleted file mode 100755 index 50bcb17a2a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/hello.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_object] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_create_object] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_object] - -// OH_JSVM_CreateObject的样例方法 -static JSVM_Value CreateObject(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_Value object = nullptr; - // 创建一个空对象 - JSVM_Status status = OH_JSVM_CreateObject(env, &object); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateObject fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateObject success"); - } - // 设置对象的属性 - JSVM_Value name = nullptr; - // 设置属性名为 "name" - OH_JSVM_CreateStringUtf8(env, "name", JSVM_AUTO_LENGTH, &name); - JSVM_Value value = nullptr; - // 设置属性值为 "Hello from N-API!" - OH_JSVM_CreateStringUtf8(env, "Hello OH_JSVM_CreateObject!", JSVM_AUTO_LENGTH, &value); - // 将属性设置到对象上 - OH_JSVM_SetProperty(env, object, name, value); - return object; -} -// CreateObject注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateObject}, -}; -static JSVM_CallbackStruct *method = param; -// CreateObject方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createObject", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(createObject())JS"; -// [End oh_jsvm_create_object] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createobject", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/oh-package.json5 deleted file mode 100755 index 28d2121b36..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/cpp/types/libcreateobject/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreateobject.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/pages/Index.ets deleted file mode 100755 index 4b46c6078e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreateobject.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/module.json5 deleted file mode 100755 index 95badc6f52..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createobject", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreateobjectAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreateobjectAbility", - "srcEntry": "./ets/createobjectability/CreateobjectAbility.ets", - "description": "$string:CreateobjectAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreateobjectAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/string.json deleted file mode 100755 index 41bc46c409..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreateobjectAbility_desc", - "value": "description" - }, - { - "name": "CreateobjectAbility_label", - "value": "JsvmAboutObject" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index ff12b3182c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateObject', 0, async (done: Function) => { - console.log('uitest: TestCreateObject begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreateobjectAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreateobjectAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateObject end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/module.json5 deleted file mode 100755 index c43374ad96..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createobject/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createobject_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/oh-package.json5 deleted file mode 100755 index f9241794e7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createsymbol", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatesymbol.so": "file:./src/main/cpp/types/libcreatesymbol" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 5fdefb94c9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createsymbol SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createsymbol PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/hello.cpp deleted file mode 100755 index 5cb03169be..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/hello.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_symbol] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" -// [StartExclude oh_jsvm_create_symbol] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_symbol] - -// OH_JSVM_CreateSymbol的样例方法 -static JSVM_Value CreateSymbol(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_Value result = nullptr; - const char *des = "only"; - OH_JSVM_CreateStringUtf8(env, des, JSVM_AUTO_LENGTH, &result); - JSVM_Value returnSymbol = nullptr; - OH_JSVM_CreateSymbol(env, result, &returnSymbol); - JSVM_ValueType valuetypeSymbol; - OH_JSVM_Typeof(env, returnSymbol, &valuetypeSymbol); - if (valuetypeSymbol == JSVM_SYMBOL) { - OH_LOG_INFO(LOG_APP, "JSVM CreateSymbol Success"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateSymbol fail"); - } - return returnSymbol; -} -// CreateSymbol注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateSymbol}, -}; -static JSVM_CallbackStruct *method = param; -// CreateSymbol方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createSymbol", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(createSymbol())JS"; -// [End oh_jsvm_create_symbol] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createsymbol", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/oh-package.json5 deleted file mode 100755 index 33b3466c20..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/cpp/types/libcreatesymbol/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatesymbol.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/pages/Index.ets deleted file mode 100755 index 09a6c90b63..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatesymbol.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/module.json5 deleted file mode 100755 index 597c39a146..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createsymbol", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreatesymbolAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreatesymbolAbility", - "srcEntry": "./ets/createsymbolability/CreatesymbolAbility.ets", - "description": "$string:CreatesymbolAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreatesymbolAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/string.json deleted file mode 100755 index 1c3a873a7c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreatesymbolAbility_desc", - "value": "description" - }, - { - "name": "CreatesymbolAbility_label", - "value": "JsvmAboutObject" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index cbc209eb1a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateSymbol', 0, async (done: Function) => { - console.log('uitest: TestCreateSymbol begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreatesymbolAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreatesymbolAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateSymbol end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/module.json5 deleted file mode 100755 index 5eed504824..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/createsymbol/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createsymbol_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/oh-package.json5 deleted file mode 100755 index 05877d4746..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getprototype", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetprototype.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 367da72ea0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(getprototype SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getprototype PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/hello.cpp deleted file mode 100755 index d3aea8acd0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/hello.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_prototype] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" -// [StartExclude oh_jsvm_get_prototype] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_prototype] - -// GetPrototype注册回调 -// OH_JSVM_GetPrototype的样例方法 -static JSVM_Value GetPrototype(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - JSVM_Value result{nullptr}; - JSVM_Status status = OH_JSVM_GetPrototype(env, argv[0], &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetPrototype fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetPrototype success"); - } - return result; -} -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetPrototype}, -}; -static JSVM_CallbackStruct *method = param; -// GetPrototype方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getPrototype", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(const myObject = {}; - const proto = getPrototype(myObject); - console.log(proto === Object.prototype);)JS"; -// [End oh_jsvm_get_prototype] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getprototype", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 277a4d031c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetprototype.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/pages/Index.ets deleted file mode 100755 index a39b49aab5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetprototype.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/module.json5 deleted file mode 100755 index 26760a7cf9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "getprototype", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/string.json deleted file mode 100755 index b9929ce09c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmAboutObject" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 0e0f870878..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetPrototype', 0, async (done: Function) => { - console.log('uitest: TestGetPrototype begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetPrototype end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/module.json5 deleted file mode 100755 index d4eaf9addd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getprototype/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getprototype_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/oh-package.json5 deleted file mode 100755 index 78ec1d9aa1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvalueexternal", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvalueexternal.so": "file:./src/main/cpp/types/libgetvalueexternal" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 190651fdb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getvalueexternal SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvalueexternal PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/hello.cpp deleted file mode 100755 index 3416d4d9fa..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/hello.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_external] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_get_value_external] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_external] - -// OH_JSVM_GetValueExternal的样例方法 -static JSVM_Value GetValueExternal(JSVM_Env env, JSVM_CallbackInfo info) -{ - static int data = 0x12345; - JSVM_Value externalValue = nullptr; - JSVM_Status status = OH_JSVM_CreateExternal(env, (void*)&data, nullptr, nullptr, &externalValue); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CreateExternal fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CreateExternal success"); - } - void *dataValue; - status = OH_JSVM_GetValueExternal(env, externalValue, &dataValue); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetValueExternal fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetValueExternal success"); - } - // 将符号位转化为int类型传出去 - JSVM_Value returnValue = nullptr; - int retData = *static_cast(dataValue); - OH_JSVM_CreateInt32(env, retData, &returnValue); - return returnValue; -} -// GetValueExternal注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetValueExternal}, -}; -static JSVM_CallbackStruct *method = param; -// GetValueExternal方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getValueExternal", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(getValueExternal())JS"; -// [End oh_jsvm_get_value_external] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvalueexternal", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/oh-package.json5 deleted file mode 100755 index 8bc8170107..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/cpp/types/libgetvalueexternal/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvalueexternal.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/pages/Index.ets deleted file mode 100755 index 3d23b7a8b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvalueexternal.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/module.json5 deleted file mode 100755 index 04d2006a87..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getvalueexternal", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetvalueexternalAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetvalueexternalAbility", - "srcEntry": "./ets/getvalueexternalability/GetvalueexternalAbility.ets", - "description": "$string:GetvalueexternalAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetvalueexternalAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/string.json deleted file mode 100755 index 418b7f6b87..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetvalueexternalAbility_desc", - "value": "description" - }, - { - "name": "GetvalueexternalAbility_label", - "value": "JsvmAboutObject" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 7386629c99..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueExternal', 0, async (done: Function) => { - console.log('uitest: TestGetValueExternal begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetvalueexternalAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetvalueexternalAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueExternal end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/module.json5 deleted file mode 100755 index 73e07eb435..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/getvalueexternal/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvalueexternal_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/oh-package.json5 deleted file mode 100755 index 99ced34fac..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "instanceof", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libinstanceof.so": "file:./src/main/cpp/types/libinstanceof" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/CMakeLists.txt deleted file mode 100755 index dac25731fd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(instanceof SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(instanceof PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/hello.cpp deleted file mode 100755 index 55c02be3ad..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/hello.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_instanceof] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_instanceof] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_instanceof] - -// OH_JSVM_Instanceof的样例方法 -static JSVM_Value InstanceOf(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取两个JavaScript侧传入的参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - bool result = false; - JSVM_Status status = OH_JSVM_Instanceof(env, args[0], args[1], &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM InstanceOf fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM InstanceOf:%{public}d", result); - } - JSVM_Value returnValue = nullptr; - OH_JSVM_GetBoolean(env, result, &returnValue); - return returnValue; -} -// InstanceOf注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = InstanceOf}, -}; -static JSVM_CallbackStruct *method = param; -// InstanceOf方法别名,TS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"instanceOf", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(class Person { - name; - age; - constructor(name, age) { - this.name = name; - this.age = age; - } - } - instanceOf(new Person('Alice', 30), Person); - ;)JS"; -// [End oh_jsvm_instanceof] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "instanceof", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/oh-package.json5 deleted file mode 100755 index 47bff799db..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/cpp/types/libinstanceof/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libinstanceof.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/pages/Index.ets deleted file mode 100755 index 1bff49246c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libinstanceof.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/module.json5 deleted file mode 100755 index 0432702469..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "instanceof", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "InstanceofAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "InstanceofAbility", - "srcEntry": "./ets/instanceofability/InstanceofAbility.ets", - "description": "$string:InstanceofAbility_desc", - "icon": "$media:layered_image", - "label": "$string:InstanceofAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/string.json deleted file mode 100755 index 1b566a233e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "InstanceofAbility_desc", - "value": "description" - }, - { - "name": "InstanceofAbility_label", - "value": "JsvmAboutObject" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 44cf3969e3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testInstanceof', 0, async (done: Function) => { - console.log('uitest: TestInstanceof begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'InstanceofAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('InstanceofAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestInstanceof end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/module.json5 deleted file mode 100755 index e086498256..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/instanceof/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "instanceof_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/oh-package.json5 deleted file mode 100755 index 6c5d6d8055..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "objectfreeze", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libobjectfreeze.so": "file:./src/main/cpp/types/libobjectfreeze" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 8a241f55fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(objectfreeze SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(objectfreeze PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/hello.cpp deleted file mode 100755 index 88611d7f8d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_object_freeze] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_object_freeze] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_object_freeze] - -// OH_JSVM_ObjectFreeze的样例方法 -const int FREEZE_TEST_VALUE = 111111; -static JSVM_Value ObjectFreeze(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 接受一个JavaScript侧传入的object - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - // 调用接口OH_JSVM_ObjectFreeze将传入的object冻结 - JSVM_Status status = OH_JSVM_ObjectFreeze(env, argv[0]); - if (status == JSVM_OK) { - OH_LOG_INFO(LOG_APP, "Test JSVM OH_JSVM_ObjectFreeze success"); - } - // 测试冻结后的对象中属性能否修改 - JSVM_Value value = nullptr; - OH_JSVM_CreateInt32(env, FREEZE_TEST_VALUE, &value); - OH_JSVM_SetNamedProperty(env, argv[0], "data", value); - // 将冻结后修改过的属性返回JavaScript侧 - return argv[0]; -} -// ObjectFreeze注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = ObjectFreeze}, -}; -static JSVM_CallbackStruct *method = param; -// ObjectFreeze方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"objectFreeze", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(let obj = { data: 55, message: "hello world"}; - objectFreeze(obj))JS"; -// [End oh_jsvm_object_freeze] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "objectfreeze", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/oh-package.json5 deleted file mode 100755 index aa691d9a9b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/cpp/types/libobjectfreeze/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libobjectfreeze.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/pages/Index.ets deleted file mode 100755 index 1ac7898a59..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libobjectfreeze.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/module.json5 deleted file mode 100755 index 49aaac4234..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "objectfreeze", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "ObjectfreezeAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ObjectfreezeAbility", - "srcEntry": "./ets/objectfreezeability/ObjectfreezeAbility.ets", - "description": "$string:ObjectfreezeAbility_desc", - "icon": "$media:layered_image", - "label": "$string:ObjectfreezeAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/string.json deleted file mode 100755 index 0682ce8e28..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "ObjectfreezeAbility_desc", - "value": "description" - }, - { - "name": "ObjectfreezeAbility_label", - "value": "JsvmAboutObject" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index c06f07000b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testObjectFreeze', 0, async (done: Function) => { - console.log('uitest: TestObjectFreeze begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'ObjectfreezeAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('ObjectfreezeAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestObjectFreeze end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/module.json5 deleted file mode 100755 index 356c9ada05..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectfreeze/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "objectfreeze_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/oh-package.json5 deleted file mode 100755 index e2c814ce9b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "objectseal", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libobjectseal.so": "file:./src/main/cpp/types/libobjectseal" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 2915cd52c1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(objectseal SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(objectseal PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/hello.cpp deleted file mode 100755 index 7a4fbd541b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/hello.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_object_seal] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_object_seal] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_object_seal] - -// OH_JSVM_ObjectSeal的样例方法 -const int TEST_VALUE = 111111; -static JSVM_Value ObjectSeal(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 接受一个JavaScript侧传入的object - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - // 调用接口OH_JSVM_ObjectSeal将传入的object封闭,使其无法添加新的属性 - JSVM_Status status = OH_JSVM_ObjectSeal(env, argv[0]); - if (status == JSVM_OK) { - OH_LOG_INFO(LOG_APP, "Test JSVM OH_JSVM_ObjectSeal success"); - } - // 检查封闭后的对象中属性能否修改、删除、新增 - // 封闭后对象修改 - JSVM_Value changeValue = nullptr; - OH_JSVM_CreateInt32(env, TEST_VALUE, &changeValue); - OH_JSVM_SetNamedProperty(env, argv[0], "data", changeValue); - // 封闭后对象删除 - JSVM_Value deleteProperty = nullptr; - OH_JSVM_CreateStringUtf8(env, "message", JSVM_AUTO_LENGTH, &deleteProperty); - bool result = false; - OH_JSVM_DeleteProperty(env, argv[0], deleteProperty, &result); - if (result) { - OH_LOG_INFO(LOG_APP, "Test JSVM OH_JSVM_ObjectSeal failed"); - } - // 封闭后对象新增 - JSVM_Value addValue = nullptr; - OH_JSVM_CreateStringUtf8(env, "addValue", JSVM_AUTO_LENGTH, &addValue); - OH_JSVM_SetNamedProperty(env, argv[0], "newProperty", addValue); - // 将封闭后改动过的对象返回JavaScript侧 - return argv[0]; -} -// ObjectSeal注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = ObjectSeal}, -}; -static JSVM_CallbackStruct *method = param; -// ObjectSeal方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"objectSeal", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS( let obj = { data: 55, message: "hello world"}; - objectSeal(obj))JS"; -// [End oh_jsvm_object_seal] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "objectseal", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/oh-package.json5 deleted file mode 100755 index ef92118a40..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/cpp/types/libobjectseal/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libobjectseal.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/pages/Index.ets deleted file mode 100755 index 7d21d553ce..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libobjectseal.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/module.json5 deleted file mode 100755 index 8fbf4fecf0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "objectseal", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "ObjectsealAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ObjectsealAbility", - "srcEntry": "./ets/objectsealability/ObjectsealAbility.ets", - "description": "$string:ObjectsealAbility_desc", - "icon": "$media:layered_image", - "label": "$string:ObjectsealAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/string.json deleted file mode 100755 index 833d0f016e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "ObjectsealAbility_desc", - "value": "description" - }, - { - "name": "ObjectsealAbility_label", - "value": "JsvmAboutObject" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 1cc6ea6bcb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testObjectSeal', 0, async (done: Function) => { - console.log('uitest: TestObjectSeal begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'ObjectsealAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('ObjectsealAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestObjectSeal end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/module.json5 deleted file mode 100755 index 6793d50f0f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/objectseal/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "objectseal_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/ohosTest.md deleted file mode 100755 index abd3d09965..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/ohosTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# JsvmAboutObject 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------------------------------------------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 检查给定的类型标签是否与对象上的类型标签匹配 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 创建一个包装了外部指针的JavaScript对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 创建一个默认的JavaScript Object对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 根据给定的描述符创建一个Symbol对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定JavaScript对象的原型 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取先前传递给Hello World的外部数据指针 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 判断一个对象是否是某个构造函数的实例 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 冻结给定的对象,防止向其添加新属性,删除现有属性,防止更改现有属性的可枚举性、可配置性或可写性,并防止更改现有属性的值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 密封给定的对象。这可以防止向其添加新属性,以及将所有现有属性标记为不可配置 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 在全局注册表中搜索具有给定描述的现有Symbol,如果该Symbol已经存在,它将被返回,否则将在注册表中创建一个新Symbol | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 返回JavaScript对象的类型 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/oh-package.json5 deleted file mode 100755 index cbaa0d2b4e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "symbolfor", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libsymbolfor.so": "file:./src/main/cpp/types/libsymbolfor" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 51189c1583..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(symbolfor SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(symbolfor PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/hello.cpp deleted file mode 100755 index 574da85338..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/hello.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_symbol_for] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_symbol_for] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_symbol_for] - -static const size_t TESTMO_LENGTH = 9; -// 定义一个常量,用于存储最大字符串长度 -static const int MAX_BUFFER_SIZE = 128; -// OH_JSVM_SymbolFor的样例方法 -static JSVM_Value SymbolFor(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_Value description = nullptr; - OH_JSVM_CreateStringUtf8(env, "test_demo", TESTMO_LENGTH, &description); - char buffer[MAX_BUFFER_SIZE]; - size_t bufferSize = MAX_BUFFER_SIZE; - size_t copied = 0; - OH_JSVM_GetValueStringUtf8(env, description, buffer, bufferSize, &copied); - JSVM_Value symbol = nullptr; - OH_JSVM_CreateSymbol(env, description, &symbol); - JSVM_Value result_symbol = nullptr; - JSVM_Status status = OH_JSVM_SymbolFor(env, buffer, copied, &result_symbol); - JSVM_ValueType valuetypeSymbol; - OH_JSVM_Typeof(env, result_symbol, &valuetypeSymbol); - if (valuetypeSymbol == JSVM_SYMBOL && status == JSVM_OK) { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_SymbolFor success"); - } - // 返回结果 - return result_symbol; -} -// SymbolFor注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = SymbolFor}, -}; -static JSVM_CallbackStruct *method = param; -// SymbolFor方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"symbolFor", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(symbolFor())JS"; -// [End oh_jsvm_symbol_for] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "symbolfor", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/oh-package.json5 deleted file mode 100755 index bfb52e4511..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/cpp/types/libsymbolfor/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libsymbolfor.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/pages/Index.ets deleted file mode 100755 index 4b25b6e8fa..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libsymbolfor.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/module.json5 deleted file mode 100755 index efbfdcd4ba..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/module.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": "symbolfor", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "SymbolforAbility", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "SymbolforAbility", - "srcEntry": "./ets/symbolforability/SymbolforAbility.ets", - "description": "$string:SymbolforAbility_desc", - "icon": "$media:layered_image", - "label": "$string:SymbolforAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/string.json deleted file mode 100755 index d061f37b3c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "SymbolforAbility_desc", - "value": "description" - }, - { - "name": "SymbolforAbility_label", - "value": "label" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 235203dd23..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testSymbolFor', 0, async (done: Function) => { - console.log('uitest: TestSymbolFor begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestSymbolFor end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/module.json5 deleted file mode 100755 index d0bd3c1c92..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/symbolfor/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "symbolfor_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/oh-package.json5 deleted file mode 100755 index 5962d1ecbc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "typeof", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libtypeof.so": "file:./src/main/cpp/types/libtypeof" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 9f521523a9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(typeof SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(typeof PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/hello.cpp deleted file mode 100755 index 0d5caecd78..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/hello.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_typeof] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_typeof] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_typeof] - -// OH_JSVM_Typeof的样例方法 -static JSVM_Value GetTypeof(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - JSVM_ValueType valueType; - OH_JSVM_Typeof(env, args[0], &valueType); - JSVM_Value type = nullptr; - switch (valueType) { - case JSVM_UNDEFINED: - OH_LOG_INFO(LOG_APP, "JSVM Input type is undefined"); - OH_JSVM_CreateStringUtf8(env, "Input type is undefined", JSVM_AUTO_LENGTH, &type); - break; - case JSVM_NULL: - OH_LOG_INFO(LOG_APP, "JSVM Input type is null"); - OH_JSVM_CreateStringUtf8(env, "Input type is null", JSVM_AUTO_LENGTH, &type); - break; - case JSVM_BOOLEAN: - OH_LOG_INFO(LOG_APP, "JSVM Input type is boolean"); - OH_JSVM_CreateStringUtf8(env, "Input type is boolean", JSVM_AUTO_LENGTH, &type); - break; - case JSVM_NUMBER: - OH_LOG_INFO(LOG_APP, "JSVM Input type is number"); - OH_JSVM_CreateStringUtf8(env, "Input type is number", JSVM_AUTO_LENGTH, &type); - break; - case JSVM_STRING: - OH_LOG_INFO(LOG_APP, "JSVM Input type is string"); - OH_JSVM_CreateStringUtf8(env, "Input type is string", JSVM_AUTO_LENGTH, &type); - break; - case JSVM_SYMBOL: - OH_LOG_INFO(LOG_APP, "JSVM Input type is symbol"); - OH_JSVM_CreateStringUtf8(env, "Input type is symbol", JSVM_AUTO_LENGTH, &type); - break; - case JSVM_OBJECT: - OH_LOG_INFO(LOG_APP, "JSVM Input type is object"); - OH_JSVM_CreateStringUtf8(env, "Input type is object", JSVM_AUTO_LENGTH, &type); - break; - case JSVM_FUNCTION: - OH_LOG_INFO(LOG_APP, "JSVM Input type is function"); - OH_JSVM_CreateStringUtf8(env, "Input type is function", JSVM_AUTO_LENGTH, &type); - break; - case JSVM_EXTERNAL: - OH_LOG_INFO(LOG_APP, "JSVM Input type is external"); - OH_JSVM_CreateStringUtf8(env, "Input type is external", JSVM_AUTO_LENGTH, &type); - break; - case JSVM_BIGINT: - OH_LOG_INFO(LOG_APP, "JSVM Input type is bigint"); - OH_JSVM_CreateStringUtf8(env, "Input type is bigint", JSVM_AUTO_LENGTH, &type); - break; - default: - OH_LOG_INFO(LOG_APP, "JSVM Input type does not match any"); - OH_JSVM_CreateStringUtf8(env, " ", JSVM_AUTO_LENGTH, &type); - break; - } - return type; -} -// GetTypeof注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetTypeof}, -}; -static JSVM_CallbackStruct *method = param; -// GetTypeof方法别名,TS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getTypeof", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(getTypeof(true);)JS"; -// [End oh_jsvm_typeof] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "typeof", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/oh-package.json5 deleted file mode 100755 index b858570513..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/cpp/types/libtypeof/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libtypeof.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/pages/Index.ets deleted file mode 100755 index f9748bff77..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libtypeof.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/module.json5 deleted file mode 100755 index cf7ef571af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "typeof", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "TypeofAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "TypeofAbility", - "srcEntry": "./ets/typeofability/TypeofAbility.ets", - "description": "$string:TypeofAbility_desc", - "icon": "$media:layered_image", - "label": "$string:TypeofAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/string.json deleted file mode 100755 index e747d9a12e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "TypeofAbility_desc", - "value": "description" - }, - { - "name": "TypeofAbility_label", - "value": "JsvmAboutObject" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index c832338632..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testTypeof', 0, async (done: Function) => { - console.log('uitest: TestTypeof begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'TypeofAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('TypeofAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestTypeof end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/module.json5 deleted file mode 100755 index 7b20cf4064..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutObject/typeof/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "typeof_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/app.json5 deleted file mode 100755 index 48a4ad99be..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmaboutprimitive", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/element/string.json deleted file mode 100755 index 9ef5244128..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmAboutPrimitive" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/README.md deleted file mode 100755 index c8449f4f90..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/README.md +++ /dev/null @@ -1,233 +0,0 @@ -# ArkTs使用JSVM-API接口进行primitive类相关开发 - -### 介绍 - -在使用JSVM-API接口时,开发人员可以实现在JSVM模块中与JavaScript对象的交互,并进行数据转换和获取特定对象的操作,它们在不同的场景中发挥着重要的作用,使开发人员能够更灵活地处理JavaScript值和对象。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口进行primitive类相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-primitive.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :--------------------------------------------------------------------: | :--------------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -coercetobool/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -coercetonumber/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -coercetoobject/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -coercetostring/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getboolean/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getglobal/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getnull/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getundefined/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvaluebool/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/build-profile.json5 deleted file mode 100755 index b7afbd979a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/build-profile.json5 +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "coercetobool", - "srcPath": "./coercetobool", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "coercetonumber", - "srcPath": "./coercetonumber", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "coercetoobject", - "srcPath": "./coercetoobject", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "coercetostring", - "srcPath": "./coercetostring", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getboolean", - "srcPath": "./getboolean", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getvaluebool", - "srcPath": "./getvaluebool", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getglobal", - "srcPath": "./getglobal", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getnull", - "srcPath": "./getnull", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getundefined", - "srcPath": "./getundefined", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/oh-package.json5 deleted file mode 100755 index 6facad79ba..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "coercetobool", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcoercetobool.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/CMakeLists.txt deleted file mode 100755 index a88e8587fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutPrimitiveOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(coercetobool SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(coercetobool PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/hello.cpp deleted file mode 100755 index 78bf452b32..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/hello.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_coerce_to_bool] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_coerce_to_bool] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_coerce_to_bool] - -// OH_JSVM_CoerceToBool的样例方法 -static JSVM_Value CoerceToBool(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - JSVM_Value boolean = nullptr; - JSVM_Status status = OH_JSVM_CoerceToBool(env, args[0], &boolean); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CoerceToBool failed"); - } else { - bool result = false; - OH_JSVM_GetValueBool(env, boolean, &result); - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CoerceToBool success:%{public}d", result); - } - return boolean; -} -// CoerceToBool注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CoerceToBool}, -}; -static JSVM_CallbackStruct *method = param; -// CoerceToBool方法别名,ArkTS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"coerceToBool", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(coerceToBool("123"))JS"; -// [End oh_jsvm_coerce_to_bool] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "coercetobool", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index ac686c0716..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcoercetobool.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/pages/Index.ets deleted file mode 100755 index fd69f54ee1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcoercetobool.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/module.json5 deleted file mode 100755 index 3f76496cde..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "coercetobool", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/string.json deleted file mode 100755 index 6381fdf941..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmAboutPrimitive" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 9e896ce911..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCoerceToBool', 0, async (done: Function) => { - console.log('uitest: TestCoerceToBool begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCoerceToBool end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/module.json5 deleted file mode 100755 index fef439084c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetobool/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "coercetobool_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/oh-package.json5 deleted file mode 100755 index 6cf407cac7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "coercetonumber", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcoercetonumber.so": "file:./src/main/cpp/types/libcoercetonumber" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/CMakeLists.txt deleted file mode 100755 index facc2363fc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutPrimitiveOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(coercetonumber SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(coercetonumber PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/hello.cpp deleted file mode 100755 index 6eb547cd89..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/hello.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_coerce_to_number] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" -// [StartExclude oh_jsvm_coerce_to_number] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_coerce_to_number] - -// OH_JSVM_CoerceToNumber的样例方法 -static JSVM_Value CoerceToNumber(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - JSVM_Value number = nullptr; - JSVM_Status status = OH_JSVM_CoerceToNumber(env, args[0], &number); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CoerceToNumber failed"); - } else { - int32_t result = 0; - OH_JSVM_GetValueInt32(env, number, &result); - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CoerceToNumber success:%{public}d", result); - } - return number; -} -// CoerceToNumber注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CoerceToNumber}, -}; -static JSVM_CallbackStruct *method = param; -// CoerceToNumber方法别名,ArkTS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"coerceToNumber", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(coerceToNumber(true))JS"; -// [End oh_jsvm_coerce_to_number] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "coercetonumber", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/oh-package.json5 deleted file mode 100755 index 53f344cc27..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/cpp/types/libcoercetonumber/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcoercetonumber.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/pages/Index.ets deleted file mode 100755 index f1f413a5f2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcoercetonumber.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/module.json5 deleted file mode 100755 index d34c66cc71..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "coercetonumber", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CoercetonumberAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CoercetonumberAbility", - "srcEntry": "./ets/coercetonumberability/CoercetonumberAbility.ets", - "description": "$string:CoercetonumberAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CoercetonumberAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/string.json deleted file mode 100755 index 688b3a1f50..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CoercetonumberAbility_desc", - "value": "description" - }, - { - "name": "CoercetonumberAbility_label", - "value": "JsvmAboutPrimitive" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index d07af72962..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCoerceToNumber', 0, async (done: Function) => { - console.log('uitest: TestCoerceToNumber begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CoercetonumberAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CoercetonumberAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCoerceToNumber end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/module.json5 deleted file mode 100755 index 8694a7613e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetonumber/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "coercetonumber_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/oh-package.json5 deleted file mode 100755 index 0568f31272..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "coercetoobject", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcoercetoobject.so": "file:./src/main/cpp/types/libcoercetoobject" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 4ddb88de0d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutPrimitiveOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(coercetoobject SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(coercetoobject PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/hello.cpp deleted file mode 100755 index efaba9b724..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/hello.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_coerce_to_object] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_coerce_to_object] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_coerce_to_object] - -// OH_JSVM_CoerceToObject的样例方法 -static JSVM_Value CoerceToObject(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - JSVM_Value obj = nullptr; - JSVM_Status status = OH_JSVM_CoerceToObject(env, args[0], &obj); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_CoerceToObject failed"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CoerceToObject success"); - } - return obj; -} -// CoerceToObjec注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CoerceToObject}, -}; -static JSVM_CallbackStruct *method = param; -// CoerceToObject方法别名,ArkTS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"coerceToObject", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(coerceToObject(123))JS"; -// [End oh_jsvm_coerce_to_object] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "coercetoobject", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/oh-package.json5 deleted file mode 100755 index 4ce39594ad..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/cpp/types/libcoercetoobject/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcoercetoobject.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/pages/Index.ets deleted file mode 100755 index 43505b6e1b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcoercetoobject.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/module.json5 deleted file mode 100755 index e1a0d870b3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "coercetoobject", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CoercetoobjectAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CoercetoobjectAbility", - "srcEntry": "./ets/coercetoobjectability/CoercetoobjectAbility.ets", - "description": "$string:CoercetoobjectAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CoercetoobjectAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/string.json deleted file mode 100755 index 34e1bf59a1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CoercetoobjectAbility_desc", - "value": "description" - }, - { - "name": "CoercetoobjectAbility_label", - "value": "JsvmAboutPrimitive" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index cd7d27a848..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCoerceToObject', 0, async (done: Function) => { - console.log('uitest: TestCoerceToObject begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CoercetoobjectAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CoercetoobjectAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCoerceToObject end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/module.json5 deleted file mode 100755 index 2c976ff7d5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetoobject/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "coercetoobject_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/oh-package.json5 deleted file mode 100755 index 7f67da56f1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "coercetostring", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcoercetostring.so": "file:./src/main/cpp/types/libcoercetostring" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 4bc265a801..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(coercetostring SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(coercetostring PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/hello.cpp deleted file mode 100755 index 123b091580..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/hello.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_coerce_to_string] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_coerce_to_string] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_coerce_to_string] - -// OH_JSVM_CoerceToString的样例方法 -static JSVM_Value CoerceToString(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - JSVM_Value str = nullptr; - JSVM_Status status = OH_JSVM_CoerceToString(env, args[0], &str); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_CoerceToString fail"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CoerceToString success"); - } - return str; -} -// CoerceToString注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CoerceToString}, -}; -static JSVM_CallbackStruct *method = param; -// CoerceToString方法别名,ArkTS侧调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"coerceToString", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(coerceToString(22222))JS"; -// [End oh_jsvm_coerce_to_string] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "coercetostring", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/oh-package.json5 deleted file mode 100755 index 24c7c053ec..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/cpp/types/libcoercetostring/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcoercetostring.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/pages/Index.ets deleted file mode 100755 index 99339f82b2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcoercetostring.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/module.json5 deleted file mode 100755 index 1eee56a7af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "coercetostring", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CoercetostringAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CoercetostringAbility", - "srcEntry": "./ets/coercetostringability/CoercetostringAbility.ets", - "description": "$string:CoercetostringAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CoercetostringAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/string.json deleted file mode 100755 index 3d93e0aeca..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CoercetostringAbility_desc", - "value": "description" - }, - { - "name": "CoercetostringAbility_label", - "value": "JsvmAboutPrimitive" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 54f405fa6a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCoerceToString', 0, async (done: Function) => { - console.log('uitest: TestCoerceToString begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CoercetostringAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CoercetostringAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCoerceToString end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/module.json5 deleted file mode 100755 index b1d2aa50f7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/coercetostring/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "coercetostring_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/oh-package.json5 deleted file mode 100755 index 08c0881e28..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getboolean", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetboolean.so": "file:./src/main/cpp/types/libgetboolean" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 46e6a30dc7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getboolean SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getboolean PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/hello.cpp deleted file mode 100755 index ebd0e23ed1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/hello.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_boolean] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_get_boolean] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_boolean] - -// OH_JSVM_GetBoolean的样例方法 -static JSVM_Value GetBoolean(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 传入两个参数并解析 - size_t argc = 2; - JSVM_Value argv[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - int32_t paramData = 0; - OH_JSVM_GetValueInt32(env, argv[0], ¶mData); - int32_t paramValue = 0; - OH_JSVM_GetValueInt32(env, argv[1], ¶mValue); - JSVM_Value returnValue = nullptr; - bool type = false; - if (paramData == paramValue) { - OH_LOG_INFO(LOG_APP, "JSVM resultType equal"); - type = true; - } - JSVM_Status status = OH_JSVM_GetBoolean(env, type, &returnValue); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_CoerceToNumber fail"); - } else { - bool result = false; - OH_JSVM_GetValueBool(env, returnValue, &result); - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_CoerceToNumber success:%{public}d", result); - } - // 返回结果 - return returnValue; -} -// GetBoolean注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetBoolean}, -}; -static JSVM_CallbackStruct *method = param; -// GetBoolean方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getBoolean", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(getBoolean(1, 2))JS"; -// const char *SRC_CALL_NATIVE = R"JS(getBoolean(1, 1))JS"; -// [End oh_jsvm_get_boolean] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getboolean", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/oh-package.json5 deleted file mode 100755 index 44148b8150..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/cpp/types/libgetboolean/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetboolean.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/pages/Index.ets deleted file mode 100755 index dcf7f83035..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetboolean.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/module.json5 deleted file mode 100755 index af59a2b0b5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getboolean", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetbooleanAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetbooleanAbility", - "srcEntry": "./ets/getbooleanability/GetbooleanAbility.ets", - "description": "$string:GetbooleanAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetbooleanAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/string.json deleted file mode 100755 index fe1ec26c0c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetbooleanAbility_desc", - "value": "description" - }, - { - "name": "GetbooleanAbility_label", - "value": "JsvmAboutPrimitive" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 8e6181a775..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetBoolean', 0, async (done: Function) => { - console.log('uitest: TestGetBoolean begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetbooleanAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetbooleanAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetBoolean end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/module.json5 deleted file mode 100755 index d84e576d82..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getboolean/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getboolean_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/oh-package.json5 deleted file mode 100755 index 6b41753d0f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getglobal", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetglobal.so": "file:./src/main/cpp/types/libgetglobal" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/CMakeLists.txt deleted file mode 100755 index d25ded8811..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getglobal SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getglobal PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/hello.cpp deleted file mode 100755 index 4321e184d2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/hello.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_global] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_get_global] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_global] - -// OH_JSVM_GetGlobal的样例方法 -static JSVM_Value GetGlobal(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取全局对象 - JSVM_Value value = nullptr; - JSVM_Value global = nullptr; - OH_JSVM_CreateInt32(env, 1, &value); - JSVM_Status status = OH_JSVM_GetGlobal(env, &global); - OH_JSVM_SetNamedProperty(env, global, "Row", value); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetGlobal fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetGlobal success"); - } - return global; -} -// GetGlobal注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetGlobal}, -}; -static JSVM_CallbackStruct *method = param; -// GetGlobal方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getGlobal", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(getGlobal())JS"; -// [End oh_jsvm_get_global] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getglobal", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/oh-package.json5 deleted file mode 100755 index ebe943799e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/cpp/types/libgetglobal/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetglobal.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/pages/Index.ets deleted file mode 100755 index 79eb37d286..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetglobal.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/module.json5 deleted file mode 100755 index bada9b3cff..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "getglobal", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetglobalAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetglobalAbility", - "srcEntry": "./ets/getglobalability/GetglobalAbility.ets", - "description": "$string:GetglobalAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetglobalAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/string.json deleted file mode 100755 index 4fc66efff6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetglobalAbility_desc", - "value": "description" - }, - { - "name": "GetglobalAbility_label", - "value": "JsvmAboutPrimitive" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index c455dbaa2b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetGlobal', 0, async (done: Function) => { - console.log('uitest: TestGetGlobal begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetglobalAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetglobalAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetGlobal end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/module.json5 deleted file mode 100755 index 954dc92637..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getglobal/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "getglobal_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/oh-package.json5 deleted file mode 100755 index c86d82f187..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getnull", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetnull.so": "file:./src/main/cpp/types/libgetnull" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 34d492cbc8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getnull SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getnull PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/hello.cpp deleted file mode 100755 index 148def4d13..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/hello.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_null] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_get_null] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_null] - -// GetNull注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetNull}, -}; -static JSVM_CallbackStruct *method = param; -// GetNull方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getNull", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// OH_JSVM_GetNull的样例方法 -static JSVM_Value GetNull(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_Value nullValue = nullptr; - JSVM_Status status = OH_JSVM_GetNull(env, &nullValue); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetNull fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetNull success"); - } - return nullValue; -} -// [End oh_jsvm_get_null] -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(getNull())JS"; - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getnull", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/oh-package.json5 deleted file mode 100755 index 69f351200a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/cpp/types/libgetnull/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetnull.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/pages/Index.ets deleted file mode 100755 index a05088e543..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetnull.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/module.json5 deleted file mode 100755 index cb2da8c0cf..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "getnull", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetnullAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetnullAbility", - "srcEntry": "./ets/getnullability/GetnullAbility.ets", - "description": "$string:GetnullAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetnullAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/string.json deleted file mode 100755 index 24f0b34420..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetnullAbility_desc", - "value": "description" - }, - { - "name": "GetnullAbility_label", - "value": "JsvmAboutPrimitive" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index b17863e4fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetNull', 0, async (done: Function) => { - console.log('uitest: TestGetNull begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetnullAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetnullAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetNull end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/module.json5 deleted file mode 100755 index dd901e63c1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getnull/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "getnull_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/oh-package.json5 deleted file mode 100755 index a101e3e313..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getundefined", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetundefined.so": "file:./src/main/cpp/types/libgetundefined" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/CMakeLists.txt deleted file mode 100755 index fbe5c54585..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getundefined SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getundefined PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/hello.cpp deleted file mode 100755 index 7f587272a1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/hello.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_undefined] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_get_undefined] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_undefined] - -// GetUndefined注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetUndefined}, -}; -static JSVM_CallbackStruct *method = param; -// GetUndefined方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getUndefined", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// OH_JSVM_GetUndefined的样例方法 -static JSVM_Value GetUndefined(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取并解析传进的参数 - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 创建一个undefined值 - JSVM_Value value = nullptr; - JSVM_Status status = OH_JSVM_GetUndefined(env, &value); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetUndefined failed"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetUndefined success"); - } - return value; -} -// [End oh_jsvm_get_undefined] -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(getUndefined())JS"; - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getundefined", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/oh-package.json5 deleted file mode 100755 index ed444d28c6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/cpp/types/libgetundefined/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetundefined.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/pages/Index.ets deleted file mode 100755 index 0c69a90801..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetundefined.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/module.json5 deleted file mode 100755 index 5883732608..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "getundefined", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetundefinedAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetundefinedAbility", - "srcEntry": "./ets/getundefinedability/GetundefinedAbility.ets", - "description": "$string:GetundefinedAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetundefinedAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/string.json deleted file mode 100755 index 033a2730bc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetundefinedAbility_desc", - "value": "description" - }, - { - "name": "GetundefinedAbility_label", - "value": "JsvmAboutPrimitive" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index f811865865..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetUndefined', 0, async (done: Function) => { - console.log('uitest: TestGetUndefined begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetundefinedAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetundefinedAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetUndefined end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/module.json5 deleted file mode 100755 index eb9a4b8237..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getundefined/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "getundefined_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/oh-package.json5 deleted file mode 100755 index f94f43e35c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvaluebool", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvaluebool.so": "file:./src/main/cpp/types/libgetvaluebool" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/CMakeLists.txt deleted file mode 100755 index e712be0dec..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JSVMDemo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getvaluebool SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvaluebool PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/hello.cpp deleted file mode 100755 index ec3f580e1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_bool] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_get_value_bool] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_bool] - -// GetValueBool注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetValueBool}, -}; -static JSVM_CallbackStruct *method = param; -// GetValueBool方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getValueBool", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// OH_JSVM_GetValueBool的样例方法 -static JSVM_Value GetValueBool(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - bool result = false; - JSVM_Status status = OH_JSVM_GetValueBool(env, args[0], &result); - if (status == JSVM_BOOLEAN_EXPECTED || status != JSVM_OK) { - // 如果OH_JSVM_GetValueBool成功会返回JSVM_OK,如果传入一个非布尔值则会返回JSVM_BOOLEAN_EXPECTED - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetValueBool fail:%{public}d", status); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetValueBool success:%{public}d", result); - } - JSVM_Value boolJv = nullptr; - OH_JSVM_GetBoolean(env, result, &boolJv); - return boolJv; -} -// [End oh_jsvm_get_value_bool] -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(getValueBool("abc"))JS"; -// const char *SRC_CALL_NATIVE = R"JS(getValueBool(true))JS"; -// const char *SRC_CALL_NATIVE = R"JS(getValueBool(false))JS"; - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvaluebool", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/oh-package.json5 deleted file mode 100755 index 9d32f5488b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/cpp/types/libgetvaluebool/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvaluebool.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/pages/Index.ets deleted file mode 100755 index 2003b2dc6c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvaluebool.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/module.json5 deleted file mode 100755 index 9b276e0e29..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "getvaluebool", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetvalueboolAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetvalueboolAbility", - "srcEntry": "./ets/getvalueboolability/GetvalueboolAbility.ets", - "description": "$string:GetvalueboolAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetvalueboolAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/string.json deleted file mode 100755 index a059c632a6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetvalueboolAbility_desc", - "value": "description" - }, - { - "name": "GetvalueboolAbility_label", - "value": "JsvmAboutPrimitive" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 0e12eb8334..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueBool', 0, async (done: Function) => { - console.log('uitest: TestGetValueBool begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetvalueboolAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetvalueboolAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueBool end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/module.json5 deleted file mode 100755 index ec4548e4df..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/getvaluebool/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "getvaluebool_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/ohosTest.md deleted file mode 100755 index 6c0b7e9b2c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPrimitive/ohosTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# JsvmAboutPrimitive 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 将目标值转换为Boolean类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 将目标值转换为Number类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 将目标值转换为Object类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 将目标值转换为String类型对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取JavaScript单例对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取当前环境中的全局global对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取JavaScript null | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取JavaScript undefined | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定JavaScript Boolean的C布尔基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/app.json5 deleted file mode 100755 index 160d1bf710..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmaboutpromise", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/element/string.json deleted file mode 100755 index 69f3fda044..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmAboutPromise" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/README.md deleted file mode 100755 index 11d0014884..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/README.md +++ /dev/null @@ -1,93 +0,0 @@ -# ArkTS使用JSVM-API接口处理异步操作 - -### 介绍 - -使用JSVM-API接口处理异步操作。异步操作是指需要一定时间才能完成的操作,例如从网络下载数据或读取大型文件。与同步操作不同,异步操作不会阻塞主线程,而是会在后台执行。当异步操作完成后,事件循环将把它放入任务队列中,等待主线程空闲时执行。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口处理异步操作](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-promise.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -|:--------------------------------------------------------------------:|:--------------------------------------------------------------------:| -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -ispromise/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -resolvereject/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/build-profile.json5 deleted file mode 100755 index 9c52a08979..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/build-profile.json5 +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "ispromise", - "srcPath": "./ispromise", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "resolvereject", - "srcPath": "./resolvereject", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/oh-package.json5 deleted file mode 100755 index 6609f10199..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "ispromise", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libispromise.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 12439788dd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutPromise) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(ispromise SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(ispromise PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/hello.cpp deleted file mode 100755 index 627c4d6bca..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/hello.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_ispromise] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [EndExclude oh_jsvm_ispromise] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_ispromise] - -// OH_JSVM_IsPromise的样例方法 -static JSVM_Value IsPromise(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - bool isPromise = false; - JSVM_Status status = OH_JSVM_IsPromise(env, args[0], &isPromise); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_IsPromise fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_IsPromise success:%{public}d", isPromise); - } - JSVM_Value result = nullptr; - OH_JSVM_GetBoolean(env, isPromise, &result); - return result; -} -// IsPromise注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = IsPromise}, -}; -static JSVM_CallbackStruct *method = param; -// IsPromise方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"isPromise", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(isPromise())JS"; -// [End oh_jsvm_ispromise] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "ispromise", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 5a0ea78a44..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libispromise.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/pages/Index.ets deleted file mode 100755 index 5639888902..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libispromise.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/module.json5 deleted file mode 100755 index e72f7a6391..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "ispromise", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/module.json5 deleted file mode 100755 index 37191bb53c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ispromise/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "ispromise_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ohosTest.md deleted file mode 100755 index d91f25b154..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/ohosTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# JsvmAboutDate 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------- | ------------ | ------------------------ | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 查询Promise是否为Promise对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 通过与之关联的延迟对象来解析JavaScript promise | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/oh-package.json5 deleted file mode 100755 index 193f8161ce..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "resolvereject", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libresolvereject.so": "file:./src/main/cpp/types/libresolvereject" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 541b71f1ab..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutPromise) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(resolvereject SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(resolvereject PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/hello.cpp deleted file mode 100755 index c75293bfcc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/hello.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_resolvedeferred_and_rejectdeferred] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_resolvedeferred_and_rejectdeferred] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_resolvedeferred_and_rejectdeferred] - -// OH_JSVM_CreatePromise、OH_JSVM_ResolveDeferred、OH_JSVM_RejectDeferred的样例方法 -static JSVM_Value CreatePromise(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_Deferred defer = nullptr; - JSVM_Value promise = nullptr; - JSVM_Status status = OH_JSVM_CreatePromise(env, &defer, &promise); - bool isPromise = false; - JSVM_Value returnIsPromise = nullptr; - OH_JSVM_IsPromise(env, promise, &isPromise); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreatePromise fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreatePromise success:%{public}d", isPromise); - } - // 将布尔值转为可以返回的JSVM_Value - OH_JSVM_GetBoolean(env, isPromise, &returnIsPromise); - return returnIsPromise; -} - -static JSVM_Value ResolveRejectDeferred(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获得并解析参数 - size_t argc = 3; - JSVM_Value args[3] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 第一个参数为向resolve传入的信息,第二个参数为向reject传入的信息,第三个参数为Promise的状态 - bool status = false; - OH_JSVM_GetValueBool(env, args[2], &status); - // 创建Promise对象 - JSVM_Deferred deferred = nullptr; - JSVM_Value promise = nullptr; - JSVM_Status createStatus = OH_JSVM_CreatePromise(env, &deferred, &promise); - if (createStatus != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "Create promise failed"); - return nullptr; - } - // 根据第三个参数设置resolve或reject - if (status) { - OH_JSVM_ResolveDeferred(env, deferred, args[0]); - OH_LOG_INFO(LOG_APP, "OH_JSVM_ResolveDeferred resolve"); - } else { - OH_JSVM_RejectDeferred(env, deferred, args[1]); - OH_LOG_INFO(LOG_APP, "OH_JSVM_RejectDeferred reject"); - } - JSVM_Value result = nullptr; - OH_JSVM_GetBoolean(env, true, &result); - return result; -} -// CreatePromise,ResolveRejectDeferred注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreatePromise}, - {.data = nullptr, .callback = ResolveRejectDeferred}, -}; -static JSVM_CallbackStruct *method = param; -// CreatePromise,ResolveRejectDeferred方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createPromise", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, - {"resolveRejectDeferred", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE_CREATE_PROMISE = R"JS(createPromise())JS"; -const char *SRC_CALL_NATIVE_RESOLVE_REJECT_DEFERRED1 = R"JS(resolveRejectDeferred('success','fail', true))JS"; -const char *SRC_CALL_NATIVE_RESOLVE_REJECT_DEFERRED2 = R"JS(resolveRejectDeferred('success','fail', false))JS"; -// [End oh_jsvm_resolvedeferred_and_rejectdeferred] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE_CREATE_PROMISE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE_RESOLVE_REJECT_DEFERRED1, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE_RESOLVE_REJECT_DEFERRED2, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "resolvereject", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/oh-package.json5 deleted file mode 100755 index f18cdc7cef..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/cpp/types/libresolvereject/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libresolvereject.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/pages/Index.ets deleted file mode 100755 index 1ebf019d9a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libresolvereject.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/module.json5 deleted file mode 100755 index 611397a0c4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "resolvereject", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "ResolverejectAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ResolverejectAbility", - "srcEntry": "./ets/resolverejectability/ResolverejectAbility.ets", - "description": "$string:ResolverejectAbility_desc", - "icon": "$media:layered_image", - "label": "$string:ResolverejectAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/module.json5 deleted file mode 100755 index 8a7f45711b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutPromise/resolvereject/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "resolvereject_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/app.json5 deleted file mode 100755 index fa77fa691e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmaboutproperty", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/element/string.json deleted file mode 100755 index 462be837c6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmAboutProperty" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/README.md deleted file mode 100755 index 0fbdef4b09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/README.md +++ /dev/null @@ -1,273 +0,0 @@ -# ArkTs使用JSVM-API接口设置JavaScript对象的属性 - -### 介绍 - -使用JSVM-API接口获取和设置JavaScript对象的属性。通过合理使用这些函数,实现更复杂的功能和逻辑。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口设置JavaScript对象的属性](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-property.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :-------------------------------------------------------------------: | :-------------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -defineproperties/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -deleteproperty/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getallpropertynames/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getnamedproperty/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getproperty/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getpropertynames/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -hasnamedproperty/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -hasownproperty/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -hasproperty/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -setnamedproperty/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -setproperty/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/build-profile.json5 deleted file mode 100755 index 045c2423e4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/build-profile.json5 +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "getpropertynames", - "srcPath": "./getpropertynames", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getproperty", - "srcPath": "./getproperty", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "deleteproperty", - "srcPath": "./deleteproperty", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getnamedproperty", - "srcPath": "./getnamedproperty", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "defineproperties", - "srcPath": "./defineproperties", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getallpropertynames", - "srcPath": "./getallpropertynames", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "setproperty", - "srcPath": "./setproperty", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "hasproperty", - "srcPath": "./hasproperty", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "hasownproperty", - "srcPath": "./hasownproperty", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "setnamedproperty", - "srcPath": "./setnamedproperty", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "hasnamedproperty", - "srcPath": "./hasnamedproperty", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/oh-package.json5 deleted file mode 100755 index c59b85f09d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "defineproperties", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libdefineproperties.so": "file:./src/main/cpp/types/libdefineproperties" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 409794f0bc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutProperty) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(defineproperties SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(defineproperties PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/hello.cpp deleted file mode 100755 index 30231f3645..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/hello.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" -#include -#include - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" -#define MAX_MALLOC_SIZE 0x800000 - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_define_properties] -// 属性描述符列表中defineMethodPropertiesExample属性的回调函数 -static JSVM_Value DefineMethodPropertiesExample(JSVM_Env env, JSVM_CallbackInfo info) -{ - int32_t propValue = 26; - JSVM_Value returnValue; - OH_JSVM_CreateInt32(env, propValue, &returnValue); - return returnValue; -} -// 属性描述符列表中getterCallback属性的回调函数 -static JSVM_Value GetterCallback(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_Value result; - const char *str = "Hello world!"; - size_t length = strlen(str); - // 创建属性的值 - OH_JSVM_CreateStringUtf8(env, str, length, &result); - return result; -} - -// 执行JavaScript字符串的函数 -static JSVM_Value RunScriptAndLogResult(JSVM_Env env, const std::string &srcCode) -{ - JSVM_Value sourceCodeValue; - OH_JSVM_CreateStringUtf8(env, srcCode.c_str(), srcCode.size(), &sourceCodeValue); - JSVM_Script script; - // 编译JavaScript代码字符串并返回编译后的脚本 - OH_JSVM_CompileScript(env, sourceCodeValue, nullptr, 0, true, nullptr, &script); - JSVM_Value jsVmResult; - // 执行JavaScript代码字符串 - OH_JSVM_RunScript(env, script, &jsVmResult); - return jsVmResult; -} - -// OH_JSVM_DefineProperties的样例方法 -static JSVM_Value DefineProperties(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 接受一个JavaScript侧传入的空object - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - // 创建一个string类型的属性值 - JSVM_Value stringValue; - OH_JSVM_CreateStringUtf8(env, "Hello!", JSVM_AUTO_LENGTH, &stringValue); - // 创建属性描述符对应的回调函数列表 - JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = DefineMethodPropertiesExample}, - {.data = nullptr, .callback = GetterCallback}, - - }; - // 创建属性描述符列表,不同类型属性值添加位置参考JSVM_PropertyDescriptor定义 - JSVM_PropertyDescriptor descriptor[] = { - // 定义method类型的属性值 - {"defineMethodPropertiesExample", nullptr, ¶m[0], nullptr, nullptr, nullptr, JSVM_DEFAULT}, - // 定义string类型的属性值 - {"defineStringPropertiesExample", nullptr, nullptr, nullptr, nullptr, stringValue, JSVM_DEFAULT}, - // 定义getter类型的属性值 - {"getterCallback", nullptr, nullptr, ¶m[1], nullptr, nullptr, JSVM_DEFAULT}}; - // 根据属性描述符列表为obj对象创建属性 - JSVM_Status statusProperty = OH_JSVM_DefineProperties(env, - *argv, - sizeof(descriptor) / sizeof(descriptor[0]), - descriptor); - if (statusProperty != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM DefineProperties fail"); - return nullptr; - } - // 调用obj对象中添加的属性 - // 运行obj.defineMethodPropertiesExample()并将结果返回给JavaScript - std::string srcMethod = R"JS(obj.defineMethodPropertiesExample();)JS"; - JSVM_Value jsVmResult = RunScriptAndLogResult(env, srcMethod); - if (jsVmResult != nullptr) { - int32_t number; - OH_JSVM_GetValueInt32(env, jsVmResult, &number); - OH_LOG_INFO(LOG_APP, "JSVM DefineMethodPropertiesExample success:%{public}d", number); - } - // 运行obj.defineStringPropertiesExample()并将结果返回给JavaScript - static std::string srcString = R"JS(obj.defineStringPropertiesExample;)JS"; - JSVM_Value jsVmResult1 = RunScriptAndLogResult(env, srcString); - if (jsVmResult1 != nullptr) { - size_t length = 0; - OH_JSVM_GetValueStringUtf8(env, jsVmResult1, nullptr, 0, &length); - if (length == 0 || length > MAX_MALLOC_SIZE) { - OH_LOG_ERROR(LOG_APP, "Invalid string length: %{public}zu", length); - return jsVmResult; - } - char *buf = (char *)malloc(length + 1); - OH_JSVM_GetValueStringUtf8(env, jsVmResult1, buf, length + 1, &length); - OH_LOG_INFO(LOG_APP, "JSVM defineStringPropertiesExample success:%{public}s", buf); - free(buf); - } - // 调用obj的getterCallback()并将结果字符串返回给JavaScript - static std::string srcGetter = R"JS(obj.getterCallback;)JS"; - JSVM_Value jsVmResult2 = RunScriptAndLogResult(env, srcGetter); - if (jsVmResult2 != nullptr) { - size_t length = 0; - OH_JSVM_GetValueStringUtf8(env, jsVmResult2, nullptr, 0, &length); - OH_JSVM_GetValueStringUtf8(env, jsVmResult1, nullptr, 0, &length); - if (length == 0 || length > MAX_MALLOC_SIZE) { - OH_LOG_ERROR(LOG_APP, "Invalid string length: %{public}zu", length); - return jsVmResult; - } - char *buf = (char *)malloc(length + 1); - OH_JSVM_GetValueStringUtf8(env, jsVmResult2, buf, length + 1, &length); - OH_LOG_INFO(LOG_APP, "JSVM getterCallback success:%{public}s", buf); - free(buf); - } - return jsVmResult; -} - -// DefineProperties注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = DefineProperties}, -}; -static JSVM_CallbackStruct *method = param; -// DefineProperties方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"defineProperties", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let obj = {}; - defineProperties(obj) -)JS"; -// [End oh_jsvm_define_properties] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "defineproperties", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/oh-package.json5 deleted file mode 100755 index cda01b57ad..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/cpp/types/libdefineproperties/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libdefineproperties.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/pages/Index.ets deleted file mode 100755 index a6227e5f82..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libdefineproperties.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/module.json5 deleted file mode 100755 index 7add5f24c3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "defineproperties", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "DefinepropertiesAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "DefinepropertiesAbility", - "srcEntry": "./ets/definepropertiesability/DefinepropertiesAbility.ets", - "description": "$string:DefinepropertiesAbility_desc", - "icon": "$media:layered_image", - "label": "$string:DefinepropertiesAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/string.json deleted file mode 100755 index 3a13ad00d6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "DefinepropertiesAbility_desc", - "value": "description" - }, - { - "name": "DefinepropertiesAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index a4270bba3e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testDefineProperties', 0, async (done: Function) => { - console.log('uitest: TestDefineProperties begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'DefinepropertiesAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('DefinepropertiesAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestDefineProperties end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/module.json5 deleted file mode 100755 index c6810afd6f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/defineproperties/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "defineproperties_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/oh-package.json5 deleted file mode 100755 index fbd0dbf5b2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "deleteproperty", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libdeleteproperty.so": "file:./src/main/cpp/types/libdeleteproperty" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 3c68e1323d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutProperty) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(deleteproperty SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(deleteproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/hello.cpp deleted file mode 100755 index 4ed3a2dd09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/hello.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_delete_property] -// OH_JSVM_DeleteProperty的样例方法 -static JSVM_Value DeleteProperty(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取js侧传入的两个参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - JSVM_ValueType valueType; - OH_JSVM_Typeof(env, args[0], &valueType); - if (valueType != JSVM_OBJECT) { - OH_JSVM_ThrowError(env, nullptr, "Expects an object as argument."); - return nullptr; - } - // 从传入的Object对象中删除指定属性,返回是否删除成功的bool结果值 - bool result = false; - JSVM_Status status = OH_JSVM_DeleteProperty(env, args[0], args[1], &result); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_DeleteProperty failed"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_DeleteProperty success:%{public}d", result); - } - // 将bool结果转换为JSVM_value并返回 - JSVM_Value ret; - OH_JSVM_GetBoolean(env, result, &ret); - return ret; -} -// DeleteProperty注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = DeleteProperty}, -}; -static JSVM_CallbackStruct *method = param; -// DeleteProperty方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"deleteProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let obj = { data: 0, message: "hello world", 50: 1}; - deleteProperty(obj, "message") -)JS"; -// [End oh_jsvm_delete_property] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "deleteproperty", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/oh-package.json5 deleted file mode 100755 index d6413588d7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/cpp/types/libdeleteproperty/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libdeleteproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/pages/Index.ets deleted file mode 100755 index 037ebc569d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libdeleteproperty.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/module.json5 deleted file mode 100755 index 836665b3e4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "deleteproperty", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "DeletepropertyAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "DeletepropertyAbility", - "srcEntry": "./ets/deletepropertyability/DeletepropertyAbility.ets", - "description": "$string:DeletepropertyAbility_desc", - "icon": "$media:layered_image", - "label": "$string:DeletepropertyAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/string.json deleted file mode 100755 index 1aef48f84a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "DeletepropertyAbility_desc", - "value": "description" - }, - { - "name": "DeletepropertyAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 9e350045ea..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testDeleteProperty', 0, async (done: Function) => { - console.log('uitest: TestDeleteProperty begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'DeletepropertyAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('DeletepropertyAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestDeleteProperty end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/module.json5 deleted file mode 100755 index 171021952a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/deleteproperty/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "deleteproperty_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/oh-package.json5 deleted file mode 100755 index 45bb916f60..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getallpropertynames", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetallpropertynames.so": "file:./src/main/cpp/types/libgetallpropertynames" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 448b8735b5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutProperty) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getallpropertynames SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getallpropertynames PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/hello.cpp deleted file mode 100755 index 66b8d9957d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/hello.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_get_all_property_names] -// OH_JSVM_GetAllPropertyNames的样例方法 -static JSVM_Value GetAllPropertyNames(JSVM_Env env, JSVM_CallbackInfo info) -{ - // // 获取js侧传入的一个参数 - size_t argc = 1; - JSVM_Value args[1]; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 获取给定对象的所有属性名称(自有属性) - JSVM_Value result; - JSVM_Status status = OH_JSVM_GetAllPropertyNames(env, args[0], - JSVM_KeyCollectionMode::JSVM_KEY_O_ONLY, - JSVM_KeyFilter::JSVM_KEY_WRITABLE, - JSVM_KeyConversion::JSVM_KEY_NUMBERS_TO_STRINGS, &result); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "Failed to get allpropertynames"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetAllPropertyNames success"); - } - return result; -} -// GetAllPropertyNames注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetAllPropertyNames}, -}; -static JSVM_CallbackStruct *method = param; -// GetAllPropertyNames方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getAllPropertyNames", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let obj = '{ data: 0, message: "hello world", 50: 1}'; - let script = getAllPropertyNames(obj); -)JS"; -// [End oh_jsvm_get_all_property_names] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getallpropertynames", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/oh-package.json5 deleted file mode 100755 index 60b97e056a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/cpp/types/libgetallpropertynames/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetallpropertynames.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/pages/Index.ets deleted file mode 100755 index 63637d06a6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetallpropertynames.so'; - -@Entry -@Component -struct Index { - @State message: string = 'OH_JSVM_GetAllPropertyNames'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/module.json5 deleted file mode 100755 index 24abb823d2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getallpropertynames", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetallpropertynamesAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetallpropertynamesAbility", - "srcEntry": "./ets/getallpropertynamesability/GetallpropertynamesAbility.ets", - "description": "$string:GetallpropertynamesAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetallpropertynamesAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/string.json deleted file mode 100755 index f940655f4c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetallpropertynamesAbility_desc", - "value": "description" - }, - { - "name": "GetallpropertynamesAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index ea05ca35f0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetAllPropertyNames', 0, async (done: Function) => { - console.log('uitest: TestGetAllPropertyNames begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetallpropertynamesAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetallpropertynamesAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetAllPropertyNames end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/module.json5 deleted file mode 100755 index 393e966fbd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getallpropertynames/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getallpropertynames_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/oh-package.json5 deleted file mode 100755 index e8e5dc4f64..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getnamedproperty", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetnamedproperty.so": "file:./src/main/cpp/types/libgetnamedproperty" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/CMakeLists.txt deleted file mode 100755 index de0f007857..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutProperty) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getnamedproperty SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getnamedproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/hello.cpp deleted file mode 100755 index 1a89a3e838..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/hello.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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 "ark_runtime/jsvm.h" -#include "hilog/log.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_get_named_property] -// OH_JSVM_GetNamedProperty的样例方法 -const size_t MAX_KEY_LENGTH = 32; -static JSVM_Value GetNamedProperty(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取js侧传入的两个参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - char strKey[MAX_KEY_LENGTH] = ""; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 获取要获取的属性名 - size_t keyLength; - OH_JSVM_GetValueStringUtf8(env, args[1], strKey, MAX_KEY_LENGTH, &keyLength); - // 获取指定属性的值并存储在result中 - JSVM_Value result; - JSVM_Status status = OH_JSVM_GetNamedProperty(env, args[0], strKey, &result); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_GetNamedProperty failed"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetNamedProperty success"); - } - return result; -} -// GetNamedProperty注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetNamedProperty}, -}; -static JSVM_CallbackStruct *method = param; -// GetNamedProperty方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getNamedProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let obj = { data: 0, message: "hello world", 50: 1}; - getNamedProperty(obj, "message") -)JS"; -// [End oh_jsvm_get_named_property] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getnamedproperty", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/oh-package.json5 deleted file mode 100755 index 3bf0f63687..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/cpp/types/libgetnamedproperty/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetnamedproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/pages/Index.ets deleted file mode 100755 index 0cce1296bf..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetnamedproperty.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/module.json5 deleted file mode 100755 index b7b08e66dd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getnamedproperty", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetnamedpropertyAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetnamedpropertyAbility", - "srcEntry": "./ets/getnamedpropertyability/GetnamedpropertyAbility.ets", - "description": "$string:GetnamedpropertyAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetnamedpropertyAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/string.json deleted file mode 100755 index 28dc2bcede..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetnamedpropertyAbility_desc", - "value": "description" - }, - { - "name": "GetnamedpropertyAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 1e520633c0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetNamedProperty', 0, async (done: Function) => { - console.log('uitest: TestGetNamedProperty begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetnamedpropertyAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetnamedpropertyAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetNamedProperty end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/module.json5 deleted file mode 100755 index ed90c4453f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getnamedproperty/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getnamedproperty_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/oh-package.json5 deleted file mode 100755 index d62f4faafb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getproperty", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetproperty.so": "file:./src/main/cpp/types/libgetproperty" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/CMakeLists.txt deleted file mode 100755 index b2e21e59a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutPropertyOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getproperty SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/hello.cpp deleted file mode 100755 index d785e7aba4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_get_property] -// OH_JSVM_GetProperty的样例方法 -static JSVM_Value GetProperty(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 接收两个js传来的参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 传入的第一个参数为要检测的object,第二个对象为要检测的属性,通过调用OH_JSVM_GetProperty接口获取对应的值 - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_GetProperty(env, args[0], args[1], &result); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_GetProperty fail"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetProperty success"); - } - return result; -} -// GetProperty注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetProperty}, -}; -static JSVM_CallbackStruct *method = param; -// GetProperty方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let obj = { data: 0, message: "hello world", 50: 1}; - getProperty(obj, "message") -)JS"; -// [End oh_jsvm_get_property] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getproperty", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/oh-package.json5 deleted file mode 100755 index c1cc0732f9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/cpp/types/libgetproperty/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/pages/Index.ets deleted file mode 100755 index bb407c5156..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetproperty.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/module.json5 deleted file mode 100755 index d7faca32c1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getproperty", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetpropertyAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetpropertyAbility", - "srcEntry": "./ets/getpropertyability/GetpropertyAbility.ets", - "description": "$string:GetpropertyAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetpropertyAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/string.json deleted file mode 100755 index 991a2e032c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetpropertyAbility_desc", - "value": "description" - }, - { - "name": "GetpropertyAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 925a0a45b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetProperty', 0, async (done: Function) => { - console.log('uitest: TestGetProperty begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetpropertyAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetpropertyAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetProperty end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/module.json5 deleted file mode 100755 index 8f068374c5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getproperty/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getproperty_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/oh-package.json5 deleted file mode 100755 index 5eb4ffe7a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getpropertynames", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetpropertynames.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 40d7eb68ac..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutPropertyOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getpropertynames SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getpropertynames PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/hello.cpp deleted file mode 100755 index e55e090e57..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_get_property_names] -// OH_JSVM_GetPropertyNames的样例方法 -static JSVM_Value GetPropertyNames(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 将obj作为参数传入 - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 以字符串数组的形式获取对象的可枚举属性的名称,以result传出 - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_GetPropertyNames(env, args[0], &result); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "Failed to get propertynames"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetPropertyNames success"); - } - return result; -} -// GetPropertyNames注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetPropertyNames}, -}; -static JSVM_CallbackStruct *method = param; -// GetPropertyNames方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getPropertyNames", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let obj = '{ data: 0, message: "hello world"}'; - let script = getPropertyNames(obj); -)JS"; -// [End oh_jsvm_get_property_names] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getpropertynames", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index e7873e47f5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetpropertynames.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/pages/Index.ets deleted file mode 100755 index 2d31a4f3d5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetpropertynames.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/module.json5 deleted file mode 100755 index 5e8d998cf9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "getpropertynames", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/string.json deleted file mode 100755 index 1e3b82db3d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 1025092173..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetPropertyNames', 0, async (done: Function) => { - console.log('uitest: TestGetPropertyNames begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetPropertyNames end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/module.json5 deleted file mode 100755 index 393cda5ff4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/getpropertynames/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getpropertynames_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/oh-package.json5 deleted file mode 100755 index b147d9a194..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "hasnamedproperty", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libhasnamedproperty.so": "file:./src/main/cpp/types/libhasnamedproperty" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/CMakeLists.txt deleted file mode 100755 index acaeb0b41a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutProperty) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(hasnamedproperty SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(hasnamedproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/hello.cpp deleted file mode 100755 index a350001301..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/hello.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_has_named_property] -// OH_JSVM_HasNamedProperty的样例方法 -const size_t STR_KEY_LEN = 32; -static JSVM_Value HasNamedProperty(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取js侧传入的两个参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - char strKey[STR_KEY_LEN] = ""; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 获取要检查的属性名 - size_t keyLength; - OH_JSVM_GetValueStringUtf8(env, args[1], strKey, STR_KEY_LEN, &keyLength); - // 检查对象是否具有指定命名的属性,并将结果存储在hasProperty中 - bool hasProperty = false; - JSVM_Status status = OH_JSVM_HasNamedProperty(env, args[0], strKey, &hasProperty); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_HasNamedProperty failed"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_HasNamedProperty success:%{public}d", hasProperty); - } - // 将bool结果转换为JSVM_Value并返回 - JSVM_Value result; - OH_JSVM_GetBoolean(env, hasProperty, &result); - return result; -} -// HasNamedProperty注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = HasNamedProperty}, -}; -static JSVM_CallbackStruct *method = param; -// HasNamedProperty方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"hasNamedProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let obj = { data: 0, message: "hello world", 50: 1}; - hasNamedProperty(obj, "message") -)JS"; -// [End oh_jsvm_has_named_property] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "hasnamedproperty", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/oh-package.json5 deleted file mode 100755 index cb23934b92..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/cpp/types/libhasnamedproperty/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libhasnamedproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/pages/Index.ets deleted file mode 100755 index 98ca9e16cc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libhasnamedproperty.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/module.json5 deleted file mode 100755 index a5342e7d10..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "hasnamedproperty", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "HasnamedpropertyAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "HasnamedpropertyAbility", - "srcEntry": "./ets/hasnamedpropertyability/HasnamedpropertyAbility.ets", - "description": "$string:HasnamedpropertyAbility_desc", - "icon": "$media:layered_image", - "label": "$string:HasnamedpropertyAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/string.json deleted file mode 100755 index 854f880b51..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "HasnamedpropertyAbility_desc", - "value": "description" - }, - { - "name": "HasnamedpropertyAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 4a3fa1b8d4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testHasNamedProperty', 0, async (done: Function) => { - console.log('uitest: TestHasNamedProperty begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'HasnamedpropertyAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('HasnamedpropertyAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestHasNamedProperty end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/module.json5 deleted file mode 100755 index 61889a6030..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasnamedproperty/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "hasnamedproperty_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/oh-package.json5 deleted file mode 100755 index 68bf6e7bde..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "hasownproperty", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libhasownproperty.so": "file:./src/main/cpp/types/libhasownproperty" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 8840d15b89..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutProperty) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(hasownproperty SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(hasownproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/hello.cpp deleted file mode 100755 index 325270cfe3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/hello.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_has_own_property] -// OH_JSVM_HasOwnProperty的样例方法 -static JSVM_Value HasOwnProperty(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取js侧传入的两个参数 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 检查第一个参数是否为对象 - JSVM_ValueType valueType1; - OH_JSVM_Typeof(env, args[0], &valueType1); - if (valueType1 != JSVM_OBJECT) { - OH_JSVM_ThrowError(env, nullptr, "First argument must be an object."); - return nullptr; - } - // 检查第二个参数是否为string - JSVM_ValueType valuetype2; - OH_JSVM_Typeof(env, args[1], &valuetype2); - if (valuetype2 != JSVM_STRING) { - OH_JSVM_ThrowError(env, nullptr, "Second argument must be a string."); - return nullptr; - } - // 检查对象是否具有指定属性,结果存储在hasProperty中 - bool hasProperty; - JSVM_Status status = OH_JSVM_HasOwnProperty(env, args[0], args[1], &hasProperty); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_HasOwnProperty failed"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_HasOwnProperty success:%{public}d", hasProperty); - } - // 将bool结果转换为JSVM_Value并返回 - JSVM_Value result; - OH_JSVM_GetBoolean(env, hasProperty, &result); - return result; -} -// HasOwnProperty注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = HasOwnProperty}, -}; -static JSVM_CallbackStruct *method = param; -// HasOwnProperty方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"hasOwnProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let obj = { data: 0, message: "hello world", 50: 1}; - hasOwnProperty(obj, "message") - hasOwnProperty(obj, "__defineGetter__") -)JS"; -// [End oh_jsvm_has_own_property] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "hasownproperty", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/oh-package.json5 deleted file mode 100755 index 328049443f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/cpp/types/libhasownproperty/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libhasownproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/pages/Index.ets deleted file mode 100755 index 2f7168def6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libhasownproperty.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/module.json5 deleted file mode 100755 index 153fbb77ea..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "hasownproperty", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "HasownpropertyAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "HasownpropertyAbility", - "srcEntry": "./ets/hasownpropertyability/HasownpropertyAbility.ets", - "description": "$string:HasownpropertyAbility_desc", - "icon": "$media:layered_image", - "label": "$string:HasownpropertyAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/string.json deleted file mode 100755 index acc7ad4e1c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "HasownpropertyAbility_desc", - "value": "description" - }, - { - "name": "HasownpropertyAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 2f25df1f3b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testHasOwnProperty', 0, async (done: Function) => { - console.log('uitest: TestHasOwnProperty begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'HasownpropertyAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('HasownpropertyAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestHasOwnProperty end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/module.json5 deleted file mode 100755 index dda4c6cac6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasownproperty/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "hasownproperty_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/oh-package.json5 deleted file mode 100755 index ad61c4038d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "hasproperty", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libhasproperty.so": "file:./src/main/cpp/types/libhasproperty" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 468ac51837..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutPropertyOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(hasproperty SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(hasproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/hello.cpp deleted file mode 100755 index 413028d04b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/hello.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_has_property] -// OH_JSVM_HasProperty的样例方法 -static JSVM_Value HasProperty(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 从js侧传入两个参数:第一个参数为要检验的对象,第二个参数为要检测是否存在对象的属性 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 将参数传入OH_JSVM_HasProperty方法中,若接口调用成功则将结果转化为JSVM_Value类型抛出,否则抛出错误 - bool result; - JSVM_Status status = OH_JSVM_HasProperty(env, args[0], args[1], &result); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_HasProperty fail"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_HasProperty success:%{public}d", result); - } - // 若传入属性存在传入对象中,则输出true将结果转化为JSVM_Value类型抛出 - JSVM_Value returnReslut = nullptr; - OH_JSVM_GetBoolean(env, result, &returnReslut); - return returnReslut; -} -// HasProperty注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = HasProperty}, -}; -static JSVM_CallbackStruct *method = param; -// HasProperty方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"hasProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let obj = { data: 0, message: "hello world", 50: 1}; - hasProperty(obj, "data") - hasProperty(obj, 0) -)JS"; -// [End oh_jsvm_has_property] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "hasproperty", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/oh-package.json5 deleted file mode 100755 index 745046399b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/cpp/types/libhasproperty/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libhasproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/pages/Index.ets deleted file mode 100755 index 54a365db06..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libhasproperty.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/module.json5 deleted file mode 100755 index f2d743b927..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "hasproperty", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "HaspropertyAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "HaspropertyAbility", - "srcEntry": "./ets/haspropertyability/HaspropertyAbility.ets", - "description": "$string:HaspropertyAbility_desc", - "icon": "$media:layered_image", - "label": "$string:HaspropertyAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/string.json deleted file mode 100755 index d4283ee7ba..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "HaspropertyAbility_desc", - "value": "description" - }, - { - "name": "HaspropertyAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 34a080c52d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testHasProperty', 0, async (done: Function) => { - console.log('uitest: TestHasProperty begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'HaspropertyAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('HaspropertyAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestHasProperty end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/module.json5 deleted file mode 100755 index 52307b1f3c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hasproperty/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "hasproperty_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/ohosTest.md deleted file mode 100755 index c3f113be44..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/ohosTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# JsvmAboutProperty 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 批量的向给定对象中定义属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 用给定的属性的名称,删除目标对象属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定对象的所有可用属性名称 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 用给定的属性的名称,检索目标对象的属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 用给定的属性的名称,检索目标对象的属性,此方法等效于调用Hello World | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定对象的所有可枚举属性名称 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 用给定的属性的名称,查询目标对象是否有此属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 判断给定Object中是否有名为key的own property | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 用给定的属性的名称,查询目标对象是否有此属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 为给定对象设置一个属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 用给定的属性的名称为目标对象设置属性 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/oh-package.json5 deleted file mode 100755 index 7db23ca0ac..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "setnamedproperty", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libsetnamedproperty.so": "file:./src/main/cpp/types/libsetnamedproperty" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/CMakeLists.txt deleted file mode 100755 index f55e742841..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutProperty) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(setnamedproperty SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(setnamedproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/hello.cpp deleted file mode 100755 index e105db29e0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/hello.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_set_named_property] -// OH_JSVM_SetNamedProperty的样例方法 -const size_t STR_KEY_LEN = 32; -static JSVM_Value SetNamedProperty(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取js侧传入的一个参数 - size_t argc = 1; - JSVM_Value str; - char strKey[STR_KEY_LEN] = ""; - OH_JSVM_GetCbInfo(env, info, &argc, &str, nullptr, nullptr); - // 获取传入参数字符串并存储在strKey中 - size_t keyLength; - OH_JSVM_GetValueStringUtf8(env, str, strKey, STR_KEY_LEN, &keyLength); - // 创建一个新对象 - JSVM_Value newObj; - OH_JSVM_CreateObject(env, &newObj); - // 设置整数值1234为属性值 - int32_t value = 1234; - JSVM_Value numValue; - OH_JSVM_CreateInt32(env, value, &numValue); - // 将整数值与指定属性名关联 - JSVM_Status status = OH_JSVM_SetNamedProperty(env, newObj, strKey, numValue); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_SetNamedProperty failed"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_SetNamedProperty success"); - } - // 返回新创建并设置命名属性的对象 - return newObj; -} -// SetNamedProperty注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = SetNamedProperty}, -}; -static JSVM_CallbackStruct *method = param; -// SetNamedProperty方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"setNamedProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - setNamedProperty("message") -)JS"; -// [End oh_jsvm_set_named_property] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "setnamedproperty", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/oh-package.json5 deleted file mode 100755 index 52424be521..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/cpp/types/libsetnamedproperty/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libsetnamedproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/pages/Index.ets deleted file mode 100755 index 89c81be87c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libsetnamedproperty.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/module.json5 deleted file mode 100755 index fa82914354..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "setnamedproperty", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "SetnamedpropertyAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "SetnamedpropertyAbility", - "srcEntry": "./ets/setnamedpropertyability/SetnamedpropertyAbility.ets", - "description": "$string:SetnamedpropertyAbility_desc", - "icon": "$media:layered_image", - "label": "$string:SetnamedpropertyAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/string.json deleted file mode 100755 index 2787b15d5d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "SetnamedpropertyAbility_desc", - "value": "description" - }, - { - "name": "SetnamedpropertyAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 46909e12c0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testSetNamedProperty', 0, async (done: Function) => { - console.log('uitest: TestSetNamedProperty begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'SetnamedpropertyAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('SetnamedpropertyAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestSetNamedProperty end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/module.json5 deleted file mode 100755 index fafc3e927a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setnamedproperty/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "setnamedproperty_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/oh-package.json5 deleted file mode 100755 index 5a748a07ab..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "setproperty", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libsetproperty.so": "file:./src/main/cpp/types/libsetproperty" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 865164b58b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutPropertyOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(setproperty SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(setproperty PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/hello.cpp deleted file mode 100755 index 663f72a97f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/hello.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_set_property] -// OH_JSVM_SetProperty的样例方法 -static JSVM_Value SetProperty(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 接收js侧传入的三个参数:第一个参数为想要设置的object,第二个参数为属性,第三个参数为属性对应的值 - size_t argc = 3; - JSVM_Value args[3] = {nullptr}; - JSVM_Status status = OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_GetCbInfo fail"); - return nullptr; - } - // 通过调用OH_JSVM_SetProperty接口将属性与值设置入object如果失败,直接抛出错误 - status = OH_JSVM_SetProperty(env, args[0], args[1], args[2]); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "JSVM OH_JSVM_SetProperty fail"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_SetProperty success"); - } - // 将设置成功后的object返回出去 - return args[0]; -} -// SetProperty注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = SetProperty}, -}; -static JSVM_CallbackStruct *method = param; -// SetProperty方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"setProperty", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let obj = { data: 0, message: "hello world", 50: 1}; - setProperty(obj, "code", "hi") -)JS"; -// [End oh_jsvm_set_property] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "setproperty", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/oh-package.json5 deleted file mode 100755 index 5a92aab963..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/cpp/types/libsetproperty/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libsetproperty.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/pages/Index.ets deleted file mode 100755 index 84761ef743..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libsetproperty.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/module.json5 deleted file mode 100755 index fb11038147..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "setproperty", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "SetpropertyAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "SetpropertyAbility", - "srcEntry": "./ets/setpropertyability/SetpropertyAbility.ets", - "description": "$string:SetpropertyAbility_desc", - "icon": "$media:layered_image", - "label": "$string:SetpropertyAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/string.json deleted file mode 100755 index 6aa980d30a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "SetpropertyAbility_desc", - "value": "description" - }, - { - "name": "SetpropertyAbility_label", - "value": "JsvmAboutProperty" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index c061efc63a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testSetProperty', 0, async (done: Function) => { - console.log('uitest: TestSetProperty begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'SetpropertyAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('SetpropertyAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestSetProperty end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/module.json5 deleted file mode 100755 index ea13358c3e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty/setproperty/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "setproperty_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/app.json5 deleted file mode 100755 index 48d4bd983d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmaboutstring", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/element/string.json deleted file mode 100755 index a42a2fba6a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmAboutString" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/README.md deleted file mode 100755 index 6d5f7f5f95..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/README.md +++ /dev/null @@ -1,173 +0,0 @@ -# ArkTs使用JSVM-API接口创建和获取string值 - -### 介绍 - -使用JSVM-API接口获取和设置JavaScript对象的属性。通过合理使用这些函数,实现更复杂的功能和逻辑。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口创建和获取string值](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-string.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :-----------------------------------------------------------------: | :-----------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -createstringlatin1/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createstringutf8/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createstringutf16/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvaluestringlatin1/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvaluestringutf8/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvaluestringutf16/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/build-profile.json5 deleted file mode 100755 index d8f9f6ecb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/build-profile.json5 +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "getvaluestringutf8", - "srcPath": "./getvaluestringutf8", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createstringutf8", - "srcPath": "./createstringutf8", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getvaluestringutf16", - "srcPath": "./getvaluestringutf16", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createstringutf16", - "srcPath": "./createstringutf16", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getvaluestringlatin1", - "srcPath": "./getvaluestringlatin1", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createstringlatin1", - "srcPath": "./createstringlatin1", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/oh-package.json5 deleted file mode 100755 index d9a696fcd8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createstringlatin1", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatestringlatin1.so": "file:./src/main/cpp/types/libcreatestringlatin1" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/CMakeLists.txt deleted file mode 100755 index d52859a2bf..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutString) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createstringlatin1 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createstringlatin1 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/hello.cpp deleted file mode 100755 index 1a292bed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/hello.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_string_latin1] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -#include -// [StartExclude oh_jsvm_create_string_latin1] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_string_latin1] - -// CreateStringLatin1注册回调 -// 定义字符串缓冲区的最大长度 -static const int MAX_BUFFER_SIZE = 128; -// OH_JSVM_CreateStringLatin1的样例方法 -static JSVM_Value CreateStringLatin1(JSVM_Env env, JSVM_CallbackInfo info) -{ - const char *str = "Hello, World! éçñ, successes to create Latin1 string!"; - size_t length = JSVM_AUTO_LENGTH; - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_CreateStringLatin1(env, str, length, &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateStringLatin1 fail"); - } else { - char buf[MAX_BUFFER_SIZE]; - size_t lengthInner; - OH_JSVM_GetValueStringLatin1(env, result, buf, MAX_BUFFER_SIZE, &lengthInner); - OH_LOG_INFO(LOG_APP, "JSVM CreateStringLatin1 success: %{public}s", buf); - } - return result; -} -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateStringLatin1}, -}; -static JSVM_CallbackStruct *method = param; -// CreateStringLatin1方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createStringLatin1", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let script = createStringLatin1(); -)JS"; -// [End oh_jsvm_create_string_latin1] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createstringlatin1", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/oh-package.json5 deleted file mode 100755 index 2fcc5928d5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/cpp/types/libcreatestringlatin1/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatestringlatin1.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/pages/Index.ets deleted file mode 100755 index f75a6592ea..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatestringlatin1.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/module.json5 deleted file mode 100755 index 8a7e0c8372..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createstringlatin1", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Createstringlatin1Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Createstringlatin1Ability", - "srcEntry": "./ets/createstringlatin1ability/Createstringlatin1Ability.ets", - "description": "$string:Createstringlatin1Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Createstringlatin1Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/string.json deleted file mode 100755 index c65d6b2c39..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Createstringlatin1Ability_desc", - "value": "description" - }, - { - "name": "Createstringlatin1Ability_label", - "value": "JsvmAboutString" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 5766f9d48d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateStringLatin1', 0, async (done: Function) => { - console.log('uitest: TestCreateStringLatin1 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Createstringlatin1Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Createstringlatin1Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateStringLatin1 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/module.json5 deleted file mode 100755 index b17ba92206..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringlatin1/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createstringlatin1_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/oh-package.json5 deleted file mode 100755 index dd734e0931..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createstringutf16", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatestringutf16.so": "file:./src/main/cpp/types/libcreatestringutf16" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 04d44dd785..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutString) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createstringutf16 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createstringutf16 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/hello.cpp deleted file mode 100755 index 5c45e7a12a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/hello.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_string_utf16] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -#include -#include -#include -// [StartExclude oh_jsvm_create_string_utf16] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_string_utf16] - -// OH_JSVM_CreateStringUtf16的样例方法 -static JSVM_Value CreateStringUtf16(JSVM_Env env, JSVM_CallbackInfo info) -{ - const char16_t *str = u"你好, World!, successes to create UTF-16 string!"; - std::u16string ustr(str); - size_t length = ustr.length(); - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_CreateStringUtf16(env, str, length, &result); - std::u16string u16str = {str}; - // 将 std::u16string 转换为 std::string - std::wstring_convert, char16_t> converter; - std::string strResult = converter.to_bytes(u16str); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateStringUtf16 fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateStringUtf16 success: %{public}s", strResult.c_str()); - } - return result; -} -// CreateStringUtf16注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateStringUtf16}, -}; -static JSVM_CallbackStruct *method = param; -// CreateStringUtf16方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createStringUtf16", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let script = createStringUtf16(); -)JS"; -// [End oh_jsvm_create_string_utf16] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createstringutf16", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/oh-package.json5 deleted file mode 100755 index 261f04720c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/cpp/types/libcreatestringutf16/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatestringutf16.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/pages/Index.ets deleted file mode 100755 index cb96f822f1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatestringutf16.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/module.json5 deleted file mode 100755 index 3035bf6331..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createstringutf16", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Createstringutf16Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Createstringutf16Ability", - "srcEntry": "./ets/createstringutf16ability/Createstringutf16Ability.ets", - "description": "$string:Createstringutf16Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Createstringutf16Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/string.json deleted file mode 100755 index b782589bd5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Createstringutf16Ability_desc", - "value": "description" - }, - { - "name": "Createstringutf16Ability_label", - "value": "JsvmAboutString" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 9bd8b87611..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateStringUtf16', 0, async (done: Function) => { - console.log('uitest: TestCreateStringUtf16 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Createstringutf16Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Createstringutf16Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateStringUtf16 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/module.json5 deleted file mode 100755 index 0228657d5d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf16/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createstringutf16_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/oh-package.json5 deleted file mode 100755 index 4ee14447f0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createstringutf8", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatestringutf8.so": "file:./src/main/cpp/types/libcreatestringutf8" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 3028ef0c41..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutString) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createstringutf8 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createstringutf8 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/hello.cpp deleted file mode 100755 index ae1b9e4656..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/hello.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_string_utf8] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -#include -// [StartExclude oh_jsvm_create_string_utf8] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_string_utf8] - -// OH_JSVM_CreateStringUtf8的样例方法 -static JSVM_Value CreateStringUtf8(JSVM_Env env, JSVM_CallbackInfo info) -{ - const char *str = u8"你好, World!, successes to create UTF-8 string!"; - size_t length = strlen(str); - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_CreateStringUtf8(env, str, length, &result); - if (status != JSVM_OK) { - OH_JSVM_ThrowError(env, nullptr, "Failed to create UTF-8 string"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM CreateStringUtf8 success: %{public}s", str); - } - return result; -} -// CreateStringUtf8注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateStringUtf8}, -}; -static JSVM_CallbackStruct *method = param; -// CreateStringUtf8方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createStringUtf8", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let script = createStringUtf8(); -)JS"; -// [End oh_jsvm_create_string_utf8] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createstringutf8", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/oh-package.json5 deleted file mode 100755 index dcc507b436..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/cpp/types/libcreatestringutf8/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatestringutf8.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/pages/Index.ets deleted file mode 100755 index b1844cdeaf..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatestringutf8.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/module.json5 deleted file mode 100755 index f2d88c25dd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createstringutf8", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Createstringutf8Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Createstringutf8Ability", - "srcEntry": "./ets/createstringutf8ability/Createstringutf8Ability.ets", - "description": "$string:Createstringutf8Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Createstringutf8Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/string.json deleted file mode 100755 index 963d2bd8ac..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Createstringutf8Ability_desc", - "value": "description" - }, - { - "name": "Createstringutf8Ability_label", - "value": "JsvmAboutString" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index f5e56b4c89..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateStringUtf8', 0, async (done: Function) => { - console.log('uitest: TestCreateStringUtf8 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Createstringutf8Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Createstringutf8Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateStringUtf8 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/module.json5 deleted file mode 100755 index f273d80b98..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/createstringutf8/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createstringutf8_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/oh-package.json5 deleted file mode 100755 index 2fe9c61070..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvaluestringlatin1", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvaluestringlatin1.so": "file:./src/main/cpp/types/libgetvaluestringlatin1" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 2e51e58bd6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutString) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getvaluestringlatin1 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvaluestringlatin1 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/hello.cpp deleted file mode 100755 index 22ae0ae914..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/hello.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_string_latin1] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -#include -// [StartExclude oh_jsvm_get_value_string_latin1] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_string_latin1] - -// OH_JSVM_GetValueStringLatin1的样例方法 -// 定义字符串缓冲区的最大长度 -static const int MAX_BUFFER_SIZE = 128; -static JSVM_Value GetValueStringLatin1(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - char buf[MAX_BUFFER_SIZE]; - size_t length; - JSVM_Value jsvmRes = nullptr; - JSVM_Status status = OH_JSVM_GetValueStringLatin1(env, args[0], buf, MAX_BUFFER_SIZE, &length); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetValueStringLatin1 fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetValueStringLatin1 success: %{public}s", buf); - } - OH_JSVM_CreateStringLatin1(env, buf, length, &jsvmRes); - return jsvmRes; -} -// GetValueStringLatin1注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetValueStringLatin1}, -}; -static JSVM_CallbackStruct *method = param; -// GetValueStringLatin1方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getValueStringLatin1", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let data = "中文"; - let script = getValueStringLatin1(data); -)JS"; -// [End oh_jsvm_get_value_string_latin1] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvaluestringlatin1", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/oh-package.json5 deleted file mode 100755 index b638ae2d9d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/cpp/types/libgetvaluestringlatin1/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvaluestringlatin1.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/pages/Index.ets deleted file mode 100755 index 8595933ac7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvaluestringlatin1.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/module.json5 deleted file mode 100755 index 0f215e4319..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getvaluestringlatin1", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Getvaluestringlatin1Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Getvaluestringlatin1Ability", - "srcEntry": "./ets/getvaluestringlatin1ability/Getvaluestringlatin1Ability.ets", - "description": "$string:Getvaluestringlatin1Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Getvaluestringlatin1Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/string.json deleted file mode 100755 index 2f6c38297f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Getvaluestringlatin1Ability_desc", - "value": "description" - }, - { - "name": "Getvaluestringlatin1Ability_label", - "value": "JsvmAboutString" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 999d3ab43c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueStringLatin1', 0, async (done: Function) => { - console.log('uitest: TestGetValueStringLatin1 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Getvaluestringlatin1Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Getvaluestringlatin1Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueStringLatin1 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/module.json5 deleted file mode 100755 index b031af5499..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringlatin1/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvaluestringlatin1_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/oh-package.json5 deleted file mode 100755 index 41bff22cfc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvaluestringutf16", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvaluestringutf16.so": "file:./src/main/cpp/types/libgetvaluestringutf16" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 0a3dadf924..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutString) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getvaluestringutf16 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvaluestringutf16 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/hello.cpp deleted file mode 100755 index 3775a2734a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/hello.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_string_utf16] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -#include -#include -#include -// [StartExclude oh_jsvm_get_value_string_utf16] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_string_utf16] - -// OH_JSVM_GetValueStringUtf16的样例方法 -// 定义字符串缓冲区的最大长度 -static const int MAX_BUFFER_SIZE = 128; -static JSVM_Value GetValueStringUtf16(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - JSVM_Value result = nullptr; - size_t length = 0; - char16_t buffer[MAX_BUFFER_SIZE] = {0}; - // 字符串的缓冲区大小 - size_t bufferSize = MAX_BUFFER_SIZE; - JSVM_Status status = OH_JSVM_GetValueStringUtf16(env, args[0], buffer, bufferSize, &length); - // 将 char16_t 转换为 std::u16string - std::u16string u16str = {buffer}; - // 将 std::u16string 转换为 std::string - std::wstring_convert, char16_t> converter; - std::string str = converter.to_bytes(u16str); - // 获取字符串返回结果 - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetValueStringUtf16 fail"); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetValueStringUtf16 success: %{public}s", str.c_str()); - } - return result; -} -// GetValueStringUtf16注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetValueStringUtf16}, -}; -static JSVM_CallbackStruct *method = param; -// GetValueStringUtf16方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getValueStringUtf16", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let data = "ahello。"; - let script = getValueStringUtf16(data); -)JS"; -// [End oh_jsvm_get_value_string_utf16] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvaluestringutf16", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/oh-package.json5 deleted file mode 100755 index 2cb3cff955..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/cpp/types/libgetvaluestringutf16/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvaluestringutf16.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/pages/Index.ets deleted file mode 100755 index 64ce337e1c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvaluestringutf16.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/module.json5 deleted file mode 100755 index 56a8ad2fc7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getvaluestringutf16", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Getvaluestringutf16Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Getvaluestringutf16Ability", - "srcEntry": "./ets/getvaluestringutf16ability/Getvaluestringutf16Ability.ets", - "description": "$string:Getvaluestringutf16Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Getvaluestringutf16Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/string.json deleted file mode 100755 index 4a8e3f92aa..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Getvaluestringutf16Ability_desc", - "value": "description" - }, - { - "name": "Getvaluestringutf16Ability_label", - "value": "JsvmAboutString" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 7233ac3afc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueStringUtf16', 0, async (done: Function) => { - console.log('uitest: TestGetValueStringUtf16 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Getvaluestringutf16Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Getvaluestringutf16Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueStringUtf16 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/module.json5 deleted file mode 100755 index 792288067a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf16/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvaluestringutf16_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/oh-package.json5 deleted file mode 100755 index fbff5ac8d7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvaluestringutf8", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvaluestringutf8.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 2f3e9c8fee..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmAboutString) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getvaluestringutf8 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvaluestringutf8 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/hello.cpp deleted file mode 100755 index 6ff3ff67a1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/hello.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_string_utf8] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -#include -// [StartExclude oh_jsvm_get_value_string_utf8] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" -#define MAX_MALLOC_SIZE 0x800000 - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_string_utf8] - -// OH_JSVM_GetValueStringUtf8的样例方法 -static JSVM_Value GetValueStringUtf8(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - size_t length = 0; - JSVM_Status status = OH_JSVM_GetValueStringUtf8(env, args[0], nullptr, 0, &length); - if (length == 0 || length > MAX_MALLOC_SIZE) { - OH_LOG_ERROR(LOG_APP, "Invalid string length: %{public}zu", length); - return jsVmResult; - } - char *buf = (char *)malloc(length + 1); - status = OH_JSVM_GetValueStringUtf8(env, args[0], buf, length + 1, &length); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetValueStringUtf8 fail"); - free(buf); - return nullptr; - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetValueStringUtf8 success: %{public}s", buf); - } - JSVM_Value result = nullptr; - OH_JSVM_CreateStringUtf8(env, buf, length, &result); - free(buf); - return result; -} -// GetValueStringUtf8注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetValueStringUtf8}, -}; -static JSVM_CallbackStruct *method = param; -// GetValueStringUtf8方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getValueStringUtf8", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS( - let data = "aaBC+-$%^你好123"; - let script = getValueStringUtf8(data); -)JS"; -// [End oh_jsvm_get_value_string_utf8] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvaluestringutf8", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index cb5b309524..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvaluestringutf8.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/pages/Index.ets deleted file mode 100755 index 8c286a1d51..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvaluestringutf8.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/module.json5 deleted file mode 100755 index 2b73a31dd5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "getvaluestringutf8", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/string.json deleted file mode 100755 index db834031ce..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmAboutString" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index badaf0048c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueStringUtf8', 0, async (done: Function) => { - console.log('uitest: TestGetValueStringUtf8 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueStringUtf8 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/module.json5 deleted file mode 100755 index 67e5e8f720..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/getvaluestringutf8/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvaluestringutf8_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/ohosTest.md deleted file mode 100755 index 9688268b6e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmAboutString/ohosTest.md +++ /dev/null @@ -1,13 +0,0 @@ -# JsvmAboutString 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 获取给定JavaScript string对象的Utf8编码字符串 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 根据Utf8编码的字符串创建一个JavaScript string对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定JavaScript string对象的Utf16编码字符串 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 根据Utf16编码的字符串数据创建JavaScript string对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定JavaScript string对象的Latin1编码字符串 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 根据Latin-1编码的字符串创建一个JavaScript string对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/app.json5 deleted file mode 100755 index 0b2352e53d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmbasicdatatypes", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/element/string.json deleted file mode 100755 index 07b4432806..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmBasicDataTypes" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/README.md deleted file mode 100755 index ae3feb8425..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/README.md +++ /dev/null @@ -1,213 +0,0 @@ -# ArkTS使用JSVM-API接口创建基本数据类型 - -### 介绍 - -在JavaScript中,整数类型是一种基本数据类型,用于表示没有小数部分的数值。double类型用于表示有小数的数值。JavaScript的数值存储方式会导致在某些情况下无法准确表示非常大或非常小的数值,在这种情况下,需要使用BigInt对应的JSVM-API接口来处理更大范围的整数。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口创建基本数据类型](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-basic-data-types.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :--------------------------------------------------------------------: | :--------------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World ,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -createdouble/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createint32/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createint64/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createuint32/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvaluedouble/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvalueint32/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvalueint64/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvalueuint32/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/build-profile.json5 deleted file mode 100755 index 7592cbeea8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/build-profile.json5 +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "getvalueuint32", - "srcPath": "./getvalueuint32", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getvalueint32", - "srcPath": "./getvalueint32", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getvalueint64", - "srcPath": "./getvalueint64", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getvaluedouble", - "srcPath": "./getvaluedouble", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createint32", - "srcPath": "./createint32", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createuint32", - "srcPath": "./createuint32", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createint64", - "srcPath": "./createint64", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createdouble", - "srcPath": "./createdouble", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/code-linter.json5 deleted file mode 100755 index 6908a38b9f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/code-linter.json5 +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - "@security/no-unsafe-aes": "error", - "@security/no-unsafe-hash": "error", - "@security/no-unsafe-mac": "warn", - "@security/no-unsafe-dh": "error", - "@security/no-unsafe-dsa": "error", - "@security/no-unsafe-ecdsa": "error", - "@security/no-unsafe-rsa-encrypt": "error", - "@security/no-unsafe-rsa-sign": "error", - "@security/no-unsafe-rsa-key": "error", - "@security/no-unsafe-dsa-key": "error", - "@security/no-unsafe-dh-key": "error", - "@security/no-unsafe-3des": "error" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/oh-package.json5 deleted file mode 100755 index 2ffad1e6ab..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createdouble", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatedouble.so": "file:./src/main/cpp/types/libcreatedouble" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 8defe1820f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createdouble SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createdouble PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/hello.cpp deleted file mode 100755 index a43da1bb0a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/hello.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_double] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_create_double] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_double] - -// OH_JSVM_CreateDouble的样例方法 -static JSVM_Value CreateDouble(JSVM_Env env, JSVM_CallbackInfo info) -{ - double value = 1.234; - // 创建JavaScript中的double数字 - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_CreateDouble(env, value, &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateDouble fail"); - } else { - double number = 0; - OH_JSVM_GetValueDouble(env, result, &number); - OH_LOG_INFO(LOG_APP, "JSVM CreateDouble success: %{public}f", number); - } - return result; -} - -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateDouble}, -}; -static JSVM_CallbackStruct *method = param; -// CreateDouble方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createDouble", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(createDouble())JS"; -// [End oh_jsvm_create_double] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createdouble", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/oh-package.json5 deleted file mode 100755 index 3fb55a4452..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/cpp/types/libcreatedouble/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatedouble.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/pages/Index.ets deleted file mode 100755 index 2d32bc429f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatedouble.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/module.json5 deleted file mode 100755 index e67fe2313c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createdouble", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreatedoubleAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreatedoubleAbility", - "srcEntry": "./ets/createdoubleability/CreatedoubleAbility.ets", - "description": "$string:CreatedoubleAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreatedoubleAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/float.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/float.json deleted file mode 100755 index a8a5d404dc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/string.json deleted file mode 100755 index 443e20337b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreatedoubleAbility_desc", - "value": "description" - }, - { - "name": "CreatedoubleAbility_label", - "value": "JsvmBasicDataTypes" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index da0bb7758f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateDouble', 0, async (done: Function) => { - console.log('uitest: TestCreateDouble begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreatedoubleAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreatedoubleAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateDouble end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/module.json5 deleted file mode 100755 index 55ac2b0448..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createdouble/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createdouble_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/oh-package.json5 deleted file mode 100755 index 3ddb6a7f84..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createint32", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreateint32.so": "file:./src/main/cpp/types/libcreateint32" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/CMakeLists.txt deleted file mode 100755 index b4b5138d8c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createint32 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createint32 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/hello.cpp deleted file mode 100755 index 669c52c347..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/hello.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_int32] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_create_int32] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_int32] - -// OH_JSVM_CreateInt32的样例方法 -static JSVM_Value CreateInt32(JSVM_Env env, JSVM_CallbackInfo info) -{ - int32_t value = -20; - // 创建JavaScript中的int32数字 - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_CreateInt32(env, value, &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateInt32 fail"); - } else { - int32_t number = 0; - OH_JSVM_GetValueInt32(env, result, &number); - OH_LOG_INFO(LOG_APP, "JSVM CreateInt32 success: %{public}d", number); - } - return result; -} - -// CreateInt32注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateInt32}, -}; -static JSVM_CallbackStruct *method = param; -// CreateInt32方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createInt32", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(createInt32())JS"; -// [End oh_jsvm_create_int32] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createint32", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/oh-package.json5 deleted file mode 100755 index 7e936c3553..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/cpp/types/libcreateint32/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreateint32.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/pages/Index.ets deleted file mode 100755 index 32f5bc185c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreateint32.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/module.json5 deleted file mode 100755 index dfcde23da2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createint32", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Createint32Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Createint32Ability", - "srcEntry": "./ets/createint32ability/Createint32Ability.ets", - "description": "$string:Createint32Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Createint32Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/float.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/float.json deleted file mode 100755 index a8a5d404dc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/string.json deleted file mode 100755 index 4952ec019e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Createint32Ability_desc", - "value": "description" - }, - { - "name": "Createint32Ability_label", - "value": "JsvmBasicDataTypes" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index b69e5b4143..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateInt32', 0, async (done: Function) => { - console.log('uitest: TestCreateInt32 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Createint32Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Createint32Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateInt32 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/module.json5 deleted file mode 100755 index 991d61fd96..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint32/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createint32_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/oh-package.json5 deleted file mode 100755 index a10a43543c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createint64", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreateint64.so": "file:./src/main/cpp/types/libcreateint64" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 6a981df243..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createint64 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/hello.cpp deleted file mode 100755 index 4f62e14e28..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/hello.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_int64] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_create_int64] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_int64] - -// OH_JSVM_CreateInt64的样例方法 -static JSVM_Value CreateInt64(JSVM_Env env, JSVM_CallbackInfo info) -{ - // int64是有符号的64位整数类型,可以表示范围从-2^63到2^63 - 1的整数,即 -9223372036854775808到9223372036854775807 - // 要表示的整数值 - int64_t value = 2147483648; - // 创建JavaScript中的int64数字 - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_CreateInt64(env, value, &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateInt64 fail"); - } else { - int64_t number = 0; - OH_JSVM_GetValueInt64(env, result, &number); - OH_LOG_INFO(LOG_APP, "JSVM CreateInt64 success: %{public}ld", number); - } - return result; -} - -// CreateInt64注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateInt64}, -}; -static JSVM_CallbackStruct *method = param; -// CreateInt64方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createInt64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(createInt64())JS"; -// [End oh_jsvm_create_int64] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createint64", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/oh-package.json5 deleted file mode 100755 index 08e7a45a0b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/cpp/types/libcreateint64/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreateint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/pages/Index.ets deleted file mode 100755 index 31b8309e2f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreateint64.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/module.json5 deleted file mode 100755 index dcf7e628b5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createint64", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Createint64Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Createint64Ability", - "srcEntry": "./ets/createint64ability/Createint64Ability.ets", - "description": "$string:Createint64Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Createint64Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/float.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/float.json deleted file mode 100755 index a8a5d404dc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/string.json deleted file mode 100755 index 21b1b8281f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Createint64Ability_desc", - "value": "description" - }, - { - "name": "Createint64Ability_label", - "value": "JsvmBasicDataTypes" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 52794e0cf6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateInt64', 0, async (done: Function) => { - console.log('uitest: TestCreateInt64 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Createint64Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Createint64Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateInt64 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/module.json5 deleted file mode 100755 index edf0505453..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createint64/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createint64_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/oh-package.json5 deleted file mode 100755 index 2205c7d23f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createuint32", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreateuint32.so": "file:./src/main/cpp/types/libcreateuint32" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 9463604e10..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(createuint32 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createuint32 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/hello.cpp deleted file mode 100755 index 98de1a91a6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/hello.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_uint32] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_create_uint32] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_create_uint32] - -// OH_JSVM_CreateUint32的样例方法 -static JSVM_Value CreateUInt32(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 如果使用 - // uint32_t类型来定义-26,会发生溢出,溢出时会对结果进行模运算,将负数的二进制补码转换为相应的正数。-26输出4294967270 - // uint32_t是无符号的32位整数类型,只能表示非负整数。它的范围是从0到2 ^32 - 1,即0到4294967295 - // 要表示的整数值 - uint32_t value = 26; - // 创建JavaScript中的uint32数字 - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_CreateUint32(env, value, &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM CreateUInt32 fail"); - } else { - uint32_t number = 0; - OH_JSVM_GetValueUint32(env, result, &number); - OH_LOG_INFO(LOG_APP, "JSVM CreateUInt32 success: %{public}u", number); - } - return result; -} - -// CreateUInt32注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = CreateUInt32}, -}; -static JSVM_CallbackStruct *method = param; -// CreateUInt32方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"createUInt32", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(createUInt32())JS"; -// [End oh_jsvm_create_uint32] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createuint32", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/oh-package.json5 deleted file mode 100755 index 7bfb2c66cf..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/cpp/types/libcreateuint32/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreateuint32.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/pages/Index.ets deleted file mode 100755 index 3072091e6c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreateuint32.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/module.json5 deleted file mode 100755 index cc25dc7fe1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createuint32", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Createuint32Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Createuint32Ability", - "srcEntry": "./ets/createuint32ability/Createuint32Ability.ets", - "description": "$string:Createuint32Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Createuint32Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/float.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/float.json deleted file mode 100755 index a8a5d404dc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/string.json deleted file mode 100755 index a4c07ca4de..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Createuint32Ability_desc", - "value": "description" - }, - { - "name": "Createuint32Ability_label", - "value": "JsvmBasicDataTypes" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 7cd741c7c4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateUint32', 0, async (done: Function) => { - console.log('uitest: TestCreateUint32 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Createuint32Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Createuint32Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateUint32 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/module.json5 deleted file mode 100755 index 9257b69e82..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/createuint32/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createuint32_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/oh-package.json5 deleted file mode 100755 index a4b612239b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvaluedouble", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvaluedouble.so": "file:./src/main/cpp/types/libgetvaluedouble" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 8bd85de0c7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(getvaluedouble SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvaluedouble PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/hello.cpp deleted file mode 100755 index 03d8f1f8d9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/hello.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_double] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_get_value_double] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_double] - -// OH_JSVM_GetValueDouble的样例方法 -static JSVM_Value GetDouble(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - double value; - JSVM_Status status = OH_JSVM_GetValueDouble(env, args[0], &value); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetDouble fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetDouble success: %{public}f", value); - } - return args[0]; -} - -// GetDouble注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetDouble}, -}; -static JSVM_CallbackStruct *method = param; -// GetDouble方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getDouble", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(getDouble(-110.0456))JS"; -// [EndExclude oh_jsvm_get_value_double] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvaluedouble", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/oh-package.json5 deleted file mode 100755 index e82145546b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/cpp/types/libgetvaluedouble/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvaluedouble.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/pages/Index.ets deleted file mode 100755 index cf01d3f3fa..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvaluedouble.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/module.json5 deleted file mode 100755 index ef5f2188e2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getvaluedouble", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetvaluedoubleAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetvaluedoubleAbility", - "srcEntry": "./ets/getvaluedoubleability/GetvaluedoubleAbility.ets", - "description": "$string:GetvaluedoubleAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetvaluedoubleAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/float.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/float.json deleted file mode 100755 index a8a5d404dc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/string.json deleted file mode 100755 index 4f731d212f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetvaluedoubleAbility_desc", - "value": "description" - }, - { - "name": "GetvaluedoubleAbility_label", - "value": "JsvmBasicDataTypes" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 8156b7a3ff..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueDouble', 0, async (done: Function) => { - console.log('uitest: TestGetValueDouble begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetvaluedoubleAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetvaluedoubleAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueDouble end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/module.json5 deleted file mode 100755 index 2b02944b22..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvaluedouble/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvaluedouble_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/oh-package.json5 deleted file mode 100755 index c2656b7e45..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvalueint32", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvalueint32.so": "file:./src/main/cpp/types/libgetvalueint32" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 64e952af9f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(getvalueint32 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvalueint32 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/hello.cpp deleted file mode 100755 index 91284f3db5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/hello.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_int32] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_get_value_int32] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_int32] - -// OH_JSVM_GetValueInt32的样例方法 -static JSVM_Value GetValueInt32(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - int32_t result32 = 0; - // 解析传递的参数 - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 将前端传过来的参数转为JSVM模块的int32类型 - JSVM_Status status = OH_JSVM_GetValueInt32(env, args[0], &result32); - if (status != JSVM_OK) { - return nullptr; - } - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetValueInt32 fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetValueInt32 success: %{public}d", result32); - } - return args[0]; -} - -// GetValueInt32注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetValueInt32}, -}; -static JSVM_CallbackStruct *method = param; -// GetValueInt32方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getValueInt32", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(getValueInt32(-123))JS"; -// [EndExclude oh_jsvm_get_value_int32] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvalueint32", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/oh-package.json5 deleted file mode 100755 index b66b71212e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/cpp/types/libgetvalueint32/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvalueint32.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/pages/Index.ets deleted file mode 100755 index d30d9aef64..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvalueint32.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/module.json5 deleted file mode 100755 index 9fa14e29de..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getvalueint32", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Getvalueint32Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Getvalueint32Ability", - "srcEntry": "./ets/getvalueint32ability/Getvalueint32Ability.ets", - "description": "$string:Getvalueint32Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Getvalueint32Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/float.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/float.json deleted file mode 100755 index a8a5d404dc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/string.json deleted file mode 100755 index cd92a017c6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Getvalueint32Ability_desc", - "value": "description" - }, - { - "name": "Getvalueint32Ability_label", - "value": "JsvmBasicDataTypes" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index ae013930bd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueInt32', 0, async (done: Function) => { - console.log('uitest: TestGetValueInt32 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Getvalueint32Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Getvalueint32Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueInt32 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/module.json5 deleted file mode 100755 index 686641c799..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint32/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvalueint32_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/oh-package.json5 deleted file mode 100755 index 96d2a56367..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvalueint64", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvalueint64.so": "file:./src/main/cpp/types/libgetvalueint64" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 21bbc9754c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(getvalueint64 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvalueint64 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/hello.cpp deleted file mode 100755 index f8f2451be8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/hello.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_int64] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_get_value_int64] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_int64] - -// OH_JSVM_GetValueInt64的样例方法 -static JSVM_Value GetValueInt64(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - int64_t result64 = 0; - // 解析传递的值 - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 将前端传过来的参数分别转为JSVM模块的int64类型 - JSVM_Status status = OH_JSVM_GetValueInt64(env, args[0], &result64); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetValueInt64 fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetValueInt64 success: %{public}d", result64); - } - return args[0]; -} - -// GetValueInt64注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetValueInt64}, -}; -static JSVM_CallbackStruct *method = param; -// GetValueInt64方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getValueInt64", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(getValueInt64(-123))JS"; -// [End oh_jsvm_get_value_int64] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvalueint64", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/oh-package.json5 deleted file mode 100755 index 97fea61b98..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/cpp/types/libgetvalueint64/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvalueint64.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/pages/Index.ets deleted file mode 100755 index e8293f9c5b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvalueint64.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/module.json5 deleted file mode 100755 index 35160b266a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getvalueint64", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Getvalueint64Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Getvalueint64Ability", - "srcEntry": "./ets/getvalueint64ability/Getvalueint64Ability.ets", - "description": "$string:Getvalueint64Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Getvalueint64Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/float.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/float.json deleted file mode 100755 index a8a5d404dc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/string.json deleted file mode 100755 index f583d497b8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Getvalueint64Ability_desc", - "value": "description" - }, - { - "name": "Getvalueint64Ability_label", - "value": "JsvmBasicDataTypes" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 447073c3fd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueInt64', 0, async (done: Function) => { - console.log('uitest: TestGetValueInt64 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Getvalueint64Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Getvalueint64Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueInt64 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/module.json5 deleted file mode 100755 index 586f513627..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueint64/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvalueint64_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/oh-package.json5 deleted file mode 100755 index 4fd3e2eba4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvalueuint32", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvalueuint32.so": "file:./src/main/cpp/types/libgetvalueuint32" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/CMakeLists.txt deleted file mode 100755 index df0efbaf60..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(GetValueUint32) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(getvalueuint32 SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvalueuint32 PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/hello.cpp deleted file mode 100755 index 3165b0388b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/hello.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_value_uint32] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" - -// [StartExclude oh_jsvm_get_value_uint32] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_value_uint32] - -// OH_JSVM_GetValueUint32的样例方法 -static JSVM_Value GetValueUint32(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取传入的数字类型参数 - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - // 解析传入的参数 - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - uint32_t number = 0; - // 获取传入参数的值中的无符号32位整数 - JSVM_Status status = OH_JSVM_GetValueUint32(env, argv[0], &number); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM GetValueUint32 fail"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM GetValueUint32 success: %{public}u", number); - } - return argv[0]; -} - -// GetValueUint32注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetValueUint32}, -}; -static JSVM_CallbackStruct *method = param; - -// GetValueUint32方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getValueUint32", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(getValueUint32(123))JS"; -// [End oh_jsvm_get_value_uint32] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvalueuint32", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/oh-package.json5 deleted file mode 100755 index b06823b75c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/cpp/types/libgetvalueuint32/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvalueuint32.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/pages/Index.ets deleted file mode 100755 index 35fb46201e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvalueuint32.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/module.json5 deleted file mode 100755 index 100e9decb2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "getvalueuint32", - "type": "entry", - "description": "$string:module_desc", - "mainElement": "Getvalueuint32Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Getvalueuint32Ability", - "srcEntry": "./ets/getvalueuint32ability/Getvalueuint32Ability.ets", - "description": "$string:Getvalueuint32Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Getvalueuint32Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "Getvalueuint32BackupAbility", - "srcEntry": "./ets/getvalueuint32backupability/Getvalueuint32BackupAbility.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/float.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/float.json deleted file mode 100755 index a8a5d404dc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/string.json deleted file mode 100755 index 96a70e17d9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "Getvalueuint32Ability_desc", - "value": "description" - }, - { - "name": "Getvalueuint32Ability_label", - "value": "JsvmBasicDataTypes" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 0c060b2982..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetValueUint32', 0, async (done: Function) => { - console.log('uitest: TestGetValueUint32 begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'Getvalueuint32Ability' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('Getvalueuint32Ability'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetValueUint32 end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/module.json5 deleted file mode 100755 index a40e14a8fa..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/getvalueuint32/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvalueuint32_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigor/hvigor-config.json5 deleted file mode 100755 index 8d4c6165b5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.2", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/oh-package.json5 deleted file mode 100755 index 635416b1c5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.2", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.21", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/ohosTest.md deleted file mode 100755 index 9202aff6bd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmBasicDataTypes/ohosTest.md +++ /dev/null @@ -1,15 +0,0 @@ -# JsvmBasicDataTypes 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 根据Double类型对象创建JavaScript number对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 根据Int32_t类型对象创建JavaScript number对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 根据Int64_t类型对象创建JavaScript number对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 根据Uint32_t类型对象创建JavaScript number对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定JavaScript number的Double基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定JavaScript number的Int32基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定JavaScript number的Int64基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取给定JavaScript number的Uint32基础类型值 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/app.json5 deleted file mode 100755 index 04fde9d869..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmerror", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/element/string.json deleted file mode 100755 index 9818687db5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmError" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/README.md deleted file mode 100755 index 9140d22f42..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/README.md +++ /dev/null @@ -1,293 +0,0 @@ -# ArkTs使用JSVM-API接口进行错误处理开发 - -### 介绍 - -使用JSVM-API接口进行错误处理开发,使得在JSVM-API模块中能够更好地管理和响应错误情况。通过合理使用这些函数,可以提高模块的稳定性和可靠性。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口进行错误处理开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-error.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :-----------------------------------------------------------: | :-----------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -createerror/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createrangeerror/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createsyntaxerror/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createtypeerror/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getandclearlastexception/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getlasterrorinfo/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -iserror/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -isexceptionpending/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -throwerror/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -throwrangeerror/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -throwsyntaxerror/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -throwtypeerror/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/build-profile.json5 deleted file mode 100755 index 3a9eaaf8f9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/build-profile.json5 +++ /dev/null @@ -1,190 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "createerror", - "srcPath": "./createerror", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "throwerror", - "srcPath": "./throwerror", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "throwtypeerror", - "srcPath": "./throwtypeerror", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "throwrangeerror", - "srcPath": "./throwrangeerror", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "throwsyntaxerror", - "srcPath": "./throwsyntaxerror", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "iserror", - "srcPath": "./iserror", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createtypeerror", - "srcPath": "./createtypeerror", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createrangeerror", - "srcPath": "./createrangeerror", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "createsyntaxerror", - "srcPath": "./createsyntaxerror", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getandclearlastexception", - "srcPath": "./getandclearlastexception", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "isexceptionpending", - "srcPath": "./isexceptionpending", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getlasterrorinfo", - "srcPath": "./getlasterrorinfo", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/oh-package.json5 deleted file mode 100755 index a5fc50bf75..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createerror", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreateerror.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/CMakeLists.txt deleted file mode 100755 index c5484099da..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createerror SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/hello.cpp deleted file mode 100755 index a409805922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/hello.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_create_error] -// 捕获清除并打印错误,该函数作为公共函数,在本文档后续样例中不再声明和定义 -static void GetLastErrorAndClean(JSVM_Env env) -{ - // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); - // 打印错误信息 - JSVM_Value message; - JSVM_Value errorCode; - OH_JSVM_GetNamedProperty((env), result, "message", &message); - OH_JSVM_GetNamedProperty((env), result, "code", &errorCode); - const int maxMessageLength = 256; - const int maxCodeLength = 256; - char messagestr[maxMessageLength]; - char codeStr[maxCodeLength]; - OH_JSVM_GetValueStringUtf8(env, message, messagestr, maxMessageLength, nullptr); - OH_JSVM_GetValueStringUtf8(env, errorCode, codeStr, maxCodeLength, nullptr); - OH_LOG_INFO(LOG_APP, "JSVM error message: %{public}s, error code: %{public}s", messagestr, codeStr); -} - -// OH_JSVM_CreateError的样例方法 -static JSVM_Value JsVmCreateThrowError(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 在JSVM环境中创建一个字符串,并将其存储在errorCode变量中 - JSVM_Value errorCode = nullptr; - OH_JSVM_CreateStringUtf8(env, "-1", JSVM_AUTO_LENGTH, &errorCode); - // 在JSVM环境中创建一个字符串,并将其存储在errorMessage变量中 - JSVM_Value errorMessage = nullptr; - OH_JSVM_CreateStringUtf8(env, "HasError", JSVM_AUTO_LENGTH, &errorMessage); - // 创建一个JavaScript对象error - JSVM_Value error = nullptr; - OH_JSVM_CreateError(env, errorCode, errorMessage, &error); - // 通过OH_JSVM_Throw接口将对象抛出 - OH_JSVM_Throw(env, error); - GetLastErrorAndClean(env); - return nullptr; -} - -// JsVmThrow注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmCreateThrowError}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmThrow方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmCreateThrowError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmCreateThrowError();)JS"; -// [End oh_jsvm_create_error] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createerror", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 829ad5fd7e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreateerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/pages/Index.ets deleted file mode 100755 index 1eefbc5ae3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreateerror.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/module.json5 deleted file mode 100755 index ee7a5d5ed3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "createerror", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/string.json deleted file mode 100755 index fc7be80287..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 2f0bf88996..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateError', 0, async (done: Function) => { - console.log('uitest: TestCreateError begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateError end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/module.json5 deleted file mode 100755 index 4a3fd27594..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createerror/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createerror_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/oh-package.json5 deleted file mode 100755 index a25803931e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createrangeerror", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreaterangeerror.so": "file:./src/main/cpp/types/libcreaterangeerror" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 01313dd048..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createrangeerror SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createrangeerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/hello.cpp deleted file mode 100755 index e43240c661..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/hello.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_create_range_error] -// OH_JSVM_CreateRangeError的样例方法 -static JSVM_Value JsVmCreateRangeError(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 在JSVM环境中创建一个字符串,并将其存储在errorCode变量中 - JSVM_Value errorCode = nullptr; - OH_JSVM_CreateStringUtf8(env, "-1", JSVM_AUTO_LENGTH, &errorCode); - // 在JSVM环境中创建一个字符串,并将其存储在errorMessage变量中 - JSVM_Value errorMessage = nullptr; - OH_JSVM_CreateStringUtf8(env, "HasError", JSVM_AUTO_LENGTH, &errorMessage); - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_CreateRangeError(env, errorCode, errorMessage, &result); - if (status == JSVM_OK) { - OH_LOG_INFO(LOG_APP, "JSVM API CreateRangeError SUCCESS"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM API CreateRangeError FAILED"); - } - return result; -} -// JsVmCreateRangeError注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmCreateRangeError}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmCreateRangeError方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmCreateRangeError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmCreateRangeError();)JS"; -// [End oh_jsvm_create_range_error] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createrangeerror", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/oh-package.json5 deleted file mode 100755 index 87811c5d75..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/cpp/types/libcreaterangeerror/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreaterangeerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/pages/Index.ets deleted file mode 100755 index e1fb293c74..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreaterangeerror.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/module.json5 deleted file mode 100755 index aa3306221f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createrangeerror", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreaterangeerrorAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreaterangeerrorAbility", - "srcEntry": "./ets/createrangeerrorability/CreaterangeerrorAbility.ets", - "description": "$string:CreaterangeerrorAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreaterangeerrorAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/string.json deleted file mode 100755 index ec0182512a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreaterangeerrorAbility_desc", - "value": "description" - }, - { - "name": "CreaterangeerrorAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 64be00249e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateRangeError', 0, async (done: Function) => { - console.log('uitest: TestCreateRangeError begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreaterangeerrorAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreaterangeerrorAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateRangeError end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/module.json5 deleted file mode 100755 index 03dea5d0a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createrangeerror/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createrangeerror_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/oh-package.json5 deleted file mode 100755 index f0e76e351e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createsyntaxerror", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatesyntaxerror.so": "file:./src/main/cpp/types/libcreatesyntaxerror" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/CMakeLists.txt deleted file mode 100755 index a34c88e1e0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createsyntaxerror SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createsyntaxerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/hello.cpp deleted file mode 100755 index 6d420a47b6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/hello.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_create_syntax_error] -// OH_JSVM_CreateSyntaxError的样例方法 -static JSVM_Value JsVmCreateSyntaxError(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 在JSVM环境中创建一个字符串,并将其存储在errorCode变量中 - JSVM_Value errorCode = nullptr; - OH_JSVM_CreateStringUtf8(env, "-1", JSVM_AUTO_LENGTH, &errorCode); - // 在JSVM环境中创建一个字符串,并将其存储在errorMessage变量中 - JSVM_Value errorMessage = nullptr; - OH_JSVM_CreateStringUtf8(env, "HasError", JSVM_AUTO_LENGTH, &errorMessage); - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_CreateSyntaxError(env, errorCode, errorMessage, &result); - if (status == JSVM_OK) { - OH_LOG_INFO(LOG_APP, "JSVM API CreateSyntaxError SUCCESS"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM API CreateSyntaxError FAILED"); - } - return result; -} -// JsVmCreateSyntaxError注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmCreateSyntaxError}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmThrow方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmCreateSyntaxError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmCreateSyntaxError();)JS"; -// [End oh_jsvm_create_syntax_error] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createsyntaxerror", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/oh-package.json5 deleted file mode 100755 index 6f1311c9f9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/cpp/types/libcreatesyntaxerror/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatesyntaxerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/pages/Index.ets deleted file mode 100755 index d44750a57f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatesyntaxerror.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/module.json5 deleted file mode 100755 index 449335b6b9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createsyntaxerror", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreatesyntaxerrorAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreatesyntaxerrorAbility", - "srcEntry": "./ets/createsyntaxerrorability/CreatesyntaxerrorAbility.ets", - "description": "$string:CreatesyntaxerrorAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreatesyntaxerrorAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/string.json deleted file mode 100755 index e316f21703..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreatesyntaxerrorAbility_desc", - "value": "description" - }, - { - "name": "CreatesyntaxerrorAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index a4f5d1732b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateSyntaxError', 0, async (done: Function) => { - console.log('uitest: TestCreateSyntaxError begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreatesyntaxerrorAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreatesyntaxerrorAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateSyntaxError end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/module.json5 deleted file mode 100755 index 91f2313d80..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createsyntaxerror/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createsyntaxerror_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/oh-package.json5 deleted file mode 100755 index 04869db2d5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createtypeerror", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatetypeerror.so": "file:./src/main/cpp/types/libcreatetypeerror" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 3eb1cbdf19..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createtypeerror SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createtypeerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/hello.cpp deleted file mode 100755 index 7eac12fcf3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/hello.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_create_type_error] -// OH_JSVM_CreateTypeError的样例方法 -static JSVM_Value JsVmCreateTypeError(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 在JSVM环境中创建一个字符串,并将其存储在errorCode变量中 - JSVM_Value errorCode = nullptr; - OH_JSVM_CreateStringUtf8(env, "-1", JSVM_AUTO_LENGTH, &errorCode); - // 在JSVM环境中创建一个字符串,并将其存储在errorMessage变量中 - JSVM_Value errorMessage = nullptr; - OH_JSVM_CreateStringUtf8(env, "HasError", JSVM_AUTO_LENGTH, &errorMessage); - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_CreateTypeError(env, errorCode, errorMessage, &result); - if (status == JSVM_OK) { - OH_LOG_INFO(LOG_APP, "JSVM API Create TypeError SUCCESS"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM API Create TypeError FAILED"); - } - return result; -} -// JsVmCreateTypeError注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmCreateTypeError}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmCreateTypeError方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmCreateTypeError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmCreateTypeError();)JS"; -// [End oh_jsvm_create_type_error] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createtypeerror", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/oh-package.json5 deleted file mode 100755 index e0c257dce2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/cpp/types/libcreatetypeerror/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatetypeerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/pages/Index.ets deleted file mode 100755 index fc4d6af506..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libcreatetypeerror.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/module.json5 deleted file mode 100755 index 3a6433a1ad..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "createtypeerror", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "CreateTypeErrorAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "CreateTypeErrorAbility", - "srcEntry": "./ets/createtypeerrorability/CreateTypeErrorAbility.ets", - "description": "$string:CreateTypeErrorAbility_desc", - "icon": "$media:layered_image", - "label": "$string:CreateTypeErrorAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/string.json deleted file mode 100755 index f84c143f98..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "CreateTypeErrorAbility_desc", - "value": "description" - }, - { - "name": "CreateTypeErrorAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 6d1c03f778..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testCreateTypeError', 0, async (done: Function) => { - console.log('uitest: TestCreateTypeError begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'CreateTypeErrorAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('CreateTypeErrorAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestCreateTypeError end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/module.json5 deleted file mode 100755 index 8238646db7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/createtypeerror/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createtypeerror_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/oh-package.json5 deleted file mode 100755 index d607a6ee8c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getandclearlastexception", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetandclearlastexception.so": "file:./src/main/cpp/types/libgetandclearlastexception" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 7b34e025a6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getandclearlastexception SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getandclearlastexception PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/hello.cpp deleted file mode 100755 index 9112e0c35e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/hello.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_get_and_clear_last_exception] -// OH_JSVM_GetAndClearLastException的样例方法 -static JSVM_Value JsVmGetAndClearLastException(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 抛出异常,创造异常情况 - OH_JSVM_ThrowError(env, "OH_JSVM_ThrowError errorCode", "OH_JSVM_ThrowError errorMessage"); - // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); - if (status != JSVM_OK) { - OH_LOG_INFO(LOG_APP, "JSVM API OH_JSVM_GetAndClearLastException FAILED"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM API OH_JSVM_GetAndClearLastException SUCCESS"); - } - return result; -} -// JsVmGetAndClearLastException注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmGetAndClearLastException}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmGetAndClearLastException方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmGetAndClearLastException", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmGetAndClearLastException();)JS"; -// [End oh_jsvm_get_and_clear_last_exception] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getandclearlastexception", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/oh-package.json5 deleted file mode 100755 index 3d496a26da..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/cpp/types/libgetandclearlastexception/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetandclearlastexception.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/pages/Index.ets deleted file mode 100755 index 0f157cf9a9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetandclearlastexception.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/module.json5 deleted file mode 100755 index 91ad41dbdd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getandclearlastexception", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetandclearlastexceptionAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetandclearlastexceptionAbility", - "srcEntry": "./ets/getandclearlastexceptionability/GetandclearlastexceptionAbility.ets", - "description": "$string:GetandclearlastexceptionAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetandclearlastexceptionAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/string.json deleted file mode 100755 index bd3602a9ee..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetandclearlastexceptionAbility_desc", - "value": "description" - }, - { - "name": "GetandclearlastexceptionAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 564cdcea37..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetAndClearLastException', 0, async (done: Function) => { - console.log('uitest: TestGetAndClearLastException begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetandclearlastexceptionAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetandclearlastexceptionAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetAndClearLastException end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/module.json5 deleted file mode 100755 index ef66a432e7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getandclearlastexception/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getandclearlastexception_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/oh-package.json5 deleted file mode 100755 index 2b1e7e8384..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getlasterrorinfo", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetlasterrorinfo.so": "file:./src/main/cpp/types/libgetlasterrorinfo" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 3c5ddc6e74..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getlasterrorinfo SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getlasterrorinfo PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/hello.cpp deleted file mode 100755 index 601edb67e9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/hello.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_get_last_error_info] -// OH_JSVM_GetLastErrorInfo的样例方法 -static JSVM_Value JsVmGetLastErrorInfo(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取输入参数(这里以字符串message作为参数传入) - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 将传入的字符串参数以OH_JSVM_GetValueInt32取出,主动制造错误 - int32_t value = 0; - OH_JSVM_GetValueInt32(env, args[0], &value); - // 调用接口OH_JSVM_GetLastErrorInfo获取最后一次错误信息 - const JSVM_ExtendedErrorInfo *errorInfo; - OH_JSVM_GetLastErrorInfo(env, &errorInfo); - - // 取出错误消息作为返回值带出去打印 - JSVM_Value result = nullptr; - OH_LOG_INFO(LOG_APP, - "JSVM API OH_JSVM_GetLastErrorInfo: SUCCESS, error message is %{public}s, error code is %{public}d", - errorInfo->errorMessage, errorInfo->errorCode); - // 对异常进行处理,防止程序由于抛异常而退出 - JSVM_Value result1 = nullptr; - OH_JSVM_GetAndClearLastException(env, &result1); - OH_JSVM_CreateInt32(env, errorInfo->errorCode, &result); - return result; -} -// JsVmGetLastErrorInfo注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmGetLastErrorInfo}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmGetLastErrorInfo方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmGetLastErrorInfo", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmGetLastErrorInfo();)JS"; -// [End oh_jsvm_get_last_error_info] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getlasterrorinfo", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/oh-package.json5 deleted file mode 100755 index fc0beb5f02..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/cpp/types/libgetlasterrorinfo/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetlasterrorinfo.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/pages/Index.ets deleted file mode 100755 index e223955b81..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetlasterrorinfo.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/module.json5 deleted file mode 100755 index 5ceb174fa4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getlasterrorinfo", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetlasterrorInfoAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetlasterrorInfoAbility", - "srcEntry": "./ets/getlasterrorinfoability/GetlasterrorInfoAbility.ets", - "description": "$string:GetlasterrorInfoAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetlasterrorInfoAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/string.json deleted file mode 100755 index dea87b7315..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetlasterrorInfoAbility_desc", - "value": "description" - }, - { - "name": "GetlasterrorInfoAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index f024ad3a20..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetLastErrorInfo', 0, async (done: Function) => { - console.log('uitest: TestGetLastErrorInfo begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetlasterrorInfoAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetlasterrorInfoAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetLastErrorInfo end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/module.json5 deleted file mode 100755 index bc31ddf487..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/getlasterrorinfo/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getlasterrorinfo_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/oh-package.json5 deleted file mode 100755 index a813e52c3c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "iserror", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libiserror.so": "file:./src/main/cpp/types/libiserror" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 58f3b62516..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(iserror SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(iserror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/hello.cpp deleted file mode 100755 index 795a0fe3d0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/hello.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_is_error] -// OH_JSVM_IsError的样例方法 -static JSVM_Value JsVmIsError(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 调用接口OH_JSVM_IsError判断入参是否为一个error对象 - bool result = false; - // 如果JSVM_Value为一个error对象,则设置result为true的布尔值,否则设置为false - JSVM_Status status = OH_JSVM_IsError(env, args[0], &result); - if (status == JSVM_OK) { - OH_LOG_INFO(LOG_APP, "JSVM API call OH_JSVM_IsError success, result is %{public}d", result); - } else { - OH_LOG_INFO(LOG_APP, "JSVM API call OH_JSVM_IsError failed"); - } - // 取出result通过OH_JSVM_GetBoolean接口将取出的bool值转换为JSVM_Value类型的值返回出去 - JSVM_Value returnValue = nullptr; - OH_JSVM_GetBoolean(env, result, &returnValue); - return returnValue; -} -// JsVmIsError注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmIsError}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmIsError方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmIsError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmIsError(Error()))JS"; -// [End oh_jsvm_is_error] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "iserror", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/oh-package.json5 deleted file mode 100755 index 046e20b416..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/cpp/types/libiserror/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libiserror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/pages/Index.ets deleted file mode 100755 index f15581fd6b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libiserror.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/module.json5 deleted file mode 100755 index 28767b5a1a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "iserror", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "IserrorAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "IserrorAbility", - "srcEntry": "./ets/iserrorability/IserrorAbility.ets", - "description": "$string:IserrorAbility_desc", - "icon": "$media:layered_image", - "label": "$string:IserrorAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/string.json deleted file mode 100755 index 6c63c0e729..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "IserrorAbility_desc", - "value": "description" - }, - { - "name": "IserrorAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 9047ef5aa7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testIsError', 0, async (done: Function) => { - console.log('uitest: TestIsError begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'IserrorAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('IserrorAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestIsError end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/module.json5 deleted file mode 100755 index d07eef90c7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/iserror/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "iserror_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/oh-package.json5 deleted file mode 100755 index 08b7f30e9a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "isexceptionpending", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libisexceptionpending.so": "file:./src/main/cpp/types/libisexceptionpending" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/CMakeLists.txt deleted file mode 100755 index d58d0090bb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(isexceptionpending SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(isexceptionpending PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/hello.cpp deleted file mode 100755 index f64686c684..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/hello.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_is_exception_pending] -// OH_JSVM_GetAndClearLastException的样例方法 -static JSVM_Value JsVmIsExceptionPending(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_Status status; - bool isExceptionPending = false; - // 在执行一些可能引发异常的操作后 - OH_JSVM_ThrowError(env, "OH_JSVM_ThrowError errorCode", "OH_JSVM_ThrowError errorMessage"); - // 检查当前环境中是否有异常挂起 - status = OH_JSVM_IsExceptionPending(env, &isExceptionPending); - if (status != JSVM_OK) { - return nullptr; - } - if (isExceptionPending) { - OH_LOG_INFO(LOG_APP, "JSVM API OH_JSVM_IsExceptionPending: SUCCESS"); - // 处理异常挂起的情况 - JSVM_Value result = nullptr; - status = OH_JSVM_GetAndClearLastException(env, &result); - if (status != JSVM_OK) { - return nullptr; - } - // 将处理的异常返回出去 - return result; - } else { - OH_LOG_INFO(LOG_APP, "JSVM API OH_JSVM_IsExceptionPending: FAILED"); - } - return nullptr; -} -// JsVmIsExceptionPending注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmIsExceptionPending}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmIsExceptionPending方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmIsExceptionPending", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmIsExceptionPending();)JS"; -// [End oh_jsvm_is_exception_pending] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "isexceptionpending", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/oh-package.json5 deleted file mode 100755 index 771487a294..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/cpp/types/libisexceptionpending/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libisexceptionpending.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/pages/Index.ets deleted file mode 100755 index fcb29310dc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libisexceptionpending.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/module.json5 deleted file mode 100755 index ed3f1b33dc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "isexceptionpending", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "IsexceptionpendingAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "IsexceptionpendingAbility", - "srcEntry": "./ets/isexceptionpendingability/IsexceptionpendingAbility.ets", - "description": "$string:IsexceptionpendingAbility_desc", - "icon": "$media:layered_image", - "label": "$string:IsexceptionpendingAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/string.json deleted file mode 100755 index d9cd2cbfe8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "IsexceptionpendingAbility_desc", - "value": "description" - }, - { - "name": "IsexceptionpendingAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 1c35824fea..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testIsExceptionPending', 0, async (done: Function) => { - console.log('uitest: TestIsExceptionPending begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'IsexceptionpendingAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('IsexceptionpendingAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestIsExceptionPending end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/module.json5 deleted file mode 100755 index e4269bd675..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/isexceptionpending/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "isexceptionpending_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/ohosTest.md deleted file mode 100755 index e309de19fb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/ohosTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# JsvmError 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------ | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 创建并获取一个带文本信息的JavaScript Error | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 创建并获取一个带文本信息的JavaScript RangeError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 创建并获取一个带文本信息的JavaScript SyntaxError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 创建并获取一个带文本信息的JavaScript TypeError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取并清除最近一次出现的异常 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 获取调用JSVM接口最后一次发生的错误信息 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 判断给定的JSVM_Value是否表示一个error对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 判断是否出现了异常 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 抛出一个带文本信息的JS Error | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 创建并获取一个带文本信息的JavaScript RangeError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 创建并获取一个带文本信息的JavaScript SyntaxError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 创建并获取一个带文本信息的JavaScript SyntaxError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 创建并获取一个带文本信息的JavaScript TypeError | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/oh-package.json5 deleted file mode 100755 index b1b76a15bc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "throwerror", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libthrowerror.so": "file:./src/main/cpp/types/libthrowerror" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 6bc7a47bae..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(throwerror SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(throwerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/hello.cpp deleted file mode 100755 index 2bfcb24695..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/hello.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -static void GetLastErrorAndClean(JSVM_Env env) -{ - // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); - // 打印错误信息 - JSVM_Value message; - JSVM_Value errorCode; - OH_JSVM_GetNamedProperty((env), result, "message", &message); - OH_JSVM_GetNamedProperty((env), result, "code", &errorCode); - const int maxMessageLength = 256; - const int maxCodeLength = 256; - char messagestr[maxMessageLength]; - char codeStr[maxCodeLength]; - OH_JSVM_GetValueStringUtf8(env, message, messagestr, maxMessageLength, nullptr); - OH_JSVM_GetValueStringUtf8(env, errorCode, codeStr, maxCodeLength, nullptr); - OH_LOG_INFO(LOG_APP, "JSVM error message: %{public}s, error code: %{public}s", messagestr, codeStr); -} - -// [Start oh_jsvm_throw_error] -// OH_JSVM_ThrowError的样例方法 -static JSVM_Value JsVmThrowError(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - if (argc == 0) { - // 如果没有传递参数,直接抛出错误 - OH_JSVM_ThrowError(env, "-1", "has Error"); - } else if (argc == 1) { - size_t length; - // 通过入参获取到javaScript侧传入的字符串长度。 - OH_JSVM_GetValueStringUtf8(env, argv[0], nullptr, 0, &length); - char *buffer = new char[length + 1]; - // 获取入参的字符串内容。 - OH_JSVM_GetValueStringUtf8(env, argv[0], buffer, length + 1, nullptr); - // 作为error信息填入到OH_JSVM_ThrowError接口中。 - OH_JSVM_ThrowError(env, "self defined error code", buffer); - delete[] buffer; - } - GetLastErrorAndClean(env); - return nullptr; -} -// JsVmThrowError注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmThrowError}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmThrowError方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmThrowError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmThrowError();jsVmThrowError("self defined error message");)JS"; -// [End oh_jsvm_throw_error] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "throwerror", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/oh-package.json5 deleted file mode 100755 index 02a85d7783..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/cpp/types/libthrowerror/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libthrowerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/pages/Index.ets deleted file mode 100755 index 998e449696..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libthrowerror.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/module.json5 deleted file mode 100755 index 3ab4c922be..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "throwerror", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "ThrowerrorAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ThrowerrorAbility", - "srcEntry": "./ets/throwerrorability/ThrowerrorAbility.ets", - "description": "$string:ThrowerrorAbility_desc", - "icon": "$media:layered_image", - "label": "$string:ThrowerrorAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/string.json deleted file mode 100755 index b80b6e3a54..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "ThrowerrorAbility_desc", - "value": "description" - }, - { - "name": "ThrowerrorAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index e6abaa916e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testThrowError', 0, async (done: Function) => { - console.log('uitest: TestThrowError begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'ThrowerrorAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('ThrowerrorAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestThrowError end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/module.json5 deleted file mode 100755 index 69284f3e05..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwerror/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "throwerror_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/oh-package.json5 deleted file mode 100755 index a41bd18c9a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "throwrangeerror", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libthrowrangeerror.so": "file:./src/main/cpp/types/libthrowrangeerror" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 247bc126d6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(throwrangeerror SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(throwrangeerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/hello.cpp deleted file mode 100755 index 821c850896..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/hello.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// 捕获清除并打印错误,该函数作为公共函数,在本文档后续样例中不再声明和定义 -static void GetLastErrorAndClean(JSVM_Env env) -{ - // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); - // 打印错误信息 - JSVM_Value message; - JSVM_Value errorCode; - OH_JSVM_GetNamedProperty((env), result, "message", &message); - OH_JSVM_GetNamedProperty((env), result, "code", &errorCode); - const int maxMessageLength = 256; - const int maxCodeLength = 256; - char messagestr[maxMessageLength]; - char codeStr[maxCodeLength]; - OH_JSVM_GetValueStringUtf8(env, message, messagestr, maxMessageLength, nullptr); - OH_JSVM_GetValueStringUtf8(env, errorCode, codeStr, maxCodeLength, nullptr); - OH_LOG_INFO(LOG_APP, "JSVM error message: %{public}s, error code: %{public}s", messagestr, codeStr); -} - -// [Start oh_jsvm_throw_range_error] -// OH_JSVM_ThrowRangeError的样例方法 -static JSVM_Value JsVmThrowRangeError(JSVM_Env env, JSVM_CallbackInfo info) -{ - // js侧传入两个参数 - size_t argc = 2; - JSVM_Value argv[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - // 如果传入参数个数不为2 - if (argc != 2) { - // 这里抛出一个RangeError - OH_JSVM_ThrowRangeError(env, "OH_JSVM_ThrowRangeError", "Expected two numbers as arguments"); - GetLastErrorAndClean(env); - return nullptr; - } - JSVM_Value result = nullptr; - OH_JSVM_GetBoolean(env, true, &result); - return result; -} -// JsVmThrowRangeError注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmThrowRangeError}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmThrowRangeError方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmThrowRangeError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmThrowRangeError(1);)JS"; -// [End oh_jsvm_throw_range_error] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "throwrangeerror", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/oh-package.json5 deleted file mode 100755 index 5de32810b8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/cpp/types/libthrowrangeerror/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libthrowrangeerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/pages/Index.ets deleted file mode 100755 index 774c649678..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libthrowrangeerror.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/module.json5 deleted file mode 100755 index 478f372a4b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "throwrangeerror", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "ThrowrangeerrorAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ThrowrangeerrorAbility", - "srcEntry": "./ets/throwrangeerrorability/ThrowrangeerrorAbility.ets", - "description": "$string:ThrowrangeerrorAbility_desc", - "icon": "$media:layered_image", - "label": "$string:ThrowrangeerrorAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/string.json deleted file mode 100755 index d8f6f6fd07..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "ThrowrangeerrorAbility_desc", - "value": "description" - }, - { - "name": "ThrowrangeerrorAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index aa3a111076..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testThrowRangeError', 0, async (done: Function) => { - console.log('uitest: TestThrowRangeError begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'ThrowrangeerrorAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('ThrowrangeerrorAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestThrowRangeError end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/module.json5 deleted file mode 100755 index 4fb52715dd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwrangeerror/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "throwrangeerror_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/oh-package.json5 deleted file mode 100755 index 1400000e35..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "throwsyntaxerror", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libthrowsyntaxerror.so": "file:./src/main/cpp/types/libthrowsyntaxerror" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 0e833e0293..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(throwsyntaxerror SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(throwsyntaxerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/hello.cpp deleted file mode 100755 index 527403c712..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/hello.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// 捕获清除并打印错误,该函数作为公共函数,在本文档后续样例中不再声明和定义 -static void GetLastErrorAndClean(JSVM_Env env) -{ - // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); - // 打印错误信息 - JSVM_Value message; - JSVM_Value errorCode; - OH_JSVM_GetNamedProperty((env), result, "message", &message); - OH_JSVM_GetNamedProperty((env), result, "code", &errorCode); - const int maxMessageLength = 256; - const int maxCodeLength = 256; - char messagestr[maxMessageLength]; - char codeStr[maxCodeLength]; - OH_JSVM_GetValueStringUtf8(env, message, messagestr, maxMessageLength, nullptr); - OH_JSVM_GetValueStringUtf8(env, errorCode, codeStr, maxCodeLength, nullptr); - OH_LOG_INFO(LOG_APP, "JSVM error message: %{public}s, error code: %{public}s", messagestr, codeStr); -} - -// [Start oh_jsvm_throw_syntax_error] -// OH_JSVM_ThrowSyntaxError的样例方法 -static JSVM_Value JsVmThrowSyntaxError(JSVM_Env env, JSVM_CallbackInfo info) -{ - // JS侧传入运行的JS代码 - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - JSVM_Script script = nullptr; - // 通过OH_JSVM_CompileScript接口编译JS代码 - OH_JSVM_CompileScript(env, argv[0], nullptr, 0, true, nullptr, &script); - JSVM_Value scriptResult = nullptr; - // 通过OH_JSVM_RunScript接口运行JS代码 - JSVM_Status status = OH_JSVM_RunScript(env, script, &scriptResult); - if (status != JSVM_OK) { - // 如果JSVM_RunScript接口返回状态不为JSVM_OK,则抛出一个SyntaxError - OH_JSVM_ThrowSyntaxError(env, "JsVmThrowSyntaxError", "throw syntax error"); - GetLastErrorAndClean(env); - return nullptr; - } - JSVM_Value result = nullptr; - OH_JSVM_GetBoolean(env, true, &result); - return result; -} -// JsVmThrowSyntaxError注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmThrowSyntaxError}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmThrowSyntaxError方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmThrowSyntaxError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmThrowSyntaxError();)JS"; -// [End oh_jsvm_throw_syntax_error] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "throwsyntaxerror", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/oh-package.json5 deleted file mode 100755 index 24af3733f9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/cpp/types/libthrowsyntaxerror/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libthrowsyntaxerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/pages/Index.ets deleted file mode 100755 index eec38a73ff..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libthrowsyntaxerror.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/module.json5 deleted file mode 100755 index d9dfe63ec0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "throwsyntaxerror", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "ThrowsyntaxerrorAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ThrowsyntaxerrorAbility", - "srcEntry": "./ets/throwsyntaxerrorability/ThrowsyntaxerrorAbility.ets", - "description": "$string:ThrowsyntaxerrorAbility_desc", - "icon": "$media:layered_image", - "label": "$string:ThrowsyntaxerrorAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/string.json deleted file mode 100755 index b18870a0c9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "ThrowsyntaxerrorAbility_desc", - "value": "description" - }, - { - "name": "ThrowsyntaxerrorAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index fe76fcf134..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testThrowSyntaxError', 0, async (done: Function) => { - console.log('uitest: TestThrowSyntaxError begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'ThrowsyntaxerrorAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('ThrowsyntaxerrorAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestThrowSyntaxError end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/module.json5 deleted file mode 100755 index d69b8b5c42..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwsyntaxerror/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "throwsyntaxerror_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/oh-package.json5 deleted file mode 100755 index a94708ad5b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "throwtypeerror", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libthrowtypeerror.so": "file:./src/main/cpp/types/libthrowtypeerror" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/CMakeLists.txt deleted file mode 100755 index a65ba8e54d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(throwtypeerror SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(throwtypeerror PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/hello.cpp deleted file mode 100755 index e8013f05ad..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/hello.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -static void GetLastErrorAndClean(JSVM_Env env) -{ - // 调用OH_JSVM_GetAndClearLastException接口获取并清除最后一个未处理的异常。即使存在挂起的JavaScript异常,也可以调用此API - JSVM_Value result = nullptr; - JSVM_Status status = OH_JSVM_GetAndClearLastException(env, &result); - // 打印错误信息 - JSVM_Value message; - JSVM_Value errorCode; - OH_JSVM_GetNamedProperty((env), result, "message", &message); - OH_JSVM_GetNamedProperty((env), result, "code", &errorCode); - const int maxMessageLength = 256; - const int maxCodeLength = 256; - char messagestr[maxMessageLength]; - char codeStr[maxCodeLength]; - OH_JSVM_GetValueStringUtf8(env, message, messagestr, maxMessageLength, nullptr); - OH_JSVM_GetValueStringUtf8(env, errorCode, codeStr, maxCodeLength, nullptr); - OH_LOG_INFO(LOG_APP, "JSVM error message: %{public}s, error code: %{public}s", messagestr, codeStr); -} - -// [Start oh_jsvm_throw_type_error] -// OH_JSVM_ThrowTypeError的样例方法 -static JSVM_Value JsVmThrowTypeError(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr); - if (argc == 0) { - // 如果没有传递参数,直接抛出错误 - OH_JSVM_ThrowTypeError(env, "-1", "throwing type error"); - } else if (argc == 1) { - size_t length; - // 通过入参获取到javaScript侧传入的字符串长度 - OH_JSVM_GetValueStringUtf8(env, argv[0], nullptr, 0, &length); - char *buffer = new char[length + 1]; - // 获取入参的字符串内容 - OH_JSVM_GetValueStringUtf8(env, argv[0], buffer, length + 1, nullptr); - // 作为error信息填入到OH_JSVM_ThrowError接口中 - OH_JSVM_ThrowTypeError(env, "self defined error code", buffer); - delete[] buffer; - } - GetLastErrorAndClean(env); - return nullptr; -} -// JsVmThrowTypeError注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsVmThrowTypeError}, -}; -static JSVM_CallbackStruct *method = param; -// JsVmThrowTypeError方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"jsVmThrowTypeError", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char *SRC_CALL_NATIVE = R"JS(jsVmThrowTypeError();jsVmThrowTypeError("self defined error message");)JS"; -// [End oh_jsvm_throw_type_error] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "throwtypeerror", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/oh-package.json5 deleted file mode 100755 index 2b169e9786..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/cpp/types/libthrowtypeerror/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libthrowtypeerror.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/pages/Index.ets deleted file mode 100755 index 5ba8ffaa00..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libthrowtypeerror.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/module.json5 deleted file mode 100755 index 4841afab76..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/module.json5 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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": "throwtypeerror", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "ThrowtypeerrorAbility", - "deviceTypes": [ - "default", - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ThrowtypeerrorAbility", - "srcEntry": "./ets/throwtypeerrorability/ThrowtypeerrorAbility.ets", - "description": "$string:ThrowtypeerrorAbility_desc", - "icon": "$media:layered_image", - "label": "$string:ThrowtypeerrorAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/string.json deleted file mode 100755 index 3f12e62455..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "ThrowtypeerrorAbility_desc", - "value": "description" - }, - { - "name": "ThrowtypeerrorAbility_label", - "value": "JsvmError" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 9ce627cb98..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testThrowTypeError', 0, async (done: Function) => { - console.log('uitest: TestThrowTypeError begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'ThrowtypeerrorAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('ThrowtypeerrorAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestThrowTypeError end'); - done(); - }) - }) -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/module.json5 deleted file mode 100755 index 0c06653f75..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmError/throwtypeerror/src/ohosTest/module.json5 +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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": "throwtypeerror_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/app.json5 deleted file mode 100755 index cab34896e1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.jsvmlifecycle", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/element/string.json deleted file mode 100755 index 9c06c4c0ae..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsvmLifeCycle" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/README.md deleted file mode 100755 index 3b3d2d5bcc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/README.md +++ /dev/null @@ -1,141 +0,0 @@ -# ArkTs使用JSVM-API接口进行生命周期相关开发 - -### 介绍 - -在JSVM-API中,JSVM_Value是一个表示JavaScript值的抽象类型,它可以表示任何JavaScript值,包括基本类型(如数字、字符串、布尔值)和对象类型(如数组、函数、对象等)。 JSVM_Value的生命周期与其在JavaScript中的对应值的生命周期紧密相关。当JavaScript值被垃圾回收时,与之关联的JSVM_Value也将不再有效。重要的是不要在JavaScript值不再存在时尝试使用JSVM_Value。 - -框架层的scope通常用于管理JSVM_Value的生命周期。在JSVM-API中,可以使用OH_JSVM_OpenHandleScope和OH_JSVM_CloseHandleScope函数来创建和销毁scope。通过在scope内创建JSVM_Value,可以确保在scope结束时自动释放JSVM_Value,避免内存泄漏。 - -JSVM_Ref是一个JSVM-API类型,用于管理JSVM_Value的生命周期。JSVM_Ref允许您在JSVM_Value的生命周期内保持对其的引用,即使它已经超出了其原始上下文的范围。这使得您可以在不同的上下文中共享JSVM_Value,并确保在不再需要时正确释放其内存。 - -合理使用OH_JSVM_OpenHandleScope和OH_JSVM_CloseHandleScope管理JSVM_Value的生命周期,做到生命周期最小化,避免发生内存泄漏问题。 - -每个JSVM_Value属于特定的HandleScope,HandleScope通过OH_JSVM_OpenHandleScope和OH_JSVM_CloseHandleScope来建立和关闭,HandleScope关闭后,所属的JSVM_Value就会自动释放。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口进行生命周期相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-life-cycle.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :---------------------------------------------------------------: | :---------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -addfinalizer/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -openescapablehandlescope/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -openhandlescope/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -referenceref/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle > .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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/oh-package.json5 deleted file mode 100755 index a232e1752a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "addfinalizer", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libaddfinalizer.so": "file:./src/main/cpp/types/libaddfinalizer" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/CMakeLists.txt deleted file mode 100755 index a40ac21fbd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmLifeCycle) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(addfinalizer SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(addfinalizer PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/hello.cpp deleted file mode 100755 index 44e52a83f4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/hello.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_add_finalizer] -static int AddFinalizer(JSVM_VM vm, JSVM_Env env) -{ - // 打开 handlescope - JSVM_HandleScope handleScope; - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - // 创建 object 并设置回调 - JSVM_Value obj; - CHECK_RET(OH_JSVM_CreateObject(env, &obj)); - CHECK_RET(OH_JSVM_AddFinalizer( - env, obj, nullptr, - [](JSVM_Env env, void *data, void *hint) -> void { - // Finalizer 方法,可在该方法中清理 Native 对象 - OH_LOG_INFO(LOG_APP, "JSVM: finalizer called."); - }, - nullptr, nullptr)); - OH_LOG_INFO(LOG_APP, "JSVM: finalizer added."); - // 关闭 handlescope,触发 GC,GC 时 Finalizer 会被调用 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - OH_LOG_INFO(LOG_APP, "JSVM: before call gc."); - CHECK_RET(OH_JSVM_MemoryPressureNotification(env, JSVM_MemoryPressureLevel::JSVM_MEMORY_PRESSURE_LEVEL_CRITICAL)); - OH_LOG_INFO(LOG_APP, "JSVM: after call gc."); - - return 0; -} - -static void RunDemo(JSVM_VM vm, JSVM_Env env) -{ - if (AddFinalizer(vm, env) != 0) { - OH_LOG_INFO(LOG_APP, "Run PromiseRegisterHandler failed"); - } -} -// [End oh_jsvm_add_finalizer] - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - JSVM_VM vm; - JSVM_Env envs = nullptr; - RunDemo(vm, envs); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "addfinalizer", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/oh-package.json5 deleted file mode 100755 index dfb41ef937..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/cpp/types/libaddfinalizer/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libaddfinalizer.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/pages/Index.ets deleted file mode 100755 index ddb30835b9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libaddfinalizer.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/module.json5 deleted file mode 100755 index 70b6d5b445..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "addfinalizer", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "AddfinalizerAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "AddfinalizerAbility", - "srcEntry": "./ets/addfinalizerability/AddfinalizerAbility.ets", - "description": "$string:AddfinalizerAbility_desc", - "icon": "$media:layered_image", - "label": "$string:AddfinalizerAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/string.json deleted file mode 100755 index 3194937a92..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "AddfinalizerAbility_desc", - "value": "description" - }, - { - "name": "AddfinalizerAbility_label", - "value": "JsvmLifeCycle" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index c99fa3cf73..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testAddFinalizer', 0, async (done: Function) => { - console.log('uitest: TestAddFinalizer begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'AddfinalizerAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('AddfinalizerAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestAddFinalizer end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/module.json5 deleted file mode 100755 index aa271837b8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/addfinalizer/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "addfinalizer_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/build-profile.json5 deleted file mode 100755 index 3e71ddabaf..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/build-profile.json5 +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "openhandlescope", - "srcPath": "./openhandlescope", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "openescapablehandlescope", - "srcPath": "./openescapablehandlescope", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "referenceref", - "srcPath": "./referenceref", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "addfinalizer", - "srcPath": "./addfinalizer", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigor/hvigor-config.json5 deleted file mode 100755 index a653156fd9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,22 +0,0 @@ -{ - "modelVersion": "5.0.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/ohosTest.md deleted file mode 100755 index bcb491022c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/ohosTest.md +++ /dev/null @@ -1,11 +0,0 @@ -# JsvmLifeCycle 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 为对象添加JSVM_Finalize回调,以便在JavaScript对象被垃圾回收时调用来释放原生对象 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 打开一个新的scope逃逸Handle scope,在关闭该scope之前创建的对象与父作用域有相同的生命周期 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 打开一个Handle scope,确保scope范围内的JSVM_Value不被GC回收 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 增加由Hello World创建的引用的引用计数,以确保对象在有引用时不会被提前释放 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/oh-package.json5 deleted file mode 100755 index 114b120530..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "openescapablehandlescope", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libopenescapablehandlescope.so": "file:./src/main/cpp/types/libopenescapablehandlescope" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 9f8118b41b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmLifeCycle) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(openescapablehandlescope SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(openescapablehandlescope PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/hello.cpp deleted file mode 100755 index 8cdbe605c8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/hello.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_open_escapable_handle_scope_close_escapable_handle_scope_escape_handle] -// OH_JSVM_OpenEscapableHandleScope、OH_JSVM_CloseEscapableHandleScope、OH_JSVM_EscapeHandle的样例方法 -static JSVM_Value EscapableHandleScopeTest(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 创建一个可逃逸的句柄作用域 - JSVM_EscapableHandleScope scope = nullptr; - JSVM_Status status = OH_JSVM_OpenEscapableHandleScope(env, &scope); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_OpenEscapableHandleScope: failed"); - return nullptr; - } - // 在可逃逸的句柄作用域内创建一个obj - JSVM_Value obj; - OH_JSVM_CreateObject(env, &obj); - // 在对象中添加属性 - JSVM_Value value = nullptr; - OH_JSVM_CreateStringUtf8(env, "Test jsvm_escapable_handle_scope", JSVM_AUTO_LENGTH, &value); - OH_JSVM_SetNamedProperty(env, obj, "name", value); - // 调用OH_JSVM_EscapeHandle将对象逃逸到作用域之外 - JSVM_Value escapedObj = nullptr; - OH_JSVM_EscapeHandle(env, scope, obj, &escapedObj); - // 关闭可逃逸的句柄作用域,清理资源 - status = OH_JSVM_CloseEscapableHandleScope(env, scope); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CloseEscapableHandleScope: failed"); - return nullptr; - } - // 此时的escapedObj已逃逸,可以在作用域外继续使用escapedObj - bool result = false; - OH_JSVM_CreateStringUtf8(env, "name", JSVM_AUTO_LENGTH, &value); - OH_JSVM_HasProperty(env, escapedObj, value, &result); - if (result) { - OH_LOG_INFO(LOG_APP, "JSVM EscapableHandleScopeTest: success"); - } - return escapedObj; -} - -// EscapableHandleScopeTest注册回调 -static JSVM_CallbackStruct param[] = { - {.callback = EscapableHandleScopeTest, .data = nullptr}, -}; -static JSVM_CallbackStruct *method = param; -// EscapableHandleScopeTest方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"escapableHandleScopeTest", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -const char *SRC_CALL_NATIVE = "escapableHandleScopeTest()"; -// [End oh_jsvm_open_escapable_handle_scope_close_escapable_handle_scope_escape_handle] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "openescapablehandlescope", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/oh-package.json5 deleted file mode 100755 index a85e422d31..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/cpp/types/libopenescapablehandlescope/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libopenescapablehandlescope.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/pages/Index.ets deleted file mode 100755 index 792847dda2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libopenescapablehandlescope.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/module.json5 deleted file mode 100755 index 305798d21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "openescapablehandlescope", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "OpenescapablehandlescopeAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "OpenescapablehandlescopeAbility", - "srcEntry": "./ets/openescapablehandlescopeability/OpenescapablehandlescopeAbility.ets", - "description": "$string:OpenescapablehandlescopeAbility_desc", - "icon": "$media:layered_image", - "label": "$string:OpenescapablehandlescopeAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/string.json deleted file mode 100755 index ca69330875..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "OpenescapablehandlescopeAbility_desc", - "value": "description" - }, - { - "name": "OpenescapablehandlescopeAbility_label", - "value": "JsvmLifeCycle" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 0b39b5ed67..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testOpenEscapableHandleScope', 0, async (done: Function) => { - console.log('uitest: TestOpenEscapableHandleScope begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'OpenescapablehandlescopeAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('OpenescapablehandlescopeAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestOpenEscapableHandleScope end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/module.json5 deleted file mode 100755 index 6cabbf718b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openescapablehandlescope/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "openescapablehandlescope_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/oh-package.json5 deleted file mode 100755 index 423e154e35..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "openhandlescope", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libopenhandlescope.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 2d159bb181..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmLifeCycle) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(openhandlescope SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(openhandlescope PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/hello.cpp deleted file mode 100755 index ca40f5dec3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/hello.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_open_handle_scope_and_oh_jsvm_close_handle_scope] -// OH_JSVM_OpenHandleScope、OH_JSVM_CloseHandleScope的三种样例方法 -static JSVM_Value HandleScopeFor(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 在for循环中频繁调用JSVM接口创建js对象时,要加handle_scope及时释放不再使用的资源。 - // 下面例子中,每次循环结束局部变量res的生命周期已结束,因此加scope及时释放其持有的js对象,防止内存泄漏 - constexpr uint32_t DIFF_VALUE_HUNDRED_THOUSAND = 10000; - JSVM_Value checked = nullptr; - for (int i = 0; i < DIFF_VALUE_HUNDRED_THOUSAND; i++) { - JSVM_HandleScope scope = nullptr; - JSVM_Status status = OH_JSVM_OpenHandleScope(env, &scope); - if (status != JSVM_OK || scope == nullptr) { - OH_JSVM_GetBoolean(env, false, &checked); - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_OpenHandleScope: failed"); - return checked; - } - JSVM_Value res = nullptr; - OH_JSVM_CreateObject(env, &res); - status = OH_JSVM_CloseHandleScope(env, scope); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_CloseHandleScope: failed"); - } - } - OH_JSVM_GetBoolean(env, true, &checked); - OH_LOG_INFO(LOG_APP, "JSVM HandleScopeFor: success"); - return checked; -} - -// HandleScopeFor注册回调 -static JSVM_CallbackStruct param[] = { - {.callback = HandleScopeFor, .data = nullptr}, -}; - -static JSVM_CallbackStruct *method = param; -// HandleScopeFor方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"HandleScopeFor", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -const char *SRC_CALL_NATIVE = "HandleScopeFor()"; -// [End oh_jsvm_open_handle_scope_and_oh_jsvm_close_handle_scope] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "openhandlescope", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 89c71eb71c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libopenhandlescope.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/pages/Index.ets deleted file mode 100755 index 03c5e0b491..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libopenhandlescope.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/module.json5 deleted file mode 100755 index ba711d6075..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "openhandlescope", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/string.json deleted file mode 100755 index edd4b66d25..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "JsvmLifeCycle" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 9d04fd8fd4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testOpenHandleScope', 0, async (done: Function) => { - console.log('uitest: TestOpenHandleScope begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestOpenHandleScope end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/module.json5 deleted file mode 100755 index 396fcfaa88..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/openhandlescope/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "openhandlescope_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/oh-package.json5 deleted file mode 100755 index 5bd37280af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "referenceref", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libreferenceref.so": "file:./src/main/cpp/types/libreferenceref" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/CMakeLists.txt deleted file mode 100755 index e6ebbba849..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(JsvmLifeCycle) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(referenceref SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(referenceref PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/hello.cpp deleted file mode 100755 index 387d2a6f14..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/hello.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_reference_ref_and_oh_jsvm_reference_unref] -static JSVM_Value UseReference(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 创建 JavaScript 对象 - JSVM_Value obj = nullptr; - OH_JSVM_CreateObject(env, &obj); - JSVM_Value value = nullptr; - OH_JSVM_CreateStringUtf8(env, "UseReference", JSVM_AUTO_LENGTH, &value); - OH_JSVM_SetNamedProperty(env, obj, "name", value); - - JSVM_Ref g_ref = nullptr; - // 创建对JavaScript对象的引用 - JSVM_Status status = OH_JSVM_CreateReference(env, obj, 1, &g_ref); - if (status != JSVM_OK) { - return nullptr; - } - - // 增加传入引用的引用计数并返回生成的引用计数 - uint32_t result; - OH_JSVM_ReferenceRef(env, g_ref, &result); - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_ReferenceRef, count = %{public}d.", result); - const int resultValue = 2; - if (result != resultValue) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_ReferenceRef: failed"); - return nullptr; - } - - // 减少传入引用的引用计数并返回生成的引用计数 - uint32_t num; - OH_JSVM_ReferenceUnref(env, g_ref, &num); - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_ReferenceUnref, count = %{public}d.", num); - if (num != 1) { - return nullptr; - } - - JSVM_Value object = nullptr; - // 通过调用OH_JSVM_GetReferenceValue获取引用的JavaScript对象 - status = OH_JSVM_GetReferenceValue(env, g_ref, &object); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetReferenceValue: failed"); - return nullptr; - } - - // 不再使用引用,通过调用OH_JSVM_DeleteReference删除对JavaScript对象的引用 - status = OH_JSVM_DeleteReference(env, g_ref); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_DeleteReference: failed"); - return nullptr; - } - - // 将获取到的对象返回 - OH_LOG_INFO(LOG_APP, "JSVM UseReference success"); - return object; -} - -// CreateReference、UseReference、DeleteReference注册回调 -static JSVM_CallbackStruct param[] = { - {.callback = UseReference, .data = nullptr}, -}; -static JSVM_CallbackStruct *method = param; -// CreateReference、UseReference、DeleteReference方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"useReference", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -const char *SRC_CALL_NATIVE = "useReference()"; -// [End oh_jsvm_reference_ref_and_oh_jsvm_reference_unref] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "referenceref", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/oh-package.json5 deleted file mode 100755 index ce625a1fcd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/cpp/types/libreferenceref/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libreferenceref.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/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/pages/Index.ets deleted file mode 100755 index 691cf5d69c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libreferenceref.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/module.json5 deleted file mode 100755 index 0ad3206d6f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "referenceref", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "ReferencerefAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ReferencerefAbility", - "srcEntry": "./ets/referencerefability/ReferencerefAbility.ets", - "description": "$string:ReferencerefAbility_desc", - "icon": "$media:layered_image", - "label": "$string:ReferencerefAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/string.json deleted file mode 100755 index 973fe803e3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "ReferencerefAbility_desc", - "value": "description" - }, - { - "name": "ReferencerefAbility_label", - "value": "JsvmLifeCycle" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 3aa1dbc83b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testReferenceRef', 0, async (done: Function) => { - console.log('uitest: TestReferenceRef begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'ReferencerefAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('ReferencerefAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestReferenceRef end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/module.json5 deleted file mode 100755 index 45b4f0c1a6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/JsvmLifeCycle/referenceref/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "referenceref_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/app.json5 deleted file mode 100755 index de155cec19..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.usageinstructionsone", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/element/string.json deleted file mode 100755 index 23a0c5df08..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "UsageInstructionsOne" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/README.md deleted file mode 100755 index 5d13c47d5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/README.md +++ /dev/null @@ -1,160 +0,0 @@ -# ArkTS JSVM-API使用指导 - -### 介绍 - -使用JSVM-API实现跨语言交互,首先需要按照JSVM-API的机制实现模块的注册和加载等相关动作。 - -- ArkTS/JS侧:实现C++方法的调用。代码比较简单,import一个对应的so库后,即可调用C++方法。 -- Native侧:.cpp文件,实现模块的注册。需要提供注册lib库的名称,并在注册回调方法中定义接口的映射关系,即Native方法及对应的JS/ArkTS接口名称等。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口进行函数创建和调用](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-function-call.md) -- [使用JSVM-API接口进行虚拟机快照相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-create-snapshot.md) -- [使用JSVM-API接口进行JSON操作](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-JSON.md) -- [使用JSVM-API接口进行任务队列相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-execute_tasks.md) -- [使用JSVM-API接口进行WebAssembly模块相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-wasm.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------------------: | :----------------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击hello world,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -aboutjson/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -createsnapshot/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -functioncall/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -pumpmessageloop/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 - webassembly/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/UsageInstructionsOne > .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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/oh-package.json5 deleted file mode 100755 index dba47d4ea7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "aboutjson", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libaboutjson.so": "file:./src/main/cpp/types/libaboutjson" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 083fe70ccb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(aboutjson SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(aboutjson PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/hello.cpp deleted file mode 100755 index eed89dc8d6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/hello.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * 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 "ark_runtime/jsvm.h" -#include -#include - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_json_parse_and_json_stringify] -// 解析JSON数字 -static JSVM_Value JsonParseNumber(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 设置要解析的JSON数字 - std::string strNumber = "10.555"; - JSVM_Value jsonString; - JSVM_CALL(OH_JSVM_CreateStringUtf8(env, strNumber.c_str(), strNumber.size(), &jsonString)); - JSVM_Value jsonObject; - // 调用OH_JSVM_JsonParse函数解析JSON数字,并将结果存储在JSON对象中 - JSVM_CALL(OH_JSVM_JsonParse(env, jsonString, &jsonObject)); - double number; - JSVM_CALL(OH_JSVM_GetValueDouble(env, jsonObject, &number)); - OH_LOG_INFO(LOG_APP, "Test JSVM jsonParseNumber: %{public}f", number); - return nullptr; -} - -// 解析JSON字符串中的对象 -static JSVM_Value JsonParseObject(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 设置要解析的JSON对象字符串 - std::string strObject = "{\"first\": \"one\", \"second\": \"two\", \"third\": \"three\"}"; - JSVM_Value strJson; - JSVM_CALL(OH_JSVM_CreateStringUtf8(env, strObject.c_str(), strObject.size(), &strJson)); - JSVM_Value jsonObject; - // 调用OH_JSVM_JsonParse函数解析JSON对象字符串,并将结果存储在JSON对象中 - JSVM_CALL(OH_JSVM_JsonParse(env, strJson, &jsonObject)); - JSVM_Value jsonString; - // 调用OH_JSVM_JsonStringify函数将对象转换为字符串格式,并将结果存储在JSVM字符串对象中 - JSVM_CALL(OH_JSVM_JsonStringify(env, jsonObject, &jsonString)); - size_t totalLen = 0; - JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, nullptr, 0, &totalLen)); - size_t needLen = totalLen + 1; - char* buff = new char[needLen]; - JSVM_CALL(OH_JSVM_GetValueStringUtf8(env, jsonString, buff, needLen, &totalLen)); - OH_LOG_INFO(LOG_APP, "Test JSVM jsonParseNumber: %{public}s", buff); - delete[] buff; - return nullptr; -} - -// JsonParse注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = JsonParseNumber}, - {.data = nullptr, .callback = JsonParseObject}, -}; - -static JSVM_CallbackStruct *method = param; - -JSVM_PropertyDescriptor descriptor[] = { - {"jsonParseNumber", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, - {"jsonParseObject", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 待执行的js代码 -static const char *STR_TASK = R"JS(jsonParseNumber();jsonParseObject();)JS"; -// [End oh_jsvm_json_parse_and_json_stringify] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, STR_TASK, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "aboutjson", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/oh-package.json5 deleted file mode 100755 index 45d6184b42..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/cpp/types/libaboutjson/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libaboutjson.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/pages/Index.ets deleted file mode 100755 index 14a9ad3167..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libaboutjson.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/module.json5 deleted file mode 100755 index cd1fb3993f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "aboutjson", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "AboutjsonAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "AboutjsonAbility", - "srcEntry": "./ets/aboutjsonability/AboutjsonAbility.ets", - "description": "$string:AboutjsonAbility_desc", - "icon": "$media:layered_image", - "label": "$string:AboutjsonAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/string.json deleted file mode 100755 index 7af45ffc6f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "AboutjsonAbility_desc", - "value": "description" - }, - { - "name": "AboutjsonAbility_label", - "value": "UsageInstructionsOne" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 59ddebeef1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testAboutJSON', 0, async (done: Function) => { - console.log('uitest: TestAboutJSON begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'AboutjsonAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('AboutjsonAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestAboutJSON end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/module.json5 deleted file mode 100755 index af813d8638..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/aboutjson/src/ohosTest/module.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "aboutjson_test", - "type": "feature", - "deviceTypes": [ - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/build-profile.json5 deleted file mode 100755 index 589d45ae02..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/build-profile.json5 +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "createsnapshot", - "srcPath": "./createsnapshot", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "functioncall", - "srcPath": "./functioncall", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "aboutjson", - "srcPath": "./aboutjson", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "pumpmessageloop", - "srcPath": "./pumpmessageloop", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "webassembly", - "srcPath": "./webassembly", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/oh-package.json5 deleted file mode 100755 index f7c7c87cc7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "createsnapshot", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libcreatesnapshot.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/CMakeLists.txt deleted file mode 100755 index bc1b341b4e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(createsnapshot SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(createsnapshot PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/hello.cpp deleted file mode 100755 index c6fa3cb59a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/hello.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_create_snapshot_and_create_env_from_snapshot] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include -#include - -#define LOG_DEMAIN 0x0202 -#define LOG_TAG "TEST_TAG" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用GET_AND_THROW_LAST_ERROR处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -static const int MAX_BUFFER_SIZE = 128; -// CreateHelloString()函数需绑定到JSVM虚拟机, 用于OH_JSVM_CreateSnapshot虚拟机快照的正常创建 -static JSVM_Value CreateHelloString(JSVM_Env env, JSVM_CallbackInfo info) -{ - JSVM_Value outPut; - OH_JSVM_CreateStringUtf8(env, "Hello world!", JSVM_AUTO_LENGTH, &outPut); - return outPut; -} -// 提供外部引用的方式以便JavaScript环境可以调用绑定的函数 -static JSVM_CallbackStruct helloCb = {CreateHelloString, nullptr}; - -static intptr_t g_externals[] = { - (intptr_t)&helloCb, - 0, -}; - -static JSVM_Value RunVMScript(JSVM_Env env, std::string &src) -{ - // 打开handleScope作用域 - JSVM_HandleScope handleScope; - OH_JSVM_OpenHandleScope(env, &handleScope); - JSVM_Value jsStr = nullptr; - OH_JSVM_CreateStringUtf8(env, src.c_str(), src.size(), &jsStr); - // 编译JavaScript代码 - JSVM_Script script; - OH_JSVM_CompileScript(env, jsStr, nullptr, 0, true, nullptr, &script); - // 执行JavaScript代码 - JSVM_Value result = nullptr; - OH_JSVM_RunScript(env, script, &result); - // 关闭handleScope作用域 - OH_JSVM_CloseHandleScope(env, handleScope); - return result; -} -// OH_JSVM_CreateSnapshot的样例方法 -static void CreateVMSnapshot() -{ - // 创建JavaScript虚拟机实例,打开虚拟机作用域 - JSVM_VM vm; - JSVM_CreateVMOptions vmOptions; - memset(&vmOptions, 0, sizeof(vmOptions)); - // isForSnapshotting设置该虚拟机是否用于创建快照 - vmOptions.isForSnapshotting = true; - OH_JSVM_CreateVM(&vmOptions, &vm); - JSVM_VMScope vmScope; - OH_JSVM_OpenVMScope(vm, &vmScope); - // 创建JavaScript环境,打开环境作用域 - JSVM_Env env; - // 将native函数注册成JavaScript可调用的方法 - JSVM_PropertyDescriptor descriptor[] = { - {"createHelloString", nullptr, &helloCb, nullptr, nullptr, nullptr, JSVM_DEFAULT}, - }; - OH_JSVM_CreateEnv(vm, 1, descriptor, &env); - JSVM_EnvScope envScope; - OH_JSVM_OpenEnvScope(env, &envScope); - // 使用OH_JSVM_CreateSnapshot创建虚拟机的启动快照 - const char *blobData = nullptr; - size_t blobSize = 0; - JSVM_Env envs[1] = {env}; - OH_JSVM_CreateSnapshot(vm, 1, envs, &blobData, &blobSize); - // 将snapshot保存到文件中 - // 保存快照数据,/data/storage/el2/base/files/test_blob.bin为沙箱路径 - // 以包名为com.example.jsvm为例,实际文件会保存到/data/app/el2/100/base/com.example.jsvm/files/test_blob.bin - std::ofstream file("/data/storage/el2/base/files/test_blob.bin", - std::ios::out | std::ios::binary | std::ios::trunc); - file.write(blobData, blobSize); - file.close(); - // 关闭并销毁环境和虚拟机 - OH_JSVM_CloseEnvScope(env, envScope); - OH_JSVM_DestroyEnv(env); - OH_JSVM_CloseVMScope(vm, vmScope); - OH_JSVM_DestroyVM(vm); -} - -static void RunVMSnapshot() -{ - // blobData的生命周期不能短于vm的生命周期 - // 从文件中读取snapshot - std::vector blobData; - std::ifstream file("/data/storage/el2/base/files/test_blob.bin", std::ios::in | std::ios::binary | std::ios::ate); - size_t blobSize = file.tellg(); - blobData.resize(blobSize); - file.seekg(0, std::ios::beg); - file.read(blobData.data(), blobSize); - file.close(); - OH_LOG_INFO(LOG_APP, "Test JSVM RunVMSnapshot read file blobSize = : %{public}ld", blobSize); - // 使用快照数据创建虚拟机实例 - JSVM_VM vm; - JSVM_CreateVMOptions vmOptions; - memset(&vmOptions, 0, sizeof(vmOptions)); - vmOptions.snapshotBlobData = blobData.data(); - vmOptions.snapshotBlobSize = blobSize; - OH_JSVM_CreateVM(&vmOptions, &vm); - JSVM_VMScope vmScope; - OH_JSVM_OpenVMScope(vm, &vmScope); - // 从快照中创建环境env - JSVM_Env env; - OH_JSVM_CreateEnvFromSnapshot(vm, 0, &env); - JSVM_EnvScope envScope; - OH_JSVM_OpenEnvScope(env, &envScope); - // 执行js脚本,快照记录的env中定义了createHelloString() - std::string src = "createHelloString()"; - JSVM_Value result = RunVMScript(env, src); - // 环境关闭前检查脚本运行结果 - char str[MAX_BUFFER_SIZE]; - OH_JSVM_GetValueStringUtf8(env, result, str, MAX_BUFFER_SIZE, nullptr); - if (strcmp(str, "Hello world!") != 0) { - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d", __FILE__, __LINE__); - } - // 关闭并销毁环境和虚拟机 - OH_JSVM_CloseEnvScope(env, envScope); - OH_JSVM_DestroyEnv(env); - OH_JSVM_CloseVMScope(vm, vmScope); - OH_JSVM_DestroyVM(vm); - return; -} - -static JSVM_Value AdjustExternalMemory(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 在创建虚拟机快照时,如果存在对外部的依赖,需要在OH_JSVM_Init时,将外部依赖注册到initOptions.externalReferences中 - // 创建虚拟机快照并将快照保存到文件中 - CreateVMSnapshot(); - // snapshot可以记录下特定的js执行环境,可以跨进程通过snapshot快速还原出js执行上下文环境 - RunVMSnapshot(); - JSVM_Value result = nullptr; - OH_JSVM_CreateInt32(env, 0, &result); - return result; -} - -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = AdjustExternalMemory}, -}; -static JSVM_CallbackStruct *method = param; -// AdjustExternalMemory方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"adjustExternalMemory", nullptr, method, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试JS -const char *SRC_CALL_NATIVE = R"JS(adjustExternalMemory();)JS"; - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - initOptions.externalReferences = g_externals; - int argc = 0; - char **argv = nullptr; - initOptions.argc = &argc; - initOptions.argv = argv; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - OH_LOG_INFO(LOG_APP, "JSVM Init"); - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}, - }; - - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "createsnapshot", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } -// [End oh_jsvm_create_snapshot_and_create_env_from_snapshot] diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 2a68d78e46..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libcreatesnapshot.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/pages/Index.ets deleted file mode 100755 index 8490bd77e6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 napitest from 'libcreatesnapshot.so'; - -// [Start create_snapshot_call_native] -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} -// [End create_snapshot_call_native] diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/module.json5 deleted file mode 100755 index 4fd68d7d5d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "createsnapshot", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/string.json deleted file mode 100755 index 57b4ddbcfb..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "UsageInstructionsOne" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index fd2208064c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testVirtualMachine', 0, async (done: Function) => { - console.log('uitest: TestVirtualMachine begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestVirtualMachine end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/module.json5 deleted file mode 100755 index 1ddcba8011..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/createsnapshot/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "createsnapshot_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/oh-package.json5 deleted file mode 100755 index 5311039a72..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "functioncall", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libfunctioncall.so": "file:./src/main/cpp/types/libfunctioncall" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 653ad2d17c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -# 添加名为entry的库 -add_library(functioncall SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(functioncall PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/hello.cpp deleted file mode 100755 index a85a5900d7..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/hello.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start jsvm_function_call] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -#define CHECK_RET(cond) \ - if ((cond)) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } - -#define CHECK(cond) \ - if (!(cond)) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } - -JSVM_Value NativeCreateFunctionTest(JSVM_Env env, JSVM_CallbackInfo info) -{ - void *data; - size_t argc = 1; - JSVM_Value argv[1] = {nullptr}; - JSVM_Value thisArg; - // 获取callback 参数信息 - JSVM_Status ret = OH_JSVM_GetCbInfo(env, info, &argc, &argv[0], &thisArg, &data); - if (ret != JSVM_OK) { - const JSVM_ExtendedErrorInfo *info; - OH_JSVM_GetLastErrorInfo(env, &info); - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", - __FILE__, __LINE__, ret, info != nullptr ? info->errorMessage : ""); - return nullptr; - } - const int maxMessageLength = 256; - char message[256]; - OH_JSVM_GetValueStringLatin1(env, argv[0], message, maxMessageLength, nullptr); - if (data == nullptr) { - OH_LOG_ERROR(LOG_APP, "jsvm: %{public}s; callback data null", message); - } else { - OH_LOG_INFO(LOG_APP, "jsvm: %{public}s; %{public}s", message, (char *)data); - } - return nullptr; -} - -static int32_t TEST_FUNC() -{ - JSVM_InitOptions initOptions{}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - static bool isVMInit = false; - if (!isVMInit) { - isVMInit = true; - // 单个进程只用初始化一次 - OH_JSVM_Init(&initOptions); - } - CHECK_RET(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK_RET(OH_JSVM_CreateEnv(vm, 0, nullptr, &env)); - CHECK_RET(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 创建并检查函数 - char hello[] = "Hello World!"; - JSVM_CallbackStruct cb = {NativeCreateFunctionTest, (void *)hello}; - JSVM_Value func; - CHECK_RET(OH_JSVM_CreateFunction(env, "", JSVM_AUTO_LENGTH, &cb, &func)); - bool isFunction = false; - CHECK_RET(OH_JSVM_IsFunction(env, func, &isFunction)); - CHECK(isFunction); - - // 将函数设置到全局对象中 - JSVM_Value global; - CHECK_RET(OH_JSVM_GetGlobal(env, &global)); - JSVM_Value key; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, "NativeFunc", JSVM_AUTO_LENGTH, &key)); - CHECK_RET(OH_JSVM_SetProperty(env, global, key, func)); - - // 通过call 接口调用函数 - JSVM_Value argv[1] = {nullptr}; - OH_JSVM_CreateStringUtf8(env, "jsvm api call function", JSVM_AUTO_LENGTH, &argv[0]); - CHECK_RET(OH_JSVM_CallFunction(env, global, func, 1, argv, &result)); - - // 通过script调用函数 - JSVM_Script script; - JSVM_Value jsSrc; - const char *srcCallNative = R"JS(NativeFunc('js source call function');)JS"; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, srcCallNative, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK_RET(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK_RET(OH_JSVM_DestroyEnv(env)); - CHECK_RET(OH_JSVM_DestroyVM(vm)); - return 0; -} -// [End jsvm_function_call] - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TEST_FUNC(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "functioncall", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/oh-package.json5 deleted file mode 100755 index 35220b6282..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/cpp/types/libfunctioncall/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libfunctioncall.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/pages/Index.ets deleted file mode 100755 index 077afe3387..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libfunctioncall.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/module.json5 deleted file mode 100755 index fb49b29a59..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "functioncall", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "FunctioncallAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "FunctioncallAbility", - "srcEntry": "./ets/functioncallability/FunctioncallAbility.ets", - "description": "$string:FunctioncallAbility_desc", - "icon": "$media:layered_image", - "label": "$string:FunctioncallAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/string.json deleted file mode 100755 index 44eeb07d7f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "FunctioncallAbility_desc", - "value": "description" - }, - { - "name": "FunctioncallAbility_label", - "value": "UsageInstructionsOne" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 54cb707f94..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testFunctionCall', 0, async (done: Function) => { - console.log('uitest: TestFunctionCall begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'FunctioncallAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('FunctioncallAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestFunctionCall end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/module.json5 deleted file mode 100755 index 6be052cc06..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/functioncall/src/ohosTest/module.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "functioncall_test", - "type": "feature", - "deviceTypes": [ - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/ohosTest.md deleted file mode 100755 index 7514b8b85d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/ohosTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# UsageInstructionsOne 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -|---------------------------------|--------|---------------|------------------|------|------| -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 使用JSVM-API接口进行JSON操作 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 使用JSVM-API接口进行函数创建和调用 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 使用JSVM-API接口进行虚拟机快照相关开发 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 使用JSVM-API接口进行任务队列相关开发 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 使用JSVM-API接口进行WebAssembly模块相关开发 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/build-profile.json5 deleted file mode 100755 index 14bbd03b5c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/build-profile.json5 +++ /dev/null @@ -1,39 +0,0 @@ -{ - "apiType": "stageMode", - "buildOption": { - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/oh-package.json5 deleted file mode 100755 index 65d6248edd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/oh-package.json5 +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "pumpmessageloop", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libpumpmessageloop.so": "file:./src/main/cpp/types/libpumpmessageloop" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/CMakeLists.txt deleted file mode 100755 index b379448254..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsOne) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(pumpmessageloop SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(pumpmessageloop PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/hello.cpp deleted file mode 100755 index ca0f8add77..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/hello.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" -// [Start oh_jsvm_pump_message_loop_and_perform_microtask_checkpoint] -#include -#include -// [StartExclude oh_jsvm_pump_message_loop_and_perform_microtask_checkpoint] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_pump_message_loop_and_perform_microtask_checkpoint] - -// 待执行的js代码 -static const char *STR_TASK = R"JS( - // wasm 字节码 (以add 模块为例) - // 以下 wasmBuffer 对应的 wasm 字节码文本格式如下所示,只包含了一个函数 add - // (module - // (func $add (param $lhs i32) (param $rhs i32) (result i32) - // local.get $lhs - // local.get $rhs - // i32.add - // ) - // (export "add" (func $add)) - // ) - var wasmBytes = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, - 0x60, 0x02, 0x7f, 0x7f, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x07, - 0x07, 0x01, 0x03, 0x61, 0x64, 0x64, 0x00, 0x00, 0x0a, 0x09, 0x01, - 0x07, 0x00, 0x20, 0x00, 0x20, 0x01, 0x6a, 0x0b]); - - var p = WebAssembly.instantiate(wasmBytes, {}); - p.then((result) => { - consoleinfo("Called with instance " + result); - }); - p.finally(() => { - consoleinfo("Called Finally"); - }); -)JS"; - -// 保证js代码中的打印信息可以正常输出 -static JSVM_Value ConsoleInfo(JSVM_Env env, JSVM_CallbackInfo info) -{ - size_t argc = 1; - JSVM_Value args[1]; - #define MAX_LOG_LENGTH 255 - char log[MAX_LOG_LENGTH + 1] = ""; - size_t logLength; - JSVM_CALL(OH_JSVM_GetCbInfo(env, info, &argc, args, NULL, NULL)); - - OH_JSVM_GetValueStringUtf8(env, args[0], log, MAX_LOG_LENGTH, &logLength); - log[MAX_LOG_LENGTH] = 0; - OH_LOG_INFO(LOG_APP, "JSVM API TEST: %{public}s", log); - return nullptr; -} - -// 注册consoleinfo的方法 -JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = ConsoleInfo}, -}; -JSVM_PropertyDescriptor descriptor[] = { - {"consoleinfo", NULL, ¶m[0], NULL, NULL, NULL, JSVM_DEFAULT}, -}; - -static int32_t TestJSVM() -{ - JSVM_InitOptions init_options; - memset(&init_options, 0, sizeof(init_options)); - if (g_aa == 0) { - OH_JSVM_Init(&init_options); - g_aa++; - } - // 创建JavaScript虚拟机实例,打开虚拟机作用域 - JSVM_VM vm; - JSVM_CreateVMOptions options; - memset(&options, 0, sizeof(options)); - CHECK(OH_JSVM_CreateVM(&options, &vm)); - JSVM_VMScope vm_scope; - CHECK(OH_JSVM_OpenVMScope(vm, &vm_scope)); - - JSVM_Env env; - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - JSVM_EnvScope envScope; - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - JSVM_HandleScope handlescope; - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handlescope)); - JSVM_Value sourcecodevalue; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, STR_TASK, strlen(STR_TASK), &sourcecodevalue)); - JSVM_Script script; - CHECK_RET(OH_JSVM_CompileScript(env, sourcecodevalue, nullptr, 0, true, nullptr, &script)); - JSVM_Value result; - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - bool rst = false; - auto start = std::chrono::system_clock::now(); - while (true) { - // 如果任务队列中没有任务启动,则rst设置为false - CHECK_RET(OH_JSVM_PumpMessageLoop(vm, &rst)); - CHECK_RET(OH_JSVM_PerformMicrotaskCheckpoint(vm)); - // 定时退出 - auto now = std::chrono::system_clock::now(); - auto cost = std::chrono::duration_cast(now - start).count(); - const int timeoutMs = 100; - if (cost > timeoutMs) { - break; - } - } - - // 关闭并销毁环境和虚拟机 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handlescope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_CloseVMScope(vm, vm_scope)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} -// [End oh_jsvm_pump_message_loop_and_perform_microtask_checkpoint] - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "pumpmessageloop", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/oh-package.json5 deleted file mode 100755 index 5ee71f8cd5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/cpp/types/libpumpmessageloop/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libpumpmessageloop.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pages/Index.ets deleted file mode 100755 index 421e35222f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libpumpmessageloop.so'; - -@Entry -@Component -struct Index { - @State message: string = 'OH_JSVM_PumpMessageLoop'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/module.json5 deleted file mode 100755 index 1a185959e6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -{ - "module": { - "name": "pumpmessageloop", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "PumpmessageloopAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "PumpmessageloopAbility", - "srcEntry": "./ets/pumpmessageloopability/PumpmessageloopAbility.ets", - "description": "$string:PumpmessageloopAbility_desc", - "icon": "$media:layered_image", - "label": "$string:PumpmessageloopAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/module.json5 deleted file mode 100755 index 22f91b0ebc..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsOne/pumpmessageloop/src/ohosTest/module.json5 +++ /dev/null @@ -1,11 +0,0 @@ -{ - "module": { - "name": "pumpmessageloop_test", - "type": "feature", - "deviceTypes": [ - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/.gitignore deleted file mode 100755 index 0b9dda19af..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/app.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/app.json5 deleted file mode 100755 index 1ae38a4aaf..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.usageinstructionstwo", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/element/string.json deleted file mode 100755 index eb95d62248..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "UsageInstructionsTwo" - } - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/README.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/README.md deleted file mode 100755 index c803ac6f18..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/README.md +++ /dev/null @@ -1,179 +0,0 @@ -# ArkTS JSVM-API使用指导 - -### 介绍 - -使用JSVM-API实现跨语言交互,首先需要按照JSVM-API的机制实现模块的注册和加载等相关动作。 - -- ArkTS/JS侧:实现C++方法的调用。代码比较简单,import一个对应的so库后,即可调用C++方法。 -- Native侧:.cpp文件,实现模块的注册。需要提供注册lib库的名称,并在注册回调方法中定义接口的映射关系,即Native方法及对应的JS/ArkTS接口名称等。 - -该工程中展示的代码详细描述可查如下链接: - -- [使用JSVM-API接口获取JSVM API的版本号](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-version.md) -- [使用JSVM-API接口进行JavaScript代码调试调优](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-heapstatistics-debugger-cpuprofiler-heapsnapshot.md) -- [使用JSVM-API判断给定的两个JS value是否严格相等](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-strict-equals.md) -- [使用JSVM-API进行内存管理](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-memory-management.md) - -### 效果预览 - -| 首页 | 执行及结果即时反馈 | -| :----------------------------------------------------------------------: | :----------------------------------------------------------------------: | -| | | - -### 使用说明 - -1. 在主界面,可以点击Hello World,开始执行。 -2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 - -### 工程目录 - -``` -adjustexternalmemory/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getheapstatistics/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接口 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getversion/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -getvm/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -memorypressurenotification/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -strictequals/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ │ ├── libentry - │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 - │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 - │ │ ├── CMakeLists.txt // 配置CMake打包参数 - │ │ ├── hello.cpp // 实现Native侧的runTest接 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ ├── test - │ │ ├── Ability.test.ets // 自动化测试代码 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:Phone。 - -2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 - -3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo > .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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/oh-package.json5 deleted file mode 100755 index c9cc6951fd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "adjustexternalmemory", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libadjustexternalmemory.so": "file:./src/main/cpp/types/libadjustexternalmemory" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/CMakeLists.txt deleted file mode 100755 index bb05dea29e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(adjustexternalmemory SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(adjustexternalmemory PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/hello.cpp deleted file mode 100755 index c7810d9f44..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/hello.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_adjust_external_memory] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_adjust_external_memory] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_adjust_external_memory] - -// OH_JSVM_AdjustExternalMemory的样例方法 -static JSVM_Value AdjustExternalMemory(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 分配1MB的内存 - int64_t change = 1024 * 1024; - int64_t adjustedValue = 0; - JSVM_Status status = OH_JSVM_AdjustExternalMemory(env, change, &adjustedValue); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_AdjustExternalMemory: failed"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_AdjustExternalMemory: success"); - OH_LOG_INFO(LOG_APP, "JSVM Allocate memory size: %{public}d", adjustedValue); - } - JSVM_Value checked; - OH_JSVM_GetBoolean(env, true, &checked); - return checked; -} -// AdjustExternalMemory注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = AdjustExternalMemory}, -}; -static JSVM_CallbackStruct *method = param; -// AdjustExternalMemory方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"adjustExternalMemory", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -const char *SRC_CALL_NATIVE = R"JS(adjustExternalMemory())JS"; -// [End oh_jsvm_adjust_external_memory] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "adjustexternalmemory", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/oh-package.json5 deleted file mode 100755 index 772e11bab6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/cpp/types/libadjustexternalmemory/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libadjustexternalmemory.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/pages/Index.ets deleted file mode 100755 index 6a1ce75aed..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libadjustexternalmemory.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/module.json5 deleted file mode 100755 index 5d0fc1b026..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "adjustexternalmemory", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "AdjustexternalmemoryAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "AdjustexternalmemoryAbility", - "srcEntry": "./ets/adjustexternalmemoryability/AdjustexternalmemoryAbility.ets", - "description": "$string:AdjustexternalmemoryAbility_desc", - "icon": "$media:layered_image", - "label": "$string:AdjustexternalmemoryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/string.json deleted file mode 100755 index c339dd7cd9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "AdjustexternalmemoryAbility_desc", - "value": "description" - }, - { - "name": "AdjustexternalmemoryAbility_label", - "value": "UsageInstructionsTwo" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index fc125513d9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testAdjustExternalMemory', 0, async (done: Function) => { - console.log('uitest: TestAdjustExternalMemory begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'AdjustexternalmemoryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('AdjustexternalmemoryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestAdjustExternalMemory end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/module.json5 deleted file mode 100755 index 170918af62..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/adjustexternalmemory/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "adjustexternalmemory_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/build-profile.json5 deleted file mode 100755 index 38065e7524..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/build-profile.json5 +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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", - "compileSdkVersion": "5.0.3(15)", - "compatibleSdkVersion": "5.0.3(15)", - "targetSdkVersion": "5.0.3(15)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "getvm", - "srcPath": "./getvm", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getheapstatistics", - "srcPath": "./getheapstatistics", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "getversion", - "srcPath": "./getversion", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "adjustexternalmemory", - "srcPath": "./adjustexternalmemory", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "memorypressurenotification", - "srcPath": "./memorypressurenotification", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "strictequals", - "srcPath": "./strictequals", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/code-linter.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/code-linter.json5 deleted file mode 100755 index 9deb980763..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/code-linter.json5 +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/oh-package.json5 deleted file mode 100755 index 4aa4f00e13..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getheapstatistics", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetheapstatistics.so": "file:./src/main/cpp/types/libgetheapstatistics" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/CMakeLists.txt deleted file mode 100755 index b16e9bf4b5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getheapstatistics SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getheapstatistics PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/hello.cpp deleted file mode 100755 index feb8547a11..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/hello.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_heap_statistics] -#include "napi/native_api.h" -#include "hilog/log.h" -#include "ark_runtime/jsvm.h" -// [StartExclude oh_jsvm_get_heap_statistics] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_heap_statistics] - -// OH_JSVM_GetHeapStatistics的样例方法 -void PrintHeapStatistics(JSVM_HeapStatistics result) -{ - OH_LOG_INFO(LOG_APP, "JSVM API heap totalHeapSize: %{public}zu", result.totalHeapSize); - OH_LOG_INFO(LOG_APP, "JSVM API heap totalHeapSizeExecutable: %{public}zu", result.totalHeapSizeExecutable); - OH_LOG_INFO(LOG_APP, "JSVM API heap totalPhysicalSize: %{public}zu", result.totalPhysicalSize); - OH_LOG_INFO(LOG_APP, "JSVM API heap totalAvailableSize: %{public}zu", result.totalAvailableSize); - OH_LOG_INFO(LOG_APP, "JSVM API heap usedHeapSize: %{public}zu", result.usedHeapSize); - OH_LOG_INFO(LOG_APP, "JSVM API heap heapSizeLimit: %{public}zu", result.heapSizeLimit); - OH_LOG_INFO(LOG_APP, "JSVM API heap mallocedMemory: %{public}zu", result.mallocedMemory); - OH_LOG_INFO(LOG_APP, "JSVM API heap externalMemory: %{public}zu", result.externalMemory); - OH_LOG_INFO(LOG_APP, "JSVM API heap peakMallocedMemory: %{public}zu", result.peakMallocedMemory); - OH_LOG_INFO(LOG_APP, "JSVM API heap numberOfNativeContexts: %{public}zu", result.numberOfNativeContexts); - OH_LOG_INFO(LOG_APP, "JSVM API heap numberOfDetachedContexts: %{public}zu", result.numberOfDetachedContexts); - OH_LOG_INFO(LOG_APP, "JSVM API heap totalGlobalHandlesSize: %{public}zu", result.totalGlobalHandlesSize); - OH_LOG_INFO(LOG_APP, "JSVM API heap usedGlobalHandlesSize: %{public}zu", result.usedGlobalHandlesSize); -} - -static JSVM_Value GetHeapStatistics(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取当前虚拟机对象 - JSVM_VM testVm; - OH_JSVM_GetVM(env, &testVm); - // 获取虚拟机的堆统计信息 - JSVM_HeapStatistics result; - OH_JSVM_GetHeapStatistics(testVm, &result); - // 打印虚拟机堆统计信息 - PrintHeapStatistics(result); - // 返回虚拟机堆统计信息中‘本机上下文数量’ - JSVM_Value nativeContextsCnt = nullptr; - OH_JSVM_CreateInt64(env, result.numberOfNativeContexts, &nativeContextsCnt); - return nativeContextsCnt; -} -// GetHeapStatistics注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetHeapStatistics}, -}; -static JSVM_CallbackStruct *method = param; -// GetHeapStatistics方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getHeapStatistics", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -const char *SRC_CALL_NATIVE = R"JS(getHeapStatistics())JS"; -// [End oh_jsvm_get_heap_statistics] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getheapstatistics", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/oh-package.json5 deleted file mode 100755 index a30397b587..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/cpp/types/libgetheapstatistics/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetheapstatistics.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/pages/Index.ets deleted file mode 100755 index e5863e3dc6..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetheapstatistics.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/module.json5 deleted file mode 100755 index c0d3f31894..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getheapstatistics", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetheapstatisticsAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetheapstatisticsAbility", - "srcEntry": "./ets/getheapstatisticsability/GetheapstatisticsAbility.ets", - "description": "$string:GetheapstatisticsAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetheapstatisticsAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/string.json deleted file mode 100755 index b662a8916e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetheapstatisticsAbility_desc", - "value": "description" - }, - { - "name": "GetheapstatisticsAbility_label", - "value": "UsageInstructionsTwo" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index d33f4e0aed..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetHeapStatistics', 0, async (done: Function) => { - console.log('uitest: TestGetHeapStatistics begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetheapstatisticsAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetheapstatisticsAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetHeapStatistics end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/module.json5 deleted file mode 100755 index af2c813f33..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getheapstatistics/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getheapstatistics_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/oh-package.json5 deleted file mode 100755 index 36d47adea9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getversion", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetversion.so": "file:./src/main/cpp/types/libgetversion" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 2773ea2fc1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getversion SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getversion PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/hello.cpp deleted file mode 100755 index ea3b28350e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/hello.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "ark_runtime/jsvm.h" - -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) - -// [Start oh_jsvm_get_version_and_vm_info] -// OH_JSVM_GetVersion的样例方法 -static JSVM_Value GetVersion(JSVM_Env env, JSVM_CallbackInfo info) -{ - uint32_t jsVersion = 0; - // 调用接口,获取当前JSVM运行时支持的最高JSVM API版本 - JSVM_CALL(OH_JSVM_GetVersion(env, &jsVersion)); - int value = static_cast(jsVersion); - OH_LOG_INFO(LOG_APP, "JSVM GetVersion success:%{public}d", value); - return nullptr; -} - -// OH_JSVM_GetVMInfo的样例方法 -// 打印JSVM(JavaScript虚拟机)的各项信息 -void PrintVmInfo(JSVM_VMInfo vmInfo) -{ - OH_LOG_INFO(LOG_APP, "JSVM API apiVersion: %{public}d", vmInfo.apiVersion); - OH_LOG_INFO(LOG_APP, "JSVM API engine: %{public}s", vmInfo.engine); - OH_LOG_INFO(LOG_APP, "JSVM API version: %{public}s", vmInfo.version); - OH_LOG_INFO(LOG_APP, "JSVM API cachedDataVersionTag: 0x%{public}x", vmInfo.cachedDataVersionTag); -} - -static JSVM_Value GetVMInfo(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 调用接口,获取虚拟机的信息 - JSVM_VMInfo result; - JSVM_CALL(OH_JSVM_GetVMInfo(&result)); - // 输出VM虚拟机信息 - PrintVmInfo(result); - return nullptr; -} - -// IsStrictEquals注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetVersion}, - {.data = nullptr, .callback = GetVMInfo}, -}; -static JSVM_CallbackStruct *method = param; -// IsStrictEquals方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getVersion", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, - {"getVMInfo", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -// 样例测试js -static const char *STR_TASK = R"JS(getVersion();getVMInfo();)JS"; -// [End oh_jsvm_get_version_and_vm_info] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, STR_TASK, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getversion", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/oh-package.json5 deleted file mode 100755 index e04a84f1e4..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/cpp/types/libgetversion/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetversion.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/pages/Index.ets deleted file mode 100755 index 967a378e9d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetversion.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/module.json5 deleted file mode 100755 index 5b80bc7a0f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "getversion", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "GetversionAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "GetversionAbility", - "srcEntry": "./ets/getversionability/GetversionAbility.ets", - "description": "$string:GetversionAbility_desc", - "icon": "$media:layered_image", - "label": "$string:GetversionAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/string.json deleted file mode 100755 index a774b64060..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "GetversionAbility_desc", - "value": "description" - }, - { - "name": "GetversionAbility_label", - "value": "UsageInstructionsTwo" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 3e561fa06d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetVersion', 0, async (done: Function) => { - console.log('uitest: TestGetVersion begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'GetversionAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('GetversionAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetVersion end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/module.json5 deleted file mode 100755 index 29bb82d576..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getversion/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getversion_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/oh-package.json5 deleted file mode 100755 index b30f517d46..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "getvm", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libgetvm.so": "file:./src/main/cpp/types/libentry" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/CMakeLists.txt deleted file mode 100755 index f43b6a3639..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(getvm SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(getvm PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp deleted file mode 100755 index d2502f321f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_get_vm] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_get_vm] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_get_vm] - -// OH_JSVM_GetVM的样例方法 -static JSVM_Value GetVM(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 获取当前虚拟机对象,后续可以进行与虚拟机相关的操作或分析 - JSVM_VM testVm; - JSVM_Status status = OH_JSVM_GetVM(env, &testVm); - JSVM_Value result = nullptr; - if (status != JSVM_OK || testVm == nullptr) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_GetVM: failed"); - OH_JSVM_GetBoolean(env, true, &result); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_GetVM: success"); - OH_JSVM_GetBoolean(env, false, &result); - } - return result; -} -// GetVM注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = GetVM}, -}; -static JSVM_CallbackStruct *method = param; -// GetVM方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"getVM", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -const char *SRC_CALL_NATIVE = R"JS(getVM())JS"; -// [End oh_jsvm_get_vm] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "getvm", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index ff274def60..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libgetvm.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/pages/Index.ets deleted file mode 100755 index 837d7a4b47..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libgetvm.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/module.json5 deleted file mode 100755 index ff651598ba..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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": "getvm", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/string.json deleted file mode 100755 index 895c9a6def..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "UsageInstructionsTwo" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 643e8a0023..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testGetVM', 0, async (done: Function) => { - console.log('uitest: TestGetVM begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestGetVM end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/module.json5 deleted file mode 100755 index 26a069d024..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "getvm_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigorfile.ts deleted file mode 100755 index 2db60fa918..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/oh-package.json5 deleted file mode 100755 index f5ea14034e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "memorypressurenotification", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libmemorypressurenotification.so": "file:./src/main/cpp/types/libmemorypressurenotification" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/CMakeLists.txt deleted file mode 100755 index e669cc2e2b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(memorypressurenotification SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(memorypressurenotification PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/hello.cpp deleted file mode 100755 index 02dc84601c..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/hello.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_memory_pressure_notification] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_memory_pressure_notification] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_memory_pressure_notification] - -// OH_JSVM_MemoryPressureNotification的样例方法 -static JSVM_Value MemoryPressureNotification(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 设置当前JSVM的内存压力级别 - JSVM_Status status = OH_JSVM_MemoryPressureNotification(env, JSVM_MEMORY_PRESSURE_LEVEL_CRITICAL); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_MemoryPressureNotification: failed"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_MemoryPressureNotification: success"); - OH_LOG_INFO(LOG_APP, "JSVM Current JSVM memory pressure level: %{public}d", - JSVM_MEMORY_PRESSURE_LEVEL_CRITICAL); - } - return nullptr; -} -// MemoryPressureNotification注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = MemoryPressureNotification}, -}; -static JSVM_CallbackStruct *method = param; -// MemoryPressureNotification方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"memoryPressureNotification", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; - -const char *SRC_CALL_NATIVE = R"JS(memoryPressureNotification())JS"; -// [End oh_jsvm_memory_pressure_notification] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "memorypressurenotification", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/oh-package.json5 deleted file mode 100755 index 06314ae494..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/cpp/types/libmemorypressurenotification/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libmemorypressurenotification.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/pages/Index.ets deleted file mode 100755 index 3f8477f1e8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libmemorypressurenotification.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/module.json5 deleted file mode 100755 index 6418d7f372..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "memorypressurenotification", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "MemorypressurenotificationAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "MemorypressurenotificationAbility", - "srcEntry": "./ets/memorypressurenotificationability/MemorypressurenotificationAbility.ets", - "description": "$string:MemorypressurenotificationAbility_desc", - "icon": "$media:layered_image", - "label": "$string:MemorypressurenotificationAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/string.json deleted file mode 100755 index c1156c47a8..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "MemorypressurenotificationAbility_desc", - "value": "description" - }, - { - "name": "MemorypressurenotificationAbility_label", - "value": "UsageInstructionsTwo" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 93a785013b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击Hello World执行 - */ - it('testMemoryPressureNotification', 0, async (done: Function) => { - console.log('uitest: TestMemoryPressureNotification begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'MemorypressurenotificationAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('MemorypressurenotificationAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('Hello World')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestMemoryPressureNotification end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/module.json5 deleted file mode 100755 index 265d555911..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/memorypressurenotification/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "memorypressurenotification_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/ohosTest.md b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/ohosTest.md deleted file mode 100755 index afd31196ea..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/ohosTest.md +++ /dev/null @@ -1,13 +0,0 @@ -# UsageInstructionsTwo 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------------------------------------------------- | ------------ | --------------- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 使用JSVM-API接口获取JSVM API的版本号 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 设置JavaScript对象保持活动状态的外部分配内存的数量 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 通知虚拟机系统内存不足并有选择地触发垃圾回收 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 判断给定的两个JS value是否严格相等 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 检索给定环境的虚拟机实例 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | -| 返回一组虚拟机堆的统计数据 | 位于首页 | 点击Hello World | 1秒后页面显示“success” | 是 | Pass | diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/.gitignore b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/.gitignore deleted file mode 100755 index 32abf8fd5e..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/build-profile.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/build-profile.json5 deleted file mode 100755 index 2c0104dcb5..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/build-profile.json5 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/hvigorfile.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/hvigorfile.ts deleted file mode 100755 index 46872af922..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/hvigorfile.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/obfuscation-rules.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/obfuscation-rules.txt deleted file mode 100755 index 5ff2b5d0b0..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/oh-package.json5 deleted file mode 100755 index f9981a8fa3..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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": "strictequals", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libstrictequals.so": "file:./src/main/cpp/types/libstrictequals" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/CMakeLists.txt deleted file mode 100755 index a757f93fdd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(UsageInstructionsTwo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# 日志打印配置 -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(strictequals SHARED hello.cpp) -# 构建此可执行文件需要链接的库 -target_link_libraries(strictequals PUBLIC libace_napi.z.so libjsvm.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/hello.cpp deleted file mode 100755 index 7b81aaded9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/hello.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start oh_jsvm_strict_equals] -#include "napi/native_api.h" -#include "ark_runtime/jsvm.h" -#include "hilog/log.h" -// [StartExclude oh_jsvm_strict_equals] -#define LOG_DOMAIN 0x3200 -#define LOG_TAG "APP" - -static int g_aa = 0; - -#define CHECK_RET(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return -1; \ - } \ - } while (0) - -#define CHECK(theCall) \ - do { \ - JSVM_Status cond = theCall; \ - if ((cond) != JSVM_OK) { \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d", __FILE__, __LINE__, \ - cond); \ - return -1; \ - } \ - } while (0) - -// 用于调用theCall并检查其返回值是否为JSVM_OK。 -// 如果不是,则调用OH_JSVM_GetLastErrorInfo处理错误并返回retVal。 -#define JSVM_CALL_BASE(env, theCall, retVal) \ - do { \ - JSVM_Status cond = theCall; \ - if (cond != JSVM_OK) { \ - const JSVM_ExtendedErrorInfo *info; \ - OH_JSVM_GetLastErrorInfo(env, &info); \ - OH_LOG_ERROR(LOG_APP, "jsvm fail file: %{public}s line: %{public}d ret = %{public}d message = %{public}s", \ - __FILE__, __LINE__, cond, info != nullptr ? info->errorMessage : ""); \ - return retVal; \ - } \ - } while (0) - -// JSVM_CALL_BASE的简化版本,返回nullptr -#define JSVM_CALL(theCall) JSVM_CALL_BASE(env, theCall, nullptr) -// [EndExclude oh_jsvm_strict_equals] - -// OH_JSVM_StrictEquals的样例方法 -static JSVM_Value IsStrictEquals(JSVM_Env env, JSVM_CallbackInfo info) -{ - // 接受两个入参 - size_t argc = 2; - JSVM_Value args[2] = {nullptr}; - OH_JSVM_GetCbInfo(env, info, &argc, args, nullptr, nullptr); - // 调用OH_JSVM_StrictEquals接口判断给定的两个JavaScript value是否严格相等 - bool result = false; - JSVM_Status status = OH_JSVM_StrictEquals(env, args[0], args[1], &result); - if (status != JSVM_OK) { - OH_LOG_ERROR(LOG_APP, "JSVM OH_JSVM_StrictEquals: failed"); - } else { - OH_LOG_INFO(LOG_APP, "JSVM OH_JSVM_StrictEquals: success: %{public}d", result); - } - JSVM_Value isStrictEqual; - OH_JSVM_GetBoolean(env, result, &isStrictEqual); - return isStrictEqual; -} -// IsStrictEquals注册回调 -static JSVM_CallbackStruct param[] = { - {.data = nullptr, .callback = IsStrictEquals}, -}; -static JSVM_CallbackStruct *method = param; -// IsStrictEquals方法别名,供JS调用 -static JSVM_PropertyDescriptor descriptor[] = { - {"isStrictEquals", nullptr, method++, nullptr, nullptr, nullptr, JSVM_DEFAULT}, -}; -// 样例测试js -const char* SRC_CALL_NATIVE = R"JS(data = '123';value = '123';isStrictEquals(data,value);)JS"; -// [End oh_jsvm_strict_equals] - -static int32_t TestJSVM() -{ - JSVM_InitOptions initOptions = {0}; - JSVM_VM vm; - JSVM_Env env = nullptr; - JSVM_VMScope vmScope; - JSVM_EnvScope envScope; - JSVM_HandleScope handleScope; - JSVM_Value result; - // 初始化JavaScript引擎实例 - if (g_aa == 0) { - g_aa++; - CHECK(OH_JSVM_Init(&initOptions)); - } - // 创建JSVM环境 - CHECK(OH_JSVM_CreateVM(nullptr, &vm)); - CHECK(OH_JSVM_CreateEnv(vm, sizeof(descriptor) / sizeof(descriptor[0]), descriptor, &env)); - CHECK(OH_JSVM_OpenVMScope(vm, &vmScope)); - CHECK_RET(OH_JSVM_OpenEnvScope(env, &envScope)); - CHECK_RET(OH_JSVM_OpenHandleScope(env, &handleScope)); - - // 通过script调用测试函数 - JSVM_Script script; - JSVM_Value jsSrc; - CHECK_RET(OH_JSVM_CreateStringUtf8(env, SRC_CALL_NATIVE, JSVM_AUTO_LENGTH, &jsSrc)); - CHECK_RET(OH_JSVM_CompileScript(env, jsSrc, nullptr, 0, true, nullptr, &script)); - CHECK_RET(OH_JSVM_RunScript(env, script, &result)); - - // 销毁JSVM环境 - CHECK_RET(OH_JSVM_CloseHandleScope(env, handleScope)); - CHECK_RET(OH_JSVM_CloseEnvScope(env, envScope)); - CHECK(OH_JSVM_CloseVMScope(vm, vmScope)); - CHECK(OH_JSVM_DestroyEnv(env)); - CHECK(OH_JSVM_DestroyVM(vm)); - return 0; -} - -static napi_value RunTest(napi_env env, napi_callback_info info) -{ - TestJSVM(); - return nullptr; -} - -// 模块注册信息,供arkts侧调用 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"runTest", nullptr, RunTest, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "strictequals", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/Index.d.ts deleted file mode 100755 index 8fc2c9e21f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 runTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/oh-package.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/oh-package.json5 deleted file mode 100755 index 315b75619a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/cpp/types/libstrictequals/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libstrictequals.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/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/pages/Index.ets deleted file mode 100755 index 8ef108a519..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 napitest from 'libstrictequals.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - try { - napitest.runTest(); - this.message = 'success'; - } catch (error) { - console.error('An error occurred: ', error); - this.message = 'fail'; - } - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/module.json5 deleted file mode 100755 index 2c7147c8cd..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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": "strictequals", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "StrictequalsAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "StrictequalsAbility", - "srcEntry": "./ets/strictequalsability/StrictequalsAbility.ets", - "description": "$string:StrictequalsAbility_desc", - "icon": "$media:layered_image", - "label": "$string:StrictequalsAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/string.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/string.json deleted file mode 100755 index 7f004aac0f..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "StrictequalsAbility_desc", - "value": "description" - }, - { - "name": "StrictequalsAbility_label", - "value": "UsageInstructionsTwo" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/layered_image.json deleted file mode 100755 index 16cf3219a2..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 14bbd62cb9..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100755 index 485d59283b..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - /** - * 打开应用,点击OH_JSVM_StrictEquals执行 - */ - it('testStrictEquals', 0, async (done: Function) => { - console.log('uitest: TestStrictEquals begin'); - - const want: Want = { - bundleName: bundleName, - abilityName: 'StrictequalsAbility' - } - const driver = Driver.create(); - await delegator.startAbility(want); - await driver.delayMs(1000); - - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.log('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('StrictequalsAbility'); - - await driver.delayMs(1000); - const text = await driver.findComponent(ON.text('OH_JSVM_StrictEquals')); - await text.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('success')); - console.log('uitest: TestStrictEquals end'); - done(); - }) - }) -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/List.test.ets deleted file mode 100755 index a10a79ed1d..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/module.json5 deleted file mode 100755 index 096e46e751..0000000000 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/strictequals/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "strictequals_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/app.json5 deleted file mode 100755 index ede19046e1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiasynchronoustask", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/element/string.json deleted file mode 100755 index 2d04976352..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIAsynchronousTask" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/README.md deleted file mode 100755 index ad578f30fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/README.md +++ /dev/null @@ -1,74 +0,0 @@ -# ArkTS使用Node-API接口进行异步任务开发 - -### 介绍 - -本工程展示了使用Node-API接口进行异步任务开发中的Promise方式和callback方式,详细描述可查如下链接。 - -- [使用Node-API接口进行异步任务开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-asynchronous-task.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现如上图效果,和两个按钮,依次点击按钮后可以调用Promise方式和callback方式的方法,并将结果呈现到text文本中,并在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIAsynchronousTask.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── libentry - │ │ └── libentry1 - │ │ ├── callback.cpp // callback方式实现 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp // Promise方式实现 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 异步任务 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIAsynchronousTask.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeAPIAsynchronousTask > .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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/oh-package.json5 deleted file mode 100755 index 54a3b5a444..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/oh-package.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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", - "libentry1.so": "file:./src/main/cpp/types/libentry1" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index ec971d6e4f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIAsynchronousTask) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so) - -add_library(entry1 SHARED callback.cpp) -target_link_libraries(entry1 PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 9ec67bd35e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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" - -// [Start napi_create_async_work] -struct CallbackData { - napi_async_work asyncWork = nullptr; - napi_deferred deferred = nullptr; - napi_ref callback = nullptr; - double args = 0; - double result = 0; -}; - -// [StartExclude napi_create_async_work] -// [Start napi_first_call_back_work] -static void ExecuteCB(napi_env env, void *data) -{ - CallbackData *callbackData = reinterpret_cast(data); - callbackData->result = callbackData->args; -} -// [End napi_first_call_back_work] - -// [Start napi_second_call_back_main] -static void CompleteCB(napi_env env, napi_status status, void *data) -{ - CallbackData *callbackData = reinterpret_cast(data); - napi_value result = nullptr; - napi_create_double(env, callbackData->result, &result); - if (callbackData->result > 0) { - napi_resolve_deferred(env, callbackData->deferred, result); - } else { - napi_reject_deferred(env, callbackData->deferred, result); - } - - napi_delete_async_work(env, callbackData->asyncWork); - delete callbackData; -} -// [End napi_second_call_back_main] -// [EndExclude napi_create_async_work] - -static napi_value AsyncWork(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1]; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - napi_value promise = nullptr; - napi_deferred deferred = nullptr; - napi_create_promise(env, &deferred, &promise); - - auto callbackData = new CallbackData(); - callbackData->deferred = deferred; - napi_get_value_double(env, args[0], &callbackData->args); - - napi_value resourceName = nullptr; - napi_create_string_utf8(env, "AsyncCallback", NAPI_AUTO_LENGTH, &resourceName); - // 创建异步任务 - napi_create_async_work(env, nullptr, resourceName, ExecuteCB, CompleteCB, callbackData, &callbackData->asyncWork); - // 将异步任务加入队列 - napi_queue_async_work(env, callbackData->asyncWork); - - return promise; -} -// [End napi_create_async_work] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"asyncWork", nullptr, AsyncWork, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 35ceb64941..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 asyncWork: (data: number) => Promise; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/Index.d.ts deleted file mode 100755 index 63a99bdb80..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 asyncWork: (arg1: number, arg2: number, callback: (result: number) => void) => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/oh-package.json5 deleted file mode 100755 index 36e064ade2..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/cpp/types/libentry1/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libentry1.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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index e350d5eb1f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; -import nativeModule from 'libentry1.so'; - -let num1: number = 123; -let num2: number = 456; - -@Entry -@Component -struct Index { - @State message: string = 'AsyncWork'; - - build() { - Column({space: 5}) { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - Button($r('app.string.AsyncWorkPromise')) - .margin(3) - .onClick(() => { - testNapi.asyncWork(1024).then((result) => { - hilog.info(0x0000, 'XXX', 'result is %{public}d', result); - this.message = 'result is ' + result.toString(); - }); - }) - Button($r('app.string.AsyncWorkCallback')) - .margin(3) - .onClick(() => { - nativeModule.asyncWork(num1, num2, (result) => { - hilog.info(0x0000, 'XXX', 'result is %{public}d', result); - this.message = 'result is ' + result.toString(); - }); - }) - } - .width('100%') - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/ohosTest.md deleted file mode 100755 index 1f25dfb700..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeAPIAsynchronousTask/ohosTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# 使用Node-API接口进行异步任务开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| --------------------------------------- | ------------ | -------------------------------------- | ---------------------------------------------------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 asyncWork | 位于主页 | 点击Call AsyncWorkCallback的Button组件 | 成功调用函数输出日志,页面顶端文本变为result is 579 | Pass | -| ArkTS端成功调用native侧接口 asyncWork | 位于主页 | 点击Call AsyncWorkPromise的Button组件 | 成功调用函数输出日志,页面顶端文本变为result is 1024 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/app.json5 deleted file mode 100755 index 649ca03844..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiloadmodule", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/element/string.json deleted file mode 100755 index 675cb765b6..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeApiLoadModule" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/README.md deleted file mode 100755 index 55e0727daf..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# ArkTS使用Node-API接口在主线程中进行模块加载 - -### 介绍 - -本工程展示了使用Node-API接口在主线程中进行系统模块加载与ArkTS单文件加载。详细描述可查如下链接中。 - -- [使用Node-API接口在主线程中进行模块加载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-load-module.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现如上图效果和两个按钮,依次点击按钮后可以加载系统模块和单文件模块,并将成功结果呈现到text文本中。 -3. 运行测试用例NodeApiLoadModule.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── libentry - │ │ └── libentry1 - │ │ ├── file.cpp // ArkTS单文件加载 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp // 系统模块加载 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 加载模块 - │ │ ├── Test.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeApiLoadModule.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiLoadModule > .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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/build-profile.json5 deleted file mode 100755 index a00dddb50c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/build-profile.json5 +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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", - // [Start napi_load_module_napi_build] - "buildOption": { - "arkOptions" : { - "runtimeOnly" : { - "sources": [ - "./src/main/ets/Test.ets" - ] - } - }, - // [End napi_load_module_napi_build] - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - "abiFilters": [ - "arm64-v8a", - "x86_64", - "armeabi-v7a" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/oh-package.json5 deleted file mode 100755 index 54a3b5a444..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/oh-package.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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", - "libentry1.so": "file:./src/main/cpp/types/libentry1" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 5b0b4adc21..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeApiLoadModule) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so) - -add_library(entry1 SHARED file.cpp) -target_link_libraries(entry1 PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/file.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/file.cpp deleted file mode 100755 index 5aef2ae53f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/file.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 -// [Start napi_load_module_napi_file] -static napi_value loadModule(napi_env env, napi_callback_info info) -{ - napi_value result; - // 1. 使用napi_load_module加载Test文件中的模块 - napi_status status = napi_load_module(env, "ets/Test", &result); - - napi_value testFn; - // 2. 使用napi_get_named_property获取test函数 - napi_get_named_property(env, result, "test", &testFn); - // 3. 使用napi_call_function调用函数test - napi_call_function(env, result, testFn, 0, nullptr, nullptr); - - napi_value value; - napi_value key; - std::string keyStr = "value"; - napi_create_string_utf8(env, keyStr.c_str(), keyStr.size(), &key); - // 4. 使用napi_get_property获取变量value - napi_get_property(env, result, key, &value); - return result; -} -// [End napi_load_module_napi_file] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry1", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index c6ca2381ca..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 -// [Start napi_load_module_napi_init] -static napi_value loadModule(napi_env env, napi_callback_info info) -{ - // 1. 使用napi_load_module加载模块@ohos.hilog - napi_value result; - napi_status status = napi_load_module(env, "@ohos.hilog", &result); - - // 2. 使用napi_get_named_property获取info函数 - napi_value infoFn; - napi_get_named_property(env, result, "info", &infoFn); - - napi_value tag; - std::string formatStr = "test"; - napi_create_string_utf8(env, formatStr.c_str(), formatStr.size(), &tag); - - napi_value outputString; - std::string str = "Hello OpenHarmony"; - napi_create_string_utf8(env, str.c_str(), str.size(), &outputString); - - napi_value flag; - napi_create_int32(env, 0, &flag); - - napi_value args[3] = {flag, tag, outputString}; - // 3. 使用napi_call_function调用info函数 - napi_call_function(env, result, infoFn, 3, args, nullptr); - return result; -} -// [End napi_load_module_napi_init] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 3ea0fb8778..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/Index.d.ts deleted file mode 100755 index 3ea0fb8778..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/oh-package.json5 deleted file mode 100755 index 36e064ade2..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/cpp/types/libentry1/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libentry1.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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/Test.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/Test.ets deleted file mode 100755 index e9b1d7e82c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/Test.ets +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start napi_load_module_napi_test] -let value = 123; -function test() { - console.log('Hello OpenHarmony'); -} -export {value, test}; -// [End napi_load_module_napi_test] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index d4341fc545..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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'; -import test from 'libentry1.so'; - -@Entry -@Component -struct Index { - @State message: string = 'LoudModule'; - - build() { - Column() { - Text(this.message) - .fontSize(30) - Button($r('app.string.loadModuleSystem')) - .margin(3) - .width('70%') - .onClick(() => { - testNapi.loadModule(); - this.message = 'loadModuleSystem success'; - }) - Button($r('app.string.loadModuleFile')) - .margin(3) - .width('70%') - .onClick(() => { - test.loadModule(); - this.message = 'loadModuleFile success'; - }) - } - .width('100%') - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/ohosTest.md deleted file mode 100755 index 0ad3be6c53..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModule/ohosTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# 使用Node-API接口在主线程中进行模块加载测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ---------------------------------------- | ------------ | ----------------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleSystem的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleSystem success | Pass | -| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleFile的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleFile success | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/app.json5 deleted file mode 100755 index 4097e70731..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiloadmodulewithinfo", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/element/string.json deleted file mode 100755 index fd19d4fd5b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeApiLoadModuleWithInfo" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/README.md deleted file mode 100755 index 89c98d8f9c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/README.md +++ /dev/null @@ -1,86 +0,0 @@ -# ArkTS使用Node-API接口进行模块加载 - -### 介绍 - - Node-API中的napi_load_module_with_info接口的功能是进行模块的加载,当模块加载出来之后,可以使用函数napi_get_property获取模块导出的变量,也可以使用napi_get_named_property获取模块导出的函数,该函数可以在新创建的ArkTS基础运行时环境中使用。 - - 本工程展示了使用napi_load_module_with_info接口进行对不同内容的加载,代码详细描述可查如下链接。 - -- [使用Node-API接口进行模块加载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-load-module-with-info.md) - -### 效果预览 - -| 首页图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现LoadModule效果和六个按钮,点击按钮后可以调用napi_load_module_with_info接口进行对不同内容进行加载,并修改Text文本内容。 -3. 运行测试用例NodeApiLoadModuleWithInfo.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── libentry - │ │ └── libentryone - │ │ └── libentrytwo - │ │ └── libentrythree - │ │ └── libentryfour - │ │ ├── api.cpp // 加载API模块 - │ │ ├── har_name.cpp // 加载HAR模块名 - │ │ ├── file.cpp // 加载模块内文件路径 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp // 加载Native库 - │ │ ├── remote_har.cpp // 加载远程HAR模块名 - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 加载模块 - │ │ ├── Test.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeApiLoadModuleWithInfo.test.ets // 自动化测试代码 - │ │ └── List.test.ets - har1/ // HAR加载HAR模块名 - har2/ // HAR加载HAR模块名 - library/ // 加载HAR模块名 -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiLoadModuleWithInfo > .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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/build-profile.json5 deleted file mode 100755 index b0505bb0e6..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/build-profile.json5 +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "library", - "srcPath": "./library", - }, - { - "name": "har1", - "srcPath": "./har1", - }, - { - "name": "har2", - "srcPath": "./har2", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/build-profile.json5 deleted file mode 100755 index 03ac87827c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/build-profile.json5 +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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", - // [Start napi_load_module_with_info_entry_build] - // [Start napi_load_module_with_info_entry_build2] - // [Start napi_load_module_with_info_entry_build3] - // [Start napi_load_module_with_info_entry_build4] - "buildOption": { - "arkOptions" : { - "runtimeOnly" : { - // [StartExclute napi_load_module_with_info_entry_build2] - // [StartExclute napi_load_module_with_info_entry_build3] - // [StartExclute napi_load_module_with_info_entry_build4] - "sources": [ - "./src/main/ets/Test.ets", - ], - // [EndExclute napi_load_module_with_info_entry_build2] - // [EndExclute napi_load_module_with_info_entry_build3] - // [EndExclute napi_load_module_with_info_entry_build4] - // [End napi_load_module_with_info_entry_build] - "packages": [ - // [StartExclute napi_load_module_with_info_entry_build3] - // [StartExclute napi_load_module_with_info_entry_build4] - "library", - // [End napi_load_module_with_info_entry_build2] - // [EndExclute napi_load_module_with_info_entry_build4] - "libentry.so", - // [End napi_load_module_with_info_entry_build4] - "libentryone.so", - "libentrytwo.so", - "libentrythree.so", - "libentryfour.so", - "har1", - // [EndExclute napi_load_module_with_info_entry_build3] - "@ohos/hypium" - // [End napi_load_module_with_info_entry_build3] - ] - } - }, - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - "abiFilters": [ - "arm64-v8a", - "x86_64", - "armeabi-v7a" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/oh-package.json5 deleted file mode 100755 index 20e134cad1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/oh-package.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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": "", - // [Start napi_load_module_with_info_entry_oh] - // [Start napi_load_module_with_info_entry_oh2] - // [Start napi_load_module_with_info_entry_oh3] - "dependencies": { - // [StartExclute napi_load_module_with_info_entry_oh] - // [StartExclute napi_load_module_with_info_entry_oh2] - "libentry.so": "file:./src/main/cpp/types/libentry", - // [Start napi_load_module_with_info_entry_oh3] - "libentryone.so": "file:./src/main/cpp/types/libentryone", - "libentrytwo.so": "file:./src/main/cpp/types/libentrytwo", - "libentrythree.so": "file:./src/main/cpp/types/libentrythree", - "libentryfour.so": "file:./src/main/cpp/types/libentryfour", - // [EndExclute napi_load_module_with_info_entry_oh] - "library": "file:../library", - // [End napi_load_module_with_info_entry_oh] - // [EndExclute napi_load_module_with_info_entry_oh2] - "@ohos/hypium": "1.0.16", - // [End napi_load_module_with_info_entry_oh2] - "har1": "file:../har1" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index f510980786..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeApiLoadModuleWithInfo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so) - -add_library(entryone SHARED har_name.cpp) -target_link_libraries(entryone PUBLIC libace_napi.z.so) - -add_library(entrytwo SHARED remote_har.cpp) -target_link_libraries(entrytwo PUBLIC libace_napi.z.so) - -add_library(entrythree SHARED api.cpp) -target_link_libraries(entrythree PUBLIC libace_napi.z.so) - -add_library(entryfour SHARED file.cpp) -target_link_libraries(entryfour PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/file.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/file.cpp deleted file mode 100755 index df5669b217..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/file.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 -#include "napi/native_api.h" -// [Start napi_load_module_with_info_entry_file] -static napi_value loadModule(napi_env env, napi_callback_info info) -{ - napi_value result; - // 1. 使用napi_load_module_with_info加载Test文件中的模块 - napi_status status = - napi_load_module_with_info(env, "entry/src/main/ets/Test", "com.example.application/entry", &result); - - napi_value testFn; - // 2. 使用napi_get_named_property获取test函数 - napi_get_named_property(env, result, "test", &testFn); - // 3. 使用napi_call_function调用函数test - napi_call_function(env, result, testFn, 0, nullptr, nullptr); - - napi_value value; - napi_value key; - std::string keyStr = "value"; - napi_create_string_utf8(env, keyStr.c_str(), keyStr.size(), &key); - // 4. 使用napi_get_property获取变量value - napi_get_property(env, result, key, &value); - return result; -} -// [End napi_load_module_with_info_entry_file] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entryfour", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 4baacf9868..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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" -// [Start napi_load_module_with_info_entry_napi_init] -static constexpr int INT_ARG_2 = 2; // 入参索引 -static constexpr int INT_ARG_3 = 3; // 入参索引 - -static napi_value loadModule(napi_env env, napi_callback_info info) -{ - napi_value result; - // 1. 使用napi_load_module_with_info加载libentry.so - napi_status status = napi_load_module_with_info(env, "libentry.so", "com.example.application/entry", &result); - - napi_value addFn; - // 2. 使用napi_get_named_property获取add函数 - napi_get_named_property(env, result, "add", &addFn); - - napi_value a; - napi_value b; - napi_create_int32(env, INT_ARG_2, &a); - napi_create_int32(env, INT_ARG_3, &b); - napi_value args[2] = {a, b}; - // 3. 使用napi_call_function调用函数add - napi_value returnValue; - napi_call_function(env, result, addFn, INT_ARG_2, args, &returnValue); - return result; -} -// [End napi_load_module_with_info_entry_napi_init] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 3ea0fb8778..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/Index.d.ts deleted file mode 100755 index 3ea0fb8778..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/oh-package.json5 deleted file mode 100755 index 1d11de68ff..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryfour/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libentryfour.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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/Index.d.ts deleted file mode 100755 index 3ea0fb8778..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/oh-package.json5 deleted file mode 100755 index 79fbadf636..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentryone/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libentryone.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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/Index.d.ts deleted file mode 100755 index 3ea0fb8778..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/oh-package.json5 deleted file mode 100755 index 1a58275421..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrythree/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libentrythree.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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/Index.d.ts deleted file mode 100755 index 3ea0fb8778..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/Index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/oh-package.json5 deleted file mode 100755 index 3de70b84bb..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/cpp/types/libentrytwo/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libentrytwo.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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/Test.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/Test.ets deleted file mode 100755 index cc4cc49b66..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/Test.ets +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start napi_load_module_with_info_entry_test] -let value = 123; - -function test() { - console.log('Hello OpenHarmony'); -} - -export { value, test }; -// [End napi_load_module_with_info_entry_test] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index a7f3c13067..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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'; -import napiHar from 'libentryone.so'; -import napiRemoteHar from 'libentrytwo.so'; -import napiAPI from 'libentrythree.so'; -import napiFile from 'libentryfour.so' -import { tests } from 'har1'; - -@Entry -@Component -struct Index { - @State message: string = 'LoadModule'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bolder) - Button($r('app.string.loadModuleFile')) - .width('70%') - .onClick(() => { - napiFile.loadModule(); - this.message = 'loadModuleFile success'; - }) - Button($r('app.string.loadModuleHarName')) - .width('70%') - .onClick(() => { - napiHar.loadModule(); - this.message = 'loadModuleHarName success'; - }) - Button($r('app.string.loadModuleRemoteHar')) - .width('70%') - .onClick(() => { - napiRemoteHar.loadModule(); - this.message = 'loadModuleRemoteHar success'; - }) - Button($r('app.string.loadModuleAPI')) - .width('70%') - .onClick(() => { - napiAPI.loadModule(); - this.message = 'loadModuleAPI success'; - }) - Button($r('app.string.loadModuleNative')) - .width('70%') - .onClick(() => { - testNapi.loadModule(); - this.message = 'loadModuleNative success'; - }) - Button($r('app.string.loadModuleHarToHar')) - .width('70%') - .onClick(() => { - tests(); - this.message = 'loadModuleHarToHar success'; - }) - } - .width('100%') - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/Index.ets deleted file mode 100755 index 4c3322f217..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/Index.ets +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 'libhar1.so'; - -export { MainPage } from './src/main/ets/components/MainPage'; - -function tests() { - testNapi.loadModule(); -} - -export { tests }; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/build-profile.json5 deleted file mode 100755 index cd34a51c33..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/build-profile.json5 +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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", - // [Start napi_load_module_with_info_har1_build] - "buildOption": { - "arkOptions": { - "runtimeOnly": { - "packages": [ - "har2", - // [End napi_load_module_with_info_har1_build] - "libhar1.so" - ] - } - }, - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - "abiFilters": [ - "arm64-v8a", - "x86_64", - "armeabi-v7a" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - }, - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/oh-package.json5 deleted file mode 100755 index 05b7ff9d29..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/oh-package.json5 +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "name": "har1", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - // [Start napi_load_module_with_info_har1_oh] - "dependencies": { - "har2": "file:../har2", - // [End napi_load_module_with_info_har1_oh] - "libhar1.so": "file:./src/main/cpp/types/libhar1" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/CMakeLists.txt deleted file mode 100755 index d6cd095097..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeApiLoadModuleWithInfo) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(har1 SHARED napi_init.cpp) -target_link_libraries(har1 PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/napi_init.cpp deleted file mode 100755 index ee70ca579e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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 - -static napi_value Add(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - napi_valuetype valuetype0; - napi_typeof(env, args[0], &valuetype0); - - napi_valuetype valuetype1; - napi_typeof(env, args[1], &valuetype1); - - double value0; - napi_get_value_double(env, args[0], &value0); - - double value1; - napi_get_value_double(env, args[1], &value1); - - napi_value sum; - napi_create_double(env, value0 + value1, &sum); - - return sum; -} -// [Start napi_load_module_with_info_har1_napi_init] -static napi_value loadModule(napi_env env, napi_callback_info info) -{ - napi_value result; - // 1. 使用napi_load_module_with_info加载har2,注意这里的moduleName为模块所在HAP包的moduleName - napi_status status = napi_load_module_with_info(env, "har2", "com.example.application/entry", &result); - - napi_value testFn; - // 2. 使用napi_get_named_property获取test函数 - napi_get_named_property(env, result, "test", &testFn); - // 3. 使用napi_call_function调用函数test - napi_call_function(env, result, testFn, 0, nullptr, nullptr); - - napi_value value; - napi_value key; - std::string keyStr = "value"; - napi_create_string_utf8(env, keyStr.c_str(), keyStr.size(), &key); - // 4. 使用napi_get_property获取变量value - napi_get_property(env, result, key, &value); - return result; -} -// [End napi_load_module_with_info_har1_napi_init] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"loadModule", nullptr, loadModule, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "har1", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterHar1Module(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/index.d.ts deleted file mode 100755 index 5fc9f8f93b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start napi_load_module_with_info_har1_dts] -export const add: (a: number, b: number) => number; -// [End napi_load_module_with_info_har1_dts] -export const loadModule: () => void; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/oh-package.json5 deleted file mode 100755 index 6b3f73a609..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/cpp/types/libhar1/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "name": "libhar1.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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/ets/components/MainPage.ets deleted file mode 100755 index 1243a59406..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/ets/components/MainPage.ets +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MainPage { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/module.json5 deleted file mode 100755 index bdac60be9a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/main/module.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "har1", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/module.json5 deleted file mode 100755 index 49d7bcb9fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har1/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "har1_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/Index.ets deleted file mode 100755 index 43a3d53c32..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/Index.ets +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { MainPage } from './src/main/ets/components/MainPage' -// [Start napi_load_module_with_info_har2_index] -let value = 123; - -function test() { - console.log('Hello OpenHarmony'); -} - -export { value, test }; -// [End napi_load_module_with_info_har2_index] diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/build-profile.json5 deleted file mode 100755 index 5552c941de..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/build-profile.json5 +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - }, - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/oh-package.json5 deleted file mode 100755 index 39e87d1423..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/oh-package.json5 +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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": "har2", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - "dependencies": {} -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/ets/components/MainPage.ets deleted file mode 100755 index 1243a59406..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/ets/components/MainPage.ets +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MainPage { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/module.json5 deleted file mode 100755 index 26b32e3ff5..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/main/module.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "har2", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/module.json5 deleted file mode 100755 index 68ada365ca..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/har2/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "har2_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/Index.ets deleted file mode 100755 index 64f8aae764..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/Index.ets +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start napi_load_module_with_info_library_index] -export { MainPage } from './src/main/ets/components/MainPage'; - -let value = 123; -function test() { - console.log('Hello OpenHarmony'); -} -export {value, test}; -// [End napi_load_module_with_info_library_index] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/build-profile.json5 deleted file mode 100755 index 5552c941de..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/build-profile.json5 +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - }, - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/oh-package.json5 deleted file mode 100755 index fae4159fcb..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/oh-package.json5 +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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": "library", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "Index.ets", - "author": "", - "license": "Apache-2.0", - "dependencies": {} -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/ets/components/MainPage.ets b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/ets/components/MainPage.ets deleted file mode 100755 index 1243a59406..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/ets/components/MainPage.ets +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MainPage { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/module.json5 deleted file mode 100755 index 3f3b753ed0..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/main/module.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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": "library", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/module.json5 deleted file mode 100755 index 472a25c73d..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/library/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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": "library_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/ohosTest.md deleted file mode 100755 index 66f599baf4..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeAPIClassicUseCases/NodeApiLoadModuleWithInfo/ohosTest.md +++ /dev/null @@ -1,13 +0,0 @@ -# 使用Node-API接口进行模块加载测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ---------------------------------------- | ------------ | -------------------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleFile的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleFile success | Pass | -| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleHarName的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleHarName success | Pass | -| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleRemoteHar的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleRemoteHar success | Pass | -| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleAPI的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleAPI success | Pass | -| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleNative的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleNative success | Pass | -| ArkTS端成功调用native侧接口 loadModule | 位于主页 | 点击按钮为调用Call loadModuleHarToHar的Button组件 | 成功调用函数输出日志,页面顶端文本变为loadModuleHarToHar success | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/AppScope/app.json5 deleted file mode 100755 index b87b01bcc5..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiapplicationscenario", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/element/string.json deleted file mode 100755 index b853cf75b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeApiApplicationScenario" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/README.md deleted file mode 100755 index 68729a5cbb..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/README.md +++ /dev/null @@ -1,87 +0,0 @@ -# ArkTSNode-API使用场景 - -### 介绍 - -开发者通过pthread_create创建新线程后,可以通过napi_create_ark_runtime来创建一个新的ArkTS基础运行时环境,并通过该运行时环境加载ArkTS模块。当使用结束后,开发者需要通过napi_destroy_ark_runtime来销毁所创建的ArkTS基础运行时环境。 - -napi_create_threadsafe_function是Node-API接口之一,用于创建一个线程安全的JavaScript函数。主要用于在多个线程之间共享和调用,而不会出现竞争条件或死锁。例如异步计算、数据共享、多线程编程场景。 - -Node-API中的napi_call_threadsafe_function_with_priority接口的功能是从异步线程向ArkTS线程投递任务,底层队列会根据任务的优先级和入队方式来处理任务。 - -在自己创建的ArkTS运行环境中调用异步的ArkTS接口时,可以通过使用Node-API中的扩展接口napi_run_event_loop和napi_stop_event_loop来运行和停止ArkTS实例中的事件循环,该工程中展示的代码详细描述可查如下链接。 - -- [使用Node-API接口创建ArkTS运行时环境](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-ark-runtime.md) -- [使用Node-API接口进行线程安全开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-thread-safety.md) -- [使用Node-API接口从异步线程向ArkTS线程投递指定优先级和入队方式的的任务](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-call-threadsafe-function-with-priority.md) -- [使用扩展的Node-API接口在异步线程中运行和停止事件循环](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-event-loop.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击button组件可以执行对应文本内容的Node-API接口并将文本NodeAPI改为执行成功结果。 -3. 运行测试用例NodeApiApplicationScenario.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── libentry - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── libentry1 - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ │ ├── thread_safety.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // Node-API使用场景 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeApiApplicationScenario.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario > .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/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/build-profile.json5 deleted file mode 100755 index 69c4785e3c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/build-profile.json5 +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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", -// [Start napi_event_loop_build] -// [Start napi_ark_runtime_build] - "buildOption": { - "arkOptions" : { - "runtimeOnly" : { - "sources": [ - "./src/main/ets/pages/ObjectUtils.ets" - ] - } - }, -// [End napi_event_loop_build] -// [Start napi_ark_runtime_build] - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - "abiFilters": [ - "arm64-v8a", - "x86_64", - "armeabi-v7a" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/oh-package.json5 deleted file mode 100755 index 54a3b5a444..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/oh-package.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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", - "libentry1.so": "file:./src/main/cpp/types/libentry1" - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 59fb92fd61..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.4.1) -project(MyApplication) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) -add_library(entry1 SHARED thread_safety.cpp) -target_link_libraries(entry1 PUBLIC libace_napi.z.so libhilog_ndk.z.so) diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index ec9b10d9e5..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start napi_call_threadsafe_function_with_priority_cpp] -// [Start napi_ark_runtime_cpp] -#include -#include "napi/native_api.h" -// [StartExclute napi_ark_runtime_cpp] -#include -#include -#include - -static constexpr int INT_ARG_2 = 2; // 入参索引 -static constexpr int INT_ARG_12 = 12; // 入参索引 -static constexpr int INT_ARG_15 = 15; // 入参索引 -// [EndExclute napi_ark_runtime_cpp] -// [StartExclute napi_call_threadsafe_function_with_priority_cpp] -static void *CreateArkRuntimeFunc(void *arg) -{ - // 1. 创建基础运行环境 - napi_env env; - napi_status ret = napi_create_ark_runtime(&env); - if (ret != napi_ok) { - return nullptr; - } - - // 2. 加载自定义模块 - napi_value objUtils; - ret = napi_load_module_with_info(env, "entry/src/main/ets/pages/ObjectUtils", "com.example.myapplication/entry", - &objUtils); - if (ret != napi_ok) { - return nullptr; - } - - // 3. 使用ArkTS中的logger - napi_value logger; - ret = napi_get_named_property(env, objUtils, "Logger", &logger); - if (ret != napi_ok) { - return nullptr; - } - ret = napi_call_function(env, objUtils, logger, 0, nullptr, nullptr); - - // 4. 销毁ArkTS环境 - ret = napi_destroy_ark_runtime(&env); - - return nullptr; -} - -static napi_value CreateArkRuntime(napi_env env, napi_callback_info info) -{ - pthread_t tid; - pthread_create(&tid, nullptr, CreateArkRuntimeFunc, nullptr); - pthread_join(tid, nullptr); - return nullptr; -} -// [StartExclute napi_ark_runtime_cpp] -// [Start napi_event_loop_cpp] -static napi_value ResolvedCallback(napi_env env, napi_callback_info info) -{ - napi_stop_event_loop(env); - return nullptr; -} - -static napi_value RejectedCallback(napi_env env, napi_callback_info info) -{ - napi_stop_event_loop(env); - return nullptr; -} - -static void *RunEventLoopFunc(void *arg) -{ - // 1. 创建ArkTS实例 - napi_env env; - napi_status ret = napi_create_ark_runtime(&env); - if (ret != napi_ok) { - return nullptr; - } - - // 2. 加载自定义的模块 - napi_value objectUtils; - // 'com.example.myapplication' 为当前应用的bundleName - ret = napi_load_module_with_info(env, "ets/pages/ObjectUtils", "com.example.myapplication/entry", &objectUtils); - if (ret != napi_ok) { - return nullptr; - } - - // 3. 调用异步SetTimeout接口 - napi_value setTimeout = nullptr; - napi_value promise = nullptr; - - napi_get_named_property(env, objectUtils, "SetTimeout", &setTimeout); - napi_call_function(env, objectUtils, setTimeout, 0, nullptr, &promise); - - napi_value theFunc = nullptr; - if (napi_get_named_property(env, promise, "then", &theFunc) != napi_ok) { - return nullptr; - } - - napi_value resolvedCallback = nullptr; - napi_value rejectedCallback = nullptr; - napi_create_function(env, "resolvedCallback", NAPI_AUTO_LENGTH, ResolvedCallback, nullptr, &resolvedCallback); - napi_create_function(env, "rejectedCallback", NAPI_AUTO_LENGTH, RejectedCallback, nullptr, &rejectedCallback); - napi_value argv[2] = {resolvedCallback, rejectedCallback}; - napi_call_function(env, promise, theFunc, INT_ARG_2, argv, nullptr); - - auto flag = reinterpret_cast(arg); - if (*flag == true) { - napi_run_event_loop(env, napi_event_mode_default); - } else { - // 非阻塞式的处理任务,有可能队列中还没有任务就已经返回了 - napi_run_event_loop(env, napi_event_mode_nowait); - } - return nullptr; -} - -static napi_value RunEventLoop(napi_env env, napi_callback_info info) -{ - pthread_t tid; - size_t argc = 1; - napi_value argv[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - - bool flag = false; - napi_get_value_bool(env, argv[0], &flag); - // 创建异步线程 - pthread_create(&tid, nullptr, RunEventLoopFunc, &flag); - pthread_join(tid, nullptr); - - return nullptr; -} -// [StartExclute napi_event_loop_cpp] -// [EndExclute napi_call_threadsafe_function_with_priority_cpp] -struct CallbackData { - napi_threadsafe_function tsfn; - napi_async_work work; -}; -// ArkTS线程的回调实现 -static void CallJs(napi_env env, napi_value jsCb, void *context, void *data) -{ - if (env == nullptr) { - return; - } - napi_value resultNumber = nullptr; - napi_value undefined = nullptr; - napi_get_undefined(env, &undefined); - napi_value number1 = nullptr; - napi_create_int32(env, INT_ARG_12, &number1); - napi_value number2 = nullptr; - napi_create_int32(env, INT_ARG_15, &number2); - napi_value argv[2] = {number1, number2}; - napi_call_function(env, undefined, jsCb, INT_ARG_2, argv, &resultNumber); - int32_t res = 0; - napi_get_value_int32(env, resultNumber, &res); -} - -// 异步线程中调用该接口向ArkTS线程投递指定优先级和入队方式的任务 -static void ExecuteWork(napi_env env, void *data) -{ - CallbackData *callbackData = reinterpret_cast(data); - // 执行任务为napi_priority_idle优先级,入队方式为队列尾部入队 - napi_call_threadsafe_function_with_priority(callbackData->tsfn, nullptr, napi_priority_idle, true); - napi_call_threadsafe_function_with_priority(callbackData->tsfn, nullptr, napi_priority_low, true); - napi_call_threadsafe_function_with_priority(callbackData->tsfn, nullptr, napi_priority_high, true); - napi_call_threadsafe_function_with_priority(callbackData->tsfn, nullptr, napi_priority_immediate, true); - // 执行任务为napi_priority_high优先级,入队方式为队列头部入队 - napi_call_threadsafe_function_with_priority(callbackData->tsfn, nullptr, napi_priority_high, false); -} - -static void WorkComplete(napi_env env, napi_status status, void *data) -{ - CallbackData *callbackData = reinterpret_cast(data); - napi_release_threadsafe_function(callbackData->tsfn, napi_tsfn_release); - napi_delete_async_work(env, callbackData->work); - callbackData->work = nullptr; - callbackData->tsfn = nullptr; -} - -static napi_value CallThreadSafeWithPriority(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value jsCb = nullptr; - CallbackData *callbackData = nullptr; - napi_get_cb_info(env, info, &argc, &jsCb, nullptr, reinterpret_cast(&callbackData)); - napi_value resourceName = nullptr; - napi_create_string_utf8(env, "Thread-safe Function Demo", NAPI_AUTO_LENGTH, &resourceName); - napi_create_threadsafe_function(env, jsCb, nullptr, resourceName, 0, 1, callbackData, nullptr, callbackData, CallJs, - &callbackData->tsfn); - napi_create_async_work(env, nullptr, resourceName, ExecuteWork, WorkComplete, callbackData, &callbackData->work); - napi_queue_async_work(env, callbackData->work); - return nullptr; -} -// [EndExclute napi_event_loop_cpp] -// [EndExclute napi_ark_runtime_cpp] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - CallbackData *callbackData = new CallbackData(); - napi_property_descriptor desc[] = { - {"createArkRuntime", nullptr, CreateArkRuntime, nullptr, nullptr, nullptr, napi_static, nullptr}, - {"runEventLoop", nullptr, RunEventLoop, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"callThreadSafeWithPriority", nullptr, CallThreadSafeWithPriority, nullptr, nullptr, nullptr, - napi_default, callbackData}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module nativeModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = nullptr, - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterQueueWorkModule() { napi_module_register(&nativeModule); } -// [End napi_call_threadsafe_function_with_priority_cpp] -// [End napi_event_loop_cpp] -// [End napi_ark_runtime_cpp] diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 02cad6e4e3..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start napi_ark_runtime_dts] -export const createArkRuntime: () => object; -// [End napi_ark_runtime_dts] -// [Start napi_event_loop_dts] -export const runEventLoop: (isDefault: boolean) => object; -// [End napi_event_loop_dts] -// [Start napi_call_threadsafe_function_with_priority_dts] -export const callThreadSafeWithPriority: (cb: (a: number, b: number) => number) => void; -// [End napi_call_threadsafe_function_with_priority_dts] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/Index.d.ts deleted file mode 100755 index dd21c1bcca..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/Index.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start napi_thread_safety_dts] -export const startThread: (a: () => Promise) => void; -// [End napi_thread_safety_dts] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/oh-package.json5 deleted file mode 100755 index 36e064ade2..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/cpp/types/libentry1/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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": "libentry1.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/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 0df5e4a1b9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start napi_call_threadsafe_function_with_priority_ets] -// [Start napi_event_loop_ets] -// [Start napi_ark_runtime_ets] -import testNapi from 'libentry.so'; -// [StartExclute napi_call_threadsafe_function_with_priority_ets] -// [StartExclute napi_event_loop_ets] -// [StartExclute napi_ark_runtime_ets] -// [Start napi_thread_safety_ets] -import nativeModule from 'libentry1.so'; -// [StartExclute napi_thread_safety_ets] -@Entry -@Component -struct Index { - @State message: string = 'NodeAPI'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(30) - .fontWeight(FontWeight.Bold) - Button($r('app.string.createArkRuntime')) - .width('70%') - .onClick(() => { - // [EndExclute napi_ark_runtime_ets] - testNapi.createArkRuntime(); - // [End napi_ark_runtime_ets] - this.message = 'ArkRuntime success'; - }) - Button($r('app.string.runEventLoop')) - .width('70%') - .onClick(() => { - // [EndExclute napi_event_loop_ets] - testNapi.runEventLoop(true); - // [End napi_event_loop_ets] - this.message = 'EventLoop success'; - }) - Button($r('app.string.CallThreadSafeWithPriority')) - .width('70%') - .onClick(() => { - // [EndExclute napi_call_threadsafe_function_with_priority_ets] - let callback = (a: number, b: number): number => { - console.info('result is ' + (a + b)) - return a + b; - } - testNapi.callThreadSafeWithPriority(callback); - // [End napi_call_threadsafe_function_with_priority_ets] - this.message = 'ThreadSafeWithPriority success'; - }) - Button($r('app.string.startThread')) - .width('70%') - .onClick(() => { - // [EndExclute napi_thread_safety_ets] - let callback = (): Promise => { - return new Promise((resolve) => { - setTimeout(() => { - resolve('string from promise'); - }, 5000); - }); - } - nativeModule.startThread(callback); - // [End napi_thread_safety_ets] - this.message = 'StartThread success'; - }) - } - .width('100%') - .height('100%') - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/ohosTest.md deleted file mode 100755 index b6660114f1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiApplicationScenario/ohosTest.md +++ /dev/null @@ -1,11 +0,0 @@ -# Node-API使用场景用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| -------------------------------------------------------- | ------------ | ----------------------------------------------- | --------------------------------------------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口createArkRuntime | 位于主页 | 点击Call createArkRuntime的Button组件 | 成功调用函数输出日志,页面顶端文本变为success | Pass | -| ArkTS端成功调用native侧接口 callThreadSafeWithPriority | 位于主页 | 点击Call CallThreadSafeWithPriority的Button组件 | 成功调用函数输出日志,页面顶端文本变为success | Pass | -| ArkTS端成功调用native侧接口runEventLoop | 位于主页 | 点击按钮为调用runEventLoop的Button组件 | 成功调用函数输出日志,页面顶端文本变为success | Pass | -| ArkTS端成功调用native侧接口startThread | 位于主页 | 点击按钮为调用startThread的Button组件 | 成功调用函数输出日志,页面顶端文本变为success | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/app.json5 deleted file mode 100755 index 6ad8b4f7f7..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiarray", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/element/string.json deleted file mode 100755 index 6af9a7ec9e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIArray" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/README.md deleted file mode 100755 index 5d2b33db6a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# ArkTS使用Node-API接口进行array相关开发 - -### 介绍 - -使用Node-API接口进行array相关开发时,调用相关接口可以在Node-API模块中直接操作和处理ArkTS中的数组,使用Node-API接口进行数组(array)相关开发时,涉及的基本概念主要包括数组的创建、访问、修改、遍历以及与数组相关的操作。 - -该工程中展示了在Node-API模块中进行数组创建、获取数组长度、通过索引获得对应值等场景,其中代码详细描述可查如下链接。 - -- [使用Node-API接口进行array相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-array.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIArray.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API接口进行array相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIArray.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 6700d5f02f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPI_array) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index bc1c616708..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,475 +0,0 @@ -/* - * 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 -#include "napi/native_api.h" - -// [Start napi_create_array] -static constexpr int INT_NUMBER_5 = 5; // 入参索引 -static constexpr int INT_ARGS_2 = 2; // 入参索引 - -// 使用Node-API接口进行array相关开发 napi_create_array -static napi_value CreateArray(napi_env env, napi_callback_info info) -{ - // 创建一个空数组 - napi_value jsArray = nullptr; - napi_create_array(env, &jsArray); - // 将创建好的数组进行赋值 - for (int i = 0; i < INT_NUMBER_5; i++) { - napi_value element; - napi_create_int32(env, i, &element); - napi_set_element(env, jsArray, i, element); - } - // 返回已创建好的数组 - return jsArray; -} -// [End napi_create_array] - -// [Start napi_create_array_with_length] -// 使用Node-API接口进行array相关开发 napi_create_array_with_length -static napi_value CreateArrayWithLength(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 1; - napi_value argv[1] = {nullptr}; - napi_value jsArray = nullptr; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - // 获取传递的数组长度 - int32_t length = 0; - napi_get_value_int32(env, argv[0], &length); - // 使用napi_create_array_with_length创建指定长度的数组 - napi_create_array_with_length(env, length, &jsArray); - // 返回数组 - return jsArray; -} -// [End napi_create_array_with_length] - -// [Start napi_get_array_length] -// 使用Node-API接口进行array相关开发 napi_get_array_length -static napi_value GetArrayLength(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_value result; - uint32_t length; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 检查参数是否为数组 - bool isArray; - napi_is_array(env, args[0], &isArray); - if (!isArray) { - napi_throw_type_error(env, nullptr, "Argument must be an array"); - return nullptr; - } - napi_get_array_length(env, args[0], &length); - // 创建返回值 - napi_create_uint32(env, length, &result); - return result; -} -// [End napi_get_array_length] - -// [Start napi_is_array] -// 使用Node-API接口进行array相关开发 napi_is_array -static napi_value IsArray(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 调用napi_is_array接口判断给定入参是否为array数组 - bool result; - napi_status status = napi_is_array(env, args[0], &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_is_array fail"); - return nullptr; - } - // 将结果转成napi_value类型返回 - napi_value returnValue; - napi_get_boolean(env, result, &returnValue); - - return returnValue; -} -// [End napi_is_array] - -// [Start napi_set_element] -// 使用Node-API接口进行array相关开发 napi_set_element -static napi_value NapiSetElement(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 3; - napi_value args[3] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 检查第一个参数是否为数组 - bool isArr = false; - napi_is_array(env, args[0], &isArr); - if (!isArr) { - napi_throw_type_error(env, nullptr, "Argument should be an object of type array"); - return nullptr; - } - // 获取要设置的元素索引 - double index = 0; - napi_get_value_double(env, args[1], &index); - // 将传入的值设置到数组指定索引位置 - napi_set_element(env, args[0], static_cast(index), args[INT_ARGS_2]); - - return nullptr; -} -// [End napi_set_element] - -// [Start napi_get_element] -// 使用Node-API接口进行array相关开发 napi_get_element -static napi_value NapiGetElement(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取请求元素的索引值 - uint32_t index; - napi_get_value_uint32(env, args[1], &index); - // 获取请求索引位置的元素值并存储在result中 - napi_value result; - napi_get_element(env, args[0], index, &result); - - return result; -} -// [End napi_get_element] - -// [Start napi_has_element] -// 使用Node-API接口进行array相关开发 napi_has_element -static napi_value NapiHasElement(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取要判断的元素的索引 - uint32_t index; - napi_get_value_uint32(env, args[1], &index); - // 判断指定索引位置的元素是否存在 - bool hasElement = true; - napi_has_element(env, args[0], index, &hasElement); - // 将bool结果转换为napi_value并返回 - napi_value result; - napi_get_boolean(env, hasElement, &result); - return result; -} -// [End napi_has_element] - -// [Start napi_delete_element] -// 使用Node-API接口进行array相关开发 napi_delete_element -static napi_value NapiDeleteElement(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取要删除的元素的索引 - uint32_t index; - napi_get_value_uint32(env, args[1], &index); - // 尝试删除请求索引位置的元素 - bool deleted = true; - napi_delete_element(env, args[0], index, &deleted); - // 将bool结果转换为napi_value并返回 - napi_value result; - napi_get_boolean(env, deleted, &result); - return result; -} -// [End napi_delete_element] - -// [Start napi_create_typed_array] -// 使用Node-API接口进行array相关开发 napi_create_typedarray -static napi_value CreateTypedArray(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - int32_t typeNum = 0; - napi_get_value_int32(env, args[0], &typeNum); - napi_typedarray_type arrayType; - // 用于存储每个元素的大小 - size_t elementSize = 0; - // 根据传递的类型值选择创建对应的类型数组 - arrayType = static_cast(typeNum); - switch (typeNum) { - case napi_int8_array: - case napi_uint8_array: - case napi_uint8_clamped_array: - elementSize = sizeof(int8_t); - break; - case napi_int16_array: - case napi_uint16_array: - elementSize = sizeof(int16_t); - break; - case napi_int32_array: - case napi_uint32_array: - elementSize = sizeof(int32_t); - break; - case napi_float32_array: - elementSize = sizeof(float); - break; - case napi_float64_array: - elementSize = sizeof(double); - break; - case napi_bigint64_array: - case napi_biguint64_array: - elementSize = sizeof(int64_t); - break; - default: - // 默认创建napi_int8_array类型 - arrayType = napi_int8_array; - elementSize = sizeof(int8_t); - break; - } - size_t length = 3; - napi_value arrayBuffer = nullptr; - napi_value typedArray = nullptr; - void *data; - // 创建一个ArrayBuffer - napi_create_arraybuffer(env, length * elementSize, (void **)&data, &arrayBuffer); - // 根据给定类型创建TypedArray - napi_create_typedarray(env, arrayType, length, arrayBuffer, 0, &typedArray); - return typedArray; -} -// [End napi_create_typed_array] - -// [Start napi_is_typed_array] -// 使用Node-API接口进行array相关开发 napi_is_typedarray -static napi_value IsTypedarray(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 调用napi_is_typedarray接口判断给定入参类型是否为TypedArray。 - bool result = false; - napi_status status = napi_is_typedarray(env, args[0], &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_is_typedarray fail"); - return nullptr; - } - // 将结果转成napi_value类型返回。 - napi_value returnValue = nullptr; - napi_get_boolean(env, result, &returnValue); - - return returnValue; -} -// [End napi_is_typed_array] - -// [Start napi_get_typed_array_info] -// 使用Node-API接口进行array相关开发 napi_get_typedarray_info -static napi_value GetTypedarrayInfo(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数,第一个参数为需要获得的信息的TypedArray类型数据,第二个参数为需要获得的信息类型的枚举值 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 将第二个参数转为int32类型便于比较 - int32_t infoTypeParam; - napi_get_value_int32(env, args[1], &infoTypeParam); - // 定义枚举类型与ArkTS侧枚举类型InfoType顺序含义一致 - enum InfoType { INFO_TYPE = 1, INFO_LENGTH, INFO_ARRAY_BUFFER, INFO_BYTE_OFFSET }; - void *data; - napi_typedarray_type type; - size_t byteOffset; - size_t length; - napi_value arraybuffer; - // 调用接口napi_get_typedarray_info获得TypedArray类型数据的信息 - napi_get_typedarray_info(env, args[0], &type, &length, &data, &arraybuffer, &byteOffset); - napi_value result; - // 根据属性名,返回TypedArray对应的属性值 - switch (infoTypeParam) { - case INFO_TYPE: - // 如果传入的参数是int8类型的TypedArray数据,它的类型(type)为napi_int8_array - napi_value int8_type; - napi_get_boolean(env, type == napi_int8_array, &int8_type); - result = int8_type; - break; - case INFO_LENGTH: - // TypedArray中的元素数 - napi_value napiLength; - napi_create_int32(env, length, &napiLength); - result = napiLength; - break; - case INFO_BYTE_OFFSET: - // TypedArray数组的第一个元素所在的基础原生数组中的字节偏移量 - napi_value napiByteOffset; - napi_create_int32(env, byteOffset, &napiByteOffset); - result = napiByteOffset; - break; - case INFO_ARRAY_BUFFER: - // TypedArray下的ArrayBuffer - result = arraybuffer; - break; - default: - break; - } - return result; -} -// [End napi_get_typed_array_info] - -// [Start napi_create_data_view] -// 使用Node-API接口进行array相关开发 napi_create_dataview -static napi_value CreateDataView(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_value arraybuffer = nullptr; - napi_value result = nullptr; - // DataView的字节长度 - size_t byteLength = 12; - // 字节偏移量 - size_t byteOffset = 4; - // 获取回调函数的参数信息 - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 将参数转换为对象类型 - napi_coerce_to_object(env, args[0], &arraybuffer); - // 创建一个数据视图对象,并指定字节长度和字节偏移量 - napi_status status = napi_create_dataview(env, byteLength, arraybuffer, byteOffset, &result); - if (status != napi_ok) { - // 抛出创建DataView内容失败的错误 - napi_throw_error(env, nullptr, "Failed to create DataView"); - return nullptr; - } - // 获取DataView的指针和长度信息 - uint8_t *data = nullptr; - size_t length = 0; - napi_get_dataview_info(env, result, &length, (void **)&data, nullptr, nullptr); - // 为DataView赋值 - for (size_t i = 0; i < length; i++) { - data[i] = static_cast(i + 1); - } - return result; -} -// [End napi_create_data_view] - -// [Start napi_is_data_view] -// 使用Node-API接口进行array相关开发 napi_is_dataview -static napi_value IsDataView(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 调用napi_is_dataview接口判断给定入参是否为DataView数据。 - bool result; - napi_status status = napi_is_dataview(env, args[0], &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_is_dataview fail"); - return nullptr; - } - // 将结果转成napi_value类型返回。 - napi_value returnValue; - napi_get_boolean(env, result, &returnValue); - - return returnValue; -} -// [End napi_is_data_view] - -// [Start napi_get_data_view_info] -// 使用Node-API接口进行array相关开发 napi_get_dataview_info -static napi_value GetDataViewInfo(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传入的参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 将第二个参数转为int32类型的数字 - int32_t infoType; - napi_get_value_int32(env, args[1], &infoType); - size_t byteLength; - void *data; - napi_value arrayBuffer; - size_t byteOffset; - // 定义枚举类型与ArkTS侧枚举类型InfoType顺序含义一致 - enum InfoType { BYTE_LENGTH = 0, ARRAY_BUFFER, BYTE_OFFSET }; - // 获取dataview信息 - napi_get_dataview_info(env, args[0], &byteLength, &data, &arrayBuffer, &byteOffset); - napi_value result; - switch (infoType) { - case BYTE_LENGTH: - // 返回查询DataView的字节数 - napi_value napiByteLength; - napi_create_int32(env, byteLength, &napiByteLength); - result = napiByteLength; - break; - case ARRAY_BUFFER: - // 返回查询DataView的arraybuffer - result = arrayBuffer; - break; - case BYTE_OFFSET: - // 返回查询DataView的偏移字节量 - napi_value napiByteOffset; - napi_create_int32(env, byteOffset, &napiByteOffset); - result = napiByteOffset; - break; - default: - break; - } - return result; -} -// [End napi_get_data_view_info] - -// [Start change_use_napi_process] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_value typedArrayTypes; - napi_create_object(env, &typedArrayTypes); - napi_value typeIndex; - std::string typeKeys[] = { - "INT8_ARRAY", "UINT8_ARRAY", "UINT8_CLAMPED_ARRAY", "INT16_ARRAY", "UINT16_ARRAY", "INT32_ARRAY", - "UINT32_ARRAY", "FLOAT32_ARRAY", "FLOAT64_ARRAY", "BIGINT64_ARRAY", "BIGUINT64_ARRAY", - }; - for (int32_t i = 0; i < sizeof(typeKeys) / sizeof(typeKeys[0]); i++) { - napi_create_int32(env, i, &typeIndex); - napi_set_named_property(env, typedArrayTypes, typeKeys[i].c_str(), typeIndex); - } - napi_property_descriptor desc[] = { - {"createArray", nullptr, CreateArray, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createArrayWithLength", nullptr, CreateArrayWithLength, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getArrayLength", nullptr, GetArrayLength, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"isArray", nullptr, IsArray, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiSetElement", nullptr, NapiSetElement, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiGetElement", nullptr, NapiGetElement, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiHasElement", nullptr, NapiHasElement, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiDeleteElement", nullptr, NapiDeleteElement, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createTypedArray", nullptr, CreateTypedArray, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"TypedArrayTypes", nullptr, nullptr, nullptr, nullptr, typedArrayTypes, napi_default, nullptr}, - {"isTypedarray", nullptr, IsTypedarray, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getTypedarrayInfo", nullptr, GetTypedarrayInfo, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createDataView", nullptr, CreateDataView, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"isDataView", nullptr, IsDataView, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getDataViewInfo", nullptr, GetDataViewInfo, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END -// [End change_use_napi_process] - -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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 655f5726fd..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_create_array_api] -export const createArray: () => number[]; // 使用Node-API接口进行array相关开发 napi_create_array -// [End napi_create_array_api] - -// [Start napi_create_array_with_length_api] -export const createArrayWithLength: (length: number) => void[]; // 使用Node-API接口进行array相关开发 napi_create_array_with_length -// [End napi_create_array_with_length_api] - -// [Start napi_get_array_length_api] -export const getArrayLength: (arr: Array) => number | void; // 使用Node-API接口进行array相关开发 napi_get_array_length -// [End napi_get_array_length_api] - -// [Start napi_is_array_api] -export const isArray: (data: Array | T) => boolean | void; // 使用Node-API接口进行array相关开发 napi_is_array -// [End napi_is_array_api] - -// [Start napi_set_element_api] -export const napiSetElement: (arr: Array, index: number, - value: T) => void; // 使用Node-API接口进行array相关开发 napi_set_element -// [End napi_set_element_api] - -// [Start napi_get_element_api] -export const napiGetElement: (arr: Array, - index: number) => number | string | Object | boolean | undefined; // 使用Node-API接口进行array相关开发 napi_get_element -// [End napi_get_element_api] - -// [Start napi_has_element_api] -export const napiHasElement: (arr: Array, index: number) => boolean; // 使用Node-API接口进行array相关开发 napi_has_element -// [End napi_has_element_api] - -// [Start napi_delete_element_api] -export const napiDeleteElement: (arr: Array, - index: number) => boolean; // 使用Node-API接口进行array相关开发 napi_delete_element -// [End napi_delete_element_api] - -// [Start napi_create_typed_array_api] -export const enum TypedArrayTypes { - INT8_ARRAY = 0, - UINT8_ARRAY, - UINT8_CLAMPED_ARRAY, - INT16_ARRAY, - UINT16_ARRAY, - INT32_ARRAY, - UINT32_ARRAY, - FLOAT32_ARRAY, - FLOAT64_ARRAY, - BIGINT64_ARRAY, - BIGuINT64_ARRAY, -} - -export const createTypedArray: (type: TypedArrayTypes) => T; // 使用Node-API接口进行array相关开发 napi_create_typedarray -// [End napi_create_typed_array_api] - -// [Start napi_is_typed_array_api] -export const isTypedarray: (data: Object) => boolean | void; // 使用Node-API接口进行array相关开发 napi_is_typedarray -// [End napi_is_typed_array_api] - -// [Start napi_get_typed_array_info_api] -export const getTypedarrayInfo: (typeArray: T, - infoType: number) => ArrayBuffer | number | boolean; // 使用Node-API接口进行array相关开发 napi_get_typedarray_info -// [End napi_get_typed_array_info_api] - -// [Start napi_create_data_view_api] -export const createDataView: (arraybuffer: ArrayBuffer) => DataView | void; // 使用Node-API接口进行array相关开发 napi_create_dataview -// [End napi_create_data_view_api] - -// [Start napi_is_data_view_api] -export const isDataView: (date: DataView | string) => boolean | void; // 使用Node-API接口进行array相关开发 napi_is_dataview -// [End napi_is_data_view_api] - -// [Start napi_get_data_view_info_api] -export const getDataViewInfo: (dataView: DataView, - infoType: number) => ArrayBuffer | number; // 使用Node-API接口进行array相关开发 napi_get_dataview_info -// [End napi_get_data_view_info_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index c85ea228c1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,310 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiCreateArray', - '2.napiCreateArrayWithLength', - '3.napiGetArrayLength', - '4.napiIsArray', - '5.napiSetElement', - '6.napiGetElement', - '7.napiHasElement', - '8.napiDeleteElement', - '9.napiCreateTypedArray', - '10.napiIsTypedArray', - '11.napiGetTypedArrayInfo', - '12.napiCreateDataView', - '13.napiIsDataView', - '14.napiGetDataViewInfo' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(23) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 4 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiCreateArray') { - // [Start ark_napi_create_array] - //使用Node-API接口进行array相关开发 napi_create_array - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_array:%{public}s', - JSON.stringify(testNapi.createArray())); - // [End ark_napi_create_array] - this.result = 'napiCreateArraySuccess'; - } else if (item === '2.napiCreateArrayWithLength') { - // [Start ark_napi_create_array_with_length] - // 使用Node-API接口进行array相关开发 napi_create_array_with_length - let array = testNapi.createArrayWithLength(6); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_array_with_length:%{public}d', array.length); - // [End ark_napi_create_array_with_length] - this.result = 'napiCreateArrayWithLengthSuccess'; - } else if (item === '3.napiGetArrayLength') { - // [Start ark_napi_get_array_length] - // 使用Node-API接口进行array相关开发 napi_get_array_length - const arr = [0, 1, 2, 3, 4, 5]; - hilog.info(0x0000, 'testTag', 'Test Node-API get_array_length:%{public}d', - testNapi.getArrayLength(arr)); - // [End ark_napi_get_array_length] - this.result = 'napiGetArrayLengthSuccess'; - } else if (item === '4.napiIsArray') { - // [Start ark_napi_is_array] - // 使用Node-API接口进行array相关开发 napi_is_array - try { - let value = new Array(1); - let data = "123"; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_array: %{public}s', - testNapi.isArray(value)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_array: %{public}s', - testNapi.isArray(data)); - // [StartExclude ark_napi_is_array] - this.result = 'napiIsArraySuccess'; - // [EndExclude ark_napi_is_array] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_array error: %{public}s', error.message); - // [StartExclude ark_napi_is_array] - this.result = 'napiIsArrayFail'; - // [EndExclude ark_napi_is_array] - } - // [End ark_napi_is_array] - } else if (item === '5.napiSetElement') { - // [Start ark_napi_set_element] - // 使用Node-API接口进行array相关开发 napi_set_element - let arr = [10, 20, 30]; - testNapi.napiSetElement(arr, 1, 'newElement'); - testNapi.napiSetElement(arr, 2, 50); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_element arr: %{public}s', arr.toString()); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_element arr[3]: %{public}s', arr[3]); - - interface MyObject { - first: number; - second: number; - } - - let obj: MyObject = { - first: 1, - second: 2 - }; - testNapi.napiSetElement(arr, 4, obj); - let objAsString = JSON.stringify(arr[4]); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_element arr[4]: %{public}s', objAsString); - // [End ark_napi_set_element] - this.result = 'napiSetElementSuccess'; - } else if (item === '6.napiGetElement') { - // [Start ark_napi_get_element] - // 使用Node-API接口进行array相关开发 napi_get_element - interface MyObject { - first: number; - second: number; - } - - let obj: MyObject = { - first: 1, - second: 2 - }; - let arr = [10, 'hello', null, obj]; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[0]: %{public}d', - testNapi.napiGetElement(arr, 0)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[1]: %{public}s', - testNapi.napiGetElement(arr, 1)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[2]: %{public}s', - testNapi.napiGetElement(arr, 2)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[3]: %{public}s', - testNapi.napiGetElement(arr, 3)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[4]: %{public}s', - JSON.stringify(testNapi.napiGetElement(arr, 4))); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[null]: %{public}s', - testNapi.napiGetElement(arr, 5)); - // [End ark_napi_get_element] - this.result = 'napiGetElementSuccess'; - } else if (item === '7.napiHasElement') { - // [Start ark_napi_has_element] - // 使用Node-API接口进行array相关开发 napi_has_element - let arr = [10, 'hello', null, 'world']; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element arr[0]: %{public}s', - testNapi.napiHasElement(arr, 0)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element arr[7]: %{public}s', - testNapi.napiHasElement(arr, 7)); - // [End ark_napi_has_element] - this.result = 'napiHasElementSuccess'; - } else if (item === '8.napiDeleteElement') { - // [Start ark_napi_delete_element] - // 使用Node-API接口进行array相关开发 napi_delete_element - let arr = [10, 'hello', null, 'world']; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element arr[0]: %{public}s', - testNapi.napiHasElement(arr, 0)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_delete_element arr[0]: %{public}s', - testNapi.napiDeleteElement(arr, 0)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element deleted arr[0]: %{public}s', - testNapi.napiHasElement(arr, 0)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[0]: %{public}d', - testNapi.napiGetElement(arr, 0)); - // [End ark_napi_delete_element] - this.result = 'napiDeleteElementSuccess'; - } else if (item === '9.napiCreateTypedArray') { - // [Start ark_napi_create_typed_array] - // 使用Node-API接口进行array相关开发 napi_create_typedarray - let typedArray = testNapi.createTypedArray(testNapi.TypedArrayTypes["INT8_ARRAY"]); - if (typedArray instanceof Int8Array) { - hilog.info(0x0000, 'testTag', ' Node-API napi_create_typedarray: Int8Array'); - // [StartExclude ark_napi_create_typed_array] - this.result = 'napiCreateInt8ArraySuccess'; - // [EndExclude ark_napi_create_typed_array] - } - let uint8Array = testNapi.createTypedArray(testNapi.TypedArrayTypes["UINT8_ARRAY"]); - if (uint8Array instanceof Uint8Array) { - hilog.info(0x0000, 'testTag', ' Node-API napi_create_typedarray: Uint8Array'); - // [StartExclude ark_napi_create_typed_array] - this.result = 'napiCreateUint8ArraySuccess'; - // [EndExclude ark_napi_create_typed_array] - } - // [End ark_napi_create_typed_array] - } else if (item === '10.napiIsTypedArray') { - // [Start ark_napi_is_typed_array] - // 使用Node-API接口进行array相关开发 napi_is_typedarray - try { - let value = new Uint8Array([1, 2, 3, 4]); - let data = "123"; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_typedarray: %{public}s', - testNapi.isTypedarray(value)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_typedarray: %{public}s', - testNapi.isTypedarray(data)); - // [StartExclude ark_napi_is_typed_array] - this.result = 'napiIsTypedArraySuccess'; - // [EndExclude ark_napi_is_typed_array] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_typedarray error: %{public}s', error.message); - // [StartExclude ark_napi_is_typed_array] - this.result = 'napiIsTypedArrayFail'; - // [EndExclude ark_napi_is_typed_array] - } - // [End ark_napi_is_typed_array] - } else if (item === '11.napiGetTypedArrayInfo') { - // [Start ark_napi_get_typed_array_info] - // 使用Node-API接口进行array相关开发 napi_get_typedarray_info - // 传入TypedArray类型数据。TypedArray是一种用来描述二进制数据的类数组数据视图,没有直接构造器,可以用其子类构造类数组 - // TypedArray的子类有: Int8Array Uint8Array Uint8ClampedArray Int16Array Int32Array等 - let int8Array = new Int8Array([15, 7]); - // 定义枚举类型 这些都是TypedArray的属性 - enum InfoType { - TYPE = 1, // 传入的TypedArray的类型 - LENGTH = 2, // 传入的TypedArray的长度 - ARRAY_BUFFER = 3, // TypedArray下的ArrayBuffer - BYTE_OFFSET = 4 // 数组的第一个元素所在的基础原生数组中的字节偏移量 - }; - let arrbuff = testNapi.getTypedarrayInfo(int8Array, InfoType.ARRAY_BUFFER) as ArrayBuffer; - // 将arraybuffer转为数组 - let arr = new Array(new Int8Array(arrbuff)); - hilog.info(0x0000, 'Node-API', 'get_typedarray_info_arraybuffer: %{public}s', arr.toString()); - hilog.info(0x0000, 'Node-API', 'get_typedarray_info_isIn8Array: %{public}s', - testNapi.getTypedarrayInfo(int8Array, InfoType.TYPE).toString()); - hilog.info(0x0000, 'Node-API', 'get_typedarray_info_length: %{public}d', - testNapi.getTypedarrayInfo(int8Array, InfoType.LENGTH)); - hilog.info(0x0000, 'Node-API', 'get_typedarray_info_byte_offset: %{public}d', - testNapi.getTypedarrayInfo(int8Array, InfoType.BYTE_OFFSET)); - // [End ark_napi_get_typed_array_info] - this.result = 'napiGetTypedArrayInfoSuccess'; - } else if (item === '12.napiCreateDataView') { - // [Start ark_napi_create_data_view] - // 使用Node-API接口进行array相关开发 napi_create_dataview - const arrayBuffer = new ArrayBuffer(16); - const dataView = testNapi.createDataView(arrayBuffer) as DataView; - hilog.info(0x0000, 'testTag', 'Test Node-API dataView:%{public}d', dataView.byteLength); - hilog.info(0x0000, 'testTag', 'Test Node-API dataView第一个数据:%{public}d', dataView.getInt8(0)); - // [End ark_napi_create_data_view] - this.result = 'napiCreateDataViewSuccess'; - } else if (item === '13.napiIsDataView') { - // [Start ark_napi_is_data_view] - // 使用Node-API接口进行array相关开发 napi_is_dataview - try { - let buffer = new ArrayBuffer(16); - let dataView = new DataView(buffer); - let data = "123"; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_dataview: %{public}s', - testNapi.isDataView(dataView)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_dataview: %{public}s', - testNapi.isDataView(data)); - // [StartExclude ark_napi_is_data_view] - this.result = 'napiIsDataViewSuccess'; - // [EndExclude ark_napi_is_data_view] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_dataview error: %{public}s', error.message); - // [StartExclude ark_napi_is_data_view] - this.result = 'napiIsDataViewFail'; - // [EndExclude ark_napi_is_data_view] - } - // [End ark_napi_is_data_view] - } else if (item === '14.napiGetDataViewInfo') { - // [Start ark_napi_get_data_view_info] - // 使用Node-API接口进行array相关开发 napi_get_dataview_info - // 创建一个ArrayBuffer - let arrayBuffer = new Int8Array([2, 5]).buffer; - // 使用arrayBuffer创建一个dataView - let dataView = new DataView(arrayBuffer); - // 定义一个枚举类型 - enum InfoType { - BYTE_LENGTH = 0, - ARRAY_BUFFER = 1, - BYTE_OFFSET = 2, - }; - // 传入DataView类型参数查询DataView的字节数 - hilog.info(0x0000, 'Node-API', 'get_dataview_info_bytelength %{public}d', - testNapi.getDataViewInfo(dataView, InfoType.BYTE_LENGTH)); - // 传入DataView类型参数查询DataView的ArrayBuffer - let arrbuff = testNapi.getDataViewInfo(dataView, InfoType.ARRAY_BUFFER) as ArrayBuffer; - // 将arraybuffer转为数组 - let arr = Array.from(new Int8Array(arrbuff)); - hilog.info(0x0000, 'Node-API', 'get_dataview_info_arraybuffer %{public}s', arr.toString()); - // 传入DataView类型参数查询DataView开始投影的数据缓冲区中的字节偏移量 - hilog.info(0x0000, 'Node-API', 'get_dataview_info_byteoffset %{public}d', - testNapi.getDataViewInfo(dataView, InfoType.BYTE_OFFSET)); - // [End ark_napi_get_data_view_info] - this.result = 'napiGetDataViewInfoSuccess'; - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - .id('List') - } - .width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} - diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/ohosTest.md deleted file mode 100755 index a480dd668d..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArray/ohosTest.md +++ /dev/null @@ -1,21 +0,0 @@ -# 使用Node-API进行array相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------ | ------------ | ----------------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 createArray | 位于主页 | 点击文本为1.napiCreateArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateArraySuccess | Pass | -| ArkTS端成功调用native侧接口createArrayWithLength | 位于主页 | 点击文本为2.napiCreateArrayWithLength的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateArrayWithLengthSuccess | Pass | -| ArkTS端成功调用native侧接口getArrayLength | 位于主页 | 点击文本为3.napiGetArrayLength的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetArrayLengthSuccess | Pass | -| ArkTS端成功调用native侧接口isArray | 位于主页 | 点击文本为4.napiIsArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsArraySuccess | Pass | -| ArkTS端成功调用native侧接口napiSetElement | 位于主页 | 点击文本为5.napiSetElement的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiSetElementSuccess | Pass | -| ArkTS端成功调用native侧接口napiGetElement | 位于主页 | 点击文本为6.napiGetElement的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetElementSuccess | Pass | -| ArkTS端成功调用native侧接口napiHasElement | 位于主页 | 点击文本为7.napiHasElement的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiHasElementSuccess | Pass | -| ArkTS端成功调用native侧接口napiDeleteElement | 位于主页 | 点击文本为8.napiDeleteElement的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDeleteElementSuccess | Pass | -| ArkTS端成功调用native侧接口createTypedArray | 位于主页 | 点击文本为9.napiCreateTypedArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateUint8ArraySuccess | Pass | -| ArkTS端成功调用native侧接口isTypedarray | 位于主页 | 点击文本为10.napiIsTypedArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsTypedArraySuccess | Pass | -| ArkTS端成功调用native侧接口getTypedarrayInfo | 位于主页 | 点击文本为11.napiGetTypedArrayInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetTypedArrayInfoSuccess | Pass | -| ArkTS端成功调用native侧接口createDataView | 位于主页 | 点击文本为12.napiCreateDataView的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateDataViewSuccess | Pass | -| ArkTS端成功调用native侧接口isDataView | 位于主页 | 点击文本为13.napiIsDataView的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsDataViewSuccess | Pass | -| ArkTS端成功调用native侧接口getDataViewInfo | 位于主页 | 点击文本为14.napiGetDataViewInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetDataViewInfoSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/app.json5 deleted file mode 100755 index 68c6ac4600..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiarraybuffer", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/element/string.json deleted file mode 100755 index 1a06c8079d..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIArraybuffer" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/README.md deleted file mode 100755 index b8e56d852b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# ArkTS使用Node-API接口进行ArrayBuffer相关开发 - -### 介绍 - -ArrayBuffer是ArkTS中的一种数据类型,用于表示通用的、固定长度的原始二进制数据缓冲区。它提供了一种在ArkTS中有效地表示和操作原始二进制数据的方式 - -该工程主要展示了使用Node-API接口进行检查值是否为ArrayBuffer、获取给定的ArrayBuffer对象信息、分离ArrayBuffer信息、判定是否分离ArrayBuffer以及创建指定长度的ArrayBuffer对象,其中展示的代码详细描述可查如下链接。 - -- [使用Node-API接口进行ArrayBuffer相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-arraybuffer.md) - -### 效果预览 - -| 首页 | 执行效果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIArraybuffer.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API接口进行Arraybuffer相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIArraybuffer.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 590b7279a2..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPI_arraybuffer) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 0371f4cf45..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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" - -// [Start napi_is_arraybuffer] -// napi_is_arraybuffer -static napi_value IsArrayBuffer(napi_env env, napi_callback_info info) -{ - // 接受一个入参 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 调用napi_is_arraybuffer接口判断给定入参是否为ArrayBuffer数据 - bool result = false; - napi_status status = napi_is_arraybuffer(env, args[0], &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_is_arraybuffer fail"); - return nullptr; - } - // 将结果转成napi_value类型返回 - napi_value returnValue = nullptr; - napi_get_boolean(env, result, &returnValue); - return returnValue; -} -// [End napi_is_arraybuffer] - -// [Start napi_get_arraybuffer_info] -// napi_get_arraybuffer_info -static napi_value GetArraybufferInfo(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 检查参数是否为ArrayBuffer - bool isArraybuffer = false; - napi_is_arraybuffer(env, args[0], &isArraybuffer); - if (!isArraybuffer) { - napi_throw_type_error(env, nullptr, "Argument must be an ArrayBuffer"); - return nullptr; - } - - void *data = nullptr; - size_t byteLength = 0; - // 获取ArrayBuffer的底层数据缓冲区和长度 - napi_status status = napi_get_arraybuffer_info(env, args[0], &data, &byteLength); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Failed to get ArrayBuffer info"); - return nullptr; - } - // 创建结果对象 - napi_value result = nullptr; - napi_create_object(env, &result); - // 创建数据缓冲区的字节长度属性 - napi_value byteLengthValue = nullptr; - napi_create_uint32(env, byteLength, &byteLengthValue); - napi_set_named_property(env, result, "byteLength", byteLengthValue); - napi_value bufferData; - napi_create_arraybuffer(env, byteLength, &data, &bufferData); - napi_set_named_property(env, result, "buffer", bufferData); - return result; -} -// [End napi_get_arraybuffer_info] - -// [Start napi_detach_arraybuffer] -// napi_detach_arraybuffer -static napi_value DetachedArraybuffer(napi_env env, napi_callback_info info) -{ - // 调用napi_detach_arraybuffer接口分离给定ArrayBuffer的底层数据 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - napi_value arrayBuffer = args[0]; - napi_detach_arraybuffer(env, arrayBuffer); - // 将分离后的arraybuffer传出去 - return arrayBuffer; -} - -// napi_is_detach_arraybuffer -static napi_value IsDetachedArraybuffer(napi_env env, napi_callback_info info) -{ - // 调用napi_is_detached_arraybuffer判断给定的arraybuffer是否已被分离 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - napi_value arrayBuffer = args[0]; - bool result = false; - napi_is_detached_arraybuffer(env, arrayBuffer, &result); - // 将返回值通过napi_get_boolean接口转成napi_value传出去做打印 - napi_value returnValue; - napi_get_boolean(env, result, &returnValue); - return returnValue; -} -// [End napi_detach_arraybuffer] - -// [Start napi_create_arraybuffer] -// napi_create_arraybuffer -static napi_value CreateArraybuffer(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value argv[1] = {nullptr}; - napi_value result = nullptr; - // 解析传递的参数 - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - int32_t value; - size_t length; - // 将ArkTS侧传递的参数转换为size_t类型,作为napi_create_arraybuffer的参数 - napi_get_value_int32(env, argv[0], &value); - length = size_t(value); - void *data; - // 创建一个新的ArrayBuffer - napi_create_arraybuffer(env, length, &data, &result); - if (data != nullptr) { - // 确保安全后才能使用data进行操作 - } - // 返回ArrayBuffer - return result; -} -// [End napi_create_arraybuffer] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"isArrayBuffer", nullptr, IsArrayBuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getArraybufferInfo", nullptr, GetArraybufferInfo, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"detachedArraybuffer", nullptr, DetachedArraybuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"isDetachedArraybuffer", nullptr, IsDetachedArraybuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createArraybuffer", nullptr, CreateArraybuffer, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 3bcabf7866..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_is_arraybuffer_api] -export const isArrayBuffer: (arrayBuffer: T) => boolean | void; // napi_is_arraybuffer -// [End napi_is_arraybuffer_api] - -// [Start napi_get_arraybuffer_info_api] -export class ArrayBufferInfo { - byteLength: number; - buffer: Object; -} - -export const getArraybufferInfo: (data: ArrayBuffer) => ArrayBufferInfo | void; // napi_get_arraybuffer_info -// [End napi_get_arraybuffer_info_api] - -// [Start napi_detach_arraybuffer_api] -export const detachedArraybuffer: (buffer: ArrayBuffer) => ArrayBuffer; // napi_detach_arraybuffer - -export const isDetachedArraybuffer: (arrarBeffer: ArrayBuffer) => boolean; //napi_is_detached_arraybuffer -// [End napi_detach_arraybuffer_api] - -// [Start napi_create_arraybuffer_api] -export const createArraybuffer: (size: number) => ArrayBuffer; // napi_create_arraybuffer -// [End napi_create_arraybuffer_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 3b51abe806..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiIsArraybuffer', - '2.napiGetArraybufferInfo', - '3.napiDetachArraybuffer', - '4.napiCreateArraybuffer' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(25) - .fontWeight(FontWeight.Bold) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiIsArraybuffer') { - // [Start ark_napi_is_arraybuffer] - // napi_is_arraybuffer - try { - let value = new ArrayBuffer(1); - let data = "123"; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_arraybuffer: %{public}s', - testNapi.isArrayBuffer(value)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_arraybuffer: %{public}s', - testNapi.isArrayBuffer(data)); - // [StartExclude ark_napi_is_arraybuffer] - this.result = 'napiIsArraybufferSuccess'; - // [EndExclude ark_napi_is_arraybuffer] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_arraybuffer error: %{public}s', - error.message); - // [StartExclude ark_napi_is_arraybuffer] - this.result = 'napiIsArraybufferFail'; - // [EndExclude ark_napi_is_arraybuffer] - } - // [End ark_napi_is_arraybuffer] - } else if (item === '2.napiGetArraybufferInfo') { - // [Start ark_napi_get_arraybuffer_info - // napi_get_arraybuffer_info - const buffer = new ArrayBuffer(10); - hilog.info(0x0000, 'testTag', 'Test Node-API get_arraybuffer_info:%{public}s ', - JSON.stringify(testNapi.getArraybufferInfo(buffer))); - // [End ark_napi_get_arraybuffer_info] - this.result = 'napiGetArraybufferInfoSuccess'; - } else if (item === '3.napiDetachArraybuffer') { - // [Start ark_napi_detach_arraybuffer] - // napi_detach_arraybuffer and napi_is_detached_arraybuffer - try { - const bufferArray = new ArrayBuffer(8); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_detached_arraybuffer one: %{public}s', - testNapi.isDetachedArraybuffer(bufferArray)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_detached_arraybuffer two: %{public}s ', - testNapi.isDetachedArraybuffer(testNapi.detachedArraybuffer(bufferArray))); - // [StartExclude ark_napi_detach_arraybuffer] - this.result = 'napiDetachArraybufferSuccess'; - // [EndExclude ark_napi_detach_arraybuffer] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_detached_arraybuffer error: %{public}s', - error.message); - // [StartExclude ark_napi_detach_arraybuffer] - this.result = 'napiDetachArraybufferFail'; - // [EndExclude ark_napi_detach_arraybuffer] - } - // [End ark_napi_detach_arraybuffer] - } else if (item === '4.napiCreateArraybuffer') { - // [Start ark_napi_create_arraybuffer] - // napi_create_arraybuffer - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_arraybuffer:%{public}s', - testNapi.createArraybuffer(10).toString()); - // [End ark_napi_create_arraybuffer] - this.result = 'napiCreateArraybufferSuccess'; - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - } - .width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/ohosTest.md deleted file mode 100755 index db3693318a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIArraybuffer/ohosTest.md +++ /dev/null @@ -1,11 +0,0 @@ -# 使用Node-API进行arraybuffer相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------ | ------------ | -------------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口isArrayBuffer | 位于主页 | 点击文本为1.napiIsArraybuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsArraybufferSuccess | Pass | -| ArkTS端成功调用native侧接口getArraybufferInfo | 位于主页 | 点击文本为2.napiGetArraybufferInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetArraybufferInfoSuccess | Pass | -| ArkTS端成功调用native侧接口isDetachedArraybuffer | 位于主页 | 点击文本为3.napiDetachArraybuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDetachArraybufferSuccess | Pass | -| ArkTS端成功调用native侧接口createArraybuffer | 位于主页 | 点击文本为4.napiCreateArraybuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateArraybufferSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/app.json5 deleted file mode 100755 index 4a5324e529..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapibasicdatatypes", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/element/string.json deleted file mode 100755 index a5255df568..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIBasicDataTypes" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/README.md deleted file mode 100755 index cfec2108aa..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# ArkTS使用Node-API进行basic_data_types相关开发 - -### 介绍 - -ArkTS的Number类型是一个双精度64位二进制格式IEEE 754值。只有在-2^53+1到2^53-1范围内(闭区间)的整数才能在不丢失精度的情况下被表示,在超过该取值范围的情况下,需要使用BigInt对应的NPI接口来处理更大范围的整数。 - -该工程主要展示了使用Node-API接口将number类型转换为uint32、int32、int64、double以及前述四种类型转换回number类型,其中展示的代码详细描述可查如下链接。 - -- [使用Node-API进行basic_data_types相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-basic-data-types.md) - -### 效果预览 - -| 首页 | 执行效果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIBasicDataTypes.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API接口进行basic_data_types相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIBasicDataTypes.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 6ea17b5242..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIBasicDataTypes) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index e752683274..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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" - -// [Start napi_get_value_uint32] -// napi_get_value_uint32 -static napi_value GetValueUint32(napi_env env, napi_callback_info info) -{ - // 获取传入的数字类型参数 - size_t argc = 1; - napi_value argv[1] = {nullptr}; - // 解析传入的参数 - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - - uint32_t number = 0; - // 获取传入参数的值中的无符号32位整数 - napi_status status = napi_get_value_uint32(env, argv[0], &number); - // 如果传递的参数不是数字,将会返回napi_number_expected,设置函数返回nullptr - if (status == napi_number_expected) { - return nullptr; - } - napi_value result = nullptr; - // 创建传入参数无符号32位整数,并传出 - napi_create_uint32(env, number, &result); - return result; -} -// [End napi_get_value_uint32] - -// [Start napi_get_value_int32] -// napi_get_value_int32 -static napi_value GetValueInt32(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - int32_t result32 = 0; - // 解析传递的参数 - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 将前端传过来的参数转为Node-API模块的int32类型 - napi_status status = napi_get_value_int32(env, args[0], &result32); - // 如果传递的参数不是数字napi_get_value_int32接口将会返回napi_number_expected,设置函数返回nullptr - if (status == napi_number_expected) { - return nullptr; - } - // 调用napi_create_int32接口将int32类型的数据转为napi_value返回 - napi_value napiResult32 = nullptr; - napi_create_int32(env, result32, &napiResult32); - return napiResult32; -} -// [End napi_get_value_int32] - -// [Start napi_get_value_int64] -// napi_get_value_int64 -static napi_value GetValueInt64(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - int64_t result64 = 0; - // 解析传递的值 - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 将前端传过来的参数转为Node-API模块的int64类型 - napi_status status = napi_get_value_int64(env, args[0], &result64); - // 如果传递的参数不是数字, 返回napi_number_expected. - if (status == napi_number_expected) { - return nullptr; - } - // 调用napi_create_int64接口将int64类型的数据转为napi_value返回前端 - napi_value napiResult64 = nullptr; - napi_create_int64(env, result64, &napiResult64); - return napiResult64; -} -// [End napi_get_value_int64] - -// [Start napi_get_value_double] -// napi_get_value_double -static napi_value GetDouble(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - double value = 0; - napi_status status = napi_get_value_double(env, args[0], &value); - // 传入非数字接口返回napi_number_expected - if (status == napi_number_expected) { - return nullptr; - } - napi_value result = nullptr; - napi_create_double(env, value, &result); - return result; -} -// [End napi_get_value_double] - -// [Start napi_create_int32] -// napi_create_int32 -static napi_value CreateInt32(napi_env env, napi_callback_info info) -{ - // int32_t是有符号的32位整数类型,表示带有符号的整数,它的范围是从-2^31到2^31 - 1,也就是-2147483648到2147483647 - // 要表示的整数值 - int32_t value = -26; - // 创建ArkTS中的int32数字 - napi_value result = nullptr; - napi_status status = napi_create_int32(env, value, &result); - if (status != napi_ok) { - // 处理错误 - napi_throw_error(env, nullptr, "Failed to create int32 value"); - } - return result; -} -// [End napi_create_int32] - -// [Start napi_create_uint32] -// napi_create_uint32 -static napi_value CreateUInt32(napi_env env, napi_callback_info info) -{ - // 如果使用 - // uint32_t类型来定义-26,会发生溢出,溢出时会对结果进行模运算,将负数的二进制补码转换为相应的正数。-26输出4294967270 - // uint32_t是无符号的32位整数类型,只能表示非负整数。它的范围是从0到2 ^32 - 1,即0到4294967295 - // 要表示的整数值 - uint32_t value = 26; - // 创建ArkTS中的uint32数字 - napi_value result = nullptr; - napi_status status = napi_create_uint32(env, value, &result); - if (status != napi_ok) { - // 处理错误 - napi_throw_error(env, nullptr, "Failed to create uint32 value"); - } - return result; -} -// [End napi_create_uint32] - -// [Start napi_create_int64] -// napi_create_int64 -static napi_value CreateInt64(napi_env env, napi_callback_info info) -{ - // int64是有符号的64位整数类型,可以表示范围从-2^63到2^63 - 1的整数,即 -9223372036854775808到9223372036854775807 - // 要表示的整数值 - int64_t value = 2147483648; - // 创建ArkTS中的int64数字 - napi_value result = nullptr; - napi_status status = napi_create_int64(env, value, &result); - if (status != napi_ok) { - // 处理错误 - napi_throw_error(env, nullptr, "Failed to create int64 value"); - } - return result; -} -// [End napi_create_int64] - -// [Start napi_create_double] -// napi_create_double -static napi_value CreateDouble(napi_env env, napi_callback_info info) -{ - double value = 1.234; - // 创建ArkTS中的double数字 - napi_value result = nullptr; - napi_status status = napi_create_double(env, value, &result); - if (status != napi_ok) { - // 处理错误 - napi_throw_error(env, nullptr, "Failed to create double value"); - } - return result; -} -// [End napi_create_double] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"getValueUint32", nullptr, GetValueUint32, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getValueInt32", nullptr, GetValueInt32, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getValueInt64", nullptr, GetValueInt64, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getDouble", nullptr, GetDouble, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createInt32", nullptr, CreateInt32, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createUInt32", nullptr, CreateUInt32, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createInt64", nullptr, CreateInt64, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createDouble", nullptr, CreateDouble, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 1901dd8f17..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_get_value_uint32_api] -export const getValueUint32: (data: T) => number | void; // napi_get_value_uint32 -// [End napi_get_value_uint32_api] - -// [Start napi_get_value_int32_api] -export const getValueInt32: (value: number | string) => number | void; // napi_get_value_int32 -// [End napi_get_value_int32_api] - -// [Start napi_get_value_int64_api] -export const getValueInt64: (value: number | string) => number | void; // napi_get_value_int64 -// [End napi_get_value_int64_api] - -// [Start napi_get_value_double_api] -export const getDouble: (value: number | string) => number | void; // napi_get_value_double -// [End napi_get_value_double_api] - -// [Start napi_create_int32_api] -export const createInt32: () => number; // napi_create_int32 -// [End napi_create_int32_api] - -// [Start napi_create_uint32_api] -export const createUInt32: () => number; // napi_create_uint32 -// [End napi_create_uint32_api] - -// [Start napi_create_int64_api] -export const createInt64: () => number; // napi_create_int64 -// [End napi_create_int64_api] - -// [Start napi_create_double_api] -export const createDouble: () => number; // napi_create_double -// [End napi_create_double_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 20023e52c9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiGetValueUint32', - '2.napiGetValueInt32', - '3.napiGetValueInt64', - '4.napiGetValueDouble', - '5.napiCreateInt32', - '6.napiCreateUint32', - '7.napiCreateInt64', - '8.napiCreateDouble' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(25) - .fontWeight(FontWeight.Bold) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiGetValueUint32') { - // [Start ark_napi_get_value_uint32] - // napi_get_value_uint32 - let value = testNapi.getValueUint32(111111111111); - let data = testNapi.getValueUint32("sssss"); - hilog.info(0x0000, 'Node-API', 'get_value_uint32_number %{public}d', value); - // 传入非数字"sssss"时函数返回undefined - hilog.info(0x0000, 'Node-API', 'get_value_uint32_number %{public}s', data); - // 传入uint32范围内的数字100时函数返回原数字 - hilog.info(0x0000, 'Node-API', 'get_value_uint32_number %{public}d', - testNapi.getValueUint32(100)); - // [End ark_napi_get_value_uint32] - this.result = 'napiGetValueUint32Success'; - } else if (item === '2.napiGetValueInt32') { - // [Start ark_napi_get_value_int32] - // napi_get_value_int32 - // 传入非数字“ss”时函数返回undefined - hilog.info(0x0000, 'Node-API', 'get_value_int32_not_number %{public}s', testNapi.getValueInt32('ss')); - // 传入int32范围内的数字100时函数返回原数字 - hilog.info(0x0000, 'Node-API', 'get_value_int32_number %{public}d', testNapi.getValueInt32(100)); - // 传入68719476735,此数字的二进制为111111111111111111111111111111111111,在int32类型中此二进制代表数字-1 - hilog.info(0x0000, 'Node-API', 'get_value_int32_oversize %{public}d', - testNapi.getValueInt32(68719476735)); - // 大于2的31次-1的数字且不是二进制为111111111111111111111111111111111111这样的在int32中有特殊含义的数字也会溢出,导致数值发生改变,返回值按后32位二进制编码解码 - hilog.info(0x0000, 'Node-API', 'get_value_int32_oversize %{public}d', - testNapi.getValueInt32(687194767355)); - // 传入NAN(not a number)、+Infinity(正无穷)或-Infinity(负无穷),会返回数字0 - hilog.info(0x0000, 'Node-API', 'get_value_int32_number_NAN %{public}d', testNapi.getValueInt32(NaN)); - hilog.info(0x0000, 'Node-API', 'get_value_int32_number_+Infinity %{public}d', - testNapi.getValueInt32(+Infinity)); - hilog.info(0x0000, 'Node-API', 'get_value_int32_number_-Infinity %{public}d', - testNapi.getValueInt32(-Infinity)); - // [End ark_napi_get_value_int32] - this.result = 'napiGetValueInt32Success'; - } else if (item === '3.napiGetValueInt64') { - // [Start ark_napi_get_value_int64] - // napi_get_value_int64 - // 输入不超过int64表示范围的数字,会返回该数字 - hilog.info(0x0000, 'Node-API', 'get_value_int64_number %{public}d', testNapi.getValueInt64(80)); - // 传入非数字“ss”,获得函数返回的值应为undefined - hilog.info(0x0000, 'Node-API', 'get_value_int64_not_number %{public}s', - testNapi.getValueInt64('sAs')); - // 输入超过int64表示范围的数字会溢出,失去精度,导致输入数字与返回数字不相等 - hilog.info(0x0000, 'Node-API', 'get_value_int64_number_oversize %{public}d', - testNapi.getValueInt64(9223372036854775809)); - // 传入NAN(not a number)、+Infinity(正无穷)或-Infinity(负无穷)接口返回数字0 - hilog.info(0x0000, 'Node-API', 'get_value_int64_number_NAN %{public}d', testNapi.getValueInt64(NaN)); - hilog.info(0x0000, 'Node-API', 'get_value_int64_number_+Infinity %{public}d', - testNapi.getValueInt64(+Infinity)); - hilog.info(0x0000, 'Node-API', 'get_value_int64_number_-Infinity %{public}d', - testNapi.getValueInt64(-Infinity)); - // [End ark_napi_get_value_int64] - this.result = 'napiGetValueInt64Success'; - } else if (item === '4.napiGetValueDouble') { - // [Start ark_napi_get_value_double] - // napi_get_value_double - // 输入数字,返回该数字 - hilog.info(0x0000, 'Node-API', 'get_value_double_number %{public}d', testNapi.getDouble(80.885)); - // 传入非数字,获得函数返回的值应为undefined - hilog.info(0x0000, 'Node-API', 'get_value_double_not_number %{public}s', testNapi.getDouble('sAs')); - // [End ark_napi_get_value_double] - this.result = 'napiGetValueDoubleSuccess'; - } else if (item === '5.napiCreateInt32') { - // [Start ark_napi_create_int32] - // napi_create_int32 - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_int32:' + testNapi.createInt32()); - // [End ark_napi_create_int32] - this.result = 'napiCreateInt32Success'; - } else if (item === '6.napiCreateUint32') { - // [Start ark_napi_create_uint32] - // napi_create_uint32 - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_uint32: ' + testNapi.createUInt32()); - // [End ark_napi_create_uint32] - this.result = 'napiCreateUint32Success'; - } else if (item === '7.napiCreateInt64') { - // [Start ark_napi_create_int64] - // napi_create_int64 - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_int64: ' + testNapi.createInt64()); - // [End ark_napi_create_int64] - this.result = 'napiCreateInt64Success'; - } else if (item === '8.napiCreateDouble') { - // [Start ark_napi_create_double] - // napi_create_double - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_double: ' + testNapi.createDouble()); - // [End ark_napi_create_double] - this.result = 'napiCreateDoubleSuccess'; - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - } - .width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/ohosTest.md deleted file mode 100755 index 3adc3c6a07..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBasicDataTypes/ohosTest.md +++ /dev/null @@ -1,15 +0,0 @@ -# 使用Node-API进行basic_data_types相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ----------------------------------------- | ------------ | ---------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口getValueUint32 | 位于主页 | 点击文本为1.napiGetValueUint32的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueUint32Success | Pass | -| ArkTS端成功调用native侧接口getValueInt32 | 位于主页 | 点击文本为2.napiGetValueInt32的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueInt32Success | Pass | -| ArkTS端成功调用native侧接口getValueInt64 | 位于主页 | 点击文本为3.napiGetValueInt64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueInt64Success | Pass | -| ArkTS端成功调用native侧接口getDouble | 位于主页 | 点击文本为4.napiGetValueDouble的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueDoubleSuccess | Pass | -| ArkTS端成功调用native侧接口createInt32 | 位于主页 | 点击文本为5.napiCreateInt32的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateInt32Success | Pass | -| ArkTS端成功调用native侧接口createUInt32 | 位于主页 | 点击文本为6.napiCreateUint32的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateUint32Success | Pass | -| ArkTS端成功调用native侧接口createInt64 | 位于主页 | 点击文本为7.napiCreateInt64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateInt64Success | Pass | -| ArkTS端成功调用native侧接口createDouble | 位于主页 | 点击文本为8.napiCreateDouble的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateDoubleSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/app.json5 deleted file mode 100755 index eee9280a08..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapibigint", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/element/string.json deleted file mode 100755 index 104c905573..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIBigint" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/README.md deleted file mode 100755 index 9d5ca28925..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# ArkTS使用Node-API进行bigint相关开发 - -### 介绍 - -BigInt是ArkTS中用于表示任意精度整数的数据类型,它能够处理比Number类型更大范围的整数值。通过Node-API提供的接口,可以在Node-API模块中创建、获取和操作BigInt类型值,从而实现与BigInt相关的功能扩展。 - -该工程主要展示使用Node-API创建中展示使用int64、uint64类型和给定字节数的uint64创建BigInt对象等场景。其中代码详细描述可查如下链接。 - -- [使用Node-API进行bigint相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-bigint.md) - -### 效果预览 - -| 执行结果图 | | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIBigint.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行bigint相关开发 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIBigint.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 9b135d06f6..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIBigint) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 0dc16e8beb..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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 "hilog/log.h" - -// [Start napi_create_bigint_int64] -// napi_create_bigint_int64 -static napi_value CreateBigintInt64t(napi_env env, napi_callback_info info) -{ - // 声明int64_t的变量value - int64_t value = -5555555555555555555; - // 将value转化为napi_value类型返回 - napi_value returnValue = nullptr; - napi_create_bigint_int64(env, value, &returnValue); - return returnValue; -} -// [End napi_create_bigint_int64] - -// [Start napi_create_bigint_uint64] -// napi_create_bigint_uint64 -static napi_value CreateBigintUint64t(napi_env env, napi_callback_info info) -{ - // 声明uint64_t的变量value - uint64_t value = 5555555555555555555; - // 将value转化为napi_value类型返回 - napi_value returnValue = nullptr; - napi_create_bigint_uint64(env, value, &returnValue); - return returnValue; -} -// [End napi_create_bigint_uint64] - -// [Start napi_create_bigint_words] -// napi_create_bigint_words -static napi_value CreateBigintWords(napi_env env, napi_callback_info info) -{ - // 使用napi_create_bigint_words接口创建一个BigInt对象 - int signBit = 0; - size_t wordCount = 3; - uint64_t words[] = {12ULL, 34ULL, 56ULL}; - napi_value returnValue = nullptr; - napi_status status = napi_create_bigint_words(env, signBit, wordCount, words, &returnValue); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_create_bigint_words fail"); - return nullptr; - } - return returnValue; -} -// [End napi_create_bigint_words] - -// [Start napi_get_value_bigint_int64] -// napi_get_value_bigint_int64 -static napi_value GetValueBigintInt64t(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 从传入的参数中提取64位整数的BigInt数据 - int64_t value = 0; - bool lossLess = false; - napi_status status = napi_get_value_bigint_int64(env, args[0], &value, &lossLess); - // 判断从ArkTS侧获取bigint是否为无损转换,如果不是抛出异常 - if (!lossLess) { - napi_throw_error(env, nullptr, "BigInt values have not been lossless converted"); - return nullptr; - } - // 如果接口调用成功正常调用则返回true给ArkTS侧 - napi_value returnValue = nullptr; - napi_get_boolean(env, status == napi_ok, &returnValue); - return returnValue; -} -// [End napi_get_value_bigint_int64] - -// [Start napi_get_value_bigint_uint64] -// napi_get_value_bigint_uint64 -static napi_value GetValueBigintUint64t(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 从参数值中获取BigInt的数值 - uint64_t value = 0; - bool lossLess = false; - napi_status status = napi_get_value_bigint_uint64(env, args[0], &value, &lossLess); - // 判断从ArkTS侧获取bigint是否为无损转换,如果不是抛出异常 - if (!lossLess) { - napi_throw_error(env, nullptr, "BigInt values have no lossless converted"); - return nullptr; - } - // 如果接口调用成功正常调用则返回true给ArkTS侧 - napi_value returnValue = nullptr; - napi_get_boolean(env, status == napi_ok, &returnValue); - return returnValue; -} -// [End napi_get_value_bigint_uint64] - -// [Start napi_get_value_bigint_words] -// napi_get_value_bigint_words -static napi_value GetValueBigintWords(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - int signBit = 0; - size_t wordCount = 0; - uint64_t words = 0; - // 调用napi_get_value_bigint_words接口获取wordCount - napi_status status = napi_get_value_bigint_words(env, args[0], nullptr, &wordCount, nullptr); - OH_LOG_INFO(LOG_APP, "Node-API , wordCount:%{public}d.", wordCount); - // 调用napi_get_value_bigint_words接口获取传入bigInt相关信息,如:signBit传入bigInt正负信息 - status = napi_get_value_bigint_words(env, args[0], &signBit, &wordCount, &words); - OH_LOG_INFO(LOG_APP, "Node-API , signBit: %{public}d.", signBit); - if (status != napi_ok) { - OH_LOG_ERROR(LOG_APP, "Node-API , reason:%{public}d.", status); - napi_throw_error(env, nullptr, "napi_get_date_value fail"); - return nullptr; - } - // 将符号位转化为int类型传出去 - napi_value returnValue = nullptr; - napi_create_int32(env, signBit, &returnValue); - return returnValue; -} -// [End napi_get_value_bigint_words] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"createBigintInt64t", nullptr, CreateBigintInt64t, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createBigintUint64t", nullptr, CreateBigintUint64t, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createBigintWords", nullptr, CreateBigintWords, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getValueBigintInt64t", nullptr, GetValueBigintInt64t, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getValueBigintUint64t", nullptr, GetValueBigintUint64t, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getValueBigintWords", nullptr, GetValueBigintWords, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 9a160cff4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_create_bigint_int64_api] -export const createBigintInt64t: () => bigint; // napi_create_bigint_int64 -// [End napi_create_bigint_int64_api] - -// [Start napi_create_bigint_uint64_api] -export const createBigintUint64t: () => bigint; // napi_create_bigint_uint64 -// [End napi_create_bigint_uint64_api] - -// [Start napi_create_bigint_words_api] -export const createBigintWords: () => bigint | void; // napi_create_bigint_words -// [End napi_create_bigint_words_api] - -// [Start napi_get_value_bigint_int64_api] -export const getValueBigintInt64t: (bigInt64: bigint) => boolean | void; // napi_get_value_bigint_int64 -// [End napi_get_value_bigint_int64_api] - -// [Start napi_get_value_bigint_uint64_api] -export const getValueBigintUint64t: (bigUint64: bigint) => boolean | void; // napi_get_value_bigint_uint64 -// [End napi_get_value_bigint_uint64_api] - -// [Start napi_get_value_bigint_words_api] -export const getValueBigintWords: (bigIntWords: bigint) => bigint | void; // napi_get_value_bigint_words -// [End napi_get_value_bigint_words_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 2da3dcf00c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiCreateBigintInt64', - '2.napiCreateBigintUint64', - '3.napiCreateBigintWords', - '4.napiGetValueBigintInt64', - '5.napiGetValueBigintUint64', - '6.napiGetValueBigintWords' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(22) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiCreateBigintInt64') { - // [Start ark_napi_create_bigint_int64] - // napi_create_bigint_int64 - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_bigint_int64: %{public}d', - testNapi.createBigintInt64t()); - // [End ark_napi_create_bigint_int64] - this.result = 'napiCreateBigintInt64Success'; - } else if (item === '2.napiCreateBigintUint64') { - // [Start ark_napi_create_bigint_uint64] - // napi_create_bigint_uint64 - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_bigint_uint64: %{public}d', - testNapi.createBigintUint64t()); - // [End ark_napi_create_bigint_uint64] - this.result = 'napiCreateBigintUint64Success'; - } else if (item === '3.napiCreateBigintWords') { - // [Start ark_napi_create_bigint_words] - // napi_create_bigint_words - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_bigint_words: %{public}d', - testNapi.createBigintWords()); - // [StartExclude ark_napi_create_bigint_words] - this.result = 'napiCreateBigintWordsSuccess'; - // [EndExclude ark_napi_create_bigint_words] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API NapiGetValueBigint: %{public}s', error.message); - // [StartExclude ark_napi_create_bigint_words] - this.result = 'napiCreateBigintWordsFail'; - // [EndExclude ark_napi_create_bigint_words] - } - // [End ark_napi_create_bigint_words] - } else if (item === '4.napiGetValueBigintInt64') { - // [Start ark_napi_get_value_bigint_int64] - // napi_get_value_bigint_int64 - let bigInt = BigInt(-5555555555555555); - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_int64: %{public}s', - JSON.stringify(testNapi.getValueBigintInt64t(bigInt))); - // [StartExclude ark_napi_get_value_bigint_int64] - this.result = 'napiGetValueBigintInt64Success'; - // [EndExclude ark_napi_get_value_bigint_int64] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API NapiGetValueBigint: %{public}s', error.message); - // [StartExclude ark_napi_get_value_bigint_int64] - this.result = 'napiGetValueBigintInt64Fail'; - // [EndExclude ark_napi_get_value_bigint_int64] - } - // [End ark_napi_get_value_bigint_int64] - } else if (item === '5.napiGetValueBigintUint64') { - // [Start ark_napi_get_value_bigint_uint64] - // napi_get_value_bigint_uint64 - let bigUint = BigInt(5555555555555555); - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_uint64: %{public}s', - JSON.stringify(testNapi.getValueBigintUint64t(bigUint))); - // [StartExclude ark_napi_get_value_bigint_uint64] - this.result = 'napiGetValueBigintUint64Success'; - // [EndExclude ark_napi_get_value_bigint_uint64] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API NapiGetValueBigint: %{public}s', error.message); - // [StartExclude ark_napi_get_value_bigint_uint64] - this.result = 'napiGetValueBigintUint64Fail'; - // [EndExclude ark_napi_get_value_bigint_uint64] - } - // [End ark_napi_get_value_bigint_uint64] - } else if (item === '6.napiGetValueBigintWords') { - // [Start ark_napi_get_value_bigint_words] - // napi_get_value_bigint_words - let bigInt = BigInt(-5555555555555555); - let bigUint = BigInt(5555555555555555); - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_words signBit is: %{public}d', - testNapi.getValueBigintWords(bigInt)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_words signBit is: %{public}d', - testNapi.getValueBigintWords(bigUint)); - // [StartExclude ark_napi_get_value_bigint_words] - this.result = 'napiGetValueBigintWordsSuccess'; - // [EndExclude ark_napi_get_value_bigint_words] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API NapiGetValueBigint: %{public}s', error.message); - // [StartExclude ark_napi_get_value_bigint_words] - this.result = 'napiGetValueBigintWordsFail'; - // [EndExclude ark_napi_get_value_bigint_words] - } - // [End ark_napi_get_value_bigint_words] - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/ohosTest.md deleted file mode 100755 index b1dd34f4cf..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBigint/ohosTest.md +++ /dev/null @@ -1,13 +0,0 @@ -# 使用Node-API进行bigInt相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------ | ------------ | ---------------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口createBigintInt64t | 位于主页 | 点击文本为1.napiCreateBigintInt64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateBigintInt64Success | Pass | -| ArkTS端成功调用native侧接口createBigintUint64t | 位于主页 | 点击文本为2.napiCreateBigintUint64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateBigintUint64Success | Pass | -| ArkTS端成功调用native侧接口createBigintWords | 位于主页 | 点击文本为3.napiCreateBigintWords的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateBigintWordsSuccess | Pass | -| ArkTS端成功调用native侧接口getValueBigintInt64t | 位于主页 | 点击文本为4.napiGetValueBigintInt64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueBigintInt64Success | Pass | -| ArkTS端成功调用native侧接口getValueBigintUint64t | 位于主页 | 点击文本为5.napiGetValueBigintUint64的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueBigintUint64Success | Pass | -| ArkTS端成功调用native侧接口getValueBigintWords | 位于主页 | 点击文本为6.napiGetValueBigintWords的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueBigintWordsSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/app.json5 deleted file mode 100755 index 010dd71fa4..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapibuffer", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/element/string.json deleted file mode 100755 index 501ac3971c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIBuffer" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/README.md deleted file mode 100755 index 8e7882c890..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# ArkTS使用Node-API进行buffer相关开发 - -### 介绍 - -在ArkTS中,Buffer是一种用于处理二进制数据的数据类型,使用Node-API接口进行buffer相关开发时,使用Buffer对象与ArkTS代码之间进行二进制数据的有效交互,以便在Node-API模块创建、操纵和传递Buffer对象到ArkTS,从而处理和传递二进制数据,比如文件I/O、网络传输等。 - -该工程主要展示了使用Node-API进行创建指定大小ArkTS Buffer、创建并获取指定大小ArkTS Buffer、判断给定value是否为Buffer对象等功能场景,其中代码详细描述可查如下链接。 - -- [使用Node-API进行buffer相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-buffer.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIBuffer.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API接口进行array相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIBuffer.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 428a5b0714..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIBuffer) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 34ae2cfb87..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 -#include "hilog/log.h" -#include "napi/native_api.h" - -static constexpr int INT_ARG_5 = 5; // 入参索引 - -// napi_create_buffer -static napi_value CreateBuffer(napi_env env, napi_callback_info info) -{ - std::string str("CreateBuffer"); - void *bufferPtr = nullptr; - size_t bufferSize = str.size(); - napi_value buffer = nullptr; - // 调用napi_create_buffer接口创建并获取一个指定大小的ArkTS Buffer - napi_create_buffer(env, bufferSize, &bufferPtr, &buffer); - // 将字符串str的值复制到buffer的内存中 - strcpy((char *)bufferPtr, str.data()); - return buffer; -} - -// napi_create_buffer_copy -static napi_value CreateBufferCopy(napi_env env, napi_callback_info info) -{ - // 要copy的内容 - std::string str("CreateBufferCopy"); - napi_value buffer = nullptr; - // 调用napi_create_buffer_copy接口创建buffer并将str的内容copy到buffer - void *resultData = nullptr; - napi_create_buffer_copy(env, str.size(), str.data(), &resultData, &buffer); - OH_LOG_INFO(LOG_APP, "Node-API resultData is : %{public}s.", resultData); - return buffer; -} - -// 回调函数,用于释放内存 -void FinalizeCallback(napi_env env, void *data, void *hint) -{ - if (data == nullptr) { - return; - } - free(data); - data = nullptr; -} - -// napi_create_external_buffer -static napi_value CreateExternalBuffer(napi_env env, napi_callback_info info) -{ - // 创建一个字符串 - std::string str("CreateExternalBuffer"); - // 在堆上分配内存,大小为字符串的长度 - void *data = malloc(str.size()); - // 将字符串复制到分配的内存中 - strcpy(static_cast(data), str.data()); - // 使用napi_create_external_buffer接口创建并获取一个指定大小buffer - napi_value buffer = nullptr; - napi_create_external_buffer(env, str.size(), data, FinalizeCallback, nullptr, &buffer); - return buffer; -} - -// napi_get_buffer_info -static napi_value GetBufferInfo(napi_env env, napi_callback_info info) -{ - // 创建一个字符串 - std::string str("GetBufferInfo"); - napi_value buffer = nullptr; - void *bufferPtr = nullptr; - size_t bufferSize = str.size(); - napi_create_buffer(env, bufferSize, &bufferPtr, &buffer); - strcpy((char *)bufferPtr, str.data()); - - // 获取Buffer的信息 - void *tmpBufferPtr = nullptr; - size_t bufferLength = 0; - napi_get_buffer_info(env, buffer, &tmpBufferPtr, &bufferLength); - - // 创建一个新的ArkTS字符串来保存Buffer的内容并返出去 - napi_value returnValue = nullptr; - napi_create_string_utf8(env, (char *)tmpBufferPtr, bufferLength, &returnValue); - return returnValue; -} - -// napi_is_buffer -static napi_value IsBuffer(napi_env env, napi_callback_info info) -{ - // 创建一个Buffer对象 - std::string str = "buffer"; - napi_value buffer = nullptr; - napi_create_buffer(env, strlen(str.data()), (void **)(str.data()), &buffer); - - // 调用napi_is_buffer接口判断创建的对象是否为buffer - bool result = false; - napi_is_buffer(env, buffer, &result); - // 将结果返回出去 - napi_value returnValue = nullptr; - napi_get_boolean(env, result, &returnValue); - return returnValue; -} - -typedef struct { - uint8_t *data; - size_t length; -} BufferData; - -void FinalizeCallback1(napi_env env, void *finalizeData, void *finalizeHint) -{ - // 获取终结时的数据 - BufferData *bufferData = static_cast(finalizeData); - - // 执行清理操作,比如释放资源 - delete[] bufferData->data; - delete bufferData; -} - -// napi_create_external_arraybuffer -napi_value CreateExternalArraybuffer(napi_env env, napi_callback_info info) -{ - // 创建一个有五个元素的C++数组 - uint8_t *dataArray = new uint8_t[5]{1, 2, 3, 4, 5}; - napi_value externalBuffer = nullptr; - BufferData *bufferData = new BufferData{dataArray, 5}; - - // 使用napi_create_external_arraybuffer创建一个外部Array Buffer对象,并指定终结回调函数 - napi_status status = - napi_create_external_arraybuffer(env, dataArray, 5, FinalizeCallback1, bufferData, &externalBuffer); - if (status != napi_ok) { - // 处理错误 - napi_throw_error(env, nullptr, "Node-API napi_create_external_arraybuffer fail"); - return nullptr; - } - napi_value outputArray; - // 使用napi_create_typedarray创建一个Array对象,并将externalBuffer对象作为参数传入 - status = napi_create_typedarray(env, napi_int8_array, INT_ARG_5, externalBuffer, 0, &outputArray); - if (status != napi_ok) { - // 处理错误 - napi_throw_error(env, nullptr, "Node-API napi_create_typedarray fail"); - return nullptr; - } - return outputArray; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"createBuffer", nullptr, CreateBuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createBufferCopy", nullptr, CreateBufferCopy, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createExternalBuffer", nullptr, CreateExternalBuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getBufferInfo", nullptr, GetBufferInfo, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"isBuffer", nullptr, IsBuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createExternalArraybuffer", nullptr, CreateExternalArraybuffer, nullptr, nullptr, nullptr, napi_default, - nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index e7e49a6976..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 createBuffer: () => string; // napi_create_buffer - -export const createBufferCopy: () => string; // napi_create_buffer_copy - -export const createExternalBuffer: () => string; // napi_create_external_buffer - -export const getBufferInfo: () => string; // napi_get_buffer_info - -export const isBuffer: () => boolean; // napi_is_buffer - -export const createExternalArraybuffer: () => ArrayBuffer | void; // napi_create_external_arraybuffer \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 9841b4ca2a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiCreateBuffer', - '2.napiCreateBufferCopy', - '3.napiCreateExternalBuffer', - '4.napiGetBufferInfo', - '5.napiIsBuffer', - '6.napiCreateExternalArraybuffer' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(20) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiCreateBuffer') { - // napi_create_buffer - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_buffer: %{public}s', - testNapi.createBuffer().toString()); - this.result = 'napiCreateBufferSuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_buffer error'); - this.result = 'napiCreateBufferFail'; - } - } else if (item === '2.napiCreateBufferCopy') { - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_buffer_copy: %{public}s', - testNapi.createBufferCopy().toString()); - this.result = 'napiCreateBufferCopySuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_buffer_copy error'); - this.result = 'napiCreateBufferCopyFail'; - } - } else if (item === '3.napiCreateExternalBuffer') { - // napi_create_external_buffer - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_external_buffer: %{public}s', - testNapi.createExternalBuffer() - .toString()); - this.result = 'napiCreateExternalBufferSuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_external_buffer error'); - this.result = 'napiCreateExternalBufferFail'; - } - } else if (item === '4.napiGetBufferInfo') { - // napi_get_buffer_info - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_buffer_info: %{public}s', - testNapi.getBufferInfo().toString()); - this.result = 'napiGetBufferInfoSuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_get_buffer_info error'); - this.result = 'napiGetBufferInfoFail'; - } - } else if (item === '5.napiIsBuffer') { - // napi_is_buffer - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_buffer: %{public}s', - JSON.stringify(testNapi.isBuffer())); - this.result = 'napiIsBufferSuccess'; - } catch (error) { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_buffer error'); - this.result = 'napiIsBufferFail'; - } - } else if (item === '6.napiCreateExternalArraybuffer') { - // napi_create_external_arraybuffer - hilog.info(0x0000, 'testTag', 'Node-API createExternalArraybuffer: %{public}s', - JSON.stringify(testNapi.createExternalArraybuffer())); - this.result = 'napiCreateExternalArraybufferSuccess'; - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - } - .width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/ohosTest.md deleted file mode 100755 index 3d51411013..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIBuffer/ohosTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# 使用Node-API进行buffer相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ---------------------------------------------------- | ------------ | --------------------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口createBuffer | 位于主页 | 点击文本为1.napiCreateBuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateBufferSuccess | Pass | -| ArkTS端成功调用native侧接口createExternalBuffer | 位于主页 | 点击文本为2.napiCreateExternalBuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateExternalBufferSuccess | Pass | -| ArkTS端成功调用native侧接口getBufferInfo | 位于主页 | 点击文本为3.napiGetBufferInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetBufferInfoSuccess | Pass | -| ArkTS端成功调用native侧接口isBuffer | 位于主页 | 点击文本为4.napiIsBuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsBufferSuccess | Pass | -| ArkTS端成功调用native侧接口createExternalArraybuffer | 位于主页 | 点击文本为5.napiCreateExternalArraybuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateExternalArraybufferSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/app.json5 deleted file mode 100755 index f13a0fe4e9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiclass", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/element/string.json deleted file mode 100755 index cfcf2c9cd8..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIClass" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/README.md deleted file mode 100755 index 862d45ca29..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行class相关开发 - -### 介绍 - -该工程主要展示了使用Node-API接口进行class相关开发,处理ArkTS中的类,例如定义类、构造实例等,其中代码详细描述可查如下链接。 - -- [使用Node-API进行class相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-class.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIClass.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行class相关开发 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIClass.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 53c0232351..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIClass) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 22f52d776f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 -#include -#include "napi/native_api.h" - -static constexpr int INT_ARG_18 = 18; // 入参索引 - -// [Start napi_new_instance] -// napi_new_instance -static napi_value NewInstance(napi_env env, napi_callback_info info) -{ - // 传入并解析参数,第一个参数为传入的构造函数,第二个参数为需要传入构造函数的参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 调用napi_new_instance接口,实例化一个对象,将这个对象返回 - napi_value result = nullptr; - napi_new_instance(env, args[0], 1, &args[1], &result); - return result; -} -// [End napi_new_instance] - -// [Start napi_wrap_unwrap_remove_wrap] -struct Object { - std::string name; - int32_t age; -}; - -static void DerefItem(napi_env env, void *data, void *hint) -{ - // 可选的原生回调,用于在ArkTS对象被垃圾回收时释放原生实例 - OH_LOG_INFO(LOG_APP, "Node-API DerefItem"); - (void)hint; -} - -// napi_wrap -static napi_value Wrap(napi_env env, napi_callback_info info) -{ - OH_LOG_INFO(LOG_APP, "Node-API wrap"); - // 初始化Node-API模块的object - struct Object *obj = new struct Object(); - obj->name = "lilei"; - obj->age = INT_ARG_18; - size_t argc = 1; - napi_value toWrap; - // 调用napi_wrap将Node-API模块的object绑定到ArkTS object上 - napi_get_cb_info(env, info, &argc, &toWrap, NULL, NULL); - napi_wrap(env, toWrap, reinterpret_cast(obj), DerefItem, NULL, NULL); - - return toWrap; -} - -// napi_remove_wrap -static napi_value RemoveWrap(napi_env env, napi_callback_info info) -{ - OH_LOG_INFO(LOG_APP, "Node-API removeWrap"); - size_t argc = 1; - napi_value wrapped = nullptr; - void *data = nullptr; - // 调用napi_remove_wrap从一个被包装的对象中解除包装 - napi_get_cb_info(env, info, &argc, &wrapped, nullptr, nullptr); - napi_remove_wrap(env, wrapped, &data); - - return nullptr; -} - -// napi_unwrap -static napi_value UnWrap(napi_env env, napi_callback_info info) -{ - OH_LOG_INFO(LOG_APP, "Node-API unWrap"); - size_t argc = 1; - napi_value wrapped = nullptr; - napi_get_cb_info(env, info, &argc, &wrapped, nullptr, nullptr); - // 调用napi_unwrap取出绑定在ArkTS object中的数据并打印 - struct Object *data; - napi_unwrap(env, wrapped, reinterpret_cast(&data)); - OH_LOG_INFO(LOG_APP, "Node-API name: %{public}s", data->name.c_str()); - OH_LOG_INFO(LOG_APP, "Node-API age: %{public}d", data->age); - return nullptr; -} -// [End napi_wrap_unwrap_remove_wrap] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"newInstance", nullptr, NewInstance, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"wrap", nullptr, Wrap, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"removeWrap", nullptr, RemoveWrap, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"unWrap", nullptr, UnWrap, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 9e0e5aa76d..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_new_instance_api] -export const newInstance: (obj: Object, param: string) => Object // napi_new_instance -// [End napi_new_instance_api] - -// [Start napi_wrap_unwrap_remove_wrap_api] -export const wrap: (obj: Object) => Object; // napi_wrap - -export const unWrap: (obj: Object) => void; // napi_unwrap - -export const removeWrap: (obj: Object) => void; // napi_remove_wrap -// [End napi_wrap_unwrap_remove_wrap_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index c3092dc54e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -// [Start ark_napi_new_instance] -class Fruit { - name: string; - - constructor(name: string) { - this.name = name; - } -} - -// [StartExclude ark_napi_new_instance] -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiNewInstance', - '2.napiRemoveWrap' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(25) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiNewInstance') { - // [EndExclude ark_napi_new_instance] - // napi_new_instance - // 调用函数,用变量obj接收函数返回的实例化对象 - let obj = testNapi.newInstance(Fruit, 'test'); - // 打印实例化对象obj的信息 - hilog.info(0x0000, 'Node-API', 'napi_new_instance %{public}s', JSON.stringify(obj)); - // [End ark_napi_new_instance] - this.result = 'napiNewInstanceSuccess'; - } else if (item === '2.napiRemoveWrap') { - // [Start ark_napi_wrap_unwrap_remove_wrap] - try { - class Obj { - } - - let obj: Obj = {}; - testNapi.wrap(obj) // napi_wrap - testNapi.unWrap(obj) // napi_unwrap - testNapi.removeWrap(obj) // napi_remove_wrap - // [StartExclude ark_napi_wrap_unwrap_remove_wrap] - this.result = 'napiRemoveWrapSuccess'; - // [EndExclude ark_napi_wrap_unwrap_remove_wrap] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API error: %{public}s', error.message); - // [StartExclude ark_napi_wrap_unwrap_remove_wrap] - this.result = 'napiRemoveWrapFail'; - // [EndExclude ark_napi_wrap_unwrap_remove_wrap] - } - // [End ark_napi_wrap_unwrap_remove_wrap] - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/ohosTest.md deleted file mode 100755 index 3342c2311d..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIClass/ohosTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# 使用Node-API进行class相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------- | ------------ | ------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口newInstance | 位于主页 | 点击文本为1.napiNewInstance的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiNewInstanceSuccess | Pass | -| ArkTS端成功调用native侧接口wrap,unWrap,removeWrap | 位于主页 | 点击文本为2.napiRemoveWrap的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiRemoveWrapSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/app.json5 deleted file mode 100755 index fcea5f34a3..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapicleanuphook", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/element/string.json deleted file mode 100755 index fd2b885854..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPICleanuphook" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/README.md deleted file mode 100755 index 82af9b29e4..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# ArkTS使用Node-API进行cleanuphook相关开发 - -### 介绍 - -使用Node-API接口在进程退出时处理未释放资源,在Node-API模块注册清理钩子,一旦当前环境退出,这些钩子就会运行,使所有资源都被正确释放。 - -本工程主要展示了使用Node-API注册钩子函数、取消钩子函数等场景,其中代码详细描述可查如下链接。 - -- [使用Node-API进行cleanuphook相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-cleanuphook.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPICleanuphook.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行cleanuphook相关开发 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPICleanuphook.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/build-profile.json5 deleted file mode 100755 index 63f7a6918b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/build-profile.json5 +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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" - ] - }, - "sourceOption": { - "workers": [ - "./src/main/ets/workers/worker.ts" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 796387181d..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPICleanuphook) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libuv.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 0d5588f21e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_remove_add_env_cleanup_hook] -#include -#include -#include -#include "napi/native_api.h" -#include "uv.h" - -// 定义内存结构,包含指向数据的指针和数据的大小 -typedef struct { - char *data; - size_t size; -} Memory; - -// 外部缓冲区清理回调函数,用于释放分配的内存 -void ExternalFinalize(napi_env env, void *finalizeData, void *finalizeHint) -{ - Memory *wrapper = (Memory *)finalizeHint; - // [StartExclude napi_remove_add_env_cleanup_hook] - if (wrapper == nullptr) { - //处理内存分配失败的情况 - return; - } - // [EndExclude napi_remove_add_env_cleanup_hook] - free(wrapper->data); - free(wrapper); - OH_LOG_INFO(LOG_APP, "Node-API napi_add_env_cleanup_hook ExternalFinalize"); -} - -// 在环境关闭时执行一些清理操作,如清理全局变量或其他需要在环境关闭时处理的资源 -static void Cleanup(void *arg) -{ - // 执行清理操作 - OH_LOG_INFO(LOG_APP, "Node-API napi_add_env_cleanup_hook cleanuped: %{public}d", *(int *)(arg)); -} - -// 创建外部缓冲区并注册环境清理钩子函数 -static napi_value NapiEnvCleanUpHook(napi_env env, napi_callback_info info) -{ - // 分配内存并复制字符串数据到内存中 - std::string str("Hello from Node-API!"); - Memory *wrapper = (Memory *)malloc(sizeof(Memory)); - // [StartExclude napi_remove_add_env_cleanup_hook] - if (wrapper == nullptr) { - //处理内存分配失败的情况 - return nullptr; - } - // [End napi_remove_add_env_cleanup_hook] - wrapper->data = static_cast(malloc(str.size())); - strcpy(wrapper->data, str.c_str()); - wrapper->size = str.size(); - // 创建外部缓冲区对象,并指定清理回调函数 - napi_value buffer = nullptr; - napi_create_external_buffer(env, wrapper->size, (void *)wrapper->data, ExternalFinalize, wrapper, &buffer); - // 静态变量作为钩子函数参数 - static int hookArg = 42; - static int hookParameter = 1; - // 注册环境清理钩子函数 - napi_status status = napi_add_env_cleanup_hook(env, Cleanup, &hookArg); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Test Node-API napi_add_env_cleanup_hook failed."); - return nullptr; - } - // 注册环境清理钩子函数,此处不移除环境清理钩子,为了在Java环境被销毁时,这个钩子函数被调用,用来模拟执行一些清理操作,例如释放资源、关闭文件等。 - status = napi_add_env_cleanup_hook(env, Cleanup, &hookParameter); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Test Node-API napi_add_env_cleanup_hook failed."); - return nullptr; - } - // 立即移除环境清理钩子函数,确保不会在后续环境清理时被调用 - // 通常,当为其添加此钩子的资源无论如何都被拆除时调用这个接口 - napi_remove_env_cleanup_hook(env, Cleanup, &hookArg); - // 返回创建的外部缓冲区对象 - return buffer; -} -// [End napi_remove_add_env_cleanup_hook] - -// [Start napi_add_remove_async_cleanup_hook] -typedef struct { - napi_env env; - void *testData; - uv_async_s asyncUv; - napi_async_cleanup_hook_handle cleanupHandle; -} AsyncContent; - -// 删除异步工作对象并注销钩子函数 -static void FinalizeWork(uv_handle_s *handle) -{ - AsyncContent *asyncData = reinterpret_cast(handle->data); - // 不再需要异步清理钩子函数的情况下,尝试将其从环境中移除 - napi_status result = napi_remove_async_cleanup_hook(asyncData->cleanupHandle); - if (result != napi_ok) { - napi_throw_error(asyncData->env, nullptr, "Test Node-API napi_remove_async_cleanup_hook failed"); - } - // 释放AsyncContent - free(asyncData); -} - -// 异步执行环境清理工作 -static void AsyncWork(uv_async_s *async) -{ - // 执行一些清理工作,比如释放动态分配的内存 - AsyncContent *asyncData = reinterpret_cast(async->data); - if (asyncData->testData != nullptr) { - free(asyncData->testData); - asyncData->testData = nullptr; - } - // 关闭libuv句柄,并触发FinalizeWork回调清理 - uv_close((uv_handle_s *)async, FinalizeWork); -} - -// 异步清理钩子函数,创建异步工作对象并执行 -static void AsyncCleanup(napi_async_cleanup_hook_handle handle, void *info) -{ - AsyncContent *data = reinterpret_cast(info); - // 获取libUv循环实例并初始化一个异步句柄,以便后续执行异步工作 - uv_loop_s *uvLoop; - napi_get_uv_event_loop(data->env, &uvLoop); - uv_async_init(uvLoop, &data->asyncUv, AsyncWork); - - data->asyncUv.data = data; - data->cleanupHandle = handle; - // 发送异步信号触发AsyncWork函数执行清理工作 - uv_async_send(&data->asyncUv); -} - -static napi_value NapiAsyncCleanUpHook(napi_env env, napi_callback_info info) -{ - // 分配AsyncContent内存 - AsyncContent *data = reinterpret_cast(malloc(sizeof(AsyncContent))); - // StartExclude napi_add_remove_async_cleanup_hook] - if (data == nullptr) { - //处理内存分配失败的情况 - return nullptr; - } - // [EndExclude napi_add_remove_async_cleanup_hook] - data->env = env; - data->cleanupHandle = nullptr; - // 分配内存并复制字符串数据 - const char *testDataStr = "TestNapiAsyncCleanUpHook"; - data->testData = strdup(testDataStr); - if (data->testData == nullptr) { - napi_throw_error(env, nullptr, "Test Node-API data->testData is nullptr"); - } - // 添加异步清理钩子函数 - napi_status status = napi_add_async_cleanup_hook(env, AsyncCleanup, data, &data->cleanupHandle); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Test Node-API napi_add_async_cleanup_hook failed"); - } - napi_value result = nullptr; - napi_get_boolean(env, true, &result); - return result; -} -// [End napi_add_remove_async_cleanup_hook] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"napiEnvCleanUpHook", nullptr, NapiEnvCleanUpHook, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiAsyncCleanUpHook", nullptr, NapiAsyncCleanUpHook, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index b48f7cfd46..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_remove_add_env_cleanup_hook_api] -export const napiEnvCleanUpHook: () => Object | void; -// [End napi_remove_add_env_cleanup_hook_api] - -// [Start napi_add_remove_async_cleanup_hook_api] -export const napiAsyncCleanUpHook: () => boolean | void; -// [End napi_add_remove_async_cleanup_hook_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 6b502b0256..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import worker from '@ohos.worker'; -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = ''; - private items: string[] = [ - 'Reset Result Message', - '1.napiRemoveEnvCleanupHook', - '2.napiRemoveAsyncCleanupHook' - ]; - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(20) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiRemoveEnvCleanupHook') { - // [Start connect_with_worker] - let wk = new worker.ThreadWorker('entry/ets/workers/worker.ts'); - // 发送消息到worker线程 - wk.postMessage('test NapiEnvCleanUpHook'); - // 处理来自worker线程的消息 - wk.onmessage = (message) => { - hilog.info(0x0000, 'testTag', 'Test Node-API message from worker: %{public}s', - JSON.stringify(message)); - wk.terminate(); - }; - // [End connect_with_worker] - this.result = 'napiRemoveEnvCleanupHookSuccess'; - } else if (item === '2.napiRemoveAsyncCleanupHook') { - // [Start ark_napi_remove_add_env_cleanup_hook] - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_add_async_cleanup_hook: %{public}s', - testNapi.napiAsyncCleanUpHook()); - // [StartExclude ark_napi_remove_add_env_cleanup_hook] - this.result = 'napiRemoveAsyncCleanupHookSuccess'; - // [EndExclude ark_napi_remove_add_env_cleanup_hook] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_add_async_cleanup_hook error.message: %{public}s', - error.message); - // [StartExclude ark_napi_remove_add_env_cleanup_hook] - this.result = 'napiRemoveAsyncCleanupHookFail'; - // [EndExclude ark_napi_remove_add_env_cleanup_hook] - } - // [End ark_napi_remove_add_env_cleanup_hook] - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - } - .width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/ohosTest.md deleted file mode 100755 index 48166fa83a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPICleanuphook/ohosTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# 使用Node-API进行cleanuphook相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ----------------------------------------------- | ------------ | ------------------------------------------------ | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口napiEnvCleanUpHook | 位于主页 | 点击文本为1.napiRemoveEnvCleanupHook的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiRemoveEnvCleanupHookSuccess | Pass | -| ArkTS端成功调用native侧接口napiAsyncCleanUpHook | 位于主页 | 点击文本为2.napiRemoveAsyncCleanupHook的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiRemoveAsyncCleanupHookSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/app.json5 deleted file mode 100755 index 2ca6010d56..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapidate", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/element/string.json deleted file mode 100755 index 022111c88c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIDate" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/README.md deleted file mode 100755 index ee3554ee0f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行Date相关开发 - -### 介绍 - -Node-API中date相关接口用于处理ArkTS Date对象,并在Node-API模块和ArkTS代码之间进行日期数据的转换和处理。这对于在Node-API模块中处理时间和日期相关逻辑非常有用,工程中展示的代码详细描述可查如下链接。 - -- [使用Node-API进行Date相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-date.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIDate.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行Date相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIDate.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 2da23c8ff4..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIDate) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index f4fc6dc492..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_create_date] -#include -#include "napi/native_api.h" - -// napi_create_date -static napi_value CreateDate(napi_env env, napi_callback_info info) -{ - // 获取传入的Unix Time Stamp时间 - double value = 1501924876711; - // 调用napi_create_date接口将double值转换成表示日期时间,并创建成一个ArkTS对象放入returnValue中 - napi_value returnValue = nullptr; - napi_create_date(env, value, &returnValue); - return returnValue; -} -// [End napi_create_date] - -// [Start napi_get_date_value] -// napi_get_date_value -static napi_value GetDateValue(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取传入的Unix Time Stamp时间 - double value = 0; - napi_status status = napi_get_date_value(env, args[0], &value); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_get_date_value fail"); - return nullptr; - } - - // 将获取到的Unix Time Stamp时间打印 - OH_LOG_INFO(LOG_APP, "Node-API gets unix time stamp is:%{public}lf.", value); - - // 把转换后的Unix Time Stamp时间创建成ArkTS double数值,并放入returnValue中 - napi_value returnValue = nullptr; - napi_create_double(env, value, &returnValue); - return returnValue; -} -// [End napi_get_date_value] - -// [Start napi_is_date] -// napi_is_date -static napi_value IsDate(napi_env env, napi_callback_info info) -{ - // 接受一个入参 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 调用napi_is_date接口判断给定入参是否为Date数据 - bool result = false; - napi_status status = napi_is_date(env, args[0], &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_is_date fail"); - return nullptr; - } - // 将结果转成napi_value类型返回 - napi_value returnValue = nullptr; - napi_get_boolean(env, result, &returnValue); - - return returnValue; -} -// [End napi_is_date] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"createDate", nullptr, CreateDate, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getDateValue", nullptr, GetDateValue, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"isDate", nullptr, IsDate, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8492f67328..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_create_date_api] -export const createDate: () => Date; // napi_create_date -// [End napi_create_date_api] - -// [Start napi_get_date_value_api] -export const getDateValue: (date: Date) => number | void; // napi_get_date_value -// [End napi_get_date_value_api] - -// [Start napi_is_date_api] -export const isDate: (date: T) => boolean | void; // napi_is_date -// [End napi_is_date_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index ef8032c365..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiCreateDate', - '2.napiGetDateValue', - '3.napiIsDate' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(25) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiCreateDate') { - // [Start ark_napi_create_date] - // napi_create_date - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_date: %{public}s', - testNapi.createDate().toString()); - // [End ark_napi_create_date] - this.result = 'napiCreateDateSuccess'; - } else if (item === '2.napiGetDateValue') { - // [Start ark_napi_get_date_value] - // napi_get_date_value - try { - const date = new Date(); - hilog.info(0x0000, 'testTag', 'Node-API: output the Unix Time Stamp: %{public}d', date.getTime()); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_date_value: %{public}d', - testNapi.getDateValue(date)); - // [StartExclude ark_napi_get_date_value] - this.result = 'napiGetDateValueSuccess'; - // [EndExclude ark_napi_get_date_value] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_get_date_value error: %{public}s', - error.message); - // [StartExclude ark_napi_get_date_value] - this.result = 'napiGetDateValueFail'; - // [EndExclude ark_napi_get_date_value] - } - // [End ark_napi_get_date_value] - } else if (item === '3.napiIsDate') { - // [Start ark_napi_is_date] - // napi_is_date - try { - let now: Date = new Date(); - let date = "123"; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_date: %{public}s', testNapi.isDate(now)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_date: %{public}s', testNapi.isDate(date)); - // [StartExclude ark_napi_is_date] - this.result = 'napiIsDateSuccess'; - // [EndExclude ark_napi_is_date] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_date error: %{public}s', error.message); - // [StartExclude ark_napi_is_date] - this.result = 'napiIsDateFail'; - // [EndExclude ark_napi_is_date] - } - // [End ark_napi_is_date] - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/ohosTest.md deleted file mode 100755 index e9f4a92c4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIDate/ohosTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# 使用Node-API进行date相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| --------------------------------------- | ------------ | -------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口createDate | 位于主页 | 点击文本为1.napiCreateDate的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateDateSuccess | Pass | -| ArkTS端成功调用native侧接口getDateValue | 位于主页 | 点击文本为2.napiGetDateValue的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetDateValueSuccess | Pass | -| ArkTS端成功调用native侧接口isDate | 位于主页 | 点击文本为3.napiIsDate的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsDateSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/app.json5 deleted file mode 100755 index 7db9917074..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapienvironmentallifecycle", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/element/string.json deleted file mode 100755 index ccd8c94a69..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIEnvironmentalLifeCycle" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/README.md deleted file mode 100755 index 1fbd6522e6..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行environmental-life-cycle相关开发 - -### 介绍 - -在Node-API模块中,可以使用Node-API接口将特定数据与当前的环境相关联,并在需要时检索该数据,本工程主要展示绑定和检索与当前运行环境相关联的数据项,其中代码详细描述可查如下链接。 - -- [使用Node-API进行environmental-life-cycle相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-environmental-life-cycle.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| :----------------------------------------------------------- | :----------------------------------------------------------- | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIEnvironmentalLifeCycle.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行environmental-life-cycle相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIEnvironmentalLifeCycle.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 9ebcc97b79..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIEnviornmentalLifeCycle) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 4edf62a527..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_set_instance_data] -#include -#include "napi/native_api.h" - -// 定义一个结构来存储实例数据 -struct InstanceData { - int32_t value; -}; - -// 对象被释放时的回调函数,用于清理实例数据 -void FinalizeCallback(napi_env env, void *finalizeData, void *finalizeHint) -{ - if (finalizeData) { - InstanceData *data = reinterpret_cast(finalizeData); - // 释放内存,清除指针指向地址 - delete (data); - *(InstanceData **)finalizeData = nullptr; - } -} - -// napi_set_instance_data -static napi_value SetInstanceData(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value argv[1]; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - int32_t instanceDataValue; - napi_get_value_int32(env, argv[0], &instanceDataValue); - InstanceData *instanceData = new InstanceData; - instanceData->value = instanceDataValue; - // 调用napi_set_instance_data将实例数据关联到Node-API环境,并指定FinalizeCallback函数 - napi_status status = napi_set_instance_data(env, instanceData, FinalizeCallback, nullptr); - bool success = true; - napi_value result; - if (status == napi_ok) { - napi_get_boolean(env, success, &result); - } - return result; -} -// [End napi_set_instance_data] - -// [Start napi_get_instance_data] -// napi_get_instance_data -static napi_value GetInstanceData(napi_env env, napi_callback_info info) -{ - InstanceData *resData = nullptr; - // napi_get_instance_data获取之前想关联的数据项 - napi_get_instance_data(env, (void **)&resData); - napi_value result; - napi_create_int32(env, resData->value, &result); - return result; -} -// [End napi_get_instance_data] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"setInstanceData", nullptr, SetInstanceData, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getInstanceData", nullptr, GetInstanceData, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 2ed5806689..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_set_instance_data_api] -export const setInstanceData: (data: number) => boolean; // napi_set_instance_data -// [End napi_set_instance_data_api] - -// [Start napi_get_instance_data_api] -export const getInstanceData: () => number; // napi_get_instance_data -// [End napi_get_instance_data_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 2d276e0e8d..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiSetInstanceData', - '2.napiGetInstanceData' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(22) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiSetInstanceData') { - // [Start ark_napi_set_instance_data] - // napi_set_instance_data - let data = 5; - let value = testNapi.setInstanceData(data); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_instance_data:%{public}s', value); - // [End ark_napi_set_instance_data] - this.result = 'napiSetInstanceDataSuccess'; - } else if (item === '2.napiGetInstanceData') { - // [Start ark_napi_get_instance_data] - // napi_get_instance_data - let data = 5; - testNapi.setInstanceData(data); - let value = testNapi.getInstanceData(); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_instance_data:%{public}d', value); - // [End ark_napi_get_instance_data] - this.result = 'napiGetInstanceDataSuccess'; - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/ohosTest.md deleted file mode 100755 index feebcef908..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIEnvironmentalLifeCycle/ohosTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# 使用Node-API进行environmental-life-cycle相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| --------------------------------------------- | ------------ | ----------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 setInstanceData | 位于主页 | 点击文本为1.napiSetInstanceData的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiSetInstanceDataSuccess | Pass | -| ArkTS端成功调用native侧接口getInstanceData | 位于主页 | 点击文本为2.napiGetInstanceData的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetInstanceDataSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/AppScope/app.json5 deleted file mode 100755 index ee9b5cbb6a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapierror", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/element/string.json deleted file mode 100755 index 70210c9807..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIError" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/README.md deleted file mode 100755 index 9f99e9c3c4..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行错误处理开发 - -### 介绍 - -使用Node-API接口进行错误处理开发,使得在Node-API模块中能够更好地管理和响应错误情况。通过合理使用这些函数,可以提高模块的稳定性和可靠性,本工程主要展示使用Node-API进行创建错误对象并抛出、获取错误对象、检查napi_value是否代表错误对象和抛出致命异常终止进程等场景,其中代码详细描述可查如下链接。 - -- [使用Node-API进行错误处理开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-error.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIError.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行错误处理开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIError.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 8531edd27c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIError) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index e589bfa657..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "napi/native_api.h" - -// [Start napi_get_last_error_info] -// napi_get_last_error_info -static napi_value GetLastErrorInfo(napi_env env, napi_callback_info info) -{ - // 获取输入参数(这里以字符串message作为参数传入) - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 将传入的字符串参数以napi_get_value_int32取出,主动制造错误 - int32_t value = 0; - napi_status status = napi_get_value_int32(env, args[0], &value); - // 接口使用错误,故返回值不为napi_ok - if (status != napi_ok) { - OH_LOG_INFO(LOG_APP, "napi_get_value_int32 return status, status is not equal to napi_ok."); - } - // 调用接口napi_get_last_error_info获取最后一次错误信息 - const napi_extended_error_info *errorInfo; - napi_get_last_error_info(env, &errorInfo); - // 取出错误码与接口调用错误后其返回值作比较 - if (errorInfo->error_code == status) { - OH_LOG_INFO(LOG_APP, "napi_get_last_error_info return errorInfo, error_code equal to status."); - } - // 取出错误消息作为返回值带出去打印 - napi_value result = nullptr; - napi_create_string_utf8(env, errorInfo->error_message, NAPI_AUTO_LENGTH, &result); - return result; -} -// [End napi_get_last_error_info] - -// [Start napi_create_type_error] -// napi_create_type_error -static napi_value CreatTypeError(napi_env env, napi_callback_info info) -{ - // 构造errorCode和errorMessage - napi_value errorCode = nullptr; - napi_create_string_utf8(env, "napi_create_error errorCode", NAPI_AUTO_LENGTH, &errorCode); - napi_value errorMessage = nullptr; - napi_create_string_utf8(env, "napi_create_error errorMessage", NAPI_AUTO_LENGTH, &errorMessage); - // 调用napi_create_type_error创建一个typeError错误对象 - napi_value error = nullptr; - napi_create_type_error(env, errorCode, errorMessage, &error); - return error; -} -// [End napi_create_type_error] - -// [Start napi_create_range_error] -// napi_create_range_error -static napi_value CreatRangeError(napi_env env, napi_callback_info info) -{ - // 构造errorCode和errorMessage - napi_value errorCode = nullptr; - napi_create_string_utf8(env, "napi_create_error errorCode", NAPI_AUTO_LENGTH, &errorCode); - napi_value errorMessage = nullptr; - napi_create_string_utf8(env, "napi_create_error errorMessage", NAPI_AUTO_LENGTH, &errorMessage); - // 调用napi_create_range_error创建一个typeError错误对象 - napi_value error = nullptr; - napi_create_range_error(env, errorCode, errorMessage, &error); - return error; -} -// [End napi_create_range_error] - -// [Start napi_create_error] -// napi_create_error and napi_throw -static napi_value NapiThrow(napi_env env, napi_callback_info info) -{ - // 代码中发生某些错误后,可执行以下操作抛出异常 - // 在Node-API环境中创建一个字符串,并将其存储在errorCode变量中 - napi_value errorCode = nullptr; - napi_create_string_utf8(env, "throw errorCode", NAPI_AUTO_LENGTH, &errorCode); - // 在Node-API环境中创建一个字符串,并将其存储在errorMessage变量中 - napi_value errorMessage = nullptr; - napi_create_string_utf8(env, "throw errorMessage", NAPI_AUTO_LENGTH, &errorMessage); - // 创建一个ArkTS对象error - napi_value error = nullptr; - napi_create_error(env, errorCode, errorMessage, &error); - // 通过napi_throw接口将对象抛出 - napi_throw(env, error); - return nullptr; -} -// [End napi_create_error] - -// [Start napi_throw_error] -// napi_throw_error -// 这里直接抛出一个带有errorMessage的错误 -static napi_value NapiThrowErrorMessage(napi_env env, napi_callback_info info) -{ - napi_throw_error(env, nullptr, "napi_throw_error throwing an error"); - return nullptr; -} - -// 传入两个参数,在第二个参数,也就是除数为0的时候抛出一个错误 -static napi_value NapiThrowError(napi_env env, napi_callback_info info) -{ - // ArkTS侧传入两个参数 - size_t argc = 2; - napi_value argv[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - // 将其转换为double类型的值作为被除数和除数 - double dividend; - double divisor; - napi_get_value_double(env, argv[0], ÷nd); - napi_get_value_double(env, argv[1], &divisor); - // 在这里判断除数如果为0则直接抛出一个错误,errorCode为:DIVIDE_BY_ZERO,errorMessage为:Cannot divide by zero - if (divisor == 0) { - napi_throw_error(env, "DIVIDE_BY_ZERO", "Cannot divide by zero"); - } - return nullptr; -} -// [End napi_throw_error] - -// [Start napi_throw_type_error] -// napi_throw_type_error -// 这里直接抛出一个带有errorMessage的TypeError -static napi_value ThrowTypeErrorMessage(napi_env env, napi_callback_info info) -{ - napi_throw_type_error(env, nullptr, "napi_throw_type_error throwing an error"); - return nullptr; -} - -// 传入一个类型不匹配的参数,判断类型不匹配之后抛出typeError -static napi_value ThrowTypeError(napi_env env, napi_callback_info info) -{ - // ArkTS侧传入一个参数 - size_t argc = 1; - napi_value argv[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - // 将传入参数转换为napi_valuetype类型的值 - napi_valuetype valueType; - napi_typeof(env, argv[0], &valueType); - // 如果传入参数不为napi_number类型的值则抛出TypeError - if (valueType != napi_number) { - // 这里抛出一个既带有errorCode也带有errorMessage的TypeError - napi_throw_type_error(env, "napi_throw_type_error", "Argument must be a number"); - } - return nullptr; -} -// [End napi_throw_type_error] - -// [Start napi_throw_range_error] -// napi_throw_range_error -// 这里直接抛出一个带有errorMessage的RangeError -static napi_value ThrowRangeErrorMessage(napi_env env, napi_callback_info info) -{ - napi_throw_range_error(env, nullptr, "napi_throw_range_error one"); - return nullptr; -} - -// 传入不匹配的参数个数,判断不匹配之后抛出rangeError -static napi_value ThrowRangeError(napi_env env, napi_callback_info info) -{ - // ArkTS侧传入两个参数 - size_t argc = 2; - napi_value argv[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - // 如果传入参数个数不为2 - if (argc != 2) { - // 这里抛出一个RangeError - napi_throw_range_error(env, "napi_throw_range_error", "Expected two numbers as arguments"); - return nullptr; - } - // 下面将传入的两值相加并传出去 - double numOne = 0; - double numTwo = 0; - napi_get_value_double(env, argv[0], &numOne); - napi_get_value_double(env, argv[1], &numTwo); - double result = numOne + numTwo; - napi_value resultValue; - napi_create_double(env, result, &resultValue); - return resultValue; -} -// [End napi_throw_range_error] - -// [Start napi_is_error] -// napi_is_error -static napi_value NapiIsError(napi_env env, napi_callback_info info) -{ - // 接收一个入参 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 调用接口napi_is_error判断入参是否为一个error对象 - bool result = false; - // 如果napi_value为一个error对象,则设置result为true的布尔值,否则设置为false - napi_is_error(env, args[0], &result); - // 取出result通过napi_get_boolean接口将取出的bool值转换为napi_value类型的值返回出去 - napi_value returnValue = nullptr; - napi_get_boolean(env, result, &returnValue); - return returnValue; -} -// [End napi_is_error] - -// [Start napi_get_and_clear_last_exception] -// napi_get_and_clear_last_exception -static napi_value GetAndClearLastException(napi_env env, napi_callback_info info) -{ - // 抛出异常,创造异常情况 - napi_throw_error(env, "napi_create_error errorCode", "napi_create_error errorMessage"); - // 调用napi_get_and_clear_last_exception接口获取并清除最后一个未处理的异常。即使存在挂起的ArkTS异常,也可以调用此API - napi_value result = nullptr; - napi_status status = napi_get_and_clear_last_exception(env, &result); - if (status != napi_ok) { - return nullptr; - } - return result; -} -// [End napi_get_and_clear_last_exception] - -// [Start napi_is_exception_pending] -// napi_is_exception_pending -static napi_value IsExceptionPending(napi_env env, napi_callback_info info) -{ - napi_status status; - bool isExceptionPending = false; - // 在执行一些可能引发异常的操作后 - napi_throw_error(env, "napi_create_error errorCode", "napi_create_error errorMessage"); - // 检查当前环境中是否有异常挂起 - status = napi_is_exception_pending(env, &isExceptionPending); - if (status != napi_ok) { - return nullptr; - } - if (isExceptionPending) { - // 处理异常挂起的情况 - napi_value result = nullptr; - status = napi_get_and_clear_last_exception(env, &result); - if (status != napi_ok) { - return nullptr; - } - // 将处理的异常返回出去 - return result; - } - return nullptr; -} -// [End napi_is_exception_pending] - -// [Start napi_fatal_error] -// napi_fatal_error -static napi_value FatalError(napi_env env, napi_callback_info info) -{ - // 请注意,使用napi_fatal_error函数会导致应用进程直接终止,因此应该谨慎使用,仅在遇到无法恢复的严重错误时才应该调用该函数 - // 模拟一个致命错误条件 - bool errorCondition = true; - if (errorCondition) { - // 创建一个致命错误信息 - napi_fatal_error("napi_fatal_error test", NAPI_AUTO_LENGTH, "napi_create_error errorMessage", NAPI_AUTO_LENGTH); - } - return nullptr; -} -// [End napi_fatal_error] - -// [Start napi_fatal_exception] -// napi_fatal_exception -static napi_value FatalException(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - - napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - if (status != napi_ok) { - return nullptr; - } - // 请注意,使用napi_fatal_exception函数会导致应用进程直接终止,因此应该谨慎使用,仅在主线程遇到无法恢复的严重错误时才应该调用该函数 - // 模拟一个致命错误条件 - status = napi_fatal_exception(env, args[0]); - if (status != napi_ok) { - return nullptr; - } - return nullptr; -} -// [End napi_fatal_exception] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"getLastErrorInfo", nullptr, GetLastErrorInfo, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"creatTypeError", nullptr, CreatTypeError, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"creatRangeError", nullptr, CreatRangeError, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiThrow", nullptr, NapiThrow, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiThrowErrorMessage", nullptr, NapiThrowErrorMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiThrowError", nullptr, NapiThrowError, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"throwTypeErrorMessage", nullptr, ThrowTypeErrorMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"throwTypeError", nullptr, ThrowTypeError, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"throwRangeErrorMessage", nullptr, ThrowRangeErrorMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"throwRangeError", nullptr, ThrowRangeError, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiIsError", nullptr, NapiIsError, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getAndClearLastException", nullptr, GetAndClearLastException, nullptr, nullptr, nullptr, napi_default, - nullptr}, - {"isExceptionPending", nullptr, IsExceptionPending, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"fatalError", nullptr, FatalError, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"fatalException", nullptr, FatalException, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 6458d55543..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_get_last_error_info_api] -export const getLastErrorInfo: (str: string) => string; // napi_get_last_error_info -// [End napi_get_last_error_info_api] - -// [Start napi_create_type_error_api] -export const creatTypeError: () => Error; // napi_create_type_error -// [End napi_create_type_error_api] - -// [Start napi_create_range_error_api] -export const creatRangeError: () => Error; // napi_create_range_error -// [End napi_create_range_error_api] - -// [Start napi_create_error_api] -export const napiThrow: () => void; // napi_create_error and napi_throw -// [End napi_create_error_api] - -// [Start napi_throw_error_api] -export const napiThrowErrorMessage: () => void; // napi_throw_error - -export const napiThrowError: (dividend: number, divisor: number) => void; // napi_throw_error -// [End napi_throw_error_api] - -// [Start napi_throw_type_error_api] -export const throwTypeErrorMessage: () => void; // napi_throw_type_error - -export const throwTypeError: (message: string) => void; // napi_throw_type_error -// [End napi_throw_type_error_api] - -// [Start napi_throw_range_error_api] -export const throwRangeErrorMessage: () => void; // napi_throw_range_error - -export const throwRangeError: (num: number) => number | void; // napi_throw_range_error -// [End napi_throw_range_error_api] - -// [Start napi_is_error_api] -export const napiIsError: (obj: T) => boolean; // napi_is_error -// [End napi_is_error_api] - -// [Start napi_get_and_clear_last_exception_api] -export const getAndClearLastException: () => Error | void; // napi_get_and_clear_last_exception -// [End napi_get_and_clear_last_exception_api] - -// [Start ark_napi_is_exception_pending_interface] -export interface MyObject { - code: string; - message: string; -} -// [End ark_napi_is_exception_pending_interface] - -// [Start napi_is_exception_pending_api] -export const isExceptionPending: () => Object | void; // napi_is_exception_pending -// [End napi_is_exception_pending_api] - -// [Start napi_fatal_error_api] -export const fatalError: () => void; // napi_fatal_error -// [End napi_fatal_error_api] - -// [Start napi_fatal_exception_api] -export const fatalException: (err: Error) => void; // napi_fatal_exception -// [End napi_fatal_exception_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 117809f4f7..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,308 +0,0 @@ -/* - * 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 testNapi, { MyObject } from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiGetLastErrorInfo', - '2.napiCreateTypeError', - '3.napiCreateRangeError', - '4.napiCreateErrorAndNapiThrow', - '5.napiThrowError', - '6.napiThrowTypeError', - '7.napiThrowRangeError', - '8.napiIsError', - '9.napiGetAndClearLastException', - '10.napiIsExceptionPending', - '11.napiFatalError', - '12.napiFatalException' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(20) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiGetLastErrorInfo') { - // [Start ark_napi_get_last_error_info] - // napi_get_last_error_info - try { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_last_error_info: %{public}s', - testNapi.getLastErrorInfo('message')); - // [StartExclude ark_napi_get_last_error_info] - this.result = 'napiGetLastErrorInfoSuccess'; - // [EndExclude ark_napi_get_last_error_info] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_get_last_error_info error: %{public}s', error); - // [StartExclude ark_napi_get_last_error_info] - this.result = 'napiGetLastErrorInfoFail'; - // [EndExclude ark_napi_get_last_error_info] - } - // [End ark_napi_get_last_error_info] - } else if (item === '2.napiCreateTypeError') { - // [Start ark_napi_create_type_error] - try { - // [StartExclude ark_napi_create_type_error] - this.result = 'napiCreateTypeErrorSuccess'; - // [EndExclude ark_napi_create_type_error] - throw testNapi.creatTypeError(); - } catch (error) { // napi_create_type_error - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_create_type_error errorCode: %{public}s, errorMessage %{public}s', error.code, - error.message); - // [StartExclude ark_napi_create_type_error] - this.result = 'napiCreateTypeErrorFail'; - // [EndExclude ark_napi_create_type_error] - } - // [End ark_napi_create_type_error] - } else if (item === '3.napiCreateRangeError') { - // [Start ark_napi_create_range_error] - // napi_create_range_error - try { - // [StartExclude ark_napi_create_range_error] - this.result = 'napiCreateRangeErrorSuccess'; - // [EndExclude ark_napi_create_range_error] - throw testNapi.creatRangeError(); - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_create_range_error errorCode: %{public}s, errorMessage: %{public}s', - error.code, - error.message); - // [StartExclude ark_napi_create_range_error] - this.result = 'napiCreateRangeErrorFail'; - // [EndExclude ark_napi_create_range_error] - } - // [End ark_napi_create_range_error] - } else if (item === '4.napiCreateErrorAndNapiThrow') { - // [Start ark_napi_create_error] - // napi_create_error and napi_throw - try { - testNapi.napiThrow(); - // [StartExclude ark_napi_create_error] - this.result = 'napiCreateErrorAndNapiThrowSuccess'; - // [EndExclude ark_napi_create_error] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_throw errorCode: %{public}s, errorMessage: %{public}s', - error.code, error.message); - // [StartExclude ark_napi_create_error] - this.result = 'napiCreateErrorAndNapiThrowFail'; - // [EndExclude ark_napi_create_error] - } - // [End ark_napi_create_error] - } else if (item === '5.napiThrowError') { - // [Start ark_napi_throw_error] - // napi_throw_error - try { - testNapi.napiThrowErrorMessage(); - // [StartExclude ark_napi_throw_error] - this.result = 'napiThrowErrorMessageSuccess'; - // [EndExclude ark_napi_throw_error] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_throw_error error code: %{public}s , message: %{public}s', error.code, - error.message); - // [StartExclude ark_napi_throw_error] - this.result = 'napiThrowErrorMessageFail'; - // [EndExclude ark_napi_throw_error] - } - try { - testNapi.napiThrowError(5, 0); - // [StartExclude ark_napi_throw_error] - this.result = 'napiThrowErrorSuccess'; - // [EndExclude ark_napi_throw_error] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_throw_error errorCode: %{public}s , errorManager: %{public}s', error.code, - error.message); - // [StartExclude ark_napi_throw_error] - this.result = 'napiThrowErrorFail'; - // [EndExclude ark_napi_throw_error] - } - // [End ark_napi_throw_error] - } else if (item === '6.napiThrowTypeError') { - // [Start ark_napi_throw_type_error] - // napi_throw_type_error - try { - testNapi.throwTypeErrorMessage(); - // [StartExclude ark_napi_throw_type_error] - this.result = 'throwTypeErrorMessageSuccess'; - // [EndExclude ark_napi_throw_type_error] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_throw_type_error errorCode: %{public}s, errorMessage: %{public}s', - error.code, - error.message); - // [StartExclude ark_napi_throw_type_error] - this.result = 'throwTypeErrorMessageFail'; - // [EndExclude ark_napi_throw_type_error] - } - try { - testNapi.throwTypeError('str'); - // [StartExclude ark_napi_throw_type_error] - this.result = 'throwTypeErrorSuccess'; - // [EndExclude ark_napi_throw_type_error] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_throw_type_error errorCode: %{public}s, errorMessage: %{public}s', - error.code, - error.message); - // [StartExclude ark_napi_throw_type_error] - this.result = 'throwTypeErrorFail'; - // [EndExclude ark_napi_throw_type_error] - } - // [End ark_napi_throw_type_error] - } else if (item === '7.napiThrowRangeError') { - // [Start ark_napi_throw_range_error] - // napi_throw_range_error - try { - testNapi.throwRangeErrorMessage(); - // [StartExclude ark_napi_throw_range_error] - this.result = 'throwRangeErrorMessageSuccess'; - // [EndExclude ark_napi_throw_range_error] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_throw_range_error errorCode: %{public}s, errorMessage: %{public}s', - error.code, - error.message); - // [StartExclude ark_napi_throw_range_error] - this.result = 'throwRangeErrorMessageFail'; - // [EndExclude ark_napi_throw_range_error] - } - - try { - testNapi.throwRangeError(1); - // [StartExclude ark_napi_throw_range_error] - this.result = 'throwRangeErrorSuccess'; - // [EndExclude ark_napi_throw_range_error] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_throw_range_error errorCode: %{public}s, errorMessage: %{public}s', - error.code, - error.message); - // [StartExclude ark_napi_throw_range_error] - this.result = 'throwRangeErrorFail'; - // [EndExclude ark_napi_throw_range_error] - } - // [End ark_napi_throw_range_error] - } else if (item === '8.napiIsError') { - // [Start ark_napi_is_error] - // napi_is_error - try { - // [StartExclude ark_napi_is_error] - this.result = 'napiIsErrorSuccess'; - // [EndExclude ark_napi_is_error] - throw new Error("throwing an error"); - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_error error: %{public}s', - testNapi.napiIsError(error) - .toString()); - hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_error error: %{public}s', - testNapi.napiIsError(1) - .toString()); - // [StartExclude ark_napi_is_error] - this.result = 'napiIsErrorFail'; - // [EndExclude ark_napi_is_error] - } - // [End ark_napi_is_error] - } else if (item === '9.napiGetAndClearLastException') { - // [Start ark_napi_get_and_clear_last_exception] - // napi_get_and_clear_last_exception - // 这里获取到最后一个未处理的异常 - hilog.info(0x0000, 'testTag', - 'Test Node-API napi_get_and_clear_last_exception, error.message: %{public}s', - testNapi.getAndClearLastException()); - // [End ark_napi_get_and_clear_last_exception] - this.result = 'napiGetAndClearLastExceptionSuccess'; - } else if (item === '10.napiIsExceptionPending') { - // [Start ark_napi_is_exception_pending] - // napi_is_exception_pending - try { - let result = testNapi.isExceptionPending() as MyObject; - hilog.info(0x0000, 'testTag', - 'Test Node-API napi_is_exception_pending, error.Code: %{public}s, error.message: %{public}s', - result.code, result.message); - // [StartExclude ark_napi_is_exception_pending] - this.result = 'napiIsExceptionPendingSuccess'; - // [EndExclude ark_napi_is_exception_pending] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_exception_pending error'); - // [StartExclude ark_napi_is_exception_pending] - this.result = 'napiIsExceptionPendingFail'; - // [EndExclude ark_napi_is_exception_pending] - } - // [End ark_napi_is_exception_pending] - } else if (item === '11.napiFatalError') { - // [Start ark_napi_fatal_error] - // napi_fatal_error 请注意,使用napi_fatal_error函数会导致应用进程直接终止,因此应该谨慎使用,仅在遇到无法恢复的严重错误时才应该调用该函数 - // 模拟一个致命错误条件 - try { - testNapi.fatalError(); - // [StartExclude ark_napi_fatal_error] - this.result = 'napiFatalErrorSuccess'; - // [EndExclude ark_napi_fatal_error] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_fatal_error error'); - // [StartExclude ark_napi_fatal_error] - this.result = 'napiFatalErrorFail'; - // [EndExclude ark_napi_fatal_error] - } - // [End ark_napi_fatal_error] - } else if (item === '12.napiFatalException') { - // napi_fatal_exception 请注意,使用napi_fatal_error函数会导致应用进程直接终止,因此应该谨慎使用,仅在遇到无法恢复的严重错误时才应该调用该函数 - // 模拟一个致命错误条件 - try { - // [Start ark_napi_fatal_exception] - const err = new Error("a fatal exception occurred"); - testNapi.fatalException(err); - // [End ark_napi_fatal_exception] - this.result = 'napiFatalExceptionSuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_fatal_exception error'); - this.result = 'napiFatalExceptionFail'; - } - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/ohosTest.md deleted file mode 100755 index efd0513e1d..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIError/ohosTest.md +++ /dev/null @@ -1,17 +0,0 @@ -# 使用Node-API进行错误处理开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| --------------------------------------------------- | ------------ | -------------------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 getLastErrorInfo | 位于主页 | 点击文本为1.napiGetLastErrorInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetLastErrorInfoSuccess | Pass | -| ArkTS端成功调用native侧接口creatTypeError | 位于主页 | 点击文本为2.napiCreateTypeError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateTypeErrorSuccess | Pass | -| ArkTS端成功调用native侧接口creatRangeError | 位于主页 | 点击文本为3.napiCreateRangeError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateRangeErrorSuccess | Pass | -| ArkTS端成功调用native侧接口napiThrow | 位于主页 | 点击文本为4.napiCreateErrorAndNapiThrow的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateErrorAndNapiThrowSuccess | Pass | -| ArkTS端成功调用native侧接口napiThrowError | 位于主页 | 点击文本为5.napiThrowError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiThrowErrorSuccess | Pass | -| ArkTS端成功调用native侧接口throwTypeError | 位于主页 | 点击文本为6.napiThrowTypeError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: throwTypeErrorSuccess | Pass | -| ArkTS端成功调用native侧接口throwRangeError | 位于主页 | 点击文本为7.napiThrowRangeError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: throwRangeErrorSuccess | Pass | -| ArkTS端成功调用native侧接口napiIsError | 位于主页 | 点击文本为8.napiIsError的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsErrorSuccess | Pass | -| ArkTS端成功调用native侧接口getAndClearLastException | 位于主页 | 点击文本为9.napiGetAndClearLastException的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetAndClearLastExceptionSuccess | Pass | -| ArkTS端成功调用native侧接口isExceptionPending | 位于主页 | 点击文本为10.napiIsExceptionPending的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsExceptionPendingSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/app.json5 deleted file mode 100755 index fea2df7549..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiextendcapabilities", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/element/string.json deleted file mode 100755 index 5cb53b4b9f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIExtendCapabilities" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/README.md deleted file mode 100755 index 96980a8882..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行扩展能力功能开发 - -### 介绍 - -扩展能力接口进一步扩展了Node-API的功能,提供了一些额外的接口,用于在Node-API模块中与ArkTS进行更灵活的交互和定制,这些接口可以用于创建自定义ArkTS对象等场景,本工程主要展示了使用Node-API对模块加载、ArkTS Object相关、运行指定abc文件、异步工作对象加入队列并指定优先级、给ArkTS对象绑定回调和回调所需的参数等场景,其中展示的代码详细描述可查如下链接。 - -- [使用Node-API进行扩展能力功能开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-extension.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIExtendCapabilities.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行扩展能力功能开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIExtendCapabilities.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 37b14bbfc9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(using_NodeAPI_extend_capabilities) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 6eabbeacfd..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,578 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "hilog/log.h" - -static constexpr int INT_ARG_100 = 100; // 入参索引 - -// [Start node_api_module_add] -// 模块加载 -static napi_value Add(napi_env env, napi_callback_info info) -{ - // 接受传入两个参数 - size_t requireArgc = 2; - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 将传入的napi_value类型的参数转化为double类型 - double valueLeft; - double valueRight; - napi_get_value_double(env, args[0], &valueLeft); - napi_get_value_double(env, args[1], &valueRight); - - // 将转化后的double值相加并转成napi_value返回给ArkTS代码使用 - napi_value sum; - napi_create_double(env, valueLeft + valueRight, &sum); - - return sum; -} - -// [StartExclude node_api_module_add] -// [Start node_api_module_create_object_properties] -// ArkTS Object相关 napi_create_object_with_properties -static napi_value CreateObjectWithProperties(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value argv[1] = {nullptr}; - // 获取解析传递的参数 - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - // 声明了一个napi_property_descriptor数组desc,其中包含了一个名为"name"的属性,其值为传入的第一个参数argv[0]。 - napi_property_descriptor desc[] = { - {"name", nullptr, nullptr, nullptr, nullptr, argv[0], napi_default_jsproperty, nullptr}}; - napi_value object = nullptr; - // 调用napi_create_object_with_properties来创建一个新的ArkTS对象,并将属性值添加到该对象中。 - napi_create_object_with_properties(env, &object, sizeof(desc) / sizeof(desc[0]), desc); - napi_valuetype valueType; - napi_typeof(env, object, &valueType); - if (valueType == napi_object) { - return object; - } -} -// [End node_api_module_create_object_properties] -// [Start node_api_module_create_object_name_properties] -// ArkTS Object相关 napi_create_object_with_named_properties -static napi_value CreateObjectWithNameProperties(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value argv[1] = {nullptr}; - // 获取解析传递的参数 - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - napi_value obj = nullptr; - const char *key[] = { - "name", - }; - const napi_value values[] = { - argv[0], - }; - napi_property_descriptor desc[] = {{"name", nullptr, nullptr, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_status status = napi_create_object_with_named_properties( - env, &obj, sizeof(desc) / sizeof(desc[0]), key, values); - if (status != napi_ok) { - return argv[0]; - } - return obj; -} -// [End node_api_module_create_object_name_properties] -// [Start node_api_module_run_script_path] -// 运行指定abc文件 napi_run_script_path -static napi_value RunScriptPath(napi_env env, napi_callback_info info) -{ - napi_value value = nullptr; - // 注意:记得在应用rawfile目录下放置.abc文件 - const char *scriptPath = "/entry/src/main/resources/rawfile/test.abc"; - // 使用napi_run_script_path函数执行指定路径中的文件 - napi_status status = napi_run_script_path(env, scriptPath, &value); - // 检查是否执行成功,如果失败,返回false - napi_value returnValue = nullptr; - if (value == nullptr || status != napi_ok) { - napi_get_boolean(env, false, &returnValue); - } else { - napi_get_boolean(env, true, &returnValue); - } - return returnValue; -} -// [End node_api_module_run_script_path] -// 给ArkTS对象绑定回调和回调所需的参数 napi_coerce_to_native_binding_object -// [Start napi_coerce_to_native_binding_object] -class Object { -public: - Object() = default; - ~Object() = default; - - static Object *GetInstance() - { - Object *instance = new Object(); - return instance; - } - - static napi_value GetAddress(napi_env env, napi_callback_info info) - { - napi_value thisVar = nullptr; - napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); - if (thisVar == nullptr) { - return nullptr; - } - void *object = nullptr; - napi_unwrap(env, thisVar, &object); - if (object == nullptr) { - return nullptr; - } - uint64_t addressVal = reinterpret_cast(object); - napi_value address = nullptr; - napi_create_bigint_uint64(env, addressVal, &address); - return address; - } - - // 获取数组大小 - static napi_value GetSetSize(napi_env env, napi_callback_info info) - { - napi_value thisVar = nullptr; - napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); - if (thisVar == nullptr) { - return nullptr; - } - void *object = nullptr; - napi_unwrap(env, thisVar, &object); - if (object == nullptr) { - return nullptr; - } - std::lock_guard lock(reinterpret_cast(object)->numberSetMutex_); - uint32_t setSize = reinterpret_cast(object)->numberSet_.size(); - napi_value napiSize = nullptr; - napi_create_uint32(env, setSize, &napiSize); - return napiSize; - } - - // 往数组里插入元素 - static napi_value Store(napi_env env, napi_callback_info info) - { - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_value thisVar = nullptr; - napi_get_cb_info(env, info, &argc, args, &thisVar, nullptr); - if (argc != 1) { - napi_throw_error(env, nullptr, "Store args number must be one."); - return nullptr; - } - napi_valuetype type = napi_undefined; - napi_typeof(env, args[0], &type); - if (type != napi_number) { - napi_throw_error(env, nullptr, "Store args is not number."); - return nullptr; - } - if (thisVar == nullptr) { - return nullptr; - } - uint32_t value = 0; - napi_get_value_uint32(env, args[0], &value); - void *object = nullptr; - napi_unwrap(env, thisVar, &object); - if (object == nullptr) { - return nullptr; - } - std::lock_guard lock(reinterpret_cast(object)->numberSetMutex_); - reinterpret_cast(object)->numberSet_.insert(value); - return nullptr; - } - - // 删除数组元素 - static napi_value Erase(napi_env env, napi_callback_info info) - { - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_value thisVar = nullptr; - napi_get_cb_info(env, info, &argc, args, &thisVar, nullptr); - if (argc != 1) { - napi_throw_error(env, nullptr, "Erase args number must be one."); - return nullptr; - } - napi_valuetype type = napi_undefined; - napi_typeof(env, args[0], &type); - if (type != napi_number) { - napi_throw_error(env, nullptr, "Erase args is not number."); - return nullptr; - } - if (thisVar == nullptr) { - return nullptr; - } - uint32_t value = 0; - napi_get_value_uint32(env, args[0], &value); - void *object = nullptr; - napi_unwrap(env, thisVar, &object); - if (object == nullptr) { - return nullptr; - } - std::lock_guard lock(reinterpret_cast(object)->numberSetMutex_); - reinterpret_cast(object)->numberSet_.erase(value); - return nullptr; - } - - // 清空数组 - static napi_value Clear(napi_env env, napi_callback_info info) - { - napi_value thisVar = nullptr; - napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); - if (thisVar == nullptr) { - return nullptr; - } - void *object = nullptr; - napi_unwrap(env, thisVar, &object); - if (object == nullptr) { - return nullptr; - } - std::lock_guard lock(reinterpret_cast(object)->numberSetMutex_); - reinterpret_cast(object)->numberSet_.clear(); - return nullptr; - } - -private: - Object(const Object &) = delete; - Object &operator=(const Object &) = delete; - - std::unordered_set numberSet_{}; - std::mutex numberSetMutex_{}; -}; - -void FinializeCallback(napi_env env, void *data, void *hint) { return; } - -// 解绑回调,在序列化时调用,可在对象解绑时执行一些清理操作 -void *DetachCallback(napi_env env, void *value, void *hint) { return value; } - -// 绑定回调,在反序列化时调用 -napi_value AttachCallback(napi_env env, void *value, void *hint) -{ - napi_value object = nullptr; - napi_create_object(env, &object); - napi_property_descriptor desc[] = { - {"getAddress", nullptr, Object::GetAddress, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getSetSize", nullptr, Object::GetSetSize, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"store", nullptr, Object::Store, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"erase", nullptr, Object::Erase, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"clear", nullptr, Object::Clear, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, object, sizeof(desc) / sizeof(desc[0]), desc); - // 将JS对象object和native对象value生命周期进行绑定 - napi_wrap(env, object, value, FinializeCallback, nullptr, nullptr); - // JS对象携带native信息 - napi_coerce_to_native_binding_object(env, object, DetachCallback, AttachCallback, value, hint); - return object; -} -// [StartExclude napi_coerce_to_native_binding_object] -// [Start napi_serialize_deserialize_delete_serialization_data] -// 序列化和反序列化 -static napi_value AboutSerialize(napi_env env, napi_callback_info info) -{ - // 获取传入的ts的一个对象作为参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - napi_value undefined = nullptr; - // 构造napi_serialize方法所需参数 - napi_get_undefined(env, &undefined); - void *data = nullptr; - // 调用napi_serialize方法将ts对象转化为native数据 - napi_status status = napi_serialize(env, args[0], undefined, undefined, &data); - if (status != napi_ok || data == nullptr) { - napi_throw_error(env, nullptr, "Node-API napi_serialize fail"); - return nullptr; - } - // 构造napi_value类型的数据,用于接收将native数据转化为ts对象后的数据 - napi_value result = nullptr; - napi_deserialize(env, data, &result); - napi_value number = nullptr; - // 获取native数据转化为ts对象后的数据中的numKey属性的值 - napi_get_named_property(env, result, "numKey", &number); - // 判断获取到的属性值是否为number类型 - napi_valuetype valuetype; - napi_typeof(env, number, &valuetype); - if (valuetype != napi_number) { - napi_throw_error(env, nullptr, "Node-API Wrong type of argment. Expects a number."); - return nullptr; - } - // 调用napi_delete_serialization_data方法删除序列化数据 - napi_delete_serialization_data(env, data); - // 返回获取到的属性值 - return number; -} -// [End napi_serialize_deserialize_delete_serialization_data] -// [Start napi_is_sendable] -// Sendable相关 napi_is_sendable -static napi_value IsSendable(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - bool isSendable = false; - napi_is_sendable(env, args[0], &isSendable); - napi_value result; - napi_get_boolean(env, isSendable, &result); - return result; -} -// [End napi_is_sendable] - -// [Start napi_define_sendable_class] -static napi_value func(napi_env env, napi_callback_info info) -{ - napi_value val; - napi_create_string_utf8(env, "func result", NAPI_AUTO_LENGTH, &val); - return val; -} - -static napi_value DefineSendableClass(napi_env env) -{ - napi_value str; - napi_create_string_utf8(env, "str", NAPI_AUTO_LENGTH, &str); - - napi_property_descriptor props[] = { - {"staticStr", nullptr, nullptr, nullptr, nullptr, str, - static_cast(napi_static | napi_writable), nullptr}, - {"staticFunc", nullptr, func, nullptr, nullptr, nullptr, napi_static, nullptr}, - {"str", nullptr, nullptr, nullptr, nullptr, str, static_cast(1 << 9 | napi_writable), - nullptr}, - {"func", nullptr, nullptr, nullptr, nullptr, nullptr, - static_cast(1 << 11 | napi_writable), nullptr}, - }; - - napi_value sendableClass = nullptr; - napi_define_sendable_class( - env, "SendableClass", NAPI_AUTO_LENGTH, - [](napi_env env, napi_callback_info info) -> napi_value { - napi_value thisVar = nullptr; - napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); - napi_value str; - napi_create_string_utf8(env, "instance str", NAPI_AUTO_LENGTH, &str); - napi_property_descriptor props[] = { - {"str", nullptr, nullptr, nullptr, nullptr, str, napi_default, nullptr}, - {"func", nullptr, func, nullptr, nullptr, nullptr, napi_default, nullptr}, - }; - napi_define_properties(env, thisVar, sizeof(props) / sizeof(props[0]), props); - return thisVar; - }, - nullptr, sizeof(props) / sizeof(props[0]), props, nullptr, &sendableClass); - - return sendableClass; -} -// [End napi_define_sendable_class] -// [Start napi_create_sendable_object_with_properties] -// Sendable相关 napi_create_sendable_object_with_properties -static napi_value GetSendableObject(napi_env env, napi_callback_info info) -{ - napi_value val_true; - napi_get_boolean(env, true, &val_true); - napi_property_descriptor desc1[] = { - {"x", nullptr, nullptr, nullptr, nullptr, val_true, napi_default_jsproperty, nullptr}, - }; - napi_value obj; - napi_create_sendable_object_with_properties(env, 1, desc1, &obj); - return obj; -} -// [End napi_create_sendable_object_with_properties -// [Start napi_create_sendable_array] -// Sendable相关 napi_create_sendable_array -static napi_value GetSendableArray(napi_env env, napi_callback_info info) -{ - napi_value result = nullptr; - napi_create_sendable_array(env, &result); - return result; -} -// [End napi_create_sendable_array] -// [Start napi_create_sendable_array_with_length] -// Sendable相关 napi_create_sendable_array_with_length -static napi_value GetSendableArrayWithLength(napi_env env, napi_callback_info info) -{ - napi_value result = nullptr; - napi_create_sendable_array_with_length(env, 1, &result); - return result; -} -// End napi_create_sendable_array_with_length] -// [Start napi_create_sendable_arraybuffer] -// Sendable相关 napi_create_sendable_arraybuffer -static napi_value GetSendableArrayBuffer(napi_env env, napi_callback_info info) -{ - static size_t length = 1024; - void *data; - napi_value result = nullptr; - napi_create_sendable_arraybuffer(env, length, &data, &result); - bool isArrayBuffer = false; - napi_is_arraybuffer(env, result, &isArrayBuffer); - OH_LOG_INFO(LOG_APP, "isArrayBuffer: %{public}d", isArrayBuffer); - return result; -} -// [End napi_create_sendable_arraybuffer] -// [Start napi_create_sendable_typed_array] -// Sendable相关 napi_create_sendable_typedarray -static napi_value GetSendableTypedArray(napi_env env, napi_callback_info info) -{ - static size_t length = 1024; - static size_t offset = 0; - void *data; - napi_value arraybuffer = nullptr; - napi_create_sendable_arraybuffer(env, length, &data, &arraybuffer); - - napi_value result = nullptr; - napi_create_sendable_typedarray(env, napi_uint8_array, length, arraybuffer, offset, &result); - bool isTypedArray = false; - napi_is_typedarray(env, result, &isTypedArray); - OH_LOG_INFO(LOG_APP, "isTypedArray: %{public}d", isTypedArray); - return result; -} -// [End napi_create_sendable_typed_array] -// [Start napi_wrap_sendable] -// Sendable相关 napi_wrap_sendable -static napi_value WrapSendable(napi_env env, napi_callback_info info) -{ - napi_value val_true; - napi_get_boolean(env, true, &val_true); - napi_property_descriptor desc1[] = { - {"x", nullptr, nullptr, nullptr, nullptr, val_true, napi_default_jsproperty, nullptr}, - }; - napi_value obj; - napi_create_sendable_object_with_properties(env, 1, desc1, &obj); - - const char *testStr = "test"; - napi_wrap_sendable( - env, obj, (void *)testStr, [](napi_env env, void *data, void *hint) {}, nullptr); - - return nullptr; -} -// [End napi_wrap_sendable] -// [Start napi_wrap_sendable_with_size] -// Sendable相关 napi_wrap_sendable_with_size -static napi_value WrapSendableWithSize(napi_env env, napi_callback_info info) -{ - napi_value val_true; - napi_get_boolean(env, true, &val_true); - napi_property_descriptor desc1[] = { - {"x", nullptr, nullptr, nullptr, nullptr, val_true, napi_default_jsproperty, nullptr}, - }; - napi_value obj; - napi_create_sendable_object_with_properties(env, 1, desc1, &obj); - - const char *testStr = "test"; - napi_wrap_sendable_with_size( - env, obj, (void *)testStr, [](napi_env env, void *data, void *hint) {}, nullptr, INT_ARG_100); - - return nullptr; -} -// [End napi_wrap_sendable_with_size] -// [Start napi_unwrap_sendable] -// Sendable相关 napi_unwrap_sendable -static napi_value UnwrapSendable(napi_env env, napi_callback_info info) -{ - napi_value val_true; - napi_get_boolean(env, true, &val_true); - napi_property_descriptor desc1[] = { - {"x", nullptr, nullptr, nullptr, nullptr, val_true, napi_default_jsproperty, nullptr}, - }; - napi_value obj; - napi_create_sendable_object_with_properties(env, 1, desc1, &obj); - - const char *testStr = "test"; - napi_wrap_sendable( - env, obj, (void *)testStr, [](napi_env env, void *data, void *hint) {}, nullptr); - - char *tmpTestStr = nullptr; - napi_unwrap_sendable(env, obj, (void **)&tmpTestStr); - OH_LOG_INFO(LOG_APP, "native value is %{public}s", tmpTestStr); - - return nullptr; -} -// [End napi_unwrap_sendable] -// [Start napi_remove_wrap_sendable] -// Sendable相关 napi_remove_wrap_sendable -static napi_value RemoveWrapSendable(napi_env env, napi_callback_info info) -{ - napi_value val_true; - napi_get_boolean(env, true, &val_true); - napi_property_descriptor desc1[] = { - {"x", nullptr, nullptr, nullptr, nullptr, val_true, napi_default_jsproperty, nullptr}, - }; - napi_value obj; - napi_create_sendable_object_with_properties(env, 1, desc1, &obj); - - const char *testStr = "test"; - napi_wrap_sendable( - env, obj, (void *)testStr, [](napi_env env, void *data, void *hint) {}, nullptr); - - char *tmpTestStr = nullptr; - napi_remove_wrap_sendable(env, obj, (void **)&tmpTestStr); - OH_LOG_INFO(LOG_APP, "native value is %{public}s", tmpTestStr); - - return nullptr; -} -// [End napi_remove_wrap_sendable] -// [EndExclude napi_coerce_to_native_binding_object] -// [EndExclude node_api_module_add] - -// C++函数Init用于初始化插件,用于将ArkTS层的函数或属性与C++层的函数进行关联 -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - // 通过napi_property_descriptor结构体,可以定义需要导出的属性,并在Node-API模块中使用。napi_define_properties将属性与实际的C++函数进行关联,使其可以被ArkTS层访问和调用 - napi_property_descriptor desc[] = { - {"add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createObjectWithProperties", nullptr, CreateObjectWithProperties, nullptr, nullptr, nullptr, napi_default, - nullptr}, - {"createObjectWithNameProperties", nullptr, CreateObjectWithNameProperties, nullptr, nullptr, nullptr, - napi_default, nullptr}, - {"runScriptPath", nullptr, RunScriptPath, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getAddress", nullptr, Object::GetAddress, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getSetSize", nullptr, Object::GetSetSize, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"store", nullptr, Object::Store, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"erase", nullptr, Object::Erase, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"clear", nullptr, Object::Clear, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"aboutSerialize", nullptr, AboutSerialize, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"isSendable", nullptr, IsSendable, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getSendableObject", nullptr, GetSendableObject, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getSendableArray", nullptr, GetSendableArray, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getSendableArrayWithLength", nullptr, GetSendableArrayWithLength, nullptr, nullptr, nullptr, napi_default, - nullptr}, - {"getSendableArrayBuffer", nullptr, GetSendableArrayBuffer, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getSendableTypedArray", nullptr, GetSendableTypedArray, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"wrapSendable", nullptr, WrapSendable, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"wrapSendableWithSize", nullptr, WrapSendableWithSize, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"unwrapSendable", nullptr, UnwrapSendable, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"removeWrapSendable", nullptr, RemoveWrapSendable, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - auto object = Object::GetInstance(); - napi_wrap(env, exports, reinterpret_cast(object), FinializeCallback, nullptr, nullptr); - napi_coerce_to_native_binding_object(env, exports, DetachCallback, AttachCallback, reinterpret_cast(object), - nullptr); - napi_value cons = DefineSendableClass(env); - napi_set_named_property(env, exports, "SendableClass", cons); - return exports; -} -EXTERN_C_END - -// 插件的初始化被定义在一个名为demoModule的结构体中,其中包含了模块的基本信息,比如模块的版本号、注册函数等 -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}, -}; - -// 在RegisterEntryModule函数中,使用napi_module_register函数注册并导出了这个插件 -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } -// [End napi_coerce_to_native_binding_object] -// [End node_api_module_add] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 4f111a684b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start node_api_module_add_api] -export const add: (a: number, b: number) => number; // 模块加载 -// [End node_api_module_add_api] - -// [Start node_api_module_create_object_properties_api] -export const createObjectWithProperties: (data: string) => Object; // ArkTS Object相关 napi_create_object_with_properties -// [End node_api_module_create_object_properties_api] - -// [Start node_api_module_create_object_name_properties_api] -export const createObjectWithNameProperties: (data: string) => string | { name: string }; // ArkTS Object相关 napi_create_object_with_named_properties -// [End node_api_module_create_object_name_properties_api] - -// [Start node_api_module_run_script_path_api] -export const runScriptPath: () => boolean; // 运行指定abc文件 napi_run_script_path -// [End node_api_module_run_script_path_api] -// [Start napi_coerce_to_native_binding_object_api] -// 给ArkTS对象绑定回调和回调所需的参数 napi_coerce_to_native_binding_object -export const getAddress: () => number; - -export const getSetSize: () => number; - -export const store: (a: number) => void; - -export const erase: (a: number) => void; - -export const clear: () => void; -// [End napi_coerce_to_native_binding_object_api] - -// [Start napi_serialize_deserialize_delete_serialization_data_api] -export const aboutSerialize: (obj: Object) => number; // 序列化和反序列化 -// [End napi_serialize_deserialize_delete_serialization_data_api] - -// [Start napi_is_sendable_api] -export const isSendable: (a: T) => boolean; // Sendable相关 napi_is_sendable -// [End napi_is_sendable_api] - -// [Start napi_define_sendable_class_api] -@Sendable -export class SendableClass { - static staticStr: string; - static staticFunc(): string; - str: string; - func(): string; -} // Sendable相关 napi_define_sendable_class -// [End napi_define_sendable_class_api] - -// [Start napi_create_sendable_object_with_properties_api] -export const getSendableObject: () => { x: true }; // Sendable相关 napi_create_sendable_object_with_properties -// [End napi_create_sendable_object_with_properties_api] - -// [Start napi_create_sendable_array_api] -export const getSendableArray: () => []; // Sendable相关 napi_create_sendable_array -// [End napi_create_sendable_array_api] - -// [Start napi_create_sendable_array_with_length_api] -export const getSendableArrayWithLength: () => []; // Sendable相关 napi_create_sendable_array_with_length -// [End napi_create_sendable_array_with_length_api] - -// [Start napi_create_sendable_arraybuffer_api] -export const getSendableArrayBuffer: () => void; // Sendable相关 napi_create_sendable_arraybuffer -// [End napi_create_sendable_arraybuffer_api] - -// [Start napi_create_sendable_typed_array_api] -export const getSendableTypedArray: () => void; // Sendable相关 napi_create_sendable_typedarray -// [End napi_create_sendable_typed_array_api] - -// [Start napi_wrap_sendable_api] -export const wrapSendable: () => void; // Sendable相关 napi_wrap_sendable -// [End napi_wrap_sendable_api] - -// [Start napi_wrap_sendable_with_size_api] -export const wrapSendableWithSize: () => void; // Sendable相关 napi_wrap_sendable_with_size -// [End napi_wrap_sendable_with_size_api] - -// [Start napi_unwrap_sendable_api] -export const unwrapSendable: () => void; // Sendable相关 napi_unwrap_sendable -// [End napi_unwrap_sendable_api] - -// [Start napi_remove_wrap_sendable_api] -export const removeWrapSendable: () => void; // Sendable相关 napi_remove_wrap_sendable -// [End napi_remove_wrap_sendable_api] diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index f1dc444030..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,267 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; -import taskpool from '@ohos.taskpool'; - -// [Start ark_napi_coerce_to_native_binding_object] -@Concurrent -function getAddress() { - let address: number = testNapi.getAddress(); - console.info('taskpool:: address is' + address); -} - -@Concurrent -function store(a: number, b: number, c: number) { - let size: number = testNapi.getSetSize(); - console.info('set size is' + size + 'before store'); - testNapi.store(a); - testNapi.store(b); - testNapi.store(c); - size = testNapi.getSetSize(); - console.info('set size is' + size + 'after store'); -} - -@Concurrent -function erase(a: number) { - let size: number = testNapi.getSetSize(); - console.info('set size is' + size + 'before erase'); - testNapi.erase(a); - size = testNapi.getSetSize(); - console.info('set size is' + size + 'after erase'); -} - -@Concurrent -function clear() { - let size: number = testNapi.getSetSize(); - console.info('set size is' + size + 'before clear'); - testNapi.clear(); - size = testNapi.getSetSize(); - console.info('set size is' + size + 'after clear'); -} - -async function test01(): Promise { - let address: number = testNapi.getAddress(); - console.info('host thread address is' + address); - - let task1 = new taskpool.Task(getAddress); - await taskpool.execute(task1); - - let task2 = new taskpool.Task(store, 1, 2, 3); - await taskpool.execute(task2); - - let task3 = new taskpool.Task(store, 4, 5, 6); - await taskpool.execute(task3); - - let task4 = new taskpool.Task(erase, 3); - await taskpool.execute(task4); - - let task5 = new taskpool.Task(erase, 5); - await taskpool.execute(task5); - - let task6 = new taskpool.Task(clear); - await taskpool.execute(task6); -} -// [End ark_napi_coerce_to_native_binding_object] - -// [Start ark_napi_serialize_deserialize_delete_serialization_data] -class Obj { - numKey: number = 0; -} -// [StartExclude ark_napi_serialize_deserialize_delete_serialization_data] - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiLoadModule', - '2.napiCreateObjectWithProperties', - '3.napiCreateObjectWithNamedProperties', - '4.napiRunScriptPath', - '5.napiCoerceToNativeBindingObject', - '6.napiAboutSerialize', - '7.napiIsSendable', - '8.napiDefineSendableClass', - '9.napiCreateSendableObjectWithProperties', - '10.napiCreateSendableArray', - '11.napiCreateSendableArrayWithLength', - '12.napiCreateSendableArraybuffer', - '13.napiCreateSendableTypedArray', - '14.napiWrapSendable', - '15.napiWrapSendableWithSize', - '16.napiUnwrapSendable', - '17.napiRemoveWrapSendable' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(17) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiLoadModule') { - // [Start ark_node_api_module_add] - hilog.info(0x0000, 'testTag', 'Test Node-API 2 + 3 = %{public}d', testNapi.add(2, 3)); - // [End ark_node_api_module_add] - this.result = 'napiLoadModuleSuccess'; - } else if (item === '2.napiCreateObjectWithProperties') { - // [Start ark_node_api_module_create_object_properties] - // ArkTS Object相关 napi_create_object_with_properties - let value1 = testNapi.createObjectWithProperties('createObject'); - hilog.info(0x0000, 'testTag', 'Node-API napi_create_object_with_properties:%{public}s', - JSON.stringify(value1)); - // [End ark_node_api_module_create_object_properties] - this.result = 'napiCreateObjectWithPropertiesSuccess'; - } else if (item === '3.napiCreateObjectWithNamedProperties') { - // [Start ark_node_api_module_create_object_name_properties] - // ArkTS Object相关 napi_create_object_with_named_properties - let value2 = testNapi.createObjectWithNameProperties('ls'); - hilog.info(0x0000, 'testTag', 'Node-API napi_create_object_with_named_properties:%{public}s', - JSON.stringify(value2)); - // [End ark_node_api_module_create_object_name_properties] - this.result = 'napiCreateObjectWithNamedPropertiesSuccess'; - } else if (item === '4.napiRunScriptPath') { - // [Start ark_node_api_module_run_script_path] - // 运行指定abc文件 napi_run_script_path - try { // 在此处执行错误返回false,成功就返回true - hilog.info(0x0000, 'testTag', 'Test Node-API napi_run_script_path: %{public}s', - testNapi.runScriptPath()); - // [StartExclude ark_node_api_module_run_script_path] - this.result = 'napiRunScriptPathSuccess'; - // [EndExclude ark_node_api_module_run_script_path] - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_run_script_path errorMessage: %{public}s', - error.message); - // [StartExclude ark_node_api_module_run_script_path] - this.result = 'napiRunScriptPathFail'; - // [EndExclude ark_node_api_module_run_script_path] - } - // [End ark_node_api_module_run_script_path] - } else if (item === '5.napiCoerceToNativeBindingObject') { - // 给ArkTS对象绑定回调和回调所需的参数 napi_coerce_to_native_binding_object - test01(); - this.result = 'napiCoerceToNativeBindingObjectSuccess'; - } else if (item === '6.napiAboutSerialize') { - // [EndExclude ark_napi_serialize_deserialize_delete_serialization_data] - // 序列化和反序列化 - let obj: Obj = { numKey: 500 }; - hilog.info(0x0000, 'testTag', ' Node-API aboutSerialize: %{public}d', testNapi.aboutSerialize(obj)); - // [End ark_napi_serialize_deserialize_delete_serialization_data] - this.result = 'napiAboutSerializeSuccess'; - } else if (item === '7.napiIsSendable') { - // [Start ark_napi_is_sendable] - // Sendable相关 napi_is_sendable - let value = testNapi.isSendable('createObject'); - hilog.info(0x0000, 'testTag', 'Node-API napi_is_sendable: %{public}s', JSON.stringify(value)); - // [End ark_napi_is_sendable] - this.result = 'napiIsSendableSuccess'; - } else if (item === '8.napiDefineSendableClass') { - // [Start ark_napi_define_sendable_class] - // Sendable相关 napi_define_sendable_class - let value = new testNapi.SendableClass(); - hilog.info(0x0000, 'testTag', 'Node-API napi_define_sendable_class: %{public}s', value.str); - // [End ark_napi_define_sendable_class] - this.result = 'napiDefineSendableClassSuccess'; - } else if (item === '9.napiCreateSendableObjectWithProperties') { - // [Start ark_napi_create_sendable_object_with_properties] - // Sendable相关 napi_create_sendable_object_with_properties - let value = testNapi.getSendableObject(); - hilog.info(0x0000, 'testTag', 'Node-API napi_create_sendable_object_with_properties: %{public}s', - JSON.stringify(value)); - // [End ark_napi_create_sendable_object_with_properties] - this.result = 'napiCreateSendableObjectWithPropertiesSuccess'; - } else if (item === '10.napiCreateSendableArray') { - // [Start ark_napi_create_sendable_array] - // Sendable相关 napi_create_sendable_array - let value = testNapi.getSendableArray(); - hilog.info(0x0000, 'testTag', 'Node-API napi_create_sendable_array: %{public}s', - JSON.stringify(value)); - // [End ark_napi_create_sendable_array] - this.result = 'napiCreateSendableArraySuccess'; - } else if (item === '11.napiCreateSendableArrayWithLength') { - // [Start ark_napi_create_sendable_array_with_length] - // Sendable相关 napi_create_sendable_array_with_length - let value = testNapi.getSendableArrayWithLength(); - hilog.info(0x0000, 'testTag', 'Node-API napi_create_sendable_array_with_length: %{public}s', - JSON.stringify(value.length)); - // [End ark_napi_create_sendable_array_with_length] - this.result = 'napiCreateSendableArrayWithLengthSuccess'; - } else if (item === '12.napiCreateSendableArraybuffer') { - // [Start ark_napi_create_sendable_arraybuffer] - // Sendable相关 napi_create_sendable_arraybuffer - testNapi.getSendableArrayBuffer(); - // [End ark_napi_create_sendable_arraybuffer] - this.result = 'napiCreateSendableArraybufferSuccess'; - } else if (item === '13.napiCreateSendableTypedArray') { - // [Start ark_napi_create_sendable_typed_array] - // Sendable相关 napi_create_sendable_typedarray - testNapi.getSendableTypedArray(); - // [End ark_napi_create_sendable_typed_array] - this.result = 'napiCreateSendableTypedArraySuccess'; - } else if (item === '14.napiWrapSendable') { - // [Start ark_napi_wrap_sendable] - // Sendable相关 napi_wrap_sendable - testNapi.wrapSendable(); - // [End ark_napi_wrap_sendable] - this.result = 'napiWrapSendableSuccess'; - } else if (item === '15.napiWrapSendableWithSize') { - // [Start ark_napi_wrap_sendable_with_size] - // Sendable相关 napi_wrap_sendable_with_size - testNapi.wrapSendableWithSize(); - // [End ark_napi_wrap_sendable_with_size] - this.result = 'napiWrapSendableWithSizeSuccess'; - } else if (item === '16.napiUnwrapSendable') { - // [Start ark_napi_unwrap_sendable] - // Sendable相关 napi_unwrap_sendable - testNapi.unwrapSendable(); - // [End ark_napi_unwrap_sendable] - this.result = 'napiUnwrapSendableSuccess'; - } else if (item === '17.napiRemoveWrapSendable') { - // [Start ark_napi_remove_wrap_sendable] - // Sendable相关 napi_remove_wrap_sendable - testNapi.removeWrapSendable(); - // [End ark_napi_remove_wrap_sendable] - this.result = 'napiRemoveWrapSendableSuccess'; - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - .id('List') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/ohosTest.md deleted file mode 100755 index 32212f4447..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIExtendCapabilities/ohosTest.md +++ /dev/null @@ -1,23 +0,0 @@ -# 使用Node-API进行扩展能力功能开发测试用例归档 - -## 用例表 - -| 测试功能 | 预 置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------------------ | ------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 createObjectWithProperties | 位于主页 | 点击文本为1.napiCreateObjectWithProperties的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateObjectWithPropertiesSuccess | Pass | -| ArkTS端成功调用native侧接口createObjectWithNameProperties | 位于主页 | 点击文本为2.napiCreateObjectWithNamedProperties的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateObjectWithNamedPropertiesSuccess | Pass | -| ArkTS端成功调用native侧接口runScriptPath | 位于主页 | 点击文本为3.napiRunScriptPath的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiRunScriptPathSuccess | Pass | -| ArkTS端成功调用native侧接口getAddress,getSetSize,store,erase,clear | 位于主页 | 点击文本为4.napiCoerceToNativeBindingObject的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCoerceToNativeBindingObjectSuccess | Pass | -| ArkTS端成功调用native侧接口aboutSerialize | 位于主页 | 点击文本为5.napiAboutSerialize的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiAboutSerializeSuccess | Pass | -| ArkTS端成功调用native侧接口isSendable | 位于主页 | 点击文本为6.napiIsSendable的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsSendableSuccess | Pass | -| ArkTS端成功调用native侧接口SendableClass | 位于主页 | 点击文本为7.napiDefineSendableClass的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDefineSendableClassSuccess | Pass | -| ArkTS端成功调用native侧接口getSendableObject | 位于主页 | 点击文本为8.napiCreateSendableObjectWithProperties的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSendableObjectWithPropertiesSuccess | Pass | -| ArkTS端成功调用native侧接口getSendableArray | 位于主页 | 点击文本为9.napiCreateSendableArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSendableArraySuccess | Pass | -| ArkTS端成功调用native侧接口getSendableArrayWithLength | 位于主页 | 点击文本为10.napiCreateSendableArrayWithLength的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSendableArrayWithLengthSuccess | Pass | -| ArkTS端成功调用native侧接口getSendableArrayBuffer | 位于主页 | 点击文本为11.napiCreateSendableArraybuffer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSendableArraybufferSuccess | Pass | -| ArkTS端成功调用native侧接口getSendableTypedArray | 位于主页 | 点击文本为12.napiCreateSendableTypedArray的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSendableTypedArraySuccess | Pass | -| ArkTS端成功调用native侧接口wrapSendable | 位于主页 | 点击文本为13.napiWrapSendable的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiWrapSendableSuccess | Pass | -| ArkTS端成功调用native侧接口wrapSendableWithSize | 位于主页 | 点击文本为14.napiWrapSendableWithSize的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiWrapSendableWithSizeSuccess | Pass | -| ArkTS端成功调用native侧接口unwrapSendable | 位于主页 | 点击文本为15.napiUnwrapSendable的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiUnwrapSendableSuccess | Pass | -| ArkTS端成功调用native侧接口removeWrapSendable | 位于主页 | 点击文本为16.napiRemoveWrapSendable的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiRemoveWrapSendableSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/app.json5 deleted file mode 100755 index 6550eba95d..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapifunction", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/element/string.json deleted file mode 100755 index ac005ab950..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIFunction" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/README.md deleted file mode 100755 index 2a7785e156..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行function相关开发 - -### 介绍 - -函数调用允许开发者从Node-API模块中调用ArkTS函数,并传递参数进行调用,或者直接在Node-API模块中创建一个ArkTS方法,本工程中展示的代码详细描述可查如下链接。 - -- [使用Node-API进行function相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-function.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIFunction.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行function相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIFunction.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 11eb088d96..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIFunctio) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 22cb880f7b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_get_cb_info] -#include "napi/native_api.h" - -// napi_get_cb_info -// 获取ArkTS侧入参的的参数信息 -static napi_value GetCbArgs(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - return args[0]; -} - -// 获取ArkTS侧入参的参数个数 -static napi_value GetCbArgQuantity(napi_env env, napi_callback_info info) -{ - size_t argc = 0; - napi_value result = nullptr; - napi_get_cb_info(env, info, &argc, nullptr, nullptr, nullptr); - napi_create_int32(env, argc, &result); - return result; -} - -// 获取ArkTS侧this参数 -static napi_value GetCbContext(napi_env env, napi_callback_info info) -{ - napi_value thisArg = nullptr; - napi_get_cb_info(env, info, nullptr, nullptr, &thisArg, nullptr); - return thisArg; -} -// [End napi_get_cb_info] - -// [Start napi_call_function] -// napi_call_function -static napi_value CallFunction(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value argv[1] = {nullptr}; - // 获取ArkTS侧入参 - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - // 获取全局对象,这里用global是因为napi_call_function的第二个参数是JS函数的this入参。 - napi_value global = nullptr; - napi_get_global(env, &global); - // 调用ArkTS方法 - napi_value result = nullptr; - // 调用napi_call_function时传入的argv的长度必须大于等于argc声明的数量,且被初始化成nullptr - napi_call_function(env, global, argv[0], argc, argv, &result); - return result; -} - -static napi_value ObjCallFunction(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传递的两个参数 - size_t argc = 2; - napi_value argv[2] = {nullptr}; - // 获取ArkTS侧入参 - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - // 调用ArkTS方法 - napi_value result = nullptr; - // 调用napi_call_function时传入的argv的长度必须大于等于argc声明的数量,且被初始化成nullptr - napi_call_function(env, argv[0], argv[1], argc, argv, &result); - return result; -} -// [End napi_call_function] - -// [Start napi_create_function] -// napi_create_function -static napi_value CalculateArea(napi_env env, napi_callback_info info) -{ - // 获取ArkTS侧传递的两个参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - double width = 0; - napi_get_value_double(env, args[0], &width); - double height = 0; - napi_get_value_double(env, args[1], &height); - napi_value area = nullptr; - napi_create_double(env, width * height, &area); - return area; -} -// [End napi_create_function] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"getCbArgs", nullptr, GetCbArgs, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getCbArgQuantity", nullptr, GetCbArgQuantity, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getCbContext", nullptr, GetCbContext, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"callFunction", nullptr, CallFunction, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"objCallFunction", nullptr, ObjCallFunction, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_value fn = nullptr; - napi_create_function(env, nullptr, 0, CalculateArea, nullptr, &fn); - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - napi_set_named_property(env, exports, "calculateArea", fn); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index ceacdecece..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_get_cb_info_api] -export const getCbArgs: (arg: T) => T; // napi_get_cb_info - -// getCbArgQuantity的入参由用户自定义,在此用例中,我们用两个入参,一个是string,一个是number -export const getCbArgQuantity: (str: string, num: number) => number; - -export const getCbContext: () => Object; -// [End napi_get_cb_info_api] - -// [Start napi_call_function_api] -export const callFunction: (func: Function) => number; // napi_call_function - -export const objCallFunction: (obj: Object, func: Function) => number; -// [End napi_call_function_api] - -// [Start napi_create_function_api] -export const calculateArea: (width: number, height: number) => number; // napi_create_function -// [End napi_create_function_api] diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 1734ab6667..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start ark_napi_get_cb_info] -import { hilog } from '@kit.PerformanceAnalysisKit'; -import testNapi from 'libentry.so'; - -function summation(arr: Array) { - let sum: number = 0; - for (let i = 0; i < arr.length; i++) { - sum += arr[i]; - } - return sum; -} - -const str = 'message'; -const arr = [0, 1, 2, 3, 4, 5]; -const num = 526; - -class Student { - name: string; - age: number; - score: number; - - constructor(name: string, age: number, score: number) { - this.name = name; - this.age = age; - this.score = score; - } -} - -// [StartExclude ark_napi_get_cb_info] -// [Start ark_napi_call_function] -function returnNumber() { - return 10; -} - -class Person { - age(): number { - return 11; - } -} - -// [StartExclude ark_napi_call_function] -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiGetCbInfo', - '2.napiCallFunction', - '3.napiCreateFunction' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(25) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiGetCbInfo') { - // [EndExclude ark_napi_get_cb_info] - // napi_get_cb_info - let student = new Student('Alice', 18, 100); - // 获取参数 - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get string arg:%{public}s', - testNapi.getCbArgs(str)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get array arg:%{public}s ', - testNapi.getCbArgs(arr).toString()); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get num arg:%{public}d ', - testNapi.getCbArgs(num)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get undefined arg:%{public}s ', - testNapi.getCbArgs(undefined)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get object arg:%{public}s ', - JSON.stringify(testNapi.getCbArgs(student))); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get function arg:%{public}d ', - testNapi.getCbArgs(summation(arr))); - // 获取参数个数 - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get arg quantity:%{public}d ', - testNapi.getCbArgQuantity(str, num)); - // 获取上下文 - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_cb_info get thisArg:%{public}s ', - testNapi.getCbContext().toString()); - // [End ark_napi_get_cb_info] - this.result = 'napiGetCbInfoSuccess'; - } else if (item === '2.napiCallFunction') { - // [EndExclude ark_napi_call_function] - // napi_call_function - const person = new Person(); - hilog.info(0x0000, 'testTag', 'Test Node-API call_function:%{public}d', - testNapi.callFunction(returnNumber)); - hilog.info(0x0000, 'testTag', 'Test Node-API call_function:%{public}d', - testNapi.objCallFunction(person, person.age)); - // [End ark_napi_call_function] - this.result = 'napiCallFunctionSuccess'; - } else if (item === '3.napiCreateFunction') { - // [Start ark_napi_create_function] - // napi_create_function - hilog.info(0x0000, 'testTag', 'Test Node-API create_function:%{public}d ', - testNapi.calculateArea(1.2, 4)); - // [End ark_napi_create_function] - this.result = 'napiCreateFunctionSuccess'; - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/ohosTest.md deleted file mode 100755 index 55d56487ab..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIFunction/ohosTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# 使用Node-API进行function相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------------------ | ------------ | ---------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 getCbArgs,getCbArgQuantity,getCbContext | 位于主页 | 点击文本为1.napiGetCbInfo的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetCbInfoSuccess | Pass | -| ArkTS端成功调用native侧接口callFunction,objCallFunction | 位于主页 | 点击文本为2.napiCallFunction的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCallFunctionSuccess | Pass | -| ArkTS端成功调用native侧接口calculateArea | 位于主页 | 点击文本为3.napiCreateFunction的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateFunctionSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/app.json5 deleted file mode 100755 index 0f394f4281..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapilifecycle", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/element/string.json deleted file mode 100755 index 76f1edf47c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPILifeCycle" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/README.md deleted file mode 100755 index 3a95e5bfa4..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行life-cycle相关开发 - -### 介绍 - -在Node-API中,napi_value是一个表示ArkTS值的抽象类型,它可以表示任何ArkTS值,包括基本类型(如数字、字符串、布尔值)和复杂对象类型(如数组、函数、对象等),napi_value的生命周期与其在ArkTS中的对应值的生命周期紧密相关。当ArkTS值被垃圾回收时,与之关联的napi_value也将不再有效。重要的是不要在ArkTS值不再存在时尝试使用napi_value,框架层的scope通常用于管理napi_value的生命周期。在Node-API中,可以使用napi_open_handle_scope和napi_close_handle_scope函数来创建和销毁scope。通过在scope内创建napi_value,可以确保在scope结束时自动释放napi_value,避免内存泄漏,napi_ref是一个Node-API类型,用于管理napi_value的生命周期。napi_ref允许您在napi_value的生命周期内保持对其的引用,即使它已经超出了其原始上下文的范围。这使得您可以在不同的上下文中共享napi_value,并确保在不再需要时正确释放其内存,本工程中展示的代码详细描述可查如下链接。 - -- [使用Node-API进行life-cycle相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-life-cycle.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPILifeCycle.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行life-cycle相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPILifeCycle.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 9cb24a5a1f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPILifeCycle) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index cdc6424c3e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * 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 "hilog/log.h" -#include "napi/native_api.h" - -// [Start napi_open_close_handle_scope] -// napi_open_handle_scope、napi_close_handle_scope -static napi_value HandleScopeTest(napi_env env, napi_callback_info info) -{ - // 通过调用napi_open_handle_scope来创建一个句柄作用域 - napi_handle_scope scope; - napi_open_handle_scope(env, &scope); - // 在句柄作用域内创建一个obj - napi_value obj = nullptr; - napi_create_object(env, &obj); - // 在对象中添加属性 - napi_value value = nullptr; - napi_create_string_utf8(env, "handleScope", NAPI_AUTO_LENGTH, &value); - napi_set_named_property(env, obj, "key", value); - // 在作用域内获取obj的属性并返回 - napi_value result = nullptr; - napi_get_named_property(env, obj, "key", &result); - // 关闭句柄作用域,自动释放在该作用域内创建的对象句柄 - napi_close_handle_scope(env, scope); - // 此处的result能够得到值“handleScope” - return result; -} - -static napi_value HandleScope(napi_env env, napi_callback_info info) -{ - // 通过调用napi_open_handle_scope来创建一个句柄作用域 - napi_handle_scope scope; - napi_open_handle_scope(env, &scope); - // 在句柄作用域内创建一个obj - napi_value obj = nullptr; - napi_create_object(env, &obj); - // 在对象中添加属性 - napi_value value = nullptr; - napi_create_string_utf8(env, "handleScope", NAPI_AUTO_LENGTH, &value); - napi_set_named_property(env, obj, "key", value); - // 关闭句柄作用域,自动释放在该作用域内创建的对象句柄 - napi_close_handle_scope(env, scope); - // 在作用域外获取obj的属性并返回,此处只能得到“undefined” - napi_value result = nullptr; - napi_get_named_property(env, obj, "key", &result); - return result; -} -// [End napi_open_close_handle_scope] - -// [Start napi_open_close_escapable_handle_scope] -// napi_open_escapable_handle_scope、napi_close_escapable_handle_scope、napi_escape_handle -static napi_value EscapableHandleScopeTest(napi_env env, napi_callback_info info) -{ - // 创建一个可逃逸的句柄作用域 - napi_escapable_handle_scope scope; - napi_open_escapable_handle_scope(env, &scope); - // 在可逃逸的句柄作用域内创建一个obj - napi_value obj = nullptr; - napi_create_object(env, &obj); - // 在对象中添加属性 - napi_value value = nullptr; - napi_create_string_utf8(env, "Test napi_escapable_handle_scope", NAPI_AUTO_LENGTH, &value); - napi_set_named_property(env, obj, "key", value); - // 调用napi_escape_handle将对象逃逸到作用域之外 - napi_value escapedObj = nullptr; - napi_escape_handle(env, scope, obj, &escapedObj); - // 关闭可逃逸的句柄作用域,清理资源 - napi_close_escapable_handle_scope(env, scope); - // 在获取逃逸后的obj:escapedObj的属性并返回,此处也能够得到“napi_escapable_handle_scope” - napi_value result = nullptr; - // 为了验证逃逸的实现,可以在此处获取obj的属性,此处会得到“undefined” - napi_get_named_property(env, escapedObj, "key", &result); - return result; -} -// [End napi_open_close_escapable_handle_scope] - -// [Start napi_create_delete_reference] -// 创建一个指向napi_ref类型的指针,用于存储创建的引用。在调用napi_create_reference函数之前,你需要分配一个napi_ref类型的变量,并将其地址传递给result位置的参数 -napi_ref g_ref; - -void Finalizer(napi_env env, void *data, void *hint) -{ - // 执行资源清理操作 - OH_LOG_INFO(LOG_APP, "Node-API: Use terminators to release resources."); -} - -static napi_value CreateReference(napi_env env, napi_callback_info info) -{ - napi_value obj = nullptr; - napi_create_object(env, &obj); - napi_value value = nullptr; - napi_create_string_utf8(env, "CreateReference", NAPI_AUTO_LENGTH, &value); - // 将键值对添加到对象中 - napi_set_named_property(env, obj, "key", value); - // [StartExclude napi_create_delete_reference] - // 创建对ArkTS对象的引用 - napi_status status = napi_create_reference(env, obj, 1, &g_ref); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_create_reference fail"); - return nullptr; - } - // [EndExclude napi_create_delete_reference] - // 添加终结器 - void *data = {}; - napi_add_finalizer(env, obj, data, Finalizer, nullptr, &g_ref); - // 增加传入引用的引用计数并返回生成的引用计数 - uint32_t result = 0; - napi_reference_ref(env, g_ref, &result); - OH_LOG_INFO(LOG_APP, "napi_reference_ref, count = %{public}d.", result); - uint32_t numCount = 2; - if (result != numCount) { - // 若传入引用的引用计数未增加,则抛出错误 - napi_throw_error(env, nullptr, "napi_reference_ref fail"); - return nullptr; - } - return obj; -} - -static napi_value UseReference(napi_env env, napi_callback_info info) -{ - napi_value obj = nullptr; - // 通过调用napi_get_reference_value获取引用的ArkTS对象 - napi_status status = napi_get_reference_value(env, g_ref, &obj); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_get_reference_value fail"); - return nullptr; - } - // 将获取到的对象返回 - return obj; -} - -static napi_value DeleteReference(napi_env env, napi_callback_info info) -{ - // 减少传入引用的引用计数并返回生成的引用计数 - uint32_t result = 0; - napi_value count = nullptr; - napi_reference_unref(env, g_ref, &result); - OH_LOG_INFO(LOG_APP, "napi_reference_ref, count = %{public}d.", result); - uint32_t numCount = 1; - if (result != numCount) { - // 若传入引用的引用计数未减少,则抛出错误 - napi_throw_error(env, nullptr, "napi_reference_unref fail"); - return nullptr; - } - // 通过调用napi_delete_reference删除对ArkTS对象的引用 - napi_status status = napi_delete_reference(env, g_ref); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_delete_reference fail"); - return nullptr; - } - napi_value returnResult = nullptr; - napi_create_string_utf8(env, "napi_delete_reference success", NAPI_AUTO_LENGTH, &returnResult); - return returnResult; -} -// [End napi_create_delete_reference] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"handleScopeTest", nullptr, HandleScopeTest, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"handleScope", nullptr, HandleScope, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"escapableHandleScopeTest", nullptr, EscapableHandleScopeTest, nullptr, nullptr, nullptr, napi_default, - nullptr}, - {"createReference", nullptr, CreateReference, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"useReference", nullptr, UseReference, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"deleteReference", nullptr, DeleteReference, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 23c45532e0..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_open_close_handle_scope_api] -export const handleScopeTest: () => string; // napi_open_handle_scope、napi_close_handle_scope - -export const handleScope: () => string; -// [End napi_open_close_handle_scope_api] - -// [Start napi_open_close_escapable_handle_scope_api] -export const escapableHandleScopeTest: () => string; // napi_open_escapable_handle_scope、napi_close_escapable_handle_scope、napi_escape_handle -// [End napi_open_close_escapable_handle_scope_api] - -// [Start napi_create_delete_reference_api] -export const createReference: () => Object | void; // napi_add_finalizer - -export const useReference: () => Object | void; - -export const deleteReference: () => string | void; -// [End napi_create_delete_reference_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 4d86ca8563..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiOpenHandleScope', - '2.napiOpenEscapableHandleScope', - '3.napiAddFinalizer' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(20) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiOpenHandleScope') { - // [Start ark_napi_open_close_handle_scope] - // napi_open_handle_scope napi_close_handle_scope - try { - hilog.info(0x0000, 'testTag', 'Test Node-API handleScopeTest: %{public}s', - testNapi.handleScopeTest()); - hilog.info(0x0000, 'testTag', 'Test Node-API handleScope: %{public}s', testNapi.handleScope()); - // [StartExclude ark_napi_open_close_handle_scope] - this.result = 'napiOpenHandleScopeSuccess'; - // [EndExclude ark_napi_open_close_handle_scope] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API handleScopeTest errorCode: %{public}s, errorMessage: %{public}s', error.code, - error.message); - // [StartExclude ark_napi_open_close_handle_scope] - this.result = 'napiOpenHandleScopeFail'; - // [EndExclude ark_napi_open_close_handle_scope] - } - // [End ark_napi_open_close_handle_scope] - } else if (item === '2.napiOpenEscapableHandleScope') { - // [Start ark_napi_open_close_escapable_handle_scope] - // napi_open_escapable_handle_scope napi_close_escapable_handle_scope、napi_escape_handle - try { - hilog.info(0x0000, 'testTag', 'Test Node-API EscapableHandleScopeTest: %{public}s', - testNapi.escapableHandleScopeTest()); - // [StartExclude ark_napi_open_close_escapable_handle_scope] - this.result = 'napiOpenEscapableHandleScopeSuccess'; - // [EndExclude ark_napi_open_close_escapable_handle_scope] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API EscapableHandleScopeTest errorCode: %{public}s, errorMessage: %{public}s', - error.code, - error.message); - // [StartExclude ark_napi_open_close_escapable_handle_scope] - this.result = 'napiOpenEscapableHandleScopeFail'; - // [EndExclude ark_napi_open_close_escapable_handle_scope] - } - // [End ark_napi_open_close_escapable_handle_scope] - } else if (item === '3.napiAddFinalizer') { - // [Start ark_napi_create_delete_reference] - // napi_add_finalizer - try { - hilog.info(0x0000, 'testTag', 'Test Node-API createReference: %{public}s', - JSON.stringify(testNapi.createReference())); - hilog.info(0x0000, 'testTag', 'Test Node-API useReference: %{public}s', - JSON.stringify(testNapi.useReference())); - hilog.info(0x0000, 'testTag', 'Test Node-API deleteReference: %{public}s', - testNapi.deleteReference()); - // [StartExclude ark_napi_create_delete_reference] - this.result = 'napiAddFinalizerSuccess'; - // [EndExclude ark_napi_create_delete_reference] - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API ReferenceTest errorCode: %{public}s, errorMessage: %{public}s', error.code, - error.message); - // [StartExclude ark_napi_create_delete_reference] - this.result = 'napiAddFinalizerFail'; - // [EndExclude ark_napi_create_delete_reference] - } - // [End ark_napi_create_delete_reference] - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/ohosTest.md deleted file mode 100755 index da6467447e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPILifeCycle/ohosTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# 使用Node-API进行life-cycle相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------------------ | ------------ | ---------------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 handleScopeTest,handleScope | 位于主页 | 点击文本为1.napiOpenHandleScope的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiOpenHandleScopeSuccess | Pass | -| ArkTS端成功调用native侧接口createArrayWithLength | 位于主页 | 点击文本为2.escapableHandleScopeTest的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiOpenEscapableHandleScopeSuccess | Pass | -| ArkTS端成功调用native侧接口createReference,useReference,deleteReference | 位于主页 | 点击文本为3.napiAddFinalizer的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiAddFinalizerSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/app.json5 deleted file mode 100755 index c0e25e886a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiobject", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/element/string.json deleted file mode 100755 index 6177c3d7c8..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIObject" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/README.md deleted file mode 100755 index dcffc96cc1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行object相关开发 - -### 介绍 - -使用Node-API接口进行object相关开发,处理ArkTS对象的基本操作的功能,例如创建对象、获取原型、冻结和密封对象,检查对象的类型等。这些操作是在处理ArkTS对象时非常常见的,提供了一种与ArkTS对象交互的方式,本工程中展示的代码详细描述可查如下链接。 - -- [使用Node-API进行object相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-object.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIObject.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行object相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIObject.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 63f331b928..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIObject) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index e5259d2a34..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/* - * 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 -#include -#include "hilog/log.h" -#include "napi/native_api.h" - -// napi_get_prototype -static napi_value GetPrototype(napi_env env, napi_callback_info info) -{ - // 获取并解析传参 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - napi_value result = nullptr; - // 获取此对象的原型对象,将结果返回到napi_value类型的变量result中 - napi_get_prototype(env, args[0], &result); - return result; -} -// napi_create_object -napi_value NewObject(napi_env env, napi_callback_info info) -{ - napi_value object = nullptr; - // 创建一个空对象 - napi_create_object(env, &object); - // 设置对象的属性 - napi_value name = nullptr; - // 设置属性名为"name" - napi_create_string_utf8(env, "name", NAPI_AUTO_LENGTH, &name); - napi_value value = nullptr; - // 设置属性值为"Hello from Node-API!" - napi_create_string_utf8(env, "Hello from Node-API!", NAPI_AUTO_LENGTH, &value); - // 将属性设置到对象上 - napi_set_property(env, object, name, value); - return object; -} -// napi_object_freeze -static napi_value ObjectFreeze(napi_env env, napi_callback_info info) -{ - // 接受一个ArkTS侧传入的object - size_t argc = 1; - napi_value argv[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - - // 调用接口napi_object_freeze将传入的object冻结 - napi_value objFreeze = argv[0]; - napi_status status = napi_object_freeze(env, objFreeze); - if (status == napi_ok) { - OH_LOG_INFO(LOG_APP, "Node-API napi_object_freeze success"); - } - // 将冻结后的object传回ArkTS侧 - return objFreeze; -} -// napi_object_seal -static napi_value ObjectSeal(napi_env env, napi_callback_info info) -{ - // 接受一个ArkTS侧传入的object - size_t argc = 1; - napi_value argv[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - // 调用接口napi_object_seal将传入的object封闭,使其无法添加新的属性 - napi_value objSeal = argv[0]; - napi_status status = napi_object_seal(env, objSeal); - if (status == napi_ok) { - OH_LOG_INFO(LOG_APP, "Node-API napi_object_seal success"); - } - // 将封闭后的object传回ArkTS侧 - return objSeal; -} -// napi_typeof -static napi_value NapiTypeof(napi_env env, napi_callback_info info) -{ - // 接受一个入参 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 调用napi_typeof判断传入ArkTS参数类型 - napi_valuetype valueType; - napi_status status = napi_typeof(env, args[0], &valueType); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_typeof fail"); - return nullptr; - } - // 将结果转成napi_value类型返回。 - napi_value returnValue = nullptr; - switch (valueType) { - case napi_undefined: - napi_create_string_utf8(env, "Input type is napi_undefined", NAPI_AUTO_LENGTH, &returnValue); - break; - case napi_null: - napi_create_string_utf8(env, "Input type is napi_null", NAPI_AUTO_LENGTH, &returnValue); - break; - case napi_boolean: - napi_create_string_utf8(env, "Input type is napi_boolean", NAPI_AUTO_LENGTH, &returnValue); - break; - case napi_number: - napi_create_string_utf8(env, "Input type is napi_number", NAPI_AUTO_LENGTH, &returnValue); - break; - case napi_string: - napi_create_string_utf8(env, "Input type is napi_string", NAPI_AUTO_LENGTH, &returnValue); - break; - case napi_object: - napi_create_string_utf8(env, "Input type is napi_object", NAPI_AUTO_LENGTH, &returnValue); - break; - case napi_function: - napi_create_string_utf8(env, "Input type is napi_function", NAPI_AUTO_LENGTH, &returnValue); - break; - case napi_bigint: - napi_create_string_utf8(env, "Input type is napi_bigint", NAPI_AUTO_LENGTH, &returnValue); - break; - default: - napi_create_string_utf8(env, "unknown", NAPI_AUTO_LENGTH, &returnValue); - } - return returnValue; -} -// napi_instanceof -static napi_value NapiInstanceof(napi_env env, napi_callback_info info) -{ - // 接受两个入参 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 调用napi_instanceof接口判断给定object是否为给定constructor的实例 - bool result = true; - napi_status status = napi_instanceof(env, args[0], args[1], &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_instanceof fail"); - return nullptr; - } - // 将结果转成napi_value类型返回 - napi_value returnValue = nullptr; - napi_get_boolean(env, result, &returnValue); - - return returnValue; -} - -#define NUMBERINT_FOUR 4 -// 定义一个静态常量napi_type_tag数组存储类型标签 -static const napi_type_tag TagsData[NUMBERINT_FOUR] = { - {0x9e4b2449547061b3, 0x33999f8a6516c499}, - {0x1d55a794c53a726d, 0x43633f509f9c944e}, - // 用于表示无标签或默认标签 - {0, 0}, - {0x6a971439f5b2e5d7, 0x531dc28a7e5317c0}, -}; -// napi_type_tag_object -static napi_value SetTypeTagToObject(napi_env env, napi_callback_info info) -{ - // 获取函数调用信息和参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取索引数字转换为napi_value - int32_t index = 0; - napi_get_value_int32(env, args[1], &index); - // 给参数(对象)设置类型标签 - napi_status status = napi_type_tag_object(env, args[0], &TagsData[index]); - if (status != napi_ok) { - napi_throw_error(env, "Reconnect error", "napi_type_tag_object failed"); - return nullptr; - } - // 将bool结果转换为napi_value并返回 - napi_value result = nullptr; - napi_get_boolean(env, true, &result); - return result; -} -// napi_check_object_type_tag -static napi_value CheckObjectTypeTag(napi_env env, napi_callback_info info) -{ - // 获取函数调用信息和参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取索引数字转换为napi_value - int32_t index = 0; - napi_get_value_int32(env, args[1], &index); - // 检查对象的类型标签 - bool checkResult = true; - napi_check_object_type_tag(env, args[0], &TagsData[index], &checkResult); - // 将bool结果转换为napi_value并返回 - napi_value checked = nullptr; - napi_get_boolean(env, checkResult, &checked); - - return checked; -} - -// 用于释放外部数据的回调函数 -void finalizeCallback(napi_env env, void *data, void *hint) -{ - // 释放外部数据 - free(data); -} -// napi_create_external -static napi_value GetExternalType(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取参数的数据类型 - napi_valuetype valueType; - napi_typeof(env, args[0], &valueType); - napi_value returnValue = nullptr; - if (valueType == napi_external) { - // 如果数据类型是napi_external,则返回true - napi_get_boolean(env, true, &returnValue); - } else { - napi_get_boolean(env, false, &returnValue); - } - return returnValue; -} - -static napi_value CreateExternal(napi_env env, napi_callback_info info) -{ - // 设置外部数据大小为10 - const size_t dataSize = 10; - // 分配外部数据 - void *data = malloc(dataSize); - // 初始化外部数据 - memset(data, 0, dataSize); - napi_value result = nullptr; - // 返回带有外部数据的对象 - napi_status status = napi_create_external(env, data, finalizeCallback, nullptr, &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, " Node-API Failed to create external data"); - return nullptr; - } - return result; -} -// napi_get_value_external -static int g_external = 5; -static napi_value GetValueExternal(napi_env env, napi_callback_info info) -{ - // 创建外部数据 - int *data = &g_external; - napi_value setExternal = nullptr; - napi_create_external(env, data, nullptr, nullptr, &setExternal); - // 获得外部数据的值 - void *getExternal; - napi_get_value_external(env, setExternal, &getExternal); - // 返回获得到的外部数据 - napi_value result = nullptr; - napi_create_int32(env, *(int *)getExternal, &result); - return result; -} -// napi_create_symbol -static napi_value CreateSymbol(napi_env env, napi_callback_info info) -{ - napi_value result = nullptr; - const char *des = "only"; - // 使用napi_create_string_utf8创建描述字符串 - napi_create_string_utf8(env, des, NAPI_AUTO_LENGTH, &result); - napi_value returnSymbol = nullptr; - // 创建一个symbol类型,并返回 - napi_create_symbol(env, result, &returnSymbol); - return returnSymbol; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"getPrototype", nullptr, GetPrototype, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createObject", nullptr, NewObject, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"objectFreeze", nullptr, ObjectFreeze, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"objectSeal", nullptr, ObjectSeal, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiTypeof", nullptr, NapiTypeof, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiInstanceof", nullptr, NapiInstanceof, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"setTypeTagToObject", nullptr, SetTypeTagToObject, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"checkObjectTypeTag", nullptr, CheckObjectTypeTag, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createExternal", nullptr, GetExternalType, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getExternalType", nullptr, CreateExternal, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getValueExternal", nullptr, GetValueExternal, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createSymbol", nullptr, CreateSymbol, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 8a29db2752..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 getPrototype: (object: Object) => Object; // napi_get_prototype - -export const createObject: () => { name: string }; // napi_create_object - -export interface Obj { - data: number - message: string -} - -export const objectFreeze: (objFreeze: Object) => Obj; // napi_object_freeze - -export interface Obj1 { - data: number - message: string - id: number -} - -export const objectSeal: (objSeal: Object) => Obj1; // napi_object_seal - -export const napiTypeof: (value: T) => string | void; // napi_typeof - -export const napiInstanceof: (date: Object, construct: Object) => boolean | void; // napi_instanceof - -export const setTypeTagToObject: (obj: Object, index: number) => boolean | void; // napi_type_tag_object - -export const checkObjectTypeTag: (obj: Object, index: number) => boolean; // napi_check_object_type_tag - -export const createExternal: () => Object; // napi_create_external - -export const getExternalType: (externalData: Object) => boolean; // napi_create_external - -export const getValueExternal: () => number; // napi_get_value_external - -export const createSymbol: () => symbol; // napi_create_symbol \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 42e73a977b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,234 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; -import { napiGetPrototype } from './napiGetPrototype'; - -// 定义一个类 -class Person { - // 属性 - name: string; - age: number; - - // 构造函数 - constructor(name: string, age: number) { - this.name = name; - this.age = age; - } -} - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiGetPrototype', - '2.napiCreateObject', - '3.napiObjectFreeze', - '4.napiObjectSeal', - '5.napiTypeof', - '6.napiInstanceof', - '7.napiTypeTagObject', - '8.napiCreateExternal', - '9.napiGetValueExternal', - '10.napiCreateSymbol' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(22) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiGetPrototype') { - napiGetPrototype(); - this.result = 'napiGetPrototypeSuccess'; - } else if (item === '2.napiCreateObject') { - // napi_create_object - try { - const myObject = testNapi.createObject(); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_object: %{public}s', myObject.name); - this.result = 'napiCreateObjectSuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', - 'Test Node-API napi_create_object errorCode: %{public}s, errorMessage: %{public}s', error.code, - error.message); - this.result = 'napiCreateObjectFail'; - } - } else if (item === '3.napiObjectFreeze') { - // napi_object_freeze - try { - class Obj { - public data: number = 0 - public message: string = '' - } - - let obj: Obj = { data: 0, message: 'hello world' }; - let objFreeze = testNapi.objectFreeze(obj); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_object_freeze: %{public}s', (objFreeze.data = 1)); - this.result = 'napiObjectFreezeSuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_object_freeze error: %{public}s', error.message); - this.result = 'napiObjectFreezeFail'; - } - } else if (item === '4.napiObjectSeal') { - // napi_object_seal - try { - class Obj { - public data: number = 0 - public message: string = '' - // 可选属性 - public address?: number = 0 - } - - let obj: Obj = { data: 0, message: 'hello world' }; - let objSeal = testNapi.objectSeal(obj); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_object_seal: %{public}s', objSeal.message); - objSeal.data = 1; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_object_seal: %{public}d', objSeal.data); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_object_seal: %{public}d', (objSeal.id = 1)); - this.result = 'napiObjectSealSuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_object_seal error: %{public}s', error.message); - this.result = 'napiObjectSealFail'; - } - } else if (item === '5.napiTypeof') { - // napi_typeof - try { - let varUndefined: undefined; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', - testNapi.napiTypeof(varUndefined)); - let varNull: null = null; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', - testNapi.napiTypeof(varNull)); - let varTrue = true; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', - testNapi.napiTypeof(varTrue)); - let varNum = 1; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', testNapi.napiTypeof(varNum)); - let varString = 'str'; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', - testNapi.napiTypeof(varString)); - - class Obj { - public id: number = 0 - public name: string = '' - } - - let varObject: Obj = { id: 1, name: 'LiLei' }; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', - testNapi.napiTypeof(varObject)); - const addNum = (a: number, b: number): number => a * b; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', testNapi.napiTypeof(addNum)); - let varBigint = BigInt('1234567890123456789012345678901234567890'); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_typeof: %{public}s', - testNapi.napiTypeof(varBigint)); - this.result = 'napiTypeofSuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_typeof error: %{public}s', error.message); - this.result = 'napiTypeofFail'; - } - } else if (item === '6.napiInstanceof') { - // napi_instanceof - try { - class Person { - public name: string; - public age: number; - - constructor(name: string, age: number) { - this.name = name; - this.age = age; - } - } - - const person = new Person('Alice', 30); - - class Obj { - public data: number = 0 - public message: string = '' - } - - let obj: Obj = { data: 0, message: 'hello world' }; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_instanceof: %{public}s', - testNapi.napiInstanceof(person, Person)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_instanceof: %{public}s', - testNapi.napiInstanceof(obj, Person)); - this.result = 'napiInstanceofSuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_instanceof error: %{public}s', error.message); - this.result = 'napiInstanceofFail'; - } - } else if (item === '7.napiTypeTagObject') { - - // napi_type_tag_object and napi_check_object_type_tag - class Obj { - public data: number = 0 - public message: string = '' - } - - let objA: Obj = { data: 0, message: 'hello world' }; - let objB: Obj = { data: 10, message: 'typetag' }; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_type_tag_object objA -> 0: %{public}s', - testNapi.setTypeTagToObject(objA, 0)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_type_tag_object objB -> 0: %{public}s', - testNapi.setTypeTagToObject(objB, 0)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_check_object_type_tag objA -> 0: %{public}s', - testNapi.checkObjectTypeTag(objA, 0)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_check_object_type_tag objB -> 1: %{public}s', - testNapi.checkObjectTypeTag(objB, 1)); - this.result = 'napiTypeTagObjectSuccess'; - } else if (item === '8.napiCreateExternal') { - // napi_create_external - const externalData = testNapi.createExternal(); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_external:%{public}s', - testNapi.getExternalType(externalData)); - this.result = 'napiCreateExternalSuccess'; - } else if (item === '9.napiGetValueExternal') { - // napi_get_value_external - hilog.info(0x0000, 'Node-API', 'get_value_external:%{public}d', testNapi.getValueExternal()); - this.result = 'napiGetValueExternalSuccess'; - } else if (item === '10.napiCreateSymbol') { - // napi_create_symbol - let varSymbol = testNapi.createSymbol(); - hilog.info(0x0000, 'Node-API', 'createSymbol:%{public}s', typeof varSymbol); - this.result = 'napiCreateSymbolSuccess'; - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/ohosTest.md deleted file mode 100755 index a08063b27f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIObject/ohosTest.md +++ /dev/null @@ -1,17 +0,0 @@ -# 使用Node-API进行object相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------------------ | ------------ | ------------------------------------------ | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 napiGetPrototype | 位于主页 | 点击文本为1.napiGetPrototype的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetPrototypeSuccess | Pass | -| ArkTS端成功调用native侧接口createObject | 位于主页 | 点击文本为2.napiCreateObject的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateObjectSuccess | Pass | -| ArkTS端成功调用native侧接口objectFreeze | 位于主页 | 点击文本为3.napiObjectFreeze的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiObjectFreezeSuccess | Pass | -| ArkTS端成功调用native侧接口objectSeal | 位于主页 | 点击文本为4.napiObjectSeal的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiObjectSealSuccess | Pass | -| ArkTS端成功调用native侧接口napiTypeOf | 位于主页 | 点击文本为5.napiTypeof的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiTypeofSuccess | Pass | -| ArkTS端成功调用native侧接口napiInstanceof | 位于主页 | 点击文本为6.napiInstanceof的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiInstanceofSuccess | Pass | -| ArkTS端成功调用native侧接口setTypeTagToObject,checkObjectTypeTag | 位于主页 | 点击文本为7.napiTypeTagObject的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiTypeTagObjectSuccess | Pass | -| ArkTS端成功调用native侧接口createExternal,getExternalType | 位于主页 | 点击文本为8.napiCreateExternal的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateExternalSuccess | Pass | -| ArkTS端成功调用native侧接口getValueExternal | 位于主页 | 点击文本为9.napiGetValueExternal的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueExternalSuccess | Pass | -| ArkTS端成功调用native侧接口createSymbol | 位于主页 | 点击文本为10.napiCreateSymbol的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCreateSymbolSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/app.json5 deleted file mode 100755 index 41d00c9b12..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiprimitive", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/element/string.json deleted file mode 100755 index 95d1cf67e2..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIPrimitive" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/README.md deleted file mode 100755 index 86c2a03108..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API接口进行primitiv类相关开发 - -### 介绍 - -在使用Node-API接口时,开发人员可以实现在Node-API模块中与ArkTS对象的交互,并进行数据转换和获取特定对象的操作,它们在不同的场景中发挥着重要的作用,使开发人员能够更灵活地处理ArkTS值和对象,本工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [使用Node-API接口进行primitiv类相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-primitive.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIPrimitive.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API接口进行primitiv类相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIPrimitive.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 409f10fe25..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIPrimitive) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index be73865685..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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" - -// [Start napi_coerce_to_bool] -// napi_coerce_to_bool -static napi_value CoerceToBool(napi_env env, napi_callback_info info) -{ - // 获取并解析传进的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 将传入的值转换为布尔值 - napi_value result = nullptr; - napi_coerce_to_bool(env, args[0], &result); - // 返回强转之后的ArkTS boolean值 - return result; -} -// [End napi_coerce_to_bool] - -// [Start napi_coerce_to_number] -// napi_coerce_to_number -static napi_value CoerceToNumber(napi_env env, napi_callback_info info) -{ - // 获取并解析传进的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 将传入的值转换为number值 - napi_value result = nullptr; - napi_coerce_to_number(env, args[0], &result); - return result; -} -// [End napi_coerce_to_number] - -// [Start napi_coerce_to_object] -// napi_coerce_to_object -static napi_value CoerceToObject(napi_env env, napi_callback_info info) -{ - // 获取并解析传进的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_value obj = nullptr; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 将传入的值转换为Object值 - napi_coerce_to_object(env, args[0], &obj); - return obj; -} -// [End napi_coerce_to_object] - -// [Start napi_coerce_to_string] -// napi_coerce_to_string -static napi_value CoerceToString(napi_env env, napi_callback_info info) -{ - // 获取并解析传进的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 将传入的值转换为string - napi_value str = nullptr; - napi_coerce_to_string(env, args[0], &str); - return str; -} -// [End napi_coerce_to_string] - -// [Start napi_get_boolean] -// napi_get_boolean -static napi_value GetBoolean(napi_env env, napi_callback_info info) -{ - // 传入两个参数并解析 - size_t argc = 2; - napi_value argv[2]; - napi_valuetype data; - napi_valuetype value; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - // 判断两个参数类型值 - napi_typeof(env, argv[0], &data); - napi_typeof(env, argv[1], &value); - - napi_value returnValue = nullptr; - // 判断两个类型值是否相等,获取结果的布尔值 - napi_get_boolean(env, data == value, &returnValue); - // 返回结果 - return returnValue; -} -// [End napi_get_boolean] - -// [Start napi_get_value_bool] -// napi_get_value_bool -static napi_value GetValueBool(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - bool boolC = false; - napi_status status = napi_get_value_bool(env, args[0], &boolC); - if (status == napi_boolean_expected) { - // 如果napi_get_value_bool成功会返回napi_ok,如果传入一个非布尔值则会返回napi_boolean_expected - return nullptr; - } - napi_value boolNapi = nullptr; - napi_get_boolean(env, boolC, &boolNapi); - return boolNapi; -} -// [End napi_get_value_bool] - -// [Start napi_get_global] -// napi_get_global -static napi_value GetGlobal(napi_env env, napi_callback_info info) -{ - napi_value global = nullptr; - // 获取global对象 - napi_get_global(env, &global); - return global; -} -// [End napi_get_global] - -// [Start napi_get_null] -// napi_get_null -static napi_value GetNull(napi_env env, napi_callback_info info) -{ - napi_value nullValue = nullptr; - napi_get_null(env, &nullValue); - return nullValue; -} -// [End napi_get_null] - -// [Start napi_get_undefined] -// napi_get_undefined -static napi_value GetUndefined(napi_env env, napi_callback_info info) -{ - // 获取并解析传进的参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - napi_value value = nullptr; - napi_get_undefined(env, &value); - // 判断传入参数的类型与undefined值的类型是否一致 - bool isEqual = false; - napi_strict_equals(env, args[0], value, &isEqual); - // 参数与undefined值相等 - napi_value result = nullptr; - // 返回判断类型之后的结果,相等返回为true,不等则为false - napi_get_boolean(env, isEqual, &result); - return result; -} -// [End napi_get_undefined] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"coerceToBool", nullptr, CoerceToBool, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"coerceToNumber", nullptr, CoerceToNumber, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"coerceToObject", nullptr, CoerceToObject, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"coerceToString", nullptr, CoerceToString, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getBoolean", nullptr, GetBoolean, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getValueBool", nullptr, GetValueBool, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getGlobal", nullptr, GetGlobal, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getNull", nullptr, GetNull, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getUndefined", nullptr, GetUndefined, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index c1f99a1279..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_coerce_to_bool_api] -export const coerceToBool: (data: T) => boolean; // napi_coerce_to_bool -// [End napi_coerce_to_bool_api] - -// [Start napi_coerce_to_number_api] -export const coerceToNumber: (data: T) => number; // napi_coerce_to_number -// [End napi_coerce_to_number_api] - -// [Start napi_coerce_to_object_api] -export const coerceToObject: (data: T) => Object; // napi_coerce_to_object -// [End napi_coerce_to_object_api] - -// [Start napi_coerce_to_string_api] -export const coerceToString: (data: T) => string; // napi_coerce_to_string -// [End napi_coerce_to_string_api] - -// [Start napi_get_boolean_api] -export const getBoolean: (data: T, value: String) => boolean; // napi_get_boolean -// [End napi_get_boolean_api] - -// [Start napi_get_value_bool_api] -export const getValueBool: (value: boolean | string) => boolean | void; // napi_get_value_bool -// [End napi_get_value_bool_api] - -// [Start napi_get_global_api] -export const getGlobal: () => Object; // napi_get_global -// [End napi_get_global_api] - -// [Start napi_get_null_api] -export const getNull: () => null; // napi_get_null -// [End napi_get_null_api] - -// [Start napi_get_undefined_api] -export const getUndefined: (value: undefined) => boolean; // napi_get_undefined -// [End napi_get_undefined_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index c2c5c92228..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiCoerceToBool', - '2.napiCoerceToNumber', - '3.napiCoerceToObject', - '4.napiCoerceToString', - '5.napiGetBoolean', - '6.napiGetValueBool', - '7.napiGetGlobal', - '8.napiGetNull', - '9.napiGetUndefined' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(22) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiCoerceToBool') { - // [Start ark_napi_coerce_to_bool] - // napi_coerce_to_bool - let value = testNapi.coerceToBool(0); - let str = testNapi.coerceToBool('111111111'); - let obj = new Object(); - let res = testNapi.coerceToBool(obj); - let result = testNapi.coerceToBool(null); - // false - hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_bool:%{public}s', value); - // true - hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_bool:%{public}s', str); - // true - hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_bool:%{public}s', res); - // false - hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_bool:%{public}s', result); - // [End ark_napi_coerce_to_bool] - this.result = 'napiCoerceToBoolSuccess'; - } else if (item === '2.napiCoerceToNumber') { - // [Start ark_napi_coerce_to_number] - // napi_coerce_to_number - let value = testNapi.coerceToNumber('2556'); - let str = testNapi.coerceToNumber('sssss'); - let bool = testNapi.coerceToNumber(true); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_number:%{public}d', value); - // 返回的为NAN - hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_number:%{public}d', str); - // 返回的是1 - hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_number:%{public}d', bool); - // [End ark_napi_coerce_to_number] - this.result = 'napiCoerceToNumberSuccess'; - } else if (item === '3.napiCoerceToObject') { - // [Start ark_napi_coerce_to_object] - // napi_coerce_to_object - let value = testNapi.coerceToObject('222222'); - let result = testNapi.coerceToObject(111); - hilog.info(0x0000, 'testTag', 'Node-API coerceToObject:%{public}s.', typeof result); - if (typeof value === 'object') { - hilog.info(0x0000, 'testTag', 'Node-API The value is an object.'); - } else { - hilog.info(0x0000, 'testTag', 'Node-API The value is not an object.'); - } - // [End ark_napi_coerce_to_object] - this.result = 'napiCoerceToObjectSuccess'; - } else if (item === '4.napiCoerceToString') { - // [Start ark_napi_coerce_to_string] - // napi_coerce_to_string - let value = testNapi.coerceToString(212); - let obj = new Object(); - let res = testNapi.coerceToString(obj); - let bool = testNapi.coerceToString(false); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_string:%{public}s', value); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_string:%{public}s', typeof res); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_coerce_to_string:%{public}s', bool); - // [End ark_napi_coerce_to_string] - this.result = 'napiCoerceToStringSuccess'; - } else if (item === '5.napiGetBoolean') { - // [Start ark_napi_get_boolean] - // napi_get_boolean - let value = testNapi.getBoolean(1, '1'); - let data = testNapi.getBoolean('sss', '1'); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_boolean:%{public}s', value); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_boolean:%{public}s', data); - // [End ark_napi_get_boolean] - this.result = 'napiGetBooleanSuccess'; - } else if (item === '6.napiGetValueBool') { - // [Start ark_napi_get_value_bool] - // napi_get_value_bool - // // 分别传入布尔值和非布尔值检测接口,传入布尔值将返回原布尔值,传入其他类型返回undefined - hilog.info(0x0000, 'Node-API', 'get_value_bool_not_bool %{public}s', - testNapi.getValueBool('你好123')); - hilog.info(0x0000, 'Node-API', 'get_value_bool_true %{public}s', testNapi.getValueBool(true)); - hilog.info(0x0000, 'Node-API', 'get_value_bool_false %{public}s', testNapi.getValueBool(false)); - // [End ark_napi_get_value_bool] - this.result = 'napiGetValueBoolSuccess'; - } else if (item === '7.napiGetGlobal') { - // [Start ark_napi_get_global] - // napi_get_global - let globalObj = testNapi.getGlobal(); - // 判断获取的global是否具有global的自身属性 - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_global:%{public}s', - globalObj.hasOwnProperty!("undefined")); - // [End ark_napi_get_global] - this.result = 'napiGetGlobalSuccess'; - } else if (item === '8.napiGetNull') { - // [Start ark_napi_get_null] - // napi_get_null - let value = testNapi.getNull(); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_null:%{public}s', value); - // [End ark_napi_get_null] - this.result = 'napiGetNullSuccess'; - } else if (item === '9.napiGetUndefined') { - // [Start ark_napi_get_undefined] - // napi_get_undefined - let data: undefined = undefined; - let value = testNapi.getUndefined(data); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_undefined:%{public}s', value); - // [End ark_napi_get_undefined] - this.result = 'napiGetUndefinedSuccess'; - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/ohosTest.md deleted file mode 100755 index 5640f18f01..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPrimitive/ohosTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# 使用Node-API进行primitive相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------ | ------------ | ---------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 coerceToBool | 位于主页 | 点击文本为1.napiCoerceToBool的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCoerceToBoolSuccess | Pass | -| ArkTS端成功调用native侧接口coerceToNumber | 位于主页 | 点击文本为2.napiCoerceToNumber的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCoerceToNumberSuccess | Pass | -| ArkTS端成功调用native侧接口coerceToObject | 位于主页 | 点击文本为3.napiCoerceToObject的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCoerceToObjectSuccess | Pass | -| ArkTS端成功调用native侧接口coerceToString | 位于主页 | 点击文本为4.napiCoerceToString的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiCoerceToStringSuccess | Pass | -| ArkTS端成功调用native侧接口getBoolean | 位于主页 | 点击文本为5.napiGetBoolean的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetBooleanSuccess | Pass | -| ArkTS端成功调用native侧接口getValueBool | 位于主页 | 点击文本为6.napiGetValueBool的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetValueBoolSuccess | Pass | -| ArkTS端成功调用native侧接口getGlobal | 位于主页 | 点击文本为7.napiGetGlobal的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetGlobalSuccess | Pass | -| ArkTS端成功调用native侧接口getNull | 位于主页 | 点击文本为8.napiGetNull的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetNullSuccess | Pass | -| ArkTS端成功调用native侧接口getUndefined | 位于主页 | 点击文本为9.napiGetUndefined的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetUndefinedSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/app.json5 deleted file mode 100755 index be09964d9e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapipromise", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/element/string.json deleted file mode 100755 index 15ca23f62b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIPromise" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/README.md deleted file mode 100755 index 39ecac3243..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行promise相关开发 - -### 介绍 - -使用Node-API接口处理异步操作。异步操作是指需要一定时间才能完成的操作,例如从网络下载数据或读取大型文件。与同步操作不同,异步操作不会阻塞主线程,而是会在后台执行。当异步操作完成后,事件循环将把它放入任务队列中,等待主线程空闲时执行,本工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [使用Node-API进行promise相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-promise.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIPromise.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行promise相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIPromise.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index e8c0971277..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIPromise) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 9e72fdba12..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" - -static constexpr int INT_ARGS_2 = 2; // 入参索引 - -// [Start napi_is_promise] -// napi_is_promise -static napi_value IsPromise(napi_env env, napi_callback_info info) -{ - napi_value argv[1] = {nullptr}; - size_t argc = 1; - napi_status status; - // 获取传入的参数 - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - bool isPromise = false; - // 检查给定的入参是否为Promise对象,将结果保存在isPromise变量中 - status = napi_is_promise(env, argv[0], &isPromise); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_is_promise failed"); - return nullptr; - } - napi_value result = nullptr; - // 将isPromise的值转换为napi_value中的类型返回 - napi_get_boolean(env, isPromise, &result); - return result; -} -// [End napi_is_promise] - -// [Start napi_resolve_reject_deferred] -// napi_resolve_deferred & napi_reject_deferred -static napi_value CreatePromise(napi_env env, napi_callback_info info) -{ - // deferred是一个延迟对象,作用是将函数延迟一定时间再执行 - napi_deferred deferred = nullptr; - napi_value promise = nullptr; - // 调用接口创建Promise对象 - napi_status status = napi_create_promise(env, &deferred, &promise); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Create promise failed"); - return nullptr; - } - // 调用napi_is_promise判断napi_create_promise接口创建的是不是Promise对象 - bool isPromise = false; - napi_value returnIsPromise = nullptr; - napi_is_promise(env, promise, &isPromise); - // 将布尔值转为可以返回的napi_value - napi_get_boolean(env, isPromise, &returnIsPromise); - return returnIsPromise; -} - -static napi_value ResolveRejectDeferred(napi_env env, napi_callback_info info) -{ - // 获得并解析参数 - size_t argc = 3; - napi_value args[3] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 第一个参数为向resolve传入的信息,第二个参数为向reject传入的信息,第三个参数为Promise的状态 - bool status; - napi_get_value_bool(env, args[INT_ARGS_2], &status); - // 创建Promise对象 - napi_deferred deferred = nullptr; - napi_value promise = nullptr; - napi_status createStatus = napi_create_promise(env, &deferred, &promise); - if (createStatus != napi_ok) { - napi_throw_error(env, nullptr, "Create promise failed"); - return nullptr; - } - // 根据第三个参数设置resolve或reject - if (status) { - napi_resolve_deferred(env, deferred, args[0]); - } else { - napi_reject_deferred(env, deferred, args[1]); - } - // 返回设置了resolve或reject的Promise对象 - return promise; -} -// [End napi_resolve_reject_deferred] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"isPromise", nullptr, IsPromise, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createPromise", nullptr, CreatePromise, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"resolveRejectDeferred", nullptr, ResolveRejectDeferred, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 2f3624c69c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_is_promise_api] -export const isPromise: (value: T) => boolean; // napi_is_promise -// [End napi_is_promise_api] - -// [Start napi_resolve_reject_deferred_api] -export const createPromise: () => boolean | void; // napi_resolve_deferred & napi_reject_deferred - -export const resolveRejectDeferred: (resolve: string, reject: string, status: boolean) => Promise | void; -// [End napi_resolve_reject_deferred_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index b9820ecdd9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiIsPromise', - '2.napiDeferred' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(22) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiIsPromise') { - // [Start ark_napi_is_promise] - // napi_is_promise - let value = Promise.resolve(); - // 传入的对象为Promise时,返回true,否则返回false - hilog.info(0x0000, 'Node-API', 'napi_is_promise %{public}s', testNapi.isPromise(value)); - hilog.info(0x0000, 'Node-API', 'napi_is_promise string %{public}s', testNapi.isPromise('')); - // [End ark_napi_is_promise] - this.result = 'napiIsPromiseSuccess'; - } else if (item === '2.napiDeferred') { - // [Start ark_napi_resolve_reject_deferred] - // napi_resolve_deferred & napi_reject_deferred - // 创建promise如果创建成功返回true,创建失败返回false - hilog.info(0x0000, 'Node-API', 'napi_create_promise %{public}s', testNapi.createPromise()); - // 调用resolveRejectDeferred函数设置resolve和reject的返回结果以及Promise状态 - // Promise状态为true时设置resolve,返回结果在then函数中获得 - let promiseSuccess: Promise = - testNapi.resolveRejectDeferred('success', 'fail', true) as Promise; - promiseSuccess.then((res) => { - hilog.info(0x0000, 'Node-API', 'get_resolve_deferred resolve %{public}s', res) - // [StartExclude ark_napi_resolve_reject_deferred] - this.result = 'napiDeferredSuccess'; - // [EndExclude ark_napi_resolve_reject_deferred] - }).catch((err: Error) => { - hilog.info(0x0000, 'Node-API', 'get_resolve_deferred reject %{public}s', err) - // [StartExclude ark_napi_resolve_reject_deferred] - this.result = 'napiDeferredFail'; - // [EndExclude ark_napi_resolve_reject_deferred] - }) - // Promise状态为false时设置reject,返回结果在catch函数中获得 - let promiseFail: Promise = - testNapi.resolveRejectDeferred('success', 'fail', false) as Promise; - promiseFail.then((res) => { - hilog.info(0x0000, 'Node-API', 'get_resolve_deferred resolve %{public}s', res) - // [StartExclude ark_napi_resolve_reject_deferred] - this.result = 'napiDeferredSuccess'; - // [EndExclude ark_napi_resolve_reject_deferred] - }).catch((err: Error) => { - hilog.info(0x0000, 'Node-API', 'get_resolve_deferred reject %{public}s', err) - // [StartExclude ark_napi_resolve_reject_deferred] - this.result = 'napiDeferredFail'; - // [EndExclude ark_napi_resolve_reject_deferred] - }) - // [End ark_napi_resolve_reject_deferred] - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/ohosTest.md deleted file mode 100755 index 23bc29983e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIPromise/ohosTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# 使用Node-API进行promise相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------------------ | ------------ | ----------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口isPromise | 位于主页 | 点击文本为1.napiIsPromise的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiIsPromiseSuccess | Pass | -| ArkTS端成功调用native侧接口createPromise,resolveRejectDeferred | 位于主页 | 点击文本为2.napiDeferred的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDeferredSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/app.json5 deleted file mode 100755 index 1f7238eae6..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapiproperty", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/element/string.json deleted file mode 100755 index 1d1b5e602c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeAPIProperty" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/README.md deleted file mode 100755 index 3e6e49a7e7..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行property相关开发 - -### 介绍 - -使用Node-API接口获取和设置ArkTS对象的属性。通过合理使用这些函数,实现更复杂的功能和逻辑,本工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [使用Node-API进行property相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-property.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeAPIProperty.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行property相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeAPIProperty.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty > .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/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index feb418a6db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NodeAPIProperty) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 115c9bd479..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,391 +0,0 @@ -/* - * 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 -#include "napi/native_api.h" - -static constexpr int INT_ARG_2 = 2; // 入参索引 - -// [Start napi_get_property_names] -// napi_get_property_names -static napi_value GetPropertyNames(napi_env env, napi_callback_info info) -{ - // 解析ArkTS的传参 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 以字符串数组的形式获取对象的可枚举属性的名称,以result传出 - napi_value result; - napi_status status = napi_get_property_names(env, args[0], &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_get_property_names fail"); - return nullptr; - } - return result; -} -// [End napi_get_property_names] - -// [Start napi_set_property] -// napi_set_property -static napi_value SetProperty(napi_env env, napi_callback_info info) -{ - // 接收ArkTS侧传入的三个参数:第一个参数为想要设置的object,第二个参数为属性,第三个参数为属性对应的值 - size_t argc = 3; - napi_value args[3] = {nullptr}; - napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_get_cb_info fail"); - } - // 通过调用napi_set_property接口将属性与值设置入object,如果失败,直接抛出错误 - status = napi_set_property(env, args[0], args[1], args[INT_ARG_2]); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_set_property fail"); - return nullptr; - } - // 返回设置成功的object对象 - return args[0]; -} -// [End napi_set_property] - -// [Start napi_get_property] -// napi_get_property -static napi_value GetProperty(napi_env env, napi_callback_info info) -{ - // 接收两个ArkTS传来的参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 传入的第一个参数为要检测的object,第二个对象为要检测的属性,通过调用napi_get_property接口获取对应的值 - napi_value result; - napi_status status = napi_get_property(env, args[0], args[1], &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_get_property fail"); - return nullptr; - } - return result; -} -// [End napi_get_property] - -// [Start napi_has_property] -// napi_has_property -static napi_value HasProperty(napi_env env, napi_callback_info info) -{ - // 从ArkTS侧传入两个参数:第一个参数为要检验的对象,第二个参数为要检测是否存在对象的属性 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 将参数传入napi_has_property方法中,若接口调用成功则将结果转化为napi_value类型抛出,否则抛出错误 - bool result; - napi_status status = napi_has_property(env, args[0], args[1], &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_has_property fail"); - return nullptr; - } - - // 若传入属性存在传入对象中,则输出true将结果转化为napi_value类型抛出 - napi_value returnResult; - napi_get_boolean(env, result, &returnResult); - return returnResult; -} -// [End napi_has_property] - -// [Start napi_delete_property] -// napi_delete_property -// 从传入的Object对象中删除指定属性,返回是否删除成功的bool结果值 -static napi_value DeleteProperty(napi_env env, napi_callback_info info) -{ - // 接收两个ArkTS传来的参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - napi_valuetype valueType; - napi_typeof(env, args[0], &valueType); - if (valueType != napi_object) { - napi_throw_error(env, nullptr, "Expects an object as argument."); - return nullptr; - } - // 删除指定属性,结果存储在result中 - bool result = false; - napi_status status = napi_delete_property(env, args[0], args[1], &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_delete_property failed"); - return nullptr; - } - // 将bool结果转换为napi_value并返回 - napi_value ret; - napi_get_boolean(env, result, &ret); - return ret; -} -// [End napi_delete_property] - -// [Start napi_has_own_property] -// napi_has_own_property -static napi_value NapiHasOwnProperty(napi_env env, napi_callback_info info) -{ - // 接收两个ArkTS传来的参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 检查第一个参数是否为对象 - napi_valuetype valueTypeObj; - napi_typeof(env, args[0], &valueTypeObj); - if (valueTypeObj != napi_object) { - napi_throw_error(env, nullptr, "First argument must be an object."); - return nullptr; - } - // 检查第二个参数是否为string - napi_valuetype valuetypeStr; - napi_typeof(env, args[1], &valuetypeStr); - if (valuetypeStr != napi_string) { - napi_throw_error(env, nullptr, "Second argument must be a string."); - return nullptr; - } - // 检查对象是否具有指定属性,结果存储在hasProperty中 - bool hasProperty; - napi_status status = napi_has_own_property(env, args[0], args[1], &hasProperty); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_has_own_property failed"); - return nullptr; - } - // 将bool结果转换为napi_value并返回 - napi_value result; - napi_get_boolean(env, hasProperty, &result); - return result; -} -// [End napi_has_own_property] - -// [Start napi_set_named_property] -// napi_set_named_property -static napi_value NapiSetNamedProperty(napi_env env, napi_callback_info info) -{ - // 接收一个ArkTS传来的参数 - size_t argc = 1; - napi_value str; - const int32_t strLength = 32; - char strKey[strLength] = ""; - napi_get_cb_info(env, info, &argc, &str, nullptr, nullptr); - // 获取传入参数字符串并存储在strKey中 - size_t keyLength; - napi_get_value_string_utf8(env, str, strKey, strLength, &keyLength); - // 创建一个新对象 - napi_value newObj; - napi_create_object(env, &newObj); - // 设置整数值1234为属性值 - int32_t value = 1234; - napi_value numValue; - napi_create_int32(env, value, &numValue); - // 将整数值与指定属性名关联 - napi_status status = napi_set_named_property(env, newObj, strKey, numValue); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_set_named_property failed"); - return nullptr; - } - // 返回设置了命名属性的对象newObj - return newObj; -} -// [End napi_set_named_property] - -// [Start napi_get_named_property] -// napi_get_named_property -static napi_value NapiGetNamedProperty(napi_env env, napi_callback_info info) -{ - // 接收两个ArkTS传来的参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - const int32_t strLength = 32; - char strKey[strLength] = ""; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取要获取的属性名 - size_t keyLength; - napi_get_value_string_utf8(env, args[1], strKey, strLength, &keyLength); - // 获取指定属性的值并存储在result中 - napi_value result; - napi_status status = napi_get_named_property(env, args[0], strKey, &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_get_named_property failed"); - return nullptr; - } - // 返回result - return result; -} -// [End napi_get_named_property] - -// [Start napi_has_named_property] -// napi_has_named_property -static napi_value NapiHasNamedProperty(napi_env env, napi_callback_info info) -{ - // 接收两个ArkTS传来的参数 - size_t argc = 2; - napi_value args[2] = {nullptr}; - const int32_t strLength = 32; - char strKey[strLength] = ""; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取要检查的属性名 - size_t keyLength; - napi_get_value_string_utf8(env, args[1], strKey, strLength, &keyLength); - // 检查对象是否具有指定命名的属性,并将结果存储在hasProperty中 - bool hasProperty = false; - napi_status status = napi_has_named_property(env, args[0], strKey, &hasProperty); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_has_named_property failed"); - return nullptr; - } - // 将bool结果转换为napi_value并返回 - napi_value result; - napi_get_boolean(env, hasProperty, &result); - return result; -} -// [End napi_has_named_property] - -// [Start napi_define_properties] -// napi_define_properties -static napi_value DefineMethodPropertiesExample(napi_env env, napi_callback_info info) -{ - // 创建一个int32类型的属性值 - int32_t propValue = 26; - napi_value returnValue = nullptr; - napi_create_int32(env, propValue, &returnValue); - return returnValue; -} - -// Getter回调函数 -static napi_value GetterCallback(napi_env env, napi_callback_info info) -{ - napi_value result; - const char *str = u8"World!"; - size_t length = strlen(str); - // 创建属性的值 - napi_create_string_utf8(env, str, length, &result); - return result; -} - -// Setter回调函数 -static napi_value SetterCallback(napi_env env, napi_callback_info info) -{ - // 获取传递给setter的参数 - size_t argc = 1; - napi_value argv[1] = {nullptr}; - napi_value result; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - std::string buf; - size_t length; - napi_get_value_string_utf8(env, argv[0], (char *)buf.c_str(), NAPI_AUTO_LENGTH, &length); - napi_create_string_utf8(env, buf.c_str(), length, &result); - return result; -} - -static napi_value DefineMethodProperties(napi_env env, napi_callback_info info) -{ - napi_value obj; - napi_create_object(env, &obj); - // 在obj对象上定义了一个函数defineMethodPropertiesExample,在函数defineMethodPropertiesExample中定义了一个变量并返回,在调用obj的这个对象时可以调用这个函数 - napi_property_descriptor descriptor[] = {{"defineMethodPropertiesExample", nullptr, DefineMethodPropertiesExample, - nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, obj, sizeof(descriptor) / sizeof(descriptor[0]), descriptor); - return obj; -} - -static napi_value DefineStringProperties(napi_env env, napi_callback_info info) -{ - napi_value obj; - napi_create_object(env, &obj); - // 创建一个string类型的属性值 - napi_value string_value; - napi_create_string_utf8(env, "Hello!", NAPI_AUTO_LENGTH, &string_value); - napi_property_descriptor descriptor[] = { - {"defineStringPropertiesExample", nullptr, nullptr, nullptr, nullptr, string_value, napi_default, nullptr}}; - napi_define_properties(env, obj, sizeof(descriptor) / sizeof(descriptor[0]), descriptor); - return obj; -} - -static napi_value CreateStringWithGetterSetter(napi_env env, napi_callback_info info) -{ - napi_value obj; - napi_create_object(env, &obj); - // 定义getter函数 - napi_value getterFn; - napi_create_function(env, nullptr, 0, GetterCallback, nullptr, &getterFn); - napi_set_named_property(env, obj, "getterCallback", getterFn); - // 定义setter函数 - napi_value setterFn; - napi_create_function(env, nullptr, 0, SetterCallback, nullptr, &setterFn); - napi_set_named_property(env, obj, "setterCallback", setterFn); - // 定义带有getter和setter的属性 - napi_property_descriptor desc = {"defineGetterSetter", nullptr, GetterCallback, SetterCallback, nullptr, obj, - napi_enumerable, nullptr}; - napi_define_properties(env, obj, 1, &desc); - return obj; -} -// [End napi_define_properties] - -// [Start napi_get_all_property_names] -// napi_get_all_property_names -static napi_value GetAllPropertyNames(napi_env env, napi_callback_info info) -{ - // 传入一个参数 - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取给定对象的所有属性名称 - napi_value result; - napi_status status = napi_get_all_property_names(env, args[0], napi_key_own_only, napi_key_writable, - napi_key_numbers_to_strings, &result); - // 如果获取属性名失败,抛出一个错误 - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Node-API napi_get_all_property_names fail"); - return nullptr; - } - - return result; -} -// [End napi_get_all_property_names] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"getPropertyNames", nullptr, GetPropertyNames, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"setProperty", nullptr, SetProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getProperty", nullptr, GetProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"hasProperty", nullptr, HasProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"deleteProperty", nullptr, DeleteProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiHasOwnProperty", nullptr, NapiHasOwnProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiSetNamedProperty", nullptr, NapiSetNamedProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiGetNamedProperty", nullptr, NapiGetNamedProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"napiHasNamedProperty", nullptr, NapiHasNamedProperty, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"defineMethodProperties", nullptr, DefineMethodProperties, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"defineStringProperties", nullptr, DefineStringProperties, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createStringWithGetterSetter", nullptr, CreateStringWithGetterSetter, nullptr, nullptr, nullptr, napi_default, - nullptr}, - {"getAllPropertyNames", nullptr, GetAllPropertyNames, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index e2f3372d4c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_get_property_names_api] -export const getPropertyNames: (obj: Object) => Array | void; // napi_get_property_names -// [End napi_get_property_names_api] - -// [Start napi_set_property_api] -export const setProperty: (obj: Object, key: String, value: string) => Object | void; // napi_set_property -// [End napi_set_property_api] - -// [Start napi_get_property_api] -export const getProperty: (obj: Object, key: string) => string | void; // napi_get_property -// [End napi_get_property_api] - -// [Start napi_has_property_api] -export const hasProperty: (obj: Object, key: number | string) => boolean | void; // napi_has_property -// [End napi_has_property_api] - -// [Start napi_delete_property_api] -export const deleteProperty: (obj: Object, key: string) => boolean; // napi_delete_property -// [End napi_delete_property_api] - -// [Start napi_has_own_property_api] -export const napiHasOwnProperty: (obj: Object, key: string) => boolean | void; // napi_has_own_property -// [End napi_has_own_property_api] - -// [Start napi_set_named_property_api] -export const napiSetNamedProperty: (key: string) => Object | void; // napi_set_named_property -// [End napi_set_named_property_api] - -// [Start napi_get_named_property_api] -export const napiGetNamedProperty: (obj: Object, - key: string) => boolean | number | string | Object | void; // napi_get_named_property -// [End napi_get_named_property_api] - -// [Start napi_has_named_property_api] -export const napiHasNamedProperty: (obj: Object, key: string) => boolean | void; // napi_has_named_property -// [End napi_has_named_property_api] - -// [Start napi_define_properties_api] -export class DefineMethodObj { - defineMethodPropertiesExample: Function; -} - -export class DefineStringObj { - defineStringPropertiesExample: string; -} - -export class DefineGetterSetterObj { - getterCallback: Function; - setterCallback: Function; -} - -export const defineMethodProperties: () => DefineMethodObj; // napi_define_properties - -export const defineStringProperties: () => DefineStringObj; - -export const createStringWithGetterSetter: () => DefineGetterSetterObj; -// [End napi_define_properties_api] - -// [Start napi_get_all_property_names_api] -export const getAllPropertyNames: (obj: Object) => Array | void; // napi_get_all_property_names -// [End napi_get_all_property_names_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index a8e26c51f7..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,294 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; -import { napiDeleteProperty } from './napiDeleteProperty'; -import { napiHasOwnProperty } from './napiHasOwnProperty'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiGetPropertyNames', - '2.napiSetProperty', - '3.napiGetProperty', - '4.napiHasProperty', - '5.napiDeleteProperty', - '6.napiHasOwnProperty', - '7.napiSetNamedProperty', - '8.napiGetNamedProperty', - '9.napiHasNamedProperty', - '10.napiDefineProperties', - '11.napiGetAllPropertyNames' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(20) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 4 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiGetPropertyNames') { - // [Start ark_napi_get_property_names] - // napi_get_property_names - try { - class Obj { - public data: number = 0 - public message: string = '' - } - - let obj: Obj = { data: 0, message: 'hello world' }; - let propertyNames = testNapi.getPropertyNames(obj); - if (Array.isArray(propertyNames) && propertyNames.length > 0) { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_property_names: %{public}s', - propertyNames[0]); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_property_names: %{public}s', - propertyNames[1]); - // [StartExclude ark_napi_get_property_names] - this.result = 'napiGetPropertyNamesSuccess'; - // [EndExclude ark_napi_get_property_names] - } - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API napi_get_property_names error: %{public}s', - error.message); - // [StartExclude ark_napi_get_property_names] - this.result = 'napiGetPropertyNamesFail'; - // [EndExclude ark_napi_get_property_names] - } - // [End ark_napi_get_property_names] - } else if (item === '2.napiSetProperty') { - // [Start ark_napi_set_property] - // napi_set_property - try { - class Obj { - public data: number = 0 - public message: string = '' - } - - let obj: Obj = { data: 0, message: 'hello world' }; - let result = testNapi.setProperty(obj, 'code', 'hi'); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_property: %{public}s', - JSON.stringify(result)); - // [StartExclude ark_napi_set_property] - this.result = 'napiSetPropertySuccess'; - // [EndExclude ark_napi_set_property] - } catch (error) { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_property error: %{public}s', error.message); - // [StartExclude ark_napi_set_property] - this.result = 'napiSetPropertyFail'; - // [EndExclude ark_napi_set_property] - } - // [End ark_napi_set_property] - } else if (item === '3.napiGetProperty') { - // [Start ark_napi_get_property] - // napi_get_property - try { - class Obj { - public data: number = 0 - public message: string = '' - } - - let obj: Obj = { data: 0, message: 'hello world' }; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_property: %{public}s', - testNapi.getProperty(obj, 'message')); - // [StartExclude ark_napi_get_property] - this.result = 'napiGetPropertySuccess'; - // [EndExclude ark_napi_get_property] - } catch (error) { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_property error: %{public}s', error.message); - // [StartExclude ark_napi_get_property] - this.result = 'napiGetPropertyFail'; - // [EndExclude ark_napi_get_property] - } - // [End ark_napi_get_property] - } else if (item === '4.napiHasProperty') { - // [Start ark_napi_has_property] - // napi_has_property - try { - class Obj { - public data: number = 0 - public message: string = '' - } - - let obj: Obj = { data: 0, message: 'hello world' }; - let resultFalse = testNapi.hasProperty(obj, 0); - let resultTrue = testNapi.hasProperty(obj, 'data'); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_property: %{public}s', - JSON.stringify(resultFalse)); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_property: %{public}s', - JSON.stringify(resultTrue)); - // [StartExclude ark_napi_has_property] - this.result = 'napiHasPropertySuccess'; - // [EndExclude ark_napi_has_property] - } catch (error) { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_property error: %{public}s', error.message); - // [StartExclude ark_napi_has_property] - this.result = 'napiHasPropertyFail'; - // [EndExclude ark_napi_has_property] - } - // [End ark_napi_has_property] - } else if (item === '5.napiDeleteProperty') { - // napi_delete_property - napiDeleteProperty(); - this.result = 'napiDeletePropertySuccess'; - } else if (item === '6.napiHasOwnProperty') { - // napi_has_own_property - napiHasOwnProperty(); - this.result = 'napiHasOwnPropertySuccess'; - } else if (item === '7.napiSetNamedProperty') { - // [Start ark_napi_set_named_property] - // napi_set_named_property - let obj = testNapi.napiSetNamedProperty('myProperty'); - let objAsString = JSON.stringify(obj); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_named_property: %{public}s', objAsString); - // [End ark_napi_set_named_property] - this.result = 'napiSetNamedPropertySuccess'; - } else if (item === '8.napiGetNamedProperty') { - // [Start ark_napi_get_named_property] - // napi_get_named_property - interface NestedObj { - nestedStr: string; - nestedNum: number; - } - - class Obj { - public str: string = ''; - public num: number = 0; - public bol: boolean = false; - public nestedObj: NestedObj = { nestedStr: '', nestedNum: 0 }; - } - - let obj: Obj = { - str: 'bar', - num: 42, - bol: true, - nestedObj: { nestedStr: 'nestedValue', nestedNum: 123 } - }; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_named_property : %{public}s', - testNapi.napiGetNamedProperty(obj, 'str')); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_named_property : %{public}d', - testNapi.napiGetNamedProperty(obj, 'num')); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_named_property : %{public}s', - testNapi.napiGetNamedProperty(obj, 'bol')); - let nestedObj = testNapi.napiGetNamedProperty(obj, 'nestedObj'); - let objAsString = JSON.stringify(nestedObj); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_named_property : %{public}s', objAsString); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_named_property : %{public}s', - testNapi.napiGetNamedProperty(obj, 'null')); - // [End ark_napi_get_named_property] - this.result = 'napiGetNamedPropertySuccess'; - } else if (item === '9.napiHasNamedProperty') { - // [Start ark_napi_has_named_property] - // napi_has_named_property - interface NestedObj { - nestedStr: string; - nestedNum: number; - } - - class Obj { - public str: string = ''; - public num: number = 0; - public bol: boolean = false; - public nestedObj: NestedObj = { nestedStr: '', nestedNum: 0 }; - } - - let obj: Obj = { - str: 'bar', - num: 42, - bol: true, - nestedObj: { nestedStr: 'nestedValue', nestedNum: 123 } - }; - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_named_property : %{public}s', - testNapi.napiHasNamedProperty(obj, 'str')); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_named_property : %{public}s', - testNapi.napiHasNamedProperty(obj, 'nestedStr')); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_named_property : %{public}s', - testNapi.napiHasNamedProperty(obj, 'bol')); - // [End ark_napi_has_named_property] - this.result = 'napiHasNamedPropertySuccess'; - } else if (item === '10.napiDefineProperties') { - // [Start ark_napi_define_properties] - // napi_define_properties - // 定义method类型的属性 - hilog.info(0x0000, 'testTag', 'Test Node-API define_method_properties:%{public}d', - testNapi.defineMethodProperties() - .defineMethodPropertiesExample()); - // 定义string类型的属性 - hilog.info(0x0000, 'testTag', 'Test Node-API define_string_properties::%{public}s ', - testNapi.defineStringProperties() - .defineStringPropertiesExample); - // getter和setter - hilog.info(0x0000, 'testTag', 'Test Node-API get::%{public}s ', - testNapi.createStringWithGetterSetter() - .getterCallback()); - hilog.info(0x0000, 'testTag', 'Test Node-API setter::%{public}s ', - testNapi.createStringWithGetterSetter() - .setterCallback('set data')); - // [End ark_napi_define_properties] - this.result = 'napiDefinePropertiesSuccess'; - } else if (item === '11.napiGetAllPropertyNames') { - // [Start ark_napi_get_all_property_names] - // napi_get_all_property_names - try { - class Obj { - public data: number = 0 - public message: string = '' - } - - let obj: Obj = { data: 0, message: 'hello world' }; - let propertyNames = testNapi.getAllPropertyNames(obj); - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_all_property_names: %{public}s', - JSON.stringify(propertyNames)); - // [StartExclude ark_napi_get_all_property_names] - this.result = 'napiGetAllPropertyNamesSuccess'; - // [EndExclude ark_napi_get_all_property_names] - } catch (error) { - hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_all_property_names error: %{public}s', - error.message); - // [StartExclude ark_napi_get_all_property_names] - this.result = 'napiGetAllPropertyNamesFail'; - // [EndExclude ark_napi_get_all_property_names] - } - // [End ark_napi_get_all_property_names] - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - .id('List') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/ohosTest.md deleted file mode 100755 index f4ff2dfc6c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeAPIProperty/ohosTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# 使用Node-API进行property相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------- | ------------ | ---------------------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 getPropertyNames | 位于主页 | 点击文本为1.napiGetPropertyNames的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetPropertyNamesSuccess | Pass | -| ArkTS端成功调用native侧接口setProperty | 位于主页 | 点击文本为2.napiSetProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiSetPropertySuccess | Pass | -| ArkTS端成功调用native侧接口getProperty | 位于主页 | 点击文本为3.napiGetProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetPropertySuccess | Pass | -| ArkTS端成功调用native侧接口hasProperty | 位于主页 | 点击文本为4.napiHasProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiHasPropertySuccess | Pass | -| ArkTS端成功调用native侧接口napiDeleteProperty | 位于主页 | 点击文本为5.napiDeleteProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDeletePropertySuccess | Pass | -| ArkTS端成功调用native侧接口napiHasOwnProperty | 位于主页 | 点击文本为6.napiHasOwnProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiHasOwnPropertySuccess | Pass | -| ArkTS端成功调用native侧接口napiSetNamedProperty | 位于主页 | 点击文本为7.napiSetNamedProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiSetNamedPropertySuccess | Pass | -| ArkTS端成功调用native侧接口napiGetNamedProperty | 位于主页 | 点击文本为8.napiGetNamedProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetNamedPropertySuccess | Pass | -| ArkTS端成功调用native侧接口napiHasNamedProperty | 位于主页 | 点击文本为9.napiHasNamedProperty的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiHasNamedPropertySuccess | Pass | -| ArkTS端成功调用native侧接口defineStringProperties | 位于主页 | 点击文本为10.napiDefineProperties的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiDefinePropertiesSuccess | Pass | -| ArkTS端成功调用native侧接口getAllPropertyNames | 位于主页 | 点击文本为11.napiGetAllPropertyNames的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiGetAllPropertyNamesSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/app.json5 deleted file mode 100755 index 086121a9d8..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapicustomasynchronousoperations", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/element/string.json deleted file mode 100755 index 82222f6bc7..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeApiCustomAsynchronousOperations" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/README.md deleted file mode 100755 index 09e0b21ff9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# ArkTS使用Node-API进行自定义异步操作相关开发 - -### 介绍 - -使用Node-API的自定义异步操作功能,可以使ArkTS的使用更加灵活和高效,可以处理那些可能阻塞事件循环的长时间运行任务,同时保持ArkTS应用的响应性和性能。 - -本工程主要展示了使用Node-API进行创建和销毁异步资源上下文环境、在异步资源上下文环境中执行ArkTS回调函数和创建关闭回调作用域实现场景,其中代码详细描述可查如下链接。 - -- [使用Node-API进行自定义异步操作相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-custom-asynchronous-operations.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeApiCustomAsynchronousOperations.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行自定义异步操作相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeApiCustomAsynchronousOperations.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations > .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/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 4319502219..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(use_napi_about_custom_asynchronous_operations) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so) - -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libhilog_ndk.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index 40da20536c..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_async_open_close_callback_scope] -#include "napi/native_api.h" - -static constexpr int INT_ARG_3 = 3; // 入参索引 - -static napi_value AsynchronousWork(napi_env env, napi_callback_info info) -{ - // 接受四个参数 - size_t argc = 4; - napi_value args[4] = {nullptr}; - // 从回调信息中获取参数 - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 提取参数中的资源、接收器对象和函数 - napi_value resource = args[0]; - napi_value recv = args[1]; - napi_value func = args[2]; - napi_value argv[1] = {nullptr}; - argv[0] = args[INT_ARG_3]; - // 获取函数的类型 - napi_valuetype funcType; - napi_typeof(env, func, &funcType); - // 创建一个资源名称为"test"的字符串 - napi_value resourceName = nullptr; - napi_create_string_utf8(env, "test", NAPI_AUTO_LENGTH, &resourceName); - // 初始化异步上下文 - napi_async_context context; - napi_status status = napi_async_init(env, resource, resourceName, &context); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_async_init fail"); - return nullptr; - } - // 打开回调作用域 - napi_callback_scope scope = nullptr; - napi_open_callback_scope(env, resource, context, &scope); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_open_callback_scope fail"); - return nullptr; - } - // 调用回调函数 - napi_value result = nullptr; - if (funcType == napi_function) { - napi_make_callback(env, context, recv, func, 1, argv, &result); - } else { - napi_throw_error(env, nullptr, "Unexpected argument type"); - return nullptr; - } - // 关闭回调作用域 - napi_close_callback_scope(env, scope); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "napi_close_callback_scope fail"); - return nullptr; - } - // 销毁异步上下文 - napi_async_destroy(env, context); - return result; -} -// [End napi_async_open_close_callback_scope] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"asynchronousWork", nullptr, AsynchronousWork, nullptr, nullptr, nullptr, napi_default, nullptr}, - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 9c9248788f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_async_open_close_callback_scope_api] -export const asynchronousWork: (object: Object, obj: Object, fun: Function, num: number) => number | void; -// [End napi_async_open_close_callback_scope_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index e4e96d5ce3..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start ark_napi_async_open_close_callback_scope] -import { hilog } from '@kit.PerformanceAnalysisKit'; -import testNapi from 'libentry.so'; -import process from '@ohos.process'; - -// [StartExclude ark_napi_async_open_close_callback_scope] -@Entry -@Component -struct Index { - @State result: string = ''; - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(25) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 3 }) - List({ space: '10vp' }) { - ListItem() { - Text('1.customAsync') - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - // [EndExclude ark_napi_async_open_close_callback_scope] - try { - hilog.info(0x0000, 'testTag', 'Test Node-API asynchronousWork: %{public}d', - testNapi.asynchronousWork({}, process.ProcessManager, (num: number) => { - return num; - }, 123)); - this.result = 'customAsyncSuccess'; - } catch (error) { - hilog.error(0x0000, 'testTag', 'Test Node-API asynchronousWork error: %{public}s', error.message); - this.result = 'customAsyncFail'; - } - // [End ark_napi_async_open_close_callback_scope] - }) - } - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/ohosTest.md deleted file mode 100755 index 97fd0ca562..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiCustomAsynchronousOperations/ohosTest.md +++ /dev/null @@ -1,8 +0,0 @@ -# 使用Node-API进行自定义异步操作相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------- | ------------ | --------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口asynchronousWork | 位于主页 | 点击文本为1.customAsync的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: customAsyncSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/AppScope/app.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/AppScope/app.json5 deleted file mode 100755 index ddd54162f1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/AppScope/app.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.nodeapistring", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/element/string.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/element/string.json deleted file mode 100755 index a872f762a3..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NodeApiString" - } - ] -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/README.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/README.md deleted file mode 100755 index 7b8fb028eb..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# ArkTS使用Node-API进行string相关开发 - -### 介绍 - -使用Node-API关于string的六个接口,可以让Node-API模块和ArkTS字符串进行交互,本工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [使用Node-API进行string相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-about-string.md) - -### 效果预览 - -| 首页 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。 -3. 运行测试用例NodeApiString.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── Index.d.ts - │ │ ├── oh-package.json5 - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用Node-API进行string相关开发示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── NodeApiString.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString > .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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/build-profile.json5 deleted file mode 100755 index df8b8004f9..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/build-profile.json5 +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/build-profile.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/build-profile.json5 deleted file mode 100755 index 5612a9a1db..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/build-profile.json5 +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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": false, - "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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/oh-package.json5 deleted file mode 100755 index 5d993e5251..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/oh-package.json5 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/CMakeLists.txt deleted file mode 100755 index 603a636c47..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(use_napi_about_string) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) -add_definitions( "-DLOG_DOMAIN=0xd0d0" ) -add_definitions( "-DLOG_TAG=\"testTag\"" ) -target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/napi_init.cpp deleted file mode 100755 index ca0393188e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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 -#include - -static const int MAX_BUFFER_SIZE = 128; - -// [Start napi_get_value_string_utf8] -static napi_value GetValueStringUtf8(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取字符串的长度 - size_t length = 0; - napi_status status = napi_get_value_string_utf8(env, args[0], nullptr, 0, &length); - // 传入一个非字符串 napi_get_value_string_utf8接口会返回napi_string_expected - if (status != napi_ok) { - return nullptr; - } - char *buf = new char[length + 1]; - std::memset(buf, 0, length + 1); - napi_get_value_string_utf8(env, args[0], buf, length + 1, &length); - napi_value result = nullptr; - status = napi_create_string_utf8(env, buf, length, &result); - delete buf; - if (status != napi_ok) { - return nullptr; - }; - return result; -} -// [End napi_get_value_string_utf8] - -// [Start napi_create_string_utf8] -static napi_value CreateStringUtf8(napi_env env, napi_callback_info info) -{ - const char *str = u8"你好, World!, successes to create UTF-8 string! 111"; - size_t length = strlen(str); - napi_value result = nullptr; - napi_status status = napi_create_string_utf8(env, str, length, &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Failed to create UTF-8 string"); - return nullptr; - } - return result; -} -// [End napi_create_string_utf8] - -// [Start napi_get_value_string_utf16] -static napi_value GetValueStringUtf16(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1]; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - napi_value result = nullptr; - // 字符串的缓冲区 - char16_t buffer[MAX_BUFFER_SIZE]; - // 字符串的缓冲区大小 - size_t bufferSize = MAX_BUFFER_SIZE; - // 字符串的长度 - size_t stringLen; - // 获取字符串的数据和长度 - napi_get_value_string_utf16(env, args[0], buffer, bufferSize, &stringLen); - // 获取字符串返回结果 - napi_create_string_utf16(env, buffer, stringLen, &result); - // 返回结果 - return result; -} -// [End napi_get_value_string_utf16] - -// [Start napi_create_string_utf16] -static napi_value CreateStringUtf16(napi_env env, napi_callback_info info) -{ - const char16_t *str = u"你好, World!, successes to create UTF-16 string! 111"; - size_t length = NAPI_AUTO_LENGTH; - napi_value result = nullptr; - napi_status status = napi_create_string_utf16(env, str, length, &result); - if (status != napi_ok) { - napi_throw_error(env, nullptr, "Failed to create UTF-16 string"); - return nullptr; - } - return result; -} -// [End napi_create_string_utf16] - -// [Start napi_get_value_string_latin1] -static napi_value GetValueStringLatin1(napi_env env, napi_callback_info info) -{ - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - char buf[MAX_BUFFER_SIZE]; - size_t length = 0; - napi_value napi_Res = nullptr; - napi_status status = napi_get_value_string_latin1(env, args[0], buf, MAX_BUFFER_SIZE, &length); - // 当输入的值不是字符串时,接口会返回napi_string_expected - if (status == napi_string_expected) { - return nullptr; - } - napi_create_string_latin1(env, buf, length, &napi_Res); - return napi_Res; -} -// [End napi_get_value_string_latin1] - -// [Start napi_create_string_latin1] -static napi_value CreateStringLatin1(napi_env env, napi_callback_info info) -{ - const char *str = "Hello, World! éçñ, successes to create Latin1 string! 111"; - size_t length = NAPI_AUTO_LENGTH; - napi_value result = nullptr; - napi_status status = napi_create_string_latin1(env, str, length, &result); - if (status != napi_ok) { - // 处理错误 - napi_throw_error(env, nullptr, "Failed to create Latin1 string"); - return nullptr; - } - return result; -} -// [End napi_create_string_latin1] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"getValueStringUtf8", nullptr, GetValueStringUtf8, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createStringUtf8", nullptr, CreateStringUtf8, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getValueStringUtf16", nullptr, GetValueStringUtf16, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createStringUtf16", nullptr, CreateStringUtf16, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"getValueStringLatin1", nullptr, GetValueStringLatin1, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createStringLatin1", nullptr, CreateStringLatin1, nullptr, nullptr, nullptr, napi_default, nullptr}, - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100755 index 905a15b94b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start napi_get_value_string_utf8_api] -export const getValueStringUtf8: (param: string | number) => string | void; -// [End napi_get_value_string_utf8_api] - -// [Start napi_create_string_utf8_api] -export const createStringUtf8: () => string | void; -// [End napi_create_string_utf8_api] - -// [Start napi_get_value_string_utf16_api] -export const getValueStringUtf16: (data: string) => string; -// [End napi_get_value_string_utf16_api] - -// [Start napi_create_string_utf16_api] -export const createStringUtf16: () => string | void; -// [End napi_create_string_utf16_api] - -// [Start napi_get_value_string_latin1_api] -export const getValueStringLatin1: (param: number | string) => string | void; -// [End napi_get_value_string_latin1_api] - -// [Start napi_create_string_latin1_api] -export const createStringLatin1: () => string | void; -// [End napi_create_string_latin1_api] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100755 index 846e4c7e13..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100755 index a36ca588fe..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100755 index 1504a74f09..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/pages/Index.ets deleted file mode 100755 index 01466b983d..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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 testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State result: string = '' - private items: string[] = [ - 'Reset Result Message', - '1.napiString' - ] - - build() { - Column() { - Text('Result: ' + this.result) - .fontSize(22) - .fontWeight(FontWeight.Bold) - .margin({ bottom: 4 }) - List({ space: '10vp' }) { - ForEach(this.items, (item: string) => { - ListItem() { - Text(item) - .fontSize(16) - .width('100%') - .height(60) - .textAlign(TextAlign.Center) - .fontWeight(FontWeight.Bold) - .borderRadius(30) - .backgroundColor(Color.White) - .onClick(() => { - if (item === 'Reset Result Message') { - this.result = ''; - } else if (item === '1.napiString') { - // [Start ark_napi_get_value_string_utf8] - // 分别传入字符和非字符检测接口,传入字符串类型的数据将返回原字符串,传入其他类型返回undefined - hilog.info(0x0000, 'testTag', 'Test Node-API get_value_string_utf8_string %{public}s', - testNapi.getValueStringUtf8('aaBC+-$%^你好123')); - hilog.info(0x0000, 'testTag', 'Test Node-API get_value_string_utf8_not_string %{public}s', - testNapi.getValueStringUtf8(50)); - // [End ark_napi_get_value_string_utf8] - // [Start ark_napi_create_string_utf8] - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_string_utf8:%{public}s', - testNapi.createStringUtf8()); - // [End ark_napi_create_string_utf8] - // [Start ark_napi_get_value_string_utf16] - let result = testNapi.getValueStringUtf16('hello,'); - hilog.info(0x0000, 'testTag', 'Node-API napi_get_value_string_utf16:%{public}s', result); - // [End ark_napi_get_value_string_utf16] - // [Start ark_napi_create_string_utf16] - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_string_utf16:%{public}s ', - testNapi.createStringUtf16()); - // [End ark_napi_create_string_utf16] - // [Start ark_napi_get_value_string_latin1] - // 传入非字符型数据,函数返回undefined - hilog.info(0x0000, 'testTag', 'Test Node-API get_value_string_latin1_not_string %{public}s', - testNapi.getValueStringLatin1(10)); - // ISO-8859-1编码不支持中文,传入中文字符会乱码 - hilog.info(0x0000, 'testTag', 'Test Node-API get_value_string_latin1_string_chinese %{public}s', - testNapi.getValueStringLatin1('中文')); - // 传入其他字符,不会乱码 - hilog.info(0x0000, 'testTag', 'Test Node-API get_value_string_latin1_string %{public}s', - testNapi.getValueStringLatin1('abo ABP=-&*/')); - // [End ark_napi_get_value_string_latin1] - // [Start ark_napi_create_string_latin1] - hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_string_latin1:%{public}s', - testNapi.createStringLatin1()); - // End ark_napi_create_string_latin1] - this.result = 'napiStringSuccess'; - } - }) - } - }) - }.scrollBar(BarState.Off) - .width('90%') - }.width('100%') - .height('100%') - .backgroundColor(0xDCDCDC) - .padding({ top: 5 }) - } -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/module.json5 deleted file mode 100755 index 776ce01475..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/module.json5 +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/color.json deleted file mode 100755 index d66f9a7d4a..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100755 index d742c2f96e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/dark/element/color.json deleted file mode 100755 index 438d5bc43b..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/module.json5 deleted file mode 100755 index 9983b2ba4e..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/hvigor/hvigor-config.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/hvigor/hvigor-config.json5 deleted file mode 100755 index cef74543b1..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.1", - "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/ArkTs/NodeAPI/NodeApiUse/NodeApiString/oh-package.json5 b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/oh-package.json5 deleted file mode 100755 index eaef52736f..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/oh-package.json5 +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} diff --git a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/ohosTest.md b/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/ohosTest.md deleted file mode 100755 index b476a5dddb..0000000000 --- a/code/DocsSample/ArkTs/NodeAPI/NodeApiUse/NodeApiString/ohosTest.md +++ /dev/null @@ -1,8 +0,0 @@ -# 使用Node-API进行string相关开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | -| ------------------------------------------------------------ | ------------ | -------------------------------- | ------------------------------------------------------------ | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Pass | -| ArkTS端成功调用native侧接口 getValueStringUtf8,createStringUtf8,getValueStringUtf16, createStringUtf16, getValueStringLatin1,createStringLatin1 | 位于主页 | 点击文本为1.napiString的文本组件 | 成功调用函数输出日志,页面顶端文本变为Result: napiStringSuccess | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListAcrScrollBar.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListAcrScrollBar.ets index 6cb9df1e99..cc00ad82b6 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListAcrScrollBar.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListAcrScrollBar.ets @@ -1,139 +1,139 @@ -/* - * 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 { - ArcList, - ArcListItem, - ArcListAttribute, - ArcListItemAttribute, - LengthMetrics, - ArcScrollBar, -} from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct ArcListAcrScrollBar { - private arcListScroller: Scroller = new Scroller(); - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcListAcrScrollBar_title') }) { - ArcList({ scroller: this.arcListScroller }) { - ArcListItem() { - Row() { - Image($r('app.media.wlan')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.blueTooth')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.mobileData')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.displayAndBrightness')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - } - .width('466px') - .height('466px') - .space(LengthMetrics.px(10)) - .borderRadius('233px') - .backgroundColor(Color.Black) - - ArcScrollBar({ scroller: this.arcListScroller }) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcListAcrScrollBar_title')) - } +/* + * 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 { + ArcList, + ArcListItem, + ArcListAttribute, + ArcListItemAttribute, + LengthMetrics, + ArcScrollBar, +} from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct ArcListAcrScrollBar { + private arcListScroller: Scroller = new Scroller(); + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcListAcrScrollBar_title') }) { + ArcList({ scroller: this.arcListScroller }) { + ArcListItem() { + Row() { + Image($r('app.media.wlan')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.blueTooth')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.mobileData')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.displayAndBrightness')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + } + .width('466px') + .height('466px') + .space(LengthMetrics.px(10)) + .borderRadius('233px') + .backgroundColor(Color.Black) + + ArcScrollBar({ scroller: this.arcListScroller }) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcListAcrScrollBar_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListArcIndexerBar.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListArcIndexerBar.ets index ca16ea3554..a6ac032409 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListArcIndexerBar.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListArcIndexerBar.ets @@ -1,155 +1,155 @@ -/* - * 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 { ArcList, ArcListAttribute, ArcListItemAttribute, ArcListItem, LengthMetrics } from '@kit.ArkUI'; -import { ColorMetrics, ComponentContent } from '@ohos.arkui.node'; -import { util } from '@kit.ArkTS'; -import { ArcAlphabetIndexer, ArcAlphabetIndexerAttribute } from '@ohos.arkui.ArcAlphabetIndexer'; -import { ComponentCard } from '../../common/Card'; - -class Contact { - key: string = util.generateRandomUUID(true); - name: string; - firstChar: string; - - constructor(name: string, firstChar: string) { - this.name = name; - this.firstChar = firstChar; - } -} -@Builder -function buildText() { - Column() { - Text('Contacts') - .fontColor('#FFFFFF') - .fontSize('19fp') - - } -} - -@Entry -@Component -export struct ArcListArcIndexerBar { - - @State contacts: Array = [ - new Contact('阿哈', 'A'), - new Contact('贝贝', 'B'), - new Contact('彩彩', 'C'), - new Contact('东东', 'D'), - new Contact('嗯嗯', 'E'), - new Contact('芳芳', 'F'), - new Contact('哥哥', 'G'), - new Contact('哈哈', 'H'), - new Contact('吉吉', 'J'), - new Contact('可可', 'K'), - new Contact('乐乐', 'L'), - new Contact('妹妹', 'M'), - new Contact('妮妮', 'N'), - new Contact('哦豁', 'O'), - new Contact('胖胖', 'P'), - new Contact('琪琪', 'Q'), - new Contact('然然', 'R'), - new Contact('叔叔', 'S'), - new Contact('天天', 'T'), - ]; - private scrollerForList: Scroller = new Scroller(); - private watchSize: string = '600px'; // 手表默认宽高:233*233 - private fullValue: string[] = [ - '#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' - ]; - @State indexerIndex: number = 0; - - context: UIContext = this.getUIContext(); - tabBar1: ComponentContent = new ComponentContent(this.context, wrapBuilder(buildText)); - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcListArcIndexerBar_title') }) { - Stack() { - ArcList({ initialIndex: 0, header:this.tabBar1, scroller:this.scrollerForList }) { - ForEach(this.contacts, (item: Contact) => { - ArcListItem() { - Row() { - Text(item.firstChar) - .textAlign(TextAlign.Center) - .width(30) - .height(30) - .margin(10) - .backgroundColor('#FF9CC998') - .borderRadius(20) - Text(item.name).fontSize('38px').fontColor('#FFFFFFFF') - } - .width('100%') - .justifyContent(FlexAlign.Start) - } - .borderRadius('65px') - .width('370px') - .height('130px') - .backgroundColor('#26FFFFFF') - }, (item: Contact) => JSON.stringify(item)) - } - .space(LengthMetrics.px(10)) - .scrollBar(BarState.Off) - .width(this.watchSize) - .height(this.watchSize) - .borderRadius(this.watchSize) - .backgroundColor(Color.Black) - .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { - this.indexerIndex = centerIndex + 1; - }) - - ArcAlphabetIndexer({ arrayValue: this.fullValue, selected: this.indexerIndex}) - .autoCollapse(true) - .width(this.watchSize) - .height(this.watchSize) - .usePopup(false) - .selected(this.indexerIndex!!) - .onSelect((index: number) => { - this.indexerIndex = index - this.scrollerForList.scrollToIndex(this.indexerIndex - 1) - }) - .hitTestBehavior(HitTestMode.Transparent) - .selectedColor(ColorMetrics.resourceColor(0xFFFFFF)) - .selectedBackgroundColor(ColorMetrics.resourceColor(0x1F71FF)) - .color(ColorMetrics.resourceColor(0xFFFFFF)) - .popupColor(ColorMetrics.resourceColor(0xFFFFFF)) - .popupBackground(ColorMetrics.resourceColor(0xD8404040)) - .itemSize(LengthMetrics.px(12)) - .selectedFont({ - size: '11.0fp', - style: FontStyle.Normal, - weight: 500, - family: 'HarmonyOS Sans' - }) - .font({ - size: '11.0fp', - style: FontStyle.Normal, - weight: 500, - family: 'HarmonyOS Sans' - }) - - }.width('600px') - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcListArcIndexerBar_title')) - } -} +/* + * 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 { ArcList, ArcListAttribute, ArcListItemAttribute, ArcListItem, LengthMetrics } from '@kit.ArkUI'; +import { ColorMetrics, ComponentContent } from '@ohos.arkui.node'; +import { util } from '@kit.ArkTS'; +import { ArcAlphabetIndexer, ArcAlphabetIndexerAttribute } from '@ohos.arkui.ArcAlphabetIndexer'; +import { ComponentCard } from '../../common/Card'; + +class Contact { + key: string = util.generateRandomUUID(true); + name: string; + firstChar: string; + + constructor(name: string, firstChar: string) { + this.name = name; + this.firstChar = firstChar; + } +} +@Builder +function buildText() { + Column() { + Text('Contacts') + .fontColor('#FFFFFF') + .fontSize('19fp') + + } +} + +@Entry +@Component +export struct ArcListArcIndexerBar { + + @State contacts: Array = [ + new Contact('阿哈', 'A'), + new Contact('贝贝', 'B'), + new Contact('彩彩', 'C'), + new Contact('东东', 'D'), + new Contact('嗯嗯', 'E'), + new Contact('芳芳', 'F'), + new Contact('哥哥', 'G'), + new Contact('哈哈', 'H'), + new Contact('吉吉', 'J'), + new Contact('可可', 'K'), + new Contact('乐乐', 'L'), + new Contact('妹妹', 'M'), + new Contact('妮妮', 'N'), + new Contact('哦豁', 'O'), + new Contact('胖胖', 'P'), + new Contact('琪琪', 'Q'), + new Contact('然然', 'R'), + new Contact('叔叔', 'S'), + new Contact('天天', 'T'), + ]; + private scrollerForList: Scroller = new Scroller(); + private watchSize: string = '600px'; // 手表默认宽高:233*233 + private fullValue: string[] = [ + '#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' + ]; + @State indexerIndex: number = 0; + + context: UIContext = this.getUIContext(); + tabBar1: ComponentContent = new ComponentContent(this.context, wrapBuilder(buildText)); + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcListArcIndexerBar_title') }) { + Stack() { + ArcList({ initialIndex: 0, header:this.tabBar1, scroller:this.scrollerForList }) { + ForEach(this.contacts, (item: Contact) => { + ArcListItem() { + Row() { + Text(item.firstChar) + .textAlign(TextAlign.Center) + .width(30) + .height(30) + .margin(10) + .backgroundColor('#FF9CC998') + .borderRadius(20) + Text(item.name).fontSize('38px').fontColor('#FFFFFFFF') + } + .width('100%') + .justifyContent(FlexAlign.Start) + } + .borderRadius('65px') + .width('370px') + .height('130px') + .backgroundColor('#26FFFFFF') + }, (item: Contact) => JSON.stringify(item)) + } + .space(LengthMetrics.px(10)) + .scrollBar(BarState.Off) + .width(this.watchSize) + .height(this.watchSize) + .borderRadius(this.watchSize) + .backgroundColor(Color.Black) + .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { + this.indexerIndex = centerIndex + 1; + }) + + ArcAlphabetIndexer({ arrayValue: this.fullValue, selected: this.indexerIndex}) + .autoCollapse(true) + .width(this.watchSize) + .height(this.watchSize) + .usePopup(false) + .selected(this.indexerIndex!!) + .onSelect((index: number) => { + this.indexerIndex = index + this.scrollerForList.scrollToIndex(this.indexerIndex - 1) + }) + .hitTestBehavior(HitTestMode.Transparent) + .selectedColor(ColorMetrics.resourceColor(0xFFFFFF)) + .selectedBackgroundColor(ColorMetrics.resourceColor(0x1F71FF)) + .color(ColorMetrics.resourceColor(0xFFFFFF)) + .popupColor(ColorMetrics.resourceColor(0xFFFFFF)) + .popupBackground(ColorMetrics.resourceColor(0xD8404040)) + .itemSize(LengthMetrics.px(12)) + .selectedFont({ + size: '11.0fp', + style: FontStyle.Normal, + weight: 500, + family: 'HarmonyOS Sans' + }) + .font({ + size: '11.0fp', + style: FontStyle.Normal, + weight: 500, + family: 'HarmonyOS Sans' + }) + + }.width('600px') + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcListArcIndexerBar_title')) + } +} diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListContents.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListContents.ets index 007f3911dd..ed930ddd36 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListContents.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListContents.ets @@ -1,81 +1,81 @@ -/* - * 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 { ArcList, ArcListAttribute, ArcListItemAttribute, ArcListItem, LengthMetrics } from '@kit.ArkUI'; -import { util } from '@kit.ArkTS'; -import { ComponentCard } from '../../common/Card'; - -class Contact { - key: string = util.generateRandomUUID(true); - name: string; - icon: Resource; - - constructor(name: string, icon: Resource) { - this.name = name; - this.icon = icon; - } -} - -@Entry -@Component -export struct ArcListContents { - private contacts: Array = [ - new Contact('小红', $r('app.media.ic_contact')), - new Contact('小兰', $r('app.media.ic_contact')), - new Contact('小王', $r('app.media.ic_contact')), - new Contact('小李', $r('app.media.ic_contact')), - new Contact('小明', $r('app.media.ic_contact')) - ]; - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcListContents_title') }) { - ArcList({ initialIndex: 2 }) { - ForEach(this.contacts, (item: Contact) => { - ArcListItem() { - Row() { - Image(item.icon) - .width(40) - .height(40) - .margin(10) - .backgroundColor('#FF9CC998') - .borderRadius(20) - Text(item.name).fontSize('38px').fontColor('#FFFFFFFF') - } - .width('100%') - .justifyContent(FlexAlign.Start) - } - .borderRadius('65px') - .width('410px') - .height('130px') - .backgroundColor('#26FFFFFF') - }, (item: Contact) => JSON.stringify(item)) - } - .space(LengthMetrics.px(10)) - .width('466px') - .height('466px') - .borderRadius('233px') - .backgroundColor(Color.Black) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcListContents_title')) - } +/* + * 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 { ArcList, ArcListAttribute, ArcListItemAttribute, ArcListItem, LengthMetrics } from '@kit.ArkUI'; +import { util } from '@kit.ArkTS'; +import { ComponentCard } from '../../common/Card'; + +class Contact { + key: string = util.generateRandomUUID(true); + name: string; + icon: Resource; + + constructor(name: string, icon: Resource) { + this.name = name; + this.icon = icon; + } +} + +@Entry +@Component +export struct ArcListContents { + private contacts: Array = [ + new Contact('小红', $r('app.media.ic_contact')), + new Contact('小兰', $r('app.media.ic_contact')), + new Contact('小王', $r('app.media.ic_contact')), + new Contact('小李', $r('app.media.ic_contact')), + new Contact('小明', $r('app.media.ic_contact')) + ]; + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcListContents_title') }) { + ArcList({ initialIndex: 2 }) { + ForEach(this.contacts, (item: Contact) => { + ArcListItem() { + Row() { + Image(item.icon) + .width(40) + .height(40) + .margin(10) + .backgroundColor('#FF9CC998') + .borderRadius(20) + Text(item.name).fontSize('38px').fontColor('#FFFFFFFF') + } + .width('100%') + .justifyContent(FlexAlign.Start) + } + .borderRadius('65px') + .width('410px') + .height('130px') + .backgroundColor('#26FFFFFF') + }, (item: Contact) => JSON.stringify(item)) + } + .space(LengthMetrics.px(10)) + .width('466px') + .height('466px') + .borderRadius('233px') + .backgroundColor(Color.Black) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcListContents_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListCrown.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListCrown.ets index cc76cdd3cb..e25e75003b 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListCrown.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListCrown.ets @@ -1,135 +1,135 @@ -/* - * 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 { ColorMetrics, LengthMetrics } from '@kit.ArkUI'; -import { ArcList, ArcListItem, ArcListAttribute, ArcListItemAttribute } from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Builder -function buildText() { - Column() { - Text($r('app.string.ArcListCrown_set')) - .fontColor('#FFFFFF') - .fontSize('19fp') - - }.height(10) -} - -@Entry -@Component -export struct ArcListCrown { - private watchSize: string = '466px'; // 手表默认宽高:466*466 - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcListCrown_title') }) { - Stack() { - ArcList({ - initialIndex: 2, - }) { - ArcListItem() { - Text('Network').fontSize('38px').fontColor('#FFFFFFFF') - } - .borderRadius('65px') - .width('414px') - .height('50px') - .autoScale(false) - - ArcListItem() { - Row() { - Image($r('app.media.wlan')).width('80px').height('80px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text('WLAN').fontSize('38px').fontColor('#FFFFFFFF') - Text('On').fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('80px').height('80px') - .borderRadius('50px') - } - - } - .borderRadius('65px') - .width('414px') - .height('100px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.mobileData')).width('80px').height('80px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text('Bluetooth').fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('80px').height('80px') - .borderRadius('50px') - } - - } - .borderRadius('65px') - .width('414px') - .height('100px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Text('Display').fontSize('38px').fontColor('#FFFFFFFF') - } - .borderRadius('65px') - .width('414px') - .height('50px') - .autoScale(false) - - ArcListItem() { - Row() { - Image($r('app.media.displayAndBrightness')).width('80px').height('80px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text('Display & brightness').fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('80px').height('80px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('100px') - .backgroundColor('#26FFFFFF') - } - .space(LengthMetrics.px(10)) - .scrollBarWidth(LengthMetrics.px(10)) - .scrollBarColor(ColorMetrics.resourceColor(Color.White)) - .borderRadius(this.watchSize) - .focusable(true) - .focusOnTouch(true) - .defaultFocus(true) - } - .align(Alignment.Center) - .width(this.watchSize) - .height(this.watchSize) - .borderRadius(this.watchSize) - .backgroundColor(Color.Black) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcListCrown_title')) - } +/* + * 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 { ColorMetrics, LengthMetrics } from '@kit.ArkUI'; +import { ArcList, ArcListItem, ArcListAttribute, ArcListItemAttribute } from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Builder +function buildText() { + Column() { + Text($r('app.string.ArcListCrown_set')) + .fontColor('#FFFFFF') + .fontSize('19fp') + + }.height(10) +} + +@Entry +@Component +export struct ArcListCrown { + private watchSize: string = '466px'; // 手表默认宽高:466*466 + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcListCrown_title') }) { + Stack() { + ArcList({ + initialIndex: 2, + }) { + ArcListItem() { + Text('Network').fontSize('38px').fontColor('#FFFFFFFF') + } + .borderRadius('65px') + .width('414px') + .height('50px') + .autoScale(false) + + ArcListItem() { + Row() { + Image($r('app.media.wlan')).width('80px').height('80px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text('WLAN').fontSize('38px').fontColor('#FFFFFFFF') + Text('On').fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('80px').height('80px') + .borderRadius('50px') + } + + } + .borderRadius('65px') + .width('414px') + .height('100px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.mobileData')).width('80px').height('80px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text('Bluetooth').fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('80px').height('80px') + .borderRadius('50px') + } + + } + .borderRadius('65px') + .width('414px') + .height('100px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Text('Display').fontSize('38px').fontColor('#FFFFFFFF') + } + .borderRadius('65px') + .width('414px') + .height('50px') + .autoScale(false) + + ArcListItem() { + Row() { + Image($r('app.media.displayAndBrightness')).width('80px').height('80px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text('Display & brightness').fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('80px').height('80px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('100px') + .backgroundColor('#26FFFFFF') + } + .space(LengthMetrics.px(10)) + .scrollBarWidth(LengthMetrics.px(10)) + .scrollBarColor(ColorMetrics.resourceColor(Color.White)) + .borderRadius(this.watchSize) + .focusable(true) + .focusOnTouch(true) + .defaultFocus(true) + } + .align(Alignment.Center) + .width(this.watchSize) + .height(this.watchSize) + .borderRadius(this.watchSize) + .backgroundColor(Color.Black) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcListCrown_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListShow.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListShow.ets index 932600a062..a46936d5cd 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListShow.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListShow.ets @@ -1,128 +1,128 @@ -/* - * 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 { ArcList, ArcListItem, ArcListAttribute, ArcListItemAttribute, LengthMetrics, } from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct ArcListShow { - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcListShow_title') }) { - ArcList({ initialIndex: 2 }) { - ArcListItem() { - Row() { - Image($r('app.media.wlan')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.blueTooth')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.mobileData')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.displayAndBrightness')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - } - .width('466px') - .height('466px') - .space(LengthMetrics.px(10)) - .borderRadius('233px') - .backgroundColor(Color.Black) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcListShow_title')) - } +/* + * 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 { ArcList, ArcListItem, ArcListAttribute, ArcListItemAttribute, LengthMetrics, } from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct ArcListShow { + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcListShow_title') }) { + ArcList({ initialIndex: 2 }) { + ArcListItem() { + Row() { + Image($r('app.media.wlan')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.blueTooth')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.mobileData')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.displayAndBrightness')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + } + .width('466px') + .height('466px') + .space(LengthMetrics.px(10)) + .borderRadius('233px') + .backgroundColor(Color.Black) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcListShow_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListSideSlip.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListSideSlip.ets index ce364a1d34..e17cda1880 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListSideSlip.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListSideSlip.ets @@ -1,159 +1,159 @@ -/* - * 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 { ArcList, ArcListAttribute, ArcListItemAttribute, ArcListItem } from '@kit.ArkUI'; -import { ComponentContent, LengthMetrics } from '@ohos.arkui.node'; -import { util } from '@kit.ArkTS'; -import { ComponentCard } from '../../common/Card'; - -class Contact { - key: string = util.generateRandomUUID(true); - name: string; - firstChar: string; - - constructor(name: string, firstChar: string) { - this.name = name; - this.firstChar = firstChar; - } -} -@Builder -function buildText() { - Column() { - Text('Contacts ') - .fontColor('#FFFFFF') - .fontSize('19fp') - - } -} - -@Entry -@Component -export struct ArcListSideSlip { - @State contacts: Array = [ - new Contact('Alice', 'A'), - new Contact('Bob', 'B'), - new Contact('Charlie', 'C'), - new Contact('Diana', 'D'), - new Contact('Eve', 'E'), - new Contact('阿哈', 'A'), - new Contact('贝贝', 'B'), - new Contact('彩彩', 'C'), - new Contact('东东', 'D'), - new Contact('嗯嗯', 'E'), - new Contact('芳芳', 'F'), - new Contact('哥哥', 'G'), - new Contact('哈哈', 'H'), - new Contact('吉吉', 'J'), - new Contact('可可', 'K'), - new Contact('乐乐', 'L'), - new Contact('妹妹', 'M'), - new Contact('妮妮', 'N'), - new Contact('哦豁', 'O'), - new Contact('胖胖', 'P'), - new Contact('琪琪', 'Q'), - new Contact('然然', 'R'), - new Contact('叔叔', 'S'), - new Contact('天天', 'T'), - ]; - - private scrollerForList: Scroller = new Scroller(); - - @State indexerIndex: number = 0; - context: UIContext = this.getUIContext(); - tabBar1: ComponentContent = new ComponentContent(this.context, wrapBuilder(buildText)); - - @Builder - itemEnd(item: Contact) { - // 构建尾端滑出组件 - Button({ type: ButtonType.Circle }) { - Image($r('app.media.MaterialSymbolsDelete')) - .width(20) - .height(20) - } - .width(20) - .height(20) - .backgroundColor(Color.Black) - .onClick(() => { - this.getUIContext()?.animateTo({ - duration: 1000, - curve: Curve.Smooth, - iterations: 1, - playMode: PlayMode.Normal, - }, () => { - let index = this.contacts.indexOf(item); - this.contacts.splice(index, 1); - }) - - }) - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcListSideSlip_title') }) { - Stack() { - ArcList({ initialIndex: 0, header: this.tabBar1, scroller: this.scrollerForList }) { - ForEach(this.contacts, (item: Contact) => { - ArcListItem() { - Row() { - Text(item.firstChar) - .textAlign(TextAlign.Center) - .width(30) - .height(30) - .margin(10) - .backgroundColor('#FF9CC998') - .borderRadius(20) - Text(item.name).fontSize('38px').fontColor('#FFFFFFFF') - } - .backgroundColor('#26FFFFFF') - .borderRadius('65px') - .width('90%') - .justifyContent(FlexAlign.Start) - } - .swipeAction({ - end: { - // index为该ArcListItem在ArcList中的索引值。 - builder: () => { - this.itemEnd(item); - }, - } - }) // 设置侧滑属性. - .borderRadius('65px') - .width('400px') - .height('130px') - - }, (item: Contact) => JSON.stringify(item)) - } - .space(LengthMetrics.px(10)) - .scrollBar(BarState.Auto) - .width('466px') - .height('466px') - .borderRadius('233px') - .backgroundColor(Color.Black) - .margin(50) - .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { - this.indexerIndex = centerIndex + 1; - }) - } - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcListSideSlip_title')) - } +/* + * 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 { ArcList, ArcListAttribute, ArcListItemAttribute, ArcListItem } from '@kit.ArkUI'; +import { ComponentContent, LengthMetrics } from '@ohos.arkui.node'; +import { util } from '@kit.ArkTS'; +import { ComponentCard } from '../../common/Card'; + +class Contact { + key: string = util.generateRandomUUID(true); + name: string; + firstChar: string; + + constructor(name: string, firstChar: string) { + this.name = name; + this.firstChar = firstChar; + } +} +@Builder +function buildText() { + Column() { + Text('Contacts ') + .fontColor('#FFFFFF') + .fontSize('19fp') + + } +} + +@Entry +@Component +export struct ArcListSideSlip { + @State contacts: Array = [ + new Contact('Alice', 'A'), + new Contact('Bob', 'B'), + new Contact('Charlie', 'C'), + new Contact('Diana', 'D'), + new Contact('Eve', 'E'), + new Contact('阿哈', 'A'), + new Contact('贝贝', 'B'), + new Contact('彩彩', 'C'), + new Contact('东东', 'D'), + new Contact('嗯嗯', 'E'), + new Contact('芳芳', 'F'), + new Contact('哥哥', 'G'), + new Contact('哈哈', 'H'), + new Contact('吉吉', 'J'), + new Contact('可可', 'K'), + new Contact('乐乐', 'L'), + new Contact('妹妹', 'M'), + new Contact('妮妮', 'N'), + new Contact('哦豁', 'O'), + new Contact('胖胖', 'P'), + new Contact('琪琪', 'Q'), + new Contact('然然', 'R'), + new Contact('叔叔', 'S'), + new Contact('天天', 'T'), + ]; + + private scrollerForList: Scroller = new Scroller(); + + @State indexerIndex: number = 0; + context: UIContext = this.getUIContext(); + tabBar1: ComponentContent = new ComponentContent(this.context, wrapBuilder(buildText)); + + @Builder + itemEnd(item: Contact) { + // 构建尾端滑出组件 + Button({ type: ButtonType.Circle }) { + Image($r('app.media.MaterialSymbolsDelete')) + .width(20) + .height(20) + } + .width(20) + .height(20) + .backgroundColor(Color.Black) + .onClick(() => { + this.getUIContext()?.animateTo({ + duration: 1000, + curve: Curve.Smooth, + iterations: 1, + playMode: PlayMode.Normal, + }, () => { + let index = this.contacts.indexOf(item); + this.contacts.splice(index, 1); + }) + + }) + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcListSideSlip_title') }) { + Stack() { + ArcList({ initialIndex: 0, header: this.tabBar1, scroller: this.scrollerForList }) { + ForEach(this.contacts, (item: Contact) => { + ArcListItem() { + Row() { + Text(item.firstChar) + .textAlign(TextAlign.Center) + .width(30) + .height(30) + .margin(10) + .backgroundColor('#FF9CC998') + .borderRadius(20) + Text(item.name).fontSize('38px').fontColor('#FFFFFFFF') + } + .backgroundColor('#26FFFFFF') + .borderRadius('65px') + .width('90%') + .justifyContent(FlexAlign.Start) + } + .swipeAction({ + end: { + // index为该ArcListItem在ArcList中的索引值。 + builder: () => { + this.itemEnd(item); + }, + } + }) // 设置侧滑属性. + .borderRadius('65px') + .width('400px') + .height('130px') + + }, (item: Contact) => JSON.stringify(item)) + } + .space(LengthMetrics.px(10)) + .scrollBar(BarState.Auto) + .width('466px') + .height('466px') + .borderRadius('233px') + .backgroundColor(Color.Black) + .margin(50) + .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { + this.indexerIndex = centerIndex + 1; + }) + } + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcListSideSlip_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListStyles.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListStyles.ets index d3452e6ba7..ff990f8ed7 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListStyles.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcListStyles.ets @@ -1,351 +1,351 @@ -/* - * 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 { - ArcList, - ArcListItem, - ArcListAttribute, - ArcListItemAttribute, - LengthMetrics, - ComponentContent -} from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Builder -function customHeader() { - Column() { - Text($r('app.string.ArcListCrown_set')) - .fontColor('#FFFFFFFF') - .fontSize('19fp') - } -} - - -@Entry -@Component -export struct ArcListStyles { - context: UIContext = this.getUIContext(); - arcListHeader: ComponentContent = new ComponentContent(this.context, wrapBuilder(customHeader)); - - build() { - NavDestination() { - Column({ space: 12 }) { - List(){ - ListItem(){ - ComponentCard({ title: $r('app.string.ArcListStyles_head') }) { - ArcList({ header: this.arcListHeader }) { - ArcListItem() { - Row() { - Image($r('app.media.wlan')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.blueTooth')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.mobileData')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.displayAndBrightness')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - } - .width('466px') - .height('466px') - .space(LengthMetrics.px(10)) - .borderRadius('233px') - .backgroundColor(Color.Black) - } - } - - ListItem(){ - ComponentCard({ title: $r('app.string.ArcListStyles_titleSpacing') }) { - ArcList({ initialIndex: 2 }) { - ArcListItem() { - Row() { - Image($r('app.media.wlan')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.blueTooth')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.mobileData')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.displayAndBrightness')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - } - .width('466px') - .height('466px') - .space(LengthMetrics.px(30)) - .borderRadius('233px') - .backgroundColor(Color.Black) - - } - } - - ListItem(){ - ComponentCard({ title: $r('app.string.ArcListStyles_titleScale') }) { - ArcList({ initialIndex: 2 }) { - ArcListItem() { - Row() { - Image($r('app.media.wlan')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.blueTooth')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.mobileData')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - .autoScale(false) - - ArcListItem() { - Row() { - Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.displayAndBrightness')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - .autoScale(false) - } - .width('466px') - .height('466px') - .space(LengthMetrics.px(30)) - .borderRadius('233px') - .backgroundColor(Color.Black) - } - } - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcListStyles_title')) - } +/* + * 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 { + ArcList, + ArcListItem, + ArcListAttribute, + ArcListItemAttribute, + LengthMetrics, + ComponentContent +} from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Builder +function customHeader() { + Column() { + Text($r('app.string.ArcListCrown_set')) + .fontColor('#FFFFFFFF') + .fontSize('19fp') + } +} + + +@Entry +@Component +export struct ArcListStyles { + context: UIContext = this.getUIContext(); + arcListHeader: ComponentContent = new ComponentContent(this.context, wrapBuilder(customHeader)); + + build() { + NavDestination() { + Column({ space: 12 }) { + List(){ + ListItem(){ + ComponentCard({ title: $r('app.string.ArcListStyles_head') }) { + ArcList({ header: this.arcListHeader }) { + ArcListItem() { + Row() { + Image($r('app.media.wlan')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.blueTooth')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.mobileData')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.displayAndBrightness')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + } + .width('466px') + .height('466px') + .space(LengthMetrics.px(10)) + .borderRadius('233px') + .backgroundColor(Color.Black) + } + } + + ListItem(){ + ComponentCard({ title: $r('app.string.ArcListStyles_titleSpacing') }) { + ArcList({ initialIndex: 2 }) { + ArcListItem() { + Row() { + Image($r('app.media.wlan')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.blueTooth')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.mobileData')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.displayAndBrightness')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + } + .width('466px') + .height('466px') + .space(LengthMetrics.px(30)) + .borderRadius('233px') + .backgroundColor(Color.Black) + + } + } + + ListItem(){ + ComponentCard({ title: $r('app.string.ArcListStyles_titleScale') }) { + ArcList({ initialIndex: 2 }) { + ArcListItem() { + Row() { + Image($r('app.media.wlan')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.blueTooth')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.mobileData')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + .autoScale(false) + + ArcListItem() { + Row() { + Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.displayAndBrightness')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + .autoScale(false) + } + .width('466px') + .height('466px') + .space(LengthMetrics.px(30)) + .borderRadius('233px') + .backgroundColor(Color.Black) + } + } + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcListStyles_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcLongList.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcLongList.ets index 6ddd21ef91..a12b2467a9 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcLongList.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/ArcLongList.ets @@ -1,151 +1,151 @@ -/* - * 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 { ArcList, ArcListAttribute, ArcListItemAttribute, ArcListItem } from '@kit.ArkUI'; -import { LengthMetrics } from '@ohos.arkui.node'; -import { ComponentCard } from '../../common/Card'; - -class BasicDataSource implements IDataSource { - private listeners: DataChangeListener[] = []; - private originDataArray: StringData[] = []; - - public totalCount(): number { - return 0; - } - - public getData(index: number): StringData { - return this.originDataArray[index]; - } - - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - console.info('add listener'); - this.listeners.push(listener); - } - } - - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener); - if (pos >= 0) { - console.info('remove listener'); - this.listeners.splice(pos, 1); - } - } - - notifyDataReload(): void { - this.listeners.forEach(listener => { - listener.onDataReloaded(); - }); - } - - notifyDataAdd(index: number): void { - this.listeners.forEach(listener => { - listener.onDataAdd(index); - }); - } - - notifyDataChange(index: number): void { - this.listeners.forEach(listener => { - listener.onDataChange(index); - }); - } - - notifyDataDelete(index: number): void { - this.listeners.forEach(listener => { - listener.onDataDelete(index); - }); - } - - notifyDataMove(from: number, to: number): void { - this.listeners.forEach(listener => { - listener.onDataMove(from, to); - }); - } - - notifyDatasetChange(operations: DataOperation[]): void { - this.listeners.forEach(listener => { - listener.onDatasetChange(operations); - }); - } -} - -class MyDataSource extends BasicDataSource { - private dataArray: StringData[] = []; - - public totalCount(): number { - return this.dataArray.length; - } - - public getData(index: number): StringData { - return this.dataArray[index]; - } - - public pushData(data: StringData): void { - this.dataArray.push(data); - this.notifyDataAdd(this.dataArray.length - 1); - } -} - -@Observed -class StringData { - message: string; - - constructor(message: string) { - this.message = message; - } -} - -@Entry -@Component -export struct ArcLongList { - private data: MyDataSource = new MyDataSource(); - - aboutToAppear() { - for (let i = 0; i <= 100; i++) { - this.data.pushData(new StringData(`Hello ${i}`)); - } - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcLongList_title') }) { - ArcList() { - LazyForEach(this.data, (item: StringData, index: number) => { - ArcListItem() { - Text(item.message).fontSize(30).fontColor(Color.White) - } - .onClick(() => { - item.message += '0'; - }) - }, (item: StringData, index: number) => JSON.stringify(item) + index.toString()) - }.cachedCount(3) - .space(LengthMetrics.px(10)) - .scrollBar(BarState.Auto) - .width('466px') - .height('466px') - .borderRadius('233px') - .backgroundColor(Color.Black) - .margin(50) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcLongList_title')) - } +/* + * 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 { ArcList, ArcListAttribute, ArcListItemAttribute, ArcListItem } from '@kit.ArkUI'; +import { LengthMetrics } from '@ohos.arkui.node'; +import { ComponentCard } from '../../common/Card'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + private originDataArray: StringData[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): StringData { + return this.originDataArray[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }); + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }); + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }); + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }); + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }); + } + + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }); + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: StringData[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): StringData { + return this.dataArray[index]; + } + + public pushData(data: StringData): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Observed +class StringData { + message: string; + + constructor(message: string) { + this.message = message; + } +} + +@Entry +@Component +export struct ArcLongList { + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i <= 100; i++) { + this.data.pushData(new StringData(`Hello ${i}`)); + } + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcLongList_title') }) { + ArcList() { + LazyForEach(this.data, (item: StringData, index: number) => { + ArcListItem() { + Text(item.message).fontSize(30).fontColor(Color.White) + } + .onClick(() => { + item.message += '0'; + }) + }, (item: StringData, index: number) => JSON.stringify(item) + index.toString()) + }.cachedCount(3) + .space(LengthMetrics.px(10)) + .scrollBar(BarState.Auto) + .width('466px') + .height('466px') + .borderRadius('233px') + .backgroundColor(Color.Black) + .margin(50) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcLongList_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/arcListBuiltInScrollerBar.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/arcListBuiltInScrollerBar.ets index f38604db4a..d9d8ec8cf8 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/arcListBuiltInScrollerBar.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/arcListBuiltInScrollerBar.ets @@ -1,129 +1,129 @@ -/* - * 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 { ArcList, ArcListItem, ArcListAttribute, ArcListItemAttribute, LengthMetrics, ColorMetrics } from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct arcListBuiltInScrollerBar { - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.arcListBuiltInScrollerBar_title') }) { - ArcList() { - ArcListItem() { - Row() { - Image($r('app.media.wlan')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.blueTooth')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') - Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.mobileData')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - - ArcListItem() { - Row() { - Image($r('app.media.displayAndBrightness')).width('99px').height('99px') - .borderRadius('50px').margin({ left: 7 }) - Column() { - Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') - }.width('190px') - - Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') - .borderRadius('50px') - } - } - .borderRadius('65px') - .width('414px') - .height('129px') - .backgroundColor('#26FFFFFF') - } - .width('466px') - .height('466px') - .space(LengthMetrics.px(10)) - .borderRadius('233px') - .backgroundColor(Color.Black) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.arcListBuiltInScrollerBar_title')) - } +/* + * 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 { ArcList, ArcListItem, ArcListAttribute, ArcListItemAttribute, LengthMetrics, ColorMetrics } from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct arcListBuiltInScrollerBar { + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.arcListBuiltInScrollerBar_title') }) { + ArcList() { + ArcListItem() { + Row() { + Image($r('app.media.wlan')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_waln')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.blueTooth')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_blue')).fontSize('38px').fontColor('#FFFFFFFF') + Text($r('app.string.ArcListStyles_open')).fontSize('20px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.mobileData')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_net')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.ic_settings_more_connections')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_connect')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + + ArcListItem() { + Row() { + Image($r('app.media.displayAndBrightness')).width('99px').height('99px') + .borderRadius('50px').margin({ left: 7 }) + Column() { + Text($r('app.string.ArcListStyles_light')).fontSize('38px').fontColor('#FFFFFFFF') + }.width('190px') + + Image($r('app.media.ic_settings_arrow')).width('92px').height('92px') + .borderRadius('50px') + } + } + .borderRadius('65px') + .width('414px') + .height('129px') + .backgroundColor('#26FFFFFF') + } + .width('466px') + .height('466px') + .space(LengthMetrics.px(10)) + .borderRadius('233px') + .backgroundColor(Color.Black) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.arcListBuiltInScrollerBar_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/index.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/index.ets index b2b874b86c..dc596f1567 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/index.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcList/index.ets @@ -1,132 +1,132 @@ -/* - * 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 { CompletedRoutableCard } from '../../common/Card'; -import { Route } from '../../common/Route'; -import { ArcListAcrScrollBar } from './ArcListAcrScrollBar'; -import { ArcListArcIndexerBar } from './ArcListArcIndexerBar'; -import { arcListBuiltInScrollerBar } from './arcListBuiltInScrollerBar'; -import { ArcListContents } from './ArcListContents'; -import { ArcListCrown } from './ArcListCrown'; -import { ArcListShow } from './ArcListShow'; -import { ArcListSideSlip } from './ArcListSideSlip'; -import { ArcListStyles } from './ArcListStyles'; -import { ArcLongList } from './ArcLongList'; - -import resource from '../../common/resource'; - -export const ARCLIST_ROUTE_PREFIX: string = 'arcList'; - -const routes: Route[] = [ - { - name: `${ARCLIST_ROUTE_PREFIX}/ArcListShow`, - title: resource.resourceToString($r('app.string.ArcListShow_title')), - description: $r('app.string.ArcListShow_description') - }, - { - name: `${ARCLIST_ROUTE_PREFIX}/ArcListContents`, - title: resource.resourceToString($r('app.string.ArcListContents_title')), - description: $r('app.string.ArcListContents_description') - }, - { - name: `${ARCLIST_ROUTE_PREFIX}/ArcListStyles`, - title: resource.resourceToString($r('app.string.ArcListStyles_title')), - description: $r('app.string.ArcListStyles_description') - }, - { - name: `${ARCLIST_ROUTE_PREFIX}/arcListBuiltInScrollerBar`, - title: resource.resourceToString($r('app.string.arcListBuiltInScrollerBar_title')), - description: $r('app.string.arcListBuiltInScrollerBar_description') - }, - { - name: `${ARCLIST_ROUTE_PREFIX}/ArcListAcrScrollBar`, - title: resource.resourceToString($r('app.string.ArcListAcrScrollBar_title')), - description: $r('app.string.ArcListAcrScrollBar_description') - }, - { - name: `${ARCLIST_ROUTE_PREFIX}/ArcListArcIndexerBar`, - title: resource.resourceToString($r('app.string.ArcListArcIndexerBar_title')), - description: $r('app.string.ArcListArcIndexerBar_description') - }, - { - name: `${ARCLIST_ROUTE_PREFIX}/ArcListSideSlip`, - title: resource.resourceToString($r('app.string.ArcListSideSlip_title')), - description: $r('app.string.ArcListSideSlip_description') - }, - { - name: `${ARCLIST_ROUTE_PREFIX}/ArcLongList`, - title: resource.resourceToString($r('app.string.ArcLongList_title')), - description: $r('app.string.ArcLongList_description') - }, - { - name: `${ARCLIST_ROUTE_PREFIX}/ArcListCrown`, - title: resource.resourceToString($r('app.string.ArcListCrown_title')), - description: $r('app.string.ArcListCrown_description') - } -]; - -@Builder -export function arcListDestination(name: string) { - if (name === ARCLIST_ROUTE_PREFIX) { - ArcListExample(); - } else if (name === routes[0].name) { - ArcListShow(); - } else if (name === routes[1].name) { - ArcListContents(); - } else if (name === routes[2].name) { - ArcListStyles(); - } else if (name === routes[3].name) { - arcListBuiltInScrollerBar(); - } else if (name === routes[4].name) { - ArcListAcrScrollBar(); - } else if (name === routes[5].name) { - ArcListArcIndexerBar(); - } else if (name === routes[6].name) { - ArcListSideSlip(); - } else if (name === routes[7].name) { - ArcLongList(); - } else if (name === routes[8].name) { - ArcListCrown(); - } -} - -@Entry -@Component -struct ArcListExample { - @Consume pathStack: NavPathStack; - - build() { - NavDestination() { - List({ space: 12 }) { - ForEach(routes, (route: Route) => { - ListItem() { - CompletedRoutableCard({ title: route.title, description: route.description }) - } - .width('100%') - .onClick(() => { - this.pathStack.pushPath({ name: route.name }); - }) - }) - } - .contentStartOffset(56) - .padding({ left: 16, right: 16 }) - } - .backgroundColor('#f1f3f5') - .title('ArcList', { - backgroundBlurStyle: BlurStyle.COMPONENT_THICK, - barStyle: BarStyle.STACK - }) - } +/* + * 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 { CompletedRoutableCard } from '../../common/Card'; +import { Route } from '../../common/Route'; +import { ArcListAcrScrollBar } from './ArcListAcrScrollBar'; +import { ArcListArcIndexerBar } from './ArcListArcIndexerBar'; +import { arcListBuiltInScrollerBar } from './arcListBuiltInScrollerBar'; +import { ArcListContents } from './ArcListContents'; +import { ArcListCrown } from './ArcListCrown'; +import { ArcListShow } from './ArcListShow'; +import { ArcListSideSlip } from './ArcListSideSlip'; +import { ArcListStyles } from './ArcListStyles'; +import { ArcLongList } from './ArcLongList'; + +import resource from '../../common/resource'; + +export const ARCLIST_ROUTE_PREFIX: string = 'arcList'; + +const routes: Route[] = [ + { + name: `${ARCLIST_ROUTE_PREFIX}/ArcListShow`, + title: resource.resourceToString($r('app.string.ArcListShow_title')), + description: $r('app.string.ArcListShow_description') + }, + { + name: `${ARCLIST_ROUTE_PREFIX}/ArcListContents`, + title: resource.resourceToString($r('app.string.ArcListContents_title')), + description: $r('app.string.ArcListContents_description') + }, + { + name: `${ARCLIST_ROUTE_PREFIX}/ArcListStyles`, + title: resource.resourceToString($r('app.string.ArcListStyles_title')), + description: $r('app.string.ArcListStyles_description') + }, + { + name: `${ARCLIST_ROUTE_PREFIX}/arcListBuiltInScrollerBar`, + title: resource.resourceToString($r('app.string.arcListBuiltInScrollerBar_title')), + description: $r('app.string.arcListBuiltInScrollerBar_description') + }, + { + name: `${ARCLIST_ROUTE_PREFIX}/ArcListAcrScrollBar`, + title: resource.resourceToString($r('app.string.ArcListAcrScrollBar_title')), + description: $r('app.string.ArcListAcrScrollBar_description') + }, + { + name: `${ARCLIST_ROUTE_PREFIX}/ArcListArcIndexerBar`, + title: resource.resourceToString($r('app.string.ArcListArcIndexerBar_title')), + description: $r('app.string.ArcListArcIndexerBar_description') + }, + { + name: `${ARCLIST_ROUTE_PREFIX}/ArcListSideSlip`, + title: resource.resourceToString($r('app.string.ArcListSideSlip_title')), + description: $r('app.string.ArcListSideSlip_description') + }, + { + name: `${ARCLIST_ROUTE_PREFIX}/ArcLongList`, + title: resource.resourceToString($r('app.string.ArcLongList_title')), + description: $r('app.string.ArcLongList_description') + }, + { + name: `${ARCLIST_ROUTE_PREFIX}/ArcListCrown`, + title: resource.resourceToString($r('app.string.ArcListCrown_title')), + description: $r('app.string.ArcListCrown_description') + } +]; + +@Builder +export function arcListDestination(name: string) { + if (name === ARCLIST_ROUTE_PREFIX) { + ArcListExample(); + } else if (name === routes[0].name) { + ArcListShow(); + } else if (name === routes[1].name) { + ArcListContents(); + } else if (name === routes[2].name) { + ArcListStyles(); + } else if (name === routes[3].name) { + arcListBuiltInScrollerBar(); + } else if (name === routes[4].name) { + ArcListAcrScrollBar(); + } else if (name === routes[5].name) { + ArcListArcIndexerBar(); + } else if (name === routes[6].name) { + ArcListSideSlip(); + } else if (name === routes[7].name) { + ArcLongList(); + } else if (name === routes[8].name) { + ArcListCrown(); + } +} + +@Entry +@Component +struct ArcListExample { + @Consume pathStack: NavPathStack; + + build() { + NavDestination() { + List({ space: 12 }) { + ForEach(routes, (route: Route) => { + ListItem() { + CompletedRoutableCard({ title: route.title, description: route.description }) + } + .width('100%') + .onClick(() => { + this.pathStack.pushPath({ name: route.name }); + }) + }) + } + .contentStartOffset(56) + .padding({ left: 16, right: 16 }) + } + .backgroundColor('#f1f3f5') + .title('ArcList', { + backgroundBlurStyle: BlurStyle.COMPONENT_THICK, + barStyle: BarStyle.STACK + }) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperAction.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperAction.ets index d7f1f0af98..f205d94f02 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperAction.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperAction.ets @@ -1,78 +1,78 @@ -/* - * 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 { Decimal } from '@kit.ArkTS'; -import { - ArcSwiper, - ArcSwiperAttribute, -} from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct ArcSwiperAction { - private MIN_SCALE: number = 0.1; - @State backgroundColors: Color[] = [Color.Green, Color.Blue, Color.Yellow, Color.Pink, Color.Gray, Color.Orange]; - @State opacityList: number[] = []; - @State scaleList: number[] = []; - - aboutToAppear(): void { - for (let i = 0; i < this.backgroundColors.length; i++) { - this.opacityList.push(1.0); - this.scaleList.push(1.0); - } - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcSwiperAction_title') }) { - ArcSwiper() { - ForEach(this.backgroundColors, (backgroundColor: Color, index: number) => { - Text(index.toString()) - .width(233) - .height(233) - .fontSize(50) - .textAlign(TextAlign.Center) - .backgroundColor(backgroundColor) - .opacity(this.opacityList[index]) - .scale({ x: this.scaleList[index], y: this.scaleList[index] }) - }) - } - .customContentTransition({ - timeout: 1000, - transition: (proxy: SwiperContentTransitionProxy) => { - if (proxy.position <= -1 || proxy.position >= 1) { - // 页面完全滑出视窗外时,重置属性值 - this.opacityList[proxy.index] = 1.0; - this.scaleList[proxy.index] = 1.0; - } else { - let position: number = Decimal.abs(proxy.position).toNumber(); - this.opacityList[proxy.index] = 1 - position; - this.scaleList[proxy.index] = - this.MIN_SCALE + (1 - this.MIN_SCALE) * (1 - position); - } - } - }) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcSwiperAction_title')) - } +/* + * 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 { Decimal } from '@kit.ArkTS'; +import { + ArcSwiper, + ArcSwiperAttribute, +} from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct ArcSwiperAction { + private MIN_SCALE: number = 0.1; + @State backgroundColors: Color[] = [Color.Green, Color.Blue, Color.Yellow, Color.Pink, Color.Gray, Color.Orange]; + @State opacityList: number[] = []; + @State scaleList: number[] = []; + + aboutToAppear(): void { + for (let i = 0; i < this.backgroundColors.length; i++) { + this.opacityList.push(1.0); + this.scaleList.push(1.0); + } + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcSwiperAction_title') }) { + ArcSwiper() { + ForEach(this.backgroundColors, (backgroundColor: Color, index: number) => { + Text(index.toString()) + .width(233) + .height(233) + .fontSize(50) + .textAlign(TextAlign.Center) + .backgroundColor(backgroundColor) + .opacity(this.opacityList[index]) + .scale({ x: this.scaleList[index], y: this.scaleList[index] }) + }) + } + .customContentTransition({ + timeout: 1000, + transition: (proxy: SwiperContentTransitionProxy) => { + if (proxy.position <= -1 || proxy.position >= 1) { + // 页面完全滑出视窗外时,重置属性值 + this.opacityList[proxy.index] = 1.0; + this.scaleList[proxy.index] = 1.0; + } else { + let position: number = Decimal.abs(proxy.position).toNumber(); + this.opacityList[proxy.index] = 1 - position; + this.scaleList[proxy.index] = + this.MIN_SCALE + (1 - this.MIN_SCALE) * (1 - position); + } + } + }) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcSwiperAction_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperHorizontal.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperHorizontal.ets index 47d538edcb..d8c2d8e98f 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperHorizontal.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperHorizontal.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { - ArcSwiper, - ArcSwiperAttribute, -} from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct ArcSwiperHorizontal { - @State message: string = 'Hello World'; - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcSwiperHorizontal_title') }) { - ArcSwiper() { - Text('0') - .width(233) - .height(233) - .backgroundColor(Color.Gray) - .textAlign(TextAlign.Center) - .fontSize(30) - - Text('1') - .width(233) - .height(233) - .backgroundColor(Color.Green) - .textAlign(TextAlign.Center) - .fontSize(30) - - Text('2') - .width(233) - .height(233) - .backgroundColor(Color.Pink) - .textAlign(TextAlign.Center) - .fontSize(30) - } - .indicator(true) - .vertical(false) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcSwiperHorizontal_title')) - } -} +/* + * 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 { + ArcSwiper, + ArcSwiperAttribute, +} from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct ArcSwiperHorizontal { + @State message: string = 'Hello World'; + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcSwiperHorizontal_title') }) { + ArcSwiper() { + Text('0') + .width(233) + .height(233) + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text('1') + .width(233) + .height(233) + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text('2') + .width(233) + .height(233) + .backgroundColor(Color.Pink) + .textAlign(TextAlign.Center) + .fontSize(30) + } + .indicator(true) + .vertical(false) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcSwiperHorizontal_title')) + } +} diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperSideSlip.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperSideSlip.ets index af64879aee..5eac8d25e8 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperSideSlip.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperSideSlip.ets @@ -1,74 +1,74 @@ -/* - * 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 { - ArcSwiper, - ArcSwiperAttribute, - ArcDotIndicator, - ArcDirection, - ArcSwiperController -} from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct ArcSwiperSideSlip { - @State backgroundColors: Color[] = [Color.Green, Color.Blue, Color.Yellow, Color.Pink, Color.Gray, Color.Orange]; - innerSelectedIndex: number = 0; - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcSwiperSideSlip_title') }) { - ArcSwiper() { - ForEach(this.backgroundColors, (backgroundColor: Color, index: number) => { - Text(index.toString()) - .width(233) - .height(233) - .fontSize(50) - .textAlign(TextAlign.Center) - .backgroundColor(backgroundColor) - }) - } - .onAnimationStart((index: number, targetIndex: number) => { - this.innerSelectedIndex = targetIndex; - }) - .onGestureRecognizerJudgeBegin((event: BaseGestureEvent, current: GestureRecognizer, - others: Array): GestureJudgeResult => { // 在识别器即将要成功时,根据当前组件状态,设置识别器使能状态 - if (current) { - let target = current.getEventTargetInfo(); - if (target && current.isBuiltIn() && current.getType() == GestureControl.GestureType.PAN_GESTURE) { - let swiperTarget = target as ScrollableTargetInfo; - if (swiperTarget instanceof ScrollableTargetInfo && - (swiperTarget.isBegin() || this.innerSelectedIndex === 0)) { // 此处判断swiperTarget.isBegin()或innerSelectedIndex === 0,表明ArcSwiper滑动到开头 - let panEvent = event as PanGestureEvent; - if (panEvent && panEvent.offsetX > 0 && (swiperTarget.isBegin() || this.innerSelectedIndex === 0)) { - return GestureJudgeResult.REJECT; - } - } - } - } - return GestureJudgeResult.CONTINUE; - }) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcSwiperSideSlip_title')) - } +/* + * 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 { + ArcSwiper, + ArcSwiperAttribute, + ArcDotIndicator, + ArcDirection, + ArcSwiperController +} from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct ArcSwiperSideSlip { + @State backgroundColors: Color[] = [Color.Green, Color.Blue, Color.Yellow, Color.Pink, Color.Gray, Color.Orange]; + innerSelectedIndex: number = 0; + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcSwiperSideSlip_title') }) { + ArcSwiper() { + ForEach(this.backgroundColors, (backgroundColor: Color, index: number) => { + Text(index.toString()) + .width(233) + .height(233) + .fontSize(50) + .textAlign(TextAlign.Center) + .backgroundColor(backgroundColor) + }) + } + .onAnimationStart((index: number, targetIndex: number) => { + this.innerSelectedIndex = targetIndex; + }) + .onGestureRecognizerJudgeBegin((event: BaseGestureEvent, current: GestureRecognizer, + others: Array): GestureJudgeResult => { // 在识别器即将要成功时,根据当前组件状态,设置识别器使能状态 + if (current) { + let target = current.getEventTargetInfo(); + if (target && current.isBuiltIn() && current.getType() == GestureControl.GestureType.PAN_GESTURE) { + let swiperTarget = target as ScrollableTargetInfo; + if (swiperTarget instanceof ScrollableTargetInfo && + (swiperTarget.isBegin() || this.innerSelectedIndex === 0)) { // 此处判断swiperTarget.isBegin()或innerSelectedIndex === 0,表明ArcSwiper滑动到开头 + let panEvent = event as PanGestureEvent; + if (panEvent && panEvent.offsetX > 0 && (swiperTarget.isBegin() || this.innerSelectedIndex === 0)) { + return GestureJudgeResult.REJECT; + } + } + } + } + return GestureJudgeResult.CONTINUE; + }) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcSwiperSideSlip_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperStyles.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperStyles.ets index 11bf5dd57c..550309c79f 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperStyles.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperStyles.ets @@ -1,96 +1,96 @@ -/* - * 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 { - ArcSwiper, - ArcSwiperAttribute, - ArcDotIndicator, - ArcDirection, - ArcSwiperController -} from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct ArcSwiperStyles { - @State message: string = 'Hello World'; - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcSwiperStyles_titleDefault') }) { - ArcSwiper() { - Text('0') - .width(233) - .height(233) - .backgroundColor(Color.Gray) - .textAlign(TextAlign.Center) - .fontSize(30) - - Text('1') - .width(233) - .height(233) - .backgroundColor(Color.Green) - .textAlign(TextAlign.Center) - .fontSize(30) - - Text('2') - .width(233) - .height(233) - .backgroundColor(Color.Pink) - .textAlign(TextAlign.Center) - .fontSize(30) - } - } - - ComponentCard({ title: $r('app.string.ArcSwiperStyles_titleCustomize') }) { - ArcSwiper() { - Text('0') - .width(233) - .height(233) - .backgroundColor(Color.Gray) - .textAlign(TextAlign.Center) - .fontSize(30) - - Text('1') - .width(233) - .height(233) - .backgroundColor(Color.Green) - .textAlign(TextAlign.Center) - .fontSize(30) - - Text('2') - .width(233) - .height(233) - .backgroundColor(Color.Pink) - .textAlign(TextAlign.Center) - .fontSize(30) - } - .indicator( - new ArcDotIndicator() - .arcDirection(ArcDirection.SIX_CLOCK_DIRECTION) // 设置导航点位于6点钟方向 - .itemColor(Color.Red) // 设置导航点颜色为红色 - .selectedItemColor(Color.Blue) // 设置选中导航点颜色为蓝色 - ) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcSwiperStyles_title')) - } +/* + * 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 { + ArcSwiper, + ArcSwiperAttribute, + ArcDotIndicator, + ArcDirection, + ArcSwiperController +} from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct ArcSwiperStyles { + @State message: string = 'Hello World'; + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcSwiperStyles_titleDefault') }) { + ArcSwiper() { + Text('0') + .width(233) + .height(233) + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text('1') + .width(233) + .height(233) + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text('2') + .width(233) + .height(233) + .backgroundColor(Color.Pink) + .textAlign(TextAlign.Center) + .fontSize(30) + } + } + + ComponentCard({ title: $r('app.string.ArcSwiperStyles_titleCustomize') }) { + ArcSwiper() { + Text('0') + .width(233) + .height(233) + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text('1') + .width(233) + .height(233) + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text('2') + .width(233) + .height(233) + .backgroundColor(Color.Pink) + .textAlign(TextAlign.Center) + .fontSize(30) + } + .indicator( + new ArcDotIndicator() + .arcDirection(ArcDirection.SIX_CLOCK_DIRECTION) // 设置导航点位于6点钟方向 + .itemColor(Color.Red) // 设置导航点颜色为红色 + .selectedItemColor(Color.Blue) // 设置选中导航点颜色为蓝色 + ) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcSwiperStyles_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperToggle.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperToggle.ets index 143dab03e0..82548c9cd7 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperToggle.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperToggle.ets @@ -1,100 +1,100 @@ -/* - * 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 { - ArcButton, - ArcButtonOptions, - ArcButtonStatus, - ArcButtonStyleMode, - ArcButtonPosition, - ArcSwiper, - ArcSwiperAttribute, - ArcDotIndicator, - ArcDirection, - ArcSwiperController -} from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct ArcSwiperToggle { - private wearableSwiperController: ArcSwiperController = new ArcSwiperController(); - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcSwiperToggle_title') }) { - Stack() { - ArcSwiper(this.wearableSwiperController) { - Text('0') - .width(233) - .height(233) - .backgroundColor(Color.Gray) - .textAlign(TextAlign.Center) - .fontSize(30) - - Text('1') - .width(233) - .height(233) - .backgroundColor(Color.Green) - .textAlign(TextAlign.Center) - .fontSize(30) - - Text('2') - .width(233) - .height(233) - .backgroundColor(Color.Pink) - .textAlign(TextAlign.Center) - .fontSize(30) - } - .vertical(true) - .indicator(false) - - Column() { - ArcButton({ - options: new ArcButtonOptions({ - label: 'previous', - position: ArcButtonPosition.TOP_EDGE, - styleMode: ArcButtonStyleMode.EMPHASIZED_LIGHT, - onClick: () => { - this.wearableSwiperController.showPrevious(); // 通过controller切换到前一页 - } - }) - }) - - Blank() - - ArcButton({ - options: new ArcButtonOptions({ - label: 'next', - position: ArcButtonPosition.BOTTOM_EDGE, - styleMode: ArcButtonStyleMode.EMPHASIZED_LIGHT, - onClick: () => { - this.wearableSwiperController.showNext(); // 通过controller切换到后一页 - } - }) - }) - }.width('100%').height('100%') - } - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcSwiperToggle_title')) - } +/* + * 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 { + ArcButton, + ArcButtonOptions, + ArcButtonStatus, + ArcButtonStyleMode, + ArcButtonPosition, + ArcSwiper, + ArcSwiperAttribute, + ArcDotIndicator, + ArcDirection, + ArcSwiperController +} from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct ArcSwiperToggle { + private wearableSwiperController: ArcSwiperController = new ArcSwiperController(); + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcSwiperToggle_title') }) { + Stack() { + ArcSwiper(this.wearableSwiperController) { + Text('0') + .width(233) + .height(233) + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text('1') + .width(233) + .height(233) + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text('2') + .width(233) + .height(233) + .backgroundColor(Color.Pink) + .textAlign(TextAlign.Center) + .fontSize(30) + } + .vertical(true) + .indicator(false) + + Column() { + ArcButton({ + options: new ArcButtonOptions({ + label: 'previous', + position: ArcButtonPosition.TOP_EDGE, + styleMode: ArcButtonStyleMode.EMPHASIZED_LIGHT, + onClick: () => { + this.wearableSwiperController.showPrevious(); // 通过controller切换到前一页 + } + }) + }) + + Blank() + + ArcButton({ + options: new ArcButtonOptions({ + label: 'next', + position: ArcButtonPosition.BOTTOM_EDGE, + styleMode: ArcButtonStyleMode.EMPHASIZED_LIGHT, + onClick: () => { + this.wearableSwiperController.showNext(); // 通过controller切换到后一页 + } + }) + }) + }.width('100%').height('100%') + } + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcSwiperToggle_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperVertical.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperVertical.ets index 4e27070ed8..766faba50d 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperVertical.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/ArcSwiperVertical.ets @@ -1,68 +1,68 @@ -/* - * 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 { - ArcSwiper, - ArcSwiperAttribute, - ArcDotIndicator, - ArcDirection, - ArcSwiperController -} from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct ArcSwiperVertical { - @State message: string = 'Hello World'; - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ArcSwiperVertical_title') }) { - ArcSwiper() { - Text('0') - .width(233) - .height(233) - .backgroundColor(Color.Gray) - .textAlign(TextAlign.Center) - .fontSize(30) - - Text('1') - .width(233) - .height(233) - .backgroundColor(Color.Green) - .textAlign(TextAlign.Center) - .fontSize(30) - - Text('2') - .width(233) - .height(233) - .backgroundColor(Color.Pink) - .textAlign(TextAlign.Center) - .fontSize(30) - } - .indicator(new ArcDotIndicator() - .arcDirection(ArcDirection.THREE_CLOCK_DIRECTION)) - .vertical(true) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ArcSwiperVertical_title')) - } +/* + * 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 { + ArcSwiper, + ArcSwiperAttribute, + ArcDotIndicator, + ArcDirection, + ArcSwiperController +} from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct ArcSwiperVertical { + @State message: string = 'Hello World'; + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ArcSwiperVertical_title') }) { + ArcSwiper() { + Text('0') + .width(233) + .height(233) + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text('1') + .width(233) + .height(233) + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text('2') + .width(233) + .height(233) + .backgroundColor(Color.Pink) + .textAlign(TextAlign.Center) + .fontSize(30) + } + .indicator(new ArcDotIndicator() + .arcDirection(ArcDirection.THREE_CLOCK_DIRECTION)) + .vertical(true) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ArcSwiperVertical_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/index.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/index.ets index 98f58400da..eb3ead581a 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/index.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/arcSwiper/index.ets @@ -1,107 +1,107 @@ -/* - * 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 { CompletedRoutableCard } from '../../common/Card'; -import { Route } from '../../common/Route'; -import { ArcSwiperAction } from './ArcSwiperAction'; -import { ArcSwiperHorizontal } from './ArcSwiperHorizontal'; -import { ArcSwiperSideSlip } from './ArcSwiperSideSlip'; -import { ArcSwiperStyles } from './ArcSwiperStyles'; -import { ArcSwiperToggle } from './ArcSwiperToggle'; -import { ArcSwiperVertical } from './ArcSwiperVertical'; -import resource from '../../common/resource'; - -export const ARCSWIPER_ROUTE_PREFIX: string = 'arcSwiper'; - -const routes: Route[] = [ - { - name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperStyles`, - title: resource.resourceToString($r('app.string.ArcSwiperStyles_title')), - description: $r('app.string.ArcSwiperStyles_description') - }, - { - name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperToggle`, - title: resource.resourceToString($r('app.string.ArcSwiperToggle_title')), - description: $r('app.string.ArcSwiperToggle_description') - }, - { - name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperHorizontal`, - title: resource.resourceToString($r('app.string.ArcSwiperHorizontal_title')), - description: $r('app.string.ArcSwiperHorizontal_description') - }, - { - name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperVertical`, - title: resource.resourceToString($r('app.string.ArcSwiperVertical_title')), - description: $r('app.string.ArcSwiperVertical_description') - }, - { - name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperAction`, - title: resource.resourceToString($r('app.string.ArcSwiperAction_title')), - description: $r('app.string.ArcSwiperAction_description') - }, - { - name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperSideSlip`, - title: resource.resourceToString($r('app.string.ArcSwiperSideSlip_title')), - description: $r('app.string.ArcSwiperSideSlip_description') - } -]; - -@Builder -export function arcSwiperDestination(name: string) { - if (name === ARCSWIPER_ROUTE_PREFIX) { - ArcSwiperExample(); - } else if (name === routes[0].name) { - ArcSwiperStyles(); - } else if (name === routes[1].name) { - ArcSwiperToggle(); - } else if (name === routes[2].name) { - ArcSwiperHorizontal(); - } else if (name === routes[3].name) { - ArcSwiperVertical(); - } else if (name === routes[4].name) { - ArcSwiperAction(); - } else if (name === routes[5].name) { - ArcSwiperSideSlip(); - } -} - -@Entry -@Component -struct ArcSwiperExample { - @Consume pathStack: NavPathStack; - - build() { - NavDestination() { - List({ space: 12 }) { - ForEach(routes, (route: Route) => { - ListItem() { - CompletedRoutableCard({ title: route.title, description: route.description }) - } - .width('100%') - .onClick(() => { - this.pathStack.pushPath({ name: route.name }); - }) - }) - } - .contentStartOffset(56) - .padding({ left: 16, right: 16 }) - } - .backgroundColor('#f1f3f5') - .title('ArcSwiper', { - backgroundBlurStyle: BlurStyle.COMPONENT_THICK, - barStyle: BarStyle.STACK - }) - } +/* + * 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 { CompletedRoutableCard } from '../../common/Card'; +import { Route } from '../../common/Route'; +import { ArcSwiperAction } from './ArcSwiperAction'; +import { ArcSwiperHorizontal } from './ArcSwiperHorizontal'; +import { ArcSwiperSideSlip } from './ArcSwiperSideSlip'; +import { ArcSwiperStyles } from './ArcSwiperStyles'; +import { ArcSwiperToggle } from './ArcSwiperToggle'; +import { ArcSwiperVertical } from './ArcSwiperVertical'; +import resource from '../../common/resource'; + +export const ARCSWIPER_ROUTE_PREFIX: string = 'arcSwiper'; + +const routes: Route[] = [ + { + name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperStyles`, + title: resource.resourceToString($r('app.string.ArcSwiperStyles_title')), + description: $r('app.string.ArcSwiperStyles_description') + }, + { + name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperToggle`, + title: resource.resourceToString($r('app.string.ArcSwiperToggle_title')), + description: $r('app.string.ArcSwiperToggle_description') + }, + { + name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperHorizontal`, + title: resource.resourceToString($r('app.string.ArcSwiperHorizontal_title')), + description: $r('app.string.ArcSwiperHorizontal_description') + }, + { + name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperVertical`, + title: resource.resourceToString($r('app.string.ArcSwiperVertical_title')), + description: $r('app.string.ArcSwiperVertical_description') + }, + { + name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperAction`, + title: resource.resourceToString($r('app.string.ArcSwiperAction_title')), + description: $r('app.string.ArcSwiperAction_description') + }, + { + name: `${ARCSWIPER_ROUTE_PREFIX}/ArcSwiperSideSlip`, + title: resource.resourceToString($r('app.string.ArcSwiperSideSlip_title')), + description: $r('app.string.ArcSwiperSideSlip_description') + } +]; + +@Builder +export function arcSwiperDestination(name: string) { + if (name === ARCSWIPER_ROUTE_PREFIX) { + ArcSwiperExample(); + } else if (name === routes[0].name) { + ArcSwiperStyles(); + } else if (name === routes[1].name) { + ArcSwiperToggle(); + } else if (name === routes[2].name) { + ArcSwiperHorizontal(); + } else if (name === routes[3].name) { + ArcSwiperVertical(); + } else if (name === routes[4].name) { + ArcSwiperAction(); + } else if (name === routes[5].name) { + ArcSwiperSideSlip(); + } +} + +@Entry +@Component +struct ArcSwiperExample { + @Consume pathStack: NavPathStack; + + build() { + NavDestination() { + List({ space: 12 }) { + ForEach(routes, (route: Route) => { + ListItem() { + CompletedRoutableCard({ title: route.title, description: route.description }) + } + .width('100%') + .onClick(() => { + this.pathStack.pushPath({ name: route.name }); + }) + }) + } + .contentStartOffset(56) + .padding({ left: 16, right: 16 }) + } + .backgroundColor('#f1f3f5') + .title('ArcSwiper', { + backgroundBlurStyle: BlurStyle.COMPONENT_THICK, + barStyle: BarStyle.STACK + }) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridDataSource.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridDataSource.ets index f0d9e9bb80..58db5d6fc5 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridDataSource.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridDataSource.ets @@ -1,59 +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. - */ - -export class GridDataSource implements IDataSource { - private list: string[] = []; - private listeners: DataChangeListener[] = []; - - constructor(list: string[]) { - this.list = list; - } - - totalCount(): number { - return this.list.length; - } - - getData(index: number): string { - return this.list[index]; - } - - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - this.listeners.push(listener); - } - } - - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener); - if (pos >= 0) { - this.listeners.splice(pos, 1); - } - } - - // 通知控制器数据位置变化 - notifyDataMove(from: number, to: number): void { - this.listeners.forEach(listener => { - listener.onDataMove(from, to); - }) - } - - // 交换元素位置 - public swapItem(from: number, to: number): void { - let temp: string = this.list[from]; - this.list[from] = this.list[to]; - this.list[to] = temp; - this.notifyDataMove(from, to); - } +/* + * 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 class GridDataSource implements IDataSource { + private list: string[] = []; + private listeners: DataChangeListener[] = []; + + constructor(list: string[]) { + this.list = list; + } + + totalCount(): number { + return this.list.length; + } + + getData(index: number): string { + return this.list[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + this.listeners.splice(pos, 1); + } + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } + + // 交换元素位置 + public swapItem(from: number, to: number): void { + let temp: string = this.list[from]; + this.list[from] = this.list[to]; + this.list[to] = temp; + this.notifyDataMove(from, to); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridScrollbar.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridScrollbar.ets index 74443ede72..26baf97ee4 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridScrollbar.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridScrollbar.ets @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { GridDataSource } from './GridDataSource'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct GridScrollbar { - numbers: GridDataSource = new GridDataSource([]); - scroller: Scroller = new Scroller(); - @State gridPosition: number = 0; //0代表滚动到grid顶部,1代表中间值,2代表滚动到grid底部。 - - aboutToAppear() { - let list: string[] = []; - for (let i = 0; i < 5; i++) { - for (let j = 0; j < 5; j++) { - list.push(j.toString()); - } - } - this.numbers = new GridDataSource(list); - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.GridScrollbar_title') }) { - Row({ space: 5 }) { - Grid(this.scroller) { - LazyForEach(this.numbers, (day: string) => { - GridItem() { - Text() - .fontSize(16) - .backgroundColor(0xF9CF93) - .width('100%') - .height(80) - .textAlign(TextAlign.Center) - } - }, (index: number) => index.toString()) - } - .columnsTemplate('1fr 1fr 1fr 1fr 1fr') - .columnsGap(10) - .rowsGap(10) - .friction(0.6) - .enableScrollInteraction(true) - .supportAnimation(false) - .multiSelectable(false) - .edgeEffect(EdgeEffect.Spring) - .scrollBar(BarState.Off) - .scrollBarColor(Color.Grey) - .scrollBarWidth(4) - .width('90%') - .backgroundColor(0xFAEEE0) - .height(300) - .margin({left:10}) - ScrollBar({ scroller: this.scroller }).height(300) - - }.width('100%').margin({ top: 5 }) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.GridScrollbar_title')) - } +/* + * 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 { GridDataSource } from './GridDataSource'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct GridScrollbar { + numbers: GridDataSource = new GridDataSource([]); + scroller: Scroller = new Scroller(); + @State gridPosition: number = 0; //0代表滚动到grid顶部,1代表中间值,2代表滚动到grid底部。 + + aboutToAppear() { + let list: string[] = []; + for (let i = 0; i < 5; i++) { + for (let j = 0; j < 5; j++) { + list.push(j.toString()); + } + } + this.numbers = new GridDataSource(list); + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.GridScrollbar_title') }) { + Row({ space: 5 }) { + Grid(this.scroller) { + LazyForEach(this.numbers, (day: string) => { + GridItem() { + Text() + .fontSize(16) + .backgroundColor(0xF9CF93) + .width('100%') + .height(80) + .textAlign(TextAlign.Center) + } + }, (index: number) => index.toString()) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr') + .columnsGap(10) + .rowsGap(10) + .friction(0.6) + .enableScrollInteraction(true) + .supportAnimation(false) + .multiSelectable(false) + .edgeEffect(EdgeEffect.Spring) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Grey) + .scrollBarWidth(4) + .width('90%') + .backgroundColor(0xFAEEE0) + .height(300) + .margin({left:10}) + ScrollBar({ scroller: this.scroller }).height(300) + + }.width('100%').margin({ top: 5 }) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.GridScrollbar_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridSideToSide.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridSideToSide.ets index fd30401da3..9f70e84f34 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridSideToSide.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/GridSideToSide.ets @@ -1,90 +1,90 @@ -/* - * 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 { GridDataSource } from './GridDataSource'; -import { ComponentCard } from '../../common/Card'; - -@Entry -@Component -export struct GridSideToSide { - numbers: GridDataSource = new GridDataSource([]); - scroller: Scroller = new Scroller(); - @State gridPosition: number = 0; //0代表滚动到grid顶部,1代表中间值,2代表滚动到grid底部。 - @State data: number = 1; - - aboutToAppear() { - let list: string[] = []; - for (let i = 0; i < 7; i++) { - for (let j = 0; j < 10; j++) { - list.push(this.data.toString()); - this.data += 1; - if(this.data == 32) { - this.data = 0; - } - } - } - this.numbers = new GridDataSource(list); - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.GridSideToSide_title') }) { - Column(){ - Grid(this.scroller) { - LazyForEach(this.numbers, (day: string) => { - GridItem() { - Text(day) - .fontSize(16) - .backgroundColor(0xF9CF93) - .width('100%') - .height(50) - .textAlign(TextAlign.Center) - } - }, (index: number) => index.toString()) - } - .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr') - .columnsGap(10) - .rowsGap(10) - .width('90%') - .height(300) - .scrollBar(BarState.Off) - - Row({ space: 20 }) { - Button('上一页') - .onClick(() => { - this.scroller.scrollPage({ - next: false - }); - }) - - Button('下一页') - .onClick(() => { - this.scroller.scrollPage({ - next: true - }); - }) - } - } - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.GridSideToSide_title')) - } +/* + * 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 { GridDataSource } from './GridDataSource'; +import { ComponentCard } from '../../common/Card'; + +@Entry +@Component +export struct GridSideToSide { + numbers: GridDataSource = new GridDataSource([]); + scroller: Scroller = new Scroller(); + @State gridPosition: number = 0; //0代表滚动到grid顶部,1代表中间值,2代表滚动到grid底部。 + @State data: number = 1; + + aboutToAppear() { + let list: string[] = []; + for (let i = 0; i < 7; i++) { + for (let j = 0; j < 10; j++) { + list.push(this.data.toString()); + this.data += 1; + if(this.data == 32) { + this.data = 0; + } + } + } + this.numbers = new GridDataSource(list); + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.GridSideToSide_title') }) { + Column(){ + Grid(this.scroller) { + LazyForEach(this.numbers, (day: string) => { + GridItem() { + Text(day) + .fontSize(16) + .backgroundColor(0xF9CF93) + .width('100%') + .height(50) + .textAlign(TextAlign.Center) + } + }, (index: number) => index.toString()) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr') + .columnsGap(10) + .rowsGap(10) + .width('90%') + .height(300) + .scrollBar(BarState.Off) + + Row({ space: 20 }) { + Button('上一页') + .onClick(() => { + this.scroller.scrollPage({ + next: false + }); + }) + + Button('下一页') + .onClick(() => { + this.scroller.scrollPage({ + next: true + }); + }) + } + } + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.GridSideToSide_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/LongGrid.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/LongGrid.ets index 073655c3e3..87258637d6 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/LongGrid.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/grid/LongGrid.ets @@ -1,70 +1,70 @@ -/* - * 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 { ComponentCard } from '../../common/Card'; -import { GridDataSource } from './GridDataSource'; - -@Entry -@Component -export struct LongGrid { - numbers: GridDataSource = new GridDataSource([]); - scroller: Scroller = new Scroller(); - - aboutToAppear() { - let list: string[] = []; - for (let i = 0; i <= 10; i++) { - for (let j = 0; j < 5; j++) { - list.push(j.toString()); - } - } - this.numbers = new GridDataSource(list); - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.LongGrid_title') }) { - Column({ space: 5 }) { - Grid(this.scroller) { - LazyForEach(this.numbers, (day: string) => { - GridItem() { - Text(day) - .fontSize(16) - .backgroundColor(0xF9CF93) - .width('100%') - .height(80) - .textAlign(TextAlign.Center) - } - }, (index: number) => index.toString()) - } - .columnsTemplate('1fr 1fr 1fr 1fr 1fr') - .columnsGap(10) - .rowsGap(20) - .edgeEffect(EdgeEffect.Spring, { alwaysEnabled: true, effectEdge: EffectEdge.START }) - .width('90%') - .backgroundColor(0xDCDCDC) - .height('80%') - - }.width('100%').margin({ top: 5 }) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.LongGrid_title')) - } +/* + * 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 { ComponentCard } from '../../common/Card'; +import { GridDataSource } from './GridDataSource'; + +@Entry +@Component +export struct LongGrid { + numbers: GridDataSource = new GridDataSource([]); + scroller: Scroller = new Scroller(); + + aboutToAppear() { + let list: string[] = []; + for (let i = 0; i <= 10; i++) { + for (let j = 0; j < 5; j++) { + list.push(j.toString()); + } + } + this.numbers = new GridDataSource(list); + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.LongGrid_title') }) { + Column({ space: 5 }) { + Grid(this.scroller) { + LazyForEach(this.numbers, (day: string) => { + GridItem() { + Text(day) + .fontSize(16) + .backgroundColor(0xF9CF93) + .width('100%') + .height(80) + .textAlign(TextAlign.Center) + } + }, (index: number) => index.toString()) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr') + .columnsGap(10) + .rowsGap(20) + .edgeEffect(EdgeEffect.Spring, { alwaysEnabled: true, effectEdge: EffectEdge.START }) + .width('90%') + .backgroundColor(0xDCDCDC) + .height('80%') + + }.width('100%').margin({ top: 5 }) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.LongGrid_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/CollapseAndExpand.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/CollapseAndExpand.ets index 52fd69387c..1c4cc17fd5 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/CollapseAndExpand.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/CollapseAndExpand.ets @@ -1,184 +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. - */ - -import { curves } from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - -interface ItemInfo { - index: number, - name: string, - label: ResourceStr, - type?: string, -} - -interface ItemGroupInfo extends ItemInfo { - children: ItemInfo[] -} - - -@Entry -@Component -export struct CollapseAndExpand { - @State routes: ItemGroupInfo[] = [ - { - index: 0, - name: 'basicInfo', - label: '个人基本资料', - children: [ - { - index: 0, - name: '昵称', - label: 'xxxx', - type: 'Text' - }, - { - index: 1, - name: '头像', - label: $r('sys.media.ohos_user_auth_icon_face'), - type: 'Image' - }, - { - index: 2, - name: '年龄', - label: 'xxxx', - type: 'Text' - }, - { - index: 3, - name: '生日', - label: 'xxxxxxxxx', - type: 'Text' - }, - { - index: 4, - name: '性别', - label: 'xxxxxxxx', - type: 'Text' - }, - ] - }, - { - index: 1, - name: 'equipInfo', - label: '设备信息', - children: [] - }, - { - index: 2, - name: 'appInfo', - label: '应用使用信息', - children: [] - }, - { - index: 3, - name: 'uploadInfo', - label: '您主动上传的数据', - children: [] - }, - { - index: 4, - name: 'tradeInfo', - label: '交易与资产信息', - children: [] - }, - { - index: 5, - name: 'otherInfo', - label: '其他资料', - children: [] - }, - ]; - - @State expandedItems: boolean[] = Array(this.routes.length).fill(false); - @State selection: string | null = null; - - @Builder - ListItemGroupHeader(itemGroup: ItemGroupInfo) { - Row() { - Text(itemGroup.label) - Blank() - Image($r('sys.media.ohos_ic_public_arrow_down')) - .fillColor($r('sys.color.ohos_id_color_fourth')) - .height(30) - .width(30) - .rotate({ angle: !!itemGroup.children.length ? (this.expandedItems[itemGroup.index] ? 180 : 0) : 180 }) - .animation({ curve: curves.interpolatingSpring(0, 1, 228, 22) }) - } - .width("100%") - .padding(10) - .animation({ curve: curves.interpolatingSpring(0, 1, 528, 39) }) - .onClick(() => { - if (itemGroup.children.length) { - this.getUIContext()?.animateTo({ curve: curves.interpolatingSpring(0, 1, 528, 39) }, () => { - this.expandedItems[itemGroup.index] = !this.expandedItems[itemGroup.index]; - }) - } - }) - } - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.CollapseAndExpand_title') }) { - Column() { - List({ space: 10 }) { - ForEach(this.routes, (itemGroup: ItemGroupInfo) => { - ListItemGroup({ - header: this.ListItemGroupHeader(itemGroup), - style: ListItemGroupStyle.CARD, - }) { - if (this.expandedItems[itemGroup.index] && itemGroup.children) { - ForEach(itemGroup.children, (item: ItemInfo) => { - ListItem({ style: ListItemStyle.CARD }) { - Row() { - Text(item.name) - Blank() - if (item.type === 'Image') { - Image(item.label) - .height(20) - .width(20) - } else { - Text(item.label) - } - Image($r('sys.media.ohos_ic_public_arrow_right')) - .fillColor($r('sys.color.ohos_id_color_fourth')) - .height(30) - .width(30) - } - .width("100%") - } - .width("100%") - .animation({ curve: curves.interpolatingSpring(0, 1, 528, 39) }) - }) - } - }.clip(true) - }) - } - .width("100%") - } - .width('100%') - .height('100%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.CollapseAndExpand_title')) - } - +/* + * 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 { curves } from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + +interface ItemInfo { + index: number, + name: string, + label: ResourceStr, + type?: string, +} + +interface ItemGroupInfo extends ItemInfo { + children: ItemInfo[] +} + + +@Entry +@Component +export struct CollapseAndExpand { + @State routes: ItemGroupInfo[] = [ + { + index: 0, + name: 'basicInfo', + label: '个人基本资料', + children: [ + { + index: 0, + name: '昵称', + label: 'xxxx', + type: 'Text' + }, + { + index: 1, + name: '头像', + label: $r('sys.media.ohos_user_auth_icon_face'), + type: 'Image' + }, + { + index: 2, + name: '年龄', + label: 'xxxx', + type: 'Text' + }, + { + index: 3, + name: '生日', + label: 'xxxxxxxxx', + type: 'Text' + }, + { + index: 4, + name: '性别', + label: 'xxxxxxxx', + type: 'Text' + }, + ] + }, + { + index: 1, + name: 'equipInfo', + label: '设备信息', + children: [] + }, + { + index: 2, + name: 'appInfo', + label: '应用使用信息', + children: [] + }, + { + index: 3, + name: 'uploadInfo', + label: '您主动上传的数据', + children: [] + }, + { + index: 4, + name: 'tradeInfo', + label: '交易与资产信息', + children: [] + }, + { + index: 5, + name: 'otherInfo', + label: '其他资料', + children: [] + }, + ]; + + @State expandedItems: boolean[] = Array(this.routes.length).fill(false); + @State selection: string | null = null; + + @Builder + ListItemGroupHeader(itemGroup: ItemGroupInfo) { + Row() { + Text(itemGroup.label) + Blank() + Image($r('sys.media.ohos_ic_public_arrow_down')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(30) + .width(30) + .rotate({ angle: !!itemGroup.children.length ? (this.expandedItems[itemGroup.index] ? 180 : 0) : 180 }) + .animation({ curve: curves.interpolatingSpring(0, 1, 228, 22) }) + } + .width("100%") + .padding(10) + .animation({ curve: curves.interpolatingSpring(0, 1, 528, 39) }) + .onClick(() => { + if (itemGroup.children.length) { + this.getUIContext()?.animateTo({ curve: curves.interpolatingSpring(0, 1, 528, 39) }, () => { + this.expandedItems[itemGroup.index] = !this.expandedItems[itemGroup.index]; + }) + } + }) + } + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.CollapseAndExpand_title') }) { + Column() { + List({ space: 10 }) { + ForEach(this.routes, (itemGroup: ItemGroupInfo) => { + ListItemGroup({ + header: this.ListItemGroupHeader(itemGroup), + style: ListItemGroupStyle.CARD, + }) { + if (this.expandedItems[itemGroup.index] && itemGroup.children) { + ForEach(itemGroup.children, (item: ItemInfo) => { + ListItem({ style: ListItemStyle.CARD }) { + Row() { + Text(item.name) + Blank() + if (item.type === 'Image') { + Image(item.label) + .height(20) + .width(20) + } else { + Text(item.label) + } + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(30) + .width(30) + } + .width("100%") + } + .width("100%") + .animation({ curve: curves.interpolatingSpring(0, 1, 528, 39) }) + }) + } + }.clip(true) + }) + } + .width("100%") + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.CollapseAndExpand_title')) + } + } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/ListChatRoom.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/ListChatRoom.ets index f71e5b69ea..7a64085db0 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/ListChatRoom.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/ListChatRoom.ets @@ -1,110 +1,110 @@ -/* - * 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 { ComponentCard } from '../../common/Card' -// 消息类型定义 -interface Message { - id: number - content: string - sender: string -} - -@Entry -@Component -export struct ListChatRoom { - // 自定义消息组件 - @Builder - MessageItem(message: Message) { - Column() { - Text(`${message.sender}: ${message.content}`) - .fontSize(16) - .textAlign(TextAlign.Start) - .padding(10) - .backgroundColor(message.sender === '系统' ? '#F0F0F0' : '#E6F3FF') - .borderRadius(8) - } - .width('100%') - .alignItems(HorizontalAlign.Start) - .margin({ bottom: 8 }) - } - - // 发送消息方法 - sendMessage() { - if (this.inputText.trim()) { - this.messages = [...this.messages, { - id: Date.now(), - content: this.inputText, - sender: '观众' - }] - this.inputText = '' - } - } - // 消息列表数据 - @State messages: Message[] = [ - { id: 1, content: '欢迎来到直播间!', sender: '系统' }, - { id: 2, content: '大家好啊~', sender: '主播' } - ] - - // 输入框内容 - @State inputText: string = '' - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.ListChatRoom_title') }) { - Column() { - // 聊天消息区域 - List({ space: 10 }) { - ForEach(this.messages, (item: Message) => { - ListItem() { - this.MessageItem(item) - } - }, (item: Message) => item.id.toString()) - } - .layoutWeight(1) // 占据剩余空间 - .alignListItem(ListItemAlign.Center) - - // 输入区域 - Row({ space: 10 }) { - TextInput({ text: this.inputText, placeholder: '说点什么...' }) - .layoutWeight(1) - .onChange((value: string) => { - this.inputText = value - }) - .onSubmit(() => { // 回车发送 - this.sendMessage() - }) - - Button('发送', { type: ButtonType.Capsule }) - .backgroundColor('#007AFF') - .onClick(() => { - this.sendMessage() - }) - } - .padding(10) - .backgroundColor('#F5F5F5') - } - .width('100%') - .height('100%') - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.ListChatRoom_title')) - } +/* + * 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 { ComponentCard } from '../../common/Card' +// 消息类型定义 +interface Message { + id: number + content: string + sender: string +} + +@Entry +@Component +export struct ListChatRoom { + // 自定义消息组件 + @Builder + MessageItem(message: Message) { + Column() { + Text(`${message.sender}: ${message.content}`) + .fontSize(16) + .textAlign(TextAlign.Start) + .padding(10) + .backgroundColor(message.sender === '系统' ? '#F0F0F0' : '#E6F3FF') + .borderRadius(8) + } + .width('100%') + .alignItems(HorizontalAlign.Start) + .margin({ bottom: 8 }) + } + + // 发送消息方法 + sendMessage() { + if (this.inputText.trim()) { + this.messages = [...this.messages, { + id: Date.now(), + content: this.inputText, + sender: '观众' + }] + this.inputText = '' + } + } + // 消息列表数据 + @State messages: Message[] = [ + { id: 1, content: '欢迎来到直播间!', sender: '系统' }, + { id: 2, content: '大家好啊~', sender: '主播' } + ] + + // 输入框内容 + @State inputText: string = '' + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.ListChatRoom_title') }) { + Column() { + // 聊天消息区域 + List({ space: 10 }) { + ForEach(this.messages, (item: Message) => { + ListItem() { + this.MessageItem(item) + } + }, (item: Message) => item.id.toString()) + } + .layoutWeight(1) // 占据剩余空间 + .alignListItem(ListItemAlign.Center) + + // 输入区域 + Row({ space: 10 }) { + TextInput({ text: this.inputText, placeholder: '说点什么...' }) + .layoutWeight(1) + .onChange((value: string) => { + this.inputText = value + }) + .onSubmit(() => { // 回车发送 + this.sendMessage() + }) + + Button('发送', { type: ButtonType.Capsule }) + .backgroundColor('#007AFF') + .onClick(() => { + this.sendMessage() + }) + } + .padding(10) + .backgroundColor('#F5F5F5') + } + .width('100%') + .height('100%') + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.ListChatRoom_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/ListDataSource.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/ListDataSource.ets index 07e4de1fe5..c3caedf7f6 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/ListDataSource.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/ListDataSource.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export class ListDataSource implements IDataSource { - private list: number[] = []; - private listeners: DataChangeListener[] = []; - - constructor(list: number[]) { - this.list = list; - } - - totalCount(): number { - return this.list.length; - } - - getData(index: number): number { - return this.list[index]; - } - - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - this.listeners.push(listener); - } - } - - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener); - if (pos >= 0) { - this.listeners.splice(pos, 1); - } - } - - // 通知控制器数据删除 - notifyDataDelete(index: number): void { - this.listeners.forEach(listener => { - listener.onDataDelete(index); - }); - } - - // 在指定索引位置删除一个元素 - public deleteItem(index: number): void { - this.list.splice(index, 1); - this.notifyDataDelete(index); - } +/* + * 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 class ListDataSource implements IDataSource { + private list: number[] = []; + private listeners: DataChangeListener[] = []; + + constructor(list: number[]) { + this.list = list; + } + + totalCount(): number { + return this.list.length; + } + + getData(index: number): number { + return this.list[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + this.listeners.splice(pos, 1); + } + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }); + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.list.splice(index, 1); + this.notifyDataDelete(index); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/LongList.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/LongList.ets index 6c5fd86c5d..2a69094a22 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/LongList.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/LongList.ets @@ -1,67 +1,67 @@ -/* - * 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 { ComponentCard } from '../../common/Card'; -import { ListDataSource } from './ListDataSource'; - -@Entry -@Component -export struct LongList { - private arr: ListDataSource = new ListDataSource([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.LongList_title') }) { - List({ space: 20, initialIndex: 0 }) { - LazyForEach(this.arr, (item: number) => { - ListItem() { - Text('' + item) - .width('100%').height(100).fontSize(16) - .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) - } - }, (item: string) => item) - } - .listDirection(Axis.Vertical) // 排列方向 - .scrollBar(BarState.Off) - .friction(0.6) - .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线 - .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring - .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { - console.info('first' + firstIndex); - console.info('last' + lastIndex); - console.info('center' + centerIndex); - }) - .onScrollVisibleContentChange((start: VisibleListContentInfo, end: VisibleListContentInfo) => { - console.log(' start index: ' + start.index + - ' start item group area: ' + start.itemGroupArea + - ' start index in group: ' + start.itemIndexInGroup); - console.log(' end index: ' + end.index + - ' end item group area: ' + end.itemGroupArea + - ' end index in group: ' + end.itemIndexInGroup); - }) - .onDidScroll((scrollOffset: number, scrollState: ScrollState) => { - console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset); - }) - .width('90%') - } - } - .backgroundColor(0xDCDCDC) - .width('100%') - .height('100%') - } - .title($r('app.string.LongList_title')) - } +/* + * 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 { ComponentCard } from '../../common/Card'; +import { ListDataSource } from './ListDataSource'; + +@Entry +@Component +export struct LongList { + private arr: ListDataSource = new ListDataSource([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.LongList_title') }) { + List({ space: 20, initialIndex: 0 }) { + LazyForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%').height(100).fontSize(16) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .listDirection(Axis.Vertical) // 排列方向 + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线 + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { + console.info('first' + firstIndex); + console.info('last' + lastIndex); + console.info('center' + centerIndex); + }) + .onScrollVisibleContentChange((start: VisibleListContentInfo, end: VisibleListContentInfo) => { + console.log(' start index: ' + start.index + + ' start item group area: ' + start.itemGroupArea + + ' start index in group: ' + start.itemIndexInGroup); + console.log(' end index: ' + end.index + + ' end item group area: ' + end.itemGroupArea + + ' end index in group: ' + end.itemIndexInGroup); + }) + .onDidScroll((scrollOffset: number, scrollState: ScrollState) => { + console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset); + }) + .width('90%') + } + } + .backgroundColor(0xDCDCDC) + .width('100%') + .height('100%') + } + .title($r('app.string.LongList_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/swiper/SwiperAndTabsLinkage.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/swiper/SwiperAndTabsLinkage.ets index 4b6320ccd9..9ce261ca58 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/swiper/SwiperAndTabsLinkage.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/swiper/SwiperAndTabsLinkage.ets @@ -1,125 +1,125 @@ -/* - * 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 { ComponentCard } from "../../common/Card"; - -// xxx.ets -class MyDataSource implements IDataSource { - private list: number[] = []; - - constructor(list: number[]) { - this.list = list; - } - - totalCount(): number { - return this.list.length; - } - - getData(index: number): number { - return this.list[index]; - } - - registerDataChangeListener(listener: DataChangeListener): void { - } - - unregisterDataChangeListener() { - } -} - -@Entry -@Component -export struct SwiperAndTabsLinkage { - @State fontColor: string = '#182431'; - @State selectedFontColor: string = '#007DFF'; - @State currentIndex: number = 0; - private list: number[] = []; - private tabsController: TabsController = new TabsController(); - private swiperController: SwiperController = new SwiperController(); - private swiperData: MyDataSource = new MyDataSource([]); - - aboutToAppear(): void { - for (let i = 0; i <= 9; i++) { - this.list.push(i); - } - this.swiperData = new MyDataSource(this.list); - } - - @Builder tabBuilder(index: number, name: string) { - Column() { - Text(name) - .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) - .fontSize(16) - .fontWeight(this.currentIndex === index ? 500 : 400) - .lineHeight(22) - .margin({ top: 17, bottom: 7 }) - Divider() - .strokeWidth(2) - .color('#007DFF') - .opacity(this.currentIndex === index ? 1 : 0) - }.width('20%') - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.SwiperAndTabsLinkage_title') }) { - Column() { - Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { - ForEach(this.list, (index: number) =>{ - TabContent().tabBar(this.tabBuilder(index, '页签 ' + this.list[index])) - }) - } - .onTabBarClick((index: number) => { - this.currentIndex = index; - this.swiperController.changeIndex(index, true); - }) - .barMode(BarMode.Scrollable) - .backgroundColor('#F1F3F5') - .height(56) - .width('100%') - - Swiper(this.swiperController) { - LazyForEach(this.swiperData, (item: string) => { - Text(item.toString()) - .onAppear(()=>{ - console.info('onAppear ' + item.toString()); - }) - .onDisAppear(()=>{ - console.info('onDisAppear ' + item.toString()); - }) - .width('100%') - .height('40%') - .backgroundColor(0xAFEEEE) - .textAlign(TextAlign.Center) - .fontSize(30) - }, (item: string) => item) - } - .loop(false) - .onSelected((index: number) => { - console.info("onSelected:" + index); - this.currentIndex = index; - this.tabsController.changeIndex(index); - }) - } - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.SwiperAndTabsLinkage_title')) - } +/* + * 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 { ComponentCard } from "../../common/Card"; + +// xxx.ets +class MyDataSource implements IDataSource { + private list: number[] = []; + + constructor(list: number[]) { + this.list = list; + } + + totalCount(): number { + return this.list.length; + } + + getData(index: number): number { + return this.list[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +export struct SwiperAndTabsLinkage { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF'; + @State currentIndex: number = 0; + private list: number[] = []; + private tabsController: TabsController = new TabsController(); + private swiperController: SwiperController = new SwiperController(); + private swiperData: MyDataSource = new MyDataSource([]); + + aboutToAppear(): void { + for (let i = 0; i <= 9; i++) { + this.list.push(i); + } + this.swiperData = new MyDataSource(this.list); + } + + @Builder tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }) + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + }.width('20%') + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.SwiperAndTabsLinkage_title') }) { + Column() { + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + ForEach(this.list, (index: number) =>{ + TabContent().tabBar(this.tabBuilder(index, '页签 ' + this.list[index])) + }) + } + .onTabBarClick((index: number) => { + this.currentIndex = index; + this.swiperController.changeIndex(index, true); + }) + .barMode(BarMode.Scrollable) + .backgroundColor('#F1F3F5') + .height(56) + .width('100%') + + Swiper(this.swiperController) { + LazyForEach(this.swiperData, (item: string) => { + Text(item.toString()) + .onAppear(()=>{ + console.info('onAppear ' + item.toString()); + }) + .onDisAppear(()=>{ + console.info('onDisAppear ' + item.toString()); + }) + .width('100%') + .height('40%') + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .loop(false) + .onSelected((index: number) => { + console.info("onSelected:" + index); + this.currentIndex = index; + this.tabsController.changeIndex(index); + }) + } + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.SwiperAndTabsLinkage_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/swiper/SwiperIgnoreComponentSize.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/swiper/SwiperIgnoreComponentSize.ets index 420343eb51..29314df334 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/swiper/SwiperIgnoreComponentSize.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/swiper/SwiperIgnoreComponentSize.ets @@ -1,121 +1,121 @@ -/* - * 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 { LengthMetrics } from '@kit.ArkUI'; -import { ComponentCard } from '../../common/Card'; - - -class MyDataSource implements IDataSource { - private list: number[] = []; - - constructor(list: number[]) { - this.list = list; - } - - totalCount(): number { - return this.list.length; - } - - getData(index: number): number { - return this.list[index]; - } - - registerDataChangeListener(listener: DataChangeListener): void { - } - - unregisterDataChangeListener() { - } -} - -@Entry -@Component -export struct SwiperIgnoreComponentSize { - - @State space: LengthMetrics = LengthMetrics.vp(0); - @State spacePool: LengthMetrics[] = [LengthMetrics.vp(0), LengthMetrics.px(3), LengthMetrics.vp(10)]; - @State spaceIndex: number = 0; - - @State ignoreSize: boolean = false; - @State ignoreSizePool: boolean[] = [false, true]; - @State ignoreSizeIndex: number = 0; - - private swiperController1: SwiperController = new SwiperController(); - private data1: MyDataSource = new MyDataSource([]); - - aboutToAppear(): void { - let list1: number[] = []; - for (let i = 1; i <= 10; i++) { - list1.push(i); - } - this.data1 = new MyDataSource(list1); - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.SwiperIgnoreComponentSize_title') }) { - Scroll() { - Column({ space: 20 }) { - Swiper(this.swiperController1) { - LazyForEach(this.data1, (item: string) => { - Text(item.toString()) - .width('90%') - .height(120) - .backgroundColor(0xAFEEEE) - .textAlign(TextAlign.Center) - .fontSize(30) - }, (item: string) => item) - } - .indicator(new DotIndicator() - .space(this.space) - .bottom(LengthMetrics.vp(0), this.ignoreSize) - .itemWidth(15) - .itemHeight(15) - .selectedItemWidth(15) - .selectedItemHeight(15) - .color(Color.Gray) - .selectedColor(Color.Blue)) - .displayArrow({ - showBackground: true, - isSidebarMiddle: true, - backgroundSize: 24, - backgroundColor: Color.White, - arrowSize: 18, - arrowColor: Color.Blue - }, false) - - Column({ space: 4 }) { - Button('spaceIndex:' + this.spaceIndex).onClick(() => { - this.spaceIndex = (this.spaceIndex + 1) % this.spacePool.length; - this.space = this.spacePool[this.spaceIndex]; - }).margin(10) - - Button('ignoreSizeIndex:' + this.ignoreSizeIndex).onClick(() => { - this.ignoreSizeIndex = (this.ignoreSizeIndex + 1) % this.ignoreSizePool.length; - this.ignoreSize = this.ignoreSizePool[this.ignoreSizeIndex]; - }).margin(10) - }.margin(2) - }.width('100%') - } - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.SwiperIgnoreComponentSize_title')) - } +/* + * 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 { LengthMetrics } from '@kit.ArkUI'; +import { ComponentCard } from '../../common/Card'; + + +class MyDataSource implements IDataSource { + private list: number[] = []; + + constructor(list: number[]) { + this.list = list; + } + + totalCount(): number { + return this.list.length; + } + + getData(index: number): number { + return this.list[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +export struct SwiperIgnoreComponentSize { + + @State space: LengthMetrics = LengthMetrics.vp(0); + @State spacePool: LengthMetrics[] = [LengthMetrics.vp(0), LengthMetrics.px(3), LengthMetrics.vp(10)]; + @State spaceIndex: number = 0; + + @State ignoreSize: boolean = false; + @State ignoreSizePool: boolean[] = [false, true]; + @State ignoreSizeIndex: number = 0; + + private swiperController1: SwiperController = new SwiperController(); + private data1: MyDataSource = new MyDataSource([]); + + aboutToAppear(): void { + let list1: number[] = []; + for (let i = 1; i <= 10; i++) { + list1.push(i); + } + this.data1 = new MyDataSource(list1); + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.SwiperIgnoreComponentSize_title') }) { + Scroll() { + Column({ space: 20 }) { + Swiper(this.swiperController1) { + LazyForEach(this.data1, (item: string) => { + Text(item.toString()) + .width('90%') + .height(120) + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .indicator(new DotIndicator() + .space(this.space) + .bottom(LengthMetrics.vp(0), this.ignoreSize) + .itemWidth(15) + .itemHeight(15) + .selectedItemWidth(15) + .selectedItemHeight(15) + .color(Color.Gray) + .selectedColor(Color.Blue)) + .displayArrow({ + showBackground: true, + isSidebarMiddle: true, + backgroundSize: 24, + backgroundColor: Color.White, + arrowSize: 18, + arrowColor: Color.Blue + }, false) + + Column({ space: 4 }) { + Button('spaceIndex:' + this.spaceIndex).onClick(() => { + this.spaceIndex = (this.spaceIndex + 1) % this.spacePool.length; + this.space = this.spacePool[this.spaceIndex]; + }).margin(10) + + Button('ignoreSizeIndex:' + this.ignoreSizeIndex).onClick(() => { + this.ignoreSizeIndex = (this.ignoreSizeIndex + 1) % this.ignoreSizePool.length; + this.ignoreSize = this.ignoreSizePool[this.ignoreSizeIndex]; + }).margin(10) + }.margin(2) + }.width('100%') + } + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.SwiperIgnoreComponentSize_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDataSource.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDataSource.ets index ef8f873f79..1a68f59619 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDataSource.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDataSource.ets @@ -1,145 +1,145 @@ -/* - * 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. - */ - -// 实现IDataSource接口的对象,用于瀑布流组件加载数据 -export class WaterFlowDataSource implements IDataSource { - private dataArray: number[] = []; - private listeners: DataChangeListener[] = []; - - constructor(count: number) { - for (let i = 0; i < count; i++) { - this.dataArray.push(i); - } - } - - // 获取索引对应的数据 - public getData(index: number): number { - return this.dataArray[index]; - } - - // 通知控制器数据重新加载 - notifyDataReload(): void { - this.listeners.forEach(listener => { - listener.onDataReloaded(); - }) - } - - // 通知控制器数据增加 - notifyDataAdd(index: number): void { - this.listeners.forEach(listener => { - listener.onDataAdd(index); - }) - } - - // 通知控制器数据变化 - notifyDataChange(index: number): void { - this.listeners.forEach(listener => { - listener.onDataChange(index); - }) - } - - // 通知控制器数据删除 - notifyDataDelete(index: number): void { - this.listeners.forEach(listener => { - listener.onDataDelete(index); - }) - } - - // 通知控制器数据位置变化 - notifyDataMove(from: number, to: number): void { - this.listeners.forEach(listener => { - listener.onDataMove(from, to); - }) - } - - // 获取数据总数 - public totalCount(): number { - return this.dataArray.length; - } - - // 注册改变数据的控制器 - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - this.listeners.push(listener); - } - } - - // 注销改变数据的控制器 - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener) - if (pos >= 0) { - this.listeners.splice(pos, 1); - } - } - - // 增加数据 - public add1stItem(): void { - this.dataArray.splice(0, 0, this.dataArray.length); - this.notifyDataAdd(0); - } - - // 在数据尾部增加一个元素 - public addLastItem(): void { - this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length); - this.notifyDataAdd(this.dataArray.length - 1); - } - - public addNewItems(count: number): void { - let len = this.dataArray.length; - for (let i = 0; i < count; i++) { - this.dataArray.push(this.dataArray.length); - } - this.listeners.forEach(listener => { - listener.onDatasetChange([{ type: DataOperationType.ADD, index: len, count: count }]); - }) - } - - // 在指定索引位置增加一个元素 - public addItem(index: number): void { - this.dataArray.splice(index, 0, this.dataArray.length); - this.notifyDataAdd(index); - } - - // 删除第一个元素 - public delete1stItem(): void { - this.dataArray.splice(0, 1); - this.notifyDataDelete(0); - } - - // 删除第二个元素 - public delete2ndItem(): void { - this.dataArray.splice(1, 1); - this.notifyDataDelete(1); - } - - // 删除最后一个元素 - public deleteLastItem(): void { - this.dataArray.splice(-1, 1); - this.notifyDataDelete(this.dataArray.length); - } - - // 在指定索引位置增加一个元素 - public deleteItem(index: number): void { - this.dataArray.splice(index, 1); - this.notifyDataDelete(index); - } - - // 重新加载数据 - public reload(): void { - this.dataArray.splice(1, 1); - this.dataArray.splice(3, 2); - this.notifyDataReload(); - } -} +/* + * 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. + */ + +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = []; + private listeners: DataChangeListener[] = []; + + constructor(count: number) { + for (let i = 0; i < count; i++) { + this.dataArray.push(i); + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index]; + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length; + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener); + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1); + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length); + this.notifyDataAdd(0); + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length); + this.notifyDataAdd(this.dataArray.length - 1); + } + + public addNewItems(count: number): void { + let len = this.dataArray.length; + for (let i = 0; i < count; i++) { + this.dataArray.push(this.dataArray.length); + } + this.listeners.forEach(listener => { + listener.onDatasetChange([{ type: DataOperationType.ADD, index: len, count: count }]); + }) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length); + this.notifyDataAdd(index); + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1); + this.notifyDataDelete(0); + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1); + this.notifyDataDelete(1); + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1); + this.notifyDataDelete(this.dataArray.length); + } + + // 在指定索引位置增加一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1); + this.notifyDataDelete(index); + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1); + this.dataArray.splice(3, 2); + this.notifyDataReload(); + } +} diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDynamicSwitchover.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDynamicSwitchover.ets index 6c7ccb83c5..c29d63a200 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDynamicSwitchover.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDynamicSwitchover.ets @@ -1,179 +1,179 @@ -/* - * 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 { ComponentCard } from '../../common/Card'; -import { WaterFlowDataSource } from './WaterFlowDataSource' -import { image } from '@kit.ImageKit'; - -@Reusable -@Component -struct ReusableFlowItem { - @State item: number = 0; - - // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 - aboutToReuse(params: Record) { - this.item = params.item; - } - - build() { - Column() { - Text('FlowItem' + this.item).fontSize(16).height('16') - Image('res/waterFlow(' + this.item % 5 + ').JPG') - .objectFit(ImageFit.Fill) - .width('100%') - .layoutWeight(1) - } - } -} - -@Reusable -@Component -struct ReusableListItem { - @State item: number = 0; - - aboutToReuse(params: Record) { - this.item = params.item; - } - - build() { - Row() { - Image('res/waterFlow(' + this.item % 5 + ').JPG') - .objectFit(ImageFit.Fill) - .height(100) - .aspectRatio(1) - Text('N' + this.item).fontSize(12).height('16').layoutWeight(1).textAlign(TextAlign.Center) - } - } -} - -@Entry -@Component -export struct WaterFlowDynamicSwitchover { - minSize: number = 80; - maxSize: number = 180; - colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; - dataSource: WaterFlowDataSource = new WaterFlowDataSource(100); - private itemWidthArray: number[] = []; - private itemHeightArray: number[] = []; - @State columns: number = 2; - @State waterflowScale: number = 1; - @State imageScale: number = 1; - @State waterFlowOpacity: number = 1; - @State waterflowSnapshot: image.PixelMap | undefined = undefined; - private columnChanged: boolean = false; - private oldColumn: number = this.columns; - private pinchTime: number = 0; - private gridItems: number[] = []; - - // 计算FlowItem宽/高 - getSize() { - let ret = Math.floor(Math.random() * this.maxSize); - return (ret > this.minSize ? ret : this.minSize); - } - - // 设置FlowItem的宽/高数组 - setItemSizeArray() { - for (let i = 0; i < 100; i++) { - this.itemWidthArray.push(this.getSize()); - this.itemHeightArray.push(this.getSize()); - } - } - - aboutToAppear() { - // 读取上次最后切换到到列数 - let lastCount = AppStorage.get('columnsCount'); - if (typeof lastCount != 'undefined') { - this.columns = lastCount; - } - this.setItemSizeArray(); - for (let i = 0; i < 15; ++i) { - this.gridItems.push(i); - } - } - - // 根据缩放阈值改变列数,触发WaterFlow重新布局 - changeColumns(scale: number) { - if (scale > (this.columns / (this.columns - 0.5)) && this.columns > 1) { - this.columns--; - this.columnChanged = true; - } else if (scale < 1 && this.columns < 4) { - this.columns++; - this.columnChanged = true; - } - } - - @Builder - itemFoot() { - Row() { - LoadingProgress() - .color(Color.Blue).height(50).aspectRatio(1).width('20%') - Text(`正在加载`) - .fontSize(20) - .width('30%') - .height(50) - .align(Alignment.Center) - .margin({ top: 2 }) - }.width('100%').justifyContent(FlexAlign.Center) - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.WaterFlowDynamicSwitchover_title') }) { - Column({ space: 2 }) { - Button('切换列数').fontSize(20).onClick(() => { - if (this.columns === 2) { - this.columns = 1; - } else { - this.columns = 2; - } - }) - WaterFlow({ layoutMode: WaterFlowLayoutMode.SLIDING_WINDOW }) { - LazyForEach(this.dataSource, (item: number) => { - FlowItem() { - if (this.columns === 1) { - ReusableListItem({ item: item }) - } else { - ReusableFlowItem({ item: item }) - } - } - .width('100%') - .aspectRatio(this.columns === 2 ? this.itemHeightArray[item % 100] / this.itemWidthArray[item % 100] : 0) - .backgroundColor(this.colors[item % 5]) - }, (item: string) => item) - } - .columnsTemplate('1fr '.repeat(this.columns)) - .backgroundColor(0xFAEEE0) - .width('100%') - .height('100%') - .layoutWeight(1) - // 即将触底时提前增加数据 - .onScrollIndex((first: number, last: number) => { - if (last + 20 >= this.dataSource.totalCount()) { - setTimeout(() => { - this.dataSource.addNewItems(100); - }, 1000); - } - }) - } - } - } - .width('100%') - .height('100%') - } - .backgroundColor('#f1f2f3') - .title($r('app.string.WaterFlowDynamicSwitchover_title')) - } -} +/* + * 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 { ComponentCard } from '../../common/Card'; +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { image } from '@kit.ImageKit'; + +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0; + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + } + + build() { + Column() { + Text('FlowItem' + this.item).fontSize(16).height('16') + Image('res/waterFlow(' + this.item % 5 + ').JPG') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } +} + +@Reusable +@Component +struct ReusableListItem { + @State item: number = 0; + + aboutToReuse(params: Record) { + this.item = params.item; + } + + build() { + Row() { + Image('res/waterFlow(' + this.item % 5 + ').JPG') + .objectFit(ImageFit.Fill) + .height(100) + .aspectRatio(1) + Text('N' + this.item).fontSize(12).height('16').layoutWeight(1).textAlign(TextAlign.Center) + } + } +} + +@Entry +@Component +export struct WaterFlowDynamicSwitchover { + minSize: number = 80; + maxSize: number = 180; + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + dataSource: WaterFlowDataSource = new WaterFlowDataSource(100); + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + @State columns: number = 2; + @State waterflowScale: number = 1; + @State imageScale: number = 1; + @State waterFlowOpacity: number = 1; + @State waterflowSnapshot: image.PixelMap | undefined = undefined; + private columnChanged: boolean = false; + private oldColumn: number = this.columns; + private pinchTime: number = 0; + private gridItems: number[] = []; + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + // 读取上次最后切换到到列数 + let lastCount = AppStorage.get('columnsCount'); + if (typeof lastCount != 'undefined') { + this.columns = lastCount; + } + this.setItemSizeArray(); + for (let i = 0; i < 15; ++i) { + this.gridItems.push(i); + } + } + + // 根据缩放阈值改变列数,触发WaterFlow重新布局 + changeColumns(scale: number) { + if (scale > (this.columns / (this.columns - 0.5)) && this.columns > 1) { + this.columns--; + this.columnChanged = true; + } else if (scale < 1 && this.columns < 4) { + this.columns++; + this.columnChanged = true; + } + } + + @Builder + itemFoot() { + Row() { + LoadingProgress() + .color(Color.Blue).height(50).aspectRatio(1).width('20%') + Text(`正在加载`) + .fontSize(20) + .width('30%') + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + }.width('100%').justifyContent(FlexAlign.Center) + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.WaterFlowDynamicSwitchover_title') }) { + Column({ space: 2 }) { + Button('切换列数').fontSize(20).onClick(() => { + if (this.columns === 2) { + this.columns = 1; + } else { + this.columns = 2; + } + }) + WaterFlow({ layoutMode: WaterFlowLayoutMode.SLIDING_WINDOW }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + if (this.columns === 1) { + ReusableListItem({ item: item }) + } else { + ReusableFlowItem({ item: item }) + } + } + .width('100%') + .aspectRatio(this.columns === 2 ? this.itemHeightArray[item % 100] / this.itemWidthArray[item % 100] : 0) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .columnsTemplate('1fr '.repeat(this.columns)) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + // 即将触底时提前增加数据 + .onScrollIndex((first: number, last: number) => { + if (last + 20 >= this.dataSource.totalCount()) { + setTimeout(() => { + this.dataSource.addNewItems(100); + }, 1000); + } + }) + } + } + } + .width('100%') + .height('100%') + } + .backgroundColor('#f1f2f3') + .title($r('app.string.WaterFlowDynamicSwitchover_title')) + } +} diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowGroupingMixing.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowGroupingMixing.ets index 0f5fcc388c..7c0059d37d 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowGroupingMixing.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowGroupingMixing.ets @@ -1,180 +1,180 @@ -/* - * 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 { ComponentCard } from '../../common/Card'; -import { WaterFlowDataSource } from './WaterFlowDataSource' -import { image } from '@kit.ImageKit'; - -@Reusable -@Component -struct ReusableFlowItem { - @State item: number = 0; - - // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 - aboutToReuse(params: Record) { - this.item = params.item; - } - - build() { - Stack({ alignContent: Alignment.Center }) { - Text('FlowItem' + this.item).fontSize(14).height('16') - Image('res/waterFlow (' + this.item % 5 + ').JPG') - .objectFit(ImageFit.Fill) - .width('100%') - .layoutWeight(1) - } - } -} - -@Entry -@Component -export struct WaterFlowGroupingMixing { - minSize: number = 80; - maxSize: number = 180; - colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; - dataSource: WaterFlowDataSource = new WaterFlowDataSource(100); - private itemWidthArray: number[] = []; - private itemHeightArray: number[] = []; - @State columns: number = 2; - @State waterflowScale: number = 1; - @State imageScale: number = 1; - @State waterFlowOpacity: number = 1; - @State waterflowSnapshot: image.PixelMap | undefined = undefined; - private columnChanged: boolean = false; - private oldColumn: number = this.columns; - private pinchTime: number = 0; - private gridItems: number[] = []; - - // 计算FlowItem宽/高 - getSize() { - let ret = Math.floor(Math.random() * this.maxSize); - return (ret > this.minSize ? ret : this.minSize); - } - - // 设置FlowItem的宽/高数组 - setItemSizeArray() { - for (let i = 0; i < 100; i++) { - this.itemWidthArray.push(this.getSize()); - this.itemHeightArray.push(this.getSize()); - } - } - - aboutToAppear() { - // 读取上次最后切换到到列数 - let lastCount = AppStorage.get('columnsCount'); - if (typeof lastCount != 'undefined') { - this.columns = lastCount; - } - this.setItemSizeArray(); - for (let i = 0; i < 15; ++i) { - this.gridItems.push(i); - } - } - - // 根据缩放阈值改变列数,触发WaterFlow重新布局 - changeColumns(scale: number) { - if (scale > (this.columns / (this.columns - 0.5)) && this.columns > 1) { - this.columns--; - this.columnChanged = true; - } else if (scale < 1 && this.columns < 4) { - this.columns++; - this.columnChanged = true; - } - } - - @Builder - itemFoot() { - Row() { - LoadingProgress() - .color(Color.Blue).height(50).aspectRatio(1).width('20%') - Text(`正在加载`) - .fontSize(20) - .width('30%') - .height(50) - .align(Alignment.Center) - .margin({ top: 2 }) - }.width('100%').justifyContent(FlexAlign.Center) - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.WaterFlowGroupingMixing_title') }) { - List({ space: 10 }) { - ListItem() { - Text('List').fontSize(14).height(16).margin(3) - } - - ListItem() { - Column() { - Text('Grid in ListItem').fontSize(12).height(16).margin(3) - - Grid() { - ForEach(this.gridItems, (day: number) => { - GridItem() { - Text('GridItem').fontSize(10).height(16) - }.backgroundColor(0xFFC0CB) - }, (day: number) => day.toString()) - } - .height('30%') - .rowsGap(5) - .columnsGap(5) - .columnsTemplate('1fr '.repeat(5)) - .rowsTemplate('1fr '.repeat(3)) - .width('95%') - }.borderWidth(3) - } - - ListItem() { - Column() { - Text('WaterFlow in ListItem').fontSize(14).height(16).margin(3) - WaterFlow({ layoutMode: WaterFlowLayoutMode.SLIDING_WINDOW }) { - LazyForEach(this.dataSource, (item: number) => { - FlowItem() { - ReusableFlowItem({ item: item }) - } - .width('100%') - .aspectRatio(this.columns === 2 ? this.itemHeightArray[item % 100] / this.itemWidthArray[item % 100] : 0) - .backgroundColor(this.colors[item % 5]) - }, (item: string) => item) - } - .columnsTemplate('1fr '.repeat(this.columns)) - .backgroundColor(0xFAEEE0) - .height('100%') - .layoutWeight(1) - // 即将触底时提前增加数据 - .onScrollIndex((first: number, last: number) => { - if (last + 20 >= this.dataSource.totalCount()) { - setTimeout(() => { - this.dataSource.addNewItems(100); - }, 1000) - } - }) - .width('95%') - }.borderWidth(3) - } - }.borderWidth(3) - .width('98%') - .alignListItem(ListItemAlign.Center).scrollBar(BarState.Off) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.WaterFlowGroupingMixing_title')) - } -} +/* + * 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 { ComponentCard } from '../../common/Card'; +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { image } from '@kit.ImageKit'; + +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0; + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + } + + build() { + Stack({ alignContent: Alignment.Center }) { + Text('FlowItem' + this.item).fontSize(14).height('16') + Image('res/waterFlow (' + this.item % 5 + ').JPG') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } +} + +@Entry +@Component +export struct WaterFlowGroupingMixing { + minSize: number = 80; + maxSize: number = 180; + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + dataSource: WaterFlowDataSource = new WaterFlowDataSource(100); + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + @State columns: number = 2; + @State waterflowScale: number = 1; + @State imageScale: number = 1; + @State waterFlowOpacity: number = 1; + @State waterflowSnapshot: image.PixelMap | undefined = undefined; + private columnChanged: boolean = false; + private oldColumn: number = this.columns; + private pinchTime: number = 0; + private gridItems: number[] = []; + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + // 读取上次最后切换到到列数 + let lastCount = AppStorage.get('columnsCount'); + if (typeof lastCount != 'undefined') { + this.columns = lastCount; + } + this.setItemSizeArray(); + for (let i = 0; i < 15; ++i) { + this.gridItems.push(i); + } + } + + // 根据缩放阈值改变列数,触发WaterFlow重新布局 + changeColumns(scale: number) { + if (scale > (this.columns / (this.columns - 0.5)) && this.columns > 1) { + this.columns--; + this.columnChanged = true; + } else if (scale < 1 && this.columns < 4) { + this.columns++; + this.columnChanged = true; + } + } + + @Builder + itemFoot() { + Row() { + LoadingProgress() + .color(Color.Blue).height(50).aspectRatio(1).width('20%') + Text(`正在加载`) + .fontSize(20) + .width('30%') + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + }.width('100%').justifyContent(FlexAlign.Center) + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.WaterFlowGroupingMixing_title') }) { + List({ space: 10 }) { + ListItem() { + Text('List').fontSize(14).height(16).margin(3) + } + + ListItem() { + Column() { + Text('Grid in ListItem').fontSize(12).height(16).margin(3) + + Grid() { + ForEach(this.gridItems, (day: number) => { + GridItem() { + Text('GridItem').fontSize(10).height(16) + }.backgroundColor(0xFFC0CB) + }, (day: number) => day.toString()) + } + .height('30%') + .rowsGap(5) + .columnsGap(5) + .columnsTemplate('1fr '.repeat(5)) + .rowsTemplate('1fr '.repeat(3)) + .width('95%') + }.borderWidth(3) + } + + ListItem() { + Column() { + Text('WaterFlow in ListItem').fontSize(14).height(16).margin(3) + WaterFlow({ layoutMode: WaterFlowLayoutMode.SLIDING_WINDOW }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + .aspectRatio(this.columns === 2 ? this.itemHeightArray[item % 100] / this.itemWidthArray[item % 100] : 0) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .columnsTemplate('1fr '.repeat(this.columns)) + .backgroundColor(0xFAEEE0) + .height('100%') + .layoutWeight(1) + // 即将触底时提前增加数据 + .onScrollIndex((first: number, last: number) => { + if (last + 20 >= this.dataSource.totalCount()) { + setTimeout(() => { + this.dataSource.addNewItems(100); + }, 1000) + } + }) + .width('95%') + }.borderWidth(3) + } + }.borderWidth(3) + .width('98%') + .alignListItem(ListItemAlign.Center).scrollBar(BarState.Off) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.WaterFlowGroupingMixing_title')) + } +} diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowInfiniteScrolling.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowInfiniteScrolling.ets index 090bdf39b8..d5a726b1e8 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowInfiniteScrolling.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowInfiniteScrolling.ets @@ -1,147 +1,147 @@ -/* - * 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 { ComponentCard } from '../../common/Card'; -import { WaterFlowDataSource } from './WaterFlowDataSource' -import { image } from '@kit.ImageKit'; - -@Reusable -@Component -struct ReusableFlowItem { - @State item: number = 0; - - // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 - aboutToReuse(params: Record) { - this.item = params.item; - } - - build() { - Column() { - Text('FlowItem' + this.item).fontSize(16).height('16') - Image('res/waterFlow(' + this.item % 5 + ').JPG') - .objectFit(ImageFit.Fill) - .width('100%') - .layoutWeight(1) - } - } -} - -@Entry -@Component -export struct WaterFlowInfiniteScrolling { - minSize: number = 80; - maxSize: number = 180; - colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; - dataSource: WaterFlowDataSource = new WaterFlowDataSource(100); - private itemWidthArray: number[] = []; - private itemHeightArray: number[] = []; - @State columns: number = 2; - @State waterflowScale: number = 1; - @State imageScale: number = 1; - @State waterFlowOpacity: number = 1; - @State waterflowSnapshot: image.PixelMap | undefined = undefined; - private columnChanged: boolean = false; - private oldColumn: number = this.columns; - private pinchTime: number = 0; - private gridItems: number[] = []; - - // 计算FlowItem宽/高 - getSize() { - let ret = Math.floor(Math.random() * this.maxSize); - return (ret > this.minSize ? ret : this.minSize); - } - - // 设置FlowItem的宽/高数组 - setItemSizeArray() { - for (let i = 0; i < 100; i++) { - this.itemWidthArray.push(this.getSize()); - this.itemHeightArray.push(this.getSize()); - } - } - - aboutToAppear() { - // 读取上次最后切换到到列数 - let lastCount = AppStorage.get('columnsCount'); - if (typeof lastCount != 'undefined') { - this.columns = lastCount; - } - this.setItemSizeArray(); - for (let i = 0; i < 15; ++i) { - this.gridItems.push(i); - } - } - - // 根据缩放阈值改变列数,触发WaterFlow重新布局 - changeColumns(scale: number) { - if (scale > (this.columns / (this.columns - 0.5)) && this.columns > 1) { - this.columns--; - this.columnChanged = true; - } else if (scale < 1 && this.columns < 4) { - this.columns++; - this.columnChanged = true; - } - } - - @Builder - itemFoot() { - Row() { - LoadingProgress() - .color(Color.Blue).height(50).aspectRatio(1).width('20%') - Text(`正在加载`) - .fontSize(20) - .width('30%') - .height(50) - .align(Alignment.Center) - .margin({ top: 2 }) - }.width('100%').justifyContent(FlexAlign.Center) - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.WaterFlowInfiniteScrolling_title') }) { - WaterFlow({ footer: this.itemFoot(), layoutMode: WaterFlowLayoutMode.SLIDING_WINDOW }) { - LazyForEach(this.dataSource, (item: number) => { - FlowItem() { - ReusableFlowItem({ item: item }) - } - .width('100%') - .aspectRatio(this.itemHeightArray[item % 100] / this.itemWidthArray[item%100]) - .backgroundColor(this.colors[item % 5]) - }, (item: string) => item) - } - .columnsTemplate('1fr '.repeat(this.columns)) - .backgroundColor(0xFAEEE0) - .width('100%') - .height('100%') - .layoutWeight(1) - // 触底加载数据 - .onReachEnd(() => { - setTimeout(() => { - for (let i = 0; i < 100; i++) { - this.dataSource.addLastItem(); - } - }, 1000) - }) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.WaterFlowInfiniteScrolling_title')) - } -} +/* + * 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 { ComponentCard } from '../../common/Card'; +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { image } from '@kit.ImageKit'; + +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0; + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + } + + build() { + Column() { + Text('FlowItem' + this.item).fontSize(16).height('16') + Image('res/waterFlow(' + this.item % 5 + ').JPG') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } +} + +@Entry +@Component +export struct WaterFlowInfiniteScrolling { + minSize: number = 80; + maxSize: number = 180; + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + dataSource: WaterFlowDataSource = new WaterFlowDataSource(100); + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + @State columns: number = 2; + @State waterflowScale: number = 1; + @State imageScale: number = 1; + @State waterFlowOpacity: number = 1; + @State waterflowSnapshot: image.PixelMap | undefined = undefined; + private columnChanged: boolean = false; + private oldColumn: number = this.columns; + private pinchTime: number = 0; + private gridItems: number[] = []; + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + // 读取上次最后切换到到列数 + let lastCount = AppStorage.get('columnsCount'); + if (typeof lastCount != 'undefined') { + this.columns = lastCount; + } + this.setItemSizeArray(); + for (let i = 0; i < 15; ++i) { + this.gridItems.push(i); + } + } + + // 根据缩放阈值改变列数,触发WaterFlow重新布局 + changeColumns(scale: number) { + if (scale > (this.columns / (this.columns - 0.5)) && this.columns > 1) { + this.columns--; + this.columnChanged = true; + } else if (scale < 1 && this.columns < 4) { + this.columns++; + this.columnChanged = true; + } + } + + @Builder + itemFoot() { + Row() { + LoadingProgress() + .color(Color.Blue).height(50).aspectRatio(1).width('20%') + Text(`正在加载`) + .fontSize(20) + .width('30%') + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + }.width('100%').justifyContent(FlexAlign.Center) + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.WaterFlowInfiniteScrolling_title') }) { + WaterFlow({ footer: this.itemFoot(), layoutMode: WaterFlowLayoutMode.SLIDING_WINDOW }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + .aspectRatio(this.itemHeightArray[item % 100] / this.itemWidthArray[item%100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .columnsTemplate('1fr '.repeat(this.columns)) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + // 触底加载数据 + .onReachEnd(() => { + setTimeout(() => { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem(); + } + }, 1000) + }) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.WaterFlowInfiniteScrolling_title')) + } +} diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowInfiniteScrollingEarly.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowInfiniteScrollingEarly.ets index 162cb8e756..2862877a85 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowInfiniteScrollingEarly.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowInfiniteScrollingEarly.ets @@ -1,147 +1,147 @@ -/* - * 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 { ComponentCard } from '../../common/Card'; -import { WaterFlowDataSource } from './WaterFlowDataSource' -import { image } from '@kit.ImageKit'; - -@Reusable -@Component -struct ReusableFlowItem { - @State item: number = 0; - - // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 - aboutToReuse(params: Record) { - this.item = params.item; - } - - build() { - Column() { - Text('FlowItem' + this.item).fontSize(16).height('16') - Image('res/waterFlow(' + this.item % 5 + ').JPG') - .objectFit(ImageFit.Fill) - .width('100%') - .layoutWeight(1) - } - } -} - -@Entry -@Component -export struct WaterFlowInfiniteScrollingEarly { - minSize: number = 80; - maxSize: number = 180; - colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; - dataSource: WaterFlowDataSource = new WaterFlowDataSource(100); - private itemWidthArray: number[] = []; - private itemHeightArray: number[] = []; - @State columns: number = 2; - @State waterflowScale: number = 1; - @State imageScale: number = 1; - @State waterFlowOpacity: number = 1; - @State waterflowSnapshot: image.PixelMap | undefined = undefined; - private columnChanged: boolean = false; - private oldColumn: number = this.columns; - private pinchTime: number = 0; - private gridItems: number[] = []; - - // 计算FlowItem宽/高 - getSize() { - let ret = Math.floor(Math.random() * this.maxSize); - return (ret > this.minSize ? ret : this.minSize); - } - - // 设置FlowItem的宽/高数组 - setItemSizeArray() { - for (let i = 0; i < 100; i++) { - this.itemWidthArray.push(this.getSize()); - this.itemHeightArray.push(this.getSize()); - } - } - - aboutToAppear() { - // 读取上次最后切换到到列数 - let lastCount = AppStorage.get('columnsCount'); - if (typeof lastCount != 'undefined') { - this.columns = lastCount; - } - this.setItemSizeArray(); - for (let i = 0; i < 15; ++i) { - this.gridItems.push(i); - } - } - - // 根据缩放阈值改变列数,触发WaterFlow重新布局 - changeColumns(scale: number) { - if (scale > (this.columns / (this.columns - 0.5)) && this.columns > 1) { - this.columns--; - this.columnChanged = true; - } else if (scale < 1 && this.columns < 4) { - this.columns++; - this.columnChanged = true; - } - } - - @Builder - itemFoot() { - Row() { - LoadingProgress() - .color(Color.Blue).height(50).aspectRatio(1).width('20%') - Text(`正在加载`) - .fontSize(20) - .width('30%') - .height(50) - .align(Alignment.Center) - .margin({ top: 2 }) - }.width('100%').justifyContent(FlexAlign.Center) - } - - build() { - NavDestination() { - Column({ space: 12 }) { - ComponentCard({ title: $r('app.string.WaterFlowInfiniteScrollingEarly_title') }) { - WaterFlow({ layoutMode: WaterFlowLayoutMode.SLIDING_WINDOW }) { - LazyForEach(this.dataSource, (item: number) => { - FlowItem() { - ReusableFlowItem({ item: item }) - } - .width('100%') - .aspectRatio(this.itemHeightArray[item % 100] / this.itemWidthArray[item%100]) - .backgroundColor(this.colors[item % 5]) - }, (item: string) => item) - } - .columnsTemplate('1fr '.repeat(this.columns)) - .backgroundColor(0xFAEEE0) - .width('100%') - .height('100%') - .layoutWeight(1) - // 即将触底时提前增加数据 - .onScrollIndex((first: number, last: number) => { - if (last + 20 >= this.dataSource.totalCount()) { - setTimeout(() => { - this.dataSource.addNewItems(100); - }, 1000); - } - }) - } - } - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor('#f1f2f3') - .title($r('app.string.WaterFlowInfiniteScrollingEarly_title')) - } +/* + * 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 { ComponentCard } from '../../common/Card'; +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { image } from '@kit.ImageKit'; + +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0; + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + } + + build() { + Column() { + Text('FlowItem' + this.item).fontSize(16).height('16') + Image('res/waterFlow(' + this.item % 5 + ').JPG') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } +} + +@Entry +@Component +export struct WaterFlowInfiniteScrollingEarly { + minSize: number = 80; + maxSize: number = 180; + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + dataSource: WaterFlowDataSource = new WaterFlowDataSource(100); + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + @State columns: number = 2; + @State waterflowScale: number = 1; + @State imageScale: number = 1; + @State waterFlowOpacity: number = 1; + @State waterflowSnapshot: image.PixelMap | undefined = undefined; + private columnChanged: boolean = false; + private oldColumn: number = this.columns; + private pinchTime: number = 0; + private gridItems: number[] = []; + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + // 读取上次最后切换到到列数 + let lastCount = AppStorage.get('columnsCount'); + if (typeof lastCount != 'undefined') { + this.columns = lastCount; + } + this.setItemSizeArray(); + for (let i = 0; i < 15; ++i) { + this.gridItems.push(i); + } + } + + // 根据缩放阈值改变列数,触发WaterFlow重新布局 + changeColumns(scale: number) { + if (scale > (this.columns / (this.columns - 0.5)) && this.columns > 1) { + this.columns--; + this.columnChanged = true; + } else if (scale < 1 && this.columns < 4) { + this.columns++; + this.columnChanged = true; + } + } + + @Builder + itemFoot() { + Row() { + LoadingProgress() + .color(Color.Blue).height(50).aspectRatio(1).width('20%') + Text(`正在加载`) + .fontSize(20) + .width('30%') + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + }.width('100%').justifyContent(FlexAlign.Center) + } + + build() { + NavDestination() { + Column({ space: 12 }) { + ComponentCard({ title: $r('app.string.WaterFlowInfiniteScrollingEarly_title') }) { + WaterFlow({ layoutMode: WaterFlowLayoutMode.SLIDING_WINDOW }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + .aspectRatio(this.itemHeightArray[item % 100] / this.itemWidthArray[item%100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .columnsTemplate('1fr '.repeat(this.columns)) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + // 即将触底时提前增加数据 + .onScrollIndex((first: number, last: number) => { + if (last + 20 >= this.dataSource.totalCount()) { + setTimeout(() => { + this.dataSource.addNewItems(100); + }, 1000); + } + }) + } + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.WaterFlowInfiniteScrollingEarly_title')) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/index.ets b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/index.ets index d7c2f53083..d01ac38612 100644 --- a/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/index.ets +++ b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/index.ets @@ -1,92 +1,92 @@ -/* - * 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 { CompletedRoutableCard } from '../../common/Card'; -import { Route } from '../../common/Route'; -import { WaterFlowInfiniteScrolling } from './WaterFlowInfiniteScrolling'; -import { WaterFlowInfiniteScrollingEarly } from './WaterFlowInfiniteScrollingEarly'; -import { WaterFlowGroupingMixing } from './WaterFlowGroupingMixing'; -import { WaterFlowDynamicSwitchover } from './WaterFlowDynamicSwitchover'; -import resource from '../../common/resource'; - -export const WATERFLOW_ROUTE_PREFIX: string = 'waterFlow'; - -const routes: Route[] = [ - { - name: `${WATERFLOW_ROUTE_PREFIX}/WaterFlowInfiniteScrolling`, - title: resource.resourceToString($r('app.string.WaterFlowInfiniteScrolling_title')), - description: $r('app.string.WaterFlowInfiniteScrolling_description') - }, - { - name: `${WATERFLOW_ROUTE_PREFIX}/WaterFlowInfiniteScrollingEarly`, - title: resource.resourceToString($r('app.string.WaterFlowInfiniteScrollingEarly_title')), - description: $r('app.string.WaterFlowInfiniteScrollingEarly_description') - }, - { - name: `${WATERFLOW_ROUTE_PREFIX}/WaterFlowGroupingMixing`, - title: resource.resourceToString($r('app.string.WaterFlowGroupingMixing_title')), - description: $r('app.string.WaterFlowGroupingMixing_description') - }, - { - name: `${WATERFLOW_ROUTE_PREFIX}/WaterFlowDynamicSwitchover`, - title: resource.resourceToString($r('app.string.WaterFlowDynamicSwitchover_title')), - description: $r('app.string.WaterFlowDynamicSwitchover_description') - } - -]; - -@Builder -export function waterFlowDestination(name: string) { - if (name === WATERFLOW_ROUTE_PREFIX) { - WaterFlowExample(); - } else if (name === routes[0].name) { - WaterFlowInfiniteScrolling(); - } else if (name === routes[1].name) { - WaterFlowInfiniteScrollingEarly(); - } else if (name === routes[2].name) { - WaterFlowGroupingMixing(); - } else if (name === routes[3].name) { - WaterFlowDynamicSwitchover(); - } -} - -@Entry -@Component -struct WaterFlowExample { - @Consume pathStack: NavPathStack; - - build() { - NavDestination() { - List({ space: 12 }) { - ForEach(routes, (route: Route) => { - ListItem() { - CompletedRoutableCard({ title: route.title, description: route.description }) - } - .width('100%') - .onClick(() => { - this.pathStack.pushPath({ name: route.name }); - }) - }) - } - .contentStartOffset(56) - .padding({ left: 16, right: 16 }) - } - .backgroundColor('#f1f3f5') - .title('WaterFlow', { - backgroundBlurStyle: BlurStyle.COMPONENT_THICK, - barStyle: BarStyle.STACK - }) - } +/* + * 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 { CompletedRoutableCard } from '../../common/Card'; +import { Route } from '../../common/Route'; +import { WaterFlowInfiniteScrolling } from './WaterFlowInfiniteScrolling'; +import { WaterFlowInfiniteScrollingEarly } from './WaterFlowInfiniteScrollingEarly'; +import { WaterFlowGroupingMixing } from './WaterFlowGroupingMixing'; +import { WaterFlowDynamicSwitchover } from './WaterFlowDynamicSwitchover'; +import resource from '../../common/resource'; + +export const WATERFLOW_ROUTE_PREFIX: string = 'waterFlow'; + +const routes: Route[] = [ + { + name: `${WATERFLOW_ROUTE_PREFIX}/WaterFlowInfiniteScrolling`, + title: resource.resourceToString($r('app.string.WaterFlowInfiniteScrolling_title')), + description: $r('app.string.WaterFlowInfiniteScrolling_description') + }, + { + name: `${WATERFLOW_ROUTE_PREFIX}/WaterFlowInfiniteScrollingEarly`, + title: resource.resourceToString($r('app.string.WaterFlowInfiniteScrollingEarly_title')), + description: $r('app.string.WaterFlowInfiniteScrollingEarly_description') + }, + { + name: `${WATERFLOW_ROUTE_PREFIX}/WaterFlowGroupingMixing`, + title: resource.resourceToString($r('app.string.WaterFlowGroupingMixing_title')), + description: $r('app.string.WaterFlowGroupingMixing_description') + }, + { + name: `${WATERFLOW_ROUTE_PREFIX}/WaterFlowDynamicSwitchover`, + title: resource.resourceToString($r('app.string.WaterFlowDynamicSwitchover_title')), + description: $r('app.string.WaterFlowDynamicSwitchover_description') + } + +]; + +@Builder +export function waterFlowDestination(name: string) { + if (name === WATERFLOW_ROUTE_PREFIX) { + WaterFlowExample(); + } else if (name === routes[0].name) { + WaterFlowInfiniteScrolling(); + } else if (name === routes[1].name) { + WaterFlowInfiniteScrollingEarly(); + } else if (name === routes[2].name) { + WaterFlowGroupingMixing(); + } else if (name === routes[3].name) { + WaterFlowDynamicSwitchover(); + } +} + +@Entry +@Component +struct WaterFlowExample { + @Consume pathStack: NavPathStack; + + build() { + NavDestination() { + List({ space: 12 }) { + ForEach(routes, (route: Route) => { + ListItem() { + CompletedRoutableCard({ title: route.title, description: route.description }) + } + .width('100%') + .onClick(() => { + this.pathStack.pushPath({ name: route.name }); + }) + }) + } + .contentStartOffset(56) + .padding({ left: 16, right: 16 }) + } + .backgroundColor('#f1f3f5') + .title('WaterFlow', { + backgroundBlurStyle: BlurStyle.COMPONENT_THICK, + barStyle: BarStyle.STACK + }) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/AppScope/app.json5 b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/AppScope/app.json5 index 64b99a033e..f7577827b3 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/AppScope/app.json5 +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/AppScope/app.json5 @@ -1,26 +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. - * -*/ - -{ - "app": { - "bundleName": "com.samples.statemgmtv2mvvm", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.statemgmtv2mvvm", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/AppScope/resources/base/element/string.json b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/AppScope/resources/base/element/string.json index dc01ed969a..cf5987edb1 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "StateMgmtV2MVVM" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "StateMgmtV2MVVM" + } + ] +} diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/README.md b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/README.md index 9ea5138d60..b96a86d0ac 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/README.md +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/README.md @@ -1,71 +1,71 @@ -# MVVM模式(状态管理V2)示例 - -### 介绍 -本教程通过一个简单的待办事项应用示例,逐步引入了状态管理V2装饰器,并通过代码重构实现了MVVM架构。最终,将数据、逻辑和视图分层,使得代码结构更加清晰、易于维护。 - -### 效果预览 -|TodoList页面 | -|----------------------------------------------| -|![todolist](./screenshots/MVVMV2-todolist.gif)| - -使用说明 -1. 点击任务切换任务完成状态; -2. 点击删除、输入添加新任务完成任务增删; -3. 点击全部完成、全部未完成更新所有任务完成状态; -4. 点击设置,更新是否显示已完成任务。 - -### 工程目录 -``` -/src -├── /main -│ ├── /ets -│ │ ├── /entryability -│ │ ├── /model //重构后的Model层 -│ │ │ ├── TaskListModel.ets -│ │ │ └── TaskModel.ets -│ │ ├── /pages //通过状态管理V2版本实现ViewModel -│ │ │ ├── 1-Basic.ets -│ │ │ ├── 2-Local.ets -│ │ │ ├── 3-Param.ets -│ │ │ ├── 4-Event.ets -│ │ │ ├── 5-Repeat.ets -│ │ │ ├── 6-ObservedV2Trace.ets -│ │ │ ├── 7-MonitorComputed.ets -│ │ │ ├── 8-AppStorageV2.ets -│ │ │ ├── 9-PersistenceV2.ets -│ │ │ ├── 10-Builder.ets -│ │ │ ├── SettingPage.ets //设置页 -│ │ │ └── TodoListPage.ets //重构后的主页面 -│ │ ├── /settingability -│ │ ├── /view //重构后的View层 -│ │ │ ├── BottomView.ets -│ │ │ ├── ListView.ets -│ │ │ └── TitleView.ets -│ │ ├── /viewmodel //重构后的ViewModel层 -│ │ │ ├── TaskListViewModel.ets -│ │ │ └── TaskViewModel.ets -│ └── /resources -│ ├── ... -├─── ... -``` - -### 相关权限 -不涉及。 - -### 依赖 -不涉及。 - -### 约束与限制 -1. 本示例仅支持标准系统上运行,支持设备:RK3568; -2. 本示例为Stage模型,已适配API12版本SDK,SDK版本号5.0.0.71; -3. 本示例需要使用DevEco Studio 版本号(5.0.3.900)版本才可编译运行。 - -### 下载 -如需单独下载本工程,执行如下命令: -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkUISample/StateMgmtV2MVVM > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` +# MVVM模式(状态管理V2)示例 + +### 介绍 +本教程通过一个简单的待办事项应用示例,逐步引入了状态管理V2装饰器,并通过代码重构实现了MVVM架构。最终,将数据、逻辑和视图分层,使得代码结构更加清晰、易于维护。 + +### 效果预览 +|TodoList页面 | +|----------------------------------------------| +|![todolist](./screenshots/MVVMV2-todolist.gif)| + +使用说明 +1. 点击任务切换任务完成状态; +2. 点击删除、输入添加新任务完成任务增删; +3. 点击全部完成、全部未完成更新所有任务完成状态; +4. 点击设置,更新是否显示已完成任务。 + +### 工程目录 +``` +/src +├── /main +│ ├── /ets +│ │ ├── /entryability +│ │ ├── /model //重构后的Model层 +│ │ │ ├── TaskListModel.ets +│ │ │ └── TaskModel.ets +│ │ ├── /pages //通过状态管理V2版本实现ViewModel +│ │ │ ├── 1-Basic.ets +│ │ │ ├── 2-Local.ets +│ │ │ ├── 3-Param.ets +│ │ │ ├── 4-Event.ets +│ │ │ ├── 5-Repeat.ets +│ │ │ ├── 6-ObservedV2Trace.ets +│ │ │ ├── 7-MonitorComputed.ets +│ │ │ ├── 8-AppStorageV2.ets +│ │ │ ├── 9-PersistenceV2.ets +│ │ │ ├── 10-Builder.ets +│ │ │ ├── SettingPage.ets //设置页 +│ │ │ └── TodoListPage.ets //重构后的主页面 +│ │ ├── /settingability +│ │ ├── /view //重构后的View层 +│ │ │ ├── BottomView.ets +│ │ │ ├── ListView.ets +│ │ │ └── TitleView.ets +│ │ ├── /viewmodel //重构后的ViewModel层 +│ │ │ ├── TaskListViewModel.ets +│ │ │ └── TaskViewModel.ets +│ └── /resources +│ ├── ... +├─── ... +``` + +### 相关权限 +不涉及。 + +### 依赖 +不涉及。 + +### 约束与限制 +1. 本示例仅支持标准系统上运行,支持设备:RK3568; +2. 本示例为Stage模型,已适配API12版本SDK,SDK版本号5.0.0.71; +3. 本示例需要使用DevEco Studio 版本号(5.0.3.900)版本才可编译运行。 + +### 下载 +如需单独下载本工程,执行如下命令: +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUISample/StateMgmtV2MVVM > .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/ArkUISample/StateMgmtV2MVVM/build-profile.json5 b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/build-profile.json5 index 068fb1d513..71b86b9431 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/build-profile.json5 +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/build-profile.json5 @@ -1,59 +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. - * -*/ - -{ - "app": { - "signingConfigs": [], - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, - "targetSdkVersion": 12, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "targetSdkVersion": 12, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/build-profile.json5 b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/build-profile.json5 index e0c30185be..8aa2bcfce3 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/build-profile.json5 +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/build-profile.json5 @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -{ - "apiType": "stageMode", - "buildOption": { - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/oh-package.json5 b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/oh-package.json5 index 887dfe3d46..f39a70cf78 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/oh-package.json5 +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/oh-package.json5 @@ -1,26 +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": {} -} - +/* + * 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/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/entryability/EntryAbility.ets index ef43aaabee..98e92a1c2a 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/TodoListPage', (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'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/TodoListPage', (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/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/model/TaskListModel.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/model/TaskListModel.ets index 325579b96a..9167605416 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/model/TaskListModel.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/model/TaskListModel.ets @@ -1,42 +1,42 @@ -/* - * 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. - * -*/ - -// src/main/ets/model/TaskListModel.ets - -import { common } from '@kit.AbilityKit'; -import util from '@ohos.util'; -import TaskModel from'./TaskModel'; - -export default class TaskListModel { - public tasks: TaskModel[] = []; - - constructor(tasks: TaskModel[]) { - this.tasks = tasks; - } - - async loadTasks(context: common.UIAbilityContext){ - let getJson = await context.resourceManager.getRawFileContent('defaultTasks.json'); - let textDecoderOptions: util.TextDecoderOptions = { ignoreBOM : true }; - let textDecoder = util.TextDecoder.create('utf-8',textDecoderOptions); - let result = textDecoder.decodeToString(getJson); - this.tasks =JSON.parse(result).map((task: TaskModel)=>{ - let newTask = new TaskModel(); - newTask.taskName = task.taskName; - newTask.isFinish = task.isFinish; - return newTask; - }); - } +/* + * 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. + * +*/ + +// src/main/ets/model/TaskListModel.ets + +import { common } from '@kit.AbilityKit'; +import util from '@ohos.util'; +import TaskModel from'./TaskModel'; + +export default class TaskListModel { + public tasks: TaskModel[] = []; + + constructor(tasks: TaskModel[]) { + this.tasks = tasks; + } + + async loadTasks(context: common.UIAbilityContext){ + let getJson = await context.resourceManager.getRawFileContent('defaultTasks.json'); + let textDecoderOptions: util.TextDecoderOptions = { ignoreBOM : true }; + let textDecoder = util.TextDecoder.create('utf-8',textDecoderOptions); + let result = textDecoder.decodeToString(getJson); + this.tasks =JSON.parse(result).map((task: TaskModel)=>{ + let newTask = new TaskModel(); + newTask.taskName = task.taskName; + newTask.isFinish = task.isFinish; + return newTask; + }); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/model/TaskModel.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/model/TaskModel.ets index 10fe902b6a..4fda48d268 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/model/TaskModel.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/model/TaskModel.ets @@ -1,22 +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. - * -*/ - -// src/main/ets/model/TaskModel.ets - -export default class TaskModel { - public taskName: string = 'Todo'; - public isFinish: boolean = false; +/* + * 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. + * +*/ + +// src/main/ets/model/TaskModel.ets + +export default class TaskModel { + public taskName: string = 'Todo'; + public isFinish: boolean = false; } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/10-Builder.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/10-Builder.ets index 5805f767d5..a02aa9a48f 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/10-Builder.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/10-Builder.ets @@ -1,160 +1,160 @@ -/* - * 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. - * -*/ - -// src/main/ets/pages/10-Builder.ets - -import { AppStorageV2, PersistenceV2, Type } from '@kit.ArkUI'; -import { common, Want } from '@kit.AbilityKit'; -import { Setting } from './SettingPage'; -import util from '@ohos.util'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -@ObservedV2 -class Task { - // 未实现构造函数,因为@Type当前不支持带参数的构造函数 - @Trace public taskName: string = 'Todo'; - @Trace public isFinish: boolean = false; -} - -@Builder function actionButton(text: string|Resource, onClick:() => void) { - Button(text, { buttonStyle: ButtonStyleMode.NORMAL }) - .onClick(onClick) - .margin({ left: 10, right: 10, top: 5, bottom: 5 }) -} - -@ObservedV2 -class TaskList { - // 对于复杂对象需要@Type修饰,确保序列化成功 - @Type(Task) - @Trace public tasks: Task[] = []; - - constructor(tasks: Task[]) { - this.tasks = tasks; - } - - async loadTasks(context: common.UIAbilityContext) { - let getJson = await context.resourceManager.getRawFileContent('defaultTasks.json'); - let textDecoderOptions: util.TextDecoderOptions = { ignoreBOM : true }; - let textDecoder = util.TextDecoder.create('utf-8',textDecoderOptions); - let result = textDecoder.decodeToString(getJson); - this.tasks =JSON.parse(result).map((task: Task)=>{ - let newTask = new Task(); - newTask.taskName = task.taskName; - newTask.isFinish = task.isFinish; - return newTask; - }); - } -} - -@ComponentV2 -struct TaskItem { - @Param task: Task = new Task(); - @Event deleteTask: () => void = () => {}; - @Monitor('task.isFinish') - onTaskFinished(mon: IMonitor) { - hilog.debug(0x0000, 'testTag', '%{public}s', '任务' + this.task.taskName + '的完成状态从' + mon.value()?.before + '变为了' + mon.value()?.now); - } - - build() { - Row() { - Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) - .width(28) - .height(28) - .margin({ left : 15, right : 10 }) - Text(this.task.taskName) - .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) - .fontSize(18) - actionButton($r('app.string.Delete_task'), () => this.deleteTask()) - } - .height('7%') - .width('90%') - .backgroundColor('#90f1f3f5') - .borderRadius(25) - .onClick(() => this.task.isFinish = !this.task.isFinish) - } -} - -@Entry -@ComponentV2 -struct TodoList { - @Local taskList: TaskList = PersistenceV2.connect(TaskList, 'TaskList', () => new TaskList([]))!; - @Local newTaskName: string = ''; - @Local setting: Setting = AppStorageV2.connect(Setting, 'Setting', () => new Setting())!; - private context = getContext(this) as common.UIAbilityContext; - - async aboutToAppear() { - this.taskList = PersistenceV2.connect(TaskList, 'TaskList', () => new TaskList([]))!; - if (this.taskList.tasks.length === 0) { - await this.taskList.loadTasks(this.context); - } - } - - finishAll(ifFinish: boolean) { - for (let task of this.taskList.tasks) { - task.isFinish = ifFinish; - } - } - - @Computed - get tasksUnfinished(): number { - return this.taskList.tasks.filter(task => !task.isFinish).length; - } - - build() { - Column() { - Text($r('app.string.TodoList_title')) - .fontSize(40) - .margin(10) - Text(`${this.context.resourceManager.getStringSync($r('app.string.Unfinish_count').id)}:${this.tasksUnfinished}`) - .margin({ left: 10, bottom: 10 }) - Repeat(this.taskList.tasks.filter(task => this.setting.showCompletedTask || !task.isFinish)) - .each((obj: RepeatItem) => { - TaskItem({ - task: obj.item, - deleteTask: () => this.taskList.tasks.splice(this.taskList.tasks.indexOf(obj.item), 1) - }).margin(5) - }) - Row() { - actionButton($r('app.string.Finish_all_tasks'), (): void => this.finishAll(true)) - actionButton($r('app.string.Unfinish_all_tasks'), (): void => this.finishAll(false)) - actionButton($r('app.string.Setting'), (): void => { - let wantInfo: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.statemgmtv2mvvm', // 替换成AppScope/app.json5里的bundleName - abilityName: 'SettingAbility', - }; - this.context.startAbility(wantInfo); - }) - } - .margin({ top: 10, bottom: 5 }) - Row() { - TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) - .onChange((value) => this.newTaskName = value) - .width('70%') - actionButton('+', (): void => { - let newTask = new Task(); - newTask.taskName = this.newTaskName; - this.taskList.tasks.push(newTask); - this.newTaskName = ''; - }) - } - } - .height('100%') - .width('100%') - .alignItems(HorizontalAlign.Start) - .margin({ left: 15 }) - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +// src/main/ets/pages/10-Builder.ets + +import { AppStorageV2, PersistenceV2, Type } from '@kit.ArkUI'; +import { common, Want } from '@kit.AbilityKit'; +import { Setting } from './SettingPage'; +import util from '@ohos.util'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@ObservedV2 +class Task { + // 未实现构造函数,因为@Type当前不支持带参数的构造函数 + @Trace public taskName: string = 'Todo'; + @Trace public isFinish: boolean = false; +} + +@Builder function actionButton(text: string|Resource, onClick:() => void) { + Button(text, { buttonStyle: ButtonStyleMode.NORMAL }) + .onClick(onClick) + .margin({ left: 10, right: 10, top: 5, bottom: 5 }) +} + +@ObservedV2 +class TaskList { + // 对于复杂对象需要@Type修饰,确保序列化成功 + @Type(Task) + @Trace public tasks: Task[] = []; + + constructor(tasks: Task[]) { + this.tasks = tasks; + } + + async loadTasks(context: common.UIAbilityContext) { + let getJson = await context.resourceManager.getRawFileContent('defaultTasks.json'); + let textDecoderOptions: util.TextDecoderOptions = { ignoreBOM : true }; + let textDecoder = util.TextDecoder.create('utf-8',textDecoderOptions); + let result = textDecoder.decodeToString(getJson); + this.tasks =JSON.parse(result).map((task: Task)=>{ + let newTask = new Task(); + newTask.taskName = task.taskName; + newTask.isFinish = task.isFinish; + return newTask; + }); + } +} + +@ComponentV2 +struct TaskItem { + @Param task: Task = new Task(); + @Event deleteTask: () => void = () => {}; + @Monitor('task.isFinish') + onTaskFinished(mon: IMonitor) { + hilog.debug(0x0000, 'testTag', '%{public}s', '任务' + this.task.taskName + '的完成状态从' + mon.value()?.before + '变为了' + mon.value()?.now); + } + + build() { + Row() { + Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) + .width(28) + .height(28) + .margin({ left : 15, right : 10 }) + Text(this.task.taskName) + .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) + .fontSize(18) + actionButton($r('app.string.Delete_task'), () => this.deleteTask()) + } + .height('7%') + .width('90%') + .backgroundColor('#90f1f3f5') + .borderRadius(25) + .onClick(() => this.task.isFinish = !this.task.isFinish) + } +} + +@Entry +@ComponentV2 +struct TodoList { + @Local taskList: TaskList = PersistenceV2.connect(TaskList, 'TaskList', () => new TaskList([]))!; + @Local newTaskName: string = ''; + @Local setting: Setting = AppStorageV2.connect(Setting, 'Setting', () => new Setting())!; + private context = getContext(this) as common.UIAbilityContext; + + async aboutToAppear() { + this.taskList = PersistenceV2.connect(TaskList, 'TaskList', () => new TaskList([]))!; + if (this.taskList.tasks.length === 0) { + await this.taskList.loadTasks(this.context); + } + } + + finishAll(ifFinish: boolean) { + for (let task of this.taskList.tasks) { + task.isFinish = ifFinish; + } + } + + @Computed + get tasksUnfinished(): number { + return this.taskList.tasks.filter(task => !task.isFinish).length; + } + + build() { + Column() { + Text($r('app.string.TodoList_title')) + .fontSize(40) + .margin(10) + Text(`${this.context.resourceManager.getStringSync($r('app.string.Unfinish_count').id)}:${this.tasksUnfinished}`) + .margin({ left: 10, bottom: 10 }) + Repeat(this.taskList.tasks.filter(task => this.setting.showCompletedTask || !task.isFinish)) + .each((obj: RepeatItem) => { + TaskItem({ + task: obj.item, + deleteTask: () => this.taskList.tasks.splice(this.taskList.tasks.indexOf(obj.item), 1) + }).margin(5) + }) + Row() { + actionButton($r('app.string.Finish_all_tasks'), (): void => this.finishAll(true)) + actionButton($r('app.string.Unfinish_all_tasks'), (): void => this.finishAll(false)) + actionButton($r('app.string.Setting'), (): void => { + let wantInfo: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.statemgmtv2mvvm', // 替换成AppScope/app.json5里的bundleName + abilityName: 'SettingAbility', + }; + this.context.startAbility(wantInfo); + }) + } + .margin({ top: 10, bottom: 5 }) + Row() { + TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) + .onChange((value) => this.newTaskName = value) + .width('70%') + actionButton('+', (): void => { + let newTask = new Task(); + newTask.taskName = this.newTaskName; + this.taskList.tasks.push(newTask); + this.newTaskName = ''; + }) + } + } + .height('100%') + .width('100%') + .alignItems(HorizontalAlign.Start) + .margin({ left: 15 }) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/2-Local.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/2-Local.ets index 6dd42e7a28..485bbd5ef4 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/2-Local.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/2-Local.ets @@ -1,39 +1,39 @@ -/* - * 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. - * -*/ - -// src/main/ets/pages/2-Local.ets - -@Entry -@ComponentV2 -struct TodoList { - @Local isFinish: boolean = false; - - build() { - Column() { - Text($r('app.string.TodoList_title')) - .fontSize(40) - .margin({ bottom: 10 }) - Row() { - Image(this.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) - .width(28) - .height(28) - Text('task1') - .decoration({ type: this.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) - } - .onClick(() => this.isFinish = !this.isFinish) - } - } +/* + * 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. + * +*/ + +// src/main/ets/pages/2-Local.ets + +@Entry +@ComponentV2 +struct TodoList { + @Local isFinish: boolean = false; + + build() { + Column() { + Text($r('app.string.TodoList_title')) + .fontSize(40) + .margin({ bottom: 10 }) + Row() { + Image(this.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) + .width(28) + .height(28) + Text('task1') + .decoration({ type: this.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) + } + .onClick(() => this.isFinish = !this.isFinish) + } + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/3-Param.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/3-Param.ets index ae80b7ce27..c474a162ba 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/3-Param.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/3-Param.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -// src/main/ets/pages/3-Param.ets - -@ComponentV2 -struct TaskItem { - @Param taskName: string = ''; - @Param @Once isFinish: boolean = false; - - build() { - Row() { - Image(this.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) - .width(28) - .height(28) - Text(this.taskName) - .decoration({ type: this.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) - } - .onClick(() => this.isFinish = !this.isFinish) - } -} - -@Entry -@ComponentV2 -struct TodoList { - build() { - Column() { - Text($r('app.string.TodoList_title')) - .fontSize(40) - .margin({ bottom: 10 }) - TaskItem({ taskName: 'Task 1', isFinish: false }) - TaskItem({ taskName: 'Task 2', isFinish: false }) - TaskItem({ taskName: 'Task 3', isFinish: false }) - } - } +/* + * 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. + * +*/ + +// src/main/ets/pages/3-Param.ets + +@ComponentV2 +struct TaskItem { + @Param taskName: string = ''; + @Param @Once isFinish: boolean = false; + + build() { + Row() { + Image(this.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) + .width(28) + .height(28) + Text(this.taskName) + .decoration({ type: this.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) + } + .onClick(() => this.isFinish = !this.isFinish) + } +} + +@Entry +@ComponentV2 +struct TodoList { + build() { + Column() { + Text($r('app.string.TodoList_title')) + .fontSize(40) + .margin({ bottom: 10 }) + TaskItem({ taskName: 'Task 1', isFinish: false }) + TaskItem({ taskName: 'Task 2', isFinish: false }) + TaskItem({ taskName: 'Task 3', isFinish: false }) + } + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/4-Event.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/4-Event.ets index e1a31f5822..7c7659f589 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/4-Event.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/4-Event.ets @@ -1,68 +1,68 @@ -/* - * 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. - * -*/ - -// src/main/ets/pages/4-Event.ets - -@ComponentV2 -struct TaskItem { - @Param taskName: string = ''; - @Param @Once isFinish: boolean = false; - @Event deleteTask: () => void = () => {}; - - build() { - Row() { - Image(this.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) - .width(28) - .height(28) - Text(this.taskName) - .decoration({ type: this.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) - Button($r('app.string.Delete_task')) - .onClick(() => this.deleteTask()) - } - .onClick(() => this.isFinish = !this.isFinish) - } -} - -@Entry -@ComponentV2 -struct TodoList { - @Local tasks: string[] = ['task1','task2','task3']; - @Local newTaskName: string = ''; - build() { - Column() { - Text($r('app.string.TodoList_title')) - .fontSize(40) - .margin({ bottom: 10 }) - ForEach(this.tasks, (task: string) => { - TaskItem({ - taskName: task, - isFinish: false, - deleteTask: () => this.tasks.splice(this.tasks.indexOf(task), 1) - }) - }) - Row() { - TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) - .onChange((value) => this.newTaskName = value) - .width('70%') - Button('+') - .onClick(() => { - this.tasks.push(this.newTaskName); - this.newTaskName = ''; - }) - } - } - } +/* + * 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. + * +*/ + +// src/main/ets/pages/4-Event.ets + +@ComponentV2 +struct TaskItem { + @Param taskName: string = ''; + @Param @Once isFinish: boolean = false; + @Event deleteTask: () => void = () => {}; + + build() { + Row() { + Image(this.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) + .width(28) + .height(28) + Text(this.taskName) + .decoration({ type: this.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) + Button($r('app.string.Delete_task')) + .onClick(() => this.deleteTask()) + } + .onClick(() => this.isFinish = !this.isFinish) + } +} + +@Entry +@ComponentV2 +struct TodoList { + @Local tasks: string[] = ['task1','task2','task3']; + @Local newTaskName: string = ''; + build() { + Column() { + Text($r('app.string.TodoList_title')) + .fontSize(40) + .margin({ bottom: 10 }) + ForEach(this.tasks, (task: string) => { + TaskItem({ + taskName: task, + isFinish: false, + deleteTask: () => this.tasks.splice(this.tasks.indexOf(task), 1) + }) + }) + Row() { + TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) + .onChange((value) => this.newTaskName = value) + .width('70%') + Button('+') + .onClick(() => { + this.tasks.push(this.newTaskName); + this.newTaskName = ''; + }) + } + } + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/5-Repeat.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/5-Repeat.ets index e6b24ff3f2..d082c0b3e3 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/5-Repeat.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/5-Repeat.ets @@ -1,69 +1,69 @@ -/* - * 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. - * -*/ - -// src/main/ets/pages/5-Repeat.ets - -@ComponentV2 -struct TaskItem { - @Param taskName: string = ''; - @Param @Once isFinish: boolean = false; - @Event deleteTask: () => void = () => {}; - - build() { - Row() { - Image(this.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) - .width(28) - .height(28) - Text(this.taskName) - .decoration({ type: this.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) - Button($r('app.string.Delete_task')) - .onClick(() => this.deleteTask()) - } - .onClick(() => this.isFinish = !this.isFinish) - } -} - -@Entry -@ComponentV2 -struct TodoList { - @Local tasks: string[] = ['task1','task2','task3']; - @Local newTaskName: string = ''; - build() { - Column() { - Text($r('app.string.TodoList_title')) - .fontSize(40) - .margin({ bottom: 10 }) - Repeat(this.tasks) - .each((obj: RepeatItem) => { - TaskItem({ - taskName: obj.item, - isFinish: false, - deleteTask: () => this.tasks.splice(this.tasks.indexOf(obj.item), 1) - }) - }) - Row() { - TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) - .onChange((value) => this.newTaskName = value) - .width('70%') - Button('+') - .onClick(() => { - this.tasks.push(this.newTaskName); - this.newTaskName = ''; - }) - } - } - } +/* + * 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. + * +*/ + +// src/main/ets/pages/5-Repeat.ets + +@ComponentV2 +struct TaskItem { + @Param taskName: string = ''; + @Param @Once isFinish: boolean = false; + @Event deleteTask: () => void = () => {}; + + build() { + Row() { + Image(this.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) + .width(28) + .height(28) + Text(this.taskName) + .decoration({ type: this.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) + Button($r('app.string.Delete_task')) + .onClick(() => this.deleteTask()) + } + .onClick(() => this.isFinish = !this.isFinish) + } +} + +@Entry +@ComponentV2 +struct TodoList { + @Local tasks: string[] = ['task1','task2','task3']; + @Local newTaskName: string = ''; + build() { + Column() { + Text($r('app.string.TodoList_title')) + .fontSize(40) + .margin({ bottom: 10 }) + Repeat(this.tasks) + .each((obj: RepeatItem) => { + TaskItem({ + taskName: obj.item, + isFinish: false, + deleteTask: () => this.tasks.splice(this.tasks.indexOf(obj.item), 1) + }) + }) + Row() { + TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) + .onChange((value) => this.newTaskName = value) + .width('70%') + Button('+') + .onClick(() => { + this.tasks.push(this.newTaskName); + this.newTaskName = ''; + }) + } + } + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/6-ObservedV2Trace.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/6-ObservedV2Trace.ets index 24cb0ed44d..5ab649817c 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/6-ObservedV2Trace.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/6-ObservedV2Trace.ets @@ -1,95 +1,95 @@ -/* - * 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. - * -*/ - -// src/main/ets/pages/6-ObservedV2Trace.ets - -@ObservedV2 -class Task { - public taskName: string = ''; - @Trace public isFinish: boolean = false; - - constructor (taskName: string, isFinish: boolean) { - this.taskName = taskName; - this.isFinish = isFinish; - } -} - -@ComponentV2 -struct TaskItem { - @Param task: Task = new Task('', false); - @Event deleteTask: () => void = () => {}; - - build() { - Row() { - Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) - .width(28) - .height(28) - Text(this.task.taskName) - .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) - Button($r('app.string.Delete_task')) - .onClick(() => this.deleteTask()) - } - .onClick(() => this.task.isFinish = !this.task.isFinish) - } -} - -@Entry -@ComponentV2 -struct TodoList { - @Local tasks: Task[] = [ - new Task('task1', false), - new Task('task2', false), - new Task('task3', false), - ]; - @Local newTaskName: string = ''; - - finishAll(ifFinish: boolean) { - for (let task of this.tasks) { - task.isFinish = ifFinish; - } - } - - build() { - Column() { - Text($r('app.string.TodoList_title')) - .fontSize(40) - .margin({ bottom: 10 }) - Repeat(this.tasks) - .each((obj: RepeatItem) => { - TaskItem({ - task: obj.item, - deleteTask: () => this.tasks.splice(this.tasks.indexOf(obj.item), 1) - }) - }) - Row() { - Button($r('app.string.Finish_all_tasks')) - .onClick(() => this.finishAll(true)) - Button($r('app.string.Unfinish_all_tasks')) - .onClick(() => this.finishAll(false)) - } - Row() { - TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) - .onChange((value) => this.newTaskName = value) - .width('70%') - Button('+') - .onClick(() => { - this.tasks.push(new Task(this.newTaskName, false)); - this.newTaskName = ''; - }) - } - } - } +/* + * 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. + * +*/ + +// src/main/ets/pages/6-ObservedV2Trace.ets + +@ObservedV2 +class Task { + public taskName: string = ''; + @Trace public isFinish: boolean = false; + + constructor (taskName: string, isFinish: boolean) { + this.taskName = taskName; + this.isFinish = isFinish; + } +} + +@ComponentV2 +struct TaskItem { + @Param task: Task = new Task('', false); + @Event deleteTask: () => void = () => {}; + + build() { + Row() { + Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) + .width(28) + .height(28) + Text(this.task.taskName) + .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) + Button($r('app.string.Delete_task')) + .onClick(() => this.deleteTask()) + } + .onClick(() => this.task.isFinish = !this.task.isFinish) + } +} + +@Entry +@ComponentV2 +struct TodoList { + @Local tasks: Task[] = [ + new Task('task1', false), + new Task('task2', false), + new Task('task3', false), + ]; + @Local newTaskName: string = ''; + + finishAll(ifFinish: boolean) { + for (let task of this.tasks) { + task.isFinish = ifFinish; + } + } + + build() { + Column() { + Text($r('app.string.TodoList_title')) + .fontSize(40) + .margin({ bottom: 10 }) + Repeat(this.tasks) + .each((obj: RepeatItem) => { + TaskItem({ + task: obj.item, + deleteTask: () => this.tasks.splice(this.tasks.indexOf(obj.item), 1) + }) + }) + Row() { + Button($r('app.string.Finish_all_tasks')) + .onClick(() => this.finishAll(true)) + Button($r('app.string.Unfinish_all_tasks')) + .onClick(() => this.finishAll(false)) + } + Row() { + TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) + .onChange((value) => this.newTaskName = value) + .width('70%') + Button('+') + .onClick(() => { + this.tasks.push(new Task(this.newTaskName, false)); + this.newTaskName = ''; + }) + } + } + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/7-MonitorComputed.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/7-MonitorComputed.ets index 5715069a8e..728de6be3c 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/7-MonitorComputed.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/7-MonitorComputed.ets @@ -1,106 +1,106 @@ -/* - * 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'; - -// src/main/ets/pages/7-MonitorComputed.ets - -@ObservedV2 -class Task { - public taskName: string = ''; - @Trace public isFinish: boolean = false; - - constructor (taskName: string, isFinish: boolean) { - this.taskName = taskName; - this.isFinish = isFinish; - } -} - -@ComponentV2 -struct TaskItem { - @Param task: Task = new Task('', false); - @Event deleteTask: () => void = () => {}; - @Monitor('task.isFinish') - onTaskFinished(mon: IMonitor) { - hilog.debug(0x0000, 'testTag', '%{public}s', '任务' + this.task.taskName + '的完成状态从' + mon.value()?.before + '变为了' + mon.value()?.now); - } - - build() { - Row() { - Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) - .width(28) - .height(28) - Text(this.task.taskName) - .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) - Button($r('app.string.Delete_task')) - .onClick(() => this.deleteTask()) - } - .onClick(() => this.task.isFinish = !this.task.isFinish) - } -} - -@Entry -@ComponentV2 -struct TodoList { - @Local tasks: Task[] = [ - new Task('task1', false), - new Task('task2', false), - new Task('task3', false), - ]; - @Local newTaskName: string = ''; - - finishAll(ifFinish: boolean) { - for (let task of this.tasks) { - task.isFinish = ifFinish; - } - } - - @Computed - get tasksUnfinished(): number { - return this.tasks.filter(task => !task.isFinish).length; - } - - build() { - Column() { - Text($r('app.string.TodoList_title')) - .fontSize(40) - .margin({ bottom: 10 }) - Text(`${getContext(this).resourceManager.getStringSync($r('app.string.Unfinish_count').id)}:${this.tasksUnfinished}`) - Repeat(this.tasks) - .each((obj: RepeatItem) => { - TaskItem({ - task: obj.item, - deleteTask: () => this.tasks.splice(this.tasks.indexOf(obj.item), 1) - }) - }) - Row() { - Button($r('app.string.Finish_all_tasks')) - .onClick(() => this.finishAll(true)) - Button($r('app.string.Unfinish_all_tasks')) - .onClick(() => this.finishAll(false)) - } - Row() { - TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) - .onChange((value) => this.newTaskName = value) - .width('70%') - Button('+') - .onClick(() => { - this.tasks.push(new Task(this.newTaskName, false)); - this.newTaskName = ''; - }) - } - } - } +/* + * 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'; + +// src/main/ets/pages/7-MonitorComputed.ets + +@ObservedV2 +class Task { + public taskName: string = ''; + @Trace public isFinish: boolean = false; + + constructor (taskName: string, isFinish: boolean) { + this.taskName = taskName; + this.isFinish = isFinish; + } +} + +@ComponentV2 +struct TaskItem { + @Param task: Task = new Task('', false); + @Event deleteTask: () => void = () => {}; + @Monitor('task.isFinish') + onTaskFinished(mon: IMonitor) { + hilog.debug(0x0000, 'testTag', '%{public}s', '任务' + this.task.taskName + '的完成状态从' + mon.value()?.before + '变为了' + mon.value()?.now); + } + + build() { + Row() { + Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) + .width(28) + .height(28) + Text(this.task.taskName) + .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) + Button($r('app.string.Delete_task')) + .onClick(() => this.deleteTask()) + } + .onClick(() => this.task.isFinish = !this.task.isFinish) + } +} + +@Entry +@ComponentV2 +struct TodoList { + @Local tasks: Task[] = [ + new Task('task1', false), + new Task('task2', false), + new Task('task3', false), + ]; + @Local newTaskName: string = ''; + + finishAll(ifFinish: boolean) { + for (let task of this.tasks) { + task.isFinish = ifFinish; + } + } + + @Computed + get tasksUnfinished(): number { + return this.tasks.filter(task => !task.isFinish).length; + } + + build() { + Column() { + Text($r('app.string.TodoList_title')) + .fontSize(40) + .margin({ bottom: 10 }) + Text(`${getContext(this).resourceManager.getStringSync($r('app.string.Unfinish_count').id)}:${this.tasksUnfinished}`) + Repeat(this.tasks) + .each((obj: RepeatItem) => { + TaskItem({ + task: obj.item, + deleteTask: () => this.tasks.splice(this.tasks.indexOf(obj.item), 1) + }) + }) + Row() { + Button($r('app.string.Finish_all_tasks')) + .onClick(() => this.finishAll(true)) + Button($r('app.string.Unfinish_all_tasks')) + .onClick(() => this.finishAll(false)) + } + Row() { + TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) + .onChange((value) => this.newTaskName = value) + .width('70%') + Button('+') + .onClick(() => { + this.tasks.push(new Task(this.newTaskName, false)); + this.newTaskName = ''; + }) + } + } + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/8-AppStorageV2.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/8-AppStorageV2.ets index 6fba3c67c1..1ab1e0441d 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/8-AppStorageV2.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/8-AppStorageV2.ets @@ -1,121 +1,121 @@ -/* - * 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. - * -*/ - -// src/main/ets/pages/8-AppStorageV2.ets - -import { AppStorageV2 } from '@kit.ArkUI'; -import { common, Want } from '@kit.AbilityKit'; -import { Setting } from './SettingPage'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -@ObservedV2 -class Task { - public taskName: string = ''; - @Trace public isFinish: boolean = false; - - constructor (taskName: string, isFinish: boolean) { - this.taskName = taskName; - this.isFinish = isFinish; - } -} - -@ComponentV2 -struct TaskItem { - @Param task: Task = new Task('', false); - @Event deleteTask: () => void = () => {}; - @Monitor('task.isFinish') - onTaskFinished(mon: IMonitor) { - hilog.debug(0x0000, 'testTag', '%{public}s', '任务' + this.task.taskName + '的完成状态从' + mon.value()?.before + '变为了' + mon.value()?.now); - } - - build() { - Row() { - Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) - .width(28) - .height(28) - Text(this.task.taskName) - .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) - Button($r('app.string.Delete_task')) - .onClick(() => this.deleteTask()) - } - .onClick(() => this.task.isFinish = !this.task.isFinish) - } -} - -@Entry -@ComponentV2 -struct TodoList { - @Local tasks: Task[] = [ - new Task('task1', false), - new Task('task2', false), - new Task('task3', false), - ]; - @Local newTaskName: string = ''; - @Local setting: Setting = AppStorageV2.connect(Setting, 'Setting', () => new Setting())!; - private context = getContext(this) as common.UIAbilityContext; - - finishAll(ifFinish: boolean) { - for (let task of this.tasks) { - task.isFinish = ifFinish; - } - } - - @Computed - get tasksUnfinished(): number { - return this.tasks.filter(task => !task.isFinish).length; - } - - build() { - Column() { - Text($r('app.string.TodoList_title')) - .fontSize(40) - .margin({ bottom: 10 }) - Text(`${this.context.resourceManager.getStringSync($r('app.string.Unfinish_count').id)}:${this.tasksUnfinished}`) - Repeat(this.tasks.filter(task => this.setting.showCompletedTask || !task.isFinish)) - .each((obj: RepeatItem) => { - TaskItem({ - task: obj.item, - deleteTask: () => this.tasks.splice(this.tasks.indexOf(obj.item), 1) - }) - }) - Row() { - Button($r('app.string.Finish_all_tasks')) - .onClick(() => this.finishAll(true)) - Button($r('app.string.Unfinish_all_tasks')) - .onClick(() => this.finishAll(false)) - Button($r('app.string.Setting')) - .onClick(() => { - let wantInfo: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.statemgmtv2mvvm', // 替换成AppScope/app.json5里的bundleName - abilityName: 'SettingAbility', - }; - this.context.startAbility(wantInfo); - }) - } - Row() { - TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) - .onChange((value) => this.newTaskName = value) - .width('70%') - Button('+') - .onClick(() => { - this.tasks.push(new Task(this.newTaskName, false)); - this.newTaskName = ''; - }) - } - } - } +/* + * 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. + * +*/ + +// src/main/ets/pages/8-AppStorageV2.ets + +import { AppStorageV2 } from '@kit.ArkUI'; +import { common, Want } from '@kit.AbilityKit'; +import { Setting } from './SettingPage'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@ObservedV2 +class Task { + public taskName: string = ''; + @Trace public isFinish: boolean = false; + + constructor (taskName: string, isFinish: boolean) { + this.taskName = taskName; + this.isFinish = isFinish; + } +} + +@ComponentV2 +struct TaskItem { + @Param task: Task = new Task('', false); + @Event deleteTask: () => void = () => {}; + @Monitor('task.isFinish') + onTaskFinished(mon: IMonitor) { + hilog.debug(0x0000, 'testTag', '%{public}s', '任务' + this.task.taskName + '的完成状态从' + mon.value()?.before + '变为了' + mon.value()?.now); + } + + build() { + Row() { + Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) + .width(28) + .height(28) + Text(this.task.taskName) + .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) + Button($r('app.string.Delete_task')) + .onClick(() => this.deleteTask()) + } + .onClick(() => this.task.isFinish = !this.task.isFinish) + } +} + +@Entry +@ComponentV2 +struct TodoList { + @Local tasks: Task[] = [ + new Task('task1', false), + new Task('task2', false), + new Task('task3', false), + ]; + @Local newTaskName: string = ''; + @Local setting: Setting = AppStorageV2.connect(Setting, 'Setting', () => new Setting())!; + private context = getContext(this) as common.UIAbilityContext; + + finishAll(ifFinish: boolean) { + for (let task of this.tasks) { + task.isFinish = ifFinish; + } + } + + @Computed + get tasksUnfinished(): number { + return this.tasks.filter(task => !task.isFinish).length; + } + + build() { + Column() { + Text($r('app.string.TodoList_title')) + .fontSize(40) + .margin({ bottom: 10 }) + Text(`${this.context.resourceManager.getStringSync($r('app.string.Unfinish_count').id)}:${this.tasksUnfinished}`) + Repeat(this.tasks.filter(task => this.setting.showCompletedTask || !task.isFinish)) + .each((obj: RepeatItem) => { + TaskItem({ + task: obj.item, + deleteTask: () => this.tasks.splice(this.tasks.indexOf(obj.item), 1) + }) + }) + Row() { + Button($r('app.string.Finish_all_tasks')) + .onClick(() => this.finishAll(true)) + Button($r('app.string.Unfinish_all_tasks')) + .onClick(() => this.finishAll(false)) + Button($r('app.string.Setting')) + .onClick(() => { + let wantInfo: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.statemgmtv2mvvm', // 替换成AppScope/app.json5里的bundleName + abilityName: 'SettingAbility', + }; + this.context.startAbility(wantInfo); + }) + } + Row() { + TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) + .onChange((value) => this.newTaskName = value) + .width('70%') + Button('+') + .onClick(() => { + this.tasks.push(new Task(this.newTaskName, false)); + this.newTaskName = ''; + }) + } + } + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/9-PersistenceV2.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/9-PersistenceV2.ets index 41d716edc5..ec18b61f87 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/9-PersistenceV2.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/9-PersistenceV2.ets @@ -1,147 +1,147 @@ -/* - * 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. - * -*/ - -// src/main/ets/pages/9-PersistenceV2.ets - -import { AppStorageV2, PersistenceV2, Type } from '@kit.ArkUI'; -import { common, Want } from '@kit.AbilityKit'; -import { Setting } from './SettingPage'; -import util from '@ohos.util'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -@ObservedV2 -class Task { - // 未实现构造函数,因为@Type当前不支持带参数的构造函数 - @Trace public taskName: string = 'Todo'; - @Trace public isFinish: boolean = false; -} - -@ObservedV2 -class TaskList { - // 对于复杂对象需要@Type修饰,确保序列化成功 - @Type(Task) - @Trace public tasks: Task[] = []; - - constructor(tasks: Task[]) { - this.tasks = tasks; - } - - async loadTasks(context: common.UIAbilityContext) { - let getJson = await context.resourceManager.getRawFileContent('defaultTasks.json'); - let textDecoderOptions: util.TextDecoderOptions = { ignoreBOM : true }; - let textDecoder = util.TextDecoder.create('utf-8',textDecoderOptions); - let result = textDecoder.decodeToString(getJson); - this.tasks =JSON.parse(result).map((task: Task)=>{ - let newTask = new Task(); - newTask.taskName = task.taskName; - newTask.isFinish = task.isFinish; - return newTask; - }); - } -} - -@ComponentV2 -struct TaskItem { - @Param task: Task = new Task(); - @Event deleteTask: () => void = () => {}; - @Monitor('task.isFinish') - onTaskFinished(mon: IMonitor) { - hilog.debug(0x0000, 'testTag', '%{public}s', '任务' + this.task.taskName + '的完成状态从' + mon.value()?.before + '变为了' + mon.value()?.now); - } - - build() { - Row() { - Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) - .width(28) - .height(28) - Text(this.task.taskName) - .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) - Button($r('app.string.Delete_task')) - .onClick(() => this.deleteTask()) - } - .onClick(() => this.task.isFinish = !this.task.isFinish) - } -} - -@Entry -@ComponentV2 -struct TodoList { - @Local taskList: TaskList = PersistenceV2.connect(TaskList, 'TaskList', () => new TaskList([]))!; - @Local newTaskName: string = ''; - @Local setting: Setting = AppStorageV2.connect(Setting, 'Setting', () => new Setting())!; - private context = getContext(this) as common.UIAbilityContext; - - async aboutToAppear() { - this.taskList = PersistenceV2.connect(TaskList, 'TaskList', () => new TaskList([]))!; - if (this.taskList.tasks.length === 0) { - await this.taskList.loadTasks(this.context); - } - } - - finishAll(ifFinish: boolean) { - for (let task of this.taskList.tasks) { - task.isFinish = ifFinish; - } - } - - @Computed - get tasksUnfinished(): number { - return this.taskList.tasks.filter(task => !task.isFinish).length; - } - - build() { - Column() { - Text($r('app.string.TodoList_title')) - .fontSize(40) - .margin({ bottom: 10 }) - Text(`${this.context.resourceManager.getStringSync($r('app.string.Unfinish_count').id)}:${this.tasksUnfinished}`) - Repeat(this.taskList.tasks.filter(task => this.setting.showCompletedTask || !task.isFinish)) - .each((obj: RepeatItem) => { - TaskItem({ - task: obj.item, - deleteTask: () => this.taskList.tasks.splice(this.taskList.tasks.indexOf(obj.item), 1) - }) - }) - Row() { - Button($r('app.string.Finish_all_tasks')) - .onClick(() => this.finishAll(true)) - Button($r('app.string.Unfinish_all_tasks')) - .onClick(() => this.finishAll(false)) - Button($r('app.string.Setting')) - .onClick(() => { - let wantInfo: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.statemgmtv2mvvm', // 替换成AppScope/app.json5里的bundleName - abilityName: 'SettingAbility', - }; - this.context.startAbility(wantInfo); - }) - } - Row() { - TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) - .onChange((value) => this.newTaskName = value) - .width('70%') - Button('+') - .onClick(() => { - let newTask = new Task(); - newTask.taskName = this.newTaskName; - this.taskList.tasks.push(newTask); - this.newTaskName = ''; - }) - } - } - } +/* + * 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. + * +*/ + +// src/main/ets/pages/9-PersistenceV2.ets + +import { AppStorageV2, PersistenceV2, Type } from '@kit.ArkUI'; +import { common, Want } from '@kit.AbilityKit'; +import { Setting } from './SettingPage'; +import util from '@ohos.util'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@ObservedV2 +class Task { + // 未实现构造函数,因为@Type当前不支持带参数的构造函数 + @Trace public taskName: string = 'Todo'; + @Trace public isFinish: boolean = false; +} + +@ObservedV2 +class TaskList { + // 对于复杂对象需要@Type修饰,确保序列化成功 + @Type(Task) + @Trace public tasks: Task[] = []; + + constructor(tasks: Task[]) { + this.tasks = tasks; + } + + async loadTasks(context: common.UIAbilityContext) { + let getJson = await context.resourceManager.getRawFileContent('defaultTasks.json'); + let textDecoderOptions: util.TextDecoderOptions = { ignoreBOM : true }; + let textDecoder = util.TextDecoder.create('utf-8',textDecoderOptions); + let result = textDecoder.decodeToString(getJson); + this.tasks =JSON.parse(result).map((task: Task)=>{ + let newTask = new Task(); + newTask.taskName = task.taskName; + newTask.isFinish = task.isFinish; + return newTask; + }); + } +} + +@ComponentV2 +struct TaskItem { + @Param task: Task = new Task(); + @Event deleteTask: () => void = () => {}; + @Monitor('task.isFinish') + onTaskFinished(mon: IMonitor) { + hilog.debug(0x0000, 'testTag', '%{public}s', '任务' + this.task.taskName + '的完成状态从' + mon.value()?.before + '变为了' + mon.value()?.now); + } + + build() { + Row() { + Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) + .width(28) + .height(28) + Text(this.task.taskName) + .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) + Button($r('app.string.Delete_task')) + .onClick(() => this.deleteTask()) + } + .onClick(() => this.task.isFinish = !this.task.isFinish) + } +} + +@Entry +@ComponentV2 +struct TodoList { + @Local taskList: TaskList = PersistenceV2.connect(TaskList, 'TaskList', () => new TaskList([]))!; + @Local newTaskName: string = ''; + @Local setting: Setting = AppStorageV2.connect(Setting, 'Setting', () => new Setting())!; + private context = getContext(this) as common.UIAbilityContext; + + async aboutToAppear() { + this.taskList = PersistenceV2.connect(TaskList, 'TaskList', () => new TaskList([]))!; + if (this.taskList.tasks.length === 0) { + await this.taskList.loadTasks(this.context); + } + } + + finishAll(ifFinish: boolean) { + for (let task of this.taskList.tasks) { + task.isFinish = ifFinish; + } + } + + @Computed + get tasksUnfinished(): number { + return this.taskList.tasks.filter(task => !task.isFinish).length; + } + + build() { + Column() { + Text($r('app.string.TodoList_title')) + .fontSize(40) + .margin({ bottom: 10 }) + Text(`${this.context.resourceManager.getStringSync($r('app.string.Unfinish_count').id)}:${this.tasksUnfinished}`) + Repeat(this.taskList.tasks.filter(task => this.setting.showCompletedTask || !task.isFinish)) + .each((obj: RepeatItem) => { + TaskItem({ + task: obj.item, + deleteTask: () => this.taskList.tasks.splice(this.taskList.tasks.indexOf(obj.item), 1) + }) + }) + Row() { + Button($r('app.string.Finish_all_tasks')) + .onClick(() => this.finishAll(true)) + Button($r('app.string.Unfinish_all_tasks')) + .onClick(() => this.finishAll(false)) + Button($r('app.string.Setting')) + .onClick(() => { + let wantInfo: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.statemgmtv2mvvm', // 替换成AppScope/app.json5里的bundleName + abilityName: 'SettingAbility', + }; + this.context.startAbility(wantInfo); + }) + } + Row() { + TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) + .onChange((value) => this.newTaskName = value) + .width('70%') + Button('+') + .onClick(() => { + let newTask = new Task(); + newTask.taskName = this.newTaskName; + this.taskList.tasks.push(newTask); + this.newTaskName = ''; + }) + } + } + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/SettingPage.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/SettingPage.ets index a5b2227f78..e427401259 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/SettingPage.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/SettingPage.ets @@ -1,51 +1,51 @@ -/* - * 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. - * -*/ - -// src/main/ets/pages/SettingPage.ets - -import { AppStorageV2 } from '@kit.ArkUI'; -import { common } from '@kit.AbilityKit'; - -@ObservedV2 -export class Setting { - @Trace public showCompletedTask: boolean = true; -} - -@Entry -@ComponentV2 -struct SettingPage { - @Local setting: Setting = AppStorageV2.connect(Setting, 'Setting', () => new Setting())!; - private context = getContext(this) as common.UIAbilityContext; - - build(){ - Column(){ - Text($r('app.string.Setting')) - .fontSize(40) - .margin({ bottom: 10 }) - Row() { - Text($r('app.string.Show_finished_tasks')) - Toggle({ type: ToggleType.Switch, isOn:this.setting.showCompletedTask }) - .onChange((isOn) => { - this.setting.showCompletedTask = isOn; - }) - } - Button($r('app.string.Back')) - .onClick(()=>this.context.terminateSelf()) - .margin({ top: 10 }) - } - .alignItems(HorizontalAlign.Start) - } +/* + * 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. + * +*/ + +// src/main/ets/pages/SettingPage.ets + +import { AppStorageV2 } from '@kit.ArkUI'; +import { common } from '@kit.AbilityKit'; + +@ObservedV2 +export class Setting { + @Trace public showCompletedTask: boolean = true; +} + +@Entry +@ComponentV2 +struct SettingPage { + @Local setting: Setting = AppStorageV2.connect(Setting, 'Setting', () => new Setting())!; + private context = getContext(this) as common.UIAbilityContext; + + build(){ + Column(){ + Text($r('app.string.Setting')) + .fontSize(40) + .margin({ bottom: 10 }) + Row() { + Text($r('app.string.Show_finished_tasks')) + Toggle({ type: ToggleType.Switch, isOn:this.setting.showCompletedTask }) + .onChange((isOn) => { + this.setting.showCompletedTask = isOn; + }) + } + Button($r('app.string.Back')) + .onClick(()=>this.context.terminateSelf()) + .margin({ top: 10 }) + } + .alignItems(HorizontalAlign.Start) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/TodoListPage.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/TodoListPage.ets index 3b2e89ffc8..5515ae13b3 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/TodoListPage.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/pages/TodoListPage.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -// src/main/ets/pages/TodoListPage.ets - -import TaskListViewModel from '../viewmodel/TaskListViewModel'; -import { common } from '@kit.AbilityKit'; -import { AppStorageV2, PersistenceV2 } from '@kit.ArkUI'; -import { Setting } from '../pages/SettingPage'; -import TitleView from '../view/TitleView'; -import ListView from '../view/ListView'; -import BottomView from '../view/BottomView'; - -@Entry -@ComponentV2 -struct TodoList { - @Local taskList: TaskListViewModel = PersistenceV2.connect(TaskListViewModel, 'TaskList', () => new TaskListViewModel())!; - @Local setting: Setting = AppStorageV2.connect(Setting, 'Setting', () => new Setting())!; - private context = getContext(this) as common.UIAbilityContext; - - async aboutToAppear() { - this.taskList = PersistenceV2.connect(TaskListViewModel, 'TaskList', () => new TaskListViewModel())!; - if (this.taskList.tasks.length === 0) { - await this.taskList.loadTasks(this.context); - } - } - - @Computed - get tasksUnfinished(): number { - return this.taskList.tasks.filter(task => !task.isFinish).length; - } - - build() { - Column() { - TitleView({ tasksUnfinished: this.tasksUnfinished }) - ListView({ taskList: this.taskList, setting: this.setting }); - BottomView({ taskList: this.taskList }); - } - .height('100%') - .width('100%') - .alignItems(HorizontalAlign.Start) - .margin({ left: 15 }) - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +// src/main/ets/pages/TodoListPage.ets + +import TaskListViewModel from '../viewmodel/TaskListViewModel'; +import { common } from '@kit.AbilityKit'; +import { AppStorageV2, PersistenceV2 } from '@kit.ArkUI'; +import { Setting } from '../pages/SettingPage'; +import TitleView from '../view/TitleView'; +import ListView from '../view/ListView'; +import BottomView from '../view/BottomView'; + +@Entry +@ComponentV2 +struct TodoList { + @Local taskList: TaskListViewModel = PersistenceV2.connect(TaskListViewModel, 'TaskList', () => new TaskListViewModel())!; + @Local setting: Setting = AppStorageV2.connect(Setting, 'Setting', () => new Setting())!; + private context = getContext(this) as common.UIAbilityContext; + + async aboutToAppear() { + this.taskList = PersistenceV2.connect(TaskListViewModel, 'TaskList', () => new TaskListViewModel())!; + if (this.taskList.tasks.length === 0) { + await this.taskList.loadTasks(this.context); + } + } + + @Computed + get tasksUnfinished(): number { + return this.taskList.tasks.filter(task => !task.isFinish).length; + } + + build() { + Column() { + TitleView({ tasksUnfinished: this.tasksUnfinished }) + ListView({ taskList: this.taskList, setting: this.setting }); + BottomView({ taskList: this.taskList }); + } + .height('100%') + .width('100%') + .alignItems(HorizontalAlign.Start) + .margin({ left: 15 }) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/settingability/SettingAbility.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/settingability/SettingAbility.ets index dc977a8e36..6461ffff9f 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/settingability/SettingAbility.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/settingability/SettingAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class SettingAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/SettingPage', (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'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class SettingAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/SettingPage', (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/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/BottomView.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/BottomView.ets index 5a67dcb2aa..a5f85fd494 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/BottomView.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/BottomView.ets @@ -1,63 +1,63 @@ -/* - * 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. - * -*/ - -// src/main/ets/view/BottomView.ets - -import { common, Want } from '@kit.AbilityKit'; -import TaskViewModel from '../viewmodel/TaskViewModel'; -import TaskListViewModel from '../viewmodel/TaskListViewModel'; - -@Builder export function actionButton(text: string|Resource, onClick:() => void) { - Button(text, { buttonStyle: ButtonStyleMode.NORMAL }) - .onClick(onClick) - .margin({ left: 10, right: 10, top: 5, bottom: 5 }) -} - -@ComponentV2 -export default struct BottomView { - @Param taskList: TaskListViewModel = new TaskListViewModel(); - @Local newTaskName: string = ''; - private context = getContext() as common.UIAbilityContext; - - build() { - Column() { - Row() { - actionButton($r('app.string.Finish_all_tasks'), (): void => this.taskList.finishAll(true)) - actionButton($r('app.string.Unfinish_all_tasks'), (): void => this.taskList.finishAll(false)) - actionButton($r('app.string.Setting'), (): void => { - let wantInfo: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: 'com.samples.statemgmtv2mvvm', // 替换成AppScope/app.json5里的bundleName - abilityName: 'SettingAbility', - }; - this.context.startAbility(wantInfo); - }) - } - .margin({ top: 10, bottom: 5 }) - Row() { - TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) - .onChange((value) => this.newTaskName = value) - .width('70%') - actionButton('+', (): void => { - let newTask = new TaskViewModel(); - newTask.taskName = this.newTaskName; - this.taskList.addTask(newTask); - this.newTaskName = ''; - }) - } - } - } +/* + * 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. + * +*/ + +// src/main/ets/view/BottomView.ets + +import { common, Want } from '@kit.AbilityKit'; +import TaskViewModel from '../viewmodel/TaskViewModel'; +import TaskListViewModel from '../viewmodel/TaskListViewModel'; + +@Builder export function actionButton(text: string|Resource, onClick:() => void) { + Button(text, { buttonStyle: ButtonStyleMode.NORMAL }) + .onClick(onClick) + .margin({ left: 10, right: 10, top: 5, bottom: 5 }) +} + +@ComponentV2 +export default struct BottomView { + @Param taskList: TaskListViewModel = new TaskListViewModel(); + @Local newTaskName: string = ''; + private context = getContext() as common.UIAbilityContext; + + build() { + Column() { + Row() { + actionButton($r('app.string.Finish_all_tasks'), (): void => this.taskList.finishAll(true)) + actionButton($r('app.string.Unfinish_all_tasks'), (): void => this.taskList.finishAll(false)) + actionButton($r('app.string.Setting'), (): void => { + let wantInfo: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.samples.statemgmtv2mvvm', // 替换成AppScope/app.json5里的bundleName + abilityName: 'SettingAbility', + }; + this.context.startAbility(wantInfo); + }) + } + .margin({ top: 10, bottom: 5 }) + Row() { + TextInput({ placeholder: $r('app.string.Add_new_task'), text: this.newTaskName }) + .onChange((value) => this.newTaskName = value) + .width('70%') + actionButton('+', (): void => { + let newTask = new TaskViewModel(); + newTask.taskName = this.newTaskName; + this.taskList.addTask(newTask); + this.newTaskName = ''; + }) + } + } + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/ListView.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/ListView.ets index 1410409257..2807f2af8f 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/ListView.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/ListView.ets @@ -1,67 +1,67 @@ -/* - * 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. - * -*/ - -// src/main/ets/view/ListView.ets - -import TaskViewModel from '../viewmodel/TaskViewModel'; -import TaskListViewModel from '../viewmodel/TaskListViewModel'; -import { Setting } from '../pages/SettingPage'; -import { actionButton } from './BottomView'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -@ComponentV2 -struct TaskItem { - @Param task: TaskViewModel = new TaskViewModel(); - @Event deleteTask: () => void = () => {}; - @Monitor('task.isFinish') - onTaskFinished(mon: IMonitor) { - hilog.debug(0x0000, 'testTag', '%{public}s', '任务' + this.task.taskName + '的完成状态从' + mon.value()?.before + '变为了' + mon.value()?.now); - } - - build() { - Row() { - Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) - .width(28) - .height(28) - .margin({ left: 15, right: 10 }) - Text(this.task.taskName) - .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) - .fontSize(18) - actionButton($r('app.string.Delete_task'), () => this.deleteTask()); - } - .height('7%') - .width('90%') - .backgroundColor('#90f1f3f5') - .borderRadius(25) - .onClick(() => this.task.updateIsFinish()) - } -} - -@ComponentV2 -export default struct ListView { - @Param taskList: TaskListViewModel = new TaskListViewModel(); - @Param setting: Setting = new Setting(); - - build() { - Repeat(this.taskList.tasks.filter(task => this.setting.showCompletedTask || !task.isFinish)) - .each((obj: RepeatItem) => { - TaskItem({ - task: obj.item, - deleteTask: () => this.taskList.removeTask(obj.item) - }).margin(5) - }) - } +/* + * 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. + * +*/ + +// src/main/ets/view/ListView.ets + +import TaskViewModel from '../viewmodel/TaskViewModel'; +import TaskListViewModel from '../viewmodel/TaskListViewModel'; +import { Setting } from '../pages/SettingPage'; +import { actionButton } from './BottomView'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@ComponentV2 +struct TaskItem { + @Param task: TaskViewModel = new TaskViewModel(); + @Event deleteTask: () => void = () => {}; + @Monitor('task.isFinish') + onTaskFinished(mon: IMonitor) { + hilog.debug(0x0000, 'testTag', '%{public}s', '任务' + this.task.taskName + '的完成状态从' + mon.value()?.before + '变为了' + mon.value()?.now); + } + + build() { + Row() { + Image(this.task.isFinish ? $r('app.media.finished') : $r('app.media.unfinished')) + .width(28) + .height(28) + .margin({ left: 15, right: 10 }) + Text(this.task.taskName) + .decoration({ type: this.task.isFinish ? TextDecorationType.LineThrough : TextDecorationType.None }) + .fontSize(18) + actionButton($r('app.string.Delete_task'), () => this.deleteTask()); + } + .height('7%') + .width('90%') + .backgroundColor('#90f1f3f5') + .borderRadius(25) + .onClick(() => this.task.updateIsFinish()) + } +} + +@ComponentV2 +export default struct ListView { + @Param taskList: TaskListViewModel = new TaskListViewModel(); + @Param setting: Setting = new Setting(); + + build() { + Repeat(this.taskList.tasks.filter(task => this.setting.showCompletedTask || !task.isFinish)) + .each((obj: RepeatItem) => { + TaskItem({ + task: obj.item, + deleteTask: () => this.taskList.removeTask(obj.item) + }).margin(5) + }) + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/TitleView.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/TitleView.ets index 66fe89fd9c..b72f0c7a2a 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/TitleView.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/view/TitleView.ets @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -// src/main/ets/view/TitleView.ets - -@ComponentV2 -export default struct TitleView { - @Param tasksUnfinished: number = 0; - - build() { - Column() { - Text($r('app.string.TodoList_title')) - .fontSize(40) - .margin(10) - Text(`${getContext(this).resourceManager.getStringSync($r('app.string.Unfinish_count').id)}:${this.tasksUnfinished}`) - .margin({ left: 10, bottom: 10 }) - } - } +/* + * 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. + * +*/ + +// src/main/ets/view/TitleView.ets + +@ComponentV2 +export default struct TitleView { + @Param tasksUnfinished: number = 0; + + build() { + Column() { + Text($r('app.string.TodoList_title')) + .fontSize(40) + .margin(10) + Text(`${getContext(this).resourceManager.getStringSync($r('app.string.Unfinish_count').id)}:${this.tasksUnfinished}`) + .margin({ left: 10, bottom: 10 }) + } + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/viewmodel/TaskListViewModel.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/viewmodel/TaskListViewModel.ets index acf454e0d2..f0fe8481ca 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/viewmodel/TaskListViewModel.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/viewmodel/TaskListViewModel.ets @@ -1,52 +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. - * -*/ - -// src/main/ets/viewmodel/TaskListViewModel.ets - -import { common } from '@kit.AbilityKit'; -import { Type } from '@kit.ArkUI'; -import TaskListModel from '../model/TaskListModel'; -import TaskViewModel from'./TaskViewModel'; - -@ObservedV2 -export default class TaskListViewModel { - @Type(TaskViewModel) - @Trace public tasks: TaskViewModel[] = []; - - async loadTasks(context: common.UIAbilityContext) { - let taskList = new TaskListModel([]); - await taskList.loadTasks(context); - for(let task of taskList.tasks){ - let taskViewModel = new TaskViewModel(); - taskViewModel.updateTask(task); - this.tasks.push(taskViewModel); - } - } - - finishAll(ifFinish: boolean): void { - for(let task of this.tasks){ - task.isFinish = ifFinish; - } - } - - addTask(newTask: TaskViewModel): void { - this.tasks.push(newTask); - } - - removeTask(removedTask: TaskViewModel): void { - this.tasks.splice(this.tasks.indexOf(removedTask), 1); - } +/* + * 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. + * +*/ + +// src/main/ets/viewmodel/TaskListViewModel.ets + +import { common } from '@kit.AbilityKit'; +import { Type } from '@kit.ArkUI'; +import TaskListModel from '../model/TaskListModel'; +import TaskViewModel from'./TaskViewModel'; + +@ObservedV2 +export default class TaskListViewModel { + @Type(TaskViewModel) + @Trace public tasks: TaskViewModel[] = []; + + async loadTasks(context: common.UIAbilityContext) { + let taskList = new TaskListModel([]); + await taskList.loadTasks(context); + for(let task of taskList.tasks){ + let taskViewModel = new TaskViewModel(); + taskViewModel.updateTask(task); + this.tasks.push(taskViewModel); + } + } + + finishAll(ifFinish: boolean): void { + for(let task of this.tasks){ + task.isFinish = ifFinish; + } + } + + addTask(newTask: TaskViewModel): void { + this.tasks.push(newTask); + } + + removeTask(removedTask: TaskViewModel): void { + this.tasks.splice(this.tasks.indexOf(removedTask), 1); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/viewmodel/TaskViewModel.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/viewmodel/TaskViewModel.ets index 16bab0db91..b412dcc9c1 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/viewmodel/TaskViewModel.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/ets/viewmodel/TaskViewModel.ets @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -// src/main/ets/viewmodel/TaskViewModel.ets - -import TaskModel from '../model/TaskModel'; - -@ObservedV2 -export default class TaskViewModel { - @Trace public taskName: string = 'Todo'; - @Trace public isFinish: boolean = false; - - updateTask(task: TaskModel) { - this.taskName = task.taskName; - this.isFinish = task.isFinish; - } - - updateIsFinish(): void { - this.isFinish = !this.isFinish; - } +/* + * 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. + * +*/ + +// src/main/ets/viewmodel/TaskViewModel.ets + +import TaskModel from '../model/TaskModel'; + +@ObservedV2 +export default class TaskViewModel { + @Trace public taskName: string = 'Todo'; + @Trace public isFinish: boolean = false; + + updateTask(task: TaskModel) { + this.taskName = task.taskName; + this.isFinish = task.isFinish; + } + + updateIsFinish(): void { + this.isFinish = !this.isFinish; + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/module.json5 b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/module.json5 index 3e96d96f82..c90903e9e3 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/module.json5 +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/module.json5 @@ -1,61 +1,61 @@ -/* - * 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" - ] - } - ] - }, - { - "name": "SettingAbility", - "srcEntry": "./ets/settingability/SettingAbility.ets", - "description": "$string:SettingAbility_desc", - "icon": "$media:layered_image", - "label": "$string:SettingAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background" - } - ] - } +/* + * 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" + ] + } + ] + }, + { + "name": "SettingAbility", + "srcEntry": "./ets/settingability/SettingAbility.ets", + "description": "$string:SettingAbility_desc", + "icon": "$media:layered_image", + "label": "$string:SettingAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/base/profile/backup_config.json index d742c2f96e..78f40ae7c4 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/rawfile/defaultTasks.json b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/rawfile/defaultTasks.json index f840413bcf..bd049d2be3 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/rawfile/defaultTasks.json +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/main/resources/rawfile/defaultTasks.json @@ -1,7 +1,7 @@ -[ - {"taskName": "学习ArkTS开发", "isFinish": false}, - {"taskName": "健身", "isFinish": false}, - {"taskName": "买水果", "isFinish": true}, - {"taskName": "取快递", "isFinish": true}, - {"taskName": "刷题", "isFinish": true} +[ + {"taskName": "学习ArkTS开发", "isFinish": false}, + {"taskName": "健身", "isFinish": false}, + {"taskName": "买水果", "isFinish": true}, + {"taskName": "取快递", "isFinish": true}, + {"taskName": "刷题", "isFinish": true} ] \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/ohosTest/ets/test/TodoList.test.ets b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/ohosTest/ets/test/TodoList.test.ets index 9632adc418..c3524a32fd 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/ohosTest/ets/test/TodoList.test.ets +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/ohosTest/ets/test/TodoList.test.ets @@ -1,152 +1,152 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -import hilog from '@ohos.hilog' -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON, MatchPattern } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -function sleep(time: number) { - return new Promise((resolve: Function) => setTimeout(resolve, time)); -} - -export default function TodoListTest () { - - describe('TodoListTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - await sleep(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击单个任务,测试切换单项任务的完成状态 - */ - it('testTask',0, async (done: Function) => { - hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testTask begin'); - let driver = Driver.create(); - await driver.delayMs(1000); - let text = await driver.findComponent(ON.text('未完成任务:', MatchPattern.CONTAINS)); - await text.getText().then(result => { - expect(result).assertEqual('未完成任务:2'); - }); - let task = await driver.findComponent(ON.text('刷题')); - await task.click(); - await driver.delayMs(1000); - await text.getText().then(result => { - expect(result).assertEqual('未完成任务:3'); - }); - await task.click(); - await driver.delayMs(1000); - await text.getText().then(result => { - expect(result).assertEqual('未完成任务:2'); - }); - done(); - hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testTask end'); - }) - - /** - * 点击全部完成,全部未完成按钮,测试切换全部任务的完成状态 - */ - it('testFinishAll_UnfinishAll',0, async (done: Function) => { - hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testFinishAll_UnfinishAll begin'); - let driver = Driver.create(); - await driver.delayMs(1000); - let unfinishAll = await driver.findComponent(ON.text('全部未完成')); - await unfinishAll.click(); - await driver.delayMs(1000); - let text = await driver.findComponent(ON.text('未完成任务:', MatchPattern.CONTAINS)); - await text.getText().then(result => { - expect(result).assertEqual('未完成任务:5'); - }); - let finishAll = await driver.findComponent(ON.text('全部完成')); - await finishAll.click(); - await driver.delayMs(1000); - await text.getText().then(result => { - expect(result).assertEqual('未完成任务:0'); - }); - done(); - hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testFinishAll_UnfinishAll end'); - }) - - /** - * 点击删除添加新任务,测试增删功能 - */ - it('testDeleteAddTask',0, async (done: Function) => { - hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testDeleteAddTask begin'); - let driver = Driver.create(); - await driver.delayMs(1000); - let deleteButton = await driver.findComponent(ON.text('删除')); - await deleteButton.click(); - await driver.delayMs(1000); - let button_search = await driver.findComponent(ON.text('学习ArkTS开发')); - expect(button_search === null).assertTrue(); - let inputField = await driver.findComponent(ON.type('TextInput')); - await inputField.inputText('test123') - let addButton = await driver.findComponent(ON.text('+')); - await addButton.click(); - await driver.delayMs(1000); - let newTask = await driver.findComponent(ON.text('test123')); - expect(newTask === null).assertFalse(); - done(); - hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testDeleteAddTask end'); - }) - - /** - * 点击设置按钮,测试切换显示已完成任务功能 - */ - it('testSetting',0, async (done: Function) => { - hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testSetting begin'); - let driver = Driver.create(); - await driver.delayMs(1000); - let settingButton = await driver.findComponent(ON.text('设置')); - await settingButton.click(); - await driver.delayMs(1000); - let switchToggle = await driver.findComponent(ON.type('Toggle')); - await switchToggle.click(); - await driver.delayMs(1000); - let backButton = await driver.findComponent(ON.text('返回待办')); - await backButton.click(); - await driver.delayMs(1000); - let finishTask = await driver.findComponent(ON.text('健身')); - expect(finishTask === null).assertTrue(); - await settingButton.click(); - await driver.delayMs(1000); - let switchToggle1 = await driver.findComponent(ON.type('Toggle')); - await switchToggle1.click(); - await driver.delayMs(1000); - let backButton1 = await driver.findComponent(ON.text('返回待办')); - await backButton1.click(); - await driver.delayMs(1000); - let finishTask1 = await driver.findComponent(ON.text('健身')); - expect(finishTask1 === null).assertFalse(); - done(); - hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testSetting end'); - }) - }) -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +import hilog from '@ohos.hilog' +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON, MatchPattern } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +function sleep(time: number) { + return new Promise((resolve: Function) => setTimeout(resolve, time)); +} + +export default function TodoListTest () { + + describe('TodoListTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + await sleep(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击单个任务,测试切换单项任务的完成状态 + */ + it('testTask',0, async (done: Function) => { + hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testTask begin'); + let driver = Driver.create(); + await driver.delayMs(1000); + let text = await driver.findComponent(ON.text('未完成任务:', MatchPattern.CONTAINS)); + await text.getText().then(result => { + expect(result).assertEqual('未完成任务:2'); + }); + let task = await driver.findComponent(ON.text('刷题')); + await task.click(); + await driver.delayMs(1000); + await text.getText().then(result => { + expect(result).assertEqual('未完成任务:3'); + }); + await task.click(); + await driver.delayMs(1000); + await text.getText().then(result => { + expect(result).assertEqual('未完成任务:2'); + }); + done(); + hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testTask end'); + }) + + /** + * 点击全部完成,全部未完成按钮,测试切换全部任务的完成状态 + */ + it('testFinishAll_UnfinishAll',0, async (done: Function) => { + hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testFinishAll_UnfinishAll begin'); + let driver = Driver.create(); + await driver.delayMs(1000); + let unfinishAll = await driver.findComponent(ON.text('全部未完成')); + await unfinishAll.click(); + await driver.delayMs(1000); + let text = await driver.findComponent(ON.text('未完成任务:', MatchPattern.CONTAINS)); + await text.getText().then(result => { + expect(result).assertEqual('未完成任务:5'); + }); + let finishAll = await driver.findComponent(ON.text('全部完成')); + await finishAll.click(); + await driver.delayMs(1000); + await text.getText().then(result => { + expect(result).assertEqual('未完成任务:0'); + }); + done(); + hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testFinishAll_UnfinishAll end'); + }) + + /** + * 点击删除添加新任务,测试增删功能 + */ + it('testDeleteAddTask',0, async (done: Function) => { + hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testDeleteAddTask begin'); + let driver = Driver.create(); + await driver.delayMs(1000); + let deleteButton = await driver.findComponent(ON.text('删除')); + await deleteButton.click(); + await driver.delayMs(1000); + let button_search = await driver.findComponent(ON.text('学习ArkTS开发')); + expect(button_search === null).assertTrue(); + let inputField = await driver.findComponent(ON.type('TextInput')); + await inputField.inputText('test123') + let addButton = await driver.findComponent(ON.text('+')); + await addButton.click(); + await driver.delayMs(1000); + let newTask = await driver.findComponent(ON.text('test123')); + expect(newTask === null).assertFalse(); + done(); + hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testDeleteAddTask end'); + }) + + /** + * 点击设置按钮,测试切换显示已完成任务功能 + */ + it('testSetting',0, async (done: Function) => { + hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testSetting begin'); + let driver = Driver.create(); + await driver.delayMs(1000); + let settingButton = await driver.findComponent(ON.text('设置')); + await settingButton.click(); + await driver.delayMs(1000); + let switchToggle = await driver.findComponent(ON.type('Toggle')); + await switchToggle.click(); + await driver.delayMs(1000); + let backButton = await driver.findComponent(ON.text('返回待办')); + await backButton.click(); + await driver.delayMs(1000); + let finishTask = await driver.findComponent(ON.text('健身')); + expect(finishTask === null).assertTrue(); + await settingButton.click(); + await driver.delayMs(1000); + let switchToggle1 = await driver.findComponent(ON.type('Toggle')); + await switchToggle1.click(); + await driver.delayMs(1000); + let backButton1 = await driver.findComponent(ON.text('返回待办')); + await backButton1.click(); + await driver.delayMs(1000); + let finishTask1 = await driver.findComponent(ON.text('健身')); + expect(finishTask1 === null).assertFalse(); + done(); + hilog.info(0x0000, 'testTag', '%{public}s', 'uitest: testSetting end'); + }) + }) +} diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/ohosTest/module.json5 index 7785c1ef09..229daaf602 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/entry/src/ohosTest/module.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/hvigor/hvigor-config.json5 b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/hvigor/hvigor-config.json5 index cf31b248c8..c6e3f1bbca 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/hvigor/hvigor-config.json5 @@ -1,38 +1,38 @@ -/* - * 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*/ - } -} +/* + * 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/ArkUISample/StateMgmtV2MVVM/oh-package.json5 b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/oh-package.json5 index 85654c41cc..6f7a200b4f 100644 --- a/code/DocsSample/ArkUISample/StateMgmtV2MVVM/oh-package.json5 +++ b/code/DocsSample/ArkUISample/StateMgmtV2MVVM/oh-package.json5 @@ -1,26 +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. - * -*/ - -{ - "modelVersion": "5.0.0", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ArkWebSchemeHandler/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ArkWebSchemeHandler/ohosTest.md b/code/DocsSample/ArkWeb/ArkWebSchemeHandler/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/.gitignore b/code/DocsSample/ArkWeb/LifecycleWebComp/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/app.json5 b/code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/app.json5 old mode 100755 new mode 100644 index eb9fbe57f4..c280ad8998 --- a/code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.lifecyclewebcomp", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.lifecyclewebcomp", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index c5e75bb9ea..db726d0837 --- a/code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "LifecycleWebComp" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "LifecycleWebComp" + } + ] +} diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/LifecycleWebComp/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/README.md b/code/DocsSample/ArkWeb/LifecycleWebComp/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/build-profile.json5 b/code/DocsSample/ArkWeb/LifecycleWebComp/build-profile.json5 old mode 100755 new mode 100644 index 20e9fa86a9..fe9f102c81 --- a/code/DocsSample/ArkWeb/LifecycleWebComp/build-profile.json5 +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/build-profile.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2024 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 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/ArkWeb/LifecycleWebComp/code-linter.json5 b/code/DocsSample/ArkWeb/LifecycleWebComp/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/.gitignore b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/build-profile.json5 b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/build-profile.json5 old mode 100755 new mode 100644 index 90b14923bf..31bf2f4c4d --- a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2024 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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2024 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/oh-package.json5 b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/oh-package.json5 old mode 100755 new mode 100644 index 41a4755f66..4e54d14e1b --- a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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": {} -} - +/* + * Copyright (c) 2024 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/ArkWeb/LifecycleWebComp/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index d91a720cec..217744d8eb --- a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1755a4686c..6b744d7eaa --- a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 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)); - } +/* + * Copyright (c) 2024 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/ArkWeb/LifecycleWebComp/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/module.json5 old mode 100755 new mode 100644 index b541792385..cb5df2316a --- a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/module.json5 @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2024 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" - } - ] - } - ] - } +/* + * Copyright (c) 2024 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/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index f7fceda00c..8449213216 --- a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/rawfile/index.html @@ -1,9 +1,9 @@ - - - - - - -

Hello, ArkWeb

- - + + + + + + +

Hello, ArkWeb

+ + diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 1f646ea03f..5f63462032 --- a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/LifecycleWebComp/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index 5f9d8a5758..76e3231223 --- a/code/DocsSample/ArkWeb/LifecycleWebComp/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/hvigor/hvigor-config.json5 @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2024 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*/ - } -} +/* + * Copyright (c) 2024 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/ArkWeb/LifecycleWebComp/hvigorfile.ts b/code/DocsSample/ArkWeb/LifecycleWebComp/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/oh-package.json5 b/code/DocsSample/ArkWeb/LifecycleWebComp/oh-package.json5 old mode 100755 new mode 100644 index fb70d168e1..d7622199b7 --- a/code/DocsSample/ArkWeb/LifecycleWebComp/oh-package.json5 +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * Copyright (c) 2024 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/ohosTest.md b/code/DocsSample/ArkWeb/LifecycleWebComp/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/screenshots/LifecycleWebComp.png b/code/DocsSample/ArkWeb/LifecycleWebComp/screenshots/LifecycleWebComp.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/.gitignore b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/app.json5 b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/app.json5 old mode 100755 new mode 100644 index 75ab31d093..f3bfcf5490 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/app.json5 @@ -1,25 +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.managewebcompsecpriv", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.managewebcompsecpriv", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 32877db4dc..8e172ff206 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ManageWebCompSecPriv" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ManageWebCompSecPriv" + } + ] +} diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/README.md b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/build-profile.json5 old mode 100755 new mode 100644 index 633b9956ee..e8a4489c36 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/build-profile.json5 @@ -1,52 +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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 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/ArkWeb/ManageWebCompSecPriv/code-linter.json5 b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/.gitignore b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b23d2fe946..0f2f8b94aa --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets old mode 100755 new mode 100644 index fc8f4c0846..49754ae2a2 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start clear_all_intelligent_tracking_prevention_bypasses] -import { webview } from '@kit.ArkWeb'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Button('clearIntelligentTrackingPreventionBypassingList') - .onClick(() => { - webview.WebviewController.clearIntelligentTrackingPreventionBypassingList(); - }) - Web({ src: $r('app.string.web_path'), controller: this.controller }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start clear_all_intelligent_tracking_prevention_bypasses] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('clearIntelligentTrackingPreventionBypassingList') + .onClick(() => { + webview.WebviewController.clearIntelligentTrackingPreventionBypassingList(); + }) + Web({ src: $r('app.string.web_path'), controller: this.controller }) + } + } +} // [End clear_all_intelligent_tracking_prevention_bypasses] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets old mode 100755 new mode 100644 index 92dcff572c..2d271fae79 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start collect_information_about_ad_filtering] -import { webview } from '@kit.ArkWeb'; - -@Entry -@Component -struct WebComponent { - @State totalAdsBlockCounts: number = 0; - // [StartExclude collect_information_about_ad_filtering] - @State myString: string = 'onAdsBlocked'; - // [EndExclude collect_information_about_ad_filtering] - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Web({ src: $r('app.string.web_path'), controller: this.controller }) - .onAdsBlocked((details: AdsBlockedDetails) => { - if (details) { - console.log(' Blocked ' + details.adsBlocked.length + ' in ' + details.url); - let adList: string[] = Array.from(new Set(details.adsBlocked)); - this.totalAdsBlockCounts += adList.length; - console.log('Total blocked counts :' + this.totalAdsBlockCounts); - } - }) - } - } -} -// [End collect_information_about_ad_filtering] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start collect_information_about_ad_filtering] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + @State totalAdsBlockCounts: number = 0; + // [StartExclude collect_information_about_ad_filtering] + @State myString: string = 'onAdsBlocked'; + // [EndExclude collect_information_about_ad_filtering] + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: $r('app.string.web_path'), controller: this.controller }) + .onAdsBlocked((details: AdsBlockedDetails) => { + if (details) { + console.log(' Blocked ' + details.adsBlocked.length + ' in ' + details.url); + let adList: string[] = Array.from(new Set(details.adsBlocked)); + this.totalAdsBlockCounts += adList.length; + console.log('Total blocked counts :' + this.totalAdsBlockCounts); + } + }) + } + } +} +// [End collect_information_about_ad_filtering] diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets old mode 100755 new mode 100644 index e70fa2041e..f7649e9937 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets @@ -1,66 +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. - */ -// [Start turn_off_ad_filtering_for_specific_domain_pages] -import { webview } from '@kit.ArkWeb'; - -// [StartExclude turn_off_ad_filtering_for_specific_domain_pages] -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} -// [EndExclude turn_off_ad_filtering_for_specific_domain_pages] -@Entry -@Component -struct WebComponent { - mainUrl: string = resourceToString($r('app.string.web_path')); - textInputController: TextInputController = new TextInputController(); - controller: webview.WebviewController = new webview.WebviewController(); - - @State inputText: string = resourceToString($r('app.string.web_path')); - - build() { - Column() { - Row() { - Flex() { - TextInput({ text: this.inputText, placeholder: this.mainUrl, controller: this.textInputController}) - .id('input_url') - .height(40) - .margin(5) - .borderColor(Color.Blue) - .onChange((value: string) => { - this.inputText = value; - }) - - Button({type: ButtonType.Capsule}) { Text('Go') } - .onClick(() => { - this.controller.loadUrl(this.inputText); - }) - - Button({type: ButtonType.Capsule}) { Text('addAdsBlockDisallowedList') } - .onClick(() => { - let arrDomainSuffixes: string[] = []; - arrDomainSuffixes.push('example.com'); - arrDomainSuffixes.push('abcdefg.cn'); - webview.AdsBlockManager.addAdsBlockDisallowedList(arrDomainSuffixes); - }) - } - } - Web({ src: this.mainUrl, controller: this.controller }) - .onControllerAttached(()=>{ - this.controller.enableAdsBlock(true); - }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start turn_off_ad_filtering_for_specific_domain_pages] +import { webview } from '@kit.ArkWeb'; + +// [StartExclude turn_off_ad_filtering_for_specific_domain_pages] +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} +// [EndExclude turn_off_ad_filtering_for_specific_domain_pages] +@Entry +@Component +struct WebComponent { + mainUrl: string = resourceToString($r('app.string.web_path')); + textInputController: TextInputController = new TextInputController(); + controller: webview.WebviewController = new webview.WebviewController(); + + @State inputText: string = resourceToString($r('app.string.web_path')); + + build() { + Column() { + Row() { + Flex() { + TextInput({ text: this.inputText, placeholder: this.mainUrl, controller: this.textInputController}) + .id('input_url') + .height(40) + .margin(5) + .borderColor(Color.Blue) + .onChange((value: string) => { + this.inputText = value; + }) + + Button({type: ButtonType.Capsule}) { Text('Go') } + .onClick(() => { + this.controller.loadUrl(this.inputText); + }) + + Button({type: ButtonType.Capsule}) { Text('addAdsBlockDisallowedList') } + .onClick(() => { + let arrDomainSuffixes: string[] = []; + arrDomainSuffixes.push('example.com'); + arrDomainSuffixes.push('abcdefg.cn'); + webview.AdsBlockManager.addAdsBlockDisallowedList(arrDomainSuffixes); + }) + } + } + Web({ src: this.mainUrl, controller: this.controller }) + .onControllerAttached(()=>{ + this.controller.enableAdsBlock(true); + }) + } + } +} // [End turn_off_ad_filtering_for_specific_domain_pages] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets old mode 100755 new mode 100644 index fe925a82e9..c407061e16 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start set_up_page_level_ad_filtering_switch] -import { webview } from '@kit.ArkWeb'; - -// [StartExclude set_up_page_level_ad_filtering_switch] -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} -// [EndExclude set_up_page_level_ad_filtering_switch] -@Entry -@Component -struct WebComponent { - mainUrl: string = resourceToString($r('app.string.web_path')); - textInputController: TextInputController = new TextInputController(); - controller: webview.WebviewController = new webview.WebviewController(); - - @State inputText: string = resourceToString($r('app.string.web_path')); - - build() { - Column() { - Row() { - Flex() { - TextInput({ text: this.inputText, placeholder: this.mainUrl, controller: this.textInputController}) - .id('input_url') - .height(40) - .margin(5) - .borderColor(Color.Blue) - .onChange((value: string) => { - this.inputText = value; - }) - - Button({type: ButtonType.Capsule}) { Text('Go'); } - .onClick(() => { - this.controller.loadUrl(this.inputText); - }) - - Button({type: ButtonType.Capsule}) { Text('addAdsBlockAllowedList'); } - .onClick(() => { - let arrDisallowDomainSuffixes = ['example.com']; - webview.AdsBlockManager.addAdsBlockDisallowedList(arrDisallowDomainSuffixes); - - let arrAllowedDomainSuffixes = ['news.example.com', 'sport.example.com']; - webview.AdsBlockManager.addAdsBlockAllowedList(arrAllowedDomainSuffixes); - }) - } - } - Web({ src: this.mainUrl, controller: this.controller }) - .onControllerAttached(()=>{ - this.controller.enableAdsBlock(true); - }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start set_up_page_level_ad_filtering_switch] +import { webview } from '@kit.ArkWeb'; + +// [StartExclude set_up_page_level_ad_filtering_switch] +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} +// [EndExclude set_up_page_level_ad_filtering_switch] +@Entry +@Component +struct WebComponent { + mainUrl: string = resourceToString($r('app.string.web_path')); + textInputController: TextInputController = new TextInputController(); + controller: webview.WebviewController = new webview.WebviewController(); + + @State inputText: string = resourceToString($r('app.string.web_path')); + + build() { + Column() { + Row() { + Flex() { + TextInput({ text: this.inputText, placeholder: this.mainUrl, controller: this.textInputController}) + .id('input_url') + .height(40) + .margin(5) + .borderColor(Color.Blue) + .onChange((value: string) => { + this.inputText = value; + }) + + Button({type: ButtonType.Capsule}) { Text('Go'); } + .onClick(() => { + this.controller.loadUrl(this.inputText); + }) + + Button({type: ButtonType.Capsule}) { Text('addAdsBlockAllowedList'); } + .onClick(() => { + let arrDisallowDomainSuffixes = ['example.com']; + webview.AdsBlockManager.addAdsBlockDisallowedList(arrDisallowDomainSuffixes); + + let arrAllowedDomainSuffixes = ['news.example.com', 'sport.example.com']; + webview.AdsBlockManager.addAdsBlockAllowedList(arrAllowedDomainSuffixes); + }) + } + } + Web({ src: this.mainUrl, controller: this.controller }) + .onControllerAttached(()=>{ + this.controller.enableAdsBlock(true); + }) + } + } +} // [End set_up_page_level_ad_filtering_switch] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets old mode 100755 new mode 100644 index e317299ae7..ab7767a6c6 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start enable_or_disable_web_component_anti_tracking] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Button('enableIntelligentTrackingPrevention') - .onClick(() => { - try { - this.controller.enableIntelligentTrackingPrevention(true); - console.log('enableIntelligentTrackingPrevention: true'); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Web({ src: $r('app.string.web_path'), controller: this.controller }); - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start enable_or_disable_web_component_anti_tracking] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('enableIntelligentTrackingPrevention') + .onClick(() => { + try { + this.controller.enableIntelligentTrackingPrevention(true); + console.log('enableIntelligentTrackingPrevention: true'); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Web({ src: $r('app.string.web_path'), controller: this.controller }); + } + } +} // [End enable_or_disable_web_component_anti_tracking] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index b70ec5f3e3..cb5f033b5e --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets @@ -1,74 +1,74 @@ -/* - * 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 { router } from '@kit.ArkUI'; - -@Entry -@Component -struct Index { - build() { - Column({ space: 10 }) { - Button('LocCrossOriginResAccSol_one') - .onClick(() => { - router.pushUrl({ url: 'pages/LocCrossOriginResAccSol_one' }); - }) - Button('LocCrossOriginResAccSol_two') - .onClick(() => { - router.pushUrl({ url: 'pages/LocCrossOriginResAccSol_two' }); - }) - Button('AddIntTrackPreventByPassList') - .onClick(() => { - router.pushUrl({ url: 'pages/AddIntTrackPreventByPassList' }); - }) - Button('ClearIntTrackPreventByPassList') - .onClick(() => { - router.pushUrl({ url: 'pages/ClearIntTrackPreventByPassList' }); - }) - Button('EnableIntTrackPrevent') - .onClick(() => { - router.pushUrl({ url: 'pages/EnableIntTrackPrevent' }); - }) - Button('IsIntTrackPreventEnabled') - .onClick(() => { - router.pushUrl({ url: 'pages/IsIntTrackPreventEnabled' }); - }) - Button('OnIntTrackPreventResult') - .onClick(() => { - router.pushUrl({ url: 'pages/OnIntTrackPreventResult' }); - }) - Button('RemoveIntTrackPreventByPassList') - .onClick(() => { - router.pushUrl({ url: 'pages/RemoveIntTrackPreventByPassList' }); - }) - Button('EnablingAdsBlocking') - .onClick(() => { - router.pushUrl({ url: 'pages/EnablingAdsBlocking' }); - }) - Button('DisAdsBlockSpecDomPages_one') - .onClick(() => { - router.pushUrl({ url: 'pages/DisAdsBlockSpecDomPages_one' }); - }) - Button('DisAdsBlockSpecDomPages_two') - .onClick(() => { - router.pushUrl({ url: 'pages/DisAdsBlockSpecDomPages_two' }); - }) - Button('CollectingAdsBlockingInformation') - .onClick(() => { - router.pushUrl({ url: 'pages/CollectingAdsBlockingInformation' }); - }) - }.height('100%') - .width('100%') - } +/* + * 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 { router } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('LocCrossOriginResAccSol_one') + .onClick(() => { + router.pushUrl({ url: 'pages/LocCrossOriginResAccSol_one' }); + }) + Button('LocCrossOriginResAccSol_two') + .onClick(() => { + router.pushUrl({ url: 'pages/LocCrossOriginResAccSol_two' }); + }) + Button('AddIntTrackPreventByPassList') + .onClick(() => { + router.pushUrl({ url: 'pages/AddIntTrackPreventByPassList' }); + }) + Button('ClearIntTrackPreventByPassList') + .onClick(() => { + router.pushUrl({ url: 'pages/ClearIntTrackPreventByPassList' }); + }) + Button('EnableIntTrackPrevent') + .onClick(() => { + router.pushUrl({ url: 'pages/EnableIntTrackPrevent' }); + }) + Button('IsIntTrackPreventEnabled') + .onClick(() => { + router.pushUrl({ url: 'pages/IsIntTrackPreventEnabled' }); + }) + Button('OnIntTrackPreventResult') + .onClick(() => { + router.pushUrl({ url: 'pages/OnIntTrackPreventResult' }); + }) + Button('RemoveIntTrackPreventByPassList') + .onClick(() => { + router.pushUrl({ url: 'pages/RemoveIntTrackPreventByPassList' }); + }) + Button('EnablingAdsBlocking') + .onClick(() => { + router.pushUrl({ url: 'pages/EnablingAdsBlocking' }); + }) + Button('DisAdsBlockSpecDomPages_one') + .onClick(() => { + router.pushUrl({ url: 'pages/DisAdsBlockSpecDomPages_one' }); + }) + Button('DisAdsBlockSpecDomPages_two') + .onClick(() => { + router.pushUrl({ url: 'pages/DisAdsBlockSpecDomPages_two' }); + }) + Button('CollectingAdsBlockingInformation') + .onClick(() => { + router.pushUrl({ url: 'pages/CollectingAdsBlockingInformation' }); + }) + }.height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets old mode 100755 new mode 100644 index f35678435d..b33603d2c0 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start check_if_web_component_anti_tracking_on] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Button('isIntelligentTrackingPreventionEnabled') - .onClick(() => { - try { - let result = this.controller.isIntelligentTrackingPreventionEnabled(); - console.log('result: ' + result); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Web({ src: $r('app.string.web_path'), controller: this.controller }); - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start check_if_web_component_anti_tracking_on] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('isIntelligentTrackingPreventionEnabled') + .onClick(() => { + try { + let result = this.controller.isIntelligentTrackingPreventionEnabled(); + console.log('result: ' + result); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Web({ src: $r('app.string.web_path'), controller: this.controller }); + } + } +} // [End check_if_web_component_anti_tracking_on] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_one.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_one.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_two.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_two.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets old mode 100755 new mode 100644 index 86bb3887db..23fdec43f0 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start retrieve_blocked_and_visited_domain_names] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - // 需要打开智能防跟踪功能,才会触发onIntelligentTrackingPreventionResult回调 - Button('enableIntelligentTrackingPrevention') - .onClick(() => { - try { - this.controller.enableIntelligentTrackingPrevention(true); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Web({ src: $r('app.string.web_path'), controller: this.controller }) - .onIntelligentTrackingPreventionResult((details) => { - console.log('onIntelligentTrackingPreventionResult: [websiteHost]= ' + details.host + - ', [trackerHost]=' + details.trackerHost); - }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start retrieve_blocked_and_visited_domain_names] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + // 需要打开智能防跟踪功能,才会触发onIntelligentTrackingPreventionResult回调 + Button('enableIntelligentTrackingPrevention') + .onClick(() => { + try { + this.controller.enableIntelligentTrackingPrevention(true); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Web({ src: $r('app.string.web_path'), controller: this.controller }) + .onIntelligentTrackingPreventionResult((details) => { + console.log('onIntelligentTrackingPreventionResult: [websiteHost]= ' + details.host + + ', [trackerHost]=' + details.trackerHost); + }) + } + } +} // [End retrieve_blocked_and_visited_domain_names] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets old mode 100755 new mode 100644 index 504ff4f33c..ed8c741879 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets @@ -1,40 +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. - */ -// [Start partial_domain_name_list] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Button('removeIntelligentTrackingPreventionBypassingList') - .onClick(() => { - try { - let hostList = [ 'www.test1.com', 'www.test2.com' ]; - webview.WebviewController.removeIntelligentTrackingPreventionBypassingList(hostList); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Web({ src: 'www.example.com', controller: this.controller }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start partial_domain_name_list] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('removeIntelligentTrackingPreventionBypassingList') + .onClick(() => { + try { + let hostList = [ 'www.test1.com', 'www.test2.com' ]; + webview.WebviewController.removeIntelligentTrackingPreventionBypassingList(hostList); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } +} // [End partial_domain_name_list] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/module.json5 old mode 100755 new mode 100644 index 81751d0bc4..e9db80c0ac --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index 56e1d4c806..01ba29a16a --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html @@ -1,23 +1,23 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js old mode 100755 new mode 100644 index 171372835d..dfd1c0b8cb --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js @@ -1,21 +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. - */ - -// [Start cors_script_raw] -const body = document.body; -const element = document.createElement('div'); -element.textContent = 'success'; -body.appendChild(element); +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start cors_script_raw] +const body = document.body; +const element = document.createElement('div'); +element.textContent = 'success'; +body.appendChild(element); // [End cors_script_raw] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html old mode 100755 new mode 100644 index b9fd97fc20..e8aa150815 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html @@ -1,56 +1,56 @@ - - - - - - - - Demo - - - - - -
- -
-
- - - + + + + + + + + Demo + + + + + +
+ +
+
+ + + diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/js/script.js b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/js/script.js old mode 100755 new mode 100644 index ac3dd07ac3..9853f099a5 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/js/script.js +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/js/script.js @@ -1,21 +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. - */ - -// [Start cors_script] -const body = document.body; -const element = document.createElement('div'); -element.textContent = 'success'; -body.appendChild(element); +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start cors_script] +const body = document.body; +const element = document.createElement('div'); +element.textContent = 'success'; +body.appendChild(element); // [End cors_script] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/ManageWebCompSecPriv/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/ohosTest.md b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/AddIntTrackPreventByPassList.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/AddIntTrackPreventByPassList.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/ClearIntTrackPreventByPassList.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/ClearIntTrackPreventByPassList.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/CollectingAdsBlockingInformation.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/CollectingAdsBlockingInformation.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_one.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_one.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_two.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_two.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/EnableIntTrackPrevent.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/EnableIntTrackPrevent.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_1.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_2.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/IsIntTrackPreventEnabled.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/IsIntTrackPreventEnabled.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_one.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_one.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_1.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_2.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/OnIntTrackPreventResult.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/OnIntTrackPreventResult.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/RemoveIntTrackPreventByPassList.png b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/screenshots/RemoveIntTrackPreventByPassList.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageFileIO/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/app.json5 b/code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/app.json5 old mode 100755 new mode 100644 index a955b9b444..c81be32093 --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/app.json5 @@ -1,25 +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.managewebpagefileio", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.managewebpagefileio", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index fd4f95881b..651c9e3690 --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ManageWebPageFileIO" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ManageWebPageFileIO" + } + ] +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/README.md b/code/DocsSample/ArkWeb/ManageWebPageFileIO/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageFileIO/build-profile.json5 old mode 100755 new mode 100644 index 87d40a385e..7a9c78377e --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/build-profile.json5 @@ -1,52 +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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 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/ArkWeb/ManageWebPageFileIO/code-linter.json5 b/code/DocsSample/ArkWeb/ManageWebPageFileIO/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b23d2fe946..0f2f8b94aa --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 611bcc25b1..80e8214f74 --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets @@ -1,42 +1,42 @@ -/* - * 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 { router } from '@kit.ArkUI'; - -@Entry -@Component -struct Index { - build() { - Column({ space: 10 }) { - Button('UploadFiles') - .onClick(() => { - router.pushUrl({ url: 'pages/UploadFiles' }); - }) - Button('ListenForPageDown') - .onClick(() => { - router.pushUrl({ url: 'pages/ListenForPageDown' }); - }) - Button('InitiatingADownloadTask') - .onClick(() => { - router.pushUrl({ url: 'pages/InitiatingADownloadTask' }); - }) - Button('ResumeDownload') - .onClick(() => { - router.pushUrl({ url: 'pages/ResumeDownload' }); - }) - }.height('100%') - .width('100%') - } +/* + * 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 { router } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('UploadFiles') + .onClick(() => { + router.pushUrl({ url: 'pages/UploadFiles' }); + }) + Button('ListenForPageDown') + .onClick(() => { + router.pushUrl({ url: 'pages/ListenForPageDown' }); + }) + Button('InitiatingADownloadTask') + .onClick(() => { + router.pushUrl({ url: 'pages/InitiatingADownloadTask' }); + }) + Button('ResumeDownload') + .onClick(() => { + router.pushUrl({ url: 'pages/ResumeDownload' }); + }) + }.height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets old mode 100755 new mode 100644 index 0c104b48a2..5b876e5f29 --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start init_download_task] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; - -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate(); - @State myText: string = 'download'; - - build() { - Column() { - Text(this.myText) - Button('setDownloadDelegate') - .onClick(() => { - try { - this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => { - console.log('will start a download.'); - // 传入一个下载路径,并开始下载。 - webDownloadItem.start('/data/storage/el2/base/cache/web/' + webDownloadItem.getSuggestedFileName()); - }) - this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => { - console.log('download update guid: ' + webDownloadItem.getGuid()); - }) - this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => { - console.log('download failed guid: ' + webDownloadItem.getGuid()); - }) - this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => { - console.log('download finish guid: ' + webDownloadItem.getGuid()); - this.myText = 'download finish'; - }) - this.controller.setDownloadDelegate(this.delegate); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('startDownload') - .onClick(() => { - try { - // 这里指定下载地址为 https://www.example.com/,Web组件会发起一个下载任务将该页面下载下来。 - // 开发者需要替换为自己想要下载的内容的地址。 - this.controller.startDownload(resourceToString($r('app.string.web_path'))); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Web({ src: 'www.example.com', controller: this.controller }) - } - } -} -// [End init_download_task] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start init_download_task] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate(); + @State myText: string = 'download'; + + build() { + Column() { + Text(this.myText) + Button('setDownloadDelegate') + .onClick(() => { + try { + this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => { + console.log('will start a download.'); + // 传入一个下载路径,并开始下载。 + webDownloadItem.start('/data/storage/el2/base/cache/web/' + webDownloadItem.getSuggestedFileName()); + }) + this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => { + console.log('download update guid: ' + webDownloadItem.getGuid()); + }) + this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => { + console.log('download failed guid: ' + webDownloadItem.getGuid()); + }) + this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => { + console.log('download finish guid: ' + webDownloadItem.getGuid()); + this.myText = 'download finish'; + }) + this.controller.setDownloadDelegate(this.delegate); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('startDownload') + .onClick(() => { + try { + // 这里指定下载地址为 https://www.example.com/,Web组件会发起一个下载任务将该页面下载下来。 + // 开发者需要替换为自己想要下载的内容的地址。 + this.controller.startDownload(resourceToString($r('app.string.web_path'))); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } +} +// [End init_download_task] diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ListenForPageDown.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ListenForPageDown.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets old mode 100755 new mode 100644 index b2c4f70021..c0d230cdc7 --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets @@ -1,106 +1,106 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start recovery_download_task] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { DownloadUtil, fileName, filePath } from './downloadUtil'; // downloadUtil.ets 见下文 - -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate(); - download: webview.WebDownloadItem = new webview.WebDownloadItem(); - // 用于记录失败的下载任务。 - failedData: Uint8Array = new Uint8Array(); - - build() { - Column() { - Button('setDownloadDelegate') - .onClick(() => { - try { - this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => { - console.log('will start a download.'); - // 传入一个下载路径,并开始下载。 - webDownloadItem.start('/data/storage/el2/base/cache/web/' + webDownloadItem.getSuggestedFileName()); - }) - this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => { - console.log('download update percent complete: ' + webDownloadItem.getPercentComplete()); - this.download = webDownloadItem; - }) - this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => { - console.log('download failed guid: ' + webDownloadItem.getGuid()); - // 序列化失败的下载任务到一个字节数组。 - this.failedData = webDownloadItem.serialize(); - }) - this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => { - console.log('download finish guid: ' + webDownloadItem.getGuid()); - }) - this.controller.setDownloadDelegate(this.delegate); - webview.WebDownloadManager.setDownloadDelegate(this.delegate); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('startDownload') - .onClick(() => { - try { - // 这里指定下载地址为 https://www.example.com/,Web组件会发起一个下载任务将该页面下载下来。 - // 开发者需要替换为自己想要下载的内容的地址。 - this.controller.startDownload(resourceToString($r('app.string.web_path'))); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - // 将当前的下载任务信息序列化保存,用于后续恢复下载任务。 - // 当前用例仅展示下载一个任务的场景,多任务场景请按需扩展。 - Button('record') - .onClick(() => { - try { - // 保存当前下载数据到持久化文档中。 - DownloadUtil.saveDownloadInfo(DownloadUtil.uint8ArrayToStr(this.download.serialize())); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - // 从序列化的下载任务信息中,恢复下载任务。 - // 按钮触发时必须保证WebDownloadManager.setDownloadDelegate设置完成。 - Button('recovery') - .onClick(() => { - try { - // 当前默认持久化文件存在,用户根据实际情况增加判断。 - let webDownloadItem = - webview.WebDownloadItem.deserialize( - DownloadUtil.strToUint8Array(DownloadUtil.readFileSync(filePath, fileName))); - webview.WebDownloadManager.resumeDownload(webDownloadItem); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - - Web({ src: 'www.example.com', controller: this.controller }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start recovery_download_task] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { DownloadUtil, fileName, filePath } from './downloadUtil'; // downloadUtil.ets 见下文 + +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate(); + download: webview.WebDownloadItem = new webview.WebDownloadItem(); + // 用于记录失败的下载任务。 + failedData: Uint8Array = new Uint8Array(); + + build() { + Column() { + Button('setDownloadDelegate') + .onClick(() => { + try { + this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => { + console.log('will start a download.'); + // 传入一个下载路径,并开始下载。 + webDownloadItem.start('/data/storage/el2/base/cache/web/' + webDownloadItem.getSuggestedFileName()); + }) + this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => { + console.log('download update percent complete: ' + webDownloadItem.getPercentComplete()); + this.download = webDownloadItem; + }) + this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => { + console.log('download failed guid: ' + webDownloadItem.getGuid()); + // 序列化失败的下载任务到一个字节数组。 + this.failedData = webDownloadItem.serialize(); + }) + this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => { + console.log('download finish guid: ' + webDownloadItem.getGuid()); + }) + this.controller.setDownloadDelegate(this.delegate); + webview.WebDownloadManager.setDownloadDelegate(this.delegate); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('startDownload') + .onClick(() => { + try { + // 这里指定下载地址为 https://www.example.com/,Web组件会发起一个下载任务将该页面下载下来。 + // 开发者需要替换为自己想要下载的内容的地址。 + this.controller.startDownload(resourceToString($r('app.string.web_path'))); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + // 将当前的下载任务信息序列化保存,用于后续恢复下载任务。 + // 当前用例仅展示下载一个任务的场景,多任务场景请按需扩展。 + Button('record') + .onClick(() => { + try { + // 保存当前下载数据到持久化文档中。 + DownloadUtil.saveDownloadInfo(DownloadUtil.uint8ArrayToStr(this.download.serialize())); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + // 从序列化的下载任务信息中,恢复下载任务。 + // 按钮触发时必须保证WebDownloadManager.setDownloadDelegate设置完成。 + Button('recovery') + .onClick(() => { + try { + // 当前默认持久化文件存在,用户根据实际情况增加判断。 + let webDownloadItem = + webview.WebDownloadItem.deserialize( + DownloadUtil.strToUint8Array(DownloadUtil.readFileSync(filePath, fileName))); + webview.WebDownloadManager.resumeDownload(webDownloadItem); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + + Web({ src: 'www.example.com', controller: this.controller }) + } + } +} // [End recovery_download_task] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/UploadFiles.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/UploadFiles.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets old mode 100755 new mode 100644 index f00bbab9c0..be9907e29f --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start task_info_persistence_util] -import { util } from '@kit.ArkTS'; -import fileStream from '@ohos.file.fs'; - -const helper = new util.Base64Helper(); - -export const filePath = getContext().filesDir; -export const fileName = 'demoFile.txt'; -export namespace DownloadUtil { - - export function uint8ArrayToStr(uint8Array: Uint8Array): string { - return helper.encodeToStringSync(uint8Array); - } - - export function strToUint8Array(str: string): Uint8Array { - return helper.decodeSync(str); - } - - export function saveDownloadInfo(downloadInfo: string): void { - if (!fileExists(filePath)) { - mkDirectorySync(filePath); - } - - writeToFileSync(filePath, fileName, downloadInfo); - } - - export function fileExists(filePath: string): boolean { - try { - return fileStream.accessSync(filePath); - } catch (error) { - return false; - } - } - - export function mkDirectorySync(directoryPath: string, recursion?: boolean): void { - try { - fileStream.mkdirSync(directoryPath, recursion ?? false); - } catch (error) { - console.error(`mk dir error. err message: ${error.message}, err code: ${error.code}`); - } - } - - export function writeToFileSync(dir: string, fileName: string, msg: string): void { - let file = fileStream.openSync(dir + '/' + fileName, fileStream.OpenMode.WRITE_ONLY | fileStream.OpenMode.CREATE); - fileStream.writeSync(file.fd, msg); - } - - export function readFileSync(dir: string, fileName: string): string { - return fileStream.readTextSync(dir + '/' + fileName); - } - -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start task_info_persistence_util] +import { util } from '@kit.ArkTS'; +import fileStream from '@ohos.file.fs'; + +const helper = new util.Base64Helper(); + +export const filePath = getContext().filesDir; +export const fileName = 'demoFile.txt'; +export namespace DownloadUtil { + + export function uint8ArrayToStr(uint8Array: Uint8Array): string { + return helper.encodeToStringSync(uint8Array); + } + + export function strToUint8Array(str: string): Uint8Array { + return helper.decodeSync(str); + } + + export function saveDownloadInfo(downloadInfo: string): void { + if (!fileExists(filePath)) { + mkDirectorySync(filePath); + } + + writeToFileSync(filePath, fileName, downloadInfo); + } + + export function fileExists(filePath: string): boolean { + try { + return fileStream.accessSync(filePath); + } catch (error) { + return false; + } + } + + export function mkDirectorySync(directoryPath: string, recursion?: boolean): void { + try { + fileStream.mkdirSync(directoryPath, recursion ?? false); + } catch (error) { + console.error(`mk dir error. err message: ${error.message}, err code: ${error.code}`); + } + } + + export function writeToFileSync(dir: string, fileName: string, msg: string): void { + let file = fileStream.openSync(dir + '/' + fileName, fileStream.OpenMode.WRITE_ONLY | fileStream.OpenMode.CREATE); + fileStream.writeSync(file.fd, msg); + } + + export function readFileSync(dir: string, fileName: string): string { + return fileStream.readTextSync(dir + '/' + fileName); + } + +} // [End task_info_persistence_util] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/module.json5 old mode 100755 new mode 100644 index 81751d0bc4..e9db80c0ac --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html old mode 100755 new mode 100644 index c890546eb8..79e8cc88be --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html @@ -1,21 +1,21 @@ - - - - - -

download test

- + + + + + +

download test

+ \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index 006195d7f7..3dab642cbf --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/index.html @@ -1,21 +1,21 @@ - - - - - -Download - - + + + + + +Download + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/local.html b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/local.html old mode 100755 new mode 100644 index d7bb4919a5..a02fa4eb2b --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/local.html +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/local.html @@ -1,28 +1,28 @@ - - - - - - - Document - - - - -
- - - + + + + + + + Document + + + + +
+ + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageFileIO/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageFileIO/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/ManageWebPageFileIO/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageFileIO/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageFileIO/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/ManageWebPageFileIO/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageFileIO/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/ohosTest.md b/code/DocsSample/ArkWeb/ManageWebPageFileIO/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_1.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_2.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/ListenForPageDown_1.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/ListenForPageDown_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/ListenForPageDown_2.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/ListenForPageDown_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/ResumeDownload.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/ResumeDownload.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/UploadFiles_1.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/UploadFiles_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/UploadFiles_2.png b/code/DocsSample/ArkWeb/ManageWebPageFileIO/screenshots/UploadFiles_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageInteracts/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/app.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/app.json5 old mode 100755 new mode 100644 index 46003233ad..ce3d05eda7 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/app.json5 @@ -1,25 +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.managewebpageinteracts", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.managewebpageinteracts", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 520a651cc4..be8d935f62 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ManageWebPageInteracts" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ManageWebPageInteracts" + } + ] +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/README.md b/code/DocsSample/ArkWeb/ManageWebPageInteracts/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/build-profile.json5 old mode 100755 new mode 100644 index 5209cd7eb7..aa5718fb8d --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/build-profile.json5 @@ -1,64 +1,64 @@ -/* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -{ - "app": { - "signingConfigs": [], - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry2", - "srcPath": "./entry2", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* +* 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry2", + "srcPath": "./entry2", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/code-linter.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b23d2fe946..0f2f8b94aa --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/ImpNestedScroll.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/ImpNestedScroll.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 94ee9bb218..f9b6f41e80 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets @@ -1,38 +1,38 @@ -/* - * 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 { router } from '@kit.ArkUI'; - -@Entry -@Component -struct Index { - build() { - Column({ space: 10 }) { - Button('ImpNestedScroll') - .onClick(() => { - router.pushUrl({ url: 'pages/ImpNestedScroll' }); - }) - Button('OnIntKbdAttachSysCustIn') - .onClick(() => { - router.pushUrl({ url: 'pages/OnIntKbdAttachSysCustIn' }); - }) - Button('SetSKBMode_one') - .onClick(() => { - router.pushUrl({ url: 'pages/SetSKBMode_one' }); - }) - }.height('100%') - .width('100%') - } +/* + * 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 { router } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('ImpNestedScroll') + .onClick(() => { + router.pushUrl({ url: 'pages/ImpNestedScroll' }); + }) + Button('OnIntKbdAttachSysCustIn') + .onClick(() => { + router.pushUrl({ url: 'pages/OnIntKbdAttachSysCustIn' }); + }) + Button('SetSKBMode_one') + .onClick(() => { + router.pushUrl({ url: 'pages/SetSKBMode_one' }); + }) + }.height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets old mode 100755 new mode 100644 index 22ab66fb15..ed6dd8f9d0 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets @@ -1,122 +1,122 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start soft_keyboard_web] -import { webview } from '@kit.ArkWeb'; -import { inputMethodEngine } from '@kit.IMEKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - webKeyboardController: WebKeyboardController = new WebKeyboardController(); - inputAttributeMap: Map = new Map([ - ['UNSPECIFIED', inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED], - ['GO', inputMethodEngine.ENTER_KEY_TYPE_GO], - ['SEARCH', inputMethodEngine.ENTER_KEY_TYPE_SEARCH], - ['SEND', inputMethodEngine.ENTER_KEY_TYPE_SEND], - ['NEXT', inputMethodEngine.ENTER_KEY_TYPE_NEXT], - ['DONE', inputMethodEngine.ENTER_KEY_TYPE_DONE], - ['PREVIOUS', inputMethodEngine.ENTER_KEY_TYPE_PREVIOUS] - ]); - - /** - * 自定义键盘组件Builder - */ - @Builder - customKeyboardBuilder() { - // 这里实现自定义键盘组件,对接WebKeyboardController实现输入、删除、关闭等操作。 - Row() { - Text('finish') - .fontSize(20) - .fontColor(Color.Blue) - .onClick(() => { - this.webKeyboardController.close(); - }) - // 插入字符。 - Button('insertText').onClick(() => { - this.webKeyboardController.insertText('insert '); - }).margin({ - bottom: 200, - }); - // 从后往前删除length参数指定长度的字符。 - Button('deleteForward').onClick(() => { - this.webKeyboardController.deleteForward(1); - }).margin({ - bottom: 200, - }); - // 从前往后删除length参数指定长度的字符。 - Button('deleteBackward').onClick(() => { - this.webKeyboardController.deleteBackward(1); - }).margin({ - left: -220, - }); - // 插入功能按键。 - Button('sendFunctionKey').onClick(() => { - this.webKeyboardController.sendFunctionKey(6); - }) - } - } - - build() { - Column() { - Web({ src: $rawfile('index.html'), controller: this.controller }) - .onInterceptKeyboardAttach((keyBoardCallBackInfo) => { - // option初始化,默认使用系统默认键盘 - let option: WebKeyboardOptions = { - useSystemKeyboard: true, - }; - if (!keyBoardCallBackInfo) { - return option; - } - - // 保存WebKeyboardController,使用自定义键盘时候,需要使用该handler控制输入、删除、软键盘关闭等行为 - this.webKeyboardController = keyBoardCallBackInfo.controller; - let attributes: Record = keyBoardCallBackInfo.attributes; - // 遍历attributes - let attributeKeys = Object.keys(attributes); - for (let i = 0; i < attributeKeys.length; i++) { - console.log('WebCustomKeyboard key = ' + attributeKeys[i] + ', value = ' + attributes[attributeKeys[i]]); - } - - if (attributes) { - if (attributes['data-keyboard'] == 'customKeyboard') { - // 根据html可编辑元素的属性,判断使用不同的软键盘,例如这里如果属性包含有data-keyboard,且值为customKeyboard,则使用自定义键盘 - console.log('WebCustomKeyboard use custom keyboard'); - option.useSystemKeyboard = false; - // 设置自定义键盘builder - option.customKeyboard = () => { - this.customKeyboardBuilder(); - } - return option; - } - - if (attributes['keyboard-return'] != undefined) { - // 根据html可编辑元素的属性,判断使用不同的软键盘,例如这里如果属性包含有keyboard-return,使用系统键盘,并且指定系统软键盘enterKey类型 - option.useSystemKeyboard = true; - let enterKeyType: number | undefined = this.inputAttributeMap.get(attributes['keyboard-return']); - if (enterKeyType != undefined) { - option.enterKeyType = enterKeyType; - } - return option; - } - } - - return option; - }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start soft_keyboard_web] +import { webview } from '@kit.ArkWeb'; +import { inputMethodEngine } from '@kit.IMEKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + webKeyboardController: WebKeyboardController = new WebKeyboardController(); + inputAttributeMap: Map = new Map([ + ['UNSPECIFIED', inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED], + ['GO', inputMethodEngine.ENTER_KEY_TYPE_GO], + ['SEARCH', inputMethodEngine.ENTER_KEY_TYPE_SEARCH], + ['SEND', inputMethodEngine.ENTER_KEY_TYPE_SEND], + ['NEXT', inputMethodEngine.ENTER_KEY_TYPE_NEXT], + ['DONE', inputMethodEngine.ENTER_KEY_TYPE_DONE], + ['PREVIOUS', inputMethodEngine.ENTER_KEY_TYPE_PREVIOUS] + ]); + + /** + * 自定义键盘组件Builder + */ + @Builder + customKeyboardBuilder() { + // 这里实现自定义键盘组件,对接WebKeyboardController实现输入、删除、关闭等操作。 + Row() { + Text('finish') + .fontSize(20) + .fontColor(Color.Blue) + .onClick(() => { + this.webKeyboardController.close(); + }) + // 插入字符。 + Button('insertText').onClick(() => { + this.webKeyboardController.insertText('insert '); + }).margin({ + bottom: 200, + }); + // 从后往前删除length参数指定长度的字符。 + Button('deleteForward').onClick(() => { + this.webKeyboardController.deleteForward(1); + }).margin({ + bottom: 200, + }); + // 从前往后删除length参数指定长度的字符。 + Button('deleteBackward').onClick(() => { + this.webKeyboardController.deleteBackward(1); + }).margin({ + left: -220, + }); + // 插入功能按键。 + Button('sendFunctionKey').onClick(() => { + this.webKeyboardController.sendFunctionKey(6); + }) + } + } + + build() { + Column() { + Web({ src: $rawfile('index.html'), controller: this.controller }) + .onInterceptKeyboardAttach((keyBoardCallBackInfo) => { + // option初始化,默认使用系统默认键盘 + let option: WebKeyboardOptions = { + useSystemKeyboard: true, + }; + if (!keyBoardCallBackInfo) { + return option; + } + + // 保存WebKeyboardController,使用自定义键盘时候,需要使用该handler控制输入、删除、软键盘关闭等行为 + this.webKeyboardController = keyBoardCallBackInfo.controller; + let attributes: Record = keyBoardCallBackInfo.attributes; + // 遍历attributes + let attributeKeys = Object.keys(attributes); + for (let i = 0; i < attributeKeys.length; i++) { + console.log('WebCustomKeyboard key = ' + attributeKeys[i] + ', value = ' + attributes[attributeKeys[i]]); + } + + if (attributes) { + if (attributes['data-keyboard'] == 'customKeyboard') { + // 根据html可编辑元素的属性,判断使用不同的软键盘,例如这里如果属性包含有data-keyboard,且值为customKeyboard,则使用自定义键盘 + console.log('WebCustomKeyboard use custom keyboard'); + option.useSystemKeyboard = false; + // 设置自定义键盘builder + option.customKeyboard = () => { + this.customKeyboardBuilder(); + } + return option; + } + + if (attributes['keyboard-return'] != undefined) { + // 根据html可编辑元素的属性,判断使用不同的软键盘,例如这里如果属性包含有keyboard-return,使用系统键盘,并且指定系统软键盘enterKey类型 + option.useSystemKeyboard = true; + let enterKeyType: number | undefined = this.inputAttributeMap.get(attributes['keyboard-return']); + if (enterKeyType != undefined) { + option.enterKeyType = enterKeyType; + } + return option; + } + } + + return option; + }) + } + } +} // [End soft_keyboard_web] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/SetSKBMode_one.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/SetSKBMode_one.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/module.json5 old mode 100755 new mode 100644 index 81751d0bc4..e9db80c0ac --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/rawfile/SetSKBModeIndex.html b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/rawfile/SetSKBModeIndex.html old mode 100755 new mode 100644 index 4ca7b500a1..61538c5f01 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/rawfile/SetSKBModeIndex.html +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/rawfile/SetSKBModeIndex.html @@ -1,25 +1,25 @@ - - - - - - 测试网页 - - -

DEMO

- - - + + + + + + 测试网页 + + +

DEMO

+ + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index 5c81f6e49a..126ebbb351 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/rawfile/index.html @@ -1,63 +1,63 @@ - - - - - - - - - - - - -

input标签,原有默认行为:

-
-
- -

input标签,系统键盘自定义enterKeyType属性 enter key UNSPECIFIED:

-
-
- -

input标签,系统键盘自定义enterKeyType属性 enter key GO:

-
-
- -

input标签,系统键盘自定义enterKeyType属性 enter key SEARCH:

-
-
- -

input标签,系统键盘自定义enterKeyType属性 enter key SEND:

-
-
- -

input标签,系统键盘自定义enterKeyType属性 enter key NEXT:

-
-
- -

input标签,系统键盘自定义enterKeyType属性 enter key DONE:

-
-
- -

input标签,系统键盘自定义enterKeyType属性 enter key PREVIOUS:

-
-
- -

input标签,应用自定义键盘:

-
- - - - + + + + + + + + + + + + +

input标签,原有默认行为:

+
+
+ +

input标签,系统键盘自定义enterKeyType属性 enter key UNSPECIFIED:

+
+
+ +

input标签,系统键盘自定义enterKeyType属性 enter key GO:

+
+
+ +

input标签,系统键盘自定义enterKeyType属性 enter key SEARCH:

+
+
+ +

input标签,系统键盘自定义enterKeyType属性 enter key SEND:

+
+
+ +

input标签,系统键盘自定义enterKeyType属性 enter key NEXT:

+
+
+ +

input标签,系统键盘自定义enterKeyType属性 enter key DONE:

+
+
+ +

input标签,系统键盘自定义enterKeyType属性 enter key PREVIOUS:

+
+
+ +

input标签,应用自定义键盘:

+
+ + + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/build-profile.json5 old mode 100755 new mode 100644 index 154bdd0875..9edfdf8c4a --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* +* 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/oh-package.json5 old mode 100755 new mode 100644 index 3fc6e6bee3..2944307304 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/oh-package.json5 @@ -1,25 +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": "entry2", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* +* 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": "entry2", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2ability/Entry2Ability.ets old mode 100755 new mode 100644 index 0a120848dd..f7cf84b7a4 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2ability/Entry2Ability.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2ability/Entry2Ability.ets @@ -1,61 +1,61 @@ -/* - * 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, KeyboardAvoidMode } from '@kit.ArkUI'; - -export default class Entry2Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - // [Start soft_keyboard_entryability] - 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) => { - let keyboardAvoidMode = windowStage.getMainWindowSync().getUIContext().getKeyboardAvoidMode(); - // 设置虚拟键盘抬起时压缩页面大小为减去键盘的高度 - windowStage.getMainWindowSync().getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE); - 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.'); - }); - } - - // [End soft_keyboard_entryability] - 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'); - } +/* + * 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, KeyboardAvoidMode } from '@kit.ArkUI'; + +export default class Entry2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + // [Start soft_keyboard_entryability] + 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) => { + let keyboardAvoidMode = windowStage.getMainWindowSync().getUIContext().getKeyboardAvoidMode(); + // 设置虚拟键盘抬起时压缩页面大小为减去键盘的高度 + windowStage.getMainWindowSync().getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE); + 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.'); + }); + } + + // [End soft_keyboard_entryability] + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets old mode 100755 new mode 100644 index a9c5227a98..f9a6b45900 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets @@ -1,27 +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 Entry2BackupAbility 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)); - } +/* + * 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 Entry2BackupAbility 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/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/module.json5 old mode 100755 new mode 100644 index 3ab4a8f46b..04dba69118 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/module.json5 @@ -1,67 +1,67 @@ -/* -* 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": "entry2", - "type": "entry", - "description": "$string:module_desc", - "mainElement": "Entry2Ability", - "deviceTypes": [ - "phone", - "2in1", - "car" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry2Ability", - "srcEntry": "./ets/entry2ability/Entry2Ability.ets", - "description": "$string:Entry2Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry2Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "Entry2BackupAbility", - "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.ets", - "type": "backup", - "exported": false, - "metadata": [ - { - "name": "ohos.extension.backup", - "resource": "$profile:backup_config" - } - ] - } - ] - } +/* +* 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": "entry2", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "Entry2Ability", + "deviceTypes": [ + "phone", + "2in1", + "car" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry2Ability", + "srcEntry": "./ets/entry2ability/Entry2Ability.ets", + "description": "$string:Entry2Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry2Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "Entry2BackupAbility", + "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.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/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index 9da34ae8bb..4699c0c00f --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/resources/rawfile/index.html @@ -1,25 +1,25 @@ - - - - - - 测试网页 - - -

DEMO

- - + + + + + + 测试网页 + + +

DEMO

+ + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/module.json5 old mode 100755 new mode 100644 index af99bf1564..def0d923e0 --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/ohosTest/module.json5 @@ -1,28 +1,28 @@ -/* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -{ - "module": { - "name": "entry2_test", - "type": "feature", - "deviceTypes": [ - "phone", - "2in1", - "car" - ], - "deliveryWithInstall": true, - "installationFree": false - } +/* +* 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": "entry2_test", + "type": "feature", + "deviceTypes": [ + "phone", + "2in1", + "car" + ], + "deliveryWithInstall": true, + "installationFree": false + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/ManageWebPageInteracts/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageInteracts/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageInteracts/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/ManageWebPageInteracts/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageInteracts/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/ohosTest.md b/code/DocsSample/ArkWeb/ManageWebPageInteracts/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/ImpNestedScroll.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/ImpNestedScroll.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/OnIntKbdAttachSysCustIn.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/OnIntKbdAttachSysCustIn.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_one_1.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_one_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_one_2.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_one_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_two_1.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_two_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_two_2.png b/code/DocsSample/ArkWeb/ManageWebPageInteracts/screenshots/SetSKBMode_two_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/app.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/app.json5 old mode 100755 new mode 100644 index 9e9d3da1dc..b0c7bc7d94 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/app.json5 @@ -1,25 +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.acceleratepageaccess", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.acceleratepageaccess", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 44391627e8..09408da82d --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AcceleratePageAccess" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AcceleratePageAccess" + } + ] +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/README.md b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/build-profile.json5 old mode 100755 new mode 100644 index 5ff7c51f91..eb8b316a35 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/build-profile.json5 @@ -1,100 +1,100 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry1", - "srcPath": "./entry1", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry2", - "srcPath": "./entry2", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry3", - "srcPath": "./entry3", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry4", - "srcPath": "./entry4", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry1", + "srcPath": "./entry1", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry2", + "srcPath": "./entry2", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry3", + "srcPath": "./entry3", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry4", + "srcPath": "./entry4", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/code-linter.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b865efd626..82e98bec44 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 7aaec79f5a..29feaca766 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/module.json5 old mode 100755 new mode 100644 index 81751d0bc4..e9db80c0ac --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/oh-package.json5 old mode 100755 new mode 100644 index 4628f905e0..c4e8768835 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/oh-package.json5 @@ -1,25 +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": "entry1", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "entry1", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/entry1ability/Entry1Ability.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/entry1ability/Entry1Ability.ets old mode 100755 new mode 100644 index 135ea1f3a0..3377c9ffae --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/entry1ability/Entry1Ability.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/entry1ability/Entry1Ability.ets @@ -1,66 +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. - */ -// [Start initialize_kernel_in_onCreate_and_pre_connect_to_homepage] -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; -import { webview } from '@kit.ArkWeb'; - -export default class Entry1Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - console.log('EntryAbility onCreate'); - webview.WebviewController.initializeWebEngine(); - // 预连接时,需要將'https://www.example.com'替换成真实要访问的网站地址。 - - webview.WebviewController.prepareForPageLoad(this.context.resourceManager.getStringSync($r('app.string.web_path_one')), true, 2); - AppStorage.setOrCreate('abilityWant', want); - console.log('EntryAbility onCreate done'); - } - - // [StartExclude initialize_kernel_in_onCreate_and_pre_connect_to_homepage] - 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'); - } - // [EndExclude initialize_kernel_in_onCreate_and_pre_connect_to_homepage] -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start initialize_kernel_in_onCreate_and_pre_connect_to_homepage] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; + +export default class Entry1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + console.log('EntryAbility onCreate'); + webview.WebviewController.initializeWebEngine(); + // 预连接时,需要將'https://www.example.com'替换成真实要访问的网站地址。 + + webview.WebviewController.prepareForPageLoad(this.context.resourceManager.getStringSync($r('app.string.web_path_one')), true, 2); + AppStorage.setOrCreate('abilityWant', want); + console.log('EntryAbility onCreate done'); + } + + // [StartExclude initialize_kernel_in_onCreate_and_pre_connect_to_homepage] + 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'); + } + // [EndExclude initialize_kernel_in_onCreate_and_pre_connect_to_homepage] +} // [End initialize_kernel_in_onCreate_and_pre_connect_to_homepage] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/module.json5 old mode 100755 new mode 100644 index 465872d230..5303c59d21 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/module.json5 @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry1", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Entry1Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry1Ability", - "srcEntry": "./ets/entry1ability/Entry1Ability.ets", - "description": "$string:Entry1Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry1Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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": "entry1", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Entry1Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry1Ability", + "srcEntry": "./ets/entry1ability/Entry1Ability.ets", + "description": "$string:Entry1Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry1Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/module.json5 old mode 100755 new mode 100644 index b463f808d1..a8392c11cf --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry1_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry1_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/oh-package.json5 old mode 100755 new mode 100644 index bcb70ff878..6f8ebfffe8 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/oh-package.json5 @@ -1,25 +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": "entry2", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "entry2", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/entry2ability/Entry2Ability.ets old mode 100755 new mode 100644 index cf7edaa3ca..dab8f3ea72 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/entry2ability/Entry2Ability.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/entry2ability/Entry2Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Entry2Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Entry2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Prefetching.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Prefetching.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets old mode 100755 new mode 100644 index 3a77ecbda2..7440060a2f --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -//[Start prefetch_post_request_on_page_end_clear_cache] -import { webview } from '@kit.ArkWeb'; -// [StartExclude prefetch_post_request_on_page_end_clear_cache] -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} -// [EndExclude prefetch_post_request_on_page_end_clear_cache] -@Entry -@Component -struct WebComponent { - webviewController: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Web({ src: $r('app.string.web_path'), controller: this.webviewController}) - .onAppear(() => { - // 预获取时,需要將'https://www.example1.com/post?e=f&g=h'替换成真实要访问的网站地址。 - webview.WebviewController.prefetchResource( - {url:resourceToString($r('app.string.post_path')), - method:'POST', - formData:'a=x&b=y',}, - [{headerKey:'c', - headerValue:'z',},], - 'KeyX', 500); - }) - .onPageEnd(() => { - // 清除后续不再使用的预获取资源缓存。 - webview.WebviewController.clearPrefetchedResource(['KeyX',]); - }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +//[Start prefetch_post_request_on_page_end_clear_cache] +import { webview } from '@kit.ArkWeb'; +// [StartExclude prefetch_post_request_on_page_end_clear_cache] +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} +// [EndExclude prefetch_post_request_on_page_end_clear_cache] +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: $r('app.string.web_path'), controller: this.webviewController}) + .onAppear(() => { + // 预获取时,需要將'https://www.example1.com/post?e=f&g=h'替换成真实要访问的网站地址。 + webview.WebviewController.prefetchResource( + {url:resourceToString($r('app.string.post_path')), + method:'POST', + formData:'a=x&b=y',}, + [{headerKey:'c', + headerValue:'z',},], + 'KeyX', 500); + }) + .onPageEnd(() => { + // 清除后续不再使用的预获取资源缓存。 + webview.WebviewController.clearPrefetchedResource(['KeyX',]); + }) + } + } +} //[End prefetch_post_request_on_page_end_clear_cache] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_three.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_three.ets old mode 100755 new mode 100644 index 27f0bd71d3..b5b280f4b5 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_three.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_three.ets @@ -1,43 +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. - */ -// [Start on_page_end_trigger_prefetch_post_request_access_page] -import { webview } from '@kit.ArkWeb'; -// [StartExclude on_page_end_trigger_prefetch_post_request_access_page] -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} -// [EndExclude on_page_end_trigger_prefetch_post_request_access_page] -@Entry -@Component -struct WebComponent { - webviewController: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Web({ src: $r('app.string.web_path'), controller: this.webviewController}) - .onPageEnd(() => { - // 预获取时,需要將'https://www.example1.com/post?e=f&g=h'替换成真实要访问的网站地址。 - webview.WebviewController.prefetchResource( - {url:resourceToString($r('app.string.web_path')) + '/post?e=f&g=h', - method:'POST', - formData:'a=x&b=y',}, - [{headerKey:'c', - headerValue:'z',},], - 'KeyX', 500); - }) - } - } -} -//[End on_page_end_trigger_prefetch_post_request_access_page] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start on_page_end_trigger_prefetch_post_request_access_page] +import { webview } from '@kit.ArkWeb'; +// [StartExclude on_page_end_trigger_prefetch_post_request_access_page] +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} +// [EndExclude on_page_end_trigger_prefetch_post_request_access_page] +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: $r('app.string.web_path'), controller: this.webviewController}) + .onPageEnd(() => { + // 预获取时,需要將'https://www.example1.com/post?e=f&g=h'替换成真实要访问的网站地址。 + webview.WebviewController.prefetchResource( + {url:resourceToString($r('app.string.web_path')) + '/post?e=f&g=h', + method:'POST', + formData:'a=x&b=y',}, + [{headerKey:'c', + headerValue:'z',},], + 'KeyX', 500); + }) + } + } +} +//[End on_page_end_trigger_prefetch_post_request_access_page] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_two.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_two.ets old mode 100755 new mode 100644 index c0ebd33ed7..bf09aea7ff --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_two.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_two.ets @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start initialize_kernel_in_onCreate_and_pre_fetch_post_request] -import { webview } from '@kit.ArkWeb'; - -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} - -@Entry -@Component -struct WebComponent { - webviewController: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Web({ src: $r('app.string.web_path'), controller: this.webviewController}) - .onPageEnd(() => { - // 预获取时,需要將'https://www.example1.com/post?e=f&g=h'替换成真实要访问的网站地址。 - webview.WebviewController.prefetchResource( - {url:resourceToString($r('app.string.post_path')), - method:'POST', - formData:'a=x&b=y',}, - [{headerKey:'c', - headerValue:'z',},], - 'KeyX', 500); - }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start initialize_kernel_in_onCreate_and_pre_fetch_post_request] +import { webview } from '@kit.ArkWeb'; + +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} + +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: $r('app.string.web_path'), controller: this.webviewController}) + .onPageEnd(() => { + // 预获取时,需要將'https://www.example1.com/post?e=f&g=h'替换成真实要访问的网站地址。 + webview.WebviewController.prefetchResource( + {url:resourceToString($r('app.string.post_path')), + method:'POST', + formData:'a=x&b=y',}, + [{headerKey:'c', + headerValue:'z',},], + 'KeyX', 500); + }) + } + } +} // [End initialize_kernel_in_onCreate_and_pre_fetch_post_request] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/module.json5 old mode 100755 new mode 100644 index fc96afe421..7c87a975ff --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/module.json5 @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry2", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Entry2Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry2Ability", - "srcEntry": "./ets/entry2ability/Entry2Ability.ets", - "description": "$string:Entry2Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry2Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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": "entry2", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Entry2Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry2Ability", + "srcEntry": "./ets/entry2ability/Entry2Ability.ets", + "description": "$string:Entry2Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry2Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 87a1b50487..031b54bde3 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry2_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry2_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/oh-package.json5 old mode 100755 new mode 100644 index 401ea2ff2d..655d244a4e --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/oh-package.json5 @@ -1,25 +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": "entry3", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "entry3", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/entry3ability/Entry3Ability.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/entry3ability/Entry3Ability.ets old mode 100755 new mode 100644 index 70e9ac6ded..407cf0869b --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/entry3ability/Entry3Ability.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/entry3ability/Entry3Ability.ets @@ -1,66 +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. - */ - -// [Start save_the_uiContext_to_localstorage_in_entry_ability] -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; -// [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] -import { hilog } from '@kit.PerformanceAnalysisKit'; -// [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] - -const localStorage: LocalStorage = new LocalStorage('uiContext'); - -export default class Entry3Ability extends UIAbility { - public storage: LocalStorage = localStorage; - // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] - // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] - onWindowStageCreate(windowStage: window.WindowStage) { - windowStage.loadContent('pages/Index', this.storage, (err, data) => { - if (err.code) { - return; - } - - this.storage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext()); - }); - } - - // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] - // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] - // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } - // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] -} -// [End save_the_uiContext_to_localstorage_in_entry_ability] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start save_the_uiContext_to_localstorage_in_entry_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +// [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] +import { hilog } from '@kit.PerformanceAnalysisKit'; +// [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] + +const localStorage: LocalStorage = new LocalStorage('uiContext'); + +export default class Entry3Ability extends UIAbility { + public storage: LocalStorage = localStorage; + // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] + // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] + onWindowStageCreate(windowStage: window.WindowStage) { + windowStage.loadContent('pages/Index', this.storage, (err, data) => { + if (err.code) { + return; + } + + this.storage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext()); + }); + } + + // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] + // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] + // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability] + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } + // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability] +} +// [End save_the_uiContext_to_localstorage_in_entry_ability] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/BusinessWebview.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/BusinessWebview.ets old mode 100755 new mode 100644 index b48330fdca..510e596046 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/BusinessWebview.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/BusinessWebview.ets @@ -1,27 +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. - */ - -// [Start write_code_for_business_components] -import { BuilderData } from './DynamicComponent'; - -@Builder -function webBuilder(data: BuilderData) { - // 此处组件可根据业务需要自行扩展 - Web({ src: data.url, controller: data.controller }) - .cacheMode(CacheMode.Default) -} - -export const businessWebview = wrapBuilder(webBuilder); +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start write_code_for_business_components] +import { BuilderData } from './DynamicComponent'; + +@Builder +function webBuilder(data: BuilderData) { + // 此处组件可根据业务需要自行扩展 + Web({ src: data.url, controller: data.controller }) + .cacheMode(CacheMode.Default) +} + +export const businessWebview = wrapBuilder(webBuilder); // [End write_code_for_business_components] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/DynamicComponent.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/DynamicComponent.ets old mode 100755 new mode 100644 index d4322b01d0..d0fc29ad85 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/DynamicComponent.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/DynamicComponent.ets @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start underlying_code_required_for_dynamic_components] -import { NodeController, BuilderNode, FrameNode, UIContext } from '@kit.ArkUI'; - -export interface BuilderData { - url: string; - controller: WebviewController; -} - -const storage = LocalStorage.getShared(); - -export class NodeControllerImpl extends NodeController { - private rootNode: BuilderNode | null = null; - private wrappedBuilder: WrappedBuilder | null = null; - - constructor(wrappedBuilder: WrappedBuilder) { - super(); - this.wrappedBuilder = wrappedBuilder; - } - - makeNode(): FrameNode | null { - if (this.rootNode != null) { - return this.rootNode.getFrameNode(); - } - return null; - } - - initWeb(url: string, controller: WebviewController) { - if(this.rootNode != null) { - return; - } - - const uiContext: UIContext = storage.get('uiContext') as UIContext; - if (!uiContext) { - return; - } - this.rootNode = new BuilderNode(uiContext); - this.rootNode.build(this.wrappedBuilder, { url: url, controller: controller }); - } -} - -export const createNode = (wrappedBuilder: WrappedBuilder, data: BuilderData) => { - const baseNode = new NodeControllerImpl(wrappedBuilder); - baseNode.initWeb(data.url, data.controller); - return baseNode; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start underlying_code_required_for_dynamic_components] +import { NodeController, BuilderNode, FrameNode, UIContext } from '@kit.ArkUI'; + +export interface BuilderData { + url: string; + controller: WebviewController; +} + +const storage = LocalStorage.getShared(); + +export class NodeControllerImpl extends NodeController { + private rootNode: BuilderNode | null = null; + private wrappedBuilder: WrappedBuilder | null = null; + + constructor(wrappedBuilder: WrappedBuilder) { + super(); + this.wrappedBuilder = wrappedBuilder; + } + + makeNode(): FrameNode | null { + if (this.rootNode != null) { + return this.rootNode.getFrameNode(); + } + return null; + } + + initWeb(url: string, controller: WebviewController) { + if(this.rootNode != null) { + return; + } + + const uiContext: UIContext = storage.get('uiContext') as UIContext; + if (!uiContext) { + return; + } + this.rootNode = new BuilderNode(uiContext); + this.rootNode.build(this.wrappedBuilder, { url: url, controller: controller }); + } +} + +export const createNode = (wrappedBuilder: WrappedBuilder, data: BuilderData) => { + const baseNode = new NodeControllerImpl(wrappedBuilder); + baseNode.initWeb(data.url, data.controller); + return baseNode; +} // [End underlying_code_required_for_dynamic_components] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileConfig.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileConfig.ets old mode 100755 new mode 100644 index 029801052b..75d2750e83 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileConfig.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileConfig.ets @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start compile_resource_allocation_information] -import { webview } from '@kit.ArkWeb' - -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} - -export interface Config { - url: string, - localPath: string, // 本地资源路径 - options: webview.CacheOptions -} - -export let configs: Config[] = [ - { - url: resourceToString($r('app.string.web_path')), - localPath: 'example.js', - options: { - responseHeaders: [ - { headerKey: 'E-Tag', headerValue: 'aWO42N9P9dG/5xqYQCxsx+vDOoU='}, - { headerKey: 'Last-Modified', headerValue: 'Wed, 21 Mar 2025 10:38:41 GMT'} - ] - } - } -] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start compile_resource_allocation_information] +import { webview } from '@kit.ArkWeb' + +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} + +export interface Config { + url: string, + localPath: string, // 本地资源路径 + options: webview.CacheOptions +} + +export let configs: Config[] = [ + { + url: resourceToString($r('app.string.web_path')), + localPath: 'example.js', + options: { + responseHeaders: [ + { headerKey: 'E-Tag', headerValue: 'aWO42N9P9dG/5xqYQCxsx+vDOoU='}, + { headerKey: 'Last-Modified', headerValue: 'Wed, 21 Mar 2025 10:38:41 GMT'} + ] + } + } +] // [End compile_resource_allocation_information] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileWebview.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileWebview.ets old mode 100755 new mode 100644 index 20538a0fe6..6be2676507 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileWebview.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileWebview.ets @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start read_local_js_resource_from_rawfile_dir_via_file_api] -import { BuilderData } from './DynamicComponent'; -import { Config, configs } from './PrecompileConfig'; - -@Builder -function webBuilder(data: BuilderData) { - Web({ src: data.url, controller: data.controller }) - .onControllerAttached(() => { - precompile(data.controller, configs); - }) - .fileAccess(true) -} - -export const precompileWebview = wrapBuilder(webBuilder); - -export const precompile = async (controller: WebviewController, configs: Array) => { - for (const config of configs) { - let content = await readRawFile(config.localPath); - - try { - controller.precompileJavaScript(config.url, content, config.options) - .then(errCode => { - console.error('precompile successfully! ' + errCode); - }).catch((errCode: number) => { - console.error('precompile failed. ' + errCode); - }); - } catch (err) { - console.error('precompile failed. ' + err.code + ' ' + err.message); - } - } -} - -async function readRawFile(path: string) { - try { - return await getContext().resourceManager.getRawFileContent(path);; - } catch (err) { - return new Uint8Array(0); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start read_local_js_resource_from_rawfile_dir_via_file_api] +import { BuilderData } from './DynamicComponent'; +import { Config, configs } from './PrecompileConfig'; + +@Builder +function webBuilder(data: BuilderData) { + Web({ src: data.url, controller: data.controller }) + .onControllerAttached(() => { + precompile(data.controller, configs); + }) + .fileAccess(true) +} + +export const precompileWebview = wrapBuilder(webBuilder); + +export const precompile = async (controller: WebviewController, configs: Array) => { + for (const config of configs) { + let content = await readRawFile(config.localPath); + + try { + controller.precompileJavaScript(config.url, content, config.options) + .then(errCode => { + console.error('precompile successfully! ' + errCode); + }).catch((errCode: number) => { + console.error('precompile failed. ' + errCode); + }); + } catch (err) { + console.error('precompile failed. ' + err.code + ' ' + err.message); + } + } +} + +async function readRawFile(path: string) { + try { + return await getContext().resourceManager.getRawFileContent(path);; + } catch (err) { + return new Uint8Array(0); + } +} // [End read_local_js_resource_from_rawfile_dir_via_file_api] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/module.json5 old mode 100755 new mode 100644 index db35d4bff4..5566c38cae --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/module.json5 @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry3", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Entry3Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry3Ability", - "srcEntry": "./ets/entry3ability/Entry3Ability.ets", - "description": "$string:Entry3Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry3Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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": "entry3", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Entry3Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry3Ability", + "srcEntry": "./ets/entry3ability/Entry3Ability.ets", + "description": "$string:Entry3Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry3Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9fec93324f..edaba8aaab --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry3_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry3_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/oh-package.json5 old mode 100755 new mode 100644 index 0291d967fe..ac50b7be86 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/oh-package.json5 @@ -1,25 +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": "entry4", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "entry4", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets old mode 100755 new mode 100644 index 24119194e2..8ab5d17a3c --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets @@ -1,66 +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. - */ - -// [Start save_uiContext_to_localstorage_in_entry_ability] -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; -// [StartExclude save_uiContext_to_localstorage_in_entry_ability] -import { hilog } from '@kit.PerformanceAnalysisKit'; -// [EndExclude save_uiContext_to_localstorage_in_entry_ability] - -const localStorage: LocalStorage = new LocalStorage('uiContext'); - -export default class Entry4Ability extends UIAbility { - public storage: LocalStorage = localStorage; - // [StartExclude save_uiContext_to_localstorage_in_entry_ability] - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - // [EndExclude save_uiContext_to_localstorage_in_entry_ability] - - // [StartExclude save_uiContext_to_localstorage_in_entry_ability] - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - // [EndExclude save_uiContext_to_localstorage_in_entry_ability] - onWindowStageCreate(windowStage: window.WindowStage) { - windowStage.loadContent('pages/Index', this.storage, (err, data) => { - if (err.code) { - return; - } - - this.storage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext()); - }); - } - // [StartExclude save_uiContext_to_localstorage_in_entry_ability] - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - // [EndExclude save_uiContext_to_localstorage_in_entry_ability] - // [StartExclude save_uiContext_to_localstorage_in_entry_ability] - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - // [EndExclude save_uiContext_to_localstorage_in_entry_ability] - // [StartExclude save_uiContext_to_localstorage_in_entry_ability] - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } - // [EndExclude save_uiContext_to_localstorage_in_entry_ability] -} -// [End save_uiContext_to_localstorage_in_entry_ability] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start save_uiContext_to_localstorage_in_entry_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +// [StartExclude save_uiContext_to_localstorage_in_entry_ability] +import { hilog } from '@kit.PerformanceAnalysisKit'; +// [EndExclude save_uiContext_to_localstorage_in_entry_ability] + +const localStorage: LocalStorage = new LocalStorage('uiContext'); + +export default class Entry4Ability extends UIAbility { + public storage: LocalStorage = localStorage; + // [StartExclude save_uiContext_to_localstorage_in_entry_ability] + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + // [EndExclude save_uiContext_to_localstorage_in_entry_ability] + + // [StartExclude save_uiContext_to_localstorage_in_entry_ability] + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + // [EndExclude save_uiContext_to_localstorage_in_entry_ability] + onWindowStageCreate(windowStage: window.WindowStage) { + windowStage.loadContent('pages/Index', this.storage, (err, data) => { + if (err.code) { + return; + } + + this.storage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext()); + }); + } + // [StartExclude save_uiContext_to_localstorage_in_entry_ability] + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + // [EndExclude save_uiContext_to_localstorage_in_entry_ability] + // [StartExclude save_uiContext_to_localstorage_in_entry_ability] + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + // [EndExclude save_uiContext_to_localstorage_in_entry_ability] + // [StartExclude save_uiContext_to_localstorage_in_entry_ability] + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } + // [EndExclude save_uiContext_to_localstorage_in_entry_ability] +} +// [End save_uiContext_to_localstorage_in_entry_ability] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/BusinessWebview.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/BusinessWebview.ets old mode 100755 new mode 100644 index 9bc8a28fae..0f37c63bfd --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/BusinessWebview.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/BusinessWebview.ets @@ -1,26 +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. - */ -// [Start write_code_for_business_components] -import { BuilderData } from './DynamicComponent'; - -@Builder -function webBuilder(data: BuilderData) { - // 此处组件可根据业务需要自行扩展 - Web({ src: data.url, controller: data.controller }) - .cacheMode(CacheMode.Default) -} - -export const businessWebview = wrapBuilder(webBuilder); +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start write_code_for_business_components] +import { BuilderData } from './DynamicComponent'; + +@Builder +function webBuilder(data: BuilderData) { + // 此处组件可根据业务需要自行扩展 + Web({ src: data.url, controller: data.controller }) + .cacheMode(CacheMode.Default) +} + +export const businessWebview = wrapBuilder(webBuilder); // [End write_code_for_business_components] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/DynamicComponent.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/DynamicComponent.ets old mode 100755 new mode 100644 index d4322b01d0..d0fc29ad85 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/DynamicComponent.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/DynamicComponent.ets @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start underlying_code_required_for_dynamic_components] -import { NodeController, BuilderNode, FrameNode, UIContext } from '@kit.ArkUI'; - -export interface BuilderData { - url: string; - controller: WebviewController; -} - -const storage = LocalStorage.getShared(); - -export class NodeControllerImpl extends NodeController { - private rootNode: BuilderNode | null = null; - private wrappedBuilder: WrappedBuilder | null = null; - - constructor(wrappedBuilder: WrappedBuilder) { - super(); - this.wrappedBuilder = wrappedBuilder; - } - - makeNode(): FrameNode | null { - if (this.rootNode != null) { - return this.rootNode.getFrameNode(); - } - return null; - } - - initWeb(url: string, controller: WebviewController) { - if(this.rootNode != null) { - return; - } - - const uiContext: UIContext = storage.get('uiContext') as UIContext; - if (!uiContext) { - return; - } - this.rootNode = new BuilderNode(uiContext); - this.rootNode.build(this.wrappedBuilder, { url: url, controller: controller }); - } -} - -export const createNode = (wrappedBuilder: WrappedBuilder, data: BuilderData) => { - const baseNode = new NodeControllerImpl(wrappedBuilder); - baseNode.initWeb(data.url, data.controller); - return baseNode; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start underlying_code_required_for_dynamic_components] +import { NodeController, BuilderNode, FrameNode, UIContext } from '@kit.ArkUI'; + +export interface BuilderData { + url: string; + controller: WebviewController; +} + +const storage = LocalStorage.getShared(); + +export class NodeControllerImpl extends NodeController { + private rootNode: BuilderNode | null = null; + private wrappedBuilder: WrappedBuilder | null = null; + + constructor(wrappedBuilder: WrappedBuilder) { + super(); + this.wrappedBuilder = wrappedBuilder; + } + + makeNode(): FrameNode | null { + if (this.rootNode != null) { + return this.rootNode.getFrameNode(); + } + return null; + } + + initWeb(url: string, controller: WebviewController) { + if(this.rootNode != null) { + return; + } + + const uiContext: UIContext = storage.get('uiContext') as UIContext; + if (!uiContext) { + return; + } + this.rootNode = new BuilderNode(uiContext); + this.rootNode.build(this.wrappedBuilder, { url: url, controller: controller }); + } +} + +export const createNode = (wrappedBuilder: WrappedBuilder, data: BuilderData) => { + const baseNode = new NodeControllerImpl(wrappedBuilder); + baseNode.initWeb(data.url, data.controller); + return baseNode; +} // [End underlying_code_required_for_dynamic_components] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/InjectWebview.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/InjectWebview.ets old mode 100755 new mode 100644 index 8d61a652b6..9ccca1250e --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/InjectWebview.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/InjectWebview.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start local_resources_content_read_from_rawfile_directory_by_file_operation] -import { webview } from '@kit.ArkWeb'; -import { resourceConfigs } from './Resource'; -import { BuilderData } from './DynamicComponent'; - -@Builder -function webBuilder(data: BuilderData) { - Web({ src: data.url, controller: data.controller }) - .onControllerAttached(async () => { - try { - data.controller.injectOfflineResources(await getData ()); - } catch (err) { - console.error('error: ' + err.code + ' ' + err.message); - } - }) - .fileAccess(true) -} - -export const injectWebview = wrapBuilder(webBuilder); - -export async function getData() { - const resourceMapArr: webview.OfflineResourceMap[] = []; - - // 读取配置,从rawfile目录中读取文件内容 - for (let config of resourceConfigs) { - let buf: Uint8Array = new Uint8Array(0); - if (config.localPath) { - buf = await readRawFile(config.localPath); - } - - resourceMapArr.push({ - urlList: config.urlList, - resource: buf, - responseHeaders: config.responseHeaders, - type: config.type, - }) - } - - return resourceMapArr; -} - -export async function readRawFile(url: string) { - try { - return await getContext().resourceManager.getRawFileContent(url); - } catch (err) { - return new Uint8Array(0); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start local_resources_content_read_from_rawfile_directory_by_file_operation] +import { webview } from '@kit.ArkWeb'; +import { resourceConfigs } from './Resource'; +import { BuilderData } from './DynamicComponent'; + +@Builder +function webBuilder(data: BuilderData) { + Web({ src: data.url, controller: data.controller }) + .onControllerAttached(async () => { + try { + data.controller.injectOfflineResources(await getData ()); + } catch (err) { + console.error('error: ' + err.code + ' ' + err.message); + } + }) + .fileAccess(true) +} + +export const injectWebview = wrapBuilder(webBuilder); + +export async function getData() { + const resourceMapArr: webview.OfflineResourceMap[] = []; + + // 读取配置,从rawfile目录中读取文件内容 + for (let config of resourceConfigs) { + let buf: Uint8Array = new Uint8Array(0); + if (config.localPath) { + buf = await readRawFile(config.localPath); + } + + resourceMapArr.push({ + urlList: config.urlList, + resource: buf, + responseHeaders: config.responseHeaders, + type: config.type, + }) + } + + return resourceMapArr; +} + +export async function readRawFile(url: string) { + try { + return await getContext().resourceManager.getRawFileContent(url); + } catch (err) { + return new Uint8Array(0); + } +} // [End local_resources_content_read_from_rawfile_directory_by_file_operation] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Resource.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Resource.ets old mode 100755 new mode 100644 index 99f5dc7fae..0c7ab57171 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Resource.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Resource.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start compile_resource_allocation_information] -import { webview } from '@kit.ArkWeb'; -// [StartExclude compile_resource_allocation_information] -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} -// [EndExclude compile_resource_allocation_information] -export interface ResourceConfig { - urlList: Array, - type: webview.OfflineResourceType, - responseHeaders: Array
, - localPath: string, // 本地资源存放在rawfile目录下的路径 -} - -export const resourceConfigs: ResourceConfig[] = [ - { - localPath: 'example.png', - urlList: [ - resourceToString($r('app.string.web_path')), - resourceToString($r('app.string.web_path')) + 'path1/example.png', - resourceToString($r('app.string.web_path')) + 'path2/example.png', - ], - type: webview.OfflineResourceType.IMAGE, - responseHeaders: [ - { headerKey: 'Cache-Control', headerValue: 'max-age=1000' }, - { headerKey: 'Content-Type', headerValue: 'image/png' }, - ] - }, - { - localPath: 'example.js', - urlList: [ // 仅提供一个url,这个url既作为资源的源,也作为资源的网络请求地址 - resourceToString($r('app.string.web_path_one')), - ], - type: webview.OfflineResourceType.CLASSIC_JS, - responseHeaders: [ - // 以 - + + + + + + + + + +
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+ + + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/ohosTest.md b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_1.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_2.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_two.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_two.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/app.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/app.json5 old mode 100755 new mode 100644 index ba45a3b3a9..a0839764e9 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/app.json5 @@ -1,25 +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.loadpages", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.loadpages", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 9b49e3610e..20d3fed609 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "LoadPages" - } - ] +{ + "string": [ + { + "name": "app_name", + "value": "LoadPages" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/README.md b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/build-profile.json5 old mode 100755 new mode 100644 index 87d40a385e..7a9c78377e --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/build-profile.json5 @@ -1,52 +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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/code-linter.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b865efd626..82e98bec44 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 7aaec79f5a..29feaca766 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/GlobalContext.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/GlobalContext.ets old mode 100755 new mode 100644 index a87397789e..4e388d7c07 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/GlobalContext.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/GlobalContext.ets @@ -1,37 +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. - */ - -// [Start after_load_complete_call_to_change_page] -export class GlobalContext { - private constructor() {} - private static instance: GlobalContext; - private _objects = new Map(); - - public static getContext(): GlobalContext { - if (!GlobalContext.instance) { - GlobalContext.instance = new GlobalContext(); - } - return GlobalContext.instance; - } - - getObject(value: string): Object | undefined { - return this._objects.get(value); - } - - setObject(key: string, objectClass: Object): void { - this._objects.set(key, objectClass); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start after_load_complete_call_to_change_page] +export class GlobalContext { + private constructor() {} + private static instance: GlobalContext; + private _objects = new Map(); + + public static getContext(): GlobalContext { + if (!GlobalContext.instance) { + GlobalContext.instance = new GlobalContext(); + } + return GlobalContext.instance; + } + + getObject(value: string): Object | undefined { + return this._objects.get(value); + } + + setObject(key: string, objectClass: Object): void { + this._objects.set(key, objectClass); + } +} // [End after_load_complete_call_to_change_page] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets old mode 100755 new mode 100644 index 2545aea0f8..7265103ddf --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start load_local_page_file_in_sandbox_path] -import { webview } from '@kit.ArkWeb'; -import { GlobalContext } from './GlobalContext'; - -let url = 'file://' + GlobalContext.getContext().getObject('filesDir') + '/index.html'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Text('loading success'); - // 加载沙箱路径文件。 - Web({ src: url, controller: this.controller }); - } - } -} -// [End load_local_page_file_in_sandbox_path] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start load_local_page_file_in_sandbox_path] +import { webview } from '@kit.ArkWeb'; +import { GlobalContext } from './GlobalContext'; + +let url = 'file://' + GlobalContext.getContext().getObject('filesDir') + '/index.html'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Text('loading success'); + // 加载沙箱路径文件。 + Web({ src: url, controller: this.controller }); + } + } +} +// [End load_local_page_file_in_sandbox_path] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets old mode 100755 new mode 100644 index 7e78e47a05..208359c5f0 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start web_components_load_html_strings_by_data_url] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - htmlStr: string = 'data:text/html, Source:
source
'; - - build() { - Column() { - // 组件创建时,加载htmlStr - Web({ src: this.htmlStr, controller: this.controller }); - } - } -} -// [End web_components_load_html_strings_by_data_url] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start web_components_load_html_strings_by_data_url] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + htmlStr: string = 'data:text/html, Source:
source
'; + + build() { + Column() { + // 组件创建时,加载htmlStr + Web({ src: this.htmlStr, controller: this.controller }); + } + } +} +// [End web_components_load_html_strings_by_data_url] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets old mode 100755 new mode 100644 index ed142efe47..cc56f8160a --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start devs_load_page_fragments_for_quick_loading] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Button('loadData') - .onClick(() => { - try { - // 点击按钮时,通过loadData,加载HTML格式的文本数据 - this.controller.loadData( - 'Source:
source
', - 'text/html', - 'UTF-8' - ); - } catch (error) { - console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - // 组件创建时,加载www.example.com - Web({ src: 'www.example.com', controller: this.controller }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start devs_load_page_fragments_for_quick_loading] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('loadData') + .onClick(() => { + try { + // 点击按钮时,通过loadData,加载HTML格式的文本数据 + this.controller.loadData( + 'Source:
source
', + 'text/html', + 'UTF-8' + ); + } catch (error) { + console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + // 组件创建时,加载www.example.com + Web({ src: 'www.example.com', controller: this.controller }) + } + } +} // [End devs_load_page_fragments_for_quick_loading] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets old mode 100755 new mode 100644 index a09d901e5a..781bbe446f --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// [Start after_load_complete_call_to_change_page] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Button('loadUrl') - .onClick(() => { - try { - // 点击按钮时,通过loadUrl,跳转到local1.html - this.controller.loadUrl($rawfile('local1.html')); - } catch (error) { - console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - // 组件创建时,通过$rawfile加载本地文件local.html - Web({ src: $rawfile('local.html'), controller: this.controller }); - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start after_load_complete_call_to_change_page] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('loadUrl') + .onClick(() => { + try { + // 点击按钮时,通过loadUrl,跳转到local1.html + this.controller.loadUrl($rawfile('local1.html')); + } catch (error) { + console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + // 组件创建时,通过$rawfile加载本地文件local.html + Web({ src: $rawfile('local.html'), controller: this.controller }); + } + } +} // [End after_load_complete_call_to_change_page] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets old mode 100755 new mode 100644 index bd01e1ff1c..e1bb080555 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start use_load_interface_to_show_web_changes] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Button('loadUrl') - .onClick(() => { - try { - // 点击按钮时,通过loadUrl,跳转到www.example1.com - this.controller.loadUrl('www.example1.com'); - } catch (error) { - console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - // 组件创建时,加载www.example.com - Web({ src: 'www.example.com', controller: this.controller }); - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start use_load_interface_to_show_web_changes] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('loadUrl') + .onClick(() => { + try { + // 点击按钮时,通过loadUrl,跳转到www.example1.com + this.controller.loadUrl('www.example1.com'); + } catch (error) { + console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + // 组件创建时,加载www.example.com + Web({ src: 'www.example.com', controller: this.controller }); + } + } +} // [End use_load_interface_to_show_web_changes] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/module.json5 old mode 100755 new mode 100644 index 773b91ff67..ee18f9ce4f --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions":[ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions":[ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html old mode 100755 new mode 100644 index 7c614d61c1..4e79563963 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html @@ -1,21 +1,21 @@ - - - - - -

Hello World

- - + + + + + +

Hello World

+ + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local1.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local1.html old mode 100755 new mode 100644 index 9287b82f7a..5b3b0b03bb --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local1.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local1.html @@ -1,21 +1,21 @@ - - - - - -

This is local1 page

- - + + + + + +

This is local1 page

+ + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/ohosTest.md b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_one.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_one.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_two.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_two.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_1.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_2.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_1.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_2.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_1.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_2.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/app.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/app.json5 old mode 100755 new mode 100644 index 92cd9950ec..829e8ba122 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/app.json5 @@ -1,25 +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.managepageredirectnav", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.managepageredirectnav", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index d63596ddd9..f2843105d1 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ManagePageRedirectNav" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ManagePageRedirectNav" + } + ] +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/README.md b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/build-profile.json5 old mode 100755 new mode 100644 index 87d40a385e..7a9c78377e --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/build-profile.json5 @@ -1,52 +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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/code-linter.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index f7776d248a..23a5f21890 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/CrossApplicationRedirection.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/CrossApplicationRedirection.ets old mode 100755 new mode 100644 index fcabd906d8..a449c95a90 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/CrossApplicationRedirection.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/CrossApplicationRedirection.ets @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { webview } from '@kit.ArkWeb'; -import { call } from '@kit.TelephonyKit'; -// [Start click_link_call_html_to_reach_phone_dialing_screen] -@Entry -@Component -struct WebComponent { - webviewController: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Web({ src: $rawfile('call.html'), controller: this.webviewController }) - .onLoadIntercept((event) => { - if (event) { - let url: string = event.data.getRequestUrl(); - // 判断链接是否为拨号链接 - if (url.indexOf('tel://') === 0) { - // 跳转拨号界面 - call.makeCall(url.substring(6), (err) => { - if (!err) { - console.info('make call succeeded.'); - } else { - console.info('make call fail, err is:' + JSON.stringify(err)); - } - }); - return true; - } - } - return false; - }) - } - } -} -//[End click_link_call_html_to_reach_phone_dialing_screen] +/* + * 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 { webview } from '@kit.ArkWeb'; +import { call } from '@kit.TelephonyKit'; +// [Start click_link_call_html_to_reach_phone_dialing_screen] +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: $rawfile('call.html'), controller: this.webviewController }) + .onLoadIntercept((event) => { + if (event) { + let url: string = event.data.getRequestUrl(); + // 判断链接是否为拨号链接 + if (url.indexOf('tel://') === 0) { + // 跳转拨号界面 + call.makeCall(url.substring(6), (err) => { + if (!err) { + console.info('make call succeeded.'); + } else { + console.info('make call fail, err is:' + JSON.stringify(err)); + } + }); + return true; + } + } + return false; + }) + } + } +} +//[End click_link_call_html_to_reach_phone_dialing_screen] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/HistoryNavigati.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/HistoryNavigati.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/PageRedirection.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/PageRedirection.ets old mode 100755 new mode 100644 index 7693f2044b..d57537f43f --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/PageRedirection.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/PageRedirection.ets @@ -1,43 +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. - */ - -import { webview } from '@kit.ArkWeb'; -import { router } from '@kit.ArkUI'; - -// [Start index_load_route_link_to_profile] -@Entry -@Component -struct WebComponent { - webviewController: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - // 资源文件route.html存放路径src/main/resources/rawfile - Web({ src: $rawfile('route.html'), controller: this.webviewController }) - .onLoadIntercept((event) => { - if (event) { - let url: string = event.data.getRequestUrl(); - if (url.indexOf('native://') === 0) { - // 跳转其他界面 - router.pushUrl({ url: url.substring(9) }); - return true; - } - } - return false; - }) - } - } -} +/* + * 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 { webview } from '@kit.ArkWeb'; +import { router } from '@kit.ArkUI'; + +// [Start index_load_route_link_to_profile] +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + // 资源文件route.html存放路径src/main/resources/rawfile + Web({ src: $rawfile('route.html'), controller: this.webviewController }) + .onLoadIntercept((event) => { + if (event) { + let url: string = event.data.getRequestUrl(); + if (url.indexOf('native://') === 0) { + // 跳转其他界面 + router.pushUrl({ url: url.substring(9) }); + return true; + } + } + return false; + }) + } + } +} // [End index_load_route_link_to_profile] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/ProfilePage.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/ProfilePage.ets old mode 100755 new mode 100644 index 59c3c59c95..fa930b9d9c --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/ProfilePage.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/ProfilePage.ets @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start navigate_to_profile_page] -@Entry -@Component -struct ProfilePage { - @State message: string = 'Hello World'; - - build() { - Column() { - Text(this.message) - .fontSize(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. + */ +// [Start navigate_to_profile_page] +@Entry +@Component +struct ProfilePage { + @State message: string = 'Hello World'; + + build() { + Column() { + Text(this.message) + .fontSize(20) + } + } +} // [End navigate_to_profile_page] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/module.json5 old mode 100755 new mode 100644 index 81751d0bc4..e9db80c0ac --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/call.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/call.html old mode 100755 new mode 100644 index f61401cc7f..ea7fea2546 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/call.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/call.html @@ -1,24 +1,24 @@ -/* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - - - - - - - +/* +* 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. +*/ + + + + + + + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/route.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/route.html old mode 100755 new mode 100644 index 5603383333..ecc87a4168 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/route.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/route.html @@ -1,24 +1,24 @@ -/* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - - - - - - - +/* +* 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. +*/ + + + + + + + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/ohosTest.md b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_1.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_2.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_1.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_2.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_1.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_2.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/app.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/app.json5 old mode 100755 new mode 100644 index bb62a8d4a9..e5c664911c --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/app.json5 @@ -1,25 +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.netreqinterceptcachewinops", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.netreqinterceptcachewinops", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 969b8196a3..ac0ab70b4d --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NetReqInterceptCacheWinOps" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "NetReqInterceptCacheWinOps" + } + ] +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/README.md b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/build-profile.json5 old mode 100755 new mode 100644 index 22c5348e27..fa898913bf --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/build-profile.json5 @@ -1,76 +1,76 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry2", - "srcPath": "./entry2", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry3", - "srcPath": "./entry3", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry2", + "srcPath": "./entry2", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry3", + "srcPath": "./entry3", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/code-linter.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/build-profile.json5 old mode 100755 new mode 100644 index 78c972d3cb..3c342f5bdb --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/build-profile.json5 @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "apiType": "stageMode", - "buildOption": { - "externalNativeOptions": { - "abiFilters": ["arm64-v8a", "x86_64", "armeabi-v7a"], - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": { + "abiFilters": ["arm64-v8a", "x86_64", "armeabi-v7a"], + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 7086685aff..1686eb5df7 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.4.1) -project(schemehandler) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_INFO_FILE) - include(${PACKAGE_INFO_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED rawfile_request.cpp hello.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(schemehandler) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_INFO_FILE) + include(${PACKAGE_INFO_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED rawfile_request.cpp hello.cpp) target_link_libraries(entry PUBLIC librawfile.z.so libace_napi.z.so libohweb.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/hello.cpp b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/hello.cpp old mode 100755 new mode 100644 index 1e1319c00b..7ece7e82f1 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/hello.cpp +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/hello.cpp @@ -1,165 +1,165 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start set_intercept_web_module_request_example] -#include "hilog/log.h" -#include "napi/native_api.h" -#include "rawfile_request.h" -#include "rawfile/raw_file_manager.h" -#include "web/arkweb_scheme_handler.h" -#include "web/arkweb_net_error_list.h" - -#undef LOG_TAG -#define LOG_TAG "ss-handler" - -// [Start set_intercept_web_module_request] -ArkWeb_SchemeHandler *g_schemeHandler; -// [StartExclude set_intercept_web_module_request] -ArkWeb_SchemeHandler *g_schemeHandlerForSW; -NativeResourceManager *g_resourceManager; - -// 注册三方协议的配置,需要在Web内核初始化之前调用,否则会注册失败。 -static napi_value RegisterCustomSchemes(napi_env env, napi_callback_info info) -{ - OH_LOG_INFO(LOG_APP, "register custom schemes"); - // [Start register_set_custom_schemes] - OH_ArkWeb_RegisterCustomSchemes("custom", ARKWEB_SCHEME_OPTION_STANDARD | ARKWEB_SCHEME_OPTION_CORS_ENABLED); - OH_ArkWeb_RegisterCustomSchemes("custom-local", ARKWEB_SCHEME_OPTION_LOCAL); - OH_ArkWeb_RegisterCustomSchemes( - "custom-csp-bypassing", ARKWEB_SCHEME_OPTION_CSP_BYPASSING | ARKWEB_SCHEME_OPTION_STANDARD); - OH_ArkWeb_RegisterCustomSchemes("custom-isolated", ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED); - // [End register_set_custom_schemes] - return nullptr; -} - -// 请求开始的回调,在该函数中我们创建一个RawfileRequest来实现对Web内核请求的拦截。 -void OnURLRequestStart(const ArkWeb_SchemeHandler *schemeHandler, - ArkWeb_ResourceRequest *resourceRequest, - const ArkWeb_ResourceHandler *resourceHandler, - bool *intercept) -{ - *intercept = true; - RawfileRequest* request = new RawfileRequest(resourceRequest, resourceHandler, g_resourceManager); - OH_ArkWebResourceRequest_SetUserData(resourceRequest, request); - request->Start(); -} - -// 请求结束的回调,在该函数中我们需要标记RawfileRequest已经结束了,内部不应该再使用ResourceHandler。 -void OnURLRequestStop(const ArkWeb_SchemeHandler *schemeHandler, - const ArkWeb_ResourceRequest *request) -{ - if (!request) { - OH_LOG_ERROR(LOG_APP, "on request stop request is nullptr."); - return; - } - - RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebResourceRequest_GetUserData(request); - if (rawfileRequest) { - rawfileRequest->Stop(); - } -} - -void OnURLRequestStartForSW(const ArkWeb_SchemeHandler *schemeHandler, - ArkWeb_ResourceRequest *resourceRequest, - const ArkWeb_ResourceHandler *resourceHandler, - bool *intercept) -{ - *intercept = true; - RawfileRequest* request = new RawfileRequest(resourceRequest, resourceHandler, g_resourceManager); - OH_ArkWebResourceRequest_SetUserData(resourceRequest, request); - request->Start(); -} - -void OnURLRequestStopForSW(const ArkWeb_SchemeHandler *schemeHandler, - const ArkWeb_ResourceRequest *request) -{ - if (!request) { - OH_LOG_ERROR(LOG_APP, "on request stop request is nullptr."); - return; - } - - RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebResourceRequest_GetUserData(request); - if (rawfileRequest) { - rawfileRequest->Stop(); - } -} - -// 设置SchemeHandler。 -static napi_value SetSchemeHandler(napi_env env, napi_callback_info info) -{ - OH_LOG_INFO(LOG_APP, "set scheme handler"); - // [EndExclude set_intercept_web_module_request] - // [Start set_intercept_web_module_request_custom] - OH_ArkWeb_CreateSchemeHandler(&g_schemeHandler); - OH_ArkWeb_CreateSchemeHandler(&g_schemeHandlerForSW); - - OH_ArkWebSchemeHandler_SetOnRequestStart(g_schemeHandler, OnURLRequestStart); - OH_ArkWebSchemeHandler_SetOnRequestStop(g_schemeHandler, OnURLRequestStop); - - // [StartExclude set_intercept_web_module_request_custom] - OH_ArkWebSchemeHandler_SetOnRequestStart(g_schemeHandlerForSW, OnURLRequestStart); - OH_ArkWebSchemeHandler_SetOnRequestStop(g_schemeHandlerForSW, OnURLRequestStop); - // [EndExclude set_intercept_web_module_request_custom] - - OH_ArkWeb_SetSchemeHandler("custom", "scheme-handler", g_schemeHandler); - OH_ArkWeb_SetSchemeHandler("custom-csp-bypassing", "scheme-handler", g_schemeHandler); - OH_ArkWeb_SetSchemeHandler("custom-isolated", "scheme-handler", g_schemeHandler); - OH_ArkWeb_SetSchemeHandler("custom-local", "scheme-handler", g_schemeHandler); - // [End set_intercept_web_module_request_custom] - OH_ArkWeb_SetSchemeHandler("https", "scheme-handler", g_schemeHandler); - OH_ArkWeb_SetSchemeHandler("http", "scheme-handler", g_schemeHandler); - // [End set_intercept_web_module_request] - - OH_ArkWebServiceWorker_SetSchemeHandler("https", g_schemeHandlerForSW); - return nullptr; -} - -static napi_value InitResourceManager(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value argv[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - g_resourceManager = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); - return nullptr; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"setSchemeHandler", nullptr, SetSchemeHandler, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"initResourceManager", nullptr, InitResourceManager, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"registerCustomSchemes", nullptr, RegisterCustomSchemes, nullptr, nullptr, nullptr, napi_default, nullptr} - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start set_intercept_web_module_request_example] +#include "hilog/log.h" +#include "napi/native_api.h" +#include "rawfile_request.h" +#include "rawfile/raw_file_manager.h" +#include "web/arkweb_scheme_handler.h" +#include "web/arkweb_net_error_list.h" + +#undef LOG_TAG +#define LOG_TAG "ss-handler" + +// [Start set_intercept_web_module_request] +ArkWeb_SchemeHandler *g_schemeHandler; +// [StartExclude set_intercept_web_module_request] +ArkWeb_SchemeHandler *g_schemeHandlerForSW; +NativeResourceManager *g_resourceManager; + +// 注册三方协议的配置,需要在Web内核初始化之前调用,否则会注册失败。 +static napi_value RegisterCustomSchemes(napi_env env, napi_callback_info info) +{ + OH_LOG_INFO(LOG_APP, "register custom schemes"); + // [Start register_set_custom_schemes] + OH_ArkWeb_RegisterCustomSchemes("custom", ARKWEB_SCHEME_OPTION_STANDARD | ARKWEB_SCHEME_OPTION_CORS_ENABLED); + OH_ArkWeb_RegisterCustomSchemes("custom-local", ARKWEB_SCHEME_OPTION_LOCAL); + OH_ArkWeb_RegisterCustomSchemes( + "custom-csp-bypassing", ARKWEB_SCHEME_OPTION_CSP_BYPASSING | ARKWEB_SCHEME_OPTION_STANDARD); + OH_ArkWeb_RegisterCustomSchemes("custom-isolated", ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED); + // [End register_set_custom_schemes] + return nullptr; +} + +// 请求开始的回调,在该函数中我们创建一个RawfileRequest来实现对Web内核请求的拦截。 +void OnURLRequestStart(const ArkWeb_SchemeHandler *schemeHandler, + ArkWeb_ResourceRequest *resourceRequest, + const ArkWeb_ResourceHandler *resourceHandler, + bool *intercept) +{ + *intercept = true; + RawfileRequest* request = new RawfileRequest(resourceRequest, resourceHandler, g_resourceManager); + OH_ArkWebResourceRequest_SetUserData(resourceRequest, request); + request->Start(); +} + +// 请求结束的回调,在该函数中我们需要标记RawfileRequest已经结束了,内部不应该再使用ResourceHandler。 +void OnURLRequestStop(const ArkWeb_SchemeHandler *schemeHandler, + const ArkWeb_ResourceRequest *request) +{ + if (!request) { + OH_LOG_ERROR(LOG_APP, "on request stop request is nullptr."); + return; + } + + RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebResourceRequest_GetUserData(request); + if (rawfileRequest) { + rawfileRequest->Stop(); + } +} + +void OnURLRequestStartForSW(const ArkWeb_SchemeHandler *schemeHandler, + ArkWeb_ResourceRequest *resourceRequest, + const ArkWeb_ResourceHandler *resourceHandler, + bool *intercept) +{ + *intercept = true; + RawfileRequest* request = new RawfileRequest(resourceRequest, resourceHandler, g_resourceManager); + OH_ArkWebResourceRequest_SetUserData(resourceRequest, request); + request->Start(); +} + +void OnURLRequestStopForSW(const ArkWeb_SchemeHandler *schemeHandler, + const ArkWeb_ResourceRequest *request) +{ + if (!request) { + OH_LOG_ERROR(LOG_APP, "on request stop request is nullptr."); + return; + } + + RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebResourceRequest_GetUserData(request); + if (rawfileRequest) { + rawfileRequest->Stop(); + } +} + +// 设置SchemeHandler。 +static napi_value SetSchemeHandler(napi_env env, napi_callback_info info) +{ + OH_LOG_INFO(LOG_APP, "set scheme handler"); + // [EndExclude set_intercept_web_module_request] + // [Start set_intercept_web_module_request_custom] + OH_ArkWeb_CreateSchemeHandler(&g_schemeHandler); + OH_ArkWeb_CreateSchemeHandler(&g_schemeHandlerForSW); + + OH_ArkWebSchemeHandler_SetOnRequestStart(g_schemeHandler, OnURLRequestStart); + OH_ArkWebSchemeHandler_SetOnRequestStop(g_schemeHandler, OnURLRequestStop); + + // [StartExclude set_intercept_web_module_request_custom] + OH_ArkWebSchemeHandler_SetOnRequestStart(g_schemeHandlerForSW, OnURLRequestStart); + OH_ArkWebSchemeHandler_SetOnRequestStop(g_schemeHandlerForSW, OnURLRequestStop); + // [EndExclude set_intercept_web_module_request_custom] + + OH_ArkWeb_SetSchemeHandler("custom", "scheme-handler", g_schemeHandler); + OH_ArkWeb_SetSchemeHandler("custom-csp-bypassing", "scheme-handler", g_schemeHandler); + OH_ArkWeb_SetSchemeHandler("custom-isolated", "scheme-handler", g_schemeHandler); + OH_ArkWeb_SetSchemeHandler("custom-local", "scheme-handler", g_schemeHandler); + // [End set_intercept_web_module_request_custom] + OH_ArkWeb_SetSchemeHandler("https", "scheme-handler", g_schemeHandler); + OH_ArkWeb_SetSchemeHandler("http", "scheme-handler", g_schemeHandler); + // [End set_intercept_web_module_request] + + OH_ArkWebServiceWorker_SetSchemeHandler("https", g_schemeHandlerForSW); + return nullptr; +} + +static napi_value InitResourceManager(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value argv[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + g_resourceManager = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); + return nullptr; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"setSchemeHandler", nullptr, SetSchemeHandler, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initResourceManager", nullptr, InitResourceManager, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"registerCustomSchemes", nullptr, RegisterCustomSchemes, nullptr, nullptr, nullptr, napi_default, nullptr} + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} // [End set_intercept_web_module_request_example] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 5e824d1654..3c11c8b57c --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/napi_init.cpp @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" - -static napi_value Add(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - napi_valuetype valuetype0; - napi_typeof(env, args[0], &valuetype0); - - napi_valuetype valuetype1; - napi_typeof(env, args[1], &valuetype1); - - double value0; - napi_get_value_double(env, args[0], &value0); - - double value1; - napi_get_value_double(env, args[1], &value1); - - napi_value sum; - napi_create_double(env, value0 + value1, &sum); - - return sum; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.cpp b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.cpp old mode 100755 new mode 100644 index 06617760fa..a3ce2921a7 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.cpp +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.cpp @@ -1,289 +1,289 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start intercepted_request_processing_cpp] -#include "rawfile_request.h" -#include "threads.h" - -#include "hilog/log.h" -#include "rawfile/raw_file.h" -#include "rawfile/raw_file_manager.h" - -#undef LOG_TAG -#define LOG_TAG "ss-handler" - -namespace { - -uint8_t g_buffer[1024]; -cnd_t g_httpBodyCnd; -mtx_t g_httpBodyMtx; -const int HTTP_OK = 200; -const int HTTP_NOT_FOUND = 404; -const int BUFFER_SIZE = 1000; - -// HttpBodyStream的读回调。 -void ReadCallback(const ArkWeb_HttpBodyStream *httpBodyStream, uint8_t* buffer, int bytesRead) -{ - OH_LOG_INFO(LOG_APP, "read http body back."); - bool isEof = OH_ArkWebHttpBodyStream_IsEof(httpBodyStream); - if (!isEof && bytesRead != 0) { - memset(buffer, 0, BUFFER_SIZE); - OH_ArkWebHttpBodyStream_Read(httpBodyStream, buffer, BUFFER_SIZE); - } else { - RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebHttpBodyStream_GetUserData(httpBodyStream); - if (rawfileRequest) { - rawfileRequest->ReadRawfileDataOnWorkerThread(); - cnd_signal(&g_httpBodyCnd); - } - } -} - -int ReadHttpBodyOnWorkerThread(void* userData) -{ - memset(g_buffer, 0, BUFFER_SIZE); - ArkWeb_HttpBodyStream *httpBodyStream = (ArkWeb_HttpBodyStream *)userData; - OH_ArkWebHttpBodyStream_Read(httpBodyStream, g_buffer, BUFFER_SIZE); - int initResult = cnd_init(&g_httpBodyCnd); - if (initResult == 0) { - OH_LOG_INFO(LOG_APP, "cnd_init success."); - } else { - OH_LOG_INFO(LOG_APP, "cnd_init fail."); - } - int mtxResult = mtx_init(&g_httpBodyMtx, mtx_plain); - if (mtxResult == 0) { - OH_LOG_INFO(LOG_APP, "mtx_init success."); - } else { - OH_LOG_INFO(LOG_APP, "mtx_init fail."); - } - int waitResult = cnd_wait(&g_httpBodyCnd, &g_httpBodyMtx); - if (waitResult == 0) { - OH_LOG_INFO(LOG_APP, "cnd_wait success."); - } else { - OH_LOG_INFO(LOG_APP, "cnd_wait fail."); - } - return 0; -} - -int ReadRawfileOnWorkerThread(void* userData) -{ - RawfileRequest* rawfileRequest = (RawfileRequest*)userData; - if (rawfileRequest) { - rawfileRequest->ReadRawfileDataOnWorkerThread(); - } - return 0; -} - -// ArkWeb_HttpBodyStream的初始化回调。 -void InitCallback(const ArkWeb_HttpBodyStream *httpBodyStream, ArkWeb_NetError result) -{ - OH_LOG_INFO(LOG_APP, "init http body stream done %{public}d.", result); - bool isChunked = OH_ArkWebHttpBodyStream_IsChunked(httpBodyStream); - OH_LOG_INFO(LOG_APP, "http body stream is chunked %{public}d.", isChunked); - thrd_t th; - if (thrd_create(&th, ReadHttpBodyOnWorkerThread, (void *)httpBodyStream) != thrd_success) { - OH_LOG_ERROR(LOG_APP, "create thread failed."); - return; - } - - if (thrd_detach(th) != thrd_success) { - OH_LOG_ERROR(LOG_APP, "detach thread failed."); - } -} - -const int BLOCK_SIZE = 1024 * 8; -const int MAXWHILE = 100; - -} // namespace - -RawfileRequest::RawfileRequest(const ArkWeb_ResourceRequest *resourceRequest, - const ArkWeb_ResourceHandler *resourceHandler, - const NativeResourceManager* resourceManager) - : resourceRequest_(resourceRequest), - resourceHandler_(resourceHandler), - resourceManager_(resourceManager) {} - -RawfileRequest::~RawfileRequest() {} - -void RawfileRequest::Start() -{ - OH_LOG_INFO(LOG_APP, "start a rawfile request."); - // [Start get_intercepted_request_info] - char* url; - OH_ArkWebResourceRequest_GetUrl(resourceRequest_, &url); - std::string urlStr(url); - std::size_t position = urlStr.rfind('/'); - if (position != std::string::npos) { - rawfilePath_ = urlStr.substr(position + 1); - } - OH_ArkWeb_ReleaseString(url); - // [End get_intercepted_request_info] - - // [Start set_intercepted_request_response] - // [StartExclude set_intercepted_request_response] - OH_ArkWeb_CreateResponse(&response_); - // [EndExclude set_intercepted_request_response] - OH_ArkWebResourceRequest_GetHttpBodyStream(resourceRequest(), &stream_); - if (stream_) { - OH_LOG_ERROR(LOG_APP, "have http body stream"); - // [Start get_put_post_request_data] - OH_ArkWebHttpBodyStream_SetUserData(stream_, this); - OH_ArkWebHttpBodyStream_SetReadCallback(stream_, ReadCallback); - OH_ArkWebHttpBodyStream_Init(stream_, InitCallback); - // [End get_put_post_request_data] - } else { - thrd_t th; - if (thrd_create(&th, ReadRawfileOnWorkerThread, static_cast(this)) != thrd_success) { - OH_LOG_ERROR(LOG_APP, "create thread failed."); - return; - } - - if (thrd_detach(th) != thrd_success) { - OH_LOG_ERROR(LOG_APP, "detach thread failed."); - } - } -} - -// 在worker线程中读取rawfile,并通过ResourceHandler返回给Web内核。 -void RawfileRequest::ReadRawfileDataOnWorkerThread() -{ - OH_LOG_INFO(LOG_APP, "read rawfile in worker thread."); - const struct UrlInfo { - std::string resource; - std::string mimeType; - } urlInfos[] = { - {"test.html", "text/html"}, - {"video.html", "text/html"}, - {"isolated.html", "text/html"}, - {"csp_bypassing.html", "text/html"}, - {"post_data.html", "text/html"}, - {"chunked_post_stream.html", "text/html"}, - {"local.html", "text/html"}, - {"service_worker.html", "text/html"}, - {"csp_script.js", "text/javascript"}, - {"sw.js", "text/javascript"}, - {"isolated_script.js", "text/javascript"}, - {"local_script.js", "text/javascript"}, - {"test.mp4", "video/mp4"}, - {"xhr", "application/json"} - }; - - if (!resourceManager()) { - OH_LOG_ERROR(LOG_APP, "read rawfile error, resource manager is nullptr."); - return; - } - - RawFile *rawfile = OH_ResourceManager_OpenRawFile(resourceManager(), RawfilePath().c_str()); - // [StartExclude set_intercepted_request_response] - if (!rawfile) { - OH_ArkWebResponse_SetStatus(response(), HTTP_NOT_FOUND); - } else { - OH_ArkWebResponse_SetStatus(response(), HTTP_OK); - } - // [EndExclude set_intercepted_request_response] - - for (auto &urlInfo : urlInfos) { - if (urlInfo.resource == RawfilePath()) { - OH_ArkWebResponse_SetMimeType(response(), urlInfo.mimeType.c_str()); - break; - } - } - // [StartExclude set_intercepted_request_response] - OH_ArkWebResponse_SetCharset(response(), "UTF-8"); - // [EndExclude set_intercepted_request_response] - - long len = OH_ResourceManager_GetRawFileSize(rawfile); - // [StartExclude set_intercepted_request_response] - OH_ArkWebResponse_SetHeaderByName(response(), "content-length", std::to_string(len).c_str(), false); - // EndExclude set_intercepted_request_response] - DidReceiveResponse(); - - long consumed = 0; - uint8_t buffer[BLOCK_SIZE]; - int i = 0; - while (++i < MAXWHILE) { - int ret = OH_ResourceManager_ReadRawFile(rawfile, buffer, BLOCK_SIZE); - if (ret > 0) { - OH_LOG_INFO(LOG_APP, "read rawfile %{public}d bytes.", ret); - } else if (ret == 0) { - OH_LOG_INFO(LOG_APP, "read rawfile Reached end of file, %{public}d bytes read.", ret); - break; - } else { - OH_LOG_ERROR(LOG_APP, "read rawfile Error, %{public}d bytes read.", ret); - break; - } - consumed += ret; - OH_ResourceManager_SeekRawFile(rawfile, consumed, 0); - DidReceiveData(buffer, ret); - memset(buffer, 0, BLOCK_SIZE); - } - - OH_ResourceManager_CloseRawFile(rawfile); - DidFinish(); -} - -void RawfileRequest::Stop() -{ - OH_LOG_INFO(LOG_APP, "stop the rawfile request."); - std::lock_guard guard(mutex_); - stopped_ = true; - if (response_) { - OH_ArkWeb_DestroyResponse(response_); - } - OH_ArkWebResourceRequest_Destroy(resourceRequest_); - OH_ArkWebResourceHandler_Destroy(resourceHandler_); -} - -void RawfileRequest::DidReceiveResponse() -{ - OH_LOG_INFO(LOG_APP, "did receive response."); - std::lock_guard guard(mutex_); - if (!stopped_) { - // [StartExclude set_intercepted_request_response] - OH_ArkWebResourceHandler_DidReceiveResponse(resourceHandler_, response_); - // [EndExclude set_intercepted_request_response] - } -} - -void RawfileRequest::DidReceiveData(const uint8_t *buffer, int64_t bufLen) -{ - OH_LOG_INFO(LOG_APP, "did receive data."); - std::lock_guard guard(mutex_); - if (!stopped_) { - // [StartExclude set_intercepted_request_response] - OH_ArkWebResourceHandler_DidReceiveData(resourceHandler_, buffer, bufLen); - // [EndExclude set_intercepted_request_response] - } -} - -void RawfileRequest::DidFinish() -{ - OH_LOG_INFO(LOG_APP, "did finish."); - std::lock_guard guard(mutex_); - if (!stopped_) { - // [StartExclude set_intercepted_request_response] - OH_ArkWebResourceHandler_DidFinish(resourceHandler_); - // [EndExclude set_intercepted_request_response] - // [End set_intercepted_request_response] - } -} - -void RawfileRequest::DidFailWithError(ArkWeb_NetError errorCode) -{ - OH_LOG_INFO(LOG_APP, "did finish with error %{public}d.", errorCode); - if (!stopped_) { - OH_ArkWebResourceHandler_DidFailWithError(resourceHandler_, errorCode); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start intercepted_request_processing_cpp] +#include "rawfile_request.h" +#include "threads.h" + +#include "hilog/log.h" +#include "rawfile/raw_file.h" +#include "rawfile/raw_file_manager.h" + +#undef LOG_TAG +#define LOG_TAG "ss-handler" + +namespace { + +uint8_t g_buffer[1024]; +cnd_t g_httpBodyCnd; +mtx_t g_httpBodyMtx; +const int HTTP_OK = 200; +const int HTTP_NOT_FOUND = 404; +const int BUFFER_SIZE = 1000; + +// HttpBodyStream的读回调。 +void ReadCallback(const ArkWeb_HttpBodyStream *httpBodyStream, uint8_t* buffer, int bytesRead) +{ + OH_LOG_INFO(LOG_APP, "read http body back."); + bool isEof = OH_ArkWebHttpBodyStream_IsEof(httpBodyStream); + if (!isEof && bytesRead != 0) { + memset(buffer, 0, BUFFER_SIZE); + OH_ArkWebHttpBodyStream_Read(httpBodyStream, buffer, BUFFER_SIZE); + } else { + RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebHttpBodyStream_GetUserData(httpBodyStream); + if (rawfileRequest) { + rawfileRequest->ReadRawfileDataOnWorkerThread(); + cnd_signal(&g_httpBodyCnd); + } + } +} + +int ReadHttpBodyOnWorkerThread(void* userData) +{ + memset(g_buffer, 0, BUFFER_SIZE); + ArkWeb_HttpBodyStream *httpBodyStream = (ArkWeb_HttpBodyStream *)userData; + OH_ArkWebHttpBodyStream_Read(httpBodyStream, g_buffer, BUFFER_SIZE); + int initResult = cnd_init(&g_httpBodyCnd); + if (initResult == 0) { + OH_LOG_INFO(LOG_APP, "cnd_init success."); + } else { + OH_LOG_INFO(LOG_APP, "cnd_init fail."); + } + int mtxResult = mtx_init(&g_httpBodyMtx, mtx_plain); + if (mtxResult == 0) { + OH_LOG_INFO(LOG_APP, "mtx_init success."); + } else { + OH_LOG_INFO(LOG_APP, "mtx_init fail."); + } + int waitResult = cnd_wait(&g_httpBodyCnd, &g_httpBodyMtx); + if (waitResult == 0) { + OH_LOG_INFO(LOG_APP, "cnd_wait success."); + } else { + OH_LOG_INFO(LOG_APP, "cnd_wait fail."); + } + return 0; +} + +int ReadRawfileOnWorkerThread(void* userData) +{ + RawfileRequest* rawfileRequest = (RawfileRequest*)userData; + if (rawfileRequest) { + rawfileRequest->ReadRawfileDataOnWorkerThread(); + } + return 0; +} + +// ArkWeb_HttpBodyStream的初始化回调。 +void InitCallback(const ArkWeb_HttpBodyStream *httpBodyStream, ArkWeb_NetError result) +{ + OH_LOG_INFO(LOG_APP, "init http body stream done %{public}d.", result); + bool isChunked = OH_ArkWebHttpBodyStream_IsChunked(httpBodyStream); + OH_LOG_INFO(LOG_APP, "http body stream is chunked %{public}d.", isChunked); + thrd_t th; + if (thrd_create(&th, ReadHttpBodyOnWorkerThread, (void *)httpBodyStream) != thrd_success) { + OH_LOG_ERROR(LOG_APP, "create thread failed."); + return; + } + + if (thrd_detach(th) != thrd_success) { + OH_LOG_ERROR(LOG_APP, "detach thread failed."); + } +} + +const int BLOCK_SIZE = 1024 * 8; +const int MAXWHILE = 100; + +} // namespace + +RawfileRequest::RawfileRequest(const ArkWeb_ResourceRequest *resourceRequest, + const ArkWeb_ResourceHandler *resourceHandler, + const NativeResourceManager* resourceManager) + : resourceRequest_(resourceRequest), + resourceHandler_(resourceHandler), + resourceManager_(resourceManager) {} + +RawfileRequest::~RawfileRequest() {} + +void RawfileRequest::Start() +{ + OH_LOG_INFO(LOG_APP, "start a rawfile request."); + // [Start get_intercepted_request_info] + char* url; + OH_ArkWebResourceRequest_GetUrl(resourceRequest_, &url); + std::string urlStr(url); + std::size_t position = urlStr.rfind('/'); + if (position != std::string::npos) { + rawfilePath_ = urlStr.substr(position + 1); + } + OH_ArkWeb_ReleaseString(url); + // [End get_intercepted_request_info] + + // [Start set_intercepted_request_response] + // [StartExclude set_intercepted_request_response] + OH_ArkWeb_CreateResponse(&response_); + // [EndExclude set_intercepted_request_response] + OH_ArkWebResourceRequest_GetHttpBodyStream(resourceRequest(), &stream_); + if (stream_) { + OH_LOG_ERROR(LOG_APP, "have http body stream"); + // [Start get_put_post_request_data] + OH_ArkWebHttpBodyStream_SetUserData(stream_, this); + OH_ArkWebHttpBodyStream_SetReadCallback(stream_, ReadCallback); + OH_ArkWebHttpBodyStream_Init(stream_, InitCallback); + // [End get_put_post_request_data] + } else { + thrd_t th; + if (thrd_create(&th, ReadRawfileOnWorkerThread, static_cast(this)) != thrd_success) { + OH_LOG_ERROR(LOG_APP, "create thread failed."); + return; + } + + if (thrd_detach(th) != thrd_success) { + OH_LOG_ERROR(LOG_APP, "detach thread failed."); + } + } +} + +// 在worker线程中读取rawfile,并通过ResourceHandler返回给Web内核。 +void RawfileRequest::ReadRawfileDataOnWorkerThread() +{ + OH_LOG_INFO(LOG_APP, "read rawfile in worker thread."); + const struct UrlInfo { + std::string resource; + std::string mimeType; + } urlInfos[] = { + {"test.html", "text/html"}, + {"video.html", "text/html"}, + {"isolated.html", "text/html"}, + {"csp_bypassing.html", "text/html"}, + {"post_data.html", "text/html"}, + {"chunked_post_stream.html", "text/html"}, + {"local.html", "text/html"}, + {"service_worker.html", "text/html"}, + {"csp_script.js", "text/javascript"}, + {"sw.js", "text/javascript"}, + {"isolated_script.js", "text/javascript"}, + {"local_script.js", "text/javascript"}, + {"test.mp4", "video/mp4"}, + {"xhr", "application/json"} + }; + + if (!resourceManager()) { + OH_LOG_ERROR(LOG_APP, "read rawfile error, resource manager is nullptr."); + return; + } + + RawFile *rawfile = OH_ResourceManager_OpenRawFile(resourceManager(), RawfilePath().c_str()); + // [StartExclude set_intercepted_request_response] + if (!rawfile) { + OH_ArkWebResponse_SetStatus(response(), HTTP_NOT_FOUND); + } else { + OH_ArkWebResponse_SetStatus(response(), HTTP_OK); + } + // [EndExclude set_intercepted_request_response] + + for (auto &urlInfo : urlInfos) { + if (urlInfo.resource == RawfilePath()) { + OH_ArkWebResponse_SetMimeType(response(), urlInfo.mimeType.c_str()); + break; + } + } + // [StartExclude set_intercepted_request_response] + OH_ArkWebResponse_SetCharset(response(), "UTF-8"); + // [EndExclude set_intercepted_request_response] + + long len = OH_ResourceManager_GetRawFileSize(rawfile); + // [StartExclude set_intercepted_request_response] + OH_ArkWebResponse_SetHeaderByName(response(), "content-length", std::to_string(len).c_str(), false); + // EndExclude set_intercepted_request_response] + DidReceiveResponse(); + + long consumed = 0; + uint8_t buffer[BLOCK_SIZE]; + int i = 0; + while (++i < MAXWHILE) { + int ret = OH_ResourceManager_ReadRawFile(rawfile, buffer, BLOCK_SIZE); + if (ret > 0) { + OH_LOG_INFO(LOG_APP, "read rawfile %{public}d bytes.", ret); + } else if (ret == 0) { + OH_LOG_INFO(LOG_APP, "read rawfile Reached end of file, %{public}d bytes read.", ret); + break; + } else { + OH_LOG_ERROR(LOG_APP, "read rawfile Error, %{public}d bytes read.", ret); + break; + } + consumed += ret; + OH_ResourceManager_SeekRawFile(rawfile, consumed, 0); + DidReceiveData(buffer, ret); + memset(buffer, 0, BLOCK_SIZE); + } + + OH_ResourceManager_CloseRawFile(rawfile); + DidFinish(); +} + +void RawfileRequest::Stop() +{ + OH_LOG_INFO(LOG_APP, "stop the rawfile request."); + std::lock_guard guard(mutex_); + stopped_ = true; + if (response_) { + OH_ArkWeb_DestroyResponse(response_); + } + OH_ArkWebResourceRequest_Destroy(resourceRequest_); + OH_ArkWebResourceHandler_Destroy(resourceHandler_); +} + +void RawfileRequest::DidReceiveResponse() +{ + OH_LOG_INFO(LOG_APP, "did receive response."); + std::lock_guard guard(mutex_); + if (!stopped_) { + // [StartExclude set_intercepted_request_response] + OH_ArkWebResourceHandler_DidReceiveResponse(resourceHandler_, response_); + // [EndExclude set_intercepted_request_response] + } +} + +void RawfileRequest::DidReceiveData(const uint8_t *buffer, int64_t bufLen) +{ + OH_LOG_INFO(LOG_APP, "did receive data."); + std::lock_guard guard(mutex_); + if (!stopped_) { + // [StartExclude set_intercepted_request_response] + OH_ArkWebResourceHandler_DidReceiveData(resourceHandler_, buffer, bufLen); + // [EndExclude set_intercepted_request_response] + } +} + +void RawfileRequest::DidFinish() +{ + OH_LOG_INFO(LOG_APP, "did finish."); + std::lock_guard guard(mutex_); + if (!stopped_) { + // [StartExclude set_intercepted_request_response] + OH_ArkWebResourceHandler_DidFinish(resourceHandler_); + // [EndExclude set_intercepted_request_response] + // [End set_intercepted_request_response] + } +} + +void RawfileRequest::DidFailWithError(ArkWeb_NetError errorCode) +{ + OH_LOG_INFO(LOG_APP, "did finish with error %{public}d.", errorCode); + if (!stopped_) { + OH_ArkWebResourceHandler_DidFailWithError(resourceHandler_, errorCode); + } +} // [End intercepted_request_processing_cpp] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.h b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.h old mode 100755 new mode 100644 index 8a8cdbc0d9..09f6814761 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.h +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.h @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start rawfile_request_head] -#ifndef RAWFILE_REQUEST_H -#define RAWFILE_REQUEST_H - -#include -#include - -#include -#include "web/arkweb_scheme_handler.h" -#include "web/arkweb_net_error_list.h" - -class RawfileRequest { -public: - RawfileRequest(const ArkWeb_ResourceRequest *resourceRequest, - const ArkWeb_ResourceHandler *resourceHandler, - const NativeResourceManager* resourceManager); - ~RawfileRequest(); - - void Start(); - void Stop(); - void ReadRawfileDataOnWorkerThread(); - - const ArkWeb_ResourceHandler *resourceHandler() { return resourceHandler_; } - const ArkWeb_ResourceRequest *resourceRequest() { return resourceRequest_; } - const NativeResourceManager *resourceManager() { return resourceManager_; } - ArkWeb_Response *response() { return response_; } - ArkWeb_HttpBodyStream *stream() { return stream_; } - const std::string RawfilePath() { return rawfilePath_; } - - void DidReceiveResponse(); - void DidReceiveData(const uint8_t *buffer, int64_t bufLen); - void DidFinish(); - void DidFailWithError(ArkWeb_NetError errorCode); - -private: - const ArkWeb_ResourceRequest *resourceRequest_{nullptr}; - const ArkWeb_ResourceHandler *resourceHandler_{nullptr}; - const NativeResourceManager *resourceManager_{nullptr}; - ArkWeb_Response *response_; - bool stopped_{false}; - std::string rawfilePath_; - ArkWeb_HttpBodyStream *stream_{nullptr}; - std::mutex mutex_; -}; - -#endif // RAWFILE_REQUEST_H +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start rawfile_request_head] +#ifndef RAWFILE_REQUEST_H +#define RAWFILE_REQUEST_H + +#include +#include + +#include +#include "web/arkweb_scheme_handler.h" +#include "web/arkweb_net_error_list.h" + +class RawfileRequest { +public: + RawfileRequest(const ArkWeb_ResourceRequest *resourceRequest, + const ArkWeb_ResourceHandler *resourceHandler, + const NativeResourceManager* resourceManager); + ~RawfileRequest(); + + void Start(); + void Stop(); + void ReadRawfileDataOnWorkerThread(); + + const ArkWeb_ResourceHandler *resourceHandler() { return resourceHandler_; } + const ArkWeb_ResourceRequest *resourceRequest() { return resourceRequest_; } + const NativeResourceManager *resourceManager() { return resourceManager_; } + ArkWeb_Response *response() { return response_; } + ArkWeb_HttpBodyStream *stream() { return stream_; } + const std::string RawfilePath() { return rawfilePath_; } + + void DidReceiveResponse(); + void DidReceiveData(const uint8_t *buffer, int64_t bufLen); + void DidFinish(); + void DidFailWithError(ArkWeb_NetError errorCode); + +private: + const ArkWeb_ResourceRequest *resourceRequest_{nullptr}; + const ArkWeb_ResourceHandler *resourceHandler_{nullptr}; + const NativeResourceManager *resourceManager_{nullptr}; + ArkWeb_Response *response_; + bool stopped_{false}; + std::string rawfilePath_; + ArkWeb_HttpBodyStream *stream_{nullptr}; + std::mutex mutex_; +}; + +#endif // RAWFILE_REQUEST_H // [End rawfile_request_head] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index 39fae16db3..97cceb187e --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,22 +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. - */ - -import { resourceManager } from "@kit.LocalizationKit"; - -// [Start export_register_set_init_schemes] -export const registerCustomSchemes: () => void; -export const setSchemeHandler: () => void; -export const initResourceManager: (resmgr: resourceManager.ResourceManager) => void; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { resourceManager } from "@kit.LocalizationKit"; + +// [Start export_register_set_init_schemes] +export const registerCustomSchemes: () => void; +export const setSchemeHandler: () => void; +export const initResourceManager: (resmgr: resourceManager.ResourceManager) => void; // [End export_register_set_init_schemes] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 2a39089b66..8ddc53ccb1 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start register_init_scheme_example] -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; -import testNapi from 'libentry.so'; -import { webview } from '@kit.ArkWeb'; - -// [Start register_init_scheme] -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - // 注册三方协议的配置。 - testNapi.registerCustomSchemes(); - // 初始化Web组件内核,该操作会初始化Browser进程以及创建BrowserContext。 - webview.WebviewController.initializeWebEngine(); - // 设置SchemeHandler。 - testNapi.setSchemeHandler(); - } - - // [StartExclude register_init_scheme] - onDestroy(): void { - - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - return; - } - }); - } - - onWindowStageDestroy(): void { - - } - - onForeground(): void { - - } - - onBackground(): void { - - } - // [EndExclude register_init_scheme] -}; -// [End register_init_scheme] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start register_init_scheme_example] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import testNapi from 'libentry.so'; +import { webview } from '@kit.ArkWeb'; + +// [Start register_init_scheme] +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // 注册三方协议的配置。 + testNapi.registerCustomSchemes(); + // 初始化Web组件内核,该操作会初始化Browser进程以及创建BrowserContext。 + webview.WebviewController.initializeWebEngine(); + // 设置SchemeHandler。 + testNapi.setSchemeHandler(); + } + + // [StartExclude register_init_scheme] + onDestroy(): void { + + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + return; + } + }); + } + + onWindowStageDestroy(): void { + + } + + onForeground(): void { + + } + + onBackground(): void { + + } + // [EndExclude register_init_scheme] +}; +// [End register_init_scheme] // [End register_init_scheme_example] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 360bb38ae0..5420d2ebfb --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/pages/Index.ets @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start set_test_html] -import testNapi from 'libentry.so'; -import { webview } from '@kit.ArkWeb'; -import { resourceManager } from '@kit.LocalizationKit'; - -@Entry -@Component -struct Index { - mycontroller: webview.WebviewController = new webview.WebviewController('scheme-handler'); - - build() { - Row() { - Column() { - Button('goback').onClick( event => { - this.mycontroller.backward(); - }) - - Web({ src: $rawfile('test.html'), controller: this.mycontroller}) - .javaScriptAccess(true) - .width('100%') - .height('100%') - .databaseAccess(true) - .fileAccess(false) - .domStorageAccess(true) - .cacheMode(CacheMode.Default) - .onPageBegin( event => { - testNapi.initResourceManager(getContext().resourceManager); - }) - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start set_test_html] +import testNapi from 'libentry.so'; +import { webview } from '@kit.ArkWeb'; +import { resourceManager } from '@kit.LocalizationKit'; + +@Entry +@Component +struct Index { + mycontroller: webview.WebviewController = new webview.WebviewController('scheme-handler'); + + build() { + Row() { + Column() { + Button('goback').onClick( event => { + this.mycontroller.backward(); + }) + + Web({ src: $rawfile('test.html'), controller: this.mycontroller}) + .javaScriptAccess(true) + .width('100%') + .height('100%') + .databaseAccess(true) + .fileAccess(false) + .domStorageAccess(true) + .cacheMode(CacheMode.Default) + .onPageBegin( event => { + testNapi.initResourceManager(getContext().resourceManager); + }) + } + .width('100%') + } + .height('100%') + } +} // [End set_test_html] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/module.json5 old mode 100755 new mode 100644 index 81751d0bc4..e9db80c0ac --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html old mode 100755 new mode 100644 index 5d0e9d1b0f..645cd7833b --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html @@ -1,46 +1,46 @@ - - - - - - - - -
test post chunked http body.
- - + + + + + + + + +
test post chunked http body.
+ + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_bypassing.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_bypassing.html old mode 100755 new mode 100644 index 59d38ff73d..c80c78270a --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_bypassing.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_bypassing.html @@ -1,26 +1,26 @@ - - - - - - - - -

scheme: custom-csp-bypassing

-

options: ARKWEB_SCHEME_OPTION_CSP_BYPASSING | ARKWEB_SCHEME_OPTION_STANDARD

- - - + + + + + + + + +

scheme: custom-csp-bypassing

+

options: ARKWEB_SCHEME_OPTION_CSP_BYPASSING | ARKWEB_SCHEME_OPTION_STANDARD

+ + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_script.js b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_script.js old mode 100755 new mode 100644 index d345c85fd5..8621810e79 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_script.js +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_script.js @@ -1,21 +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. -*/ - -// [Start csp_rules_java_script] -const body = document.body; -const element = document.createElement('div'); -element.textContent = 'csp_script.js bypass the csp rules'; -body.appendChild(element); -// [End csp_rules_java_script] +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// [Start csp_rules_java_script] +const body = document.body; +const element = document.createElement('div'); +element.textContent = 'csp_script.js bypass the csp rules'; +body.appendChild(element); +// [End csp_rules_java_script] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated.html old mode 100755 new mode 100644 index 5ca0272983..bc04b31350 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated.html @@ -1,26 +1,26 @@ - - - - - - - -

scheme: custom-isolated

-

options: ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED

-
isolated_script.js 被拦截
- - - + + + + + + + +

scheme: custom-isolated

+

options: ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED

+
isolated_script.js 被拦截
+ + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated_script.js b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated_script.js old mode 100755 new mode 100644 index e1e912d400..5ad02d6e03 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated_script.js +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated_script.js @@ -1,19 +1,19 @@ -/* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// [Start isolated_script_java_script] -const element = document.getElementById('isolated_test'); -element.textContent = 'isolated_script.js not blocked'; -// [End isolated_script_java_script] +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// [Start isolated_script_java_script] +const element = document.getElementById('isolated_test'); +element.textContent = 'isolated_script.js not blocked'; +// [End isolated_script_java_script] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local.html old mode 100755 new mode 100644 index bbd9de1662..48ae7287bb --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local.html @@ -1,26 +1,26 @@ - - - - - - - -

scheme: custom-local

-

options: ARKWEB_SCHEME_OPTION_LOCAL

-
local_script.js 被拦截
- - - + + + + + + + +

scheme: custom-local

+

options: ARKWEB_SCHEME_OPTION_LOCAL

+
local_script.js 被拦截
+ + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local_script.js b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local_script.js old mode 100755 new mode 100644 index 0e7da82dee..b09eb3740e --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local_script.js +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local_script.js @@ -1,19 +1,19 @@ -/* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// [Start local_script_java_script] -const element = document.getElementById('local_test'); -element.textContent = 'local_script.js not blocked.'; -// [End local_script_java_script] +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// [Start local_script_java_script] +const element = document.getElementById('local_test'); +element.textContent = 'local_script.js not blocked.'; +// [End local_script_java_script] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html old mode 100755 new mode 100644 index 573507058f..cbb19dd30b --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html @@ -1,48 +1,48 @@ - - - - - - - - -
test xhr post
-
test xhr put
- - + + + + + + + + +
test xhr post
+
test xhr put
+ + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html old mode 100755 new mode 100644 index b6188583c6..e971e1c413 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html @@ -1,34 +1,34 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/sw.js b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/sw.js old mode 100755 new mode 100644 index fe14cf8d50..cdc5590284 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/sw.js +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/sw.js @@ -1,27 +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. -*/ - -// [Start add_event_listener_java_script] -self.addEventListener('install', event => { - console.log('v1 installing'); - event.waitUntil( - caches.open('static-v1').then(cache => cache.add('/cat.svg')) - ); -}); - -self.addEventListener('activate', event => { - console.log('v1 now redy to handle fetches.'); -}); -// [End add_event_listener_java_script] +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// [Start add_event_listener_java_script] +self.addEventListener('install', event => { + console.log('v1 installing'); + event.waitUntil( + caches.open('static-v1').then(cache => cache.add('/cat.svg')) + ); +}); + +self.addEventListener('activate', event => { + console.log('v1 now redy to handle fetches.'); +}); +// [End add_event_listener_java_script] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.html old mode 100755 new mode 100644 index 03e9dfb938..957e0b9cc9 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.html @@ -1,31 +1,31 @@ - - - - - - - - -

网络拦截测试demo

-拦截视频资源请求,读取本地mp4文件
-测试三方协议忽略csp检查,并成功拦截
-测试拦截设置ISOLATED属性的三方协议
-测试拦截设置LOCAL属性的三方协议
-测试拦截service worker触发的请求
-测试读取blob类型http body stream
-测试读取chunked类型http body stream - + + + + + + + + +

网络拦截测试demo

+拦截视频资源请求,读取本地mp4文件
+测试三方协议忽略csp检查,并成功拦截
+测试拦截设置ISOLATED属性的三方协议
+测试拦截设置LOCAL属性的三方协议
+测试拦截service worker触发的请求
+测试读取blob类型http body stream
+测试读取chunked类型http body stream + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.mp4 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.mp4 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html old mode 100755 new mode 100644 index 657b559854..87ccf17357 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html @@ -1,25 +1,25 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/xhr b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/xhr old mode 100755 new mode 100644 index 81d8352ea1..42d4264b05 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/xhr +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/xhr @@ -1,16 +1,16 @@ -/* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - +/* +* 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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/Libentry.mock.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/Libentry.mock.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/oh-package.json5 old mode 100755 new mode 100644 index bcb70ff878..6f8ebfffe8 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/oh-package.json5 @@ -1,25 +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": "entry2", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "entry2", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2ability/Entry2Ability.ets old mode 100755 new mode 100644 index b6c293ba8d..0686a465f4 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2ability/Entry2Ability.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2ability/Entry2Ability.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start web_module_open_bf_cache] -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; -import { webview } from '@kit.ArkWeb'; - -export default class Entry2Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - let features = new webview.BackForwardCacheSupportedFeatures(); - features.nativeEmbed = true; - features.mediaTakeOver = true; - webview.WebviewController.enableBackForwardCache(features); - webview.WebviewController.initializeWebEngine(); - AppStorage.setOrCreate('abilityWant', want); - } - // [End web_module_open_bf_cache] - - 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'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start web_module_open_bf_cache] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; + +export default class Entry2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + let features = new webview.BackForwardCacheSupportedFeatures(); + features.nativeEmbed = true; + features.mediaTakeOver = true; + webview.WebviewController.enableBackForwardCache(features); + webview.WebviewController.initializeWebEngine(); + AppStorage.setOrCreate('abilityWant', want); + } + // [End web_module_open_bf_cache] + + 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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets old mode 100755 new mode 100644 index a9c5227a98..f9a6b45900 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets @@ -1,27 +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 Entry2BackupAbility 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)); - } +/* + * 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 Entry2BackupAbility 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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/module.json5 old mode 100755 new mode 100644 index b171fdbc82..90a4604809 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/module.json5 @@ -1,70 +1,70 @@ -/* - * 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": "entry2", - "type": "entry", - "description": "$string:module_desc", - "mainElement": "Entry2Ability", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry2Ability", - "srcEntry": "./ets/entry2ability/Entry2Ability.ets", - "description": "$string:Entry2Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry2Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "Entry2BackupAbility", - "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.ets", - "type": "backup", - "exported": false, - "metadata": [ - { - "name": "ohos.extension.backup", - "resource": "$profile:backup_config" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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": "entry2", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "Entry2Ability", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry2Ability", + "srcEntry": "./ets/entry2ability/Entry2Ability.ets", + "description": "$string:Entry2Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry2Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "Entry2BackupAbility", + "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/module.json5 old mode 100755 new mode 100644 index f877d50cb7..17410acb16 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/module.json5 @@ -1,26 +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. - */ - -{ - "module": { - "name": "entry2_test", - "type": "feature", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry2_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/.gitignore b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/build-profile.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/oh-package.json5 old mode 100755 new mode 100644 index 401ea2ff2d..655d244a4e --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/oh-package.json5 @@ -1,25 +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": "entry3", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "entry3", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/entry3ability/Entry3Ability.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/entry3ability/Entry3Ability.ets old mode 100755 new mode 100644 index ec13ab90b8..069b292b0a --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/entry3ability/Entry3Ability.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/entry3ability/Entry3Ability.ets @@ -1,63 +1,63 @@ -/* - * 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'; -// [Start create_main_window] -import { createNWeb, defaultUrl } from '../pages/common'; - -// [StartExclude create_main_window] -export default class Entry3Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - // [EndExclude create_main_window] - - 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; - } - // 创建Web动态组件(需传入UIContext),loadContent之后的任意时机均可创建,应用仅创建一个Web组件 - createNWeb(defaultUrl, windowStage.getMainWindowSync().getUIContext()); - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - // [End create_main_window] - - 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'); - } -} +/* + * 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'; +// [Start create_main_window] +import { createNWeb, defaultUrl } from '../pages/common'; + +// [StartExclude create_main_window] +export default class Entry3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + // [EndExclude create_main_window] + + 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; + } + // 创建Web动态组件(需传入UIContext),loadContent之后的任意时机均可创建,应用仅创建一个Web组件 + createNWeb(defaultUrl, windowStage.getMainWindowSync().getUIContext()); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + // [End create_main_window] + + 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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/common.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/common.ets old mode 100755 new mode 100644 index 2c84144ae3..f5fa3e58a3 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/common.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/common.ets @@ -1,118 +1,118 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start dynamic_web_module_manage] -// 提供动态挂载Web组件能力 -import { UIContext, NodeController, BuilderNode, FrameNode } from '@kit.ArkUI'; -import { webview } from '@kit.ArkWeb'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -export const defaultUrl : string = 'www.example.com'; - -// Data为入参封装类 -class Data{ - public url: string = ''; - public webController: webview.WebviewController | null = null; - - constructor(url: string, webController: webview.WebviewController) { - this.url = url; - this.webController = webController; - } -} - -// @Builder中为动态组件的具体组件内容 -@Builder -function webBuilder(data:Data) { - Web({ src: data.url, controller: data.webController }) - .width('100%') - .height('100%') - .borderStyle(BorderStyle.Dashed) - .borderWidth(2) -} - -let wrap = wrapBuilder<[Data]>(webBuilder); - -// 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用 -export class MyNodeController extends NodeController { - private builderNode: BuilderNode<[Data]> | null | undefined = null; - private webController : webview.WebviewController | null | undefined = null; - private rootNode : FrameNode | null = null; - - constructor(builderNode : BuilderNode<[Data]> | undefined, webController : webview.WebviewController | undefined) { - super(); - this.builderNode = builderNode; - this.webController = webController; - } - - // 必须要重写的方法,用于构建节点数、返回节点挂载在对应NodeContainer中 - // 在对应NodeContainer创建的时候调用或者通过rebuild方法调用刷新 - makeNode(uiContext: UIContext): FrameNode | null { - // 该节点会被挂载在NodeContainer的父节点下 - return this.rootNode; - } - - // 挂载Webview - attachWeb() : void { - if (this.builderNode) { - let frameNode : FrameNode | null = this.builderNode.getFrameNode(); - if (frameNode?.getParent() != null) { - // 挂载自定义节点前判断该节点是否已经被挂载 - hilog.error(0x0000, 'testTag', '%{public}s', 'The frameNode is already attached'); - return; - } - this.rootNode = this.builderNode.getFrameNode(); - } - } - - // 卸载Webview - detachWeb() : void { - this.rootNode = null; - } - - getWebController() : webview.WebviewController | null | undefined { - return this.webController; - } -} - -// 创建Map保存所需要的BuilderNode -let builderNodeMap : Map | undefined> = new Map(); -// 创建Map保存所需要的webview.WebviewController -let webControllerMap : Map = new Map(); - -// 初始化需要UIContext对象,UIContext对象可通过窗口或自定义组件的getUIContext方法获取 -export const createNWeb = (url: string, uiContext: UIContext) => { - // 创建WebviewController - let webController = new webview.WebviewController() ; - // 创建BuilderNode - let builderNode : BuilderNode<[Data]> = new BuilderNode(uiContext); - // 创建动态Web组件 - builderNode.build(wrap, new Data(url, webController)); - - // 保存BuilderNode - builderNodeMap.set(url, builderNode); - // 保存WebviewController - webControllerMap.set(url, webController); -} - -// 自定义获取BuilderNode的接口 -export const getBuilderNode = (url : string) : BuilderNode<[Data]> | undefined => { - return builderNodeMap.get(url); -} -// 自定义获取WebviewController的接口 -export const getWebviewController = (url : string) : webview.WebviewController | undefined => { - return webControllerMap.get(url); -} -// [End dynamic_web_module_manage] - +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start dynamic_web_module_manage] +// 提供动态挂载Web组件能力 +import { UIContext, NodeController, BuilderNode, FrameNode } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +export const defaultUrl : string = 'www.example.com'; + +// Data为入参封装类 +class Data{ + public url: string = ''; + public webController: webview.WebviewController | null = null; + + constructor(url: string, webController: webview.WebviewController) { + this.url = url; + this.webController = webController; + } +} + +// @Builder中为动态组件的具体组件内容 +@Builder +function webBuilder(data:Data) { + Web({ src: data.url, controller: data.webController }) + .width('100%') + .height('100%') + .borderStyle(BorderStyle.Dashed) + .borderWidth(2) +} + +let wrap = wrapBuilder<[Data]>(webBuilder); + +// 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用 +export class MyNodeController extends NodeController { + private builderNode: BuilderNode<[Data]> | null | undefined = null; + private webController : webview.WebviewController | null | undefined = null; + private rootNode : FrameNode | null = null; + + constructor(builderNode : BuilderNode<[Data]> | undefined, webController : webview.WebviewController | undefined) { + super(); + this.builderNode = builderNode; + this.webController = webController; + } + + // 必须要重写的方法,用于构建节点数、返回节点挂载在对应NodeContainer中 + // 在对应NodeContainer创建的时候调用或者通过rebuild方法调用刷新 + makeNode(uiContext: UIContext): FrameNode | null { + // 该节点会被挂载在NodeContainer的父节点下 + return this.rootNode; + } + + // 挂载Webview + attachWeb() : void { + if (this.builderNode) { + let frameNode : FrameNode | null = this.builderNode.getFrameNode(); + if (frameNode?.getParent() != null) { + // 挂载自定义节点前判断该节点是否已经被挂载 + hilog.error(0x0000, 'testTag', '%{public}s', 'The frameNode is already attached'); + return; + } + this.rootNode = this.builderNode.getFrameNode(); + } + } + + // 卸载Webview + detachWeb() : void { + this.rootNode = null; + } + + getWebController() : webview.WebviewController | null | undefined { + return this.webController; + } +} + +// 创建Map保存所需要的BuilderNode +let builderNodeMap : Map | undefined> = new Map(); +// 创建Map保存所需要的webview.WebviewController +let webControllerMap : Map = new Map(); + +// 初始化需要UIContext对象,UIContext对象可通过窗口或自定义组件的getUIContext方法获取 +export const createNWeb = (url: string, uiContext: UIContext) => { + // 创建WebviewController + let webController = new webview.WebviewController() ; + // 创建BuilderNode + let builderNode : BuilderNode<[Data]> = new BuilderNode(uiContext); + // 创建动态Web组件 + builderNode.build(wrap, new Data(url, webController)); + + // 保存BuilderNode + builderNodeMap.set(url, builderNode); + // 保存WebviewController + webControllerMap.set(url, webController); +} + +// 自定义获取BuilderNode的接口 +export const getBuilderNode = (url : string) : BuilderNode<[Data]> | undefined => { + return builderNodeMap.get(url); +} +// 自定义获取WebviewController的接口 +export const getWebviewController = (url : string) : webview.WebviewController | undefined => { + return webControllerMap.get(url); +} +// [End dynamic_web_module_manage] + diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/module.json5 old mode 100755 new mode 100644 index db35d4bff4..5566c38cae --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/module.json5 @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry3", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Entry3Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry3Ability", - "srcEntry": "./ets/entry3ability/Entry3Ability.ets", - "description": "$string:Entry3Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry3Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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": "entry3", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Entry3Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry3Ability", + "srcEntry": "./ets/entry3ability/Entry3Ability.ets", + "description": "$string:Entry3Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry3Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9fec93324f..edaba8aaab --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry3_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry3_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/List.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigorfile.ts b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/oh-package.json5 b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/ohosTest.md b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_1.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_2.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_1.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_2.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_1.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_2.png b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/.gitignore b/code/DocsSample/ArkWeb/ProcessWebPageCont/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/app.json5 b/code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/app.json5 old mode 100755 new mode 100644 index 139b247a26..4b1ce53f11 --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/app.json5 @@ -1,25 +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.processwebpagecont", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.processwebpagecont", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 9884e6c4b0..4779102eff --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ProcessWebPageCont" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ProcessWebPageCont" + } + ] +} diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/ProcessWebPageCont/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/README.md b/code/DocsSample/ArkWeb/ProcessWebPageCont/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/build-profile.json5 b/code/DocsSample/ArkWeb/ProcessWebPageCont/build-profile.json5 old mode 100755 new mode 100644 index 87d40a385e..7a9c78377e --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/build-profile.json5 @@ -1,52 +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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 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/ArkWeb/ProcessWebPageCont/code-linter.json5 b/code/DocsSample/ArkWeb/ProcessWebPageCont/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/.gitignore b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/build-profile.json5 b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/oh-package.json5 b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b865efd626..82e98bec44 --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 7aaec79f5a..29feaca766 --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets old mode 100755 new mode 100644 index ddce0c96a4..a357e5996f --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start use_expand_safe_area_to_enable_immersive_effect] -import { webview } from '@kit.ArkWeb'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Web({ src: 'www.example.com', controller: this.controller }) - .width('100%').height('100%') - .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) - } - } -} -// [End use_expand_safe_area_to_enable_immersive_effect] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start use_expand_safe_area_to_enable_immersive_effect] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .width('100%').height('100%') + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + } + } +} +// [End use_expand_safe_area_to_enable_immersive_effect] diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 28727bc714..1def271b56 --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets @@ -1,42 +1,42 @@ -/* - * 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 { router } from '@kit.ArkUI'; - -@Entry -@Component -struct Index { - build() { - Column({ space: 10 }) { - Button('InitiatePrintW3CAPI') - .onClick(() => { - router.pushUrl({ url: 'pages/InitiatePrintW3CAPI' }); - }) - Button('InitiatePrintAppAPI') - .onClick(() => { - router.pushUrl({ url: 'pages/InitiatePrintAppAPI' }); - }) - Button('PreviewPDF') - .onClick(() => { - router.pushUrl({ url: 'pages/PreviewPDF' }); - }) - Button('CalcAdjustSafeArea') - .onClick(() => { - router.pushUrl({ url: 'pages/CalcAdjustSafeArea' }); - }) - }.height('100%') - .width('100%') - } +/* + * 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 { router } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('InitiatePrintW3CAPI') + .onClick(() => { + router.pushUrl({ url: 'pages/InitiatePrintW3CAPI' }); + }) + Button('InitiatePrintAppAPI') + .onClick(() => { + router.pushUrl({ url: 'pages/InitiatePrintAppAPI' }); + }) + Button('PreviewPDF') + .onClick(() => { + router.pushUrl({ url: 'pages/PreviewPDF' }); + }) + Button('CalcAdjustSafeArea') + .onClick(() => { + router.pushUrl({ url: 'pages/CalcAdjustSafeArea' }); + }) + }.height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintAppAPI.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintAppAPI.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintW3CAPI.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintW3CAPI.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets old mode 100755 new mode 100644 index 8e8d12a1db..dad0b0ca92 --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start web_module_create_load_pdf] -import { webview } from '@kit.ArkWeb'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Web({ - src: - $r('app.string.web_path'), // 方式一 加载网络PDF文档 - // getContext(this).filesDir + '/test.pdf', // 方式二 加载本地应用沙箱内PDF文档 - // 'resource://rawfile/test.pdf', // 方式三 应用内resource资源PDF文档 - // $rawfile('test.pdf'), // 方式四 应用内resource资源PDF文档 - controller: this.controller - }) - .domStorageAccess(true) - } - } -} -// [End web_module_create_load_pdf] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start web_module_create_load_pdf] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ + src: + $r('app.string.web_path'), // 方式一 加载网络PDF文档 + // getContext(this).filesDir + '/test.pdf', // 方式二 加载本地应用沙箱内PDF文档 + // 'resource://rawfile/test.pdf', // 方式三 应用内resource资源PDF文档 + // $rawfile('test.pdf'), // 方式四 应用内resource资源PDF文档 + controller: this.controller + }) + .domStorageAccess(true) + } + } +} +// [End web_module_create_load_pdf] diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/module.json5 old mode 100755 new mode 100644 index 35af445a0c..70729d262d --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/module.json5 @@ -1,82 +1,82 @@ -/* - * 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" - } - ] - } - ], - // [Start web_module_print_html] - // [Start web_module_preview_pdf] - "requestPermissions":[ - // [StartExclude web_module_preview_pdf] - { - "name" : "ohos.permission.PRINT" - }, - // EndExclude web_module_preview_pdf] - // [StartExclude web_module_print_html] - { - "name" : "ohos.permission.INTERNET" - } - // [EndExclude web_module_print_html] - ], - // [End web_module_preview_pdf] - // [End web_module_print_html] - } +/* + * 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" + } + ] + } + ], + // [Start web_module_print_html] + // [Start web_module_preview_pdf] + "requestPermissions":[ + // [StartExclude web_module_preview_pdf] + { + "name" : "ohos.permission.PRINT" + }, + // EndExclude web_module_preview_pdf] + // [StartExclude web_module_print_html] + { + "name" : "ohos.permission.INTERNET" + } + // [EndExclude web_module_print_html] + ], + // [End web_module_preview_pdf] + // [End web_module_print_html] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html old mode 100755 new mode 100644 index d286a9756e..7225f16ebc --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html @@ -1,63 +1,63 @@ - - - - - - - - printTest - - - - -
-

-
This is a test page for printing
-
-
-

- -

content content content

-
- - - - - - - - - - - - - - - - - -
ThingChairs
1blue
2green
-
-

content content content

-

content content content

-
- + + + + + + + + printTest + + + + +
+

+
This is a test page for printing
+
+
+

+ +

content content content

+
+ + + + + + + + + + + + + + + + + +
ThingChairs
1blue
2green
+
+

content content content

+

content content content

+
+ diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/rawfile/test.pdf b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/rawfile/test.pdf old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/ProcessWebPageCont/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/ProcessWebPageCont/hvigorfile.ts b/code/DocsSample/ArkWeb/ProcessWebPageCont/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/oh-package.json5 b/code/DocsSample/ArkWeb/ProcessWebPageCont/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/oh-package.json5 +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/ohosTest.md b/code/DocsSample/ArkWeb/ProcessWebPageCont/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/CalcAdjustSafeArea.png b/code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/CalcAdjustSafeArea.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/InitiatePrintAppAPI.png b/code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/InitiatePrintAppAPI.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/InitiatePrintW3CAPI.png b/code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/InitiatePrintW3CAPI.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/PreviewPDF.png b/code/DocsSample/ArkWeb/ProcessWebPageCont/screenshots/PreviewPDF.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/.gitignore b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/app.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/app.json5 old mode 100755 new mode 100644 index 67a31a5bae..0f85c55572 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/app.json5 @@ -1,25 +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.setbasicattrsevtsone", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.setbasicattrsevtsone", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 5b78418123..f3bc9e64fe --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SetBasicAttrsEvtsOne" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SetBasicAttrsEvtsOne" + } + ] +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/README.md b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/build-profile.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/build-profile.json5 old mode 100755 new mode 100644 index 87d40a385e..7a9c78377e --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/build-profile.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/build-profile.json5 @@ -1,52 +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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 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/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/code-linter.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/.gitignore b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/build-profile.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/oh-package.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b23d2fe946..0f2f8b94aa --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/AllowGeolocation.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/AllowGeolocation.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ClearAllCookiesSync.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ClearAllCookiesSync.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ConfigCookieSync.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ConfigCookieSync.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_one.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_one.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_two.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_two.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteAllData.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteAllData.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteGeolocation.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteGeolocation.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ExistCookie.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ExistCookie.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/FetchCookieSync.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/FetchCookieSync.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/GetAccessibleGeolocation.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/GetAccessibleGeolocation.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_one.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_one.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_two.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_two.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 17271bb68e..420f733900 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/Index.ets @@ -1,82 +1,82 @@ -/* - * 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 { router } from '@kit.ArkUI'; - -@Entry -@Component -struct Index { - build() { - Column({ space: 10 }) { - Button('DarkMode_one') - .onClick(() => { - router.pushUrl({ url: 'pages/DarkMode_one' }); - }) - Button('DarkMode_two') - .onClick(() => { - router.pushUrl({ url: 'pages/DarkMode_two' }); - }) - Button('AllowGeolocation') - .onClick(() => { - router.pushUrl({ url: 'pages/AllowGeolocation' }); - }) - Button('ClearAllCookiesSync') - .onClick(() => { - router.pushUrl({ url: 'pages/ClearAllCookiesSync' }); - }) - Button('ConfigCookieSync') - .onClick(() => { - router.pushUrl({ url: 'pages/ConfigCookieSync' }); - }) - Button('DeleteAllData') - .onClick(() => { - router.pushUrl({ url: 'pages/DeleteAllData' }); - }) - Button('DeleteGeolocation') - .onClick(() => { - router.pushUrl({ url: 'pages/DeleteGeolocation' }); - }) - Button('ExistCookie') - .onClick(() => { - router.pushUrl({ url: 'pages/ExistCookie' }); - }) - Button('FetchCookieSync') - .onClick(() => { - router.pushUrl({ url: 'pages/FetchCookieSync' }); - }) - Button('GetAccessibleGeolocation') - .onClick(() => { - router.pushUrl({ url: 'pages/GetAccessibleGeolocation' }); - }) - Button('IncognitoMode_one') - .onClick(() => { - router.pushUrl({ url: 'pages/IncognitoMode_one' }); - }) - Button('IncognitoMode_two') - .onClick(() => { - router.pushUrl({ url: 'pages/IncognitoMode_two' }); - }) - Button('OpenPageNewWin') - .onClick(() => { - router.pushUrl({ url: 'pages/OpenPageNewWin' }); - }) - Button('ManageLocPerms') - .onClick(() => { - router.pushUrl({ url: 'pages/ManageLocPerms' }); - }) - }.height('100%') - .width('100%') - } +/* + * 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 { router } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('DarkMode_one') + .onClick(() => { + router.pushUrl({ url: 'pages/DarkMode_one' }); + }) + Button('DarkMode_two') + .onClick(() => { + router.pushUrl({ url: 'pages/DarkMode_two' }); + }) + Button('AllowGeolocation') + .onClick(() => { + router.pushUrl({ url: 'pages/AllowGeolocation' }); + }) + Button('ClearAllCookiesSync') + .onClick(() => { + router.pushUrl({ url: 'pages/ClearAllCookiesSync' }); + }) + Button('ConfigCookieSync') + .onClick(() => { + router.pushUrl({ url: 'pages/ConfigCookieSync' }); + }) + Button('DeleteAllData') + .onClick(() => { + router.pushUrl({ url: 'pages/DeleteAllData' }); + }) + Button('DeleteGeolocation') + .onClick(() => { + router.pushUrl({ url: 'pages/DeleteGeolocation' }); + }) + Button('ExistCookie') + .onClick(() => { + router.pushUrl({ url: 'pages/ExistCookie' }); + }) + Button('FetchCookieSync') + .onClick(() => { + router.pushUrl({ url: 'pages/FetchCookieSync' }); + }) + Button('GetAccessibleGeolocation') + .onClick(() => { + router.pushUrl({ url: 'pages/GetAccessibleGeolocation' }); + }) + Button('IncognitoMode_one') + .onClick(() => { + router.pushUrl({ url: 'pages/IncognitoMode_one' }); + }) + Button('IncognitoMode_two') + .onClick(() => { + router.pushUrl({ url: 'pages/IncognitoMode_two' }); + }) + Button('OpenPageNewWin') + .onClick(() => { + router.pushUrl({ url: 'pages/OpenPageNewWin' }); + }) + Button('ManageLocPerms') + .onClick(() => { + router.pushUrl({ url: 'pages/ManageLocPerms' }); + }) + }.height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ManageLocPerms.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ManageLocPerms.ets old mode 100755 new mode 100644 index 0a7471c0b8..b39a2cf2be --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ManageLocPerms.ets +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ManageLocPerms.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start a_pop_up_window_is_used_to_notify_the_app_side_location_permission_request_message] -import { webview } from '@kit.ArkWeb'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { abilityAccessCtrl, common } from '@kit.AbilityKit'; - -let context = getContext(this) as common.UIAbilityContext; -let atManager = abilityAccessCtrl.createAtManager(); - -// 向用户请求位置权限设置。 -atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION']).then((data) => { - console.info('data:' + JSON.stringify(data)); - console.info('data permissions:' + data.permissions); - console.info('data authResults:' + data.authResults); -}).catch((error: BusinessError) => { - console.error(`Failed to request permissions from user. Code is ${error.code}, message is ${error.message}`); -}) - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Web({ src: $rawfile('getLocation.html'), controller: this.controller }) - .geolocationAccess(true) - .onGeolocationShow((event) => { // 地理位置权限申请通知 - AlertDialog.show({ - title: 'Location permission requests', - message: 'Whether to allow access to location information', - primaryButton: { - value: 'cancel', - action: () => { - if (event) { - event.geolocation.invoke(event.origin, false, false); // 不允许此站点地理位置权限请求 - } - } - }, - secondaryButton: { - value: 'ok', - action: () => { - if (event) { - event.geolocation.invoke(event.origin, true, false); // 允许此站点地理位置权限请求 - } - } - }, - cancel: () => { - if (event) { - event.geolocation.invoke(event.origin, false, false); // 不允许此站点地理位置权限请求 - } - } - }) - }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start a_pop_up_window_is_used_to_notify_the_app_side_location_permission_request_message] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { abilityAccessCtrl, common } from '@kit.AbilityKit'; + +let context = getContext(this) as common.UIAbilityContext; +let atManager = abilityAccessCtrl.createAtManager(); + +// 向用户请求位置权限设置。 +atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION']).then((data) => { + console.info('data:' + JSON.stringify(data)); + console.info('data permissions:' + data.permissions); + console.info('data authResults:' + data.authResults); +}).catch((error: BusinessError) => { + console.error(`Failed to request permissions from user. Code is ${error.code}, message is ${error.message}`); +}) + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: $rawfile('getLocation.html'), controller: this.controller }) + .geolocationAccess(true) + .onGeolocationShow((event) => { // 地理位置权限申请通知 + AlertDialog.show({ + title: 'Location permission requests', + message: 'Whether to allow access to location information', + primaryButton: { + value: 'cancel', + action: () => { + if (event) { + event.geolocation.invoke(event.origin, false, false); // 不允许此站点地理位置权限请求 + } + } + }, + secondaryButton: { + value: 'ok', + action: () => { + if (event) { + event.geolocation.invoke(event.origin, true, false); // 允许此站点地理位置权限请求 + } + } + }, + cancel: () => { + if (event) { + event.geolocation.invoke(event.origin, false, false); // 不允许此站点地理位置权限请求 + } + } + }) + }) + } + } +} // [End a_pop_up_window_is_used_to_notify_the_app_side_location_permission_request_message] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/OpenPageNewWin.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/OpenPageNewWin.ets old mode 100755 new mode 100644 index 7f240bbeb8..af16dd1c6e --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/OpenPageNewWin.ets +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/OpenPageNewWin.ets @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start receive_a_web_component_new_window_event] -import { webview } from '@kit.ArkWeb'; - -// 在同一page页有两个Web组件。在WebComponent新开窗口时,会跳转到NewWebViewComp。 -@CustomDialog -struct NewWebViewComp { - controller?: CustomDialogController; - webviewController1: webview.WebviewController = new webview.WebviewController(); - - build() { - Column() { - Web({ src: '', controller: this.webviewController1 }) - .javaScriptAccess(true) - .multiWindowAccess(false) - .onWindowExit(() => { - console.info('NewWebViewComp onWindowExit'); - if (this.controller) { - this.controller.close(); - } - }) - } - } -} - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - dialogController: CustomDialogController | null = null; - - build() { - Column() { - Web({ src: $rawfile('window.html'), controller: this.controller }) - .javaScriptAccess(true) - // 需要使能multiWindowAccess - .multiWindowAccess(true) - .allowWindowOpenMethod(true) - .onWindowNew((event) => { - if (this.dialogController) { - this.dialogController.close(); - } - let popController: webview.WebviewController = new webview.WebviewController(); - this.dialogController = new CustomDialogController({ - builder: NewWebViewComp({ webviewController1: popController }) - }); - this.dialogController.open(); - // 将新窗口对应WebviewController返回给Web内核。 - // 如果不需要打开新窗口请调用event.handler.setWebController接口设置成null。 - // 若不调用event.handler.setWebController接口,会造成render进程阻塞。 - event.handler.setWebController(popController); - }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start receive_a_web_component_new_window_event] +import { webview } from '@kit.ArkWeb'; + +// 在同一page页有两个Web组件。在WebComponent新开窗口时,会跳转到NewWebViewComp。 +@CustomDialog +struct NewWebViewComp { + controller?: CustomDialogController; + webviewController1: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: '', controller: this.webviewController1 }) + .javaScriptAccess(true) + .multiWindowAccess(false) + .onWindowExit(() => { + console.info('NewWebViewComp onWindowExit'); + if (this.controller) { + this.controller.close(); + } + }) + } + } +} + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + dialogController: CustomDialogController | null = null; + + build() { + Column() { + Web({ src: $rawfile('window.html'), controller: this.controller }) + .javaScriptAccess(true) + // 需要使能multiWindowAccess + .multiWindowAccess(true) + .allowWindowOpenMethod(true) + .onWindowNew((event) => { + if (this.dialogController) { + this.dialogController.close(); + } + let popController: webview.WebviewController = new webview.WebviewController(); + this.dialogController = new CustomDialogController({ + builder: NewWebViewComp({ webviewController1: popController }) + }); + this.dialogController.open(); + // 将新窗口对应WebviewController返回给Web内核。 + // 如果不需要打开新窗口请调用event.handler.setWebController接口设置成null。 + // 若不调用event.handler.setWebController接口,会造成render进程阻塞。 + event.handler.setWebController(popController); + }) + } + } +} // [End receive_a_web_component_new_window_event] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/module.json5 old mode 100755 new mode 100644 index 2978d8982a..394d2a4703 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/module.json5 @@ -1,98 +1,98 @@ -/* - * 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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - }, - { - "name" : "ohos.permission.LOCATION", - "reason": "$string:EntryAbility_desc", - "usedScene": { - "abilities": [ - "EntryAbility" - ], - } - }, - { - "name" : "ohos.permission.APPROXIMATELY_LOCATION", - "reason": "$string:EntryAbility_desc", - "usedScene": { - "abilities": [ - "EntryAbility" - ], - } - }, - { - "name" : "ohos.permission.LOCATION_IN_BACKGROUND", - "reason": "$string:EntryAbility_desc", - "usedScene": { - "abilities": [ - "EntryAbility" - ], - } - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + }, + { + "name" : "ohos.permission.LOCATION", + "reason": "$string:EntryAbility_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + } + }, + { + "name" : "ohos.permission.APPROXIMATELY_LOCATION", + "reason": "$string:EntryAbility_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + } + }, + { + "name" : "ohos.permission.LOCATION_IN_BACKGROUND", + "reason": "$string:EntryAbility_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + } + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/darkModePage.html b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/darkModePage.html old mode 100755 new mode 100644 index e075d76ba4..43497f5df3 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/darkModePage.html +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/darkModePage.html @@ -1,35 +1,35 @@ - - - - - - - - - -
-

Dark mode debug page

-
- + + + + + + + + + +
+

Dark mode debug page

+
+ \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/getLocation.html b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/getLocation.html old mode 100755 new mode 100644 index d67a1ca9b3..4ae442f92a --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/getLocation.html +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/getLocation.html @@ -1,34 +1,34 @@ - - - - - -

位置信息

- - - - + + + + + +

位置信息

+ + + + diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index 077a0a6b74..25c6d7f996 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/index.html @@ -1,55 +1,55 @@ - - - - - - - test - - - -
状态信息
- - + + + + + + + test + + + +
状态信息
+ + diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/window.html b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/window.html old mode 100755 new mode 100644 index ff3a612e76..e1a15e6a52 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/window.html +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/window.html @@ -1,34 +1,34 @@ - - - - - - - WindowEvent - - - - - + + + + + + + WindowEvent + + + + + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/hvigorfile.ts b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/oh-package.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/oh-package.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/ohosTest.md b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/AllowGeolocation.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/AllowGeolocation.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ClearAllCookiesSync.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ClearAllCookiesSync.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ConfigCookieSync.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ConfigCookieSync.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DarkMode_one.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DarkMode_one.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DarkMode_two.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DarkMode_two.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DeleteAllData.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DeleteAllData.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DeleteGeolocation.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/DeleteGeolocation.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ExistCookie.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ExistCookie.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/FetchCookieSync.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/FetchCookieSync.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/GetAccessibleGeolocation.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/GetAccessibleGeolocation.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/IncognitoMode_one.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/IncognitoMode_one.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/IncognitoMode_two.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/IncognitoMode_two.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ManageLocPerms_1.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ManageLocPerms_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ManageLocPerms_2.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/ManageLocPerms_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/OpenPageNewWin_1.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/OpenPageNewWin_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/OpenPageNewWin_2.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/screenshots/OpenPageNewWin_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/app.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/app.json5 old mode 100755 new mode 100644 index 23063cfa6e..31ec642dd4 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/app.json5 @@ -1,25 +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.setbasicsttrsrvtstwo", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.setbasicsttrsrvtstwo", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 67e05c262a..4f29f23844 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SetBasicAttrsEvtsTwo" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SetBasicAttrsEvtsTwo" + } + ] +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/README.md b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/build-profile.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/build-profile.json5 old mode 100755 new mode 100644 index 87d40a385e..7a9c78377e --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/build-profile.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/build-profile.json5 @@ -1,52 +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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 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/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/code-linter.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/.gitignore b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/build-profile.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/oh-package.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b23d2fe946..0f2f8b94aa --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Cache_one.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Cache_one.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Cache_two.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Cache_two.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/CookieManagement.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/CookieManagement.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/DomStorage.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/DomStorage.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 027763ceb6..e5fb4c112b --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/Index.ets @@ -1,58 +1,58 @@ -/* - * 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 { router } from '@kit.ArkUI' - -@Entry -@Component -struct Index { - build() { - Column({ space: 10 }) { - Button('UserAgent_one') - .onClick(() => { - router.pushUrl({ url: 'pages/UserAgent_one' }); - }) - Button('UserAgent_two') - .onClick(() => { - router.pushUrl({ url: 'pages/UserAgent_two' }); - }) - Button('UserAgent_three') - .onClick(() => { - router.pushUrl({ url: 'pages/UserAgent_three' }); - }) - Button('CookieManagement') - .onClick(() => { - router.pushUrl({ url: 'pages/CookieManagement' }); - }) - Button('Cache_one') - .onClick(() => { - router.pushUrl({ url: 'pages/Cache_one' }); - }) - Button('Cache_two') - .onClick(() => { - router.pushUrl({ url: 'pages/Cache_two' }); - }) - Button('DomStorage') - .onClick(() => { - router.pushUrl({ url: 'pages/DomStorage' }); - }) - Button('UseMotionDirSensor') - .onClick(() => { - router.pushUrl({ url: 'pages/UseMotionDirSensor' }); - }) - }.height('100%') - .width('100%') - } +/* + * 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 { router } from '@kit.ArkUI' + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('UserAgent_one') + .onClick(() => { + router.pushUrl({ url: 'pages/UserAgent_one' }); + }) + Button('UserAgent_two') + .onClick(() => { + router.pushUrl({ url: 'pages/UserAgent_two' }); + }) + Button('UserAgent_three') + .onClick(() => { + router.pushUrl({ url: 'pages/UserAgent_three' }); + }) + Button('CookieManagement') + .onClick(() => { + router.pushUrl({ url: 'pages/CookieManagement' }); + }) + Button('Cache_one') + .onClick(() => { + router.pushUrl({ url: 'pages/Cache_one' }); + }) + Button('Cache_two') + .onClick(() => { + router.pushUrl({ url: 'pages/Cache_two' }); + }) + Button('DomStorage') + .onClick(() => { + router.pushUrl({ url: 'pages/DomStorage' }); + }) + Button('UseMotionDirSensor') + .onClick(() => { + router.pushUrl({ url: 'pages/UseMotionDirSensor' }); + }) + }.height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UseMotionDirSensor.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UseMotionDirSensor.ets old mode 100755 new mode 100644 index 3e82c27291..d823038993 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UseMotionDirSensor.ets +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UseMotionDirSensor.ets @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start the_type_of_resource_for_which_permission_is_requested] -import { webview } from '@kit.ArkWeb'; -import { abilityAccessCtrl, PermissionRequestResult } from '@kit.AbilityKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - aboutToAppear() { - // 配置Web开启调试模式 - webview.WebviewController.setWebDebuggingAccess(true); - // 访问控制管理, 获取访问控制模块对象。 - let atManager = abilityAccessCtrl.createAtManager(); - try { - atManager.requestPermissionsFromUser(getContext(this) - , ['ohos.permission.ACCELEROMETER', 'ohos.permission.GYROSCOPE'] - , (err: BusinessError, data: PermissionRequestResult) => { - console.info('data:' + JSON.stringify(data)); - console.info('data permissions:' + data.permissions); - console.info('data authResults:' + data.authResults); - }) - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - } - - build() { - Column() { - Web({ src: $rawfile('index.html'), controller: this.controller }) - .onPermissionRequest((event) => { - if (event) { - AlertDialog.show({ - title: 'title', - message: 'text', - primaryButton: { - value: 'deny', - action: () => { - event.request.deny(); - } - }, - secondaryButton: { - value: 'onConfirm', - action: () => { - event.request.grant(event.request.getAccessibleResource()); - } - }, - autoCancel: false, - cancel: () => { - event.request.deny(); - } - }) - } - }) - } - } -} -// [End the_type_of_resource_for_which_permission_is_requested] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start the_type_of_resource_for_which_permission_is_requested] +import { webview } from '@kit.ArkWeb'; +import { abilityAccessCtrl, PermissionRequestResult } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + aboutToAppear() { + // 配置Web开启调试模式 + webview.WebviewController.setWebDebuggingAccess(true); + // 访问控制管理, 获取访问控制模块对象。 + let atManager = abilityAccessCtrl.createAtManager(); + try { + atManager.requestPermissionsFromUser(getContext(this) + , ['ohos.permission.ACCELEROMETER', 'ohos.permission.GYROSCOPE'] + , (err: BusinessError, data: PermissionRequestResult) => { + console.info('data:' + JSON.stringify(data)); + console.info('data permissions:' + data.permissions); + console.info('data authResults:' + data.authResults); + }) + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + } + + build() { + Column() { + Web({ src: $rawfile('index.html'), controller: this.controller }) + .onPermissionRequest((event) => { + if (event) { + AlertDialog.show({ + title: 'title', + message: 'text', + primaryButton: { + value: 'deny', + action: () => { + event.request.deny(); + } + }, + secondaryButton: { + value: 'onConfirm', + action: () => { + event.request.grant(event.request.getAccessibleResource()); + } + }, + autoCancel: false, + cancel: () => { + event.request.deny(); + } + }) + } + }) + } + } +} +// [End the_type_of_resource_for_which_permission_is_requested] diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UserAgent_one.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UserAgent_one.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UserAgent_three.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UserAgent_three.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UserAgent_two.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/ets/pages/UserAgent_two.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/module.json5 old mode 100755 new mode 100644 index 3efcee4a83..94f3336a43 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/module.json5 @@ -1,81 +1,81 @@ -/* - * 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" - } - ] - } - ], - // [Start declare_the_appropriate_sensor_permissions] - "requestPermissions": [ - // [StartExclude declare_the_appropriate_sensor_permissions] - { - "name": "ohos.permission.INTERNET" - }, - // [EndExclude declare_the_appropriate_sensor_permissions] - { - "name" : "ohos.permission.ACCELEROMETER" // 加速度权限 - }, - { - "name" : "ohos.permission.GYROSCOPE" // 陀螺仪权限 - } - ] - // [End declare_the_appropriate_sensor_permissions] - } +/* + * 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" + } + ] + } + ], + // [Start declare_the_appropriate_sensor_permissions] + "requestPermissions": [ + // [StartExclude declare_the_appropriate_sensor_permissions] + { + "name": "ohos.permission.INTERNET" + }, + // [EndExclude declare_the_appropriate_sensor_permissions] + { + "name" : "ohos.permission.ACCELEROMETER" // 加速度权限 + }, + { + "name" : "ohos.permission.GYROSCOPE" // 陀螺仪权限 + } + ] + // [End declare_the_appropriate_sensor_permissions] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index 014f7fad0f..fea52d6524 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/rawfile/index.html @@ -1,154 +1,154 @@ - - - - - - - - - - - 运动和方向传感器 - - - - - -
-

运动和方向:

-
    -
  • -
  • -
  • -
  • -
  • -
  • -
-
- - + + + + + + + + + + + 运动和方向传感器 + + + + + +
+

运动和方向:

+
    +
  • +
  • +
  • +
  • +
  • +
  • +
+
+ + diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/hvigorfile.ts b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/oh-package.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/oh-package.json5 +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/ohosTest.md b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/Cache_one.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/Cache_one.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/Cache_two.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/Cache_two.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/CookieManagement.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/CookieManagement.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/DomStorage.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/DomStorage.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UseMotionDirSensor_1.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UseMotionDirSensor_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UseMotionDirSensor_2.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UseMotionDirSensor_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UserAgent_one.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UserAgent_one.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UserAgent_three.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UserAgent_three.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UserAgent_two.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsTwo/screenshots/UserAgent_two.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/.gitignore b/code/DocsSample/ArkWeb/UseFrontendJSApp/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/app.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/app.json5 old mode 100755 new mode 100644 index 68bbfe1e14..fb2771a6d1 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/app.json5 @@ -1,25 +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.usefrontendjsapp", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.usefrontendjsapp", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 3aba7e3f91..d98b87fae5 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "UseFrontendJSApp" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "UseFrontendJSApp" + } + ] +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/README.md b/code/DocsSample/ArkWeb/UseFrontendJSApp/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/build-profile.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/build-profile.json5 old mode 100755 new mode 100644 index 44608d7953..e1f2fec7b0 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/build-profile.json5 @@ -1,100 +1,100 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry2", - "srcPath": "./entry2", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry3", - "srcPath": "./entry3", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry4", - "srcPath": "./entry4", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry5", - "srcPath": "./entry5", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry2", + "srcPath": "./entry2", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry3", + "srcPath": "./entry3", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry4", + "srcPath": "./entry4", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry5", + "srcPath": "./entry5", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/code-linter.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/.gitignore b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/build-profile.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/oh-package.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/UseFrontendJSApp/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b865efd626..82e98bec44 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 7aaec79f5a..29feaca766 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/UseFrontendJSApp/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index 7f1578abee..3db8398102 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/rawfile/index.html @@ -1,39 +1,39 @@ - - - - - - - -

这是一个测试信息,默认字体为黑色,调用runJavaScript方法后字体为绿色,调用runJavaScriptCodePassed方法后字体为红色

- - - + + + + + + + +

这是一个测试信息,默认字体为黑色,调用runJavaScript方法后字体为绿色,调用runJavaScriptCodePassed方法后字体为红色

+ + + diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/.gitignore b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/build-profile.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/hvigorfile.ts b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/oh-package.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/oh-package.json5 old mode 100755 new mode 100644 index bcb70ff878..6f8ebfffe8 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/oh-package.json5 @@ -1,25 +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": "entry2", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "entry2", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/entry2ability/Entry2Ability.ets old mode 100755 new mode 100644 index cf7edaa3ca..dab8f3ea72 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/entry2ability/Entry2Ability.ets +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/entry2ability/Entry2Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Entry2Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Entry2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets old mode 100755 new mode 100644 index 8e31827bb9..213e60d618 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets @@ -1,27 +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 Entry2BackupAbility 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)); - } +/* + * 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 Entry2BackupAbility 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/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index f1c2b9b420..730f850ab0 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Index.ets @@ -1,62 +1,62 @@ -/* - * 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 { router } from '@kit.ArkUI'; - -@Entry -@Component -struct Index { - build() { - Column({ space: 10 }) { - Button('JavaScriptProxy') - .onClick(() => { - router.pushUrl({ url: 'pages/JavaScriptProxy' }); - }) - Button('Promise_one') - .onClick(() => { - router.pushUrl({ url: 'pages/Promise_one' }); - }) - Button('Promise_two') - .onClick(() => { - router.pushUrl({ url: 'pages/Promise_two' }); - }) - Button('RegisterJavaScriptProxy') - .onClick(() => { - router.pushUrl({ url: 'pages/RegisterJavaScriptProxy' }); - }) - Button('UsageOfComplexTypes_one') - .onClick(() => { - router.pushUrl({ url: 'pages/UsageOfComplexTypes_one' }); - }) - Button('UsageOfComplexTypes_two') - .onClick(() => { - router.pushUrl({ url: 'pages/UsageOfComplexTypes_two' }); - }) - Button('UsageOfComplexTypes_three') - .onClick(() => { - router.pushUrl({ url: 'pages/UsageOfComplexTypes_three' }); - }) - Button('UsageOfComplexTypes_four') - .onClick(() => { - router.pushUrl({ url: 'pages/UsageOfComplexTypes_four' }); - }) - Button('UsageOfComplexTypes_five') - .onClick(() => { - router.pushUrl({ url: 'pages/UsageOfComplexTypes_five' }); - }) - }.height('100%') - .width('100%') - } +/* + * 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 { router } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('JavaScriptProxy') + .onClick(() => { + router.pushUrl({ url: 'pages/JavaScriptProxy' }); + }) + Button('Promise_one') + .onClick(() => { + router.pushUrl({ url: 'pages/Promise_one' }); + }) + Button('Promise_two') + .onClick(() => { + router.pushUrl({ url: 'pages/Promise_two' }); + }) + Button('RegisterJavaScriptProxy') + .onClick(() => { + router.pushUrl({ url: 'pages/RegisterJavaScriptProxy' }); + }) + Button('UsageOfComplexTypes_one') + .onClick(() => { + router.pushUrl({ url: 'pages/UsageOfComplexTypes_one' }); + }) + Button('UsageOfComplexTypes_two') + .onClick(() => { + router.pushUrl({ url: 'pages/UsageOfComplexTypes_two' }); + }) + Button('UsageOfComplexTypes_three') + .onClick(() => { + router.pushUrl({ url: 'pages/UsageOfComplexTypes_three' }); + }) + Button('UsageOfComplexTypes_four') + .onClick(() => { + router.pushUrl({ url: 'pages/UsageOfComplexTypes_four' }); + }) + Button('UsageOfComplexTypes_five') + .onClick(() => { + router.pushUrl({ url: 'pages/UsageOfComplexTypes_five' }); + }) + }.height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/JavaScriptProxy.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/JavaScriptProxy.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_one.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_one.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_two.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_two.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/RegisterJavaScriptProxy.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/RegisterJavaScriptProxy.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_five.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_five.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_four.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_four.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_one.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_one.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_three.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_three.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_two.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_two.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/module.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/module.json5 old mode 100755 new mode 100644 index b171fdbc82..90a4604809 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/module.json5 @@ -1,70 +1,70 @@ -/* - * 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": "entry2", - "type": "entry", - "description": "$string:module_desc", - "mainElement": "Entry2Ability", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry2Ability", - "srcEntry": "./ets/entry2ability/Entry2Ability.ets", - "description": "$string:Entry2Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry2Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "Entry2BackupAbility", - "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.ets", - "type": "backup", - "exported": false, - "metadata": [ - { - "name": "ohos.extension.backup", - "resource": "$profile:backup_config" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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": "entry2", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "Entry2Ability", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry2Ability", + "srcEntry": "./ets/entry2ability/Entry2Ability.ets", + "description": "$string:Entry2Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry2Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "Entry2BackupAbility", + "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index1.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index1.html old mode 100755 new mode 100644 index 3958298a5b..f191e18ba4 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index1.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index1.html @@ -1,29 +1,29 @@ - - - - - - -

- - + + + + + + +

+ + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index2.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index2.html old mode 100755 new mode 100644 index 48629c4688..7ce3b4e0f6 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index2.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index2.html @@ -1,27 +1,27 @@ - - - - - - -

- - + + + + + + +

+ + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index3.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index3.html old mode 100755 new mode 100644 index 962d597f49..e8d5f8a4bc --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index3.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index3.html @@ -1,30 +1,30 @@ - - - - - - -

- - + + + + + + +

+ + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index4.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index4.html old mode 100755 new mode 100644 index 3958298a5b..f191e18ba4 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index4.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index4.html @@ -1,29 +1,29 @@ - - - - - - -

- - + + + + + + +

+ + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index5.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index5.html old mode 100755 new mode 100644 index feaddcf9a7..39411f1290 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index5.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index5.html @@ -1,27 +1,27 @@ - - - - - - -

- - + + + + + + +

+ + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index6.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index6.html old mode 100755 new mode 100644 index 3757d69e80..139cccc5c8 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index6.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index6.html @@ -1,51 +1,51 @@ - - - - - - -

- - - + + + + + + +

+ + + diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index7.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index7.html old mode 100755 new mode 100644 index 2fc570446f..a40f4ca5f9 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index7.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index7.html @@ -1,27 +1,27 @@ - - - - - - -

- - + + + + + + +

+ + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index8.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index8.html old mode 100755 new mode 100644 index d22db3ddf4..b7092a6123 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index8.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index8.html @@ -1,27 +1,27 @@ - - - - - - -

- - + + + + + + +

+ + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index9.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index9.html old mode 100755 new mode 100644 index 2fc570446f..a40f4ca5f9 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index9.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/main/resources/rawfile/index9.html @@ -1,27 +1,27 @@ - - - - - - -

- - + + + + + + +

+ + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/module.json5 old mode 100755 new mode 100644 index f877d50cb7..17410acb16 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/ohosTest/module.json5 @@ -1,26 +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. - */ - -{ - "module": { - "name": "entry2_test", - "type": "feature", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry2_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/test/List.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry2/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/.gitignore b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/build-profile.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/hvigorfile.ts b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/oh-package.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/oh-package.json5 old mode 100755 new mode 100644 index 401ea2ff2d..655d244a4e --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/oh-package.json5 @@ -1,25 +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": "entry3", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "entry3", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/ets/entry3ability/Entry3Ability.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/ets/entry3ability/Entry3Ability.ets old mode 100755 new mode 100644 index c34db223b2..e62e0723b2 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/ets/entry3ability/Entry3Ability.ets +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/ets/entry3ability/Entry3Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Entry3Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Entry3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/module.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/module.json5 old mode 100755 new mode 100644 index f7927bcf5c..a9345ab1e0 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/module.json5 @@ -1,42 +1,42 @@ -/* - * 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": "entry3", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Entry3Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry3Ability", - "srcEntry": "./ets/entry3ability/Entry3Ability.ets", - "description": "$string:Entry3Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry3Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } +/* + * 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": "entry3", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Entry3Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry3Ability", + "srcEntry": "./ets/entry3ability/Entry3Ability.ets", + "description": "$string:Entry3Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry3Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index 3cb37326b7..7e67007432 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/main/resources/rawfile/index.html @@ -1,69 +1,69 @@ - - - - - - - WebView Message Port Demo - - -

WebView Message Port Demo

-
- -
-
-

display received message send from ets

- - - + + + + + + + WebView Message Port Demo + + +

WebView Message Port Demo

+
+ +
+
+

display received message send from ets

+ + + diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9fec93324f..edaba8aaab --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry3_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry3_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/test/List.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry3/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/.gitignore b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/build-profile.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/build-profile.json5 old mode 100755 new mode 100644 index 21cff55421..471250ade0 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/build-profile.json5 @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "apiType": "stageMode", - "buildOption": { - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - "abiFilters": ["arm64-v8a", "x86_64", "armeabi-v7a"] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/ArkWeb/UseFrontendJSApp/entry4/hvigorfile.ts b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/oh-package.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/oh-package.json5 old mode 100755 new mode 100644 index 894d9a4f47..00f4289f03 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/oh-package.json5 @@ -1,26 +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": "entry4", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libentry4.so": "file:./src/main/cpp/types/libentry4" - } +/* + * 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": "entry4", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry4.so": "file:./src/main/cpp/types/libentry4" + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 4fe9719079..14607faba8 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/CMakeLists.txt @@ -1,24 +1,24 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.4.1) -project(NDKJSBridg) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED hello.cpp jsbridge_object.cpp) - -find_library( - # Sets the name of the path variable. - hilog-lib - # Specifies the name of the NDK library that - # you want CMake to locate. - hilog_ndk.z -) - +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(NDKJSBridg) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED hello.cpp jsbridge_object.cpp) + +find_library( + # Sets the name of the path variable. + hilog-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + hilog_ndk.z +) + target_link_libraries(entry PUBLIC libace_napi.z.so ${hilog-lib} libohweb.so) \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/hello.cpp b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/hello.cpp old mode 100755 new mode 100644 index dfb60ac003..096575c6a7 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/hello.cpp +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/hello.cpp @@ -1,327 +1,327 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start node_api_layer_code] -#include "napi/native_api.h" -#include -#include -#include -#include -#include - -#include "hilog/log.h" -#include "web/arkweb_interface.h" -#include "jsbridge_object.h" - -constexpr unsigned int LOG_PRINT_DOMAIN = 0xFF00; -std::shared_ptr jsbridge_object_ptr = nullptr; -static ArkWeb_ControllerAPI *controller = nullptr; -static ArkWeb_ComponentAPI *component = nullptr; - -// 发送JS脚本到H5侧执行,该方法为执行结果的回调。 -static void RunJavaScriptCallback(const char *webTag, const char *result, void *userData) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit RunJavaScriptCallback webTag:%{public}s", webTag); - if (!userData) { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit RunJavaScriptCallback userData is nullptr"); - return; - } - std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); - if (auto jsb_ptr = jsb_weak_ptr.lock()) { - jsb_ptr->RunJavaScriptCallback(result); - } else { - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit RunJavaScriptCallback jsb_weak_ptr lock failed"); - } -} - -// 示例代码 ,注册了1个对象,2个方法 -static void ProxyMethod1( - const char *webTag, const ArkWeb_JavaScriptBridgeData *dataArray, size_t arraySize, void *userData) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit ProxyMethod1 webTag:%{public}s", webTag); - if (!userData) { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit ProxyMethod1 userData is nullptr"); - return; - } - std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); - if (auto jsb_ptr = jsb_weak_ptr.lock()) { - jsb_ptr->ProxyMethod1(dataArray, arraySize); - } else { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit ProxyMethod1 jsb_weak_ptr lock failed"); - } -} - -static void ProxyMethod2( - const char *webTag, const ArkWeb_JavaScriptBridgeData *dataArray, size_t arraySize, void *userData) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit ProxyMethod2 webTag:%{public}s", webTag); - if (!userData) { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit ProxyMethod2 userData is nullptr"); - return; - } - std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); - - std::string jsCode = "runJSRetStr()"; - ArkWeb_JavaScriptObject object = { - (uint8_t *)jsCode.c_str(), jsCode.size(), - &JSBridgeObject::StaticRunJavaScriptCallback, - static_cast(jsbridge_object_ptr->GetWeakPtr()) - }; - controller->runJavaScript(webTag, &object); - - if (auto jsb_ptr = jsb_weak_ptr.lock()) { - jsb_ptr->ProxyMethod2(dataArray, arraySize); - } else { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit ProxyMethod2 JsWeakPtr lock failed"); - } -} - -void ValidCallback(const char *webTag, void *userData) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit ValidCallback webTag: %{public}s", webTag); - if (!userData) { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit ValidCallback userData is nullptr"); - return; - } - std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); - if (auto jsb_ptr = jsb_weak_ptr.lock()) { - jsb_ptr->SaySomething("ValidCallback"); - } else { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit ValidCallback jsb_weak_ptr lock failed"); - } - - // [Start the_front_end_page_calls_application_side_functions] - // 注册对象 - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit RegisterJavaScriptProxy begin"); - ArkWeb_ProxyMethod method1 = {"method1", ProxyMethod1, static_cast(jsbridge_object_ptr->GetWeakPtr())}; - ArkWeb_ProxyMethod method2 = {"method2", ProxyMethod2, static_cast(jsbridge_object_ptr->GetWeakPtr())}; - ArkWeb_ProxyMethod methodList[2] = {method1, method2}; - // 调用Native Development Kit接口注册对象 - // 如此注册的情况下,在H5页面就可以使用proxy.method1、proxy.method1调用此文件下的ProxyMethod1和ProxyMethod2方法了 - ArkWeb_ProxyObject proxyObject = {"ndkProxy", methodList, 2}; - controller->registerJavaScriptProxy(webTag, &proxyObject); - // [End the_front_end_page_calls_application_side_functions] - - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit RegisterJavaScriptProxy end"); -} - -void LoadStartCallback(const char *webTag, void *userData) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit LoadStartCallback webTag: %{public}s", webTag); - if (!userData) { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit LoadStartCallback userData is null"); - return; - } - std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); - if (auto jsb_ptr = jsb_weak_ptr.lock()) { - jsb_ptr->SaySomething("LoadStartCallback"); - } else { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, - "ArkWeb", "Native Development Kit LoadStartCallback jsb_weak_ptr lock failed"); - } -} - -void LoadEndCallback(const char *webTag, void *userData) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit LoadEndCallback webTag: %{public}s", webTag); - if (!userData) { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit LoadEndCallback userData is nullptr"); - return; - } - std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); - if (auto jsb_ptr = jsb_weak_ptr.lock()) { - jsb_ptr->SaySomething("LoadEndCallback"); - } else { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit LoadEndCallback jsb_weak_ptr lock failed"); - } -} - -void DestroyCallback(const char *webTag, void *userData) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit DestoryCallback webTag: %{public}s", webTag); - if (!userData) { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit DestroyCallback userData is nullptr"); - return; - } - std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); - if (auto jsb_ptr = jsb_weak_ptr.lock()) { - jsb_ptr->SaySomething("DestroyCallback"); - } else { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit DestroyCallback jsb_weak_ptr lock failed"); - } -} - -void SetComponentCallback(ArkWeb_ComponentAPI * component, const char* webTagValue) -{ - // [Start the_native_side_registers_the_callback_of_the_component_lifecycle] - if (!ARKWEB_MEMBER_MISSING(component, onControllerAttached)) { - component->onControllerAttached( - webTagValue, ValidCallback, static_cast(jsbridge_object_ptr->GetWeakPtr())); - } else { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onControllerAttached func not exist"); - } - - if (!ARKWEB_MEMBER_MISSING(component, onPageBegin)) { - component->onPageBegin(webTagValue, LoadStartCallback, static_cast(jsbridge_object_ptr->GetWeakPtr())); - } else { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onPageBegin func not exist"); - } - - if (!ARKWEB_MEMBER_MISSING(component, onPageEnd)) { - component->onPageEnd(webTagValue, LoadEndCallback, static_cast(jsbridge_object_ptr->GetWeakPtr())); - } else { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onPageEnd func not exist"); - } - - if (!ARKWEB_MEMBER_MISSING(component, onDestroy)) { - component->onDestroy(webTagValue, DestroyCallback, static_cast(jsbridge_object_ptr->GetWeakPtr())); - } else { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onDestroy func not exist"); - } - // [End the_native_side_registers_the_callback_of_the_component_lifecycle] -} - -// [Start parse_and_store_webtags] -// 解析存储webTag -static napi_value NativeWebInit(napi_env env, napi_callback_info info) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit NativeWebInit start"); - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit NativeWebInit webTag:%{public}s", webTagValue); - - // 将webTag保存在实例对象中 - jsbridge_object_ptr = std::make_shared(webTagValue); - if (jsbridge_object_ptr) - jsbridge_object_ptr->Init(); -// [End parse_and_store_webtags] - - controller = reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_CONTROLLER)); - component = reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_COMPONENT)); - SetComponentCallback(component, webTagValue); - - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit NativeWebInit end"); - return nullptr; -} - -// 发送JS脚本到H5侧执行 -static napi_value RunJavaScript(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit OH_NativeArkWeb_RunJavaScript webTag:%{public}s", webTagValue); - - // 获取第二个参数 jsCode - size_t bufferSize = 0; - napi_get_value_string_utf8(env, args[1], nullptr, 0, &bufferSize); - char *jsCode = new (std::nothrow) char[bufferSize + 1]; - size_t byteLength = 0; - napi_get_value_string_utf8(env, args[1], jsCode, bufferSize + 1, &byteLength); - - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit OH_NativeArkWeb_RunJavaScript jsCode len:%{public}zu", strlen(jsCode)); - - // 构造runJS执行的结构体 - ArkWeb_JavaScriptObject object = {(uint8_t *)jsCode, bufferSize, &JSBridgeObject::StaticRunJavaScriptCallback, - static_cast(jsbridge_object_ptr->GetWeakPtr())}; - controller->runJavaScript(webTagValue, &object); - return nullptr; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"nativeWebInit", nullptr, NativeWebInit, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"runJavaScript", nullptr, RunJavaScript, nullptr, nullptr, nullptr, napi_default, nullptr}, - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start node_api_layer_code] +#include "napi/native_api.h" +#include +#include +#include +#include +#include + +#include "hilog/log.h" +#include "web/arkweb_interface.h" +#include "jsbridge_object.h" + +constexpr unsigned int LOG_PRINT_DOMAIN = 0xFF00; +std::shared_ptr jsbridge_object_ptr = nullptr; +static ArkWeb_ControllerAPI *controller = nullptr; +static ArkWeb_ComponentAPI *component = nullptr; + +// 发送JS脚本到H5侧执行,该方法为执行结果的回调。 +static void RunJavaScriptCallback(const char *webTag, const char *result, void *userData) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit RunJavaScriptCallback webTag:%{public}s", webTag); + if (!userData) { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit RunJavaScriptCallback userData is nullptr"); + return; + } + std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); + if (auto jsb_ptr = jsb_weak_ptr.lock()) { + jsb_ptr->RunJavaScriptCallback(result); + } else { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit RunJavaScriptCallback jsb_weak_ptr lock failed"); + } +} + +// 示例代码 ,注册了1个对象,2个方法 +static void ProxyMethod1( + const char *webTag, const ArkWeb_JavaScriptBridgeData *dataArray, size_t arraySize, void *userData) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit ProxyMethod1 webTag:%{public}s", webTag); + if (!userData) { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit ProxyMethod1 userData is nullptr"); + return; + } + std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); + if (auto jsb_ptr = jsb_weak_ptr.lock()) { + jsb_ptr->ProxyMethod1(dataArray, arraySize); + } else { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit ProxyMethod1 jsb_weak_ptr lock failed"); + } +} + +static void ProxyMethod2( + const char *webTag, const ArkWeb_JavaScriptBridgeData *dataArray, size_t arraySize, void *userData) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit ProxyMethod2 webTag:%{public}s", webTag); + if (!userData) { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit ProxyMethod2 userData is nullptr"); + return; + } + std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); + + std::string jsCode = "runJSRetStr()"; + ArkWeb_JavaScriptObject object = { + (uint8_t *)jsCode.c_str(), jsCode.size(), + &JSBridgeObject::StaticRunJavaScriptCallback, + static_cast(jsbridge_object_ptr->GetWeakPtr()) + }; + controller->runJavaScript(webTag, &object); + + if (auto jsb_ptr = jsb_weak_ptr.lock()) { + jsb_ptr->ProxyMethod2(dataArray, arraySize); + } else { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit ProxyMethod2 JsWeakPtr lock failed"); + } +} + +void ValidCallback(const char *webTag, void *userData) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit ValidCallback webTag: %{public}s", webTag); + if (!userData) { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit ValidCallback userData is nullptr"); + return; + } + std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); + if (auto jsb_ptr = jsb_weak_ptr.lock()) { + jsb_ptr->SaySomething("ValidCallback"); + } else { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit ValidCallback jsb_weak_ptr lock failed"); + } + + // [Start the_front_end_page_calls_application_side_functions] + // 注册对象 + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit RegisterJavaScriptProxy begin"); + ArkWeb_ProxyMethod method1 = {"method1", ProxyMethod1, static_cast(jsbridge_object_ptr->GetWeakPtr())}; + ArkWeb_ProxyMethod method2 = {"method2", ProxyMethod2, static_cast(jsbridge_object_ptr->GetWeakPtr())}; + ArkWeb_ProxyMethod methodList[2] = {method1, method2}; + // 调用Native Development Kit接口注册对象 + // 如此注册的情况下,在H5页面就可以使用proxy.method1、proxy.method1调用此文件下的ProxyMethod1和ProxyMethod2方法了 + ArkWeb_ProxyObject proxyObject = {"ndkProxy", methodList, 2}; + controller->registerJavaScriptProxy(webTag, &proxyObject); + // [End the_front_end_page_calls_application_side_functions] + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit RegisterJavaScriptProxy end"); +} + +void LoadStartCallback(const char *webTag, void *userData) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit LoadStartCallback webTag: %{public}s", webTag); + if (!userData) { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit LoadStartCallback userData is null"); + return; + } + std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); + if (auto jsb_ptr = jsb_weak_ptr.lock()) { + jsb_ptr->SaySomething("LoadStartCallback"); + } else { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, + "ArkWeb", "Native Development Kit LoadStartCallback jsb_weak_ptr lock failed"); + } +} + +void LoadEndCallback(const char *webTag, void *userData) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit LoadEndCallback webTag: %{public}s", webTag); + if (!userData) { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit LoadEndCallback userData is nullptr"); + return; + } + std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); + if (auto jsb_ptr = jsb_weak_ptr.lock()) { + jsb_ptr->SaySomething("LoadEndCallback"); + } else { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit LoadEndCallback jsb_weak_ptr lock failed"); + } +} + +void DestroyCallback(const char *webTag, void *userData) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit DestoryCallback webTag: %{public}s", webTag); + if (!userData) { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit DestroyCallback userData is nullptr"); + return; + } + std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); + if (auto jsb_ptr = jsb_weak_ptr.lock()) { + jsb_ptr->SaySomething("DestroyCallback"); + } else { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit DestroyCallback jsb_weak_ptr lock failed"); + } +} + +void SetComponentCallback(ArkWeb_ComponentAPI * component, const char* webTagValue) +{ + // [Start the_native_side_registers_the_callback_of_the_component_lifecycle] + if (!ARKWEB_MEMBER_MISSING(component, onControllerAttached)) { + component->onControllerAttached( + webTagValue, ValidCallback, static_cast(jsbridge_object_ptr->GetWeakPtr())); + } else { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onControllerAttached func not exist"); + } + + if (!ARKWEB_MEMBER_MISSING(component, onPageBegin)) { + component->onPageBegin(webTagValue, LoadStartCallback, static_cast(jsbridge_object_ptr->GetWeakPtr())); + } else { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onPageBegin func not exist"); + } + + if (!ARKWEB_MEMBER_MISSING(component, onPageEnd)) { + component->onPageEnd(webTagValue, LoadEndCallback, static_cast(jsbridge_object_ptr->GetWeakPtr())); + } else { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onPageEnd func not exist"); + } + + if (!ARKWEB_MEMBER_MISSING(component, onDestroy)) { + component->onDestroy(webTagValue, DestroyCallback, static_cast(jsbridge_object_ptr->GetWeakPtr())); + } else { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onDestroy func not exist"); + } + // [End the_native_side_registers_the_callback_of_the_component_lifecycle] +} + +// [Start parse_and_store_webtags] +// 解析存储webTag +static napi_value NativeWebInit(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit NativeWebInit start"); + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit NativeWebInit webTag:%{public}s", webTagValue); + + // 将webTag保存在实例对象中 + jsbridge_object_ptr = std::make_shared(webTagValue); + if (jsbridge_object_ptr) + jsbridge_object_ptr->Init(); +// [End parse_and_store_webtags] + + controller = reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_CONTROLLER)); + component = reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_COMPONENT)); + SetComponentCallback(component, webTagValue); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit NativeWebInit end"); + return nullptr; +} + +// 发送JS脚本到H5侧执行 +static napi_value RunJavaScript(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit OH_NativeArkWeb_RunJavaScript webTag:%{public}s", webTagValue); + + // 获取第二个参数 jsCode + size_t bufferSize = 0; + napi_get_value_string_utf8(env, args[1], nullptr, 0, &bufferSize); + char *jsCode = new (std::nothrow) char[bufferSize + 1]; + size_t byteLength = 0; + napi_get_value_string_utf8(env, args[1], jsCode, bufferSize + 1, &byteLength); + + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit OH_NativeArkWeb_RunJavaScript jsCode len:%{public}zu", strlen(jsCode)); + + // 构造runJS执行的结构体 + ArkWeb_JavaScriptObject object = {(uint8_t *)jsCode, bufferSize, &JSBridgeObject::StaticRunJavaScriptCallback, + static_cast(jsbridge_object_ptr->GetWeakPtr())}; + controller->runJavaScript(webTagValue, &object); + return nullptr; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"nativeWebInit", nullptr, NativeWebInit, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"runJavaScript", nullptr, RunJavaScript, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } // [End node_api_layer_code] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.cpp b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.cpp old mode 100755 new mode 100644 index 263795347a..b35bebbf50 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.cpp +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.cpp @@ -1,90 +1,90 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start handles_javascript_calls_from_webview] -#include "jsbridge_object.h" - -#include "hilog/log.h" - -constexpr unsigned int LOG_PRINT_DOMAIN = 0xFF00; - -JSBridgeObject::JSBridgeObject(const char *webTag) : webTag_(webTag) {} - -void JSBridgeObject::Init() { weak_ptr_ = shared_from_this(); } - -std::weak_ptr *JSBridgeObject::GetWeakPtr() { return &weak_ptr_; } - -void JSBridgeObject::StaticRunJavaScriptCallback( - const char *webTag, const ArkWeb_JavaScriptBridgeData *data, void *userData) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "JSBridgeObject StaticRunJavaScriptCallback webTag:%{public}s", webTag); - if (!userData) { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "JSBridgeObject StaticRunJavaScriptCallback userData is nullptr"); - return; - } - std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); - if (auto jsb_ptr = jsb_weak_ptr.lock()) { - std::string result((char *)data->buffer, data->size); - jsb_ptr->RunJavaScriptCallback(result.c_str()); - } else { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "JSBridgeObject StaticRunJavaScriptCallback jsb_weak_ptr lock failed"); - } -} - -void JSBridgeObject::RunJavaScriptCallback(const char *result) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "JSBridgeObject OH_NativeArkWeb_RunJavaScript result:%{public}s", result); -} - -void JSBridgeObject::ProxyMethod1(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "JSBridgeObject ProxyMethod1 argc:%{public}d", - arraySize); - for (int i = 0; i < arraySize; i++) { - std::string result((char *)dataArray[i].buffer, dataArray[i].size); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "JSBridgeObject ProxyMethod1 argv[%{public}d]:%{public}s, size:%{public}d", - i, result.c_str(), dataArray[i].size); - } -} - -void JSBridgeObject::ProxyMethod2(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "JSBridgeObject ProxyMethod2 argc:%{public}d", arraySize); - for (int i = 0; i < arraySize; i++) { - std::string result((char *)dataArray[i].buffer, dataArray[i].size); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "JSBridgeObject ProxyMethod2 argv[%{public}d]:%{public}s, size:%{public}d", - i, result.c_str(), dataArray[i].size); - } -} - -void JSBridgeObject::SaySomething(const char *say) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "JSBridgeObject SaySomething argc:%{public}s", say); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start handles_javascript_calls_from_webview] +#include "jsbridge_object.h" + +#include "hilog/log.h" + +constexpr unsigned int LOG_PRINT_DOMAIN = 0xFF00; + +JSBridgeObject::JSBridgeObject(const char *webTag) : webTag_(webTag) {} + +void JSBridgeObject::Init() { weak_ptr_ = shared_from_this(); } + +std::weak_ptr *JSBridgeObject::GetWeakPtr() { return &weak_ptr_; } + +void JSBridgeObject::StaticRunJavaScriptCallback( + const char *webTag, const ArkWeb_JavaScriptBridgeData *data, void *userData) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "JSBridgeObject StaticRunJavaScriptCallback webTag:%{public}s", webTag); + if (!userData) { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "JSBridgeObject StaticRunJavaScriptCallback userData is nullptr"); + return; + } + std::weak_ptr jsb_weak_ptr = *static_cast *>(userData); + if (auto jsb_ptr = jsb_weak_ptr.lock()) { + std::string result((char *)data->buffer, data->size); + jsb_ptr->RunJavaScriptCallback(result.c_str()); + } else { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "JSBridgeObject StaticRunJavaScriptCallback jsb_weak_ptr lock failed"); + } +} + +void JSBridgeObject::RunJavaScriptCallback(const char *result) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "JSBridgeObject OH_NativeArkWeb_RunJavaScript result:%{public}s", result); +} + +void JSBridgeObject::ProxyMethod1(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "JSBridgeObject ProxyMethod1 argc:%{public}d", + arraySize); + for (int i = 0; i < arraySize; i++) { + std::string result((char *)dataArray[i].buffer, dataArray[i].size); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "JSBridgeObject ProxyMethod1 argv[%{public}d]:%{public}s, size:%{public}d", + i, result.c_str(), dataArray[i].size); + } +} + +void JSBridgeObject::ProxyMethod2(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "JSBridgeObject ProxyMethod2 argc:%{public}d", arraySize); + for (int i = 0; i < arraySize; i++) { + std::string result((char *)dataArray[i].buffer, dataArray[i].size); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "JSBridgeObject ProxyMethod2 argv[%{public}d]:%{public}s, size:%{public}d", + i, result.c_str(), dataArray[i].size); + } +} + +void JSBridgeObject::SaySomething(const char *say) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "JSBridgeObject SaySomething argc:%{public}s", say); +} // [End handles_javascript_calls_from_webview] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.h b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.h old mode 100755 new mode 100644 index 887af98b16..68d1e15bdc --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.h +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.h @@ -1,40 +1,40 @@ -#ifndef HEADER_GUARD_H -#define HEADER_GUARD_H -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start the_service_code_on_the_native_side] -#include "web/arkweb_type.h" -#include - -class JSBridgeObject : public std::enable_shared_from_this { -public: - explicit JSBridgeObject(const char* webTag); - ~JSBridgeObject() = default; - void Init(); - std::weak_ptr* GetWeakPtr(); - static void StaticRunJavaScriptCallback(const char *webTag, const ArkWeb_JavaScriptBridgeData *data, - void *userData); - void RunJavaScriptCallback(const char *result); - void ProxyMethod1(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize); - void ProxyMethod2(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize); - void SaySomething(const char* say); - -private: - std::string webTag_; - std::weak_ptr weak_ptr_; -}; -// [End the_service_code_on_the_native_side] +#ifndef HEADER_GUARD_H +#define HEADER_GUARD_H +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start the_service_code_on_the_native_side] +#include "web/arkweb_type.h" +#include + +class JSBridgeObject : public std::enable_shared_from_this { +public: + explicit JSBridgeObject(const char* webTag); + ~JSBridgeObject() = default; + void Init(); + std::weak_ptr* GetWeakPtr(); + static void StaticRunJavaScriptCallback(const char *webTag, const ArkWeb_JavaScriptBridgeData *data, + void *userData); + void RunJavaScriptCallback(const char *result); + void ProxyMethod1(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize); + void ProxyMethod2(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize); + void SaySomething(const char* say); + +private: + std::string webTag_; + std::weak_ptr weak_ptr_; +}; +// [End the_service_code_on_the_native_side] #endif // HEADER_GUARD_H \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 0deb1bb76f..820107b7d2 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/napi_init.cpp @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" - -static napi_value Add(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - napi_valuetype valuetype0; - napi_typeof(env, args[0], &valuetype0); - - napi_valuetype valuetype1; - napi_typeof(env, args[1], &valuetype1); - - double value0; - napi_get_value_double(env, args[0], &value0); - - double value1; - napi_get_value_double(env, args[1], &value1); - - napi_value sum; - napi_create_double(env, value0 + value1, &sum); - - return sum; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/Index.d.ts b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/Index.d.ts old mode 100755 new mode 100644 index f218f5ee91..a12836b52e --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/Index.d.ts +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/Index.d.ts @@ -1,19 +1,19 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start the_arkts_interface_is_exposed_on_the_node_api_side] -export const nativeWebInit: (webName: string) => void; -export const runJavaScript: (webName: string, jsCode: string) => void; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start the_arkts_interface_is_exposed_on_the_node_api_side] +export const nativeWebInit: (webName: string) => void; +export const runJavaScript: (webName: string, jsCode: string) => void; // [End the_arkts_interface_is_exposed_on_the_node_api_side] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/oh-package.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/oh-package.json5 old mode 100755 new mode 100644 index 3b5002fcab..1228596cfe --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/oh-package.json5 @@ -1,21 +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": "libentry4.so", - "types": "./Index.d.ts", - "version": "1.0.0", - "description": "Please describe the basic information." +/* + * 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": "libentry4.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/ArkWeb/UseFrontendJSApp/entry4/src/main/ets/entry4ability/Entry4Ability.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/ets/entry4ability/Entry4Ability.ets old mode 100755 new mode 100644 index af4f86a3ab..84e3ab74f2 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/ets/entry4ability/Entry4Ability.ets +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/ets/entry4ability/Entry4Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Entry4Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Entry4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 0de2b59620..8a21a25554 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/ets/pages/Index.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start interact_with_the_webview_via_the_native_api] -// [Start use_the_native_interface_to_bind_arkweb] -import testNapi from 'libentry.so'; -import { webview } from '@kit.ArkWeb'; - -class testObj { - constructor() { - } - - test(): string { - console.log('ArkUI Web Component'); - return 'ArkUI Web Component'; - } - - toString(): void { - console.log('Web Component toString'); - } -} - -@Entry -@Component -struct Index { - // [Start customize_a_webtag_and_send_it_to_the_native_side_of_the_application] - webTag: string = 'ArkWeb1'; - controller: webview.WebviewController = new webview.WebviewController(this.webTag); - @State testObjtest: testObj = new testObj(); - - aboutToAppear() { - console.info('aboutToAppear'); - //初始化web Native Development Kit - testNapi.nativeWebInit(this.webTag); - // [End customize_a_webtag_and_send_it_to_the_native_side_of_the_application] - } - // [End use_the_native_interface_to_bind_arkweb] - - build() { - Column() { - Row() { - Button('runJS hello') - .fontSize(12) - .onClick(() => { - testNapi.runJavaScript(this.webTag, 'runJSRetStr(\"" + "hello" + "\")'); - }) - }.height('20%') - - Row() { - Web({ src: $rawfile('runJS.html'), controller: this.controller }) - .javaScriptAccess(true) - .fileAccess(true) - .onControllerAttached(() => { - console.error('Native Development Kit onControllerAttached webId: ' + this.controller.getWebId()); - }) - }.height('80%') - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start interact_with_the_webview_via_the_native_api] +// [Start use_the_native_interface_to_bind_arkweb] +import testNapi from 'libentry.so'; +import { webview } from '@kit.ArkWeb'; + +class testObj { + constructor() { + } + + test(): string { + console.log('ArkUI Web Component'); + return 'ArkUI Web Component'; + } + + toString(): void { + console.log('Web Component toString'); + } +} + +@Entry +@Component +struct Index { + // [Start customize_a_webtag_and_send_it_to_the_native_side_of_the_application] + webTag: string = 'ArkWeb1'; + controller: webview.WebviewController = new webview.WebviewController(this.webTag); + @State testObjtest: testObj = new testObj(); + + aboutToAppear() { + console.info('aboutToAppear'); + //初始化web Native Development Kit + testNapi.nativeWebInit(this.webTag); + // [End customize_a_webtag_and_send_it_to_the_native_side_of_the_application] + } + // [End use_the_native_interface_to_bind_arkweb] + + build() { + Column() { + Row() { + Button('runJS hello') + .fontSize(12) + .onClick(() => { + testNapi.runJavaScript(this.webTag, 'runJSRetStr(\"" + "hello" + "\")'); + }) + }.height('20%') + + Row() { + Web({ src: $rawfile('runJS.html'), controller: this.controller }) + .javaScriptAccess(true) + .fileAccess(true) + .onControllerAttached(() => { + console.error('Native Development Kit onControllerAttached webId: ' + this.controller.getWebId()); + }) + }.height('80%') + } + } +} // [End interact_with_the_webview_via_the_native_api] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/module.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/module.json5 old mode 100755 new mode 100644 index f98aa30d84..afa13b4ebd --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/module.json5 @@ -1,42 +1,42 @@ -/* - * 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": "entry4", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Entry4Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry4Ability", - "srcEntry": "./ets/entry4ability/Entry4Ability.ets", - "description": "$string:Entry4Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry4Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } +/* + * 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": "entry4", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Entry4Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry4Ability", + "srcEntry": "./ets/entry4ability/Entry4Ability.ets", + "description": "$string:Entry4Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry4Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/rawfile/runJS.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/rawfile/runJS.html old mode 100755 new mode 100644 index 34c305147c..a6ebe9e466 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/rawfile/runJS.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/main/resources/rawfile/runJS.html @@ -1,93 +1,93 @@ - - - - - - - - - run javascript demo - - -

run JavaScript Ext demo

-

-
- -
-
- -
- - - + + + + + + + + + run javascript demo + + +

run JavaScript Ext demo

+

+
+ +
+
+ +
+ + + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/mock/Libentry4.mock.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/mock/Libentry4.mock.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 4d2bdff32b..12ba91e946 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry4_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry4_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/test/List.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry4/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/.gitignore b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/build-profile.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/build-profile.json5 old mode 100755 new mode 100644 index 21cff55421..471250ade0 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/build-profile.json5 @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "apiType": "stageMode", - "buildOption": { - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "", - "abiFilters": ["arm64-v8a", "x86_64", "armeabi-v7a"] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/ArkWeb/UseFrontendJSApp/entry5/hvigorfile.ts b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/oh-package.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/oh-package.json5 old mode 100755 new mode 100644 index 15af4af3a3..b58415e458 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/oh-package.json5 @@ -1,26 +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": "entry5", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libentry5.so": "file:./src/main/cpp/types/libentry5" - } +/* + * 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": "entry5", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry5.so": "file:./src/main/cpp/types/libentry5" + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/CMakeLists.txt b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index deaa05dd7a..46be202fc2 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/CMakeLists.txt @@ -1,25 +1,25 @@ -# entry/src/main/cpp/CMakeLists.txt -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.4.1) -project(NDKPostMessage) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED hello.cpp) - -find_library( - # Sets the name of the path variable. - hilog-lib - # Specifies the name of the NDK library that - # you want CMake to locate. - hilog_ndk.z -) - -target_link_libraries(entry PUBLIC libace_napi.z.so ${hilog-lib} libohweb.so) +# entry/src/main/cpp/CMakeLists.txt +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(NDKPostMessage) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED hello.cpp) + +find_library( + # Sets the name of the path variable. + hilog-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + hilog_ndk.z +) + +target_link_libraries(entry PUBLIC libace_napi.z.so ${hilog-lib} libohweb.so) diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/hello.cpp b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/hello.cpp old mode 100755 new mode 100644 index 228c754290..cde6ffb2e4 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/hello.cpp +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/hello.cpp @@ -1,469 +1,469 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start the_node_api_layer_code_for_the_data_channel_between_the_application_side_and_the_frontend_page] -#include "napi/native_api.h" -#include -#include -#include -#include -#include -#include -#include "hilog/log.h" -#include "web/arkweb_interface.h" -#include - -constexpr unsigned int LOG_PRINT_DOMAIN = 0xFF00; -ArkWeb_ControllerAPI *controller = nullptr; - -ArkWeb_WebMessagePortAPI *webMessagePort = nullptr; -ArkWeb_WebMessageAPI *webMessage = nullptr; -size_t g_webMessagePortSize = 0; -ArkWeb_WebMessagePortPtr *g_web_message_port_arr = nullptr; - -static void WebMessagePortCallback( - const char *webTag, const ArkWeb_WebMessagePortPtr port, const ArkWeb_WebMessagePtr message, void *userData) -{ - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit WebMesagePortCallback webTag:%{public}s,messageType:%{public}d", - webTag, webMessage->getType(message)); - size_t len = 0; - void *back = webMessage->getData(message, &len); - if (webMessage->getType(message) == ArkWeb_WebMessageType::ARKWEB_STRING) { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit WebMesagePortCallback message:%{public}s,messageSize:%{public}d", back, len); - } else if (webMessage->getType(message) == ArkWeb_WebMessageType::ARKWEB_BUFFER) { - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit WebMesagePortCallback messageSize:%{public}d", len); - } -} - -static napi_value NativeWebInit(napi_env env, napi_callback_info info) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit NativeWebInit start"); - size_t argc = 1; - napi_value args[1] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit NativeWebInit webTag:%{public}s", webTagValue); - - controller = reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_CONTROLLER)); - if (controller) - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "get ArkWeb_ControllerAPI success"); - - webMessagePort = - reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_WEB_MESSAGE_PORT)); - if (webMessagePort) - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "get ArkWeb_WebMessagePortAPI success"); - - webMessage = reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_WEB_MESSAGE)); - if (webMessage) - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "get ArkWeb_WebMessageAPI success"); - - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit NativeWebInit end"); - - return nullptr; -} - -static napi_value createWebMessagePorts(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit Refresh webTag:%{public}s", webTagValue); - - // 初始化端口 - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit createWebMessagePorts begin"); - g_web_message_port_arr = controller->createWebMessagePorts(webTagValue, &g_webMessagePortSize); - // 把其中一个端口发送给HTML - ArkWeb_ErrorCode code = - controller->postWebMessage(webTagValue, "init_web_messageport", g_web_message_port_arr, 1, "*"); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit postWebMessage ArkWeb_ErrorCode:%{public}d", code); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit createWebMessagePorts end, web message port size:%{public}d", g_webMessagePortSize); - return nullptr; -} - -static napi_value postMessage(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit Refresh webTag:%{public}s", webTagValue); - - // 发送消息 - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit postMessage begin"); - - if (g_web_message_port_arr == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); - return nullptr; - } - ArkWeb_WebMessagePtr message = webMessage->createWebMessage(); - webMessage->setType(message, ArkWeb_WebMessageType::ARKWEB_STRING); - std::string str = "send string from native"; - webMessage->setData(message, (void *)str.c_str(), str.length() + 1); - ArkWeb_ErrorCode code = webMessagePort->postMessage(g_web_message_port_arr[1], webTagValue, message); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit postMessage ArkWeb_ErrorCode:%{public}d", code); - webMessage->destroyWebMessage(&message); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit postMessage end, web message port size:%{public}d", g_webMessagePortSize); - return nullptr; -} - - -// 在线程中发消息 -void sendMessage(const char *webTag, const ArkWeb_WebMessagePtr message) -{ - // 发送1000次 - for (int i = 0; i < 1000; i++) { - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "sendMessage in thread %{public}d", i); - if (g_web_message_port_arr && webTag && message) { - webMessagePort->postMessage(g_web_message_port_arr[1], webTag, message); - } - } -} -static napi_value postMessageThread(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit Refresh webTag:%{public}s", webTagValue); - - // 构造消息 - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit postMessage begin"); - - if (g_web_message_port_arr == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); - return nullptr; - } - ArkWeb_WebMessagePtr message = webMessage->createWebMessage(); - webMessage->setType(message, ArkWeb_WebMessageType::ARKWEB_STRING); - std::string str = "thread message"; - webMessage->setData(message, (void *)str.c_str(), str.length() + 1); - const int numThreads = 5; - std::thread threads[numThreads]; - - // 创建线程 - for (int i = 0; i < numThreads; ++i) { - threads[i] = std::thread(sendMessage, webTagValue, message); - } - - // 等待所有线程完成 - for (int i = 0; i < numThreads; ++i) { - threads[i].detach(); - } - return nullptr; -} - -// 在线程中注册回调 -void SetHandler(const char *webTag) -{ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "setMessageEventHandler in thread"); - webMessagePort->setMessageEventHandler(g_web_message_port_arr[1], webTag, WebMessagePortCallback, NULL); -} - -static napi_value setMessageEventHandlerThread(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit Refresh webTag:%{public}s", webTagValue); - - // 注册回调 - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit SetMessageEventHandler begin"); - if (g_web_message_port_arr == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); - return nullptr; - } - std::thread thread(SetHandler, webTagValue); - thread.detach(); - webMessagePort->setMessageEventHandler(g_web_message_port_arr[1], webTagValue, WebMessagePortCallback, NULL); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit SetMessageEventHandler end, web message port size:%{public}d", g_webMessagePortSize); - return nullptr; -} -static napi_value postNoneMessage(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, - "ArkWeb", "Native Development Kit Refresh webTag:%{public}s", webTagValue); - - // 发送消息 - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit 发消息开始"); - - if (g_web_message_port_arr == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); - return nullptr; - } - ArkWeb_WebMessagePtr message = webMessage->createWebMessage(); - webMessage->setType(message, ArkWeb_WebMessageType::ARKWEB_NONE); - std::string str = "send string from native"; - webMessage->setData(message, (void *)str.c_str(), str.length() + 1); - webMessagePort->postMessage(g_web_message_port_arr[1], webTagValue, message); - webMessage->destroyWebMessage(&message); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit postMessage end, web message port size:%{public}d", g_webMessagePortSize); - return nullptr; -} - -static napi_value postBufferMessage(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit Refresh webTag:%{public}s", webTagValue); - - // 发送消息 - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit postMessage begin"); - - if (g_web_message_port_arr == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); - return nullptr; - } - ArkWeb_WebMessagePtr message1 = webMessage->createWebMessage(); - webMessage->setType(message1, ArkWeb_WebMessageType::ARKWEB_BUFFER); - std::string str1 = "send buffer from native"; - webMessage->setData(message1, (void *)str1.c_str(), str1.length()); - webMessagePort->postMessage(g_web_message_port_arr[1], webTagValue, message1); - webMessage->destroyWebMessage(&message1); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit postMessage end, web message port size:%{public}d", g_webMessagePortSize); - return nullptr; -} - -static napi_value setMessageEventHandler(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit Refresh webTag:%{public}s", webTagValue); - - // 注册回调 - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit SetMessageEventHandler begin"); - if (g_web_message_port_arr == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); - return nullptr; - } - webMessagePort->setMessageEventHandler(g_web_message_port_arr[1], webTagValue, WebMessagePortCallback, NULL); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit SetMessageEventHandler end, web message port size:%{public}d", g_webMessagePortSize); - return nullptr; -} - -static napi_value closeMessagePort(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit Refresh webTag:%{public}s", webTagValue); - - // 关闭端口,先调用close,再调用destroyWebMessagePorts - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit SetMessageEventHandler begin"); - if (g_web_message_port_arr == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); - return nullptr; - } - webMessagePort->close(g_web_message_port_arr[0], webTagValue); - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit SetMessageEventHandler end, web message port size:%{public}d", g_webMessagePortSize); - controller->refresh(webTagValue); - return nullptr; -} - -static napi_value destroyMessagePort(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit Refresh webTag:%{public}s", webTagValue); - - // 释放内存,先调用close,再调用destroyWebMessagePorts - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit SetMessageEventHandler begin"); - if (g_web_message_port_arr == nullptr) { - OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); - return nullptr; - } - controller->destroyWebMessagePorts(&g_web_message_port_arr, g_webMessagePortSize); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit SetMessageEventHandler end, web message port size:%{public}d", g_webMessagePortSize); - return nullptr; -} - -static napi_value destroyNullMessagePort(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - // 获取第一个参数webTag - size_t webTagSize = 0; - napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); - char *webTagValue = new (std::nothrow) char[webTagSize + 1]; - size_t webTagLength = 0; - napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit Refresh webTag:%{public}s", webTagValue); - - // 释放内存,先调用close,再调用destroyWebMessagePorts - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit SetMessageEventHandler begin"); - - controller->destroyWebMessagePorts(&g_web_message_port_arr, g_webMessagePortSize); - - OH_LOG_Print( - LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", - "Native Development Kit SetMessageEventHandler end, web message port size:%{public}d", g_webMessagePortSize); - return nullptr; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"nativeWebInit", nullptr, NativeWebInit, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"createWebMessagePorts", nullptr, createWebMessagePorts, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"postMessage", nullptr, postMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"postNoneMessage", nullptr, postNoneMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"postBufferMessage", nullptr, postBufferMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"setMessageEventHandler", nullptr, setMessageEventHandler, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"closeMessagePort", nullptr, closeMessagePort, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"destroyMessagePort", nullptr, destroyMessagePort, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"postMessageThread", nullptr, postMessageThread, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"setMessageEventHandlerThread", nullptr, setMessageEventHandlerThread, nullptr, nullptr, nullptr, - napi_default, nullptr}, - {"destroyNullMessagePort", nullptr, destroyNullMessagePort, nullptr, nullptr, nullptr, napi_default, nullptr}, - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start the_node_api_layer_code_for_the_data_channel_between_the_application_side_and_the_frontend_page] +#include "napi/native_api.h" +#include +#include +#include +#include +#include +#include +#include "hilog/log.h" +#include "web/arkweb_interface.h" +#include + +constexpr unsigned int LOG_PRINT_DOMAIN = 0xFF00; +ArkWeb_ControllerAPI *controller = nullptr; + +ArkWeb_WebMessagePortAPI *webMessagePort = nullptr; +ArkWeb_WebMessageAPI *webMessage = nullptr; +size_t g_webMessagePortSize = 0; +ArkWeb_WebMessagePortPtr *g_web_message_port_arr = nullptr; + +static void WebMessagePortCallback( + const char *webTag, const ArkWeb_WebMessagePortPtr port, const ArkWeb_WebMessagePtr message, void *userData) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit WebMesagePortCallback webTag:%{public}s,messageType:%{public}d", + webTag, webMessage->getType(message)); + size_t len = 0; + void *back = webMessage->getData(message, &len); + if (webMessage->getType(message) == ArkWeb_WebMessageType::ARKWEB_STRING) { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit WebMesagePortCallback message:%{public}s,messageSize:%{public}d", back, len); + } else if (webMessage->getType(message) == ArkWeb_WebMessageType::ARKWEB_BUFFER) { + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit WebMesagePortCallback messageSize:%{public}d", len); + } +} + +static napi_value NativeWebInit(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit NativeWebInit start"); + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit NativeWebInit webTag:%{public}s", webTagValue); + + controller = reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_CONTROLLER)); + if (controller) + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "get ArkWeb_ControllerAPI success"); + + webMessagePort = + reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_WEB_MESSAGE_PORT)); + if (webMessagePort) + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "get ArkWeb_WebMessagePortAPI success"); + + webMessage = reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_WEB_MESSAGE)); + if (webMessage) + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "get ArkWeb_WebMessageAPI success"); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit NativeWebInit end"); + + return nullptr; +} + +static napi_value createWebMessagePorts(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit Refresh webTag:%{public}s", webTagValue); + + // 初始化端口 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit createWebMessagePorts begin"); + g_web_message_port_arr = controller->createWebMessagePorts(webTagValue, &g_webMessagePortSize); + // 把其中一个端口发送给HTML + ArkWeb_ErrorCode code = + controller->postWebMessage(webTagValue, "init_web_messageport", g_web_message_port_arr, 1, "*"); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit postWebMessage ArkWeb_ErrorCode:%{public}d", code); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit createWebMessagePorts end, web message port size:%{public}d", g_webMessagePortSize); + return nullptr; +} + +static napi_value postMessage(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit Refresh webTag:%{public}s", webTagValue); + + // 发送消息 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit postMessage begin"); + + if (g_web_message_port_arr == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); + return nullptr; + } + ArkWeb_WebMessagePtr message = webMessage->createWebMessage(); + webMessage->setType(message, ArkWeb_WebMessageType::ARKWEB_STRING); + std::string str = "send string from native"; + webMessage->setData(message, (void *)str.c_str(), str.length() + 1); + ArkWeb_ErrorCode code = webMessagePort->postMessage(g_web_message_port_arr[1], webTagValue, message); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit postMessage ArkWeb_ErrorCode:%{public}d", code); + webMessage->destroyWebMessage(&message); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit postMessage end, web message port size:%{public}d", g_webMessagePortSize); + return nullptr; +} + + +// 在线程中发消息 +void sendMessage(const char *webTag, const ArkWeb_WebMessagePtr message) +{ + // 发送1000次 + for (int i = 0; i < 1000; i++) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "sendMessage in thread %{public}d", i); + if (g_web_message_port_arr && webTag && message) { + webMessagePort->postMessage(g_web_message_port_arr[1], webTag, message); + } + } +} +static napi_value postMessageThread(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit Refresh webTag:%{public}s", webTagValue); + + // 构造消息 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit postMessage begin"); + + if (g_web_message_port_arr == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); + return nullptr; + } + ArkWeb_WebMessagePtr message = webMessage->createWebMessage(); + webMessage->setType(message, ArkWeb_WebMessageType::ARKWEB_STRING); + std::string str = "thread message"; + webMessage->setData(message, (void *)str.c_str(), str.length() + 1); + const int numThreads = 5; + std::thread threads[numThreads]; + + // 创建线程 + for (int i = 0; i < numThreads; ++i) { + threads[i] = std::thread(sendMessage, webTagValue, message); + } + + // 等待所有线程完成 + for (int i = 0; i < numThreads; ++i) { + threads[i].detach(); + } + return nullptr; +} + +// 在线程中注册回调 +void SetHandler(const char *webTag) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "setMessageEventHandler in thread"); + webMessagePort->setMessageEventHandler(g_web_message_port_arr[1], webTag, WebMessagePortCallback, NULL); +} + +static napi_value setMessageEventHandlerThread(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit Refresh webTag:%{public}s", webTagValue); + + // 注册回调 + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit SetMessageEventHandler begin"); + if (g_web_message_port_arr == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); + return nullptr; + } + std::thread thread(SetHandler, webTagValue); + thread.detach(); + webMessagePort->setMessageEventHandler(g_web_message_port_arr[1], webTagValue, WebMessagePortCallback, NULL); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit SetMessageEventHandler end, web message port size:%{public}d", g_webMessagePortSize); + return nullptr; +} +static napi_value postNoneMessage(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, + "ArkWeb", "Native Development Kit Refresh webTag:%{public}s", webTagValue); + + // 发送消息 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit 发消息开始"); + + if (g_web_message_port_arr == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); + return nullptr; + } + ArkWeb_WebMessagePtr message = webMessage->createWebMessage(); + webMessage->setType(message, ArkWeb_WebMessageType::ARKWEB_NONE); + std::string str = "send string from native"; + webMessage->setData(message, (void *)str.c_str(), str.length() + 1); + webMessagePort->postMessage(g_web_message_port_arr[1], webTagValue, message); + webMessage->destroyWebMessage(&message); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit postMessage end, web message port size:%{public}d", g_webMessagePortSize); + return nullptr; +} + +static napi_value postBufferMessage(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit Refresh webTag:%{public}s", webTagValue); + + // 发送消息 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit postMessage begin"); + + if (g_web_message_port_arr == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); + return nullptr; + } + ArkWeb_WebMessagePtr message1 = webMessage->createWebMessage(); + webMessage->setType(message1, ArkWeb_WebMessageType::ARKWEB_BUFFER); + std::string str1 = "send buffer from native"; + webMessage->setData(message1, (void *)str1.c_str(), str1.length()); + webMessagePort->postMessage(g_web_message_port_arr[1], webTagValue, message1); + webMessage->destroyWebMessage(&message1); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit postMessage end, web message port size:%{public}d", g_webMessagePortSize); + return nullptr; +} + +static napi_value setMessageEventHandler(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit Refresh webTag:%{public}s", webTagValue); + + // 注册回调 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit SetMessageEventHandler begin"); + if (g_web_message_port_arr == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); + return nullptr; + } + webMessagePort->setMessageEventHandler(g_web_message_port_arr[1], webTagValue, WebMessagePortCallback, NULL); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit SetMessageEventHandler end, web message port size:%{public}d", g_webMessagePortSize); + return nullptr; +} + +static napi_value closeMessagePort(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit Refresh webTag:%{public}s", webTagValue); + + // 关闭端口,先调用close,再调用destroyWebMessagePorts + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit SetMessageEventHandler begin"); + if (g_web_message_port_arr == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); + return nullptr; + } + webMessagePort->close(g_web_message_port_arr[0], webTagValue); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit SetMessageEventHandler end, web message port size:%{public}d", g_webMessagePortSize); + controller->refresh(webTagValue); + return nullptr; +} + +static napi_value destroyMessagePort(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit Refresh webTag:%{public}s", webTagValue); + + // 释放内存,先调用close,再调用destroyWebMessagePorts + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit SetMessageEventHandler begin"); + if (g_web_message_port_arr == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "webMessagePort is nullptr"); + return nullptr; + } + controller->destroyWebMessagePorts(&g_web_message_port_arr, g_webMessagePortSize); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit SetMessageEventHandler end, web message port size:%{public}d", g_webMessagePortSize); + return nullptr; +} + +static napi_value destroyNullMessagePort(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // 获取第一个参数webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit Refresh webTag:%{public}s", webTagValue); + + // 释放内存,先调用close,再调用destroyWebMessagePorts + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit SetMessageEventHandler begin"); + + controller->destroyWebMessagePorts(&g_web_message_port_arr, g_webMessagePortSize); + + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "Native Development Kit SetMessageEventHandler end, web message port size:%{public}d", g_webMessagePortSize); + return nullptr; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"nativeWebInit", nullptr, NativeWebInit, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createWebMessagePorts", nullptr, createWebMessagePorts, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"postMessage", nullptr, postMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"postNoneMessage", nullptr, postNoneMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"postBufferMessage", nullptr, postBufferMessage, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"setMessageEventHandler", nullptr, setMessageEventHandler, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"closeMessagePort", nullptr, closeMessagePort, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"destroyMessagePort", nullptr, destroyMessagePort, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"postMessageThread", nullptr, postMessageThread, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"setMessageEventHandlerThread", nullptr, setMessageEventHandlerThread, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"destroyNullMessagePort", nullptr, destroyNullMessagePort, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } // [End the_node_api_layer_code_for_the_data_channel_between_the_application_side_and_the_frontend_page] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/napi_init.cpp b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 5e824d1654..3c11c8b57c --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/napi_init.cpp @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" - -static napi_value Add(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - - napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - - napi_valuetype valuetype0; - napi_typeof(env, args[0], &valuetype0); - - napi_valuetype valuetype1; - napi_typeof(env, args[1], &valuetype1); - - double value0; - napi_get_value_double(env, args[0], &value0); - - double value1; - napi_get_value_double(env, args[1], &value1); - - napi_value sum; - napi_create_double(env, value0 + value1, &sum); - - return sum; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/types/libentry5/Index.d.ts b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/types/libentry5/Index.d.ts old mode 100755 new mode 100644 index d31c530984..85deb09b85 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/types/libentry5/Index.d.ts +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/types/libentry5/Index.d.ts @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start the_arkts_interface_is_exposed_on_the_node_api_side] -export const nativeWebInit: (webName: string) => void; -export const createWebMessagePorts: (webName: string) => void; -export const postMessage: (webName: string) => void; -export const postNoneMessage: (webName: string) => void; -export const setMessageEventHandler: (webName: string) => void; -export const closeMessagePort: (webName: string) => void; -export const destroyMessagePort: (webName: string) => void; -export const postBufferMessage: (webName: string) => void; -export const destroyNullMessagePort: (webName: string) => void; -export const setMessageEventHandlerThread: (webName: string) => void; -export const postMessageThread: (webName: string) => void; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start the_arkts_interface_is_exposed_on_the_node_api_side] +export const nativeWebInit: (webName: string) => void; +export const createWebMessagePorts: (webName: string) => void; +export const postMessage: (webName: string) => void; +export const postNoneMessage: (webName: string) => void; +export const setMessageEventHandler: (webName: string) => void; +export const closeMessagePort: (webName: string) => void; +export const destroyMessagePort: (webName: string) => void; +export const postBufferMessage: (webName: string) => void; +export const destroyNullMessagePort: (webName: string) => void; +export const setMessageEventHandlerThread: (webName: string) => void; +export const postMessageThread: (webName: string) => void; // [End the_arkts_interface_is_exposed_on_the_node_api_side] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/types/libentry5/oh-package.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/types/libentry5/oh-package.json5 old mode 100755 new mode 100644 index 58cb547be0..98c81afaba --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/types/libentry5/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/cpp/types/libentry5/oh-package.json5 @@ -1,21 +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": "libentry5.so", - "types": "./Index.d.ts", - "version": "1.0.0", - "description": "Please describe the basic information." +/* + * 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": "libentry5.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/ArkWeb/UseFrontendJSApp/entry5/src/main/ets/entry5ability/Entry5Ability.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/ets/entry5ability/Entry5Ability.ets old mode 100755 new mode 100644 index b95e7a9bb2..d0e606032c --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/ets/entry5ability/Entry5Ability.ets +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/ets/entry5ability/Entry5Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Entry5Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -}; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Entry5Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index aca5dc363d..95128ad574 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/ets/pages/Index.ets @@ -1,274 +1,274 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start webview_and_native_modules_are_used_to_implement_complex_message_interaction_between_applications_and_h5_pages] -import testNapi from 'libentry.so'; -import web_webview from '@ohos.web.webview'; -import { BusinessError } from '@ohos.base'; - -@Entry -@Component -struct Index { - @State webTag: string = 'postMessage'; - controller: web_webview.WebviewController = new web_webview.WebviewController(this.webTag); - @State h5Log: string = 'Display received message send from HTML'; - - aboutToAppear() { - web_webview.WebviewController.setWebDebuggingAccess(true); - // 初始化web Native Development Kit - testNapi.nativeWebInit(this.webTag); - } - - aboutToDisAppear() { - console.error('aboutToDisAppear'); - } - - build() { - Scroll() { - Column({ space: 10 }) { - // 展示H5接收到的内容 - Text($r('app.string.H5_Side_Message_Display_From_App')) - TextArea({text: this.h5Log}) - .id('log_area') - .width('100%') - .height(100) - .border({ width: 1 }) - Text($r('app.string.App_Side_Button')) - Row() { - Button('createNoControllerTagPort') - .id('create_no_tag_btn') - .onClick(() => { - try { - testNapi.createWebMessagePorts('noTag'); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('createPort') - .id('create_port_btn') - .onClick(() => { - try { - testNapi.createWebMessagePorts(this.webTag); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - } - - Row({ space: 10 }) { - - Button('setHandler') - .id('set_handler_btn') - .onClick(() => { - try { - testNapi.setMessageEventHandler(this.webTag); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - - Button('setHandlerThread') - .id('set_handler_thread_btn') - .onClick(() => { - try { - testNapi.setMessageEventHandlerThread(this.webTag); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - } - - Row({ space: 10 }) { - Button('SendString') - .id('send_string_btn') - .onClick(() => { - try { - this.h5Log = '' - testNapi.postMessage(this.webTag); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('SendStringThread') - .id('send_string_thread_btn') - .onClick(() => { - try { - this.h5Log = '' - testNapi.postMessageThread(this.webTag); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - } - - Row({ space: 10 }) { - Button('SendBuffer') - .id('send_buffer_btn') - .onClick(() => { - try { - this.h5Log = '' - testNapi.postBufferMessage(this.webTag); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('SendNone') - .id('send_none_btn') - .onClick(() => { - try { - this.h5Log = '' - testNapi.postNoneMessage(this.webTag); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - } - - Row({ space: 10 }) { - - Button('closePort') - .id('close_port_btn') - .onClick(() => { - try { - testNapi.closeMessagePort(this.webTag); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('destroyNullPort') - .id('destroy_null_btn') - .onClick(() => { - try { - testNapi.destroyNullMessagePort(this.webTag); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('destroyPort') - .id('destroy_port_btn') - .onClick(() => { - try { - testNapi.destroyMessagePort(this.webTag); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - } - .width('100%') - .padding(10) - .border({ width: 1 }) - - Column({ space: 10 }) { - Text($r('app.string.H5_Side_Send_Button')) - Row({ space: 10 }) { - Button('H5String') - .id('h5_send_string_btn') - .onClick(() => { - try { - this.controller.runJavaScript('for(var i = 0; i < 2000; i++) postStringToApp()'); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('H5Buffer') - .id('h5_send_buffer_btn') - .onClick(() => { - try { - this.controller.runJavaScript('postBufferToApp()'); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('H5Number') - .id('h5_send_number_btn') - .onClick(() => { - try { - this.controller.runJavaScript('postNumberToApp()'); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - } - - Row({ space: 10 }) { - Button('H5Json') - .id('h5_send_json_btn') - .onClick(() => { - try { - this.controller.runJavaScript('postJsonToApp()'); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('H5Array') - .id('h5_send_array_btn') - .onClick(() => { - try { - this.controller.runJavaScript('postArrayStringToApp()'); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - Button('H5Object') - .id('h5_send_object_btn') - .onClick(() => { - try { - this.controller.runJavaScript('postObjectToApp()'); - } catch (error) { - console.error( - `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } - }) - } - } - .width('100%') - .margin(10) - .padding(10) - .border({ width: 1 }) - - Web({ src: $rawfile('index.html'), controller: this.controller }) - .onConsole((event) => { - if (event) { - let msg = event.message.getMessage(); - if (msg.startsWith('H5')) { - this.h5Log = event.message.getMessage() + '\n' + this.h5Log; - } - } - return false; - }) - } - }.height('100%') - .scrollable(ScrollDirection.Vertical) - .scrollBar(BarState.Off) - .edgeEffect(EdgeEffect.Spring) - } -} -// [End webview_and_native_modules_are_used_to_implement_complex_message_interaction_between_applications_and_h5_pages] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start webview_and_native_modules_are_used_to_implement_complex_message_interaction_between_applications_and_h5_pages] +import testNapi from 'libentry.so'; +import web_webview from '@ohos.web.webview'; +import { BusinessError } from '@ohos.base'; + +@Entry +@Component +struct Index { + @State webTag: string = 'postMessage'; + controller: web_webview.WebviewController = new web_webview.WebviewController(this.webTag); + @State h5Log: string = 'Display received message send from HTML'; + + aboutToAppear() { + web_webview.WebviewController.setWebDebuggingAccess(true); + // 初始化web Native Development Kit + testNapi.nativeWebInit(this.webTag); + } + + aboutToDisAppear() { + console.error('aboutToDisAppear'); + } + + build() { + Scroll() { + Column({ space: 10 }) { + // 展示H5接收到的内容 + Text($r('app.string.H5_Side_Message_Display_From_App')) + TextArea({text: this.h5Log}) + .id('log_area') + .width('100%') + .height(100) + .border({ width: 1 }) + Text($r('app.string.App_Side_Button')) + Row() { + Button('createNoControllerTagPort') + .id('create_no_tag_btn') + .onClick(() => { + try { + testNapi.createWebMessagePorts('noTag'); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('createPort') + .id('create_port_btn') + .onClick(() => { + try { + testNapi.createWebMessagePorts(this.webTag); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + } + + Row({ space: 10 }) { + + Button('setHandler') + .id('set_handler_btn') + .onClick(() => { + try { + testNapi.setMessageEventHandler(this.webTag); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + + Button('setHandlerThread') + .id('set_handler_thread_btn') + .onClick(() => { + try { + testNapi.setMessageEventHandlerThread(this.webTag); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + } + + Row({ space: 10 }) { + Button('SendString') + .id('send_string_btn') + .onClick(() => { + try { + this.h5Log = '' + testNapi.postMessage(this.webTag); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('SendStringThread') + .id('send_string_thread_btn') + .onClick(() => { + try { + this.h5Log = '' + testNapi.postMessageThread(this.webTag); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + } + + Row({ space: 10 }) { + Button('SendBuffer') + .id('send_buffer_btn') + .onClick(() => { + try { + this.h5Log = '' + testNapi.postBufferMessage(this.webTag); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('SendNone') + .id('send_none_btn') + .onClick(() => { + try { + this.h5Log = '' + testNapi.postNoneMessage(this.webTag); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + } + + Row({ space: 10 }) { + + Button('closePort') + .id('close_port_btn') + .onClick(() => { + try { + testNapi.closeMessagePort(this.webTag); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('destroyNullPort') + .id('destroy_null_btn') + .onClick(() => { + try { + testNapi.destroyNullMessagePort(this.webTag); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('destroyPort') + .id('destroy_port_btn') + .onClick(() => { + try { + testNapi.destroyMessagePort(this.webTag); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + } + .width('100%') + .padding(10) + .border({ width: 1 }) + + Column({ space: 10 }) { + Text($r('app.string.H5_Side_Send_Button')) + Row({ space: 10 }) { + Button('H5String') + .id('h5_send_string_btn') + .onClick(() => { + try { + this.controller.runJavaScript('for(var i = 0; i < 2000; i++) postStringToApp()'); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('H5Buffer') + .id('h5_send_buffer_btn') + .onClick(() => { + try { + this.controller.runJavaScript('postBufferToApp()'); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('H5Number') + .id('h5_send_number_btn') + .onClick(() => { + try { + this.controller.runJavaScript('postNumberToApp()'); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + } + + Row({ space: 10 }) { + Button('H5Json') + .id('h5_send_json_btn') + .onClick(() => { + try { + this.controller.runJavaScript('postJsonToApp()'); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('H5Array') + .id('h5_send_array_btn') + .onClick(() => { + try { + this.controller.runJavaScript('postArrayStringToApp()'); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Button('H5Object') + .id('h5_send_object_btn') + .onClick(() => { + try { + this.controller.runJavaScript('postObjectToApp()'); + } catch (error) { + console.error( + `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + } + } + .width('100%') + .margin(10) + .padding(10) + .border({ width: 1 }) + + Web({ src: $rawfile('index.html'), controller: this.controller }) + .onConsole((event) => { + if (event) { + let msg = event.message.getMessage(); + if (msg.startsWith('H5')) { + this.h5Log = event.message.getMessage() + '\n' + this.h5Log; + } + } + return false; + }) + } + }.height('100%') + .scrollable(ScrollDirection.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.Spring) + } +} +// [End webview_and_native_modules_are_used_to_implement_complex_message_interaction_between_applications_and_h5_pages] diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/module.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/module.json5 old mode 100755 new mode 100644 index 93341c64f1..e5f83a1901 --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/module.json5 @@ -1,42 +1,42 @@ -/* - * 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": "entry5", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Entry5Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry5Ability", - "srcEntry": "./ets/entry5ability/Entry5Ability.ets", - "description": "$string:Entry5Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry5Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ] - } +/* + * 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": "entry5", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Entry5Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry5Ability", + "srcEntry": "./ets/entry5ability/Entry5Ability.ets", + "description": "$string:Entry5Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry5Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index ebfeb5b327..d2925296dd --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/main/resources/rawfile/index.html @@ -1,138 +1,138 @@ - - - - - -

etsRunJavaScriptExt测试demo

-

-

Receive string:

-

Receive arraybuffer:

- - - - + + + + + +

etsRunJavaScriptExt测试demo

+

+

Receive string:

+

Receive arraybuffer:

+ + + + diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/mock/Libentry5.mock.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/mock/Libentry5.mock.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/module.json5 old mode 100755 new mode 100644 index b9137f46ef..5ee7a310ff --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry5_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry5_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/test/List.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UseFrontendJSApp/entry5/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/UseFrontendJSApp/hvigorfile.ts b/code/DocsSample/ArkWeb/UseFrontendJSApp/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/oh-package.json5 b/code/DocsSample/ArkWeb/UseFrontendJSApp/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/UseFrontendJSApp/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseFrontendJSApp/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/ohosTest.md b/code/DocsSample/ArkWeb/UseFrontendJSApp/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/AppCallFrontendFn_1.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/AppCallFrontendFn_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/AppCallFrontendFn_2.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/AppCallFrontendFn_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/AppCallFrontendFn_3.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/AppCallFrontendFn_3.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannelC_C_1.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannelC_C_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannelC_C_2.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannelC_C_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannel_1.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannel_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannel_2.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannel_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannel_3.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/EstabDataChannel_3.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/JavaScriptProxy_1.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/JavaScriptProxy_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/JavaScriptProxy_2.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/JavaScriptProxy_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/MutualInvokeCCpp.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/MutualInvokeCCpp.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/Promise_one.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/Promise_one.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/Promise_two.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/Promise_two.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/RegisterJavaScriptProxy_1.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/RegisterJavaScriptProxy_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/RegisterJavaScriptProxy_2.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/RegisterJavaScriptProxy_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_five.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_five.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_four.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_four.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_one.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_one.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_three.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_three.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_two.png b/code/DocsSample/ArkWeb/UseFrontendJSApp/screenshots/UsageOfComplexTypes_two.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/.gitignore b/code/DocsSample/ArkWeb/UseOfflineWebComp/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/app.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/app.json5 old mode 100755 new mode 100644 index 8010ebfedd..5f862a961c --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/app.json5 @@ -1,25 +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.useofflinewebcomp", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.useofflinewebcomp", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 9c1aa63575..16490fd4d5 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "UseOfflineWebComp" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "UseOfflineWebComp" + } + ] +} diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/README.md b/code/DocsSample/ArkWeb/UseOfflineWebComp/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/build-profile.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/build-profile.json5 old mode 100755 new mode 100644 index 104fe4ce6a..13931b8666 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/build-profile.json5 @@ -1,76 +1,76 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry1", - "srcPath": "./entry1", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry2", - "srcPath": "./entry2", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry1", + "srcPath": "./entry1", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry2", + "srcPath": "./entry2", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/code-linter.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/.gitignore b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/build-profile.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/oh-package.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 36f8578555..afdc22155d --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -import { createNWeb } from "../pages/common"; -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - // [Start entry_ability_window_stage_created_after_specified_page_loaded] - onWindowStageCreate(windowStage: window.WindowStage): void { - windowStage.loadContent('pages/Index', (err, data) => { - // 创建Web动态组件(需传入UIContext),loadContent之后的任意时机均可创建 - createNWeb('www.example.com', windowStage.getMainWindowSync().getUIContext()); - if (err.code) { - return; - } - }); - } - // [End entry_ability_window_stage_created_after_specified_page_loaded] - - 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'); - } -} +/* + * 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 { createNWeb } from "../pages/common"; +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + // [Start entry_ability_window_stage_created_after_specified_page_loaded] + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err, data) => { + // 创建Web动态组件(需传入UIContext),loadContent之后的任意时机均可创建 + createNWeb('www.example.com', windowStage.getMainWindowSync().getUIContext()); + if (err.code) { + return; + } + }); + } + // [End entry_ability_window_stage_created_after_specified_page_loaded] + + 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/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets old mode 100755 new mode 100644 index 983bc89174..12f79f4c56 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets @@ -1,101 +1,101 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// [Start manage_dynamic_webview_components_in_harmonyos_app] -// 创建NodeController -// common.ets -import { UIContext, NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; -import { webview } from '@kit.ArkWeb'; - -// @Builder中为动态组件的具体组件内容 -// Data为入参封装类 -class Data{ - public url: ResourceStr = 'www.example.com'; - public controller: WebviewController = new webview.WebviewController(); -} - -@Builder -function webBuilder(data:Data) { - Column() { - Web({ src: data.url, controller: data.controller }) - .width('100%') - .height('100%') - } -} - -let wrap = wrapBuilder(webBuilder); - -// 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用 -export class MyNodeController extends NodeController { - private rootnode: BuilderNode | null = null; - // 必须要重写的方法,用于构建节点数、返回节点挂载在对应NodeContainer中 - // 在对应NodeContainer创建的时候调用、或者通过rebuild方法调用刷新 - makeNode(uiContext: UIContext): FrameNode | null { - console.log(' uicontext is undefined : '+ (uiContext === undefined)); - if (this.rootnode != null) { - // 返回FrameNode节点 - return this.rootnode.getFrameNode(); - } - // 返回null控制动态组件脱离绑定节点 - return null; - } - // 当布局大小发生变化时进行回调 - aboutToResize(size: Size) { - console.log('aboutToResize width : ' + size.width + ' height : ' + size.height ); - } - - // 当controller对应的NodeContainer在Appear的时候进行回调 - aboutToAppear() { - console.log('aboutToAppear'); - } - - // 当controller对应的NodeContainer在Disappear的时候进行回调 - aboutToDisappear() { - console.log('aboutToDisappear'); - } - - // 此函数为自定义函数,可作为初始化函数使用 - // 通过UIContext初始化BuilderNode,再通过BuilderNode中的build接口初始化@Builder中的内容 - initWeb(url:ResourceStr, uiContext:UIContext, control:WebviewController) { - if (this.rootnode != null) { - return; - } - // 创建节点,需要uiContext - this.rootnode = new BuilderNode(uiContext); - // 创建动态Web组件 - this.rootnode.build(wrap, { url:url, controller:control }); - } -} -// 创建Map保存所需要的NodeController -let nodeMap:Map = new Map(); -// 创建Map保存所需要的WebViewController -let controllerMap:Map = new Map(); - -// 初始化需要UIContext 需在Ability获取 -export const createNWeb = (url: ResourceStr, uiContext: UIContext) => { - // 创建NodeController - let baseNode = new MyNodeController(); - let controller = new webview.WebviewController() ; - // 初始化自定义Web组件 - baseNode.initWeb(url, uiContext, controller); - controllerMap.set(url, controller); - nodeMap.set(url, baseNode); -} -// 自定义获取NodeController接口 -export const getNWeb = (url: ResourceStr) : MyNodeController | undefined => { - return nodeMap.get(url); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start manage_dynamic_webview_components_in_harmonyos_app] +// 创建NodeController +// common.ets +import { UIContext, NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; + +// @Builder中为动态组件的具体组件内容 +// Data为入参封装类 +class Data{ + public url: ResourceStr = 'www.example.com'; + public controller: WebviewController = new webview.WebviewController(); +} + +@Builder +function webBuilder(data:Data) { + Column() { + Web({ src: data.url, controller: data.controller }) + .width('100%') + .height('100%') + } +} + +let wrap = wrapBuilder(webBuilder); + +// 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用 +export class MyNodeController extends NodeController { + private rootnode: BuilderNode | null = null; + // 必须要重写的方法,用于构建节点数、返回节点挂载在对应NodeContainer中 + // 在对应NodeContainer创建的时候调用、或者通过rebuild方法调用刷新 + makeNode(uiContext: UIContext): FrameNode | null { + console.log(' uicontext is undefined : '+ (uiContext === undefined)); + if (this.rootnode != null) { + // 返回FrameNode节点 + return this.rootnode.getFrameNode(); + } + // 返回null控制动态组件脱离绑定节点 + return null; + } + // 当布局大小发生变化时进行回调 + aboutToResize(size: Size) { + console.log('aboutToResize width : ' + size.width + ' height : ' + size.height ); + } + + // 当controller对应的NodeContainer在Appear的时候进行回调 + aboutToAppear() { + console.log('aboutToAppear'); + } + + // 当controller对应的NodeContainer在Disappear的时候进行回调 + aboutToDisappear() { + console.log('aboutToDisappear'); + } + + // 此函数为自定义函数,可作为初始化函数使用 + // 通过UIContext初始化BuilderNode,再通过BuilderNode中的build接口初始化@Builder中的内容 + initWeb(url:ResourceStr, uiContext:UIContext, control:WebviewController) { + if (this.rootnode != null) { + return; + } + // 创建节点,需要uiContext + this.rootnode = new BuilderNode(uiContext); + // 创建动态Web组件 + this.rootnode.build(wrap, { url:url, controller:control }); + } +} +// 创建Map保存所需要的NodeController +let nodeMap:Map = new Map(); +// 创建Map保存所需要的WebViewController +let controllerMap:Map = new Map(); + +// 初始化需要UIContext 需在Ability获取 +export const createNWeb = (url: ResourceStr, uiContext: UIContext) => { + // 创建NodeController + let baseNode = new MyNodeController(); + let controller = new webview.WebviewController() ; + // 初始化自定义Web组件 + baseNode.initWeb(url, uiContext, controller); + controllerMap.set(url, controller); + nodeMap.set(url, baseNode); +} +// 自定义获取NodeController接口 +export const getNWeb = (url: ResourceStr) : MyNodeController | undefined => { + return nodeMap.get(url); +} // [End manage_dynamic_webview_components_in_harmonyos_app] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/module.json5 old mode 100755 new mode 100644 index 81751d0bc4..e9db80c0ac --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/.gitignore b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/build-profile.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/hvigorfile.ts b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/oh-package.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/oh-package.json5 old mode 100755 new mode 100644 index 4628f905e0..c4e8768835 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/oh-package.json5 @@ -1,25 +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": "entry1", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "entry1", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/entry1ability/Entry1Ability.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/entry1ability/Entry1Ability.ets old mode 100755 new mode 100644 index 844f1ef14f..399559a50d --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/entry1ability/Entry1Ability.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/entry1ability/Entry1Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; -import { createNWeb } from '../pages/common'; - -export default class Entry1Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - // [Start entry_ability_window_stage_created_after_page_loaded] - onWindowStageCreate(windowStage: window.WindowStage): void { - windowStage.loadContent('pages/Index', (err, data) => { - // 创建空的Web动态组件(需传入UIContext),loadContent之后的任意时机均可创建 - createNWeb('about:blank', windowStage.getMainWindowSync().getUIContext()); - if (err.code) { - return; - } - }); - } - // [End entry_ability_window_stage_created_after_page_loaded] - - 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'); - } -} +/* + * 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 { createNWeb } from '../pages/common'; + +export default class Entry1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + // [Start entry_ability_window_stage_created_after_page_loaded] + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err, data) => { + // 创建空的Web动态组件(需传入UIContext),loadContent之后的任意时机均可创建 + createNWeb('about:blank', windowStage.getMainWindowSync().getUIContext()); + if (err.code) { + return; + } + }); + } + // [End entry_ability_window_stage_created_after_page_loaded] + + 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/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/common.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/common.ets old mode 100755 new mode 100644 index 8aafa42d13..8558a5a6e8 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/common.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/common.ets @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start manage_dynamic_webview_components_in_harmonyos] -// 创建NodeController -import { UIContext, NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; -import { webview } from '@kit.ArkWeb'; - -// @Builder中为动态组件的具体组件内容 -// Data为入参封装类 -class Data{ - public url: ResourceStr = 'www.example.com'; - public controller: WebviewController = new webview.WebviewController(); -} - -@Builder -function webBuilder(data:Data) { - Column() { - Web({ src: data.url, controller: data.controller }) - .width('100%') - .height('100%') - } -} - -let wrap = wrapBuilder(webBuilder); - -// 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用 -export class MyNodeController extends NodeController { - private rootnode: BuilderNode | null = null; - // 必须要重写的方法,用于构建节点数、返回节点挂载在对应NodeContainer中 - // 在对应NodeContainer创建的时候调用、或者通过rebuild方法调用刷新 - makeNode(uiContext: UIContext): FrameNode | null { - console.log(' uicontext is undefined : '+ (uiContext === undefined)); - if (this.rootnode != null) { - // 返回FrameNode节点 - return this.rootnode.getFrameNode(); - } - // 返回null控制动态组件脱离绑定节点 - return null; - } - // 当布局大小发生变化时进行回调 - aboutToResize(size: Size) { - console.log('aboutToResize width : ' + size.width + ' height : ' + size.height ); - } - - // 当controller对应的NodeContainer在Appear的时候进行回调 - aboutToAppear() { - console.log('aboutToAppear'); - } - - // 当controller对应的NodeContainer在Disappear的时候进行回调 - aboutToDisappear() { - console.log('aboutToDisappear'); - } - - // 此函数为自定义函数,可作为初始化函数使用 - // 通过UIContext初始化BuilderNode,再通过BuilderNode中的build接口初始化@Builder中的内容 - initWeb(url:ResourceStr, uiContext:UIContext, control:WebviewController) { - if (this.rootnode != null) { - return; - } - // 创建节点,需要uiContext - this.rootnode = new BuilderNode(uiContext); - // 创建动态Web组件 - this.rootnode.build(wrap, { url:url, controller:control }); - } -} -// 创建Map保存所需要的NodeController -let nodeMap:Map = new Map(); -// 创建Map保存所需要的WebViewController -let controllerMap:Map = new Map(); - -// 初始化需要UIContext 需在Ability获取 -export const createNWeb = (url: ResourceStr, uiContext: UIContext) => { - // 创建NodeController - let baseNode = new MyNodeController(); - let controller = new webview.WebviewController() ; - // 初始化自定义Web组件 - baseNode.initWeb(url, uiContext, controller); - controllerMap.set(url, controller); - nodeMap.set(url, baseNode); -} -// 自定义获取NodeController接口 -export const getNWeb = (url: ResourceStr) : MyNodeController | undefined => { - return nodeMap.get(url); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start manage_dynamic_webview_components_in_harmonyos] +// 创建NodeController +import { UIContext, NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; + +// @Builder中为动态组件的具体组件内容 +// Data为入参封装类 +class Data{ + public url: ResourceStr = 'www.example.com'; + public controller: WebviewController = new webview.WebviewController(); +} + +@Builder +function webBuilder(data:Data) { + Column() { + Web({ src: data.url, controller: data.controller }) + .width('100%') + .height('100%') + } +} + +let wrap = wrapBuilder(webBuilder); + +// 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用 +export class MyNodeController extends NodeController { + private rootnode: BuilderNode | null = null; + // 必须要重写的方法,用于构建节点数、返回节点挂载在对应NodeContainer中 + // 在对应NodeContainer创建的时候调用、或者通过rebuild方法调用刷新 + makeNode(uiContext: UIContext): FrameNode | null { + console.log(' uicontext is undefined : '+ (uiContext === undefined)); + if (this.rootnode != null) { + // 返回FrameNode节点 + return this.rootnode.getFrameNode(); + } + // 返回null控制动态组件脱离绑定节点 + return null; + } + // 当布局大小发生变化时进行回调 + aboutToResize(size: Size) { + console.log('aboutToResize width : ' + size.width + ' height : ' + size.height ); + } + + // 当controller对应的NodeContainer在Appear的时候进行回调 + aboutToAppear() { + console.log('aboutToAppear'); + } + + // 当controller对应的NodeContainer在Disappear的时候进行回调 + aboutToDisappear() { + console.log('aboutToDisappear'); + } + + // 此函数为自定义函数,可作为初始化函数使用 + // 通过UIContext初始化BuilderNode,再通过BuilderNode中的build接口初始化@Builder中的内容 + initWeb(url:ResourceStr, uiContext:UIContext, control:WebviewController) { + if (this.rootnode != null) { + return; + } + // 创建节点,需要uiContext + this.rootnode = new BuilderNode(uiContext); + // 创建动态Web组件 + this.rootnode.build(wrap, { url:url, controller:control }); + } +} +// 创建Map保存所需要的NodeController +let nodeMap:Map = new Map(); +// 创建Map保存所需要的WebViewController +let controllerMap:Map = new Map(); + +// 初始化需要UIContext 需在Ability获取 +export const createNWeb = (url: ResourceStr, uiContext: UIContext) => { + // 创建NodeController + let baseNode = new MyNodeController(); + let controller = new webview.WebviewController() ; + // 初始化自定义Web组件 + baseNode.initWeb(url, uiContext, controller); + controllerMap.set(url, controller); + nodeMap.set(url, baseNode); +} +// 自定义获取NodeController接口 +export const getNWeb = (url: ResourceStr) : MyNodeController | undefined => { + return nodeMap.get(url); +} // [End manage_dynamic_webview_components_in_harmonyos] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/index2.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/index2.ets old mode 100755 new mode 100644 index 61785eaeb4..7c80dbf9c0 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/index2.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/index2.ets @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start nodeContainer_bind_controller_show_dynamic_pages] -import web_webview from '@ohos.web.webview'; - -@Entry -@Component -struct index2 { - webviewController: web_webview.WebviewController = new web_webview.WebviewController(); - - build() { - Row() { - Column() { - Web({src: 'www.example.com', controller: this.webviewController}) - .width('100%') - .height('100%') - } - .width('100%') - } - .height('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start nodeContainer_bind_controller_show_dynamic_pages] +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct index2 { + webviewController: web_webview.WebviewController = new web_webview.WebviewController(); + + build() { + Row() { + Column() { + Web({src: 'www.example.com', controller: this.webviewController}) + .width('100%') + .height('100%') + } + .width('100%') + } + .height('100%') + } +} // [End nodeContainer_bind_controller_show_dynamic_pages] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/module.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/module.json5 old mode 100755 new mode 100644 index 465872d230..5303c59d21 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/module.json5 @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry1", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Entry1Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry1Ability", - "srcEntry": "./ets/entry1ability/Entry1Ability.ets", - "description": "$string:Entry1Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry1Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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": "entry1", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Entry1Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry1Ability", + "srcEntry": "./ets/entry1ability/Entry1Ability.ets", + "description": "$string:Entry1Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry1Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/module.json5 old mode 100755 new mode 100644 index b463f808d1..a8392c11cf --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry1_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry1_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/test/List.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/.gitignore b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/build-profile.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/hvigorfile.ts b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/oh-package.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/oh-package.json5 old mode 100755 new mode 100644 index bcb70ff878..6f8ebfffe8 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/oh-package.json5 @@ -1,25 +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": "entry2", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* + * 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": "entry2", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/entry2ability/Entry2Ability.ets old mode 100755 new mode 100644 index 502c9fd6ee..1270a900ce --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/entry2ability/Entry2Ability.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/entry2ability/Entry2Ability.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class Entry2Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class Entry2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/common.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/common.ets old mode 100755 new mode 100644 index b424a64654..b29faae956 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/common.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/common.ets @@ -1,111 +1,111 @@ -/* - * 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. - */ - -// 创建NodeController -// common.ets -import { UIContext } from '@kit.ArkUI'; -import { webview } from '@kit.ArkWeb'; -import { NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; -// @Builder中为动态组件的具体组件内容 -// Data为入参封装类 -class Data{ - public url: string = 'www.example.com'; - public controller: WebviewController = new webview.WebviewController(); -} -// 通过布尔变量shouldInactive控制网页在后台完成预渲染后停止渲染 -let shouldInactive: boolean = true; -// [Start call_onActive_method_to_pre_render_offline_web_component] -@Builder -function webBuilder(data:Data) { - Column() { - Web({ src: data.url, controller: data.controller }) - .onPageBegin(() => { - // 调用onActive,开启渲染 - data.controller.onActive(); - }) - // [StartExclude call_onActive_method_to_pre_render_offline_web_component] - .onFirstMeaningfulPaint(() =>{ - if (!shouldInactive) { - return; - } - // 在预渲染完成时触发,停止渲染 - data.controller.onInactive(); - shouldInactive = false; - }) - // [EndExclude call_onActive_method_to_pre_render_offline_web_component] - .width('100%') - .height('100%') - } -} -// [End call_onActive_method_to_pre_render_offline_web_component] -let wrap = wrapBuilder(webBuilder); -// 用于控制和反馈对应的NodeContianer上的节点的行为,需要与NodeContainer一起使用 -export class MyNodeController extends NodeController { - private rootnode: BuilderNode | null = null; - // 必须要重写的方法,用于构建节点数、返回节点挂载在对应NodeContianer中 - // 在对应NodeContianer创建的时候调用、或者通过rebuild方法调用刷新 - makeNode(uiContext: UIContext): FrameNode | null { - console.info(' uicontext is undifined : '+ (uiContext === undefined)); - if (this.rootnode != null) { - // 返回FrameNode节点 - return this.rootnode.getFrameNode(); - } - // 返回null控制动态组件脱离绑定节点 - return null; - } - // 当布局大小发生变化时进行回调 - aboutToResize(size: Size) { - console.info('aboutToResize width : ' + size.width + ' height : ' + size.height ); - } - // 当controller对应的NodeContainer在Appear的时候进行回调 - aboutToAppear() { - console.info('aboutToAppear'); - // 切换到前台后,不需要停止渲染 - shouldInactive = false; - } - // 当controller对应的NodeContainer在Disappear的时候进行回调 - aboutToDisappear() { - console.info('aboutToDisappear'); - } - // 此函数为自定义函数,可作为初始化函数使用 - // 通过UIContext初始化BuilderNode,再通过BuilderNode中的build接口初始化@Builder中的内容 - initWeb(url:string, uiContext:UIContext, control:WebviewController) { - if (this.rootnode != null) { - return; - } - // 创建节点,需要uiContext - this.rootnode = new BuilderNode(uiContext); - // 创建动态Web组件 - this.rootnode.build(wrap, { url:url, controller:control }); - } -} -// 创建Map保存所需要的NodeController -let nodeMap:Map = new Map(); -// 创建Map保存所需要的WebViewController -let controllerMap:Map = new Map(); -// 初始化需要UIContext 需在Ability获取 -export const createNWeb = (url: string, uiContext: UIContext) => { - // 创建NodeController - let baseNode = new MyNodeController(); - let controller = new webview.WebviewController(); - // 初始化自定义Web组件 - baseNode.initWeb(url, uiContext, controller); - controllerMap.set(url, controller) - nodeMap.set(url, baseNode); -} -// 自定义获取NodeController接口 -export const getNWeb = (url : string) : MyNodeController | undefined => { - return nodeMap.get(url); +/* + * 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. + */ + +// 创建NodeController +// common.ets +import { UIContext } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; +import { NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; +// @Builder中为动态组件的具体组件内容 +// Data为入参封装类 +class Data{ + public url: string = 'www.example.com'; + public controller: WebviewController = new webview.WebviewController(); +} +// 通过布尔变量shouldInactive控制网页在后台完成预渲染后停止渲染 +let shouldInactive: boolean = true; +// [Start call_onActive_method_to_pre_render_offline_web_component] +@Builder +function webBuilder(data:Data) { + Column() { + Web({ src: data.url, controller: data.controller }) + .onPageBegin(() => { + // 调用onActive,开启渲染 + data.controller.onActive(); + }) + // [StartExclude call_onActive_method_to_pre_render_offline_web_component] + .onFirstMeaningfulPaint(() =>{ + if (!shouldInactive) { + return; + } + // 在预渲染完成时触发,停止渲染 + data.controller.onInactive(); + shouldInactive = false; + }) + // [EndExclude call_onActive_method_to_pre_render_offline_web_component] + .width('100%') + .height('100%') + } +} +// [End call_onActive_method_to_pre_render_offline_web_component] +let wrap = wrapBuilder(webBuilder); +// 用于控制和反馈对应的NodeContianer上的节点的行为,需要与NodeContainer一起使用 +export class MyNodeController extends NodeController { + private rootnode: BuilderNode | null = null; + // 必须要重写的方法,用于构建节点数、返回节点挂载在对应NodeContianer中 + // 在对应NodeContianer创建的时候调用、或者通过rebuild方法调用刷新 + makeNode(uiContext: UIContext): FrameNode | null { + console.info(' uicontext is undifined : '+ (uiContext === undefined)); + if (this.rootnode != null) { + // 返回FrameNode节点 + return this.rootnode.getFrameNode(); + } + // 返回null控制动态组件脱离绑定节点 + return null; + } + // 当布局大小发生变化时进行回调 + aboutToResize(size: Size) { + console.info('aboutToResize width : ' + size.width + ' height : ' + size.height ); + } + // 当controller对应的NodeContainer在Appear的时候进行回调 + aboutToAppear() { + console.info('aboutToAppear'); + // 切换到前台后,不需要停止渲染 + shouldInactive = false; + } + // 当controller对应的NodeContainer在Disappear的时候进行回调 + aboutToDisappear() { + console.info('aboutToDisappear'); + } + // 此函数为自定义函数,可作为初始化函数使用 + // 通过UIContext初始化BuilderNode,再通过BuilderNode中的build接口初始化@Builder中的内容 + initWeb(url:string, uiContext:UIContext, control:WebviewController) { + if (this.rootnode != null) { + return; + } + // 创建节点,需要uiContext + this.rootnode = new BuilderNode(uiContext); + // 创建动态Web组件 + this.rootnode.build(wrap, { url:url, controller:control }); + } +} +// 创建Map保存所需要的NodeController +let nodeMap:Map = new Map(); +// 创建Map保存所需要的WebViewController +let controllerMap:Map = new Map(); +// 初始化需要UIContext 需在Ability获取 +export const createNWeb = (url: string, uiContext: UIContext) => { + // 创建NodeController + let baseNode = new MyNodeController(); + let controller = new webview.WebviewController(); + // 初始化自定义Web组件 + baseNode.initWeb(url, uiContext, controller); + controllerMap.set(url, controller) + nodeMap.set(url, baseNode); +} +// 自定义获取NodeController接口 +export const getNWeb = (url : string) : MyNodeController | undefined => { + return nodeMap.get(url); } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/index2.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/index2.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/module.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/module.json5 old mode 100755 new mode 100644 index 428153389a..1f8c3599ec --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/module.json5 @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry2", - "type": "feature", - "description": "$string:module_desc", - "mainElement": "Entry2Ability", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry2Ability", - "srcEntry": "./ets/entry2ability/Entry2Ability.ets", - "description": "$string:Entry2Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry2Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true - } - ], - // [Start add_network_permission] - "requestPermissions":[ - { - "name" : "ohos.permission.INTERNET" - } - ], - // [End add_network_permission] - } +/* + * 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": "entry2", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "Entry2Ability", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry2Ability", + "srcEntry": "./ets/entry2ability/Entry2Ability.ets", + "description": "$string:Entry2Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry2Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ], + // [Start add_network_permission] + "requestPermissions":[ + { + "name" : "ohos.permission.INTERNET" + } + ], + // [End add_network_permission] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 87a1b50487..031b54bde3 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry2_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * 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": "entry2_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/test/List.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/UseOfflineWebComp/hvigorfile.ts b/code/DocsSample/ArkWeb/UseOfflineWebComp/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/oh-package.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/ohosTest.md b/code/DocsSample/ArkWeb/UseOfflineWebComp/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/CreatingOfflineWebComponents.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/CreatingOfflineWebComponents.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_one_1.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_one_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_one_2.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_one_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_two_1.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_two_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_two_2.png b/code/DocsSample/ArkWeb/UseOfflineWebComp/screenshots/PreLaunchingRenderingProcess_two_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/.gitignore b/code/DocsSample/ArkWeb/UseSameLayerRender/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/app.json5 b/code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/app.json5 old mode 100755 new mode 100644 index fc7f6d18d6..5b18054bf8 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/app.json5 @@ -1,25 +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.usesamelayerrender", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.usesamelayerrender", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index c09b1adba3..030dffd09f --- a/code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "UseSameLayerRender" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "UseSameLayerRender" + } + ] +} diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/UseSameLayerRender/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/README.md b/code/DocsSample/ArkWeb/UseSameLayerRender/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/build-profile.json5 b/code/DocsSample/ArkWeb/UseSameLayerRender/build-profile.json5 old mode 100755 new mode 100644 index 87d40a385e..7a9c78377e --- a/code/DocsSample/ArkWeb/UseSameLayerRender/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/build-profile.json5 @@ -1,52 +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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 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/ArkWeb/UseSameLayerRender/code-linter.json5 b/code/DocsSample/ArkWeb/UseSameLayerRender/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/.gitignore b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/build-profile.json5 b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/oh-package.json5 b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/UseSameLayerRender/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b23d2fe946..0f2f8b94aa --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/DrawXCompAVPBtn.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/DrawXCompAVPBtn.ets old mode 100755 new mode 100644 index 4c6650113c..89604aae09 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/DrawXCompAVPBtn.ets +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/DrawXCompAVPBtn.ets @@ -1,216 +1,216 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start draw_x_component_av_player_button] -// 创建NodeController -import { webview } from '@kit.ArkWeb'; -import { UIContext, NodeController, BuilderNode, NodeRenderType, FrameNode } from '@kit.ArkUI'; -import { AVPlayerDemo } from './PlayerDemo'; - -@Observed -declare class Params { - public textOne : string - public textTwo : string - public width : number - public height : number -} - -declare class NodeControllerParams { - public surfaceId : string - public type : string - public renderType : NodeRenderType - public embedId : string - public width : number - public height : number -} - -// 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用。 -class MyNodeController extends NodeController { - private rootNode: BuilderNode<[Params]> | undefined | null; - private embedId_ : string = ''; - private surfaceId_ : string = ''; - private renderType_ :NodeRenderType = NodeRenderType.RENDER_TYPE_DISPLAY; - private width_ : number = 0; - private height_ : number = 0; - private type_ : string = ''; - private isDestroy_ : boolean = false; - - setRenderOption(params : NodeControllerParams) { - this.surfaceId_ = params.surfaceId; - this.renderType_ = params.renderType; - this.embedId_ = params.embedId; - this.width_ = params.width; - this.height_ = params.height; - this.type_ = params.type; - } - // 必须要重写的方法,用于构建节点数、返回节点数挂载在对应NodeContainer中。 - // 在对应NodeContainer创建的时候调用、或者通过rebuild方法调用刷新。 - makeNode(uiContext: UIContext): FrameNode | null{ - if (this.isDestroy_) { // rootNode为null - return null; - } - if (!this.rootNode) { // rootNode 为undefined时 - this.rootNode = new BuilderNode(uiContext, { surfaceId: this.surfaceId_, type: this.renderType_}); - if (this.type_ === 'native/video') { - this.rootNode.build( - wrapBuilder(videoBuilder), {textOne: 'myButton', width : this.width_, height : this.height_}); - } else { - // other - } - } - // 返回FrameNode节点。 - return this.rootNode.getFrameNode(); - } - - setBuilderNode(rootNode: BuilderNode | null): void{ - this.rootNode = rootNode; - } - - getBuilderNode(): BuilderNode<[Params]> | undefined | null{ - return this.rootNode; - } - - updateNode(arg: Object): void { - this.rootNode?.update(arg); - } - getEmbedId() : string { - return this.embedId_; - } - - setDestroy(isDestroy : boolean) : void { - this.isDestroy_ = isDestroy; - if (this.isDestroy_) { - this.rootNode = null; - } - } - - postEvent(event: TouchEvent | undefined) : boolean { - return this.rootNode?.postTouchEvent(event) as boolean; - } -} - -@Component -struct VideoComponent { - @ObjectLink params: Params; - @State bkColor: Color = Color.Red; - mXComponentController: XComponentController = new XComponentController(); - @State playerChanged: boolean = false; - player?: AVPlayerDemo; - - build() { - Column() { - Button(this.params.textOne); - - XComponent({ id: 'video_player_id', type: XComponentType.SURFACE, controller: this.mXComponentController}) - .border({width: 1, color: Color.Red}) - .onLoad(() => { - this.player = new AVPlayerDemo(); - this.player.setSurfaceID(this.mXComponentController.getXComponentSurfaceId()); - this.playerChanged = !this.playerChanged; - this.player.avPlayerLiveDemo(); - }) - .width(300) - .height(200) - } - //自定义组件中的最外层容器组件宽高应该为同层标签的宽高 - .width(this.params.width) - .height(this.params.height) - } -} -// @Builder中为动态组件的具体组件内容。 -@Builder -function videoBuilder(params: Params) { - VideoComponent({ params: params }) - .backgroundColor(Color.Gray) -} - -@Entry -@Component -struct WebIndex { - browserTabController: WebviewController = new webview.WebviewController() - private nodeControllerMap: Map = new Map(); - @State componentIdArr: Array = []; - - aboutToAppear() { - // 配置web开启调试模式。 - webview.WebviewController.setWebDebuggingAccess(true); - } - - build(){ - Row() { - Column() { - Stack() { - ForEach(this.componentIdArr, (componentId: string) => { - NodeContainer(this.nodeControllerMap.get(componentId)); - }, (embedId: string) => embedId) - // Web组件加载本地test.html页面。 - Web({ src: $rawfile('test3.html'), controller: this.browserTabController }) - // 配置同层渲染开关开启。 - .enableNativeEmbedMode(true) - // 获取embed标签的生命周期变化数据。 - .onNativeEmbedLifecycleChange((embed) => { - console.log('NativeEmbed surfaceId' + embed.surfaceId); - // 1. 如果使用embed.info.id作为映射nodeController的key,请在h5页面显式指定id - const componentId = embed.info?.id?.toString() as string - if (embed.status == NativeEmbedStatus.CREATE) { - console.log('NativeEmbed create' + JSON.stringify(embed.info)) - // 创建节点控制器,设置参数并rebuild。 - let nodeController = new MyNodeController() - // 1. embed.info.width和embed.info.height单位是px格式,需要转换成ets侧的默认单位vp - nodeController.setRenderOption({ - surfaceId : embed.surfaceId as string, type : embed.info?.type as string, - renderType : NodeRenderType.RENDER_TYPE_TEXTURE, embedId : embed.embedId as string, - width : px2vp(embed.info?.width), height : px2vp(embed.info?.height)}); - nodeController.setDestroy(false); - // 根据web传入的embed的id属性作为key,将nodeController存入map。 - this.nodeControllerMap.set(componentId, nodeController) - // 将web传入的embed的id属性存入@State状态数组变量中,用于动态创建nodeContainer节点容器,需要将push动作放在set之后。 - this.componentIdArr.push(componentId) - } else if (embed.status == NativeEmbedStatus.UPDATE) { - let nodeController = this.nodeControllerMap.get(componentId); - nodeController?.updateNode({ - textOne: 'update', width: px2vp(embed.info?.width), height: px2vp(embed.info?.height)} as ESObject); - } else { - let nodeController = this.nodeControllerMap.get(componentId); - nodeController?.setDestroy(true); - this.nodeControllerMap.clear(); - this.componentIdArr.length = 0; - } - })// 获取同层渲染组件触摸事件信息。 - .onNativeEmbedGestureEvent((touch) => { - console.log('NativeEmbed onNativeEmbedGestureEvent' + JSON.stringify(touch.touchEvent)); - this.componentIdArr.forEach((componentId: string) => { - let nodeController = this.nodeControllerMap.get(componentId) - // 将获取到的同层区域的事件发送到该区域embedId对应的nodeController上 - if (nodeController?.getEmbedId() === touch.embedId) { - let ret = nodeController?.postEvent(touch.touchEvent) - if (ret) { - console.log('onNativeEmbedGestureEvent success ' + componentId); - } else { - console.log('onNativeEmbedGestureEvent fail ' + componentId); - } - if (touch.result) { - // 通知Web组件手势事件消费结果 - touch.result.setGestureEventResult(ret); - } - } - }) - }) - } - } - } - } -} -// [End draw_x_component_av_player_button] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start draw_x_component_av_player_button] +// 创建NodeController +import { webview } from '@kit.ArkWeb'; +import { UIContext, NodeController, BuilderNode, NodeRenderType, FrameNode } from '@kit.ArkUI'; +import { AVPlayerDemo } from './PlayerDemo'; + +@Observed +declare class Params { + public textOne : string + public textTwo : string + public width : number + public height : number +} + +declare class NodeControllerParams { + public surfaceId : string + public type : string + public renderType : NodeRenderType + public embedId : string + public width : number + public height : number +} + +// 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用。 +class MyNodeController extends NodeController { + private rootNode: BuilderNode<[Params]> | undefined | null; + private embedId_ : string = ''; + private surfaceId_ : string = ''; + private renderType_ :NodeRenderType = NodeRenderType.RENDER_TYPE_DISPLAY; + private width_ : number = 0; + private height_ : number = 0; + private type_ : string = ''; + private isDestroy_ : boolean = false; + + setRenderOption(params : NodeControllerParams) { + this.surfaceId_ = params.surfaceId; + this.renderType_ = params.renderType; + this.embedId_ = params.embedId; + this.width_ = params.width; + this.height_ = params.height; + this.type_ = params.type; + } + // 必须要重写的方法,用于构建节点数、返回节点数挂载在对应NodeContainer中。 + // 在对应NodeContainer创建的时候调用、或者通过rebuild方法调用刷新。 + makeNode(uiContext: UIContext): FrameNode | null{ + if (this.isDestroy_) { // rootNode为null + return null; + } + if (!this.rootNode) { // rootNode 为undefined时 + this.rootNode = new BuilderNode(uiContext, { surfaceId: this.surfaceId_, type: this.renderType_}); + if (this.type_ === 'native/video') { + this.rootNode.build( + wrapBuilder(videoBuilder), {textOne: 'myButton', width : this.width_, height : this.height_}); + } else { + // other + } + } + // 返回FrameNode节点。 + return this.rootNode.getFrameNode(); + } + + setBuilderNode(rootNode: BuilderNode | null): void{ + this.rootNode = rootNode; + } + + getBuilderNode(): BuilderNode<[Params]> | undefined | null{ + return this.rootNode; + } + + updateNode(arg: Object): void { + this.rootNode?.update(arg); + } + getEmbedId() : string { + return this.embedId_; + } + + setDestroy(isDestroy : boolean) : void { + this.isDestroy_ = isDestroy; + if (this.isDestroy_) { + this.rootNode = null; + } + } + + postEvent(event: TouchEvent | undefined) : boolean { + return this.rootNode?.postTouchEvent(event) as boolean; + } +} + +@Component +struct VideoComponent { + @ObjectLink params: Params; + @State bkColor: Color = Color.Red; + mXComponentController: XComponentController = new XComponentController(); + @State playerChanged: boolean = false; + player?: AVPlayerDemo; + + build() { + Column() { + Button(this.params.textOne); + + XComponent({ id: 'video_player_id', type: XComponentType.SURFACE, controller: this.mXComponentController}) + .border({width: 1, color: Color.Red}) + .onLoad(() => { + this.player = new AVPlayerDemo(); + this.player.setSurfaceID(this.mXComponentController.getXComponentSurfaceId()); + this.playerChanged = !this.playerChanged; + this.player.avPlayerLiveDemo(); + }) + .width(300) + .height(200) + } + //自定义组件中的最外层容器组件宽高应该为同层标签的宽高 + .width(this.params.width) + .height(this.params.height) + } +} +// @Builder中为动态组件的具体组件内容。 +@Builder +function videoBuilder(params: Params) { + VideoComponent({ params: params }) + .backgroundColor(Color.Gray) +} + +@Entry +@Component +struct WebIndex { + browserTabController: WebviewController = new webview.WebviewController() + private nodeControllerMap: Map = new Map(); + @State componentIdArr: Array = []; + + aboutToAppear() { + // 配置web开启调试模式。 + webview.WebviewController.setWebDebuggingAccess(true); + } + + build(){ + Row() { + Column() { + Stack() { + ForEach(this.componentIdArr, (componentId: string) => { + NodeContainer(this.nodeControllerMap.get(componentId)); + }, (embedId: string) => embedId) + // Web组件加载本地test.html页面。 + Web({ src: $rawfile('test3.html'), controller: this.browserTabController }) + // 配置同层渲染开关开启。 + .enableNativeEmbedMode(true) + // 获取embed标签的生命周期变化数据。 + .onNativeEmbedLifecycleChange((embed) => { + console.log('NativeEmbed surfaceId' + embed.surfaceId); + // 1. 如果使用embed.info.id作为映射nodeController的key,请在h5页面显式指定id + const componentId = embed.info?.id?.toString() as string + if (embed.status == NativeEmbedStatus.CREATE) { + console.log('NativeEmbed create' + JSON.stringify(embed.info)) + // 创建节点控制器,设置参数并rebuild。 + let nodeController = new MyNodeController() + // 1. embed.info.width和embed.info.height单位是px格式,需要转换成ets侧的默认单位vp + nodeController.setRenderOption({ + surfaceId : embed.surfaceId as string, type : embed.info?.type as string, + renderType : NodeRenderType.RENDER_TYPE_TEXTURE, embedId : embed.embedId as string, + width : px2vp(embed.info?.width), height : px2vp(embed.info?.height)}); + nodeController.setDestroy(false); + // 根据web传入的embed的id属性作为key,将nodeController存入map。 + this.nodeControllerMap.set(componentId, nodeController) + // 将web传入的embed的id属性存入@State状态数组变量中,用于动态创建nodeContainer节点容器,需要将push动作放在set之后。 + this.componentIdArr.push(componentId) + } else if (embed.status == NativeEmbedStatus.UPDATE) { + let nodeController = this.nodeControllerMap.get(componentId); + nodeController?.updateNode({ + textOne: 'update', width: px2vp(embed.info?.width), height: px2vp(embed.info?.height)} as ESObject); + } else { + let nodeController = this.nodeControllerMap.get(componentId); + nodeController?.setDestroy(true); + this.nodeControllerMap.clear(); + this.componentIdArr.length = 0; + } + })// 获取同层渲染组件触摸事件信息。 + .onNativeEmbedGestureEvent((touch) => { + console.log('NativeEmbed onNativeEmbedGestureEvent' + JSON.stringify(touch.touchEvent)); + this.componentIdArr.forEach((componentId: string) => { + let nodeController = this.nodeControllerMap.get(componentId) + // 将获取到的同层区域的事件发送到该区域embedId对应的nodeController上 + if (nodeController?.getEmbedId() === touch.embedId) { + let ret = nodeController?.postEvent(touch.touchEvent) + if (ret) { + console.log('onNativeEmbedGestureEvent success ' + componentId); + } else { + console.log('onNativeEmbedGestureEvent fail ' + componentId); + } + if (touch.result) { + // 通知Web组件手势事件消费结果 + touch.result.setGestureEventResult(ret); + } + } + }) + }) + } + } + } + } +} +// [End draw_x_component_av_player_button] diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index b5f3b4332d..be598b7d15 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/Index.ets @@ -1,38 +1,38 @@ -/* - * 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 { router } from '@kit.ArkUI'; - -@Entry -@Component -struct Index { - build() { - Column({ space: 10 }) { - Button('RenderTxtBoxSameLayer_one') - .onClick(() => { - router.pushUrl({ url: 'pages/RenderTxtBoxSameLayer_one' }); - }) - Button('RenderTxtBoxSameLayer_two') - .onClick(() => { - router.pushUrl({ url: 'pages/RenderTxtBoxSameLayer_two' }); - }) - Button('DrawXCompAVPBtn') - .onClick(() => { - router.pushUrl({ url: 'pages/DrawXCompAVPBtn' }); - }) - }.height('100%') - .width('100%') - } +/* + * 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 { router } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('RenderTxtBoxSameLayer_one') + .onClick(() => { + router.pushUrl({ url: 'pages/RenderTxtBoxSameLayer_one' }); + }) + Button('RenderTxtBoxSameLayer_two') + .onClick(() => { + router.pushUrl({ url: 'pages/RenderTxtBoxSameLayer_two' }); + }) + Button('DrawXCompAVPBtn') + .onClick(() => { + router.pushUrl({ url: 'pages/DrawXCompAVPBtn' }); + }) + }.height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/PlayerDemo.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/PlayerDemo.ets old mode 100755 new mode 100644 index 69eb5079b9..4602bf0742 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/PlayerDemo.ets +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/PlayerDemo.ets @@ -1,103 +1,103 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start mp4_player_example] -import { media } from '@kit.MediaKit'; -import { BusinessError } from '@ohos.base'; - -export class AVPlayerDemo { - private count: number = 0; - private surfaceId: string = ''; // surfaceID用于播放画面显示,具体的值需要通过Xcomponent接口获取,相关文档链接见上面Xcomponent创建方法。 - private isSeek: boolean = true; // 用于区分模式是否支持seek操作。 - - setSurfaceID(id: string){ - console.log('setSurfaceID : ' + id); - this.surfaceId = id; - } - // 注册avplayer回调函数。 - setAVPlayerCallback(avPlayer: media.AVPlayer) { - // seek操作结果回调函数。 - avPlayer.on('seekDone', (seekDoneTime: number) => { - console.info(`AVPlayer seek succeeded, seek time is ${seekDoneTime}`); - }) - // error回调监听函数,当avplayer在操作过程中出现错误时,调用reset接口触发重置流程。 - avPlayer.on('error', (err: BusinessError) => { - console.error(`Invoke avPlayer failed, code is ${err.code}, message is ${err.message}`); - avPlayer.reset(); - }) - // 状态机变化回调函数。 - avPlayer.on('stateChange', async (state: string, reason: media.StateChangeReason) => { - switch (state) { - case 'idle': // 成功调用reset接口后触发该状态机上报。 - console.info('AVPlayer state idle called.'); - avPlayer.release(); // 调用release接口销毁实例对象。 - break; - case 'initialized': // avplayer 设置播放源后触发该状态上报。 - console.info('AVPlayer state initialized called.'); - avPlayer.surfaceId = this.surfaceId; // 设置显示画面,当播放的资源为纯音频时无需设置。 - avPlayer.prepare(); - break; - case 'prepared': // prepared调用成功后上报该状态机。 - console.info('AVPlayer state prepared called.'); - avPlayer.play(); // 调用播放接口开始播放。 - break; - case 'playing': // play成功调用后触发该状态机上报。 - console.info('AVPlayer state prepared called.'); - if(this.count !== 0) { - if (this.isSeek) { - console.info('AVPlayer start to seek.'); - avPlayer.seek(avPlayer.duration); // seek到视频末尾。 - } else { - // 当播放模式不支持seek操作时继续播放到结尾。 - console.info('AVPlayer wait to play end.'); - } - } else { - avPlayer.pause(); // 调用暂停接口暂停播放。 - } - this.count++; - break; - case 'paused': // pause成功调用后触发该状态机上报。 - console.info('AVPlayer state paused called.'); - avPlayer.play(); // 再次播放接口开始播放。 - break; - case 'completed': //播放接口后触发该状态机上报。 - console.info('AVPlayer state paused called.'); - avPlayer.stop(); // 调用播放接口接口。 - break; - case 'stopped': // stop接口后触发该状态机上报。 - console.info('AVPlayer state stopped called.'); - avPlayer.reset(); // 调用reset接口初始化avplayer状态。 - break; - case 'released': //播放接口后触发该状态机上报。 - console.info('AVPlayer state released called.'); - break; - default: - break; - } - }) - } - - // 通过url设置网络地址来实现播放直播码流。 - async avPlayerLiveDemo(){ - // 创建avPlayer实例对象 - let avPlayer: media.AVPlayer = await media.createAVPlayer(); - // 创建状态机变化回调函数。 - this.setAVPlayerCallback(avPlayer); - this.isSeek = false; // 不支持seek操作。 - // 使用时需要自行替换视频链接 - avPlayer.url = 'xxx/demo.mp4'; - } -} -// [End mp4_player_example] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start mp4_player_example] +import { media } from '@kit.MediaKit'; +import { BusinessError } from '@ohos.base'; + +export class AVPlayerDemo { + private count: number = 0; + private surfaceId: string = ''; // surfaceID用于播放画面显示,具体的值需要通过Xcomponent接口获取,相关文档链接见上面Xcomponent创建方法。 + private isSeek: boolean = true; // 用于区分模式是否支持seek操作。 + + setSurfaceID(id: string){ + console.log('setSurfaceID : ' + id); + this.surfaceId = id; + } + // 注册avplayer回调函数。 + setAVPlayerCallback(avPlayer: media.AVPlayer) { + // seek操作结果回调函数。 + avPlayer.on('seekDone', (seekDoneTime: number) => { + console.info(`AVPlayer seek succeeded, seek time is ${seekDoneTime}`); + }) + // error回调监听函数,当avplayer在操作过程中出现错误时,调用reset接口触发重置流程。 + avPlayer.on('error', (err: BusinessError) => { + console.error(`Invoke avPlayer failed, code is ${err.code}, message is ${err.message}`); + avPlayer.reset(); + }) + // 状态机变化回调函数。 + avPlayer.on('stateChange', async (state: string, reason: media.StateChangeReason) => { + switch (state) { + case 'idle': // 成功调用reset接口后触发该状态机上报。 + console.info('AVPlayer state idle called.'); + avPlayer.release(); // 调用release接口销毁实例对象。 + break; + case 'initialized': // avplayer 设置播放源后触发该状态上报。 + console.info('AVPlayer state initialized called.'); + avPlayer.surfaceId = this.surfaceId; // 设置显示画面,当播放的资源为纯音频时无需设置。 + avPlayer.prepare(); + break; + case 'prepared': // prepared调用成功后上报该状态机。 + console.info('AVPlayer state prepared called.'); + avPlayer.play(); // 调用播放接口开始播放。 + break; + case 'playing': // play成功调用后触发该状态机上报。 + console.info('AVPlayer state prepared called.'); + if(this.count !== 0) { + if (this.isSeek) { + console.info('AVPlayer start to seek.'); + avPlayer.seek(avPlayer.duration); // seek到视频末尾。 + } else { + // 当播放模式不支持seek操作时继续播放到结尾。 + console.info('AVPlayer wait to play end.'); + } + } else { + avPlayer.pause(); // 调用暂停接口暂停播放。 + } + this.count++; + break; + case 'paused': // pause成功调用后触发该状态机上报。 + console.info('AVPlayer state paused called.'); + avPlayer.play(); // 再次播放接口开始播放。 + break; + case 'completed': //播放接口后触发该状态机上报。 + console.info('AVPlayer state paused called.'); + avPlayer.stop(); // 调用播放接口接口。 + break; + case 'stopped': // stop接口后触发该状态机上报。 + console.info('AVPlayer state stopped called.'); + avPlayer.reset(); // 调用reset接口初始化avplayer状态。 + break; + case 'released': //播放接口后触发该状态机上报。 + console.info('AVPlayer state released called.'); + break; + default: + break; + } + }) + } + + // 通过url设置网络地址来实现播放直播码流。 + async avPlayerLiveDemo(){ + // 创建avPlayer实例对象 + let avPlayer: media.AVPlayer = await media.createAVPlayer(); + // 创建状态机变化回调函数。 + this.setAVPlayerCallback(avPlayer); + this.isSeek = false; // 不支持seek操作。 + // 使用时需要自行替换视频链接 + avPlayer.url = 'xxx/demo.mp4'; + } +} +// [End mp4_player_example] diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/RenderTxtBoxSameLayer_one.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/RenderTxtBoxSameLayer_one.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/RenderTxtBoxSameLayer_two.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/ets/pages/RenderTxtBoxSameLayer_two.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/module.json5 old mode 100755 new mode 100644 index 0755ae2a6b..6596c6e686 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/module.json5 @@ -1,74 +1,74 @@ -/* - * 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" - } - ] - } - ], - // [Start request_permissions] - "requestPermissions":[ - { - "name" : "ohos.permission.INTERNET" - } - ], - // [End request_permissions] - - } +/* + * 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" + } + ] + } + ], + // [Start request_permissions] + "requestPermissions":[ + { + "name" : "ohos.permission.INTERNET" + } + ], + // [End request_permissions] + + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test1.html b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test1.html old mode 100755 new mode 100644 index 767ff7705b..0417d261ed --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test1.html +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test1.html @@ -1,33 +1,33 @@ - - - - - - - 同层渲染测试html - - - - - - - - - - - - - + + + + + + + 同层渲染测试html + + + + + + + + + + + + + diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test2.html b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test2.html old mode 100755 new mode 100644 index 0b21253492..a87df34562 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test2.html +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test2.html @@ -1,33 +1,33 @@ - - - - - - - 同层渲染测试html - - - - - - - - - - - - - + + + + + + + 同层渲染测试html + + + + + + + + + + + + + diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test3.html b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test3.html old mode 100755 new mode 100644 index 6216179164..641bb291f1 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test3.html +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/rawfile/test3.html @@ -1,29 +1,29 @@ - - - - - - 同层渲染测试html - - - -
-
- -
-
- + + + + + + 同层渲染测试html + + + +
+
+ +
+
+ \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UseSameLayerRender/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/UseSameLayerRender/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/UseSameLayerRender/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/UseSameLayerRender/hvigorfile.ts b/code/DocsSample/ArkWeb/UseSameLayerRender/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/oh-package.json5 b/code/DocsSample/ArkWeb/UseSameLayerRender/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/UseSameLayerRender/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UseSameLayerRender/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/ohosTest.md b/code/DocsSample/ArkWeb/UseSameLayerRender/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/screenshots/DrawXCompAVPBtn.png b/code/DocsSample/ArkWeb/UseSameLayerRender/screenshots/DrawXCompAVPBtn.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/screenshots/RenderTxtBoxSameLayer_one.png b/code/DocsSample/ArkWeb/UseSameLayerRender/screenshots/RenderTxtBoxSameLayer_one.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UseSameLayerRender/screenshots/RenderTxtBoxSameLayer_two.png b/code/DocsSample/ArkWeb/UseSameLayerRender/screenshots/RenderTxtBoxSameLayer_two.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/.gitignore b/code/DocsSample/ArkWeb/UsingWebMultimedia/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/app.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/app.json5 old mode 100755 new mode 100644 index e797bbd562..ed067223ab --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/app.json5 @@ -1,25 +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.usingwebmultimedia", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.usingwebmultimedia", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index bff15b824e..201e95512e --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "UsingWebMultimedia" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "UsingWebMultimedia" + } + ] +} diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/README.md b/code/DocsSample/ArkWeb/UsingWebMultimedia/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/build-profile.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/build-profile.json5 old mode 100755 new mode 100644 index 43f67ad37e..d5afe2afae --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/build-profile.json5 @@ -1,76 +1,76 @@ -/* -* 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry2", - "srcPath": "./entry2", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "entry3", - "srcPath": "./entry3", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* +* 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry2", + "srcPath": "./entry2", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "entry3", + "srcPath": "./entry3", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/code-linter.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/.gitignore b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/build-profile.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/oh-package.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/UsingWebMultimedia/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 6ba41b851a..7582e04e86 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,59 +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'; - -const ARK_WEB_MEDIA_LOG_INFO = 0x0000; -const ARK_WEB_MEDIA_LOG_ERROR = 0x0000; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(ARK_WEB_MEDIA_LOG_ERROR, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * 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'; + +const ARK_WEB_MEDIA_LOG_INFO = 0x0000; +const ARK_WEB_MEDIA_LOG_ERROR = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(ARK_WEB_MEDIA_LOG_ERROR, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 2ed644a076..07890bf5a1 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; - -const ARK_WEB_MEDIA_LOG_INFO = 0x0000; - -export default class EntryBackupAbility extends BackupExtensionAbility { - async onBackup() { - hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', 'onBackup ok'); - } - - async onRestore(bundleVersion: BundleVersion) { - hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const ARK_WEB_MEDIA_LOG_INFO = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(ARK_WEB_MEDIA_LOG_INFO, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/module.json5 old mode 100755 new mode 100644 index 599faa0ffe..54af2946ce --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/module.json5 @@ -1,110 +1,110 @@ -/* - * 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" - } - ] - } - ], - "requestPermissions":[ - { - "name" : "ohos.permission.CAMERA", - "reason": "$string:EntryAbility_desc", - "usedScene": { - "abilities": [ - "EntryAbility" - ] - } - }, - { - "name" : "ohos.permission.MICROPHONE", - "reason": "$string:EntryAbility_desc", - "usedScene": { - "abilities": [ - "EntryAbility" - ] - } - } - ], - "requestPermissions": [ - { - "name" : "ohos.permission.CAMERA", - "reason": "$string:EntryAbility_desc", - "usedScene": { - "abilities": [ - "EntryAbility" - ] - } - }, - { - "name" : "ohos.permission.MICROPHONE", - "reason": "$string:EntryAbility_desc", - "usedScene": { - "abilities": [ - "EntryAbility" - ] - } - }, - { - "name": "ohos.permission.INTERNET" - } - ] - - } +/* + * 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" + } + ] + } + ], + "requestPermissions":[ + { + "name" : "ohos.permission.CAMERA", + "reason": "$string:EntryAbility_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ] + } + }, + { + "name" : "ohos.permission.MICROPHONE", + "reason": "$string:EntryAbility_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ] + } + } + ], + "requestPermissions": [ + { + "name" : "ohos.permission.CAMERA", + "reason": "$string:EntryAbility_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ] + } + }, + { + "name" : "ohos.permission.MICROPHONE", + "reason": "$string:EntryAbility_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ] + } + }, + { + "name": "ohos.permission.INTERNET" + } + ] + + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/rawfile/index.html b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/rawfile/index.html old mode 100755 new mode 100644 index 3e4f8b4a2e..9464d7b99d --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/rawfile/index.html +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/rawfile/index.html @@ -1,45 +1,45 @@ - - - - - - - - - - -
- - - - + + + + + + + + + + +
+ + + + diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/.gitignore b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/build-profile.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/build-profile.json5 old mode 100755 new mode 100644 index 154bdd0875..9edfdf8c4a --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* +* 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/hvigorfile.ts b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/obfuscation-rules.txt b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/obfuscation-rules.txt old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/oh-package.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/oh-package.json5 old mode 100755 new mode 100644 index 3fc6e6bee3..2944307304 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/oh-package.json5 @@ -1,25 +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": "entry2", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* +* 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": "entry2", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets old mode 100755 new mode 100644 index 413af92ba3..d1bd537608 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { hilog } from '@kit.PerformanceAnalysisKit'; - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -// [Start allow_subsequent_rendering_to_use_ui] -import { window } from '@kit.ArkUI'; - -export default class Entry2Ability extends UIAbility { - // [StartExclude allow_subsequent_rendering_to_use_ui] - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - // [EndExclude allow_subsequent_rendering_to_use_ui] - onWindowStageCreate(windowStage: window.WindowStage): void { - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - return; - } - // 保存 UIContext, 在后续的同层渲染绘制中会用到。 - AppStorage.setOrCreate('UIContext', windowStage.getMainWindowSync().getUIContext()); - }); - } - // [StartExclude allow_subsequent_rendering_to_use_ui] - 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'); - } - // [EndExclude allow_subsequent_rendering_to_use_ui] -} +/* + * 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 { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +// [Start allow_subsequent_rendering_to_use_ui] +import { window } from '@kit.ArkUI'; + +export default class Entry2Ability extends UIAbility { + // [StartExclude allow_subsequent_rendering_to_use_ui] + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + // [EndExclude allow_subsequent_rendering_to_use_ui] + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + return; + } + // 保存 UIContext, 在后续的同层渲染绘制中会用到。 + AppStorage.setOrCreate('UIContext', windowStage.getMainWindowSync().getUIContext()); + }); + } + // [StartExclude allow_subsequent_rendering_to_use_ui] + 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'); + } + // [EndExclude allow_subsequent_rendering_to_use_ui] +} // [End allow_subsequent_rendering_to_use_ui] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets old mode 100755 new mode 100644 index a9c5227a98..f9a6b45900 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets @@ -1,27 +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 Entry2BackupAbility 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)); - } +/* + * 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 Entry2BackupAbility 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/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/PlayerDemo.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/PlayerDemo.ets old mode 100755 new mode 100644 index 163d102b84..7ed1e324c8 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/PlayerDemo.ets +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/PlayerDemo.ets @@ -1,278 +1,278 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//[Start video_playing_usage] -import { media } from '@kit.MediaKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -export interface AVPlayerListener { - onPlaying() : void; - onPaused() : void; - onDurationChanged(duration: number) : void; - onBufferedTimeChanged(buffered: number) : void; - onTimeUpdate(time: number) : void; - onEnded() : void; - onError() : void; - onVideoSizeChanged(width: number, height: number): void; - onDestroyed(): void; -} - -interface PlayerParam { - url: string; - listener?: AVPlayerListener; - httpHeaders?: Record; -} - -interface PlayCommand { - func: Function; - name?: string; -} - -interface CheckPlayCommandResult { - ignore: boolean; - indexToRemove: number; -} - -export class AVPlayerDemo { - // surfaceID用于播放画面显示,具体的值需要通过Xcomponent接口获取,相关文档链接见上面Xcomponent创建方法 - private surfaceID: string = ''; - - public avPlayer?: media.AVPlayer; - public prepared: boolean = false; - - public commands: PlayCommand[] = []; - - setSurfaceID(id: string) { - console.log(`AVPlayerDemo.setSurfaceID : ${id}`); - this.surfaceID = id; - } - // 注册avplayer回调函数 - setAVPlayerCallback(avPlayer: media.AVPlayer, listener?: AVPlayerListener) { - // seek操作结果回调函数 - avPlayer.on('seekDone', (seekDoneTime: number) => { - console.info(`AVPlayer seek succeeded, seek time is ${seekDoneTime}`); - }); - // error回调监听函数,当avPlayer在操作过程中出现错误时调用reset接口触发重置流程 - avPlayer.on('error', (err: BusinessError) => { - console.error(`Invoke avPlayer failed, code is ${err.code}, message is ${err.message}`); - listener?.onError(); - avPlayer.reset(); // 调用reset重置资源,触发idle状态 - }); - // 状态机变化回调函数 - avPlayer.on('stateChange', async (state: string, reason: media.StateChangeReason) => { - switch (state) { - case 'idle': // 成功调用reset接口后触发该状态机上报 - console.info('AVPlayer state idle called.'); - avPlayer.release(); // 调用release接口销毁实例对象 - break; - case 'initialized': // avplayer 设置播放源后触发该状态上报 - console.info('AVPlayer state initialized called.'); - avPlayer.surfaceId = this.surfaceID; // 设置显示画面,当播放的资源为纯音频时无需设置 - avPlayer.prepare(); - break; - case 'prepared': // prepare调用成功后上报该状态机 - console.info('AVPlayer state prepared called.'); - this.prepared = true; - this.schedule(); - break; - case 'playing': // play成功调用后触发该状态机上报 - console.info('AVPlayer state playing called.'); - listener?.onPlaying(); - break; - case 'paused': // pause成功调用后触发该状态机上报 - console.info('AVPlayer state paused called.'); - listener?.onPaused(); - break; - case 'completed': // 播放结束后触发该状态机上报 - console.info('AVPlayer state completed called.'); - avPlayer.stop(); //调用播放结束接口 - break; - case 'stopped': // stop接口成功调用后触发该状态机上报 - console.info('AVPlayer state stopped called.'); - listener?.onEnded(); - break; - case 'released': - this.prepared = false; - listener?.onDestroyed(); - console.info('AVPlayer state released called.'); - break; - default: - console.info('AVPlayer state unknown called.'); - break; - } - }); - avPlayer.on('durationUpdate', (duration: number) => { - console.info(`AVPlayer state durationUpdate success,new duration is :${duration}`); - listener?.onDurationChanged(duration/1000); - }); - avPlayer.on('timeUpdate', (time:number) => { - listener?.onTimeUpdate(time/1000); - }); - avPlayer.on('bufferingUpdate', (infoType: media.BufferingInfoType, value: number) => { - console.info(`AVPlayer state bufferingUpdate success,and infoType value is:${infoType}, value is : ${value}`); - if (infoType == media.BufferingInfoType.BUFFERING_PERCENT) { - } - listener?.onBufferedTimeChanged(value); - }) - avPlayer.on('videoSizeChange', (width: number, height: number) => { - console.info(`AVPlayer state videoSizeChange success,and width is:${width}, height is : ${height}`); - listener?.onVideoSizeChanged(width, height); - }) - } - - // 以下demo为通过url设置网络地址来实现播放直播码流的demo - async avPlayerLiveDemo(playerParam: PlayerParam) { - // 创建avPlayer实例对象 - this.avPlayer = await media.createAVPlayer(); - // 创建状态机变化回调函数 - this.setAVPlayerCallback(this.avPlayer, playerParam.listener); - - let mediaSource: media.MediaSource = media.createMediaSourceWithUrl(playerParam.url, playerParam.httpHeaders); - let strategy: media.PlaybackStrategy = { - preferredWidth: 100, - preferredHeight: 100, - preferredBufferDuration: 100, - preferredHdr: false - }; - this.avPlayer.setMediaSource(mediaSource, strategy); - console.log(`AVPlayer url:[${playerParam.url}]`); - } - - schedule() { - if (!this.avPlayer) { - return; - } - if (!this.prepared) { - return; - } - if (this.commands.length > 0) { - let command = this.commands.shift(); - if (command) { - command.func(); - } - if (this.commands.length > 0) { - setTimeout(() => { - this.schedule(); - }); - } - } - } - - private checkCommand(selfName: string, oppositeName: string) { - let indexToRemove = -1; - let ignoreThisAction = false; - let index = this.commands.length - 1; - while (index >= 0) { - if (this.commands[index].name == selfName) { - ignoreThisAction = true; - break; - } - if (this.commands[index].name == oppositeName) { - indexToRemove = index; - break; - } - index--; - } - - let result : CheckPlayCommandResult = { - ignore: ignoreThisAction, - indexToRemove: indexToRemove, - }; - return result; - } - - play() { - let commandName = 'play'; - let checkResult = this.checkCommand(commandName, 'pause'); - if (checkResult.ignore) { - console.log(`AVPlayer ${commandName} ignored.`); - this.schedule(); - return; - } - if (checkResult.indexToRemove >= 0) { - let removedCommand = this.commands.splice(checkResult.indexToRemove, 1); - console.log(`AVPlayer ${JSON.stringify(removedCommand)} removed.`); - return; - } - this.commands.push({ func: ()=>{ - console.info('AVPlayer.play()'); - this.avPlayer?.play(); - }, name: commandName}); - this.schedule(); - } - pause() { - let commandName = 'pause'; - let checkResult = this.checkCommand(commandName, 'play'); - console.log(`checkResult:${JSON.stringify(checkResult)}`); - if (checkResult.ignore) { - console.log(`AVPlayer ${commandName} ignored.`); - this.schedule(); - return; - } - if (checkResult.indexToRemove >= 0) { - let removedCommand = this.commands.splice(checkResult.indexToRemove, 1); - console.log(`AVPlayer ${JSON.stringify(removedCommand)} removed.`); - return; - } - this.commands.push({ func: ()=>{ - console.info('AVPlayer.pause()'); - this.avPlayer?.pause(); - }, name: commandName}); - this.schedule(); - } - release() { - this.commands.push({ func: ()=>{ - console.info('AVPlayer.release()'); - this.avPlayer?.release(); - }}); - this.schedule(); - } - seek(time: number) { - this.commands.push({ func: ()=>{ - console.info(`AVPlayer.seek(${time})`); - this.avPlayer?.seek(time * 1000); - }}); - this.schedule(); - } - setVolume(volume: number) { - this.commands.push({ func: ()=>{ - console.info(`AVPlayer.setVolume(${volume})`); - this.avPlayer?.setVolume(volume); - }}); - this.schedule(); - } - setPlaybackRate(playbackRate: number) { - let speed = media.PlaybackSpeed.SPEED_FORWARD_1_00_X; - let delta = 0.05; - playbackRate += delta; - if (playbackRate < 1) { - speed = media.PlaybackSpeed.SPEED_FORWARD_0_75_X; - } else if (playbackRate < 1.25) { - speed = media.PlaybackSpeed.SPEED_FORWARD_1_00_X; - } else if (playbackRate < 1.5) { - speed = media.PlaybackSpeed.SPEED_FORWARD_1_25_X; - } else if (playbackRate < 2) { - speed = media.PlaybackSpeed.SPEED_FORWARD_1_75_X; - } else { - speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X; - } - this.commands.push({ func: ()=>{ - console.info(`AVPlayer.setSpeed(${speed})`); - this.avPlayer?.setSpeed(speed); - }}); - this.schedule(); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//[Start video_playing_usage] +import { media } from '@kit.MediaKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +export interface AVPlayerListener { + onPlaying() : void; + onPaused() : void; + onDurationChanged(duration: number) : void; + onBufferedTimeChanged(buffered: number) : void; + onTimeUpdate(time: number) : void; + onEnded() : void; + onError() : void; + onVideoSizeChanged(width: number, height: number): void; + onDestroyed(): void; +} + +interface PlayerParam { + url: string; + listener?: AVPlayerListener; + httpHeaders?: Record; +} + +interface PlayCommand { + func: Function; + name?: string; +} + +interface CheckPlayCommandResult { + ignore: boolean; + indexToRemove: number; +} + +export class AVPlayerDemo { + // surfaceID用于播放画面显示,具体的值需要通过Xcomponent接口获取,相关文档链接见上面Xcomponent创建方法 + private surfaceID: string = ''; + + public avPlayer?: media.AVPlayer; + public prepared: boolean = false; + + public commands: PlayCommand[] = []; + + setSurfaceID(id: string) { + console.log(`AVPlayerDemo.setSurfaceID : ${id}`); + this.surfaceID = id; + } + // 注册avplayer回调函数 + setAVPlayerCallback(avPlayer: media.AVPlayer, listener?: AVPlayerListener) { + // seek操作结果回调函数 + avPlayer.on('seekDone', (seekDoneTime: number) => { + console.info(`AVPlayer seek succeeded, seek time is ${seekDoneTime}`); + }); + // error回调监听函数,当avPlayer在操作过程中出现错误时调用reset接口触发重置流程 + avPlayer.on('error', (err: BusinessError) => { + console.error(`Invoke avPlayer failed, code is ${err.code}, message is ${err.message}`); + listener?.onError(); + avPlayer.reset(); // 调用reset重置资源,触发idle状态 + }); + // 状态机变化回调函数 + avPlayer.on('stateChange', async (state: string, reason: media.StateChangeReason) => { + switch (state) { + case 'idle': // 成功调用reset接口后触发该状态机上报 + console.info('AVPlayer state idle called.'); + avPlayer.release(); // 调用release接口销毁实例对象 + break; + case 'initialized': // avplayer 设置播放源后触发该状态上报 + console.info('AVPlayer state initialized called.'); + avPlayer.surfaceId = this.surfaceID; // 设置显示画面,当播放的资源为纯音频时无需设置 + avPlayer.prepare(); + break; + case 'prepared': // prepare调用成功后上报该状态机 + console.info('AVPlayer state prepared called.'); + this.prepared = true; + this.schedule(); + break; + case 'playing': // play成功调用后触发该状态机上报 + console.info('AVPlayer state playing called.'); + listener?.onPlaying(); + break; + case 'paused': // pause成功调用后触发该状态机上报 + console.info('AVPlayer state paused called.'); + listener?.onPaused(); + break; + case 'completed': // 播放结束后触发该状态机上报 + console.info('AVPlayer state completed called.'); + avPlayer.stop(); //调用播放结束接口 + break; + case 'stopped': // stop接口成功调用后触发该状态机上报 + console.info('AVPlayer state stopped called.'); + listener?.onEnded(); + break; + case 'released': + this.prepared = false; + listener?.onDestroyed(); + console.info('AVPlayer state released called.'); + break; + default: + console.info('AVPlayer state unknown called.'); + break; + } + }); + avPlayer.on('durationUpdate', (duration: number) => { + console.info(`AVPlayer state durationUpdate success,new duration is :${duration}`); + listener?.onDurationChanged(duration/1000); + }); + avPlayer.on('timeUpdate', (time:number) => { + listener?.onTimeUpdate(time/1000); + }); + avPlayer.on('bufferingUpdate', (infoType: media.BufferingInfoType, value: number) => { + console.info(`AVPlayer state bufferingUpdate success,and infoType value is:${infoType}, value is : ${value}`); + if (infoType == media.BufferingInfoType.BUFFERING_PERCENT) { + } + listener?.onBufferedTimeChanged(value); + }) + avPlayer.on('videoSizeChange', (width: number, height: number) => { + console.info(`AVPlayer state videoSizeChange success,and width is:${width}, height is : ${height}`); + listener?.onVideoSizeChanged(width, height); + }) + } + + // 以下demo为通过url设置网络地址来实现播放直播码流的demo + async avPlayerLiveDemo(playerParam: PlayerParam) { + // 创建avPlayer实例对象 + this.avPlayer = await media.createAVPlayer(); + // 创建状态机变化回调函数 + this.setAVPlayerCallback(this.avPlayer, playerParam.listener); + + let mediaSource: media.MediaSource = media.createMediaSourceWithUrl(playerParam.url, playerParam.httpHeaders); + let strategy: media.PlaybackStrategy = { + preferredWidth: 100, + preferredHeight: 100, + preferredBufferDuration: 100, + preferredHdr: false + }; + this.avPlayer.setMediaSource(mediaSource, strategy); + console.log(`AVPlayer url:[${playerParam.url}]`); + } + + schedule() { + if (!this.avPlayer) { + return; + } + if (!this.prepared) { + return; + } + if (this.commands.length > 0) { + let command = this.commands.shift(); + if (command) { + command.func(); + } + if (this.commands.length > 0) { + setTimeout(() => { + this.schedule(); + }); + } + } + } + + private checkCommand(selfName: string, oppositeName: string) { + let indexToRemove = -1; + let ignoreThisAction = false; + let index = this.commands.length - 1; + while (index >= 0) { + if (this.commands[index].name == selfName) { + ignoreThisAction = true; + break; + } + if (this.commands[index].name == oppositeName) { + indexToRemove = index; + break; + } + index--; + } + + let result : CheckPlayCommandResult = { + ignore: ignoreThisAction, + indexToRemove: indexToRemove, + }; + return result; + } + + play() { + let commandName = 'play'; + let checkResult = this.checkCommand(commandName, 'pause'); + if (checkResult.ignore) { + console.log(`AVPlayer ${commandName} ignored.`); + this.schedule(); + return; + } + if (checkResult.indexToRemove >= 0) { + let removedCommand = this.commands.splice(checkResult.indexToRemove, 1); + console.log(`AVPlayer ${JSON.stringify(removedCommand)} removed.`); + return; + } + this.commands.push({ func: ()=>{ + console.info('AVPlayer.play()'); + this.avPlayer?.play(); + }, name: commandName}); + this.schedule(); + } + pause() { + let commandName = 'pause'; + let checkResult = this.checkCommand(commandName, 'play'); + console.log(`checkResult:${JSON.stringify(checkResult)}`); + if (checkResult.ignore) { + console.log(`AVPlayer ${commandName} ignored.`); + this.schedule(); + return; + } + if (checkResult.indexToRemove >= 0) { + let removedCommand = this.commands.splice(checkResult.indexToRemove, 1); + console.log(`AVPlayer ${JSON.stringify(removedCommand)} removed.`); + return; + } + this.commands.push({ func: ()=>{ + console.info('AVPlayer.pause()'); + this.avPlayer?.pause(); + }, name: commandName}); + this.schedule(); + } + release() { + this.commands.push({ func: ()=>{ + console.info('AVPlayer.release()'); + this.avPlayer?.release(); + }}); + this.schedule(); + } + seek(time: number) { + this.commands.push({ func: ()=>{ + console.info(`AVPlayer.seek(${time})`); + this.avPlayer?.seek(time * 1000); + }}); + this.schedule(); + } + setVolume(volume: number) { + this.commands.push({ func: ()=>{ + console.info(`AVPlayer.setVolume(${volume})`); + this.avPlayer?.setVolume(volume); + }}); + this.schedule(); + } + setPlaybackRate(playbackRate: number) { + let speed = media.PlaybackSpeed.SPEED_FORWARD_1_00_X; + let delta = 0.05; + playbackRate += delta; + if (playbackRate < 1) { + speed = media.PlaybackSpeed.SPEED_FORWARD_0_75_X; + } else if (playbackRate < 1.25) { + speed = media.PlaybackSpeed.SPEED_FORWARD_1_00_X; + } else if (playbackRate < 1.5) { + speed = media.PlaybackSpeed.SPEED_FORWARD_1_25_X; + } else if (playbackRate < 2) { + speed = media.PlaybackSpeed.SPEED_FORWARD_1_75_X; + } else { + speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X; + } + this.commands.push({ func: ()=>{ + console.info(`AVPlayer.setSpeed(${speed})`); + this.avPlayer?.setSpeed(speed); + }}); + this.schedule(); + } +} //[End video_playing_usage] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/module.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/module.json5 old mode 100755 new mode 100644 index 395d1acd09..8b99132eae --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/module.json5 @@ -1,70 +1,70 @@ -/* -* 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": "entry2", - "type": "entry", - "description": "$string:module_desc", - "mainElement": "Entry2Ability", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry2Ability", - "srcEntry": "./ets/entry2ability/Entry2Ability.ets", - "description": "$string:Entry2Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry2Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "Entry2BackupAbility", - "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.ets", - "type": "backup", - "exported": false, - "metadata": [ - { - "name": "ohos.extension.backup", - "resource": "$profile:backup_config" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* +* 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": "entry2", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "Entry2Ability", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry2Ability", + "srcEntry": "./ets/entry2ability/Entry2Ability.ets", + "description": "$string:Entry2Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry2Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "Entry2BackupAbility", + "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/rawfile/main.html b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/rawfile/main.html old mode 100755 new mode 100644 index dde8aedb68..f87d2d1991 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/rawfile/main.html +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/resources/rawfile/main.html @@ -1,27 +1,27 @@ - - - - - 视频托管测试html - - - -
- - -
- - + + + + + 视频托管测试html + + + +
+ + +
+ + diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 72b1fd5f36..275d4a7e53 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/ohosTest/module.json5 @@ -1,26 +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. -*/ - -{ - "module": { - "name": "entry2_test", - "type": "feature", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* +* 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": "entry2_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/test/List.test.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/build-profile.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/build-profile.json5 index 154bdd0875..9edfdf8c4a 100644 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/build-profile.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* +* 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/oh-package.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/oh-package.json5 index f34ecb6885..fdde2dca53 100644 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/oh-package.json5 @@ -1,25 +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": "entry3", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +/* +* 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": "entry3", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/ets/entry3ability/Entry3Ability.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/ets/entry3ability/Entry3Ability.ets index 5b2c6720cb..94de6f8cdb 100644 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/ets/entry3ability/Entry3Ability.ets +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/ets/entry3ability/Entry3Ability.ets @@ -1,58 +1,58 @@ -/* - * 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'; - -const DOMAIN = 0x0000; - -export default class Entry3Ability extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); - return; - } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * 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'; + +const DOMAIN = 0x0000; + +export default class Entry3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/ets/entry3backupability/Entry3BackupAbility.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/ets/entry3backupability/Entry3BackupAbility.ets index 1b3eee2847..0370ffb34e 100644 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/ets/entry3backupability/Entry3BackupAbility.ets +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/ets/entry3backupability/Entry3BackupAbility.ets @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; - -const DOMAIN = 0x0000; - -export default class Entry3BackupAbility extends BackupExtensionAbility { - async onBackup() { - hilog.info(DOMAIN, 'testTag', 'onBackup ok'); - await Promise.resolve(); - } - - async onRestore(bundleVersion: BundleVersion) { - hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); - await Promise.resolve(); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class Entry3BackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/module.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/module.json5 index 7cdc77b7fa..405a5183ab 100644 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/module.json5 @@ -1,65 +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. -*/ - -{ - "module": { - "name": "entry3", - "type": "entry", - "description": "$string:module_desc", - "mainElement": "Entry3Ability", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Entry3Ability", - "srcEntry": "./ets/entry3ability/Entry3Ability.ets", - "description": "$string:Entry3Ability_desc", - "icon": "$media:layered_image", - "label": "$string:Entry3Ability_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "Entry3BackupAbility", - "srcEntry": "./ets/entry3backupability/Entry3BackupAbility.ets", - "type": "backup", - "exported": false, - "metadata": [ - { - "name": "ohos.extension.backup", - "resource": "$profile:backup_config" - } - ] - } - ] - } +/* +* 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": "entry3", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "Entry3Ability", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "Entry3Ability", + "srcEntry": "./ets/entry3ability/Entry3Ability.ets", + "description": "$string:Entry3Ability_desc", + "icon": "$media:layered_image", + "label": "$string:Entry3Ability_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "Entry3BackupAbility", + "srcEntry": "./ets/entry3backupability/Entry3BackupAbility.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/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/element/float.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/element/float.json index a8a5d404dc..33ea22304f 100644 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/element/float.json +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/element/float.json @@ -1,8 +1,8 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/profile/backup_config.json index d742c2f96e..78f40ae7c4 100644 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/rawfile/PictureInPicture.html b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/rawfile/PictureInPicture.html index 7bf4266df6..bf46d9515a 100644 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/rawfile/PictureInPicture.html +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/main/resources/rawfile/PictureInPicture.html @@ -1,87 +1,87 @@ - - - - - - - Picture-in-Picture Demo - - - - - - - - - - + + + + + + + Picture-in-Picture Demo + + + + + + + + + + \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/ohosTest/module.json5 index 86214f17e0..33e7ebcfda 100644 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry3/src/ohosTest/module.json5 @@ -1,26 +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. -*/ - -{ - "module": { - "name": "entry3_test", - "type": "feature", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* +* 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": "entry3_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/UsingWebMultimedia/hvigorfile.ts b/code/DocsSample/ArkWeb/UsingWebMultimedia/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/oh-package.json5 b/code/DocsSample/ArkWeb/UsingWebMultimedia/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/oh-package.json5 +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/ohosTest.md b/code/DocsSample/ArkWeb/UsingWebMultimedia/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/HoldVideoConfWebRTC_1.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/HoldVideoConfWebRTC_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/HoldVideoConfWebRTC_2.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/HoldVideoConfWebRTC_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/HoldVideoConfWebRTC_3.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/HoldVideoConfWebRTC_3.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/TakeOverMediaPlay.png b/code/DocsSample/ArkWeb/UsingWebMultimedia/screenshots/TakeOverMediaPlay.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/.gitignore b/code/DocsSample/ArkWeb/WebRenderLayout/.gitignore old mode 100755 new mode 100644 index 0b9dda19af..d2ff20141c --- a/code/DocsSample/ArkWeb/WebRenderLayout/.gitignore +++ b/code/DocsSample/ArkWeb/WebRenderLayout/.gitignore @@ -1,12 +1,12 @@ -/node_modules -/oh_modules -/local.properties -/.idea -**/build -/.hvigor -.cxx -/.clangd -/.clang-format -/.clang-tidy -**/.test +/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/ArkWeb/WebRenderLayout/AppScope/app.json5 b/code/DocsSample/ArkWeb/WebRenderLayout/AppScope/app.json5 old mode 100755 new mode 100644 index d00f94d308..05d4077ce4 --- a/code/DocsSample/ArkWeb/WebRenderLayout/AppScope/app.json5 +++ b/code/DocsSample/ArkWeb/WebRenderLayout/AppScope/app.json5 @@ -1,25 +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.webrenderlayout", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.webrenderlayout", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/WebRenderLayout/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 60150165cd..d141695c97 --- a/code/DocsSample/ArkWeb/WebRenderLayout/AppScope/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/WebRenderLayout/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "WebRenderLayout" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "WebRenderLayout" + } + ] +} diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/WebRenderLayout/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/README.md b/code/DocsSample/ArkWeb/WebRenderLayout/README.md old mode 100755 new mode 100644 index 840e942011..15a85277b8 --- a/code/DocsSample/ArkWeb/WebRenderLayout/README.md +++ b/code/DocsSample/ArkWeb/WebRenderLayout/README.md @@ -1,78 +1,78 @@ -# Web组件渲染模式 - -## RenderMode - -### 介绍 - -1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-render-mode.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。 - -### 效果预览 - -| 主页 | -| ------------------------------------------------------------ | -| | - -使用说明 - -1. 使用renderMode设置渲染模式为 ASYNC_RENDER (同步渲染模式)。 -# Web组件大小自适应页面内容布局 - -## FitPageContent - -### 介绍 - -1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-fit-content.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。 - -### 效果预览 - -| 主页 | -| --------------------------------------------------------- | -| | - -使用说明 - -1. 使用Web组件大小自适应页面内容布局模式layoutMode(WebLayoutMode.FIT_CONTENT)时,能使Web组件的大小根据页面内容自适应变化。 - -## 工程目录 - -``` -entry/src/main/ -|---ets -|---|---entryability -|---|---|---EntryAbility.ets -|---|---pages -|---|---|---Index.ets // 首页 -|---|---|---FitPageContent.ets -|---|---|---RenderMode.ets -|---resources // 静态资源 -|---ohosTest -|---|---ets -|---|---|---tests -|---|---|---|---Ability.test.ets // 自动化测试用例 -``` - -## 相关权限 - -[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) - -## 依赖 - -不涉及。 - -## 约束与限制 - -1. 本示例仅支持标准系统上运行,支持设备:RK3568。 -2. 本示例支持API14版本SDK,SDK版本号(API Version 14 Release)。 -3. 本示例需要使用DevEco Studio 版本号(5.0.1Release)才可编译运行。 - -## 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/ArkWeb/WebRenderLayout > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# Web组件渲染模式 + +## RenderMode + +### 介绍 + +1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-render-mode.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。 + +### 效果预览 + +| 主页 | +| ------------------------------------------------------------ | +| | + +使用说明 + +1. 使用renderMode设置渲染模式为 ASYNC_RENDER (同步渲染模式)。 +# Web组件大小自适应页面内容布局 + +## FitPageContent + +### 介绍 + +1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-fit-content.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。 + +### 效果预览 + +| 主页 | +| --------------------------------------------------------- | +| | + +使用说明 + +1. 使用Web组件大小自适应页面内容布局模式layoutMode(WebLayoutMode.FIT_CONTENT)时,能使Web组件的大小根据页面内容自适应变化。 + +## 工程目录 + +``` +entry/src/main/ +|---ets +|---|---entryability +|---|---|---EntryAbility.ets +|---|---pages +|---|---|---Index.ets // 首页 +|---|---|---FitPageContent.ets +|---|---|---RenderMode.ets +|---resources // 静态资源 +|---ohosTest +|---|---ets +|---|---|---tests +|---|---|---|---Ability.test.ets // 自动化测试用例 +``` + +## 相关权限 + +[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) + +## 依赖 + +不涉及。 + +## 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:RK3568。 +2. 本示例支持API14版本SDK,SDK版本号(API Version 14 Release)。 +3. 本示例需要使用DevEco Studio 版本号(5.0.1Release)才可编译运行。 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkWeb/WebRenderLayout > .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/ArkWeb/WebRenderLayout/build-profile.json5 b/code/DocsSample/ArkWeb/WebRenderLayout/build-profile.json5 old mode 100755 new mode 100644 index 87d40a385e..7a9c78377e --- a/code/DocsSample/ArkWeb/WebRenderLayout/build-profile.json5 +++ b/code/DocsSample/ArkWeb/WebRenderLayout/build-profile.json5 @@ -1,52 +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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 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/ArkWeb/WebRenderLayout/code-linter.json5 b/code/DocsSample/ArkWeb/WebRenderLayout/code-linter.json5 old mode 100755 new mode 100644 index 9deb980763..28586467ee --- a/code/DocsSample/ArkWeb/WebRenderLayout/code-linter.json5 +++ b/code/DocsSample/ArkWeb/WebRenderLayout/code-linter.json5 @@ -1,35 +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. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/.gitignore b/code/DocsSample/ArkWeb/WebRenderLayout/entry/.gitignore old mode 100755 new mode 100644 index 32abf8fd5e..e2713a2779 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/.gitignore +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/.gitignore @@ -1,6 +1,6 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx +/node_modules +/oh_modules +/.preview +/build +/.cxx /.test \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/build-profile.json5 b/code/DocsSample/ArkWeb/WebRenderLayout/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/build-profile.json5 +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/WebRenderLayout/entry/hvigorfile.ts old mode 100755 new mode 100644 index c9362b128e..98d52319cb --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/hvigorfile.ts +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/hvigorfile.ts @@ -1,21 +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. */ -} +/* +* 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/ArkWeb/WebRenderLayout/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/WebRenderLayout/entry/obfuscation-rules.txt old mode 100755 new mode 100644 index 5ff2b5d0b0..272efb6ca3 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/obfuscation-rules.txt +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/obfuscation-rules.txt @@ -1,23 +1,23 @@ -# Define project specific obfuscation rules here. -# You can include the obfuscation configuration files in the current module's build-profile.json5. -# -# For more details, see -# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 - -# Obfuscation options: -# -disable-obfuscation: disable all obfuscations -# -enable-property-obfuscation: obfuscate the property names -# -enable-toplevel-obfuscation: obfuscate the names in the global scope -# -compact: remove unnecessary blank spaces and all line feeds -# -remove-log: remove all console.* statements -# -print-namecache: print the name cache that contains the mapping from the old names to new names -# -apply-namecache: reuse the given cache file - -# Keep options: -# -keep-property-name: specifies property names that you want to keep -# -keep-global-name: specifies names that you want to keep in the global scope - --enable-property-obfuscation --enable-toplevel-obfuscation --enable-filename-obfuscation +# 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/ArkWeb/WebRenderLayout/entry/oh-package.json5 b/code/DocsSample/ArkWeb/WebRenderLayout/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/oh-package.json5 +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/ArkWeb/WebRenderLayout/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b23d2fe946..0f2f8b94aa --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/FitPageContent.ets b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/FitPageContent.ets old mode 100755 new mode 100644 index 99001f5aaa..540e3cb7c6 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/FitPageContent.ets +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/FitPageContent.ets @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start a_page_that_contains_a_webview_and_text_in_the_comment_section] -import { webview } from '@kit.ArkWeb'; - -@Entry -@Component -struct WebHeightPage { - private webviewController: WebviewController = new webview.WebviewController(); - private scroller: Scroller = new Scroller(); - - build() { - Navigation() { - Column() { - Scroll(this.scroller) { - Column() { - Web({ - src: $rawfile('fit_content.html'), - controller: this.webviewController, - renderMode: RenderMode.SYNC_RENDER // 设置为同步渲染模式 - }) - .layoutMode(WebLayoutMode.FIT_CONTENT)// 设置为Web组件大小自适应页面内容 - .overScrollMode(OverScrollMode.NEVER) // 设置过滚动模式为关闭状态 - Text($r('app.string.Comment_area')) - .fontSize(28) - .fontColor('#FF0F0F') - .height(100) - .width('100%') - .backgroundColor('#f89f0f') - } - } - } - } - .title($r('app.string.Title_bar')) - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start a_page_that_contains_a_webview_and_text_in_the_comment_section] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebHeightPage { + private webviewController: WebviewController = new webview.WebviewController(); + private scroller: Scroller = new Scroller(); + + build() { + Navigation() { + Column() { + Scroll(this.scroller) { + Column() { + Web({ + src: $rawfile('fit_content.html'), + controller: this.webviewController, + renderMode: RenderMode.SYNC_RENDER // 设置为同步渲染模式 + }) + .layoutMode(WebLayoutMode.FIT_CONTENT)// 设置为Web组件大小自适应页面内容 + .overScrollMode(OverScrollMode.NEVER) // 设置过滚动模式为关闭状态 + Text($r('app.string.Comment_area')) + .fontSize(28) + .fontColor('#FF0F0F') + .height(100) + .width('100%') + .backgroundColor('#f89f0f') + } + } + } + } + .title($r('app.string.Title_bar')) + } +} // [End a_page_that_contains_a_webview_and_text_in_the_comment_section] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 1092ee0ead..df919e917f --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/Index.ets @@ -1,35 +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. - */ - -import { router } from '@kit.ArkUI'; -import { webview } from '@kit.ArkWeb'; - -@Entry -@Component -struct Index { - build() { - Column({ space: 10 }) { - Button('RenderMode') - .onClick(() => { - router.pushUrl({ url: 'pages/RenderMode' }); - }) - Button('FitPageContent') - .onClick(() => { - router.pushUrl({ url: 'pages/FitPageContent' }); - }) - }.height('100%') - .width('100%') - } +/* + * 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 { router } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('RenderMode') + .onClick(() => { + router.pushUrl({ url: 'pages/RenderMode' }); + }) + Button('FitPageContent') + .onClick(() => { + router.pushUrl({ url: 'pages/FitPageContent' }); + }) + }.height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/RenderMode.ets b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/RenderMode.ets old mode 100755 new mode 100644 index 780f6e8d2e..fa5b59c771 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/RenderMode.ets +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/ets/pages/RenderMode.ets @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start web_component_rendering_mode] -import { webview } from '@kit.ArkWeb'; - -@Entry -@Component -struct WebHeightPage { - private webviewController: WebviewController = new webview.WebviewController() - - build() { - Column() { - Web({ - src: 'www.example.com', - controller: this.webviewController, - renderMode: RenderMode.ASYNC_RENDER // 设置渲染模式 - }) - } - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start web_component_rendering_mode] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebHeightPage { + private webviewController: WebviewController = new webview.WebviewController() + + build() { + Column() { + Web({ + src: 'www.example.com', + controller: this.webviewController, + renderMode: RenderMode.ASYNC_RENDER // 设置渲染模式 + }) + } + } +} // [End web_component_rendering_mode] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/module.json5 old mode 100755 new mode 100644 index 81751d0bc4..e9db80c0ac --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index f23e751204..6e797f7e8e --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/element/string.json +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/element/string.json @@ -1,24 +1,24 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "WebRenderLayout" - }, - { - "name": "Title_bar", - "value": "标题栏" - }, - { - "name": "Comment_area", - "value": "评论区" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "WebRenderLayout" + }, + { + "name": "Title_bar", + "value": "标题栏" + }, + { + "name": "Comment_area", + "value": "评论区" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 index 16cf3219a2..fb49920440 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/layered_image.json +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/layered_image.json @@ -1,7 +1,7 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 448826afad..a632b71f19 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/profile/main_pages.json +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/base/profile/main_pages.json @@ -1,7 +1,7 @@ -{ - "src": [ - "pages/Index", - "pages/FitPageContent", - "pages/RenderMode" - ] -} +{ + "src": [ + "pages/Index", + "pages/FitPageContent", + "pages/RenderMode" + ] +} diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 index 28c2ed941a..f618771a19 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/en_US/element/string.json +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/en_US/element/string.json @@ -1,16 +1,16 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "WebRenderLayout" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "WebRenderLayout" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/rawfile/fit_content.html b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/rawfile/fit_content.html old mode 100755 new mode 100644 index ff8af6e0c9..46c149ed86 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/rawfile/fit_content.html +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/rawfile/fit_content.html @@ -1,63 +1,63 @@ - - - - - - - - Fit-Content - - -
-

使用场景

-

ArkWeb(方舟Web)提供了Web组件,用于在应用程序中显示Web页面内容。常见使用场景包括:

-
    -
  • - 应用集成Web页面:应用可以在页面中使用Web组件,嵌入Web页面内容,以降低开发成本,提升开发、运营效率。

    -
  • -
  • - 浏览器网页浏览场景:浏览器类应用可以使用Web组件,打开三方网页,使用无痕模式浏览Web页面,设置广告拦截等。

    -
  • -
  • 小程序:小程序类宿主应用可以使用Web组件,渲染小程序的页面。

  • -
-
-

能力范围

-

Web组件为开发者提供了丰富的控制Web页面能力。包括:

-
    -
  • Web页面加载:声明式加载Web页面和离屏加载Web页面等。

  • -
  • 生命周期管理:组件生命周期状态变化,通知Web页面的加载状态变化等。

  • -
  • 常用属性与事件:UserAgent管理、Cookie与存储管理、字体与深色模式管理、权限管理等。

    -
  • -
  • - 与应用界面交互:自定义文本选择菜单、上下文菜单、文件上传界面等与应用界面交互能力。

    -
  • -
  • App通过JavaScriptProxy,与Web页面进行JavaScript交互。

  • -
  • 安全与隐私:无痕浏览模式、广告拦截、坚盾守护模式等。

  • -
  • 维测能力:DevTools工具调试能力,使用crashpad收集Web组件崩溃信息。 -

  • -
  • - 其他高阶能力:与原生组件同层渲染、Web组件的网络托管、Web组件的媒体播放托管、Web组件输入框拉起自定义输入法、等。

    -
  • -
-
-

约束与限制

-
    -
  • Web内核版本:ArkWeb基于谷歌Chromium内核开发,使用的Chromium版本为M114。
  • -
-
-
- - + + + + + + + + Fit-Content + + +
+

使用场景

+

ArkWeb(方舟Web)提供了Web组件,用于在应用程序中显示Web页面内容。常见使用场景包括:

+
    +
  • + 应用集成Web页面:应用可以在页面中使用Web组件,嵌入Web页面内容,以降低开发成本,提升开发、运营效率。

    +
  • +
  • + 浏览器网页浏览场景:浏览器类应用可以使用Web组件,打开三方网页,使用无痕模式浏览Web页面,设置广告拦截等。

    +
  • +
  • 小程序:小程序类宿主应用可以使用Web组件,渲染小程序的页面。

  • +
+
+

能力范围

+

Web组件为开发者提供了丰富的控制Web页面能力。包括:

+
    +
  • Web页面加载:声明式加载Web页面和离屏加载Web页面等。

  • +
  • 生命周期管理:组件生命周期状态变化,通知Web页面的加载状态变化等。

  • +
  • 常用属性与事件:UserAgent管理、Cookie与存储管理、字体与深色模式管理、权限管理等。

    +
  • +
  • + 与应用界面交互:自定义文本选择菜单、上下文菜单、文件上传界面等与应用界面交互能力。

    +
  • +
  • App通过JavaScriptProxy,与Web页面进行JavaScript交互。

  • +
  • 安全与隐私:无痕浏览模式、广告拦截、坚盾守护模式等。

  • +
  • 维测能力:DevTools工具调试能力,使用crashpad收集Web组件崩溃信息。 +

  • +
  • + 其他高阶能力:与原生组件同层渲染、Web组件的网络托管、Web组件的媒体播放托管、Web组件输入框拉起自定义输入法、等。

    +
  • +
+
+

约束与限制

+
    +
  • Web内核版本:ArkWeb基于谷歌Chromium内核开发,使用的Chromium版本为M114。
  • +
+
+
+ + diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 index 1e50186edc..8b827c36ef --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/zh_CN/element/string.json +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/main/resources/zh_CN/element/string.json @@ -1,16 +1,16 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "模块描述" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "WebRenderLayout" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "WebRenderLayout" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 index aba5ed077b..b9a78e2015 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/mock/mock-config.json5 +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/mock/mock-config.json5 @@ -1,17 +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. - */ - -{ +/* + * 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/ArkWeb/WebRenderLayout/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 index 136bd3e551..1375e7a47e --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,97 +1,97 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -export default function abilityTest() { - describe('ActsAbilityTest', () => { - // Defines a test suite. Two parameters are supported: test suite name and test suite function. - beforeAll(() => { - // Presets an action, which is performed only once before all test cases of the test suite start. - // This API supports only one parameter: preset action function. - }) - beforeEach(() => { - // Presets an action, which is performed before each unit test case starts. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: preset action function. - }) - afterEach(() => { - // Presets a clear action, which is performed after each unit test case ends. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: clear action function. - }) - afterAll(() => { - // Presets a clear action, which is performed after all test cases of the test suite end. - // This API supports only one parameter: clear action function. - }) - - /* - * 打开应用,点击 RenderMode 按钮 - * 使用renderMode设置渲染模式为同步渲染模式 - */ - it('RenderMode',0, async (done: Function) => { - console.info('uitest: RenderMode begin'); - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - await driver.delayMs(5000); - - const button1 = await driver.findComponent(ON.text('RenderMode')); - await button1.click(); - await driver.delayMs(1000); - - const web1 = await driver.findComponent(ON.type('Web')); - let src: string = await web1.getText(); - expect(src).assertContain('www.example.com'); - - await driver.pressBack(); - console.info('uitest: RenderMode end'); - done(); - }); - - /* - * 点击 FitPageContent 按钮 - * 使用Web组件大小自适应页面内容布局模式使Web组件的大小根据页面内容自适应变化 - */ - it('FitPageContent',0, async (done: Function) => { - console.info('uitest: FitPageContent begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - - const button1 = await driver.findComponent(ON.text('FitPageContent')); - await button1.click(); - await driver.delayMs(1000); - - const web1 = await driver.findComponent(ON.type('Web')); - let src: string = await web1.getText(); - expect(src).assertContain('fit_content.html'); - - await driver.pressBack(); - console.info('uitest: FitPageContent end'); - done(); - }); - }) -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + + /* + * 打开应用,点击 RenderMode 按钮 + * 使用renderMode设置渲染模式为同步渲染模式 + */ + it('RenderMode',0, async (done: Function) => { + console.info('uitest: RenderMode begin'); + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + await driver.delayMs(5000); + + const button1 = await driver.findComponent(ON.text('RenderMode')); + await button1.click(); + await driver.delayMs(1000); + + const web1 = await driver.findComponent(ON.type('Web')); + let src: string = await web1.getText(); + expect(src).assertContain('www.example.com'); + + await driver.pressBack(); + console.info('uitest: RenderMode end'); + done(); + }); + + /* + * 点击 FitPageContent 按钮 + * 使用Web组件大小自适应页面内容布局模式使Web组件的大小根据页面内容自适应变化 + */ + it('FitPageContent',0, async (done: Function) => { + console.info('uitest: FitPageContent begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + + const button1 = await driver.findComponent(ON.text('FitPageContent')); + await button1.click(); + await driver.delayMs(1000); + + const web1 = await driver.findComponent(ON.type('Web')); + let src: string = await web1.getText(); + expect(src).assertContain('fit_content.html'); + + await driver.pressBack(); + console.info('uitest: FitPageContent end'); + done(); + }); + }) +} diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 index a10a79ed1d..1eac52fceb --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/ets/test/List.test.ets +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/ets/test/List.test.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/test/List.test.ets old mode 100755 new mode 100644 index 234f7bd3c7..f1186b1f53 --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/test/List.test.ets +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/test/List.test.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import localUnitTest from './LocalUnit.test'; - -export default function testsuite() { - localUnitTest(); +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 index 05912c780d..7fc57c77db --- a/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/test/LocalUnit.test.ets +++ b/code/DocsSample/ArkWeb/WebRenderLayout/entry/src/test/LocalUnit.test.ets @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; - -export default function localUnitTest() { - describe('localUnitTest', () => { - // Defines a test suite. Two parameters are supported: test suite name and test suite function. - beforeAll(() => { - // Presets an action, which is performed only once before all test cases of the test suite start. - // This API supports only one parameter: preset action function. - }); - beforeEach(() => { - // Presets an action, which is performed before each unit test case starts. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: preset action function. - }); - afterEach(() => { - // Presets a clear action, which is performed after each unit test case ends. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: clear action function. - }); - afterAll(() => { - // Presets a clear action, which is performed after all test cases of the test suite end. - // This API supports only one parameter: clear action function. - }); - it('assertContain', 0, () => { - // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. - let a = 'abc'; - let b = 'b'; - // Defines a variety of assertion methods, which are used to declare expected boolean conditions. - expect(a).assertContain(b); - expect(a).assertEqual(a); - }); - }); +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/WebRenderLayout/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index c61d3eed60..43beb743cb --- a/code/DocsSample/ArkWeb/WebRenderLayout/hvigor/hvigor-config.json5 +++ b/code/DocsSample/ArkWeb/WebRenderLayout/hvigor/hvigor-config.json5 @@ -1,37 +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*/ - } -} +/* + * 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/ArkWeb/WebRenderLayout/hvigorfile.ts b/code/DocsSample/ArkWeb/WebRenderLayout/hvigorfile.ts old mode 100755 new mode 100644 index f82b71dd9d..1307c03303 --- a/code/DocsSample/ArkWeb/WebRenderLayout/hvigorfile.ts +++ b/code/DocsSample/ArkWeb/WebRenderLayout/hvigorfile.ts @@ -1,21 +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. */ -} +/* +* 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/ArkWeb/WebRenderLayout/oh-package.json5 b/code/DocsSample/ArkWeb/WebRenderLayout/oh-package.json5 old mode 100755 new mode 100644 index 4c8bad9bdb..93f097993a --- a/code/DocsSample/ArkWeb/WebRenderLayout/oh-package.json5 +++ b/code/DocsSample/ArkWeb/WebRenderLayout/oh-package.json5 @@ -1,25 +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.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/ohosTest.md b/code/DocsSample/ArkWeb/WebRenderLayout/ohosTest.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/screenshots/FitPageContent.png b/code/DocsSample/ArkWeb/WebRenderLayout/screenshots/FitPageContent.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/ArkWeb/WebRenderLayout/screenshots/RenderModeWebComp.png b/code/DocsSample/ArkWeb/WebRenderLayout/screenshots/RenderModeWebComp.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/AppScope/app.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/AppScope/app.json5 index da5f910f00..50601e9feb 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/AppScope/app.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.harsample", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.harsample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/AppScope/resources/base/element/string.json b/code/DocsSample/BundleManagerDocsSample/HarSample/AppScope/resources/base/element/string.json index 0f9315e137..6b9925cc18 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/AppScope/resources/base/element/string.json +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "HarSample" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "HarSample" + } + ] +} diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/build-profile.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/build-profile.json5 index d2571bfa54..480c508183 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/build-profile.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/build-profile.json5 @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "library", - "srcPath": "./library" - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "library", + "srcPath": "./library" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/build-profile.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/build-profile.json5 index 0c8525dfdd..910cc991f5 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/build-profile.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/oh-package.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/oh-package.json5 index 45159edb79..c8286b9e1d 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/oh-package.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": { - "library": "file:../library" - } -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": { + "library": "file:../library" + } +} diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/ets/entryability/EntryAbility.ts index 714d4b5563..964a26f869 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import window from '@ohos.window'; -import Logger from '../logger/Logger'; - -const TAG = 'EntryAbility'; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - Logger.info(TAG, `Ability onCreate want: ${JSON.stringify(want)}`, `launchParam: ${JSON.stringify(launchParam)}`); - } - - onDestroy() { - Logger.info(TAG, 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - Logger.info(TAG, 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - Logger.error(TAG, `Failed to load the content. Cause: ${JSON.stringify(err)}`); - return; - } - Logger.info(TAG, `Succeeded in loading the content. Data: ${JSON.stringify(data)}`); - }); - } - - onWindowStageDestroy() { - Logger.info(TAG, 'Ability onWindowStageDestroy'); - } - - onForeground() { - Logger.info(TAG, 'Ability onForeground'); - } - - onBackground() { - Logger.info(TAG, 'Ability onBackground'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; +import Logger from '../logger/Logger'; + +const TAG = 'EntryAbility'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + Logger.info(TAG, `Ability onCreate want: ${JSON.stringify(want)}`, `launchParam: ${JSON.stringify(launchParam)}`); + } + + onDestroy() { + Logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + Logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error(TAG, `Failed to load the content. Cause: ${JSON.stringify(err)}`); + return; + } + Logger.info(TAG, `Succeeded in loading the content. Data: ${JSON.stringify(data)}`); + }); + } + + onWindowStageDestroy() { + Logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground() { + Logger.info(TAG, 'Ability onForeground'); + } + + onBackground() { + Logger.info(TAG, 'Ability onBackground'); + } +} diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/ets/logger/Logger.ts b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/ets/logger/Logger.ts index 6801aa8031..c973e6b266 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/ets/logger/Logger.ts +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/ets/logger/Logger.ts @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -export class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } - - fatal(...args: string[]): void { - hilog.fatal(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +export class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } + + fatal(...args: string[]): void { + hilog.fatal(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_HarSample]'); \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/module.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/module.json5 index a61f5cbf7c..bac72d9592 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/module.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 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" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/resources/base/element/color.json b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/resources/base/element/color.json index 5682f26b17..20bf6d89a9 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/main/resources/base/element/color.json @@ -1,20 +1,20 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "page_background", - "value": "#F1F3F5" - }, - { - "name": "button_background", - "value": "#007DFF" - }, - { - "name": "text_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "page_background", + "value": "#F1F3F5" + }, + { + "name": "button_background", + "value": "#007DFF" + }, + { + "name": "text_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/ohosTest/ets/logger/Logger.ts b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/ohosTest/ets/logger/Logger.ts index 6f2887b721..59fa81f698 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/ohosTest/ets/logger/Logger.ts +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/ohosTest/ets/logger/Logger.ts @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -export class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } - - fatal(...args: string[]): void { - hilog.fatal(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +export class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } + + fatal(...args: string[]): void { + hilog.fatal(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_HarSample_Test]'); \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/ohosTest/module.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/ohosTest/module.json5 index 0511adbc86..c6ad62fbbd 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/hvigor/hvigor-config.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/hvigor/hvigor-config.json5 index 7fcecec159..dba571014f 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/hvigor/hvigor-config.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/library/build-profile.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/library/build-profile.json5 index e9c00838cf..833db6086e 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/library/build-profile.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/library/build-profile.json5 @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2023-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" - ] - }, - }, - "targets": [ - { - "name": "default" - } - ] -} +/* + * Copyright (c) 2023-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" + ] + }, + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/library/index.ets b/code/DocsSample/BundleManagerDocsSample/HarSample/library/index.ets index 5c2adbf8c4..ab44ac132c 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/library/index.ets +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/library/index.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { MainPage } from './src/main/ets/components/mainpage/MainPage'; -export { Log } from './src/main/ts/test'; -export { func } from './src/main/ts/test'; -export { func2 } from './src/main/ts/test'; +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { MainPage } from './src/main/ets/components/mainpage/MainPage'; +export { Log } from './src/main/ts/test'; +export { func } from './src/main/ts/test'; +export { func2 } from './src/main/ts/test'; export { nativeAdd } from './src/main/ets/utils/nativeTest'; \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/library/oh-package.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/library/oh-package.json5 index d5d81fe8a1..dff32d3a01 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/library/oh-package.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/library/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "Apache-2.0", - "devDependencies": { - "@types/liblibrary.so": "file:./src/main/cpp/types/liblibrary" - }, - "author": "", - "name": "library", - "description": "Please describe the basic information.", - "main": "index.ets", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "Apache-2.0", + "devDependencies": { + "@types/liblibrary.so": "file:./src/main/cpp/types/liblibrary" + }, + "author": "", + "name": "library", + "description": "Please describe the basic information.", + "main": "index.ets", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/cpp/types/liblibrary/index.d.ts b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/cpp/types/liblibrary/index.d.ts index 2dfa9815bf..57d8ff2271 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/cpp/types/liblibrary/index.d.ts +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/cpp/types/liblibrary/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2023 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. - */ - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/cpp/types/liblibrary/oh-package.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/cpp/types/liblibrary/oh-package.json5 index 57886b03cb..e57a824ed9 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/cpp/types/liblibrary/oh-package.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/cpp/types/liblibrary/oh-package.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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": "liblibrary.so", - "types": "./index.d.ts", - "version": "", - "description": "Please describe the basic information." +/* + * Copyright (c) 2023 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": "liblibrary.so", + "types": "./index.d.ts", + "version": "", + "description": "Please describe the basic information." } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ets/components/mainpage/MainPage.ets b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ets/components/mainpage/MainPage.ets index ad83c99ed7..d4b9ea86bd 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ets/components/mainpage/MainPage.ets +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ets/components/mainpage/MainPage.ets @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MainPage { - @State message: string = 'HAR MainPage'; - - build() { - Column() { - Row() { - Text(this.message) - .fontSize(32) - .fontWeight(FontWeight.Bold) - } - .margin({ top: '32px' }) - .width('624px') - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { - Column() { - Image($r('app.media.pic_empty')).width('33%') - Text($r('app.string.empty')) - .fontSize(14) - .fontColor($r('app.color.text_color')) - } - }.width('100%') - .height('90%') - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.page_background')) - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainPage { + @State message: string = 'HAR MainPage'; + + build() { + Column() { + Row() { + Text(this.message) + .fontSize(32) + .fontWeight(FontWeight.Bold) + } + .margin({ top: '32px' }) + .width('624px') + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { + Column() { + Image($r('app.media.pic_empty')).width('33%') + Text($r('app.string.empty')) + .fontSize(14) + .fontColor($r('app.color.text_color')) + } + }.width('100%') + .height('90%') + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.page_background')) + } +} diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ets/utils/nativeTest.ts b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ets/utils/nativeTest.ts index a093a75805..0d3d9a76bf 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ets/utils/nativeTest.ts +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ets/utils/nativeTest.ts @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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 native from 'liblibrary.so'; - -export function nativeAdd(a: number, b: number): number { - let result: number = native.add(a, b); - return result; +/* + * Copyright (c) 2023 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 native from 'liblibrary.so'; + +export function nativeAdd(a: number, b: number): number { + let result: number = native.add(a, b); + return result; } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/module.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/module.json5 index 7fe25c1fa5..85c863fcf2 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/module.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/module.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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": "library", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} +/* + * Copyright (c) 2023 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": "library", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/resources/base/element/color.json b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/resources/base/element/color.json index 5682f26b17..20bf6d89a9 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/resources/base/element/color.json +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/resources/base/element/color.json @@ -1,20 +1,20 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "page_background", - "value": "#F1F3F5" - }, - { - "name": "button_background", - "value": "#007DFF" - }, - { - "name": "text_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "page_background", + "value": "#F1F3F5" + }, + { + "name": "button_background", + "value": "#007DFF" + }, + { + "name": "text_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ts/test.ets b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ts/test.ets index 1109fa5b7f..b3526ba696 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ts/test.ets +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/library/src/main/ts/test.ets @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2023 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 class Log { - static info(msg: string) { - console.info(msg); - } -} - -export function func() { - return 'har func'; -} - -export function func2() { - return 'har func2'; +/* + * Copyright (c) 2023 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 class Log { + static info(msg: string) { + console.info(msg); + } +} + +export function func() { + return 'har func'; +} + +export function func2() { + return 'har func2'; } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HarSample/oh-package.json5 b/code/DocsSample/BundleManagerDocsSample/HarSample/oh-package.json5 index e30539c78b..1dcc15ba8b 100644 --- a/code/DocsSample/BundleManagerDocsSample/HarSample/oh-package.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HarSample/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "harsample", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "harsample", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/AppScope/app.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/AppScope/app.json5 index 1a6671675f..f272e3f7ae 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/AppScope/app.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.hspsample", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.hspsample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/AppScope/resources/base/element/string.json b/code/DocsSample/BundleManagerDocsSample/HspSample/AppScope/resources/base/element/string.json index ec33d38a52..03637f7821 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/AppScope/resources/base/element/string.json +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "HspSample" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "HspSample" + } + ] +} diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/build-profile.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/build-profile.json5 index fe8c14b574..d45be4b132 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/build-profile.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/build-profile.json5 @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "library", - "srcPath": "./library", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "library", + "srcPath": "./library", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/build-profile.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/build-profile.json5 index 0c8525dfdd..910cc991f5 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/build-profile.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/oh-package.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/oh-package.json5 index 45159edb79..c8286b9e1d 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/oh-package.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": { - "library": "file:../library" - } -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": { + "library": "file:../library" + } +} diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/ets/entryability/EntryAbility.ts index 714d4b5563..964a26f869 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import window from '@ohos.window'; -import Logger from '../logger/Logger'; - -const TAG = 'EntryAbility'; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - Logger.info(TAG, `Ability onCreate want: ${JSON.stringify(want)}`, `launchParam: ${JSON.stringify(launchParam)}`); - } - - onDestroy() { - Logger.info(TAG, 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - Logger.info(TAG, 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - Logger.error(TAG, `Failed to load the content. Cause: ${JSON.stringify(err)}`); - return; - } - Logger.info(TAG, `Succeeded in loading the content. Data: ${JSON.stringify(data)}`); - }); - } - - onWindowStageDestroy() { - Logger.info(TAG, 'Ability onWindowStageDestroy'); - } - - onForeground() { - Logger.info(TAG, 'Ability onForeground'); - } - - onBackground() { - Logger.info(TAG, 'Ability onBackground'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; +import Logger from '../logger/Logger'; + +const TAG = 'EntryAbility'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + Logger.info(TAG, `Ability onCreate want: ${JSON.stringify(want)}`, `launchParam: ${JSON.stringify(launchParam)}`); + } + + onDestroy() { + Logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + Logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error(TAG, `Failed to load the content. Cause: ${JSON.stringify(err)}`); + return; + } + Logger.info(TAG, `Succeeded in loading the content. Data: ${JSON.stringify(data)}`); + }); + } + + onWindowStageDestroy() { + Logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground() { + Logger.info(TAG, 'Ability onForeground'); + } + + onBackground() { + Logger.info(TAG, 'Ability onBackground'); + } +} diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/ets/logger/Logger.ts b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/ets/logger/Logger.ts index 0d85adbb7f..ed0cb54fe7 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/ets/logger/Logger.ts +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/ets/logger/Logger.ts @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -export class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } - - fatal(...args: string[]): void { - hilog.fatal(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +export class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } + + fatal(...args: string[]): void { + hilog.fatal(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_HSP]'); \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/module.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/module.json5 index a61f5cbf7c..bac72d9592 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/module.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 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" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/resources/base/element/color.json b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/resources/base/element/color.json index 6483db0e0b..0d7a675936 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/main/resources/base/element/color.json @@ -1,24 +1,24 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "text_color", - "value": "#182431" - }, - { - "name": "button_background", - "value": "#007DFF" - }, - { - "name": "page_background", - "value": "#F1F3F5" - }, - { - "name": "backGrounding", - "value": "#f1f3f5" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "text_color", + "value": "#182431" + }, + { + "name": "button_background", + "value": "#007DFF" + }, + { + "name": "page_background", + "value": "#F1F3F5" + }, + { + "name": "backGrounding", + "value": "#f1f3f5" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/ohosTest/ets/logger/Logger.ts b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/ohosTest/ets/logger/Logger.ts index 7bf60678fe..46fc9ccb32 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/ohosTest/ets/logger/Logger.ts +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/ohosTest/ets/logger/Logger.ts @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -export class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } - - fatal(...args: string[]): void { - hilog.fatal(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +export class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } + + fatal(...args: string[]): void { + hilog.fatal(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_HspSample_Test]'); \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/ohosTest/module.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/ohosTest/module.json5 index 0511adbc86..c6ad62fbbd 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/hvigor/hvigor-config.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/hvigor/hvigor-config.json5 index fb29482d10..9a79085076 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/hvigor/hvigor-config.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/build-profile.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/library/build-profile.json5 index afdd327d9b..be7ab69a42 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/build-profile.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/build-profile.json5 @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2023 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": "" - }, - }, - "targets": [ - { - "name": "default" - } - ] +/* + * Copyright (c) 2023 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": "" + }, + }, + "targets": [ + { + "name": "default" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/oh-package.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/library/oh-package.json5 index 5fc598646d..c18e5c2879 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/oh-package.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "Apache-2.0", - "devDependencies": { - "@types/liblibrary.so": "file:./src/main/cpp/types/liblibrary" - }, - "author": "", - "name": "library", - "description": "Please describe the basic information.", - "main": "./src/main/ets/Index.ets", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "Apache-2.0", + "devDependencies": { + "@types/liblibrary.so": "file:./src/main/cpp/types/liblibrary" + }, + "author": "", + "name": "library", + "description": "Please describe the basic information.", + "main": "./src/main/ets/Index.ets", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/cpp/types/liblibrary/index.d.ts b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/cpp/types/liblibrary/index.d.ts index 0f453034d2..aaa16bac9a 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/cpp/types/liblibrary/index.d.ts +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/cpp/types/liblibrary/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2023 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. - */ - +/* + * Copyright (c) 2023 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 multi: (a: number, b: number) => number; \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/cpp/types/liblibrary/oh-package.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/cpp/types/liblibrary/oh-package.json5 index d865f17539..c0b9370721 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/cpp/types/liblibrary/oh-package.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/cpp/types/liblibrary/oh-package.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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": "libibrary.so", - "types": "./index.d.ts", - "version": "", - "description": "Please describe the basic information." +/* + * Copyright (c) 2023 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": "libibrary.so", + "types": "./index.d.ts", + "version": "", + "description": "Please describe the basic information." } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/Index.ets b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/Index.ets index adbf4d90f7..1bee7e514a 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/Index.ets +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/Index.ets @@ -1,19 +1,19 @@ -/* - * Copyright (c) 2023 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 { Log, add, minus } from './utils/test'; -export { MyTitleBar } from './components/MyTitleBar'; -export { ResManager } from './ResManager'; +/* + * Copyright (c) 2023 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 { Log, add, minus } from './utils/test'; +export { MyTitleBar } from './components/MyTitleBar'; +export { ResManager } from './ResManager'; export { nativeMulti } from './utils/nativeTest'; \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/ResManager.ets b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/ResManager.ets index aaeef4e50d..83492c54e3 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/ResManager.ets +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/ResManager.ets @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2023 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 class ResManager{ - static getPic(): Resource{ - return $r('app.media.pic'); - } - static getDesc(): Resource{ - return $r('app.string.shared_desc'); - } +/* + * Copyright (c) 2023 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 class ResManager{ + static getPic(): Resource{ + return $r('app.media.pic'); + } + static getDesc(): Resource{ + return $r('app.string.shared_desc'); + } } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/components/MyTitleBar.ets b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/components/MyTitleBar.ets index 1b5139d3ca..248d99a0d6 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/components/MyTitleBar.ets +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/components/MyTitleBar.ets @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct MyTitleBar { - build() { - Row() { - Text($r('app.string.library_title')) - .id('library') - .fontFamily('HarmonyHeiTi') - .fontWeight(FontWeight.Bold) - .fontSize(32) - .fontWeight(700) - .fontColor($r('app.color.text_color')) - } - .width('100%') - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MyTitleBar { + build() { + Row() { + Text($r('app.string.library_title')) + .id('library') + .fontFamily('HarmonyHeiTi') + .fontWeight(FontWeight.Bold) + .fontSize(32) + .fontWeight(700) + .fontColor($r('app.color.text_color')) + } + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/pages/Back.ets b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/pages/Back.ets index c5b772379c..e35f7348c2 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/pages/Back.ets +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/pages/Back.ets @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router'; - -@Entry -@Component -struct Index3 { // 路径为:`library/src/main/ets/pages/Back.ets - @State message: string = 'HSP back page'; - - build() { - Row() { - Column() { - Text(this.message) - .fontFamily('HarmonyHeiTi') - .fontWeight(FontWeight.Bold) - .fontSize(32) - .fontWeight(700) - .fontColor($r('app.color.text_color')) - .margin({ top: '32px' }) - .width('624px') - - Button($r('app.string.back_to_HAP')) - .id('backToHAP') - .fontFamily('HarmonyHeiTi') - .height(48) - .width('624px') - .margin({ top: 550 }) - .type(ButtonType.Capsule) - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('app.color.button_background')) - .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - // 绑定点击事件 - .onClick(() => { - router.back({ // 返回HAP的页面 - url: 'pages/Index' // 路径为:`entry/src/main/ets/pages/Index.ets` - }) - }) - - Button($r('app.string.back_to_HSP')) - .id('backToHSP') - .fontFamily('HarmonyHeiTi') - .height(48) - .width('624px') - .margin({ top: '4%' , bottom: '6%' }) - .type(ButtonType.Capsule) - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('app.color.button_background')) - .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - // 绑定点击事件 - .onClick(() => { - router.back({ // 返回HSP的页面 - url: '@bundle:com.samples.hspsample/library/ets/pages/Menu' //路径为:`library/src/main/ets/pages/Menu.ets - }) - }) - } - .width('100%') - } - .backgroundColor($r('app.color.page_background')) - .height('100%') - } +/* + * Copyright (c) 2023 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 router from '@ohos.router'; + +@Entry +@Component +struct Index3 { // 路径为:`library/src/main/ets/pages/Back.ets + @State message: string = 'HSP back page'; + + build() { + Row() { + Column() { + Text(this.message) + .fontFamily('HarmonyHeiTi') + .fontWeight(FontWeight.Bold) + .fontSize(32) + .fontWeight(700) + .fontColor($r('app.color.text_color')) + .margin({ top: '32px' }) + .width('624px') + + Button($r('app.string.back_to_HAP')) + .id('backToHAP') + .fontFamily('HarmonyHeiTi') + .height(48) + .width('624px') + .margin({ top: 550 }) + .type(ButtonType.Capsule) + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('app.color.button_background')) + .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + // 绑定点击事件 + .onClick(() => { + router.back({ // 返回HAP的页面 + url: 'pages/Index' // 路径为:`entry/src/main/ets/pages/Index.ets` + }) + }) + + Button($r('app.string.back_to_HSP')) + .id('backToHSP') + .fontFamily('HarmonyHeiTi') + .height(48) + .width('624px') + .margin({ top: '4%' , bottom: '6%' }) + .type(ButtonType.Capsule) + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('app.color.button_background')) + .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + // 绑定点击事件 + .onClick(() => { + router.back({ // 返回HSP的页面 + url: '@bundle:com.samples.hspsample/library/ets/pages/Menu' //路径为:`library/src/main/ets/pages/Menu.ets + }) + }) + } + .width('100%') + } + .backgroundColor($r('app.color.page_background')) + .height('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/pages/Menu.ets b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/pages/Menu.ets index cf2a096fba..c23e9b016d 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/pages/Menu.ets +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/pages/Menu.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router'; - -@Entry -@Component -struct MenuIndex { - @State message: string = 'HSP menu page'; - - build() { - Column() { - Text(this.message) - .fontFamily('HarmonyHeiTi') - .fontWeight(FontWeight.Bold) - .fontSize(32) - .fontWeight(700) - .fontColor($r('app.color.text_color')) - .margin({ top: '32px' }) - .width('624px') - - Button($r('app.string.router_to_HSP')) - .id('menuToBack') - .fontFamily('HarmonyHeiTi') - .height(48) - .width('624px') - .margin({ top: 620, bottom: '6%' }) - .type(ButtonType.Capsule) - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('app.color.button_background')) - .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - // 绑定点击事件 - .onClick(() => { - router.pushUrl({ - url: '@bundle:com.samples.hspsample/library/ets/pages/Back' - }) - }) - } - .width('100%') - .backgroundColor($r('app.color.page_background')) - .height('100%') - } +/* + * Copyright (c) 2023 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 router from '@ohos.router'; + +@Entry +@Component +struct MenuIndex { + @State message: string = 'HSP menu page'; + + build() { + Column() { + Text(this.message) + .fontFamily('HarmonyHeiTi') + .fontWeight(FontWeight.Bold) + .fontSize(32) + .fontWeight(700) + .fontColor($r('app.color.text_color')) + .margin({ top: '32px' }) + .width('624px') + + Button($r('app.string.router_to_HSP')) + .id('menuToBack') + .fontFamily('HarmonyHeiTi') + .height(48) + .width('624px') + .margin({ top: 620, bottom: '6%' }) + .type(ButtonType.Capsule) + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('app.color.button_background')) + .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + // 绑定点击事件 + .onClick(() => { + router.pushUrl({ + url: '@bundle:com.samples.hspsample/library/ets/pages/Back' + }) + }) + } + .width('100%') + .backgroundColor($r('app.color.page_background')) + .height('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/utils/nativeTest.ts b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/utils/nativeTest.ts index a012ec0c3e..3589c82009 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/utils/nativeTest.ts +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/ets/utils/nativeTest.ts @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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 native from 'liblibrary.so'; - -export function nativeMulti(a: number, b: number): number { - let result: number = native.multi(a, b); - return result; +/* + * Copyright (c) 2023 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 native from 'liblibrary.so'; + +export function nativeMulti(a: number, b: number): number { + let result: number = native.multi(a, b); + return result; } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/module.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/module.json5 index 2721df92cb..d35a7ca8ba 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/module.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/module.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2023 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": "library", - "type": "shared", - "description": "$string:shared_desc", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" - } +/* + * Copyright (c) 2023 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": "library", + "type": "shared", + "description": "$string:shared_desc", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "pages": "$profile:main_pages" + } } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/resources/base/element/string.json b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/resources/base/element/string.json index e1e8dfcf67..3e455ad20b 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/resources/base/element/string.json +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/library/src/main/resources/base/element/string.json @@ -1,24 +1,24 @@ -{ - "string": [ - { - "name": "shared_desc", - "value": "shared" - }, - { - "name": "library_title", - "value": "library" - }, - { - "name": "back_to_HAP", - "value": "back to HAP page" - }, - { - "name": "back_to_HSP", - "value": "back to HSP page" - }, - { - "name": "router_to_HSP", - "value": "router to HSP page" - } - ] +{ + "string": [ + { + "name": "shared_desc", + "value": "shared" + }, + { + "name": "library_title", + "value": "library" + }, + { + "name": "back_to_HAP", + "value": "back to HAP page" + }, + { + "name": "back_to_HSP", + "value": "back to HSP page" + }, + { + "name": "router_to_HSP", + "value": "router to HSP page" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/BundleManagerDocsSample/HspSample/oh-package.json5 b/code/DocsSample/BundleManagerDocsSample/HspSample/oh-package.json5 index 70271a7050..f502491723 100644 --- a/code/DocsSample/BundleManagerDocsSample/HspSample/oh-package.json5 +++ b/code/DocsSample/BundleManagerDocsSample/HspSample/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "hspsample", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "hspsample", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/ConnectivityKit/NFC/HCECardSimulationDevelopment/ohosTest.md b/code/DocsSample/ConnectivityKit/NFC/HCECardSimulationDevelopment/ohosTest.md old mode 100755 new mode 100644 index dd30e6501f..8287c8a8cb --- a/code/DocsSample/ConnectivityKit/NFC/HCECardSimulationDevelopment/ohosTest.md +++ b/code/DocsSample/ConnectivityKit/NFC/HCECardSimulationDevelopment/ohosTest.md @@ -1,7 +1,7 @@ -# HCE卡模拟开发示例代码工程化 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------- | ------------ | ----------------- | ------------------------|--------- | -------- | +# HCE卡模拟开发示例代码工程化 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------- | ------------ | ----------------- | ------------------------|--------- | -------- | | NFC功能正常启动 | 设备支持NFC | 启动应用 | 应用停留在启动界面,输出预期日志 |否 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ConnectivityKit/NFC/HCECardSimulationDevelopment/screenshots/image.jpeg b/code/DocsSample/ConnectivityKit/NFC/HCECardSimulationDevelopment/screenshots/image.jpeg old mode 100755 new mode 100644 diff --git a/code/DocsSample/ConnectivityKit/NFC/NFCReadAndWrite/ohosTest.md b/code/DocsSample/ConnectivityKit/NFC/NFCReadAndWrite/ohosTest.md old mode 100755 new mode 100644 index 5813f372f5..4e057f15d2 --- a/code/DocsSample/ConnectivityKit/NFC/NFCReadAndWrite/ohosTest.md +++ b/code/DocsSample/ConnectivityKit/NFC/NFCReadAndWrite/ohosTest.md @@ -1,7 +1,7 @@ -# NFC标签读写示例代码工程化 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------- | ------------ | ----------------- | ------------------------|--------- | -------- | +# NFC标签读写示例代码工程化 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------- | ------------ | ----------------- | ------------------------|--------- | -------- | | NFC功能正常启动 | 设备支持NFC | 启动应用 | 应用停留在启动界面,输出预期日志 |否 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ConnectivityKit/NFC/NFCReadAndWrite/screenshots/image.jpeg b/code/DocsSample/ConnectivityKit/NFC/NFCReadAndWrite/screenshots/image.jpeg old mode 100755 new mode 100644 diff --git a/code/DocsSample/ConnectivityKit/NFC/SecureElement/ohosTest.md b/code/DocsSample/ConnectivityKit/NFC/SecureElement/ohosTest.md old mode 100755 new mode 100644 index dd54c17674..f3c71387de --- a/code/DocsSample/ConnectivityKit/NFC/SecureElement/ohosTest.md +++ b/code/DocsSample/ConnectivityKit/NFC/SecureElement/ohosTest.md @@ -1,7 +1,7 @@ -# 安全单元访问示例代码工程化 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------- | ------------ | ----------------- | ------------------------|--------- | -------- | +# 安全单元访问示例代码工程化 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------- | ------------ | ----------------- | ------------------------|--------- | -------- | | NFC功能正常启动 | 设备支持NFC | 启动应用 | 应用停留在启动界面,输出预期日志 |否 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ConnectivityKit/NFC/SecureElement/screenshots/image.jpeg b/code/DocsSample/ConnectivityKit/NFC/SecureElement/screenshots/image.jpeg old mode 100755 new mode 100644 diff --git a/code/DocsSample/ConnectivityKit/Wlan/ohosTest.md b/code/DocsSample/ConnectivityKit/Wlan/ohosTest.md old mode 100755 new mode 100644 index 8ba91e60bf..e02cd4bf9d --- a/code/DocsSample/ConnectivityKit/Wlan/ohosTest.md +++ b/code/DocsSample/ConnectivityKit/Wlan/ohosTest.md @@ -1,10 +1,10 @@ -# P2P模式开发测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------ | ------------ | ------------------------------ | ------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 |点击运行 | 成功拉起应用 | 否 | Pass | -| 主页点击create group按钮 | 打开WLAN,位于主页 |点击create group按钮 | 主页显示success文字 | 否 | Pass | -| 主页connect按钮点击 | 打开WLAN,点击create group按钮后,位于主页 |点击connect按钮 | 输出预期日志 | 否 | Pass | +# P2P模式开发测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------ | ------------ | ------------------------------ | ------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 |点击运行 | 成功拉起应用 | 否 | Pass | +| 主页点击create group按钮 | 打开WLAN,位于主页 |点击create group按钮 | 主页显示success文字 | 否 | Pass | +| 主页connect按钮点击 | 打开WLAN,点击create group按钮后,位于主页 |点击connect按钮 | 输出预期日志 | 否 | Pass | | 主页delete group按钮点击 | 打开WLAN,点击create group按钮后,位于主页 |点击delete group按钮 | 主页显示的文字被清除 | 否 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_brush.cpp b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_brush.cpp index 0c7191b1a1..a6cf5fb884 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_brush.cpp +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_brush.cpp @@ -1,277 +1,277 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sample_graphics.h" - -void SampleGraphics::DrawBrushBasic(OH_Drawing_Canvas *canvas) -{ - // 创建画刷 - OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); - // 设置填充颜色为红色 - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - // 开启抗锯齿效果 - OH_Drawing_BrushSetAntiAlias(brush, true); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(0, 0, value300_, value300_); - // 绘制矩形1 - OH_Drawing_CanvasDrawRect(canvas, rect1); - OH_Drawing_CanvasDetachBrush(canvas); - // 复制画刷 - OH_Drawing_Brush* brush_copy = OH_Drawing_BrushCopy(brush); - - // 画刷重置 - OH_Drawing_BrushReset(brush); - // 设置透明度 - OH_Drawing_BrushSetAlpha(brush, rgbaHalf_); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(value400_, value400_, value700_, value700_); - // 绘制矩形2 - OH_Drawing_CanvasDrawRect(canvas, rect2); - OH_Drawing_CanvasDetachBrush(canvas); - - OH_Drawing_CanvasAttachBrush(canvas, brush_copy); - OH_Drawing_Rect* rect3 = OH_Drawing_RectCreate(value800_, value800_, value1100_, value1100_); - // 绘制矩形3 - OH_Drawing_CanvasDrawRect(canvas, rect3); - OH_Drawing_CanvasDetachBrush(canvas); - - // 销毁各类对象 - OH_Drawing_BrushDestroy(brush); - OH_Drawing_BrushDestroy(brush_copy); - OH_Drawing_RectDestroy(rect1); - OH_Drawing_RectDestroy(rect2); - OH_Drawing_RectDestroy(rect3); -} - -void SampleGraphics::DrawMixedMode(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_CanvasClear(canvas, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMin_, rgbaMin_)); - OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value100_, value100_, value600_, value600_); - // 绘制矩形(目标像素) - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMin_, 0xFF)); - // 设置混合模式为叠加模式 - OH_Drawing_BrushSetBlendMode(brush, OH_Drawing_BlendMode::BLEND_MODE_PLUS); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_Point *point = OH_Drawing_PointCreate(value600_, value600_); - // 绘制圆(源像素) - OH_Drawing_CanvasDrawCircle(canvas, point, value300_); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_BrushDestroy(brush); - OH_Drawing_PointDestroy(point); -} - -void SampleGraphics::DrawShaderEffect1Line(OH_Drawing_Canvas *canvas) -{ - // 线性渐变着色器 - OH_Drawing_Point *startPt = OH_Drawing_PointCreate(value100_, value100_); - OH_Drawing_Point *endPt = OH_Drawing_PointCreate(value300_, value300_); - uint32_t colors[] = { - OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMax_, rgbaMin_), - OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_), - OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMin_, rgbaMax_)}; - float pos[] = {0.0f, 0.5f, 1.0f}; - OH_Drawing_ShaderEffect *linearShaderEffect1 = - OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, indexThree_, - OH_Drawing_TileMode::CLAMP); - OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); - // 基于画刷设置着色器 - OH_Drawing_BrushSetShaderEffect(brush, linearShaderEffect1); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value100_, value100_, value300_, value300_); - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - - // 使用矩阵创建线性渐变着色器 - OH_Drawing_CanvasTranslate(canvas, value300_, 0.f); - OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); - OH_Drawing_MatrixScale(matrix, 2.0f, 1.0f, value200_, value200_); - OH_Drawing_Point2D startPt2{value100_, value100_}; - OH_Drawing_Point2D endPt2{value300_, value300_}; - OH_Drawing_ShaderEffect *linearShaderEffect2 = OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix( - &startPt2, &endPt2, colors, pos, indexThree_, OH_Drawing_TileMode::CLAMP, matrix); - OH_Drawing_BrushSetShaderEffect(brush, linearShaderEffect2); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - - // 销毁各类对象 - OH_Drawing_BrushDestroy(brush); - OH_Drawing_RectDestroy(rect); - OH_Drawing_ShaderEffectDestroy(linearShaderEffect1); - OH_Drawing_ShaderEffectDestroy(linearShaderEffect2); - OH_Drawing_PointDestroy(startPt); - OH_Drawing_PointDestroy(endPt); - OH_Drawing_MatrixDestroy(matrix); -} - -void SampleGraphics::DrawShaderEffect2Line(OH_Drawing_Canvas *canvas) -{ - uint32_t colors[] = { - OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMax_, rgbaMin_), - OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_), - OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMin_, rgbaMax_)}; - float pos[] = {0.0f, 0.5f, 1.0f}; - OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value100_, value100_, value300_, value300_); - - // 径向渐变着色器 - OH_Drawing_Point *centerPt = OH_Drawing_PointCreate(value200_, value200_); - OH_Drawing_ShaderEffect *radialShaderEffect = - OH_Drawing_ShaderEffectCreateRadialGradient(centerPt, value200_, colors, pos, indexThree_, - OH_Drawing_TileMode::REPEAT); - OH_Drawing_BrushSetShaderEffect(brush, radialShaderEffect); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - - // 扇形渐变着色器 - OH_Drawing_CanvasTranslate(canvas, value300_, 0.f); - OH_Drawing_ShaderEffect* sweepShaderEffect = - OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, colors, pos, indexThree_, OH_Drawing_TileMode::CLAMP); - OH_Drawing_BrushSetShaderEffect(brush, sweepShaderEffect); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - - // 双圆锥渐变着色器 - OH_Drawing_CanvasTranslate(canvas, value300_, 0.f); - OH_Drawing_Point2D pt3{value200_, value200_}; - OH_Drawing_ShaderEffect *twoPointShaderEffect = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient( - &pt3, value30_, &pt3, value100_, colors, pos, indexThree_, OH_Drawing_TileMode::CLAMP, nullptr); - OH_Drawing_BrushSetShaderEffect(brush, twoPointShaderEffect); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - - // 销毁各类对象 - OH_Drawing_BrushDestroy(brush); - OH_Drawing_RectDestroy(rect); - OH_Drawing_ShaderEffectDestroy(radialShaderEffect); - OH_Drawing_ShaderEffectDestroy(sweepShaderEffect); - OH_Drawing_ShaderEffectDestroy(twoPointShaderEffect); -} - -void SampleGraphics::DrawShaderEffect(OH_Drawing_Canvas *canvas) -{ - // 线性渐变着色器 - DrawShaderEffect1Line(canvas); - OH_Drawing_CanvasTranslate(canvas, -value300_, value300_); - DrawShaderEffect2Line(canvas); -} - -void SampleGraphics::DrawColorFilter(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetAntiAlias(brush, true); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value100_, value100_, value300_, value300_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - - OH_Drawing_CanvasTranslate(canvas, 0.f, value300_); - // 创建luma亮度颜色滤波器 - OH_Drawing_ColorFilter* lumaColorFilter = OH_Drawing_ColorFilterCreateLuma(); - OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); - OH_Drawing_FilterSetColorFilter(filter, lumaColorFilter); - OH_Drawing_BrushSetFilter(brush, filter); - OH_Drawing_CanvasAttachBrush(canvas, brush); - // 绘制经过luma亮度颜色滤波器效果的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - - OH_Drawing_CanvasTranslate(canvas, 0.f, value300_); - const float matrix[20] = { - 1, 0, 0, 0, 0, - 0, 1, 0, 0, 0, - 0, 0, 0.5f, 0.5f, 0, - 0, 0, 0.5f, 0.5f, 0 - }; - // 创建5*4矩阵颜色滤波器 - OH_Drawing_ColorFilter* matrixColorFilter = OH_Drawing_ColorFilterCreateMatrix(matrix); - // 创建从SRGB转换到线性颜色空间的颜色滤波器 - OH_Drawing_ColorFilter* s2lColorFilter = OH_Drawing_ColorFilterCreateSrgbGammaToLinear(); - // 创建从线性颜色空间转换到SRGB的颜色滤波器 - OH_Drawing_ColorFilter* l2sColorFilter = OH_Drawing_ColorFilterCreateLinearToSrgbGamma(); - // 创建合成滤波器 - OH_Drawing_ColorFilter* composeColorFilter1 = - OH_Drawing_ColorFilterCreateCompose(matrixColorFilter, s2lColorFilter); - OH_Drawing_ColorFilter* composeColorFilter2 = - OH_Drawing_ColorFilterCreateCompose(composeColorFilter1, l2sColorFilter); - OH_Drawing_FilterSetColorFilter(filter, composeColorFilter1); - OH_Drawing_BrushSetFilter(brush, filter); - OH_Drawing_CanvasAttachBrush(canvas, brush); - // 绘制经过合成颜色滤波器效果的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - - // 销毁各类对象 - OH_Drawing_BrushDestroy(brush); - OH_Drawing_ColorFilterDestroy(matrixColorFilter); - OH_Drawing_ColorFilterDestroy(lumaColorFilter); - OH_Drawing_ColorFilterDestroy(s2lColorFilter); - OH_Drawing_ColorFilterDestroy(l2sColorFilter); - OH_Drawing_ColorFilterDestroy(composeColorFilter1); - OH_Drawing_ColorFilterDestroy(composeColorFilter2); - OH_Drawing_RectDestroy(rect); - OH_Drawing_FilterDestroy(filter); -} - -void SampleGraphics::DrawMaskFilterBrush(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetAntiAlias(brush, true); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - // 创建模糊蒙版滤波器 - OH_Drawing_MaskFilter *maskFilter = OH_Drawing_MaskFilterCreateBlur(OH_Drawing_BlurType::NORMAL, 20, true); - OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); - OH_Drawing_FilterSetMaskFilter(filter, maskFilter); - // 设置画刷的滤波器效果 - OH_Drawing_BrushSetFilter(brush, filter); - OH_Drawing_CanvasAttachBrush(canvas, brush); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value600_); - // 绘制矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - // 销毁各类对象 - OH_Drawing_BrushDestroy(brush); - OH_Drawing_MaskFilterDestroy(maskFilter); - OH_Drawing_RectDestroy(rect); - OH_Drawing_FilterDestroy(filter); -} +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sample_graphics.h" + +void SampleGraphics::DrawBrushBasic(OH_Drawing_Canvas *canvas) +{ + // 创建画刷 + OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); + // 设置填充颜色为红色 + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + // 开启抗锯齿效果 + OH_Drawing_BrushSetAntiAlias(brush, true); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(0, 0, value300_, value300_); + // 绘制矩形1 + OH_Drawing_CanvasDrawRect(canvas, rect1); + OH_Drawing_CanvasDetachBrush(canvas); + // 复制画刷 + OH_Drawing_Brush* brush_copy = OH_Drawing_BrushCopy(brush); + + // 画刷重置 + OH_Drawing_BrushReset(brush); + // 设置透明度 + OH_Drawing_BrushSetAlpha(brush, rgbaHalf_); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(value400_, value400_, value700_, value700_); + // 绘制矩形2 + OH_Drawing_CanvasDrawRect(canvas, rect2); + OH_Drawing_CanvasDetachBrush(canvas); + + OH_Drawing_CanvasAttachBrush(canvas, brush_copy); + OH_Drawing_Rect* rect3 = OH_Drawing_RectCreate(value800_, value800_, value1100_, value1100_); + // 绘制矩形3 + OH_Drawing_CanvasDrawRect(canvas, rect3); + OH_Drawing_CanvasDetachBrush(canvas); + + // 销毁各类对象 + OH_Drawing_BrushDestroy(brush); + OH_Drawing_BrushDestroy(brush_copy); + OH_Drawing_RectDestroy(rect1); + OH_Drawing_RectDestroy(rect2); + OH_Drawing_RectDestroy(rect3); +} + +void SampleGraphics::DrawMixedMode(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_CanvasClear(canvas, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMin_, rgbaMin_)); + OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value100_, value100_, value600_, value600_); + // 绘制矩形(目标像素) + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMin_, 0xFF)); + // 设置混合模式为叠加模式 + OH_Drawing_BrushSetBlendMode(brush, OH_Drawing_BlendMode::BLEND_MODE_PLUS); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_Point *point = OH_Drawing_PointCreate(value600_, value600_); + // 绘制圆(源像素) + OH_Drawing_CanvasDrawCircle(canvas, point, value300_); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_BrushDestroy(brush); + OH_Drawing_PointDestroy(point); +} + +void SampleGraphics::DrawShaderEffect1Line(OH_Drawing_Canvas *canvas) +{ + // 线性渐变着色器 + OH_Drawing_Point *startPt = OH_Drawing_PointCreate(value100_, value100_); + OH_Drawing_Point *endPt = OH_Drawing_PointCreate(value300_, value300_); + uint32_t colors[] = { + OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMax_, rgbaMin_), + OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_), + OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMin_, rgbaMax_)}; + float pos[] = {0.0f, 0.5f, 1.0f}; + OH_Drawing_ShaderEffect *linearShaderEffect1 = + OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, indexThree_, + OH_Drawing_TileMode::CLAMP); + OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); + // 基于画刷设置着色器 + OH_Drawing_BrushSetShaderEffect(brush, linearShaderEffect1); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value100_, value100_, value300_, value300_); + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + + // 使用矩阵创建线性渐变着色器 + OH_Drawing_CanvasTranslate(canvas, value300_, 0.f); + OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); + OH_Drawing_MatrixScale(matrix, 2.0f, 1.0f, value200_, value200_); + OH_Drawing_Point2D startPt2{value100_, value100_}; + OH_Drawing_Point2D endPt2{value300_, value300_}; + OH_Drawing_ShaderEffect *linearShaderEffect2 = OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix( + &startPt2, &endPt2, colors, pos, indexThree_, OH_Drawing_TileMode::CLAMP, matrix); + OH_Drawing_BrushSetShaderEffect(brush, linearShaderEffect2); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + + // 销毁各类对象 + OH_Drawing_BrushDestroy(brush); + OH_Drawing_RectDestroy(rect); + OH_Drawing_ShaderEffectDestroy(linearShaderEffect1); + OH_Drawing_ShaderEffectDestroy(linearShaderEffect2); + OH_Drawing_PointDestroy(startPt); + OH_Drawing_PointDestroy(endPt); + OH_Drawing_MatrixDestroy(matrix); +} + +void SampleGraphics::DrawShaderEffect2Line(OH_Drawing_Canvas *canvas) +{ + uint32_t colors[] = { + OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMax_, rgbaMin_), + OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_), + OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMin_, rgbaMax_)}; + float pos[] = {0.0f, 0.5f, 1.0f}; + OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value100_, value100_, value300_, value300_); + + // 径向渐变着色器 + OH_Drawing_Point *centerPt = OH_Drawing_PointCreate(value200_, value200_); + OH_Drawing_ShaderEffect *radialShaderEffect = + OH_Drawing_ShaderEffectCreateRadialGradient(centerPt, value200_, colors, pos, indexThree_, + OH_Drawing_TileMode::REPEAT); + OH_Drawing_BrushSetShaderEffect(brush, radialShaderEffect); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + + // 扇形渐变着色器 + OH_Drawing_CanvasTranslate(canvas, value300_, 0.f); + OH_Drawing_ShaderEffect* sweepShaderEffect = + OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, colors, pos, indexThree_, OH_Drawing_TileMode::CLAMP); + OH_Drawing_BrushSetShaderEffect(brush, sweepShaderEffect); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + + // 双圆锥渐变着色器 + OH_Drawing_CanvasTranslate(canvas, value300_, 0.f); + OH_Drawing_Point2D pt3{value200_, value200_}; + OH_Drawing_ShaderEffect *twoPointShaderEffect = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient( + &pt3, value30_, &pt3, value100_, colors, pos, indexThree_, OH_Drawing_TileMode::CLAMP, nullptr); + OH_Drawing_BrushSetShaderEffect(brush, twoPointShaderEffect); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + + // 销毁各类对象 + OH_Drawing_BrushDestroy(brush); + OH_Drawing_RectDestroy(rect); + OH_Drawing_ShaderEffectDestroy(radialShaderEffect); + OH_Drawing_ShaderEffectDestroy(sweepShaderEffect); + OH_Drawing_ShaderEffectDestroy(twoPointShaderEffect); +} + +void SampleGraphics::DrawShaderEffect(OH_Drawing_Canvas *canvas) +{ + // 线性渐变着色器 + DrawShaderEffect1Line(canvas); + OH_Drawing_CanvasTranslate(canvas, -value300_, value300_); + DrawShaderEffect2Line(canvas); +} + +void SampleGraphics::DrawColorFilter(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetAntiAlias(brush, true); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value100_, value100_, value300_, value300_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + + OH_Drawing_CanvasTranslate(canvas, 0.f, value300_); + // 创建luma亮度颜色滤波器 + OH_Drawing_ColorFilter* lumaColorFilter = OH_Drawing_ColorFilterCreateLuma(); + OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); + OH_Drawing_FilterSetColorFilter(filter, lumaColorFilter); + OH_Drawing_BrushSetFilter(brush, filter); + OH_Drawing_CanvasAttachBrush(canvas, brush); + // 绘制经过luma亮度颜色滤波器效果的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + + OH_Drawing_CanvasTranslate(canvas, 0.f, value300_); + const float matrix[20] = { + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 0.5f, 0.5f, 0, + 0, 0, 0.5f, 0.5f, 0 + }; + // 创建5*4矩阵颜色滤波器 + OH_Drawing_ColorFilter* matrixColorFilter = OH_Drawing_ColorFilterCreateMatrix(matrix); + // 创建从SRGB转换到线性颜色空间的颜色滤波器 + OH_Drawing_ColorFilter* s2lColorFilter = OH_Drawing_ColorFilterCreateSrgbGammaToLinear(); + // 创建从线性颜色空间转换到SRGB的颜色滤波器 + OH_Drawing_ColorFilter* l2sColorFilter = OH_Drawing_ColorFilterCreateLinearToSrgbGamma(); + // 创建合成滤波器 + OH_Drawing_ColorFilter* composeColorFilter1 = + OH_Drawing_ColorFilterCreateCompose(matrixColorFilter, s2lColorFilter); + OH_Drawing_ColorFilter* composeColorFilter2 = + OH_Drawing_ColorFilterCreateCompose(composeColorFilter1, l2sColorFilter); + OH_Drawing_FilterSetColorFilter(filter, composeColorFilter1); + OH_Drawing_BrushSetFilter(brush, filter); + OH_Drawing_CanvasAttachBrush(canvas, brush); + // 绘制经过合成颜色滤波器效果的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + + // 销毁各类对象 + OH_Drawing_BrushDestroy(brush); + OH_Drawing_ColorFilterDestroy(matrixColorFilter); + OH_Drawing_ColorFilterDestroy(lumaColorFilter); + OH_Drawing_ColorFilterDestroy(s2lColorFilter); + OH_Drawing_ColorFilterDestroy(l2sColorFilter); + OH_Drawing_ColorFilterDestroy(composeColorFilter1); + OH_Drawing_ColorFilterDestroy(composeColorFilter2); + OH_Drawing_RectDestroy(rect); + OH_Drawing_FilterDestroy(filter); +} + +void SampleGraphics::DrawMaskFilterBrush(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetAntiAlias(brush, true); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + // 创建模糊蒙版滤波器 + OH_Drawing_MaskFilter *maskFilter = OH_Drawing_MaskFilterCreateBlur(OH_Drawing_BlurType::NORMAL, 20, true); + OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); + OH_Drawing_FilterSetMaskFilter(filter, maskFilter); + // 设置画刷的滤波器效果 + OH_Drawing_BrushSetFilter(brush, filter); + OH_Drawing_CanvasAttachBrush(canvas, brush); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value600_); + // 绘制矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + // 销毁各类对象 + OH_Drawing_BrushDestroy(brush); + OH_Drawing_MaskFilterDestroy(maskFilter); + OH_Drawing_RectDestroy(rect); + OH_Drawing_FilterDestroy(filter); +} diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_canvas.cpp b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_canvas.cpp index a42696723f..18a69c1590 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_canvas.cpp +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_canvas.cpp @@ -1,194 +1,194 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sample_graphics.h" -#include "common/log_common.h" - -void SampleGraphics::DrawCreateCanvas(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate(); - OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE}; - uint64_t width = width_ / 2; - uint64_t height = height_ / 2; - OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat); - // 创建一个canvas对象 - OH_Drawing_Canvas* newCanvas = OH_Drawing_CanvasCreate(); - // 将画布与bitmap绑定,画布画的内容会输出到绑定的bitmap内存中 - OH_Drawing_CanvasBind(newCanvas, bitmap); - // 使用红色清除画布内容 - OH_Drawing_CanvasClear(newCanvas, OH_Drawing_ColorSetArgb(rgbaHalf_, rgbaMax_, rgbaMin_, rgbaMin_)); - // 获取画布宽高 - SAMPLE_LOGI("Canvas-->width=%{public}d,height=%{public}d", OH_Drawing_CanvasGetWidth(newCanvas), - OH_Drawing_CanvasGetHeight(newCanvas)); - OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0); - OH_Drawing_CanvasDestroy(newCanvas); - OH_Drawing_BitmapDestroy(bitmap); -} - -void SampleGraphics::DrawCanvasConcatMatrix(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_Matrix *matrix1 = OH_Drawing_MatrixCreateTranslation(value300_, value300_); - // 对画布进行矩阵操作 - OH_Drawing_CanvasConcatMatrix(canvas, matrix1); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreate(); - OH_Drawing_CanvasGetTotalMatrix(canvas, matrix2); - SAMPLE_LOGI("Canvas-->MatrixIsEqual=%{public}d", OH_Drawing_MatrixIsEqual(matrix1, matrix2) ? 1 : 0); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_MatrixDestroy(matrix1); - OH_Drawing_MatrixDestroy(matrix2); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::DrawClipOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetColor(brush, 0xff0000ff); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value200_, value200_, value1000_, value1000_); - // 裁剪矩形区域 - OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::INTERSECT, true); - OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(0, 0, 0, 0); - OH_Drawing_CanvasGetLocalClipBounds(canvas, rect2); - SAMPLE_LOGI("Canvas-->ClipBounds:top=%{public}f,left=%{public}f,right=%{public}f,bottom=%{public}f", - OH_Drawing_RectGetTop(rect2), OH_Drawing_RectGetLeft(rect2), OH_Drawing_RectGetRight(rect2), - OH_Drawing_RectGetBottom(rect2)); - OH_Drawing_Path *path = OH_Drawing_PathCreate(); - OH_Drawing_PathAddCircle(path, value200_, value200_, value400_, PATH_DIRECTION_CCW); - // 裁剪圆形区域 - OH_Drawing_CanvasClipPath(canvas, path, OH_Drawing_CanvasClipOp::DIFFERENCE, true); - // 绘制背景 - OH_Drawing_CanvasDrawBackground(canvas, brush); - OH_Drawing_BrushDestroy(brush); - OH_Drawing_PathDestroy(path); - OH_Drawing_RectDestroy(rect); - OH_Drawing_RectDestroy(rect2); -} - -void SampleGraphics::CanvasSaveOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - // 保存当前画布状态 - OH_Drawing_CanvasSave(canvas); - // 平移 - OH_Drawing_CanvasTranslate(canvas, 0.f, value200_); - // 保存当前画布状态 - OH_Drawing_CanvasSave(canvas); - // 获取画布状态数量 - SAMPLE_LOGI("Canvas-->saveCount=%{public}d", OH_Drawing_CanvasGetSaveCount(canvas)); - // 放大 - OH_Drawing_CanvasScale(canvas, 2.f, 2.f); - OH_Drawing_Point* point = OH_Drawing_PointCreate(value300_, value300_); - // 绘制圆形(经过放大和移动) - OH_Drawing_CanvasDrawCircle(canvas, point, value100_); - // 恢复操作 - OH_Drawing_CanvasRestore(canvas); - // 绘制圆形(仅经过移动) - OH_Drawing_CanvasDrawCircle(canvas, point, value100_); - // 恢复操作至最初状态 - OH_Drawing_CanvasRestoreToCount(canvas, 0); - // 绘制圆形(原始状态) - OH_Drawing_CanvasDrawCircle(canvas, point, value100_); - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_PenDestroy(pen); - OH_Drawing_PointDestroy(point); -} - -void SampleGraphics::CanvasSaveLayerOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Brush* brush1 = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetColor(brush1, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_CanvasAttachBrush(canvas, brush1); - OH_Drawing_Brush* brush2 = OH_Drawing_BrushCreate(); - // 创建图像滤波器实现模糊效果 - OH_Drawing_ImageFilter *imageFilter = - OH_Drawing_ImageFilterCreateBlur(value30_, value30_, OH_Drawing_TileMode::CLAMP, nullptr); - OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); - OH_Drawing_FilterSetImageFilter(filter, imageFilter); - OH_Drawing_BrushSetFilter(brush2, filter); - OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0.f, 0.f, width_, height_); - // 保存当前画布状态 - OH_Drawing_CanvasSaveLayer(canvas, rect, brush2); - OH_Drawing_Point* point1 = OH_Drawing_PointCreate(value300_, value300_); - // 绘制圆形(经过模糊操作) - OH_Drawing_CanvasDrawCircle(canvas, point1, value100_); - // 恢复操作 - OH_Drawing_CanvasRestore(canvas); - OH_Drawing_Point* point2 = OH_Drawing_PointCreate(value300_, value700_); - // 绘制圆形 - OH_Drawing_CanvasDrawCircle(canvas, point2, value100_); - OH_Drawing_CanvasDetachBrush(canvas); - // 释放对象 - OH_Drawing_ImageFilterDestroy(imageFilter); - OH_Drawing_BrushDestroy(brush1); - OH_Drawing_BrushDestroy(brush2); - OH_Drawing_PointDestroy(point1); - OH_Drawing_PointDestroy(point2); - OH_Drawing_RectDestroy(rect); -} - -void SampleGraphics::DrawRegion(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_CanvasAttachBrush(canvas, brush); - // 矩形区域1 - OH_Drawing_Region *region1 = OH_Drawing_RegionCreate(); - OH_Drawing_Rect *rect1 = OH_Drawing_RectCreate(value100_, value100_, value600_, value600_); - OH_Drawing_RegionSetRect(region1, rect1); - // 矩形区域2 - OH_Drawing_Region *region2 = OH_Drawing_RegionCreate(); - OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(value300_, value300_, value900_, value900_); - OH_Drawing_RegionSetRect(region2, rect2); - // 两个矩形区域组合 - OH_Drawing_RegionOp(region1, region2, OH_Drawing_RegionOpMode::REGION_OP_MODE_XOR); - OH_Drawing_CanvasDrawRegion(canvas, region1); - OH_Drawing_CanvasDetachBrush(canvas); - // 销毁各类对象 - OH_Drawing_BrushDestroy(brush); - OH_Drawing_RegionDestroy(region1); - OH_Drawing_RegionDestroy(region2); - OH_Drawing_RectDestroy(rect1); - OH_Drawing_RectDestroy(rect2); -} +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sample_graphics.h" +#include "common/log_common.h" + +void SampleGraphics::DrawCreateCanvas(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate(); + OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE}; + uint64_t width = width_ / 2; + uint64_t height = height_ / 2; + OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat); + // 创建一个canvas对象 + OH_Drawing_Canvas* newCanvas = OH_Drawing_CanvasCreate(); + // 将画布与bitmap绑定,画布画的内容会输出到绑定的bitmap内存中 + OH_Drawing_CanvasBind(newCanvas, bitmap); + // 使用红色清除画布内容 + OH_Drawing_CanvasClear(newCanvas, OH_Drawing_ColorSetArgb(rgbaHalf_, rgbaMax_, rgbaMin_, rgbaMin_)); + // 获取画布宽高 + SAMPLE_LOGI("Canvas-->width=%{public}d,height=%{public}d", OH_Drawing_CanvasGetWidth(newCanvas), + OH_Drawing_CanvasGetHeight(newCanvas)); + OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0); + OH_Drawing_CanvasDestroy(newCanvas); + OH_Drawing_BitmapDestroy(bitmap); +} + +void SampleGraphics::DrawCanvasConcatMatrix(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_Matrix *matrix1 = OH_Drawing_MatrixCreateTranslation(value300_, value300_); + // 对画布进行矩阵操作 + OH_Drawing_CanvasConcatMatrix(canvas, matrix1); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreate(); + OH_Drawing_CanvasGetTotalMatrix(canvas, matrix2); + SAMPLE_LOGI("Canvas-->MatrixIsEqual=%{public}d", OH_Drawing_MatrixIsEqual(matrix1, matrix2) ? 1 : 0); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_MatrixDestroy(matrix1); + OH_Drawing_MatrixDestroy(matrix2); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::DrawClipOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetColor(brush, 0xff0000ff); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value200_, value200_, value1000_, value1000_); + // 裁剪矩形区域 + OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::INTERSECT, true); + OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(0, 0, 0, 0); + OH_Drawing_CanvasGetLocalClipBounds(canvas, rect2); + SAMPLE_LOGI("Canvas-->ClipBounds:top=%{public}f,left=%{public}f,right=%{public}f,bottom=%{public}f", + OH_Drawing_RectGetTop(rect2), OH_Drawing_RectGetLeft(rect2), OH_Drawing_RectGetRight(rect2), + OH_Drawing_RectGetBottom(rect2)); + OH_Drawing_Path *path = OH_Drawing_PathCreate(); + OH_Drawing_PathAddCircle(path, value200_, value200_, value400_, PATH_DIRECTION_CCW); + // 裁剪圆形区域 + OH_Drawing_CanvasClipPath(canvas, path, OH_Drawing_CanvasClipOp::DIFFERENCE, true); + // 绘制背景 + OH_Drawing_CanvasDrawBackground(canvas, brush); + OH_Drawing_BrushDestroy(brush); + OH_Drawing_PathDestroy(path); + OH_Drawing_RectDestroy(rect); + OH_Drawing_RectDestroy(rect2); +} + +void SampleGraphics::CanvasSaveOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + // 保存当前画布状态 + OH_Drawing_CanvasSave(canvas); + // 平移 + OH_Drawing_CanvasTranslate(canvas, 0.f, value200_); + // 保存当前画布状态 + OH_Drawing_CanvasSave(canvas); + // 获取画布状态数量 + SAMPLE_LOGI("Canvas-->saveCount=%{public}d", OH_Drawing_CanvasGetSaveCount(canvas)); + // 放大 + OH_Drawing_CanvasScale(canvas, 2.f, 2.f); + OH_Drawing_Point* point = OH_Drawing_PointCreate(value300_, value300_); + // 绘制圆形(经过放大和移动) + OH_Drawing_CanvasDrawCircle(canvas, point, value100_); + // 恢复操作 + OH_Drawing_CanvasRestore(canvas); + // 绘制圆形(仅经过移动) + OH_Drawing_CanvasDrawCircle(canvas, point, value100_); + // 恢复操作至最初状态 + OH_Drawing_CanvasRestoreToCount(canvas, 0); + // 绘制圆形(原始状态) + OH_Drawing_CanvasDrawCircle(canvas, point, value100_); + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_PenDestroy(pen); + OH_Drawing_PointDestroy(point); +} + +void SampleGraphics::CanvasSaveLayerOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Brush* brush1 = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetColor(brush1, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_CanvasAttachBrush(canvas, brush1); + OH_Drawing_Brush* brush2 = OH_Drawing_BrushCreate(); + // 创建图像滤波器实现模糊效果 + OH_Drawing_ImageFilter *imageFilter = + OH_Drawing_ImageFilterCreateBlur(value30_, value30_, OH_Drawing_TileMode::CLAMP, nullptr); + OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); + OH_Drawing_FilterSetImageFilter(filter, imageFilter); + OH_Drawing_BrushSetFilter(brush2, filter); + OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0.f, 0.f, width_, height_); + // 保存当前画布状态 + OH_Drawing_CanvasSaveLayer(canvas, rect, brush2); + OH_Drawing_Point* point1 = OH_Drawing_PointCreate(value300_, value300_); + // 绘制圆形(经过模糊操作) + OH_Drawing_CanvasDrawCircle(canvas, point1, value100_); + // 恢复操作 + OH_Drawing_CanvasRestore(canvas); + OH_Drawing_Point* point2 = OH_Drawing_PointCreate(value300_, value700_); + // 绘制圆形 + OH_Drawing_CanvasDrawCircle(canvas, point2, value100_); + OH_Drawing_CanvasDetachBrush(canvas); + // 释放对象 + OH_Drawing_ImageFilterDestroy(imageFilter); + OH_Drawing_BrushDestroy(brush1); + OH_Drawing_BrushDestroy(brush2); + OH_Drawing_PointDestroy(point1); + OH_Drawing_PointDestroy(point2); + OH_Drawing_RectDestroy(rect); +} + +void SampleGraphics::DrawRegion(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_CanvasAttachBrush(canvas, brush); + // 矩形区域1 + OH_Drawing_Region *region1 = OH_Drawing_RegionCreate(); + OH_Drawing_Rect *rect1 = OH_Drawing_RectCreate(value100_, value100_, value600_, value600_); + OH_Drawing_RegionSetRect(region1, rect1); + // 矩形区域2 + OH_Drawing_Region *region2 = OH_Drawing_RegionCreate(); + OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(value300_, value300_, value900_, value900_); + OH_Drawing_RegionSetRect(region2, rect2); + // 两个矩形区域组合 + OH_Drawing_RegionOp(region1, region2, OH_Drawing_RegionOpMode::REGION_OP_MODE_XOR); + OH_Drawing_CanvasDrawRegion(canvas, region1); + OH_Drawing_CanvasDetachBrush(canvas); + // 销毁各类对象 + OH_Drawing_BrushDestroy(brush); + OH_Drawing_RegionDestroy(region1); + OH_Drawing_RegionDestroy(region2); + OH_Drawing_RectDestroy(rect1); + OH_Drawing_RectDestroy(rect2); +} diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_matrix.cpp b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_matrix.cpp index 04b17debe2..ded6e2098e 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_matrix.cpp +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_matrix.cpp @@ -1,306 +1,306 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sample_graphics.h" -#include "common/log_common.h" - -void SampleGraphics::DrawMatrixBasic(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - // 创建矩阵对象 - OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); - // 设置矩阵(平移) - OH_Drawing_MatrixSetMatrix(matrix, indexOne_, 0, value300_, 0, indexOne_, value300_, 0, 0, indexOne_); - OH_Drawing_Point2D src{value300_, value300_}; - OH_Drawing_Point2D dst; - // 源点坐标变换为目标点坐标 - OH_Drawing_MatrixMapPoints(matrix, &src, &dst, indexOne_); - SAMPLE_LOGI("DrawMatrixBasic-->point(src) x=%{public}f,y=%{public}f", src.x, src.y); - SAMPLE_LOGI("DrawMatrixBasic-->point(dst) x=%{public}f,y=%{public}f", dst.x, dst.y); - OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(0, 0, 0, 0); - // 源矩形变换为目标矩形 - OH_Drawing_MatrixMapRect(matrix, rect, rect2); - SAMPLE_LOGI("DrawMatrixBasic-->rect(src) left=%{public}f,top=%{public}f,right=%{public}f,bottom=%{public}f", - OH_Drawing_RectGetLeft(rect), OH_Drawing_RectGetTop(rect), OH_Drawing_RectGetRight(rect), - OH_Drawing_RectGetBottom(rect)); - SAMPLE_LOGI("DrawMatrixBasic-->rect(dst) left=%{public}f,top=%{public}f,right=%{public}f,bottom=%{public}f", - OH_Drawing_RectGetLeft(rect2), OH_Drawing_RectGetTop(rect2), OH_Drawing_RectGetRight(rect2), - OH_Drawing_RectGetBottom(rect2)); - OH_Drawing_CanvasConcatMatrix(canvas, matrix); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreate(); - // 逆矩阵 - OH_Drawing_MatrixInvert(matrix2, matrix); - SAMPLE_LOGI( - "matrix2(%{public}f,%{public}f,%{public}f,%{public}f,%{public}f,%{public}f,%{public}f,%{public}f,%{public}f)", - OH_Drawing_MatrixGetValue(matrix, 0), OH_Drawing_MatrixGetValue(matrix, indexOne_), - OH_Drawing_MatrixGetValue(matrix, indexTwo_), OH_Drawing_MatrixGetValue(matrix, indexThree_), - OH_Drawing_MatrixGetValue(matrix, indexFour_), OH_Drawing_MatrixGetValue(matrix, indexFive_), - OH_Drawing_MatrixGetValue(matrix, indexSix_), OH_Drawing_MatrixGetValue(matrix, indexSeven_), - OH_Drawing_MatrixGetValue(matrix, indexNine_)); - // 重置矩阵 - OH_Drawing_MatrixReset(matrix); - OH_Drawing_CanvasDetachBrush(canvas); - // 释放对象 - OH_Drawing_RectDestroy(rect); - OH_Drawing_RectDestroy(rect2); - OH_Drawing_MatrixDestroy(matrix); - OH_Drawing_MatrixDestroy(matrix2); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::DrawTranslationOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - // 创建在水平和垂直方向分别平移300px的矩阵对象 - OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(value300_, value300_); - OH_Drawing_CanvasConcatMatrix(canvas, matrix); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_MatrixDestroy(matrix); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::DrawPreTranslationOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); - // 旋转 - OH_Drawing_MatrixRotate(matrix, value45_, value300_, value300_); - // 左乘平移(先平移后旋转) - OH_Drawing_MatrixPreTranslate(matrix, value200_, value200_); - OH_Drawing_CanvasConcatMatrix(canvas, matrix); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_MatrixDestroy(matrix); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::DrawPostTranslationOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); - // 旋转 - OH_Drawing_MatrixRotate(matrix, value45_, value300_, value300_); - // 右乘平移(先旋转后平移) - OH_Drawing_MatrixPostTranslate(matrix, value200_, value200_); - OH_Drawing_CanvasConcatMatrix(canvas, matrix); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_MatrixDestroy(matrix); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::DrawRotationOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - // 创建旋转的矩阵对象 - OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateRotation(value45_, value300_, value300_); - OH_Drawing_CanvasConcatMatrix(canvas, matrix); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_MatrixDestroy(matrix); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::DrawPreRotationOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); - // 平移 - OH_Drawing_MatrixTranslate(matrix, value200_, value200_); - // 左乘旋转(先旋转后平移) - OH_Drawing_MatrixPreRotate(matrix, value45_, value300_, value300_); - OH_Drawing_CanvasConcatMatrix(canvas, matrix); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_MatrixDestroy(matrix); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::DrawPostRotationOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); - // 平移 - OH_Drawing_MatrixTranslate(matrix, value200_, value200_); - // 右乘旋转(先平移后旋转) - OH_Drawing_MatrixPostRotate(matrix, value45_, value300_, value300_); - OH_Drawing_CanvasConcatMatrix(canvas, matrix); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_MatrixDestroy(matrix); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::DrawScaleOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - // 创建缩放的矩阵对象 - OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateScale(2, 2, value300_, value300_); - OH_Drawing_CanvasConcatMatrix(canvas, matrix); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_PenDestroy(pen); - OH_Drawing_MatrixDestroy(matrix); -} - -void SampleGraphics::DrawPreScaleOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(value100_, value100_); - // 左乘缩放(先缩放后平移) - OH_Drawing_MatrixPreScale(matrix, indexTwo_, indexTwo_, value300_, value300_); - OH_Drawing_CanvasConcatMatrix(canvas, matrix); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_PenDestroy(pen); - OH_Drawing_MatrixDestroy(matrix); -} - -void SampleGraphics::DrawPostScaleOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(value100_, value100_); - // 右乘缩放(先平移后缩放) - OH_Drawing_MatrixPostScale(matrix, indexTwo_, indexTwo_, value300_, value300_); - OH_Drawing_CanvasConcatMatrix(canvas, matrix); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_PenDestroy(pen); - OH_Drawing_MatrixDestroy(matrix); -} - -void SampleGraphics::DrawConcatOperation(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); - // 绘制原始矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_Matrix* matrix1 = OH_Drawing_MatrixCreateTranslation(value100_, value100_); - OH_Drawing_Matrix* matrix2 = OH_Drawing_MatrixCreate(); - OH_Drawing_Matrix* matrix3 = OH_Drawing_MatrixCreate(); - OH_Drawing_MatrixScale(matrix2, indexTwo_, indexTwo_, value300_, value300_); - OH_Drawing_MatrixConcat(matrix3, matrix2, matrix1); - OH_Drawing_CanvasConcatMatrix(canvas, matrix3); - // 绘制变换后的矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_RectDestroy(rect); - OH_Drawing_PenDestroy(pen); - OH_Drawing_MatrixDestroy(matrix1); - OH_Drawing_MatrixDestroy(matrix2); - OH_Drawing_MatrixDestroy(matrix3); -} +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sample_graphics.h" +#include "common/log_common.h" + +void SampleGraphics::DrawMatrixBasic(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + // 创建矩阵对象 + OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); + // 设置矩阵(平移) + OH_Drawing_MatrixSetMatrix(matrix, indexOne_, 0, value300_, 0, indexOne_, value300_, 0, 0, indexOne_); + OH_Drawing_Point2D src{value300_, value300_}; + OH_Drawing_Point2D dst; + // 源点坐标变换为目标点坐标 + OH_Drawing_MatrixMapPoints(matrix, &src, &dst, indexOne_); + SAMPLE_LOGI("DrawMatrixBasic-->point(src) x=%{public}f,y=%{public}f", src.x, src.y); + SAMPLE_LOGI("DrawMatrixBasic-->point(dst) x=%{public}f,y=%{public}f", dst.x, dst.y); + OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(0, 0, 0, 0); + // 源矩形变换为目标矩形 + OH_Drawing_MatrixMapRect(matrix, rect, rect2); + SAMPLE_LOGI("DrawMatrixBasic-->rect(src) left=%{public}f,top=%{public}f,right=%{public}f,bottom=%{public}f", + OH_Drawing_RectGetLeft(rect), OH_Drawing_RectGetTop(rect), OH_Drawing_RectGetRight(rect), + OH_Drawing_RectGetBottom(rect)); + SAMPLE_LOGI("DrawMatrixBasic-->rect(dst) left=%{public}f,top=%{public}f,right=%{public}f,bottom=%{public}f", + OH_Drawing_RectGetLeft(rect2), OH_Drawing_RectGetTop(rect2), OH_Drawing_RectGetRight(rect2), + OH_Drawing_RectGetBottom(rect2)); + OH_Drawing_CanvasConcatMatrix(canvas, matrix); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreate(); + // 逆矩阵 + OH_Drawing_MatrixInvert(matrix2, matrix); + SAMPLE_LOGI( + "matrix2(%{public}f,%{public}f,%{public}f,%{public}f,%{public}f,%{public}f,%{public}f,%{public}f,%{public}f)", + OH_Drawing_MatrixGetValue(matrix, 0), OH_Drawing_MatrixGetValue(matrix, indexOne_), + OH_Drawing_MatrixGetValue(matrix, indexTwo_), OH_Drawing_MatrixGetValue(matrix, indexThree_), + OH_Drawing_MatrixGetValue(matrix, indexFour_), OH_Drawing_MatrixGetValue(matrix, indexFive_), + OH_Drawing_MatrixGetValue(matrix, indexSix_), OH_Drawing_MatrixGetValue(matrix, indexSeven_), + OH_Drawing_MatrixGetValue(matrix, indexNine_)); + // 重置矩阵 + OH_Drawing_MatrixReset(matrix); + OH_Drawing_CanvasDetachBrush(canvas); + // 释放对象 + OH_Drawing_RectDestroy(rect); + OH_Drawing_RectDestroy(rect2); + OH_Drawing_MatrixDestroy(matrix); + OH_Drawing_MatrixDestroy(matrix2); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::DrawTranslationOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + // 创建在水平和垂直方向分别平移300px的矩阵对象 + OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(value300_, value300_); + OH_Drawing_CanvasConcatMatrix(canvas, matrix); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_MatrixDestroy(matrix); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::DrawPreTranslationOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); + // 旋转 + OH_Drawing_MatrixRotate(matrix, value45_, value300_, value300_); + // 左乘平移(先平移后旋转) + OH_Drawing_MatrixPreTranslate(matrix, value200_, value200_); + OH_Drawing_CanvasConcatMatrix(canvas, matrix); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_MatrixDestroy(matrix); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::DrawPostTranslationOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); + // 旋转 + OH_Drawing_MatrixRotate(matrix, value45_, value300_, value300_); + // 右乘平移(先旋转后平移) + OH_Drawing_MatrixPostTranslate(matrix, value200_, value200_); + OH_Drawing_CanvasConcatMatrix(canvas, matrix); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_MatrixDestroy(matrix); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::DrawRotationOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + // 创建旋转的矩阵对象 + OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateRotation(value45_, value300_, value300_); + OH_Drawing_CanvasConcatMatrix(canvas, matrix); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_MatrixDestroy(matrix); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::DrawPreRotationOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); + // 平移 + OH_Drawing_MatrixTranslate(matrix, value200_, value200_); + // 左乘旋转(先旋转后平移) + OH_Drawing_MatrixPreRotate(matrix, value45_, value300_, value300_); + OH_Drawing_CanvasConcatMatrix(canvas, matrix); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_MatrixDestroy(matrix); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::DrawPostRotationOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); + // 平移 + OH_Drawing_MatrixTranslate(matrix, value200_, value200_); + // 右乘旋转(先平移后旋转) + OH_Drawing_MatrixPostRotate(matrix, value45_, value300_, value300_); + OH_Drawing_CanvasConcatMatrix(canvas, matrix); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_MatrixDestroy(matrix); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::DrawScaleOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + // 创建缩放的矩阵对象 + OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateScale(2, 2, value300_, value300_); + OH_Drawing_CanvasConcatMatrix(canvas, matrix); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_PenDestroy(pen); + OH_Drawing_MatrixDestroy(matrix); +} + +void SampleGraphics::DrawPreScaleOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(value100_, value100_); + // 左乘缩放(先缩放后平移) + OH_Drawing_MatrixPreScale(matrix, indexTwo_, indexTwo_, value300_, value300_); + OH_Drawing_CanvasConcatMatrix(canvas, matrix); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_PenDestroy(pen); + OH_Drawing_MatrixDestroy(matrix); +} + +void SampleGraphics::DrawPostScaleOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(value100_, value100_); + // 右乘缩放(先平移后缩放) + OH_Drawing_MatrixPostScale(matrix, indexTwo_, indexTwo_, value300_, value300_); + OH_Drawing_CanvasConcatMatrix(canvas, matrix); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_PenDestroy(pen); + OH_Drawing_MatrixDestroy(matrix); +} + +void SampleGraphics::DrawConcatOperation(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value500_); + // 绘制原始矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_Matrix* matrix1 = OH_Drawing_MatrixCreateTranslation(value100_, value100_); + OH_Drawing_Matrix* matrix2 = OH_Drawing_MatrixCreate(); + OH_Drawing_Matrix* matrix3 = OH_Drawing_MatrixCreate(); + OH_Drawing_MatrixScale(matrix2, indexTwo_, indexTwo_, value300_, value300_); + OH_Drawing_MatrixConcat(matrix3, matrix2, matrix1); + OH_Drawing_CanvasConcatMatrix(canvas, matrix3); + // 绘制变换后的矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_RectDestroy(rect); + OH_Drawing_PenDestroy(pen); + OH_Drawing_MatrixDestroy(matrix1); + OH_Drawing_MatrixDestroy(matrix2); + OH_Drawing_MatrixDestroy(matrix3); +} diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_path.cpp b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_path.cpp index 7078c8ee41..ae2265a1d9 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_path.cpp +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_path.cpp @@ -1,453 +1,453 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sample_graphics.h" -#include "common/log_common.h" - -OH_Drawing_Path* SampleGraphics::DrawPathBasicTriangle(float startX, float startY, int32_t w) -{ - // 创建路径对象 - OH_Drawing_Path *path = OH_Drawing_PathCreate(); - // 设置填充路径规则 - OH_Drawing_PathSetFillType(path, OH_Drawing_PathFillType::PATH_FILL_TYPE_EVEN_ODD); - // 移动到起始点 - OH_Drawing_PathMoveTo(path, startX + value15_, startY); - // 添加线段 - OH_Drawing_PathLineTo(path, startX + value15_, startY + value150_); - OH_Drawing_PathLineTo(path, startX + w - value15_, startY + value150_); - // 闭合路径 - OH_Drawing_PathClose(path); - // 判断路径是否包含坐标点 - SAMPLE_LOGI("PathBasic-->contains:%{public}d", - OH_Drawing_PathContains(path, startX + value30_, startY + value100_) ? 1 : 0); - // 判断路径是否闭合 - SAMPLE_LOGI("PathBasic-->isClosed:%{public}d", OH_Drawing_PathIsClosed(path, false) ? 1 : 0); - // 获取路径长度 - SAMPLE_LOGI("PathBasic-->getLength:%{public}f", OH_Drawing_PathGetLength(path, false)); - OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 0, 0); - // 获取边界 - OH_Drawing_PathGetBounds(path, rect); - SAMPLE_LOGI("PathBasic-->getBounds:left=%{public}f,top=%{public}f,right=%{public}f,bottom=%{public}f", - OH_Drawing_RectGetLeft(rect), OH_Drawing_RectGetTop(rect), OH_Drawing_RectGetRight(rect), - OH_Drawing_RectGetBottom(rect)); - OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); - // 获取变换矩阵 - OH_Drawing_PathGetMatrix(path, false, value50_, matrix, OH_Drawing_PathMeasureMatrixFlags::GET_POSITION_MATRIX); - OH_Drawing_Point2D point{startX + value30_, startY + value150_}; - OH_Drawing_Point2D tangent{0, 0}; - // 获取坐标点和切线 - OH_Drawing_PathGetPositionTangent(path, false, 1, &point, &tangent); - SAMPLE_LOGI("PathBasic-->tangent.x=%{public}f,tangent.y=%{public}f", tangent.x, tangent.y); - OH_Drawing_MatrixDestroy(matrix); - return path; -} - -void SampleGraphics::DrawPathBasic(OH_Drawing_Canvas *canvas) -{ - int32_t w = width_ / indexFive_; - float startX = 0; - float startY = value100_; - OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetAntiAlias(pen, true); - float penWidth = 3.f; - OH_Drawing_PenSetWidth(pen, penWidth); - OH_Drawing_CanvasAttachPen(canvas, pen); - - // 三角形1 - OH_Drawing_Path *path = DrawPathBasicTriangle(startX, startY, w); - OH_Drawing_CanvasDrawPath(canvas, path); - - // 三角形2 - // 复制路径 - OH_Drawing_Path *path_copy = OH_Drawing_PathCopy(path); - OH_Drawing_Matrix *matrix_translate = OH_Drawing_MatrixCreateTranslation(w, 0); - // 对路径进行矩阵变换 - OH_Drawing_PathTransform(path_copy, matrix_translate); - OH_Drawing_CanvasDrawPath(canvas, path_copy); - - // 三角形3 - OH_Drawing_Path *path_third = OH_Drawing_PathCreate(); - // 对路径进行矩阵变换 - OH_Drawing_PathTransformWithPerspectiveClip(path_copy, matrix_translate, path_third, false); - OH_Drawing_CanvasDrawPath(canvas, path_third); - - // 三角形4 - OH_Drawing_Path *path_fourth = OH_Drawing_PathCreate(); - OH_Drawing_PathOffset(path, path_fourth, w * indexThree_, 0); - OH_Drawing_CanvasDrawPath(canvas, path_fourth); - - // 梯形 - startX += indexFour_ * w; - OH_Drawing_Path *path_fifth = OH_Drawing_PathCreate(); - OH_Drawing_PathMoveTo(path_fifth, startX + value15_, startY); - OH_Drawing_PathLineTo(path_fifth, startX + value15_, startY + value100_); - OH_Drawing_PathLineTo(path_fifth, startX + w - value15_, startY + value100_); - OH_Drawing_PathTransform(path_fourth, matrix_translate); - // 将两个路径合并(取差集) - OH_Drawing_PathOp(path_fifth, path_fourth, OH_Drawing_PathOpMode::PATH_OP_MODE_REVERSE_DIFFERENCE); - OH_Drawing_CanvasDrawPath(canvas, path_fifth); - - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_PathDestroy(path); - OH_Drawing_PathDestroy(path_copy); - OH_Drawing_PathDestroy(path_third); - OH_Drawing_PathDestroy(path_fourth); - OH_Drawing_PathDestroy(path_fifth); - OH_Drawing_MatrixDestroy(matrix_translate); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::DrawPathTo1Line(OH_Drawing_Canvas *canvas) -{ - int32_t w = width_ / indexFive_; - float startX = 0; - float startY = value100_; - OH_Drawing_Path *path = OH_Drawing_PathCreate(); - - // 线段 - OH_Drawing_PathMoveTo(path, startX + value15_, startY + value70_); - OH_Drawing_PathLineTo(path, startX + w - value15_, startY + value70_); - OH_Drawing_CanvasDrawPath(canvas, path); - - // 弧线 - startX += w; - OH_Drawing_PathReset(path); - float startDeg = 60; - float sweepDeg = -240; - OH_Drawing_PathArcTo(path, startX + value15_, startY + value30_, startX + w - value15_, startY + value150_, - startDeg, sweepDeg); - OH_Drawing_CanvasDrawPath(canvas, path); - - // 二阶贝塞尔曲线 - startX += w; - OH_Drawing_PathReset(path); - OH_Drawing_PathMoveTo(path, startX + value15_, startY); - OH_Drawing_PathQuadTo(path, startX + value30_, startY + value100_, startX + w - value15_, startY + value150_); - OH_Drawing_CanvasDrawPath(canvas, path); - - // 二阶贝塞尔曲线(带权重) - startX += w; - OH_Drawing_PathReset(path); - OH_Drawing_PathMoveTo(path, startX + value15_, startY); - float weight = 5.f; - OH_Drawing_PathConicTo(path, startX + value30_, startY + value100_, startX + w - value15_, startY + value150_, - weight); - OH_Drawing_CanvasDrawPath(canvas, path); - - // 三阶贝塞尔曲线 - startX += w; - OH_Drawing_PathReset(path); - OH_Drawing_PathMoveTo(path, startX + value15_, startY); - OH_Drawing_PathCubicTo(path, startX + value30_, startY + value120_, startX + w - value30_, startY + value30_, - startX + w - value15_, startY + value150_); - OH_Drawing_CanvasDrawPath(canvas, path); - - OH_Drawing_PathDestroy(path); -} - -void SampleGraphics::DrawPathTo2Line(OH_Drawing_Canvas *canvas) -{ - int32_t w = width_ / indexFive_; - float startX = 0; - float startY = value300_; - OH_Drawing_Path *path = OH_Drawing_PathCreate(); - - // 线段 - OH_Drawing_PathMoveTo(path, startX, startY); - OH_Drawing_PathRMoveTo(path, value15_, value70_); - OH_Drawing_PathRLineTo(path, w - value30_, 0); - OH_Drawing_CanvasDrawPath(canvas, path); - - // 二阶贝塞尔曲线 - startX += w; - OH_Drawing_PathReset(path); - OH_Drawing_PathMoveTo(path, startX + value15_, startY); - OH_Drawing_PathRQuadTo(path, value30_, value100_, w - value10_, value150_); - OH_Drawing_CanvasDrawPath(canvas, path); - - // 二阶贝塞尔曲线(带权重) - startX += w; - OH_Drawing_PathReset(path); - OH_Drawing_PathMoveTo(path, startX + value15_, startY); - float weight = 5.f; - OH_Drawing_PathRConicTo(path, value30_, value100_, w - value15_, value150_, weight); - OH_Drawing_CanvasDrawPath(canvas, path); - - // 三阶贝塞尔曲线 - startX += w; - OH_Drawing_PathReset(path); - OH_Drawing_PathMoveTo(path, startX + value15_, startY); - OH_Drawing_PathRCubicTo(path, value30_, value120_, w - value30_, value30_, w - value10_, value150_); - OH_Drawing_CanvasDrawPath(canvas, path); - - OH_Drawing_PathDestroy(path); -} - -void SampleGraphics::DrawPathTo(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetAntiAlias(pen, true); - float penWidth = 3.f; - OH_Drawing_PenSetWidth(pen, penWidth); - OH_Drawing_CanvasAttachPen(canvas, pen); - - DrawPathTo1Line(canvas); - OH_Drawing_CanvasTranslate(canvas, 0, value200_); - DrawPathTo2Line(canvas); - - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::DrawPathAdd1Line(OH_Drawing_Canvas *canvas) -{ - int32_t w = width_ / indexFive_; - float startX = 0; - float startY = value100_; - // 圆 - OH_Drawing_Path *pathCircle = OH_Drawing_PathCreate(); - float radius = 40; - float startYAdded = 60; - OH_Drawing_PathAddCircle(pathCircle, startX + w / indexTwo_, startY + startYAdded, radius, PATH_DIRECTION_CCW); - OH_Drawing_CanvasDrawPath(canvas, pathCircle); - OH_Drawing_PathDestroy(pathCircle); - // 矩形 - startX += w; - OH_Drawing_Path *pathRect = OH_Drawing_PathCreate(); - OH_Drawing_PathAddRect(pathRect, startX + value10_, startY + value30_, startX + w - value10_, - startY + value90_, PATH_DIRECTION_CCW); - OH_Drawing_CanvasDrawPath(canvas, pathRect); - OH_Drawing_PathDestroy(pathRect); - // 椭圆 - startX += w; - OH_Drawing_Path *pathOval = OH_Drawing_PathCreate(); - OH_Drawing_Rect *rectOval = OH_Drawing_RectCreate(startX + value10_, startY + value30_, - startX + w - value10_, startY + value90_); - OH_Drawing_PathAddOval(pathOval, rectOval, OH_Drawing_PathDirection::PATH_DIRECTION_CW); - OH_Drawing_CanvasDrawPath(canvas, pathOval); - OH_Drawing_RectDestroy(rectOval); - OH_Drawing_PathDestroy(pathOval); - // 圆角矩形 - startX += w; - OH_Drawing_Path *pathRoundRect = OH_Drawing_PathCreate(); - OH_Drawing_Rect *rectRoundRect = OH_Drawing_RectCreate(startX + value10_, startY + value30_, - startX + w - value10_, startY + value90_); - OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rectRoundRect, value20_, value20_); - OH_Drawing_PathAddRoundRect(pathRoundRect, roundRect, PATH_DIRECTION_CCW); - OH_Drawing_CanvasDrawPath(canvas, pathRoundRect); - OH_Drawing_RectDestroy(rectRoundRect); - OH_Drawing_PathDestroy(pathRoundRect); - OH_Drawing_RoundRectDestroy(roundRect); -} - -void SampleGraphics::DrawPathAdd2Line(OH_Drawing_Canvas *canvas) -{ - int32_t w = width_ / indexFive_; - float startX = 0; - float startY = value100_; - // 多边形 - OH_Drawing_Path *pathPolygon = OH_Drawing_PathCreate(); - float leftPointX = startX + value10_; - float rightPointX = startX + w - value10_; - float middlePointX = (leftPointX + rightPointX) / 2; - OH_Drawing_Point2D points[] = {{middlePointX, startY + value30_}, {leftPointX, startY + value90_}, - {rightPointX, startY + value90_}}; - OH_Drawing_PathAddPolygon(pathPolygon, points, 3, true); // 3 is the size of point array - OH_Drawing_CanvasDrawPath(canvas, pathPolygon); - OH_Drawing_PathDestroy(pathPolygon); - // 曲线 - startX += w; - OH_Drawing_Rect *rectArc = OH_Drawing_RectCreate(startX - value30_, startY + value30_, - startX + w - value10_, startY + value150_); - OH_Drawing_Path *pathArc = OH_Drawing_PathCreate(); - OH_Drawing_PathAddArc(pathArc, rectArc, 0, -value90_); - OH_Drawing_CanvasDrawPath(canvas, pathArc); - OH_Drawing_RectDestroy(rectArc); - OH_Drawing_PathDestroy(pathArc); -} - -void SampleGraphics::DrawPathAdd3Line(OH_Drawing_Canvas *canvas) -{ - int32_t w = width_ / indexFive_; - float startX = 0; - float startY = value100_; - // 线段1 - OH_Drawing_Path *pathOuter1 = OH_Drawing_PathCreate(); - OH_Drawing_Path *pathInner1 = OH_Drawing_PathCreate(); - OH_Drawing_PathMoveTo(pathInner1, startX + value10_, startY); - OH_Drawing_PathLineTo(pathInner1, startX + w - value10_, startY); - OH_Drawing_Matrix *matrix1 = OH_Drawing_MatrixCreateTranslation(0, value50_); - OH_Drawing_PathAddPath(pathOuter1, pathInner1, matrix1); - OH_Drawing_CanvasDrawPath(canvas, pathOuter1); - OH_Drawing_PathDestroy(pathOuter1); - OH_Drawing_PathDestroy(pathInner1); - OH_Drawing_MatrixDestroy(matrix1); - // 线段2 - startX += w; - OH_Drawing_Path *pathOuter2 = OH_Drawing_PathCreate(); - OH_Drawing_Path *pathInner2 = OH_Drawing_PathCreate(); - OH_Drawing_PathMoveTo(pathInner2, startX + value10_, startY + value50_); - OH_Drawing_PathLineTo(pathInner2, startX + w - value10_, startY + value50_); - OH_Drawing_PathAddPathWithMode(pathOuter2, pathInner2, OH_Drawing_PathAddMode::PATH_ADD_MODE_APPEND); - OH_Drawing_CanvasDrawPath(canvas, pathOuter2); - OH_Drawing_PathDestroy(pathOuter2); - OH_Drawing_PathDestroy(pathInner2); - // 线段3 - startX += w; - OH_Drawing_Path *pathOuter3 = OH_Drawing_PathCreate(); - OH_Drawing_Path *pathInner3 = OH_Drawing_PathCreate(); - OH_Drawing_PathMoveTo(pathInner3, startX + value10_, startY); - OH_Drawing_PathLineTo(pathInner3, startX + w - value10_, startY); - OH_Drawing_PathAddPathWithOffsetAndMode(pathOuter3, pathInner3, 0, value50_, - OH_Drawing_PathAddMode::PATH_ADD_MODE_APPEND); - OH_Drawing_CanvasDrawPath(canvas, pathOuter3); - OH_Drawing_PathDestroy(pathOuter3); - OH_Drawing_PathDestroy(pathInner3); - // 线段4 - startX += w; - OH_Drawing_Path *pathOuter4 = OH_Drawing_PathCreate(); - OH_Drawing_Path *pathInner4 = OH_Drawing_PathCreate(); - OH_Drawing_PathMoveTo(pathInner4, startX + value10_, startY); - OH_Drawing_PathLineTo(pathInner4, startX + w - value10_, startY); - OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateTranslation(0, value50_); - OH_Drawing_PathAddPathWithMatrixAndMode(pathOuter4, pathInner4, matrix2, - OH_Drawing_PathAddMode::PATH_ADD_MODE_APPEND); - OH_Drawing_CanvasDrawPath(canvas, pathOuter4); - OH_Drawing_PathDestroy(pathOuter4); - OH_Drawing_PathDestroy(pathInner4); - OH_Drawing_MatrixDestroy(matrix2); -} - -void SampleGraphics::DrawPathAdd4Line(OH_Drawing_Canvas *canvas) -{ - int32_t w = width_ / indexFive_; - float startX = 0; - float startY = value100_; - // 椭圆 - OH_Drawing_Path *pathOval = OH_Drawing_PathCreate(); - OH_Drawing_Rect *rectOval = OH_Drawing_RectCreate(startX + value10_, startY + value30_, - startX + w - value10_, startY + value90_); - OH_Drawing_PathAddOvalWithInitialPoint(pathOval, rectOval, 1, OH_Drawing_PathDirection::PATH_DIRECTION_CW); - OH_Drawing_CanvasDrawPath(canvas, pathOval); - OH_Drawing_RectDestroy(rectOval); - OH_Drawing_PathDestroy(pathOval); - // 矩形 - startX += w; - OH_Drawing_Path *pathRect = OH_Drawing_PathCreate(); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(startX + value10_, startY + value30_, - startX + w - value10_, startY + value90_); - OH_Drawing_PathAddRectWithInitialCorner(pathRect, rect, PATH_DIRECTION_CCW, 1); - OH_Drawing_CanvasDrawPath(canvas, pathRect); - OH_Drawing_PathDestroy(pathRect); - OH_Drawing_RectDestroy(rect); -} - -void SampleGraphics::DrawPathAdd(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetAntiAlias(pen, true); - float penWidth = 3.f; - OH_Drawing_PenSetWidth(pen, penWidth); - OH_Drawing_CanvasAttachPen(canvas, pen); - - DrawPathAdd1Line(canvas); - OH_Drawing_CanvasTranslate(canvas, 0, value200_); - DrawPathAdd2Line(canvas); - OH_Drawing_CanvasTranslate(canvas, 0, value200_); - DrawPathAdd3Line(canvas); - OH_Drawing_CanvasTranslate(canvas, 0, value200_); - DrawPathAdd4Line(canvas); - - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_PenDestroy(pen); -} - -void SampleGraphics::BuildFromSvgString(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_CanvasAttachBrush(canvas, brush); - char* str = "M150 130L30 300L270 300Z"; - OH_Drawing_Path* path = OH_Drawing_PathCreate(); - // 通过svg构建path - OH_Drawing_PathBuildFromSvgString(path, str); - OH_Drawing_CanvasDrawPath(canvas, path); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_BrushDestroy(brush); - OH_Drawing_PathDestroy(path); -} - -void SampleGraphics::DrawStar(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - OH_Drawing_PenSetJoin(pen, LINE_ROUND_JOIN); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMax_, rgbaMin_)); - OH_Drawing_CanvasAttachBrush(canvas, brush); - int len = value551_; - float aX = value630_; - float aY = value551_; - float angle = 18.0f; - float dX = aX - len * std::sin(angle); - float dY = aY + len * std::cos(angle); - float cX = aX + len * std::sin(angle); - float cY = dY; - float bX = aX + (len / 2.0); - float bY = aY + std::sqrt((cX - dX) * (cX - dX) + (len / 2.0) * (len / 2.0)); - float eX = aX - (len / 2.0); - float eY = bY; - // 创建路径 - OH_Drawing_Path* path = OH_Drawing_PathCreate(); - // 到起始点 - OH_Drawing_PathMoveTo(path, aX, aY); - // 绘制直线 - OH_Drawing_PathLineTo(path, bX, bY); - OH_Drawing_PathLineTo(path, cX, cY); - OH_Drawing_PathLineTo(path, dX, dY); - OH_Drawing_PathLineTo(path, eX, eY); - // 直线闭合,形成五角星 - OH_Drawing_PathClose(path); - // 绘制闭合路径 - OH_Drawing_CanvasDrawPath(canvas, path); - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_PenDestroy(pen); - OH_Drawing_BrushDestroy(brush); - OH_Drawing_PathDestroy(path); +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sample_graphics.h" +#include "common/log_common.h" + +OH_Drawing_Path* SampleGraphics::DrawPathBasicTriangle(float startX, float startY, int32_t w) +{ + // 创建路径对象 + OH_Drawing_Path *path = OH_Drawing_PathCreate(); + // 设置填充路径规则 + OH_Drawing_PathSetFillType(path, OH_Drawing_PathFillType::PATH_FILL_TYPE_EVEN_ODD); + // 移动到起始点 + OH_Drawing_PathMoveTo(path, startX + value15_, startY); + // 添加线段 + OH_Drawing_PathLineTo(path, startX + value15_, startY + value150_); + OH_Drawing_PathLineTo(path, startX + w - value15_, startY + value150_); + // 闭合路径 + OH_Drawing_PathClose(path); + // 判断路径是否包含坐标点 + SAMPLE_LOGI("PathBasic-->contains:%{public}d", + OH_Drawing_PathContains(path, startX + value30_, startY + value100_) ? 1 : 0); + // 判断路径是否闭合 + SAMPLE_LOGI("PathBasic-->isClosed:%{public}d", OH_Drawing_PathIsClosed(path, false) ? 1 : 0); + // 获取路径长度 + SAMPLE_LOGI("PathBasic-->getLength:%{public}f", OH_Drawing_PathGetLength(path, false)); + OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 0, 0); + // 获取边界 + OH_Drawing_PathGetBounds(path, rect); + SAMPLE_LOGI("PathBasic-->getBounds:left=%{public}f,top=%{public}f,right=%{public}f,bottom=%{public}f", + OH_Drawing_RectGetLeft(rect), OH_Drawing_RectGetTop(rect), OH_Drawing_RectGetRight(rect), + OH_Drawing_RectGetBottom(rect)); + OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); + // 获取变换矩阵 + OH_Drawing_PathGetMatrix(path, false, value50_, matrix, OH_Drawing_PathMeasureMatrixFlags::GET_POSITION_MATRIX); + OH_Drawing_Point2D point{startX + value30_, startY + value150_}; + OH_Drawing_Point2D tangent{0, 0}; + // 获取坐标点和切线 + OH_Drawing_PathGetPositionTangent(path, false, 1, &point, &tangent); + SAMPLE_LOGI("PathBasic-->tangent.x=%{public}f,tangent.y=%{public}f", tangent.x, tangent.y); + OH_Drawing_MatrixDestroy(matrix); + return path; +} + +void SampleGraphics::DrawPathBasic(OH_Drawing_Canvas *canvas) +{ + int32_t w = width_ / indexFive_; + float startX = 0; + float startY = value100_; + OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetAntiAlias(pen, true); + float penWidth = 3.f; + OH_Drawing_PenSetWidth(pen, penWidth); + OH_Drawing_CanvasAttachPen(canvas, pen); + + // 三角形1 + OH_Drawing_Path *path = DrawPathBasicTriangle(startX, startY, w); + OH_Drawing_CanvasDrawPath(canvas, path); + + // 三角形2 + // 复制路径 + OH_Drawing_Path *path_copy = OH_Drawing_PathCopy(path); + OH_Drawing_Matrix *matrix_translate = OH_Drawing_MatrixCreateTranslation(w, 0); + // 对路径进行矩阵变换 + OH_Drawing_PathTransform(path_copy, matrix_translate); + OH_Drawing_CanvasDrawPath(canvas, path_copy); + + // 三角形3 + OH_Drawing_Path *path_third = OH_Drawing_PathCreate(); + // 对路径进行矩阵变换 + OH_Drawing_PathTransformWithPerspectiveClip(path_copy, matrix_translate, path_third, false); + OH_Drawing_CanvasDrawPath(canvas, path_third); + + // 三角形4 + OH_Drawing_Path *path_fourth = OH_Drawing_PathCreate(); + OH_Drawing_PathOffset(path, path_fourth, w * indexThree_, 0); + OH_Drawing_CanvasDrawPath(canvas, path_fourth); + + // 梯形 + startX += indexFour_ * w; + OH_Drawing_Path *path_fifth = OH_Drawing_PathCreate(); + OH_Drawing_PathMoveTo(path_fifth, startX + value15_, startY); + OH_Drawing_PathLineTo(path_fifth, startX + value15_, startY + value100_); + OH_Drawing_PathLineTo(path_fifth, startX + w - value15_, startY + value100_); + OH_Drawing_PathTransform(path_fourth, matrix_translate); + // 将两个路径合并(取差集) + OH_Drawing_PathOp(path_fifth, path_fourth, OH_Drawing_PathOpMode::PATH_OP_MODE_REVERSE_DIFFERENCE); + OH_Drawing_CanvasDrawPath(canvas, path_fifth); + + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_PathDestroy(path); + OH_Drawing_PathDestroy(path_copy); + OH_Drawing_PathDestroy(path_third); + OH_Drawing_PathDestroy(path_fourth); + OH_Drawing_PathDestroy(path_fifth); + OH_Drawing_MatrixDestroy(matrix_translate); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::DrawPathTo1Line(OH_Drawing_Canvas *canvas) +{ + int32_t w = width_ / indexFive_; + float startX = 0; + float startY = value100_; + OH_Drawing_Path *path = OH_Drawing_PathCreate(); + + // 线段 + OH_Drawing_PathMoveTo(path, startX + value15_, startY + value70_); + OH_Drawing_PathLineTo(path, startX + w - value15_, startY + value70_); + OH_Drawing_CanvasDrawPath(canvas, path); + + // 弧线 + startX += w; + OH_Drawing_PathReset(path); + float startDeg = 60; + float sweepDeg = -240; + OH_Drawing_PathArcTo(path, startX + value15_, startY + value30_, startX + w - value15_, startY + value150_, + startDeg, sweepDeg); + OH_Drawing_CanvasDrawPath(canvas, path); + + // 二阶贝塞尔曲线 + startX += w; + OH_Drawing_PathReset(path); + OH_Drawing_PathMoveTo(path, startX + value15_, startY); + OH_Drawing_PathQuadTo(path, startX + value30_, startY + value100_, startX + w - value15_, startY + value150_); + OH_Drawing_CanvasDrawPath(canvas, path); + + // 二阶贝塞尔曲线(带权重) + startX += w; + OH_Drawing_PathReset(path); + OH_Drawing_PathMoveTo(path, startX + value15_, startY); + float weight = 5.f; + OH_Drawing_PathConicTo(path, startX + value30_, startY + value100_, startX + w - value15_, startY + value150_, + weight); + OH_Drawing_CanvasDrawPath(canvas, path); + + // 三阶贝塞尔曲线 + startX += w; + OH_Drawing_PathReset(path); + OH_Drawing_PathMoveTo(path, startX + value15_, startY); + OH_Drawing_PathCubicTo(path, startX + value30_, startY + value120_, startX + w - value30_, startY + value30_, + startX + w - value15_, startY + value150_); + OH_Drawing_CanvasDrawPath(canvas, path); + + OH_Drawing_PathDestroy(path); +} + +void SampleGraphics::DrawPathTo2Line(OH_Drawing_Canvas *canvas) +{ + int32_t w = width_ / indexFive_; + float startX = 0; + float startY = value300_; + OH_Drawing_Path *path = OH_Drawing_PathCreate(); + + // 线段 + OH_Drawing_PathMoveTo(path, startX, startY); + OH_Drawing_PathRMoveTo(path, value15_, value70_); + OH_Drawing_PathRLineTo(path, w - value30_, 0); + OH_Drawing_CanvasDrawPath(canvas, path); + + // 二阶贝塞尔曲线 + startX += w; + OH_Drawing_PathReset(path); + OH_Drawing_PathMoveTo(path, startX + value15_, startY); + OH_Drawing_PathRQuadTo(path, value30_, value100_, w - value10_, value150_); + OH_Drawing_CanvasDrawPath(canvas, path); + + // 二阶贝塞尔曲线(带权重) + startX += w; + OH_Drawing_PathReset(path); + OH_Drawing_PathMoveTo(path, startX + value15_, startY); + float weight = 5.f; + OH_Drawing_PathRConicTo(path, value30_, value100_, w - value15_, value150_, weight); + OH_Drawing_CanvasDrawPath(canvas, path); + + // 三阶贝塞尔曲线 + startX += w; + OH_Drawing_PathReset(path); + OH_Drawing_PathMoveTo(path, startX + value15_, startY); + OH_Drawing_PathRCubicTo(path, value30_, value120_, w - value30_, value30_, w - value10_, value150_); + OH_Drawing_CanvasDrawPath(canvas, path); + + OH_Drawing_PathDestroy(path); +} + +void SampleGraphics::DrawPathTo(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetAntiAlias(pen, true); + float penWidth = 3.f; + OH_Drawing_PenSetWidth(pen, penWidth); + OH_Drawing_CanvasAttachPen(canvas, pen); + + DrawPathTo1Line(canvas); + OH_Drawing_CanvasTranslate(canvas, 0, value200_); + DrawPathTo2Line(canvas); + + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::DrawPathAdd1Line(OH_Drawing_Canvas *canvas) +{ + int32_t w = width_ / indexFive_; + float startX = 0; + float startY = value100_; + // 圆 + OH_Drawing_Path *pathCircle = OH_Drawing_PathCreate(); + float radius = 40; + float startYAdded = 60; + OH_Drawing_PathAddCircle(pathCircle, startX + w / indexTwo_, startY + startYAdded, radius, PATH_DIRECTION_CCW); + OH_Drawing_CanvasDrawPath(canvas, pathCircle); + OH_Drawing_PathDestroy(pathCircle); + // 矩形 + startX += w; + OH_Drawing_Path *pathRect = OH_Drawing_PathCreate(); + OH_Drawing_PathAddRect(pathRect, startX + value10_, startY + value30_, startX + w - value10_, + startY + value90_, PATH_DIRECTION_CCW); + OH_Drawing_CanvasDrawPath(canvas, pathRect); + OH_Drawing_PathDestroy(pathRect); + // 椭圆 + startX += w; + OH_Drawing_Path *pathOval = OH_Drawing_PathCreate(); + OH_Drawing_Rect *rectOval = OH_Drawing_RectCreate(startX + value10_, startY + value30_, + startX + w - value10_, startY + value90_); + OH_Drawing_PathAddOval(pathOval, rectOval, OH_Drawing_PathDirection::PATH_DIRECTION_CW); + OH_Drawing_CanvasDrawPath(canvas, pathOval); + OH_Drawing_RectDestroy(rectOval); + OH_Drawing_PathDestroy(pathOval); + // 圆角矩形 + startX += w; + OH_Drawing_Path *pathRoundRect = OH_Drawing_PathCreate(); + OH_Drawing_Rect *rectRoundRect = OH_Drawing_RectCreate(startX + value10_, startY + value30_, + startX + w - value10_, startY + value90_); + OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rectRoundRect, value20_, value20_); + OH_Drawing_PathAddRoundRect(pathRoundRect, roundRect, PATH_DIRECTION_CCW); + OH_Drawing_CanvasDrawPath(canvas, pathRoundRect); + OH_Drawing_RectDestroy(rectRoundRect); + OH_Drawing_PathDestroy(pathRoundRect); + OH_Drawing_RoundRectDestroy(roundRect); +} + +void SampleGraphics::DrawPathAdd2Line(OH_Drawing_Canvas *canvas) +{ + int32_t w = width_ / indexFive_; + float startX = 0; + float startY = value100_; + // 多边形 + OH_Drawing_Path *pathPolygon = OH_Drawing_PathCreate(); + float leftPointX = startX + value10_; + float rightPointX = startX + w - value10_; + float middlePointX = (leftPointX + rightPointX) / 2; + OH_Drawing_Point2D points[] = {{middlePointX, startY + value30_}, {leftPointX, startY + value90_}, + {rightPointX, startY + value90_}}; + OH_Drawing_PathAddPolygon(pathPolygon, points, 3, true); // 3 is the size of point array + OH_Drawing_CanvasDrawPath(canvas, pathPolygon); + OH_Drawing_PathDestroy(pathPolygon); + // 曲线 + startX += w; + OH_Drawing_Rect *rectArc = OH_Drawing_RectCreate(startX - value30_, startY + value30_, + startX + w - value10_, startY + value150_); + OH_Drawing_Path *pathArc = OH_Drawing_PathCreate(); + OH_Drawing_PathAddArc(pathArc, rectArc, 0, -value90_); + OH_Drawing_CanvasDrawPath(canvas, pathArc); + OH_Drawing_RectDestroy(rectArc); + OH_Drawing_PathDestroy(pathArc); +} + +void SampleGraphics::DrawPathAdd3Line(OH_Drawing_Canvas *canvas) +{ + int32_t w = width_ / indexFive_; + float startX = 0; + float startY = value100_; + // 线段1 + OH_Drawing_Path *pathOuter1 = OH_Drawing_PathCreate(); + OH_Drawing_Path *pathInner1 = OH_Drawing_PathCreate(); + OH_Drawing_PathMoveTo(pathInner1, startX + value10_, startY); + OH_Drawing_PathLineTo(pathInner1, startX + w - value10_, startY); + OH_Drawing_Matrix *matrix1 = OH_Drawing_MatrixCreateTranslation(0, value50_); + OH_Drawing_PathAddPath(pathOuter1, pathInner1, matrix1); + OH_Drawing_CanvasDrawPath(canvas, pathOuter1); + OH_Drawing_PathDestroy(pathOuter1); + OH_Drawing_PathDestroy(pathInner1); + OH_Drawing_MatrixDestroy(matrix1); + // 线段2 + startX += w; + OH_Drawing_Path *pathOuter2 = OH_Drawing_PathCreate(); + OH_Drawing_Path *pathInner2 = OH_Drawing_PathCreate(); + OH_Drawing_PathMoveTo(pathInner2, startX + value10_, startY + value50_); + OH_Drawing_PathLineTo(pathInner2, startX + w - value10_, startY + value50_); + OH_Drawing_PathAddPathWithMode(pathOuter2, pathInner2, OH_Drawing_PathAddMode::PATH_ADD_MODE_APPEND); + OH_Drawing_CanvasDrawPath(canvas, pathOuter2); + OH_Drawing_PathDestroy(pathOuter2); + OH_Drawing_PathDestroy(pathInner2); + // 线段3 + startX += w; + OH_Drawing_Path *pathOuter3 = OH_Drawing_PathCreate(); + OH_Drawing_Path *pathInner3 = OH_Drawing_PathCreate(); + OH_Drawing_PathMoveTo(pathInner3, startX + value10_, startY); + OH_Drawing_PathLineTo(pathInner3, startX + w - value10_, startY); + OH_Drawing_PathAddPathWithOffsetAndMode(pathOuter3, pathInner3, 0, value50_, + OH_Drawing_PathAddMode::PATH_ADD_MODE_APPEND); + OH_Drawing_CanvasDrawPath(canvas, pathOuter3); + OH_Drawing_PathDestroy(pathOuter3); + OH_Drawing_PathDestroy(pathInner3); + // 线段4 + startX += w; + OH_Drawing_Path *pathOuter4 = OH_Drawing_PathCreate(); + OH_Drawing_Path *pathInner4 = OH_Drawing_PathCreate(); + OH_Drawing_PathMoveTo(pathInner4, startX + value10_, startY); + OH_Drawing_PathLineTo(pathInner4, startX + w - value10_, startY); + OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateTranslation(0, value50_); + OH_Drawing_PathAddPathWithMatrixAndMode(pathOuter4, pathInner4, matrix2, + OH_Drawing_PathAddMode::PATH_ADD_MODE_APPEND); + OH_Drawing_CanvasDrawPath(canvas, pathOuter4); + OH_Drawing_PathDestroy(pathOuter4); + OH_Drawing_PathDestroy(pathInner4); + OH_Drawing_MatrixDestroy(matrix2); +} + +void SampleGraphics::DrawPathAdd4Line(OH_Drawing_Canvas *canvas) +{ + int32_t w = width_ / indexFive_; + float startX = 0; + float startY = value100_; + // 椭圆 + OH_Drawing_Path *pathOval = OH_Drawing_PathCreate(); + OH_Drawing_Rect *rectOval = OH_Drawing_RectCreate(startX + value10_, startY + value30_, + startX + w - value10_, startY + value90_); + OH_Drawing_PathAddOvalWithInitialPoint(pathOval, rectOval, 1, OH_Drawing_PathDirection::PATH_DIRECTION_CW); + OH_Drawing_CanvasDrawPath(canvas, pathOval); + OH_Drawing_RectDestroy(rectOval); + OH_Drawing_PathDestroy(pathOval); + // 矩形 + startX += w; + OH_Drawing_Path *pathRect = OH_Drawing_PathCreate(); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(startX + value10_, startY + value30_, + startX + w - value10_, startY + value90_); + OH_Drawing_PathAddRectWithInitialCorner(pathRect, rect, PATH_DIRECTION_CCW, 1); + OH_Drawing_CanvasDrawPath(canvas, pathRect); + OH_Drawing_PathDestroy(pathRect); + OH_Drawing_RectDestroy(rect); +} + +void SampleGraphics::DrawPathAdd(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetAntiAlias(pen, true); + float penWidth = 3.f; + OH_Drawing_PenSetWidth(pen, penWidth); + OH_Drawing_CanvasAttachPen(canvas, pen); + + DrawPathAdd1Line(canvas); + OH_Drawing_CanvasTranslate(canvas, 0, value200_); + DrawPathAdd2Line(canvas); + OH_Drawing_CanvasTranslate(canvas, 0, value200_); + DrawPathAdd3Line(canvas); + OH_Drawing_CanvasTranslate(canvas, 0, value200_); + DrawPathAdd4Line(canvas); + + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_PenDestroy(pen); +} + +void SampleGraphics::BuildFromSvgString(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_CanvasAttachBrush(canvas, brush); + char* str = "M150 130L30 300L270 300Z"; + OH_Drawing_Path* path = OH_Drawing_PathCreate(); + // 通过svg构建path + OH_Drawing_PathBuildFromSvgString(path, str); + OH_Drawing_CanvasDrawPath(canvas, path); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_BrushDestroy(brush); + OH_Drawing_PathDestroy(path); +} + +void SampleGraphics::DrawStar(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + OH_Drawing_PenSetJoin(pen, LINE_ROUND_JOIN); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMax_, rgbaMin_)); + OH_Drawing_CanvasAttachBrush(canvas, brush); + int len = value551_; + float aX = value630_; + float aY = value551_; + float angle = 18.0f; + float dX = aX - len * std::sin(angle); + float dY = aY + len * std::cos(angle); + float cX = aX + len * std::sin(angle); + float cY = dY; + float bX = aX + (len / 2.0); + float bY = aY + std::sqrt((cX - dX) * (cX - dX) + (len / 2.0) * (len / 2.0)); + float eX = aX - (len / 2.0); + float eY = bY; + // 创建路径 + OH_Drawing_Path* path = OH_Drawing_PathCreate(); + // 到起始点 + OH_Drawing_PathMoveTo(path, aX, aY); + // 绘制直线 + OH_Drawing_PathLineTo(path, bX, bY); + OH_Drawing_PathLineTo(path, cX, cY); + OH_Drawing_PathLineTo(path, dX, dY); + OH_Drawing_PathLineTo(path, eX, eY); + // 直线闭合,形成五角星 + OH_Drawing_PathClose(path); + // 绘制闭合路径 + OH_Drawing_CanvasDrawPath(canvas, path); + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_PenDestroy(pen); + OH_Drawing_BrushDestroy(brush); + OH_Drawing_PathDestroy(path); } \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_pen.cpp b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_pen.cpp index a95bd5bb0f..acfd52e305 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_pen.cpp +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_pen.cpp @@ -1,243 +1,243 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sample_graphics.h" - -void SampleGraphics::DrawPenBasic(OH_Drawing_Canvas *canvas) -{ - // 创建画笔对象 - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - // 设置画笔描边颜色为红色 - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - // 设置画笔线宽为20 - OH_Drawing_PenSetWidth(pen, value20_); - // 设置抗锯齿 - OH_Drawing_PenSetAntiAlias(pen, true); - // 在画布中设置画笔 - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(value100_, value100_, value400_, value400_); - // 绘制矩形1 - OH_Drawing_CanvasDrawRect(canvas, rect1); - OH_Drawing_CanvasDetachPen(canvas); - // 复制画笔 - OH_Drawing_Pen* pen_copy = OH_Drawing_PenCopy(pen); - - // 画刷重置 - OH_Drawing_PenReset(pen); - // 设置画笔线宽为20 - OH_Drawing_PenSetWidth(pen, value20_); - // 设置透明度 - OH_Drawing_PenSetAlpha(pen, rgbaHalf_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(value500_, value500_, value800_, value800_); - // 绘制矩形2 - OH_Drawing_CanvasDrawRect(canvas, rect2); - OH_Drawing_CanvasDetachPen(canvas); - - OH_Drawing_CanvasAttachPen(canvas, pen_copy); - OH_Drawing_Rect* rect3 = OH_Drawing_RectCreate(value900_, value900_, value1200_, value1200_); - // 绘制矩形3 - OH_Drawing_CanvasDrawRect(canvas, rect3); - OH_Drawing_CanvasDetachBrush(canvas); - - // 销毁各类对象 - OH_Drawing_PenDestroy(pen); - OH_Drawing_PenDestroy(pen_copy); - OH_Drawing_RectDestroy(rect1); - OH_Drawing_RectDestroy(rect2); - OH_Drawing_RectDestroy(rect3); -} - -void SampleGraphics::DrawPenLinearGradient(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Point *startPt = OH_Drawing_PointCreate(value120_, value120_); - OH_Drawing_Point *endPt = OH_Drawing_PointCreate(value1000_, value1000_); - uint32_t colors[] = { - OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMax_, rgbaMin_), - OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_), - OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMin_, rgbaMax_)}; - float pos2 = 0.5f; - float pos[] = {0.0f, pos2, 1.0f}; - // 创建线性渐变着色器效果 - OH_Drawing_ShaderEffect *shaderEffect = - OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, 3, OH_Drawing_TileMode::CLAMP); - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetWidth(pen, value150_); - // 基于画笔设置着色器效果 - OH_Drawing_PenSetShaderEffect(pen, shaderEffect); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value200_, value200_, value1000_, value1000_); - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachPen(canvas); - // 销毁各类对象 - OH_Drawing_PenDestroy(pen); - OH_Drawing_RectDestroy(rect); - OH_Drawing_ShaderEffectDestroy(shaderEffect); - OH_Drawing_PointDestroy(startPt); - OH_Drawing_PointDestroy(endPt); -} - -void SampleGraphics::DrawMiterLimit(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - uint32_t color = OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_); - OH_Drawing_PenSetColor(pen, color); - float width = value50_; - OH_Drawing_PenSetWidth(pen, width); - OH_Drawing_PenSetAntiAlias(pen, true); - // 设置画笔转角样式 - OH_Drawing_PenSetJoin(pen, OH_Drawing_PenLineJoinStyle::LINE_MITER_JOIN); - // 设置折角尖角的限制值 - OH_Drawing_PenSetMiterLimit(pen, value15_); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Path* path = OH_Drawing_PathCreate(); - float aX = value100_; - float aY = value100_; - float bX = value100_; - float bY = value800_; - float cX = value200_; - float cY = value100_; - OH_Drawing_PathMoveTo(path, aX, aY); - OH_Drawing_PathLineTo(path, bX, bY); - OH_Drawing_PathLineTo(path, cX, cY); - OH_Drawing_CanvasDrawPath(canvas, path); - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_PenDestroy(pen); - OH_Drawing_PathDestroy(path); -} - -void SampleGraphics::DrawStroke(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); - uint32_t color = OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_); - OH_Drawing_PenSetColor(pen, color); - float width = value50_; - OH_Drawing_PenSetWidth(pen, width); - OH_Drawing_PenSetAntiAlias(pen, true); - // 设置画笔线帽样式 - OH_Drawing_PenSetCap(pen, OH_Drawing_PenLineCapStyle::LINE_ROUND_CAP); - // 设置画笔转角样式 - OH_Drawing_PenSetJoin(pen, OH_Drawing_PenLineJoinStyle::LINE_BEVEL_JOIN); - OH_Drawing_CanvasAttachPen(canvas, pen); - // 创建路径 - OH_Drawing_Path* path = OH_Drawing_PathCreate(); - float aX = value100_; - float aY = value100_; - float bX = value100_; - float bY = value800_; - float cX = value800_; - float cY = value800_; - float dX = value800_; - float dY = value100_; - // 到起始点 - OH_Drawing_PathMoveTo(path, aX, aY); - // 绘制直线 - OH_Drawing_PathLineTo(path, bX, bY); - OH_Drawing_PathLineTo(path, cX, cY); - OH_Drawing_PathLineTo(path, dX, dY); - OH_Drawing_CanvasDrawPath(canvas, path); - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_PenDestroy(pen); - OH_Drawing_PathDestroy(path); -} - -void SampleGraphics::DrawPathEffect(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value10_); - // 表示10px的实线,5px的间隔,2px的实线,5px的间隔,以此循环 - float intervals[] = {value10_, 5, 2, 5}; - // 创建虚线路径效果 - int count = 4; - OH_Drawing_PathEffect *pathEffect = OH_Drawing_CreateDashPathEffect(intervals, count, 0.0); - OH_Drawing_PenSetPathEffect(pen, pathEffect); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value900_, value900_); - // 绘制矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachPen(canvas); - OH_Drawing_PenDestroy(pen); - OH_Drawing_RectDestroy(rect); - OH_Drawing_PathEffectDestroy(pathEffect); -} - -void SampleGraphics::DrawImageFilter(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetAntiAlias(pen, true); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value20_); - // 创建图像滤波器实现模糊效果 - OH_Drawing_ImageFilter *imageFilter = - OH_Drawing_ImageFilterCreateBlur(value20_, value20_, OH_Drawing_TileMode::CLAMP, nullptr); - OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); - // 为滤波器对象设置图像滤波器 - OH_Drawing_FilterSetImageFilter(filter, imageFilter); - // 设置画笔的滤波器效果 - OH_Drawing_PenSetFilter(pen, filter); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value900_, value900_); - // 绘制矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachPen(canvas); - // 销毁各类对象 - OH_Drawing_PenDestroy(pen); - OH_Drawing_ImageFilterDestroy(imageFilter); - OH_Drawing_RectDestroy(rect); - OH_Drawing_FilterDestroy(filter); -} - -void SampleGraphics::DrawMaskFilterPen(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); - OH_Drawing_PenSetAntiAlias(pen, true); - OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_PenSetWidth(pen, value20_); - // 创建蒙版滤波器 - OH_Drawing_MaskFilter *maskFilter = OH_Drawing_MaskFilterCreateBlur(OH_Drawing_BlurType::NORMAL, value20_, true); - OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); - OH_Drawing_FilterSetMaskFilter(filter, maskFilter); - // 设置画笔的滤波器效果 - OH_Drawing_PenSetFilter(pen, filter); - OH_Drawing_CanvasAttachPen(canvas, pen); - OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value600_); - // 绘制矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDetachPen(canvas); - // 销毁各类对象 - OH_Drawing_PenDestroy(pen); - OH_Drawing_MaskFilterDestroy(maskFilter); - OH_Drawing_RectDestroy(rect); - OH_Drawing_FilterDestroy(filter); -} +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sample_graphics.h" + +void SampleGraphics::DrawPenBasic(OH_Drawing_Canvas *canvas) +{ + // 创建画笔对象 + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + // 设置画笔描边颜色为红色 + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + // 设置画笔线宽为20 + OH_Drawing_PenSetWidth(pen, value20_); + // 设置抗锯齿 + OH_Drawing_PenSetAntiAlias(pen, true); + // 在画布中设置画笔 + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(value100_, value100_, value400_, value400_); + // 绘制矩形1 + OH_Drawing_CanvasDrawRect(canvas, rect1); + OH_Drawing_CanvasDetachPen(canvas); + // 复制画笔 + OH_Drawing_Pen* pen_copy = OH_Drawing_PenCopy(pen); + + // 画刷重置 + OH_Drawing_PenReset(pen); + // 设置画笔线宽为20 + OH_Drawing_PenSetWidth(pen, value20_); + // 设置透明度 + OH_Drawing_PenSetAlpha(pen, rgbaHalf_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(value500_, value500_, value800_, value800_); + // 绘制矩形2 + OH_Drawing_CanvasDrawRect(canvas, rect2); + OH_Drawing_CanvasDetachPen(canvas); + + OH_Drawing_CanvasAttachPen(canvas, pen_copy); + OH_Drawing_Rect* rect3 = OH_Drawing_RectCreate(value900_, value900_, value1200_, value1200_); + // 绘制矩形3 + OH_Drawing_CanvasDrawRect(canvas, rect3); + OH_Drawing_CanvasDetachBrush(canvas); + + // 销毁各类对象 + OH_Drawing_PenDestroy(pen); + OH_Drawing_PenDestroy(pen_copy); + OH_Drawing_RectDestroy(rect1); + OH_Drawing_RectDestroy(rect2); + OH_Drawing_RectDestroy(rect3); +} + +void SampleGraphics::DrawPenLinearGradient(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Point *startPt = OH_Drawing_PointCreate(value120_, value120_); + OH_Drawing_Point *endPt = OH_Drawing_PointCreate(value1000_, value1000_); + uint32_t colors[] = { + OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMax_, rgbaMin_), + OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_), + OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMin_, rgbaMin_, rgbaMax_)}; + float pos2 = 0.5f; + float pos[] = {0.0f, pos2, 1.0f}; + // 创建线性渐变着色器效果 + OH_Drawing_ShaderEffect *shaderEffect = + OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, 3, OH_Drawing_TileMode::CLAMP); + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetWidth(pen, value150_); + // 基于画笔设置着色器效果 + OH_Drawing_PenSetShaderEffect(pen, shaderEffect); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value200_, value200_, value1000_, value1000_); + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachPen(canvas); + // 销毁各类对象 + OH_Drawing_PenDestroy(pen); + OH_Drawing_RectDestroy(rect); + OH_Drawing_ShaderEffectDestroy(shaderEffect); + OH_Drawing_PointDestroy(startPt); + OH_Drawing_PointDestroy(endPt); +} + +void SampleGraphics::DrawMiterLimit(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + uint32_t color = OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_); + OH_Drawing_PenSetColor(pen, color); + float width = value50_; + OH_Drawing_PenSetWidth(pen, width); + OH_Drawing_PenSetAntiAlias(pen, true); + // 设置画笔转角样式 + OH_Drawing_PenSetJoin(pen, OH_Drawing_PenLineJoinStyle::LINE_MITER_JOIN); + // 设置折角尖角的限制值 + OH_Drawing_PenSetMiterLimit(pen, value15_); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Path* path = OH_Drawing_PathCreate(); + float aX = value100_; + float aY = value100_; + float bX = value100_; + float bY = value800_; + float cX = value200_; + float cY = value100_; + OH_Drawing_PathMoveTo(path, aX, aY); + OH_Drawing_PathLineTo(path, bX, bY); + OH_Drawing_PathLineTo(path, cX, cY); + OH_Drawing_CanvasDrawPath(canvas, path); + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_PenDestroy(pen); + OH_Drawing_PathDestroy(path); +} + +void SampleGraphics::DrawStroke(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + uint32_t color = OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_); + OH_Drawing_PenSetColor(pen, color); + float width = value50_; + OH_Drawing_PenSetWidth(pen, width); + OH_Drawing_PenSetAntiAlias(pen, true); + // 设置画笔线帽样式 + OH_Drawing_PenSetCap(pen, OH_Drawing_PenLineCapStyle::LINE_ROUND_CAP); + // 设置画笔转角样式 + OH_Drawing_PenSetJoin(pen, OH_Drawing_PenLineJoinStyle::LINE_BEVEL_JOIN); + OH_Drawing_CanvasAttachPen(canvas, pen); + // 创建路径 + OH_Drawing_Path* path = OH_Drawing_PathCreate(); + float aX = value100_; + float aY = value100_; + float bX = value100_; + float bY = value800_; + float cX = value800_; + float cY = value800_; + float dX = value800_; + float dY = value100_; + // 到起始点 + OH_Drawing_PathMoveTo(path, aX, aY); + // 绘制直线 + OH_Drawing_PathLineTo(path, bX, bY); + OH_Drawing_PathLineTo(path, cX, cY); + OH_Drawing_PathLineTo(path, dX, dY); + OH_Drawing_CanvasDrawPath(canvas, path); + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_PenDestroy(pen); + OH_Drawing_PathDestroy(path); +} + +void SampleGraphics::DrawPathEffect(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value10_); + // 表示10px的实线,5px的间隔,2px的实线,5px的间隔,以此循环 + float intervals[] = {value10_, 5, 2, 5}; + // 创建虚线路径效果 + int count = 4; + OH_Drawing_PathEffect *pathEffect = OH_Drawing_CreateDashPathEffect(intervals, count, 0.0); + OH_Drawing_PenSetPathEffect(pen, pathEffect); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value900_, value900_); + // 绘制矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachPen(canvas); + OH_Drawing_PenDestroy(pen); + OH_Drawing_RectDestroy(rect); + OH_Drawing_PathEffectDestroy(pathEffect); +} + +void SampleGraphics::DrawImageFilter(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetAntiAlias(pen, true); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value20_); + // 创建图像滤波器实现模糊效果 + OH_Drawing_ImageFilter *imageFilter = + OH_Drawing_ImageFilterCreateBlur(value20_, value20_, OH_Drawing_TileMode::CLAMP, nullptr); + OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); + // 为滤波器对象设置图像滤波器 + OH_Drawing_FilterSetImageFilter(filter, imageFilter); + // 设置画笔的滤波器效果 + OH_Drawing_PenSetFilter(pen, filter); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value900_, value900_); + // 绘制矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachPen(canvas); + // 销毁各类对象 + OH_Drawing_PenDestroy(pen); + OH_Drawing_ImageFilterDestroy(imageFilter); + OH_Drawing_RectDestroy(rect); + OH_Drawing_FilterDestroy(filter); +} + +void SampleGraphics::DrawMaskFilterPen(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); + OH_Drawing_PenSetAntiAlias(pen, true); + OH_Drawing_PenSetColor(pen, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_PenSetWidth(pen, value20_); + // 创建蒙版滤波器 + OH_Drawing_MaskFilter *maskFilter = OH_Drawing_MaskFilterCreateBlur(OH_Drawing_BlurType::NORMAL, value20_, true); + OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); + OH_Drawing_FilterSetMaskFilter(filter, maskFilter); + // 设置画笔的滤波器效果 + OH_Drawing_PenSetFilter(pen, filter); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_Rect *rect = OH_Drawing_RectCreate(value300_, value300_, value600_, value600_); + // 绘制矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDetachPen(canvas); + // 销毁各类对象 + OH_Drawing_PenDestroy(pen); + OH_Drawing_MaskFilterDestroy(maskFilter); + OH_Drawing_RectDestroy(rect); + OH_Drawing_FilterDestroy(filter); +} diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_pixelmap.cpp b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_pixelmap.cpp index 0097d52e57..28626ca9bd 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_pixelmap.cpp +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_pixelmap.cpp @@ -1,163 +1,163 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sample_graphics.h" -#include "common/log_common.h" - -void SampleGraphics::DrawCustomPixelMap(OH_Drawing_Canvas *canvas) -{ - uint32_t width = 600; - uint32_t height = 400; - // 字节长度,RGBA_8888每个像素占4字节 - size_t bufferSize = width * height * 4; - uint8_t *pixels = new uint8_t[bufferSize]; - for (uint32_t i = 0; i < width * height; ++i) { - // 遍历并编辑每个像素,从而形成红绿蓝相间的条纹,间隔20 - uint32_t n = i / 20 % 3; - pixels[i * rgbaSize_] = rgbaMin_; - pixels[i * rgbaSize_ + indexOne_] = rgbaMin_; - pixels[i * rgbaSize_ + indexTwo_] = rgbaMin_; - pixels[i * rgbaSize_ + indexThree_] = rgbaMax_; - if (n == 0) { - pixels[i * rgbaSize_] = rgbaMax_; - } else if (n == 1) { - pixels[i * rgbaSize_ + indexOne_] = rgbaMax_; - } else { - pixels[i * rgbaSize_ + indexTwo_] = rgbaMax_; - } - } - // 设置位图格式(长、宽、颜色类型、透明度类型) - OH_Pixelmap_InitializationOptions *createOps = nullptr; - OH_PixelmapInitializationOptions_Create(&createOps); - OH_PixelmapInitializationOptions_SetWidth(createOps, width); - OH_PixelmapInitializationOptions_SetHeight(createOps, height); - OH_PixelmapInitializationOptions_SetPixelFormat(createOps, PIXEL_FORMAT_RGBA_8888); - OH_PixelmapInitializationOptions_SetAlphaType(createOps, PIXELMAP_ALPHA_TYPE_UNKNOWN); - // 创建OH_PixelmapNative对象 - OH_PixelmapNative *pixelMapNative = nullptr; - OH_PixelmapNative_CreatePixelmap(pixels, bufferSize, createOps, &pixelMapNative); - // 利用OH_PixelmapNative对象创建PixelMap对象 - OH_Drawing_PixelMap *pixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(pixelMapNative); - OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, width, height); - OH_Drawing_Rect *dst = OH_Drawing_RectCreate(value200_, value200_, value800_, value600_); - OH_Drawing_SamplingOptions* samplingOptions = OH_Drawing_SamplingOptionsCreate( - OH_Drawing_FilterMode::FILTER_MODE_LINEAR, OH_Drawing_MipmapMode::MIPMAP_MODE_LINEAR); - // 绘制PixelMap - OH_Drawing_CanvasDrawPixelMapRect(canvas, pixelMap, src, dst, samplingOptions); - OH_PixelmapNative_Release(pixelMapNative); - OH_Drawing_PixelMapDissolve(pixelMap); - OH_Drawing_RectDestroy(src); - OH_Drawing_RectDestroy(dst); - OH_Drawing_SamplingOptionsDestroy(samplingOptions); - delete[] pixels; -} - -void SampleGraphics::DrawPixelMapRect(OH_Drawing_Canvas *canvas) -{ - // 从NativePixelMap中获取PixelMap对象 - OH_Drawing_PixelMap *pixelMap = OH_Drawing_PixelMapGetFromNativePixelMap(nativePixelMap_); - OH_Drawing_SamplingOptions *sampling = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_LINEAR, MIPMAP_MODE_NONE); - float width = value400_; - float height = value400_; - OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, width, height); - OH_Drawing_Rect *dst = OH_Drawing_RectCreate(value100_, value100_, value700_, value700_); - // 绘制PixelMap - OH_Drawing_CanvasDrawPixelMapRect(canvas, pixelMap, src, dst, sampling); - // 解除NativePixelMap和PixelMap的关联 - OH_Drawing_PixelMapDissolve(pixelMap); - OH_Drawing_SamplingOptionsDestroy(sampling); - OH_Drawing_RectDestroy(src); - OH_Drawing_RectDestroy(dst); -} - -void SampleGraphics::DrawBitmap(OH_Drawing_Canvas *canvas) -{ - // 创建一个bitmap对象 - OH_Drawing_Bitmap* bitmap1 = OH_Drawing_BitmapCreate(); - OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE}; - uint64_t width = width_ / 2; - uint64_t height = height_ / 2; - // 构建bitmap对象 - OH_Drawing_BitmapBuild(bitmap1, width, height, &cFormat); - OH_Drawing_Canvas* newCanvas = OH_Drawing_CanvasCreate(); - OH_Drawing_CanvasBind(newCanvas, bitmap1); - OH_Drawing_CanvasClear(newCanvas, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - // 获取位图宽高 - SAMPLE_LOGI("Bitmap-->width=%{public}d,height=%{public}d", OH_Drawing_BitmapGetWidth(bitmap1), - OH_Drawing_BitmapGetHeight(bitmap1)); - // 获取像素 - void *pixels = OH_Drawing_BitmapGetPixels(bitmap1); - OH_Drawing_Image_Info imageInfo; - imageInfo.width = width; - imageInfo.height = height; - imageInfo.colorType = COLOR_FORMAT_RGBA_8888; - imageInfo.alphaType = ALPHA_FORMAT_OPAQUE; - // 通过像素创建一个bitmap对象 - OH_Drawing_Bitmap* bitmap2 = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, width * 4); - OH_Drawing_CanvasDrawBitmap(canvas, bitmap1, 0, 0); - OH_Drawing_CanvasDrawBitmap(canvas, bitmap2, width, height); - OH_Drawing_CanvasDestroy(newCanvas); - OH_Drawing_BitmapDestroy(bitmap1); - OH_Drawing_BitmapDestroy(bitmap2); -} - -void SampleGraphics::DrawImage(OH_Drawing_Canvas *canvas) -{ - // 创建一个bitmap对象 - OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate(); - OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE}; - uint64_t width = width_ / 2; - uint64_t height = height_ / 2; - OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat); - OH_Drawing_Canvas* newCanvas = OH_Drawing_CanvasCreate(); - OH_Drawing_CanvasBind(newCanvas, bitmap); - OH_Drawing_CanvasClear(newCanvas, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - // 创建image对象 - OH_Drawing_Image* image = OH_Drawing_ImageCreate(); - // 从bitmap构建image - OH_Drawing_ImageBuildFromBitmap(image, bitmap); - // 获取Image宽高 - SAMPLE_LOGI("Image-->width=%{public}d,height=%{public}d", OH_Drawing_ImageGetWidth(image), - OH_Drawing_ImageGetHeight(image)); - OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, width / 2, height / 2); - OH_Drawing_SamplingOptions* options = OH_Drawing_SamplingOptionsCreate( - OH_Drawing_FilterMode::FILTER_MODE_LINEAR, OH_Drawing_MipmapMode::MIPMAP_MODE_LINEAR); - OH_Drawing_CanvasDrawImageRect(canvas, image, rect, options); - // 销毁对象 - OH_Drawing_CanvasDestroy(newCanvas); - OH_Drawing_BitmapDestroy(bitmap); - OH_Drawing_ImageDestroy(image); - OH_Drawing_RectDestroy(rect); - OH_Drawing_SamplingOptionsDestroy(options); -} +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sample_graphics.h" +#include "common/log_common.h" + +void SampleGraphics::DrawCustomPixelMap(OH_Drawing_Canvas *canvas) +{ + uint32_t width = 600; + uint32_t height = 400; + // 字节长度,RGBA_8888每个像素占4字节 + size_t bufferSize = width * height * 4; + uint8_t *pixels = new uint8_t[bufferSize]; + for (uint32_t i = 0; i < width * height; ++i) { + // 遍历并编辑每个像素,从而形成红绿蓝相间的条纹,间隔20 + uint32_t n = i / 20 % 3; + pixels[i * rgbaSize_] = rgbaMin_; + pixels[i * rgbaSize_ + indexOne_] = rgbaMin_; + pixels[i * rgbaSize_ + indexTwo_] = rgbaMin_; + pixels[i * rgbaSize_ + indexThree_] = rgbaMax_; + if (n == 0) { + pixels[i * rgbaSize_] = rgbaMax_; + } else if (n == 1) { + pixels[i * rgbaSize_ + indexOne_] = rgbaMax_; + } else { + pixels[i * rgbaSize_ + indexTwo_] = rgbaMax_; + } + } + // 设置位图格式(长、宽、颜色类型、透明度类型) + OH_Pixelmap_InitializationOptions *createOps = nullptr; + OH_PixelmapInitializationOptions_Create(&createOps); + OH_PixelmapInitializationOptions_SetWidth(createOps, width); + OH_PixelmapInitializationOptions_SetHeight(createOps, height); + OH_PixelmapInitializationOptions_SetPixelFormat(createOps, PIXEL_FORMAT_RGBA_8888); + OH_PixelmapInitializationOptions_SetAlphaType(createOps, PIXELMAP_ALPHA_TYPE_UNKNOWN); + // 创建OH_PixelmapNative对象 + OH_PixelmapNative *pixelMapNative = nullptr; + OH_PixelmapNative_CreatePixelmap(pixels, bufferSize, createOps, &pixelMapNative); + // 利用OH_PixelmapNative对象创建PixelMap对象 + OH_Drawing_PixelMap *pixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(pixelMapNative); + OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, width, height); + OH_Drawing_Rect *dst = OH_Drawing_RectCreate(value200_, value200_, value800_, value600_); + OH_Drawing_SamplingOptions* samplingOptions = OH_Drawing_SamplingOptionsCreate( + OH_Drawing_FilterMode::FILTER_MODE_LINEAR, OH_Drawing_MipmapMode::MIPMAP_MODE_LINEAR); + // 绘制PixelMap + OH_Drawing_CanvasDrawPixelMapRect(canvas, pixelMap, src, dst, samplingOptions); + OH_PixelmapNative_Release(pixelMapNative); + OH_Drawing_PixelMapDissolve(pixelMap); + OH_Drawing_RectDestroy(src); + OH_Drawing_RectDestroy(dst); + OH_Drawing_SamplingOptionsDestroy(samplingOptions); + delete[] pixels; +} + +void SampleGraphics::DrawPixelMapRect(OH_Drawing_Canvas *canvas) +{ + // 从NativePixelMap中获取PixelMap对象 + OH_Drawing_PixelMap *pixelMap = OH_Drawing_PixelMapGetFromNativePixelMap(nativePixelMap_); + OH_Drawing_SamplingOptions *sampling = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_LINEAR, MIPMAP_MODE_NONE); + float width = value400_; + float height = value400_; + OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, width, height); + OH_Drawing_Rect *dst = OH_Drawing_RectCreate(value100_, value100_, value700_, value700_); + // 绘制PixelMap + OH_Drawing_CanvasDrawPixelMapRect(canvas, pixelMap, src, dst, sampling); + // 解除NativePixelMap和PixelMap的关联 + OH_Drawing_PixelMapDissolve(pixelMap); + OH_Drawing_SamplingOptionsDestroy(sampling); + OH_Drawing_RectDestroy(src); + OH_Drawing_RectDestroy(dst); +} + +void SampleGraphics::DrawBitmap(OH_Drawing_Canvas *canvas) +{ + // 创建一个bitmap对象 + OH_Drawing_Bitmap* bitmap1 = OH_Drawing_BitmapCreate(); + OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE}; + uint64_t width = width_ / 2; + uint64_t height = height_ / 2; + // 构建bitmap对象 + OH_Drawing_BitmapBuild(bitmap1, width, height, &cFormat); + OH_Drawing_Canvas* newCanvas = OH_Drawing_CanvasCreate(); + OH_Drawing_CanvasBind(newCanvas, bitmap1); + OH_Drawing_CanvasClear(newCanvas, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + // 获取位图宽高 + SAMPLE_LOGI("Bitmap-->width=%{public}d,height=%{public}d", OH_Drawing_BitmapGetWidth(bitmap1), + OH_Drawing_BitmapGetHeight(bitmap1)); + // 获取像素 + void *pixels = OH_Drawing_BitmapGetPixels(bitmap1); + OH_Drawing_Image_Info imageInfo; + imageInfo.width = width; + imageInfo.height = height; + imageInfo.colorType = COLOR_FORMAT_RGBA_8888; + imageInfo.alphaType = ALPHA_FORMAT_OPAQUE; + // 通过像素创建一个bitmap对象 + OH_Drawing_Bitmap* bitmap2 = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, width * 4); + OH_Drawing_CanvasDrawBitmap(canvas, bitmap1, 0, 0); + OH_Drawing_CanvasDrawBitmap(canvas, bitmap2, width, height); + OH_Drawing_CanvasDestroy(newCanvas); + OH_Drawing_BitmapDestroy(bitmap1); + OH_Drawing_BitmapDestroy(bitmap2); +} + +void SampleGraphics::DrawImage(OH_Drawing_Canvas *canvas) +{ + // 创建一个bitmap对象 + OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate(); + OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE}; + uint64_t width = width_ / 2; + uint64_t height = height_ / 2; + OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat); + OH_Drawing_Canvas* newCanvas = OH_Drawing_CanvasCreate(); + OH_Drawing_CanvasBind(newCanvas, bitmap); + OH_Drawing_CanvasClear(newCanvas, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + // 创建image对象 + OH_Drawing_Image* image = OH_Drawing_ImageCreate(); + // 从bitmap构建image + OH_Drawing_ImageBuildFromBitmap(image, bitmap); + // 获取Image宽高 + SAMPLE_LOGI("Image-->width=%{public}d,height=%{public}d", OH_Drawing_ImageGetWidth(image), + OH_Drawing_ImageGetHeight(image)); + OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, width / 2, height / 2); + OH_Drawing_SamplingOptions* options = OH_Drawing_SamplingOptionsCreate( + OH_Drawing_FilterMode::FILTER_MODE_LINEAR, OH_Drawing_MipmapMode::MIPMAP_MODE_LINEAR); + OH_Drawing_CanvasDrawImageRect(canvas, image, rect, options); + // 销毁对象 + OH_Drawing_CanvasDestroy(newCanvas); + OH_Drawing_BitmapDestroy(bitmap); + OH_Drawing_ImageDestroy(image); + OH_Drawing_RectDestroy(rect); + OH_Drawing_SamplingOptionsDestroy(options); +} diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_rect.cpp b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_rect.cpp index 2547fe6aea..2897cea514 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_rect.cpp +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/cpp/samples/sample_rect.cpp @@ -1,126 +1,126 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sample_graphics.h" -#include "common/log_common.h" - -void SampleGraphics::DrawRectBasic(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_BrushSetAntiAlias(brush, true); - OH_Drawing_CanvasAttachBrush(canvas, brush); - // 创建矩形对象 - OH_Drawing_Rect* rect = OH_Drawing_RectCreate(value200_, value200_, value500_, value500_); - OH_Drawing_Rect* rect_copy = OH_Drawing_RectCreate(0, 0, 0, 0); - OH_Drawing_RectCopy(rect, rect_copy); - // 设置矩形left,right,top,bottom - OH_Drawing_RectSetLeft(rect, value300_); - OH_Drawing_RectSetTop(rect, value300_); - OH_Drawing_RectSetRight(rect, value600_); - OH_Drawing_RectSetBottom(rect, value600_); - // 获取矩形left,right,top,bottom,width,height - SAMPLE_LOGI( - "left:%{public}f, right:%{public}f, top:%{public}f, bottom:%{public}f, width:%{public}f, height: %{public}f", - OH_Drawing_RectGetLeft(rect), OH_Drawing_RectGetRight(rect), OH_Drawing_RectGetTop(rect), - OH_Drawing_RectGetBottom(rect), OH_Drawing_RectGetWidth(rect), OH_Drawing_RectGetHeight(rect)); - SAMPLE_LOGI( - "left:%{public}f, right:%{public}f, top:%{public}f, bottom:%{public}f, width:%{public}f, height: %{public}f", - OH_Drawing_RectGetLeft(rect_copy), OH_Drawing_RectGetRight(rect_copy), OH_Drawing_RectGetTop(rect_copy), - OH_Drawing_RectGetBottom(rect_copy), OH_Drawing_RectGetWidth(rect_copy), OH_Drawing_RectGetHeight(rect_copy)); - // 绘制矩形 - OH_Drawing_CanvasDrawRect(canvas, rect); - OH_Drawing_CanvasDrawRect(canvas, rect_copy); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_BrushDestroy(brush); - OH_Drawing_RectDestroy(rect); - OH_Drawing_RectDestroy(rect_copy); -} - -void SampleGraphics::DrawRectIntersect(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_BrushSetAntiAlias(brush, true); - OH_Drawing_CanvasAttachBrush(canvas, brush); - // 创建矩形对象 - OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(value200_, value200_, value500_, value500_); - OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(value300_, value300_, value600_, value600_); - // 取交集 - OH_Drawing_RectIntersect(rect1, rect2); - // 绘制矩形 - OH_Drawing_CanvasDrawRect(canvas, rect1); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_BrushDestroy(brush); - OH_Drawing_RectDestroy(rect1); - OH_Drawing_RectDestroy(rect2); -} - -void SampleGraphics::DrawRectJoin(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_BrushSetAntiAlias(brush, true); - OH_Drawing_CanvasAttachBrush(canvas, brush); - // 创建矩形对象 - OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(value200_, value200_, value500_, value500_); - OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(value300_, value300_, value600_, value600_); - // 取并集 - OH_Drawing_RectJoin(rect1, rect2); - // 绘制矩形 - OH_Drawing_CanvasDrawRect(canvas, rect1); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_BrushDestroy(brush); - OH_Drawing_RectDestroy(rect1); - OH_Drawing_RectDestroy(rect2); -} - -void SampleGraphics::DrawRoundRect(OH_Drawing_Canvas *canvas) -{ - OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); - OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); - OH_Drawing_CanvasAttachBrush(canvas, brush); - // 创建矩形 - OH_Drawing_Rect* rect = OH_Drawing_RectCreate(value100_, value100_, value900_, value600_); - // 创建圆角矩形 - OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, value30_, value30_); - OH_Drawing_RoundRectSetCorner(roundRect, OH_Drawing_CornerPos::CORNER_POS_TOP_LEFT, {value50_, value50_}); - OH_Drawing_Corner_Radii p = OH_Drawing_RoundRectGetCorner(roundRect, OH_Drawing_CornerPos::CORNER_POS_TOP_LEFT); - SAMPLE_LOGI("top-left-corner:x=%{public}f, y:%{public}f", p.x, p.y); - // 绘制圆角矩形 - OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); - OH_Drawing_CanvasDetachBrush(canvas); - OH_Drawing_BrushDestroy(brush); - OH_Drawing_RectDestroy(rect); - OH_Drawing_RoundRectDestroy(roundRect); -} +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sample_graphics.h" +#include "common/log_common.h" + +void SampleGraphics::DrawRectBasic(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_BrushSetAntiAlias(brush, true); + OH_Drawing_CanvasAttachBrush(canvas, brush); + // 创建矩形对象 + OH_Drawing_Rect* rect = OH_Drawing_RectCreate(value200_, value200_, value500_, value500_); + OH_Drawing_Rect* rect_copy = OH_Drawing_RectCreate(0, 0, 0, 0); + OH_Drawing_RectCopy(rect, rect_copy); + // 设置矩形left,right,top,bottom + OH_Drawing_RectSetLeft(rect, value300_); + OH_Drawing_RectSetTop(rect, value300_); + OH_Drawing_RectSetRight(rect, value600_); + OH_Drawing_RectSetBottom(rect, value600_); + // 获取矩形left,right,top,bottom,width,height + SAMPLE_LOGI( + "left:%{public}f, right:%{public}f, top:%{public}f, bottom:%{public}f, width:%{public}f, height: %{public}f", + OH_Drawing_RectGetLeft(rect), OH_Drawing_RectGetRight(rect), OH_Drawing_RectGetTop(rect), + OH_Drawing_RectGetBottom(rect), OH_Drawing_RectGetWidth(rect), OH_Drawing_RectGetHeight(rect)); + SAMPLE_LOGI( + "left:%{public}f, right:%{public}f, top:%{public}f, bottom:%{public}f, width:%{public}f, height: %{public}f", + OH_Drawing_RectGetLeft(rect_copy), OH_Drawing_RectGetRight(rect_copy), OH_Drawing_RectGetTop(rect_copy), + OH_Drawing_RectGetBottom(rect_copy), OH_Drawing_RectGetWidth(rect_copy), OH_Drawing_RectGetHeight(rect_copy)); + // 绘制矩形 + OH_Drawing_CanvasDrawRect(canvas, rect); + OH_Drawing_CanvasDrawRect(canvas, rect_copy); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_BrushDestroy(brush); + OH_Drawing_RectDestroy(rect); + OH_Drawing_RectDestroy(rect_copy); +} + +void SampleGraphics::DrawRectIntersect(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_BrushSetAntiAlias(brush, true); + OH_Drawing_CanvasAttachBrush(canvas, brush); + // 创建矩形对象 + OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(value200_, value200_, value500_, value500_); + OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(value300_, value300_, value600_, value600_); + // 取交集 + OH_Drawing_RectIntersect(rect1, rect2); + // 绘制矩形 + OH_Drawing_CanvasDrawRect(canvas, rect1); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_BrushDestroy(brush); + OH_Drawing_RectDestroy(rect1); + OH_Drawing_RectDestroy(rect2); +} + +void SampleGraphics::DrawRectJoin(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Brush* brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_BrushSetAntiAlias(brush, true); + OH_Drawing_CanvasAttachBrush(canvas, brush); + // 创建矩形对象 + OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(value200_, value200_, value500_, value500_); + OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(value300_, value300_, value600_, value600_); + // 取并集 + OH_Drawing_RectJoin(rect1, rect2); + // 绘制矩形 + OH_Drawing_CanvasDrawRect(canvas, rect1); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_BrushDestroy(brush); + OH_Drawing_RectDestroy(rect1); + OH_Drawing_RectDestroy(rect2); +} + +void SampleGraphics::DrawRoundRect(OH_Drawing_Canvas *canvas) +{ + OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); + OH_Drawing_BrushSetColor(brush, OH_Drawing_ColorSetArgb(rgbaMax_, rgbaMax_, rgbaMin_, rgbaMin_)); + OH_Drawing_CanvasAttachBrush(canvas, brush); + // 创建矩形 + OH_Drawing_Rect* rect = OH_Drawing_RectCreate(value100_, value100_, value900_, value600_); + // 创建圆角矩形 + OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, value30_, value30_); + OH_Drawing_RoundRectSetCorner(roundRect, OH_Drawing_CornerPos::CORNER_POS_TOP_LEFT, {value50_, value50_}); + OH_Drawing_Corner_Radii p = OH_Drawing_RoundRectGetCorner(roundRect, OH_Drawing_CornerPos::CORNER_POS_TOP_LEFT); + SAMPLE_LOGI("top-left-corner:x=%{public}f, y:%{public}f", p.x, p.y); + // 绘制圆角矩形 + OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); + OH_Drawing_CanvasDetachBrush(canvas); + OH_Drawing_BrushDestroy(brush); + OH_Drawing_RectDestroy(rect); + OH_Drawing_RoundRectDestroy(roundRect); +} diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/BitmapDrawing.ets b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/BitmapDrawing.ets index 8ba47c2520..a8bc93702f 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/BitmapDrawing.ets +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/BitmapDrawing.ets @@ -1,35 +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. - */ - -import XComponentContext from '../../interface/XComponentContext'; - -@Entry -@Component -struct BitmapDrawing { - private xComponentContext: XComponentContext | undefined = undefined; - - build() { - Column() { - XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext = xComponentContext as XComponentContext; - this.xComponentContext.draw('CanvasGet', 'DrawBitmap'); - }) - .backgroundColor(Color.White) - .width('100%') - .height('100%') - } - } +/* + * 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 XComponentContext from '../../interface/XComponentContext'; + +@Entry +@Component +struct BitmapDrawing { + private xComponentContext: XComponentContext | undefined = undefined; + + build() { + Column() { + XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext = xComponentContext as XComponentContext; + this.xComponentContext.draw('CanvasGet', 'DrawBitmap'); + }) + .backgroundColor(Color.White) + .width('100%') + .height('100%') + } + } } \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/BrushDrawing.ets b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/BrushDrawing.ets index e0810fcd3c..bd90b0ab1a 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/BrushDrawing.ets +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/BrushDrawing.ets @@ -1,78 +1,78 @@ -/* - * 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 XComponentContext from '../../interface/XComponentContext'; - -@Entry -@Component -struct BrushDrawing { - private xComponentContext: XComponentContext | undefined = undefined; - - build() { - Column() { - XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext = xComponentContext as XComponentContext; - }) - .backgroundColor(Color.White) - .width('100%') - .height('70%') - Flex({ - direction: FlexDirection.Row, - wrap: FlexWrap.Wrap, - justifyContent: FlexAlign.Start, - alignItems: ItemAlign.Start - }) { - Button($r('app.string.DrawingBrushBasic')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'BrushBasic'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingBlendMode')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'MixedMode'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingColorFilter')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'ColorFilter'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingShaderEffect')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'LinearGradient'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingMaskFilter')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'MaskFilterBrush'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - } - .width('100%') - .height('30%') - } - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import XComponentContext from '../../interface/XComponentContext'; + +@Entry +@Component +struct BrushDrawing { + private xComponentContext: XComponentContext | undefined = undefined; + + build() { + Column() { + XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext = xComponentContext as XComponentContext; + }) + .backgroundColor(Color.White) + .width('100%') + .height('70%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems: ItemAlign.Start + }) { + Button($r('app.string.DrawingBrushBasic')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'BrushBasic'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingBlendMode')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'MixedMode'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingColorFilter')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'ColorFilter'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingShaderEffect')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'LinearGradient'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingMaskFilter')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'MaskFilterBrush'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + } + .width('100%') + .height('30%') + } + } } \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/CanvasDrawing.ets b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/CanvasDrawing.ets index 250044a192..b682fcfaa2 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/CanvasDrawing.ets +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/CanvasDrawing.ets @@ -1,92 +1,92 @@ -/* - * 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 XComponentContext from '../../interface/XComponentContext'; - -@Entry -@Component -struct CanvasDrawing { - private xComponentContext: XComponentContext | undefined = undefined; - - build() { - Column() { - XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext = xComponentContext as XComponentContext; - }) - .backgroundColor(Color.White) - .width('100%') - .height('70%') - Flex({ - direction: FlexDirection.Row, - wrap: FlexWrap.Wrap, - justifyContent: FlexAlign.Start, - alignItems: ItemAlign.Start - }) { - Button($r('app.string.DrawingCreateCanvas')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGetByCPU', 'CanvasCreate'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingClip')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'ClipOperation'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingSave')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'SaveOperation'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingSaveLayer')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'SaveLayerOperation'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingConcatMatrix')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'ConcatMatrix'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingDrawPixelMap')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'CustomPixelMap'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingDrawRegion')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'DrawRegion'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - } - .width('100%') - .height('30%') - } - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import XComponentContext from '../../interface/XComponentContext'; + +@Entry +@Component +struct CanvasDrawing { + private xComponentContext: XComponentContext | undefined = undefined; + + build() { + Column() { + XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext = xComponentContext as XComponentContext; + }) + .backgroundColor(Color.White) + .width('100%') + .height('70%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems: ItemAlign.Start + }) { + Button($r('app.string.DrawingCreateCanvas')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGetByCPU', 'CanvasCreate'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingClip')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'ClipOperation'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingSave')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'SaveOperation'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingSaveLayer')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'SaveLayerOperation'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingConcatMatrix')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'ConcatMatrix'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingDrawPixelMap')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'CustomPixelMap'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingDrawRegion')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'DrawRegion'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + } + .width('100%') + .height('30%') + } + } } \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/ImageDrawing.ets b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/ImageDrawing.ets index fb07ab8bb2..728c80afbe 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/ImageDrawing.ets +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/ImageDrawing.ets @@ -1,35 +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. - */ - -import XComponentContext from '../../interface/XComponentContext'; - -@Entry -@Component -struct ImageDrawing { - private xComponentContext: XComponentContext | undefined = undefined; - - build() { - Column() { - XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext = xComponentContext as XComponentContext; - this.xComponentContext.draw('CanvasGet', 'DrawImage'); - }) - .backgroundColor(Color.White) - .width('100%') - .height('100%') - } - } +/* + * 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 XComponentContext from '../../interface/XComponentContext'; + +@Entry +@Component +struct ImageDrawing { + private xComponentContext: XComponentContext | undefined = undefined; + + build() { + Column() { + XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext = xComponentContext as XComponentContext; + this.xComponentContext.draw('CanvasGet', 'DrawImage'); + }) + .backgroundColor(Color.White) + .width('100%') + .height('100%') + } + } } \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/MatrixDrawing.ets b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/MatrixDrawing.ets index 94db4b2170..86c50a4a88 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/MatrixDrawing.ets +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/MatrixDrawing.ets @@ -1,120 +1,120 @@ -/* - * 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 XComponentContext from '../../interface/XComponentContext'; - -@Entry -@Component -struct MatrixDrawing { - private xComponentContext: XComponentContext | undefined = undefined; - - build() { - Column() { - XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext = xComponentContext as XComponentContext; - }) - .backgroundColor(Color.White) - .width('100%') - .height('70%') - Flex({ - direction: FlexDirection.Row, - wrap: FlexWrap.Wrap, - justifyContent: FlexAlign.Start, - alignItems: ItemAlign.Start - }) { - Button($r('app.string.DrawingMatrixBasic')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'MatrixBasic'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - Button($r('app.string.DrawingTranslation')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'TranslationOperation'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - Button($r('app.string.DrawingPreTranslation')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PreTranslationOperation'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - Button($r('app.string.DrawingPostTranslation')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PostTranslationOperation'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - Button($r('app.string.DrawingRotation')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'RotationOperation'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - Button($r('app.string.DrawingPreRotation')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PreRotationOperation'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - Button($r('app.string.DrawingPostRotation')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PostRotationOperation'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - Button($r('app.string.DrawingScale')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'ScaleOperation'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - Button($r('app.string.DrawingPreScale')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PreScaleOperation'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - Button($r('app.string.DrawingPostScale')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PostScaleOperation'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - Button($r('app.string.DrawingConcat')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'ConcatOperation'); - } - }) - .margin({ top: 5, bottom: 5, left: 5, right: 5 }) - } - .width('100%') - .height('30%') - } - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import XComponentContext from '../../interface/XComponentContext'; + +@Entry +@Component +struct MatrixDrawing { + private xComponentContext: XComponentContext | undefined = undefined; + + build() { + Column() { + XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext = xComponentContext as XComponentContext; + }) + .backgroundColor(Color.White) + .width('100%') + .height('70%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems: ItemAlign.Start + }) { + Button($r('app.string.DrawingMatrixBasic')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'MatrixBasic'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + Button($r('app.string.DrawingTranslation')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'TranslationOperation'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + Button($r('app.string.DrawingPreTranslation')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PreTranslationOperation'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + Button($r('app.string.DrawingPostTranslation')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PostTranslationOperation'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + Button($r('app.string.DrawingRotation')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'RotationOperation'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + Button($r('app.string.DrawingPreRotation')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PreRotationOperation'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + Button($r('app.string.DrawingPostRotation')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PostRotationOperation'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + Button($r('app.string.DrawingScale')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'ScaleOperation'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + Button($r('app.string.DrawingPreScale')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PreScaleOperation'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + Button($r('app.string.DrawingPostScale')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PostScaleOperation'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + Button($r('app.string.DrawingConcat')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'ConcatOperation'); + } + }) + .margin({ top: 5, bottom: 5, left: 5, right: 5 }) + } + .width('100%') + .height('30%') + } + } } \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PathDrawing.ets b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PathDrawing.ets index f961f3244f..9d9b237179 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PathDrawing.ets +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PathDrawing.ets @@ -1,78 +1,78 @@ -/* - * 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 XComponentContext from '../../interface/XComponentContext'; - -@Entry -@Component -struct PathDrawing { - private xComponentContext: XComponentContext | undefined = undefined; - - build() { - Column() { - XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext = xComponentContext as XComponentContext; - }) - .backgroundColor(Color.White) - .width('100%') - .height('70%') - Flex({ - direction: FlexDirection.Row, - wrap: FlexWrap.Wrap, - justifyContent: FlexAlign.Start, - alignItems: ItemAlign.Start - }) { - Button($r('app.string.DrawingPathBasic')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PathBasic'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingPathAdd')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PathAdd'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingPathTo')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PathTo'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingPathStar')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PathStar'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingBuildFromSvgString')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'BuildFromSvgString'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - } - .width('100%') - .height('30%') - } - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import XComponentContext from '../../interface/XComponentContext'; + +@Entry +@Component +struct PathDrawing { + private xComponentContext: XComponentContext | undefined = undefined; + + build() { + Column() { + XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext = xComponentContext as XComponentContext; + }) + .backgroundColor(Color.White) + .width('100%') + .height('70%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems: ItemAlign.Start + }) { + Button($r('app.string.DrawingPathBasic')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PathBasic'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingPathAdd')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PathAdd'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingPathTo')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PathTo'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingPathStar')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PathStar'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingBuildFromSvgString')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'BuildFromSvgString'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + } + .width('100%') + .height('30%') + } + } } \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PenDrawing.ets b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PenDrawing.ets index 0583bae219..22e53fd6e3 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PenDrawing.ets +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PenDrawing.ets @@ -1,92 +1,92 @@ -/* - * 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 XComponentContext from '../../interface/XComponentContext'; - -@Entry -@Component -struct PenDrawing { - private xComponentContext: XComponentContext | undefined = undefined; - - build() { - Column() { - XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext = xComponentContext as XComponentContext; - }) - .backgroundColor(Color.White) - .width('100%') - .height('70%') - Flex({ - direction: FlexDirection.Row, - wrap: FlexWrap.Wrap, - justifyContent: FlexAlign.Start, - alignItems: ItemAlign.Start - }) { - Button($r('app.string.DrawingPenBasic')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PenBasic'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingCapJoin')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'Stroke'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingMiterLimit')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'MiterLimit'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingImageFilter')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'ImageFilter'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingPathEffect')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PathEffect'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingShaderEffect')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'PenLinearGradient'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingMaskFilter')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'MaskFilterPen'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - } - .width('100%') - .height('30%') - } - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import XComponentContext from '../../interface/XComponentContext'; + +@Entry +@Component +struct PenDrawing { + private xComponentContext: XComponentContext | undefined = undefined; + + build() { + Column() { + XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext = xComponentContext as XComponentContext; + }) + .backgroundColor(Color.White) + .width('100%') + .height('70%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems: ItemAlign.Start + }) { + Button($r('app.string.DrawingPenBasic')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PenBasic'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingCapJoin')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'Stroke'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingMiterLimit')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'MiterLimit'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingImageFilter')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'ImageFilter'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingPathEffect')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PathEffect'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingShaderEffect')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'PenLinearGradient'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingMaskFilter')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'MaskFilterPen'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + } + .width('100%') + .height('30%') + } + } } \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PixelMapDrawing.ets b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PixelMapDrawing.ets index 9dd9691b5b..dfd6fdaf2e 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PixelMapDrawing.ets +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/PixelMapDrawing.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import XComponentContext from '../../interface/XComponentContext'; -import { image } from '@kit.ImageKit'; -import { resourceManager } from '@kit.LocalizationKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct PixelMapDrawing { - private xComponentContext: XComponentContext | undefined = undefined; - private pMap: image.PixelMap | undefined = undefined; - aboutToAppear() { - const context: Context = getContext(this); - const resourceMgr: resourceManager.ResourceManager = context.resourceManager; - resourceMgr.getRawFileContent('startIcon.png').then((fileData: Uint8Array) => { - console.log('Succeeded in getting RawFileContent'); - const buffer = fileData.buffer.slice(0); - const imageSource: image.ImageSource = image.createImageSource(buffer); - imageSource.createPixelMap().then((pMap: image.PixelMap) => { - this.pMap = pMap; - }).catch((err: BusinessError) => { - console.error('Failed to creating PixelMap'); - }); - }).catch((err: BusinessError) => { - console.error('Failed to get RawFileContent'); - }); - } - - build() { - Column() { - XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext = xComponentContext as XComponentContext; - }) - .backgroundColor(Color.White) - .width('100%') - .height('70%') - Flex({ - direction: FlexDirection.Row, - wrap: FlexWrap.Wrap, - justifyContent: FlexAlign.Start, - alignItems: ItemAlign.Start - }) { - Button($r('app.string.DrawingLocalPixelMap')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.drawImage('CanvasGet', 'LocalPixelMap', this.pMap); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingCustomPixelMap')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'CustomPixelMap'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - } - .width('100%') - .height('30%') - } - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import XComponentContext from '../../interface/XComponentContext'; +import { image } from '@kit.ImageKit'; +import { resourceManager } from '@kit.LocalizationKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct PixelMapDrawing { + private xComponentContext: XComponentContext | undefined = undefined; + private pMap: image.PixelMap | undefined = undefined; + aboutToAppear() { + const context: Context = getContext(this); + const resourceMgr: resourceManager.ResourceManager = context.resourceManager; + resourceMgr.getRawFileContent('startIcon.png').then((fileData: Uint8Array) => { + console.log('Succeeded in getting RawFileContent'); + const buffer = fileData.buffer.slice(0); + const imageSource: image.ImageSource = image.createImageSource(buffer); + imageSource.createPixelMap().then((pMap: image.PixelMap) => { + this.pMap = pMap; + }).catch((err: BusinessError) => { + console.error('Failed to creating PixelMap'); + }); + }).catch((err: BusinessError) => { + console.error('Failed to get RawFileContent'); + }); + } + + build() { + Column() { + XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext = xComponentContext as XComponentContext; + }) + .backgroundColor(Color.White) + .width('100%') + .height('70%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems: ItemAlign.Start + }) { + Button($r('app.string.DrawingLocalPixelMap')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.drawImage('CanvasGet', 'LocalPixelMap', this.pMap); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingCustomPixelMap')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'CustomPixelMap'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + } + .width('100%') + .height('30%') + } + } } \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/RectDrawing.ets b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/RectDrawing.ets index bdebddb8c7..74b58f3e2c 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/RectDrawing.ets +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/ets/drawing/pages/RectDrawing.ets @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import XComponentContext from '../../interface/XComponentContext'; - -@Entry -@Component -struct RectDrawing { - private xComponentContext: XComponentContext | undefined = undefined; - - build() { - Column() { - XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) - .onLoad((xComponentContext) => { - this.xComponentContext = xComponentContext as XComponentContext; - }) - .backgroundColor(Color.White) - .width('100%') - .height('70%') - Flex({ - direction: FlexDirection.Row, - wrap: FlexWrap.Wrap, - justifyContent: FlexAlign.Start, - alignItems: ItemAlign.Start - }) { - Button($r('app.string.DrawingRectBasic')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'RectBasic'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingIntersect')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'RectIntersect'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingJoin')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'RectJoin'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - Button($r('app.string.DrawingRoundRect')) - .onClick((): void => { - if (this.xComponentContext) { - this.xComponentContext.draw('CanvasGet', 'RoundRect'); - } - }) - .margin({ top: 10, bottom: 10, left: 10, right: 10 }) - } - .width('100%') - .height('30%') - } - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import XComponentContext from '../../interface/XComponentContext'; + +@Entry +@Component +struct RectDrawing { + private xComponentContext: XComponentContext | undefined = undefined; + + build() { + Column() { + XComponent({ id: 'basicEffectXComponent', type: XComponentType.SURFACE, libraryname: 'entry' }) + .onLoad((xComponentContext) => { + this.xComponentContext = xComponentContext as XComponentContext; + }) + .backgroundColor(Color.White) + .width('100%') + .height('70%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems: ItemAlign.Start + }) { + Button($r('app.string.DrawingRectBasic')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'RectBasic'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingIntersect')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'RectIntersect'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingJoin')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'RectJoin'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + Button($r('app.string.DrawingRoundRect')) + .onClick((): void => { + if (this.xComponentContext) { + this.xComponentContext.draw('CanvasGet', 'RoundRect'); + } + }) + .margin({ top: 10, bottom: 10, left: 10, right: 10 }) + } + .width('100%') + .height('30%') + } + } } \ No newline at end of file diff --git a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/module.json5 b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/module.json5 index 81e36fa1cf..2cd3a6c601 100644 --- a/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/module.json5 +++ b/code/DocsSample/Drawing/NDKAPIDrawing/entry/src/main/module.json5 @@ -1,51 +1,51 @@ -{ - "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" - } - ] - } - ] - } +{ + "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/Notification/Notification/AppScope/app.json5 b/code/DocsSample/Notification/Notification/AppScope/app.json5 index 03e6d5d694..42c9a5408a 100644 --- a/code/DocsSample/Notification/Notification/AppScope/app.json5 +++ b/code/DocsSample/Notification/Notification/AppScope/app.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2023 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.notification", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.notification", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Notification/Notification/AppScope/resources/base/element/string.json b/code/DocsSample/Notification/Notification/AppScope/resources/base/element/string.json index 6b5ba9e585..2603caef26 100644 --- a/code/DocsSample/Notification/Notification/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Notification/Notification/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "Notification" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "Notification" + } + ] +} diff --git a/code/DocsSample/Notification/Notification/README_zh.md b/code/DocsSample/Notification/Notification/README_zh.md index 83021009a9..06d287717c 100644 --- a/code/DocsSample/Notification/Notification/README_zh.md +++ b/code/DocsSample/Notification/Notification/README_zh.md @@ -1,80 +1,80 @@ -# 通知 - -### 介绍 - -本示例使用 [@ohos.notificationManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-notification-kit/js-apis-notificationManager.md) 等接口, 展示了如何初始化不同类型通知的通知内容以及通知的发布、取消及桌面角标的设置,通知类型包括基本类型、长文本类型、多行文本类型、图片类型、带进度条的通知、点击可跳转到应用以及公共事件通知。 - -### 效果预览 - -| 主界面 | 图片通知 | 多行文本通知 | 进度条通知 | -|----------------------------------------------------------|:----------------------------------------------------:|:---------------------------------------------------------:|:---------------------------------------------------------:| -| | | | | - -使用说明 - -1.启动应用后,弹出是否允许发送通知的弹窗,点击允许后开始操作; - -2.点击主界面中设置角标列表项设置角标,回到仿桌面,可以看到角标数量,对应消息数量(使用前需安装并启动[仿桌面应用](../../../SystemFeature/ApplicationModels/Launcher)); - -3.点主击界面中对应的列表项发布不同类型的通知,下拉状态栏,在通知栏可以看到发布的通知; - -### 工程目录 - -``` -entry/src/main/ets/ -|---entryability -| |---EntryAbility.ets -|---pages -| |---Index.ets // 首页 -| |---Second.ets // 通知启动Ability时,被拉起的Ability页面 -|---publish -| |---PublishOperation.ets // 使能通知开关、设置通知角标、发布通知 -|---secondability -| |---SecondAbility.ets // 通知启动Ability时,被拉起的Ability -|---subscribe -| |---SubscribeOperation.ets // 订阅通知 -``` - -### 具体实现 - -- 允许发送通知、发送通知的功能接口封装在PublishOperation,源码参考:[PublishOperation.ets](entry/src/main/ets/publish/PublishOperation.ets) - * 允许发送通知: - 通过publishOperation.enableNotification()调用notificationManager.requestEnableNotification()接口向用户请求发送通知; - - * 设置角标: - - 通过publishOperation.setBadgeNumberForBasic()调用notificationManager.setBadgeNumber()接口设置角标; - - * 发送通知:通过notificationManager.publish发布通知的接口,通知类型包括基本类型、长文本类型、多行文本类型、图片类型、带进度条的通知、点击可跳转到应用以及公共事件通知; -- 订阅通知功能接口封装在SubscribeOperation,源码参考:[PublishOperation.ets](entry/src/main/ets/subscribe/SubscribeOperation.ets) - -### 相关权限 - -[ohos.permission.NOTIFICATION_CONTROLLER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionnotification_controller) - -### 依赖 - -应用的角标依赖于仿桌面应用进行显示:[仿桌面应用](../../../SystemFeature/ApplicationModels/Launcher)。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568。 - -2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.3.1; - -3.本示例涉及使用系统接口:notificationManager.requestEnableNotification ,需要手动替换Full SDK才能编译通过; - -4.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行; - -5.本示例涉及[ohos.permission.NOTIFICATION_CONTROLLER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionnotification_controller)权限为system_core级别,需要配置高权限签名; - -### 下载 - -```shell -git init -git config core.sparsecheckout true -echo code/DocsSample/Notification/Notification/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` - +# 通知 + +### 介绍 + +本示例使用 [@ohos.notificationManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-notification-kit/js-apis-notificationManager.md) 等接口, 展示了如何初始化不同类型通知的通知内容以及通知的发布、取消及桌面角标的设置,通知类型包括基本类型、长文本类型、多行文本类型、图片类型、带进度条的通知、点击可跳转到应用以及公共事件通知。 + +### 效果预览 + +| 主界面 | 图片通知 | 多行文本通知 | 进度条通知 | +|----------------------------------------------------------|:----------------------------------------------------:|:---------------------------------------------------------:|:---------------------------------------------------------:| +| | | | | + +使用说明 + +1.启动应用后,弹出是否允许发送通知的弹窗,点击允许后开始操作; + +2.点击主界面中设置角标列表项设置角标,回到仿桌面,可以看到角标数量,对应消息数量(使用前需安装并启动[仿桌面应用](../../../SystemFeature/ApplicationModels/Launcher)); + +3.点主击界面中对应的列表项发布不同类型的通知,下拉状态栏,在通知栏可以看到发布的通知; + +### 工程目录 + +``` +entry/src/main/ets/ +|---entryability +| |---EntryAbility.ets +|---pages +| |---Index.ets // 首页 +| |---Second.ets // 通知启动Ability时,被拉起的Ability页面 +|---publish +| |---PublishOperation.ets // 使能通知开关、设置通知角标、发布通知 +|---secondability +| |---SecondAbility.ets // 通知启动Ability时,被拉起的Ability +|---subscribe +| |---SubscribeOperation.ets // 订阅通知 +``` + +### 具体实现 + +- 允许发送通知、发送通知的功能接口封装在PublishOperation,源码参考:[PublishOperation.ets](entry/src/main/ets/publish/PublishOperation.ets) + * 允许发送通知: + 通过publishOperation.enableNotification()调用notificationManager.requestEnableNotification()接口向用户请求发送通知; + + * 设置角标: + + 通过publishOperation.setBadgeNumberForBasic()调用notificationManager.setBadgeNumber()接口设置角标; + + * 发送通知:通过notificationManager.publish发布通知的接口,通知类型包括基本类型、长文本类型、多行文本类型、图片类型、带进度条的通知、点击可跳转到应用以及公共事件通知; +- 订阅通知功能接口封装在SubscribeOperation,源码参考:[PublishOperation.ets](entry/src/main/ets/subscribe/SubscribeOperation.ets) + +### 相关权限 + +[ohos.permission.NOTIFICATION_CONTROLLER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionnotification_controller) + +### 依赖 + +应用的角标依赖于仿桌面应用进行显示:[仿桌面应用](../../../SystemFeature/ApplicationModels/Launcher)。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568。 + +2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.3.1; + +3.本示例涉及使用系统接口:notificationManager.requestEnableNotification ,需要手动替换Full SDK才能编译通过; + +4.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行; + +5.本示例涉及[ohos.permission.NOTIFICATION_CONTROLLER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionnotification_controller)权限为system_core级别,需要配置高权限签名; + +### 下载 + +```shell +git init +git config core.sparsecheckout true +echo code/DocsSample/Notification/Notification/ > .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/Notification/Notification/build-profile.json5 b/code/DocsSample/Notification/Notification/build-profile.json5 index e89f4e59bc..50337ead09 100644 --- a/code/DocsSample/Notification/Notification/build-profile.json5 +++ b/code/DocsSample/Notification/Notification/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ], - "signingConfigs": [] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ], + "signingConfigs": [] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Notification/Notification/entry/build-profile.json5 b/code/DocsSample/Notification/Notification/entry/build-profile.json5 index 0c8525dfdd..910cc991f5 100644 --- a/code/DocsSample/Notification/Notification/entry/build-profile.json5 +++ b/code/DocsSample/Notification/Notification/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Notification/Notification/entry/oh-package.json5 b/code/DocsSample/Notification/Notification/entry/oh-package.json5 index 60744fdbc7..225946cb11 100644 --- a/code/DocsSample/Notification/Notification/entry/oh-package.json5 +++ b/code/DocsSample/Notification/Notification/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/Notification/Notification/entry/src/main/ets/entryAbility/EntryAbility.ets b/code/DocsSample/Notification/Notification/entry/src/main/ets/entryAbility/EntryAbility.ets index be806ebc5c..b23b3e2942 100644 --- a/code/DocsSample/Notification/Notification/entry/src/main/ets/entryAbility/EntryAbility.ets +++ b/code/DocsSample/Notification/Notification/entry/src/main/ets/entryAbility/EntryAbility.ets @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import Base from '@ohos.base'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; -import hilog from '@ohos.hilog'; -import { subscribeOperations } from '../subscribe/SubscribeOperation'; - -const TAG: string = '[EntryAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onCreate'); - } - - onDestroy() { - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/Index', (err: Base.BusinessError) => { - if (err.code) { - hilog.info(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onForeground'); - subscribeOperations.createSubscriber(); - } - - onBackground() { - // Ability has back to background - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onBackground'); - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import Base from '@ohos.base'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import hilog from '@ohos.hilog'; +import { subscribeOperations } from '../subscribe/SubscribeOperation'; + +const TAG: string = '[EntryAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onCreate'); + } + + onDestroy() { + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onWindowStageCreate'); + windowStage.loadContent('pages/Index', (err: Base.BusinessError) => { + if (err.code) { + hilog.info(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onForeground'); + subscribeOperations.createSubscriber(); + } + + onBackground() { + // Ability has back to background + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onBackground'); + } +} diff --git a/code/DocsSample/Notification/Notification/entry/src/main/ets/pages/Second.ets b/code/DocsSample/Notification/Notification/entry/src/main/ets/pages/Second.ets index 6d2e377eef..389f40e738 100644 --- a/code/DocsSample/Notification/Notification/entry/src/main/ets/pages/Second.ets +++ b/code/DocsSample/Notification/Notification/entry/src/main/ets/pages/Second.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2023 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 Second { - @State message: string = 'Second Page' - - build() { - Column() { - Row() { - Text($r('app.string.SecondPage')) { - } - .fontSize(24) - .fontWeight(FontWeight.Bold) - }.height(56) - .padding({ left: 24, right: 24 }) - .width('100%') - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { - Column() { - Image($r('app.media.pic_empty')).width('33%') - Text($r('app.string.empty')) - .fontSize(14) - .fontColor($r('app.color.text_color')) - } - }.width('100%') - .height('90%') - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - .padding({ top: 36, bottom: 106 }) - } +/* + * Copyright (c) 2023 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 Second { + @State message: string = 'Second Page' + + build() { + Column() { + Row() { + Text($r('app.string.SecondPage')) { + } + .fontSize(24) + .fontWeight(FontWeight.Bold) + }.height(56) + .padding({ left: 24, right: 24 }) + .width('100%') + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { + Column() { + Image($r('app.media.pic_empty')).width('33%') + Text($r('app.string.empty')) + .fontSize(14) + .fontColor($r('app.color.text_color')) + } + }.width('100%') + .height('90%') + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + .padding({ top: 36, bottom: 106 }) + } } \ No newline at end of file diff --git a/code/DocsSample/Notification/Notification/entry/src/main/ets/publish/PublishOperation.ets b/code/DocsSample/Notification/Notification/entry/src/main/ets/publish/PublishOperation.ets index 0566b78450..00a93a054a 100644 --- a/code/DocsSample/Notification/Notification/entry/src/main/ets/publish/PublishOperation.ets +++ b/code/DocsSample/Notification/Notification/entry/src/main/ets/publish/PublishOperation.ets @@ -1,294 +1,294 @@ -/* - * Copyright (c) 2023 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 Base from '@ohos.base'; -import image from '@ohos.multimedia.image'; -import notificationManager from '@ohos.notificationManager'; -import wantAgent from '@ohos.app.ability.wantAgent'; -import { WantAgent } from '@ohos.app.ability.wantAgent' -import hilog from '@ohos.hilog'; -import resourceManager from '@ohos.resourceManager'; - -const TAG: string = '[PublishOperation]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class PublishOperation { - private context: Context; - - constructor(context: Context) { - this.context = context; - } - - enableNotification = async () => { - notificationManager.isNotificationEnabled().then((data: boolean) => { - hilog.info(DOMAIN_NUMBER, TAG, 'isNotificationEnabled success, data: ' + JSON.stringify(data)); - if(!data){ - notificationManager.requestEnableNotification().then(() => { - hilog.info(DOMAIN_NUMBER, TAG, `[ANS] requestEnableNotification success`); - }).catch((err:Base.BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, - `[ANS] requestEnableNotification failed, code is ${err.code}, message is ${err.message}`); - }); - } - }).catch((err: Base.BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, `isNotificationEnabled fail: ${JSON.stringify(err)}`); - }); - } - publishBasic = async () => { - let notificationRequest: notificationManager.NotificationRequest = { - id: 1, - content: { - notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // 普通文本类型通知 - normal: { - title: 'test_title', - text: 'test_text', - additionalText: 'test_additionalText', - } - } - }; - - // 发布通知 - notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, - `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); - }); - } - publishLong = async () => { - let notificationRequest: notificationManager.NotificationRequest = { - id: 2, - content: { - notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, // 长文本类型通知 - longText: { - title: 'test_title', - text: 'test_text', - additionalText: 'test_additionalText', - longText: 'test_longText', - briefText: 'test_briefText', - expandedTitle: 'test_expandedTitle', - } - } - }; - - // 发布通知 - notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, - `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); - }); - } - publishMultiLine = async () => { - let notificationRequest: notificationManager.NotificationRequest = { - id: 3, - content: { - notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // 多行文本类型通知 - multiLine: { - title: 'test_title', - text: 'test_text', - briefText: 'test_briefText', - longTitle: 'test_longTitle', - lines: ['line_01', 'line_02', 'line_03', 'line_04'], - } - } - }; - - // 发布通知 - notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, - `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); - }); - } - - publishPicture = async () => { - const resourceMgr: resourceManager.ResourceManager = this.context.resourceManager; - let imageArray: Uint8Array = await resourceMgr.getMediaContent($r('app.media.pic').id); - const arraybuffer: ArrayBuffer = imageArray.buffer as ArrayBuffer; - let imageResource = image.createImageSource(arraybuffer); - let imagePixelMap = await imageResource.createPixelMap(); - - if (imagePixelMap !== undefined) { - let notificationRequest: notificationManager.NotificationRequest = { - id: 4, - content: { - notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_PICTURE, - picture: { - title: 'test_title', - text: 'test_text', - additionalText: 'test_additionalText', - briefText: 'test_briefText', - expandedTitle: 'test_expandedTitle', - picture: imagePixelMap - } - } - }; - - // 发布通知 - notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, - `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); - }); - } - } - publishProgressBar = async () => { - notificationManager.isSupportTemplate('downloadTemplate').then((data: boolean) => { - hilog.info(DOMAIN_NUMBER, TAG, `[ANS] isSupportTemplate success`); - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in supporting download template notification.'); - if (data == true) { // data的值为true表示支持支持downloadTemplate模板类通知,false表示不支持 - let notificationRequest: notificationManager.NotificationRequest = { - id: 5, - content: { - notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: 'test_title', - text: 'test_text', - additionalText: 'test_additionalText' - } - }, - // 构造进度条模板,name字段当前需要固定配置为downloadTemplate - template: { - name: 'downloadTemplate', - data: { - title: 'File Title', fileName: 'music.mp4', progressValue: 45 - } - } - } - // 发布通知 - notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, - `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); - }); - } - }).catch((err: Base.BusinessError) => { - hilog.error(DOMAIN_NUMBER, TAG, - `Failed to support download template notification. Code is ${err.code}, message is ${err.message}`); - }); - } - publishWantAgentStartAbility = async () => { - let wantAgentObj: WantAgent; // 用于保存创建成功的wantAgent对象,后续使用其完成触发的动作。 - // 通过WantAgentInfo的operationType设置动作类型 - let wantAgentInfo: wantAgent.WantAgentInfo = { - wants: [ - { - deviceId: '', - bundleName: 'com.samples.notification', - abilityName: 'SecondAbility', - action: '', - entities: [], - uri: '', - parameters: {} - } - ], - operationType: wantAgent.OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG] - }; - // 创建WantAgent - wantAgent.getWantAgent(wantAgentInfo, (err: Base.BusinessError, data: WantAgent) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to get want agent. Code is ${err.code}, message is ${err.message}`); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in getting want agent.'); - wantAgentObj = data; - this.publishWantAgent(wantAgentObj); - }); - } - publishWantAgentCommonEvent = async () => { - let wantAgentObj: WantAgent; // 用于保存创建成功的WantAgent对象,后续使用其完成触发的动作。 - // 通过WantAgentInfo的operationType设置动作类型 - let wantAgentInfo: wantAgent.WantAgentInfo = { - wants: [ - { - action: 'event_name', // 设置事件名 - parameters: {}, - } - ], - operationType: wantAgent.OperationType.SEND_COMMON_EVENT, - requestCode: 0, - wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG], - }; - - // 创建WantAgent - wantAgent.getWantAgent(wantAgentInfo, (err: Base.BusinessError, data: WantAgent) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to get want agent. Code is ${err.code}, message is ${err.message}`); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in getting want agent.'); - wantAgentObj = data; - this.publishWantAgent(wantAgentObj); - }); - } - publishWantAgent = async (wantAgentObj: WantAgent) => { - // 构造NotificationRequest对象 - let notificationRequest: notificationManager.NotificationRequest = { - content: { - notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: 'Test_Title', - text: 'Test_Text', - additionalText: 'Test_AdditionalText', - }, - }, - id: 6, - label: 'TEST', - wantAgent: wantAgentObj, - } - - notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, - `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); - }); - } - setBadgeNumberCallback = async (err: Base.BusinessError) => { - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, `Failed to set badge number. Code is ${err.code}, message is ${err.message}`); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in setting badge number.`); - } - setBadgeNumber = async () => { - let badgeNumber = 9; - notificationManager.setBadgeNumber(badgeNumber, this.setBadgeNumberCallback); - } - setBadgeNumberForBasic = async () => { - await notificationManager.removeAllSlots(); - await notificationManager.addSlot(notificationManager.SlotType.CONTENT_INFORMATION); - await this.publishBasic(); - await this.setBadgeNumber(); - } -} +/* + * Copyright (c) 2023 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 Base from '@ohos.base'; +import image from '@ohos.multimedia.image'; +import notificationManager from '@ohos.notificationManager'; +import wantAgent from '@ohos.app.ability.wantAgent'; +import { WantAgent } from '@ohos.app.ability.wantAgent' +import hilog from '@ohos.hilog'; +import resourceManager from '@ohos.resourceManager'; + +const TAG: string = '[PublishOperation]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class PublishOperation { + private context: Context; + + constructor(context: Context) { + this.context = context; + } + + enableNotification = async () => { + notificationManager.isNotificationEnabled().then((data: boolean) => { + hilog.info(DOMAIN_NUMBER, TAG, 'isNotificationEnabled success, data: ' + JSON.stringify(data)); + if(!data){ + notificationManager.requestEnableNotification().then(() => { + hilog.info(DOMAIN_NUMBER, TAG, `[ANS] requestEnableNotification success`); + }).catch((err:Base.BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, + `[ANS] requestEnableNotification failed, code is ${err.code}, message is ${err.message}`); + }); + } + }).catch((err: Base.BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, `isNotificationEnabled fail: ${JSON.stringify(err)}`); + }); + } + publishBasic = async () => { + let notificationRequest: notificationManager.NotificationRequest = { + id: 1, + content: { + notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // 普通文本类型通知 + normal: { + title: 'test_title', + text: 'test_text', + additionalText: 'test_additionalText', + } + } + }; + + // 发布通知 + notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, + `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); + }); + } + publishLong = async () => { + let notificationRequest: notificationManager.NotificationRequest = { + id: 2, + content: { + notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, // 长文本类型通知 + longText: { + title: 'test_title', + text: 'test_text', + additionalText: 'test_additionalText', + longText: 'test_longText', + briefText: 'test_briefText', + expandedTitle: 'test_expandedTitle', + } + } + }; + + // 发布通知 + notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, + `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); + }); + } + publishMultiLine = async () => { + let notificationRequest: notificationManager.NotificationRequest = { + id: 3, + content: { + notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // 多行文本类型通知 + multiLine: { + title: 'test_title', + text: 'test_text', + briefText: 'test_briefText', + longTitle: 'test_longTitle', + lines: ['line_01', 'line_02', 'line_03', 'line_04'], + } + } + }; + + // 发布通知 + notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, + `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); + }); + } + + publishPicture = async () => { + const resourceMgr: resourceManager.ResourceManager = this.context.resourceManager; + let imageArray: Uint8Array = await resourceMgr.getMediaContent($r('app.media.pic').id); + const arraybuffer: ArrayBuffer = imageArray.buffer as ArrayBuffer; + let imageResource = image.createImageSource(arraybuffer); + let imagePixelMap = await imageResource.createPixelMap(); + + if (imagePixelMap !== undefined) { + let notificationRequest: notificationManager.NotificationRequest = { + id: 4, + content: { + notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_PICTURE, + picture: { + title: 'test_title', + text: 'test_text', + additionalText: 'test_additionalText', + briefText: 'test_briefText', + expandedTitle: 'test_expandedTitle', + picture: imagePixelMap + } + } + }; + + // 发布通知 + notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, + `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); + }); + } + } + publishProgressBar = async () => { + notificationManager.isSupportTemplate('downloadTemplate').then((data: boolean) => { + hilog.info(DOMAIN_NUMBER, TAG, `[ANS] isSupportTemplate success`); + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in supporting download template notification.'); + if (data == true) { // data的值为true表示支持支持downloadTemplate模板类通知,false表示不支持 + let notificationRequest: notificationManager.NotificationRequest = { + id: 5, + content: { + notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: 'test_title', + text: 'test_text', + additionalText: 'test_additionalText' + } + }, + // 构造进度条模板,name字段当前需要固定配置为downloadTemplate + template: { + name: 'downloadTemplate', + data: { + title: 'File Title', fileName: 'music.mp4', progressValue: 45 + } + } + } + // 发布通知 + notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, + `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); + }); + } + }).catch((err: Base.BusinessError) => { + hilog.error(DOMAIN_NUMBER, TAG, + `Failed to support download template notification. Code is ${err.code}, message is ${err.message}`); + }); + } + publishWantAgentStartAbility = async () => { + let wantAgentObj: WantAgent; // 用于保存创建成功的wantAgent对象,后续使用其完成触发的动作。 + // 通过WantAgentInfo的operationType设置动作类型 + let wantAgentInfo: wantAgent.WantAgentInfo = { + wants: [ + { + deviceId: '', + bundleName: 'com.samples.notification', + abilityName: 'SecondAbility', + action: '', + entities: [], + uri: '', + parameters: {} + } + ], + operationType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG] + }; + // 创建WantAgent + wantAgent.getWantAgent(wantAgentInfo, (err: Base.BusinessError, data: WantAgent) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to get want agent. Code is ${err.code}, message is ${err.message}`); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in getting want agent.'); + wantAgentObj = data; + this.publishWantAgent(wantAgentObj); + }); + } + publishWantAgentCommonEvent = async () => { + let wantAgentObj: WantAgent; // 用于保存创建成功的WantAgent对象,后续使用其完成触发的动作。 + // 通过WantAgentInfo的operationType设置动作类型 + let wantAgentInfo: wantAgent.WantAgentInfo = { + wants: [ + { + action: 'event_name', // 设置事件名 + parameters: {}, + } + ], + operationType: wantAgent.OperationType.SEND_COMMON_EVENT, + requestCode: 0, + wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG], + }; + + // 创建WantAgent + wantAgent.getWantAgent(wantAgentInfo, (err: Base.BusinessError, data: WantAgent) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to get want agent. Code is ${err.code}, message is ${err.message}`); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in getting want agent.'); + wantAgentObj = data; + this.publishWantAgent(wantAgentObj); + }); + } + publishWantAgent = async (wantAgentObj: WantAgent) => { + // 构造NotificationRequest对象 + let notificationRequest: notificationManager.NotificationRequest = { + content: { + notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: 'Test_Title', + text: 'Test_Text', + additionalText: 'Test_AdditionalText', + }, + }, + id: 6, + label: 'TEST', + wantAgent: wantAgentObj, + } + + notificationManager.publish(notificationRequest, (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, + `Failed to publish notification. Code is ${err.code}, message is ${err.message}`); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.'); + }); + } + setBadgeNumberCallback = async (err: Base.BusinessError) => { + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, `Failed to set badge number. Code is ${err.code}, message is ${err.message}`); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in setting badge number.`); + } + setBadgeNumber = async () => { + let badgeNumber = 9; + notificationManager.setBadgeNumber(badgeNumber, this.setBadgeNumberCallback); + } + setBadgeNumberForBasic = async () => { + await notificationManager.removeAllSlots(); + await notificationManager.addSlot(notificationManager.SlotType.CONTENT_INFORMATION); + await this.publishBasic(); + await this.setBadgeNumber(); + } +} diff --git a/code/DocsSample/Notification/Notification/entry/src/main/ets/secondAbility/SecondAbility.ets b/code/DocsSample/Notification/Notification/entry/src/main/ets/secondAbility/SecondAbility.ets index be13d054f1..e17ba3c4df 100644 --- a/code/DocsSample/Notification/Notification/entry/src/main/ets/secondAbility/SecondAbility.ets +++ b/code/DocsSample/Notification/Notification/entry/src/main/ets/secondAbility/SecondAbility.ets @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import Base from '@ohos.base'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; -import hilog from '@ohos.hilog'; - -const TAG: string = '[SecondAbility]'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class SecondAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onCreate'); - } - - onDestroy() { - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/Second', (err: Base.BusinessError) => { - if (err.code) { - hilog.info(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onForeground'); - } - - onBackground() { - // Ability has back to background - hilog.info(DOMAIN_NUMBER, TAG, 'Ability onBackground'); - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import Base from '@ohos.base'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import hilog from '@ohos.hilog'; + +const TAG: string = '[SecondAbility]'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class SecondAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onCreate'); + } + + onDestroy() { + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onWindowStageCreate'); + windowStage.loadContent('pages/Second', (err: Base.BusinessError) => { + if (err.code) { + hilog.info(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(DOMAIN_NUMBER, TAG, 'Ability onBackground'); + } +} diff --git a/code/DocsSample/Notification/Notification/entry/src/main/ets/subscribe/SubscribeOperation.ets b/code/DocsSample/Notification/Notification/entry/src/main/ets/subscribe/SubscribeOperation.ets index e7b3dc0dc7..4c53d5dbbb 100644 --- a/code/DocsSample/Notification/Notification/entry/src/main/ets/subscribe/SubscribeOperation.ets +++ b/code/DocsSample/Notification/Notification/entry/src/main/ets/subscribe/SubscribeOperation.ets @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2023 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 Base from '@ohos.base'; -import notificationSubscribe from '@ohos.notificationSubscribe'; -import hilog from '@ohos.hilog'; -import notificationManager from '@ohos.notificationManager'; - -interface NotificationSortingMap { - readonly sortedHashCode: Array; -} - -const TAG: string = '[SubscribeOperations]'; -const DOMAIN_NUMBER: number = 0xFF00; - -class SubscribeOperations { - createSubscriber = async () => { - let subscriber: notificationSubscribe.NotificationSubscriber = { - onConsume: (data: notificationSubscribe.SubscribeCallbackData) => { - let req: notificationManager.NotificationRequest = data.request; - hilog.info(DOMAIN_NUMBER, TAG, `onConsume callback. req.id: ${req.id}`); - }, - onCancel: (data: notificationSubscribe.SubscribeCallbackData) => { - let req: notificationManager.NotificationRequest = data.request; - hilog.info(DOMAIN_NUMBER, TAG, `onCancel callback. req.id: ${req.id}`); - }, - onUpdate: (data: NotificationSortingMap) => { - hilog.info(DOMAIN_NUMBER, TAG, `onUpdate callback. req.id: ${data.sortedHashCode}`); - }, - onConnect: () => { - hilog.info(DOMAIN_NUMBER, TAG, `onConnect callback.`); - }, - onDisconnect: () => { - hilog.info(DOMAIN_NUMBER, TAG, `onDisconnect callback.`); - }, - onDestroy: () => { - hilog.info(DOMAIN_NUMBER, TAG, `onDestroy callback.`); - }, - }; - - notificationSubscribe.subscribe(subscriber, (err: Base.BusinessError) => { // callback形式调用异步接口 - if (err) { - hilog.error(DOMAIN_NUMBER, TAG, - `Failed to subscribe notification. Code is ${err.code}, message is ${err.message}`); - return; - } - }); - } -} - +/* + * Copyright (c) 2023 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 Base from '@ohos.base'; +import notificationSubscribe from '@ohos.notificationSubscribe'; +import hilog from '@ohos.hilog'; +import notificationManager from '@ohos.notificationManager'; + +interface NotificationSortingMap { + readonly sortedHashCode: Array; +} + +const TAG: string = '[SubscribeOperations]'; +const DOMAIN_NUMBER: number = 0xFF00; + +class SubscribeOperations { + createSubscriber = async () => { + let subscriber: notificationSubscribe.NotificationSubscriber = { + onConsume: (data: notificationSubscribe.SubscribeCallbackData) => { + let req: notificationManager.NotificationRequest = data.request; + hilog.info(DOMAIN_NUMBER, TAG, `onConsume callback. req.id: ${req.id}`); + }, + onCancel: (data: notificationSubscribe.SubscribeCallbackData) => { + let req: notificationManager.NotificationRequest = data.request; + hilog.info(DOMAIN_NUMBER, TAG, `onCancel callback. req.id: ${req.id}`); + }, + onUpdate: (data: NotificationSortingMap) => { + hilog.info(DOMAIN_NUMBER, TAG, `onUpdate callback. req.id: ${data.sortedHashCode}`); + }, + onConnect: () => { + hilog.info(DOMAIN_NUMBER, TAG, `onConnect callback.`); + }, + onDisconnect: () => { + hilog.info(DOMAIN_NUMBER, TAG, `onDisconnect callback.`); + }, + onDestroy: () => { + hilog.info(DOMAIN_NUMBER, TAG, `onDestroy callback.`); + }, + }; + + notificationSubscribe.subscribe(subscriber, (err: Base.BusinessError) => { // callback形式调用异步接口 + if (err) { + hilog.error(DOMAIN_NUMBER, TAG, + `Failed to subscribe notification. Code is ${err.code}, message is ${err.message}`); + return; + } + }); + } +} + export let subscribeOperations = new SubscribeOperations(); \ No newline at end of file diff --git a/code/DocsSample/Notification/Notification/entry/src/main/ets/util/Logger.ets b/code/DocsSample/Notification/Notification/entry/src/main/ets/util/Logger.ets index 8161ed13ad..37c4bc4c93 100644 --- a/code/DocsSample/Notification/Notification/entry/src/main/ets/util/Logger.ets +++ b/code/DocsSample/Notification/Notification/entry/src/main/ets/util/Logger.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix - this.domain = 0xFF00 - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix + this.domain = 0xFF00 + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export let logger = new Logger('[Sample_Notification]'); \ No newline at end of file diff --git a/code/DocsSample/Notification/Notification/entry/src/main/module.json5 b/code/DocsSample/Notification/Notification/entry/src/main/module.json5 index 64e5dc0ebe..f2f1d21694 100644 --- a/code/DocsSample/Notification/Notification/entry/src/main/module.json5 +++ b/code/DocsSample/Notification/Notification/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2023 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:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "SecondAbility", - "srcEntry": "./ets/secondAbility/SecondAbility.ets", - "description": "$string:SecondAbility_desc", - "icon": "$media:icon", - "label": "$string:SecondAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - }, - ], - "requestPermissions": [ - { - "name": "ohos.permission.NOTIFICATION_CONTROLLER", - "usedScene": { - "abilities": [ - "EntryAbility" - ], - "when": "always" - } - } - ] - } +/* + * Copyright (c) 2023 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:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "SecondAbility", + "srcEntry": "./ets/secondAbility/SecondAbility.ets", + "description": "$string:SecondAbility_desc", + "icon": "$media:icon", + "label": "$string:SecondAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + }, + ], + "requestPermissions": [ + { + "name": "ohos.permission.NOTIFICATION_CONTROLLER", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "always" + } + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/Notification/Notification/entry/src/main/resources/base/element/color.json b/code/DocsSample/Notification/Notification/entry/src/main/resources/base/element/color.json index e1691a2f31..59da6fd48a 100644 --- a/code/DocsSample/Notification/Notification/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Notification/Notification/entry/src/main/resources/base/element/color.json @@ -1,20 +1,20 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "background", - "value": "#f1f3f5" - }, - { - "name": "backGrounding", - "value": "#f1f3f5" - }, - { - "name": "text_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "background", + "value": "#f1f3f5" + }, + { + "name": "backGrounding", + "value": "#f1f3f5" + }, + { + "name": "text_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Notification/Notification/entry/src/ohosTest/ets/util/Logger.ets b/code/DocsSample/Notification/Notification/entry/src/ohosTest/ets/util/Logger.ets index 314038b8c8..b7fe261636 100644 --- a/code/DocsSample/Notification/Notification/entry/src/ohosTest/ets/util/Logger.ets +++ b/code/DocsSample/Notification/Notification/entry/src/ohosTest/ets/util/Logger.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix - this.domain = 0xF811 - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix + this.domain = 0xF811 + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export let logger = new Logger('[Test_Notification]'); \ No newline at end of file diff --git a/code/DocsSample/Notification/Notification/entry/src/ohosTest/module.json5 b/code/DocsSample/Notification/Notification/entry/src/ohosTest/module.json5 index 7e44e83cf9..e6a499c49e 100644 --- a/code/DocsSample/Notification/Notification/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Notification/Notification/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/DocsSample/Notification/Notification/hvigor/hvigor-config.json5 b/code/DocsSample/Notification/Notification/hvigor/hvigor-config.json5 index fb29482d10..9a79085076 100644 --- a/code/DocsSample/Notification/Notification/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Notification/Notification/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/DocsSample/Notification/Notification/oh-package.json5 b/code/DocsSample/Notification/Notification/oh-package.json5 index 5097761742..1bad7f601d 100644 --- a/code/DocsSample/Notification/Notification/oh-package.json5 +++ b/code/DocsSample/Notification/Notification/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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. - */ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "notification", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "notification", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/DocsSample/Notification/Notification/ohosTest.md b/code/DocsSample/Notification/Notification/ohosTest.md index 44c41be7d0..31049a6bbc 100644 --- a/code/DocsSample/Notification/Notification/ohosTest.md +++ b/code/DocsSample/Notification/Notification/ohosTest.md @@ -1,16 +1,16 @@ -# Notification 测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------- | -------------- | ----------------------- | ------------------------------------------------------------ | :------- | -------- | -| 应用请求通知使能 | 设备正常运行 | 点击使能通知 | 底部弹出提示对话框,显示是否允许"Notification"发送通知.点击确认后开启通知权限 | 是 | Pass | -| 发布设置角标通知 | 已开启通知授权 | 点击设置角标 | 查看角标数量 | 否 | Pass | -| 发布普通文本通知 | 已开启通知授权 | 点击发布普通文本 | 通知栏显示通知图标,下拉后标题为'test_title',文本内容为'test_text',附加信息为'test_additionalText' | 是 | Pass | -| 发布长文本类型通知 | 已开启通知授权 | 点击长文本通知 | 通知栏显示通知图标,下拉后文本标题为 test_expandedTitle 文本内容为 test_longText | 是 | Pass | -| 发布多行文本通知 | 已开启通知授权 | 点击多行文本通知 | 通知栏显示通知图标,下拉后存在文本标题test_longTitle 文本内容为纵向的 'line_01', 'line_02', 'line_03', 'line_04' | 是 | Pass | -| 发布图片类型通知 | 已开启通知授权 | 点击图片通知 | 通知栏显示通知图标,下拉后文本标题为Test_Title 文本内容 为test_text, 弹窗右侧存在图片 | 是 | Pass | -| 发布进度条通知 | 已开启通知授权 | 点击发布进度条通知 | 通知栏显示通知图标,下拉后存在文件下载的进度条 | 否 | Pass | -| 发布公共事件通知 | 已开启通知授权 | 点击发布公共事件通知 | 通知栏显示通知图标,下拉后文本标题 Test_Title 文本内容 test_text | 是 | Pass | -| 发布启动Ability通知 | 已开启通知授权 | 点击发布启动Ability通知 | 通知栏显示通知图标,下拉后存在文本标题 Test_Title 文本内容 test_text,点击后打开 SecondAbility,并进入 | 是 | Pass | - +# Notification 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------- | -------------- | ----------------------- | ------------------------------------------------------------ | :------- | -------- | +| 应用请求通知使能 | 设备正常运行 | 点击使能通知 | 底部弹出提示对话框,显示是否允许"Notification"发送通知.点击确认后开启通知权限 | 是 | Pass | +| 发布设置角标通知 | 已开启通知授权 | 点击设置角标 | 查看角标数量 | 否 | Pass | +| 发布普通文本通知 | 已开启通知授权 | 点击发布普通文本 | 通知栏显示通知图标,下拉后标题为'test_title',文本内容为'test_text',附加信息为'test_additionalText' | 是 | Pass | +| 发布长文本类型通知 | 已开启通知授权 | 点击长文本通知 | 通知栏显示通知图标,下拉后文本标题为 test_expandedTitle 文本内容为 test_longText | 是 | Pass | +| 发布多行文本通知 | 已开启通知授权 | 点击多行文本通知 | 通知栏显示通知图标,下拉后存在文本标题test_longTitle 文本内容为纵向的 'line_01', 'line_02', 'line_03', 'line_04' | 是 | Pass | +| 发布图片类型通知 | 已开启通知授权 | 点击图片通知 | 通知栏显示通知图标,下拉后文本标题为Test_Title 文本内容 为test_text, 弹窗右侧存在图片 | 是 | Pass | +| 发布进度条通知 | 已开启通知授权 | 点击发布进度条通知 | 通知栏显示通知图标,下拉后存在文件下载的进度条 | 否 | Pass | +| 发布公共事件通知 | 已开启通知授权 | 点击发布公共事件通知 | 通知栏显示通知图标,下拉后文本标题 Test_Title 文本内容 test_text | 是 | Pass | +| 发布启动Ability通知 | 已开启通知授权 | 点击发布启动Ability通知 | 通知栏显示通知图标,下拉后存在文本标题 Test_Title 文本内容 test_text,点击后打开 SecondAbility,并进入 | 是 | Pass | + diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/.gitignore b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/app.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/app.json5 old mode 100755 new mode 100644 index 09cfe33a8c..7ce69cd85a --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/app.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/app.json5 @@ -1,25 +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.assetstoreproject", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.assetstoreproject", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/resources/base/element/string.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 730252237f..f5ec105027 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AssetStoreProject" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AssetStoreProject" + } + ] +} diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/README.md b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/README.md old mode 100755 new mode 100644 index 3fb8bd7f71..6e96cbfd4e --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/README.md +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/README.md @@ -1,73 +1,73 @@ -# Asset Store Kit开发指导(ArkTS) - -### 介绍 - -Asset Store Kit(关键资产存储开发套件)包含了关键资产存储服务(ASSET)开放的接口能力集合,提供了用户短敏感数据的安全存储及管理能力。其中,短敏感数据可以是密码类(账号/密码)、Token类(应用凭据)、关键明文(如银行卡号)等长度较短的用户敏感数据。 - -本示例主要展示了Asset Store Kit开发指导(ArkTS)中新增关键资产、删除关键资产、更新关键资产、查询关键资产和查询关键资产场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [新增关键资产(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-js-add.md) -- [删除关键资产(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-js-remove.md) -- [更新关键资产(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-js-update.md) -- [查询关键资产(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-js-query.md) -- [查询需要用户的关键资产(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-js-query-auth.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击文本为‘Add Critical Asset’和'Add Critical Asset Auth'的按钮可以新增资产,点击Remove Critical Asset'和'Remove Critical Asset Second'按钮可以对应删除新增资产点击'Update Critical Asset'、'QueryAll Critical Asset'、'QueryAttributes Critical Asset'、'QueryList Critical Asset'可以依次进行关键资产的更新查询,其中最后一个按钮需要具有用户关键资产点击后才可成功(可以通过设置运行设备锁屏密码后点击图中1,4按钮添加后执行成功弹出输入密码框) -3. 运行测试用例AssetStoreArkTS.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // Asset Store Kit开发指导(ArkTS)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── AssetStoreArkTS.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -ohos.permission.ACCESS_BIOMETRIC - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# Asset Store Kit开发指导(ArkTS) + +### 介绍 + +Asset Store Kit(关键资产存储开发套件)包含了关键资产存储服务(ASSET)开放的接口能力集合,提供了用户短敏感数据的安全存储及管理能力。其中,短敏感数据可以是密码类(账号/密码)、Token类(应用凭据)、关键明文(如银行卡号)等长度较短的用户敏感数据。 + +本示例主要展示了Asset Store Kit开发指导(ArkTS)中新增关键资产、删除关键资产、更新关键资产、查询关键资产和查询关键资产场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [新增关键资产(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-js-add.md) +- [删除关键资产(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-js-remove.md) +- [更新关键资产(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-js-update.md) +- [查询关键资产(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-js-query.md) +- [查询需要用户的关键资产(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-js-query-auth.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击文本为‘Add Critical Asset’和'Add Critical Asset Auth'的按钮可以新增资产,点击Remove Critical Asset'和'Remove Critical Asset Second'按钮可以对应删除新增资产点击'Update Critical Asset'、'QueryAll Critical Asset'、'QueryAttributes Critical Asset'、'QueryList Critical Asset'可以依次进行关键资产的更新查询,其中最后一个按钮需要具有用户关键资产点击后才可成功(可以通过设置运行设备锁屏密码后点击图中1,4按钮添加后执行成功弹出输入密码框) +3. 运行测试用例AssetStoreArkTS.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // Asset Store Kit开发指导(ArkTS)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── AssetStoreArkTS.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +ohos.permission.ACCESS_BIOMETRIC + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS > .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/Security/AssetStoreKit/AssetStoreArkTS/build-profile.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/build-profile.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/code-linter.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/.gitignore b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/build-profile.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/build-profile.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/hvigorfile.ts b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/oh-package.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/oh-package.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/module.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/module.json5 old mode 100755 new mode 100644 index b2b3da6691..e9819632b5 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/module.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/module.json5 @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.ACCESS_BIOMETRIC", - "reason": "$string:reason", - "usedScene": { - "when": "always" - } - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.ACCESS_BIOMETRIC", + "reason": "$string:reason", + "usedScene": { + "when": "always" + } + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/AssetStoreArkTS.test.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/AssetStoreArkTS.test.ets old mode 100755 new mode 100644 index 7718fcb683..654b441b3d --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/AssetStoreArkTS.test.ets +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/AssetStoreArkTS.test.ets @@ -1,111 +1,111 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function assetStoreArkTSTest() { - describe('assetStoreArkTSTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,添加关键资产 - */ - it('testAssetStoreArkTS001', 0, async () => { - console.info('uitest: testAssetStoreArkTS001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Add Critical Asset')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Add Critical Asset Success')); - console.info('uitest: testAssetStoreArkTS001 end'); - }) - - /** - * 点击按钮,添加关键资产 - */ - it('testAssetStoreArkTS002', 0, async () => { - console.info('uitest: testAssetStoreArkTS002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Add Critical Asset Auth')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Add Critical Asset Auth Success')); - console.info('uitest: testAssetStoreArkTS002 end'); - }) - - /** - * 点击按钮,更新查询关键资产 - */ - it('testAssetStoreArkTS003', 0, async () => { - console.info('uitest: testAssetStoreArkTS003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Update Critical Asset')); - const button2 = await driver.findComponent(ON.text('QueryAll Critical Asset')); - const button3 = await driver.findComponent(ON.text('QueryAttributes Critical Asset')); - const button4 = await driver.findComponent(ON.text('QueryList Critical Asset')); - await button1.click(); - await button2.click(); - await button3.click(); - await button4.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Update Critical Asset Success')); - await driver.assertComponentExist(ON.text('QueryAll Critical Asset Success')); - await driver.assertComponentExist(ON.text('QueryAttributes Critical Asset Success')); - await driver.assertComponentExist(ON.text('QueryList Critical Asset Success')); - console.info('uitest: testAssetStoreArkTS003 end'); - }) - - /** - * 点击按钮,删除关键资产 - */ - it('testAssetStoreArkTS004', 0, async () => { - console.info('uitest: testAssetStoreArkTS004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Remove Critical Asset')); - const button2 = await driver.findComponent(ON.text('Remove Critical Asset Second')); - await button1.click(); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Remove Critical Asset Success')); - await driver.assertComponentExist(ON.text('Remove Critical Asset Second Success')); - console.info('uitest: testAssetStoreArkTS004 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function assetStoreArkTSTest() { + describe('assetStoreArkTSTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,添加关键资产 + */ + it('testAssetStoreArkTS001', 0, async () => { + console.info('uitest: testAssetStoreArkTS001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Add Critical Asset')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Add Critical Asset Success')); + console.info('uitest: testAssetStoreArkTS001 end'); + }) + + /** + * 点击按钮,添加关键资产 + */ + it('testAssetStoreArkTS002', 0, async () => { + console.info('uitest: testAssetStoreArkTS002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Add Critical Asset Auth')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Add Critical Asset Auth Success')); + console.info('uitest: testAssetStoreArkTS002 end'); + }) + + /** + * 点击按钮,更新查询关键资产 + */ + it('testAssetStoreArkTS003', 0, async () => { + console.info('uitest: testAssetStoreArkTS003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Update Critical Asset')); + const button2 = await driver.findComponent(ON.text('QueryAll Critical Asset')); + const button3 = await driver.findComponent(ON.text('QueryAttributes Critical Asset')); + const button4 = await driver.findComponent(ON.text('QueryList Critical Asset')); + await button1.click(); + await button2.click(); + await button3.click(); + await button4.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Update Critical Asset Success')); + await driver.assertComponentExist(ON.text('QueryAll Critical Asset Success')); + await driver.assertComponentExist(ON.text('QueryAttributes Critical Asset Success')); + await driver.assertComponentExist(ON.text('QueryList Critical Asset Success')); + console.info('uitest: testAssetStoreArkTS003 end'); + }) + + /** + * 点击按钮,删除关键资产 + */ + it('testAssetStoreArkTS004', 0, async () => { + console.info('uitest: testAssetStoreArkTS004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Remove Critical Asset')); + const button2 = await driver.findComponent(ON.text('Remove Critical Asset Second')); + await button1.click(); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Remove Critical Asset Success')); + await driver.assertComponentExist(ON.text('Remove Critical Asset Second Success')); + console.info('uitest: testAssetStoreArkTS004 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/test/List.test.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/hvigor/hvigor-config.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/AssetStoreKit/AssetStoreArkTS/hvigorfile.ts b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/oh-package.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/oh-package.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/ohosTest.md b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/ohosTest.md old mode 100755 new mode 100644 index 4843a896f8..f2c9d18d6f --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/ohosTest.md +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/ohosTest.md @@ -1,11 +1,11 @@ -# Asset Store Kit(ArkTS)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------------------------- | ------------ | ---- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮新增关键资产 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | -| 点击按钮新增关键资产 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | -| 点击按钮更新并查询关键资产 | 成功拉起应用 | | 成功更新查询并输出日志 | 是 | Pass | +# Asset Store Kit(ArkTS)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------------- | ------------ | ---- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮新增关键资产 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | +| 点击按钮新增关键资产 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | +| 点击按钮更新并查询关键资产 | 成功拉起应用 | | 成功更新查询并输出日志 | 是 | Pass | | 点击按钮移除关键资产 | 成功拉起应用 | | 成功移除并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/screenshots/AssetStoreArkTS1.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/screenshots/AssetStoreArkTS1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/screenshots/AssetStoreArkTS2.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreArkTS/screenshots/AssetStoreArkTS2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/.gitignore b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/app.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/app.json5 old mode 100755 new mode 100644 index 9adf839d88..bcf7c42f7e --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/app.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/app.json5 @@ -1,25 +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.assetstorendk", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.assetstorendk", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/resources/base/element/string.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 14d02017ba..7122455547 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AssetStoreNdk" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AssetStoreNdk" + } + ] +} diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/README.md b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/README.md old mode 100755 new mode 100644 index 51ff1c070d..dd0502b079 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/README.md +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/README.md @@ -1,78 +1,78 @@ -# Asset Store Kit开发指导(C/C++) - -### 介绍 - -Asset Store Kit(关键资产存储开发套件)包含了关键资产存储服务(ASSET)开放的接口能力集合,提供了用户短敏感数据的安全存储及管理能力。其中,短敏感数据可以是密码类(账号/密码)、Token类(应用凭据)、关键明文(如银行卡号)等长度较短的用户敏感数据。 - -本示例主要展示了Asset Store Kit开发指导(C/C++)中新增关键资产、删除关键资产、更新关键资产、查询关键资产场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [新增关键资产(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-native-add.md) -- [删除关键资产(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-native-remove.md) -- [更新关键资产(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-native-update.md) -- [查询关键资产(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-native-query.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击文本为‘AddAsset’的按钮可以新增资产,点击'RemoveAsset'按钮可以删除新增资产,点击'UpdateAsset'、'QueryAsset'、'QueryAttributesAsset'、'BatchQuary'可以依次进行关键资产的更新查询,其中最后一个按钮需要先在添加后直接查询可成功,更新后会导致失败。 -3. 运行测试用例AssetStoreNdk.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ ├── libentry - │ │ | ├── index.d.ts - │ │ ├── CMakeLists.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // Asset Store Kit开发指导(C/C++)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── AssetStoreNdk.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/AssetStoreKit/AssetStoreNdk > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# Asset Store Kit开发指导(C/C++) + +### 介绍 + +Asset Store Kit(关键资产存储开发套件)包含了关键资产存储服务(ASSET)开放的接口能力集合,提供了用户短敏感数据的安全存储及管理能力。其中,短敏感数据可以是密码类(账号/密码)、Token类(应用凭据)、关键明文(如银行卡号)等长度较短的用户敏感数据。 + +本示例主要展示了Asset Store Kit开发指导(C/C++)中新增关键资产、删除关键资产、更新关键资产、查询关键资产场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [新增关键资产(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-native-add.md) +- [删除关键资产(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-native-remove.md) +- [更新关键资产(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-native-update.md) +- [查询关键资产(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AssetStoreKit/asset-native-query.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击文本为‘AddAsset’的按钮可以新增资产,点击'RemoveAsset'按钮可以删除新增资产,点击'UpdateAsset'、'QueryAsset'、'QueryAttributesAsset'、'BatchQuary'可以依次进行关键资产的更新查询,其中最后一个按钮需要先在添加后直接查询可成功,更新后会导致失败。 +3. 运行测试用例AssetStoreNdk.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ ├── libentry + │ │ | ├── index.d.ts + │ │ ├── CMakeLists.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // Asset Store Kit开发指导(C/C++)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── AssetStoreNdk.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/AssetStoreKit/AssetStoreNdk > .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/Security/AssetStoreKit/AssetStoreNdk/build-profile.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/build-profile.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/code-linter.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/.gitignore b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/build-profile.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/build-profile.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/AssetStoreKit/AssetStoreNdk/entry/hvigorfile.ts b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/oh-package.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/oh-package.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 2b6d880a64..5995f4dc00 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(AssetStoreNdk) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(AssetStoreNdk) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libasset_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index b91f7869c8..5722981350 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/napi_init.cpp @@ -1,223 +1,223 @@ -/* - * 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 -#include "asset/asset_api.h" - -static constexpr int INT_ARG_7 = 7; // 入参索引 -static constexpr int INT_ARG_6 = 6; // 入参索引 - -// [Start add_critical_asset] -static napi_value NAPI_Global_AddAsset(napi_env env, napi_callback_info info) -{ - static const char *secretContent = "demo_pwd"; - static const char *aliasContent = "demo_alias"; - static const char *labelContent = "demo_label"; - - Asset_Blob secret = {(uint32_t)(strlen(secretContent)), (uint8_t *)secretContent}; - Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; - Asset_Blob label = {(uint32_t)(strlen(labelContent)), (uint8_t *)labelContent}; - Asset_Attr attr[] = { - {.tag = ASSET_TAG_ACCESSIBILITY, .value.u32 = ASSET_ACCESSIBILITY_DEVICE_FIRST_UNLOCKED}, - {.tag = ASSET_TAG_SECRET, .value.blob = secret}, - {.tag = ASSET_TAG_ALIAS, .value.blob = alias}, - {.tag = ASSET_TAG_DATA_LABEL_NORMAL_1, .value.blob = label}, - }; - - int32_t ret = OH_Asset_Add(attr, sizeof(attr) / sizeof(attr[0])); - napi_value result; - if (ret == ASSET_SUCCESS) { - // Asset added successfully. - napi_create_string_utf8(env, "success", INT_ARG_7, &result); - } else { - // Failed to add Asset. - napi_create_string_utf8(env, "failed", INT_ARG_6, &result); - } - return result; -} -// [End add_critical_asset] - -// [Start remove_critical_asset] -static napi_value RemoveAsset(napi_env env, napi_callback_info info) -{ - static const char *aliasContent = "demo_alias"; - Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; - - Asset_Attr attr[] = { - {.tag = ASSET_TAG_ALIAS, .value.blob = alias}, // 此处指定别名删除,也可不指定别名删除多条数据 - }; - - int32_t ret = OH_Asset_Remove(attr, sizeof(attr) / sizeof(attr[0])); - napi_value result; - if (ret == ASSET_SUCCESS) { - // Asset added successfully. - napi_create_string_utf8(env, "success", INT_ARG_7, &result); - } else { - // Failed to add Asset. - napi_create_string_utf8(env, "failed", INT_ARG_6, &result); - } - return result; -} -// [End remove_critical_asset] - -// [Start update_critical_asset] -static napi_value NAPI_Global_UpdateAsset(napi_env env, napi_callback_info info) -{ - static const char *aliasContent = "demo_alias"; - static const char *secretContent = "demo_pwd_new"; - static const char *labelContent = "demo_label_new"; - - Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; - Asset_Blob new_secret = {(uint32_t)(strlen(secretContent)), (uint8_t *)secretContent}; - Asset_Blob new_label = {(uint32_t)(strlen(labelContent)), (uint8_t *)labelContent}; - Asset_Attr query[] = {{.tag = ASSET_TAG_ALIAS, .value.blob = alias}}; - Asset_Attr attributesToUpdate[] = { - {.tag = ASSET_TAG_SECRET, .value.blob = new_secret}, - {.tag = ASSET_TAG_DATA_LABEL_NORMAL_1, .value.blob = new_label}, - }; - - int32_t ret = OH_Asset_Update(query, sizeof(query) / sizeof(query[0]), attributesToUpdate, - sizeof(attributesToUpdate) / sizeof(attributesToUpdate[0])); - napi_value result; - if (ret == ASSET_SUCCESS) { - // Asset added successfully. - napi_create_string_utf8(env, "success", INT_ARG_7, &result); - } else { - // Failed to add Asset. - napi_create_string_utf8(env, "failed", INT_ARG_6, &result); - } - return result; -} -// [End update_critical_asset] - -// [Start query_single_plaintext] -static napi_value NAPI_Global_QueryAsset(napi_env env, napi_callback_info info) -{ - static const char *aliasContent = "demo_alias"; - Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; - Asset_Attr attr[] = { - {.tag = ASSET_TAG_ALIAS, .value.blob = alias}, // 指定了关键资产别名,最多查询到一条满足条件的关键资产 - {.tag = ASSET_TAG_RETURN_TYPE, - .value.u32 = ASSET_RETURN_ALL}, // 此处表示需要返回关键资产的所有信息,即属性+明文 - }; - - Asset_ResultSet resultSet = {0}; - napi_value result; - int32_t ret = OH_Asset_Query(attr, sizeof(attr) / sizeof(attr[0]), &resultSet); - if (ret == ASSET_SUCCESS) { - // Parse the resultSet. - for (uint32_t i = 0; i < resultSet.count; i++) { - // Parse the secret: the data is secret->blob.data, the size is secret->blob.size. - Asset_Attr *secret = OH_Asset_ParseAttr(resultSet.results + i, ASSET_TAG_SECRET); - } - napi_create_string_utf8(env, "success", INT_ARG_7, &result); - } else { - napi_create_string_utf8(env, "failed", INT_ARG_6, &result); - } - OH_Asset_FreeResultSet(&resultSet); - return result; -} -// [End query_single_plaintext] - -// [Start query_single_attribute] -static napi_value NAPI_Global_QueryAttributes(napi_env env, napi_callback_info info) -{ - static const char *aliasContent = "demo_alias"; - Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; - Asset_Attr attr[] = { - {.tag = ASSET_TAG_ALIAS, .value.blob = alias}, // 指定了关键资产别名,最多查询到一条满足条件的关键资产 - {.tag = ASSET_TAG_RETURN_TYPE, - .value.u32 = ASSET_RETURN_ATTRIBUTES}, // 此处表示仅返回关键资产属性,不包含关键资产明文 - }; - - Asset_ResultSet resultSet = {0}; - int32_t ret = OH_Asset_Query(attr, sizeof(attr) / sizeof(attr[0]), &resultSet); - napi_value result; - if (ret == ASSET_SUCCESS) { - // Parse the result. - for (uint32_t i = 0; i < resultSet.count; i++) { - // Parse the data label: the data is label->blob.data, the size is label->blob.size. - Asset_Attr *label = OH_Asset_ParseAttr(resultSet.results + i, ASSET_TAG_DATA_LABEL_NORMAL_1); - } - napi_create_string_utf8(env, "success", INT_ARG_7, &result); - } else { - napi_create_string_utf8(env, "failed", INT_ARG_6, &result); - } - OH_Asset_FreeResultSet(&resultSet); - return result; -} -// [End query_single_attribute] - -// [Start query_list_attribute] -static napi_value NAPI_Global_BatchQuery(napi_env env, napi_callback_info info) -{ - static const char *labelContent = "demo_label"; - Asset_Blob label = {(uint32_t)(strlen(labelContent)), (uint8_t *)labelContent}; - static const char *aliasContent = "demo_alias"; - Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; - - Asset_Attr attr[] = { - {.tag = ASSET_TAG_RETURN_TYPE, .value.u32 = ASSET_RETURN_ATTRIBUTES}, - {.tag = ASSET_TAG_DATA_LABEL_NORMAL_1, .value.blob = label}, - {.tag = ASSET_TAG_RETURN_OFFSET, .value.u32 = 0}, - {.tag = ASSET_TAG_RETURN_LIMIT, .value.u32 = 1}, - {.tag = ASSET_TAG_RETURN_ORDERED_BY, .value.u32 = ASSET_TAG_DATA_LABEL_NORMAL_1}, - }; - - Asset_ResultSet resultSet = {0}; - int32_t ret = OH_Asset_Query(attr, sizeof(attr) / sizeof(attr[0]), &resultSet); - napi_value result; - if (ret == ASSET_SUCCESS) { - // Parse the result. - for (uint32_t i = 0; i < resultSet.count; i++) { - // Parse the data alias: the data is alias->blob.data, the size is alias->blob.size.. - Asset_Attr *alias = OH_Asset_ParseAttr(resultSet.results + i, ASSET_TAG_ALIAS); - } - napi_create_string_utf8(env, "success", INT_ARG_7, &result); - } else { - napi_create_string_utf8(env, "failed", INT_ARG_6, &result); - } - OH_Asset_FreeResultSet(&resultSet); - return result; -} -// [End query_list_attribute] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"AddAsset", nullptr, NAPI_Global_AddAsset, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"RemoveAsset", nullptr, RemoveAsset, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"UpdateAsset", nullptr, NAPI_Global_UpdateAsset, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"QueryAsset", nullptr, NAPI_Global_QueryAsset, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"QueryAttributes", nullptr, NAPI_Global_QueryAttributes, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"BatchQuery", nullptr, NAPI_Global_BatchQuery, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - +/* + * 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 +#include "asset/asset_api.h" + +static constexpr int INT_ARG_7 = 7; // 入参索引 +static constexpr int INT_ARG_6 = 6; // 入参索引 + +// [Start add_critical_asset] +static napi_value NAPI_Global_AddAsset(napi_env env, napi_callback_info info) +{ + static const char *secretContent = "demo_pwd"; + static const char *aliasContent = "demo_alias"; + static const char *labelContent = "demo_label"; + + Asset_Blob secret = {(uint32_t)(strlen(secretContent)), (uint8_t *)secretContent}; + Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; + Asset_Blob label = {(uint32_t)(strlen(labelContent)), (uint8_t *)labelContent}; + Asset_Attr attr[] = { + {.tag = ASSET_TAG_ACCESSIBILITY, .value.u32 = ASSET_ACCESSIBILITY_DEVICE_FIRST_UNLOCKED}, + {.tag = ASSET_TAG_SECRET, .value.blob = secret}, + {.tag = ASSET_TAG_ALIAS, .value.blob = alias}, + {.tag = ASSET_TAG_DATA_LABEL_NORMAL_1, .value.blob = label}, + }; + + int32_t ret = OH_Asset_Add(attr, sizeof(attr) / sizeof(attr[0])); + napi_value result; + if (ret == ASSET_SUCCESS) { + // Asset added successfully. + napi_create_string_utf8(env, "success", INT_ARG_7, &result); + } else { + // Failed to add Asset. + napi_create_string_utf8(env, "failed", INT_ARG_6, &result); + } + return result; +} +// [End add_critical_asset] + +// [Start remove_critical_asset] +static napi_value RemoveAsset(napi_env env, napi_callback_info info) +{ + static const char *aliasContent = "demo_alias"; + Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; + + Asset_Attr attr[] = { + {.tag = ASSET_TAG_ALIAS, .value.blob = alias}, // 此处指定别名删除,也可不指定别名删除多条数据 + }; + + int32_t ret = OH_Asset_Remove(attr, sizeof(attr) / sizeof(attr[0])); + napi_value result; + if (ret == ASSET_SUCCESS) { + // Asset added successfully. + napi_create_string_utf8(env, "success", INT_ARG_7, &result); + } else { + // Failed to add Asset. + napi_create_string_utf8(env, "failed", INT_ARG_6, &result); + } + return result; +} +// [End remove_critical_asset] + +// [Start update_critical_asset] +static napi_value NAPI_Global_UpdateAsset(napi_env env, napi_callback_info info) +{ + static const char *aliasContent = "demo_alias"; + static const char *secretContent = "demo_pwd_new"; + static const char *labelContent = "demo_label_new"; + + Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; + Asset_Blob new_secret = {(uint32_t)(strlen(secretContent)), (uint8_t *)secretContent}; + Asset_Blob new_label = {(uint32_t)(strlen(labelContent)), (uint8_t *)labelContent}; + Asset_Attr query[] = {{.tag = ASSET_TAG_ALIAS, .value.blob = alias}}; + Asset_Attr attributesToUpdate[] = { + {.tag = ASSET_TAG_SECRET, .value.blob = new_secret}, + {.tag = ASSET_TAG_DATA_LABEL_NORMAL_1, .value.blob = new_label}, + }; + + int32_t ret = OH_Asset_Update(query, sizeof(query) / sizeof(query[0]), attributesToUpdate, + sizeof(attributesToUpdate) / sizeof(attributesToUpdate[0])); + napi_value result; + if (ret == ASSET_SUCCESS) { + // Asset added successfully. + napi_create_string_utf8(env, "success", INT_ARG_7, &result); + } else { + // Failed to add Asset. + napi_create_string_utf8(env, "failed", INT_ARG_6, &result); + } + return result; +} +// [End update_critical_asset] + +// [Start query_single_plaintext] +static napi_value NAPI_Global_QueryAsset(napi_env env, napi_callback_info info) +{ + static const char *aliasContent = "demo_alias"; + Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; + Asset_Attr attr[] = { + {.tag = ASSET_TAG_ALIAS, .value.blob = alias}, // 指定了关键资产别名,最多查询到一条满足条件的关键资产 + {.tag = ASSET_TAG_RETURN_TYPE, + .value.u32 = ASSET_RETURN_ALL}, // 此处表示需要返回关键资产的所有信息,即属性+明文 + }; + + Asset_ResultSet resultSet = {0}; + napi_value result; + int32_t ret = OH_Asset_Query(attr, sizeof(attr) / sizeof(attr[0]), &resultSet); + if (ret == ASSET_SUCCESS) { + // Parse the resultSet. + for (uint32_t i = 0; i < resultSet.count; i++) { + // Parse the secret: the data is secret->blob.data, the size is secret->blob.size. + Asset_Attr *secret = OH_Asset_ParseAttr(resultSet.results + i, ASSET_TAG_SECRET); + } + napi_create_string_utf8(env, "success", INT_ARG_7, &result); + } else { + napi_create_string_utf8(env, "failed", INT_ARG_6, &result); + } + OH_Asset_FreeResultSet(&resultSet); + return result; +} +// [End query_single_plaintext] + +// [Start query_single_attribute] +static napi_value NAPI_Global_QueryAttributes(napi_env env, napi_callback_info info) +{ + static const char *aliasContent = "demo_alias"; + Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; + Asset_Attr attr[] = { + {.tag = ASSET_TAG_ALIAS, .value.blob = alias}, // 指定了关键资产别名,最多查询到一条满足条件的关键资产 + {.tag = ASSET_TAG_RETURN_TYPE, + .value.u32 = ASSET_RETURN_ATTRIBUTES}, // 此处表示仅返回关键资产属性,不包含关键资产明文 + }; + + Asset_ResultSet resultSet = {0}; + int32_t ret = OH_Asset_Query(attr, sizeof(attr) / sizeof(attr[0]), &resultSet); + napi_value result; + if (ret == ASSET_SUCCESS) { + // Parse the result. + for (uint32_t i = 0; i < resultSet.count; i++) { + // Parse the data label: the data is label->blob.data, the size is label->blob.size. + Asset_Attr *label = OH_Asset_ParseAttr(resultSet.results + i, ASSET_TAG_DATA_LABEL_NORMAL_1); + } + napi_create_string_utf8(env, "success", INT_ARG_7, &result); + } else { + napi_create_string_utf8(env, "failed", INT_ARG_6, &result); + } + OH_Asset_FreeResultSet(&resultSet); + return result; +} +// [End query_single_attribute] + +// [Start query_list_attribute] +static napi_value NAPI_Global_BatchQuery(napi_env env, napi_callback_info info) +{ + static const char *labelContent = "demo_label"; + Asset_Blob label = {(uint32_t)(strlen(labelContent)), (uint8_t *)labelContent}; + static const char *aliasContent = "demo_alias"; + Asset_Blob alias = {(uint32_t)(strlen(aliasContent)), (uint8_t *)aliasContent}; + + Asset_Attr attr[] = { + {.tag = ASSET_TAG_RETURN_TYPE, .value.u32 = ASSET_RETURN_ATTRIBUTES}, + {.tag = ASSET_TAG_DATA_LABEL_NORMAL_1, .value.blob = label}, + {.tag = ASSET_TAG_RETURN_OFFSET, .value.u32 = 0}, + {.tag = ASSET_TAG_RETURN_LIMIT, .value.u32 = 1}, + {.tag = ASSET_TAG_RETURN_ORDERED_BY, .value.u32 = ASSET_TAG_DATA_LABEL_NORMAL_1}, + }; + + Asset_ResultSet resultSet = {0}; + int32_t ret = OH_Asset_Query(attr, sizeof(attr) / sizeof(attr[0]), &resultSet); + napi_value result; + if (ret == ASSET_SUCCESS) { + // Parse the result. + for (uint32_t i = 0; i < resultSet.count; i++) { + // Parse the data alias: the data is alias->blob.data, the size is alias->blob.size.. + Asset_Attr *alias = OH_Asset_ParseAttr(resultSet.results + i, ASSET_TAG_ALIAS); + } + napi_create_string_utf8(env, "success", INT_ARG_7, &result); + } else { + napi_create_string_utf8(env, "failed", INT_ARG_6, &result); + } + OH_Asset_FreeResultSet(&resultSet); + return result; +} +// [End query_list_attribute] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"AddAsset", nullptr, NAPI_Global_AddAsset, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"RemoveAsset", nullptr, RemoveAsset, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"UpdateAsset", nullptr, NAPI_Global_UpdateAsset, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"QueryAsset", nullptr, NAPI_Global_QueryAsset, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"QueryAttributes", nullptr, NAPI_Global_QueryAttributes, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"BatchQuery", nullptr, NAPI_Global_BatchQuery, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index 620010e4c8..67a55cce53 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,26 +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. - */ - -export const AddAsset: () => string; - -export const RemoveAsset: () => string; - -export const UpdateAsset: () => string; - -export const QueryAsset: () => string; - -export const QueryAttributes: () => string; - +/* + * 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 AddAsset: () => string; + +export const RemoveAsset: () => string; + +export const UpdateAsset: () => string; + +export const QueryAsset: () => string; + +export const QueryAttributes: () => string; + export const BatchQuery: () => string; \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index a36ca588fe..965554bb3a --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 8ed0bcf328..bf6003c3e1 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/ets/pages/Index.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { hilog } from '@kit.PerformanceAnalysisKit'; -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'AssetStoreNdk'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(20) - .fontWeight(FontWeight.Bold) - .textAlign(TextAlign.Center) - Button('AddAsset') - .width('70%') - .onClick(() => { - hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.AddAsset()) // 新增 - this.message = 'AddAsset success'; - }) - Button('RemoveAsset') - .width('70%') - .onClick(() => { - hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.RemoveAsset()) // 删除 - this.message = 'RemoveAsset success'; - }) - Button('UpdateAsset') - .width('70%') - .onClick(() => { - hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.UpdateAsset()) //更新 - this.message = 'UpdateAsset success'; - }) - Button('QueryAsset') - .width('70%') - .onClick(() => { - hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.QueryAsset()) - this.message = 'QueryAsset success'; - }) - Button('QueryAttributes') - .width('70%') - .onClick(() => { - hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.QueryAttributes()) - this.message = 'QueryAttributes success'; - }) - Button('BatchQuery') - .width('70%') - .onClick(() => { - hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.BatchQuery()) // 更新前进行查询成功 更新后会失败 - this.message = 'BatchQuery success'; - }) - } - .height('100%') - .width('100%') - .alignItems(HorizontalAlign.Center) - .justifyContent(FlexAlign.Center) - } +/* + * 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 testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State message: string = 'AssetStoreNdk'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Center) + Button('AddAsset') + .width('70%') + .onClick(() => { + hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.AddAsset()) // 新增 + this.message = 'AddAsset success'; + }) + Button('RemoveAsset') + .width('70%') + .onClick(() => { + hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.RemoveAsset()) // 删除 + this.message = 'RemoveAsset success'; + }) + Button('UpdateAsset') + .width('70%') + .onClick(() => { + hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.UpdateAsset()) //更新 + this.message = 'UpdateAsset success'; + }) + Button('QueryAsset') + .width('70%') + .onClick(() => { + hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.QueryAsset()) + this.message = 'QueryAsset success'; + }) + Button('QueryAttributes') + .width('70%') + .onClick(() => { + hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.QueryAttributes()) + this.message = 'QueryAttributes success'; + }) + Button('BatchQuery') + .width('70%') + .onClick(() => { + hilog.info(0x0000, 'testTag', 'GenerateKey %{public}s', testNapi.BatchQuery()) // 更新前进行查询成功 更新后会失败 + this.message = 'BatchQuery success'; + }) + } + .height('100%') + .width('100%') + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + } } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/module.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/module.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/AssetStoreNdk.test.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/AssetStoreNdk.test.ets old mode 100755 new mode 100644 index a018f3333c..50f1d72df2 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/AssetStoreNdk.test.ets +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/AssetStoreNdk.test.ets @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function assetStoreNdkTest() { - describe('assetStoreNdkTest', () => { - - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - it('testAssetStoreNdk001', 0, async () => { - console.info('uitest: testAssetStoreNdk001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('AddAsset')); - const button2 = await driver.findComponent(ON.text('RemoveAsset')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AddAsset success')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RemoveAsset success')); - await button1.click(); - console.info('uitest: testAssetStoreNdk001 end'); - }) - - it('testAssetStoreNdk002', 0, async () => { - console.info('uitest: testAssetStoreNdk002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('BatchQuery')); - const button2 = await driver.findComponent(ON.text('UpdateAsset')); - const button3 = await driver.findComponent(ON.text('QueryAsset')); - const button4 = await driver.findComponent(ON.text('QueryAttributes')); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('BatchQuery success')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('UpdateAsset success')); - await button3.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('QueryAsset success')); - await button4.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('QueryAttributes success')); - console.info('uitest: testAssetStoreNdk002 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function assetStoreNdkTest() { + describe('assetStoreNdkTest', () => { + + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + it('testAssetStoreNdk001', 0, async () => { + console.info('uitest: testAssetStoreNdk001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('AddAsset')); + const button2 = await driver.findComponent(ON.text('RemoveAsset')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AddAsset success')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RemoveAsset success')); + await button1.click(); + console.info('uitest: testAssetStoreNdk001 end'); + }) + + it('testAssetStoreNdk002', 0, async () => { + console.info('uitest: testAssetStoreNdk002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('BatchQuery')); + const button2 = await driver.findComponent(ON.text('UpdateAsset')); + const button3 = await driver.findComponent(ON.text('QueryAsset')); + const button4 = await driver.findComponent(ON.text('QueryAttributes')); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('BatchQuery success')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('UpdateAsset success')); + await button3.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('QueryAsset success')); + await button4.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('QueryAttributes success')); + console.info('uitest: testAssetStoreNdk002 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/test/List.test.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/hvigor/hvigor-config.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/AssetStoreKit/AssetStoreNdk/hvigorfile.ts b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/oh-package.json5 b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/oh-package.json5 +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/ohosTest.md b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/ohosTest.md old mode 100755 new mode 100644 index 8ac0e7544a..e0aec39739 --- a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/ohosTest.md +++ b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/ohosTest.md @@ -1,10 +1,10 @@ -# Asset Store Kit(C/C++)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------------------------- | ------------ | ---- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮新增关键资产 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | -| 点击按钮移除关键资产 | 成功拉起应用 | | 成功移除并输出日志 | 是 | Pass | +# Asset Store Kit(C/C++)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------------- | ------------ | ---- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮新增关键资产 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | +| 点击按钮移除关键资产 | 成功拉起应用 | | 成功移除并输出日志 | 是 | Pass | | 点击按钮更新并查询关键资产 | 成功拉起应用 | | 成功更新查询并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/screenshots/AssetStoreNdk1.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/screenshots/AssetStoreNdk1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/screenshots/AssetStoreNdk2.png b/code/DocsSample/Security/AssetStoreKit/AssetStoreNdk/screenshots/AssetStoreNdk2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/app.json5 old mode 100755 new mode 100644 index bc63d611f3..d62c80428d --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/app.json5 @@ -1,25 +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.encryptiondecryptionguidance3des", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.encryptiondecryptionguidance3des", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 97555a321d..c9880ec1f7 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "EncryptionDecryptionGuidance3DES" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "EncryptionDecryptionGuidance3DES" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/README.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/README.md old mode 100755 new mode 100644 index d5002e4966..d111c6f8f4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/README.md @@ -1,81 +1,81 @@ -# 使用3DES对称密钥(ECB模式)加解密 - -### 介绍 - -本示例主要展示了使用3DES对称密钥(ECB模式)加解密(ArkTS)的同步异步方法和C/C++场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用3DES对称密钥(ECB模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-3des-sym-encrypt-decrypt-ecb.md) -- [使用3DES对称密钥(ECB模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-3des-sym-encrypt-decrypt-ecb-ndk.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例EncryptionDecryptionGuidance3DES.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── 3des_ecb_encryption_decryption.cpp - │ │ | ├── file.h - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用3DES对称密钥(ECB模式)加解密示例代码 - │ │ ├── 3des_ecb_encryption_decryption.ets - │ │ ├── 3des_ecb_encryption_decryption_asynchronous.ets - │ │ ├── 3des_ecb_encryption_decryption_synchronous.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── EncryptionDecryptionGuidance3DES.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 使用3DES对称密钥(ECB模式)加解密 + +### 介绍 + +本示例主要展示了使用3DES对称密钥(ECB模式)加解密(ArkTS)的同步异步方法和C/C++场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用3DES对称密钥(ECB模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-3des-sym-encrypt-decrypt-ecb.md) +- [使用3DES对称密钥(ECB模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-3des-sym-encrypt-decrypt-ecb-ndk.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例EncryptionDecryptionGuidance3DES.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── 3des_ecb_encryption_decryption.cpp + │ │ | ├── file.h + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用3DES对称密钥(ECB模式)加解密示例代码 + │ │ ├── 3des_ecb_encryption_decryption.ets + │ │ ├── 3des_ecb_encryption_decryption_asynchronous.ets + │ │ ├── 3des_ecb_encryption_decryption_synchronous.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── EncryptionDecryptionGuidance3DES.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES > .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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index ebfec4c614..05757dad0a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(EncryptionDecryptionGuidance3DESArkTs) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp types/project/3des_ecb_encryption_decryption.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(EncryptionDecryptionGuidance3DESArkTs) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp types/project/3des_ecb_encryption_decryption.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index d998ee2fc2..075d3ed0a5 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/napi_init.cpp @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" -#include "types/project/file.h" - -static napi_value NAPI_Global_doTest3DesEcb(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTest3DesEcb(), &ret); - return ret; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"doTest3DesEcb", nullptr, NAPI_Global_doTest3DesEcb, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/file.h" + +static napi_value NAPI_Global_doTest3DesEcb(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTest3DesEcb(), &ret); + return ret; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"doTest3DesEcb", nullptr, NAPI_Global_doTest3DesEcb, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index eca27a27b1..feacf528f9 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 doTest3DesEcb: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/project/3des_ecb_encryption_decryption.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/project/3des_ecb_encryption_decryption.cpp old mode 100755 new mode 100644 index 76129259f8..197ef6b1fc --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/project/3des_ecb_encryption_decryption.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/project/3des_ecb_encryption_decryption.cpp @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start crypt_decrypt_flow] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" -#include -#include "file.h" - -OH_Crypto_ErrCode doTest3DesEcb() -{ - OH_CryptoSymKeyGenerator *genCtx = nullptr; - OH_CryptoSymCipher *encCtx = nullptr; - OH_CryptoSymCipher *decCtx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - OH_CryptoSymCipherParams *params = nullptr; - char *plainText = const_cast("this is test!"); - Crypto_DataBlob input = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; - Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("3DES192", &genCtx); // 随机生成对称密钥 - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_Create(¶ms); // 创建参数 - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Create("3DES192|ECB|PKCS7", &encCtx); // 加密操作 - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(encCtx, &input, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Create("3DES192|ECB|PKCS7", &decCtx); // 解密操作 - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } -end: - OH_CryptoSymCipherParams_Destroy(params); - OH_CryptoSymCipher_Destroy(encCtx); - OH_CryptoSymCipher_Destroy(decCtx); - OH_CryptoSymKeyGenerator_Destroy(genCtx); - OH_CryptoSymKey_Destroy(keyCtx); - OH_Crypto_FreeDataBlob(&outUpdate); - OH_Crypto_FreeDataBlob(&decUpdate); - return ret; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start crypt_decrypt_flow] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" +#include +#include "file.h" + +OH_Crypto_ErrCode doTest3DesEcb() +{ + OH_CryptoSymKeyGenerator *genCtx = nullptr; + OH_CryptoSymCipher *encCtx = nullptr; + OH_CryptoSymCipher *decCtx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + OH_CryptoSymCipherParams *params = nullptr; + char *plainText = const_cast("this is test!"); + Crypto_DataBlob input = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; + Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("3DES192", &genCtx); // 随机生成对称密钥 + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_Create(¶ms); // 创建参数 + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Create("3DES192|ECB|PKCS7", &encCtx); // 加密操作 + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(encCtx, &input, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Create("3DES192|ECB|PKCS7", &decCtx); // 解密操作 + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } +end: + OH_CryptoSymCipherParams_Destroy(params); + OH_CryptoSymCipher_Destroy(encCtx); + OH_CryptoSymCipher_Destroy(decCtx); + OH_CryptoSymKeyGenerator_Destroy(genCtx); + OH_CryptoSymKey_Destroy(keyCtx); + OH_Crypto_FreeDataBlob(&outUpdate); + OH_Crypto_FreeDataBlob(&decUpdate); + return ret; +} // [End crypt_decrypt_flow] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/project/file.h b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/project/file.h old mode 100755 new mode 100644 index ef588998c3..7e388d978e --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/project/file.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/cpp/types/project/file.h @@ -1,23 +1,23 @@ -#ifndef FILE_H -#define FILE_H -/* - * 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 "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" - -OH_Crypto_ErrCode doTest3DesEcb(); - +#ifndef FILE_H +#define FILE_H +/* + * 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 "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" + +OH_Crypto_ErrCode doTest3DesEcb(); + #endif // FILE_H \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption.ets old mode 100755 new mode 100644 index 28b1e6e094..9b26168d82 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption.ets @@ -1,36 +1,36 @@ -/* - * 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 { - @State message: string = 'Encryption Decryption Guidance 3DES'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_3des_ecb')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.doTest3DesEcb(); - this.message = 'Call Success Result:' + ret.toString(); - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { + @State message: string = 'Encryption Decryption Guidance 3DES'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_3des_ecb')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.doTest3DesEcb(); + this.message = 'Call Success Result:' + ret.toString(); + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_asynchronous.ets old mode 100755 new mode 100644 index d5e657a6a6..574aaf4958 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_asynchronous.ets @@ -1,84 +1,84 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start async_symmetry_encrypt_decrypt] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 加密消息 -async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('3DES192|ECB|PKCS7'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); - let encryptData = await cipher.doFinal(plainText); - return encryptData; -} - -// 解密消息 -async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('3DES192|ECB|PKCS7'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); - let decryptData = await decoder.doFinal(cipherText); - return decryptData; -} - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let symGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); - let symKey = await symGenerator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function main() { - let keyData = - new Uint8Array([238, 249, 61, 55, 128, 220, 183, 224, 139, 253, 248, 239, 239, 41, 71, 25, 235, 206, 230, 162, 249, - 27, 234, 114]); - let symKey = await genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessagePromise(symKey, plainText); - let decryptText = await decryptMessagePromise(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End async_symmetry_encrypt_decrypt] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance 3DES ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_3des_ecb_asynchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = '3DES_ECBSuccess'; - } catch { - this.message = '3DES_ECBFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start async_symmetry_encrypt_decrypt] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 加密消息 +async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('3DES192|ECB|PKCS7'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); + let encryptData = await cipher.doFinal(plainText); + return encryptData; +} + +// 解密消息 +async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('3DES192|ECB|PKCS7'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); + let decryptData = await decoder.doFinal(cipherText); + return decryptData; +} + +async function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let symGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); + let symKey = await symGenerator.convertKey(symKeyBlob); + console.info('convertKey success'); + return symKey; +} + +async function main() { + let keyData = + new Uint8Array([238, 249, 61, 55, 128, 220, 183, 224, 139, 253, 248, 239, 239, 41, 71, 25, 235, 206, 230, 162, 249, + 27, 234, 114]); + let symKey = await genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await encryptMessagePromise(symKey, plainText); + let decryptText = await decryptMessagePromise(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} +// [End async_symmetry_encrypt_decrypt] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance 3DES ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_3des_ecb_asynchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = '3DES_ECBSuccess'; + } catch { + this.message = '3DES_ECBFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_synchronous.ets old mode 100755 new mode 100644 index 6e4f3404f7..9e6078b4b8 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_synchronous.ets @@ -1,84 +1,84 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start sync_symmetry_encrypt_decrypt] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 加密消息 -function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('3DES192|ECB|PKCS7'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); - let encryptData = cipher.doFinalSync(plainText); - return encryptData; -} - -// 解密消息 -function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('3DES192|ECB|PKCS7'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); - let decryptData = decoder.doFinalSync(cipherText); - return decryptData; -} - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let symGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); - let symKey = symGenerator.convertKeySync(symKeyBlob); - console.info('convertKeySync success'); - return symKey; -} - -function main() { - let keyData = - new Uint8Array([238, 249, 61, 55, 128, 220, 183, 224, 139, 253, 248, 239, 239, 41, 71, 25, 235, 206, 230, 162, 249, - 27, 234, 114]); - let symKey = genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessage(symKey, plainText); - let decryptText = decryptMessage(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End sync_symmetry_encrypt_decrypt] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance 3DES ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_3des_ecb_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = '3DES_ECBSuccess'; - } catch { - this.message = '3DES_ECBFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start sync_symmetry_encrypt_decrypt] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 加密消息 +function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('3DES192|ECB|PKCS7'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); + let encryptData = cipher.doFinalSync(plainText); + return encryptData; +} + +// 解密消息 +function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('3DES192|ECB|PKCS7'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); + let decryptData = decoder.doFinalSync(cipherText); + return decryptData; +} + +function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let symGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); + let symKey = symGenerator.convertKeySync(symKeyBlob); + console.info('convertKeySync success'); + return symKey; +} + +function main() { + let keyData = + new Uint8Array([238, 249, 61, 55, 128, 220, 183, 224, 139, 253, 248, 239, 239, 41, 71, 25, 235, 206, 230, 162, 249, + 27, 234, 114]); + let symKey = genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = encryptMessage(symKey, plainText); + let decryptText = decryptMessage(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} +// [End sync_symmetry_encrypt_decrypt] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance 3DES ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_3des_ecb_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = '3DES_ECBSuccess'; + } catch { + this.message = '3DES_ECBFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/mock/mock-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidance3DES.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidance3DES.test.ets old mode 100755 new mode 100644 index 5147c7202c..df2a2c7b59 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidance3DES.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidance3DES.test.ets @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function encryptionDecryptionGuidance3DESTest() { - describe('encryptionDecryptionGuidance3DESTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用3DES对称密钥(ECB模式)加解密(ArkTS),异步方法 - */ - it('testEncryptionDecryptionGuidance3DES001', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DES001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('3des_ecb_encryption_decryption_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call 3DES_ECB Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('3DES_ECBSuccess')); - console.info('uitest: testEncryptionDecryptionGuidance3DES001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用3DES对称密钥(ECB模式)加解密(ArkTS),同步方法 - */ - it('testEncryptionDecryptionGuidance3DES002', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DES002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('3des_ecb_encryption_decryption_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call 3DES_ECB Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('3DES_ECBSuccess')); - console.info('uitest: testEncryptionDecryptionGuidance3DES002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用3DES对称密钥(ECB模式)加解密(C/C++) - */ - it('testEncryptionDecryptionGuidance3DES003', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DES003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('3des_ecb_encryption_decryption')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call 3DES_ECB')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call Success Result:0')); - console.info('uitest: testEncryptionDecryptionGuidance3DES003 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function encryptionDecryptionGuidance3DESTest() { + describe('encryptionDecryptionGuidance3DESTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用3DES对称密钥(ECB模式)加解密(ArkTS),异步方法 + */ + it('testEncryptionDecryptionGuidance3DES001', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DES001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('3des_ecb_encryption_decryption_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call 3DES_ECB Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('3DES_ECBSuccess')); + console.info('uitest: testEncryptionDecryptionGuidance3DES001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用3DES对称密钥(ECB模式)加解密(ArkTS),同步方法 + */ + it('testEncryptionDecryptionGuidance3DES002', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DES002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('3des_ecb_encryption_decryption_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call 3DES_ECB Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('3DES_ECBSuccess')); + console.info('uitest: testEncryptionDecryptionGuidance3DES002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用3DES对称密钥(ECB模式)加解密(C/C++) + */ + it('testEncryptionDecryptionGuidance3DES003', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DES003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('3des_ecb_encryption_decryption')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call 3DES_ECB')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call Success Result:0')); + console.info('uitest: testEncryptionDecryptionGuidance3DES003 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/ohosTest.md old mode 100755 new mode 100644 index d03d8f9d22..c603d0ffe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/ohosTest.md @@ -1,10 +1,10 @@ -# 使用3DES对称密钥(ECB模式)加解密测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用3DES对称密钥(ECB模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用3DES对称密钥(ECB模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 使用3DES对称密钥(ECB模式)加解密测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用3DES对称密钥(ECB模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用3DES对称密钥(ECB模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用3DES对称密钥(ECB模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/screenshots/EncryptionDecryptionGuidance3DES1.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/screenshots/EncryptionDecryptionGuidance3DES1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/screenshots/EncryptionDecryptionGuidance3DES2.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/screenshots/EncryptionDecryptionGuidance3DES2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/app.json5 old mode 100755 new mode 100644 index 2aa8298fa5..153d7314e8 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/app.json5 @@ -1,25 +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.encryptiondecryptionguidanceaes", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.encryptiondecryptionguidanceaes", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 15f59c2fc0..41dc2dbd55 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "EncryptionDecryptionGuidanceAes" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "EncryptionDecryptionGuidanceAes" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/README.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/README.md old mode 100755 new mode 100644 index f31966a89e..35cf64d81c --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/README.md @@ -1,85 +1,85 @@ -# 使用AES对称密钥加解密(C/C++) - -### 介绍 - -本示例主要展示了使用AES对称密钥(C/C++)GCM模式、CCM模式、CBC模式、ECB模式以及GCM模式分段加解密场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用AES对称密钥(GCM模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-gcm-ndk.md) -- [使用AES对称密钥(CCM模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-ccm-ndk.md) -- [使用AES对称密钥(CBC模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-cbc-ndk.md) -- [使用AES对称密钥(ECB模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-ecb-ndk.md) -- [使用AES对称密钥(GCM模式)分段加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-gcm-by-segment-ndk.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例EncryptionDecryptionGuidanceAes.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── aes_cbc_encryption_decryption.cpp - │ │ | ├── aes_ccm_encryption_decryption.cpp - │ │ | ├── aes_ecb_encryption_decryption.cpp - │ │ | ├── aes_gcm_encryption_decryption.cpp - │ │ | ├── aes_gcm_segment_encryption_decryption.cpp - │ │ | ├── file.h - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用AES对称密钥加解密(C/C++)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── EncryptionDecryptionGuidanceAes.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 使用AES对称密钥加解密(C/C++) + +### 介绍 + +本示例主要展示了使用AES对称密钥(C/C++)GCM模式、CCM模式、CBC模式、ECB模式以及GCM模式分段加解密场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用AES对称密钥(GCM模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-gcm-ndk.md) +- [使用AES对称密钥(CCM模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-ccm-ndk.md) +- [使用AES对称密钥(CBC模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-cbc-ndk.md) +- [使用AES对称密钥(ECB模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-ecb-ndk.md) +- [使用AES对称密钥(GCM模式)分段加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-gcm-by-segment-ndk.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例EncryptionDecryptionGuidanceAes.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── aes_cbc_encryption_decryption.cpp + │ │ | ├── aes_ccm_encryption_decryption.cpp + │ │ | ├── aes_ecb_encryption_decryption.cpp + │ │ | ├── aes_gcm_encryption_decryption.cpp + │ │ | ├── aes_gcm_segment_encryption_decryption.cpp + │ │ | ├── file.h + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用AES对称密钥加解密(C/C++)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── EncryptionDecryptionGuidanceAes.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes > .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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index a3c5ee621e..6123b8267a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(EncryptionDecryptionGuidanceAes) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp types/project/aes_gcm_encryption_decryption.cpp types/project/aes_ccm_encryption_decryption.cpp types/project/aes_cbc_encryption_decryption.cpp types/project/aes_ecb_encryption_decryption.cpp types/project/aes_gcm_segment_encryption_decryption.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(EncryptionDecryptionGuidanceAes) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp types/project/aes_gcm_encryption_decryption.cpp types/project/aes_ccm_encryption_decryption.cpp types/project/aes_cbc_encryption_decryption.cpp types/project/aes_ecb_encryption_decryption.cpp types/project/aes_gcm_segment_encryption_decryption.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index ed2270c009..835ac96773 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/napi_init.cpp @@ -1,78 +1,78 @@ -/* - * 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 "types/project/file.h" - -static napi_value NAPI_Global_doTestAesGcm(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestAesGcm(), &ret); - return ret; -} - -static napi_value NAPI_Global_doTestAesCcm(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestAesCcm(), &ret); - return ret; -} - -static napi_value NAPI_Global_doTestAesCbc(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestAesCbc(), &ret); - return ret; -} - -static napi_value NAPI_Global_doTestAesEcb(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestAesEcb(), &ret); - return ret; -} - -static napi_value NAPI_Global_testAesGcmSeg(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestAesGcmSeg(), &ret); - return ret; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"testAesGcm", nullptr, NAPI_Global_doTestAesGcm, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"testAesCcm", nullptr, NAPI_Global_doTestAesCcm, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"testAesCbc", nullptr, NAPI_Global_doTestAesCbc, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"testAesEcb", nullptr, NAPI_Global_doTestAesEcb, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"testAesGcmSeg", nullptr, NAPI_Global_testAesGcmSeg, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/file.h" + +static napi_value NAPI_Global_doTestAesGcm(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestAesGcm(), &ret); + return ret; +} + +static napi_value NAPI_Global_doTestAesCcm(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestAesCcm(), &ret); + return ret; +} + +static napi_value NAPI_Global_doTestAesCbc(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestAesCbc(), &ret); + return ret; +} + +static napi_value NAPI_Global_doTestAesEcb(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestAesEcb(), &ret); + return ret; +} + +static napi_value NAPI_Global_testAesGcmSeg(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestAesGcmSeg(), &ret); + return ret; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"testAesGcm", nullptr, NAPI_Global_doTestAesGcm, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"testAesCcm", nullptr, NAPI_Global_doTestAesCcm, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"testAesCbc", nullptr, NAPI_Global_doTestAesCbc, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"testAesEcb", nullptr, NAPI_Global_doTestAesEcb, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"testAesGcmSeg", nullptr, NAPI_Global_testAesGcmSeg, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index e50d1a0437..12eaa92556 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export const testAesGcm: () => number; - -export const testAesCcm: () => number; - -export const testAesCbc: () => number; - -export const testAesEcb: () => number; - -export const testAesGcmSeg: () => number; +/* + * 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 testAesGcm: () => number; + +export const testAesCcm: () => number; + +export const testAesCbc: () => number; + +export const testAesEcb: () => number; + +export const testAesGcmSeg: () => number; diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_cbc_encryption_decryption.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_cbc_encryption_decryption.cpp old mode 100755 new mode 100644 index 0b16684b2d..5546576bab --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_cbc_encryption_decryption.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_cbc_encryption_decryption.cpp @@ -1,93 +1,93 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start cbc_encrypt_decrypt_aes_symkey] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" -#include -#include "file.h" - -OH_Crypto_ErrCode doTestAesCbc() -{ - OH_CryptoSymKeyGenerator *genCtx = nullptr; - OH_CryptoSymCipher *encCtx = nullptr; - OH_CryptoSymCipher *decCtx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - OH_CryptoSymCipherParams *params = nullptr; - Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; - char *plainText = const_cast("this is test!"); - Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; - uint8_t iv[16] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4, 3, 1, 0, 10}; // iv使用安全随机数生成 - Crypto_DataBlob ivBlob = {.data = iv, .len = sizeof(iv)}; - // 生成对称密钥 - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES128", &genCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 设置参数 - ret = OH_CryptoSymCipherParams_Create(¶ms); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivBlob); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 加密 - ret = OH_CryptoSymCipher_Create("AES128|CBC|PKCS7", &encCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(encCtx, &msgBlob, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 解密 - ret = OH_CryptoSymCipher_Create("AES128|CBC|PKCS7", &decCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - -end: - OH_CryptoSymCipherParams_Destroy(params); - OH_CryptoSymCipher_Destroy(encCtx); - OH_CryptoSymCipher_Destroy(decCtx); - OH_CryptoSymKeyGenerator_Destroy(genCtx); - OH_CryptoSymKey_Destroy(keyCtx); - OH_Crypto_FreeDataBlob(&outUpdate); - OH_Crypto_FreeDataBlob(&decUpdate); - return ret; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start cbc_encrypt_decrypt_aes_symkey] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" +#include +#include "file.h" + +OH_Crypto_ErrCode doTestAesCbc() +{ + OH_CryptoSymKeyGenerator *genCtx = nullptr; + OH_CryptoSymCipher *encCtx = nullptr; + OH_CryptoSymCipher *decCtx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + OH_CryptoSymCipherParams *params = nullptr; + Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; + char *plainText = const_cast("this is test!"); + Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; + uint8_t iv[16] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4, 3, 1, 0, 10}; // iv使用安全随机数生成 + Crypto_DataBlob ivBlob = {.data = iv, .len = sizeof(iv)}; + // 生成对称密钥 + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES128", &genCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 设置参数 + ret = OH_CryptoSymCipherParams_Create(¶ms); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivBlob); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 加密 + ret = OH_CryptoSymCipher_Create("AES128|CBC|PKCS7", &encCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(encCtx, &msgBlob, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 解密 + ret = OH_CryptoSymCipher_Create("AES128|CBC|PKCS7", &decCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + +end: + OH_CryptoSymCipherParams_Destroy(params); + OH_CryptoSymCipher_Destroy(encCtx); + OH_CryptoSymCipher_Destroy(decCtx); + OH_CryptoSymKeyGenerator_Destroy(genCtx); + OH_CryptoSymKey_Destroy(keyCtx); + OH_Crypto_FreeDataBlob(&outUpdate); + OH_Crypto_FreeDataBlob(&decUpdate); + return ret; +} // [End cbc_encrypt_decrypt_aes_symkey] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_ccm_encryption_decryption.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_ccm_encryption_decryption.cpp old mode 100755 new mode 100644 index 088d9e43cc..2ccbd56687 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_ccm_encryption_decryption.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_ccm_encryption_decryption.cpp @@ -1,117 +1,117 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start ccm_encrypt_decrypt_aes_symkey] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" -#include -#include "file.h" - -OH_Crypto_ErrCode doTestAesCcm() -{ - OH_CryptoSymKeyGenerator *genCtx = nullptr; - OH_CryptoSymCipher *encCtx = nullptr; - OH_CryptoSymCipher *decCtx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - OH_CryptoSymCipherParams *params = nullptr; - - Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; - - uint8_t aad[8] = {1, 2, 3, 4, 5, 6, 7, 8}; - uint8_t tag[12] = {0}; - uint8_t iv[7] = {1, 2, 4, 12, 3, 4, 2}; // iv使用安全随机数生成 - Crypto_DataBlob ivData = {.data = iv, .len = sizeof(iv)}; - Crypto_DataBlob aadData = {.data = aad, .len = sizeof(aad)}; - Crypto_DataBlob tagData = {.data = tag, .len = sizeof(tag)}; - Crypto_DataBlob tagOutPut = {.data = nullptr, .len = 0}; - char *plainText = const_cast("this is test!"); - Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; - // 生成对称密钥 - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES128", &genCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 设置参数 - ret = OH_CryptoSymCipherParams_Create(¶ms); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivData); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_AAD_DATABLOB, &aadData); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagData); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 加密 - ret = OH_CryptoSymCipher_Create("AES128|CCM", &encCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Update(encCtx, &msgBlob, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(encCtx, nullptr, &tagOutPut); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 解密 - ret = OH_CryptoSymCipher_Create("AES128|CCM", &decCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagOutPut); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - -end: - OH_CryptoSymCipherParams_Destroy(params); - OH_CryptoSymCipher_Destroy(encCtx); - OH_CryptoSymCipher_Destroy(decCtx); - OH_CryptoSymKeyGenerator_Destroy(genCtx); - OH_CryptoSymKey_Destroy(keyCtx); - OH_Crypto_FreeDataBlob(&outUpdate); - OH_Crypto_FreeDataBlob(&decUpdate); - OH_Crypto_FreeDataBlob(&tagOutPut); - return ret; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start ccm_encrypt_decrypt_aes_symkey] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" +#include +#include "file.h" + +OH_Crypto_ErrCode doTestAesCcm() +{ + OH_CryptoSymKeyGenerator *genCtx = nullptr; + OH_CryptoSymCipher *encCtx = nullptr; + OH_CryptoSymCipher *decCtx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + OH_CryptoSymCipherParams *params = nullptr; + + Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; + + uint8_t aad[8] = {1, 2, 3, 4, 5, 6, 7, 8}; + uint8_t tag[12] = {0}; + uint8_t iv[7] = {1, 2, 4, 12, 3, 4, 2}; // iv使用安全随机数生成 + Crypto_DataBlob ivData = {.data = iv, .len = sizeof(iv)}; + Crypto_DataBlob aadData = {.data = aad, .len = sizeof(aad)}; + Crypto_DataBlob tagData = {.data = tag, .len = sizeof(tag)}; + Crypto_DataBlob tagOutPut = {.data = nullptr, .len = 0}; + char *plainText = const_cast("this is test!"); + Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; + // 生成对称密钥 + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES128", &genCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 设置参数 + ret = OH_CryptoSymCipherParams_Create(¶ms); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivData); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_AAD_DATABLOB, &aadData); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagData); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 加密 + ret = OH_CryptoSymCipher_Create("AES128|CCM", &encCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Update(encCtx, &msgBlob, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(encCtx, nullptr, &tagOutPut); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 解密 + ret = OH_CryptoSymCipher_Create("AES128|CCM", &decCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagOutPut); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + +end: + OH_CryptoSymCipherParams_Destroy(params); + OH_CryptoSymCipher_Destroy(encCtx); + OH_CryptoSymCipher_Destroy(decCtx); + OH_CryptoSymKeyGenerator_Destroy(genCtx); + OH_CryptoSymKey_Destroy(keyCtx); + OH_Crypto_FreeDataBlob(&outUpdate); + OH_Crypto_FreeDataBlob(&decUpdate); + OH_Crypto_FreeDataBlob(&tagOutPut); + return ret; +} // [End ccm_encrypt_decrypt_aes_symkey] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_ecb_encryption_decryption.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_ecb_encryption_decryption.cpp old mode 100755 new mode 100644 index b2c3c0b82a..fcce356f72 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_ecb_encryption_decryption.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_ecb_encryption_decryption.cpp @@ -1,87 +1,87 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start ecb_encrypt_decrypt_aes_symkey] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" -#include -#include "file.h" - -OH_Crypto_ErrCode doTestAesEcb() -{ - OH_CryptoSymKeyGenerator *genCtx = nullptr; - OH_CryptoSymCipher *encCtx = nullptr; - OH_CryptoSymCipher *decCtx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - OH_CryptoSymCipherParams *params = nullptr; - char *plainText = const_cast("this is test"); - Crypto_DataBlob input = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; - Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; - - // 随机生成对称密钥 - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES128", &genCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - // 创建参数 - ret = OH_CryptoSymCipherParams_Create(¶ms); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 加密操作 - ret = OH_CryptoSymCipher_Create("AES128|ECB|PKCS7", &encCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(encCtx, &input, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 解密操作 - ret = OH_CryptoSymCipher_Create("AES128|ECB|PKCS7", &decCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - -end: - OH_CryptoSymCipherParams_Destroy(params); - OH_CryptoSymCipher_Destroy(encCtx); - OH_CryptoSymCipher_Destroy(decCtx); - OH_CryptoSymKeyGenerator_Destroy(genCtx); - OH_CryptoSymKey_Destroy(keyCtx); - OH_Crypto_FreeDataBlob(&outUpdate); - OH_Crypto_FreeDataBlob(&decUpdate); - return ret; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start ecb_encrypt_decrypt_aes_symkey] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" +#include +#include "file.h" + +OH_Crypto_ErrCode doTestAesEcb() +{ + OH_CryptoSymKeyGenerator *genCtx = nullptr; + OH_CryptoSymCipher *encCtx = nullptr; + OH_CryptoSymCipher *decCtx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + OH_CryptoSymCipherParams *params = nullptr; + char *plainText = const_cast("this is test"); + Crypto_DataBlob input = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; + Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; + + // 随机生成对称密钥 + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES128", &genCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + // 创建参数 + ret = OH_CryptoSymCipherParams_Create(¶ms); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 加密操作 + ret = OH_CryptoSymCipher_Create("AES128|ECB|PKCS7", &encCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(encCtx, &input, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 解密操作 + ret = OH_CryptoSymCipher_Create("AES128|ECB|PKCS7", &decCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + +end: + OH_CryptoSymCipherParams_Destroy(params); + OH_CryptoSymCipher_Destroy(encCtx); + OH_CryptoSymCipher_Destroy(decCtx); + OH_CryptoSymKeyGenerator_Destroy(genCtx); + OH_CryptoSymKey_Destroy(keyCtx); + OH_Crypto_FreeDataBlob(&outUpdate); + OH_Crypto_FreeDataBlob(&decUpdate); + return ret; +} // [End ecb_encrypt_decrypt_aes_symkey] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_gcm_encryption_decryption.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_gcm_encryption_decryption.cpp old mode 100755 new mode 100644 index a8c0b64d2e..118068d9c2 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_gcm_encryption_decryption.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_gcm_encryption_decryption.cpp @@ -1,118 +1,118 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start gcm_encrypt_decrypt_aes_symkey] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" -#include -#include "file.h" - -OH_Crypto_ErrCode doTestAesGcm() -{ - OH_CryptoSymKeyGenerator *genCtx = nullptr; - OH_CryptoSymCipher *encCtx = nullptr; - OH_CryptoSymCipher *decCtx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - OH_CryptoSymCipherParams *params = nullptr; - - Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; - - uint8_t aad[8] = {1, 2, 3, 4, 5, 6, 7, 8}; - uint8_t tag[16] = {0}; - uint8_t iv[12] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4}; // iv使用安全随机数生成 - Crypto_DataBlob ivData = {.data = iv, .len = sizeof(iv)}; - Crypto_DataBlob aadData = {.data = aad, .len = sizeof(aad)}; - Crypto_DataBlob tagData = {.data = tag, .len = sizeof(tag)}; - Crypto_DataBlob tagOutPut = {.data = nullptr, .len = 0}; - char *plainText = const_cast("this is test!"); - Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; - - // 生成对称密钥 - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES128", &genCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 设置参数 - ret = OH_CryptoSymCipherParams_Create(¶ms); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivData); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_AAD_DATABLOB, &aadData); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagData); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 加密 - ret = OH_CryptoSymCipher_Create("AES128|GCM|PKCS7", &encCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Update(encCtx, &msgBlob, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(encCtx, nullptr, &tagOutPut); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 解密 - ret = OH_CryptoSymCipher_Create("AES128|GCM|PKCS7", &decCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagOutPut); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - -end: - OH_CryptoSymCipherParams_Destroy(params); - OH_CryptoSymCipher_Destroy(encCtx); - OH_CryptoSymCipher_Destroy(decCtx); - OH_CryptoSymKeyGenerator_Destroy(genCtx); - OH_CryptoSymKey_Destroy(keyCtx); - OH_Crypto_FreeDataBlob(&outUpdate); - OH_Crypto_FreeDataBlob(&decUpdate); - OH_Crypto_FreeDataBlob(&tagOutPut); - return ret; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start gcm_encrypt_decrypt_aes_symkey] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" +#include +#include "file.h" + +OH_Crypto_ErrCode doTestAesGcm() +{ + OH_CryptoSymKeyGenerator *genCtx = nullptr; + OH_CryptoSymCipher *encCtx = nullptr; + OH_CryptoSymCipher *decCtx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + OH_CryptoSymCipherParams *params = nullptr; + + Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; + + uint8_t aad[8] = {1, 2, 3, 4, 5, 6, 7, 8}; + uint8_t tag[16] = {0}; + uint8_t iv[12] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4}; // iv使用安全随机数生成 + Crypto_DataBlob ivData = {.data = iv, .len = sizeof(iv)}; + Crypto_DataBlob aadData = {.data = aad, .len = sizeof(aad)}; + Crypto_DataBlob tagData = {.data = tag, .len = sizeof(tag)}; + Crypto_DataBlob tagOutPut = {.data = nullptr, .len = 0}; + char *plainText = const_cast("this is test!"); + Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; + + // 生成对称密钥 + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES128", &genCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 设置参数 + ret = OH_CryptoSymCipherParams_Create(¶ms); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivData); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_AAD_DATABLOB, &aadData); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagData); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 加密 + ret = OH_CryptoSymCipher_Create("AES128|GCM|PKCS7", &encCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Update(encCtx, &msgBlob, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(encCtx, nullptr, &tagOutPut); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 解密 + ret = OH_CryptoSymCipher_Create("AES128|GCM|PKCS7", &decCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagOutPut); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + +end: + OH_CryptoSymCipherParams_Destroy(params); + OH_CryptoSymCipher_Destroy(encCtx); + OH_CryptoSymCipher_Destroy(decCtx); + OH_CryptoSymKeyGenerator_Destroy(genCtx); + OH_CryptoSymKey_Destroy(keyCtx); + OH_Crypto_FreeDataBlob(&outUpdate); + OH_Crypto_FreeDataBlob(&decUpdate); + OH_Crypto_FreeDataBlob(&tagOutPut); + return ret; +} // [End gcm_encrypt_decrypt_aes_symkey] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_gcm_segment_encryption_decryption.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_gcm_segment_encryption_decryption.cpp old mode 100755 new mode 100644 index c226fee779..3b43fd23d9 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_gcm_segment_encryption_decryption.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/aes_gcm_segment_encryption_decryption.cpp @@ -1,146 +1,146 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start gcm_seg_encrypt_decrypt_aes_symkey] -#include -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" -#include "file.h" - -#define OH_CRYPTO_GCM_TAG_LEN 16 -#define OH_CRYPTO_MAX_TEST_DATA_LEN 128 -OH_Crypto_ErrCode doTestAesGcmSeg() -{ - OH_CryptoSymKeyGenerator *genCtx = nullptr; - OH_CryptoSymCipher *encCtx = nullptr; - OH_CryptoSymCipher *decCtx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - OH_CryptoSymCipherParams *params = nullptr; - - char *plainText = const_cast("aaaaa.....bbbbb.....ccccc.....ddddd.....eee"); - Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; - - uint8_t aad[8] = {1, 2, 3, 4, 5, 6, 7, 8}; - uint8_t tagArr[16] = {0}; - uint8_t iv[12] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4}; // iv使用安全随机数生成 - Crypto_DataBlob tag = {.data = nullptr, .len = 0}; - Crypto_DataBlob ivBlob = {.data = iv, .len = sizeof(iv)}; - Crypto_DataBlob aadBlob = {.data = aad, .len = sizeof(aad)}; - Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob tagInit = {.data = tagArr, .len = sizeof(tagArr)}; - int32_t cipherLen = 0; - int blockSize = 20; - int32_t randomLen = strlen(plainText); - int cnt = randomLen / blockSize; - int rem = randomLen % blockSize; - uint8_t cipherText[OH_CRYPTO_MAX_TEST_DATA_LEN] = {0}; - Crypto_DataBlob cipherBlob; - - // 生成密钥 - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES128", &genCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 设置参数 - ret = OH_CryptoSymCipherParams_Create(¶ms); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivBlob); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_AAD_DATABLOB, &aadBlob); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagInit); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 加密 - ret = OH_CryptoSymCipher_Create("AES128|GCM|PKCS7", &encCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - for (int i = 0; i < cnt; i++) { - msgBlob.len = blockSize; - ret = OH_CryptoSymCipher_Update(encCtx, &msgBlob, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - msgBlob.data += blockSize; - memcpy(&cipherText[cipherLen], outUpdate.data, outUpdate.len); - cipherLen += outUpdate.len; - } - if (rem > 0) { - msgBlob.len = rem; - ret = OH_CryptoSymCipher_Update(encCtx, (Crypto_DataBlob *)&msgBlob, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - memcpy(&cipherText[cipherLen], outUpdate.data, outUpdate.len); - cipherLen += outUpdate.len; - } - ret = OH_CryptoSymCipher_Final(encCtx, nullptr, &tag); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 解密 - cipherBlob = {.data = reinterpret_cast(cipherText), .len = (size_t)cipherLen}; - msgBlob.data -= strlen(plainText) - rem; - msgBlob.len = strlen(plainText); - ret = OH_CryptoSymCipher_Create("AES128|GCM|PKCS7", &decCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tag); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(decCtx, &cipherBlob, &decUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - -end: - OH_CryptoSymCipherParams_Destroy(params); - OH_CryptoSymCipher_Destroy(encCtx); - OH_CryptoSymCipher_Destroy(decCtx); - OH_CryptoSymKeyGenerator_Destroy(genCtx); - OH_CryptoSymKey_Destroy(keyCtx); - OH_Crypto_FreeDataBlob(&outUpdate); - OH_Crypto_FreeDataBlob(&tag); - OH_Crypto_FreeDataBlob(&decUpdate); - return ret; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start gcm_seg_encrypt_decrypt_aes_symkey] +#include +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" +#include "file.h" + +#define OH_CRYPTO_GCM_TAG_LEN 16 +#define OH_CRYPTO_MAX_TEST_DATA_LEN 128 +OH_Crypto_ErrCode doTestAesGcmSeg() +{ + OH_CryptoSymKeyGenerator *genCtx = nullptr; + OH_CryptoSymCipher *encCtx = nullptr; + OH_CryptoSymCipher *decCtx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + OH_CryptoSymCipherParams *params = nullptr; + + char *plainText = const_cast("aaaaa.....bbbbb.....ccccc.....ddddd.....eee"); + Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; + + uint8_t aad[8] = {1, 2, 3, 4, 5, 6, 7, 8}; + uint8_t tagArr[16] = {0}; + uint8_t iv[12] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4}; // iv使用安全随机数生成 + Crypto_DataBlob tag = {.data = nullptr, .len = 0}; + Crypto_DataBlob ivBlob = {.data = iv, .len = sizeof(iv)}; + Crypto_DataBlob aadBlob = {.data = aad, .len = sizeof(aad)}; + Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob tagInit = {.data = tagArr, .len = sizeof(tagArr)}; + int32_t cipherLen = 0; + int blockSize = 20; + int32_t randomLen = strlen(plainText); + int cnt = randomLen / blockSize; + int rem = randomLen % blockSize; + uint8_t cipherText[OH_CRYPTO_MAX_TEST_DATA_LEN] = {0}; + Crypto_DataBlob cipherBlob; + + // 生成密钥 + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES128", &genCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 设置参数 + ret = OH_CryptoSymCipherParams_Create(¶ms); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivBlob); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_AAD_DATABLOB, &aadBlob); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagInit); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 加密 + ret = OH_CryptoSymCipher_Create("AES128|GCM|PKCS7", &encCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + for (int i = 0; i < cnt; i++) { + msgBlob.len = blockSize; + ret = OH_CryptoSymCipher_Update(encCtx, &msgBlob, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + msgBlob.data += blockSize; + memcpy(&cipherText[cipherLen], outUpdate.data, outUpdate.len); + cipherLen += outUpdate.len; + } + if (rem > 0) { + msgBlob.len = rem; + ret = OH_CryptoSymCipher_Update(encCtx, (Crypto_DataBlob *)&msgBlob, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + memcpy(&cipherText[cipherLen], outUpdate.data, outUpdate.len); + cipherLen += outUpdate.len; + } + ret = OH_CryptoSymCipher_Final(encCtx, nullptr, &tag); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 解密 + cipherBlob = {.data = reinterpret_cast(cipherText), .len = (size_t)cipherLen}; + msgBlob.data -= strlen(plainText) - rem; + msgBlob.len = strlen(plainText); + ret = OH_CryptoSymCipher_Create("AES128|GCM|PKCS7", &decCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tag); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(decCtx, &cipherBlob, &decUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + +end: + OH_CryptoSymCipherParams_Destroy(params); + OH_CryptoSymCipher_Destroy(encCtx); + OH_CryptoSymCipher_Destroy(decCtx); + OH_CryptoSymKeyGenerator_Destroy(genCtx); + OH_CryptoSymKey_Destroy(keyCtx); + OH_Crypto_FreeDataBlob(&outUpdate); + OH_Crypto_FreeDataBlob(&tag); + OH_Crypto_FreeDataBlob(&decUpdate); + return ret; +} // [End gcm_seg_encrypt_decrypt_aes_symkey] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/file.h b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/file.h old mode 100755 new mode 100644 index e2bfb60be6..0b8939ca3d --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/file.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/cpp/types/project/file.h @@ -1,26 +1,26 @@ -#ifndef ENCRYPTIONDECRYPTIONGUIDANCEAES_FILE_H -#define ENCRYPTIONDECRYPTIONGUIDANCEAES_FILE_H -/* - * 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 "CryptoArchitectureKit/crypto_common.h" - -OH_Crypto_ErrCode doTestAesGcm(); -OH_Crypto_ErrCode doTestAesCcm(); -OH_Crypto_ErrCode doTestAesCbc(); -OH_Crypto_ErrCode doTestAesEcb(); -OH_Crypto_ErrCode doTestAesGcmSeg(); - +#ifndef ENCRYPTIONDECRYPTIONGUIDANCEAES_FILE_H +#define ENCRYPTIONDECRYPTIONGUIDANCEAES_FILE_H +/* + * 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 "CryptoArchitectureKit/crypto_common.h" + +OH_Crypto_ErrCode doTestAesGcm(); +OH_Crypto_ErrCode doTestAesCcm(); +OH_Crypto_ErrCode doTestAesCbc(); +OH_Crypto_ErrCode doTestAesEcb(); +OH_Crypto_ErrCode doTestAesGcmSeg(); + #endif //ENCRYPTIONDECRYPTIONGUIDANCEAES_FILE_H \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index a36ca588fe..965554bb3a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index d096ce63db..97b84c02d1 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/ets/pages/Index.ets @@ -1,62 +1,62 @@ -/* - * 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 { - @State message: string = 'EncryptionDecryptionGuidanceAes'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(24) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_gcm')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testAesGcm(); - this.message = 'AES_GCMSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_aes_ccm')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testAesCcm(); - this.message = 'AES_CCMSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_aes_cbc')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testAesCbc(); - this.message = 'AES_CBCSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_aes_ecb')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testAesEcb(); - this.message = 'AES_ECBSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_aes_gcm_segment')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testAesEcb(); - this.message = 'AES_GCM_SegmentSuccess Result:' + ret.toString(); - }) - } - .width('100%') - .height('100%') - } -} +/* + * 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 { + @State message: string = 'EncryptionDecryptionGuidanceAes'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(24) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_gcm')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testAesGcm(); + this.message = 'AES_GCMSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_aes_ccm')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testAesCcm(); + this.message = 'AES_CCMSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_aes_cbc')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testAesCbc(); + this.message = 'AES_CBCSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_aes_ecb')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testAesEcb(); + this.message = 'AES_ECBSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_aes_gcm_segment')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testAesEcb(); + this.message = 'AES_GCM_SegmentSuccess Result:' + ret.toString(); + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceAes.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceAes.test.ets old mode 100755 new mode 100644 index 698d631a89..5d9bff15da --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceAes.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceAes.test.ets @@ -1,114 +1,114 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function encryptionDecryptionGuidanceAesTest() { - describe('EncryptionDecryptionGuidanceAesTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用AES对称密钥(GCM模式)加解密(C/C++) - */ - it('testEncryptionDecryptionGuidanceAes001', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAes001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call AES_GCM')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_GCMSuccess Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceAes001 end'); - }) - - /** - * 点击按钮,使用AES对称密钥(CCM模式)加解密(C/C++) - */ - it('testEncryptionDecryptionGuidanceAes002', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAes002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call AES_CCM')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_CCMSuccess Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceAes002 end'); - }) - - /** - * 点击按钮,使用AES对称密钥(CBC模式)加解密(C/C++) - */ - it('testEncryptionDecryptionGuidanceAes003', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAes003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call AES_CBC')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_CBCSuccess Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceAes003 end'); - }) - - /** - * 点击按钮,使用AES对称密钥(ECB模式)加解密(C/C++) - */ - it('testEncryptionDecryptionGuidanceAes004', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAes004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call AES_ECB')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_ECBSuccess Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceAes004 end'); - }) - - /** - * 点击按钮,使用AES对称密钥(GCM模式)分段加解密(C/C++) - */ - it('testEncryptionDecryptionGuidanceAes005', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAes005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call AES_GCM_Segment')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_GCM_SegmentSuccess Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceAes005 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function encryptionDecryptionGuidanceAesTest() { + describe('EncryptionDecryptionGuidanceAesTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用AES对称密钥(GCM模式)加解密(C/C++) + */ + it('testEncryptionDecryptionGuidanceAes001', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAes001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call AES_GCM')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_GCMSuccess Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceAes001 end'); + }) + + /** + * 点击按钮,使用AES对称密钥(CCM模式)加解密(C/C++) + */ + it('testEncryptionDecryptionGuidanceAes002', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAes002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call AES_CCM')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_CCMSuccess Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceAes002 end'); + }) + + /** + * 点击按钮,使用AES对称密钥(CBC模式)加解密(C/C++) + */ + it('testEncryptionDecryptionGuidanceAes003', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAes003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call AES_CBC')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_CBCSuccess Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceAes003 end'); + }) + + /** + * 点击按钮,使用AES对称密钥(ECB模式)加解密(C/C++) + */ + it('testEncryptionDecryptionGuidanceAes004', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAes004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call AES_ECB')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_ECBSuccess Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceAes004 end'); + }) + + /** + * 点击按钮,使用AES对称密钥(GCM模式)分段加解密(C/C++) + */ + it('testEncryptionDecryptionGuidanceAes005', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAes005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call AES_GCM_Segment')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_GCM_SegmentSuccess Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceAes005 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/ohosTest.md old mode 100755 new mode 100644 index 6149d9d589..8415a3609c --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/ohosTest.md @@ -1,12 +1,12 @@ -# 使用AES对称密钥加解密(C/C++)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用AES对称密钥(GCM模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(CCM模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(CBC模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(ECB模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 使用AES对称密钥加解密(C/C++)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用AES对称密钥(GCM模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(CCM模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(CBC模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(ECB模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用AES对称密钥(GCM模式)分段加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/screenshots/EncryptionDecryptionGuidanceAes1.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/screenshots/EncryptionDecryptionGuidanceAes1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/screenshots/EncryptionDecryptionGuidanceAes2.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAes/screenshots/EncryptionDecryptionGuidanceAes2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/app.json5 old mode 100755 new mode 100644 index c88fd09984..f6ae8fe605 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/app.json5 @@ -1,25 +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.encryptiondecryptionguidanceaesarkts", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.encryptiondecryptionguidanceaesarkts", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 90315fb34a..96fc25d01b --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "EncryptionDecryptionGuidanceAesArkTs" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "EncryptionDecryptionGuidanceAesArkTs" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/README.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/README.md old mode 100755 new mode 100644 index 636ba18456..92ed5818cc --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/README.md @@ -1,86 +1,86 @@ -# 使用AES对称密钥加解密(ArkTS) - -### 介绍 - -本示例主要展示了使用AES对称密钥不同模式加解密(ArkTS)的同步异步方法和C/C++场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用AES对称密钥(GCM模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-gcm.md) -- [使用AES对称密钥(CCM模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-ccm.md) -- [使用AES对称密钥(CBC模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-cbc.md) -- [使用AES对称密钥(ECB模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-ecb.md) -- [使用AES对称密钥(GCM模式)分段加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-gcm-by-segment.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例EncryptionDecryptionGuidanceAesArkTs.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── aes_cbc_encryption_decryption - │ │ | ├── aes_cbc_encryption_decryption_asynchronous.ets - │ │ | ├── aes_cbc_encryption_decryption_synchronous.ets - │ │ ├── aes_ccm_encryption_decryption - │ │ | ├── aes_ccm_encryption_decryption_asynchronous.ets - │ │ | ├── aes_ccm_encryption_decryption_synchronous.ets - │ │ ├── aes_ecb_encryption_decryption - │ │ | ├── aes_ecb_encryption_decryption_asynchronous.ets - │ │ | ├── aes_ecb_encryption_decryption_synchronous.ets - │ │ ├── aes_gcm_encryption_decryption - │ │ | ├── aes_gcm_encryption_decryption_asynchronous.ets - │ │ | ├── aes_gcm_encryption_decryption_synchronous.ets - │ │ ├── aes_gcm_seg_encryption_decryption - │ │ | ├── aes_gcm_seg_encryption_decryption_asynchronous.ets - │ │ | ├── aes_gcm_seg_encryption_decryption_synchronous.ets - │ │ ├── Index.ets // 使用AES对称密钥加解密(ArkTS)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── EncryptionDecryptionGuidanceAesArkTs.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 使用AES对称密钥加解密(ArkTS) + +### 介绍 + +本示例主要展示了使用AES对称密钥不同模式加解密(ArkTS)的同步异步方法和C/C++场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用AES对称密钥(GCM模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-gcm.md) +- [使用AES对称密钥(CCM模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-ccm.md) +- [使用AES对称密钥(CBC模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-cbc.md) +- [使用AES对称密钥(ECB模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-ecb.md) +- [使用AES对称密钥(GCM模式)分段加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-aes-sym-encrypt-decrypt-gcm-by-segment.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例EncryptionDecryptionGuidanceAesArkTs.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── aes_cbc_encryption_decryption + │ │ | ├── aes_cbc_encryption_decryption_asynchronous.ets + │ │ | ├── aes_cbc_encryption_decryption_synchronous.ets + │ │ ├── aes_ccm_encryption_decryption + │ │ | ├── aes_ccm_encryption_decryption_asynchronous.ets + │ │ | ├── aes_ccm_encryption_decryption_synchronous.ets + │ │ ├── aes_ecb_encryption_decryption + │ │ | ├── aes_ecb_encryption_decryption_asynchronous.ets + │ │ | ├── aes_ecb_encryption_decryption_synchronous.ets + │ │ ├── aes_gcm_encryption_decryption + │ │ | ├── aes_gcm_encryption_decryption_asynchronous.ets + │ │ | ├── aes_gcm_encryption_decryption_synchronous.ets + │ │ ├── aes_gcm_seg_encryption_decryption + │ │ | ├── aes_gcm_seg_encryption_decryption_asynchronous.ets + │ │ | ├── aes_gcm_seg_encryption_decryption_synchronous.ets + │ │ ├── Index.ets // 使用AES对称密钥加解密(ArkTS)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── EncryptionDecryptionGuidanceAesArkTs.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs > .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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_cbc_encryption_decryption/aes_cbc_encryption_decryption_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_cbc_encryption_decryption/aes_cbc_encryption_decryption_asynchronous.ets old mode 100755 new mode 100644 index 7529796290..7db8cf2008 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_cbc_encryption_decryption/aes_cbc_encryption_decryption_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_cbc_encryption_decryption/aes_cbc_encryption_decryption_asynchronous.ets @@ -1,103 +1,103 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start cbc_encrypt_decrypt_aes_symkey_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genIvParamsSpec() { - let ivBlob = generateRandom(16); - let ivParamsSpec: cryptoFramework.IvParamsSpec = { - algName: 'IvParamsSpec', - iv: ivBlob - }; - return ivParamsSpec; -} - -let iv = genIvParamsSpec(); - -// 加密消息 -async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('AES128|CBC|PKCS7'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, iv); - let cipherData = await cipher.doFinal(plainText); - return cipherData; -} - -// 解密消息 -async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('AES128|CBC|PKCS7'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, iv); - let decryptData = await decoder.doFinal(cipherText); - return decryptData; -} - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); - let symKey = await aesGenerator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function aesCBC() { - try { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = await genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessagePromise(symKey, plainText); - let decryptText = await decryptMessagePromise(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } - } catch (error) { - console.error(`AES CBC “${error}“, error code: ${error.code}`); - } -} -// [End cbc_encrypt_decrypt_aes_symkey_async] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_cbc_asynchronous')) - .width('70%') - .onClick(() => { - try { - aesCBC(); - this.message = 'AES_CBCAsynchronousSuccess'; - } catch { - this.message = 'AES_CBCAsynchronousFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start cbc_encrypt_decrypt_aes_symkey_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function generateRandom(len: number) { + let rand = cryptoFramework.createRandom(); + let generateRandSync = rand.generateRandomSync(len); + return generateRandSync; +} + +function genIvParamsSpec() { + let ivBlob = generateRandom(16); + let ivParamsSpec: cryptoFramework.IvParamsSpec = { + algName: 'IvParamsSpec', + iv: ivBlob + }; + return ivParamsSpec; +} + +let iv = genIvParamsSpec(); + +// 加密消息 +async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('AES128|CBC|PKCS7'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, iv); + let cipherData = await cipher.doFinal(plainText); + return cipherData; +} + +// 解密消息 +async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('AES128|CBC|PKCS7'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, iv); + let decryptData = await decoder.doFinal(cipherText); + return decryptData; +} + +async function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); + let symKey = await aesGenerator.convertKey(symKeyBlob); + console.info('convertKey success'); + return symKey; +} + +async function aesCBC() { + try { + let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); + let symKey = await genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await encryptMessagePromise(symKey, plainText); + let decryptText = await decryptMessagePromise(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } + } catch (error) { + console.error(`AES CBC “${error}“, error code: ${error.code}`); + } +} +// [End cbc_encrypt_decrypt_aes_symkey_async] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_cbc_asynchronous')) + .width('70%') + .onClick(() => { + try { + aesCBC(); + this.message = 'AES_CBCAsynchronousSuccess'; + } catch { + this.message = 'AES_CBCAsynchronousFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_cbc_encryption_decryption/aes_cbc_encryption_decryption_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_cbc_encryption_decryption/aes_cbc_encryption_decryption_synchronous.ets old mode 100755 new mode 100644 index ea3fa63be5..9417d3be74 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_cbc_encryption_decryption/aes_cbc_encryption_decryption_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_cbc_encryption_decryption/aes_cbc_encryption_decryption_synchronous.ets @@ -1,103 +1,103 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start cbc_encrypt_decrypt_aes_symkey_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genIvParamsSpec() { - let ivBlob = generateRandom(16); - let ivParamsSpec: cryptoFramework.IvParamsSpec = { - algName: 'IvParamsSpec', - iv: ivBlob - }; - return ivParamsSpec; -} - -let iv = genIvParamsSpec(); - -// 加密消息 -function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('AES128|CBC|PKCS7'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, iv); - let cipherData = cipher.doFinalSync(plainText); - return cipherData; -} - -// 解密消息 -function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('AES128|CBC|PKCS7'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, iv); - let decryptData = decoder.doFinalSync(cipherText); - return decryptData; -} - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); - let symKey = aesGenerator.convertKeySync(symKeyBlob); - console.info('convertKeySync success'); - return symKey; -} - -function main() { - try { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessage(symKey, plainText); - let decryptText = decryptMessage(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } - } catch (error) { - console.error(`AES CBC “${error}“, error code: ${error.code}`); - } -} -// [End cbc_encrypt_decrypt_aes_symkey_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_cbc_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'AES_CBCSynchronousSuccess'; - } catch { - this.message = 'AES_CBCSynchronousFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start cbc_encrypt_decrypt_aes_symkey_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function generateRandom(len: number) { + let rand = cryptoFramework.createRandom(); + let generateRandSync = rand.generateRandomSync(len); + return generateRandSync; +} + +function genIvParamsSpec() { + let ivBlob = generateRandom(16); + let ivParamsSpec: cryptoFramework.IvParamsSpec = { + algName: 'IvParamsSpec', + iv: ivBlob + }; + return ivParamsSpec; +} + +let iv = genIvParamsSpec(); + +// 加密消息 +function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('AES128|CBC|PKCS7'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, iv); + let cipherData = cipher.doFinalSync(plainText); + return cipherData; +} + +// 解密消息 +function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('AES128|CBC|PKCS7'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, iv); + let decryptData = decoder.doFinalSync(cipherText); + return decryptData; +} + +function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); + let symKey = aesGenerator.convertKeySync(symKeyBlob); + console.info('convertKeySync success'); + return symKey; +} + +function main() { + try { + let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); + let symKey = genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = encryptMessage(symKey, plainText); + let decryptText = decryptMessage(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } + } catch (error) { + console.error(`AES CBC “${error}“, error code: ${error.code}`); + } +} +// [End cbc_encrypt_decrypt_aes_symkey_sync] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_cbc_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'AES_CBCSynchronousSuccess'; + } catch { + this.message = 'AES_CBCSynchronousFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ccm_encryption_decryption/aes_ccm_encryption_decryption_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ccm_encryption_decryption/aes_ccm_encryption_decryption_asynchronous.ets old mode 100755 new mode 100644 index 91e7d58f41..8bae8f3c81 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ccm_encryption_decryption/aes_ccm_encryption_decryption_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ccm_encryption_decryption/aes_ccm_encryption_decryption_asynchronous.ets @@ -1,105 +1,105 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start ccm_encrypt_decrypt_aes_symkey_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function genCcmParamsSpec() { - let rand: cryptoFramework.Random = cryptoFramework.createRandom(); - let ivBlob: cryptoFramework.DataBlob = rand.generateRandomSync(7); - let aadBlob: cryptoFramework.DataBlob = rand.generateRandomSync(8); - let arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 12 bytes - let dataTag = new Uint8Array(arr); - let tagBlob: cryptoFramework.DataBlob = { - data: dataTag - }; - // CCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 - let ccmParamsSpec: cryptoFramework.CcmParamsSpec = { - iv: ivBlob, - aad: aadBlob, - authTag: tagBlob, - algName: 'CcmParamsSpec' - }; - return ccmParamsSpec; -} - -let ccmParams = genCcmParamsSpec(); - -// 加密消息 -async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('AES128|CCM'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, ccmParams); - let encryptUpdate = await cipher.update(plainText); - // ccm模式加密doFinal时传入空,获得tag数据,并更新至ccmParams对象中。 - ccmParams.authTag = await cipher.doFinal(null); - return encryptUpdate; -} - -// 解密消息 -async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('AES128|CCM'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, ccmParams); - let decryptUpdate = await decoder.doFinal(cipherText); - return decryptUpdate; -} - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); - let symKey = await aesGenerator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function main() { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = await genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessagePromise(symKey, plainText); - let decryptText = await decryptMessagePromise(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End ccm_encrypt_decrypt_aes_symkey_async] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_ccm_asynchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'AES_CCMAsynchronousSuccess'; - } catch { - this.message = 'AES_CCMAsynchronousFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start ccm_encrypt_decrypt_aes_symkey_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function genCcmParamsSpec() { + let rand: cryptoFramework.Random = cryptoFramework.createRandom(); + let ivBlob: cryptoFramework.DataBlob = rand.generateRandomSync(7); + let aadBlob: cryptoFramework.DataBlob = rand.generateRandomSync(8); + let arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 12 bytes + let dataTag = new Uint8Array(arr); + let tagBlob: cryptoFramework.DataBlob = { + data: dataTag + }; + // CCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 + let ccmParamsSpec: cryptoFramework.CcmParamsSpec = { + iv: ivBlob, + aad: aadBlob, + authTag: tagBlob, + algName: 'CcmParamsSpec' + }; + return ccmParamsSpec; +} + +let ccmParams = genCcmParamsSpec(); + +// 加密消息 +async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('AES128|CCM'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, ccmParams); + let encryptUpdate = await cipher.update(plainText); + // ccm模式加密doFinal时传入空,获得tag数据,并更新至ccmParams对象中。 + ccmParams.authTag = await cipher.doFinal(null); + return encryptUpdate; +} + +// 解密消息 +async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('AES128|CCM'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, ccmParams); + let decryptUpdate = await decoder.doFinal(cipherText); + return decryptUpdate; +} + +async function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); + let symKey = await aesGenerator.convertKey(symKeyBlob); + console.info('convertKey success'); + return symKey; +} + +async function main() { + let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); + let symKey = await genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await encryptMessagePromise(symKey, plainText); + let decryptText = await decryptMessagePromise(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} +// [End ccm_encrypt_decrypt_aes_symkey_async] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_ccm_asynchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'AES_CCMAsynchronousSuccess'; + } catch { + this.message = 'AES_CCMAsynchronousFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ccm_encryption_decryption/aes_ccm_encryption_decryption_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ccm_encryption_decryption/aes_ccm_encryption_decryption_synchronous.ets old mode 100755 new mode 100644 index febf23ea27..262ab0a434 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ccm_encryption_decryption/aes_ccm_encryption_decryption_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ccm_encryption_decryption/aes_ccm_encryption_decryption_synchronous.ets @@ -1,105 +1,105 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start ccm_encrypt_decrypt_aes_symkey_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function genCcmParamsSpec() { - let rand: cryptoFramework.Random = cryptoFramework.createRandom(); - let ivBlob: cryptoFramework.DataBlob = rand.generateRandomSync(7); - let aadBlob: cryptoFramework.DataBlob = rand.generateRandomSync(8); - let arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 12 bytes - let dataTag = new Uint8Array(arr); - let tagBlob: cryptoFramework.DataBlob = { - data: dataTag - }; - // CCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 - let ccmParamsSpec: cryptoFramework.CcmParamsSpec = { - iv: ivBlob, - aad: aadBlob, - authTag: tagBlob, - algName: 'CcmParamsSpec' - }; - return ccmParamsSpec; -} - -let ccmParams = genCcmParamsSpec(); - -// 加密消息 -function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('AES128|CCM'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, ccmParams); - let encryptUpdate = cipher.updateSync(plainText); - // ccm模式加密doFinal时传入空,获得tag数据,并更新至ccmParams对象中。 - ccmParams.authTag = cipher.doFinalSync(null); - return encryptUpdate; -} - -// 解密消息 -function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('AES128|CCM'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, ccmParams); - let decryptUpdate = decoder.doFinalSync(cipherText); - return decryptUpdate; -} - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); - let symKey = aesGenerator.convertKeySync(symKeyBlob); - console.info('convertKeySync success'); - return symKey; -} - -function main() { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessage(symKey, plainText); - let decryptText = decryptMessage(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End ccm_encrypt_decrypt_aes_symkey_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_ccm_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'AES_CCMSynchronousSuccess'; - } catch { - this.message = 'AES_CCMSynchronousFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start ccm_encrypt_decrypt_aes_symkey_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function genCcmParamsSpec() { + let rand: cryptoFramework.Random = cryptoFramework.createRandom(); + let ivBlob: cryptoFramework.DataBlob = rand.generateRandomSync(7); + let aadBlob: cryptoFramework.DataBlob = rand.generateRandomSync(8); + let arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 12 bytes + let dataTag = new Uint8Array(arr); + let tagBlob: cryptoFramework.DataBlob = { + data: dataTag + }; + // CCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 + let ccmParamsSpec: cryptoFramework.CcmParamsSpec = { + iv: ivBlob, + aad: aadBlob, + authTag: tagBlob, + algName: 'CcmParamsSpec' + }; + return ccmParamsSpec; +} + +let ccmParams = genCcmParamsSpec(); + +// 加密消息 +function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('AES128|CCM'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, ccmParams); + let encryptUpdate = cipher.updateSync(plainText); + // ccm模式加密doFinal时传入空,获得tag数据,并更新至ccmParams对象中。 + ccmParams.authTag = cipher.doFinalSync(null); + return encryptUpdate; +} + +// 解密消息 +function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('AES128|CCM'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, ccmParams); + let decryptUpdate = decoder.doFinalSync(cipherText); + return decryptUpdate; +} + +function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); + let symKey = aesGenerator.convertKeySync(symKeyBlob); + console.info('convertKeySync success'); + return symKey; +} + +function main() { + let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); + let symKey = genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = encryptMessage(symKey, plainText); + let decryptText = decryptMessage(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} +// [End ccm_encrypt_decrypt_aes_symkey_sync] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_ccm_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'AES_CCMSynchronousSuccess'; + } catch { + this.message = 'AES_CCMSynchronousFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ecb_encryption_decryption/aes_ecb_encryption_decryption_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ecb_encryption_decryption/aes_ecb_encryption_decryption_asynchronous.ets old mode 100755 new mode 100644 index 5557cbed19..457bd5d0aa --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ecb_encryption_decryption/aes_ecb_encryption_decryption_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ecb_encryption_decryption/aes_ecb_encryption_decryption_asynchronous.ets @@ -1,86 +1,86 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start ecb_encrypt_decrypt_aes_symkey_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 加密消息 -async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('AES128|ECB|PKCS7'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); - let cipherData = await cipher.doFinal(plainText); - return cipherData; -} - -// 解密消息 -async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('AES128|ECB|PKCS7'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); - let decryptData = await decoder.doFinal(cipherText); - return decryptData; -} - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); - let symKey = await aesGenerator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function aesECB() { - try { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = await genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessagePromise(symKey, plainText); - let decryptText = await decryptMessagePromise(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } - } catch (error) { - console.error(`AES ECB “${error}“, error code: ${error.code}`); - } -} -// [End ecb_encrypt_decrypt_aes_symkey_async] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_ecb_asynchronous')) - .width('70%') - .onClick(() => { - try { - aesECB(); - this.message = 'AES_ECBAsynchronousSuccess'; - } catch { - this.message = 'AES_ECBAsynchronousFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start ecb_encrypt_decrypt_aes_symkey_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 加密消息 +async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('AES128|ECB|PKCS7'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); + let cipherData = await cipher.doFinal(plainText); + return cipherData; +} + +// 解密消息 +async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('AES128|ECB|PKCS7'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); + let decryptData = await decoder.doFinal(cipherText); + return decryptData; +} + +async function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); + let symKey = await aesGenerator.convertKey(symKeyBlob); + console.info('convertKey success'); + return symKey; +} + +async function aesECB() { + try { + let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); + let symKey = await genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await encryptMessagePromise(symKey, plainText); + let decryptText = await decryptMessagePromise(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } + } catch (error) { + console.error(`AES ECB “${error}“, error code: ${error.code}`); + } +} +// [End ecb_encrypt_decrypt_aes_symkey_async] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_ecb_asynchronous')) + .width('70%') + .onClick(() => { + try { + aesECB(); + this.message = 'AES_ECBAsynchronousSuccess'; + } catch { + this.message = 'AES_ECBAsynchronousFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ecb_encryption_decryption/aes_ecb_encryption_decryption_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ecb_encryption_decryption/aes_ecb_encryption_decryption_synchronous.ets old mode 100755 new mode 100644 index d09feab12b..920e400cdd --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ecb_encryption_decryption/aes_ecb_encryption_decryption_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_ecb_encryption_decryption/aes_ecb_encryption_decryption_synchronous.ets @@ -1,86 +1,86 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start ecb_encrypt_decrypt_aes_symkey_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 加密消息 -function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('AES128|ECB|PKCS7'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); - let cipherData = cipher.doFinalSync(plainText); - return cipherData; -} - -// 解密消息 -function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('AES128|ECB|PKCS7'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); - let decryptData = decoder.doFinalSync(cipherText); - return decryptData; -} - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); - let symKey = aesGenerator.convertKeySync(symKeyBlob); - console.info('convertKeySync success'); - return symKey; -} - -function main() { - try { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessage(symKey, plainText); - let decryptText = decryptMessage(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } - } catch (error) { - console.error(`AES ECB “${error}“, error code: ${error.code}`); - } -} -// [End ecb_encrypt_decrypt_aes_symkey_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_ecb_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'AES_ECBSynchronousSuccess'; - } catch { - this.message = 'AES_ECBSynchronousFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start ecb_encrypt_decrypt_aes_symkey_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 加密消息 +function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('AES128|ECB|PKCS7'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); + let cipherData = cipher.doFinalSync(plainText); + return cipherData; +} + +// 解密消息 +function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('AES128|ECB|PKCS7'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); + let decryptData = decoder.doFinalSync(cipherText); + return decryptData; +} + +function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); + let symKey = aesGenerator.convertKeySync(symKeyBlob); + console.info('convertKeySync success'); + return symKey; +} + +function main() { + try { + let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); + let symKey = genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = encryptMessage(symKey, plainText); + let decryptText = decryptMessage(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } + } catch (error) { + console.error(`AES ECB “${error}“, error code: ${error.code}`); + } +} +// [End ecb_encrypt_decrypt_aes_symkey_sync] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_ecb_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'AES_ECBSynchronousSuccess'; + } catch { + this.message = 'AES_ECBSynchronousFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_encryption_decryption/aes_gcm_encryption_decryption_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_encryption_decryption/aes_gcm_encryption_decryption_asynchronous.ets old mode 100755 new mode 100644 index aa470de3f2..321c95d615 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_encryption_decryption/aes_gcm_encryption_decryption_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_encryption_decryption/aes_gcm_encryption_decryption_asynchronous.ets @@ -1,117 +1,117 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start gcm_encrypt_decrypt_aes_symkey_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genGcmParamsSpec() { - let ivBlob = generateRandom(12); - let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes - let dataAad = new Uint8Array(arr); - let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; - arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes - let dataTag = new Uint8Array(arr); - let tagBlob: cryptoFramework.DataBlob = { - data: dataTag - }; - // GCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 - let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { - iv: ivBlob, - aad: aadBlob, - authTag: tagBlob, - algName: 'GcmParamsSpec' - }; - return gcmParamsSpec; -} - -let gcmParams = genGcmParamsSpec(); - -// 加密消息 -async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('AES128|GCM|PKCS7'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); - let encryptUpdate = await cipher.update(plainText); - // gcm模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 - gcmParams.authTag = await cipher.doFinal(null); - return encryptUpdate; -} - -// 解密消息 -async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('AES128|GCM|PKCS7'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); - let decryptUpdate = await decoder.update(cipherText); - // gcm模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 - let decryptData = await decoder.doFinal(null); - if (decryptData == null) { - console.info('GCM decrypt success, decryptData is null'); - } - return decryptUpdate; -} - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); - let symKey = await aesGenerator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function main() { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = await genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessagePromise(symKey, plainText); - let decryptText = await decryptMessagePromise(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End gcm_encrypt_decrypt_aes_symkey_async] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_gcm_asynchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'AES_GCMAsynchronousSuccess'; - } catch { - this.message = 'AES_GCMAsynchronousFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start gcm_encrypt_decrypt_aes_symkey_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function generateRandom(len: number) { + let rand = cryptoFramework.createRandom(); + let generateRandSync = rand.generateRandomSync(len); + return generateRandSync; +} + +function genGcmParamsSpec() { + let ivBlob = generateRandom(12); + let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes + let dataAad = new Uint8Array(arr); + let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; + arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes + let dataTag = new Uint8Array(arr); + let tagBlob: cryptoFramework.DataBlob = { + data: dataTag + }; + // GCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 + let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { + iv: ivBlob, + aad: aadBlob, + authTag: tagBlob, + algName: 'GcmParamsSpec' + }; + return gcmParamsSpec; +} + +let gcmParams = genGcmParamsSpec(); + +// 加密消息 +async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('AES128|GCM|PKCS7'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); + let encryptUpdate = await cipher.update(plainText); + // gcm模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 + gcmParams.authTag = await cipher.doFinal(null); + return encryptUpdate; +} + +// 解密消息 +async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('AES128|GCM|PKCS7'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); + let decryptUpdate = await decoder.update(cipherText); + // gcm模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 + let decryptData = await decoder.doFinal(null); + if (decryptData == null) { + console.info('GCM decrypt success, decryptData is null'); + } + return decryptUpdate; +} + +async function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); + let symKey = await aesGenerator.convertKey(symKeyBlob); + console.info('convertKey success'); + return symKey; +} + +async function main() { + let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); + let symKey = await genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await encryptMessagePromise(symKey, plainText); + let decryptText = await decryptMessagePromise(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} +// [End gcm_encrypt_decrypt_aes_symkey_async] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_gcm_asynchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'AES_GCMAsynchronousSuccess'; + } catch { + this.message = 'AES_GCMAsynchronousFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_encryption_decryption/aes_gcm_encryption_decryption_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_encryption_decryption/aes_gcm_encryption_decryption_synchronous.ets old mode 100755 new mode 100644 index c2be00a40a..d8f1bf0e10 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_encryption_decryption/aes_gcm_encryption_decryption_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_encryption_decryption/aes_gcm_encryption_decryption_synchronous.ets @@ -1,117 +1,117 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start gcm_encrypt_decrypt_aes_symkey_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genGcmParamsSpec() { - let ivBlob = generateRandom(12); - let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes - let dataAad = new Uint8Array(arr); - let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; - arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes - let dataTag = new Uint8Array(arr); - let tagBlob: cryptoFramework.DataBlob = { - data: dataTag - }; - // GCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 - let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { - iv: ivBlob, - aad: aadBlob, - authTag: tagBlob, - algName: 'GcmParamsSpec' - }; - return gcmParamsSpec; -} - -let gcmParams = genGcmParamsSpec(); - -// 加密消息 -function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('AES128|GCM|PKCS7'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); - let encryptUpdate = cipher.updateSync(plainText); - // gcm模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 - gcmParams.authTag = cipher.doFinalSync(null); - return encryptUpdate; -} - -// 解密消息 -function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('AES128|GCM|PKCS7'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); - let decryptUpdate = decoder.updateSync(cipherText); - // gcm模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 - let decryptData = decoder.doFinalSync(null); - if (decryptData == null) { - console.info('GCM decrypt success, decryptData is null'); - } - return decryptUpdate; -} - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); - let symKey = aesGenerator.convertKeySync(symKeyBlob); - console.info('convertKeySync success'); - return symKey; -} - -function main() { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessage(symKey, plainText); - let decryptText = decryptMessage(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End gcm_encrypt_decrypt_aes_symkey_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_gcm_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'AES_GCMSynchronousSuccess'; - } catch { - this.message = 'AES_GCMSynchronousFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start gcm_encrypt_decrypt_aes_symkey_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function generateRandom(len: number) { + let rand = cryptoFramework.createRandom(); + let generateRandSync = rand.generateRandomSync(len); + return generateRandSync; +} + +function genGcmParamsSpec() { + let ivBlob = generateRandom(12); + let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes + let dataAad = new Uint8Array(arr); + let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; + arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes + let dataTag = new Uint8Array(arr); + let tagBlob: cryptoFramework.DataBlob = { + data: dataTag + }; + // GCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 + let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { + iv: ivBlob, + aad: aadBlob, + authTag: tagBlob, + algName: 'GcmParamsSpec' + }; + return gcmParamsSpec; +} + +let gcmParams = genGcmParamsSpec(); + +// 加密消息 +function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('AES128|GCM|PKCS7'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); + let encryptUpdate = cipher.updateSync(plainText); + // gcm模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 + gcmParams.authTag = cipher.doFinalSync(null); + return encryptUpdate; +} + +// 解密消息 +function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('AES128|GCM|PKCS7'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); + let decryptUpdate = decoder.updateSync(cipherText); + // gcm模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 + let decryptData = decoder.doFinalSync(null); + if (decryptData == null) { + console.info('GCM decrypt success, decryptData is null'); + } + return decryptUpdate; +} + +function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); + let symKey = aesGenerator.convertKeySync(symKeyBlob); + console.info('convertKeySync success'); + return symKey; +} + +function main() { + let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); + let symKey = genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = encryptMessage(symKey, plainText); + let decryptText = decryptMessage(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} +// [End gcm_encrypt_decrypt_aes_symkey_sync] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_gcm_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'AES_GCMSynchronousSuccess'; + } catch { + this.message = 'AES_GCMSynchronousFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_seg_encryption_decryption/aes_gcm_seg_encryption_decryption_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_seg_encryption_decryption/aes_gcm_seg_encryption_decryption_asynchronous.ets deleted file mode 100755 index e07bf37b10..0000000000 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_seg_encryption_decryption/aes_gcm_seg_encryption_decryption_asynchronous.ets +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start gcm_seg_encrypt_decrypt_aes_symkey_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genGcmParamsSpec() { - let ivBlob = generateRandom(12); - let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes - let dataAad = new Uint8Array(arr); - let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; - arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes - let dataTag = new Uint8Array(arr); - let tagBlob: cryptoFramework.DataBlob = { - data: dataTag - }; // The GCM authTag is obtained by doFinal() in encryption and passed in params of init() in decryption. - let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { - iv: ivBlob, - aad: aadBlob, - authTag: tagBlob, - algName: 'GcmParamsSpec' - }; - return gcmParamsSpec; -} - -let gcmParams = genGcmParamsSpec(); - -// 分段加密消息 -async function encryptMessageUpdateBySegment(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('AES128|GCM|PKCS7'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - let cipherText = new Uint8Array(); - for (let i = 0; i < plainText.data.length; i += updateLength) { - let updateMessage = plainText.data.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - let updateOutput = await cipher.update(updateMessageBlob); - // 把update的结果拼接起来,得到密文(有些情况下还需拼接doFinal的结果,这取决于分组模式 - // 和填充模式,本例中GCM模式的doFinal结果只包含authTag而不含密文,所以不需要拼接) - let mergeText = new Uint8Array(cipherText.length + updateOutput.data.length); - mergeText.set(cipherText); - mergeText.set(updateOutput.data, cipherText.length); - cipherText = mergeText; - } - gcmParams.authTag = await cipher.doFinal(null); - let cipherBlob: cryptoFramework.DataBlob = { data: cipherText }; - return cipherBlob; -} - -// 分段解密消息 -async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('AES128|GCM|PKCS7'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - let decryptText = new Uint8Array(); - for (let i = 0; i < cipherText.data.length; i += updateLength) { - let updateMessage = cipherText.data.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - let updateOutput = await decoder.update(updateMessageBlob); - // 把update的结果拼接起来,得到明文 - let mergeText = new Uint8Array(decryptText.length + updateOutput.data.length); - mergeText.set(decryptText); - mergeText.set(updateOutput.data, decryptText.length); - decryptText = mergeText; - } - let decryptData = await decoder.doFinal(null); - if (decryptData == null) { - console.info('GCM decrypt success, decryptData is null'); - } - let decryptBlob: cryptoFramework.DataBlob = { data: decryptText }; - return decryptBlob; -} - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); - let symKey = await aesGenerator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function aes() { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = await genSymKeyByData(keyData); - let message = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; // 假设信息总共43字节,根据utf-8解码后,也是43字节 - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessageUpdateBySegment(symKey, plainText); - let decryptText = await decryptMessagePromise(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End gcm_seg_encrypt_decrypt_aes_symkey_async] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_gcm_segmentation_asynchronous')) - .width('70%') - .onClick(() => { - try { - aes(); - this.message = 'AES_GCMAsynchronousSuccess'; - } catch { - this.message = 'AES_GCMAsynchronousFail'; - } - }) - } - .height('100%') - .width('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_seg_encryption_decryption/aes_gcm_seg_encryption_decryption_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_seg_encryption_decryption/aes_gcm_seg_encryption_decryption_synchronous.ets deleted file mode 100755 index c91ccccd90..0000000000 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/ets/pages/aes_gcm_seg_encryption_decryption/aes_gcm_seg_encryption_decryption_synchronous.ets +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start gcm_seg_encrypt_decrypt_aes_symkey_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genGcmParamsSpec() { - let ivBlob = generateRandom(12); - let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes - let dataAad = new Uint8Array(arr); - let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; - arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes - let dataTag = new Uint8Array(arr); - let tagBlob: cryptoFramework.DataBlob = { - data: dataTag - }; // The GCM authTag is obtained by doFinal() in encryption and passed in params of init() in decryption. - let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { - iv: ivBlob, - aad: aadBlob, - authTag: tagBlob, - algName: 'GcmParamsSpec' - }; - return gcmParamsSpec; -} - -let gcmParams = genGcmParamsSpec(); - -// 分段加密消息 -function encryptMessageUpdateBySegment(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('AES128|GCM|PKCS7'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - let cipherText = new Uint8Array(); - for (let i = 0; i < plainText.data.length; i += updateLength) { - let updateMessage = plainText.data.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - let updateOutput = cipher.updateSync(updateMessageBlob); - // 把update的结果拼接起来,得到密文(有些情况下还需拼接doFinal的结果,这取决于分组模式 - // 和填充模式,本例中GCM模式的doFinal结果只包含authTag而不含密文,所以不需要拼接) - let mergeText = new Uint8Array(cipherText.length + updateOutput.data.length); - mergeText.set(cipherText); - mergeText.set(updateOutput.data, cipherText.length); - cipherText = mergeText; - } - gcmParams.authTag = cipher.doFinalSync(null); - let cipherBlob: cryptoFramework.DataBlob = { data: cipherText }; - return cipherBlob; -} - -// 分段解密消息 -function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('AES128|GCM|PKCS7'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - let decryptText = new Uint8Array(); - for (let i = 0; i < cipherText.data.length; i += updateLength) { - let updateMessage = cipherText.data.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - let updateOutput = decoder.updateSync(updateMessageBlob); - // 把update的结果拼接起来,得到明文 - let mergeText = new Uint8Array(decryptText.length + updateOutput.data.length); - mergeText.set(decryptText); - mergeText.set(updateOutput.data, decryptText.length); - decryptText = mergeText; - } - let decryptData = decoder.doFinalSync(null); - if (decryptData == null) { - console.info('GCM decrypt success, decryptData is null'); - } - let decryptBlob: cryptoFramework.DataBlob = { data: decryptText }; - return decryptBlob; -} - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('AES128'); - let symKey = aesGenerator.convertKeySync(symKeyBlob); - console.info('convertKeySync success'); - return symKey; -} - -function main() { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = genSymKeyByData(keyData); - let message = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; // 假设信息总共43字节,根据utf-8解码后,也是43字节 - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessageUpdateBySegment(symKey, plainText); - let decryptText = decryptMessage(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End gcm_seg_encrypt_decrypt_aes_symkey_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance Aes ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_gcm_segmentation_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'AES_GCMSynchronousSuccess'; - } catch { - this.message = 'AES_GCMSynchronousFail'; - } - }) - } - .height('100%') - .width('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceAesArkTs.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceAesArkTs.test.ets old mode 100755 new mode 100644 index cf410b05a9..f5217bc5f5 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceAesArkTs.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceAesArkTs.test.ets @@ -1,224 +1,224 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function encryptionDecryptionGuidanceAesArkTsTest() { - describe('encryptionDecryptionGuidanceAesArkTsTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用AES对称密钥(GCM模式)加解密(ArkTS),异步方法 - */ - it('testEncryptionDecryptionGuidanceAesArkTs001', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('aes_gcm_encryption_decryption_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES_GCM Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_GCMAsynchronousSuccess')); - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用AES对称密钥(GCM模式)加解密(ArkTS),同步方法 - */ - it('testEncryptionDecryptionGuidanceAesArkTs002', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('aes_gcm_encryption_decryption_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES_GCM Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_GCMSynchronousSuccess')); - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用AES对称密钥(CCM模式)加解密(ArkTS),异步方法 - */ - it('testEncryptionDecryptionGuidanceAesArkTs003', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('aes_ccm_encryption_decryption_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES_CCM Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_CCMAsynchronousSuccess')); - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用AES对称密钥(CCM模式)加解密(ArkTS),同步方法 - */ - it('testEncryptionDecryptionGuidanceAesArkTs004', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('aes_ccm_encryption_decryption_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES_CCM Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_CCMSynchronousSuccess')); - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs004 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用AES对称密钥(CBC模式)加解密(ArkTS),异步方法 - */ - it('testEncryptionDecryptionGuidanceAesArkTs005', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('aes_cbc_encryption_decryption_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES_CBC Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_CBCAsynchronousSuccess')); - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs005 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用AES对称密钥(CBC模式)加解密(ArkTS),同步方法 - */ - it('testEncryptionDecryptionGuidanceAesArkTs006', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs006 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('aes_cbc_encryption_decryption_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES_CBC Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_CBCSynchronousSuccess')); - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs006 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用AES对称密钥(ECB模式)加解密(ArkTS),异步方法 - */ - it('testEncryptionDecryptionGuidanceAesArkTs007', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs007 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('aes_ecb_encryption_decryption_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES_ECB Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_ECBAsynchronousSuccess')); - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs007 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用AES对称密钥(ECB模式)加解密(ArkTS),同步方法 - */ - it('testEncryptionDecryptionGuidanceAesArkTs008', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs008 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('aes_ecb_encryption_decryption_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES_ECB Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_ECBSynchronousSuccess')); - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs008 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用AES对称密钥(GCM模式)分段加解密(ArkTS),异步方法 - */ - it('testEncryptionDecryptionGuidanceAesArkTs009', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs009 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('aes_gcm_seg_encryption_decryption_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES_GCM segmentation Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_GCMAsynchronousSuccess')); - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs009 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用AES对称密钥(GCM模式)分段加解密(ArkTS),同步方法 - */ - it('testEncryptionDecryptionGuidanceAesArkTs010', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs010 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('aes_gcm_seg_encryption_decryption_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES_GCM segmentation Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES_GCMSynchronousSuccess')); - console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs010 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function encryptionDecryptionGuidanceAesArkTsTest() { + describe('encryptionDecryptionGuidanceAesArkTsTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用AES对称密钥(GCM模式)加解密(ArkTS),异步方法 + */ + it('testEncryptionDecryptionGuidanceAesArkTs001', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('aes_gcm_encryption_decryption_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES_GCM Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_GCMAsynchronousSuccess')); + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用AES对称密钥(GCM模式)加解密(ArkTS),同步方法 + */ + it('testEncryptionDecryptionGuidanceAesArkTs002', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('aes_gcm_encryption_decryption_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES_GCM Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_GCMSynchronousSuccess')); + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用AES对称密钥(CCM模式)加解密(ArkTS),异步方法 + */ + it('testEncryptionDecryptionGuidanceAesArkTs003', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('aes_ccm_encryption_decryption_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES_CCM Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_CCMAsynchronousSuccess')); + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用AES对称密钥(CCM模式)加解密(ArkTS),同步方法 + */ + it('testEncryptionDecryptionGuidanceAesArkTs004', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('aes_ccm_encryption_decryption_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES_CCM Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_CCMSynchronousSuccess')); + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs004 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用AES对称密钥(CBC模式)加解密(ArkTS),异步方法 + */ + it('testEncryptionDecryptionGuidanceAesArkTs005', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('aes_cbc_encryption_decryption_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES_CBC Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_CBCAsynchronousSuccess')); + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs005 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用AES对称密钥(CBC模式)加解密(ArkTS),同步方法 + */ + it('testEncryptionDecryptionGuidanceAesArkTs006', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs006 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('aes_cbc_encryption_decryption_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES_CBC Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_CBCSynchronousSuccess')); + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs006 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用AES对称密钥(ECB模式)加解密(ArkTS),异步方法 + */ + it('testEncryptionDecryptionGuidanceAesArkTs007', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs007 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('aes_ecb_encryption_decryption_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES_ECB Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_ECBAsynchronousSuccess')); + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs007 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用AES对称密钥(ECB模式)加解密(ArkTS),同步方法 + */ + it('testEncryptionDecryptionGuidanceAesArkTs008', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs008 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('aes_ecb_encryption_decryption_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES_ECB Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_ECBSynchronousSuccess')); + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs008 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用AES对称密钥(GCM模式)分段加解密(ArkTS),异步方法 + */ + it('testEncryptionDecryptionGuidanceAesArkTs009', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs009 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('aes_gcm_seg_encryption_decryption_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES_GCM segmentation Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_GCMAsynchronousSuccess')); + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs009 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用AES对称密钥(GCM模式)分段加解密(ArkTS),同步方法 + */ + it('testEncryptionDecryptionGuidanceAesArkTs010', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs010 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('aes_gcm_seg_encryption_decryption_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES_GCM segmentation Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES_GCMSynchronousSuccess')); + console.info('uitest: testEncryptionDecryptionGuidanceAesArkTs010 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/ohosTest.md old mode 100755 new mode 100644 index fb67bbedbd..ad51c77def --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/ohosTest.md @@ -1,17 +1,17 @@ -# 使用AES对称密钥加解密(ArkTS)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用AES对称密钥(GCM模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(GCM模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(CCM模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(CCM模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(CBC模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(CBC模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(ECB模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(ECB模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用AES对称密钥(GCM模式)分段加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 使用AES对称密钥加解密(ArkTS)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用AES对称密钥(GCM模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(GCM模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(CCM模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(CCM模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(CBC模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(CBC模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(ECB模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(ECB模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用AES对称密钥(GCM模式)分段加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用AES对称密钥(GCM模式)分段加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/screenshots/EncryptionDecryptionGuidanceAesArkTs1.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/screenshots/EncryptionDecryptionGuidanceAesArkTs1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/screenshots/EncryptionDecryptionGuidanceAesArkTs2.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceAesArkTs/screenshots/EncryptionDecryptionGuidanceAesArkTs2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/app.json5 old mode 100755 new mode 100644 index f6aaebfdd9..c7be98756b --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/app.json5 @@ -1,25 +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.encryptiondecryptionguidancersa", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.encryptiondecryptionguidancersa", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 501a0ecc04..a097cdb19d --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "EncryptionDecryptionGuidanceRSA" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "EncryptionDecryptionGuidanceRSA" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/README.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/README.md old mode 100755 new mode 100644 index 05fbc6431a..ff1301574a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/README.md @@ -1,78 +1,78 @@ -# 使用RSA非对称密钥加解密 - -### 介绍 - -本示例主要展示了使用RSA非对称密钥(PKCS1模式)加解密、使用RSA非对称密钥分段加解密、使用RSA非对称密钥(PKCS1_OAEP模式)加解密场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用RSA非对称密钥(PKCS1模式)加解密](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-asym-encrypt-decrypt-pkcs1.md) -- [使用RSA非对称密钥分段加解密](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-asym-encrypt-decrypt-by-segment.md) -- [使用RSA非对称密钥(PKCS1_OAEP模式)加解密](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-asym-encrypt-decrypt-pkcs1_oaep.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例EncryptionDecryptionGuidanceRSA.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用RSA非对称密钥加解密示例代码 - │ │ ├── rsa_pkcs1 - │ │ | ├── RSAPKCS1Async.ets - │ │ | ├── RSAPKCS1Sync.ets - │ │ ├── rsa_pkcs1_oaep - │ │ | ├── RSAPKCS1OAEPAsync.ets - │ │ | ├── RSAPKCS1OAEPSync.ets - │ │ ├── rsa_segmentation - │ │ | ├── RSASegmentationAsync.ets - │ │ | ├── RSASegmentationSync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── EncryptionDecryptionGuidanceRSA.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 使用RSA非对称密钥加解密 + +### 介绍 + +本示例主要展示了使用RSA非对称密钥(PKCS1模式)加解密、使用RSA非对称密钥分段加解密、使用RSA非对称密钥(PKCS1_OAEP模式)加解密场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用RSA非对称密钥(PKCS1模式)加解密](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-asym-encrypt-decrypt-pkcs1.md) +- [使用RSA非对称密钥分段加解密](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-asym-encrypt-decrypt-by-segment.md) +- [使用RSA非对称密钥(PKCS1_OAEP模式)加解密](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-asym-encrypt-decrypt-pkcs1_oaep.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例EncryptionDecryptionGuidanceRSA.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用RSA非对称密钥加解密示例代码 + │ │ ├── rsa_pkcs1 + │ │ | ├── RSAPKCS1Async.ets + │ │ | ├── RSAPKCS1Sync.ets + │ │ ├── rsa_pkcs1_oaep + │ │ | ├── RSAPKCS1OAEPAsync.ets + │ │ | ├── RSAPKCS1OAEPSync.ets + │ │ ├── rsa_segmentation + │ │ | ├── RSASegmentationAsync.ets + │ │ | ├── RSASegmentationSync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── EncryptionDecryptionGuidanceRSA.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA > .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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Async.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Async.ets old mode 100755 new mode 100644 index 0159e53a43..33683cc72e --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Async.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Async.ets @@ -1,123 +1,123 @@ -/* - * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 加密消息 -async function encryptMessagePromise(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('RSA1024|PKCS1'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null); - let encryptData = await cipher.doFinal(plainText); - return encryptData; -} - -// 解密消息 -async function decryptMessagePromise(privateKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('RSA1024|PKCS1'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, privateKey, null); - let decryptData = await decoder.doFinal(cipherText); - return decryptData; -} - -// 生成RSA密钥对 -async function genKeyPairByData(pubKeyData: Uint8Array, priKeyData: Uint8Array) { - let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyData }; - let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyData }; - let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); - let keyPair = await rsaGenerator.convertKey(pubKeyBlob, priKeyBlob); - console.info('convertKey success'); - return keyPair; -} - -async function main() { - let pkData = - new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, - 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, 74, 42, 173, 40, 215, - 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, 210, 181, 12, 29, 70, - 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, 245, 46, 70, 45, 157, - 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, 118, 92, 147, 121, 220, - 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, 105, 208, 133, 140, 13, - 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1]); - let skData = - new Uint8Array([48, 130, 2, 119, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 97, 48, - 130, 2, 93, 2, 1, 0, 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, - 74, 42, 173, 40, 215, 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, - 210, 181, 12, 29, 70, 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, - 245, 46, 70, 45, 157, 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, - 118, 92, 147, 121, 220, 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, - 105, 208, 133, 140, 13, 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1, 2, 129, 128, 70, 75, 184, 139, 53, 1, 94, - 17, 240, 244, 218, 101, 193, 253, 215, 190, 164, 204, 197, 192, 200, 89, 107, 39, 171, 119, 65, 38, 204, 168, 105, - 180, 234, 217, 16, 161, 185, 132, 175, 103, 25, 154, 153, 153, 36, 36, 26, 178, 150, 66, 45, 8, 185, 19, 90, 228, - 210, 177, 30, 200, 177, 141, 78, 184, 248, 59, 113, 154, 145, 73, 160, 24, 73, 157, 86, 207, 186, 32, 95, 200, - 106, 252, 107, 69, 170, 193, 216, 196, 181, 142, 74, 203, 15, 18, 89, 228, 152, 19, 239, 21, 233, 98, 121, 214, - 57, 187, 111, 239, 223, 248, 199, 70, 223, 108, 108, 113, 234, 144, 155, 95, 246, 144, 244, 122, 39, 55, 127, 81, - 2, 65, 0, 246, 96, 188, 0, 0, 104, 221, 105, 139, 144, 63, 175, 209, 87, 179, 162, 88, 192, 99, 82, 125, 53, 54, - 48, 70, 245, 239, 37, 15, 242, 247, 84, 115, 187, 196, 95, 156, 40, 165, 60, 64, 102, 13, 229, 243, 2, 149, 0, - 232, 226, 221, 192, 95, 11, 12, 208, 5, 181, 98, 62, 210, 190, 141, 235, 2, 65, 0, 204, 244, 34, 10, 105, 80, 76, - 116, 163, 35, 231, 168, 187, 206, 189, 101, 215, 103, 80, 115, 86, 11, 34, 127, 203, 114, 84, 188, 121, 174, 169, - 31, 142, 2, 182, 27, 140, 225, 157, 227, 71, 98, 15, 203, 187, 213, 5, 190, 20, 121, 8, 30, 193, 100, 232, 101, - 141, 8, 124, 20, 29, 78, 6, 95, 2, 65, 0, 204, 43, 225, 224, 6, 118, 224, 117, 100, 200, 199, 94, 70, 23, 109, - 175, 173, 232, 208, 230, 61, 8, 105, 189, 156, 48, 150, 91, 154, 89, 248, 136, 173, 215, 254, 166, 84, 220, 130, - 1, 234, 68, 40, 100, 84, 251, 224, 202, 254, 51, 115, 28, 198, 38, 124, 25, 175, 129, 94, 199, 61, 17, 216, 189, - 2, 64, 72, 230, 129, 129, 48, 138, 134, 87, 106, 123, 231, 247, 165, 173, 216, 194, 115, 198, 228, 223, 209, 120, - 46, 114, 68, 92, 75, 117, 170, 214, 140, 131, 147, 208, 181, 19, 193, 157, 178, 186, 87, 246, 178, 101, 166, 79, - 20, 54, 211, 51, 101, 199, 2, 197, 48, 192, 134, 84, 193, 69, 170, 82, 201, 131, 2, 65, 0, 213, 165, 55, 166, 131, - 210, 195, 56, 250, 147, 195, 61, 205, 208, 189, 185, 40, 52, 50, 119, 137, 23, 246, 46, 220, 108, 52, 23, 152, - 154, 94, 32, 144, 195, 184, 249, 21, 168, 12, 57, 222, 18, 60, 117, 81, 157, 72, 30, 155, 190, 165, 242, 228, 139, - 240, 184, 145, 170, 103, 210, 160, 161, 135, 13]); - let keyPair = await genKeyPairByData(pkData, skData); - let pubKey = keyPair.pubKey; - let priKey = keyPair.priKey; - let message = 'This is a test'; - // 把字符串按utf-8解码为Uint8Array - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessagePromise(pubKey, plainText); - let decryptText = await decryptMessagePromise(priKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - // 把Uint8Array按utf-8编码为字符串 - let messageDecrypted = buffer.from(decryptText.data).toString('utf-8'); - console.info('decrypted result string:' + messageDecrypted); - } else { - console.error('decrypt failed'); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'RSA PKCS1 Async'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_pkcs1_async')) - .onClick(async () => { - try { - await main(); - this.message = 'RSA PKCS1 Async Success'; - } catch (error) { - console.error(error); - this.message = 'RSA PKCS1 Async Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 加密消息 +async function encryptMessagePromise(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('RSA1024|PKCS1'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null); + let encryptData = await cipher.doFinal(plainText); + return encryptData; +} + +// 解密消息 +async function decryptMessagePromise(privateKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('RSA1024|PKCS1'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, privateKey, null); + let decryptData = await decoder.doFinal(cipherText); + return decryptData; +} + +// 生成RSA密钥对 +async function genKeyPairByData(pubKeyData: Uint8Array, priKeyData: Uint8Array) { + let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyData }; + let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyData }; + let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); + let keyPair = await rsaGenerator.convertKey(pubKeyBlob, priKeyBlob); + console.info('convertKey success'); + return keyPair; +} + +async function main() { + let pkData = + new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, + 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, 74, 42, 173, 40, 215, + 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, 210, 181, 12, 29, 70, + 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, 245, 46, 70, 45, 157, + 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, 118, 92, 147, 121, 220, + 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, 105, 208, 133, 140, 13, + 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1]); + let skData = + new Uint8Array([48, 130, 2, 119, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 97, 48, + 130, 2, 93, 2, 1, 0, 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, + 74, 42, 173, 40, 215, 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, + 210, 181, 12, 29, 70, 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, + 245, 46, 70, 45, 157, 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, + 118, 92, 147, 121, 220, 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, + 105, 208, 133, 140, 13, 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1, 2, 129, 128, 70, 75, 184, 139, 53, 1, 94, + 17, 240, 244, 218, 101, 193, 253, 215, 190, 164, 204, 197, 192, 200, 89, 107, 39, 171, 119, 65, 38, 204, 168, 105, + 180, 234, 217, 16, 161, 185, 132, 175, 103, 25, 154, 153, 153, 36, 36, 26, 178, 150, 66, 45, 8, 185, 19, 90, 228, + 210, 177, 30, 200, 177, 141, 78, 184, 248, 59, 113, 154, 145, 73, 160, 24, 73, 157, 86, 207, 186, 32, 95, 200, + 106, 252, 107, 69, 170, 193, 216, 196, 181, 142, 74, 203, 15, 18, 89, 228, 152, 19, 239, 21, 233, 98, 121, 214, + 57, 187, 111, 239, 223, 248, 199, 70, 223, 108, 108, 113, 234, 144, 155, 95, 246, 144, 244, 122, 39, 55, 127, 81, + 2, 65, 0, 246, 96, 188, 0, 0, 104, 221, 105, 139, 144, 63, 175, 209, 87, 179, 162, 88, 192, 99, 82, 125, 53, 54, + 48, 70, 245, 239, 37, 15, 242, 247, 84, 115, 187, 196, 95, 156, 40, 165, 60, 64, 102, 13, 229, 243, 2, 149, 0, + 232, 226, 221, 192, 95, 11, 12, 208, 5, 181, 98, 62, 210, 190, 141, 235, 2, 65, 0, 204, 244, 34, 10, 105, 80, 76, + 116, 163, 35, 231, 168, 187, 206, 189, 101, 215, 103, 80, 115, 86, 11, 34, 127, 203, 114, 84, 188, 121, 174, 169, + 31, 142, 2, 182, 27, 140, 225, 157, 227, 71, 98, 15, 203, 187, 213, 5, 190, 20, 121, 8, 30, 193, 100, 232, 101, + 141, 8, 124, 20, 29, 78, 6, 95, 2, 65, 0, 204, 43, 225, 224, 6, 118, 224, 117, 100, 200, 199, 94, 70, 23, 109, + 175, 173, 232, 208, 230, 61, 8, 105, 189, 156, 48, 150, 91, 154, 89, 248, 136, 173, 215, 254, 166, 84, 220, 130, + 1, 234, 68, 40, 100, 84, 251, 224, 202, 254, 51, 115, 28, 198, 38, 124, 25, 175, 129, 94, 199, 61, 17, 216, 189, + 2, 64, 72, 230, 129, 129, 48, 138, 134, 87, 106, 123, 231, 247, 165, 173, 216, 194, 115, 198, 228, 223, 209, 120, + 46, 114, 68, 92, 75, 117, 170, 214, 140, 131, 147, 208, 181, 19, 193, 157, 178, 186, 87, 246, 178, 101, 166, 79, + 20, 54, 211, 51, 101, 199, 2, 197, 48, 192, 134, 84, 193, 69, 170, 82, 201, 131, 2, 65, 0, 213, 165, 55, 166, 131, + 210, 195, 56, 250, 147, 195, 61, 205, 208, 189, 185, 40, 52, 50, 119, 137, 23, 246, 46, 220, 108, 52, 23, 152, + 154, 94, 32, 144, 195, 184, 249, 21, 168, 12, 57, 222, 18, 60, 117, 81, 157, 72, 30, 155, 190, 165, 242, 228, 139, + 240, 184, 145, 170, 103, 210, 160, 161, 135, 13]); + let keyPair = await genKeyPairByData(pkData, skData); + let pubKey = keyPair.pubKey; + let priKey = keyPair.priKey; + let message = 'This is a test'; + // 把字符串按utf-8解码为Uint8Array + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await encryptMessagePromise(pubKey, plainText); + let decryptText = await decryptMessagePromise(priKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + // 把Uint8Array按utf-8编码为字符串 + let messageDecrypted = buffer.from(decryptText.data).toString('utf-8'); + console.info('decrypted result string:' + messageDecrypted); + } else { + console.error('decrypt failed'); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'RSA PKCS1 Async'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_pkcs1_async')) + .onClick(async () => { + try { + await main(); + this.message = 'RSA PKCS1 Async Success'; + } catch (error) { + console.error(error); + this.message = 'RSA PKCS1 Async Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Sync.ets old mode 100755 new mode 100644 index 6ce9553d8e..ed3d8769b0 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Sync.ets @@ -1,123 +1,123 @@ -/* - * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 加密消息 -function encryptMessage(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('RSA1024|PKCS1'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null); - let encryptData = cipher.doFinalSync(plainText); - return encryptData; -} - -// 解密消息 -function decryptMessage(privateKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('RSA1024|PKCS1'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, privateKey, null); - let decryptData = decoder.doFinalSync(cipherText); - return decryptData; -} - -// 生成RSA密钥对 -function genKeyPairByData(pubKeyData: Uint8Array, priKeyData: Uint8Array) { - let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyData }; - let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyData }; - let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); - let keyPair = rsaGenerator.convertKeySync(pubKeyBlob, priKeyBlob); - console.info('convertKeySync success'); - return keyPair; -} - -function main() { - let pkData = - new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, - 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, 74, 42, 173, 40, 215, - 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, 210, 181, 12, 29, 70, - 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, 245, 46, 70, 45, 157, - 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, 118, 92, 147, 121, 220, - 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, 105, 208, 133, 140, 13, - 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1]); - let skData = - new Uint8Array([48, 130, 2, 119, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 97, 48, - 130, 2, 93, 2, 1, 0, 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, - 74, 42, 173, 40, 215, 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, - 210, 181, 12, 29, 70, 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, - 245, 46, 70, 45, 157, 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, - 118, 92, 147, 121, 220, 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, - 105, 208, 133, 140, 13, 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1, 2, 129, 128, 70, 75, 184, 139, 53, 1, 94, - 17, 240, 244, 218, 101, 193, 253, 215, 190, 164, 204, 197, 192, 200, 89, 107, 39, 171, 119, 65, 38, 204, 168, 105, - 180, 234, 217, 16, 161, 185, 132, 175, 103, 25, 154, 153, 153, 36, 36, 26, 178, 150, 66, 45, 8, 185, 19, 90, 228, - 210, 177, 30, 200, 177, 141, 78, 184, 248, 59, 113, 154, 145, 73, 160, 24, 73, 157, 86, 207, 186, 32, 95, 200, - 106, 252, 107, 69, 170, 193, 216, 196, 181, 142, 74, 203, 15, 18, 89, 228, 152, 19, 239, 21, 233, 98, 121, 214, - 57, 187, 111, 239, 223, 248, 199, 70, 223, 108, 108, 113, 234, 144, 155, 95, 246, 144, 244, 122, 39, 55, 127, 81, - 2, 65, 0, 246, 96, 188, 0, 0, 104, 221, 105, 139, 144, 63, 175, 209, 87, 179, 162, 88, 192, 99, 82, 125, 53, 54, - 48, 70, 245, 239, 37, 15, 242, 247, 84, 115, 187, 196, 95, 156, 40, 165, 60, 64, 102, 13, 229, 243, 2, 149, 0, - 232, 226, 221, 192, 95, 11, 12, 208, 5, 181, 98, 62, 210, 190, 141, 235, 2, 65, 0, 204, 244, 34, 10, 105, 80, 76, - 116, 163, 35, 231, 168, 187, 206, 189, 101, 215, 103, 80, 115, 86, 11, 34, 127, 203, 114, 84, 188, 121, 174, 169, - 31, 142, 2, 182, 27, 140, 225, 157, 227, 71, 98, 15, 203, 187, 213, 5, 190, 20, 121, 8, 30, 193, 100, 232, 101, - 141, 8, 124, 20, 29, 78, 6, 95, 2, 65, 0, 204, 43, 225, 224, 6, 118, 224, 117, 100, 200, 199, 94, 70, 23, 109, - 175, 173, 232, 208, 230, 61, 8, 105, 189, 156, 48, 150, 91, 154, 89, 248, 136, 173, 215, 254, 166, 84, 220, 130, - 1, 234, 68, 40, 100, 84, 251, 224, 202, 254, 51, 115, 28, 198, 38, 124, 25, 175, 129, 94, 199, 61, 17, 216, 189, - 2, 64, 72, 230, 129, 129, 48, 138, 134, 87, 106, 123, 231, 247, 165, 173, 216, 194, 115, 198, 228, 223, 209, 120, - 46, 114, 68, 92, 75, 117, 170, 214, 140, 131, 147, 208, 181, 19, 193, 157, 178, 186, 87, 246, 178, 101, 166, 79, - 20, 54, 211, 51, 101, 199, 2, 197, 48, 192, 134, 84, 193, 69, 170, 82, 201, 131, 2, 65, 0, 213, 165, 55, 166, 131, - 210, 195, 56, 250, 147, 195, 61, 205, 208, 189, 185, 40, 52, 50, 119, 137, 23, 246, 46, 220, 108, 52, 23, 152, - 154, 94, 32, 144, 195, 184, 249, 21, 168, 12, 57, 222, 18, 60, 117, 81, 157, 72, 30, 155, 190, 165, 242, 228, 139, - 240, 184, 145, 170, 103, 210, 160, 161, 135, 13]); - let keyPair = genKeyPairByData(pkData, skData); - let pubKey = keyPair.pubKey; - let priKey = keyPair.priKey; - let message = 'This is a test'; - // 把字符串按utf-8解码为Uint8Array - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessage(pubKey, plainText); - let decryptText = decryptMessage(priKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - // 把Uint8Array按utf-8编码为字符串 - let messageDecrypted = buffer.from(decryptText.data).toString('utf-8'); - console.info('decrypted result string:' + messageDecrypted); - } else { - console.error('decrypt failed'); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'RSA PKCS1 Sync'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_pkcs1_sync')) - .onClick(() => { - try { - main(); - this.message = 'RSA PKCS1 Sync Success'; - } catch (error) { - console.error(error); - this.message = 'RSA PKCS1 Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 加密消息 +function encryptMessage(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('RSA1024|PKCS1'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null); + let encryptData = cipher.doFinalSync(plainText); + return encryptData; +} + +// 解密消息 +function decryptMessage(privateKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('RSA1024|PKCS1'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, privateKey, null); + let decryptData = decoder.doFinalSync(cipherText); + return decryptData; +} + +// 生成RSA密钥对 +function genKeyPairByData(pubKeyData: Uint8Array, priKeyData: Uint8Array) { + let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyData }; + let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyData }; + let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); + let keyPair = rsaGenerator.convertKeySync(pubKeyBlob, priKeyBlob); + console.info('convertKeySync success'); + return keyPair; +} + +function main() { + let pkData = + new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, + 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, 74, 42, 173, 40, 215, + 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, 210, 181, 12, 29, 70, + 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, 245, 46, 70, 45, 157, + 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, 118, 92, 147, 121, 220, + 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, 105, 208, 133, 140, 13, + 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1]); + let skData = + new Uint8Array([48, 130, 2, 119, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 97, 48, + 130, 2, 93, 2, 1, 0, 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, + 74, 42, 173, 40, 215, 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, + 210, 181, 12, 29, 70, 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, + 245, 46, 70, 45, 157, 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, + 118, 92, 147, 121, 220, 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, + 105, 208, 133, 140, 13, 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1, 2, 129, 128, 70, 75, 184, 139, 53, 1, 94, + 17, 240, 244, 218, 101, 193, 253, 215, 190, 164, 204, 197, 192, 200, 89, 107, 39, 171, 119, 65, 38, 204, 168, 105, + 180, 234, 217, 16, 161, 185, 132, 175, 103, 25, 154, 153, 153, 36, 36, 26, 178, 150, 66, 45, 8, 185, 19, 90, 228, + 210, 177, 30, 200, 177, 141, 78, 184, 248, 59, 113, 154, 145, 73, 160, 24, 73, 157, 86, 207, 186, 32, 95, 200, + 106, 252, 107, 69, 170, 193, 216, 196, 181, 142, 74, 203, 15, 18, 89, 228, 152, 19, 239, 21, 233, 98, 121, 214, + 57, 187, 111, 239, 223, 248, 199, 70, 223, 108, 108, 113, 234, 144, 155, 95, 246, 144, 244, 122, 39, 55, 127, 81, + 2, 65, 0, 246, 96, 188, 0, 0, 104, 221, 105, 139, 144, 63, 175, 209, 87, 179, 162, 88, 192, 99, 82, 125, 53, 54, + 48, 70, 245, 239, 37, 15, 242, 247, 84, 115, 187, 196, 95, 156, 40, 165, 60, 64, 102, 13, 229, 243, 2, 149, 0, + 232, 226, 221, 192, 95, 11, 12, 208, 5, 181, 98, 62, 210, 190, 141, 235, 2, 65, 0, 204, 244, 34, 10, 105, 80, 76, + 116, 163, 35, 231, 168, 187, 206, 189, 101, 215, 103, 80, 115, 86, 11, 34, 127, 203, 114, 84, 188, 121, 174, 169, + 31, 142, 2, 182, 27, 140, 225, 157, 227, 71, 98, 15, 203, 187, 213, 5, 190, 20, 121, 8, 30, 193, 100, 232, 101, + 141, 8, 124, 20, 29, 78, 6, 95, 2, 65, 0, 204, 43, 225, 224, 6, 118, 224, 117, 100, 200, 199, 94, 70, 23, 109, + 175, 173, 232, 208, 230, 61, 8, 105, 189, 156, 48, 150, 91, 154, 89, 248, 136, 173, 215, 254, 166, 84, 220, 130, + 1, 234, 68, 40, 100, 84, 251, 224, 202, 254, 51, 115, 28, 198, 38, 124, 25, 175, 129, 94, 199, 61, 17, 216, 189, + 2, 64, 72, 230, 129, 129, 48, 138, 134, 87, 106, 123, 231, 247, 165, 173, 216, 194, 115, 198, 228, 223, 209, 120, + 46, 114, 68, 92, 75, 117, 170, 214, 140, 131, 147, 208, 181, 19, 193, 157, 178, 186, 87, 246, 178, 101, 166, 79, + 20, 54, 211, 51, 101, 199, 2, 197, 48, 192, 134, 84, 193, 69, 170, 82, 201, 131, 2, 65, 0, 213, 165, 55, 166, 131, + 210, 195, 56, 250, 147, 195, 61, 205, 208, 189, 185, 40, 52, 50, 119, 137, 23, 246, 46, 220, 108, 52, 23, 152, + 154, 94, 32, 144, 195, 184, 249, 21, 168, 12, 57, 222, 18, 60, 117, 81, 157, 72, 30, 155, 190, 165, 242, 228, 139, + 240, 184, 145, 170, 103, 210, 160, 161, 135, 13]); + let keyPair = genKeyPairByData(pkData, skData); + let pubKey = keyPair.pubKey; + let priKey = keyPair.priKey; + let message = 'This is a test'; + // 把字符串按utf-8解码为Uint8Array + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = encryptMessage(pubKey, plainText); + let decryptText = decryptMessage(priKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + // 把Uint8Array按utf-8编码为字符串 + let messageDecrypted = buffer.from(decryptText.data).toString('utf-8'); + console.info('decrypted result string:' + messageDecrypted); + } else { + console.error('decrypt failed'); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'RSA PKCS1 Sync'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_pkcs1_sync')) + .onClick(() => { + try { + main(); + this.message = 'RSA PKCS1 Sync Success'; + } catch (error) { + console.error(error); + this.message = 'RSA PKCS1 Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1_oaep/RSAPKCS1OAEPAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1_oaep/RSAPKCS1OAEPAsync.ets old mode 100755 new mode 100644 index 59e5442dbe..2ba5cba186 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1_oaep/RSAPKCS1OAEPAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1_oaep/RSAPKCS1OAEPAsync.ets @@ -1,131 +1,131 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pss_verify_rsa_keypair_sign_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 根据密钥参数属性构造RSA非对称密钥对密钥参数 -function genRsaKeyPairSpec(nIn: bigint, eIn: bigint, dIn: bigint) { - let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { - n: nIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC - }; - let rsaKeyPairSpec: cryptoFramework.RSAKeyPairSpec = { - params: rsaCommSpec, - sk: dIn, - pk: eIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC - }; - return rsaKeyPairSpec; -} - -// 生成RSA2048密钥对参数 -function genRsa2048KeyPairSpec(): cryptoFramework.RSAKeyPairSpec { - let nIn = - BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc4328daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee34e4d933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7afa7ac59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c0589c3e253f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); - let eIn = BigInt('0x010001'); - let dIn = - BigInt('0x6a7df2ca63ead4dda191d614b6b385e0d9056a3d6d5cfe07db1daabee022db08212d97613d3328e0267c9dd23d787abde2afcb306aeb7dfce69246cc73f5c87fdf06030179a2114b767db1f083ff841c025d7dc00cd82435b9a90f695369e94df23d2ce458bc3b3283ad8bba2b8fa1ba62e2dce9accff3799aae7c840016f3ba8e0048c0b6cc4339af7161003a5beb864a0164b2c1c9237b64bc87556994351b27506c33d4bcdfce0f9c491a7d6b0628c7c852be4f0a9c3132b2ed3a2c8881e9aab07e20e17deb074691be677776a78b5c502e05d9bdde72126b3738695e2dd1a0a98a14247c65d8a7ee79432a092cb0721a12df798e44f7cfce0c498147a9b1'); - return genRsaKeyPairSpec(nIn, eIn, dIn); -} - -async function rsaUseSpecDecryptOAEPPromise() { - let plan = 'This is a test'; - // 获得RSA密钥对密钥参数对象 - let rsaKeyPairSpec = genRsa2048KeyPairSpec(); - // 根据RSA密钥对参数生成RSA密钥对 - let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaKeyPairSpec); - let cipher = cryptoFramework.createCipher('RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA1'); - let decoder = cryptoFramework.createCipher('RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA1'); - // RSA加解密PKCS1-OAEP模式填充字节流P - let pSource = new Uint8Array([1, 2, 3, 4]); - let input: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan, 'utf-8').buffer) }; - // 生成密钥对 - let keyPair = await rsaGeneratorSpec.generateKeyPair(); - // 进行加密操作初始化 - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, keyPair.pubKey, null); - // get和set操作可以放在Cipher对象init之后,此处对cipher进行set和get操作 - cipher.setCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR, pSource); - let retP = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR); - // 比较get出来的P字节流与set进去的P字节流是否一致 - if (retP.toString() != pSource.toString()) { - console.error('error init pSource' + retP); - } else { - console.info('pSource changed ==' + retP); - } - // 进行OAEP其他参数的get操作 - let md = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MD_NAME_STR); - console.info('md == ' + md); - let mgf = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF_NAME_STR); - console.info('mgf == ' + mgf); - let mgf1Md = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_MD_STR); - console.info('mgf1Md == ' + mgf1Md); - let cipherDataBlob = await cipher.doFinal(input); - // get和set操作可以放在Cipher对象init之前,且与init之后等价,此处对decoder进行set和get操作 - decoder.setCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR, pSource); - retP = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR); - // 比较get出来的P字节流与set进去的P字节流是否一致 - if (retP.toString() != pSource.toString()) { - console.error('error init pSource' + retP); - } else { - console.info('pSource changed ==' + retP); - } - // 进行OAEP其他参数的get操作 - md = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MD_NAME_STR); - console.info('md == ' + md); - mgf = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF_NAME_STR); - console.info('mgf == ' + mgf); - mgf1Md = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_MD_STR); - console.info('mgf1Md == ' + mgf1Md); - // 初始化解密操作 - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, keyPair.priKey, null); - let decodeData = await decoder.doFinal(cipherDataBlob); - // 解密成功 - if (decodeData.data.toString() === input.data.toString()) { - console.info('oaep decrypt success'); - } else { - console.error('oaep decrypt fail'); - } -} -// [End pss_verify_rsa_keypair_sign_async] - -@Entry -@Component -struct Index { - @State message: string = 'RSA PKCS1 OAEP Async'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_pkcs1_oaep_async')) - .onClick(async () => { - try { - await rsaUseSpecDecryptOAEPPromise(); - this.message = 'RSA PKCS1 OAEP Async Success'; - } catch (error) { - console.error(error); - this.message = 'RSA PKCS1 OAEP Async Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pss_verify_rsa_keypair_sign_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 根据密钥参数属性构造RSA非对称密钥对密钥参数 +function genRsaKeyPairSpec(nIn: bigint, eIn: bigint, dIn: bigint) { + let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { + n: nIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC + }; + let rsaKeyPairSpec: cryptoFramework.RSAKeyPairSpec = { + params: rsaCommSpec, + sk: dIn, + pk: eIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC + }; + return rsaKeyPairSpec; +} + +// 生成RSA2048密钥对参数 +function genRsa2048KeyPairSpec(): cryptoFramework.RSAKeyPairSpec { + let nIn = + BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc4328daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee34e4d933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7afa7ac59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c0589c3e253f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); + let eIn = BigInt('0x010001'); + let dIn = + BigInt('0x6a7df2ca63ead4dda191d614b6b385e0d9056a3d6d5cfe07db1daabee022db08212d97613d3328e0267c9dd23d787abde2afcb306aeb7dfce69246cc73f5c87fdf06030179a2114b767db1f083ff841c025d7dc00cd82435b9a90f695369e94df23d2ce458bc3b3283ad8bba2b8fa1ba62e2dce9accff3799aae7c840016f3ba8e0048c0b6cc4339af7161003a5beb864a0164b2c1c9237b64bc87556994351b27506c33d4bcdfce0f9c491a7d6b0628c7c852be4f0a9c3132b2ed3a2c8881e9aab07e20e17deb074691be677776a78b5c502e05d9bdde72126b3738695e2dd1a0a98a14247c65d8a7ee79432a092cb0721a12df798e44f7cfce0c498147a9b1'); + return genRsaKeyPairSpec(nIn, eIn, dIn); +} + +async function rsaUseSpecDecryptOAEPPromise() { + let plan = 'This is a test'; + // 获得RSA密钥对密钥参数对象 + let rsaKeyPairSpec = genRsa2048KeyPairSpec(); + // 根据RSA密钥对参数生成RSA密钥对 + let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaKeyPairSpec); + let cipher = cryptoFramework.createCipher('RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA1'); + let decoder = cryptoFramework.createCipher('RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA1'); + // RSA加解密PKCS1-OAEP模式填充字节流P + let pSource = new Uint8Array([1, 2, 3, 4]); + let input: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan, 'utf-8').buffer) }; + // 生成密钥对 + let keyPair = await rsaGeneratorSpec.generateKeyPair(); + // 进行加密操作初始化 + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, keyPair.pubKey, null); + // get和set操作可以放在Cipher对象init之后,此处对cipher进行set和get操作 + cipher.setCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR, pSource); + let retP = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR); + // 比较get出来的P字节流与set进去的P字节流是否一致 + if (retP.toString() != pSource.toString()) { + console.error('error init pSource' + retP); + } else { + console.info('pSource changed ==' + retP); + } + // 进行OAEP其他参数的get操作 + let md = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MD_NAME_STR); + console.info('md == ' + md); + let mgf = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF_NAME_STR); + console.info('mgf == ' + mgf); + let mgf1Md = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_MD_STR); + console.info('mgf1Md == ' + mgf1Md); + let cipherDataBlob = await cipher.doFinal(input); + // get和set操作可以放在Cipher对象init之前,且与init之后等价,此处对decoder进行set和get操作 + decoder.setCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR, pSource); + retP = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR); + // 比较get出来的P字节流与set进去的P字节流是否一致 + if (retP.toString() != pSource.toString()) { + console.error('error init pSource' + retP); + } else { + console.info('pSource changed ==' + retP); + } + // 进行OAEP其他参数的get操作 + md = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MD_NAME_STR); + console.info('md == ' + md); + mgf = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF_NAME_STR); + console.info('mgf == ' + mgf); + mgf1Md = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_MD_STR); + console.info('mgf1Md == ' + mgf1Md); + // 初始化解密操作 + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, keyPair.priKey, null); + let decodeData = await decoder.doFinal(cipherDataBlob); + // 解密成功 + if (decodeData.data.toString() === input.data.toString()) { + console.info('oaep decrypt success'); + } else { + console.error('oaep decrypt fail'); + } +} +// [End pss_verify_rsa_keypair_sign_async] + +@Entry +@Component +struct Index { + @State message: string = 'RSA PKCS1 OAEP Async'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_pkcs1_oaep_async')) + .onClick(async () => { + try { + await rsaUseSpecDecryptOAEPPromise(); + this.message = 'RSA PKCS1 OAEP Async Success'; + } catch (error) { + console.error(error); + this.message = 'RSA PKCS1 OAEP Async Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1_oaep/RSAPKCS1OAEPSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1_oaep/RSAPKCS1OAEPSync.ets old mode 100755 new mode 100644 index e7ac095b19..b03ec271bc --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1_oaep/RSAPKCS1OAEPSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1_oaep/RSAPKCS1OAEPSync.ets @@ -1,126 +1,126 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pss_verify_rsa_keypair_sign_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; -// 根据密钥参数属性构造RSA非对称密钥对密钥参数 -function genRsaKeyPairSpec(nIn: bigint, eIn: bigint, dIn: bigint) { - let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { - n: nIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC - }; - let rsaKeyPairSpec: cryptoFramework.RSAKeyPairSpec = { - params: rsaCommSpec, - sk: dIn, - pk: eIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC - }; - return rsaKeyPairSpec; -} -// 生成RSA2048密钥对参数 -function genRsa2048KeyPairSpec(): cryptoFramework.RSAKeyPairSpec { - let nIn = BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc4328daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee34e4d933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7afa7ac59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c0589c3e253f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); - let eIn = BigInt('0x010001'); - let dIn = BigInt('0x6a7df2ca63ead4dda191d614b6b385e0d9056a3d6d5cfe07db1daabee022db08212d97613d3328e0267c9dd23d787abde2afcb306aeb7dfce69246cc73f5c87fdf06030179a2114b767db1f083ff841c025d7dc00cd82435b9a90f695369e94df23d2ce458bc3b3283ad8bba2b8fa1ba62e2dce9accff3799aae7c840016f3ba8e0048c0b6cc4339af7161003a5beb864a0164b2c1c9237b64bc87556994351b27506c33d4bcdfce0f9c491a7d6b0628c7c852be4f0a9c3132b2ed3a2c8881e9aab07e20e17deb074691be677776a78b5c502e05d9bdde72126b3738695e2dd1a0a98a14247c65d8a7ee79432a092cb0721a12df798e44f7cfce0c498147a9b1'); - return genRsaKeyPairSpec(nIn, eIn, dIn); -} -function main() { - let plan = 'This is a test'; - // 获得RSA密钥对密钥参数对象 - let rsaKeyPairSpec = genRsa2048KeyPairSpec(); - // 根据RSA密钥对参数生成RSA密钥对 - let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaKeyPairSpec); - let cipher = cryptoFramework.createCipher('RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA1'); - let decoder = cryptoFramework.createCipher('RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA1'); - // RSA加解密PKCS1-OAEP模式填充字节流P - let pSource = new Uint8Array([1, 2, 3, 4]); - let input: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan, 'utf-8').buffer) }; - // 生成密钥对 - let keyPair = rsaGeneratorSpec.generateKeyPairSync(); - // 进行加密操作初始化 - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, keyPair.pubKey, null); - // get和set操作可以放在Cipher对象init之后,此处对cipher进行set和get操作 - cipher.setCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR, pSource); - let retP = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR); - // 比较get出来的P字节流与set进去的P字节流是否一致 - if (retP.toString() != pSource.toString()) { - console.error('error init pSource' + retP); - } else { - console.info('pSource changed ==' + retP); - } - // 进行OAEP其他参数的get操作 - let md = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MD_NAME_STR); - console.info('md == ' + md); - let mgf = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF_NAME_STR); - console.info('mgf == ' + mgf); - let mgf1Md = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_MD_STR); - console.info('mgf1Md == ' + mgf1Md); - let cipherDataBlob = cipher.doFinalSync(input); - // get和set操作可以放在Cipher对象init之前,且与init之后等价,此处对decoder进行set和get操作 - decoder.setCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR, pSource); - retP = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR); - // 比较get出来的P字节流与set进去的P字节流是否一致 - if (retP.toString() != pSource.toString()) { - console.error('error init pSource' + retP); - } else { - console.info('pSource changed ==' + retP); - } - // 进行OAEP其他参数的get操作 - md = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MD_NAME_STR); - console.info('md == ' + md); - mgf = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF_NAME_STR); - console.info('mgf == ' + mgf); - mgf1Md = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_MD_STR); - console.info('mgf1Md == ' + mgf1Md); - // 初始化解密操作 - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, keyPair.priKey, null); - let decodeData = decoder.doFinalSync(cipherDataBlob); - // 解密成功 - if (decodeData.data.toString() === input.data.toString()) { - console.info('oaep decrypt success'); - } else { - console.error('oaep decrypt fail'); - } -} -// [End pss_verify_rsa_keypair_sign_sync] - -@Entry -@Component -struct Index { - @State message: string = 'RSA PKCS1 OAEP Sync'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_pkcs1_oaep_sync')) - .onClick(() => { - try { - main(); - this.message = 'RSA PKCS1 OAEP Sync Success'; - } catch (error) { - console.error(error); - this.message = 'RSA PKCS1 OAEP Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pss_verify_rsa_keypair_sign_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; +// 根据密钥参数属性构造RSA非对称密钥对密钥参数 +function genRsaKeyPairSpec(nIn: bigint, eIn: bigint, dIn: bigint) { + let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { + n: nIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC + }; + let rsaKeyPairSpec: cryptoFramework.RSAKeyPairSpec = { + params: rsaCommSpec, + sk: dIn, + pk: eIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC + }; + return rsaKeyPairSpec; +} +// 生成RSA2048密钥对参数 +function genRsa2048KeyPairSpec(): cryptoFramework.RSAKeyPairSpec { + let nIn = BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc4328daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee34e4d933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7afa7ac59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c0589c3e253f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); + let eIn = BigInt('0x010001'); + let dIn = BigInt('0x6a7df2ca63ead4dda191d614b6b385e0d9056a3d6d5cfe07db1daabee022db08212d97613d3328e0267c9dd23d787abde2afcb306aeb7dfce69246cc73f5c87fdf06030179a2114b767db1f083ff841c025d7dc00cd82435b9a90f695369e94df23d2ce458bc3b3283ad8bba2b8fa1ba62e2dce9accff3799aae7c840016f3ba8e0048c0b6cc4339af7161003a5beb864a0164b2c1c9237b64bc87556994351b27506c33d4bcdfce0f9c491a7d6b0628c7c852be4f0a9c3132b2ed3a2c8881e9aab07e20e17deb074691be677776a78b5c502e05d9bdde72126b3738695e2dd1a0a98a14247c65d8a7ee79432a092cb0721a12df798e44f7cfce0c498147a9b1'); + return genRsaKeyPairSpec(nIn, eIn, dIn); +} +function main() { + let plan = 'This is a test'; + // 获得RSA密钥对密钥参数对象 + let rsaKeyPairSpec = genRsa2048KeyPairSpec(); + // 根据RSA密钥对参数生成RSA密钥对 + let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaKeyPairSpec); + let cipher = cryptoFramework.createCipher('RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA1'); + let decoder = cryptoFramework.createCipher('RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA1'); + // RSA加解密PKCS1-OAEP模式填充字节流P + let pSource = new Uint8Array([1, 2, 3, 4]); + let input: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan, 'utf-8').buffer) }; + // 生成密钥对 + let keyPair = rsaGeneratorSpec.generateKeyPairSync(); + // 进行加密操作初始化 + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, keyPair.pubKey, null); + // get和set操作可以放在Cipher对象init之后,此处对cipher进行set和get操作 + cipher.setCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR, pSource); + let retP = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR); + // 比较get出来的P字节流与set进去的P字节流是否一致 + if (retP.toString() != pSource.toString()) { + console.error('error init pSource' + retP); + } else { + console.info('pSource changed ==' + retP); + } + // 进行OAEP其他参数的get操作 + let md = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MD_NAME_STR); + console.info('md == ' + md); + let mgf = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF_NAME_STR); + console.info('mgf == ' + mgf); + let mgf1Md = cipher.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_MD_STR); + console.info('mgf1Md == ' + mgf1Md); + let cipherDataBlob = cipher.doFinalSync(input); + // get和set操作可以放在Cipher对象init之前,且与init之后等价,此处对decoder进行set和get操作 + decoder.setCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR, pSource); + retP = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_PSRC_UINT8ARR); + // 比较get出来的P字节流与set进去的P字节流是否一致 + if (retP.toString() != pSource.toString()) { + console.error('error init pSource' + retP); + } else { + console.info('pSource changed ==' + retP); + } + // 进行OAEP其他参数的get操作 + md = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MD_NAME_STR); + console.info('md == ' + md); + mgf = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF_NAME_STR); + console.info('mgf == ' + mgf); + mgf1Md = decoder.getCipherSpec(cryptoFramework.CipherSpecItem.OAEP_MGF1_MD_STR); + console.info('mgf1Md == ' + mgf1Md); + // 初始化解密操作 + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, keyPair.priKey, null); + let decodeData = decoder.doFinalSync(cipherDataBlob); + // 解密成功 + if (decodeData.data.toString() === input.data.toString()) { + console.info('oaep decrypt success'); + } else { + console.error('oaep decrypt fail'); + } +} +// [End pss_verify_rsa_keypair_sign_sync] + +@Entry +@Component +struct Index { + @State message: string = 'RSA PKCS1 OAEP Sync'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_pkcs1_oaep_sync')) + .onClick(() => { + try { + main(); + this.message = 'RSA PKCS1 OAEP Sync Success'; + } catch (error) { + console.error(error); + this.message = 'RSA PKCS1 OAEP Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_segmentation/RSASegmentationAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_segmentation/RSASegmentationAsync.ets old mode 100755 new mode 100644 index d69e8ada76..ddec066c4f --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_segmentation/RSASegmentationAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_segmentation/RSASegmentationAsync.ets @@ -1,105 +1,105 @@ -/* - * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 分段加密消息 -async function rsaEncryptBySegment(pubKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('RSA1024|PKCS1'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, pubKey, null); - let plainTextSplitLen = 64; - let cipherText = new Uint8Array(); - for (let i = 0; i < plainText.data.length; i += plainTextSplitLen) { - let updateMessage = plainText.data.subarray(i, i + plainTextSplitLen); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 将原文按64字符进行拆分,循环调用doFinal进行加密,使用1024bit密钥时,每次加密生成128字节长度的密文 - let updateOutput = await cipher.doFinal(updateMessageBlob); - let mergeText = new Uint8Array(cipherText.length + updateOutput.data.length); - mergeText.set(cipherText); - mergeText.set(updateOutput.data, cipherText.length); - cipherText = mergeText; - } - let cipherBlob: cryptoFramework.DataBlob = { data: cipherText }; - return cipherBlob; -} - -// 分段解密消息 -async function rsaDecryptBySegment(priKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('RSA1024|PKCS1'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, priKey, null); - let cipherTextSplitLen = 128; // RSA密钥每次加密生成的密文字节长度计算方式:密钥位数/8 - let decryptText = new Uint8Array(); - for (let i = 0; i < cipherText.data.length; i += cipherTextSplitLen) { - let updateMessage = cipherText.data.subarray(i, i + cipherTextSplitLen); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 将密文按128字节进行拆分解密,得到原文后进行拼接 - let updateOutput = await decoder.doFinal(updateMessageBlob); - let mergeText = new Uint8Array(decryptText.length + updateOutput.data.length); - mergeText.set(decryptText); - mergeText.set(updateOutput.data, decryptText.length); - decryptText = mergeText; - } - let decryptBlob: cryptoFramework.DataBlob = { data: decryptText }; - return decryptBlob; -} - -async function rsaEncryptLongMessage() { - let message = 'This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!'; - let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); // 创建非对称密钥生成器对象 - let keyPair = await asyKeyGenerator.generateKeyPair(); // 随机生成RSA密钥 - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await rsaEncryptBySegment(keyPair.pubKey, plainText); - let decryptText = await rsaDecryptBySegment(keyPair.priKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'RSA Segmentation Async'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_segmentation_async')) - .onClick(async () => { - try { - await rsaEncryptLongMessage(); - this.message = 'RSA Segmentation Async Success'; - } catch (error) { - console.error(error); - this.message = 'RSA Segmentation Async Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 分段加密消息 +async function rsaEncryptBySegment(pubKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('RSA1024|PKCS1'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, pubKey, null); + let plainTextSplitLen = 64; + let cipherText = new Uint8Array(); + for (let i = 0; i < plainText.data.length; i += plainTextSplitLen) { + let updateMessage = plainText.data.subarray(i, i + plainTextSplitLen); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + // 将原文按64字符进行拆分,循环调用doFinal进行加密,使用1024bit密钥时,每次加密生成128字节长度的密文 + let updateOutput = await cipher.doFinal(updateMessageBlob); + let mergeText = new Uint8Array(cipherText.length + updateOutput.data.length); + mergeText.set(cipherText); + mergeText.set(updateOutput.data, cipherText.length); + cipherText = mergeText; + } + let cipherBlob: cryptoFramework.DataBlob = { data: cipherText }; + return cipherBlob; +} + +// 分段解密消息 +async function rsaDecryptBySegment(priKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('RSA1024|PKCS1'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, priKey, null); + let cipherTextSplitLen = 128; // RSA密钥每次加密生成的密文字节长度计算方式:密钥位数/8 + let decryptText = new Uint8Array(); + for (let i = 0; i < cipherText.data.length; i += cipherTextSplitLen) { + let updateMessage = cipherText.data.subarray(i, i + cipherTextSplitLen); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + // 将密文按128字节进行拆分解密,得到原文后进行拼接 + let updateOutput = await decoder.doFinal(updateMessageBlob); + let mergeText = new Uint8Array(decryptText.length + updateOutput.data.length); + mergeText.set(decryptText); + mergeText.set(updateOutput.data, decryptText.length); + decryptText = mergeText; + } + let decryptBlob: cryptoFramework.DataBlob = { data: decryptText }; + return decryptBlob; +} + +async function rsaEncryptLongMessage() { + let message = 'This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!'; + let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); // 创建非对称密钥生成器对象 + let keyPair = await asyKeyGenerator.generateKeyPair(); // 随机生成RSA密钥 + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await rsaEncryptBySegment(keyPair.pubKey, plainText); + let decryptText = await rsaDecryptBySegment(keyPair.priKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'RSA Segmentation Async'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_segmentation_async')) + .onClick(async () => { + try { + await rsaEncryptLongMessage(); + this.message = 'RSA Segmentation Async Success'; + } catch (error) { + console.error(error); + this.message = 'RSA Segmentation Async Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_segmentation/RSASegmentationSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_segmentation/RSASegmentationSync.ets old mode 100755 new mode 100644 index 6ff5d7ecb0..e38c88681e --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_segmentation/RSASegmentationSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_segmentation/RSASegmentationSync.ets @@ -1,105 +1,105 @@ -/* - * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 分段加密消息 -function rsaEncryptBySegment(pubKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('RSA1024|PKCS1'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, pubKey, null); - let plainTextSplitLen = 64; - let cipherText = new Uint8Array(); - for (let i = 0; i < plainText.data.length; i += plainTextSplitLen) { - let updateMessage = plainText.data.subarray(i, i + plainTextSplitLen); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 将原文按64字符进行拆分,循环调用doFinal进行加密,使用1024bit密钥时,每次加密生成128字节长度的密文 - let updateOutput = cipher.doFinalSync(updateMessageBlob); - let mergeText = new Uint8Array(cipherText.length + updateOutput.data.length); - mergeText.set(cipherText); - mergeText.set(updateOutput.data, cipherText.length); - cipherText = mergeText; - } - let cipherBlob: cryptoFramework.DataBlob = { data: cipherText }; - return cipherBlob; -} - -// 分段解密消息 -function rsaDecryptBySegment(priKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('RSA1024|PKCS1'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, priKey, null); - let cipherTextSplitLen = 128; // RSA密钥每次加密生成的密文字节长度计算方式:密钥位数/8 - let decryptText = new Uint8Array(); - for (let i = 0; i < cipherText.data.length; i += cipherTextSplitLen) { - let updateMessage = cipherText.data.subarray(i, i + cipherTextSplitLen); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 将密文按128字节进行拆分解密,得到原文后进行拼接 - let updateOutput = decoder.doFinalSync(updateMessageBlob); - let mergeText = new Uint8Array(decryptText.length + updateOutput.data.length); - mergeText.set(decryptText); - mergeText.set(updateOutput.data, decryptText.length); - decryptText = mergeText; - } - let decryptBlob: cryptoFramework.DataBlob = { data: decryptText }; - return decryptBlob; -} - -function main() { - let message = 'This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!'; - let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); // 创建非对称密钥生成器对象 - let keyPair = asyKeyGenerator.generateKeyPairSync(); // 随机生成RSA密钥 - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = rsaEncryptBySegment(keyPair.pubKey, plainText); - let decryptText = rsaDecryptBySegment(keyPair.priKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'RSA Segmentation Sync'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_segmentation_sync')) - .onClick(() => { - try { - main(); - this.message = 'RSA Segmentation Sync Success'; - } catch (error) { - console.error(error); - this.message = 'RSA Segmentation Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 分段加密消息 +function rsaEncryptBySegment(pubKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('RSA1024|PKCS1'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, pubKey, null); + let plainTextSplitLen = 64; + let cipherText = new Uint8Array(); + for (let i = 0; i < plainText.data.length; i += plainTextSplitLen) { + let updateMessage = plainText.data.subarray(i, i + plainTextSplitLen); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + // 将原文按64字符进行拆分,循环调用doFinal进行加密,使用1024bit密钥时,每次加密生成128字节长度的密文 + let updateOutput = cipher.doFinalSync(updateMessageBlob); + let mergeText = new Uint8Array(cipherText.length + updateOutput.data.length); + mergeText.set(cipherText); + mergeText.set(updateOutput.data, cipherText.length); + cipherText = mergeText; + } + let cipherBlob: cryptoFramework.DataBlob = { data: cipherText }; + return cipherBlob; +} + +// 分段解密消息 +function rsaDecryptBySegment(priKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('RSA1024|PKCS1'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, priKey, null); + let cipherTextSplitLen = 128; // RSA密钥每次加密生成的密文字节长度计算方式:密钥位数/8 + let decryptText = new Uint8Array(); + for (let i = 0; i < cipherText.data.length; i += cipherTextSplitLen) { + let updateMessage = cipherText.data.subarray(i, i + cipherTextSplitLen); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + // 将密文按128字节进行拆分解密,得到原文后进行拼接 + let updateOutput = decoder.doFinalSync(updateMessageBlob); + let mergeText = new Uint8Array(decryptText.length + updateOutput.data.length); + mergeText.set(decryptText); + mergeText.set(updateOutput.data, decryptText.length); + decryptText = mergeText; + } + let decryptBlob: cryptoFramework.DataBlob = { data: decryptText }; + return decryptBlob; +} + +function main() { + let message = 'This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!'; + let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); // 创建非对称密钥生成器对象 + let keyPair = asyKeyGenerator.generateKeyPairSync(); // 随机生成RSA密钥 + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = rsaEncryptBySegment(keyPair.pubKey, plainText); + let decryptText = rsaDecryptBySegment(keyPair.priKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'RSA Segmentation Sync'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_segmentation_sync')) + .onClick(() => { + try { + main(); + this.message = 'RSA Segmentation Sync Success'; + } catch (error) { + console.error(error); + this.message = 'RSA Segmentation Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceRSA.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceRSA.test.ets old mode 100755 new mode 100644 index 42831c4dee..01251e8708 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceRSA.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceRSA.test.ets @@ -1,152 +1,152 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function encryptionDecryptionGuidanceRSATest() { - describe('encryptionDecryptionGuidanceRSATest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用RSA非对称密钥(PKCS1模式)加解密,异步方法 - */ - it('testEncryptionDecryptionGuidanceRSA001', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceRSA001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA PKCS1 Async')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA PKCS1 Async')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA PKCS1 Async Success')); - console.info('uitest: testEncryptionDecryptionGuidanceRSA001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA非对称密钥(PKCS1模式)加解密,同步方法 - */ - it('testEncryptionDecryptionGuidanceRSA002', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceRSA002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA PKCS1 Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA PKCS1 Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA PKCS1 Sync Success')); - console.info('uitest: testEncryptionDecryptionGuidanceRSA002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA非对称密钥分段加解密,异步方法 - */ - it('testEncryptionDecryptionGuidanceRSA003', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceRSA003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA Segmentation Async')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA Segmentation Async')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA Segmentation Async Success')); - console.info('uitest: testEncryptionDecryptionGuidanceRSA003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA非对称密钥分段加解密,同步方法 - */ - it('testEncryptionDecryptionGuidanceRSA004', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceRSA004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA Segmentation Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA Segmentation Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA Segmentation Sync Success')); - console.info('uitest: testEncryptionDecryptionGuidanceRSA004 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA非对称密钥(PKCS1_OAEP模式)加解密,异步方法 - */ - it('testEncryptionDecryptionGuidanceRSA005', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceRSA005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA PKCS1 OAEP Async')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA PKCS1 OAEP Async')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA PKCS1 OAEP Async Success')); - console.info('uitest: testEncryptionDecryptionGuidanceRSA005 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA非对称密钥(PKCS1_OAEP模式)加解密,同步方法 - */ - it('testEncryptionDecryptionGuidanceRSA006', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceRSA006 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA PKCS1 OAEP Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA PKCS1 OAEP Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA PKCS1 OAEP Sync Success')); - console.info('uitest: testEncryptionDecryptionGuidanceRSA006 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function encryptionDecryptionGuidanceRSATest() { + describe('encryptionDecryptionGuidanceRSATest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用RSA非对称密钥(PKCS1模式)加解密,异步方法 + */ + it('testEncryptionDecryptionGuidanceRSA001', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceRSA001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA PKCS1 Async')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA PKCS1 Async')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA PKCS1 Async Success')); + console.info('uitest: testEncryptionDecryptionGuidanceRSA001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA非对称密钥(PKCS1模式)加解密,同步方法 + */ + it('testEncryptionDecryptionGuidanceRSA002', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceRSA002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA PKCS1 Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA PKCS1 Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA PKCS1 Sync Success')); + console.info('uitest: testEncryptionDecryptionGuidanceRSA002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA非对称密钥分段加解密,异步方法 + */ + it('testEncryptionDecryptionGuidanceRSA003', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceRSA003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA Segmentation Async')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA Segmentation Async')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA Segmentation Async Success')); + console.info('uitest: testEncryptionDecryptionGuidanceRSA003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA非对称密钥分段加解密,同步方法 + */ + it('testEncryptionDecryptionGuidanceRSA004', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceRSA004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA Segmentation Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA Segmentation Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA Segmentation Sync Success')); + console.info('uitest: testEncryptionDecryptionGuidanceRSA004 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA非对称密钥(PKCS1_OAEP模式)加解密,异步方法 + */ + it('testEncryptionDecryptionGuidanceRSA005', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceRSA005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA PKCS1 OAEP Async')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA PKCS1 OAEP Async')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA PKCS1 OAEP Async Success')); + console.info('uitest: testEncryptionDecryptionGuidanceRSA005 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA非对称密钥(PKCS1_OAEP模式)加解密,同步方法 + */ + it('testEncryptionDecryptionGuidanceRSA006', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceRSA006 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA PKCS1 OAEP Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA PKCS1 OAEP Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA PKCS1 OAEP Sync Success')); + console.info('uitest: testEncryptionDecryptionGuidanceRSA006 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/ohosTest.md old mode 100755 new mode 100644 index 19ecc369b9..3316dd685d --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/ohosTest.md @@ -1,13 +1,13 @@ -# 使用RSA非对称密钥加解密测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用RSA非对称密钥(PKCS1模式)加解密,异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA非对称密钥(PKCS1模式)加解密,同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA非对称密钥分段加解密,异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA非对称密钥分段加解密,同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA非对称密钥(PKCS1_OAEP模式)加解密,异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 使用RSA非对称密钥加解密测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用RSA非对称密钥(PKCS1模式)加解密,异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA非对称密钥(PKCS1模式)加解密,同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA非对称密钥分段加解密,异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA非对称密钥分段加解密,同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA非对称密钥(PKCS1_OAEP模式)加解密,异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用RSA非对称密钥(PKCS1_OAEP模式)加解密,同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/screenshots/EncryptionDecryptionGuidanceRSA1.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/screenshots/EncryptionDecryptionGuidanceRSA1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/screenshots/EncryptionDecryptionGuidanceRSA2.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/screenshots/EncryptionDecryptionGuidanceRSA2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/app.json5 old mode 100755 new mode 100644 index a3eeaf2416..d2e812a42e --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/app.json5 @@ -1,25 +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.encryptiondecryptionguidancesm2", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.encryptiondecryptionguidancesm2", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 5f16b21330..d6c14f7e0d --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "EncryptionDecryptionGuidanceSM2" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "EncryptionDecryptionGuidanceSM2" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/README.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/README.md old mode 100755 new mode 100644 index c62590747c..8f759e7ec1 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/README.md @@ -1,73 +1,73 @@ -# 使用SM2非对称密钥加解密及密文格式转换 - -### 介绍 - -本示例主要展示了使用SM2非对称密钥加解密及密文格式转换场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用SM2非对称密钥加解密](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm2-asym-encrypt-decrypt.md) -- [使用SM2密文格式转换](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm2-ciphertext-conversion.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例EncryptionDecryptionGuidanceSM2.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用SM2非对称密钥加解密及密文格式转换示例代码 - │ │ ├── sm2 - │ │ | ├── CreateASN.1Ciphertext.ets - │ │ | ├── ObtainCiphertext.ets - │ │ | ├── SM2EncryptionDecryptionAsync.ets - │ │ | ├── SM2EncryptionDecryptionSync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── EncryptionDecryptionGuidanceSM2.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2 > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 使用SM2非对称密钥加解密及密文格式转换 + +### 介绍 + +本示例主要展示了使用SM2非对称密钥加解密及密文格式转换场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用SM2非对称密钥加解密](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm2-asym-encrypt-decrypt.md) +- [使用SM2密文格式转换](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm2-ciphertext-conversion.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例EncryptionDecryptionGuidanceSM2.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用SM2非对称密钥加解密及密文格式转换示例代码 + │ │ ├── sm2 + │ │ | ├── CreateASN.1Ciphertext.ets + │ │ | ├── ObtainCiphertext.ets + │ │ | ├── SM2EncryptionDecryptionAsync.ets + │ │ | ├── SM2EncryptionDecryptionSync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── EncryptionDecryptionGuidanceSM2.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2 > .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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/CreateASN.1Ciphertext.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/CreateASN.1Ciphertext.ets old mode 100755 new mode 100644 index f4a1f26269..fee1793d98 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/CreateASN.1Ciphertext.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/CreateASN.1Ciphertext.ets @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function testGenCipherTextBySpec() { - let spec: cryptoFramework.SM2CipherTextSpec = { - xCoordinate: BigInt('20625015362595980457695435345498579729138244358573902431560627260141789922999'), - yCoordinate: BigInt('48563164792857017065725892921053777369510340820930241057309844352421738767712'), - cipherTextData: new Uint8Array([100, 227, 78, 195, 249, 179, 43, 70, 242, 69, 169, 10, 65, 123]), - hashData: new Uint8Array([87, 167, 167, 247, 88, 146, 203, 234, 83, 126, 117, 129, 52, 142, 82, 54, 152, 226, 201, - 111, 143, 115, 169, 125, 128, 42, 157, 31, 114, 198, 109, 244]), - } - // 此处的data可直接使用cryptoFramework进行SM2解密 - let data = cryptoFramework.SM2CryptoUtil.genCipherTextBySpec(spec, 'C1C3C2'); - console.info('genCipherTextBySpec success'); -} - -@Entry -@Component -struct Index { - @State message: string = 'Create ASN.1'; - - build() { - Column({ space: 5 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_create_asn1')) - .width('70%') - .onClick(() => { - try { - testGenCipherTextBySpec(); - this.message = 'Create ASN.1 Success'; - } catch { - this.message = 'Create ASN.1 Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function testGenCipherTextBySpec() { + let spec: cryptoFramework.SM2CipherTextSpec = { + xCoordinate: BigInt('20625015362595980457695435345498579729138244358573902431560627260141789922999'), + yCoordinate: BigInt('48563164792857017065725892921053777369510340820930241057309844352421738767712'), + cipherTextData: new Uint8Array([100, 227, 78, 195, 249, 179, 43, 70, 242, 69, 169, 10, 65, 123]), + hashData: new Uint8Array([87, 167, 167, 247, 88, 146, 203, 234, 83, 126, 117, 129, 52, 142, 82, 54, 152, 226, 201, + 111, 143, 115, 169, 125, 128, 42, 157, 31, 114, 198, 109, 244]), + } + // 此处的data可直接使用cryptoFramework进行SM2解密 + let data = cryptoFramework.SM2CryptoUtil.genCipherTextBySpec(spec, 'C1C3C2'); + console.info('genCipherTextBySpec success'); +} + +@Entry +@Component +struct Index { + @State message: string = 'Create ASN.1'; + + build() { + Column({ space: 5 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_create_asn1')) + .width('70%') + .onClick(() => { + try { + testGenCipherTextBySpec(); + this.message = 'Create ASN.1 Success'; + } catch { + this.message = 'Create ASN.1 Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/ObtainCiphertext.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/ObtainCiphertext.ets old mode 100755 new mode 100644 index 0470f3dafe..b8a3c20316 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/ObtainCiphertext.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/ObtainCiphertext.ets @@ -1,52 +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. - */ - -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function testGetCipherTextSpec() { - let cipherTextArray = - new Uint8Array([48, 118, 2, 32, 45, 153, 88, 82, 104, 221, 226, 43, 174, 21, 122, 248, 5, 232, 105, 41, 92, 95, 102, - 224, 216, 149, 85, 236, 110, 6, 64, 188, 149, 70, 70, 183, 2, 32, 107, 93, 198, 247, 119, 18, 40, 110, 90, 156, - 193, 158, 205, 113, 170, 128, 146, 109, 75, 17, 181, 109, 110, 91, 149, 5, 110, 233, 209, 78, 229, 96, 4, 32, 87, - 167, 167, 247, 88, 146, 203, 234, 83, 126, 117, 129, 52, 142, 82, 54, 152, 226, 201, 111, 143, 115, 169, 125, 128, - 42, 157, 31, 114, 198, 109, 244, 4, 14, 100, 227, 78, 195, 249, 179, 43, 70, 242, 69, 169, 10, 65, 123]); - let cipherText: cryptoFramework.DataBlob = { data: cipherTextArray }; - let spec: cryptoFramework.SM2CipherTextSpec = cryptoFramework.SM2CryptoUtil.getCipherTextSpec(cipherText, 'C1C3C2'); - console.info('getCipherTextSpec success'); -} - -@Entry -@Component -struct Index { - @State message: string = 'Obtain Ciphertext'; - - build() { - Column({ space: 5 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_obtain_ciphertext')) - .width('70%') - .onClick(() => { - try { - testGetCipherTextSpec(); - this.message = 'Obtain Ciphertext Success'; - } catch { - this.message = 'Obtain Ciphertext Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function testGetCipherTextSpec() { + let cipherTextArray = + new Uint8Array([48, 118, 2, 32, 45, 153, 88, 82, 104, 221, 226, 43, 174, 21, 122, 248, 5, 232, 105, 41, 92, 95, 102, + 224, 216, 149, 85, 236, 110, 6, 64, 188, 149, 70, 70, 183, 2, 32, 107, 93, 198, 247, 119, 18, 40, 110, 90, 156, + 193, 158, 205, 113, 170, 128, 146, 109, 75, 17, 181, 109, 110, 91, 149, 5, 110, 233, 209, 78, 229, 96, 4, 32, 87, + 167, 167, 247, 88, 146, 203, 234, 83, 126, 117, 129, 52, 142, 82, 54, 152, 226, 201, 111, 143, 115, 169, 125, 128, + 42, 157, 31, 114, 198, 109, 244, 4, 14, 100, 227, 78, 195, 249, 179, 43, 70, 242, 69, 169, 10, 65, 123]); + let cipherText: cryptoFramework.DataBlob = { data: cipherTextArray }; + let spec: cryptoFramework.SM2CipherTextSpec = cryptoFramework.SM2CryptoUtil.getCipherTextSpec(cipherText, 'C1C3C2'); + console.info('getCipherTextSpec success'); +} + +@Entry +@Component +struct Index { + @State message: string = 'Obtain Ciphertext'; + + build() { + Column({ space: 5 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_obtain_ciphertext')) + .width('70%') + .onClick(() => { + try { + testGetCipherTextSpec(); + this.message = 'Obtain Ciphertext Success'; + } catch { + this.message = 'Obtain Ciphertext Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/SM2EncryptionDecryptionAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/SM2EncryptionDecryptionAsync.ets old mode 100755 new mode 100644 index 0c4d284ae6..9f27af3892 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/SM2EncryptionDecryptionAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/SM2EncryptionDecryptionAsync.ets @@ -1,95 +1,95 @@ -/* - * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 加密消息 -async function encryptMessagePromise(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('SM2_256|SM3'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null); - let encryptData = await cipher.doFinal(plainText); - return encryptData; -} - -// 解密消息 -async function decryptMessagePromise(privateKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('SM2_256|SM3'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, privateKey, null); - let decryptData = await decoder.doFinal(cipherText); - return decryptData; -} - -// 生成SM2密钥对 -async function genKeyPairByData(pubKeyData: Uint8Array, priKeyData: Uint8Array) { - let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyData }; - let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyData }; - let sm2Generator = cryptoFramework.createAsyKeyGenerator('SM2_256'); - let keyPair = await sm2Generator.convertKey(pubKeyBlob, priKeyBlob); - console.info('convertKey success'); - return keyPair; -} - -async function main() { - let pkData = - new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 129, 28, 207, 85, 1, 130, 45, 3, 66, 0, - 4, 90, 3, 58, 157, 190, 248, 76, 7, 132, 200, 151, 208, 112, 230, 96, 140, 90, 238, 211, 155, 128, 109, 248, 40, - 83, 214, 78, 42, 104, 106, 55, 148, 249, 35, 61, 32, 221, 135, 143, 100, 45, 97, 194, 176, 52, 73, 136, 174, 40, - 70, 70, 34, 103, 103, 161, 99, 27, 187, 13, 187, 109, 244, 13, 7]); - let skData = - new Uint8Array([48, 49, 2, 1, 1, 4, 32, 54, 41, 239, 240, 63, 188, 134, 113, 31, 102, 149, 203, 245, 89, 15, 15, 47, - 202, 170, 60, 38, 154, 28, 169, 189, 100, 251, 76, 112, 223, 156, 159, 160, 10, 6, 8, 42, 129, 28, 207, 85, 1, - 130, 45]); - let keyPair = await genKeyPairByData(pkData, skData); - let pubKey = keyPair.pubKey; - let priKey = keyPair.priKey; - let message = 'This is a test'; - // 把字符串按utf-8解码为Uint8Array - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessagePromise(pubKey, plainText); - let decryptText = await decryptMessagePromise(priKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - // 把Uint8Array按utf-8编码为字符串 - let messageDecrypted = buffer.from(decryptText.data).toString('utf-8'); - console.info('decrypted result string:' + messageDecrypted); - } else { - console.error('decrypt failed'); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'SM2 Async'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm2_async')) - .width('70%') - .onClick(async () => { - try { - await main(); - this.message = 'SM2 Async Success'; - } catch { - this.message = 'SM2 Async Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 加密消息 +async function encryptMessagePromise(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('SM2_256|SM3'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null); + let encryptData = await cipher.doFinal(plainText); + return encryptData; +} + +// 解密消息 +async function decryptMessagePromise(privateKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('SM2_256|SM3'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, privateKey, null); + let decryptData = await decoder.doFinal(cipherText); + return decryptData; +} + +// 生成SM2密钥对 +async function genKeyPairByData(pubKeyData: Uint8Array, priKeyData: Uint8Array) { + let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyData }; + let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyData }; + let sm2Generator = cryptoFramework.createAsyKeyGenerator('SM2_256'); + let keyPair = await sm2Generator.convertKey(pubKeyBlob, priKeyBlob); + console.info('convertKey success'); + return keyPair; +} + +async function main() { + let pkData = + new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 129, 28, 207, 85, 1, 130, 45, 3, 66, 0, + 4, 90, 3, 58, 157, 190, 248, 76, 7, 132, 200, 151, 208, 112, 230, 96, 140, 90, 238, 211, 155, 128, 109, 248, 40, + 83, 214, 78, 42, 104, 106, 55, 148, 249, 35, 61, 32, 221, 135, 143, 100, 45, 97, 194, 176, 52, 73, 136, 174, 40, + 70, 70, 34, 103, 103, 161, 99, 27, 187, 13, 187, 109, 244, 13, 7]); + let skData = + new Uint8Array([48, 49, 2, 1, 1, 4, 32, 54, 41, 239, 240, 63, 188, 134, 113, 31, 102, 149, 203, 245, 89, 15, 15, 47, + 202, 170, 60, 38, 154, 28, 169, 189, 100, 251, 76, 112, 223, 156, 159, 160, 10, 6, 8, 42, 129, 28, 207, 85, 1, + 130, 45]); + let keyPair = await genKeyPairByData(pkData, skData); + let pubKey = keyPair.pubKey; + let priKey = keyPair.priKey; + let message = 'This is a test'; + // 把字符串按utf-8解码为Uint8Array + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await encryptMessagePromise(pubKey, plainText); + let decryptText = await decryptMessagePromise(priKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + // 把Uint8Array按utf-8编码为字符串 + let messageDecrypted = buffer.from(decryptText.data).toString('utf-8'); + console.info('decrypted result string:' + messageDecrypted); + } else { + console.error('decrypt failed'); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'SM2 Async'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm2_async')) + .width('70%') + .onClick(async () => { + try { + await main(); + this.message = 'SM2 Async Success'; + } catch { + this.message = 'SM2 Async Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/SM2EncryptionDecryptionSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/SM2EncryptionDecryptionSync.ets old mode 100755 new mode 100644 index 66fae4ff7c..48d1673144 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/SM2EncryptionDecryptionSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/ets/pages/sm2/SM2EncryptionDecryptionSync.ets @@ -1,95 +1,95 @@ -/* - * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 加密消息 -function encryptMessage(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('SM2_256|SM3'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null); - let encryptData = cipher.doFinalSync(plainText); - return encryptData; -} - -// 解密消息 -function decryptMessage(privateKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('SM2_256|SM3'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, privateKey, null); - let decryptData = decoder.doFinalSync(cipherText); - return decryptData; -} - -// 生成SM2密钥对 -function genKeyPairByData(pubKeyData: Uint8Array, priKeyData: Uint8Array) { - let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyData }; - let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyData }; - let sm2Generator = cryptoFramework.createAsyKeyGenerator('SM2_256'); - let keyPair = sm2Generator.convertKeySync(pubKeyBlob, priKeyBlob); - console.info('convertKeySync success'); - return keyPair; -} - -function main() { - let pkData = - new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 129, 28, 207, 85, 1, 130, 45, 3, 66, 0, - 4, 90, 3, 58, 157, 190, 248, 76, 7, 132, 200, 151, 208, 112, 230, 96, 140, 90, 238, 211, 155, 128, 109, 248, 40, - 83, 214, 78, 42, 104, 106, 55, 148, 249, 35, 61, 32, 221, 135, 143, 100, 45, 97, 194, 176, 52, 73, 136, 174, 40, - 70, 70, 34, 103, 103, 161, 99, 27, 187, 13, 187, 109, 244, 13, 7]); - let skData = - new Uint8Array([48, 49, 2, 1, 1, 4, 32, 54, 41, 239, 240, 63, 188, 134, 113, 31, 102, 149, 203, 245, 89, 15, 15, 47, - 202, 170, 60, 38, 154, 28, 169, 189, 100, 251, 76, 112, 223, 156, 159, 160, 10, 6, 8, 42, 129, 28, 207, 85, 1, - 130, 45]); - let keyPair = genKeyPairByData(pkData, skData); - let pubKey = keyPair.pubKey; - let priKey = keyPair.priKey; - let message = 'This is a test'; - // 把字符串按utf-8解码为Uint8Array - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessage(pubKey, plainText); - let decryptText = decryptMessage(priKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - // 把Uint8Array按utf-8编码为字符串 - let messageDecrypted = buffer.from(decryptText.data).toString('utf-8'); - console.info('decrypted result string:' + messageDecrypted); - } else { - console.error('decrypt failed'); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'SM2 Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm2_sync')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'SM2 Sync Success'; - } catch { - this.message = 'SM2 Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 加密消息 +function encryptMessage(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('SM2_256|SM3'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null); + let encryptData = cipher.doFinalSync(plainText); + return encryptData; +} + +// 解密消息 +function decryptMessage(privateKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('SM2_256|SM3'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, privateKey, null); + let decryptData = decoder.doFinalSync(cipherText); + return decryptData; +} + +// 生成SM2密钥对 +function genKeyPairByData(pubKeyData: Uint8Array, priKeyData: Uint8Array) { + let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyData }; + let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyData }; + let sm2Generator = cryptoFramework.createAsyKeyGenerator('SM2_256'); + let keyPair = sm2Generator.convertKeySync(pubKeyBlob, priKeyBlob); + console.info('convertKeySync success'); + return keyPair; +} + +function main() { + let pkData = + new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 129, 28, 207, 85, 1, 130, 45, 3, 66, 0, + 4, 90, 3, 58, 157, 190, 248, 76, 7, 132, 200, 151, 208, 112, 230, 96, 140, 90, 238, 211, 155, 128, 109, 248, 40, + 83, 214, 78, 42, 104, 106, 55, 148, 249, 35, 61, 32, 221, 135, 143, 100, 45, 97, 194, 176, 52, 73, 136, 174, 40, + 70, 70, 34, 103, 103, 161, 99, 27, 187, 13, 187, 109, 244, 13, 7]); + let skData = + new Uint8Array([48, 49, 2, 1, 1, 4, 32, 54, 41, 239, 240, 63, 188, 134, 113, 31, 102, 149, 203, 245, 89, 15, 15, 47, + 202, 170, 60, 38, 154, 28, 169, 189, 100, 251, 76, 112, 223, 156, 159, 160, 10, 6, 8, 42, 129, 28, 207, 85, 1, + 130, 45]); + let keyPair = genKeyPairByData(pkData, skData); + let pubKey = keyPair.pubKey; + let priKey = keyPair.priKey; + let message = 'This is a test'; + // 把字符串按utf-8解码为Uint8Array + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = encryptMessage(pubKey, plainText); + let decryptText = decryptMessage(priKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + // 把Uint8Array按utf-8编码为字符串 + let messageDecrypted = buffer.from(decryptText.data).toString('utf-8'); + console.info('decrypted result string:' + messageDecrypted); + } else { + console.error('decrypt failed'); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'SM2 Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm2_sync')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'SM2 Sync Success'; + } catch { + this.message = 'SM2 Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceSM2.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceSM2.test.ets old mode 100755 new mode 100644 index fc847beaed..beab5f33d0 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceSM2.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceSM2.test.ets @@ -1,116 +1,116 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function encryptionDecryptionGuidanceSM2Test() { - describe('encryptionDecryptionGuidanceSM2Test', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用SM2非对称密钥加解密,异步方法 - */ - it('testEncryptionDecryptionGuidanceSM2001', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceSM2001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM2 Async')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2 Async')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2 Async Success')); - console.info('uitest: testEncryptionDecryptionGuidanceSM2001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM2非对称密钥加解密,同步方法 - */ - it('testEncryptionDecryptionGuidanceSM2002', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceSM2002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM2 Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2 Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2 Sync Success')); - console.info('uitest: testEncryptionDecryptionGuidanceSM2002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM2密文格式转换,指定密文参数,生成标准ASN.1密文 - */ - it('testEncryptionDecryptionGuidanceSM2003', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceSM2003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Create ASN.1')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Create ASN.1')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Create ASN.1 Success')); - console.info('uitest: testEncryptionDecryptionGuidanceSM2003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM2密文格式转换,从标准ASN.1密文中,获取密文参数 - */ - it('testEncryptionDecryptionGuidanceSM2004', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceSM2004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Obtain Ciphertext')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Obtain Ciphertext')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Obtain Ciphertext Success')); - console.info('uitest: testEncryptionDecryptionGuidanceSM2004 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function encryptionDecryptionGuidanceSM2Test() { + describe('encryptionDecryptionGuidanceSM2Test', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用SM2非对称密钥加解密,异步方法 + */ + it('testEncryptionDecryptionGuidanceSM2001', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceSM2001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM2 Async')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2 Async')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2 Async Success')); + console.info('uitest: testEncryptionDecryptionGuidanceSM2001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM2非对称密钥加解密,同步方法 + */ + it('testEncryptionDecryptionGuidanceSM2002', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceSM2002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM2 Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2 Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2 Sync Success')); + console.info('uitest: testEncryptionDecryptionGuidanceSM2002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM2密文格式转换,指定密文参数,生成标准ASN.1密文 + */ + it('testEncryptionDecryptionGuidanceSM2003', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceSM2003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Create ASN.1')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Create ASN.1')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Create ASN.1 Success')); + console.info('uitest: testEncryptionDecryptionGuidanceSM2003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM2密文格式转换,从标准ASN.1密文中,获取密文参数 + */ + it('testEncryptionDecryptionGuidanceSM2004', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceSM2004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Obtain Ciphertext')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Obtain Ciphertext')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Obtain Ciphertext Success')); + console.info('uitest: testEncryptionDecryptionGuidanceSM2004 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/ohosTest.md old mode 100755 new mode 100644 index 86c9994116..517166af84 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/ohosTest.md @@ -1,11 +1,11 @@ -# 使用SM2非对称密钥加解密及密文格式转换测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用SM2非对称密钥加解密,异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM2非对称密钥加解密,同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM2密文格式转换,指定密文参数,生成标准ASN.1密文 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 使用SM2非对称密钥加解密及密文格式转换测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用SM2非对称密钥加解密,异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM2非对称密钥加解密,同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM2密文格式转换,指定密文参数,生成标准ASN.1密文 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用SM2密文格式转换,从标准ASN.1密文中,获取密文参数 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/screenshots/EncryptionDecryptionGuidanceSM21.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/screenshots/EncryptionDecryptionGuidanceSM21.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/screenshots/EncryptionDecryptionGuidanceSM22.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM2/screenshots/EncryptionDecryptionGuidanceSM22.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/app.json5 old mode 100755 new mode 100644 index f705dfb225..63f431a683 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/app.json5 @@ -1,25 +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.encryptiondecryptionguidancesm4", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.encryptiondecryptionguidancesm4", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 03f452cdce..14ef92ce2b --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "EncryptionDecryptionGuidanceSM4" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "EncryptionDecryptionGuidanceSM4" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/README.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/README.md old mode 100755 new mode 100644 index 8984bdeee5..30672eed9d --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/README.md @@ -1,83 +1,83 @@ -# 使用SM4对称密钥加解密(C/C++) - -### 介绍 - -本示例主要展示了使用SM4对称密钥(ECB模式)加解密(C/C++)、使用SM4对称密钥(CBC模式)加解密(C/C++)、使用SM4对称密钥(GCM模式)加解密(C/C++)、使用SM4对称密钥(GCM模式)分段加解密(C/C++)场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用SM4对称密钥(ECB模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-ecb-ndk.md) -- [使用SM4对称密钥(CBC模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-cbc-ndk.md) -- [使用SM4对称密钥(GCM模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-gcm-ndk.md) -- [使用SM4对称密钥(GCM模式)分段加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-gcm-by-segment-ndk.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例EncryptionDecryptionGuidanceSM4.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── sm4_cbc_encryption_decryption.cpp - │ │ | ├── sm4_ecb_encryption_decryption.cpp - │ │ | ├── sm4_gcm_encryption_decryption.cpp - │ │ | ├── sm4_gcm_seg_encryption_decryption.cpp - │ │ | ├── file.h - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用SM4对称密钥加解密(C/C++)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── EncryptionDecryptionGuidanceSM4.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4 > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 使用SM4对称密钥加解密(C/C++) + +### 介绍 + +本示例主要展示了使用SM4对称密钥(ECB模式)加解密(C/C++)、使用SM4对称密钥(CBC模式)加解密(C/C++)、使用SM4对称密钥(GCM模式)加解密(C/C++)、使用SM4对称密钥(GCM模式)分段加解密(C/C++)场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用SM4对称密钥(ECB模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-ecb-ndk.md) +- [使用SM4对称密钥(CBC模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-cbc-ndk.md) +- [使用SM4对称密钥(GCM模式)加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-gcm-ndk.md) +- [使用SM4对称密钥(GCM模式)分段加解密(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-gcm-by-segment-ndk.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例EncryptionDecryptionGuidanceSM4.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── sm4_cbc_encryption_decryption.cpp + │ │ | ├── sm4_ecb_encryption_decryption.cpp + │ │ | ├── sm4_gcm_encryption_decryption.cpp + │ │ | ├── sm4_gcm_seg_encryption_decryption.cpp + │ │ | ├── file.h + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用SM4对称密钥加解密(C/C++)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── EncryptionDecryptionGuidanceSM4.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4 > .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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 2452fd1879..908bd14781 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(EncryptionDecryptionGuidanceSM4) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp types/project/sm4_ecb_encryption_decryption.cpp types/project/sm4_cbc_encryption_decryption.cpp types/project/sm4_gcm_encryption_decryption.cpp types/project/sm4_gcm_seg_encryption_decryption.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(EncryptionDecryptionGuidanceSM4) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp types/project/sm4_ecb_encryption_decryption.cpp types/project/sm4_cbc_encryption_decryption.cpp types/project/sm4_gcm_encryption_decryption.cpp types/project/sm4_gcm_seg_encryption_decryption.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index fa4c21e593..0baaf52375 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/napi_init.cpp @@ -1,70 +1,70 @@ -/* - * 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 "types/project/file.h" - -static napi_value NAPI_Global_testSm4Ecb(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestSm4Ecb(), &ret); - return ret; -} - -static napi_value NAPI_Global_testSm4Cbc(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestSm4Cbc(), &ret); - return ret; -} - -static napi_value NAPI_Global_testSm4Gcm(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestSm4Gcm(), &ret); - return ret; -} - -static napi_value NAPI_Global_testSm4GcmSeg(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestSm4GcmSeg(), &ret); - return ret; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"testSm4Ecb", nullptr, NAPI_Global_testSm4Ecb, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"testSm4Cbc", nullptr, NAPI_Global_testSm4Cbc, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"testSm4Gcm", nullptr, NAPI_Global_testSm4Gcm, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"testSm4GcmSeg", nullptr, NAPI_Global_testSm4GcmSeg, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/file.h" + +static napi_value NAPI_Global_testSm4Ecb(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestSm4Ecb(), &ret); + return ret; +} + +static napi_value NAPI_Global_testSm4Cbc(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestSm4Cbc(), &ret); + return ret; +} + +static napi_value NAPI_Global_testSm4Gcm(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestSm4Gcm(), &ret); + return ret; +} + +static napi_value NAPI_Global_testSm4GcmSeg(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestSm4GcmSeg(), &ret); + return ret; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"testSm4Ecb", nullptr, NAPI_Global_testSm4Ecb, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"testSm4Cbc", nullptr, NAPI_Global_testSm4Cbc, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"testSm4Gcm", nullptr, NAPI_Global_testSm4Gcm, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"testSm4GcmSeg", nullptr, NAPI_Global_testSm4GcmSeg, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index eccd145f2a..1286917646 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,22 +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. - */ - -export const testSm4Ecb: () => number; - -export const testSm4Cbc: () => number; - -export const testSm4Gcm: () => number; - -export const testSm4GcmSeg: () => number; +/* + * 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 testSm4Ecb: () => number; + +export const testSm4Cbc: () => number; + +export const testSm4Gcm: () => number; + +export const testSm4GcmSeg: () => number; diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/file.h b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/file.h old mode 100755 new mode 100644 index 076f122220..2e8def9185 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/file.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/file.h @@ -1,21 +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. - */ - -#include "CryptoArchitectureKit/crypto_common.h" - -OH_Crypto_ErrCode doTestSm4Ecb(); -OH_Crypto_ErrCode doTestSm4Cbc(); -OH_Crypto_ErrCode doTestSm4Gcm(); +/* + * 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 "CryptoArchitectureKit/crypto_common.h" + +OH_Crypto_ErrCode doTestSm4Ecb(); +OH_Crypto_ErrCode doTestSm4Cbc(); +OH_Crypto_ErrCode doTestSm4Gcm(); OH_Crypto_ErrCode doTestSm4GcmSeg(); \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_cbc_encryption_decryption.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_cbc_encryption_decryption.cpp old mode 100755 new mode 100644 index 366a53a790..dcd27349a1 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_cbc_encryption_decryption.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_cbc_encryption_decryption.cpp @@ -1,97 +1,97 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start crypt_decrypt_sm4_cbc] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" -#include -// [StartExclude crypt_decrypt_sm4_cbc] -#include "file.h" -// [EndExclude crypt_decrypt_sm4_cbc] - -OH_Crypto_ErrCode doTestSm4Cbc() -{ - OH_CryptoSymKeyGenerator *genCtx = nullptr; - OH_CryptoSymCipher *encCtx = nullptr; - OH_CryptoSymCipher *decCtx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - OH_CryptoSymCipherParams *params = nullptr; - Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; - - char *plainText = const_cast("this is test!"); - Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; - uint8_t iv[16] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4, 3, 1, 0, 10}; // iv使用安全随机数生成 - Crypto_DataBlob ivBlob = {.data = iv, .len = sizeof(iv)}; - // 生成对称密钥 - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("SM4_128", &genCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 设置参数 - ret = OH_CryptoSymCipherParams_Create(¶ms); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivBlob); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 加密 - ret = OH_CryptoSymCipher_Create("SM4_128|CBC|PKCS7", &encCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(encCtx, &msgBlob, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 解密 - ret = OH_CryptoSymCipher_Create("SM4_128|CBC|PKCS7", &decCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 资源释放 -end: - OH_CryptoSymCipherParams_Destroy(params); - OH_CryptoSymCipher_Destroy(encCtx); - OH_CryptoSymCipher_Destroy(decCtx); - OH_CryptoSymKeyGenerator_Destroy(genCtx); - OH_CryptoSymKey_Destroy(keyCtx); - OH_Crypto_FreeDataBlob(&outUpdate); - OH_Crypto_FreeDataBlob(&decUpdate); - return ret; -} -// [End crypt_decrypt_sm4_cbc] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start crypt_decrypt_sm4_cbc] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" +#include +// [StartExclude crypt_decrypt_sm4_cbc] +#include "file.h" +// [EndExclude crypt_decrypt_sm4_cbc] + +OH_Crypto_ErrCode doTestSm4Cbc() +{ + OH_CryptoSymKeyGenerator *genCtx = nullptr; + OH_CryptoSymCipher *encCtx = nullptr; + OH_CryptoSymCipher *decCtx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + OH_CryptoSymCipherParams *params = nullptr; + Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; + + char *plainText = const_cast("this is test!"); + Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; + uint8_t iv[16] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4, 3, 1, 0, 10}; // iv使用安全随机数生成 + Crypto_DataBlob ivBlob = {.data = iv, .len = sizeof(iv)}; + // 生成对称密钥 + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("SM4_128", &genCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 设置参数 + ret = OH_CryptoSymCipherParams_Create(¶ms); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivBlob); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 加密 + ret = OH_CryptoSymCipher_Create("SM4_128|CBC|PKCS7", &encCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(encCtx, &msgBlob, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 解密 + ret = OH_CryptoSymCipher_Create("SM4_128|CBC|PKCS7", &decCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 资源释放 +end: + OH_CryptoSymCipherParams_Destroy(params); + OH_CryptoSymCipher_Destroy(encCtx); + OH_CryptoSymCipher_Destroy(decCtx); + OH_CryptoSymKeyGenerator_Destroy(genCtx); + OH_CryptoSymKey_Destroy(keyCtx); + OH_Crypto_FreeDataBlob(&outUpdate); + OH_Crypto_FreeDataBlob(&decUpdate); + return ret; +} +// [End crypt_decrypt_sm4_cbc] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_ecb_encryption_decryption.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_ecb_encryption_decryption.cpp old mode 100755 new mode 100644 index 1031db9133..4aec3a3200 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_ecb_encryption_decryption.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_ecb_encryption_decryption.cpp @@ -1,89 +1,89 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start crypt_decrypt_sm4_ecb] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" -#include -// [StartExclude crypt_decrypt_sm4_ecb] -#include "file.h" -// [EndExclude crypt_decrypt_sm4_ecb] - -OH_Crypto_ErrCode doTestSm4Ecb() -{ - OH_CryptoSymKeyGenerator *genCtx = nullptr; - OH_CryptoSymCipher *encCtx = nullptr; - OH_CryptoSymCipher *decCtx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - OH_CryptoSymCipherParams *params = nullptr; - char *plainText = const_cast("this is test!"); - Crypto_DataBlob input = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; - Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; - - // 随机生成对称密钥 - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("SM4_128", &genCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - // 创建参数 - ret = OH_CryptoSymCipherParams_Create(¶ms); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 加密操作 - ret = OH_CryptoSymCipher_Create("SM4_128|ECB|PKCS7", &encCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(encCtx, &input, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 解密操作 - ret = OH_CryptoSymCipher_Create("SM4_128|ECB|PKCS7", &decCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - // 释放资源 -end: - OH_CryptoSymCipherParams_Destroy(params); - OH_CryptoSymCipher_Destroy(encCtx); - OH_CryptoSymCipher_Destroy(decCtx); - OH_CryptoSymKeyGenerator_Destroy(genCtx); - OH_CryptoSymKey_Destroy(keyCtx); - OH_Crypto_FreeDataBlob(&outUpdate); - OH_Crypto_FreeDataBlob(&decUpdate); - return ret; -} -// [End crypt_decrypt_sm4_ecb] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start crypt_decrypt_sm4_ecb] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" +#include +// [StartExclude crypt_decrypt_sm4_ecb] +#include "file.h" +// [EndExclude crypt_decrypt_sm4_ecb] + +OH_Crypto_ErrCode doTestSm4Ecb() +{ + OH_CryptoSymKeyGenerator *genCtx = nullptr; + OH_CryptoSymCipher *encCtx = nullptr; + OH_CryptoSymCipher *decCtx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + OH_CryptoSymCipherParams *params = nullptr; + char *plainText = const_cast("this is test!"); + Crypto_DataBlob input = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; + Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; + + // 随机生成对称密钥 + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("SM4_128", &genCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + // 创建参数 + ret = OH_CryptoSymCipherParams_Create(¶ms); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 加密操作 + ret = OH_CryptoSymCipher_Create("SM4_128|ECB|PKCS7", &encCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(encCtx, &input, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 解密操作 + ret = OH_CryptoSymCipher_Create("SM4_128|ECB|PKCS7", &decCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + // 释放资源 +end: + OH_CryptoSymCipherParams_Destroy(params); + OH_CryptoSymCipher_Destroy(encCtx); + OH_CryptoSymCipher_Destroy(decCtx); + OH_CryptoSymKeyGenerator_Destroy(genCtx); + OH_CryptoSymKey_Destroy(keyCtx); + OH_Crypto_FreeDataBlob(&outUpdate); + OH_Crypto_FreeDataBlob(&decUpdate); + return ret; +} +// [End crypt_decrypt_sm4_ecb] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_gcm_encryption_decryption.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_gcm_encryption_decryption.cpp old mode 100755 new mode 100644 index 1811c13a19..875841d78c --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_gcm_encryption_decryption.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_gcm_encryption_decryption.cpp @@ -1,120 +1,120 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start crypt_decrypt_sm4_gcm] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" -#include -// [StartExclude crypt_decrypt_sm4_gcm] -#include "file.h" -// [EndExclude crypt_decrypt_sm4_gcm] - -OH_Crypto_ErrCode doTestSm4Gcm() -{ - OH_CryptoSymKeyGenerator *genCtx = nullptr; - OH_CryptoSymCipher *encCtx = nullptr; - OH_CryptoSymCipher *decCtx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - OH_CryptoSymCipherParams *params = nullptr; - - Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; - - uint8_t aad[8] = {1, 2, 3, 4, 5, 6, 7, 8}; - uint8_t tag[16] = {0}; - uint8_t iv[12] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4}; // iv使用安全随机数生成 - Crypto_DataBlob ivData = {.data = iv, .len = sizeof(iv)}; - Crypto_DataBlob aadData = {.data = aad, .len = sizeof(aad)}; - Crypto_DataBlob tagData = {.data = tag, .len = sizeof(tag)}; - Crypto_DataBlob tagOutPut = {.data = nullptr, .len = 0}; - char *plainText = const_cast("this is test!"); - Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; - // 生成对称密钥 - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("SM4_128", &genCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 设置参数 - ret = OH_CryptoSymCipherParams_Create(¶ms); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivData); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_AAD_DATABLOB, &aadData); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagData); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 加密 - ret = OH_CryptoSymCipher_Create("SM4_128|GCM|PKCS7", &encCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Update(encCtx, &msgBlob, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(encCtx, nullptr, &tagOutPut); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 解密 - ret = OH_CryptoSymCipher_Create("SM4_128|GCM|PKCS7", &decCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagOutPut); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 释放资源 -end: - OH_CryptoSymCipherParams_Destroy(params); - OH_CryptoSymCipher_Destroy(encCtx); - OH_CryptoSymCipher_Destroy(decCtx); - OH_CryptoSymKeyGenerator_Destroy(genCtx); - OH_CryptoSymKey_Destroy(keyCtx); - OH_Crypto_FreeDataBlob(&outUpdate); - OH_Crypto_FreeDataBlob(&decUpdate); - OH_Crypto_FreeDataBlob(&tagOutPut); - return ret; -} -// [End crypt_decrypt_sm4_gcm] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start crypt_decrypt_sm4_gcm] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" +#include +// [StartExclude crypt_decrypt_sm4_gcm] +#include "file.h" +// [EndExclude crypt_decrypt_sm4_gcm] + +OH_Crypto_ErrCode doTestSm4Gcm() +{ + OH_CryptoSymKeyGenerator *genCtx = nullptr; + OH_CryptoSymCipher *encCtx = nullptr; + OH_CryptoSymCipher *decCtx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + OH_CryptoSymCipherParams *params = nullptr; + + Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; + + uint8_t aad[8] = {1, 2, 3, 4, 5, 6, 7, 8}; + uint8_t tag[16] = {0}; + uint8_t iv[12] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4}; // iv使用安全随机数生成 + Crypto_DataBlob ivData = {.data = iv, .len = sizeof(iv)}; + Crypto_DataBlob aadData = {.data = aad, .len = sizeof(aad)}; + Crypto_DataBlob tagData = {.data = tag, .len = sizeof(tag)}; + Crypto_DataBlob tagOutPut = {.data = nullptr, .len = 0}; + char *plainText = const_cast("this is test!"); + Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; + // 生成对称密钥 + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("SM4_128", &genCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 设置参数 + ret = OH_CryptoSymCipherParams_Create(¶ms); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivData); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_AAD_DATABLOB, &aadData); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagData); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 加密 + ret = OH_CryptoSymCipher_Create("SM4_128|GCM|PKCS7", &encCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Update(encCtx, &msgBlob, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(encCtx, nullptr, &tagOutPut); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 解密 + ret = OH_CryptoSymCipher_Create("SM4_128|GCM|PKCS7", &decCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagOutPut); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(decCtx, &outUpdate, &decUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 释放资源 +end: + OH_CryptoSymCipherParams_Destroy(params); + OH_CryptoSymCipher_Destroy(encCtx); + OH_CryptoSymCipher_Destroy(decCtx); + OH_CryptoSymKeyGenerator_Destroy(genCtx); + OH_CryptoSymKey_Destroy(keyCtx); + OH_Crypto_FreeDataBlob(&outUpdate); + OH_Crypto_FreeDataBlob(&decUpdate); + OH_Crypto_FreeDataBlob(&tagOutPut); + return ret; +} +// [End crypt_decrypt_sm4_gcm] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_gcm_seg_encryption_decryption.cpp b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_gcm_seg_encryption_decryption.cpp old mode 100755 new mode 100644 index 6635d2ab25..4f4952621b --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_gcm_seg_encryption_decryption.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/cpp/types/project/sm4_gcm_seg_encryption_decryption.cpp @@ -1,144 +1,144 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start crypt_decrypt_sm4_gcm_seg] -#include -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_cipher.h" - -#define OH_CRYPTO_GCM_TAG_LEN 16 -#define OH_CRYPTO_MAX_TEST_DATA_LEN 128 - -OH_Crypto_ErrCode doTestSm4GcmSeg() -{ - OH_CryptoSymKeyGenerator *genCtx = nullptr; - OH_CryptoSymCipher *encCtx = nullptr; - OH_CryptoSymCipher *decCtx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - OH_CryptoSymCipherParams *params = nullptr; - - char *plainText = const_cast("aaaaa.....bbbbb.....ccccc.....ddddd.....eee"); - Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; - uint8_t aad[8] = {1, 2, 3, 4, 5, 6, 7, 8}; - uint8_t tagArr[16] = {0}; - uint8_t iv[12] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4}; // iv使用安全随机数生成 - Crypto_DataBlob tag = {.data = nullptr, .len = 0}; - Crypto_DataBlob ivBlob = {.data = iv, .len = sizeof(iv)}; - Crypto_DataBlob aadBlob = {.data = aad, .len = sizeof(aad)}; - Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; - Crypto_DataBlob tagInit = {.data = tagArr, .len = sizeof(tagArr)}; - int32_t cipherLen = 0; - int blockSize = 20; - int32_t randomLen = strlen(plainText); - int cnt = randomLen / blockSize; - int rem = randomLen % blockSize; - uint8_t cipherText[OH_CRYPTO_MAX_TEST_DATA_LEN] = {0}; - Crypto_DataBlob cipherBlob; - - // 生成密钥 - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("SM4_128", &genCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 设置参数 - ret = OH_CryptoSymCipherParams_Create(¶ms); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivBlob); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_AAD_DATABLOB, &aadBlob); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagInit); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 加密 - ret = OH_CryptoSymCipher_Create("SM4_128|GCM|PKCS7", &encCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - for (int i = 0; i < cnt; i++) { - msgBlob.len = blockSize; - ret = OH_CryptoSymCipher_Update(encCtx, &msgBlob, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - msgBlob.data += blockSize; - memcpy(&cipherText[cipherLen], outUpdate.data, outUpdate.len); - cipherLen += outUpdate.len; - } - if (rem > 0) { - msgBlob.len = rem; - ret = OH_CryptoSymCipher_Update(encCtx, (Crypto_DataBlob *)&msgBlob, &outUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - memcpy(&cipherText[cipherLen], outUpdate.data, outUpdate.len); - cipherLen += outUpdate.len; - } - ret = OH_CryptoSymCipher_Final(encCtx, nullptr, &tag); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - - // 解密 - cipherBlob = {.data = reinterpret_cast(cipherText), .len = (size_t)cipherLen}; - msgBlob.data -= strlen(plainText) - rem; - msgBlob.len = strlen(plainText); - ret = OH_CryptoSymCipher_Create("SM4_128|GCM|PKCS7", &decCtx); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tag); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); - if (ret != CRYPTO_SUCCESS) { - goto end; - } - ret = OH_CryptoSymCipher_Final(decCtx, &cipherBlob, &decUpdate); - if (ret != CRYPTO_SUCCESS) { - goto end; - } -end: - OH_CryptoSymCipherParams_Destroy(params); - OH_CryptoSymCipher_Destroy(encCtx); - OH_CryptoSymCipher_Destroy(decCtx); - OH_CryptoSymKeyGenerator_Destroy(genCtx); - OH_CryptoSymKey_Destroy(keyCtx); - OH_Crypto_FreeDataBlob(&outUpdate); - OH_Crypto_FreeDataBlob(&tag); - OH_Crypto_FreeDataBlob(&decUpdate); - return ret; -} -// [End crypt_decrypt_sm4_gcm_seg] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start crypt_decrypt_sm4_gcm_seg] +#include +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_cipher.h" + +#define OH_CRYPTO_GCM_TAG_LEN 16 +#define OH_CRYPTO_MAX_TEST_DATA_LEN 128 + +OH_Crypto_ErrCode doTestSm4GcmSeg() +{ + OH_CryptoSymKeyGenerator *genCtx = nullptr; + OH_CryptoSymCipher *encCtx = nullptr; + OH_CryptoSymCipher *decCtx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + OH_CryptoSymCipherParams *params = nullptr; + + char *plainText = const_cast("aaaaa.....bbbbb.....ccccc.....ddddd.....eee"); + Crypto_DataBlob msgBlob = {.data = (uint8_t *)(plainText), .len = strlen(plainText)}; + uint8_t aad[8] = {1, 2, 3, 4, 5, 6, 7, 8}; + uint8_t tagArr[16] = {0}; + uint8_t iv[12] = {1, 2, 4, 12, 3, 4, 2, 3, 3, 2, 0, 4}; // iv使用安全随机数生成 + Crypto_DataBlob tag = {.data = nullptr, .len = 0}; + Crypto_DataBlob ivBlob = {.data = iv, .len = sizeof(iv)}; + Crypto_DataBlob aadBlob = {.data = aad, .len = sizeof(aad)}; + Crypto_DataBlob outUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob decUpdate = {.data = nullptr, .len = 0}; + Crypto_DataBlob tagInit = {.data = tagArr, .len = sizeof(tagArr)}; + int32_t cipherLen = 0; + int blockSize = 20; + int32_t randomLen = strlen(plainText); + int cnt = randomLen / blockSize; + int rem = randomLen % blockSize; + uint8_t cipherText[OH_CRYPTO_MAX_TEST_DATA_LEN] = {0}; + Crypto_DataBlob cipherBlob; + + // 生成密钥 + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("SM4_128", &genCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymKeyGenerator_Generate(genCtx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 设置参数 + ret = OH_CryptoSymCipherParams_Create(¶ms); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_IV_DATABLOB, &ivBlob); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_AAD_DATABLOB, &aadBlob); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tagInit); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 加密 + ret = OH_CryptoSymCipher_Create("SM4_128|GCM|PKCS7", &encCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(encCtx, CRYPTO_ENCRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + for (int i = 0; i < cnt; i++) { + msgBlob.len = blockSize; + ret = OH_CryptoSymCipher_Update(encCtx, &msgBlob, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + msgBlob.data += blockSize; + memcpy(&cipherText[cipherLen], outUpdate.data, outUpdate.len); + cipherLen += outUpdate.len; + } + if (rem > 0) { + msgBlob.len = rem; + ret = OH_CryptoSymCipher_Update(encCtx, (Crypto_DataBlob *)&msgBlob, &outUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + memcpy(&cipherText[cipherLen], outUpdate.data, outUpdate.len); + cipherLen += outUpdate.len; + } + ret = OH_CryptoSymCipher_Final(encCtx, nullptr, &tag); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + + // 解密 + cipherBlob = {.data = reinterpret_cast(cipherText), .len = (size_t)cipherLen}; + msgBlob.data -= strlen(plainText) - rem; + msgBlob.len = strlen(plainText); + ret = OH_CryptoSymCipher_Create("SM4_128|GCM|PKCS7", &decCtx); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipherParams_SetParam(params, CRYPTO_TAG_DATABLOB, &tag); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Init(decCtx, CRYPTO_DECRYPT_MODE, keyCtx, params); + if (ret != CRYPTO_SUCCESS) { + goto end; + } + ret = OH_CryptoSymCipher_Final(decCtx, &cipherBlob, &decUpdate); + if (ret != CRYPTO_SUCCESS) { + goto end; + } +end: + OH_CryptoSymCipherParams_Destroy(params); + OH_CryptoSymCipher_Destroy(encCtx); + OH_CryptoSymCipher_Destroy(decCtx); + OH_CryptoSymKeyGenerator_Destroy(genCtx); + OH_CryptoSymKey_Destroy(keyCtx); + OH_Crypto_FreeDataBlob(&outUpdate); + OH_Crypto_FreeDataBlob(&tag); + OH_Crypto_FreeDataBlob(&decUpdate); + return ret; +} +// [End crypt_decrypt_sm4_gcm_seg] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index b26a323c41..e138da64e6 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', err.message ?? ''); - 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'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', err.message ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 2e6219c69b..25fe92595b --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/ets/pages/Index.ets @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'EncryptionDecryptionGuidanceSM4'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(24) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_ecb')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testSm4Ecb(); - this.message = 'SM4_ECBSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_sm4_cbc')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testSm4Cbc(); - this.message = 'SM4_CBCSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_sm4_gcm')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testSm4Gcm(); - this.message = 'SM4_GCMSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_sm4_gcm_seg')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testSm4GcmSeg(); - this.message = 'SM4_GCM_SEGSuccess Result:' + ret.toString(); - }) - } - .width('100%') - .height('100%') - } -} +/* + * 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 { + @State message: string = 'EncryptionDecryptionGuidanceSM4'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(24) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm4_ecb')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testSm4Ecb(); + this.message = 'SM4_ECBSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_sm4_cbc')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testSm4Cbc(); + this.message = 'SM4_CBCSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_sm4_gcm')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testSm4Gcm(); + this.message = 'SM4_GCMSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_sm4_gcm_seg')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testSm4GcmSeg(); + this.message = 'SM4_GCM_SEGSuccess Result:' + ret.toString(); + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceSM4.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceSM4.test.ets old mode 100755 new mode 100644 index 820fdccd4e..9edb09d835 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceSM4.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidanceSM4.test.ets @@ -1,100 +1,100 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function encryptionDecryptionGuidanceSM4Test() { - describe('encryptionDecryptionGuidanceSM4Test', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用SM4对称密钥(ECB模式)加解密(C/C++) - */ - it('testEncryptionDecryptionGuidanceSM4001', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceSM4001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call SM4_ECB')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_ECBSuccess Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceSM4001 end'); - }) - - /** - * 点击按钮,使用SM4对称密钥(CBC模式)加解密(C/C++) - */ - it('testEncryptionDecryptionGuidanceSM4002', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceSM4002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call SM4_CBC')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_CBCSuccess Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceSM4002 end'); - }) - - /** - * 点击按钮,使用SM4对称密钥(GCM模式)加解密(C/C++) - */ - it('testEncryptionDecryptionGuidanceSM4003', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceSM4003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call SM4_GCM')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_GCMSuccess Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceSM4003 end'); - }) - - /** - * 点击按钮,使用SM4对称密钥(GCM模式)分段加解密(C/C++) - */ - it('testEncryptionDecryptionGuidanceSM4004', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceSM4004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call SM4_GCM_SEG')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_GCM_SEGSuccess Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceSM4004 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function encryptionDecryptionGuidanceSM4Test() { + describe('encryptionDecryptionGuidanceSM4Test', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用SM4对称密钥(ECB模式)加解密(C/C++) + */ + it('testEncryptionDecryptionGuidanceSM4001', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceSM4001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call SM4_ECB')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_ECBSuccess Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceSM4001 end'); + }) + + /** + * 点击按钮,使用SM4对称密钥(CBC模式)加解密(C/C++) + */ + it('testEncryptionDecryptionGuidanceSM4002', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceSM4002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call SM4_CBC')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_CBCSuccess Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceSM4002 end'); + }) + + /** + * 点击按钮,使用SM4对称密钥(GCM模式)加解密(C/C++) + */ + it('testEncryptionDecryptionGuidanceSM4003', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceSM4003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call SM4_GCM')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_GCMSuccess Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceSM4003 end'); + }) + + /** + * 点击按钮,使用SM4对称密钥(GCM模式)分段加解密(C/C++) + */ + it('testEncryptionDecryptionGuidanceSM4004', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceSM4004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call SM4_GCM_SEG')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_GCM_SEGSuccess Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceSM4004 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/ohosTest.md old mode 100755 new mode 100644 index 33d470b6d1..8bb265dabd --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/ohosTest.md @@ -1,11 +1,11 @@ -# 使用SM4对称密钥加解密(C/C++)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用SM4对称密钥(ECB模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM4对称密钥(CBC模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM4对称密钥(GCM模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 使用SM4对称密钥加解密(C/C++)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用SM4对称密钥(ECB模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM4对称密钥(CBC模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM4对称密钥(GCM模式)加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用SM4对称密钥(GCM模式)分段加解密(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/screenshots/EncryptionDecryptionGuidanceSM41.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/screenshots/EncryptionDecryptionGuidanceSM41.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/screenshots/EncryptionDecryptionGuidanceSM42.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4/screenshots/EncryptionDecryptionGuidanceSM42.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/app.json5 old mode 100755 new mode 100644 index 0ad16de397..294445e445 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/app.json5 @@ -1,25 +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.encryptiondecryptionguidancesm4arkts", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.encryptiondecryptionguidancesm4arkts", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index deda2c228b..6f3ea08d13 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "EncryptionDecryptionGuidanceSM4ArkTs" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "EncryptionDecryptionGuidanceSM4ArkTs" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/README.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/README.md old mode 100755 new mode 100644 index c75536b69d..158426a44f --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/README.md @@ -1,82 +1,82 @@ -# 使用SM4对称密钥加解密(ArkTS) - -### 介绍 - -本示例主要展示了使用SM4对称密钥(ECB模式)加解密(ArkTS)、使用SM4对称密钥(CBC模式)加解密(ArkTS)、使用SM4对称密钥(GCM模式)加解密(ArkTS)、使用SM4对称密钥(GCM模式)分段加解密(ArkTS)场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用SM4对称密钥(ECB模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-ecb.md) -- [使用SM4对称密钥(CBC模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-cbc.md) -- [使用SM4对称密钥(GCM模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-gcm.md) -- [使用SM4对称密钥(GCM模式)分段加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-gcm-by-segment.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例EncryptionDecryptionGuidanceSM4ArkTs.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用SM4对称密钥加解密(ArkTS)示例代码 - │ │ ├── sm4_cbc_encryption_decryption - │ │ | ├── sm4_cbc_encryption_decryption_asynchronous.ets - │ │ | ├── sm4_cbc_encryption_decryption_synchronous.ets - │ │ ├── sm4_ecb_encryption_decryption - │ │ | ├── sm4_ecb_encryption_decryption_asynchronous.ets - │ │ | ├── sm4_ecb_encryption_decryption_synchronous.ets - │ │ ├── sm4_gcm_encryption_decryption - │ │ | ├── sm4_gcm_encryption_decryption_asynchronous.ets - │ │ | ├── sm4_gcm_encryption_decryption_synchronous.ets - │ │ ├── sm4_gcm_seg_encryption_decryption - │ │ | ├── sm4_gcm_seg_encryption_decryption_asynchronous.ets - │ │ | ├── sm4_gcm_seg_encryption_decryption_synchronous.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── EncryptionDecryptionGuidanceSM4ArkTs.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 使用SM4对称密钥加解密(ArkTS) + +### 介绍 + +本示例主要展示了使用SM4对称密钥(ECB模式)加解密(ArkTS)、使用SM4对称密钥(CBC模式)加解密(ArkTS)、使用SM4对称密钥(GCM模式)加解密(ArkTS)、使用SM4对称密钥(GCM模式)分段加解密(ArkTS)场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用SM4对称密钥(ECB模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-ecb.md) +- [使用SM4对称密钥(CBC模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-cbc.md) +- [使用SM4对称密钥(GCM模式)加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-gcm.md) +- [使用SM4对称密钥(GCM模式)分段加解密(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm4-sym-encrypt-decrypt-gcm-by-segment.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例EncryptionDecryptionGuidanceSM4ArkTs.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用SM4对称密钥加解密(ArkTS)示例代码 + │ │ ├── sm4_cbc_encryption_decryption + │ │ | ├── sm4_cbc_encryption_decryption_asynchronous.ets + │ │ | ├── sm4_cbc_encryption_decryption_synchronous.ets + │ │ ├── sm4_ecb_encryption_decryption + │ │ | ├── sm4_ecb_encryption_decryption_asynchronous.ets + │ │ | ├── sm4_ecb_encryption_decryption_synchronous.ets + │ │ ├── sm4_gcm_encryption_decryption + │ │ | ├── sm4_gcm_encryption_decryption_asynchronous.ets + │ │ | ├── sm4_gcm_encryption_decryption_synchronous.ets + │ │ ├── sm4_gcm_seg_encryption_decryption + │ │ | ├── sm4_gcm_seg_encryption_decryption_asynchronous.ets + │ │ | ├── sm4_gcm_seg_encryption_decryption_synchronous.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── EncryptionDecryptionGuidanceSM4ArkTs.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs > .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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_cbc_encryption_decryption/sm4_cbc_encryption_decryption_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_cbc_encryption_decryption/sm4_cbc_encryption_decryption_asynchronous.ets old mode 100755 new mode 100644 index 20fef92877..20d8296d94 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_cbc_encryption_decryption/sm4_cbc_encryption_decryption_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_cbc_encryption_decryption/sm4_cbc_encryption_decryption_asynchronous.ets @@ -1,103 +1,103 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start async_symmetry_encrypt_decrypt_sm4_cbc] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genIvParamsSpec() { - let ivBlob = generateRandom(16); // 16 bytes - let ivParamsSpec: cryptoFramework.IvParamsSpec = { - algName: 'IvParamsSpec', - iv: ivBlob - }; - return ivParamsSpec; -} - -let iv = genIvParamsSpec(); - -// 加密消息 -async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('SM4_128|CBC|PKCS7'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, iv); - let encryptData = await cipher.doFinal(plainText); - return encryptData; -} - -// 解密消息 -async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('SM4_128|CBC|PKCS7'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, iv); - let decryptData = await decoder.doFinal(cipherText); - return decryptData; -} - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let symGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); - let symKey = await symGenerator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function main() { - try { - let keyData = new Uint8Array([7, 154, 52, 176, 4, 236, 150, 43, 237, 9, 145, 166, 141, 174, 224, 131]); - let symKey = await genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessagePromise(symKey, plainText); - let decryptText = await decryptMessagePromise(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } - } catch (error) { - console.error(`SM4 “${error}“, error code: ${error.code}`); - } -} -// [End async_symmetry_encrypt_decrypt_sm4_cbc] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_cbc_asynchronous')) - .width('70%') - .onClick(async () => { - try { - await main(); - this.message = 'SM4_CBCSuccess'; - } catch { - this.message = 'SM4_CBCFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start async_symmetry_encrypt_decrypt_sm4_cbc] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function generateRandom(len: number) { + let rand = cryptoFramework.createRandom(); + let generateRandSync = rand.generateRandomSync(len); + return generateRandSync; +} + +function genIvParamsSpec() { + let ivBlob = generateRandom(16); // 16 bytes + let ivParamsSpec: cryptoFramework.IvParamsSpec = { + algName: 'IvParamsSpec', + iv: ivBlob + }; + return ivParamsSpec; +} + +let iv = genIvParamsSpec(); + +// 加密消息 +async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('SM4_128|CBC|PKCS7'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, iv); + let encryptData = await cipher.doFinal(plainText); + return encryptData; +} + +// 解密消息 +async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('SM4_128|CBC|PKCS7'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, iv); + let decryptData = await decoder.doFinal(cipherText); + return decryptData; +} + +async function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let symGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); + let symKey = await symGenerator.convertKey(symKeyBlob); + console.info('convertKey success'); + return symKey; +} + +async function main() { + try { + let keyData = new Uint8Array([7, 154, 52, 176, 4, 236, 150, 43, 237, 9, 145, 166, 141, 174, 224, 131]); + let symKey = await genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await encryptMessagePromise(symKey, plainText); + let decryptText = await decryptMessagePromise(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } + } catch (error) { + console.error(`SM4 “${error}“, error code: ${error.code}`); + } +} +// [End async_symmetry_encrypt_decrypt_sm4_cbc] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm4_cbc_asynchronous')) + .width('70%') + .onClick(async () => { + try { + await main(); + this.message = 'SM4_CBCSuccess'; + } catch { + this.message = 'SM4_CBCFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_cbc_encryption_decryption/sm4_cbc_encryption_decryption_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_cbc_encryption_decryption/sm4_cbc_encryption_decryption_synchronous.ets old mode 100755 new mode 100644 index 4f2ba41c80..a59d5e8de3 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_cbc_encryption_decryption/sm4_cbc_encryption_decryption_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_cbc_encryption_decryption/sm4_cbc_encryption_decryption_synchronous.ets @@ -1,103 +1,103 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start sync_symmetry_encrypt_decrypt_sm4_cbc] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genIvParamsSpec() { - let ivBlob = generateRandom(16); // 16 bytes - let ivParamsSpec: cryptoFramework.IvParamsSpec = { - algName: 'IvParamsSpec', - iv: ivBlob - }; - return ivParamsSpec; -} - -let iv = genIvParamsSpec(); - -// 加密消息 -function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('SM4_128|CBC|PKCS7'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, iv); - let encryptData = cipher.doFinalSync(plainText); - return encryptData; -} - -// 解密消息 -function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('SM4_128|CBC|PKCS7'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, iv); - let decryptData = decoder.doFinalSync(cipherText); - return decryptData; -} - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let symGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); - let symKey = symGenerator.convertKeySync(symKeyBlob); - console.info('convertKeySync success'); - return symKey; -} - -function main() { - try { - let keyData = new Uint8Array([7, 154, 52, 176, 4, 236, 150, 43, 237, 9, 145, 166, 141, 174, 224, 131]); - let symKey = genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessage(symKey, plainText); - let decryptText = decryptMessage(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } - } catch (error) { - console.error(`SM4 “${error}“, error code: ${error.code}`); - } -} -// [End sync_symmetry_encrypt_decrypt_sm4_cbc] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_cbc_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'SM4_CBCSuccess'; - } catch { - this.message = 'SM4_CBCFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start sync_symmetry_encrypt_decrypt_sm4_cbc] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function generateRandom(len: number) { + let rand = cryptoFramework.createRandom(); + let generateRandSync = rand.generateRandomSync(len); + return generateRandSync; +} + +function genIvParamsSpec() { + let ivBlob = generateRandom(16); // 16 bytes + let ivParamsSpec: cryptoFramework.IvParamsSpec = { + algName: 'IvParamsSpec', + iv: ivBlob + }; + return ivParamsSpec; +} + +let iv = genIvParamsSpec(); + +// 加密消息 +function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('SM4_128|CBC|PKCS7'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, iv); + let encryptData = cipher.doFinalSync(plainText); + return encryptData; +} + +// 解密消息 +function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('SM4_128|CBC|PKCS7'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, iv); + let decryptData = decoder.doFinalSync(cipherText); + return decryptData; +} + +function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let symGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); + let symKey = symGenerator.convertKeySync(symKeyBlob); + console.info('convertKeySync success'); + return symKey; +} + +function main() { + try { + let keyData = new Uint8Array([7, 154, 52, 176, 4, 236, 150, 43, 237, 9, 145, 166, 141, 174, 224, 131]); + let symKey = genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = encryptMessage(symKey, plainText); + let decryptText = decryptMessage(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } + } catch (error) { + console.error(`SM4 “${error}“, error code: ${error.code}`); + } +} +// [End sync_symmetry_encrypt_decrypt_sm4_cbc] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm4_cbc_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'SM4_CBCSuccess'; + } catch { + this.message = 'SM4_CBCFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_ecb_encryption_decryption/sm4_ecb_encryption_decryption_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_ecb_encryption_decryption/sm4_ecb_encryption_decryption_asynchronous.ets old mode 100755 new mode 100644 index 3b24ee43ce..e250e992a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_ecb_encryption_decryption/sm4_ecb_encryption_decryption_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_ecb_encryption_decryption/sm4_ecb_encryption_decryption_asynchronous.ets @@ -1,82 +1,82 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start async_symmetry_encrypt_decrypt_sm4] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 加密消息 -async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('SM4_128|ECB|PKCS7'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); - let encryptData = await cipher.doFinal(plainText); - return encryptData; -} - -// 解密消息 -async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('SM4_128|ECB|PKCS7'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); - let decryptData = await decoder.doFinal(cipherText); - return decryptData; -} - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let symGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); - let symKey = await symGenerator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function main() { - let keyData = new Uint8Array([7, 154, 52, 176, 4, 236, 150, 43, 237, 9, 145, 166, 141, 174, 224, 131]); - let symKey = await genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessagePromise(symKey, plainText); - let decryptText = await decryptMessagePromise(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End async_symmetry_encrypt_decrypt_sm4] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_ecb_asynchronous')) - .width('70%') - .onClick(async () => { - try { - await main(); - this.message = 'SM4_ECBSuccess'; - } catch { - this.message = 'SM4_ECBFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start async_symmetry_encrypt_decrypt_sm4] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 加密消息 +async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('SM4_128|ECB|PKCS7'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); + let encryptData = await cipher.doFinal(plainText); + return encryptData; +} + +// 解密消息 +async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('SM4_128|ECB|PKCS7'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); + let decryptData = await decoder.doFinal(cipherText); + return decryptData; +} + +async function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let symGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); + let symKey = await symGenerator.convertKey(symKeyBlob); + console.info('convertKey success'); + return symKey; +} + +async function main() { + let keyData = new Uint8Array([7, 154, 52, 176, 4, 236, 150, 43, 237, 9, 145, 166, 141, 174, 224, 131]); + let symKey = await genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await encryptMessagePromise(symKey, plainText); + let decryptText = await decryptMessagePromise(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} +// [End async_symmetry_encrypt_decrypt_sm4] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm4_ecb_asynchronous')) + .width('70%') + .onClick(async () => { + try { + await main(); + this.message = 'SM4_ECBSuccess'; + } catch { + this.message = 'SM4_ECBFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_ecb_encryption_decryption/sm4_ecb_encryption_decryption_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_ecb_encryption_decryption/sm4_ecb_encryption_decryption_synchronous.ets old mode 100755 new mode 100644 index 912041ec50..615d9d6545 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_ecb_encryption_decryption/sm4_ecb_encryption_decryption_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_ecb_encryption_decryption/sm4_ecb_encryption_decryption_synchronous.ets @@ -1,82 +1,82 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start sync_symmetry_encrypt_decrypt_sm4] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 加密消息 -function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('SM4_128|ECB|PKCS7'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); - let encryptData = cipher.doFinalSync(plainText); - return encryptData; -} - -// 解密消息 -function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('SM4_128|ECB|PKCS7'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); - let decryptData = decoder.doFinalSync(cipherText); - return decryptData; -} - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let symGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); - let symKey = symGenerator.convertKeySync(symKeyBlob); - console.info('convertKeySync success'); - return symKey; -} - -function main() { - let keyData = new Uint8Array([7, 154, 52, 176, 4, 236, 150, 43, 237, 9, 145, 166, 141, 174, 224, 131]); - let symKey = genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessage(symKey, plainText); - let decryptText = decryptMessage(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End sync_symmetry_encrypt_decrypt_sm4] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_ecb_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'SM4_ECBSuccess'; - } catch { - this.message = 'SM4_ECBFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start sync_symmetry_encrypt_decrypt_sm4] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 加密消息 +function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('SM4_128|ECB|PKCS7'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null); + let encryptData = cipher.doFinalSync(plainText); + return encryptData; +} + +// 解密消息 +function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('SM4_128|ECB|PKCS7'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null); + let decryptData = decoder.doFinalSync(cipherText); + return decryptData; +} + +function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let symGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); + let symKey = symGenerator.convertKeySync(symKeyBlob); + console.info('convertKeySync success'); + return symKey; +} + +function main() { + let keyData = new Uint8Array([7, 154, 52, 176, 4, 236, 150, 43, 237, 9, 145, 166, 141, 174, 224, 131]); + let symKey = genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = encryptMessage(symKey, plainText); + let decryptText = decryptMessage(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} +// [End sync_symmetry_encrypt_decrypt_sm4] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm4_ecb_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'SM4_ECBSuccess'; + } catch { + this.message = 'SM4_ECBFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_asynchronous.ets old mode 100755 new mode 100644 index fc6d4372cf..e5a4de1e01 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_asynchronous.ets @@ -1,117 +1,117 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start async_symmetry_encrypt_decrypt_sm4_gcm] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genGcmParamsSpec() { - let ivBlob = generateRandom(12); // 12 bytes - let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes - let dataAad = new Uint8Array(arr); - let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; - arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes - let dataTag = new Uint8Array(arr); - let tagBlob: cryptoFramework.DataBlob = { - data: dataTag - }; - // GCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 - let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { - iv: ivBlob, - aad: aadBlob, - authTag: tagBlob, - algName: 'GcmParamsSpec' - }; - return gcmParamsSpec; -} - -let gcmParams = genGcmParamsSpec(); - -// 加密消息 -async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); - let encryptUpdate = await cipher.update(plainText); - // gcm模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 - gcmParams.authTag = await cipher.doFinal(null); - return encryptUpdate; -} - -// 解密消息 -async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); - let decryptUpdate = await decoder.update(cipherText); - // gcm模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 - let decryptData = await decoder.doFinal(null); - if (decryptData == null) { - console.info('GCM decrypt success, decryptData is null'); - } - return decryptUpdate; -} - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let sm4Generator = cryptoFramework.createSymKeyGenerator('SM4_128'); - let symKey = await sm4Generator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function main() { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = await genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessagePromise(symKey, plainText); - let decryptText = await decryptMessagePromise(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End async_symmetry_encrypt_decrypt_sm4_gcm] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_gcm_asynchronous')) - .width('70%') - .onClick(async() => { - try { - await main(); - this.message = 'SM4_GCMSuccess'; - } catch { - this.message = 'SM4_GCMFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start async_symmetry_encrypt_decrypt_sm4_gcm] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function generateRandom(len: number) { + let rand = cryptoFramework.createRandom(); + let generateRandSync = rand.generateRandomSync(len); + return generateRandSync; +} + +function genGcmParamsSpec() { + let ivBlob = generateRandom(12); // 12 bytes + let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes + let dataAad = new Uint8Array(arr); + let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; + arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes + let dataTag = new Uint8Array(arr); + let tagBlob: cryptoFramework.DataBlob = { + data: dataTag + }; + // GCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 + let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { + iv: ivBlob, + aad: aadBlob, + authTag: tagBlob, + algName: 'GcmParamsSpec' + }; + return gcmParamsSpec; +} + +let gcmParams = genGcmParamsSpec(); + +// 加密消息 +async function encryptMessagePromise(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); + await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); + let encryptUpdate = await cipher.update(plainText); + // gcm模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 + gcmParams.authTag = await cipher.doFinal(null); + return encryptUpdate; +} + +// 解密消息 +async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); + await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); + let decryptUpdate = await decoder.update(cipherText); + // gcm模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 + let decryptData = await decoder.doFinal(null); + if (decryptData == null) { + console.info('GCM decrypt success, decryptData is null'); + } + return decryptUpdate; +} + +async function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let sm4Generator = cryptoFramework.createSymKeyGenerator('SM4_128'); + let symKey = await sm4Generator.convertKey(symKeyBlob); + console.info('convertKey success'); + return symKey; +} + +async function main() { + let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); + let symKey = await genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = await encryptMessagePromise(symKey, plainText); + let decryptText = await decryptMessagePromise(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} +// [End async_symmetry_encrypt_decrypt_sm4_gcm] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm4_gcm_asynchronous')) + .width('70%') + .onClick(async() => { + try { + await main(); + this.message = 'SM4_GCMSuccess'; + } catch { + this.message = 'SM4_GCMFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_synchronous.ets old mode 100755 new mode 100644 index 06f7badc93..1ccef7bec4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_synchronous.ets @@ -1,117 +1,117 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start sync_symmetry_encrypt_decrypt_sm4_gcm] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genGcmParamsSpec() { - let ivBlob = generateRandom(12); // 12 bytes - let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes - let dataAad = new Uint8Array(arr); - let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; - arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes - let dataTag = new Uint8Array(arr); - let tagBlob: cryptoFramework.DataBlob = { - data: dataTag - }; - // GCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 - let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { - iv: ivBlob, - aad: aadBlob, - authTag: tagBlob, - algName: 'GcmParamsSpec' - }; - return gcmParamsSpec; -} - -let gcmParams = genGcmParamsSpec(); - -// 加密消息 -function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); - let encryptUpdate = cipher.updateSync(plainText); - // gcm模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 - gcmParams.authTag = cipher.doFinalSync(null); - return encryptUpdate; -} - -// 解密消息 -function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); - let decryptUpdate = decoder.updateSync(cipherText); - // gcm模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 - let decryptData = decoder.doFinalSync(null); - if (decryptData == null) { - console.info('GCM decrypt success, decryptData is null'); - } - return decryptUpdate; -} - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let sm4Generator = cryptoFramework.createSymKeyGenerator('SM4_128'); - let symKey = sm4Generator.convertKeySync(symKeyBlob); - console.info('convertKeySync success'); - return symKey; -} - -function main() { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = genSymKeyByData(keyData); - let message = 'This is a test'; - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessage(symKey, plainText); - let decryptText = decryptMessage(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End sync_symmetry_encrypt_decrypt_sm4_gcm] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_gcm_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'SM4_GCMSuccess'; - } catch { - this.message = 'SM4_GCMFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start sync_symmetry_encrypt_decrypt_sm4_gcm] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function generateRandom(len: number) { + let rand = cryptoFramework.createRandom(); + let generateRandSync = rand.generateRandomSync(len); + return generateRandSync; +} + +function genGcmParamsSpec() { + let ivBlob = generateRandom(12); // 12 bytes + let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes + let dataAad = new Uint8Array(arr); + let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; + arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes + let dataTag = new Uint8Array(arr); + let tagBlob: cryptoFramework.DataBlob = { + data: dataTag + }; + // GCM的authTag在加密时从doFinal结果中获取,在解密时填入init函数的params参数中 + let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { + iv: ivBlob, + aad: aadBlob, + authTag: tagBlob, + algName: 'GcmParamsSpec' + }; + return gcmParamsSpec; +} + +let gcmParams = genGcmParamsSpec(); + +// 加密消息 +function encryptMessage(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { + let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); + cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); + let encryptUpdate = cipher.updateSync(plainText); + // gcm模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 + gcmParams.authTag = cipher.doFinalSync(null); + return encryptUpdate; +} + +// 解密消息 +function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { + let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); + decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); + let decryptUpdate = decoder.updateSync(cipherText); + // gcm模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 + let decryptData = decoder.doFinalSync(null); + if (decryptData == null) { + console.info('GCM decrypt success, decryptData is null'); + } + return decryptUpdate; +} + +function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let sm4Generator = cryptoFramework.createSymKeyGenerator('SM4_128'); + let symKey = sm4Generator.convertKeySync(symKeyBlob); + console.info('convertKeySync success'); + return symKey; +} + +function main() { + let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); + let symKey = genSymKeyByData(keyData); + let message = 'This is a test'; + let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; + let encryptText = encryptMessage(symKey, plainText); + let decryptText = decryptMessage(symKey, encryptText); + if (plainText.data.toString() === decryptText.data.toString()) { + console.info('decrypt ok'); + console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); + } else { + console.error('decrypt failed'); + } +} +// [End sync_symmetry_encrypt_decrypt_sm4_gcm] + +@Entry +@Component +struct Index { + @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm4_gcm_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'SM4_GCMSuccess'; + } catch { + this.message = 'SM4_GCMFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_seg_encryption_decryption/sm4_gcm_seg_encryption_decryption_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_seg_encryption_decryption/sm4_gcm_seg_encryption_decryption_asynchronous.ets deleted file mode 100755 index 32394d2e53..0000000000 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_seg_encryption_decryption/sm4_gcm_seg_encryption_decryption_asynchronous.ets +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start async_symmetry_encrypt_decrypt_sm4_gcm_seg] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genGcmParamsSpec() { - let ivBlob = generateRandom(12); - let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes - let dataAad = new Uint8Array(arr); - let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; - arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes - let dataTag = new Uint8Array(arr); - let tagBlob: cryptoFramework.DataBlob = { - data: dataTag - }; // The GCM authTag is obtained by doFinal() in encryption and passed in params of init() in decryption. - let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { - iv: ivBlob, - aad: aadBlob, - authTag: tagBlob, - algName: 'GcmParamsSpec' - }; - return gcmParamsSpec; -} - -let gcmParams = genGcmParamsSpec(); - -// 分段加密消息 -async function encryptMessageUpdateBySegment(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); - await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - let cipherText = new Uint8Array(); - for (let i = 0; i < plainText.data.length; i += updateLength) { - let updateMessage = plainText.data.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - let updateOutput = await cipher.update(updateMessageBlob); - // 把update的结果拼接起来,得到密文(有些情况下还需拼接doFinal的结果,这取决于分组模式 - // 和填充模式,本例中GCM模式的doFinal结果只包含authTag而不含密文,所以不需要拼接) - let mergeText = new Uint8Array(cipherText.length + updateOutput.data.length); - mergeText.set(cipherText); - mergeText.set(updateOutput.data, cipherText.length); - cipherText = mergeText; - } - gcmParams.authTag = await cipher.doFinal(null); - let cipherBlob: cryptoFramework.DataBlob = { data: cipherText }; - return cipherBlob; -} - -// 分段解密消息 -async function decryptMessagePromise(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); - await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - let decryptText = new Uint8Array(); - for (let i = 0; i < cipherText.data.length; i += updateLength) { - let updateMessage = cipherText.data.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - let updateOutput = await decoder.update(updateMessageBlob); - // 把update的结果拼接起来,得到明文 - let mergeText = new Uint8Array(decryptText.length + updateOutput.data.length); - mergeText.set(decryptText); - mergeText.set(updateOutput.data, decryptText.length); - decryptText = mergeText; - } - let decryptData = await decoder.doFinal(null); - if (decryptData == null) { - console.info('GCM decrypt success, decryptData is null'); - } - let decryptBlob: cryptoFramework.DataBlob = { data: decryptText }; - return decryptBlob; -} - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let sm4Generator = cryptoFramework.createSymKeyGenerator('SM4_128'); - let symKey = await sm4Generator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function sm4() { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = await genSymKeyByData(keyData); - let message = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; // 假设信息总共43字节,根据utf-8解码后,也是43字节 - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = await encryptMessageUpdateBySegment(symKey, plainText); - let decryptText = await decryptMessagePromise(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End async_symmetry_encrypt_decrypt_sm4_gcm_seg] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_gcm_segmentation_asynchronous')) - .width('70%') - .onClick(async () => { - try { - await sm4(); - this.message = 'SM4_GCMSegmentationSuccess'; - } catch { - this.message = 'SM4_GCMSegmentationFail'; - } - }) - } - .height('100%') - .width('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_seg_encryption_decryption/sm4_gcm_seg_encryption_decryption_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_seg_encryption_decryption/sm4_gcm_seg_encryption_decryption_synchronous.ets deleted file mode 100755 index 1b59b325c6..0000000000 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_seg_encryption_decryption/sm4_gcm_seg_encryption_decryption_synchronous.ets +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start sync_symmetry_encrypt_decrypt_sm4_gcm_seg] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function generateRandom(len: number) { - let rand = cryptoFramework.createRandom(); - let generateRandSync = rand.generateRandomSync(len); - return generateRandSync; -} - -function genGcmParamsSpec() { - let ivBlob = generateRandom(12); // 12 bytes - let arr = [1, 2, 3, 4, 5, 6, 7, 8]; // 8 bytes - let dataAad = new Uint8Array(arr); - let aadBlob: cryptoFramework.DataBlob = { data: dataAad }; - arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 16 bytes - let dataTag = new Uint8Array(arr); - let tagBlob: cryptoFramework.DataBlob = { - data: dataTag - }; // The GCM authTag is obtained by doFinal() in encryption and passed in params of init() in decryption. - let gcmParamsSpec: cryptoFramework.GcmParamsSpec = { - iv: ivBlob, - aad: aadBlob, - authTag: tagBlob, - algName: 'GcmParamsSpec' - }; - return gcmParamsSpec; -} - -let gcmParams = genGcmParamsSpec(); - -// 分段加密消息 -function encryptMessageUpdateBySegment(symKey: cryptoFramework.SymKey, plainText: cryptoFramework.DataBlob) { - let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); - cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - let cipherText = new Uint8Array(); - for (let i = 0; i < plainText.data.length; i += updateLength) { - let updateMessage = plainText.data.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - let updateOutput = cipher.updateSync(updateMessageBlob); - // 把update的结果拼接起来,得到密文(有些情况下还需拼接doFinal的结果,这取决于分组模式 - // 和填充模式,本例中GCM模式的doFinal结果只包含authTag而不含密文,所以不需要拼接) - let mergeText = new Uint8Array(cipherText.length + updateOutput.data.length); - mergeText.set(cipherText); - mergeText.set(updateOutput.data, cipherText.length); - cipherText = mergeText; - } - gcmParams.authTag = cipher.doFinalSync(null); - let cipherBlob: cryptoFramework.DataBlob = { data: cipherText }; - return cipherBlob; -} - -// 分段解密消息 -function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) { - let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); - decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - let decryptText = new Uint8Array(); - for (let i = 0; i < cipherText.data.length; i += updateLength) { - let updateMessage = cipherText.data.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - let updateOutput = decoder.updateSync(updateMessageBlob); - // 把update的结果拼接起来,得到明文 - let mergeText = new Uint8Array(decryptText.length + updateOutput.data.length); - mergeText.set(decryptText); - mergeText.set(updateOutput.data, decryptText.length); - decryptText = mergeText; - } - let decryptData = decoder.doFinalSync(null); - if (decryptData == null) { - console.info('GCM decrypt success, decryptData is null'); - } - let decryptBlob: cryptoFramework.DataBlob = { data: decryptText }; - return decryptBlob; -} - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let sm4Generator = cryptoFramework.createSymKeyGenerator('SM4_128'); - let symKey = sm4Generator.convertKeySync(symKeyBlob); - console.info('convertKeySync success'); - return symKey; -} - -function main() { - let keyData = new Uint8Array([83, 217, 231, 76, 28, 113, 23, 219, 250, 71, 209, 210, 205, 97, 32, 159]); - let symKey = genSymKeyByData(keyData); - let message = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; // 假设信息总共43字节,根据utf-8解码后,也是43字节 - let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }; - let encryptText = encryptMessageUpdateBySegment(symKey, plainText); - let decryptText = decryptMessage(symKey, encryptText); - if (plainText.data.toString() === decryptText.data.toString()) { - console.info('decrypt ok'); - console.info('decrypt plainText: ' + buffer.from(decryptText.data).toString('utf-8')); - } else { - console.error('decrypt failed'); - } -} -// [End sync_symmetry_encrypt_decrypt_sm4_gcm_seg] - -@Entry -@Component -struct Index { - @State message: string = 'Encryption Decryption Guidance SM4 ArkTs'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_gcm_segmentation_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'SM4_GCMSegmentationSuccess'; - } catch { - this.message = 'SM4_GCMSegmentationFail'; - } - }) - } - .height('100%') - .width('100%') - } -} \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidance3DESArkTs.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidance3DESArkTs.test.ets old mode 100755 new mode 100644 index 8a1013fd00..822fd08aa6 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidance3DESArkTs.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/EncryptionDecryptionGuidance3DESArkTs.test.ets @@ -1,188 +1,188 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function encryptionDecryptionGuidance3DESArkTsTest() { - describe('encryptionDecryptionGuidance3DESArkTsTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用SM4对称密钥(ECB模式)加解密(ArkTS),异步方法 - */ - it('testEncryptionDecryptionGuidance3DESArkTs001', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('sm4_cbc_encryption_decryption_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM4_CBC Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_CBCSuccess')); - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM4对称密钥(ECB模式)加解密(ArkTS),同步方法 - */ - it('testEncryptionDecryptionGuidance3DESArkTs002', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('sm4_cbc_encryption_decryption_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM4_CBC Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_CBCSuccess')); - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM4对称密钥(CBC模式)加解密(ArkTS),异步方法 - */ - it('testEncryptionDecryptionGuidance3DESArkTs003', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('sm4_ecb_encryption_decryption_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM4_ECB Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_ECBSuccess')); - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM4对称密钥(CBC模式)加解密(ArkTS),同步方法 - */ - it('testEncryptionDecryptionGuidance3DESArkTs004', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('sm4_ecb_encryption_decryption_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM4_ECB Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_ECBSuccess')); - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs004 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM4对称密钥(GCM模式)加解密(ArkTS),异步方法 - */ - it('testEncryptionDecryptionGuidance3DESArkTs005', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('sm4_gcm_encryption_decryption_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM4_GCM Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_GCMSuccess')); - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs005 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM4对称密钥(GCM模式)加解密(ArkTS),同步方法 - */ - it('testEncryptionDecryptionGuidance3DESArkTs006', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs006 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('sm4_gcm_encryption_decryption_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM4_GCM Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_GCMSuccess')); - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs006 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM4对称密钥(GCM模式)分段加解密(ArkTS),异步方法 - */ - it('testEncryptionDecryptionGuidance3DESArkTs007', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs007 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('sm4_gcm_seg_encryption_decryption_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM4_GCM Segmentation Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_GCMSegmentationSuccess')); - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs007 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM4对称密钥(GCM模式)分段加解密(ArkTS),同步方法 - */ - it('testEncryptionDecryptionGuidance3DESArkTs008', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs008 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('sm4_gcm_seg_encryption_decryption_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM4_GCM Segmentation Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4_GCMSegmentationSuccess')); - console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs008 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function encryptionDecryptionGuidance3DESArkTsTest() { + describe('encryptionDecryptionGuidance3DESArkTsTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用SM4对称密钥(ECB模式)加解密(ArkTS),异步方法 + */ + it('testEncryptionDecryptionGuidance3DESArkTs001', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('sm4_cbc_encryption_decryption_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM4_CBC Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_CBCSuccess')); + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM4对称密钥(ECB模式)加解密(ArkTS),同步方法 + */ + it('testEncryptionDecryptionGuidance3DESArkTs002', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('sm4_cbc_encryption_decryption_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM4_CBC Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_CBCSuccess')); + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM4对称密钥(CBC模式)加解密(ArkTS),异步方法 + */ + it('testEncryptionDecryptionGuidance3DESArkTs003', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('sm4_ecb_encryption_decryption_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM4_ECB Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_ECBSuccess')); + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM4对称密钥(CBC模式)加解密(ArkTS),同步方法 + */ + it('testEncryptionDecryptionGuidance3DESArkTs004', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('sm4_ecb_encryption_decryption_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM4_ECB Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_ECBSuccess')); + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs004 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM4对称密钥(GCM模式)加解密(ArkTS),异步方法 + */ + it('testEncryptionDecryptionGuidance3DESArkTs005', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('sm4_gcm_encryption_decryption_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM4_GCM Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_GCMSuccess')); + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs005 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM4对称密钥(GCM模式)加解密(ArkTS),同步方法 + */ + it('testEncryptionDecryptionGuidance3DESArkTs006', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs006 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('sm4_gcm_encryption_decryption_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM4_GCM Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_GCMSuccess')); + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs006 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM4对称密钥(GCM模式)分段加解密(ArkTS),异步方法 + */ + it('testEncryptionDecryptionGuidance3DESArkTs007', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs007 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('sm4_gcm_seg_encryption_decryption_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM4_GCM Segmentation Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_GCMSegmentationSuccess')); + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs007 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM4对称密钥(GCM模式)分段加解密(ArkTS),同步方法 + */ + it('testEncryptionDecryptionGuidance3DESArkTs008', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs008 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('sm4_gcm_seg_encryption_decryption_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM4_GCM Segmentation Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4_GCMSegmentationSuccess')); + console.info('uitest: testEncryptionDecryptionGuidance3DESArkTs008 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/ohosTest.md old mode 100755 new mode 100644 index fc78ff5f12..04e17dac5d --- a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/ohosTest.md @@ -1,15 +1,15 @@ -# 使用SM4对称密钥加解密(ArkTS)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用SM4对称密钥(ECB模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM4对称密钥(ECB模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM4对称密钥(CBC模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM4对称密钥(CBC模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM4对称密钥(GCM模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM4对称密钥(GCM模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM4对称密钥(GCM模式)分段加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 使用SM4对称密钥加解密(ArkTS)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用SM4对称密钥(ECB模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM4对称密钥(ECB模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM4对称密钥(CBC模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM4对称密钥(CBC模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM4对称密钥(GCM模式)加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM4对称密钥(GCM模式)加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM4对称密钥(GCM模式)分段加解密(ArkTS),异步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用SM4对称密钥(GCM模式)分段加解密(ArkTS),同步方法 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/screenshots/EncryptionDecryptionGuidanceSM4ArkTs1.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/screenshots/EncryptionDecryptionGuidanceSM4ArkTs1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/screenshots/EncryptionDecryptionGuidanceSM4ArkTs2.png b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/screenshots/EncryptionDecryptionGuidanceSM4ArkTs2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/app.json5 old mode 100755 new mode 100644 index 1cb30c06fa..02057bf087 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/app.json5 @@ -1,25 +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.hkdfderivation", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.hkdfderivation", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 76a0d27731..83ed1e5d1f --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "HKDFDerivation" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "HKDFDerivation" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/README.md old mode 100755 new mode 100644 index 72d1d39386..45da0eccbe --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/README.md @@ -1,70 +1,70 @@ -# 使用HKDF进行密钥派生 - -### 介绍 - -本示例主要展示了使用HKDF进行密钥派生通过await、Promis、同步返回场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用HKDF进行密钥派生](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-key-derivation-using-hkdf.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例HKDFDerivation.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用HKDF进行密钥派生示例代码 - │ │ ├── Await.ets - │ │ ├── Promise.ets - │ │ ├── Sync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── HKDFDerivation.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 使用HKDF进行密钥派生 + +### 介绍 + +本示例主要展示了使用HKDF进行密钥派生通过await、Promis、同步返回场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用HKDF进行密钥派生](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-key-derivation-using-hkdf.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例HKDFDerivation.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用HKDF进行密钥派生示例代码 + │ │ ├── Await.ets + │ │ ├── Promise.ets + │ │ ├── Sync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── HKDFDerivation.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation > .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/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Await.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Await.ets old mode 100755 new mode 100644 index 0f99919369..ba56487c34 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Await.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Await.ets @@ -1,59 +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. - */ - -// [Start use_hkdf_for_key_derivation_await] - -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -async function kdfAwait() { - let keyData = new Uint8Array(buffer.from('012345678901234567890123456789', 'utf-8').buffer); - let saltData = new Uint8Array(buffer.from('0123456789', 'utf-8').buffer); - let infoData = new Uint8Array(buffer.from('infostring', 'utf-8').buffer); - let spec: cryptoFramework.HKDFSpec = { - algName: 'HKDF', - key: keyData, - salt: saltData, - info: infoData, - keySize: 32 - }; - let kdf = cryptoFramework.createKdf('HKDF|SHA256|EXTRACT_AND_EXPAND'); - let secret = await kdf.generateSecret(spec); - console.info('key derivation output is ' + secret.data); -} -// [End use_hkdf_for_key_derivation_await] -@Entry -@Component -struct Index { - @State message: string = 'Await'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_await')) - .width('70%') - .onClick(async () => { - try { - await kdfAwait(); - this.message = 'Await Success'; - } catch { - this.message = 'Await Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start use_hkdf_for_key_derivation_await] + +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +async function kdfAwait() { + let keyData = new Uint8Array(buffer.from('012345678901234567890123456789', 'utf-8').buffer); + let saltData = new Uint8Array(buffer.from('0123456789', 'utf-8').buffer); + let infoData = new Uint8Array(buffer.from('infostring', 'utf-8').buffer); + let spec: cryptoFramework.HKDFSpec = { + algName: 'HKDF', + key: keyData, + salt: saltData, + info: infoData, + keySize: 32 + }; + let kdf = cryptoFramework.createKdf('HKDF|SHA256|EXTRACT_AND_EXPAND'); + let secret = await kdf.generateSecret(spec); + console.info('key derivation output is ' + secret.data); +} +// [End use_hkdf_for_key_derivation_await] +@Entry +@Component +struct Index { + @State message: string = 'Await'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_await')) + .width('70%') + .onClick(async () => { + try { + await kdfAwait(); + this.message = 'Await Success'; + } catch { + this.message = 'Await Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Promise.ets old mode 100755 new mode 100644 index 59080c5cb3..0dc16a07a5 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Promise.ets @@ -1,65 +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. - */ - -// [Start use_hkdf_for_key_derivation_promise] - -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { buffer } from '@kit.ArkTS'; - -function kdfPromise() { - let keyData = new Uint8Array(buffer.from('012345678901234567890123456789', 'utf-8').buffer); - let saltData = new Uint8Array(buffer.from('0123456789', 'utf-8').buffer); - let infoData = new Uint8Array(buffer.from('infostring', 'utf-8').buffer); - let spec: cryptoFramework.HKDFSpec = { - algName: 'HKDF', - key: keyData, - salt: saltData, - info: infoData, - keySize: 32 - }; - let kdf = cryptoFramework.createKdf('HKDF|SHA256|EXTRACT_AND_EXPAND'); - let kdfPromise = kdf.generateSecret(spec); - kdfPromise.then((secret) => { - console.info('key derivation output is ' + secret.data); - }).catch((error: BusinessError) => { - console.error('key derivation error.'); - }); -} - -// [End use_hkdf_for_key_derivation_promise] -@Entry -@Component -struct Index { - @State message: string = 'Promise'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_promise')) - .width('70%') - .onClick(() => { - try { - kdfPromise(); - this.message = 'Promise Success'; - } catch { - this.message = 'Promise Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start use_hkdf_for_key_derivation_promise] + +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { buffer } from '@kit.ArkTS'; + +function kdfPromise() { + let keyData = new Uint8Array(buffer.from('012345678901234567890123456789', 'utf-8').buffer); + let saltData = new Uint8Array(buffer.from('0123456789', 'utf-8').buffer); + let infoData = new Uint8Array(buffer.from('infostring', 'utf-8').buffer); + let spec: cryptoFramework.HKDFSpec = { + algName: 'HKDF', + key: keyData, + salt: saltData, + info: infoData, + keySize: 32 + }; + let kdf = cryptoFramework.createKdf('HKDF|SHA256|EXTRACT_AND_EXPAND'); + let kdfPromise = kdf.generateSecret(spec); + kdfPromise.then((secret) => { + console.info('key derivation output is ' + secret.data); + }).catch((error: BusinessError) => { + console.error('key derivation error.'); + }); +} + +// [End use_hkdf_for_key_derivation_promise] +@Entry +@Component +struct Index { + @State message: string = 'Promise'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_promise')) + .width('70%') + .onClick(() => { + try { + kdfPromise(); + this.message = 'Promise Success'; + } catch { + this.message = 'Promise Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Sync.ets old mode 100755 new mode 100644 index 87e344284c..40001e2437 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Sync.ets @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start use_hkdf_for_key_derivation_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function kdfSync() { - let keyData = new Uint8Array(buffer.from('012345678901234567890123456789', 'utf-8').buffer); - let saltData = new Uint8Array(buffer.from('0123456789', 'utf-8').buffer); - let infoData = new Uint8Array(buffer.from('infostring', 'utf-8').buffer); - let spec: cryptoFramework.HKDFSpec = { - algName: 'HKDF', - key: keyData, - salt: saltData, - info: infoData, - keySize: 32 - }; - let kdf = cryptoFramework.createKdf('HKDF|SHA256|EXTRACT_AND_EXPAND'); - let secret = kdf.generateSecretSync(spec); - console.info('[Sync]key derivation output is ' + secret.data); -} - -// [End use_hkdf_for_key_derivation_sync] -@Entry -@Component -struct Index { - @State message: string = 'Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sync')) - .width('70%') - .onClick(() => { - try { - kdfSync(); - this.message = 'Sync Success'; - } catch { - this.message = 'Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start use_hkdf_for_key_derivation_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function kdfSync() { + let keyData = new Uint8Array(buffer.from('012345678901234567890123456789', 'utf-8').buffer); + let saltData = new Uint8Array(buffer.from('0123456789', 'utf-8').buffer); + let infoData = new Uint8Array(buffer.from('infostring', 'utf-8').buffer); + let spec: cryptoFramework.HKDFSpec = { + algName: 'HKDF', + key: keyData, + salt: saltData, + info: infoData, + keySize: 32 + }; + let kdf = cryptoFramework.createKdf('HKDF|SHA256|EXTRACT_AND_EXPAND'); + let secret = kdf.generateSecretSync(spec); + console.info('[Sync]key derivation output is ' + secret.data); +} + +// [End use_hkdf_for_key_derivation_sync] +@Entry +@Component +struct Index { + @State message: string = 'Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sync')) + .width('70%') + .onClick(() => { + try { + kdfSync(); + this.message = 'Sync Success'; + } catch { + this.message = 'Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/HKDFDerivation.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/HKDFDerivation.test.ets old mode 100755 new mode 100644 index 3a243a0a37..8506514c41 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/HKDFDerivation.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/HKDFDerivation.test.ets @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function hKDFDerivationTest() { - describe('hKDFDerivationTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用HKDF进行密钥派生,通过await返回结果 - */ - it('testHKDFDerivation001', 0, async () => { - console.info('uitest: testHKDFDerivation001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Await')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Await')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Await Success')); - console.info('uitest: testHKDFDerivation001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用HKDF进行密钥派生,通过Promise返回结果 - */ - it('testHKDFDerivation002', 0, async () => { - console.info('uitest: testHKDFDerivation002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Promise')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Promise')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Promise Success')); - console.info('uitest: testHKDFDerivation002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用HKDF进行密钥派生,通过同步方式返回结果 - */ - it('testHKDFDerivation003', 0, async () => { - console.info('uitest: testHKDFDerivation003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Sync Success')); - console.info('uitest: testHKDFDerivation003 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function hKDFDerivationTest() { + describe('hKDFDerivationTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用HKDF进行密钥派生,通过await返回结果 + */ + it('testHKDFDerivation001', 0, async () => { + console.info('uitest: testHKDFDerivation001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Await')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Await')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Await Success')); + console.info('uitest: testHKDFDerivation001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用HKDF进行密钥派生,通过Promise返回结果 + */ + it('testHKDFDerivation002', 0, async () => { + console.info('uitest: testHKDFDerivation002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Promise')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Promise')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Promise Success')); + console.info('uitest: testHKDFDerivation002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用HKDF进行密钥派生,通过同步方式返回结果 + */ + it('testHKDFDerivation003', 0, async () => { + console.info('uitest: testHKDFDerivation003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Sync Success')); + console.info('uitest: testHKDFDerivation003 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/ohosTest.md old mode 100755 new mode 100644 index 709ea03893..b60d8dee46 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/ohosTest.md @@ -1,10 +1,10 @@ -# 使用HKDF进行密钥派生测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用HKDF进行密钥派生,通过await返回结果 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用HKDF进行密钥派生,通过Promise返回结果 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 使用HKDF进行密钥派生测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用HKDF进行密钥派生,通过await返回结果 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用HKDF进行密钥派生,通过Promise返回结果 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用HKDF进行密钥派生,通过同步方式返回结果 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/screenshots/HKDFDerivation1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/screenshots/HKDFDerivation1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/screenshots/HKDFDerivation2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/screenshots/HKDFDerivation2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/app.json5 old mode 100755 new mode 100644 index c0f56cab0f..43ce254749 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/app.json5 @@ -1,25 +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.pbkdf2derivation", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.pbkdf2derivation", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index f1111d6343..1c4fc7b683 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "PBKDF2Derivation" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "PBKDF2Derivation" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/README.md old mode 100755 new mode 100644 index 2dd89e382f..dc9f804a39 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/README.md @@ -1,70 +1,70 @@ -# 使用PBKDF2进行密钥派生 - -### 介绍 - -本示例主要展示了使用PBKDF2进行密钥派生(通过await、Promise、同步方式返回结果)的场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用PBKDF2进行密钥派生](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-key-derivation-using-pbkdf2.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例PBKDF2Derivation.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用PBKDF2进行密钥派生示例代码 - │ │ ├── Await.ets - │ │ ├── Promise.ets - │ │ ├── Sync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── PBKDF2Derivation.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 使用PBKDF2进行密钥派生 + +### 介绍 + +本示例主要展示了使用PBKDF2进行密钥派生(通过await、Promise、同步方式返回结果)的场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用PBKDF2进行密钥派生](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-key-derivation-using-pbkdf2.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例PBKDF2Derivation.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用PBKDF2进行密钥派生示例代码 + │ │ ├── Await.ets + │ │ ├── Promise.ets + │ │ ├── Sync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── PBKDF2Derivation.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation > .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/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Await.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Await.ets old mode 100755 new mode 100644 index 4a23ae51e4..681864bef1 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Await.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Await.ets @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start use_pbkdf2_for_key_derivation_await] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -async function kdfAwait() { - let spec: cryptoFramework.PBKDF2Spec = { - algName: 'PBKDF2', - password: '123456', - salt: new Uint8Array(16), - iterations: 10000, - keySize: 32 - }; - let kdf = cryptoFramework.createKdf('PBKDF2|SHA256'); - let secret = await kdf.generateSecret(spec); - console.info('key derivation output is ' + secret.data); -} - -// [End use_pbkdf2_for_key_derivation_await] - -@Entry -@Component -struct Index { - @State message: string = 'Await'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_await')) - .width('70%') - .onClick(async () => { - try { - await kdfAwait(); - this.message = 'Await Success'; - } catch { - this.message = 'Await Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start use_pbkdf2_for_key_derivation_await] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +async function kdfAwait() { + let spec: cryptoFramework.PBKDF2Spec = { + algName: 'PBKDF2', + password: '123456', + salt: new Uint8Array(16), + iterations: 10000, + keySize: 32 + }; + let kdf = cryptoFramework.createKdf('PBKDF2|SHA256'); + let secret = await kdf.generateSecret(spec); + console.info('key derivation output is ' + secret.data); +} + +// [End use_pbkdf2_for_key_derivation_await] + +@Entry +@Component +struct Index { + @State message: string = 'Await'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_await')) + .width('70%') + .onClick(async () => { + try { + await kdfAwait(); + this.message = 'Await Success'; + } catch { + this.message = 'Await Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Promise.ets old mode 100755 new mode 100644 index 17b97190db..162be118f9 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Promise.ets @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start use_pbkdf2_for_key_derivation_promise] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -function kdfPromise() { - let spec: cryptoFramework.PBKDF2Spec = { - algName: 'PBKDF2', - password: '123456', - salt: new Uint8Array(16), - iterations: 10000, - keySize: 32 - }; - let kdf = cryptoFramework.createKdf('PBKDF2|SHA256'); - let kdfPromise = kdf.generateSecret(spec); - kdfPromise.then((secret) => { - console.info('key derivation output is ' + secret.data); - }).catch((error: BusinessError) => { - console.error('key derivation error.'); - }); -} -// [End use_pbkdf2_for_key_derivation_promise] -@Entry -@Component -struct Index { - @State message: string = 'Promise'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_promise')) - .width('70%') - .onClick(() => { - try { - kdfPromise(); - this.message = 'Promise Success'; - } catch { - this.message = 'Promise Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start use_pbkdf2_for_key_derivation_promise] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +function kdfPromise() { + let spec: cryptoFramework.PBKDF2Spec = { + algName: 'PBKDF2', + password: '123456', + salt: new Uint8Array(16), + iterations: 10000, + keySize: 32 + }; + let kdf = cryptoFramework.createKdf('PBKDF2|SHA256'); + let kdfPromise = kdf.generateSecret(spec); + kdfPromise.then((secret) => { + console.info('key derivation output is ' + secret.data); + }).catch((error: BusinessError) => { + console.error('key derivation error.'); + }); +} +// [End use_pbkdf2_for_key_derivation_promise] +@Entry +@Component +struct Index { + @State message: string = 'Promise'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_promise')) + .width('70%') + .onClick(() => { + try { + kdfPromise(); + this.message = 'Promise Success'; + } catch { + this.message = 'Promise Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Sync.ets old mode 100755 new mode 100644 index f259312c81..e2db20777a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Sync.ets @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start use_pbkdf2_for_key_derivation_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function kdfSync() { - let spec: cryptoFramework.PBKDF2Spec = { - algName: 'PBKDF2', - password: '123456', - salt: new Uint8Array(16), - iterations: 10000, - keySize: 32 - }; - let kdf = cryptoFramework.createKdf('PBKDF2|SHA256'); - let secret = kdf.generateSecretSync(spec); - console.info('[Sync]key derivation output is ' + secret.data); -} - -// [End use_pbkdf2_for_key_derivation_sync] -@Entry -@Component -struct Index { - @State message: string = 'Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sync')) - .width('70%') - .onClick(() => { - try { - kdfSync(); - this.message = 'Sync Success'; - } catch { - this.message = 'Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start use_pbkdf2_for_key_derivation_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function kdfSync() { + let spec: cryptoFramework.PBKDF2Spec = { + algName: 'PBKDF2', + password: '123456', + salt: new Uint8Array(16), + iterations: 10000, + keySize: 32 + }; + let kdf = cryptoFramework.createKdf('PBKDF2|SHA256'); + let secret = kdf.generateSecretSync(spec); + console.info('[Sync]key derivation output is ' + secret.data); +} + +// [End use_pbkdf2_for_key_derivation_sync] +@Entry +@Component +struct Index { + @State message: string = 'Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sync')) + .width('70%') + .onClick(() => { + try { + kdfSync(); + this.message = 'Sync Success'; + } catch { + this.message = 'Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/PBKDF2Derivation.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/PBKDF2Derivation.test.ets old mode 100755 new mode 100644 index 43d53397c9..e62d26ac0d --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/PBKDF2Derivation.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/ets/test/PBKDF2Derivation.test.ets @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function pBKDF2DerivationTest() { - describe('pBKDF2DerivationTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用PBKDF2进行密钥派生,通过await返回 - */ - it('testPBKDF2Derivation001', 0, async () => { - console.info('uitest: testPBKDF2Derivation001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Await')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Await')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Await Success')); - console.info('uitest: testPBKDF2Derivation001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用PBKDF2进行密钥派生,通过Promise返回 - */ - it('testPBKDF2Derivation002', 0, async () => { - console.info('uitest: testPBKDF2Derivation002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Promise')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Promise')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Promise Success')); - console.info('uitest: testPBKDF2Derivation002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用PBKDF2进行密钥派生,通过同步方式 - */ - it('testPBKDF2Derivation003', 0, async () => { - console.info('uitest: testPBKDF2Derivation003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Sync Success')); - console.info('uitest: testPBKDF2Derivation003 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function pBKDF2DerivationTest() { + describe('pBKDF2DerivationTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用PBKDF2进行密钥派生,通过await返回 + */ + it('testPBKDF2Derivation001', 0, async () => { + console.info('uitest: testPBKDF2Derivation001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Await')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Await')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Await Success')); + console.info('uitest: testPBKDF2Derivation001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用PBKDF2进行密钥派生,通过Promise返回 + */ + it('testPBKDF2Derivation002', 0, async () => { + console.info('uitest: testPBKDF2Derivation002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Promise')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Promise')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Promise Success')); + console.info('uitest: testPBKDF2Derivation002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用PBKDF2进行密钥派生,通过同步方式 + */ + it('testPBKDF2Derivation003', 0, async () => { + console.info('uitest: testPBKDF2Derivation003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Sync Success')); + console.info('uitest: testPBKDF2Derivation003 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/ohosTest.md old mode 100755 new mode 100644 index 9cbfdf11d4..96277ce9f2 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/ohosTest.md @@ -1,10 +1,10 @@ -# 使用PBKDF2进行密钥派生测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用PBKDF2进行密钥派生,通过await返回 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用PBKDF2进行密钥派生,通过Promise返回 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 使用PBKDF2进行密钥派生测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用PBKDF2进行密钥派生,通过await返回 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用PBKDF2进行密钥派生,通过Promise返回 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用PBKDF2进行密钥派生,通过同步方式 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/screenshots/PBKDF2Derivation1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/screenshots/PBKDF2Derivation1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/screenshots/PBKDF2Derivation2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/screenshots/PBKDF2Derivation2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/app.json5 old mode 100755 new mode 100644 index 600c7611c1..b086c9bbef --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/app.json5 @@ -1,25 +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.binarydataconvertasymmetrickeypair", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.binarydataconvertasymmetrickeypair", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 8464f1db0e..5c28c864ec --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "BinaryDataConvertAsymmetricKeyPair" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "BinaryDataConvertAsymmetricKeyPair" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/README.md old mode 100755 new mode 100644 index d4a1a4c537..9f2a479829 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/README.md @@ -1,81 +1,81 @@ -# 指定二进制数据转换非对称密钥对(C/C++) - -### 介绍 - -以RSA、ECC、SM2为例,根据指定的对称密钥二进制数据,生成非对称密钥对(OH_CryptoKeyPair),即将外部或存储的二进制数据转换为算法库的密钥对象,该对象可用于后续的加解密等操作。 - -本示例主要展示了指定二进制数据转换RSA密钥对、 指定二进制数据转换ECC密钥对、 指定二进制数据转换SM2密钥对的场景。该工程中展示的代码详细描述可查如下链接。 - -- [指定二进制数据转换非对称密钥对(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-binary-data-to-asym-key-pair-ndk.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例BinaryDataConvertAsymmetricKeyPair.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── ecc.cpp - │ │ | ├── file.h - │ │ | ├── rsa.cpp - │ │ | ├── sm2.cpp - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 指定二进制数据转换非对称密钥对(C/C++)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── BinaryDataConvertAsymmetricKeyPair.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 指定二进制数据转换非对称密钥对(C/C++) + +### 介绍 + +以RSA、ECC、SM2为例,根据指定的对称密钥二进制数据,生成非对称密钥对(OH_CryptoKeyPair),即将外部或存储的二进制数据转换为算法库的密钥对象,该对象可用于后续的加解密等操作。 + +本示例主要展示了指定二进制数据转换RSA密钥对、 指定二进制数据转换ECC密钥对、 指定二进制数据转换SM2密钥对的场景。该工程中展示的代码详细描述可查如下链接。 + +- [指定二进制数据转换非对称密钥对(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-binary-data-to-asym-key-pair-ndk.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例BinaryDataConvertAsymmetricKeyPair.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── ecc.cpp + │ │ | ├── file.h + │ │ | ├── rsa.cpp + │ │ | ├── sm2.cpp + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 指定二进制数据转换非对称密钥对(C/C++)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── BinaryDataConvertAsymmetricKeyPair.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 69dea61c94..2f818a9fc1 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(BinaryDataConvertAsymmetricKeyPair) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp types/project/ecc.cpp types/project/rsa.cpp types/project/sm2.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(BinaryDataConvertAsymmetricKeyPair) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp types/project/ecc.cpp types/project/rsa.cpp types/project/sm2.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 14fd46456a..83bb0807e7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp @@ -1,63 +1,63 @@ -/* - * 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 "types/project/file.h" - -static napi_value NAPI_Global_doTestDataCovertAsymKey(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestDataCovertAsymKey(), &ret); - return ret; -} - -static napi_value NAPI_Global_doAsymEccCovert(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doAsymEccCovert(), &ret); - return ret; -} - -static napi_value NAPI_Global_doAsymSm2Covert(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doAsymSm2Covert(), &ret); - return ret; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"doTestDataCovertAsymKey", nullptr, NAPI_Global_doTestDataCovertAsymKey, nullptr, nullptr, nullptr, - napi_default, nullptr}, - {"doAsymEccCovert", nullptr, NAPI_Global_doAsymEccCovert, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"doAsymSm2Covert", nullptr, NAPI_Global_doAsymSm2Covert, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/file.h" + +static napi_value NAPI_Global_doTestDataCovertAsymKey(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestDataCovertAsymKey(), &ret); + return ret; +} + +static napi_value NAPI_Global_doAsymEccCovert(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doAsymEccCovert(), &ret); + return ret; +} + +static napi_value NAPI_Global_doAsymSm2Covert(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doAsymSm2Covert(), &ret); + return ret; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"doTestDataCovertAsymKey", nullptr, NAPI_Global_doTestDataCovertAsymKey, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"doAsymEccCovert", nullptr, NAPI_Global_doAsymEccCovert, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"doAsymSm2Covert", nullptr, NAPI_Global_doAsymSm2Covert, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index 06af395920..195f2920de --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,20 +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. - */ - -export const doTestDataCovertAsymKey: () => number; - -export const doAsymEccCovert: () => number; - +/* + * 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 doTestDataCovertAsymKey: () => number; + +export const doAsymEccCovert: () => number; + export const doAsymSm2Covert: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/ecc.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/ecc.cpp old mode 100755 new mode 100644 index 0b6a75765b..6015a441af --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/ecc.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/ecc.cpp @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start convert_ecc_keypair] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_asym_key.h" -#include "file.h" - -OH_Crypto_ErrCode doAsymEccCovert() -{ - OH_CryptoAsymKeyGenerator *ctx = nullptr; - OH_Crypto_ErrCode ret; - - ret = OH_CryptoAsymKeyGenerator_Create("ECC256", &ctx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - - uint8_t ecc224PubKeyBlobData[] = {48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, - 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 157, 58, 248, 205, 95, - 171, 229, 33, 116, 44, 192, 12, 115, 119, 84, 156, 128, 56, 180, 246, 84, - 43, 33, 244, 224, 221, 181, 154, 155, 222, 157, 124, 131, 217, 214, 134, 199, - 155, 61, 196, 203, 107, 13, 227, 121, 57, 199, 109, 220, 103, 55, 78, 148, - 185, 226, 212, 162, 31, 66, 201, 50, 129, 1, 156}; - - uint8_t ecc224PriKeyBlobData[] = {48, 49, 2, 1, 1, 4, 32, 255, 121, 33, 196, 188, 159, 112, 149, 146, 107, - 243, 78, 152, 214, 12, 119, 87, 199, 207, 57, 116, 64, 150, 240, 121, 22, 88, - 138, 196, 71, 70, 222, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7}; - Crypto_DataBlob pubBlob = {.data = ecc224PubKeyBlobData, .len = sizeof(ecc224PubKeyBlobData)}; - Crypto_DataBlob priBlob = {.data = ecc224PriKeyBlobData, .len = sizeof(ecc224PriKeyBlobData)}; - - OH_CryptoKeyPair *dupKeyPair = nullptr; - ret = OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &pubBlob, &priBlob, &dupKeyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - return ret; - } - - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(dupKeyPair); - return ret; -} -// [End convert_ecc_keypair] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start convert_ecc_keypair] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_asym_key.h" +#include "file.h" + +OH_Crypto_ErrCode doAsymEccCovert() +{ + OH_CryptoAsymKeyGenerator *ctx = nullptr; + OH_Crypto_ErrCode ret; + + ret = OH_CryptoAsymKeyGenerator_Create("ECC256", &ctx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + + uint8_t ecc224PubKeyBlobData[] = {48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, + 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 157, 58, 248, 205, 95, + 171, 229, 33, 116, 44, 192, 12, 115, 119, 84, 156, 128, 56, 180, 246, 84, + 43, 33, 244, 224, 221, 181, 154, 155, 222, 157, 124, 131, 217, 214, 134, 199, + 155, 61, 196, 203, 107, 13, 227, 121, 57, 199, 109, 220, 103, 55, 78, 148, + 185, 226, 212, 162, 31, 66, 201, 50, 129, 1, 156}; + + uint8_t ecc224PriKeyBlobData[] = {48, 49, 2, 1, 1, 4, 32, 255, 121, 33, 196, 188, 159, 112, 149, 146, 107, + 243, 78, 152, 214, 12, 119, 87, 199, 207, 57, 116, 64, 150, 240, 121, 22, 88, + 138, 196, 71, 70, 222, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7}; + Crypto_DataBlob pubBlob = {.data = ecc224PubKeyBlobData, .len = sizeof(ecc224PubKeyBlobData)}; + Crypto_DataBlob priBlob = {.data = ecc224PriKeyBlobData, .len = sizeof(ecc224PriKeyBlobData)}; + + OH_CryptoKeyPair *dupKeyPair = nullptr; + ret = OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &pubBlob, &priBlob, &dupKeyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + return ret; + } + + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(dupKeyPair); + return ret; +} +// [End convert_ecc_keypair] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h old mode 100755 new mode 100644 index 7d25e73822..0ad709e296 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h @@ -1,24 +1,24 @@ -#ifndef FILE_H -#define FILE_H -/* - * 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 "CryptoArchitectureKit/crypto_common.h" - -OH_Crypto_ErrCode doTestDataCovertAsymKey(); -OH_Crypto_ErrCode doAsymEccCovert(); -OH_Crypto_ErrCode doAsymSm2Covert(); - +#ifndef FILE_H +#define FILE_H +/* + * 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 "CryptoArchitectureKit/crypto_common.h" + +OH_Crypto_ErrCode doTestDataCovertAsymKey(); +OH_Crypto_ErrCode doAsymEccCovert(); +OH_Crypto_ErrCode doAsymSm2Covert(); + #endif // FILE_H \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp old mode 100755 new mode 100644 index 92ce3d4351..eec6dd08b6 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start convert_rsa_keypair] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_asym_key.h" -#include "file.h" - -OH_Crypto_ErrCode doTestDataCovertAsymKey() -{ - OH_CryptoAsymKeyGenerator *ctx = nullptr; - OH_Crypto_ErrCode ret; - - ret = OH_CryptoAsymKeyGenerator_Create("RSA1024|PRIMES_2", &ctx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - - uint8_t rsaDatablob[] = {48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, - 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 235, 184, 151, 247, 130, 216, 140, - 187, 64, 124, 219, 137, 140, 184, 53, 137, 216, 105, 156, 141, 137, 165, 30, 80, 232, - 55, 96, 46, 23, 237, 197, 123, 121, 27, 240, 190, 14, 111, 237, 172, 67, 42, 47, - 164, 226, 248, 211, 157, 213, 194, 131, 109, 181, 41, 173, 217, 127, 252, 121, 126, 26, - 130, 55, 4, 134, 104, 73, 5, 132, 91, 214, 146, 232, 64, 99, 87, 33, 222, 155, - 159, 9, 59, 212, 144, 46, 183, 83, 89, 220, 189, 148, 13, 176, 5, 139, 156, 230, - 143, 16, 152, 79, 36, 8, 112, 40, 174, 35, 83, 82, 57, 137, 87, 123, 215, 99, - 199, 66, 131, 150, 31, 143, 56, 252, 2, 73, 41, 70, 159, 2, 3, 1, 0, 1}; - Crypto_DataBlob retBlob = {.data = rsaDatablob, .len = sizeof(rsaDatablob)}; - - OH_CryptoKeyPair *dupKeyPair = nullptr; - ret = OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &retBlob, nullptr, &dupKeyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - return ret; - } - - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(dupKeyPair); - return ret; -} -// [End convert_rsa_keypair] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start convert_rsa_keypair] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_asym_key.h" +#include "file.h" + +OH_Crypto_ErrCode doTestDataCovertAsymKey() +{ + OH_CryptoAsymKeyGenerator *ctx = nullptr; + OH_Crypto_ErrCode ret; + + ret = OH_CryptoAsymKeyGenerator_Create("RSA1024|PRIMES_2", &ctx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + + uint8_t rsaDatablob[] = {48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, + 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 235, 184, 151, 247, 130, 216, 140, + 187, 64, 124, 219, 137, 140, 184, 53, 137, 216, 105, 156, 141, 137, 165, 30, 80, 232, + 55, 96, 46, 23, 237, 197, 123, 121, 27, 240, 190, 14, 111, 237, 172, 67, 42, 47, + 164, 226, 248, 211, 157, 213, 194, 131, 109, 181, 41, 173, 217, 127, 252, 121, 126, 26, + 130, 55, 4, 134, 104, 73, 5, 132, 91, 214, 146, 232, 64, 99, 87, 33, 222, 155, + 159, 9, 59, 212, 144, 46, 183, 83, 89, 220, 189, 148, 13, 176, 5, 139, 156, 230, + 143, 16, 152, 79, 36, 8, 112, 40, 174, 35, 83, 82, 57, 137, 87, 123, 215, 99, + 199, 66, 131, 150, 31, 143, 56, 252, 2, 73, 41, 70, 159, 2, 3, 1, 0, 1}; + Crypto_DataBlob retBlob = {.data = rsaDatablob, .len = sizeof(rsaDatablob)}; + + OH_CryptoKeyPair *dupKeyPair = nullptr; + ret = OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &retBlob, nullptr, &dupKeyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + return ret; + } + + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(dupKeyPair); + return ret; +} +// [End convert_rsa_keypair] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/sm2.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/sm2.cpp old mode 100755 new mode 100644 index 9ba5c7e821..01652efd3d --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/sm2.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/cpp/types/project/sm2.cpp @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start convert_sm2_keypair] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_asym_key.h" -#include "file.h" - -OH_Crypto_ErrCode doAsymSm2Covert() -{ - OH_CryptoAsymKeyGenerator *ctx = nullptr; - OH_CryptoKeyPair *dupKeyPair = nullptr; - OH_Crypto_ErrCode ret; - - ret = OH_CryptoAsymKeyGenerator_Create("SM2_256", &ctx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - - uint8_t sm2PubKeyBlobData[] = {48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, - 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 157, 58, 248, 205, 95, - 171, 229, 33, 116, 44, 192, 12, 115, 119, 84, 156, 128, 56, 180, 246, 84, - 43, 33, 244, 224, 221, 181, 154, 155, 222, 157, 124, 131, 217, 214, 134, 199, - 155, 61, 196, 203, 107, 13, 227, 121, 57, 199, 109, 220, 103, 55, 78, 148, - 185, 226, 212, 162, 31, 66, 201, 50, 129, 1, 156}; - - uint8_t sm2PriKeyBlobData[] = {48, 49, 2, 1, 1, 4, 32, 255, 121, 33, 196, 188, 159, 112, 149, 146, 107, - 243, 78, 152, 214, 12, 119, 87, 199, 207, 57, 116, 64, 150, 240, 121, 22, 88, - 138, 196, 71, 70, 222, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7}; - Crypto_DataBlob pubBlob = {.data = sm2PubKeyBlobData, .len = sizeof(sm2PubKeyBlobData)}; - Crypto_DataBlob priBlob = {.data = sm2PriKeyBlobData, .len = sizeof(sm2PriKeyBlobData)}; - ret = OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &pubBlob, &priBlob, &dupKeyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - return ret; - } - - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(dupKeyPair); - return ret; -} -// [End convert_sm2_keypair] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start convert_sm2_keypair] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_asym_key.h" +#include "file.h" + +OH_Crypto_ErrCode doAsymSm2Covert() +{ + OH_CryptoAsymKeyGenerator *ctx = nullptr; + OH_CryptoKeyPair *dupKeyPair = nullptr; + OH_Crypto_ErrCode ret; + + ret = OH_CryptoAsymKeyGenerator_Create("SM2_256", &ctx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + + uint8_t sm2PubKeyBlobData[] = {48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, + 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 157, 58, 248, 205, 95, + 171, 229, 33, 116, 44, 192, 12, 115, 119, 84, 156, 128, 56, 180, 246, 84, + 43, 33, 244, 224, 221, 181, 154, 155, 222, 157, 124, 131, 217, 214, 134, 199, + 155, 61, 196, 203, 107, 13, 227, 121, 57, 199, 109, 220, 103, 55, 78, 148, + 185, 226, 212, 162, 31, 66, 201, 50, 129, 1, 156}; + + uint8_t sm2PriKeyBlobData[] = {48, 49, 2, 1, 1, 4, 32, 255, 121, 33, 196, 188, 159, 112, 149, 146, 107, + 243, 78, 152, 214, 12, 119, 87, 199, 207, 57, 116, 64, 150, 240, 121, 22, 88, + 138, 196, 71, 70, 222, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7}; + Crypto_DataBlob pubBlob = {.data = sm2PubKeyBlobData, .len = sizeof(sm2PubKeyBlobData)}; + Crypto_DataBlob priBlob = {.data = sm2PriKeyBlobData, .len = sizeof(sm2PriKeyBlobData)}; + ret = OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &pubBlob, &priBlob, &dupKeyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + return ret; + } + + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(dupKeyPair); + return ret; +} +// [End convert_sm2_keypair] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index a36ca588fe..965554bb3a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 4ed1e2a132..212c56b02d --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets @@ -1,50 +1,50 @@ -/* - * 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 { - @State message: string = 'BinaryDataConvertAsymmetricKeyPair'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.doTestDataCovertAsymKey(); - this.message = 'Call RSA Success Result:' + ret.toString(); - }) - Button($r('app.string.call_ecc')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.doAsymEccCovert(); - this.message = 'Call ECC Success Result:' + ret.toString(); - }) - Button($r('app.string.call_sm2')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.doAsymSm2Covert(); - this.message = 'Call SM2 Success Result:' + ret.toString(); - }) - } - .width('100%') - .height('100%') - } -} +/* + * 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 { + @State message: string = 'BinaryDataConvertAsymmetricKeyPair'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.doTestDataCovertAsymKey(); + this.message = 'Call RSA Success Result:' + ret.toString(); + }) + Button($r('app.string.call_ecc')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.doAsymEccCovert(); + this.message = 'Call ECC Success Result:' + ret.toString(); + }) + Button($r('app.string.call_sm2')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.doAsymSm2Covert(); + this.message = 'Call SM2 Success Result:' + ret.toString(); + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/BinaryDataConvertAsymmetricKeyPair.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/BinaryDataConvertAsymmetricKeyPair.test.ets old mode 100755 new mode 100644 index 9cc07e33f7..34b6b3ab20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/BinaryDataConvertAsymmetricKeyPair.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/BinaryDataConvertAsymmetricKeyPair.test.ets @@ -1,86 +1,86 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function binaryDataConvertAsymmetricKeyPairTest() { - describe('binaryDataConvertAsymmetricKeyPairTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,指定二进制数据转换RSA密钥对 - */ - it('testBinaryDataConvertAsymmetricKeyPair001', 0, async () => { - console.info('uitest: testBinaryDataConvertAsymmetricKeyPair001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call RSA')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call RSA Success Result:0')); - console.info('uitest: testBinaryDataConvertAsymmetricKeyPair001 end'); - }) - - /** - * 点击按钮,指定二进制数据转换ECC密钥对 - */ - it('testBinaryDataConvertAsymmetricKeyPair002', 0, async () => { - console.info('uitest: testBinaryDataConvertAsymmetricKeyPair002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call ECC')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call ECC Success Result:0')); - console.info('uitest: testBinaryDataConvertAsymmetricKeyPair002 end'); - }) - - /** - * 点击按钮,指定二进制数据转换SM2密钥对 - */ - it('testBinaryDataConvertAsymmetricKeyPair003', 0, async () => { - console.info('uitest: testBinaryDataConvertAsymmetricKeyPair003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call SM2')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call SM2 Success Result:0')); - console.info('uitest: testBinaryDataConvertAsymmetricKeyPair003 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function binaryDataConvertAsymmetricKeyPairTest() { + describe('binaryDataConvertAsymmetricKeyPairTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,指定二进制数据转换RSA密钥对 + */ + it('testBinaryDataConvertAsymmetricKeyPair001', 0, async () => { + console.info('uitest: testBinaryDataConvertAsymmetricKeyPair001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call RSA')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call RSA Success Result:0')); + console.info('uitest: testBinaryDataConvertAsymmetricKeyPair001 end'); + }) + + /** + * 点击按钮,指定二进制数据转换ECC密钥对 + */ + it('testBinaryDataConvertAsymmetricKeyPair002', 0, async () => { + console.info('uitest: testBinaryDataConvertAsymmetricKeyPair002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call ECC')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call ECC Success Result:0')); + console.info('uitest: testBinaryDataConvertAsymmetricKeyPair002 end'); + }) + + /** + * 点击按钮,指定二进制数据转换SM2密钥对 + */ + it('testBinaryDataConvertAsymmetricKeyPair003', 0, async () => { + console.info('uitest: testBinaryDataConvertAsymmetricKeyPair003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call SM2')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call SM2 Success Result:0')); + console.info('uitest: testBinaryDataConvertAsymmetricKeyPair003 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/ohosTest.md old mode 100755 new mode 100644 index 9f5f6d82ff..aea3fe60ba --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/ohosTest.md @@ -1,10 +1,10 @@ -# 指定二进制数据转换非对称密钥对(C/C++)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,指定二进制数据转换RSA密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定二进制数据转换ECC密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 指定二进制数据转换非对称密钥对(C/C++)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,指定二进制数据转换RSA密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定二进制数据转换ECC密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,指定二进制数据转换SM2密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/screenshots/BinaryDataConvertAsymmetricKeyPair1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/screenshots/BinaryDataConvertAsymmetricKeyPair1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/screenshots/BinaryDataConvertAsymmetricKeyPair2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPair/screenshots/BinaryDataConvertAsymmetricKeyPair2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/app.json5 old mode 100755 new mode 100644 index 9920c5d64d..fd806431dd --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/app.json5 @@ -1,25 +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.binarydataconvertasymmetrickeypairarkts", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.binarydataconvertasymmetrickeypairarkts", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index f74d73da16..2062a7c594 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "BinaryDataConvertAsymmetricKeyPairArkTS" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "BinaryDataConvertAsymmetricKeyPairArkTS" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/README.md old mode 100755 new mode 100644 index 8bc1aa6db7..24239da1e9 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/README.md @@ -1,80 +1,80 @@ -# 指定二进制数据转换非对称密钥对(ArkTS) - -### 介绍 - -以RSA、ECC、SM2为例,根据指定的对称密钥二进制数据,生成非对称密钥对(KeyPair),即将外部或存储的二进制数据转换为算法库的密钥对象,该对象可用于后续的加解密等操作。 - -本示例主要展示了指定二进制数据转换RSA密钥对、指定二进制数据转换ECC密钥对、 指定PKCS8二进制数据转换ECC私钥和指定二进制数据转换SM2密钥对场景。该工程中展示的代码详细描述可查如下链接。 - -- [ 指定二进制数据转换非对称密钥对(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-binary-data-to-asym-key-pair.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例BinaryDataConvertAsymmetricKeyPairArkTS.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── ecc - │ │ | ├── Callback.ets - │ │ | ├── Sync.ets - │ │ ├── pkcs8ecc - │ │ | ├── PKCS8ECC.ets - │ │ ├── rsa - │ │ | ├── Callback.ets - │ │ | ├── Sync.ets - │ │ ├── sm2 - │ │ | ├── Callback.ets - │ │ | ├── Sync.ets - │ │ ├── Index.ets // 指定二进制数据转换非对称密钥对(ArkTS)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── BinaryDataConvertAsymmetricKeyPairArkTS.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 指定二进制数据转换非对称密钥对(ArkTS) + +### 介绍 + +以RSA、ECC、SM2为例,根据指定的对称密钥二进制数据,生成非对称密钥对(KeyPair),即将外部或存储的二进制数据转换为算法库的密钥对象,该对象可用于后续的加解密等操作。 + +本示例主要展示了指定二进制数据转换RSA密钥对、指定二进制数据转换ECC密钥对、 指定PKCS8二进制数据转换ECC私钥和指定二进制数据转换SM2密钥对场景。该工程中展示的代码详细描述可查如下链接。 + +- [ 指定二进制数据转换非对称密钥对(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-binary-data-to-asym-key-pair.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例BinaryDataConvertAsymmetricKeyPairArkTS.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── ecc + │ │ | ├── Callback.ets + │ │ | ├── Sync.ets + │ │ ├── pkcs8ecc + │ │ | ├── PKCS8ECC.ets + │ │ ├── rsa + │ │ | ├── Callback.ets + │ │ | ├── Sync.ets + │ │ ├── sm2 + │ │ | ├── Callback.ets + │ │ | ├── Sync.ets + │ │ ├── Index.ets // 指定二进制数据转换非对称密钥对(ArkTS)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── BinaryDataConvertAsymmetricKeyPairArkTS.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/ecc/Callback.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/ecc/Callback.ets old mode 100755 new mode 100644 index ddd643289b..dc9cf6ed25 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/ecc/Callback.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/ecc/Callback.ets @@ -1,63 +1,63 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start bin_convert_ecc_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function convertEccAsyKey() { - let pubKeyArray = - new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, - 83, 96, 142, 9, 86, 214, 126, 106, 247, 233, 92, 125, 4, 128, 138, 105, 246, 162, 215, 71, 81, 58, 202, 121, 26, - 105, 211, 55, 130, 45, 236, 143, 55, 16, 248, 75, 167, 160, 167, 106, 2, 152, 243, 44, 68, 66, 0, 167, 99, 92, - 235, 215, 159, 239, 28, 106, 124, 171, 34, 145, 124, 174, 57, 92]); - let priKeyArray = - new Uint8Array([48, 49, 2, 1, 1, 4, 32, 115, 56, 137, 35, 207, 0, 60, 191, 90, 61, 136, 105, 210, 16, 27, 4, 171, - 57, 10, 61, 123, 40, 189, 28, 34, 207, 236, 22, 45, 223, 10, 189, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7]); - let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyArray }; - let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyArray }; - let generator = cryptoFramework.createAsyKeyGenerator('ECC256'); - generator.convertKey(pubKeyBlob, priKeyBlob, (error, data) => { - if (error) { - console.error(`convertKey failed, ${error.code}, ${error.message}`); - return; - } - console.info('convertKey success'); - }); -} -// [End bin_convert_ecc_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'ECC Callback'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_ecc_callback')) - .width('70%') - .onClick(() => { - try { - convertEccAsyKey(); - this.message = 'ECC Callback Success'; - } catch { - this.message = 'ECC Callback Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start bin_convert_ecc_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function convertEccAsyKey() { + let pubKeyArray = + new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, + 83, 96, 142, 9, 86, 214, 126, 106, 247, 233, 92, 125, 4, 128, 138, 105, 246, 162, 215, 71, 81, 58, 202, 121, 26, + 105, 211, 55, 130, 45, 236, 143, 55, 16, 248, 75, 167, 160, 167, 106, 2, 152, 243, 44, 68, 66, 0, 167, 99, 92, + 235, 215, 159, 239, 28, 106, 124, 171, 34, 145, 124, 174, 57, 92]); + let priKeyArray = + new Uint8Array([48, 49, 2, 1, 1, 4, 32, 115, 56, 137, 35, 207, 0, 60, 191, 90, 61, 136, 105, 210, 16, 27, 4, 171, + 57, 10, 61, 123, 40, 189, 28, 34, 207, 236, 22, 45, 223, 10, 189, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7]); + let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyArray }; + let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyArray }; + let generator = cryptoFramework.createAsyKeyGenerator('ECC256'); + generator.convertKey(pubKeyBlob, priKeyBlob, (error, data) => { + if (error) { + console.error(`convertKey failed, ${error.code}, ${error.message}`); + return; + } + console.info('convertKey success'); + }); +} +// [End bin_convert_ecc_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'ECC Callback'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_ecc_callback')) + .width('70%') + .onClick(() => { + try { + convertEccAsyKey(); + this.message = 'ECC Callback Success'; + } catch { + this.message = 'ECC Callback Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/ecc/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/ecc/Sync.ets old mode 100755 new mode 100644 index c593c7fbfc..bf5c93cda7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/ecc/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/ecc/Sync.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start bin_convert_ecc_keypair_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function convertECCAsyKeySync() { - let pubKeyArray = - new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, - 83, 96, 142, 9, 86, 214, 126, 106, 247, 233, 92, 125, 4, 128, 138, 105, 246, 162, 215, 71, 81, 58, 202, 121, 26, - 105, 211, 55, 130, 45, 236, 143, 55, 16, 248, 75, 167, 160, 167, 106, 2, 152, 243, 44, 68, 66, 0, 167, 99, 92, - 235, 215, 159, 239, 28, 106, 124, 171, 34, 145, 124, 174, 57, 92]); - let priKeyArray = - new Uint8Array([48, 49, 2, 1, 1, 4, 32, 115, 56, 137, 35, 207, 0, 60, 191, 90, 61, 136, 105, 210, 16, 27, 4, 171, - 57, 10, 61, 123, 40, 189, 28, 34, 207, 236, 22, 45, 223, 10, 189, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7]); - let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyArray }; - let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyArray }; - let generator = cryptoFramework.createAsyKeyGenerator('ECC256'); - try { - let keyPair = generator.convertKeySync(pubKeyBlob, priKeyBlob); - if (keyPair != null) { - console.info('convertKeySync success'); - } - } catch (e) { - console.error(`get key pair failed, ${e.code}, ${e.message}`); - } -} -// [End bin_convertbin_convert_ecc_keypair_sync] - -@Entry -@Component -struct Index { - @State message: string = 'ECC Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_ecc_sync')) - .width('70%') - .onClick(() => { - try { - convertECCAsyKeySync(); - this.message = 'ECC Sync Success'; - } catch { - this.message = 'ECC Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start bin_convert_ecc_keypair_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function convertECCAsyKeySync() { + let pubKeyArray = + new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, + 83, 96, 142, 9, 86, 214, 126, 106, 247, 233, 92, 125, 4, 128, 138, 105, 246, 162, 215, 71, 81, 58, 202, 121, 26, + 105, 211, 55, 130, 45, 236, 143, 55, 16, 248, 75, 167, 160, 167, 106, 2, 152, 243, 44, 68, 66, 0, 167, 99, 92, + 235, 215, 159, 239, 28, 106, 124, 171, 34, 145, 124, 174, 57, 92]); + let priKeyArray = + new Uint8Array([48, 49, 2, 1, 1, 4, 32, 115, 56, 137, 35, 207, 0, 60, 191, 90, 61, 136, 105, 210, 16, 27, 4, 171, + 57, 10, 61, 123, 40, 189, 28, 34, 207, 236, 22, 45, 223, 10, 189, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7]); + let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyArray }; + let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyArray }; + let generator = cryptoFramework.createAsyKeyGenerator('ECC256'); + try { + let keyPair = generator.convertKeySync(pubKeyBlob, priKeyBlob); + if (keyPair != null) { + console.info('convertKeySync success'); + } + } catch (e) { + console.error(`get key pair failed, ${e.code}, ${e.message}`); + } +} +// [End bin_convertbin_convert_ecc_keypair_sync] + +@Entry +@Component +struct Index { + @State message: string = 'ECC Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_ecc_sync')) + .width('70%') + .onClick(() => { + try { + convertECCAsyKeySync(); + this.message = 'ECC Sync Success'; + } catch { + this.message = 'ECC Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/pkcs8ecc/PKCS8ECC.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/pkcs8ecc/PKCS8ECC.ets old mode 100755 new mode 100644 index fef66ea023..a9c12d2cea --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/pkcs8ecc/PKCS8ECC.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/pkcs8ecc/PKCS8ECC.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pkcs8_convert_ecc_pri_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -async function main() { - // 创建一个AsyKeyGenerator实例 - let eccGenerator = cryptoFramework.createAsyKeyGenerator('ECC256'); - // 使用密钥生成器随机生成非对称密钥对 - let keyGenPromise = eccGenerator.generateKeyPair(); - keyGenPromise.then(keyPair => { - let pubKey = keyPair.pubKey; - let priKey = keyPair.priKey; - // 获取非对称密钥对ECC的二进制数据 - let pubBlob = pubKey.getEncoded(); - let skBlob = priKey.getEncodedDer('PKCS8'); - let generator = cryptoFramework.createAsyKeyGenerator('ECC256'); - generator.convertKey(pubBlob, skBlob, (error, data) => { - if (error) { - console.error(`convertKey failed, ${error.code}, ${error.message}`); - return; - } - console.info('convertKey success'); - }); - }); -} -// [End pkcs8_convert_ecc_pri_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'PKCS8 ECC Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_pkcs8_ecc_sync')) - .width('70%') - .onClick(async () => { - try { - await main(); - this.message = 'PKCS8 ECC Sync Success'; - } catch { - this.message = 'PKCS8 ECC Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pkcs8_convert_ecc_pri_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +async function main() { + // 创建一个AsyKeyGenerator实例 + let eccGenerator = cryptoFramework.createAsyKeyGenerator('ECC256'); + // 使用密钥生成器随机生成非对称密钥对 + let keyGenPromise = eccGenerator.generateKeyPair(); + keyGenPromise.then(keyPair => { + let pubKey = keyPair.pubKey; + let priKey = keyPair.priKey; + // 获取非对称密钥对ECC的二进制数据 + let pubBlob = pubKey.getEncoded(); + let skBlob = priKey.getEncodedDer('PKCS8'); + let generator = cryptoFramework.createAsyKeyGenerator('ECC256'); + generator.convertKey(pubBlob, skBlob, (error, data) => { + if (error) { + console.error(`convertKey failed, ${error.code}, ${error.message}`); + return; + } + console.info('convertKey success'); + }); + }); +} +// [End pkcs8_convert_ecc_pri_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'PKCS8 ECC Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_pkcs8_ecc_sync')) + .width('70%') + .onClick(async () => { + try { + await main(); + this.message = 'PKCS8 ECC Sync Success'; + } catch { + this.message = 'PKCS8 ECC Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Callback.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Callback.ets old mode 100755 new mode 100644 index 4ed6e24446..ecc1a4fad9 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Callback.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Callback.ets @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start bin_convert_rsa_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function convertAsyKey() { - let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); - let pkVal = - new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, - 2, 129, 129, 0, 174, 203, 113, 83, 113, 3, 143, 213, 194, 79, 91, 9, 51, 142, 87, 45, 97, 65, 136, 24, 166, 35, 5, - 179, 42, 47, 212, 79, 111, 74, 134, 120, 73, 67, 21, 19, 235, 80, 46, 152, 209, 133, 232, 87, 192, 140, 18, 206, - 27, 106, 106, 169, 106, 46, 135, 111, 118, 32, 129, 27, 89, 255, 183, 116, 247, 38, 12, 7, 238, 77, 151, 167, 6, - 102, 153, 126, 66, 28, 253, 253, 216, 64, 20, 138, 117, 72, 15, 216, 178, 37, 208, 179, 63, 204, 39, 94, 244, 170, - 48, 190, 21, 11, 73, 169, 156, 104, 193, 3, 17, 100, 28, 60, 50, 92, 235, 218, 57, 73, 119, 19, 101, 164, 192, - 161, 197, 106, 105, 73, 2, 3, 1, 0, 1]); - let pkBlob: cryptoFramework.DataBlob = { data: pkVal }; - rsaGenerator.convertKey(pkBlob, null, (err, keyPair) => { - if (err) { - console.error(`convertKey failed, ${err.code}, ${err.message}`); - return; - } - console.info('convertKey success'); - }); -} -// [End bin_convert_rsa_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'RSA Callback'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_callback')) - .width('70%') - .onClick(() => { - try { - convertAsyKey(); - this.message = 'RSA Callback Success'; - } catch { - this.message = 'RSA Callback Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start bin_convert_rsa_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function convertAsyKey() { + let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); + let pkVal = + new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, + 2, 129, 129, 0, 174, 203, 113, 83, 113, 3, 143, 213, 194, 79, 91, 9, 51, 142, 87, 45, 97, 65, 136, 24, 166, 35, 5, + 179, 42, 47, 212, 79, 111, 74, 134, 120, 73, 67, 21, 19, 235, 80, 46, 152, 209, 133, 232, 87, 192, 140, 18, 206, + 27, 106, 106, 169, 106, 46, 135, 111, 118, 32, 129, 27, 89, 255, 183, 116, 247, 38, 12, 7, 238, 77, 151, 167, 6, + 102, 153, 126, 66, 28, 253, 253, 216, 64, 20, 138, 117, 72, 15, 216, 178, 37, 208, 179, 63, 204, 39, 94, 244, 170, + 48, 190, 21, 11, 73, 169, 156, 104, 193, 3, 17, 100, 28, 60, 50, 92, 235, 218, 57, 73, 119, 19, 101, 164, 192, + 161, 197, 106, 105, 73, 2, 3, 1, 0, 1]); + let pkBlob: cryptoFramework.DataBlob = { data: pkVal }; + rsaGenerator.convertKey(pkBlob, null, (err, keyPair) => { + if (err) { + console.error(`convertKey failed, ${err.code}, ${err.message}`); + return; + } + console.info('convertKey success'); + }); +} +// [End bin_convert_rsa_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'RSA Callback'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_callback')) + .width('70%') + .onClick(() => { + try { + convertAsyKey(); + this.message = 'RSA Callback Success'; + } catch { + this.message = 'RSA Callback Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Sync.ets old mode 100755 new mode 100644 index d02ca4a976..cdf63892db --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Sync.ets @@ -1,63 +1,63 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start bin_convert_rsa_keypair_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function convertAsyKeySync() { - let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); - let pkVal = - new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, - 2, 129, 129, 0, 174, 203, 113, 83, 113, 3, 143, 213, 194, 79, 91, 9, 51, 142, 87, 45, 97, 65, 136, 24, 166, 35, 5, - 179, 42, 47, 212, 79, 111, 74, 134, 120, 73, 67, 21, 19, 235, 80, 46, 152, 209, 133, 232, 87, 192, 140, 18, 206, - 27, 106, 106, 169, 106, 46, 135, 111, 118, 32, 129, 27, 89, 255, 183, 116, 247, 38, 12, 7, 238, 77, 151, 167, 6, - 102, 153, 126, 66, 28, 253, 253, 216, 64, 20, 138, 117, 72, 15, 216, 178, 37, 208, 179, 63, 204, 39, 94, 244, 170, - 48, 190, 21, 11, 73, 169, 156, 104, 193, 3, 17, 100, 28, 60, 50, 92, 235, 218, 57, 73, 119, 19, 101, 164, 192, - 161, 197, 106, 105, 73, 2, 3, 1, 0, 1]); - let pkBlob: cryptoFramework.DataBlob = { data: pkVal }; - try { - let keyPair = rsaGenerator.convertKeySync(pkBlob, null); - if (keyPair != null) { - console.info('convertKeySync success'); - } - } catch (e) { - console.error(`get key pair failed, ${e.code}, ${e.message}`); - } -} -// [End bin_convert_rsa_keypair_sync] - -@Entry -@Component -struct Index { - @State message: string = 'RSA Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_sync')) - .width('70%') - .onClick(() => { - try { - convertAsyKeySync(); - this.message = 'RSA Sync Success'; - } catch { - this.message = 'RSA Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start bin_convert_rsa_keypair_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function convertAsyKeySync() { + let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); + let pkVal = + new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, + 2, 129, 129, 0, 174, 203, 113, 83, 113, 3, 143, 213, 194, 79, 91, 9, 51, 142, 87, 45, 97, 65, 136, 24, 166, 35, 5, + 179, 42, 47, 212, 79, 111, 74, 134, 120, 73, 67, 21, 19, 235, 80, 46, 152, 209, 133, 232, 87, 192, 140, 18, 206, + 27, 106, 106, 169, 106, 46, 135, 111, 118, 32, 129, 27, 89, 255, 183, 116, 247, 38, 12, 7, 238, 77, 151, 167, 6, + 102, 153, 126, 66, 28, 253, 253, 216, 64, 20, 138, 117, 72, 15, 216, 178, 37, 208, 179, 63, 204, 39, 94, 244, 170, + 48, 190, 21, 11, 73, 169, 156, 104, 193, 3, 17, 100, 28, 60, 50, 92, 235, 218, 57, 73, 119, 19, 101, 164, 192, + 161, 197, 106, 105, 73, 2, 3, 1, 0, 1]); + let pkBlob: cryptoFramework.DataBlob = { data: pkVal }; + try { + let keyPair = rsaGenerator.convertKeySync(pkBlob, null); + if (keyPair != null) { + console.info('convertKeySync success'); + } + } catch (e) { + console.error(`get key pair failed, ${e.code}, ${e.message}`); + } +} +// [End bin_convert_rsa_keypair_sync] + +@Entry +@Component +struct Index { + @State message: string = 'RSA Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_sync')) + .width('70%') + .onClick(() => { + try { + convertAsyKeySync(); + this.message = 'RSA Sync Success'; + } catch { + this.message = 'RSA Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Callback.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Callback.ets old mode 100755 new mode 100644 index 48c1b0183d..dc2e5e4639 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Callback.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Callback.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start bin_convert_sm2_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function convertSM2AsyKey() { - let pubKeyArray = - new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 129, 28, 207, 85, 1, 130, 45, 3, 66, 0, - 4, 90, 3, 58, 157, 190, 248, 76, 7, 132, 200, 151, 208, 112, 230, 96, 140, 90, 238, 211, 155, 128, 109, 248, 40, - 83, 214, 78, 42, 104, 106, 55, 148, 249, 35, 61, 32, 221, 135, 143, 100, 45, 97, 194, 176, 52, 73, 136, 174, 40, - 70, 70, 34, 103, 103, 161, 99, 27, 187, 13, 187, 109, 244, 13, 7]); - let priKeyArray = - new Uint8Array([48, 49, 2, 1, 1, 4, 32, 54, 41, 239, 240, 63, 188, 134, 113, 31, 102, 149, 203, 245, 89, 15, 15, 47, - 202, 170, 60, 38, 154, 28, 169, 189, 100, 251, 76, 112, 223, 156, 159, 160, 10, 6, 8, 42, 129, 28, 207, 85, 1, - 130, 45]); - let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyArray }; - let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyArray }; - let generator = cryptoFramework.createAsyKeyGenerator('SM2_256'); - generator.convertKey(pubKeyBlob, priKeyBlob, (error, data) => { - if (error) { - console.error(`convertKey failed, ${error.code}, ${error.message}`); - return; - } - console.info('convertKey success'); - }); -} -// [End bin_convert_sm2_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'SM2 Callback'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm2_callback')) - .width('70%') - .onClick(() => { - try { - convertSM2AsyKey(); - this.message = 'SM2 Callback Success'; - } catch { - this.message = 'SM2 Callback Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start bin_convert_sm2_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function convertSM2AsyKey() { + let pubKeyArray = + new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 129, 28, 207, 85, 1, 130, 45, 3, 66, 0, + 4, 90, 3, 58, 157, 190, 248, 76, 7, 132, 200, 151, 208, 112, 230, 96, 140, 90, 238, 211, 155, 128, 109, 248, 40, + 83, 214, 78, 42, 104, 106, 55, 148, 249, 35, 61, 32, 221, 135, 143, 100, 45, 97, 194, 176, 52, 73, 136, 174, 40, + 70, 70, 34, 103, 103, 161, 99, 27, 187, 13, 187, 109, 244, 13, 7]); + let priKeyArray = + new Uint8Array([48, 49, 2, 1, 1, 4, 32, 54, 41, 239, 240, 63, 188, 134, 113, 31, 102, 149, 203, 245, 89, 15, 15, 47, + 202, 170, 60, 38, 154, 28, 169, 189, 100, 251, 76, 112, 223, 156, 159, 160, 10, 6, 8, 42, 129, 28, 207, 85, 1, + 130, 45]); + let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyArray }; + let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyArray }; + let generator = cryptoFramework.createAsyKeyGenerator('SM2_256'); + generator.convertKey(pubKeyBlob, priKeyBlob, (error, data) => { + if (error) { + console.error(`convertKey failed, ${error.code}, ${error.message}`); + return; + } + console.info('convertKey success'); + }); +} +// [End bin_convert_sm2_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'SM2 Callback'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm2_callback')) + .width('70%') + .onClick(() => { + try { + convertSM2AsyKey(); + this.message = 'SM2 Callback Success'; + } catch { + this.message = 'SM2 Callback Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Sync.ets old mode 100755 new mode 100644 index f40dae78f5..49b062d773 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Sync.ets @@ -1,65 +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. - */ - -// [Start bin_convert_sm2_keypair_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function convertSM2AsyKeySync() { - let pubKeyArray = - new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 129, 28, 207, 85, 1, 130, 45, 3, 66, 0, - 4, 90, 3, 58, 157, 190, 248, 76, 7, 132, 200, 151, 208, 112, 230, 96, 140, 90, 238, 211, 155, 128, 109, 248, 40, - 83, 214, 78, 42, 104, 106, 55, 148, 249, 35, 61, 32, 221, 135, 143, 100, 45, 97, 194, 176, 52, 73, 136, 174, 40, - 70, 70, 34, 103, 103, 161, 99, 27, 187, 13, 187, 109, 244, 13, 7]); - let priKeyArray = - new Uint8Array([48, 49, 2, 1, 1, 4, 32, 54, 41, 239, 240, 63, 188, 134, 113, 31, 102, 149, 203, 245, 89, 15, 15, 47, - 202, 170, 60, 38, 154, 28, 169, 189, 100, 251, 76, 112, 223, 156, 159, 160, 10, 6, 8, 42, 129, 28, 207, 85, 1, - 130, 45]); - let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyArray }; - let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyArray }; - let generator = cryptoFramework.createAsyKeyGenerator('SM2_256'); - try { - let keyPair = generator.convertKeySync(pubKeyBlob, priKeyBlob); - if (keyPair != null) { - console.info('convertKeySync success'); - } - } catch (e) { - console.error(`get key pair failed, ${e.code}, ${e.message}`); - } -} -// [End bin_convert_sm2_keypair_sync] - -@Entry -@Component -struct Index { - @State message: string = 'SM2 Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm2_sync')) - .width('70%') - .onClick(() => { - try { - convertSM2AsyKeySync(); - this.message = 'SM2 Sync Success'; - } catch { - this.message = 'SM2 Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start bin_convert_sm2_keypair_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function convertSM2AsyKeySync() { + let pubKeyArray = + new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 129, 28, 207, 85, 1, 130, 45, 3, 66, 0, + 4, 90, 3, 58, 157, 190, 248, 76, 7, 132, 200, 151, 208, 112, 230, 96, 140, 90, 238, 211, 155, 128, 109, 248, 40, + 83, 214, 78, 42, 104, 106, 55, 148, 249, 35, 61, 32, 221, 135, 143, 100, 45, 97, 194, 176, 52, 73, 136, 174, 40, + 70, 70, 34, 103, 103, 161, 99, 27, 187, 13, 187, 109, 244, 13, 7]); + let priKeyArray = + new Uint8Array([48, 49, 2, 1, 1, 4, 32, 54, 41, 239, 240, 63, 188, 134, 113, 31, 102, 149, 203, 245, 89, 15, 15, 47, + 202, 170, 60, 38, 154, 28, 169, 189, 100, 251, 76, 112, 223, 156, 159, 160, 10, 6, 8, 42, 129, 28, 207, 85, 1, + 130, 45]); + let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyArray }; + let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyArray }; + let generator = cryptoFramework.createAsyKeyGenerator('SM2_256'); + try { + let keyPair = generator.convertKeySync(pubKeyBlob, priKeyBlob); + if (keyPair != null) { + console.info('convertKeySync success'); + } + } catch (e) { + console.error(`get key pair failed, ${e.code}, ${e.message}`); + } +} +// [End bin_convert_sm2_keypair_sync] + +@Entry +@Component +struct Index { + @State message: string = 'SM2 Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm2_sync')) + .width('70%') + .onClick(() => { + try { + convertSM2AsyKeySync(); + this.message = 'SM2 Sync Success'; + } catch { + this.message = 'SM2 Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/BinaryDataConvertAsymmetricKeyPairArkTS.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/BinaryDataConvertAsymmetricKeyPairArkTS.test.ets old mode 100755 new mode 100644 index 570e9a0752..2dfb95cd2c --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/BinaryDataConvertAsymmetricKeyPairArkTS.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/BinaryDataConvertAsymmetricKeyPairArkTS.test.ets @@ -1,170 +1,170 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function binaryDataConvertAsymmetricKeyPairArkTSTest() { - describe('binaryDataConvertAsymmetricKeyPairArkTSTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,指定二进制数据转换ECC密钥对 - */ - it('testBinaryDataConvertAsymmetricKeyPairArkTS001', 0, async () => { - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('ECC Callback')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call ECC Callback')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ECC Callback Success')); - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定二进制数据转换ECC密钥对 - */ - it('testBinaryDataConvertAsymmetricKeyPairArkTS002', 0, async () => { - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('ECC Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call ECC Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ECC Sync Success')); - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定PKCS8二进制数据转换ECC私钥 - */ - it('testBinaryDataConvertAsymmetricKeyPairArkTS003', 0, async () => { - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('PKCS8 ECC')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call PKCS8 ECC Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('PKCS8 ECC Sync Success')); - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定二进制数据转换RSA密钥对 - */ - it('testBinaryDataConvertAsymmetricKeyPairArkTS004', 0, async () => { - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA Callback')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA Callback')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA Callback Success')); - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS004 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定二进制数据转换RSA密钥对 - */ - it('testBinaryDataConvertAsymmetricKeyPairArkTS005', 0, async () => { - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA Sync Success')); - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS005 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定二进制数据转换SM2密钥对 - */ - it('testBinaryDataConvertAsymmetricKeyPairArkTS006', 0, async () => { - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS006 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM2 Callback')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2 Callback')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2 Callback Success')); - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS006 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定二进制数据转换SM2密钥对 - */ - it('testBinaryDataConvertAsymmetricKeyPairArkTS007', 0, async () => { - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS007 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM2 Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2 Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2 Sync Success')); - console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS007 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function binaryDataConvertAsymmetricKeyPairArkTSTest() { + describe('binaryDataConvertAsymmetricKeyPairArkTSTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,指定二进制数据转换ECC密钥对 + */ + it('testBinaryDataConvertAsymmetricKeyPairArkTS001', 0, async () => { + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('ECC Callback')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call ECC Callback')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ECC Callback Success')); + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定二进制数据转换ECC密钥对 + */ + it('testBinaryDataConvertAsymmetricKeyPairArkTS002', 0, async () => { + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('ECC Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call ECC Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ECC Sync Success')); + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定PKCS8二进制数据转换ECC私钥 + */ + it('testBinaryDataConvertAsymmetricKeyPairArkTS003', 0, async () => { + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('PKCS8 ECC')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call PKCS8 ECC Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('PKCS8 ECC Sync Success')); + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定二进制数据转换RSA密钥对 + */ + it('testBinaryDataConvertAsymmetricKeyPairArkTS004', 0, async () => { + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA Callback')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA Callback')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA Callback Success')); + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS004 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定二进制数据转换RSA密钥对 + */ + it('testBinaryDataConvertAsymmetricKeyPairArkTS005', 0, async () => { + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA Sync Success')); + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS005 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定二进制数据转换SM2密钥对 + */ + it('testBinaryDataConvertAsymmetricKeyPairArkTS006', 0, async () => { + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS006 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM2 Callback')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2 Callback')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2 Callback Success')); + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS006 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定二进制数据转换SM2密钥对 + */ + it('testBinaryDataConvertAsymmetricKeyPairArkTS007', 0, async () => { + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS007 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM2 Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2 Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2 Sync Success')); + console.info('uitest: testBinaryDataConvertAsymmetricKeyPairArkTS007 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/ohosTest.md old mode 100755 new mode 100644 index 8c37a2a883..aca67a6fac --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/ohosTest.md @@ -1,14 +1,14 @@ -# 指定二进制数据转换非对称密钥对(ArkTS)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,指定二进制数据转换ECC密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定二进制数据转换ECC密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定PKCS8二进制数据转换ECC私钥 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定二进制数据转换RSA密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定二进制数据转换RSA密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定二进制数据转换SM2密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 指定二进制数据转换非对称密钥对(ArkTS)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,指定二进制数据转换ECC密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定二进制数据转换ECC密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定PKCS8二进制数据转换ECC私钥 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定二进制数据转换RSA密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定二进制数据转换RSA密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定二进制数据转换SM2密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,指定二进制数据转换SM2密钥对 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/screenshots/BinaryDataConvertAsymmetricKeyPairArkTS1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/screenshots/BinaryDataConvertAsymmetricKeyPairArkTS1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/screenshots/BinaryDataConvertAsymmetricKeyPairArkTS2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/BinaryDataConvertAsymmetricKeyPairArkTS/screenshots/BinaryDataConvertAsymmetricKeyPairArkTS2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/app.json5 old mode 100755 new mode 100644 index 2d0fb8ce22..a7ecbaae53 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/app.json5 @@ -1,25 +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.convertspecifiedpemasymmetrickeypair", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.convertspecifiedpemasymmetrickeypair", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index a2e570241b..13b70d7f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ConvertSpecifiedPEMAsymmetricKeyPair" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ConvertSpecifiedPEMAsymmetricKeyPair" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/README.md old mode 100755 new mode 100644 index 2b086dc87b..6f3cc74dd7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/README.md @@ -1,84 +1,84 @@ -# 指定PEM格式字符串数据转换非对称密钥对 - -### 介绍 - -以RSA为例,根据指定的非对称密钥字符串数据,生成非对称密钥对(KeyPair)。 - -以RSA为例,根据指定的非对称密钥字符串数据,生成非对称密钥对(OH_CryptoKeyPair)。 - -本示例主要展示了指定PEM格式字符串数据转换非对称密钥对(ArkTS、C/C++)场景。该工程中展示的代码详细描述可查如下链接。 - -- [指定PEM格式字符串数据转换非对称密钥对(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-string-data-to-asym-key-pair.md) -- [指定PEM格式字符串数据转换非对称密钥对(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-string-data-to-asym-key-pair-ndk.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例ConvertSpecifiedPEMAsymmetricKeyPair.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── rsa.cpp - │ │ | ├── file.h - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 指定PEM格式字符串数据转换非对称密钥对示例代码 - │ │ ├── Promise.ets - │ │ ├── Sync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── ConvertSpecifiedPEMAsymmetricKeyPair.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 指定PEM格式字符串数据转换非对称密钥对 + +### 介绍 + +以RSA为例,根据指定的非对称密钥字符串数据,生成非对称密钥对(KeyPair)。 + +以RSA为例,根据指定的非对称密钥字符串数据,生成非对称密钥对(OH_CryptoKeyPair)。 + +本示例主要展示了指定PEM格式字符串数据转换非对称密钥对(ArkTS、C/C++)场景。该工程中展示的代码详细描述可查如下链接。 + +- [指定PEM格式字符串数据转换非对称密钥对(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-string-data-to-asym-key-pair.md) +- [指定PEM格式字符串数据转换非对称密钥对(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-string-data-to-asym-key-pair-ndk.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例ConvertSpecifiedPEMAsymmetricKeyPair.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── rsa.cpp + │ │ | ├── file.h + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 指定PEM格式字符串数据转换非对称密钥对示例代码 + │ │ ├── Promise.ets + │ │ ├── Sync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── ConvertSpecifiedPEMAsymmetricKeyPair.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 3acbdf11b3..c368231d79 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(ConvertSpecifiedPEMAsymmetricKeyPair) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp types/project/rsa.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(ConvertSpecifiedPEMAsymmetricKeyPair) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp types/project/rsa.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index bcceea269b..0289597a76 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp @@ -1,45 +1,45 @@ -/* - * 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 "types/project/file.h" - -static napi_value NAPI_Global_doTestPemDataCovertAsymKey(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestPemDataCovertAsymKey(), &ret); - return ret; -} -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"doTestPemDataCovertAsymKey", nullptr, NAPI_Global_doTestPemDataCovertAsymKey, - nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/file.h" + +static napi_value NAPI_Global_doTestPemDataCovertAsymKey(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestPemDataCovertAsymKey(), &ret); + return ret; +} +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"doTestPemDataCovertAsymKey", nullptr, NAPI_Global_doTestPemDataCovertAsymKey, + nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index d6b778380d..458a767fc8 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 doTestPemDataCovertAsymKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h old mode 100755 new mode 100644 index 30d9dba935..8b7f51e5db --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h @@ -1,22 +1,22 @@ -#ifndef FILE_H -#define FILE_H -/* - * 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 "CryptoArchitectureKit/crypto_common.h" - -OH_Crypto_ErrCode doTestPemDataCovertAsymKey(); - +#ifndef FILE_H +#define FILE_H +/* + * 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 "CryptoArchitectureKit/crypto_common.h" + +OH_Crypto_ErrCode doTestPemDataCovertAsymKey(); + #endif // FILE_H \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp old mode 100755 new mode 100644 index f0c1f2495a..5b95b55abe --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start specify_pem_string_convert_rsa_keypair] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_asym_key.h" -#include "file.h" - -OH_Crypto_ErrCode doTestPemDataCovertAsymKey() -{ - OH_CryptoAsymKeyGenerator *ctx = nullptr; - OH_Crypto_ErrCode ret; - - ret = OH_CryptoAsymKeyGenerator_Create("RSA1024", &ctx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - - uint8_t sm2PubKeyBlobData[] = { - 48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, - 0, 48, 129, 137, 2, 129, 129, 0, 235, 184, 151, 247, 130, 216, 140, 187, 64, 124, 219, 137, 140, - 184, 53, 137, 216, 105, 156, 141, 137, 165, 30, 80, 232, 55, 96, 46, 23, 237, 197, 123, 121, 27, - 240, 190, 14, 111, 237, 172, 67, 42, 47, 164, 226, 248, 211, 157, 213, 194, 131, 109, 181, 41, 173, - 217, 127, 252, 121, 126, 26, 130, 55, 4, 134, 104, 73, 5, 132, 91, 214, 146, 232, 64, 99, 87, - 33, 222, 155, 159, 9, 59, 212, 144, 46, 183, 83, 89, 220, 189, 148, 13, 176, 5, 139, 156, 230, - 143, 16, 152, 79, 36, 8, 112, 40, 174, 35, 83, 82, 57, 137, 87, 123, 215, 99, 199, 66, 131, - 150, 31, 143, 56, 252, 2, 73, 41, 70, 159, 2, 3, 1, 0, 1}; - - OH_CryptoKeyPair *dupKeyPair = nullptr; - Crypto_DataBlob pubBlob = {.data = sm2PubKeyBlobData, .len = sizeof(sm2PubKeyBlobData)}; - ret = OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &pubBlob, nullptr, &dupKeyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - return ret; - } - - OH_CryptoPubKey *pubKey1 = OH_CryptoKeyPair_GetPubKey(dupKeyPair); - Crypto_DataBlob retBlob = {.data = nullptr, .len = 0}; - ret = OH_CryptoPubKey_Encode(pubKey1, CRYPTO_PEM, "PKCS1", &retBlob); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(dupKeyPair); - return ret; - } - OH_Crypto_FreeDataBlob(&retBlob); - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(dupKeyPair); - return ret; -} -// [End specify_pem_string_convert_rsa_keypair] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start specify_pem_string_convert_rsa_keypair] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_asym_key.h" +#include "file.h" + +OH_Crypto_ErrCode doTestPemDataCovertAsymKey() +{ + OH_CryptoAsymKeyGenerator *ctx = nullptr; + OH_Crypto_ErrCode ret; + + ret = OH_CryptoAsymKeyGenerator_Create("RSA1024", &ctx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + + uint8_t sm2PubKeyBlobData[] = { + 48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, + 0, 48, 129, 137, 2, 129, 129, 0, 235, 184, 151, 247, 130, 216, 140, 187, 64, 124, 219, 137, 140, + 184, 53, 137, 216, 105, 156, 141, 137, 165, 30, 80, 232, 55, 96, 46, 23, 237, 197, 123, 121, 27, + 240, 190, 14, 111, 237, 172, 67, 42, 47, 164, 226, 248, 211, 157, 213, 194, 131, 109, 181, 41, 173, + 217, 127, 252, 121, 126, 26, 130, 55, 4, 134, 104, 73, 5, 132, 91, 214, 146, 232, 64, 99, 87, + 33, 222, 155, 159, 9, 59, 212, 144, 46, 183, 83, 89, 220, 189, 148, 13, 176, 5, 139, 156, 230, + 143, 16, 152, 79, 36, 8, 112, 40, 174, 35, 83, 82, 57, 137, 87, 123, 215, 99, 199, 66, 131, + 150, 31, 143, 56, 252, 2, 73, 41, 70, 159, 2, 3, 1, 0, 1}; + + OH_CryptoKeyPair *dupKeyPair = nullptr; + Crypto_DataBlob pubBlob = {.data = sm2PubKeyBlobData, .len = sizeof(sm2PubKeyBlobData)}; + ret = OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &pubBlob, nullptr, &dupKeyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + return ret; + } + + OH_CryptoPubKey *pubKey1 = OH_CryptoKeyPair_GetPubKey(dupKeyPair); + Crypto_DataBlob retBlob = {.data = nullptr, .len = 0}; + ret = OH_CryptoPubKey_Encode(pubKey1, CRYPTO_PEM, "PKCS1", &retBlob); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(dupKeyPair); + return ret; + } + OH_Crypto_FreeDataBlob(&retBlob); + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(dupKeyPair); + return ret; +} +// [End specify_pem_string_convert_rsa_keypair] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index a36ca588fe..965554bb3a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 49dcd56389..8f2a8e7e60 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets @@ -1,61 +1,61 @@ -/* - * 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 { router } from '@kit.ArkUI'; -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'ConvertSpecifiedPEMAsymmetricKeyPair'; - - goToSample(url: string): void { - router.pushUrl({ - url: url, - }, router.RouterMode.Single, (err) => { - if (err) { - console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); - return; - } - console.info('pushUrl success'); - }) - } - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(20) - .fontWeight(FontWeight.Bold) - Button($r('app.string.pem_to_rsa')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.doTestPemDataCovertAsymKey(); - this.message = 'doTestPemDataCovertAsymKey Success Result:' + ret.toString(); - }) - Button($r('app.string.promise')) - .width('70%') - .onClick(() => { - this.goToSample('pages/Promise') - }) - Button($r('app.string.sync')) - .width('70%') - .onClick(() => { - this.goToSample('pages/Sync') - }) - } - .width('100%') - .height('100%') - } -} +/* + * 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 { router } from '@kit.ArkUI'; +import testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State message: string = 'ConvertSpecifiedPEMAsymmetricKeyPair'; + + goToSample(url: string): void { + router.pushUrl({ + url: url, + }, router.RouterMode.Single, (err) => { + if (err) { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('pushUrl success'); + }) + } + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(20) + .fontWeight(FontWeight.Bold) + Button($r('app.string.pem_to_rsa')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.doTestPemDataCovertAsymKey(); + this.message = 'doTestPemDataCovertAsymKey Success Result:' + ret.toString(); + }) + Button($r('app.string.promise')) + .width('70%') + .onClick(() => { + this.goToSample('pages/Promise') + }) + Button($r('app.string.sync')) + .width('70%') + .onClick(() => { + this.goToSample('pages/Sync') + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Promise.ets old mode 100755 new mode 100644 index 8c0e302bce..cc450eca35 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Promise.ets @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start specify_pem_string_convert_rsa_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -let priKeyPkcs1Str1024: string = - '-----BEGIN RSA PRIVATE KEY-----\n' + - 'MIICXQIBAAKBgQCwIN3mr21+N96ToxnVnaS+xyK9cNRAHiHGgrbjHw6RAj3V+l+W\n' + - 'Y68IhIe3DudVlzE9oMjeOQwkMkq//HCxNlIlFR6O6pa0mrXSwPRE7YKG97CeKk2g\n' + - 'YOS8YEh8toAvm7xKbiLkXuuMlxrjP2j/mb5iI/UASFSPZiQ/IyxDr0AQaQIDAQAB\n' + - 'AoGAEvBFzBNa+7J4PXnRQlYEK/tvsd0bBZX33ceacMubHl6WVZbphltLq+fMTBPP\n' + - 'LjXmtpC+aJ7Lvmyl+wTi/TsxE9vxW5JnbuRT48rnZ/Xwq0eozDeEeIBRrpsr7Rvr\n' + - '7ctrgzr4m4yMHq9aDgpxj8IR7oHkfwnmWr0wM3FuiVlj650CQQDineeNZ1hUTkj4\n' + - 'D3O+iCi3mxEVEeJrpqrmSFolRMb+iozrIRKuJlgcOs+Gqi2fHfOTTL7LkpYe8SVg\n' + - 'e3JxUdVLAkEAxvcZXk+byMFoetrnlcMR13VHUpoVeoV9qkv6CAWLlbMdgf7uKmgp\n' + - 'a1Yp3QPDNQQqkPvrqtfR19JWZ4uy1qREmwJALTU3BjyBoH/liqb6fh4HkWk75Som\n' + - 'MzeSjFIOubSYxhq5tgZpBZjcpvUMhV7Zrw54kwASZ+YcUJvmyvKViAm9NQJBAKF7\n' + - 'DyXSKrem8Ws0m1ybM7HQx5As6l3EVhePDmDQT1eyRbKp+xaD74nkJpnwYdB3jyyY\n' + - 'qc7A1tj5J5NmeEFolR0CQQCn76Xp8HCjGgLHw9vg7YyIL28y/XyfFyaZAzzK+Yia\n' + - 'akNwQ6NeGtXSsuGCcyyfpacHp9xy8qXQNKSkw03/5vDO\n' + - '-----END RSA PRIVATE KEY-----\n'; -let publicPkcs1Str1024: string = - '-----BEGIN RSA PUBLIC KEY-----\n' + - 'MIGJAoGBALAg3eavbX433pOjGdWdpL7HIr1w1EAeIcaCtuMfDpECPdX6X5ZjrwiE\n' + - 'h7cO51WXMT2gyN45DCQySr/8cLE2UiUVHo7qlrSatdLA9ETtgob3sJ4qTaBg5Lxg\n' + - 'SHy2gC+bvEpuIuRe64yXGuM/aP+ZvmIj9QBIVI9mJD8jLEOvQBBpAgMBAAE=\n' + - '-----END RSA PUBLIC KEY-----\n'; - -async function testPkcs1ToPkcs8ByPromise() { - let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); - let keyPair = await asyKeyGenerator.convertPemKey(publicPkcs1Str1024, priKeyPkcs1Str1024); - let priPemKey = keyPair.priKey; - let pubPemKey = keyPair.pubKey; - let priString = priPemKey.getEncodedPem('PKCS8'); - let pubString = pubPemKey.getEncodedPem('X509'); - console.info('[promise]TestPkcs1ToPkcs8ByPromise priString output is ' + priString); - console.info('[promise]TestPkcs1ToPkcs8ByPromise pubString output is ' + pubString); -} -// [End specify_pem_string_convert_rsa_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'Promise'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_promise')) - .width('70%') - .onClick(async () => { - try { - await testPkcs1ToPkcs8ByPromise(); - this.message = 'Promise Success'; - } catch { - this.message = 'Promise Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start specify_pem_string_convert_rsa_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +let priKeyPkcs1Str1024: string = + '-----BEGIN RSA PRIVATE KEY-----\n' + + 'MIICXQIBAAKBgQCwIN3mr21+N96ToxnVnaS+xyK9cNRAHiHGgrbjHw6RAj3V+l+W\n' + + 'Y68IhIe3DudVlzE9oMjeOQwkMkq//HCxNlIlFR6O6pa0mrXSwPRE7YKG97CeKk2g\n' + + 'YOS8YEh8toAvm7xKbiLkXuuMlxrjP2j/mb5iI/UASFSPZiQ/IyxDr0AQaQIDAQAB\n' + + 'AoGAEvBFzBNa+7J4PXnRQlYEK/tvsd0bBZX33ceacMubHl6WVZbphltLq+fMTBPP\n' + + 'LjXmtpC+aJ7Lvmyl+wTi/TsxE9vxW5JnbuRT48rnZ/Xwq0eozDeEeIBRrpsr7Rvr\n' + + '7ctrgzr4m4yMHq9aDgpxj8IR7oHkfwnmWr0wM3FuiVlj650CQQDineeNZ1hUTkj4\n' + + 'D3O+iCi3mxEVEeJrpqrmSFolRMb+iozrIRKuJlgcOs+Gqi2fHfOTTL7LkpYe8SVg\n' + + 'e3JxUdVLAkEAxvcZXk+byMFoetrnlcMR13VHUpoVeoV9qkv6CAWLlbMdgf7uKmgp\n' + + 'a1Yp3QPDNQQqkPvrqtfR19JWZ4uy1qREmwJALTU3BjyBoH/liqb6fh4HkWk75Som\n' + + 'MzeSjFIOubSYxhq5tgZpBZjcpvUMhV7Zrw54kwASZ+YcUJvmyvKViAm9NQJBAKF7\n' + + 'DyXSKrem8Ws0m1ybM7HQx5As6l3EVhePDmDQT1eyRbKp+xaD74nkJpnwYdB3jyyY\n' + + 'qc7A1tj5J5NmeEFolR0CQQCn76Xp8HCjGgLHw9vg7YyIL28y/XyfFyaZAzzK+Yia\n' + + 'akNwQ6NeGtXSsuGCcyyfpacHp9xy8qXQNKSkw03/5vDO\n' + + '-----END RSA PRIVATE KEY-----\n'; +let publicPkcs1Str1024: string = + '-----BEGIN RSA PUBLIC KEY-----\n' + + 'MIGJAoGBALAg3eavbX433pOjGdWdpL7HIr1w1EAeIcaCtuMfDpECPdX6X5ZjrwiE\n' + + 'h7cO51WXMT2gyN45DCQySr/8cLE2UiUVHo7qlrSatdLA9ETtgob3sJ4qTaBg5Lxg\n' + + 'SHy2gC+bvEpuIuRe64yXGuM/aP+ZvmIj9QBIVI9mJD8jLEOvQBBpAgMBAAE=\n' + + '-----END RSA PUBLIC KEY-----\n'; + +async function testPkcs1ToPkcs8ByPromise() { + let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); + let keyPair = await asyKeyGenerator.convertPemKey(publicPkcs1Str1024, priKeyPkcs1Str1024); + let priPemKey = keyPair.priKey; + let pubPemKey = keyPair.pubKey; + let priString = priPemKey.getEncodedPem('PKCS8'); + let pubString = pubPemKey.getEncodedPem('X509'); + console.info('[promise]TestPkcs1ToPkcs8ByPromise priString output is ' + priString); + console.info('[promise]TestPkcs1ToPkcs8ByPromise pubString output is ' + pubString); +} +// [End specify_pem_string_convert_rsa_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'Promise'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_promise')) + .width('70%') + .onClick(async () => { + try { + await testPkcs1ToPkcs8ByPromise(); + this.message = 'Promise Success'; + } catch { + this.message = 'Promise Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Sync.ets old mode 100755 new mode 100644 index 94c12c13bd..372fa5322b --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/ets/pages/Sync.ets @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start specify_pem_string_convert_rsa_keypair_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -let priKeyPkcs1Str1024: string = - '-----BEGIN RSA PRIVATE KEY-----\n' + - 'MIICXQIBAAKBgQCwIN3mr21+N96ToxnVnaS+xyK9cNRAHiHGgrbjHw6RAj3V+l+W\n' + - 'Y68IhIe3DudVlzE9oMjeOQwkMkq//HCxNlIlFR6O6pa0mrXSwPRE7YKG97CeKk2g\n' + - 'YOS8YEh8toAvm7xKbiLkXuuMlxrjP2j/mb5iI/UASFSPZiQ/IyxDr0AQaQIDAQAB\n' + - 'AoGAEvBFzBNa+7J4PXnRQlYEK/tvsd0bBZX33ceacMubHl6WVZbphltLq+fMTBPP\n' + - 'LjXmtpC+aJ7Lvmyl+wTi/TsxE9vxW5JnbuRT48rnZ/Xwq0eozDeEeIBRrpsr7Rvr\n' + - '7ctrgzr4m4yMHq9aDgpxj8IR7oHkfwnmWr0wM3FuiVlj650CQQDineeNZ1hUTkj4\n' + - 'D3O+iCi3mxEVEeJrpqrmSFolRMb+iozrIRKuJlgcOs+Gqi2fHfOTTL7LkpYe8SVg\n' + - 'e3JxUdVLAkEAxvcZXk+byMFoetrnlcMR13VHUpoVeoV9qkv6CAWLlbMdgf7uKmgp\n' + - 'a1Yp3QPDNQQqkPvrqtfR19JWZ4uy1qREmwJALTU3BjyBoH/liqb6fh4HkWk75Som\n' + - 'MzeSjFIOubSYxhq5tgZpBZjcpvUMhV7Zrw54kwASZ+YcUJvmyvKViAm9NQJBAKF7\n' + - 'DyXSKrem8Ws0m1ybM7HQx5As6l3EVhePDmDQT1eyRbKp+xaD74nkJpnwYdB3jyyY\n' + - 'qc7A1tj5J5NmeEFolR0CQQCn76Xp8HCjGgLHw9vg7YyIL28y/XyfFyaZAzzK+Yia\n' + - 'akNwQ6NeGtXSsuGCcyyfpacHp9xy8qXQNKSkw03/5vDO\n' + - '-----END RSA PRIVATE KEY-----\n'; -let publicPkcs1Str1024: string = - '-----BEGIN RSA PUBLIC KEY-----\n' + - 'MIGJAoGBALAg3eavbX433pOjGdWdpL7HIr1w1EAeIcaCtuMfDpECPdX6X5ZjrwiE\n' + - 'h7cO51WXMT2gyN45DCQySr/8cLE2UiUVHo7qlrSatdLA9ETtgob3sJ4qTaBg5Lxg\n' + - 'SHy2gC+bvEpuIuRe64yXGuM/aP+ZvmIj9QBIVI9mJD8jLEOvQBBpAgMBAAE=\n' + - '-----END RSA PUBLIC KEY-----\n'; - -function testPkcs1ToPkcs8BySync() { - let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); - try { - let keyPairData = asyKeyGenerator.convertPemKeySync(publicPkcs1Str1024, priKeyPkcs1Str1024); - if (keyPairData != null) { - console.info('[Sync]: convert pem key pair success'); - } else { - console.error('[Sync]: convert pem key pair result fail!'); - } - let priPemKey = keyPairData.priKey; - let pubPemKey = keyPairData.pubKey; - let priString = priPemKey.getEncodedPem('PKCS8'); - let pubString = pubPemKey.getEncodedPem('X509'); - console.info('[Sync]TestPkcs1ToPkcs8BySync priString output is ' + priString); - console.info('[Sync]TestPkcs1ToPkcs8BySync pubString output is ' + pubString); - } catch (e) { - console.error(`Sync error, ${e.code}, ${e.message}`); - } -} -// [End specify_pem_string_convert_rsa_keypair_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sync')) - .width('70%') - .onClick(() => { - try { - testPkcs1ToPkcs8BySync(); - this.message = 'Sync Success'; - } catch { - this.message = 'Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start specify_pem_string_convert_rsa_keypair_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +let priKeyPkcs1Str1024: string = + '-----BEGIN RSA PRIVATE KEY-----\n' + + 'MIICXQIBAAKBgQCwIN3mr21+N96ToxnVnaS+xyK9cNRAHiHGgrbjHw6RAj3V+l+W\n' + + 'Y68IhIe3DudVlzE9oMjeOQwkMkq//HCxNlIlFR6O6pa0mrXSwPRE7YKG97CeKk2g\n' + + 'YOS8YEh8toAvm7xKbiLkXuuMlxrjP2j/mb5iI/UASFSPZiQ/IyxDr0AQaQIDAQAB\n' + + 'AoGAEvBFzBNa+7J4PXnRQlYEK/tvsd0bBZX33ceacMubHl6WVZbphltLq+fMTBPP\n' + + 'LjXmtpC+aJ7Lvmyl+wTi/TsxE9vxW5JnbuRT48rnZ/Xwq0eozDeEeIBRrpsr7Rvr\n' + + '7ctrgzr4m4yMHq9aDgpxj8IR7oHkfwnmWr0wM3FuiVlj650CQQDineeNZ1hUTkj4\n' + + 'D3O+iCi3mxEVEeJrpqrmSFolRMb+iozrIRKuJlgcOs+Gqi2fHfOTTL7LkpYe8SVg\n' + + 'e3JxUdVLAkEAxvcZXk+byMFoetrnlcMR13VHUpoVeoV9qkv6CAWLlbMdgf7uKmgp\n' + + 'a1Yp3QPDNQQqkPvrqtfR19JWZ4uy1qREmwJALTU3BjyBoH/liqb6fh4HkWk75Som\n' + + 'MzeSjFIOubSYxhq5tgZpBZjcpvUMhV7Zrw54kwASZ+YcUJvmyvKViAm9NQJBAKF7\n' + + 'DyXSKrem8Ws0m1ybM7HQx5As6l3EVhePDmDQT1eyRbKp+xaD74nkJpnwYdB3jyyY\n' + + 'qc7A1tj5J5NmeEFolR0CQQCn76Xp8HCjGgLHw9vg7YyIL28y/XyfFyaZAzzK+Yia\n' + + 'akNwQ6NeGtXSsuGCcyyfpacHp9xy8qXQNKSkw03/5vDO\n' + + '-----END RSA PRIVATE KEY-----\n'; +let publicPkcs1Str1024: string = + '-----BEGIN RSA PUBLIC KEY-----\n' + + 'MIGJAoGBALAg3eavbX433pOjGdWdpL7HIr1w1EAeIcaCtuMfDpECPdX6X5ZjrwiE\n' + + 'h7cO51WXMT2gyN45DCQySr/8cLE2UiUVHo7qlrSatdLA9ETtgob3sJ4qTaBg5Lxg\n' + + 'SHy2gC+bvEpuIuRe64yXGuM/aP+ZvmIj9QBIVI9mJD8jLEOvQBBpAgMBAAE=\n' + + '-----END RSA PUBLIC KEY-----\n'; + +function testPkcs1ToPkcs8BySync() { + let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024'); + try { + let keyPairData = asyKeyGenerator.convertPemKeySync(publicPkcs1Str1024, priKeyPkcs1Str1024); + if (keyPairData != null) { + console.info('[Sync]: convert pem key pair success'); + } else { + console.error('[Sync]: convert pem key pair result fail!'); + } + let priPemKey = keyPairData.priKey; + let pubPemKey = keyPairData.pubKey; + let priString = priPemKey.getEncodedPem('PKCS8'); + let pubString = pubPemKey.getEncodedPem('X509'); + console.info('[Sync]TestPkcs1ToPkcs8BySync priString output is ' + priString); + console.info('[Sync]TestPkcs1ToPkcs8BySync pubString output is ' + pubString); + } catch (e) { + console.error(`Sync error, ${e.code}, ${e.message}`); + } +} +// [End specify_pem_string_convert_rsa_keypair_sync] + +@Entry +@Component +struct Index { + @State message: string = 'Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sync')) + .width('70%') + .onClick(() => { + try { + testPkcs1ToPkcs8BySync(); + this.message = 'Sync Success'; + } catch { + this.message = 'Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/ConvertSpecifiedPEMAsymmetricKeyPair.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/ConvertSpecifiedPEMAsymmetricKeyPair.test.ets old mode 100755 new mode 100644 index 8b68f88d7b..f95d1d3a75 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/ConvertSpecifiedPEMAsymmetricKeyPair.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/ConvertSpecifiedPEMAsymmetricKeyPair.test.ets @@ -1,94 +1,94 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function convertSpecifiedPEMAsymmetricKeyPairTest() { - describe('convertSpecifiedPEMAsymmetricKeyPairTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,指定PEM格式字符串数据转换非对称密钥对(C/C++) - */ - it('testConvertSpecifiedPEMAsymmetricKeyPair001', 0, async () => { - console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('PEM TO RSA')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('doTestPemDataCovertAsymKey Success Result:0')); - console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair001 end'); - }) - - /** - * 点击按钮,指定PEM格式字符串数据转换非对称密钥对(ArkTS),Promise方式 - */ - it('testConvertSpecifiedPEMAsymmetricKeyPair002', 0, async () => { - console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Promise')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Promise')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Promise Success')); - console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定PEM格式字符串数据转换非对称密钥对(ArkTS),同步方式 - */ - it('testConvertSpecifiedPEMAsymmetricKeyPair003', 0, async () => { - console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Sync Success')); - console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair003 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function convertSpecifiedPEMAsymmetricKeyPairTest() { + describe('convertSpecifiedPEMAsymmetricKeyPairTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,指定PEM格式字符串数据转换非对称密钥对(C/C++) + */ + it('testConvertSpecifiedPEMAsymmetricKeyPair001', 0, async () => { + console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('PEM TO RSA')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('doTestPemDataCovertAsymKey Success Result:0')); + console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair001 end'); + }) + + /** + * 点击按钮,指定PEM格式字符串数据转换非对称密钥对(ArkTS),Promise方式 + */ + it('testConvertSpecifiedPEMAsymmetricKeyPair002', 0, async () => { + console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Promise')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Promise')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Promise Success')); + console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定PEM格式字符串数据转换非对称密钥对(ArkTS),同步方式 + */ + it('testConvertSpecifiedPEMAsymmetricKeyPair003', 0, async () => { + console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Sync Success')); + console.info('uitest: testConvertSpecifiedPEMAsymmetricKeyPair003 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/oh-package.json5 old mode 100755 new mode 100644 index 610c3ebfcd..9b142d655b --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/oh-package.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -{ - "modelVersion": "5.0.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/ohosTest.md old mode 100755 new mode 100644 index 15c0012f6a..c634e4b865 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/ohosTest.md @@ -1,10 +1,10 @@ -# 指定PEM格式字符串数据转换非对称密钥对测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,指定PEM格式字符串数据转换非对称密钥对(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定PEM格式字符串数据转换非对称密钥对(ArkTS),Promise方式 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 指定PEM格式字符串数据转换非对称密钥对测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,指定PEM格式字符串数据转换非对称密钥对(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定PEM格式字符串数据转换非对称密钥对(ArkTS),Promise方式 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,指定PEM格式字符串数据转换非对称密钥对(ArkTS),同步方式 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/screenshots/ConvertSpecifiedPEMAsymmetricKeyPair1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/screenshots/ConvertSpecifiedPEMAsymmetricKeyPair1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/screenshots/ConvertSpecifiedPEMAsymmetricKeyPair2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSpecifiedPEMAsymmetricKeyPair/screenshots/ConvertSpecifiedPEMAsymmetricKeyPair2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/app.json5 old mode 100755 new mode 100644 index 5ddaae415a..f8882387c7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/app.json5 @@ -1,25 +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.convertsymmetrickeybinaryformat", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.convertsymmetrickeybinaryformat", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 00781a53ea..7ee6e68683 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ConvertSymmetricKeyBinaryFormat" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ConvertSymmetricKeyBinaryFormat" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/README.md old mode 100755 new mode 100644 index 3499be5efa..49f2db0f9c --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/README.md @@ -1,80 +1,80 @@ -# 指定二进制数据转换对称密钥(C/C++) - -### 介绍 - -以3DES和HMAC为例,根据指定的对称密钥二进制数据,生成密钥(OH_CryptoSymKey),即将外部或存储的二进制数据转换为算法库的密钥对象,该对象可用于后续的加解密等操作。 - -本示例主要展示了指定二进制数据转换对称密钥(C/C++),指定二进制数据转换3DES密钥和指定二进制数据转换HMAC密钥场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [指定二进制数据转换对称密钥(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-binary-data-to-sym-key-ndk.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例ConvertSymmetricKeyBinaryFormat.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── 3des.cpp - │ │ | ├── file.h - │ │ | ├── hmac.cpp - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 指定二进制数据转换对称密钥(C/C++)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── ConvertSymmetricKeyBinaryFormat.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 指定二进制数据转换对称密钥(C/C++) + +### 介绍 + +以3DES和HMAC为例,根据指定的对称密钥二进制数据,生成密钥(OH_CryptoSymKey),即将外部或存储的二进制数据转换为算法库的密钥对象,该对象可用于后续的加解密等操作。 + +本示例主要展示了指定二进制数据转换对称密钥(C/C++),指定二进制数据转换3DES密钥和指定二进制数据转换HMAC密钥场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [指定二进制数据转换对称密钥(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-binary-data-to-sym-key-ndk.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例ConvertSymmetricKeyBinaryFormat.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── 3des.cpp + │ │ | ├── file.h + │ │ | ├── hmac.cpp + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 指定二进制数据转换对称密钥(C/C++)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── ConvertSymmetricKeyBinaryFormat.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 4bca72ebb0..01f0d79a10 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(ConvertSymmetricKeyBinaryFormat) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp types/project/3des.cpp types/project/hmac.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(ConvertSymmetricKeyBinaryFormat) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp types/project/3des.cpp types/project/hmac.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index b46e70b38c..b919b8908e --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/napi_init.cpp @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" -#include "types/project/file.h" - -static napi_value NAPI_Global_doTestDataCovertSymKey(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestDataCovertSymKey(), &ret); - return ret; -} - -static napi_value NAPI_Global_testConvertHmacKey(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, testConvertHmacKey(), &ret); - return ret; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"doTestDataCovertSymKey", nullptr, NAPI_Global_doTestDataCovertSymKey, nullptr, - nullptr, nullptr, napi_default, nullptr}, - {"testConvertHmacKey", nullptr, NAPI_Global_testConvertHmacKey, nullptr, nullptr, - nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/file.h" + +static napi_value NAPI_Global_doTestDataCovertSymKey(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestDataCovertSymKey(), &ret); + return ret; +} + +static napi_value NAPI_Global_testConvertHmacKey(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, testConvertHmacKey(), &ret); + return ret; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"doTestDataCovertSymKey", nullptr, NAPI_Global_doTestDataCovertSymKey, nullptr, + nullptr, nullptr, napi_default, nullptr}, + {"testConvertHmacKey", nullptr, NAPI_Global_testConvertHmacKey, nullptr, nullptr, + nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index 8e2a91aaa2..b845170866 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,18 +1,18 @@ -/* - * 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 doTestDataCovertSymKey: () => number; - +/* + * 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 doTestDataCovertSymKey: () => number; + export const testConvertHmacKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/3des.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/3des.cpp old mode 100755 new mode 100644 index 8d984da1d9..41834b834c --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/3des.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/3des.cpp @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_3des_key] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_key.h" -#include "file.h" - -OH_Crypto_ErrCode doTestDataCovertSymKey() -{ - const char *algName = "3DES192"; - OH_CryptoSymKeyGenerator *ctx = nullptr; - OH_CryptoSymKey *convertKeyCtx = nullptr; - Crypto_DataBlob out = {.data = nullptr, .len = 0}; - OH_Crypto_ErrCode ret; - uint8_t arr[] = {0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, 0xad, 0x47, 0xfc, 0x5a, - 0x46, 0x39, 0xee, 0x7c, 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72}; - Crypto_DataBlob convertBlob = {.data = arr, .len = sizeof(arr)}; - ret = OH_CryptoSymKeyGenerator_Create(algName, &ctx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - ret = OH_CryptoSymKeyGenerator_Convert(ctx, &convertBlob, &convertKeyCtx); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoSymKeyGenerator_Destroy(ctx); - return ret; - } - ret = OH_CryptoSymKey_GetKeyData(convertKeyCtx, &out); - OH_CryptoSymKeyGenerator_Destroy(ctx); - OH_CryptoSymKey_Destroy(convertKeyCtx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - OH_Crypto_FreeDataBlob(&out); - return ret; -} -// [End generate_3des_key] - +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_3des_key] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_key.h" +#include "file.h" + +OH_Crypto_ErrCode doTestDataCovertSymKey() +{ + const char *algName = "3DES192"; + OH_CryptoSymKeyGenerator *ctx = nullptr; + OH_CryptoSymKey *convertKeyCtx = nullptr; + Crypto_DataBlob out = {.data = nullptr, .len = 0}; + OH_Crypto_ErrCode ret; + uint8_t arr[] = {0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, 0xad, 0x47, 0xfc, 0x5a, + 0x46, 0x39, 0xee, 0x7c, 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72}; + Crypto_DataBlob convertBlob = {.data = arr, .len = sizeof(arr)}; + ret = OH_CryptoSymKeyGenerator_Create(algName, &ctx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + ret = OH_CryptoSymKeyGenerator_Convert(ctx, &convertBlob, &convertKeyCtx); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoSymKeyGenerator_Destroy(ctx); + return ret; + } + ret = OH_CryptoSymKey_GetKeyData(convertKeyCtx, &out); + OH_CryptoSymKeyGenerator_Destroy(ctx); + OH_CryptoSymKey_Destroy(convertKeyCtx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + OH_Crypto_FreeDataBlob(&out); + return ret; +} +// [End generate_3des_key] + diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/file.h b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/file.h old mode 100755 new mode 100644 index 0014c8f10b..2169066f1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/file.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/file.h @@ -1,23 +1,23 @@ -#ifndef FILE_H -#define FILE_H -/* - * 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 "CryptoArchitectureKit/crypto_common.h" - -OH_Crypto_ErrCode doTestDataCovertSymKey(); -OH_Crypto_ErrCode testConvertHmacKey(); - +#ifndef FILE_H +#define FILE_H +/* + * 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 "CryptoArchitectureKit/crypto_common.h" + +OH_Crypto_ErrCode doTestDataCovertSymKey(); +OH_Crypto_ErrCode testConvertHmacKey(); + #endif // FILE_H \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/hmac.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/hmac.cpp old mode 100755 new mode 100644 index f320e6c05a..fb71685be5 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/hmac.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/cpp/types/project/hmac.cpp @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_hmac_key] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_key.h" -#include -#include "file.h" - -OH_Crypto_ErrCode testConvertHmacKey() -{ - const char *algName = "HMAC"; - OH_CryptoSymKeyGenerator *ctx = nullptr; - OH_CryptoSymKey *convertKeyCtx = nullptr; - Crypto_DataBlob out = {.data = nullptr, .len = 0}; - OH_Crypto_ErrCode ret; - - char *arr = const_cast("12345678abcdefgh12345678abcdefgh12345678abcdefgh12345678abcdefgh"); - Crypto_DataBlob convertBlob = {.data = (uint8_t *)(arr), .len = strlen(arr)}; - ret = OH_CryptoSymKeyGenerator_Create(algName, &ctx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - ret = OH_CryptoSymKeyGenerator_Convert(ctx, &convertBlob, &convertKeyCtx); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoSymKeyGenerator_Destroy(ctx); - return ret; - } - ret = OH_CryptoSymKey_GetKeyData(convertKeyCtx, &out); - OH_CryptoSymKeyGenerator_Destroy(ctx); - OH_CryptoSymKey_Destroy(convertKeyCtx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - OH_Crypto_FreeDataBlob(&out); - return ret; -} -// [End generate_hmac_key] - +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_hmac_key] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_key.h" +#include +#include "file.h" + +OH_Crypto_ErrCode testConvertHmacKey() +{ + const char *algName = "HMAC"; + OH_CryptoSymKeyGenerator *ctx = nullptr; + OH_CryptoSymKey *convertKeyCtx = nullptr; + Crypto_DataBlob out = {.data = nullptr, .len = 0}; + OH_Crypto_ErrCode ret; + + char *arr = const_cast("12345678abcdefgh12345678abcdefgh12345678abcdefgh12345678abcdefgh"); + Crypto_DataBlob convertBlob = {.data = (uint8_t *)(arr), .len = strlen(arr)}; + ret = OH_CryptoSymKeyGenerator_Create(algName, &ctx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + ret = OH_CryptoSymKeyGenerator_Convert(ctx, &convertBlob, &convertKeyCtx); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoSymKeyGenerator_Destroy(ctx); + return ret; + } + ret = OH_CryptoSymKey_GetKeyData(convertKeyCtx, &out); + OH_CryptoSymKeyGenerator_Destroy(ctx); + OH_CryptoSymKey_Destroy(convertKeyCtx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + OH_Crypto_FreeDataBlob(&out); + return ret; +} +// [End generate_hmac_key] + diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index a36ca588fe..965554bb3a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index a17ad623c7..bf0e19bee7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/ets/pages/Index.ets @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'ConvertSymmetricKeyBinaryFormat'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.3des')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.doTestDataCovertSymKey(); - this.message = '3DES Success Result:' + ret.toString(); - }) - Button($r('app.string.hmac')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testConvertHmacKey(); - this.message = 'HMAC Success Result:' + ret.toString(); - }) - } - .width('100%') - .height('100%') - } -} +/* + * 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 { + @State message: string = 'ConvertSymmetricKeyBinaryFormat'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.3des')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.doTestDataCovertSymKey(); + this.message = '3DES Success Result:' + ret.toString(); + }) + Button($r('app.string.hmac')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testConvertHmacKey(); + this.message = 'HMAC Success Result:' + ret.toString(); + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/ConvertSymmetricKeyBinaryFormat.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/ConvertSymmetricKeyBinaryFormat.test.ets old mode 100755 new mode 100644 index 20a5acac40..fa05a8de55 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/ConvertSymmetricKeyBinaryFormat.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/ConvertSymmetricKeyBinaryFormat.test.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function convertSymmetricKeyBinaryFormatTest() { - describe('convertSymmetricKeyBinaryFormatTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,指定二进制数据转换对称密钥(3DES) - */ - it('testConvertSymmetricKeyBinaryFormat001', 0, async () => { - console.info('uitest: testConvertSymmetricKeyBinaryFormat001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('3DES')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('3DES Success Result:0')); - console.info('uitest: testConvertSymmetricKeyBinaryFormat001 end'); - }) - - /** - * 点击按钮,指定二进制数据转换对称密钥(HMAC) - */ - it('testConvertSymmetricKeyBinaryFormat002', 0, async () => { - console.info('uitest: testConvertSymmetricKeyBinaryFormat002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('HMAC')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('HMAC Success Result:0')); - console.info('uitest: testConvertSymmetricKeyBinaryFormat002 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function convertSymmetricKeyBinaryFormatTest() { + describe('convertSymmetricKeyBinaryFormatTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,指定二进制数据转换对称密钥(3DES) + */ + it('testConvertSymmetricKeyBinaryFormat001', 0, async () => { + console.info('uitest: testConvertSymmetricKeyBinaryFormat001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('3DES')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('3DES Success Result:0')); + console.info('uitest: testConvertSymmetricKeyBinaryFormat001 end'); + }) + + /** + * 点击按钮,指定二进制数据转换对称密钥(HMAC) + */ + it('testConvertSymmetricKeyBinaryFormat002', 0, async () => { + console.info('uitest: testConvertSymmetricKeyBinaryFormat002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('HMAC')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('HMAC Success Result:0')); + console.info('uitest: testConvertSymmetricKeyBinaryFormat002 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/ohosTest.md old mode 100755 new mode 100644 index b0efe41b95..3d0857ee55 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/ohosTest.md @@ -1,9 +1,9 @@ -# 指定二进制数据转换对称密钥(C/C++)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,指定二进制数据转换对称密钥(3DES) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 指定二进制数据转换对称密钥(C/C++)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,指定二进制数据转换对称密钥(3DES) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,指定二进制数据转换对称密钥(HMAC) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/screenshots/ConvertSymmetricKeyBinaryFormat1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/screenshots/ConvertSymmetricKeyBinaryFormat1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/screenshots/ConvertSymmetricKeyBinaryFormat2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormat/screenshots/ConvertSymmetricKeyBinaryFormat2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/app.json5 old mode 100755 new mode 100644 index 98bb06c359..13a98cdee5 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/app.json5 @@ -1,25 +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.convertsymmetrickeybinaryformatarkts", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.convertsymmetrickeybinaryformatarkts", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index d0bbf57c68..9e746ecc17 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ConvertSymmetricKeyBinaryFormatArkTS" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ConvertSymmetricKeyBinaryFormatArkTS" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/README.md old mode 100755 new mode 100644 index 89c4fc9a4c..e0e73fa912 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/README.md @@ -1,75 +1,75 @@ -# 指定二进制数据转换对称密钥(ArkTS) - -### 介绍 - -以3DES和HMAC为例,根据指定的对称密钥二进制数据,生成密钥(SymKey),即将外部或存储的二进制数据转换为算法库的密钥对象,该对象可用于后续的加解密等操作。 - -本示例主要展示了指定二进制数据转换对称密钥(ArkTS),指定二进制数据转换3DES密钥和指定二进制数据转换HMAC密钥场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [指定二进制数据转换对称密钥(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-binary-data-to-sym-key.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例ConvertSymmetricKeyBinaryFormatArkTS.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 指定二进制数据转换对称密钥(ArkTS)示例代码 - │ │ ├── 3des - │ │ | ├── Callback.ets - │ │ | ├── Sync.ets - │ │ ├── hmac - │ │ | ├── Await.ets - │ │ | ├── Sync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── ConvertSymmetricKeyBinaryFormatArkTS.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 指定二进制数据转换对称密钥(ArkTS) + +### 介绍 + +以3DES和HMAC为例,根据指定的对称密钥二进制数据,生成密钥(SymKey),即将外部或存储的二进制数据转换为算法库的密钥对象,该对象可用于后续的加解密等操作。 + +本示例主要展示了指定二进制数据转换对称密钥(ArkTS),指定二进制数据转换3DES密钥和指定二进制数据转换HMAC密钥场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [指定二进制数据转换对称密钥(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-binary-data-to-sym-key.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例ConvertSymmetricKeyBinaryFormatArkTS.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 指定二进制数据转换对称密钥(ArkTS)示例代码 + │ │ ├── 3des + │ │ | ├── Callback.ets + │ │ | ├── Sync.ets + │ │ ├── hmac + │ │ | ├── Await.ets + │ │ | ├── Sync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── ConvertSymmetricKeyBinaryFormatArkTS.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/3des/Callback.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/3des/Callback.ets old mode 100755 new mode 100644 index f628f89c58..28755c5466 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/3des/Callback.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/3des/Callback.ets @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_3des_key] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -function genKeyMaterialBlob(): cryptoFramework.DataBlob { - let arr = [ - 0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, - 0xad, 0x47, 0xfc, 0x5a, 0x46, 0x39, 0xee, 0x7c, - 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72]; // 密钥长度为192位,即24字节。 - let keyMaterial = new Uint8Array(arr); - return { data: keyMaterial }; -} - -function testConvertSymKey() { - // 创建SymKeyGenerator实例 - let symKeyGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); - // 根据指定的数据生成对称密钥 - let keyMaterialBlob = genKeyMaterialBlob(); - try { - symKeyGenerator.convertKey(keyMaterialBlob, (error, key) => { - if (error) { // 如果业务逻辑执行失败,则callback的第一个参数返回错误信息,即异步抛出异常 - let e: BusinessError = error as BusinessError; - console.error(`convertKey error, ${e.code}, ${e.message}`); - return; - } - console.info('key algName:' + key.algName); - console.info('key format:' + key.format); - let encodedKey = key.getEncoded(); // 获取对称密钥的二进制数据,并以字节数组形式输出。长度为24字节 - console.info('key getEncoded hex: ' + encodedKey.data); - }) - } catch (error) { // 参数检查发现错误立即抛出异常 - let e: BusinessError = error as BusinessError; - console.error(`convertKey failed, ${e.code}, ${e.message}`); - } -} -// [End generate_3des_key] - -@Entry -@Component -struct Index { - @State message: string = 'Callback'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_3des_callback')) - .width('70%') - .onClick(() => { - try { - testConvertSymKey(); - this.message = '3DES Callback Success'; - } catch { - this.message = '3DES Callback Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_3des_key] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +function genKeyMaterialBlob(): cryptoFramework.DataBlob { + let arr = [ + 0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, + 0xad, 0x47, 0xfc, 0x5a, 0x46, 0x39, 0xee, 0x7c, + 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72]; // 密钥长度为192位,即24字节。 + let keyMaterial = new Uint8Array(arr); + return { data: keyMaterial }; +} + +function testConvertSymKey() { + // 创建SymKeyGenerator实例 + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); + // 根据指定的数据生成对称密钥 + let keyMaterialBlob = genKeyMaterialBlob(); + try { + symKeyGenerator.convertKey(keyMaterialBlob, (error, key) => { + if (error) { // 如果业务逻辑执行失败,则callback的第一个参数返回错误信息,即异步抛出异常 + let e: BusinessError = error as BusinessError; + console.error(`convertKey error, ${e.code}, ${e.message}`); + return; + } + console.info('key algName:' + key.algName); + console.info('key format:' + key.format); + let encodedKey = key.getEncoded(); // 获取对称密钥的二进制数据,并以字节数组形式输出。长度为24字节 + console.info('key getEncoded hex: ' + encodedKey.data); + }) + } catch (error) { // 参数检查发现错误立即抛出异常 + let e: BusinessError = error as BusinessError; + console.error(`convertKey failed, ${e.code}, ${e.message}`); + } +} +// [End generate_3des_key] + +@Entry +@Component +struct Index { + @State message: string = 'Callback'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_3des_callback')) + .width('70%') + .onClick(() => { + try { + testConvertSymKey(); + this.message = '3DES Callback Success'; + } catch { + this.message = '3DES Callback Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/3des/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/3des/Sync.ets old mode 100755 new mode 100644 index 0167185aa6..69484cf5fa --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/3des/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/3des/Sync.ets @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_3des_key_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -function genKeyMaterialBlob(): cryptoFramework.DataBlob { - let arr = [ - 0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, - 0xad, 0x47, 0xfc, 0x5a, 0x46, 0x39, 0xee, 0x7c, - 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72]; // 密钥长度为192位,即24字节。 - let keyMaterial = new Uint8Array(arr); - return { data: keyMaterial }; -} - -function testConvertSymKey() { - // 创建SymKeyGenerator实例 - let symKeyGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); - // 根据指定的数据生成对称密钥 - let keyMaterialBlob = genKeyMaterialBlob(); - try { - symKeyGenerator.convertKey(keyMaterialBlob, (error, key) => { - if (error) { // 如果业务逻辑执行失败,则callback的第一个参数返回错误信息,即异步抛出异常 - let e: BusinessError = error as BusinessError; - console.error(`convertKey error, ${e.code}, ${e.message}`); - return; - } - console.info('key algName:' + key.algName); - console.info('key format:' + key.format); - let encodedKey = key.getEncoded(); // 获取对称密钥的二进制数据,并以字节数组形式输出。长度为24字节 - console.info('key getEncoded hex: ' + encodedKey.data); - }) - } catch (error) { // 参数检查发现错误立即抛出异常 - let e: BusinessError = error as BusinessError; - console.error(`convertKey failed, ${e.code}, ${e.message}`); - } -} -// [End generate_3des_key_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_3des_sync')) - .width('70%') - .onClick(() => { - try { - testConvertSymKey(); - this.message = '3DES Sync Success'; - } catch { - this.message = '3DES Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_3des_key_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +function genKeyMaterialBlob(): cryptoFramework.DataBlob { + let arr = [ + 0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, + 0xad, 0x47, 0xfc, 0x5a, 0x46, 0x39, 0xee, 0x7c, + 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72]; // 密钥长度为192位,即24字节。 + let keyMaterial = new Uint8Array(arr); + return { data: keyMaterial }; +} + +function testConvertSymKey() { + // 创建SymKeyGenerator实例 + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); + // 根据指定的数据生成对称密钥 + let keyMaterialBlob = genKeyMaterialBlob(); + try { + symKeyGenerator.convertKey(keyMaterialBlob, (error, key) => { + if (error) { // 如果业务逻辑执行失败,则callback的第一个参数返回错误信息,即异步抛出异常 + let e: BusinessError = error as BusinessError; + console.error(`convertKey error, ${e.code}, ${e.message}`); + return; + } + console.info('key algName:' + key.algName); + console.info('key format:' + key.format); + let encodedKey = key.getEncoded(); // 获取对称密钥的二进制数据,并以字节数组形式输出。长度为24字节 + console.info('key getEncoded hex: ' + encodedKey.data); + }) + } catch (error) { // 参数检查发现错误立即抛出异常 + let e: BusinessError = error as BusinessError; + console.error(`convertKey failed, ${e.code}, ${e.message}`); + } +} +// [End generate_3des_key_sync] + +@Entry +@Component +struct Index { + @State message: string = 'Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_3des_sync')) + .width('70%') + .onClick(() => { + try { + testConvertSymKey(); + this.message = '3DES Sync Success'; + } catch { + this.message = '3DES Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/hmac/Await.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/hmac/Await.ets old mode 100755 new mode 100644 index e98f137c15..f211f4d212 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/hmac/Await.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/hmac/Await.ets @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_hmac_key] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -async function testConvertHmacKey() { - // 对称密钥长度为64字节,512比特 - let keyMessage = '12345678abcdefgh12345678abcdefgh12345678abcdefgh12345678abcdefgh'; - let keyBlob: cryptoFramework.DataBlob = { - data: new Uint8Array(buffer.from(keyMessage, 'utf-8').buffer) - } - let symKeyGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); - let key = await symKeyGenerator.convertKey(keyBlob); - let encodedKey = key.getEncoded(); - console.info('key encoded data:' + encodedKey.data); -} -// [End generate_hmac_key] - -@Entry -@Component -struct Index { - @State message: string = 'Await'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_hmac_await')) - .width('70%') - .onClick(async () => { - try { - await testConvertHmacKey(); - this.message = 'HMAC Await Success'; - } catch { - this.message = 'HMAC Await Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_hmac_key] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +async function testConvertHmacKey() { + // 对称密钥长度为64字节,512比特 + let keyMessage = '12345678abcdefgh12345678abcdefgh12345678abcdefgh12345678abcdefgh'; + let keyBlob: cryptoFramework.DataBlob = { + data: new Uint8Array(buffer.from(keyMessage, 'utf-8').buffer) + } + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); + let key = await symKeyGenerator.convertKey(keyBlob); + let encodedKey = key.getEncoded(); + console.info('key encoded data:' + encodedKey.data); +} +// [End generate_hmac_key] + +@Entry +@Component +struct Index { + @State message: string = 'Await'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_hmac_await')) + .width('70%') + .onClick(async () => { + try { + await testConvertHmacKey(); + this.message = 'HMAC Await Success'; + } catch { + this.message = 'HMAC Await Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/hmac/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/hmac/Sync.ets old mode 100755 new mode 100644 index 128d2d71f6..de13360714 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/hmac/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/ets/pages/hmac/Sync.ets @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_hmac_key_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function testConvertKeySync() { - // 对称密钥长度为64字节,512比特 - let keyMessage = '12345678abcdefgh12345678abcdefgh12345678abcdefgh12345678abcdefgh'; - let keyBlob: cryptoFramework.DataBlob = { - data : new Uint8Array(buffer.from(keyMessage, 'utf-8').buffer) - } - let symKeyGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); - let key = symKeyGenerator.convertKeySync(keyBlob); - let encodedKey = key.getEncoded(); - console.info('key encoded data:' + encodedKey.data); -} -// [End generate_hmac_key_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_hmac_sync')) - .width('70%') - .onClick(() => { - try { - testConvertKeySync(); - this.message = 'HMAC Sync Success'; - } catch { - this.message = 'HMAC Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_hmac_key_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function testConvertKeySync() { + // 对称密钥长度为64字节,512比特 + let keyMessage = '12345678abcdefgh12345678abcdefgh12345678abcdefgh12345678abcdefgh'; + let keyBlob: cryptoFramework.DataBlob = { + data : new Uint8Array(buffer.from(keyMessage, 'utf-8').buffer) + } + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); + let key = symKeyGenerator.convertKeySync(keyBlob); + let encodedKey = key.getEncoded(); + console.info('key encoded data:' + encodedKey.data); +} +// [End generate_hmac_key_sync] + +@Entry +@Component +struct Index { + @State message: string = 'Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_hmac_sync')) + .width('70%') + .onClick(() => { + try { + testConvertKeySync(); + this.message = 'HMAC Sync Success'; + } catch { + this.message = 'HMAC Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/ConvertSymmetricKeyBinaryFormatArkTS.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/ConvertSymmetricKeyBinaryFormatArkTS.test.ets old mode 100755 new mode 100644 index 2d9ad30904..acd0bdd3c5 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/ConvertSymmetricKeyBinaryFormatArkTS.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/ConvertSymmetricKeyBinaryFormatArkTS.test.ets @@ -1,116 +1,116 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function convertSymmetricKeyBinaryFormatArkTSTest() { - describe('convertSymmetricKeyBinaryFormatArkTSTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,指定二进制数据转换对称密钥(3DES callback方式) - */ - it('testConvertSymmetricKeyBinaryFormatArkTS001', 0, async () => { - console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('3DES Callback')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call 3DES Callback')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('3DES Callback Success')); - console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定二进制数据转换对称密钥(3DES 同步方式) - */ - it('testConvertSymmetricKeyBinaryFormatArkTS002', 0, async () => { - console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('3DES Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call 3DES Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('3DES Sync Success')); - console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定二进制数据转换对称密钥(HMAC await方式) - */ - it('testConvertSymmetricKeyBinaryFormatArkTS003', 0, async () => { - console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('HMAC Await')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call HMAC Await')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('HMAC Await Success')); - console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定二进制数据转换对称密钥(HMAC 同步方式) - */ - it('testConvertSymmetricKeyBinaryFormatArkTS004', 0, async () => { - console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('HMAC Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call HMAC Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('HMAC Sync Success')); - console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS004 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function convertSymmetricKeyBinaryFormatArkTSTest() { + describe('convertSymmetricKeyBinaryFormatArkTSTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,指定二进制数据转换对称密钥(3DES callback方式) + */ + it('testConvertSymmetricKeyBinaryFormatArkTS001', 0, async () => { + console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('3DES Callback')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call 3DES Callback')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('3DES Callback Success')); + console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定二进制数据转换对称密钥(3DES 同步方式) + */ + it('testConvertSymmetricKeyBinaryFormatArkTS002', 0, async () => { + console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('3DES Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call 3DES Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('3DES Sync Success')); + console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定二进制数据转换对称密钥(HMAC await方式) + */ + it('testConvertSymmetricKeyBinaryFormatArkTS003', 0, async () => { + console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('HMAC Await')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call HMAC Await')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('HMAC Await Success')); + console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定二进制数据转换对称密钥(HMAC 同步方式) + */ + it('testConvertSymmetricKeyBinaryFormatArkTS004', 0, async () => { + console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('HMAC Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call HMAC Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('HMAC Sync Success')); + console.info('uitest: testConvertSymmetricKeyBinaryFormatArkTS004 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/ohosTest.md old mode 100755 new mode 100644 index ef892568aa..2d2602064b --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/ohosTest.md @@ -1,11 +1,11 @@ -# 指定二进制数据转换对称密钥(ArkTS)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,指定二进制数据转换对称密钥(3DES callback方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定二进制数据转换对称密钥(3DES 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定二进制数据转换对称密钥(HMAC await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 指定二进制数据转换对称密钥(ArkTS)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,指定二进制数据转换对称密钥(3DES callback方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定二进制数据转换对称密钥(3DES 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定二进制数据转换对称密钥(HMAC await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,指定二进制数据转换对称密钥(HMAC 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/screenshots/ConvertSymmetricKeyBinaryFormatArkTS1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/screenshots/ConvertSymmetricKeyBinaryFormatArkTS1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/screenshots/ConvertSymmetricKeyBinaryFormatArkTS2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ConvertSymmetricKeyBinaryFormatArkTS/screenshots/ConvertSymmetricKeyBinaryFormatArkTS2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/app.json5 old mode 100755 new mode 100644 index f0e59de766..4bd0fd9f00 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/app.json5 @@ -1,25 +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.ecccompresspublickeyformatconversion", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.ecccompresspublickeyformatconversion", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 0b4c15377a..e741108c2e --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ECCCompressPublicKeyFormatConversion" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ECCCompressPublicKeyFormatConversion" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/README.md old mode 100755 new mode 100644 index 7de12b007c..08e4d78cab --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/README.md @@ -1,84 +1,84 @@ -# 使用ECC压缩/非压缩格式转换 - -### 介绍 - -可通过指定ECC公钥数据,生成公钥对象(PubKey);也可从公钥对象(PubKey)中,获取ECC公钥数据。当前仅支持ECC算法中,满足X509规范的压缩/非压缩格式的公钥数据。此处的公钥数据应当是完整的X509公钥,对于只使用点数据的情况. - -本示例主要展示了使用ECC压缩/非压缩公钥格式转换(ArkTS)、使用ECC压缩/非压缩公钥格式转换(C/C++)、使用ECC压缩/非压缩点格式转换场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [使用ECC压缩/非压缩公钥格式转换(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-compressed-or-uncompressed-ECC-pubkey.md) -- [使用ECC压缩/非压缩公钥格式转换(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-compressed-or-uncompressed-ECC-pubkey-ndk.md) -- [使用ECC压缩/非压缩点格式转换](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-compressed-or-uncompressed-ECC-point.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例ECCCompressPublicKeyFormatConversion.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── specifyUncompressedPublicKey.cpp - │ │ | ├── file.h - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 使用ECC压缩/非压缩格式转换示例代码 - │ │ ├── CompressedPointData.ets - │ │ ├── GetKeyObject.ets - │ │ ├── SpecifyUncompressedPublicKey.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── ECCCompressPublicKeyFormatConversion.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 使用ECC压缩/非压缩格式转换 + +### 介绍 + +可通过指定ECC公钥数据,生成公钥对象(PubKey);也可从公钥对象(PubKey)中,获取ECC公钥数据。当前仅支持ECC算法中,满足X509规范的压缩/非压缩格式的公钥数据。此处的公钥数据应当是完整的X509公钥,对于只使用点数据的情况. + +本示例主要展示了使用ECC压缩/非压缩公钥格式转换(ArkTS)、使用ECC压缩/非压缩公钥格式转换(C/C++)、使用ECC压缩/非压缩点格式转换场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [使用ECC压缩/非压缩公钥格式转换(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-compressed-or-uncompressed-ECC-pubkey.md) +- [使用ECC压缩/非压缩公钥格式转换(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-compressed-or-uncompressed-ECC-pubkey-ndk.md) +- [使用ECC压缩/非压缩点格式转换](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-convert-compressed-or-uncompressed-ECC-point.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例ECCCompressPublicKeyFormatConversion.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── specifyUncompressedPublicKey.cpp + │ │ | ├── file.h + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 使用ECC压缩/非压缩格式转换示例代码 + │ │ ├── CompressedPointData.ets + │ │ ├── GetKeyObject.ets + │ │ ├── SpecifyUncompressedPublicKey.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── ECCCompressPublicKeyFormatConversion.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 07e5f6b78a..99340164a1 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(ECCCompressPublicKeyFormatConversion) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp types/project/specifyUncompressedPublicKey.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(ECCCompressPublicKeyFormatConversion) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp types/project/specifyUncompressedPublicKey.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 7e5e45dba0..fb04405809 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/napi_init.cpp @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" -#include "types/project/file.h" - -static napi_value NAPI_Global_doTestEccDataCovert(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestEccDataCovert(), &ret); - return ret; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"doTestEccDataCovert", nullptr, NAPI_Global_doTestEccDataCovert, nullptr, - nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/file.h" + +static napi_value NAPI_Global_doTestEccDataCovert(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestEccDataCovert(), &ret); + return ret; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"doTestEccDataCovert", nullptr, NAPI_Global_doTestEccDataCovert, nullptr, + nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index 351b95574f..7ace52c4f4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 doTestEccDataCovert: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/project/file.h b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/project/file.h old mode 100755 new mode 100644 index 46646f6b1a..028afbe0eb --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/project/file.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/project/file.h @@ -1,22 +1,22 @@ -#ifndef FILE_H -#define FILE_H -/* - * 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 "CryptoArchitectureKit/crypto_common.h" - -OH_Crypto_ErrCode doTestEccDataCovert(); - +#ifndef FILE_H +#define FILE_H +/* + * 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 "CryptoArchitectureKit/crypto_common.h" + +OH_Crypto_ErrCode doTestEccDataCovert(); + #endif // FILE_H \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/project/specifyUncompressedPublicKey.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/project/specifyUncompressedPublicKey.cpp old mode 100755 new mode 100644 index 5a56ee2444..a7f83d5f51 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/project/specifyUncompressedPublicKey.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/cpp/types/project/specifyUncompressedPublicKey.cpp @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start convert_ecc_uncompressed_pub_keypair] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_asym_key.h" - -OH_Crypto_ErrCode doTestEccDataCovert() -{ - OH_CryptoAsymKeyGenerator *generator = nullptr; - OH_CryptoKeyPair *keyPair = nullptr; - Crypto_DataBlob returnBlob = { .data = nullptr, .len = 0 }; - OH_Crypto_ErrCode ret = CRYPTO_INVALID_PARAMS; - - ret = OH_CryptoAsymKeyGenerator_Create("ECC_BrainPoolP256r1", &generator); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - uint8_t pubKeyBlobData[] = { - 48, 90, 48, 20, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 9, 43, 36, 3, 3, 2, - 8, 1, 1, 7, 3, 66, 0, 4, 143, 39, 57, 249, 145, 50, 63, 222, 35, 70, 178, - 121, 202, 154, 21, 146, 129, 75, 76, 63, 8, 195, 157, 111, 40, 217, 215, - 148, 120, 224, 205, 82, 83, 92, 185, 21, 211, 184, 5, 19, 114, 33, 86, 85, - 228, 123, 242, 206, 200, 98, 178, 184, 130, 35, 232, 45, 5, 202, 189, 11, - 46, 163, 156, 152 - }; - Crypto_DataBlob pubKeyUncompressedBlob = { - .data = pubKeyBlobData, - .len = sizeof(pubKeyBlobData), - }; - ret = OH_CryptoAsymKeyGenerator_Convert(generator, CRYPTO_DER, &pubKeyUncompressedBlob, nullptr, &keyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(generator); - return ret; - } - - OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); - ret = OH_CryptoPubKey_Encode(pubKey, CRYPTO_DER, "X509|COMPRESSED", &returnBlob); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(generator); - OH_CryptoKeyPair_Destroy(keyPair); - return ret; - } - OH_CryptoAsymKeyGenerator_Destroy(generator); - OH_CryptoKeyPair_Destroy(keyPair); - return ret; -} -// [End convert_ecc_uncompressed_pub_keypair] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start convert_ecc_uncompressed_pub_keypair] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_asym_key.h" + +OH_Crypto_ErrCode doTestEccDataCovert() +{ + OH_CryptoAsymKeyGenerator *generator = nullptr; + OH_CryptoKeyPair *keyPair = nullptr; + Crypto_DataBlob returnBlob = { .data = nullptr, .len = 0 }; + OH_Crypto_ErrCode ret = CRYPTO_INVALID_PARAMS; + + ret = OH_CryptoAsymKeyGenerator_Create("ECC_BrainPoolP256r1", &generator); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + uint8_t pubKeyBlobData[] = { + 48, 90, 48, 20, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 9, 43, 36, 3, 3, 2, + 8, 1, 1, 7, 3, 66, 0, 4, 143, 39, 57, 249, 145, 50, 63, 222, 35, 70, 178, + 121, 202, 154, 21, 146, 129, 75, 76, 63, 8, 195, 157, 111, 40, 217, 215, + 148, 120, 224, 205, 82, 83, 92, 185, 21, 211, 184, 5, 19, 114, 33, 86, 85, + 228, 123, 242, 206, 200, 98, 178, 184, 130, 35, 232, 45, 5, 202, 189, 11, + 46, 163, 156, 152 + }; + Crypto_DataBlob pubKeyUncompressedBlob = { + .data = pubKeyBlobData, + .len = sizeof(pubKeyBlobData), + }; + ret = OH_CryptoAsymKeyGenerator_Convert(generator, CRYPTO_DER, &pubKeyUncompressedBlob, nullptr, &keyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(generator); + return ret; + } + + OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); + ret = OH_CryptoPubKey_Encode(pubKey, CRYPTO_DER, "X509|COMPRESSED", &returnBlob); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(generator); + OH_CryptoKeyPair_Destroy(keyPair); + return ret; + } + OH_CryptoAsymKeyGenerator_Destroy(generator); + OH_CryptoKeyPair_Destroy(keyPair); + return ret; +} +// [End convert_ecc_uncompressed_pub_keypair] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index a36ca588fe..965554bb3a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/CompressedPointData.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/CompressedPointData.ets old mode 100755 new mode 100644 index 80c042b09c..1d6385c690 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/CompressedPointData.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/CompressedPointData.ets @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start convert_ecc_uncompressed_point] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function eccPointUncompressedToCompressed() { - let pkData = - new Uint8Array([4, 143, 39, 57, 249, 145, 50, 63, 222, 35, 70, 178, 121, 202, 154, 21, 146, 129, 75, 76, 63, 8, 195, - 157, 111, 40, 217, 215, 148, 120, 224, 205, 82, 83, 92, 185, 21, 211, 184, 5, 19, 114, 33, 86, 85, 228, 123, 242, - 206, 200, 98, 178, 184, 130, 35, 232, 45, 5, 202, 189, 11, 46, 163, 156, 152]); - let returnPoint = cryptoFramework.ECCKeyUtil.convertPoint('NID_brainpoolP256r1', pkData); - console.info('convertPoint success'); - let returnData = cryptoFramework.ECCKeyUtil.getEncodedPoint('NID_brainpoolP256r1', returnPoint, 'COMPRESSED'); - console.info('returnData: ' + - returnData); // (因为y为偶数,所以压缩点数据的前缀是02)returnData: 2,143,39,57,249,145,50,63,222,35,70,178,121,202,154,21, - // 146,129,75,76,63,8,195,157,111,40,217,215,148,120,224,205,82 -} -// [End convert_ecc_uncompressed_point] - -@Entry -@Component -struct Index { - @State message: string = 'CompressedPointData'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_compressedPointData')) - .width('70%') - .onClick(() => { - try { - eccPointUncompressedToCompressed(); - this.message = 'CompressedPointData Success'; - } catch { - this.message = 'CompressedPointData Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start convert_ecc_uncompressed_point] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function eccPointUncompressedToCompressed() { + let pkData = + new Uint8Array([4, 143, 39, 57, 249, 145, 50, 63, 222, 35, 70, 178, 121, 202, 154, 21, 146, 129, 75, 76, 63, 8, 195, + 157, 111, 40, 217, 215, 148, 120, 224, 205, 82, 83, 92, 185, 21, 211, 184, 5, 19, 114, 33, 86, 85, 228, 123, 242, + 206, 200, 98, 178, 184, 130, 35, 232, 45, 5, 202, 189, 11, 46, 163, 156, 152]); + let returnPoint = cryptoFramework.ECCKeyUtil.convertPoint('NID_brainpoolP256r1', pkData); + console.info('convertPoint success'); + let returnData = cryptoFramework.ECCKeyUtil.getEncodedPoint('NID_brainpoolP256r1', returnPoint, 'COMPRESSED'); + console.info('returnData: ' + + returnData); // (因为y为偶数,所以压缩点数据的前缀是02)returnData: 2,143,39,57,249,145,50,63,222,35,70,178,121,202,154,21, + // 146,129,75,76,63,8,195,157,111,40,217,215,148,120,224,205,82 +} +// [End convert_ecc_uncompressed_point] + +@Entry +@Component +struct Index { + @State message: string = 'CompressedPointData'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_compressedPointData')) + .width('70%') + .onClick(() => { + try { + eccPointUncompressedToCompressed(); + this.message = 'CompressedPointData Success'; + } catch { + this.message = 'CompressedPointData Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/GetKeyObject.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/GetKeyObject.ets old mode 100755 new mode 100644 index 92a7bc04a9..5a01bdf194 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/GetKeyObject.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/GetKeyObject.ets @@ -1,69 +1,69 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start specify_ecc_uncompressed_point_get_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -async function eccPointCompressedToPoint() { - let pkData = - new Uint8Array([2, 143, 39, 57, 249, 145, 50, 63, 222, 35, 70, 178, 121, 202, 154, 21, 146, 129, 75, 76, 63, 8, 195, - 157, 111, 40, 217, 215, 148, 120, 224, 205, 82]); - let returnPoint = cryptoFramework.ECCKeyUtil.convertPoint('NID_brainpoolP256r1', pkData); - console.info('convertPoint success'); - let eccCommonParamsSpec = cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_brainpoolP256r1'); - let eccPubKeySpec: cryptoFramework.ECCPubKeySpec = { - algName: 'ECC', - specType: cryptoFramework.AsyKeySpecType.PUBLIC_KEY_SPEC, - params: eccCommonParamsSpec, - pk: returnPoint - }; - let generatorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(eccPubKeySpec); - let pubKey = await generatorBySpec.generatePubKey(); - let returnData = cryptoFramework.ECCKeyUtil.getEncodedPoint('NID_brainpoolP256r1', returnPoint, 'UNCOMPRESSED'); - console.info('returnData: ' + - returnData); // 4,143,39,57,249,145,50,63,222,35,70,178,121,202,154,21,146,129,75,76,63,8,195,157,111, - // 40,217,215,148,120,224,205,82,83,92,185,21,211,184,5,19,114,33,86,85,228,123,242,206,200,98,178,184, - // 130,35,232,45,5,202,189,11,46,163,156,152 - let eccPkX = pubKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_PK_X_BN); - console.info('returnPoint x data: ' + - returnPoint.x); // 64750044510792891439269945828433327517677381559622384455951527515863444933970 - console.info('ECC_PK_X_BN:' + - eccPkX); // 64750044510792891439269945828433327517677381559622384455951527515863444933970 -} -// [End specify_ecc_uncompressed_point_get_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'GetKeyObject'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_getKeyObject')) - .width('70%') - .onClick(async () => { - try { - await eccPointCompressedToPoint(); - this.message = 'GetKeyObject Success'; - } catch { - this.message = 'GetKeyObject Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start specify_ecc_uncompressed_point_get_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +async function eccPointCompressedToPoint() { + let pkData = + new Uint8Array([2, 143, 39, 57, 249, 145, 50, 63, 222, 35, 70, 178, 121, 202, 154, 21, 146, 129, 75, 76, 63, 8, 195, + 157, 111, 40, 217, 215, 148, 120, 224, 205, 82]); + let returnPoint = cryptoFramework.ECCKeyUtil.convertPoint('NID_brainpoolP256r1', pkData); + console.info('convertPoint success'); + let eccCommonParamsSpec = cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_brainpoolP256r1'); + let eccPubKeySpec: cryptoFramework.ECCPubKeySpec = { + algName: 'ECC', + specType: cryptoFramework.AsyKeySpecType.PUBLIC_KEY_SPEC, + params: eccCommonParamsSpec, + pk: returnPoint + }; + let generatorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(eccPubKeySpec); + let pubKey = await generatorBySpec.generatePubKey(); + let returnData = cryptoFramework.ECCKeyUtil.getEncodedPoint('NID_brainpoolP256r1', returnPoint, 'UNCOMPRESSED'); + console.info('returnData: ' + + returnData); // 4,143,39,57,249,145,50,63,222,35,70,178,121,202,154,21,146,129,75,76,63,8,195,157,111, + // 40,217,215,148,120,224,205,82,83,92,185,21,211,184,5,19,114,33,86,85,228,123,242,206,200,98,178,184, + // 130,35,232,45,5,202,189,11,46,163,156,152 + let eccPkX = pubKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_PK_X_BN); + console.info('returnPoint x data: ' + + returnPoint.x); // 64750044510792891439269945828433327517677381559622384455951527515863444933970 + console.info('ECC_PK_X_BN:' + + eccPkX); // 64750044510792891439269945828433327517677381559622384455951527515863444933970 +} +// [End specify_ecc_uncompressed_point_get_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'GetKeyObject'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_getKeyObject')) + .width('70%') + .onClick(async () => { + try { + await eccPointCompressedToPoint(); + this.message = 'GetKeyObject Success'; + } catch { + this.message = 'GetKeyObject Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 6036ad8755..1d878bc7e0 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/Index.ets @@ -1,66 +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. - */ - -import { router } from '@kit.ArkUI'; -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'ECCCompressPublicKeyFormatConversion'; - - goToSample(url: string): void { - router.pushUrl({ - url: url, - }, router.RouterMode.Single, (err) => { - if (err) { - console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); - return; - } - console.info('pushUrl success'); - }) - } - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(20) - .fontWeight(FontWeight.Bold) - Button($r('app.string.SpecifyUncompressedPublicKey')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.doTestEccDataCovert(); - this.message = 'doTestEccDataCovert Success Result:' + ret.toString(); - }) - Button($r('app.string.SpecifyUncompressedPublicKeyArkTS')) - .width('70%') - .onClick(() => { - this.goToSample('pages/SpecifyUncompressedPublicKey') - }) - Button($r('app.string.CompressedPointData')) - .width('70%') - .onClick(() => { - this.goToSample('pages/CompressedPointData') - }) - Button($r('app.string.GetKeyObject')) - .width('70%') - .onClick(() => { - this.goToSample('pages/GetKeyObject') - }) - } - .width('100%') - .height('100%') - } -} +/* + * 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 { router } from '@kit.ArkUI'; +import testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State message: string = 'ECCCompressPublicKeyFormatConversion'; + + goToSample(url: string): void { + router.pushUrl({ + url: url, + }, router.RouterMode.Single, (err) => { + if (err) { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('pushUrl success'); + }) + } + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(20) + .fontWeight(FontWeight.Bold) + Button($r('app.string.SpecifyUncompressedPublicKey')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.doTestEccDataCovert(); + this.message = 'doTestEccDataCovert Success Result:' + ret.toString(); + }) + Button($r('app.string.SpecifyUncompressedPublicKeyArkTS')) + .width('70%') + .onClick(() => { + this.goToSample('pages/SpecifyUncompressedPublicKey') + }) + Button($r('app.string.CompressedPointData')) + .width('70%') + .onClick(() => { + this.goToSample('pages/CompressedPointData') + }) + Button($r('app.string.GetKeyObject')) + .width('70%') + .onClick(() => { + this.goToSample('pages/GetKeyObject') + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/SpecifyUncompressedPublicKey.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/SpecifyUncompressedPublicKey.ets old mode 100755 new mode 100644 index a645f24603..b1afc4373e --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/SpecifyUncompressedPublicKey.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/ets/pages/SpecifyUncompressedPublicKey.ets @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start convert_ecc_uncompressed_pub_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -async function eccPubUncompressedToCompressed() { - let pkData = - new Uint8Array([48, 90, 48, 20, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 9, 43, 36, 3, 3, 2, 8, 1, 1, 7, 3, 66, 0, 4, - 143, 39, 57, 249, 145, 50, 63, 222, 35, 70, 178, 121, 202, 154, 21, 146, 129, 75, 76, 63, 8, 195, 157, 111, 40, - 217, 215, 148, 120, 224, 205, 82, 83, 92, 185, 21, 211, 184, 5, 19, 114, 33, 86, 85, 228, 123, 242, 206, 200, 98, - 178, 184, 130, 35, 232, 45, 5, 202, 189, 11, 46, 163, 156, 152]); - let pubKeyBlob: cryptoFramework.DataBlob = { data: pkData }; - let generator = cryptoFramework.createAsyKeyGenerator('ECC_BrainPoolP256r1'); - let keyPair = await generator.convertKey(pubKeyBlob, null); - let returnBlob = keyPair.pubKey.getEncodedDer('X509|COMPRESSED'); - console.info('returnBlob data:' + returnBlob.data); -} -// [End convert_ecc_uncompressed_pub_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'SpecifyUncompressedPublicKey'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_specifyUncompressedPublicKey')) - .width('70%') - .onClick(async () => { - try { - await eccPubUncompressedToCompressed(); - this.message = 'SpecifyUncompressedPublicKey Success'; - } catch { - this.message = 'SpecifyUncompressedPublicKey Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start convert_ecc_uncompressed_pub_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +async function eccPubUncompressedToCompressed() { + let pkData = + new Uint8Array([48, 90, 48, 20, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 9, 43, 36, 3, 3, 2, 8, 1, 1, 7, 3, 66, 0, 4, + 143, 39, 57, 249, 145, 50, 63, 222, 35, 70, 178, 121, 202, 154, 21, 146, 129, 75, 76, 63, 8, 195, 157, 111, 40, + 217, 215, 148, 120, 224, 205, 82, 83, 92, 185, 21, 211, 184, 5, 19, 114, 33, 86, 85, 228, 123, 242, 206, 200, 98, + 178, 184, 130, 35, 232, 45, 5, 202, 189, 11, 46, 163, 156, 152]); + let pubKeyBlob: cryptoFramework.DataBlob = { data: pkData }; + let generator = cryptoFramework.createAsyKeyGenerator('ECC_BrainPoolP256r1'); + let keyPair = await generator.convertKey(pubKeyBlob, null); + let returnBlob = keyPair.pubKey.getEncodedDer('X509|COMPRESSED'); + console.info('returnBlob data:' + returnBlob.data); +} +// [End convert_ecc_uncompressed_pub_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'SpecifyUncompressedPublicKey'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_specifyUncompressedPublicKey')) + .width('70%') + .onClick(async () => { + try { + await eccPubUncompressedToCompressed(); + this.message = 'SpecifyUncompressedPublicKey Success'; + } catch { + this.message = 'SpecifyUncompressedPublicKey Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/ECCCompressPublicKeyFormatConversion.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/ECCCompressPublicKeyFormatConversion.test.ets old mode 100755 new mode 100644 index d26cb86c1b..b5bd589ba4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/ECCCompressPublicKeyFormatConversion.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/ECCCompressPublicKeyFormatConversion.test.ets @@ -1,112 +1,112 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function eccCompressPublicKeyFormatConversionTest() { - describe('eccCompressPublicKeyFormatConversionTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用ECC压缩/非压缩公钥格式转换(C/C++) - */ - it('testEccCompressPublicKeyFormatConversion001', 0, async () => { - console.info('uitest: testEccCompressPublicKeyFormatConversion001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SpecifyUncompressedPublicKey')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('doTestEccDataCovert Success Result:0')); - console.info('uitest: testEccCompressPublicKeyFormatConversion001 end'); - }) - - /** - * 点击按钮,使用ECC压缩/非压缩公钥格式转换(ArkTS) - */ - it('testEccCompressPublicKeyFormatConversion002', 0, async () => { - console.info('uitest: testEccCompressPublicKeyFormatConversion002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SpecifyUncompressedPublicKeyArkTS')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SpecifyUncompressedPublicKey')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SpecifyUncompressedPublicKey Success')); - console.info('uitest: testEccCompressPublicKeyFormatConversion002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用ECC压缩/非压缩点格式转换(指定非压缩点数据转换为压缩点数据) - */ - it('testEccCompressPublicKeyFormatConversion003', 0, async () => { - console.info('uitest: testEccCompressPublicKeyFormatConversion003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('CompressedPointData')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CompressedPointData')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('CompressedPointData Success')); - console.info('uitest: testEccCompressPublicKeyFormatConversion003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用ECC压缩/非压缩点格式转换(指定压缩点数据获取密钥对象) - */ - it('testEccCompressPublicKeyFormatConversion004', 0, async () => { - console.info('uitest: testEccCompressPublicKeyFormatConversion004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('GetKeyObject')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call GetKeyObject')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('GetKeyObject Success')); - console.info('uitest: testEccCompressPublicKeyFormatConversion004 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function eccCompressPublicKeyFormatConversionTest() { + describe('eccCompressPublicKeyFormatConversionTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用ECC压缩/非压缩公钥格式转换(C/C++) + */ + it('testEccCompressPublicKeyFormatConversion001', 0, async () => { + console.info('uitest: testEccCompressPublicKeyFormatConversion001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SpecifyUncompressedPublicKey')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('doTestEccDataCovert Success Result:0')); + console.info('uitest: testEccCompressPublicKeyFormatConversion001 end'); + }) + + /** + * 点击按钮,使用ECC压缩/非压缩公钥格式转换(ArkTS) + */ + it('testEccCompressPublicKeyFormatConversion002', 0, async () => { + console.info('uitest: testEccCompressPublicKeyFormatConversion002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SpecifyUncompressedPublicKeyArkTS')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SpecifyUncompressedPublicKey')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SpecifyUncompressedPublicKey Success')); + console.info('uitest: testEccCompressPublicKeyFormatConversion002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用ECC压缩/非压缩点格式转换(指定非压缩点数据转换为压缩点数据) + */ + it('testEccCompressPublicKeyFormatConversion003', 0, async () => { + console.info('uitest: testEccCompressPublicKeyFormatConversion003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('CompressedPointData')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CompressedPointData')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('CompressedPointData Success')); + console.info('uitest: testEccCompressPublicKeyFormatConversion003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用ECC压缩/非压缩点格式转换(指定压缩点数据获取密钥对象) + */ + it('testEccCompressPublicKeyFormatConversion004', 0, async () => { + console.info('uitest: testEccCompressPublicKeyFormatConversion004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('GetKeyObject')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call GetKeyObject')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('GetKeyObject Success')); + console.info('uitest: testEccCompressPublicKeyFormatConversion004 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/ohosTest.md old mode 100755 new mode 100644 index 9baaf295cf..13c6e7e5a2 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/ohosTest.md @@ -1,11 +1,11 @@ -# 使用ECC压缩/非压缩格式转换测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用ECC压缩/非压缩公钥格式转换(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用ECC压缩/非压缩公钥格式转换(ArkTS) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用ECC压缩/非压缩点格式转换(指定非压缩点数据转换为压缩点数据) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 使用ECC压缩/非压缩格式转换测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------------ | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用ECC压缩/非压缩公钥格式转换(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用ECC压缩/非压缩公钥格式转换(ArkTS) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用ECC压缩/非压缩点格式转换(指定非压缩点数据转换为压缩点数据) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用ECC压缩/非压缩点格式转换(指定压缩点数据获取密钥对象) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/screenshots/ECCCompressPublicKeyFormatConversion1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/screenshots/ECCCompressPublicKeyFormatConversion1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/screenshots/ECCCompressPublicKeyFormatConversion2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/ECCCompressPublicKeyFormatConversion/screenshots/ECCCompressPublicKeyFormatConversion2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/app.json5 old mode 100755 new mode 100644 index 6e73874745..ec79f46166 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/app.json5 @@ -1,25 +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.randomlygenerateasymmetrickeypair", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.randomlygenerateasymmetrickeypair", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 0e2bfe3619..8b2697f297 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "RandomlyGenerateAsymmetricKeyPair" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "RandomlyGenerateAsymmetricKeyPair" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/README.md old mode 100755 new mode 100644 index 59cdecc50d..5f3d17a746 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/README.md @@ -1,80 +1,80 @@ -# 随机生成非对称密钥对(C/C++) - -### 介绍 - -以RSA和SM2为例,随机生成非对称密钥对(OH_CryptoKeyPair),并获得二进制数据。非对称密钥对可用于后续加解密等操作,二进制数据可用于存储或运输。 - -本示例主要展示了随机生成非对称密钥对(C/C++),随机生成RSA、SM2密钥对场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [随机生成非对称密钥对(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-asym-key-pair-randomly-ndk.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例RandomlyGenerateAsymmetricKeyPair.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── sm2.cpp - │ │ | ├── file.h - │ │ | ├── rsa.cpp - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 随机生成非对称密钥对(C/C++)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── RandomlyGenerateAsymmetricKeyPair.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 随机生成非对称密钥对(C/C++) + +### 介绍 + +以RSA和SM2为例,随机生成非对称密钥对(OH_CryptoKeyPair),并获得二进制数据。非对称密钥对可用于后续加解密等操作,二进制数据可用于存储或运输。 + +本示例主要展示了随机生成非对称密钥对(C/C++),随机生成RSA、SM2密钥对场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [随机生成非对称密钥对(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-asym-key-pair-randomly-ndk.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例RandomlyGenerateAsymmetricKeyPair.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── sm2.cpp + │ │ | ├── file.h + │ │ | ├── rsa.cpp + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 随机生成非对称密钥对(C/C++)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── RandomlyGenerateAsymmetricKeyPair.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 6c5f6bf253..ace0c9826d --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(RandomlyGenerateAsymmetricKeyPair) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp types/project/rsa.cpp types/project/sm2.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(RandomlyGenerateAsymmetricKeyPair) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp types/project/rsa.cpp types/project/sm2.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 51469dbaf8..a781d77594 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/napi_init.cpp @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" -#include "types/project/file.h" - -static napi_value NAPI_Global_randomGenerateAsymKey(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, randomGenerateAsymKey(), &ret); - return ret; -} -static napi_value NAPI_Global_randomGenerateRSA(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, randomGenerateRSA(), &ret); - return ret; -} -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"randomGenerateAsymKey", nullptr, NAPI_Global_randomGenerateAsymKey, nullptr, - nullptr, nullptr, napi_default, nullptr}, - {"randomGenerateRSA", nullptr, NAPI_Global_randomGenerateRSA, nullptr, nullptr, - nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/file.h" + +static napi_value NAPI_Global_randomGenerateAsymKey(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, randomGenerateAsymKey(), &ret); + return ret; +} +static napi_value NAPI_Global_randomGenerateRSA(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, randomGenerateRSA(), &ret); + return ret; +} +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"randomGenerateAsymKey", nullptr, NAPI_Global_randomGenerateAsymKey, nullptr, + nullptr, nullptr, napi_default, nullptr}, + {"randomGenerateRSA", nullptr, NAPI_Global_randomGenerateRSA, nullptr, nullptr, + nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index 79549f1de1..6cc44ebc55 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,18 +1,18 @@ -/* - * 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 randomGenerateAsymKey: () => number; - +/* + * 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 randomGenerateAsymKey: () => number; + export const randomGenerateRSA: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h old mode 100755 new mode 100644 index e209fd8b3e..ef4b0f6843 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/file.h @@ -1,24 +1,24 @@ -#ifndef FILE_H -#define FILE_H -/* - * 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 "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_asym_key.h" - -OH_Crypto_ErrCode randomGenerateAsymKey(); -OH_Crypto_ErrCode randomGenerateRSA(); - +#ifndef FILE_H +#define FILE_H +/* + * 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 "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_asym_key.h" + +OH_Crypto_ErrCode randomGenerateAsymKey(); +OH_Crypto_ErrCode randomGenerateRSA(); + #endif // FILE_H \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp old mode 100755 new mode 100644 index a81b095892..2cf7492fa3 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/rsa.cpp @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_rsa_keypair] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_asym_key.h" -#include "file.h" - -OH_Crypto_ErrCode randomGenerateAsymKey() -{ - OH_CryptoAsymKeyGenerator *ctx = nullptr; - OH_CryptoKeyPair *keyPair = nullptr; - OH_Crypto_ErrCode ret; - - ret = OH_CryptoAsymKeyGenerator_Create("RSA1024|PRIMES_2", &ctx); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - return ret; - } - - ret = OH_CryptoAsymKeyGenerator_Generate(ctx, &keyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(keyPair); - return ret; - } - - OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); - Crypto_DataBlob retBlob = {.data = nullptr, .len = 0}; - ret = OH_CryptoPubKey_Encode(pubKey, CRYPTO_PEM, "PKCS1", &retBlob); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(keyPair); - return ret; - } - - OH_Crypto_FreeDataBlob(&retBlob); - - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(keyPair); - return ret; -} -// [End generate_rsa_keypair] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_rsa_keypair] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_asym_key.h" +#include "file.h" + +OH_Crypto_ErrCode randomGenerateAsymKey() +{ + OH_CryptoAsymKeyGenerator *ctx = nullptr; + OH_CryptoKeyPair *keyPair = nullptr; + OH_Crypto_ErrCode ret; + + ret = OH_CryptoAsymKeyGenerator_Create("RSA1024|PRIMES_2", &ctx); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + return ret; + } + + ret = OH_CryptoAsymKeyGenerator_Generate(ctx, &keyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(keyPair); + return ret; + } + + OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); + Crypto_DataBlob retBlob = {.data = nullptr, .len = 0}; + ret = OH_CryptoPubKey_Encode(pubKey, CRYPTO_PEM, "PKCS1", &retBlob); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(keyPair); + return ret; + } + + OH_Crypto_FreeDataBlob(&retBlob); + + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(keyPair); + return ret; +} +// [End generate_rsa_keypair] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/sm2.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/sm2.cpp old mode 100755 new mode 100644 index 9c574e00af..46d5fea4ad --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/sm2.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/cpp/types/project/sm2.cpp @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_sm2_keypair] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_asym_key.h" -#include "file.h" - -OH_Crypto_ErrCode randomGenerateRSA() -{ - OH_CryptoAsymKeyGenerator *ctx = nullptr; - OH_CryptoKeyPair *dupKeyPair = nullptr; - OH_Crypto_ErrCode ret; - - ret = OH_CryptoAsymKeyGenerator_Create("SM2_256", &ctx); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - return ret; - } - - ret = OH_CryptoAsymKeyGenerator_Generate(ctx, &dupKeyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(dupKeyPair); - return ret; - } - - OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(dupKeyPair); - Crypto_DataBlob retBlob = { .data = nullptr, .len = 0 }; - ret = OH_CryptoPubKey_Encode(pubKey, CRYPTO_DER, nullptr, &retBlob); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(dupKeyPair); - return ret; - } - - OH_CryptoAsymKeyGenerator_Destroy(ctx); - OH_CryptoKeyPair_Destroy(dupKeyPair); - return ret; -} -// [End generate_sm2_keypair] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_sm2_keypair] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_asym_key.h" +#include "file.h" + +OH_Crypto_ErrCode randomGenerateRSA() +{ + OH_CryptoAsymKeyGenerator *ctx = nullptr; + OH_CryptoKeyPair *dupKeyPair = nullptr; + OH_Crypto_ErrCode ret; + + ret = OH_CryptoAsymKeyGenerator_Create("SM2_256", &ctx); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + return ret; + } + + ret = OH_CryptoAsymKeyGenerator_Generate(ctx, &dupKeyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(dupKeyPair); + return ret; + } + + OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(dupKeyPair); + Crypto_DataBlob retBlob = { .data = nullptr, .len = 0 }; + ret = OH_CryptoPubKey_Encode(pubKey, CRYPTO_DER, nullptr, &retBlob); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(dupKeyPair); + return ret; + } + + OH_CryptoAsymKeyGenerator_Destroy(ctx); + OH_CryptoKeyPair_Destroy(dupKeyPair); + return ret; +} +// [End generate_sm2_keypair] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index a36ca588fe..965554bb3a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 7636c7b9f2..31df824f96 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'RandomlyGenerateAsymmetricKeyPair'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.randomGenerateAsymKey(); - this.message = 'Call RSA Success Result:' + ret.toString(); - }) - Button($r('app.string.call_sm2')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.randomGenerateRSA(); - this.message = 'Call SM2 Success Result:' + ret.toString(); - }) - } - .width('100%') - .height('100%') - } -} +/* + * 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 { + @State message: string = 'RandomlyGenerateAsymmetricKeyPair'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.randomGenerateAsymKey(); + this.message = 'Call RSA Success Result:' + ret.toString(); + }) + Button($r('app.string.call_sm2')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.randomGenerateRSA(); + this.message = 'Call SM2 Success Result:' + ret.toString(); + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/RandomlyGenerateAsymmetricKeyPair.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/RandomlyGenerateAsymmetricKeyPair.test.ets old mode 100755 new mode 100644 index e0df163ee2..cc5008f1c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/RandomlyGenerateAsymmetricKeyPair.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/RandomlyGenerateAsymmetricKeyPair.test.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function randomlyGenerateAsymmetricKeyPairTest() { - describe('randomlyGenerateAsymmetricKeyPairTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,随机生成非对称密钥对(RSA) - */ - it('testRandomlyGenerateAsymmetricKeyPair001', 0, async () => { - console.info('uitest: testRandomlyGenerateAsymmetricKeyPair001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call RSA')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call RSA Success Result:0')); - console.info('uitest: testRandomlyGenerateAsymmetricKeyPair001 end'); - }) - - /** - * 点击按钮,随机生成非对称密钥对(SM2) - */ - it('testRandomlyGenerateAsymmetricKeyPair002', 0, async () => { - console.info('uitest: testRandomlyGenerateAsymmetricKeyPair002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call SM2')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call SM2 Success Result:0')); - console.info('uitest: testRandomlyGenerateAsymmetricKeyPair002 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function randomlyGenerateAsymmetricKeyPairTest() { + describe('randomlyGenerateAsymmetricKeyPairTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,随机生成非对称密钥对(RSA) + */ + it('testRandomlyGenerateAsymmetricKeyPair001', 0, async () => { + console.info('uitest: testRandomlyGenerateAsymmetricKeyPair001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call RSA')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call RSA Success Result:0')); + console.info('uitest: testRandomlyGenerateAsymmetricKeyPair001 end'); + }) + + /** + * 点击按钮,随机生成非对称密钥对(SM2) + */ + it('testRandomlyGenerateAsymmetricKeyPair002', 0, async () => { + console.info('uitest: testRandomlyGenerateAsymmetricKeyPair002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call SM2')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call SM2 Success Result:0')); + console.info('uitest: testRandomlyGenerateAsymmetricKeyPair002 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/ohosTest.md old mode 100755 new mode 100644 index 70148643fc..6705d611b7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/ohosTest.md @@ -1,9 +1,9 @@ -# 随机生成非对称密钥对(C/C++)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,随机生成非对称密钥对(RSA) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 随机生成非对称密钥对(C/C++)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,随机生成非对称密钥对(RSA) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,随机生成非对称密钥对(SM2) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/screenshots/RandomlyGenerateAsymmetricKeyPair1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/screenshots/RandomlyGenerateAsymmetricKeyPair1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/screenshots/RandomlyGenerateAsymmetricKeyPair2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPair/screenshots/RandomlyGenerateAsymmetricKeyPair2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/app.json5 old mode 100755 new mode 100644 index 2bee01b4af..bf9e81bc4f --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/app.json5 @@ -1,25 +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.randomlygenerateasymmetrickeypairarkts", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.randomlygenerateasymmetrickeypairarkts", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 99aa3f9c60..bd5ebcd46a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "RandomlyGenerateAsymmetricKeyPairArkTS" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "RandomlyGenerateAsymmetricKeyPairArkTS" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/README.md old mode 100755 new mode 100644 index db40d6e6d4..1070ad5051 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/README.md @@ -1,75 +1,75 @@ -# 随机生成非对称密钥对(ArkTS) - -### 介绍 - -以RSA和SM2为例,随机生成非对称密钥对(KeyPair),并获得二进制数据。非对称密钥对可用于后续加解密等操作,二进制数据可用于存储或运输。 - -本示例主要展示了随机生成非对称密钥对(ArkTS),随机生成RSA、SM2密钥对场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [随机生成非对称密钥对(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-asym-key-pair-randomly.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例RandomlyGenerateAsymmetricKeyPairArkTS.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 随机生成非对称密钥对(ArkTS)示例代码 - │ │ ├── rsa - │ │ | ├── Promise.ets - │ │ | ├── Sync.ets - │ │ ├── sm2 - │ │ | ├── Promise.ets - │ │ | ├── Sync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── RandomlyGenerateAsymmetricKeyPairArkTS.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 随机生成非对称密钥对(ArkTS) + +### 介绍 + +以RSA和SM2为例,随机生成非对称密钥对(KeyPair),并获得二进制数据。非对称密钥对可用于后续加解密等操作,二进制数据可用于存储或运输。 + +本示例主要展示了随机生成非对称密钥对(ArkTS),随机生成RSA、SM2密钥对场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [随机生成非对称密钥对(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-asym-key-pair-randomly.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例RandomlyGenerateAsymmetricKeyPairArkTS.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 随机生成非对称密钥对(ArkTS)示例代码 + │ │ ├── rsa + │ │ | ├── Promise.ets + │ │ | ├── Sync.ets + │ │ ├── sm2 + │ │ | ├── Promise.ets + │ │ | ├── Sync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── RandomlyGenerateAsymmetricKeyPairArkTS.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Promise.ets old mode 100755 new mode 100644 index 2acfd34c5e..7c8b11a245 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Promise.ets @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_rsa_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function generateAsyKey() { - // 创建一个AsyKeyGenerator实例 - let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024|PRIMES_2'); - // 使用密钥生成器随机生成非对称密钥对 - let keyGenPromise = rsaGenerator.generateKeyPair(); - keyGenPromise.then(keyPair => { - let pubKey = keyPair.pubKey; - let priKey = keyPair.priKey; - // 获取非对称密钥对的二进制数据 - let pkBlob = pubKey.getEncoded(); - let skBlob = priKey.getEncoded(); - console.info('pk bin data' + pkBlob.data); - console.info('sk bin data' + skBlob.data); - }); -} -// [End generate_rsa_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'RSA Promise'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_promise')) - .width('70%') - .onClick(() => { - try { - generateAsyKey(); - this.message = 'RSA Promise Success'; - } catch { - this.message = 'RSA Promise Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_rsa_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function generateAsyKey() { + // 创建一个AsyKeyGenerator实例 + let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024|PRIMES_2'); + // 使用密钥生成器随机生成非对称密钥对 + let keyGenPromise = rsaGenerator.generateKeyPair(); + keyGenPromise.then(keyPair => { + let pubKey = keyPair.pubKey; + let priKey = keyPair.priKey; + // 获取非对称密钥对的二进制数据 + let pkBlob = pubKey.getEncoded(); + let skBlob = priKey.getEncoded(); + console.info('pk bin data' + pkBlob.data); + console.info('sk bin data' + skBlob.data); + }); +} +// [End generate_rsa_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'RSA Promise'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_promise')) + .width('70%') + .onClick(() => { + try { + generateAsyKey(); + this.message = 'RSA Promise Success'; + } catch { + this.message = 'RSA Promise Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Sync.ets old mode 100755 new mode 100644 index 8673349983..551fb3e5bd --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/rsa/Sync.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_rsa_keypair_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function generateAsyKeySync() { - // 创建一个AsyKeyGenerator实例 - let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024|PRIMES_2'); - // 使用密钥生成器随机生成非对称密钥对 - try { - let keyPair = rsaGenerator.generateKeyPairSync(); - if (keyPair != null) { - let pubKey = keyPair.pubKey; - let priKey = keyPair.priKey; - // 获取非对称密钥对的二进制数据 - let pkBlob = pubKey.getEncoded(); - let skBlob = priKey.getEncoded(); - console.info('pk bin data' + pkBlob.data); - console.info('sk bin data' + skBlob.data); - } else { - console.error('[Sync]: get key pair result fail!'); - } - } catch (e) { - console.error(`get key pair failed, ${e.code}, ${e.message}`); - } -} -// [End generate_rsa_keypair_sync] - -@Entry -@Component -struct Index { - @State message: string = 'RSA Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_sync')) - .width('70%') - .onClick(() => { - try { - generateAsyKeySync(); - this.message = 'RSA Sync Success'; - } catch { - this.message = 'RSA Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_rsa_keypair_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function generateAsyKeySync() { + // 创建一个AsyKeyGenerator实例 + let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024|PRIMES_2'); + // 使用密钥生成器随机生成非对称密钥对 + try { + let keyPair = rsaGenerator.generateKeyPairSync(); + if (keyPair != null) { + let pubKey = keyPair.pubKey; + let priKey = keyPair.priKey; + // 获取非对称密钥对的二进制数据 + let pkBlob = pubKey.getEncoded(); + let skBlob = priKey.getEncoded(); + console.info('pk bin data' + pkBlob.data); + console.info('sk bin data' + skBlob.data); + } else { + console.error('[Sync]: get key pair result fail!'); + } + } catch (e) { + console.error(`get key pair failed, ${e.code}, ${e.message}`); + } +} +// [End generate_rsa_keypair_sync] + +@Entry +@Component +struct Index { + @State message: string = 'RSA Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_sync')) + .width('70%') + .onClick(() => { + try { + generateAsyKeySync(); + this.message = 'RSA Sync Success'; + } catch { + this.message = 'RSA Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Promise.ets old mode 100755 new mode 100644 index 488294afb7..b687356048 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Promise.ets @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_sm2_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function generateSM2Key() { - // 创建一个AsyKeyGenerator实例 - let sm2Generator = cryptoFramework.createAsyKeyGenerator('SM2_256'); - // 使用密钥生成器随机生成非对称密钥对 - let keyGenPromise = sm2Generator.generateKeyPair(); - keyGenPromise.then(keyPair => { - let pubKey = keyPair.pubKey; - let priKey = keyPair.priKey; - // 获取非对称密钥对的二进制数据 - let pkBlob = pubKey.getEncoded(); - let skBlob = priKey.getEncoded(); - console.info('pk bin data' + pkBlob.data); - console.info('sk bin data' + skBlob.data); - }); -} -// [End generate_sm2_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'SM2 Promise'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm2_promise')) - .width('70%') - .onClick(() => { - try { - generateSM2Key(); - this.message = 'SM2 Promise Success'; - } catch { - this.message = 'SM2 Promise Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_sm2_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function generateSM2Key() { + // 创建一个AsyKeyGenerator实例 + let sm2Generator = cryptoFramework.createAsyKeyGenerator('SM2_256'); + // 使用密钥生成器随机生成非对称密钥对 + let keyGenPromise = sm2Generator.generateKeyPair(); + keyGenPromise.then(keyPair => { + let pubKey = keyPair.pubKey; + let priKey = keyPair.priKey; + // 获取非对称密钥对的二进制数据 + let pkBlob = pubKey.getEncoded(); + let skBlob = priKey.getEncoded(); + console.info('pk bin data' + pkBlob.data); + console.info('sk bin data' + skBlob.data); + }); +} +// [End generate_sm2_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'SM2 Promise'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm2_promise')) + .width('70%') + .onClick(() => { + try { + generateSM2Key(); + this.message = 'SM2 Promise Success'; + } catch { + this.message = 'SM2 Promise Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Sync.ets old mode 100755 new mode 100644 index b6a73a566b..5129a8fb8d --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/ets/pages/sm2/Sync.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_sm2_keypair_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function generateSM2KeySync() { - // 创建一个AsyKeyGenerator实例 - let rsaGenerator = cryptoFramework.createAsyKeyGenerator('SM2_256'); - // 使用密钥生成器随机生成非对称密钥对 - try { - let keyPair = rsaGenerator.generateKeyPairSync(); - if (keyPair != null) { - let pubKey = keyPair.pubKey; - let priKey = keyPair.priKey; - // 获取非对称密钥对的二进制数据 - let pkBlob = pubKey.getEncoded(); - let skBlob = priKey.getEncoded(); - console.info('pk bin data' + pkBlob.data); - console.info('sk bin data' + skBlob.data); - } else { - console.error('[Sync]: get key pair result fail!'); - } - } catch (e) { - console.error(`get key pair failed, ${e.code}, ${e.message}`); - } -} -// [End generate_sm2_keypair_sync] - -@Entry -@Component -struct Index { - @State message: string = 'SM2 Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm2_sync')) - .width('70%') - .onClick(() => { - try { - generateSM2KeySync(); - this.message = 'SM2 Sync Success'; - } catch { - this.message = 'SM2 Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_sm2_keypair_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function generateSM2KeySync() { + // 创建一个AsyKeyGenerator实例 + let rsaGenerator = cryptoFramework.createAsyKeyGenerator('SM2_256'); + // 使用密钥生成器随机生成非对称密钥对 + try { + let keyPair = rsaGenerator.generateKeyPairSync(); + if (keyPair != null) { + let pubKey = keyPair.pubKey; + let priKey = keyPair.priKey; + // 获取非对称密钥对的二进制数据 + let pkBlob = pubKey.getEncoded(); + let skBlob = priKey.getEncoded(); + console.info('pk bin data' + pkBlob.data); + console.info('sk bin data' + skBlob.data); + } else { + console.error('[Sync]: get key pair result fail!'); + } + } catch (e) { + console.error(`get key pair failed, ${e.code}, ${e.message}`); + } +} +// [End generate_sm2_keypair_sync] + +@Entry +@Component +struct Index { + @State message: string = 'SM2 Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm2_sync')) + .width('70%') + .onClick(() => { + try { + generateSM2KeySync(); + this.message = 'SM2 Sync Success'; + } catch { + this.message = 'SM2 Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/RandomlyGenerateAsymmetricKeyPairArkTS.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/RandomlyGenerateAsymmetricKeyPairArkTS.test.ets old mode 100755 new mode 100644 index 5c07cdc897..5a8cdfe785 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/RandomlyGenerateAsymmetricKeyPairArkTS.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/ets/test/RandomlyGenerateAsymmetricKeyPairArkTS.test.ets @@ -1,116 +1,116 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function randomlyGenerateAsymmetricKeyPairArkTSTest() { - describe('randomlyGenerateAsymmetricKeyPairArkTSTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,随机生成非对称密钥对(RSA Promise方式) - */ - it('testRandomlyGenerateAsymmetricKeyPairArkTS001', 0, async () => { - console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA Promise')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA Promise')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA Promise Success')); - console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,随机生成非对称密钥对(RSA 同步方式) - */ - it('testRandomlyGenerateAsymmetricKeyPairArkTS002', 0, async () => { - console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA Sync Success')); - console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,随机生成非对称密钥对(SM2 Promise方式) - */ - it('testRandomlyGenerateAsymmetricKeyPairArkTS003', 0, async () => { - console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM2 Promise')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2 Promise')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2 Promise Success')); - console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,随机生成非对称密钥对(SM2 同步方式) - */ - it('testRandomlyGenerateAsymmetricKeyPairArkTS004', 0, async () => { - console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM2 Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2 Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2 Sync Success')); - console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS004 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function randomlyGenerateAsymmetricKeyPairArkTSTest() { + describe('randomlyGenerateAsymmetricKeyPairArkTSTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,随机生成非对称密钥对(RSA Promise方式) + */ + it('testRandomlyGenerateAsymmetricKeyPairArkTS001', 0, async () => { + console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA Promise')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA Promise')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA Promise Success')); + console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,随机生成非对称密钥对(RSA 同步方式) + */ + it('testRandomlyGenerateAsymmetricKeyPairArkTS002', 0, async () => { + console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA Sync Success')); + console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,随机生成非对称密钥对(SM2 Promise方式) + */ + it('testRandomlyGenerateAsymmetricKeyPairArkTS003', 0, async () => { + console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM2 Promise')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2 Promise')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2 Promise Success')); + console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,随机生成非对称密钥对(SM2 同步方式) + */ + it('testRandomlyGenerateAsymmetricKeyPairArkTS004', 0, async () => { + console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM2 Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2 Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2 Sync Success')); + console.info('uitest: testRandomlyGenerateAsymmetricKeyPairArkTS004 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/ohosTest.md old mode 100755 new mode 100644 index 12243c6aeb..acf17e91e4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/ohosTest.md @@ -1,11 +1,11 @@ -# 随机生成非对称密钥对(ArkTS)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,随机生成非对称密钥对(RSA Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,随机生成非对称密钥对(RSA 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,随机生成非对称密钥对(SM2 Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 随机生成非对称密钥对(ArkTS)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,随机生成非对称密钥对(RSA Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,随机生成非对称密钥对(RSA 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,随机生成非对称密钥对(SM2 Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,随机生成非对称密钥对(SM2 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/screenshots/RandomlyGenerateAsymmetricKeyPairArkTS1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/screenshots/RandomlyGenerateAsymmetricKeyPairArkTS1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/screenshots/RandomlyGenerateAsymmetricKeyPairArkTS2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateAsymmetricKeyPairArkTS/screenshots/RandomlyGenerateAsymmetricKeyPairArkTS2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/app.json5 old mode 100755 new mode 100644 index fe14bc8bea..050d254981 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/app.json5 @@ -1,25 +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.randomlygeneratesymmetrickey", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.randomlygeneratesymmetrickey", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 6ba815b223..e400fe91aa --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "RandomlyGenerateSymmetricKey" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "RandomlyGenerateSymmetricKey" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/README.md old mode 100755 new mode 100644 index 1b0a4f0cf9..ec6c451a8f --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/README.md @@ -1,80 +1,80 @@ -# 随机生成对称密钥(C/C++) - -### 介绍 - -以AES和SM4为例,随机生成对称密钥(OH_CryptoSymKey)。对称密钥对象可用于后续加解密操作,二进制数据可用于存储或运输。 - -本示例主要展示了随机生成对称密钥(C/C++),随机生成AES、SM4密钥场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [随机生成对称密钥(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-sym-key-randomly-ndk.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例RandomlyGenerateSymmetricKey.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── aes.cpp - │ │ | ├── file.h - │ │ | ├── sm4.cpp - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 随机生成对称密钥(C/C++)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── RandomlyGenerateSymmetricKey.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 随机生成对称密钥(C/C++) + +### 介绍 + +以AES和SM4为例,随机生成对称密钥(OH_CryptoSymKey)。对称密钥对象可用于后续加解密操作,二进制数据可用于存储或运输。 + +本示例主要展示了随机生成对称密钥(C/C++),随机生成AES、SM4密钥场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [随机生成对称密钥(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-sym-key-randomly-ndk.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例RandomlyGenerateSymmetricKey.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── aes.cpp + │ │ | ├── file.h + │ │ | ├── sm4.cpp + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 随机生成对称密钥(C/C++)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── RandomlyGenerateSymmetricKey.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 0ae7b82df5..8f216f9500 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(RandomlyGenerateSymmetricKey) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp types/project/aes.cpp types/project/sm4.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(RandomlyGenerateSymmetricKey) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp types/project/aes.cpp types/project/sm4.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 68d7644115..b718f5d2af --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/napi_init.cpp @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" -#include "types/project/file.h" - -static napi_value NAPI_Global_testGenerateSM4Key(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, testGenerateSymKey(), &ret); - return ret; -} - -static napi_value NAPI_Global_testGenerateSymKey(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, testGenerateSM4Key(), &ret); - return ret; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - - {"testGenerateSM4Key", nullptr, NAPI_Global_testGenerateSM4Key, nullptr, nullptr, nullptr, napi_default, - nullptr}, - {"testGenerateSymKey", nullptr, NAPI_Global_testGenerateSymKey, nullptr, nullptr, nullptr, napi_default, - nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/file.h" + +static napi_value NAPI_Global_testGenerateSM4Key(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, testGenerateSymKey(), &ret); + return ret; +} + +static napi_value NAPI_Global_testGenerateSymKey(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, testGenerateSM4Key(), &ret); + return ret; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + + {"testGenerateSM4Key", nullptr, NAPI_Global_testGenerateSM4Key, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"testGenerateSymKey", nullptr, NAPI_Global_testGenerateSymKey, nullptr, nullptr, nullptr, napi_default, + nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index 8f0344e171..b90c1af84a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,18 +1,18 @@ -/* - * 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 testGenerateSymKey: () => number; - +/* + * 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 testGenerateSymKey: () => number; + export const testGenerateSM4Key: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/aes.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/aes.cpp old mode 100755 new mode 100644 index 6bbb8ebac2..3b3832e419 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/aes.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/aes.cpp @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_aes_key] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_key.h" -#include "file.h" - -OH_Crypto_ErrCode testGenerateSymKey() -{ - OH_CryptoSymKeyGenerator *ctx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - Crypto_DataBlob out = {.data = nullptr, .len = 0}; - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES256", &ctx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - ret = OH_CryptoSymKeyGenerator_Generate(ctx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoSymKeyGenerator_Destroy(ctx); - return ret; - } - ret = OH_CryptoSymKey_GetKeyData(keyCtx, &out); - OH_CryptoSymKeyGenerator_Destroy(ctx); - OH_CryptoSymKey_Destroy(keyCtx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - OH_Crypto_FreeDataBlob(&out); - return ret; -} -// [End generate_aes_key] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_aes_key] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_key.h" +#include "file.h" + +OH_Crypto_ErrCode testGenerateSymKey() +{ + OH_CryptoSymKeyGenerator *ctx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + Crypto_DataBlob out = {.data = nullptr, .len = 0}; + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("AES256", &ctx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + ret = OH_CryptoSymKeyGenerator_Generate(ctx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoSymKeyGenerator_Destroy(ctx); + return ret; + } + ret = OH_CryptoSymKey_GetKeyData(keyCtx, &out); + OH_CryptoSymKeyGenerator_Destroy(ctx); + OH_CryptoSymKey_Destroy(keyCtx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + OH_Crypto_FreeDataBlob(&out); + return ret; +} +// [End generate_aes_key] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/file.h b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/file.h old mode 100755 new mode 100644 index 619116bf40..31e35bb0c3 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/file.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/file.h @@ -1,23 +1,23 @@ -#ifndef FILE_H -#define FILE_H -/* - * 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 "CryptoArchitectureKit/crypto_common.h" - -OH_Crypto_ErrCode testGenerateSymKey(); -OH_Crypto_ErrCode testGenerateSM4Key(); - +#ifndef FILE_H +#define FILE_H +/* + * 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 "CryptoArchitectureKit/crypto_common.h" + +OH_Crypto_ErrCode testGenerateSymKey(); +OH_Crypto_ErrCode testGenerateSM4Key(); + #endif // FILE_H \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/sm4.cpp b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/sm4.cpp old mode 100755 new mode 100644 index e6a3310767..4e8d677505 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/sm4.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/cpp/types/project/sm4.cpp @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_sm4_key] -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_sym_key.h" -#include "file.h" - -OH_Crypto_ErrCode testGenerateSM4Key() -{ - OH_CryptoSymKeyGenerator *ctx = nullptr; - OH_CryptoSymKey *keyCtx = nullptr; - Crypto_DataBlob out = {.data = nullptr, .len = 0}; - OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("SM4_128", &ctx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - ret = OH_CryptoSymKeyGenerator_Generate(ctx, &keyCtx); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoSymKeyGenerator_Destroy(ctx); - return ret; - } - ret = OH_CryptoSymKey_GetKeyData(keyCtx, &out); - OH_CryptoSymKeyGenerator_Destroy(ctx); - OH_CryptoSymKey_Destroy(keyCtx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - OH_Crypto_FreeDataBlob(&out); - return ret; -} -// [End generate_sm4_key] +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_sm4_key] +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_sym_key.h" +#include "file.h" + +OH_Crypto_ErrCode testGenerateSM4Key() +{ + OH_CryptoSymKeyGenerator *ctx = nullptr; + OH_CryptoSymKey *keyCtx = nullptr; + Crypto_DataBlob out = {.data = nullptr, .len = 0}; + OH_Crypto_ErrCode ret = OH_CryptoSymKeyGenerator_Create("SM4_128", &ctx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + ret = OH_CryptoSymKeyGenerator_Generate(ctx, &keyCtx); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoSymKeyGenerator_Destroy(ctx); + return ret; + } + ret = OH_CryptoSymKey_GetKeyData(keyCtx, &out); + OH_CryptoSymKeyGenerator_Destroy(ctx); + OH_CryptoSymKey_Destroy(keyCtx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + OH_Crypto_FreeDataBlob(&out); + return ret; +} +// [End generate_sm4_key] diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index a36ca588fe..965554bb3a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 3cf9885f60..f290adcc5a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/ets/pages/Index.ets @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'RandomlyGenerateSymmetricKey'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testGenerateSymKey(); - this.message = 'Call AES Success Result:' + ret.toString(); - }) - Button($r('app.string.call_sm4')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.testGenerateSM4Key(); - this.message = 'Call SM4 Success Result:' + ret.toString(); - }) - } - .width('100%') - .height('100%') - } -} +/* + * 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 { + @State message: string = 'RandomlyGenerateSymmetricKey'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testGenerateSymKey(); + this.message = 'Call AES Success Result:' + ret.toString(); + }) + Button($r('app.string.call_sm4')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.testGenerateSM4Key(); + this.message = 'Call SM4 Success Result:' + ret.toString(); + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/RandomlyGenerateSymmetricKey.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/RandomlyGenerateSymmetricKey.test.ets old mode 100755 new mode 100644 index a6892bf7a7..a764585f42 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/RandomlyGenerateSymmetricKey.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/ets/test/RandomlyGenerateSymmetricKey.test.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function encryptionDecryptionGuidanceAesTest() { - describe('encryptionDecryptionGuidanceAesTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,随机生成对称密钥(AES) - */ - it('testEncryptionDecryptionGuidanceAes001', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAes001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call AES')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call AES Success Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceAes001 end'); - }) - - /** - * 点击按钮,随机生成对称密钥(SM4) - */ - it('testEncryptionDecryptionGuidanceAes002', 0, async () => { - console.info('uitest: testEncryptionDecryptionGuidanceAes002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call SM4')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call SM4 Success Result:0')); - console.info('uitest: testEncryptionDecryptionGuidanceAes002 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function encryptionDecryptionGuidanceAesTest() { + describe('encryptionDecryptionGuidanceAesTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,随机生成对称密钥(AES) + */ + it('testEncryptionDecryptionGuidanceAes001', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAes001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call AES')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call AES Success Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceAes001 end'); + }) + + /** + * 点击按钮,随机生成对称密钥(SM4) + */ + it('testEncryptionDecryptionGuidanceAes002', 0, async () => { + console.info('uitest: testEncryptionDecryptionGuidanceAes002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call SM4')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call SM4 Success Result:0')); + console.info('uitest: testEncryptionDecryptionGuidanceAes002 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/ohosTest.md old mode 100755 new mode 100644 index 02be69a3a1..a2782d5bd9 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/ohosTest.md @@ -1,9 +1,9 @@ -# 随机生成对称密钥(C/C++)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,随机生成对称密钥(AES) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 随机生成对称密钥(C/C++)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,随机生成对称密钥(AES) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,随机生成对称密钥(SM4) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/screenshots/RandomlyGenerateSymmetricKey1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/screenshots/RandomlyGenerateSymmetricKey1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/screenshots/RandomlyGenerateSymmetricKey2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKey/screenshots/RandomlyGenerateSymmetricKey2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/app.json5 old mode 100755 new mode 100644 index d22270a8e1..7375775fcb --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/app.json5 @@ -1,25 +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.randomlygeneratesymmetrickeyarkts", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.randomlygeneratesymmetrickeyarkts", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 6a8e9bbcd3..e5498d2667 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "RandomlyGenerateSymmetricKeyArkTS" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "RandomlyGenerateSymmetricKeyArkTS" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/README.md old mode 100755 new mode 100644 index 091b34bdc5..1c5af4d200 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/README.md @@ -1,75 +1,75 @@ -# 随机生成对称密钥(ArkTS) - -### 介绍 - -以AES和SM4为例,随机生成对称密钥(SymKey),并获得二进制数据。对称密钥对象可用于后续加解密操作,二进制数据可用于存储或运输。 - -本示例主要展示了随机生成对称密钥(ArkTS),随机生成AES、SM4密钥场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [随机生成对称密钥(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-sym-key-randomly.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例RandomlyGenerateSymmetricKeyArkTS.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 随机生成对称密钥(ArkTS)示例代码 - │ │ ├── aes - │ │ | ├── Promise.ets - │ │ | ├── Sync.ets - │ │ ├── sm4 - │ │ | ├── Promise.ets - │ │ | ├── Sync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── RandomlyGenerateSymmetricKeyArkTS.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 随机生成对称密钥(ArkTS) + +### 介绍 + +以AES和SM4为例,随机生成对称密钥(SymKey),并获得二进制数据。对称密钥对象可用于后续加解密操作,二进制数据可用于存储或运输。 + +本示例主要展示了随机生成对称密钥(ArkTS),随机生成AES、SM4密钥场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [随机生成对称密钥(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-sym-key-randomly.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例RandomlyGenerateSymmetricKeyArkTS.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 随机生成对称密钥(ArkTS)示例代码 + │ │ ├── aes + │ │ | ├── Promise.ets + │ │ | ├── Sync.ets + │ │ ├── sm4 + │ │ | ├── Promise.ets + │ │ | ├── Sync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── RandomlyGenerateSymmetricKeyArkTS.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/aes/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/aes/Promise.ets old mode 100755 new mode 100644 index c4d94ea9be..fd0b361f88 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/aes/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/aes/Promise.ets @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_aes_key] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function testGenerateAesKey() { - // 创建SymKeyGenerator实例 - let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256'); - // 使用密钥生成器随机生成对称密钥 - let promiseSymKey = symKeyGenerator.generateSymKey(); - promiseSymKey.then(key => { - // 获取对称密钥的二进制数据,输出256位密钥。长度为32字节 - let encodedKey = key.getEncoded(); - console.info('key hex:' + encodedKey.data); - }); -} -// [End generate_aes_key] - -@Entry -@Component -struct Index { - @State message: string = 'AES Promise'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_promise')) - .width('70%') - .onClick(() => { - try { - testGenerateAesKey(); - this.message = 'AES Promise Success'; - } catch { - this.message = 'AES Promise Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_aes_key] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function testGenerateAesKey() { + // 创建SymKeyGenerator实例 + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256'); + // 使用密钥生成器随机生成对称密钥 + let promiseSymKey = symKeyGenerator.generateSymKey(); + promiseSymKey.then(key => { + // 获取对称密钥的二进制数据,输出256位密钥。长度为32字节 + let encodedKey = key.getEncoded(); + console.info('key hex:' + encodedKey.data); + }); +} +// [End generate_aes_key] + +@Entry +@Component +struct Index { + @State message: string = 'AES Promise'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_promise')) + .width('70%') + .onClick(() => { + try { + testGenerateAesKey(); + this.message = 'AES Promise Success'; + } catch { + this.message = 'AES Promise Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/aes/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/aes/Sync.ets old mode 100755 new mode 100644 index 5548989153..4ff18ccb86 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/aes/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/aes/Sync.ets @@ -1,52 +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. - */ - -// [Start generate_aes_key_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function testSyncGenerateAesKey() { - // 创建SymKeyGenerator实例 - let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256'); - // 使用密钥生成器随机生成对称密钥 - let promiseSymKey = symKeyGenerator.generateSymKeySync(); - // 获取对称密钥的二进制数据,输出256位密钥。长度为32字节 - let encodedKey = promiseSymKey.getEncoded(); - console.info('key hex:' + encodedKey.data); -} -// [End generate_aes_key_sync] - -@Entry -@Component -struct Index { - @State message: string = 'AES Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_aes_sync')) - .width('70%') - .onClick(() => { - try { - testSyncGenerateAesKey(); - this.message = 'AES Sync Success'; - } catch { - this.message = 'AES Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_aes_key_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function testSyncGenerateAesKey() { + // 创建SymKeyGenerator实例 + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256'); + // 使用密钥生成器随机生成对称密钥 + let promiseSymKey = symKeyGenerator.generateSymKeySync(); + // 获取对称密钥的二进制数据,输出256位密钥。长度为32字节 + let encodedKey = promiseSymKey.getEncoded(); + console.info('key hex:' + encodedKey.data); +} +// [End generate_aes_key_sync] + +@Entry +@Component +struct Index { + @State message: string = 'AES Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_aes_sync')) + .width('70%') + .onClick(() => { + try { + testSyncGenerateAesKey(); + this.message = 'AES Sync Success'; + } catch { + this.message = 'AES Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/sm4/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/sm4/Promise.ets old mode 100755 new mode 100644 index 4b090edce6..6936f584a9 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/sm4/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/sm4/Promise.ets @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_sm4_key] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function testGenerateSM4Key() { - // 创建SymKeyGenerator实例 - let symKeyGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); - // 使用密钥生成器随机生成对称密钥 - let promiseSymKey = symKeyGenerator.generateSymKey(); - promiseSymKey.then(key => { - // 获取对称密钥的二进制数据,输出128位字节流。长度为16字节 - let encodedKey = key.getEncoded(); - console.info('key hex:' + encodedKey.data); - }); -} -// [End generate_sm4_key] - -@Entry -@Component -struct Index { - @State message: string = 'SM4 Promise'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_promise')) - .width('70%') - .onClick(() => { - try { - testGenerateSM4Key(); - this.message = 'SM4 Promise Success'; - } catch { - this.message = 'SM4 Promise Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_sm4_key] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function testGenerateSM4Key() { + // 创建SymKeyGenerator实例 + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); + // 使用密钥生成器随机生成对称密钥 + let promiseSymKey = symKeyGenerator.generateSymKey(); + promiseSymKey.then(key => { + // 获取对称密钥的二进制数据,输出128位字节流。长度为16字节 + let encodedKey = key.getEncoded(); + console.info('key hex:' + encodedKey.data); + }); +} +// [End generate_sm4_key] + +@Entry +@Component +struct Index { + @State message: string = 'SM4 Promise'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm4_promise')) + .width('70%') + .onClick(() => { + try { + testGenerateSM4Key(); + this.message = 'SM4 Promise Success'; + } catch { + this.message = 'SM4 Promise Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/sm4/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/sm4/Sync.ets old mode 100755 new mode 100644 index 1f13393702..bd5b0ecfe9 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/sm4/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/ets/pages/sm4/Sync.ets @@ -1,52 +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. - */ - -// [Start generate_sm4_key_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function testSyncGenerateSm4Key() { - // 创建SymKeyGenerator实例 - let symKeyGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); - // 使用密钥生成器随机生成对称密钥 - let promiseSymKey = symKeyGenerator.generateSymKeySync(); - // 获取对称密钥的二进制数据,输出128位字节流。长度为16字节 - let encodedKey = promiseSymKey.getEncoded(); - console.info('key hex:' + encodedKey.data); -} -// [End generate_sm4_key_sync] - -@Entry -@Component -struct Index { - @State message: string = 'SM4 Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm4_sync')) - .width('70%') - .onClick(() => { - try { - testSyncGenerateSm4Key(); - this.message = 'SM4 Sync Success'; - } catch { - this.message = 'SM4 Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_sm4_key_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function testSyncGenerateSm4Key() { + // 创建SymKeyGenerator实例 + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('SM4_128'); + // 使用密钥生成器随机生成对称密钥 + let promiseSymKey = symKeyGenerator.generateSymKeySync(); + // 获取对称密钥的二进制数据,输出128位字节流。长度为16字节 + let encodedKey = promiseSymKey.getEncoded(); + console.info('key hex:' + encodedKey.data); +} +// [End generate_sm4_key_sync] + +@Entry +@Component +struct Index { + @State message: string = 'SM4 Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm4_sync')) + .width('70%') + .onClick(() => { + try { + testSyncGenerateSm4Key(); + this.message = 'SM4 Sync Success'; + } catch { + this.message = 'SM4 Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/RandomlyGenerateSymmetricKeyArkTS.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/RandomlyGenerateSymmetricKeyArkTS.test.ets old mode 100755 new mode 100644 index 47d60062b3..22bd00d9ac --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/RandomlyGenerateSymmetricKeyArkTS.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/ets/test/RandomlyGenerateSymmetricKeyArkTS.test.ets @@ -1,116 +1,116 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function randomlyGenerateSymmetricKeyArkTSTest() { - describe('randomlyGenerateSymmetricKeyArkTSTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,随机生成对称密钥(AES Promise方式) - */ - it('testRandomlyGenerateSymmetricKeyArkTS001', 0, async () => { - console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('AES Promise')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES Promise')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES Promise Success')); - console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,随机生成对称密钥(AES 同步方式) - */ - it('testRandomlyGenerateSymmetricKeyArkTS002', 0, async () => { - console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('AES Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES Sync Success')); - console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,随机生成对称密钥(SM4 Promise方式) - */ - it('testRandomlyGenerateSymmetricKeyArkTS003', 0, async () => { - console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM4 Promise')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM4 Promise')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4 Promise Success')); - console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,随机生成对称密钥(SM4 同步方式) - */ - it('testRandomlyGenerateSymmetricKeyArkTS004', 0, async () => { - console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM4 Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM4 Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM4 Sync Success')); - console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS004 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function randomlyGenerateSymmetricKeyArkTSTest() { + describe('randomlyGenerateSymmetricKeyArkTSTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,随机生成对称密钥(AES Promise方式) + */ + it('testRandomlyGenerateSymmetricKeyArkTS001', 0, async () => { + console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('AES Promise')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES Promise')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES Promise Success')); + console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,随机生成对称密钥(AES 同步方式) + */ + it('testRandomlyGenerateSymmetricKeyArkTS002', 0, async () => { + console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('AES Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES Sync Success')); + console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,随机生成对称密钥(SM4 Promise方式) + */ + it('testRandomlyGenerateSymmetricKeyArkTS003', 0, async () => { + console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM4 Promise')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM4 Promise')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4 Promise Success')); + console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,随机生成对称密钥(SM4 同步方式) + */ + it('testRandomlyGenerateSymmetricKeyArkTS004', 0, async () => { + console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM4 Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM4 Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM4 Sync Success')); + console.info('uitest: testRandomlyGenerateSymmetricKeyArkTS004 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/ohosTest.md old mode 100755 new mode 100644 index d446aed4da..8f40868b3b --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/ohosTest.md @@ -1,11 +1,11 @@ -# 随机生成对称密钥(ArkTS)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,随机生成对称密钥(AES Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,随机生成对称密钥(AES 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,随机生成对称密钥(SM4 Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 随机生成对称密钥(ArkTS)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,随机生成对称密钥(AES Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,随机生成对称密钥(AES 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,随机生成对称密钥(SM4 Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,随机生成对称密钥(SM4 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/screenshots/RandomlyGenerateSymmetricKeyArkTS1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/screenshots/RandomlyGenerateSymmetricKeyArkTS1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/screenshots/RandomlyGenerateSymmetricKeyArkTS2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/RandomlyGenerateSymmetricKeyArkTS/screenshots/RandomlyGenerateSymmetricKeyArkTS2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/app.json5 old mode 100755 new mode 100644 index 2faa5c820b..00a1f3c0bb --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/app.json5 @@ -1,25 +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.specifiedparametersgenerateasymmetrickeypair", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.specifiedparametersgenerateasymmetrickeypair", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 9cce03d52d..564c403420 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SpecifiedParametersGenerateAsymmetricKeyPair" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SpecifiedParametersGenerateAsymmetricKeyPair" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/README.md old mode 100755 new mode 100644 index d82fe2cdbe..d83f64eec0 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/README.md @@ -1,78 +1,78 @@ -# 指定密钥参数生成非对称密钥对 - -### 介绍 - -以RSA、ECC、SM2为例,根据指定的密钥参数,生成非对称密钥对(KeyPair),并获取密钥参数属性。该对象可用于后续的加解密等操作。获取的密钥参数属性可用于存储或运输。 - -本示例主要展示了指定密钥参数生成非对称密钥对,指定密钥参数生成RSA公钥、指定密钥参数生成ECC密钥对、根据椭圆曲线名生成SM2密钥对场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [指定密钥参数生成非对称密钥对](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-asym-key-pair-from-key-spec.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例SpecifiedParametersGenerateAsymmetricKeyPair.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 指定密钥参数生成非对称密钥对示例代码 - │ │ ├── ecc - │ │ | ├── Promise.ets - │ │ | ├── Sync.ets - │ │ ├── rsa - │ │ | ├── Callback.ets - │ │ | ├── Sync.ets - │ │ ├── sm2 - │ │ | ├── Promise.ets - │ │ | ├── Sync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── SpecifiedParametersGenerateAsymmetricKeyPair.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 指定密钥参数生成非对称密钥对 + +### 介绍 + +以RSA、ECC、SM2为例,根据指定的密钥参数,生成非对称密钥对(KeyPair),并获取密钥参数属性。该对象可用于后续的加解密等操作。获取的密钥参数属性可用于存储或运输。 + +本示例主要展示了指定密钥参数生成非对称密钥对,指定密钥参数生成RSA公钥、指定密钥参数生成ECC密钥对、根据椭圆曲线名生成SM2密钥对场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [指定密钥参数生成非对称密钥对](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-asym-key-pair-from-key-spec.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例SpecifiedParametersGenerateAsymmetricKeyPair.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 指定密钥参数生成非对称密钥对示例代码 + │ │ ├── ecc + │ │ | ├── Promise.ets + │ │ | ├── Sync.ets + │ │ ├── rsa + │ │ | ├── Callback.ets + │ │ | ├── Sync.ets + │ │ ├── sm2 + │ │ | ├── Promise.ets + │ │ | ├── Sync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── SpecifiedParametersGenerateAsymmetricKeyPair.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair > .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/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/ecc/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/ecc/Promise.ets old mode 100755 new mode 100644 index 1cf4004061..69f5202462 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/ecc/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/ecc/Promise.ets @@ -1,144 +1,144 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start specify_parameter_generate_ecc_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -// 打印bigint信息 -function showBigIntInfo(bnName: string, bnValue: bigint | string | number) { - if (typeof bnValue === 'string') { - console.error('type is string'); - return; - } - if (typeof bnValue === 'number') { - console.error('type is number'); - return; - } - console.info(bnName + ':'); - console.info('. Decimal: ' + bnValue.toString()); - console.info('. Hexadecimal: ' + bnValue.toString(16)); - console.info('. Length (bits): ' + bnValue.toString(2).length); -} - -// 根据关键规范构造EccCommonSpec结构体。EccCommonSpec结构体定义了ECC私钥和公钥的公共参数 -function genEccCommonSpec(): cryptoFramework.ECCCommonParamsSpec { - let fieldFp: cryptoFramework.ECFieldFp = { - fieldType: 'Fp', - p: BigInt('0xffffffffffffffffffffffffffffffff000000000000000000000001') - } - let G: cryptoFramework.Point = { - x: BigInt('0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21'), - y: BigInt('0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34') - } - let eccCommonSpec: cryptoFramework.ECCCommonParamsSpec = { - algName: 'ECC', - specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC, - field: fieldFp, - a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe'), - b: BigInt('0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4'), - g: G, - n: BigInt('0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d'), - h: 1 - } - return eccCommonSpec; -} - -// 打印ECC密钥规格 -function showEccSpecDetailInfo(key: cryptoFramework.PubKey | cryptoFramework.PriKey, keyType: string) { - console.info('show detail of ' + keyType + ':'); - try { - let p = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FP_P_BN); - showBigIntInfo('--- p', p); // length is 224, hex : ffffffffffffffffffffffffffffffff000000000000000000000001 - let a = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_A_BN); - showBigIntInfo('--- a', a); // length is 224, hex : fffffffffffffffffffffffffffffffefffffffffffffffffffffffe - let b = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_B_BN); - showBigIntInfo('--- b', b); // length is 224, hex : b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4 - let gX = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_G_X_BN); - showBigIntInfo('--- gX', gX); // length is 224, hex : b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21 - let gY = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_G_Y_BN); - showBigIntInfo('--- gY', gY); // length is 224, hex : bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34 - let n = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_N_BN); - showBigIntInfo('--- n', n); // length is 224, hex : ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d - let h = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_H_NUM); - console.warn('--- h: ' + h); // key h: 1 - let fieldType = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FIELD_TYPE_STR); - console.warn('--- field type: ' + fieldType); // key field type: Fp - let fieldSize = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FIELD_SIZE_NUM); - console.warn('--- field size: ' + fieldSize); // key field size: 224 - let curveName = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_CURVE_NAME_STR); - console.warn('--- curve name: ' + curveName); // key curve name: NID_secp224r1 - if (keyType == 'priKey') { - let sk = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_SK_BN); - showBigIntInfo('--- sk', sk); - } else if (keyType == 'pubKey') { - let pkX = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_PK_X_BN); - showBigIntInfo('--- pkX', pkX); - let pkY = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_PK_Y_BN); - showBigIntInfo('--- pkY', pkY); - } - } catch (error) { - console.error('getAsyKeySpec error'); - let e: BusinessError = error as BusinessError; - console.error(`getAsyKeySpec failed, ${e.code}, ${e.message}`); - } -} - -// 根据EccCommonSpec实例生成ECC密钥对,获取密钥规格 -function testEccUseCommKeySpecGet() { - try { - let commKeySpec = genEccCommonSpec(); // 使用参数属性,构造ECC公私钥公共密钥参数对象 - let generatorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(commKeySpec); // 使用密钥参数对象创建生成器 - let keyPairPromise = generatorBySpec.generateKeyPair(); // Generate an ECC key pair. - keyPairPromise.then(keyPair => { // 使用生成器创建ECC密钥对 - showEccSpecDetailInfo(keyPair.priKey, 'priKey'); // 对私钥获取相关密钥参数属性 - showEccSpecDetailInfo(keyPair.pubKey, 'pubKey'); // 对公钥获取相关密钥参数属性 - }).catch((error: BusinessError) => { - // 逻辑错误等异步异常在此捕获 - console.error('generateComm error'); - console.error('error code: ' + error.code + ', message is: ' + error.message); - }) - } catch (error) { - // 参数错误等同步异常在此捕获 - console.error('testEccUseCommSpec error'); - let e: BusinessError = error as BusinessError; - console.error(`ecc comm spec failed, ${e.code}, ${e.message}`); - } -} -// [End specify_parameter_generate_ecc_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'ECC Promise'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_ecc_promise')) - .width('70%') - .onClick(() => { - try { - testEccUseCommKeySpecGet(); - this.message = 'ECC Promise Success'; - } catch { - this.message = 'ECC Promise Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start specify_parameter_generate_ecc_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +// 打印bigint信息 +function showBigIntInfo(bnName: string, bnValue: bigint | string | number) { + if (typeof bnValue === 'string') { + console.error('type is string'); + return; + } + if (typeof bnValue === 'number') { + console.error('type is number'); + return; + } + console.info(bnName + ':'); + console.info('. Decimal: ' + bnValue.toString()); + console.info('. Hexadecimal: ' + bnValue.toString(16)); + console.info('. Length (bits): ' + bnValue.toString(2).length); +} + +// 根据关键规范构造EccCommonSpec结构体。EccCommonSpec结构体定义了ECC私钥和公钥的公共参数 +function genEccCommonSpec(): cryptoFramework.ECCCommonParamsSpec { + let fieldFp: cryptoFramework.ECFieldFp = { + fieldType: 'Fp', + p: BigInt('0xffffffffffffffffffffffffffffffff000000000000000000000001') + } + let G: cryptoFramework.Point = { + x: BigInt('0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21'), + y: BigInt('0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34') + } + let eccCommonSpec: cryptoFramework.ECCCommonParamsSpec = { + algName: 'ECC', + specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC, + field: fieldFp, + a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe'), + b: BigInt('0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4'), + g: G, + n: BigInt('0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d'), + h: 1 + } + return eccCommonSpec; +} + +// 打印ECC密钥规格 +function showEccSpecDetailInfo(key: cryptoFramework.PubKey | cryptoFramework.PriKey, keyType: string) { + console.info('show detail of ' + keyType + ':'); + try { + let p = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FP_P_BN); + showBigIntInfo('--- p', p); // length is 224, hex : ffffffffffffffffffffffffffffffff000000000000000000000001 + let a = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_A_BN); + showBigIntInfo('--- a', a); // length is 224, hex : fffffffffffffffffffffffffffffffefffffffffffffffffffffffe + let b = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_B_BN); + showBigIntInfo('--- b', b); // length is 224, hex : b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4 + let gX = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_G_X_BN); + showBigIntInfo('--- gX', gX); // length is 224, hex : b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21 + let gY = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_G_Y_BN); + showBigIntInfo('--- gY', gY); // length is 224, hex : bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34 + let n = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_N_BN); + showBigIntInfo('--- n', n); // length is 224, hex : ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d + let h = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_H_NUM); + console.warn('--- h: ' + h); // key h: 1 + let fieldType = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FIELD_TYPE_STR); + console.warn('--- field type: ' + fieldType); // key field type: Fp + let fieldSize = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FIELD_SIZE_NUM); + console.warn('--- field size: ' + fieldSize); // key field size: 224 + let curveName = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_CURVE_NAME_STR); + console.warn('--- curve name: ' + curveName); // key curve name: NID_secp224r1 + if (keyType == 'priKey') { + let sk = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_SK_BN); + showBigIntInfo('--- sk', sk); + } else if (keyType == 'pubKey') { + let pkX = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_PK_X_BN); + showBigIntInfo('--- pkX', pkX); + let pkY = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_PK_Y_BN); + showBigIntInfo('--- pkY', pkY); + } + } catch (error) { + console.error('getAsyKeySpec error'); + let e: BusinessError = error as BusinessError; + console.error(`getAsyKeySpec failed, ${e.code}, ${e.message}`); + } +} + +// 根据EccCommonSpec实例生成ECC密钥对,获取密钥规格 +function testEccUseCommKeySpecGet() { + try { + let commKeySpec = genEccCommonSpec(); // 使用参数属性,构造ECC公私钥公共密钥参数对象 + let generatorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(commKeySpec); // 使用密钥参数对象创建生成器 + let keyPairPromise = generatorBySpec.generateKeyPair(); // Generate an ECC key pair. + keyPairPromise.then(keyPair => { // 使用生成器创建ECC密钥对 + showEccSpecDetailInfo(keyPair.priKey, 'priKey'); // 对私钥获取相关密钥参数属性 + showEccSpecDetailInfo(keyPair.pubKey, 'pubKey'); // 对公钥获取相关密钥参数属性 + }).catch((error: BusinessError) => { + // 逻辑错误等异步异常在此捕获 + console.error('generateComm error'); + console.error('error code: ' + error.code + ', message is: ' + error.message); + }) + } catch (error) { + // 参数错误等同步异常在此捕获 + console.error('testEccUseCommSpec error'); + let e: BusinessError = error as BusinessError; + console.error(`ecc comm spec failed, ${e.code}, ${e.message}`); + } +} +// [End specify_parameter_generate_ecc_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'ECC Promise'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_ecc_promise')) + .width('70%') + .onClick(() => { + try { + testEccUseCommKeySpecGet(); + this.message = 'ECC Promise Success'; + } catch { + this.message = 'ECC Promise Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/ecc/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/ecc/Sync.ets old mode 100755 new mode 100644 index 85cc541dad..0770504c59 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/ecc/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/ecc/Sync.ets @@ -1,136 +1,136 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start specify_parameter_generate_ecc_keypair_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function showBigIntInfo(bnName: string, bnValue: bigint | string | number) { - if (typeof bnValue === 'string') { - console.error('type is string'); - return; - } - if (typeof bnValue === 'number') { - console.error('type is number'); - return; - } - console.info(bnName + ':'); - console.info('. Decimal: ' + bnValue.toString()); - console.info('. Hexadecimal: ' + bnValue.toString(16)); - console.info('. Length (bits): ' + bnValue.toString(2).length); -} - -// 根据关键规范构造EccCommonSpec结构体。EccCommonSpec结构体定义了ECC私钥和公钥的公共参数 -function genEccCommonSpec(): cryptoFramework.ECCCommonParamsSpec { - let fieldFp: cryptoFramework.ECFieldFp = { - fieldType: 'Fp', - p: BigInt('0xffffffffffffffffffffffffffffffff000000000000000000000001') - } - let G: cryptoFramework.Point = { - x: BigInt('0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21'), - y: BigInt('0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34') - } - let eccCommonSpec: cryptoFramework.ECCCommonParamsSpec = { - algName: 'ECC', - specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC, - field: fieldFp, - a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe'), - b: BigInt('0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4'), - g: G, - n: BigInt('0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d'), - h: 1 - } - return eccCommonSpec; -} - -// 打印ECC密钥规格 -function showEccSpecDetailInfo(key: cryptoFramework.PubKey | cryptoFramework.PriKey, keyType: string) { - console.info('show detail of ' + keyType + ':'); - try { - let p = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FP_P_BN); - showBigIntInfo('--- p', p); // length is 224, hex : ffffffffffffffffffffffffffffffff000000000000000000000001 - let a = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_A_BN); - showBigIntInfo('--- a', a); // length is 224, hex : fffffffffffffffffffffffffffffffefffffffffffffffffffffffe - let b = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_B_BN); - showBigIntInfo('--- b', b); // length is 224, hex : b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4 - let gX = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_G_X_BN); - showBigIntInfo('--- gX', gX); // length is 224, hex : b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21 - let gY = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_G_Y_BN); - showBigIntInfo('--- gY', gY); // length is 224, hex : bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34 - let n = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_N_BN); - showBigIntInfo('--- n', n); // length is 224, hex : ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d - let h = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_H_NUM); - console.warn('--- h: ' + h); // key h: 1 - let fieldType = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FIELD_TYPE_STR); - console.warn('--- field type: ' + fieldType); // key field type: Fp - let fieldSize = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FIELD_SIZE_NUM); - console.warn('--- field size: ' + fieldSize); // key field size: 224 - let curveName = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_CURVE_NAME_STR); - console.warn('--- curve name: ' + curveName); // key curve name: NID_secp224r1 - if (keyType == 'priKey') { - let sk = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_SK_BN); - showBigIntInfo('--- sk', sk); - } else if (keyType == 'pubKey') { - let pkX = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_PK_X_BN); - showBigIntInfo('--- pkX', pkX); - let pkY = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_PK_Y_BN); - showBigIntInfo('--- pkY', pkY); - } - } catch (e) { - console.error(`getAsyKeySpec failed, ${e.code}, ${e.message}`); - } -} - -// 根据EccCommonSpec实例生成ECC密钥对,获取密钥规格 -function testEccUseCommKeySpecGetSync() { - try { - let commKeySpec = genEccCommonSpec(); // 使用参数属性,构造ECC公私钥公共密钥参数对象 - let generatorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(commKeySpec); // 使用密钥参数对象创建生成器 - let keyPair = generatorBySpec.generateKeyPairSync(); // Generate an ECC key pair. - if (keyPair != null) { - showEccSpecDetailInfo(keyPair.priKey, 'priKey'); // 对私钥获取相关密钥参数属性 - showEccSpecDetailInfo(keyPair.pubKey, 'pubKey'); // 对公钥获取相关密钥参数属性 - } else { - console.error('get key pair result fail!'); - } - } catch (e) { - // 逻辑错误等异常在此捕获 - console.error(`get key pair result fail, ${e.code}, ${e.message}`); - } -} -// [End specify_parameter_generate_ecc_keypair_sync] - -@Entry -@Component -struct Index { - @State message: string = 'ECC Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_ecc_sync')) - .width('70%') - .onClick(() => { - try { - testEccUseCommKeySpecGetSync(); - this.message = 'ECC Sync Success'; - } catch { - this.message = 'ECC Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start specify_parameter_generate_ecc_keypair_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function showBigIntInfo(bnName: string, bnValue: bigint | string | number) { + if (typeof bnValue === 'string') { + console.error('type is string'); + return; + } + if (typeof bnValue === 'number') { + console.error('type is number'); + return; + } + console.info(bnName + ':'); + console.info('. Decimal: ' + bnValue.toString()); + console.info('. Hexadecimal: ' + bnValue.toString(16)); + console.info('. Length (bits): ' + bnValue.toString(2).length); +} + +// 根据关键规范构造EccCommonSpec结构体。EccCommonSpec结构体定义了ECC私钥和公钥的公共参数 +function genEccCommonSpec(): cryptoFramework.ECCCommonParamsSpec { + let fieldFp: cryptoFramework.ECFieldFp = { + fieldType: 'Fp', + p: BigInt('0xffffffffffffffffffffffffffffffff000000000000000000000001') + } + let G: cryptoFramework.Point = { + x: BigInt('0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21'), + y: BigInt('0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34') + } + let eccCommonSpec: cryptoFramework.ECCCommonParamsSpec = { + algName: 'ECC', + specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC, + field: fieldFp, + a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe'), + b: BigInt('0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4'), + g: G, + n: BigInt('0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d'), + h: 1 + } + return eccCommonSpec; +} + +// 打印ECC密钥规格 +function showEccSpecDetailInfo(key: cryptoFramework.PubKey | cryptoFramework.PriKey, keyType: string) { + console.info('show detail of ' + keyType + ':'); + try { + let p = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FP_P_BN); + showBigIntInfo('--- p', p); // length is 224, hex : ffffffffffffffffffffffffffffffff000000000000000000000001 + let a = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_A_BN); + showBigIntInfo('--- a', a); // length is 224, hex : fffffffffffffffffffffffffffffffefffffffffffffffffffffffe + let b = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_B_BN); + showBigIntInfo('--- b', b); // length is 224, hex : b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4 + let gX = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_G_X_BN); + showBigIntInfo('--- gX', gX); // length is 224, hex : b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21 + let gY = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_G_Y_BN); + showBigIntInfo('--- gY', gY); // length is 224, hex : bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34 + let n = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_N_BN); + showBigIntInfo('--- n', n); // length is 224, hex : ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d + let h = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_H_NUM); + console.warn('--- h: ' + h); // key h: 1 + let fieldType = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FIELD_TYPE_STR); + console.warn('--- field type: ' + fieldType); // key field type: Fp + let fieldSize = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_FIELD_SIZE_NUM); + console.warn('--- field size: ' + fieldSize); // key field size: 224 + let curveName = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_CURVE_NAME_STR); + console.warn('--- curve name: ' + curveName); // key curve name: NID_secp224r1 + if (keyType == 'priKey') { + let sk = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_SK_BN); + showBigIntInfo('--- sk', sk); + } else if (keyType == 'pubKey') { + let pkX = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_PK_X_BN); + showBigIntInfo('--- pkX', pkX); + let pkY = key.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_PK_Y_BN); + showBigIntInfo('--- pkY', pkY); + } + } catch (e) { + console.error(`getAsyKeySpec failed, ${e.code}, ${e.message}`); + } +} + +// 根据EccCommonSpec实例生成ECC密钥对,获取密钥规格 +function testEccUseCommKeySpecGetSync() { + try { + let commKeySpec = genEccCommonSpec(); // 使用参数属性,构造ECC公私钥公共密钥参数对象 + let generatorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(commKeySpec); // 使用密钥参数对象创建生成器 + let keyPair = generatorBySpec.generateKeyPairSync(); // Generate an ECC key pair. + if (keyPair != null) { + showEccSpecDetailInfo(keyPair.priKey, 'priKey'); // 对私钥获取相关密钥参数属性 + showEccSpecDetailInfo(keyPair.pubKey, 'pubKey'); // 对公钥获取相关密钥参数属性 + } else { + console.error('get key pair result fail!'); + } + } catch (e) { + // 逻辑错误等异常在此捕获 + console.error(`get key pair result fail, ${e.code}, ${e.message}`); + } +} +// [End specify_parameter_generate_ecc_keypair_sync] + +@Entry +@Component +struct Index { + @State message: string = 'ECC Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_ecc_sync')) + .width('70%') + .onClick(() => { + try { + testEccUseCommKeySpecGetSync(); + this.message = 'ECC Sync Success'; + } catch { + this.message = 'ECC Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/rsa/Callback.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/rsa/Callback.ets old mode 100755 new mode 100644 index 27ffea8b49..c1bfb5e14d --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/rsa/Callback.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/rsa/Callback.ets @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start specify_parameter_generate_rsa_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -// RSA公钥密钥参数生成函数 -function genRsaPubKeySpec(nIn: bigint, eIn: bigint): cryptoFramework.RSAPubKeySpec { - let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { - n: nIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC - }; - let rsaPubKeySpec: cryptoFramework.RSAPubKeySpec = { - params: rsaCommSpec, - pk: eIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.PUBLIC_KEY_SPEC - }; - return rsaPubKeySpec; -} - -// 根据密钥参数构造RSA公钥规范对象 -function genRsa2048PubKeySpec() { - let nIn = - BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc4' + - '328daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee' + - '34e4d933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7' + - 'afa7ac59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c' + - '0589c3e253f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); - let eIn = BigInt('0x010001'); - return genRsaPubKeySpec(nIn, eIn); -} - -// 将RSA公钥规格与预期值进行比较 -function compareRsaPubKeyBySpec(rsaKeySpec: cryptoFramework.RSAPubKeySpec, n: bigint | string | number, - e: bigint | string | number) { - if (typeof n === 'string' || typeof e === 'string') { - console.error('type is string'); - return false; - } - if (typeof n === 'number' || typeof e === 'number') { - console.error('type is number'); - return false; - } - if (rsaKeySpec.params.n != n) { - return false; - } - if (rsaKeySpec.pk != e) { - return false; - } - return true; -} - -// 根据RSA公钥规格生成RSA公钥,获取密钥规格,并与预期值进行比较 -function rsaUsePubKeySpecGetCallback() { - let rsaPubKeySpec = genRsa2048PubKeySpec(); - let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaPubKeySpec); - rsaGeneratorSpec.generatePubKey((error, key) => { - if (error) { - console.error('generate pubKey error' + 'error code: ' + error.code + 'error message' + error.message); - } - let pubKey = key; - let nBN = pubKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.RSA_N_BN); - let eBN = pubKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.RSA_PK_BN); - if (compareRsaPubKeyBySpec(rsaPubKeySpec, nBN, eBN) != true) { - console.error('error pub key big number'); - } else { - console.info('n, e in the pubKey are same as the spec.'); - } - }); -} -// [End specify_parameter_generate_rsa_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'RSA Callback'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_callback')) - .width('70%') - .onClick(() => { - try { - rsaUsePubKeySpecGetCallback(); - this.message = 'RSA Callback Success'; - } catch { - this.message = 'RSA Callback Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start specify_parameter_generate_rsa_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +// RSA公钥密钥参数生成函数 +function genRsaPubKeySpec(nIn: bigint, eIn: bigint): cryptoFramework.RSAPubKeySpec { + let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { + n: nIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC + }; + let rsaPubKeySpec: cryptoFramework.RSAPubKeySpec = { + params: rsaCommSpec, + pk: eIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.PUBLIC_KEY_SPEC + }; + return rsaPubKeySpec; +} + +// 根据密钥参数构造RSA公钥规范对象 +function genRsa2048PubKeySpec() { + let nIn = + BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc4' + + '328daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee' + + '34e4d933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7' + + 'afa7ac59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c' + + '0589c3e253f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); + let eIn = BigInt('0x010001'); + return genRsaPubKeySpec(nIn, eIn); +} + +// 将RSA公钥规格与预期值进行比较 +function compareRsaPubKeyBySpec(rsaKeySpec: cryptoFramework.RSAPubKeySpec, n: bigint | string | number, + e: bigint | string | number) { + if (typeof n === 'string' || typeof e === 'string') { + console.error('type is string'); + return false; + } + if (typeof n === 'number' || typeof e === 'number') { + console.error('type is number'); + return false; + } + if (rsaKeySpec.params.n != n) { + return false; + } + if (rsaKeySpec.pk != e) { + return false; + } + return true; +} + +// 根据RSA公钥规格生成RSA公钥,获取密钥规格,并与预期值进行比较 +function rsaUsePubKeySpecGetCallback() { + let rsaPubKeySpec = genRsa2048PubKeySpec(); + let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaPubKeySpec); + rsaGeneratorSpec.generatePubKey((error, key) => { + if (error) { + console.error('generate pubKey error' + 'error code: ' + error.code + 'error message' + error.message); + } + let pubKey = key; + let nBN = pubKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.RSA_N_BN); + let eBN = pubKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.RSA_PK_BN); + if (compareRsaPubKeyBySpec(rsaPubKeySpec, nBN, eBN) != true) { + console.error('error pub key big number'); + } else { + console.info('n, e in the pubKey are same as the spec.'); + } + }); +} +// [End specify_parameter_generate_rsa_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'RSA Callback'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_callback')) + .width('70%') + .onClick(() => { + try { + rsaUsePubKeySpecGetCallback(); + this.message = 'RSA Callback Success'; + } catch { + this.message = 'RSA Callback Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/rsa/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/rsa/Sync.ets old mode 100755 new mode 100644 index f4648a0586..e7e3cf1c5c --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/rsa/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/rsa/Sync.ets @@ -1,112 +1,112 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start specify_parameter_generate_rsa_keypair_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -// RSA公钥密钥参数生成函数 -function genRsaPubKeySpec(nIn: bigint, eIn: bigint): cryptoFramework.RSAPubKeySpec { - let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { - n: nIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC - }; - let rsaPubKeySpec: cryptoFramework.RSAPubKeySpec = { - params: rsaCommSpec, - pk: eIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.PUBLIC_KEY_SPEC - }; - return rsaPubKeySpec; -} - -// 根据密钥参数构造RSA公钥规范对象 -function genRsa2048PubKeySpec() { - let nIn = - BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc43' + - '28daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee34' + - 'e4d933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7afa' + - '7ac59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c0589' + - 'c3e253f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); - let eIn = BigInt('0x010001'); - return genRsaPubKeySpec(nIn, eIn); -} - -// 将RSA公钥规格与预期值进行比较 -function compareRsaPubKeyBySpec(rsaKeySpec: cryptoFramework.RSAPubKeySpec, n: bigint | string | number, - e: bigint | string | number) { - if (typeof n === 'string' || typeof e === 'string') { - console.error('type is string'); - return false; - } - if (typeof n === 'number' || typeof e === 'number') { - console.error('type is number'); - return false; - } - if (rsaKeySpec.params.n != n) { - return false; - } - if (rsaKeySpec.pk != e) { - return false; - } - return true; -} - -// 根据RSA公钥规格生成RSA公钥,获取密钥规格,并与预期值进行比较 -function rsaUsePubKeySpecGetSync() { - let rsaPubKeySpec = genRsa2048PubKeySpec(); - let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaPubKeySpec); - try { - let pubKey = rsaGeneratorSpec.generatePubKeySync(); - if (pubKey != null) { - let nBN = pubKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.RSA_N_BN); - let eBN = pubKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.RSA_PK_BN); - if (compareRsaPubKeyBySpec(rsaPubKeySpec, nBN, eBN) != true) { - console.error('error pub key big number'); - } else { - console.info('n, e in the pubKey are same as the spec.'); - } - } else { - console.error('get pub key result fail!'); - } - } catch (e) { - console.error(`get pub key result fail, ${e.code}, ${e.message}`); - } -} -// [End specify_parameter_generate_rsa_keypair_sync] - -@Entry -@Component -struct Index { - @State message: string = 'RSA Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_rsa_sync')) - .width('70%') - .onClick(() => { - try { - rsaUsePubKeySpecGetSync(); - this.message = 'RSA Sync Success'; - } catch { - this.message = 'RSA Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start specify_parameter_generate_rsa_keypair_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +// RSA公钥密钥参数生成函数 +function genRsaPubKeySpec(nIn: bigint, eIn: bigint): cryptoFramework.RSAPubKeySpec { + let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { + n: nIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC + }; + let rsaPubKeySpec: cryptoFramework.RSAPubKeySpec = { + params: rsaCommSpec, + pk: eIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.PUBLIC_KEY_SPEC + }; + return rsaPubKeySpec; +} + +// 根据密钥参数构造RSA公钥规范对象 +function genRsa2048PubKeySpec() { + let nIn = + BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc43' + + '28daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee34' + + 'e4d933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7afa' + + '7ac59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c0589' + + 'c3e253f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); + let eIn = BigInt('0x010001'); + return genRsaPubKeySpec(nIn, eIn); +} + +// 将RSA公钥规格与预期值进行比较 +function compareRsaPubKeyBySpec(rsaKeySpec: cryptoFramework.RSAPubKeySpec, n: bigint | string | number, + e: bigint | string | number) { + if (typeof n === 'string' || typeof e === 'string') { + console.error('type is string'); + return false; + } + if (typeof n === 'number' || typeof e === 'number') { + console.error('type is number'); + return false; + } + if (rsaKeySpec.params.n != n) { + return false; + } + if (rsaKeySpec.pk != e) { + return false; + } + return true; +} + +// 根据RSA公钥规格生成RSA公钥,获取密钥规格,并与预期值进行比较 +function rsaUsePubKeySpecGetSync() { + let rsaPubKeySpec = genRsa2048PubKeySpec(); + let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaPubKeySpec); + try { + let pubKey = rsaGeneratorSpec.generatePubKeySync(); + if (pubKey != null) { + let nBN = pubKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.RSA_N_BN); + let eBN = pubKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.RSA_PK_BN); + if (compareRsaPubKeyBySpec(rsaPubKeySpec, nBN, eBN) != true) { + console.error('error pub key big number'); + } else { + console.info('n, e in the pubKey are same as the spec.'); + } + } else { + console.error('get pub key result fail!'); + } + } catch (e) { + console.error(`get pub key result fail, ${e.code}, ${e.message}`); + } +} +// [End specify_parameter_generate_rsa_keypair_sync] + +@Entry +@Component +struct Index { + @State message: string = 'RSA Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_rsa_sync')) + .width('70%') + .onClick(() => { + try { + rsaUsePubKeySpecGetSync(); + this.message = 'RSA Sync Success'; + } catch { + this.message = 'RSA Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/sm2/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/sm2/Promise.ets old mode 100755 new mode 100644 index 6eff4a965f..689ee6aef9 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/sm2/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/sm2/Promise.ets @@ -1,65 +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. - */ - -// [Start specify_parameter_generate_sm2_keypair] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function genSM2KeyPairSpec() { - let sm2CommonParamsSpec = cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_sm2'); - let sm2KeyPairSpec: cryptoFramework.ECCKeyPairSpec = { - algName: 'SM2', - specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC, - params: sm2CommonParamsSpec, - sk: BigInt('0x6330B599ECD23ABDC74B9A5B7B5E00E553005F72743101C5FAB83AEB579B7074'), - pk: { - x: BigInt('0x67F3B850BDC0BA5D3A29D8A0883C4B17612AB84F87F18E28F77D824A115C02C4'), - y: BigInt('0xD48966CE754BBBEDD6501A1385E1B205C186E926ADED44287145E8897D4B2071') - }, - }; - return sm2KeyPairSpec; -} - -async function sm2Test() { - let sm2KeyPairSpec = genSM2KeyPairSpec(); - let generatorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(sm2KeyPairSpec); - let keyPair = await generatorBySpec.generateKeyPair(); - let sm2CurveName = keyPair.priKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_CURVE_NAME_STR); - console.info('ECC_CURVE_NAME_STR: ' + sm2CurveName); // NID_sm2 -} -// [End specify_parameter_generate_sm2_keypair] - -@Entry -@Component -struct Index { - @State message: string = 'SM2 Promise'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm2_promise')) - .width('70%') - .onClick(async () => { - try { - await sm2Test(); - this.message = 'SM2 Promise Success'; - } catch { - this.message = 'SM2 Promise Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start specify_parameter_generate_sm2_keypair] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function genSM2KeyPairSpec() { + let sm2CommonParamsSpec = cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_sm2'); + let sm2KeyPairSpec: cryptoFramework.ECCKeyPairSpec = { + algName: 'SM2', + specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC, + params: sm2CommonParamsSpec, + sk: BigInt('0x6330B599ECD23ABDC74B9A5B7B5E00E553005F72743101C5FAB83AEB579B7074'), + pk: { + x: BigInt('0x67F3B850BDC0BA5D3A29D8A0883C4B17612AB84F87F18E28F77D824A115C02C4'), + y: BigInt('0xD48966CE754BBBEDD6501A1385E1B205C186E926ADED44287145E8897D4B2071') + }, + }; + return sm2KeyPairSpec; +} + +async function sm2Test() { + let sm2KeyPairSpec = genSM2KeyPairSpec(); + let generatorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(sm2KeyPairSpec); + let keyPair = await generatorBySpec.generateKeyPair(); + let sm2CurveName = keyPair.priKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_CURVE_NAME_STR); + console.info('ECC_CURVE_NAME_STR: ' + sm2CurveName); // NID_sm2 +} +// [End specify_parameter_generate_sm2_keypair] + +@Entry +@Component +struct Index { + @State message: string = 'SM2 Promise'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm2_promise')) + .width('70%') + .onClick(async () => { + try { + await sm2Test(); + this.message = 'SM2 Promise Success'; + } catch { + this.message = 'SM2 Promise Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/sm2/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/sm2/Sync.ets old mode 100755 new mode 100644 index 9344dad94c..a480ed6adc --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/sm2/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/ets/pages/sm2/Sync.ets @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start specify_parameter_generate_sm2_keypair_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function genSM2KeyPairSpec() { - let sm2CommonParamsSpec = cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_sm2'); - let sm2KeyPairSpec: cryptoFramework.ECCKeyPairSpec = { - algName: 'SM2', - specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC, - params: sm2CommonParamsSpec, - sk: BigInt('0x6330B599ECD23ABDC74B9A5B7B5E00E553005F72743101C5FAB83AEB579B7074'), - pk: { - x: BigInt('0x67F3B850BDC0BA5D3A29D8A0883C4B17612AB84F87F18E28F77D824A115C02C4'), - y: BigInt('0xD48966CE754BBBEDD6501A1385E1B205C186E926ADED44287145E8897D4B2071') - }, - }; - return sm2KeyPairSpec; -} - -function sm2TestSync() { - let sm2KeyPairSpec = genSM2KeyPairSpec(); - let generatorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(sm2KeyPairSpec); - try { - let keyPair = generatorBySpec.generateKeyPairSync(); - if (keyPair != null) { - let sm2CurveName = keyPair.priKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_CURVE_NAME_STR); - console.info('ECC_CURVE_NAME_STR: ' + sm2CurveName); // NID_sm2 - } else { - console.error('get key pair result fail!'); - } - } catch (e) { - console.error(`get key pair result fail, ${e.code}, ${e.message}`); - } -} -// [End specify_parameter_generate_sm2_keypair_sync] - -@Entry -@Component -struct Index { - @State message: string = 'SM2 Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm2_sync')) - .width('70%') - .onClick(() => { - try { - sm2TestSync(); - this.message = 'SM2 Sync Success'; - } catch { - this.message = 'SM2 Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start specify_parameter_generate_sm2_keypair_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function genSM2KeyPairSpec() { + let sm2CommonParamsSpec = cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_sm2'); + let sm2KeyPairSpec: cryptoFramework.ECCKeyPairSpec = { + algName: 'SM2', + specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC, + params: sm2CommonParamsSpec, + sk: BigInt('0x6330B599ECD23ABDC74B9A5B7B5E00E553005F72743101C5FAB83AEB579B7074'), + pk: { + x: BigInt('0x67F3B850BDC0BA5D3A29D8A0883C4B17612AB84F87F18E28F77D824A115C02C4'), + y: BigInt('0xD48966CE754BBBEDD6501A1385E1B205C186E926ADED44287145E8897D4B2071') + }, + }; + return sm2KeyPairSpec; +} + +function sm2TestSync() { + let sm2KeyPairSpec = genSM2KeyPairSpec(); + let generatorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(sm2KeyPairSpec); + try { + let keyPair = generatorBySpec.generateKeyPairSync(); + if (keyPair != null) { + let sm2CurveName = keyPair.priKey.getAsyKeySpec(cryptoFramework.AsyKeySpecItem.ECC_CURVE_NAME_STR); + console.info('ECC_CURVE_NAME_STR: ' + sm2CurveName); // NID_sm2 + } else { + console.error('get key pair result fail!'); + } + } catch (e) { + console.error(`get key pair result fail, ${e.code}, ${e.message}`); + } +} +// [End specify_parameter_generate_sm2_keypair_sync] + +@Entry +@Component +struct Index { + @State message: string = 'SM2 Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm2_sync')) + .width('70%') + .onClick(() => { + try { + sm2TestSync(); + this.message = 'SM2 Sync Success'; + } catch { + this.message = 'SM2 Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/SpecifiedParametersGenerateAsymmetricKeyPair.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/SpecifiedParametersGenerateAsymmetricKeyPair.test.ets old mode 100755 new mode 100644 index ff4381d2a5..970c0a23ed --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/SpecifiedParametersGenerateAsymmetricKeyPair.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/ets/test/SpecifiedParametersGenerateAsymmetricKeyPair.test.ets @@ -1,151 +1,151 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function specifiedParametersGenerateAsymmetricKeyPairTest() { - describe('specifiedParametersGenerateAsymmetricKeyPairTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,指定密钥参数生成RSA公钥(callback方式) - */ - it('testSpecifiedParametersGenerateAsymmetricKeyPair001', 0, async () => { - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('ECC Promise')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call ECC Promise')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ECC Promise Success')); - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定密钥参数生成RSA公钥(同步方式) - */ - it('testSpecifiedParametersGenerateAsymmetricKeyPair002', 0, async () => { - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('ECC Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call ECC Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ECC Sync Success')); - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定密钥参数生成ECC密钥对(Promise方式) - */ - it('testSpecifiedParametersGenerateAsymmetricKeyPair003', 0, async () => { - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA Callback')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA Callback')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA Callback Success')); - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,指定密钥参数生成ECC密钥对(同步方式) - */ - it('testSpecifiedParametersGenerateAsymmetricKeyPair004', 0, async () => { - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA Sync Success')); - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair004 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,安根据椭圆曲线名生成SM2密钥对(Promise方式) - */ - it('testSpecifiedParametersGenerateAsymmetricKeyPair005', 0, async () => { - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM2 Promise')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2 Promise')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2 Promise Success')); - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair005 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,根据椭圆曲线名生成SM2密钥对(同步方式) - */ - it('testSpecifiedParametersGenerateAsymmetricKeyPair006', 0, async () => { - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair006 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM2 Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2 Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2 Sync Success')); - console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair006 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function specifiedParametersGenerateAsymmetricKeyPairTest() { + describe('specifiedParametersGenerateAsymmetricKeyPairTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,指定密钥参数生成RSA公钥(callback方式) + */ + it('testSpecifiedParametersGenerateAsymmetricKeyPair001', 0, async () => { + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('ECC Promise')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call ECC Promise')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ECC Promise Success')); + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定密钥参数生成RSA公钥(同步方式) + */ + it('testSpecifiedParametersGenerateAsymmetricKeyPair002', 0, async () => { + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('ECC Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call ECC Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ECC Sync Success')); + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定密钥参数生成ECC密钥对(Promise方式) + */ + it('testSpecifiedParametersGenerateAsymmetricKeyPair003', 0, async () => { + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA Callback')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA Callback')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA Callback Success')); + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,指定密钥参数生成ECC密钥对(同步方式) + */ + it('testSpecifiedParametersGenerateAsymmetricKeyPair004', 0, async () => { + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA Sync Success')); + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair004 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,安根据椭圆曲线名生成SM2密钥对(Promise方式) + */ + it('testSpecifiedParametersGenerateAsymmetricKeyPair005', 0, async () => { + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM2 Promise')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2 Promise')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2 Promise Success')); + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair005 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,根据椭圆曲线名生成SM2密钥对(同步方式) + */ + it('testSpecifiedParametersGenerateAsymmetricKeyPair006', 0, async () => { + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair006 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM2 Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2 Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2 Sync Success')); + console.info('uitest: testSpecifiedParametersGenerateAsymmetricKeyPair006 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/ohosTest.md old mode 100755 new mode 100644 index 8de2bacdab..67e51c6806 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/ohosTest.md @@ -1,13 +1,13 @@ -# 指定密钥参数生成非对称密钥对测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,指定密钥参数生成RSA公钥(callback方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定密钥参数生成RSA公钥(同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定密钥参数生成ECC密钥对(Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,指定密钥参数生成ECC密钥对(同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,安根据椭圆曲线名生成SM2密钥对(Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 指定密钥参数生成非对称密钥对测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,指定密钥参数生成RSA公钥(callback方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定密钥参数生成RSA公钥(同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定密钥参数生成ECC密钥对(Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,指定密钥参数生成ECC密钥对(同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,安根据椭圆曲线名生成SM2密钥对(Promise方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,根据椭圆曲线名生成SM2密钥对(同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/screenshots/SpecifiedParametersGenerateAsymmetricKeyPair1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/screenshots/SpecifiedParametersGenerateAsymmetricKeyPair1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/screenshots/SpecifiedParametersGenerateAsymmetricKeyPair2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyGenerationConversion/SpecifiedParametersGenerateAsymmetricKeyPair/screenshots/SpecifiedParametersGenerateAsymmetricKeyPair2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/app.json5 old mode 100755 new mode 100644 index ad1234818e..09a0c5dcae --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/app.json5 @@ -1,25 +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.keynegotiation", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.keynegotiation", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 80d7691083..3c9c7b5767 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "KeyNegotiation" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "KeyNegotiation" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/README.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/README.md old mode 100755 new mode 100644 index fadad79f8b..0c122b08fc --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/README.md @@ -1,78 +1,78 @@ -# 密钥协商 - -### 介绍 - -本示例主要展示了使用ECDH进行密钥协商(await方式和同步方式)、使用X25519进行密钥协商(await方式和同步方式)、使用DH进行密钥协商(await方式和同步方式)场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用ECDH进行密钥协商](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-key-agreement-using-ecdh.md) -- [使用X25519进行密钥协商](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-key-agreement-using-x25519.md) -- [使用DH进行密钥协商](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-key-agreement-using-dh.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例KeyNegotiation.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 密钥协商示例代码 - │ │ ├── DH - │ │ | ├── DHAsync.ets - │ │ | ├── DHSync.ets - │ │ ├── ECDH - │ │ | ├── EDCHAsync.ets - │ │ | ├── EDCHSync.ets - │ │ ├── X25519 - │ │ | ├── X25519Async.ets - │ │ | ├── X25519Sync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── KeyNegotiation.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 密钥协商 + +### 介绍 + +本示例主要展示了使用ECDH进行密钥协商(await方式和同步方式)、使用X25519进行密钥协商(await方式和同步方式)、使用DH进行密钥协商(await方式和同步方式)场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用ECDH进行密钥协商](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-key-agreement-using-ecdh.md) +- [使用X25519进行密钥协商](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-key-agreement-using-x25519.md) +- [使用DH进行密钥协商](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-key-agreement-using-dh.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例KeyNegotiation.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 密钥协商示例代码 + │ │ ├── DH + │ │ | ├── DHAsync.ets + │ │ | ├── DHSync.ets + │ │ ├── ECDH + │ │ | ├── EDCHAsync.ets + │ │ | ├── EDCHSync.ets + │ │ ├── X25519 + │ │ | ├── X25519Async.ets + │ │ | ├── X25519Sync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── KeyNegotiation.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation > .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/Security/CryptoArchitectureKit/KeyNegotiation/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHAsync.ets old mode 100755 new mode 100644 index efd5f7a375..dacfb015f3 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHAsync.ets @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start use_dh_for_key_negotiation_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -async function dhAwait() { - let keyGen = cryptoFramework.createAsyKeyGenerator('DH_modp1536'); - // 随机生成公私钥对A - let keyPairA = await keyGen.generateKeyPair(); - // 随机生成规格一致的公私钥对B - let keyPairB = await keyGen.generateKeyPair(); - let keyAgreement = cryptoFramework.createKeyAgreement('DH_modp1536'); - // 使用A的公钥和B的私钥进行密钥协商 - let secret1 = await keyAgreement.generateSecret(keyPairB.priKey, keyPairA.pubKey); - // 使用A的私钥和B的公钥进行密钥协商 - let secret2 = await keyAgreement.generateSecret(keyPairA.priKey, keyPairB.pubKey); - // 两种协商的结果应当一致 - if (secret1.data.toString() === secret2.data.toString()) { - console.info('DH success'); - console.info('DH output is ' + secret1.data); - } else { - console.error('DH result is not equal'); - } -} -// [End use_dh_for_key_negotiation_async] - -@Entry -@Component -struct Index { - @State message: string = 'DH Async'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_dh_async')) - .width('70%') - .onClick(async () => { - try { - await dhAwait(); - this.message = 'DH Async Success'; - } catch { - this.message = 'DH Async Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start use_dh_for_key_negotiation_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +async function dhAwait() { + let keyGen = cryptoFramework.createAsyKeyGenerator('DH_modp1536'); + // 随机生成公私钥对A + let keyPairA = await keyGen.generateKeyPair(); + // 随机生成规格一致的公私钥对B + let keyPairB = await keyGen.generateKeyPair(); + let keyAgreement = cryptoFramework.createKeyAgreement('DH_modp1536'); + // 使用A的公钥和B的私钥进行密钥协商 + let secret1 = await keyAgreement.generateSecret(keyPairB.priKey, keyPairA.pubKey); + // 使用A的私钥和B的公钥进行密钥协商 + let secret2 = await keyAgreement.generateSecret(keyPairA.priKey, keyPairB.pubKey); + // 两种协商的结果应当一致 + if (secret1.data.toString() === secret2.data.toString()) { + console.info('DH success'); + console.info('DH output is ' + secret1.data); + } else { + console.error('DH result is not equal'); + } +} +// [End use_dh_for_key_negotiation_async] + +@Entry +@Component +struct Index { + @State message: string = 'DH Async'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_dh_async')) + .width('70%') + .onClick(async () => { + try { + await dhAwait(); + this.message = 'DH Async Success'; + } catch { + this.message = 'DH Async Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHSync.ets old mode 100755 new mode 100644 index 1dad296c72..069442d878 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHSync.ets @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// [Start use_dh_for_key_negotiation_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function dhAwait() { - let keyGen = cryptoFramework.createAsyKeyGenerator('DH_modp1536'); - // 随机生成公私钥对A - let keyPairA = keyGen.generateKeyPairSync(); - // 随机生成规格一致的公私钥对B - let keyPairB = keyGen.generateKeyPairSync(); - let keyAgreement = cryptoFramework.createKeyAgreement('DH_modp1536'); - // 使用A的公钥和B的私钥进行密钥协商 - let secret1 = keyAgreement.generateSecretSync(keyPairB.priKey, keyPairA.pubKey); - // 使用A的私钥和B的公钥进行密钥协商 - let secret2 = keyAgreement.generateSecretSync(keyPairA.priKey, keyPairB.pubKey); - // 两种协商的结果应当一致 - if (secret1.data.toString() === secret2.data.toString()) { - console.info('DH success'); - console.info('DH output is ' + secret1.data); - } else { - console.error('DH result is not equal'); - } -} -// [End use_dh_for_key_negotiation_sync] -@Entry -@Component -struct Index { - @State message: string = 'DH Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_dh_sync')) - .width('70%') - .onClick(() => { - try { - dhAwait(); - this.message = 'DH Sync Success'; - } catch { - this.message = 'DH Async Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start use_dh_for_key_negotiation_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function dhAwait() { + let keyGen = cryptoFramework.createAsyKeyGenerator('DH_modp1536'); + // 随机生成公私钥对A + let keyPairA = keyGen.generateKeyPairSync(); + // 随机生成规格一致的公私钥对B + let keyPairB = keyGen.generateKeyPairSync(); + let keyAgreement = cryptoFramework.createKeyAgreement('DH_modp1536'); + // 使用A的公钥和B的私钥进行密钥协商 + let secret1 = keyAgreement.generateSecretSync(keyPairB.priKey, keyPairA.pubKey); + // 使用A的私钥和B的公钥进行密钥协商 + let secret2 = keyAgreement.generateSecretSync(keyPairA.priKey, keyPairB.pubKey); + // 两种协商的结果应当一致 + if (secret1.data.toString() === secret2.data.toString()) { + console.info('DH success'); + console.info('DH output is ' + secret1.data); + } else { + console.error('DH result is not equal'); + } +} +// [End use_dh_for_key_negotiation_sync] +@Entry +@Component +struct Index { + @State message: string = 'DH Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_dh_sync')) + .width('70%') + .onClick(() => { + try { + dhAwait(); + this.message = 'DH Sync Success'; + } catch { + this.message = 'DH Async Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHAsync.ets old mode 100755 new mode 100644 index 5dc035ea5d..3431de645b --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHAsync.ets @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/// [Start use_ecdh_for_key_negotiation_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -async function ecdhAwait() { - // 假设此公私钥对数据为外部传入 - let pubKeyArray = - new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, - 83, 96, 142, 9, 86, 214, 126, 106, 247, 233, 92, 125, 4, 128, 138, 105, 246, 162, 215, 71, 81, 58, 202, 121, 26, - 105, 211, 55, 130, 45, 236, 143, 55, 16, 248, 75, 167, 160, 167, 106, 2, 152, 243, 44, 68, 66, 0, 167, 99, 92, - 235, 215, 159, 239, 28, 106, 124, 171, 34, 145, 124, 174, 57, 92]); - let priKeyArray = - new Uint8Array([48, 49, 2, 1, 1, 4, 32, 115, 56, 137, 35, 207, 0, 60, 191, 90, 61, 136, 105, 210, 16, 27, 4, 171, - 57, 10, 61, 123, 40, 189, 28, 34, 207, 236, 22, 45, 223, 10, 189, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7]); - let eccGen = cryptoFramework.createAsyKeyGenerator('ECC256'); - // 外部传入的公私钥对A - let keyPairA = await eccGen.convertKey({ data: pubKeyArray }, { data: priKeyArray }); - // 内部生成的公私钥对B - let keyPairB = await eccGen.generateKeyPair(); - let eccKeyAgreement = cryptoFramework.createKeyAgreement('ECC256'); - // 使用A的公钥和B的私钥进行密钥协商 - let secret1 = await eccKeyAgreement.generateSecret(keyPairB.priKey, keyPairA.pubKey); - // 使用A的私钥和B的公钥进行密钥协商 - let secret2 = await eccKeyAgreement.generateSecret(keyPairA.priKey, keyPairB.pubKey); - // 两种协商的结果应当一致 - if (secret1.data.toString() === secret2.data.toString()) { - console.info('ecdh success'); - console.info('ecdh output is ' + secret1.data); - } else { - console.error('ecdh result is not equal'); - } -} - -// [End use_ecdh_for_key_negotiation_async] -@Entry -@Component -struct Index { - @State message: string = 'EDCH Async'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_edch_async')) - .width('70%') - .onClick(async () => { - try { - await ecdhAwait(); - this.message = 'EDCH Async Success'; - } catch { - this.message = 'EDCH Async Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// [Start use_ecdh_for_key_negotiation_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +async function ecdhAwait() { + // 假设此公私钥对数据为外部传入 + let pubKeyArray = + new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, + 83, 96, 142, 9, 86, 214, 126, 106, 247, 233, 92, 125, 4, 128, 138, 105, 246, 162, 215, 71, 81, 58, 202, 121, 26, + 105, 211, 55, 130, 45, 236, 143, 55, 16, 248, 75, 167, 160, 167, 106, 2, 152, 243, 44, 68, 66, 0, 167, 99, 92, + 235, 215, 159, 239, 28, 106, 124, 171, 34, 145, 124, 174, 57, 92]); + let priKeyArray = + new Uint8Array([48, 49, 2, 1, 1, 4, 32, 115, 56, 137, 35, 207, 0, 60, 191, 90, 61, 136, 105, 210, 16, 27, 4, 171, + 57, 10, 61, 123, 40, 189, 28, 34, 207, 236, 22, 45, 223, 10, 189, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7]); + let eccGen = cryptoFramework.createAsyKeyGenerator('ECC256'); + // 外部传入的公私钥对A + let keyPairA = await eccGen.convertKey({ data: pubKeyArray }, { data: priKeyArray }); + // 内部生成的公私钥对B + let keyPairB = await eccGen.generateKeyPair(); + let eccKeyAgreement = cryptoFramework.createKeyAgreement('ECC256'); + // 使用A的公钥和B的私钥进行密钥协商 + let secret1 = await eccKeyAgreement.generateSecret(keyPairB.priKey, keyPairA.pubKey); + // 使用A的私钥和B的公钥进行密钥协商 + let secret2 = await eccKeyAgreement.generateSecret(keyPairA.priKey, keyPairB.pubKey); + // 两种协商的结果应当一致 + if (secret1.data.toString() === secret2.data.toString()) { + console.info('ecdh success'); + console.info('ecdh output is ' + secret1.data); + } else { + console.error('ecdh result is not equal'); + } +} + +// [End use_ecdh_for_key_negotiation_async] +@Entry +@Component +struct Index { + @State message: string = 'EDCH Async'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_edch_async')) + .width('70%') + .onClick(async () => { + try { + await ecdhAwait(); + this.message = 'EDCH Async Success'; + } catch { + this.message = 'EDCH Async Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHSync.ets old mode 100755 new mode 100644 index edf1a0f7d1..0d9af70024 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHSync.ets @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start use_ecdh_for_key_negotiation_sync] - -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function ecdhAwait() { - // 假设此公私钥对数据为外部传入 - let pubKeyArray = - new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, - 83, 96, 142, 9, 86, 214, 126, 106, 247, 233, 92, 125, 4, 128, 138, 105, 246, 162, 215, 71, 81, 58, 202, 121, 26, - 105, 211, 55, 130, 45, 236, 143, 55, 16, 248, 75, 167, 160, 167, 106, 2, 152, 243, 44, 68, 66, 0, 167, 99, 92, - 235, 215, 159, 239, 28, 106, 124, 171, 34, 145, 124, 174, 57, 92]); - let priKeyArray = - new Uint8Array([48, 49, 2, 1, 1, 4, 32, 115, 56, 137, 35, 207, 0, 60, 191, 90, 61, 136, 105, 210, 16, 27, 4, 171, - 57, 10, 61, 123, 40, 189, 28, 34, 207, 236, 22, 45, 223, 10, 189, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7]); - let eccGen = cryptoFramework.createAsyKeyGenerator('ECC256'); - // 外部传入的公私钥对A - let keyPairA = eccGen.convertKeySync({ data: pubKeyArray }, { data: priKeyArray }); - // 内部生成的公私钥对B - let keyPairB = eccGen.generateKeyPairSync(); - let eccKeyAgreement = cryptoFramework.createKeyAgreement('ECC256'); - // 使用A的公钥和B的私钥进行密钥协商 - let secret1 = eccKeyAgreement.generateSecretSync(keyPairB.priKey, keyPairA.pubKey); - // 使用A的私钥和B的公钥进行密钥协商 - let secret2 = eccKeyAgreement.generateSecretSync(keyPairA.priKey, keyPairB.pubKey); - // 两种协商的结果应当一致 - if (secret1.data.toString() === secret2.data.toString()) { - console.info('ecdh success'); - console.info('ecdh output is ' + secret1.data); - } else { - console.error('ecdh result is not equal'); - } -} - -// [End use_ecdh_for_key_negotiation_sync] - -@Entry -@Component -struct Index { - @State message: string = 'EDCH Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_edch_sync')) - .width('70%') - .onClick(() => { - try { - ecdhAwait(); - this.message = 'EDCH Sync Success'; - } catch { - this.message = 'EDCH Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start use_ecdh_for_key_negotiation_sync] + +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function ecdhAwait() { + // 假设此公私钥对数据为外部传入 + let pubKeyArray = + new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, + 83, 96, 142, 9, 86, 214, 126, 106, 247, 233, 92, 125, 4, 128, 138, 105, 246, 162, 215, 71, 81, 58, 202, 121, 26, + 105, 211, 55, 130, 45, 236, 143, 55, 16, 248, 75, 167, 160, 167, 106, 2, 152, 243, 44, 68, 66, 0, 167, 99, 92, + 235, 215, 159, 239, 28, 106, 124, 171, 34, 145, 124, 174, 57, 92]); + let priKeyArray = + new Uint8Array([48, 49, 2, 1, 1, 4, 32, 115, 56, 137, 35, 207, 0, 60, 191, 90, 61, 136, 105, 210, 16, 27, 4, 171, + 57, 10, 61, 123, 40, 189, 28, 34, 207, 236, 22, 45, 223, 10, 189, 160, 10, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7]); + let eccGen = cryptoFramework.createAsyKeyGenerator('ECC256'); + // 外部传入的公私钥对A + let keyPairA = eccGen.convertKeySync({ data: pubKeyArray }, { data: priKeyArray }); + // 内部生成的公私钥对B + let keyPairB = eccGen.generateKeyPairSync(); + let eccKeyAgreement = cryptoFramework.createKeyAgreement('ECC256'); + // 使用A的公钥和B的私钥进行密钥协商 + let secret1 = eccKeyAgreement.generateSecretSync(keyPairB.priKey, keyPairA.pubKey); + // 使用A的私钥和B的公钥进行密钥协商 + let secret2 = eccKeyAgreement.generateSecretSync(keyPairA.priKey, keyPairB.pubKey); + // 两种协商的结果应当一致 + if (secret1.data.toString() === secret2.data.toString()) { + console.info('ecdh success'); + console.info('ecdh output is ' + secret1.data); + } else { + console.error('ecdh result is not equal'); + } +} + +// [End use_ecdh_for_key_negotiation_sync] + +@Entry +@Component +struct Index { + @State message: string = 'EDCH Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_edch_sync')) + .width('70%') + .onClick(() => { + try { + ecdhAwait(); + this.message = 'EDCH Sync Success'; + } catch { + this.message = 'EDCH Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Async.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Async.ets old mode 100755 new mode 100644 index a320edc5a2..bde3bbf28e --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Async.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Async.ets @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start use_x25519a_for_key_negotiation_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -async function x25519Await() { - // 假设此公私钥对数据为外部传入 - let pubKeyArray = - new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 36, 98, 216, 106, 74, 99, 179, 203, 81, 145, 147, 101, - 139, 57, 74, 225, 119, 196, 207, 0, 50, 232, 93, 147, 188, 21, 225, 228, 54, 251, 230, 52]); - let priKeyArray = - new Uint8Array([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 110, 4, 34, 4, 32, 112, 65, 156, 73, 65, 89, 183, 39, 119, - 229, 110, 12, 192, 237, 186, 153, 21, 122, 28, 176, 248, 108, 22, 242, 239, 179, 106, 175, 85, 65, 214, 90]); - let keyGen = cryptoFramework.createAsyKeyGenerator('X25519'); - // 外部传入的公私钥对A - let keyPairA = await keyGen.convertKey({ data: pubKeyArray }, { data: priKeyArray }); - // 内部生成的公私钥对B - let keyPairB = await keyGen.generateKeyPair(); - let keyAgreement = cryptoFramework.createKeyAgreement('X25519'); - // 使用A的公钥和B的私钥进行密钥协商 - let secret1 = await keyAgreement.generateSecret(keyPairB.priKey, keyPairA.pubKey); - // 使用A的私钥和B的公钥进行密钥协商 - let secret2 = await keyAgreement.generateSecret(keyPairA.priKey, keyPairB.pubKey); - // 两种协商的结果应当一致 - if (secret1.data.toString() === secret2.data.toString()) { - console.info('x25519 success'); - console.info('x25519 output is ' + secret1.data); - } else { - console.error('x25519 result is not equal'); - } -} -// [End use_x25519a_for_key_negotiation_async] -@Entry -@Component -struct Index { - @State message: string = 'X25519 Async'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_x25519_async')) - .width('70%') - .onClick(async () => { - try { - await x25519Await(); - this.message = 'X25519 Async Success'; - } catch { - this.message = 'X25519 Async Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start use_x25519a_for_key_negotiation_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +async function x25519Await() { + // 假设此公私钥对数据为外部传入 + let pubKeyArray = + new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 36, 98, 216, 106, 74, 99, 179, 203, 81, 145, 147, 101, + 139, 57, 74, 225, 119, 196, 207, 0, 50, 232, 93, 147, 188, 21, 225, 228, 54, 251, 230, 52]); + let priKeyArray = + new Uint8Array([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 110, 4, 34, 4, 32, 112, 65, 156, 73, 65, 89, 183, 39, 119, + 229, 110, 12, 192, 237, 186, 153, 21, 122, 28, 176, 248, 108, 22, 242, 239, 179, 106, 175, 85, 65, 214, 90]); + let keyGen = cryptoFramework.createAsyKeyGenerator('X25519'); + // 外部传入的公私钥对A + let keyPairA = await keyGen.convertKey({ data: pubKeyArray }, { data: priKeyArray }); + // 内部生成的公私钥对B + let keyPairB = await keyGen.generateKeyPair(); + let keyAgreement = cryptoFramework.createKeyAgreement('X25519'); + // 使用A的公钥和B的私钥进行密钥协商 + let secret1 = await keyAgreement.generateSecret(keyPairB.priKey, keyPairA.pubKey); + // 使用A的私钥和B的公钥进行密钥协商 + let secret2 = await keyAgreement.generateSecret(keyPairA.priKey, keyPairB.pubKey); + // 两种协商的结果应当一致 + if (secret1.data.toString() === secret2.data.toString()) { + console.info('x25519 success'); + console.info('x25519 output is ' + secret1.data); + } else { + console.error('x25519 result is not equal'); + } +} +// [End use_x25519a_for_key_negotiation_async] +@Entry +@Component +struct Index { + @State message: string = 'X25519 Async'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_x25519_async')) + .width('70%') + .onClick(async () => { + try { + await x25519Await(); + this.message = 'X25519 Async Success'; + } catch { + this.message = 'X25519 Async Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Sync.ets old mode 100755 new mode 100644 index 953a34d8c2..d4f82b1059 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Sync.ets @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start use_x25519a_for_key_negotiation_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; - -function x25519Await() { - // 假设此公私钥对数据为外部传入 - let pubKeyArray = - new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 36, 98, 216, 106, 74, 99, 179, 203, 81, 145, 147, 101, - 139, 57, 74, 225, 119, 196, 207, 0, 50, 232, 93, 147, 188, 21, 225, 228, 54, 251, 230, 52]); - let priKeyArray = - new Uint8Array([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 110, 4, 34, 4, 32, 112, 65, 156, 73, 65, 89, 183, 39, 119, - 229, 110, 12, 192, 237, 186, 153, 21, 122, 28, 176, 248, 108, 22, 242, 239, 179, 106, 175, 85, 65, 214, 90]); - let keyGen = cryptoFramework.createAsyKeyGenerator('X25519'); - // 外部传入的公私钥对A - let keyPairA = keyGen.convertKeySync({ data: pubKeyArray }, { data: priKeyArray }); - // 内部生成的公私钥对B - let keyPairB = keyGen.generateKeyPairSync(); - let keyAgreement = cryptoFramework.createKeyAgreement('X25519'); - // 使用A的公钥和B的私钥进行密钥协商 - let secret1 = keyAgreement.generateSecretSync(keyPairB.priKey, keyPairA.pubKey); - // 使用A的私钥和B的公钥进行密钥协商 - let secret2 = keyAgreement.generateSecretSync(keyPairA.priKey, keyPairB.pubKey); - // 两种协商的结果应当一致 - if (secret1.data.toString() === secret2.data.toString()) { - console.info('x25519 success'); - console.info('x25519 output is ' + secret1.data); - } else { - console.error('x25519 result is not equal'); - } -} -// [End use_x25519a_for_key_negotiation_sync] -@Entry -@Component -struct Index { - @State message: string = 'X25519 Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_x25519_sync')) - .width('70%') - .onClick(() => { - try { - x25519Await(); - this.message = 'X25519 Sync Success'; - } catch { - this.message = 'X25519 Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start use_x25519a_for_key_negotiation_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; + +function x25519Await() { + // 假设此公私钥对数据为外部传入 + let pubKeyArray = + new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 36, 98, 216, 106, 74, 99, 179, 203, 81, 145, 147, 101, + 139, 57, 74, 225, 119, 196, 207, 0, 50, 232, 93, 147, 188, 21, 225, 228, 54, 251, 230, 52]); + let priKeyArray = + new Uint8Array([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 110, 4, 34, 4, 32, 112, 65, 156, 73, 65, 89, 183, 39, 119, + 229, 110, 12, 192, 237, 186, 153, 21, 122, 28, 176, 248, 108, 22, 242, 239, 179, 106, 175, 85, 65, 214, 90]); + let keyGen = cryptoFramework.createAsyKeyGenerator('X25519'); + // 外部传入的公私钥对A + let keyPairA = keyGen.convertKeySync({ data: pubKeyArray }, { data: priKeyArray }); + // 内部生成的公私钥对B + let keyPairB = keyGen.generateKeyPairSync(); + let keyAgreement = cryptoFramework.createKeyAgreement('X25519'); + // 使用A的公钥和B的私钥进行密钥协商 + let secret1 = keyAgreement.generateSecretSync(keyPairB.priKey, keyPairA.pubKey); + // 使用A的私钥和B的公钥进行密钥协商 + let secret2 = keyAgreement.generateSecretSync(keyPairA.priKey, keyPairB.pubKey); + // 两种协商的结果应当一致 + if (secret1.data.toString() === secret2.data.toString()) { + console.info('x25519 success'); + console.info('x25519 output is ' + secret1.data); + } else { + console.error('x25519 result is not equal'); + } +} +// [End use_x25519a_for_key_negotiation_sync] +@Entry +@Component +struct Index { + @State message: string = 'X25519 Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_x25519_sync')) + .width('70%') + .onClick(() => { + try { + x25519Await(); + this.message = 'X25519 Sync Success'; + } catch { + this.message = 'X25519 Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/KeyNegotiation.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/KeyNegotiation.test.ets old mode 100755 new mode 100644 index dfa0e0b86f..cece2ce32b --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/KeyNegotiation.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/KeyNegotiation.test.ets @@ -1,152 +1,152 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function keyNegotiationTest() { - describe('keyNegotiationTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用ECDH进行密钥协商(await方式) - */ - it('testKeyNegotiation001', 0, async () => { - console.info('uitest: testKeyNegotiation001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('ECDH Async')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call EDCH Async')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('EDCH Async Success')); - console.info('uitest: testKeyNegotiation001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用ECDH进行密钥协商(同步方式) - */ - it('testKeyNegotiation002', 0, async () => { - console.info('uitest: testKeyNegotiation002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('ECDH Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call EDCH Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('EDCH Sync Success')); - console.info('uitest: testKeyNegotiation002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用X25519进行密钥协商(await方式) - */ - it('testKeyNegotiation003', 0, async () => { - console.info('uitest: testKeyNegotiation003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('X25519 Async')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call X25519 Async')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('X25519 Async Success')); - console.info('uitest: testKeyNegotiation003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用X25519进行密钥协商(同步方式) - */ - it('testKeyNegotiation004', 0, async () => { - console.info('uitest: testKeyNegotiation004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('X25519 Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call X25519 Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('X25519 Sync Success')); - console.info('uitest: testKeyNegotiation004 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用DH进行密钥协商(await方式) - */ - it('testKeyNegotiation005', 0, async () => { - console.info('uitest: testKeyNegotiation005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('DH Async')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call DH Async')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('DH Async Success')); - console.info('uitest: testKeyNegotiation005 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用DH进行密钥协商(同步方式) - */ - it('testKeyNegotiation006', 0, async () => { - console.info('uitest: testKeyNegotiation006 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('DH Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call DH Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('DH Sync Success')); - console.info('uitest: testKeyNegotiation006 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function keyNegotiationTest() { + describe('keyNegotiationTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用ECDH进行密钥协商(await方式) + */ + it('testKeyNegotiation001', 0, async () => { + console.info('uitest: testKeyNegotiation001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('ECDH Async')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call EDCH Async')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('EDCH Async Success')); + console.info('uitest: testKeyNegotiation001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用ECDH进行密钥协商(同步方式) + */ + it('testKeyNegotiation002', 0, async () => { + console.info('uitest: testKeyNegotiation002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('ECDH Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call EDCH Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('EDCH Sync Success')); + console.info('uitest: testKeyNegotiation002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用X25519进行密钥协商(await方式) + */ + it('testKeyNegotiation003', 0, async () => { + console.info('uitest: testKeyNegotiation003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('X25519 Async')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call X25519 Async')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('X25519 Async Success')); + console.info('uitest: testKeyNegotiation003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用X25519进行密钥协商(同步方式) + */ + it('testKeyNegotiation004', 0, async () => { + console.info('uitest: testKeyNegotiation004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('X25519 Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call X25519 Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('X25519 Sync Success')); + console.info('uitest: testKeyNegotiation004 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用DH进行密钥协商(await方式) + */ + it('testKeyNegotiation005', 0, async () => { + console.info('uitest: testKeyNegotiation005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('DH Async')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call DH Async')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('DH Async Success')); + console.info('uitest: testKeyNegotiation005 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用DH进行密钥协商(同步方式) + */ + it('testKeyNegotiation006', 0, async () => { + console.info('uitest: testKeyNegotiation006 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('DH Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call DH Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('DH Sync Success')); + console.info('uitest: testKeyNegotiation006 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/KeyNegotiation/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/ohosTest.md old mode 100755 new mode 100644 index 0c4fd9e85b..b082027408 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/ohosTest.md @@ -1,13 +1,13 @@ -# 密钥协商测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用ECDH进行密钥协商(await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用ECDH进行密钥协商(同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用X25519进行密钥协商(await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用X25519进行密钥协商(同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用DH进行密钥协商(await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 密钥协商测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用ECDH进行密钥协商(await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用ECDH进行密钥协商(同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用X25519进行密钥协商(await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用X25519进行密钥协商(同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用DH进行密钥协商(await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用DH进行密钥协商(同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/screenshots/KeyNegotiation1.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/screenshots/KeyNegotiation1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/screenshots/KeyNegotiation2.png b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/screenshots/KeyNegotiation2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/app.json5 old mode 100755 new mode 100644 index 506c340746..78f9ea61a0 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/app.json5 @@ -1,25 +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.messageauthenticationcode", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.messageauthenticationcode", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 43fb13c245..230944b974 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MessageAuthenticationCode" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "MessageAuthenticationCode" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/README.md b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/README.md old mode 100755 new mode 100644 index b511849f5c..d277f6b7e2 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/README.md @@ -1,73 +1,73 @@ -# 消息认证码计算 - -### 介绍 - -本示例主要展示了消息认证码计算(HMAC、分段HMAC)场景 。该工程中展示的代码详细描述可查如下链接。 - -- [消息认证码计算](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-compute-mac.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例MessageAuthenticationCode.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 消息认证码计算示例代码 - │ │ ├── HMACSegmentation - │ │ | ├── Async.ets - │ │ | ├── Sync.ets - │ │ ├── HMACSingleTime - │ │ | ├── Async.ets - │ │ | ├── Sync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── MessageAuthenticationCode.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 消息认证码计算 + +### 介绍 + +本示例主要展示了消息认证码计算(HMAC、分段HMAC)场景 。该工程中展示的代码详细描述可查如下链接。 + +- [消息认证码计算](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-compute-mac.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例MessageAuthenticationCode.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 消息认证码计算示例代码 + │ │ ├── HMACSegmentation + │ │ | ├── Async.ets + │ │ | ├── Sync.ets + │ │ ├── HMACSingleTime + │ │ | ├── Async.ets + │ │ | ├── Sync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── MessageAuthenticationCode.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode > .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/Security/CryptoArchitectureKit/MessageAuthenticationCode/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Async.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Async.ets old mode 100755 new mode 100644 index 61b41b8f92..b74165d49c --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Async.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Async.ets @@ -1,69 +1,69 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start message_authentication_code_calculation_hmac_one_time_incoming] - -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); - let symKey = await aesGenerator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function doHmac() { - // 把字符串按utf-8解码为Uint8Array,使用固定的128位的密钥,即16字节 - let keyData = new Uint8Array(buffer.from('12345678abcdefgh', 'utf-8').buffer); - let key = await genSymKeyByData(keyData); - let macAlgName = 'SHA256'; // 摘要算法名 - let message = 'hmacTestMessgae'; // 待进行HMAC的数据 - let mac = cryptoFramework.createMac(macAlgName); - await mac.init(key); - // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 - await mac.update({ data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }); - let macResult = await mac.doFinal(); - console.info('HMAC result:' + macResult.data); - let macLen = mac.getMacLength(); - console.info('HMAC len:' + macLen); -} - -// [End message_authentication_code_calculation_hmac_one_time_incoming] - -@Entry -@Component -struct Index { - @State message: string = 'Segmentation Async'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_segmentation_async')) - .width('70%') - .onClick(async () => { - try { - await doHmac(); - this.message = 'Segmentation Async Success'; - } catch { - this.message = 'Segmentation Async Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start message_authentication_code_calculation_hmac_one_time_incoming] + +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +async function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); + let symKey = await aesGenerator.convertKey(symKeyBlob); + console.info('convertKey success'); + return symKey; +} + +async function doHmac() { + // 把字符串按utf-8解码为Uint8Array,使用固定的128位的密钥,即16字节 + let keyData = new Uint8Array(buffer.from('12345678abcdefgh', 'utf-8').buffer); + let key = await genSymKeyByData(keyData); + let macAlgName = 'SHA256'; // 摘要算法名 + let message = 'hmacTestMessgae'; // 待进行HMAC的数据 + let mac = cryptoFramework.createMac(macAlgName); + await mac.init(key); + // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 + await mac.update({ data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }); + let macResult = await mac.doFinal(); + console.info('HMAC result:' + macResult.data); + let macLen = mac.getMacLength(); + console.info('HMAC len:' + macLen); +} + +// [End message_authentication_code_calculation_hmac_one_time_incoming] + +@Entry +@Component +struct Index { + @State message: string = 'Segmentation Async'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_segmentation_async')) + .width('70%') + .onClick(async () => { + try { + await doHmac(); + this.message = 'Segmentation Async Success'; + } catch { + this.message = 'Segmentation Async Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Sync.ets old mode 100755 new mode 100644 index 7fa0b1b7b4..de5f90cfbb --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Sync.ets @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start message_authentication_code_calculation_sync_one_time_incoming] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); - let symKey = aesGenerator.convertKeySync(symKeyBlob); - console.info('[Sync]convertKey success'); - return symKey; -} - -function doHmacBySync() { - // 把字符串按utf-8解码为Uint8Array,使用固定的128位的密钥,即16字节 - let keyData = new Uint8Array(buffer.from('12345678abcdefgh', 'utf-8').buffer); - let key = genSymKeyByData(keyData); - let macAlgName = 'SHA256'; // 摘要算法名 - let message = 'hmacTestMessgae'; // 待进行HMAC的数据 - let mac = cryptoFramework.createMac(macAlgName); - mac.initSync(key); - // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 - mac.updateSync({ data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }); - let macResult = mac.doFinalSync(); - console.info('[Sync]HMAC result:' + macResult.data); - let macLen = mac.getMacLength(); - console.info('HMAC len:' + macLen); -} - -// [End message_authentication_code_calculation_sync_one_time_incoming] - -@Entry -@Component -struct Index { - @State message: string = 'Segmentation Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_segmentation_sync')) - .width('70%') - .onClick(() => { - try { - doHmacBySync(); - this.message = 'Segmentation Sync Success'; - } catch { - this.message = 'Segmentation Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start message_authentication_code_calculation_sync_one_time_incoming] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); + let symKey = aesGenerator.convertKeySync(symKeyBlob); + console.info('[Sync]convertKey success'); + return symKey; +} + +function doHmacBySync() { + // 把字符串按utf-8解码为Uint8Array,使用固定的128位的密钥,即16字节 + let keyData = new Uint8Array(buffer.from('12345678abcdefgh', 'utf-8').buffer); + let key = genSymKeyByData(keyData); + let macAlgName = 'SHA256'; // 摘要算法名 + let message = 'hmacTestMessgae'; // 待进行HMAC的数据 + let mac = cryptoFramework.createMac(macAlgName); + mac.initSync(key); + // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 + mac.updateSync({ data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }); + let macResult = mac.doFinalSync(); + console.info('[Sync]HMAC result:' + macResult.data); + let macLen = mac.getMacLength(); + console.info('HMAC len:' + macLen); +} + +// [End message_authentication_code_calculation_sync_one_time_incoming] + +@Entry +@Component +struct Index { + @State message: string = 'Segmentation Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_segmentation_sync')) + .width('70%') + .onClick(() => { + try { + doHmacBySync(); + this.message = 'Segmentation Sync Success'; + } catch { + this.message = 'Segmentation Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Async.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Async.ets old mode 100755 new mode 100644 index b3f63e6512..86e933b7a0 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Async.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Async.ets @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start message_authentication_code_calculated_as_fragmented_hmac_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -async function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); - let symKey = await aesGenerator.convertKey(symKeyBlob); - console.info('convertKey success'); - return symKey; -} - -async function doLoopHmac() { - // 把字符串按utf-8解码为Uint8Array,使用固定的128位的密钥,即16字节 - let keyData = new Uint8Array(buffer.from('12345678abcdefgh', 'utf-8').buffer); - let key = await genSymKeyByData(keyData); - let macAlgName = 'SHA256'; // 摘要算法名 - let mac = cryptoFramework.createMac(macAlgName); - // 假设信息总共43字节,根据utf-8解码后,也是43字节 - let messageText = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; - let messageData = new Uint8Array(buffer.from(messageText, 'utf-8').buffer); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - await mac.init(key); - for (let i = 0; i < messageData.length; i += updateLength) { - let updateMessage = messageData.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - await mac.update(updateMessageBlob); - } - let macOutput = await mac.doFinal(); - console.info('HMAC result: ' + macOutput.data); - let macLen = mac.getMacLength(); - console.info('HMAC len:' + macLen); -} - - -// [End message_authentication_code_calculated_as_fragmented_hmac_async] -@Entry -@Component -struct Index { - @State message: string = 'SingleTime Async'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_single_time_async')) - .width('70%') - .onClick(async () => { - try { - await doLoopHmac(); - this.message = 'SingleTime Async Success'; - } catch { - this.message = 'SingleTime Async Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start message_authentication_code_calculated_as_fragmented_hmac_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +async function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); + let symKey = await aesGenerator.convertKey(symKeyBlob); + console.info('convertKey success'); + return symKey; +} + +async function doLoopHmac() { + // 把字符串按utf-8解码为Uint8Array,使用固定的128位的密钥,即16字节 + let keyData = new Uint8Array(buffer.from('12345678abcdefgh', 'utf-8').buffer); + let key = await genSymKeyByData(keyData); + let macAlgName = 'SHA256'; // 摘要算法名 + let mac = cryptoFramework.createMac(macAlgName); + // 假设信息总共43字节,根据utf-8解码后,也是43字节 + let messageText = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; + let messageData = new Uint8Array(buffer.from(messageText, 'utf-8').buffer); + let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 + await mac.init(key); + for (let i = 0; i < messageData.length; i += updateLength) { + let updateMessage = messageData.subarray(i, i + updateLength); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + await mac.update(updateMessageBlob); + } + let macOutput = await mac.doFinal(); + console.info('HMAC result: ' + macOutput.data); + let macLen = mac.getMacLength(); + console.info('HMAC len:' + macLen); +} + + +// [End message_authentication_code_calculated_as_fragmented_hmac_async] +@Entry +@Component +struct Index { + @State message: string = 'SingleTime Async'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_single_time_async')) + .width('70%') + .onClick(async () => { + try { + await doLoopHmac(); + this.message = 'SingleTime Async Success'; + } catch { + this.message = 'SingleTime Async Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Sync.ets old mode 100755 new mode 100644 index 45fe02cfc8..caa9d1ba84 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Sync.ets @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start message_authentication_code_calculated_as_fragmented_hmac_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function genSymKeyByData(symKeyData: Uint8Array) { - let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; - let aesGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); - let symKey = aesGenerator.convertKeySync(symKeyBlob); - console.info('[Sync]convertKey success'); - return symKey; -} - -function doLoopHmacBySync() { - // 把字符串按utf-8解码为Uint8Array,使用固定的128位的密钥,即16字节 - let keyData = new Uint8Array(buffer.from('12345678abcdefgh', 'utf-8').buffer); - let key = genSymKeyByData(keyData); - let macAlgName = 'SHA256'; // 摘要算法名 - let mac = cryptoFramework.createMac(macAlgName); - // 假设信息总共43字节,根据utf-8解码后,也是43字节 - let messageText = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; - let messageData = new Uint8Array(buffer.from(messageText, 'utf-8').buffer); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - mac.initSync(key); - for (let i = 0; i < messageData.length; i += updateLength) { - let updateMessage = messageData.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - mac.updateSync(updateMessageBlob); - } - let macOutput = mac.doFinalSync(); - console.info('[Sync]HMAC result: ' + macOutput.data); - let macLen = mac.getMacLength(); - console.info('HMAC len:' + macLen); -} - - -// [End message_authentication_code_calculated_as_fragmented_hmac_sync] -@Entry -@Component -struct Index { - @State message: string = 'SingleTime Sync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_single_time_sync')) - .width('70%') - .onClick(() => { - try { - doLoopHmacBySync(); - this.message = 'SingleTime Sync Success'; - } catch { - this.message = 'SingleTime Sync Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start message_authentication_code_calculated_as_fragmented_hmac_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function genSymKeyByData(symKeyData: Uint8Array) { + let symKeyBlob: cryptoFramework.DataBlob = { data: symKeyData }; + let aesGenerator = cryptoFramework.createSymKeyGenerator('HMAC'); + let symKey = aesGenerator.convertKeySync(symKeyBlob); + console.info('[Sync]convertKey success'); + return symKey; +} + +function doLoopHmacBySync() { + // 把字符串按utf-8解码为Uint8Array,使用固定的128位的密钥,即16字节 + let keyData = new Uint8Array(buffer.from('12345678abcdefgh', 'utf-8').buffer); + let key = genSymKeyByData(keyData); + let macAlgName = 'SHA256'; // 摘要算法名 + let mac = cryptoFramework.createMac(macAlgName); + // 假设信息总共43字节,根据utf-8解码后,也是43字节 + let messageText = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; + let messageData = new Uint8Array(buffer.from(messageText, 'utf-8').buffer); + let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 + mac.initSync(key); + for (let i = 0; i < messageData.length; i += updateLength) { + let updateMessage = messageData.subarray(i, i + updateLength); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + mac.updateSync(updateMessageBlob); + } + let macOutput = mac.doFinalSync(); + console.info('[Sync]HMAC result: ' + macOutput.data); + let macLen = mac.getMacLength(); + console.info('HMAC len:' + macLen); +} + + +// [End message_authentication_code_calculated_as_fragmented_hmac_sync] +@Entry +@Component +struct Index { + @State message: string = 'SingleTime Sync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_single_time_sync')) + .width('70%') + .onClick(() => { + try { + doLoopHmacBySync(); + this.message = 'SingleTime Sync Success'; + } catch { + this.message = 'SingleTime Sync Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/MessageAuthenticationCode.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/MessageAuthenticationCode.test.ets old mode 100755 new mode 100644 index c9a5c1341e..1c094db7b4 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/MessageAuthenticationCode.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/ets/test/MessageAuthenticationCode.test.ets @@ -1,116 +1,116 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function messageAuthenticationCodeTest() { - describe('messageAuthenticationCodeTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,消息认证码计算(HMAC await方式) - */ - it('testMessageAuthenticationCode001', 0, async () => { - console.info('uitest: testMessageAuthenticationCode001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Segmentation Async')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Segmentation Async')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Segmentation Async Success')); - console.info('uitest: testMessageAuthenticationCode001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,消息认证码计算(HMAC 同步方式) - */ - it('testMessageAuthenticationCode002', 0, async () => { - console.info('uitest: testMessageAuthenticationCode002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Segmentation Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call Segmentation Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Segmentation Sync Success')); - console.info('uitest: testMessageAuthenticationCode002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,消息认证码计算(分段HMAC await方式) - */ - it('testMessageAuthenticationCode003', 0, async () => { - console.info('uitest: testMessageAuthenticationCode003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SingleTime Async')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SingleTime Async')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SingleTime Async Success')); - console.info('uitest: testMessageAuthenticationCode003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,消息认证码计算(分段HMAC 同步方式) - */ - it('testMessageAuthenticationCode004', 0, async () => { - console.info('uitest: testMessageAuthenticationCode004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SingleTime Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SingleTime Sync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SingleTime Sync Success')); - console.info('uitest: testMessageAuthenticationCode004 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function messageAuthenticationCodeTest() { + describe('messageAuthenticationCodeTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,消息认证码计算(HMAC await方式) + */ + it('testMessageAuthenticationCode001', 0, async () => { + console.info('uitest: testMessageAuthenticationCode001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Segmentation Async')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Segmentation Async')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Segmentation Async Success')); + console.info('uitest: testMessageAuthenticationCode001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,消息认证码计算(HMAC 同步方式) + */ + it('testMessageAuthenticationCode002', 0, async () => { + console.info('uitest: testMessageAuthenticationCode002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Segmentation Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call Segmentation Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Segmentation Sync Success')); + console.info('uitest: testMessageAuthenticationCode002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,消息认证码计算(分段HMAC await方式) + */ + it('testMessageAuthenticationCode003', 0, async () => { + console.info('uitest: testMessageAuthenticationCode003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SingleTime Async')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SingleTime Async')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SingleTime Async Success')); + console.info('uitest: testMessageAuthenticationCode003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,消息认证码计算(分段HMAC 同步方式) + */ + it('testMessageAuthenticationCode004', 0, async () => { + console.info('uitest: testMessageAuthenticationCode004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SingleTime Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SingleTime Sync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SingleTime Sync Success')); + console.info('uitest: testMessageAuthenticationCode004 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/MessageAuthenticationCode/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/ohosTest.md old mode 100755 new mode 100644 index 77ebece084..997924c683 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/ohosTest.md @@ -1,11 +1,11 @@ -# 消息认证码计算测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,消息认证码计算(HMAC await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,消息认证码计算(HMAC 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,消息认证码计算(分段HMAC await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 消息认证码计算测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,消息认证码计算(HMAC await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,消息认证码计算(HMAC 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,消息认证码计算(分段HMAC await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,消息认证码计算(分段HMAC 同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/screenshots/MessageAuthenticationCode1.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/screenshots/MessageAuthenticationCode1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/screenshots/MessageAuthenticationCode2.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/screenshots/MessageAuthenticationCode2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/app.json5 old mode 100755 new mode 100644 index 9910d9b555..67ca916409 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/app.json5 @@ -1,25 +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.messagedigestcomputation", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.messagedigestcomputation", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index a91c6054ec..8b289a1ace --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MessageDigestComputation" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "MessageDigestComputation" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/README.md b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/README.md old mode 100755 new mode 100644 index bcf20708c1..cdcfecf7b3 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/README.md @@ -1,85 +1,85 @@ -# 消息摘要计算 - -### 介绍 - -本示例主要展示了消息摘要计算(ArkTS)、消息摘要计算(C/C++)场景 。该工程中展示的代码详细描述可查如下链接。 - -- [消息摘要计算(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-message-digest.md) -- [消息摘要计算(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-message-digest-ndk.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例MessageDigestComputation.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── segmentation.cpp - │ │ | ├── singleTime.cpp - │ │ | ├── file.h - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 消息摘要计算示例代码 - │ │ ├── segmentation - │ │ | ├── SegmentationAsync.ets - │ │ | ├── SegmentationSync.ets - │ │ ├── singleTime - │ │ | ├── SingleTimeAsync.ets - │ │ | ├── SingleTimeSync.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── MessageDigestComputation.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 消息摘要计算 + +### 介绍 + +本示例主要展示了消息摘要计算(ArkTS)、消息摘要计算(C/C++)场景 。该工程中展示的代码详细描述可查如下链接。 + +- [消息摘要计算(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-message-digest.md) +- [消息摘要计算(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-message-digest-ndk.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例MessageDigestComputation.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── segmentation.cpp + │ │ | ├── singleTime.cpp + │ │ | ├── file.h + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 消息摘要计算示例代码 + │ │ ├── segmentation + │ │ | ├── SegmentationAsync.ets + │ │ | ├── SegmentationSync.ets + │ │ ├── singleTime + │ │ | ├── SingleTimeAsync.ets + │ │ | ├── SingleTimeSync.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── MessageDigestComputation.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation > .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/Security/CryptoArchitectureKit/MessageDigestComputation/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/MessageDigestComputation/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 2dfee85b6d..e9e4d0405d --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(MessageDigestComputation) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp types/project/segmentation.cpp types/project/singleTime.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(MessageDigestComputation) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp types/project/segmentation.cpp types/project/singleTime.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 6c43b7ba23..87ee66888a --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/napi_init.cpp @@ -1,52 +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. - */ - -#include "napi/native_api.h" -#include "types/project/file.h" - -static napi_value NAPI_Global_doTestMd(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doTestMd(), &ret); - return ret; -} -static napi_value NAPI_Global_doLoopMd(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, doLoopMd(), &ret); - return ret; -} -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"doTestMd", nullptr, NAPI_Global_doTestMd, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"doLoopMd", nullptr, NAPI_Global_doLoopMd, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/file.h" + +static napi_value NAPI_Global_doTestMd(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doTestMd(), &ret); + return ret; +} +static napi_value NAPI_Global_doLoopMd(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, doLoopMd(), &ret); + return ret; +} +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"doTestMd", nullptr, NAPI_Global_doTestMd, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"doLoopMd", nullptr, NAPI_Global_doLoopMd, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index 9e477cb765..8d3539298b --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,18 +1,18 @@ -/* - * 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 doTestMd: () => number; - +/* + * 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 doTestMd: () => number; + export const doLoopMd: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/file.h b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/file.h old mode 100755 new mode 100644 index 9efce03ab0..4e6a15a13e --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/file.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/file.h @@ -1,23 +1,23 @@ -#ifndef FILE_H -#define FILE_H -/* - * 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 "CryptoArchitectureKit/crypto_common.h" - -OH_Crypto_ErrCode doTestMd(); -OH_Crypto_ErrCode doLoopMd(); - +#ifndef FILE_H +#define FILE_H +/* + * 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 "CryptoArchitectureKit/crypto_common.h" + +OH_Crypto_ErrCode doTestMd(); +OH_Crypto_ErrCode doLoopMd(); + #endif // FILE_H \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/segmentation.cpp b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/segmentation.cpp old mode 100755 new mode 100644 index fe193cfc52..3900c7b7ba --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/segmentation.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/segmentation.cpp @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start message_digest_calculation_segmented_digest_algorithm] - -#include -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_digest.h" -#include "file.h" -#define OH_CRYPTO_DIGEST_DATA_MAX (1024 * 1024 * 100) - -static constexpr int INT_640 = 640; - -OH_Crypto_ErrCode doLoopMd() -{ - OH_Crypto_ErrCode ret; - OH_CryptoDigest *ctx = nullptr; - uint8_t *testData = (uint8_t *)malloc(OH_CRYPTO_DIGEST_DATA_MAX); - if (testData == nullptr) { - return CRYPTO_MEMORY_ERROR; - } - Crypto_DataBlob out = {.data = nullptr, .len = 0}; - int mdLen = 0; - int isBlockSize = 20; - int offset = 0; - - ret = OH_CryptoDigest_Create("SHA256", &ctx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - do { - for (int i = 0; i < INT_640 / isBlockSize; i++) { - Crypto_DataBlob in = {.data = reinterpret_cast(testData + offset), - .len = static_cast(isBlockSize)}; - ret = OH_CryptoDigest_Update(ctx, &in); - if (ret != CRYPTO_SUCCESS) { - break; - } - offset += isBlockSize; - } - ret = OH_CryptoDigest_Final(ctx, &out); - if (ret != CRYPTO_SUCCESS) { - break; - } - mdLen = OH_CryptoDigest_GetLength(ctx); - } while (0); - OH_Crypto_FreeDataBlob(&out); - OH_DigestCrypto_Destroy(ctx); - return ret; -} - +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start message_digest_calculation_segmented_digest_algorithm] + +#include +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_digest.h" +#include "file.h" +#define OH_CRYPTO_DIGEST_DATA_MAX (1024 * 1024 * 100) + +static constexpr int INT_640 = 640; + +OH_Crypto_ErrCode doLoopMd() +{ + OH_Crypto_ErrCode ret; + OH_CryptoDigest *ctx = nullptr; + uint8_t *testData = (uint8_t *)malloc(OH_CRYPTO_DIGEST_DATA_MAX); + if (testData == nullptr) { + return CRYPTO_MEMORY_ERROR; + } + Crypto_DataBlob out = {.data = nullptr, .len = 0}; + int mdLen = 0; + int isBlockSize = 20; + int offset = 0; + + ret = OH_CryptoDigest_Create("SHA256", &ctx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + do { + for (int i = 0; i < INT_640 / isBlockSize; i++) { + Crypto_DataBlob in = {.data = reinterpret_cast(testData + offset), + .len = static_cast(isBlockSize)}; + ret = OH_CryptoDigest_Update(ctx, &in); + if (ret != CRYPTO_SUCCESS) { + break; + } + offset += isBlockSize; + } + ret = OH_CryptoDigest_Final(ctx, &out); + if (ret != CRYPTO_SUCCESS) { + break; + } + mdLen = OH_CryptoDigest_GetLength(ctx); + } while (0); + OH_Crypto_FreeDataBlob(&out); + OH_DigestCrypto_Destroy(ctx); + return ret; +} + // [End message_digest_calculation_segmented_digest_algorithm] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/singleTime.cpp b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/singleTime.cpp old mode 100755 new mode 100644 index eafdeeb714..f3776b2b61 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/singleTime.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/singleTime.cpp @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start message_digest_calculation_digest_algorithm_one_time_incoming] - -#include "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_digest.h" -#include -#include "file.h" - -OH_Crypto_ErrCode doTestMd() -{ - OH_Crypto_ErrCode ret; - OH_CryptoDigest *ctx = nullptr; - char *testData = const_cast("0123456789"); - Crypto_DataBlob in = {.data = (uint8_t *)(testData), .len = strlen(testData)}; - Crypto_DataBlob out = {.data = nullptr, .len = 0}; - int mdLen = 0; - ret = OH_CryptoDigest_Create("SHA256", &ctx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - do { - ret = OH_CryptoDigest_Update(ctx, &in); - if (ret != CRYPTO_SUCCESS) { - break; - } - ret = OH_CryptoDigest_Final(ctx, &out); - if (ret != CRYPTO_SUCCESS) { - break; - } - mdLen = OH_CryptoDigest_GetLength(ctx); - } while (0); - OH_Crypto_FreeDataBlob(&out); - OH_DigestCrypto_Destroy(ctx); - return ret; -} - +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start message_digest_calculation_digest_algorithm_one_time_incoming] + +#include "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_digest.h" +#include +#include "file.h" + +OH_Crypto_ErrCode doTestMd() +{ + OH_Crypto_ErrCode ret; + OH_CryptoDigest *ctx = nullptr; + char *testData = const_cast("0123456789"); + Crypto_DataBlob in = {.data = (uint8_t *)(testData), .len = strlen(testData)}; + Crypto_DataBlob out = {.data = nullptr, .len = 0}; + int mdLen = 0; + ret = OH_CryptoDigest_Create("SHA256", &ctx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + do { + ret = OH_CryptoDigest_Update(ctx, &in); + if (ret != CRYPTO_SUCCESS) { + break; + } + ret = OH_CryptoDigest_Final(ctx, &out); + if (ret != CRYPTO_SUCCESS) { + break; + } + mdLen = OH_CryptoDigest_GetLength(ctx); + } while (0); + OH_Crypto_FreeDataBlob(&out); + OH_DigestCrypto_Destroy(ctx); + return ret; +} + // [End message_digest_calculation_digest_algorithm_one_time_incoming] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationAsync.ets old mode 100755 new mode 100644 index a4efb4f678..9dce1b36b1 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationAsync.ets @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start message_digest_calculation_segmented_digest_algorithm_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -async function doLoopMd() { - let mdAlgName = 'SHA256'; // 摘要算法名 - let md = cryptoFramework.createMd(mdAlgName); - // 假设信息总共43字节,根据utf-8解码后,也是43字节 - let messageText = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; - let messageData = new Uint8Array(buffer.from(messageText, 'utf-8').buffer); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - for (let i = 0; i < messageData.length; i += updateLength) { - let updateMessage = messageData.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - await md.update(updateMessageBlob); - } - let mdOutput = await md.digest(); - console.info('md result: ' + mdOutput.data); - let mdLen = md.getMdLength(); - console.info('md len: ' + mdLen); -} - -// [End message_digest_calculation_segmented_digest_algorithm_async] -@Entry -@Component -struct Index { - @State message: string = 'SegmentationAsync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_segmentation_async')) - .width('70%') - .onClick(async () => { - try { - await doLoopMd(); - this.message = 'SegmentationAsyncSuccess'; - } catch { - this.message = 'SegmentationAsyncFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start message_digest_calculation_segmented_digest_algorithm_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +async function doLoopMd() { + let mdAlgName = 'SHA256'; // 摘要算法名 + let md = cryptoFramework.createMd(mdAlgName); + // 假设信息总共43字节,根据utf-8解码后,也是43字节 + let messageText = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; + let messageData = new Uint8Array(buffer.from(messageText, 'utf-8').buffer); + let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 + for (let i = 0; i < messageData.length; i += updateLength) { + let updateMessage = messageData.subarray(i, i + updateLength); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + await md.update(updateMessageBlob); + } + let mdOutput = await md.digest(); + console.info('md result: ' + mdOutput.data); + let mdLen = md.getMdLength(); + console.info('md len: ' + mdLen); +} + +// [End message_digest_calculation_segmented_digest_algorithm_async] +@Entry +@Component +struct Index { + @State message: string = 'SegmentationAsync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_segmentation_async')) + .width('70%') + .onClick(async () => { + try { + await doLoopMd(); + this.message = 'SegmentationAsyncSuccess'; + } catch { + this.message = 'SegmentationAsyncFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationSync.ets old mode 100755 new mode 100644 index 5e9b58c592..ccac0bd6d8 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationSync.ets @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start message_digest_calculation_segmented_digest_algorithm_sync] - -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function doLoopMdBySync() { - let mdAlgName = 'SHA256'; // 摘要算法名 - let md = cryptoFramework.createMd(mdAlgName); - // 假设信息总共43字节,根据utf-8解码后,也是43字节 - let messageText = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; - let messageData = new Uint8Array(buffer.from(messageText, 'utf-8').buffer); - let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 - for (let i = 0; i < messageData.length; i += updateLength) { - let updateMessage = messageData.subarray(i, i + updateLength); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - md.updateSync(updateMessageBlob); - } - let mdOutput = md.digestSync(); - console.info('[Sync]:md result: ' + mdOutput.data); - let mdLen = md.getMdLength(); - console.info('md len: ' + mdLen); -} -// [End message_digest_calculation_segmented_digest_algorithm_sync] -@Entry -@Component -struct Index { - @State message: string = 'SegmentationSync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_segmentation_sync')) - .width('70%') - .onClick(() => { - try { - doLoopMdBySync(); - this.message = 'SegmentationSyncSuccess'; - } catch { - this.message = 'SegmentationSyncFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start message_digest_calculation_segmented_digest_algorithm_sync] + +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function doLoopMdBySync() { + let mdAlgName = 'SHA256'; // 摘要算法名 + let md = cryptoFramework.createMd(mdAlgName); + // 假设信息总共43字节,根据utf-8解码后,也是43字节 + let messageText = 'aaaaa.....bbbbb.....ccccc.....ddddd.....eee'; + let messageData = new Uint8Array(buffer.from(messageText, 'utf-8').buffer); + let updateLength = 20; // 假设以20字节为单位进行分段update,实际并无要求 + for (let i = 0; i < messageData.length; i += updateLength) { + let updateMessage = messageData.subarray(i, i + updateLength); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + md.updateSync(updateMessageBlob); + } + let mdOutput = md.digestSync(); + console.info('[Sync]:md result: ' + mdOutput.data); + let mdLen = md.getMdLength(); + console.info('md len: ' + mdLen); +} +// [End message_digest_calculation_segmented_digest_algorithm_sync] +@Entry +@Component +struct Index { + @State message: string = 'SegmentationSync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_segmentation_sync')) + .width('70%') + .onClick(() => { + try { + doLoopMdBySync(); + this.message = 'SegmentationSyncSuccess'; + } catch { + this.message = 'SegmentationSyncFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeAsync.ets old mode 100755 new mode 100644 index c39fc8f1e3..b1d60c8f84 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeAsync.ets @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start message_digest_calculation_digest_algorithm_one_time_incoming_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -async function doMd() { - let mdAlgName = 'SHA256'; // 摘要算法名 - let message = 'mdTestMessgae'; // 待摘要的数据 - let md = cryptoFramework.createMd(mdAlgName); - // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 - await md.update({ data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }); - let mdResult = await md.digest(); - console.info('Md result:' + mdResult.data); - let mdLen = md.getMdLength(); - console.info('md len: ' + mdLen); -} - -// [End message_digest_calculation_digest_algorithm_one_time_incoming_async] - -@Entry -@Component -struct Index { - @State message: string = 'SingleTimeAsync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button($r('app.string.call_single_time_async')) - .width('70%') - .onClick(async () => { - try { - await doMd(); - this.message = 'SingleTimeAsyncSuccess'; - } catch { - this.message = 'SingleTimeAsyncFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start message_digest_calculation_digest_algorithm_one_time_incoming_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +async function doMd() { + let mdAlgName = 'SHA256'; // 摘要算法名 + let message = 'mdTestMessgae'; // 待摘要的数据 + let md = cryptoFramework.createMd(mdAlgName); + // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 + await md.update({ data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }); + let mdResult = await md.digest(); + console.info('Md result:' + mdResult.data); + let mdLen = md.getMdLength(); + console.info('md len: ' + mdLen); +} + +// [End message_digest_calculation_digest_algorithm_one_time_incoming_async] + +@Entry +@Component +struct Index { + @State message: string = 'SingleTimeAsync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button($r('app.string.call_single_time_async')) + .width('70%') + .onClick(async () => { + try { + await doMd(); + this.message = 'SingleTimeAsyncSuccess'; + } catch { + this.message = 'SingleTimeAsyncFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeSync.ets old mode 100755 new mode 100644 index 1f60f9e33a..8fe219d110 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeSync.ets @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start message_digest_calculation_digest_algorithm_one_time_incoming_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function doMdBySync() { - let mdAlgName = 'SHA256'; // 摘要算法名 - let message = 'mdTestMessgae'; // 待摘要的数据 - let md = cryptoFramework.createMd(mdAlgName); - // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 - md.updateSync({ data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }); - let mdResult = md.digestSync(); - console.info('[Sync]:Md result:' + mdResult.data); - let mdLen = md.getMdLength(); - console.info('md len: ' + mdLen); -} -// [End message_digest_calculation_digest_algorithm_one_time_incoming_sync] -@Entry -@Component -struct Index { - @State message: string = 'SingleTimeSync'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) - Button('Call SingleTimeSync') - .width('70%') - .onClick(() => { - try { - doMdBySync(); - this.message = 'SingleTimeSyncSuccess'; - } catch { - this.message = 'SingleTimeSyncFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start message_digest_calculation_digest_algorithm_one_time_incoming_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function doMdBySync() { + let mdAlgName = 'SHA256'; // 摘要算法名 + let message = 'mdTestMessgae'; // 待摘要的数据 + let md = cryptoFramework.createMd(mdAlgName); + // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 + md.updateSync({ data: new Uint8Array(buffer.from(message, 'utf-8').buffer) }); + let mdResult = md.digestSync(); + console.info('[Sync]:Md result:' + mdResult.data); + let mdLen = md.getMdLength(); + console.info('md len: ' + mdLen); +} +// [End message_digest_calculation_digest_algorithm_one_time_incoming_sync] +@Entry +@Component +struct Index { + @State message: string = 'SingleTimeSync'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20).fontWeight(FontWeight.Bold) + Button('Call SingleTimeSync') + .width('70%') + .onClick(() => { + try { + doMdBySync(); + this.message = 'SingleTimeSyncSuccess'; + } catch { + this.message = 'SingleTimeSyncFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/MessageDigestComputation.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/MessageDigestComputation.test.ets old mode 100755 new mode 100644 index 14bdf7f840..77a030e99c --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/MessageDigestComputation.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/ets/test/MessageDigestComputation.test.ets @@ -1,144 +1,144 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function messageDigestComputationTest() { - describe('messageDigestComputationTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,消息摘要计算(ArkTS 摘要算法await方式) - */ - it('testMessageDigestComputation001', 0, async () => { - console.info('uitest: testMessageDigestComputation001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SegmentationAsync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SegmentationAsync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SegmentationAsyncSuccess')); - console.info('uitest: testMessageDigestComputation001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,消息摘要计算(ArkTS 摘要算法同步方式) - */ - it('testMessageDigestComputation002', 0, async () => { - console.info('uitest: testMessageDigestComputation002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SegmentationSync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SegmentationSync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SegmentationSyncSuccess')); - console.info('uitest: testMessageDigestComputation002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,消息摘要计算(ArkTS 分段摘要算法await方式) - */ - it('testMessageDigestComputation003', 0, async () => { - console.info('uitest: testMessageDigestComputation003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SingleTimeAsync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SingleTimeAsync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SingleTimeAsyncSuccess')); - console.info('uitest: testMessageDigestComputation003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,消息摘要计算(ArkTS 分段摘要算法同步方式) - */ - it('testMessageDigestComputation004', 0, async () => { - console.info('uitest: testMessageDigestComputation004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SingleTimeSync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SingleTimeSync')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SingleTimeSyncSuccess')); - console.info('uitest: testMessageDigestComputation004 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,消息摘要计算(C/C++ 摘要算法) - */ - it('testMessageDigestComputation005', 0, async () => { - console.info('uitest: testMessageDigestComputation005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SingleTime C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SingleTime C++ Success Result:0')); - console.info('uitest: testMessageDigestComputation005 end'); - }) - - /** - * 点击按钮,消息摘要计算(C/C++ 分段摘要算法) - */ - it('testMessageDigestComputation006', 0, async () => { - console.info('uitest: testMessageDigestComputation006 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Segmentation C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Segmentation C++ Success Result:0')); - console.info('uitest: testMessageDigestComputation006 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function messageDigestComputationTest() { + describe('messageDigestComputationTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,消息摘要计算(ArkTS 摘要算法await方式) + */ + it('testMessageDigestComputation001', 0, async () => { + console.info('uitest: testMessageDigestComputation001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SegmentationAsync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SegmentationAsync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SegmentationAsyncSuccess')); + console.info('uitest: testMessageDigestComputation001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,消息摘要计算(ArkTS 摘要算法同步方式) + */ + it('testMessageDigestComputation002', 0, async () => { + console.info('uitest: testMessageDigestComputation002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SegmentationSync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SegmentationSync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SegmentationSyncSuccess')); + console.info('uitest: testMessageDigestComputation002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,消息摘要计算(ArkTS 分段摘要算法await方式) + */ + it('testMessageDigestComputation003', 0, async () => { + console.info('uitest: testMessageDigestComputation003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SingleTimeAsync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SingleTimeAsync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SingleTimeAsyncSuccess')); + console.info('uitest: testMessageDigestComputation003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,消息摘要计算(ArkTS 分段摘要算法同步方式) + */ + it('testMessageDigestComputation004', 0, async () => { + console.info('uitest: testMessageDigestComputation004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SingleTimeSync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SingleTimeSync')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SingleTimeSyncSuccess')); + console.info('uitest: testMessageDigestComputation004 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,消息摘要计算(C/C++ 摘要算法) + */ + it('testMessageDigestComputation005', 0, async () => { + console.info('uitest: testMessageDigestComputation005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SingleTime C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SingleTime C++ Success Result:0')); + console.info('uitest: testMessageDigestComputation005 end'); + }) + + /** + * 点击按钮,消息摘要计算(C/C++ 分段摘要算法) + */ + it('testMessageDigestComputation006', 0, async () => { + console.info('uitest: testMessageDigestComputation006 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Segmentation C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Segmentation C++ Success Result:0')); + console.info('uitest: testMessageDigestComputation006 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/MessageDigestComputation/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/ohosTest.md old mode 100755 new mode 100644 index ccbd450e69..53df17f13a --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/ohosTest.md @@ -1,13 +1,13 @@ -# 消息摘要计算测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,消息摘要计算(ArkTS 摘要算法await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,消息摘要计算(ArkTS 摘要算法同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,消息摘要计算(ArkTS 分段摘要算法await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,消息摘要计算(ArkTS 分段摘要算法同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,消息摘要计算(C/C++ 摘要算法) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 消息摘要计算测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,消息摘要计算(ArkTS 摘要算法await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,消息摘要计算(ArkTS 摘要算法同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,消息摘要计算(ArkTS 分段摘要算法await方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,消息摘要计算(ArkTS 分段摘要算法同步方式) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,消息摘要计算(C/C++ 摘要算法) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,消息摘要计算(C/C++ 分段摘要算法) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/screenshots/MessageDigestComputation1.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/screenshots/MessageDigestComputation1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/screenshots/MessageDigestComputation2.png b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/screenshots/MessageDigestComputation2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/app.json5 old mode 100755 new mode 100644 index 85c53f0885..5501621fff --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/app.json5 @@ -1,25 +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.securerandomnumbergeneration", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.securerandomnumbergeneration", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 8b07fd87d5..3487457a46 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SecureRandomNumberGeneration" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SecureRandomNumberGeneration" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/README.md b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/README.md old mode 100755 new mode 100644 index 0f0d3f0930..f5027645fa --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/README.md @@ -1,69 +1,69 @@ -# 安全随机数生成 - -### 介绍 - -随机数主要用于临时会话密钥生成和非对称加密算法密钥生成等场景。在加解密场景中,安全随机数生成器需要具备随机性,不可预测性,与不可重现性。当前系统生成的随机数满足密码学安全伪随机性要求 - -本示例主要展示了安全随机数生成(await、同步)场景 。该工程中展示的代码详细描述可查如下链接。 - -- [安全随机数生成](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-random-number.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例SecureRandomNumberGeneration.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 安全随机数生成示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── SecureRandomNumberGeneration.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 安全随机数生成 + +### 介绍 + +随机数主要用于临时会话密钥生成和非对称加密算法密钥生成等场景。在加解密场景中,安全随机数生成器需要具备随机性,不可预测性,与不可重现性。当前系统生成的随机数满足密码学安全伪随机性要求 + +本示例主要展示了安全随机数生成(await、同步)场景 。该工程中展示的代码详细描述可查如下链接。 + +- [安全随机数生成](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-generate-random-number.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例SecureRandomNumberGeneration.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 安全随机数生成示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── SecureRandomNumberGeneration.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration > .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/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/SecureRandomNumberGeneration.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/SecureRandomNumberGeneration.test.ets old mode 100755 new mode 100644 index a7521c6d1f..cc40b528c8 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/SecureRandomNumberGeneration.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/ets/test/SecureRandomNumberGeneration.test.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function secureRandomNumberGenerationTest() { - describe('secureRandomNumberGenerationTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,安全随机数生成,使用await返回结果 - */ - it('testSecureRandomNumberGeneration001', 0, async () => { - console.info('uitest: testSecureRandomNumberGeneration001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call Async')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AsyncSuccess')); - console.info('uitest: testSecureRandomNumberGeneration001 end'); - }) - - /** - * 点击按钮,安全随机数生成,同步返回结果 - */ - it('testSecureRandomNumberGeneration002', 0, async () => { - console.info('uitest: testSecureRandomNumberGeneration002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call Sync')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SyncSuccess')); - console.info('uitest: testSecureRandomNumberGeneration002 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function secureRandomNumberGenerationTest() { + describe('secureRandomNumberGenerationTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,安全随机数生成,使用await返回结果 + */ + it('testSecureRandomNumberGeneration001', 0, async () => { + console.info('uitest: testSecureRandomNumberGeneration001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call Async')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AsyncSuccess')); + console.info('uitest: testSecureRandomNumberGeneration001 end'); + }) + + /** + * 点击按钮,安全随机数生成,同步返回结果 + */ + it('testSecureRandomNumberGeneration002', 0, async () => { + console.info('uitest: testSecureRandomNumberGeneration002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call Sync')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SyncSuccess')); + console.info('uitest: testSecureRandomNumberGeneration002 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/ohosTest.md old mode 100755 new mode 100644 index 182fbe1d70..7437e0328f --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/ohosTest.md @@ -1,9 +1,9 @@ -# 安全随机数生成测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,安全随机数生成,使用await返回结果 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 安全随机数生成测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,安全随机数生成,使用await返回结果 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,安全随机数生成,同步返回结果 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/screenshots/SecureRandomNumberGeneration1.png b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/screenshots/SecureRandomNumberGeneration1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/screenshots/SecureRandomNumberGeneration2.png b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/screenshots/SecureRandomNumberGeneration2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/app.json5 old mode 100755 new mode 100644 index ec1418b55f..56d39e636c --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/app.json5 @@ -1,25 +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.signingsignatureverification", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.signingsignatureverification", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 4b213a8f30..7d9ab06441 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SigningSignatureVerification" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SigningSignatureVerification" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/README.md b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/README.md old mode 100755 new mode 100644 index 3afb9e5c17..15c4580072 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/README.md @@ -1,89 +1,89 @@ -# 签名验签(C/C++) - -### 介绍 - -当需要判断接收的数据是否被篡改、数据是否为指定对象发送的数据时,可以使用签名验签操作。接下来将说明系统目前支持的算法及其对应的规格。 - -本示例主要展示了签名验签(C/C++)的多种场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用RSA密钥对(PKCS1模式)验签(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pkcs1-ndk.md) -- [使用RSA密钥对(PKCS1模式)签名恢复(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-recover-pkcs1-ndk.md) -- [使用RSA密钥对分段验签(PKCS1模式)(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pkcs1-by-segment-ndk.md) -- [使用RSA密钥对验签(PSS模式)(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pss-ndk.md) -- [使用ECDSA密钥对验签(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-ecdsa-sign-sig-verify-ndk.md) -- [使用SM2密钥对验签(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm2-sign-sig-verify-pkcs1-ndk.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例SigningSignatureVerification.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── cpp - │ │ ├── types - │ │ | ├── libentry - │ │ | ├── index.d.ts - │ │ | ├── oh-package.json5 - │ │ | ├── project - │ │ | ├── ecdsa_signature_verification.cpp - │ │ | ├── rsa_pkcs1_segment_signature.cpp - │ │ | ├── rsa_pkcs1_signature_restoration.cpp - │ │ | ├── rsa_pkcs1_signature_validator.cpp - │ │ | ├── rsa_pss_verification_tool.cpp - │ │ | ├── signing_signature_verification.h - │ │ | ├── sm2_signature_verification.cpp - │ │ ├── CMakeList.txt - │ │ ├── napi_init.cpp - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 签名验签(C/C++)示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── SigningSignatureVerification.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 签名验签(C/C++) + +### 介绍 + +当需要判断接收的数据是否被篡改、数据是否为指定对象发送的数据时,可以使用签名验签操作。接下来将说明系统目前支持的算法及其对应的规格。 + +本示例主要展示了签名验签(C/C++)的多种场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用RSA密钥对(PKCS1模式)验签(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pkcs1-ndk.md) +- [使用RSA密钥对(PKCS1模式)签名恢复(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-recover-pkcs1-ndk.md) +- [使用RSA密钥对分段验签(PKCS1模式)(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pkcs1-by-segment-ndk.md) +- [使用RSA密钥对验签(PSS模式)(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pss-ndk.md) +- [使用ECDSA密钥对验签(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-ecdsa-sign-sig-verify-ndk.md) +- [使用SM2密钥对验签(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm2-sign-sig-verify-pkcs1-ndk.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例SigningSignatureVerification.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── cpp + │ │ ├── types + │ │ | ├── libentry + │ │ | ├── index.d.ts + │ │ | ├── oh-package.json5 + │ │ | ├── project + │ │ | ├── ecdsa_signature_verification.cpp + │ │ | ├── rsa_pkcs1_segment_signature.cpp + │ │ | ├── rsa_pkcs1_signature_restoration.cpp + │ │ | ├── rsa_pkcs1_signature_validator.cpp + │ │ | ├── rsa_pss_verification_tool.cpp + │ │ | ├── signing_signature_verification.h + │ │ | ├── sm2_signature_verification.cpp + │ │ ├── CMakeList.txt + │ │ ├── napi_init.cpp + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 签名验签(C/C++)示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── SigningSignatureVerification.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification > .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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/build-profile.json5 old mode 100755 new mode 100644 index e736e6631f..d4c9b145c6 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 41f8f6ab75..f3347fe669 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/CMakeLists.txt @@ -1,16 +1,16 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(MyApplication) - -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 - ${NATIVERENDER_ROOT_PATH}/types/project) - -add_library(entry SHARED napi_init.cpp types/project/rsa_pkcs1_segment_signature.cpp types/project/rsa_pkcs1_signature_restoration.cpp types/project/rsa_pkcs1_signature_validator.cpp types/project/rsa_pss_verification_tool.cpp types/project/ecdsa_signature_verification.cpp types/project/sm2_signature_verification.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(MyApplication) + +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 + ${NATIVERENDER_ROOT_PATH}/types/project) + +add_library(entry SHARED napi_init.cpp types/project/rsa_pkcs1_segment_signature.cpp types/project/rsa_pkcs1_signature_restoration.cpp types/project/rsa_pkcs1_signature_validator.cpp types/project/rsa_pss_verification_tool.cpp types/project/ecdsa_signature_verification.cpp types/project/sm2_signature_verification.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libohcrypto.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 5226e5c527..b243c28c08 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/napi_init.cpp @@ -1,88 +1,88 @@ -/* - * 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 "types/project/signing_signature_verification.h" -#include - -static napi_value TestRsaSignatureSeg(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_get_boolean(env, DoTestRsaSignatureSeg(), &ret); - return ret; -} - -static napi_value TestRsaSignature(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_get_boolean(env, DoTestRsaSignature(), &ret); - return ret; -} - -static napi_value TestRsaSignatureRecover(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_create_int32(env, DoTestRsaSignatureRecover(), &ret); - return ret; -} - -static napi_value TestRsaPssSignatureSeg(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_get_boolean(env, DoTestRsaPssSignatureSeg(), &ret); - return ret; -} - -static napi_value TestEcdsaSignature(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_get_boolean(env, DoTestEcdsaSignature(), &ret); - return ret; -} - -static napi_value TestSm2Signature(napi_env env, napi_callback_info info) -{ - napi_value ret; - napi_get_boolean(env, DoTestSm2Signature(), &ret); - return ret; -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"signatureSeg", nullptr, TestRsaSignatureSeg, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"signature", nullptr, TestRsaSignature, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"signatureRecover", nullptr, TestRsaSignatureRecover, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"pssSignatureSeg", nullptr, TestRsaPssSignatureSeg, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"ecdsaSignature", nullptr, TestEcdsaSignature, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"sm2Signature", nullptr, TestSm2Signature, nullptr, nullptr, nullptr, napi_default, nullptr}, - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * 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 "types/project/signing_signature_verification.h" +#include + +static napi_value TestRsaSignatureSeg(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_get_boolean(env, DoTestRsaSignatureSeg(), &ret); + return ret; +} + +static napi_value TestRsaSignature(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_get_boolean(env, DoTestRsaSignature(), &ret); + return ret; +} + +static napi_value TestRsaSignatureRecover(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_create_int32(env, DoTestRsaSignatureRecover(), &ret); + return ret; +} + +static napi_value TestRsaPssSignatureSeg(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_get_boolean(env, DoTestRsaPssSignatureSeg(), &ret); + return ret; +} + +static napi_value TestEcdsaSignature(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_get_boolean(env, DoTestEcdsaSignature(), &ret); + return ret; +} + +static napi_value TestSm2Signature(napi_env env, napi_callback_info info) +{ + napi_value ret; + napi_get_boolean(env, DoTestSm2Signature(), &ret); + return ret; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"signatureSeg", nullptr, TestRsaSignatureSeg, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"signature", nullptr, TestRsaSignature, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"signatureRecover", nullptr, TestRsaSignatureRecover, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"pssSignatureSeg", nullptr, TestRsaPssSignatureSeg, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"ecdsaSignature", nullptr, TestEcdsaSignature, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"sm2Signature", nullptr, TestSm2Signature, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index b2764719ca..c14cf00cf4 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,26 +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. - */ - -export const signatureSeg: () => number; - -export const signature: () => number; - -export const signatureRecover: () => number; - -export const pssSignatureSeg: () => number; - -export const ecdsaSignature: () => number; - +/* + * 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 signatureSeg: () => number; + +export const signature: () => number; + +export const signatureRecover: () => number; + +export const pssSignatureSeg: () => number; + +export const ecdsaSignature: () => number; + export const sm2Signature: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/ecdsa_signature_verification.cpp b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/ecdsa_signature_verification.cpp old mode 100755 new mode 100644 index d0ae1503c7..aff24c6835 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/ecdsa_signature_verification.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/ecdsa_signature_verification.cpp @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start verify_signatures_with_ecdsa_keys_c] -#include "signing_signature_verification.h" - -bool DoTestEcdsaSignature() -{ - OH_CryptoAsymKeyGenerator *keyCtx = nullptr; - OH_CryptoKeyPair *keyPair = nullptr; - OH_CryptoVerify *verify = nullptr; - - uint8_t plainText[] = {0xe4, 0x2b, 0xcc, 0x08, 0x11, 0x79, 0x16, 0x1b, - 0x35, 0x7f, 0xb3, 0xaf, 0x40, 0x3b, 0x3f, 0x7c}; - Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; - - uint8_t pubKeyText[] = {0x30, 0x39, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, - 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x22, 0x00, 0x03, 0x4d, 0xe4, 0xbb, - 0x11, 0x10, 0x1a, 0xd2, 0x05, 0x74, 0xf1, 0x0b, 0xb4, 0x75, 0x57, 0xf4, 0x3e, 0x55, 0x14, - 0x17, 0x05, 0x4a, 0xb2, 0xfb, 0x8c, 0x84, 0x64, 0x38, 0x02, 0xa0, 0x2a, 0xa6, 0xf0}; - - Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; - - uint8_t signText[] = {0x30, 0x44, 0x02, 0x20, 0x21, 0x89, 0x99, 0xb1, 0x56, 0x4e, 0x3a, 0x2c, 0x16, 0x08, - 0xb5, 0x8a, 0x06, 0x6f, 0x67, 0x47, 0x1b, 0x04, 0x18, 0x7d, 0x53, 0x2d, 0xba, 0x00, - 0x38, 0xd9, 0xe3, 0xe7, 0x8c, 0xcf, 0x76, 0x83, 0x02, 0x20, 0x13, 0x54, 0x84, 0x9d, - 0x73, 0x40, 0xc3, 0x92, 0x66, 0xdc, 0x3e, 0xc9, 0xf1, 0x4c, 0x33, 0x84, 0x2a, 0x76, - 0xaf, 0xc6, 0x61, 0x84, 0x5c, 0xae, 0x4b, 0x0d, 0x3c, 0xb0, 0xc8, 0x04, 0x89, 0x71}; - - Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; - - OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; - // keypair - ret = OH_CryptoAsymKeyGenerator_Create((const char *)"ECC256", &keyCtx); - if (ret != CRYPTO_SUCCESS) { - return false; - } - ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_DER, &keyBlob, nullptr, &keyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); - // verify - ret = OH_CryptoVerify_Create((const char *)"ECC|SHA256", &verify); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - ret = OH_CryptoVerify_Init(verify, pubKey); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - bool res = OH_CryptoVerify_Final(verify, &msgBlob, &signBlob); - if (ret != true) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - OH_CryptoKeyPair_Destroy(keyPair); - return res; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start verify_signatures_with_ecdsa_keys_c] +#include "signing_signature_verification.h" + +bool DoTestEcdsaSignature() +{ + OH_CryptoAsymKeyGenerator *keyCtx = nullptr; + OH_CryptoKeyPair *keyPair = nullptr; + OH_CryptoVerify *verify = nullptr; + + uint8_t plainText[] = {0xe4, 0x2b, 0xcc, 0x08, 0x11, 0x79, 0x16, 0x1b, + 0x35, 0x7f, 0xb3, 0xaf, 0x40, 0x3b, 0x3f, 0x7c}; + Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; + + uint8_t pubKeyText[] = {0x30, 0x39, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, + 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x22, 0x00, 0x03, 0x4d, 0xe4, 0xbb, + 0x11, 0x10, 0x1a, 0xd2, 0x05, 0x74, 0xf1, 0x0b, 0xb4, 0x75, 0x57, 0xf4, 0x3e, 0x55, 0x14, + 0x17, 0x05, 0x4a, 0xb2, 0xfb, 0x8c, 0x84, 0x64, 0x38, 0x02, 0xa0, 0x2a, 0xa6, 0xf0}; + + Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; + + uint8_t signText[] = {0x30, 0x44, 0x02, 0x20, 0x21, 0x89, 0x99, 0xb1, 0x56, 0x4e, 0x3a, 0x2c, 0x16, 0x08, + 0xb5, 0x8a, 0x06, 0x6f, 0x67, 0x47, 0x1b, 0x04, 0x18, 0x7d, 0x53, 0x2d, 0xba, 0x00, + 0x38, 0xd9, 0xe3, 0xe7, 0x8c, 0xcf, 0x76, 0x83, 0x02, 0x20, 0x13, 0x54, 0x84, 0x9d, + 0x73, 0x40, 0xc3, 0x92, 0x66, 0xdc, 0x3e, 0xc9, 0xf1, 0x4c, 0x33, 0x84, 0x2a, 0x76, + 0xaf, 0xc6, 0x61, 0x84, 0x5c, 0xae, 0x4b, 0x0d, 0x3c, 0xb0, 0xc8, 0x04, 0x89, 0x71}; + + Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; + + OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; + // keypair + ret = OH_CryptoAsymKeyGenerator_Create((const char *)"ECC256", &keyCtx); + if (ret != CRYPTO_SUCCESS) { + return false; + } + ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_DER, &keyBlob, nullptr, &keyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); + // verify + ret = OH_CryptoVerify_Create((const char *)"ECC|SHA256", &verify); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + ret = OH_CryptoVerify_Init(verify, pubKey); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + bool res = OH_CryptoVerify_Final(verify, &msgBlob, &signBlob); + if (ret != true) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + OH_CryptoKeyPair_Destroy(keyPair); + return res; +} // [End verify_signatures_with_ecdsa_keys_c] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_segment_signature.cpp b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_segment_signature.cpp old mode 100755 new mode 100644 index 9848e4a3a3..4b41c78f3f --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_segment_signature.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_segment_signature.cpp @@ -1,123 +1,123 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pkcs1_seg_verify_rsa_keypair_sign] -#include "signing_signature_verification.h" - -static constexpr int INT_64 = 64; -bool DoTestRsaSignatureSeg() -{ - OH_CryptoAsymKeyGenerator *keyCtx = nullptr; - OH_CryptoKeyPair *keyPair = nullptr; - OH_CryptoVerify *verify = nullptr; - - uint8_t plainText[] = { - 0x43, 0x31, 0x7d, 0xb5, 0x85, 0x2e, 0xd4, 0xef, 0x08, 0x7a, 0x17, 0x96, 0xbc, 0x7c, 0x8f, 0x80, - 0x8c, 0xa7, 0x63, 0x7f, 0x26, 0x89, 0x8f, 0xf0, 0xfa, 0xa7, 0x51, 0xbd, 0x9c, 0x69, 0x17, 0xf3, - 0xd1, 0xb5, 0xc7, 0x12, 0xbf, 0xcf, 0x91, 0x25, 0x82, 0x23, 0x6b, 0xd6, 0x64, 0x52, 0x77, 0x93, - 0x01, 0x9d, 0x70, 0xa3, 0xf4, 0x92, 0x16, 0xec, 0x3f, 0xa7, 0x3c, 0x83, 0x8d, 0x40, 0x41, 0xfc, - }; - Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; - - uint8_t pubKeyText[] = { - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x55, 0x42, - 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x47, 0x4a, 0x41, - 0x6f, 0x47, 0x42, 0x41, 0x4d, 0x78, 0x63, 0x44, 0x4d, 0x6f, 0x61, 0x59, 0x52, 0x58, 0x6f, 0x78, 0x65, 0x69, - 0x33, 0x49, 0x6d, 0x33, 0x33, 0x78, 0x4a, 0x76, 0x61, 0x73, 0x63, 0x43, 0x62, 0x77, 0x31, 0x6f, 0x73, 0x63, - 0x32, 0x56, 0x56, 0x69, 0x47, 0x6a, 0x56, 0x47, 0x47, 0x4a, 0x37, 0x6c, 0x75, 0x4e, 0x41, 0x58, 0x6b, 0x6a, - 0x73, 0x56, 0x46, 0x64, 0x35, 0x0a, 0x58, 0x37, 0x4c, 0x4d, 0x6c, 0x46, 0x34, 0x63, 0x35, 0x5a, 0x75, 0x59, - 0x2f, 0x61, 0x69, 0x57, 0x77, 0x70, 0x54, 0x69, 0x63, 0x62, 0x67, 0x49, 0x33, 0x43, 0x66, 0x50, 0x6f, 0x32, - 0x6a, 0x6c, 0x52, 0x74, 0x67, 0x41, 0x46, 0x6b, 0x44, 0x71, 0x7a, 0x4b, 0x53, 0x46, 0x62, 0x46, 0x47, 0x51, - 0x6b, 0x43, 0x6e, 0x64, 0x63, 0x2b, 0x54, 0x59, 0x6b, 0x5a, 0x42, 0x32, 0x70, 0x45, 0x6f, 0x72, 0x0a, 0x7a, - 0x73, 0x61, 0x56, 0x58, 0x77, 0x5a, 0x47, 0x45, 0x34, 0x41, 0x43, 0x70, 0x59, 0x35, 0x79, 0x65, 0x66, 0x49, - 0x44, 0x6c, 0x45, 0x57, 0x49, 0x51, 0x4f, 0x6a, 0x59, 0x4b, 0x2f, 0x6c, 0x58, 0x71, 0x7a, 0x48, 0x47, 0x69, - 0x4f, 0x69, 0x32, 0x75, 0x4a, 0x45, 0x75, 0x44, 0x43, 0x50, 0x6a, 0x51, 0x64, 0x6a, 0x54, 0x41, 0x67, 0x4d, - 0x42, 0x41, 0x41, 0x45, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x52, 0x53, 0x41, - 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, - }; - - Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; - - uint8_t signText[] = { - 0x68, 0x2f, 0x3b, 0xe6, 0xa6, 0x5c, 0xb8, 0x60, 0xd4, 0xe1, 0x64, 0xa7, 0xd8, 0x0c, 0x9c, 0x89, - 0x39, 0xb4, 0xf0, 0xb7, 0xad, 0xb5, 0x8a, 0x71, 0x04, 0xf1, 0xa5, 0x63, 0xdd, 0x32, 0x6a, 0x44, - 0xeb, 0xff, 0xb7, 0xe6, 0x85, 0xe5, 0xa5, 0x55, 0x5d, 0x5b, 0x28, 0x53, 0x63, 0xe4, 0xb3, 0xb9, - 0xa8, 0x70, 0xc8, 0x8f, 0xcd, 0x21, 0x8d, 0xe6, 0x1f, 0xe5, 0x78, 0x34, 0xd3, 0x45, 0x0c, 0x9c, - 0x7a, 0x22, 0x1b, 0x63, 0x55, 0xca, 0x14, 0xa5, 0x0c, 0x7a, 0x40, 0x8e, 0xa1, 0x14, 0x78, 0xa1, - 0xf1, 0x36, 0x78, 0xbd, 0xba, 0x37, 0x3b, 0x5b, 0xb0, 0x8e, 0xb3, 0x4a, 0x9b, 0x1b, 0x0c, 0xfa, - 0xfa, 0xc7, 0x9f, 0xb1, 0x35, 0x48, 0x82, 0x73, 0xf8, 0x6b, 0xd4, 0x76, 0x33, 0x5c, 0xed, 0x9c, - 0xd8, 0x4b, 0xc9, 0x92, 0xa0, 0x3f, 0x6e, 0xba, 0x78, 0x2e, 0x80, 0x78, 0x1e, 0x74, 0xa0, 0x47, - }; - - Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; - - // keypair - OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; - ret = OH_CryptoAsymKeyGenerator_Create((const char *)"RSA2048", &keyCtx); - if (ret != CRYPTO_SUCCESS) { - return false; - } - ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_PEM, &keyBlob, nullptr, &keyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); - // verify - ret = OH_CryptoVerify_Create((const char *)"RSA1024|PKCS1|SHA256", &verify); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - int blockSize = 20; - int cntS = INT_64 / blockSize; - int remS = INT_64 % blockSize; - ret = OH_CryptoVerify_Init(verify, pubKey); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - for (int i = 0; i < cntS; i++) { - msgBlob.len = blockSize; - ret = OH_CryptoVerify_Update(verify, (Crypto_DataBlob *)&msgBlob); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - msgBlob.data += blockSize; - } - bool res = false; - if (remS > 0) { - msgBlob.len = remS; - res = OH_CryptoVerify_Final(verify, (Crypto_DataBlob *)&msgBlob, (Crypto_DataBlob *)&signBlob); - if (res != true) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - } - - msgBlob.data -= INT_64 - remS; - msgBlob.len = INT_64; - - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - OH_CryptoKeyPair_Destroy(keyPair); - return res; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pkcs1_seg_verify_rsa_keypair_sign] +#include "signing_signature_verification.h" + +static constexpr int INT_64 = 64; +bool DoTestRsaSignatureSeg() +{ + OH_CryptoAsymKeyGenerator *keyCtx = nullptr; + OH_CryptoKeyPair *keyPair = nullptr; + OH_CryptoVerify *verify = nullptr; + + uint8_t plainText[] = { + 0x43, 0x31, 0x7d, 0xb5, 0x85, 0x2e, 0xd4, 0xef, 0x08, 0x7a, 0x17, 0x96, 0xbc, 0x7c, 0x8f, 0x80, + 0x8c, 0xa7, 0x63, 0x7f, 0x26, 0x89, 0x8f, 0xf0, 0xfa, 0xa7, 0x51, 0xbd, 0x9c, 0x69, 0x17, 0xf3, + 0xd1, 0xb5, 0xc7, 0x12, 0xbf, 0xcf, 0x91, 0x25, 0x82, 0x23, 0x6b, 0xd6, 0x64, 0x52, 0x77, 0x93, + 0x01, 0x9d, 0x70, 0xa3, 0xf4, 0x92, 0x16, 0xec, 0x3f, 0xa7, 0x3c, 0x83, 0x8d, 0x40, 0x41, 0xfc, + }; + Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; + + uint8_t pubKeyText[] = { + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x55, 0x42, + 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x47, 0x4a, 0x41, + 0x6f, 0x47, 0x42, 0x41, 0x4d, 0x78, 0x63, 0x44, 0x4d, 0x6f, 0x61, 0x59, 0x52, 0x58, 0x6f, 0x78, 0x65, 0x69, + 0x33, 0x49, 0x6d, 0x33, 0x33, 0x78, 0x4a, 0x76, 0x61, 0x73, 0x63, 0x43, 0x62, 0x77, 0x31, 0x6f, 0x73, 0x63, + 0x32, 0x56, 0x56, 0x69, 0x47, 0x6a, 0x56, 0x47, 0x47, 0x4a, 0x37, 0x6c, 0x75, 0x4e, 0x41, 0x58, 0x6b, 0x6a, + 0x73, 0x56, 0x46, 0x64, 0x35, 0x0a, 0x58, 0x37, 0x4c, 0x4d, 0x6c, 0x46, 0x34, 0x63, 0x35, 0x5a, 0x75, 0x59, + 0x2f, 0x61, 0x69, 0x57, 0x77, 0x70, 0x54, 0x69, 0x63, 0x62, 0x67, 0x49, 0x33, 0x43, 0x66, 0x50, 0x6f, 0x32, + 0x6a, 0x6c, 0x52, 0x74, 0x67, 0x41, 0x46, 0x6b, 0x44, 0x71, 0x7a, 0x4b, 0x53, 0x46, 0x62, 0x46, 0x47, 0x51, + 0x6b, 0x43, 0x6e, 0x64, 0x63, 0x2b, 0x54, 0x59, 0x6b, 0x5a, 0x42, 0x32, 0x70, 0x45, 0x6f, 0x72, 0x0a, 0x7a, + 0x73, 0x61, 0x56, 0x58, 0x77, 0x5a, 0x47, 0x45, 0x34, 0x41, 0x43, 0x70, 0x59, 0x35, 0x79, 0x65, 0x66, 0x49, + 0x44, 0x6c, 0x45, 0x57, 0x49, 0x51, 0x4f, 0x6a, 0x59, 0x4b, 0x2f, 0x6c, 0x58, 0x71, 0x7a, 0x48, 0x47, 0x69, + 0x4f, 0x69, 0x32, 0x75, 0x4a, 0x45, 0x75, 0x44, 0x43, 0x50, 0x6a, 0x51, 0x64, 0x6a, 0x54, 0x41, 0x67, 0x4d, + 0x42, 0x41, 0x41, 0x45, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x52, 0x53, 0x41, + 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, + }; + + Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; + + uint8_t signText[] = { + 0x68, 0x2f, 0x3b, 0xe6, 0xa6, 0x5c, 0xb8, 0x60, 0xd4, 0xe1, 0x64, 0xa7, 0xd8, 0x0c, 0x9c, 0x89, + 0x39, 0xb4, 0xf0, 0xb7, 0xad, 0xb5, 0x8a, 0x71, 0x04, 0xf1, 0xa5, 0x63, 0xdd, 0x32, 0x6a, 0x44, + 0xeb, 0xff, 0xb7, 0xe6, 0x85, 0xe5, 0xa5, 0x55, 0x5d, 0x5b, 0x28, 0x53, 0x63, 0xe4, 0xb3, 0xb9, + 0xa8, 0x70, 0xc8, 0x8f, 0xcd, 0x21, 0x8d, 0xe6, 0x1f, 0xe5, 0x78, 0x34, 0xd3, 0x45, 0x0c, 0x9c, + 0x7a, 0x22, 0x1b, 0x63, 0x55, 0xca, 0x14, 0xa5, 0x0c, 0x7a, 0x40, 0x8e, 0xa1, 0x14, 0x78, 0xa1, + 0xf1, 0x36, 0x78, 0xbd, 0xba, 0x37, 0x3b, 0x5b, 0xb0, 0x8e, 0xb3, 0x4a, 0x9b, 0x1b, 0x0c, 0xfa, + 0xfa, 0xc7, 0x9f, 0xb1, 0x35, 0x48, 0x82, 0x73, 0xf8, 0x6b, 0xd4, 0x76, 0x33, 0x5c, 0xed, 0x9c, + 0xd8, 0x4b, 0xc9, 0x92, 0xa0, 0x3f, 0x6e, 0xba, 0x78, 0x2e, 0x80, 0x78, 0x1e, 0x74, 0xa0, 0x47, + }; + + Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; + + // keypair + OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; + ret = OH_CryptoAsymKeyGenerator_Create((const char *)"RSA2048", &keyCtx); + if (ret != CRYPTO_SUCCESS) { + return false; + } + ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_PEM, &keyBlob, nullptr, &keyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); + // verify + ret = OH_CryptoVerify_Create((const char *)"RSA1024|PKCS1|SHA256", &verify); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + int blockSize = 20; + int cntS = INT_64 / blockSize; + int remS = INT_64 % blockSize; + ret = OH_CryptoVerify_Init(verify, pubKey); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + for (int i = 0; i < cntS; i++) { + msgBlob.len = blockSize; + ret = OH_CryptoVerify_Update(verify, (Crypto_DataBlob *)&msgBlob); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + msgBlob.data += blockSize; + } + bool res = false; + if (remS > 0) { + msgBlob.len = remS; + res = OH_CryptoVerify_Final(verify, (Crypto_DataBlob *)&msgBlob, (Crypto_DataBlob *)&signBlob); + if (res != true) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + } + + msgBlob.data -= INT_64 - remS; + msgBlob.len = INT_64; + + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + OH_CryptoKeyPair_Destroy(keyPair); + return res; +} // [End pkcs1_seg_verify_rsa_keypair_sign] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_signature_restoration.cpp b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_signature_restoration.cpp old mode 100755 new mode 100644 index 95f46677b3..34a372a568 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_signature_restoration.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_signature_restoration.cpp @@ -1,100 +1,100 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pkcs1_recover_rsa_keypair_sign] -#include "signing_signature_verification.h" - -OH_Crypto_ErrCode DoTestRsaSignatureRecover() -{ - OH_CryptoAsymKeyGenerator *keyCtx = nullptr; - OH_CryptoKeyPair *keyPair = nullptr; - OH_CryptoVerify *verify = nullptr; - - uint8_t plainText[] = {0xc4, 0xa5, 0xe5, 0x45, 0xee, 0x71, 0x5e, 0x3b, 0x24, 0x1d, 0x7e, - 0x62, 0xd6, 0x6b, 0xab, 0x98, 0x88, 0x0f, 0xaf, 0x1e, 0x96, 0xa0, - 0x6c, 0xa5, 0x0d, 0x29, 0xfd, 0xcc, 0xef, 0xf6, 0x2b, 0x92}; - Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; - - uint8_t pubKeyText[] = { - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x55, 0x42, - 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x47, 0x4a, 0x41, - 0x6f, 0x47, 0x42, 0x41, 0x4b, 0x72, 0x55, 0x74, 0x74, 0x64, 0x76, 0x73, 0x2b, 0x62, 0x6e, 0x4d, 0x2f, 0x6f, - 0x4e, 0x75, 0x39, 0x45, 0x42, 0x78, 0x35, 0x64, 0x49, 0x6d, 0x61, 0x70, 0x52, 0x67, 0x4d, 0x6a, 0x4b, 0x41, - 0x38, 0x51, 0x48, 0x4b, 0x61, 0x75, 0x2f, 0x6c, 0x58, 0x50, 0x50, 0x68, 0x76, 0x38, 0x30, 0x69, 0x59, 0x4c, - 0x46, 0x2b, 0x79, 0x35, 0x35, 0x0a, 0x6d, 0x42, 0x2f, 0x38, 0x2b, 0x4b, 0x68, 0x34, 0x34, 0x43, 0x2b, 0x5a, - 0x76, 0x6f, 0x78, 0x5a, 0x66, 0x38, 0x78, 0x34, 0x6e, 0x78, 0x6f, 0x71, 0x76, 0x4f, 0x6f, 0x73, 0x32, 0x44, - 0x55, 0x69, 0x51, 0x44, 0x4f, 0x4a, 0x35, 0x63, 0x57, 0x68, 0x5a, 0x62, 0x4d, 0x71, 0x4d, 0x42, 0x71, 0x62, - 0x39, 0x30, 0x4e, 0x39, 0x63, 0x2f, 0x44, 0x51, 0x67, 0x39, 0x34, 0x63, 0x52, 0x7a, 0x35, 0x66, 0x0a, 0x68, - 0x55, 0x66, 0x6d, 0x66, 0x6d, 0x54, 0x41, 0x46, 0x6a, 0x5a, 0x53, 0x33, 0x78, 0x6c, 0x78, 0x77, 0x6e, 0x50, - 0x77, 0x66, 0x66, 0x39, 0x71, 0x44, 0x79, 0x4c, 0x63, 0x5a, 0x55, 0x6b, 0x6e, 0x64, 0x43, 0x30, 0x50, 0x77, - 0x72, 0x6c, 0x38, 0x72, 0x70, 0x4b, 0x7a, 0x50, 0x47, 0x63, 0x71, 0x4e, 0x67, 0x33, 0x5a, 0x41, 0x67, 0x4d, - 0x42, 0x41, 0x41, 0x45, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x52, 0x53, 0x41, - 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, - }; - - Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; - - uint8_t signText[] = { - 0x1f, 0xe3, 0xcf, 0x8d, 0x94, 0xb4, 0xa0, 0x9e, 0xf1, 0x0c, 0x38, 0x59, 0xcb, 0x5b, 0x89, 0xc9, - 0x66, 0x8b, 0xfd, 0x8d, 0x1e, 0x37, 0xfa, 0x5e, 0x1b, 0xb1, 0x51, 0x07, 0xf1, 0xb0, 0x7d, 0x18, - 0x2d, 0x82, 0x2a, 0x04, 0xa4, 0x4e, 0x94, 0x7e, 0x76, 0xb8, 0xa4, 0x78, 0x90, 0x2f, 0x43, 0x1d, - 0x95, 0x80, 0xd7, 0xb3, 0x46, 0x4d, 0x58, 0x4b, 0xcd, 0x1f, 0x1d, 0xb3, 0x1f, 0x6b, 0x15, 0xd8, - 0x33, 0x51, 0x1d, 0x36, 0x12, 0x39, 0x92, 0xb4, 0x4d, 0xe2, 0x89, 0x26, 0x01, 0xe9, 0x1f, 0xc0, - 0x9c, 0x7c, 0xd8, 0xeb, 0x47, 0xff, 0xfb, 0x5d, 0x98, 0x9a, 0x02, 0x6a, 0x16, 0x37, 0xb1, 0xf5, - 0x08, 0x4d, 0xd7, 0xa0, 0xf2, 0x9e, 0xbe, 0x4b, 0x54, 0x77, 0x94, 0x95, 0x4b, 0x97, 0x10, 0x22, - 0x49, 0xa5, 0x2e, 0x05, 0x86, 0xfd, 0x6f, 0x9a, 0x40, 0xe6, 0x43, 0xab, 0xc5, 0xbc, 0xac, 0x21, - }; - - Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; - - // keypair - OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; - ret = OH_CryptoAsymKeyGenerator_Create((const char *)"RSA2048", &keyCtx); - if (ret != CRYPTO_SUCCESS) { - return ret; - } - ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_PEM, &keyBlob, nullptr, &keyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return ret; - } - OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); - // verify - ret = OH_CryptoVerify_Create((const char *)"RSA1024|PKCS1|SHA256|Recover", &verify); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return ret; - } - ret = OH_CryptoVerify_Init(verify, pubKey); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return ret; - } - Crypto_DataBlob rawSignData = {.data = nullptr, .len = 0}; - ret = OH_CryptoVerify_Recover(verify, (Crypto_DataBlob *)&signBlob, &rawSignData); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return ret; - } - - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - OH_CryptoKeyPair_Destroy(keyPair); - return ret; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pkcs1_recover_rsa_keypair_sign] +#include "signing_signature_verification.h" + +OH_Crypto_ErrCode DoTestRsaSignatureRecover() +{ + OH_CryptoAsymKeyGenerator *keyCtx = nullptr; + OH_CryptoKeyPair *keyPair = nullptr; + OH_CryptoVerify *verify = nullptr; + + uint8_t plainText[] = {0xc4, 0xa5, 0xe5, 0x45, 0xee, 0x71, 0x5e, 0x3b, 0x24, 0x1d, 0x7e, + 0x62, 0xd6, 0x6b, 0xab, 0x98, 0x88, 0x0f, 0xaf, 0x1e, 0x96, 0xa0, + 0x6c, 0xa5, 0x0d, 0x29, 0xfd, 0xcc, 0xef, 0xf6, 0x2b, 0x92}; + Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; + + uint8_t pubKeyText[] = { + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x55, 0x42, + 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x47, 0x4a, 0x41, + 0x6f, 0x47, 0x42, 0x41, 0x4b, 0x72, 0x55, 0x74, 0x74, 0x64, 0x76, 0x73, 0x2b, 0x62, 0x6e, 0x4d, 0x2f, 0x6f, + 0x4e, 0x75, 0x39, 0x45, 0x42, 0x78, 0x35, 0x64, 0x49, 0x6d, 0x61, 0x70, 0x52, 0x67, 0x4d, 0x6a, 0x4b, 0x41, + 0x38, 0x51, 0x48, 0x4b, 0x61, 0x75, 0x2f, 0x6c, 0x58, 0x50, 0x50, 0x68, 0x76, 0x38, 0x30, 0x69, 0x59, 0x4c, + 0x46, 0x2b, 0x79, 0x35, 0x35, 0x0a, 0x6d, 0x42, 0x2f, 0x38, 0x2b, 0x4b, 0x68, 0x34, 0x34, 0x43, 0x2b, 0x5a, + 0x76, 0x6f, 0x78, 0x5a, 0x66, 0x38, 0x78, 0x34, 0x6e, 0x78, 0x6f, 0x71, 0x76, 0x4f, 0x6f, 0x73, 0x32, 0x44, + 0x55, 0x69, 0x51, 0x44, 0x4f, 0x4a, 0x35, 0x63, 0x57, 0x68, 0x5a, 0x62, 0x4d, 0x71, 0x4d, 0x42, 0x71, 0x62, + 0x39, 0x30, 0x4e, 0x39, 0x63, 0x2f, 0x44, 0x51, 0x67, 0x39, 0x34, 0x63, 0x52, 0x7a, 0x35, 0x66, 0x0a, 0x68, + 0x55, 0x66, 0x6d, 0x66, 0x6d, 0x54, 0x41, 0x46, 0x6a, 0x5a, 0x53, 0x33, 0x78, 0x6c, 0x78, 0x77, 0x6e, 0x50, + 0x77, 0x66, 0x66, 0x39, 0x71, 0x44, 0x79, 0x4c, 0x63, 0x5a, 0x55, 0x6b, 0x6e, 0x64, 0x43, 0x30, 0x50, 0x77, + 0x72, 0x6c, 0x38, 0x72, 0x70, 0x4b, 0x7a, 0x50, 0x47, 0x63, 0x71, 0x4e, 0x67, 0x33, 0x5a, 0x41, 0x67, 0x4d, + 0x42, 0x41, 0x41, 0x45, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x52, 0x53, 0x41, + 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, + }; + + Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; + + uint8_t signText[] = { + 0x1f, 0xe3, 0xcf, 0x8d, 0x94, 0xb4, 0xa0, 0x9e, 0xf1, 0x0c, 0x38, 0x59, 0xcb, 0x5b, 0x89, 0xc9, + 0x66, 0x8b, 0xfd, 0x8d, 0x1e, 0x37, 0xfa, 0x5e, 0x1b, 0xb1, 0x51, 0x07, 0xf1, 0xb0, 0x7d, 0x18, + 0x2d, 0x82, 0x2a, 0x04, 0xa4, 0x4e, 0x94, 0x7e, 0x76, 0xb8, 0xa4, 0x78, 0x90, 0x2f, 0x43, 0x1d, + 0x95, 0x80, 0xd7, 0xb3, 0x46, 0x4d, 0x58, 0x4b, 0xcd, 0x1f, 0x1d, 0xb3, 0x1f, 0x6b, 0x15, 0xd8, + 0x33, 0x51, 0x1d, 0x36, 0x12, 0x39, 0x92, 0xb4, 0x4d, 0xe2, 0x89, 0x26, 0x01, 0xe9, 0x1f, 0xc0, + 0x9c, 0x7c, 0xd8, 0xeb, 0x47, 0xff, 0xfb, 0x5d, 0x98, 0x9a, 0x02, 0x6a, 0x16, 0x37, 0xb1, 0xf5, + 0x08, 0x4d, 0xd7, 0xa0, 0xf2, 0x9e, 0xbe, 0x4b, 0x54, 0x77, 0x94, 0x95, 0x4b, 0x97, 0x10, 0x22, + 0x49, 0xa5, 0x2e, 0x05, 0x86, 0xfd, 0x6f, 0x9a, 0x40, 0xe6, 0x43, 0xab, 0xc5, 0xbc, 0xac, 0x21, + }; + + Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; + + // keypair + OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; + ret = OH_CryptoAsymKeyGenerator_Create((const char *)"RSA2048", &keyCtx); + if (ret != CRYPTO_SUCCESS) { + return ret; + } + ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_PEM, &keyBlob, nullptr, &keyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return ret; + } + OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); + // verify + ret = OH_CryptoVerify_Create((const char *)"RSA1024|PKCS1|SHA256|Recover", &verify); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return ret; + } + ret = OH_CryptoVerify_Init(verify, pubKey); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return ret; + } + Crypto_DataBlob rawSignData = {.data = nullptr, .len = 0}; + ret = OH_CryptoVerify_Recover(verify, (Crypto_DataBlob *)&signBlob, &rawSignData); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return ret; + } + + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + OH_CryptoKeyPair_Destroy(keyPair); + return ret; +} // [End pkcs1_recover_rsa_keypair_sign] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_signature_validator.cpp b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_signature_validator.cpp old mode 100755 new mode 100644 index da798b263f..c153dd1e41 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_signature_validator.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pkcs1_signature_validator.cpp @@ -1,102 +1,102 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pkcs1_verify_rsa_keypair_sign] -#include "signing_signature_verification.h" - -bool DoTestRsaSignature() -{ - OH_CryptoAsymKeyGenerator *keyCtx = nullptr; - OH_CryptoKeyPair *keyPair = nullptr; - OH_CryptoVerify *verify = nullptr; - - uint8_t plainText[] = { - 0x43, 0x31, 0x7d, 0xb5, 0x85, 0x2e, 0xd4, 0xef, 0x08, 0x7a, 0x17, 0x96, 0xbc, 0x7c, 0x8f, 0x80, - 0x8c, 0xa7, 0x63, 0x7f, 0x26, 0x89, 0x8f, 0xf0, 0xfa, 0xa7, 0x51, 0xbd, 0x9c, 0x69, 0x17, 0xf3, - 0xd1, 0xb5, 0xc7, 0x12, 0xbf, 0xcf, 0x91, 0x25, 0x82, 0x23, 0x6b, 0xd6, 0x64, 0x52, 0x77, 0x93, - 0x01, 0x9d, 0x70, 0xa3, 0xf4, 0x92, 0x16, 0xec, 0x3f, 0xa7, 0x3c, 0x83, 0x8d, 0x40, 0x41, 0xfc, - }; - Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; - - uint8_t pubKeyText[] = { - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x55, 0x42, - 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x47, 0x4a, 0x41, - 0x6f, 0x47, 0x42, 0x41, 0x4d, 0x78, 0x63, 0x44, 0x4d, 0x6f, 0x61, 0x59, 0x52, 0x58, 0x6f, 0x78, 0x65, 0x69, - 0x33, 0x49, 0x6d, 0x33, 0x33, 0x78, 0x4a, 0x76, 0x61, 0x73, 0x63, 0x43, 0x62, 0x77, 0x31, 0x6f, 0x73, 0x63, - 0x32, 0x56, 0x56, 0x69, 0x47, 0x6a, 0x56, 0x47, 0x47, 0x4a, 0x37, 0x6c, 0x75, 0x4e, 0x41, 0x58, 0x6b, 0x6a, - 0x73, 0x56, 0x46, 0x64, 0x35, 0x0a, 0x58, 0x37, 0x4c, 0x4d, 0x6c, 0x46, 0x34, 0x63, 0x35, 0x5a, 0x75, 0x59, - 0x2f, 0x61, 0x69, 0x57, 0x77, 0x70, 0x54, 0x69, 0x63, 0x62, 0x67, 0x49, 0x33, 0x43, 0x66, 0x50, 0x6f, 0x32, - 0x6a, 0x6c, 0x52, 0x74, 0x67, 0x41, 0x46, 0x6b, 0x44, 0x71, 0x7a, 0x4b, 0x53, 0x46, 0x62, 0x46, 0x47, 0x51, - 0x6b, 0x43, 0x6e, 0x64, 0x63, 0x2b, 0x54, 0x59, 0x6b, 0x5a, 0x42, 0x32, 0x70, 0x45, 0x6f, 0x72, 0x0a, 0x7a, - 0x73, 0x61, 0x56, 0x58, 0x77, 0x5a, 0x47, 0x45, 0x34, 0x41, 0x43, 0x70, 0x59, 0x35, 0x79, 0x65, 0x66, 0x49, - 0x44, 0x6c, 0x45, 0x57, 0x49, 0x51, 0x4f, 0x6a, 0x59, 0x4b, 0x2f, 0x6c, 0x58, 0x71, 0x7a, 0x48, 0x47, 0x69, - 0x4f, 0x69, 0x32, 0x75, 0x4a, 0x45, 0x75, 0x44, 0x43, 0x50, 0x6a, 0x51, 0x64, 0x6a, 0x54, 0x41, 0x67, 0x4d, - 0x42, 0x41, 0x41, 0x45, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x52, 0x53, 0x41, - 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, - }; - - Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; - - uint8_t signText[] = { - 0x68, 0x2f, 0x3b, 0xe6, 0xa6, 0x5c, 0xb8, 0x60, 0xd4, 0xe1, 0x64, 0xa7, 0xd8, 0x0c, 0x9c, 0x89, - 0x39, 0xb4, 0xf0, 0xb7, 0xad, 0xb5, 0x8a, 0x71, 0x04, 0xf1, 0xa5, 0x63, 0xdd, 0x32, 0x6a, 0x44, - 0xeb, 0xff, 0xb7, 0xe6, 0x85, 0xe5, 0xa5, 0x55, 0x5d, 0x5b, 0x28, 0x53, 0x63, 0xe4, 0xb3, 0xb9, - 0xa8, 0x70, 0xc8, 0x8f, 0xcd, 0x21, 0x8d, 0xe6, 0x1f, 0xe5, 0x78, 0x34, 0xd3, 0x45, 0x0c, 0x9c, - 0x7a, 0x22, 0x1b, 0x63, 0x55, 0xca, 0x14, 0xa5, 0x0c, 0x7a, 0x40, 0x8e, 0xa1, 0x14, 0x78, 0xa1, - 0xf1, 0x36, 0x78, 0xbd, 0xba, 0x37, 0x3b, 0x5b, 0xb0, 0x8e, 0xb3, 0x4a, 0x9b, 0x1b, 0x0c, 0xfa, - 0xfa, 0xc7, 0x9f, 0xb1, 0x35, 0x48, 0x82, 0x73, 0xf8, 0x6b, 0xd4, 0x76, 0x33, 0x5c, 0xed, 0x9c, - 0xd8, 0x4b, 0xc9, 0x92, 0xa0, 0x3f, 0x6e, 0xba, 0x78, 0x2e, 0x80, 0x78, 0x1e, 0x74, 0xa0, 0x47, - }; - - Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; - - // keypair - OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; - ret = OH_CryptoAsymKeyGenerator_Create((const char *)"RSA2048", &keyCtx); - if (ret != CRYPTO_SUCCESS) { - return false; - } - ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_PEM, &keyBlob, nullptr, &keyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); - // verify - ret = OH_CryptoVerify_Create((const char *)"RSA1024|PKCS1|SHA256", &verify); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - ret = OH_CryptoVerify_Init(verify, pubKey); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - bool res = OH_CryptoVerify_Final(verify, &msgBlob, &signBlob); - if (res != true) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - OH_CryptoKeyPair_Destroy(keyPair); - return res; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pkcs1_verify_rsa_keypair_sign] +#include "signing_signature_verification.h" + +bool DoTestRsaSignature() +{ + OH_CryptoAsymKeyGenerator *keyCtx = nullptr; + OH_CryptoKeyPair *keyPair = nullptr; + OH_CryptoVerify *verify = nullptr; + + uint8_t plainText[] = { + 0x43, 0x31, 0x7d, 0xb5, 0x85, 0x2e, 0xd4, 0xef, 0x08, 0x7a, 0x17, 0x96, 0xbc, 0x7c, 0x8f, 0x80, + 0x8c, 0xa7, 0x63, 0x7f, 0x26, 0x89, 0x8f, 0xf0, 0xfa, 0xa7, 0x51, 0xbd, 0x9c, 0x69, 0x17, 0xf3, + 0xd1, 0xb5, 0xc7, 0x12, 0xbf, 0xcf, 0x91, 0x25, 0x82, 0x23, 0x6b, 0xd6, 0x64, 0x52, 0x77, 0x93, + 0x01, 0x9d, 0x70, 0xa3, 0xf4, 0x92, 0x16, 0xec, 0x3f, 0xa7, 0x3c, 0x83, 0x8d, 0x40, 0x41, 0xfc, + }; + Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; + + uint8_t pubKeyText[] = { + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x55, 0x42, + 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x47, 0x4a, 0x41, + 0x6f, 0x47, 0x42, 0x41, 0x4d, 0x78, 0x63, 0x44, 0x4d, 0x6f, 0x61, 0x59, 0x52, 0x58, 0x6f, 0x78, 0x65, 0x69, + 0x33, 0x49, 0x6d, 0x33, 0x33, 0x78, 0x4a, 0x76, 0x61, 0x73, 0x63, 0x43, 0x62, 0x77, 0x31, 0x6f, 0x73, 0x63, + 0x32, 0x56, 0x56, 0x69, 0x47, 0x6a, 0x56, 0x47, 0x47, 0x4a, 0x37, 0x6c, 0x75, 0x4e, 0x41, 0x58, 0x6b, 0x6a, + 0x73, 0x56, 0x46, 0x64, 0x35, 0x0a, 0x58, 0x37, 0x4c, 0x4d, 0x6c, 0x46, 0x34, 0x63, 0x35, 0x5a, 0x75, 0x59, + 0x2f, 0x61, 0x69, 0x57, 0x77, 0x70, 0x54, 0x69, 0x63, 0x62, 0x67, 0x49, 0x33, 0x43, 0x66, 0x50, 0x6f, 0x32, + 0x6a, 0x6c, 0x52, 0x74, 0x67, 0x41, 0x46, 0x6b, 0x44, 0x71, 0x7a, 0x4b, 0x53, 0x46, 0x62, 0x46, 0x47, 0x51, + 0x6b, 0x43, 0x6e, 0x64, 0x63, 0x2b, 0x54, 0x59, 0x6b, 0x5a, 0x42, 0x32, 0x70, 0x45, 0x6f, 0x72, 0x0a, 0x7a, + 0x73, 0x61, 0x56, 0x58, 0x77, 0x5a, 0x47, 0x45, 0x34, 0x41, 0x43, 0x70, 0x59, 0x35, 0x79, 0x65, 0x66, 0x49, + 0x44, 0x6c, 0x45, 0x57, 0x49, 0x51, 0x4f, 0x6a, 0x59, 0x4b, 0x2f, 0x6c, 0x58, 0x71, 0x7a, 0x48, 0x47, 0x69, + 0x4f, 0x69, 0x32, 0x75, 0x4a, 0x45, 0x75, 0x44, 0x43, 0x50, 0x6a, 0x51, 0x64, 0x6a, 0x54, 0x41, 0x67, 0x4d, + 0x42, 0x41, 0x41, 0x45, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x52, 0x53, 0x41, + 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, + }; + + Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; + + uint8_t signText[] = { + 0x68, 0x2f, 0x3b, 0xe6, 0xa6, 0x5c, 0xb8, 0x60, 0xd4, 0xe1, 0x64, 0xa7, 0xd8, 0x0c, 0x9c, 0x89, + 0x39, 0xb4, 0xf0, 0xb7, 0xad, 0xb5, 0x8a, 0x71, 0x04, 0xf1, 0xa5, 0x63, 0xdd, 0x32, 0x6a, 0x44, + 0xeb, 0xff, 0xb7, 0xe6, 0x85, 0xe5, 0xa5, 0x55, 0x5d, 0x5b, 0x28, 0x53, 0x63, 0xe4, 0xb3, 0xb9, + 0xa8, 0x70, 0xc8, 0x8f, 0xcd, 0x21, 0x8d, 0xe6, 0x1f, 0xe5, 0x78, 0x34, 0xd3, 0x45, 0x0c, 0x9c, + 0x7a, 0x22, 0x1b, 0x63, 0x55, 0xca, 0x14, 0xa5, 0x0c, 0x7a, 0x40, 0x8e, 0xa1, 0x14, 0x78, 0xa1, + 0xf1, 0x36, 0x78, 0xbd, 0xba, 0x37, 0x3b, 0x5b, 0xb0, 0x8e, 0xb3, 0x4a, 0x9b, 0x1b, 0x0c, 0xfa, + 0xfa, 0xc7, 0x9f, 0xb1, 0x35, 0x48, 0x82, 0x73, 0xf8, 0x6b, 0xd4, 0x76, 0x33, 0x5c, 0xed, 0x9c, + 0xd8, 0x4b, 0xc9, 0x92, 0xa0, 0x3f, 0x6e, 0xba, 0x78, 0x2e, 0x80, 0x78, 0x1e, 0x74, 0xa0, 0x47, + }; + + Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; + + // keypair + OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; + ret = OH_CryptoAsymKeyGenerator_Create((const char *)"RSA2048", &keyCtx); + if (ret != CRYPTO_SUCCESS) { + return false; + } + ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_PEM, &keyBlob, nullptr, &keyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); + // verify + ret = OH_CryptoVerify_Create((const char *)"RSA1024|PKCS1|SHA256", &verify); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + ret = OH_CryptoVerify_Init(verify, pubKey); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + bool res = OH_CryptoVerify_Final(verify, &msgBlob, &signBlob); + if (res != true) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + OH_CryptoKeyPair_Destroy(keyPair); + return res; +} // [End pkcs1_verify_rsa_keypair_sign] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pss_verification_tool.cpp b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pss_verification_tool.cpp old mode 100755 new mode 100644 index 320b6ef619..daca1482f3 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pss_verification_tool.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/rsa_pss_verification_tool.cpp @@ -1,116 +1,116 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pss_verify_rsa_keypair_sign] -#include "signing_signature_verification.h" - -bool DoTestRsaPssSignatureSeg() -{ - OH_CryptoAsymKeyGenerator *keyCtx = nullptr; - OH_CryptoKeyPair *keyPair = nullptr; - OH_CryptoVerify *verify = nullptr; - - uint8_t plainText[] = { - 0x13, 0xa7, 0x73, 0xe8, 0xb8, 0x22, 0x99, 0x72, 0x98, 0x29, 0xae, 0x74, 0xa8, 0x4a, 0xea, 0xa9, - }; - Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; - - uint8_t pubKeyText[] = { - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x55, 0x42, - 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x42, 0x43, - 0x67, 0x4b, 0x43, 0x41, 0x51, 0x45, 0x41, 0x76, 0x6a, 0x6c, 0x59, 0x35, 0x53, 0x72, 0x54, 0x57, 0x32, 0x43, - 0x78, 0x74, 0x47, 0x32, 0x54, 0x67, 0x54, 0x54, 0x39, 0x39, 0x78, 0x71, 0x37, 0x62, 0x4e, 0x41, 0x6b, 0x54, - 0x2b, 0x65, 0x6a, 0x75, 0x65, 0x7a, 0x37, 0x39, 0x37, 0x2f, 0x65, 0x63, 0x56, 0x4b, 0x34, 0x78, 0x37, 0x58, - 0x41, 0x4d, 0x6d, 0x73, 0x4a, 0x0a, 0x4a, 0x63, 0x66, 0x49, 0x36, 0x73, 0x54, 0x4d, 0x4e, 0x68, 0x45, 0x6b, - 0x70, 0x79, 0x63, 0x31, 0x4b, 0x32, 0x46, 0x6e, 0x30, 0x74, 0x59, 0x47, 0x2f, 0x6d, 0x4d, 0x37, 0x72, 0x71, - 0x6d, 0x6a, 0x6c, 0x6b, 0x75, 0x72, 0x34, 0x72, 0x74, 0x6a, 0x4a, 0x4a, 0x75, 0x66, 0x34, 0x35, 0x45, 0x42, - 0x30, 0x79, 0x6c, 0x55, 0x65, 0x47, 0x61, 0x39, 0x6d, 0x44, 0x4a, 0x57, 0x76, 0x62, 0x2b, 0x73, 0x0a, 0x41, - 0x4a, 0x78, 0x33, 0x41, 0x44, 0x78, 0x70, 0x50, 0x31, 0x59, 0x36, 0x46, 0x61, 0x71, 0x54, 0x44, 0x6e, 0x64, - 0x47, 0x41, 0x6e, 0x6b, 0x65, 0x4d, 0x53, 0x2f, 0x56, 0x71, 0x53, 0x45, 0x65, 0x75, 0x43, 0x36, 0x4d, 0x42, - 0x38, 0x52, 0x53, 0x65, 0x6f, 0x31, 0x4f, 0x59, 0x4c, 0x53, 0x73, 0x7a, 0x36, 0x43, 0x76, 0x38, 0x34, 0x76, - 0x76, 0x53, 0x69, 0x32, 0x37, 0x32, 0x51, 0x44, 0x6e, 0x0a, 0x6f, 0x4b, 0x4f, 0x4d, 0x34, 0x43, 0x78, 0x6d, - 0x6e, 0x32, 0x31, 0x58, 0x5a, 0x43, 0x5a, 0x2f, 0x59, 0x50, 0x32, 0x35, 0x67, 0x5a, 0x6e, 0x57, 0x4f, 0x61, - 0x42, 0x4c, 0x50, 0x57, 0x79, 0x6f, 0x48, 0x46, 0x65, 0x49, 0x55, 0x42, 0x48, 0x4c, 0x50, 0x69, 0x4a, 0x2b, - 0x72, 0x58, 0x48, 0x4e, 0x65, 0x4f, 0x38, 0x2b, 0x70, 0x6c, 0x37, 0x49, 0x42, 0x74, 0x66, 0x35, 0x67, 0x70, - 0x4a, 0x76, 0x0a, 0x31, 0x6e, 0x78, 0x72, 0x45, 0x4b, 0x73, 0x75, 0x2b, 0x6e, 0x64, 0x48, 0x43, 0x6e, 0x46, - 0x64, 0x6f, 0x38, 0x2f, 0x49, 0x46, 0x46, 0x4a, 0x6a, 0x70, 0x36, 0x73, 0x6f, 0x55, 0x4a, 0x4f, 0x5a, 0x52, - 0x4b, 0x6e, 0x6f, 0x41, 0x4b, 0x34, 0x67, 0x6a, 0x34, 0x48, 0x30, 0x50, 0x76, 0x49, 0x79, 0x4d, 0x67, 0x4b, - 0x61, 0x43, 0x43, 0x41, 0x55, 0x57, 0x70, 0x4a, 0x65, 0x76, 0x35, 0x42, 0x52, 0x0a, 0x42, 0x4f, 0x56, 0x38, - 0x4f, 0x59, 0x34, 0x48, 0x48, 0x6f, 0x42, 0x6b, 0x47, 0x4d, 0x6e, 0x32, 0x71, 0x6a, 0x4d, 0x48, 0x78, 0x49, - 0x6c, 0x71, 0x48, 0x50, 0x67, 0x59, 0x70, 0x41, 0x53, 0x50, 0x51, 0x77, 0x49, 0x44, 0x41, 0x51, 0x41, 0x42, - 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x55, 0x42, 0x4c, - 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, - }; - - Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; - - uint8_t signText[] = { - 0xac, 0x2b, 0x12, 0x56, 0x1c, 0xe1, 0x60, 0x49, 0xc2, 0xd9, 0x87, 0x89, 0xfb, 0xa3, 0xc5, 0x41, 0x64, 0x7f, - 0x6f, 0x80, 0xc8, 0xdb, 0xb3, 0xdf, 0x25, 0x76, 0x4b, 0x1e, 0x51, 0xaa, 0x0a, 0x6d, 0x83, 0x49, 0xae, 0x00, - 0x7a, 0x99, 0xf4, 0xc8, 0x98, 0x45, 0x71, 0xfc, 0x5e, 0xdb, 0xed, 0x31, 0xad, 0xf2, 0x35, 0x05, 0xe2, 0x3e, - 0xf1, 0xcb, 0x96, 0xb2, 0xb9, 0x59, 0xaf, 0x30, 0x25, 0xb0, 0xda, 0x83, 0x18, 0x2b, 0x11, 0xa4, 0x93, 0x2d, - 0x9e, 0x93, 0x99, 0x62, 0xdd, 0xea, 0x1b, 0xfa, 0x60, 0xb8, 0xea, 0x9c, 0xef, 0x4f, 0x2b, 0x9d, 0xd1, 0x3e, - 0xe1, 0x6b, 0x24, 0x98, 0x9d, 0x32, 0xa3, 0x1e, 0x9d, 0x45, 0xe7, 0x3d, 0x51, 0x7e, 0x3b, 0x0c, 0xee, 0x3f, - 0xca, 0x29, 0xd9, 0x02, 0xe5, 0xb8, 0xf5, 0x89, 0x06, 0xf4, 0xfe, 0x27, 0x44, 0xff, 0x38, 0xed, 0x5a, 0x0e, - 0x89, 0x16, 0x15, 0x26, 0xf0, 0xb2, 0x4c, 0x95, 0xee, 0x0a, 0xd3, 0x61, 0xc7, 0xb2, 0x4b, 0xfd, 0x20, 0xb9, - 0x83, 0x25, 0x43, 0x4d, 0xa0, 0x3d, 0xaa, 0x40, 0x7b, 0xac, 0x01, 0x48, 0x8e, 0x2a, 0x96, 0x11, 0xc0, 0x31, - 0x51, 0x5b, 0xaf, 0xeb, 0x8b, 0xaf, 0xb5, 0x88, 0xcb, 0xe0, 0x97, 0x45, 0x36, 0xe9, 0x6e, 0x6e, 0xe0, 0x55, - 0xea, 0xf4, 0xd2, 0x88, 0xbb, 0xc9, 0x85, 0x94, 0xd5, 0x65, 0xeb, 0xa3, 0x1c, 0xd1, 0xd6, 0xf5, 0x22, 0x29, - 0xf1, 0x16, 0xa5, 0x53, 0x1b, 0xd0, 0x6c, 0xf6, 0x0d, 0xa8, 0xd4, 0xe4, 0xb2, 0x0a, 0x92, 0x64, 0x7a, 0x6d, - 0xf2, 0x76, 0xf3, 0xb0, 0x08, 0x44, 0x31, 0x31, 0x90, 0x48, 0x9e, 0x2e, 0x03, 0xc7, 0xab, 0x5d, 0x7a, 0x07, - 0x1f, 0x1d, 0x10, 0x21, 0x54, 0x60, 0x0d, 0x26, 0xe4, 0x1c, 0xc7, 0x82, 0x03, 0x65, 0x64, 0x70, 0x41, 0x68, - 0x0f, 0xfa, 0x64, 0x3c, - }; - - Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; - - // keypair - OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; - ret = OH_CryptoAsymKeyGenerator_Create((const char *)"RSA2048", &keyCtx); - if (ret != CRYPTO_SUCCESS) { - return false; - } - ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_PEM, &keyBlob, nullptr, &keyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); - // verify - ret = OH_CryptoVerify_Create((const char *)"RSA2048|PSS|SHA256|MGF1_SHA256", &verify); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - ret = OH_CryptoVerify_Init(verify, pubKey); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - bool res = OH_CryptoVerify_Final(verify, &msgBlob, &signBlob); - if (ret != true) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - OH_CryptoKeyPair_Destroy(keyPair); - return res; -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pss_verify_rsa_keypair_sign] +#include "signing_signature_verification.h" + +bool DoTestRsaPssSignatureSeg() +{ + OH_CryptoAsymKeyGenerator *keyCtx = nullptr; + OH_CryptoKeyPair *keyPair = nullptr; + OH_CryptoVerify *verify = nullptr; + + uint8_t plainText[] = { + 0x13, 0xa7, 0x73, 0xe8, 0xb8, 0x22, 0x99, 0x72, 0x98, 0x29, 0xae, 0x74, 0xa8, 0x4a, 0xea, 0xa9, + }; + Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; + + uint8_t pubKeyText[] = { + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x55, 0x42, + 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x42, 0x43, + 0x67, 0x4b, 0x43, 0x41, 0x51, 0x45, 0x41, 0x76, 0x6a, 0x6c, 0x59, 0x35, 0x53, 0x72, 0x54, 0x57, 0x32, 0x43, + 0x78, 0x74, 0x47, 0x32, 0x54, 0x67, 0x54, 0x54, 0x39, 0x39, 0x78, 0x71, 0x37, 0x62, 0x4e, 0x41, 0x6b, 0x54, + 0x2b, 0x65, 0x6a, 0x75, 0x65, 0x7a, 0x37, 0x39, 0x37, 0x2f, 0x65, 0x63, 0x56, 0x4b, 0x34, 0x78, 0x37, 0x58, + 0x41, 0x4d, 0x6d, 0x73, 0x4a, 0x0a, 0x4a, 0x63, 0x66, 0x49, 0x36, 0x73, 0x54, 0x4d, 0x4e, 0x68, 0x45, 0x6b, + 0x70, 0x79, 0x63, 0x31, 0x4b, 0x32, 0x46, 0x6e, 0x30, 0x74, 0x59, 0x47, 0x2f, 0x6d, 0x4d, 0x37, 0x72, 0x71, + 0x6d, 0x6a, 0x6c, 0x6b, 0x75, 0x72, 0x34, 0x72, 0x74, 0x6a, 0x4a, 0x4a, 0x75, 0x66, 0x34, 0x35, 0x45, 0x42, + 0x30, 0x79, 0x6c, 0x55, 0x65, 0x47, 0x61, 0x39, 0x6d, 0x44, 0x4a, 0x57, 0x76, 0x62, 0x2b, 0x73, 0x0a, 0x41, + 0x4a, 0x78, 0x33, 0x41, 0x44, 0x78, 0x70, 0x50, 0x31, 0x59, 0x36, 0x46, 0x61, 0x71, 0x54, 0x44, 0x6e, 0x64, + 0x47, 0x41, 0x6e, 0x6b, 0x65, 0x4d, 0x53, 0x2f, 0x56, 0x71, 0x53, 0x45, 0x65, 0x75, 0x43, 0x36, 0x4d, 0x42, + 0x38, 0x52, 0x53, 0x65, 0x6f, 0x31, 0x4f, 0x59, 0x4c, 0x53, 0x73, 0x7a, 0x36, 0x43, 0x76, 0x38, 0x34, 0x76, + 0x76, 0x53, 0x69, 0x32, 0x37, 0x32, 0x51, 0x44, 0x6e, 0x0a, 0x6f, 0x4b, 0x4f, 0x4d, 0x34, 0x43, 0x78, 0x6d, + 0x6e, 0x32, 0x31, 0x58, 0x5a, 0x43, 0x5a, 0x2f, 0x59, 0x50, 0x32, 0x35, 0x67, 0x5a, 0x6e, 0x57, 0x4f, 0x61, + 0x42, 0x4c, 0x50, 0x57, 0x79, 0x6f, 0x48, 0x46, 0x65, 0x49, 0x55, 0x42, 0x48, 0x4c, 0x50, 0x69, 0x4a, 0x2b, + 0x72, 0x58, 0x48, 0x4e, 0x65, 0x4f, 0x38, 0x2b, 0x70, 0x6c, 0x37, 0x49, 0x42, 0x74, 0x66, 0x35, 0x67, 0x70, + 0x4a, 0x76, 0x0a, 0x31, 0x6e, 0x78, 0x72, 0x45, 0x4b, 0x73, 0x75, 0x2b, 0x6e, 0x64, 0x48, 0x43, 0x6e, 0x46, + 0x64, 0x6f, 0x38, 0x2f, 0x49, 0x46, 0x46, 0x4a, 0x6a, 0x70, 0x36, 0x73, 0x6f, 0x55, 0x4a, 0x4f, 0x5a, 0x52, + 0x4b, 0x6e, 0x6f, 0x41, 0x4b, 0x34, 0x67, 0x6a, 0x34, 0x48, 0x30, 0x50, 0x76, 0x49, 0x79, 0x4d, 0x67, 0x4b, + 0x61, 0x43, 0x43, 0x41, 0x55, 0x57, 0x70, 0x4a, 0x65, 0x76, 0x35, 0x42, 0x52, 0x0a, 0x42, 0x4f, 0x56, 0x38, + 0x4f, 0x59, 0x34, 0x48, 0x48, 0x6f, 0x42, 0x6b, 0x47, 0x4d, 0x6e, 0x32, 0x71, 0x6a, 0x4d, 0x48, 0x78, 0x49, + 0x6c, 0x71, 0x48, 0x50, 0x67, 0x59, 0x70, 0x41, 0x53, 0x50, 0x51, 0x77, 0x49, 0x44, 0x41, 0x51, 0x41, 0x42, + 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x55, 0x42, 0x4c, + 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, + }; + + Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; + + uint8_t signText[] = { + 0xac, 0x2b, 0x12, 0x56, 0x1c, 0xe1, 0x60, 0x49, 0xc2, 0xd9, 0x87, 0x89, 0xfb, 0xa3, 0xc5, 0x41, 0x64, 0x7f, + 0x6f, 0x80, 0xc8, 0xdb, 0xb3, 0xdf, 0x25, 0x76, 0x4b, 0x1e, 0x51, 0xaa, 0x0a, 0x6d, 0x83, 0x49, 0xae, 0x00, + 0x7a, 0x99, 0xf4, 0xc8, 0x98, 0x45, 0x71, 0xfc, 0x5e, 0xdb, 0xed, 0x31, 0xad, 0xf2, 0x35, 0x05, 0xe2, 0x3e, + 0xf1, 0xcb, 0x96, 0xb2, 0xb9, 0x59, 0xaf, 0x30, 0x25, 0xb0, 0xda, 0x83, 0x18, 0x2b, 0x11, 0xa4, 0x93, 0x2d, + 0x9e, 0x93, 0x99, 0x62, 0xdd, 0xea, 0x1b, 0xfa, 0x60, 0xb8, 0xea, 0x9c, 0xef, 0x4f, 0x2b, 0x9d, 0xd1, 0x3e, + 0xe1, 0x6b, 0x24, 0x98, 0x9d, 0x32, 0xa3, 0x1e, 0x9d, 0x45, 0xe7, 0x3d, 0x51, 0x7e, 0x3b, 0x0c, 0xee, 0x3f, + 0xca, 0x29, 0xd9, 0x02, 0xe5, 0xb8, 0xf5, 0x89, 0x06, 0xf4, 0xfe, 0x27, 0x44, 0xff, 0x38, 0xed, 0x5a, 0x0e, + 0x89, 0x16, 0x15, 0x26, 0xf0, 0xb2, 0x4c, 0x95, 0xee, 0x0a, 0xd3, 0x61, 0xc7, 0xb2, 0x4b, 0xfd, 0x20, 0xb9, + 0x83, 0x25, 0x43, 0x4d, 0xa0, 0x3d, 0xaa, 0x40, 0x7b, 0xac, 0x01, 0x48, 0x8e, 0x2a, 0x96, 0x11, 0xc0, 0x31, + 0x51, 0x5b, 0xaf, 0xeb, 0x8b, 0xaf, 0xb5, 0x88, 0xcb, 0xe0, 0x97, 0x45, 0x36, 0xe9, 0x6e, 0x6e, 0xe0, 0x55, + 0xea, 0xf4, 0xd2, 0x88, 0xbb, 0xc9, 0x85, 0x94, 0xd5, 0x65, 0xeb, 0xa3, 0x1c, 0xd1, 0xd6, 0xf5, 0x22, 0x29, + 0xf1, 0x16, 0xa5, 0x53, 0x1b, 0xd0, 0x6c, 0xf6, 0x0d, 0xa8, 0xd4, 0xe4, 0xb2, 0x0a, 0x92, 0x64, 0x7a, 0x6d, + 0xf2, 0x76, 0xf3, 0xb0, 0x08, 0x44, 0x31, 0x31, 0x90, 0x48, 0x9e, 0x2e, 0x03, 0xc7, 0xab, 0x5d, 0x7a, 0x07, + 0x1f, 0x1d, 0x10, 0x21, 0x54, 0x60, 0x0d, 0x26, 0xe4, 0x1c, 0xc7, 0x82, 0x03, 0x65, 0x64, 0x70, 0x41, 0x68, + 0x0f, 0xfa, 0x64, 0x3c, + }; + + Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; + + // keypair + OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; + ret = OH_CryptoAsymKeyGenerator_Create((const char *)"RSA2048", &keyCtx); + if (ret != CRYPTO_SUCCESS) { + return false; + } + ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_PEM, &keyBlob, nullptr, &keyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); + // verify + ret = OH_CryptoVerify_Create((const char *)"RSA2048|PSS|SHA256|MGF1_SHA256", &verify); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + ret = OH_CryptoVerify_Init(verify, pubKey); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + bool res = OH_CryptoVerify_Final(verify, &msgBlob, &signBlob); + if (ret != true) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + OH_CryptoKeyPair_Destroy(keyPair); + return res; +} // [End pss_verify_rsa_keypair_sign] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/signing_signature_verification.h b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/signing_signature_verification.h old mode 100755 new mode 100644 index afde6e8c95..2aca2232ef --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/signing_signature_verification.h +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/signing_signature_verification.h @@ -1,29 +1,29 @@ -#ifndef MYAPPLICATION_AA_H -#define MYAPPLICATION_AA_H -/* - * 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 "CryptoArchitectureKit/crypto_common.h" -#include "CryptoArchitectureKit/crypto_signature.h" -#include "CryptoArchitectureKit/crypto_asym_key.h" - -bool DoTestRsaSignature(); -bool DoTestRsaSignatureSeg(); -OH_Crypto_ErrCode DoTestRsaSignatureRecover(); -bool DoTestRsaPssSignatureSeg(); -bool DoTestEcdsaSignature(); -bool DoTestSm2Signature(); - +#ifndef MYAPPLICATION_AA_H +#define MYAPPLICATION_AA_H +/* + * 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 "CryptoArchitectureKit/crypto_common.h" +#include "CryptoArchitectureKit/crypto_signature.h" +#include "CryptoArchitectureKit/crypto_asym_key.h" + +bool DoTestRsaSignature(); +bool DoTestRsaSignatureSeg(); +OH_Crypto_ErrCode DoTestRsaSignatureRecover(); +bool DoTestRsaPssSignatureSeg(); +bool DoTestEcdsaSignature(); +bool DoTestSm2Signature(); + #endif // MYAPPLICATION_AA_H \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/sm2_signature_verification.cpp b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/sm2_signature_verification.cpp old mode 100755 new mode 100644 index c1e897b0de..4ca9a53c96 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/sm2_signature_verification.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/sm2_signature_verification.cpp @@ -1,88 +1,88 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start verify_signatures_with_sm2_key_pair_c] -#include "signing_signature_verification.h" - -bool DoTestSm2Signature() -{ - OH_CryptoAsymKeyGenerator *keyCtx = nullptr; - OH_CryptoKeyPair *keyPair = nullptr; - OH_CryptoVerify *verify = nullptr; - - uint8_t plainText[] = { - 0x96, 0x46, 0x2e, 0xde, 0x3f, 0x47, 0xbf, 0xd6, 0x87, 0x48, 0x36, 0x1d, 0x75, 0x35, 0xbd, 0xbc, - 0x6b, 0x06, 0xe8, 0xb3, 0x68, 0x91, 0x53, 0xce, 0x76, 0x5d, 0x24, 0xda, 0xdc, 0xc4, 0x9f, 0x94, - }; - Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; - - uint8_t pubKeyText[] = { - 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, - 0x81, 0x1c, 0xcf, 0x55, 0x01, 0x82, 0x2d, 0x03, 0x42, 0x00, 0x04, 0x80, 0x5b, 0x78, 0x04, 0xd7, - 0xcf, 0xc3, 0x99, 0x63, 0xae, 0x88, 0xcd, 0xfc, 0xd6, 0x18, 0xf4, 0x08, 0xe8, 0xe3, 0x68, 0x47, - 0x4f, 0x44, 0x0e, 0xb2, 0xba, 0x3a, 0xb3, 0x10, 0xf1, 0xc9, 0xd0, 0x84, 0xe2, 0xa4, 0x47, 0xbe, - 0x72, 0xae, 0xf8, 0x6a, 0xeb, 0x6e, 0x10, 0xab, 0x52, 0x6b, 0x6a, 0x58, 0xc6, 0xb5, 0x78, 0xaa, - 0x70, 0xe5, 0x58, 0x20, 0x4e, 0x34, 0x42, 0x77, 0x08, 0x27, 0x11, - }; - - Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; - - uint8_t signText[] = { - 0x30, 0x45, 0x02, 0x21, 0x00, 0xf4, 0xe7, 0x9d, 0x35, 0x33, 0xa6, 0x86, 0x2e, 0x2a, 0x97, 0x72, 0xc9, 0x46, - 0x79, 0x65, 0xca, 0x4a, 0x71, 0x34, 0xca, 0xf7, 0x58, 0xb3, 0x26, 0xa5, 0xdb, 0xfa, 0x8b, 0xbe, 0xbf, 0x5f, - 0x90, 0x02, 0x20, 0x53, 0xb4, 0x23, 0xb1, 0xe2, 0x8f, 0x2f, 0xe9, 0xc8, 0x22, 0xef, 0xab, 0x9b, 0x13, 0x08, - 0x75, 0x8e, 0xb1, 0x9c, 0x59, 0xe5, 0xd6, 0x64, 0x35, 0xf5, 0xd1, 0xde, 0xfa, 0xfe, 0x80, 0x37, 0x1a, - }; - - Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; - - // keypair - OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; - ret = OH_CryptoAsymKeyGenerator_Create((const char *)"SM2_256", &keyCtx); - if (ret != CRYPTO_SUCCESS) { - return false; - } - ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_DER, &keyBlob, nullptr, &keyPair); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); - // verify - ret = OH_CryptoVerify_Create((const char *)"SM2_256|SM3", &verify); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - ret = OH_CryptoVerify_Init(verify, pubKey); - if (ret != CRYPTO_SUCCESS) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - bool res = OH_CryptoVerify_Final(verify, &msgBlob, &signBlob); - if (ret != true) { - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - return false; - } - - OH_CryptoVerify_Destroy(verify); - OH_CryptoAsymKeyGenerator_Destroy(keyCtx); - OH_CryptoKeyPair_Destroy(keyPair); - return res; -} - +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start verify_signatures_with_sm2_key_pair_c] +#include "signing_signature_verification.h" + +bool DoTestSm2Signature() +{ + OH_CryptoAsymKeyGenerator *keyCtx = nullptr; + OH_CryptoKeyPair *keyPair = nullptr; + OH_CryptoVerify *verify = nullptr; + + uint8_t plainText[] = { + 0x96, 0x46, 0x2e, 0xde, 0x3f, 0x47, 0xbf, 0xd6, 0x87, 0x48, 0x36, 0x1d, 0x75, 0x35, 0xbd, 0xbc, + 0x6b, 0x06, 0xe8, 0xb3, 0x68, 0x91, 0x53, 0xce, 0x76, 0x5d, 0x24, 0xda, 0xdc, 0xc4, 0x9f, 0x94, + }; + Crypto_DataBlob msgBlob = {.data = reinterpret_cast(plainText), .len = sizeof(plainText)}; + + uint8_t pubKeyText[] = { + 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, + 0x81, 0x1c, 0xcf, 0x55, 0x01, 0x82, 0x2d, 0x03, 0x42, 0x00, 0x04, 0x80, 0x5b, 0x78, 0x04, 0xd7, + 0xcf, 0xc3, 0x99, 0x63, 0xae, 0x88, 0xcd, 0xfc, 0xd6, 0x18, 0xf4, 0x08, 0xe8, 0xe3, 0x68, 0x47, + 0x4f, 0x44, 0x0e, 0xb2, 0xba, 0x3a, 0xb3, 0x10, 0xf1, 0xc9, 0xd0, 0x84, 0xe2, 0xa4, 0x47, 0xbe, + 0x72, 0xae, 0xf8, 0x6a, 0xeb, 0x6e, 0x10, 0xab, 0x52, 0x6b, 0x6a, 0x58, 0xc6, 0xb5, 0x78, 0xaa, + 0x70, 0xe5, 0x58, 0x20, 0x4e, 0x34, 0x42, 0x77, 0x08, 0x27, 0x11, + }; + + Crypto_DataBlob keyBlob = {.data = reinterpret_cast(pubKeyText), .len = sizeof(pubKeyText)}; + + uint8_t signText[] = { + 0x30, 0x45, 0x02, 0x21, 0x00, 0xf4, 0xe7, 0x9d, 0x35, 0x33, 0xa6, 0x86, 0x2e, 0x2a, 0x97, 0x72, 0xc9, 0x46, + 0x79, 0x65, 0xca, 0x4a, 0x71, 0x34, 0xca, 0xf7, 0x58, 0xb3, 0x26, 0xa5, 0xdb, 0xfa, 0x8b, 0xbe, 0xbf, 0x5f, + 0x90, 0x02, 0x20, 0x53, 0xb4, 0x23, 0xb1, 0xe2, 0x8f, 0x2f, 0xe9, 0xc8, 0x22, 0xef, 0xab, 0x9b, 0x13, 0x08, + 0x75, 0x8e, 0xb1, 0x9c, 0x59, 0xe5, 0xd6, 0x64, 0x35, 0xf5, 0xd1, 0xde, 0xfa, 0xfe, 0x80, 0x37, 0x1a, + }; + + Crypto_DataBlob signBlob = {.data = reinterpret_cast(signText), .len = sizeof(signText)}; + + // keypair + OH_Crypto_ErrCode ret = CRYPTO_SUCCESS; + ret = OH_CryptoAsymKeyGenerator_Create((const char *)"SM2_256", &keyCtx); + if (ret != CRYPTO_SUCCESS) { + return false; + } + ret = OH_CryptoAsymKeyGenerator_Convert(keyCtx, CRYPTO_DER, &keyBlob, nullptr, &keyPair); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + OH_CryptoPubKey *pubKey = OH_CryptoKeyPair_GetPubKey(keyPair); + // verify + ret = OH_CryptoVerify_Create((const char *)"SM2_256|SM3", &verify); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + ret = OH_CryptoVerify_Init(verify, pubKey); + if (ret != CRYPTO_SUCCESS) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + bool res = OH_CryptoVerify_Final(verify, &msgBlob, &signBlob); + if (ret != true) { + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + return false; + } + + OH_CryptoVerify_Destroy(verify); + OH_CryptoAsymKeyGenerator_Destroy(keyCtx); + OH_CryptoKeyPair_Destroy(keyPair); + return res; +} + // [End verify_signatures_with_sm2_key_pair_c] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index a36ca588fe..965554bb3a --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 25fd42ff7d..037c49dd58 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/ets/pages/Index.ets @@ -1,66 +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. - */ - -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 5 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_signature_seg')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.signatureSeg(); - this.message = 'SignatureSegSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_signature')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.signature(); - this.message = 'SignatureSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_signature_recover')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.signatureRecover(); - this.message = 'SignatureRecoverSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_psssignature_seg')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.pssSignatureSeg(); - this.message = 'PSSSignatureSegSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_ecdsasignature')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.ecdsaSignature(); - this.message = 'ECDSASignatureSuccess Result:' + ret.toString(); - }) - Button($r('app.string.call_sm2signature')) - .width('70%') - .onClick(() => { - let ret: number = testNapi.sm2Signature(); - this.message = 'SM2SignatureSuccess Result:' + ret.toString(); - }) - } - .height('100%') - .width('100%') - } -} +/* + * 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 { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 5 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_signature_seg')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.signatureSeg(); + this.message = 'SignatureSegSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_signature')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.signature(); + this.message = 'SignatureSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_signature_recover')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.signatureRecover(); + this.message = 'SignatureRecoverSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_psssignature_seg')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.pssSignatureSeg(); + this.message = 'PSSSignatureSegSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_ecdsasignature')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.ecdsaSignature(); + this.message = 'ECDSASignatureSuccess Result:' + ret.toString(); + }) + Button($r('app.string.call_sm2signature')) + .width('70%') + .onClick(() => { + let ret: number = testNapi.sm2Signature(); + this.message = 'SM2SignatureSuccess Result:' + ret.toString(); + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/SigningSignatureVerification.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/SigningSignatureVerification.test.ets old mode 100755 new mode 100644 index fb2bef7c97..3d3612f119 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/SigningSignatureVerification.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/ets/test/SigningSignatureVerification.test.ets @@ -1,128 +1,128 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function signingSignatureVerificationTest() { - describe('signingSignatureVerificationTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用RSA密钥对(PKCS1模式)验签(C/C++) - */ - it('testSigningSignatureVerificationTest001', 0, async () => { - console.info('uitest: testSigningSignatureVerificationTest001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call SignatureSeg')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SignatureSegSuccess Result:true')); - console.info('uitest: testSigningSignatureVerificationTest001 end'); - }) - - /** - * 点击按钮,使用RSA密钥对(PKCS1模式)签名恢复(C/C++) - */ - it('testSigningSignatureVerificationTest002', 0, async () => { - console.info('uitest: testSigningSignatureVerificationTest002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call Signature')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SignatureSuccess Result:true')); - console.info('uitest: testSigningSignatureVerificationTest002 end'); - }) - - /** - * 点击按钮,使用RSA密钥对分段验签(PKCS1模式)(C/C++) - */ - it('testSigningSignatureVerificationTest003', 0, async () => { - console.info('uitest: testSigningSignatureVerificationTest003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call SignatureRecover')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SignatureRecoverSuccess Result:0')); - console.info('uitest: testSigningSignatureVerificationTest003 end'); - }) - - /** - * 点击按钮,使用RSA密钥对验签(PSS模式)(C/C++) - */ - it('testSigningSignatureVerificationTest004', 0, async () => { - console.info('uitest: testSigningSignatureVerificationTest004 begin'); - const driver = Driver.create(); - const button = await driver.findComponent(ON.text('Call PSSSignatureSeg')); - await driver.delayMs(1000); - await button.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('PSSSignatureSegSuccess Result:false')); - console.info('uitest: testSigningSignatureVerificationTest004 end'); - }) - - /** - * 点击按钮,使用ECDSA密钥对验签(C/C++) - */ - it('testSigningSignatureVerificationTest005', 0, async () => { - console.info('uitest: testSigningSignatureVerificationTest005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call ECDSASignature')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ECDSASignatureSuccess Result:false')); - console.info('uitest: testSigningSignatureVerificationTest005 end'); - }) - - /** - * 点击按钮,使用SM2密钥对验签(C/C++) - */ - it('testSigningSignatureVerificationTest006', 0, async () => { - console.info('uitest: testSigningSignatureVerificationTest006 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call SM2Signature')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2SignatureSuccess Result:false')); - console.info('uitest: testSigningSignatureVerificationTest006 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function signingSignatureVerificationTest() { + describe('signingSignatureVerificationTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用RSA密钥对(PKCS1模式)验签(C/C++) + */ + it('testSigningSignatureVerificationTest001', 0, async () => { + console.info('uitest: testSigningSignatureVerificationTest001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call SignatureSeg')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SignatureSegSuccess Result:true')); + console.info('uitest: testSigningSignatureVerificationTest001 end'); + }) + + /** + * 点击按钮,使用RSA密钥对(PKCS1模式)签名恢复(C/C++) + */ + it('testSigningSignatureVerificationTest002', 0, async () => { + console.info('uitest: testSigningSignatureVerificationTest002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call Signature')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SignatureSuccess Result:true')); + console.info('uitest: testSigningSignatureVerificationTest002 end'); + }) + + /** + * 点击按钮,使用RSA密钥对分段验签(PKCS1模式)(C/C++) + */ + it('testSigningSignatureVerificationTest003', 0, async () => { + console.info('uitest: testSigningSignatureVerificationTest003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call SignatureRecover')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SignatureRecoverSuccess Result:0')); + console.info('uitest: testSigningSignatureVerificationTest003 end'); + }) + + /** + * 点击按钮,使用RSA密钥对验签(PSS模式)(C/C++) + */ + it('testSigningSignatureVerificationTest004', 0, async () => { + console.info('uitest: testSigningSignatureVerificationTest004 begin'); + const driver = Driver.create(); + const button = await driver.findComponent(ON.text('Call PSSSignatureSeg')); + await driver.delayMs(1000); + await button.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('PSSSignatureSegSuccess Result:false')); + console.info('uitest: testSigningSignatureVerificationTest004 end'); + }) + + /** + * 点击按钮,使用ECDSA密钥对验签(C/C++) + */ + it('testSigningSignatureVerificationTest005', 0, async () => { + console.info('uitest: testSigningSignatureVerificationTest005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call ECDSASignature')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ECDSASignatureSuccess Result:false')); + console.info('uitest: testSigningSignatureVerificationTest005 end'); + }) + + /** + * 点击按钮,使用SM2密钥对验签(C/C++) + */ + it('testSigningSignatureVerificationTest006', 0, async () => { + console.info('uitest: testSigningSignatureVerificationTest006 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call SM2Signature')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2SignatureSuccess Result:false')); + console.info('uitest: testSigningSignatureVerificationTest006 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/ohosTest.md old mode 100755 new mode 100644 index cd57f20d95..3484ec8f48 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/ohosTest.md @@ -1,13 +1,13 @@ -# 签名验签(C/C++)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用RSA密钥对(PKCS1模式)验签(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA密钥对(PKCS1模式)签名恢复(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA密钥对分段验签(PKCS1模式)(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA密钥对验签(PSS模式)(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用ECDSA密钥对验签(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 签名验签(C/C++)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用RSA密钥对(PKCS1模式)验签(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA密钥对(PKCS1模式)签名恢复(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA密钥对分段验签(PKCS1模式)(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA密钥对验签(PSS模式)(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用ECDSA密钥对验签(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用SM2密钥对验签(C/C++) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/screenshots/SigningSignatureVerification1.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/screenshots/SigningSignatureVerification1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/screenshots/SigningSignatureVerification2.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/screenshots/SigningSignatureVerification2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/app.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/app.json5 old mode 100755 new mode 100644 index b699ed2606..839e94769a --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/app.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/app.json5 @@ -1,25 +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.signingsignatureverificationarkts", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.signingsignatureverificationarkts", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index cc63c91523..23956993e9 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SigningSignatureVerificationArkTs" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SigningSignatureVerificationArkTs" + } + ] +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/README.md b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/README.md old mode 100755 new mode 100644 index cad3648ab0..89991a1f58 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/README.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/README.md @@ -1,80 +1,80 @@ -# 签名验签(ArkTS) - -### 介绍 - -当需要判断接收的数据是否被篡改、数据是否为指定对象发送的数据时,可以使用签名验签操作。接下来将说明系统目前支持的算法及其对应的规格。 - -本示例主要展示了签名验签(ArkTS)的多种场景 。该工程中展示的代码详细描述可查如下链接。 - -- [使用RSA密钥对(PKCS1模式)签名验签(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pkcs1.md) -- [使用RSA密钥对(PKCS1模式)签名及签名恢复(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-recover-pkcs1.md) -- [使用RSA密钥对分段签名验签(PKCS1模式)(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pkcs1-by-segment.md) -- [使用RSA密钥对签名验签(PSS模式)(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pss.md) -- [使用ECDSA密钥对签名验签(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-ecdsa-sign-sig-verify.md) -- [使用SM2密钥对签名验签(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm2-sign-sig-verify-pkcs1.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例SigningSignatureVerificationArkTs.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 签名验签(ArkTS)示例代码 - │ │ ├── ecdsa_signature_verification - │ │ ├── rsa_pkcs1_segment_signature - │ │ ├── rsa_pkcs1_signature_restoration - │ │ ├── rsa_pkcs1_signature_validator - │ │ ├── rsa_pss_signature_verification - │ │ ├── sm2_signature_verification - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── SigningSignatureVerificationArkTs.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 签名验签(ArkTS) + +### 介绍 + +当需要判断接收的数据是否被篡改、数据是否为指定对象发送的数据时,可以使用签名验签操作。接下来将说明系统目前支持的算法及其对应的规格。 + +本示例主要展示了签名验签(ArkTS)的多种场景 。该工程中展示的代码详细描述可查如下链接。 + +- [使用RSA密钥对(PKCS1模式)签名验签(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pkcs1.md) +- [使用RSA密钥对(PKCS1模式)签名及签名恢复(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-recover-pkcs1.md) +- [使用RSA密钥对分段签名验签(PKCS1模式)(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pkcs1-by-segment.md) +- [使用RSA密钥对签名验签(PSS模式)(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-rsa-sign-sig-verify-pss.md) +- [使用ECDSA密钥对签名验签(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-ecdsa-sign-sig-verify.md) +- [使用SM2密钥对签名验签(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/CryptoArchitectureKit/crypto-sm2-sign-sig-verify-pkcs1.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例SigningSignatureVerificationArkTs.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 签名验签(ArkTS)示例代码 + │ │ ├── ecdsa_signature_verification + │ │ ├── rsa_pkcs1_segment_signature + │ │ ├── rsa_pkcs1_signature_restoration + │ │ ├── rsa_pkcs1_signature_validator + │ │ ├── rsa_pss_signature_verification + │ │ ├── sm2_signature_verification + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── SigningSignatureVerificationArkTs.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs > .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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/code-linter.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/.gitignore b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/build-profile.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/build-profile.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_asynchronous.ets old mode 100755 new mode 100644 index 6e103ba1f1..8f55acfd9a --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_asynchronous.ets @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start signature_verification_with_ecdsa_key_pair_ark_async] - -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 完整的明文被拆分为input1和input2 -let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; -let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; - -async function signMessagePromise(priKey: cryptoFramework.PriKey) { - let signAlg = 'ECC256|SHA256'; - let signer = cryptoFramework.createSign(signAlg); - await signer.init(priKey); - await signer.update(input1); // 如果明文较短,可以直接调用sign接口一次性传入 - let signData = await signer.sign(input2); - return signData; -} - -async function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { - let verifyAlg = 'ECC256|SHA256'; - let verifier = cryptoFramework.createVerify(verifyAlg); - await verifier.init(pubKey); - await verifier.update(input1); // 如果明文较短,可以直接调用verify接口一次性传入 - let res = await verifier.verify(input2, signMessageBlob); - console.info('verify result is ' + res); - return res; -} - -async function main() { - let keyGenAlg = 'ECC256'; - let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); - let keyPair = await generator.generateKeyPair(); - let signData = await signMessagePromise(keyPair.priKey); - let verifyResult = await verifyMessagePromise(signData, keyPair.pubKey); - if (verifyResult === true) { - console.info('verify success'); - } else { - console.error('verify failed'); - } -} - -// [End signature_verification_with_ecdsa_key_pair_ark_async] -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_ecdsasignature_asynchronous')) - .width('70%') - .onClick(async () => { - try { - await main(); - this.message = 'ECDSASignatureSuccess'; - } catch { - this.message = 'ECDSASignatureFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start signature_verification_with_ecdsa_key_pair_ark_async] + +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 完整的明文被拆分为input1和input2 +let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; +let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; + +async function signMessagePromise(priKey: cryptoFramework.PriKey) { + let signAlg = 'ECC256|SHA256'; + let signer = cryptoFramework.createSign(signAlg); + await signer.init(priKey); + await signer.update(input1); // 如果明文较短,可以直接调用sign接口一次性传入 + let signData = await signer.sign(input2); + return signData; +} + +async function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { + let verifyAlg = 'ECC256|SHA256'; + let verifier = cryptoFramework.createVerify(verifyAlg); + await verifier.init(pubKey); + await verifier.update(input1); // 如果明文较短,可以直接调用verify接口一次性传入 + let res = await verifier.verify(input2, signMessageBlob); + console.info('verify result is ' + res); + return res; +} + +async function main() { + let keyGenAlg = 'ECC256'; + let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); + let keyPair = await generator.generateKeyPair(); + let signData = await signMessagePromise(keyPair.priKey); + let verifyResult = await verifyMessagePromise(signData, keyPair.pubKey); + if (verifyResult === true) { + console.info('verify success'); + } else { + console.error('verify failed'); + } +} + +// [End signature_verification_with_ecdsa_key_pair_ark_async] +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_ecdsasignature_asynchronous')) + .width('70%') + .onClick(async () => { + try { + await main(); + this.message = 'ECDSASignatureSuccess'; + } catch { + this.message = 'ECDSASignatureFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_synchronous.ets old mode 100755 new mode 100644 index 8288f2ce24..12568ccd9e --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_synchronous.ets @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start signature_verification_with_ecdsa_key_pair_ark_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 完整的明文被拆分为input1和input2 -let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; -let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; - -function signMessagePromise(priKey: cryptoFramework.PriKey) { - let signAlg = 'ECC256|SHA256'; - let signer = cryptoFramework.createSign(signAlg); - signer.initSync(priKey); - signer.updateSync(input1); // 如果明文较短,可以直接调用sign接口一次性传入 - let signData = signer.signSync(input2); - return signData; -} - -function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { - let verifyAlg = 'ECC256|SHA256'; - let verifier = cryptoFramework.createVerify(verifyAlg); - verifier.initSync(pubKey); - verifier.updateSync(input1); // 如果明文较短,可以直接调用verify接口一次性传入 - let res = verifier.verifySync(input2, signMessageBlob); - console.info('verify result is ' + res); - return res; -} - -function main() { - let keyGenAlg = 'ECC256'; - let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); - let keyPair = generator.generateKeyPairSync(); - let signData = signMessagePromise(keyPair.priKey); - let verifyResult = verifyMessagePromise(signData, keyPair.pubKey); - if (verifyResult === true) { - console.info('verify success'); - } else { - console.error('verify failed'); - } -} - - -// [End signature_verification_with_ecdsa_key_pair_ark_sync] -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_ecdsasignature_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'ECDSASignatureSuccess'; - } catch { - this.message = 'ECDSASignatureFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start signature_verification_with_ecdsa_key_pair_ark_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 完整的明文被拆分为input1和input2 +let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; +let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; + +function signMessagePromise(priKey: cryptoFramework.PriKey) { + let signAlg = 'ECC256|SHA256'; + let signer = cryptoFramework.createSign(signAlg); + signer.initSync(priKey); + signer.updateSync(input1); // 如果明文较短,可以直接调用sign接口一次性传入 + let signData = signer.signSync(input2); + return signData; +} + +function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { + let verifyAlg = 'ECC256|SHA256'; + let verifier = cryptoFramework.createVerify(verifyAlg); + verifier.initSync(pubKey); + verifier.updateSync(input1); // 如果明文较短,可以直接调用verify接口一次性传入 + let res = verifier.verifySync(input2, signMessageBlob); + console.info('verify result is ' + res); + return res; +} + +function main() { + let keyGenAlg = 'ECC256'; + let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); + let keyPair = generator.generateKeyPairSync(); + let signData = signMessagePromise(keyPair.priKey); + let verifyResult = verifyMessagePromise(signData, keyPair.pubKey); + if (verifyResult === true) { + console.info('verify success'); + } else { + console.error('verify failed'); + } +} + + +// [End signature_verification_with_ecdsa_key_pair_ark_sync] +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_ecdsasignature_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'ECDSASignatureSuccess'; + } catch { + this.message = 'ECDSASignatureFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_segment_signature/rsa_pkcs1_segment_signature_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_segment_signature/rsa_pkcs1_segment_signature_asynchronous.ets old mode 100755 new mode 100644 index 4c2a2df08a..9fbda9d0a0 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_segment_signature/rsa_pkcs1_segment_signature_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_segment_signature/rsa_pkcs1_segment_signature_asynchronous.ets @@ -1,99 +1,99 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pkcs1_seg_verify_rsa_keypair_sign_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -async function signMessageBySegment(priKey: cryptoFramework.PriKey, plainText: Uint8Array) { - let signAlg = 'RSA1024|PKCS1|SHA256'; - let signer = cryptoFramework.createSign(signAlg); - await signer.init(priKey); - let textSplitLen = 64; // 自定义的数据拆分长度,此处取64 - for (let i = 0; i < plainText.length; i += textSplitLen) { - let updateMessage = plainText.subarray(i, i + textSplitLen); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - await signer.update(updateMessageBlob); - } - // 已通过分段传入所有明文,故此处sign传入null - let signData = await signer.sign(null); - return signData; -} - -async function verifyMessagBySegment(pubKey: cryptoFramework.PubKey, plainText: Uint8Array, - signMessageBlob: cryptoFramework.DataBlob) { - let verifyAlg = 'RSA1024|PKCS1|SHA256'; - let verifier = cryptoFramework.createVerify(verifyAlg); - await verifier.init(pubKey); - let textSplitLen = 64; // 自定义的数据拆分长度,此处取64 - for (let i = 0; i < plainText.length; i += textSplitLen) { - let updateMessage = plainText.subarray(i, i + textSplitLen); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - await verifier.update(updateMessageBlob); - } - // 已通过分段传入所有明文,故此处verify第一个参数传入null - let res = await verifier.verify(null, signMessageBlob); - console.info('verify result is ' + res); - return res; -} - -async function rsaSignatureBySegment() { - let message = 'This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!'; - let keyGenAlg = 'RSA1024'; - let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); - let keyPair = await generator.generateKeyPair(); - let messageData = new Uint8Array(buffer.from(message, 'utf-8').buffer); - let signData = await signMessageBySegment(keyPair.priKey, messageData); - let verifyResult = await verifyMessagBySegment(keyPair.pubKey, messageData, signData); - if (verifyResult === true) { - console.info('verify success'); - } else { - console.error('verify failed'); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_signatureseg_asynchronous')) - .width('70%') - .onClick(async () => { - try { - await rsaSignatureBySegment(); - this.message = 'SignatureSegSuccess'; - } catch { - this.message = 'SignatureSegFail'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pkcs1_seg_verify_rsa_keypair_sign_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +async function signMessageBySegment(priKey: cryptoFramework.PriKey, plainText: Uint8Array) { + let signAlg = 'RSA1024|PKCS1|SHA256'; + let signer = cryptoFramework.createSign(signAlg); + await signer.init(priKey); + let textSplitLen = 64; // 自定义的数据拆分长度,此处取64 + for (let i = 0; i < plainText.length; i += textSplitLen) { + let updateMessage = plainText.subarray(i, i + textSplitLen); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + // 分段update + await signer.update(updateMessageBlob); + } + // 已通过分段传入所有明文,故此处sign传入null + let signData = await signer.sign(null); + return signData; +} + +async function verifyMessagBySegment(pubKey: cryptoFramework.PubKey, plainText: Uint8Array, + signMessageBlob: cryptoFramework.DataBlob) { + let verifyAlg = 'RSA1024|PKCS1|SHA256'; + let verifier = cryptoFramework.createVerify(verifyAlg); + await verifier.init(pubKey); + let textSplitLen = 64; // 自定义的数据拆分长度,此处取64 + for (let i = 0; i < plainText.length; i += textSplitLen) { + let updateMessage = plainText.subarray(i, i + textSplitLen); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + // 分段update + await verifier.update(updateMessageBlob); + } + // 已通过分段传入所有明文,故此处verify第一个参数传入null + let res = await verifier.verify(null, signMessageBlob); + console.info('verify result is ' + res); + return res; +} + +async function rsaSignatureBySegment() { + let message = 'This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!'; + let keyGenAlg = 'RSA1024'; + let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); + let keyPair = await generator.generateKeyPair(); + let messageData = new Uint8Array(buffer.from(message, 'utf-8').buffer); + let signData = await signMessageBySegment(keyPair.priKey, messageData); + let verifyResult = await verifyMessagBySegment(keyPair.pubKey, messageData, signData); + if (verifyResult === true) { + console.info('verify success'); + } else { + console.error('verify failed'); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_signatureseg_asynchronous')) + .width('70%') + .onClick(async () => { + try { + await rsaSignatureBySegment(); + this.message = 'SignatureSegSuccess'; + } catch { + this.message = 'SignatureSegFail'; + } + }) + } + .height('100%') + .width('100%') + } +} // [End pkcs1_seg_verify_rsa_keypair_sign_async] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_segment_signature/rsa_pkcs1_segment_signature_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_segment_signature/rsa_pkcs1_segment_signature_synchronous.ets old mode 100755 new mode 100644 index a25363ad66..ce88faa050 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_segment_signature/rsa_pkcs1_segment_signature_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_segment_signature/rsa_pkcs1_segment_signature_synchronous.ets @@ -1,99 +1,99 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pkcs1_seg_verify_rsa_keypair_sign_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -function signMessageBySegment(priKey: cryptoFramework.PriKey, plainText: Uint8Array) { - let signAlg = 'RSA1024|PKCS1|SHA256'; - let signer = cryptoFramework.createSign(signAlg); - signer.initSync(priKey); - let textSplitLen = 64; // 自定义的数据拆分长度,此处取64 - for (let i = 0; i < plainText.length; i += textSplitLen) { - let updateMessage = plainText.subarray(i, i + textSplitLen); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - signer.updateSync(updateMessageBlob); - } - // 已通过分段传入所有明文,故此处sign传入null - let signData = signer.signSync(null); - return signData; -} - -function verifyMessagBySegment(pubKey: cryptoFramework.PubKey, plainText: Uint8Array, - signMessageBlob: cryptoFramework.DataBlob) { - let verifyAlg = 'RSA1024|PKCS1|SHA256'; - let verifier = cryptoFramework.createVerify(verifyAlg); - verifier.initSync(pubKey); - let textSplitLen = 64; // 自定义的数据拆分长度,此处取64 - for (let i = 0; i < plainText.length; i += textSplitLen) { - let updateMessage = plainText.subarray(i, i + textSplitLen); - let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; - // 分段update - verifier.updateSync(updateMessageBlob); - } - // 已通过分段传入所有明文,故此处verify第一个参数传入null - let res = verifier.verifySync(null, signMessageBlob); - console.info('verify result is ' + res); - return res; -} - -function rsaSignatureBySegment() { - let message = 'This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + - 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!'; - let keyGenAlg = 'RSA1024'; - let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); - let keyPair = generator.generateKeyPairSync(); - let messageData = new Uint8Array(buffer.from(message, 'utf-8').buffer); - let signData = signMessageBySegment(keyPair.priKey, messageData); - let verifyResult = verifyMessagBySegment(keyPair.pubKey, messageData, signData); - if (verifyResult === true) { - console.info('verify success'); - } else { - console.error('verify failed'); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_signatureseg_synchronous')) - .width('70%') - .onClick(() => { - try { - rsaSignatureBySegment(); - this.message = 'SignatureSegSuccess'; - } catch { - this.message = 'SignatureSegFail'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pkcs1_seg_verify_rsa_keypair_sign_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +function signMessageBySegment(priKey: cryptoFramework.PriKey, plainText: Uint8Array) { + let signAlg = 'RSA1024|PKCS1|SHA256'; + let signer = cryptoFramework.createSign(signAlg); + signer.initSync(priKey); + let textSplitLen = 64; // 自定义的数据拆分长度,此处取64 + for (let i = 0; i < plainText.length; i += textSplitLen) { + let updateMessage = plainText.subarray(i, i + textSplitLen); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + // 分段update + signer.updateSync(updateMessageBlob); + } + // 已通过分段传入所有明文,故此处sign传入null + let signData = signer.signSync(null); + return signData; +} + +function verifyMessagBySegment(pubKey: cryptoFramework.PubKey, plainText: Uint8Array, + signMessageBlob: cryptoFramework.DataBlob) { + let verifyAlg = 'RSA1024|PKCS1|SHA256'; + let verifier = cryptoFramework.createVerify(verifyAlg); + verifier.initSync(pubKey); + let textSplitLen = 64; // 自定义的数据拆分长度,此处取64 + for (let i = 0; i < plainText.length; i += textSplitLen) { + let updateMessage = plainText.subarray(i, i + textSplitLen); + let updateMessageBlob: cryptoFramework.DataBlob = { data: updateMessage }; + // 分段update + verifier.updateSync(updateMessageBlob); + } + // 已通过分段传入所有明文,故此处verify第一个参数传入null + let res = verifier.verifySync(null, signMessageBlob); + console.info('verify result is ' + res); + return res; +} + +function rsaSignatureBySegment() { + let message = 'This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!' + + 'This is a long plainTest! This is a long plainTest! This is a long plainTest! This is a long plainTest!'; + let keyGenAlg = 'RSA1024'; + let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); + let keyPair = generator.generateKeyPairSync(); + let messageData = new Uint8Array(buffer.from(message, 'utf-8').buffer); + let signData = signMessageBySegment(keyPair.priKey, messageData); + let verifyResult = verifyMessagBySegment(keyPair.pubKey, messageData, signData); + if (verifyResult === true) { + console.info('verify success'); + } else { + console.error('verify failed'); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_signatureseg_synchronous')) + .width('70%') + .onClick(() => { + try { + rsaSignatureBySegment(); + this.message = 'SignatureSegSuccess'; + } catch { + this.message = 'SignatureSegFail'; + } + }) + } + .height('100%') + .width('100%') + } +} // [End pkcs1_seg_verify_rsa_keypair_sign_async] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_restoration/rsa_pkcs1_signature_restoration_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_restoration/rsa_pkcs1_signature_restoration_asynchronous.ets old mode 100755 new mode 100644 index dcff99411b..a7aa691f19 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_restoration/rsa_pkcs1_signature_restoration_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_restoration/rsa_pkcs1_signature_restoration_asynchronous.ets @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pkcs1_recover_rsa_keypair_sign_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 完整的明文被拆分为input1和input2 -let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; - -async function signMessagePromise(priKey: cryptoFramework.PriKey) { - let signAlg = 'RSA1024|PKCS1|NoHash|OnlySign'; - let signer = cryptoFramework.createSign(signAlg); - await signer.init(priKey); - let signData = await signer.sign(input1); - return signData; -} - -async function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { - let verifyAlg = 'RSA1024|PKCS1|NoHash|Recover'; - let verifier = cryptoFramework.createVerify(verifyAlg); - await verifier.init(pubKey); - let rawSignData = await verifier.recover(signMessageBlob); - return rawSignData; -} - -async function main() { - let keyGenAlg = 'RSA1024'; - let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); - let keyPair = await generator.generateKeyPair(); - let signData = await signMessagePromise(keyPair.priKey); - let rawSignData = await verifyMessagePromise(signData, keyPair.pubKey); - if (rawSignData != null) { - console.info('recover result: ' + rawSignData.data); - } else { - console.error('get verify recover result fail!'); - } -} -// [End pkcs1_recover_rsa_keypair_sign_async] - -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_signature_recover_asynchronous')) - .width('70%') - .onClick(async () => { - try { - await main(); - this.message = 'SignatureRecoverSuccess'; - } catch { - this.message = 'SignatureRecoverFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pkcs1_recover_rsa_keypair_sign_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 完整的明文被拆分为input1和input2 +let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; + +async function signMessagePromise(priKey: cryptoFramework.PriKey) { + let signAlg = 'RSA1024|PKCS1|NoHash|OnlySign'; + let signer = cryptoFramework.createSign(signAlg); + await signer.init(priKey); + let signData = await signer.sign(input1); + return signData; +} + +async function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { + let verifyAlg = 'RSA1024|PKCS1|NoHash|Recover'; + let verifier = cryptoFramework.createVerify(verifyAlg); + await verifier.init(pubKey); + let rawSignData = await verifier.recover(signMessageBlob); + return rawSignData; +} + +async function main() { + let keyGenAlg = 'RSA1024'; + let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); + let keyPair = await generator.generateKeyPair(); + let signData = await signMessagePromise(keyPair.priKey); + let rawSignData = await verifyMessagePromise(signData, keyPair.pubKey); + if (rawSignData != null) { + console.info('recover result: ' + rawSignData.data); + } else { + console.error('get verify recover result fail!'); + } +} +// [End pkcs1_recover_rsa_keypair_sign_async] + +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_signature_recover_asynchronous')) + .width('70%') + .onClick(async () => { + try { + await main(); + this.message = 'SignatureRecoverSuccess'; + } catch { + this.message = 'SignatureRecoverFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_restoration/rsa_pkcs1_signature_restoration_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_restoration/rsa_pkcs1_signature_restoration_synchronous.ets old mode 100755 new mode 100644 index c9d2c14cdf..67bf74dc98 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_restoration/rsa_pkcs1_signature_restoration_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_restoration/rsa_pkcs1_signature_restoration_synchronous.ets @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pkcs1_recover_rsa_keypair_sign_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 完整的明文被拆分为input1和input2 -let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; - -function signMessagePromise(priKey: cryptoFramework.PriKey) { - let signAlg = 'RSA1024|PKCS1|NoHash|OnlySign'; - let signer = cryptoFramework.createSign(signAlg); - signer.initSync(priKey); - let signData = signer.signSync(input1); - return signData; -} - -function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { - let verifyAlg = 'RSA1024|PKCS1|NoHash|Recover'; - let verifier = cryptoFramework.createVerify(verifyAlg); - verifier.initSync(pubKey); - let rawSignData = verifier.recoverSync(signMessageBlob); - return rawSignData; -} - -function main() { - let keyGenAlg = 'RSA1024'; - let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); - let keyPair = generator.generateKeyPairSync(); - let signData = signMessagePromise(keyPair.priKey); - let rawSignData = verifyMessagePromise(signData, keyPair.pubKey); - if (rawSignData != null) { - console.info('recover result: ' + rawSignData.data); - } else { - console.error('get verify recover result fail!'); - } -} -// [End pkcs1_recover_rsa_keypair_sign_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_signature_recover_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'SignatureRecoverSuccess'; - } catch { - this.message = 'SignatureRecoverFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pkcs1_recover_rsa_keypair_sign_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 完整的明文被拆分为input1和input2 +let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; + +function signMessagePromise(priKey: cryptoFramework.PriKey) { + let signAlg = 'RSA1024|PKCS1|NoHash|OnlySign'; + let signer = cryptoFramework.createSign(signAlg); + signer.initSync(priKey); + let signData = signer.signSync(input1); + return signData; +} + +function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { + let verifyAlg = 'RSA1024|PKCS1|NoHash|Recover'; + let verifier = cryptoFramework.createVerify(verifyAlg); + verifier.initSync(pubKey); + let rawSignData = verifier.recoverSync(signMessageBlob); + return rawSignData; +} + +function main() { + let keyGenAlg = 'RSA1024'; + let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); + let keyPair = generator.generateKeyPairSync(); + let signData = signMessagePromise(keyPair.priKey); + let rawSignData = verifyMessagePromise(signData, keyPair.pubKey); + if (rawSignData != null) { + console.info('recover result: ' + rawSignData.data); + } else { + console.error('get verify recover result fail!'); + } +} +// [End pkcs1_recover_rsa_keypair_sign_sync] + +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_signature_recover_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'SignatureRecoverSuccess'; + } catch { + this.message = 'SignatureRecoverFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_validator/rsa_pkcs1_signature_validator_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_validator/rsa_pkcs1_signature_validator_asynchronous.ets old mode 100755 new mode 100644 index 6bb1c04b21..5dacfc1341 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_validator/rsa_pkcs1_signature_validator_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_validator/rsa_pkcs1_signature_validator_asynchronous.ets @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pkcs1_verify_rsa_keypair_sign_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 完整的明文被拆分为input1和input2 -let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; -let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; - -async function signMessagePromise(priKey: cryptoFramework.PriKey) { - let signAlg = 'RSA1024|PKCS1|SHA256'; - let signer = cryptoFramework.createSign(signAlg); - await signer.init(priKey); - await signer.update(input1); // 如果明文较短,可以直接调用sign接口一次性传入 - let signData = await signer.sign(input2); - return signData; -} - -async function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { - let verifyAlg = 'RSA1024|PKCS1|SHA256'; - let verifier = cryptoFramework.createVerify(verifyAlg); - await verifier.init(pubKey); - await verifier.update(input1); // 如果明文较短,可以直接调用verify接口一次性传入 - let res = await verifier.verify(input2, signMessageBlob); - console.info('verify result is ' + res); - return res; -} - -async function main() { - let keyGenAlg = 'RSA1024'; - let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); - let keyPair = await generator.generateKeyPair(); - let signData = await signMessagePromise(keyPair.priKey); - let verifyResult = await verifyMessagePromise(signData, keyPair.pubKey); - if (verifyResult === true) { - console.info('verify success'); - } else { - console.error('verify failed'); - } -} -// [End pkcs1_verify_rsa_keypair_sign_async] - -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_signature_verify_asynchronous')) - .width('70%') - .onClick(async() => { - try { - await main(); - this.message = 'SignatureVerifySuccess'; - } catch { - this.message = 'SignatureVerifyFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pkcs1_verify_rsa_keypair_sign_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 完整的明文被拆分为input1和input2 +let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; +let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; + +async function signMessagePromise(priKey: cryptoFramework.PriKey) { + let signAlg = 'RSA1024|PKCS1|SHA256'; + let signer = cryptoFramework.createSign(signAlg); + await signer.init(priKey); + await signer.update(input1); // 如果明文较短,可以直接调用sign接口一次性传入 + let signData = await signer.sign(input2); + return signData; +} + +async function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { + let verifyAlg = 'RSA1024|PKCS1|SHA256'; + let verifier = cryptoFramework.createVerify(verifyAlg); + await verifier.init(pubKey); + await verifier.update(input1); // 如果明文较短,可以直接调用verify接口一次性传入 + let res = await verifier.verify(input2, signMessageBlob); + console.info('verify result is ' + res); + return res; +} + +async function main() { + let keyGenAlg = 'RSA1024'; + let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); + let keyPair = await generator.generateKeyPair(); + let signData = await signMessagePromise(keyPair.priKey); + let verifyResult = await verifyMessagePromise(signData, keyPair.pubKey); + if (verifyResult === true) { + console.info('verify success'); + } else { + console.error('verify failed'); + } +} +// [End pkcs1_verify_rsa_keypair_sign_async] + +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_signature_verify_asynchronous')) + .width('70%') + .onClick(async() => { + try { + await main(); + this.message = 'SignatureVerifySuccess'; + } catch { + this.message = 'SignatureVerifyFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_validator/rsa_pkcs1_signature_validator_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_validator/rsa_pkcs1_signature_validator_synchronous.ets old mode 100755 new mode 100644 index c4d36b1a62..6c0a7fd9b8 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_validator/rsa_pkcs1_signature_validator_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pkcs1_signature_validator/rsa_pkcs1_signature_validator_synchronous.ets @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start pkcs1_verify_rsa_keypair_sign_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 完整的明文被拆分为input1和input2 -let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; -let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; - -function signMessagePromise(priKey: cryptoFramework.PriKey) { - let signAlg = 'RSA1024|PKCS1|SHA256'; - let signer = cryptoFramework.createSign(signAlg); - signer.initSync(priKey); - signer.updateSync(input1); // 如果明文较短,可以直接调用sign接口一次性传入 - let signData = signer.signSync(input2); - return signData; -} - -function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { - let verifyAlg = 'RSA1024|PKCS1|SHA256'; - let verifier = cryptoFramework.createVerify(verifyAlg); - verifier.initSync(pubKey); - verifier.updateSync(input1); // 如果明文较短,可以直接调用verify接口一次性传入 - let res = verifier.verifySync(input2, signMessageBlob); - console.info('verify result is ' + res); - return res; -} - -function main() { - let keyGenAlg = 'RSA1024'; - let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); - let keyPair = generator.generateKeyPairSync(); - let signData = signMessagePromise(keyPair.priKey); - let verifyResult = verifyMessagePromise(signData, keyPair.pubKey); - if (verifyResult === true) { - console.info('verify success'); - } else { - console.error('verify failed'); - } -} -// [End pkcs1_verify_rsa_keypair_sign_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_signature_verify_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'SignatureVerifySuccess'; - } catch { - this.message = 'SignatureVerifyFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start pkcs1_verify_rsa_keypair_sign_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 完整的明文被拆分为input1和input2 +let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; +let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; + +function signMessagePromise(priKey: cryptoFramework.PriKey) { + let signAlg = 'RSA1024|PKCS1|SHA256'; + let signer = cryptoFramework.createSign(signAlg); + signer.initSync(priKey); + signer.updateSync(input1); // 如果明文较短,可以直接调用sign接口一次性传入 + let signData = signer.signSync(input2); + return signData; +} + +function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { + let verifyAlg = 'RSA1024|PKCS1|SHA256'; + let verifier = cryptoFramework.createVerify(verifyAlg); + verifier.initSync(pubKey); + verifier.updateSync(input1); // 如果明文较短,可以直接调用verify接口一次性传入 + let res = verifier.verifySync(input2, signMessageBlob); + console.info('verify result is ' + res); + return res; +} + +function main() { + let keyGenAlg = 'RSA1024'; + let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); + let keyPair = generator.generateKeyPairSync(); + let signData = signMessagePromise(keyPair.priKey); + let verifyResult = verifyMessagePromise(signData, keyPair.pubKey); + if (verifyResult === true) { + console.info('verify success'); + } else { + console.error('verify failed'); + } +} +// [End pkcs1_verify_rsa_keypair_sign_sync] + +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_signature_verify_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'SignatureVerifySuccess'; + } catch { + this.message = 'SignatureVerifyFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pss_signature_verification/rsa_pss_signature_verification_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pss_signature_verification/rsa_pss_signature_verification_asynchronous.ets old mode 100755 new mode 100644 index 3a57c49f4f..5e67a8f9b8 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pss_signature_verification/rsa_pss_signature_verification_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pss_signature_verification/rsa_pss_signature_verification_asynchronous.ets @@ -1,127 +1,127 @@ -/* - * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 根据密钥参数属性构造RSA非对称密钥对密钥参数 -function genRsaKeyPairSpec(nIn: bigint, eIn: bigint, dIn: bigint) { - let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { - n: nIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC - }; - let rsaKeyPairSpec: cryptoFramework.RSAKeyPairSpec = { - params: rsaCommSpec, - sk: dIn, - pk: eIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC - }; - return rsaKeyPairSpec; -} - -// 生成RSA2048密钥对参数 -function genRsa2048KeyPairSpec(): cryptoFramework.RSAKeyPairSpec { - let nIn = - BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc432' + - '8daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee34e4' + - 'd933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7afa7ac' + - '59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c0589c3e2' + - '53f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); - let eIn = BigInt('0x010001'); - let dIn = - BigInt('0x6a7df2ca63ead4dda191d614b6b385e0d9056a3d6d5cfe07db1daabee022db08212d97613d3328e0267c9dd23d787abde2afcb3' + - '06aeb7dfce69246cc73f5c87fdf06030179a2114b767db1f083ff841c025d7dc00cd82435b9a90f695369e94df23d2ce458bc3b3283ad8' + - 'bba2b8fa1ba62e2dce9accff3799aae7c840016f3ba8e0048c0b6cc4339af7161003a5beb864a0164b2c1c9237b64bc87556994351b275' + - '06c33d4bcdfce0f9c491a7d6b0628c7c852be4f0a9c3132b2ed3a2c8881e9aab07e20e17deb074691be677776a78b5c502e05d9bdde721' + - '26b3738695e2dd1a0a98a14247c65d8a7ee79432a092cb0721a12df798e44f7cfce0c498147a9b1'); - return genRsaKeyPairSpec(nIn, eIn, dIn); -} - -async function verifyMessagePSS() { - // 完整的明文被拆分为input1和input2 - let plan1 = 'This is Sign test plan1'; - let plan2 = 'This is Sign test plan2'; - let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan1, 'utf-8').buffer) }; - let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan2, 'utf-8').buffer) }; - // 获得RSA密钥对密钥参数对象 - let rsaKeyPairSpec = genRsa2048KeyPairSpec(); - // 构造RSA密钥对生成器 - let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaKeyPairSpec); - // sign和verfiy均支持RSA密钥带长度/不带长度的写法 - let signer = cryptoFramework.createSign('RSA|PSS|SHA256|MGF1_SHA256'); - let verifyer = cryptoFramework.createVerify('RSA2048|PSS|SHA256|MGF1_SHA256'); - let keyPair = await rsaGeneratorSpec.generateKeyPair(); - await signer.init(keyPair.priKey); - // 在签名初始化后,对PSS参数进行set和get操作 - let setN = 32; - signer.setSignSpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM, setN); - let saltLen = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM); - console.info('SaltLen == ' + saltLen); - let tf = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_TRAILER_FIELD_NUM); - console.info('trailer field == ' + tf); - let md = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MD_NAME_STR); - console.info('md == ' + md); - let mgf = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MGF_NAME_STR); - console.info('mgf == ' + mgf); - let mgf1Md = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MGF1_MD_STR); - console.info('mgf1Md == ' + mgf1Md); - await signer.update(input1); - let signMessageBlob = await signer.sign(input2); - // 在验签初始化前,对PSS参数进行set和get操作 - verifyer.setVerifySpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM, setN); - saltLen = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM); - console.info('SaltLen == ' + saltLen); - tf = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_TRAILER_FIELD_NUM); - console.info('trailer field == ' + tf); - md = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MD_NAME_STR); - console.info('md == ' + md); - mgf = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MGF_NAME_STR); - console.info('mgf == ' + mgf); - mgf1Md = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MGF1_MD_STR); - await verifyer.init(keyPair.pubKey); - await verifyer.update(input1); - let verifyResult = await verifyer.verify(input2, signMessageBlob); - if (verifyResult === true) { - console.info('verify success'); - } else { - console.error('verify failed'); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_psssignatureseg_asynchronous')) - .width('70%') - .onClick(async() => { - try { - await verifyMessagePSS(); - this.message = 'PSSSignatureSegSuccess'; - } catch { - this.message = 'PSSSignatureSegFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 根据密钥参数属性构造RSA非对称密钥对密钥参数 +function genRsaKeyPairSpec(nIn: bigint, eIn: bigint, dIn: bigint) { + let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { + n: nIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC + }; + let rsaKeyPairSpec: cryptoFramework.RSAKeyPairSpec = { + params: rsaCommSpec, + sk: dIn, + pk: eIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC + }; + return rsaKeyPairSpec; +} + +// 生成RSA2048密钥对参数 +function genRsa2048KeyPairSpec(): cryptoFramework.RSAKeyPairSpec { + let nIn = + BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc432' + + '8daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee34e4' + + 'd933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7afa7ac' + + '59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c0589c3e2' + + '53f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); + let eIn = BigInt('0x010001'); + let dIn = + BigInt('0x6a7df2ca63ead4dda191d614b6b385e0d9056a3d6d5cfe07db1daabee022db08212d97613d3328e0267c9dd23d787abde2afcb3' + + '06aeb7dfce69246cc73f5c87fdf06030179a2114b767db1f083ff841c025d7dc00cd82435b9a90f695369e94df23d2ce458bc3b3283ad8' + + 'bba2b8fa1ba62e2dce9accff3799aae7c840016f3ba8e0048c0b6cc4339af7161003a5beb864a0164b2c1c9237b64bc87556994351b275' + + '06c33d4bcdfce0f9c491a7d6b0628c7c852be4f0a9c3132b2ed3a2c8881e9aab07e20e17deb074691be677776a78b5c502e05d9bdde721' + + '26b3738695e2dd1a0a98a14247c65d8a7ee79432a092cb0721a12df798e44f7cfce0c498147a9b1'); + return genRsaKeyPairSpec(nIn, eIn, dIn); +} + +async function verifyMessagePSS() { + // 完整的明文被拆分为input1和input2 + let plan1 = 'This is Sign test plan1'; + let plan2 = 'This is Sign test plan2'; + let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan1, 'utf-8').buffer) }; + let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan2, 'utf-8').buffer) }; + // 获得RSA密钥对密钥参数对象 + let rsaKeyPairSpec = genRsa2048KeyPairSpec(); + // 构造RSA密钥对生成器 + let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaKeyPairSpec); + // sign和verfiy均支持RSA密钥带长度/不带长度的写法 + let signer = cryptoFramework.createSign('RSA|PSS|SHA256|MGF1_SHA256'); + let verifyer = cryptoFramework.createVerify('RSA2048|PSS|SHA256|MGF1_SHA256'); + let keyPair = await rsaGeneratorSpec.generateKeyPair(); + await signer.init(keyPair.priKey); + // 在签名初始化后,对PSS参数进行set和get操作 + let setN = 32; + signer.setSignSpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM, setN); + let saltLen = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM); + console.info('SaltLen == ' + saltLen); + let tf = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_TRAILER_FIELD_NUM); + console.info('trailer field == ' + tf); + let md = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MD_NAME_STR); + console.info('md == ' + md); + let mgf = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MGF_NAME_STR); + console.info('mgf == ' + mgf); + let mgf1Md = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MGF1_MD_STR); + console.info('mgf1Md == ' + mgf1Md); + await signer.update(input1); + let signMessageBlob = await signer.sign(input2); + // 在验签初始化前,对PSS参数进行set和get操作 + verifyer.setVerifySpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM, setN); + saltLen = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM); + console.info('SaltLen == ' + saltLen); + tf = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_TRAILER_FIELD_NUM); + console.info('trailer field == ' + tf); + md = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MD_NAME_STR); + console.info('md == ' + md); + mgf = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MGF_NAME_STR); + console.info('mgf == ' + mgf); + mgf1Md = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MGF1_MD_STR); + await verifyer.init(keyPair.pubKey); + await verifyer.update(input1); + let verifyResult = await verifyer.verify(input2, signMessageBlob); + if (verifyResult === true) { + console.info('verify success'); + } else { + console.error('verify failed'); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_psssignatureseg_asynchronous')) + .width('70%') + .onClick(async() => { + try { + await verifyMessagePSS(); + this.message = 'PSSSignatureSegSuccess'; + } catch { + this.message = 'PSSSignatureSegFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pss_signature_verification/rsa_pss_signature_verification_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pss_signature_verification/rsa_pss_signature_verification_synchronous.ets old mode 100755 new mode 100644 index f6656e9c4e..fd4f9257b3 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pss_signature_verification/rsa_pss_signature_verification_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/rsa_pss_signature_verification/rsa_pss_signature_verification_synchronous.ets @@ -1,127 +1,127 @@ -/* - * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 根据密钥参数属性构造RSA非对称密钥对密钥参数 -function genRsaKeyPairSpec(nIn: bigint, eIn: bigint, dIn: bigint) { - let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { - n: nIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC - }; - let rsaKeyPairSpec: cryptoFramework.RSAKeyPairSpec = { - params: rsaCommSpec, - sk: dIn, - pk: eIn, - algName: 'RSA', - specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC - }; - return rsaKeyPairSpec; -} - -// 生成RSA2048密钥对参数 -function genRsa2048KeyPairSpec(): cryptoFramework.RSAKeyPairSpec { - let nIn = - BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc43' + - '28daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee34' + - 'e4d933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7afa' + - '7ac59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c0589' + - 'c3e253f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); - let eIn = BigInt('0x010001'); - let dIn = - BigInt('0x6a7df2ca63ead4dda191d614b6b385e0d9056a3d6d5cfe07db1daabee022db08212d97613d3328e0267c9dd23d787abde2afcb' + - '306aeb7dfce69246cc73f5c87fdf06030179a2114b767db1f083ff841c025d7dc00cd82435b9a90f695369e94df23d2ce458bc3b3283a' + - 'd8bba2b8fa1ba62e2dce9accff3799aae7c840016f3ba8e0048c0b6cc4339af7161003a5beb864a0164b2c1c9237b64bc87556994351b' + - '27506c33d4bcdfce0f9c491a7d6b0628c7c852be4f0a9c3132b2ed3a2c8881e9aab07e20e17deb074691be677776a78b5c502e05d9bdd' + - 'e72126b3738695e2dd1a0a98a14247c65d8a7ee79432a092cb0721a12df798e44f7cfce0c498147a9b1'); - return genRsaKeyPairSpec(nIn, eIn, dIn); -} - -function verifyMessagePSS() { - // 完整的明文被拆分为input1和input2 - let plan1 = 'This is Sign test plan1'; - let plan2 = 'This is Sign test plan2'; - let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan1, 'utf-8').buffer) }; - let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan2, 'utf-8').buffer) }; - // 获得RSA密钥对密钥参数对象 - let rsaKeyPairSpec = genRsa2048KeyPairSpec(); - // 构造RSA密钥对生成器 - let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaKeyPairSpec); - // sign和verfiy均支持RSA密钥带长度/不带长度的写法 - let signer = cryptoFramework.createSign('RSA|PSS|SHA256|MGF1_SHA256'); - let verifyer = cryptoFramework.createVerify('RSA2048|PSS|SHA256|MGF1_SHA256'); - let keyPair = rsaGeneratorSpec.generateKeyPairSync(); - signer.initSync(keyPair.priKey); - // 在签名初始化后,对PSS参数进行set和get操作 - let setN = 32; - signer.setSignSpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM, setN); - let saltLen = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM); - console.info('SaltLen == ' + saltLen); - let tf = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_TRAILER_FIELD_NUM); - console.info('trailer field == ' + tf); - let md = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MD_NAME_STR); - console.info('md == ' + md); - let mgf = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MGF_NAME_STR); - console.info('mgf == ' + mgf); - let mgf1Md = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MGF1_MD_STR); - console.info('mgf1Md == ' + mgf1Md); - signer.updateSync(input1); - let signMessageBlob = signer.signSync(input2); - // 在验签初始化前,对PSS参数进行set和get操作 - verifyer.setVerifySpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM, setN); - saltLen = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM); - console.info('SaltLen == ' + saltLen); - tf = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_TRAILER_FIELD_NUM); - console.info('trailer field == ' + tf); - md = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MD_NAME_STR); - console.info('md == ' + md); - mgf = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MGF_NAME_STR); - console.info('mgf == ' + mgf); - mgf1Md = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MGF1_MD_STR); - verifyer.initSync(keyPair.pubKey); - verifyer.updateSync(input1); - let verifyResult = verifyer.verifySync(input2, signMessageBlob); - if (verifyResult === true) { - console.info('verify success'); - } else { - console.error('verify failed'); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_psssignatureseg_synchronous')) - .width('70%') - .onClick(() => { - try { - verifyMessagePSS(); - this.message = 'PSSSignatureSegSuccess'; - } catch { - this.message = 'PSSSignatureSegFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * 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 { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 根据密钥参数属性构造RSA非对称密钥对密钥参数 +function genRsaKeyPairSpec(nIn: bigint, eIn: bigint, dIn: bigint) { + let rsaCommSpec: cryptoFramework.RSACommonParamsSpec = { + n: nIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC + }; + let rsaKeyPairSpec: cryptoFramework.RSAKeyPairSpec = { + params: rsaCommSpec, + sk: dIn, + pk: eIn, + algName: 'RSA', + specType: cryptoFramework.AsyKeySpecType.KEY_PAIR_SPEC + }; + return rsaKeyPairSpec; +} + +// 生成RSA2048密钥对参数 +function genRsa2048KeyPairSpec(): cryptoFramework.RSAKeyPairSpec { + let nIn = + BigInt('0x9260d0750ae117eee55c3f3deaba74917521a262ee76007cdf8a56755ad73a1598a1408410a01434c3f5bc54a88b57fa19fc43' + + '28daea0750a4c44e88cff3b2382621b80f670464433e4336e6d003e8cd65bff211da144b88291c2259a00a72b711c116ef7686e8fee34' + + 'e4d933c868187bdc26f7be071493c86f7a5941c3510806ad67b0f94d88f5cf5c02a092821d8626e8932b65c5bd8c92049c210932b7afa' + + '7ac59c0e886ae5c1edb00d8ce2c57633db26bd6639bff73cee82be9275c402b4cf2a4388da8cf8c64eefe1c5a0f5ab8057c39fa5c0589' + + 'c3e253f0960332300f94bea44877b588e1edbde97cf2360727a09b775262d7ee552b3319b9266f05a25'); + let eIn = BigInt('0x010001'); + let dIn = + BigInt('0x6a7df2ca63ead4dda191d614b6b385e0d9056a3d6d5cfe07db1daabee022db08212d97613d3328e0267c9dd23d787abde2afcb' + + '306aeb7dfce69246cc73f5c87fdf06030179a2114b767db1f083ff841c025d7dc00cd82435b9a90f695369e94df23d2ce458bc3b3283a' + + 'd8bba2b8fa1ba62e2dce9accff3799aae7c840016f3ba8e0048c0b6cc4339af7161003a5beb864a0164b2c1c9237b64bc87556994351b' + + '27506c33d4bcdfce0f9c491a7d6b0628c7c852be4f0a9c3132b2ed3a2c8881e9aab07e20e17deb074691be677776a78b5c502e05d9bdd' + + 'e72126b3738695e2dd1a0a98a14247c65d8a7ee79432a092cb0721a12df798e44f7cfce0c498147a9b1'); + return genRsaKeyPairSpec(nIn, eIn, dIn); +} + +function verifyMessagePSS() { + // 完整的明文被拆分为input1和input2 + let plan1 = 'This is Sign test plan1'; + let plan2 = 'This is Sign test plan2'; + let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan1, 'utf-8').buffer) }; + let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(plan2, 'utf-8').buffer) }; + // 获得RSA密钥对密钥参数对象 + let rsaKeyPairSpec = genRsa2048KeyPairSpec(); + // 构造RSA密钥对生成器 + let rsaGeneratorSpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaKeyPairSpec); + // sign和verfiy均支持RSA密钥带长度/不带长度的写法 + let signer = cryptoFramework.createSign('RSA|PSS|SHA256|MGF1_SHA256'); + let verifyer = cryptoFramework.createVerify('RSA2048|PSS|SHA256|MGF1_SHA256'); + let keyPair = rsaGeneratorSpec.generateKeyPairSync(); + signer.initSync(keyPair.priKey); + // 在签名初始化后,对PSS参数进行set和get操作 + let setN = 32; + signer.setSignSpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM, setN); + let saltLen = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM); + console.info('SaltLen == ' + saltLen); + let tf = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_TRAILER_FIELD_NUM); + console.info('trailer field == ' + tf); + let md = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MD_NAME_STR); + console.info('md == ' + md); + let mgf = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MGF_NAME_STR); + console.info('mgf == ' + mgf); + let mgf1Md = signer.getSignSpec(cryptoFramework.SignSpecItem.PSS_MGF1_MD_STR); + console.info('mgf1Md == ' + mgf1Md); + signer.updateSync(input1); + let signMessageBlob = signer.signSync(input2); + // 在验签初始化前,对PSS参数进行set和get操作 + verifyer.setVerifySpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM, setN); + saltLen = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_SALT_LEN_NUM); + console.info('SaltLen == ' + saltLen); + tf = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_TRAILER_FIELD_NUM); + console.info('trailer field == ' + tf); + md = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MD_NAME_STR); + console.info('md == ' + md); + mgf = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MGF_NAME_STR); + console.info('mgf == ' + mgf); + mgf1Md = verifyer.getVerifySpec(cryptoFramework.SignSpecItem.PSS_MGF1_MD_STR); + verifyer.initSync(keyPair.pubKey); + verifyer.updateSync(input1); + let verifyResult = verifyer.verifySync(input2, signMessageBlob); + if (verifyResult === true) { + console.info('verify success'); + } else { + console.error('verify failed'); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_psssignatureseg_synchronous')) + .width('70%') + .onClick(() => { + try { + verifyMessagePSS(); + this.message = 'PSSSignatureSegSuccess'; + } catch { + this.message = 'PSSSignatureSegFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_asynchronous.ets old mode 100755 new mode 100644 index 5f612bc7e6..ff0539c310 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_asynchronous.ets @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start use_the_sm2_key_pair_to_sign_and_verify_async] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 完整的明文被拆分为input1和input2 -let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; -let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; - -async function signMessagePromise(priKey: cryptoFramework.PriKey) { - let signAlg = 'SM2_256|SM3'; - let signer = cryptoFramework.createSign(signAlg); - await signer.init(priKey); - await signer.update(input1); // 如果明文较短,可以直接调用sign接口一次性传入 - let signData = await signer.sign(input2); - return signData; -} - -async function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { - let verifyAlg = 'SM2_256|SM3'; - let verifier = cryptoFramework.createVerify(verifyAlg); - await verifier.init(pubKey); - await verifier.update(input1); // 如果明文较短,可以直接调用verify接口一次性传入 - let res = await verifier.verify(input2, signMessageBlob); - console.info('verify result is ' + res); - return res; -} - -async function main() { - let keyGenAlg = 'SM2_256'; - let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); - let keyPair = await generator.generateKeyPair(); - let signData = await signMessagePromise(keyPair.priKey); - let verifyResult = await verifyMessagePromise(signData, keyPair.pubKey); - if (verifyResult === true) { - console.info('verify success'); - } else { - console.error('verify failed'); - } -} - - -// [End use_the_sm2_key_pair_to_sign_and_verify_async] -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm2_signature_asynchronous')) - .width('70%') - .onClick(async() => { - try { - await main(); - this.message = 'SM2SignatureSuccess'; - } catch { - this.message = 'SM2SignatureFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start use_the_sm2_key_pair_to_sign_and_verify_async] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 完整的明文被拆分为input1和input2 +let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; +let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; + +async function signMessagePromise(priKey: cryptoFramework.PriKey) { + let signAlg = 'SM2_256|SM3'; + let signer = cryptoFramework.createSign(signAlg); + await signer.init(priKey); + await signer.update(input1); // 如果明文较短,可以直接调用sign接口一次性传入 + let signData = await signer.sign(input2); + return signData; +} + +async function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { + let verifyAlg = 'SM2_256|SM3'; + let verifier = cryptoFramework.createVerify(verifyAlg); + await verifier.init(pubKey); + await verifier.update(input1); // 如果明文较短,可以直接调用verify接口一次性传入 + let res = await verifier.verify(input2, signMessageBlob); + console.info('verify result is ' + res); + return res; +} + +async function main() { + let keyGenAlg = 'SM2_256'; + let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); + let keyPair = await generator.generateKeyPair(); + let signData = await signMessagePromise(keyPair.priKey); + let verifyResult = await verifyMessagePromise(signData, keyPair.pubKey); + if (verifyResult === true) { + console.info('verify success'); + } else { + console.error('verify failed'); + } +} + + +// [End use_the_sm2_key_pair_to_sign_and_verify_async] +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm2_signature_asynchronous')) + .width('70%') + .onClick(async() => { + try { + await main(); + this.message = 'SM2SignatureSuccess'; + } catch { + this.message = 'SM2SignatureFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_synchronous.ets old mode 100755 new mode 100644 index 3957b3ac72..425e384e5c --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_synchronous.ets @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start use_the_sm2_key_pair_to_sign_and_verify_sync] -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { buffer } from '@kit.ArkTS'; - -// 完整的明文被拆分为input1和input2 -let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; -let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; - -function signMessagePromise(priKey: cryptoFramework.PriKey) { - let signAlg = 'SM2_256|SM3'; - let signer = cryptoFramework.createSign(signAlg); - signer.initSync(priKey); - signer.updateSync(input1); // 如果明文较短,可以直接调用sign接口一次性传入 - let signData = signer.signSync(input2); - return signData; -} - -function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { - let verifyAlg = 'SM2_256|SM3'; - let verifier = cryptoFramework.createVerify(verifyAlg); - verifier.initSync(pubKey); - verifier.updateSync(input1); // 如果明文较短,可以直接调用verify接口一次性传入 - let res = verifier.verifySync(input2, signMessageBlob); - console.info('verify result is ' + res); - return res; -} - -function main() { - let keyGenAlg = 'SM2_256'; - let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); - let keyPair = generator.generateKeyPairSync(); - let signData = signMessagePromise(keyPair.priKey); - let verifyResult = verifyMessagePromise(signData, keyPair.pubKey); - if (verifyResult === true) { - console.info('verify success'); - } else { - console.error('verify failed'); - } -} - -// [End use_the_sm2_key_pair_to_sign_and_verify_sync] - -@Entry -@Component -struct Index { - @State message: string = 'Signing Signature Verification'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) - Button($r('app.string.call_sm2_signature_synchronous')) - .width('70%') - .onClick(() => { - try { - main(); - this.message = 'SM2SignatureSuccess'; - } catch { - this.message = 'SM2SignatureFail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start use_the_sm2_key_pair_to_sign_and_verify_sync] +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { buffer } from '@kit.ArkTS'; + +// 完整的明文被拆分为input1和input2 +let input1: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan1', 'utf-8').buffer) }; +let input2: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from('This is Sign test plan2', 'utf-8').buffer) }; + +function signMessagePromise(priKey: cryptoFramework.PriKey) { + let signAlg = 'SM2_256|SM3'; + let signer = cryptoFramework.createSign(signAlg); + signer.initSync(priKey); + signer.updateSync(input1); // 如果明文较短,可以直接调用sign接口一次性传入 + let signData = signer.signSync(input2); + return signData; +} + +function verifyMessagePromise(signMessageBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey) { + let verifyAlg = 'SM2_256|SM3'; + let verifier = cryptoFramework.createVerify(verifyAlg); + verifier.initSync(pubKey); + verifier.updateSync(input1); // 如果明文较短,可以直接调用verify接口一次性传入 + let res = verifier.verifySync(input2, signMessageBlob); + console.info('verify result is ' + res); + return res; +} + +function main() { + let keyGenAlg = 'SM2_256'; + let generator = cryptoFramework.createAsyKeyGenerator(keyGenAlg); + let keyPair = generator.generateKeyPairSync(); + let signData = signMessagePromise(keyPair.priKey); + let verifyResult = verifyMessagePromise(signData, keyPair.pubKey); + if (verifyResult === true) { + console.info('verify success'); + } else { + console.error('verify failed'); + } +} + +// [End use_the_sm2_key_pair_to_sign_and_verify_sync] + +@Entry +@Component +struct Index { + @State message: string = 'Signing Signature Verification'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(25).fontWeight(FontWeight.Bold) + Button($r('app.string.call_sm2_signature_synchronous')) + .width('70%') + .onClick(() => { + try { + main(); + this.message = 'SM2SignatureSuccess'; + } catch { + this.message = 'SM2SignatureFail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/mock/mock-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/mock/mock-config.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/SigningSignatureVerificationArkTs.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/SigningSignatureVerificationArkTs.test.ets old mode 100755 new mode 100644 index 62f8fd0ec5..13f32fba0a --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/SigningSignatureVerificationArkTs.test.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/ets/test/SigningSignatureVerificationArkTs.test.ets @@ -1,259 +1,259 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function signingSignatureVerificationArkTsTest() { - describe('signingSignatureVerificationArkTsTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,使用RSA密钥对(PKCS1模式)签名验签(异步) - */ - it('signingSignatureVerificationArkTsTest001', 0, async () => { - console.info('uitest: signingSignatureVerificationArkTsTest001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('rsa_pkcs1_signature_validator_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SignatureVerify Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SignatureVerifySuccess')); - console.info('uitest: signingSignatureVerificationArkTsTest001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA密钥对(PKCS1模式)签名验签(同步) - */ - it('testSigningSignatureVerificationArkTsTest002', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('rsa_pkcs1_signature_validator_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SignatureVerify Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SignatureVerifySuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA密钥对(PKCS1模式)签名及签名恢复(异步) - */ - it('testSigningSignatureVerificationArkTsTest003', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('rsa_pkcs1_signature_restoration_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SignatureRecover Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SignatureRecoverSuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA密钥对(PKCS1模式)签名及签名恢复(同步) - */ - it('testSigningSignatureVerificationArkTsTest004', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('rsa_pkcs1_signature_restoration_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SignatureRecover Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SignatureRecoverSuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest004 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA密钥对分段签名验签(PKCS1模式)(异步) - */ - it('testSigningSignatureVerificationArkTsTest005', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('rsa_pkcs1_segment_signature_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SignatureSeg Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SignatureSegSuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest005 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA密钥对分段签名验签(PKCS1模式)(同步) - */ - it('testSigningSignatureVerificationArkTsTest006', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest006 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('rsa_pkcs1_segment_signature_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SignatureSeg Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SignatureSegSuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest006 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA密钥对签名验签(PSS模式)(异步) - */ - it('testSigningSignatureVerificationArkTsTest007', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest007 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('rsa_pss_signature_verification_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call PSSSignatureSeg Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('PSSSignatureSegSuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest007 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用RSA密钥对签名验签(PSS模式)(同步) - */ - it('testSigningSignatureVerificationArkTsTest008', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest008 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('rsa_pss_signature_verification_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call PSSSignatureSeg Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('PSSSignatureSegSuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest008 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用ECDSA密钥对签名验签(异步) - */ - it('testSigningSignatureVerificationArkTsTest009', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest009 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('ecdsa_signature_verification_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call ECDSASignature Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ECDSASignatureSuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest009 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用ECDSA密钥对签名验签(同步) - */ - it('testSigningSignatureVerificationArkTsTest010', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest010 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('ecdsa_signature_verification_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call ECDSASignature Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ECDSASignatureSuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest010 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM2密钥对签名验签(异步) - */ - it('testSigningSignatureVerificationArkTsTest011', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest011 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('sm2_signature_verification_asynchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2Signature Asynchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2SignatureSuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest011 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,使用SM2密钥对签名验签(同步) - */ - it('testSigningSignatureVerificationArkTsTest012', 0, async () => { - console.info('uitest: testSigningSignatureVerificationArkTsTest012 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('sm2_signature_verification_synchronous')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2Signature Synchronous')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2SignatureSuccess')); - console.info('uitest: testSigningSignatureVerificationArkTsTest012 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function signingSignatureVerificationArkTsTest() { + describe('signingSignatureVerificationArkTsTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,使用RSA密钥对(PKCS1模式)签名验签(异步) + */ + it('signingSignatureVerificationArkTsTest001', 0, async () => { + console.info('uitest: signingSignatureVerificationArkTsTest001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('rsa_pkcs1_signature_validator_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SignatureVerify Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SignatureVerifySuccess')); + console.info('uitest: signingSignatureVerificationArkTsTest001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA密钥对(PKCS1模式)签名验签(同步) + */ + it('testSigningSignatureVerificationArkTsTest002', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('rsa_pkcs1_signature_validator_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SignatureVerify Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SignatureVerifySuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA密钥对(PKCS1模式)签名及签名恢复(异步) + */ + it('testSigningSignatureVerificationArkTsTest003', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('rsa_pkcs1_signature_restoration_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SignatureRecover Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SignatureRecoverSuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA密钥对(PKCS1模式)签名及签名恢复(同步) + */ + it('testSigningSignatureVerificationArkTsTest004', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('rsa_pkcs1_signature_restoration_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SignatureRecover Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SignatureRecoverSuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest004 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA密钥对分段签名验签(PKCS1模式)(异步) + */ + it('testSigningSignatureVerificationArkTsTest005', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('rsa_pkcs1_segment_signature_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SignatureSeg Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SignatureSegSuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest005 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA密钥对分段签名验签(PKCS1模式)(同步) + */ + it('testSigningSignatureVerificationArkTsTest006', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest006 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('rsa_pkcs1_segment_signature_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SignatureSeg Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SignatureSegSuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest006 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA密钥对签名验签(PSS模式)(异步) + */ + it('testSigningSignatureVerificationArkTsTest007', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest007 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('rsa_pss_signature_verification_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call PSSSignatureSeg Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('PSSSignatureSegSuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest007 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用RSA密钥对签名验签(PSS模式)(同步) + */ + it('testSigningSignatureVerificationArkTsTest008', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest008 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('rsa_pss_signature_verification_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call PSSSignatureSeg Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('PSSSignatureSegSuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest008 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用ECDSA密钥对签名验签(异步) + */ + it('testSigningSignatureVerificationArkTsTest009', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest009 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('ecdsa_signature_verification_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call ECDSASignature Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ECDSASignatureSuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest009 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用ECDSA密钥对签名验签(同步) + */ + it('testSigningSignatureVerificationArkTsTest010', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest010 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('ecdsa_signature_verification_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call ECDSASignature Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ECDSASignatureSuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest010 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM2密钥对签名验签(异步) + */ + it('testSigningSignatureVerificationArkTsTest011', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest011 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('sm2_signature_verification_asynchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2Signature Asynchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2SignatureSuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest011 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,使用SM2密钥对签名验签(同步) + */ + it('testSigningSignatureVerificationArkTsTest012', 0, async () => { + console.info('uitest: testSigningSignatureVerificationArkTsTest012 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('sm2_signature_verification_synchronous')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2Signature Synchronous')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2SignatureSuccess')); + console.info('uitest: testSigningSignatureVerificationArkTsTest012 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/test/List.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/hvigor/hvigor-config.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/hvigorfile.ts b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/oh-package.json5 b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/oh-package.json5 +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/ohosTest.md b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/ohosTest.md old mode 100755 new mode 100644 index 63f32b67e5..6ae3b3fcca --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/ohosTest.md +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/ohosTest.md @@ -1,19 +1,19 @@ -# 签名验签(ArkTS)测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,使用RSA密钥对(PKCS1模式)签名验签(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA密钥对(PKCS1模式)签名验签(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA密钥对(PKCS1模式)签名及签名恢复(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA密钥对(PKCS1模式)签名及签名恢复(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA密钥对分段签名验签(PKCS1模式)(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA密钥对分段签名验签(PKCS1模式)(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA密钥对签名验签(PSS模式)(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用RSA密钥对签名验签(PSS模式)(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用ECDSA密钥对签名验签(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用ECDSA密钥对签名验签(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,使用SM2密钥对签名验签(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 签名验签(ArkTS)测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,使用RSA密钥对(PKCS1模式)签名验签(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA密钥对(PKCS1模式)签名验签(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA密钥对(PKCS1模式)签名及签名恢复(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA密钥对(PKCS1模式)签名及签名恢复(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA密钥对分段签名验签(PKCS1模式)(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA密钥对分段签名验签(PKCS1模式)(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA密钥对签名验签(PSS模式)(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用RSA密钥对签名验签(PSS模式)(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用ECDSA密钥对签名验签(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用ECDSA密钥对签名验签(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,使用SM2密钥对签名验签(异步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,使用SM2密钥对签名验签(同步) | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/screenshots/SigningSignatureVerificationArkTs1.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/screenshots/SigningSignatureVerificationArkTs1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/screenshots/SigningSignatureVerificationArkTs2.png b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/screenshots/SigningSignatureVerificationArkTs2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/.gitignore b/code/DocsSample/Security/DataProtectionKit/DataProtection/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/app.json5 b/code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/app.json5 old mode 100755 new mode 100644 index eac5feed4e..2b91e37f42 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/app.json5 +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/app.json5 @@ -1,25 +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.dataprotection", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.dataprotection", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/resources/base/element/string.json b/code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index a374075e47..ab466414a7 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "DataProtection" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "DataProtection" + } + ] +} diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/DataProtectionKit/DataProtection/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/README.md b/code/DocsSample/Security/DataProtectionKit/DataProtection/README.md old mode 100755 new mode 100644 index 054fb72487..604f191cb2 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/README.md +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/README.md @@ -1,73 +1,73 @@ -# 数据防泄漏服务开发指导 - -### 介绍 - -DLP是系统提供的系统级的数据防泄漏解决方案,提供一种称为DLP的文件格式。后缀格式为“原始文件名(包含原始文件后缀).dlp”,例如“test.docx.dlp”,文件由授权凭证和原始文件密文组成。 - -应用需要访问DLP文件时,系统会自动安装应用的DLP沙箱分身应用,相当于完全独立的应用,数据和配置会继承原应用,但相互之间并不共享。分身应用在运行时会处于DLP沙箱环境中,访问外部的权限会被限制,以防止数据的泄漏。每当打开一个新的DLP文件会生成一个应用沙箱分身,沙箱应用之间也是相互隔离的,当应用关闭后应用分身会自动卸载,沙箱期间产生的临时数据也会丢弃。 - -正常情况下,应用不会感知到沙箱的存在,访问的也是解密后的明文,和访问普通文件没有区别,但由于DLP沙箱会限制其访问外部的权限(例如网络、剪切板、截屏、录屏、蓝牙等)。为了更好的用户体验,需要应用进行适配,例如文件只读的情况下,不应显示“保存”按钮,不应主动联网等。 - -本示例主要展示了数据防泄漏服务开发指导,该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [数据防泄漏服务开发指导](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DataProtectionKit/dlp-guidelines.md) - -### 效果预览 - -| 首页效果图 | -| ------------------------------------------------------------ | -| | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,并且具有说明账号未登录,请登录账号后重试的弹窗。 -3. 运行测试用例DataProtection.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 数据防泄漏服务开发指导示例代码 - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── DataProtection.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API16版本SDK,版本号:5.0.4.150,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.4 Release (Build Version: 5.0.11.100, built on March 28, 2025)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/DataProtectionKit/DataProtection > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -```` +# 数据防泄漏服务开发指导 + +### 介绍 + +DLP是系统提供的系统级的数据防泄漏解决方案,提供一种称为DLP的文件格式。后缀格式为“原始文件名(包含原始文件后缀).dlp”,例如“test.docx.dlp”,文件由授权凭证和原始文件密文组成。 + +应用需要访问DLP文件时,系统会自动安装应用的DLP沙箱分身应用,相当于完全独立的应用,数据和配置会继承原应用,但相互之间并不共享。分身应用在运行时会处于DLP沙箱环境中,访问外部的权限会被限制,以防止数据的泄漏。每当打开一个新的DLP文件会生成一个应用沙箱分身,沙箱应用之间也是相互隔离的,当应用关闭后应用分身会自动卸载,沙箱期间产生的临时数据也会丢弃。 + +正常情况下,应用不会感知到沙箱的存在,访问的也是解密后的明文,和访问普通文件没有区别,但由于DLP沙箱会限制其访问外部的权限(例如网络、剪切板、截屏、录屏、蓝牙等)。为了更好的用户体验,需要应用进行适配,例如文件只读的情况下,不应显示“保存”按钮,不应主动联网等。 + +本示例主要展示了数据防泄漏服务开发指导,该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [数据防泄漏服务开发指导](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DataProtectionKit/dlp-guidelines.md) + +### 效果预览 + +| 首页效果图 | +| ------------------------------------------------------------ | +| | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,并且具有说明账号未登录,请登录账号后重试的弹窗。 +3. 运行测试用例DataProtection.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 数据防泄漏服务开发指导示例代码 + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── DataProtection.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API16版本SDK,版本号:5.0.4.150,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.4 Release (Build Version: 5.0.11.100, built on March 28, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/DataProtectionKit/DataProtection > .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/Security/DataProtectionKit/DataProtection/build-profile.json5 b/code/DocsSample/Security/DataProtectionKit/DataProtection/build-profile.json5 old mode 100755 new mode 100644 index 9296ac9136..5df1ab5a7f --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/build-profile.json5 +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 16, - "compatibleSdkVersion": 16, - "targetSdkVersion": 16, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 16, + "compatibleSdkVersion": 16, + "targetSdkVersion": 16, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/code-linter.json5 b/code/DocsSample/Security/DataProtectionKit/DataProtection/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/.gitignore b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/build-profile.json5 b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/build-profile.json5 +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/hvigorfile.ts b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/oh-package.json5 b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/oh-package.json5 +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/DataProtectionKit/DataProtection/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/DataProtectionKit/DataProtection/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/module.json5 b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/module.json5 old mode 100755 new mode 100644 index 0dd84338e8..3d70d21568 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/module.json5 +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/module.json5 @@ -1,67 +1,67 @@ -/* - * 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", - "ohos.want.action.viewData" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "EntryBackupAbility", - "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", - "type": "backup", - "exported": false, - "metadata": [ - { - "name": "ohos.extension.backup", - "resource": "$profile:backup_config" - } - ] - } - ] - } +/* + * 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", + "ohos.want.action.viewData" + ] + } + ] + } + ], + "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/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/DataProtection.test.ets b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/DataProtection.test.ets old mode 100755 new mode 100644 index 5c631dc9e2..b0b578bb9c --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/DataProtection.test.ets +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/DataProtection.test.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} - -export default function dataProtectionTest() { - describe('dataProtectionTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮关闭弹窗 - */ - it('testDataProtection001', 0, async () => { - console.info('uitest: testDataProtection001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text(resourceToString($r('app.string.button_name')))); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('DataProtection')); - console.info('uitest: testDataProtection001 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} + +export default function dataProtectionTest() { + describe('dataProtectionTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮关闭弹窗 + */ + it('testDataProtection001', 0, async () => { + console.info('uitest: testDataProtection001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text(resourceToString($r('app.string.button_name')))); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('DataProtection')); + console.info('uitest: testDataProtection001 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/test/List.test.ets b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/hvigor/hvigor-config.json5 b/code/DocsSample/Security/DataProtectionKit/DataProtection/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/DataProtectionKit/DataProtection/hvigorfile.ts b/code/DocsSample/Security/DataProtectionKit/DataProtection/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/oh-package.json5 b/code/DocsSample/Security/DataProtectionKit/DataProtection/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/oh-package.json5 +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/ohosTest.md b/code/DocsSample/Security/DataProtectionKit/DataProtection/ohosTest.md old mode 100755 new mode 100644 index 214332ec23..e34db9d8f9 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/ohosTest.md +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/ohosTest.md @@ -1,8 +1,8 @@ -# 数据防泄漏服务开发指导测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------ | ------------ | ---- | ------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +# 数据防泄漏服务开发指导测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------ | ------------ | ---- | ------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | | 页面正确显示 | 成功拉起应用 | | 页面成功弹窗 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/screenshots/DataProtection.png b/code/DocsSample/Security/DataProtectionKit/DataProtection/screenshots/DataProtection.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/.gitignore b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/app.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/app.json5 old mode 100755 new mode 100644 index 68bab6dbc2..801e86b738 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/app.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/app.json5 @@ -1,25 +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.certificatealgorithmlibrary", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.certificatealgorithmlibrary", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/resources/base/element/string.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 000f0d375b..ad134223d3 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "CertificateAlgorithmLibrary" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "CertificateAlgorithmLibrary" + } + ] +} diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/README.md b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/README.md old mode 100755 new mode 100644 index 62e61b7e33..c246f8945f --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/README.md +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/README.md @@ -1,82 +1,82 @@ -# 证书算法库 - -### 介绍 - -证书算法库框架是一个屏蔽了第三方算法库实现差异的证书算法框架,向应用提供证书、证书扩展域段、证书吊销列表的创建、解析及校验能力,此外还提供了证书链的校验能力。 - -本示例主要展示了证书算法库中证书对象的创建、证书扩展信息对象的创建、证书吊销列表对象的创建、证书链校验时从p12文件构造TrustAnchor对象数组、证书链校验器对象的创建和校验、证书集合及证书吊销列表集合对象的创建和获取、证书链对象的创建和校验的场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 - -- [证书对象的创建、解析和校验](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-parse-verify-cert-object.md) -- [证书扩展信息对象的创建、解析和校验](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-parse-verify-certextension-object.md) -- [证书吊销列表对象的创建、解析和校验](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-parse-verify-crl-object.md) -- [证书链校验时从p12文件构造TrustAnchor对象数组](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-trustanchor-from-p12.md) -- [证书链校验器对象的创建和校验](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-verify-cerchainvalidator-object.md) -- [证书集合及证书吊销列表集合对象的创建和获取](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-get-cert-crl-object.md) -- [证书链对象的创建和校验](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-verify-certchain-object.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例CertificateAlgorithmLibrary.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 证书算法库示例代码 - │ │ ├── CreateGetCertCrlObject.ets - │ │ ├── CreateParseVerifyCertextensionObject.ets - │ │ ├── CreateParseVerifyCertObject.ets - │ │ ├── CreateParseVerifyCrlObject.ets - │ │ ├── CreateTrustanchorFromP12.ets - │ │ ├── CreateVerifyCerchainvalidatorObject.ets - │ │ ├── CreateVerifyCertchainObject.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── CertificateAlgorithmLibrary.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 证书算法库 + +### 介绍 + +证书算法库框架是一个屏蔽了第三方算法库实现差异的证书算法框架,向应用提供证书、证书扩展域段、证书吊销列表的创建、解析及校验能力,此外还提供了证书链的校验能力。 + +本示例主要展示了证书算法库中证书对象的创建、证书扩展信息对象的创建、证书吊销列表对象的创建、证书链校验时从p12文件构造TrustAnchor对象数组、证书链校验器对象的创建和校验、证书集合及证书吊销列表集合对象的创建和获取、证书链对象的创建和校验的场景。该工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。 + +- [证书对象的创建、解析和校验](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-parse-verify-cert-object.md) +- [证书扩展信息对象的创建、解析和校验](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-parse-verify-certextension-object.md) +- [证书吊销列表对象的创建、解析和校验](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-parse-verify-crl-object.md) +- [证书链校验时从p12文件构造TrustAnchor对象数组](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-trustanchor-from-p12.md) +- [证书链校验器对象的创建和校验](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-verify-cerchainvalidator-object.md) +- [证书集合及证书吊销列表集合对象的创建和获取](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-get-cert-crl-object.md) +- [证书链对象的创建和校验](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/create-verify-certchain-object.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例CertificateAlgorithmLibrary.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 证书算法库示例代码 + │ │ ├── CreateGetCertCrlObject.ets + │ │ ├── CreateParseVerifyCertextensionObject.ets + │ │ ├── CreateParseVerifyCertObject.ets + │ │ ├── CreateParseVerifyCrlObject.ets + │ │ ├── CreateTrustanchorFromP12.ets + │ │ ├── CreateVerifyCerchainvalidatorObject.ets + │ │ ├── CreateVerifyCertchainObject.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── CertificateAlgorithmLibrary.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary > .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/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/build-profile.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/build-profile.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/code-linter.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/.gitignore b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/build-profile.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/build-profile.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/hvigorfile.ts b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/oh-package.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/oh-package.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateGetCertCrlObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateGetCertCrlObject.ets old mode 100755 new mode 100644 index 78139d9373..5cb1c7db97 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateGetCertCrlObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateGetCertCrlObject.ets @@ -1,135 +1,135 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - -// [Start certificate_collection_and_certificate_revocation_list_collection_object_creation_and_acquisition] -import { cert } from '@kit.DeviceCertificateKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { util } from '@kit.ArkTS'; - -async function createX509CRL(): Promise { - let crlData = '-----BEGIN X509 CRL-----\n' + - 'MIHzMF4CAQMwDQYJKoZIhvcNAQEEBQAwFTETMBEGA1UEAxMKQ1JMIGlzc3VlchcN\n' + - 'MTcwODA3MTExOTU1WhcNMzIxMjE0MDA1MzIwWjAVMBMCAgPoFw0zMjEyMTQwMDUz\n' + - 'MjBaMA0GCSqGSIb3DQEBBAUAA4GBACEPHhlaCTWA42ykeaOyR0SGQIHIOUR3gcDH\n' + - 'J1LaNwiL+gDxI9rMQmlhsUGJmPIPdRs9uYyI+f854lsWYisD2PUEpn3DbEvzwYeQ\n' + - '5SqQoPDoM+YfZZa23hoTLsu52toXobP74sf/9K501p/+8hm4ROMLBoRT86GQKY6g\n' + - 'eavsH0Q3\n' + - '-----END X509 CRL-----\n'; - - // 证书吊销列表二进制数据,需业务自行赋值 - let textEncoder = new util.TextEncoder(); - let encodingBlob: cert.EncodingBlob = { - data: textEncoder.encodeInto(crlData), - // 根据encodingData的格式进行赋值,支持FORMAT_PEM和FORMAT_DER - encodingFormat: cert.EncodingFormat.FORMAT_PEM - }; - let x509CRL: cert.X509CRL = {} as cert.X509CRL; - try { - x509CRL = await cert.createX509CRL(encodingBlob); - } catch (err) { - let e: BusinessError = err as BusinessError; - console.error(`createX509CRL failed, errCode: ${e.code}, errMsg: ${e.message}`); - } - return x509CRL; -} - -async function createX509Cert(): Promise { - let certData = '-----BEGIN CERTIFICATE-----\n' + - 'MIIBHTCBwwICA+gwCgYIKoZIzj0EAwIwGjEYMBYGA1UEAwwPRXhhbXBsZSBSb290\n' + - 'IENBMB4XDTIzMDkwNTAyNDgyMloXDTI2MDUzMTAyNDgyMlowGjEYMBYGA1UEAwwP\n' + - 'RXhhbXBsZSBSb290IENBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHjG74yMI\n' + - 'ueO7z3T+dyuEIrhxTg2fqgeNB3SGfsIXlsiUfLTatUsU0i/sePnrKglj2H8Abbx9\n' + - 'PK0tsW/VgqwDIDAKBggqhkjOPQQDAgNJADBGAiEApVZno/Z7WyDc/muRN1y57uaY\n' + - 'Mjrgnvp/AMdE8qmFiDwCIQCrIYdHVO1awaPgcdALZY+uLQi6mEs/oMJLUcmaag3E\n' + - 'Qw==\n' + - '-----END CERTIFICATE-----\n'; - - let textEncoder = new util.TextEncoder(); - let encodingBlob: cert.EncodingBlob = { - data: textEncoder.encodeInto(certData), - // 根据encodingData的格式进行赋值,支持FORMAT_PEM和FORMAT_DER - encodingFormat: cert.EncodingFormat.FORMAT_PEM - }; - - let x509Cert: cert.X509Cert = {} as cert.X509Cert; - try { - x509Cert = await cert.createX509Cert(encodingBlob); - } catch (err) { - let e: BusinessError = err as BusinessError; - console.error(`createX509Cert failed, errCode: ${e.code}, errMsg: ${e.message}`); - } - return x509Cert; -} - -async function sample() { - const x509Cert = await createX509Cert(); - const x509CRL = await createX509CRL(); - let collection: cert.CertCRLCollection = {} as cert.CertCRLCollection; - try { - collection = cert.createCertCRLCollection([x509Cert], [x509CRL]); - console.log('createCertCRLCollection success'); - } catch (err) { - console.error('createCertCRLCollection failed'); - } - - const certParam: cert.X509CertMatchParameters = { - validDate: '231128000000Z' - } - try { - let certs: cert.X509Cert[] = await collection.selectCerts(certParam); - } catch (err) { - console.error('selectCerts failed'); - } - - const crlParam: cert.X509CRLMatchParameters = { - x509Cert: x509Cert - } - try { - let crls: cert.X509CRL[] = await collection.selectCRLs(crlParam); - console.error('selectCRLs success'); - } catch (err) { - console.error('selectCRLs failed'); - } -} - - -// [End certificate_collection_and_certificate_revocation_list_collection_object_creation_and_acquisition] -@Entry -@Component -struct Index { - @State message: string = 'CreateGetCertCrlObject'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button('Call CreateGetCertCrlObject') - .width('70%') - .onClick(() => { - try { - sample(); - this.message = 'Call Success'; - } catch { - this.message = 'Call Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +// [Start certificate_collection_and_certificate_revocation_list_collection_object_creation_and_acquisition] +import { cert } from '@kit.DeviceCertificateKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { util } from '@kit.ArkTS'; + +async function createX509CRL(): Promise { + let crlData = '-----BEGIN X509 CRL-----\n' + + 'MIHzMF4CAQMwDQYJKoZIhvcNAQEEBQAwFTETMBEGA1UEAxMKQ1JMIGlzc3VlchcN\n' + + 'MTcwODA3MTExOTU1WhcNMzIxMjE0MDA1MzIwWjAVMBMCAgPoFw0zMjEyMTQwMDUz\n' + + 'MjBaMA0GCSqGSIb3DQEBBAUAA4GBACEPHhlaCTWA42ykeaOyR0SGQIHIOUR3gcDH\n' + + 'J1LaNwiL+gDxI9rMQmlhsUGJmPIPdRs9uYyI+f854lsWYisD2PUEpn3DbEvzwYeQ\n' + + '5SqQoPDoM+YfZZa23hoTLsu52toXobP74sf/9K501p/+8hm4ROMLBoRT86GQKY6g\n' + + 'eavsH0Q3\n' + + '-----END X509 CRL-----\n'; + + // 证书吊销列表二进制数据,需业务自行赋值 + let textEncoder = new util.TextEncoder(); + let encodingBlob: cert.EncodingBlob = { + data: textEncoder.encodeInto(crlData), + // 根据encodingData的格式进行赋值,支持FORMAT_PEM和FORMAT_DER + encodingFormat: cert.EncodingFormat.FORMAT_PEM + }; + let x509CRL: cert.X509CRL = {} as cert.X509CRL; + try { + x509CRL = await cert.createX509CRL(encodingBlob); + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`createX509CRL failed, errCode: ${e.code}, errMsg: ${e.message}`); + } + return x509CRL; +} + +async function createX509Cert(): Promise { + let certData = '-----BEGIN CERTIFICATE-----\n' + + 'MIIBHTCBwwICA+gwCgYIKoZIzj0EAwIwGjEYMBYGA1UEAwwPRXhhbXBsZSBSb290\n' + + 'IENBMB4XDTIzMDkwNTAyNDgyMloXDTI2MDUzMTAyNDgyMlowGjEYMBYGA1UEAwwP\n' + + 'RXhhbXBsZSBSb290IENBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHjG74yMI\n' + + 'ueO7z3T+dyuEIrhxTg2fqgeNB3SGfsIXlsiUfLTatUsU0i/sePnrKglj2H8Abbx9\n' + + 'PK0tsW/VgqwDIDAKBggqhkjOPQQDAgNJADBGAiEApVZno/Z7WyDc/muRN1y57uaY\n' + + 'Mjrgnvp/AMdE8qmFiDwCIQCrIYdHVO1awaPgcdALZY+uLQi6mEs/oMJLUcmaag3E\n' + + 'Qw==\n' + + '-----END CERTIFICATE-----\n'; + + let textEncoder = new util.TextEncoder(); + let encodingBlob: cert.EncodingBlob = { + data: textEncoder.encodeInto(certData), + // 根据encodingData的格式进行赋值,支持FORMAT_PEM和FORMAT_DER + encodingFormat: cert.EncodingFormat.FORMAT_PEM + }; + + let x509Cert: cert.X509Cert = {} as cert.X509Cert; + try { + x509Cert = await cert.createX509Cert(encodingBlob); + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`createX509Cert failed, errCode: ${e.code}, errMsg: ${e.message}`); + } + return x509Cert; +} + +async function sample() { + const x509Cert = await createX509Cert(); + const x509CRL = await createX509CRL(); + let collection: cert.CertCRLCollection = {} as cert.CertCRLCollection; + try { + collection = cert.createCertCRLCollection([x509Cert], [x509CRL]); + console.log('createCertCRLCollection success'); + } catch (err) { + console.error('createCertCRLCollection failed'); + } + + const certParam: cert.X509CertMatchParameters = { + validDate: '231128000000Z' + } + try { + let certs: cert.X509Cert[] = await collection.selectCerts(certParam); + } catch (err) { + console.error('selectCerts failed'); + } + + const crlParam: cert.X509CRLMatchParameters = { + x509Cert: x509Cert + } + try { + let crls: cert.X509CRL[] = await collection.selectCRLs(crlParam); + console.error('selectCRLs success'); + } catch (err) { + console.error('selectCRLs failed'); + } +} + + +// [End certificate_collection_and_certificate_revocation_list_collection_object_creation_and_acquisition] +@Entry +@Component +struct Index { + @State message: string = 'CreateGetCertCrlObject'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button('Call CreateGetCertCrlObject') + .width('70%') + .onClick(() => { + try { + sample(); + this.message = 'Call Success'; + } catch { + this.message = 'Call Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertObject.ets old mode 100755 new mode 100644 index 99b48021f1..188021f53c --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertObject.ets @@ -1,115 +1,115 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start certificate_object_creation_resolution_validation] - -import { cert } from '@kit.DeviceCertificateKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { util } from '@kit.ArkTS'; - -// 此处仅为示例的证书二进制数据,需根据业务的不同对证书数据进行赋值 -let certData = '-----BEGIN CERTIFICATE-----\n' + - 'MIIBLzCB1QIUO/QDVJwZLIpeJyPjyTvE43xvE5cwCgYIKoZIzj0EAwIwGjEYMBYG\n' + - 'A1UEAwwPRXhhbXBsZSBSb290IENBMB4XDTIzMDkwNDExMjAxOVoXDTI2MDUzMDEx\n' + - 'MjAxOVowGjEYMBYGA1UEAwwPRXhhbXBsZSBSb290IENBMFkwEwYHKoZIzj0CAQYI\n' + - 'KoZIzj0DAQcDQgAEHjG74yMIueO7z3T+dyuEIrhxTg2fqgeNB3SGfsIXlsiUfLTa\n' + - 'tUsU0i/sePnrKglj2H8Abbx9PK0tsW/VgqwDIDAKBggqhkjOPQQDAgNJADBGAiEA\n' + - '0ce/fvA4tckNZeB865aOApKXKlBjiRlaiuq5mEEqvNACIQDPD9WyC21MXqPBuRUf\n' + - 'BetUokslUfjT6+s/X4ByaxycAA==\n' + - '-----END CERTIFICATE-----\n'; - -// 证书示例 -function certSample(): void { - let textEncoder = new util.TextEncoder(); - let encodingBlob: cert.EncodingBlob = { - // 将证书数据从string类型转换成Unit8Array - data: textEncoder.encodeInto(certData), - // 证书格式,仅支持PEM和DER。在此示例中,证书为PEM格式 - encodingFormat: cert.EncodingFormat.FORMAT_PEM - }; - - // 创建X509Cert实例 - cert.createX509Cert(encodingBlob, (err, x509Cert) => { - if (err != null) { - // 创建X509Cert实例失败 - console.error(`createX509Cert failed, errCode:${err.code}, errMsg:${err.message}`); - return; - } - // X509Cert实例创建成功 - console.log('createX509Cert success'); - - // 获取证书版本 - let version = x509Cert.getVersion(); - let serial = x509Cert.getCertSerialNumber(); - console.log(`X509 version: ${version} , X509 serial:${serial}`); - - // 使用上级证书对象的getPublicKey()方法或本(自签名)证书对象获取公钥对象 - try { - let pubKey = x509Cert.getPublicKey(); - // 验证证书签名 - x509Cert.verify(pubKey, (err, data) => { - if (err == null) { - // 签名验证成功 - console.log('verify success'); - } else { - // 签名验证失败 - console.error(`verify failed, errCode: ${err.code} , errMsg:${err.message}`); - } - }); - } catch (error) { - let e: BusinessError = error as BusinessError; - console.error(`getPublicKey failed, errCode: ${e.code} , errMsg:${e.message}`); - } - - // 用一个字符串代表时间 - let date = '20230930000001Z'; - - // 验证证书的有效期 - try { - x509Cert.checkValidityWithDate(date); - } catch (error) { - let e: BusinessError = error as BusinessError; - console.error(`checkValidityWithDate failed, errCode: ${e.code}, errMsg:${e.message}`); - } - }); -} - - -// [End certificate_object_creation_resolution_validation] -@Entry -@Component -struct Index { - @State message: string = 'CreateParseVerifyCertObject'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button('Call CreateParseVerifyCertObject') - .width('70%') - .onClick(()=>{ - try { - certSample(); - this.message = 'Call Success'; - } catch { - this.message = 'Call Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start certificate_object_creation_resolution_validation] + +import { cert } from '@kit.DeviceCertificateKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { util } from '@kit.ArkTS'; + +// 此处仅为示例的证书二进制数据,需根据业务的不同对证书数据进行赋值 +let certData = '-----BEGIN CERTIFICATE-----\n' + + 'MIIBLzCB1QIUO/QDVJwZLIpeJyPjyTvE43xvE5cwCgYIKoZIzj0EAwIwGjEYMBYG\n' + + 'A1UEAwwPRXhhbXBsZSBSb290IENBMB4XDTIzMDkwNDExMjAxOVoXDTI2MDUzMDEx\n' + + 'MjAxOVowGjEYMBYGA1UEAwwPRXhhbXBsZSBSb290IENBMFkwEwYHKoZIzj0CAQYI\n' + + 'KoZIzj0DAQcDQgAEHjG74yMIueO7z3T+dyuEIrhxTg2fqgeNB3SGfsIXlsiUfLTa\n' + + 'tUsU0i/sePnrKglj2H8Abbx9PK0tsW/VgqwDIDAKBggqhkjOPQQDAgNJADBGAiEA\n' + + '0ce/fvA4tckNZeB865aOApKXKlBjiRlaiuq5mEEqvNACIQDPD9WyC21MXqPBuRUf\n' + + 'BetUokslUfjT6+s/X4ByaxycAA==\n' + + '-----END CERTIFICATE-----\n'; + +// 证书示例 +function certSample(): void { + let textEncoder = new util.TextEncoder(); + let encodingBlob: cert.EncodingBlob = { + // 将证书数据从string类型转换成Unit8Array + data: textEncoder.encodeInto(certData), + // 证书格式,仅支持PEM和DER。在此示例中,证书为PEM格式 + encodingFormat: cert.EncodingFormat.FORMAT_PEM + }; + + // 创建X509Cert实例 + cert.createX509Cert(encodingBlob, (err, x509Cert) => { + if (err != null) { + // 创建X509Cert实例失败 + console.error(`createX509Cert failed, errCode:${err.code}, errMsg:${err.message}`); + return; + } + // X509Cert实例创建成功 + console.log('createX509Cert success'); + + // 获取证书版本 + let version = x509Cert.getVersion(); + let serial = x509Cert.getCertSerialNumber(); + console.log(`X509 version: ${version} , X509 serial:${serial}`); + + // 使用上级证书对象的getPublicKey()方法或本(自签名)证书对象获取公钥对象 + try { + let pubKey = x509Cert.getPublicKey(); + // 验证证书签名 + x509Cert.verify(pubKey, (err, data) => { + if (err == null) { + // 签名验证成功 + console.log('verify success'); + } else { + // 签名验证失败 + console.error(`verify failed, errCode: ${err.code} , errMsg:${err.message}`); + } + }); + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`getPublicKey failed, errCode: ${e.code} , errMsg:${e.message}`); + } + + // 用一个字符串代表时间 + let date = '20230930000001Z'; + + // 验证证书的有效期 + try { + x509Cert.checkValidityWithDate(date); + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`checkValidityWithDate failed, errCode: ${e.code}, errMsg:${e.message}`); + } + }); +} + + +// [End certificate_object_creation_resolution_validation] +@Entry +@Component +struct Index { + @State message: string = 'CreateParseVerifyCertObject'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button('Call CreateParseVerifyCertObject') + .width('70%') + .onClick(()=>{ + try { + certSample(); + this.message = 'Call Success'; + } catch { + this.message = 'Call Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertextensionObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertextensionObject.ets old mode 100755 new mode 100644 index 10ae5d5771..ec59e35bd6 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertextensionObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertextensionObject.ets @@ -1,100 +1,100 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// [Start create_parse_validate_certificate_extension_info_objects] - -import { cert } from '@kit.DeviceCertificateKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { util } from '@kit.ArkTS'; - -// 证书扩展数据,以下只是一个示例。需要根据具体业务来赋值 -let extData = new Uint8Array([ - 0x30, 0x40, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x1D, - 0x13, 0x01, 0x01, 0xFF, 0x04, 0x05, 0x30, 0x03, - 0x01, 0x01, 0xFF, 0x30, 0x0E, 0x06, 0x03, 0x55, - 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, - 0x02, 0x01, 0xC6, 0x30, 0x1D, 0x06, 0x03, 0x55, - 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xE0, 0x8C, - 0x9B, 0xDB, 0x25, 0x49, 0xB3, 0xF1, 0x7C, 0x86, - 0xD6, 0xB2, 0x42, 0x87, 0x0B, 0xD0, 0x6B, 0xA0, - 0xD9, 0xE4 -]); - -// 证书扩展示例 -function certExtensionSample(): void { - let textEncoder = new util.TextEncoder(); - let encodingBlob: cert.EncodingBlob = { - data: extData, - // 证书扩展格式,目前仅支持DER格式 - encodingFormat: cert.EncodingFormat.FORMAT_DER - }; - - // 创建一个证书扩展实例 - cert.createCertExtension(encodingBlob, (err, certExtension) => { - if (err != null) { - // 证书扩展实例创建失败 - console.error(`createCertExtension failed, errCode:${err.code}, errMsg:${err.message} `); - return; - } - // 证书扩展实例创建成功 - console.log('createCertExtension success'); - - try { - // 根据OID获取证书扩展信息 - let oidData = '2.5.29.14'; - let oid: cert.DataBlob = { - data: textEncoder.encodeInto(oidData), - } - let entry = certExtension.getEntry(cert.ExtensionEntryType.EXTENSION_ENTRY_TYPE_ENTRY, oid); - - // 检查证书是否为CA证书 - let pathLen = certExtension.checkCA(); - console.log('test cert extension success'); - } catch (err) { - let e: BusinessError = err as BusinessError; - console.error(`operation failed, message:${e.message} ,code:${e.code} `); - } - }); -} - - -// [End create_parse_validate_certificate_extension_info_objects] - -@Entry -@Component -struct Index { - @State message: string = 'CreateParseVerifyCertextensionObject'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button('Call CreateParseVerifyCertextensionObject') - .width('70%') - .onClick(()=>{ - try { - certExtensionSample(); - this.message = 'Call Success'; - } catch { - this.message = 'Call Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start create_parse_validate_certificate_extension_info_objects] + +import { cert } from '@kit.DeviceCertificateKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { util } from '@kit.ArkTS'; + +// 证书扩展数据,以下只是一个示例。需要根据具体业务来赋值 +let extData = new Uint8Array([ + 0x30, 0x40, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x1D, + 0x13, 0x01, 0x01, 0xFF, 0x04, 0x05, 0x30, 0x03, + 0x01, 0x01, 0xFF, 0x30, 0x0E, 0x06, 0x03, 0x55, + 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, + 0x02, 0x01, 0xC6, 0x30, 0x1D, 0x06, 0x03, 0x55, + 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xE0, 0x8C, + 0x9B, 0xDB, 0x25, 0x49, 0xB3, 0xF1, 0x7C, 0x86, + 0xD6, 0xB2, 0x42, 0x87, 0x0B, 0xD0, 0x6B, 0xA0, + 0xD9, 0xE4 +]); + +// 证书扩展示例 +function certExtensionSample(): void { + let textEncoder = new util.TextEncoder(); + let encodingBlob: cert.EncodingBlob = { + data: extData, + // 证书扩展格式,目前仅支持DER格式 + encodingFormat: cert.EncodingFormat.FORMAT_DER + }; + + // 创建一个证书扩展实例 + cert.createCertExtension(encodingBlob, (err, certExtension) => { + if (err != null) { + // 证书扩展实例创建失败 + console.error(`createCertExtension failed, errCode:${err.code}, errMsg:${err.message} `); + return; + } + // 证书扩展实例创建成功 + console.log('createCertExtension success'); + + try { + // 根据OID获取证书扩展信息 + let oidData = '2.5.29.14'; + let oid: cert.DataBlob = { + data: textEncoder.encodeInto(oidData), + } + let entry = certExtension.getEntry(cert.ExtensionEntryType.EXTENSION_ENTRY_TYPE_ENTRY, oid); + + // 检查证书是否为CA证书 + let pathLen = certExtension.checkCA(); + console.log('test cert extension success'); + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`operation failed, message:${e.message} ,code:${e.code} `); + } + }); +} + + +// [End create_parse_validate_certificate_extension_info_objects] + +@Entry +@Component +struct Index { + @State message: string = 'CreateParseVerifyCertextensionObject'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button('Call CreateParseVerifyCertextensionObject') + .width('70%') + .onClick(()=>{ + try { + certExtensionSample(); + this.message = 'Call Success'; + } catch { + this.message = 'Call Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCrlObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCrlObject.ets old mode 100755 new mode 100644 index e43c16bd9c..019ef19a2a --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCrlObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCrlObject.ets @@ -1,205 +1,205 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start create_parse_verify_certificate_revocation_list_objects] - - -import { cert } from '@kit.DeviceCertificateKit'; -import { cryptoFramework } from '@kit.CryptoArchitectureKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { util } from '@kit.ArkTS'; - -// CRL数据,以下只是一个示例,需要根据具体业务来赋值 -let crlData = '-----BEGIN X509 CRL-----\n' + - 'MIIByzCBtAIBATANBgkqhkiG9w0BAQsFADBXMQswCQYDVQQGEwJDTjEPMA0GA1UE\n' + - 'CAwG6ZmV6KW/MQ8wDQYDVQQHDAbopb/lrokxDzANBgNVBAoMBua1i+ivlTEVMBMG\n' + - 'A1UEAwwM5Lit5paH5rWL6K+VFw0yNTAyMjAwNjEzMTZaFw0yNTAzMjIwNjEzMTZa\n' + - 'MBkwFwIGAXKnJjrAFw0yNTAyMjAwNjEzMDNaoA4wDDAKBgNVHRQEAwIBADANBgkq\n' + - 'hkiG9w0BAQsFAAOCAQEAt9AZ/B5FQiXnKKBGocKmM5QKeky/3etcI+cAVyD0zfjI\n' + - 'r1UrL1aF+49LdZps3zQRqm4RQmo9CwL+KsMZiIMSeWF5Q6LW7BQa08hx5PtdjoOu\n' + - '1IWVKAwR5IigpaOwMKRTq1xJ372EiUkDD83AsxEkQoQW0bBvFklGrzglSACeKST+\n' + - 'Pn6ywwFyYj34cfRuz3ueqwHRmN/mGzQdet7Ns8JBGWutDzfJsAiPC/TIaafTOocO\n' + - 'CHo81Q2rMcqAJj5uXyc1Gq8KfOEqsxo/oDwReghjwrUedJ+9l/cQBr0F8HPV4H8W\n' + - '49sYMpseywjp9lxjWt/2nrx1z2yMaivGrVhoFasZvQ==\n' + - '-----END X509 CRL-----\n' - -let certData = '-----BEGIN CERTIFICATE-----\n' + - 'MIIDgTCCAmmgAwIBAgIGAXKnJjrAMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNVBAYT\n' + - 'AkNOMQ8wDQYDVQQIDAbpmZXopb8xDzANBgNVBAcMBuilv+WuiTEPMA0GA1UECgwG\n' + - '5rWL6K+VMRUwEwYDVQQDDAzkuK3mlofmtYvor5UwHhcNMjUwMjIwMDYwOTUyWhcN\n' + - 'MzUwMjE4MDYwOTUyWjBXMQswCQYDVQQGEwJDTjEPMA0GA1UECAwG6ZmV6KW/MQ8w\n' + - 'DQYDVQQHDAbopb/lrokxDzANBgNVBAoMBua1i+ivlTEVMBMGA1UEAwwM5Lit5paH\n' + - '5rWL6K+VMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2DQpPYN7cJjQ\n' + - 'LWLlkP5dD8J/g1xx97t2bFciUOru14IBm9EeX6qkohDSl6kQHwfVSqTfcqdIn9We\n' + - '73FiitfDjHc9xxbvBKbCYicCzS/eNl0W9q14FiEB8M9vz4dpKK00KZBcGc1QK2m+\n' + - '/N6zw4Tw4wXZ97v6/M+bhY5X0b3qEJlgQNyz7dD0wF7SCuzLL9zbr403KktHMG5Y\n' + - 'MzyOBaGOaMuVQFlXMV/E5OWfqbM7n0Pu/cGj+AfkkziWxB+5WFCRP6Pw64LJGo+e\n' + - 'uZHgHp07kk6+a2YNnFMcdTsOIWBSpCvC3I612NjpBirn2bFRWqTD++YAuvJQagmM\n' + - '+VhIjXD48wIDAQABo1MwUTAdBgNVHQ4EFgQUIN7ulBn89L5HXh9m9JM7rpkvlXUw\n' + - 'HwYDVR0jBBgwFoAUIN7ulBn89L5HXh9m9JM7rpkvlXUwDwYDVR0TAQH/BAUwAwEB\n' + - '/zANBgkqhkiG9w0BAQsFAAOCAQEAxWNa3LSOR3QOJ+wE1Y/q5zzEPWmWR5OMrRJK\n' + - 'juBHhYbzsg3r74fBO3Hw8XggEpHr6SOI1rBpZhciA8D9E8RnM1aJLY53rpBDY5OV\n' + - 'wxTFzrjdwIknt13t6ILfGeLye5OAF0S8VPdfDqP9NddNNr/WFKpd3tKoBlG0ObMa\n' + - 'LaQvOqObz0MJrjKsyI680nJjFLjLZ6+lEDSg4rsGU+bxEkONerStAPNcN2x9z7O6\n' + - 'YJOvhiLjWvr8VRjlMZYVmT9gqCImoo+7JaHbu8jz9mjRxD6fo9I1OvCLNFyFw2sV\n' + - 'iYID9UEbT6IWv/kKBdr7Te9+SY6AWxUxO8Hd7HdPKDOCrGrU9A==\n' + - '-----END CERTIFICATE-----\n'; - -let pubKeyData = new Uint8Array([ - 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, - 0x00, 0xd8, 0x34, 0x29, 0x3d, 0x83, 0x7b, 0x70, 0x98, 0xd0, 0x2d, 0x62, 0xe5, 0x90, 0xfe, 0x5d, - 0x0f, 0xc2, 0x7f, 0x83, 0x5c, 0x71, 0xf7, 0xbb, 0x76, 0x6c, 0x57, 0x22, 0x50, 0xea, 0xee, 0xd7, - 0x82, 0x01, 0x9b, 0xd1, 0x1e, 0x5f, 0xaa, 0xa4, 0xa2, 0x10, 0xd2, 0x97, 0xa9, 0x10, 0x1f, 0x07, - 0xd5, 0x4a, 0xa4, 0xdf, 0x72, 0xa7, 0x48, 0x9f, 0xd5, 0x9e, 0xef, 0x71, 0x62, 0x8a, 0xd7, 0xc3, - 0x8c, 0x77, 0x3d, 0xc7, 0x16, 0xef, 0x04, 0xa6, 0xc2, 0x62, 0x27, 0x02, 0xcd, 0x2f, 0xde, 0x36, - 0x5d, 0x16, 0xf6, 0xad, 0x78, 0x16, 0x21, 0x01, 0xf0, 0xcf, 0x6f, 0xcf, 0x87, 0x69, 0x28, 0xad, - 0x34, 0x29, 0x90, 0x5c, 0x19, 0xcd, 0x50, 0x2b, 0x69, 0xbe, 0xfc, 0xde, 0xb3, 0xc3, 0x84, 0xf0, - 0xe3, 0x05, 0xd9, 0xf7, 0xbb, 0xfa, 0xfc, 0xcf, 0x9b, 0x85, 0x8e, 0x57, 0xd1, 0xbd, 0xea, 0x10, - 0x99, 0x60, 0x40, 0xdc, 0xb3, 0xed, 0xd0, 0xf4, 0xc0, 0x5e, 0xd2, 0x0a, 0xec, 0xcb, 0x2f, 0xdc, - 0xdb, 0xaf, 0x8d, 0x37, 0x2a, 0x4b, 0x47, 0x30, 0x6e, 0x58, 0x33, 0x3c, 0x8e, 0x05, 0xa1, 0x8e, - 0x68, 0xcb, 0x95, 0x40, 0x59, 0x57, 0x31, 0x5f, 0xc4, 0xe4, 0xe5, 0x9f, 0xa9, 0xb3, 0x3b, 0x9f, - 0x43, 0xee, 0xfd, 0xc1, 0xa3, 0xf8, 0x07, 0xe4, 0x93, 0x38, 0x96, 0xc4, 0x1f, 0xb9, 0x58, 0x50, - 0x91, 0x3f, 0xa3, 0xf0, 0xeb, 0x82, 0xc9, 0x1a, 0x8f, 0x9e, 0xb9, 0x91, 0xe0, 0x1e, 0x9d, 0x3b, - 0x92, 0x4e, 0xbe, 0x6b, 0x66, 0x0d, 0x9c, 0x53, 0x1c, 0x75, 0x3b, 0x0e, 0x21, 0x60, 0x52, 0xa4, - 0x2b, 0xc2, 0xdc, 0x8e, 0xb5, 0xd8, 0xd8, 0xe9, 0x06, 0x2a, 0xe7, 0xd9, 0xb1, 0x51, 0x5a, 0xa4, - 0xc3, 0xfb, 0xe6, 0x00, 0xba, 0xf2, 0x50, 0x6a, 0x09, 0x8c, 0xf9, 0x58, 0x48, 0x8d, 0x70, 0xf8, - 0xf3, 0x02, 0x03, 0x01, 0x00, 0x01 -]); - -// CRL示例 -function crlSample(): void { - let textEncoder = new util.TextEncoder(); - let encodingBlob: cert.EncodingBlob = { - // 将CRL数据从string转为Unit8Array - data: textEncoder.encodeInto(crlData), - // CRL格式,仅支持PEM和DER格式。在这个例子中,CRL用的是PEM格式 - encodingFormat: cert.EncodingFormat.FORMAT_PEM - }; - - // 创建X509CRL实例 - cert.createX509CRL(encodingBlob, (err, x509Crl) => { - if (err != null) { - // 创建X509CRL实例失败 - console.error(`createX509Crl failed, errCode: ${err.code}, errMsg:${err.message} `); - return; - } - // 创建X509CRL实例成功 - console.log('createX509CRL success'); - - // 获取CRL的版本 - let version = x509Crl.getVersion(); - let revokedType = x509Crl.getType(); - console.log(`X509 CRL version: ${version}, type :${revokedType}`); - - // 公钥的二进制数据需要传入@ohos.security.cryptoFramework的convertKey()方法去获取公钥对象 - try { - let keyGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024|PRIMES_3'); - console.log('createAsyKeyGenerator success'); - let pubEncodingBlob: cryptoFramework.DataBlob = { - data: pubKeyData, - }; - keyGenerator.convertKey(pubEncodingBlob, null, (e, keyPair) => { - if (e == null) { - console.log('convert key success'); - x509Crl.verify(keyPair.pubKey, (err, data) => { - if (err == null) { - // 签名验证成功 - console.log('verify success'); - } else { - // 签名验证失败 - console.error(`verify failed, errCode: ${err.code}, errMsg: ${err.message}`); - } - }); - } else { - console.error(`convert key failed, message: ${e.message}, code: ${e.code} `); - } - }) - } catch (error) { - let e: BusinessError = error as BusinessError; - console.error(`get pubKey failed, errCode: ${e.code}, errMsg: ${e.message}`); - } - - // 使用certFramework的createX509Cert()方法创建一个X509Cert实例 - let certBlob: cert.EncodingBlob = { - data: textEncoder.encodeInto(certData), - encodingFormat: cert.EncodingFormat.FORMAT_PEM - }; - let revokedFlag = true; - let serial: bigint = BigInt('0'); - cert.createX509Cert(certBlob, (err, cert) => { - serial = cert.getCertSerialNumber(); - if (err == null) { - try { - // 检查证书是否被吊销 - revokedFlag = x509Crl.isRevoked(cert); - console.log(`revokedFlag is: ${revokedFlag}`); - if (!revokedFlag) { - console.log('the given cert is not revoked.'); - return; - } - // 根据序列号来获取被吊销的证书 - try { - let crlEntry = x509Crl.getRevokedCert(serial); - console.log('get getRevokedCert success'); - let serialNumber = crlEntry.getSerialNumber(); - console.log(`crlEntry serialNumber is: ${serialNumber}`); - - // 获取被吊销证书的吊销日期 - let date = crlEntry.getRevocationDate(); - console.log(`revocation date is: ${date}`); - } catch (error) { - let e: BusinessError = error as BusinessError; - console.error(`getRevokedCert failed, errCode: ${e.code}, errMsg: ${e.message}`); - } - } catch (error) { - let e: BusinessError = error as BusinessError; - console.error(`isRevoked failed, errCode: ${e.code}, errMsg:${e.message}`); - } - } else { - console.error(`create x509 cert failed, errCode: ${err.code}, errMsg: ${err.message}`); - } - }) - }); -} - - -// [End create_parse_verify_certificate_revocation_list_objects] - -@Entry -@Component -struct Index { - @State message: string = 'CreateParseVerifyCrlObject'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button('Call CreateParseVerifyCrlObject') - .width('70%') - .onClick(() => { - try { - crlSample(); - this.message = 'Call Success'; - } catch { - this.message = 'Call Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start create_parse_verify_certificate_revocation_list_objects] + + +import { cert } from '@kit.DeviceCertificateKit'; +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { util } from '@kit.ArkTS'; + +// CRL数据,以下只是一个示例,需要根据具体业务来赋值 +let crlData = '-----BEGIN X509 CRL-----\n' + + 'MIIByzCBtAIBATANBgkqhkiG9w0BAQsFADBXMQswCQYDVQQGEwJDTjEPMA0GA1UE\n' + + 'CAwG6ZmV6KW/MQ8wDQYDVQQHDAbopb/lrokxDzANBgNVBAoMBua1i+ivlTEVMBMG\n' + + 'A1UEAwwM5Lit5paH5rWL6K+VFw0yNTAyMjAwNjEzMTZaFw0yNTAzMjIwNjEzMTZa\n' + + 'MBkwFwIGAXKnJjrAFw0yNTAyMjAwNjEzMDNaoA4wDDAKBgNVHRQEAwIBADANBgkq\n' + + 'hkiG9w0BAQsFAAOCAQEAt9AZ/B5FQiXnKKBGocKmM5QKeky/3etcI+cAVyD0zfjI\n' + + 'r1UrL1aF+49LdZps3zQRqm4RQmo9CwL+KsMZiIMSeWF5Q6LW7BQa08hx5PtdjoOu\n' + + '1IWVKAwR5IigpaOwMKRTq1xJ372EiUkDD83AsxEkQoQW0bBvFklGrzglSACeKST+\n' + + 'Pn6ywwFyYj34cfRuz3ueqwHRmN/mGzQdet7Ns8JBGWutDzfJsAiPC/TIaafTOocO\n' + + 'CHo81Q2rMcqAJj5uXyc1Gq8KfOEqsxo/oDwReghjwrUedJ+9l/cQBr0F8HPV4H8W\n' + + '49sYMpseywjp9lxjWt/2nrx1z2yMaivGrVhoFasZvQ==\n' + + '-----END X509 CRL-----\n' + +let certData = '-----BEGIN CERTIFICATE-----\n' + + 'MIIDgTCCAmmgAwIBAgIGAXKnJjrAMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNVBAYT\n' + + 'AkNOMQ8wDQYDVQQIDAbpmZXopb8xDzANBgNVBAcMBuilv+WuiTEPMA0GA1UECgwG\n' + + '5rWL6K+VMRUwEwYDVQQDDAzkuK3mlofmtYvor5UwHhcNMjUwMjIwMDYwOTUyWhcN\n' + + 'MzUwMjE4MDYwOTUyWjBXMQswCQYDVQQGEwJDTjEPMA0GA1UECAwG6ZmV6KW/MQ8w\n' + + 'DQYDVQQHDAbopb/lrokxDzANBgNVBAoMBua1i+ivlTEVMBMGA1UEAwwM5Lit5paH\n' + + '5rWL6K+VMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2DQpPYN7cJjQ\n' + + 'LWLlkP5dD8J/g1xx97t2bFciUOru14IBm9EeX6qkohDSl6kQHwfVSqTfcqdIn9We\n' + + '73FiitfDjHc9xxbvBKbCYicCzS/eNl0W9q14FiEB8M9vz4dpKK00KZBcGc1QK2m+\n' + + '/N6zw4Tw4wXZ97v6/M+bhY5X0b3qEJlgQNyz7dD0wF7SCuzLL9zbr403KktHMG5Y\n' + + 'MzyOBaGOaMuVQFlXMV/E5OWfqbM7n0Pu/cGj+AfkkziWxB+5WFCRP6Pw64LJGo+e\n' + + 'uZHgHp07kk6+a2YNnFMcdTsOIWBSpCvC3I612NjpBirn2bFRWqTD++YAuvJQagmM\n' + + '+VhIjXD48wIDAQABo1MwUTAdBgNVHQ4EFgQUIN7ulBn89L5HXh9m9JM7rpkvlXUw\n' + + 'HwYDVR0jBBgwFoAUIN7ulBn89L5HXh9m9JM7rpkvlXUwDwYDVR0TAQH/BAUwAwEB\n' + + '/zANBgkqhkiG9w0BAQsFAAOCAQEAxWNa3LSOR3QOJ+wE1Y/q5zzEPWmWR5OMrRJK\n' + + 'juBHhYbzsg3r74fBO3Hw8XggEpHr6SOI1rBpZhciA8D9E8RnM1aJLY53rpBDY5OV\n' + + 'wxTFzrjdwIknt13t6ILfGeLye5OAF0S8VPdfDqP9NddNNr/WFKpd3tKoBlG0ObMa\n' + + 'LaQvOqObz0MJrjKsyI680nJjFLjLZ6+lEDSg4rsGU+bxEkONerStAPNcN2x9z7O6\n' + + 'YJOvhiLjWvr8VRjlMZYVmT9gqCImoo+7JaHbu8jz9mjRxD6fo9I1OvCLNFyFw2sV\n' + + 'iYID9UEbT6IWv/kKBdr7Te9+SY6AWxUxO8Hd7HdPKDOCrGrU9A==\n' + + '-----END CERTIFICATE-----\n'; + +let pubKeyData = new Uint8Array([ + 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, + 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, + 0x00, 0xd8, 0x34, 0x29, 0x3d, 0x83, 0x7b, 0x70, 0x98, 0xd0, 0x2d, 0x62, 0xe5, 0x90, 0xfe, 0x5d, + 0x0f, 0xc2, 0x7f, 0x83, 0x5c, 0x71, 0xf7, 0xbb, 0x76, 0x6c, 0x57, 0x22, 0x50, 0xea, 0xee, 0xd7, + 0x82, 0x01, 0x9b, 0xd1, 0x1e, 0x5f, 0xaa, 0xa4, 0xa2, 0x10, 0xd2, 0x97, 0xa9, 0x10, 0x1f, 0x07, + 0xd5, 0x4a, 0xa4, 0xdf, 0x72, 0xa7, 0x48, 0x9f, 0xd5, 0x9e, 0xef, 0x71, 0x62, 0x8a, 0xd7, 0xc3, + 0x8c, 0x77, 0x3d, 0xc7, 0x16, 0xef, 0x04, 0xa6, 0xc2, 0x62, 0x27, 0x02, 0xcd, 0x2f, 0xde, 0x36, + 0x5d, 0x16, 0xf6, 0xad, 0x78, 0x16, 0x21, 0x01, 0xf0, 0xcf, 0x6f, 0xcf, 0x87, 0x69, 0x28, 0xad, + 0x34, 0x29, 0x90, 0x5c, 0x19, 0xcd, 0x50, 0x2b, 0x69, 0xbe, 0xfc, 0xde, 0xb3, 0xc3, 0x84, 0xf0, + 0xe3, 0x05, 0xd9, 0xf7, 0xbb, 0xfa, 0xfc, 0xcf, 0x9b, 0x85, 0x8e, 0x57, 0xd1, 0xbd, 0xea, 0x10, + 0x99, 0x60, 0x40, 0xdc, 0xb3, 0xed, 0xd0, 0xf4, 0xc0, 0x5e, 0xd2, 0x0a, 0xec, 0xcb, 0x2f, 0xdc, + 0xdb, 0xaf, 0x8d, 0x37, 0x2a, 0x4b, 0x47, 0x30, 0x6e, 0x58, 0x33, 0x3c, 0x8e, 0x05, 0xa1, 0x8e, + 0x68, 0xcb, 0x95, 0x40, 0x59, 0x57, 0x31, 0x5f, 0xc4, 0xe4, 0xe5, 0x9f, 0xa9, 0xb3, 0x3b, 0x9f, + 0x43, 0xee, 0xfd, 0xc1, 0xa3, 0xf8, 0x07, 0xe4, 0x93, 0x38, 0x96, 0xc4, 0x1f, 0xb9, 0x58, 0x50, + 0x91, 0x3f, 0xa3, 0xf0, 0xeb, 0x82, 0xc9, 0x1a, 0x8f, 0x9e, 0xb9, 0x91, 0xe0, 0x1e, 0x9d, 0x3b, + 0x92, 0x4e, 0xbe, 0x6b, 0x66, 0x0d, 0x9c, 0x53, 0x1c, 0x75, 0x3b, 0x0e, 0x21, 0x60, 0x52, 0xa4, + 0x2b, 0xc2, 0xdc, 0x8e, 0xb5, 0xd8, 0xd8, 0xe9, 0x06, 0x2a, 0xe7, 0xd9, 0xb1, 0x51, 0x5a, 0xa4, + 0xc3, 0xfb, 0xe6, 0x00, 0xba, 0xf2, 0x50, 0x6a, 0x09, 0x8c, 0xf9, 0x58, 0x48, 0x8d, 0x70, 0xf8, + 0xf3, 0x02, 0x03, 0x01, 0x00, 0x01 +]); + +// CRL示例 +function crlSample(): void { + let textEncoder = new util.TextEncoder(); + let encodingBlob: cert.EncodingBlob = { + // 将CRL数据从string转为Unit8Array + data: textEncoder.encodeInto(crlData), + // CRL格式,仅支持PEM和DER格式。在这个例子中,CRL用的是PEM格式 + encodingFormat: cert.EncodingFormat.FORMAT_PEM + }; + + // 创建X509CRL实例 + cert.createX509CRL(encodingBlob, (err, x509Crl) => { + if (err != null) { + // 创建X509CRL实例失败 + console.error(`createX509Crl failed, errCode: ${err.code}, errMsg:${err.message} `); + return; + } + // 创建X509CRL实例成功 + console.log('createX509CRL success'); + + // 获取CRL的版本 + let version = x509Crl.getVersion(); + let revokedType = x509Crl.getType(); + console.log(`X509 CRL version: ${version}, type :${revokedType}`); + + // 公钥的二进制数据需要传入@ohos.security.cryptoFramework的convertKey()方法去获取公钥对象 + try { + let keyGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024|PRIMES_3'); + console.log('createAsyKeyGenerator success'); + let pubEncodingBlob: cryptoFramework.DataBlob = { + data: pubKeyData, + }; + keyGenerator.convertKey(pubEncodingBlob, null, (e, keyPair) => { + if (e == null) { + console.log('convert key success'); + x509Crl.verify(keyPair.pubKey, (err, data) => { + if (err == null) { + // 签名验证成功 + console.log('verify success'); + } else { + // 签名验证失败 + console.error(`verify failed, errCode: ${err.code}, errMsg: ${err.message}`); + } + }); + } else { + console.error(`convert key failed, message: ${e.message}, code: ${e.code} `); + } + }) + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`get pubKey failed, errCode: ${e.code}, errMsg: ${e.message}`); + } + + // 使用certFramework的createX509Cert()方法创建一个X509Cert实例 + let certBlob: cert.EncodingBlob = { + data: textEncoder.encodeInto(certData), + encodingFormat: cert.EncodingFormat.FORMAT_PEM + }; + let revokedFlag = true; + let serial: bigint = BigInt('0'); + cert.createX509Cert(certBlob, (err, cert) => { + serial = cert.getCertSerialNumber(); + if (err == null) { + try { + // 检查证书是否被吊销 + revokedFlag = x509Crl.isRevoked(cert); + console.log(`revokedFlag is: ${revokedFlag}`); + if (!revokedFlag) { + console.log('the given cert is not revoked.'); + return; + } + // 根据序列号来获取被吊销的证书 + try { + let crlEntry = x509Crl.getRevokedCert(serial); + console.log('get getRevokedCert success'); + let serialNumber = crlEntry.getSerialNumber(); + console.log(`crlEntry serialNumber is: ${serialNumber}`); + + // 获取被吊销证书的吊销日期 + let date = crlEntry.getRevocationDate(); + console.log(`revocation date is: ${date}`); + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`getRevokedCert failed, errCode: ${e.code}, errMsg: ${e.message}`); + } + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`isRevoked failed, errCode: ${e.code}, errMsg:${e.message}`); + } + } else { + console.error(`create x509 cert failed, errCode: ${err.code}, errMsg: ${err.message}`); + } + }) + }); +} + + +// [End create_parse_verify_certificate_revocation_list_objects] + +@Entry +@Component +struct Index { + @State message: string = 'CreateParseVerifyCrlObject'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button('Call CreateParseVerifyCrlObject') + .width('70%') + .onClick(() => { + try { + crlSample(); + this.message = 'Call Success'; + } catch { + this.message = 'Call Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateTrustanchorFromP12.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateTrustanchorFromP12.ets old mode 100755 new mode 100644 index ba8d960ff9..3b29ec8d98 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateTrustanchorFromP12.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateTrustanchorFromP12.ets @@ -1,161 +1,161 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// [Start trust_array_constructed_from_p12_file_during_validation] -import { cert } from '@kit.DeviceCertificateKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -function test() { - let p12Data = - new Uint8Array([0x30, 0x82, 0x07, 0x5C, 0x02, 0x01, 0x03, 0x30, 0x82, 0x07, 0x12, 0x06, 0x09, 0x2A, 0x86, 0x48, - 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x07, 0x03, 0x04, 0x82, 0x06, 0xFF, 0x30, 0x82, 0x06, 0xFB, 0x30, - 0x82, 0x05, 0xB2, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x06, 0xA0, 0x82, 0x05, 0xA3, 0x30, - 0x82, 0x05, 0x9F, 0x02, 0x01, 0x00, 0x30, 0x82, 0x05, 0x98, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, - 0x07, 0x01, 0x30, 0x57, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x05, 0x0D, 0x30, 0x4A, 0x30, 0x29, - 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x05, 0x0C, 0x30, 0x1C, 0x04, 0x08, 0xA9, 0x1C, 0x1B, 0x19, - 0x36, 0xDE, 0xD4, 0x20, 0x02, 0x02, 0x08, 0x00, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, - 0x09, 0x05, 0x00, 0x30, 0x1D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x01, 0x2A, 0x04, 0x10, 0x7D, - 0xE5, 0x23, 0x96, 0x18, 0x8B, 0xF4, 0xBC, 0x9F, 0x4E, 0xE8, 0xE9, 0xAA, 0x52, 0x18, 0x39, 0x80, 0x82, 0x05, 0x30, - 0x02, 0x2D, 0x59, 0xA9, 0x96, 0x5A, 0xFE, 0x20, 0x18, 0xB2, 0x25, 0xEA, 0xFC, 0x86, 0x0F, 0xA8, 0x3C, 0x2B, 0x26, - 0x2F, 0x44, 0x6E, 0xF3, 0x15, 0xB7, 0x94, 0xE4, 0x43, 0xEE, 0xE6, 0xC3, 0xBB, 0x3C, 0x9E, 0x60, 0x08, 0xF8, 0x15, - 0x61, 0x44, 0xD0, 0xEA, 0xD5, 0x6D, 0x1A, 0x3B, 0x9F, 0x4E, 0x2A, 0x1E, 0xBB, 0xB9, 0x4E, 0x15, 0x43, 0xB8, 0x68, - 0xDB, 0x1A, 0x4E, 0x41, 0xBA, 0x29, 0x8E, 0x75, 0xEB, 0x12, 0xC1, 0xF0, 0x4B, 0x0D, 0x13, 0xB2, 0xC2, 0x48, 0x6F, - 0xC4, 0xC4, 0x82, 0xF2, 0x26, 0xD4, 0x3D, 0x1F, 0x42, 0x7D, 0x67, 0xB0, 0x37, 0x55, 0x9E, 0xD9, 0x46, 0x99, 0x98, - 0xB4, 0xE7, 0x4B, 0x07, 0x08, 0x3F, 0xD3, 0x96, 0x9A, 0xC5, 0xDA, 0x37, 0x74, 0x08, 0x5D, 0x3B, 0x06, 0x8A, 0x16, - 0x6D, 0x81, 0x63, 0x01, 0x83, 0x94, 0xDA, 0x1B, 0x0E, 0x04, 0xCE, 0x18, 0xF0, 0x51, 0x22, 0xD8, 0x2D, 0xF1, 0x69, - 0x0C, 0xCB, 0xC9, 0x51, 0x17, 0x07, 0x1F, 0x2B, 0xCF, 0x74, 0x26, 0xD7, 0x73, 0xB3, 0x2D, 0xF2, 0x82, 0xF0, 0x38, - 0x5B, 0x8A, 0x8F, 0xCD, 0x84, 0x69, 0x40, 0x59, 0xCE, 0xB3, 0x39, 0xFE, 0xF6, 0xB7, 0x24, 0x89, 0x34, 0xFF, 0xF4, - 0x40, 0x50, 0x06, 0x4D, 0xC6, 0x13, 0x82, 0xAF, 0x7F, 0x84, 0xB1, 0x67, 0x3C, 0x89, 0xBB, 0x5D, 0x32, 0xC3, 0xA6, - 0xF1, 0x7D, 0xF5, 0x72, 0x68, 0x75, 0xCE, 0x69, 0xAB, 0x6C, 0x32, 0xDA, 0x16, 0x3B, 0xC4, 0xCA, 0x47, 0x45, 0xE9, - 0x59, 0x1E, 0xB1, 0x70, 0xDA, 0x8A, 0x00, 0x69, 0x80, 0x40, 0xCA, 0x60, 0xE6, 0x07, 0x16, 0xF0, 0xA2, 0xF9, 0x12, - 0x7D, 0x09, 0x43, 0x66, 0x46, 0x78, 0x35, 0xA6, 0x94, 0x35, 0x60, 0x82, 0xFC, 0xB8, 0x5E, 0x39, 0xE7, 0xA1, 0x22, - 0xAD, 0xCC, 0x6F, 0x5E, 0xCE, 0x01, 0x6B, 0xA1, 0xDD, 0xE5, 0xDD, 0x79, 0x9B, 0xA1, 0x28, 0xC4, 0x03, 0x84, 0x8D, - 0x6C, 0x07, 0xD4, 0xFE, 0x57, 0xFB, 0x89, 0x3F, 0x43, 0x44, 0x69, 0xF1, 0x9E, 0x53, 0x6C, 0x11, 0x11, 0x96, 0x79, - 0xE4, 0xB8, 0x3B, 0x49, 0x2E, 0xF6, 0x3B, 0xC5, 0x6C, 0x76, 0x21, 0x22, 0x15, 0x85, 0x77, 0x8A, 0xDD, 0xD2, 0x43, - 0x85, 0x73, 0x39, 0x77, 0x9F, 0xFA, 0x8F, 0xCF, 0xCB, 0xEA, 0x62, 0xBD, 0x5C, 0x66, 0x45, 0xCD, 0xB0, 0xCA, 0x42, - 0xCC, 0xB9, 0xCF, 0xE3, 0x84, 0x63, 0x9F, 0x63, 0xCE, 0x49, 0xE9, 0x74, 0x26, 0xCC, 0x26, 0x78, 0xCE, 0x9F, 0x4E, - 0x38, 0xA2, 0x9C, 0xEB, 0x75, 0xC5, 0x33, 0x6B, 0x00, 0x83, 0x85, 0xA3, 0x0F, 0xE7, 0xE1, 0x11, 0xA6, 0x48, 0xDC, - 0xEF, 0x0C, 0x05, 0xB3, 0xDE, 0x94, 0xB9, 0x69, 0xCB, 0x27, 0x09, 0xAB, 0x27, 0xD8, 0x06, 0xED, 0x25, 0xBC, 0xA6, - 0x2E, 0xB7, 0xF9, 0x2E, 0xAD, 0x84, 0x1D, 0xDD, 0x73, 0xD8, 0xC0, 0x46, 0x8A, 0xFE, 0x9A, 0xDF, 0x07, 0xE1, 0x33, - 0xE2, 0x1C, 0x37, 0x6A, 0x8E, 0xA2, 0x91, 0x0B, 0xD7, 0x76, 0xEF, 0x3C, 0x87, 0x4A, 0x53, 0x84, 0xFA, 0xFA, 0xC5, - 0x71, 0x76, 0xC0, 0x75, 0x70, 0x67, 0x67, 0x71, 0x9D, 0x8B, 0x81, 0x6F, 0x68, 0xC5, 0xB1, 0xFC, 0xA3, 0x59, 0xB5, - 0xD0, 0x03, 0x56, 0xE7, 0x89, 0x03, 0xD7, 0x99, 0xDE, 0x66, 0x33, 0xFA, 0x53, 0x50, 0x5F, 0xB4, 0x9D, 0xB3, 0x90, - 0x8F, 0x57, 0x20, 0xF0, 0x8B, 0xDB, 0x73, 0xCA, 0xA4, 0x71, 0x61, 0x67, 0x6A, 0x6D, 0xA5, 0xCA, 0x88, 0xD4, 0xCC, - 0x82, 0x34, 0xC9, 0x3E, 0x10, 0x10, 0x57, 0xD1, 0x08, 0x96, 0x80, 0x09, 0xA8, 0xBB, 0x6F, 0x53, 0x8F, 0xFD, 0x87, - 0xCF, 0x73, 0xFC, 0xE1, 0x3A, 0x92, 0x2E, 0x78, 0x66, 0xFB, 0x86, 0x5D, 0x62, 0xE0, 0xC4, 0x58, 0x55, 0x3F, 0xA4, - 0xEA, 0xA1, 0xBE, 0x5B, 0x5E, 0x8E, 0x46, 0x50, 0x5E, 0x7C, 0x01, 0xD6, 0x63, 0xAA, 0x6F, 0xD5, 0xFD, 0xAF, 0xC5, - 0x1D, 0xB3, 0x90, 0x9C, 0xD8, 0x5F, 0x8D, 0xF2, 0x81, 0xEB, 0xBF, 0xA1, 0xDE, 0xB7, 0x9D, 0xCD, 0x24, 0x82, 0x06, - 0x0B, 0x63, 0xE6, 0xBF, 0x57, 0x51, 0xF0, 0xB6, 0xE9, 0x7F, 0xAA, 0x7B, 0x10, 0xBD, 0xCD, 0x85, 0x41, 0xE0, 0xD7, - 0xF1, 0x53, 0xB7, 0xF8, 0x46, 0x91, 0x9E, 0x8D, 0x4B, 0xCB, 0x28, 0x35, 0x40, 0x37, 0x1E, 0x83, 0x64, 0x6A, 0x70, - 0x01, 0x9D, 0xBF, 0xF1, 0x0E, 0xB6, 0x2E, 0x7A, 0xB7, 0x8F, 0x0F, 0x8C, 0x69, 0xD6, 0xF2, 0xD1, 0xF6, 0x1E, 0xCD, - 0x08, 0xA8, 0xD4, 0x1B, 0xCB, 0x38, 0xEA, 0x26, 0x37, 0x5C, 0x60, 0x3A, 0x38, 0x5B, 0x12, 0x1D, 0x00, 0x7B, 0xEC, - 0xCE, 0xFB, 0x89, 0x23, 0x8A, 0x11, 0xE1, 0x1B, 0xDE, 0x54, 0x91, 0x6A, 0x26, 0x22, 0xD0, 0x1C, 0x2E, 0xBA, 0xD0, - 0x92, 0x87, 0xDA, 0xF0, 0x93, 0xBB, 0x3A, 0x2C, 0x52, 0xFB, 0xB2, 0xA9, 0xA8, 0x92, 0x19, 0xE3, 0x19, 0xDC, 0xB0, - 0x0E, 0xC5, 0xE7, 0x9D, 0xFB, 0xF9, 0xA3, 0x23, 0x32, 0xD0, 0x4E, 0x2C, 0x05, 0x2D, 0x76, 0xDB, 0x93, 0x53, 0x5B, - 0x0E, 0x2A, 0xA3, 0xDD, 0x5F, 0xD3, 0x1A, 0x3B, 0x1E, 0x1F, 0x26, 0x88, 0x43, 0xAD, 0x10, 0x1F, 0xA9, 0xC4, 0xF9, - 0x1F, 0xCD, 0xA5, 0xD2, 0xDC, 0x24, 0x95, 0x1D, 0xE7, 0x57, 0xE1, 0x02, 0x0A, 0x20, 0xEA, 0x6A, 0x78, 0x4E, 0x96, - 0xE2, 0xE5, 0x6D, 0x6F, 0xFD, 0x81, 0x7B, 0x61, 0x85, 0xA3, 0x3D, 0xC5, 0x7B, 0xEF, 0xAE, 0x58, 0xA2, 0xDB, 0x91, - 0x73, 0xDB, 0x47, 0x8E, 0xD1, 0x7D, 0xD7, 0x8F, 0x56, 0x06, 0x28, 0x8C, 0x78, 0x73, 0x02, 0x65, 0xB0, 0x16, 0x4B, - 0xE6, 0xA3, 0xD7, 0x06, 0x7C, 0xEA, 0x7D, 0xE2, 0xAE, 0xBB, 0xE5, 0xD2, 0xEB, 0xF0, 0x91, 0x71, 0x7C, 0xBC, 0xA6, - 0x1A, 0xE8, 0x9F, 0xD3, 0xA9, 0x3C, 0x5D, 0x60, 0xCF, 0x59, 0x26, 0x46, 0x45, 0xF2, 0x7F, 0x85, 0x6B, 0xE7, 0xC2, - 0x58, 0x52, 0x90, 0x12, 0x07, 0xBA, 0xE6, 0xB8, 0xE5, 0xD7, 0x24, 0x93, 0xD5, 0x6E, 0xB1, 0x74, 0x6C, 0xAA, 0xA0, - 0x60, 0xBF, 0xF3, 0x32, 0x41, 0x0B, 0xA2, 0x01, 0x84, 0x0D, 0x83, 0xE4, 0x43, 0xD1, 0xBA, 0xC1, 0x92, 0x84, 0x26, - 0xF8, 0xF2, 0x77, 0x20, 0x1B, 0xF2, 0x8F, 0x00, 0x69, 0x18, 0x2F, 0x6C, 0xA8, 0x58, 0xB5, 0x5D, 0xFA, 0x27, 0xD2, - 0x38, 0xD2, 0x49, 0x6E, 0xDF, 0x55, 0x79, 0xAF, 0x1C, 0x44, 0xDA, 0x5A, 0xD7, 0x44, 0x53, 0x50, 0x8B, 0x77, 0x70, - 0x4D, 0x91, 0xEC, 0x07, 0xA5, 0x64, 0x21, 0x3C, 0x31, 0x09, 0x68, 0x65, 0xB4, 0xFA, 0xBE, 0x23, 0xF9, 0xDF, 0x77, - 0x46, 0xA2, 0x9A, 0x5D, 0xE3, 0xBE, 0x1E, 0xE3, 0x84, 0xEF, 0xAE, 0x7D, 0xF8, 0x1C, 0x54, 0xE8, 0x4E, 0xAE, 0xB5, - 0xBB, 0xD6, 0xC3, 0x8D, 0x56, 0x79, 0xE8, 0x7C, 0x43, 0xDC, 0xF3, 0xB3, 0x7A, 0x30, 0x22, 0x09, 0xBC, 0x10, 0xD6, - 0x84, 0xC4, 0x0F, 0x4C, 0x0B, 0xA2, 0xD1, 0xCB, 0xCD, 0x1F, 0x50, 0x3D, 0xF7, 0x23, 0x45, 0x55, 0x18, 0x21, 0x3D, - 0x64, 0x05, 0x2E, 0x52, 0x3A, 0x73, 0xFD, 0xF2, 0xA9, 0xCA, 0x3F, 0xF6, 0x7F, 0x87, 0xE8, 0x56, 0x9B, 0x68, 0x6B, - 0x20, 0xB0, 0x1D, 0x83, 0x04, 0x2F, 0x59, 0xFD, 0x84, 0x57, 0x7D, 0x82, 0x97, 0x96, 0xE8, 0xFB, 0xDF, 0x71, 0x8C, - 0x26, 0x47, 0x85, 0xA5, 0xBE, 0xFB, 0xF5, 0x05, 0x4C, 0xD3, 0x3D, 0x73, 0xF4, 0xA5, 0xF1, 0xA3, 0x99, 0x98, 0x1B, - 0x84, 0x8B, 0xB3, 0x53, 0xCE, 0x4D, 0xEA, 0x5A, 0x48, 0xD2, 0xB9, 0x7E, 0xB6, 0xEB, 0x9B, 0x94, 0x6F, 0xDD, 0x44, - 0x80, 0x89, 0xD2, 0x78, 0x6D, 0xB9, 0xDA, 0x8B, 0x83, 0x49, 0xE0, 0x4D, 0x49, 0xDF, 0x6B, 0xFF, 0xF7, 0x04, 0x00, - 0x32, 0xAA, 0x1D, 0x4F, 0x8D, 0x4B, 0xDE, 0xB8, 0x0D, 0xC6, 0x54, 0x1C, 0xB2, 0xCD, 0x60, 0x29, 0x72, 0x0A, 0x7E, - 0xE7, 0xEB, 0x7A, 0xF6, 0x5B, 0x04, 0x3F, 0x5B, 0x93, 0x12, 0x0D, 0xD5, 0xFF, 0x7A, 0x41, 0x44, 0x0B, 0x37, 0x12, - 0x82, 0x3D, 0xDD, 0x1E, 0x59, 0xB9, 0xBE, 0x0F, 0x9E, 0xD6, 0xD0, 0x68, 0x69, 0x74, 0xF9, 0xB1, 0x21, 0xA3, 0x70, - 0x4F, 0xDA, 0xF8, 0x9F, 0xB9, 0x49, 0x3F, 0xC6, 0xB2, 0x69, 0xC8, 0xD8, 0x60, 0xF1, 0x6A, 0x52, 0x07, 0xFA, 0x42, - 0xFD, 0xA9, 0x06, 0xCF, 0x97, 0x4A, 0x0E, 0xC5, 0xFC, 0x63, 0x27, 0x54, 0xC8, 0xBE, 0x8B, 0x4F, 0xB6, 0x42, 0xBC, - 0xA2, 0xCC, 0x70, 0x4A, 0x6B, 0x24, 0x5B, 0x68, 0x28, 0x47, 0xFA, 0x6B, 0x89, 0x28, 0x07, 0x5D, 0xE0, 0x2C, 0x4A, - 0xD9, 0x22, 0xE3, 0xB3, 0x2F, 0xAA, 0xC2, 0xA0, 0x7C, 0x0F, 0x92, 0xC5, 0xDD, 0xB6, 0x23, 0x8F, 0x73, 0x73, 0x0F, - 0xD7, 0x73, 0x71, 0x2F, 0x0A, 0x78, 0xE8, 0x5B, 0xDB, 0xC2, 0xE0, 0xDB, 0xC9, 0x3E, 0xC3, 0x72, 0x9C, 0x14, 0xD7, - 0xD1, 0x28, 0xFD, 0xF4, 0xEE, 0xBC, 0x0E, 0x13, 0x37, 0xCA, 0x85, 0x9F, 0xB9, 0xA2, 0x0E, 0xF6, 0xE7, 0x49, 0xD1, - 0xD0, 0x11, 0x76, 0x53, 0xA3, 0x73, 0x95, 0x2A, 0x23, 0xC8, 0x0E, 0x97, 0x83, 0x07, 0x64, 0xB2, 0x51, 0xB7, 0xC8, - 0x51, 0x9F, 0xA4, 0x3E, 0x7B, 0xA4, 0x18, 0x6D, 0x99, 0xF0, 0x6E, 0xC3, 0x97, 0xAE, 0xF4, 0xB7, 0x66, 0x37, 0xFA, - 0x65, 0xFC, 0x5E, 0xE2, 0x57, 0xFA, 0x8B, 0x4C, 0x86, 0x10, 0xB4, 0x5C, 0xA4, 0xD2, 0x60, 0x83, 0x69, 0x1E, 0xFF, - 0x36, 0x9B, 0xF9, 0x84, 0xFB, 0xB8, 0x83, 0x64, 0xF1, 0x41, 0xA5, 0x25, 0x56, 0x21, 0xBA, 0x13, 0x98, 0x0C, 0x3B, - 0x04, 0xAA, 0x6C, 0x9A, 0xD4, 0xE3, 0x13, 0x15, 0x54, 0x05, 0x4C, 0x5C, 0xE1, 0x7A, 0x31, 0x5E, 0x90, 0xCF, 0x48, - 0x4E, 0x83, 0xD7, 0x7F, 0xED, 0x93, 0x22, 0xAB, 0x67, 0xE7, 0x76, 0x32, 0x64, 0xBA, 0x5A, 0x21, 0x3E, 0x30, 0x82, - 0x01, 0x41, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x01, 0x32, 0x04, 0x82, - 0x01, 0x2E, 0x30, 0x82, 0x01, 0x2A, 0x30, 0x82, 0x01, 0x26, 0x06, 0x0B, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, - 0x0C, 0x0A, 0x01, 0x02, 0xA0, 0x81, 0xEF, 0x30, 0x81, 0xEC, 0x30, 0x57, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, - 0x0D, 0x01, 0x05, 0x0D, 0x30, 0x4A, 0x30, 0x29, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x05, 0x0C, - 0x30, 0x1C, 0x04, 0x08, 0xED, 0x3E, 0xED, 0x07, 0x5C, 0x1F, 0x71, 0xAD, 0x02, 0x02, 0x08, 0x00, 0x30, 0x0C, 0x06, - 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x09, 0x05, 0x00, 0x30, 0x1D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, - 0x65, 0x03, 0x04, 0x01, 0x2A, 0x04, 0x10, 0xA7, 0x49, 0xA4, 0x6E, 0x00, 0x19, 0x75, 0x59, 0x75, 0x59, 0xBA, 0x4B, - 0xC7, 0x24, 0x88, 0x34, 0x04, 0x81, 0x90, 0xCA, 0x23, 0x82, 0xAA, 0x16, 0x57, 0x99, 0xFA, 0x94, 0x9F, 0xAE, 0x32, - 0x5C, 0x5B, 0xE7, 0x01, 0xD0, 0xED, 0xA7, 0x58, 0x57, 0x52, 0xBF, 0x57, 0x13, 0xD4, 0x15, 0xB0, 0x06, 0xF5, 0x38, - 0xCC, 0x64, 0x23, 0x09, 0xD5, 0x8C, 0x0D, 0x64, 0x31, 0xFA, 0x74, 0xAA, 0x96, 0x7E, 0x9B, 0x16, 0xCA, 0x21, 0xFD, - 0xC0, 0x54, 0x91, 0x40, 0x7F, 0xB3, 0xF2, 0xA3, 0xEC, 0xA1, 0x4A, 0x07, 0xF0, 0x87, 0x22, 0xDB, 0x8A, 0x49, 0x89, - 0xF7, 0xF2, 0x6A, 0xFC, 0x8D, 0x03, 0x6E, 0x32, 0x4F, 0xD0, 0xD8, 0x93, 0x92, 0xA5, 0xF1, 0x41, 0xBD, 0xEA, 0xE1, - 0x38, 0xA9, 0xD8, 0x9D, 0xAB, 0xB4, 0x8E, 0x4A, 0x40, 0x0E, 0xC7, 0xE3, 0xE9, 0xBF, 0x0E, 0xBA, 0x8D, 0xAA, 0x3E, - 0x93, 0x53, 0x88, 0xEE, 0x0A, 0x2C, 0x71, 0xF1, 0x61, 0x44, 0xA5, 0xAD, 0xED, 0x3E, 0xAB, 0x32, 0x9A, 0x32, 0x85, - 0x08, 0xF5, 0x8B, 0xCC, 0x15, 0x35, 0xEE, 0xFA, 0x17, 0x27, 0x97, 0x8D, 0xD9, 0x1C, 0x5E, 0x74, 0x9D, 0x7B, 0x31, - 0x25, 0x30, 0x23, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x15, 0x31, 0x16, 0x04, 0x14, 0x5F, - 0x8E, 0xAB, 0x9C, 0x5F, 0xE2, 0x3B, 0xB1, 0x5C, 0x1A, 0x36, 0x1D, 0x7D, 0xCB, 0x90, 0x45, 0x20, 0x3C, 0x3B, 0xAC, - 0x30, 0x41, 0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, - 0x04, 0x20, 0x93, 0x25, 0xC4, 0x3E, 0x2A, 0x6D, 0x4C, 0x30, 0x87, 0x0F, 0xE3, 0x5A, 0x95, 0xB0, 0xF2, 0x6C, 0xBA, - 0x07, 0x89, 0x7D, 0xFB, 0xCF, 0xCF, 0x1D, 0x54, 0xA3, 0x36, 0x24, 0x7B, 0x30, 0x97, 0xB5, 0x04, 0x08, 0xE7, 0x96, - 0x59, 0xCC, 0x42, 0x9F, 0xEF, 0xFC, 0x02, 0x02, 0x08, 0x00]); - - try { - cert.createTrustAnchorsWithKeyStore(p12Data, '123456').then((data) => { - console.log('createTrustAnchorsWithKeyStore sucess, the num of result is :' + JSON.stringify(data.length)); - }).catch((err: BusinessError) => { - console.error('createTrustAnchorsWithKeyStore failed, error :' + JSON.stringify(err)); - }) - } catch (error) { - console.error('createTrustAnchorsWithKeyStore failed, error :' + JSON.stringify(error)); - } -} - - -// [End trust_array_constructed_from_p12_file_during_validation] -@Entry -@Component -struct Index { - @State message: string = 'CreateTrustanchorFromP12'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button('Call CreateTrustanchorFromP12') - .width('70%') - .onClick(() => { - try { - test(); - this.message = 'Call Success'; - } catch { - this.message = 'Call Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start trust_array_constructed_from_p12_file_during_validation] +import { cert } from '@kit.DeviceCertificateKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +function test() { + let p12Data = + new Uint8Array([0x30, 0x82, 0x07, 0x5C, 0x02, 0x01, 0x03, 0x30, 0x82, 0x07, 0x12, 0x06, 0x09, 0x2A, 0x86, 0x48, + 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x07, 0x03, 0x04, 0x82, 0x06, 0xFF, 0x30, 0x82, 0x06, 0xFB, 0x30, + 0x82, 0x05, 0xB2, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x06, 0xA0, 0x82, 0x05, 0xA3, 0x30, + 0x82, 0x05, 0x9F, 0x02, 0x01, 0x00, 0x30, 0x82, 0x05, 0x98, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, + 0x07, 0x01, 0x30, 0x57, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x05, 0x0D, 0x30, 0x4A, 0x30, 0x29, + 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x05, 0x0C, 0x30, 0x1C, 0x04, 0x08, 0xA9, 0x1C, 0x1B, 0x19, + 0x36, 0xDE, 0xD4, 0x20, 0x02, 0x02, 0x08, 0x00, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, + 0x09, 0x05, 0x00, 0x30, 0x1D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x01, 0x2A, 0x04, 0x10, 0x7D, + 0xE5, 0x23, 0x96, 0x18, 0x8B, 0xF4, 0xBC, 0x9F, 0x4E, 0xE8, 0xE9, 0xAA, 0x52, 0x18, 0x39, 0x80, 0x82, 0x05, 0x30, + 0x02, 0x2D, 0x59, 0xA9, 0x96, 0x5A, 0xFE, 0x20, 0x18, 0xB2, 0x25, 0xEA, 0xFC, 0x86, 0x0F, 0xA8, 0x3C, 0x2B, 0x26, + 0x2F, 0x44, 0x6E, 0xF3, 0x15, 0xB7, 0x94, 0xE4, 0x43, 0xEE, 0xE6, 0xC3, 0xBB, 0x3C, 0x9E, 0x60, 0x08, 0xF8, 0x15, + 0x61, 0x44, 0xD0, 0xEA, 0xD5, 0x6D, 0x1A, 0x3B, 0x9F, 0x4E, 0x2A, 0x1E, 0xBB, 0xB9, 0x4E, 0x15, 0x43, 0xB8, 0x68, + 0xDB, 0x1A, 0x4E, 0x41, 0xBA, 0x29, 0x8E, 0x75, 0xEB, 0x12, 0xC1, 0xF0, 0x4B, 0x0D, 0x13, 0xB2, 0xC2, 0x48, 0x6F, + 0xC4, 0xC4, 0x82, 0xF2, 0x26, 0xD4, 0x3D, 0x1F, 0x42, 0x7D, 0x67, 0xB0, 0x37, 0x55, 0x9E, 0xD9, 0x46, 0x99, 0x98, + 0xB4, 0xE7, 0x4B, 0x07, 0x08, 0x3F, 0xD3, 0x96, 0x9A, 0xC5, 0xDA, 0x37, 0x74, 0x08, 0x5D, 0x3B, 0x06, 0x8A, 0x16, + 0x6D, 0x81, 0x63, 0x01, 0x83, 0x94, 0xDA, 0x1B, 0x0E, 0x04, 0xCE, 0x18, 0xF0, 0x51, 0x22, 0xD8, 0x2D, 0xF1, 0x69, + 0x0C, 0xCB, 0xC9, 0x51, 0x17, 0x07, 0x1F, 0x2B, 0xCF, 0x74, 0x26, 0xD7, 0x73, 0xB3, 0x2D, 0xF2, 0x82, 0xF0, 0x38, + 0x5B, 0x8A, 0x8F, 0xCD, 0x84, 0x69, 0x40, 0x59, 0xCE, 0xB3, 0x39, 0xFE, 0xF6, 0xB7, 0x24, 0x89, 0x34, 0xFF, 0xF4, + 0x40, 0x50, 0x06, 0x4D, 0xC6, 0x13, 0x82, 0xAF, 0x7F, 0x84, 0xB1, 0x67, 0x3C, 0x89, 0xBB, 0x5D, 0x32, 0xC3, 0xA6, + 0xF1, 0x7D, 0xF5, 0x72, 0x68, 0x75, 0xCE, 0x69, 0xAB, 0x6C, 0x32, 0xDA, 0x16, 0x3B, 0xC4, 0xCA, 0x47, 0x45, 0xE9, + 0x59, 0x1E, 0xB1, 0x70, 0xDA, 0x8A, 0x00, 0x69, 0x80, 0x40, 0xCA, 0x60, 0xE6, 0x07, 0x16, 0xF0, 0xA2, 0xF9, 0x12, + 0x7D, 0x09, 0x43, 0x66, 0x46, 0x78, 0x35, 0xA6, 0x94, 0x35, 0x60, 0x82, 0xFC, 0xB8, 0x5E, 0x39, 0xE7, 0xA1, 0x22, + 0xAD, 0xCC, 0x6F, 0x5E, 0xCE, 0x01, 0x6B, 0xA1, 0xDD, 0xE5, 0xDD, 0x79, 0x9B, 0xA1, 0x28, 0xC4, 0x03, 0x84, 0x8D, + 0x6C, 0x07, 0xD4, 0xFE, 0x57, 0xFB, 0x89, 0x3F, 0x43, 0x44, 0x69, 0xF1, 0x9E, 0x53, 0x6C, 0x11, 0x11, 0x96, 0x79, + 0xE4, 0xB8, 0x3B, 0x49, 0x2E, 0xF6, 0x3B, 0xC5, 0x6C, 0x76, 0x21, 0x22, 0x15, 0x85, 0x77, 0x8A, 0xDD, 0xD2, 0x43, + 0x85, 0x73, 0x39, 0x77, 0x9F, 0xFA, 0x8F, 0xCF, 0xCB, 0xEA, 0x62, 0xBD, 0x5C, 0x66, 0x45, 0xCD, 0xB0, 0xCA, 0x42, + 0xCC, 0xB9, 0xCF, 0xE3, 0x84, 0x63, 0x9F, 0x63, 0xCE, 0x49, 0xE9, 0x74, 0x26, 0xCC, 0x26, 0x78, 0xCE, 0x9F, 0x4E, + 0x38, 0xA2, 0x9C, 0xEB, 0x75, 0xC5, 0x33, 0x6B, 0x00, 0x83, 0x85, 0xA3, 0x0F, 0xE7, 0xE1, 0x11, 0xA6, 0x48, 0xDC, + 0xEF, 0x0C, 0x05, 0xB3, 0xDE, 0x94, 0xB9, 0x69, 0xCB, 0x27, 0x09, 0xAB, 0x27, 0xD8, 0x06, 0xED, 0x25, 0xBC, 0xA6, + 0x2E, 0xB7, 0xF9, 0x2E, 0xAD, 0x84, 0x1D, 0xDD, 0x73, 0xD8, 0xC0, 0x46, 0x8A, 0xFE, 0x9A, 0xDF, 0x07, 0xE1, 0x33, + 0xE2, 0x1C, 0x37, 0x6A, 0x8E, 0xA2, 0x91, 0x0B, 0xD7, 0x76, 0xEF, 0x3C, 0x87, 0x4A, 0x53, 0x84, 0xFA, 0xFA, 0xC5, + 0x71, 0x76, 0xC0, 0x75, 0x70, 0x67, 0x67, 0x71, 0x9D, 0x8B, 0x81, 0x6F, 0x68, 0xC5, 0xB1, 0xFC, 0xA3, 0x59, 0xB5, + 0xD0, 0x03, 0x56, 0xE7, 0x89, 0x03, 0xD7, 0x99, 0xDE, 0x66, 0x33, 0xFA, 0x53, 0x50, 0x5F, 0xB4, 0x9D, 0xB3, 0x90, + 0x8F, 0x57, 0x20, 0xF0, 0x8B, 0xDB, 0x73, 0xCA, 0xA4, 0x71, 0x61, 0x67, 0x6A, 0x6D, 0xA5, 0xCA, 0x88, 0xD4, 0xCC, + 0x82, 0x34, 0xC9, 0x3E, 0x10, 0x10, 0x57, 0xD1, 0x08, 0x96, 0x80, 0x09, 0xA8, 0xBB, 0x6F, 0x53, 0x8F, 0xFD, 0x87, + 0xCF, 0x73, 0xFC, 0xE1, 0x3A, 0x92, 0x2E, 0x78, 0x66, 0xFB, 0x86, 0x5D, 0x62, 0xE0, 0xC4, 0x58, 0x55, 0x3F, 0xA4, + 0xEA, 0xA1, 0xBE, 0x5B, 0x5E, 0x8E, 0x46, 0x50, 0x5E, 0x7C, 0x01, 0xD6, 0x63, 0xAA, 0x6F, 0xD5, 0xFD, 0xAF, 0xC5, + 0x1D, 0xB3, 0x90, 0x9C, 0xD8, 0x5F, 0x8D, 0xF2, 0x81, 0xEB, 0xBF, 0xA1, 0xDE, 0xB7, 0x9D, 0xCD, 0x24, 0x82, 0x06, + 0x0B, 0x63, 0xE6, 0xBF, 0x57, 0x51, 0xF0, 0xB6, 0xE9, 0x7F, 0xAA, 0x7B, 0x10, 0xBD, 0xCD, 0x85, 0x41, 0xE0, 0xD7, + 0xF1, 0x53, 0xB7, 0xF8, 0x46, 0x91, 0x9E, 0x8D, 0x4B, 0xCB, 0x28, 0x35, 0x40, 0x37, 0x1E, 0x83, 0x64, 0x6A, 0x70, + 0x01, 0x9D, 0xBF, 0xF1, 0x0E, 0xB6, 0x2E, 0x7A, 0xB7, 0x8F, 0x0F, 0x8C, 0x69, 0xD6, 0xF2, 0xD1, 0xF6, 0x1E, 0xCD, + 0x08, 0xA8, 0xD4, 0x1B, 0xCB, 0x38, 0xEA, 0x26, 0x37, 0x5C, 0x60, 0x3A, 0x38, 0x5B, 0x12, 0x1D, 0x00, 0x7B, 0xEC, + 0xCE, 0xFB, 0x89, 0x23, 0x8A, 0x11, 0xE1, 0x1B, 0xDE, 0x54, 0x91, 0x6A, 0x26, 0x22, 0xD0, 0x1C, 0x2E, 0xBA, 0xD0, + 0x92, 0x87, 0xDA, 0xF0, 0x93, 0xBB, 0x3A, 0x2C, 0x52, 0xFB, 0xB2, 0xA9, 0xA8, 0x92, 0x19, 0xE3, 0x19, 0xDC, 0xB0, + 0x0E, 0xC5, 0xE7, 0x9D, 0xFB, 0xF9, 0xA3, 0x23, 0x32, 0xD0, 0x4E, 0x2C, 0x05, 0x2D, 0x76, 0xDB, 0x93, 0x53, 0x5B, + 0x0E, 0x2A, 0xA3, 0xDD, 0x5F, 0xD3, 0x1A, 0x3B, 0x1E, 0x1F, 0x26, 0x88, 0x43, 0xAD, 0x10, 0x1F, 0xA9, 0xC4, 0xF9, + 0x1F, 0xCD, 0xA5, 0xD2, 0xDC, 0x24, 0x95, 0x1D, 0xE7, 0x57, 0xE1, 0x02, 0x0A, 0x20, 0xEA, 0x6A, 0x78, 0x4E, 0x96, + 0xE2, 0xE5, 0x6D, 0x6F, 0xFD, 0x81, 0x7B, 0x61, 0x85, 0xA3, 0x3D, 0xC5, 0x7B, 0xEF, 0xAE, 0x58, 0xA2, 0xDB, 0x91, + 0x73, 0xDB, 0x47, 0x8E, 0xD1, 0x7D, 0xD7, 0x8F, 0x56, 0x06, 0x28, 0x8C, 0x78, 0x73, 0x02, 0x65, 0xB0, 0x16, 0x4B, + 0xE6, 0xA3, 0xD7, 0x06, 0x7C, 0xEA, 0x7D, 0xE2, 0xAE, 0xBB, 0xE5, 0xD2, 0xEB, 0xF0, 0x91, 0x71, 0x7C, 0xBC, 0xA6, + 0x1A, 0xE8, 0x9F, 0xD3, 0xA9, 0x3C, 0x5D, 0x60, 0xCF, 0x59, 0x26, 0x46, 0x45, 0xF2, 0x7F, 0x85, 0x6B, 0xE7, 0xC2, + 0x58, 0x52, 0x90, 0x12, 0x07, 0xBA, 0xE6, 0xB8, 0xE5, 0xD7, 0x24, 0x93, 0xD5, 0x6E, 0xB1, 0x74, 0x6C, 0xAA, 0xA0, + 0x60, 0xBF, 0xF3, 0x32, 0x41, 0x0B, 0xA2, 0x01, 0x84, 0x0D, 0x83, 0xE4, 0x43, 0xD1, 0xBA, 0xC1, 0x92, 0x84, 0x26, + 0xF8, 0xF2, 0x77, 0x20, 0x1B, 0xF2, 0x8F, 0x00, 0x69, 0x18, 0x2F, 0x6C, 0xA8, 0x58, 0xB5, 0x5D, 0xFA, 0x27, 0xD2, + 0x38, 0xD2, 0x49, 0x6E, 0xDF, 0x55, 0x79, 0xAF, 0x1C, 0x44, 0xDA, 0x5A, 0xD7, 0x44, 0x53, 0x50, 0x8B, 0x77, 0x70, + 0x4D, 0x91, 0xEC, 0x07, 0xA5, 0x64, 0x21, 0x3C, 0x31, 0x09, 0x68, 0x65, 0xB4, 0xFA, 0xBE, 0x23, 0xF9, 0xDF, 0x77, + 0x46, 0xA2, 0x9A, 0x5D, 0xE3, 0xBE, 0x1E, 0xE3, 0x84, 0xEF, 0xAE, 0x7D, 0xF8, 0x1C, 0x54, 0xE8, 0x4E, 0xAE, 0xB5, + 0xBB, 0xD6, 0xC3, 0x8D, 0x56, 0x79, 0xE8, 0x7C, 0x43, 0xDC, 0xF3, 0xB3, 0x7A, 0x30, 0x22, 0x09, 0xBC, 0x10, 0xD6, + 0x84, 0xC4, 0x0F, 0x4C, 0x0B, 0xA2, 0xD1, 0xCB, 0xCD, 0x1F, 0x50, 0x3D, 0xF7, 0x23, 0x45, 0x55, 0x18, 0x21, 0x3D, + 0x64, 0x05, 0x2E, 0x52, 0x3A, 0x73, 0xFD, 0xF2, 0xA9, 0xCA, 0x3F, 0xF6, 0x7F, 0x87, 0xE8, 0x56, 0x9B, 0x68, 0x6B, + 0x20, 0xB0, 0x1D, 0x83, 0x04, 0x2F, 0x59, 0xFD, 0x84, 0x57, 0x7D, 0x82, 0x97, 0x96, 0xE8, 0xFB, 0xDF, 0x71, 0x8C, + 0x26, 0x47, 0x85, 0xA5, 0xBE, 0xFB, 0xF5, 0x05, 0x4C, 0xD3, 0x3D, 0x73, 0xF4, 0xA5, 0xF1, 0xA3, 0x99, 0x98, 0x1B, + 0x84, 0x8B, 0xB3, 0x53, 0xCE, 0x4D, 0xEA, 0x5A, 0x48, 0xD2, 0xB9, 0x7E, 0xB6, 0xEB, 0x9B, 0x94, 0x6F, 0xDD, 0x44, + 0x80, 0x89, 0xD2, 0x78, 0x6D, 0xB9, 0xDA, 0x8B, 0x83, 0x49, 0xE0, 0x4D, 0x49, 0xDF, 0x6B, 0xFF, 0xF7, 0x04, 0x00, + 0x32, 0xAA, 0x1D, 0x4F, 0x8D, 0x4B, 0xDE, 0xB8, 0x0D, 0xC6, 0x54, 0x1C, 0xB2, 0xCD, 0x60, 0x29, 0x72, 0x0A, 0x7E, + 0xE7, 0xEB, 0x7A, 0xF6, 0x5B, 0x04, 0x3F, 0x5B, 0x93, 0x12, 0x0D, 0xD5, 0xFF, 0x7A, 0x41, 0x44, 0x0B, 0x37, 0x12, + 0x82, 0x3D, 0xDD, 0x1E, 0x59, 0xB9, 0xBE, 0x0F, 0x9E, 0xD6, 0xD0, 0x68, 0x69, 0x74, 0xF9, 0xB1, 0x21, 0xA3, 0x70, + 0x4F, 0xDA, 0xF8, 0x9F, 0xB9, 0x49, 0x3F, 0xC6, 0xB2, 0x69, 0xC8, 0xD8, 0x60, 0xF1, 0x6A, 0x52, 0x07, 0xFA, 0x42, + 0xFD, 0xA9, 0x06, 0xCF, 0x97, 0x4A, 0x0E, 0xC5, 0xFC, 0x63, 0x27, 0x54, 0xC8, 0xBE, 0x8B, 0x4F, 0xB6, 0x42, 0xBC, + 0xA2, 0xCC, 0x70, 0x4A, 0x6B, 0x24, 0x5B, 0x68, 0x28, 0x47, 0xFA, 0x6B, 0x89, 0x28, 0x07, 0x5D, 0xE0, 0x2C, 0x4A, + 0xD9, 0x22, 0xE3, 0xB3, 0x2F, 0xAA, 0xC2, 0xA0, 0x7C, 0x0F, 0x92, 0xC5, 0xDD, 0xB6, 0x23, 0x8F, 0x73, 0x73, 0x0F, + 0xD7, 0x73, 0x71, 0x2F, 0x0A, 0x78, 0xE8, 0x5B, 0xDB, 0xC2, 0xE0, 0xDB, 0xC9, 0x3E, 0xC3, 0x72, 0x9C, 0x14, 0xD7, + 0xD1, 0x28, 0xFD, 0xF4, 0xEE, 0xBC, 0x0E, 0x13, 0x37, 0xCA, 0x85, 0x9F, 0xB9, 0xA2, 0x0E, 0xF6, 0xE7, 0x49, 0xD1, + 0xD0, 0x11, 0x76, 0x53, 0xA3, 0x73, 0x95, 0x2A, 0x23, 0xC8, 0x0E, 0x97, 0x83, 0x07, 0x64, 0xB2, 0x51, 0xB7, 0xC8, + 0x51, 0x9F, 0xA4, 0x3E, 0x7B, 0xA4, 0x18, 0x6D, 0x99, 0xF0, 0x6E, 0xC3, 0x97, 0xAE, 0xF4, 0xB7, 0x66, 0x37, 0xFA, + 0x65, 0xFC, 0x5E, 0xE2, 0x57, 0xFA, 0x8B, 0x4C, 0x86, 0x10, 0xB4, 0x5C, 0xA4, 0xD2, 0x60, 0x83, 0x69, 0x1E, 0xFF, + 0x36, 0x9B, 0xF9, 0x84, 0xFB, 0xB8, 0x83, 0x64, 0xF1, 0x41, 0xA5, 0x25, 0x56, 0x21, 0xBA, 0x13, 0x98, 0x0C, 0x3B, + 0x04, 0xAA, 0x6C, 0x9A, 0xD4, 0xE3, 0x13, 0x15, 0x54, 0x05, 0x4C, 0x5C, 0xE1, 0x7A, 0x31, 0x5E, 0x90, 0xCF, 0x48, + 0x4E, 0x83, 0xD7, 0x7F, 0xED, 0x93, 0x22, 0xAB, 0x67, 0xE7, 0x76, 0x32, 0x64, 0xBA, 0x5A, 0x21, 0x3E, 0x30, 0x82, + 0x01, 0x41, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x01, 0x32, 0x04, 0x82, + 0x01, 0x2E, 0x30, 0x82, 0x01, 0x2A, 0x30, 0x82, 0x01, 0x26, 0x06, 0x0B, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, + 0x0C, 0x0A, 0x01, 0x02, 0xA0, 0x81, 0xEF, 0x30, 0x81, 0xEC, 0x30, 0x57, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, + 0x0D, 0x01, 0x05, 0x0D, 0x30, 0x4A, 0x30, 0x29, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x05, 0x0C, + 0x30, 0x1C, 0x04, 0x08, 0xED, 0x3E, 0xED, 0x07, 0x5C, 0x1F, 0x71, 0xAD, 0x02, 0x02, 0x08, 0x00, 0x30, 0x0C, 0x06, + 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x09, 0x05, 0x00, 0x30, 0x1D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, + 0x65, 0x03, 0x04, 0x01, 0x2A, 0x04, 0x10, 0xA7, 0x49, 0xA4, 0x6E, 0x00, 0x19, 0x75, 0x59, 0x75, 0x59, 0xBA, 0x4B, + 0xC7, 0x24, 0x88, 0x34, 0x04, 0x81, 0x90, 0xCA, 0x23, 0x82, 0xAA, 0x16, 0x57, 0x99, 0xFA, 0x94, 0x9F, 0xAE, 0x32, + 0x5C, 0x5B, 0xE7, 0x01, 0xD0, 0xED, 0xA7, 0x58, 0x57, 0x52, 0xBF, 0x57, 0x13, 0xD4, 0x15, 0xB0, 0x06, 0xF5, 0x38, + 0xCC, 0x64, 0x23, 0x09, 0xD5, 0x8C, 0x0D, 0x64, 0x31, 0xFA, 0x74, 0xAA, 0x96, 0x7E, 0x9B, 0x16, 0xCA, 0x21, 0xFD, + 0xC0, 0x54, 0x91, 0x40, 0x7F, 0xB3, 0xF2, 0xA3, 0xEC, 0xA1, 0x4A, 0x07, 0xF0, 0x87, 0x22, 0xDB, 0x8A, 0x49, 0x89, + 0xF7, 0xF2, 0x6A, 0xFC, 0x8D, 0x03, 0x6E, 0x32, 0x4F, 0xD0, 0xD8, 0x93, 0x92, 0xA5, 0xF1, 0x41, 0xBD, 0xEA, 0xE1, + 0x38, 0xA9, 0xD8, 0x9D, 0xAB, 0xB4, 0x8E, 0x4A, 0x40, 0x0E, 0xC7, 0xE3, 0xE9, 0xBF, 0x0E, 0xBA, 0x8D, 0xAA, 0x3E, + 0x93, 0x53, 0x88, 0xEE, 0x0A, 0x2C, 0x71, 0xF1, 0x61, 0x44, 0xA5, 0xAD, 0xED, 0x3E, 0xAB, 0x32, 0x9A, 0x32, 0x85, + 0x08, 0xF5, 0x8B, 0xCC, 0x15, 0x35, 0xEE, 0xFA, 0x17, 0x27, 0x97, 0x8D, 0xD9, 0x1C, 0x5E, 0x74, 0x9D, 0x7B, 0x31, + 0x25, 0x30, 0x23, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x15, 0x31, 0x16, 0x04, 0x14, 0x5F, + 0x8E, 0xAB, 0x9C, 0x5F, 0xE2, 0x3B, 0xB1, 0x5C, 0x1A, 0x36, 0x1D, 0x7D, 0xCB, 0x90, 0x45, 0x20, 0x3C, 0x3B, 0xAC, + 0x30, 0x41, 0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, + 0x04, 0x20, 0x93, 0x25, 0xC4, 0x3E, 0x2A, 0x6D, 0x4C, 0x30, 0x87, 0x0F, 0xE3, 0x5A, 0x95, 0xB0, 0xF2, 0x6C, 0xBA, + 0x07, 0x89, 0x7D, 0xFB, 0xCF, 0xCF, 0x1D, 0x54, 0xA3, 0x36, 0x24, 0x7B, 0x30, 0x97, 0xB5, 0x04, 0x08, 0xE7, 0x96, + 0x59, 0xCC, 0x42, 0x9F, 0xEF, 0xFC, 0x02, 0x02, 0x08, 0x00]); + + try { + cert.createTrustAnchorsWithKeyStore(p12Data, '123456').then((data) => { + console.log('createTrustAnchorsWithKeyStore sucess, the num of result is :' + JSON.stringify(data.length)); + }).catch((err: BusinessError) => { + console.error('createTrustAnchorsWithKeyStore failed, error :' + JSON.stringify(err)); + }) + } catch (error) { + console.error('createTrustAnchorsWithKeyStore failed, error :' + JSON.stringify(error)); + } +} + + +// [End trust_array_constructed_from_p12_file_during_validation] +@Entry +@Component +struct Index { + @State message: string = 'CreateTrustanchorFromP12'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button('Call CreateTrustanchorFromP12') + .width('70%') + .onClick(() => { + try { + test(); + this.message = 'Call Success'; + } catch { + this.message = 'Call Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCerchainvalidatorObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCerchainvalidatorObject.ets old mode 100755 new mode 100644 index 1b87d7c7f6..4dd9b49955 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCerchainvalidatorObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCerchainvalidatorObject.ets @@ -1,154 +1,154 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - -// [Start certificate_chain_validator_object_creation_and_validation] -import { cert } from '@kit.DeviceCertificateKit'; -import { util } from '@kit.ArkTS'; - -// CA数据,这只是一个示例,需要根据具体业务来赋值 -let caCertData = '-----BEGIN CERTIFICATE-----\n' + - 'MIIDgTCCAmmgAwIBAgIGAXKnJjrAMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNVBAYT\n' + - 'AkNOMQ8wDQYDVQQIDAbpmZXopb8xDzANBgNVBAcMBuilv+WuiTEPMA0GA1UECgwG\n' + - '5rWL6K+VMRUwEwYDVQQDDAzkuK3mlofmtYvor5UwHhcNMjUwMjIwMDI1NjMxWhcN\n' + - 'MzUwMjE4MDI1NjMxWjBXMQswCQYDVQQGEwJDTjEPMA0GA1UECAwG6ZmV6KW/MQ8w\n' + - 'DQYDVQQHDAbopb/lrokxDzANBgNVBAoMBua1i+ivlTEVMBMGA1UEAwwM5Lit5paH\n' + - '5rWL6K+VMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyY30ubE33Zmc\n' + - 'BBM4OIpD1UuDVKynC4xNBK4v79vnlc4ElmRZD4RjkS612DtpaUzt/yHMZXmJTdqg\n' + - '2jq7UG4sQc0G3uNGIXdUpRZpnUYGVftuZMxHaNOb+IgDkZzaO3Dk33piOpH/X/Ke\n' + - 'OosCbm7eBL+y+wRhUsLSCEasEsIvW3edHuYLrfz3MzwY/9AmnwqDGdRJ5rPayODD\n' + - 'HH0yw9JuRkdMacN8omVX8jBfJeI8KafcQW8MJz+Y0qyQyiZ6A81AQSVfT+6Sk2U3\n' + - 'UqeSTmtdIL1u29HfYLwYGHey+1Ro2wxqnMsFKIdKu2dDMDQZx61pER/dFtPYFlS7\n' + - '/uh3mi9HUQIDAQABo1MwUTAdBgNVHQ4EFgQUGDykmR825RPNFIEQaFzUqkr+CIow\n' + - 'HwYDVR0jBBgwFoAUGDykmR825RPNFIEQaFzUqkr+CIowDwYDVR0TAQH/BAUwAwEB\n' + - '/zANBgkqhkiG9w0BAQsFAAOCAQEAXjlmYKjBz1ajWywZNlN+LVRXNx7bS4TYtOc2\n' + - 'ME4N1ls6yjWSLtBe4DdkBqZ2HwrVW4dg5xZdAS/T0v/rRiGbX6iUFRV9WCTdtLZB\n' + - 'HKNh7vU39F7mgTaaWXQK/+6NeLKMzwJENRRaESI/sXeKE6irfJgYuq3NH8GGFd+w\n' + - 'HnvVBHRb6WSlY2s5Li7t6lj40UbwOljnqzRQvBeX57rOnzJgVKND3oY9pex/05Oe\n' + - '96x+qc2iqZbu54A6NYCTj/65EEKoj5rYxPXMV4FegV42ouaLJJoS+cEEY7w+ixcl\n' + - '04TjtjEdhTZiJCmI0RK50H2SWC0t9qkFewM3CCWTHY5ygPtMGA==\n' + - '-----END CERTIFICATE-----\n'; - -// 二级CA证书数据,这只是一个示例,需要根据具体业务来赋值 -let secondCaCertData = '-----BEGIN CERTIFICATE-----\n' + - 'MIIDgTCCAmmgAwIBAgIGAXKnJjrBMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNVBAYT\n' + - 'AkNOMQ8wDQYDVQQIDAbpmZXopb8xDzANBgNVBAcMBuilv+WuiTEPMA0GA1UECgwG\n' + - '5rWL6K+VMRUwEwYDVQQDDAzkuK3mlofmtYvor5UwHhcNMjUwMjIwMDI1NjU3WhcN\n' + - 'MzUwMjE4MDI1NjU3WjBXMQswCQYDVQQGEwJDTjEPMA0GA1UECAwG6ZmV6KW/MQ8w\n' + - 'DQYDVQQHDAbopb/lrokxDzANBgNVBAoMBua1i+ivlTEVMBMGA1UEAwwM5Lit5paH\n' + - '5rWL6K+VMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxSL5L7fwMaRF\n' + - 'RiT1l7kpzaAqZe33/3lgexoMfGiIFarIhYyYJsmOJKes2uLSnPeqEtscrXmFQiIG\n' + - '0srmwrriGgo3oxDp4/5i1FhCf3FqZUwD/RJhtVmkHT0HoYl4cpt/dJSF/e5vxt/J\n' + - '2Z1eRIQOj9DzyqET6+ONQmfVOyzEH6xlpXHZLvykSZ7ytPp25LxULPWjTmpDOPRq\n' + - 'vkSMaH4H3mPw/Z9r0MVKP7DgAZMl2yVudHp785AMTVD0L9zWGHf3sek25ek5nv2r\n' + - 'SlB21MTBpvd8GC/iGns4V3Bvf75WAMgpGghAkRRyADeqt5Hw+x9BIb9FcfE+h6n+\n' + - '6EF6FPa8GQIDAQABo1MwUTAdBgNVHQ4EFgQUjt2Crk/j6W8WCdHWyz4H+Q2/3PYw\n' + - 'HwYDVR0jBBgwFoAUGDykmR825RPNFIEQaFzUqkr+CIowDwYDVR0TAQH/BAUwAwEB\n' + - '/zANBgkqhkiG9w0BAQsFAAOCAQEAksPHMuVF9e2GMVlaSe1Ao9D1KrJvKNaFZPCI\n' + - 'lQe2CDsX+Qu7sQj4SML5vvWFLtcAp6ZovqUyEM0PtZWVSjPCRTMJ3ofBPwnXvQ2N\n' + - '7J7NCDA227MQabXeN3jMhkcAzlpdO5poTnobPF4xRqb39jM7otnNJsujvzdDab2l\n' + - 'LiP4eU5TrEaF2lwidBWJX0VoLrRpqzQhiWXGMpCBBugP5U+bFs20wezJBG19WYyc\n' + - '2xKKfvyIcxrpmvjLZl8HddS7Ot1CKXyc8U9QZBGAlPwOXu8juppcEtjJyl36EnvF\n' + - 'YAcwrXOAtCiNpX3UnLUbG8GtpOOWQWCt+x1gKmA6V0jbqQmqcw==\n' + - '-----END CERTIFICATE-----\n'; - -// 证书链校验器示例。在这个示例中,验证了一个二级证书链 -function certChainValidatorSample(): void { - let textEncoder = new util.TextEncoder(); - // 证书链校验器算法。目前仅支持PKIX - let algorithm = 'PKIX'; - - // 创建一个证书链校验器实例 - let validator = cert.createCertChainValidator(algorithm); - - // CA证书数据 - let uint8ArrayOfCaCertData = textEncoder.encodeInto(caCertData); - - // CA证书数据的长度 - let uint8ArrayOfCaCertDataLen = new Uint8Array(new Uint16Array([uint8ArrayOfCaCertData.byteLength]).buffer); - - // 二级CA证书数据 - let uint8ArrayOf2ndCaCertData = textEncoder.encodeInto(secondCaCertData); - - // 二级CA证书数据的长度 - let uint8ArrayOf2ndCaCertDataLen = new Uint8Array(new Uint16Array([uint8ArrayOf2ndCaCertData.byteLength]).buffer); - - // 证书链二进制数据:二级CA证书数据长度+二级CA证书数据+CA证书数据长度+CA证书数据(L-V格式) - let encodingData = new Uint8Array(uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + - uint8ArrayOfCaCertDataLen.length + uint8ArrayOfCaCertData.length); - for (let i = 0; i < uint8ArrayOf2ndCaCertDataLen.length; i++) { - encodingData[i] = uint8ArrayOf2ndCaCertDataLen[i]; - } - for (let i = 0; i < uint8ArrayOf2ndCaCertData.length; i++) { - encodingData[uint8ArrayOf2ndCaCertDataLen.length + i] = uint8ArrayOf2ndCaCertData[i]; - } - for (let i = 0; i < uint8ArrayOfCaCertDataLen.length; i++) { - encodingData[uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + i] = - uint8ArrayOfCaCertDataLen[i]; - } - for (let i = 0; i < uint8ArrayOfCaCertData.length; i++) { - encodingData[uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + - uint8ArrayOfCaCertDataLen.length + i] = uint8ArrayOfCaCertData[i]; - } - - let certChainData: cert.CertChainData = { - // Uint8Array类型:L-V格式(证书数据长度-证书数据) - data: encodingData, - // 证书的数量。本例中为2 - count: 2, - // 证书格式。仅支持 PEM 和 DER。在此示例中,证书为 PEM 格式 - encodingFormat: cert.EncodingFormat.FORMAT_PEM - }; - - // 验证证书链 - validator.validate(certChainData, (err, data) => { - if (err != null) { - // 校验失败 - console.error(`validate failed, errCode: ${err.code}, errMsg: ${err.message}`); - } else { - // 校验成功 - console.log('validate success'); - } - }); -} - - -// [End certificate_chain_validator_object_creation_and_validation] -@Entry -@Component -struct Index { - @State message: string = 'CreateVerifyCerchainvalidatorObject'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button('Call CreateVerifyCerchainvalidatorObject') - .width('70%') - .onClick(() => { - try { - certChainValidatorSample(); - this.message = 'Call Success'; - } catch { - this.message = 'Call Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +// [Start certificate_chain_validator_object_creation_and_validation] +import { cert } from '@kit.DeviceCertificateKit'; +import { util } from '@kit.ArkTS'; + +// CA数据,这只是一个示例,需要根据具体业务来赋值 +let caCertData = '-----BEGIN CERTIFICATE-----\n' + + 'MIIDgTCCAmmgAwIBAgIGAXKnJjrAMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNVBAYT\n' + + 'AkNOMQ8wDQYDVQQIDAbpmZXopb8xDzANBgNVBAcMBuilv+WuiTEPMA0GA1UECgwG\n' + + '5rWL6K+VMRUwEwYDVQQDDAzkuK3mlofmtYvor5UwHhcNMjUwMjIwMDI1NjMxWhcN\n' + + 'MzUwMjE4MDI1NjMxWjBXMQswCQYDVQQGEwJDTjEPMA0GA1UECAwG6ZmV6KW/MQ8w\n' + + 'DQYDVQQHDAbopb/lrokxDzANBgNVBAoMBua1i+ivlTEVMBMGA1UEAwwM5Lit5paH\n' + + '5rWL6K+VMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyY30ubE33Zmc\n' + + 'BBM4OIpD1UuDVKynC4xNBK4v79vnlc4ElmRZD4RjkS612DtpaUzt/yHMZXmJTdqg\n' + + '2jq7UG4sQc0G3uNGIXdUpRZpnUYGVftuZMxHaNOb+IgDkZzaO3Dk33piOpH/X/Ke\n' + + 'OosCbm7eBL+y+wRhUsLSCEasEsIvW3edHuYLrfz3MzwY/9AmnwqDGdRJ5rPayODD\n' + + 'HH0yw9JuRkdMacN8omVX8jBfJeI8KafcQW8MJz+Y0qyQyiZ6A81AQSVfT+6Sk2U3\n' + + 'UqeSTmtdIL1u29HfYLwYGHey+1Ro2wxqnMsFKIdKu2dDMDQZx61pER/dFtPYFlS7\n' + + '/uh3mi9HUQIDAQABo1MwUTAdBgNVHQ4EFgQUGDykmR825RPNFIEQaFzUqkr+CIow\n' + + 'HwYDVR0jBBgwFoAUGDykmR825RPNFIEQaFzUqkr+CIowDwYDVR0TAQH/BAUwAwEB\n' + + '/zANBgkqhkiG9w0BAQsFAAOCAQEAXjlmYKjBz1ajWywZNlN+LVRXNx7bS4TYtOc2\n' + + 'ME4N1ls6yjWSLtBe4DdkBqZ2HwrVW4dg5xZdAS/T0v/rRiGbX6iUFRV9WCTdtLZB\n' + + 'HKNh7vU39F7mgTaaWXQK/+6NeLKMzwJENRRaESI/sXeKE6irfJgYuq3NH8GGFd+w\n' + + 'HnvVBHRb6WSlY2s5Li7t6lj40UbwOljnqzRQvBeX57rOnzJgVKND3oY9pex/05Oe\n' + + '96x+qc2iqZbu54A6NYCTj/65EEKoj5rYxPXMV4FegV42ouaLJJoS+cEEY7w+ixcl\n' + + '04TjtjEdhTZiJCmI0RK50H2SWC0t9qkFewM3CCWTHY5ygPtMGA==\n' + + '-----END CERTIFICATE-----\n'; + +// 二级CA证书数据,这只是一个示例,需要根据具体业务来赋值 +let secondCaCertData = '-----BEGIN CERTIFICATE-----\n' + + 'MIIDgTCCAmmgAwIBAgIGAXKnJjrBMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNVBAYT\n' + + 'AkNOMQ8wDQYDVQQIDAbpmZXopb8xDzANBgNVBAcMBuilv+WuiTEPMA0GA1UECgwG\n' + + '5rWL6K+VMRUwEwYDVQQDDAzkuK3mlofmtYvor5UwHhcNMjUwMjIwMDI1NjU3WhcN\n' + + 'MzUwMjE4MDI1NjU3WjBXMQswCQYDVQQGEwJDTjEPMA0GA1UECAwG6ZmV6KW/MQ8w\n' + + 'DQYDVQQHDAbopb/lrokxDzANBgNVBAoMBua1i+ivlTEVMBMGA1UEAwwM5Lit5paH\n' + + '5rWL6K+VMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxSL5L7fwMaRF\n' + + 'RiT1l7kpzaAqZe33/3lgexoMfGiIFarIhYyYJsmOJKes2uLSnPeqEtscrXmFQiIG\n' + + '0srmwrriGgo3oxDp4/5i1FhCf3FqZUwD/RJhtVmkHT0HoYl4cpt/dJSF/e5vxt/J\n' + + '2Z1eRIQOj9DzyqET6+ONQmfVOyzEH6xlpXHZLvykSZ7ytPp25LxULPWjTmpDOPRq\n' + + 'vkSMaH4H3mPw/Z9r0MVKP7DgAZMl2yVudHp785AMTVD0L9zWGHf3sek25ek5nv2r\n' + + 'SlB21MTBpvd8GC/iGns4V3Bvf75WAMgpGghAkRRyADeqt5Hw+x9BIb9FcfE+h6n+\n' + + '6EF6FPa8GQIDAQABo1MwUTAdBgNVHQ4EFgQUjt2Crk/j6W8WCdHWyz4H+Q2/3PYw\n' + + 'HwYDVR0jBBgwFoAUGDykmR825RPNFIEQaFzUqkr+CIowDwYDVR0TAQH/BAUwAwEB\n' + + '/zANBgkqhkiG9w0BAQsFAAOCAQEAksPHMuVF9e2GMVlaSe1Ao9D1KrJvKNaFZPCI\n' + + 'lQe2CDsX+Qu7sQj4SML5vvWFLtcAp6ZovqUyEM0PtZWVSjPCRTMJ3ofBPwnXvQ2N\n' + + '7J7NCDA227MQabXeN3jMhkcAzlpdO5poTnobPF4xRqb39jM7otnNJsujvzdDab2l\n' + + 'LiP4eU5TrEaF2lwidBWJX0VoLrRpqzQhiWXGMpCBBugP5U+bFs20wezJBG19WYyc\n' + + '2xKKfvyIcxrpmvjLZl8HddS7Ot1CKXyc8U9QZBGAlPwOXu8juppcEtjJyl36EnvF\n' + + 'YAcwrXOAtCiNpX3UnLUbG8GtpOOWQWCt+x1gKmA6V0jbqQmqcw==\n' + + '-----END CERTIFICATE-----\n'; + +// 证书链校验器示例。在这个示例中,验证了一个二级证书链 +function certChainValidatorSample(): void { + let textEncoder = new util.TextEncoder(); + // 证书链校验器算法。目前仅支持PKIX + let algorithm = 'PKIX'; + + // 创建一个证书链校验器实例 + let validator = cert.createCertChainValidator(algorithm); + + // CA证书数据 + let uint8ArrayOfCaCertData = textEncoder.encodeInto(caCertData); + + // CA证书数据的长度 + let uint8ArrayOfCaCertDataLen = new Uint8Array(new Uint16Array([uint8ArrayOfCaCertData.byteLength]).buffer); + + // 二级CA证书数据 + let uint8ArrayOf2ndCaCertData = textEncoder.encodeInto(secondCaCertData); + + // 二级CA证书数据的长度 + let uint8ArrayOf2ndCaCertDataLen = new Uint8Array(new Uint16Array([uint8ArrayOf2ndCaCertData.byteLength]).buffer); + + // 证书链二进制数据:二级CA证书数据长度+二级CA证书数据+CA证书数据长度+CA证书数据(L-V格式) + let encodingData = new Uint8Array(uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + + uint8ArrayOfCaCertDataLen.length + uint8ArrayOfCaCertData.length); + for (let i = 0; i < uint8ArrayOf2ndCaCertDataLen.length; i++) { + encodingData[i] = uint8ArrayOf2ndCaCertDataLen[i]; + } + for (let i = 0; i < uint8ArrayOf2ndCaCertData.length; i++) { + encodingData[uint8ArrayOf2ndCaCertDataLen.length + i] = uint8ArrayOf2ndCaCertData[i]; + } + for (let i = 0; i < uint8ArrayOfCaCertDataLen.length; i++) { + encodingData[uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + i] = + uint8ArrayOfCaCertDataLen[i]; + } + for (let i = 0; i < uint8ArrayOfCaCertData.length; i++) { + encodingData[uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + + uint8ArrayOfCaCertDataLen.length + i] = uint8ArrayOfCaCertData[i]; + } + + let certChainData: cert.CertChainData = { + // Uint8Array类型:L-V格式(证书数据长度-证书数据) + data: encodingData, + // 证书的数量。本例中为2 + count: 2, + // 证书格式。仅支持 PEM 和 DER。在此示例中,证书为 PEM 格式 + encodingFormat: cert.EncodingFormat.FORMAT_PEM + }; + + // 验证证书链 + validator.validate(certChainData, (err, data) => { + if (err != null) { + // 校验失败 + console.error(`validate failed, errCode: ${err.code}, errMsg: ${err.message}`); + } else { + // 校验成功 + console.log('validate success'); + } + }); +} + + +// [End certificate_chain_validator_object_creation_and_validation] +@Entry +@Component +struct Index { + @State message: string = 'CreateVerifyCerchainvalidatorObject'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button('Call CreateVerifyCerchainvalidatorObject') + .width('70%') + .onClick(() => { + try { + certChainValidatorSample(); + this.message = 'Call Success'; + } catch { + this.message = 'Call Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCertchainObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCertchainObject.ets old mode 100755 new mode 100644 index 9081b2d61e..6307cb4d1e --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCertchainObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCertchainObject.ets @@ -1,149 +1,149 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start certificate_chain_object_creation_and_validation] - -import { cert } from '@kit.DeviceCertificateKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { util } from '@kit.ArkTS'; - -let certChainData = '-----BEGIN CERTIFICATE-----\n' + - 'MIID6jCCAtKgAwIBAgIIIM2q/TmRoLcwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE\n' + - 'BhMCRU4xEDAOBgNVBAgTB0VuZ2xhbmQxDzANBgNVBAcTBkxvbmRvbjEMMAoGA1UE\n' + - 'ChMDdHMyMQwwCgYDVQQLEwN0czIxDDAKBgNVBAMTA3RzMjAeFw0yMzEyMDUwNzM5\n' + - 'MDBaFw0yNDEwMzEyMzU5MDBaMGExCzAJBgNVBAYTAkNOMRAwDgYDVQQIEwdKaWFu\n' + - 'Z3N1MRAwDgYDVQQHEwdOYW5qaW5nMQwwCgYDVQQKEwN0czMxDDAKBgNVBAsTA3Rz\n' + - 'MzESMBAGA1UEAxMJMTI3LjAuMC4xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n' + - 'CgKCAQEAtt+2QxUevbolYLp51QGcUpageI4fwGLIqv4fj4aoVnHFOOBqVOVpfCLR\n' + - 'p26LFV/F8ebwPyo8YEBKSwXzMD1573rMSbaH9BalscH5lZYAbetXoio6YRvzlcmc\n' + - 'rVvLBNMeVnxY86xHpo0MTNyP7W024rZsxWO98xFQVdoiaBC+7+midlisx2Y+7u0j\n' + - 'zT9GjeUP6JLdLFUZJKUPSTK3jVzw9v1eZQZKYoNfU6vFMd6ndtwW6qEnwpzmmX/U\n' + - 'T+p5ThAMH593zszlz330nTSXBjIsGkyvOz9gSB0Z0LAuJj06XUNhGL5xKJYKbdI3\n' + - '8MFQFJKvRHfgTAvVsvAvpBUM2DuBKwIDAQABo4GsMIGpMAkGA1UdEwQCMAAwHQYD\n' + - 'VR0OBBYEFDfsHTMZwoA6eaDFlBUyDpka+sYtMAsGA1UdDwQEAwID+DAnBgNVHSUE\n' + - 'IDAeBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMEMBQGA1UdEQQNMAuCCTEy\n' + - 'Ny4wLjAuMTARBglghkgBhvhCAQEEBAMCBkAwHgYJYIZIAYb4QgENBBEWD3hjYSBj\n' + - 'ZXJ0aWZpY2F0ZTANBgkqhkiG9w0BAQsFAAOCAQEAp5vTvXrt8ZpgRJVtzv9ss0lJ\n' + - 'izp1fJf+ft5cDXrs7TSD5oHrSW2vk/ZieIMhexU4LFwhs4OE7jK6pgI48Dseqxx7\n' + - 'B/KktxhVMJUmVXd9Ayjp6f+BtZlIk0cArPuoXToXjsV8caTGBXHRdzxpAk/w9syc\n' + - 'GYrbH9TrdNMuTizOb+k268oKXUageZNxHmd7YvOXkcNgrd29jzwXKDYYiUa1DISz\n' + - 'DnYaJOgPt0B/5izhoWNK7GhJDy9KEuLURcTSWFysbbnljwO9INPT9MmlS83PdAgN\n' + - 'iS8VXF4pce1W9U5jH7d7k0JDVSXybebe1iPFphsZpYM/NE+jap+mPy1nTCbf9g==\n' + - '-----END CERTIFICATE-----\n' + - '-----BEGIN CERTIFICATE-----\n' + - 'MIIC0zCCAoWgAwIBAgIIXpLoPpQVWnkwBQYDK2VwMFoxCzAJBgNVBAYTAkVOMRAw\n' + - 'DgYDVQQIEwdFbmdsYW5kMQ8wDQYDVQQHEwZMb25kb24xDDAKBgNVBAoTA3RzMTEM\n' + - 'MAoGA1UECxMDdHMxMQwwCgYDVQQDEwN0czEwHhcNMjMxMjA1MDczNzAwWhcNMjQw\n' + - 'OTAxMjM1OTAwWjBaMQswCQYDVQQGEwJFTjEQMA4GA1UECBMHRW5nbGFuZDEPMA0G\n' + - 'A1UEBxMGTG9uZG9uMQwwCgYDVQQKEwN0czIxDDAKBgNVBAsTA3RzMjEMMAoGA1UE\n' + - 'AxMDdHMyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtt+2QxUevbol\n' + - 'YLp51QGcUpageI4fwGLIqv4fj4aoVnHFOOBqVOVpfCLRp26LFV/F8ebwPyo8YEBK\n' + - 'SwXzMD1573rMSbaH9BalscH5lZYAbetXoio6YRvzlcmcrVvLBNMeVnxY86xHpo0M\n' + - 'TNyP7W024rZsxWO98xFQVdoiaBC+7+midlisx2Y+7u0jzT9GjeUP6JLdLFUZJKUP\n' + - 'STK3jVzw9v1eZQZKYoNfU6vFMd6ndtwW6qEnwpzmmX/UT+p5ThAMH593zszlz330\n' + - 'nTSXBjIsGkyvOz9gSB0Z0LAuJj06XUNhGL5xKJYKbdI38MFQFJKvRHfgTAvVsvAv\n' + - 'pBUM2DuBKwIDAQABo28wbTAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBQ37B0zGcKA\n' + - 'OnmgxZQVMg6ZGvrGLTALBgNVHQ8EBAMCAQYwEQYJYIZIAYb4QgEBBAQDAgAHMB4G\n' + - 'CWCGSAGG+EIBDQQRFg94Y2EgY2VydGlmaWNhdGUwBQYDK2VwA0EAuasLBe55YgvF\n' + - 'b4wmHeohylc9r8cFGS1LNQ5UcSn3sGqMYf6ehnef16NLuCW6upHCs8Sui4iAMvsP\n' + - 'uKPWR9dKBA==\n' + - '-----END CERTIFICATE-----\n' + - '-----BEGIN CERTIFICATE-----\n' + - 'MIIB3zCCAZGgAwIBAgIIWQvOEDl+ya4wBQYDK2VwMFoxCzAJBgNVBAYTAkVOMRAw\n' + - 'DgYDVQQIEwdFbmdsYW5kMQ8wDQYDVQQHEwZMb25kb24xDDAKBgNVBAoTA3RzMTEM\n' + - 'MAoGA1UECxMDdHMxMQwwCgYDVQQDEwN0czEwHhcNMjMxMjA1MDAwMDAwWhcNMjQx\n' + - 'MjA0MjM1OTU5WjBaMQswCQYDVQQGEwJFTjEQMA4GA1UECBMHRW5nbGFuZDEPMA0G\n' + - 'A1UEBxMGTG9uZG9uMQwwCgYDVQQKEwN0czExDDAKBgNVBAsTA3RzMTEMMAoGA1UE\n' + - 'AxMDdHMxMCowBQYDK2VwAyEAuxadj1ww0LqPN24zr28jcSOlSWAe0QdLyRF+ZgG6\n' + - 'klKjdTBzMBIGA1UdEwEB/wQIMAYBAf8CARQwHQYDVR0OBBYEFNSgpoQvfxR8A1Y4\n' + - 'St8NjOHkRpm4MAsGA1UdDwQEAwIBBjARBglghkgBhvhCAQEEBAMCAAcwHgYJYIZI\n' + - 'AYb4QgENBBEWD3hjYSBjZXJ0aWZpY2F0ZTAFBgMrZXADQQAblBgoa72X/K13WOvc\n' + - 'KW0fqBgFKvLy85hWD6Ufi61k4ProQiZzMK+0+y9jReKelPx/zRdCCgSbQroAR2mV\n' + - 'xjoE\n' + - '-----END CERTIFICATE-----\n'; - -async function sample() { - let textEncoder = new util.TextEncoder(); - // 证书链二进制数据,需业务自行赋值 - const encodingBlob: cert.EncodingBlob = { - data: textEncoder.encodeInto(certChainData), - // 根据encodingData的格式进行赋值,支持FORMAT_PEM、FORMAT_DER和FORMAT_PKCS7 - encodingFormat: cert.EncodingFormat.FORMAT_PEM - }; - let x509CertChain: cert.X509CertChain = {} as cert.X509CertChain; - try { - x509CertChain = await cert.createX509CertChain(encodingBlob); - } catch (err) { - let e: BusinessError = err as BusinessError; - console.error(`createX509CertChain failed, errCode: ${e.code}, errMsg: ${e.message}`); - } - - try { - let certList = x509CertChain.getCertList(); - } catch (err) { - let e: BusinessError = err as BusinessError; - console.error(`X509CertChain getCertList failed, errCode: ${e.code}, errMsg: ${e.message}`); - } - - // 证书链校验数据,需业务自行赋值 - const param: cert.CertChainValidationParameters = { - date: '20231212080000Z', - trustAnchors: [{ - CAPubKey: new Uint8Array([0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00, 0xbb, 0x16, - 0x9d, 0x8f, 0x5c, 0x30, 0xd0, 0xba, 0x8f, 0x37, 0x6e, 0x33, 0xaf, 0x6f, 0x23, 0x71, 0x23, 0xa5, 0x49, 0x60, - 0x1e, 0xd1, 0x07, 0x4b, 0xc9, 0x11, 0x7e, 0x66, 0x01, 0xba, 0x92, 0x52]), - CASubject: new Uint8Array([0x30, 0x5a, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x45, - 0x4e, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x07, 0x45, 0x6e, 0x67, 0x6c, 0x61, 0x6e, - 0x64, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x06, 0x4c, 0x6f, 0x6e, 0x64, 0x6f, 0x6e, - 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x03, 0x74, 0x73, 0x31, 0x31, 0x0c, 0x30, 0x0a, - 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x03, 0x74, 0x73, 0x31, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x13, 0x03, 0x74, 0x73, 0x31]), - }] - }; - try { - const validationRes = await x509CertChain.validate(param); - console.log('X509CertChain validate success'); - } catch (err) { - console.error('X509CertChain validate failed'); - } -} - - -// [End certificate_chain_object_creation_and_validation] -@Entry -@Component -struct Index { - @State message: string = 'CreateVerifyCertchainObject'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button('Call CreateVerifyCertchainObject') - .width('70%') - .onClick(()=>{ - try { - sample(); - this.message = 'Call Success'; - } catch { - this.message = 'Call Fail'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start certificate_chain_object_creation_and_validation] + +import { cert } from '@kit.DeviceCertificateKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { util } from '@kit.ArkTS'; + +let certChainData = '-----BEGIN CERTIFICATE-----\n' + + 'MIID6jCCAtKgAwIBAgIIIM2q/TmRoLcwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE\n' + + 'BhMCRU4xEDAOBgNVBAgTB0VuZ2xhbmQxDzANBgNVBAcTBkxvbmRvbjEMMAoGA1UE\n' + + 'ChMDdHMyMQwwCgYDVQQLEwN0czIxDDAKBgNVBAMTA3RzMjAeFw0yMzEyMDUwNzM5\n' + + 'MDBaFw0yNDEwMzEyMzU5MDBaMGExCzAJBgNVBAYTAkNOMRAwDgYDVQQIEwdKaWFu\n' + + 'Z3N1MRAwDgYDVQQHEwdOYW5qaW5nMQwwCgYDVQQKEwN0czMxDDAKBgNVBAsTA3Rz\n' + + 'MzESMBAGA1UEAxMJMTI3LjAuMC4xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n' + + 'CgKCAQEAtt+2QxUevbolYLp51QGcUpageI4fwGLIqv4fj4aoVnHFOOBqVOVpfCLR\n' + + 'p26LFV/F8ebwPyo8YEBKSwXzMD1573rMSbaH9BalscH5lZYAbetXoio6YRvzlcmc\n' + + 'rVvLBNMeVnxY86xHpo0MTNyP7W024rZsxWO98xFQVdoiaBC+7+midlisx2Y+7u0j\n' + + 'zT9GjeUP6JLdLFUZJKUPSTK3jVzw9v1eZQZKYoNfU6vFMd6ndtwW6qEnwpzmmX/U\n' + + 'T+p5ThAMH593zszlz330nTSXBjIsGkyvOz9gSB0Z0LAuJj06XUNhGL5xKJYKbdI3\n' + + '8MFQFJKvRHfgTAvVsvAvpBUM2DuBKwIDAQABo4GsMIGpMAkGA1UdEwQCMAAwHQYD\n' + + 'VR0OBBYEFDfsHTMZwoA6eaDFlBUyDpka+sYtMAsGA1UdDwQEAwID+DAnBgNVHSUE\n' + + 'IDAeBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMEMBQGA1UdEQQNMAuCCTEy\n' + + 'Ny4wLjAuMTARBglghkgBhvhCAQEEBAMCBkAwHgYJYIZIAYb4QgENBBEWD3hjYSBj\n' + + 'ZXJ0aWZpY2F0ZTANBgkqhkiG9w0BAQsFAAOCAQEAp5vTvXrt8ZpgRJVtzv9ss0lJ\n' + + 'izp1fJf+ft5cDXrs7TSD5oHrSW2vk/ZieIMhexU4LFwhs4OE7jK6pgI48Dseqxx7\n' + + 'B/KktxhVMJUmVXd9Ayjp6f+BtZlIk0cArPuoXToXjsV8caTGBXHRdzxpAk/w9syc\n' + + 'GYrbH9TrdNMuTizOb+k268oKXUageZNxHmd7YvOXkcNgrd29jzwXKDYYiUa1DISz\n' + + 'DnYaJOgPt0B/5izhoWNK7GhJDy9KEuLURcTSWFysbbnljwO9INPT9MmlS83PdAgN\n' + + 'iS8VXF4pce1W9U5jH7d7k0JDVSXybebe1iPFphsZpYM/NE+jap+mPy1nTCbf9g==\n' + + '-----END CERTIFICATE-----\n' + + '-----BEGIN CERTIFICATE-----\n' + + 'MIIC0zCCAoWgAwIBAgIIXpLoPpQVWnkwBQYDK2VwMFoxCzAJBgNVBAYTAkVOMRAw\n' + + 'DgYDVQQIEwdFbmdsYW5kMQ8wDQYDVQQHEwZMb25kb24xDDAKBgNVBAoTA3RzMTEM\n' + + 'MAoGA1UECxMDdHMxMQwwCgYDVQQDEwN0czEwHhcNMjMxMjA1MDczNzAwWhcNMjQw\n' + + 'OTAxMjM1OTAwWjBaMQswCQYDVQQGEwJFTjEQMA4GA1UECBMHRW5nbGFuZDEPMA0G\n' + + 'A1UEBxMGTG9uZG9uMQwwCgYDVQQKEwN0czIxDDAKBgNVBAsTA3RzMjEMMAoGA1UE\n' + + 'AxMDdHMyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtt+2QxUevbol\n' + + 'YLp51QGcUpageI4fwGLIqv4fj4aoVnHFOOBqVOVpfCLRp26LFV/F8ebwPyo8YEBK\n' + + 'SwXzMD1573rMSbaH9BalscH5lZYAbetXoio6YRvzlcmcrVvLBNMeVnxY86xHpo0M\n' + + 'TNyP7W024rZsxWO98xFQVdoiaBC+7+midlisx2Y+7u0jzT9GjeUP6JLdLFUZJKUP\n' + + 'STK3jVzw9v1eZQZKYoNfU6vFMd6ndtwW6qEnwpzmmX/UT+p5ThAMH593zszlz330\n' + + 'nTSXBjIsGkyvOz9gSB0Z0LAuJj06XUNhGL5xKJYKbdI38MFQFJKvRHfgTAvVsvAv\n' + + 'pBUM2DuBKwIDAQABo28wbTAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBQ37B0zGcKA\n' + + 'OnmgxZQVMg6ZGvrGLTALBgNVHQ8EBAMCAQYwEQYJYIZIAYb4QgEBBAQDAgAHMB4G\n' + + 'CWCGSAGG+EIBDQQRFg94Y2EgY2VydGlmaWNhdGUwBQYDK2VwA0EAuasLBe55YgvF\n' + + 'b4wmHeohylc9r8cFGS1LNQ5UcSn3sGqMYf6ehnef16NLuCW6upHCs8Sui4iAMvsP\n' + + 'uKPWR9dKBA==\n' + + '-----END CERTIFICATE-----\n' + + '-----BEGIN CERTIFICATE-----\n' + + 'MIIB3zCCAZGgAwIBAgIIWQvOEDl+ya4wBQYDK2VwMFoxCzAJBgNVBAYTAkVOMRAw\n' + + 'DgYDVQQIEwdFbmdsYW5kMQ8wDQYDVQQHEwZMb25kb24xDDAKBgNVBAoTA3RzMTEM\n' + + 'MAoGA1UECxMDdHMxMQwwCgYDVQQDEwN0czEwHhcNMjMxMjA1MDAwMDAwWhcNMjQx\n' + + 'MjA0MjM1OTU5WjBaMQswCQYDVQQGEwJFTjEQMA4GA1UECBMHRW5nbGFuZDEPMA0G\n' + + 'A1UEBxMGTG9uZG9uMQwwCgYDVQQKEwN0czExDDAKBgNVBAsTA3RzMTEMMAoGA1UE\n' + + 'AxMDdHMxMCowBQYDK2VwAyEAuxadj1ww0LqPN24zr28jcSOlSWAe0QdLyRF+ZgG6\n' + + 'klKjdTBzMBIGA1UdEwEB/wQIMAYBAf8CARQwHQYDVR0OBBYEFNSgpoQvfxR8A1Y4\n' + + 'St8NjOHkRpm4MAsGA1UdDwQEAwIBBjARBglghkgBhvhCAQEEBAMCAAcwHgYJYIZI\n' + + 'AYb4QgENBBEWD3hjYSBjZXJ0aWZpY2F0ZTAFBgMrZXADQQAblBgoa72X/K13WOvc\n' + + 'KW0fqBgFKvLy85hWD6Ufi61k4ProQiZzMK+0+y9jReKelPx/zRdCCgSbQroAR2mV\n' + + 'xjoE\n' + + '-----END CERTIFICATE-----\n'; + +async function sample() { + let textEncoder = new util.TextEncoder(); + // 证书链二进制数据,需业务自行赋值 + const encodingBlob: cert.EncodingBlob = { + data: textEncoder.encodeInto(certChainData), + // 根据encodingData的格式进行赋值,支持FORMAT_PEM、FORMAT_DER和FORMAT_PKCS7 + encodingFormat: cert.EncodingFormat.FORMAT_PEM + }; + let x509CertChain: cert.X509CertChain = {} as cert.X509CertChain; + try { + x509CertChain = await cert.createX509CertChain(encodingBlob); + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`createX509CertChain failed, errCode: ${e.code}, errMsg: ${e.message}`); + } + + try { + let certList = x509CertChain.getCertList(); + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`X509CertChain getCertList failed, errCode: ${e.code}, errMsg: ${e.message}`); + } + + // 证书链校验数据,需业务自行赋值 + const param: cert.CertChainValidationParameters = { + date: '20231212080000Z', + trustAnchors: [{ + CAPubKey: new Uint8Array([0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00, 0xbb, 0x16, + 0x9d, 0x8f, 0x5c, 0x30, 0xd0, 0xba, 0x8f, 0x37, 0x6e, 0x33, 0xaf, 0x6f, 0x23, 0x71, 0x23, 0xa5, 0x49, 0x60, + 0x1e, 0xd1, 0x07, 0x4b, 0xc9, 0x11, 0x7e, 0x66, 0x01, 0xba, 0x92, 0x52]), + CASubject: new Uint8Array([0x30, 0x5a, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x45, + 0x4e, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x07, 0x45, 0x6e, 0x67, 0x6c, 0x61, 0x6e, + 0x64, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x06, 0x4c, 0x6f, 0x6e, 0x64, 0x6f, 0x6e, + 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x03, 0x74, 0x73, 0x31, 0x31, 0x0c, 0x30, 0x0a, + 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x03, 0x74, 0x73, 0x31, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, + 0x03, 0x13, 0x03, 0x74, 0x73, 0x31]), + }] + }; + try { + const validationRes = await x509CertChain.validate(param); + console.log('X509CertChain validate success'); + } catch (err) { + console.error('X509CertChain validate failed'); + } +} + + +// [End certificate_chain_object_creation_and_validation] +@Entry +@Component +struct Index { + @State message: string = 'CreateVerifyCertchainObject'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button('Call CreateVerifyCertchainObject') + .width('70%') + .onClick(()=>{ + try { + sample(); + this.message = 'Call Success'; + } catch { + this.message = 'Call Fail'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/module.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/module.json5 old mode 100755 new mode 100644 index ee5b41c510..4bdc71c1d6 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/module.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/module.json5 @@ -1,78 +1,78 @@ -/* - * 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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.ACCESS_CERT_MANAGER", - "reason": "$string:reason", - "usedScene": { - "abilities": [ - "FormAbility" - ], - "when": "always" - } - }, - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.ACCESS_CERT_MANAGER", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "FormAbility" + ], + "when": "always" + } + }, + ] + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/CertificateAlgorithmLibrary.test.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/CertificateAlgorithmLibrary.test.ets old mode 100755 new mode 100644 index 66e6389663..a99ab838b7 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/CertificateAlgorithmLibrary.test.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/CertificateAlgorithmLibrary.test.ets @@ -1,176 +1,176 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function certificateAlgorithmLibraryTest() { - describe('certificateAlgorithmLibraryTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,创建、解析校验证书对象 - */ - it('testCertificateAlgorithmLibrary001', 0, async (done: Function) => { - console.info('uitest: testCertificateAlgorithmLibrary001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('CreateParseVerifyCertObject')); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CreateParseVerifyCertObject')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call Success')); - console.info('uitest: testCertificateAlgorithmLibrary001 end'); - await driver.pressBack(); - done(); - }) - - /** - * 点击按钮,创建、解析和校验证书扩展信息对象 - */ - it('testCertificateAlgorithmLibrary002', 0, async (done: Function) => { - console.info('uitest: testCertificateAlgorithmLibrary002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('CreateParseVerifyCertextensionObject')); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CreateParseVerifyCertextensionObject')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call Success')); - console.info('uitest: testCertificateAlgorithmLibrary002 end'); - await driver.pressBack(); - done(); - }) - - /** - * 点击按钮,创建、解析和校验证书吊销列表对象 - */ - it('testCertificateAlgorithmLibrary003', 0, async (done: Function) => { - console.info('uitest: testCertificateAlgorithmLibrary003 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('CreateParseVerifyCrlObject')); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CreateParseVerifyCrlObject')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call Success')); - console.info('uitest: testCertificateAlgorithmLibrary003 end'); - await driver.pressBack(); - done(); - }) - - /** - * 点击按钮,构造TrustAnchor对象数组 - */ - it('testCertificateAlgorithmLibrary004', 0, async (done: Function) => { - console.info('uitest: testCertificateAlgorithmLibrary004 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('CreateTrustanchorFromP12')); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CreateTrustanchorFromP12')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call Success')); - console.info('uitest: testCertificateAlgorithmLibrary004 end'); - await driver.pressBack(); - done(); - }) - - /** - * 点击按钮,创建和校验证书链校验器对象 - */ - it('testCertificateAlgorithmLibrary005', 0, async (done: Function) => { - console.info('uitest: testCertificateAlgorithmLibrary005 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('CreateVerifyCerchainvalidatorObject')); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CreateVerifyCerchainvalidatorObject')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call Success')); - console.info('uitest: testCertificateAlgorithmLibrary005 end'); - await driver.pressBack(); - done(); - }) - - /** - * 点击按钮,创建和获取证书集合及证书吊销列表集合对象 - */ - it('testCertificateAlgorithmLibrary006', 0, async (done: Function) => { - console.info('uitest: testCertificateAlgorithmLibrary006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('CreateGetCertCrlObject')); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CreateGetCertCrlObject')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call Success')); - console.info('uitest: testCertificateAlgorithmLibrary006 end'); - await driver.pressBack(); - done(); - }) - - /** - * 点击按钮,创建和校验证书链对象 - */ - it('testCertificateAlgorithmLibrary007', 0, async (done: Function) => { - console.info('uitest: testCertificateAlgorithmLibrary007 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('CreateVerifyCertchainObject')); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CreateVerifyCertchainObject')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call Success')); - console.info('uitest: testCertificateAlgorithmLibrary007 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function certificateAlgorithmLibraryTest() { + describe('certificateAlgorithmLibraryTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,创建、解析校验证书对象 + */ + it('testCertificateAlgorithmLibrary001', 0, async (done: Function) => { + console.info('uitest: testCertificateAlgorithmLibrary001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('CreateParseVerifyCertObject')); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CreateParseVerifyCertObject')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call Success')); + console.info('uitest: testCertificateAlgorithmLibrary001 end'); + await driver.pressBack(); + done(); + }) + + /** + * 点击按钮,创建、解析和校验证书扩展信息对象 + */ + it('testCertificateAlgorithmLibrary002', 0, async (done: Function) => { + console.info('uitest: testCertificateAlgorithmLibrary002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('CreateParseVerifyCertextensionObject')); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CreateParseVerifyCertextensionObject')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call Success')); + console.info('uitest: testCertificateAlgorithmLibrary002 end'); + await driver.pressBack(); + done(); + }) + + /** + * 点击按钮,创建、解析和校验证书吊销列表对象 + */ + it('testCertificateAlgorithmLibrary003', 0, async (done: Function) => { + console.info('uitest: testCertificateAlgorithmLibrary003 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('CreateParseVerifyCrlObject')); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CreateParseVerifyCrlObject')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call Success')); + console.info('uitest: testCertificateAlgorithmLibrary003 end'); + await driver.pressBack(); + done(); + }) + + /** + * 点击按钮,构造TrustAnchor对象数组 + */ + it('testCertificateAlgorithmLibrary004', 0, async (done: Function) => { + console.info('uitest: testCertificateAlgorithmLibrary004 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('CreateTrustanchorFromP12')); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CreateTrustanchorFromP12')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call Success')); + console.info('uitest: testCertificateAlgorithmLibrary004 end'); + await driver.pressBack(); + done(); + }) + + /** + * 点击按钮,创建和校验证书链校验器对象 + */ + it('testCertificateAlgorithmLibrary005', 0, async (done: Function) => { + console.info('uitest: testCertificateAlgorithmLibrary005 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('CreateVerifyCerchainvalidatorObject')); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CreateVerifyCerchainvalidatorObject')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call Success')); + console.info('uitest: testCertificateAlgorithmLibrary005 end'); + await driver.pressBack(); + done(); + }) + + /** + * 点击按钮,创建和获取证书集合及证书吊销列表集合对象 + */ + it('testCertificateAlgorithmLibrary006', 0, async (done: Function) => { + console.info('uitest: testCertificateAlgorithmLibrary006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('CreateGetCertCrlObject')); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CreateGetCertCrlObject')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call Success')); + console.info('uitest: testCertificateAlgorithmLibrary006 end'); + await driver.pressBack(); + done(); + }) + + /** + * 点击按钮,创建和校验证书链对象 + */ + it('testCertificateAlgorithmLibrary007', 0, async (done: Function) => { + console.info('uitest: testCertificateAlgorithmLibrary007 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('CreateVerifyCertchainObject')); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CreateVerifyCertchainObject')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call Success')); + console.info('uitest: testCertificateAlgorithmLibrary007 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/test/List.test.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/hvigor/hvigor-config.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/hvigorfile.ts b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/oh-package.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/oh-package.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/ohosTest.md b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/ohosTest.md old mode 100755 new mode 100644 index 810f0307b3..282567f260 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/ohosTest.md +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/ohosTest.md @@ -1,14 +1,14 @@ -# 证书算法库测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,创建、解析校验证书对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,创建、解析和校验证书扩展信息对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,创建、解析和校验证书吊销列表对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,构造TrustAnchor对象数组 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,创建和校验证书链校验器对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | -| 点击按钮,创建和获取证书集合及证书吊销列表集合对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# 证书算法库测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------------------------------------- | ------------ | ---- | -------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,创建、解析校验证书对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,创建、解析和校验证书扩展信息对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,创建、解析和校验证书吊销列表对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,构造TrustAnchor对象数组 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,创建和校验证书链校验器对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮,创建和获取证书集合及证书吊销列表集合对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮,创建和校验证书链对象 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/screenshots/CertificateAlgorithmLibrary1.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/screenshots/CertificateAlgorithmLibrary1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/screenshots/CertificateAlgorithmLibrary2.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/screenshots/CertificateAlgorithmLibrary2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/.gitignore b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/app.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/app.json5 old mode 100755 new mode 100644 index 5963407ce7..f6dcb15f5a --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/app.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/app.json5 @@ -1,25 +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.certificatemanagement", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.certificatemanagement", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/element/string.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 4763eada6a..939dfafaa7 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "CertificateManagement" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "CertificateManagement" + } + ] +} diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/README.md b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/README.md old mode 100755 new mode 100644 index 26c19d65e9..33eb0cc351 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/README.md +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/README.md @@ -1,72 +1,72 @@ -# 证书管理 - -### 介绍 - -证书管理主要提供系统级的证书管理能力,实现证书全生命周期(安装、存储、使用和销毁)的管理和安全使用。 - -本示例主要展示了证书管理中证书管理与证书管理对话框的使用场景。该工程中展示的代码详细描述可查如下链接中介绍。 - -- [证书管理开发指导](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/certManager-guidelines.md) -- [证书管理对话框开发指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/security/DeviceCertificateKit/certManagerDialog-guidelines.md) - -### 效果预览 - -| 首页效果图 | 执行结果图 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| | | - -### 使用说明 - -1. 运行Index主界面。 -2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 -3. 运行测试用例CertificateManagement.test.ets文件对页面代码进行测试可以全部通过。 - -### 工程目录 - -``` -entry/src/ - ├── main - │ ├── ets - │ │ ├── entryability - │ │ ├── entrybackupability - │ │ ├── pages - │ │ ├── Index.ets // 证书管理示例代码 - │ │ ├── CertManagerGuidelines.ets - │ │ ├── CertManagerDialogGuidelines.ets - │ ├── module.json5 - │ └── resources - ├── ohosTest - │ ├── ets - │ │ └── test - │ │ ├── Ability.test.ets - │ │ ├── CertificateManagement.test.ets // 自动化测试代码 - │ │ └── List.test.ets -``` - -### 相关权限 - -[ohos.permission.ACCESS_CERT_MANAGER](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionaccesscertmanager) - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行, 支持设备:RK3568。 - -2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 - -3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -```` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/DeviceCertificateKit/CertificateManagement > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 证书管理 + +### 介绍 + +证书管理主要提供系统级的证书管理能力,实现证书全生命周期(安装、存储、使用和销毁)的管理和安全使用。 + +本示例主要展示了证书管理中证书管理与证书管理对话框的使用场景。该工程中展示的代码详细描述可查如下链接中介绍。 + +- [证书管理开发指导](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/certManager-guidelines.md) +- [证书管理对话框开发指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/security/DeviceCertificateKit/certManagerDialog-guidelines.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例CertificateManagement.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 证书管理示例代码 + │ │ ├── CertManagerGuidelines.ets + │ │ ├── CertManagerDialogGuidelines.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── CertificateManagement.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +[ohos.permission.ACCESS_CERT_MANAGER](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionaccesscertmanager) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/DeviceCertificateKit/CertificateManagement > .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/Security/DeviceCertificateKit/CertificateManagement/build-profile.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/build-profile.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/code-linter.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/.gitignore b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/build-profile.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/build-profile.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/hvigorfile.ts b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/oh-package.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/oh-package.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets old mode 100755 new mode 100644 index 2043736855..e6b8c16549 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets @@ -1,59 +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. - */ -// [Start certificate_management_dialog_box_development_guide] -import { certificateManagerDialog } from '@kit.DeviceCertificateKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { common } from '@kit.AbilityKit'; - -async function certificateManagerDialogSample() { - /* context为应用的上下文信息,由调用方自行获取,此处仅为示例 */ - let context: common.Context = getContext(); - /* pageType为页面类型,此处赋值PAGE_MAIN,即拉起证书管理主界面 */ - let pageType: certificateManagerDialog.CertificateDialogPageType = - certificateManagerDialog.CertificateDialogPageType.PAGE_MAIN; - try { - certificateManagerDialog.openCertificateManagerDialog(context, pageType).then(() => { - console.info('Succeeded in opening certificate manager dialog.'); - }).catch((err: BusinessError) => { - console.error(`Failed to open certificate manager dialog. Code: ${err.code}, message: ${err.message}`); - }) - } catch (error) { - console.error(`Failed to open certificate manager dialog. Code: ${error.code}, message: ${error.message}`); - } -} - - -// [End certificate_management_dialog_box_development_guide] -@Entry -@Component -struct Index { - @State message: string = 'CertManagerDialogGuidelines'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontWeight(FontWeight.Bold) - .fontSize(25) - Button($r('app.string.call_certManagerDialogGuidelines')) - .width('70%') - .onClick(() => { - certificateManagerDialogSample(); - this.message = 'CertManagerDialogGuidelines Success'; - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start certificate_management_dialog_box_development_guide] +import { certificateManagerDialog } from '@kit.DeviceCertificateKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { common } from '@kit.AbilityKit'; + +async function certificateManagerDialogSample() { + /* context为应用的上下文信息,由调用方自行获取,此处仅为示例 */ + let context: common.Context = getContext(); + /* pageType为页面类型,此处赋值PAGE_MAIN,即拉起证书管理主界面 */ + let pageType: certificateManagerDialog.CertificateDialogPageType = + certificateManagerDialog.CertificateDialogPageType.PAGE_MAIN; + try { + certificateManagerDialog.openCertificateManagerDialog(context, pageType).then(() => { + console.info('Succeeded in opening certificate manager dialog.'); + }).catch((err: BusinessError) => { + console.error(`Failed to open certificate manager dialog. Code: ${err.code}, message: ${err.message}`); + }) + } catch (error) { + console.error(`Failed to open certificate manager dialog. Code: ${error.code}, message: ${error.message}`); + } +} + + +// [End certificate_management_dialog_box_development_guide] +@Entry +@Component +struct Index { + @State message: string = 'CertManagerDialogGuidelines'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontWeight(FontWeight.Bold) + .fontSize(25) + Button($r('app.string.call_certManagerDialogGuidelines')) + .width('70%') + .onClick(() => { + certificateManagerDialogSample(); + this.message = 'CertManagerDialogGuidelines Success'; + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets old mode 100755 new mode 100644 index 39f6cc11db..2114a68824 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets @@ -1,298 +1,298 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start certificate_management_development_guidance] - -import { certificateManager } from '@kit.DeviceCertificateKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -async function certificateManagerSample() { - /* 安装的凭据数据需要业务赋值,本例数据非凭据数据 */ - let keystore: Uint8Array = new Uint8Array([ - 0x30,0x82,0x0c,0x26,0x02,0x01,0x03,0x30,0x82,0x0b,0xe0,0x06,0x09,0x2a,0x86,0x48, - 0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x82,0x0b,0xd1,0x04,0x82,0x0b,0xcd,0x30,0x82, - 0x0b,0xc9,0x30,0x82,0x05,0x6e,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07, - 0x01,0xa0,0x82,0x05,0x5f,0x04,0x82,0x05,0x5b,0x30,0x82,0x05,0x57,0x30,0x82,0x05, - 0x53,0x06,0x0b,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x0a,0x01,0x02,0xa0,0x82, - 0x04,0xfa,0x30,0x82,0x04,0xf6,0x30,0x28,0x06,0x0a,0x2a,0x86,0x48,0x86,0xf7,0x0d, - 0x01,0x0c,0x01,0x03,0x30,0x1a,0x04,0x14,0xb6,0x80,0x7d,0xb9,0xc3,0x44,0x84,0x1f, - 0x44,0xe6,0x95,0x6a,0x98,0xa1,0xcb,0x97,0xfb,0x2b,0xcc,0x5a,0x02,0x02,0x04,0x00, - 0x04,0x82,0x04,0xc8,0x78,0xa7,0x16,0x45,0x40,0xf0,0xec,0xac,0x3e,0x34,0x17,0xd7, - 0x8b,0x5c,0xca,0x85,0x29,0x0b,0x08,0xef,0xa2,0xf0,0x6d,0x55,0xd7,0xde,0x96,0xa5, - 0x49,0x6d,0x9d,0xa6,0xe6,0x00,0xd7,0x2c,0x65,0xf6,0xc2,0xd1,0xe8,0x70,0xfb,0xb5, - 0xd9,0xc6,0x7d,0xd4,0x28,0x45,0x17,0x4f,0x4f,0xd9,0x9b,0xab,0xe2,0xdc,0xe7,0x22, - 0x6c,0x1e,0xbc,0xd6,0xf0,0x38,0x0b,0xd7,0xd9,0xfc,0xa7,0xb4,0x87,0x95,0x96,0xc3, - 0x93,0xc0,0xb5,0x37,0xf4,0x64,0xfe,0xe5,0x07,0xac,0x41,0x2d,0xf5,0xeb,0xe3,0x8b, - 0xc2,0x74,0x73,0x13,0x3b,0x5f,0x17,0x54,0x2d,0x31,0x20,0x69,0x1c,0xab,0x66,0xba, - 0x06,0x43,0x03,0xa3,0x69,0x54,0x72,0x70,0x5f,0x78,0xd2,0xec,0xdd,0x50,0xb8,0x25, - 0x03,0xd4,0xec,0x2d,0x92,0x96,0x9f,0xcc,0xa6,0x4a,0x50,0x34,0x1c,0xfc,0xe3,0xc2, - 0x6b,0x65,0xec,0xb3,0x1c,0xc8,0xf2,0xd0,0x79,0xf0,0x28,0x61,0x9a,0xfe,0xea,0x7f, - 0x16,0x38,0xe1,0xf4,0x7f,0x86,0xfe,0x73,0x67,0xc9,0x60,0x73,0xd8,0xef,0x2c,0x6b, - 0xde,0x88,0x37,0xc5,0xd7,0x18,0x60,0x74,0x97,0x07,0x85,0x70,0x74,0x30,0x66,0x8f, - 0x11,0x4a,0xb9,0x18,0xed,0xfc,0xc7,0xdb,0x63,0x58,0x7b,0x57,0x0d,0xfa,0x43,0x81, - 0xbd,0x34,0xfc,0x17,0xd3,0x2a,0xa9,0x74,0xa0,0x2c,0x1b,0xe2,0xaa,0x3d,0xd2,0x84, - 0x18,0xaa,0x2a,0x0e,0xa8,0xcc,0x2a,0xc4,0x39,0x60,0x29,0xb5,0x03,0xaf,0xea,0x96, - 0xcf,0xa5,0x67,0x4c,0xa7,0x59,0x76,0xea,0x8a,0x60,0xd6,0xd8,0xc3,0x9e,0x0e,0xad, - 0xd6,0xa0,0x5a,0x00,0x7c,0xa6,0xe8,0x62,0xa4,0x0a,0x53,0xcc,0x48,0xf0,0x4d,0x6d, - 0xda,0xb3,0xa9,0x82,0x37,0x75,0xff,0x20,0xa9,0xe8,0x6e,0xc8,0x4a,0x8a,0x81,0x84, - 0x7a,0x1d,0x02,0x40,0xd9,0x76,0xee,0x89,0x62,0xd5,0x57,0x19,0xc8,0x9a,0x6a,0x22, - 0x8d,0x01,0x8f,0xc9,0x14,0x72,0xf9,0x90,0xa3,0x0f,0x5f,0x23,0x32,0xc4,0xd5,0x79, - 0x53,0x1f,0xbc,0x3a,0xf4,0x19,0x7f,0x93,0xb7,0x8b,0x0b,0xb9,0xeb,0x1f,0xa2,0x5c, - 0x93,0x0e,0x5f,0x29,0x87,0xea,0x67,0x4d,0x5d,0x2b,0x5e,0x29,0x81,0xbd,0x3d,0xfc, - 0xdf,0x92,0x50,0x19,0xc2,0x50,0x4d,0x07,0x76,0x08,0xfc,0xbe,0xd1,0x73,0x64,0xb7, - 0x22,0x6f,0xb7,0x89,0x93,0xc1,0xb1,0x44,0x42,0x27,0xf5,0x61,0x06,0x32,0xd1,0xc0, - 0xdb,0x92,0x51,0x1b,0xd3,0x5c,0x95,0x85,0x0e,0x66,0xc5,0xe9,0xf5,0x7f,0x44,0x52, - 0x49,0xfb,0x0a,0x83,0x02,0x6e,0x69,0x6c,0xf1,0x6f,0xe5,0xa1,0xa0,0x5d,0x8a,0xd3, - 0x4f,0x9d,0x0a,0x08,0x1b,0x32,0x70,0xe3,0xf3,0xf0,0x63,0xda,0x37,0x90,0x96,0x3f, - 0xac,0xf7,0x3d,0xd5,0xeb,0x08,0xc1,0x51,0x91,0x75,0x2c,0x0f,0xf1,0x5b,0x39,0xce, - 0x05,0x06,0x65,0x1c,0xe8,0x36,0xb0,0x86,0x6e,0xbe,0xb9,0x25,0xd6,0xdf,0x5c,0x50, - 0x56,0x99,0x69,0x8e,0x92,0xbe,0xa1,0x03,0x18,0xd6,0x34,0xa6,0x98,0x53,0x3a,0xb7, - 0x96,0xcb,0xa8,0x1d,0xc9,0x9e,0x92,0x15,0xf4,0x99,0x7e,0x58,0x81,0x99,0x84,0xa0, - 0x67,0xa5,0x77,0x1e,0xa9,0xac,0xc2,0xcf,0xd8,0x7a,0x68,0xef,0x35,0x9e,0xb6,0xb7, - 0x78,0x6b,0x43,0x12,0x53,0x93,0x7b,0x50,0x94,0x37,0x48,0x75,0x98,0x27,0x0f,0x73, - 0x1a,0xb7,0x2f,0x19,0x7e,0x42,0x08,0x02,0x05,0x42,0x71,0xd6,0x26,0x64,0x04,0x25, - 0x87,0xd9,0x02,0x05,0x1f,0x79,0x6b,0x9b,0x0e,0xfa,0x10,0x7b,0xf3,0x96,0x3f,0x53, - 0x02,0x9d,0x80,0x13,0xd7,0x30,0x03,0x24,0x96,0x21,0x05,0xdb,0x2d,0xe9,0xc8,0x51, - 0x30,0x42,0x6d,0xa9,0xe8,0x39,0xb0,0xa9,0x59,0xb9,0x21,0x22,0x98,0x41,0x0e,0x33, - 0x0d,0x7f,0x7a,0x69,0x45,0x0b,0xf1,0xac,0xfd,0xaa,0xaa,0x45,0x7f,0x78,0x24,0xf8, - 0x56,0x85,0x3b,0x4b,0x95,0x78,0x40,0xc7,0x2f,0xfc,0xb6,0xb7,0x5f,0xa2,0xf9,0xe9, - 0x80,0x4c,0x4a,0xbf,0x4f,0xcb,0xb9,0x51,0x7c,0x18,0xb7,0xb7,0x70,0xf1,0x4c,0x96, - 0xd2,0x4a,0x44,0xb9,0xa6,0x22,0xc9,0x95,0xf5,0x99,0xbd,0x8c,0xf2,0x45,0x88,0xfb, - 0x2f,0xe0,0x38,0x42,0xc8,0xe5,0x0d,0x55,0x05,0x0f,0xb9,0x91,0x7d,0xaf,0x27,0x91, - 0xb3,0xc4,0x83,0x46,0x49,0x1a,0xce,0x3a,0xff,0x1b,0x58,0xc9,0xa4,0x22,0x82,0x57, - 0x7f,0xda,0x5f,0xae,0xea,0xae,0x96,0x91,0xef,0xde,0x4e,0x25,0x66,0xbb,0xe9,0xb3, - 0xa7,0xbc,0x12,0xc4,0x5f,0xee,0xc6,0x13,0x9c,0xd9,0xbc,0x14,0xef,0x3d,0x7b,0xa4, - 0x91,0x4a,0x77,0xfd,0x18,0x9c,0xc7,0x38,0xaf,0x24,0x3f,0x6c,0x8f,0x8f,0x6e,0x2c, - 0x38,0x7c,0xa4,0xba,0xc7,0x70,0x90,0x6d,0x5e,0x51,0x3c,0xe0,0x3d,0xc5,0xa8,0x44, - 0xb0,0xf4,0x0b,0xba,0xe0,0x0e,0x8b,0x65,0xeb,0x04,0xfd,0x1a,0x8b,0x94,0xbf,0xfe, - 0xf0,0x64,0xa4,0xfa,0xb4,0xe1,0x11,0xd4,0x95,0x13,0xee,0xce,0xf6,0x14,0xf7,0x1c, - 0xbc,0xf5,0x64,0x90,0x88,0x69,0xb2,0xfd,0x26,0x26,0x83,0xa7,0x4c,0x3d,0x27,0xae, - 0x3c,0x68,0xb5,0xcc,0x9f,0x46,0xc2,0x9a,0x95,0x9a,0xa7,0x8b,0x4a,0x14,0xf7,0x80, - 0x9f,0x04,0xf9,0x39,0x3b,0x55,0x9e,0xb5,0x1c,0x79,0x7d,0x2d,0x9b,0x29,0xb9,0x7c, - 0x61,0x01,0xf5,0x26,0x1e,0xa0,0xcb,0x18,0xaf,0xc6,0x6d,0x2f,0x42,0xb7,0xa5,0x94, - 0x91,0xa5,0xc0,0x15,0xd9,0x18,0x4e,0xb6,0xc3,0x77,0x9e,0x59,0x6e,0x61,0x48,0x32, - 0xcf,0x5e,0x09,0x3a,0x17,0x48,0x59,0x68,0x9a,0x6c,0x7f,0xd3,0x71,0xd8,0x2c,0xce, - 0x58,0x68,0x33,0x79,0xe6,0xb6,0xf0,0xb5,0xac,0xb0,0xa4,0xc0,0x10,0x0f,0xad,0x02, - 0x19,0x58,0x53,0x5a,0x9a,0x5d,0x84,0xa6,0x8e,0x3c,0xc8,0xa9,0x22,0xb5,0x2a,0x39, - 0x3f,0xf8,0x76,0x53,0xea,0x7b,0x23,0x81,0x2b,0xe1,0x1d,0x63,0xb3,0x83,0x76,0xc8, - 0xd3,0x5e,0xba,0x97,0x79,0x9b,0xfb,0xf3,0x1e,0x10,0xac,0xd8,0x2e,0xa0,0x64,0xba, - 0x02,0x21,0x18,0x05,0xd1,0x30,0xdd,0x33,0x32,0x98,0x3d,0x0d,0x22,0xb4,0xda,0x8d, - 0xa0,0x9a,0x3a,0x97,0x0f,0xa5,0xe1,0xf1,0x56,0x17,0xd8,0xbd,0x15,0xd3,0xd6,0xe0, - 0x20,0x95,0x7b,0x6a,0x63,0x59,0x80,0xee,0xcd,0x60,0xb1,0xb0,0xba,0x8d,0x6a,0x4c, - 0x3d,0x5c,0xac,0x1a,0x87,0x1d,0x07,0xfe,0x69,0x81,0x8f,0x5d,0xba,0x64,0x3f,0xea, - 0xdf,0x36,0xb3,0x07,0x6c,0xbc,0x5b,0xe8,0xc0,0x5c,0x9a,0xd1,0x16,0xe3,0x2e,0xa5, - 0x92,0x5b,0xba,0x89,0x55,0x65,0x5d,0x14,0xd2,0x36,0x9e,0xfd,0x6d,0xcf,0x9d,0x68, - 0x10,0x7f,0xb6,0xdf,0x6b,0x9a,0x9b,0xd4,0x6b,0x37,0xfd,0x77,0xde,0x39,0x59,0xed, - 0xe3,0xdb,0x65,0xe8,0xa4,0x15,0x4a,0x6d,0xb4,0xad,0xb8,0x36,0xe1,0x3a,0xf8,0x6a, - 0xfe,0x6e,0x1f,0x02,0x15,0x09,0x36,0x44,0xb7,0x52,0x5b,0x79,0x3c,0x8e,0xfb,0x20, - 0x62,0xdb,0x7b,0xb6,0xb1,0x43,0xea,0x29,0xff,0x10,0xef,0x24,0x9c,0x4d,0xc2,0xa8, - 0x98,0xaa,0x29,0x59,0x85,0x06,0xc3,0xdb,0xcf,0xc2,0x71,0xfa,0xad,0x7b,0xd5,0xf7, - 0x50,0x53,0xc5,0x75,0x97,0x15,0x42,0x90,0x8f,0xf1,0xed,0x6a,0x98,0x83,0x59,0x15, - 0x23,0xa7,0xea,0xe9,0xed,0x22,0xec,0x0a,0x41,0x4c,0xc2,0x35,0x54,0xd9,0xec,0x4b, - 0xb8,0x3f,0xd0,0x68,0xed,0xa7,0x83,0x4e,0x42,0x29,0x5c,0x4d,0xa3,0x79,0x3e,0x59, - 0x86,0x04,0x62,0x24,0x9d,0x7b,0xb3,0x69,0xe9,0x82,0x57,0xdb,0xbf,0xeb,0x98,0x4f, - 0x59,0x7e,0x8d,0x8f,0x69,0x56,0xdc,0x3f,0xeb,0x01,0xcf,0x82,0x05,0x1e,0xe7,0x6d, - 0xff,0xb2,0x67,0xd8,0x34,0x68,0xf7,0xd0,0xee,0x6d,0xc6,0x22,0x4c,0x4d,0x36,0xd1, - 0xf5,0x5a,0xab,0xbb,0x41,0x43,0x4d,0xef,0x2c,0x62,0x64,0x28,0x31,0x46,0x30,0x1f, - 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x09,0x14,0x31,0x12,0x1e,0x10,0x00, - 0x6c,0x00,0x64,0x00,0x71,0x00,0x20,0x00,0x74,0x00,0x65,0x00,0x73,0x00,0x74,0x30, - 0x23,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x09,0x15,0x31,0x16,0x04,0x14, - 0x44,0x37,0x75,0x8f,0xcd,0x94,0x90,0x07,0x3e,0x38,0x20,0xb7,0x1b,0x3f,0x0d,0x3d, - 0x40,0x85,0x32,0x6a,0x30,0x82,0x06,0x53,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d, - 0x01,0x07,0x06,0xa0,0x82,0x06,0x44,0x30,0x82,0x06,0x40,0x02,0x01,0x00,0x30,0x82, - 0x06,0x39,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0x30,0x28,0x06, - 0x0a,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x01,0x06,0x30,0x1a,0x04,0x14,0xc8, - 0xe2,0x48,0x69,0x85,0x06,0xb3,0x34,0x55,0xf1,0xfe,0x9c,0x95,0x92,0xbd,0x73,0xcd, - 0x50,0xf4,0x88,0x02,0x02,0x04,0x00,0x80,0x82,0x06,0x00,0xb6,0x66,0x06,0x1a,0x84, - 0xb1,0xb7,0xf8,0xca,0x74,0xe1,0x7c,0x23,0x94,0x5f,0xb3,0x73,0xda,0x81,0x51,0x0e, - 0x4d,0x07,0xcd,0x8a,0x68,0xd5,0x15,0x98,0x57,0xc1,0xb9,0x94,0x30,0xc7,0x97,0x40, - 0x3b,0xa4,0xc0,0xd5,0xfe,0xd3,0x9f,0x92,0xe9,0x6a,0xeb,0x52,0x1c,0xd8,0x89,0x26, - 0xf4,0x1b,0x49,0xe9,0xef,0x45,0x0b,0x33,0x36,0x73,0x1b,0x91,0x2b,0x75,0xff,0x9b, - 0x12,0x41,0xc7,0x80,0xb1,0x4a,0x12,0xaf,0x02,0x8d,0x4b,0xea,0xcd,0x0e,0xc6,0x03, - 0x14,0x4c,0x79,0xef,0xa6,0xc2,0xf6,0x86,0xd3,0x19,0xfd,0xe6,0x85,0xfa,0x3b,0x0d, - 0x3b,0xb2,0x98,0xd2,0xff,0xa0,0xfe,0x65,0x63,0xc9,0xc2,0xa7,0xf4,0x0d,0x98,0x57, - 0xab,0xd5,0x7b,0x58,0x87,0x62,0x58,0x74,0x40,0x75,0x06,0x8f,0x4a,0x93,0xff,0x76, - 0xbb,0xd3,0x19,0x4d,0xf8,0x04,0x89,0xa4,0xc5,0xe3,0xbe,0xde,0x60,0x04,0x7f,0x52, - 0x58,0x11,0x51,0x6f,0xa9,0xf9,0x06,0x6d,0x03,0x83,0xcd,0xa7,0x01,0xf8,0x2d,0xa0, - 0xe6,0x45,0x63,0x85,0x46,0x7c,0x9b,0x55,0x86,0xfd,0xe9,0xc3,0xd4,0xeb,0xeb,0x3e, - 0x2b,0x0e,0x33,0x8a,0x9f,0x40,0xe3,0x9d,0x52,0xe3,0xf8,0x6f,0x1a,0x4d,0x5f,0xaf, - 0x78,0x12,0x56,0x56,0xab,0x3d,0xbd,0x36,0x8e,0xd9,0xa9,0xc4,0xfc,0xd3,0x21,0x6b, - 0xa7,0xa0,0xa3,0xc6,0x50,0x41,0x43,0xdb,0xd0,0xf7,0x16,0x08,0x06,0x0d,0xed,0x15, - 0x90,0xdc,0x31,0xeb,0x0d,0x4b,0x7b,0x1c,0xa6,0x32,0xca,0x52,0xaa,0x3a,0x71,0xc2, - 0xb7,0xce,0x42,0xd4,0x90,0xbe,0x65,0x0b,0x55,0x54,0x79,0x6b,0xbf,0xbc,0xf7,0x1d, - 0x5f,0x14,0x4a,0x02,0x4c,0x63,0x16,0x6d,0x85,0xad,0xb3,0x1f,0x11,0x43,0x3f,0xd3, - 0x4d,0x3b,0xfc,0x96,0x79,0xca,0xa5,0x9e,0xc1,0xdf,0xbc,0x94,0x2d,0x46,0xe2,0xe7, - 0x1a,0x93,0xfc,0xc5,0x09,0x16,0x8d,0x91,0x41,0xc0,0x59,0x4f,0x9c,0x76,0x94,0x86, - 0xf2,0x59,0x5d,0xca,0xa9,0x20,0x93,0x10,0xd6,0x45,0x3b,0x30,0x55,0xdf,0x96,0x9f, - 0x60,0x06,0x7c,0x9a,0xb9,0x24,0x1e,0xe0,0xae,0x65,0xd5,0x4b,0x4a,0xe2,0x55,0xc7, - 0x09,0xb5,0x51,0x40,0x07,0x7e,0xe1,0xef,0x34,0x63,0x7b,0x3a,0xa9,0x98,0x2f,0x09, - 0xe1,0xfd,0x7a,0xb3,0x29,0x79,0xfc,0xf5,0xbd,0x3c,0x3c,0x05,0x02,0xd5,0xc5,0x86, - 0xaf,0x9a,0xd3,0x10,0x7e,0xc3,0x1b,0xf7,0x73,0x64,0xd6,0x27,0x04,0x08,0xee,0x7b, - 0x49,0x2d,0x21,0x2e,0xd8,0xbc,0x29,0x3a,0x80,0x82,0x2d,0xed,0xf2,0xaf,0x08,0x55, - 0xce,0x80,0x9c,0xf2,0xeb,0x60,0x38,0x12,0x27,0x31,0xa0,0x2f,0x64,0xbf,0x21,0x8c, - 0x63,0x88,0x90,0xee,0x9e,0xc0,0x5f,0xb8,0xea,0xa5,0xf3,0x26,0x01,0x65,0xe3,0x97, - 0xb6,0x17,0x6f,0x6a,0x48,0x77,0xc0,0x26,0x00,0x65,0x19,0xc8,0xe8,0xc6,0x94,0x5d, - 0x03,0xcb,0xc5,0xa9,0x5d,0xc5,0x4b,0x8f,0xcf,0x33,0xeb,0x2a,0x9a,0x5a,0x75,0xe4, - 0xec,0x7d,0x59,0xab,0xd1,0x9a,0xb7,0x73,0x54,0x2a,0xe3,0x3d,0x63,0x62,0xcf,0xa0, - 0x5f,0xb5,0xf4,0x12,0x61,0xa6,0xbb,0xd9,0xf6,0x3f,0xc9,0x0c,0x96,0x9f,0xf8,0xa2, - 0x38,0x2c,0xb5,0xdf,0x26,0x07,0x0d,0xc5,0x43,0x33,0xe3,0x69,0x31,0x56,0x7a,0x4c, - 0x3c,0xc7,0x44,0xa4,0x9f,0x62,0xa4,0x5f,0x9b,0xdd,0xe4,0x24,0x28,0x1b,0xe6,0x72, - 0xc8,0x8d,0xe7,0x40,0x4e,0x81,0xe6,0x8e,0x3c,0xb5,0x53,0xe3,0x0b,0x43,0x69,0xaf, - 0x7d,0xb8,0xfc,0xf2,0xb5,0x2a,0xad,0x95,0xe1,0xb7,0xbd,0xdf,0x3b,0x16,0xac,0x7b, - 0x9f,0xad,0x8f,0x66,0x7d,0x72,0x3e,0xf4,0xdb,0xf5,0xdd,0x91,0x09,0x7a,0x2b,0xf8, - 0x3d,0xa6,0x26,0xec,0x22,0x00,0xcc,0xe6,0xab,0x03,0xe6,0xbe,0x7b,0x70,0x09,0x07, - 0x72,0xfc,0x32,0xf1,0x46,0xda,0x7e,0x0a,0x97,0xcf,0x42,0xaf,0x2d,0x70,0x56,0x34, - 0xce,0xc9,0x7b,0xca,0xb6,0xd5,0xc8,0xd4,0xe3,0x96,0x62,0x02,0x54,0x66,0x65,0x88, - 0xf7,0xe5,0xb6,0x68,0x0d,0x61,0x8d,0x71,0xa4,0x39,0xd0,0xe5,0xf7,0x38,0x27,0x00, - 0x65,0x53,0xd4,0x1b,0x0a,0x94,0x63,0xa8,0x19,0xc3,0x2a,0x5b,0x2a,0x6a,0xb9,0x19, - 0xfa,0x04,0x3e,0xc5,0x0a,0xc6,0x5c,0xc0,0x3f,0xbb,0x3f,0x18,0x9b,0x27,0xdc,0xd5, - 0xf7,0x2b,0x54,0x30,0x68,0x47,0x45,0xae,0x12,0xe4,0xdc,0x71,0xa5,0xbd,0x4b,0x6e, - 0xd6,0xba,0x6e,0x96,0xa6,0x73,0x77,0xc5,0x2b,0x48,0x6d,0x7e,0xbb,0x44,0x6f,0xd5, - 0x5d,0x17,0xcb,0xd6,0x96,0xb8,0xd1,0x06,0xe1,0xea,0x2f,0xa6,0x86,0x1b,0x81,0x97, - 0xbe,0xa0,0xfb,0x9a,0x20,0x6d,0xf5,0x33,0xeb,0x64,0xd3,0x89,0x68,0x8c,0x8b,0xa9, - 0x4f,0x19,0x51,0xb5,0x8d,0x89,0x74,0x51,0x2c,0x90,0x38,0x0e,0x0d,0x18,0x53,0x87, - 0x31,0x62,0x3d,0x54,0x1e,0x74,0xc0,0x9a,0xc3,0x37,0xdd,0x36,0x00,0x5c,0xc9,0xb4, - 0x1d,0x57,0x0b,0xb2,0x43,0x25,0x2b,0xb6,0xee,0x83,0xda,0xfd,0xad,0x41,0x9d,0xf4, - 0xdf,0x60,0xfe,0xa1,0xd0,0x1c,0x78,0x3e,0x36,0x17,0x38,0x4a,0xb2,0x42,0x15,0xac, - 0xa6,0x5e,0x88,0xe3,0x11,0x76,0x48,0xc9,0xcd,0x86,0xbb,0x2b,0x7a,0xab,0xa9,0xfe, - 0x76,0x0f,0xb5,0xb4,0x6e,0x1a,0xfd,0x5f,0xa4,0x20,0x32,0xb2,0xb5,0x4d,0x25,0xa4, - 0x34,0xd3,0x06,0xf4,0xc6,0x6e,0x83,0xcb,0x5e,0x87,0xe0,0x25,0xee,0x17,0x58,0x2e, - 0xaa,0x3c,0x54,0xf1,0xb5,0x33,0xcd,0xa7,0x37,0x78,0x10,0x25,0x23,0x90,0x8a,0x80, - 0x3f,0xbb,0x4b,0xdf,0x89,0xc2,0xee,0x5c,0x78,0x33,0x1a,0x76,0x3e,0xf9,0x46,0x49, - 0x50,0x0c,0x39,0x38,0x33,0x6b,0xbe,0xae,0xec,0xec,0xf9,0xf5,0x1c,0x40,0xa1,0xa7, - 0x29,0x0e,0x02,0x7a,0xd7,0xb9,0x0b,0x2e,0x6f,0x9f,0x33,0x97,0x63,0x87,0xe0,0xb7, - 0xf6,0x9e,0xa0,0x43,0xa6,0xbe,0x04,0x3f,0x3f,0x8a,0xcc,0x8d,0xd3,0xbc,0x15,0x0e, - 0x9b,0xb7,0x99,0xc1,0x3f,0xfa,0xaf,0x8a,0xc4,0x67,0x0d,0x36,0xda,0xab,0xf5,0xe9, - 0x77,0xa9,0x84,0x0b,0xf9,0x22,0x49,0x15,0x9d,0x72,0x62,0x73,0x21,0x90,0x14,0x6e, - 0x4b,0x2d,0x50,0x80,0x02,0x5e,0x79,0x66,0x7d,0x8c,0x5b,0xf8,0x2a,0x0c,0x2e,0x62, - 0x15,0x85,0x78,0xce,0xa7,0xb6,0x33,0x8f,0xba,0xe4,0xb1,0xa5,0x9e,0xea,0x66,0x9e, - 0x9c,0x98,0x7d,0x90,0x75,0x6f,0xd4,0xc0,0xd5,0x42,0x5d,0x5e,0xd4,0xab,0xed,0x1e, - 0xe0,0x77,0x48,0xaf,0x13,0xac,0x89,0x8c,0x2a,0x2a,0x6b,0xb1,0x45,0xca,0xae,0x86, - 0xfc,0xd8,0x15,0x4e,0xae,0xce,0x00,0x63,0x71,0xa6,0xef,0x43,0xdd,0x1c,0x77,0x21, - 0x85,0xa8,0xd2,0x46,0x61,0xf0,0xfd,0xcb,0x43,0x31,0x41,0x35,0xda,0x2f,0xa9,0xc8, - 0xb0,0x5f,0xd6,0xc9,0x7b,0x43,0x97,0x28,0xfa,0x2e,0xe7,0x07,0x8e,0x32,0xd5,0xf5, - 0x30,0x2f,0x76,0x51,0x4b,0x21,0xcf,0xbd,0xc2,0x3a,0x5e,0x85,0x60,0x2b,0x42,0xc5, - 0x56,0x70,0xf1,0xfb,0xce,0xd5,0xee,0x4f,0x30,0x33,0x08,0xea,0x3b,0xa7,0x31,0x54, - 0x67,0xc2,0x07,0x2d,0x7c,0x2f,0x43,0xbe,0x34,0x34,0xd4,0x11,0x5c,0x8f,0x94,0x6a, - 0x77,0xcb,0x03,0x77,0x48,0x33,0xac,0x77,0x78,0x42,0x6c,0x6f,0x08,0x93,0x23,0x5c, - 0xb8,0x6e,0xae,0xac,0xd0,0x33,0x85,0x1a,0x55,0xd5,0x85,0xa7,0x00,0xf0,0xf9,0x01, - 0x58,0xac,0x39,0x10,0x05,0x45,0x3e,0xb0,0xa9,0x86,0x12,0x78,0xe7,0xad,0xb0,0xee, - 0x4f,0xc7,0x34,0xf4,0x09,0x9c,0x70,0x77,0xa7,0x41,0xb3,0x54,0xc3,0xc4,0xa0,0xf2, - 0x72,0x50,0x74,0x9c,0xed,0x16,0x45,0x92,0x15,0xa8,0x42,0x86,0x93,0x4e,0x28,0x79, - 0x1e,0x80,0x7a,0x13,0xae,0x4d,0x37,0x55,0xeb,0xbd,0x83,0x35,0xec,0x20,0xa1,0x83, - 0x19,0x50,0x30,0x02,0x6c,0x48,0x78,0x3b,0xa9,0x6f,0x18,0x57,0x69,0x3a,0x5b,0xdb, - 0xd6,0x77,0x7f,0x5c,0x0d,0xe3,0xd1,0xd0,0x27,0x1f,0x3f,0xd2,0xfb,0x6b,0xab,0x36, - 0x44,0x58,0x6f,0xf4,0xa2,0x45,0x32,0xc9,0x05,0x67,0xd9,0x1a,0x9c,0x9b,0x63,0x31, - 0x7a,0x54,0xbd,0xa0,0x63,0x7a,0x01,0x73,0xbc,0xcc,0xd2,0xe2,0x44,0x17,0xd2,0xd7, - 0xb8,0x76,0x7e,0xb7,0x5a,0x04,0xfc,0xb9,0xd9,0xed,0xd2,0x76,0x38,0x21,0x71,0xfc, - 0x83,0x55,0x89,0x30,0x6e,0xf8,0x0d,0xc0,0xe7,0xb6,0x8e,0x1a,0x44,0xf6,0x8d,0xdb, - 0x2a,0x01,0xf6,0x55,0x6f,0x43,0xbe,0x66,0x39,0xd7,0xeb,0x7c,0x5a,0xb8,0xb2,0xae, - 0x9c,0xf0,0x7b,0xb8,0xbd,0x4e,0x3b,0xf0,0x67,0x15,0x47,0xc7,0x62,0x6c,0xe5,0xe9, - 0x96,0xb8,0x97,0x10,0x3a,0x1d,0xf2,0x22,0xf4,0x10,0x92,0x46,0xb0,0x09,0xda,0x98, - 0xff,0xef,0xa9,0x1f,0xe8,0x23,0x52,0xfa,0x30,0x9b,0x4b,0xf1,0xe1,0xb6,0x13,0xd4, - 0xd7,0x2c,0x37,0x1d,0x71,0x91,0x0f,0x0a,0x22,0x9d,0x31,0x2a,0x5e,0x70,0xa1,0xe2, - 0x7d,0xeb,0x3d,0x06,0xc6,0xfb,0xe7,0x96,0x96,0x43,0xcc,0xdc,0x29,0xa1,0xfa,0xbb, - 0x45,0x16,0x4c,0xbe,0xa1,0xad,0xce,0x0e,0x8b,0x95,0x50,0xac,0x7e,0x8d,0x68,0x08, - 0xd4,0xe2,0xa6,0x63,0x70,0xb4,0x1e,0x1a,0x80,0xcb,0x6d,0xa6,0xf5,0xf5,0xcc,0xe8, - 0xeb,0xc2,0x49,0x08,0x72,0xf3,0xad,0x4a,0xb9,0x0a,0xec,0xf7,0x35,0x97,0x6f,0x72, - 0x0c,0x48,0xc6,0xa8,0x54,0xc7,0x93,0xd4,0xf7,0x70,0x5a,0xe9,0x16,0x08,0xb5,0xfc, - 0xf9,0xb2,0xb6,0xe4,0xc2,0xd4,0xfd,0x31,0xe9,0xe6,0x3c,0x3a,0x67,0xcc,0x35,0xf5, - 0xfd,0x81,0xb6,0x14,0xff,0xb8,0xfb,0x4f,0x0f,0xc2,0x2d,0xd0,0x57,0xdf,0xa4,0x5f, - 0x1e,0x4d,0x01,0x41,0x4f,0xfe,0x76,0x50,0x66,0x83,0x75,0x90,0x06,0xbf,0x2d,0xf1, - 0x27,0x46,0x7e,0x32,0xc4,0xc5,0x2f,0xf4,0x26,0x7f,0x46,0x30,0x3d,0x30,0x21,0x30, - 0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1a,0x05,0x00,0x04,0x14,0x33,0x7b,0x5c,0xd1, - 0x1b,0xad,0x79,0x93,0x10,0xa3,0x79,0x2e,0xae,0x8b,0x10,0x87,0xba,0x28,0xf7,0xa6, - 0x04,0x14,0x84,0x78,0x82,0x85,0xc4,0x9e,0xa2,0x14,0x4f,0xad,0x59,0x15,0x3d,0x23, - 0xe6,0x62,0xbf,0x6d,0x8c,0x06,0x02,0x02,0x04,0x00 - ]); - - /* 安装凭据对应的密码,业务赋值 */ - let keystorePwd: string = 'huawei'; - let appKeyUri: string = ''; - try { - /* 安装私有凭据 */ - const res: certificateManager.CMResult = await certificateManager.installPrivateCertificate(keystore, keystorePwd, 'testPriCredential'); - appKeyUri = (res.uri != undefined) ? res.uri : ''; - } catch (err) { - let e: BusinessError = err as BusinessError; - console.error(`Failed to install private certificate. Code: ${e.code}, message: ${e.message}`); - } - - try { - /* srcData为待签名、验签的数据,业务自行赋值 */ - let srcData: Uint8Array = new Uint8Array([ - 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, - ]); - - /* 构造签名的属性参数 */ - const signSpec: certificateManager.CMSignatureSpec = { - purpose: certificateManager.CmKeyPurpose.CM_KEY_PURPOSE_SIGN, - padding: certificateManager.CmKeyPadding.CM_PADDING_PSS, - digest: certificateManager.CmKeyDigest.CM_DIGEST_SHA256 - }; - - /* 签名 */ - const signHandle: certificateManager.CMHandle = await certificateManager.init(appKeyUri, signSpec); - await certificateManager.update(signHandle.handle, srcData); - const signResult: certificateManager.CMResult = await certificateManager.finish(signHandle.handle); - - /* 构造验签的的属性参数 */ - const verifySpec: certificateManager.CMSignatureSpec = { - purpose: certificateManager.CmKeyPurpose.CM_KEY_PURPOSE_VERIFY, - padding: certificateManager.CmKeyPadding.CM_PADDING_PSS, - digest: certificateManager.CmKeyDigest.CM_DIGEST_SHA256 - }; - - /* 验签 */ - const verifyHandle: certificateManager.CMHandle = await certificateManager.init(appKeyUri, verifySpec); - await certificateManager.update(verifyHandle.handle, srcData); - const verifyResult = await certificateManager.finish(verifyHandle.handle, signResult.outData); - console.info('Succeeded in signing and verifying.'); - } catch (err) { - let e: BusinessError = err as BusinessError; - console.error(`Failed to sign or verify. Code: ${e.code}, message: ${e.message}`); - } - - try { - /* 卸载私有凭据 */ - await certificateManager.uninstallPrivateCertificate(appKeyUri); - } catch (err) { - let e: BusinessError = err as BusinessError; - console.error(`Failed to uninstall private certificate. Code: ${e.code}, message: ${e.message}`); - } -} - -// [End certificate_management_development_guidance] - -@Entry -@Component -struct Index { - @State message: string = 'CertManagerGuidelines'; - - build() { - Column({space: 5}) { - Text(this.message) - .fontSize(25) - .fontWeight(FontWeight.Bold) - Button($r('app.string.call_certManagerGuidelines')) - .width('70%') - .onClick(()=>{ - certificateManagerSample(); - this.message = 'CertManagerGuidelines Success'; - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start certificate_management_development_guidance] + +import { certificateManager } from '@kit.DeviceCertificateKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +async function certificateManagerSample() { + /* 安装的凭据数据需要业务赋值,本例数据非凭据数据 */ + let keystore: Uint8Array = new Uint8Array([ + 0x30,0x82,0x0c,0x26,0x02,0x01,0x03,0x30,0x82,0x0b,0xe0,0x06,0x09,0x2a,0x86,0x48, + 0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x82,0x0b,0xd1,0x04,0x82,0x0b,0xcd,0x30,0x82, + 0x0b,0xc9,0x30,0x82,0x05,0x6e,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07, + 0x01,0xa0,0x82,0x05,0x5f,0x04,0x82,0x05,0x5b,0x30,0x82,0x05,0x57,0x30,0x82,0x05, + 0x53,0x06,0x0b,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x0a,0x01,0x02,0xa0,0x82, + 0x04,0xfa,0x30,0x82,0x04,0xf6,0x30,0x28,0x06,0x0a,0x2a,0x86,0x48,0x86,0xf7,0x0d, + 0x01,0x0c,0x01,0x03,0x30,0x1a,0x04,0x14,0xb6,0x80,0x7d,0xb9,0xc3,0x44,0x84,0x1f, + 0x44,0xe6,0x95,0x6a,0x98,0xa1,0xcb,0x97,0xfb,0x2b,0xcc,0x5a,0x02,0x02,0x04,0x00, + 0x04,0x82,0x04,0xc8,0x78,0xa7,0x16,0x45,0x40,0xf0,0xec,0xac,0x3e,0x34,0x17,0xd7, + 0x8b,0x5c,0xca,0x85,0x29,0x0b,0x08,0xef,0xa2,0xf0,0x6d,0x55,0xd7,0xde,0x96,0xa5, + 0x49,0x6d,0x9d,0xa6,0xe6,0x00,0xd7,0x2c,0x65,0xf6,0xc2,0xd1,0xe8,0x70,0xfb,0xb5, + 0xd9,0xc6,0x7d,0xd4,0x28,0x45,0x17,0x4f,0x4f,0xd9,0x9b,0xab,0xe2,0xdc,0xe7,0x22, + 0x6c,0x1e,0xbc,0xd6,0xf0,0x38,0x0b,0xd7,0xd9,0xfc,0xa7,0xb4,0x87,0x95,0x96,0xc3, + 0x93,0xc0,0xb5,0x37,0xf4,0x64,0xfe,0xe5,0x07,0xac,0x41,0x2d,0xf5,0xeb,0xe3,0x8b, + 0xc2,0x74,0x73,0x13,0x3b,0x5f,0x17,0x54,0x2d,0x31,0x20,0x69,0x1c,0xab,0x66,0xba, + 0x06,0x43,0x03,0xa3,0x69,0x54,0x72,0x70,0x5f,0x78,0xd2,0xec,0xdd,0x50,0xb8,0x25, + 0x03,0xd4,0xec,0x2d,0x92,0x96,0x9f,0xcc,0xa6,0x4a,0x50,0x34,0x1c,0xfc,0xe3,0xc2, + 0x6b,0x65,0xec,0xb3,0x1c,0xc8,0xf2,0xd0,0x79,0xf0,0x28,0x61,0x9a,0xfe,0xea,0x7f, + 0x16,0x38,0xe1,0xf4,0x7f,0x86,0xfe,0x73,0x67,0xc9,0x60,0x73,0xd8,0xef,0x2c,0x6b, + 0xde,0x88,0x37,0xc5,0xd7,0x18,0x60,0x74,0x97,0x07,0x85,0x70,0x74,0x30,0x66,0x8f, + 0x11,0x4a,0xb9,0x18,0xed,0xfc,0xc7,0xdb,0x63,0x58,0x7b,0x57,0x0d,0xfa,0x43,0x81, + 0xbd,0x34,0xfc,0x17,0xd3,0x2a,0xa9,0x74,0xa0,0x2c,0x1b,0xe2,0xaa,0x3d,0xd2,0x84, + 0x18,0xaa,0x2a,0x0e,0xa8,0xcc,0x2a,0xc4,0x39,0x60,0x29,0xb5,0x03,0xaf,0xea,0x96, + 0xcf,0xa5,0x67,0x4c,0xa7,0x59,0x76,0xea,0x8a,0x60,0xd6,0xd8,0xc3,0x9e,0x0e,0xad, + 0xd6,0xa0,0x5a,0x00,0x7c,0xa6,0xe8,0x62,0xa4,0x0a,0x53,0xcc,0x48,0xf0,0x4d,0x6d, + 0xda,0xb3,0xa9,0x82,0x37,0x75,0xff,0x20,0xa9,0xe8,0x6e,0xc8,0x4a,0x8a,0x81,0x84, + 0x7a,0x1d,0x02,0x40,0xd9,0x76,0xee,0x89,0x62,0xd5,0x57,0x19,0xc8,0x9a,0x6a,0x22, + 0x8d,0x01,0x8f,0xc9,0x14,0x72,0xf9,0x90,0xa3,0x0f,0x5f,0x23,0x32,0xc4,0xd5,0x79, + 0x53,0x1f,0xbc,0x3a,0xf4,0x19,0x7f,0x93,0xb7,0x8b,0x0b,0xb9,0xeb,0x1f,0xa2,0x5c, + 0x93,0x0e,0x5f,0x29,0x87,0xea,0x67,0x4d,0x5d,0x2b,0x5e,0x29,0x81,0xbd,0x3d,0xfc, + 0xdf,0x92,0x50,0x19,0xc2,0x50,0x4d,0x07,0x76,0x08,0xfc,0xbe,0xd1,0x73,0x64,0xb7, + 0x22,0x6f,0xb7,0x89,0x93,0xc1,0xb1,0x44,0x42,0x27,0xf5,0x61,0x06,0x32,0xd1,0xc0, + 0xdb,0x92,0x51,0x1b,0xd3,0x5c,0x95,0x85,0x0e,0x66,0xc5,0xe9,0xf5,0x7f,0x44,0x52, + 0x49,0xfb,0x0a,0x83,0x02,0x6e,0x69,0x6c,0xf1,0x6f,0xe5,0xa1,0xa0,0x5d,0x8a,0xd3, + 0x4f,0x9d,0x0a,0x08,0x1b,0x32,0x70,0xe3,0xf3,0xf0,0x63,0xda,0x37,0x90,0x96,0x3f, + 0xac,0xf7,0x3d,0xd5,0xeb,0x08,0xc1,0x51,0x91,0x75,0x2c,0x0f,0xf1,0x5b,0x39,0xce, + 0x05,0x06,0x65,0x1c,0xe8,0x36,0xb0,0x86,0x6e,0xbe,0xb9,0x25,0xd6,0xdf,0x5c,0x50, + 0x56,0x99,0x69,0x8e,0x92,0xbe,0xa1,0x03,0x18,0xd6,0x34,0xa6,0x98,0x53,0x3a,0xb7, + 0x96,0xcb,0xa8,0x1d,0xc9,0x9e,0x92,0x15,0xf4,0x99,0x7e,0x58,0x81,0x99,0x84,0xa0, + 0x67,0xa5,0x77,0x1e,0xa9,0xac,0xc2,0xcf,0xd8,0x7a,0x68,0xef,0x35,0x9e,0xb6,0xb7, + 0x78,0x6b,0x43,0x12,0x53,0x93,0x7b,0x50,0x94,0x37,0x48,0x75,0x98,0x27,0x0f,0x73, + 0x1a,0xb7,0x2f,0x19,0x7e,0x42,0x08,0x02,0x05,0x42,0x71,0xd6,0x26,0x64,0x04,0x25, + 0x87,0xd9,0x02,0x05,0x1f,0x79,0x6b,0x9b,0x0e,0xfa,0x10,0x7b,0xf3,0x96,0x3f,0x53, + 0x02,0x9d,0x80,0x13,0xd7,0x30,0x03,0x24,0x96,0x21,0x05,0xdb,0x2d,0xe9,0xc8,0x51, + 0x30,0x42,0x6d,0xa9,0xe8,0x39,0xb0,0xa9,0x59,0xb9,0x21,0x22,0x98,0x41,0x0e,0x33, + 0x0d,0x7f,0x7a,0x69,0x45,0x0b,0xf1,0xac,0xfd,0xaa,0xaa,0x45,0x7f,0x78,0x24,0xf8, + 0x56,0x85,0x3b,0x4b,0x95,0x78,0x40,0xc7,0x2f,0xfc,0xb6,0xb7,0x5f,0xa2,0xf9,0xe9, + 0x80,0x4c,0x4a,0xbf,0x4f,0xcb,0xb9,0x51,0x7c,0x18,0xb7,0xb7,0x70,0xf1,0x4c,0x96, + 0xd2,0x4a,0x44,0xb9,0xa6,0x22,0xc9,0x95,0xf5,0x99,0xbd,0x8c,0xf2,0x45,0x88,0xfb, + 0x2f,0xe0,0x38,0x42,0xc8,0xe5,0x0d,0x55,0x05,0x0f,0xb9,0x91,0x7d,0xaf,0x27,0x91, + 0xb3,0xc4,0x83,0x46,0x49,0x1a,0xce,0x3a,0xff,0x1b,0x58,0xc9,0xa4,0x22,0x82,0x57, + 0x7f,0xda,0x5f,0xae,0xea,0xae,0x96,0x91,0xef,0xde,0x4e,0x25,0x66,0xbb,0xe9,0xb3, + 0xa7,0xbc,0x12,0xc4,0x5f,0xee,0xc6,0x13,0x9c,0xd9,0xbc,0x14,0xef,0x3d,0x7b,0xa4, + 0x91,0x4a,0x77,0xfd,0x18,0x9c,0xc7,0x38,0xaf,0x24,0x3f,0x6c,0x8f,0x8f,0x6e,0x2c, + 0x38,0x7c,0xa4,0xba,0xc7,0x70,0x90,0x6d,0x5e,0x51,0x3c,0xe0,0x3d,0xc5,0xa8,0x44, + 0xb0,0xf4,0x0b,0xba,0xe0,0x0e,0x8b,0x65,0xeb,0x04,0xfd,0x1a,0x8b,0x94,0xbf,0xfe, + 0xf0,0x64,0xa4,0xfa,0xb4,0xe1,0x11,0xd4,0x95,0x13,0xee,0xce,0xf6,0x14,0xf7,0x1c, + 0xbc,0xf5,0x64,0x90,0x88,0x69,0xb2,0xfd,0x26,0x26,0x83,0xa7,0x4c,0x3d,0x27,0xae, + 0x3c,0x68,0xb5,0xcc,0x9f,0x46,0xc2,0x9a,0x95,0x9a,0xa7,0x8b,0x4a,0x14,0xf7,0x80, + 0x9f,0x04,0xf9,0x39,0x3b,0x55,0x9e,0xb5,0x1c,0x79,0x7d,0x2d,0x9b,0x29,0xb9,0x7c, + 0x61,0x01,0xf5,0x26,0x1e,0xa0,0xcb,0x18,0xaf,0xc6,0x6d,0x2f,0x42,0xb7,0xa5,0x94, + 0x91,0xa5,0xc0,0x15,0xd9,0x18,0x4e,0xb6,0xc3,0x77,0x9e,0x59,0x6e,0x61,0x48,0x32, + 0xcf,0x5e,0x09,0x3a,0x17,0x48,0x59,0x68,0x9a,0x6c,0x7f,0xd3,0x71,0xd8,0x2c,0xce, + 0x58,0x68,0x33,0x79,0xe6,0xb6,0xf0,0xb5,0xac,0xb0,0xa4,0xc0,0x10,0x0f,0xad,0x02, + 0x19,0x58,0x53,0x5a,0x9a,0x5d,0x84,0xa6,0x8e,0x3c,0xc8,0xa9,0x22,0xb5,0x2a,0x39, + 0x3f,0xf8,0x76,0x53,0xea,0x7b,0x23,0x81,0x2b,0xe1,0x1d,0x63,0xb3,0x83,0x76,0xc8, + 0xd3,0x5e,0xba,0x97,0x79,0x9b,0xfb,0xf3,0x1e,0x10,0xac,0xd8,0x2e,0xa0,0x64,0xba, + 0x02,0x21,0x18,0x05,0xd1,0x30,0xdd,0x33,0x32,0x98,0x3d,0x0d,0x22,0xb4,0xda,0x8d, + 0xa0,0x9a,0x3a,0x97,0x0f,0xa5,0xe1,0xf1,0x56,0x17,0xd8,0xbd,0x15,0xd3,0xd6,0xe0, + 0x20,0x95,0x7b,0x6a,0x63,0x59,0x80,0xee,0xcd,0x60,0xb1,0xb0,0xba,0x8d,0x6a,0x4c, + 0x3d,0x5c,0xac,0x1a,0x87,0x1d,0x07,0xfe,0x69,0x81,0x8f,0x5d,0xba,0x64,0x3f,0xea, + 0xdf,0x36,0xb3,0x07,0x6c,0xbc,0x5b,0xe8,0xc0,0x5c,0x9a,0xd1,0x16,0xe3,0x2e,0xa5, + 0x92,0x5b,0xba,0x89,0x55,0x65,0x5d,0x14,0xd2,0x36,0x9e,0xfd,0x6d,0xcf,0x9d,0x68, + 0x10,0x7f,0xb6,0xdf,0x6b,0x9a,0x9b,0xd4,0x6b,0x37,0xfd,0x77,0xde,0x39,0x59,0xed, + 0xe3,0xdb,0x65,0xe8,0xa4,0x15,0x4a,0x6d,0xb4,0xad,0xb8,0x36,0xe1,0x3a,0xf8,0x6a, + 0xfe,0x6e,0x1f,0x02,0x15,0x09,0x36,0x44,0xb7,0x52,0x5b,0x79,0x3c,0x8e,0xfb,0x20, + 0x62,0xdb,0x7b,0xb6,0xb1,0x43,0xea,0x29,0xff,0x10,0xef,0x24,0x9c,0x4d,0xc2,0xa8, + 0x98,0xaa,0x29,0x59,0x85,0x06,0xc3,0xdb,0xcf,0xc2,0x71,0xfa,0xad,0x7b,0xd5,0xf7, + 0x50,0x53,0xc5,0x75,0x97,0x15,0x42,0x90,0x8f,0xf1,0xed,0x6a,0x98,0x83,0x59,0x15, + 0x23,0xa7,0xea,0xe9,0xed,0x22,0xec,0x0a,0x41,0x4c,0xc2,0x35,0x54,0xd9,0xec,0x4b, + 0xb8,0x3f,0xd0,0x68,0xed,0xa7,0x83,0x4e,0x42,0x29,0x5c,0x4d,0xa3,0x79,0x3e,0x59, + 0x86,0x04,0x62,0x24,0x9d,0x7b,0xb3,0x69,0xe9,0x82,0x57,0xdb,0xbf,0xeb,0x98,0x4f, + 0x59,0x7e,0x8d,0x8f,0x69,0x56,0xdc,0x3f,0xeb,0x01,0xcf,0x82,0x05,0x1e,0xe7,0x6d, + 0xff,0xb2,0x67,0xd8,0x34,0x68,0xf7,0xd0,0xee,0x6d,0xc6,0x22,0x4c,0x4d,0x36,0xd1, + 0xf5,0x5a,0xab,0xbb,0x41,0x43,0x4d,0xef,0x2c,0x62,0x64,0x28,0x31,0x46,0x30,0x1f, + 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x09,0x14,0x31,0x12,0x1e,0x10,0x00, + 0x6c,0x00,0x64,0x00,0x71,0x00,0x20,0x00,0x74,0x00,0x65,0x00,0x73,0x00,0x74,0x30, + 0x23,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x09,0x15,0x31,0x16,0x04,0x14, + 0x44,0x37,0x75,0x8f,0xcd,0x94,0x90,0x07,0x3e,0x38,0x20,0xb7,0x1b,0x3f,0x0d,0x3d, + 0x40,0x85,0x32,0x6a,0x30,0x82,0x06,0x53,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d, + 0x01,0x07,0x06,0xa0,0x82,0x06,0x44,0x30,0x82,0x06,0x40,0x02,0x01,0x00,0x30,0x82, + 0x06,0x39,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0x30,0x28,0x06, + 0x0a,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x01,0x06,0x30,0x1a,0x04,0x14,0xc8, + 0xe2,0x48,0x69,0x85,0x06,0xb3,0x34,0x55,0xf1,0xfe,0x9c,0x95,0x92,0xbd,0x73,0xcd, + 0x50,0xf4,0x88,0x02,0x02,0x04,0x00,0x80,0x82,0x06,0x00,0xb6,0x66,0x06,0x1a,0x84, + 0xb1,0xb7,0xf8,0xca,0x74,0xe1,0x7c,0x23,0x94,0x5f,0xb3,0x73,0xda,0x81,0x51,0x0e, + 0x4d,0x07,0xcd,0x8a,0x68,0xd5,0x15,0x98,0x57,0xc1,0xb9,0x94,0x30,0xc7,0x97,0x40, + 0x3b,0xa4,0xc0,0xd5,0xfe,0xd3,0x9f,0x92,0xe9,0x6a,0xeb,0x52,0x1c,0xd8,0x89,0x26, + 0xf4,0x1b,0x49,0xe9,0xef,0x45,0x0b,0x33,0x36,0x73,0x1b,0x91,0x2b,0x75,0xff,0x9b, + 0x12,0x41,0xc7,0x80,0xb1,0x4a,0x12,0xaf,0x02,0x8d,0x4b,0xea,0xcd,0x0e,0xc6,0x03, + 0x14,0x4c,0x79,0xef,0xa6,0xc2,0xf6,0x86,0xd3,0x19,0xfd,0xe6,0x85,0xfa,0x3b,0x0d, + 0x3b,0xb2,0x98,0xd2,0xff,0xa0,0xfe,0x65,0x63,0xc9,0xc2,0xa7,0xf4,0x0d,0x98,0x57, + 0xab,0xd5,0x7b,0x58,0x87,0x62,0x58,0x74,0x40,0x75,0x06,0x8f,0x4a,0x93,0xff,0x76, + 0xbb,0xd3,0x19,0x4d,0xf8,0x04,0x89,0xa4,0xc5,0xe3,0xbe,0xde,0x60,0x04,0x7f,0x52, + 0x58,0x11,0x51,0x6f,0xa9,0xf9,0x06,0x6d,0x03,0x83,0xcd,0xa7,0x01,0xf8,0x2d,0xa0, + 0xe6,0x45,0x63,0x85,0x46,0x7c,0x9b,0x55,0x86,0xfd,0xe9,0xc3,0xd4,0xeb,0xeb,0x3e, + 0x2b,0x0e,0x33,0x8a,0x9f,0x40,0xe3,0x9d,0x52,0xe3,0xf8,0x6f,0x1a,0x4d,0x5f,0xaf, + 0x78,0x12,0x56,0x56,0xab,0x3d,0xbd,0x36,0x8e,0xd9,0xa9,0xc4,0xfc,0xd3,0x21,0x6b, + 0xa7,0xa0,0xa3,0xc6,0x50,0x41,0x43,0xdb,0xd0,0xf7,0x16,0x08,0x06,0x0d,0xed,0x15, + 0x90,0xdc,0x31,0xeb,0x0d,0x4b,0x7b,0x1c,0xa6,0x32,0xca,0x52,0xaa,0x3a,0x71,0xc2, + 0xb7,0xce,0x42,0xd4,0x90,0xbe,0x65,0x0b,0x55,0x54,0x79,0x6b,0xbf,0xbc,0xf7,0x1d, + 0x5f,0x14,0x4a,0x02,0x4c,0x63,0x16,0x6d,0x85,0xad,0xb3,0x1f,0x11,0x43,0x3f,0xd3, + 0x4d,0x3b,0xfc,0x96,0x79,0xca,0xa5,0x9e,0xc1,0xdf,0xbc,0x94,0x2d,0x46,0xe2,0xe7, + 0x1a,0x93,0xfc,0xc5,0x09,0x16,0x8d,0x91,0x41,0xc0,0x59,0x4f,0x9c,0x76,0x94,0x86, + 0xf2,0x59,0x5d,0xca,0xa9,0x20,0x93,0x10,0xd6,0x45,0x3b,0x30,0x55,0xdf,0x96,0x9f, + 0x60,0x06,0x7c,0x9a,0xb9,0x24,0x1e,0xe0,0xae,0x65,0xd5,0x4b,0x4a,0xe2,0x55,0xc7, + 0x09,0xb5,0x51,0x40,0x07,0x7e,0xe1,0xef,0x34,0x63,0x7b,0x3a,0xa9,0x98,0x2f,0x09, + 0xe1,0xfd,0x7a,0xb3,0x29,0x79,0xfc,0xf5,0xbd,0x3c,0x3c,0x05,0x02,0xd5,0xc5,0x86, + 0xaf,0x9a,0xd3,0x10,0x7e,0xc3,0x1b,0xf7,0x73,0x64,0xd6,0x27,0x04,0x08,0xee,0x7b, + 0x49,0x2d,0x21,0x2e,0xd8,0xbc,0x29,0x3a,0x80,0x82,0x2d,0xed,0xf2,0xaf,0x08,0x55, + 0xce,0x80,0x9c,0xf2,0xeb,0x60,0x38,0x12,0x27,0x31,0xa0,0x2f,0x64,0xbf,0x21,0x8c, + 0x63,0x88,0x90,0xee,0x9e,0xc0,0x5f,0xb8,0xea,0xa5,0xf3,0x26,0x01,0x65,0xe3,0x97, + 0xb6,0x17,0x6f,0x6a,0x48,0x77,0xc0,0x26,0x00,0x65,0x19,0xc8,0xe8,0xc6,0x94,0x5d, + 0x03,0xcb,0xc5,0xa9,0x5d,0xc5,0x4b,0x8f,0xcf,0x33,0xeb,0x2a,0x9a,0x5a,0x75,0xe4, + 0xec,0x7d,0x59,0xab,0xd1,0x9a,0xb7,0x73,0x54,0x2a,0xe3,0x3d,0x63,0x62,0xcf,0xa0, + 0x5f,0xb5,0xf4,0x12,0x61,0xa6,0xbb,0xd9,0xf6,0x3f,0xc9,0x0c,0x96,0x9f,0xf8,0xa2, + 0x38,0x2c,0xb5,0xdf,0x26,0x07,0x0d,0xc5,0x43,0x33,0xe3,0x69,0x31,0x56,0x7a,0x4c, + 0x3c,0xc7,0x44,0xa4,0x9f,0x62,0xa4,0x5f,0x9b,0xdd,0xe4,0x24,0x28,0x1b,0xe6,0x72, + 0xc8,0x8d,0xe7,0x40,0x4e,0x81,0xe6,0x8e,0x3c,0xb5,0x53,0xe3,0x0b,0x43,0x69,0xaf, + 0x7d,0xb8,0xfc,0xf2,0xb5,0x2a,0xad,0x95,0xe1,0xb7,0xbd,0xdf,0x3b,0x16,0xac,0x7b, + 0x9f,0xad,0x8f,0x66,0x7d,0x72,0x3e,0xf4,0xdb,0xf5,0xdd,0x91,0x09,0x7a,0x2b,0xf8, + 0x3d,0xa6,0x26,0xec,0x22,0x00,0xcc,0xe6,0xab,0x03,0xe6,0xbe,0x7b,0x70,0x09,0x07, + 0x72,0xfc,0x32,0xf1,0x46,0xda,0x7e,0x0a,0x97,0xcf,0x42,0xaf,0x2d,0x70,0x56,0x34, + 0xce,0xc9,0x7b,0xca,0xb6,0xd5,0xc8,0xd4,0xe3,0x96,0x62,0x02,0x54,0x66,0x65,0x88, + 0xf7,0xe5,0xb6,0x68,0x0d,0x61,0x8d,0x71,0xa4,0x39,0xd0,0xe5,0xf7,0x38,0x27,0x00, + 0x65,0x53,0xd4,0x1b,0x0a,0x94,0x63,0xa8,0x19,0xc3,0x2a,0x5b,0x2a,0x6a,0xb9,0x19, + 0xfa,0x04,0x3e,0xc5,0x0a,0xc6,0x5c,0xc0,0x3f,0xbb,0x3f,0x18,0x9b,0x27,0xdc,0xd5, + 0xf7,0x2b,0x54,0x30,0x68,0x47,0x45,0xae,0x12,0xe4,0xdc,0x71,0xa5,0xbd,0x4b,0x6e, + 0xd6,0xba,0x6e,0x96,0xa6,0x73,0x77,0xc5,0x2b,0x48,0x6d,0x7e,0xbb,0x44,0x6f,0xd5, + 0x5d,0x17,0xcb,0xd6,0x96,0xb8,0xd1,0x06,0xe1,0xea,0x2f,0xa6,0x86,0x1b,0x81,0x97, + 0xbe,0xa0,0xfb,0x9a,0x20,0x6d,0xf5,0x33,0xeb,0x64,0xd3,0x89,0x68,0x8c,0x8b,0xa9, + 0x4f,0x19,0x51,0xb5,0x8d,0x89,0x74,0x51,0x2c,0x90,0x38,0x0e,0x0d,0x18,0x53,0x87, + 0x31,0x62,0x3d,0x54,0x1e,0x74,0xc0,0x9a,0xc3,0x37,0xdd,0x36,0x00,0x5c,0xc9,0xb4, + 0x1d,0x57,0x0b,0xb2,0x43,0x25,0x2b,0xb6,0xee,0x83,0xda,0xfd,0xad,0x41,0x9d,0xf4, + 0xdf,0x60,0xfe,0xa1,0xd0,0x1c,0x78,0x3e,0x36,0x17,0x38,0x4a,0xb2,0x42,0x15,0xac, + 0xa6,0x5e,0x88,0xe3,0x11,0x76,0x48,0xc9,0xcd,0x86,0xbb,0x2b,0x7a,0xab,0xa9,0xfe, + 0x76,0x0f,0xb5,0xb4,0x6e,0x1a,0xfd,0x5f,0xa4,0x20,0x32,0xb2,0xb5,0x4d,0x25,0xa4, + 0x34,0xd3,0x06,0xf4,0xc6,0x6e,0x83,0xcb,0x5e,0x87,0xe0,0x25,0xee,0x17,0x58,0x2e, + 0xaa,0x3c,0x54,0xf1,0xb5,0x33,0xcd,0xa7,0x37,0x78,0x10,0x25,0x23,0x90,0x8a,0x80, + 0x3f,0xbb,0x4b,0xdf,0x89,0xc2,0xee,0x5c,0x78,0x33,0x1a,0x76,0x3e,0xf9,0x46,0x49, + 0x50,0x0c,0x39,0x38,0x33,0x6b,0xbe,0xae,0xec,0xec,0xf9,0xf5,0x1c,0x40,0xa1,0xa7, + 0x29,0x0e,0x02,0x7a,0xd7,0xb9,0x0b,0x2e,0x6f,0x9f,0x33,0x97,0x63,0x87,0xe0,0xb7, + 0xf6,0x9e,0xa0,0x43,0xa6,0xbe,0x04,0x3f,0x3f,0x8a,0xcc,0x8d,0xd3,0xbc,0x15,0x0e, + 0x9b,0xb7,0x99,0xc1,0x3f,0xfa,0xaf,0x8a,0xc4,0x67,0x0d,0x36,0xda,0xab,0xf5,0xe9, + 0x77,0xa9,0x84,0x0b,0xf9,0x22,0x49,0x15,0x9d,0x72,0x62,0x73,0x21,0x90,0x14,0x6e, + 0x4b,0x2d,0x50,0x80,0x02,0x5e,0x79,0x66,0x7d,0x8c,0x5b,0xf8,0x2a,0x0c,0x2e,0x62, + 0x15,0x85,0x78,0xce,0xa7,0xb6,0x33,0x8f,0xba,0xe4,0xb1,0xa5,0x9e,0xea,0x66,0x9e, + 0x9c,0x98,0x7d,0x90,0x75,0x6f,0xd4,0xc0,0xd5,0x42,0x5d,0x5e,0xd4,0xab,0xed,0x1e, + 0xe0,0x77,0x48,0xaf,0x13,0xac,0x89,0x8c,0x2a,0x2a,0x6b,0xb1,0x45,0xca,0xae,0x86, + 0xfc,0xd8,0x15,0x4e,0xae,0xce,0x00,0x63,0x71,0xa6,0xef,0x43,0xdd,0x1c,0x77,0x21, + 0x85,0xa8,0xd2,0x46,0x61,0xf0,0xfd,0xcb,0x43,0x31,0x41,0x35,0xda,0x2f,0xa9,0xc8, + 0xb0,0x5f,0xd6,0xc9,0x7b,0x43,0x97,0x28,0xfa,0x2e,0xe7,0x07,0x8e,0x32,0xd5,0xf5, + 0x30,0x2f,0x76,0x51,0x4b,0x21,0xcf,0xbd,0xc2,0x3a,0x5e,0x85,0x60,0x2b,0x42,0xc5, + 0x56,0x70,0xf1,0xfb,0xce,0xd5,0xee,0x4f,0x30,0x33,0x08,0xea,0x3b,0xa7,0x31,0x54, + 0x67,0xc2,0x07,0x2d,0x7c,0x2f,0x43,0xbe,0x34,0x34,0xd4,0x11,0x5c,0x8f,0x94,0x6a, + 0x77,0xcb,0x03,0x77,0x48,0x33,0xac,0x77,0x78,0x42,0x6c,0x6f,0x08,0x93,0x23,0x5c, + 0xb8,0x6e,0xae,0xac,0xd0,0x33,0x85,0x1a,0x55,0xd5,0x85,0xa7,0x00,0xf0,0xf9,0x01, + 0x58,0xac,0x39,0x10,0x05,0x45,0x3e,0xb0,0xa9,0x86,0x12,0x78,0xe7,0xad,0xb0,0xee, + 0x4f,0xc7,0x34,0xf4,0x09,0x9c,0x70,0x77,0xa7,0x41,0xb3,0x54,0xc3,0xc4,0xa0,0xf2, + 0x72,0x50,0x74,0x9c,0xed,0x16,0x45,0x92,0x15,0xa8,0x42,0x86,0x93,0x4e,0x28,0x79, + 0x1e,0x80,0x7a,0x13,0xae,0x4d,0x37,0x55,0xeb,0xbd,0x83,0x35,0xec,0x20,0xa1,0x83, + 0x19,0x50,0x30,0x02,0x6c,0x48,0x78,0x3b,0xa9,0x6f,0x18,0x57,0x69,0x3a,0x5b,0xdb, + 0xd6,0x77,0x7f,0x5c,0x0d,0xe3,0xd1,0xd0,0x27,0x1f,0x3f,0xd2,0xfb,0x6b,0xab,0x36, + 0x44,0x58,0x6f,0xf4,0xa2,0x45,0x32,0xc9,0x05,0x67,0xd9,0x1a,0x9c,0x9b,0x63,0x31, + 0x7a,0x54,0xbd,0xa0,0x63,0x7a,0x01,0x73,0xbc,0xcc,0xd2,0xe2,0x44,0x17,0xd2,0xd7, + 0xb8,0x76,0x7e,0xb7,0x5a,0x04,0xfc,0xb9,0xd9,0xed,0xd2,0x76,0x38,0x21,0x71,0xfc, + 0x83,0x55,0x89,0x30,0x6e,0xf8,0x0d,0xc0,0xe7,0xb6,0x8e,0x1a,0x44,0xf6,0x8d,0xdb, + 0x2a,0x01,0xf6,0x55,0x6f,0x43,0xbe,0x66,0x39,0xd7,0xeb,0x7c,0x5a,0xb8,0xb2,0xae, + 0x9c,0xf0,0x7b,0xb8,0xbd,0x4e,0x3b,0xf0,0x67,0x15,0x47,0xc7,0x62,0x6c,0xe5,0xe9, + 0x96,0xb8,0x97,0x10,0x3a,0x1d,0xf2,0x22,0xf4,0x10,0x92,0x46,0xb0,0x09,0xda,0x98, + 0xff,0xef,0xa9,0x1f,0xe8,0x23,0x52,0xfa,0x30,0x9b,0x4b,0xf1,0xe1,0xb6,0x13,0xd4, + 0xd7,0x2c,0x37,0x1d,0x71,0x91,0x0f,0x0a,0x22,0x9d,0x31,0x2a,0x5e,0x70,0xa1,0xe2, + 0x7d,0xeb,0x3d,0x06,0xc6,0xfb,0xe7,0x96,0x96,0x43,0xcc,0xdc,0x29,0xa1,0xfa,0xbb, + 0x45,0x16,0x4c,0xbe,0xa1,0xad,0xce,0x0e,0x8b,0x95,0x50,0xac,0x7e,0x8d,0x68,0x08, + 0xd4,0xe2,0xa6,0x63,0x70,0xb4,0x1e,0x1a,0x80,0xcb,0x6d,0xa6,0xf5,0xf5,0xcc,0xe8, + 0xeb,0xc2,0x49,0x08,0x72,0xf3,0xad,0x4a,0xb9,0x0a,0xec,0xf7,0x35,0x97,0x6f,0x72, + 0x0c,0x48,0xc6,0xa8,0x54,0xc7,0x93,0xd4,0xf7,0x70,0x5a,0xe9,0x16,0x08,0xb5,0xfc, + 0xf9,0xb2,0xb6,0xe4,0xc2,0xd4,0xfd,0x31,0xe9,0xe6,0x3c,0x3a,0x67,0xcc,0x35,0xf5, + 0xfd,0x81,0xb6,0x14,0xff,0xb8,0xfb,0x4f,0x0f,0xc2,0x2d,0xd0,0x57,0xdf,0xa4,0x5f, + 0x1e,0x4d,0x01,0x41,0x4f,0xfe,0x76,0x50,0x66,0x83,0x75,0x90,0x06,0xbf,0x2d,0xf1, + 0x27,0x46,0x7e,0x32,0xc4,0xc5,0x2f,0xf4,0x26,0x7f,0x46,0x30,0x3d,0x30,0x21,0x30, + 0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1a,0x05,0x00,0x04,0x14,0x33,0x7b,0x5c,0xd1, + 0x1b,0xad,0x79,0x93,0x10,0xa3,0x79,0x2e,0xae,0x8b,0x10,0x87,0xba,0x28,0xf7,0xa6, + 0x04,0x14,0x84,0x78,0x82,0x85,0xc4,0x9e,0xa2,0x14,0x4f,0xad,0x59,0x15,0x3d,0x23, + 0xe6,0x62,0xbf,0x6d,0x8c,0x06,0x02,0x02,0x04,0x00 + ]); + + /* 安装凭据对应的密码,业务赋值 */ + let keystorePwd: string = 'huawei'; + let appKeyUri: string = ''; + try { + /* 安装私有凭据 */ + const res: certificateManager.CMResult = await certificateManager.installPrivateCertificate(keystore, keystorePwd, 'testPriCredential'); + appKeyUri = (res.uri != undefined) ? res.uri : ''; + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`Failed to install private certificate. Code: ${e.code}, message: ${e.message}`); + } + + try { + /* srcData为待签名、验签的数据,业务自行赋值 */ + let srcData: Uint8Array = new Uint8Array([ + 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, + ]); + + /* 构造签名的属性参数 */ + const signSpec: certificateManager.CMSignatureSpec = { + purpose: certificateManager.CmKeyPurpose.CM_KEY_PURPOSE_SIGN, + padding: certificateManager.CmKeyPadding.CM_PADDING_PSS, + digest: certificateManager.CmKeyDigest.CM_DIGEST_SHA256 + }; + + /* 签名 */ + const signHandle: certificateManager.CMHandle = await certificateManager.init(appKeyUri, signSpec); + await certificateManager.update(signHandle.handle, srcData); + const signResult: certificateManager.CMResult = await certificateManager.finish(signHandle.handle); + + /* 构造验签的的属性参数 */ + const verifySpec: certificateManager.CMSignatureSpec = { + purpose: certificateManager.CmKeyPurpose.CM_KEY_PURPOSE_VERIFY, + padding: certificateManager.CmKeyPadding.CM_PADDING_PSS, + digest: certificateManager.CmKeyDigest.CM_DIGEST_SHA256 + }; + + /* 验签 */ + const verifyHandle: certificateManager.CMHandle = await certificateManager.init(appKeyUri, verifySpec); + await certificateManager.update(verifyHandle.handle, srcData); + const verifyResult = await certificateManager.finish(verifyHandle.handle, signResult.outData); + console.info('Succeeded in signing and verifying.'); + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`Failed to sign or verify. Code: ${e.code}, message: ${e.message}`); + } + + try { + /* 卸载私有凭据 */ + await certificateManager.uninstallPrivateCertificate(appKeyUri); + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`Failed to uninstall private certificate. Code: ${e.code}, message: ${e.message}`); + } +} + +// [End certificate_management_development_guidance] + +@Entry +@Component +struct Index { + @State message: string = 'CertManagerGuidelines'; + + build() { + Column({space: 5}) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_certManagerGuidelines')) + .width('70%') + .onClick(()=>{ + certificateManagerSample(); + this.message = 'CertManagerGuidelines Success'; + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/module.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/module.json5 old mode 100755 new mode 100644 index a42c7d6374..6ec5c351a4 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/module.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/module.json5 @@ -1,78 +1,78 @@ -/* - * 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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.ACCESS_CERT_MANAGER", - "reason": "$string:reason", - "usedScene": { - "abilities": [ - "FormAbility" - ], - "when": "always" - } - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.ACCESS_CERT_MANAGER", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "FormAbility" + ], + "when": "always" + } + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/CertificateManagement.test.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/CertificateManagement.test.ets old mode 100755 new mode 100644 index c4ad7137ad..f5d4e58759 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/CertificateManagement.test.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/CertificateManagement.test.ets @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -function resourceToString(resource: Resource) { - return getContext().resourceManager.getStringSync(resource); -} - -export default function certificateManagementTest() { - describe('certificateManagementTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,安装、获取、使用、卸载证书 - */ - it('testCertificateManagement001', 0, async (done: Function) => { - console.info('uitest: testCertificateManagement001 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('CertManagerGuidelines')); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CertManagerGuidelines')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('CertManagerGuidelines Success')); - console.info('uitest: testCertificateManagement001 end'); - await driver.pressBack(); - done(); - }) - - /** - * 点击按钮,拉起证书管理界面 - */ - it('testCertificateManagement002', 0, async (done: Function) => { - console.info('uitest: testCertificateManagement002 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button1 = await driver.findComponent(ON.text('CertManagerDialogGuidelines')); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CertManagerDialogGuidelines')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text(resourceToString($r('app.string.dialog')))); - console.info('uitest: testCertificateManagement002 end'); - done(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +function resourceToString(resource: Resource) { + return getContext().resourceManager.getStringSync(resource); +} + +export default function certificateManagementTest() { + describe('certificateManagementTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,安装、获取、使用、卸载证书 + */ + it('testCertificateManagement001', 0, async (done: Function) => { + console.info('uitest: testCertificateManagement001 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('CertManagerGuidelines')); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CertManagerGuidelines')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('CertManagerGuidelines Success')); + console.info('uitest: testCertificateManagement001 end'); + await driver.pressBack(); + done(); + }) + + /** + * 点击按钮,拉起证书管理界面 + */ + it('testCertificateManagement002', 0, async (done: Function) => { + console.info('uitest: testCertificateManagement002 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button1 = await driver.findComponent(ON.text('CertManagerDialogGuidelines')); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CertManagerDialogGuidelines')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text(resourceToString($r('app.string.dialog')))); + console.info('uitest: testCertificateManagement002 end'); + done(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/List.test.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/hvigor/hvigor-config.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/DeviceCertificateKit/CertificateManagement/hvigorfile.ts b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/oh-package.json5 b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/oh-package.json5 +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/ohosTest.md b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/ohosTest.md old mode 100755 new mode 100644 index dd7dfc6a9d..6301852ad7 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/ohosTest.md +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/ohosTest.md @@ -1,9 +1,9 @@ -# **证书管理**测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------------------- | ------------ | ---- | ---------------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮安装,获取,应用私有凭据进行签名、验签,删除 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +# **证书管理**测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------------------- | ------------ | ---- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮安装,获取,应用私有凭据进行签名、验签,删除 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | | 点击按钮拉起证书管理界面 | 成功拉起应用 | | 成功拉起弹窗并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement1.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement2.png b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/app.json5 old mode 100755 new mode 100644 index cd3e2cc1f7..dddc4dae3e --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/app.json5 @@ -1,25 +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.keydeletion", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.keydeletion", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 90445a8bb9..6871b23fb4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "KeyDeletion" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "KeyDeletion" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/KeyDeletion/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index baaca7e6a4..7395e4fc05 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(KeyDeletion) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(KeyDeletion) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 3a5cdcb34a..086974eaa5 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp @@ -1,116 +1,116 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start key_deletion] -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include -// [StartExclude key_deletion] -/* 以下以生成ECC密钥为例 */ -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} - -struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; - -static OH_Huks_Result GenerateKeyHelper(const char *alias) -{ - struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; - struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr; - struct OH_Huks_Result ohResult; - do { - /* 1.初始化密钥属性集 */ - ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam, - sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 2.生成密钥 */ - ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr); - } while (0); - OH_Huks_FreeParamSet(&testGenerateKeyParamSet); - return ohResult; -} -// [EndExclude key_deletion] -static napi_value DeleteKey(napi_env env, napi_callback_info info) -{ - /* 1.获取密钥别名 */ - const char *alias = "test_key"; - struct OH_Huks_Blob keyAlias = { - (uint32_t)strlen("test_key"), - (uint8_t *)"test_key" - }; - // [StartExclude key_deletion] - /* 生成密钥 */ - OH_Huks_Result genResult = GenerateKeyHelper(alias); - if (genResult.errorCode != OH_HUKS_SUCCESS) { - napi_value ret; - napi_create_int32(env, genResult.errorCode, &ret); - return ret; - } - // [EndExclude key_deletion] - - /* 2.调用OH_Huks_DeleteKeyItem删除密钥 */ - struct OH_Huks_Result ohResult = OH_Huks_DeleteKeyItem(&keyAlias, nullptr); - - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} -// [End key_deletion] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "deleteKey", nullptr, DeleteKey, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start key_deletion] +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include +// [StartExclude key_deletion] +/* 以下以生成ECC密钥为例 */ +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} + +struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; + +static OH_Huks_Result GenerateKeyHelper(const char *alias) +{ + struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; + struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr; + struct OH_Huks_Result ohResult; + do { + /* 1.初始化密钥属性集 */ + ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam, + sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 2.生成密钥 */ + ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr); + } while (0); + OH_Huks_FreeParamSet(&testGenerateKeyParamSet); + return ohResult; +} +// [EndExclude key_deletion] +static napi_value DeleteKey(napi_env env, napi_callback_info info) +{ + /* 1.获取密钥别名 */ + const char *alias = "test_key"; + struct OH_Huks_Blob keyAlias = { + (uint32_t)strlen("test_key"), + (uint8_t *)"test_key" + }; + // [StartExclude key_deletion] + /* 生成密钥 */ + OH_Huks_Result genResult = GenerateKeyHelper(alias); + if (genResult.errorCode != OH_HUKS_SUCCESS) { + napi_value ret; + napi_create_int32(env, genResult.errorCode, &ret); + return ret; + } + // [EndExclude key_deletion] + + /* 2.调用OH_Huks_DeleteKeyItem删除密钥 */ + struct OH_Huks_Result ohResult = OH_Huks_DeleteKeyItem(&keyAlias, nullptr); + + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} +// [End key_deletion] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "deleteKey", nullptr, DeleteKey, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index 4ebb6e3b65..70baf682c5 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 deleteKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets old mode 100755 new mode 100644 index a5cc677a2f..30a8e4ea27 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets @@ -1,171 +1,171 @@ -/* - * 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. - */ - -/* - * 以下以HKDF256密钥的Promise操作使用为例 - */ -// [Start key_deletions] -import { huks } from '@kit.UniversalKeystoreKit'; - -/* 1.确定密钥别名 */ -let keyAlias = 'test_Key'; -// [StartExclude key_deletions] -/* 2.初始化密钥属性集 */ -let generateProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DH - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048 - } -]; - -let generateHuksOptions: huks.HuksOptions = { - properties: generateProperties, - inData: new Uint8Array([]) -} - -/* 3.生成密钥 */ -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throw (error as Error); - } - }); -} - -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { - console.info(`enter promise generateKeyItem`); - try { - await generateKeyItem(keyAlias, huksOptions) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); - }); - return 'Success'; - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); - return 'Failed'; - } -} - -async function testGenKey(): Promise { - let ret = await publicGenKeyFunc(keyAlias, generateHuksOptions); - return ret; -} - -// [EndExclude key_deletions] -/* 4.构造空对象 */ -let deleteHuksOptions: huks.HuksOptions = { - properties: [] -} - -class ThrowObject { - public isThrow = false; -} - -function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -/* 3.删除密钥*/ -async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { - console.info(`enter promise deleteKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - console.log('start genKey...') - await testGenKey(); - console.log('end genKey...') - await deleteKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`); - } - }); - return 'Success'; - } catch (error) { - console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`); - return 'Failed'; - } -} - -async function testDerive(): Promise { - let ret = await publicDeleteKeyFunc(keyAlias, deleteHuksOptions); - return ret; -} -// [End key_deletions] -@Entry -@Component -struct Index { - @State message: string = 'KeyDeletion'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_key_deletion')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - let ret = await testDerive(); - this.message = 'KeyDeletion Result: ' + ret; - }) - } - .height('100%') - .width('100%') - } -} +/* + * 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. + */ + +/* + * 以下以HKDF256密钥的Promise操作使用为例 + */ +// [Start key_deletions] +import { huks } from '@kit.UniversalKeystoreKit'; + +/* 1.确定密钥别名 */ +let keyAlias = 'test_Key'; +// [StartExclude key_deletions] +/* 2.初始化密钥属性集 */ +let generateProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_DH + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048 + } +]; + +let generateHuksOptions: huks.HuksOptions = { + properties: generateProperties, + inData: new Uint8Array([]) +} + +/* 3.生成密钥 */ +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw (error as Error); + } + }); +} + +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { + console.info(`enter promise generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); + }); + return 'Success'; + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); + return 'Failed'; + } +} + +async function testGenKey(): Promise { + let ret = await publicGenKeyFunc(keyAlias, generateHuksOptions); + return ret; +} + +// [EndExclude key_deletions] +/* 4.构造空对象 */ +let deleteHuksOptions: huks.HuksOptions = { + properties: [] +} + +class ThrowObject { + public isThrow = false; +} + +function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +/* 3.删除密钥*/ +async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { + console.info(`enter promise deleteKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + console.log('start genKey...') + await testGenKey(); + console.log('end genKey...') + await deleteKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`); + } + }); + return 'Success'; + } catch (error) { + console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`); + return 'Failed'; + } +} + +async function testDerive(): Promise { + let ret = await publicDeleteKeyFunc(keyAlias, deleteHuksOptions); + return ret; +} +// [End key_deletions] +@Entry +@Component +struct Index { + @State message: string = 'KeyDeletion'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_key_deletion')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + let ret = await testDerive(); + this.message = 'KeyDeletion Result: ' + ret; + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/KeyDeletion.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/KeyDeletion.test.ets old mode 100755 new mode 100644 index 725a61f885..23df4b7376 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/KeyDeletion.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/KeyDeletion.test.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function keyDeletionTest() { - describe('keyDeletionTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,密钥删除(ArkTS) - */ - it('testKeyDeletion001', 0, async () => { - console.info('uitest: testKeyDeletion001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('KeyDeletion').type('Button')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call KeyDeletion')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('KeyDeletion Result: Success')); - console.info('uitest: testKeyDeletion001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,密钥删除(C/C++) - */ - it('testKeyDeletion002', 0, async () => { - console.info('uitest: testKeyDeletion002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testKeyDeletion002 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function keyDeletionTest() { + describe('keyDeletionTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,密钥删除(ArkTS) + */ + it('testKeyDeletion001', 0, async () => { + console.info('uitest: testKeyDeletion001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('KeyDeletion').type('Button')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call KeyDeletion')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('KeyDeletion Result: Success')); + console.info('uitest: testKeyDeletion001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,密钥删除(C/C++) + */ + it('testKeyDeletion002', 0, async () => { + console.info('uitest: testKeyDeletion002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testKeyDeletion002 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyDeletion/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/ohosTest.md old mode 100755 new mode 100644 index 3f92d43bf3..f123e6d184 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/ohosTest.md @@ -1,9 +1,9 @@ -# 密钥删除测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------- | ------------ | ---- | ---------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,密钥删除(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | +# 密钥删除测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------- | ------------ | ---- | ---------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,密钥删除(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | | 点击按钮,密钥删除(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/app.json5 old mode 100755 new mode 100644 index 9b61f8dafa..0130144635 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/app.json5 @@ -1,25 +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.generatekey", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.generatekey", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index db98e9ec5c..99baa78e80 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "GenerateKey" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "GenerateKey" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index a6ed6d775f..0a6fa49673 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(GenerateKey) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(GenerateKey) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index a083b2faff..a66fe4fc99 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp @@ -1,90 +1,90 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start generate_key] -/* 以下以生成ECC密钥为例 */ -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include - -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} - -struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; - -static napi_value GenerateKey(napi_env env, napi_callback_info info) -{ - /* 1.确定密钥别名 */ - const char *alias = "test_generate"; - struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; - struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr; - struct OH_Huks_Result ohResult; - do { - /* 2.初始化密钥属性集 */ - ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam, - sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 3.生成密钥 */ - ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr); - } while (0); - OH_Huks_FreeParamSet(&testGenerateKeyParamSet); - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} -// [End generate_key] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"generateKey", nullptr, GenerateKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start generate_key] +/* 以下以生成ECC密钥为例 */ +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include + +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} + +struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; + +static napi_value GenerateKey(napi_env env, napi_callback_info info) +{ + /* 1.确定密钥别名 */ + const char *alias = "test_generate"; + struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; + struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr; + struct OH_Huks_Result ohResult; + do { + /* 2.初始化密钥属性集 */ + ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam, + sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 3.生成密钥 */ + ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr); + } while (0); + OH_Huks_FreeParamSet(&testGenerateKeyParamSet); + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} +// [End generate_key] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"generateKey", nullptr, GenerateKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/Index.d.ts old mode 100755 new mode 100644 index 9f09a140e5..589dd8a4f8 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/Index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 generateKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index 846e4c7e13..6abf3b7c20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index a36ca588fe..965554bb3a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 0a421f42aa..1da69929bd --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets @@ -1,127 +1,127 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// [Start generate_key_ar] - -import { huks } from '@kit.UniversalKeystoreKit'; -import testNapi from 'libentry.so'; - -/* 1.确定密钥别名 */ -let keyAlias = 'dh_key'; -/* 2.初始化密钥属性集 */ -let properties1: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DH - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048 - } -]; - -let huksOptions: huks.HuksOptions = { - properties: properties1, - inData: new Uint8Array([]) -} - -/* 3.生成密钥 */ -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throw (error as Error); - } - }); -} - -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { - console.info(`enter promise generateKeyItem`); - try { - await generateKeyItem(keyAlias, huksOptions) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); - }); - return 'Success'; - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ` + JSON.stringify(error)); - return 'Failed'; - } -} - -async function testGenKey(): Promise { - let ret = await publicGenKeyFunc(keyAlias, huksOptions); - return ret; -} - - -// [End generate_key_ar] - - -@Entry -@Component -struct Index { - @State message: string = 'GenerateKey'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_cpp')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - let ret: number = testNapi.generateKey(); - this.message = 'C/C++ Call Result: ' + ret.toString(); - }) - Button($r('app.string.call_arkts')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - let ret = await testGenKey(); - this.message = 'ArkTS Call Result: ' + ret; - }) - } - .width('100%') - .height('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start generate_key_ar] + +import { huks } from '@kit.UniversalKeystoreKit'; +import testNapi from 'libentry.so'; + +/* 1.确定密钥别名 */ +let keyAlias = 'dh_key'; +/* 2.初始化密钥属性集 */ +let properties1: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_DH + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048 + } +]; + +let huksOptions: huks.HuksOptions = { + properties: properties1, + inData: new Uint8Array([]) +} + +/* 3.生成密钥 */ +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw (error as Error); + } + }); +} + +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { + console.info(`enter promise generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); + }); + return 'Success'; + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ` + JSON.stringify(error)); + return 'Failed'; + } +} + +async function testGenKey(): Promise { + let ret = await publicGenKeyFunc(keyAlias, huksOptions); + return ret; +} + + +// [End generate_key_ar] + + +@Entry +@Component +struct Index { + @State message: string = 'GenerateKey'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_cpp')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + let ret: number = testNapi.generateKey(); + this.message = 'C/C++ Call Result: ' + ret.toString(); + }) + Button($r('app.string.call_arkts')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + let ret = await testGenKey(); + this.message = 'ArkTS Call Result: ' + ret; + }) + } + .width('100%') + .height('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/GenerateKey.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/GenerateKey.test.ets old mode 100755 new mode 100644 index 19c39f7844..3eb32fe70b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/GenerateKey.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/GenerateKey.test.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function generateKeyTest() { - describe('generateKeyTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,生成密钥(C/C++) - */ - it('testGenerateKey001', 0, async () => { - console.info('uitest: testGenerateKey001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('C/C++ Call Result: 0')); - console.info('uitest: testGenerateKey001 end'); - }) - - /** - * 点击按钮,生成密钥(ArkTS) - */ - it('testGenerateKey002', 0, async () => { - console.info('uitest: testGenerateKey002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call ArkTS')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ArkTS Call Result: Success')); - console.info('uitest: testGenerateKey002 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function generateKeyTest() { + describe('generateKeyTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,生成密钥(C/C++) + */ + it('testGenerateKey001', 0, async () => { + console.info('uitest: testGenerateKey001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('C/C++ Call Result: 0')); + console.info('uitest: testGenerateKey001 end'); + }) + + /** + * 点击按钮,生成密钥(ArkTS) + */ + it('testGenerateKey002', 0, async () => { + console.info('uitest: testGenerateKey002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call ArkTS')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ArkTS Call Result: Success')); + console.info('uitest: testGenerateKey002 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/ohosTest.md old mode 100755 new mode 100644 index 3f92d43bf3..f123e6d184 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/ohosTest.md @@ -1,9 +1,9 @@ -# 密钥删除测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------- | ------------ | ---- | ---------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,密钥删除(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | +# 密钥删除测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------- | ------------ | ---- | ---------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,密钥删除(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | | 点击按钮,密钥删除(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/app.json5 old mode 100755 new mode 100644 index 0a9cd32b14..e676f61bef --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/app.json5 @@ -1,25 +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.importencryptedkey", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.importencryptedkey", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 3e08dc5773..53ff5b073b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ImportEncryptedKey" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ImportEncryptedKey" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/build-profile.json5 old mode 100755 new mode 100644 index 6f6fa15160..d8e84a5fde --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 15, - "compatibleSdkVersion": 15, - "targetSdkVersion": 15, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} +/* + * 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", + "compileSdkVersion": 15, + "compatibleSdkVersion": 15, + "targetSdkVersion": 15, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/code-linter.json5 old mode 100755 new mode 100644 index 9deb980763..28586467ee --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/code-linter.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/code-linter.json5 @@ -1,35 +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. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/build-profile.json5 index 4774ad7bc7..6e7c38b54f 100644 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/build-profile.json5 @@ -1,60 +1,60 @@ -/* - * 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": [ - "armeabi-v7a", - "arm64-v8a", - "x86_64" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": [ + "armeabi-v7a", + "arm64-v8a", + "x86_64" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/hvigorfile.ts old mode 100755 new mode 100644 index 46872af922..e4f43d5466 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/hvigorfile.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/hvigorfile.ts @@ -1,21 +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. */ -} +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/oh-package.json5 index 5d993e5251..118bdd4fe7 100644 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 628b68bebe..8bfc963011 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(ImportEncryptedKey) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(ImportEncryptedKey) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index de42574229..d9a1f609f1 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp @@ -1,611 +1,611 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start encrypt_import_key] - -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include - -#define MAX_MALLOC_SIZE 0x800000 - -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} -struct HksImportWrappedKeyTestParams { - // server key, for real. - struct OH_Huks_Blob *wrappingKeyAlias; - struct OH_Huks_ParamSet *genWrappingKeyParamSet; - uint32_t publicKeySize; - struct OH_Huks_Blob *callerKeyAlias; - struct OH_Huks_ParamSet *genCallerKeyParamSet; - struct OH_Huks_Blob *callerKekAlias; - struct OH_Huks_Blob *callerKek; - struct OH_Huks_ParamSet *importCallerKekParamSet; - struct OH_Huks_Blob *callerAgreeKeyAlias; - struct OH_Huks_ParamSet *agreeParamSet; - struct OH_Huks_ParamSet *importWrappedKeyParamSet; - struct OH_Huks_Blob *importedKeyAlias; - struct OH_Huks_Blob *importedPlainKey; - uint32_t keyMaterialLen; -}; -static const uint32_t IV_SIZE = 16; -static uint8_t IV[IV_SIZE] = "bababababababab"; // 此处仅为测试数据,实际使用时该值每次应该不同。 -static const uint32_t WRAPPED_KEY_IV_SIZE = 16; -static uint8_t WRAPPED_KEY_IV[IV_SIZE] = "bababababababab"; // 此处仅为测试数据,实际使用时该值每次应该不同。 -static const uint32_t AAD_SIZE = 16; -static uint8_t AAD[AAD_SIZE] = "abababababababa"; // 此处仅为测试数据,实际使用时该值每次应该不同。 -static const uint32_t NONCE_SIZE = 12; -static uint8_t NONCE[NONCE_SIZE] = "hahahahahah"; // 此处仅为测试数据,实际使用时该值每次应该不同。 -static const uint32_t AEAD_TAG_SIZE = 16; -static const uint32_t X25519_256_SIZE = 256; -static struct OH_Huks_Blob g_wrappingKeyAliasAes256 = {.size = (uint32_t)strlen("test_wrappingKey_x25519_aes256"), - .data = (uint8_t *)"test_wrappingKey_x25519_aes256"}; -static struct OH_Huks_Blob g_callerKeyAliasAes256 = {.size = (uint32_t)strlen("test_caller_key_x25519_aes256"), - .data = (uint8_t *)"test_caller_key_x25519_aes256"}; -static struct OH_Huks_Blob g_callerKekAliasAes256 = {.size = (uint32_t)strlen("test_caller_kek_x25519_aes256"), - .data = (uint8_t *)"test_caller_kek_x25519_aes256"}; -static struct OH_Huks_Blob g_callerAes256Kek = {.size = (uint32_t)strlen("This is kek to encrypt plain key"), - .data = (uint8_t *)"This is kek to encrypt plain key"}; -static struct OH_Huks_Blob g_callerAgreeKeyAliasAes256 = {.size = - (uint32_t)strlen("test_caller_agree_key_x25519_aes256"), - .data = (uint8_t *)"test_caller_agree_key_x25519_aes256"}; -static struct OH_Huks_Blob g_importedKeyAliasAes256 = {.size = (uint32_t)strlen("test_import_key_x25519_aes256"), - .data = (uint8_t *)"test_import_key_x25519_aes256"}; -static struct OH_Huks_Blob g_importedAes256PlainKey = {.size = (uint32_t)strlen("This is plain key to be imported"), - .data = (uint8_t *)"This is plain key to be imported"}; -static struct OH_Huks_Param g_importWrappedAes256Params[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT | OH_HUKS_KEY_PURPOSE_DECRYPT}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, - {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}, - {.tag = OH_HUKS_TAG_UNWRAP_ALGORITHM_SUITE, .uint32Param = OH_HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING}, - {.tag = OH_HUKS_TAG_ASSOCIATED_DATA, - .blob = {.size = AAD_SIZE, .data = (uint8_t *)AAD}}, // 此处仅为测试数据,实际使用时该值应与调用者信息相关。 - {.tag = OH_HUKS_TAG_NONCE, - .blob = {.size = NONCE_SIZE, .data = (uint8_t *)NONCE}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。 -static const uint32_t g_x25519PubKeySize = 32; -static struct OH_Huks_Param g_genWrappingKeyParams[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_X25519}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_UNWRAP}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_CURVE25519_KEY_SIZE_256}}; -static struct OH_Huks_Param g_genCallerX25519Params[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_X25519}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_CURVE25519_KEY_SIZE_256}}; -static struct OH_Huks_Param g_importParamsCallerKek[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, - {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}, - {.tag = OH_HUKS_TAG_IV, - .blob = {.size = WRAPPED_KEY_IV_SIZE, - .data = (uint8_t *)WRAPPED_KEY_IV}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。 -static struct OH_Huks_Param g_callerAgreeParams[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_X25519}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_CURVE25519_KEY_SIZE_256}}; -static struct OH_Huks_Param g_aesKekEncryptParams[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, - {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}, - {.tag = OH_HUKS_TAG_ASSOCIATED_DATA, - .blob = {.size = AAD_SIZE, .data = (uint8_t *)AAD}}, // 此处仅为测试数据,实际使用时该值应与调用者信息相关。 - {.tag = OH_HUKS_TAG_NONCE, - .blob = {.size = NONCE_SIZE, .data = (uint8_t *)NONCE}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。 -static struct OH_Huks_Param g_importAgreeKeyParams[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, - {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}, - {.tag = OH_HUKS_TAG_IV, - .blob = {.size = IV_SIZE, .data = (uint8_t *)IV}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。 -OH_Huks_Result HuksAgreeKey(const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_Blob *peerPublicKey, struct OH_Huks_Blob *agreedKey) -{ - uint8_t temp[10] = {0}; - struct OH_Huks_Blob inData = {sizeof(temp), temp}; - uint8_t handleU[sizeof(uint64_t)] = {0}; - struct OH_Huks_Blob handle = {sizeof(uint64_t), handleU}; - OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, paramSet, &handle, nullptr); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - uint8_t outDataU[1024] = {0}; - struct OH_Huks_Blob outDataUpdate = {1024, outDataU}; - ret = OH_Huks_UpdateSession(&handle, paramSet, peerPublicKey, &outDataUpdate); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_FinishSession(&handle, paramSet, &inData, agreedKey); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - return ret; -} -OH_Huks_Result MallocAndCheckBlobData(struct OH_Huks_Blob *blob, const uint32_t blobSize) -{ - struct OH_Huks_Result ret; - ret.errorCode = OH_HUKS_SUCCESS; - if (blobSize == 0 || blobSize > MAX_MALLOC_SIZE) { - ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; - } - blob->data = (uint8_t *)malloc(blobSize); - if (blob->data == NULL) { - ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; - } - return ret; -} -static const uint32_t TIMES = 4; -static const uint32_t MAX_UPDATE_SIZE = 64; -static const uint32_t MAX_OUTDATA_SIZE = MAX_UPDATE_SIZE * TIMES; -#define HUKS_FREE_BLOB(blob) \ - do { \ - if ((blob).data != nullptr) { \ - free((blob).data); \ - (blob).data = nullptr; \ - } \ - (blob).size = 0; \ - } while (0) -#define OH_HUKS_KEY_BYTES(keySize) (((keySize) + 7) / 8) -static OH_Huks_Result HksEncryptLoopUpdate(const struct OH_Huks_Blob *handle, const struct OH_Huks_ParamSet *paramSet, - const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData) -{ - struct OH_Huks_Result ret; - ret.errorCode = OH_HUKS_SUCCESS; - struct OH_Huks_Blob inDataSeg = *inData; - uint8_t *lastPtr = inData->data + inData->size - 1; - struct OH_Huks_Blob outDataSeg = {MAX_OUTDATA_SIZE, NULL}; - uint8_t *cur = outData->data; - outData->size = 0; - inDataSeg.size = MAX_UPDATE_SIZE; - bool isFinished = false; - while (inDataSeg.data <= lastPtr) { - if (inDataSeg.data + MAX_UPDATE_SIZE <= lastPtr) { - outDataSeg.size = MAX_OUTDATA_SIZE; - } else { - isFinished = true; - inDataSeg.size = lastPtr - inDataSeg.data + 1; - break; - } - if (MallocAndCheckBlobData(&outDataSeg, outDataSeg.size).errorCode != (int32_t)OH_HUKS_SUCCESS) { - ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; - return ret; - } - ret = OH_Huks_UpdateSession(handle, paramSet, &inDataSeg, &outDataSeg); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - free(outDataSeg.data); - return ret; - } - std::copy(outDataSeg.data, outDataSeg.data + outDataSeg.size, cur); - cur += outDataSeg.size; - outData->size += outDataSeg.size; - free(outDataSeg.data); - if ((isFinished == false) && (inDataSeg.data + MAX_UPDATE_SIZE > lastPtr)) { - ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; - return ret; - } - inDataSeg.data += MAX_UPDATE_SIZE; - } - struct OH_Huks_Blob outDataFinish = {inDataSeg.size * TIMES, NULL}; - if (MallocAndCheckBlobData(&outDataFinish, outDataFinish.size).errorCode != (int32_t)OH_HUKS_SUCCESS) { - ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; - return ret; - } - ret = OH_Huks_FinishSession(handle, paramSet, &inDataSeg, &outDataFinish); - if (ret.errorCode != OH_HUKS_SUCCESS) { - free(outDataFinish.data); - return ret; - } - std::copy(outDataFinish.data, outDataFinish.data + outDataFinish.size, cur); - outData->size += outDataFinish.size; - free(outDataFinish.data); - return ret; -} -OH_Huks_Result HuksEncrypt(const struct OH_Huks_Blob *key, const struct OH_Huks_ParamSet *paramSet, - const struct OH_Huks_Blob *plainText, struct OH_Huks_Blob *cipherText) -{ - uint8_t handle[sizeof(uint64_t)] = {0}; - struct OH_Huks_Blob handleBlob = {sizeof(uint64_t), handle}; - OH_Huks_Result ret = OH_Huks_InitSession(key, paramSet, &handleBlob, nullptr); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = HksEncryptLoopUpdate(&handleBlob, paramSet, plainText, cipherText); - return ret; -} -static OH_Huks_Result BuildWrappedKeyData(struct OH_Huks_Blob **blobArray, uint32_t size, - struct OH_Huks_Blob *outData) -{ - uint32_t totalLength = size * sizeof(uint32_t); - struct OH_Huks_Result ret; - ret.errorCode = OH_HUKS_SUCCESS; - /* 计算大小 */ - for (uint32_t i = 0; i < size; ++i) { - totalLength += blobArray[i]->size; - } - struct OH_Huks_Blob outBlob = {0, nullptr}; - outBlob.size = totalLength; - ret = MallocAndCheckBlobData(&outBlob, outBlob.size); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - uint32_t offset = 0; - /* 拷贝数据 */ - for (uint32_t i = 0; i < size; ++i) { - if (totalLength - offset >= sizeof(blobArray[i]->size)) { - std::copy(reinterpret_cast(&blobArray[i]->size), - reinterpret_cast(&blobArray[i]->size) + sizeof(blobArray[i]->size), - outBlob.data + offset); - } else { - ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; - return ret; - } - offset += sizeof(blobArray[i]->size); - if (totalLength - offset >= blobArray[i]->size) { - std::copy(blobArray[i]->data, blobArray[i]->data + blobArray[i]->size, outBlob.data + offset); - } else { - ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; - return ret; - } - offset += blobArray[i]->size; - } - outData->size = outBlob.size; - outData->data = outBlob.data; - return ret; -} -static OH_Huks_Result CheckParamsValid(const struct HksImportWrappedKeyTestParams *params) -{ - struct OH_Huks_Result ret; - ret.errorCode = OH_HUKS_SUCCESS; - if (params == nullptr) { - ret.errorCode = OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT; - return ret; - } - if (params->wrappingKeyAlias == nullptr || params->genWrappingKeyParamSet == nullptr || - params->callerKeyAlias == nullptr || params->genCallerKeyParamSet == nullptr || - params->callerKekAlias == nullptr || params->callerKek == nullptr || - params->importCallerKekParamSet == nullptr || params->callerAgreeKeyAlias == nullptr || - params->agreeParamSet == nullptr || params->importWrappedKeyParamSet == nullptr || - params->importedKeyAlias == nullptr || params->importedPlainKey == nullptr) { - ret.errorCode = OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT; - return ret; - } - return ret; -} -static OH_Huks_Result GenerateAndExportHuksPublicKey(const struct HksImportWrappedKeyTestParams *params, - struct OH_Huks_Blob *huksPublicKey) -{ - OH_Huks_Result ret = OH_Huks_GenerateKeyItem(params->wrappingKeyAlias, params->genWrappingKeyParamSet, nullptr); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - huksPublicKey->size = params->publicKeySize; - ret = MallocAndCheckBlobData(huksPublicKey, huksPublicKey->size); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_ExportPublicKeyItem(params->wrappingKeyAlias, nullptr, huksPublicKey); - return ret; -} -static OH_Huks_Result GenerateAndExportCallerPublicKey(const struct HksImportWrappedKeyTestParams *params, - struct OH_Huks_Blob *callerSelfPublicKey) -{ - OH_Huks_Result ret = OH_Huks_GenerateKeyItem(params->callerKeyAlias, params->genCallerKeyParamSet, nullptr); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - callerSelfPublicKey->size = params->publicKeySize; - ret = MallocAndCheckBlobData(callerSelfPublicKey, callerSelfPublicKey->size); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_ExportPublicKeyItem(params->callerKeyAlias, params->genWrappingKeyParamSet, callerSelfPublicKey); - return ret; -} -static OH_Huks_Result ImportKekAndAgreeSharedSecret(const struct HksImportWrappedKeyTestParams *params, - const struct OH_Huks_Blob *huksPublicKey, - struct OH_Huks_Blob *outSharedKey) -{ - OH_Huks_Result ret = - OH_Huks_ImportKeyItem(params->callerKekAlias, params->importCallerKekParamSet, params->callerKek); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - ret = MallocAndCheckBlobData(outSharedKey, outSharedKey->size); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - ret = HuksAgreeKey(params->agreeParamSet, params->callerKeyAlias, huksPublicKey, outSharedKey); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - struct OH_Huks_ParamSet *importAgreeKeyParams = nullptr; - ret = InitParamSet(&importAgreeKeyParams, g_importAgreeKeyParams, - sizeof(g_importAgreeKeyParams) / sizeof(OH_Huks_Param)); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_ImportKeyItem(params->callerAgreeKeyAlias, importAgreeKeyParams, outSharedKey); - OH_Huks_FreeParamSet(&importAgreeKeyParams); - return ret; -} -static OH_Huks_Result EncryptImportedPlainKeyAndKek(const struct HksImportWrappedKeyTestParams *params, - struct OH_Huks_Blob *plainCipherText, - struct OH_Huks_Blob *kekCipherText) -{ - struct OH_Huks_ParamSet *encryptParamSet = nullptr; - OH_Huks_Result ret = - InitParamSet(&encryptParamSet, g_aesKekEncryptParams, sizeof(g_aesKekEncryptParams) / sizeof(OH_Huks_Param)); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - ret = HuksEncrypt(params->callerKekAlias, encryptParamSet, params->importedPlainKey, plainCipherText); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - ret = HuksEncrypt(params->callerAgreeKeyAlias, encryptParamSet, params->callerKek, kekCipherText); - OH_Huks_FreeParamSet(&encryptParamSet); - return ret; -} -static OH_Huks_Result ImportWrappedKey(const struct HksImportWrappedKeyTestParams *params, - struct OH_Huks_Blob *plainCipher, struct OH_Huks_Blob *kekCipherText, - struct OH_Huks_Blob *peerPublicKey, struct OH_Huks_Blob *wrappedKeyData) -{ - struct OH_Huks_Blob commonAad = {.size = AAD_SIZE, .data = reinterpret_cast(AAD)}; - struct OH_Huks_Blob commonNonce = {.size = NONCE_SIZE, .data = reinterpret_cast(NONCE)}; - struct OH_Huks_Blob keyMaterialLen = {.size = sizeof(uint32_t), .data = (uint8_t *)¶ms->keyMaterialLen}; - /* 从密文中拷贝AEAD的tag并缩小其大小 */ - const uint32_t tagSize = AEAD_TAG_SIZE; - uint8_t kekTagBuf[tagSize] = {0}; - struct OH_Huks_Blob kekTag = {.size = tagSize, .data = kekTagBuf}; - std::copy(plainCipher->data + (plainCipher->size - tagSize), - plainCipher->data + (plainCipher->size - tagSize) + tagSize, kekTag.data); - plainCipher->size -= tagSize; - /* 从密钥加密密钥的密文中拷贝AEAD的tag并缩小其大小 */ - uint8_t agreeKeyTagBuf[tagSize] = {0}; - struct OH_Huks_Blob agreeKeyTag = {.size = tagSize, .data = agreeKeyTagBuf}; - std::copy(kekCipherText->data + (kekCipherText->size - tagSize), - kekCipherText->data + (kekCipherText->size - tagSize) + tagSize, agreeKeyTagBuf); - kekCipherText->size -= tagSize; - struct OH_Huks_Blob *blobArray[] = {peerPublicKey, &commonAad, &commonNonce, &agreeKeyTag, kekCipherText, - &commonAad, &commonNonce, &kekTag, &keyMaterialLen, plainCipher}; - OH_Huks_Result ret = BuildWrappedKeyData(blobArray, OH_HUKS_IMPORT_WRAPPED_KEY_TOTAL_BLOBS, wrappedKeyData); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - struct OH_Huks_Param *purpose = nullptr; - ret = OH_Huks_GetParam(params->importWrappedKeyParamSet, OH_HUKS_TAG_PURPOSE, &purpose); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_ImportWrappedKeyItem(params->importedKeyAlias, params->wrappingKeyAlias, - params->importWrappedKeyParamSet, wrappedKeyData); - return ret; -} -OH_Huks_Result HksImportWrappedKeyTestCommonCase(const struct HksImportWrappedKeyTestParams *params) -{ - OH_Huks_Result ret = CheckParamsValid(params); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return ret; - } - struct OH_Huks_Blob huksPublicKey = {0, nullptr}; - struct OH_Huks_Blob callerSelfPublicKey = {0, nullptr}; - struct OH_Huks_Blob outSharedKey = {.size = OH_HUKS_KEY_BYTES(OH_HUKS_AES_KEY_SIZE_256), .data = nullptr}; - struct OH_Huks_Blob wrappedKeyData = {0, nullptr}; - uint8_t plainKeyCipherBuffer[OH_HUKS_MAX_KEY_SIZE] = {0}; - struct OH_Huks_Blob plainCipherText = {OH_HUKS_MAX_KEY_SIZE, plainKeyCipherBuffer}; - uint8_t kekCipherTextBuffer[OH_HUKS_MAX_KEY_SIZE] = {0}; - struct OH_Huks_Blob kekCipherText = {OH_HUKS_MAX_KEY_SIZE, kekCipherTextBuffer}; - /* 模拟加密导入密钥场景,设备A为远端设备(导入设备),设备B为本端设备(被导入设备) */ - do { - /** - * 1.设备A将待导入密钥转换成HUKS密钥材料格式To_Import_Key(仅针对非对称密钥,若待导入密钥是对称密钥则可省略此步骤), - * 本示例使用g_importedAes256PlainKey(对称密钥)作为模拟 - */ - /* 2.设备B生成一个加密导入用途的、用于协商的非对称密钥对Wrapping_Key(公钥Wrapping_Pk,私钥Wrapping_Sk), - * 其密钥用途设置为unwrap,导出Wrapping_Key公钥Wrapping_Pk存放在变量huksPublicKey中 - */ - ret = GenerateAndExportHuksPublicKey(params, &huksPublicKey); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - break; - } - /* 3.设备A使用和设备B同样的算法,生成一个加密导入用途的、用于协商的非对称密钥对Caller_Key(公钥Caller_Pk,私钥Caller_Sk), - * 导出Caller_Key公钥Caller_Pk存放在变量callerSelfPublicKey中 - */ - ret = GenerateAndExportCallerPublicKey(params, &callerSelfPublicKey); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - break; - } - /** - * 4. 设备A生成一个对称密钥Caller_Kek,该密钥后续将用于加密To_Import_Key - * 5. 设备A基于Caller_Key的私钥Caller_Sk和设备B Wrapping_Key的公钥Wrapping_Pk,协商出Shared_Key - */ - ret = ImportKekAndAgreeSharedSecret(params, &huksPublicKey, &outSharedKey); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - break; - } - /** - * 6. 设备A使用Caller_Kek加密To_Import_Key,生成To_Import_Key_Enc - * 7. 设备A使用Shared_Key加密Caller_Kek,生成Caller_Kek_Enc - */ - ret = EncryptImportedPlainKeyAndKek(params, &plainCipherText, &kekCipherText); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - break; - } - /* 8. 设备A封装Caller_Pk、To_Import_Key_Enc、Caller_Kek_Enc等加密导入的材料并发送给设备B。 - * 本示例作为变量存放在callerSelfPublicKey,plainCipherText,kekCipherText - * 9. 设备B导入封装的加密密钥材料 - */ - ret = ImportWrappedKey(params, &plainCipherText, &kekCipherText, &callerSelfPublicKey, &wrappedKeyData); - } while (0); - /* 10. 设备A、B删除用于加密导入的密钥 */ - HUKS_FREE_BLOB(huksPublicKey); - HUKS_FREE_BLOB(callerSelfPublicKey); - HUKS_FREE_BLOB(outSharedKey); - HUKS_FREE_BLOB(wrappedKeyData); - return ret; -} -void HksClearKeysForWrappedKeyTest(const struct HksImportWrappedKeyTestParams *params) -{ - OH_Huks_Result ret = CheckParamsValid(params); - if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { - return; - } - (void)OH_Huks_DeleteKeyItem(params->wrappingKeyAlias, nullptr); - (void)OH_Huks_DeleteKeyItem(params->callerKeyAlias, nullptr); - (void)OH_Huks_DeleteKeyItem(params->callerKekAlias, nullptr); - (void)OH_Huks_DeleteKeyItem(params->callerAgreeKeyAlias, nullptr); - (void)OH_Huks_DeleteKeyItem(params->importedKeyAlias, nullptr); -} -static OH_Huks_Result InitCommonTestParamsAndDoImport(struct HksImportWrappedKeyTestParams *importWrappedKeyTestParams, - const struct OH_Huks_Param *importedKeyParamSetArray, - uint32_t arraySize) -{ - struct OH_Huks_ParamSet *genX25519KeyParamSet = nullptr; - struct OH_Huks_ParamSet *genCallerKeyParamSet = nullptr; - struct OH_Huks_ParamSet *callerImportParamsKek = nullptr; - struct OH_Huks_ParamSet *agreeParamSet = nullptr; - struct OH_Huks_ParamSet *importPlainKeyParams = nullptr; - OH_Huks_Result ret; - do { - ret = InitParamSet(&genX25519KeyParamSet, g_genWrappingKeyParams, - sizeof(g_genWrappingKeyParams) / sizeof(OH_Huks_Param)); - if (ret.errorCode != OH_HUKS_SUCCESS) { - break; - } - importWrappedKeyTestParams->genWrappingKeyParamSet = genX25519KeyParamSet; - importWrappedKeyTestParams->publicKeySize = g_x25519PubKeySize; - ret = InitParamSet(&genCallerKeyParamSet, g_genCallerX25519Params, - sizeof(g_genCallerX25519Params) / sizeof(OH_Huks_Param)); - if (ret.errorCode != OH_HUKS_SUCCESS) { - break; - } - importWrappedKeyTestParams->genCallerKeyParamSet = genCallerKeyParamSet; - ret = InitParamSet(&callerImportParamsKek, g_importParamsCallerKek, - sizeof(g_importParamsCallerKek) / sizeof(OH_Huks_Param)); - if (ret.errorCode != OH_HUKS_SUCCESS) { - break; - } - importWrappedKeyTestParams->importCallerKekParamSet = callerImportParamsKek; - ret = InitParamSet(&agreeParamSet, g_callerAgreeParams, sizeof(g_callerAgreeParams) / sizeof(OH_Huks_Param)); - if (ret.errorCode != OH_HUKS_SUCCESS) { - break; - } - importWrappedKeyTestParams->agreeParamSet = agreeParamSet; - ret = InitParamSet(&importPlainKeyParams, importedKeyParamSetArray, arraySize); - if (ret.errorCode != OH_HUKS_SUCCESS) { - break; - } - importWrappedKeyTestParams->importWrappedKeyParamSet = importPlainKeyParams; - ret = HksImportWrappedKeyTestCommonCase(importWrappedKeyTestParams); - } while (0); - OH_Huks_FreeParamSet(&genX25519KeyParamSet); - OH_Huks_FreeParamSet(&genCallerKeyParamSet); - OH_Huks_FreeParamSet(&callerImportParamsKek); - OH_Huks_FreeParamSet(&agreeParamSet); - OH_Huks_FreeParamSet(&importPlainKeyParams); - return ret; -} -static napi_value NAPI_Global_importWrappedKey(napi_env env, napi_callback_info info) -{ - struct HksImportWrappedKeyTestParams importWrappedKeyTestParams001 = {0}; - importWrappedKeyTestParams001.wrappingKeyAlias = &g_wrappingKeyAliasAes256; - importWrappedKeyTestParams001.keyMaterialLen = g_importedAes256PlainKey.size; - importWrappedKeyTestParams001.callerKeyAlias = &g_callerKeyAliasAes256; - importWrappedKeyTestParams001.callerKekAlias = &g_callerKekAliasAes256; - importWrappedKeyTestParams001.callerKek = &g_callerAes256Kek; - importWrappedKeyTestParams001.callerAgreeKeyAlias = &g_callerAgreeKeyAliasAes256; - importWrappedKeyTestParams001.importedKeyAlias = &g_importedKeyAliasAes256; - importWrappedKeyTestParams001.importedPlainKey = &g_importedAes256PlainKey; - OH_Huks_Result ohResult = - InitCommonTestParamsAndDoImport(&importWrappedKeyTestParams001, g_importWrappedAes256Params, - sizeof(g_importWrappedAes256Params) / sizeof(struct OH_Huks_Param)); - HksClearKeysForWrappedKeyTest(&importWrappedKeyTestParams001); - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} - - -// [End encrypt_import_key] - - -// [Start encryption_import_key_commissioning_and_verification] -static napi_value IsKeyExist(napi_env env, napi_callback_info info) -{ - /* 1.指定密钥别名 */ - struct OH_Huks_Blob keyAlias = { - (uint32_t)strlen("test_key"), - (uint8_t *)"test_key" - }; - - /* 2.调用OH_Huks_IsKeyItemExist判断密钥是否存在 */ - struct OH_Huks_Result ohResult = OH_Huks_IsKeyItemExist(&keyAlias, NULL); - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} - -// [End encryption_import_key_commissioning_and_verification] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"isKeyExist", nullptr, IsKeyExist, nullptr, nullptr, nullptr, napi_default, nullptr }, - {"importWrappedKey", nullptr, NAPI_Global_importWrappedKey, nullptr, nullptr, nullptr, napi_default, nullptr }}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start encrypt_import_key] + +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include + +#define MAX_MALLOC_SIZE 0x800000 + +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} +struct HksImportWrappedKeyTestParams { + // server key, for real. + struct OH_Huks_Blob *wrappingKeyAlias; + struct OH_Huks_ParamSet *genWrappingKeyParamSet; + uint32_t publicKeySize; + struct OH_Huks_Blob *callerKeyAlias; + struct OH_Huks_ParamSet *genCallerKeyParamSet; + struct OH_Huks_Blob *callerKekAlias; + struct OH_Huks_Blob *callerKek; + struct OH_Huks_ParamSet *importCallerKekParamSet; + struct OH_Huks_Blob *callerAgreeKeyAlias; + struct OH_Huks_ParamSet *agreeParamSet; + struct OH_Huks_ParamSet *importWrappedKeyParamSet; + struct OH_Huks_Blob *importedKeyAlias; + struct OH_Huks_Blob *importedPlainKey; + uint32_t keyMaterialLen; +}; +static const uint32_t IV_SIZE = 16; +static uint8_t IV[IV_SIZE] = "bababababababab"; // 此处仅为测试数据,实际使用时该值每次应该不同。 +static const uint32_t WRAPPED_KEY_IV_SIZE = 16; +static uint8_t WRAPPED_KEY_IV[IV_SIZE] = "bababababababab"; // 此处仅为测试数据,实际使用时该值每次应该不同。 +static const uint32_t AAD_SIZE = 16; +static uint8_t AAD[AAD_SIZE] = "abababababababa"; // 此处仅为测试数据,实际使用时该值每次应该不同。 +static const uint32_t NONCE_SIZE = 12; +static uint8_t NONCE[NONCE_SIZE] = "hahahahahah"; // 此处仅为测试数据,实际使用时该值每次应该不同。 +static const uint32_t AEAD_TAG_SIZE = 16; +static const uint32_t X25519_256_SIZE = 256; +static struct OH_Huks_Blob g_wrappingKeyAliasAes256 = {.size = (uint32_t)strlen("test_wrappingKey_x25519_aes256"), + .data = (uint8_t *)"test_wrappingKey_x25519_aes256"}; +static struct OH_Huks_Blob g_callerKeyAliasAes256 = {.size = (uint32_t)strlen("test_caller_key_x25519_aes256"), + .data = (uint8_t *)"test_caller_key_x25519_aes256"}; +static struct OH_Huks_Blob g_callerKekAliasAes256 = {.size = (uint32_t)strlen("test_caller_kek_x25519_aes256"), + .data = (uint8_t *)"test_caller_kek_x25519_aes256"}; +static struct OH_Huks_Blob g_callerAes256Kek = {.size = (uint32_t)strlen("This is kek to encrypt plain key"), + .data = (uint8_t *)"This is kek to encrypt plain key"}; +static struct OH_Huks_Blob g_callerAgreeKeyAliasAes256 = {.size = + (uint32_t)strlen("test_caller_agree_key_x25519_aes256"), + .data = (uint8_t *)"test_caller_agree_key_x25519_aes256"}; +static struct OH_Huks_Blob g_importedKeyAliasAes256 = {.size = (uint32_t)strlen("test_import_key_x25519_aes256"), + .data = (uint8_t *)"test_import_key_x25519_aes256"}; +static struct OH_Huks_Blob g_importedAes256PlainKey = {.size = (uint32_t)strlen("This is plain key to be imported"), + .data = (uint8_t *)"This is plain key to be imported"}; +static struct OH_Huks_Param g_importWrappedAes256Params[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT | OH_HUKS_KEY_PURPOSE_DECRYPT}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, + {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}, + {.tag = OH_HUKS_TAG_UNWRAP_ALGORITHM_SUITE, .uint32Param = OH_HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING}, + {.tag = OH_HUKS_TAG_ASSOCIATED_DATA, + .blob = {.size = AAD_SIZE, .data = (uint8_t *)AAD}}, // 此处仅为测试数据,实际使用时该值应与调用者信息相关。 + {.tag = OH_HUKS_TAG_NONCE, + .blob = {.size = NONCE_SIZE, .data = (uint8_t *)NONCE}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。 +static const uint32_t g_x25519PubKeySize = 32; +static struct OH_Huks_Param g_genWrappingKeyParams[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_X25519}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_UNWRAP}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_CURVE25519_KEY_SIZE_256}}; +static struct OH_Huks_Param g_genCallerX25519Params[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_X25519}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_CURVE25519_KEY_SIZE_256}}; +static struct OH_Huks_Param g_importParamsCallerKek[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, + {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}, + {.tag = OH_HUKS_TAG_IV, + .blob = {.size = WRAPPED_KEY_IV_SIZE, + .data = (uint8_t *)WRAPPED_KEY_IV}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。 +static struct OH_Huks_Param g_callerAgreeParams[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_X25519}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_CURVE25519_KEY_SIZE_256}}; +static struct OH_Huks_Param g_aesKekEncryptParams[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, + {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}, + {.tag = OH_HUKS_TAG_ASSOCIATED_DATA, + .blob = {.size = AAD_SIZE, .data = (uint8_t *)AAD}}, // 此处仅为测试数据,实际使用时该值应与调用者信息相关。 + {.tag = OH_HUKS_TAG_NONCE, + .blob = {.size = NONCE_SIZE, .data = (uint8_t *)NONCE}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。 +static struct OH_Huks_Param g_importAgreeKeyParams[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, + {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}, + {.tag = OH_HUKS_TAG_IV, + .blob = {.size = IV_SIZE, .data = (uint8_t *)IV}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。 +OH_Huks_Result HuksAgreeKey(const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_Blob *peerPublicKey, struct OH_Huks_Blob *agreedKey) +{ + uint8_t temp[10] = {0}; + struct OH_Huks_Blob inData = {sizeof(temp), temp}; + uint8_t handleU[sizeof(uint64_t)] = {0}; + struct OH_Huks_Blob handle = {sizeof(uint64_t), handleU}; + OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, paramSet, &handle, nullptr); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + uint8_t outDataU[1024] = {0}; + struct OH_Huks_Blob outDataUpdate = {1024, outDataU}; + ret = OH_Huks_UpdateSession(&handle, paramSet, peerPublicKey, &outDataUpdate); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_FinishSession(&handle, paramSet, &inData, agreedKey); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + return ret; +} +OH_Huks_Result MallocAndCheckBlobData(struct OH_Huks_Blob *blob, const uint32_t blobSize) +{ + struct OH_Huks_Result ret; + ret.errorCode = OH_HUKS_SUCCESS; + if (blobSize == 0 || blobSize > MAX_MALLOC_SIZE) { + ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; + } + blob->data = (uint8_t *)malloc(blobSize); + if (blob->data == NULL) { + ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; + } + return ret; +} +static const uint32_t TIMES = 4; +static const uint32_t MAX_UPDATE_SIZE = 64; +static const uint32_t MAX_OUTDATA_SIZE = MAX_UPDATE_SIZE * TIMES; +#define HUKS_FREE_BLOB(blob) \ + do { \ + if ((blob).data != nullptr) { \ + free((blob).data); \ + (blob).data = nullptr; \ + } \ + (blob).size = 0; \ + } while (0) +#define OH_HUKS_KEY_BYTES(keySize) (((keySize) + 7) / 8) +static OH_Huks_Result HksEncryptLoopUpdate(const struct OH_Huks_Blob *handle, const struct OH_Huks_ParamSet *paramSet, + const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData) +{ + struct OH_Huks_Result ret; + ret.errorCode = OH_HUKS_SUCCESS; + struct OH_Huks_Blob inDataSeg = *inData; + uint8_t *lastPtr = inData->data + inData->size - 1; + struct OH_Huks_Blob outDataSeg = {MAX_OUTDATA_SIZE, NULL}; + uint8_t *cur = outData->data; + outData->size = 0; + inDataSeg.size = MAX_UPDATE_SIZE; + bool isFinished = false; + while (inDataSeg.data <= lastPtr) { + if (inDataSeg.data + MAX_UPDATE_SIZE <= lastPtr) { + outDataSeg.size = MAX_OUTDATA_SIZE; + } else { + isFinished = true; + inDataSeg.size = lastPtr - inDataSeg.data + 1; + break; + } + if (MallocAndCheckBlobData(&outDataSeg, outDataSeg.size).errorCode != (int32_t)OH_HUKS_SUCCESS) { + ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; + return ret; + } + ret = OH_Huks_UpdateSession(handle, paramSet, &inDataSeg, &outDataSeg); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + free(outDataSeg.data); + return ret; + } + std::copy(outDataSeg.data, outDataSeg.data + outDataSeg.size, cur); + cur += outDataSeg.size; + outData->size += outDataSeg.size; + free(outDataSeg.data); + if ((isFinished == false) && (inDataSeg.data + MAX_UPDATE_SIZE > lastPtr)) { + ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; + return ret; + } + inDataSeg.data += MAX_UPDATE_SIZE; + } + struct OH_Huks_Blob outDataFinish = {inDataSeg.size * TIMES, NULL}; + if (MallocAndCheckBlobData(&outDataFinish, outDataFinish.size).errorCode != (int32_t)OH_HUKS_SUCCESS) { + ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; + return ret; + } + ret = OH_Huks_FinishSession(handle, paramSet, &inDataSeg, &outDataFinish); + if (ret.errorCode != OH_HUKS_SUCCESS) { + free(outDataFinish.data); + return ret; + } + std::copy(outDataFinish.data, outDataFinish.data + outDataFinish.size, cur); + outData->size += outDataFinish.size; + free(outDataFinish.data); + return ret; +} +OH_Huks_Result HuksEncrypt(const struct OH_Huks_Blob *key, const struct OH_Huks_ParamSet *paramSet, + const struct OH_Huks_Blob *plainText, struct OH_Huks_Blob *cipherText) +{ + uint8_t handle[sizeof(uint64_t)] = {0}; + struct OH_Huks_Blob handleBlob = {sizeof(uint64_t), handle}; + OH_Huks_Result ret = OH_Huks_InitSession(key, paramSet, &handleBlob, nullptr); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = HksEncryptLoopUpdate(&handleBlob, paramSet, plainText, cipherText); + return ret; +} +static OH_Huks_Result BuildWrappedKeyData(struct OH_Huks_Blob **blobArray, uint32_t size, + struct OH_Huks_Blob *outData) +{ + uint32_t totalLength = size * sizeof(uint32_t); + struct OH_Huks_Result ret; + ret.errorCode = OH_HUKS_SUCCESS; + /* 计算大小 */ + for (uint32_t i = 0; i < size; ++i) { + totalLength += blobArray[i]->size; + } + struct OH_Huks_Blob outBlob = {0, nullptr}; + outBlob.size = totalLength; + ret = MallocAndCheckBlobData(&outBlob, outBlob.size); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + uint32_t offset = 0; + /* 拷贝数据 */ + for (uint32_t i = 0; i < size; ++i) { + if (totalLength - offset >= sizeof(blobArray[i]->size)) { + std::copy(reinterpret_cast(&blobArray[i]->size), + reinterpret_cast(&blobArray[i]->size) + sizeof(blobArray[i]->size), + outBlob.data + offset); + } else { + ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; + return ret; + } + offset += sizeof(blobArray[i]->size); + if (totalLength - offset >= blobArray[i]->size) { + std::copy(blobArray[i]->data, blobArray[i]->data + blobArray[i]->size, outBlob.data + offset); + } else { + ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; + return ret; + } + offset += blobArray[i]->size; + } + outData->size = outBlob.size; + outData->data = outBlob.data; + return ret; +} +static OH_Huks_Result CheckParamsValid(const struct HksImportWrappedKeyTestParams *params) +{ + struct OH_Huks_Result ret; + ret.errorCode = OH_HUKS_SUCCESS; + if (params == nullptr) { + ret.errorCode = OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT; + return ret; + } + if (params->wrappingKeyAlias == nullptr || params->genWrappingKeyParamSet == nullptr || + params->callerKeyAlias == nullptr || params->genCallerKeyParamSet == nullptr || + params->callerKekAlias == nullptr || params->callerKek == nullptr || + params->importCallerKekParamSet == nullptr || params->callerAgreeKeyAlias == nullptr || + params->agreeParamSet == nullptr || params->importWrappedKeyParamSet == nullptr || + params->importedKeyAlias == nullptr || params->importedPlainKey == nullptr) { + ret.errorCode = OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT; + return ret; + } + return ret; +} +static OH_Huks_Result GenerateAndExportHuksPublicKey(const struct HksImportWrappedKeyTestParams *params, + struct OH_Huks_Blob *huksPublicKey) +{ + OH_Huks_Result ret = OH_Huks_GenerateKeyItem(params->wrappingKeyAlias, params->genWrappingKeyParamSet, nullptr); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + huksPublicKey->size = params->publicKeySize; + ret = MallocAndCheckBlobData(huksPublicKey, huksPublicKey->size); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_ExportPublicKeyItem(params->wrappingKeyAlias, nullptr, huksPublicKey); + return ret; +} +static OH_Huks_Result GenerateAndExportCallerPublicKey(const struct HksImportWrappedKeyTestParams *params, + struct OH_Huks_Blob *callerSelfPublicKey) +{ + OH_Huks_Result ret = OH_Huks_GenerateKeyItem(params->callerKeyAlias, params->genCallerKeyParamSet, nullptr); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + callerSelfPublicKey->size = params->publicKeySize; + ret = MallocAndCheckBlobData(callerSelfPublicKey, callerSelfPublicKey->size); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_ExportPublicKeyItem(params->callerKeyAlias, params->genWrappingKeyParamSet, callerSelfPublicKey); + return ret; +} +static OH_Huks_Result ImportKekAndAgreeSharedSecret(const struct HksImportWrappedKeyTestParams *params, + const struct OH_Huks_Blob *huksPublicKey, + struct OH_Huks_Blob *outSharedKey) +{ + OH_Huks_Result ret = + OH_Huks_ImportKeyItem(params->callerKekAlias, params->importCallerKekParamSet, params->callerKek); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + ret = MallocAndCheckBlobData(outSharedKey, outSharedKey->size); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + ret = HuksAgreeKey(params->agreeParamSet, params->callerKeyAlias, huksPublicKey, outSharedKey); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + struct OH_Huks_ParamSet *importAgreeKeyParams = nullptr; + ret = InitParamSet(&importAgreeKeyParams, g_importAgreeKeyParams, + sizeof(g_importAgreeKeyParams) / sizeof(OH_Huks_Param)); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_ImportKeyItem(params->callerAgreeKeyAlias, importAgreeKeyParams, outSharedKey); + OH_Huks_FreeParamSet(&importAgreeKeyParams); + return ret; +} +static OH_Huks_Result EncryptImportedPlainKeyAndKek(const struct HksImportWrappedKeyTestParams *params, + struct OH_Huks_Blob *plainCipherText, + struct OH_Huks_Blob *kekCipherText) +{ + struct OH_Huks_ParamSet *encryptParamSet = nullptr; + OH_Huks_Result ret = + InitParamSet(&encryptParamSet, g_aesKekEncryptParams, sizeof(g_aesKekEncryptParams) / sizeof(OH_Huks_Param)); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + ret = HuksEncrypt(params->callerKekAlias, encryptParamSet, params->importedPlainKey, plainCipherText); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + ret = HuksEncrypt(params->callerAgreeKeyAlias, encryptParamSet, params->callerKek, kekCipherText); + OH_Huks_FreeParamSet(&encryptParamSet); + return ret; +} +static OH_Huks_Result ImportWrappedKey(const struct HksImportWrappedKeyTestParams *params, + struct OH_Huks_Blob *plainCipher, struct OH_Huks_Blob *kekCipherText, + struct OH_Huks_Blob *peerPublicKey, struct OH_Huks_Blob *wrappedKeyData) +{ + struct OH_Huks_Blob commonAad = {.size = AAD_SIZE, .data = reinterpret_cast(AAD)}; + struct OH_Huks_Blob commonNonce = {.size = NONCE_SIZE, .data = reinterpret_cast(NONCE)}; + struct OH_Huks_Blob keyMaterialLen = {.size = sizeof(uint32_t), .data = (uint8_t *)¶ms->keyMaterialLen}; + /* 从密文中拷贝AEAD的tag并缩小其大小 */ + const uint32_t tagSize = AEAD_TAG_SIZE; + uint8_t kekTagBuf[tagSize] = {0}; + struct OH_Huks_Blob kekTag = {.size = tagSize, .data = kekTagBuf}; + std::copy(plainCipher->data + (plainCipher->size - tagSize), + plainCipher->data + (plainCipher->size - tagSize) + tagSize, kekTag.data); + plainCipher->size -= tagSize; + /* 从密钥加密密钥的密文中拷贝AEAD的tag并缩小其大小 */ + uint8_t agreeKeyTagBuf[tagSize] = {0}; + struct OH_Huks_Blob agreeKeyTag = {.size = tagSize, .data = agreeKeyTagBuf}; + std::copy(kekCipherText->data + (kekCipherText->size - tagSize), + kekCipherText->data + (kekCipherText->size - tagSize) + tagSize, agreeKeyTagBuf); + kekCipherText->size -= tagSize; + struct OH_Huks_Blob *blobArray[] = {peerPublicKey, &commonAad, &commonNonce, &agreeKeyTag, kekCipherText, + &commonAad, &commonNonce, &kekTag, &keyMaterialLen, plainCipher}; + OH_Huks_Result ret = BuildWrappedKeyData(blobArray, OH_HUKS_IMPORT_WRAPPED_KEY_TOTAL_BLOBS, wrappedKeyData); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + struct OH_Huks_Param *purpose = nullptr; + ret = OH_Huks_GetParam(params->importWrappedKeyParamSet, OH_HUKS_TAG_PURPOSE, &purpose); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_ImportWrappedKeyItem(params->importedKeyAlias, params->wrappingKeyAlias, + params->importWrappedKeyParamSet, wrappedKeyData); + return ret; +} +OH_Huks_Result HksImportWrappedKeyTestCommonCase(const struct HksImportWrappedKeyTestParams *params) +{ + OH_Huks_Result ret = CheckParamsValid(params); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return ret; + } + struct OH_Huks_Blob huksPublicKey = {0, nullptr}; + struct OH_Huks_Blob callerSelfPublicKey = {0, nullptr}; + struct OH_Huks_Blob outSharedKey = {.size = OH_HUKS_KEY_BYTES(OH_HUKS_AES_KEY_SIZE_256), .data = nullptr}; + struct OH_Huks_Blob wrappedKeyData = {0, nullptr}; + uint8_t plainKeyCipherBuffer[OH_HUKS_MAX_KEY_SIZE] = {0}; + struct OH_Huks_Blob plainCipherText = {OH_HUKS_MAX_KEY_SIZE, plainKeyCipherBuffer}; + uint8_t kekCipherTextBuffer[OH_HUKS_MAX_KEY_SIZE] = {0}; + struct OH_Huks_Blob kekCipherText = {OH_HUKS_MAX_KEY_SIZE, kekCipherTextBuffer}; + /* 模拟加密导入密钥场景,设备A为远端设备(导入设备),设备B为本端设备(被导入设备) */ + do { + /** + * 1.设备A将待导入密钥转换成HUKS密钥材料格式To_Import_Key(仅针对非对称密钥,若待导入密钥是对称密钥则可省略此步骤), + * 本示例使用g_importedAes256PlainKey(对称密钥)作为模拟 + */ + /* 2.设备B生成一个加密导入用途的、用于协商的非对称密钥对Wrapping_Key(公钥Wrapping_Pk,私钥Wrapping_Sk), + * 其密钥用途设置为unwrap,导出Wrapping_Key公钥Wrapping_Pk存放在变量huksPublicKey中 + */ + ret = GenerateAndExportHuksPublicKey(params, &huksPublicKey); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + break; + } + /* 3.设备A使用和设备B同样的算法,生成一个加密导入用途的、用于协商的非对称密钥对Caller_Key(公钥Caller_Pk,私钥Caller_Sk), + * 导出Caller_Key公钥Caller_Pk存放在变量callerSelfPublicKey中 + */ + ret = GenerateAndExportCallerPublicKey(params, &callerSelfPublicKey); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + break; + } + /** + * 4. 设备A生成一个对称密钥Caller_Kek,该密钥后续将用于加密To_Import_Key + * 5. 设备A基于Caller_Key的私钥Caller_Sk和设备B Wrapping_Key的公钥Wrapping_Pk,协商出Shared_Key + */ + ret = ImportKekAndAgreeSharedSecret(params, &huksPublicKey, &outSharedKey); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + break; + } + /** + * 6. 设备A使用Caller_Kek加密To_Import_Key,生成To_Import_Key_Enc + * 7. 设备A使用Shared_Key加密Caller_Kek,生成Caller_Kek_Enc + */ + ret = EncryptImportedPlainKeyAndKek(params, &plainCipherText, &kekCipherText); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + break; + } + /* 8. 设备A封装Caller_Pk、To_Import_Key_Enc、Caller_Kek_Enc等加密导入的材料并发送给设备B。 + * 本示例作为变量存放在callerSelfPublicKey,plainCipherText,kekCipherText + * 9. 设备B导入封装的加密密钥材料 + */ + ret = ImportWrappedKey(params, &plainCipherText, &kekCipherText, &callerSelfPublicKey, &wrappedKeyData); + } while (0); + /* 10. 设备A、B删除用于加密导入的密钥 */ + HUKS_FREE_BLOB(huksPublicKey); + HUKS_FREE_BLOB(callerSelfPublicKey); + HUKS_FREE_BLOB(outSharedKey); + HUKS_FREE_BLOB(wrappedKeyData); + return ret; +} +void HksClearKeysForWrappedKeyTest(const struct HksImportWrappedKeyTestParams *params) +{ + OH_Huks_Result ret = CheckParamsValid(params); + if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) { + return; + } + (void)OH_Huks_DeleteKeyItem(params->wrappingKeyAlias, nullptr); + (void)OH_Huks_DeleteKeyItem(params->callerKeyAlias, nullptr); + (void)OH_Huks_DeleteKeyItem(params->callerKekAlias, nullptr); + (void)OH_Huks_DeleteKeyItem(params->callerAgreeKeyAlias, nullptr); + (void)OH_Huks_DeleteKeyItem(params->importedKeyAlias, nullptr); +} +static OH_Huks_Result InitCommonTestParamsAndDoImport(struct HksImportWrappedKeyTestParams *importWrappedKeyTestParams, + const struct OH_Huks_Param *importedKeyParamSetArray, + uint32_t arraySize) +{ + struct OH_Huks_ParamSet *genX25519KeyParamSet = nullptr; + struct OH_Huks_ParamSet *genCallerKeyParamSet = nullptr; + struct OH_Huks_ParamSet *callerImportParamsKek = nullptr; + struct OH_Huks_ParamSet *agreeParamSet = nullptr; + struct OH_Huks_ParamSet *importPlainKeyParams = nullptr; + OH_Huks_Result ret; + do { + ret = InitParamSet(&genX25519KeyParamSet, g_genWrappingKeyParams, + sizeof(g_genWrappingKeyParams) / sizeof(OH_Huks_Param)); + if (ret.errorCode != OH_HUKS_SUCCESS) { + break; + } + importWrappedKeyTestParams->genWrappingKeyParamSet = genX25519KeyParamSet; + importWrappedKeyTestParams->publicKeySize = g_x25519PubKeySize; + ret = InitParamSet(&genCallerKeyParamSet, g_genCallerX25519Params, + sizeof(g_genCallerX25519Params) / sizeof(OH_Huks_Param)); + if (ret.errorCode != OH_HUKS_SUCCESS) { + break; + } + importWrappedKeyTestParams->genCallerKeyParamSet = genCallerKeyParamSet; + ret = InitParamSet(&callerImportParamsKek, g_importParamsCallerKek, + sizeof(g_importParamsCallerKek) / sizeof(OH_Huks_Param)); + if (ret.errorCode != OH_HUKS_SUCCESS) { + break; + } + importWrappedKeyTestParams->importCallerKekParamSet = callerImportParamsKek; + ret = InitParamSet(&agreeParamSet, g_callerAgreeParams, sizeof(g_callerAgreeParams) / sizeof(OH_Huks_Param)); + if (ret.errorCode != OH_HUKS_SUCCESS) { + break; + } + importWrappedKeyTestParams->agreeParamSet = agreeParamSet; + ret = InitParamSet(&importPlainKeyParams, importedKeyParamSetArray, arraySize); + if (ret.errorCode != OH_HUKS_SUCCESS) { + break; + } + importWrappedKeyTestParams->importWrappedKeyParamSet = importPlainKeyParams; + ret = HksImportWrappedKeyTestCommonCase(importWrappedKeyTestParams); + } while (0); + OH_Huks_FreeParamSet(&genX25519KeyParamSet); + OH_Huks_FreeParamSet(&genCallerKeyParamSet); + OH_Huks_FreeParamSet(&callerImportParamsKek); + OH_Huks_FreeParamSet(&agreeParamSet); + OH_Huks_FreeParamSet(&importPlainKeyParams); + return ret; +} +static napi_value NAPI_Global_importWrappedKey(napi_env env, napi_callback_info info) +{ + struct HksImportWrappedKeyTestParams importWrappedKeyTestParams001 = {0}; + importWrappedKeyTestParams001.wrappingKeyAlias = &g_wrappingKeyAliasAes256; + importWrappedKeyTestParams001.keyMaterialLen = g_importedAes256PlainKey.size; + importWrappedKeyTestParams001.callerKeyAlias = &g_callerKeyAliasAes256; + importWrappedKeyTestParams001.callerKekAlias = &g_callerKekAliasAes256; + importWrappedKeyTestParams001.callerKek = &g_callerAes256Kek; + importWrappedKeyTestParams001.callerAgreeKeyAlias = &g_callerAgreeKeyAliasAes256; + importWrappedKeyTestParams001.importedKeyAlias = &g_importedKeyAliasAes256; + importWrappedKeyTestParams001.importedPlainKey = &g_importedAes256PlainKey; + OH_Huks_Result ohResult = + InitCommonTestParamsAndDoImport(&importWrappedKeyTestParams001, g_importWrappedAes256Params, + sizeof(g_importWrappedAes256Params) / sizeof(struct OH_Huks_Param)); + HksClearKeysForWrappedKeyTest(&importWrappedKeyTestParams001); + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} + + +// [End encrypt_import_key] + + +// [Start encryption_import_key_commissioning_and_verification] +static napi_value IsKeyExist(napi_env env, napi_callback_info info) +{ + /* 1.指定密钥别名 */ + struct OH_Huks_Blob keyAlias = { + (uint32_t)strlen("test_key"), + (uint8_t *)"test_key" + }; + + /* 2.调用OH_Huks_IsKeyItemExist判断密钥是否存在 */ + struct OH_Huks_Result ohResult = OH_Huks_IsKeyItemExist(&keyAlias, NULL); + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} + +// [End encryption_import_key_commissioning_and_verification] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"isKeyExist", nullptr, IsKeyExist, nullptr, nullptr, nullptr, napi_default, nullptr }, + {"importWrappedKey", nullptr, NAPI_Global_importWrappedKey, nullptr, nullptr, nullptr, napi_default, nullptr }}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index c753ec3dc0..e8fa214af4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,17 +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 importWrappedKey: () => number; +/* + * 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 importWrappedKey: () => number; export const isKeyExist: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/oh-package.json5 index e8f69f3d76..2826cc7d6b 100644 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets old mode 100755 new mode 100644 index 3868b6dfe2..acac78f650 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets @@ -1,661 +1,661 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start encrypt_the_import_key] - -import { huks } from '@kit.UniversalKeystoreKit'; - -let IV = '0000000000000000'; -let AAD = 'abababababababab'; -let NONCE = 'hahahahahaha'; -let TAG_SIZE = 16; -let FILED_LENGTH = 4; -let importedAes192PlainKey = 'The aes192 key to import'; -let callerAes256Kek = 'The is kek to encrypt aes192 key'; -let callerKeyAlias = 'test_caller_key_ecdh_aes192'; -let callerKekAliasAes256 = 'test_caller_kek_ecdh_aes256'; -let callerAgreeKeyAliasAes256 = 'test_caller_agree_key_ecdh_aes256'; -let importedKeyAliasAes192 = 'test_import_key_ecdh_aes192'; -let huksPubKey: Uint8Array; -let callerSelfPublicKey: Uint8Array; -let outSharedKey: Uint8Array; -let outPlainKeyEncData: Uint8Array; -let outKekEncData: Uint8Array; -let outKekEncTag: Uint8Array; -let outAgreeKeyEncTag: Uint8Array; -let mask = [0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000]; - -function subUint8ArrayOf(arrayBuf: Uint8Array, start: number, end: number) { - let arr: number[] = []; - for (let i = start; i < end && i < arrayBuf.length; ++i) { - arr.push(arrayBuf[i]); - } - return new Uint8Array(arr); -} - -function stringToUint8Array(str: string) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function assignLength(length: number, arrayBuf: Uint8Array, startIndex: number) { - let index = startIndex; - for (let i = 0; i < 4; i++) { - arrayBuf[index++] = (length & mask[i]) >> (i * 8); - } - return 4; -} - -function assignData(data: Uint8Array, arrayBuf: Uint8Array, startIndex: number) { - let index = startIndex; - for (let i = 0; i < data.length; i++) { - arrayBuf[index++] = data[i]; - } - return data.length; -} - -let genWrappingKeyParams: huks.HuksOptions = { - properties: [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - } - ] -} - -let genCallerEcdhParams: huks.HuksOptions = { - properties: [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 - } - ] -} - -let importParamsCallerKek: huks.HuksOptions = { - properties: [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }, - { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_GCM - }, - { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE - }, - { - tag: huks.HuksTag.HUKS_TAG_IV, - value: stringToUint8Array(IV) - } - ], - inData: stringToUint8Array(callerAes256Kek) -} - -let importParamsAgreeKey: huks.HuksOptions = { - properties: [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }, - { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_GCM - }, - { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE - }, - { - tag: huks.HuksTag.HUKS_TAG_IV, - value: stringToUint8Array(IV) - } - ], -} - -let callerAgreeParams: huks.HuksOptions = { - properties: [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECDH - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 - } - ] -} - -let encryptKeyCommonParams: huks.HuksOptions = { - properties: [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }, - { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_GCM - }, - { - tag: huks.HuksTag.HUKS_TAG_NONCE, - value: stringToUint8Array(NONCE) - }, - { - tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA, - value: stringToUint8Array(AAD) - } - ], -} - -let importWrappedAes192Params: huks.HuksOptions = { - properties: [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_192 - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }, - { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC - }, - { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE - }, - { - tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE, - value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING - }, - { - tag: huks.HuksTag.HUKS_TAG_IV, - value: stringToUint8Array(IV) - } - ] -} - -async function publicGenerateItemFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise generateKeyItem`); - try { - await huks.generateKeyItem(keyAlias, huksOptions) - .then(data => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((err: Error) => { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(err)}`); - throw (err as Error); - }) - } catch (err) { - console.error(`promise: generateKeyItem invalid, ${JSON.stringify(err)}`); - throw (err as Error); - } -} - -async function publicImportKeyItemFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise importKeyItem`); - try { - await huks.importKeyItem(keyAlias, huksOptions) - .then(data => { - console.info(`promise: importKeyItem success, data = ${JSON.stringify(data)}`); - }).catch((err: Error) => { - console.error(`promise: importKeyItem failed, ${JSON.stringify(err)}`); - throw (err as Error); - }) - } catch (err) { - console.error(`promise: importKeyItem input arg invalid, ${JSON.stringify(err)}`); - throw (err as Error); - } -} - -async function publicDeleteKeyItemFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise deleteKeyItem`); - try { - await huks.deleteKeyItem(keyAlias, huksOptions) - .then(data => { - console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); - }) - .catch((err: Error) => { - console.error(`promise: deleteKeyItem failed, ${JSON.stringify(err)}`); - throw (err as Error); - }) - } catch (err) { - console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(err)}`); - throw (err as Error); - } -} - -function importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, huksOptions: huks.HuksOptions) { - return new Promise((resolve, reject) => { - try { - huks.importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throw (error as Error); - } - }); -} - -async function publicImportWrappedKeyFunc(keyAlias: string, wrappingKeyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise importWrappedKeyItem`); - for (let i = 0; i < huksOptions.inData!.length; i++) { - console.error(`${i}: ${huksOptions.inData![i]}`); - } - try { - await importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions) - .then((data) => { - console.info(`promise: importWrappedKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - console.error(`promise: importWrappedKeyItem failed, ${JSON.stringify(error)}`); - throw (error as Error); - }); - } catch (error) { - console.error(`promise: importWrappedKeyItem input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -async function publicImportWrappedKeyPromise(keyAlias: string, wrappingKeyAlias: string, - huksOptions: huks.HuksOptions) { - console.info(`enter promise importWrappedKeyItem`); - try { - await huks.importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions) - .then((data) => { - console.info(`promise: importWrappedKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - console.error(`promise: importWrappedKeyItem failed, ${JSON.stringify(error)}`); - throw (error as Error); - }); - } catch (error) { - console.error(`promise: importWrappedKeyItem input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -async function publicInitFunc(srcKeyAlias: string, huksOptions: huks.HuksOptions) { - let handle: number = 0; - console.info(`enter promise doInit`); - try { - await huks.initSession(srcKeyAlias, huksOptions) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - handle = data.handle; - }) - .catch((error: Error) => { - console.error(`promise: doInit key failed, ${JSON.stringify(error)}`); - throw (error as Error); - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } - return handle; -} - -async function publicUpdateSessionFunction(handle: number, huksOptions: huks.HuksOptions) { - const maxUpdateSize = 64; - const inData = huksOptions.inData!; - const lastInDataPosition = inData.length - 1; - let inDataSegSize = maxUpdateSize; - let inDataSegPosition = 0; - let isFinished = false; - let outData: number[] = []; - - while (inDataSegPosition <= lastInDataPosition) { - if (inDataSegPosition + maxUpdateSize > lastInDataPosition) { - isFinished = true; - inDataSegSize = lastInDataPosition - inDataSegPosition + 1; - console.info(`enter promise doUpdate`); - break; - } - huksOptions.inData = new Uint8Array( - Array.from(inData).slice(inDataSegPosition, inDataSegPosition + inDataSegSize) - ); - console.info(`enter promise doUpdate`); - try { - await huks.updateSession(handle, huksOptions) - .then((data) => { - console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`); - outData = outData.concat(Array.from(data.outData!)); - }) - .catch((error: Error) => { - console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`); - throw (error as Error); - }); - } catch (error) { - console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } - if ((!isFinished) && (inDataSegPosition + maxUpdateSize > lastInDataPosition)) { - console.error(`update size invalid isFinished = ${isFinished}`); - console.error(`inDataSegPosition = ${inDataSegPosition}`); - console.error(`lastInDataPosition = ${lastInDataPosition}`); - return; - } - inDataSegPosition += maxUpdateSize; - } - return outData; -} - -async function publicFinishSession(handle: number, huksOptions: huks.HuksOptions, inData: number[]) { - let outData: number[] = []; - console.info(`enter promise doFinish`); - try { - await huks.finishSession(handle, huksOptions) - .then((data) => { - console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); - outData = inData.concat(Array.from(data.outData!)); - }) - .catch((error: Error) => { - console.error(`promise: doFinish key failed, ${JSON.stringify(error)}`); - throw (error as Error); - }); - } catch (error) { - console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } - return new Uint8Array(outData); -} - -async function cipherFunction(keyAlias: string, huksOptions: huks.HuksOptions) { - let handle = await publicInitFunc(keyAlias, huksOptions); - let tmpData = await publicUpdateSessionFunction(handle, huksOptions); - let outData = await publicFinishSession(handle, huksOptions, tmpData!); - return outData; -} - -async function agreeFunction(keyAlias: string, huksOptions: huks.HuksOptions, huksPublicKey: Uint8Array) { - let handle = await publicInitFunc(keyAlias, huksOptions); - let outSharedKey: Uint8Array = new Uint8Array; - huksOptions.inData = huksPublicKey; - console.info(`enter promise doUpdate`); - try { - await huks.updateSession(handle, huksOptions) - .then((data) => { - console.error(`promise: doUpdate success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`); - throw (error as Error); - }); - } catch (error) { - console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } - console.info(`enter promise doInit`); - try { - await huks.finishSession(handle, huksOptions) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - outSharedKey = data.outData as Uint8Array; - }) - .catch((error: Error) => { - console.error(`promise: doInit key failed, ${JSON.stringify(error)}`); - throw (error as Error); - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } - return outSharedKey; -} - -async function importKekAndAgreeSharedSecret(callerKekAlias: string, importKekParams: huks.HuksOptions, - callerKeyAlias: string, huksPublicKey: Uint8Array, agreeParams: huks.HuksOptions) { - await publicImportKeyItemFunc(callerKekAlias, importKekParams); - outSharedKey = await agreeFunction(callerKeyAlias, agreeParams, huksPublicKey); - importParamsAgreeKey.inData = outSharedKey; - await publicImportKeyItemFunc(callerAgreeKeyAliasAes256, importParamsAgreeKey); -} - -async function generateAndExportPublicKey(keyAlias: string, huksOptions: huks.HuksOptions, caller: Boolean) { - await publicGenerateItemFunc(keyAlias, huksOptions); - try { - await huks.exportKeyItem(keyAlias, huksOptions) - .then((data) => { - console.info(`promise: exportKeyItem success, data = ${JSON.stringify(data)}`); - if (caller) { - callerSelfPublicKey = data.outData as Uint8Array; - } else { - huksPubKey = data.outData as Uint8Array; - } - }) - .catch((error: Error) => { - console.error(`promise: exportKeyItem failed, ${JSON.stringify(error)}`); - throw (error as Error); - }); - } catch (error) { - console.error(`promise: generate pubKey failed, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -async function encryptImportedPlainKeyAndKek(keyAlias: string) { - encryptKeyCommonParams.inData = stringToUint8Array(keyAlias) - let plainKeyEncData = await cipherFunction(callerKekAliasAes256, encryptKeyCommonParams); - outKekEncTag = subUint8ArrayOf(plainKeyEncData, plainKeyEncData.length - TAG_SIZE, plainKeyEncData.length) - outPlainKeyEncData = subUint8ArrayOf(plainKeyEncData, 0, plainKeyEncData.length - TAG_SIZE) - encryptKeyCommonParams.inData = stringToUint8Array(callerAes256Kek) - let kekEncData = await cipherFunction(callerAgreeKeyAliasAes256, encryptKeyCommonParams) - outAgreeKeyEncTag = subUint8ArrayOf(kekEncData, kekEncData.length - TAG_SIZE, kekEncData.length) - outKekEncData = subUint8ArrayOf(kekEncData, 0, kekEncData.length - TAG_SIZE) -} - -async function buildWrappedDataAndImportWrappedKey(plainKey: string) { - let plainKeySizeBuff = new Uint8Array(4); - assignLength(plainKey.length, plainKeySizeBuff, 0); - let wrappedData = new Uint8Array( - FILED_LENGTH + huksPubKey.length + - FILED_LENGTH + AAD.length + - FILED_LENGTH + NONCE.length + - FILED_LENGTH + TAG_SIZE + - FILED_LENGTH + outKekEncData.length + - FILED_LENGTH + AAD.length + - FILED_LENGTH + NONCE.length + - FILED_LENGTH + TAG_SIZE + - FILED_LENGTH + plainKeySizeBuff.length + - FILED_LENGTH + outPlainKeyEncData.length - ); - let index = 0; - let aadUint8Array = stringToUint8Array(AAD); - let nonceArray = stringToUint8Array(NONCE); - index += assignLength(callerSelfPublicKey.length, wrappedData, index); // 4 - index += assignData(callerSelfPublicKey, wrappedData, index); // 91 - index += assignLength(aadUint8Array.length, wrappedData, index); // 4 - index += assignData(aadUint8Array, wrappedData, index); // 16 - index += assignLength(nonceArray.length, wrappedData, index); // 4 - index += assignData(nonceArray, wrappedData, index); // 12 - index += assignLength(outAgreeKeyEncTag.length, wrappedData, index); // 4 - index += assignData(outAgreeKeyEncTag, wrappedData, index); // 16 - index += assignLength(outKekEncData.length, wrappedData, index); // 4 - index += assignData(outKekEncData, wrappedData, index); // 32 - index += assignLength(aadUint8Array.length, wrappedData, index); // 4 - index += assignData(aadUint8Array, wrappedData, index); // 16 - index += assignLength(nonceArray.length, wrappedData, index); // 4 - index += assignData(nonceArray, wrappedData, index); // 12 - index += assignLength(outKekEncTag.length, wrappedData, index); // 4 - index += assignData(outKekEncTag, wrappedData, index); // 16 - index += assignLength(plainKeySizeBuff.length, wrappedData, index); // 4 - index += assignData(plainKeySizeBuff, wrappedData, index); // 4 - index += assignLength(outPlainKeyEncData.length, wrappedData, index); // 4 - index += assignData(outPlainKeyEncData, wrappedData, index); // 24 - return wrappedData; -} - -/* 模拟加密导入密钥场景,设备A为远端设备(导入设备),设备B为本端设备(被导入设备) */ -async function ImportWrappedKey() { - /** - * 1.设备A将待导入密钥转换成HUKS密钥材料格式To_Import_Key(仅针对非对称密钥,若待导入密钥是对称密钥则可省略此步骤), - * 本示例使用importedAes256PlainKey(对称密钥)作为模拟 - */ - - /* 2.设备B生成一个加密导入用途的、用于协商的非对称密钥对Wrapping_Key(公钥Wrapping_Pk,私钥Wrapping_Sk), - * 其密钥用途设置为unwrap,导出Wrapping_Key公钥Wrapping_Pk存放在变量huksPubKey中 - */ - const srcKeyAliasWrap = 'HUKS_Basic_Capability_Import_0200'; - await generateAndExportPublicKey(srcKeyAliasWrap, genWrappingKeyParams, false); - - /* 3.设备A使用和设备B同样的算法,生成一个加密导入用途的、用于协商的非对称密钥对Caller_Key(公钥Caller_Pk,私钥Caller_Sk), - * 导出Caller_Key公钥Caller_Pk存放在变量callerSelfPublicKey中 - */ - await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true); - - /** - * 4.设备A生成一个对称密钥Caller_Kek,该密钥后续将用于加密To_Import_Key - * 5.设备A基于Caller_Key的私钥Caller_Sk和Wrapping_Key的公钥Wrapping_Pk,协商出Shared_Key - */ - await importKekAndAgreeSharedSecret(callerKekAliasAes256, importParamsCallerKek, callerKeyAlias, huksPubKey, - callerAgreeParams); - - /** - * 6.设备A使用Caller_Kek加密To_Import_Key,生成To_Import_Key_Enc - * 7.设备A使用Shared_Key加密Caller_Kek,生成Caller_Kek_Enc - */ - await encryptImportedPlainKeyAndKek(importedAes192PlainKey); - - /* 8.设备A封装Caller_Pk、To_Import_Key_Enc、Caller_Kek_Enc等加密导入的材料并发送给设备B。 - 本示例作为变量存放在callerSelfPublicKey,PlainKeyEncData,KekEncData */ - let wrappedData = await buildWrappedDataAndImportWrappedKey(importedAes192PlainKey); - importWrappedAes192Params.inData = wrappedData; - - /* 9.设备B导入封装的加密密钥材料 */ - await publicImportWrappedKeyFunc(importedKeyAliasAes192, srcKeyAliasWrap, importWrappedAes192Params); - - /* 10.设备A、B删除用于加密导入的密钥 */ - await publicDeleteKeyItemFunc(srcKeyAliasWrap, genWrappingKeyParams); - await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams); - await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192Params); - await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams); -} - - -// [End encrypt_the_import_key] - -// [Start encrypt_the_import_key_to_verify_that_the_key_exists] -/* - * 确定密钥别名和封装密钥属性参数集 - */ -let keyAlias = 'test_import_key_ecdh_aes192'; -let isKeyExist: Boolean; -let keyProperties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, -}]; -let huksOptions: huks.HuksOptions = { - properties: keyProperties, // 非空填充 - inData: new Uint8Array([]) // 非空填充 -} - -function Check() { - try { - huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => { - if (error) { - console.error(`callback: isKeyItemExist failed, ${JSON.stringify(error)}`); - } else { - if (data !== null && data.valueOf() !== null) { - isKeyExist = data.valueOf(); - console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`); - } - } - }); - } catch (error) { - console.error(`callback: isKeyItemExist input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -// [End encrypt_the_import_key_to_verify_that_the_key_exists] -export { ImportWrappedKey, Check }; +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start encrypt_the_import_key] + +import { huks } from '@kit.UniversalKeystoreKit'; + +let IV = '0000000000000000'; +let AAD = 'abababababababab'; +let NONCE = 'hahahahahaha'; +let TAG_SIZE = 16; +let FILED_LENGTH = 4; +let importedAes192PlainKey = 'The aes192 key to import'; +let callerAes256Kek = 'The is kek to encrypt aes192 key'; +let callerKeyAlias = 'test_caller_key_ecdh_aes192'; +let callerKekAliasAes256 = 'test_caller_kek_ecdh_aes256'; +let callerAgreeKeyAliasAes256 = 'test_caller_agree_key_ecdh_aes256'; +let importedKeyAliasAes192 = 'test_import_key_ecdh_aes192'; +let huksPubKey: Uint8Array; +let callerSelfPublicKey: Uint8Array; +let outSharedKey: Uint8Array; +let outPlainKeyEncData: Uint8Array; +let outKekEncData: Uint8Array; +let outKekEncTag: Uint8Array; +let outAgreeKeyEncTag: Uint8Array; +let mask = [0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000]; + +function subUint8ArrayOf(arrayBuf: Uint8Array, start: number, end: number) { + let arr: number[] = []; + for (let i = start; i < end && i < arrayBuf.length; ++i) { + arr.push(arrayBuf[i]); + } + return new Uint8Array(arr); +} + +function stringToUint8Array(str: string) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function assignLength(length: number, arrayBuf: Uint8Array, startIndex: number) { + let index = startIndex; + for (let i = 0; i < 4; i++) { + arrayBuf[index++] = (length & mask[i]) >> (i * 8); + } + return 4; +} + +function assignData(data: Uint8Array, arrayBuf: Uint8Array, startIndex: number) { + let index = startIndex; + for (let i = 0; i < data.length; i++) { + arrayBuf[index++] = data[i]; + } + return data.length; +} + +let genWrappingKeyParams: huks.HuksOptions = { + properties: [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_ECC + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE + } + ] +} + +let genCallerEcdhParams: huks.HuksOptions = { + properties: [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_ECC + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 + } + ] +} + +let importParamsCallerKek: huks.HuksOptions = { + properties: [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE + }, + { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_GCM + }, + { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE + }, + { + tag: huks.HuksTag.HUKS_TAG_IV, + value: stringToUint8Array(IV) + } + ], + inData: stringToUint8Array(callerAes256Kek) +} + +let importParamsAgreeKey: huks.HuksOptions = { + properties: [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE + }, + { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_GCM + }, + { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE + }, + { + tag: huks.HuksTag.HUKS_TAG_IV, + value: stringToUint8Array(IV) + } + ], +} + +let callerAgreeParams: huks.HuksOptions = { + properties: [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_ECDH + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 + } + ] +} + +let encryptKeyCommonParams: huks.HuksOptions = { + properties: [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE + }, + { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_GCM + }, + { + tag: huks.HuksTag.HUKS_TAG_NONCE, + value: stringToUint8Array(NONCE) + }, + { + tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA, + value: stringToUint8Array(AAD) + } + ], +} + +let importWrappedAes192Params: huks.HuksOptions = { + properties: [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_192 + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE + }, + { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC + }, + { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE + }, + { + tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE, + value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING + }, + { + tag: huks.HuksTag.HUKS_TAG_IV, + value: stringToUint8Array(IV) + } + ] +} + +async function publicGenerateItemFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise generateKeyItem`); + try { + await huks.generateKeyItem(keyAlias, huksOptions) + .then(data => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((err: Error) => { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(err)}`); + throw (err as Error); + }) + } catch (err) { + console.error(`promise: generateKeyItem invalid, ${JSON.stringify(err)}`); + throw (err as Error); + } +} + +async function publicImportKeyItemFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise importKeyItem`); + try { + await huks.importKeyItem(keyAlias, huksOptions) + .then(data => { + console.info(`promise: importKeyItem success, data = ${JSON.stringify(data)}`); + }).catch((err: Error) => { + console.error(`promise: importKeyItem failed, ${JSON.stringify(err)}`); + throw (err as Error); + }) + } catch (err) { + console.error(`promise: importKeyItem input arg invalid, ${JSON.stringify(err)}`); + throw (err as Error); + } +} + +async function publicDeleteKeyItemFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise deleteKeyItem`); + try { + await huks.deleteKeyItem(keyAlias, huksOptions) + .then(data => { + console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch((err: Error) => { + console.error(`promise: deleteKeyItem failed, ${JSON.stringify(err)}`); + throw (err as Error); + }) + } catch (err) { + console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(err)}`); + throw (err as Error); + } +} + +function importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, huksOptions: huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw (error as Error); + } + }); +} + +async function publicImportWrappedKeyFunc(keyAlias: string, wrappingKeyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise importWrappedKeyItem`); + for (let i = 0; i < huksOptions.inData!.length; i++) { + console.error(`${i}: ${huksOptions.inData![i]}`); + } + try { + await importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions) + .then((data) => { + console.info(`promise: importWrappedKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + console.error(`promise: importWrappedKeyItem failed, ${JSON.stringify(error)}`); + throw (error as Error); + }); + } catch (error) { + console.error(`promise: importWrappedKeyItem input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +async function publicImportWrappedKeyPromise(keyAlias: string, wrappingKeyAlias: string, + huksOptions: huks.HuksOptions) { + console.info(`enter promise importWrappedKeyItem`); + try { + await huks.importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions) + .then((data) => { + console.info(`promise: importWrappedKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + console.error(`promise: importWrappedKeyItem failed, ${JSON.stringify(error)}`); + throw (error as Error); + }); + } catch (error) { + console.error(`promise: importWrappedKeyItem input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +async function publicInitFunc(srcKeyAlias: string, huksOptions: huks.HuksOptions) { + let handle: number = 0; + console.info(`enter promise doInit`); + try { + await huks.initSession(srcKeyAlias, huksOptions) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch((error: Error) => { + console.error(`promise: doInit key failed, ${JSON.stringify(error)}`); + throw (error as Error); + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } + return handle; +} + +async function publicUpdateSessionFunction(handle: number, huksOptions: huks.HuksOptions) { + const maxUpdateSize = 64; + const inData = huksOptions.inData!; + const lastInDataPosition = inData.length - 1; + let inDataSegSize = maxUpdateSize; + let inDataSegPosition = 0; + let isFinished = false; + let outData: number[] = []; + + while (inDataSegPosition <= lastInDataPosition) { + if (inDataSegPosition + maxUpdateSize > lastInDataPosition) { + isFinished = true; + inDataSegSize = lastInDataPosition - inDataSegPosition + 1; + console.info(`enter promise doUpdate`); + break; + } + huksOptions.inData = new Uint8Array( + Array.from(inData).slice(inDataSegPosition, inDataSegPosition + inDataSegSize) + ); + console.info(`enter promise doUpdate`); + try { + await huks.updateSession(handle, huksOptions) + .then((data) => { + console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`); + outData = outData.concat(Array.from(data.outData!)); + }) + .catch((error: Error) => { + console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`); + throw (error as Error); + }); + } catch (error) { + console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } + if ((!isFinished) && (inDataSegPosition + maxUpdateSize > lastInDataPosition)) { + console.error(`update size invalid isFinished = ${isFinished}`); + console.error(`inDataSegPosition = ${inDataSegPosition}`); + console.error(`lastInDataPosition = ${lastInDataPosition}`); + return; + } + inDataSegPosition += maxUpdateSize; + } + return outData; +} + +async function publicFinishSession(handle: number, huksOptions: huks.HuksOptions, inData: number[]) { + let outData: number[] = []; + console.info(`enter promise doFinish`); + try { + await huks.finishSession(handle, huksOptions) + .then((data) => { + console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); + outData = inData.concat(Array.from(data.outData!)); + }) + .catch((error: Error) => { + console.error(`promise: doFinish key failed, ${JSON.stringify(error)}`); + throw (error as Error); + }); + } catch (error) { + console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } + return new Uint8Array(outData); +} + +async function cipherFunction(keyAlias: string, huksOptions: huks.HuksOptions) { + let handle = await publicInitFunc(keyAlias, huksOptions); + let tmpData = await publicUpdateSessionFunction(handle, huksOptions); + let outData = await publicFinishSession(handle, huksOptions, tmpData!); + return outData; +} + +async function agreeFunction(keyAlias: string, huksOptions: huks.HuksOptions, huksPublicKey: Uint8Array) { + let handle = await publicInitFunc(keyAlias, huksOptions); + let outSharedKey: Uint8Array = new Uint8Array; + huksOptions.inData = huksPublicKey; + console.info(`enter promise doUpdate`); + try { + await huks.updateSession(handle, huksOptions) + .then((data) => { + console.error(`promise: doUpdate success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`); + throw (error as Error); + }); + } catch (error) { + console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } + console.info(`enter promise doInit`); + try { + await huks.finishSession(handle, huksOptions) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + outSharedKey = data.outData as Uint8Array; + }) + .catch((error: Error) => { + console.error(`promise: doInit key failed, ${JSON.stringify(error)}`); + throw (error as Error); + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } + return outSharedKey; +} + +async function importKekAndAgreeSharedSecret(callerKekAlias: string, importKekParams: huks.HuksOptions, + callerKeyAlias: string, huksPublicKey: Uint8Array, agreeParams: huks.HuksOptions) { + await publicImportKeyItemFunc(callerKekAlias, importKekParams); + outSharedKey = await agreeFunction(callerKeyAlias, agreeParams, huksPublicKey); + importParamsAgreeKey.inData = outSharedKey; + await publicImportKeyItemFunc(callerAgreeKeyAliasAes256, importParamsAgreeKey); +} + +async function generateAndExportPublicKey(keyAlias: string, huksOptions: huks.HuksOptions, caller: Boolean) { + await publicGenerateItemFunc(keyAlias, huksOptions); + try { + await huks.exportKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`promise: exportKeyItem success, data = ${JSON.stringify(data)}`); + if (caller) { + callerSelfPublicKey = data.outData as Uint8Array; + } else { + huksPubKey = data.outData as Uint8Array; + } + }) + .catch((error: Error) => { + console.error(`promise: exportKeyItem failed, ${JSON.stringify(error)}`); + throw (error as Error); + }); + } catch (error) { + console.error(`promise: generate pubKey failed, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +async function encryptImportedPlainKeyAndKek(keyAlias: string) { + encryptKeyCommonParams.inData = stringToUint8Array(keyAlias) + let plainKeyEncData = await cipherFunction(callerKekAliasAes256, encryptKeyCommonParams); + outKekEncTag = subUint8ArrayOf(plainKeyEncData, plainKeyEncData.length - TAG_SIZE, plainKeyEncData.length) + outPlainKeyEncData = subUint8ArrayOf(plainKeyEncData, 0, plainKeyEncData.length - TAG_SIZE) + encryptKeyCommonParams.inData = stringToUint8Array(callerAes256Kek) + let kekEncData = await cipherFunction(callerAgreeKeyAliasAes256, encryptKeyCommonParams) + outAgreeKeyEncTag = subUint8ArrayOf(kekEncData, kekEncData.length - TAG_SIZE, kekEncData.length) + outKekEncData = subUint8ArrayOf(kekEncData, 0, kekEncData.length - TAG_SIZE) +} + +async function buildWrappedDataAndImportWrappedKey(plainKey: string) { + let plainKeySizeBuff = new Uint8Array(4); + assignLength(plainKey.length, plainKeySizeBuff, 0); + let wrappedData = new Uint8Array( + FILED_LENGTH + huksPubKey.length + + FILED_LENGTH + AAD.length + + FILED_LENGTH + NONCE.length + + FILED_LENGTH + TAG_SIZE + + FILED_LENGTH + outKekEncData.length + + FILED_LENGTH + AAD.length + + FILED_LENGTH + NONCE.length + + FILED_LENGTH + TAG_SIZE + + FILED_LENGTH + plainKeySizeBuff.length + + FILED_LENGTH + outPlainKeyEncData.length + ); + let index = 0; + let aadUint8Array = stringToUint8Array(AAD); + let nonceArray = stringToUint8Array(NONCE); + index += assignLength(callerSelfPublicKey.length, wrappedData, index); // 4 + index += assignData(callerSelfPublicKey, wrappedData, index); // 91 + index += assignLength(aadUint8Array.length, wrappedData, index); // 4 + index += assignData(aadUint8Array, wrappedData, index); // 16 + index += assignLength(nonceArray.length, wrappedData, index); // 4 + index += assignData(nonceArray, wrappedData, index); // 12 + index += assignLength(outAgreeKeyEncTag.length, wrappedData, index); // 4 + index += assignData(outAgreeKeyEncTag, wrappedData, index); // 16 + index += assignLength(outKekEncData.length, wrappedData, index); // 4 + index += assignData(outKekEncData, wrappedData, index); // 32 + index += assignLength(aadUint8Array.length, wrappedData, index); // 4 + index += assignData(aadUint8Array, wrappedData, index); // 16 + index += assignLength(nonceArray.length, wrappedData, index); // 4 + index += assignData(nonceArray, wrappedData, index); // 12 + index += assignLength(outKekEncTag.length, wrappedData, index); // 4 + index += assignData(outKekEncTag, wrappedData, index); // 16 + index += assignLength(plainKeySizeBuff.length, wrappedData, index); // 4 + index += assignData(plainKeySizeBuff, wrappedData, index); // 4 + index += assignLength(outPlainKeyEncData.length, wrappedData, index); // 4 + index += assignData(outPlainKeyEncData, wrappedData, index); // 24 + return wrappedData; +} + +/* 模拟加密导入密钥场景,设备A为远端设备(导入设备),设备B为本端设备(被导入设备) */ +async function ImportWrappedKey() { + /** + * 1.设备A将待导入密钥转换成HUKS密钥材料格式To_Import_Key(仅针对非对称密钥,若待导入密钥是对称密钥则可省略此步骤), + * 本示例使用importedAes256PlainKey(对称密钥)作为模拟 + */ + + /* 2.设备B生成一个加密导入用途的、用于协商的非对称密钥对Wrapping_Key(公钥Wrapping_Pk,私钥Wrapping_Sk), + * 其密钥用途设置为unwrap,导出Wrapping_Key公钥Wrapping_Pk存放在变量huksPubKey中 + */ + const srcKeyAliasWrap = 'HUKS_Basic_Capability_Import_0200'; + await generateAndExportPublicKey(srcKeyAliasWrap, genWrappingKeyParams, false); + + /* 3.设备A使用和设备B同样的算法,生成一个加密导入用途的、用于协商的非对称密钥对Caller_Key(公钥Caller_Pk,私钥Caller_Sk), + * 导出Caller_Key公钥Caller_Pk存放在变量callerSelfPublicKey中 + */ + await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true); + + /** + * 4.设备A生成一个对称密钥Caller_Kek,该密钥后续将用于加密To_Import_Key + * 5.设备A基于Caller_Key的私钥Caller_Sk和Wrapping_Key的公钥Wrapping_Pk,协商出Shared_Key + */ + await importKekAndAgreeSharedSecret(callerKekAliasAes256, importParamsCallerKek, callerKeyAlias, huksPubKey, + callerAgreeParams); + + /** + * 6.设备A使用Caller_Kek加密To_Import_Key,生成To_Import_Key_Enc + * 7.设备A使用Shared_Key加密Caller_Kek,生成Caller_Kek_Enc + */ + await encryptImportedPlainKeyAndKek(importedAes192PlainKey); + + /* 8.设备A封装Caller_Pk、To_Import_Key_Enc、Caller_Kek_Enc等加密导入的材料并发送给设备B。 + 本示例作为变量存放在callerSelfPublicKey,PlainKeyEncData,KekEncData */ + let wrappedData = await buildWrappedDataAndImportWrappedKey(importedAes192PlainKey); + importWrappedAes192Params.inData = wrappedData; + + /* 9.设备B导入封装的加密密钥材料 */ + await publicImportWrappedKeyFunc(importedKeyAliasAes192, srcKeyAliasWrap, importWrappedAes192Params); + + /* 10.设备A、B删除用于加密导入的密钥 */ + await publicDeleteKeyItemFunc(srcKeyAliasWrap, genWrappingKeyParams); + await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams); + await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192Params); + await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams); +} + + +// [End encrypt_the_import_key] + +// [Start encrypt_the_import_key_to_verify_that_the_key_exists] +/* + * 确定密钥别名和封装密钥属性参数集 + */ +let keyAlias = 'test_import_key_ecdh_aes192'; +let isKeyExist: Boolean; +let keyProperties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES, +}]; +let huksOptions: huks.HuksOptions = { + properties: keyProperties, // 非空填充 + inData: new Uint8Array([]) // 非空填充 +} + +function Check() { + try { + huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => { + if (error) { + console.error(`callback: isKeyItemExist failed, ${JSON.stringify(error)}`); + } else { + if (data !== null && data.valueOf() !== null) { + isKeyExist = data.valueOf(); + console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`); + } + } + }); + } catch (error) { + console.error(`callback: isKeyItemExist input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +// [End encrypt_the_import_key_to_verify_that_the_key_exists] +export { ImportWrappedKey, Check }; diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index d6143ff613..5f77599495 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/Index.ets @@ -1,63 +1,63 @@ -/* - * 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 { Check, ImportWrappedKey } from './ImportEncryptedKey'; -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'ImportEncryptedKey'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_arkts')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await ImportWrappedKey(); - Check(); - this.message = 'Call ArkTS Result: Success'; - } catch (error) { - this.message = 'Call ArkTS Result: Failed'; - } - }) - Button($r('app.string.call_cpp')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - let ret: number = testNapi.importWrappedKey(); - this.message = 'Call C/C++ Result: ' + ret.toString(); - }) - } - .height('100%') - .width('100%') - } -} +/* + * 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 { Check, ImportWrappedKey } from './ImportEncryptedKey'; +import testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State message: string = 'ImportEncryptedKey'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_arkts')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await ImportWrappedKey(); + Check(); + this.message = 'Call ArkTS Result: Success'; + } catch (error) { + this.message = 'Call ArkTS Result: Failed'; + } + }) + Button($r('app.string.call_cpp')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + let ret: number = testNapi.importWrappedKey(); + this.message = 'Call C/C++ Result: ' + ret.toString(); + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 index 9d4f8a434d..0f8ce9a2c0 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - // Defines a test suite. Two parameters are supported: test suite name and test suite function. - beforeAll(() => { - // Presets an action, which is performed only once before all test cases of the test suite start. - // This API supports only one parameter: preset action function. - }) - beforeEach(() => { - // Presets an action, which is performed before each unit test case starts. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: preset action function. - }) - afterEach(() => { - // Presets a clear action, which is performed after each unit test case ends. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: clear action function. - }) - afterAll(() => { - // Presets a clear action, which is performed after all test cases of the test suite end. - // This API supports only one parameter: clear action function. - }) - it('assertContain', 0, () => { - // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. - hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); - let a = 'abc'; - let b = 'b'; - // Defines a variety of assertion methods, which are used to declare expected boolean conditions. - expect(a).assertContain(b); - expect(a).assertEqual(a); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/ImportEncryptedKey.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/ImportEncryptedKey.test.ets old mode 100755 new mode 100644 index 5ea2be8b7b..3d6850fe65 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/ImportEncryptedKey.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/ImportEncryptedKey.test.ets @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function hMACTest() { - describe('importEncryptedKeyTest', () => { - - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,ImportEncryptedKey(ArkTS) - */ - it('testImportEncryptedKey001', 0, async () => { - console.info('uitest: testImportEncryptedKey001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call ArkTS')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call ArkTS Result: Success')); - console.info('uitest: testImportEncryptedKey001 end'); - }) - - /** - * 点击按钮,ImportEncryptedKey(C/C++) - */ - it('testImportEncryptedKey002', 0, async () => { - console.info('uitest: testImportEncryptedKey002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testImportEncryptedKey002 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function hMACTest() { + describe('importEncryptedKeyTest', () => { + + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,ImportEncryptedKey(ArkTS) + */ + it('testImportEncryptedKey001', 0, async () => { + console.info('uitest: testImportEncryptedKey001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call ArkTS')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call ArkTS Result: Success')); + console.info('uitest: testImportEncryptedKey001 end'); + }) + + /** + * 点击按钮,ImportEncryptedKey(C/C++) + */ + it('testImportEncryptedKey002', 0, async () => { + console.info('uitest: testImportEncryptedKey002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testImportEncryptedKey002 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 index ddb5fc7552..894688fbdf --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/List.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/List.test.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import importEncryptedKeyTest from './ImportEncryptedKey.test'; - -export default function testsuite() { - importEncryptedKeyTest(); -} +/* + * 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 importEncryptedKeyTest from './ImportEncryptedKey.test'; + +export default function testsuite() { + importEncryptedKeyTest(); +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigorfile.ts old mode 100755 new mode 100644 index 2db60fa918..2a5e543f19 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigorfile.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigorfile.ts @@ -1,21 +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. */ -} +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/ohosTest.md old mode 100755 new mode 100644 index 20cc8ebe07..6fafce2eb9 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/ohosTest.md @@ -1,9 +1,9 @@ -# 密钥删除测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------- | ------------ | ---- | ---------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,加密导入密钥(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | +# 密钥删除测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------- | ------------ | ---- | ---------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,加密导入密钥(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | | 点击按钮,加密导入密钥(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/app.json5 old mode 100755 new mode 100644 index 2bdcd5e619..1ce720e354 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/app.json5 @@ -1,25 +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.importkeyplaintext", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.importkeyplaintext", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 4eb76575a5..2b7782e7d8 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ImportKeyPlainText" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ImportKeyPlainText" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 14b058b32c..2b331e5591 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(ImportKeyPlainText) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(ImportKeyPlainText) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 3043449a63..a0a1f1a318 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp @@ -1,101 +1,101 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start import_keys_in_plaintext] -/* 以下以明文导入AES密钥为例 */ -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include - -#define OH_HUKS_AES_KEY_SIZE_32 32 - -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} -struct OH_Huks_Param g_testImportKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; - -static napi_value ImportKey(napi_env env, napi_callback_info info) -{ - const char *alias = "test_import"; - struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; - /* DER格式的公钥,用于后续导入密钥 */ - uint8_t pubKey[OH_HUKS_AES_KEY_SIZE_32] = {0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, - 0x2a, 0x7c, 0x86, 0xba, 0xca, 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, - 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f, 0x9e, 0x3c, 0xe5, 0xf9}; - struct OH_Huks_Blob publicKey = {OH_HUKS_AES_KEY_SIZE_32, pubKey}; - struct OH_Huks_ParamSet *testImportKeyParamSet = nullptr; - struct OH_Huks_Result ohResult; - do { - ohResult = InitParamSet(&testImportKeyParamSet, g_testImportKeyParam, - sizeof(g_testImportKeyParam) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 4. Import Key */ - char newKey[] = "test_import"; - struct OH_Huks_Blob newKeyAlias = {.size = (uint32_t)strlen(newKey), .data = (uint8_t *)newKey}; - ohResult = OH_Huks_ImportKeyItem(&newKeyAlias, testImportKeyParamSet, &publicKey); - } while (0); - OH_Huks_FreeParamSet(&testImportKeyParamSet); - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} - -// [End import_keys_in_plaintext] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"importKey", nullptr, ImportKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start import_keys_in_plaintext] +/* 以下以明文导入AES密钥为例 */ +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include + +#define OH_HUKS_AES_KEY_SIZE_32 32 + +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} +struct OH_Huks_Param g_testImportKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; + +static napi_value ImportKey(napi_env env, napi_callback_info info) +{ + const char *alias = "test_import"; + struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; + /* DER格式的公钥,用于后续导入密钥 */ + uint8_t pubKey[OH_HUKS_AES_KEY_SIZE_32] = {0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, + 0x2a, 0x7c, 0x86, 0xba, 0xca, 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, + 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f, 0x9e, 0x3c, 0xe5, 0xf9}; + struct OH_Huks_Blob publicKey = {OH_HUKS_AES_KEY_SIZE_32, pubKey}; + struct OH_Huks_ParamSet *testImportKeyParamSet = nullptr; + struct OH_Huks_Result ohResult; + do { + ohResult = InitParamSet(&testImportKeyParamSet, g_testImportKeyParam, + sizeof(g_testImportKeyParam) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 4. Import Key */ + char newKey[] = "test_import"; + struct OH_Huks_Blob newKeyAlias = {.size = (uint32_t)strlen(newKey), .data = (uint8_t *)newKey}; + ohResult = OH_Huks_ImportKeyItem(&newKeyAlias, testImportKeyParamSet, &publicKey); + } while (0); + OH_Huks_FreeParamSet(&testImportKeyParamSet); + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} + +// [End import_keys_in_plaintext] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"importKey", nullptr, ImportKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index fbdae5048a..d04ac97cd2 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 importKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets old mode 100755 new mode 100644 index 05e997efba..17f2c358fe --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets @@ -1,141 +1,141 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start import_keys_in_plaintext_AES256] - -/* 以下以导入AES256密钥的Callback操作使用为例 */ -import { huks } from '@kit.UniversalKeystoreKit' - -/* 密钥材料 */ -let plainTextSize32 = new Uint8Array([ - 0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, 0x2a, 0x7c, 0x86, 0xba, 0xca, - 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f, 0x9e, 0x3c, 0xe5, 0xf9 -]); -/* 1.确定密钥别名 */ -let keyAlias = 'AES256Alias_sample'; - -/* 2.封装密钥属性集和密钥材料 */ -let properties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }, -]; - -let options: huks.HuksOptions = { - properties: properties, - inData: plainTextSize32 -}; - -/* 3.明文导入密钥 */ -function importAES256() { - try { - huks.importKeyItem(keyAlias, options, (error, data) => { - if (error) { - console.error(`callback: importKeyItem failed` + JSON.stringify(error)); - } else { - console.info(`callback: importKeyItem success`); - } - }); - } catch (error) { - console.error(`callback: importKeyItem input arg invalid` + JSON.stringify(error)); - throw (error as Error); - } -} - -// [End import_keys_in_plaintext_AES256] - -let isKeyExist = false; - -let keyProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }, -]; - -let huksOptions: huks.HuksOptions = { - properties: keyProperties, // 非空填充 - inData: new Uint8Array([]) // 非空填充 -} - -function check() { - try { - huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => { - if (error) { - console.error(`callback: isKeyItemExist failed, ` + JSON.stringify(error)); - } else { - if (data !== null && data.valueOf() !== null) { - isKeyExist = data.valueOf(); - console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`); - } - } - }); - } catch (error) { - console.error(`callback: isKeyItemExist input arg invalid, ` + JSON.stringify(error)); - throw (error as Error); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'AES256'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_aes_256')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - try { - importAES256(); - check(); - this.message = 'AES256 Result: Success'; - }catch{ - this.message = 'AES256 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start import_keys_in_plaintext_AES256] + +/* 以下以导入AES256密钥的Callback操作使用为例 */ +import { huks } from '@kit.UniversalKeystoreKit' + +/* 密钥材料 */ +let plainTextSize32 = new Uint8Array([ + 0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, 0x2a, 0x7c, 0x86, 0xba, 0xca, + 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f, 0x9e, 0x3c, 0xe5, 0xf9 +]); +/* 1.确定密钥别名 */ +let keyAlias = 'AES256Alias_sample'; + +/* 2.封装密钥属性集和密钥材料 */ +let properties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }, +]; + +let options: huks.HuksOptions = { + properties: properties, + inData: plainTextSize32 +}; + +/* 3.明文导入密钥 */ +function importAES256() { + try { + huks.importKeyItem(keyAlias, options, (error, data) => { + if (error) { + console.error(`callback: importKeyItem failed` + JSON.stringify(error)); + } else { + console.info(`callback: importKeyItem success`); + } + }); + } catch (error) { + console.error(`callback: importKeyItem input arg invalid` + JSON.stringify(error)); + throw (error as Error); + } +} + +// [End import_keys_in_plaintext_AES256] + +let isKeyExist = false; + +let keyProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }, +]; + +let huksOptions: huks.HuksOptions = { + properties: keyProperties, // 非空填充 + inData: new Uint8Array([]) // 非空填充 +} + +function check() { + try { + huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => { + if (error) { + console.error(`callback: isKeyItemExist failed, ` + JSON.stringify(error)); + } else { + if (data !== null && data.valueOf() !== null) { + isKeyExist = data.valueOf(); + console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`); + } + } + }); + } catch (error) { + console.error(`callback: isKeyItemExist input arg invalid, ` + JSON.stringify(error)); + throw (error as Error); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'AES256'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_aes_256')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + try { + importAES256(); + check(); + this.message = 'AES256 Result: Success'; + }catch{ + this.message = 'AES256 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets old mode 100755 new mode 100644 index c21dacea92..86b978bef7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets @@ -1,190 +1,190 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start import_keys_in_plaintext_RSA2048] -/* 以下以导入RSA2048密钥的Callback操作使用为例 */ -import { huks } from '@kit.UniversalKeystoreKit' - -let rsa2048KeyPairMaterial = new Uint8Array([ - 0x01, 0x00, 0x00, 0x00, // 密钥算法(小端表示)huks.HuksKeyAlg.HUKS_ALG_RSA = 1 - 0x00, 0x08, 0x00, 0x00, // 密钥大小(比特):2048 - 0x00, 0x01, 0x00, 0x00, // 模数n长度(字节):256 - 0x03, 0x00, 0x00, 0x00, // 公钥指数e长度(字节):3 - 0x00, 0x01, 0x00, 0x00, // 私钥指数d长度(字节):256 - // 模数n - 0xc5, 0x35, 0x62, 0x48, 0xc4, 0x92, 0x87, 0x73, 0x0d, 0x42, 0x96, 0xfc, 0x7b, 0x11, 0x05, 0x06, - 0x0f, 0x8d, 0x66, 0xc1, 0x0e, 0xad, 0x37, 0x44, 0x92, 0x95, 0x2f, 0x6a, 0x55, 0xba, 0xec, 0x1d, - 0x54, 0x62, 0x0a, 0x4b, 0xd3, 0xc7, 0x05, 0xe4, 0x07, 0x40, 0xd9, 0xb7, 0xc2, 0x12, 0xcb, 0x9a, - 0x90, 0xad, 0xe3, 0x24, 0xe8, 0x5e, 0xa6, 0xf8, 0xd0, 0x6e, 0xbc, 0xd1, 0x69, 0x7f, 0x6b, 0xe4, - 0x2b, 0x4e, 0x1a, 0x65, 0xbb, 0x73, 0x88, 0x6b, 0x7c, 0xaf, 0x7e, 0xd0, 0x47, 0x26, 0xeb, 0xa5, - 0xbe, 0xd6, 0xe8, 0xee, 0x9c, 0xa5, 0x66, 0xa5, 0xc9, 0xd3, 0x25, 0x13, 0xc4, 0x0e, 0x6c, 0xab, - 0x50, 0xb6, 0x50, 0xc9, 0xce, 0x8f, 0x0a, 0x0b, 0xc6, 0x28, 0x69, 0xe9, 0x83, 0x69, 0xde, 0x42, - 0x56, 0x79, 0x7f, 0xde, 0x86, 0x24, 0xca, 0xfc, 0xaa, 0xc0, 0xf3, 0xf3, 0x7f, 0x92, 0x8e, 0x8a, - 0x12, 0x52, 0xfe, 0x50, 0xb1, 0x5e, 0x8c, 0x01, 0xce, 0xfc, 0x7e, 0xf2, 0x4f, 0x5f, 0x03, 0xfe, - 0xa7, 0xcd, 0xa1, 0xfc, 0x94, 0x52, 0x00, 0x8b, 0x9b, 0x7f, 0x09, 0xab, 0xa8, 0xa4, 0xf5, 0xb4, - 0xa5, 0xaa, 0xfc, 0x72, 0xeb, 0x17, 0x40, 0xa9, 0xee, 0xbe, 0x8f, 0xc2, 0xd1, 0x80, 0xc2, 0x0d, - 0x44, 0xa9, 0x59, 0x44, 0x59, 0x81, 0x3b, 0x5d, 0x4a, 0xde, 0xfb, 0xae, 0x24, 0xfc, 0xa3, 0xd9, - 0xbc, 0x57, 0x55, 0xc2, 0x26, 0xbc, 0x19, 0xa7, 0x9a, 0xc5, 0x59, 0xa3, 0xee, 0x5a, 0xef, 0x41, - 0x80, 0x7d, 0xf8, 0x5e, 0xc1, 0x1d, 0x32, 0x38, 0x41, 0x5b, 0xb6, 0x92, 0xb8, 0xb7, 0x03, 0x0d, - 0x3e, 0x59, 0x0f, 0x1c, 0xb3, 0xe1, 0x2a, 0x95, 0x1a, 0x3b, 0x50, 0x4f, 0xc4, 0x1d, 0xcf, 0x73, - 0x7c, 0x14, 0xca, 0xe3, 0x0b, 0xa7, 0xc7, 0x1a, 0x41, 0x4a, 0xee, 0xbe, 0x1f, 0x43, 0xdd, 0xf9, - // 公钥指数e - 0x01, 0x00, 0x01, - // 私钥指数d - 0x88, 0x4b, 0x82, 0xe7, 0xe3, 0xe3, 0x99, 0x75, 0x6c, 0x9e, 0xaf, 0x17, 0x44, 0x3e, 0xd9, 0x07, - 0xfd, 0x4b, 0xae, 0xce, 0x92, 0xc4, 0x28, 0x44, 0x5e, 0x42, 0x79, 0x08, 0xb6, 0xc3, 0x7f, 0x58, - 0x2d, 0xef, 0xac, 0x4a, 0x07, 0xcd, 0xaf, 0x46, 0x8f, 0xb4, 0xc4, 0x43, 0xf9, 0xff, 0x5f, 0x74, - 0x2d, 0xb5, 0xe0, 0x1c, 0xab, 0xf4, 0x6e, 0xd5, 0xdb, 0xc8, 0x0c, 0xfb, 0x76, 0x3c, 0x38, 0x66, - 0xf3, 0x7f, 0x01, 0x43, 0x7a, 0x30, 0x39, 0x02, 0x80, 0xa4, 0x11, 0xb3, 0x04, 0xd9, 0xe3, 0x57, - 0x23, 0xf4, 0x07, 0xfc, 0x91, 0x8a, 0xc6, 0xcc, 0xa2, 0x16, 0x29, 0xb3, 0xe5, 0x76, 0x4a, 0xa8, - 0x84, 0x19, 0xdc, 0xef, 0xfc, 0xb0, 0x63, 0x33, 0x0b, 0xfa, 0xf6, 0x68, 0x0b, 0x08, 0xea, 0x31, - 0x52, 0xee, 0x99, 0xef, 0x43, 0x2a, 0xbe, 0x97, 0xad, 0xb3, 0xb9, 0x66, 0x7a, 0xae, 0xe1, 0x8f, - 0x57, 0x86, 0xe5, 0xfe, 0x14, 0x3c, 0x81, 0xd0, 0x64, 0xf8, 0x86, 0x1a, 0x0b, 0x40, 0x58, 0xc9, - 0x33, 0x49, 0xb8, 0x99, 0xc6, 0x2e, 0x94, 0x70, 0xee, 0x09, 0x88, 0xe1, 0x5c, 0x4e, 0x6c, 0x22, - 0x72, 0xa7, 0x2a, 0x21, 0xdd, 0xd7, 0x1d, 0xfc, 0x63, 0x15, 0x0b, 0xde, 0x06, 0x9c, 0xf3, 0x28, - 0xf3, 0xac, 0x4a, 0xa8, 0xb5, 0x50, 0xca, 0x9b, 0xcc, 0x0a, 0x04, 0xfe, 0x3f, 0x98, 0x68, 0x81, - 0xac, 0x24, 0x53, 0xea, 0x1f, 0x1c, 0x6e, 0x5e, 0xca, 0xe8, 0x31, 0x0d, 0x08, 0x12, 0xf3, 0x26, - 0xf8, 0x5e, 0xeb, 0x10, 0x27, 0xae, 0xaa, 0xc3, 0xad, 0x6c, 0xc1, 0x89, 0xdb, 0x7d, 0x5a, 0x12, - 0x55, 0xad, 0x11, 0x19, 0xa1, 0xa9, 0x8f, 0x0b, 0x6d, 0x78, 0x8d, 0x1c, 0xdf, 0xe5, 0x63, 0x82, - 0x0b, 0x7d, 0x23, 0x04, 0xb4, 0x75, 0x8c, 0xed, 0x77, 0xfc, 0x1a, 0x85, 0x29, 0x11, 0xe0, 0x61, -]); - -/* 1.确定密钥别名 */ -let keyAlias = 'RSA_sample'; -/* 2.封装密钥属性集和密钥材料 */ -let properties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, - { - // 此 tag表示密钥导入后的用途,导入后将不可更改 - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }, - { - // 此 tag表示需导入的密钥类型 - tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, - // 此 value表示导入密钥对,若改为HUKS_KEY_TYPE_PUBLIC_KEY时表示仅导入公钥 - value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR - }, -]; - -let options: huks.HuksOptions = { - properties: properties, - inData: rsa2048KeyPairMaterial -}; - -/* 3.明文导入密钥 */ -function importRSA2048() { - try { - huks.importKeyItem(keyAlias, options, (error, data) => { - if (error) { - console.error(`callback: importKeyItem failed` + error); - } else { - console.info(`callback: importKeyItem success`); - } - }); - } catch (error) { - console.error(`callback: importKeyItem input arg invalid` + error); - throw (error as Error); - } -} - - - -// [End import_keys_in_plaintext_RSA2048] -let isKeyExist = false; - -let keyProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }, - { - tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, - value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR - }, -]; - -let huksOptions: huks.HuksOptions = { - properties: keyProperties, // 非空填充 - inData: new Uint8Array([]) // 非空填充 -} - -function check() { - try { - huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => { - if (error) { - console.error(`callback: isKeyItemExist failed, ` + JSON.stringify(error)); - } else { - if (data !== null && data.valueOf() !== null) { - isKeyExist = data.valueOf(); - console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`); - } - } - }); - } catch (error) { - console.error(`callback: isKeyItemExist input arg invalid, ` + JSON.stringify(error)); - throw (error as Error); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'RSA2048'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_rsa_2048')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - try { - importRSA2048(); - check(); - this.message = 'RSA2048 Result: Success'; - }catch{ - this.message = 'RSA2048 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start import_keys_in_plaintext_RSA2048] +/* 以下以导入RSA2048密钥的Callback操作使用为例 */ +import { huks } from '@kit.UniversalKeystoreKit' + +let rsa2048KeyPairMaterial = new Uint8Array([ + 0x01, 0x00, 0x00, 0x00, // 密钥算法(小端表示)huks.HuksKeyAlg.HUKS_ALG_RSA = 1 + 0x00, 0x08, 0x00, 0x00, // 密钥大小(比特):2048 + 0x00, 0x01, 0x00, 0x00, // 模数n长度(字节):256 + 0x03, 0x00, 0x00, 0x00, // 公钥指数e长度(字节):3 + 0x00, 0x01, 0x00, 0x00, // 私钥指数d长度(字节):256 + // 模数n + 0xc5, 0x35, 0x62, 0x48, 0xc4, 0x92, 0x87, 0x73, 0x0d, 0x42, 0x96, 0xfc, 0x7b, 0x11, 0x05, 0x06, + 0x0f, 0x8d, 0x66, 0xc1, 0x0e, 0xad, 0x37, 0x44, 0x92, 0x95, 0x2f, 0x6a, 0x55, 0xba, 0xec, 0x1d, + 0x54, 0x62, 0x0a, 0x4b, 0xd3, 0xc7, 0x05, 0xe4, 0x07, 0x40, 0xd9, 0xb7, 0xc2, 0x12, 0xcb, 0x9a, + 0x90, 0xad, 0xe3, 0x24, 0xe8, 0x5e, 0xa6, 0xf8, 0xd0, 0x6e, 0xbc, 0xd1, 0x69, 0x7f, 0x6b, 0xe4, + 0x2b, 0x4e, 0x1a, 0x65, 0xbb, 0x73, 0x88, 0x6b, 0x7c, 0xaf, 0x7e, 0xd0, 0x47, 0x26, 0xeb, 0xa5, + 0xbe, 0xd6, 0xe8, 0xee, 0x9c, 0xa5, 0x66, 0xa5, 0xc9, 0xd3, 0x25, 0x13, 0xc4, 0x0e, 0x6c, 0xab, + 0x50, 0xb6, 0x50, 0xc9, 0xce, 0x8f, 0x0a, 0x0b, 0xc6, 0x28, 0x69, 0xe9, 0x83, 0x69, 0xde, 0x42, + 0x56, 0x79, 0x7f, 0xde, 0x86, 0x24, 0xca, 0xfc, 0xaa, 0xc0, 0xf3, 0xf3, 0x7f, 0x92, 0x8e, 0x8a, + 0x12, 0x52, 0xfe, 0x50, 0xb1, 0x5e, 0x8c, 0x01, 0xce, 0xfc, 0x7e, 0xf2, 0x4f, 0x5f, 0x03, 0xfe, + 0xa7, 0xcd, 0xa1, 0xfc, 0x94, 0x52, 0x00, 0x8b, 0x9b, 0x7f, 0x09, 0xab, 0xa8, 0xa4, 0xf5, 0xb4, + 0xa5, 0xaa, 0xfc, 0x72, 0xeb, 0x17, 0x40, 0xa9, 0xee, 0xbe, 0x8f, 0xc2, 0xd1, 0x80, 0xc2, 0x0d, + 0x44, 0xa9, 0x59, 0x44, 0x59, 0x81, 0x3b, 0x5d, 0x4a, 0xde, 0xfb, 0xae, 0x24, 0xfc, 0xa3, 0xd9, + 0xbc, 0x57, 0x55, 0xc2, 0x26, 0xbc, 0x19, 0xa7, 0x9a, 0xc5, 0x59, 0xa3, 0xee, 0x5a, 0xef, 0x41, + 0x80, 0x7d, 0xf8, 0x5e, 0xc1, 0x1d, 0x32, 0x38, 0x41, 0x5b, 0xb6, 0x92, 0xb8, 0xb7, 0x03, 0x0d, + 0x3e, 0x59, 0x0f, 0x1c, 0xb3, 0xe1, 0x2a, 0x95, 0x1a, 0x3b, 0x50, 0x4f, 0xc4, 0x1d, 0xcf, 0x73, + 0x7c, 0x14, 0xca, 0xe3, 0x0b, 0xa7, 0xc7, 0x1a, 0x41, 0x4a, 0xee, 0xbe, 0x1f, 0x43, 0xdd, 0xf9, + // 公钥指数e + 0x01, 0x00, 0x01, + // 私钥指数d + 0x88, 0x4b, 0x82, 0xe7, 0xe3, 0xe3, 0x99, 0x75, 0x6c, 0x9e, 0xaf, 0x17, 0x44, 0x3e, 0xd9, 0x07, + 0xfd, 0x4b, 0xae, 0xce, 0x92, 0xc4, 0x28, 0x44, 0x5e, 0x42, 0x79, 0x08, 0xb6, 0xc3, 0x7f, 0x58, + 0x2d, 0xef, 0xac, 0x4a, 0x07, 0xcd, 0xaf, 0x46, 0x8f, 0xb4, 0xc4, 0x43, 0xf9, 0xff, 0x5f, 0x74, + 0x2d, 0xb5, 0xe0, 0x1c, 0xab, 0xf4, 0x6e, 0xd5, 0xdb, 0xc8, 0x0c, 0xfb, 0x76, 0x3c, 0x38, 0x66, + 0xf3, 0x7f, 0x01, 0x43, 0x7a, 0x30, 0x39, 0x02, 0x80, 0xa4, 0x11, 0xb3, 0x04, 0xd9, 0xe3, 0x57, + 0x23, 0xf4, 0x07, 0xfc, 0x91, 0x8a, 0xc6, 0xcc, 0xa2, 0x16, 0x29, 0xb3, 0xe5, 0x76, 0x4a, 0xa8, + 0x84, 0x19, 0xdc, 0xef, 0xfc, 0xb0, 0x63, 0x33, 0x0b, 0xfa, 0xf6, 0x68, 0x0b, 0x08, 0xea, 0x31, + 0x52, 0xee, 0x99, 0xef, 0x43, 0x2a, 0xbe, 0x97, 0xad, 0xb3, 0xb9, 0x66, 0x7a, 0xae, 0xe1, 0x8f, + 0x57, 0x86, 0xe5, 0xfe, 0x14, 0x3c, 0x81, 0xd0, 0x64, 0xf8, 0x86, 0x1a, 0x0b, 0x40, 0x58, 0xc9, + 0x33, 0x49, 0xb8, 0x99, 0xc6, 0x2e, 0x94, 0x70, 0xee, 0x09, 0x88, 0xe1, 0x5c, 0x4e, 0x6c, 0x22, + 0x72, 0xa7, 0x2a, 0x21, 0xdd, 0xd7, 0x1d, 0xfc, 0x63, 0x15, 0x0b, 0xde, 0x06, 0x9c, 0xf3, 0x28, + 0xf3, 0xac, 0x4a, 0xa8, 0xb5, 0x50, 0xca, 0x9b, 0xcc, 0x0a, 0x04, 0xfe, 0x3f, 0x98, 0x68, 0x81, + 0xac, 0x24, 0x53, 0xea, 0x1f, 0x1c, 0x6e, 0x5e, 0xca, 0xe8, 0x31, 0x0d, 0x08, 0x12, 0xf3, 0x26, + 0xf8, 0x5e, 0xeb, 0x10, 0x27, 0xae, 0xaa, 0xc3, 0xad, 0x6c, 0xc1, 0x89, 0xdb, 0x7d, 0x5a, 0x12, + 0x55, 0xad, 0x11, 0x19, 0xa1, 0xa9, 0x8f, 0x0b, 0x6d, 0x78, 0x8d, 0x1c, 0xdf, 0xe5, 0x63, 0x82, + 0x0b, 0x7d, 0x23, 0x04, 0xb4, 0x75, 0x8c, 0xed, 0x77, 0xfc, 0x1a, 0x85, 0x29, 0x11, 0xe0, 0x61, +]); + +/* 1.确定密钥别名 */ +let keyAlias = 'RSA_sample'; +/* 2.封装密钥属性集和密钥材料 */ +let properties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, + { + // 此 tag表示密钥导入后的用途,导入后将不可更改 + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }, + { + // 此 tag表示需导入的密钥类型 + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + // 此 value表示导入密钥对,若改为HUKS_KEY_TYPE_PUBLIC_KEY时表示仅导入公钥 + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + }, +]; + +let options: huks.HuksOptions = { + properties: properties, + inData: rsa2048KeyPairMaterial +}; + +/* 3.明文导入密钥 */ +function importRSA2048() { + try { + huks.importKeyItem(keyAlias, options, (error, data) => { + if (error) { + console.error(`callback: importKeyItem failed` + error); + } else { + console.info(`callback: importKeyItem success`); + } + }); + } catch (error) { + console.error(`callback: importKeyItem input arg invalid` + error); + throw (error as Error); + } +} + + + +// [End import_keys_in_plaintext_RSA2048] +let isKeyExist = false; + +let keyProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }, + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + }, +]; + +let huksOptions: huks.HuksOptions = { + properties: keyProperties, // 非空填充 + inData: new Uint8Array([]) // 非空填充 +} + +function check() { + try { + huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => { + if (error) { + console.error(`callback: isKeyItemExist failed, ` + JSON.stringify(error)); + } else { + if (data !== null && data.valueOf() !== null) { + isKeyExist = data.valueOf(); + console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`); + } + } + }); + } catch (error) { + console.error(`callback: isKeyItemExist input arg invalid, ` + JSON.stringify(error)); + throw (error as Error); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'RSA2048'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_rsa_2048')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + try { + importRSA2048(); + check(); + this.message = 'RSA2048 Result: Success'; + }catch{ + this.message = 'RSA2048 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets old mode 100755 new mode 100644 index 70a1720bfe..10a0bdcad8 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets @@ -1,151 +1,151 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start import_keys_in_plaintext_X25519] -/* 以下以导入X25519密钥的Callback操作使用为例 */ -import { huks } from '@kit.UniversalKeystoreKit' - -// X25519的公钥数据。X25519 密钥对中的私钥和公钥都是 32 字节(256 位),关于算法原理请自行参考相关密钥学资料。 -let x25519KeyPubMaterial = new Uint8Array([ - 0x30, 0x2A, 0x30, 0x05, 0x06, 0x03, 0x2B, 0x65, 0x6E, 0x03, 0x21, 0x00, 0xD2, 0x36, 0x9E, 0xCF, - 0xF0, 0x61, 0x5B, 0x73, 0xCE, 0x4F, 0xF0, 0x40, 0x2B, 0x89, 0x18, 0x3E, 0x06, 0x33, 0x60, 0xC6 -]); - -/* 1.确定密钥别名 */ -let keyAlias = 'X25519_Pub_import_sample'; -/* 2.封装密钥属性集和密钥材料 */ -let properties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_X25519 - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 - }, - { - // 此 tag表示密钥导入后的用途,导入后将不可更改 - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, - { - // 此 tag表示需导入的密钥类型 - tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, - // 此 value表示导入密钥的公钥,若改为HUKS_KEY_TYPE_KEY_PAIR时表示导入密钥对 - value: huks.HuksImportKeyType.HUKS_KEY_TYPE_PUBLIC_KEY - }, -]; - -let options: huks.HuksOptions = { - properties: properties, - inData: x25519KeyPubMaterial -}; - -/* 3.明文导入密钥 */ -function importX25519() { - try { - huks.importKeyItem(keyAlias, options, (error, data) => { - if (error) { - console.error(`callback: importKeyItem failed` + error); - } else { - console.info(`callback: importKeyItem success`); - } - }); - } catch (error) { - console.error(`callback: importKeyItem input arg invalid` + error); - throw (error as Error); - } -} - - -// [End import_keys_in_plaintext_X25519] - -let isKeyExist = false; - -let keyProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_X25519 - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, - { - tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, - value: huks.HuksImportKeyType.HUKS_KEY_TYPE_PUBLIC_KEY - }, -] - -let huksOptions: huks.HuksOptions = { - properties: keyProperties, // 非空填充 - inData: new Uint8Array([]) // 非空填充 -} - -function check() { - try { - huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => { - if (error) { - console.error(`callback: isKeyItemExist failed, ` + JSON.stringify(error)); - } else { - if (data !== null && data.valueOf() !== null) { - isKeyExist = data.valueOf(); - console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`); - } - } - }); - } catch (error) { - console.error(`callback: isKeyItemExist input arg invalid, ` + JSON.stringify(error)); - throw (error as Error); - } -} - -@Entry -@Component -struct Index { - @State message: string = 'X25519'; - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_x25519')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - try { - importX25519(); - check(); - this.message = 'X25519 Result: Success'; - }catch{ - this.message = 'X25519 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start import_keys_in_plaintext_X25519] +/* 以下以导入X25519密钥的Callback操作使用为例 */ +import { huks } from '@kit.UniversalKeystoreKit' + +// X25519的公钥数据。X25519 密钥对中的私钥和公钥都是 32 字节(256 位),关于算法原理请自行参考相关密钥学资料。 +let x25519KeyPubMaterial = new Uint8Array([ + 0x30, 0x2A, 0x30, 0x05, 0x06, 0x03, 0x2B, 0x65, 0x6E, 0x03, 0x21, 0x00, 0xD2, 0x36, 0x9E, 0xCF, + 0xF0, 0x61, 0x5B, 0x73, 0xCE, 0x4F, 0xF0, 0x40, 0x2B, 0x89, 0x18, 0x3E, 0x06, 0x33, 0x60, 0xC6 +]); + +/* 1.确定密钥别名 */ +let keyAlias = 'X25519_Pub_import_sample'; +/* 2.封装密钥属性集和密钥材料 */ +let properties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_X25519 + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 + }, + { + // 此 tag表示密钥导入后的用途,导入后将不可更改 + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, + { + // 此 tag表示需导入的密钥类型 + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + // 此 value表示导入密钥的公钥,若改为HUKS_KEY_TYPE_KEY_PAIR时表示导入密钥对 + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_PUBLIC_KEY + }, +]; + +let options: huks.HuksOptions = { + properties: properties, + inData: x25519KeyPubMaterial +}; + +/* 3.明文导入密钥 */ +function importX25519() { + try { + huks.importKeyItem(keyAlias, options, (error, data) => { + if (error) { + console.error(`callback: importKeyItem failed` + error); + } else { + console.info(`callback: importKeyItem success`); + } + }); + } catch (error) { + console.error(`callback: importKeyItem input arg invalid` + error); + throw (error as Error); + } +} + + +// [End import_keys_in_plaintext_X25519] + +let isKeyExist = false; + +let keyProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_X25519 + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_PUBLIC_KEY + }, +] + +let huksOptions: huks.HuksOptions = { + properties: keyProperties, // 非空填充 + inData: new Uint8Array([]) // 非空填充 +} + +function check() { + try { + huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => { + if (error) { + console.error(`callback: isKeyItemExist failed, ` + JSON.stringify(error)); + } else { + if (data !== null && data.valueOf() !== null) { + isKeyExist = data.valueOf(); + console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`); + } + } + }); + } catch (error) { + console.error(`callback: isKeyItemExist input arg invalid, ` + JSON.stringify(error)); + throw (error as Error); + } +} + +@Entry +@Component +struct Index { + @State message: string = 'X25519'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_x25519')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + try { + importX25519(); + check(); + this.message = 'X25519 Result: Success'; + }catch{ + this.message = 'X25519 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/ImportKeyPlainText.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/ImportKeyPlainText.test.ets old mode 100755 new mode 100644 index 37549a3ecc..cf0e6f603a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/ImportKeyPlainText.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/ImportKeyPlainText.test.ets @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function importKeyPlainTextTest() { - describe('importKeyPlainTextTest', () => { - - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - it('testImportKeyPlainText001', 0, async () => { - console.info('uitest: testImportKeyPlainText001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('AES256')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES256')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES256 Result: Success')); - console.info('uitest: testImportKeyPlainText001 end'); - await driver.pressBack(); - }) - - it('testImportKeyPlainText002', 0, async () => { - console.info('uitest: testImportKeyPlainText002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA2048')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA2048')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('RSA2048 Result: Success')); - console.info('uitest: testImportKeyPlainText002 end'); - await driver.pressBack(); - }) - - it('testImportKeyPlainText003', 0, async () => { - console.info('uitest: testImportKeyPlainText003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('X25519')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call X25519')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('X25519 Result: Success')); - console.info('uitest: testImportKeyPlainText003 end'); - await driver.pressBack(); - }) - - it('testImportKeyPlainText004', 0, async () => { - console.info('uitest: testImportKeyPlainText004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testImportKeyPlainText004 end'); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function importKeyPlainTextTest() { + describe('importKeyPlainTextTest', () => { + + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + it('testImportKeyPlainText001', 0, async () => { + console.info('uitest: testImportKeyPlainText001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('AES256')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES256')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES256 Result: Success')); + console.info('uitest: testImportKeyPlainText001 end'); + await driver.pressBack(); + }) + + it('testImportKeyPlainText002', 0, async () => { + console.info('uitest: testImportKeyPlainText002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA2048')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA2048')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('RSA2048 Result: Success')); + console.info('uitest: testImportKeyPlainText002 end'); + await driver.pressBack(); + }) + + it('testImportKeyPlainText003', 0, async () => { + console.info('uitest: testImportKeyPlainText003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('X25519')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call X25519')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('X25519 Result: Success')); + console.info('uitest: testImportKeyPlainText003 end'); + await driver.pressBack(); + }) + + it('testImportKeyPlainText004', 0, async () => { + console.info('uitest: testImportKeyPlainText004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testImportKeyPlainText004 end'); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/app.json5 old mode 100755 new mode 100644 index 163d71aa93..f2c7feff93 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/app.json5 @@ -1,25 +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.anonymouskeyproof", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.anonymouskeyproof", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 5cf961e6bf..d2ae0e044d --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AnonymousKeyProof" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AnonymousKeyProof" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index de73f737d2..2120cc1b57 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(AnonymousKeyProof) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(AnonymousKeyProof) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 70730d8b48..859f3a2f1e --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp @@ -1,157 +1,157 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start anonymized_key_proof] -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include - -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} - -static uint32_t g_size = 4096; -static uint32_t CERT_COUNT = 4; -void FreeCertChain(struct OH_Huks_CertChain *certChain, const uint32_t pos) -{ - if (certChain == nullptr || certChain->certs == nullptr) { - return; - } - for (uint32_t j = 0; j < pos; j++) { - if (certChain->certs[j].data != nullptr) { - free(certChain->certs[j].data); - certChain->certs[j].data = nullptr; - } - } - if (certChain->certs != nullptr) { - free(certChain->certs); - certChain->certs = nullptr; - } -} - -int32_t ConstructDataToCertChain(struct OH_Huks_CertChain *certChain) -{ - if (certChain == nullptr) { - return OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT; - } - certChain->certsCount = CERT_COUNT; - - certChain->certs = (struct OH_Huks_Blob *)malloc(sizeof(struct OH_Huks_Blob) * (certChain->certsCount)); - if (certChain->certs == nullptr) { - return OH_HUKS_ERR_CODE_INTERNAL_ERROR; - } - for (uint32_t i = 0; i < certChain->certsCount; i++) { - certChain->certs[i].size = g_size; - certChain->certs[i].data = (uint8_t *)malloc(certChain->certs[i].size); - if (certChain->certs[i].data == nullptr) { - FreeCertChain(certChain, i); - return OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT; - } - } - return 0; -} - -static struct OH_Huks_Param g_genAnonAttestParams[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_VERIFY}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS}, - {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_ECB}, -}; - -#define CHALLENGE_DATA "hi_challenge_data" -static struct OH_Huks_Blob g_challenge = {sizeof(CHALLENGE_DATA), (uint8_t *)CHALLENGE_DATA}; -static napi_value AnonAttestKey(napi_env env, napi_callback_info info) -{ - /* 1.确定密钥别名 */ - struct OH_Huks_Blob genAlias = {(uint32_t)strlen("test_anon_attest"), (uint8_t *)"test_anon_attest"}; - static struct OH_Huks_Param g_anonAttestParams[] = { - {.tag = OH_HUKS_TAG_ATTESTATION_CHALLENGE, .blob = g_challenge}, - {.tag = OH_HUKS_TAG_ATTESTATION_ID_ALIAS, .blob = genAlias}, - }; - struct OH_Huks_ParamSet *genParamSet = nullptr; - struct OH_Huks_ParamSet *anonAttestParamSet = nullptr; - OH_Huks_Result ohResult; - OH_Huks_Blob certs = {0}; - OH_Huks_CertChain certChain = {&certs, 0}; - do { - /* 2.初始化密钥参数集 */ - ohResult = - InitParamSet(&genParamSet, g_genAnonAttestParams, sizeof(g_genAnonAttestParams) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = - InitParamSet(&anonAttestParamSet, g_anonAttestParams, sizeof(g_anonAttestParams) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = OH_Huks_GenerateKeyItem(&genAlias, genParamSet, nullptr); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - - (void)ConstructDataToCertChain(&certChain); - /* 3.证明密钥 */ - ohResult = OH_Huks_AnonAttestKeyItem(&genAlias, anonAttestParamSet, &certChain); - } while (0); - FreeCertChain(&certChain, CERT_COUNT); - OH_Huks_FreeParamSet(&genParamSet); - OH_Huks_FreeParamSet(&anonAttestParamSet); - (void)OH_Huks_DeleteKeyItem(&genAlias, NULL); - - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} -// [End anonymized_key_proof] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"anonAttestKey", nullptr, AnonAttestKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start anonymized_key_proof] +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include + +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} + +static uint32_t g_size = 4096; +static uint32_t CERT_COUNT = 4; +void FreeCertChain(struct OH_Huks_CertChain *certChain, const uint32_t pos) +{ + if (certChain == nullptr || certChain->certs == nullptr) { + return; + } + for (uint32_t j = 0; j < pos; j++) { + if (certChain->certs[j].data != nullptr) { + free(certChain->certs[j].data); + certChain->certs[j].data = nullptr; + } + } + if (certChain->certs != nullptr) { + free(certChain->certs); + certChain->certs = nullptr; + } +} + +int32_t ConstructDataToCertChain(struct OH_Huks_CertChain *certChain) +{ + if (certChain == nullptr) { + return OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT; + } + certChain->certsCount = CERT_COUNT; + + certChain->certs = (struct OH_Huks_Blob *)malloc(sizeof(struct OH_Huks_Blob) * (certChain->certsCount)); + if (certChain->certs == nullptr) { + return OH_HUKS_ERR_CODE_INTERNAL_ERROR; + } + for (uint32_t i = 0; i < certChain->certsCount; i++) { + certChain->certs[i].size = g_size; + certChain->certs[i].data = (uint8_t *)malloc(certChain->certs[i].size); + if (certChain->certs[i].data == nullptr) { + FreeCertChain(certChain, i); + return OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT; + } + } + return 0; +} + +static struct OH_Huks_Param g_genAnonAttestParams[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_VERIFY}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS}, + {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_ECB}, +}; + +#define CHALLENGE_DATA "hi_challenge_data" +static struct OH_Huks_Blob g_challenge = {sizeof(CHALLENGE_DATA), (uint8_t *)CHALLENGE_DATA}; +static napi_value AnonAttestKey(napi_env env, napi_callback_info info) +{ + /* 1.确定密钥别名 */ + struct OH_Huks_Blob genAlias = {(uint32_t)strlen("test_anon_attest"), (uint8_t *)"test_anon_attest"}; + static struct OH_Huks_Param g_anonAttestParams[] = { + {.tag = OH_HUKS_TAG_ATTESTATION_CHALLENGE, .blob = g_challenge}, + {.tag = OH_HUKS_TAG_ATTESTATION_ID_ALIAS, .blob = genAlias}, + }; + struct OH_Huks_ParamSet *genParamSet = nullptr; + struct OH_Huks_ParamSet *anonAttestParamSet = nullptr; + OH_Huks_Result ohResult; + OH_Huks_Blob certs = {0}; + OH_Huks_CertChain certChain = {&certs, 0}; + do { + /* 2.初始化密钥参数集 */ + ohResult = + InitParamSet(&genParamSet, g_genAnonAttestParams, sizeof(g_genAnonAttestParams) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = + InitParamSet(&anonAttestParamSet, g_anonAttestParams, sizeof(g_anonAttestParams) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = OH_Huks_GenerateKeyItem(&genAlias, genParamSet, nullptr); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + + (void)ConstructDataToCertChain(&certChain); + /* 3.证明密钥 */ + ohResult = OH_Huks_AnonAttestKeyItem(&genAlias, anonAttestParamSet, &certChain); + } while (0); + FreeCertChain(&certChain, CERT_COUNT); + OH_Huks_FreeParamSet(&genParamSet); + OH_Huks_FreeParamSet(&anonAttestParamSet); + (void)OH_Huks_DeleteKeyItem(&genAlias, NULL); + + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} +// [End anonymized_key_proof] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"anonAttestKey", nullptr, AnonAttestKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index ea4292d920..b9a785abe3 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 anonAttestKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets old mode 100755 new mode 100644 index 5d1c616b4c..750090ef30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets @@ -1,216 +1,216 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start anonymous_key_proof] -/* - * 以下以anonAttestKey的Promise接口操作验证为例 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -/* 1.确定密钥别名 */ -let keyAliasString = 'key anon attest'; -let aliasString = keyAliasString; -let aliasUint8 = stringToUint8Array(keyAliasString); -let securityLevel = stringToUint8Array('sec_level'); -let challenge = stringToUint8Array('challenge_data'); -let versionInfo = stringToUint8Array('version_info'); -let anonAttestCertChain: string[]; - -class ThrowObject { - public isThrow: boolean = false; -} - -/* 封装生成时的密钥参数集 */ -let genKeyProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, - { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PSS - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, - value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT - }, - { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB - } -] -let genOptions: huks.HuksOptions = { - properties: genKeyProperties -}; - -/* 2.封装证明密钥的参数集 */ -let anonAttestKeyProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, - value: securityLevel - }, - { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, - value: challenge - }, - { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, - value: versionInfo - }, - { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, - value: aliasUint8 - } -] -let huksOptions: huks.HuksOptions = { - properties: anonAttestKeyProperties -}; - -function stringToUint8Array(str: string) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -/* 3.生成密钥 */ -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise generateKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await generateKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); - } - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); - } -} - -/* 4.证明密钥 */ -function anonAttestKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.anonAttestKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicAnonAttestKey(keyAlias: string, huksOptions: huks.HuksOptions): Promise { - console.info(`enter promise anonAttestKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await anonAttestKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: anonAttestKeyItem success, data = ${JSON.stringify(data)}`); - if (data !== null && data.certChains !== null) { - anonAttestCertChain = data.certChains as string[]; - } - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: anonAttestKeyItem failed, ${JSON.stringify(error)}`); - } - }); - return 'Success'; - } catch (error) { - console.error(`promise: anonAttestKeyItem input arg invalid, ${JSON.stringify(error)}`); - return 'Failed'; - } -} - -async function anonAttestKeyTest(): Promise { - await publicGenKeyFunc(aliasString, genOptions); - let ret = await publicAnonAttestKey(aliasString, huksOptions); - console.info('anon attest certChain data: ' + anonAttestCertChain) - return ret; -} -// [End anonymous_key_proof] -@Entry -@Component -struct Index { - @State message: string = 'AnonymousKeyProof'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_anonymous_key_proof')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - let ret = await anonAttestKeyTest(); - this.message = 'AnonymousKeyProof Result: ' + ret; - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start anonymous_key_proof] +/* + * 以下以anonAttestKey的Promise接口操作验证为例 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +/* 1.确定密钥别名 */ +let keyAliasString = 'key anon attest'; +let aliasString = keyAliasString; +let aliasUint8 = stringToUint8Array(keyAliasString); +let securityLevel = stringToUint8Array('sec_level'); +let challenge = stringToUint8Array('challenge_data'); +let versionInfo = stringToUint8Array('version_info'); +let anonAttestCertChain: string[]; + +class ThrowObject { + public isThrow: boolean = false; +} + +/* 封装生成时的密钥参数集 */ +let genKeyProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, + { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PSS + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, + value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT + }, + { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB + } +] +let genOptions: huks.HuksOptions = { + properties: genKeyProperties +}; + +/* 2.封装证明密钥的参数集 */ +let anonAttestKeyProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, + value: securityLevel + }, + { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, + value: challenge + }, + { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, + value: versionInfo + }, + { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, + value: aliasUint8 + } +] +let huksOptions: huks.HuksOptions = { + properties: anonAttestKeyProperties +}; + +function stringToUint8Array(str: string) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +/* 3.生成密钥 */ +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise generateKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await generateKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); + } + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); + } +} + +/* 4.证明密钥 */ +function anonAttestKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.anonAttestKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicAnonAttestKey(keyAlias: string, huksOptions: huks.HuksOptions): Promise { + console.info(`enter promise anonAttestKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await anonAttestKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: anonAttestKeyItem success, data = ${JSON.stringify(data)}`); + if (data !== null && data.certChains !== null) { + anonAttestCertChain = data.certChains as string[]; + } + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: anonAttestKeyItem failed, ${JSON.stringify(error)}`); + } + }); + return 'Success'; + } catch (error) { + console.error(`promise: anonAttestKeyItem input arg invalid, ${JSON.stringify(error)}`); + return 'Failed'; + } +} + +async function anonAttestKeyTest(): Promise { + await publicGenKeyFunc(aliasString, genOptions); + let ret = await publicAnonAttestKey(aliasString, huksOptions); + console.info('anon attest certChain data: ' + anonAttestCertChain) + return ret; +} +// [End anonymous_key_proof] +@Entry +@Component +struct Index { + @State message: string = 'AnonymousKeyProof'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_anonymous_key_proof')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + let ret = await anonAttestKeyTest(); + this.message = 'AnonymousKeyProof Result: ' + ret; + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/AnonymousKeyProof.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/AnonymousKeyProof.test.ets old mode 100755 new mode 100644 index 91bbbef815..80afe5c5aa --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/AnonymousKeyProof.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/AnonymousKeyProof.test.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function anonymousKeyProofTest() { - describe('anonymousKeyProofTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,匿名密钥证明(ArkTS) - */ - it('testAnonymousKeyProof001', 0, async () => { - console.info('uitest: testAnonymousKeyProof001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('AnonymousKeyProof').type('Button')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AnonymousKeyProof')); - await button2.click(); - await driver.delayMs(5000); - await driver.assertComponentExist(ON.text('AnonymousKeyProof Result: Success')); - console.info('uitest: testAnonymousKeyProof001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,匿名密钥证明(C/C++) - */ - it('testAnonymousKeyProof002', 0, async () => { - console.info('uitest: testAnonymousKeyProof002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(3000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testAnonymousKeyProof002 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function anonymousKeyProofTest() { + describe('anonymousKeyProofTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,匿名密钥证明(ArkTS) + */ + it('testAnonymousKeyProof001', 0, async () => { + console.info('uitest: testAnonymousKeyProof001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('AnonymousKeyProof').type('Button')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AnonymousKeyProof')); + await button2.click(); + await driver.delayMs(5000); + await driver.assertComponentExist(ON.text('AnonymousKeyProof Result: Success')); + console.info('uitest: testAnonymousKeyProof001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,匿名密钥证明(C/C++) + */ + it('testAnonymousKeyProof002', 0, async () => { + console.info('uitest: testAnonymousKeyProof002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(3000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testAnonymousKeyProof002 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/ohosTest.md old mode 100755 new mode 100644 index 23e0088d4c..cd3b5f37c2 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/ohosTest.md @@ -1,9 +1,9 @@ -# 匿名密钥证明测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------- | ------------ | ---- | ---------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,匿名密钥证明(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | +# 匿名密钥证明测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------- | ------------ | ---- | ---------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,匿名密钥证明(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | | 点击按钮,匿名密钥证明(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/app.json5 old mode 100755 new mode 100644 index 90addccb5b..4b8d9e4aee --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/app.json5 @@ -1,25 +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.nonanonymouskeyproof", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.nonanonymouskeyproof", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index bed89842c8..b9bd49669a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NonAnonymousKeyProof" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "NonAnonymousKeyProof" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index f4f8280369..5c714d56e5 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(NonanonymousKeyProof) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NonanonymousKeyProof) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index fc5993bf00..2d7892ea30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 attestKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets old mode 100755 new mode 100644 index 3509e335b4..a856527b62 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets @@ -1,216 +1,216 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start Start non_anonymized_key_proof] -/* - * 以下以attestKey的Promise接口操作验证为例 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -/* 1.确定密钥别名 */ -let keyAliasString = 'key attest'; -let aliasString = keyAliasString; -let aliasUint8 = stringToUint8Array(keyAliasString); -let securityLevel = stringToUint8Array('sec_level'); -let challenge = stringToUint8Array('challenge_data'); -let versionInfo = stringToUint8Array('version_info'); -let attestCertChain: string[]; - -class ThrowObject { - public isThrow: boolean = false; -} - -/* 封装生成时的密钥参数集 */ -let genKeyProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, - { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PSS - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, - value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT - }, - { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB - } -] -let genOptions: huks.HuksOptions = { - properties: genKeyProperties -}; - -/* 2.封装证明密钥的参数集 */ -let attestKeyproperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, - value: securityLevel - }, - { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, - value: challenge - }, - { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, - value: versionInfo - }, - { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, - value: aliasUint8 - } -] -let huksOptions: huks.HuksOptions = { - properties: attestKeyproperties -}; - -function stringToUint8Array(str: string) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -/* 3.生成密钥 */ -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise generateKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await generateKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); - } - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); - } -} - -/* 4.证明密钥 */ -function attestKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.attestKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicAttestKey(keyAlias: string, huksOptions: huks.HuksOptions): Promise { - console.info(`enter promise attestKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await attestKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: attestKeyItem success, data = ${JSON.stringify(data)}`); - if (data !== null && data.certChains !== null) { - attestCertChain = data.certChains as string[]; - } - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: attestKeyItem failed, ${JSON.stringify(error)}`); - } - }); - return 'Success'; - } catch (error) { - console.error(`promise: attestKeyItem input arg invalid, ${JSON.stringify(error)}`); - return 'Failed'; - } -} - -async function attestKeyTest(): Promise { - await publicGenKeyFunc(aliasString, genOptions); - let ret = await publicAttestKey(aliasString, huksOptions); - console.info('attest certChain data: ' + attestCertChain) - return ret; -} -// [End Start non_anonymized_key_proof] -@Entry -@Component -struct Index { - @State message: string = 'NonAnonymousKeyProof'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_non_anonymous_key_proof')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - let ret = await attestKeyTest(); - this.message = 'NonAnonymousKeyProof Result: ' + ret; - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Start non_anonymized_key_proof] +/* + * 以下以attestKey的Promise接口操作验证为例 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +/* 1.确定密钥别名 */ +let keyAliasString = 'key attest'; +let aliasString = keyAliasString; +let aliasUint8 = stringToUint8Array(keyAliasString); +let securityLevel = stringToUint8Array('sec_level'); +let challenge = stringToUint8Array('challenge_data'); +let versionInfo = stringToUint8Array('version_info'); +let attestCertChain: string[]; + +class ThrowObject { + public isThrow: boolean = false; +} + +/* 封装生成时的密钥参数集 */ +let genKeyProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, + { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PSS + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, + value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT + }, + { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB + } +] +let genOptions: huks.HuksOptions = { + properties: genKeyProperties +}; + +/* 2.封装证明密钥的参数集 */ +let attestKeyproperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, + value: securityLevel + }, + { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, + value: challenge + }, + { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, + value: versionInfo + }, + { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, + value: aliasUint8 + } +] +let huksOptions: huks.HuksOptions = { + properties: attestKeyproperties +}; + +function stringToUint8Array(str: string) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +/* 3.生成密钥 */ +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise generateKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await generateKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); + } + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); + } +} + +/* 4.证明密钥 */ +function attestKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.attestKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicAttestKey(keyAlias: string, huksOptions: huks.HuksOptions): Promise { + console.info(`enter promise attestKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await attestKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: attestKeyItem success, data = ${JSON.stringify(data)}`); + if (data !== null && data.certChains !== null) { + attestCertChain = data.certChains as string[]; + } + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: attestKeyItem failed, ${JSON.stringify(error)}`); + } + }); + return 'Success'; + } catch (error) { + console.error(`promise: attestKeyItem input arg invalid, ${JSON.stringify(error)}`); + return 'Failed'; + } +} + +async function attestKeyTest(): Promise { + await publicGenKeyFunc(aliasString, genOptions); + let ret = await publicAttestKey(aliasString, huksOptions); + console.info('attest certChain data: ' + attestCertChain) + return ret; +} +// [End Start non_anonymized_key_proof] +@Entry +@Component +struct Index { + @State message: string = 'NonAnonymousKeyProof'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_non_anonymous_key_proof')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + let ret = await attestKeyTest(); + this.message = 'NonAnonymousKeyProof Result: ' + ret; + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/module.json5 old mode 100755 new mode 100644 index 0e0b2cf33d..f0261f2ef4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/module.json5 @@ -1,78 +1,78 @@ -/* - * 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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.ATTEST_KEY", - "reason": "$string:permissionsReason", - "usedScene": { - "abilities": [ - "EntryAbility" - ], - "when": "inuse" - } - } - ] - } -} +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.ATTEST_KEY", + "reason": "$string:permissionsReason", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "inuse" + } + } + ] + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/NonAnonymousKeyProof.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/NonAnonymousKeyProof.test.ets old mode 100755 new mode 100644 index 8905d23585..56e3d849aa --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/NonAnonymousKeyProof.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/NonAnonymousKeyProof.test.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function nonAnonymousKeyProofTest() { - describe('nonAnonymousKeyProofTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,非匿名密钥证明(ArkTS) - */ - it('testNonAnonymousKeyProof001', 0, async () => { - console.info('uitest: testNonAnonymousKeyProof001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('NonAnonymousKeyProof').type('Button')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call NonAnonymousKeyProof')); - await button2.click(); - await driver.delayMs(3000); - await driver.assertComponentExist(ON.text('NonAnonymousKeyProof Result: Success')); - console.info('uitest: testNonAnonymousKeyProof001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,非匿名密钥证明(C/C++) - */ - it('testNonAnonymousKeyProof002', 0, async () => { - console.info('uitest: testNonAnonymousKeyProof002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testNonAnonymousKeyProof002 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function nonAnonymousKeyProofTest() { + describe('nonAnonymousKeyProofTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,非匿名密钥证明(ArkTS) + */ + it('testNonAnonymousKeyProof001', 0, async () => { + console.info('uitest: testNonAnonymousKeyProof001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('NonAnonymousKeyProof').type('Button')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call NonAnonymousKeyProof')); + await button2.click(); + await driver.delayMs(3000); + await driver.assertComponentExist(ON.text('NonAnonymousKeyProof Result: Success')); + console.info('uitest: testNonAnonymousKeyProof001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,非匿名密钥证明(C/C++) + */ + it('testNonAnonymousKeyProof002', 0, async () => { + console.info('uitest: testNonAnonymousKeyProof002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testNonAnonymousKeyProof002 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/ohosTest.md old mode 100755 new mode 100644 index ccfba062f1..d83f44fc10 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/ohosTest.md @@ -1,9 +1,9 @@ -# 非匿名密钥证明测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------- | ------------ | ---- | ---------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,非匿名密钥证明(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | +# 非匿名密钥证明测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------- | ------------ | ---- | ---------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,非匿名密钥证明(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | | 点击按钮,非匿名密钥证明(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/.gitignore old mode 100755 new mode 100644 index 0b9dda19af..d2ff20141c --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/.gitignore +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/.gitignore @@ -1,12 +1,12 @@ -/node_modules -/oh_modules -/local.properties -/.idea -**/build -/.hvigor -.cxx -/.clangd -/.clang-format -/.clang-tidy -**/.test +/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/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/app.json5 old mode 100755 new mode 100644 index 0040509f4e..92d4575e45 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/app.json5 @@ -1,25 +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.accesscontrol", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.accesscontrol", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index c7b5f61e40..daebd0deb4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AccessControl" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AccessControl" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/README.md old mode 100755 new mode 100644 index ba626d0360..5c30219adf --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/README.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/README.md @@ -1,88 +1,88 @@ -## 用户身份认证访问控制开发指导 - -### 介绍 - -1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-user-identity-authentication.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。 - -#### UserIdentityAuthentication - -##### 介绍 - -1. 本示例主要介绍实现用户身份认证访问控制,确保只有经过PIN认证的用户才能对加密数据进行操作。 - -##### 效果预览 - -| 主页 | 删除 | -| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | -| | | - -使用说明 - -1. 点击Call按钮依据预先设定的参数(如 SM4 算法、PIN认证等)生成密钥。 - -## 细粒度用户身份认证访问控制开发指导 - -### 介绍 - -1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-refined-user-identity-authentication.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。 - -#### FineGrainedUserIdentityAuthentication - -##### 介绍 - -1. 本示例主要介绍细粒度用户身份认证访问控制,允许设置密钥在加密、解密、签名、验签、密钥协商、密钥派生的单个或多个场景时是否需要进行身份验证。 - -##### 效果预览 - -| 主页 | 跳转页 | -| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | -| | | - -使用说明 - -1. 点击Call 按钮生成一个基于 SM4 算法、支持PIN认证且在解密时需身份验证的密钥。 - -## 工程目录 - -``` -entry/src/main/ -|---ets -|---|---entryability -|---|---|---EntryAbility.ets -|---|---pages -|---|---|---Index.ets // 首页 -|---|---|---FineGrainedUserIdentityAuthentication.ets -|---|---|---UserIdentityAuthentication.ets -|---cpp -|---resources // 静态资源 -|---ohosTest -|---|---ets -|---|---|---tests -|---|---|---|---AccessControl.test.ets // 自动化测试用例 -``` - -## 相关权限 - -[ohos.permission.ACCESS_BIOMETRIC](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionaccessbiometric) - -## 依赖 - -不涉及。 - -## 约束与限制 - -1. 本示例仅支持标准系统上运行,支持设备:RK3568。 -2. 本示例支持API14版本SDK,SDK版本号(API Version 14 Release)。 -3. 本示例需要使用DevEco Studio 版本号(5.0.1Release)才可编译运行。 - -## 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` +## 用户身份认证访问控制开发指导 + +### 介绍 + +1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-user-identity-authentication.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。 + +#### UserIdentityAuthentication + +##### 介绍 + +1. 本示例主要介绍实现用户身份认证访问控制,确保只有经过PIN认证的用户才能对加密数据进行操作。 + +##### 效果预览 + +| 主页 | 删除 | +| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| | | + +使用说明 + +1. 点击Call按钮依据预先设定的参数(如 SM4 算法、PIN认证等)生成密钥。 + +## 细粒度用户身份认证访问控制开发指导 + +### 介绍 + +1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-refined-user-identity-authentication.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。 + +#### FineGrainedUserIdentityAuthentication + +##### 介绍 + +1. 本示例主要介绍细粒度用户身份认证访问控制,允许设置密钥在加密、解密、签名、验签、密钥协商、密钥派生的单个或多个场景时是否需要进行身份验证。 + +##### 效果预览 + +| 主页 | 跳转页 | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| | | + +使用说明 + +1. 点击Call 按钮生成一个基于 SM4 算法、支持PIN认证且在解密时需身份验证的密钥。 + +## 工程目录 + +``` +entry/src/main/ +|---ets +|---|---entryability +|---|---|---EntryAbility.ets +|---|---pages +|---|---|---Index.ets // 首页 +|---|---|---FineGrainedUserIdentityAuthentication.ets +|---|---|---UserIdentityAuthentication.ets +|---cpp +|---resources // 静态资源 +|---ohosTest +|---|---ets +|---|---|---tests +|---|---|---|---AccessControl.test.ets // 自动化测试用例 +``` + +## 相关权限 + +[ohos.permission.ACCESS_BIOMETRIC](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionaccessbiometric) + +## 依赖 + +不涉及。 + +## 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:RK3568。 +2. 本示例支持API14版本SDK,SDK版本号(API Version 14 Release)。 +3. 本示例需要使用DevEco Studio 版本号(5.0.1Release)才可编译运行。 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl > .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/Security/UniversalKeystoreKit/KeyUsage/AccessControl/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/build-profile.json5 old mode 100755 new mode 100644 index d903787c46..7acbde12b1 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/code-linter.json5 old mode 100755 new mode 100644 index 9deb980763..28586467ee --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/code-linter.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/code-linter.json5 @@ -1,35 +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. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/.gitignore old mode 100755 new mode 100644 index 32abf8fd5e..e2713a2779 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/.gitignore +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/.gitignore @@ -1,6 +1,6 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx +/node_modules +/oh_modules +/.preview +/build +/.cxx /.test \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/build-profile.json5 old mode 100755 new mode 100644 index b4d65d490e..e7569e3056 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/build-profile.json5 @@ -1,43 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/hvigorfile.ts old mode 100755 new mode 100644 index 46872af922..e4f43d5466 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/hvigorfile.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/hvigorfile.ts @@ -1,21 +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. */ -} +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/oh-package.json5 old mode 100755 new mode 100644 index 4bf3e2a9b1..c9cb6c8174 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/oh-package.json5 @@ -1,25 +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": {} -} - +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets old mode 100755 new mode 100644 index 3655291796..be90c53357 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets @@ -1,444 +1,444 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start generate_key_specify_fingerprint_access_control_and_auth_purpose] -import { huks } from '@kit.UniversalKeystoreKit'; -import { userAuth } from '@kit.UserAuthenticationKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - - -let cipherInData = 'Hks_SM4_Cipher_Test_101010101010101010110_string'; // 明文数据。 -let IV = '1234567890123456'; -let handle = 0; -let cipherText: Uint8Array; // 密文数据。 -let finishOutData: Uint8Array; // 解密后的明文数据。 -let authToken: Uint8Array; -let challenge: Uint8Array; -let authType = userAuth.UserAuthType.PIN; -let authTrustLevel = userAuth.AuthTrustLevel.ATL1; - -let keyAlias = 'test_sm4_key_alias'; -class ThrowObject { - public isThrow: boolean = false; -} - -function stringToUint8Array(str: string) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -/* - * 确定封装密钥属性参数集 - */ -let generateProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM4, - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, - }, - { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }, - { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD - }, - { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - } -]; - -let generateHuksOptions: huks.HuksOptions = { - properties: generateProperties, - inData: new Uint8Array([]) -} - -/* - * 生成密钥 - */ -async function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise generateKeyItem`); - let throwObject: ThrowObject = { isThrow: true }; - try { - await generateKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: generateKeyItem failed` + JSON.stringify(error)); - } - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid` + JSON.stringify(error)); - throw (error as Error); - } -} - -async function testGenKeyForFingerprintAccessControl() { - await publicGenKeyFunc(keyAlias, generateHuksOptions); -} -// [End generate_key_specify_fingerprint_access_control_and_auth_purpose] -class HuksProperties { - public tag: huks.HuksTag = huks.HuksTag.HUKS_TAG_ALGORITHM; - public value: huks.HuksKeyAlg | huks.HuksKeySize | huks.HuksKeyPurpose | huks.HuksKeyPadding | huks.HuksCipherMode - | Uint8Array = huks.HuksKeyAlg.HUKS_ALG_ECC; -} - -/* - * 确定封装密钥属性参数集 - */ - -/* 集成生成密钥参数集 & 加密参数集 */ -let propertiesEncrypt: HuksProperties[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM4, - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }, - { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }, - { - tag: huks.HuksTag.HUKS_TAG_IV, - value: stringToUint8Array(IV), - } -]; -let encryptOptions: huks.HuksOptions = { - properties: propertiesEncrypt, - inData: new Uint8Array([]) -} - -function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.initSession(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise doInit`); - let throwObject: ThrowObject = { isThrow: true }; - try { - await initSession(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - handle = data.handle as number; - challenge = data.challenge as Uint8Array; - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doInit failed` + JSON.stringify(error)); - } - }); - } catch (error) { - console.error(`promise: doInit input arg invalid` + JSON.stringify(error)); - throw (error as Error); - } -} - -function finishEncryptSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.finishSession(handle, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicEncryptFinishFunc(handle: number, huksOptions: huks.HuksOptions) { - console.info(`enter promise doFinish`); - let throwObject: ThrowObject = { isThrow: true }; - try { - await finishEncryptSession(handle, huksOptions, throwObject) - .then((data) => { - cipherText = data.outData as Uint8Array; - console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doFinish failed` + JSON.stringify(error)); - } - }); - } catch (error) { - console.error(`promise: doFinish input arg invalid` + JSON.stringify(error)); - throw (error as Error); - } -} - -async function testSm4Cipher() { - /* 初始化密钥会话获取挑战值 */ - await publicInitFunc(keyAlias, encryptOptions); - /* 加密 */ - encryptOptions.inData = stringToUint8Array(cipherInData); - await publicEncryptFinishFunc(handle, encryptOptions); -} - -/* 集成生成密钥参数集 & 加密参数集 */ -class PropertyDecryptType { - public tag: huks.HuksTag = huks.HuksTag.HUKS_TAG_ALGORITHM - public value: huks.HuksKeyAlg | huks.HuksKeyPurpose | huks.HuksKeySize | huks.HuksKeyPadding | huks.HuksCipherMode - | Uint8Array = huks.HuksKeyAlg.HUKS_ALG_SM4 -} - -let propertiesDecrypt: PropertyDecryptType[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM4, - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }, - { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }, - { - tag: huks.HuksTag.HUKS_TAG_IV, - value: stringToUint8Array(IV), - } -] -let decryptOptions: huks.HuksOptions = { - properties: propertiesDecrypt, - inData: new Uint8Array([]) -} - -function userIAMAuthFinger(huksChallenge: Uint8Array) { - // 获取认证对象。 - let authTypeList: userAuth.UserAuthType[] = [authType]; - const authParam: userAuth.AuthParam = { - challenge: huksChallenge, - authType: authTypeList, - authTrustLevel: authTrustLevel - }; - const widgetParam: userAuth.WidgetParam = { - title: 'PIN', - }; - let auth: userAuth.UserAuthInstance; - try { - auth = userAuth.getUserAuthInstance(authParam, widgetParam); - console.info('get auth instance success'); - } catch (error) { - console.error('get auth instance failed' + JSON.stringify(error)); - throw (error as Error); - } - // 订阅认证结果。 - try { - auth.on('result', { - onResult(result) { - console.info('[HUKS] -> [IAM] userAuthInstance callback result = ' + JSON.stringify(result)); - authToken = result.token; - testSm4CipherFinish(); - } - }); - console.info('subscribe authentication event success'); - } catch (error) { - console.error('subscribe authentication event failed ' + JSON.stringify(error)); - throw (error as Error); - } - // 开始认证。 - try { - auth.start(); - console.info('authV9 start auth success'); - } catch (error) { - console.error('authV9 start auth failed, error = ' + JSON.stringify(error)); - throw (error as Error); - } -} - -function finishDecryptSession(handle: number, huksOptions: huks.HuksOptions, token: Uint8Array, - throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.finishSession(handle, huksOptions, token, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicDecryptFinishFunc(handle: number, token: Uint8Array, huksOptions: huks.HuksOptions) { - console.info(`enter promise doFinish`); - let throwObject: ThrowObject = { isThrow: true }; - try { - await finishDecryptSession(handle, huksOptions, token, throwObject) - .then((data) => { - finishOutData = data.outData as Uint8Array; - console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); - }) - .catch((error: BusinessError) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doFinish failed` + JSON.stringify(error)); - } - }); - } catch (error) { - console.error(`promise: doFinish input arg invalid` + JSON.stringify(error)); - throw (error as Error); - } -} - -async function testSm4CipherInit() { - /* 初始化密钥会话获取挑战值 */ - await publicInitFunc(keyAlias, decryptOptions); - /* 调用userIAM进行身份认证 */ - console.log('challenge value: ' + challenge.toString()); - userIAMAuthFinger(challenge); -} - -async function testSm4CipherFinish() { - /* 认证成功后进行解密, 需要传入Auth获取到的authToken值 */ - decryptOptions.inData = cipherText; - await publicDecryptFinishFunc(handle, authToken, decryptOptions); - if (finishOutData === stringToUint8Array(cipherInData)) { - console.error('test finish decrypt error'); - } else { - console.info('test finish decrypt success'); - } -} - -async function main() { - await testGenKeyForFingerprintAccessControl(); - await testSm4Cipher(); - await testSm4CipherInit(); -} - -@Entry -@Component -struct Index { - @State message: string = 'FineGrainedUserIdentityAuthentication'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.fine_grained_user_identity_authentication_call')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await main(); - this.message = 'Call Result: Success'; - } catch (error) { - this.message = 'Call Result: Failed' + error.message; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start generate_key_specify_fingerprint_access_control_and_auth_purpose] +import { huks } from '@kit.UniversalKeystoreKit'; +import { userAuth } from '@kit.UserAuthenticationKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + + +let cipherInData = 'Hks_SM4_Cipher_Test_101010101010101010110_string'; // 明文数据。 +let IV = '1234567890123456'; +let handle = 0; +let cipherText: Uint8Array; // 密文数据。 +let finishOutData: Uint8Array; // 解密后的明文数据。 +let authToken: Uint8Array; +let challenge: Uint8Array; +let authType = userAuth.UserAuthType.PIN; +let authTrustLevel = userAuth.AuthTrustLevel.ATL1; + +let keyAlias = 'test_sm4_key_alias'; +class ThrowObject { + public isThrow: boolean = false; +} + +function stringToUint8Array(str: string) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +/* + * 确定封装密钥属性参数集 + */ +let generateProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM4, + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, + }, + { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC, + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE, + }, + { + tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, + value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, + value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD + }, + { + tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, + value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + } +]; + +let generateHuksOptions: huks.HuksOptions = { + properties: generateProperties, + inData: new Uint8Array([]) +} + +/* + * 生成密钥 + */ +async function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise generateKeyItem`); + let throwObject: ThrowObject = { isThrow: true }; + try { + await generateKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: generateKeyItem failed` + JSON.stringify(error)); + } + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid` + JSON.stringify(error)); + throw (error as Error); + } +} + +async function testGenKeyForFingerprintAccessControl() { + await publicGenKeyFunc(keyAlias, generateHuksOptions); +} +// [End generate_key_specify_fingerprint_access_control_and_auth_purpose] +class HuksProperties { + public tag: huks.HuksTag = huks.HuksTag.HUKS_TAG_ALGORITHM; + public value: huks.HuksKeyAlg | huks.HuksKeySize | huks.HuksKeyPurpose | huks.HuksKeyPadding | huks.HuksCipherMode + | Uint8Array = huks.HuksKeyAlg.HUKS_ALG_ECC; +} + +/* + * 确定封装密钥属性参数集 + */ + +/* 集成生成密钥参数集 & 加密参数集 */ +let propertiesEncrypt: HuksProperties[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM4, + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE, + }, + { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC, + }, + { + tag: huks.HuksTag.HUKS_TAG_IV, + value: stringToUint8Array(IV), + } +]; +let encryptOptions: huks.HuksOptions = { + properties: propertiesEncrypt, + inData: new Uint8Array([]) +} + +function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.initSession(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise doInit`); + let throwObject: ThrowObject = { isThrow: true }; + try { + await initSession(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle as number; + challenge = data.challenge as Uint8Array; + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doInit failed` + JSON.stringify(error)); + } + }); + } catch (error) { + console.error(`promise: doInit input arg invalid` + JSON.stringify(error)); + throw (error as Error); + } +} + +function finishEncryptSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicEncryptFinishFunc(handle: number, huksOptions: huks.HuksOptions) { + console.info(`enter promise doFinish`); + let throwObject: ThrowObject = { isThrow: true }; + try { + await finishEncryptSession(handle, huksOptions, throwObject) + .then((data) => { + cipherText = data.outData as Uint8Array; + console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doFinish failed` + JSON.stringify(error)); + } + }); + } catch (error) { + console.error(`promise: doFinish input arg invalid` + JSON.stringify(error)); + throw (error as Error); + } +} + +async function testSm4Cipher() { + /* 初始化密钥会话获取挑战值 */ + await publicInitFunc(keyAlias, encryptOptions); + /* 加密 */ + encryptOptions.inData = stringToUint8Array(cipherInData); + await publicEncryptFinishFunc(handle, encryptOptions); +} + +/* 集成生成密钥参数集 & 加密参数集 */ +class PropertyDecryptType { + public tag: huks.HuksTag = huks.HuksTag.HUKS_TAG_ALGORITHM + public value: huks.HuksKeyAlg | huks.HuksKeyPurpose | huks.HuksKeySize | huks.HuksKeyPadding | huks.HuksCipherMode + | Uint8Array = huks.HuksKeyAlg.HUKS_ALG_SM4 +} + +let propertiesDecrypt: PropertyDecryptType[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM4, + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE, + }, + { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC, + }, + { + tag: huks.HuksTag.HUKS_TAG_IV, + value: stringToUint8Array(IV), + } +] +let decryptOptions: huks.HuksOptions = { + properties: propertiesDecrypt, + inData: new Uint8Array([]) +} + +function userIAMAuthFinger(huksChallenge: Uint8Array) { + // 获取认证对象。 + let authTypeList: userAuth.UserAuthType[] = [authType]; + const authParam: userAuth.AuthParam = { + challenge: huksChallenge, + authType: authTypeList, + authTrustLevel: authTrustLevel + }; + const widgetParam: userAuth.WidgetParam = { + title: 'PIN', + }; + let auth: userAuth.UserAuthInstance; + try { + auth = userAuth.getUserAuthInstance(authParam, widgetParam); + console.info('get auth instance success'); + } catch (error) { + console.error('get auth instance failed' + JSON.stringify(error)); + throw (error as Error); + } + // 订阅认证结果。 + try { + auth.on('result', { + onResult(result) { + console.info('[HUKS] -> [IAM] userAuthInstance callback result = ' + JSON.stringify(result)); + authToken = result.token; + testSm4CipherFinish(); + } + }); + console.info('subscribe authentication event success'); + } catch (error) { + console.error('subscribe authentication event failed ' + JSON.stringify(error)); + throw (error as Error); + } + // 开始认证。 + try { + auth.start(); + console.info('authV9 start auth success'); + } catch (error) { + console.error('authV9 start auth failed, error = ' + JSON.stringify(error)); + throw (error as Error); + } +} + +function finishDecryptSession(handle: number, huksOptions: huks.HuksOptions, token: Uint8Array, + throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, token, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicDecryptFinishFunc(handle: number, token: Uint8Array, huksOptions: huks.HuksOptions) { + console.info(`enter promise doFinish`); + let throwObject: ThrowObject = { isThrow: true }; + try { + await finishDecryptSession(handle, huksOptions, token, throwObject) + .then((data) => { + finishOutData = data.outData as Uint8Array; + console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch((error: BusinessError) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doFinish failed` + JSON.stringify(error)); + } + }); + } catch (error) { + console.error(`promise: doFinish input arg invalid` + JSON.stringify(error)); + throw (error as Error); + } +} + +async function testSm4CipherInit() { + /* 初始化密钥会话获取挑战值 */ + await publicInitFunc(keyAlias, decryptOptions); + /* 调用userIAM进行身份认证 */ + console.log('challenge value: ' + challenge.toString()); + userIAMAuthFinger(challenge); +} + +async function testSm4CipherFinish() { + /* 认证成功后进行解密, 需要传入Auth获取到的authToken值 */ + decryptOptions.inData = cipherText; + await publicDecryptFinishFunc(handle, authToken, decryptOptions); + if (finishOutData === stringToUint8Array(cipherInData)) { + console.error('test finish decrypt error'); + } else { + console.info('test finish decrypt success'); + } +} + +async function main() { + await testGenKeyForFingerprintAccessControl(); + await testSm4Cipher(); + await testSm4CipherInit(); +} + +@Entry +@Component +struct Index { + @State message: string = 'FineGrainedUserIdentityAuthentication'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.fine_grained_user_identity_authentication_call')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await main(); + this.message = 'Call Result: Success'; + } catch (error) { + this.message = 'Call Result: Failed' + error.message; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index c09773e820..e012e25431 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/Index.ets @@ -1,67 +1,67 @@ -/* - * 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 { router } from '@kit.ArkUI'; - -@Entry -@Component -struct Index { - @State message: string = 'AccessControl'; - - goToSample(url: string): void { - router.pushUrl({ - url: url, - }, router.RouterMode.Single, (err) => { - if (err) { - console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); - return; - } - console.info('pushUrl success'); - }) - } - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button('UserIdentityAuthentication') - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - this.goToSample('pages/UserIdentityAuthentication'); - }) - Button('FineGrainedUserIdentityAuthentication') - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - this.goToSample('pages/FineGrainedUserIdentityAuthentication'); - }) - } - .height('100%') - .width('100%') - } -} +/* + * 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 { router } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + @State message: string = 'AccessControl'; + + goToSample(url: string): void { + router.pushUrl({ + url: url, + }, router.RouterMode.Single, (err) => { + if (err) { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('pushUrl success'); + }) + } + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button('UserIdentityAuthentication') + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + this.goToSample('pages/UserIdentityAuthentication'); + }) + Button('FineGrainedUserIdentityAuthentication') + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + this.goToSample('pages/FineGrainedUserIdentityAuthentication'); + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets old mode 100755 new mode 100644 index 20d5968174..225d1590aa --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets @@ -1,417 +1,417 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// [Start user_authentication_and_access_control_guide] -import { huks } from '@kit.UniversalKeystoreKit'; -import { userAuth } from '@kit.UserAuthenticationKit'; - -/* -* 确定密钥别名和封装密钥属性参数集 -*/ -let keyAlias = 'test_sm4_key_alias'; -let IV = '1234567890123456'; -let handle: number; -let challenge: Uint8Array; -let fingerAuthToken: Uint8Array; -let authType = userAuth.UserAuthType.PIN; -let authTrustLevel = userAuth.AuthTrustLevel.ATL1; -let cipherInData = 'Hks_SM4_Cipher_Test_101010101010101010110_string'; -let finishOutData: Uint8Array; - -class ThrowObject { - public isThrow: boolean = false; -} - -let generateProperties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM4 -}, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT -}, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, -}, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, -}, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, -}, - // 指定密钥身份认证的类型:PIN。 - { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN - }, - // 指定密钥安全授权的类型(失效类型):新录入生物特征(PIN)后无效。 - { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD - }, - // 指定挑战值的类型:默认类型。 - { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL - }]; - -let generateHuksOptions: huks.HuksOptions = { - properties: generateProperties, - inData: new Uint8Array([]) -} - -/* - * 生成密钥 - */ - -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise generateKeyItem`); - let throwObject: ThrowObject = { isThrow: true }; - try { - await generateKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - console.error(`promise: generateKeyItem failed, ` + JSON.stringify(error)); - throw (error as Error); - } else { - } - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ` + JSON.stringify(error)); - throw (error as Error); - } -} - -async function testGenKeyForFingerprintAccessControl() { - await publicGenKeyFunc(keyAlias, generateHuksOptions); -} - -/* 集成生成密钥参数集 & 加密参数集 */ -let initProperties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM4, -}, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, -}, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, -}, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, -}, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, -}, { - tag: huks.HuksTag.HUKS_TAG_IV, - value: stringToUint8Array(IV), -}]; - -let initHuksOptions: huks.HuksOptions = { - properties: initProperties, - inData: new Uint8Array([]) -} - -function stringToUint8Array(str: string) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.initSession(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -/* 初始化HUKS中的会话,获取挑战值 */ -async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise doInit`); - let throwObject: ThrowObject = { isThrow: true }; - try { - await initSession(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - handle = data.handle; - challenge = data.challenge as Uint8Array; - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doInit failed, ` + JSON.stringify(error)); - } - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, ` + JSON.stringify(error)); - throw (error as Error); - } -} - -/* 调用UserIAM拉起认证,触发HUKS的访问控制流程 */ -function userIAMAuthFinger(huksChallenge: Uint8Array) { - // 获取认证对象。 - let authTypeList: userAuth.UserAuthType[] = [authType]; - const authParam: userAuth.AuthParam = { - challenge: huksChallenge, - authType: authTypeList, - authTrustLevel: authTrustLevel - }; - const widgetParam: userAuth.WidgetParam = { - title: 'PIN', - }; - let auth: userAuth.UserAuthInstance; - try { - auth = userAuth.getUserAuthInstance(authParam, widgetParam); - console.info('get auth instance success'); - } catch (error) { - console.error('get auth instance failed' + JSON.stringify(error)); - throw (error as Error); - } - // 订阅认证结果。 - try { - auth.on('result', { - onResult(result) { - console.info('[HUKS] -> [IAM] userAuthInstance callback result = ' + JSON.stringify(result)); - fingerAuthToken = result.token; - testSm4Cipher(); - } - }); - console.log('subscribe authentication event success'); - } catch (error) { - console.error('subscribe authentication event failed, ' + JSON.stringify(error)); - throw (error as Error); - } - // 开始认证。 - try { - auth.start(); - console.info('authV9 start auth success'); - } catch (error) { - console.error('authV9 start auth failed, error = ' + JSON.stringify(error)); - throw (error as Error); - } -} - -async function testInitAndAuthFinger() { - /* 初始化密钥会话获取挑战值 */ - await publicInitFunc(keyAlias, initHuksOptions); - /* 调用userIAM进行身份认证 */ - console.log('challenge value: ' + challenge.toString()); - userIAMAuthFinger(challenge); -} - -/* 集成生成密钥参数集 & 加密参数集 */ -class PropertyEncryptType { - public tag: huks.HuksTag = huks.HuksTag.HUKS_TAG_ALGORITHM; - public value: huks.HuksKeyAlg | huks.HuksKeyPurpose | huks.HuksKeySize | huks.HuksKeyPadding | huks.HuksCipherMode - | Uint8Array = huks.HuksKeyAlg.HUKS_ALG_SM4; -} - -let propertiesEncrypt: PropertyEncryptType[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM4, - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, - }, - { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }, - { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }, - { - tag: huks.HuksTag.HUKS_TAG_IV, - value: stringToUint8Array(IV), - } -] -let encryptOptions: huks.HuksOptions = { - properties: propertiesEncrypt, - inData: new Uint8Array([]) -} - -function updateSession(handle: number, huksOptions: huks.HuksOptions, token: Uint8Array, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.updateSession(handle, huksOptions, token, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicUpdateFunc(handle: number, token: Uint8Array, huksOptions: huks.HuksOptions) { - console.info(`enter promise doUpdate`); - let throwObject: ThrowObject = { isThrow: true }; - console.log('token value[publicUpdateFunc]:' + token) - try { - await updateSession(handle, huksOptions, token, throwObject) - .then((data) => { - console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doUpdate failed, ` + JSON.stringify(error)); - } - }); - } catch (error) { - console.error(`promise: doUpdate input arg invalid, ` + JSON.stringify(error)); - throw (error as Error); - } -} - -function finishSession(handle: number, huksOptions: huks.HuksOptions, token: Uint8Array, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.finishSession(handle, huksOptions, token, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicFinishFunc(handle: number, token: Uint8Array, huksOptions: huks.HuksOptions) { - console.info(`enter promise doFinish`); - let throwObject: ThrowObject = { isThrow: false }; - console.log('token value[publicFinishFunc]:' + token) - try { - await finishSession(handle, huksOptions, token, throwObject) - .then((data) => { - finishOutData = data.outData as Uint8Array; - console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doFinish failed, ` + JSON.stringify(error)); - } - }); - } catch (error) { - console.error(`promise: doFinish input arg invalid, ` + JSON.stringify(error)); - throw (error as Error); - } -} - -async function testSm4Cipher() { - encryptOptions.inData = stringToUint8Array(cipherInData); - /* 传入认证令牌 */ - await publicUpdateFunc(handle, fingerAuthToken, encryptOptions); - /* 传入认证令牌 */ - console.log('continue publicFinishFunc'); - await publicFinishFunc(handle, fingerAuthToken, encryptOptions); - console.log('end publicFinishFunc'); - if (finishOutData === stringToUint8Array(cipherInData)) { - console.error('test finish encrypt error'); - } else { - console.info('test finish encrypt success'); - } -} -// [End user_authentication_and_access_control_guide] -async function main() { - await testGenKeyForFingerprintAccessControl(); - await testInitAndAuthFinger(); -} - -@Entry -@Component -struct Index { - @State message: string = 'UserIdentityAuthentication'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.user_identity_authentication')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await main(); - this.message = 'Call Result: Success'; - } catch (error) { - this.message = 'Call Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start user_authentication_and_access_control_guide] +import { huks } from '@kit.UniversalKeystoreKit'; +import { userAuth } from '@kit.UserAuthenticationKit'; + +/* +* 确定密钥别名和封装密钥属性参数集 +*/ +let keyAlias = 'test_sm4_key_alias'; +let IV = '1234567890123456'; +let handle: number; +let challenge: Uint8Array; +let fingerAuthToken: Uint8Array; +let authType = userAuth.UserAuthType.PIN; +let authTrustLevel = userAuth.AuthTrustLevel.ATL1; +let cipherInData = 'Hks_SM4_Cipher_Test_101010101010101010110_string'; +let finishOutData: Uint8Array; + +class ThrowObject { + public isThrow: boolean = false; +} + +let generateProperties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM4 +}, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT +}, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, +}, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC, +}, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE, +}, + // 指定密钥身份认证的类型:PIN。 + { + tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, + value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN + }, + // 指定密钥安全授权的类型(失效类型):新录入生物特征(PIN)后无效。 + { + tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, + value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD + }, + // 指定挑战值的类型:默认类型。 + { + tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, + value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL + }]; + +let generateHuksOptions: huks.HuksOptions = { + properties: generateProperties, + inData: new Uint8Array([]) +} + +/* + * 生成密钥 + */ + +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise generateKeyItem`); + let throwObject: ThrowObject = { isThrow: true }; + try { + await generateKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + console.error(`promise: generateKeyItem failed, ` + JSON.stringify(error)); + throw (error as Error); + } else { + } + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ` + JSON.stringify(error)); + throw (error as Error); + } +} + +async function testGenKeyForFingerprintAccessControl() { + await publicGenKeyFunc(keyAlias, generateHuksOptions); +} + +/* 集成生成密钥参数集 & 加密参数集 */ +let initProperties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM4, +}, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, +}, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, +}, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC, +}, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE, +}, { + tag: huks.HuksTag.HUKS_TAG_IV, + value: stringToUint8Array(IV), +}]; + +let initHuksOptions: huks.HuksOptions = { + properties: initProperties, + inData: new Uint8Array([]) +} + +function stringToUint8Array(str: string) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.initSession(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +/* 初始化HUKS中的会话,获取挑战值 */ +async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise doInit`); + let throwObject: ThrowObject = { isThrow: true }; + try { + await initSession(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + challenge = data.challenge as Uint8Array; + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doInit failed, ` + JSON.stringify(error)); + } + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, ` + JSON.stringify(error)); + throw (error as Error); + } +} + +/* 调用UserIAM拉起认证,触发HUKS的访问控制流程 */ +function userIAMAuthFinger(huksChallenge: Uint8Array) { + // 获取认证对象。 + let authTypeList: userAuth.UserAuthType[] = [authType]; + const authParam: userAuth.AuthParam = { + challenge: huksChallenge, + authType: authTypeList, + authTrustLevel: authTrustLevel + }; + const widgetParam: userAuth.WidgetParam = { + title: 'PIN', + }; + let auth: userAuth.UserAuthInstance; + try { + auth = userAuth.getUserAuthInstance(authParam, widgetParam); + console.info('get auth instance success'); + } catch (error) { + console.error('get auth instance failed' + JSON.stringify(error)); + throw (error as Error); + } + // 订阅认证结果。 + try { + auth.on('result', { + onResult(result) { + console.info('[HUKS] -> [IAM] userAuthInstance callback result = ' + JSON.stringify(result)); + fingerAuthToken = result.token; + testSm4Cipher(); + } + }); + console.log('subscribe authentication event success'); + } catch (error) { + console.error('subscribe authentication event failed, ' + JSON.stringify(error)); + throw (error as Error); + } + // 开始认证。 + try { + auth.start(); + console.info('authV9 start auth success'); + } catch (error) { + console.error('authV9 start auth failed, error = ' + JSON.stringify(error)); + throw (error as Error); + } +} + +async function testInitAndAuthFinger() { + /* 初始化密钥会话获取挑战值 */ + await publicInitFunc(keyAlias, initHuksOptions); + /* 调用userIAM进行身份认证 */ + console.log('challenge value: ' + challenge.toString()); + userIAMAuthFinger(challenge); +} + +/* 集成生成密钥参数集 & 加密参数集 */ +class PropertyEncryptType { + public tag: huks.HuksTag = huks.HuksTag.HUKS_TAG_ALGORITHM; + public value: huks.HuksKeyAlg | huks.HuksKeyPurpose | huks.HuksKeySize | huks.HuksKeyPadding | huks.HuksCipherMode + | Uint8Array = huks.HuksKeyAlg.HUKS_ALG_SM4; +} + +let propertiesEncrypt: PropertyEncryptType[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM4, + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, + }, + { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE, + }, + { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC, + }, + { + tag: huks.HuksTag.HUKS_TAG_IV, + value: stringToUint8Array(IV), + } +] +let encryptOptions: huks.HuksOptions = { + properties: propertiesEncrypt, + inData: new Uint8Array([]) +} + +function updateSession(handle: number, huksOptions: huks.HuksOptions, token: Uint8Array, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.updateSession(handle, huksOptions, token, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicUpdateFunc(handle: number, token: Uint8Array, huksOptions: huks.HuksOptions) { + console.info(`enter promise doUpdate`); + let throwObject: ThrowObject = { isThrow: true }; + console.log('token value[publicUpdateFunc]:' + token) + try { + await updateSession(handle, huksOptions, token, throwObject) + .then((data) => { + console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doUpdate failed, ` + JSON.stringify(error)); + } + }); + } catch (error) { + console.error(`promise: doUpdate input arg invalid, ` + JSON.stringify(error)); + throw (error as Error); + } +} + +function finishSession(handle: number, huksOptions: huks.HuksOptions, token: Uint8Array, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, token, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicFinishFunc(handle: number, token: Uint8Array, huksOptions: huks.HuksOptions) { + console.info(`enter promise doFinish`); + let throwObject: ThrowObject = { isThrow: false }; + console.log('token value[publicFinishFunc]:' + token) + try { + await finishSession(handle, huksOptions, token, throwObject) + .then((data) => { + finishOutData = data.outData as Uint8Array; + console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doFinish failed, ` + JSON.stringify(error)); + } + }); + } catch (error) { + console.error(`promise: doFinish input arg invalid, ` + JSON.stringify(error)); + throw (error as Error); + } +} + +async function testSm4Cipher() { + encryptOptions.inData = stringToUint8Array(cipherInData); + /* 传入认证令牌 */ + await publicUpdateFunc(handle, fingerAuthToken, encryptOptions); + /* 传入认证令牌 */ + console.log('continue publicFinishFunc'); + await publicFinishFunc(handle, fingerAuthToken, encryptOptions); + console.log('end publicFinishFunc'); + if (finishOutData === stringToUint8Array(cipherInData)) { + console.error('test finish encrypt error'); + } else { + console.info('test finish encrypt success'); + } +} +// [End user_authentication_and_access_control_guide] +async function main() { + await testGenKeyForFingerprintAccessControl(); + await testInitAndAuthFinger(); +} + +@Entry +@Component +struct Index { + @State message: string = 'UserIdentityAuthentication'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.user_identity_authentication')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await main(); + this.message = 'Call Result: Success'; + } catch (error) { + this.message = 'Call Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/module.json5 old mode 100755 new mode 100644 index c16511ef42..9a475d7e2c --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.ACCESS_BIOMETRIC" - } - ] - } +/* + * 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" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.ACCESS_BIOMETRIC" + } + ] + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/float.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/float.json old mode 100755 new mode 100644 index 5f0600c708..a0a93dd91f --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/float.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/float.json @@ -1,8 +1,8 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index 24b1814c51..dd4d93181a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/string.json @@ -1,24 +1,24 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "AccessControl" - }, - { - "name": "fine_grained_user_identity_authentication_call", - "value": "Call" - }, - { - "name": "user_identity_authentication", - "value": "Call" - } - ] -} +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "AccessControl" + }, + { + "name": "fine_grained_user_identity_authentication_call", + "value": "Call" + }, + { + "name": "user_identity_authentication", + "value": "Call" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 index 16cf3219a2..fb49920440 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/layered_image.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/layered_image.json @@ -1,7 +1,7 @@ -{ - "layered-image": - { - "background" : "$media:background", - "foreground" : "$media:foreground" - } +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 107bdba988..49a1be3eb9 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/main_pages.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/main_pages.json @@ -1,7 +1,7 @@ -{ - "src": [ - "pages/Index", - "pages/FineGrainedUserIdentityAuthentication", - "pages/UserIdentityAuthentication" - ] +{ + "src": [ + "pages/Index", + "pages/FineGrainedUserIdentityAuthentication", + "pages/UserIdentityAuthentication" + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 index 9d4f8a434d..0f8ce9a2c0 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - // Defines a test suite. Two parameters are supported: test suite name and test suite function. - beforeAll(() => { - // Presets an action, which is performed only once before all test cases of the test suite start. - // This API supports only one parameter: preset action function. - }) - beforeEach(() => { - // Presets an action, which is performed before each unit test case starts. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: preset action function. - }) - afterEach(() => { - // Presets a clear action, which is performed after each unit test case ends. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: clear action function. - }) - afterAll(() => { - // Presets a clear action, which is performed after all test cases of the test suite end. - // This API supports only one parameter: clear action function. - }) - it('assertContain', 0, () => { - // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. - hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); - let a = 'abc'; - let b = 'b'; - // Defines a variety of assertion methods, which are used to declare expected boolean conditions. - expect(a).assertContain(b); - expect(a).assertEqual(a); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/AccessControl.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/AccessControl.test.ets old mode 100755 new mode 100644 index fd70984c80..55cf08dbcd --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/AccessControl.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/AccessControl.test.ets @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function accessControlTest() { - describe('accessControlTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,用户身份认证访问控制 - */ - it('testAccessControl001', 0, async () => { - console.info('uitest: testAccessControl001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('UserIdentityAuthentication')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(5000); - const button2 = await driver.findComponent(ON.text('Call')); - await button2.click(); - await driver.delayMs(10000); - await driver.assertComponentExist(ON.text('Call Result: Success')); - console.info('uitest: testAccessControl001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,细粒度用户身份认证访问控制 - */ - it('testAccessControl002', 0, async () => { - console.info('uitest: testAccessControl002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('FineGrainedUserIdentityAuthentication')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call')); - await button2.click(); - await driver.delayMs(10000); - await driver.assertComponentExist(ON.text('Call Result: Success')); - console.info('uitest: testAccessControl002 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function accessControlTest() { + describe('accessControlTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,用户身份认证访问控制 + */ + it('testAccessControl001', 0, async () => { + console.info('uitest: testAccessControl001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('UserIdentityAuthentication')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(5000); + const button2 = await driver.findComponent(ON.text('Call')); + await button2.click(); + await driver.delayMs(10000); + await driver.assertComponentExist(ON.text('Call Result: Success')); + console.info('uitest: testAccessControl001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,细粒度用户身份认证访问控制 + */ + it('testAccessControl002', 0, async () => { + console.info('uitest: testAccessControl002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('FineGrainedUserIdentityAuthentication')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call')); + await button2.click(); + await driver.delayMs(10000); + await driver.assertComponentExist(ON.text('Call Result: Success')); + console.info('uitest: testAccessControl002 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 index 628014e135..d923f98577 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/List.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/List.test.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import accessControlTest from './AccessControl.test'; - -export default function testsuite() { - accessControlTest(); -} +/* + * 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 accessControlTest from './AccessControl.test'; + +export default function testsuite() { + accessControlTest(); +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyUsage/AccessControl/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/hvigorfile.ts old mode 100755 new mode 100644 index 2db60fa918..2a5e543f19 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/hvigorfile.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/hvigorfile.ts @@ -1,21 +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. */ -} +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/AccessControl/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/ohosTest.md old mode 100755 new mode 100644 index 0333efcb58..c32f4adb8f --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/ohosTest.md @@ -1,9 +1,9 @@ -# 访问控制测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------- | ------------ | ---- | ---------------- | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮, 用户身份认证访问控制 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | +# 访问控制测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------- | ------------ | ---- | ---------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮, 用户身份认证访问控制 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | | 点击按钮, 细粒度用户身份认证访问控制 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/app.json5 old mode 100755 new mode 100644 index 50a8887628..ad9bc7f08a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/app.json5 @@ -1,25 +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.encryptiondecryption", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.encryptiondecryption", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index ba04620cde..3e3fade237 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "EncryptionDecryption" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "EncryptionDecryption" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index ab0e49ba07..870045a54a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(EncryptionDecryption) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(EncryptionDecryption) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index e66ddc43e9..c4f84a6bc7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp @@ -1,229 +1,229 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start encrypt_and_decrypt] -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include - -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} - -static const uint32_t IV_SIZE = 16; -static uint8_t IV[IV_SIZE] = {0}; // this is a test value, for real use the iv should be different every time -static struct OH_Huks_Param g_genEncDecParams[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT | OH_HUKS_KEY_PURPOSE_DECRYPT}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, - {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}}; - -static struct OH_Huks_Param g_encryptParams[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, - {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}, - {.tag = OH_HUKS_TAG_IV, - .blob = { - .size = IV_SIZE, - .data = (uint8_t *)IV // this is a test value, for real use the iv should be different every time - }}}; - -static struct OH_Huks_Param g_decryptParams[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DECRYPT}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, - {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}, - {.tag = OH_HUKS_TAG_IV, - .blob = { - .size = IV_SIZE, - .data = (uint8_t *)IV // this is a test value, for real use the iv should be different every time - }}}; - -static const uint32_t AES_COMMON_SIZE = 1024; -OH_Huks_Result HksAesCipherTestEncrypt(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *encryptParamSet, - const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *cipherText) -{ - uint8_t handleE[sizeof(uint64_t)] = {0}; - struct OH_Huks_Blob handleEncrypt = {sizeof(uint64_t), handleE}; - OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, encryptParamSet, &handleEncrypt, nullptr); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_FinishSession(&handleEncrypt, encryptParamSet, inData, cipherText); - return ret; -} - -OH_Huks_Result HksAesCipherTestDecrypt(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *decryptParamSet, - const struct OH_Huks_Blob *cipherText, struct OH_Huks_Blob *plainText, - const struct OH_Huks_Blob *inData) -{ - uint8_t handleD[sizeof(uint64_t)] = {0}; - struct OH_Huks_Blob handleDecrypt = {sizeof(uint64_t), handleD}; - OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, decryptParamSet, &handleDecrypt, nullptr); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_FinishSession(&handleDecrypt, decryptParamSet, cipherText, plainText); - return ret; -} - -static napi_value EncDecKey(napi_env env, napi_callback_info info) -{ - char tmpKeyAlias[] = "test_enc_dec"; - struct OH_Huks_Blob keyAlias = {(uint32_t)strlen(tmpKeyAlias), (uint8_t *)tmpKeyAlias}; - struct OH_Huks_ParamSet *genParamSet = nullptr; - struct OH_Huks_ParamSet *encryptParamSet = nullptr; - struct OH_Huks_ParamSet *decryptParamSet = nullptr; - OH_Huks_Result ohResult; - do { - /* 1. Generate Key */ - /* - * 模拟生成密钥场景 - * 1.1. 确定密钥别名 - */ - /* - * 1.2. 获取生成密钥算法参数配置 - */ - ohResult = InitParamSet(&genParamSet, g_genEncDecParams, sizeof(g_genEncDecParams) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* - * 1.3. 调用generateKeyItem - */ - ohResult = OH_Huks_GenerateKeyItem(&keyAlias, genParamSet, nullptr); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 2. Encrypt */ - /* - * 模拟加密场景 - * 2.1. 获取密钥别名 - */ - /* - * 2.2. 获取待加密的数据 - */ - /* - * 2.3. 获取加密算法参数配置 - */ - ohResult = InitParamSet(&encryptParamSet, g_encryptParams, sizeof(g_encryptParams) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - char tmpInData[] = "AES_ECB_INDATA_1"; - struct OH_Huks_Blob inData = {(uint32_t)strlen(tmpInData), (uint8_t *)tmpInData}; - uint8_t cipher[AES_COMMON_SIZE] = {0}; - struct OH_Huks_Blob cipherText = {AES_COMMON_SIZE, cipher}; - /* - * 2.4. 调用initSession获取handle - */ - /* - * 2.5. 调用finishSession获取加密后的密文 - */ - ohResult = HksAesCipherTestEncrypt(&keyAlias, encryptParamSet, &inData, &cipherText); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 3. Decrypt */ - /* - * 模拟解密场景 - * 3.1. 获取密钥别名 - */ - /* - * 3.2. 获取待解密的密文 - */ - /* - * 3.3. 获取解密算法参数配置 - */ - ohResult = InitParamSet(&decryptParamSet, g_decryptParams, sizeof(g_decryptParams) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - uint8_t plain[AES_COMMON_SIZE] = {0}; - struct OH_Huks_Blob plainText = {AES_COMMON_SIZE, plain}; - /* - * 3.4. 调用initSession获取handle - */ - /* - * 3.5. 调用finishSession获取解密后的数据 - */ - ohResult = HksAesCipherTestDecrypt(&keyAlias, decryptParamSet, &cipherText, &plainText, &inData); - } while (0); - /* 4. Delete Key */ - /* - * 模拟删除密钥场景 - * 4.1. 获取密钥别名 - */ - /* - * 4.2. 调用deleteKeyItem删除密钥 - */ - (void)OH_Huks_DeleteKeyItem(&keyAlias, genParamSet); - - OH_Huks_FreeParamSet(&genParamSet); - OH_Huks_FreeParamSet(&encryptParamSet); - OH_Huks_FreeParamSet(&decryptParamSet); - - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} - - -// [End encrypt_and_decrypt] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"encDecKey", nullptr, EncDecKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start encrypt_and_decrypt] +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include + +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} + +static const uint32_t IV_SIZE = 16; +static uint8_t IV[IV_SIZE] = {0}; // this is a test value, for real use the iv should be different every time +static struct OH_Huks_Param g_genEncDecParams[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT | OH_HUKS_KEY_PURPOSE_DECRYPT}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, + {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}}; + +static struct OH_Huks_Param g_encryptParams[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, + {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}, + {.tag = OH_HUKS_TAG_IV, + .blob = { + .size = IV_SIZE, + .data = (uint8_t *)IV // this is a test value, for real use the iv should be different every time + }}}; + +static struct OH_Huks_Param g_decryptParams[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DECRYPT}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, + {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}, + {.tag = OH_HUKS_TAG_IV, + .blob = { + .size = IV_SIZE, + .data = (uint8_t *)IV // this is a test value, for real use the iv should be different every time + }}}; + +static const uint32_t AES_COMMON_SIZE = 1024; +OH_Huks_Result HksAesCipherTestEncrypt(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *encryptParamSet, + const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *cipherText) +{ + uint8_t handleE[sizeof(uint64_t)] = {0}; + struct OH_Huks_Blob handleEncrypt = {sizeof(uint64_t), handleE}; + OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, encryptParamSet, &handleEncrypt, nullptr); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_FinishSession(&handleEncrypt, encryptParamSet, inData, cipherText); + return ret; +} + +OH_Huks_Result HksAesCipherTestDecrypt(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *decryptParamSet, + const struct OH_Huks_Blob *cipherText, struct OH_Huks_Blob *plainText, + const struct OH_Huks_Blob *inData) +{ + uint8_t handleD[sizeof(uint64_t)] = {0}; + struct OH_Huks_Blob handleDecrypt = {sizeof(uint64_t), handleD}; + OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, decryptParamSet, &handleDecrypt, nullptr); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_FinishSession(&handleDecrypt, decryptParamSet, cipherText, plainText); + return ret; +} + +static napi_value EncDecKey(napi_env env, napi_callback_info info) +{ + char tmpKeyAlias[] = "test_enc_dec"; + struct OH_Huks_Blob keyAlias = {(uint32_t)strlen(tmpKeyAlias), (uint8_t *)tmpKeyAlias}; + struct OH_Huks_ParamSet *genParamSet = nullptr; + struct OH_Huks_ParamSet *encryptParamSet = nullptr; + struct OH_Huks_ParamSet *decryptParamSet = nullptr; + OH_Huks_Result ohResult; + do { + /* 1. Generate Key */ + /* + * 模拟生成密钥场景 + * 1.1. 确定密钥别名 + */ + /* + * 1.2. 获取生成密钥算法参数配置 + */ + ohResult = InitParamSet(&genParamSet, g_genEncDecParams, sizeof(g_genEncDecParams) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* + * 1.3. 调用generateKeyItem + */ + ohResult = OH_Huks_GenerateKeyItem(&keyAlias, genParamSet, nullptr); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 2. Encrypt */ + /* + * 模拟加密场景 + * 2.1. 获取密钥别名 + */ + /* + * 2.2. 获取待加密的数据 + */ + /* + * 2.3. 获取加密算法参数配置 + */ + ohResult = InitParamSet(&encryptParamSet, g_encryptParams, sizeof(g_encryptParams) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + char tmpInData[] = "AES_ECB_INDATA_1"; + struct OH_Huks_Blob inData = {(uint32_t)strlen(tmpInData), (uint8_t *)tmpInData}; + uint8_t cipher[AES_COMMON_SIZE] = {0}; + struct OH_Huks_Blob cipherText = {AES_COMMON_SIZE, cipher}; + /* + * 2.4. 调用initSession获取handle + */ + /* + * 2.5. 调用finishSession获取加密后的密文 + */ + ohResult = HksAesCipherTestEncrypt(&keyAlias, encryptParamSet, &inData, &cipherText); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 3. Decrypt */ + /* + * 模拟解密场景 + * 3.1. 获取密钥别名 + */ + /* + * 3.2. 获取待解密的密文 + */ + /* + * 3.3. 获取解密算法参数配置 + */ + ohResult = InitParamSet(&decryptParamSet, g_decryptParams, sizeof(g_decryptParams) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + uint8_t plain[AES_COMMON_SIZE] = {0}; + struct OH_Huks_Blob plainText = {AES_COMMON_SIZE, plain}; + /* + * 3.4. 调用initSession获取handle + */ + /* + * 3.5. 调用finishSession获取解密后的数据 + */ + ohResult = HksAesCipherTestDecrypt(&keyAlias, decryptParamSet, &cipherText, &plainText, &inData); + } while (0); + /* 4. Delete Key */ + /* + * 模拟删除密钥场景 + * 4.1. 获取密钥别名 + */ + /* + * 4.2. 调用deleteKeyItem删除密钥 + */ + (void)OH_Huks_DeleteKeyItem(&keyAlias, genParamSet); + + OH_Huks_FreeParamSet(&genParamSet); + OH_Huks_FreeParamSet(&encryptParamSet); + OH_Huks_FreeParamSet(&decryptParamSet); + + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} + + +// [End encrypt_and_decrypt] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"encDecKey", nullptr, EncDecKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index a042918612..49fa4d09e1 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 encDecKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets old mode 100755 new mode 100644 index 38277bacb2..9d0ac6f768 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets @@ -1,264 +1,264 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start encrypt_and_decrypt_AESCBCPKCS7] -/* - * 以下以AES/CBC/PKCS7的Promise操作使用为例 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -let aesKeyAlias = 'test_aesKeyAlias'; -let handle: number; -let plainText = '123456'; -let IV = '001122334455'; -let cipherData: Uint8Array; - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function uint8ArrayToString(fileData: Uint8Array) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - -function getAesGenerateProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }]; - return properties; -} - -function getAesEncryptProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PKCS7 - }, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC - }, { - tag: huks.HuksTag.HUKS_TAG_IV, - value: stringToUint8Array(IV) - }]; - return properties; -} - -function getAesDecryptProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PKCS7 - }, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC - }, { - tag: huks.HuksTag.HUKS_TAG_IV, - value: stringToUint8Array(IV) - }]; - return properties; -} - -async function generateAesKey() { - /* - * 模拟生成密钥场景 - * 1. 确定密钥别名 - */ - /* - * 2. 获取生成密钥算法参数配置 - */ - let genProperties = getAesGenerateProperties(); - let options: huks.HuksOptions = { - properties: genProperties - } - /* - * 3. 调用generateKeyItem - */ - await huks.generateKeyItem(aesKeyAlias, options) - .then((data) => { - console.info(`promise: generate AES Key success, data = ${JSON.stringify(data)}`); - }).catch((error: Error) => { - console.error(`promise: generate AES Key failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function encryptData() { - /* - * 模拟加密场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待加密的数据 - */ - /* - * 3. 获取加密算法参数配置 - */ - let encryptProperties = getAesEncryptProperties(); - let options: huks.HuksOptions = { - properties: encryptProperties, - inData: stringToUint8Array(plainText) - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(aesKeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init EncryptData failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取加密后的密文 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - cipherData = data.outData as Uint8Array; - }).catch((error: Error) => { - console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function decryptData() { - /* - * 模拟解密场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待解密的密文 - */ - /* - * 3. 获取解密算法参数配置 - */ - let decryptOptions = getAesDecryptProperties() - let options: huks.HuksOptions = { - properties: decryptOptions, - inData: cipherData - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(aesKeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init DecryptData failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取解密后的数据 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((error: Error) => { - console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function deleteKey() { - /* - * 模拟删除密钥场景 - * 1. 获取密钥别名 - */ - let emptyOptions: huks.HuksOptions = { - properties: [] - } - /* - * 2. 调用deleteKeyItem删除密钥 - */ - await huks.deleteKeyItem(aesKeyAlias, emptyOptions) - .then((data) => { - console.info(`promise: delete data success`); - }).catch((error: Error) => { - console.error(`promise: delete data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - - -// [End encrypt_and_decrypt_AESCBCPKCS7] - - -@Entry -@Component -struct Index { - @State message: string = 'AES/CBC/PKCS7'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.aes_cbc_pkcs7')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await generateAesKey(); - await encryptData(); - await decryptData(); - await deleteKey(); - this.message = 'AES/CBC/PKCS7 Result: Success'; - } catch { - this.message = 'AES/CBC/PKCS7 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start encrypt_and_decrypt_AESCBCPKCS7] +/* + * 以下以AES/CBC/PKCS7的Promise操作使用为例 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +let aesKeyAlias = 'test_aesKeyAlias'; +let handle: number; +let plainText = '123456'; +let IV = '001122334455'; +let cipherData: Uint8Array; + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function uint8ArrayToString(fileData: Uint8Array) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + +function getAesGenerateProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }]; + return properties; +} + +function getAesEncryptProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PKCS7 + }, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC + }, { + tag: huks.HuksTag.HUKS_TAG_IV, + value: stringToUint8Array(IV) + }]; + return properties; +} + +function getAesDecryptProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PKCS7 + }, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC + }, { + tag: huks.HuksTag.HUKS_TAG_IV, + value: stringToUint8Array(IV) + }]; + return properties; +} + +async function generateAesKey() { + /* + * 模拟生成密钥场景 + * 1. 确定密钥别名 + */ + /* + * 2. 获取生成密钥算法参数配置 + */ + let genProperties = getAesGenerateProperties(); + let options: huks.HuksOptions = { + properties: genProperties + } + /* + * 3. 调用generateKeyItem + */ + await huks.generateKeyItem(aesKeyAlias, options) + .then((data) => { + console.info(`promise: generate AES Key success, data = ${JSON.stringify(data)}`); + }).catch((error: Error) => { + console.error(`promise: generate AES Key failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function encryptData() { + /* + * 模拟加密场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待加密的数据 + */ + /* + * 3. 获取加密算法参数配置 + */ + let encryptProperties = getAesEncryptProperties(); + let options: huks.HuksOptions = { + properties: encryptProperties, + inData: stringToUint8Array(plainText) + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(aesKeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init EncryptData failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取加密后的密文 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + cipherData = data.outData as Uint8Array; + }).catch((error: Error) => { + console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function decryptData() { + /* + * 模拟解密场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待解密的密文 + */ + /* + * 3. 获取解密算法参数配置 + */ + let decryptOptions = getAesDecryptProperties() + let options: huks.HuksOptions = { + properties: decryptOptions, + inData: cipherData + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(aesKeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init DecryptData failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取解密后的数据 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((error: Error) => { + console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function deleteKey() { + /* + * 模拟删除密钥场景 + * 1. 获取密钥别名 + */ + let emptyOptions: huks.HuksOptions = { + properties: [] + } + /* + * 2. 调用deleteKeyItem删除密钥 + */ + await huks.deleteKeyItem(aesKeyAlias, emptyOptions) + .then((data) => { + console.info(`promise: delete data success`); + }).catch((error: Error) => { + console.error(`promise: delete data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + + +// [End encrypt_and_decrypt_AESCBCPKCS7] + + +@Entry +@Component +struct Index { + @State message: string = 'AES/CBC/PKCS7'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.aes_cbc_pkcs7')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await generateAesKey(); + await encryptData(); + await decryptData(); + await deleteKey(); + this.message = 'AES/CBC/PKCS7 Result: Success'; + } catch { + this.message = 'AES/CBC/PKCS7 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets old mode 100755 new mode 100644 index dd8ba3875c..ea053a5c6d --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets @@ -1,272 +1,272 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start encrypt_and_decrypt_AESGCMNoPadding] -/* - * 以下以AES/GCM/NoPadding的Promise操作使用为例 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -let aesKeyAlias = 'test_aesKeyAlias'; -let handle: number; -let plainText = '123456'; -let cipherData: Uint8Array; -let AAD = '1234567890123456'; -let NONCE = '001122334455'; - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function uint8ArrayToString(fileData: Uint8Array) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - -function getAesGenerateProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }]; - return properties; -} - -function getAesGcmEncryptProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_GCM - }, { - tag: huks.HuksTag.HUKS_TAG_NONCE, - value: stringToUint8Array(NONCE) - }, { - tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA, - value: stringToUint8Array(AAD) - }]; - return properties; -} - -function getAesGcmDecryptProperties(cipherData: Uint8Array) { - let properties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_GCM - }, { - tag: huks.HuksTag.HUKS_TAG_NONCE, - value: stringToUint8Array(NONCE) - }, { - tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA, - value: stringToUint8Array(AAD) - }, { - tag: huks.HuksTag.HUKS_TAG_AE_TAG, - value: cipherData.slice(cipherData.length - 16) - }]; - return properties; -} - -async function generateAesKey() { - /* - * 模拟生成密钥场景 - * 1. 确定密钥别名 - */ - /* - * 2. 获取生成密钥算法参数配置 - */ - let genProperties = getAesGenerateProperties(); - let options: huks.HuksOptions = { - properties: genProperties - } - /* - * 3. 调用generateKeyItem - */ - await huks.generateKeyItem(aesKeyAlias, options) - .then((data) => { - console.info(`promise: generate AES Key success, data = ${JSON.stringify(data)}`); - }).catch((error: Error) => { - console.error(`promise: generate AES Key failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function encryptData() { - /* - * 模拟加密场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待加密的数据 - */ - /* - * 3. 获取加密算法参数配置 - */ - let encryptProperties = getAesGcmEncryptProperties(); - let options: huks.HuksOptions = { - properties: encryptProperties, - inData: stringToUint8Array(plainText) - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(aesKeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init EncryptDataGcm failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取加密后的密文 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - cipherData = data.outData as Uint8Array; - }).catch((error: Error) => { - console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function decryptData() { - /* - * 模拟解密场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待解密的密文 - */ - /* - * 3. 获取解密算法参数配置 - */ - let decryptOptions = getAesGcmDecryptProperties(cipherData) - let options: huks.HuksOptions = { - properties: decryptOptions, - inData: cipherData.slice(0, cipherData.length - 16) - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(aesKeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init DecryptDataGcm failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取解密后的数据 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((error: Error) => { - console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function deleteKey() { - /* - * 模拟删除密钥场景 - * 1. 获取密钥别名 - */ - let emptyOptions: huks.HuksOptions = { - properties: [] - } - /* - * 2. 调用deleteKeyItem删除密钥 - */ - await huks.deleteKeyItem(aesKeyAlias, emptyOptions) - .then((data) => { - console.info(`promise: delete data success`); - }).catch((error: Error) => { - console.error(`promise: delete data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -// [End encrypt_and_decrypt_AESGCMNoPadding] -@Entry -@Component -struct Index { - @State message: string = 'AES/GCM/NoPadding'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.aes_gcm_nopadding')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await generateAesKey(); - await encryptData(); - await decryptData(); - await deleteKey(); - this.message = 'AES/GCM/NoPadding Result: Success'; - } catch { - this.message = 'AES/GCM/NoPadding Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start encrypt_and_decrypt_AESGCMNoPadding] +/* + * 以下以AES/GCM/NoPadding的Promise操作使用为例 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +let aesKeyAlias = 'test_aesKeyAlias'; +let handle: number; +let plainText = '123456'; +let cipherData: Uint8Array; +let AAD = '1234567890123456'; +let NONCE = '001122334455'; + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function uint8ArrayToString(fileData: Uint8Array) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + +function getAesGenerateProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }]; + return properties; +} + +function getAesGcmEncryptProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE + }, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_GCM + }, { + tag: huks.HuksTag.HUKS_TAG_NONCE, + value: stringToUint8Array(NONCE) + }, { + tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA, + value: stringToUint8Array(AAD) + }]; + return properties; +} + +function getAesGcmDecryptProperties(cipherData: Uint8Array) { + let properties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE + }, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_GCM + }, { + tag: huks.HuksTag.HUKS_TAG_NONCE, + value: stringToUint8Array(NONCE) + }, { + tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA, + value: stringToUint8Array(AAD) + }, { + tag: huks.HuksTag.HUKS_TAG_AE_TAG, + value: cipherData.slice(cipherData.length - 16) + }]; + return properties; +} + +async function generateAesKey() { + /* + * 模拟生成密钥场景 + * 1. 确定密钥别名 + */ + /* + * 2. 获取生成密钥算法参数配置 + */ + let genProperties = getAesGenerateProperties(); + let options: huks.HuksOptions = { + properties: genProperties + } + /* + * 3. 调用generateKeyItem + */ + await huks.generateKeyItem(aesKeyAlias, options) + .then((data) => { + console.info(`promise: generate AES Key success, data = ${JSON.stringify(data)}`); + }).catch((error: Error) => { + console.error(`promise: generate AES Key failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function encryptData() { + /* + * 模拟加密场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待加密的数据 + */ + /* + * 3. 获取加密算法参数配置 + */ + let encryptProperties = getAesGcmEncryptProperties(); + let options: huks.HuksOptions = { + properties: encryptProperties, + inData: stringToUint8Array(plainText) + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(aesKeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init EncryptDataGcm failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取加密后的密文 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + cipherData = data.outData as Uint8Array; + }).catch((error: Error) => { + console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function decryptData() { + /* + * 模拟解密场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待解密的密文 + */ + /* + * 3. 获取解密算法参数配置 + */ + let decryptOptions = getAesGcmDecryptProperties(cipherData) + let options: huks.HuksOptions = { + properties: decryptOptions, + inData: cipherData.slice(0, cipherData.length - 16) + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(aesKeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init DecryptDataGcm failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取解密后的数据 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((error: Error) => { + console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function deleteKey() { + /* + * 模拟删除密钥场景 + * 1. 获取密钥别名 + */ + let emptyOptions: huks.HuksOptions = { + properties: [] + } + /* + * 2. 调用deleteKeyItem删除密钥 + */ + await huks.deleteKeyItem(aesKeyAlias, emptyOptions) + .then((data) => { + console.info(`promise: delete data success`); + }).catch((error: Error) => { + console.error(`promise: delete data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +// [End encrypt_and_decrypt_AESGCMNoPadding] +@Entry +@Component +struct Index { + @State message: string = 'AES/GCM/NoPadding'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.aes_gcm_nopadding')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await generateAesKey(); + await encryptData(); + await decryptData(); + await deleteKey(); + this.message = 'AES/GCM/NoPadding Result: Success'; + } catch { + this.message = 'AES/GCM/NoPadding Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets old mode 100755 new mode 100644 index 644000a154..7945f06ccb --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets @@ -1,261 +1,261 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start encrypt_and_decrypt_RSAECBOAEPSHA256] -/* - * 以下以RSA/ECB/OAEP/SHA256模式的Promise操作使用为例 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -let rsaKeyAlias = 'test_rsaKeyAlias'; -let handle: number; -let plainText = '123456'; -let cipherData: Uint8Array; - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function uint8ArrayToString(fileData: Uint8Array) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - -function getRsaGenerateProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }]; - return properties; -} - -function getRsaEncryptProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_OAEP - }, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }]; - return properties; -} - -function getRsaDecryptProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_OAEP - }, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }]; - return properties; -} - -async function generateRsaKey() { - /* - * 模拟生成密钥场景 - * 1. 确定密钥别名 - */ - /* - * 2. 获取生成密钥算法参数配置 - */ - let genProperties = getRsaGenerateProperties(); - let options: huks.HuksOptions = { - properties: genProperties - } - /* - * 3. 调用generateKeyItem - */ - await huks.generateKeyItem(rsaKeyAlias, options) - .then((data) => { - console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`); - }).catch((error: Error) => { - console.error(`promise: generate RSA Key failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function encryptData() { - /* - * 模拟加密场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待加密的数据 - */ - /* - * 3. 获取加密算法参数配置 - */ - let encryptProperties = getRsaEncryptProperties(); - let options: huks.HuksOptions = { - properties: encryptProperties, - inData: stringToUint8Array(plainText) - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(rsaKeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init EncryptDataRsa failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取加密后的密文 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - cipherData = data.outData as Uint8Array; - }).catch((error: Error) => { - console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function decryptData() { - /* - * 模拟解密场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待解密的密文 - */ - /* - * 3. 获取解密算法参数配置 - */ - let decryptOptions = getRsaDecryptProperties() - let options: huks.HuksOptions = { - properties: decryptOptions, - inData: cipherData - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(rsaKeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init DecryptDataRsa failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取解密后的数据 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((error: Error) => { - console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function deleteKey() { - /* - * 模拟删除密钥场景 - * 1. 获取密钥别名 - */ - let emptyOptions: huks.HuksOptions = { - properties: [] - } - /* - * 2. 调用deleteKeyItem删除密钥 - */ - await huks.deleteKeyItem(rsaKeyAlias, emptyOptions) - .then((data) => { - console.info(`promise: delete data success`); - }).catch((error: Error) => { - console.error(`promise: delete data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - - -// [End encrypt_and_decrypt_RSAECBOAEPSHA256] -@Entry -@Component -struct Index { - @State message: string = 'RSA/ECB/OAEP/SHA256'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.rsa_ecb_oaep_sha256')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await generateRsaKey(); - await encryptData(); - await decryptData(); - await deleteKey(); - this.message = 'RSA/ECB/OAEP/SHA256 Result: Success'; - } catch { - this.message = 'RSA/ECB/OAEP/SHA256 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start encrypt_and_decrypt_RSAECBOAEPSHA256] +/* + * 以下以RSA/ECB/OAEP/SHA256模式的Promise操作使用为例 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +let rsaKeyAlias = 'test_rsaKeyAlias'; +let handle: number; +let plainText = '123456'; +let cipherData: Uint8Array; + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function uint8ArrayToString(fileData: Uint8Array) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + +function getRsaGenerateProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }]; + return properties; +} + +function getRsaEncryptProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_OAEP + }, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }]; + return properties; +} + +function getRsaDecryptProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_OAEP + }, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }]; + return properties; +} + +async function generateRsaKey() { + /* + * 模拟生成密钥场景 + * 1. 确定密钥别名 + */ + /* + * 2. 获取生成密钥算法参数配置 + */ + let genProperties = getRsaGenerateProperties(); + let options: huks.HuksOptions = { + properties: genProperties + } + /* + * 3. 调用generateKeyItem + */ + await huks.generateKeyItem(rsaKeyAlias, options) + .then((data) => { + console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`); + }).catch((error: Error) => { + console.error(`promise: generate RSA Key failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function encryptData() { + /* + * 模拟加密场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待加密的数据 + */ + /* + * 3. 获取加密算法参数配置 + */ + let encryptProperties = getRsaEncryptProperties(); + let options: huks.HuksOptions = { + properties: encryptProperties, + inData: stringToUint8Array(plainText) + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(rsaKeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init EncryptDataRsa failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取加密后的密文 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + cipherData = data.outData as Uint8Array; + }).catch((error: Error) => { + console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function decryptData() { + /* + * 模拟解密场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待解密的密文 + */ + /* + * 3. 获取解密算法参数配置 + */ + let decryptOptions = getRsaDecryptProperties() + let options: huks.HuksOptions = { + properties: decryptOptions, + inData: cipherData + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(rsaKeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init DecryptDataRsa failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取解密后的数据 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((error: Error) => { + console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function deleteKey() { + /* + * 模拟删除密钥场景 + * 1. 获取密钥别名 + */ + let emptyOptions: huks.HuksOptions = { + properties: [] + } + /* + * 2. 调用deleteKeyItem删除密钥 + */ + await huks.deleteKeyItem(rsaKeyAlias, emptyOptions) + .then((data) => { + console.info(`promise: delete data success`); + }).catch((error: Error) => { + console.error(`promise: delete data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + + +// [End encrypt_and_decrypt_RSAECBOAEPSHA256] +@Entry +@Component +struct Index { + @State message: string = 'RSA/ECB/OAEP/SHA256'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.rsa_ecb_oaep_sha256')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await generateRsaKey(); + await encryptData(); + await decryptData(); + await deleteKey(); + this.message = 'RSA/ECB/OAEP/SHA256 Result: Success'; + } catch { + this.message = 'RSA/ECB/OAEP/SHA256 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets old mode 100755 new mode 100644 index f071b9b884..ebb254d422 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets @@ -1,262 +1,262 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start encrypt_and_decrypt_RSAECBPKCS1_V1_5] -/* - * 以下以RSA/ECB/PKCS1_V1_5模式的Promise操作使用为例 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -let rsaKeyAlias = 'test_rsaKeyAlias'; -let handle: number; -let plainText = '123456'; -let cipherData: Uint8Array; - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function uint8ArrayToString(fileData: Uint8Array) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - -function getRsaGenerateProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }]; - return properties; -} - -function getRsaEncryptProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 - }, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE - }]; - return properties; -} - -function getRsaDecryptProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 - }, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE - }]; - return properties; -} - -async function generateRsaKey() { - /* - * 模拟生成密钥场景 - * 1. 确定密钥别名 - */ - /* - * 2. 获取生成密钥算法参数配置 - */ - let genProperties = getRsaGenerateProperties(); - let options: huks.HuksOptions = { - properties: genProperties - } - /* - * 3. 调用generateKeyItem - */ - await huks.generateKeyItem(rsaKeyAlias, options) - .then((data) => { - console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`); - }).catch((error: Error) => { - console.error(`promise: generate RSA Key failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function encryptData() { - /* - * 模拟加密场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待加密的数据 - */ - /* - * 3. 获取加密算法参数配置 - */ - let encryptProperties = getRsaEncryptProperties(); - let options: huks.HuksOptions = { - properties: encryptProperties, - inData: stringToUint8Array(plainText) - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(rsaKeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init EncryptDataRsa failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取加密后的密文 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - cipherData = data.outData as Uint8Array; - }).catch((error: Error) => { - console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function decryptData() { - /* - * 模拟解密场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待解密的密文 - */ - /* - * 3. 获取解密算法参数配置 - */ - let decryptOptions = getRsaDecryptProperties() - let options: huks.HuksOptions = { - properties: decryptOptions, - inData: cipherData - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(rsaKeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init DecryptDataRsa failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取解密后的数据 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((error: Error) => { - console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function deleteKey() { - /* - * 模拟删除密钥场景 - * 1. 获取密钥别名 - */ - let emptyOptions: huks.HuksOptions = { - properties: [] - } - /* - * 2. 调用deleteKeyItem删除密钥 - */ - await huks.deleteKeyItem(rsaKeyAlias, emptyOptions) - .then((data) => { - console.info(`promise: delete data success`); - }).catch((error: Error) => { - console.error(`promise: delete data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - - - -// [End encrypt_and_decrypt_RSAECBPKCS1_V1_5] -@Entry -@Component -struct Index { - @State message: string = 'RSA/ECB/PKCS1_V1_5'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.rsa_ecb_pkcs1_v1_5')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await generateRsaKey(); - await encryptData(); - await decryptData(); - let ret = await deleteKey(); - this.message = 'RSA/ECB/PKCS1_V1_5 Result: Success'; - } catch { - this.message = 'RSA/ECB/PKCS1_V1_5 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start encrypt_and_decrypt_RSAECBPKCS1_V1_5] +/* + * 以下以RSA/ECB/PKCS1_V1_5模式的Promise操作使用为例 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +let rsaKeyAlias = 'test_rsaKeyAlias'; +let handle: number; +let plainText = '123456'; +let cipherData: Uint8Array; + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function uint8ArrayToString(fileData: Uint8Array) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + +function getRsaGenerateProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }]; + return properties; +} + +function getRsaEncryptProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 + }, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE + }]; + return properties; +} + +function getRsaDecryptProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 + }, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE + }]; + return properties; +} + +async function generateRsaKey() { + /* + * 模拟生成密钥场景 + * 1. 确定密钥别名 + */ + /* + * 2. 获取生成密钥算法参数配置 + */ + let genProperties = getRsaGenerateProperties(); + let options: huks.HuksOptions = { + properties: genProperties + } + /* + * 3. 调用generateKeyItem + */ + await huks.generateKeyItem(rsaKeyAlias, options) + .then((data) => { + console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`); + }).catch((error: Error) => { + console.error(`promise: generate RSA Key failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function encryptData() { + /* + * 模拟加密场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待加密的数据 + */ + /* + * 3. 获取加密算法参数配置 + */ + let encryptProperties = getRsaEncryptProperties(); + let options: huks.HuksOptions = { + properties: encryptProperties, + inData: stringToUint8Array(plainText) + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(rsaKeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init EncryptDataRsa failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取加密后的密文 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + cipherData = data.outData as Uint8Array; + }).catch((error: Error) => { + console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function decryptData() { + /* + * 模拟解密场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待解密的密文 + */ + /* + * 3. 获取解密算法参数配置 + */ + let decryptOptions = getRsaDecryptProperties() + let options: huks.HuksOptions = { + properties: decryptOptions, + inData: cipherData + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(rsaKeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init DecryptDataRsa failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取解密后的数据 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((error: Error) => { + console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function deleteKey() { + /* + * 模拟删除密钥场景 + * 1. 获取密钥别名 + */ + let emptyOptions: huks.HuksOptions = { + properties: [] + } + /* + * 2. 调用deleteKeyItem删除密钥 + */ + await huks.deleteKeyItem(rsaKeyAlias, emptyOptions) + .then((data) => { + console.info(`promise: delete data success`); + }).catch((error: Error) => { + console.error(`promise: delete data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + + + +// [End encrypt_and_decrypt_RSAECBPKCS1_V1_5] +@Entry +@Component +struct Index { + @State message: string = 'RSA/ECB/PKCS1_V1_5'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.rsa_ecb_pkcs1_v1_5')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await generateRsaKey(); + await encryptData(); + await decryptData(); + let ret = await deleteKey(); + this.message = 'RSA/ECB/PKCS1_V1_5 Result: Success'; + } catch { + this.message = 'RSA/ECB/PKCS1_V1_5 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets old mode 100755 new mode 100644 index c4db56bcd4..22aa278636 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets @@ -1,250 +1,250 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start encrypt_and_decrypt_SM2] -/* - * 以下以SM2模式的Promise操作使用为例 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -let sm2KeyAlias = 'test_sm2KeyAlias'; -let handle: number; -let plainText = '123456'; -let cipherData: Uint8Array; - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function uint8ArrayToString(fileData: Uint8Array) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - -function getSm2GenerateProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM2 - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }]; - return properties; -} - -function getSm2EncryptProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM2 - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SM3 - }]; - return properties; -} - -function getSm2DecryptProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM2 - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SM3 - }]; - return properties; -} - -async function generateSm2Key() { - /* - * 模拟生成密钥场景 - * 1. 确定密钥别名 - */ - /* - * 2. 获取生成密钥算法参数配置 - */ - let genProperties = getSm2GenerateProperties(); - let options: huks.HuksOptions = { - properties: genProperties - } - /* - * 3. 调用generateKeyItem - */ - await huks.generateKeyItem(sm2KeyAlias, options) - .then((data) => { - console.info(`promise: generate SM2 Key success, data = ${JSON.stringify(data)}`); - }).catch((error: Error) => { - console.error(`promise: generate SM2 Key failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function encryptDataSm2() { - /* - * 模拟加密场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待加密的数据 - */ - /* - * 3. 获取加密算法参数配置 - */ - let encryptProperties = getSm2EncryptProperties(); - let options: huks.HuksOptions = { - properties: encryptProperties, - inData: stringToUint8Array(plainText) - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(sm2KeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init EncryptDataSm2 failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取加密后的密文 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - cipherData = data.outData as Uint8Array; - }).catch((error: Error) => { - console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function decryptDataSm2() { - /* - * 模拟解密场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待解密的密文 - */ - /* - * 3. 获取解密算法参数配置 - */ - let decryptOptions = getSm2DecryptProperties() - let options: huks.HuksOptions = { - properties: decryptOptions, - inData: cipherData - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(sm2KeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init DecryptDataSm2 failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取解密后的数据 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((error: Error) => { - console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function deleteKey() { - /* - * 模拟删除密钥场景 - * 1. 获取密钥别名 - */ - let emptyOptions: huks.HuksOptions = { - properties: [] - } - /* - * 2. 调用deleteKeyItem删除密钥 - */ - await huks.deleteKeyItem(sm2KeyAlias, emptyOptions) - .then((data) => { - console.info(`promise: delete data success`); - }).catch((error: Error) => { - console.error(`promise: delete data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - - -// [End encrypt_and_decrypt_SM2] - -@Entry -@Component -struct Index { - @State message: string = 'SM2'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.sm2')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await generateSm2Key(); - await encryptDataSm2(); - await decryptDataSm2(); - await deleteKey(); - this.message = 'SM2 Result: Success'; - } catch { - this.message = 'SM2 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start encrypt_and_decrypt_SM2] +/* + * 以下以SM2模式的Promise操作使用为例 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +let sm2KeyAlias = 'test_sm2KeyAlias'; +let handle: number; +let plainText = '123456'; +let cipherData: Uint8Array; + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function uint8ArrayToString(fileData: Uint8Array) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + +function getSm2GenerateProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM2 + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }]; + return properties; +} + +function getSm2EncryptProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM2 + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SM3 + }]; + return properties; +} + +function getSm2DecryptProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM2 + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SM3 + }]; + return properties; +} + +async function generateSm2Key() { + /* + * 模拟生成密钥场景 + * 1. 确定密钥别名 + */ + /* + * 2. 获取生成密钥算法参数配置 + */ + let genProperties = getSm2GenerateProperties(); + let options: huks.HuksOptions = { + properties: genProperties + } + /* + * 3. 调用generateKeyItem + */ + await huks.generateKeyItem(sm2KeyAlias, options) + .then((data) => { + console.info(`promise: generate SM2 Key success, data = ${JSON.stringify(data)}`); + }).catch((error: Error) => { + console.error(`promise: generate SM2 Key failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function encryptDataSm2() { + /* + * 模拟加密场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待加密的数据 + */ + /* + * 3. 获取加密算法参数配置 + */ + let encryptProperties = getSm2EncryptProperties(); + let options: huks.HuksOptions = { + properties: encryptProperties, + inData: stringToUint8Array(plainText) + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(sm2KeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init EncryptDataSm2 failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取加密后的密文 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + cipherData = data.outData as Uint8Array; + }).catch((error: Error) => { + console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function decryptDataSm2() { + /* + * 模拟解密场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待解密的密文 + */ + /* + * 3. 获取解密算法参数配置 + */ + let decryptOptions = getSm2DecryptProperties() + let options: huks.HuksOptions = { + properties: decryptOptions, + inData: cipherData + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(sm2KeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init DecryptDataSm2 failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取解密后的数据 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((error: Error) => { + console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function deleteKey() { + /* + * 模拟删除密钥场景 + * 1. 获取密钥别名 + */ + let emptyOptions: huks.HuksOptions = { + properties: [] + } + /* + * 2. 调用deleteKeyItem删除密钥 + */ + await huks.deleteKeyItem(sm2KeyAlias, emptyOptions) + .then((data) => { + console.info(`promise: delete data success`); + }).catch((error: Error) => { + console.error(`promise: delete data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + + +// [End encrypt_and_decrypt_SM2] + +@Entry +@Component +struct Index { + @State message: string = 'SM2'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.sm2')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await generateSm2Key(); + await encryptDataSm2(); + await decryptDataSm2(); + await deleteKey(); + this.message = 'SM2 Result: Success'; + } catch { + this.message = 'SM2 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/EncryptionDecryption.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/EncryptionDecryption.test.ets old mode 100755 new mode 100644 index d908a11e70..75208b5792 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/EncryptionDecryption.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/EncryptionDecryption.test.ets @@ -1,149 +1,149 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function encryptionDecryptionTest() { - describe('encryptionDecryptionTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,加解密AES/CBC/PKCS7 - */ - it('testEncryptionDecryption001', 0, async () => { - console.info('uitest: testEncryptionDecryption001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('AES/CBC/PKCS7')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES/CBC/PKCS7')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES/CBC/PKCS7 Result: Success')); - console.info('uitest: testEncryptionDecryption001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,加解密AES/GCM/NoPadding - */ - it('testEncryptionDecryption002', 0, async () => { - console.info('uitest: testEncryptionDecryption002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('AES/GCM/NoPadding')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call AES/GCM/NoPadding')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('AES/GCM/NoPadding Result: Success')); - console.info('uitest: testEncryptionDecryption002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,加解密RSA/ECB/PKCS1_V1_5 - */ - it('testEncryptionDecryption003', 0, async () => { - console.info('uitest: testEncryptionDecryption003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA/ECB/PKCS1_V1_5')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA/ECB/PKCS1_V1_5')); - await button2.click(); - await driver.delayMs(3500); - await driver.assertComponentExist(ON.text('RSA/ECB/PKCS1_V1_5 Result: Success')); - console.info('uitest: testEncryptionDecryption003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,加解密RSA/ECB/OAEP/SHA256 - */ - it('testEncryptionDecryption004', 0, async () => { - console.info('uitest: testEncryptionDecryption004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA/ECB/OAEP/SHA256')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call RSA/ECB/OAEP/SHA256')); - await button2.click(); - await driver.delayMs(3500); - await driver.assertComponentExist(ON.text('RSA/ECB/OAEP/SHA256 Result: Success')); - console.info('uitest: testEncryptionDecryption004 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,加解密SM2 - */ - it('testEncryptionDecryption005', 0, async () => { - console.info('uitest: testEncryptionDecryption005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM2')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call SM2')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2 Result: Success')); - console.info('uitest: testEncryptionDecryption005 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,加解密C/C++ - */ - it('testEncryptionDecryption006', 0, async () => { - console.info('uitest: testEncryptionDecryption006 begin'); - const driver = Driver.create(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call C/C++')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testEncryptionDecryption006 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function encryptionDecryptionTest() { + describe('encryptionDecryptionTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,加解密AES/CBC/PKCS7 + */ + it('testEncryptionDecryption001', 0, async () => { + console.info('uitest: testEncryptionDecryption001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('AES/CBC/PKCS7')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES/CBC/PKCS7')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES/CBC/PKCS7 Result: Success')); + console.info('uitest: testEncryptionDecryption001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,加解密AES/GCM/NoPadding + */ + it('testEncryptionDecryption002', 0, async () => { + console.info('uitest: testEncryptionDecryption002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('AES/GCM/NoPadding')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call AES/GCM/NoPadding')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('AES/GCM/NoPadding Result: Success')); + console.info('uitest: testEncryptionDecryption002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,加解密RSA/ECB/PKCS1_V1_5 + */ + it('testEncryptionDecryption003', 0, async () => { + console.info('uitest: testEncryptionDecryption003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA/ECB/PKCS1_V1_5')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA/ECB/PKCS1_V1_5')); + await button2.click(); + await driver.delayMs(3500); + await driver.assertComponentExist(ON.text('RSA/ECB/PKCS1_V1_5 Result: Success')); + console.info('uitest: testEncryptionDecryption003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,加解密RSA/ECB/OAEP/SHA256 + */ + it('testEncryptionDecryption004', 0, async () => { + console.info('uitest: testEncryptionDecryption004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA/ECB/OAEP/SHA256')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call RSA/ECB/OAEP/SHA256')); + await button2.click(); + await driver.delayMs(3500); + await driver.assertComponentExist(ON.text('RSA/ECB/OAEP/SHA256 Result: Success')); + console.info('uitest: testEncryptionDecryption004 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,加解密SM2 + */ + it('testEncryptionDecryption005', 0, async () => { + console.info('uitest: testEncryptionDecryption005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM2')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call SM2')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2 Result: Success')); + console.info('uitest: testEncryptionDecryption005 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,加解密C/C++ + */ + it('testEncryptionDecryption006', 0, async () => { + console.info('uitest: testEncryptionDecryption006 begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call C/C++')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testEncryptionDecryption006 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/ohosTest.md old mode 100755 new mode 100644 index 40c6b9c6de..f638f40142 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/ohosTest.md @@ -1,13 +1,13 @@ -# 密钥加解密测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------------- | ------------ | ---- | ------------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,加解密AES/CBC/PKCS7 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | -| 点击按钮,加解密AES/GCM/NoPadding | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | -| 点击按钮,加解密RSA/ECB/PKCS1_V1_5 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | -| 点击按钮,加解密RSA/ECB/OAEP/SHA256 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | -| 点击按钮,加解密SM2 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +# 密钥加解密测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------------- | ------------ | ---- | ------------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,加解密AES/CBC/PKCS7 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +| 点击按钮,加解密AES/GCM/NoPadding | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +| 点击按钮,加解密RSA/ECB/PKCS1_V1_5 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +| 点击按钮,加解密RSA/ECB/OAEP/SHA256 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +| 点击按钮,加解密SM2 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | | 点击按钮,加解密C/C++ | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/Cpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/Cpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/app.json5 old mode 100755 new mode 100644 index f52eb071f7..007435cf8c --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/app.json5 @@ -1,25 +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.hmac", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.hmac", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index afd32d11bf..029ee36507 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "HMAC" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "HMAC" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/build-profile.json5 old mode 100755 new mode 100644 index d903787c46..7acbde12b1 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/code-linter.json5 old mode 100755 new mode 100644 index 9deb980763..28586467ee --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/code-linter.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/code-linter.json5 @@ -1,35 +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. - */ - -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/hvigorfile.ts old mode 100755 new mode 100644 index 46872af922..e4f43d5466 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/hvigorfile.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/hvigorfile.ts @@ -1,21 +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. */ -} +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 0539f21e8b..4b42dae941 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(HMAC) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(HMAC) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 5e01b344f6..88bc17699f --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp @@ -1,134 +1,134 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start hmac] -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include - -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} - -static struct OH_Huks_Param g_genHmacParams[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_HMAC}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_MAC}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}}; - -static const uint32_t HMAC_COMMON_SIZE = 1024; -OH_Huks_Result HksHmacTest(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_ParamSet *hmacParamSet, - const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *hashText) -{ - uint8_t handleE[sizeof(uint64_t)] = {0}; - struct OH_Huks_Blob handle = {sizeof(uint64_t), handleE}; - OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, hmacParamSet, &handle, nullptr); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_FinishSession(&handle, hmacParamSet, inData, hashText); - return ret; -} - -static napi_value HmacKey(napi_env env, napi_callback_info info) -{ - /* 1. Generate Key */ - /* - * 模拟生成密钥场景 - * 1.1. 确定密钥别名 - */ - char tmpKeyAlias[] = "test_hmac"; - struct OH_Huks_Blob keyAlias = {(uint32_t)strlen(tmpKeyAlias), (uint8_t *)tmpKeyAlias}; - struct OH_Huks_ParamSet *hmacParamSet = nullptr; - OH_Huks_Result ohResult; - do { - /* - * 1.2. 获取生成密钥算法参数配置 - */ - ohResult = InitParamSet(&hmacParamSet, g_genHmacParams, sizeof(g_genHmacParams) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* - * 1.3. 调用generateKeyItem - */ - ohResult = OH_Huks_GenerateKeyItem(&keyAlias, hmacParamSet, nullptr); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 2. Hmac */ - /* - * 模拟哈希场景 - * 2.1. 获取密钥别名 - */ - /* - * 2.2. 获取待哈希的数据 - */ - char tmpInData[] = "HMAC_MAC_INDATA_1"; - struct OH_Huks_Blob inData = {(uint32_t)strlen(tmpInData), (uint8_t *)tmpInData}; - uint8_t cipher[HMAC_COMMON_SIZE] = {0}; - struct OH_Huks_Blob hashText = {HMAC_COMMON_SIZE, cipher}; - /* - * 2.3. 调用initSession获取handle - */ - /* - * 2.4. 调用finishSession获取哈希后的内容 - */ - ohResult = HksHmacTest(&keyAlias, hmacParamSet, &inData, &hashText); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - } while (0); - OH_Huks_FreeParamSet(&hmacParamSet); - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} -// [End hmac] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = {{"hmacKey", nullptr, HmacKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start hmac] +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include + +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} + +static struct OH_Huks_Param g_genHmacParams[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_HMAC}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_MAC}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}}; + +static const uint32_t HMAC_COMMON_SIZE = 1024; +OH_Huks_Result HksHmacTest(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_ParamSet *hmacParamSet, + const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *hashText) +{ + uint8_t handleE[sizeof(uint64_t)] = {0}; + struct OH_Huks_Blob handle = {sizeof(uint64_t), handleE}; + OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, hmacParamSet, &handle, nullptr); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_FinishSession(&handle, hmacParamSet, inData, hashText); + return ret; +} + +static napi_value HmacKey(napi_env env, napi_callback_info info) +{ + /* 1. Generate Key */ + /* + * 模拟生成密钥场景 + * 1.1. 确定密钥别名 + */ + char tmpKeyAlias[] = "test_hmac"; + struct OH_Huks_Blob keyAlias = {(uint32_t)strlen(tmpKeyAlias), (uint8_t *)tmpKeyAlias}; + struct OH_Huks_ParamSet *hmacParamSet = nullptr; + OH_Huks_Result ohResult; + do { + /* + * 1.2. 获取生成密钥算法参数配置 + */ + ohResult = InitParamSet(&hmacParamSet, g_genHmacParams, sizeof(g_genHmacParams) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* + * 1.3. 调用generateKeyItem + */ + ohResult = OH_Huks_GenerateKeyItem(&keyAlias, hmacParamSet, nullptr); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 2. Hmac */ + /* + * 模拟哈希场景 + * 2.1. 获取密钥别名 + */ + /* + * 2.2. 获取待哈希的数据 + */ + char tmpInData[] = "HMAC_MAC_INDATA_1"; + struct OH_Huks_Blob inData = {(uint32_t)strlen(tmpInData), (uint8_t *)tmpInData}; + uint8_t cipher[HMAC_COMMON_SIZE] = {0}; + struct OH_Huks_Blob hashText = {HMAC_COMMON_SIZE, cipher}; + /* + * 2.3. 调用initSession获取handle + */ + /* + * 2.4. 调用finishSession获取哈希后的内容 + */ + ohResult = HksHmacTest(&keyAlias, hmacParamSet, &inData, &hashText); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + } while (0); + OH_Huks_FreeParamSet(&hmacParamSet); + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} +// [End hmac] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = {{"hmacKey", nullptr, HmacKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index 127a71cc2a..97f8716a9a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 hmacKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets old mode 100755 new mode 100644 index 925aa809b5..edb3b5637b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets @@ -1,155 +1,155 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start hmac_to] -/* - * 以下以HMAC密钥的Promise操作使用为例 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -let hmacKeyAlias = 'test_HMAC'; -let handle: number; -let plainText = '123456'; -let hashData: Uint8Array; - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function uint8ArrayToString(fileData: Uint8Array) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - -function getHMACProperties() { - const properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_HMAC - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - }]; - return properties; -} - -async function generateHMACKey() { - /* - * 模拟生成密钥场景 - * 1. 确定密钥别名 - */ - /* - * 2. 获取生成密钥算法参数配置 - */ - let genProperties = getHMACProperties(); - let options: huks.HuksOptions = { - properties: genProperties - } - /* - * 3. 调用generateKeyItem - */ - await huks.generateKeyItem(hmacKeyAlias, options) - .then((data) => { - console.info(`promise: generate HMAC Key success`); - }).catch((error: Error) => { - console.error(`promise: generate HMAC Key failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} - -async function hMACData() { - /* - * 模拟HMAC场景 - * 1. 获取密钥别名 - */ - /* - * 2. 获取待哈希的数据 - */ - /* - * 3. 获取HMAC算法参数配置 - */ - let hmacProperties = getHMACProperties(); - let options: huks.HuksOptions = { - properties: hmacProperties, - inData: stringToUint8Array(plainText) - } - /* - * 4. 调用initSession获取handle - */ - await huks.initSession(hmacKeyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((error: Error) => { - console.error(`promise: init EncryptData failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) - /* - * 5. 调用finishSession获取HMAC的结果 - */ - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: HMAC data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - hashData = data.outData as Uint8Array; - }).catch((error: Error) => { - console.error(`promise: HMAC data failed, ${JSON.stringify(error)}`); - throw (error as Error); - }) -} -// [End hmac_to] -@Entry -@Component -struct Index { - @State message: string = 'HMAC'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_hmac')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await generateHMACKey(); - await hMACData(); - this.message = 'HMAC Result: Success'; - } catch (error) { - this.message = 'HMAC Result: ' + error.message; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start hmac_to] +/* + * 以下以HMAC密钥的Promise操作使用为例 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +let hmacKeyAlias = 'test_HMAC'; +let handle: number; +let plainText = '123456'; +let hashData: Uint8Array; + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function uint8ArrayToString(fileData: Uint8Array) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + +function getHMACProperties() { + const properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_HMAC + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA384, + }]; + return properties; +} + +async function generateHMACKey() { + /* + * 模拟生成密钥场景 + * 1. 确定密钥别名 + */ + /* + * 2. 获取生成密钥算法参数配置 + */ + let genProperties = getHMACProperties(); + let options: huks.HuksOptions = { + properties: genProperties + } + /* + * 3. 调用generateKeyItem + */ + await huks.generateKeyItem(hmacKeyAlias, options) + .then((data) => { + console.info(`promise: generate HMAC Key success`); + }).catch((error: Error) => { + console.error(`promise: generate HMAC Key failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} + +async function hMACData() { + /* + * 模拟HMAC场景 + * 1. 获取密钥别名 + */ + /* + * 2. 获取待哈希的数据 + */ + /* + * 3. 获取HMAC算法参数配置 + */ + let hmacProperties = getHMACProperties(); + let options: huks.HuksOptions = { + properties: hmacProperties, + inData: stringToUint8Array(plainText) + } + /* + * 4. 调用initSession获取handle + */ + await huks.initSession(hmacKeyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((error: Error) => { + console.error(`promise: init EncryptData failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) + /* + * 5. 调用finishSession获取HMAC的结果 + */ + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: HMAC data success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + hashData = data.outData as Uint8Array; + }).catch((error: Error) => { + console.error(`promise: HMAC data failed, ${JSON.stringify(error)}`); + throw (error as Error); + }) +} +// [End hmac_to] +@Entry +@Component +struct Index { + @State message: string = 'HMAC'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_hmac')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await generateHMACKey(); + await hMACData(); + this.message = 'HMAC Result: Success'; + } catch (error) { + this.message = 'HMAC Result: ' + error.message; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index 4ca75fc98a..4cddde7d4b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/Index.ets @@ -1,69 +1,69 @@ -/* - * 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 { router } from '@kit.ArkUI'; -import testNapi from 'libentry.so'; - -@Entry -@Component -struct Index { - @State message: string = 'HMAC'; - - goToSample(url: string): void { - router.pushUrl({ - url: url, - }, router.RouterMode.Single, (err) => { - if (err) { - console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); - return; - } - console.info('pushUrl success'); - }) - } - - build() { - Column({ space: 5 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.hmac')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - this.goToSample('pages/HMAC') - }) - Button($r('app.string.call_cpp_hmac_key')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - let ret: number = testNapi.hmacKey(); - this.message = 'Call C/C++ Result: ' + ret.toString(); - }) - } - .height('100%') - .width('100%') - } -} +/* + * 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 { router } from '@kit.ArkUI'; +import testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State message: string = 'HMAC'; + + goToSample(url: string): void { + router.pushUrl({ + url: url, + }, router.RouterMode.Single, (err) => { + if (err) { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('pushUrl success'); + }) + } + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.hmac')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + this.goToSample('pages/HMAC') + }) + Button($r('app.string.call_cpp_hmac_key')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + let ret: number = testNapi.hmacKey(); + this.message = 'Call C/C++ Result: ' + ret.toString(); + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 index 9d4f8a434d..0f8ce9a2c0 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - // Defines a test suite. Two parameters are supported: test suite name and test suite function. - beforeAll(() => { - // Presets an action, which is performed only once before all test cases of the test suite start. - // This API supports only one parameter: preset action function. - }) - beforeEach(() => { - // Presets an action, which is performed before each unit test case starts. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: preset action function. - }) - afterEach(() => { - // Presets a clear action, which is performed after each unit test case ends. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: clear action function. - }) - afterAll(() => { - // Presets a clear action, which is performed after all test cases of the test suite end. - // This API supports only one parameter: clear action function. - }) - it('assertContain', 0, () => { - // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. - hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); - let a = 'abc'; - let b = 'b'; - // Defines a variety of assertion methods, which are used to declare expected boolean conditions. - expect(a).assertContain(b); - expect(a).assertEqual(a); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/HMAC.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/HMAC.test.ets old mode 100755 new mode 100644 index 805e76c00b..9555cd9087 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/HMAC.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/HMAC.test.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function hMACTest() { - describe('hMACTest', () => { - - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,HMAC(ArkTS) - */ - it('testHMAC001', 0, async () => { - console.info('uitest: testHMAC001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('HMAC').type('Button')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call HMAC')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('HMAC Result: Success')); - console.info('uitest: testHMAC001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,HMAC(C/C++) - */ - it('testHMAC002', 0, async () => { - console.info('uitest: testHMAC002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(2000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testHMAC002 end'); - }) - }) -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function hMACTest() { + describe('hMACTest', () => { + + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,HMAC(ArkTS) + */ + it('testHMAC001', 0, async () => { + console.info('uitest: testHMAC001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('HMAC').type('Button')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call HMAC')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('HMAC Result: Success')); + console.info('uitest: testHMAC001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,HMAC(C/C++) + */ + it('testHMAC002', 0, async () => { + console.info('uitest: testHMAC002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(2000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testHMAC002 end'); + }) + }) +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 index 6993a5dd1e..c054467fd6 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/List.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/List.test.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hMACTest from './HMAC.test'; - -export default function testsuite() { - hMACTest(); +/* + * 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 hMACTest from './HMAC.test'; + +export default function testsuite() { + hMACTest(); } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyUsage/HMAC/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/hvigorfile.ts old mode 100755 new mode 100644 index 2db60fa918..2a5e543f19 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/hvigorfile.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/hvigorfile.ts @@ -1,21 +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. */ -} +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/HMAC/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/ohosTest.md old mode 100755 new mode 100644 index 52479113a4..4568f24cfe --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/ohosTest.md @@ -1,9 +1,9 @@ -# 密钥HMAC测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------- | ------------ | ---- | ------------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,HMAC(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +# 密钥HMAC测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------- | ------------ | ---- | ------------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,HMAC(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | | 点击按钮,HMAC(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/app.json5 old mode 100755 new mode 100644 index 132bda4cf6..6defc46afc --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/app.json5 @@ -1,25 +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.keyderivation", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.keyderivation", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index e03fb76012..96cf25cee2 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "KeyDerivation" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "KeyDerivation" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 7a2e4e3663..183f2308d4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(KeyDerivation) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(KeyDerivation) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index a7dc694bf6..40a395dfd0 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp @@ -1,148 +1,148 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start key_derivation] -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include - -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} -static const uint32_t DERIVE_KEY_SIZE_32 = 32; -static const uint32_t DERIVE_KEY_SIZE_256 = 256; -static struct OH_Huks_Blob g_deriveKeyAlias = {(uint32_t)strlen("test_derive"), (uint8_t *)"test_derive"}; -static struct OH_Huks_Param g_genDeriveParams[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}}; -static struct OH_Huks_Param g_hkdfParams[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_HKDF}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256}, - {.tag = OH_HUKS_TAG_DERIVE_KEY_SIZE, .uint32Param = DERIVE_KEY_SIZE_32}}; -static struct OH_Huks_Param g_hkdfFinishParams[] = { - {.tag = OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_ONLY_USED_IN_HUKS}, - {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_deriveKeyAlias}, - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = DERIVE_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256}}; -static const uint32_t COMMON_SIZE = 2048; -static const char *G_DERIVE_IN_DATA = "Hks_HKDF_Derive_Test_00000000000000000000000000000000000000000000000000000000000" - "00000000000000000000000000000000000000000000000000000000000000000000000000000000" - "0000000000000000000000000000000000000000000000000000000000000000000000000_string"; -static napi_value DeriveKey(napi_env env, napi_callback_info info) -{ - struct OH_Huks_Blob genAlias = {(uint32_t)strlen("test_signVerify"), (uint8_t *)"test_signVerify"}; - struct OH_Huks_Blob inData = {(uint32_t)strlen(G_DERIVE_IN_DATA), (uint8_t *)G_DERIVE_IN_DATA}; - struct OH_Huks_ParamSet *genParamSet = nullptr; - struct OH_Huks_ParamSet *hkdfParamSet = nullptr; - struct OH_Huks_ParamSet *hkdfFinishParamSet = nullptr; - OH_Huks_Result ohResult; - do { - ohResult = InitParamSet(&genParamSet, g_genDeriveParams, sizeof(g_genDeriveParams) / - sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - - ohResult = InitParamSet(&hkdfParamSet, g_hkdfParams, sizeof(g_hkdfParams) / - sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - - // finish paramset - ohResult = - InitParamSet(&hkdfFinishParamSet, g_hkdfFinishParams, sizeof(g_hkdfFinishParams) / - sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - - /* 1. Generate Key */ - ohResult = OH_Huks_GenerateKeyItem(&genAlias, genParamSet, nullptr); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 2. Derive */ - // Init - uint8_t handleD[sizeof(uint64_t)] = {0}; - struct OH_Huks_Blob handleDerive = {sizeof(uint64_t), handleD}; - ohResult = OH_Huks_InitSession(&genAlias, hkdfParamSet, &handleDerive, nullptr); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - // Update - uint8_t tmpOut[COMMON_SIZE] = {0}; - struct OH_Huks_Blob outData = {COMMON_SIZE, tmpOut}; - ohResult = OH_Huks_UpdateSession(&handleDerive, hkdfParamSet, &inData, &outData); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - // Finish - uint8_t outDataD[COMMON_SIZE] = {0}; - struct OH_Huks_Blob outDataDerive = {COMMON_SIZE, outDataD}; - ohResult = OH_Huks_FinishSession(&handleDerive, hkdfFinishParamSet, &inData, &outDataDerive); - } while (0); - (void)OH_Huks_DeleteKeyItem(&genAlias, nullptr); - (void)OH_Huks_DeleteKeyItem(&g_deriveKeyAlias, nullptr); - OH_Huks_FreeParamSet(&genParamSet); - OH_Huks_FreeParamSet(&hkdfParamSet); - OH_Huks_FreeParamSet(&hkdfFinishParamSet); - - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} -// [End key_derivation] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"deriveKey", nullptr, DeriveKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start key_derivation] +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include + +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} +static const uint32_t DERIVE_KEY_SIZE_32 = 32; +static const uint32_t DERIVE_KEY_SIZE_256 = 256; +static struct OH_Huks_Blob g_deriveKeyAlias = {(uint32_t)strlen("test_derive"), (uint8_t *)"test_derive"}; +static struct OH_Huks_Param g_genDeriveParams[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}}; +static struct OH_Huks_Param g_hkdfParams[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_HKDF}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256}, + {.tag = OH_HUKS_TAG_DERIVE_KEY_SIZE, .uint32Param = DERIVE_KEY_SIZE_32}}; +static struct OH_Huks_Param g_hkdfFinishParams[] = { + {.tag = OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_ONLY_USED_IN_HUKS}, + {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_deriveKeyAlias}, + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = DERIVE_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256}}; +static const uint32_t COMMON_SIZE = 2048; +static const char *G_DERIVE_IN_DATA = "Hks_HKDF_Derive_Test_00000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000000000000_string"; +static napi_value DeriveKey(napi_env env, napi_callback_info info) +{ + struct OH_Huks_Blob genAlias = {(uint32_t)strlen("test_signVerify"), (uint8_t *)"test_signVerify"}; + struct OH_Huks_Blob inData = {(uint32_t)strlen(G_DERIVE_IN_DATA), (uint8_t *)G_DERIVE_IN_DATA}; + struct OH_Huks_ParamSet *genParamSet = nullptr; + struct OH_Huks_ParamSet *hkdfParamSet = nullptr; + struct OH_Huks_ParamSet *hkdfFinishParamSet = nullptr; + OH_Huks_Result ohResult; + do { + ohResult = InitParamSet(&genParamSet, g_genDeriveParams, sizeof(g_genDeriveParams) / + sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + + ohResult = InitParamSet(&hkdfParamSet, g_hkdfParams, sizeof(g_hkdfParams) / + sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + + // finish paramset + ohResult = + InitParamSet(&hkdfFinishParamSet, g_hkdfFinishParams, sizeof(g_hkdfFinishParams) / + sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + + /* 1. Generate Key */ + ohResult = OH_Huks_GenerateKeyItem(&genAlias, genParamSet, nullptr); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 2. Derive */ + // Init + uint8_t handleD[sizeof(uint64_t)] = {0}; + struct OH_Huks_Blob handleDerive = {sizeof(uint64_t), handleD}; + ohResult = OH_Huks_InitSession(&genAlias, hkdfParamSet, &handleDerive, nullptr); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + // Update + uint8_t tmpOut[COMMON_SIZE] = {0}; + struct OH_Huks_Blob outData = {COMMON_SIZE, tmpOut}; + ohResult = OH_Huks_UpdateSession(&handleDerive, hkdfParamSet, &inData, &outData); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + // Finish + uint8_t outDataD[COMMON_SIZE] = {0}; + struct OH_Huks_Blob outDataDerive = {COMMON_SIZE, outDataD}; + ohResult = OH_Huks_FinishSession(&handleDerive, hkdfFinishParamSet, &inData, &outDataDerive); + } while (0); + (void)OH_Huks_DeleteKeyItem(&genAlias, nullptr); + (void)OH_Huks_DeleteKeyItem(&g_deriveKeyAlias, nullptr); + OH_Huks_FreeParamSet(&genParamSet); + OH_Huks_FreeParamSet(&hkdfParamSet); + OH_Huks_FreeParamSet(&hkdfFinishParamSet); + + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} +// [End key_derivation] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"deriveKey", nullptr, DeriveKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index 0079094e8c..a15baf5bd2 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 deriveKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets old mode 100755 new mode 100644 index 3fc903ac6d..0481900ea5 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets @@ -1,362 +1,362 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// [Start the_key_is_derived_from_hkdf] -/* - * 以下以HKDF密钥的Promise操作使用为例 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -/* - * 确定密钥别名和封装密钥属性参数集 - */ -let srcKeyAlias = 'hkdf_Key'; -let deriveHkdfInData = 'deriveHkdfTestIndata'; -let handle: number; -let finishOutData: Uint8Array; -let huksKeyDeriveKeySize = 32; -/* 集成生成密钥参数集 */ -let properties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, -}, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, -}, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, -}, { - tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, -}]; - -let huksOptions: huks.HuksOptions = { - properties: properties, - inData: new Uint8Array([]) -} -/* 集成init时密钥参数集 */ -let initProperties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_HKDF, -}, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, -}, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, -}, { - tag: huks.HuksTag.HUKS_TAG_DERIVE_KEY_SIZE, - value: huksKeyDeriveKeySize, -}]; - -let initOptions: huks.HuksOptions = { - properties: initProperties, - inData: new Uint8Array([]) -} -/* 集成finish时密钥参数集 */ -let finishProperties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, -}, { - tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, - value: true, -}, { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, -}, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, -}, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, -}, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, -}, { - tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAlias), -}, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, -}, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB, -}]; -let finishOptions: huks.HuksOptions = { - properties: finishProperties, - inData: new Uint8Array([]) -} - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -class ThrowObject { - public isThrow = false; -} - -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise generateKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await generateKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.initSession(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise doInit`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await initSession(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - handle = data.handle; - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doInit failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -function updateSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.updateSession(handle, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicUpdateFunc(handle: number, huksOptions: huks.HuksOptions) { - console.info(`enter promise doUpdate`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await updateSession(handle, huksOptions, throwObject) - .then((data) => { - console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -function finishSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.finishSession(handle, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicFinishFunc(handle: number, huksOptions: huks.HuksOptions) { - console.info(`enter promise doFinish`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await finishSession(handle, huksOptions, throwObject) - .then((data) => { - finishOutData = data.outData as Uint8Array; - console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doFinish failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise deleteKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await deleteKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -async function testDerive() { - /* 生成密钥 */ - await publicGenKeyFunc(srcKeyAlias, huksOptions); - /* 进行派生操作 */ - await publicInitFunc(srcKeyAlias, initOptions); - initOptions.inData = stringToUint8Array(deriveHkdfInData); - await publicUpdateFunc(handle, initOptions); - await publicFinishFunc(handle, finishOptions); - await publicDeleteKeyFunc(srcKeyAlias, huksOptions); -} -// [End the_key_is_derived_from_hkdf] -@Entry -@Component -struct Index { - @State message: string = 'HKDF'; - - build() { - Column({ space: 12 }) { - Text(this.message).fontSize(20) - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_hkdf')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - let ret = await testDerive(); - this.message = 'HKDF Result: Success'; - } catch { - this.message = 'HKDF Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start the_key_is_derived_from_hkdf] +/* + * 以下以HKDF密钥的Promise操作使用为例 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +/* + * 确定密钥别名和封装密钥属性参数集 + */ +let srcKeyAlias = 'hkdf_Key'; +let deriveHkdfInData = 'deriveHkdfTestIndata'; +let handle: number; +let finishOutData: Uint8Array; +let huksKeyDeriveKeySize = 32; +/* 集成生成密钥参数集 */ +let properties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES, + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, +}, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, +}, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, +}, { + tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, +}]; + +let huksOptions: huks.HuksOptions = { + properties: properties, + inData: new Uint8Array([]) +} +/* 集成init时密钥参数集 */ +let initProperties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_HKDF, +}, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, +}, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, +}, { + tag: huks.HuksTag.HUKS_TAG_DERIVE_KEY_SIZE, + value: huksKeyDeriveKeySize, +}]; + +let initOptions: huks.HuksOptions = { + properties: initProperties, + inData: new Uint8Array([]) +} +/* 集成finish时密钥参数集 */ +let finishProperties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, +}, { + tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, + value: true, +}, { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES, +}, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, +}, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, +}, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, +}, { + tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAlias), +}, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE, +}, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB, +}]; +let finishOptions: huks.HuksOptions = { + properties: finishProperties, + inData: new Uint8Array([]) +} + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +class ThrowObject { + public isThrow = false; +} + +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise generateKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await generateKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.initSession(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise doInit`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await initSession(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doInit failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +function updateSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.updateSession(handle, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicUpdateFunc(handle: number, huksOptions: huks.HuksOptions) { + console.info(`enter promise doUpdate`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await updateSession(handle, huksOptions, throwObject) + .then((data) => { + console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +function finishSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicFinishFunc(handle: number, huksOptions: huks.HuksOptions) { + console.info(`enter promise doFinish`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await finishSession(handle, huksOptions, throwObject) + .then((data) => { + finishOutData = data.outData as Uint8Array; + console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doFinish failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise deleteKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await deleteKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +async function testDerive() { + /* 生成密钥 */ + await publicGenKeyFunc(srcKeyAlias, huksOptions); + /* 进行派生操作 */ + await publicInitFunc(srcKeyAlias, initOptions); + initOptions.inData = stringToUint8Array(deriveHkdfInData); + await publicUpdateFunc(handle, initOptions); + await publicFinishFunc(handle, finishOptions); + await publicDeleteKeyFunc(srcKeyAlias, huksOptions); +} +// [End the_key_is_derived_from_hkdf] +@Entry +@Component +struct Index { + @State message: string = 'HKDF'; + + build() { + Column({ space: 12 }) { + Text(this.message).fontSize(20) + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_hkdf')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + let ret = await testDerive(); + this.message = 'HKDF Result: Success'; + } catch { + this.message = 'HKDF Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets old mode 100755 new mode 100644 index a79cab1f46..b115ec9389 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets @@ -1,373 +1,373 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start the_key_is_derived_from_pbkdf2] -/* - * 以下以PBKDF2密钥的Promise操作使用为例 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -/* - * 确定密钥别名和封装密钥属性参数集 - */ -let srcKeyAlias = 'pbkdf2_Key'; -let salt = 'mySalt'; -let iterationCount = 10000; -let derivedKeySize = 32; -let handle: number; -let finishOutData: Uint8Array; - -/* 集成生成密钥参数集 */ -let properties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, -}, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, -}, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, -}, { - tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, -} -]; - -let huksOptions: huks.HuksOptions = { - properties: properties, - inData: new Uint8Array([]) -} - -/* 集成init时密钥参数集 */ -let initProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_PBKDF2, - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, -}, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, -}, { - tag: huks.HuksTag.HUKS_TAG_DERIVE_KEY_SIZE, - value: derivedKeySize, -}, { - tag: huks.HuksTag.HUKS_TAG_ITERATION, - value: iterationCount, -}, { - tag: huks.HuksTag.HUKS_TAG_SALT, - value: stringToUint8Array(salt), -} -]; - -let initOptions: huks.HuksOptions = { - properties: initProperties, - inData: new Uint8Array([]) -} - -/* 集成finish时密钥参数集 */ -let finishProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, - }, { - tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, - value: true, -}, { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, -}, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, -}, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, -}, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, -}, { - tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAlias), -}, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, -}, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB, -} -]; - -let finishOptions: huks.HuksOptions = { - properties: finishProperties, - inData: new Uint8Array([]) -} - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -class ThrowObject { - public isThrow = false; -} - -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise generateKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await generateKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.initSession(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise doInit`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await initSession(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - handle = data.handle; - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doInit failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -function updateSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.updateSession(handle, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicUpdateFunc(handle: number, huksOptions: huks.HuksOptions) { - console.info(`enter promise doUpdate`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await updateSession(handle, huksOptions, throwObject) - .then((data) => { - console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -function finishSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.finishSession(handle, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicFinishFunc(handle: number, huksOptions: huks.HuksOptions) { - console.info(`enter promise doFinish`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await finishSession(handle, huksOptions, throwObject) - .then((data) => { - finishOutData = data.outData as Uint8Array; - console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doFinish failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise deleteKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await deleteKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -async function testDerive() { - /* 生成密钥 */ - await publicGenKeyFunc(srcKeyAlias, huksOptions); - /* 进行派生操作 */ - await publicInitFunc(srcKeyAlias, initOptions); - await publicUpdateFunc(handle, initOptions); - await publicFinishFunc(handle, finishOptions); - await publicDeleteKeyFunc(srcKeyAlias, huksOptions); -} -// [End the_key_is_derived_from_pbkdf2] -@Entry -@Component -struct Index { - @State message: string = 'PBKDF2'; - - build() { - Column({ space: 12 }) { - Text(this.message) - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_pbkdf2')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - let ret = await testDerive(); - this.message = 'PBKDF2 Result: Success'; - } catch { - this.message = 'PBKDF2 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start the_key_is_derived_from_pbkdf2] +/* + * 以下以PBKDF2密钥的Promise操作使用为例 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +/* + * 确定密钥别名和封装密钥属性参数集 + */ +let srcKeyAlias = 'pbkdf2_Key'; +let salt = 'mySalt'; +let iterationCount = 10000; +let derivedKeySize = 32; +let handle: number; +let finishOutData: Uint8Array; + +/* 集成生成密钥参数集 */ +let properties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES, + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, +}, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, +}, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, +}, { + tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, +} +]; + +let huksOptions: huks.HuksOptions = { + properties: properties, + inData: new Uint8Array([]) +} + +/* 集成init时密钥参数集 */ +let initProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_PBKDF2, + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, +}, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, +}, { + tag: huks.HuksTag.HUKS_TAG_DERIVE_KEY_SIZE, + value: derivedKeySize, +}, { + tag: huks.HuksTag.HUKS_TAG_ITERATION, + value: iterationCount, +}, { + tag: huks.HuksTag.HUKS_TAG_SALT, + value: stringToUint8Array(salt), +} +]; + +let initOptions: huks.HuksOptions = { + properties: initProperties, + inData: new Uint8Array([]) +} + +/* 集成finish时密钥参数集 */ +let finishProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, + }, { + tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, + value: true, +}, { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES, +}, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, +}, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, +}, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, +}, { + tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAlias), +}, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE, +}, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB, +} +]; + +let finishOptions: huks.HuksOptions = { + properties: finishProperties, + inData: new Uint8Array([]) +} + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +class ThrowObject { + public isThrow = false; +} + +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise generateKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await generateKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.initSession(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise doInit`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await initSession(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doInit failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +function updateSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.updateSession(handle, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicUpdateFunc(handle: number, huksOptions: huks.HuksOptions) { + console.info(`enter promise doUpdate`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await updateSession(handle, huksOptions, throwObject) + .then((data) => { + console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +function finishSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicFinishFunc(handle: number, huksOptions: huks.HuksOptions) { + console.info(`enter promise doFinish`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await finishSession(handle, huksOptions, throwObject) + .then((data) => { + finishOutData = data.outData as Uint8Array; + console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doFinish failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise deleteKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await deleteKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +async function testDerive() { + /* 生成密钥 */ + await publicGenKeyFunc(srcKeyAlias, huksOptions); + /* 进行派生操作 */ + await publicInitFunc(srcKeyAlias, initOptions); + await publicUpdateFunc(handle, initOptions); + await publicFinishFunc(handle, finishOptions); + await publicDeleteKeyFunc(srcKeyAlias, huksOptions); +} +// [End the_key_is_derived_from_pbkdf2] +@Entry +@Component +struct Index { + @State message: string = 'PBKDF2'; + + build() { + Column({ space: 12 }) { + Text(this.message) + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_pbkdf2')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + let ret = await testDerive(); + this.message = 'PBKDF2 Result: Success'; + } catch { + this.message = 'PBKDF2 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/KeyDerivation.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/KeyDerivation.test.ets old mode 100755 new mode 100644 index 5538f56735..b7b4b3de0a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/KeyDerivation.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/KeyDerivation.test.ets @@ -1,95 +1,95 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function keyDerivationTest() { - describe('keyDerivationTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,密钥派生HKDF - */ - it('testKeyDerivation001', 0, async () => { - console.info('uitest: testKeyDerivation001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('HKDF')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call HKDF')); - await button2.click(); - await driver.delayMs(2000); - await driver.assertComponentExist(ON.text('HKDF Result: Success')); - console.info('uitest: testKeyDerivation001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,密钥派生PBKDF2 - */ - it('testKeyDerivation002', 0, async () => { - console.info('uitest: testKeyDerivation002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('PBKDF2')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call PBKDF2')); - await button2.click(); - await driver.delayMs(2000); - await driver.assertComponentExist(ON.text('PBKDF2 Result: Success')); - console.info('uitest: testKeyDerivation002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,密钥派生HKDF256(C/C++) - */ - it('testKeyDerivation003', 0, async () => { - console.info('uitest: testKeyDerivation003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testKeyDerivation003 end'); - await driver.pressBack(); - }) - }) -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function keyDerivationTest() { + describe('keyDerivationTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,密钥派生HKDF + */ + it('testKeyDerivation001', 0, async () => { + console.info('uitest: testKeyDerivation001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('HKDF')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call HKDF')); + await button2.click(); + await driver.delayMs(2000); + await driver.assertComponentExist(ON.text('HKDF Result: Success')); + console.info('uitest: testKeyDerivation001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,密钥派生PBKDF2 + */ + it('testKeyDerivation002', 0, async () => { + console.info('uitest: testKeyDerivation002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('PBKDF2')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call PBKDF2')); + await button2.click(); + await driver.delayMs(2000); + await driver.assertComponentExist(ON.text('PBKDF2 Result: Success')); + console.info('uitest: testKeyDerivation002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,密钥派生HKDF256(C/C++) + */ + it('testKeyDerivation003', 0, async () => { + console.info('uitest: testKeyDerivation003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testKeyDerivation003 end'); + await driver.pressBack(); + }) + }) +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/ohosTest.md old mode 100755 new mode 100644 index da4b8c8a2c..ba4443dd88 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/ohosTest.md @@ -1,10 +1,10 @@ -# 密钥派生测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------- | ------------ | ---- | ------------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,密钥派生HKDF | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | -| 点击按钮,密钥派生PBKDF2 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +# 密钥派生测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------- | ------------ | ---- | ------------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,密钥派生HKDF | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +| 点击按钮,密钥派生PBKDF2 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | | 点击按钮,密钥派生(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/app.json5 old mode 100755 new mode 100644 index 6aa00b44a4..287ffdacf9 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/app.json5 @@ -1,25 +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.keyexchange", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.keyexchange", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index dfe9e4e2e9..dc8e956b1f --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "KeyExchange" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "KeyExchange" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index b847c2d1cb..9e0677bac1 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(KeyExchange) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(KeyExchange) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index fa6fb39925..f61e730145 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp @@ -1,265 +1,265 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start key_agreement] -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include - -/* 初始化参数 */ -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} -static const uint32_t IV_SIZE = 16; -static uint8_t IV[IV_SIZE] = {0}; // this is a test value, for real use the iv should be different every time -static struct OH_Huks_Blob g_keyAliasFinal1001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_1_final"), - (uint8_t *)"HksECDHAgreeKeyAliasTest001_1_final"}; -/* 集成密钥参数集 */ -static struct OH_Huks_Param g_genAgreeParams[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; -static struct OH_Huks_Param g_agreeParamsInit01[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECDH}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}}; -static struct OH_Huks_Param g_agreeParamsFinish01[] = { - {.tag = OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_ONLY_USED_IN_HUKS}, - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_keyAliasFinal1001}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, - {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}}; -static struct OH_Huks_Blob g_keyAliasFinal2001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_2_final"), - (uint8_t *)"HksECDHAgreeKeyAliasTest001_2_final"}; -static struct OH_Huks_Param g_agreeParamsInit02[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECDH}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}}; -static struct OH_Huks_Param g_agreeParamsFinish02[] = { - {.tag = OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_ONLY_USED_IN_HUKS}, - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_keyAliasFinal2001}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, - {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}}; -static const uint32_t ECDH_COMMON_SIZE = 1024; -static struct OH_Huks_Blob g_keyAlias01001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_1"), - (uint8_t *)"HksECDHAgreeKeyAliasTest001_1"}; -static struct OH_Huks_Blob g_keyAlias02001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_2"), - (uint8_t *)"HksECDHAgreeKeyAliasTest001_2"}; - -OH_Huks_Result MallocAndCheckBlobData(struct OH_Huks_Blob *blob, const uint32_t blobSize) -{ - struct OH_Huks_Result ret; - ret.errorCode = OH_HUKS_SUCCESS; - if (blobSize == 0 || blobSize > ECDH_COMMON_SIZE) { - ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; - return ret; - } - blob->data = (uint8_t *)malloc(blobSize); - if (blob->data == NULL) { - ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; - } - return ret; -} -/* 导出密钥 */ -OH_Huks_Result HksEcdhAgreeExport(const struct OH_Huks_Blob *keyAlias1, const struct OH_Huks_Blob *keyAlias2, - struct OH_Huks_Blob *publicKey1, struct OH_Huks_Blob *publicKey2, - const struct OH_Huks_ParamSet *genParamSet) -{ - OH_Huks_Result ret = OH_Huks_ExportPublicKeyItem(keyAlias1, genParamSet, publicKey1); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_ExportPublicKeyItem(keyAlias2, genParamSet, publicKey2); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - return ret; -} -static const char *IN_DATA = "Hks_ECDH_Agree_Test_000000000000000000000000000000000000000000000000000000000000" - "00000000000000000000000000000000000000000000000000000000000000000000000000000000" - "0000000000000000000000000000000000000000000000000000000000000000000000000_string"; -/* 协商密钥操作 */ -OH_Huks_Result HksEcdhAgreeFinish(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_Blob *publicKey, - const struct OH_Huks_ParamSet *initParamSet, - const struct OH_Huks_ParamSet *finishParamSet, struct OH_Huks_Blob *outData) -{ - struct OH_Huks_Blob inData = {(uint32_t)strlen(IN_DATA), (uint8_t *)IN_DATA}; - uint8_t handleU[sizeof(uint64_t)] = {0}; - struct OH_Huks_Blob handle = {sizeof(uint64_t), handleU}; - OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, initParamSet, &handle, nullptr); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - uint8_t outDataU[ECDH_COMMON_SIZE] = {0}; - struct OH_Huks_Blob outDataUpdate = {ECDH_COMMON_SIZE, outDataU}; - ret = OH_Huks_UpdateSession(&handle, initParamSet, publicKey, &outDataUpdate); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_FinishSession(&handle, finishParamSet, &inData, outData); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - return ret; -} - -/* 协商密钥整体流程 */ -static napi_value AgreeKey(napi_env env, napi_callback_info info) -{ - struct OH_Huks_ParamSet *genParamSet = nullptr; - struct OH_Huks_ParamSet *initParamSet01 = nullptr; - struct OH_Huks_ParamSet *finishParamSet01 = nullptr; - struct OH_Huks_ParamSet *initParamSet02 = nullptr; - struct OH_Huks_ParamSet *finishParamSet02 = nullptr; - struct OH_Huks_Blob publicKey01 = {.size = OH_HUKS_ECC_KEY_SIZE_256, .data = nullptr}; - struct OH_Huks_Blob publicKey02 = {.size = OH_HUKS_ECC_KEY_SIZE_256, .data = nullptr}; - struct OH_Huks_Blob outData01 = {.size = ECDH_COMMON_SIZE, .data = nullptr}; - struct OH_Huks_Blob outData02 = {.size = ECDH_COMMON_SIZE, .data = nullptr}; - OH_Huks_Result ohResult; - do { - /* 1.确定密钥别名集成密钥参数集 */ - ohResult = InitParamSet(&genParamSet, g_genAgreeParams, sizeof(g_genAgreeParams) / - sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = - InitParamSet(&initParamSet01, g_agreeParamsInit01, sizeof(g_agreeParamsInit01) / - sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = InitParamSet(&finishParamSet01, g_agreeParamsFinish01, - sizeof(g_agreeParamsFinish01) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = - InitParamSet(&initParamSet02, g_agreeParamsInit02, sizeof(g_agreeParamsInit02) / - sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = InitParamSet(&finishParamSet02, g_agreeParamsFinish02, - sizeof(g_agreeParamsFinish02) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 2.设备A生成密钥 */ - ohResult = OH_Huks_GenerateKeyItem(&g_keyAlias01001, genParamSet, nullptr); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 3.设备B生成密钥 */ - ohResult = OH_Huks_GenerateKeyItem(&g_keyAlias02001, genParamSet, nullptr); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = MallocAndCheckBlobData(&publicKey01, publicKey01.size); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = MallocAndCheckBlobData(&publicKey02, publicKey02.size); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 4.设备A、B导出公钥 */ - ohResult = HksEcdhAgreeExport(&g_keyAlias01001, &g_keyAlias02001, &publicKey01, - &publicKey02, genParamSet); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = MallocAndCheckBlobData(&outData01, outData01.size); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = MallocAndCheckBlobData(&outData02, outData02.size); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 5.设备A协商密钥 */ - ohResult = HksEcdhAgreeFinish(&g_keyAlias01001, &publicKey02, initParamSet01, - finishParamSet01, &outData01); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 5.设备B协商密钥 */ - ohResult = HksEcdhAgreeFinish(&g_keyAlias02001, &publicKey01, initParamSet02, - finishParamSet02, &outData02); - } while (0); - free(publicKey01.data); - free(publicKey02.data); - free(outData01.data); - free(outData02.data); - /* 6.设备A、B删除密钥 */ - OH_Huks_DeleteKeyItem(&g_keyAlias01001, genParamSet); - OH_Huks_DeleteKeyItem(&g_keyAlias02001, genParamSet); - OH_Huks_DeleteKeyItem(&g_keyAliasFinal1001, NULL); - OH_Huks_DeleteKeyItem(&g_keyAliasFinal2001, NULL); - OH_Huks_FreeParamSet(&genParamSet); - OH_Huks_FreeParamSet(&initParamSet01); - OH_Huks_FreeParamSet(&finishParamSet01); - OH_Huks_FreeParamSet(&initParamSet02); - OH_Huks_FreeParamSet(&finishParamSet02); - - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} - -// [End key_agreement] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"agreeKey", nullptr, AgreeKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start key_agreement] +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include + +/* 初始化参数 */ +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} +static const uint32_t IV_SIZE = 16; +static uint8_t IV[IV_SIZE] = {0}; // this is a test value, for real use the iv should be different every time +static struct OH_Huks_Blob g_keyAliasFinal1001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_1_final"), + (uint8_t *)"HksECDHAgreeKeyAliasTest001_1_final"}; +/* 集成密钥参数集 */ +static struct OH_Huks_Param g_genAgreeParams[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; +static struct OH_Huks_Param g_agreeParamsInit01[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECDH}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}}; +static struct OH_Huks_Param g_agreeParamsFinish01[] = { + {.tag = OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_ONLY_USED_IN_HUKS}, + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_keyAliasFinal1001}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, + {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}}; +static struct OH_Huks_Blob g_keyAliasFinal2001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_2_final"), + (uint8_t *)"HksECDHAgreeKeyAliasTest001_2_final"}; +static struct OH_Huks_Param g_agreeParamsInit02[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECDH}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}}; +static struct OH_Huks_Param g_agreeParamsFinish02[] = { + {.tag = OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_ONLY_USED_IN_HUKS}, + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_keyAliasFinal2001}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE}, + {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}}; +static const uint32_t ECDH_COMMON_SIZE = 1024; +static struct OH_Huks_Blob g_keyAlias01001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_1"), + (uint8_t *)"HksECDHAgreeKeyAliasTest001_1"}; +static struct OH_Huks_Blob g_keyAlias02001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_2"), + (uint8_t *)"HksECDHAgreeKeyAliasTest001_2"}; + +OH_Huks_Result MallocAndCheckBlobData(struct OH_Huks_Blob *blob, const uint32_t blobSize) +{ + struct OH_Huks_Result ret; + ret.errorCode = OH_HUKS_SUCCESS; + if (blobSize == 0 || blobSize > ECDH_COMMON_SIZE) { + ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; + return ret; + } + blob->data = (uint8_t *)malloc(blobSize); + if (blob->data == NULL) { + ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR; + } + return ret; +} +/* 导出密钥 */ +OH_Huks_Result HksEcdhAgreeExport(const struct OH_Huks_Blob *keyAlias1, const struct OH_Huks_Blob *keyAlias2, + struct OH_Huks_Blob *publicKey1, struct OH_Huks_Blob *publicKey2, + const struct OH_Huks_ParamSet *genParamSet) +{ + OH_Huks_Result ret = OH_Huks_ExportPublicKeyItem(keyAlias1, genParamSet, publicKey1); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_ExportPublicKeyItem(keyAlias2, genParamSet, publicKey2); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + return ret; +} +static const char *IN_DATA = "Hks_ECDH_Agree_Test_000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000000000000_string"; +/* 协商密钥操作 */ +OH_Huks_Result HksEcdhAgreeFinish(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_Blob *publicKey, + const struct OH_Huks_ParamSet *initParamSet, + const struct OH_Huks_ParamSet *finishParamSet, struct OH_Huks_Blob *outData) +{ + struct OH_Huks_Blob inData = {(uint32_t)strlen(IN_DATA), (uint8_t *)IN_DATA}; + uint8_t handleU[sizeof(uint64_t)] = {0}; + struct OH_Huks_Blob handle = {sizeof(uint64_t), handleU}; + OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, initParamSet, &handle, nullptr); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + uint8_t outDataU[ECDH_COMMON_SIZE] = {0}; + struct OH_Huks_Blob outDataUpdate = {ECDH_COMMON_SIZE, outDataU}; + ret = OH_Huks_UpdateSession(&handle, initParamSet, publicKey, &outDataUpdate); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_FinishSession(&handle, finishParamSet, &inData, outData); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + return ret; +} + +/* 协商密钥整体流程 */ +static napi_value AgreeKey(napi_env env, napi_callback_info info) +{ + struct OH_Huks_ParamSet *genParamSet = nullptr; + struct OH_Huks_ParamSet *initParamSet01 = nullptr; + struct OH_Huks_ParamSet *finishParamSet01 = nullptr; + struct OH_Huks_ParamSet *initParamSet02 = nullptr; + struct OH_Huks_ParamSet *finishParamSet02 = nullptr; + struct OH_Huks_Blob publicKey01 = {.size = OH_HUKS_ECC_KEY_SIZE_256, .data = nullptr}; + struct OH_Huks_Blob publicKey02 = {.size = OH_HUKS_ECC_KEY_SIZE_256, .data = nullptr}; + struct OH_Huks_Blob outData01 = {.size = ECDH_COMMON_SIZE, .data = nullptr}; + struct OH_Huks_Blob outData02 = {.size = ECDH_COMMON_SIZE, .data = nullptr}; + OH_Huks_Result ohResult; + do { + /* 1.确定密钥别名集成密钥参数集 */ + ohResult = InitParamSet(&genParamSet, g_genAgreeParams, sizeof(g_genAgreeParams) / + sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = + InitParamSet(&initParamSet01, g_agreeParamsInit01, sizeof(g_agreeParamsInit01) / + sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = InitParamSet(&finishParamSet01, g_agreeParamsFinish01, + sizeof(g_agreeParamsFinish01) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = + InitParamSet(&initParamSet02, g_agreeParamsInit02, sizeof(g_agreeParamsInit02) / + sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = InitParamSet(&finishParamSet02, g_agreeParamsFinish02, + sizeof(g_agreeParamsFinish02) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 2.设备A生成密钥 */ + ohResult = OH_Huks_GenerateKeyItem(&g_keyAlias01001, genParamSet, nullptr); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 3.设备B生成密钥 */ + ohResult = OH_Huks_GenerateKeyItem(&g_keyAlias02001, genParamSet, nullptr); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = MallocAndCheckBlobData(&publicKey01, publicKey01.size); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = MallocAndCheckBlobData(&publicKey02, publicKey02.size); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 4.设备A、B导出公钥 */ + ohResult = HksEcdhAgreeExport(&g_keyAlias01001, &g_keyAlias02001, &publicKey01, + &publicKey02, genParamSet); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = MallocAndCheckBlobData(&outData01, outData01.size); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = MallocAndCheckBlobData(&outData02, outData02.size); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 5.设备A协商密钥 */ + ohResult = HksEcdhAgreeFinish(&g_keyAlias01001, &publicKey02, initParamSet01, + finishParamSet01, &outData01); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 5.设备B协商密钥 */ + ohResult = HksEcdhAgreeFinish(&g_keyAlias02001, &publicKey01, initParamSet02, + finishParamSet02, &outData02); + } while (0); + free(publicKey01.data); + free(publicKey02.data); + free(outData01.data); + free(outData02.data); + /* 6.设备A、B删除密钥 */ + OH_Huks_DeleteKeyItem(&g_keyAlias01001, genParamSet); + OH_Huks_DeleteKeyItem(&g_keyAlias02001, genParamSet); + OH_Huks_DeleteKeyItem(&g_keyAliasFinal1001, NULL); + OH_Huks_DeleteKeyItem(&g_keyAliasFinal2001, NULL); + OH_Huks_FreeParamSet(&genParamSet); + OH_Huks_FreeParamSet(&initParamSet01); + OH_Huks_FreeParamSet(&finishParamSet01); + OH_Huks_FreeParamSet(&initParamSet02); + OH_Huks_FreeParamSet(&finishParamSet02); + + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} + +// [End key_agreement] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"agreeKey", nullptr, AgreeKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index 2199a476a7..14e3b41480 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 agreeKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets old mode 100755 new mode 100644 index 0b85ce3c4d..89e937336c --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets @@ -1,203 +1,203 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start key_agreement_dh] -/* -*以下以 DH密钥的Promise操作使用为例 -*/ -import { huks } from '@kit.UniversalKeystoreKit'; - -function stringToUint8Array(str: string) { - let arr: number[] = [] - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function uint8ArrayToBigInt(arr: Uint8Array): bigint { - let i = 0 - const byteMax: bigint = BigInt('0x100') - let result: bigint = BigInt('0') - while (i < arr.length) { - result = result * byteMax - result = result + BigInt(arr[i]) - i += 1 - } - return result; -} - -const dhAgree: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DH, -}, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, -}] -const dh2048Agree: huks.HuksParam[] = [ - ...dhAgree, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048, -}] -const dhGenOptions: huks.HuksOptions = { - properties: dh2048Agree, - inData: new Uint8Array([]) -} -const emptyOptions: huks.HuksOptions = { - properties: [], - inData: new Uint8Array([]) -} - -async function huksDhAgreeExportKey(keyAlias: string, - peerPubKey: huks.HuksReturnResult): Promise { - const initHandle = await huks.initSession(keyAlias, dhGenOptions) - const dhAgreeUpdateBobPubKey: huks.HuksOptions = { - properties: [ - ...dh2048Agree, { - tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_KEY_EXPORT_ALLOWED, - }], - inData: peerPubKey.outData - } - await huks.updateSession(initHandle.handle, dhAgreeUpdateBobPubKey) - return await huks.finishSession(initHandle.handle, emptyOptions) -} - -async function huksDhAgreeExportTest( - aliasA: string, aliasB: string, - pubKeyA: huks.HuksReturnResult, pubKeyB: huks.HuksReturnResult) { - - const agreedKeyFromAlice = await huksDhAgreeExportKey(aliasA, pubKeyB); - console.info(`ok! agreedKeyFromAlice export is 0x${uint8ArrayToBigInt(agreedKeyFromAlice.outData).toString(16)}`); - - const agreedKeyFromBob = await huksDhAgreeExportKey(aliasB, pubKeyA); - console.info(`ok! agreedKeyFromBob export is 0x${uint8ArrayToBigInt(agreedKeyFromBob.outData).toString(16)}`); -} - -async function huksDhAgreeInHuks(keyAlias: string, peerPubKey: huks.HuksReturnResult, - aliasAgreedKey: string): Promise { - const onlyUsedInHuks: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, - }, { - tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, - }] - const dhAgreeInit: huks.HuksOptions = { - properties: [ - ...dhAgree, - { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, }, - ...onlyUsedInHuks], - inData: new Uint8Array([]) - } - const dhAgreeFinishParams: huks.HuksParam[] = [ - ...onlyUsedInHuks, - { tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, value: true }, - { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_AES }, - { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }] - - const handle = await huks.initSession(keyAlias, dhAgreeInit) - const dhAgreeUpdatePubKey: huks.HuksOptions = { - properties: [...dhAgree, ...onlyUsedInHuks], - inData: peerPubKey.outData - } - await huks.updateSession(handle.handle, dhAgreeUpdatePubKey) - const dhAgreeAliceFinnish: huks.HuksOptions = { - properties: [...dhAgreeFinishParams, { - tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, value: stringToUint8Array(aliasAgreedKey) - }], inData: new Uint8Array([]) - } - return await huks.finishSession(handle.handle, dhAgreeAliceFinnish); -} - -async function huksDhAgreeInHuksTest( - aliasA: string, aliasB: string, - pubKeyA: huks.HuksReturnResult, pubKeyB: huks.HuksReturnResult, - aliasAgreedKeyFromA: string, aliasAgreedKeyFromB: string) { - - const finishAliceResult = await huksDhAgreeInHuks(aliasA, pubKeyB, aliasAgreedKeyFromA); - console.info(`ok! finishAliceResult in huks is 0x${uint8ArrayToBigInt(finishAliceResult.outData).toString(16)}`); - const aliceAgreedExist = await huks.isKeyItemExist(aliasAgreedKeyFromA, emptyOptions); - console.info(`ok! aliceAgreedExist in huks is ${aliceAgreedExist}`); - - const finishBobResult = await huksDhAgreeInHuks(aliasB, pubKeyA, aliasAgreedKeyFromB); - console.info(`ok! finishBobResult in huks is 0x${uint8ArrayToBigInt(finishBobResult.outData).toString(16)}`); - const bobAgreedExist = await huks.isKeyItemExist(aliasAgreedKeyFromB, emptyOptions); - console.info(`ok! bobAgreedExist in huks is ${bobAgreedExist}`); - - await huks.deleteKeyItem(aliasAgreedKeyFromA, emptyOptions); - await huks.deleteKeyItem(aliasAgreedKeyFromB, emptyOptions); -} - -export default async function huksDhAgreeTest() { - const aliasAlice = 'alice'; - const aliasBob = 'bob'; - - /* 调用generateKeyItem生成别名为alice与bob的两个密钥 */ - await huks.generateKeyItem(aliasAlice, dhGenOptions); - await huks.generateKeyItem(aliasBob, dhGenOptions); - - /* 导出非对称密钥alice与bob的的公钥 */ - const pubKeyAlice = await huks.exportKeyItem(aliasAlice, emptyOptions); - const pubKeyBob = await huks.exportKeyItem(aliasBob, emptyOptions); - - /* 开始协商,协商生成的密钥返回给业务管理 */ - await huksDhAgreeExportTest(aliasAlice, aliasBob, pubKeyAlice, pubKeyBob); - - /* 开始协商,协商生成的密钥由HUKS管理 */ - await huksDhAgreeInHuksTest(aliasAlice, aliasBob, pubKeyAlice, pubKeyBob, 'agreedKeyFromAlice', 'agreedKeyFromBob'); - - await huks.deleteKeyItem(aliasAlice, emptyOptions); - await huks.deleteKeyItem(aliasBob, emptyOptions); -} - - -// [End key_agreement_dh] -@Entry -@Component -struct Index { - @State message: string = 'DH'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.dh')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await huksDhAgreeTest(); - this.message = 'DH Result: Success'; - } catch { - this.message = 'DH Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start key_agreement_dh] +/* +*以下以 DH密钥的Promise操作使用为例 +*/ +import { huks } from '@kit.UniversalKeystoreKit'; + +function stringToUint8Array(str: string) { + let arr: number[] = [] + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function uint8ArrayToBigInt(arr: Uint8Array): bigint { + let i = 0 + const byteMax: bigint = BigInt('0x100') + let result: bigint = BigInt('0') + while (i < arr.length) { + result = result * byteMax + result = result + BigInt(arr[i]) + i += 1 + } + return result; +} + +const dhAgree: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_DH, +}, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, +}] +const dh2048Agree: huks.HuksParam[] = [ + ...dhAgree, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048, +}] +const dhGenOptions: huks.HuksOptions = { + properties: dh2048Agree, + inData: new Uint8Array([]) +} +const emptyOptions: huks.HuksOptions = { + properties: [], + inData: new Uint8Array([]) +} + +async function huksDhAgreeExportKey(keyAlias: string, + peerPubKey: huks.HuksReturnResult): Promise { + const initHandle = await huks.initSession(keyAlias, dhGenOptions) + const dhAgreeUpdateBobPubKey: huks.HuksOptions = { + properties: [ + ...dh2048Agree, { + tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_KEY_EXPORT_ALLOWED, + }], + inData: peerPubKey.outData + } + await huks.updateSession(initHandle.handle, dhAgreeUpdateBobPubKey) + return await huks.finishSession(initHandle.handle, emptyOptions) +} + +async function huksDhAgreeExportTest( + aliasA: string, aliasB: string, + pubKeyA: huks.HuksReturnResult, pubKeyB: huks.HuksReturnResult) { + + const agreedKeyFromAlice = await huksDhAgreeExportKey(aliasA, pubKeyB); + console.info(`ok! agreedKeyFromAlice export is 0x${uint8ArrayToBigInt(agreedKeyFromAlice.outData).toString(16)}`); + + const agreedKeyFromBob = await huksDhAgreeExportKey(aliasB, pubKeyA); + console.info(`ok! agreedKeyFromBob export is 0x${uint8ArrayToBigInt(agreedKeyFromBob.outData).toString(16)}`); +} + +async function huksDhAgreeInHuks(keyAlias: string, peerPubKey: huks.HuksReturnResult, + aliasAgreedKey: string): Promise { + const onlyUsedInHuks: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, + }, { + tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, + }] + const dhAgreeInit: huks.HuksOptions = { + properties: [ + ...dhAgree, + { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, }, + ...onlyUsedInHuks], + inData: new Uint8Array([]) + } + const dhAgreeFinishParams: huks.HuksParam[] = [ + ...onlyUsedInHuks, + { tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, value: true }, + { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_AES }, + { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }] + + const handle = await huks.initSession(keyAlias, dhAgreeInit) + const dhAgreeUpdatePubKey: huks.HuksOptions = { + properties: [...dhAgree, ...onlyUsedInHuks], + inData: peerPubKey.outData + } + await huks.updateSession(handle.handle, dhAgreeUpdatePubKey) + const dhAgreeAliceFinnish: huks.HuksOptions = { + properties: [...dhAgreeFinishParams, { + tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, value: stringToUint8Array(aliasAgreedKey) + }], inData: new Uint8Array([]) + } + return await huks.finishSession(handle.handle, dhAgreeAliceFinnish); +} + +async function huksDhAgreeInHuksTest( + aliasA: string, aliasB: string, + pubKeyA: huks.HuksReturnResult, pubKeyB: huks.HuksReturnResult, + aliasAgreedKeyFromA: string, aliasAgreedKeyFromB: string) { + + const finishAliceResult = await huksDhAgreeInHuks(aliasA, pubKeyB, aliasAgreedKeyFromA); + console.info(`ok! finishAliceResult in huks is 0x${uint8ArrayToBigInt(finishAliceResult.outData).toString(16)}`); + const aliceAgreedExist = await huks.isKeyItemExist(aliasAgreedKeyFromA, emptyOptions); + console.info(`ok! aliceAgreedExist in huks is ${aliceAgreedExist}`); + + const finishBobResult = await huksDhAgreeInHuks(aliasB, pubKeyA, aliasAgreedKeyFromB); + console.info(`ok! finishBobResult in huks is 0x${uint8ArrayToBigInt(finishBobResult.outData).toString(16)}`); + const bobAgreedExist = await huks.isKeyItemExist(aliasAgreedKeyFromB, emptyOptions); + console.info(`ok! bobAgreedExist in huks is ${bobAgreedExist}`); + + await huks.deleteKeyItem(aliasAgreedKeyFromA, emptyOptions); + await huks.deleteKeyItem(aliasAgreedKeyFromB, emptyOptions); +} + +export default async function huksDhAgreeTest() { + const aliasAlice = 'alice'; + const aliasBob = 'bob'; + + /* 调用generateKeyItem生成别名为alice与bob的两个密钥 */ + await huks.generateKeyItem(aliasAlice, dhGenOptions); + await huks.generateKeyItem(aliasBob, dhGenOptions); + + /* 导出非对称密钥alice与bob的的公钥 */ + const pubKeyAlice = await huks.exportKeyItem(aliasAlice, emptyOptions); + const pubKeyBob = await huks.exportKeyItem(aliasBob, emptyOptions); + + /* 开始协商,协商生成的密钥返回给业务管理 */ + await huksDhAgreeExportTest(aliasAlice, aliasBob, pubKeyAlice, pubKeyBob); + + /* 开始协商,协商生成的密钥由HUKS管理 */ + await huksDhAgreeInHuksTest(aliasAlice, aliasBob, pubKeyAlice, pubKeyBob, 'agreedKeyFromAlice', 'agreedKeyFromBob'); + + await huks.deleteKeyItem(aliasAlice, emptyOptions); + await huks.deleteKeyItem(aliasBob, emptyOptions); +} + + +// [End key_agreement_dh] +@Entry +@Component +struct Index { + @State message: string = 'DH'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.dh')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await huksDhAgreeTest(); + this.message = 'DH Result: Success'; + } catch { + this.message = 'DH Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets old mode 100755 new mode 100644 index 8f9ea4b9b0..85af04b563 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets @@ -1,427 +1,427 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start key_agreement_X25519] - -/* -*以下以X25519密钥的Promise操作使用为例 -*/ -import { huks } from '@kit.UniversalKeystoreKit'; - -/* -* 确定密钥别名和封装密钥属性参数集 -*/ -let srcKeyAliasFirst = 'AgreeX25519KeyFirstAlias'; -let srcKeyAliasSecond = 'AgreeX25519KeySecondAlias'; -let agreeX25519InData = 'AgreeX25519TestIndata'; -let finishOutData: Uint8Array; -let handle: number; -let exportKey: Uint8Array; -let exportKeyFirst: Uint8Array; -let exportKeySecond: Uint8Array; -/* 集成生成密钥参数集 */ -let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_X25519, -}, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, -}, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, -}, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, -}, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, -}, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, -}, { - tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, -}]; -let huksOptions: huks.HuksOptions = { - properties: properties, - inData: new Uint8Array([]) -} -/* 集成第一个协商参数集 */ -const finishProperties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, -}, { - tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, - value: true -}, { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, -}, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, -}, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, -}, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, -}, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, -}, { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB, -}]; -let finishOptionsFirst: huks.HuksOptions = { - properties: [ - ...finishProperties, { - tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliasFirst + 'final'), - }], - inData: stringToUint8Array(agreeX25519InData) -} -/* 集成第二个协商参数集 */ -let finishOptionsSecond: huks.HuksOptions = { - properties: [ - ...finishProperties, { - tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliasSecond + 'final'), - }], - inData: stringToUint8Array(agreeX25519InData) -} - -function stringToUint8Array(str: string) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -class ThrowObject { - public isThrow: boolean = false -} - -/* 生成密钥 */ -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -/* 调用generateKeyItem生成密钥 */ -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise generateKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await generateKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -/*初始化密钥会话接口,并获取一个句柄(必选)和挑战值(可选)*/ -function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.initSession(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -/*调用initSession获取handle*/ -async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise doInit`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await initSession(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - handle = data.handle; - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doInit failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -/* 分段添加密钥操作的数据并进行相应的密钥操作,输出处理数据 */ -function updateSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.updateSession(handle, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -/* 调用updateSession进行协商操作 */ -async function publicUpdateFunc(handle: number, huksOptions: huks.HuksOptions) { - console.info(`enter promise doUpdate`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await updateSession(handle, huksOptions, throwObject) - .then((data) => { - console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -/* 结束密钥会话并进行相应的密钥操作,输出处理数据 */ -function finishSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.finishSession(handle, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -/* 调用finishSession结束操作 */ -async function publicFinishFunc(handle: number, huksOptions: huks.HuksOptions) { - console.info(`enter promise doFinish`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await finishSession(handle, huksOptions, throwObject) - .then((data) => { - finishOutData = data.outData as Uint8Array; - console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: doFinish failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -/* 导出密钥 */ -function exportKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.exportKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -/* 调用exportKeyItem导出公钥操作 */ -async function publicExportKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise export`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await exportKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: exportKeyItem success, data = ${JSON.stringify(data)}`); - exportKey = data.outData as Uint8Array; - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: exportKeyItem failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: exportKeyItem input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -/* 删除密钥操作 */ -function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { - return new Promise((resolve, reject) => { - try { - huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw (error as Error); - } - }); -} - -/* 调用deleteKeyItem删除密钥操作 */ -async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { - console.info(`enter promise deleteKeyItem`); - let throwObject: ThrowObject = { isThrow: false }; - try { - await deleteKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - if (throwObject.isThrow) { - throw (error as Error); - } else { - console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`); - throw (error as Error); - } - }); - } catch (error) { - console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`); - throw (error as Error); - } -} - -async function testAgree() { - /* 1.确定密钥别名并集成并集成要参数集 A设备:srcKeyAliasFirst B设备:srcKeyAliasSecond*/ - /* 2.设备A生成密钥 */ - await publicGenKeyFunc(srcKeyAliasFirst, huksOptions); - /* 3.设备B生成密钥 */ - await publicGenKeyFunc(srcKeyAliasSecond, huksOptions); - /* 4.设备A、B导出非对称密钥的公钥 */ - await publicExportKeyFunc(srcKeyAliasFirst, huksOptions); - exportKeyFirst = exportKey; - await publicExportKeyFunc(srcKeyAliasSecond, huksOptions); - exportKeySecond = exportKey; - /* 5.对第一个密钥进行协商(三段式)*/ - await publicInitFunc(srcKeyAliasFirst, huksOptions); - huksOptions.inData = exportKeySecond; - await publicUpdateFunc(handle, huksOptions); - await publicFinishFunc(handle, finishOptionsFirst); - /* 5.对第二个密钥进行协商(三段式) */ - await publicInitFunc(srcKeyAliasSecond, huksOptions); - huksOptions.inData = exportKeyFirst; - await publicUpdateFunc(handle, huksOptions); - await publicFinishFunc(handle, finishOptionsSecond); - /* 6.设备A、B删除密钥 */ - await publicDeleteKeyFunc(srcKeyAliasFirst, huksOptions); - await publicDeleteKeyFunc(srcKeyAliasSecond, huksOptions); -} - - -// [End key_agreement_X25519] -@Entry -@Component -struct Index { - @State message: string = 'X25519'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.x25519')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await testAgree(); - this.message = 'X25519 Result: Success'; - } catch { - this.message = 'X25519 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start key_agreement_X25519] + +/* +*以下以X25519密钥的Promise操作使用为例 +*/ +import { huks } from '@kit.UniversalKeystoreKit'; + +/* +* 确定密钥别名和封装密钥属性参数集 +*/ +let srcKeyAliasFirst = 'AgreeX25519KeyFirstAlias'; +let srcKeyAliasSecond = 'AgreeX25519KeySecondAlias'; +let agreeX25519InData = 'AgreeX25519TestIndata'; +let finishOutData: Uint8Array; +let handle: number; +let exportKey: Uint8Array; +let exportKeyFirst: Uint8Array; +let exportKeySecond: Uint8Array; +/* 集成生成密钥参数集 */ +let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_X25519, +}, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, +}, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, +}, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, +}, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE, +}, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC, +}, { + tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, +}]; +let huksOptions: huks.HuksOptions = { + properties: properties, + inData: new Uint8Array([]) +} +/* 集成第一个协商参数集 */ +const finishProperties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS, +}, { + tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, + value: true +}, { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES, +}, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, +}, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, +}, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, +}, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE, +}, { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB, +}]; +let finishOptionsFirst: huks.HuksOptions = { + properties: [ + ...finishProperties, { + tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliasFirst + 'final'), + }], + inData: stringToUint8Array(agreeX25519InData) +} +/* 集成第二个协商参数集 */ +let finishOptionsSecond: huks.HuksOptions = { + properties: [ + ...finishProperties, { + tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliasSecond + 'final'), + }], + inData: stringToUint8Array(agreeX25519InData) +} + +function stringToUint8Array(str: string) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +class ThrowObject { + public isThrow: boolean = false +} + +/* 生成密钥 */ +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +/* 调用generateKeyItem生成密钥 */ +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise generateKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await generateKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +/*初始化密钥会话接口,并获取一个句柄(必选)和挑战值(可选)*/ +function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.initSession(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +/*调用initSession获取handle*/ +async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise doInit`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await initSession(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doInit failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +/* 分段添加密钥操作的数据并进行相应的密钥操作,输出处理数据 */ +function updateSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.updateSession(handle, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +/* 调用updateSession进行协商操作 */ +async function publicUpdateFunc(handle: number, huksOptions: huks.HuksOptions) { + console.info(`enter promise doUpdate`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await updateSession(handle, huksOptions, throwObject) + .then((data) => { + console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +/* 结束密钥会话并进行相应的密钥操作,输出处理数据 */ +function finishSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +/* 调用finishSession结束操作 */ +async function publicFinishFunc(handle: number, huksOptions: huks.HuksOptions) { + console.info(`enter promise doFinish`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await finishSession(handle, huksOptions, throwObject) + .then((data) => { + finishOutData = data.outData as Uint8Array; + console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: doFinish failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +/* 导出密钥 */ +function exportKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.exportKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +/* 调用exportKeyItem导出公钥操作 */ +async function publicExportKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise export`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await exportKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: exportKeyItem success, data = ${JSON.stringify(data)}`); + exportKey = data.outData as Uint8Array; + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: exportKeyItem failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: exportKeyItem input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +/* 删除密钥操作 */ +function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw (error as Error); + } + }); +} + +/* 调用deleteKeyItem删除密钥操作 */ +async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) { + console.info(`enter promise deleteKeyItem`); + let throwObject: ThrowObject = { isThrow: false }; + try { + await deleteKeyItem(keyAlias, huksOptions, throwObject) + .then((data) => { + console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + if (throwObject.isThrow) { + throw (error as Error); + } else { + console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`); + throw (error as Error); + } + }); + } catch (error) { + console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`); + throw (error as Error); + } +} + +async function testAgree() { + /* 1.确定密钥别名并集成并集成要参数集 A设备:srcKeyAliasFirst B设备:srcKeyAliasSecond*/ + /* 2.设备A生成密钥 */ + await publicGenKeyFunc(srcKeyAliasFirst, huksOptions); + /* 3.设备B生成密钥 */ + await publicGenKeyFunc(srcKeyAliasSecond, huksOptions); + /* 4.设备A、B导出非对称密钥的公钥 */ + await publicExportKeyFunc(srcKeyAliasFirst, huksOptions); + exportKeyFirst = exportKey; + await publicExportKeyFunc(srcKeyAliasSecond, huksOptions); + exportKeySecond = exportKey; + /* 5.对第一个密钥进行协商(三段式)*/ + await publicInitFunc(srcKeyAliasFirst, huksOptions); + huksOptions.inData = exportKeySecond; + await publicUpdateFunc(handle, huksOptions); + await publicFinishFunc(handle, finishOptionsFirst); + /* 5.对第二个密钥进行协商(三段式) */ + await publicInitFunc(srcKeyAliasSecond, huksOptions); + huksOptions.inData = exportKeyFirst; + await publicUpdateFunc(handle, huksOptions); + await publicFinishFunc(handle, finishOptionsSecond); + /* 6.设备A、B删除密钥 */ + await publicDeleteKeyFunc(srcKeyAliasFirst, huksOptions); + await publicDeleteKeyFunc(srcKeyAliasSecond, huksOptions); +} + + +// [End key_agreement_X25519] +@Entry +@Component +struct Index { + @State message: string = 'X25519'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.x25519')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await testAgree(); + this.message = 'X25519 Result: Success'; + } catch { + this.message = 'X25519 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/KeyExchange.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/KeyExchange.test.ets old mode 100755 new mode 100644 index 0391b7f858..7219b914f0 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/KeyExchange.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/KeyExchange.test.ets @@ -1,95 +1,95 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function keyExchangeTest() { - describe('keyExchangeTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,X25519非对称密钥协商 - */ - it('testKeyExchange001', 0, async () => { - console.info('uitest: testKeyExchange001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('X25519')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('X25519').type('Button')); - await button2.click(); - await driver.delayMs(3500); - await driver.assertComponentExist(ON.text('X25519 Result: Success')); - console.info('uitest: testKeyExchange001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,DH密钥协商 - */ - it('testKeyExchange002', 0, async () => { - console.info('uitest: testKeyExchange002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('DH')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('DH').type('Button')); - await button2.click(); - await driver.delayMs(3500); - await driver.assertComponentExist(ON.text('DH Result: Success')); - console.info('uitest: testKeyExchange002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,密钥协商(C/C++) - */ - it('testKeyExchange003', 0, async () => { - console.info('uitest: testKeyExchange003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testKeyExchange003 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function keyExchangeTest() { + describe('keyExchangeTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,X25519非对称密钥协商 + */ + it('testKeyExchange001', 0, async () => { + console.info('uitest: testKeyExchange001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('X25519')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('X25519').type('Button')); + await button2.click(); + await driver.delayMs(3500); + await driver.assertComponentExist(ON.text('X25519 Result: Success')); + console.info('uitest: testKeyExchange001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,DH密钥协商 + */ + it('testKeyExchange002', 0, async () => { + console.info('uitest: testKeyExchange002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('DH')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('DH').type('Button')); + await button2.click(); + await driver.delayMs(3500); + await driver.assertComponentExist(ON.text('DH Result: Success')); + console.info('uitest: testKeyExchange002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,密钥协商(C/C++) + */ + it('testKeyExchange003', 0, async () => { + console.info('uitest: testKeyExchange003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testKeyExchange003 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/ohosTest.md old mode 100755 new mode 100644 index 59477d1624..d4941cce1b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/ohosTest.md @@ -1,10 +1,10 @@ -# 密钥协商测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------ | ------------ | ---- | ------------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,X25519非对称密钥协商 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | -| 点击按钮,DH密钥协商 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +# 密钥协商测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------ | ------------ | ---- | ------------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,X25519非对称密钥协商 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +| 点击按钮,DH密钥协商 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | | 点击按钮,密钥协商(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/app.json5 old mode 100755 new mode 100644 index 834bf80281..681c2bb041 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/app.json5 @@ -1,25 +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.signingverification", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.signingverification", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index a814cae425..5244c89a0e --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SigningVerification" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "SigningVerification" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/README.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index ac96cbc6e7..376c5456c7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(SigningVerification) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(SigningVerification) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index ebef8418eb..590b3d4417 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp @@ -1,167 +1,167 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start signature_verification_supported_algorithms] -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include - -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} - -static struct OH_Huks_Param g_genSignVerifyParamsTest[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_SIGN | OH_HUKS_KEY_PURPOSE_VERIFY}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}, -}; - -static struct OH_Huks_Param g_signParamsTest[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_SIGN}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}}; - -static struct OH_Huks_Param g_verifyParamsTest[] = { - {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_VERIFY}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048}, - {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}}; - -static const uint32_t RSA_COMMON_SIZE = 1024; -static const char *DATA_TO_SIGN = "Hks_RSA_Sign_Verify_Test_0000000000000000000000000000000000000000000000000000000" - "00000000000000000000000000000000000000000000000000000000000000000000000000000000" - "0000000000000000000000000000000000000000000000000000000000000000000000000_string"; - -static napi_value SignVerifyKey(napi_env env, napi_callback_info info) -{ - struct OH_Huks_Blob g_keyAlias = {(uint32_t)strlen("test_signVerify"), (uint8_t *)"test_signVerify"}; - struct OH_Huks_Blob inData = {(uint32_t)strlen(DATA_TO_SIGN), (uint8_t *)DATA_TO_SIGN}; - struct OH_Huks_ParamSet *genParamSet = nullptr; - struct OH_Huks_ParamSet *signParamSet = nullptr; - struct OH_Huks_ParamSet *verifyParamSet = nullptr; - OH_Huks_Result ohResult; - do { - ohResult = InitParamSet(&genParamSet, g_genSignVerifyParamsTest, - sizeof(g_genSignVerifyParamsTest) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = InitParamSet(&signParamSet, g_signParamsTest, sizeof(g_signParamsTest) / - sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - ohResult = - InitParamSet(&verifyParamSet, g_verifyParamsTest, sizeof(g_verifyParamsTest) / - sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 1. Generate Key */ - ohResult = OH_Huks_GenerateKeyItem(&g_keyAlias, genParamSet, nullptr); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 2. Sign */ - // Init - uint8_t handleS[sizeof(uint64_t)] = {0}; - struct OH_Huks_Blob handleSign = {(uint32_t)sizeof(uint64_t), handleS}; - ohResult = OH_Huks_InitSession(&g_keyAlias, signParamSet, &handleSign, nullptr); - // Update - uint8_t outDataS[RSA_COMMON_SIZE] = {0}; - struct OH_Huks_Blob outDataSign = {RSA_COMMON_SIZE, outDataS}; - ohResult = OH_Huks_UpdateSession(&handleSign, signParamSet, &inData, &outDataSign); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - // Finish - struct OH_Huks_Blob finishInData = {0, NULL}; - ohResult = OH_Huks_FinishSession(&handleSign, signParamSet, &finishInData, &outDataSign); - - /* 3. Verify */ - // Init - uint8_t handleV[sizeof(uint64_t)] = {0}; - struct OH_Huks_Blob handleVerify = {(uint32_t)sizeof(uint64_t), handleV}; - ohResult = OH_Huks_InitSession(&g_keyAlias, verifyParamSet, &handleVerify, nullptr); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - // Update loop - uint8_t temp[] = "out"; - struct OH_Huks_Blob verifyOut = {(uint32_t)sizeof(temp), temp}; - ohResult = OH_Huks_UpdateSession(&handleVerify, verifyParamSet, &inData, &verifyOut); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - // Finish - ohResult = OH_Huks_FinishSession(&handleVerify, verifyParamSet, &outDataSign, &verifyOut); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - } while (0); - (void)OH_Huks_DeleteKeyItem(&g_keyAlias, genParamSet); - OH_Huks_FreeParamSet(&genParamSet); - OH_Huks_FreeParamSet(&signParamSet); - OH_Huks_FreeParamSet(&verifyParamSet); - - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} - - -// [End signature_verification_supported_algorithms] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - {"signVerifyKey", nullptr, SignVerifyKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void *)0), - .reserved = {0}, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start signature_verification_supported_algorithms] +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include + +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} + +static struct OH_Huks_Param g_genSignVerifyParamsTest[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_SIGN | OH_HUKS_KEY_PURPOSE_VERIFY}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}, +}; + +static struct OH_Huks_Param g_signParamsTest[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_SIGN}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}}; + +static struct OH_Huks_Param g_verifyParamsTest[] = { + {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_VERIFY}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048}, + {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}}; + +static const uint32_t RSA_COMMON_SIZE = 1024; +static const char *DATA_TO_SIGN = "Hks_RSA_Sign_Verify_Test_0000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000000000000_string"; + +static napi_value SignVerifyKey(napi_env env, napi_callback_info info) +{ + struct OH_Huks_Blob g_keyAlias = {(uint32_t)strlen("test_signVerify"), (uint8_t *)"test_signVerify"}; + struct OH_Huks_Blob inData = {(uint32_t)strlen(DATA_TO_SIGN), (uint8_t *)DATA_TO_SIGN}; + struct OH_Huks_ParamSet *genParamSet = nullptr; + struct OH_Huks_ParamSet *signParamSet = nullptr; + struct OH_Huks_ParamSet *verifyParamSet = nullptr; + OH_Huks_Result ohResult; + do { + ohResult = InitParamSet(&genParamSet, g_genSignVerifyParamsTest, + sizeof(g_genSignVerifyParamsTest) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = InitParamSet(&signParamSet, g_signParamsTest, sizeof(g_signParamsTest) / + sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + ohResult = + InitParamSet(&verifyParamSet, g_verifyParamsTest, sizeof(g_verifyParamsTest) / + sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 1. Generate Key */ + ohResult = OH_Huks_GenerateKeyItem(&g_keyAlias, genParamSet, nullptr); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 2. Sign */ + // Init + uint8_t handleS[sizeof(uint64_t)] = {0}; + struct OH_Huks_Blob handleSign = {(uint32_t)sizeof(uint64_t), handleS}; + ohResult = OH_Huks_InitSession(&g_keyAlias, signParamSet, &handleSign, nullptr); + // Update + uint8_t outDataS[RSA_COMMON_SIZE] = {0}; + struct OH_Huks_Blob outDataSign = {RSA_COMMON_SIZE, outDataS}; + ohResult = OH_Huks_UpdateSession(&handleSign, signParamSet, &inData, &outDataSign); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + // Finish + struct OH_Huks_Blob finishInData = {0, NULL}; + ohResult = OH_Huks_FinishSession(&handleSign, signParamSet, &finishInData, &outDataSign); + + /* 3. Verify */ + // Init + uint8_t handleV[sizeof(uint64_t)] = {0}; + struct OH_Huks_Blob handleVerify = {(uint32_t)sizeof(uint64_t), handleV}; + ohResult = OH_Huks_InitSession(&g_keyAlias, verifyParamSet, &handleVerify, nullptr); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + // Update loop + uint8_t temp[] = "out"; + struct OH_Huks_Blob verifyOut = {(uint32_t)sizeof(temp), temp}; + ohResult = OH_Huks_UpdateSession(&handleVerify, verifyParamSet, &inData, &verifyOut); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + // Finish + ohResult = OH_Huks_FinishSession(&handleVerify, verifyParamSet, &outDataSign, &verifyOut); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + } while (0); + (void)OH_Huks_DeleteKeyItem(&g_keyAlias, genParamSet); + OH_Huks_FreeParamSet(&genParamSet); + OH_Huks_FreeParamSet(&signParamSet); + OH_Huks_FreeParamSet(&verifyParamSet); + + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} + + +// [End signature_verification_supported_algorithms] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"signVerifyKey", nullptr, SignVerifyKey, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index d451b1ef88..d5ab382499 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 signVerifyKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets old mode 100755 new mode 100644 index 8e7e018ab2..3830abfe8d --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets @@ -1,215 +1,215 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start key_algorithm_ECC256SHA256] -/* - * 密钥算法为ECC256、摘要算法为SHA256 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -let keyAlias = 'test_eccKeyAlias'; -let handle: number; -let plaintext = '123456'; -let signature: Uint8Array; - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function uint8ArrayToString(fileData: Uint8Array) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - -function getEccGenerateProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }]; - return properties; -} - -function getEccSignProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }]; - return properties; -} - -function getEccVerifyProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }]; - return properties; -} - -async function generateEccKey(keyAlias: string) { - let genProperties = getEccGenerateProperties(); - let options: huks.HuksOptions = { - properties: genProperties - } - await huks.generateKeyItem(keyAlias, options) - .then((data) => { - console.info(`promise: generate ECC Key success, data = ${JSON.stringify(data)}`); - }).catch((err: Error) => { - console.error(`promise: generate ECC Key failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) -} - -async function sign(keyAlias: string, plaintext: string) { - let signProperties = getEccSignProperties(); - let options: huks.HuksOptions = { - properties: signProperties, - inData: stringToUint8Array(plaintext) - } - await huks.initSession(keyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((err: Error) => { - console.error(`promise: init sign failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - signature = data.outData as Uint8Array; - }).catch((err: Error) => { - console.error(`promise: sign failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) -} - -async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) { - let verifyProperties = getEccVerifyProperties() - let options: huks.HuksOptions = { - properties: verifyProperties, - inData: stringToUint8Array(plaintext) - } - await huks.initSession(keyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((err: Error) => { - console.error(`promise: init verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) - await huks.updateSession(handle, options) - .then((data) => { - console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((err: Error) => { - console.error(`promise: update verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) - options.inData = signature; - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((err: Error) => { - console.error(`promise: verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) -} - -async function deleteEccKey(keyAlias: string) { - let emptyOptions: huks.HuksOptions = { - properties: [] - } - await huks.deleteKeyItem(keyAlias, emptyOptions) - .then((data) => { - console.info(`promise: delete data success`); - }).catch((err: Error) => { - console.error(`promise: delete data failed`); - throw (err as Error); - }) -} - -async function testSignVerify() { - await generateEccKey(keyAlias); - await sign(keyAlias, plaintext); - await verify(keyAlias, plaintext, signature); - await deleteEccKey(keyAlias); -} - - -// [End key_algorithm_ECC256SHA256] -@Entry -@Component -struct Index { - @State message: string = 'ECC256/SHA256'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.ecc256_sha256')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await testSignVerify(); - this.message = 'ECC256/SHA256 Result: Success'; - } catch (error) { - this.message = 'ECC256/SHA256 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start key_algorithm_ECC256SHA256] +/* + * 密钥算法为ECC256、摘要算法为SHA256 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +let keyAlias = 'test_eccKeyAlias'; +let handle: number; +let plaintext = '123456'; +let signature: Uint8Array; + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function uint8ArrayToString(fileData: Uint8Array) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + +function getEccGenerateProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_ECC + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }]; + return properties; +} + +function getEccSignProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_ECC + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }]; + return properties; +} + +function getEccVerifyProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_ECC + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }]; + return properties; +} + +async function generateEccKey(keyAlias: string) { + let genProperties = getEccGenerateProperties(); + let options: huks.HuksOptions = { + properties: genProperties + } + await huks.generateKeyItem(keyAlias, options) + .then((data) => { + console.info(`promise: generate ECC Key success, data = ${JSON.stringify(data)}`); + }).catch((err: Error) => { + console.error(`promise: generate ECC Key failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) +} + +async function sign(keyAlias: string, plaintext: string) { + let signProperties = getEccSignProperties(); + let options: huks.HuksOptions = { + properties: signProperties, + inData: stringToUint8Array(plaintext) + } + await huks.initSession(keyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((err: Error) => { + console.error(`promise: init sign failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + signature = data.outData as Uint8Array; + }).catch((err: Error) => { + console.error(`promise: sign failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) +} + +async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) { + let verifyProperties = getEccVerifyProperties() + let options: huks.HuksOptions = { + properties: verifyProperties, + inData: stringToUint8Array(plaintext) + } + await huks.initSession(keyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((err: Error) => { + console.error(`promise: init verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) + await huks.updateSession(handle, options) + .then((data) => { + console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((err: Error) => { + console.error(`promise: update verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) + options.inData = signature; + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((err: Error) => { + console.error(`promise: verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) +} + +async function deleteEccKey(keyAlias: string) { + let emptyOptions: huks.HuksOptions = { + properties: [] + } + await huks.deleteKeyItem(keyAlias, emptyOptions) + .then((data) => { + console.info(`promise: delete data success`); + }).catch((err: Error) => { + console.error(`promise: delete data failed`); + throw (err as Error); + }) +} + +async function testSignVerify() { + await generateEccKey(keyAlias); + await sign(keyAlias, plaintext); + await verify(keyAlias, plaintext, signature); + await deleteEccKey(keyAlias); +} + + +// [End key_algorithm_ECC256SHA256] +@Entry +@Component +struct Index { + @State message: string = 'ECC256/SHA256'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.ecc256_sha256')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await testSignVerify(); + this.message = 'ECC256/SHA256 Result: Success'; + } catch (error) { + this.message = 'ECC256/SHA256 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets old mode 100755 new mode 100644 index 8d9bd58978..ef2f7a2043 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets @@ -1,219 +1,219 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start key_algorithm_RSASHA256PKCS1_V1_5] -/* - * 密钥算法为RSA,摘要算法为SHA256,填充模式为PKCS1_V1_5 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -let keyAlias = 'test_rsaKeyAlias'; -let handle: number; -let plaintext = '123456'; -let signature: Uint8Array; - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function uint8ArrayToString(fileData: Uint8Array) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - -function getRsaGenerateProperties() { - let properties: huks.HuksParam[] = [ - { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_RSA }, - { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, - { tag: huks.HuksTag.HUKS_TAG_PADDING, value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 }, - { tag: huks.HuksTag.HUKS_TAG_DIGEST, value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 } - ]; - return properties; -} - -function getRsaSignProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }]; - return properties; -} - -function getRsaVerifyProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }]; - return properties; -} - -async function generateRsaKey(keyAlias: string) { - let genProperties = getRsaGenerateProperties(); - let options: huks.HuksOptions = { - properties: genProperties - } - await huks.generateKeyItem(keyAlias, options) - .then((data) => { - console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`); - }).catch((err: Error) => { - console.error(`promise: generate RSA Key failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) -} - -async function sign(keyAlias: string, plaintext: string) { - let signProperties = getRsaSignProperties(); - let options: huks.HuksOptions = { - properties: signProperties, - inData: stringToUint8Array(plaintext) - } - await huks.initSession(keyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((err: Error) => { - console.error(`promise: init sign failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - signature = data.outData as Uint8Array; - }).catch((err: Error) => { - console.error(`promise: sign failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) -} - -async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) { - let verifyProperties = getRsaVerifyProperties() - let options: huks.HuksOptions = { - properties: verifyProperties, - inData: stringToUint8Array(plaintext) - } - await huks.initSession(keyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((err: Error) => { - console.error(`promise: init verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) - await huks.updateSession(handle, options) - .then((data) => { - console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((err: Error) => { - console.error(`promise: update verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) - options.inData = signature; - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((err: Error) => { - console.error(`promise: verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) -} - -async function deleteRsaKey(keyAlias: string) { - let emptyOptions: huks.HuksOptions = { - properties: [] - } - await huks.deleteKeyItem(keyAlias, emptyOptions) - .then((data) => { - console.info(`promise: delete data success`); - }).catch((err: Error) => { - console.error(`promise: delete data failed`); - throw (err as Error); - }) -} - -export async function testSignVerify() { - await generateRsaKey(keyAlias); - await sign(keyAlias, plaintext); - await verify(keyAlias, plaintext, signature); - await deleteRsaKey(keyAlias); -} - - - -// [End key_algorithm_RSASHA256PKCS1_V1_5] -@Entry -@Component -struct Index { - @State message: string = 'RSA/SHA256/PKCS1_V1_5'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.rsa_sha256_pkcs1_v1_5')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await testSignVerify(); - this.message = 'RSA/SHA256/PKCS1_V1_5 Result: Success'; - } catch (error) { - this.message = 'RSA/SHA256/PKCS1_V1_5 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start key_algorithm_RSASHA256PKCS1_V1_5] +/* + * 密钥算法为RSA,摘要算法为SHA256,填充模式为PKCS1_V1_5 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +let keyAlias = 'test_rsaKeyAlias'; +let handle: number; +let plaintext = '123456'; +let signature: Uint8Array; + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function uint8ArrayToString(fileData: Uint8Array) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + +function getRsaGenerateProperties() { + let properties: huks.HuksParam[] = [ + { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_RSA }, + { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, + { tag: huks.HuksTag.HUKS_TAG_PADDING, value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 }, + { tag: huks.HuksTag.HUKS_TAG_DIGEST, value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 } + ]; + return properties; +} + +function getRsaSignProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }]; + return properties; +} + +function getRsaVerifyProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }]; + return properties; +} + +async function generateRsaKey(keyAlias: string) { + let genProperties = getRsaGenerateProperties(); + let options: huks.HuksOptions = { + properties: genProperties + } + await huks.generateKeyItem(keyAlias, options) + .then((data) => { + console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`); + }).catch((err: Error) => { + console.error(`promise: generate RSA Key failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) +} + +async function sign(keyAlias: string, plaintext: string) { + let signProperties = getRsaSignProperties(); + let options: huks.HuksOptions = { + properties: signProperties, + inData: stringToUint8Array(plaintext) + } + await huks.initSession(keyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((err: Error) => { + console.error(`promise: init sign failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + signature = data.outData as Uint8Array; + }).catch((err: Error) => { + console.error(`promise: sign failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) +} + +async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) { + let verifyProperties = getRsaVerifyProperties() + let options: huks.HuksOptions = { + properties: verifyProperties, + inData: stringToUint8Array(plaintext) + } + await huks.initSession(keyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((err: Error) => { + console.error(`promise: init verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) + await huks.updateSession(handle, options) + .then((data) => { + console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((err: Error) => { + console.error(`promise: update verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) + options.inData = signature; + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((err: Error) => { + console.error(`promise: verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) +} + +async function deleteRsaKey(keyAlias: string) { + let emptyOptions: huks.HuksOptions = { + properties: [] + } + await huks.deleteKeyItem(keyAlias, emptyOptions) + .then((data) => { + console.info(`promise: delete data success`); + }).catch((err: Error) => { + console.error(`promise: delete data failed`); + throw (err as Error); + }) +} + +export async function testSignVerify() { + await generateRsaKey(keyAlias); + await sign(keyAlias, plaintext); + await verify(keyAlias, plaintext, signature); + await deleteRsaKey(keyAlias); +} + + + +// [End key_algorithm_RSASHA256PKCS1_V1_5] +@Entry +@Component +struct Index { + @State message: string = 'RSA/SHA256/PKCS1_V1_5'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.rsa_sha256_pkcs1_v1_5')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await testSignVerify(); + this.message = 'RSA/SHA256/PKCS1_V1_5 Result: Success'; + } catch (error) { + this.message = 'RSA/SHA256/PKCS1_V1_5 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets old mode 100755 new mode 100644 index 1f9a89692c..eb1ae9e3c7 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets @@ -1,226 +1,226 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// [Start key_algorithm_RSASHA256PSS] -/* - * 密钥算法为RSA,摘要算法为SHA256,填充模式为PSS - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -let keyAlias = 'test_rsaKeyAlias'; -let handle: number; -let plaintext = '123456'; -let signature: Uint8Array; - -function stringToUint8Array(str: string) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function uint8ArrayToString(fileData: Uint8Array) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - -function getRsaGenerateProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PSS - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }]; - return properties; -} - -function getRsaSignProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PSS - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN - }]; - return properties; -} - -function getRsaVerifyProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }, { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PSS - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }]; - return properties; -} - -async function generateRsaKey(keyAlias: string) { - let genProperties = getRsaGenerateProperties(); - let options: huks.HuksOptions = { - properties: genProperties - }; - await huks.generateKeyItem(keyAlias, options) - .then((data) => { - console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`); - }).catch((err: Error) => { - console.error(`promise: generate RSA Key failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }); -} - -async function sign(keyAlias: string, plaintext: string) { - let signProperties = getRsaSignProperties(); - let options: huks.HuksOptions = { - properties: signProperties, - inData: stringToUint8Array(plaintext) - } - await huks.initSession(keyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((err: Error) => { - console.error(`promise: init sign failed, error: ` + JSON.stringify(err)); - return; - }); - - if (handle !== undefined) { - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - signature = data.outData as Uint8Array; - }).catch((err: Error) => { - console.error(`promise: sign failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }); - } -} - -async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) { - let verifyProperties = getRsaVerifyProperties(); - let options: huks.HuksOptions = { - properties: verifyProperties, - inData: stringToUint8Array(plaintext) - } - await huks.initSession(keyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((err: Error) => { - console.error(`promise: init verify failed, error: ` + JSON.stringify(err)); - return; - }); - - if (handle !== undefined) { - await huks.updateSession(handle, options) - .then((data) => { - console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((err: Error) => { - console.error(`promise: update verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }); - - options.inData = signature; - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((err: Error) => { - console.error(`promise: verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }); - } -} - -async function deleteRsaKey(keyAlias: string) { - let emptyOptions: huks.HuksOptions = { - properties: [] - } - await huks.deleteKeyItem(keyAlias, emptyOptions) - .then((data) => { - console.info(`promise: delete data success`); - }).catch((err: Error) => { - console.error(`promise: delete data failed`); - throw (err as Error); - }); -} - -export async function testSignVerify() { - await generateRsaKey(keyAlias); - await sign(keyAlias, plaintext); - await verify(keyAlias, plaintext, signature); - await deleteRsaKey(keyAlias); -} - - -// [End key_algorithm_RSASHA256PSS] -@Entry -@Component -struct Index { - @State message: string = 'RSA/SHA256/PSS'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.rsa_sha256_pss')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await testSignVerify(); - this.message = 'RSA/SHA256/PSS Result: Success'; - }catch { - this.message = 'RSA/SHA256/PSS Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// +// [Start key_algorithm_RSASHA256PSS] +/* + * 密钥算法为RSA,摘要算法为SHA256,填充模式为PSS + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +let keyAlias = 'test_rsaKeyAlias'; +let handle: number; +let plaintext = '123456'; +let signature: Uint8Array; + +function stringToUint8Array(str: string) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function uint8ArrayToString(fileData: Uint8Array) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + +function getRsaGenerateProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PSS + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }]; + return properties; +} + +function getRsaSignProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PSS + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN + }]; + return properties; +} + +function getRsaVerifyProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }, { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PSS + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }]; + return properties; +} + +async function generateRsaKey(keyAlias: string) { + let genProperties = getRsaGenerateProperties(); + let options: huks.HuksOptions = { + properties: genProperties + }; + await huks.generateKeyItem(keyAlias, options) + .then((data) => { + console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`); + }).catch((err: Error) => { + console.error(`promise: generate RSA Key failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }); +} + +async function sign(keyAlias: string, plaintext: string) { + let signProperties = getRsaSignProperties(); + let options: huks.HuksOptions = { + properties: signProperties, + inData: stringToUint8Array(plaintext) + } + await huks.initSession(keyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((err: Error) => { + console.error(`promise: init sign failed, error: ` + JSON.stringify(err)); + return; + }); + + if (handle !== undefined) { + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + signature = data.outData as Uint8Array; + }).catch((err: Error) => { + console.error(`promise: sign failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }); + } +} + +async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) { + let verifyProperties = getRsaVerifyProperties(); + let options: huks.HuksOptions = { + properties: verifyProperties, + inData: stringToUint8Array(plaintext) + } + await huks.initSession(keyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((err: Error) => { + console.error(`promise: init verify failed, error: ` + JSON.stringify(err)); + return; + }); + + if (handle !== undefined) { + await huks.updateSession(handle, options) + .then((data) => { + console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((err: Error) => { + console.error(`promise: update verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }); + + options.inData = signature; + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((err: Error) => { + console.error(`promise: verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }); + } +} + +async function deleteRsaKey(keyAlias: string) { + let emptyOptions: huks.HuksOptions = { + properties: [] + } + await huks.deleteKeyItem(keyAlias, emptyOptions) + .then((data) => { + console.info(`promise: delete data success`); + }).catch((err: Error) => { + console.error(`promise: delete data failed`); + throw (err as Error); + }); +} + +export async function testSignVerify() { + await generateRsaKey(keyAlias); + await sign(keyAlias, plaintext); + await verify(keyAlias, plaintext, signature); + await deleteRsaKey(keyAlias); +} + + +// [End key_algorithm_RSASHA256PSS] +@Entry +@Component +struct Index { + @State message: string = 'RSA/SHA256/PSS'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.rsa_sha256_pss')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await testSignVerify(); + this.message = 'RSA/SHA256/PSS Result: Success'; + }catch { + this.message = 'RSA/SHA256/PSS Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets old mode 100755 new mode 100644 index 575845c335..aae9a24519 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets @@ -1,218 +1,218 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start key_algorithm_SM2SM3] -/* - * 密钥算法为SM2、摘要算法为SM3 - */ -import { huks } from '@kit.UniversalKeystoreKit'; - -let keyAlias = 'test_sm2KeyAlias'; -let handle: number; -let plaintext = '123456'; -let signature: Uint8Array; - - -function stringToUint8Array(str: String) { - let arr: number[] = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - - -function uint8ArrayToString(fileData: Uint8Array) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - - -function getSm2GenerateProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM2 - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SM3 - }]; - return properties; -} - -function getSm2SignProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM2 - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SM3 - }]; - return properties; -} - -function getSm2VerifyProperties() { - let properties: huks.HuksParam[] = [{ - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM2 - }, { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }, { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SM3 - }]; - return properties; -} - -async function generateSm2Key(keyAlias: string) { - let genProperties = getSm2GenerateProperties(); - let options: huks.HuksOptions = { - properties: genProperties - } - await huks.generateKeyItem(keyAlias, options) - .then((data) => { - console.info(`promise: generate Sm2 Key success, data = ${JSON.stringify(data)}`); - }).catch((err: Error) => { - console.error(`promise: generate Sm2 Key failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) -} - -async function sign(keyAlias: string, plaintext: string) { - let signProperties = getSm2SignProperties(); - let options: huks.HuksOptions = { - properties: signProperties, - inData: stringToUint8Array(plaintext) - } - await huks.initSession(keyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((err: Error) => { - console.error(`promise: init sign failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - signature = data.outData as Uint8Array; - }).catch((err: Error) => { - console.error(`promise: sign failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) -} - -async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) { - let verifyProperties = getSm2VerifyProperties() - let options: huks.HuksOptions = { - properties: verifyProperties, - inData: stringToUint8Array(plaintext) - } - await huks.initSession(keyAlias, options) - .then((data) => { - handle = data.handle; - }).catch((err: Error) => { - console.error(`promise: init verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) - await huks.updateSession(handle, options) - .then((data) => { - console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((err: Error) => { - console.error(`promise: update verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) - options.inData = signature; - await huks.finishSession(handle, options) - .then((data) => { - console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); - }).catch((err: Error) => { - console.error(`promise: verify failed, error: ` + JSON.stringify(err)); - throw (err as Error); - }) -} - -async function deleteSm2Key(keyAlias: string) { - let emptyOptions: huks.HuksOptions = { - properties: [] - } - await huks.deleteKeyItem(keyAlias, emptyOptions) - .then((data) => { - console.info(`promise: delete data success`); - }).catch((err: Error) => { - console.error(`promise: delete data failed`); - throw (err as Error); - }) -} - -export async function testSignVerify() { - await generateSm2Key(keyAlias); - await sign(keyAlias, plaintext); - await verify(keyAlias, plaintext, signature); - await deleteSm2Key(keyAlias); -} - - -// [End key_algorithm_SM2SM3] -@Entry -@Component -struct Index { - @State message: string = 'SM2/SM3'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.sm2_sm3')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - let ret = await testSignVerify(); - this.message = 'SM2/SM3 Result: Success'; - } catch { - this.message = 'SM2/SM3 Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start key_algorithm_SM2SM3] +/* + * 密钥算法为SM2、摘要算法为SM3 + */ +import { huks } from '@kit.UniversalKeystoreKit'; + +let keyAlias = 'test_sm2KeyAlias'; +let handle: number; +let plaintext = '123456'; +let signature: Uint8Array; + + +function stringToUint8Array(str: String) { + let arr: number[] = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + + +function uint8ArrayToString(fileData: Uint8Array) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + + +function getSm2GenerateProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM2 + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SM3 + }]; + return properties; +} + +function getSm2SignProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM2 + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SM3 + }]; + return properties; +} + +function getSm2VerifyProperties() { + let properties: huks.HuksParam[] = [{ + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM2 + }, { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }, { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }, { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SM3 + }]; + return properties; +} + +async function generateSm2Key(keyAlias: string) { + let genProperties = getSm2GenerateProperties(); + let options: huks.HuksOptions = { + properties: genProperties + } + await huks.generateKeyItem(keyAlias, options) + .then((data) => { + console.info(`promise: generate Sm2 Key success, data = ${JSON.stringify(data)}`); + }).catch((err: Error) => { + console.error(`promise: generate Sm2 Key failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) +} + +async function sign(keyAlias: string, plaintext: string) { + let signProperties = getSm2SignProperties(); + let options: huks.HuksOptions = { + properties: signProperties, + inData: stringToUint8Array(plaintext) + } + await huks.initSession(keyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((err: Error) => { + console.error(`promise: init sign failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + signature = data.outData as Uint8Array; + }).catch((err: Error) => { + console.error(`promise: sign failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) +} + +async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) { + let verifyProperties = getSm2VerifyProperties() + let options: huks.HuksOptions = { + properties: verifyProperties, + inData: stringToUint8Array(plaintext) + } + await huks.initSession(keyAlias, options) + .then((data) => { + handle = data.handle; + }).catch((err: Error) => { + console.error(`promise: init verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) + await huks.updateSession(handle, options) + .then((data) => { + console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((err: Error) => { + console.error(`promise: update verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) + options.inData = signature; + await huks.finishSession(handle, options) + .then((data) => { + console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array)); + }).catch((err: Error) => { + console.error(`promise: verify failed, error: ` + JSON.stringify(err)); + throw (err as Error); + }) +} + +async function deleteSm2Key(keyAlias: string) { + let emptyOptions: huks.HuksOptions = { + properties: [] + } + await huks.deleteKeyItem(keyAlias, emptyOptions) + .then((data) => { + console.info(`promise: delete data success`); + }).catch((err: Error) => { + console.error(`promise: delete data failed`); + throw (err as Error); + }) +} + +export async function testSignVerify() { + await generateSm2Key(keyAlias); + await sign(keyAlias, plaintext); + await verify(keyAlias, plaintext, signature); + await deleteSm2Key(keyAlias); +} + + +// [End key_algorithm_SM2SM3] +@Entry +@Component +struct Index { + @State message: string = 'SM2/SM3'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.sm2_sm3')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + let ret = await testSignVerify(); + this.message = 'SM2/SM3 Result: Success'; + } catch { + this.message = 'SM2/SM3 Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/SigningVerification.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/SigningVerification.test.ets old mode 100755 new mode 100644 index 7006b7be9c..d609d54906 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/SigningVerification.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/SigningVerification.test.ets @@ -1,131 +1,131 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function signingVerificationTest() { - describe('signingVerificationTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,签名/验签ECC256/SHA256 - */ - it('testSigningVerification001', 0, async () => { - console.info('uitest: testSigningVerification001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('ECC256/SHA256')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('ECC256/SHA256').type('Button')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('ECC256/SHA256 Result: Success')); - console.info('uitest: testSigningVerification001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,签名/验签SM2/SM3 - */ - it('testSigningVerification002', 0, async () => { - console.info('uitest: testSigningVerification002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('SM2/SM3')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('SM2/SM3').type('Button')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('SM2/SM3 Result: Success')); - console.info('uitest: testSigningVerification002 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,签名/验签RSA/SHA256/PSS - */ - it('testSigningVerification003', 0, async () => { - console.info('uitest: testSigningVerification003 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA/SHA256/PSS')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('RSA/SHA256/PSS').type('Button')); - await button2.click(); - await driver.delayMs(4000); - await driver.assertComponentExist(ON.text('RSA/SHA256/PSS Result: Success')); - console.info('uitest: testSigningVerification003 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,签名/验签RSA/SHA256/PKCS1_V1_5 - */ - it('testSigningVerification004', 0, async () => { - console.info('uitest: testSigningVerification004 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('RSA/SHA256/PKCS1_V1_5')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('RSA/SHA256/PKCS1_V1_5').type('Button')); - await button2.click(); - await driver.delayMs(4000); - await driver.assertComponentExist(ON.text('RSA/SHA256/PKCS1_V1_5 Result: Success')); - console.info('uitest: testSigningVerification004 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,签名/验签C/C++ - */ - it('testSigningVerification005', 0, async () => { - console.info('uitest: testSigningVerification005 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testSigningVerification005 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function signingVerificationTest() { + describe('signingVerificationTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,签名/验签ECC256/SHA256 + */ + it('testSigningVerification001', 0, async () => { + console.info('uitest: testSigningVerification001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('ECC256/SHA256')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('ECC256/SHA256').type('Button')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('ECC256/SHA256 Result: Success')); + console.info('uitest: testSigningVerification001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,签名/验签SM2/SM3 + */ + it('testSigningVerification002', 0, async () => { + console.info('uitest: testSigningVerification002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('SM2/SM3')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('SM2/SM3').type('Button')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SM2/SM3 Result: Success')); + console.info('uitest: testSigningVerification002 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,签名/验签RSA/SHA256/PSS + */ + it('testSigningVerification003', 0, async () => { + console.info('uitest: testSigningVerification003 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA/SHA256/PSS')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('RSA/SHA256/PSS').type('Button')); + await button2.click(); + await driver.delayMs(4000); + await driver.assertComponentExist(ON.text('RSA/SHA256/PSS Result: Success')); + console.info('uitest: testSigningVerification003 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,签名/验签RSA/SHA256/PKCS1_V1_5 + */ + it('testSigningVerification004', 0, async () => { + console.info('uitest: testSigningVerification004 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('RSA/SHA256/PKCS1_V1_5')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('RSA/SHA256/PKCS1_V1_5').type('Button')); + await button2.click(); + await driver.delayMs(4000); + await driver.assertComponentExist(ON.text('RSA/SHA256/PKCS1_V1_5 Result: Success')); + console.info('uitest: testSigningVerification004 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,签名/验签C/C++ + */ + it('testSigningVerification005', 0, async () => { + console.info('uitest: testSigningVerification005 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testSigningVerification005 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/ohosTest.md old mode 100755 new mode 100644 index c53c86e801..8bd7bdea56 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/ohosTest.md @@ -1,12 +1,12 @@ -# 签名/验签测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ---------------------------------------- | ------------ | ---- | ------------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,签名/验签ECC256/SHA256 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | -| 点击按钮,签名/验签SM2/SM3 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | -| 点击按钮,签名/验签RSA/SHA256/PSS | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | -| 点击按钮,签名/验签RSA/SHA256/PKCS1_V1_5 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +# 签名/验签测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------- | ------------ | ---- | ------------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,签名/验签ECC256/SHA256 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +| 点击按钮,签名/验签SM2/SM3 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +| 点击按钮,签名/验签RSA/SHA256/PSS | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +| 点击按钮,签名/验签RSA/SHA256/PKCS1_V1_5 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | | 点击按钮,签名/验签C/C++ | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2561.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2561.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2562.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2562.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2561.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2561.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2562.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2562.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM21.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM21.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM22.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM22.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp1.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp2.png b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/app.json5 old mode 100755 new mode 100644 index 03eb12b218..7055299505 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/app.json5 @@ -1,25 +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.checkkeyexists", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.checkkeyexists", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index d5af273233..b52da87a06 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "CheckKeyExists" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "CheckKeyExists" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/README.md b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index c15a8e8f36..1fa27ba437 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(CheckKeyExists) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(CheckKeyExists) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index a1d73761d5..6abbe282e6 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp @@ -1,116 +1,116 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start query_whether_the_key_exists] -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include -// [StartExclude query_whether_the_key_exists] -/* 以下以生成ECC密钥为例 */ -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} - -struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; - -static OH_Huks_Result GenerateKeyHelper(const char *alias) -{ - struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; - struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr; - struct OH_Huks_Result ohResult; - do { - /* 1.初始化密钥属性集 */ - ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam, - sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 2.生成密钥 */ - ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr); - } while (0); - OH_Huks_FreeParamSet(&testGenerateKeyParamSet); - return ohResult; -} -// [EndExclude query_whether_the_key_exists] -static napi_value IsKeyExist(napi_env env, napi_callback_info info) -{ - /* 1.获取密钥别名 */ - const char *alias = "test_key"; - struct OH_Huks_Blob keyAlias = { - (uint32_t)strlen(alias), - (uint8_t *)alias - }; - - /* 生成密钥 */ - OH_Huks_Result genResult = GenerateKeyHelper(alias); - if (genResult.errorCode != OH_HUKS_SUCCESS) { - napi_value ret; - napi_create_int32(env, genResult.errorCode, &ret); - return ret; - } - - /* 2.调用OH_Huks_IsKeyItemExist判断密钥是否存在 */ - struct OH_Huks_Result ohResult = OH_Huks_IsKeyItemExist(&keyAlias, nullptr); - // OH_HUKS_SUCCESS表示存在, OH_HUKS_ERR_CODE_ITEM_NOT_EXIST表示不存在 - - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} -// [End query_whether_the_key_exists] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "isKeyExist", nullptr, IsKeyExist, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start query_whether_the_key_exists] +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include +// [StartExclude query_whether_the_key_exists] +/* 以下以生成ECC密钥为例 */ +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} + +struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; + +static OH_Huks_Result GenerateKeyHelper(const char *alias) +{ + struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; + struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr; + struct OH_Huks_Result ohResult; + do { + /* 1.初始化密钥属性集 */ + ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam, + sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 2.生成密钥 */ + ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr); + } while (0); + OH_Huks_FreeParamSet(&testGenerateKeyParamSet); + return ohResult; +} +// [EndExclude query_whether_the_key_exists] +static napi_value IsKeyExist(napi_env env, napi_callback_info info) +{ + /* 1.获取密钥别名 */ + const char *alias = "test_key"; + struct OH_Huks_Blob keyAlias = { + (uint32_t)strlen(alias), + (uint8_t *)alias + }; + + /* 生成密钥 */ + OH_Huks_Result genResult = GenerateKeyHelper(alias); + if (genResult.errorCode != OH_HUKS_SUCCESS) { + napi_value ret; + napi_create_int32(env, genResult.errorCode, &ret); + return ret; + } + + /* 2.调用OH_Huks_IsKeyItemExist判断密钥是否存在 */ + struct OH_Huks_Result ohResult = OH_Huks_IsKeyItemExist(&keyAlias, nullptr); + // OH_HUKS_SUCCESS表示存在, OH_HUKS_ERR_CODE_ITEM_NOT_EXIST表示不存在 + + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} +// [End query_whether_the_key_exists] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "isKeyExist", nullptr, IsKeyExist, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index c8feb77db6..d13f949ed3 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 isKeyExist: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets old mode 100755 new mode 100644 index 485547b725..9080f921ae --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets @@ -1,140 +1,140 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// [Start querying_the_existence_of_a_key] -import { huks } from '@kit.UniversalKeystoreKit'; - -/* 1.确定密钥别名 */ -let keyAlias = 'test_key'; -let isKeyExist: Boolean; -/* 2.构造空对象 */ -let huksOptions: huks.HuksOptions = { - properties: [] -} -// [StartExclude querying_the_existence_of_a_key] -/* 3.初始化密钥属性集 */ -let generateProperties: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DH - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048 - } -]; - -let generateHuksOptions: huks.HuksOptions = { - properties: generateProperties, - inData: new Uint8Array([]) -} - -/* 3.生成密钥 */ -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throw (error as Error); - } - }); -} - -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { - console.info(`enter promise generateKeyItem`); - try { - await generateKeyItem(keyAlias, huksOptions) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); - }); - return 'Success'; - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ` + JSON.stringify(error)); - return 'Failed'; - } -} - -async function testGenKey(): Promise { - let ret = await publicGenKeyFunc(keyAlias, generateHuksOptions); - return ret; -} - -function check(): string { -// [EndExclude querying_the_existence_of_a_key] - try { - /* 1.生成密钥 */ - testGenKey(); - /* 2.判断密钥是否存在 */ - huks.hasKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - console.error(`callback: hasKeyItem failed, ` + JSON.stringify(error)); - } else { - if (data !== null && data.valueOf() !== null) { - isKeyExist = data.valueOf(); - console.info(`callback: hasKeyItem success, isKeyExist = ${isKeyExist}`); - } - } - }); - return 'Success'; - } catch (error) { - console.error(`callback: hasKeyItem input arg invalid, ` + JSON.stringify(error)); - return 'Failed'; - } -// [End querying_the_existence_of_a_key] -} - -@Entry -@Component -struct Index { - @State message: string = 'CheckKeyExists'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_check_key_exists')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - let ret: string = check(); - this.message = 'CheckKeyExists Result: ' + ret; - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start querying_the_existence_of_a_key] +import { huks } from '@kit.UniversalKeystoreKit'; + +/* 1.确定密钥别名 */ +let keyAlias = 'test_key'; +let isKeyExist: Boolean; +/* 2.构造空对象 */ +let huksOptions: huks.HuksOptions = { + properties: [] +} +// [StartExclude querying_the_existence_of_a_key] +/* 3.初始化密钥属性集 */ +let generateProperties: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_DH + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048 + } +]; + +let generateHuksOptions: huks.HuksOptions = { + properties: generateProperties, + inData: new Uint8Array([]) +} + +/* 3.生成密钥 */ +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw (error as Error); + } + }); +} + +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { + console.info(`enter promise generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); + }); + return 'Success'; + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ` + JSON.stringify(error)); + return 'Failed'; + } +} + +async function testGenKey(): Promise { + let ret = await publicGenKeyFunc(keyAlias, generateHuksOptions); + return ret; +} + +function check(): string { +// [EndExclude querying_the_existence_of_a_key] + try { + /* 1.生成密钥 */ + testGenKey(); + /* 2.判断密钥是否存在 */ + huks.hasKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + console.error(`callback: hasKeyItem failed, ` + JSON.stringify(error)); + } else { + if (data !== null && data.valueOf() !== null) { + isKeyExist = data.valueOf(); + console.info(`callback: hasKeyItem success, isKeyExist = ${isKeyExist}`); + } + } + }); + return 'Success'; + } catch (error) { + console.error(`callback: hasKeyItem input arg invalid, ` + JSON.stringify(error)); + return 'Failed'; + } +// [End querying_the_existence_of_a_key] +} + +@Entry +@Component +struct Index { + @State message: string = 'CheckKeyExists'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_check_key_exists')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + let ret: string = check(); + this.message = 'CheckKeyExists Result: ' + ret; + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/CheckKeyExists.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/CheckKeyExists.test.ets old mode 100755 new mode 100644 index 8647c8c7e3..a41b084cd3 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/CheckKeyExists.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/CheckKeyExists.test.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function checkKeyExistsTest() { - describe('checkKeyExistsTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,查询密钥是否存在(ArkTS) - */ - it('testCheckKeyExists001', 0, async () => { - console.info('uitest: testCheckKeyExists001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('CheckKeyExists').type('Button')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call CheckKeyExists')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('CheckKeyExists Result: Success')); - console.info('uitest: testCheckKeyExists001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,查询密钥是否存在(C/C++) - */ - it('testCheckKeyExists002', 0, async () => { - console.info('uitest: testCheckKeyExists002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testCheckKeyExists002 end'); - await driver.pressBack(); - }) - }) -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function checkKeyExistsTest() { + describe('checkKeyExistsTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,查询密钥是否存在(ArkTS) + */ + it('testCheckKeyExists001', 0, async () => { + console.info('uitest: testCheckKeyExists001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('CheckKeyExists').type('Button')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call CheckKeyExists')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('CheckKeyExists Result: Success')); + console.info('uitest: testCheckKeyExists001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,查询密钥是否存在(C/C++) + */ + it('testCheckKeyExists002', 0, async () => { + console.info('uitest: testCheckKeyExists002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testCheckKeyExists002 end'); + await driver.pressBack(); + }) + }) +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/ohosTest.md old mode 100755 new mode 100644 index b9a0aadfd5..e672dd2ab8 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/ohosTest.md @@ -1,9 +1,9 @@ -## 查询密钥是否存在测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| --------------------------------- | ------------ | ---- | ------------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,查询密钥是否存在(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +## 查询密钥是否存在测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| --------------------------------- | ------------ | ---- | ------------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,查询密钥是否存在(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | | 点击按钮,查询密钥是否存在(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_1.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_2.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_2.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/app.json5 old mode 100755 new mode 100644 index 79d423e065..6827bed801 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/app.json5 @@ -1,25 +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.getkeyattributes", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.getkeyattributes", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 079011dd5d..c5f9a78ef2 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "GetKeyAttributes" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "GetKeyAttributes" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/README.md b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index c12d3b9c8c..a411957596 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(GetKeyAttributes) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(GetKeyAttributes) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 8250ad5b27..c69148a980 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp @@ -1,132 +1,132 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [Start obtain_the_key_attributes] -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include -// [StartExclude obtain_the_key_attributes] -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} - -struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; - -static OH_Huks_Result GenerateKeyHelper(const char *alias) -{ - struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; - struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr; - struct OH_Huks_Result ohResult; - do { - /* 1.初始化密钥属性集 */ - ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam, - sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 1.生成密钥 */ - ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr); - } while (0); - OH_Huks_FreeParamSet(&testGenerateKeyParamSet); - return ohResult; -} -// [EndExclude obtain_the_key_attributes] -static napi_value GetKeyParamSet(napi_env env, napi_callback_info info) -{ - /* 1. 参数构造:确定密钥别名 */ - const char *alias = "test_key"; - struct OH_Huks_Blob aliasBlob = { .size = (uint32_t)strlen(alias), .data = (uint8_t *)alias }; - // [StartExclude obtain_the_key_attributes] - /* 生成密钥 */ - OH_Huks_Result genResult = GenerateKeyHelper(alias); - if (genResult.errorCode != OH_HUKS_SUCCESS) { - napi_value ret; - napi_create_int32(env, genResult.errorCode, &ret); - return ret; - } - // [EndExclude obtain_the_key_attributes] - const size_t paramSetSize = 512; - /* 构造参数:为参数集申请内存 - * 请业务按实际情况评估大小进行申请 - */ - struct OH_Huks_ParamSet *outParamSet = static_cast(malloc(paramSetSize)); - if (outParamSet == nullptr) { - return nullptr; - } - outParamSet->paramSetSize = paramSetSize; - struct OH_Huks_Result ohResult; - do { - /* 2. 获取密钥属性集 */ - ohResult = OH_Huks_GetKeyItemParamSet(&aliasBlob, nullptr, outParamSet); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 3. 从参数集中读取参数,以OH_HUKS_TAG_PURPOSE为例 */ - OH_Huks_Param *purposeParam = nullptr; // 无需申请内存,获取后指针指向该参数在参数集中所处内存地址 - ohResult = OH_Huks_GetParam(outParamSet, OH_HUKS_TAG_PURPOSE, &purposeParam); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - } while (0); - OH_Huks_FreeParamSet(&outParamSet); - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} -// [End obtain_the_key_attributes] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "getKeyParamSet", nullptr, GetKeyParamSet, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start obtain_the_key_attributes] +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include +// [StartExclude obtain_the_key_attributes] +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} + +struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; + +static OH_Huks_Result GenerateKeyHelper(const char *alias) +{ + struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; + struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr; + struct OH_Huks_Result ohResult; + do { + /* 1.初始化密钥属性集 */ + ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam, + sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 1.生成密钥 */ + ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr); + } while (0); + OH_Huks_FreeParamSet(&testGenerateKeyParamSet); + return ohResult; +} +// [EndExclude obtain_the_key_attributes] +static napi_value GetKeyParamSet(napi_env env, napi_callback_info info) +{ + /* 1. 参数构造:确定密钥别名 */ + const char *alias = "test_key"; + struct OH_Huks_Blob aliasBlob = { .size = (uint32_t)strlen(alias), .data = (uint8_t *)alias }; + // [StartExclude obtain_the_key_attributes] + /* 生成密钥 */ + OH_Huks_Result genResult = GenerateKeyHelper(alias); + if (genResult.errorCode != OH_HUKS_SUCCESS) { + napi_value ret; + napi_create_int32(env, genResult.errorCode, &ret); + return ret; + } + // [EndExclude obtain_the_key_attributes] + const size_t paramSetSize = 512; + /* 构造参数:为参数集申请内存 + * 请业务按实际情况评估大小进行申请 + */ + struct OH_Huks_ParamSet *outParamSet = static_cast(malloc(paramSetSize)); + if (outParamSet == nullptr) { + return nullptr; + } + outParamSet->paramSetSize = paramSetSize; + struct OH_Huks_Result ohResult; + do { + /* 2. 获取密钥属性集 */ + ohResult = OH_Huks_GetKeyItemParamSet(&aliasBlob, nullptr, outParamSet); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 3. 从参数集中读取参数,以OH_HUKS_TAG_PURPOSE为例 */ + OH_Huks_Param *purposeParam = nullptr; // 无需申请内存,获取后指针指向该参数在参数集中所处内存地址 + ohResult = OH_Huks_GetParam(outParamSet, OH_HUKS_TAG_PURPOSE, &purposeParam); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + } while (0); + OH_Huks_FreeParamSet(&outParamSet); + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} +// [End obtain_the_key_attributes] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "getKeyParamSet", nullptr, GetKeyParamSet, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index bb850cef0e..daea8fc767 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 getKeyParamSet: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets old mode 100755 new mode 100644 index 9e8c6836c0..c772140ace --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets @@ -1,134 +1,134 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start obtaining_key_attribute] -import { huks } from '@kit.UniversalKeystoreKit'; - -/* 1. 设置密钥别名 */ -let keyAlias = 'keyAlias'; -/* option对象传空 */ -let emptyOptions: huks.HuksOptions = { - properties: [] -}; -// [StartExclude obtaining_key_attribute] -let properties1: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DH - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048 - } -]; - -let huksOptions: huks.HuksOptions = { - properties: properties1, - inData: new Uint8Array([]) -} - -/* 3.生成密钥 */ -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throw (error as Error); - } - }); -} - -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { - console.info(`enter promise generateKeyItem`); - try { - await generateKeyItem(keyAlias, huksOptions) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); - }); - return 'Success'; - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); - return 'Failed'; - } -} - -async function testGenKey(): Promise { - let ret = await publicGenKeyFunc(keyAlias, huksOptions); - return ret; -} - -function check(): string { -// [EndExclude obtaining_key_attribute] - try { - /* 1. 生成密钥 */ - testGenKey(); - /* 2. 获取密钥属性 */ - huks.getKeyItemProperties(keyAlias, emptyOptions, (error, data) => { - if (error) { - console.error(`callback: getKeyItemProperties failed, ${JSON.stringify(error)}`); - } else { - console.info(`callback: getKeyItemProperties success, data = ${JSON.stringify(data)}`); - } - }); - return 'Success'; - } catch (error) { - console.error(`callback: getKeyItemProperties input arg invalid, ${JSON.stringify(error)}`); - return 'Failed'; - } -// [End obtaining_key_attribute] -} - -@Entry -@Component -struct Index { - @State message: string = 'GetKeyAttributes'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_get_key_attributes')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - let ret: string = check(); - this.message = 'GetKeyAttributes Result: ' + ret; - }) - } - .height('100%') - .width('100%') - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start obtaining_key_attribute] +import { huks } from '@kit.UniversalKeystoreKit'; + +/* 1. 设置密钥别名 */ +let keyAlias = 'keyAlias'; +/* option对象传空 */ +let emptyOptions: huks.HuksOptions = { + properties: [] +}; +// [StartExclude obtaining_key_attribute] +let properties1: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_DH + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048 + } +]; + +let huksOptions: huks.HuksOptions = { + properties: properties1, + inData: new Uint8Array([]) +} + +/* 3.生成密钥 */ +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw (error as Error); + } + }); +} + +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { + console.info(`enter promise generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); + }); + return 'Success'; + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); + return 'Failed'; + } +} + +async function testGenKey(): Promise { + let ret = await publicGenKeyFunc(keyAlias, huksOptions); + return ret; +} + +function check(): string { +// [EndExclude obtaining_key_attribute] + try { + /* 1. 生成密钥 */ + testGenKey(); + /* 2. 获取密钥属性 */ + huks.getKeyItemProperties(keyAlias, emptyOptions, (error, data) => { + if (error) { + console.error(`callback: getKeyItemProperties failed, ${JSON.stringify(error)}`); + } else { + console.info(`callback: getKeyItemProperties success, data = ${JSON.stringify(data)}`); + } + }); + return 'Success'; + } catch (error) { + console.error(`callback: getKeyItemProperties input arg invalid, ${JSON.stringify(error)}`); + return 'Failed'; + } +// [End obtaining_key_attribute] +} + +@Entry +@Component +struct Index { + @State message: string = 'GetKeyAttributes'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_get_key_attributes')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + let ret: string = check(); + this.message = 'GetKeyAttributes Result: ' + ret; + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/GetKeyAttributes.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/GetKeyAttributes.test.ets old mode 100755 new mode 100644 index b389e34005..0b3b396fee --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/GetKeyAttributes.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/GetKeyAttributes.test.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function getKeyAttributesTest() { - describe('getKeyAttributesTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,获取密钥属性(ArkTS) - */ - it('testGetKeyAttributes001', 0, async () => { - console.info('uitest: testGetKeyAttributes001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('GetKeyAttributes').type('Button')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call GetKeyAttributes')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('GetKeyAttributes Result: Success')); - console.info('uitest: testGetKeyAttributes001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,获取密钥属性(C/C++) - */ - it('testGetKeyAttributes002', 0, async () => { - console.info('uitest: testGetKeyAttributes002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testGetKeyAttributes002 end'); - await driver.pressBack(); - }) - }) -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function getKeyAttributesTest() { + describe('getKeyAttributesTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,获取密钥属性(ArkTS) + */ + it('testGetKeyAttributes001', 0, async () => { + console.info('uitest: testGetKeyAttributes001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('GetKeyAttributes').type('Button')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call GetKeyAttributes')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('GetKeyAttributes Result: Success')); + console.info('uitest: testGetKeyAttributes001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,获取密钥属性(C/C++) + */ + it('testGetKeyAttributes002', 0, async () => { + console.info('uitest: testGetKeyAttributes002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testGetKeyAttributes002 end'); + await driver.pressBack(); + }) + }) +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/ohosTest.md old mode 100755 new mode 100644 index f94cbca750..9ff789ae85 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/ohosTest.md @@ -1,9 +1,9 @@ -# 获取密钥属性测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ----------------------------- | ------------ | ---- | ------------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 获取密钥属性(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +# 获取密钥属性测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------------- | ------------ | ---- | ------------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 获取密钥属性(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | | 点击按钮,获取密钥属性(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_2.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_1.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_2.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/app.json5 old mode 100755 new mode 100644 index 6af55fd49d..4ee18eb53c --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/app.json5 @@ -1,25 +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.keyexport", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.keyexport", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 6b14bfbaf8..31f53443c8 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "KeyExport" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "KeyExport" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/README.md b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/build-profile.json5 old mode 100755 new mode 100644 index df8b8004f9..9a067264a4 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "targetSdkVersion": 14, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/build-profile.json5 old mode 100755 new mode 100644 index 5612a9a1db..3186225747 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/build-profile.json5 @@ -1,59 +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": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": false, + "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/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 482cdaa452..5b291e7135 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(KeyExport) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(KeyExport) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 7ba85656d9..1e3f591993 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp @@ -1,124 +1,124 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start get_persistent_storage_asymmetric_public_keys] -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include -// [StartExclude get_persistent_storage_asymmetric_public_keys] -/* 以下以生成ECC密钥为例 */ -OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} - -struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, - {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, - {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, - {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; - -static OH_Huks_Result GenerateKeyHelper(const char *alias) -{ - struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; - struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr; - struct OH_Huks_Result ohResult; - do { - /* 1.初始化密钥属性集 */ - ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam, - sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 2.生成密钥 */ - ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr); - } while (0); - OH_Huks_FreeParamSet(&testGenerateKeyParamSet); - return ohResult; -} -// [EndExclude get_persistent_storage_asymmetric_public_keys] -static napi_value ExportKey(napi_env env, napi_callback_info info) -{ - /* 1. 参数构造:确定密钥别名 */ - const char *alias = "test_key"; - struct OH_Huks_Blob aliasBlob = { .size = (uint32_t)strlen(alias), .data = (uint8_t *)alias }; - // [StartExclude get_persistent_storage_asymmetric_public_keys] - /* 生成密钥 */ - OH_Huks_Result genResult = GenerateKeyHelper(alias); - if (genResult.errorCode != OH_HUKS_SUCCESS) { - napi_value ret; - napi_create_int32(env, genResult.errorCode, &ret); - return ret; - } - // [EndExclude get_persistent_storage_asymmetric_public_keys] - /* 构造参数:为待导出公钥申请内存 */ - uint8_t *pubKey = (uint8_t *)malloc(512); // 请业务按实际密钥大小评估申请 - if (pubKey == nullptr) { - return nullptr; - } - struct OH_Huks_Blob keyBlob = { 256, pubKey }; - struct OH_Huks_Result ohResult; - do { - ohResult = OH_Huks_ExportPublicKeyItem(&aliasBlob, nullptr, &keyBlob); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - } while (0); - free(pubKey); - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} -// [End get_persistent_storage_asymmetric_public_keys] -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "exportKey", nullptr, ExportKey, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start get_persistent_storage_asymmetric_public_keys] +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include +// [StartExclude get_persistent_storage_asymmetric_public_keys] +/* 以下以生成ECC密钥为例 */ +OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} + +struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC}, + {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE}, + {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}, + {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}}; + +static OH_Huks_Result GenerateKeyHelper(const char *alias) +{ + struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias}; + struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr; + struct OH_Huks_Result ohResult; + do { + /* 1.初始化密钥属性集 */ + ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam, + sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 2.生成密钥 */ + ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr); + } while (0); + OH_Huks_FreeParamSet(&testGenerateKeyParamSet); + return ohResult; +} +// [EndExclude get_persistent_storage_asymmetric_public_keys] +static napi_value ExportKey(napi_env env, napi_callback_info info) +{ + /* 1. 参数构造:确定密钥别名 */ + const char *alias = "test_key"; + struct OH_Huks_Blob aliasBlob = { .size = (uint32_t)strlen(alias), .data = (uint8_t *)alias }; + // [StartExclude get_persistent_storage_asymmetric_public_keys] + /* 生成密钥 */ + OH_Huks_Result genResult = GenerateKeyHelper(alias); + if (genResult.errorCode != OH_HUKS_SUCCESS) { + napi_value ret; + napi_create_int32(env, genResult.errorCode, &ret); + return ret; + } + // [EndExclude get_persistent_storage_asymmetric_public_keys] + /* 构造参数:为待导出公钥申请内存 */ + uint8_t *pubKey = (uint8_t *)malloc(512); // 请业务按实际密钥大小评估申请 + if (pubKey == nullptr) { + return nullptr; + } + struct OH_Huks_Blob keyBlob = { 256, pubKey }; + struct OH_Huks_Result ohResult; + do { + ohResult = OH_Huks_ExportPublicKeyItem(&aliasBlob, nullptr, &keyBlob); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + } while (0); + free(pubKey); + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} +// [End get_persistent_storage_asymmetric_public_keys] +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "exportKey", nullptr, ExportKey, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index 406132e484..a9a8bde79f --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 exportKey: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets old mode 100755 new mode 100644 index 62386bdce3..5c6f94e77c --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets @@ -1,136 +1,136 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start fetch_persistent_security_public_keys] -import { huks } from '@kit.UniversalKeystoreKit'; - -/* 1. 设置密钥别名 */ -let keyAlias = 'keyAlias'; -/* option对象传空 */ -let emptyOptions: huks.HuksOptions = { -properties: [] -}; -// [StartExclude fetch_persistent_security_public_keys] -let properties1: huks.HuksParam[] = [ - { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DH - }, - { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }, - { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048 - } -]; - -let huksOptions: huks.HuksOptions = { - properties: properties1, - inData: new Uint8Array([]) -} - -/* 3.生成密钥 */ -function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throw (error as Error); - } - }); -} - -async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { - console.info(`enter promise generateKeyItem`); - try { - await generateKeyItem(keyAlias, huksOptions) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch((error: Error) => { - console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); - }); - return 'Success'; - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); - return 'Failed'; - } -} - -async function testGenKey(): Promise { - let ret = await publicGenKeyFunc(keyAlias, huksOptions); - return ret; -} - -function check(): string { -// [EndExclude fetch_persistent_security_public_keys] - try { - // [StartExclude fetch_persistent_security_public_keys] - /* 1. 生成密钥 */ - testGenKey() - // [EndExclude fetch_persistent_security_public_keys] - /* 2. 导出密钥 */ - huks.exportKeyItem(keyAlias, emptyOptions, (error, data) => { - if (error) { - console.error(`callback: exportKeyItem failed, ` + error); - } else { - console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); - } - }); - return 'Success'; - } catch (error) { - console.error(`callback: exportKeyItem input arg invalid, ${JSON.stringify(error)}`); - return 'Failed'; - } -// [End fetch_persistent_security_public_keys] -} - -@Entry -@Component -struct Index { - @State message: string = 'KeyExport'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_keyExport')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(() => { - let ret: string = check(); - this.message = 'KeyExport Result: ' + ret; - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start fetch_persistent_security_public_keys] +import { huks } from '@kit.UniversalKeystoreKit'; + +/* 1. 设置密钥别名 */ +let keyAlias = 'keyAlias'; +/* option对象传空 */ +let emptyOptions: huks.HuksOptions = { +properties: [] +}; +// [StartExclude fetch_persistent_security_public_keys] +let properties1: huks.HuksParam[] = [ + { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_DH + }, + { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE + }, + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048 + } +]; + +let huksOptions: huks.HuksOptions = { + properties: properties1, + inData: new Uint8Array([]) +} + +/* 3.生成密钥 */ +function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw (error as Error); + } + }); +} + +async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { + console.info(`enter promise generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch((error: Error) => { + console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`); + }); + return 'Success'; + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`); + return 'Failed'; + } +} + +async function testGenKey(): Promise { + let ret = await publicGenKeyFunc(keyAlias, huksOptions); + return ret; +} + +function check(): string { +// [EndExclude fetch_persistent_security_public_keys] + try { + // [StartExclude fetch_persistent_security_public_keys] + /* 1. 生成密钥 */ + testGenKey() + // [EndExclude fetch_persistent_security_public_keys] + /* 2. 导出密钥 */ + huks.exportKeyItem(keyAlias, emptyOptions, (error, data) => { + if (error) { + console.error(`callback: exportKeyItem failed, ` + error); + } else { + console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); + } + }); + return 'Success'; + } catch (error) { + console.error(`callback: exportKeyItem input arg invalid, ${JSON.stringify(error)}`); + return 'Failed'; + } +// [End fetch_persistent_security_public_keys] +} + +@Entry +@Component +struct Index { + @State message: string = 'KeyExport'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_keyExport')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(() => { + let ret: string = check(); + this.message = 'KeyExport Result: ' + ret; + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/KeyExport.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/KeyExport.test.ets old mode 100755 new mode 100644 index f233530c8d..dd36f06100 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/KeyExport.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/KeyExport.test.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function keyExportTest() { - describe('keyExportTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,密钥导出(ArkTS) - */ - it('testKeyExport001', 0, async () => { - console.info('uitest: testKeyExport001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('KeyExport').type('Button')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call KeyExport')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('KeyExport Result: Success')); - console.info('uitest: testKeyExport001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,密钥导出(C/C++) - */ - it('testKeyExport002', 0, async () => { - console.info('uitest: testKeyExport002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); - console.info('uitest: testKeyExport002 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function keyExportTest() { + describe('keyExportTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,密钥导出(ArkTS) + */ + it('testKeyExport001', 0, async () => { + console.info('uitest: testKeyExport001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('KeyExport').type('Button')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call KeyExport')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('KeyExport Result: Success')); + console.info('uitest: testKeyExport001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,密钥导出(C/C++) + */ + it('testKeyExport002', 0, async () => { + console.info('uitest: testKeyExport002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Result: 0')); + console.info('uitest: testKeyExport002 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/LocalUnit.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/OtherOperations/KeyExport/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/ohosTest.md old mode 100755 new mode 100644 index 695e9b34ac..2f97b8c42f --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/ohosTest.md @@ -1,9 +1,9 @@ -# 密钥导出测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------- | ------------ | ---- | ------------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,密钥导出(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +# 密钥导出测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------- | ------------ | ---- | ------------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,密钥导出(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | | 点击按钮,密钥导出(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_1.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_2.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_1.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_1.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_2.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_2.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/app.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/app.json5 old mode 100755 new mode 100644 index 784bdb1c6d..fcec0d4c2b --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/app.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/app.json5 @@ -1,25 +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.querykeyaliasset", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * 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.querykeyaliasset", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index a48b05bab5..f2323df2c8 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/element/string.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "QueryKeyAliasSet" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "QueryKeyAliasSet" + } + ] +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/media/app_icon.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/README.md b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/README.md old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/build-profile.json5 old mode 100755 new mode 100644 index 19a7898302..4343d7582c --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * 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", - "compileSdkVersion": 20, - "compatibleSdkVersion": 20, - "targetSdkVersion": 20, - "runtimeOS": "OpenHarmony", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug" - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * 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", + "compileSdkVersion": 20, + "compatibleSdkVersion": 20, + "targetSdkVersion": 20, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/code-linter.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/code-linter.json5 old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/.gitignore b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/.gitignore old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/build-profile.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/build-profile.json5 old mode 100755 new mode 100644 index 55b7cedf15..8bbe548ca7 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/build-profile.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/build-profile.json5 @@ -1,59 +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": [ - "x86_64", - "armeabi-v7a", - "arm64-v8a" - ] - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest", - } - ] +/* + * 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": [ + "x86_64", + "armeabi-v7a", + "arm64-v8a" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/oh-package.json5 old mode 100755 new mode 100644 index 5d993e5251..118bdd4fe7 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/oh-package.json5 @@ -1,26 +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" - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/CMakeLists.txt old mode 100755 new mode 100644 index 2c6b38583c..72428e44e6 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/CMakeLists.txt +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/CMakeLists.txt @@ -1,15 +1,15 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(QueryKeyAliasSet) - -set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - -if(DEFINED PACKAGE_FIND_FILE) - include(${PACKAGE_FIND_FILE}) -endif() - -include_directories(${NATIVERENDER_ROOT_PATH} - ${NATIVERENDER_ROOT_PATH}/include) - -add_library(entry SHARED napi_init.cpp) +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(QueryKeyAliasSet) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index 41112469e8..d6f218f222 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/napi_init.cpp @@ -1,100 +1,100 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start query_key_alias_set_cpp] -/* 以下查询密钥别名集为例 */ -#include "huks/native_huks_api.h" -#include "huks/native_huks_param.h" -#include "napi/native_api.h" -#include - -OH_Huks_Result InitParamSet( - struct OH_Huks_ParamSet **paramSet, - const struct OH_Huks_Param *params, - uint32_t paramCount) -{ - OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - return ret; - } - ret = OH_Huks_AddParams(*paramSet, params, paramCount); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - ret = OH_Huks_BuildParamSet(paramSet); - if (ret.errorCode != OH_HUKS_SUCCESS) { - OH_Huks_FreeParamSet(paramSet); - return ret; - } - return ret; -} - -struct OH_Huks_Param g_testQueryParam[] = { - { - .tag = OH_HUKS_TAG_AUTH_STORAGE_LEVEL, - .uint32Param = OH_HUKS_AUTH_STORAGE_LEVEL_DE - }, -}; - -static napi_value ListAliases(napi_env env, napi_callback_info info) -{ - struct OH_Huks_ParamSet *testQueryParamSet = nullptr; - struct OH_Huks_KeyAliasSet *outData = nullptr; - struct OH_Huks_Result ohResult; - do { - /* 1.初始化密钥属性集 */ - ohResult = InitParamSet(&testQueryParamSet, g_testQueryParam, - sizeof(g_testQueryParam) / sizeof(OH_Huks_Param)); - if (ohResult.errorCode != OH_HUKS_SUCCESS) { - break; - } - /* 2.查询密钥别名集 */ - ohResult = OH_Huks_ListAliases(testQueryParamSet, &outData); - } while (0); - - OH_Huks_FreeParamSet(&testQueryParamSet); - OH_Huks_FreeKeyAliasSet(outData); - napi_value ret; - napi_create_int32(env, ohResult.errorCode, &ret); - return ret; -} -// [Start query_key_alias_set_cpp] - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "listAliases", nullptr, ListAliases, nullptr, nullptr, nullptr, napi_default, nullptr } - }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -static napi_module demoModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "entry", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void RegisterEntryModule(void) -{ - napi_module_register(&demoModule); -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start query_key_alias_set_cpp] +/* 以下查询密钥别名集为例 */ +#include "huks/native_huks_api.h" +#include "huks/native_huks_param.h" +#include "napi/native_api.h" +#include + +OH_Huks_Result InitParamSet( + struct OH_Huks_ParamSet **paramSet, + const struct OH_Huks_Param *params, + uint32_t paramCount) +{ + OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + return ret; + } + ret = OH_Huks_AddParams(*paramSet, params, paramCount); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + ret = OH_Huks_BuildParamSet(paramSet); + if (ret.errorCode != OH_HUKS_SUCCESS) { + OH_Huks_FreeParamSet(paramSet); + return ret; + } + return ret; +} + +struct OH_Huks_Param g_testQueryParam[] = { + { + .tag = OH_HUKS_TAG_AUTH_STORAGE_LEVEL, + .uint32Param = OH_HUKS_AUTH_STORAGE_LEVEL_DE + }, +}; + +static napi_value ListAliases(napi_env env, napi_callback_info info) +{ + struct OH_Huks_ParamSet *testQueryParamSet = nullptr; + struct OH_Huks_KeyAliasSet *outData = nullptr; + struct OH_Huks_Result ohResult; + do { + /* 1.初始化密钥属性集 */ + ohResult = InitParamSet(&testQueryParamSet, g_testQueryParam, + sizeof(g_testQueryParam) / sizeof(OH_Huks_Param)); + if (ohResult.errorCode != OH_HUKS_SUCCESS) { + break; + } + /* 2.查询密钥别名集 */ + ohResult = OH_Huks_ListAliases(testQueryParamSet, &outData); + } while (0); + + OH_Huks_FreeParamSet(&testQueryParamSet); + OH_Huks_FreeKeyAliasSet(outData); + napi_value ret; + napi_create_int32(env, ohResult.errorCode, &ret); + return ret; +} +// [Start query_key_alias_set_cpp] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "listAliases", nullptr, ListAliases, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/index.d.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/index.d.ts old mode 100755 new mode 100644 index f60990d452..8f80a2ec44 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/index.d.ts +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/index.d.ts @@ -1,16 +1,16 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * 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 listAliases: () => number; \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/oh-package.json5 old mode 100755 new mode 100644 index e8f69f3d76..2826cc7d6b --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -1,21 +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." +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entryability/EntryAbility.ets old mode 100755 new mode 100644 index 3e77e4b9f7..edc2839f20 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets old mode 100755 new mode 100644 index 1504a74f09..b1e2129472 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +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)); - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/QueryKeyAliasSet.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/QueryKeyAliasSet.ets old mode 100755 new mode 100644 index 72a3e381cd..53d742fe83 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/QueryKeyAliasSet.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/QueryKeyAliasSet.ets @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// [Start query_key_alias_set_arkts] -/* - * 以下查询密钥别名集Promise操作使用为例 - */ -import { huks } from '@kit.UniversalKeystoreKit' - -async function testListAliases() { - /* 1.初始化密钥属性集 */ - let queryProperties: Array = [ - { - tag: huks.HuksTag.HUKS_TAG_AUTH_STORAGE_LEVEL, - value: huks.HuksAuthStorageLevel.HUKS_AUTH_STORAGE_LEVEL_DE - } - ]; - let queryOptions: huks.HuksOptions = { - properties: queryProperties - }; - - try { - /* 2.查询密钥别名集 */ - let result: huks.HuksListAliasesReturnResult = await huks.listAliases(queryOptions); - console.info(`promise: listAliases success`); - } catch (error) { - console.error(`promise: listAliases fail`); - // [StartExclude query_key_alias_set_arkts] - throw (error as Error); - // [EndExclude query_key_alias_set_arkts] - } -} -// [End query_key_alias_set_arkts] - -@Entry -@Component -struct Index { - @State message: string = 'QueryKeyAliasSet'; - - build() { - Column({ space: 12 }) { - Text(this.message) - .fontWeight(FontWeight.Regular) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(Infinity) - .textAlign(TextAlign.Start) - Button($r('app.string.call_arkts')) - .padding('12vp') - .height('40vp') - .borderRadius($r('sys.float.ohos_id_corner_radius_button')) - .backgroundColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize('14sp') - .fontColor('#ffffff') - .onClick(async () => { - try { - await testListAliases(); - this.message = 'Call ArkTS Result: Success'; - } catch (error) { - this.message = 'Call ArkTS Result: Failed'; - } - }) - } - .height('100%') - .width('100%') - } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start query_key_alias_set_arkts] +/* + * 以下查询密钥别名集Promise操作使用为例 + */ +import { huks } from '@kit.UniversalKeystoreKit' + +async function testListAliases() { + /* 1.初始化密钥属性集 */ + let queryProperties: Array = [ + { + tag: huks.HuksTag.HUKS_TAG_AUTH_STORAGE_LEVEL, + value: huks.HuksAuthStorageLevel.HUKS_AUTH_STORAGE_LEVEL_DE + } + ]; + let queryOptions: huks.HuksOptions = { + properties: queryProperties + }; + + try { + /* 2.查询密钥别名集 */ + let result: huks.HuksListAliasesReturnResult = await huks.listAliases(queryOptions); + console.info(`promise: listAliases success`); + } catch (error) { + console.error(`promise: listAliases fail`); + // [StartExclude query_key_alias_set_arkts] + throw (error as Error); + // [EndExclude query_key_alias_set_arkts] + } +} +// [End query_key_alias_set_arkts] + +@Entry +@Component +struct Index { + @State message: string = 'QueryKeyAliasSet'; + + build() { + Column({ space: 12 }) { + Text(this.message) + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .maxLines(Infinity) + .textAlign(TextAlign.Start) + Button($r('app.string.call_arkts')) + .padding('12vp') + .height('40vp') + .borderRadius($r('sys.float.ohos_id_corner_radius_button')) + .backgroundColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize('14sp') + .fontColor('#ffffff') + .onClick(async () => { + try { + await testListAliases(); + this.message = 'Call ArkTS Result: Success'; + } catch (error) { + this.message = 'Call ArkTS Result: Failed'; + } + }) + } + .height('100%') + .width('100%') + } } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/module.json5 old mode 100755 new mode 100644 index 776ce01475..4144486d1a --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/module.json5 @@ -1,66 +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" - } - ] - } - ] - } +/* + * 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/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index d66f9a7d4a..3c712962da --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/string.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/background.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/background.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/foreground.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/layered_image.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/startIcon.png old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/backup_config.json old mode 100755 new mode 100644 index d742c2f96e..78f40ae7c4 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/backup_config.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/dark/element/color.json old mode 100755 new mode 100644 index 438d5bc43b..79b11c2747 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/dark/element/color.json +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/dark/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/QueryKeyAliasSet.test.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/QueryKeyAliasSet.test.ets old mode 100755 new mode 100644 index c27fa491c1..b193e3b786 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/QueryKeyAliasSet.test.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/QueryKeyAliasSet.test.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -// 导入测试依赖kit -import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; -import { UIAbility, Want } from '@kit.AbilityKit'; - -const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); -const bundleName = abilityDelegatorRegistry.getArguments().bundleName; -let want: Want; - -export default function queryKeyAliasSetTest() { - describe('queryKeyAliasSetTest', () => { - /** - * 打开应用 - */ - beforeAll(async () => { - want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - }; - await delegator.startAbility(want); - const driver = Driver.create(); - await driver.delayMs(1000); - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info('get top ability'); - await driver.delayMs(1000); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - }) - - /** - * 点击按钮,查询密钥别名集(ArkTS) - */ - it('testQueryKeyAliasSet001', 0, async () => { - console.info('uitest: testQueryKeyAliasSet001 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('QueryKeyAliasSet').type('Button')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - const button2 = await driver.findComponent(ON.text('Call ArkTS')); - await button2.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call ArkTS Result: Success')); - console.info('uitest: testQueryKeyAliasSet001 end'); - await driver.pressBack(); - }) - - /** - * 点击按钮,查询密钥别名集(C/C++) - */ - it('testQueryKeyAliasSet002', 0, async () => { - console.info('uitest: testQueryKeyAliasSet002 begin'); - const driver = Driver.create(); - const button1 = await driver.findComponent(ON.text('Call C/C++')); - await driver.delayMs(1000); - await button1.click(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.text('Call C/C++ Success Result: 0')); - console.info('uitest: testQueryKeyAliasSet002 end'); - await driver.pressBack(); - }) - }) +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function queryKeyAliasSetTest() { + describe('queryKeyAliasSetTest', () => { + /** + * 打开应用 + */ + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + await driver.delayMs(1000); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * 点击按钮,查询密钥别名集(ArkTS) + */ + it('testQueryKeyAliasSet001', 0, async () => { + console.info('uitest: testQueryKeyAliasSet001 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('QueryKeyAliasSet').type('Button')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + const button2 = await driver.findComponent(ON.text('Call ArkTS')); + await button2.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call ArkTS Result: Success')); + console.info('uitest: testQueryKeyAliasSet001 end'); + await driver.pressBack(); + }) + + /** + * 点击按钮,查询密钥别名集(C/C++) + */ + it('testQueryKeyAliasSet002', 0, async () => { + console.info('uitest: testQueryKeyAliasSet002 begin'); + const driver = Driver.create(); + const button1 = await driver.findComponent(ON.text('Call C/C++')); + await driver.delayMs(1000); + await button1.click(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('Call C/C++ Success Result: 0')); + console.info('uitest: testQueryKeyAliasSet002 end'); + await driver.pressBack(); + }) + }) } \ No newline at end of file diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/module.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 9983b2ba4e..c3fd9dda30 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/module.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigor/hvigor-config.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index cef74543b1..d584c19c24 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigor/hvigor-config.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigor/hvigor-config.json5 @@ -1,37 +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.1", - "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*/ - } -} +/* + * 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.1", + "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/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigorfile.ts b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/oh-package.json5 b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/oh-package.json5 old mode 100755 new mode 100644 index eaef52736f..e41bae026a --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/oh-package.json5 +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/oh-package.json5 @@ -1,25 +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.1", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.19", - "@ohos/hamock": "1.0.0" - } -} +/* + * 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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/ohosTest.md b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/ohosTest.md old mode 100755 new mode 100644 index 963e65e233..cef5b6856b --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/ohosTest.md +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/ohosTest.md @@ -1,9 +1,9 @@ -# 查询密钥别名集测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------- | ------------ | ---- | ------------------ | -------- | -------- | -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 点击按钮,查询密钥别名集(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | +# 查询密钥别名集测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------- | ------------ | ---- | ------------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮,查询密钥别名集(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | | 点击按钮,查询密钥别名集(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass | \ No newline at end of file diff --git a/code/Performance/ArkRuntime/NBody/AppScope/app.json5 b/code/Performance/ArkRuntime/NBody/AppScope/app.json5 index e76916bdcc..9e14e0fcb4 100644 --- a/code/Performance/ArkRuntime/NBody/AppScope/app.json5 +++ b/code/Performance/ArkRuntime/NBody/AppScope/app.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2023 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.example.nbody", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.example.nbody", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/Performance/ArkRuntime/NBody/AppScope/resources/base/element/string.json b/code/Performance/ArkRuntime/NBody/AppScope/resources/base/element/string.json index 6c70e2d815..69746c0922 100644 --- a/code/Performance/ArkRuntime/NBody/AppScope/resources/base/element/string.json +++ b/code/Performance/ArkRuntime/NBody/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NBody" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "NBody" + } + ] +} diff --git a/code/Performance/ArkRuntime/NBody/build-profile.json5 b/code/Performance/ArkRuntime/NBody/build-profile.json5 index a387b394ae..faa08452aa 100644 --- a/code/Performance/ArkRuntime/NBody/build-profile.json5 +++ b/code/Performance/ArkRuntime/NBody/build-profile.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2022-2023 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", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2022-2023 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", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "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/Performance/ArkRuntime/NBody/entry/build-profile.json5 b/code/Performance/ArkRuntime/NBody/entry/build-profile.json5 index 94d88d01e5..a1fb0f5965 100644 --- a/code/Performance/ArkRuntime/NBody/entry/build-profile.json5 +++ b/code/Performance/ArkRuntime/NBody/entry/build-profile.json5 @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2023 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": { - "sourceOption": { - "workers": [ - "./src/main/ets/workers/CalculateWorker.ts" - ] - } - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + "sourceOption": { + "workers": [ + "./src/main/ets/workers/CalculateWorker.ts" + ] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/Performance/ArkRuntime/NBody/entry/oh-package.json5 b/code/Performance/ArkRuntime/NBody/entry/oh-package.json5 index 60744fdbc7..225946cb11 100644 --- a/code/Performance/ArkRuntime/NBody/entry/oh-package.json5 +++ b/code/Performance/ArkRuntime/NBody/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/Performance/ArkRuntime/NBody/entry/src/main/ets/entryability/EntryAbility.ets b/code/Performance/ArkRuntime/NBody/entry/src/main/ets/entryability/EntryAbility.ets index f583515e6d..a50eabebd1 100644 --- a/code/Performance/ArkRuntime/NBody/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/Performance/ArkRuntime/NBody/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; -import Logger from '../utils/Logger'; - -const TAG: string = 'EntryAbility' - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - Logger.info(TAG, 'Ability onCreate'); - } - - onDestroy(): void | Promise { - Logger.info(TAG, 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - Logger.info(TAG, 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - Logger.error(TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - Logger.info(TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - Logger.info(TAG, 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - Logger.info(TAG, 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - Logger.info(TAG, 'Ability onBackground'); - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import Logger from '../utils/Logger'; + +const TAG: string = 'EntryAbility' + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + Logger.info(TAG, 'Ability onCreate'); + } + + onDestroy(): void | Promise { + Logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + Logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error(TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + Logger.info(TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + Logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + Logger.info(TAG, 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + Logger.info(TAG, 'Ability onBackground'); + } +} diff --git a/code/Performance/ArkRuntime/NBody/entry/src/main/ets/model/CalculateUtil.ets b/code/Performance/ArkRuntime/NBody/entry/src/main/ets/model/CalculateUtil.ets index 2c88b54ba6..c3ae6714dc 100644 --- a/code/Performance/ArkRuntime/NBody/entry/src/main/ets/model/CalculateUtil.ets +++ b/code/Performance/ArkRuntime/NBody/entry/src/main/ets/model/CalculateUtil.ets @@ -1,99 +1,99 @@ -/* - * Copyright (c) 2023 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 taskpool from '@ohos.taskpool'; -import { BusinessError } from '@ohos.base'; -import worker, { MessageEvents } from '@ohos.worker'; -import util from '@ohos.util'; -import { offsetMomentum, energy, advance } from './NBody_ETS_6'; -import Logger from '../utils/Logger'; - -const TAG: string = 'CalculateUtil'; -let calculateResult: string = "Total time costed = %s ms." - -class WorkerMessage { - timeSteps: number; - - constructor(timeSteps: number) { - this.timeSteps = timeSteps; - } -} - -/** - * 运行天体轨道计算程序 - * @param totalTimeSteps 时间推移量 - * @returns 计算时间 - */ -@Concurrent -export function computeTask(totalTimeSteps: number): number { - const tagInTask: string = 'computeTask'; - const timeStep: number = 0.01; // 单位:hour - const fractionDigits: number = 9; // 机械能数值小数位 - let start: number = new Date().getTime(); - - // 建立孤立系统的动量守恒 - offsetMomentum(); - Logger.info(tagInTask, energy().toFixed(fractionDigits)); - - // 更新天体在按指定的时间变化后的位置信息 - for (let i: number = 0; i < totalTimeSteps; i++) { - advance(timeStep); - } - - // 判断系统计算前后机械能守恒 - Logger.info(tagInTask, energy().toFixed(fractionDigits)); - let end: number = new Date().getTime(); - return end - start; -} - -/** - * 使用TaskPool开启子线程,执行轨道计算任务 - * @param totalTimeSteps 时间推移量 - */ -export function computeNBodyByTaskPool(totalTimeSteps: number): void { - Logger.info(TAG, "computeNBodyByTaskPool: start executing"); - let task: taskpool.Task = new taskpool.Task(computeTask, totalTimeSteps); - try { - Logger.info(TAG, 'computeNBodyByTaskPool: start calculating...'); - - // 向taskpool线程池派发子线程任务 - taskpool.execute(task, taskpool.Priority.HIGH).then((res: number) => { - Logger.info(TAG, 'computeNBodyByTaskPool: executed successfully, total time costed = ' + res + ' ms.'); - AppStorage.set('timeCost', util.format(calculateResult, res.toString())) - }) - } catch (err) { - Logger.error(TAG, "computeNBodyByTaskPool: execute failed, " + (err as BusinessError).toString()); - } - Logger.info(TAG, "computeNBodyByTaskPool: finish executing"); -} - -/** - * 使用Worker开启子线程,执行轨道计算任务 - * @param totalTimeSteps 时间推移量 - */ -export function computeNBodyByWorker(totalTimeSteps: number): void { - Logger.info(TAG, "computeNBodyByWorker: start executing"); - let workerInstance = new worker.ThreadWorker("entry/ets/workers/CalculateWorker.ts"); - - // 设置如何处理,来自worker线程的消息 - workerInstance.onmessage = (e: MessageEvents): void => { - let data: Record = e.data; - Logger.info(TAG, 'computeNBodyByWorker: executed successfully, total time costed = ' + data.result + ' ms.'); - AppStorage.set('timeCost', util.format(calculateResult, data.result)); - } - - // 设置由主线程向worker线程发送什么消息 - workerInstance.postMessage(new WorkerMessage(totalTimeSteps)); +/* + * Copyright (c) 2023 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 taskpool from '@ohos.taskpool'; +import { BusinessError } from '@ohos.base'; +import worker, { MessageEvents } from '@ohos.worker'; +import util from '@ohos.util'; +import { offsetMomentum, energy, advance } from './NBody_ETS_6'; +import Logger from '../utils/Logger'; + +const TAG: string = 'CalculateUtil'; +let calculateResult: string = "Total time costed = %s ms." + +class WorkerMessage { + timeSteps: number; + + constructor(timeSteps: number) { + this.timeSteps = timeSteps; + } +} + +/** + * 运行天体轨道计算程序 + * @param totalTimeSteps 时间推移量 + * @returns 计算时间 + */ +@Concurrent +export function computeTask(totalTimeSteps: number): number { + const tagInTask: string = 'computeTask'; + const timeStep: number = 0.01; // 单位:hour + const fractionDigits: number = 9; // 机械能数值小数位 + let start: number = new Date().getTime(); + + // 建立孤立系统的动量守恒 + offsetMomentum(); + Logger.info(tagInTask, energy().toFixed(fractionDigits)); + + // 更新天体在按指定的时间变化后的位置信息 + for (let i: number = 0; i < totalTimeSteps; i++) { + advance(timeStep); + } + + // 判断系统计算前后机械能守恒 + Logger.info(tagInTask, energy().toFixed(fractionDigits)); + let end: number = new Date().getTime(); + return end - start; +} + +/** + * 使用TaskPool开启子线程,执行轨道计算任务 + * @param totalTimeSteps 时间推移量 + */ +export function computeNBodyByTaskPool(totalTimeSteps: number): void { + Logger.info(TAG, "computeNBodyByTaskPool: start executing"); + let task: taskpool.Task = new taskpool.Task(computeTask, totalTimeSteps); + try { + Logger.info(TAG, 'computeNBodyByTaskPool: start calculating...'); + + // 向taskpool线程池派发子线程任务 + taskpool.execute(task, taskpool.Priority.HIGH).then((res: number) => { + Logger.info(TAG, 'computeNBodyByTaskPool: executed successfully, total time costed = ' + res + ' ms.'); + AppStorage.set('timeCost', util.format(calculateResult, res.toString())) + }) + } catch (err) { + Logger.error(TAG, "computeNBodyByTaskPool: execute failed, " + (err as BusinessError).toString()); + } + Logger.info(TAG, "computeNBodyByTaskPool: finish executing"); +} + +/** + * 使用Worker开启子线程,执行轨道计算任务 + * @param totalTimeSteps 时间推移量 + */ +export function computeNBodyByWorker(totalTimeSteps: number): void { + Logger.info(TAG, "computeNBodyByWorker: start executing"); + let workerInstance = new worker.ThreadWorker("entry/ets/workers/CalculateWorker.ts"); + + // 设置如何处理,来自worker线程的消息 + workerInstance.onmessage = (e: MessageEvents): void => { + let data: Record = e.data; + Logger.info(TAG, 'computeNBodyByWorker: executed successfully, total time costed = ' + data.result + ' ms.'); + AppStorage.set('timeCost', util.format(calculateResult, data.result)); + } + + // 设置由主线程向worker线程发送什么消息 + workerInstance.postMessage(new WorkerMessage(totalTimeSteps)); } \ No newline at end of file diff --git a/code/Performance/ArkRuntime/NBody/entry/src/main/module.json5 b/code/Performance/ArkRuntime/NBody/entry/src/main/module.json5 index d0ae81f782..7dadb23955 100644 --- a/code/Performance/ArkRuntime/NBody/entry/src/main/module.json5 +++ b/code/Performance/ArkRuntime/NBody/entry/src/main/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 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:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/Performance/ArkRuntime/NBody/entry/src/main/resources/base/element/color.json b/code/Performance/ArkRuntime/NBody/entry/src/main/resources/base/element/color.json index 2436817ebe..35992ef121 100644 --- a/code/Performance/ArkRuntime/NBody/entry/src/main/resources/base/element/color.json +++ b/code/Performance/ArkRuntime/NBody/entry/src/main/resources/base/element/color.json @@ -1,12 +1,12 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "top_bar_background_color", - "value": "#3399ff" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "top_bar_background_color", + "value": "#3399ff" + } + ] } \ No newline at end of file diff --git a/code/Performance/ArkRuntime/NBody/entry/src/main/resources/base/element/integer.json b/code/Performance/ArkRuntime/NBody/entry/src/main/resources/base/element/integer.json index 4a37c78413..a5f29aed55 100644 --- a/code/Performance/ArkRuntime/NBody/entry/src/main/resources/base/element/integer.json +++ b/code/Performance/ArkRuntime/NBody/entry/src/main/resources/base/element/integer.json @@ -1,37 +1,37 @@ -{ - "integer": [ - { - "name": "top_bar_font_size", - "value": 30 - }, - { - "name": "top_bar_text_height", - "value": 50 - }, - { - "name": "top_bar_height", - "value": 50 - }, - { - "name": "top_image_border_radius", - "value": 5 - }, - { - "name": "center_message_font_size", - "value": 30 - }, - { - "name": "button_task_pool_margin_top", - "value": 30 - }, - { - "name": "button_worker_margin_top", - "value": 30 - } - , - { - "name": "AlertDialog_offset", - "value": -20 - } - ] +{ + "integer": [ + { + "name": "top_bar_font_size", + "value": 30 + }, + { + "name": "top_bar_text_height", + "value": 50 + }, + { + "name": "top_bar_height", + "value": 50 + }, + { + "name": "top_image_border_radius", + "value": 5 + }, + { + "name": "center_message_font_size", + "value": 30 + }, + { + "name": "button_task_pool_margin_top", + "value": 30 + }, + { + "name": "button_worker_margin_top", + "value": 30 + } + , + { + "name": "AlertDialog_offset", + "value": -20 + } + ] } \ No newline at end of file diff --git a/code/Performance/ArkRuntime/NBody/entry/src/ohosTest/module.json5 b/code/Performance/ArkRuntime/NBody/entry/src/ohosTest/module.json5 index 404ccf0b4c..fb9aa43871 100644 --- a/code/Performance/ArkRuntime/NBody/entry/src/ohosTest/module.json5 +++ b/code/Performance/ArkRuntime/NBody/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/Performance/ArkRuntime/NBody/hvigor/hvigor-config.json5 b/code/Performance/ArkRuntime/NBody/hvigor/hvigor-config.json5 index 3a4f957eef..277e9a1fd2 100644 --- a/code/Performance/ArkRuntime/NBody/hvigor/hvigor-config.json5 +++ b/code/Performance/ArkRuntime/NBody/hvigor/hvigor-config.json5 @@ -1,18 +1,18 @@ -{ - "hvigorVersion": "3.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.2" - }, - "execution": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } -} +{ + "hvigorVersion": "3.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.2" + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } +} diff --git a/code/Performance/ArkRuntime/NBody/oh-package.json5 b/code/Performance/ArkRuntime/NBody/oh-package.json5 index cefc7c1df3..ec0ac2d207 100644 --- a/code/Performance/ArkRuntime/NBody/oh-package.json5 +++ b/code/Performance/ArkRuntime/NBody/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "nbody", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "nbody", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/Performance/renderGroup/AppScope/app.json5 b/code/Performance/renderGroup/AppScope/app.json5 index eda9bfffde..ed45531571 100644 --- a/code/Performance/renderGroup/AppScope/app.json5 +++ b/code/Performance/renderGroup/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.example.performance", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.example.performance", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/Performance/renderGroup/AppScope/resources/base/element/string.json b/code/Performance/renderGroup/AppScope/resources/base/element/string.json index 07e1971224..e330d1e5e1 100644 --- a/code/Performance/renderGroup/AppScope/resources/base/element/string.json +++ b/code/Performance/renderGroup/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "Performance" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "Performance" + } + ] +} diff --git a/code/Performance/renderGroup/README.md b/code/Performance/renderGroup/README.md index b2bd66ccd8..37bdd8d1f6 100644 --- a/code/Performance/renderGroup/README.md +++ b/code/Performance/renderGroup/README.md @@ -1,87 +1,87 @@ -# 性能示例 - -### 介绍 - -本示例使用renderGroup接口实现了在单一页面上存在大量应用动效的组件时,使用renderGroup方法来解决卡顿问题,从而提升绘制能力。 - -renderGroup原理说明:首次绘制组件时,若组件被标记为启用renderGroup状态,将对组件和其子组件进行离屏绘制,将绘制结果进行缓存。以后当需要重新绘制组件时,就会优先使用缓存而不必重新绘制了。从而降低绘制负载,优化渲染性能。 - -### 效果预览 -| 性能示例主页 | 场景主页 | 正例场景页 | 反例场景页 | -| ------------------------------------- |--------------------------------------------------| -------------------------------------- | ----------------------------------- | -| ![](screenshots/device/PerformanceHomePage.jpeg) | ![](screenshots/device/RenderGroupHomePage.jpeg) | ![](screenshots/device/ProfitScenePage.jpeg) | ![](screenshots/device/NonProfitScenePage.jpeg) | - -使用说明 - -1.点击性能示例主页面的**RenderGroup**按钮,在场景界面中点击**正例场景示例**,进入正例场景页,可以点击renderGroup开关按钮,可以通过Profiler分析性能数据。 - -2.点击性能示例主页面的**RenderGroup**按钮,在场景界面中点击**反例场景示例**,进入反例场景页,可以点击renderGroup开关按钮,可以通过Profiler分析性能数据。 - -### 工程目录 - -``` -features/renderGroup/src/main/ets // 列表类功能HAR共享包 -|---/pages -| |---NonProfitScene.ets // 反例场景页面 -| |---ProfitScene.ets // 正例场景页面 -|---/utils -| |---Logger.ets // 封装整个日志 -|---/view -| |---IconView.ets // 正例场景模块 -| |---NonIconView.ets // 反例场景模块 -products/phone/entry/src/main/ets -|---/entryability -| |---EntryAbility.ts // 封装整个模块启用,监听Ability对应的窗口等逻辑 -|---/model -| |---/DataType // 数据类型 -| |---/MockData // 本地数据 -|---pages -| |---/renderGroup -| | |---NonProfitScenePage.ets // 反例场景页面 -| | |---ProfitScenePage.ets // 正例场景页面 -| | |---RenderGroupHomePage.ets // 场景主页面 -| |---/Index // 性能示例首页 -|---/utils -| |---Logger.ets // 封装整个日志 - -``` - -### 具体实现 - -* 本示例分成正例场景与反例场景两个模块 - - * 正例场景 - - * 在ProfitScene的IconItem上添加动画,在IconView上使用到renderGroup接口(renderGroup(value: boolean): T)得到收益。 - * 源码链接:[ProfitScene.ets](feature/renderGroup/src/main/ets/pages/ProfitScene.ets),[IconView.ts](feature/renderGroup/src/main/ets/view/IconView.ets) - - * 反例场景 - - * 在IconView的Image上添加动画,在NonIconView上使用到renderGroup接口(renderGroup(value: boolean): T)得到负收益。 - * 源码链接:[NonProfitScene.ets](feature/renderGroup/src/main/ets/pages/NonProfitScene.ets),[NonIconView.ts](feature/renderGroup/src/main/ets/view/NonIconView.ets) - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例已适配API version 10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0Release)。 - -2.本示例需要使用DevEco Studio 版本号(4.0Release)及以上版本才可编译运行。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/Performance/renderGroup/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# 性能示例 + +### 介绍 + +本示例使用renderGroup接口实现了在单一页面上存在大量应用动效的组件时,使用renderGroup方法来解决卡顿问题,从而提升绘制能力。 + +renderGroup原理说明:首次绘制组件时,若组件被标记为启用renderGroup状态,将对组件和其子组件进行离屏绘制,将绘制结果进行缓存。以后当需要重新绘制组件时,就会优先使用缓存而不必重新绘制了。从而降低绘制负载,优化渲染性能。 + +### 效果预览 +| 性能示例主页 | 场景主页 | 正例场景页 | 反例场景页 | +| ------------------------------------- |--------------------------------------------------| -------------------------------------- | ----------------------------------- | +| ![](screenshots/device/PerformanceHomePage.jpeg) | ![](screenshots/device/RenderGroupHomePage.jpeg) | ![](screenshots/device/ProfitScenePage.jpeg) | ![](screenshots/device/NonProfitScenePage.jpeg) | + +使用说明 + +1.点击性能示例主页面的**RenderGroup**按钮,在场景界面中点击**正例场景示例**,进入正例场景页,可以点击renderGroup开关按钮,可以通过Profiler分析性能数据。 + +2.点击性能示例主页面的**RenderGroup**按钮,在场景界面中点击**反例场景示例**,进入反例场景页,可以点击renderGroup开关按钮,可以通过Profiler分析性能数据。 + +### 工程目录 + +``` +features/renderGroup/src/main/ets // 列表类功能HAR共享包 +|---/pages +| |---NonProfitScene.ets // 反例场景页面 +| |---ProfitScene.ets // 正例场景页面 +|---/utils +| |---Logger.ets // 封装整个日志 +|---/view +| |---IconView.ets // 正例场景模块 +| |---NonIconView.ets // 反例场景模块 +products/phone/entry/src/main/ets +|---/entryability +| |---EntryAbility.ts // 封装整个模块启用,监听Ability对应的窗口等逻辑 +|---/model +| |---/DataType // 数据类型 +| |---/MockData // 本地数据 +|---pages +| |---/renderGroup +| | |---NonProfitScenePage.ets // 反例场景页面 +| | |---ProfitScenePage.ets // 正例场景页面 +| | |---RenderGroupHomePage.ets // 场景主页面 +| |---/Index // 性能示例首页 +|---/utils +| |---Logger.ets // 封装整个日志 + +``` + +### 具体实现 + +* 本示例分成正例场景与反例场景两个模块 + + * 正例场景 + + * 在ProfitScene的IconItem上添加动画,在IconView上使用到renderGroup接口(renderGroup(value: boolean): T)得到收益。 + * 源码链接:[ProfitScene.ets](feature/renderGroup/src/main/ets/pages/ProfitScene.ets),[IconView.ts](feature/renderGroup/src/main/ets/view/IconView.ets) + + * 反例场景 + + * 在IconView的Image上添加动画,在NonIconView上使用到renderGroup接口(renderGroup(value: boolean): T)得到负收益。 + * 源码链接:[NonProfitScene.ets](feature/renderGroup/src/main/ets/pages/NonProfitScene.ets),[NonIconView.ts](feature/renderGroup/src/main/ets/view/NonIconView.ets) + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例已适配API version 10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0Release)。 + +2.本示例需要使用DevEco Studio 版本号(4.0Release)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/Performance/renderGroup/ > .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/Performance/renderGroup/build-profile.json5 b/code/Performance/renderGroup/build-profile.json5 index 5fc0f34eb6..f84138f190 100644 --- a/code/Performance/renderGroup/build-profile.json5 +++ b/code/Performance/renderGroup/build-profile.json5 @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./product/phone/entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "renderGroup", - "srcPath": "./feature/renderGroup" - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "runtimeOS": "OpenHarmony" + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./product/phone/entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "renderGroup", + "srcPath": "./feature/renderGroup" + } + ] } \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/Index.ets b/code/Performance/renderGroup/feature/renderGroup/Index.ets index 240e61d114..a205148552 100644 --- a/code/Performance/renderGroup/feature/renderGroup/Index.ets +++ b/code/Performance/renderGroup/feature/renderGroup/Index.ets @@ -1,18 +1,18 @@ -/* - * Copyright (c) 2023 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 { ProfitScene } from './src/main/ets/pages/ProfitScene'; - +/* + * Copyright (c) 2023 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 { ProfitScene } from './src/main/ets/pages/ProfitScene'; + export { NonProfitScene } from './src/main/ets/pages/NonProfitScene'; \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/build-profile.json5 b/code/Performance/renderGroup/feature/renderGroup/build-profile.json5 index 2f44828ebc..805afd07d8 100644 --- a/code/Performance/renderGroup/feature/renderGroup/build-profile.json5 +++ b/code/Performance/renderGroup/feature/renderGroup/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023 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" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - } - }, - ], - "targets": [ - { - "name": "default" - } - ] -} +/* + * Copyright (c) 2023 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" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + } + }, + ], + "targets": [ + { + "name": "default" + } + ] +} diff --git a/code/Performance/renderGroup/feature/renderGroup/oh-package.json5 b/code/Performance/renderGroup/feature/renderGroup/oh-package.json5 index dfa8449e0b..a3eb37e069 100644 --- a/code/Performance/renderGroup/feature/renderGroup/oh-package.json5 +++ b/code/Performance/renderGroup/feature/renderGroup/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "Apache-2.0", - "devDependencies": {}, - "author": "", - "name": "rendergroup", - "description": "Please describe the basic information.", - "main": "Index.ets", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "Apache-2.0", + "devDependencies": {}, + "author": "", + "name": "rendergroup", + "description": "Please describe the basic information.", + "main": "Index.ets", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/ets/pages/NonProfitScene.ets b/code/Performance/renderGroup/feature/renderGroup/src/main/ets/pages/NonProfitScene.ets index c796b8ad2b..10e50519a4 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/ets/pages/NonProfitScene.ets +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/ets/pages/NonProfitScene.ets @@ -1,127 +1,127 @@ -/* - * Copyright (c) 2023 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 { NonIconItem } from '../view/NonIconView'; -import router from '@ohos.router' - -// GridRow列数 -const COLUMNS: number = 6; -// GridRow横向间隙 -const GUTTER_X: number = 0; -// GridRow纵向间隙 -const GUTTER_Y: number = 0; - -// IconItem相关数据 -class IconItemSource { - image: string | Resource = '' - text: string | Resource = '' - - constructor(image: string | Resource = '', text: string | Resource = '') { - this.image = image; - this.text = text; - } -} - -@Component -export struct NonProfitScene { - // renderGroup接口是否开启 - @State renderGroupFlag: boolean = false; - private iconItemSourceList: IconItemSource[] = []; - - aboutToAppear() { - // 遍历添加60个IconItem的数据 - for (let index = 0; index < 20; index++) { - const numStart: number = index * 3; - // 此处循环使用三张图片资源 - this.iconItemSourceList.push(new IconItemSource($r('app.media.nearby'), `item${numStart + 1}`)); - this.iconItemSourceList.push(new IconItemSource($r('app.media.scan'), `item${numStart + 2}`)); - this.iconItemSourceList.push(new IconItemSource($r('app.media.shop'), `item${numStart + 3}`)); - } - } - - build() { - Column() { - // 顶部导航栏 - Row() { - Row() { - Image($r("app.media.back")) - .id('returnBtn') - .height($r('app.integer.RenderGroup_scene_back_image_size')) - .width($r('app.integer.RenderGroup_scene_back_image_size')) - .onClick(() => { - router.back(); - }) - - Text($r('app.string.RenderGroup_nonProfit_scene_title')) - .fontSize($r('app.integer.RenderGroup_scene_title_font')) - .lineHeight($r('app.integer.RenderGroup_scene_title_lineHeight')) - .fontColor(Color.Black) - .fontWeight(FontWeight.Bold) - .textAlign(TextAlign.Start) - .margin({ - left: $r('app.integer.RenderGroup_scene_title_margin_left') - }) - } - .margin({ - left: $r('app.integer.RenderGroup_scene_row_margin_left') - }) - - Stack({ alignContent: Alignment.End }) { - Button(this.renderGroupFlag ? $r('app.string.RenderGroup_button_on') : $r('app.string.RenderGroup_button_off'), { - type: ButtonType.Normal, - stateEffect: true - }) - .id("renderGroupSwitch") - .fontSize($r('app.integer.RenderGroup_scene_button_fontSize')) - .borderRadius($r('app.integer.RenderGroup_scene_button_borderRadius')) - .backgroundColor($r('app.color.RenderGroup_scene_button_backgroundColor')) - .width($r('app.integer.RenderGroup_scene_title_button_width')) - .height($r('app.integer.RenderGroup_scene_title_button_height')) - .margin({ - right: $r('app.integer.RenderGroup_scene_button_margin_right') - }) - .onClick(() => { - this.renderGroupFlag = !this.renderGroupFlag; - }) - } - } - .height($r('app.integer.RenderGroup_scene_title_row_height')) - .width($r('app.string.layout_100_percent')) - .backgroundColor(Color.White) - .justifyContent(FlexAlign.SpaceBetween) - - // IconItem放置在grid内 - GridRow({ - columns: COLUMNS, - gutter: { x: GUTTER_X, y: GUTTER_Y }, - breakpoints: { value: ["400vp", "600vp", "800vp"], reference: BreakpointsReference.WindowSize }, - direction: GridRowDirection.Row - }) { - ForEach(this.iconItemSourceList, (item: IconItemSource) => { - GridCol() { - NonIconItem({ image: item.image, text: item.text, renderGroupFlag: this.renderGroupFlag }) - } - .height($r('app.integer.RenderGroup_scene_GridCol_height')) - .width($r('app.string.layout_17_percent')) - }) - } - .width($r('app.string.layout_100_percent')) - .height($r('app.string.layout_100_percent')) - } - .width($r('app.string.layout_100_percent')) - .height($r('app.string.layout_100_percent')) - .alignItems(HorizontalAlign.Center) - } +/* + * Copyright (c) 2023 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 { NonIconItem } from '../view/NonIconView'; +import router from '@ohos.router' + +// GridRow列数 +const COLUMNS: number = 6; +// GridRow横向间隙 +const GUTTER_X: number = 0; +// GridRow纵向间隙 +const GUTTER_Y: number = 0; + +// IconItem相关数据 +class IconItemSource { + image: string | Resource = '' + text: string | Resource = '' + + constructor(image: string | Resource = '', text: string | Resource = '') { + this.image = image; + this.text = text; + } +} + +@Component +export struct NonProfitScene { + // renderGroup接口是否开启 + @State renderGroupFlag: boolean = false; + private iconItemSourceList: IconItemSource[] = []; + + aboutToAppear() { + // 遍历添加60个IconItem的数据 + for (let index = 0; index < 20; index++) { + const numStart: number = index * 3; + // 此处循环使用三张图片资源 + this.iconItemSourceList.push(new IconItemSource($r('app.media.nearby'), `item${numStart + 1}`)); + this.iconItemSourceList.push(new IconItemSource($r('app.media.scan'), `item${numStart + 2}`)); + this.iconItemSourceList.push(new IconItemSource($r('app.media.shop'), `item${numStart + 3}`)); + } + } + + build() { + Column() { + // 顶部导航栏 + Row() { + Row() { + Image($r("app.media.back")) + .id('returnBtn') + .height($r('app.integer.RenderGroup_scene_back_image_size')) + .width($r('app.integer.RenderGroup_scene_back_image_size')) + .onClick(() => { + router.back(); + }) + + Text($r('app.string.RenderGroup_nonProfit_scene_title')) + .fontSize($r('app.integer.RenderGroup_scene_title_font')) + .lineHeight($r('app.integer.RenderGroup_scene_title_lineHeight')) + .fontColor(Color.Black) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + .margin({ + left: $r('app.integer.RenderGroup_scene_title_margin_left') + }) + } + .margin({ + left: $r('app.integer.RenderGroup_scene_row_margin_left') + }) + + Stack({ alignContent: Alignment.End }) { + Button(this.renderGroupFlag ? $r('app.string.RenderGroup_button_on') : $r('app.string.RenderGroup_button_off'), { + type: ButtonType.Normal, + stateEffect: true + }) + .id("renderGroupSwitch") + .fontSize($r('app.integer.RenderGroup_scene_button_fontSize')) + .borderRadius($r('app.integer.RenderGroup_scene_button_borderRadius')) + .backgroundColor($r('app.color.RenderGroup_scene_button_backgroundColor')) + .width($r('app.integer.RenderGroup_scene_title_button_width')) + .height($r('app.integer.RenderGroup_scene_title_button_height')) + .margin({ + right: $r('app.integer.RenderGroup_scene_button_margin_right') + }) + .onClick(() => { + this.renderGroupFlag = !this.renderGroupFlag; + }) + } + } + .height($r('app.integer.RenderGroup_scene_title_row_height')) + .width($r('app.string.layout_100_percent')) + .backgroundColor(Color.White) + .justifyContent(FlexAlign.SpaceBetween) + + // IconItem放置在grid内 + GridRow({ + columns: COLUMNS, + gutter: { x: GUTTER_X, y: GUTTER_Y }, + breakpoints: { value: ["400vp", "600vp", "800vp"], reference: BreakpointsReference.WindowSize }, + direction: GridRowDirection.Row + }) { + ForEach(this.iconItemSourceList, (item: IconItemSource) => { + GridCol() { + NonIconItem({ image: item.image, text: item.text, renderGroupFlag: this.renderGroupFlag }) + } + .height($r('app.integer.RenderGroup_scene_GridCol_height')) + .width($r('app.string.layout_17_percent')) + }) + } + .width($r('app.string.layout_100_percent')) + .height($r('app.string.layout_100_percent')) + } + .width($r('app.string.layout_100_percent')) + .height($r('app.string.layout_100_percent')) + .alignItems(HorizontalAlign.Center) + } } \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/ets/pages/ProfitScene.ets b/code/Performance/renderGroup/feature/renderGroup/src/main/ets/pages/ProfitScene.ets index 1340c8fcf7..f9dea3782a 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/ets/pages/ProfitScene.ets +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/ets/pages/ProfitScene.ets @@ -1,144 +1,144 @@ -/* - * Copyright (c) 2023 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 { IconItem } from '../view/IconView'; -import router from '@ohos.router' - -// GridRow列数 -const COLUMNS: number = 6; -// GridRow横向间隙 -const GUTTER_X: number = 0; -// GridRow纵向间隙 -const GUTTER_Y: number = 0; -// X轴方向缩放比例 -const SCALE_X: number = 0.5; -// Y轴方向缩放比例 -const SCALE_Y: number = 0.5; -// 绕z轴旋转 -const ROTATE_Z: number = 1; -// 旋转角度 -const ROTATE_ANGLE: number = 360; -// 动画时长 -const DURATION: number = 3000; -// 重复次数 -const ITERATIONS: number = -1; - - -// IconItem相关数据 -class IconItemSource { - image: string | Resource = '' - text: string | Resource = '' - - constructor(image: string | Resource = '', text: string | Resource = '') { - this.image = image; - this.text = text; - } -} - -@Component -export struct ProfitScene { - // renderGroup接口是否开启 - @State renderGroupFlag: boolean = false; - private iconItemSourceList: IconItemSource[] = []; - - aboutToAppear() { - // 遍历添加60个IconItem的数据 - for (let index = 0; index < 20; index++) { - const numStart: number = index * 3; - // 此处循环使用三张图片资源 - this.iconItemSourceList.push(new IconItemSource($r('app.media.album'), `item${numStart + 1}`)); - this.iconItemSourceList.push(new IconItemSource($r('app.media.applet'), `item${numStart + 2}`)); - this.iconItemSourceList.push(new IconItemSource($r('app.media.cards'), `item${numStart + 3}`)); - } - } - - build() { - Column() { - // 顶部导航栏 - Row() { - Row() { - Image($r("app.media.back")) - .id('returnBtn') - .height($r('app.integer.RenderGroup_scene_back_image_size')) - .width($r('app.integer.RenderGroup_scene_back_image_size')) - .onClick(() => { - router.back(); - }) - - Text($r('app.string.RenderGroup_profit_scene_title')) - .fontSize($r('app.integer.RenderGroup_scene_title_font')) - .lineHeight($r('app.integer.RenderGroup_scene_title_lineHeight')) - .fontColor(Color.Black) - .fontWeight(FontWeight.Bold) - .textAlign(TextAlign.Start) - .margin({ - left: $r('app.integer.RenderGroup_scene_title_margin_left') - }) - } - .margin({ - left: $r('app.integer.RenderGroup_scene_row_margin_left') - }) - - Stack({ alignContent: Alignment.End }) { - Button(this.renderGroupFlag ? $r('app.string.RenderGroup_button_on') : $r('app.string.RenderGroup_button_off'), { - type: ButtonType.Normal, - stateEffect: true - }) - .id("renderGroupSwitch") - .fontSize($r('app.integer.RenderGroup_scene_button_fontSize')) - .borderRadius($r('app.integer.RenderGroup_scene_button_borderRadius')) - .backgroundColor($r('app.color.RenderGroup_scene_button_backgroundColor')) - .width($r('app.integer.RenderGroup_scene_title_button_width')) - .height($r('app.integer.RenderGroup_scene_title_button_height')) - .margin({ - right: $r('app.integer.RenderGroup_scene_button_margin_right') - }) - .onClick(() => { - this.renderGroupFlag = !this.renderGroupFlag; - }) - } - } - .height($r('app.integer.RenderGroup_scene_title_row_height')) - .width($r('app.string.layout_100_percent')) - .backgroundColor(Color.White) - .justifyContent(FlexAlign.SpaceBetween) - - // IconItem放置在grid内 - GridRow({ - columns: COLUMNS, - gutter: { x: GUTTER_X, y: GUTTER_Y }, - breakpoints: { value: ["400vp", "600vp", "800vp"], reference: BreakpointsReference.WindowSize }, - direction: GridRowDirection.Row - }) { - ForEach(this.iconItemSourceList, (item: IconItemSource) => { - GridCol() { - IconItem({ image: item.image, text: item.text, renderGroupFlag: this.renderGroupFlag }) - .transition(TransitionEffect.scale({ x: SCALE_X, y: SCALE_Y }) - .animation({ duration: DURATION, curve: Curve.FastOutSlowIn, iterations: ITERATIONS }) - .combine(TransitionEffect.rotate({ z: ROTATE_Z, angle: ROTATE_ANGLE }) - .animation({ duration: DURATION, curve: Curve.Linear, iterations: ITERATIONS }))) - } - .height($r('app.integer.RenderGroup_scene_GridCol_height')) - .width($r('app.string.layout_17_percent')) - }) - } - .width($r('app.string.layout_100_percent')) - .height($r('app.string.layout_100_percent')) - } - .width($r('app.string.layout_100_percent')) - .height($r('app.string.layout_100_percent')) - .alignItems(HorizontalAlign.Center) - } +/* + * Copyright (c) 2023 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 { IconItem } from '../view/IconView'; +import router from '@ohos.router' + +// GridRow列数 +const COLUMNS: number = 6; +// GridRow横向间隙 +const GUTTER_X: number = 0; +// GridRow纵向间隙 +const GUTTER_Y: number = 0; +// X轴方向缩放比例 +const SCALE_X: number = 0.5; +// Y轴方向缩放比例 +const SCALE_Y: number = 0.5; +// 绕z轴旋转 +const ROTATE_Z: number = 1; +// 旋转角度 +const ROTATE_ANGLE: number = 360; +// 动画时长 +const DURATION: number = 3000; +// 重复次数 +const ITERATIONS: number = -1; + + +// IconItem相关数据 +class IconItemSource { + image: string | Resource = '' + text: string | Resource = '' + + constructor(image: string | Resource = '', text: string | Resource = '') { + this.image = image; + this.text = text; + } +} + +@Component +export struct ProfitScene { + // renderGroup接口是否开启 + @State renderGroupFlag: boolean = false; + private iconItemSourceList: IconItemSource[] = []; + + aboutToAppear() { + // 遍历添加60个IconItem的数据 + for (let index = 0; index < 20; index++) { + const numStart: number = index * 3; + // 此处循环使用三张图片资源 + this.iconItemSourceList.push(new IconItemSource($r('app.media.album'), `item${numStart + 1}`)); + this.iconItemSourceList.push(new IconItemSource($r('app.media.applet'), `item${numStart + 2}`)); + this.iconItemSourceList.push(new IconItemSource($r('app.media.cards'), `item${numStart + 3}`)); + } + } + + build() { + Column() { + // 顶部导航栏 + Row() { + Row() { + Image($r("app.media.back")) + .id('returnBtn') + .height($r('app.integer.RenderGroup_scene_back_image_size')) + .width($r('app.integer.RenderGroup_scene_back_image_size')) + .onClick(() => { + router.back(); + }) + + Text($r('app.string.RenderGroup_profit_scene_title')) + .fontSize($r('app.integer.RenderGroup_scene_title_font')) + .lineHeight($r('app.integer.RenderGroup_scene_title_lineHeight')) + .fontColor(Color.Black) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + .margin({ + left: $r('app.integer.RenderGroup_scene_title_margin_left') + }) + } + .margin({ + left: $r('app.integer.RenderGroup_scene_row_margin_left') + }) + + Stack({ alignContent: Alignment.End }) { + Button(this.renderGroupFlag ? $r('app.string.RenderGroup_button_on') : $r('app.string.RenderGroup_button_off'), { + type: ButtonType.Normal, + stateEffect: true + }) + .id("renderGroupSwitch") + .fontSize($r('app.integer.RenderGroup_scene_button_fontSize')) + .borderRadius($r('app.integer.RenderGroup_scene_button_borderRadius')) + .backgroundColor($r('app.color.RenderGroup_scene_button_backgroundColor')) + .width($r('app.integer.RenderGroup_scene_title_button_width')) + .height($r('app.integer.RenderGroup_scene_title_button_height')) + .margin({ + right: $r('app.integer.RenderGroup_scene_button_margin_right') + }) + .onClick(() => { + this.renderGroupFlag = !this.renderGroupFlag; + }) + } + } + .height($r('app.integer.RenderGroup_scene_title_row_height')) + .width($r('app.string.layout_100_percent')) + .backgroundColor(Color.White) + .justifyContent(FlexAlign.SpaceBetween) + + // IconItem放置在grid内 + GridRow({ + columns: COLUMNS, + gutter: { x: GUTTER_X, y: GUTTER_Y }, + breakpoints: { value: ["400vp", "600vp", "800vp"], reference: BreakpointsReference.WindowSize }, + direction: GridRowDirection.Row + }) { + ForEach(this.iconItemSourceList, (item: IconItemSource) => { + GridCol() { + IconItem({ image: item.image, text: item.text, renderGroupFlag: this.renderGroupFlag }) + .transition(TransitionEffect.scale({ x: SCALE_X, y: SCALE_Y }) + .animation({ duration: DURATION, curve: Curve.FastOutSlowIn, iterations: ITERATIONS }) + .combine(TransitionEffect.rotate({ z: ROTATE_Z, angle: ROTATE_ANGLE }) + .animation({ duration: DURATION, curve: Curve.Linear, iterations: ITERATIONS }))) + } + .height($r('app.integer.RenderGroup_scene_GridCol_height')) + .width($r('app.string.layout_17_percent')) + }) + } + .width($r('app.string.layout_100_percent')) + .height($r('app.string.layout_100_percent')) + } + .width($r('app.string.layout_100_percent')) + .height($r('app.string.layout_100_percent')) + .alignItems(HorizontalAlign.Center) + } } \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/ets/utils/Logger.ets b/code/Performance/renderGroup/feature/renderGroup/src/main/ets/utils/Logger.ets index 169a17ae53..3a51cfce32 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/ets/utils/Logger.ets +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/ets/utils/Logger.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - // 日志对应的领域标识 - private domain: number = 0xF811; - // tag日志标识 - private prefix: string = '[Samples_RenderGroup]'; - // 格式字符串,用于日志的格式化输出 - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + // 日志对应的领域标识 + private domain: number = 0xF811; + // tag日志标识 + private prefix: string = '[Samples_RenderGroup]'; + // 格式字符串,用于日志的格式化输出 + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Samples_RenderGroup]'); \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/ets/view/IconView.ets b/code/Performance/renderGroup/feature/renderGroup/src/main/ets/view/IconView.ets index 0cd6da69de..4e204a0753 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/ets/view/IconView.ets +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/ets/view/IconView.ets @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 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 TEXT_OPACITY: number = 0.8; - -@Component -export struct IconItem { - @Link renderGroupFlag: boolean; - image: string | Resource = ''; - text: string | Resource = ''; - - build() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignContent: FlexAlign.Center }) { - Image(this.image) - .height($r('app.integer.RenderGroup_item_image_height')) - .width($r('app.integer.RenderGroup_item_image_width')) - .objectFit(ImageFit.Contain) - .margin({ - left: $r('app.integer.RenderGroup_item_image_margin') - }) - - Text(this.text) - .fontSize($r('app.integer.RenderGroup_item_text_font')) - .fontColor($r('app.color.RenderGroup_item_text_fontColor')) - .margin({ - top: $r('app.integer.RenderGroup_item_text_margin_top') - }) - .width($r('app.integer.RenderGroup_item_text_width')) - .opacity(TEXT_OPACITY) - .textAlign(TextAlign.Center) - } - .backgroundColor($r('app.color.RenderGroup_item_backgroundColor')) - .width($r('app.integer.RenderGroup_item_width')) - .height($r('app.integer.RenderGroup_item_height')) - .borderRadius($r('app.integer.RenderGroup_item_borderRadius')) - // 在IconItem内调用renderGroup,true为开启,false为关闭 - .renderGroup(this.renderGroupFlag) - } +/* + * Copyright (c) 2023 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 TEXT_OPACITY: number = 0.8; + +@Component +export struct IconItem { + @Link renderGroupFlag: boolean; + image: string | Resource = ''; + text: string | Resource = ''; + + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignContent: FlexAlign.Center }) { + Image(this.image) + .height($r('app.integer.RenderGroup_item_image_height')) + .width($r('app.integer.RenderGroup_item_image_width')) + .objectFit(ImageFit.Contain) + .margin({ + left: $r('app.integer.RenderGroup_item_image_margin') + }) + + Text(this.text) + .fontSize($r('app.integer.RenderGroup_item_text_font')) + .fontColor($r('app.color.RenderGroup_item_text_fontColor')) + .margin({ + top: $r('app.integer.RenderGroup_item_text_margin_top') + }) + .width($r('app.integer.RenderGroup_item_text_width')) + .opacity(TEXT_OPACITY) + .textAlign(TextAlign.Center) + } + .backgroundColor($r('app.color.RenderGroup_item_backgroundColor')) + .width($r('app.integer.RenderGroup_item_width')) + .height($r('app.integer.RenderGroup_item_height')) + .borderRadius($r('app.integer.RenderGroup_item_borderRadius')) + // 在IconItem内调用renderGroup,true为开启,false为关闭 + .renderGroup(this.renderGroupFlag) + } } \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/ets/view/NonIconView.ets b/code/Performance/renderGroup/feature/renderGroup/src/main/ets/view/NonIconView.ets index 5625395384..ef4bdd782e 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/ets/view/NonIconView.ets +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/ets/view/NonIconView.ets @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2023 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. - */ - -// 绕z轴旋转 -const ROTATE_Z: number = 1; -// 旋转角度 -const ROTATE_ANGLE: number = 360; -// 旋转时长 -const ROTATE_DURATION: number = 3000; -// 重复次数 -const ROTATE_ITERATIONS: number = -1; -// 字体透明度 -const TEXT_OPACITY: number = 0.8; - -@Component -export struct NonIconItem { - @Link renderGroupFlag: boolean; - image: string | Resource = ''; - text: string | Resource = ''; - - build() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignContent: FlexAlign.Center }) { - Image(this.image) - .height($r('app.integer.RenderGroup_item_image_height')) - .width($r('app.integer.RenderGroup_item_image_width')) - .objectFit(ImageFit.Contain) - .margin({ - left: $r('app.integer.RenderGroup_item_image_margin') - }) - .transition(TransitionEffect.rotate({ z: ROTATE_Z, angle: ROTATE_ANGLE }) - .animation({ duration: ROTATE_DURATION, curve: Curve.Linear, iterations: ROTATE_ITERATIONS })) - - Text(this.text) - .fontSize($r('app.integer.RenderGroup_item_text_font')) - .fontColor($r('app.color.RenderGroup_item_text_fontColor')) - .margin({ - top: $r('app.integer.RenderGroup_item_text_margin_top') - }) - .width($r('app.integer.RenderGroup_item_text_width')) - .opacity(TEXT_OPACITY) - .textAlign(TextAlign.Center) - } - .backgroundColor($r('app.color.RenderGroup_item_backgroundColor')) - .width($r('app.integer.RenderGroup_item_width')) - .height($r('app.integer.RenderGroup_item_height')) - .borderRadius($r('app.integer.RenderGroup_item_borderRadius')) - // 在IconItem内调用renderGroup,true为开启,false为关闭 - .renderGroup(this.renderGroupFlag) - } +/* + * Copyright (c) 2023 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. + */ + +// 绕z轴旋转 +const ROTATE_Z: number = 1; +// 旋转角度 +const ROTATE_ANGLE: number = 360; +// 旋转时长 +const ROTATE_DURATION: number = 3000; +// 重复次数 +const ROTATE_ITERATIONS: number = -1; +// 字体透明度 +const TEXT_OPACITY: number = 0.8; + +@Component +export struct NonIconItem { + @Link renderGroupFlag: boolean; + image: string | Resource = ''; + text: string | Resource = ''; + + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignContent: FlexAlign.Center }) { + Image(this.image) + .height($r('app.integer.RenderGroup_item_image_height')) + .width($r('app.integer.RenderGroup_item_image_width')) + .objectFit(ImageFit.Contain) + .margin({ + left: $r('app.integer.RenderGroup_item_image_margin') + }) + .transition(TransitionEffect.rotate({ z: ROTATE_Z, angle: ROTATE_ANGLE }) + .animation({ duration: ROTATE_DURATION, curve: Curve.Linear, iterations: ROTATE_ITERATIONS })) + + Text(this.text) + .fontSize($r('app.integer.RenderGroup_item_text_font')) + .fontColor($r('app.color.RenderGroup_item_text_fontColor')) + .margin({ + top: $r('app.integer.RenderGroup_item_text_margin_top') + }) + .width($r('app.integer.RenderGroup_item_text_width')) + .opacity(TEXT_OPACITY) + .textAlign(TextAlign.Center) + } + .backgroundColor($r('app.color.RenderGroup_item_backgroundColor')) + .width($r('app.integer.RenderGroup_item_width')) + .height($r('app.integer.RenderGroup_item_height')) + .borderRadius($r('app.integer.RenderGroup_item_borderRadius')) + // 在IconItem内调用renderGroup,true为开启,false为关闭 + .renderGroup(this.renderGroupFlag) + } } \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/module.json5 b/code/Performance/renderGroup/feature/renderGroup/src/main/module.json5 index d60f69c337..4171e20ff9 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/module.json5 +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/module.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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": "renderGroup", - "type": "har", - "deviceTypes": [ - "default", - "tablet" - ] - } -} +/* + * Copyright (c) 2023 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": "renderGroup", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/element/color.json b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/element/color.json index b2859ea57a..a3bace6407 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/element/color.json +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/element/color.json @@ -1,16 +1,16 @@ -{ - "color": [ - { - "name": "RenderGroup_item_text_fontColor", - "value": "#182431" - }, - { - "name": "RenderGroup_item_backgroundColor", - "value": "#e3e3e3" - }, - { - "name": "RenderGroup_scene_button_backgroundColor", - "value": "#317aff" - } - ] +{ + "color": [ + { + "name": "RenderGroup_item_text_fontColor", + "value": "#182431" + }, + { + "name": "RenderGroup_item_backgroundColor", + "value": "#e3e3e3" + }, + { + "name": "RenderGroup_scene_button_backgroundColor", + "value": "#317aff" + } + ] } \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/element/integer.json b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/element/integer.json index 6d5f212dce..67dbd84053 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/element/integer.json +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/element/integer.json @@ -1,88 +1,88 @@ -{ - "integer": [ - { - "name": "RenderGroup_item_image_height", - "value": 20 - }, - { - "name": "RenderGroup_item_image_width", - "value": 20 - }, - { - "name": "RenderGroup_item_image_margin", - "value": 15 - }, - { - "name": "RenderGroup_item_text_font", - "value": 10 - }, - { - "name": "RenderGroup_item_text_margin_top", - "value": 5 - }, - { - "name": "RenderGroup_item_text_width", - "value": 50 - }, - { - "name": "RenderGroup_item_width", - "value": 50 - }, - { - "name": "RenderGroup_item_height", - "value": 50 - }, - { - "name": "RenderGroup_item_borderRadius", - "value": 25 - }, - { - "name": "RenderGroup_scene_back_image_size", - "value": 24 - }, - { - "name": "RenderGroup_scene_title_font", - "value": 24 - }, - { - "name": "RenderGroup_scene_title_lineHeight", - "value": 30 - }, - { - "name": "RenderGroup_scene_title_margin_left", - "value": 16 - }, - { - "name": "RenderGroup_scene_row_margin_left", - "value": 24 - }, - { - "name": "RenderGroup_scene_button_fontSize", - "value": 13 - }, - { - "name": "RenderGroup_scene_button_borderRadius", - "value": 8 - }, - { - "name": "RenderGroup_scene_title_button_width", - "value": 160 - }, - { - "name": "RenderGroup_scene_title_button_height", - "value": 30 - }, - { - "name": "RenderGroup_scene_button_margin_right", - "value": 24 - }, - { - "name": "RenderGroup_scene_title_row_height", - "value": 56 - }, - { - "name": "RenderGroup_scene_GridCol_height", - "value": 70 - } - ] +{ + "integer": [ + { + "name": "RenderGroup_item_image_height", + "value": 20 + }, + { + "name": "RenderGroup_item_image_width", + "value": 20 + }, + { + "name": "RenderGroup_item_image_margin", + "value": 15 + }, + { + "name": "RenderGroup_item_text_font", + "value": 10 + }, + { + "name": "RenderGroup_item_text_margin_top", + "value": 5 + }, + { + "name": "RenderGroup_item_text_width", + "value": 50 + }, + { + "name": "RenderGroup_item_width", + "value": 50 + }, + { + "name": "RenderGroup_item_height", + "value": 50 + }, + { + "name": "RenderGroup_item_borderRadius", + "value": 25 + }, + { + "name": "RenderGroup_scene_back_image_size", + "value": 24 + }, + { + "name": "RenderGroup_scene_title_font", + "value": 24 + }, + { + "name": "RenderGroup_scene_title_lineHeight", + "value": 30 + }, + { + "name": "RenderGroup_scene_title_margin_left", + "value": 16 + }, + { + "name": "RenderGroup_scene_row_margin_left", + "value": 24 + }, + { + "name": "RenderGroup_scene_button_fontSize", + "value": 13 + }, + { + "name": "RenderGroup_scene_button_borderRadius", + "value": 8 + }, + { + "name": "RenderGroup_scene_title_button_width", + "value": 160 + }, + { + "name": "RenderGroup_scene_title_button_height", + "value": 30 + }, + { + "name": "RenderGroup_scene_button_margin_right", + "value": 24 + }, + { + "name": "RenderGroup_scene_title_row_height", + "value": 56 + }, + { + "name": "RenderGroup_scene_GridCol_height", + "value": 70 + } + ] } \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/album.svg b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/album.svg index c891dd3e23..7b14dc6263 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/album.svg +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/album.svg @@ -1,30 +1,30 @@ - - - ic_album - - - - - - - - - - - - - - - - - - - - - - - - - - + + + ic_album + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/applet.svg b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/applet.svg index 81842a9786..ebe013f917 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/applet.svg +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/applet.svg @@ -1,16 +1,16 @@ - - - ic_applet - - - - - - - - - - - - + + + ic_applet + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/back.svg b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/back.svg index e84df74e26..57acebd122 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/back.svg +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/back.svg @@ -1,23 +1,23 @@ - - - public/ic_back - - - - - - - - - - - - - - - - - - - + + + public/ic_back + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/cards.svg b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/cards.svg index 1554170503..aeb80463ad 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/cards.svg +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/cards.svg @@ -1,28 +1,28 @@ - - - ic_cards - - - - - - - - - - - - - - - - - - - - - - - - + + + ic_cards + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/nearby.svg b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/nearby.svg index 8031837dde..56852c4b51 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/nearby.svg +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/nearby.svg @@ -1,31 +1,31 @@ - - - ic_near - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + ic_near + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/scan.svg b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/scan.svg index 1dd38531fc..dae3d51e2c 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/scan.svg +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/scan.svg @@ -1,29 +1,29 @@ - - - ic_scan - - - - - - - - - - - - - - - - - - - - - - - - - + + + ic_scan + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/shop.svg b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/shop.svg index ee8e19061e..672daaa49e 100644 --- a/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/shop.svg +++ b/code/Performance/renderGroup/feature/renderGroup/src/main/resources/base/media/shop.svg @@ -1,31 +1,31 @@ - - - ic_shop - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + ic_shop + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Performance/renderGroup/hvigor/hvigor-config.json5 b/code/Performance/renderGroup/hvigor/hvigor-config.json5 index 213d992653..a7edd62de4 100644 --- a/code/Performance/renderGroup/hvigor/hvigor-config.json5 +++ b/code/Performance/renderGroup/hvigor/hvigor-config.json5 @@ -1,18 +1,18 @@ -{ - "hvigorVersion": "3.0.9", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.9" - }, - "execution": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } +{ + "hvigorVersion": "3.0.9", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.9" + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } } \ No newline at end of file diff --git a/code/Performance/renderGroup/oh-package.json5 b/code/Performance/renderGroup/oh-package.json5 index 45f119bb6b..a7ab602e43 100644 --- a/code/Performance/renderGroup/oh-package.json5 +++ b/code/Performance/renderGroup/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "performance", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "performance", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/Performance/renderGroup/product/phone/entry/build-profile.json5 b/code/Performance/renderGroup/product/phone/entry/build-profile.json5 index d384599700..3360e1a754 100644 --- a/code/Performance/renderGroup/product/phone/entry/build-profile.json5 +++ b/code/Performance/renderGroup/product/phone/entry/build-profile.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/Performance/renderGroup/product/phone/entry/oh-package.json5 b/code/Performance/renderGroup/product/phone/entry/oh-package.json5 index e289f8ab59..999f7eb3a5 100644 --- a/code/Performance/renderGroup/product/phone/entry/oh-package.json5 +++ b/code/Performance/renderGroup/product/phone/entry/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": { - "@ohos/rendergroup": "file:../../../feature/renderGroup" - } -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": { + "@ohos/rendergroup": "file:../../../feature/renderGroup" + } +} diff --git a/code/Performance/renderGroup/product/phone/entry/src/main/ets/entryability/EntryAbility.ts b/code/Performance/renderGroup/product/phone/entry/src/main/ets/entryability/EntryAbility.ts index 1f498190c3..078a52eb8b 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/Performance/renderGroup/product/phone/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - 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'); - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + 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/Performance/renderGroup/product/phone/entry/src/main/ets/model/DataType.ets b/code/Performance/renderGroup/product/phone/entry/src/main/ets/model/DataType.ets index e7985a4b36..ea76bfdcff 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/main/ets/model/DataType.ets +++ b/code/Performance/renderGroup/product/phone/entry/src/main/ets/model/DataType.ets @@ -1,19 +1,19 @@ -/* - * Copyright (c) 2023 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 interface PerformanceMsg { - name: string - uri: string -} +/* + * Copyright (c) 2023 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 interface PerformanceMsg { + name: string + uri: string +} diff --git a/code/Performance/renderGroup/product/phone/entry/src/main/ets/model/MockData.ets b/code/Performance/renderGroup/product/phone/entry/src/main/ets/model/MockData.ets index b015cb872a..a0773f96dc 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/main/ets/model/MockData.ets +++ b/code/Performance/renderGroup/product/phone/entry/src/main/ets/model/MockData.ets @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2023 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 { PerformanceMsg } from './DataType'; - -export let performanceTypeArray: Array = [ - { - name: 'RenderGroup', - uri: 'pages/renderGroup/RenderGroupHomePage' - } +/* + * Copyright (c) 2023 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 { PerformanceMsg } from './DataType'; + +export let performanceTypeArray: Array = [ + { + name: 'RenderGroup', + uri: 'pages/renderGroup/RenderGroupHomePage' + } ] \ No newline at end of file diff --git a/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/NonProfitScenePage.ets b/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/NonProfitScenePage.ets index 8972522294..5f21f2770d 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/NonProfitScenePage.ets +++ b/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/NonProfitScenePage.ets @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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 { NonProfitScene } from '@ohos/rendergroup'; - -@Entry -@Component -struct NonProfitScenePage { - build() { - Column() { - NonProfitScene() - } - } +/* + * Copyright (c) 2023 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 { NonProfitScene } from '@ohos/rendergroup'; + +@Entry +@Component +struct NonProfitScenePage { + build() { + Column() { + NonProfitScene() + } + } } \ No newline at end of file diff --git a/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/ProfitScenePage.ets b/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/ProfitScenePage.ets index 9f9f0850f1..4c48c5d2df 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/ProfitScenePage.ets +++ b/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/ProfitScenePage.ets @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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 { ProfitScene } from '@ohos/rendergroup'; - -@Entry -@Component -struct ProfitScenePage { - build() { - Column() { - ProfitScene() - } - } +/* + * Copyright (c) 2023 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 { ProfitScene } from '@ohos/rendergroup'; + +@Entry +@Component +struct ProfitScenePage { + build() { + Column() { + ProfitScene() + } + } } \ No newline at end of file diff --git a/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/RenderGroupHomePage.ets b/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/RenderGroupHomePage.ets index cc4e8883e5..6860c60a6f 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/RenderGroupHomePage.ets +++ b/code/Performance/renderGroup/product/phone/entry/src/main/ets/pages/renderGroup/RenderGroupHomePage.ets @@ -1,84 +1,84 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router' - -@Entry -@Component -struct Index { - build() { - Column() { - Row() { - Row(){ - Image($r("app.media.back")) - .id('returnBtn') - .height($r('app.integer.RenderGroup_scene_back_image_size')) - .width($r('app.integer.RenderGroup_scene_back_image_size')) - .onClick(() => { - router.back(); - }) - - Text($r('app.string.RenderGroupHomePage_title')) - .fontSize($r('app.integer.RenderGroupHomePage_title_font')) - .lineHeight($r('app.integer.RenderGroupHomePage_title_lineHeight')) - .fontColor(Color.Black) - .fontWeight(FontWeight.Bold) - .textAlign(TextAlign.Center) - .width($r('app.string.layout_100_percent')) - .height($r('app.integer.RenderGroupHomePage_title_height')) - } - .height($r('app.integer.RenderGroupHomePage_row_height')) - .backgroundColor(Color.White) - } - .margin({ - left: $r('app.integer.RenderGroup_scene_row_margin_left') - }) - - Button($r('app.string.RenderGroup_profit_scene_button_title'), { type: ButtonType.Normal, stateEffect: true }) - .id('ProfitScenePage') - .fontSize($r('app.integer.RenderGroup_scene_button_font')) - .borderRadius($r('app.integer.RenderGroup_scene_button_borderRadius')) - .backgroundColor($r('app.color.RenderGroup_scene_button_backgroundColor')) - .width($r('app.integer.RenderGroup_scene_button_width')) - .height($r('app.integer.RenderGroup_scene_button_height')) - .margin({ - top: $r('app.integer.RenderGroup_scene_button_margin_top') - }) - .onClick(() => { - router.pushUrl({ - url: 'pages/renderGroup/ProfitScenePage' - }) - }) - - Button($r('app.string.RenderGroup_nonProfit_scene_button_title'), { type: ButtonType.Normal, stateEffect: true }) - .id('NonProfitScenePage') - .fontSize($r('app.integer.RenderGroup_scene_button_font')) - .borderRadius($r('app.integer.RenderGroup_scene_button_borderRadius')) - .backgroundColor($r('app.color.RenderGroup_scene_button_backgroundColor')) - .width($r('app.integer.RenderGroup_scene_button_width')) - .height($r('app.integer.RenderGroup_scene_button_height')) - .margin({ - top: $r('app.integer.RenderGroup_scene_button_margin_top') - }) - .onClick(() => { - router.pushUrl({ - url: 'pages/renderGroup/NonProfitScenePage' - }) - }) - } - .height($r('app.integer.RenderGroup_scene_row_height')) - .width($r('app.string.layout_100_percent')) - } +/* + * Copyright (c) 2023 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 router from '@ohos.router' + +@Entry +@Component +struct Index { + build() { + Column() { + Row() { + Row(){ + Image($r("app.media.back")) + .id('returnBtn') + .height($r('app.integer.RenderGroup_scene_back_image_size')) + .width($r('app.integer.RenderGroup_scene_back_image_size')) + .onClick(() => { + router.back(); + }) + + Text($r('app.string.RenderGroupHomePage_title')) + .fontSize($r('app.integer.RenderGroupHomePage_title_font')) + .lineHeight($r('app.integer.RenderGroupHomePage_title_lineHeight')) + .fontColor(Color.Black) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Center) + .width($r('app.string.layout_100_percent')) + .height($r('app.integer.RenderGroupHomePage_title_height')) + } + .height($r('app.integer.RenderGroupHomePage_row_height')) + .backgroundColor(Color.White) + } + .margin({ + left: $r('app.integer.RenderGroup_scene_row_margin_left') + }) + + Button($r('app.string.RenderGroup_profit_scene_button_title'), { type: ButtonType.Normal, stateEffect: true }) + .id('ProfitScenePage') + .fontSize($r('app.integer.RenderGroup_scene_button_font')) + .borderRadius($r('app.integer.RenderGroup_scene_button_borderRadius')) + .backgroundColor($r('app.color.RenderGroup_scene_button_backgroundColor')) + .width($r('app.integer.RenderGroup_scene_button_width')) + .height($r('app.integer.RenderGroup_scene_button_height')) + .margin({ + top: $r('app.integer.RenderGroup_scene_button_margin_top') + }) + .onClick(() => { + router.pushUrl({ + url: 'pages/renderGroup/ProfitScenePage' + }) + }) + + Button($r('app.string.RenderGroup_nonProfit_scene_button_title'), { type: ButtonType.Normal, stateEffect: true }) + .id('NonProfitScenePage') + .fontSize($r('app.integer.RenderGroup_scene_button_font')) + .borderRadius($r('app.integer.RenderGroup_scene_button_borderRadius')) + .backgroundColor($r('app.color.RenderGroup_scene_button_backgroundColor')) + .width($r('app.integer.RenderGroup_scene_button_width')) + .height($r('app.integer.RenderGroup_scene_button_height')) + .margin({ + top: $r('app.integer.RenderGroup_scene_button_margin_top') + }) + .onClick(() => { + router.pushUrl({ + url: 'pages/renderGroup/NonProfitScenePage' + }) + }) + } + .height($r('app.integer.RenderGroup_scene_row_height')) + .width($r('app.string.layout_100_percent')) + } } \ No newline at end of file diff --git a/code/Performance/renderGroup/product/phone/entry/src/main/ets/utils/Logger.ets b/code/Performance/renderGroup/product/phone/entry/src/main/ets/utils/Logger.ets index 9897512029..87fdc629e4 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/main/ets/utils/Logger.ets +++ b/code/Performance/renderGroup/product/phone/entry/src/main/ets/utils/Logger.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - // 日志对应的领域标识 - private domain: number = 0xF811; - // tag日志标识 - private prefix: string = '[Samples_Performance]'; - // 格式字符串,用于日志的格式化输出 - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + // 日志对应的领域标识 + private domain: number = 0xF811; + // tag日志标识 + private prefix: string = '[Samples_Performance]'; + // 格式字符串,用于日志的格式化输出 + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Samples_Performance]'); \ No newline at end of file diff --git a/code/Performance/renderGroup/product/phone/entry/src/main/module.json5 b/code/Performance/renderGroup/product/phone/entry/src/main/module.json5 index c32260d08b..6f2734bc4f 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/main/module.json5 +++ b/code/Performance/renderGroup/product/phone/entry/src/main/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/Performance/renderGroup/product/phone/entry/src/main/resources/base/element/color.json b/code/Performance/renderGroup/product/phone/entry/src/main/resources/base/element/color.json index 4d12768ffb..e53ed61eef 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/main/resources/base/element/color.json +++ b/code/Performance/renderGroup/product/phone/entry/src/main/resources/base/element/color.json @@ -1,16 +1,16 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "performance_message_item_backgroundColor", - "value": "#0091FF" - }, - { - "name": "RenderGroup_scene_button_backgroundColor", - "value": "#317aff" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "performance_message_item_backgroundColor", + "value": "#0091FF" + }, + { + "name": "RenderGroup_scene_button_backgroundColor", + "value": "#317aff" + } + ] } \ No newline at end of file diff --git a/code/Performance/renderGroup/product/phone/entry/src/main/resources/base/element/integer.json b/code/Performance/renderGroup/product/phone/entry/src/main/resources/base/element/integer.json index d79963dad5..8d30f20c00 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/main/resources/base/element/integer.json +++ b/code/Performance/renderGroup/product/phone/entry/src/main/resources/base/element/integer.json @@ -1,56 +1,56 @@ -{ - "integer": [ - { - "name": "performance_message_font", - "value": 20 - }, - { - "name": "performance_message_margin", - "value": 20 - }, - { - "name": "performance_message_padding", - "value": 16 - }, - { - "name": "RenderGroupHomePage_title_font", - "value": 24 - }, - { - "name": "RenderGroupHomePage_title_lineHeight", - "value": 30 - }, - { - "name": "RenderGroupHomePage_title_height", - "value": 30 - }, - { - "name": "RenderGroupHomePage_row_height", - "value": 56 - }, - { - "name": "RenderGroup_scene_button_font", - "value": 18 - }, - { - "name": "RenderGroup_scene_button_borderRadius", - "value": 8 - }, - { - "name": "RenderGroup_scene_button_width", - "value": 250 - }, - { - "name": "RenderGroup_scene_button_height", - "value": 60 - }, - { - "name": "RenderGroup_scene_button_margin_top", - "value": 30 - }, - { - "name": "RenderGroup_scene_row_height", - "value": 200 - } - ] +{ + "integer": [ + { + "name": "performance_message_font", + "value": 20 + }, + { + "name": "performance_message_margin", + "value": 20 + }, + { + "name": "performance_message_padding", + "value": 16 + }, + { + "name": "RenderGroupHomePage_title_font", + "value": 24 + }, + { + "name": "RenderGroupHomePage_title_lineHeight", + "value": 30 + }, + { + "name": "RenderGroupHomePage_title_height", + "value": 30 + }, + { + "name": "RenderGroupHomePage_row_height", + "value": 56 + }, + { + "name": "RenderGroup_scene_button_font", + "value": 18 + }, + { + "name": "RenderGroup_scene_button_borderRadius", + "value": 8 + }, + { + "name": "RenderGroup_scene_button_width", + "value": 250 + }, + { + "name": "RenderGroup_scene_button_height", + "value": 60 + }, + { + "name": "RenderGroup_scene_button_margin_top", + "value": 30 + }, + { + "name": "RenderGroup_scene_row_height", + "value": 200 + } + ] } \ No newline at end of file diff --git a/code/Performance/renderGroup/product/phone/entry/src/ohosTest/ets/util/Logger.ets b/code/Performance/renderGroup/product/phone/entry/src/ohosTest/ets/util/Logger.ets index f84e782775..a173e47230 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/ohosTest/ets/util/Logger.ets +++ b/code/Performance/renderGroup/product/phone/entry/src/ohosTest/ets/util/Logger.ets @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License") - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class Logger { - private domain: number = 0xF811 - private prefix: string = '[Sample_Performance_Uitest]' - private format: string = '%{public}s, %{public}s' - - constructor(prefix: string) { - this.prefix = prefix - this.domain = 0xF811 - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args) - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args) - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args) - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args) - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class Logger { + private domain: number = 0xF811 + private prefix: string = '[Sample_Performance_Uitest]' + private format: string = '%{public}s, %{public}s' + + constructor(prefix: string) { + this.prefix = prefix + this.domain = 0xF811 + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args) + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args) + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args) + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args) + } +} + export default new Logger('[Samples_Performance]') \ No newline at end of file diff --git a/code/Performance/renderGroup/product/phone/entry/src/ohosTest/module.json5 b/code/Performance/renderGroup/product/phone/entry/src/ohosTest/module.json5 index 7e44e83cf9..e6a499c49e 100644 --- a/code/Performance/renderGroup/product/phone/entry/src/ohosTest/module.json5 +++ b/code/Performance/renderGroup/product/phone/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/Project/Test/uitest/entry/src/main/ets/pages/Web.ets b/code/Project/Test/uitest/entry/src/main/ets/pages/Web.ets index 6158df0f5c..ab2f4ec8ab 100644 --- a/code/Project/Test/uitest/entry/src/main/ets/pages/Web.ets +++ b/code/Project/Test/uitest/entry/src/main/ets/pages/Web.ets @@ -1,44 +1,44 @@ -/* -* Copyright (c) 2023-2024 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 web_webview from '@ohos.web.webview'; - -@Entry -@Component -struct Index { - controller: web_webview.WebviewController = new web_webview.WebviewController(); - // 将 WebviewController 存储到应用全局状态,TestAbility 中可获取并使用该对象 - @StorageLink('controller') storageLink: web_webview.WebviewController = this.controller; - - build() { - Row() { - Column() { - Web({ src: $rawfile('index.html'), controller: this.controller }) - .javaScriptAccess(true) - .onPageEnd(e => { - console.info(`webview onPageEnd`); - }) - .id('webComponent') - .width('80%') - .height('80%') - .align(Alignment.Center) - .borderColor(Color.Black) - .borderWidth(5) - } - .width('100%') - } - .height('100%') - } +/* +* Copyright (c) 2023-2024 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 web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct Index { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + // 将 WebviewController 存储到应用全局状态,TestAbility 中可获取并使用该对象 + @StorageLink('controller') storageLink: web_webview.WebviewController = this.controller; + + build() { + Row() { + Column() { + Web({ src: $rawfile('index.html'), controller: this.controller }) + .javaScriptAccess(true) + .onPageEnd(e => { + console.info(`webview onPageEnd`); + }) + .id('webComponent') + .width('80%') + .height('80%') + .align(Alignment.Center) + .borderColor(Color.Black) + .borderWidth(5) + } + .width('100%') + } + .height('100%') + } } \ No newline at end of file diff --git a/code/Project/Test/uitest/entry/src/main/ets/webability/WebAbility.ts b/code/Project/Test/uitest/entry/src/main/ets/webability/WebAbility.ts index 4dda5742a4..af1335dfbe 100644 --- a/code/Project/Test/uitest/entry/src/main/ets/webability/WebAbility.ts +++ b/code/Project/Test/uitest/entry/src/main/ets/webability/WebAbility.ts @@ -1,62 +1,62 @@ -/* -* Copyright (c) 2023-2024 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 from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; -import common from '@ohos.app.ability.common'; -import { BusinessError } from '@ohos.base'; - -export default class WebAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - AppStorage.SetOrCreate('EntryAbilityContext', this.context); - } - - 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/Web', (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) ?? ''); - }); - AppStorage.SetOrCreate('windowStage', windowStage); - } - - 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'); - } -} +/* +* Copyright (c) 2023-2024 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 from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import common from '@ohos.app.ability.common'; +import { BusinessError } from '@ohos.base'; + +export default class WebAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + AppStorage.SetOrCreate('EntryAbilityContext', this.context); + } + + 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/Web', (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) ?? ''); + }); + AppStorage.SetOrCreate('windowStage', windowStage); + } + + 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/Project/Test/uitest/entry/src/main/resources/rawfile/index.html b/code/Project/Test/uitest/entry/src/main/resources/rawfile/index.html index b0f9c14471..c5a69914ce 100644 --- a/code/Project/Test/uitest/entry/src/main/resources/rawfile/index.html +++ b/code/Project/Test/uitest/entry/src/main/resources/rawfile/index.html @@ -1,36 +1,36 @@ - - - -

H5页面

- - - - + + + +

H5页面

+ + + + \ No newline at end of file diff --git a/code/Solutions/InputMethod/KikaInput/build-profile.json5 b/code/Solutions/InputMethod/KikaInput/build-profile.json5 deleted file mode 100644 index ef1a3fa1da..0000000000 --- a/code/Solutions/InputMethod/KikaInput/build-profile.json5 +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "runtimeOS": "OpenHarmony" - } - ], - "signingConfigs": [] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/.gitignore b/code/Solutions/Social/GrapeSquare/.gitignore index 8514e821ba..fbabf77101 100644 --- a/code/Solutions/Social/GrapeSquare/.gitignore +++ b/code/Solutions/Social/GrapeSquare/.gitignore @@ -1,11 +1,11 @@ -/node_modules -/oh_modules -/local.properties -/.idea -**/build -/.hvigor -.cxx -/.clangd -/.clang-format -/.clang-tidy +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy **/.test \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/AppScope/app.json5 b/code/Solutions/Social/GrapeSquare/AppScope/app.json5 index 30a561cf7e..f93374f465 100644 --- a/code/Solutions/Social/GrapeSquare/AppScope/app.json5 +++ b/code/Solutions/Social/GrapeSquare/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.grapesquare", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.grapesquare", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/Solutions/Social/GrapeSquare/AppScope/resources/base/element/string.json b/code/Solutions/Social/GrapeSquare/AppScope/resources/base/element/string.json index cee7e9d78d..80a5232ed9 100644 --- a/code/Solutions/Social/GrapeSquare/AppScope/resources/base/element/string.json +++ b/code/Solutions/Social/GrapeSquare/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "葡萄广场" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "葡萄广场" + } + ] +} diff --git a/code/Solutions/Social/GrapeSquare/build-profile.json5 b/code/Solutions/Social/GrapeSquare/build-profile.json5 index bb0a027424..d02ed820a4 100644 --- a/code/Solutions/Social/GrapeSquare/build-profile.json5 +++ b/code/Solutions/Social/GrapeSquare/build-profile.json5 @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./product/phone/entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "authorizedControl", - "srcPath": "./feature/authorizedControl" - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "runtimeOS": "OpenHarmony" + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./product/phone/entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "authorizedControl", + "srcPath": "./feature/authorizedControl" + } + ] } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/hvigor/hvigor-config.json5 b/code/Solutions/Social/GrapeSquare/hvigor/hvigor-config.json5 index 213d992653..a7edd62de4 100644 --- a/code/Solutions/Social/GrapeSquare/hvigor/hvigor-config.json5 +++ b/code/Solutions/Social/GrapeSquare/hvigor/hvigor-config.json5 @@ -1,18 +1,18 @@ -{ - "hvigorVersion": "3.0.9", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.9" - }, - "execution": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } +{ + "hvigorVersion": "3.0.9", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.9" + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/hvigorfile.ts b/code/Solutions/Social/GrapeSquare/hvigorfile.ts index 160030fb5b..2a4a8343e9 100644 --- a/code/Solutions/Social/GrapeSquare/hvigorfile.ts +++ b/code/Solutions/Social/GrapeSquare/hvigorfile.ts @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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. */ -} +/* + * Copyright (c) 2023 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/Solutions/Social/GrapeSquare/hvigorw.bat b/code/Solutions/Social/GrapeSquare/hvigorw.bat index b116622299..93a1e34ae8 100644 --- a/code/Solutions/Social/GrapeSquare/hvigorw.bat +++ b/code/Solutions/Social/GrapeSquare/hvigorw.bat @@ -1,79 +1,79 @@ -:: Copyright (c) 2023 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. - -@echo off - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Hvigor startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js -set NODE_EXE=node.exe - -goto start - -:start -@rem Find node.exe -if defined NODE_HOME goto findNodeFromNodeHome - -%NODE_EXE% --version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. -echo. -echo Please set the NODE_HOME variable in your environment to match the -echo location of your NodeJs installation. - -goto fail - -:findNodeFromNodeHome -set NODE_HOME=%NODE_HOME:"=% -set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% - -if exist "%NODE_EXE_PATH%" goto execute -echo. -echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. -echo. -echo Please set the NODE_HOME variable in your environment to match the -echo location of your NodeJs installation. - -goto fail - -:execute -@rem Execute hvigor -"%NODE_EXE%" "%WRAPPER_MODULE_PATH%" %* - -if "%ERRORLEVEL%" == "0" goto hvigorwEnd - -:fail -exit /b 1 - -:hvigorwEnd -if "%OS%" == "Windows_NT" endlocal - -:end +:: Copyright (c) 2023 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. + +@echo off + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Hvigor startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js +set NODE_EXE=node.exe + +goto start + +:start +@rem Find node.exe +if defined NODE_HOME goto findNodeFromNodeHome + +%NODE_EXE% --version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:findNodeFromNodeHome +set NODE_HOME=%NODE_HOME:"=% +set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% + +if exist "%NODE_EXE_PATH%" goto execute +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:execute +@rem Execute hvigor +"%NODE_EXE%" "%WRAPPER_MODULE_PATH%" %* + +if "%ERRORLEVEL%" == "0" goto hvigorwEnd + +:fail +exit /b 1 + +:hvigorwEnd +if "%OS%" == "Windows_NT" endlocal + +:end diff --git a/code/Solutions/Social/GrapeSquare/oh-package.json5 b/code/Solutions/Social/GrapeSquare/oh-package.json5 index 25ff7452b8..9a3d1890b0 100644 --- a/code/Solutions/Social/GrapeSquare/oh-package.json5 +++ b/code/Solutions/Social/GrapeSquare/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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. - */ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "authorizedcontrol", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "authorizedcontrol", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/.gitignore b/code/Solutions/Social/GrapeSquare/product/phone/entry/.gitignore index 32abf8fd5e..e2713a2779 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/.gitignore +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/.gitignore @@ -1,6 +1,6 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx +/node_modules +/oh_modules +/.preview +/build +/.cxx /.test \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/build-profile.json5 b/code/Solutions/Social/GrapeSquare/product/phone/entry/build-profile.json5 index d384599700..3360e1a754 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/build-profile.json5 +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/build-profile.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/hvigorfile.ts b/code/Solutions/Social/GrapeSquare/product/phone/entry/hvigorfile.ts index eed1897d60..b25e77c7c8 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/hvigorfile.ts +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/hvigorfile.ts @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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. */ -} +/* + * Copyright (c) 2023 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/Solutions/Social/GrapeSquare/product/phone/entry/oh-package.json5 b/code/Solutions/Social/GrapeSquare/product/phone/entry/oh-package.json5 index 49efa14bac..9b72814cb2 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/oh-package.json5 +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/oh-package.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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. - */ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": { - "@ohos/authorizedcontrol": "file:../../../feature/authorizedControl" - } -} +/* + * Copyright (c) 2023 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. + */ +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": { + "@ohos/authorizedcontrol": "file:../../../feature/authorizedControl" + } +} diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/entryability/EntryAbility.ts b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/entryability/EntryAbility.ts index 3206000243..4b036407fc 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,108 +1,108 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; -import display from '@ohos.display'; -import Logger from '../utils/Logger'; - -const TAG = ' EntryAbility'; -const DPI: number = 160; -const SMALL_SCREEN_WIDTH: number = 480; -const MIDDLE_SCREEN_WIDTH: number = 520; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - Logger.info('Ability onCreate'); - } - - onDestroy() { - Logger.info('Ability onDestroy'); - } - - updateBreakpoint(windowWidth: number): void { - let windowWidthVp: number = windowWidth / (display.getDefaultDisplaySync().densityDPI / DPI); - let currentBreakpoint: string; - Logger.info(`breakpoint windowWidthVp:${windowWidthVp}`); - // 520以及840分别为小屏和中屏的最大宽度 - if (windowWidthVp < SMALL_SCREEN_WIDTH) { - currentBreakpoint = 'sm'; - } else if (windowWidthVp < MIDDLE_SCREEN_WIDTH) { - currentBreakpoint = 'md'; - } else { - currentBreakpoint = 'lg'; - } - Logger.info(TAG, `breakpoint: ${currentBreakpoint}`); - AppStorage.setOrCreate('currentBreakpoint', currentBreakpoint); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - Logger.info('Ability onWindowStageCreate'); - - windowStage.loadContent('pages/AdvertisingPage', (err, data) => { - if (err.code) { - Logger.error(`Failed to load the content. Cause: ${JSON.stringify(err)}`); - return; - } - Logger.info(`Succeeded in loading the content. Data:JSON.stringify(data)`); - }); - windowStage.getMainWindow((err, windowClass) => { - if (err.code) { - Logger.error(`Failed to obtain the main window.Cause: ${JSON.stringify(err)}`); - return; - } - let windowWidth: number = windowClass.getWindowProperties().windowRect.width; - this.updateBreakpoint(windowWidth); - // 设置监听键盘变化,用来设置inputView避让输入法 - try { - windowClass.on('windowSizeChange', (currentWindowSize) => { - let currentWindowWidth: number = currentWindowSize.width; - this.updateBreakpoint(currentWindowWidth); - - if (windowClass.getWindowProperties().isFullScreen) { - Logger.info(TAG, 'isFullScreen'); - } - if (windowClass.getWindowProperties().isLayoutFullScreen) { - Logger.info(TAG, 'isLayoutFullScreen'); - } - }); - windowClass.on('keyboardHeightChange', (data) => { - Logger.info(`keyboardHeightChange.Data: ${JSON.stringify(data)}`); - AppStorage.setOrCreate('keyboardHeight', data); - }) - } catch (exception) { - Logger.error(`Failed to enable the listener for keyboard height changes.Cause: ${JSON.stringify(exception)}`); - } - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - Logger.info('Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - Logger.info('Ability onForeground'); - } - - onBackground() { - // Ability has back to background - Logger.info('Ability onBackground'); - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import display from '@ohos.display'; +import Logger from '../utils/Logger'; + +const TAG = ' EntryAbility'; +const DPI: number = 160; +const SMALL_SCREEN_WIDTH: number = 480; +const MIDDLE_SCREEN_WIDTH: number = 520; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + Logger.info('Ability onCreate'); + } + + onDestroy() { + Logger.info('Ability onDestroy'); + } + + updateBreakpoint(windowWidth: number): void { + let windowWidthVp: number = windowWidth / (display.getDefaultDisplaySync().densityDPI / DPI); + let currentBreakpoint: string; + Logger.info(`breakpoint windowWidthVp:${windowWidthVp}`); + // 520以及840分别为小屏和中屏的最大宽度 + if (windowWidthVp < SMALL_SCREEN_WIDTH) { + currentBreakpoint = 'sm'; + } else if (windowWidthVp < MIDDLE_SCREEN_WIDTH) { + currentBreakpoint = 'md'; + } else { + currentBreakpoint = 'lg'; + } + Logger.info(TAG, `breakpoint: ${currentBreakpoint}`); + AppStorage.setOrCreate('currentBreakpoint', currentBreakpoint); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + Logger.info('Ability onWindowStageCreate'); + + windowStage.loadContent('pages/AdvertisingPage', (err, data) => { + if (err.code) { + Logger.error(`Failed to load the content. Cause: ${JSON.stringify(err)}`); + return; + } + Logger.info(`Succeeded in loading the content. Data:JSON.stringify(data)`); + }); + windowStage.getMainWindow((err, windowClass) => { + if (err.code) { + Logger.error(`Failed to obtain the main window.Cause: ${JSON.stringify(err)}`); + return; + } + let windowWidth: number = windowClass.getWindowProperties().windowRect.width; + this.updateBreakpoint(windowWidth); + // 设置监听键盘变化,用来设置inputView避让输入法 + try { + windowClass.on('windowSizeChange', (currentWindowSize) => { + let currentWindowWidth: number = currentWindowSize.width; + this.updateBreakpoint(currentWindowWidth); + + if (windowClass.getWindowProperties().isFullScreen) { + Logger.info(TAG, 'isFullScreen'); + } + if (windowClass.getWindowProperties().isLayoutFullScreen) { + Logger.info(TAG, 'isLayoutFullScreen'); + } + }); + windowClass.on('keyboardHeightChange', (data) => { + Logger.info(`keyboardHeightChange.Data: ${JSON.stringify(data)}`); + AppStorage.setOrCreate('keyboardHeight', data); + }) + } catch (exception) { + Logger.error(`Failed to enable the listener for keyboard height changes.Cause: ${JSON.stringify(exception)}`); + } + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + Logger.info('Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + Logger.info('Ability onForeground'); + } + + onBackground() { + // Ability has back to background + Logger.info('Ability onBackground'); + } +} diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/AdvertisingPage.ets b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/AdvertisingPage.ets index ecb6093a20..f76a15d239 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/AdvertisingPage.ets +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/AdvertisingPage.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router'; -import common from '@ohos.app.ability.common'; -import { getResourceString } from '../utils/ResourceUtils'; -import Constants from '../utils/Constants'; - -let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - -@Entry -@Component -struct AdvertisingPage { - // 初始化广告时间 - @State advertisingTime: number = 3; - // 定时器timer - @State timer: number = -1; - - aboutToAppear() { - this.timer = setInterval(() => { - this.advertisingTime--; - // 广告时间为0s时跳转到首页 - if (this.advertisingTime === 0) { - router.replaceUrl({ url: 'pages/HomePage' }); - clearInterval(this.timer); - } - }, Constants.SETINTERVAL_TIME) - } - - build() { - Stack() { - Image($r('app.media.advertisment')) - .width('100%') - .height('100%') - .objectFit(ImageFit.Contain) - Row() { - Text(`${getResourceString(context, $r('app.string.skip'))} ${this.advertisingTime}s`) - .id('skip') - .padding({ - left: $r('app.integer.layout_size_30'), - right: $r('app.integer.layout_size_30'), - top: $r('app.integer.layout_size_6'), - bottom: $r('app.integer.layout_size_6') - }) - .backgroundColor('rgba(0,0,0,0.20)') - .fontColor(Color.White) - .borderRadius($r('app.integer.layout_size_15')) - .onClick(() => { - clearInterval(this.timer); - router.replaceUrl({ url: 'pages/HomePage' }); - }) - }.width($r('app.string.layout_100')) - .justifyContent(FlexAlign.End) - .padding($r('app.integer.layout_size_10')) - } - .alignContent(Alignment.TopEnd) - .width($r('app.string.layout_100')) - .height($r('app.string.layout_100')) - } +/* + * Copyright (c) 2023 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 router from '@ohos.router'; +import common from '@ohos.app.ability.common'; +import { getResourceString } from '../utils/ResourceUtils'; +import Constants from '../utils/Constants'; + +let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Entry +@Component +struct AdvertisingPage { + // 初始化广告时间 + @State advertisingTime: number = 3; + // 定时器timer + @State timer: number = -1; + + aboutToAppear() { + this.timer = setInterval(() => { + this.advertisingTime--; + // 广告时间为0s时跳转到首页 + if (this.advertisingTime === 0) { + router.replaceUrl({ url: 'pages/HomePage' }); + clearInterval(this.timer); + } + }, Constants.SETINTERVAL_TIME) + } + + build() { + Stack() { + Image($r('app.media.advertisment')) + .width('100%') + .height('100%') + .objectFit(ImageFit.Contain) + Row() { + Text(`${getResourceString(context, $r('app.string.skip'))} ${this.advertisingTime}s`) + .id('skip') + .padding({ + left: $r('app.integer.layout_size_30'), + right: $r('app.integer.layout_size_30'), + top: $r('app.integer.layout_size_6'), + bottom: $r('app.integer.layout_size_6') + }) + .backgroundColor('rgba(0,0,0,0.20)') + .fontColor(Color.White) + .borderRadius($r('app.integer.layout_size_15')) + .onClick(() => { + clearInterval(this.timer); + router.replaceUrl({ url: 'pages/HomePage' }); + }) + }.width($r('app.string.layout_100')) + .justifyContent(FlexAlign.End) + .padding($r('app.integer.layout_size_10')) + } + .alignContent(Alignment.TopEnd) + .width($r('app.string.layout_100')) + .height($r('app.string.layout_100')) + } } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/CommentDetailPage.ets b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/CommentDetailPage.ets index 181c977fd9..f145b258c5 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/CommentDetailPage.ets +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/CommentDetailPage.ets @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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 { CommentDetailView } from '@ohos/authorizedcontrol'; - -@Entry -@Component -export struct CommentDetailPage { - build() { - Column() { - CommentDetailView() - } - } +/* + * Copyright (c) 2023 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 { CommentDetailView } from '@ohos/authorizedcontrol'; + +@Entry +@Component +export struct CommentDetailPage { + build() { + Column() { + CommentDetailView() + } + } } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/HomePage.ets b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/HomePage.ets index 3427fc074c..9cd515bd20 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/HomePage.ets +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/HomePage.ets @@ -1,101 +1,101 @@ -/* - * Copyright (c) 2023 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 { MainView, SquareView, MineView } from '@ohos/authorizedcontrol'; - -AppStorage.setOrCreate('location', '北京市') -const TAB_INDEX_0: number = 0; -const TAB_INDEX_1: number = 1; -const TAB_INDEX_2: number = 2; -// divider组件的strokWidth为1 -const DIVIDER_LINE_STROKWIDTH: number = 1; -const TABBAR_SEPARATE_LINE = 0.05; - -@Entry -@Component -struct HomePage { - // 默认显示第一个tab - @State currentTabIndex: number = 0; - @State message: Resource = $r('app.string.home'); - private controller: TabsController = new TabsController(); - - // 设置tabBar样式的位置、未选中图片、选中图片及文字显示的参数 - @Builder - TabBuilder(index: number, imageNormal: Resource, imageSelected: Resource, text: Resource) { - Column() { - Divider() - .vertical(false) - .strokeWidth(DIVIDER_LINE_STROKWIDTH) - .color($r('app.color.tab_bar_separator_line_color')) - .opacity(TABBAR_SEPARATE_LINE) - Image(this.currentTabIndex === index ? imageSelected : imageNormal) - .syncLoad(true) - .width($r('app.integer.tabbar_image_width')) - .height($r('app.integer.tabbar_image_height')) - .margin($r('app.integer.tabbar_image_margin')) - .objectFit(ImageFit.Contain) - Text(text) - .fontSize($r('app.integer.tabbar_item_font_size')) - } - .backgroundColor($r('app.color.tabbar_background')) - .height($r('app.string.layout_100')) - .width($r('app.string.layout_100')) - } - - build() { - Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentTabIndex }) { - TabContent() { - // 首页 - MainView() - } - .tabBar(this.TabBuilder(TAB_INDEX_0, - $r('app.media.ic_public_home'), - $r('app.media.ic_public_home_filled'), - $r('app.string.home'))); - - TabContent() { - // 广场页 - SquareView() - } - .tabBar(this.TabBuilder(TAB_INDEX_1, - $r('app.media.ic_gallery_discover'), - $r('app.media.ic_gallery_discover_filled'), - $r('app.string.square'))); - - TabContent() { - // 我的 - MineView() - } - .tabBar(this.TabBuilder(TAB_INDEX_2, - $r('app.media.ic_public_contacts'), - $r('app.media.ic_public_contacts_filled'), - $r('app.string.mine'))); - } - .onChange((index: number) => { - this.currentTabIndex = index; - if (this.currentTabIndex === TAB_INDEX_0) { - this.message = $r('app.string.home'); - } else if (this.currentTabIndex === TAB_INDEX_1) { - this.message = $r('app.string.square'); - } else if (this.currentTabIndex === TAB_INDEX_2) { - this.message = $r('app.string.mine'); - } - }) - - .barWidth($r('app.string.layout_100')) - .barHeight($r('app.integer.tabbar_height')) - .backgroundColor(Color.White) - } +/* + * Copyright (c) 2023 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 { MainView, SquareView, MineView } from '@ohos/authorizedcontrol'; + +AppStorage.setOrCreate('location', '北京市') +const TAB_INDEX_0: number = 0; +const TAB_INDEX_1: number = 1; +const TAB_INDEX_2: number = 2; +// divider组件的strokWidth为1 +const DIVIDER_LINE_STROKWIDTH: number = 1; +const TABBAR_SEPARATE_LINE = 0.05; + +@Entry +@Component +struct HomePage { + // 默认显示第一个tab + @State currentTabIndex: number = 0; + @State message: Resource = $r('app.string.home'); + private controller: TabsController = new TabsController(); + + // 设置tabBar样式的位置、未选中图片、选中图片及文字显示的参数 + @Builder + TabBuilder(index: number, imageNormal: Resource, imageSelected: Resource, text: Resource) { + Column() { + Divider() + .vertical(false) + .strokeWidth(DIVIDER_LINE_STROKWIDTH) + .color($r('app.color.tab_bar_separator_line_color')) + .opacity(TABBAR_SEPARATE_LINE) + Image(this.currentTabIndex === index ? imageSelected : imageNormal) + .syncLoad(true) + .width($r('app.integer.tabbar_image_width')) + .height($r('app.integer.tabbar_image_height')) + .margin($r('app.integer.tabbar_image_margin')) + .objectFit(ImageFit.Contain) + Text(text) + .fontSize($r('app.integer.tabbar_item_font_size')) + } + .backgroundColor($r('app.color.tabbar_background')) + .height($r('app.string.layout_100')) + .width($r('app.string.layout_100')) + } + + build() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentTabIndex }) { + TabContent() { + // 首页 + MainView() + } + .tabBar(this.TabBuilder(TAB_INDEX_0, + $r('app.media.ic_public_home'), + $r('app.media.ic_public_home_filled'), + $r('app.string.home'))); + + TabContent() { + // 广场页 + SquareView() + } + .tabBar(this.TabBuilder(TAB_INDEX_1, + $r('app.media.ic_gallery_discover'), + $r('app.media.ic_gallery_discover_filled'), + $r('app.string.square'))); + + TabContent() { + // 我的 + MineView() + } + .tabBar(this.TabBuilder(TAB_INDEX_2, + $r('app.media.ic_public_contacts'), + $r('app.media.ic_public_contacts_filled'), + $r('app.string.mine'))); + } + .onChange((index: number) => { + this.currentTabIndex = index; + if (this.currentTabIndex === TAB_INDEX_0) { + this.message = $r('app.string.home'); + } else if (this.currentTabIndex === TAB_INDEX_1) { + this.message = $r('app.string.square'); + } else if (this.currentTabIndex === TAB_INDEX_2) { + this.message = $r('app.string.mine'); + } + }) + + .barWidth($r('app.string.layout_100')) + .barHeight($r('app.integer.tabbar_height')) + .backgroundColor(Color.White) + } } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/SameCityListPage.ets b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/SameCityListPage.ets index 4d6dc5a8ed..a6c4ca7917 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/SameCityListPage.ets +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/pages/SameCityListPage.ets @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2023 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 { SameCityListView } from '@ohos/authorizedcontrol'; -import url from '@ohos.url'; -@Entry -@Component -export struct SameCityListPage { - private controller:TabsController=new TabsController(); - build() { - Column(){ - SameCityListView() - } - - } +/* + * Copyright (c) 2023 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 { SameCityListView } from '@ohos/authorizedcontrol'; +import url from '@ohos.url'; +@Entry +@Component +export struct SameCityListPage { + private controller:TabsController=new TabsController(); + build() { + Column(){ + SameCityListView() + } + + } } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/Constants.ets b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/Constants.ets index eacaa807e7..3eb7d8c662 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/Constants.ets +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/Constants.ets @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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 default class Constants { - // Tab下标为0 - public static readonly TAB_INDEX_0: number = 0; - // Tab下标为1 - public static readonly TAB_INDEX_1: number = 1; - // Tab下标为2 - public static readonly TAB_INDEX_2: number = 2; - // 计时器,每隔1s执行一次 - public static readonly SETINTERVAL_TIME: number = 1000; - // borderWidth - public static readonly BORDERWIDTH: number = 1; -} +/* + * Copyright (c) 2023 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 default class Constants { + // Tab下标为0 + public static readonly TAB_INDEX_0: number = 0; + // Tab下标为1 + public static readonly TAB_INDEX_1: number = 1; + // Tab下标为2 + public static readonly TAB_INDEX_2: number = 2; + // 计时器,每隔1s执行一次 + public static readonly SETINTERVAL_TIME: number = 1000; + // borderWidth + public static readonly BORDERWIDTH: number = 1; +} diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/Logger.ts b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/Logger.ts index 5e16f6a640..94213adc9f 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/Logger.ts +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/Logger.ts @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - // 日志对应的领域标识 - private domain: number = 0xF811; - // tag日志标识 - private prefix: string = '[Samples_AuthorizedControl]'; - // 格式字符串,用于日志的格式化输出 - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + // 日志对应的领域标识 + private domain: number = 0xF811; + // tag日志标识 + private prefix: string = '[Samples_AuthorizedControl]'; + // 格式字符串,用于日志的格式化输出 + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Samples_AuthorizedControl]'); \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/ResourceUtils.ets b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/ResourceUtils.ets index 3085317211..95ea48f5c3 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/ResourceUtils.ets +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/ets/utils/ResourceUtils.ets @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; - -/** - * getResourceString将Resource类型的数据转换成string类型的数据 - * @param context - * @param ResourceData - */ -export function getResourceString(context: common.UIAbilityContext, resourceData: Resource): string { - let stringData: string = context.resourceManager.getStringSync(resourceData.id); - return stringData; +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; + +/** + * getResourceString将Resource类型的数据转换成string类型的数据 + * @param context + * @param ResourceData + */ +export function getResourceString(context: common.UIAbilityContext, resourceData: Resource): string { + let stringData: string = context.resourceManager.getStringSync(resourceData.id); + return stringData; } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/module.json5 b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/module.json5 index 44457b3f9d..f249b1e8e9 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/module.json5 +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:grape_app_icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:grape_app_icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/color.json b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/color.json index db5766943d..0652575934 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/color.json +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/color.json @@ -1,16 +1,16 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "tabbar_background", - "value": "#F1F3F5" - }, - { - "name": "tab_bar_separator_line_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "tabbar_background", + "value": "#F1F3F5" + }, + { + "name": "tab_bar_separator_line_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/integer.json b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/integer.json index 6fa7a5122a..d7f7ab06b4 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/integer.json +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/integer.json @@ -1,40 +1,40 @@ -{ - "integer": [ - { - "name": "tabbar_image_width", - "value": 28 - }, - { - "name": "tabbar_image_height", - "value": 28 - }, - { - "name": "tabbar_image_margin", - "value": 6 - }, - { - "name": "tabbar_height", - "value": 56 - }, - { - "name": "tabbar_item_font_size", - "value": 12 - }, - { - "name": "layout_size_30", - "value": 30 - }, - { - "name": "layout_size_10", - "value": 10 - }, - { - "name": "layout_size_15", - "value": 15 - }, - { - "name": "layout_size_6", - "value": 6 - } - ] +{ + "integer": [ + { + "name": "tabbar_image_width", + "value": 28 + }, + { + "name": "tabbar_image_height", + "value": 28 + }, + { + "name": "tabbar_image_margin", + "value": 6 + }, + { + "name": "tabbar_height", + "value": 56 + }, + { + "name": "tabbar_item_font_size", + "value": 12 + }, + { + "name": "layout_size_30", + "value": 30 + }, + { + "name": "layout_size_10", + "value": 10 + }, + { + "name": "layout_size_15", + "value": 15 + }, + { + "name": "layout_size_6", + "value": 6 + } + ] } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/string.json b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/string.json index 396f21e177..9f170f79ed 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/string.json +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/element/string.json @@ -1,36 +1,36 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "label" - }, - { - "name": "home", - "value": "home" - }, - { - "name": "square", - "value": "square" - }, - { - "name": "mine", - "value": "mine" - }, - { - "name": "layout_100", - "value": "100%" - }, - { - "name": "skip", - "value": "skip" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "home", + "value": "home" + }, + { + "name": "square", + "value": "square" + }, + { + "name": "mine", + "value": "mine" + }, + { + "name": "layout_100", + "value": "100%" + }, + { + "name": "skip", + "value": "skip" + } + ] } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_gallery_discover.svg b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_gallery_discover.svg index 34f07f5b62..7fcf8d8b68 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_gallery_discover.svg +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_gallery_discover.svg @@ -1,16 +1,16 @@ - - - ic_gallery_discover - - - - - - - - - - - - + + + ic_gallery_discover + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_gallery_discover_filled.svg b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_gallery_discover_filled.svg index 96c605da57..7c2c4505c9 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_gallery_discover_filled.svg +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_gallery_discover_filled.svg @@ -1,19 +1,19 @@ - - - ic_gallery_discover_filled - - - - - - - - - - - - - - - + + + ic_gallery_discover_filled + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_contacts.svg b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_contacts.svg index f2bc46df08..d186d58a4e 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_contacts.svg +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_contacts.svg @@ -1,26 +1,26 @@ - - - ic_public_contacts - - - - - - - - - - - - - - - - - - - - - - + + + ic_public_contacts + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_contacts_filled.svg b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_contacts_filled.svg index eb188f2d31..20c9839547 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_contacts_filled.svg +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_contacts_filled.svg @@ -1,18 +1,18 @@ - - - Public/ic_public_contacts_filled - - - - - - - - - - - - - - + + + Public/ic_public_contacts_filled + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_home.svg b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_home.svg index 23de6d3033..f17f26aa77 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_home.svg +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_home.svg @@ -1,16 +1,16 @@ - - - ic_public_home - - - - - - - - - - - - + + + ic_public_home + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_home_filled.svg b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_home_filled.svg index a68babffe2..88e5832a27 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_home_filled.svg +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/media/ic_public_home_filled.svg @@ -1,16 +1,16 @@ - - - ic_public_home_filled - - - - - - - - - - - - + + + ic_public_home_filled + + + + + + + + + + + + \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/profile/main_pages.json b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/profile/main_pages.json index 8df505dffd..aa8b34d03d 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/profile/main_pages.json +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/base/profile/main_pages.json @@ -1,8 +1,8 @@ -{ - "src": [ - "pages/HomePage", - "pages/AdvertisingPage", - "pages/CommentDetailPage", - "pages/SameCityListPage" - ] -} +{ + "src": [ + "pages/HomePage", + "pages/AdvertisingPage", + "pages/CommentDetailPage", + "pages/SameCityListPage" + ] +} diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/en_US/element/string.json b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/en_US/element/string.json index 396f21e177..9f170f79ed 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/en_US/element/string.json +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/en_US/element/string.json @@ -1,36 +1,36 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "label" - }, - { - "name": "home", - "value": "home" - }, - { - "name": "square", - "value": "square" - }, - { - "name": "mine", - "value": "mine" - }, - { - "name": "layout_100", - "value": "100%" - }, - { - "name": "skip", - "value": "skip" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "home", + "value": "home" + }, + { + "name": "square", + "value": "square" + }, + { + "name": "mine", + "value": "mine" + }, + { + "name": "layout_100", + "value": "100%" + }, + { + "name": "skip", + "value": "skip" + } + ] } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/zh_CN/element/string.json b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/zh_CN/element/string.json index 9a856ef9f9..5049daadee 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/zh_CN/element/string.json +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/main/resources/zh_CN/element/string.json @@ -1,36 +1,36 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "模块描述" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "葡萄广场" - }, - { - "name": "home", - "value": "主页" - }, - { - "name": "square", - "value": "发现" - }, - { - "name": "mine", - "value": "我的" - }, - { - "name": "layout_100", - "value": "100%" - }, - { - "name": "skip", - "value": "跳过" - } - ] +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "葡萄广场" + }, + { + "name": "home", + "value": "主页" + }, + { + "name": "square", + "value": "发现" + }, + { + "name": "mine", + "value": "我的" + }, + { + "name": "layout_100", + "value": "100%" + }, + { + "name": "skip", + "value": "跳过" + } + ] } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/Ability.test.ets b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/Ability.test.ets index 2656267da6..79764c5bb4 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,163 +1,163 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -import Logger from './Logger' -import { Driver, ON } from '@ohos.UiTest' -import Want from '@ohos.app.ability.Want'; -import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; - -const BUNDLE = 'Weibo'; -const TAG = '[Sample_Weibo_Test]'; -const delegator = abilityDelegatorRegistry.getAbilityDelegator(); -const DELAY_TIME = 1000; - -async function getResourceString(resource: T): Promise { - let manage = delegator.getAppContext().resourceManager - let text = await manage.getStringValue(resource) - return text -} - -export default function abilityTest() { - let driver = Driver.create(); - describe('ActsAbilityTest', () => { - beforeAll(async ()=>{ - let want: Want = { - bundleName : 'com.samples.grapesquare', - abilityName : "EntryAbility" - } - await delegator.startAbility(want); - }) - - it("pass_advertisment", 0,async ()=> { - await driver.delayMs(DELAY_TIME); - Logger.info(TAG,BUNDLE + 'pass_advertisment begin'); - await driver.assertComponentExist(ON.id('skip')); - let passButton = await driver.findComponent(ON.id('skip')); - await passButton.click(); - Logger.info(TAG,BUNDLE + 'pass_advertisment end'); - }) - - //保存图片到媒体库 - it("Save_001", 0, async (done: Function) => { - Logger.info(TAG, BUNDLE + 'Save_001 begin'); - //点击进入微博展示页 - await driver.assertComponentExist(ON.id('textDetail')) - let viewList = await driver.findComponent(ON.id('textDetail')) - await driver.delayMs(500); - await viewList.click() - Logger.info(TAG, BUNDLE + 'Save_001 displayDetails') - //长按图片保存 - await driver.delayMs(DELAY_TIME) - await driver.assertComponentExist(ON.type('Image').isAfter(ON.id('textDetail'))) - let imageButton = await driver.findComponent(ON.type('Image').isAfter(ON.id('textDetail'))) - await driver.delayMs(500); - await imageButton.longClick() - //点击保存按钮 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.save')))); - let saveButton = await driver.findComponent(ON.text(await getResourceString($r('app.string.save')))); - await driver.delayMs(500); - await saveButton.click() - Logger.info(TAG, BUNDLE + 'Save_001 imageSaveSuccess') - await driver.delayMs(DELAY_TIME) - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.known')))); - let know = await driver.findComponent(ON.text(await getResourceString($r('app.string.known')))); - await know.click(); - //返回 - let backBtn = await driver.findComponent(ON.id('backBtn')); - await backBtn.click(); - Logger.info( TAG, BUNDLE + 'Save_001 end'); - await driver.delayMs(DELAY_TIME) - done() - }) - - - //获取剪贴板内容 - it("GetPasteContent_001", 0, async (done: Function) => { - await driver.delayMs(500); - Logger.info(TAG, BUNDLE + 'GetPasteContent_001 begin') - //点击进入微博展示页 - await driver.assertComponentExist(ON.id('textDetail')) - let viewList = await driver.findComponent(ON.id('textDetail')) - await viewList.click() - Logger.info(TAG, BUNDLE + 'GetPasteContent_001 displayDetails') - //点击评论按钮 - let paste = await driver.findComponent(ON.id('commentButton').text(await getResourceString($r('app.string.comment')))); - await driver.delayMs(500); - await paste.click(); - Logger.info(TAG, BUNDLE + 'SendMessageFunction_001 addComment') - //点击输入框,调起输入法 - let textInput = await driver.findComponent(ON.id('comment_add')) - await textInput.click() - Logger.info(TAG, BUNDLE + 'SendMessageFunction_001 inputText') - //在输入框输入example - await textInput.inputText('example') - let inputValue = await textInput.getText() - Logger.info(TAG, BUNDLE + 'InputMessageFunction_001 inputValue=' + inputValue) - //长按输入框调起复制 - await textInput.click() - await textInput.longClick() - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.copy')))); - let copyButton = await driver.findComponent(ON.text(await getResourceString($r('app.string.copy')))); - await copyButton.click() - Logger.info(TAG, BUNDLE + 'SendMessageFunction_001 copySuccess') - //长按输入框调起粘贴 - await textInput.longClick() - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.paste')))); - let pasteButton = await driver.findComponent(ON.text(await getResourceString($r('app.string.paste')))); - await pasteButton.click() - await driver.delayMs(DELAY_TIME) - let pasteValue = await textInput.getText() - Logger.info(TAG, BUNDLE + 'pasteMessageFunction_001 inputValue=' + pasteValue) - Logger.info(TAG, BUNDLE + 'PasteMessageFunction_001 pasteSuccess') - //返回 - let backBtn = await driver.findComponent(ON.id('backBtn')); - await backBtn.click(); - Logger.info( TAG, BUNDLE + 'Save_001 end'); - done() - }) - - //获取定位信息 - it("GetLocation_001", 0, async (done: Function) => { - await driver.delayMs(DELAY_TIME) - Logger.info(TAG, BUNDLE + 'GetLocation_001 begin') - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.discover')))); - let square = await driver.findComponent(ON.text(await getResourceString($r('app.string.discover')))); - await square.click() - Logger.info(TAG,BUNDLE + 'GetLocation_001 squareView') - //点击"同城"获取定位信息 - await driver.assertComponentExist(ON.type('LocationButton')) - Logger.info(TAG, BUNDLE + 'GetLocation_001 begin') - let location = await driver.findComponent(ON.type('LocationButton')) - await location.click() - Logger.info(TAG,BUNDLE + 'GetLocation_001 clickLocationButton') - // 点击确定 - await driver.delayMs(DELAY_TIME) - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.known')))); - let Button = await driver.findComponent(ON.text(await getResourceString($r('app.string.known')))); - await Button.click(); - //获取定位城市信息 - await driver.assertComponentExist(ON.id('locationDisplay')) - let locationValue = await driver.findComponent(ON.id('locationDisplay')) - let locationCity =await locationValue.getText() - await driver.delayMs(500); - Logger.info(TAG, BUNDLE + 'GetLocation_001 inputValue=' + locationCity) - // 返回 - let backBtn = await driver.findComponent(ON.id('locationbackBtn')) - await backBtn.click() - done() - }) - }) +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +import Logger from './Logger' +import { Driver, ON } from '@ohos.UiTest' +import Want from '@ohos.app.ability.Want'; +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +const BUNDLE = 'Weibo'; +const TAG = '[Sample_Weibo_Test]'; +const delegator = abilityDelegatorRegistry.getAbilityDelegator(); +const DELAY_TIME = 1000; + +async function getResourceString(resource: T): Promise { + let manage = delegator.getAppContext().resourceManager + let text = await manage.getStringValue(resource) + return text +} + +export default function abilityTest() { + let driver = Driver.create(); + describe('ActsAbilityTest', () => { + beforeAll(async ()=>{ + let want: Want = { + bundleName : 'com.samples.grapesquare', + abilityName : "EntryAbility" + } + await delegator.startAbility(want); + }) + + it("pass_advertisment", 0,async ()=> { + await driver.delayMs(DELAY_TIME); + Logger.info(TAG,BUNDLE + 'pass_advertisment begin'); + await driver.assertComponentExist(ON.id('skip')); + let passButton = await driver.findComponent(ON.id('skip')); + await passButton.click(); + Logger.info(TAG,BUNDLE + 'pass_advertisment end'); + }) + + //保存图片到媒体库 + it("Save_001", 0, async (done: Function) => { + Logger.info(TAG, BUNDLE + 'Save_001 begin'); + //点击进入微博展示页 + await driver.assertComponentExist(ON.id('textDetail')) + let viewList = await driver.findComponent(ON.id('textDetail')) + await driver.delayMs(500); + await viewList.click() + Logger.info(TAG, BUNDLE + 'Save_001 displayDetails') + //长按图片保存 + await driver.delayMs(DELAY_TIME) + await driver.assertComponentExist(ON.type('Image').isAfter(ON.id('textDetail'))) + let imageButton = await driver.findComponent(ON.type('Image').isAfter(ON.id('textDetail'))) + await driver.delayMs(500); + await imageButton.longClick() + //点击保存按钮 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.save')))); + let saveButton = await driver.findComponent(ON.text(await getResourceString($r('app.string.save')))); + await driver.delayMs(500); + await saveButton.click() + Logger.info(TAG, BUNDLE + 'Save_001 imageSaveSuccess') + await driver.delayMs(DELAY_TIME) + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.known')))); + let know = await driver.findComponent(ON.text(await getResourceString($r('app.string.known')))); + await know.click(); + //返回 + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + Logger.info( TAG, BUNDLE + 'Save_001 end'); + await driver.delayMs(DELAY_TIME) + done() + }) + + + //获取剪贴板内容 + it("GetPasteContent_001", 0, async (done: Function) => { + await driver.delayMs(500); + Logger.info(TAG, BUNDLE + 'GetPasteContent_001 begin') + //点击进入微博展示页 + await driver.assertComponentExist(ON.id('textDetail')) + let viewList = await driver.findComponent(ON.id('textDetail')) + await viewList.click() + Logger.info(TAG, BUNDLE + 'GetPasteContent_001 displayDetails') + //点击评论按钮 + let paste = await driver.findComponent(ON.id('commentButton').text(await getResourceString($r('app.string.comment')))); + await driver.delayMs(500); + await paste.click(); + Logger.info(TAG, BUNDLE + 'SendMessageFunction_001 addComment') + //点击输入框,调起输入法 + let textInput = await driver.findComponent(ON.id('comment_add')) + await textInput.click() + Logger.info(TAG, BUNDLE + 'SendMessageFunction_001 inputText') + //在输入框输入example + await textInput.inputText('example') + let inputValue = await textInput.getText() + Logger.info(TAG, BUNDLE + 'InputMessageFunction_001 inputValue=' + inputValue) + //长按输入框调起复制 + await textInput.click() + await textInput.longClick() + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.copy')))); + let copyButton = await driver.findComponent(ON.text(await getResourceString($r('app.string.copy')))); + await copyButton.click() + Logger.info(TAG, BUNDLE + 'SendMessageFunction_001 copySuccess') + //长按输入框调起粘贴 + await textInput.longClick() + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.paste')))); + let pasteButton = await driver.findComponent(ON.text(await getResourceString($r('app.string.paste')))); + await pasteButton.click() + await driver.delayMs(DELAY_TIME) + let pasteValue = await textInput.getText() + Logger.info(TAG, BUNDLE + 'pasteMessageFunction_001 inputValue=' + pasteValue) + Logger.info(TAG, BUNDLE + 'PasteMessageFunction_001 pasteSuccess') + //返回 + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + Logger.info( TAG, BUNDLE + 'Save_001 end'); + done() + }) + + //获取定位信息 + it("GetLocation_001", 0, async (done: Function) => { + await driver.delayMs(DELAY_TIME) + Logger.info(TAG, BUNDLE + 'GetLocation_001 begin') + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.discover')))); + let square = await driver.findComponent(ON.text(await getResourceString($r('app.string.discover')))); + await square.click() + Logger.info(TAG,BUNDLE + 'GetLocation_001 squareView') + //点击"同城"获取定位信息 + await driver.assertComponentExist(ON.type('LocationButton')) + Logger.info(TAG, BUNDLE + 'GetLocation_001 begin') + let location = await driver.findComponent(ON.type('LocationButton')) + await location.click() + Logger.info(TAG,BUNDLE + 'GetLocation_001 clickLocationButton') + // 点击确定 + await driver.delayMs(DELAY_TIME) + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.known')))); + let Button = await driver.findComponent(ON.text(await getResourceString($r('app.string.known')))); + await Button.click(); + //获取定位城市信息 + await driver.assertComponentExist(ON.id('locationDisplay')) + let locationValue = await driver.findComponent(ON.id('locationDisplay')) + let locationCity =await locationValue.getText() + await driver.delayMs(500); + Logger.info(TAG, BUNDLE + 'GetLocation_001 inputValue=' + locationCity) + // 返回 + let backBtn = await driver.findComponent(ON.id('locationbackBtn')) + await backBtn.click() + done() + }) + }) } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/List.test.ets b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/List.test.ets index 2a22ae6dc9..27c07a1a17 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/List.test.ets +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/List.test.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test' - -export default function testsuite() { - abilityTest() +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/Logger.ts b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/Logger.ts index 5e16f6a640..94213adc9f 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/Logger.ts +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/test/Logger.ts @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - // 日志对应的领域标识 - private domain: number = 0xF811; - // tag日志标识 - private prefix: string = '[Samples_AuthorizedControl]'; - // 格式字符串,用于日志的格式化输出 - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + // 日志对应的领域标识 + private domain: number = 0xF811; + // tag日志标识 + private prefix: string = '[Samples_AuthorizedControl]'; + // 格式字符串,用于日志的格式化输出 + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Samples_AuthorizedControl]'); \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testability/TestAbility.ets index 0d120161d5..0a150abd0d 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testability/TestAbility.ets +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; -import hilog from '@ohos.hilog'; -import { Hypium } from '@ohos/hypium'; -import testsuite from '../test/List.test'; -import window from '@ohos.window'; -import Want from '@ohos.app.ability.Want'; -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; - -export default class TestAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); - hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); - hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); - let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator - abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() - let abilityDelegatorArguments: abilityDelegatorRegistry.AbilityDelegatorArgs - abilityDelegatorArguments = abilityDelegatorRegistry.getArguments() - hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - } - - onDestroy() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); - windowStage.loadContent('testability/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() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); - } - - onForeground() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); - } - - onBackground() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); - } +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import hilog from '@ohos.hilog'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; +import window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; + +export default class TestAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); + let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator + abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + let abilityDelegatorArguments: abilityDelegatorRegistry.AbilityDelegatorArgs + abilityDelegatorArguments = abilityDelegatorRegistry.getArguments() + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/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() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testability/pages/Index.ets index 44948793a7..40f0a77aeb 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testability/pages/Index.ets +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -@Entry -@Component -struct Index { - aboutToAppear() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); - } - @State message: string = 'Hello World' - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('35%') - .height('5%') - .onClick(()=>{ - }) - } - .width('100%') - } - .height('100%') - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts index 1d7dc001bc..e3414df5c1 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import TestRunner from '@ohos.application.testRunner'; -import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; - -var abilityDelegator = undefined -var abilityDelegatorArguments = undefined - -async function onAbilityCreateCallback() { - hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); -} - -async function addAbilityMonitorCallback(err: any) { - hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); -} - -export default class OpenHarmonyTestRunner implements TestRunner { - constructor() { - } - - onPrepare() { - hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); - } - - async onRun() { - hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - const bundleName = abilityDelegatorArguments.bundleName; - const testAbilityName = 'TestAbility'; - let lMonitor = { - abilityName: testAbilityName, - onAbilityCreate: onAbilityCreateCallback, - }; - abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) - let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; - let debug = abilityDelegatorArguments.parameters['-D']; - if (debug == 'true') { - cmd += ' -D'; - } - hilog.info(0x0000,'testTag', 'cmd : %{public}s', cmd); - abilityDelegator.executeShellCommand(cmd, - (err: any, d: any) => { - hilog.info(0x0000,'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); - hilog.info(0x0000,'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); - hilog.info(0x0000,'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); - }) -/* const want = { - bundleName: bundleName, - abilityName: testAbilityName - }; - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - abilityDelegator.startAbility(want, (err : any, data : any) => { - hilog.info(0x0000, 'testTag', 'startAbility : err : %{public}s', JSON.stringify(err) ?? ''); - hilog.info(0x0000, 'testTag', 'startAbility : data : %{public}s',JSON.stringify(data) ?? ''); - }) - hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');*/ - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + const bundleName = abilityDelegatorArguments.bundleName; + const testAbilityName = 'TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; + let debug = abilityDelegatorArguments.parameters['-D']; + if (debug == 'true') { + cmd += ' -D'; + } + hilog.info(0x0000,'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000,'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000,'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000,'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) +/* const want = { + bundleName: bundleName, + abilityName: testAbilityName + }; + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + abilityDelegator.startAbility(want, (err : any, data : any) => { + hilog.info(0x0000, 'testTag', 'startAbility : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'startAbility : data : %{public}s',JSON.stringify(data) ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');*/ + } } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/module.json5 b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/module.json5 index 7e44e83cf9..e6a499c49e 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/module.json5 +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/element/color.json b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/element/color.json +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/element/string.json b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/element/string.json index 3436ca0366..cecafbf573 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/element/string.json +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/element/string.json @@ -1,40 +1,40 @@ -{ - "string": [ - { - "name": "module_test_desc", - "value": "test ability description" - }, - { - "name": "TestAbility_desc", - "value": "the test ability" - }, - { - "name": "TestAbility_label", - "value": "test label" - }, - { - "name": "save", - "value": "保存" - }, - { - "name": "known", - "value": "知道了" - }, - { - "name": "comment", - "value": "评论" - }, - { - "name": "copy", - "value": "复制" - }, - { - "name": "paste", - "value": "粘贴" - }, - { - "name": "discover", - "value": "发现" - } - ] +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "save", + "value": "保存" + }, + { + "name": "known", + "value": "知道了" + }, + { + "name": "comment", + "value": "评论" + }, + { + "name": "copy", + "value": "复制" + }, + { + "name": "paste", + "value": "粘贴" + }, + { + "name": "discover", + "value": "发现" + } + ] } \ No newline at end of file diff --git a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/profile/test_pages.json index c3d813c41a..b7e7343cac 100644 --- a/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/profile/test_pages.json +++ b/code/Solutions/Social/GrapeSquare/product/phone/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -1,5 +1,5 @@ -{ - "src": [ - "testability/pages/Index" - ] -} +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer/entry/src/main/ets/serviceability/ServiceAbility.ts b/code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer/entry/src/main/ets/serviceability/ServiceAbility.ts index 6de986e256..535bf6f349 100644 --- a/code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer/entry/src/main/ets/serviceability/ServiceAbility.ts +++ b/code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer/entry/src/main/ets/serviceability/ServiceAbility.ts @@ -1,229 +1,229 @@ -/* - * Copyright (c) 2023 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 rpc from '@ohos.rpc'; -import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; -import Logger from '../model/Logger'; -import { - APPLICATION_BUNDLE_NAME, - APPLICATION_ABILITY_NAME, - APPLICATION_SERVICE_NAME, - MusicSharedEventCode, - MusicConnectEvent -} from '../common/MusicSharedDefinition'; - -const TAG: string = 'ServiceAbility' -const CONNECT_REMOTE_TIMEOUT = 10000 - -let remoteProxy: rpc.RemoteProxy = null; - -class DistributedMusicServiceExtension extends rpc.RemoteObject { - private context - - constructor(des, context) { - super(des) - this.context = context - } - - startServiceAbility(want): void { - try { - let connectOptions = { - onConnect(elementName, remote): void { - Logger.info(TAG, `Start remote service has been succeeded, elementName= ${JSON.stringify(elementName)}, remote= ${JSON.stringify(remote)}`) - if (remote === null) { - Logger.info(TAG, 'Remote is null') - } - remoteProxy = remote as rpc.RemoteProxy; - clearTimeout(timeoutId) - let remoteServiceExtensionConnectEvent = AppStorage.get('remoteServiceExtensionConnectEvent'); - if (remoteServiceExtensionConnectEvent === undefined) { - Logger.info(TAG, `Connect remote service callback is ${JSON.stringify(remoteServiceExtensionConnectEvent)}`); - return; - } - AppStorage.setOrCreate('remoteServiceExtensionConnectEvent', !remoteServiceExtensionConnectEvent); - }, - onDisconnect(elementName): void { - Logger.info(TAG, `ServiceExtension has onDisconnected,elementName= ${JSON.stringify(elementName)}`) - clearTimeout(timeoutId) - remoteProxy = null; - let remoteServiceExtensionConnectEvent = AppStorage.get('remoteServiceExtensionConnectEvent'); - if (remoteServiceExtensionConnectEvent === undefined) { - Logger.info(TAG, `Disconnect remote service callback is ${JSON.stringify(remoteServiceExtensionConnectEvent)}`); - return; - } - AppStorage.setOrCreate('remoteServiceExtensionConnectEvent', !remoteServiceExtensionConnectEvent); - }, - onFailed(code): void { - Logger.info(TAG, `ServiceExtension has onFailed, code= ${JSON.stringify(code)}`) - clearTimeout(timeoutId) - remoteProxy = null; - let remoteServiceExtensionConnectEvent = AppStorage.get('remoteServiceExtensionConnectEvent'); - if (remoteServiceExtensionConnectEvent === undefined) { - Logger.info(TAG, `Failed remote service callback is ${JSON.stringify(remoteServiceExtensionConnectEvent)}`); - return; - } - AppStorage.setOrCreate('remoteServiceExtensionConnectEvent', !remoteServiceExtensionConnectEvent); - } - } - - this.context.connectServiceExtensionAbility(want, connectOptions) - let timeoutId = setTimeout(() => { - Logger.info(TAG, 'Connect remote service extension timeout') - let remoteServiceExtensionConnectEvent = AppStorage.get('remoteServiceExtensionConnectEvent'); - if (remoteServiceExtensionConnectEvent === undefined) { - Logger.info(TAG, `Timeout remote service callback is ${JSON.stringify(remoteServiceExtensionConnectEvent)}`); - return; - } - AppStorage.setOrCreate('remoteServiceExtensionConnectEvent', !remoteServiceExtensionConnectEvent); - }, CONNECT_REMOTE_TIMEOUT) - } catch (err) { - Logger.info(TAG, `ConnectServiceExtensionAbility has failed, want= ${JSON.stringify(want)}, err= ${JSON.stringify(err)}`) - } - } - - stopServiceAbility(want): void { - this.context.stopServiceExtensionAbility(want).then(() => { - Logger.info(TAG, `Stop service has been succeeded, want= ${JSON.stringify(want)}`) - }).catch((err) => { - Logger.info(TAG, `Stop service has been failed, want= ${JSON.stringify(want)}, err= ${JSON.stringify(err)}`) - }) - } - - onRemoteRequest(code: number, data: rpc.MessageParcel, reply: rpc.MessageParcel, options: rpc.MessageOption): boolean { - if (code === MusicSharedEventCode.START_DISTRIBUTED_MUSIC_SERVICE) { - let deviceId = data.readString() - let stringJson: string = data.readString() - try { - let jsonData = JSON.parse(stringJson); - Logger.info(TAG, `onRemoteRequest jsonData: ${JSON.stringify(jsonData)}`); - let params = { - uri: jsonData.uri, - seekTo: jsonData.seekTo, - isPlaying: jsonData.isPlaying, - flag: 'START_REMOTE_DISTRIBUTED_MUSIC_SERVICE' - } - let want = { - deviceId: deviceId, - bundleName: APPLICATION_BUNDLE_NAME, - abilityName: APPLICATION_SERVICE_NAME, - parameters: params - } - this.startServiceAbility(want); - } catch (error) { - Logger.error(TAG, `JSON text error`); - } - } else if (code === MusicSharedEventCode.STOP_DISTRIBUTED_MUSIC_SERVICE) { - let deviceId = data.readString() - let want = { - deviceId: deviceId, - bundleName: APPLICATION_BUNDLE_NAME, - abilityName: APPLICATION_SERVICE_NAME - } - this.stopServiceAbility(want) - } else if (code === MusicSharedEventCode.PLAY_MUSIC_SERVICE) { - if (remoteProxy === null) { - Logger.info(TAG, 'Play local is null') - return false - } - let option = new rpc.MessageOption() - let data = new rpc.MessageParcel() - let reply = new rpc.MessageParcel() - remoteProxy.sendRequest(MusicSharedEventCode.PLAY_MUSIC_SERVICE_REMOTE, data, reply, option); - } else if (code === MusicSharedEventCode.PAUSE_MUSIC_SERVICE) { - if (remoteProxy === null) { - Logger.info(TAG, 'Pause local is null') - return false - } - let option = new rpc.MessageOption() - let data = new rpc.MessageParcel() - let reply = new rpc.MessageParcel() - remoteProxy.sendRequest(MusicSharedEventCode.PAUSE_MUSIC_SERVICE_REMOTE, data, reply, option); - } else if (code === MusicSharedEventCode.PLAY_MUSIC_SERVICE_REMOTE) { - let musicPlay = AppStorage.get('musicPlay'); - if (musicPlay === undefined) { - Logger.error(TAG, 'get play callback form app storage falied'); - return false; - } - AppStorage.setOrCreate('musicPlay', !musicPlay); - } else if (code === MusicSharedEventCode.PAUSE_MUSIC_SERVICE_REMOTE) { - let musicPause = AppStorage.get('musicPause'); - if (musicPause === undefined) { - Logger.error(TAG, 'get pause callback form app storage falied'); - return false; - } - AppStorage.setOrCreate('musicPause', !musicPause); - } else if (code === MusicSharedEventCode.STOP_LOCAL_SERIVCE) { - this.context.terminateSelf().then(() => { - Logger.info(TAG, 'TerminateSelf service extension has been succeeded') - }).catch((err) => { - Logger.info(TAG, `TerminateSelf service extension has been failed err= ${JSON.stringify(err)}`) - }) - } else { - Logger.info(TAG, 'Invalid instruction') - return false - } - return true - } -} - -export default class ServiceAbility extends ServiceExtensionAbility { - onCreate(want): void { - if (want.parameters.flag === 'START_REMOTE_DISTRIBUTED_MUSIC_SERVICE') { - let localwant = { - bundleName: APPLICATION_BUNDLE_NAME, - abilityName: APPLICATION_ABILITY_NAME, - parameters: want.parameters - } - this.context.startAbility(localwant).then(() => { - Logger.info(TAG, 'StartUIAbility has been succeeded') - }).catch((err) => { - Logger.info(TAG, `StartUIAbility has been failed, err= ${JSON.stringify(err)}`) - }) - } - } - - onDestroy(): void { - Logger.info(TAG, 'ServiceAbility onDestroy') - } - - onRequest(want, startId): void { - Logger.info(TAG, 'ServiceAbility onRequest') - } - - onConnect(want): rpc.RemoteObject { - Logger.info(TAG, 'ServiceAbility onConnect') - if (this.context === null && this.context === undefined) { - Logger.error(TAG, 'ServiceAbility context does not exist or is empty') - return - } - return new DistributedMusicServiceExtension('ohos.samples.distributedMusicServiceExtension', this.context) - } - - onDisconnect(want): void { - Logger.info(TAG, 'ServiceAbility onDisconnect') - } - - onReconnect(want): void { - Logger.info(TAG, 'ServiceAbility onReconnect') - } - - onConfigurationUpdate(newConfig): void { - Logger.info(TAG, 'ServiceAbility onConfigurationUpdate') - } - - onDump(params: Array): Array { - Logger.info(TAG, 'ServiceAbility onDump') - return params - } +/* + * Copyright (c) 2023 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 rpc from '@ohos.rpc'; +import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; +import Logger from '../model/Logger'; +import { + APPLICATION_BUNDLE_NAME, + APPLICATION_ABILITY_NAME, + APPLICATION_SERVICE_NAME, + MusicSharedEventCode, + MusicConnectEvent +} from '../common/MusicSharedDefinition'; + +const TAG: string = 'ServiceAbility' +const CONNECT_REMOTE_TIMEOUT = 10000 + +let remoteProxy: rpc.RemoteProxy = null; + +class DistributedMusicServiceExtension extends rpc.RemoteObject { + private context + + constructor(des, context) { + super(des) + this.context = context + } + + startServiceAbility(want): void { + try { + let connectOptions = { + onConnect(elementName, remote): void { + Logger.info(TAG, `Start remote service has been succeeded, elementName= ${JSON.stringify(elementName)}, remote= ${JSON.stringify(remote)}`) + if (remote === null) { + Logger.info(TAG, 'Remote is null') + } + remoteProxy = remote as rpc.RemoteProxy; + clearTimeout(timeoutId) + let remoteServiceExtensionConnectEvent = AppStorage.get('remoteServiceExtensionConnectEvent'); + if (remoteServiceExtensionConnectEvent === undefined) { + Logger.info(TAG, `Connect remote service callback is ${JSON.stringify(remoteServiceExtensionConnectEvent)}`); + return; + } + AppStorage.setOrCreate('remoteServiceExtensionConnectEvent', !remoteServiceExtensionConnectEvent); + }, + onDisconnect(elementName): void { + Logger.info(TAG, `ServiceExtension has onDisconnected,elementName= ${JSON.stringify(elementName)}`) + clearTimeout(timeoutId) + remoteProxy = null; + let remoteServiceExtensionConnectEvent = AppStorage.get('remoteServiceExtensionConnectEvent'); + if (remoteServiceExtensionConnectEvent === undefined) { + Logger.info(TAG, `Disconnect remote service callback is ${JSON.stringify(remoteServiceExtensionConnectEvent)}`); + return; + } + AppStorage.setOrCreate('remoteServiceExtensionConnectEvent', !remoteServiceExtensionConnectEvent); + }, + onFailed(code): void { + Logger.info(TAG, `ServiceExtension has onFailed, code= ${JSON.stringify(code)}`) + clearTimeout(timeoutId) + remoteProxy = null; + let remoteServiceExtensionConnectEvent = AppStorage.get('remoteServiceExtensionConnectEvent'); + if (remoteServiceExtensionConnectEvent === undefined) { + Logger.info(TAG, `Failed remote service callback is ${JSON.stringify(remoteServiceExtensionConnectEvent)}`); + return; + } + AppStorage.setOrCreate('remoteServiceExtensionConnectEvent', !remoteServiceExtensionConnectEvent); + } + } + + this.context.connectServiceExtensionAbility(want, connectOptions) + let timeoutId = setTimeout(() => { + Logger.info(TAG, 'Connect remote service extension timeout') + let remoteServiceExtensionConnectEvent = AppStorage.get('remoteServiceExtensionConnectEvent'); + if (remoteServiceExtensionConnectEvent === undefined) { + Logger.info(TAG, `Timeout remote service callback is ${JSON.stringify(remoteServiceExtensionConnectEvent)}`); + return; + } + AppStorage.setOrCreate('remoteServiceExtensionConnectEvent', !remoteServiceExtensionConnectEvent); + }, CONNECT_REMOTE_TIMEOUT) + } catch (err) { + Logger.info(TAG, `ConnectServiceExtensionAbility has failed, want= ${JSON.stringify(want)}, err= ${JSON.stringify(err)}`) + } + } + + stopServiceAbility(want): void { + this.context.stopServiceExtensionAbility(want).then(() => { + Logger.info(TAG, `Stop service has been succeeded, want= ${JSON.stringify(want)}`) + }).catch((err) => { + Logger.info(TAG, `Stop service has been failed, want= ${JSON.stringify(want)}, err= ${JSON.stringify(err)}`) + }) + } + + onRemoteRequest(code: number, data: rpc.MessageParcel, reply: rpc.MessageParcel, options: rpc.MessageOption): boolean { + if (code === MusicSharedEventCode.START_DISTRIBUTED_MUSIC_SERVICE) { + let deviceId = data.readString() + let stringJson: string = data.readString() + try { + let jsonData = JSON.parse(stringJson); + Logger.info(TAG, `onRemoteRequest jsonData: ${JSON.stringify(jsonData)}`); + let params = { + uri: jsonData.uri, + seekTo: jsonData.seekTo, + isPlaying: jsonData.isPlaying, + flag: 'START_REMOTE_DISTRIBUTED_MUSIC_SERVICE' + } + let want = { + deviceId: deviceId, + bundleName: APPLICATION_BUNDLE_NAME, + abilityName: APPLICATION_SERVICE_NAME, + parameters: params + } + this.startServiceAbility(want); + } catch (error) { + Logger.error(TAG, `JSON text error`); + } + } else if (code === MusicSharedEventCode.STOP_DISTRIBUTED_MUSIC_SERVICE) { + let deviceId = data.readString() + let want = { + deviceId: deviceId, + bundleName: APPLICATION_BUNDLE_NAME, + abilityName: APPLICATION_SERVICE_NAME + } + this.stopServiceAbility(want) + } else if (code === MusicSharedEventCode.PLAY_MUSIC_SERVICE) { + if (remoteProxy === null) { + Logger.info(TAG, 'Play local is null') + return false + } + let option = new rpc.MessageOption() + let data = new rpc.MessageParcel() + let reply = new rpc.MessageParcel() + remoteProxy.sendRequest(MusicSharedEventCode.PLAY_MUSIC_SERVICE_REMOTE, data, reply, option); + } else if (code === MusicSharedEventCode.PAUSE_MUSIC_SERVICE) { + if (remoteProxy === null) { + Logger.info(TAG, 'Pause local is null') + return false + } + let option = new rpc.MessageOption() + let data = new rpc.MessageParcel() + let reply = new rpc.MessageParcel() + remoteProxy.sendRequest(MusicSharedEventCode.PAUSE_MUSIC_SERVICE_REMOTE, data, reply, option); + } else if (code === MusicSharedEventCode.PLAY_MUSIC_SERVICE_REMOTE) { + let musicPlay = AppStorage.get('musicPlay'); + if (musicPlay === undefined) { + Logger.error(TAG, 'get play callback form app storage falied'); + return false; + } + AppStorage.setOrCreate('musicPlay', !musicPlay); + } else if (code === MusicSharedEventCode.PAUSE_MUSIC_SERVICE_REMOTE) { + let musicPause = AppStorage.get('musicPause'); + if (musicPause === undefined) { + Logger.error(TAG, 'get pause callback form app storage falied'); + return false; + } + AppStorage.setOrCreate('musicPause', !musicPause); + } else if (code === MusicSharedEventCode.STOP_LOCAL_SERIVCE) { + this.context.terminateSelf().then(() => { + Logger.info(TAG, 'TerminateSelf service extension has been succeeded') + }).catch((err) => { + Logger.info(TAG, `TerminateSelf service extension has been failed err= ${JSON.stringify(err)}`) + }) + } else { + Logger.info(TAG, 'Invalid instruction') + return false + } + return true + } +} + +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want): void { + if (want.parameters.flag === 'START_REMOTE_DISTRIBUTED_MUSIC_SERVICE') { + let localwant = { + bundleName: APPLICATION_BUNDLE_NAME, + abilityName: APPLICATION_ABILITY_NAME, + parameters: want.parameters + } + this.context.startAbility(localwant).then(() => { + Logger.info(TAG, 'StartUIAbility has been succeeded') + }).catch((err) => { + Logger.info(TAG, `StartUIAbility has been failed, err= ${JSON.stringify(err)}`) + }) + } + } + + onDestroy(): void { + Logger.info(TAG, 'ServiceAbility onDestroy') + } + + onRequest(want, startId): void { + Logger.info(TAG, 'ServiceAbility onRequest') + } + + onConnect(want): rpc.RemoteObject { + Logger.info(TAG, 'ServiceAbility onConnect') + if (this.context === null && this.context === undefined) { + Logger.error(TAG, 'ServiceAbility context does not exist or is empty') + return + } + return new DistributedMusicServiceExtension('ohos.samples.distributedMusicServiceExtension', this.context) + } + + onDisconnect(want): void { + Logger.info(TAG, 'ServiceAbility onDisconnect') + } + + onReconnect(want): void { + Logger.info(TAG, 'ServiceAbility onReconnect') + } + + onConfigurationUpdate(newConfig): void { + Logger.info(TAG, 'ServiceAbility onConfigurationUpdate') + } + + onDump(params: Array): Array { + Logger.info(TAG, 'ServiceAbility onDump') + return params + } } \ No newline at end of file diff --git a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/AppScope/app.json5 b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/AppScope/app.json5 index 058c41157e..756ccf115f 100644 --- a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/AppScope/app.json5 +++ b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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.distributedfilemanager", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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.distributedfilemanager", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/AppScope/resources/base/element/string.json b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/AppScope/resources/base/element/string.json index 1d8ff02351..1a825da4ec 100644 --- a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/AppScope/resources/base/element/string.json +++ b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "分布式文件管理" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "分布式文件管理" + } + ] +} diff --git a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/build-profile.json5 b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/build-profile.json5 index 66f05ac206..66a6f8f36d 100644 --- a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/build-profile.json5 +++ b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/build-profile.json5 @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 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": { - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "Library", - "srcPath": "./Library" - } - ] +/* + * Copyright (c) 2023 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": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "Library", + "srcPath": "./Library" + } + ] } \ No newline at end of file diff --git a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/entryability/EntryAbility.ets b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/entryability/EntryAbility.ets index 21b1c8420e..10fda1fe60 100644 --- a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import DataObject from '../model/DataObject'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import window from '@ohos.window'; -import Want from '@ohos.app.ability.Want'; -import { Logger } from '@ohos/feature-file-manager'; - -let sessionId : string; - -export default class EntryAbility extends UIAbility { - async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onCreate'); - //user grant - let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); - try { - let requestPermissionsResult = await atManager.requestPermissionsFromUser(this.context, - ['ohos.permission.DISTRIBUTED_DATASYNC']); - Logger.info(`requestPermissionsResult: ${JSON.stringify(requestPermissionsResult)}`); - } catch (err) { - Logger.error(`catch err: ${JSON.stringify(err)}`); - } - - // 判断是否被拉起 - if (want.parameters && want.parameters.distributedSessionId) { - sessionId = want.parameters.distributedSessionId as string; - DataObject.createDataObject(this.context, sessionId); - } else { - DataObject.callRemote(this.context); - DataObject.createDataObject(this.context); - } - } - - onDestroy() { - Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - Logger.error('0x0000', 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - Logger.info('0x0000', 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground() { - // Ability has back to background - Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import DataObject from '../model/DataObject'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import { Logger } from '@ohos/feature-file-manager'; + +let sessionId : string; + +export default class EntryAbility extends UIAbility { + async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onCreate'); + //user grant + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); + try { + let requestPermissionsResult = await atManager.requestPermissionsFromUser(this.context, + ['ohos.permission.DISTRIBUTED_DATASYNC']); + Logger.info(`requestPermissionsResult: ${JSON.stringify(requestPermissionsResult)}`); + } catch (err) { + Logger.error(`catch err: ${JSON.stringify(err)}`); + } + + // 判断是否被拉起 + if (want.parameters && want.parameters.distributedSessionId) { + sessionId = want.parameters.distributedSessionId as string; + DataObject.createDataObject(this.context, sessionId); + } else { + DataObject.callRemote(this.context); + DataObject.createDataObject(this.context); + } + } + + onDestroy() { + Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error('0x0000', 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + Logger.info('0x0000', 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + Logger.info('0x0000', 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/model/DataObject.ets b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/model/DataObject.ets index 4d838f95f0..c005e636a0 100644 --- a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/model/DataObject.ets +++ b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/model/DataObject.ets @@ -1,150 +1,150 @@ -/* - * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 common from '@ohos.app.ability.common'; -import distributedDataObject from '@ohos.data.distributedDataObject'; -import distributedDeviceManager from '@ohos.distributedDeviceManager'; -import fs from '@ohos.file.fs'; -import Want from '@ohos.app.ability.Want'; -import { BusinessError } from '@ohos.base'; -import { Caller } from '@ohos.app.ability.UIAbility'; -import { Logger } from '@ohos/feature-file-manager'; - -const TAG: string = 'DataObjectModel'; -let caller: Caller; - -class DataObject { - public distributedObject: distributedDataObject.DataObject | undefined = undefined; - private sessionId: string = ''; - - createDataObject(context: common.UIAbilityContext, sessionId?: string) { - if (this.distributedObject) { - Logger.error(TAG, 'create dataObject already'); - return; - } - - // 创建分布式数据对象实例 - this.distributedObject = distributedDataObject.create(context, { - from: '', - localFileUriList: [], - disFileUriList: [], - disFileList: [] - }); - - // 设置数据变更监听 - this.distributedObject.on('change', (sessionId: string, fields: Array) => { - Logger.info(TAG, `change, sessionId: ${sessionId}, fields: ${JSON.stringify(fields)}`); - fields.forEach((field) => { - Logger.info(TAG, `${field}: ${this.distributedObject![field]}`); - }); - }); - // 设置同步sessionId加入组网 - if (sessionId) { - this.sessionId = sessionId; - } - this.distributedObject.setSessionId(this.sessionId); - } - - // 调用端调用startAbilityByCall接口拉起对端Ability - callRemote(context: common.UIAbilityContext) { - if (caller) { - Logger.error(TAG, 'call remote already'); - return; - } - - // 调用genSessionId接口创建一个sessionId、获取对端设备networkId - if (!this.sessionId) { - this.sessionId = distributedDataObject.genSessionId(); - } - Logger.info(TAG, `gen sessionId: ${this.sessionId}`); - let deviceId = getRemoteDeviceId(); - if (deviceId == '') { - Logger.error(TAG, 'no remote device'); - return; - } - Logger.info(TAG, `get remote deviceId: ${deviceId}`); - - let want: Want = { - bundleName: 'com.samples.distributedfilemanager', - abilityName: 'EntryAbility', - deviceId: deviceId, - parameters: { - 'ohos.aafwk.param.callAbilityToForeground': true, - 'distributedSessionId': this.sessionId - } - } - try { - context.startAbilityByCall(want).then((res) => { - if (!res) { - Logger.error(TAG, 'startAbilityByCall failed'); - } - Logger.info(TAG, 'startAbilityByCall success'); - caller = res; - }) - } catch (e) { - let err = e as BusinessError; - Logger.error(TAG, `get remote deviceId error, error code: ${err.code}, error message: ${err.message}`); - } - } - - update(from: string, localFileUriList: string[], disFileUriList: string[], disFileList: string[]) { - Logger.info(TAG, `doUpdate,${from},${localFileUriList},${disFileUriList},${disFileList}`) - this.distributedObject!['from'] = from; - this.distributedObject!['localFileUriList'] = localFileUriList; - this.distributedObject!['disFileUriList'] = disFileUriList; - this.distributedObject!['disFileList'] = disFileList; - } - - clear() { - try{ - let disFileArray: Array = this.distributedObject!["disFileList"]; - disFileArray.forEach( item => { - //判断uri前缀是否有“file+”,如果有则为文件 - if(item.includes("file+")){ - item = item.substring(5, item.length); - fs.unlinkSync(item); - } else { - fs.rmdirSync(item); - } - }) - } catch (err) { - Logger.error(TAG, `delete failed, code is ${err.code}, message is ${err.message}`); - } - this.distributedObject!['from'] = ''; - this.distributedObject!['localFileUriList'] = []; - this.distributedObject!['disFileUriList'] = []; - this.distributedObject!['disFileList'] = []; - } -} - -// 获取可信组网中的设备 -function getRemoteDeviceId() { - let deviceId = ''; - try { - let deviceManager = distributedDeviceManager.createDeviceManager('com.samples.distributedfilemanager'); - let devices = deviceManager.getAvailableDeviceListSync(); - for (let device of devices) { - if (device.networkId) { - deviceId = device.networkId; - } - } - } catch (e) { - let err = e as BusinessError; - Logger.error(TAG, `get remote deviceId error, error code: ${err.code}, error message: ${err.message}`); - } - return deviceId; -} - -export default new DataObject(); +/* + * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 common from '@ohos.app.ability.common'; +import distributedDataObject from '@ohos.data.distributedDataObject'; +import distributedDeviceManager from '@ohos.distributedDeviceManager'; +import fs from '@ohos.file.fs'; +import Want from '@ohos.app.ability.Want'; +import { BusinessError } from '@ohos.base'; +import { Caller } from '@ohos.app.ability.UIAbility'; +import { Logger } from '@ohos/feature-file-manager'; + +const TAG: string = 'DataObjectModel'; +let caller: Caller; + +class DataObject { + public distributedObject: distributedDataObject.DataObject | undefined = undefined; + private sessionId: string = ''; + + createDataObject(context: common.UIAbilityContext, sessionId?: string) { + if (this.distributedObject) { + Logger.error(TAG, 'create dataObject already'); + return; + } + + // 创建分布式数据对象实例 + this.distributedObject = distributedDataObject.create(context, { + from: '', + localFileUriList: [], + disFileUriList: [], + disFileList: [] + }); + + // 设置数据变更监听 + this.distributedObject.on('change', (sessionId: string, fields: Array) => { + Logger.info(TAG, `change, sessionId: ${sessionId}, fields: ${JSON.stringify(fields)}`); + fields.forEach((field) => { + Logger.info(TAG, `${field}: ${this.distributedObject![field]}`); + }); + }); + // 设置同步sessionId加入组网 + if (sessionId) { + this.sessionId = sessionId; + } + this.distributedObject.setSessionId(this.sessionId); + } + + // 调用端调用startAbilityByCall接口拉起对端Ability + callRemote(context: common.UIAbilityContext) { + if (caller) { + Logger.error(TAG, 'call remote already'); + return; + } + + // 调用genSessionId接口创建一个sessionId、获取对端设备networkId + if (!this.sessionId) { + this.sessionId = distributedDataObject.genSessionId(); + } + Logger.info(TAG, `gen sessionId: ${this.sessionId}`); + let deviceId = getRemoteDeviceId(); + if (deviceId == '') { + Logger.error(TAG, 'no remote device'); + return; + } + Logger.info(TAG, `get remote deviceId: ${deviceId}`); + + let want: Want = { + bundleName: 'com.samples.distributedfilemanager', + abilityName: 'EntryAbility', + deviceId: deviceId, + parameters: { + 'ohos.aafwk.param.callAbilityToForeground': true, + 'distributedSessionId': this.sessionId + } + } + try { + context.startAbilityByCall(want).then((res) => { + if (!res) { + Logger.error(TAG, 'startAbilityByCall failed'); + } + Logger.info(TAG, 'startAbilityByCall success'); + caller = res; + }) + } catch (e) { + let err = e as BusinessError; + Logger.error(TAG, `get remote deviceId error, error code: ${err.code}, error message: ${err.message}`); + } + } + + update(from: string, localFileUriList: string[], disFileUriList: string[], disFileList: string[]) { + Logger.info(TAG, `doUpdate,${from},${localFileUriList},${disFileUriList},${disFileList}`) + this.distributedObject!['from'] = from; + this.distributedObject!['localFileUriList'] = localFileUriList; + this.distributedObject!['disFileUriList'] = disFileUriList; + this.distributedObject!['disFileList'] = disFileList; + } + + clear() { + try{ + let disFileArray: Array = this.distributedObject!["disFileList"]; + disFileArray.forEach( item => { + //判断uri前缀是否有“file+”,如果有则为文件 + if(item.includes("file+")){ + item = item.substring(5, item.length); + fs.unlinkSync(item); + } else { + fs.rmdirSync(item); + } + }) + } catch (err) { + Logger.error(TAG, `delete failed, code is ${err.code}, message is ${err.message}`); + } + this.distributedObject!['from'] = ''; + this.distributedObject!['localFileUriList'] = []; + this.distributedObject!['disFileUriList'] = []; + this.distributedObject!['disFileList'] = []; + } +} + +// 获取可信组网中的设备 +function getRemoteDeviceId() { + let deviceId = ''; + try { + let deviceManager = distributedDeviceManager.createDeviceManager('com.samples.distributedfilemanager'); + let devices = deviceManager.getAvailableDeviceListSync(); + for (let device of devices) { + if (device.networkId) { + deviceId = device.networkId; + } + } + } catch (e) { + let err = e as BusinessError; + Logger.error(TAG, `get remote deviceId error, error code: ${err.code}, error message: ${err.message}`); + } + return deviceId; +} + +export default new DataObject(); diff --git a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/model/FsManager.ets b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/model/FsManager.ets index fcfe40826b..58f5ab50a8 100644 --- a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/model/FsManager.ets +++ b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/ets/model/FsManager.ets @@ -1,316 +1,316 @@ -/* - * Copyright (c) 2023-2025 Shenzhen Kaihong Digital Industry Development 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 common from '@ohos.app.ability.common'; -import fs from '@ohos.file.fs'; -import fileuri from '@ohos.file.fileuri'; -import Logger from '../../../../../Library/src/main/ets/utils/Logger'; -import prompt from '@ohos.promptAction'; -import DataObject from './DataObject'; -import { BusinessError } from '@ohos.base'; -import { FileStructure, FileType } from '@ohos/feature-file-manager/src/main/ets/mock/local/FileData'; - -const TAG: string = 'FsManager'; -const BASE_PATH = "/data/storage/el2/base/haps/entry/files"; -let filesDir1 = BASE_PATH + '/test1'; -let filesDir2 = BASE_PATH + '/test2'; -let precastFiles: string[] = [ - "file1.txt", - "file2.txt", - "file3.txt", -]; - -let isCopying: boolean = false; -const fileCopy: string = '-副本'; - -class FsManager { - initFiles(): void { - try { - let res = fs.accessSync(filesDir1); - if (res) { - Logger.info(TAG, `file path: ${filesDir1} exists`); - } else { - Logger.info(TAG, `file path: ${filesDir1} not exists`); - fs.mkdirSync(filesDir1); - } - } catch (error) { - let err: BusinessError = error as BusinessError; - Logger.error(TAG, "accessSync failed with error message: " + err.message + ", error code: " + err.code); - } - try { - let res = fs.accessSync(filesDir2); - if (res) { - Logger.info(TAG, `file path: ${filesDir2} exists`); - } else { - Logger.info(TAG, `file path: ${filesDir2} not exists`); - fs.mkdirSync(filesDir2); - } - } catch (error) { - let err: BusinessError = error as BusinessError; - Logger.error(TAG, "accessSync failed with error message: " + err.message + ", error code: " + err.code); - } - - for (let i = 0; i < precastFiles.length; i++) { - let fileName = filesDir1 + "/" + precastFiles[i]; - Logger.info(TAG, `The file name: ${fileName}`); - try { - let res = fs.accessSync(fileName); - if (res) { - Logger.info(TAG, `file: ${fileName} exists!.`); - } else { - Logger.info(TAG, `file: ${fileName} not exists, will create it!.`); - let file = fs.openSync(fileName, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); - fs.writeSync(file.fd, 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1' + - 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test' + - 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test' + - 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test' + - 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test' + - 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test'); - fs.closeSync(file); - } - } catch (error) { - let err: BusinessError = error as BusinessError; - Logger.error(TAG, "accessSync failed with error message: " + err.message + ", error code: " + err.code); - } - } - - let fileName = filesDir2 + "/" + "file4.txt"; - try { - let res = fs.accessSync(fileName); - if (res) { - Logger.info(TAG, `file: ${fileName} exists!.`); - } else { - Logger.info(TAG, `file: ${fileName} not exists, will create it!.`); - let file = fs.openSync(fileName, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); - fs.writeSync(file.fd, 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4' + - 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4' + - 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4' + - 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4' + - 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4' + - 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4'); - fs.closeSync(file); - } - } catch (error) { - let err: BusinessError = error as BusinessError; - Logger.error(TAG, "accessSync failed with error message: " + err.message + ", error code: " + err.code); - } - } - - listFiles(dir: string): Array { - let files: string[] = []; - let context = getContext(this) as common.UIAbilityContext; - let fileDir = (dir == 'files' ? context.filesDir : (dir == 'temp' ? context.tempDir : context.cacheDir)); - Logger.info(TAG, `listFiles fileDir =${fileDir}`); - try { - files = fs.listFileSync(fileDir); - Logger.info(TAG, `listFiles listFileSync =${JSON.stringify(files)}`); - } catch (err) { - Logger.info(TAG, `listFiles err =${JSON.stringify(err)}`); - } - return files; - } - - copyFilesToDistributedDir(deviceId: string, needMoveFiles: Array, disPathInSandbox: string) { - let distributedUri0 = fileuri.getUriFromPath(disPathInSandbox); - let localFileUriList: Array = []; - let disFileUriList: Array = []; - let disFileList: Array = []; - let distributedUri = ''; - needMoveFiles.forEach((file: FileType) => { - Logger.info(TAG, `in copyToDistributedDir--file type : ${file.type}`); - //用于粘贴完后的clear动作中 - let disFilePath = disPathInSandbox + "/" + file.fileName; - //type: 1 directory,type 2 file - let localSrcUri = fileuri.getUriFromPath(file.filePath); - //如果是文件夹 - if (file.type === 1) { - distributedUri = distributedUri0 + "/" + file.fileName; - this.innerCopyFilesToDistributedDir(localSrcUri, distributedUri0); - } else if (file.type === 2) { //处理Uri,如果是文件类型,需另外处理,前缀增加"file+",用分布式对象进行传输 - const fileName = localSrcUri.split('/').pop(); - distributedUri = distributedUri0 + "/" + fileName; - this.innerCopyFilesToDistributedDir(localSrcUri, distributedUri); - localSrcUri = "file+" + localSrcUri; - distributedUri = "file+" + distributedUri; - } else { - Logger.error(TAG, `this is not file or directory`); - } - // to update DataObject - localFileUriList.push(localSrcUri); - disFileUriList.push(localSrcUri); - disFileList.push(disFilePath); - }) - DataObject.update(deviceId, localFileUriList, disFileUriList, disFileList); - } - - //复制到剪切板,不弹进度条 - innerCopyFilesToDistributedDir(from: string, to: string) { - Logger.info(TAG, `copyToDistributedDir--from: ${from}`); - Logger.info(TAG, `copyToDistributedDir--to: ${to}`); - try { - // copy - let progressListener: fs.ProgressListener = (progress: fs.Progress) => { - Logger.info(TAG, "progressSize: " + progress.processedSize + ", totalSize: " + progress.totalSize); - }; - let options: fs.CopyOptions = { - "progressListener": progressListener - }; - // 进行拷贝 - fs.copy(from, to, options).then(() => { - Logger.info("Succeeded in copying. "); - }).catch((err: BusinessError) => { - Logger.info(`Failed to copy. Code: ${err.code}, message: ${err.message}`); - return prompt.showToast({ message: $r('app.string.label_copy2disfailed') }); - }) - } catch (error) { - let err: BusinessError = error as BusinessError; - Logger.error(TAG, `Failed to set paste data. Code: ${err.code}, message: ${err.message}`); - } - } - - pasteFromDistributedDir(deviceId: string, directoryPath: string, fileData: Array) { - let localDstUri = fileuri.getUriFromPath(directoryPath); - - if (DataObject.distributedObject!["disFileUriList"].length === 0) { - return prompt.showToast({ message: $r('app.string.label_nodata') }); - } - //本地拷贝:文件需进行重命名操作 - if (deviceId == DataObject.distributedObject!["from"]) { - let localFileArray: Array = DataObject.distributedObject!["localFileUriList"]; - let newFileName: string = ''; - localFileArray.forEach(item => { - //判断uri前缀是否有“file+”,如果是文件类型,去掉“file+”前缀,在localDstUri后面加上文件名称 - if (item.includes("file+")) { - item = item.substring(5, item.length); - let fileName: string | undefined = item.split('/').pop(); - if (fileName) { - newFileName = decodeURIComponent(fileName); - } else { - return; - } - //判断本地是否有同名文件,有则重命名 - fileData.forEach(file => { - //有同名文件 - if (decodeURIComponent(file.name).includes(newFileName)) { - //extension 文件后缀 - let extension: string = newFileName.slice((newFileName.lastIndexOf(".") - 1 >>> 0) + 2); - if (extension) { - let fileParts = newFileName.split('.'); - newFileName = fileParts[0] + fileCopy + '.' + fileParts[1]; - } else { - newFileName = newFileName + fileCopy; - } - } - }) - } - this.innerPasteFromDistributedDir(item, localDstUri + newFileName); - }) - } else { //跨设备拷贝 - let disFileUriArray: Array = DataObject.distributedObject!["disFileUriList"]; - disFileUriArray.forEach(item => { - if (item.includes("file+")) { - item = item.substring(5, item.length); - let fileName: string | undefined = item.split('/').pop(); - let newFileName: string = ''; - if (fileName) { - newFileName = decodeURIComponent(fileName); - //判断是否有同名文件,有则重命名 - fileData.forEach(file => { - //有同名文件 - if (decodeURIComponent(file.name).includes(newFileName)) { - //extension 文件后缀 - let extension: string = newFileName.slice((newFileName.lastIndexOf(".") - 1 >>> 0) + 2); - if (extension) { - let fileParts = newFileName.split('.'); - newFileName = fileParts[0] + fileCopy + '.' + fileParts[1]; - } else { - newFileName = newFileName + fileCopy; - } - } - }) - } else { - return; - } - this.innerPasteFromDistributedDir(item, localDstUri + newFileName); - } else { - this.innerPasteFromDistributedDir(item, localDstUri); - } - }) - } - } - - //粘贴,弹进度条 - innerPasteFromDistributedDir(from: string, to: string) { - Logger.info(TAG, `innerPasteFromDistributedDir--from: ${from}`); - Logger.info(TAG, `innerPasteFromDistributedDir--to: ${to}`); - try { - // 定义拷贝回调 - let totalProgress: number = 0; - let totalCopySize: number = 0; - let copiedSize: number = 0; - let lastCopiedSize: number = 0; - let firstCopy = true; - let progressListener: fs.ProgressListener = (progress: fs.Progress) => { - Logger.info(TAG, "progressSize: " + progress.processedSize + ", totalSize: " + progress.totalSize); - //第一次进入回调 - if (firstCopy === true) { - Logger.info(TAG, "firstCopy"); - totalCopySize += progress.totalSize; - copiedSize += progress.processedSize; - lastCopiedSize = progress.processedSize; - firstCopy = false; - } else { - copiedSize -= lastCopiedSize; - copiedSize += progress.processedSize; - lastCopiedSize = progress.processedSize; - } - - totalProgress = Number(((copiedSize / totalCopySize) * 100).toFixed(0)); - AppStorage.setOrCreate('progress', totalProgress); - Logger.info(TAG, "totalCopySize: " + totalCopySize + ", copiedSize: " + copiedSize); - if (totalCopySize != copiedSize) { - isCopying = true; - AppStorage.setOrCreate('isCopying', true); - } else { - Logger.info(TAG, "totalCopySize == copiedSize,Successfully coppied"); - isCopying = false; - AppStorage.setOrCreate('isCopying', false); - AppStorage.setOrCreate('flashPage',!AppStorage.get('flashPage')); - DataObject.clear(); - return prompt.showToast({ message: $r('app.string.label_dirupdate') }); - } - }; - let options: fs.CopyOptions = { - "progressListener": progressListener - }; - // 进行拷贝 - fs.copy(from, to, options).then(() => { - isCopying = false; - AppStorage.setOrCreate('isCopying', false); - Logger.info(TAG, "Succeeded in copying. "); - }).catch((err: BusinessError) => { - isCopying = false; - AppStorage.setOrCreate('isCopying', false); - Logger.info(TAG, `Failed to copy. Code: ${err.code}, message: ${err.message}`); - DataObject.clear(); - return prompt.showToast({ message: $r('app.string.label_copyfailed') }); - }) - } catch (err) { - Logger.error(TAG, `Failed to getData. Code: ${err.code}, message: ${err.message}`); - } - } -} - -export default new FsManager(); +/* + * Copyright (c) 2023-2025 Shenzhen Kaihong Digital Industry Development 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 common from '@ohos.app.ability.common'; +import fs from '@ohos.file.fs'; +import fileuri from '@ohos.file.fileuri'; +import Logger from '../../../../../Library/src/main/ets/utils/Logger'; +import prompt from '@ohos.promptAction'; +import DataObject from './DataObject'; +import { BusinessError } from '@ohos.base'; +import { FileStructure, FileType } from '@ohos/feature-file-manager/src/main/ets/mock/local/FileData'; + +const TAG: string = 'FsManager'; +const BASE_PATH = "/data/storage/el2/base/haps/entry/files"; +let filesDir1 = BASE_PATH + '/test1'; +let filesDir2 = BASE_PATH + '/test2'; +let precastFiles: string[] = [ + "file1.txt", + "file2.txt", + "file3.txt", +]; + +let isCopying: boolean = false; +const fileCopy: string = '-副本'; + +class FsManager { + initFiles(): void { + try { + let res = fs.accessSync(filesDir1); + if (res) { + Logger.info(TAG, `file path: ${filesDir1} exists`); + } else { + Logger.info(TAG, `file path: ${filesDir1} not exists`); + fs.mkdirSync(filesDir1); + } + } catch (error) { + let err: BusinessError = error as BusinessError; + Logger.error(TAG, "accessSync failed with error message: " + err.message + ", error code: " + err.code); + } + try { + let res = fs.accessSync(filesDir2); + if (res) { + Logger.info(TAG, `file path: ${filesDir2} exists`); + } else { + Logger.info(TAG, `file path: ${filesDir2} not exists`); + fs.mkdirSync(filesDir2); + } + } catch (error) { + let err: BusinessError = error as BusinessError; + Logger.error(TAG, "accessSync failed with error message: " + err.message + ", error code: " + err.code); + } + + for (let i = 0; i < precastFiles.length; i++) { + let fileName = filesDir1 + "/" + precastFiles[i]; + Logger.info(TAG, `The file name: ${fileName}`); + try { + let res = fs.accessSync(fileName); + if (res) { + Logger.info(TAG, `file: ${fileName} exists!.`); + } else { + Logger.info(TAG, `file: ${fileName} not exists, will create it!.`); + let file = fs.openSync(fileName, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + fs.writeSync(file.fd, 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1' + + 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test' + + 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test' + + 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test' + + 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test' + + 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test'); + fs.closeSync(file); + } + } catch (error) { + let err: BusinessError = error as BusinessError; + Logger.error(TAG, "accessSync failed with error message: " + err.message + ", error code: " + err.code); + } + } + + let fileName = filesDir2 + "/" + "file4.txt"; + try { + let res = fs.accessSync(fileName); + if (res) { + Logger.info(TAG, `file: ${fileName} exists!.`); + } else { + Logger.info(TAG, `file: ${fileName} not exists, will create it!.`); + let file = fs.openSync(fileName, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + fs.writeSync(file.fd, 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4' + + 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4' + + 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4' + + 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4' + + 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4' + + 'test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4'); + fs.closeSync(file); + } + } catch (error) { + let err: BusinessError = error as BusinessError; + Logger.error(TAG, "accessSync failed with error message: " + err.message + ", error code: " + err.code); + } + } + + listFiles(dir: string): Array { + let files: string[] = []; + let context = getContext(this) as common.UIAbilityContext; + let fileDir = (dir == 'files' ? context.filesDir : (dir == 'temp' ? context.tempDir : context.cacheDir)); + Logger.info(TAG, `listFiles fileDir =${fileDir}`); + try { + files = fs.listFileSync(fileDir); + Logger.info(TAG, `listFiles listFileSync =${JSON.stringify(files)}`); + } catch (err) { + Logger.info(TAG, `listFiles err =${JSON.stringify(err)}`); + } + return files; + } + + copyFilesToDistributedDir(deviceId: string, needMoveFiles: Array, disPathInSandbox: string) { + let distributedUri0 = fileuri.getUriFromPath(disPathInSandbox); + let localFileUriList: Array = []; + let disFileUriList: Array = []; + let disFileList: Array = []; + let distributedUri = ''; + needMoveFiles.forEach((file: FileType) => { + Logger.info(TAG, `in copyToDistributedDir--file type : ${file.type}`); + //用于粘贴完后的clear动作中 + let disFilePath = disPathInSandbox + "/" + file.fileName; + //type: 1 directory,type 2 file + let localSrcUri = fileuri.getUriFromPath(file.filePath); + //如果是文件夹 + if (file.type === 1) { + distributedUri = distributedUri0 + "/" + file.fileName; + this.innerCopyFilesToDistributedDir(localSrcUri, distributedUri0); + } else if (file.type === 2) { //处理Uri,如果是文件类型,需另外处理,前缀增加"file+",用分布式对象进行传输 + const fileName = localSrcUri.split('/').pop(); + distributedUri = distributedUri0 + "/" + fileName; + this.innerCopyFilesToDistributedDir(localSrcUri, distributedUri); + localSrcUri = "file+" + localSrcUri; + distributedUri = "file+" + distributedUri; + } else { + Logger.error(TAG, `this is not file or directory`); + } + // to update DataObject + localFileUriList.push(localSrcUri); + disFileUriList.push(localSrcUri); + disFileList.push(disFilePath); + }) + DataObject.update(deviceId, localFileUriList, disFileUriList, disFileList); + } + + //复制到剪切板,不弹进度条 + innerCopyFilesToDistributedDir(from: string, to: string) { + Logger.info(TAG, `copyToDistributedDir--from: ${from}`); + Logger.info(TAG, `copyToDistributedDir--to: ${to}`); + try { + // copy + let progressListener: fs.ProgressListener = (progress: fs.Progress) => { + Logger.info(TAG, "progressSize: " + progress.processedSize + ", totalSize: " + progress.totalSize); + }; + let options: fs.CopyOptions = { + "progressListener": progressListener + }; + // 进行拷贝 + fs.copy(from, to, options).then(() => { + Logger.info("Succeeded in copying. "); + }).catch((err: BusinessError) => { + Logger.info(`Failed to copy. Code: ${err.code}, message: ${err.message}`); + return prompt.showToast({ message: $r('app.string.label_copy2disfailed') }); + }) + } catch (error) { + let err: BusinessError = error as BusinessError; + Logger.error(TAG, `Failed to set paste data. Code: ${err.code}, message: ${err.message}`); + } + } + + pasteFromDistributedDir(deviceId: string, directoryPath: string, fileData: Array) { + let localDstUri = fileuri.getUriFromPath(directoryPath); + + if (DataObject.distributedObject!["disFileUriList"].length === 0) { + return prompt.showToast({ message: $r('app.string.label_nodata') }); + } + //本地拷贝:文件需进行重命名操作 + if (deviceId == DataObject.distributedObject!["from"]) { + let localFileArray: Array = DataObject.distributedObject!["localFileUriList"]; + let newFileName: string = ''; + localFileArray.forEach(item => { + //判断uri前缀是否有“file+”,如果是文件类型,去掉“file+”前缀,在localDstUri后面加上文件名称 + if (item.includes("file+")) { + item = item.substring(5, item.length); + let fileName: string | undefined = item.split('/').pop(); + if (fileName) { + newFileName = decodeURIComponent(fileName); + } else { + return; + } + //判断本地是否有同名文件,有则重命名 + fileData.forEach(file => { + //有同名文件 + if (decodeURIComponent(file.name).includes(newFileName)) { + //extension 文件后缀 + let extension: string = newFileName.slice((newFileName.lastIndexOf(".") - 1 >>> 0) + 2); + if (extension) { + let fileParts = newFileName.split('.'); + newFileName = fileParts[0] + fileCopy + '.' + fileParts[1]; + } else { + newFileName = newFileName + fileCopy; + } + } + }) + } + this.innerPasteFromDistributedDir(item, localDstUri + newFileName); + }) + } else { //跨设备拷贝 + let disFileUriArray: Array = DataObject.distributedObject!["disFileUriList"]; + disFileUriArray.forEach(item => { + if (item.includes("file+")) { + item = item.substring(5, item.length); + let fileName: string | undefined = item.split('/').pop(); + let newFileName: string = ''; + if (fileName) { + newFileName = decodeURIComponent(fileName); + //判断是否有同名文件,有则重命名 + fileData.forEach(file => { + //有同名文件 + if (decodeURIComponent(file.name).includes(newFileName)) { + //extension 文件后缀 + let extension: string = newFileName.slice((newFileName.lastIndexOf(".") - 1 >>> 0) + 2); + if (extension) { + let fileParts = newFileName.split('.'); + newFileName = fileParts[0] + fileCopy + '.' + fileParts[1]; + } else { + newFileName = newFileName + fileCopy; + } + } + }) + } else { + return; + } + this.innerPasteFromDistributedDir(item, localDstUri + newFileName); + } else { + this.innerPasteFromDistributedDir(item, localDstUri); + } + }) + } + } + + //粘贴,弹进度条 + innerPasteFromDistributedDir(from: string, to: string) { + Logger.info(TAG, `innerPasteFromDistributedDir--from: ${from}`); + Logger.info(TAG, `innerPasteFromDistributedDir--to: ${to}`); + try { + // 定义拷贝回调 + let totalProgress: number = 0; + let totalCopySize: number = 0; + let copiedSize: number = 0; + let lastCopiedSize: number = 0; + let firstCopy = true; + let progressListener: fs.ProgressListener = (progress: fs.Progress) => { + Logger.info(TAG, "progressSize: " + progress.processedSize + ", totalSize: " + progress.totalSize); + //第一次进入回调 + if (firstCopy === true) { + Logger.info(TAG, "firstCopy"); + totalCopySize += progress.totalSize; + copiedSize += progress.processedSize; + lastCopiedSize = progress.processedSize; + firstCopy = false; + } else { + copiedSize -= lastCopiedSize; + copiedSize += progress.processedSize; + lastCopiedSize = progress.processedSize; + } + + totalProgress = Number(((copiedSize / totalCopySize) * 100).toFixed(0)); + AppStorage.setOrCreate('progress', totalProgress); + Logger.info(TAG, "totalCopySize: " + totalCopySize + ", copiedSize: " + copiedSize); + if (totalCopySize != copiedSize) { + isCopying = true; + AppStorage.setOrCreate('isCopying', true); + } else { + Logger.info(TAG, "totalCopySize == copiedSize,Successfully coppied"); + isCopying = false; + AppStorage.setOrCreate('isCopying', false); + AppStorage.setOrCreate('flashPage',!AppStorage.get('flashPage')); + DataObject.clear(); + return prompt.showToast({ message: $r('app.string.label_dirupdate') }); + } + }; + let options: fs.CopyOptions = { + "progressListener": progressListener + }; + // 进行拷贝 + fs.copy(from, to, options).then(() => { + isCopying = false; + AppStorage.setOrCreate('isCopying', false); + Logger.info(TAG, "Succeeded in copying. "); + }).catch((err: BusinessError) => { + isCopying = false; + AppStorage.setOrCreate('isCopying', false); + Logger.info(TAG, `Failed to copy. Code: ${err.code}, message: ${err.message}`); + DataObject.clear(); + return prompt.showToast({ message: $r('app.string.label_copyfailed') }); + }) + } catch (err) { + Logger.error(TAG, `Failed to getData. Code: ${err.code}, message: ${err.message}`); + } + } +} + +export default new FsManager(); diff --git a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/resources/rawfile/arkdata/utd/utd-adt.json b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/resources/rawfile/arkdata/utd/utd-adt.json index b4486d5c86..1e7e1fda4d 100644 --- a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/resources/rawfile/arkdata/utd/utd-adt.json +++ b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/entry/src/main/resources/rawfile/arkdata/utd/utd-adt.json @@ -1,27 +1,27 @@ -{ - "UniformDataTypeDeclarations": [{ - "TypeId": "com.example.UTDType.image", - "BelongingToTypes": ["general.image"], - "FilenameExtensions": [".myImage", ".khImage"], - "MIMETypes": ["application/my-document", "application/my-doc"], - "Description": "My Image.", - "ReferenceURL": "" - }, - { - "TypeId": "com.example.UTDType.audio", - "BelongingToTypes": ["general.audio"], - "FilenameExtensions": [".myAudio", ".khAudio"], - "MIMETypes": ["application/my-document", "application/my-doc"], - "Description": "My audio.", - "ReferenceURL": "" - }, - { - "TypeId": "com.example.UTDType.video", - "BelongingToTypes": ["general.video"], - "FilenameExtensions": [".myVideo", ".khVideo"], - "MIMETypes": ["application/my-document", "application/my-doc"], - "Description": "My video.", - "ReferenceURL": "" - } - ] +{ + "UniformDataTypeDeclarations": [{ + "TypeId": "com.example.UTDType.image", + "BelongingToTypes": ["general.image"], + "FilenameExtensions": [".myImage", ".khImage"], + "MIMETypes": ["application/my-document", "application/my-doc"], + "Description": "My Image.", + "ReferenceURL": "" + }, + { + "TypeId": "com.example.UTDType.audio", + "BelongingToTypes": ["general.audio"], + "FilenameExtensions": [".myAudio", ".khAudio"], + "MIMETypes": ["application/my-document", "application/my-doc"], + "Description": "My audio.", + "ReferenceURL": "" + }, + { + "TypeId": "com.example.UTDType.video", + "BelongingToTypes": ["general.video"], + "FilenameExtensions": [".myVideo", ".khVideo"], + "MIMETypes": ["application/my-document", "application/my-doc"], + "Description": "My video.", + "ReferenceURL": "" + } + ] } \ No newline at end of file diff --git a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/hvigor/hvigor-config.json5 b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/hvigor/hvigor-config.json5 index 2e97c54288..a2eb20c67c 100644 --- a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/hvigor/hvigor-config.json5 +++ b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.1.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.1.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.1.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.1.2" + } } \ No newline at end of file diff --git a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/oh-package.json5 b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/oh-package.json5 index 3762fe6b2a..368c840c89 100644 --- a/code/SuperFeature/DistributedAppDev/DistributedFilemanager/oh-package.json5 +++ b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "myfile", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "myfile", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SuperFeature/DistributedAppDev/DistributedRdb/entry/src/main/ets/model/GlobalContext.ts b/code/SuperFeature/DistributedAppDev/DistributedRdb/entry/src/main/ets/model/GlobalContext.ts index 91a43d675a..7f505311b3 100644 --- a/code/SuperFeature/DistributedAppDev/DistributedRdb/entry/src/main/ets/model/GlobalContext.ts +++ b/code/SuperFeature/DistributedAppDev/DistributedRdb/entry/src/main/ets/model/GlobalContext.ts @@ -1,36 +1,36 @@ -// 构造单例对象 -/* - * Copyright (c) 2023 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 class GlobalContext { - private constructor() {} - private static instance: GlobalContext; - private _objects = new Map(); - - public static getContext(): GlobalContext { - if (!GlobalContext.instance) { - GlobalContext.instance = new GlobalContext(); - } - return GlobalContext.instance; - } - - getObject(value: string): Object | undefined { - return this._objects.get(value); - } - - setObject(key: string, objectClass: Object): void { - this._objects.set(key, objectClass); - } -} +// 构造单例对象 +/* + * Copyright (c) 2023 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 class GlobalContext { + private constructor() {} + private static instance: GlobalContext; + private _objects = new Map(); + + public static getContext(): GlobalContext { + if (!GlobalContext.instance) { + GlobalContext.instance = new GlobalContext(); + } + return GlobalContext.instance; + } + + getObject(value: string): Object | undefined { + return this._objects.get(value); + } + + setObject(key: string, objectClass: Object): void { + this._objects.set(key, objectClass); + } +} diff --git a/code/SuperFeature/MultiDeviceAppDev/AdaptiveCapabilities/entry/src/main/ets/pages/typicalScene/multiScene/data/applications/Applications.ets b/code/SuperFeature/MultiDeviceAppDev/AdaptiveCapabilities/entry/src/main/ets/pages/typicalScene/multiScene/data/applications/Applications.ets index 20b11b8c03..1739c4e980 100644 --- a/code/SuperFeature/MultiDeviceAppDev/AdaptiveCapabilities/entry/src/main/ets/pages/typicalScene/multiScene/data/applications/Applications.ets +++ b/code/SuperFeature/MultiDeviceAppDev/AdaptiveCapabilities/entry/src/main/ets/pages/typicalScene/multiScene/data/applications/Applications.ets @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 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 ApplicationsData: Resource [] = [ - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application'), - $r('app.string.multiScene_application') +/* + * Copyright (c) 2023 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 ApplicationsData: Resource [] = [ + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application'), + $r('app.string.multiScene_application') ] \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/AppScope/app.json5 b/code/SystemFeature/Ability/AbilityFeatureSystem/AppScope/app.json5 index c295ae892a..39d910e4c5 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/AppScope/app.json5 +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.abilityFeatureSystem", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.abilityFeatureSystem", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/AppScope/resources/base/element/string.json b/code/SystemFeature/Ability/AbilityFeatureSystem/AppScope/resources/base/element/string.json index 329e7ac73e..84d99212a1 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AbilityFeatureSystem" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AbilityFeatureSystem" + } + ] +} diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/README_zh.md b/code/SystemFeature/Ability/AbilityFeatureSystem/README_zh.md index c2c342e7d1..c5f6b671cf 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/README_zh.md +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/README_zh.md @@ -1,113 +1,113 @@ -# 基础能力增强 - -### 介绍 - -本示例使用 [ohos.app.ability.appManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-appManager-sys.md), [UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext-sys.md) , [UIExtensionContentSession](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession-sys.md) 等接口实现了以下功能: - -1. 提供查询单个应用是否正在运行接口; - -2. 新增系统接口请求创建模系统或模应用的UIExtension; - -3. UIExtension支持同步返回数据的能力; - -4. UIExtension提供StartAsCaller接口。 - -### 效果预览 - -| 主页面 | 弹出状态Toast | 同步数据页面 | UIExtension启动页 | -|:------------------------------------------------:|:-----------------------------------------------------:|:----------------------------------------------------:|:------------------------------------------------------:| -| | | | | - -使用说明 - -1.应用查询单个应用是否正在运行的能力 - -点击'查询应用状态'的ListItem,弹出Toast提示'当前应用运行中' - -2.UIExtension创建模系统或模应用 - -点击'创建模系统'的ListItem,弹出UIExtension的页面弹窗 - -3.UIExtension支持同步返回数据的能力 - -点击'同步发送数据'的ListItem,进入到新页面再次点击'同步发送数据'的ListItem,UIAbility部分弹出Toast提示'HomeAbility -onReceive data from UIExtensionAbility',UIExtensionAbility 部分弹出Toast提示'UIExtensionAbility onReceive data from -HomeAbility' - -4.UIExtension提供启动AbilityAsCaller的能力 - -点击'启动AbilityAsCaller'的ListItem,应用启动NewAbility - -5.UIExtension提供startAbilityAsCaller的能力 - -点击启动'启动UIExtensionAbility'的ListItem,进入到新页面,在新页面点击'启动AbilityAsCaller'的ListItem,应用启动NewAbility - -### 工程目录 - -``` -entry/src/main/ets/ -|---entryability -| |---EntryAbility.ets // 首页的Ability -|---pages -| |---Index.ets // 首页 -| |---Ext.ets // UIExtensionAbility的展示页 -| |---NewExt.ets // 被启动的UIExtensionAbility的页面 -| |---New.ets // 被启动UIAbility的展示页 -| |---Transit.ets // UIExtensionComponent加载NewUIExtAbility的页面 -| |---SendSync.ets // UIExtensionComponent加载SendSyncExtAbility的页面 -| |---SendSyncExt.ets // 同步数据UIExtensionAbility的展示页 -|---uiextability -| |---UIExtAbility.ets // UIExtensionAbility(用于验证新接口使用) -|---sendsyncextability -| |---SendSyncExtAbility.ets // UIExtensionAbility(用于验证新接口使用) -|---newuiextability -| |---NewUIExtAbility.ets // UIExtensionAbility(用于验证新接口使用) -|---newability -| |---NewAbility.ets // 被启动的UIAbility(验证新接口启动使用) -|---utils // 工具 -| |---Logger.ets // 日志工具 -``` - -### 具体实现 - -- 应用查询单个应用是否正在运行的能力,通过appManager调用isApplicationRunning(bundleName: string, callback: - AsyncCallback): void方法查询应用状态, 源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) -- UIExtension创建模系统或模应用,通过UIAbilityContext调用requestModalUIExtension(pickerWant: Want, callback: - AsyncCallback): void方法拉起UIExtensionAbility, 源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) -- UIExtension支持同步返回数据的能力,通过UIExtensionProxy调用sendSync(data: { [key: string]: Object }): { [key: string]: - Object }接口实现,源码参考:[SendSync.ets](entry/src/main/ets/pages/SendSync.ets) -- UIExtension提供startAbilityAsCaller的能力,通过UIExtensionContentSession调用startAbilityAsCaller(want: Want, callback: - AsyncCallback): void接口实现,源码参考:[Ext.ets](entry/src/main/ets/pages/Ext.ets) - -### 相关权限 - -[ohos.permission.GET_RUNNING_INFO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_running_info) - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568。 - -2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.5.1; - -3.本示例涉及使用系统接口:appManager.isApplicationRunning ,UIAbilityContext.requestModalUIExtension, -UIAbilityContext.startAbilityAsCaller,UIExtensionContentSession.startAbilityAsCaller,UIExtensionProxy.sendSync -需要手动替换Full SDK才能编译通过; - -4.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行; - -5.本示例涉及[ohos.permission.GET_RUNNING_INFO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_running_info)权限为 system_basic级别,需要配置高权限签名; - -### 下载 - -```shell -git init -git config core.sparsecheckout true -echo code/SystemFeature/Ability/AbilityFeatureSystem/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` - +# 基础能力增强 + +### 介绍 + +本示例使用 [ohos.app.ability.appManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-appManager-sys.md), [UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext-sys.md) , [UIExtensionContentSession](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession-sys.md) 等接口实现了以下功能: + +1. 提供查询单个应用是否正在运行接口; + +2. 新增系统接口请求创建模系统或模应用的UIExtension; + +3. UIExtension支持同步返回数据的能力; + +4. UIExtension提供StartAsCaller接口。 + +### 效果预览 + +| 主页面 | 弹出状态Toast | 同步数据页面 | UIExtension启动页 | +|:------------------------------------------------:|:-----------------------------------------------------:|:----------------------------------------------------:|:------------------------------------------------------:| +| | | | | + +使用说明 + +1.应用查询单个应用是否正在运行的能力 + +点击'查询应用状态'的ListItem,弹出Toast提示'当前应用运行中' + +2.UIExtension创建模系统或模应用 + +点击'创建模系统'的ListItem,弹出UIExtension的页面弹窗 + +3.UIExtension支持同步返回数据的能力 + +点击'同步发送数据'的ListItem,进入到新页面再次点击'同步发送数据'的ListItem,UIAbility部分弹出Toast提示'HomeAbility +onReceive data from UIExtensionAbility',UIExtensionAbility 部分弹出Toast提示'UIExtensionAbility onReceive data from +HomeAbility' + +4.UIExtension提供启动AbilityAsCaller的能力 + +点击'启动AbilityAsCaller'的ListItem,应用启动NewAbility + +5.UIExtension提供startAbilityAsCaller的能力 + +点击启动'启动UIExtensionAbility'的ListItem,进入到新页面,在新页面点击'启动AbilityAsCaller'的ListItem,应用启动NewAbility + +### 工程目录 + +``` +entry/src/main/ets/ +|---entryability +| |---EntryAbility.ets // 首页的Ability +|---pages +| |---Index.ets // 首页 +| |---Ext.ets // UIExtensionAbility的展示页 +| |---NewExt.ets // 被启动的UIExtensionAbility的页面 +| |---New.ets // 被启动UIAbility的展示页 +| |---Transit.ets // UIExtensionComponent加载NewUIExtAbility的页面 +| |---SendSync.ets // UIExtensionComponent加载SendSyncExtAbility的页面 +| |---SendSyncExt.ets // 同步数据UIExtensionAbility的展示页 +|---uiextability +| |---UIExtAbility.ets // UIExtensionAbility(用于验证新接口使用) +|---sendsyncextability +| |---SendSyncExtAbility.ets // UIExtensionAbility(用于验证新接口使用) +|---newuiextability +| |---NewUIExtAbility.ets // UIExtensionAbility(用于验证新接口使用) +|---newability +| |---NewAbility.ets // 被启动的UIAbility(验证新接口启动使用) +|---utils // 工具 +| |---Logger.ets // 日志工具 +``` + +### 具体实现 + +- 应用查询单个应用是否正在运行的能力,通过appManager调用isApplicationRunning(bundleName: string, callback: + AsyncCallback): void方法查询应用状态, 源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) +- UIExtension创建模系统或模应用,通过UIAbilityContext调用requestModalUIExtension(pickerWant: Want, callback: + AsyncCallback): void方法拉起UIExtensionAbility, 源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) +- UIExtension支持同步返回数据的能力,通过UIExtensionProxy调用sendSync(data: { [key: string]: Object }): { [key: string]: + Object }接口实现,源码参考:[SendSync.ets](entry/src/main/ets/pages/SendSync.ets) +- UIExtension提供startAbilityAsCaller的能力,通过UIExtensionContentSession调用startAbilityAsCaller(want: Want, callback: + AsyncCallback): void接口实现,源码参考:[Ext.ets](entry/src/main/ets/pages/Ext.ets) + +### 相关权限 + +[ohos.permission.GET_RUNNING_INFO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_running_info) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568。 + +2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.5.1; + +3.本示例涉及使用系统接口:appManager.isApplicationRunning ,UIAbilityContext.requestModalUIExtension, +UIAbilityContext.startAbilityAsCaller,UIExtensionContentSession.startAbilityAsCaller,UIExtensionProxy.sendSync +需要手动替换Full SDK才能编译通过; + +4.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行; + +5.本示例涉及[ohos.permission.GET_RUNNING_INFO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_running_info)权限为 system_basic级别,需要配置高权限签名; + +### 下载 + +```shell +git init +git config core.sparsecheckout true +echo code/SystemFeature/Ability/AbilityFeatureSystem/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` + diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/build-profile.json5 b/code/SystemFeature/Ability/AbilityFeatureSystem/build-profile.json5 index 6e4824ee32..51d43b29fe 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/build-profile.json5 +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/build-profile.json5 @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 11, + "compatibleSdkVersion": 11, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/build-profile.json5 b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/build-profile.json5 index 0c8525dfdd..910cc991f5 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/build-profile.json5 +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/oh-package.json5 b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/oh-package.json5 index 4be95c59ce..3fbe67bbf8 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/oh-package.json5 +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/entryability/EntryAbility.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/entryability/EntryAbility.ets index f640336e76..d759f4f0a6 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import window from '@ohos.window'; -import Want from '@ohos.app.ability.Want'; -import { BusinessError } from '@ohos.base'; -import { logger } from '../util/Logger'; - -export default class EntryAbility extends UIAbility { - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - windowStage.loadContent('pages/Index', (err: BusinessError) => { - }); - windowStage.getMainWindow((err, windowClass) => { - if (err.code) { - return; - } - windowClass.setWindowLayoutFullScreen(true); - }) - logger.info(`EntryAbility onWindowStageCreate`); - } - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - AppStorage.setOrCreate('want', want); - AppStorage.setOrCreate('launchParam', launchParam); - logger.info(`EntryAbility onCreate ${want.bundleName},${launchParam.launchReason}`); - } - - onDestroy() { - logger.info(`EntryAbility onDestroy`); - } - - onWindowStageDestroy() { - logger.info(`EntryAbility onWindowStageDestroy`); - // Main window is destroyed, release UI related resources - } - - onForeground() { - logger.info(`EntryAbility onForeground`); - // Ability has brought to foreground - } - - onBackground() { - logger.info(`EntryAbility onBackground`); - // Ability has back to background - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import { BusinessError } from '@ohos.base'; +import { logger } from '../util/Logger'; + +export default class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + windowStage.loadContent('pages/Index', (err: BusinessError) => { + }); + windowStage.getMainWindow((err, windowClass) => { + if (err.code) { + return; + } + windowClass.setWindowLayoutFullScreen(true); + }) + logger.info(`EntryAbility onWindowStageCreate`); + } + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + AppStorage.setOrCreate('want', want); + AppStorage.setOrCreate('launchParam', launchParam); + logger.info(`EntryAbility onCreate ${want.bundleName},${launchParam.launchReason}`); + } + + onDestroy() { + logger.info(`EntryAbility onDestroy`); + } + + onWindowStageDestroy() { + logger.info(`EntryAbility onWindowStageDestroy`); + // Main window is destroyed, release UI related resources + } + + onForeground() { + logger.info(`EntryAbility onForeground`); + // Ability has brought to foreground + } + + onBackground() { + logger.info(`EntryAbility onBackground`); + // Ability has back to background + } +} diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/newability/NewAbility.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/newability/NewAbility.ets index b9acfd827c..f74c81a86d 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/newability/NewAbility.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/newability/NewAbility.ets @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import window from '@ohos.window'; -import Want from '@ohos.app.ability.Want'; -import { logger } from '../util/Logger'; - -export default class NewAbility extends UIAbility { - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - windowStage.loadContent('pages/New', () => { - }); - windowStage.getMainWindow((err, windowClass) => { - if (err.code) { - return; - } - windowClass.setWindowLayoutFullScreen(true); - }) - } - - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - AppStorage.setOrCreate('want', want); - AppStorage.setOrCreate('launchParam', launchParam); - logger.info(`NewAbility onCreate ${want.bundleName},${launchParam.launchReason}`); - } - - onDestroy() { - logger.info(`NewAbility onDestroy`); - } - - onWindowStageDestroy() { - logger.info(`NewAbility onWindowStageDestroy`); - // Main window is destroyed, release UI related resources - } - - onForeground() { - logger.info(`NewAbility onForeground`); - // Ability has brought to foreground - } - - onBackground() { - logger.info(`NewAbility onBackground`); - // Ability has back to background - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import { logger } from '../util/Logger'; + +export default class NewAbility extends UIAbility { + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + windowStage.loadContent('pages/New', () => { + }); + windowStage.getMainWindow((err, windowClass) => { + if (err.code) { + return; + } + windowClass.setWindowLayoutFullScreen(true); + }) + } + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + AppStorage.setOrCreate('want', want); + AppStorage.setOrCreate('launchParam', launchParam); + logger.info(`NewAbility onCreate ${want.bundleName},${launchParam.launchReason}`); + } + + onDestroy() { + logger.info(`NewAbility onDestroy`); + } + + onWindowStageDestroy() { + logger.info(`NewAbility onWindowStageDestroy`); + // Main window is destroyed, release UI related resources + } + + onForeground() { + logger.info(`NewAbility onForeground`); + // Ability has brought to foreground + } + + onBackground() { + logger.info(`NewAbility onBackground`); + // Ability has back to background + } +} diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/newuiextability/NewUIExtAbility.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/newuiextability/NewUIExtAbility.ets index eff814ee1b..2277e8a911 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/newuiextability/NewUIExtAbility.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/newuiextability/NewUIExtAbility.ets @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 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 UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; -import Want from '@ohos.app.ability.Want'; -import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import { logger } from '../util/Logger'; - -export default class NewUIExtAbility extends UIExtensionAbility { - onCreate() { - logger.info(`NewUIExtAbility onCreate`); - } - - onDestroy() { - logger.info(`NewUIExtAbility onDestroy`); - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - let param: Record = { - 'session': session, - 'want': want - }; - - let storage: LocalStorage = new LocalStorage(param); - session.loadContent('pages/NewExt', storage); - } - - onForeground() { - logger.info(`NewUIExtAbility onForeground`); - // Ability has brought to foreground - } - - onBackground() { - logger.info(`NewUIExtAbility onBackground`); - // Ability has back to background - } -} - - +/* + * Copyright (c) 2023 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 UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; +import Want from '@ohos.app.ability.Want'; +import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import { logger } from '../util/Logger'; + +export default class NewUIExtAbility extends UIExtensionAbility { + onCreate() { + logger.info(`NewUIExtAbility onCreate`); + } + + onDestroy() { + logger.info(`NewUIExtAbility onDestroy`); + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + let param: Record = { + 'session': session, + 'want': want + }; + + let storage: LocalStorage = new LocalStorage(param); + session.loadContent('pages/NewExt', storage); + } + + onForeground() { + logger.info(`NewUIExtAbility onForeground`); + // Ability has brought to foreground + } + + onBackground() { + logger.info(`NewUIExtAbility onBackground`); + // Ability has back to background + } +} + + diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/Ext.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/Ext.ets index f7383138a5..829ddc493f 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/Ext.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/Ext.ets @@ -1,117 +1,117 @@ -/* - * Copyright (c) 2023 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 UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import Want from '@ohos.app.ability.Want'; -import { logger } from '../util/Logger'; - -export interface ListItemModel { - text: Resource, - callback?: () => void -} - -const TAG: string = 'UIExtensionAbility'; -let storage: LocalStorage = LocalStorage.getShared(); - -@Entry(storage) -@Component -struct Ext { - private session: (UIExtensionContentSession | undefined) = storage.get('session'); - private want: (Want | undefined) = storage.get('want'); - @State list: ListItemModel[] = [ - { - text: $r('app.string.extStartAbilityAsCaller'), - callback: () => { - if (this.session === undefined) { - logger.error(`${TAG} session undefined`); - return; - } - if (this.want === undefined) { - logger.error(`${TAG} want undefined`); - return; - } - let localWant: Want = this.want; - localWant.bundleName = 'com.samples.abilityFeatureSystem'; - localWant.moduleName = 'entry'; - localWant.abilityName = 'NewAbility'; - // 使用启动方的Caller身份信息启动新Ability - this.session.startAbilityAsCaller(localWant, (err, data) => { - logger.info(`${TAG} startAbilityAsCaller error:${JSON.stringify(err)} data:${JSON.stringify(data)}`); - }) - }, - } - ]; - - build() { - Column() { - Column() { - Row() { - Image($r('app.media.ic_back')) - .size({ width: 20, height: 18 }) - .margin({ right: 18 }) - .onClick(() => { - if (this.session === undefined) { - return; - } - this.session.sendData({ back: true }); - }) - Text($r('app.string.UIExtAbility_label')) - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.height(56) - .padding({ left: 24, right: 24 }) - .width('100%') - } - - Column() { - List({ space: 0, initialIndex: 0 }) { - ForEach(this.list, (item: ListItemModel, index: number) => { - ListItemGroup() { - ListItem() { - Column() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { - Text(item.text) { - }.fontSize(16) - .fontColor($r('sys.color.ohos_id_color_toolbar_sub_bg_dark')) - .height(48) - }.width('100%') - } - } - .align(Alignment.Start) - .onClick(item.callback) - .width('100%') - .padding({ left: 12, right: 12 }) - } - .padding({ top: 4, bottom: 4 }) - .borderRadius(24) - .width('100%') - .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) - .margin({ top: 10, bottom: 10 }) - }) - } - .scrollBar(BarState.Off) - .listDirection(Axis.Vertical) // 排列方向 - .friction(0.6) - .width('100%') - .height('100%') - .padding({ left: 12, right: 12 }) - .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring - }.width('100%') - }.width('100%') - .height('100%') - .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) - .padding({ top: 36, bottom: 106 }) - } +/* + * Copyright (c) 2023 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 UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import Want from '@ohos.app.ability.Want'; +import { logger } from '../util/Logger'; + +export interface ListItemModel { + text: Resource, + callback?: () => void +} + +const TAG: string = 'UIExtensionAbility'; +let storage: LocalStorage = LocalStorage.getShared(); + +@Entry(storage) +@Component +struct Ext { + private session: (UIExtensionContentSession | undefined) = storage.get('session'); + private want: (Want | undefined) = storage.get('want'); + @State list: ListItemModel[] = [ + { + text: $r('app.string.extStartAbilityAsCaller'), + callback: () => { + if (this.session === undefined) { + logger.error(`${TAG} session undefined`); + return; + } + if (this.want === undefined) { + logger.error(`${TAG} want undefined`); + return; + } + let localWant: Want = this.want; + localWant.bundleName = 'com.samples.abilityFeatureSystem'; + localWant.moduleName = 'entry'; + localWant.abilityName = 'NewAbility'; + // 使用启动方的Caller身份信息启动新Ability + this.session.startAbilityAsCaller(localWant, (err, data) => { + logger.info(`${TAG} startAbilityAsCaller error:${JSON.stringify(err)} data:${JSON.stringify(data)}`); + }) + }, + } + ]; + + build() { + Column() { + Column() { + Row() { + Image($r('app.media.ic_back')) + .size({ width: 20, height: 18 }) + .margin({ right: 18 }) + .onClick(() => { + if (this.session === undefined) { + return; + } + this.session.sendData({ back: true }); + }) + Text($r('app.string.UIExtAbility_label')) + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.height(56) + .padding({ left: 24, right: 24 }) + .width('100%') + } + + Column() { + List({ space: 0, initialIndex: 0 }) { + ForEach(this.list, (item: ListItemModel, index: number) => { + ListItemGroup() { + ListItem() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text(item.text) { + }.fontSize(16) + .fontColor($r('sys.color.ohos_id_color_toolbar_sub_bg_dark')) + .height(48) + }.width('100%') + } + } + .align(Alignment.Start) + .onClick(item.callback) + .width('100%') + .padding({ left: 12, right: 12 }) + } + .padding({ top: 4, bottom: 4 }) + .borderRadius(24) + .width('100%') + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .margin({ top: 10, bottom: 10 }) + }) + } + .scrollBar(BarState.Off) + .listDirection(Axis.Vertical) // 排列方向 + .friction(0.6) + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + }.width('100%') + }.width('100%') + .height('100%') + .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) + .padding({ top: 36, bottom: 106 }) + } } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/New.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/New.ets index c9ca586a7d..9b6418792b 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/New.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/New.ets @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import { logger } from '../util/Logger'; - -const TAG: string = '[NewAbility]'; - -@Entry -@Component -struct New { - private context = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Image($r('app.media.ic_back')) - .size({ width: 20, height: 18 }) - .margin({ right: 18 }) - .onClick(() => { - this.context.terminateSelf((err, data) => { - logger.info(`${TAG} terminateSelf err:${JSON.stringify(err)},data:${JSON.stringify(data)}`); - }) - }) - Text($r('app.string.NewAbility_label')) - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.height(56) - .padding({ left: 26, right: 26 }) - .width('100%') - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { - Column() { - Image($r('app.media.pic_empty')).width('33%') - Text($r('app.string.empty')) - .fontSize(14) - } - }.width('100%') - .height('90%') - } - .width('100%') - .height('100%') - .padding({ top: 36, bottom: 106 }) - .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import { logger } from '../util/Logger'; + +const TAG: string = '[NewAbility]'; + +@Entry +@Component +struct New { + private context = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Image($r('app.media.ic_back')) + .size({ width: 20, height: 18 }) + .margin({ right: 18 }) + .onClick(() => { + this.context.terminateSelf((err, data) => { + logger.info(`${TAG} terminateSelf err:${JSON.stringify(err)},data:${JSON.stringify(data)}`); + }) + }) + Text($r('app.string.NewAbility_label')) + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.height(56) + .padding({ left: 26, right: 26 }) + .width('100%') + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { + Column() { + Image($r('app.media.pic_empty')).width('33%') + Text($r('app.string.empty')) + .fontSize(14) + } + }.width('100%') + .height('90%') + } + .width('100%') + .height('100%') + .padding({ top: 36, bottom: 106 }) + .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) + } } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/NewExt.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/NewExt.ets index c72b746107..3d199e898f 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/NewExt.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/NewExt.ets @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2023 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 UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import Want from '@ohos.app.ability.Want'; -import { logger } from '../util/Logger'; - -const TAG: string = 'UIExtensionAbility'; -let storage: LocalStorage = LocalStorage.getShared(); - -@Entry(storage) -@Component -struct NewExt { - private session: (UIExtensionContentSession | undefined) = storage.get('session'); - private want: (Want | undefined) = storage.get('want'); - - build() { - Column() { - Row() { - Image($r('app.media.ic_back')) - .size({ width: 20, height: 18 }) - .margin({ right: 18 }) - .onClick(() => { - if (this.session === undefined) { - return; - } - this.session.terminateSelf((err, data) => { - logger.info(`${TAG} terminateSelf err:${JSON.stringify(err)},data:${JSON.stringify(data)}`); - }) - }) - Text($r('app.string.NewUIExtAbility_label')) - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.height(56) - .padding({ left: 24, right: 24 }) - .width('100%') - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { - Column() { - Image($r('app.media.pic_empty')).width('33%') - Text($r('app.string.empty')) - .fontSize(14) - } - }.width('100%') - .height('90%') - } - .width('100%') - .height('100%') - .padding({ top: 36, bottom: 106 }) - .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) - } +/* + * Copyright (c) 2023 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 UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import Want from '@ohos.app.ability.Want'; +import { logger } from '../util/Logger'; + +const TAG: string = 'UIExtensionAbility'; +let storage: LocalStorage = LocalStorage.getShared(); + +@Entry(storage) +@Component +struct NewExt { + private session: (UIExtensionContentSession | undefined) = storage.get('session'); + private want: (Want | undefined) = storage.get('want'); + + build() { + Column() { + Row() { + Image($r('app.media.ic_back')) + .size({ width: 20, height: 18 }) + .margin({ right: 18 }) + .onClick(() => { + if (this.session === undefined) { + return; + } + this.session.terminateSelf((err, data) => { + logger.info(`${TAG} terminateSelf err:${JSON.stringify(err)},data:${JSON.stringify(data)}`); + }) + }) + Text($r('app.string.NewUIExtAbility_label')) + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.height(56) + .padding({ left: 24, right: 24 }) + .width('100%') + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) { + Column() { + Image($r('app.media.pic_empty')).width('33%') + Text($r('app.string.empty')) + .fontSize(14) + } + }.width('100%') + .height('90%') + } + .width('100%') + .height('100%') + .padding({ top: 36, bottom: 106 }) + .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) + } } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/SendSync.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/SendSync.ets index f16fe2a3da..d00a09aecf 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/SendSync.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/SendSync.ets @@ -1,138 +1,138 @@ -/* - * Copyright (c) 2023 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 prompt from '@ohos.promptAction'; -import router from '@ohos.router'; -import { logger } from '../util/Logger'; - -interface GroupModel { - title?: string; - list: ListItemModel[]; -} - -export interface ListItemModel { - text: Resource, - rType?: string, - callback?: () => void, -} - -const TAG: string = 'HomeAbility'; - -@Entry -@Component -struct SendSync { - private myProxy: (UIExtensionProxy | null) = null; - @State list: GroupModel[] = [ - { - title: '1', - list: [ - { - text: $r('app.string.sendSyncData'), - rType: '', - callback: () => { - if (this.myProxy === null) { - logger.error(`${TAG} myProxy null`); - return; - } - let params: Record = { 'key': `data from ${TAG}` }; - let result = this.myProxy.sendSync(params); - prompt.showToast({ message: (`${TAG} onReceive ${result['key']}`), duration: 3000, bottom: 150 }); - } - } - ] - }, - ] - - build() { - Column() { - Column() { - Row() { - Image($r('app.media.ic_back')) - .size({ width: 20, height: 18 }) - .margin({ right: 18 }) - .onClick(() => { - router.back({ - url: 'pages/Index' - }); - }) - Text($r('app.string.SendSyncUIExtAbility_label')) - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.height(56) - .padding({ left: 24, right: 24 }) - .width('100%') - } - - Column() { - List({ space: 0, initialIndex: 0 }) { - ForEach(this.list, (groupItem: GroupModel, groupIndex: number) => { - ListItemGroup() { - ForEach(groupItem.list, (item: ListItemModel, index: number) => { - ListItem() { - Column() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { - Text(item.text) - .fontSize(16) - .height(48) - .fontColor($r('sys.color.ohos_id_color_toolbar_sub_bg_dark')) - }.width('100%') - }.width('100%') - } - .id('sendSync') - .align(Alignment.Start) - .onClick(item.callback) - .width('100%') - .padding({ left: 12, right: 12 }) - }) - } - .padding({ top: 4, bottom: 4 }) - .borderRadius(24) - .width('100%') - .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) - .margin({ top: 10, bottom: 10 }) - }) - ListItemGroup() { - ListItem() { - UIExtensionComponent({ - bundleName: 'com.samples.abilityFeatureSystem', - abilityName: 'SendSyncUIExtAbility', - parameters: { - 'ability.want.params.uiExtensionType': 'sys/commonUI', - } - }).size({ width: '100%', height: '90%' }) - .onRemoteReady((pro: UIExtensionProxy) => { - logger.info(`${TAG} onRemoteReady:`); - this.myProxy = pro; - }) - } - } - .borderRadius(24) - .width('100%') - .margin({ top: 10, bottom: 10 }) - } - .scrollBar(BarState.Off) - .listDirection(Axis.Vertical) - .friction(0.6) - .edgeEffect(EdgeEffect.Spring) - .padding({ left: 12, right: 12 }) - .width('100%') - .height('100%') - }.width('100%') - }.width('100%') - .height('100%') - .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) - .padding({ top: 36, bottom: 106 }) - } +/* + * Copyright (c) 2023 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 prompt from '@ohos.promptAction'; +import router from '@ohos.router'; +import { logger } from '../util/Logger'; + +interface GroupModel { + title?: string; + list: ListItemModel[]; +} + +export interface ListItemModel { + text: Resource, + rType?: string, + callback?: () => void, +} + +const TAG: string = 'HomeAbility'; + +@Entry +@Component +struct SendSync { + private myProxy: (UIExtensionProxy | null) = null; + @State list: GroupModel[] = [ + { + title: '1', + list: [ + { + text: $r('app.string.sendSyncData'), + rType: '', + callback: () => { + if (this.myProxy === null) { + logger.error(`${TAG} myProxy null`); + return; + } + let params: Record = { 'key': `data from ${TAG}` }; + let result = this.myProxy.sendSync(params); + prompt.showToast({ message: (`${TAG} onReceive ${result['key']}`), duration: 3000, bottom: 150 }); + } + } + ] + }, + ] + + build() { + Column() { + Column() { + Row() { + Image($r('app.media.ic_back')) + .size({ width: 20, height: 18 }) + .margin({ right: 18 }) + .onClick(() => { + router.back({ + url: 'pages/Index' + }); + }) + Text($r('app.string.SendSyncUIExtAbility_label')) + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.height(56) + .padding({ left: 24, right: 24 }) + .width('100%') + } + + Column() { + List({ space: 0, initialIndex: 0 }) { + ForEach(this.list, (groupItem: GroupModel, groupIndex: number) => { + ListItemGroup() { + ForEach(groupItem.list, (item: ListItemModel, index: number) => { + ListItem() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text(item.text) + .fontSize(16) + .height(48) + .fontColor($r('sys.color.ohos_id_color_toolbar_sub_bg_dark')) + }.width('100%') + }.width('100%') + } + .id('sendSync') + .align(Alignment.Start) + .onClick(item.callback) + .width('100%') + .padding({ left: 12, right: 12 }) + }) + } + .padding({ top: 4, bottom: 4 }) + .borderRadius(24) + .width('100%') + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .margin({ top: 10, bottom: 10 }) + }) + ListItemGroup() { + ListItem() { + UIExtensionComponent({ + bundleName: 'com.samples.abilityFeatureSystem', + abilityName: 'SendSyncUIExtAbility', + parameters: { + 'ability.want.params.uiExtensionType': 'sys/commonUI', + } + }).size({ width: '100%', height: '90%' }) + .onRemoteReady((pro: UIExtensionProxy) => { + logger.info(`${TAG} onRemoteReady:`); + this.myProxy = pro; + }) + } + } + .borderRadius(24) + .width('100%') + .margin({ top: 10, bottom: 10 }) + } + .scrollBar(BarState.Off) + .listDirection(Axis.Vertical) + .friction(0.6) + .edgeEffect(EdgeEffect.Spring) + .padding({ left: 12, right: 12 }) + .width('100%') + .height('100%') + }.width('100%') + }.width('100%') + .height('100%') + .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) + .padding({ top: 36, bottom: 106 }) + } } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/SendSyncExt.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/SendSyncExt.ets index 22c0de815c..b606992be7 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/SendSyncExt.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/SendSyncExt.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2023 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 prompt from '@ohos.promptAction'; -import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import Want from '@ohos.app.ability.Want'; - -const TAG: string = 'UIExtensionAbility'; -let storage: LocalStorage = LocalStorage.getShared(); - -@Entry(storage) -@Component -struct SendSyncExt { - private session: (UIExtensionContentSession | undefined) = storage.get('session'); - private want: (Want | undefined) = storage.get('want'); - - onPageShow() { - if (this.session != undefined) { - this.session.setReceiveDataForResultCallback((data: Record) => { - prompt.showToast({ message: `${TAG} onReceive ${data['key']}`, duration: 3000, bottom: 20 }); - let a: Record = { 'key': `data from ${TAG}` }; - return a; - }) - } - } - - build() { - Column() { - - } - .width('100%') - .height('100%') - .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) - } +/* + * Copyright (c) 2023 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 prompt from '@ohos.promptAction'; +import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import Want from '@ohos.app.ability.Want'; + +const TAG: string = 'UIExtensionAbility'; +let storage: LocalStorage = LocalStorage.getShared(); + +@Entry(storage) +@Component +struct SendSyncExt { + private session: (UIExtensionContentSession | undefined) = storage.get('session'); + private want: (Want | undefined) = storage.get('want'); + + onPageShow() { + if (this.session != undefined) { + this.session.setReceiveDataForResultCallback((data: Record) => { + prompt.showToast({ message: `${TAG} onReceive ${data['key']}`, duration: 3000, bottom: 20 }); + let a: Record = { 'key': `data from ${TAG}` }; + return a; + }) + } + } + + build() { + Column() { + + } + .width('100%') + .height('100%') + .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg')) + } } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/Transit.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/Transit.ets index e8a4516a6c..35216f0fa3 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/Transit.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/pages/Transit.ets @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router'; -import { logger } from '../util/Logger'; - -@Entry -@Component -struct Transit { - build() { - Column() { - UIExtensionComponent({ - bundleName: 'com.samples.abilityFeatureSystem', - abilityName: 'UIExtAbility', - parameters: { - 'ability.want.params.uiExtensionType': 'sys/commonUI', - } - }).size({ width: '100%', height: '100%' }) - .onReceive((data) => { - logger.info(`onReceive data:${JSON.stringify(data)}`); - if (data.back) { - router.back({ - url: 'pages/Index' - }); - } - }) - }.width('100%') - .height('100%') - } +/* + * Copyright (c) 2023 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 router from '@ohos.router'; +import { logger } from '../util/Logger'; + +@Entry +@Component +struct Transit { + build() { + Column() { + UIExtensionComponent({ + bundleName: 'com.samples.abilityFeatureSystem', + abilityName: 'UIExtAbility', + parameters: { + 'ability.want.params.uiExtensionType': 'sys/commonUI', + } + }).size({ width: '100%', height: '100%' }) + .onReceive((data) => { + logger.info(`onReceive data:${JSON.stringify(data)}`); + if (data.back) { + router.back({ + url: 'pages/Index' + }); + } + }) + }.width('100%') + .height('100%') + } } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/sendsyncuiextability/SendSyncUIExtAbility.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/sendsyncuiextability/SendSyncUIExtAbility.ets index 8808430f08..08e7ebb533 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/sendsyncuiextability/SendSyncUIExtAbility.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/sendsyncuiextability/SendSyncUIExtAbility.ets @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 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 UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; -import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import Want from '@ohos.app.ability.Want'; -import { logger } from '../util/Logger'; - -export default class NewUIExtAbility extends UIExtensionAbility { - onCreate() { - logger.info(`NewUIExtAbility onCreate`); - } - - onDestroy() { - logger.info(`NewUIExtAbility onDestroy`); - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - let param: Record = { - 'session': session, - 'want': want - }; - - let storage: LocalStorage = new LocalStorage(param); - session.loadContent('pages/SendSyncExt', storage); - } - - onForeground() { - logger.info(`NewUIExtAbility onForeground`); - // Ability has brought to foreground - } - - onBackground() { - logger.info(`NewUIExtAbility onBackground`); - // Ability has back to background - } -} - - +/* + * Copyright (c) 2023 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 UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; +import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import Want from '@ohos.app.ability.Want'; +import { logger } from '../util/Logger'; + +export default class NewUIExtAbility extends UIExtensionAbility { + onCreate() { + logger.info(`NewUIExtAbility onCreate`); + } + + onDestroy() { + logger.info(`NewUIExtAbility onDestroy`); + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + let param: Record = { + 'session': session, + 'want': want + }; + + let storage: LocalStorage = new LocalStorage(param); + session.loadContent('pages/SendSyncExt', storage); + } + + onForeground() { + logger.info(`NewUIExtAbility onForeground`); + // Ability has brought to foreground + } + + onBackground() { + logger.info(`NewUIExtAbility onBackground`); + // Ability has back to background + } +} + + diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/uiextability/UIExtAbility.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/uiextability/UIExtAbility.ets index d7c8f3b105..8bf0bcfb1d 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/uiextability/UIExtAbility.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/uiextability/UIExtAbility.ets @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2023 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 UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; -import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import Want from '@ohos.app.ability.Want'; -import { logger } from '../util/Logger'; - -export default class UIExtAbility extends UIExtensionAbility { - onCreate() { - logger.info(`UIExtAbility onCreate`); - } - - onDestroy() { - logger.info(`UIExtAbility onDestroy`); - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - let param: Record = { - 'session': session, - 'want': want - }; - let storage: LocalStorage = new LocalStorage(param); - session.loadContent('pages/Ext', storage); - } - - onForeground() { - logger.info(`UIExtAbility onForeground`); - // Ability has brought to foreground - } - - onBackground() { - logger.info(`UIExtAbility onBackground`); - // Ability has back to background - } -} - - +/* + * Copyright (c) 2023 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 UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; +import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import Want from '@ohos.app.ability.Want'; +import { logger } from '../util/Logger'; + +export default class UIExtAbility extends UIExtensionAbility { + onCreate() { + logger.info(`UIExtAbility onCreate`); + } + + onDestroy() { + logger.info(`UIExtAbility onDestroy`); + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + let param: Record = { + 'session': session, + 'want': want + }; + let storage: LocalStorage = new LocalStorage(param); + session.loadContent('pages/Ext', storage); + } + + onForeground() { + logger.info(`UIExtAbility onForeground`); + // Ability has brought to foreground + } + + onBackground() { + logger.info(`UIExtAbility onBackground`); + // Ability has back to background + } +} + + diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/util/Logger.ets b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/util/Logger.ets index a2aa23f156..68370d9993 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/util/Logger.ets +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/ets/util/Logger.ets @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export let logger = new Logger('[Basic capabilities are enhanced use system api]'); \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/module.json5 b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/module.json5 index e967eb0aa5..1e32da5c2f 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/module.json5 +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/module.json5 @@ -1,91 +1,91 @@ -/* - * Copyright (c) 2023 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" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ets", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "NewAbility", - "srcEntry": "./ets/newability/NewAbility.ets", - "description": "$string:NewAbility_desc", - "icon": "$media:icon", - "label": "$string:NewAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background" - }, - ], - "extensionAbilities": [ - { - "name": "UIExtAbility", - "srcEntry": "./ets/uiextability/UIExtAbility.ets", - "description": "$string:UIExtAbility_desc", - "icon": "$media:icon", - "visible": true, - "type": "sys/commonUI", - }, - { - "name": "NewUIExtAbility", - "icon": "$media:icon", - "description": "$string:UIExtAbility_desc", - "visible": true, - "type": "sysPicker/share", - "srcEntrance": "./ets/newuiextability/NewUIExtAbility.ets", - }, - { - "name": "SendSyncUIExtAbility", - "icon": "$media:icon", - "description": "$string:UIExtAbility_desc", - "visible": true, - "type": "sys/commonUI", - "srcEntrance": "./ets/sendsyncuiextability/SendSyncUIExtAbility.ets", - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_RUNNING_INFO" - }, - ] - } +/* + * Copyright (c) 2023 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" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "NewAbility", + "srcEntry": "./ets/newability/NewAbility.ets", + "description": "$string:NewAbility_desc", + "icon": "$media:icon", + "label": "$string:NewAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background" + }, + ], + "extensionAbilities": [ + { + "name": "UIExtAbility", + "srcEntry": "./ets/uiextability/UIExtAbility.ets", + "description": "$string:UIExtAbility_desc", + "icon": "$media:icon", + "visible": true, + "type": "sys/commonUI", + }, + { + "name": "NewUIExtAbility", + "icon": "$media:icon", + "description": "$string:UIExtAbility_desc", + "visible": true, + "type": "sysPicker/share", + "srcEntrance": "./ets/newuiextability/NewUIExtAbility.ets", + }, + { + "name": "SendSyncUIExtAbility", + "icon": "$media:icon", + "description": "$string:UIExtAbility_desc", + "visible": true, + "type": "sys/commonUI", + "srcEntrance": "./ets/sendsyncuiextability/SendSyncUIExtAbility.ets", + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_RUNNING_INFO" + }, + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/resources/base/element/color.json b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/resources/base/element/color.json index a55608bdfd..01dee51761 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/resources/base/element/color.json @@ -1,24 +1,24 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "background", - "value": "#FAFAFA" - }, - { - "name": "line_color", - "value": "#182431" - }, - { - "name": "text_color", - "value": "#182431" - }, - { - "name": "button_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "background", + "value": "#FAFAFA" + }, + { + "name": "line_color", + "value": "#182431" + }, + { + "name": "text_color", + "value": "#182431" + }, + { + "name": "button_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/resources/base/element/float.json b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/resources/base/element/float.json index 51aeb0059c..c8d10991d6 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/resources/base/element/float.json +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/main/resources/base/element/float.json @@ -1,8 +1,8 @@ -{ - "float": [ - { - "name": "font_size", - "value": "16fp" - } - ] +{ + "float": [ + { + "name": "font_size", + "value": "16fp" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/ohosTest/ets/util/Logger.ts b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/ohosTest/ets/util/Logger.ts index a2aa23f156..68370d9993 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/ohosTest/ets/util/Logger.ts +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/ohosTest/ets/util/Logger.ts @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); - hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN); + hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR); + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export let logger = new Logger('[Basic capabilities are enhanced use system api]'); \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/ohosTest/module.json5 b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/ohosTest/module.json5 index 0511adbc86..c6ad62fbbd 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/hvigor/hvigor-config.json5 b/code/SystemFeature/Ability/AbilityFeatureSystem/hvigor/hvigor-config.json5 index fb29482d10..9a79085076 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/oh-package.json5 b/code/SystemFeature/Ability/AbilityFeatureSystem/oh-package.json5 index ef9d148a5b..f668114f8d 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/oh-package.json5 +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "AbilityFeatureSystem", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "AbilityFeatureSystem", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/Ability/AbilityFeatureSystem/ohosTest.md b/code/SystemFeature/Ability/AbilityFeatureSystem/ohosTest.md index f73d748db9..4b7d5e3f3c 100644 --- a/code/SystemFeature/Ability/AbilityFeatureSystem/ohosTest.md +++ b/code/SystemFeature/Ability/AbilityFeatureSystem/ohosTest.md @@ -1,14 +1,14 @@ -# 基础能力增强测试用例 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -|---------------------------------------------|--------|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|------| -| 应用查询单个应用是否正在运行的能力 | 设备正常运行 | 应用启动成功,点击''查询应用状态'的ListItem | 弹出Toast提示'当前应用运行中' | Yes | Pass | -| UIExtension创建模系统或模应用 | 设备正常运行 | 应用启动成功,点击'创建模系统'的ListItem | 弹出UIExtension的页面弹窗 | Yes | Pass | -| UIExtension支持同步返回数据的能力 | 设备正常运行 | 1.应用启动成功,点击'同步发送数据'的ListItem
2.再次点击'同步发送数据'的ListItem
| 1.进入到同步发送数据页面页面
2.UIAbility部分弹出Toast提示'HomeAbility onReceive data from UIExtensionAbility',UIExtensionAbility 部分弹出Toast提示'UIExtensionAbility onReceive data from HomeAbility', | Yes | Pass | -| UIAbilityContext提供startAbilityAsCaller的能力 | 设备正常运行 | 应用启动成功,点击'启动AbilityAsCaller'的ListItem | 应用启动NewAbility | Yes | Pass | -| UIAbilityContext提供隐式启动startAbilityByType的能力 | 设备正常运行 | 应用启动成功,点击'启动AbilityByType'的ListItem | 应用启动NewUIExtensionAbility | Yes | Pass | -| UIExtension提供startAbilityAsCaller的能力 | 设备正常运行 | 1.应用启动成功,点击'启动UIExtensionAbility'的ListItem
2.点击'启动AbilityAsCaller'的ListItem | 1.进入到UIExtensionAbility页面
2.应用启动NewAbility | Yes | Pass | -| UIExtension提供隐式启动startAbilityByType的能力 | 设备正常运行 | 1.应用启动成功,点击'启动UIExtensionAbility'的ListItem
2.点击'启动AbilityByType'的ListItem | 1.进入到UIExtensionAbility页面
2.应用启动NewUIExtensionAbility | Yes | Pass | - +# 基础能力增强测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|---------------------------------------------|--------|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|------| +| 应用查询单个应用是否正在运行的能力 | 设备正常运行 | 应用启动成功,点击''查询应用状态'的ListItem | 弹出Toast提示'当前应用运行中' | Yes | Pass | +| UIExtension创建模系统或模应用 | 设备正常运行 | 应用启动成功,点击'创建模系统'的ListItem | 弹出UIExtension的页面弹窗 | Yes | Pass | +| UIExtension支持同步返回数据的能力 | 设备正常运行 | 1.应用启动成功,点击'同步发送数据'的ListItem
2.再次点击'同步发送数据'的ListItem
| 1.进入到同步发送数据页面页面
2.UIAbility部分弹出Toast提示'HomeAbility onReceive data from UIExtensionAbility',UIExtensionAbility 部分弹出Toast提示'UIExtensionAbility onReceive data from HomeAbility', | Yes | Pass | +| UIAbilityContext提供startAbilityAsCaller的能力 | 设备正常运行 | 应用启动成功,点击'启动AbilityAsCaller'的ListItem | 应用启动NewAbility | Yes | Pass | +| UIAbilityContext提供隐式启动startAbilityByType的能力 | 设备正常运行 | 应用启动成功,点击'启动AbilityByType'的ListItem | 应用启动NewUIExtensionAbility | Yes | Pass | +| UIExtension提供startAbilityAsCaller的能力 | 设备正常运行 | 1.应用启动成功,点击'启动UIExtensionAbility'的ListItem
2.点击'启动AbilityAsCaller'的ListItem | 1.进入到UIExtensionAbility页面
2.应用启动NewAbility | Yes | Pass | +| UIExtension提供隐式启动startAbilityByType的能力 | 设备正常运行 | 1.应用启动成功,点击'启动UIExtensionAbility'的ListItem
2.点击'启动AbilityByType'的ListItem | 1.进入到UIExtensionAbility页面
2.应用启动NewUIExtensionAbility | Yes | Pass | + diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/AppScope/app.json5 b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/AppScope/app.json5 index c9a4a91b6a..b70890c3b0 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/AppScope/app.json5 +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.embeddeduiextensionability", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.embeddeduiextensionability", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/AppScope/resources/base/element/string.json b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/AppScope/resources/base/element/string.json index 571d3b555b..6e273b77f7 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "EmbeddedUIExtensionAbility" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "EmbeddedUIExtensionAbility" + } + ] +} diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/build-profile.json5 b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/build-profile.json5 index ea6d3ca208..6ae38bd2fb 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/build-profile.json5 +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/build-profile.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2024 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", - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, - "runtimeOS": "OpenHarmony" - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "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/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/build-profile.json5 b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/build-profile.json5 index ff39b71eda..caf14acb2d 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/build-profile.json5 +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2024 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2024 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/oh-package.json5 b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/oh-package.json5 index 51b730caf1..2d009f6f73 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/oh-package.json5 +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2024 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/embeddeduiextability/EmbeddedUIExtAbility.ts b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/embeddeduiextability/EmbeddedUIExtAbility.ts index a2ac5ffe4c..af0028ffe3 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/embeddeduiextability/EmbeddedUIExtAbility.ts +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/embeddeduiextability/EmbeddedUIExtAbility.ts @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2024 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 EmbeddedUIExtensionAbility from '@ohos.app.ability.EmbeddedUIExtensionAbility'; -import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import Want from '@ohos.app.ability.Want'; -import Logger from '../model/Logger'; - -const TAG: string = 'ExampleEmbeddedAbility' -export default class ExampleEmbeddedAbility extends EmbeddedUIExtensionAbility { - onCreate() { - Logger.info(TAG, `onCreate`); - } - - onForeground() { - Logger.info(TAG, `onForeground`); - } - - onBackground() { - Logger.info(TAG, `onBackground`); - } - - onDestroy() { - Logger.info(TAG, `onDestroy`); - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - Logger.info(TAG, `onSessionCreate, want: ${JSON.stringify(want)}}`); - let param: Record = { - 'session': session - }; - let storage: LocalStorage = new LocalStorage(param); - session.loadContent('pages/extension', storage); - } - - onSessionDestroy(session: UIExtensionContentSession) { - Logger.info(TAG, `onSessionDestroy`); - } +/* + * Copyright (c) 2024 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 EmbeddedUIExtensionAbility from '@ohos.app.ability.EmbeddedUIExtensionAbility'; +import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import Want from '@ohos.app.ability.Want'; +import Logger from '../model/Logger'; + +const TAG: string = 'ExampleEmbeddedAbility' +export default class ExampleEmbeddedAbility extends EmbeddedUIExtensionAbility { + onCreate() { + Logger.info(TAG, `onCreate`); + } + + onForeground() { + Logger.info(TAG, `onForeground`); + } + + onBackground() { + Logger.info(TAG, `onBackground`); + } + + onDestroy() { + Logger.info(TAG, `onDestroy`); + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + Logger.info(TAG, `onSessionCreate, want: ${JSON.stringify(want)}}`); + let param: Record = { + 'session': session + }; + let storage: LocalStorage = new LocalStorage(param); + session.loadContent('pages/extension', storage); + } + + onSessionDestroy(session: UIExtensionContentSession) { + Logger.info(TAG, `onSessionDestroy`); + } } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/entryability/EntryAbility.ts b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/entryability/EntryAbility.ts index d30cea1c9d..72df1d36a5 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2024 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 from '@ohos.app.ability.AbilityConstant'; -import Logger from '../model/Logger'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; - -const TAG: string = 'EntryAbility '; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - Logger.info(TAG, 'Ability onCreate'); - } - - onDestroy() { - Logger.info(TAG, 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - Logger.info(TAG, 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - Logger.error(TAG, 'Failed to load the content.' + JSON.stringify(err)); - return; - } - Logger.info(TAG, 'Succeeded in loading the content.' + JSON.stringify(data)); - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - Logger.info(TAG, 'Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - Logger.info(TAG, 'Ability onForeground'); - } - - onBackground() { - // Ability has back to background - Logger.info(TAG, 'Ability onBackground'); - } -} +/* + * Copyright (c) 2024 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 from '@ohos.app.ability.AbilityConstant'; +import Logger from '../model/Logger'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +const TAG: string = 'EntryAbility '; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + Logger.info(TAG, 'Ability onCreate'); + } + + onDestroy() { + Logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + Logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error(TAG, 'Failed to load the content.' + JSON.stringify(err)); + return; + } + Logger.info(TAG, 'Succeeded in loading the content.' + JSON.stringify(data)); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + Logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + Logger.info(TAG, 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + Logger.info(TAG, 'Ability onBackground'); + } +} diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/model/Logger.ts b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/model/Logger.ts index 140eef6342..2a0e73e7cd 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/model/Logger.ts +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/model/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_EmbeddedUIExtensionAbility]'); \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/pages/extension.ets b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/pages/extension.ets index 00bac17ada..5c30e0357f 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/pages/extension.ets +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/ets/pages/extension.ets @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2024 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 UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import commonEvent from '@ohos.commonEventManager'; - -let storage = LocalStorage.getShared() - -@Entry(storage) -@Component - -struct Extension { - @State message: string = 'EmbeddedUIExtensionAbility provider'; - private session: UIExtensionContentSession | undefined = storage.get('session'); - - aboutToAppear(){ - console.info(`show`) - commonEvent.publish('page_show', (err) => { - console.log('Extension page show'); - }) - } - - build() { - Column() { - Text(this.message) - .fontSize(20) - .fontWeight(FontWeight.Bold) - .textAlign(TextAlign.Center) - } - .alignItems(HorizontalAlign.Center) - .width('100%') - .height('100%') - .justifyContent(FlexAlign.Center) - } +/* + * Copyright (c) 2024 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 UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import commonEvent from '@ohos.commonEventManager'; + +let storage = LocalStorage.getShared() + +@Entry(storage) +@Component + +struct Extension { + @State message: string = 'EmbeddedUIExtensionAbility provider'; + private session: UIExtensionContentSession | undefined = storage.get('session'); + + aboutToAppear(){ + console.info(`show`) + commonEvent.publish('page_show', (err) => { + console.log('Extension page show'); + }) + } + + build() { + Column() { + Text(this.message) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Center) + } + .alignItems(HorizontalAlign.Center) + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/module.json5 b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/module.json5 index 75e355c953..176ac6d9fb 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/module.json5 +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/module.json5 @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2024 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": [ - "phone", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "EmbeddedUIExtAbility", - "icon": "$media:icon", - "description": "EmbeddedUIExtAbility", - "type": "embeddedUI", - "srcEntry": "./ets/embeddeduiextability/EmbeddedUIExtAbility.ts", - "exported": true, - } - ] - } +/* + * Copyright (c) 2024 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": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EmbeddedUIExtAbility", + "icon": "$media:icon", + "description": "EmbeddedUIExtAbility", + "type": "embeddedUI", + "srcEntry": "./ets/embeddeduiextability/EmbeddedUIExtAbility.ts", + "exported": true, + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/resources/base/element/color.json b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/ohosTest/module.json5 b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/ohosTest/module.json5 index 3613514e70..7690747eb4 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/hvigor/hvigor-config.json5 b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/hvigor/hvigor-config.json5 index 3a4f957eef..277e9a1fd2 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/hvigor/hvigor-config.json5 @@ -1,18 +1,18 @@ -{ - "hvigorVersion": "3.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.2" - }, - "execution": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } -} +{ + "hvigorVersion": "3.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.2" + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } +} diff --git a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/oh-package.json5 b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/oh-package.json5 index 216cd0bb41..ce6cb16a57 100644 --- a/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/oh-package.json5 +++ b/code/SystemFeature/ApplicationModels/EmbeddedUIExtensionAbility/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "embeddeduiextensionability", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "embeddeduiextensionability", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/ApplicationModels/Launcher/entry/src/ohosTest/ets/test/Launcher.test.ets b/code/SystemFeature/ApplicationModels/Launcher/entry/src/ohosTest/ets/test/Launcher.test.ets index 249853739f..84c06b4ef1 100644 --- a/code/SystemFeature/ApplicationModels/Launcher/entry/src/ohosTest/ets/test/Launcher.test.ets +++ b/code/SystemFeature/ApplicationModels/Launcher/entry/src/ohosTest/ets/test/Launcher.test.ets @@ -1,272 +1,272 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, beforeAll, expect, beforeEach, afterEach } from '@ohos/hypium' -import { Driver, ON } from '@ohos.UiTest' -import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry' -import hilog from '@ohos.hilog' - -const TAG = '[Sample_Launcher_Test]' -const DOMAIN = 0xF811 -const BUNDLE = 'LauncherTest_' -let appStartRecent = 'startRecent' -let timeStampId = 'time' -let startRecentButtonId = 'startSingletonAbility' -let singletonAbilityText = 'SingletonAbility' -let appCrossChain = 'crossChain' -let crossChainButtonId = 'startSecondAbility' -let entryAbilityText = 'EntryAbility' -let secondAbilityText = 'SecondAbility' -// Return desktop coordinates based on rk3568 -let pressHome_x = 360 -let pressHome_y = 1270 -// Open the recent task list coordinates based on rk3568 -let pressRecent_x = 576 -let pressRecent_y = 1270 - -export default function launcherTest() { - describe('ActsLauncherTest', () => { - /** - * Scene:Start the most recent component instance. - * Input:Click to open the application, return to the desktop, and then click the icon again. - * Expected output:Pull the most recent ability to the foreground, no new ability instance be created. - */ - it(BUNDLE + 'StartRecentAbility_001', 0, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 begin') - let driver = Driver.create() - await driver.delayMs(1000) - // Open the recent task list - await driver.click(pressRecent_x, pressRecent_y) - await driver.delayMs(300) - // Find the number of ability instances that have been opened - let appCount = 1 - await driver.findComponents(ON.text(appStartRecent)).then(result =>{ - if (result != null) { - appCount = result.length - } - }) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 checkComponent, appCount: ' + appCount) - await driver.pressBack() - await driver.delayMs(300) - // Find and open the test application - let app = await driver.findComponent(ON.text(appStartRecent)) - await app.click() - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 openApplication') - await driver.delayMs(500) - // Read the timestamp on the current UIAbility - let firstTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) - let firstTimeStamp = JSON.stringify(await firstTimeStampComponent.getText()) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 getFirstTimeStamp, firstTimeStamp: ' + firstTimeStamp) - // Click the home button to return to the desktop - await driver.click(pressHome_x, pressHome_y) - await driver.delayMs(300) - // open the test application again - await app.click() - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 openApplicationAgain') - await driver.delayMs(500) - // Read the timestamp - // verify that clicking the application icon again opened the most recent instance, not a new one - let secondTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) - let secondTimeStamp = JSON.stringify(await secondTimeStampComponent.getText()) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 compareTimeStampEqual, secondTimeStamp: ' + secondTimeStamp) - expect(firstTimeStamp).assertEqual(secondTimeStamp) - // Open the recent task list - await driver.click(pressRecent_x, pressRecent_y) - await driver.delayMs(300) - // Verify that no new instance has been created - let secondAppList = await driver.findComponents(ON.text(appStartRecent)) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 confirmAbilityNotAdd, secondAppList: ' + secondAppList.length) - expect(secondAppList.length).assertEqual(appCount) - await driver.click(pressHome_x, pressHome_y) - await driver.delayMs(300) - await driver.click(pressHome_x, pressHome_y) - await driver.delayMs(500) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 end') - done() - }) - - /** - * Scene:Start the most recent component instance. - * Input:Long click on the application icon, select 'Open' from the pop-up menu. - * Return to the desktop and open the application by long clicking again. - * Expected output:Pull the most recent ability to the foreground, no new ability instance will be created. - */ - it(BUNDLE + 'StartRecentAbility_002', 1, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 begin') - let driver = Driver.create() - await driver.delayMs(1000) - // Open the recent task list - await driver.click(pressRecent_x, pressRecent_y) - await driver.delayMs(500) - // Find the number of ability instances that have been opened - let appCount = 1 - await driver.findComponents(ON.text(appStartRecent)).then(result =>{ - if (result != null) { - appCount = result.length - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 checkComponent, appCount: ' + appCount) - } - }) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 appCount: ' + appCount) - await driver.pressBack() - await driver.delayMs(300) - let resourceManager = abilityDelegatorRegistry.getAbilityDelegator().getAppContext().resourceManager - // Open the test application with a long click - let app = await driver.findComponent(ON.text(appStartRecent)) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 openApplicationByLongClick') - await app.longClick() - await driver.delayMs(100) - let open = await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.app_menu_open')))) - await open.click() - await driver.delayMs(500) - // Read the timestamp on the current UIAbility - let firstTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) - let firstTimeStamp = JSON.stringify(await firstTimeStampComponent.getText()) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 getFirstTimeStamp, firstTimeStamp: ' + firstTimeStamp) - // Click the home button to return to the desktop - await driver.click(pressHome_x, pressHome_y) - await driver.delayMs(300) - // open the test application with a long click again - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 openApplicationByLongClickAgain') - await app.longClick() - await driver.delayMs(100) - await open.click() - await driver.delayMs(500) - // Read the timestamp - // verify that clicking the application icon again opened the most recent instance, not a new one - let secondTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) - let secondTimeStamp = JSON.stringify(await secondTimeStampComponent.getText()) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 compareTimeStampEqual, secondTimeStamp: ' + secondTimeStamp) - expect(firstTimeStamp).assertEqual(secondTimeStamp) - // Open the recent task list - await driver.click(pressRecent_x, pressRecent_y) - await driver.delayMs(300) - // Verify that no new instance has been created - let secondAppList = await driver.findComponents(ON.text(appStartRecent)) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 confirmAbilityNotAdd, secondAppList: ' + secondAppList.length) - expect(secondAppList.length).assertEqual(appCount) - await driver.click(pressHome_x, pressHome_y) - await driver.delayMs(300) - await driver.click(pressHome_x, pressHome_y) - await driver.delayMs(500) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 end') - done() - }) - - /** - * Scene:Start the most recent component instance. - * Input:Click to open the application, click button to open SecondAbility, return to the desktop. - * Click the icon to open the application again. - * Expected output:Pull EntryAbility to the foreground, no new ability instance will be created. - */ - it(BUNDLE + 'StartRecentAbility_003', 2, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 begin') - let driver = Driver.create() - await driver.delayMs(1000) - // Open the recent task list - await driver.click(pressRecent_x, pressRecent_y) - await driver.delayMs(500) - // Find the number of ability instances that have been opened - let appList = await driver.findComponents(ON.text(appStartRecent)) - let appCount = 2 - if (appList != null) { - appCount = appList.length + 1 - } - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 checkComponent, appCount: ' + appCount) - await driver.pressBack() - await driver.delayMs(300) - // Find and open the test application - let app = await driver.findComponent(ON.text(appStartRecent)) - await app.click() - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 openApplication') - await driver.delayMs(500) - // Read the timestamp on the current UIAbility - let firstTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) - let firstTimeStamp = JSON.stringify(await firstTimeStampComponent.getText()) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 getFirstTimeStamp, firstTimeStamp: ' + firstTimeStamp) - // Find the button and click,open singletonAbility - let startRecentButton = await driver.findComponent(ON.id(startRecentButtonId)) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 clickStartRecentButton') - await startRecentButton.click() - await driver.delayMs(300) - // Verify singletonAbility is opened. - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 confirmIsSingletonAbility, singletonAbilityText: ' + singletonAbilityText) - await driver.assertComponentExist(ON.text(singletonAbilityText)) - // Click the home key - await driver.click(pressHome_x, pressHome_y) - await driver.delayMs(300) - // Find and open the test application again - await app.click() - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 openApplicationAgain') - await driver.delayMs(300) - // Read the timestamp - // Verify open current EntryAbility instead of to the desktop - let secondTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) - let secondTimeStamp = JSON.stringify(await secondTimeStampComponent.getText()) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 compareTimeStampEqual, secondTimeStamp: ' + secondTimeStamp) - expect(secondTimeStamp).assertEqual(firstTimeStamp) - // Open the recent task list - await driver.click(pressRecent_x, pressRecent_y) - await driver.delayMs(300) - // Verify that no new instance has been created - let secondAppList = await driver.findComponents(ON.text(appStartRecent)) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 confirmAbilityNotAdd, secondAppList: ' + secondAppList.length) - expect(secondAppList.length).assertEqual(appCount) - await driver.click(pressHome_x, pressHome_y) - await driver.delayMs(300) - await driver.click(pressHome_x, pressHome_y) - await driver.delayMs(500) - hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 end') - done() - }) - - /** - * Scene:Return across task chain. - * Input:Click to open the application, click the button in EntryAbility. - * Click the back button after opening SecondAbility. - * Expected output:Return to EntryAbility instead of to the desktop. - */ - it(BUNDLE + 'TaskChainBack_001', 3, async (done: Function) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 begin') - let driver = Driver.create() - await driver.delayMs(1000) - // Find and open the test application - let app = await driver.findComponent(ON.text(appCrossChain)) - hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 openApplication') - await app.click() - await driver.delayMs(500) - // Verify EntryAbility is opened - hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 confirmIsEntryAbility, entryAbilityText: ' + entryAbilityText) - await driver.assertComponentExist(ON.text(entryAbilityText)) - // Find the button and click - let crossChainButton = await driver.findComponent(ON.id(crossChainButtonId)) - hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 clickCrossChainButton') - await crossChainButton.click() - await driver.delayMs(300) - // Verify SecondAbility is opened by pulling up ServiceExtensionAbility after clicking the button - hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 confirmIsSecondAbility, secondAbilityText: ' + secondAbilityText) - await driver.assertComponentExist(ON.text(secondAbilityText)) - // Click the back key - await driver.pressBack() - await driver.delayMs(300) - // Verify back to EntryAbility instead of to the desktop - hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 assertIsEntryAbility, entryAbilityText: ' + entryAbilityText) - await driver.assertComponentExist(ON.text(entryAbilityText)) - await driver.click(pressHome_x, pressHome_y) - await driver.delayMs(300) - hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 end') - done() - }) - }) +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, beforeAll, expect, beforeEach, afterEach } from '@ohos/hypium' +import { Driver, ON } from '@ohos.UiTest' +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry' +import hilog from '@ohos.hilog' + +const TAG = '[Sample_Launcher_Test]' +const DOMAIN = 0xF811 +const BUNDLE = 'LauncherTest_' +let appStartRecent = 'startRecent' +let timeStampId = 'time' +let startRecentButtonId = 'startSingletonAbility' +let singletonAbilityText = 'SingletonAbility' +let appCrossChain = 'crossChain' +let crossChainButtonId = 'startSecondAbility' +let entryAbilityText = 'EntryAbility' +let secondAbilityText = 'SecondAbility' +// Return desktop coordinates based on rk3568 +let pressHome_x = 360 +let pressHome_y = 1270 +// Open the recent task list coordinates based on rk3568 +let pressRecent_x = 576 +let pressRecent_y = 1270 + +export default function launcherTest() { + describe('ActsLauncherTest', () => { + /** + * Scene:Start the most recent component instance. + * Input:Click to open the application, return to the desktop, and then click the icon again. + * Expected output:Pull the most recent ability to the foreground, no new ability instance be created. + */ + it(BUNDLE + 'StartRecentAbility_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 begin') + let driver = Driver.create() + await driver.delayMs(1000) + // Open the recent task list + await driver.click(pressRecent_x, pressRecent_y) + await driver.delayMs(300) + // Find the number of ability instances that have been opened + let appCount = 1 + await driver.findComponents(ON.text(appStartRecent)).then(result =>{ + if (result != null) { + appCount = result.length + } + }) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 checkComponent, appCount: ' + appCount) + await driver.pressBack() + await driver.delayMs(300) + // Find and open the test application + let app = await driver.findComponent(ON.text(appStartRecent)) + await app.click() + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 openApplication') + await driver.delayMs(500) + // Read the timestamp on the current UIAbility + let firstTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) + let firstTimeStamp = JSON.stringify(await firstTimeStampComponent.getText()) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 getFirstTimeStamp, firstTimeStamp: ' + firstTimeStamp) + // Click the home button to return to the desktop + await driver.click(pressHome_x, pressHome_y) + await driver.delayMs(300) + // open the test application again + await app.click() + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 openApplicationAgain') + await driver.delayMs(500) + // Read the timestamp + // verify that clicking the application icon again opened the most recent instance, not a new one + let secondTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) + let secondTimeStamp = JSON.stringify(await secondTimeStampComponent.getText()) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 compareTimeStampEqual, secondTimeStamp: ' + secondTimeStamp) + expect(firstTimeStamp).assertEqual(secondTimeStamp) + // Open the recent task list + await driver.click(pressRecent_x, pressRecent_y) + await driver.delayMs(300) + // Verify that no new instance has been created + let secondAppList = await driver.findComponents(ON.text(appStartRecent)) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 confirmAbilityNotAdd, secondAppList: ' + secondAppList.length) + expect(secondAppList.length).assertEqual(appCount) + await driver.click(pressHome_x, pressHome_y) + await driver.delayMs(300) + await driver.click(pressHome_x, pressHome_y) + await driver.delayMs(500) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_001 end') + done() + }) + + /** + * Scene:Start the most recent component instance. + * Input:Long click on the application icon, select 'Open' from the pop-up menu. + * Return to the desktop and open the application by long clicking again. + * Expected output:Pull the most recent ability to the foreground, no new ability instance will be created. + */ + it(BUNDLE + 'StartRecentAbility_002', 1, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 begin') + let driver = Driver.create() + await driver.delayMs(1000) + // Open the recent task list + await driver.click(pressRecent_x, pressRecent_y) + await driver.delayMs(500) + // Find the number of ability instances that have been opened + let appCount = 1 + await driver.findComponents(ON.text(appStartRecent)).then(result =>{ + if (result != null) { + appCount = result.length + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 checkComponent, appCount: ' + appCount) + } + }) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 appCount: ' + appCount) + await driver.pressBack() + await driver.delayMs(300) + let resourceManager = abilityDelegatorRegistry.getAbilityDelegator().getAppContext().resourceManager + // Open the test application with a long click + let app = await driver.findComponent(ON.text(appStartRecent)) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 openApplicationByLongClick') + await app.longClick() + await driver.delayMs(100) + let open = await driver.findComponent(ON.text(await resourceManager.getStringValue($r('app.string.app_menu_open')))) + await open.click() + await driver.delayMs(500) + // Read the timestamp on the current UIAbility + let firstTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) + let firstTimeStamp = JSON.stringify(await firstTimeStampComponent.getText()) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 getFirstTimeStamp, firstTimeStamp: ' + firstTimeStamp) + // Click the home button to return to the desktop + await driver.click(pressHome_x, pressHome_y) + await driver.delayMs(300) + // open the test application with a long click again + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 openApplicationByLongClickAgain') + await app.longClick() + await driver.delayMs(100) + await open.click() + await driver.delayMs(500) + // Read the timestamp + // verify that clicking the application icon again opened the most recent instance, not a new one + let secondTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) + let secondTimeStamp = JSON.stringify(await secondTimeStampComponent.getText()) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 compareTimeStampEqual, secondTimeStamp: ' + secondTimeStamp) + expect(firstTimeStamp).assertEqual(secondTimeStamp) + // Open the recent task list + await driver.click(pressRecent_x, pressRecent_y) + await driver.delayMs(300) + // Verify that no new instance has been created + let secondAppList = await driver.findComponents(ON.text(appStartRecent)) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 confirmAbilityNotAdd, secondAppList: ' + secondAppList.length) + expect(secondAppList.length).assertEqual(appCount) + await driver.click(pressHome_x, pressHome_y) + await driver.delayMs(300) + await driver.click(pressHome_x, pressHome_y) + await driver.delayMs(500) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_002 end') + done() + }) + + /** + * Scene:Start the most recent component instance. + * Input:Click to open the application, click button to open SecondAbility, return to the desktop. + * Click the icon to open the application again. + * Expected output:Pull EntryAbility to the foreground, no new ability instance will be created. + */ + it(BUNDLE + 'StartRecentAbility_003', 2, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 begin') + let driver = Driver.create() + await driver.delayMs(1000) + // Open the recent task list + await driver.click(pressRecent_x, pressRecent_y) + await driver.delayMs(500) + // Find the number of ability instances that have been opened + let appList = await driver.findComponents(ON.text(appStartRecent)) + let appCount = 2 + if (appList != null) { + appCount = appList.length + 1 + } + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 checkComponent, appCount: ' + appCount) + await driver.pressBack() + await driver.delayMs(300) + // Find and open the test application + let app = await driver.findComponent(ON.text(appStartRecent)) + await app.click() + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 openApplication') + await driver.delayMs(500) + // Read the timestamp on the current UIAbility + let firstTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) + let firstTimeStamp = JSON.stringify(await firstTimeStampComponent.getText()) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 getFirstTimeStamp, firstTimeStamp: ' + firstTimeStamp) + // Find the button and click,open singletonAbility + let startRecentButton = await driver.findComponent(ON.id(startRecentButtonId)) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 clickStartRecentButton') + await startRecentButton.click() + await driver.delayMs(300) + // Verify singletonAbility is opened. + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 confirmIsSingletonAbility, singletonAbilityText: ' + singletonAbilityText) + await driver.assertComponentExist(ON.text(singletonAbilityText)) + // Click the home key + await driver.click(pressHome_x, pressHome_y) + await driver.delayMs(300) + // Find and open the test application again + await app.click() + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 openApplicationAgain') + await driver.delayMs(300) + // Read the timestamp + // Verify open current EntryAbility instead of to the desktop + let secondTimeStampComponent = await driver.findComponent(ON.id(timeStampId)) + let secondTimeStamp = JSON.stringify(await secondTimeStampComponent.getText()) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 compareTimeStampEqual, secondTimeStamp: ' + secondTimeStamp) + expect(secondTimeStamp).assertEqual(firstTimeStamp) + // Open the recent task list + await driver.click(pressRecent_x, pressRecent_y) + await driver.delayMs(300) + // Verify that no new instance has been created + let secondAppList = await driver.findComponents(ON.text(appStartRecent)) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 confirmAbilityNotAdd, secondAppList: ' + secondAppList.length) + expect(secondAppList.length).assertEqual(appCount) + await driver.click(pressHome_x, pressHome_y) + await driver.delayMs(300) + await driver.click(pressHome_x, pressHome_y) + await driver.delayMs(500) + hilog.info(DOMAIN, TAG, BUNDLE + 'StartRecentAbility_003 end') + done() + }) + + /** + * Scene:Return across task chain. + * Input:Click to open the application, click the button in EntryAbility. + * Click the back button after opening SecondAbility. + * Expected output:Return to EntryAbility instead of to the desktop. + */ + it(BUNDLE + 'TaskChainBack_001', 3, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 begin') + let driver = Driver.create() + await driver.delayMs(1000) + // Find and open the test application + let app = await driver.findComponent(ON.text(appCrossChain)) + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 openApplication') + await app.click() + await driver.delayMs(500) + // Verify EntryAbility is opened + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 confirmIsEntryAbility, entryAbilityText: ' + entryAbilityText) + await driver.assertComponentExist(ON.text(entryAbilityText)) + // Find the button and click + let crossChainButton = await driver.findComponent(ON.id(crossChainButtonId)) + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 clickCrossChainButton') + await crossChainButton.click() + await driver.delayMs(300) + // Verify SecondAbility is opened by pulling up ServiceExtensionAbility after clicking the button + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 confirmIsSecondAbility, secondAbilityText: ' + secondAbilityText) + await driver.assertComponentExist(ON.text(secondAbilityText)) + // Click the back key + await driver.pressBack() + await driver.delayMs(300) + // Verify back to EntryAbility instead of to the desktop + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 assertIsEntryAbility, entryAbilityText: ' + entryAbilityText) + await driver.assertComponentExist(ON.text(entryAbilityText)) + await driver.click(pressHome_x, pressHome_y) + await driver.delayMs(300) + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskChainBack_001 end') + done() + }) + }) } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/StaticSubscriber/entry/hvigorfile.ts b/code/SystemFeature/ApplicationModels/StaticSubscriber/entry/hvigorfile.ts index c57c77181d..80e4ec5b81 100644 --- a/code/SystemFeature/ApplicationModels/StaticSubscriber/entry/hvigorfile.ts +++ b/code/SystemFeature/ApplicationModels/StaticSubscriber/entry/hvigorfile.ts @@ -1,2 +1,2 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -export { hapTasks } from '@ohos/hvigor-ohos-plugin'; +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { hapTasks } from '@ohos/hvigor-ohos-plugin'; diff --git a/code/SystemFeature/ApplicationModels/StaticSubscriber/hvigorfile.ts b/code/SystemFeature/ApplicationModels/StaticSubscriber/hvigorfile.ts index 1a4d9969c6..6478186902 100644 --- a/code/SystemFeature/ApplicationModels/StaticSubscriber/hvigorfile.ts +++ b/code/SystemFeature/ApplicationModels/StaticSubscriber/hvigorfile.ts @@ -1,2 +1,2 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/StaticSubscriber/publish/hvigorfile.ts b/code/SystemFeature/ApplicationModels/StaticSubscriber/publish/hvigorfile.ts index c57c77181d..80e4ec5b81 100644 --- a/code/SystemFeature/ApplicationModels/StaticSubscriber/publish/hvigorfile.ts +++ b/code/SystemFeature/ApplicationModels/StaticSubscriber/publish/hvigorfile.ts @@ -1,2 +1,2 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -export { hapTasks } from '@ohos/hvigor-ohos-plugin'; +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { hapTasks } from '@ohos/hvigor-ohos-plugin'; diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/AppScope/app.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/AppScope/app.json5 index 3f78b42a42..3ce317c6e3 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/AppScope/app.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.acts.abilityabacktoabilityb", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.acts.abilityabacktoabilityb", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/AppScope/resources/base/element/string.json b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/AppScope/resources/base/element/string.json index d71e5ead1c..1080233f01 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MyApplication" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + } + ] +} diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/build-profile.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/build-profile.json5 index 235336001b..66170112ec 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/build-profile.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/build-profile.json5 @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2023 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": [], - "compileSdkVersion": 9, - "compatibleSdkVersion": 9, - "products": [ - { - "name": "default", - "signingConfig": "default", - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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": [], + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, + "products": [ + { + "name": "default", + "signingConfig": "default", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/build-profile.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/build-profile.json5 index d2711a6c64..fcaca9146e 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/build-profile.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/oh-package.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/oh-package.json5 index 4be95c59ce..3fbe67bbf8 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/oh-package.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/entryability/EntryAbility.ts b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/entryability/EntryAbility.ts index ba63ef824c..c2c39ef45f 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import window from '@ohos.window'; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - 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'); - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + 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/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/logger/Logger.ts b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/logger/Logger.ts index 57c377b511..8e41f73118 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/logger/Logger.ts +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/logger/Logger.ts @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - /** - * debug - * @param args - */ - debug(...args: any[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - /** - * info - * @param args - */ - info(...args: any[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - /** - * warn - * @param args - */ - warn(...args: any[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - /** - * error - * @param args - */ - error(...args: any[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + /** + * debug + * @param args + */ + debug(...args: any[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + /** + * info + * @param args + */ + info(...args: any[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + /** + * warn + * @param args + */ + warn(...args: any[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + /** + * error + * @param args + */ + error(...args: any[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_CrossChainBack]'); \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/secondability/SecondAbility.ts b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/secondability/SecondAbility.ts index 9187897370..cc130d4259 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/secondability/SecondAbility.ts +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/secondability/SecondAbility.ts @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import hilog from '@ohos.hilog'; -import window from '@ohos.window'; -import Logger from '../logger/Logger'; - -export default class SecondAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - Logger.debug('SecondAbility onCreate'); - } - - 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/IndexSecond', (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'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; +import Logger from '../logger/Logger'; + +export default class SecondAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + Logger.debug('SecondAbility onCreate'); + } + + 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/IndexSecond', (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/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/serviceability/ServiceAbility.ts b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/serviceability/ServiceAbility.ts index ca5200c02e..002431002c 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/serviceability/ServiceAbility.ts +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/ets/serviceability/ServiceAbility.ts @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 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 ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; -import wantConstant from '@ohos.app.ability.wantConstant'; -import rpc from '@ohos.rpc'; -import Logger from '../logger/Logger'; - -class StubTest extends rpc.RemoteObject { - constructor(des) { - super(des); - } - - onRemoteRequest(code, data, reply, option): boolean { - return true; - } -} - -export default class ServiceAbility extends ServiceExtensionAbility { - onCreate(want) { - Logger.debug('ServiceExtensionAbility has been onCreate'); - } - - onDestroy() { - Logger.debug('ServiceExtensionAbility has been onDestroy'); - } - - onRequest(want, startId) { - Logger.debug('ServiceExtensionAbility has been onRequest'); - } - - onConnect(want) { - console.info('ServiceAbility onConnect'); - let secUIAbilityWant = { - bundleName: 'com.acts.abilityabacktoabilityb', - abilityName: 'SecondAbility', - parameters: { - [wantConstant.Params.ABILITY_BACK_TO_OTHER_MISSION_STACK]: true - } - }; - globalThis.context = this.context; - this.context.startAbility(secUIAbilityWant).then(() => { - Logger.debug('startAbility successful.'); - }).catch((err) => { - Logger.debug('startAbility failed.'); - }); - return new StubTest('test'); - } -} +/* + * Copyright (c) 2023 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 ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; +import wantConstant from '@ohos.app.ability.wantConstant'; +import rpc from '@ohos.rpc'; +import Logger from '../logger/Logger'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des); + } + + onRemoteRequest(code, data, reply, option): boolean { + return true; + } +} + +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + Logger.debug('ServiceExtensionAbility has been onCreate'); + } + + onDestroy() { + Logger.debug('ServiceExtensionAbility has been onDestroy'); + } + + onRequest(want, startId) { + Logger.debug('ServiceExtensionAbility has been onRequest'); + } + + onConnect(want) { + console.info('ServiceAbility onConnect'); + let secUIAbilityWant = { + bundleName: 'com.acts.abilityabacktoabilityb', + abilityName: 'SecondAbility', + parameters: { + [wantConstant.Params.ABILITY_BACK_TO_OTHER_MISSION_STACK]: true + } + }; + globalThis.context = this.context; + this.context.startAbility(secUIAbilityWant).then(() => { + Logger.debug('startAbility successful.'); + }).catch((err) => { + Logger.debug('startAbility failed.'); + }); + return new StubTest('test'); + } +} diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/module.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/module.json5 index 2887681ad9..4d3bbdc72d 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/module.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/module.json5 @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2023 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" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "launchType": "standard", - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "SecondAbility", - "srcEntrance": "./ets/secondability/SecondAbility.ts", - "description": "$string:SecondAbility_desc", - "icon": "$media:icon", - "label": "$string:SecondAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "visible": true - } - ], - "extensionAbilities": [ - { - "name": "ServiceAbility", - "srcEntrance": "./ets/serviceability/ServiceAbility.ts", - "label": "$string:ServiceAbility_label", - "description": "$string:ServiceAbility_desc", - "type": "service" - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND" - } - ] - } +/* + * Copyright (c) 2023 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" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "launchType": "standard", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "SecondAbility", + "srcEntrance": "./ets/secondability/SecondAbility.ts", + "description": "$string:SecondAbility_desc", + "icon": "$media:icon", + "label": "$string:SecondAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true + } + ], + "extensionAbilities": [ + { + "name": "ServiceAbility", + "srcEntrance": "./ets/serviceability/ServiceAbility.ts", + "label": "$string:ServiceAbility_label", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/resources/base/element/color.json b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/hvigor/hvigor-config.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/hvigor/hvigor-config.json5 index e5abb715c8..835122515a 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "hvigorVersion": "2.0.0", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "2.0.0" - } -} +/* + * Copyright (c) 2023 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. + */ + +{ + "hvigorVersion": "2.0.0", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "2.0.0" + } +} diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/oh-package.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/oh-package.json5 index 80dcaf146d..ab9d172f96 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/oh-package.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "myapplication", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "myapplication", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/AppScope/app.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/AppScope/app.json5 index cafc68858c..e6f13d24b2 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/AppScope/app.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.acts.startrecentability", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.acts.startrecentability", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/AppScope/resources/base/element/string.json b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/AppScope/resources/base/element/string.json index d71e5ead1c..1080233f01 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MyApplication" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + } + ] +} diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/build-profile.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/build-profile.json5 index 235336001b..66170112ec 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/build-profile.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/build-profile.json5 @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2023 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": [], - "compileSdkVersion": 9, - "compatibleSdkVersion": 9, - "products": [ - { - "name": "default", - "signingConfig": "default", - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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": [], + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, + "products": [ + { + "name": "default", + "signingConfig": "default", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/build-profile.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/build-profile.json5 index d2711a6c64..fcaca9146e 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/build-profile.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/oh-package.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/oh-package.json5 index 4be95c59ce..3fbe67bbf8 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/oh-package.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/entryability/EntryAbility.ts b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/entryability/EntryAbility.ts index c6b55c98e6..d24d63eb79 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import hilog from '@ohos.hilog'; -import window from '@ohos.window'; -import systemDateTime from '@ohos.systemDateTime'; -import Logger from '../logger/Logger'; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - systemDateTime.getDate().then((date) => { - Logger.debug('getDate successful'); - }); - } - - 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'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; +import systemDateTime from '@ohos.systemDateTime'; +import Logger from '../logger/Logger'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + systemDateTime.getDate().then((date) => { + Logger.debug('getDate successful'); + }); + } + + 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/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/logger/Logger.ts b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/logger/Logger.ts index a770417524..d8268862af 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/logger/Logger.ts +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/logger/Logger.ts @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - /** - * debug - * @param args - */ - debug(...args: any[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - /** - * info - * @param args - */ - info(...args: any[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - /** - * warn - * @param args - */ - warn(...args: any[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - /** - * error - * @param args - */ - error(...args: any[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - -export default new Logger('[Sample_StartRecentAbility]'); +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + /** + * debug + * @param args + */ + debug(...args: any[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + /** + * info + * @param args + */ + info(...args: any[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + /** + * warn + * @param args + */ + warn(...args: any[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + /** + * error + * @param args + */ + error(...args: any[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export default new Logger('[Sample_StartRecentAbility]'); diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/secondability/SecondAbility.ts b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/secondability/SecondAbility.ts index 690958f990..b0271aaf8d 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/secondability/SecondAbility.ts +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/ets/secondability/SecondAbility.ts @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import hilog from '@ohos.hilog'; -import window from '@ohos.window'; -import wantConstant from '@ohos.ability.wantConstant'; - -export default class SecondAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - 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/IndexSecond', (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'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; +import wantConstant from '@ohos.ability.wantConstant'; + +export default class SecondAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + 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/IndexSecond', (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/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/module.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/module.json5 index 275c4826c0..cc0bec9536 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/module.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/module.json5 @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2023 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" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "launchType": "standard", - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "SecondAbility", - "srcEntrance": "./ets/secondability/SecondAbility.ts", - "description": "$string:SecondAbility_desc", - "icon": "$media:icon", - "label": "$string:SecondAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "visible": true - } - ] - } +/* + * Copyright (c) 2023 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" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "launchType": "standard", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "SecondAbility", + "srcEntrance": "./ets/secondability/SecondAbility.ts", + "description": "$string:SecondAbility_desc", + "icon": "$media:icon", + "label": "$string:SecondAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/resources/base/element/color.json b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/hvigor/hvigor-config.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/hvigor/hvigor-config.json5 index e5abb715c8..835122515a 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "hvigorVersion": "2.0.0", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "2.0.0" - } -} +/* + * Copyright (c) 2023 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. + */ + +{ + "hvigorVersion": "2.0.0", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "2.0.0" + } +} diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/oh-package.json5 b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/oh-package.json5 index 80dcaf146d..ab9d172f96 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/oh-package.json5 +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/StartRecentAbility/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "myapplication", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "myapplication", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/AppScope/app.json5 b/code/SystemFeature/ApplicationModels/UIExtensionAbility/AppScope/app.json5 index 2f14d2e59d..e520f83e46 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/AppScope/app.json5 +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.uiextensionability", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.uiextensionability", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/AppScope/resources/base/element/string.json b/code/SystemFeature/ApplicationModels/UIExtensionAbility/AppScope/resources/base/element/string.json index d9951e760b..5071f4a359 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "uiextensionability" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "uiextensionability" + } + ] +} diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/build-profile.json5 b/code/SystemFeature/ApplicationModels/UIExtensionAbility/build-profile.json5 index ea6d3ca208..6ae38bd2fb 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/build-profile.json5 +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/build-profile.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2024 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", - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, - "runtimeOS": "OpenHarmony" - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "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/SystemFeature/ApplicationModels/UIExtensionAbility/entry/build-profile.json5 b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/build-profile.json5 index ff39b71eda..caf14acb2d 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/build-profile.json5 +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2024 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2024 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/oh-package.json5 b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/oh-package.json5 index 60744fdbc7..225946cb11 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/oh-package.json5 +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/entryability/EntryAbility.ts b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/entryability/EntryAbility.ts index 053964af92..0c2f4a450e 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2024 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 from '@ohos.app.ability.AbilityConstant'; -import Logger from '../model/Logger'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; - -const TAG: string = 'EntryAbility '; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - Logger.info(TAG, 'Ability onCreate'); - } - - onDestroy() { - Logger.info(TAG, 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - Logger.info(TAG, 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - Logger.error(TAG, 'Failed to load the content.' + JSON.stringify(err)); - return; - } - Logger.info(TAG, 'Succeeded in loading the content.' + JSON.stringify(data)); - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - Logger.info(TAG, 'Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - Logger.info(TAG, 'Ability onForeground'); - } - - onBackground() { - // Ability has back to background - Logger.info(TAG, 'Ability onBackground'); - } -} +/* + * Copyright (c) 2024 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 from '@ohos.app.ability.AbilityConstant'; +import Logger from '../model/Logger'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +const TAG: string = 'EntryAbility '; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + Logger.info(TAG, 'Ability onCreate'); + } + + onDestroy() { + Logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + Logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error(TAG, 'Failed to load the content.' + JSON.stringify(err)); + return; + } + Logger.info(TAG, 'Succeeded in loading the content.' + JSON.stringify(data)); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + Logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + Logger.info(TAG, 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + Logger.info(TAG, 'Ability onBackground'); + } +} diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/model/Logger.ts b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/model/Logger.ts index 140eef6342..2a0e73e7cd 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/model/Logger.ts +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/model/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_EmbeddedUIExtensionAbility]'); \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/pages/Extension.ets b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/pages/Extension.ets index 1b1072ca81..d9d7b7705d 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/pages/Extension.ets +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/pages/Extension.ets @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2024 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 UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import commonEvent from '@ohos.commonEventManager' -let storage = LocalStorage.GetShared(); -const TAG: string = `[testTag] ExtensionPage` - -@Entry(storage) -@Component -struct Extension { - @State message: string = `UIExtension provider`; - private session: UIExtensionContentSession | undefined = storage.get('session'); - - onPageShow() { - console.info(TAG, 'show'); - commonEvent.publish('page_show', (err) => { - console.log('Extension page show'); - }) - } - - build() { - Column() { - Text(this.message) - .fontSize(20) - .fontWeight(FontWeight.Bold) - .textAlign(TextAlign.Center) - } - .alignItems(HorizontalAlign.Center) - .width('100%') - .height('100%') - .justifyContent(FlexAlign.Center) - } +/* + * Copyright (c) 2024 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 UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import commonEvent from '@ohos.commonEventManager' +let storage = LocalStorage.GetShared(); +const TAG: string = `[testTag] ExtensionPage` + +@Entry(storage) +@Component +struct Extension { + @State message: string = `UIExtension provider`; + private session: UIExtensionContentSession | undefined = storage.get('session'); + + onPageShow() { + console.info(TAG, 'show'); + commonEvent.publish('page_show', (err) => { + console.log('Extension page show'); + }) + } + + build() { + Column() { + Text(this.message) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Center) + } + .alignItems(HorizontalAlign.Center) + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/uiextensionability/UIExtensionAbility.ets b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/uiextensionability/UIExtensionAbility.ets index fc3c4201bc..f448fbf3a0 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/uiextensionability/UIExtensionAbility.ets +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/ets/uiextensionability/UIExtensionAbility.ets @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2024 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 Want from '@ohos.app.ability.Want'; -import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; -import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import Logger from '../model/Logger'; - -const TAG: string = 'UIExtensionAbility '; - -export default class UIExtAbility extends UIExtensionAbility { - onCreate() { - Logger.info(TAG, `onCreate`); - } - - onForeground() { - Logger.info(TAG, `onForeground`); - } - - onBackground() { - Logger.info(TAG, `onBackground`); - } - - onDestroy() { - Logger.info(TAG, `onDestroy`); - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - Logger.info(TAG, `onSessionCreate, want: ${JSON.stringify(want)}}`); - let storage: LocalStorage = new LocalStorage(); - storage.setOrCreate('session', session); - session.loadContent('pages/Extension',storage); - } - - onSessionDestroy(session: UIExtensionContentSession) { - Logger.info(TAG, `onSessionDestroy`); - } -} +/* + * Copyright (c) 2024 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 Want from '@ohos.app.ability.Want'; +import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; +import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import Logger from '../model/Logger'; + +const TAG: string = 'UIExtensionAbility '; + +export default class UIExtAbility extends UIExtensionAbility { + onCreate() { + Logger.info(TAG, `onCreate`); + } + + onForeground() { + Logger.info(TAG, `onForeground`); + } + + onBackground() { + Logger.info(TAG, `onBackground`); + } + + onDestroy() { + Logger.info(TAG, `onDestroy`); + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + Logger.info(TAG, `onSessionCreate, want: ${JSON.stringify(want)}}`); + let storage: LocalStorage = new LocalStorage(); + storage.setOrCreate('session', session); + session.loadContent('pages/Extension',storage); + } + + onSessionDestroy(session: UIExtensionContentSession) { + Logger.info(TAG, `onSessionDestroy`); + } +} diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/module.json5 b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/module.json5 index 070c5f1599..ae399e0057 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/module.json5 +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/module.json5 @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2024 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": [ - "phone", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "UIExtensionProvider", - "srcEntry": "./ets/uiextensionability/UIExtensionAbility.ets", - "description": "UIExtensionAbility", - "type": "sys/commonUI", - "exported": true - } - ] - } +/* + * Copyright (c) 2024 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": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "UIExtensionProvider", + "srcEntry": "./ets/uiextensionability/UIExtensionAbility.ets", + "description": "UIExtensionAbility", + "type": "sys/commonUI", + "exported": true + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/resources/base/element/color.json b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/ohosTest/module.json5 b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/ohosTest/module.json5 index 3613514e70..7690747eb4 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/hvigor/hvigor-config.json5 b/code/SystemFeature/ApplicationModels/UIExtensionAbility/hvigor/hvigor-config.json5 index 497c2eb211..44a5bdf236 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/hvigor/hvigor-config.json5 @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "3.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.2" - }, - "execution": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } -} +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "3.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.2" + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } +} diff --git a/code/SystemFeature/ApplicationModels/UIExtensionAbility/oh-package.json5 b/code/SystemFeature/ApplicationModels/UIExtensionAbility/oh-package.json5 index 5a254d117a..336dbf0048 100644 --- a/code/SystemFeature/ApplicationModels/UIExtensionAbility/oh-package.json5 +++ b/code/SystemFeature/ApplicationModels/UIExtensionAbility/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "uiextensionability", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2024 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "uiextensionability", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/AutoFill/AutoFill/AppScope/app.json5 b/code/SystemFeature/AutoFill/AutoFill/AppScope/app.json5 index f60b21ffed..96904f1a10 100644 --- a/code/SystemFeature/AutoFill/AutoFill/AppScope/app.json5 +++ b/code/SystemFeature/AutoFill/AutoFill/AppScope/app.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2023 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.ohos.passwordbox", - "vendor": "ohos", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.ohos.passwordbox", + "vendor": "ohos", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/AutoFill/AutoFill/AppScope/resources/base/element/string.json b/code/SystemFeature/AutoFill/AutoFill/AppScope/resources/base/element/string.json index 56e6f761cc..610e3e845e 100644 --- a/code/SystemFeature/AutoFill/AutoFill/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/AutoFill/AutoFill/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "PasswordBox" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "PasswordBox" + } + ] +} diff --git a/code/SystemFeature/AutoFill/AutoFill/build-profile.json5 b/code/SystemFeature/AutoFill/AutoFill/build-profile.json5 index 81843dac93..7e17a4b329 100644 --- a/code/SystemFeature/AutoFill/AutoFill/build-profile.json5 +++ b/code/SystemFeature/AutoFill/AutoFill/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2023-2024 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", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023-2024 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", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/build-profile.json5 b/code/SystemFeature/AutoFill/AutoFill/entry/build-profile.json5 index 0c8525dfdd..910cc991f5 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/build-profile.json5 +++ b/code/SystemFeature/AutoFill/AutoFill/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/oh-package.json5 b/code/SystemFeature/AutoFill/AutoFill/entry/oh-package.json5 index 60744fdbc7..225946cb11 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/oh-package.json5 +++ b/code/SystemFeature/AutoFill/AutoFill/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillability/AutoFillAbility.ts b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillability/AutoFillAbility.ts index 68fab8e0da..a3cdc0da50 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillability/AutoFillAbility.ts +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillability/AutoFillAbility.ts @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2023-2024 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 type { FillRequest, SaveRequest, FillRequestCallback, SaveRequestCallback } from 'application/AutoFillRequest'; -import { AutoFillExtensionAbility, autoFillManager, UIExtensionContentSession } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const AUTOFILLTYPE: number = 3; -const TAG: string = 'autoFillAbility'; -const DOMAIN_NUMBER: number = 0xFF00; -const BOTTOM_LEFT: number = 6; - -export default class AutoFillAbility extends AutoFillExtensionAbility { - onCreate(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onDestroy'); - } - - onSessionDestroy(session: UIExtensionContentSession): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onSessionDestroy'); - hilog.info(DOMAIN_NUMBER, TAG, 'session content: %{public}s', JSON.stringify(session)); - } - - onForeground(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onForeground'); - } - - onBackground(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onBackground'); - } - - onFillRequest(session: UIExtensionContentSession, request: FillRequest, callback: FillRequestCallback): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onFillRequest'); - hilog.info(DOMAIN_NUMBER, TAG, 'fill requestCallback: %{public}s', JSON.stringify(callback)); - hilog.info(DOMAIN_NUMBER, TAG, 'get request viewData: ', JSON.stringify(request.viewData)); - try { - let storageFill = new LocalStorage( - { - 'session': session, - 'message': 'AutoFill Page', - 'fillCallback': callback, - 'viewData': request.viewData, - 'pageNodeInfos': request.viewData.pageNodeInfos, - 'autoFillExtensionContext': this.context, - 'customData': request.customData - }); - - let size: autoFillManager.PopupSize = { - width: 620, - height: 220 - }; - callback.setAutoFillPopupConfig({ - popupSize: size, - placement: BOTTOM_LEFT - }); - - request.viewData.pageNodeInfos.forEach((item) => { - if (item.autoFillType === AUTOFILLTYPE) { - session.loadContent('autofillpages/AutoFillNewPassWord', storageFill); - } else if (request.customData != undefined) { - session.loadContent('autofillpages/BiometricAuthentication', storageFill); - } else { - session.loadContent('autofillpages/AutoFillControl', storageFill); - } - }); - } catch (err) { - hilog.error(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill failed to load content'); - } - } - - onSaveRequest(session: UIExtensionContentSession, request: SaveRequest, callback: SaveRequestCallback): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onSaveRequest'); - - let storageSave = new LocalStorage( - { - 'session': session, - 'message': 'AutoFill Page', - 'saveCallback': callback, - 'viewData': request.viewData - }); - session.loadContent('autofillpages/SavePage', storageSave); - } -} +/* + * Copyright (c) 2023-2024 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 type { FillRequest, SaveRequest, FillRequestCallback, SaveRequestCallback } from 'application/AutoFillRequest'; +import { AutoFillExtensionAbility, autoFillManager, UIExtensionContentSession } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const AUTOFILLTYPE: number = 3; +const TAG: string = 'autoFillAbility'; +const DOMAIN_NUMBER: number = 0xFF00; +const BOTTOM_LEFT: number = 6; + +export default class AutoFillAbility extends AutoFillExtensionAbility { + onCreate(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onDestroy'); + } + + onSessionDestroy(session: UIExtensionContentSession): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onSessionDestroy'); + hilog.info(DOMAIN_NUMBER, TAG, 'session content: %{public}s', JSON.stringify(session)); + } + + onForeground(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onForeground'); + } + + onBackground(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onBackground'); + } + + onFillRequest(session: UIExtensionContentSession, request: FillRequest, callback: FillRequestCallback): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onFillRequest'); + hilog.info(DOMAIN_NUMBER, TAG, 'fill requestCallback: %{public}s', JSON.stringify(callback)); + hilog.info(DOMAIN_NUMBER, TAG, 'get request viewData: ', JSON.stringify(request.viewData)); + try { + let storageFill = new LocalStorage( + { + 'session': session, + 'message': 'AutoFill Page', + 'fillCallback': callback, + 'viewData': request.viewData, + 'pageNodeInfos': request.viewData.pageNodeInfos, + 'autoFillExtensionContext': this.context, + 'customData': request.customData + }); + + let size: autoFillManager.PopupSize = { + width: 620, + height: 220 + }; + callback.setAutoFillPopupConfig({ + popupSize: size, + placement: BOTTOM_LEFT + }); + + request.viewData.pageNodeInfos.forEach((item) => { + if (item.autoFillType === AUTOFILLTYPE) { + session.loadContent('autofillpages/AutoFillNewPassWord', storageFill); + } else if (request.customData != undefined) { + session.loadContent('autofillpages/BiometricAuthentication', storageFill); + } else { + session.loadContent('autofillpages/AutoFillControl', storageFill); + } + }); + } catch (err) { + hilog.error(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill failed to load content'); + } + } + + onSaveRequest(session: UIExtensionContentSession, request: SaveRequest, callback: SaveRequestCallback): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onSaveRequest'); + + let storageSave = new LocalStorage( + { + 'session': session, + 'message': 'AutoFill Page', + 'saveCallback': callback, + 'viewData': request.viewData + }); + session.loadContent('autofillpages/SavePage', storageSave); + } +} diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/AutoFillControl.ets b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/AutoFillControl.ets index 886243a251..c9cf555d15 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/AutoFillControl.ets +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/AutoFillControl.ets @@ -1,114 +1,114 @@ -/* - * Copyright (c) 2023-2024 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 { BusinessError } from '@ohos.base'; -import { autoFillManager, common } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const storage = LocalStorage.getShared(); -let viewData: autoFillManager.ViewData | undefined = storage.get('viewData'); -let context: common.AutoFillExtensionContext | undefined = storage.get('autoFillExtensionContext'); -const TAG: string = 'autoFill'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct AutoFillControl { - build() { - Row() { - Column() { - List({ space: 10, initialIndex: 0 }) { - ListItem() { - Text($r('app.string.user1')) - .width('100%') - .height(40) - .fontSize(16) - .textAlign(TextAlign.Center) - .borderRadius(5) - } - .onClick(() => { - if (context != undefined) { - let want: Record = {}; - context.reloadInModal({ data: { text: 'User1', want } }).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal successfully User1.'); - }).catch((err: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal failed User1.'); - }) - } - }) - - ListItem() { - Text($r('app.string.user2')) - .width('100%') - .height(40) - .fontSize(16) - .textAlign(TextAlign.Center) - .borderRadius(5) - } - .onClick(() => { - if (viewData != undefined) { - if (context != undefined) { - let want: Record = {}; - context.reloadInModal({ data: { text: 'User2', want } }).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal successfully User2.'); - }).catch((err: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal failed User2.'); - }) - } - } - }) - - ListItem() { - Text($r('app.string.user3')) - .width('100%') - .height(40) - .fontSize(16) - .textAlign(TextAlign.Center) - .borderRadius(5) - } - .onClick(() => { - if (viewData != undefined) { - if (context != undefined) { - let want: Record = {}; - context.reloadInModal({ data: { text: 'User3', want } }).then(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal successfully User3.'); - }).catch((err: BusinessError) => { - hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal failed User3.'); - }) - } - } - }) - } - .listDirection(Axis.Vertical) - .scrollBar(BarState.Off) - .friction(0.6) - .divider({ strokeWidth: 1, color: $r('app.color.placeholderColor'), startMargin: 20, endMargin: 20 }) - .edgeEffect(EdgeEffect.Spring) - .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { - console.info('first' + firstIndex); - console.info('last' + lastIndex); - console.info('center' + centerIndex); - }) - .onScroll((scrollOffset: number, scrollState: ScrollState) => { - console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset); - }) - } - .width('100%') - .shadow(ShadowStyle.OUTER_FLOATING_SM) - } - .height('100%') - .shadow(ShadowStyle.OUTER_FLOATING_SM) - } +/* + * Copyright (c) 2023-2024 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 { BusinessError } from '@ohos.base'; +import { autoFillManager, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const storage = LocalStorage.getShared(); +let viewData: autoFillManager.ViewData | undefined = storage.get('viewData'); +let context: common.AutoFillExtensionContext | undefined = storage.get('autoFillExtensionContext'); +const TAG: string = 'autoFill'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct AutoFillControl { + build() { + Row() { + Column() { + List({ space: 10, initialIndex: 0 }) { + ListItem() { + Text($r('app.string.user1')) + .width('100%') + .height(40) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(5) + } + .onClick(() => { + if (context != undefined) { + let want: Record = {}; + context.reloadInModal({ data: { text: 'User1', want } }).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal successfully User1.'); + }).catch((err: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal failed User1.'); + }) + } + }) + + ListItem() { + Text($r('app.string.user2')) + .width('100%') + .height(40) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(5) + } + .onClick(() => { + if (viewData != undefined) { + if (context != undefined) { + let want: Record = {}; + context.reloadInModal({ data: { text: 'User2', want } }).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal successfully User2.'); + }).catch((err: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal failed User2.'); + }) + } + } + }) + + ListItem() { + Text($r('app.string.user3')) + .width('100%') + .height(40) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(5) + } + .onClick(() => { + if (viewData != undefined) { + if (context != undefined) { + let want: Record = {}; + context.reloadInModal({ data: { text: 'User3', want } }).then(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal successfully User3.'); + }).catch((err: BusinessError) => { + hilog.info(DOMAIN_NUMBER, TAG, 'reloadInModal failed User3.'); + }) + } + } + }) + } + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 1, color: $r('app.color.placeholderColor'), startMargin: 20, endMargin: 20 }) + .edgeEffect(EdgeEffect.Spring) + .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { + console.info('first' + firstIndex); + console.info('last' + lastIndex); + console.info('center' + centerIndex); + }) + .onScroll((scrollOffset: number, scrollState: ScrollState) => { + console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset); + }) + } + .width('100%') + .shadow(ShadowStyle.OUTER_FLOATING_SM) + } + .height('100%') + .shadow(ShadowStyle.OUTER_FLOATING_SM) + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/AutoFillNewPassWord.ets b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/AutoFillNewPassWord.ets index 431a89829e..db80aba105 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/AutoFillNewPassWord.ets +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/AutoFillNewPassWord.ets @@ -1,123 +1,123 @@ -/* - * Copyright (c) 2023-2024 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 { FillRequestCallback, FillResponse } from 'application/AutoFillRequest'; -import ViewData from 'application/ViewData'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -let storage = LocalStorage.getShared(); -let fillCallback: FillRequestCallback | undefined = storage.get('fillCallback'); -let viewData: ViewData | undefined = storage.get('viewData'); -const TAG: string = 'autoFill'; -const DOMAIN_NUMBER: number = 0xFF00; - -function successFunc(data: ViewData) { - if (data.pageNodeInfos.length !== 3) { - hilog.error(DOMAIN_NUMBER, TAG, '%{public}s', 'get unEnough pageNodeInfos, skipping!'); - return; - } - data.pageNodeInfos[2].value = 'user1 new password'; - - hilog.info(DOMAIN_NUMBER, TAG, 'autofill about to success with viewData: %{public}s', JSON.stringify(viewData)); - if (fillCallback) { - let response: FillResponse = { viewData: data }; - fillCallback.onSuccess(response); - } -} - -function cancelFunc() { - if (fillCallback) { - fillCallback.onCancel(); - } -} - -@Entry -@Component -struct AutoFillNewPassWord { - build() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image($r('app.media.ic_public_back')) - .height(24) - .width(24) - .onClick(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'autofill cancel'); - cancelFunc(); - }) - Text($r('app.string.newPassword_title')) - .fontWeight(500) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize(20) - .fontColor($r('app.color.userPassWord_title')) - .margin({ left: '4.4%' }) - }.margin({ top: '8.8%', left: '4.9%' }).height('7.2%') - - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start }) { - Text($r('app.string.passWord')) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize(16) - .fontColor($r('app.color.userPassWord_title')) - .fontWeight(500) - Text($r('app.string.new_Password')) - .fontSize(14) - .fontFamily('HarmonyHeiTi') - .fontWeight(400) - .fontColor($r('app.color.userPassWord_title')) - } - .borderRadius(24) - .backgroundColor($r('app.color.controlBackColor')) - .width('95%') - .height('9.2%') - .padding({ top: '3.8%', left: '3.3%' }) - - Row() { - Text($r('app.string.cancel')) - .backgroundColor($r('app.color.cancelBackColor')) - .borderRadius(20) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize(16) - .fontWeight(500) - .lineHeight(22) - .width('41.7%') - .height('16.5%') - .id('Cancel') - .fontColor($r('app.color.cancelBtnColor')) - .textAlign(TextAlign.Center) - .onClick(() => { - cancelFunc(); - }) - Text($r('app.string.confirm')) - .backgroundColor($r('app.color.cancelBtnColor')) - .borderRadius(20) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize(16) - .fontWeight(500) - .lineHeight(22) - .fontColor($r('app.color.controlBackColor')) - .width('41.7%') - .height('16.5%') - .textAlign(TextAlign.Center) - .margin({ left: '3.3%' }) - .id('confirm') - .onClick(() => { - if (viewData != undefined) { - successFunc(viewData); - } - }) - }.margin({ top: 550 }) - } - .height('100%').backgroundColor($r('app.color.pageBackColor')) - } +/* + * Copyright (c) 2023-2024 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 { FillRequestCallback, FillResponse } from 'application/AutoFillRequest'; +import ViewData from 'application/ViewData'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +let storage = LocalStorage.getShared(); +let fillCallback: FillRequestCallback | undefined = storage.get('fillCallback'); +let viewData: ViewData | undefined = storage.get('viewData'); +const TAG: string = 'autoFill'; +const DOMAIN_NUMBER: number = 0xFF00; + +function successFunc(data: ViewData) { + if (data.pageNodeInfos.length !== 3) { + hilog.error(DOMAIN_NUMBER, TAG, '%{public}s', 'get unEnough pageNodeInfos, skipping!'); + return; + } + data.pageNodeInfos[2].value = 'user1 new password'; + + hilog.info(DOMAIN_NUMBER, TAG, 'autofill about to success with viewData: %{public}s', JSON.stringify(viewData)); + if (fillCallback) { + let response: FillResponse = { viewData: data }; + fillCallback.onSuccess(response); + } +} + +function cancelFunc() { + if (fillCallback) { + fillCallback.onCancel(); + } +} + +@Entry +@Component +struct AutoFillNewPassWord { + build() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Image($r('app.media.ic_public_back')) + .height(24) + .width(24) + .onClick(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'autofill cancel'); + cancelFunc(); + }) + Text($r('app.string.newPassword_title')) + .fontWeight(500) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(20) + .fontColor($r('app.color.userPassWord_title')) + .margin({ left: '4.4%' }) + }.margin({ top: '8.8%', left: '4.9%' }).height('7.2%') + + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start }) { + Text($r('app.string.passWord')) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(16) + .fontColor($r('app.color.userPassWord_title')) + .fontWeight(500) + Text($r('app.string.new_Password')) + .fontSize(14) + .fontFamily('HarmonyHeiTi') + .fontWeight(400) + .fontColor($r('app.color.userPassWord_title')) + } + .borderRadius(24) + .backgroundColor($r('app.color.controlBackColor')) + .width('95%') + .height('9.2%') + .padding({ top: '3.8%', left: '3.3%' }) + + Row() { + Text($r('app.string.cancel')) + .backgroundColor($r('app.color.cancelBackColor')) + .borderRadius(20) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(16) + .fontWeight(500) + .lineHeight(22) + .width('41.7%') + .height('16.5%') + .id('Cancel') + .fontColor($r('app.color.cancelBtnColor')) + .textAlign(TextAlign.Center) + .onClick(() => { + cancelFunc(); + }) + Text($r('app.string.confirm')) + .backgroundColor($r('app.color.cancelBtnColor')) + .borderRadius(20) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(16) + .fontWeight(500) + .lineHeight(22) + .fontColor($r('app.color.controlBackColor')) + .width('41.7%') + .height('16.5%') + .textAlign(TextAlign.Center) + .margin({ left: '3.3%' }) + .id('confirm') + .onClick(() => { + if (viewData != undefined) { + successFunc(viewData); + } + }) + }.margin({ top: 550 }) + } + .height('100%').backgroundColor($r('app.color.pageBackColor')) + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/BiometricAuthentication.ets b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/BiometricAuthentication.ets old mode 100755 new mode 100644 index 46f7371890..07573c9241 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/BiometricAuthentication.ets +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/BiometricAuthentication.ets @@ -1,158 +1,158 @@ -/* - * Copyright (c) 2024 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 { FillRequestCallback, FillResponse } from 'application/AutoFillRequest'; -import ViewData from 'application/ViewData'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { autoFillManager } from '@kit.AbilityKit'; - -const storage = LocalStorage.getShared(); -const TAG: string = 'autoFill'; -const DOMAIN_NUMBER: number = 0xFF00; -let fillCallback: FillRequestCallback | undefined = storage.get('fillCallback'); -let viewData: ViewData | undefined = storage.get('viewData'); -let customData: autoFillManager.CustomData | undefined = storage.get('customData'); - -function successFunc(data: ViewData, userName: string, passWord: string) { - if (data.pageNodeInfos.length !== 2) { - hilog.info(DOMAIN_NUMBER, TAG, 'get unEnough pageNodeInfos, skipping!'); - return; - } else { - data.pageNodeInfos[0].value = userName; - data.pageNodeInfos[1].value = passWord; - } - if (fillCallback) { - let response: FillResponse = { viewData: data }; - fillCallback.onSuccess(response); - } -} - -function cancelFunc() { - if (fillCallback) { - fillCallback.onCancel(); - } -} - -function onFailure() { - if (fillCallback) { - fillCallback.onFailure(); - } -} - -@Entry -@Component -struct BiometricAuthentication { - @State message: Resource = $r('app.string.biological_Certification'); - - build() { - Column() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image($r('app.media.arrow')) - .height(40) - .width(40) - .onClick(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'autofill cancel'); - cancelFunc(); - }) - Text(this.message) - .fontWeight(500) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize(22) - .fontColor($r('app.color.userPassWord_title')) - .margin({ left: '2.4%' }) - }.margin({ top: '13.8%', left: '4.9%' }).height('7.2%') - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Image($r('app.media.svg')) - .height(58) - .width(58) - }.margin({ top: '42.8%' }) - } - .height('70%') - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.End }) { - Column() { - Row() { - Button($r('app.string.success')) - .type(ButtonType.Normal) - .fontSize(16) - .fontWeight(500) - .id('success') - .backgroundColor($r('app.color.cancelBtnColor')) - .borderRadius(20) - .height(40) - .width('86.7%') - .onClick(() => { - if (customData != undefined) { - if (viewData != undefined) { - hilog.info(DOMAIN_NUMBER, TAG, 'Reload in modal custom data is ', JSON.stringify(customData.data)); - let flag = customData.data.text as string; - if (fillCallback != undefined) { - if (flag == 'User1') { - successFunc(viewData, 'user1', '123456'); - } else if (flag == 'User2') { - successFunc(viewData, 'user2', 'abcdef'); - } else if (flag == 'User3') { - successFunc(viewData, 'user3', 'ABCDEF'); - } else { - return; - } - } - } - } - }) - } - .margin({ bottom: '12vp' }) - - Row() { - Button($r('app.string.fail')) - .type(ButtonType.Normal) - .fontSize(16) - .fontWeight(500) - .backgroundColor($r('app.color.cancelBtnColor')) - .borderRadius(20) - .id('fail') - .height(40) - .width('86.7%') - .onClick(() => { - onFailure(); - }) - } - .margin({ bottom: '12vp' }) - - Row() { - Button($r('app.string.onCancel')) - .type(ButtonType.Normal) - .fontSize(16) - .fontWeight(500) - .backgroundColor($r('app.color.cancelColor')) - .fontColor($r('app.color.cancelBtnColor')) - .id('cancel') - .borderRadius(20) - .height(40) - .width('86.7%') - .onClick(() => { - cancelFunc(); - }) - } - } - .margin({ bottom: '44vp' }) - } - .height('30%') - } - .backgroundColor($r('app.color.pageBackColor')).height('100%') - } -} +/* + * Copyright (c) 2024 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 { FillRequestCallback, FillResponse } from 'application/AutoFillRequest'; +import ViewData from 'application/ViewData'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { autoFillManager } from '@kit.AbilityKit'; + +const storage = LocalStorage.getShared(); +const TAG: string = 'autoFill'; +const DOMAIN_NUMBER: number = 0xFF00; +let fillCallback: FillRequestCallback | undefined = storage.get('fillCallback'); +let viewData: ViewData | undefined = storage.get('viewData'); +let customData: autoFillManager.CustomData | undefined = storage.get('customData'); + +function successFunc(data: ViewData, userName: string, passWord: string) { + if (data.pageNodeInfos.length !== 2) { + hilog.info(DOMAIN_NUMBER, TAG, 'get unEnough pageNodeInfos, skipping!'); + return; + } else { + data.pageNodeInfos[0].value = userName; + data.pageNodeInfos[1].value = passWord; + } + if (fillCallback) { + let response: FillResponse = { viewData: data }; + fillCallback.onSuccess(response); + } +} + +function cancelFunc() { + if (fillCallback) { + fillCallback.onCancel(); + } +} + +function onFailure() { + if (fillCallback) { + fillCallback.onFailure(); + } +} + +@Entry +@Component +struct BiometricAuthentication { + @State message: Resource = $r('app.string.biological_Certification'); + + build() { + Column() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Image($r('app.media.arrow')) + .height(40) + .width(40) + .onClick(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'autofill cancel'); + cancelFunc(); + }) + Text(this.message) + .fontWeight(500) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(22) + .fontColor($r('app.color.userPassWord_title')) + .margin({ left: '2.4%' }) + }.margin({ top: '13.8%', left: '4.9%' }).height('7.2%') + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image($r('app.media.svg')) + .height(58) + .width(58) + }.margin({ top: '42.8%' }) + } + .height('70%') + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.End }) { + Column() { + Row() { + Button($r('app.string.success')) + .type(ButtonType.Normal) + .fontSize(16) + .fontWeight(500) + .id('success') + .backgroundColor($r('app.color.cancelBtnColor')) + .borderRadius(20) + .height(40) + .width('86.7%') + .onClick(() => { + if (customData != undefined) { + if (viewData != undefined) { + hilog.info(DOMAIN_NUMBER, TAG, 'Reload in modal custom data is ', JSON.stringify(customData.data)); + let flag = customData.data.text as string; + if (fillCallback != undefined) { + if (flag == 'User1') { + successFunc(viewData, 'user1', '123456'); + } else if (flag == 'User2') { + successFunc(viewData, 'user2', 'abcdef'); + } else if (flag == 'User3') { + successFunc(viewData, 'user3', 'ABCDEF'); + } else { + return; + } + } + } + } + }) + } + .margin({ bottom: '12vp' }) + + Row() { + Button($r('app.string.fail')) + .type(ButtonType.Normal) + .fontSize(16) + .fontWeight(500) + .backgroundColor($r('app.color.cancelBtnColor')) + .borderRadius(20) + .id('fail') + .height(40) + .width('86.7%') + .onClick(() => { + onFailure(); + }) + } + .margin({ bottom: '12vp' }) + + Row() { + Button($r('app.string.onCancel')) + .type(ButtonType.Normal) + .fontSize(16) + .fontWeight(500) + .backgroundColor($r('app.color.cancelColor')) + .fontColor($r('app.color.cancelBtnColor')) + .id('cancel') + .borderRadius(20) + .height(40) + .width('86.7%') + .onClick(() => { + cancelFunc(); + }) + } + } + .margin({ bottom: '44vp' }) + } + .height('30%') + } + .backgroundColor($r('app.color.pageBackColor')).height('100%') + } +} diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/LoginSuccessPage.ets b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/LoginSuccessPage.ets index 3eb96fe7a4..3d69f339dd 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/LoginSuccessPage.ets +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/LoginSuccessPage.ets @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2023 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 LoginSuccessPage { - build() { - Column() { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text($r('app.string.loginSuccess')) - .fontSize(24) - .fontWeight(500) - .fontFamily('HarmonyHeiTi-Medium') - .fontColor($r('app.color.user')) - }.margin({ top: '32.3%' }).width('35%').height('4.1%') - }.backgroundColor($r('app.color.pageBackColor')).height('100%').width('100%') - } -} - +/* + * Copyright (c) 2023 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 LoginSuccessPage { + build() { + Column() { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text($r('app.string.loginSuccess')) + .fontSize(24) + .fontWeight(500) + .fontFamily('HarmonyHeiTi-Medium') + .fontColor($r('app.color.user')) + }.margin({ top: '32.3%' }).width('35%').height('4.1%') + }.backgroundColor($r('app.color.pageBackColor')).height('100%').width('100%') + } +} + diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/RegisterPage.ets b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/RegisterPage.ets index 15ec594b80..b5aeb30e3e 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/RegisterPage.ets +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/RegisterPage.ets @@ -1,194 +1,194 @@ -/* - * Copyright (c) 2023-2024 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 { autoFillManager, common } from '@kit.AbilityKit'; -import { UIContext } from '@ohos.arkui.UIContext'; -import { router, promptAction } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -let options: router.RouterOptions = { - url: 'autofillpages/LoginSuccessPage' -}; -const TAG: string = 'autoFill'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct RegisterPage { - @State registerBtnColor: Resource = $r('app.color.enableColor'); - @State codeNumber: string = ''; - @State isShowLoginBtn: Boolean = false; - private registerSuccess: string = ''; - private context = getContext(this) as common.UIAbilityContext; - - aboutToAppear() { - this.context.resourceManager.getStringValue($r('app.string.registerSuccess')).then((value) => { - this.registerSuccess = value.toString(); - }) - } - - @Builder MyBuilderFunction() { - Text($r('app.string.getCodeNumber')) - .borderRadius(20) - .fontColor($r('app.color.cancelBtnColor')) - .fontWeight(500) - .fontFamily('HarmonyHeiTi-Medium') - .backgroundColor($r('app.color.cancelBackColor')) - .width('33.3%') - .height('80%') - .lineHeight(25) - .textAlign(TextAlign.Center) - .fontSize(16) - .margin({ left: '65%' }) - .onClick(() => { - this.codeNumber = '565789'; - }) - } - - build() { - Column() { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text($r('app.string.Welcome')) - .fontSize(24) - .fontWeight(500) - .fontFamily('HarmonyHeiTi-Medium') - .fontColor($r('app.color.user')) - }.margin({ top: '32.3%' }).width('35%').height('4.1%') - - List() { - ListItemGroup({ style: ListItemGroupStyle.CARD }) { - ListItem({ style: ListItemStyle.CARD }) { - TextInput({ placeholder: $r('app.string.phoneNumber') }) - .type(InputType.PhoneNumber) - .fontFamily('HarmonyHeiTi') - .fontColor($r('app.color.user')) - .fontWeight(400) - .fontSize(16) - .height('100%') - .backgroundColor($r('app.color.controlBackColor')) - .onChange((value: string) => { - if (value) { - this.registerBtnColor = $r('app.color.cancelBtnColor'); - } else { - this.registerBtnColor = $r('app.color.enableColor'); - } - }) - }.padding(0) - - // password container - ListItem({ style: ListItemStyle.CARD }) { - TextInput({ placeholder: $r('app.string.codeNumber'), text: this.codeNumber }) - .fontFamily('HarmonyHeiTi') - .fontColor($r('app.color.user')) - .fontWeight(400) - .height('100%') - .fontSize(16) - .backgroundColor($r('app.color.controlBackColor')) - .onChange((value: string) => { - this.codeNumber = value; - if (value) { - this.registerBtnColor = $r('app.color.cancelBtnColor'); - } else { - this.registerBtnColor = $r('app.color.enableColor'); - } - }) - this.MyBuilderFunction() - } - .margin({ top: 2 }) - .padding(0) - - // newPassword container - ListItem({ style: ListItemStyle.CARD }) { - TextInput({ placeholder: $r('app.string.create_password') }) - .type(InputType.NEW_PASSWORD) - .backgroundColor($r('app.color.controlBackColor')) - .fontFamily('HarmonyHeiTi') - .fontColor($r('app.color.user')) - .fontWeight(400) - .fontSize(16) - .height('100%') - .enableAutoFill(true) - .id('newPassWord') - .onChange((value: string) => { - if (value) { - this.registerBtnColor = $r('app.color.cancelBtnColor'); - } else { - this.registerBtnColor = $r('app.color.enableColor'); - } - }) - }.padding(0).margin({ top: 2 }) - }.divider({ strokeWidth: 0.5, color: $r('app.color.pageBackColor'), startMargin: 15, endMargin: 15 }) - } - .borderRadius(24) - .width('93.3%') - .height('22%') - .margin({ top: '8.6%' }) - - Flex({ justifyContent: FlexAlign.Center, alignContent: FlexAlign.SpaceBetween }) { - if (this.isShowLoginBtn) { - Button($r('app.string.login')) - .width('86.7%') - .height('5.1%') - .fontSize(16) - .fontFamily('HarmonyHeiTi-Medium') - .fontColor($r('app.color.controlBackColor')) - .fontWeight(500) - .backgroundColor(this.registerBtnColor) - .borderRadius(20) - .id('login') - .onClick(() => { - router.pushUrl(options, (err, data) => { - hilog.info(DOMAIN_NUMBER, TAG, 'page jump to LoginSuccessPage page', - JSON.stringify(err), JSON.stringify(data)); - }) - }) - } else { - Button($r('app.string.register_now')) - .width('86.7%') - .height('5.1%') - .fontSize(16) - .fontFamily('HarmonyHeiTi-Medium') - .fontColor($r('app.color.controlBackColor')) - .fontWeight(500) - .backgroundColor(this.registerBtnColor) - .borderRadius(20) - .id('registerNowBtn') - .onClick(() => { - this.isShowLoginBtn = true; - SaveFunc(); - promptAction.showToast({ - message: this.registerSuccess, - duration: 2000, - }) - }) - } - }.margin({ top: '6.3%' }) - }.backgroundColor($r('app.color.pageBackColor')).height('100%') - } -} - -function SaveFunc() { - hilog.info(DOMAIN_NUMBER, TAG, 'send save request'); - let context = AppStorage.get('uiContext'); - hilog.info(DOMAIN_NUMBER, TAG, 'UIContext: ', JSON.stringify(context)); - autoFillManager.requestAutoSave(context, { - onSuccess: () => { - hilog.info(DOMAIN_NUMBER, TAG, 'save request on success'); - }, - onFailure: () => { - hilog.info(DOMAIN_NUMBER, TAG, 'save request on failure'); - } - }); +/* + * Copyright (c) 2023-2024 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 { autoFillManager, common } from '@kit.AbilityKit'; +import { UIContext } from '@ohos.arkui.UIContext'; +import { router, promptAction } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +let options: router.RouterOptions = { + url: 'autofillpages/LoginSuccessPage' +}; +const TAG: string = 'autoFill'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct RegisterPage { + @State registerBtnColor: Resource = $r('app.color.enableColor'); + @State codeNumber: string = ''; + @State isShowLoginBtn: Boolean = false; + private registerSuccess: string = ''; + private context = getContext(this) as common.UIAbilityContext; + + aboutToAppear() { + this.context.resourceManager.getStringValue($r('app.string.registerSuccess')).then((value) => { + this.registerSuccess = value.toString(); + }) + } + + @Builder MyBuilderFunction() { + Text($r('app.string.getCodeNumber')) + .borderRadius(20) + .fontColor($r('app.color.cancelBtnColor')) + .fontWeight(500) + .fontFamily('HarmonyHeiTi-Medium') + .backgroundColor($r('app.color.cancelBackColor')) + .width('33.3%') + .height('80%') + .lineHeight(25) + .textAlign(TextAlign.Center) + .fontSize(16) + .margin({ left: '65%' }) + .onClick(() => { + this.codeNumber = '565789'; + }) + } + + build() { + Column() { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text($r('app.string.Welcome')) + .fontSize(24) + .fontWeight(500) + .fontFamily('HarmonyHeiTi-Medium') + .fontColor($r('app.color.user')) + }.margin({ top: '32.3%' }).width('35%').height('4.1%') + + List() { + ListItemGroup({ style: ListItemGroupStyle.CARD }) { + ListItem({ style: ListItemStyle.CARD }) { + TextInput({ placeholder: $r('app.string.phoneNumber') }) + .type(InputType.PhoneNumber) + .fontFamily('HarmonyHeiTi') + .fontColor($r('app.color.user')) + .fontWeight(400) + .fontSize(16) + .height('100%') + .backgroundColor($r('app.color.controlBackColor')) + .onChange((value: string) => { + if (value) { + this.registerBtnColor = $r('app.color.cancelBtnColor'); + } else { + this.registerBtnColor = $r('app.color.enableColor'); + } + }) + }.padding(0) + + // password container + ListItem({ style: ListItemStyle.CARD }) { + TextInput({ placeholder: $r('app.string.codeNumber'), text: this.codeNumber }) + .fontFamily('HarmonyHeiTi') + .fontColor($r('app.color.user')) + .fontWeight(400) + .height('100%') + .fontSize(16) + .backgroundColor($r('app.color.controlBackColor')) + .onChange((value: string) => { + this.codeNumber = value; + if (value) { + this.registerBtnColor = $r('app.color.cancelBtnColor'); + } else { + this.registerBtnColor = $r('app.color.enableColor'); + } + }) + this.MyBuilderFunction() + } + .margin({ top: 2 }) + .padding(0) + + // newPassword container + ListItem({ style: ListItemStyle.CARD }) { + TextInput({ placeholder: $r('app.string.create_password') }) + .type(InputType.NEW_PASSWORD) + .backgroundColor($r('app.color.controlBackColor')) + .fontFamily('HarmonyHeiTi') + .fontColor($r('app.color.user')) + .fontWeight(400) + .fontSize(16) + .height('100%') + .enableAutoFill(true) + .id('newPassWord') + .onChange((value: string) => { + if (value) { + this.registerBtnColor = $r('app.color.cancelBtnColor'); + } else { + this.registerBtnColor = $r('app.color.enableColor'); + } + }) + }.padding(0).margin({ top: 2 }) + }.divider({ strokeWidth: 0.5, color: $r('app.color.pageBackColor'), startMargin: 15, endMargin: 15 }) + } + .borderRadius(24) + .width('93.3%') + .height('22%') + .margin({ top: '8.6%' }) + + Flex({ justifyContent: FlexAlign.Center, alignContent: FlexAlign.SpaceBetween }) { + if (this.isShowLoginBtn) { + Button($r('app.string.login')) + .width('86.7%') + .height('5.1%') + .fontSize(16) + .fontFamily('HarmonyHeiTi-Medium') + .fontColor($r('app.color.controlBackColor')) + .fontWeight(500) + .backgroundColor(this.registerBtnColor) + .borderRadius(20) + .id('login') + .onClick(() => { + router.pushUrl(options, (err, data) => { + hilog.info(DOMAIN_NUMBER, TAG, 'page jump to LoginSuccessPage page', + JSON.stringify(err), JSON.stringify(data)); + }) + }) + } else { + Button($r('app.string.register_now')) + .width('86.7%') + .height('5.1%') + .fontSize(16) + .fontFamily('HarmonyHeiTi-Medium') + .fontColor($r('app.color.controlBackColor')) + .fontWeight(500) + .backgroundColor(this.registerBtnColor) + .borderRadius(20) + .id('registerNowBtn') + .onClick(() => { + this.isShowLoginBtn = true; + SaveFunc(); + promptAction.showToast({ + message: this.registerSuccess, + duration: 2000, + }) + }) + } + }.margin({ top: '6.3%' }) + }.backgroundColor($r('app.color.pageBackColor')).height('100%') + } +} + +function SaveFunc() { + hilog.info(DOMAIN_NUMBER, TAG, 'send save request'); + let context = AppStorage.get('uiContext'); + hilog.info(DOMAIN_NUMBER, TAG, 'UIContext: ', JSON.stringify(context)); + autoFillManager.requestAutoSave(context, { + onSuccess: () => { + hilog.info(DOMAIN_NUMBER, TAG, 'save request on success'); + }, + onFailure: () => { + hilog.info(DOMAIN_NUMBER, TAG, 'save request on failure'); + } + }); } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/SavePage.ets b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/SavePage.ets index 2a55ec0814..5f880b90c9 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/SavePage.ets +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/autofillpages/SavePage.ets @@ -1,107 +1,107 @@ -/* - * Copyright (c) 2023-2024 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 { SaveRequestCallback } from 'application/AutoFillRequest'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const storage = LocalStorage.getShared(); -const saveRequestCallback: SaveRequestCallback | undefined = storage.get('saveCallback'); - -function SuccessFunc(success: boolean) { - if (saveRequestCallback) { - if (success) { - saveRequestCallback.onSuccess(); - } - saveRequestCallback.onFailure(); - } - hilog.error(0x0000, 'testTag', '%{public}s', 'saveRequestCallback is nullptr!'); -} - -@Entry -@Component -struct SavePage { - build() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image($r('app.media.ic_public_back')) - .height(24) - .width(24) - .onClick(() => { - hilog.info(0x0000, 'testTag', '%{public}s', 'save cancel'); - SuccessFunc(false); - }) - Text($r('app.string.saveInfo')) - .fontWeight(500) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize(20) - .fontColor($r('app.color.userPassWord_title')) - .margin({ left: '4.4%' }) - .id('Save') - }.margin({ top: '8.8%', left: '4.9%' }).height('7.2%') - - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start }) { - Text($r('app.string.passWord')) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize(16) - .fontColor($r('app.color.userPassWord_title')) - .fontWeight(500) - Text($r('app.string.new_Password')) - .fontSize(14) - .fontFamily('HarmonyHeiTi') - .fontWeight(400) - .fontColor($r('app.color.userPassWord_title')) - } - .borderRadius(24) - .backgroundColor($r('app.color.controlBackColor')) - .width('95%') - .height('9.2%') - .padding({ top: '3.8%', left: '3.3%' }) - - Row() { - Text($r('app.string.cancel')) - .backgroundColor($r('app.color.cancelBackColor')) - .borderRadius(20) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize(16) - .fontWeight(500) - .lineHeight(22) - .width('41.7%') - .height('16.5%') - .fontColor($r('app.color.cancelBtnColor')) - .textAlign(TextAlign.Center) - .onClick(() => { - SuccessFunc(false); - }) - Text($r('app.string.confirm')) - .backgroundColor($r('app.color.cancelBtnColor')) - .borderRadius(20) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize(16) - .fontWeight(500) - .lineHeight(22) - .fontColor($r('app.color.controlBackColor')) - .width('41.7%') - .height('16.5%') - .textAlign(TextAlign.Center) - .margin({ left: '3.3%' }) - .id('saveConfirm') - .onClick(() => { - SuccessFunc(true); - }) - }.margin({ top: 550 }) - } - .height('100%').backgroundColor($r('app.color.pageBackColor')) - } +/* + * Copyright (c) 2023-2024 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 { SaveRequestCallback } from 'application/AutoFillRequest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const storage = LocalStorage.getShared(); +const saveRequestCallback: SaveRequestCallback | undefined = storage.get('saveCallback'); + +function SuccessFunc(success: boolean) { + if (saveRequestCallback) { + if (success) { + saveRequestCallback.onSuccess(); + } + saveRequestCallback.onFailure(); + } + hilog.error(0x0000, 'testTag', '%{public}s', 'saveRequestCallback is nullptr!'); +} + +@Entry +@Component +struct SavePage { + build() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Image($r('app.media.ic_public_back')) + .height(24) + .width(24) + .onClick(() => { + hilog.info(0x0000, 'testTag', '%{public}s', 'save cancel'); + SuccessFunc(false); + }) + Text($r('app.string.saveInfo')) + .fontWeight(500) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(20) + .fontColor($r('app.color.userPassWord_title')) + .margin({ left: '4.4%' }) + .id('Save') + }.margin({ top: '8.8%', left: '4.9%' }).height('7.2%') + + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start }) { + Text($r('app.string.passWord')) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(16) + .fontColor($r('app.color.userPassWord_title')) + .fontWeight(500) + Text($r('app.string.new_Password')) + .fontSize(14) + .fontFamily('HarmonyHeiTi') + .fontWeight(400) + .fontColor($r('app.color.userPassWord_title')) + } + .borderRadius(24) + .backgroundColor($r('app.color.controlBackColor')) + .width('95%') + .height('9.2%') + .padding({ top: '3.8%', left: '3.3%' }) + + Row() { + Text($r('app.string.cancel')) + .backgroundColor($r('app.color.cancelBackColor')) + .borderRadius(20) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(16) + .fontWeight(500) + .lineHeight(22) + .width('41.7%') + .height('16.5%') + .fontColor($r('app.color.cancelBtnColor')) + .textAlign(TextAlign.Center) + .onClick(() => { + SuccessFunc(false); + }) + Text($r('app.string.confirm')) + .backgroundColor($r('app.color.cancelBtnColor')) + .borderRadius(20) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(16) + .fontWeight(500) + .lineHeight(22) + .fontColor($r('app.color.controlBackColor')) + .width('41.7%') + .height('16.5%') + .textAlign(TextAlign.Center) + .margin({ left: '3.3%' }) + .id('saveConfirm') + .onClick(() => { + SuccessFunc(true); + }) + }.margin({ top: 550 }) + } + .height('100%').backgroundColor($r('app.color.pageBackColor')) + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/entryability/EntryAbility.ts b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/entryability/EntryAbility.ts index cbd7ab860a..b03513e918 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2023-2024 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 { BusinessError } from '@kit.BasicServicesKit'; -import type { UIContext, window } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'entryAbility'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - AppStorage.link('uiContext'); - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - let storage = new LocalStorage( - { - 'message': 'Index Page', - }); - windowStage.loadContent('pages/Index', storage, (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - - windowStage.getMainWindow((err: BusinessError, data: window.Window) => { - let errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); - // get UIContext instance - let uiContext: UIContext = windowStage.getMainWindowSync().getUIContext(); - PersistentStorage.persistProp('uiContext', uiContext); - }); - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2023-2024 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 { BusinessError } from '@kit.BasicServicesKit'; +import type { UIContext, window } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'entryAbility'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + AppStorage.link('uiContext'); + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + let storage = new LocalStorage( + { + 'message': 'Index Page', + }); + windowStage.loadContent('pages/Index', storage, (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + + windowStage.getMainWindow((err: BusinessError, data: window.Window) => { + let errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); + // get UIContext instance + let uiContext: UIContext = windowStage.getMainWindowSync().getUIContext(); + PersistentStorage.persistProp('uiContext', uiContext); + }); + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/log/Logger.ts b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/log/Logger.ts index 8072a6d5e7..41f3d658f4 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/log/Logger.ts +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/ets/log/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private pre: string = '[Sample_AUTOFILL]'; - private format: string = '%{public}s, %{public}d'; - - constructor(pre: string) { - this.pre = pre; - this.domain = 0xF811; - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.pre, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.pre, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.pre, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.pre, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private pre: string = '[Sample_AUTOFILL]'; + private format: string = '%{public}s, %{public}d'; + + constructor(pre: string) { + this.pre = pre; + this.domain = 0xF811; + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.pre, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.pre, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.pre, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.pre, this.format, args); + } +} + export default new Logger('[Sample_AUTOFILL]'); \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/module.json5 b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/module.json5 index 1532e2c374..9b96195228 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/module.json5 +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/module.json5 @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2023 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "AutoFillAbility", - "srcEntry": "./ets/autofillability/AutoFillAbility.ts", - "description": "$string:AutofillAbility_desc", - "icon": "$media:icon", - "label": "$string:AutofillAbility_label", - "type": "autoFill/password" - } - ] - } +/* + * Copyright (c) 2023 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "AutoFillAbility", + "srcEntry": "./ets/autofillability/AutoFillAbility.ts", + "description": "$string:AutofillAbility_desc", + "icon": "$media:icon", + "label": "$string:AutofillAbility_label", + "type": "autoFill/password" + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/resources/base/element/color.json b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/resources/base/element/color.json index c9116bfc0b..e9df5b0b18 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/resources/base/element/color.json @@ -1,48 +1,48 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "userPassWord_title", - "value": "#000000" - }, - { - "name": "user", - "value": "#182431" - }, - { - "name": "controlBackColor", - "value": "#FFFFFF" - }, - { - "name": "pageBackColor", - "value": "#f1f3f5" - }, - { - "name": "cancelBackColor", - "value": "#1824310c" - }, - { - "name": "cancelBtnColor", - "value": "#0A59F7" - }, - { - "name": "enableColor", - "value": "#bfdbf9" - }, - { - "name": "NoAccountColor", - "value": "#6f7780" - }, - { - "name": "cancelColor", - "value": "#FDE5E9E9" - }, - { - "name": "placeholderColor", - "value": "#fff5eeee" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "userPassWord_title", + "value": "#000000" + }, + { + "name": "user", + "value": "#182431" + }, + { + "name": "controlBackColor", + "value": "#FFFFFF" + }, + { + "name": "pageBackColor", + "value": "#f1f3f5" + }, + { + "name": "cancelBackColor", + "value": "#1824310c" + }, + { + "name": "cancelBtnColor", + "value": "#0A59F7" + }, + { + "name": "enableColor", + "value": "#bfdbf9" + }, + { + "name": "NoAccountColor", + "value": "#6f7780" + }, + { + "name": "cancelColor", + "value": "#FDE5E9E9" + }, + { + "name": "placeholderColor", + "value": "#fff5eeee" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/resources/base/media/arrow.svg b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/resources/base/media/arrow.svg old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/main/resources/base/media/svg.png b/code/SystemFeature/AutoFill/AutoFill/entry/src/main/resources/base/media/svg.png old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/ohosTest/ets/util/Logger.ts b/code/SystemFeature/AutoFill/AutoFill/entry/src/ohosTest/ets/util/Logger.ts index 0bc128a9f5..a82540eaff 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/ohosTest/ets/util/Logger.ts +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/ohosTest/ets/util/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private pre: string = ''; - private format: string = '%{public}s, %{public}s'; - - constructor(pre: string) { - this.pre = pre; - this.domain = 0xF811; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.pre, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.pre, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.pre, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.pre, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private pre: string = ''; + private format: string = '%{public}s, %{public}s'; + + constructor(pre: string) { + this.pre = pre; + this.domain = 0xF811; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.pre, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.pre, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.pre, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.pre, this.format, args); + } +} + export default new Logger('[Sample_AUTOFILL]'); \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/entry/src/ohosTest/module.json5 b/code/SystemFeature/AutoFill/AutoFill/entry/src/ohosTest/module.json5 index 4706623905..c29979a086 100644 --- a/code/SystemFeature/AutoFill/AutoFill/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/AutoFill/AutoFill/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 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 permissioAutoFillSampleTestns and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 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 permissioAutoFillSampleTestns and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/SystemFeature/AutoFill/AutoFill/hvigor/hvigor-config.json5 b/code/SystemFeature/AutoFill/AutoFill/hvigor/hvigor-config.json5 index bbe82f2ceb..5ab34e577b 100644 --- a/code/SystemFeature/AutoFill/AutoFill/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/AutoFill/AutoFill/hvigor/hvigor-config.json5 @@ -1,19 +1,19 @@ -/* - * Copyright (c) 2023-2024 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": { - } +/* + * Copyright (c) 2023-2024 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": { + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/oh-package.json5 b/code/SystemFeature/AutoFill/AutoFill/oh-package.json5 index 9d75f5f96c..878b6f1771 100644 --- a/code/SystemFeature/AutoFill/AutoFill/oh-package.json5 +++ b/code/SystemFeature/AutoFill/AutoFill/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023-2024 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", - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "passwordbox", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} +/* + * Copyright (c) 2023-2024 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", + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "passwordbox", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFill/ohosTest.md b/code/SystemFeature/AutoFill/AutoFill/ohosTest.md index 20e47b961a..d3d3aee969 100644 --- a/code/SystemFeature/AutoFill/AutoFill/ohosTest.md +++ b/code/SystemFeature/AutoFill/AutoFill/ohosTest.md @@ -1,11 +1,11 @@ -# AutoFill测试用例 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------------ | ----------------- | ----------------------------------------------------------- | ------------------------------------------------------------ | -------- | -------- | -| USER_NAME类型和Password类型的autofill控件发起自动填充请求成功 | 位于登录页面 | 1、进入登录界面,点击账号输入框
2、点击任意一个账号 | 1、选择一个账号后页面发生发生跳转生物认证界面,点击成功后页面发生跳转,显示原登录页面,用户名的输入框中填充刚选择的用户名,密码输入框会显示出账号对应的密码
| 否 | Pass | -| newPassword类型的autofill控件发起自动填充请求成功 | 位于注册页面 | 1、进入注册界面
2、点击生成密码输入框
3、点击确认 | 1、 会将生成的密码自动填充到生成密码输入框中 | 是 | Pass | -| 登录页面消失,发起自动保存请求成功 | 位于登录页面 | 1、进入账号密码登录界面
2、输入账号密码
3、点击登录 | 1、点击登录按钮后,页面会先跳转到登录成功页面,随后自动触发OnSaveRequest回调,立即跳转新页面询问用户是否保存当前账号密码,观察日志输出能够接收到OnSaveRequestSuccess信息 | 是 | Pass | -| 用户主动调用requestSave接口成功 | 位于注册页面
| 1、进入注册界面
2、输入账号密码
3、点击立即注册 | 1、点击注册按钮后,页面会先弹出注册成功弹窗,随后触发OnSaveRequest回调,立即跳转新页面询问用户是否保存当前账号密码,观察日志输出能够接收到OnSaveRequestSuccess信息 | 是 | Pass | - +# AutoFill测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------------ | ----------------- | ----------------------------------------------------------- | ------------------------------------------------------------ | -------- | -------- | +| USER_NAME类型和Password类型的autofill控件发起自动填充请求成功 | 位于登录页面 | 1、进入登录界面,点击账号输入框
2、点击任意一个账号 | 1、选择一个账号后页面发生发生跳转生物认证界面,点击成功后页面发生跳转,显示原登录页面,用户名的输入框中填充刚选择的用户名,密码输入框会显示出账号对应的密码
| 否 | Pass | +| newPassword类型的autofill控件发起自动填充请求成功 | 位于注册页面 | 1、进入注册界面
2、点击生成密码输入框
3、点击确认 | 1、 会将生成的密码自动填充到生成密码输入框中 | 是 | Pass | +| 登录页面消失,发起自动保存请求成功 | 位于登录页面 | 1、进入账号密码登录界面
2、输入账号密码
3、点击登录 | 1、点击登录按钮后,页面会先跳转到登录成功页面,随后自动触发OnSaveRequest回调,立即跳转新页面询问用户是否保存当前账号密码,观察日志输出能够接收到OnSaveRequestSuccess信息 | 是 | Pass | +| 用户主动调用requestSave接口成功 | 位于注册页面
| 1、进入注册界面
2、输入账号密码
3、点击立即注册 | 1、点击注册按钮后,页面会先弹出注册成功弹窗,随后触发OnSaveRequest回调,立即跳转新页面询问用户是否保存当前账号密码,观察日志输出能够接收到OnSaveRequestSuccess信息 | 是 | Pass | + diff --git a/code/SystemFeature/AutoFill/AutoFill/screenshots/autoFillControl.jpg b/code/SystemFeature/AutoFill/AutoFill/screenshots/autoFillControl.jpg old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFill/screenshots/biometricauthentication.jpg b/code/SystemFeature/AutoFill/AutoFill/screenshots/biometricauthentication.jpg old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/app.json5 b/code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/app.json5 old mode 100755 new mode 100644 index 0fea96d300..9c702f7cdb --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/app.json5 +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/app.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2024 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.ohos.textautofill", - "vendor": "ohos", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.ohos.textautofill", + "vendor": "ohos", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/resources/base/element/string.json b/code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 56c6dfd8f2..75874dfa9b --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AutoFillDemo" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AutoFillDemo" + } + ] +} diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/resources/base/media/app_icon.png b/code/SystemFeature/AutoFill/AutoFillScenarioization/AppScope/resources/base/media/app_icon.png old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/README_zh.md b/code/SystemFeature/AutoFill/AutoFillScenarioization/README_zh.md old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/build-profile.json5 b/code/SystemFeature/AutoFill/AutoFillScenarioization/build-profile.json5 old mode 100755 new mode 100644 index af6af27aa9..863ca041c8 --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/build-profile.json5 +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/build-profile.json5 @@ -1,43 +1,43 @@ -/** - * Copyright (c) 2024 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", - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/** + * Copyright (c) 2024 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", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/build-profile.json5 b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/build-profile.json5 old mode 100755 new mode 100644 index 1dd2b4d46b..da1ea711ff --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/build-profile.json5 +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2024 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2024 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/hvigorfile.ts b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/oh-package.json5 b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/oh-package.json5 old mode 100755 new mode 100644 index 90bacec460..19b9234a98 --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/oh-package.json5 +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/application/ItemListData.ts b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/application/ItemListData.ts old mode 100755 new mode 100644 index cbe70b4e21..b6247eaf54 --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/application/ItemListData.ts +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/application/ItemListData.ts @@ -1,17 +1,17 @@ -/* - * Copyright (c) 2024 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 let nameList: Array = ['lily', 'linda', 'john', 'tom', 'peter']; +/* + * Copyright (c) 2024 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 let nameList: Array = ['lily', 'linda', 'john', 'tom', 'peter']; export let phoneList: Array = ['15590031233', '19232466542', '13352589963', '13315584211']; \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillability/TextAutoFillAbility.ts b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillability/TextAutoFillAbility.ts old mode 100755 new mode 100644 index 0ff7188f9e..179e5e4caa --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillability/TextAutoFillAbility.ts +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillability/TextAutoFillAbility.ts @@ -1,117 +1,117 @@ -/* - * Copyright (c) 2024 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 { autoFillManager, AutoFillExtensionAbility, UIExtensionContentSession } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'autoFill'; -const DOMAIN_NUMBER: number = 0xFF00; -const BOTTOM_LEFT: number = 6; - -function suggestWords(input: string, words: string[]): string[] { - if (input.length < 1) { - return []; // 如果输入的字符少于1个,则不提供联想 - } - return words.filter(word => word.includes(input)); -} - -export default class TextAutoFillAbility extends AutoFillExtensionAbility { - onCreate(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onCreate'); - AppStorage.setOrCreate('contextEvent', this.context); - } - - onDestroy(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onDestroy'); - } - - onSessionDestroy(session: UIExtensionContentSession) { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onSessionDestroy'); - hilog.info(DOMAIN_NUMBER, TAG, 'session content: %{public}s', JSON.stringify(session)); - } - - onForeground(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onForeground'); - } - - onBackground(): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onBackground'); - } - - onUpdateRequest(request: autoFillManager.UpdateRequest): void { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onUpdateRequest'); - let storage = LocalStorage.getShared(); - let fillCallback = storage.get('fillCallback'); - let size: autoFillManager.PopupSize = { - width: 656, - height: 149 - }; - fillCallback.setAutoFillPopupConfig({ - popupSize: size, - placement: BOTTOM_LEFT - }); - let nameList: string = ''; - for (let i = 0; i < request.viewData.pageNodeInfos.length; i++) { - nameList = request.viewData.pageNodeInfos[i].value; - } - const words = ['lily', 'linda', 'john', 'tom', 'peter']; - let suggestions: Array = suggestWords(nameList, words); - - request.viewData.pageNodeInfos.find((item) => { - if (item.isFocus && item.value.length != 0 && item.autoFillType == autoFillManager.AutoFillType.PERSON_FULL_NAME) { - this.context.eventHub.emit('updateRequestData', suggestions); - } - }) - } - - onFillRequest(session: UIExtensionContentSession, request: autoFillManager.FillRequest, callback: autoFillManager.FillRequestCallback) { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onFillRequest'); - AppStorage.setOrCreate('interface', 'actionStr'); - try { - let storage_fill = new LocalStorage( - { - 'session': session, - 'message': 'AutoFill Page', - 'fillCallback': callback, - 'viewData': request.viewData, - 'pageNodeInfos': request.viewData.pageNodeInfos, - 'autoFillType': request.type - }); - let size: autoFillManager.PopupSize = { - width: 656, - height: 220 - }; - callback.setAutoFillPopupConfig({ - popupSize: size, - placement: BOTTOM_LEFT - }); - session.loadContent('autofillpages/SelectorList', storage_fill); - } catch (err) { - hilog.error(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill failed to load content'); - } - } - - onSaveRequest(session: UIExtensionContentSession, request: autoFillManager.SaveRequest, callback: autoFillManager.SaveRequestCallback) { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onSaveRequest'); - let storage_save = new LocalStorage( - { - 'session': session, - 'message': 'AutoFill Page', - 'saveCallback': callback, - 'viewData': request.viewData - }); - session.loadContent('autofillpages/SavePage', storage_save); - } +/* + * Copyright (c) 2024 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 { autoFillManager, AutoFillExtensionAbility, UIExtensionContentSession } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'autoFill'; +const DOMAIN_NUMBER: number = 0xFF00; +const BOTTOM_LEFT: number = 6; + +function suggestWords(input: string, words: string[]): string[] { + if (input.length < 1) { + return []; // 如果输入的字符少于1个,则不提供联想 + } + return words.filter(word => word.includes(input)); +} + +export default class TextAutoFillAbility extends AutoFillExtensionAbility { + onCreate(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onCreate'); + AppStorage.setOrCreate('contextEvent', this.context); + } + + onDestroy(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onDestroy'); + } + + onSessionDestroy(session: UIExtensionContentSession) { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onSessionDestroy'); + hilog.info(DOMAIN_NUMBER, TAG, 'session content: %{public}s', JSON.stringify(session)); + } + + onForeground(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onForeground'); + } + + onBackground(): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onBackground'); + } + + onUpdateRequest(request: autoFillManager.UpdateRequest): void { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onUpdateRequest'); + let storage = LocalStorage.getShared(); + let fillCallback = storage.get('fillCallback'); + let size: autoFillManager.PopupSize = { + width: 656, + height: 149 + }; + fillCallback.setAutoFillPopupConfig({ + popupSize: size, + placement: BOTTOM_LEFT + }); + let nameList: string = ''; + for (let i = 0; i < request.viewData.pageNodeInfos.length; i++) { + nameList = request.viewData.pageNodeInfos[i].value; + } + const words = ['lily', 'linda', 'john', 'tom', 'peter']; + let suggestions: Array = suggestWords(nameList, words); + + request.viewData.pageNodeInfos.find((item) => { + if (item.isFocus && item.value.length != 0 && item.autoFillType == autoFillManager.AutoFillType.PERSON_FULL_NAME) { + this.context.eventHub.emit('updateRequestData', suggestions); + } + }) + } + + onFillRequest(session: UIExtensionContentSession, request: autoFillManager.FillRequest, callback: autoFillManager.FillRequestCallback) { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onFillRequest'); + AppStorage.setOrCreate('interface', 'actionStr'); + try { + let storage_fill = new LocalStorage( + { + 'session': session, + 'message': 'AutoFill Page', + 'fillCallback': callback, + 'viewData': request.viewData, + 'pageNodeInfos': request.viewData.pageNodeInfos, + 'autoFillType': request.type + }); + let size: autoFillManager.PopupSize = { + width: 656, + height: 220 + }; + callback.setAutoFillPopupConfig({ + popupSize: size, + placement: BOTTOM_LEFT + }); + session.loadContent('autofillpages/SelectorList', storage_fill); + } catch (err) { + hilog.error(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill failed to load content'); + } + } + + onSaveRequest(session: UIExtensionContentSession, request: autoFillManager.SaveRequest, callback: autoFillManager.SaveRequestCallback) { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'autofill onSaveRequest'); + let storage_save = new LocalStorage( + { + 'session': session, + 'message': 'AutoFill Page', + 'saveCallback': callback, + 'viewData': request.viewData + }); + session.loadContent('autofillpages/SavePage', storage_save); + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/ReturnMainPage.ets b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/ReturnMainPage.ets old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/SavePage.ets b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/SavePage.ets old mode 100755 new mode 100644 index 537e8fe4e2..3b8c82d36d --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/SavePage.ets +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/SavePage.ets @@ -1,104 +1,104 @@ -/* - * Copyright (c) 2024 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 { autoFillManager } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -let storage = LocalStorage.getShared(); -let saveRequestCallback = storage.get('saveCallback'); -const TAG: string = 'autoFill'; -const DOMAIN_NUMBER: number = 0xFF00; - -function SuccessFunc(success: boolean) { - if (saveRequestCallback) { - if (success) { - saveRequestCallback.onSuccess(); - hilog.info(DOMAIN_NUMBER, TAG, 'saveRequestCallback success'); - return; - } - saveRequestCallback.onFailure(); - hilog.info(DOMAIN_NUMBER, TAG, 'saveRequestCallback onFailure'); - } - hilog.error(DOMAIN_NUMBER, TAG, 'saveRequestCallback is nullptr!'); -} - -@Entry -@Component -struct SavePage { - build() { - Column() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image($r('app.media.arrow')) - .height(44) - .width(44) - .onClick(() => { - SuccessFunc(false); - }) - Text($r('app.string.scenarioization')) - .fontWeight(500) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize(22) - .margin({ left: '2.4%' }) - }.margin({ top: '12.8%', left: '4.9%' }) - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Image($r('app.media.style')) - .height('448px') - .width('448px') - }.margin({ top: '19.8%' }) - }.height('70%') - - Column() { - Column() { - Row() { - Button($r('app.string.cancel')) - .type(ButtonType.Normal) - .borderRadius(25) - .fontSize(16) - .fontWeight(400) - .margin({ right: 6 }) - .fontColor($r('app.color.cancelBtnColor')) - .backgroundColor($r('app.color.mainInterface')) - .height('20.8%') - .width('44.5%') - .onClick(() => { - SuccessFunc(true); - }) - - Button($r('app.string.confirm')) - .type(ButtonType.Normal) - .borderRadius(25) - .fontSize(16) - .fontWeight(400) - .margin({ left: 6 }) - .fontColor($r('app.color.mainInterface')) - .id('saveOnly') - .backgroundColor($r('app.color.cancelBtnColor')) - .height('20.8%') - .width('44.5%') - .onClick(() => { - SuccessFunc(false); - }) - } - } - .margin({ bottom: '44px' }) - } - .height('30%') - .justifyContent(FlexAlign.End) - .alignItems(HorizontalAlign.Center) - }.backgroundColor($r('app.color.pageBackColor')).height('100%') - } +/* + * Copyright (c) 2024 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 { autoFillManager } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +let storage = LocalStorage.getShared(); +let saveRequestCallback = storage.get('saveCallback'); +const TAG: string = 'autoFill'; +const DOMAIN_NUMBER: number = 0xFF00; + +function SuccessFunc(success: boolean) { + if (saveRequestCallback) { + if (success) { + saveRequestCallback.onSuccess(); + hilog.info(DOMAIN_NUMBER, TAG, 'saveRequestCallback success'); + return; + } + saveRequestCallback.onFailure(); + hilog.info(DOMAIN_NUMBER, TAG, 'saveRequestCallback onFailure'); + } + hilog.error(DOMAIN_NUMBER, TAG, 'saveRequestCallback is nullptr!'); +} + +@Entry +@Component +struct SavePage { + build() { + Column() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Image($r('app.media.arrow')) + .height(44) + .width(44) + .onClick(() => { + SuccessFunc(false); + }) + Text($r('app.string.scenarioization')) + .fontWeight(500) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(22) + .margin({ left: '2.4%' }) + }.margin({ top: '12.8%', left: '4.9%' }) + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image($r('app.media.style')) + .height('448px') + .width('448px') + }.margin({ top: '19.8%' }) + }.height('70%') + + Column() { + Column() { + Row() { + Button($r('app.string.cancel')) + .type(ButtonType.Normal) + .borderRadius(25) + .fontSize(16) + .fontWeight(400) + .margin({ right: 6 }) + .fontColor($r('app.color.cancelBtnColor')) + .backgroundColor($r('app.color.mainInterface')) + .height('20.8%') + .width('44.5%') + .onClick(() => { + SuccessFunc(true); + }) + + Button($r('app.string.confirm')) + .type(ButtonType.Normal) + .borderRadius(25) + .fontSize(16) + .fontWeight(400) + .margin({ left: 6 }) + .fontColor($r('app.color.mainInterface')) + .id('saveOnly') + .backgroundColor($r('app.color.cancelBtnColor')) + .height('20.8%') + .width('44.5%') + .onClick(() => { + SuccessFunc(false); + }) + } + } + .margin({ bottom: '44px' }) + } + .height('30%') + .justifyContent(FlexAlign.End) + .alignItems(HorizontalAlign.Center) + }.backgroundColor($r('app.color.pageBackColor')).height('100%') + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/SelectorList.ets b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/SelectorList.ets old mode 100755 new mode 100644 index eec2f1e38d..5262c418bc --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/SelectorList.ets +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/autofillpages/SelectorList.ets @@ -1,113 +1,113 @@ -/* - * Copyright (c) 2024 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 { nameList, phoneList } from '../application/ItemListData'; -import { common, autoFillManager } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -let storage = LocalStorage.getShared(); -let fillCallback = storage.get('fillCallback'); -let viewData: autoFillManager.ViewData | undefined = storage.get('viewData'); -let type: number | undefined = storage.get('autoFillType'); -let context = AppStorage.get('contextEvent') as common.UIAbilityContext; -let itemList: Array | undefined; -let typeToDataMap: Map> = new Map(); -const TAG: string = 'autoFill'; -const DOMAIN_NUMBER: number = 0xFF00; -const FULL_PHONE_NUMBER: number = 15; -const PERSON_FULL_NAME: number = 10; - -typeToDataMap.set(PERSON_FULL_NAME, nameList); -typeToDataMap.set(FULL_PHONE_NUMBER, phoneList); - -function successFunc(index: number, item: string) { - if (viewData && index >= 0 && type != undefined) { - itemList = typeToDataMap.get(type); - if (itemList) { - for (let i = 0; i < viewData.pageNodeInfos.length; i++) { - if (viewData.pageNodeInfos[i].isFocus === true) { - viewData.pageNodeInfos[i].value = item; - break; - } - } - } - if (fillCallback) { - let response: autoFillManager.FillResponse = { viewData: viewData }; - fillCallback.onSuccess(response); - } - } -} - -@Entry -@Component -struct SelectorList { - @State itemListData: Array = []; - - aboutToAppear(): void { - if (type != undefined) { - let maybeUndefined: Array | undefined = typeToDataMap.get(type); - if (maybeUndefined != undefined) { - this.itemListData = maybeUndefined; - } - } - context.eventHub.on('updateRequestData', (eventData: Array) => { - hilog.info(DOMAIN_NUMBER, TAG, 'eventHub called' + eventData); - this.itemListData = eventData; - }); - } - - build() { - Row() { - Column() { - List({ space: 10, initialIndex: 0 }) { - ForEach(this.itemListData, (item: string, index: number) => { - ListItem() { - Text(item ? item : '') - .width('100%') - .height(40) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .textAlign(TextAlign.Start) - .margin({ left: '4.8%' }) - .borderRadius($r('sys.float.ohos_id_corner_radius_card')) - } - .onClick(() => { - hilog.info(DOMAIN_NUMBER, TAG, 'click item: ', item); - successFunc(index, item); - }) - }) - } - .listDirection(Axis.Vertical) - .scrollBar(BarState.Off) - .friction(0.6) - .divider({ strokeWidth: 1, color: $r('app.color.placeholderColor'), startMargin: 20, endMargin: 20 }) - .edgeEffect(EdgeEffect.Spring) - .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { - hilog.info(DOMAIN_NUMBER, TAG, 'first' + firstIndex); - hilog.info(DOMAIN_NUMBER, TAG, 'last' + lastIndex); - hilog.info(DOMAIN_NUMBER, TAG, 'center' + centerIndex); - }) - .onScroll((scrollOffset: number, scrollState: ScrollState) => { - hilog.info(DOMAIN_NUMBER, TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + - scrollOffset); - }) - } - .width('100%') - .shadow(ShadowStyle.OUTER_FLOATING_SM) - } - .height('100%') - .shadow(ShadowStyle.OUTER_FLOATING_SM) - } +/* + * Copyright (c) 2024 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 { nameList, phoneList } from '../application/ItemListData'; +import { common, autoFillManager } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +let storage = LocalStorage.getShared(); +let fillCallback = storage.get('fillCallback'); +let viewData: autoFillManager.ViewData | undefined = storage.get('viewData'); +let type: number | undefined = storage.get('autoFillType'); +let context = AppStorage.get('contextEvent') as common.UIAbilityContext; +let itemList: Array | undefined; +let typeToDataMap: Map> = new Map(); +const TAG: string = 'autoFill'; +const DOMAIN_NUMBER: number = 0xFF00; +const FULL_PHONE_NUMBER: number = 15; +const PERSON_FULL_NAME: number = 10; + +typeToDataMap.set(PERSON_FULL_NAME, nameList); +typeToDataMap.set(FULL_PHONE_NUMBER, phoneList); + +function successFunc(index: number, item: string) { + if (viewData && index >= 0 && type != undefined) { + itemList = typeToDataMap.get(type); + if (itemList) { + for (let i = 0; i < viewData.pageNodeInfos.length; i++) { + if (viewData.pageNodeInfos[i].isFocus === true) { + viewData.pageNodeInfos[i].value = item; + break; + } + } + } + if (fillCallback) { + let response: autoFillManager.FillResponse = { viewData: viewData }; + fillCallback.onSuccess(response); + } + } +} + +@Entry +@Component +struct SelectorList { + @State itemListData: Array = []; + + aboutToAppear(): void { + if (type != undefined) { + let maybeUndefined: Array | undefined = typeToDataMap.get(type); + if (maybeUndefined != undefined) { + this.itemListData = maybeUndefined; + } + } + context.eventHub.on('updateRequestData', (eventData: Array) => { + hilog.info(DOMAIN_NUMBER, TAG, 'eventHub called' + eventData); + this.itemListData = eventData; + }); + } + + build() { + Row() { + Column() { + List({ space: 10, initialIndex: 0 }) { + ForEach(this.itemListData, (item: string, index: number) => { + ListItem() { + Text(item ? item : '') + .width('100%') + .height(40) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .textAlign(TextAlign.Start) + .margin({ left: '4.8%' }) + .borderRadius($r('sys.float.ohos_id_corner_radius_card')) + } + .onClick(() => { + hilog.info(DOMAIN_NUMBER, TAG, 'click item: ', item); + successFunc(index, item); + }) + }) + } + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 1, color: $r('app.color.placeholderColor'), startMargin: 20, endMargin: 20 }) + .edgeEffect(EdgeEffect.Spring) + .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { + hilog.info(DOMAIN_NUMBER, TAG, 'first' + firstIndex); + hilog.info(DOMAIN_NUMBER, TAG, 'last' + lastIndex); + hilog.info(DOMAIN_NUMBER, TAG, 'center' + centerIndex); + }) + .onScroll((scrollOffset: number, scrollState: ScrollState) => { + hilog.info(DOMAIN_NUMBER, TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + + scrollOffset); + }) + } + .width('100%') + .shadow(ShadowStyle.OUTER_FLOATING_SM) + } + .height('100%') + .shadow(ShadowStyle.OUTER_FLOATING_SM) + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/entryability/EntryAbility.ts b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/entryability/EntryAbility.ts old mode 100755 new mode 100644 index c611aa56f0..a15ab48dd6 --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,63 +1,63 @@ -/* - * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit'; -import { UIContext, window } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'entryAbility'; -const DOMAIN_NUMBER: number = 0xFF00; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); - AppStorage.link('uiContext'); - } - - onDestroy() { - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', - JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', - JSON.stringify(data) ?? ''); - let uiContext: UIContext = windowStage.getMainWindowSync().getUIContext(); - PersistentStorage.persistProp('uiContext', uiContext); - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground'); - } - - onBackground() { - // Ability has back to background - hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground'); - } +/* + * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit'; +import { UIContext, window } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'entryAbility'; +const DOMAIN_NUMBER: number = 0xFF00; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate'); + AppStorage.link('uiContext'); + } + + onDestroy() { + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', + JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? ''); + let uiContext: UIContext = windowStage.getMainWindowSync().getUIContext(); + PersistentStorage.persistProp('uiContext', uiContext); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground'); + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/pages/Index.ets b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/pages/Index.ets old mode 100755 new mode 100644 index ee0e377199..a112c160e5 --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/pages/Index.ets +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/ets/pages/Index.ets @@ -1,170 +1,170 @@ -/* - * Copyright (c) 2024 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 { router } from '@kit.ArkUI'; -import { autoFillManager } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = 'autoFill'; -const DOMAIN_NUMBER: number = 0xFF00; - -@Entry -@Component -struct Index { - @State inputTxt: string = ''; - - build() { - Column() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Text($r('app.string.scenarioization')) - .fontWeight(500) - .fontFamily('HarmonyHeiTi-Medium') - .fontSize($r('sys.float.ohos_id_text_size_headline6')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .padding({ - left: $r('sys.float.ohos_id_max_padding_start'), - right: $r('sys.float.ohos_id_max_padding_end') - }) - }.margin({ top: '14.2%' }).height('7.2%') - - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Column() { - Row() { - Text($r('app.string.settingType')) - .fontColor($r('app.color.TextColor')) - .fontSize(14) - .fontWeight(400) - .textAlign(TextAlign.Start) - .width('91%') - .margin({ top: 5, left: -7.5 }) - } - - Row() { - TextInput({ placeholder: $r('app.string.phone_Number'), text: this.inputTxt }) - .contentType(ContentType.FULL_PHONE_NUMBER) - .height('9.4%') - .width('91%') - .fontWeight(FontWeight.Bolder) - .placeholderColor($r('app.color.TextColor')) - .backgroundColor($r('app.color.backgroundColor')) - .id('password1') - .fontSize(16) - .fontWeight(400) - .borderStyle(BorderStyle.Solid) - .enableAutoFill(true) - .borderRadius(25) - .onChange(() => { - }) - .margin({ top: '8vp' }) - } - }.margin({ top: '7.1%' }) - } - - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Column() { - Row() { - Text($r('app.string.setTypeName')) - .fontColor($r('app.color.TextColor')) - .fontSize(14) - .fontWeight(400) - .textAlign(TextAlign.Start) - .width('91%') - .margin({ top: 5, left: -7.5 }) - } - - Row() { - TextInput({ placeholder: $r('app.string.person_Full_Name'), text: this.inputTxt }) - .contentType(ContentType.PERSON_FULL_NAME) - .height('9.4%') - .width('91%') - .fontWeight(FontWeight.Bold) - .placeholderColor($r('app.color.TextColor')) - .backgroundColor($r('app.color.backgroundColor')) - .fontSize(16) - .fontWeight(400) - .id('password3') - .borderStyle(BorderStyle.Solid) - .enableAutoFill(true) - .borderRadius(25) - .onChange(() => { - }) - .margin({ top: '8vp' }) - } - } - } - .margin({ top: '20vp' }) - }.height('70%') - - Column() { - Button() { - Text($r('app.string.saveData')) - .fontSize(16) - .fontWeight(400) - .fontColor($r('app.color.backgroundColor')) - } - .type(ButtonType.Normal) - .borderRadius(25) - .margin({ bottom: '12vp' }) - .backgroundColor($r('app.color.cancelBtnColor')) - .width('91%') - .height('19.4%') - .id('save') - .onClick(() => { - let context = AppStorage.get('uiContext'); - if (context == null) { - hilog.info(DOMAIN_NUMBER, TAG, 'UIContext is null. '); - } - hilog.info(DOMAIN_NUMBER, TAG, 'UIContext: ', JSON.stringify(context)); - try { - autoFillManager.requestAutoSave(context, { - onSuccess: () => { - hilog.info(DOMAIN_NUMBER, TAG, 'save request on success'); - }, - onFailure: () => { - hilog.info(DOMAIN_NUMBER, TAG, 'save request on failure'); - } - }); - } catch (err) { - hilog.error(DOMAIN_NUMBER, TAG, 'save err', JSON.stringify(err)); - } - }) - - Button() { - Text($r('app.string.switchInterface')) - .fontSize(16) - .fontWeight(400) - .fontColor($r('app.color.cancelBtnColor')) - } - .type(ButtonType.Normal) - .borderRadius(25) - .backgroundColor($r('app.color.mainInterface')) - .width('91%') - .height('19.4%') - .margin({ bottom: '44px' }) - .id('changInterface') - .onClick(() => { - router.pushUrl({ - url: 'autofillpages/ReturnMainPage', - }) - }) - } - .height('30%') - .justifyContent(FlexAlign.End) - }.backgroundColor($r('app.color.pageBackColor')).height('100%') - } +/* + * Copyright (c) 2024 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 { router } from '@kit.ArkUI'; +import { autoFillManager } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = 'autoFill'; +const DOMAIN_NUMBER: number = 0xFF00; + +@Entry +@Component +struct Index { + @State inputTxt: string = ''; + + build() { + Column() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Text($r('app.string.scenarioization')) + .fontWeight(500) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize($r('sys.float.ohos_id_text_size_headline6')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .padding({ + left: $r('sys.float.ohos_id_max_padding_start'), + right: $r('sys.float.ohos_id_max_padding_end') + }) + }.margin({ top: '14.2%' }).height('7.2%') + + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Column() { + Row() { + Text($r('app.string.settingType')) + .fontColor($r('app.color.TextColor')) + .fontSize(14) + .fontWeight(400) + .textAlign(TextAlign.Start) + .width('91%') + .margin({ top: 5, left: -7.5 }) + } + + Row() { + TextInput({ placeholder: $r('app.string.phone_Number'), text: this.inputTxt }) + .contentType(ContentType.FULL_PHONE_NUMBER) + .height('9.4%') + .width('91%') + .fontWeight(FontWeight.Bolder) + .placeholderColor($r('app.color.TextColor')) + .backgroundColor($r('app.color.backgroundColor')) + .id('password1') + .fontSize(16) + .fontWeight(400) + .borderStyle(BorderStyle.Solid) + .enableAutoFill(true) + .borderRadius(25) + .onChange(() => { + }) + .margin({ top: '8vp' }) + } + }.margin({ top: '7.1%' }) + } + + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Column() { + Row() { + Text($r('app.string.setTypeName')) + .fontColor($r('app.color.TextColor')) + .fontSize(14) + .fontWeight(400) + .textAlign(TextAlign.Start) + .width('91%') + .margin({ top: 5, left: -7.5 }) + } + + Row() { + TextInput({ placeholder: $r('app.string.person_Full_Name'), text: this.inputTxt }) + .contentType(ContentType.PERSON_FULL_NAME) + .height('9.4%') + .width('91%') + .fontWeight(FontWeight.Bold) + .placeholderColor($r('app.color.TextColor')) + .backgroundColor($r('app.color.backgroundColor')) + .fontSize(16) + .fontWeight(400) + .id('password3') + .borderStyle(BorderStyle.Solid) + .enableAutoFill(true) + .borderRadius(25) + .onChange(() => { + }) + .margin({ top: '8vp' }) + } + } + } + .margin({ top: '20vp' }) + }.height('70%') + + Column() { + Button() { + Text($r('app.string.saveData')) + .fontSize(16) + .fontWeight(400) + .fontColor($r('app.color.backgroundColor')) + } + .type(ButtonType.Normal) + .borderRadius(25) + .margin({ bottom: '12vp' }) + .backgroundColor($r('app.color.cancelBtnColor')) + .width('91%') + .height('19.4%') + .id('save') + .onClick(() => { + let context = AppStorage.get('uiContext'); + if (context == null) { + hilog.info(DOMAIN_NUMBER, TAG, 'UIContext is null. '); + } + hilog.info(DOMAIN_NUMBER, TAG, 'UIContext: ', JSON.stringify(context)); + try { + autoFillManager.requestAutoSave(context, { + onSuccess: () => { + hilog.info(DOMAIN_NUMBER, TAG, 'save request on success'); + }, + onFailure: () => { + hilog.info(DOMAIN_NUMBER, TAG, 'save request on failure'); + } + }); + } catch (err) { + hilog.error(DOMAIN_NUMBER, TAG, 'save err', JSON.stringify(err)); + } + }) + + Button() { + Text($r('app.string.switchInterface')) + .fontSize(16) + .fontWeight(400) + .fontColor($r('app.color.cancelBtnColor')) + } + .type(ButtonType.Normal) + .borderRadius(25) + .backgroundColor($r('app.color.mainInterface')) + .width('91%') + .height('19.4%') + .margin({ bottom: '44px' }) + .id('changInterface') + .onClick(() => { + router.pushUrl({ + url: 'autofillpages/ReturnMainPage', + }) + }) + } + .height('30%') + .justifyContent(FlexAlign.End) + }.backgroundColor($r('app.color.pageBackColor')).height('100%') + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/module.json5 b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/module.json5 old mode 100755 new mode 100644 index bbb80ad288..261e3215c8 --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/module.json5 +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/module.json5 @@ -1,63 +1,63 @@ -/* - * Copyright (c) 2024 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "TextAutoFillAbility", - "srcEntry": "./ets/autofillability/TextAutoFillAbility.ts", - "description": "$string:AutoFillAbility_desc", - "exported": true, - "icon": "$media:icon", - "label": "$string:AutoFillAbility_label", - "type": "autoFill/smart" - } - ], - } +/* + * Copyright (c) 2024 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "TextAutoFillAbility", + "srcEntry": "./ets/autofillability/TextAutoFillAbility.ts", + "description": "$string:AutoFillAbility_desc", + "exported": true, + "icon": "$media:icon", + "label": "$string:AutoFillAbility_label", + "type": "autoFill/smart" + } + ], + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/element/color.json b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/element/color.json old mode 100755 new mode 100644 index 3ae5515df5..8dbfb02a3e --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/element/color.json @@ -1,40 +1,40 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "cancelBtnColor", - "value": "#0A59F7" - }, - { - "name": "enableColor", - "value": "#bfdbf9" - }, - { - "name": "pageBackColor", - "value": "#f1f3f5" - }, - { - "name": "cancelColor", - "value": "#D8FCFFFE" - }, - { - "name": "mainInterface", - "value": "#FDE5E9E9" - }, - { - "name": "placeholderColor", - "value": "#fff5eeee" - }, - { - "name": "backgroundColor", - "value": "#ffffffff" - }, - { - "name": "TextColor", - "value": "#99000000" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "cancelBtnColor", + "value": "#0A59F7" + }, + { + "name": "enableColor", + "value": "#bfdbf9" + }, + { + "name": "pageBackColor", + "value": "#f1f3f5" + }, + { + "name": "cancelColor", + "value": "#D8FCFFFE" + }, + { + "name": "mainInterface", + "value": "#FDE5E9E9" + }, + { + "name": "placeholderColor", + "value": "#fff5eeee" + }, + { + "name": "backgroundColor", + "value": "#ffffffff" + }, + { + "name": "TextColor", + "value": "#99000000" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/element/string.json b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/arrow.png b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/arrow.png old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/ic_public_back.svg b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/ic_public_back.svg old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/icon.png b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/icon.png old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/style.png b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/media/style.png old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/profile/main_pages.json b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/en_US/element/string.json b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/en_US/element/string.json old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/zh_CN/element/string.json b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/main/resources/zh_CN/element/string.json old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/test/Ability.test.ets b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/test/Ability.test.ets old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/test/List.test.ets b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/test/List.test.ets old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/testability/TestAbility.ets old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/testability/pages/Index.ets old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/module.json5 b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/module.json5 old mode 100755 new mode 100644 index 269aabf14e..17fcedb622 --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/element/color.json b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/element/color.json old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/element/string.json b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/element/string.json old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/media/icon.png b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/media/icon.png old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/SystemFeature/AutoFill/AutoFillScenarioization/entry/src/ohosTest/resources/base/profile/test_pages.json old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigor/hvigor-config.json5 b/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigor/hvigor-config.json5 old mode 100755 new mode 100644 index fb29482d10..9a79085076 --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2024 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. - */ - -{ - "hvigorVersion": "4.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" - } +/* + * Copyright (c) 2024 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. + */ + +{ + "hvigorVersion": "4.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.2" + } } \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigor/hvigor-wrapper.js b/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigor/hvigor-wrapper.js old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigorfile.ts b/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigorfile.ts old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigorw b/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigorw old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigorw.bat b/code/SystemFeature/AutoFill/AutoFillScenarioization/hvigorw.bat old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/oh-package.json5 b/code/SystemFeature/AutoFill/AutoFillScenarioization/oh-package.json5 old mode 100755 new mode 100644 index bbe632713b..5d3a2789a9 --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/oh-package.json5 +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/oh-package.json5 @@ -1,12 +1,12 @@ -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "autofilldemo", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "autofilldemo", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/ohosTest.md b/code/SystemFeature/AutoFill/AutoFillScenarioization/ohosTest.md old mode 100755 new mode 100644 index 9cd082a951..9b8d48c4de --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/ohosTest.md +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/ohosTest.md @@ -1,11 +1,11 @@ -# AutoFill情景化测试用例 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| ------------------------------------------------------------ | ---------- | ----------------------------------------------------------- | ------------------------------------------------------------ | -------- | -------- | -| 支持情景化自动填充,指定类型判断组件存在,FULL_PHONE_NUMBER的枚举值是否正确 | 位于主界面 | 1、进入主界面
| 1、应用启动成功
2、页面加载成功,组件存在
3、JSON中的contentType值FULL_PHONE_NUMBER | 是 | Pass | -| 支持情景化自动填充,指定类型判断组件存在,PERSON_FULL_NAME的枚举值是否正确 | 位于主界面 | 1、进入主界面
| 1、应用启动成功
2、页面加载成功,组件存在
3、JSON中的contentType值为PERSON_FULL_NAME | 是 | Pass | -| 支持情景化自动填充,输入字符进行联想页面弹出select弹窗并触发onUpdateRequest回调 | 位于主界面 | 1、进入主界面
| 1、输入字符联想成功
2、将选择的名字成功返回到textInput组件 | 否 | Pass | -| 主页面消失,发起手动保存请求成功 | 位于主界面 | 1、进入主界面
2、文本框输入信息
3、点击保存按钮 | 1、主页面点击文本框成功
2、成功输入
3、点击保存按钮后,页面会显示"保存和取消按钮"的页面
4、观察日志输出能够接收到OnSaveRequestSuccess信息 | 是 | Pass | +# AutoFill情景化测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------------------------------------------ | ---------- | ----------------------------------------------------------- | ------------------------------------------------------------ | -------- | -------- | +| 支持情景化自动填充,指定类型判断组件存在,FULL_PHONE_NUMBER的枚举值是否正确 | 位于主界面 | 1、进入主界面
| 1、应用启动成功
2、页面加载成功,组件存在
3、JSON中的contentType值FULL_PHONE_NUMBER | 是 | Pass | +| 支持情景化自动填充,指定类型判断组件存在,PERSON_FULL_NAME的枚举值是否正确 | 位于主界面 | 1、进入主界面
| 1、应用启动成功
2、页面加载成功,组件存在
3、JSON中的contentType值为PERSON_FULL_NAME | 是 | Pass | +| 支持情景化自动填充,输入字符进行联想页面弹出select弹窗并触发onUpdateRequest回调 | 位于主界面 | 1、进入主界面
| 1、输入字符联想成功
2、将选择的名字成功返回到textInput组件 | 否 | Pass | +| 主页面消失,发起手动保存请求成功 | 位于主界面 | 1、进入主界面
2、文本框输入信息
3、点击保存按钮 | 1、主页面点击文本框成功
2、成功输入
3、点击保存按钮后,页面会显示"保存和取消按钮"的页面
4、观察日志输出能够接收到OnSaveRequestSuccess信息 | 是 | Pass | | 主页面消失,发起自动保存请求成功 | 位于主界面 | 1、进入主界面
2、文本框输入信息
3、点击切换界面按钮 | 1、主页面点击文本框成功
2、成功输入
3、点击切换按钮后,页面先跳转"返回主界面按钮"界面后显示"保存和取消按钮"的页面
4、观察日志输出能够接收到OnSaveRequestSuccess信息 | 是 | Pass | \ No newline at end of file diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/Index.jpg b/code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/Index.jpg old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/NameAssociation.jpg b/code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/NameAssociation.jpg old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/ReturnMainPage.jpg b/code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/ReturnMainPage.jpg old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/SavePage.jpg b/code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/SavePage.jpg old mode 100755 new mode 100644 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/SelectorList.jpg b/code/SystemFeature/AutoFill/AutoFillScenarioization/screenshots/SelectorList.jpg old mode 100755 new mode 100644 diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/AppScope/app.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart/AppScope/app.json5 index 669d117d5e..5c6d1bca63 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/AppScope/app.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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.fullscreenstart", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.fullscreenstart", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/AppScope/resources/base/element/string.json b/code/SystemFeature/FullScreenStart/FullScreenStart/AppScope/resources/base/element/string.json index 7fc4af3343..0a5375ac15 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "FullScreenStart" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "FullScreenStart" + } + ] +} diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/build-profile.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart/build-profile.json5 index f0b12f54c1..6774a44508 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/build-profile.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/build-profile.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2024 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": 12, - "compileSdkVersion": 12, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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": 12, + "compileSdkVersion": 12, + "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/SystemFeature/FullScreenStart/FullScreenStart/entry/build-profile.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/build-profile.json5 index 97f563b45a..63b88fb1a0 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/build-profile.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2024 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", - } - ] +/* + * Copyright (c) 2024 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/SystemFeature/FullScreenStart/FullScreenStart/entry/oh-package.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/oh-package.json5 index 41a4755f66..4e54d14e1b 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/oh-package.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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": {} -} - +/* + * Copyright (c) 2024 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/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/entryability/EntryAbility.ets b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/entryability/EntryAbility.ets index a76c99c8ad..ca1b0ce571 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2024 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, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; -import EmbeddableUIAbility from '@ohos.app.ability.EmbeddableUIAbility'; - -export default class EntryAbility extends EmbeddableUIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2024 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, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import EmbeddableUIAbility from '@ohos.app.ability.EmbeddableUIAbility'; + +export default class EntryAbility extends EmbeddableUIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index 1755a4686c..6b744d7eaa 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 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)); - } +/* + * Copyright (c) 2024 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/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/pages/ExtensionIndex.ets b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/pages/ExtensionIndex.ets index c374a88721..3169c6f39a 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/pages/ExtensionIndex.ets +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/pages/ExtensionIndex.ets @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2024 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 { common } from '@kit.AbilityKit'; -import AtomicServiceOptions from '@ohos.app.ability.AtomicServiceOptions'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -@Entry -@Component -struct Index { - // Developers need to create an AtomicService within AppGallery Connect and replace this appId. - private appId: string = '5765880207854787517'; - private options: AtomicServiceOptions = { - displayId: 0 - }; - private extensionContext = getContext(this) as common.UIExtensionContext; - - build() { - Row() { - Column() { - Button($r('app.string.UIExtensionStart')) - .onClick((event: ClickEvent) => { - try { - this.extensionContext.openAtomicService(this.appId, this.options) - .then((result: common.AbilityResult) => { - hilog.info(0x0000, 'testTag', 'UIExtensionContext.openAtomicService succeed'); - }) - .catch((err: BusinessError) => { - hilog.error(0x0000, 'testTag', - `UIExtensionContext.openAtomicService failed, code is ${err.code}, message is ${err.message}`); - }); - } catch (err) { - let code = (err as BusinessError).code; - let message = (err as BusinessError).message; - hilog.error(0x0000, 'testTag', - `UIExtensionContext.openAtomicService failed, code is ${code}, message is ${message}`); - } - }) - .id('UIExtensionStart') - .width('93.4%').height('100%') - } - .width('100%').height('100%') - } - } -} +/* + * Copyright (c) 2024 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 { common } from '@kit.AbilityKit'; +import AtomicServiceOptions from '@ohos.app.ability.AtomicServiceOptions'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Entry +@Component +struct Index { + // Developers need to create an AtomicService within AppGallery Connect and replace this appId. + private appId: string = '5765880207854787517'; + private options: AtomicServiceOptions = { + displayId: 0 + }; + private extensionContext = getContext(this) as common.UIExtensionContext; + + build() { + Row() { + Column() { + Button($r('app.string.UIExtensionStart')) + .onClick((event: ClickEvent) => { + try { + this.extensionContext.openAtomicService(this.appId, this.options) + .then((result: common.AbilityResult) => { + hilog.info(0x0000, 'testTag', 'UIExtensionContext.openAtomicService succeed'); + }) + .catch((err: BusinessError) => { + hilog.error(0x0000, 'testTag', + `UIExtensionContext.openAtomicService failed, code is ${err.code}, message is ${err.message}`); + }); + } catch (err) { + let code = (err as BusinessError).code; + let message = (err as BusinessError).message; + hilog.error(0x0000, 'testTag', + `UIExtensionContext.openAtomicService failed, code is ${code}, message is ${message}`); + } + }) + .id('UIExtensionStart') + .width('93.4%').height('100%') + } + .width('100%').height('100%') + } + } +} diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/uiextensionability/UIExtensionAbility.ets b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/uiextensionability/UIExtensionAbility.ets index 273dd49793..1c75d8706d 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/uiextensionability/UIExtensionAbility.ets +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/ets/uiextensionability/UIExtensionAbility.ets @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2024 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 { Want, UIExtensionAbility, UIExtensionContentSession } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = '[testTag] UIExtAbility '; - -export default class UIExtAbility extends UIExtensionAbility { - onCreate() { - hilog.info(0x0000, TAG, `UIExtensionAbility onCreate`); - } - - onForeground() { - hilog.info(0x0000, TAG, `UIExtensionAbility onForeground`); - } - - onBackground() { - hilog.info(0x0000, TAG, `UIExtensionAbility onBackground`); - } - - onDestroy() { - hilog.info(0x0000, TAG, `UIExtensionAbility onDestroy`); - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - hilog.info(0x0000, TAG, `UIExtensionAbility onSessionCreate, want: ${JSON.stringify(want)}`); - let storage: LocalStorage = new LocalStorage(); - storage.setOrCreate('session', session); - session.loadContent('pages/ExtensionIndex', storage); - } - - onSessionDestroy(session: UIExtensionContentSession) { - hilog.info(0x0000, TAG, `onSessionDestroy`); - } +/* + * Copyright (c) 2024 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 { Want, UIExtensionAbility, UIExtensionContentSession } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = '[testTag] UIExtAbility '; + +export default class UIExtAbility extends UIExtensionAbility { + onCreate() { + hilog.info(0x0000, TAG, `UIExtensionAbility onCreate`); + } + + onForeground() { + hilog.info(0x0000, TAG, `UIExtensionAbility onForeground`); + } + + onBackground() { + hilog.info(0x0000, TAG, `UIExtensionAbility onBackground`); + } + + onDestroy() { + hilog.info(0x0000, TAG, `UIExtensionAbility onDestroy`); + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + hilog.info(0x0000, TAG, `UIExtensionAbility onSessionCreate, want: ${JSON.stringify(want)}`); + let storage: LocalStorage = new LocalStorage(); + storage.setOrCreate('session', session); + session.loadContent('pages/ExtensionIndex', storage); + } + + onSessionDestroy(session: UIExtensionContentSession) { + hilog.info(0x0000, TAG, `onSessionDestroy`); + } } \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/module.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/module.json5 index 2377e89673..a5e31081e2 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/module.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/module.json5 @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2024 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:startIcon", - "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" - } - ] - }, - { - "name": "UIExtAbility", - "srcEntry": "./ets/uiextensionability/UIExtensionAbility.ets", - "description": "UIExtensionAbility", - "type": "sys/commonUI", - "exported": true, - } - ] - } +/* + * Copyright (c) 2024 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:startIcon", + "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" + } + ] + }, + { + "name": "UIExtAbility", + "srcEntry": "./ets/uiextensionability/UIExtensionAbility.ets", + "description": "UIExtensionAbility", + "type": "sys/commonUI", + "exported": true, + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/resources/base/element/color.json b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/resources/base/profile/backup_config.json b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/resources/base/profile/backup_config.json index d742c2f96e..78f40ae7c4 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/resources/base/profile/backup_config.json +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/ohosTest/module.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/ohosTest/module.json5 index 1f646ea03f..5f63462032 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/hvigor/hvigor-config.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart/hvigor/hvigor-config.json5 index 5f9d8a5758..76e3231223 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/hvigor/hvigor-config.json5 @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2024 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*/ - } -} +/* + * Copyright (c) 2024 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/SystemFeature/FullScreenStart/FullScreenStart/oh-package.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart/oh-package.json5 index d645a02be5..a941f44583 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/oh-package.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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" - } -} +/* + * Copyright (c) 2024 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/SystemFeature/FullScreenStart/FullScreenStart/ohosTest.md b/code/SystemFeature/FullScreenStart/FullScreenStart/ohosTest.md index 450c6699a6..8c5569adbd 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/ohosTest.md +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/ohosTest.md @@ -1,9 +1,9 @@ -# 全屏启动原子化服务测试用例 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | -| -------------------------------------------------- | -------- | -------------------------- | ------------------------- | ------| ------ | -| 验证通过arkui接口FullScreenLaunchComponent嵌入式全屏启动原子化服务 | 位于启动页面 | 点击"全屏启动原子化服务组件"按钮 | 页面通过嵌入式启动方式跳转至原子化服务应用 | 是 | Pass | -| 验证通过UIAbilityContext.openAtomicService接口跳出式启动原子化服务 | 位于启动页面 | 点击"UIAbility启动原子化服务"按钮 | 页面通过跳出式启动方式跳转至原子化服务应用 | 是 | Pass | +# 全屏启动原子化服务测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------------------------------------- | -------- | -------------------------- | ------------------------- | ------| ------ | +| 验证通过arkui接口FullScreenLaunchComponent嵌入式全屏启动原子化服务 | 位于启动页面 | 点击"全屏启动原子化服务组件"按钮 | 页面通过嵌入式启动方式跳转至原子化服务应用 | 是 | Pass | +| 验证通过UIAbilityContext.openAtomicService接口跳出式启动原子化服务 | 位于启动页面 | 点击"UIAbility启动原子化服务"按钮 | 页面通过跳出式启动方式跳转至原子化服务应用 | 是 | Pass | | 验证通过UIExtensionContext.openAtomicService接口跳出式启动原子化服务 | 位于启动页面 | 点击"UIExtension启动原子化服务"按钮 | 页面通过跳出式启动方式跳转至原子化服务应用 | 是 | Pass | \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/AppScope/app.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/AppScope/app.json5 index bedd9b53b5..6b04af62c3 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/AppScope/app.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/AppScope/app.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2024 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.atomicservice.5765880207854787517", - "bundleType": "atomicService", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.atomicservice.5765880207854787517", + "bundleType": "atomicService", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/AppScope/resources/base/element/string.json b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/AppScope/resources/base/element/string.json index 64fcb63f50..a7245dde06 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "FullScreenStart_Service" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "FullScreenStart_Service" + } + ] +} diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/build-profile.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/build-profile.json5 index 94452336df..19d7b77601 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/build-profile.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/build-profile.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2024 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": "5.0.0(12)", - "runtimeOS": "HarmonyOS", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "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/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/build-profile.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/build-profile.json5 index 97f563b45a..63b88fb1a0 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/build-profile.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2024 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", - } - ] +/* + * Copyright (c) 2024 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/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/oh-package.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/oh-package.json5 index 41a4755f66..4e54d14e1b 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/oh-package.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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": {} -} - +/* + * Copyright (c) 2024 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/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/constants/CommonConstants.ets b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/constants/CommonConstants.ets index 589e72b7d3..b74bfe125b 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/constants/CommonConstants.ets @@ -1,124 +1,124 @@ -/* - * Copyright (c) 2024 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. - */ - -/** - * Common constants for all features. - */ -export class CommonConstants { - /** - * Full percent. - */ - static readonly FULL_PERCENT: string = '100%'; - /** - * Operator Collection. - */ - static readonly OPERATORS: string = '+-×÷'; - /** - * Operators with high precedence. - */ - static readonly OPERATORS_PRIORITY: string = '×÷'; - /** - * Addition. - */ - static readonly ADD: string = '+'; - /** - * Minus. - */ - static readonly MIN: string = '-'; - /** - * Multiplication. - */ - static readonly MUL: string = '×'; - /** - * Division. - */ - static readonly DIV: string = '÷'; - /** - * Percent sign. - */ - static readonly PERCENT_SIGN: string = '%'; - /** - * Decimal point. - */ - static readonly DOTS: string = '.'; - /** - * Number two. - */ - static readonly TWO: number = 2; - /** - * Digit ten. - */ - static readonly TEN: number = 10; - /** - * One hundred. - */ - static readonly ONE_HUNDRED: string = '100'; - /** - * Display Maximum Length of Large Fonts. - */ - static readonly INPUT_LENGTH_MAX: number = 9; - /** - * Subscript is two. - */ - static readonly INDEX_TWO: number = 2; - /** - * Maximum length of a single digit. - */ - static readonly NUM_MAX_LEN: number = 16; - /** - * Letter e. - */ - static readonly E: string = 'e'; - /** - * String Zero. - */ - static readonly ZERO: string = '0' - /** - * zero point. - */ - static readonly ZERO_DOTS: string = '0.' -} - -/** - * Symbol value. - */ -export enum Symbol { - ADD = 'add', - MIN = 'min', - MUL = 'mul', - DIV = 'div', - CLEAN = 'clean', - DEL = 'del', - EQU = 'equ' -} - -/** - * Operator Precedence Enumeration. - */ -export enum Priority { - HIGH = 2, - MEDIUM = 1, - LOW = 0 -} - -/** - * Enumerated value: addition, subtraction, multiplication, and division. - */ -export enum SymbolicEnumeration { - ADD = '+', - MIN = '-', - MUL = '×', - DIV = '÷' -} +/* + * Copyright (c) 2024 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. + */ + +/** + * Common constants for all features. + */ +export class CommonConstants { + /** + * Full percent. + */ + static readonly FULL_PERCENT: string = '100%'; + /** + * Operator Collection. + */ + static readonly OPERATORS: string = '+-×÷'; + /** + * Operators with high precedence. + */ + static readonly OPERATORS_PRIORITY: string = '×÷'; + /** + * Addition. + */ + static readonly ADD: string = '+'; + /** + * Minus. + */ + static readonly MIN: string = '-'; + /** + * Multiplication. + */ + static readonly MUL: string = '×'; + /** + * Division. + */ + static readonly DIV: string = '÷'; + /** + * Percent sign. + */ + static readonly PERCENT_SIGN: string = '%'; + /** + * Decimal point. + */ + static readonly DOTS: string = '.'; + /** + * Number two. + */ + static readonly TWO: number = 2; + /** + * Digit ten. + */ + static readonly TEN: number = 10; + /** + * One hundred. + */ + static readonly ONE_HUNDRED: string = '100'; + /** + * Display Maximum Length of Large Fonts. + */ + static readonly INPUT_LENGTH_MAX: number = 9; + /** + * Subscript is two. + */ + static readonly INDEX_TWO: number = 2; + /** + * Maximum length of a single digit. + */ + static readonly NUM_MAX_LEN: number = 16; + /** + * Letter e. + */ + static readonly E: string = 'e'; + /** + * String Zero. + */ + static readonly ZERO: string = '0' + /** + * zero point. + */ + static readonly ZERO_DOTS: string = '0.' +} + +/** + * Symbol value. + */ +export enum Symbol { + ADD = 'add', + MIN = 'min', + MUL = 'mul', + DIV = 'div', + CLEAN = 'clean', + DEL = 'del', + EQU = 'equ' +} + +/** + * Operator Precedence Enumeration. + */ +export enum Priority { + HIGH = 2, + MEDIUM = 1, + LOW = 0 +} + +/** + * Enumerated value: addition, subtraction, multiplication, and division. + */ +export enum SymbolicEnumeration { + ADD = '+', + MIN = '-', + MUL = '×', + DIV = '÷' +} diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/util/CalculateUtil.ets b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/util/CalculateUtil.ets index a18bbaa9c2..72d5587abe 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/util/CalculateUtil.ets +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/util/CalculateUtil.ets @@ -1,282 +1,282 @@ -/* - * Copyright (c) 2024 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 { CommonConstants, Priority, SymbolicEnumeration } from '../constants/CommonConstants'; -import CheckEmptyUtil from './CheckEmptyUtil'; - -class CalculateUtil { - /** - * Determines whether it is an operator. - * - * @param value The symbol. - * @return Is Operator. - */ - isSymbol(value: string) { - if (CheckEmptyUtil.isEmpty(value)) { - return; - } - return (CommonConstants.OPERATORS.indexOf(value) !== -1); - } - - /** - * Get Operator Precedence. - * - * @param value The symbol. - * @return Priority. - */ - getPriority(value: string): number { - if (CheckEmptyUtil.isEmpty(value)) { - return Priority.LOW; - } - let result = 0; - switch (value) { - case SymbolicEnumeration.ADD: - case SymbolicEnumeration.MIN: - result = Priority.MEDIUM; - break; - case SymbolicEnumeration.MUL: - case SymbolicEnumeration.DIV: - result = Priority.HIGH; - break; - default: - result = Priority.LOW; - break; - } - return result; - } - - /** - * Determine the priority of addition, subtraction, multiplication, and division. - * - * @param arg1 Parameter 1. - * @param arg2 Parameter 2. - * @return Compare Priority Results. - */ - comparePriority(arg1: string, arg2: string): boolean { - if (CheckEmptyUtil.isEmpty(arg1) || CheckEmptyUtil.isEmpty(arg2)) { - return false; - } - return (this.getPriority(arg1) <= this.getPriority(arg2)); - } - - /** - * Expression Processing. - * - * @param expressions Expressions. - */ - parseExpression(expressions: Array): string { - if (CheckEmptyUtil.isEmpty(expressions)) { - return 'NaN'; - } - let len = expressions.length; - let outputStack: string[] = []; - let outputQueue: string[] = []; - expressions.forEach((item: string, index: number) => { - // Handle % in the expression - if (item.indexOf(CommonConstants.PERCENT_SIGN) !== -1) { - expressions[index] = (this.mulOrDiv(item.slice(0, item.length - 1), - CommonConstants.ONE_HUNDRED, CommonConstants.DIV)).toString(); - } - // Whether the last digit is an operator. - if ((index === len - 1) && this.isSymbol(item)) { - expressions.pop(); - } - }); - while (expressions.length > 0) { - let current: string | undefined = expressions.shift(); - if (current !== undefined) { - if (this.isSymbol(current)) { - // Processing addition, subtraction, multiplication and division. - while (outputStack.length > 0 && this.comparePriority(current, outputStack[outputStack.length - 1])) { - let popValue: string | undefined = outputStack.pop(); - if (popValue !== undefined) { - outputQueue.push(popValue); - } - } - outputStack.push(current); - } else { - // Processing the numbers. - outputQueue.push(current); - } - } - } - while (outputStack.length > 0) { - let popValue: string | undefined = outputStack.pop(); - if (popValue !== undefined) { - outputQueue.push(popValue); - } - } - return this.dealQueue(outputQueue); - } - - /** - * Processing expressions in queues. - * - * @param queue Expression Queue. - * @return The end result. - */ - dealQueue(queue: Array): string { - if (CheckEmptyUtil.isEmpty(queue)) { - return 'NaN'; - } - let outputStack: string[] = []; - while (queue.length > 0) { - let current: string | undefined = queue.shift(); - if (current !== undefined) { - if (!this.isSymbol(current)) { - outputStack.push(current); - } else { - let second: string | undefined = outputStack.pop(); - let first: string | undefined = outputStack.pop(); - if (first !== undefined && second !== undefined) { - let calResultValue: string = this.calResult(first, second, current) - outputStack.push(calResultValue); - } - } - } - } - if (outputStack.length !== 1) { - return 'NaN'; - } else { - let end: string = outputStack[0]?.endsWith(CommonConstants.DOTS) ? - outputStack[0].substring(0, outputStack[0].length - 1) : outputStack[0]; - return end; - } - } - - /** - * Calculation result. - * - * @param arg1 Number 1. - * @param arg2 Number 2. - * @param symbol Operators. - * @return Calculation result. - */ - calResult(arg1: string, arg2: string, symbol: string): string { - if (CheckEmptyUtil.isEmpty(arg1) || CheckEmptyUtil.isEmpty(arg2) || CheckEmptyUtil.isEmpty(symbol)) { - return 'NaN'; - } - let result = 0; - switch (symbol) { - case SymbolicEnumeration.ADD: - result = this.add(arg1, arg2, CommonConstants.ADD); - break; - case SymbolicEnumeration.MIN: - result = this.add(arg1, arg2, CommonConstants.MIN); - break; - case SymbolicEnumeration.MUL: - result = this.mulOrDiv(arg1, arg2, CommonConstants.MUL); - break; - case SymbolicEnumeration.DIV: - result = this.mulOrDiv(arg1, arg2, CommonConstants.DIV); - break; - default: - break; - } - return this.numberToScientificNotation(result); - } - - /** - * Addition and subtraction operation. - * - * @param arg1 Number 1. - * @param arg2 Number 2. - * @param symbol Operators. - * @return Addition and subtraction results. - */ - add(arg1: string, arg2: string, symbol: string): number { - let addFlag = (symbol === CommonConstants.ADD); - if (this.containScientificNotation(arg1) || this.containScientificNotation(arg2)) { - if (addFlag) { - return Number(arg1) + Number(arg2); - } - return Number(arg1) - Number(arg2); - } - arg1 = (arg1 === CommonConstants.ZERO_DOTS) ? '0' : arg1; - arg2 = (arg2 === CommonConstants.ZERO_DOTS) ? '0' : arg2; - let leftArr = arg1.split(CommonConstants.DOTS); - let rightArr = arg2.split(CommonConstants.DOTS); - let leftLen = leftArr.length > 1 ? leftArr[1] : ''; - let rightLen = rightArr.length > 1 ? rightArr[1] : ''; - let maxLen = Math.max(leftLen.length, rightLen.length); - let multiples = Math.pow(CommonConstants.TEN, maxLen); - if (addFlag) { - return Number(((Number(arg1) * multiples + Number(arg2) * multiples) / multiples).toFixed(maxLen)); - } - return Number(((Number(arg1) * multiples - Number(arg2) * multiples) / multiples).toFixed(maxLen)); - } - - /** - * multiplication and division operation. - * - * @param arg1 Number 1. - * @param arg2 Number 2. - * @param symbol Operators. - * @return Multiply and divide result. - */ - mulOrDiv(arg1: string, arg2: string, symbol: string): number { - let mulFlag = (symbol === CommonConstants.MUL); - if (this.containScientificNotation(arg1) || this.containScientificNotation(arg2)) { - if (mulFlag) { - return Number(arg1) * Number(arg2); - } - return Number(arg1) / Number(arg2); - } - let leftLen = arg1.split(CommonConstants.DOTS)[1] ? arg1.split(CommonConstants.DOTS)[1].length : 0; - let rightLen = arg2.split(CommonConstants.DOTS)[1] ? arg2.split(CommonConstants.DOTS)[1].length : 0; - if (mulFlag) { - return Number(arg1.replace(CommonConstants.DOTS, '')) * - Number(arg2.replace(CommonConstants.DOTS, '')) / Math.pow(CommonConstants.TEN, leftLen + rightLen); - } - return Number(arg1.replace(CommonConstants.DOTS, '')) / - (Number(arg2.replace(CommonConstants.DOTS, '')) / Math.pow(CommonConstants.TEN, rightLen - leftLen)); - } - - /** - * Whether the operand contains scientific notation - * - * @param arg Number. - * @return Whether scientific notation is included - */ - containScientificNotation(arg: string) { - return (arg.indexOf(CommonConstants.E) !== -1); - } - - /** - * Results converted to scientific notation. - * - * @param result Digital Results. - */ - numberToScientificNotation(result: number) { - if (result === Number.NEGATIVE_INFINITY || result === Number.POSITIVE_INFINITY) { - return 'NaN'; - } - let resultStr = JSON.stringify(result); - if (this.containScientificNotation(resultStr)) { - return resultStr; - } - let prefixNumber = (resultStr.indexOf(CommonConstants.MIN) === -1) ? 1 : -1; - result *= prefixNumber; - if (resultStr.replace(CommonConstants.DOTS, '').replace(CommonConstants.MIN, '').length < - CommonConstants.NUM_MAX_LEN) { - return resultStr; - } - let suffix = (Math.floor(Math.log(result) / Math.LN10)); - let prefix = (result * Math.pow(CommonConstants.TEN, -suffix) * prefixNumber); - return (prefix + CommonConstants.E + suffix); - } -} - +/* + * Copyright (c) 2024 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 { CommonConstants, Priority, SymbolicEnumeration } from '../constants/CommonConstants'; +import CheckEmptyUtil from './CheckEmptyUtil'; + +class CalculateUtil { + /** + * Determines whether it is an operator. + * + * @param value The symbol. + * @return Is Operator. + */ + isSymbol(value: string) { + if (CheckEmptyUtil.isEmpty(value)) { + return; + } + return (CommonConstants.OPERATORS.indexOf(value) !== -1); + } + + /** + * Get Operator Precedence. + * + * @param value The symbol. + * @return Priority. + */ + getPriority(value: string): number { + if (CheckEmptyUtil.isEmpty(value)) { + return Priority.LOW; + } + let result = 0; + switch (value) { + case SymbolicEnumeration.ADD: + case SymbolicEnumeration.MIN: + result = Priority.MEDIUM; + break; + case SymbolicEnumeration.MUL: + case SymbolicEnumeration.DIV: + result = Priority.HIGH; + break; + default: + result = Priority.LOW; + break; + } + return result; + } + + /** + * Determine the priority of addition, subtraction, multiplication, and division. + * + * @param arg1 Parameter 1. + * @param arg2 Parameter 2. + * @return Compare Priority Results. + */ + comparePriority(arg1: string, arg2: string): boolean { + if (CheckEmptyUtil.isEmpty(arg1) || CheckEmptyUtil.isEmpty(arg2)) { + return false; + } + return (this.getPriority(arg1) <= this.getPriority(arg2)); + } + + /** + * Expression Processing. + * + * @param expressions Expressions. + */ + parseExpression(expressions: Array): string { + if (CheckEmptyUtil.isEmpty(expressions)) { + return 'NaN'; + } + let len = expressions.length; + let outputStack: string[] = []; + let outputQueue: string[] = []; + expressions.forEach((item: string, index: number) => { + // Handle % in the expression + if (item.indexOf(CommonConstants.PERCENT_SIGN) !== -1) { + expressions[index] = (this.mulOrDiv(item.slice(0, item.length - 1), + CommonConstants.ONE_HUNDRED, CommonConstants.DIV)).toString(); + } + // Whether the last digit is an operator. + if ((index === len - 1) && this.isSymbol(item)) { + expressions.pop(); + } + }); + while (expressions.length > 0) { + let current: string | undefined = expressions.shift(); + if (current !== undefined) { + if (this.isSymbol(current)) { + // Processing addition, subtraction, multiplication and division. + while (outputStack.length > 0 && this.comparePriority(current, outputStack[outputStack.length - 1])) { + let popValue: string | undefined = outputStack.pop(); + if (popValue !== undefined) { + outputQueue.push(popValue); + } + } + outputStack.push(current); + } else { + // Processing the numbers. + outputQueue.push(current); + } + } + } + while (outputStack.length > 0) { + let popValue: string | undefined = outputStack.pop(); + if (popValue !== undefined) { + outputQueue.push(popValue); + } + } + return this.dealQueue(outputQueue); + } + + /** + * Processing expressions in queues. + * + * @param queue Expression Queue. + * @return The end result. + */ + dealQueue(queue: Array): string { + if (CheckEmptyUtil.isEmpty(queue)) { + return 'NaN'; + } + let outputStack: string[] = []; + while (queue.length > 0) { + let current: string | undefined = queue.shift(); + if (current !== undefined) { + if (!this.isSymbol(current)) { + outputStack.push(current); + } else { + let second: string | undefined = outputStack.pop(); + let first: string | undefined = outputStack.pop(); + if (first !== undefined && second !== undefined) { + let calResultValue: string = this.calResult(first, second, current) + outputStack.push(calResultValue); + } + } + } + } + if (outputStack.length !== 1) { + return 'NaN'; + } else { + let end: string = outputStack[0]?.endsWith(CommonConstants.DOTS) ? + outputStack[0].substring(0, outputStack[0].length - 1) : outputStack[0]; + return end; + } + } + + /** + * Calculation result. + * + * @param arg1 Number 1. + * @param arg2 Number 2. + * @param symbol Operators. + * @return Calculation result. + */ + calResult(arg1: string, arg2: string, symbol: string): string { + if (CheckEmptyUtil.isEmpty(arg1) || CheckEmptyUtil.isEmpty(arg2) || CheckEmptyUtil.isEmpty(symbol)) { + return 'NaN'; + } + let result = 0; + switch (symbol) { + case SymbolicEnumeration.ADD: + result = this.add(arg1, arg2, CommonConstants.ADD); + break; + case SymbolicEnumeration.MIN: + result = this.add(arg1, arg2, CommonConstants.MIN); + break; + case SymbolicEnumeration.MUL: + result = this.mulOrDiv(arg1, arg2, CommonConstants.MUL); + break; + case SymbolicEnumeration.DIV: + result = this.mulOrDiv(arg1, arg2, CommonConstants.DIV); + break; + default: + break; + } + return this.numberToScientificNotation(result); + } + + /** + * Addition and subtraction operation. + * + * @param arg1 Number 1. + * @param arg2 Number 2. + * @param symbol Operators. + * @return Addition and subtraction results. + */ + add(arg1: string, arg2: string, symbol: string): number { + let addFlag = (symbol === CommonConstants.ADD); + if (this.containScientificNotation(arg1) || this.containScientificNotation(arg2)) { + if (addFlag) { + return Number(arg1) + Number(arg2); + } + return Number(arg1) - Number(arg2); + } + arg1 = (arg1 === CommonConstants.ZERO_DOTS) ? '0' : arg1; + arg2 = (arg2 === CommonConstants.ZERO_DOTS) ? '0' : arg2; + let leftArr = arg1.split(CommonConstants.DOTS); + let rightArr = arg2.split(CommonConstants.DOTS); + let leftLen = leftArr.length > 1 ? leftArr[1] : ''; + let rightLen = rightArr.length > 1 ? rightArr[1] : ''; + let maxLen = Math.max(leftLen.length, rightLen.length); + let multiples = Math.pow(CommonConstants.TEN, maxLen); + if (addFlag) { + return Number(((Number(arg1) * multiples + Number(arg2) * multiples) / multiples).toFixed(maxLen)); + } + return Number(((Number(arg1) * multiples - Number(arg2) * multiples) / multiples).toFixed(maxLen)); + } + + /** + * multiplication and division operation. + * + * @param arg1 Number 1. + * @param arg2 Number 2. + * @param symbol Operators. + * @return Multiply and divide result. + */ + mulOrDiv(arg1: string, arg2: string, symbol: string): number { + let mulFlag = (symbol === CommonConstants.MUL); + if (this.containScientificNotation(arg1) || this.containScientificNotation(arg2)) { + if (mulFlag) { + return Number(arg1) * Number(arg2); + } + return Number(arg1) / Number(arg2); + } + let leftLen = arg1.split(CommonConstants.DOTS)[1] ? arg1.split(CommonConstants.DOTS)[1].length : 0; + let rightLen = arg2.split(CommonConstants.DOTS)[1] ? arg2.split(CommonConstants.DOTS)[1].length : 0; + if (mulFlag) { + return Number(arg1.replace(CommonConstants.DOTS, '')) * + Number(arg2.replace(CommonConstants.DOTS, '')) / Math.pow(CommonConstants.TEN, leftLen + rightLen); + } + return Number(arg1.replace(CommonConstants.DOTS, '')) / + (Number(arg2.replace(CommonConstants.DOTS, '')) / Math.pow(CommonConstants.TEN, rightLen - leftLen)); + } + + /** + * Whether the operand contains scientific notation + * + * @param arg Number. + * @return Whether scientific notation is included + */ + containScientificNotation(arg: string) { + return (arg.indexOf(CommonConstants.E) !== -1); + } + + /** + * Results converted to scientific notation. + * + * @param result Digital Results. + */ + numberToScientificNotation(result: number) { + if (result === Number.NEGATIVE_INFINITY || result === Number.POSITIVE_INFINITY) { + return 'NaN'; + } + let resultStr = JSON.stringify(result); + if (this.containScientificNotation(resultStr)) { + return resultStr; + } + let prefixNumber = (resultStr.indexOf(CommonConstants.MIN) === -1) ? 1 : -1; + result *= prefixNumber; + if (resultStr.replace(CommonConstants.DOTS, '').replace(CommonConstants.MIN, '').length < + CommonConstants.NUM_MAX_LEN) { + return resultStr; + } + let suffix = (Math.floor(Math.log(result) / Math.LN10)); + let prefix = (result * Math.pow(CommonConstants.TEN, -suffix) * prefixNumber); + return (prefix + CommonConstants.E + suffix); + } +} + export default new CalculateUtil(); \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/util/CheckEmptyUtil.ets b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/util/CheckEmptyUtil.ets index 40b849aced..1fd436a17f 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/util/CheckEmptyUtil.ets +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/util/CheckEmptyUtil.ets @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2024 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. - */ - - -class CheckEmptyUtil { - /** - * Check obj is empty. - * - * @param {object} obj - * @return {boolean} true(empty) - */ - isEmpty(obj: object | string): boolean { - return (typeof obj === 'undefined' || obj === null || obj === ''); - } - - /** - * Check str is empty. - * - * @param {string} str - * @return {boolean} true(empty) - */ - checkStrIsEmpty(str: string): boolean { - return str.trim().length === 0; - } - - /** - * Check array is empty. - * - * @param {Array}arr - * @return {boolean} true(empty) - */ - isEmptyArr(arr: Array) { - return arr.length === 0; - } -} - -export default new CheckEmptyUtil(); - +/* + * Copyright (c) 2024 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. + */ + + +class CheckEmptyUtil { + /** + * Check obj is empty. + * + * @param {object} obj + * @return {boolean} true(empty) + */ + isEmpty(obj: object | string): boolean { + return (typeof obj === 'undefined' || obj === null || obj === ''); + } + + /** + * Check str is empty. + * + * @param {string} str + * @return {boolean} true(empty) + */ + checkStrIsEmpty(str: string): boolean { + return str.trim().length === 0; + } + + /** + * Check array is empty. + * + * @param {Array}arr + * @return {boolean} true(empty) + */ + isEmptyArr(arr: Array) { + return arr.length === 0; + } +} + +export default new CheckEmptyUtil(); + diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/entryability/EntryAbility.ets b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/entryability/EntryAbility.ets index 9668c36c46..450c59f024 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2024 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, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; -import EmbeddableUIAbility from '@ohos.app.ability.EmbeddableUIAbility'; -import commonEventManager from '@ohos.commonEventManager'; - -export default class EntryAbility extends EmbeddableUIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - let options: commonEventManager.CommonEventPublishData = { - parameters: { - 'bundleName': this.context.abilityInfo.bundleName, - } - } - commonEventManager.publish('GetCurrentTopAbility', options, async () => { - }) - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2024 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, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import EmbeddableUIAbility from '@ohos.app.ability.EmbeddableUIAbility'; +import commonEventManager from '@ohos.commonEventManager'; + +export default class EntryAbility extends EmbeddableUIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + let options: commonEventManager.CommonEventPublishData = { + parameters: { + 'bundleName': this.context.abilityInfo.bundleName, + } + } + commonEventManager.publish('GetCurrentTopAbility', options, async () => { + }) + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/viewmodel/PressKeysItem.ets b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/viewmodel/PressKeysItem.ets index 4349bfda42..fe8fa5002b 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/viewmodel/PressKeysItem.ets +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/viewmodel/PressKeysItem.ets @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2024 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 class PressKeysBean { - public flag: number; - public width: string; - public height: string; - public value: string; - public source?: Resource; - - constructor(flag: number, width: string, height: string, value: string, source?: Resource) { - this.flag = flag; - this.width = width; - this.height = height; - this.value = value; - this.source = source; - } +/* + * Copyright (c) 2024 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 class PressKeysBean { + public flag: number; + public width: string; + public height: string; + public value: string; + public source?: Resource; + + constructor(flag: number, width: string, height: string, value: string, source?: Resource) { + this.flag = flag; + this.width = width; + this.height = height; + this.value = value; + this.source = source; + } } \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/viewmodel/PresskeysViewModel.ets b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/viewmodel/PresskeysViewModel.ets index 8305ad33d5..63b34da339 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/viewmodel/PresskeysViewModel.ets +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/viewmodel/PresskeysViewModel.ets @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2024 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 { PressKeysBean } from './PressKeysItem'; - -export class PressKeysBeanViewModel { - /** - * Key array data. - */ - getPressKeys(): Array> { - return [ - [ - new PressKeysBean(0, '32vp', '32vp', 'clean', $r('app.media.ic_clean')), - new PressKeysBean(1, '19vp', '43vp', '7'), - new PressKeysBean(1, '19vp', '43vp', '4'), - new PressKeysBean(1, '19vp', '43vp', '1'), - new PressKeysBean(1, '25vp', '43vp', '%') - ], - [ - new PressKeysBean(0, '32vp', '32vp', 'div', $r('app.media.ic_div')), - new PressKeysBean(1, '19vp', '43vp', '8'), - new PressKeysBean(1, '19vp', '43vp', '5'), - new PressKeysBean(1, '19vp', '43vp', '2'), - new PressKeysBean(1, '19vp', '43vp', '0') - ], - [ - new PressKeysBean(0, '32vp', '32vp', 'mul', $r('app.media.ic_mul')), - new PressKeysBean(1, '19vp', '43vp', '9'), - new PressKeysBean(1, '19vp', '43vp', '6'), - new PressKeysBean(1, '19vp', '43vp', '3'), - new PressKeysBean(1, '19vp', '43vp', '.') - ], - [ - new PressKeysBean(0, '30.48vp', '20vp', 'del', $r('app.media.ic_del')), - new PressKeysBean(0, '24vp', '24vp', 'min', $r('app.media.ic_min')), - new PressKeysBean(0, '32vp', '32vp', 'add', $r('app.media.ic_add')), - new PressKeysBean(0, '32vp', '32vp', 'equ', $r('app.media.ic_equ')) - ] - ]; - } -} - -let keysModel = new PressKeysBeanViewModel(); - +/* + * Copyright (c) 2024 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 { PressKeysBean } from './PressKeysItem'; + +export class PressKeysBeanViewModel { + /** + * Key array data. + */ + getPressKeys(): Array> { + return [ + [ + new PressKeysBean(0, '32vp', '32vp', 'clean', $r('app.media.ic_clean')), + new PressKeysBean(1, '19vp', '43vp', '7'), + new PressKeysBean(1, '19vp', '43vp', '4'), + new PressKeysBean(1, '19vp', '43vp', '1'), + new PressKeysBean(1, '25vp', '43vp', '%') + ], + [ + new PressKeysBean(0, '32vp', '32vp', 'div', $r('app.media.ic_div')), + new PressKeysBean(1, '19vp', '43vp', '8'), + new PressKeysBean(1, '19vp', '43vp', '5'), + new PressKeysBean(1, '19vp', '43vp', '2'), + new PressKeysBean(1, '19vp', '43vp', '0') + ], + [ + new PressKeysBean(0, '32vp', '32vp', 'mul', $r('app.media.ic_mul')), + new PressKeysBean(1, '19vp', '43vp', '9'), + new PressKeysBean(1, '19vp', '43vp', '6'), + new PressKeysBean(1, '19vp', '43vp', '3'), + new PressKeysBean(1, '19vp', '43vp', '.') + ], + [ + new PressKeysBean(0, '30.48vp', '20vp', 'del', $r('app.media.ic_del')), + new PressKeysBean(0, '24vp', '24vp', 'min', $r('app.media.ic_min')), + new PressKeysBean(0, '32vp', '32vp', 'add', $r('app.media.ic_add')), + new PressKeysBean(0, '32vp', '32vp', 'equ', $r('app.media.ic_equ')) + ] + ]; + } +} + +let keysModel = new PressKeysBeanViewModel(); + export default keysModel as PressKeysBeanViewModel; \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/module.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/module.json5 index bbda7f34bc..8bac476312 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/module.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2024 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": [ - "phone", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": true, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ets", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2024 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": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/resources/base/element/color.json b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/resources/base/element/color.json index cec71ab276..ea07df432d 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/resources/base/element/color.json @@ -1,32 +1,32 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "input_back_color", - "value": "#F5F5F5" - }, - { - "name": "text_color", - "value": "#182431" - }, - { - "name": "border_color", - "value": "#F5F5F5" - }, - { - "name": "equals_back_color", - "value": "#007DFF" - }, - { - "name": "row_back_color", - "value": "#F8F8FF" - }, - { - "name": "column_back_color", - "value": "#F5F5F5" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "input_back_color", + "value": "#F5F5F5" + }, + { + "name": "text_color", + "value": "#182431" + }, + { + "name": "border_color", + "value": "#F5F5F5" + }, + { + "name": "equals_back_color", + "value": "#007DFF" + }, + { + "name": "row_back_color", + "value": "#F8F8FF" + }, + { + "name": "column_back_color", + "value": "#F5F5F5" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/resources/base/element/float.json b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/resources/base/element/float.json index f652110bc2..5450b9d27f 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/resources/base/element/float.json +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/resources/base/element/float.json @@ -1,76 +1,76 @@ -{ - "float": [ - { - "name": "float_1", - "value": "30.6" - }, - { - "name": "font_size_input", - "value": "64fp" - }, - { - "name": "font_size_text", - "value": "32fp" - }, - { - "name": "font_size_dot", - "value": "42fp" - }, - { - "name": "input_height", - "value": "86vp" - }, - { - "name": "input_margin_right", - "value": "22vp" - }, - { - "name": "input_margin_top", - "value": "121.96vp" - }, - { - "name": "text_height", - "value": "43vp" - }, - { - "name": "text_margin_right", - "value": "21vp" - }, - { - "name": "text_margin_bottom", - "value": "64vp" - }, - { - "name": "key_width", - "value": "70vp" - }, - { - "name": "key_height", - "value": "60vp" - }, - { - "name": "equals_height", - "value": "125vp" - }, - { - "name": "border_radius", - "value": "36vp" - }, - { - "name": "margin_top", - "value": "70vp" - }, - { - "name": "margin_bottom", - "value": "40vp" - }, - { - "name": "margin_left", - "value": "19vp" - }, - { - "name": "margin_right", - "value": "19vp" - } - ] +{ + "float": [ + { + "name": "float_1", + "value": "30.6" + }, + { + "name": "font_size_input", + "value": "64fp" + }, + { + "name": "font_size_text", + "value": "32fp" + }, + { + "name": "font_size_dot", + "value": "42fp" + }, + { + "name": "input_height", + "value": "86vp" + }, + { + "name": "input_margin_right", + "value": "22vp" + }, + { + "name": "input_margin_top", + "value": "121.96vp" + }, + { + "name": "text_height", + "value": "43vp" + }, + { + "name": "text_margin_right", + "value": "21vp" + }, + { + "name": "text_margin_bottom", + "value": "64vp" + }, + { + "name": "key_width", + "value": "70vp" + }, + { + "name": "key_height", + "value": "60vp" + }, + { + "name": "equals_height", + "value": "125vp" + }, + { + "name": "border_radius", + "value": "36vp" + }, + { + "name": "margin_top", + "value": "70vp" + }, + { + "name": "margin_bottom", + "value": "40vp" + }, + { + "name": "margin_left", + "value": "19vp" + }, + { + "name": "margin_right", + "value": "19vp" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/ohosTest/module.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/ohosTest/module.json5 index af8cda384e..c5691d0a8c 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/ohosTest/module.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": true - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true + } +} diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/hvigor/hvigor-config.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/hvigor/hvigor-config.json5 index 5f9d8a5758..76e3231223 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/hvigor/hvigor-config.json5 @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2024 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*/ - } -} +/* + * Copyright (c) 2024 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/SystemFeature/FullScreenStart/FullScreenStart_Service/oh-package.json5 b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/oh-package.json5 index d645a02be5..a941f44583 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart_Service/oh-package.json5 +++ b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2024 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" - } -} +/* + * Copyright (c) 2024 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/SystemFeature/Security/AuthorizedButton/AppScope/app.json5 b/code/SystemFeature/Security/AuthorizedButton/AppScope/app.json5 index 8e149b0fc4..1e9e6d483c 100644 --- a/code/SystemFeature/Security/AuthorizedButton/AppScope/app.json5 +++ b/code/SystemFeature/Security/AuthorizedButton/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.authorizedbutton", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name", - "distributedNotificationEnabled": true - } -} +/* + * Copyright (c) 2023 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.authorizedbutton", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/code/SystemFeature/Security/AuthorizedButton/AppScope/resources/base/element/string.json b/code/SystemFeature/Security/AuthorizedButton/AppScope/resources/base/element/string.json index 9c6894f1d5..dfd987d612 100644 --- a/code/SystemFeature/Security/AuthorizedButton/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/Security/AuthorizedButton/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AuthorizedButton" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "AuthorizedButton" + } + ] +} diff --git a/code/SystemFeature/Security/AuthorizedButton/README_zh.md b/code/SystemFeature/Security/AuthorizedButton/README_zh.md index 965c2a0dda..ffb3e1e839 100644 --- a/code/SystemFeature/Security/AuthorizedButton/README_zh.md +++ b/code/SystemFeature/Security/AuthorizedButton/README_zh.md @@ -1,93 +1,93 @@ -# 安全控件类型的UI控件(仅对系统应用开放) - -### 介绍 - -本示例提供了安全控件类型的UI控件,支撑应用开发者集成安全控件做临时授权场景,当用户实际点击了某种类型的安全控件时,会对应用进行相应的临时授权,减少权限弹窗对用户的干扰,同时提供更小的授权范围。 - -### 效果预览 - -| 主页 | Location | Paste | **Save** | -|:--------------------------------------:|:----------------------------------------------:|:----------------------------------------:|:--------------------------------------:| -| ![main](screenshots/devices/main.jpeg) | ![location](screenshots/devices/location.jpeg) | ![paste](screenshots/devices/paste.jpeg) | ![save](screenshots/devices/save.jpeg) | - -使用说明 -1. 在主界面,点击“LocationButton安全控件”按钮,进入“LocationButton安全控件”界面,点击“当前位置”按钮,成功获取当前定位信息,并显示在方框中。 - -2. 在主界面,点击“PasteButton安全控件”按钮,进入“PasteButton安全控件”界面,点击”复制“按钮,复制下方“天天开心”文本,点击“粘贴”按钮,获取剪贴板内容并显示在其下方框中。 - -3. 在主界面,点击“SaveButton安全控件”按钮,进入“SaveButton安全控件”界面,点击“下载”按钮,将当前页面中的图片保存到本地图库中。 - -### 工程目录 - -``` -entry/src/main/ets/ -|---securitycomponent -| |---pages -| | |---Location.ets // 位置服务安全控件界面 -| | |---Paste.ets // 剪贴板安全控件界面 -| | |---Save.ets // 媒体库安全控件界面 -|---pages -| |---Index.ets // 首页 -|---common -| |---Component -| | |---AuthorizedButton.ets // 安全控件样式 -| | |---CopyButton.ets // 剪贴板复制控件 -| | |---LocationButton.ets // 位置服务安全控件 -| | |---PasteButton.ets // 剪贴板粘贴控件 -| | |---SaveButton.ets // 媒体库写入文件控件 -| | |---TitleBar.ets // 标题栏 -|---utils -| |---Logger.ts // 日志工具 -``` - -### 具体实现 - -* 本示例分为Location安全控件模块,剪贴板安全控件模块,媒体库安全控件模块 - - * Location安全控件模块 - - * 使用SecLocationButton组件开发获取定位信息功能,在其点击回调onclick事件中调用geoLocationManager.getCurrentLocation()得到当前定位信息经纬度 - * 源码链接:[LocationButton.ets](entry/src/main/ets/common/Component/LocationButton.ets) - * 接口参考:[@ohos.geoLocationManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-location-kit/js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation) - - * 剪贴板安全控件模块 - - * 使用SecPasteButton组件开发获取剪贴板信息功能,在其点击回调onclick事件中调用ystemPasteboard.setData()将文本复制到剪贴板中,systemPasteboard.getData()得到剪贴板内容 - * 源码链接:[PasteButton.ets](entry/src/main/ets/common/Component/PasteButton.ets) - * 接口参考:[@ohos.pasteboard](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-pasteboard.md#getdata9) - - * 媒体库安全控件模块 - - * 使用SecSaveButton组件开发保存图片到媒体库功能,在其点击回调onclick事件中调用photoAccessHelper.getPhotoAccessHelper()得到媒体库图片管理器helper, - helper.createAsset()得到保存到媒体库图片的uri, - resourceManager.getMediaContent()得到存放在Resources/base/media文件下的banner.png图片内容, - fs.open()和fs.write()将图片内容通过得到的uri写到媒体库中,最后fs.close()关闭文件 - * 源码链接:[SaveButton.ets](entry/src/main/ets/common/Component/SaveButton.ets) - * 接口参考:[@ohos.file.photoAccessHelper](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-media-library-kit/js-apis-photoAccessHelper.md),[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) - -### 相关权限 - -不涉及。 - -### 依赖 - -不涉及。 - -### 约束与限制 - -1. 本示例仅支持标准系统上运行,支持设备:GPS定位功能仅支持部分机型。 -2. 本示例仅支持API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0 Release)。 -3. 本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。 -4. 本示例需要使用系统权限的系统接口,需要使用Full SDK编译。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 - -### 下载 - -如需单独下载本工程,执行如下命令: - -``` -git init -git config core.sparsecheckout true -echo code/SystemFeature/Security/AuthorizedButton/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` +# 安全控件类型的UI控件(仅对系统应用开放) + +### 介绍 + +本示例提供了安全控件类型的UI控件,支撑应用开发者集成安全控件做临时授权场景,当用户实际点击了某种类型的安全控件时,会对应用进行相应的临时授权,减少权限弹窗对用户的干扰,同时提供更小的授权范围。 + +### 效果预览 + +| 主页 | Location | Paste | **Save** | +|:--------------------------------------:|:----------------------------------------------:|:----------------------------------------:|:--------------------------------------:| +| ![main](screenshots/devices/main.jpeg) | ![location](screenshots/devices/location.jpeg) | ![paste](screenshots/devices/paste.jpeg) | ![save](screenshots/devices/save.jpeg) | + +使用说明 +1. 在主界面,点击“LocationButton安全控件”按钮,进入“LocationButton安全控件”界面,点击“当前位置”按钮,成功获取当前定位信息,并显示在方框中。 + +2. 在主界面,点击“PasteButton安全控件”按钮,进入“PasteButton安全控件”界面,点击”复制“按钮,复制下方“天天开心”文本,点击“粘贴”按钮,获取剪贴板内容并显示在其下方框中。 + +3. 在主界面,点击“SaveButton安全控件”按钮,进入“SaveButton安全控件”界面,点击“下载”按钮,将当前页面中的图片保存到本地图库中。 + +### 工程目录 + +``` +entry/src/main/ets/ +|---securitycomponent +| |---pages +| | |---Location.ets // 位置服务安全控件界面 +| | |---Paste.ets // 剪贴板安全控件界面 +| | |---Save.ets // 媒体库安全控件界面 +|---pages +| |---Index.ets // 首页 +|---common +| |---Component +| | |---AuthorizedButton.ets // 安全控件样式 +| | |---CopyButton.ets // 剪贴板复制控件 +| | |---LocationButton.ets // 位置服务安全控件 +| | |---PasteButton.ets // 剪贴板粘贴控件 +| | |---SaveButton.ets // 媒体库写入文件控件 +| | |---TitleBar.ets // 标题栏 +|---utils +| |---Logger.ts // 日志工具 +``` + +### 具体实现 + +* 本示例分为Location安全控件模块,剪贴板安全控件模块,媒体库安全控件模块 + + * Location安全控件模块 + + * 使用SecLocationButton组件开发获取定位信息功能,在其点击回调onclick事件中调用geoLocationManager.getCurrentLocation()得到当前定位信息经纬度 + * 源码链接:[LocationButton.ets](entry/src/main/ets/common/Component/LocationButton.ets) + * 接口参考:[@ohos.geoLocationManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-location-kit/js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation) + + * 剪贴板安全控件模块 + + * 使用SecPasteButton组件开发获取剪贴板信息功能,在其点击回调onclick事件中调用ystemPasteboard.setData()将文本复制到剪贴板中,systemPasteboard.getData()得到剪贴板内容 + * 源码链接:[PasteButton.ets](entry/src/main/ets/common/Component/PasteButton.ets) + * 接口参考:[@ohos.pasteboard](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-pasteboard.md#getdata9) + + * 媒体库安全控件模块 + + * 使用SecSaveButton组件开发保存图片到媒体库功能,在其点击回调onclick事件中调用photoAccessHelper.getPhotoAccessHelper()得到媒体库图片管理器helper, + helper.createAsset()得到保存到媒体库图片的uri, + resourceManager.getMediaContent()得到存放在Resources/base/media文件下的banner.png图片内容, + fs.open()和fs.write()将图片内容通过得到的uri写到媒体库中,最后fs.close()关闭文件 + * 源码链接:[SaveButton.ets](entry/src/main/ets/common/Component/SaveButton.ets) + * 接口参考:[@ohos.file.photoAccessHelper](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-media-library-kit/js-apis-photoAccessHelper.md),[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:GPS定位功能仅支持部分机型。 +2. 本示例仅支持API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0 Release)。 +3. 本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。 +4. 本示例需要使用系统权限的系统接口,需要使用Full SDK编译。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/SystemFeature/Security/AuthorizedButton/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` diff --git a/code/SystemFeature/Security/AuthorizedButton/build-profile.json5 b/code/SystemFeature/Security/AuthorizedButton/build-profile.json5 index 260a3004b2..1e8e16dcb9 100644 --- a/code/SystemFeature/Security/AuthorizedButton/build-profile.json5 +++ b/code/SystemFeature/Security/AuthorizedButton/build-profile.json5 @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/build-profile.json5 b/code/SystemFeature/Security/AuthorizedButton/entry/build-profile.json5 index d4c82c4ea1..7981e75115 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/build-profile.json5 +++ b/code/SystemFeature/Security/AuthorizedButton/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/oh-package.json5 b/code/SystemFeature/Security/AuthorizedButton/entry/oh-package.json5 index a4800abca0..22827b13be 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/oh-package.json5 +++ b/code/SystemFeature/Security/AuthorizedButton/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/AuthorizedButton.ets b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/AuthorizedButton.ets index 70273cb33d..0cbcf2eba3 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/AuthorizedButton.ets +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/AuthorizedButton.ets @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct AuthorizedButton { - private title: Resource = $r('app.string.EntryAbility_label'); - @Link image: Resource; - @Link backColor: Resource; - @Link textColor: Resource; - - build() { - Row() { - Image(this.image) - .width(24) - .height(24) - .objectFit(ImageFit.Contain) - Text(this.title) - .fontSize(16) - .margin({ left: 5 }) - .fontColor(this.textColor) - } - .margin({ bottom: 10 }) - .width(92) - .height(40) - .justifyContent(FlexAlign.Center) - .alignItems(VerticalAlign.Center) - .borderRadius(20) - .backgroundColor(this.backColor) - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct AuthorizedButton { + private title: Resource = $r('app.string.EntryAbility_label'); + @Link image: Resource; + @Link backColor: Resource; + @Link textColor: Resource; + + build() { + Row() { + Image(this.image) + .width(24) + .height(24) + .objectFit(ImageFit.Contain) + Text(this.title) + .fontSize(16) + .margin({ left: 5 }) + .fontColor(this.textColor) + } + .margin({ bottom: 10 }) + .width(92) + .height(40) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + .borderRadius(20) + .backgroundColor(this.backColor) + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/CopyButton.ets b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/CopyButton.ets index ec77200aa3..1463e8bd32 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/CopyButton.ets +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/CopyButton.ets @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2023 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 pasteboard from '@ohos.pasteboard'; -import promptAction from '@ohos.promptAction'; -import { AuthorizedButton } from './AuthorizedButton'; -import Logger from "../../utils/Logger"; - -@Component -export struct CopyButton { - @Link copyContent: string; - @State copyButtonText: Resource = $r('app.string.Copy'); - @StorageLink('copyButtonFocused') copyButtonFocused: boolean = true; - @State imageFocused: Resource = $r('app.media.copy'); - @State backColorFocused: Resource = $r('app.color.button_default_bg_color'); - @State textColorFocused: Resource = $r('app.color.background_shallow_grey'); - @State imageNormal: Resource = $r('app.media.copy1'); - @State backColorNormal: Resource = $r('app.color.button_default_text_color'); - @State textColorNormal: Resource = $r('app.color.button_default_bg_color1'); - - promptAction(message: string | Resource) { - try { - promptAction.showToast({ - message: message, - duration: 3000, - }); - } catch (error) { - Logger.error(`showToast args error code is ${error.code}, message is ${error.message}`); - } - } - - build() { - Column() { - Row() { - if (this.copyButtonFocused) { - AuthorizedButton({ - title: this.copyButtonText, - image: $imageFocused, - backColor: $backColorFocused, - textColor: $textColorFocused, - }) - } else { - AuthorizedButton({ - title: this.copyButtonText, - image: $imageNormal, - backColor: $backColorNormal, - textColor: $textColorNormal, - }) - } - } - .id('copyButton') - .onClick(() => { - this.copyButtonFocused = true; - let systemPasteboard = pasteboard.getSystemPasteboard(); - let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, this.copyContent); - systemPasteboard = pasteboard.getSystemPasteboard(); - systemPasteboard.setData(pasteData).then(async () => { - this.promptAction($r('app.string.Copy_succeed')); - Logger.info('Succeeded in setting PasteData.'); - }); - }) - } - } +/* + * Copyright (c) 2023 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 pasteboard from '@ohos.pasteboard'; +import promptAction from '@ohos.promptAction'; +import { AuthorizedButton } from './AuthorizedButton'; +import Logger from "../../utils/Logger"; + +@Component +export struct CopyButton { + @Link copyContent: string; + @State copyButtonText: Resource = $r('app.string.Copy'); + @StorageLink('copyButtonFocused') copyButtonFocused: boolean = true; + @State imageFocused: Resource = $r('app.media.copy'); + @State backColorFocused: Resource = $r('app.color.button_default_bg_color'); + @State textColorFocused: Resource = $r('app.color.background_shallow_grey'); + @State imageNormal: Resource = $r('app.media.copy1'); + @State backColorNormal: Resource = $r('app.color.button_default_text_color'); + @State textColorNormal: Resource = $r('app.color.button_default_bg_color1'); + + promptAction(message: string | Resource) { + try { + promptAction.showToast({ + message: message, + duration: 3000, + }); + } catch (error) { + Logger.error(`showToast args error code is ${error.code}, message is ${error.message}`); + } + } + + build() { + Column() { + Row() { + if (this.copyButtonFocused) { + AuthorizedButton({ + title: this.copyButtonText, + image: $imageFocused, + backColor: $backColorFocused, + textColor: $textColorFocused, + }) + } else { + AuthorizedButton({ + title: this.copyButtonText, + image: $imageNormal, + backColor: $backColorNormal, + textColor: $textColorNormal, + }) + } + } + .id('copyButton') + .onClick(() => { + this.copyButtonFocused = true; + let systemPasteboard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, this.copyContent); + systemPasteboard = pasteboard.getSystemPasteboard(); + systemPasteboard.setData(pasteData).then(async () => { + this.promptAction($r('app.string.Copy_succeed')); + Logger.info('Succeeded in setting PasteData.'); + }); + }) + } + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/LocationButton.ets b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/LocationButton.ets index b80512a814..8de65ed63a 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/LocationButton.ets +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/LocationButton.ets @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2023 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 { BusinessError } from '@ohos.base'; -import common from '@ohos.app.ability.common'; -import geoLocationManager from '@ohos.geoLocationManager'; -import promptAction from '@ohos.promptAction'; -import Logger from '../../utils/Logger'; - -let context: common.Context; - -@Component -export struct SecLocationButton { - @State message: string = ''; - @Link location: string; - - @State textTitle: string = ''; - @State textValue: string = ''; - @State backColor: Resource = $r('app.color.button_default_bg_color'); - @State textColor: Resource = $r('app.color.start_window_background'); - @State image: Resource = $r('app.media.position'); - - aboutToDisappear() { - try { - context.resourceManager.getStringByName("User_authorized").then(value => { - this.textTitle = value; - }).catch ((error: string) => { - Logger.info('promise, getCurrentLocation: error=' + error); - }); - } catch (error) { - let e: BusinessError = error as BusinessError; - Logger.error(`promise getStringByName failed, error code: ${e.code}, message: ${e.message}.`); - } - try { - context.resourceManager.getStringByName("Loading_positioning").then(value => { - this.textValue = value; - }).catch ((error: string) => { - Logger.info('promise, getCurrentLocation: error=' + JSON.stringify(error)); - }); - } catch (error) { - let e: BusinessError = error as BusinessError; - Logger.error(`promise getStringByName failed, error code: ${e.code}, message: ${e.message}.`); - } - } - - onCancel() { - Logger.info('Callback when the first button is clicked'); - } - - getLocation(): void { - let requestInfo: Record = { - 'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, - 'scenario': geoLocationManager.LocationRequestScenario.UNSET, - 'maxAccuracy': 0, - }; - try { - // 得到当前定位信息经纬度 - geoLocationManager.getCurrentLocation(requestInfo).then((result) => { - Logger.info('current location: ' + JSON.stringify(result)); - this.location = JSON.stringify(result); - }).catch ((error: string) => { - this.promptAction(JSON.stringify(error)); - Logger.info('promise, getCurrentLocation: error=' + JSON.stringify(error)); - }); - } catch (error) { - this.promptAction(JSON.stringify(error.message)); - let e: BusinessError = error as BusinessError; - Logger.error(`promise getStringByName failed, error code: ${e.code}, message: ${e.message}.`); - } - } - - promptAction( message : string ) { - this.message = message; - try { - promptAction.showToast({ - message: message, - duration: 60000, - }); - } catch (error) { - let e: BusinessError = error as BusinessError; - Logger.error(`promise getStringByName failed, error code: ${e.code}, message: ${e.message}.`); - } - } - - build() { - Row() { - LocationButton() - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - if(result == LocationButtonOnClickResult.SUCCESS){ - this.getLocation(); - } - Logger.error('SecLocationButton onClick result ' + result); - }) - } - .id('locationButton') - } -} +/* + * Copyright (c) 2023 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 { BusinessError } from '@ohos.base'; +import common from '@ohos.app.ability.common'; +import geoLocationManager from '@ohos.geoLocationManager'; +import promptAction from '@ohos.promptAction'; +import Logger from '../../utils/Logger'; + +let context: common.Context; + +@Component +export struct SecLocationButton { + @State message: string = ''; + @Link location: string; + + @State textTitle: string = ''; + @State textValue: string = ''; + @State backColor: Resource = $r('app.color.button_default_bg_color'); + @State textColor: Resource = $r('app.color.start_window_background'); + @State image: Resource = $r('app.media.position'); + + aboutToDisappear() { + try { + context.resourceManager.getStringByName("User_authorized").then(value => { + this.textTitle = value; + }).catch ((error: string) => { + Logger.info('promise, getCurrentLocation: error=' + error); + }); + } catch (error) { + let e: BusinessError = error as BusinessError; + Logger.error(`promise getStringByName failed, error code: ${e.code}, message: ${e.message}.`); + } + try { + context.resourceManager.getStringByName("Loading_positioning").then(value => { + this.textValue = value; + }).catch ((error: string) => { + Logger.info('promise, getCurrentLocation: error=' + JSON.stringify(error)); + }); + } catch (error) { + let e: BusinessError = error as BusinessError; + Logger.error(`promise getStringByName failed, error code: ${e.code}, message: ${e.message}.`); + } + } + + onCancel() { + Logger.info('Callback when the first button is clicked'); + } + + getLocation(): void { + let requestInfo: Record = { + 'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, + 'scenario': geoLocationManager.LocationRequestScenario.UNSET, + 'maxAccuracy': 0, + }; + try { + // 得到当前定位信息经纬度 + geoLocationManager.getCurrentLocation(requestInfo).then((result) => { + Logger.info('current location: ' + JSON.stringify(result)); + this.location = JSON.stringify(result); + }).catch ((error: string) => { + this.promptAction(JSON.stringify(error)); + Logger.info('promise, getCurrentLocation: error=' + JSON.stringify(error)); + }); + } catch (error) { + this.promptAction(JSON.stringify(error.message)); + let e: BusinessError = error as BusinessError; + Logger.error(`promise getStringByName failed, error code: ${e.code}, message: ${e.message}.`); + } + } + + promptAction( message : string ) { + this.message = message; + try { + promptAction.showToast({ + message: message, + duration: 60000, + }); + } catch (error) { + let e: BusinessError = error as BusinessError; + Logger.error(`promise getStringByName failed, error code: ${e.code}, message: ${e.message}.`); + } + } + + build() { + Row() { + LocationButton() + .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { + if(result == LocationButtonOnClickResult.SUCCESS){ + this.getLocation(); + } + Logger.error('SecLocationButton onClick result ' + result); + }) + } + .id('locationButton') + } +} diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/PasteButton.ets b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/PasteButton.ets index 77c51271f7..010a797d20 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/PasteButton.ets +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/PasteButton.ets @@ -1,87 +1,87 @@ -/* - * Copyright (c) 2023 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 { BusinessError } from '@ohos.base'; -import pasteboard from '@ohos.pasteboard'; -import promptAction from '@ohos.promptAction'; -import Logger from '../../utils/Logger'; - -@Component -export struct SecPasteButton { - @Link pasteContent: string; - @StorageLink('copyButtonFocused') copyButtonFocused: boolean = true; - @State imageFocused: Resource = $r('app.media.paste1'); - @State backColorFocused: Resource = $r('app.color.button_default_bg_color1'); - @State textColorFocused: Resource = $r('app.color.button_default_bg_color'); - @State imageNormal: Resource = $r('app.media.paste'); - @State backColorNormal: Resource = $r('app.color.button_default_bg_color1'); - @State textColorNormal: Resource = $r('app.color.button_default_text_color'); - - pastToMessage() { - let systemPasteboard = pasteboard.getSystemPasteboard(); - systemPasteboard.getData().then((pasteData) => { - let primaryText = pasteData.getPrimaryText(); - this.pasteContent = primaryText; - if (!primaryText) { - this.promptAction('Empty'); - } - this.promptAction($r('app.string.Paste_succeed')); - Logger.error('Succeed to get PasteData. primaryText' + primaryText); - }).catch ((error: string) => { - this.promptAction(error); - Logger.info('promise, getCurrentLocation: error=' + JSON.stringify(error)); - }); - } - - promptAction(message: string | Resource) { - try { - promptAction.showToast({ - message: message, - duration: 3000, - }); - } catch (error) { - let e: BusinessError = error as BusinessError; - Logger.error(`showToast args error code is ${e.code}, message is ${e.message}`); - } - } - - build() { - Column() { - Row() { - if (!this.copyButtonFocused) { - PasteButton({ - icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule - }) - .onClick(() => { - this.copyButtonFocused = false; - this.pastToMessage(); - }) - .backgroundColor(this.backColorFocused) - .fontColor(this.textColorFocused) - } else { - PasteButton({ - icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule - }) - .onClick(() => { - this.copyButtonFocused = false; - this.pastToMessage(); - }) - .backgroundColor(this.backColorNormal) - .fontColor(this.textColorNormal) - } - } - } - } -} +/* + * Copyright (c) 2023 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 { BusinessError } from '@ohos.base'; +import pasteboard from '@ohos.pasteboard'; +import promptAction from '@ohos.promptAction'; +import Logger from '../../utils/Logger'; + +@Component +export struct SecPasteButton { + @Link pasteContent: string; + @StorageLink('copyButtonFocused') copyButtonFocused: boolean = true; + @State imageFocused: Resource = $r('app.media.paste1'); + @State backColorFocused: Resource = $r('app.color.button_default_bg_color1'); + @State textColorFocused: Resource = $r('app.color.button_default_bg_color'); + @State imageNormal: Resource = $r('app.media.paste'); + @State backColorNormal: Resource = $r('app.color.button_default_bg_color1'); + @State textColorNormal: Resource = $r('app.color.button_default_text_color'); + + pastToMessage() { + let systemPasteboard = pasteboard.getSystemPasteboard(); + systemPasteboard.getData().then((pasteData) => { + let primaryText = pasteData.getPrimaryText(); + this.pasteContent = primaryText; + if (!primaryText) { + this.promptAction('Empty'); + } + this.promptAction($r('app.string.Paste_succeed')); + Logger.error('Succeed to get PasteData. primaryText' + primaryText); + }).catch ((error: string) => { + this.promptAction(error); + Logger.info('promise, getCurrentLocation: error=' + JSON.stringify(error)); + }); + } + + promptAction(message: string | Resource) { + try { + promptAction.showToast({ + message: message, + duration: 3000, + }); + } catch (error) { + let e: BusinessError = error as BusinessError; + Logger.error(`showToast args error code is ${e.code}, message is ${e.message}`); + } + } + + build() { + Column() { + Row() { + if (!this.copyButtonFocused) { + PasteButton({ + icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule + }) + .onClick(() => { + this.copyButtonFocused = false; + this.pastToMessage(); + }) + .backgroundColor(this.backColorFocused) + .fontColor(this.textColorFocused) + } else { + PasteButton({ + icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule + }) + .onClick(() => { + this.copyButtonFocused = false; + this.pastToMessage(); + }) + .backgroundColor(this.backColorNormal) + .fontColor(this.textColorNormal) + } + } + } + } +} diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/SaveButton.ets b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/SaveButton.ets index 024e7fc025..c1700c8e3b 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/SaveButton.ets +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/common/Component/SaveButton.ets @@ -1,88 +1,88 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import fs from '@ohos.file.fs'; -import photoAccessHelper from '@ohos.file.photoAccessHelper'; -import promptAction from '@ohos.promptAction'; -import Logger from '../../utils/Logger'; -import dataSharePredicates from '@ohos.data.dataSharePredicates'; - - -@Component -export struct SecSaveButton { - @State backColor: Resource = $r('app.color.button_default_bg_color1'); - @State textColor: Resource = $r('app.color.button_default_bg_color'); - @State image: Resource = $r('app.media.save'); - @Link saveImage: Resource; - private screenDensity: number = 0; - - promptAction(message: string | Resource) { - try { - promptAction.showToast({ - message: message, - duration: 6000, - }); - } catch (error) { - Logger.error(`showToast args error code is ${error.code}, message is ${error.message}`); - } - } - - async saveMedia() { - try { - const context = getContext(this); - // 得到图片内容 - try { - context.resourceManager.getMediaContent($r('app.media.banner').id, async (error, value) => { - if (error != null) { - Logger.error("error is " + error); - } else { - let media = value.buffer; - let helper = photoAccessHelper.getPhotoAccessHelper(context); - let uri = await helper.createAsset(photoAccessHelper.PhotoType.IMAGE, 'png'); - // 通过uri打开媒体库文件 - let file = await fs.open(uri, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); - Logger.info('openFile success, fd: ' + file.fd); - // 写到媒体库文件中 - await fs.write(file.fd, media); - await fs.close(file.fd); - this.promptAction($r('app.string.Save_succeed')); - } - }); - } catch (error) { - Logger.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`); - } - - } catch (err) { - this.promptAction($r('app.string.Save_failed')); - Logger.error(`promiseerror code: ${err.code}, message: ${err.message}.`); - } - } - build() { - Column() { - SaveButton() - .onClick(async (event, result) => { - if (result === SaveButtonOnClickResult.SUCCESS) { - Logger.info("SUCCESS"); - this.saveMedia(); - } - if(result === SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED){ - Logger.info("TEMPORARY_AUTHORIZATION_FAILED"); - } - }) - } - .id('saveButton') - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import fs from '@ohos.file.fs'; +import photoAccessHelper from '@ohos.file.photoAccessHelper'; +import promptAction from '@ohos.promptAction'; +import Logger from '../../utils/Logger'; +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + + +@Component +export struct SecSaveButton { + @State backColor: Resource = $r('app.color.button_default_bg_color1'); + @State textColor: Resource = $r('app.color.button_default_bg_color'); + @State image: Resource = $r('app.media.save'); + @Link saveImage: Resource; + private screenDensity: number = 0; + + promptAction(message: string | Resource) { + try { + promptAction.showToast({ + message: message, + duration: 6000, + }); + } catch (error) { + Logger.error(`showToast args error code is ${error.code}, message is ${error.message}`); + } + } + + async saveMedia() { + try { + const context = getContext(this); + // 得到图片内容 + try { + context.resourceManager.getMediaContent($r('app.media.banner').id, async (error, value) => { + if (error != null) { + Logger.error("error is " + error); + } else { + let media = value.buffer; + let helper = photoAccessHelper.getPhotoAccessHelper(context); + let uri = await helper.createAsset(photoAccessHelper.PhotoType.IMAGE, 'png'); + // 通过uri打开媒体库文件 + let file = await fs.open(uri, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + Logger.info('openFile success, fd: ' + file.fd); + // 写到媒体库文件中 + await fs.write(file.fd, media); + await fs.close(file.fd); + this.promptAction($r('app.string.Save_succeed')); + } + }); + } catch (error) { + Logger.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`); + } + + } catch (err) { + this.promptAction($r('app.string.Save_failed')); + Logger.error(`promiseerror code: ${err.code}, message: ${err.message}.`); + } + } + build() { + Column() { + SaveButton() + .onClick(async (event, result) => { + if (result === SaveButtonOnClickResult.SUCCESS) { + Logger.info("SUCCESS"); + this.saveMedia(); + } + if(result === SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED){ + Logger.info("TEMPORARY_AUTHORIZATION_FAILED"); + } + }) + } + .id('saveButton') + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/entryability/EntryAbility.ts b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/entryability/EntryAbility.ts index 5f07b82124..46e7640d1a 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import window from '@ohos.window'; -import Logger from '../utils/Logger'; - -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - Logger.info('testTag', '%{public}s', 'Ability onCreate'); - } - - onDestroy() { - Logger.info('testTag', '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - - // Main window is created, set main page for this ability - Logger.info('testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - Logger.error('testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - - Logger.info('testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - Logger.info('testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - Logger.info('testTag', '%{public}s', 'Ability onForeground'); - } - - onBackground() { - // Ability has back to background - Logger.info('testTag', '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; +import Logger from '../utils/Logger'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + Logger.info('testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + Logger.info('testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + + // Main window is created, set main page for this ability + Logger.info('testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error('testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + + Logger.info('testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + Logger.info('testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + Logger.info('testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + Logger.info('testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Location.ets b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Location.ets index 1b3f3666d4..6adfa96eb2 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Location.ets +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Location.ets @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router'; -import { SecLocationButton } from '../../common/Component/LocationButton'; -import { TitleBar } from '../../common/Component/TitleBar'; -import { IntroductionTitle } from '../../common/Component/IntroductionTitle'; - -@Extend(Column) function backgroundStyle() { - .size({ width: '95%', height: 139 }) - .margin({ top: 5 }) - .padding(12) - .borderRadius(24) - .alignItems(HorizontalAlign.Start) - .backgroundColor(Color.White) -} - -@Entry -@Component -struct Location { - @State location: string = ''; - - build() { - Column() { - TitleBar({ title: $r('app.string.EntryAbility_label') }) - .id('backBtn') - .onClick(() => { - router.back(); - }) - IntroductionTitle({ introduction: $r('app.string.Locate_information') }) - Column() { - Text(this.location ? this.location : $r('app.string.Get_current_positioning_information')) - } - .backgroundStyle() - - Column() { - SecLocationButton({ - location: $location - }) - } - .layoutWeight(1) - .padding(30) - .justifyContent(FlexAlign.End) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.background_shallow_grey')) - } +/* + * Copyright (c) 2023 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 router from '@ohos.router'; +import { SecLocationButton } from '../../common/Component/LocationButton'; +import { TitleBar } from '../../common/Component/TitleBar'; +import { IntroductionTitle } from '../../common/Component/IntroductionTitle'; + +@Extend(Column) function backgroundStyle() { + .size({ width: '95%', height: 139 }) + .margin({ top: 5 }) + .padding(12) + .borderRadius(24) + .alignItems(HorizontalAlign.Start) + .backgroundColor(Color.White) +} + +@Entry +@Component +struct Location { + @State location: string = ''; + + build() { + Column() { + TitleBar({ title: $r('app.string.EntryAbility_label') }) + .id('backBtn') + .onClick(() => { + router.back(); + }) + IntroductionTitle({ introduction: $r('app.string.Locate_information') }) + Column() { + Text(this.location ? this.location : $r('app.string.Get_current_positioning_information')) + } + .backgroundStyle() + + Column() { + SecLocationButton({ + location: $location + }) + } + .layoutWeight(1) + .padding(30) + .justifyContent(FlexAlign.End) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.background_shallow_grey')) + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Paste.ets b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Paste.ets index ced8fe87a4..970a0601ca 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Paste.ets +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Paste.ets @@ -1,117 +1,117 @@ -/* - * Copyright (c) 2023 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 { BusinessError } from '@ohos.base'; -import common from '@ohos.app.ability.common'; -import Logger from '../../utils/Logger'; -import router from '@ohos.router'; -import promptAction from '@ohos.promptAction'; -import { SecPasteButton } from '../../common/Component/PasteButton'; -import { CopyButton } from '../../common/Component/CopyButton'; -import { TitleBar } from '../../common/Component/TitleBar'; -import { IntroductionTitle } from '../../common/Component/IntroductionTitle'; - -@Extend(Column) function backgroundStyle() { - .size({ width: '95%', height: 139 }) - .margin({ top: 5 }) - .padding(12) - .borderRadius(24) - .alignItems(HorizontalAlign.Start) - .backgroundColor(Color.White) -} - -@Entry -@Component -struct Paste { - @State pasteContent: string = ''; - @State copyContent: string = ''; - - promptAction(message: string) { - try { - promptAction.showToast({ - message: message, - duration: 2000, - }); - } catch (error) { - Logger.error(`showToast args error code is ${error.code}, message is ${error.message}`); - } - ; - } - - aboutToAppear() { - let context: common.Context = getContext(this); - try { - context.resourceManager.getStringValue($r('app.string.Happy_every_day').id, (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - this.copyContent = value; - } - }); - } catch (error) { - let e: BusinessError = error as BusinessError; - Logger.error(`promise getStringByName failed, error code: ${e.code}, message: ${e.message}.`); - } - } - - build() { - Column() { - TitleBar({ title: $r('app.string.EntryAbility_label') }) - .id('backBtn') - .onClick(() => { - router.back(); - }) - IntroductionTitle({ introduction: $r('app.string.Copy_content') }) - Column() { - TextInput({ text: this.copyContent }) - .backgroundColor(Color.White) - .fontColor(Color.Black) - .enableKeyboardOnFocus(false) - .onChange((data => { - this.copyContent = data; - })) - } - .padding({ top: 5 }) - .size({ width: '95%', height: 139 }) - .margin({ top: 5 }) - .borderRadius(24) - .alignItems(HorizontalAlign.Start) - .backgroundColor(Color.White) - - IntroductionTitle({ introduction: $r('app.string.Paste_content') }) - Column() { - Text(this.pasteContent) - .fontColor(Color.Black) - } - .backgroundStyle() - - Column() { - CopyButton({ - copyContent: $copyContent - }) - SecPasteButton({ - pasteContent: $pasteContent, - }) - } - .layoutWeight(1) - .padding(30) - .justifyContent(FlexAlign.End) - - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.background_shallow_grey')) - } -} +/* + * Copyright (c) 2023 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 { BusinessError } from '@ohos.base'; +import common from '@ohos.app.ability.common'; +import Logger from '../../utils/Logger'; +import router from '@ohos.router'; +import promptAction from '@ohos.promptAction'; +import { SecPasteButton } from '../../common/Component/PasteButton'; +import { CopyButton } from '../../common/Component/CopyButton'; +import { TitleBar } from '../../common/Component/TitleBar'; +import { IntroductionTitle } from '../../common/Component/IntroductionTitle'; + +@Extend(Column) function backgroundStyle() { + .size({ width: '95%', height: 139 }) + .margin({ top: 5 }) + .padding(12) + .borderRadius(24) + .alignItems(HorizontalAlign.Start) + .backgroundColor(Color.White) +} + +@Entry +@Component +struct Paste { + @State pasteContent: string = ''; + @State copyContent: string = ''; + + promptAction(message: string) { + try { + promptAction.showToast({ + message: message, + duration: 2000, + }); + } catch (error) { + Logger.error(`showToast args error code is ${error.code}, message is ${error.message}`); + } + ; + } + + aboutToAppear() { + let context: common.Context = getContext(this); + try { + context.resourceManager.getStringValue($r('app.string.Happy_every_day').id, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + this.copyContent = value; + } + }); + } catch (error) { + let e: BusinessError = error as BusinessError; + Logger.error(`promise getStringByName failed, error code: ${e.code}, message: ${e.message}.`); + } + } + + build() { + Column() { + TitleBar({ title: $r('app.string.EntryAbility_label') }) + .id('backBtn') + .onClick(() => { + router.back(); + }) + IntroductionTitle({ introduction: $r('app.string.Copy_content') }) + Column() { + TextInput({ text: this.copyContent }) + .backgroundColor(Color.White) + .fontColor(Color.Black) + .enableKeyboardOnFocus(false) + .onChange((data => { + this.copyContent = data; + })) + } + .padding({ top: 5 }) + .size({ width: '95%', height: 139 }) + .margin({ top: 5 }) + .borderRadius(24) + .alignItems(HorizontalAlign.Start) + .backgroundColor(Color.White) + + IntroductionTitle({ introduction: $r('app.string.Paste_content') }) + Column() { + Text(this.pasteContent) + .fontColor(Color.Black) + } + .backgroundStyle() + + Column() { + CopyButton({ + copyContent: $copyContent + }) + SecPasteButton({ + pasteContent: $pasteContent, + }) + } + .layoutWeight(1) + .padding(30) + .justifyContent(FlexAlign.End) + + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.background_shallow_grey')) + } +} diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Save.ets b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Save.ets index 1a7bf44263..d4fa75b886 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Save.ets +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/securitycomponent/pages/Save.ets @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2023 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 router from '@ohos.router'; -import { SecSaveButton } from '../../common/Component/SaveButton'; -import { TitleBar } from '../../common/Component/TitleBar'; - -@Extend(Column) function backgroundStyle() { - .size({ width: '95%', height: 139 }) - .margin({ top: 5 }) - .padding(12) - .borderRadius(24) - .alignItems(HorizontalAlign.Start) - .backgroundColor(Color.White) -} - -@Entry -@Component -struct Save { - @State saveImage: Resource = $r('app.media.banner'); - - build() { - Column() { - TitleBar({ title: $r('app.string.EntryAbility_label') }) - .id('backBtn') - .onClick(() => { - router.back() - }) - Column() { - Image($r('app.media.banner')) - .objectFit(ImageFit.Fill) - } - .backgroundStyle() - - Column() { - SecSaveButton({ - saveImage: $saveImage - }) - } - .layoutWeight(1) - .padding(30) - .justifyContent(FlexAlign.End) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.background_shallow_grey')) - } +/* + * Copyright (c) 2023 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 router from '@ohos.router'; +import { SecSaveButton } from '../../common/Component/SaveButton'; +import { TitleBar } from '../../common/Component/TitleBar'; + +@Extend(Column) function backgroundStyle() { + .size({ width: '95%', height: 139 }) + .margin({ top: 5 }) + .padding(12) + .borderRadius(24) + .alignItems(HorizontalAlign.Start) + .backgroundColor(Color.White) +} + +@Entry +@Component +struct Save { + @State saveImage: Resource = $r('app.media.banner'); + + build() { + Column() { + TitleBar({ title: $r('app.string.EntryAbility_label') }) + .id('backBtn') + .onClick(() => { + router.back() + }) + Column() { + Image($r('app.media.banner')) + .objectFit(ImageFit.Fill) + } + .backgroundStyle() + + Column() { + SecSaveButton({ + saveImage: $saveImage + }) + } + .layoutWeight(1) + .padding(30) + .justifyContent(FlexAlign.End) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.background_shallow_grey')) + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/utils/Logger.ts b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/utils/Logger.ts index 098b569cb7..06833b8ecf 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/utils/Logger.ts +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/ets/utils/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xF811; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xF811; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_AuthorizedButton]'); \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/module.json5 b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/module.json5 index b25438604c..8c60c22573 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/module.json5 +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 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", - "srcEntrance": "./ets/entryability/EntryAbility.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 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", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/resources/base/element/color.json b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/resources/base/element/color.json index ce6a3fe641..9bbf533551 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/main/resources/base/element/color.json @@ -1,32 +1,32 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "bottom_title_divider", - "value": "#99838388" - }, - { - "name": "font_color_shallow", - "value": "#99000000" - }, - { - "name": "background_shallow_grey", - "value": "#F1F3F5" - }, - { - "name": "button_default_bg_color", - "value": "#007DFF" - }, - { - "name": "button_default_bg_color1", - "value": "#eceef0" - }, - { - "name": "button_default_text_color", - "value": "#FF93BFEC" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "bottom_title_divider", + "value": "#99838388" + }, + { + "name": "font_color_shallow", + "value": "#99000000" + }, + { + "name": "background_shallow_grey", + "value": "#F1F3F5" + }, + { + "name": "button_default_bg_color", + "value": "#007DFF" + }, + { + "name": "button_default_bg_color1", + "value": "#eceef0" + }, + { + "name": "button_default_text_color", + "value": "#FF93BFEC" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/ohosTest/module.json5 b/code/SystemFeature/Security/AuthorizedButton/entry/src/ohosTest/module.json5 index 7402a58552..f5906847df 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "visible": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/SystemFeature/Security/AuthorizedButton/entry/src/ohosTest/utils/Logger.ts b/code/SystemFeature/Security/AuthorizedButton/entry/src/ohosTest/utils/Logger.ts index 098b569cb7..06833b8ecf 100644 --- a/code/SystemFeature/Security/AuthorizedButton/entry/src/ohosTest/utils/Logger.ts +++ b/code/SystemFeature/Security/AuthorizedButton/entry/src/ohosTest/utils/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xF811; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xF811; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Sample_AuthorizedButton]'); \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/hvigor/hvigor-config.json5 b/code/SystemFeature/Security/AuthorizedButton/hvigor/hvigor-config.json5 index ac737cf85f..e75281b258 100644 --- a/code/SystemFeature/Security/AuthorizedButton/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/Security/AuthorizedButton/hvigor/hvigor-config.json5 @@ -1,6 +1,6 @@ -{ - "hvigorVersion": "3.0.2", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.2" - } +{ + "hvigorVersion": "3.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.2" + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/AuthorizedButton/oh-package.json5 b/code/SystemFeature/Security/AuthorizedButton/oh-package.json5 index 30f5d350f7..6819b579ff 100644 --- a/code/SystemFeature/Security/AuthorizedButton/oh-package.json5 +++ b/code/SystemFeature/Security/AuthorizedButton/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "authorizedbutton", - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "authorizedbutton", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/Security/DLP/AppScope/app.json5 b/code/SystemFeature/Security/DLP/AppScope/app.json5 index 8a83045ec9..80f737f450 100644 --- a/code/SystemFeature/Security/DLP/AppScope/app.json5 +++ b/code/SystemFeature/Security/DLP/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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.dlp", - "vendor": "samples", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 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.dlp", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/Security/DLP/AppScope/resources/base/element/string.json b/code/SystemFeature/Security/DLP/AppScope/resources/base/element/string.json index 9495f57b0c..3db2959d25 100644 --- a/code/SystemFeature/Security/DLP/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/Security/DLP/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "DLP" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "DLP" + } + ] +} diff --git a/code/SystemFeature/Security/DLP/README_zh.md b/code/SystemFeature/Security/DLP/README_zh.md index 82e8329ba5..f3412e2425 100644 --- a/code/SystemFeature/Security/DLP/README_zh.md +++ b/code/SystemFeature/Security/DLP/README_zh.md @@ -1,77 +1,77 @@ -# DLP - -### 介绍 - -本示例是一个安全类App,使用[@ohos.dlpPermission](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-data-protection-kit/js-apis-dlppermission-sys.md) 接口展示了在eTS中普通文件加密受限的过程。 - -### 效果预览 -| Index | Encryption | Encryptied | FileEdit | -|-----------------------------------------|-----------------------------------------------|---------------------------------------------|----------------------------------------------------| -| ![Index](screenshots/devices/Index.jpeg) | ![Encryption](screenshots/devices/Encryption.jpeg) | ![Encryptied](screenshots/devices/Encrypted.jpeg) | ![FileEdit](screenshots/devices/FileEditPage.jpeg) | - -使用说明: -1. 启动应用后点击“**+**”按钮可以添加一个普通文件; -2. 长按点击加密按钮,出现加密权限弹窗,选择需要设置的权限并点击确定; -3. 点击加密文件,跳转到文本编辑应用,如果设置的权限是只读权限,页面置灰,不可编辑。 -4. 长按点击删除按钮,删除文件; - -### 工程目录 -``` -entry/src/main/ets/ -|---component -| |---CustomDialog.ets // 权限弹窗 -|---feature -| |---DlpManager.ets // Dlp管理 -| |---FileManager.ets // 文件管理 -| |---PreferencesManager.ets // 持久化存储 -|---pages -| |---Index.ets // 首页 -|---util -| |---Logger.ts // 日志 -| |---ResourceUtils.ets // 资源转换 -``` -### 具体实现 - -+ 文件的添加和文件列表的获取分别在Index和MediaFileUri中,源码参考[Index.ets](entry/src/main/ets/pages/Index.ets) 和 [FileManager.ets](entry/src/main/ets/feature/FileManager.ets): - + 文件的添加:首先通过[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md)接口的DocumentSaveOptions()方法自定一个参数,然后通过new picker.DocumentViewPicker()方法拉起文件管理应用去新建一个普通文件。 - + 文件列表的获取:首先使用[@ohos.file.fileAccess](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-fileAccess-sys.md) 接口的createFileAccessHelper()方法来创建连接指定wants的helper对象,然后通过getRoots()方法来获取helper对象连接的文件管理服务类的设备根节点信息,并获取到目录url,最后通过getFileInfoFromUri()方法得到文件的信息。 -+ 文件的加密操作在DlpManager中,源码参考[DlpManager.ets](entry/src/main/ets/feature/DlpManager.ets): - + 加密操作:使用dlpPermission接口的generateDLPFile方法获得一个相关的操作型关系数据库RdbStore,将明文文件加密生成权限受控文件。 - -### 相关权限 - -允许文件管理类应用通过FAF框架访问公共数据文件:[ohos.permission.FILE_ACCESS_MANAGER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionfile_access_manager) - -允许应用调用storage manager服务中对空间统计以及卷信息的查询接口:[ohos.permission.STORAGE_MANAGER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionstorage_manager) - -允许查询应用的基本信息和其他敏感信息:[ohos.permission.GET_BUNDLE_INFO_PRIVILEGED](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_bundle_info_privileged) - -允许对DLP文件进行权限配置和管理:[ohos.permission.ACCESS_DLP_FILE](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionaccess_dlp_file) - -允许应用管理系统分布式帐号信息:[ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanage_distributed_accounts) - -允许应用管理系统本地帐号:[ohos.permission.MANAGE_LOCAL_ACCOUNTS](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanage_local_accounts) - -允许应用查询系统本地帐号信息:[ohos.permission.GET_LOCAL_ACCOUNTS](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_local_accounts) - -### 依赖 - -需要依赖三方应用文本编辑FileEdit的[hap](screenshots/haps)。 - -### 约束与限制 - -1. 本示例仅支持标准系统上运行; -2. 本示例仅支持API10版本SDK,SDK版本号(4.0.10.10), 镜像版本号(4.0 Release)。 -3. 本示例需要使用DevEco Studio 4.0 Beta2 (Build Version: 4.0.0.400, built on August 2, 2023)才可编译运行; -4. 本示例需要使用@ohos.dlpPermission系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 - -### 下载 - -如需单独下载本工程,执行如下命令: -``` -git init -git config core.sparsecheckout true -echo code/SystemFeature/Security/DLP/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master +# DLP + +### 介绍 + +本示例是一个安全类App,使用[@ohos.dlpPermission](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-data-protection-kit/js-apis-dlppermission-sys.md) 接口展示了在eTS中普通文件加密受限的过程。 + +### 效果预览 +| Index | Encryption | Encryptied | FileEdit | +|-----------------------------------------|-----------------------------------------------|---------------------------------------------|----------------------------------------------------| +| ![Index](screenshots/devices/Index.jpeg) | ![Encryption](screenshots/devices/Encryption.jpeg) | ![Encryptied](screenshots/devices/Encrypted.jpeg) | ![FileEdit](screenshots/devices/FileEditPage.jpeg) | + +使用说明: +1. 启动应用后点击“**+**”按钮可以添加一个普通文件; +2. 长按点击加密按钮,出现加密权限弹窗,选择需要设置的权限并点击确定; +3. 点击加密文件,跳转到文本编辑应用,如果设置的权限是只读权限,页面置灰,不可编辑。 +4. 长按点击删除按钮,删除文件; + +### 工程目录 +``` +entry/src/main/ets/ +|---component +| |---CustomDialog.ets // 权限弹窗 +|---feature +| |---DlpManager.ets // Dlp管理 +| |---FileManager.ets // 文件管理 +| |---PreferencesManager.ets // 持久化存储 +|---pages +| |---Index.ets // 首页 +|---util +| |---Logger.ts // 日志 +| |---ResourceUtils.ets // 资源转换 +``` +### 具体实现 + ++ 文件的添加和文件列表的获取分别在Index和MediaFileUri中,源码参考[Index.ets](entry/src/main/ets/pages/Index.ets) 和 [FileManager.ets](entry/src/main/ets/feature/FileManager.ets): + + 文件的添加:首先通过[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md)接口的DocumentSaveOptions()方法自定一个参数,然后通过new picker.DocumentViewPicker()方法拉起文件管理应用去新建一个普通文件。 + + 文件列表的获取:首先使用[@ohos.file.fileAccess](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-fileAccess-sys.md) 接口的createFileAccessHelper()方法来创建连接指定wants的helper对象,然后通过getRoots()方法来获取helper对象连接的文件管理服务类的设备根节点信息,并获取到目录url,最后通过getFileInfoFromUri()方法得到文件的信息。 ++ 文件的加密操作在DlpManager中,源码参考[DlpManager.ets](entry/src/main/ets/feature/DlpManager.ets): + + 加密操作:使用dlpPermission接口的generateDLPFile方法获得一个相关的操作型关系数据库RdbStore,将明文文件加密生成权限受控文件。 + +### 相关权限 + +允许文件管理类应用通过FAF框架访问公共数据文件:[ohos.permission.FILE_ACCESS_MANAGER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionfile_access_manager) + +允许应用调用storage manager服务中对空间统计以及卷信息的查询接口:[ohos.permission.STORAGE_MANAGER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionstorage_manager) + +允许查询应用的基本信息和其他敏感信息:[ohos.permission.GET_BUNDLE_INFO_PRIVILEGED](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_bundle_info_privileged) + +允许对DLP文件进行权限配置和管理:[ohos.permission.ACCESS_DLP_FILE](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionaccess_dlp_file) + +允许应用管理系统分布式帐号信息:[ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanage_distributed_accounts) + +允许应用管理系统本地帐号:[ohos.permission.MANAGE_LOCAL_ACCOUNTS](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanage_local_accounts) + +允许应用查询系统本地帐号信息:[ohos.permission.GET_LOCAL_ACCOUNTS](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_local_accounts) + +### 依赖 + +需要依赖三方应用文本编辑FileEdit的[hap](screenshots/haps)。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行; +2. 本示例仅支持API10版本SDK,SDK版本号(4.0.10.10), 镜像版本号(4.0 Release)。 +3. 本示例需要使用DevEco Studio 4.0 Beta2 (Build Version: 4.0.0.400, built on August 2, 2023)才可编译运行; +4. 本示例需要使用@ohos.dlpPermission系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 + +### 下载 + +如需单独下载本工程,执行如下命令: +``` +git init +git config core.sparsecheckout true +echo code/SystemFeature/Security/DLP/ > .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/SystemFeature/Security/DLP/build-profile.json5 b/code/SystemFeature/Security/DLP/build-profile.json5 index 9f41ac1f36..d1a07a2849 100644 --- a/code/SystemFeature/Security/DLP/build-profile.json5 +++ b/code/SystemFeature/Security/DLP/build-profile.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 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", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2023 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", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "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/SystemFeature/Security/DLP/entry/build-profile.json5 b/code/SystemFeature/Security/DLP/entry/build-profile.json5 index 2eabd9fec3..8e1d0657b6 100644 --- a/code/SystemFeature/Security/DLP/entry/build-profile.json5 +++ b/code/SystemFeature/Security/DLP/entry/build-profile.json5 @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2023 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": { - }, - "targets": [ - { - "name": "default", - "runtimeOS": "OpenHarmony" - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2023 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": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/oh-package.json5 b/code/SystemFeature/Security/DLP/entry/oh-package.json5 index 4be95c59ce..3fbe67bbf8 100644 --- a/code/SystemFeature/Security/DLP/entry/oh-package.json5 +++ b/code/SystemFeature/Security/DLP/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/Security/DLP/entry/src/main/ets/component/CustomDialog.ets b/code/SystemFeature/Security/DLP/entry/src/main/ets/component/CustomDialog.ets index d73ecc27e1..47064f8886 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/ets/component/CustomDialog.ets +++ b/code/SystemFeature/Security/DLP/entry/src/main/ets/component/CustomDialog.ets @@ -1,111 +1,111 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; -import promptAction from '@ohos.promptAction'; -import { BusinessError } from '@ohos.base'; -import { DlpManager, TestDlpFileInfo } from '../feature/DlpManager'; -import { MediaFileUri } from '../feature/FileManager'; -import Logger from '../util/Logger'; -import { getResourceString } from '../util/ResourceUtils'; - -let sourceUri: string = 'file://docs/storage/Users/currentUser'; -let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - -@CustomDialog -export struct CustomDialogExample { - @State dlpManager: DlpManager = new DlpManager(); - @State mediaFileUri: MediaFileUri = new MediaFileUri(); - // dlp文件信息 - @StorageLink('dlpFileInfos') dlpFileInfos: Array = []; - @Link currentPerssion: number; - @Link currentSelectedFileUri: string; - private controller: CustomDialogController = {} as CustomDialogController; - - // 弹窗函数 - promptPopup() { - Logger.info(`promptPopup start`); - try { - promptAction.showToast({ - message: $r('app.string.authorization_reminder'), - // 弹窗延迟时间 - duration: 2000 - }); - } catch (error) { - let message = (error as BusinessError).message; - let code = (error as BusinessError).code; - Logger.error(`showToast args error code is ${code}, message is ${message}`); - } - } - - build() { - Column() { - Text($r('app.string.encryption_protection')) - .fontSize(20) - .margin({ top: 10, bottom: 10 }) - .width('100%') - .textAlign(TextAlign.Start) - Text($r('app.string.authorization_description')) - .fontSize(18) - .width('100%') - .textAlign(TextAlign.Start) - Column() { - Row() { - Text($r('app.string.user_access_rights')).fontSize(18) - Select([ - { value: $r('app.string.read_only') }, { value: $r('app.string.edit_only') }]) - .selected(2) - .value(getResourceString(context, $r('app.string.authorization_reminder'))) - .font({ size: 16, weight: 500 }) - .fontColor('#182431') - .selectedOptionFont({ size: 16, weight: 400 }) - .optionFont({ size: 16, weight: 400 }) - .margin({ top: 20, bottom: 20, left: 6 }) - .onSelect((index: number) => { - this.currentPerssion = index; - }) - }.width('100%').justifyContent(FlexAlign.Start) - - Flex({ justifyContent: FlexAlign.SpaceAround }) { - Button($r('app.string.cancel')) - .onClick(() => { - this.controller.close() - }).backgroundColor(0xffffff) - .fontColor(Color.Black) - Button($r('app.string.confirm')) - .onClick(async () => { - if (this.currentPerssion === -1) { - this.promptPopup(); - } else { - let displayName: string = Date.now().toString() + '.txt.dlp'; - let ciphertextFd: number = await this.mediaFileUri.createFile(sourceUri, displayName); - await this.dlpManager.genTestDlpFile(this.currentSelectedFileUri, ciphertextFd, displayName, this.currentPerssion, this.dlpFileInfos); - await this.mediaFileUri.getAllFiles(context, this.dlpFileInfos); - await this.mediaFileUri.getAllFiles(context, this.dlpFileInfos); - let time: number = new Date().getTime(); - // 切换用户 - await this.dlpManager.AccountLogin(`lisi${time}`); - this.controller.close(); - } - }) - .backgroundColor(0xffffff) - .fontColor(Color.Red) - }.margin({ bottom: 10 }) - } - }.width('100%') - .height('40%') - .padding(15) - } +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; +import promptAction from '@ohos.promptAction'; +import { BusinessError } from '@ohos.base'; +import { DlpManager, TestDlpFileInfo } from '../feature/DlpManager'; +import { MediaFileUri } from '../feature/FileManager'; +import Logger from '../util/Logger'; +import { getResourceString } from '../util/ResourceUtils'; + +let sourceUri: string = 'file://docs/storage/Users/currentUser'; +let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@CustomDialog +export struct CustomDialogExample { + @State dlpManager: DlpManager = new DlpManager(); + @State mediaFileUri: MediaFileUri = new MediaFileUri(); + // dlp文件信息 + @StorageLink('dlpFileInfos') dlpFileInfos: Array = []; + @Link currentPerssion: number; + @Link currentSelectedFileUri: string; + private controller: CustomDialogController = {} as CustomDialogController; + + // 弹窗函数 + promptPopup() { + Logger.info(`promptPopup start`); + try { + promptAction.showToast({ + message: $r('app.string.authorization_reminder'), + // 弹窗延迟时间 + duration: 2000 + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + Logger.error(`showToast args error code is ${code}, message is ${message}`); + } + } + + build() { + Column() { + Text($r('app.string.encryption_protection')) + .fontSize(20) + .margin({ top: 10, bottom: 10 }) + .width('100%') + .textAlign(TextAlign.Start) + Text($r('app.string.authorization_description')) + .fontSize(18) + .width('100%') + .textAlign(TextAlign.Start) + Column() { + Row() { + Text($r('app.string.user_access_rights')).fontSize(18) + Select([ + { value: $r('app.string.read_only') }, { value: $r('app.string.edit_only') }]) + .selected(2) + .value(getResourceString(context, $r('app.string.authorization_reminder'))) + .font({ size: 16, weight: 500 }) + .fontColor('#182431') + .selectedOptionFont({ size: 16, weight: 400 }) + .optionFont({ size: 16, weight: 400 }) + .margin({ top: 20, bottom: 20, left: 6 }) + .onSelect((index: number) => { + this.currentPerssion = index; + }) + }.width('100%').justifyContent(FlexAlign.Start) + + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Button($r('app.string.cancel')) + .onClick(() => { + this.controller.close() + }).backgroundColor(0xffffff) + .fontColor(Color.Black) + Button($r('app.string.confirm')) + .onClick(async () => { + if (this.currentPerssion === -1) { + this.promptPopup(); + } else { + let displayName: string = Date.now().toString() + '.txt.dlp'; + let ciphertextFd: number = await this.mediaFileUri.createFile(sourceUri, displayName); + await this.dlpManager.genTestDlpFile(this.currentSelectedFileUri, ciphertextFd, displayName, this.currentPerssion, this.dlpFileInfos); + await this.mediaFileUri.getAllFiles(context, this.dlpFileInfos); + await this.mediaFileUri.getAllFiles(context, this.dlpFileInfos); + let time: number = new Date().getTime(); + // 切换用户 + await this.dlpManager.AccountLogin(`lisi${time}`); + this.controller.close(); + } + }) + .backgroundColor(0xffffff) + .fontColor(Color.Red) + }.margin({ bottom: 10 }) + } + }.width('100%') + .height('40%') + .padding(15) + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/main/ets/entryability/EntryAbility.ts b/code/SystemFeature/Security/DLP/entry/src/main/ets/entryability/EntryAbility.ts index 2d09298881..3682d26731 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/SystemFeature/Security/DLP/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,82 +1,82 @@ -/* - * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; -import hilog from '@ohos.hilog'; -import UIAbility from '@ohos.app.ability.UIAbility'; -import Want from '@ohos.app.ability.Want'; -import window from '@ohos.window'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import type { Permissions } from '@ohos.abilityAccessCtrl'; -import Logger from '../util/Logger'; -import App from '@system.app'; - -class TestDlpFileInfo { - plaintextPath: string = ''; - ciphertextPath: string = ''; -} - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - let permissions: Array = [ - 'ohos.permission.FILE_ACCESS_MANAGER', - 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED', - 'ohos.permission.ACCESS_DLP_FILE', - "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS", - "ohos.permission.MANAGE_LOCAL_ACCOUNTS", - "ohos.permission.GET_LOCAL_ACCOUNTS", - "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS" - ] - let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); - atManager.requestPermissionsFromUser(this.context, permissions, (code, result) => { - Logger.debug('permissionRequest ' + JSON.stringify(code) + ' Result: ' + JSON.stringify(result)) - }) - PersistentStorage.persistProp('dlpFiles',''); - AppStorage.setOrCreate>('dlpFileInfos', []); - Logger.info('Ability onCreate'); - } - - onDestroy() { - Logger.info('Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability - Logger.info('Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - Logger.error(`Failed to load the content. Cause: ${JSON.stringify(err)}`); - return; - } - Logger.info(`Succeeded in loading the content. Data: ${JSON.stringify(data)}`); - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - Logger.info('Ability onWindowStageDestroy'); - } - - onForeground() { - // Ability has brought to foreground - Logger.info('Ability onForeground'); - } - - onBackground() { - // Ability has back to background - Logger.info('Ability onBackground'); - } -} +/* + * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import type { Permissions } from '@ohos.abilityAccessCtrl'; +import Logger from '../util/Logger'; +import App from '@system.app'; + +class TestDlpFileInfo { + plaintextPath: string = ''; + ciphertextPath: string = ''; +} + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + let permissions: Array = [ + 'ohos.permission.FILE_ACCESS_MANAGER', + 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED', + 'ohos.permission.ACCESS_DLP_FILE', + "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS", + "ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "ohos.permission.GET_LOCAL_ACCOUNTS", + "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS" + ] + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); + atManager.requestPermissionsFromUser(this.context, permissions, (code, result) => { + Logger.debug('permissionRequest ' + JSON.stringify(code) + ' Result: ' + JSON.stringify(result)) + }) + PersistentStorage.persistProp('dlpFiles',''); + AppStorage.setOrCreate>('dlpFileInfos', []); + Logger.info('Ability onCreate'); + } + + onDestroy() { + Logger.info('Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + Logger.info('Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error(`Failed to load the content. Cause: ${JSON.stringify(err)}`); + return; + } + Logger.info(`Succeeded in loading the content. Data: ${JSON.stringify(data)}`); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + Logger.info('Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + Logger.info('Ability onForeground'); + } + + onBackground() { + // Ability has back to background + Logger.info('Ability onBackground'); + } +} diff --git a/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/DlpManager.ets b/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/DlpManager.ets index 52a4c548d9..0e70ed205d 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/DlpManager.ets +++ b/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/DlpManager.ets @@ -1,238 +1,238 @@ -/* - * Copyright (c) 2023 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 dlpPermission from '@ohos.dlpPermission'; -import fs from '@ohos.file.fs'; -import account from '@ohos.account.distributedAccount' -import account_osAccount from '@ohos.account.osAccount'; -import Want from '@ohos.app.ability.Want'; -import { BusinessError } from '@ohos.base'; -import common from '@ohos.app.ability.common'; -import { PreferencesManager } from '../feature/PreferencesManager'; -import Logger from '../util/Logger'; - -const TAG: string = 'DlpManager'; -const SOURCEURI: string = 'file://docs/storage/Users/currentUser'; -let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; -let accountAbility = account.getDistributedAccountAbility(); -// 用户列表 -let userList: Array = [{ - 'authAccount': '123@ohos.com', - 'authAccountType': dlpPermission.AccountType.CLOUD_ACCOUNT, - 'dlpFileAccess': dlpPermission.DLPFileAccess.READ_ONLY, - // 授权到期时间戳 - 'permExpiryTime': 8888520175, -}, { - 'authAccount': '456@ohos.com', - 'authAccountType': dlpPermission.AccountType.CLOUD_ACCOUNT, - 'dlpFileAccess': dlpPermission.DLPFileAccess.FULL_CONTROL, - // 授权到期时间戳 - 'permExpiryTime': 8888520175, -}] - -// dlp信息类型 -export class TestDlpFileInfo { - plaintextPath: string = ''; - ciphertextPath: string = ''; -} - -// 用户信息类型 -interface UserInfo { - name: string, - id: string, - event: string, - nickname: string, - avatar: string -} - -export class DlpManager { - // linkFile文件名 - private linkFileName: string = ''; - // link地址文件名 - private linkFilePath: string = ''; - // dlp文件 - private dlpFile: dlpPermission.DLPFile = {} as dlpPermission.DLPFile; - // 沙箱包名 - private sandboxBundleName: string = 'com.example.fileEdit'; - private sandboxAbilityName: string = 'EntryAbility'; - // dlp文件的句柄 - private dlpFd: number = -1; - // 账号信息 - private accountInfo?: account_osAccount.OsAccountInfo; - // dlp文件路径地址 - private dlpFileUri: string = ''; - private preferencesManager: PreferencesManager = new PreferencesManager(); - - constructor() { - } - - // 获取用户id - async getUserId(): Promise { - let accountMgr = account_osAccount.getAccountManager(); - return await accountMgr.getOsAccountLocalIdFromProcess(); - } - - // 获取帐号信息 - async getOsAccountInfo(): Promise { - let accountMgr = account_osAccount.getAccountManager(); - return await accountMgr.getCurrentOsAccount(); - } - - // 获取AuthPerm - getAuthPerm(accountName: string, dlpProperty: dlpPermission.DLPProperty): dlpPermission.DLPFileAccess { - let perm: dlpPermission.DLPFileAccess = dlpPermission.DLPFileAccess.NO_PERMISSION; - if (accountName === dlpProperty.ownerAccount) { - return dlpPermission.DLPFileAccess.FULL_CONTROL; - } - if ((dlpProperty.everyoneAccessList !== undefined) && (dlpProperty.everyoneAccessList.length > 0)) { - perm = Math.max(...dlpProperty.everyoneAccessList); - } - let authUserList = dlpProperty.authUserList ?? []; - for (let i = 0; i < authUserList.length; ++i) { - let authUser = authUserList[i]; - if (authUser.authAccount === accountName) { - return authUser.dlpFileAccess; - } - } - return perm; - } - - // 帐号登录 - async AccountLogin(accountName: string) { - Logger.info('AccountLogin start'); - let info: UserInfo = { - name: '', - id: '1234', - event: 'Ohos.account.event.LOGIN', - nickname: 'nickname', - avatar: 'avatar' - }; - info.name = accountName; - info.event = 'Ohos.account.event.LOGIN'; - try { - await accountAbility.setOsAccountDistributedInfo(info); - } catch (err) { - console.error(TAG, `setOsAccountDistributedInfo LOGIN failed${err.code}, message:${err.message}`); - return - } - let user = await accountAbility.getOsAccountDistributedInfo(); - Logger.info(`CurrentMessage is ${JSON.stringify(user)}`); - } - - // 帐号登出 - async AccountLogout() { - Logger.info('AccountLogout start'); - let accountInfo = await accountAbility.getOsAccountDistributedInfo(); - let info: UserInfo = { - name: '', - id: '1234', - event: 'Ohos.account.event.LOGIN', - nickname: 'nickname', - avatar: 'avatar' - } - if (accountInfo.name === 'ohosAnonymousName') { - return - } - info.name = accountInfo.name - info.event = 'Ohos.account.event.LOGOUT' - await accountAbility.setOsAccountDistributedInfo(info); - Logger.info('AccountLogout end'); - } - - // 生成可选参数的DLP策略 - async genTestOptionalDlpProperty(): Promise { - let accountInfo = await this.getOsAccountInfo(); - let property: dlpPermission.DLPProperty = { - 'ownerAccount': accountInfo.distributedInfo.name, - 'ownerAccountID': accountInfo.distributedInfo.id, - 'ownerAccountType': dlpPermission.AccountType.CLOUD_ACCOUNT, - 'contactAccount': accountInfo.distributedInfo.name, - 'offlineAccess': true, - }; - return property; - } - - // 生成DLP策略 - async genTestDlpProperty(): Promise { - this.accountInfo = await this.getOsAccountInfo(); - let property: dlpPermission.DLPProperty = { - 'ownerAccount': this.accountInfo.distributedInfo.name, - 'ownerAccountID': this.accountInfo.distributedInfo.name, - 'ownerAccountType': dlpPermission.AccountType.CLOUD_ACCOUNT, - 'authUserList': userList, - 'contactAccount': this.accountInfo.distributedInfo.name, - 'offlineAccess': true, - 'everyoneAccessList': [dlpPermission.DLPFileAccess.READ_ONLY], - }; - return property; - } - - // 启动沙箱应用 - startSandboxApp(): void { - let want: Want = { - bundleName: this.sandboxBundleName, - abilityName: this.sandboxAbilityName, - uri: this.linkFilePath, - parameters: { - 'linkFileName': { - 'name': this.linkFileName - }, - 'uri': this.linkFilePath, - 'dlpUri': { - 'name': this.dlpFileUri - }, - } - }; - context.startAbility(want, (err) => { - Logger.info() - }); - } - - // 生成测试DLP文件 - async genTestDlpFile(plaintextPath: string, ciphertextFd: number, displayName: string, currentPerssion: number, dlpFileInfos: Array) { - Logger.info('GenTestDlpFile start'); - let file: fs.File = fs.openSync(plaintextPath, fs.OpenMode.READ_WRITE); - this.dlpFd = ciphertextFd; - this.dlpFileUri = `${SOURCEURI}/${displayName}`; - let fileInfo: TestDlpFileInfo = new TestDlpFileInfo(); - fileInfo.plaintextPath = plaintextPath; - fileInfo.ciphertextPath = this.dlpFileUri; - dlpFileInfos.push(fileInfo); - AppStorage.set>('dlpFileInfos', dlpFileInfos); - await this.preferencesManager.putDlpFileInfos(dlpFileInfos); - Logger.info(`file.fd:${file.fd},dlpFd:${this.dlpFd}`); - let property = await this.genTestDlpProperty(); - property.everyoneAccessList = [currentPerssion + 1]; - Logger.info(`everyoneList ${JSON.stringify(property.everyoneAccessList)},current`); - try { - this.dlpFile = await dlpPermission.generateDLPFile(file.fd, this.dlpFd, property); - if (await dlpPermission.isDLPFile(this.dlpFd)) { - Logger.info(`generateDLPFile success`); - } else { - Logger.info(`generateDLPFile fail`); - } - this.dlpFile.closeDLPFile(); - } - - catch (err) { - let error: BusinessError = err as BusinessError; - Logger.error(`generateDLPFile failed, errCode:${error.code},message:${error.message}`); - fs.closeSync(file.fd); - fs.closeSync(this.dlpFd); - } - } -} - - +/* + * Copyright (c) 2023 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 dlpPermission from '@ohos.dlpPermission'; +import fs from '@ohos.file.fs'; +import account from '@ohos.account.distributedAccount' +import account_osAccount from '@ohos.account.osAccount'; +import Want from '@ohos.app.ability.Want'; +import { BusinessError } from '@ohos.base'; +import common from '@ohos.app.ability.common'; +import { PreferencesManager } from '../feature/PreferencesManager'; +import Logger from '../util/Logger'; + +const TAG: string = 'DlpManager'; +const SOURCEURI: string = 'file://docs/storage/Users/currentUser'; +let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; +let accountAbility = account.getDistributedAccountAbility(); +// 用户列表 +let userList: Array = [{ + 'authAccount': '123@ohos.com', + 'authAccountType': dlpPermission.AccountType.CLOUD_ACCOUNT, + 'dlpFileAccess': dlpPermission.DLPFileAccess.READ_ONLY, + // 授权到期时间戳 + 'permExpiryTime': 8888520175, +}, { + 'authAccount': '456@ohos.com', + 'authAccountType': dlpPermission.AccountType.CLOUD_ACCOUNT, + 'dlpFileAccess': dlpPermission.DLPFileAccess.FULL_CONTROL, + // 授权到期时间戳 + 'permExpiryTime': 8888520175, +}] + +// dlp信息类型 +export class TestDlpFileInfo { + plaintextPath: string = ''; + ciphertextPath: string = ''; +} + +// 用户信息类型 +interface UserInfo { + name: string, + id: string, + event: string, + nickname: string, + avatar: string +} + +export class DlpManager { + // linkFile文件名 + private linkFileName: string = ''; + // link地址文件名 + private linkFilePath: string = ''; + // dlp文件 + private dlpFile: dlpPermission.DLPFile = {} as dlpPermission.DLPFile; + // 沙箱包名 + private sandboxBundleName: string = 'com.example.fileEdit'; + private sandboxAbilityName: string = 'EntryAbility'; + // dlp文件的句柄 + private dlpFd: number = -1; + // 账号信息 + private accountInfo?: account_osAccount.OsAccountInfo; + // dlp文件路径地址 + private dlpFileUri: string = ''; + private preferencesManager: PreferencesManager = new PreferencesManager(); + + constructor() { + } + + // 获取用户id + async getUserId(): Promise { + let accountMgr = account_osAccount.getAccountManager(); + return await accountMgr.getOsAccountLocalIdFromProcess(); + } + + // 获取帐号信息 + async getOsAccountInfo(): Promise { + let accountMgr = account_osAccount.getAccountManager(); + return await accountMgr.getCurrentOsAccount(); + } + + // 获取AuthPerm + getAuthPerm(accountName: string, dlpProperty: dlpPermission.DLPProperty): dlpPermission.DLPFileAccess { + let perm: dlpPermission.DLPFileAccess = dlpPermission.DLPFileAccess.NO_PERMISSION; + if (accountName === dlpProperty.ownerAccount) { + return dlpPermission.DLPFileAccess.FULL_CONTROL; + } + if ((dlpProperty.everyoneAccessList !== undefined) && (dlpProperty.everyoneAccessList.length > 0)) { + perm = Math.max(...dlpProperty.everyoneAccessList); + } + let authUserList = dlpProperty.authUserList ?? []; + for (let i = 0; i < authUserList.length; ++i) { + let authUser = authUserList[i]; + if (authUser.authAccount === accountName) { + return authUser.dlpFileAccess; + } + } + return perm; + } + + // 帐号登录 + async AccountLogin(accountName: string) { + Logger.info('AccountLogin start'); + let info: UserInfo = { + name: '', + id: '1234', + event: 'Ohos.account.event.LOGIN', + nickname: 'nickname', + avatar: 'avatar' + }; + info.name = accountName; + info.event = 'Ohos.account.event.LOGIN'; + try { + await accountAbility.setOsAccountDistributedInfo(info); + } catch (err) { + console.error(TAG, `setOsAccountDistributedInfo LOGIN failed${err.code}, message:${err.message}`); + return + } + let user = await accountAbility.getOsAccountDistributedInfo(); + Logger.info(`CurrentMessage is ${JSON.stringify(user)}`); + } + + // 帐号登出 + async AccountLogout() { + Logger.info('AccountLogout start'); + let accountInfo = await accountAbility.getOsAccountDistributedInfo(); + let info: UserInfo = { + name: '', + id: '1234', + event: 'Ohos.account.event.LOGIN', + nickname: 'nickname', + avatar: 'avatar' + } + if (accountInfo.name === 'ohosAnonymousName') { + return + } + info.name = accountInfo.name + info.event = 'Ohos.account.event.LOGOUT' + await accountAbility.setOsAccountDistributedInfo(info); + Logger.info('AccountLogout end'); + } + + // 生成可选参数的DLP策略 + async genTestOptionalDlpProperty(): Promise { + let accountInfo = await this.getOsAccountInfo(); + let property: dlpPermission.DLPProperty = { + 'ownerAccount': accountInfo.distributedInfo.name, + 'ownerAccountID': accountInfo.distributedInfo.id, + 'ownerAccountType': dlpPermission.AccountType.CLOUD_ACCOUNT, + 'contactAccount': accountInfo.distributedInfo.name, + 'offlineAccess': true, + }; + return property; + } + + // 生成DLP策略 + async genTestDlpProperty(): Promise { + this.accountInfo = await this.getOsAccountInfo(); + let property: dlpPermission.DLPProperty = { + 'ownerAccount': this.accountInfo.distributedInfo.name, + 'ownerAccountID': this.accountInfo.distributedInfo.name, + 'ownerAccountType': dlpPermission.AccountType.CLOUD_ACCOUNT, + 'authUserList': userList, + 'contactAccount': this.accountInfo.distributedInfo.name, + 'offlineAccess': true, + 'everyoneAccessList': [dlpPermission.DLPFileAccess.READ_ONLY], + }; + return property; + } + + // 启动沙箱应用 + startSandboxApp(): void { + let want: Want = { + bundleName: this.sandboxBundleName, + abilityName: this.sandboxAbilityName, + uri: this.linkFilePath, + parameters: { + 'linkFileName': { + 'name': this.linkFileName + }, + 'uri': this.linkFilePath, + 'dlpUri': { + 'name': this.dlpFileUri + }, + } + }; + context.startAbility(want, (err) => { + Logger.info() + }); + } + + // 生成测试DLP文件 + async genTestDlpFile(plaintextPath: string, ciphertextFd: number, displayName: string, currentPerssion: number, dlpFileInfos: Array) { + Logger.info('GenTestDlpFile start'); + let file: fs.File = fs.openSync(plaintextPath, fs.OpenMode.READ_WRITE); + this.dlpFd = ciphertextFd; + this.dlpFileUri = `${SOURCEURI}/${displayName}`; + let fileInfo: TestDlpFileInfo = new TestDlpFileInfo(); + fileInfo.plaintextPath = plaintextPath; + fileInfo.ciphertextPath = this.dlpFileUri; + dlpFileInfos.push(fileInfo); + AppStorage.set>('dlpFileInfos', dlpFileInfos); + await this.preferencesManager.putDlpFileInfos(dlpFileInfos); + Logger.info(`file.fd:${file.fd},dlpFd:${this.dlpFd}`); + let property = await this.genTestDlpProperty(); + property.everyoneAccessList = [currentPerssion + 1]; + Logger.info(`everyoneList ${JSON.stringify(property.everyoneAccessList)},current`); + try { + this.dlpFile = await dlpPermission.generateDLPFile(file.fd, this.dlpFd, property); + if (await dlpPermission.isDLPFile(this.dlpFd)) { + Logger.info(`generateDLPFile success`); + } else { + Logger.info(`generateDLPFile fail`); + } + this.dlpFile.closeDLPFile(); + } + + catch (err) { + let error: BusinessError = err as BusinessError; + Logger.error(`generateDLPFile failed, errCode:${error.code},message:${error.message}`); + fs.closeSync(file.fd); + fs.closeSync(this.dlpFd); + } + } +} + + diff --git a/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/FileManager.ets b/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/FileManager.ets index 67d5dfba66..d61ad4a0f9 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/FileManager.ets +++ b/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/FileManager.ets @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2023 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 fs from '@ohos.file.fs'; -import fileAccess from '@ohos.file.fileAccess'; -import { BusinessError } from '@ohos.base'; -import { TestDlpFileInfo } from '../feature/DlpManager'; -import Logger from '../util/Logger'; -import common from '@ohos.app.ability.common'; -import fileUri from '@ohos.file.fileuri'; -import { PreferencesManager } from './PreferencesManager'; - -const TAG = 'FileManager'; -const RECENT_MAX = 10; // 最近打开最大文件数 -let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - -export class FileInfoType { - fileUri: string = ''; - fileName: string = ''; - size: number = 0; - isEncryption: boolean = false; - - constructor(fileUri: string, fileName: string, size: number, isEncryption?: boolean) { - this.fileUri = fileUri; - this.fileName = fileName; - this.size = size; - } -} - -export class MediaFileUri { - private fileAccessHelper: fileAccess.FileAccessHelper = {} as fileAccess.FileAccessHelper; - private fileInfos: Array = []; - - constructor() { - this.fileAccessHelper = fileAccess.createFileAccessHelper(context); - } - - // sync-close - closeSync(fd: number): void { - try { - fs.closeSync(fd); - Logger.info(TAG, 'closeSync file finish.'); - } catch (err) { - Logger.error(TAG, 'closeSync file error = ' + err); - } - } - - myGetFileSize(uri: string, mode: number): number { - let file = fs.openSync(uri, mode); // fs.OpenMode.READ_ONLY - Logger.info(TAG, `file fd: file.fd`); - let stat = fs.statSync(file.fd); - Logger.info(TAG, `get file info succeed, the size of file is ${stat.size}`); - return stat.size; - } - - // 获取文件数据 - async getFileData(url: string): Promise { - let isDone: boolean = false; - let fileInfo = await this.fileAccessHelper.getFileInfoFromUri(url); - try { - let fileIterator = fileInfo.scanFile({ suffix: ['.txt'] }); - if (!fileIterator) { - Logger.info(TAG, 'listFile interface returns an undefined object'); - } - while (!isDone) { - let result = fileIterator.next(); - isDone = result.done; - if (!isDone) { - let fileMsg: FileInfoType = new FileInfoType(result.value.uri, result.value.fileName, result.value.size); - let filterArray: Array = this.fileInfos.filter((item) => { - return item.fileName === fileMsg.fileName; - }) - if (filterArray.length > 0) { - return; - } - this.fileInfos.push(fileMsg); - } - } - } catch (err) { - Logger.info(TAG, `listFile failed, ${err}`); - } - } - - // 获取文件 - async getAllFiles(context: common.UIAbilityContext, dlpFileInfos: Array): Promise { - Logger.info(TAG, 'getAllFiles begin'); - Logger.info(TAG, 'getAllFiles begin' + JSON.stringify(dlpFileInfos)); - this.fileInfos = []; - let rootIterator = await this.fileAccessHelper.getRoots(); - // 获取目录url - let catalogueUrl: string = rootIterator.next().value.uri; - await this.getFileData(catalogueUrl); - await this.handleFileData(dlpFileInfos); - AppStorage.set('fileInfos', this.fileInfos); - } - - // 处理文件数据 - async handleFileData(dlpFileInfos: Array) { - if (dlpFileInfos.length > 0) { - for (let index = 0; index < this.fileInfos.length && index < RECENT_MAX; index++) { - dlpFileInfos.forEach(async (item: TestDlpFileInfo, ind: number) => { - let uriInfo: fileUri.FileUri = await this.getFileName(item.plaintextPath); - let fileInfo: FileInfoType = this.fileInfos[index]; - if (uriInfo.name === fileInfo.fileName) { - fileInfo.isEncryption = true; - } - }) - } - } - } - - // 删除文件 - async deleteFile(uri: string) { - Logger.info(`deleteFile start, uri is ${uri}`); - try { - let code = await this.fileAccessHelper.delete(uri); - if (code !== 0) { - Logger.error(`delete failed, code:${code}`); - } - } catch (err) { - let error: BusinessError = err as BusinessError; - Logger.error(`delete failed, errCode:${error.code}`); - } - } - - // 根据Uri获取名称 - async getFileName(uri: string) { - let uriInfo: fileUri.FileUri = new fileUri.FileUri(uri); - return uriInfo; - } - - // 新增文件 - async createFile(sourceUri: string, displayName: string): Promise { - Logger.info(`SourceUri:${sourceUri}----displayName:${displayName}`); - try { - // fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取 - let fileUri = await this.fileAccessHelper.createFile(sourceUri, displayName); - let file = fs.openSync(fileUri, fs.OpenMode.READ_WRITE); - Logger.info('the fd is ' + file.fd); - return file.fd; - } catch (err) { - let error: BusinessError = err as BusinessError; - Logger.error(`createFile failed, errCode:${error.code}, errMessage:${error.message}`); - return -1; - } - } +/* + * Copyright (c) 2023 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 fs from '@ohos.file.fs'; +import fileAccess from '@ohos.file.fileAccess'; +import { BusinessError } from '@ohos.base'; +import { TestDlpFileInfo } from '../feature/DlpManager'; +import Logger from '../util/Logger'; +import common from '@ohos.app.ability.common'; +import fileUri from '@ohos.file.fileuri'; +import { PreferencesManager } from './PreferencesManager'; + +const TAG = 'FileManager'; +const RECENT_MAX = 10; // 最近打开最大文件数 +let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +export class FileInfoType { + fileUri: string = ''; + fileName: string = ''; + size: number = 0; + isEncryption: boolean = false; + + constructor(fileUri: string, fileName: string, size: number, isEncryption?: boolean) { + this.fileUri = fileUri; + this.fileName = fileName; + this.size = size; + } +} + +export class MediaFileUri { + private fileAccessHelper: fileAccess.FileAccessHelper = {} as fileAccess.FileAccessHelper; + private fileInfos: Array = []; + + constructor() { + this.fileAccessHelper = fileAccess.createFileAccessHelper(context); + } + + // sync-close + closeSync(fd: number): void { + try { + fs.closeSync(fd); + Logger.info(TAG, 'closeSync file finish.'); + } catch (err) { + Logger.error(TAG, 'closeSync file error = ' + err); + } + } + + myGetFileSize(uri: string, mode: number): number { + let file = fs.openSync(uri, mode); // fs.OpenMode.READ_ONLY + Logger.info(TAG, `file fd: file.fd`); + let stat = fs.statSync(file.fd); + Logger.info(TAG, `get file info succeed, the size of file is ${stat.size}`); + return stat.size; + } + + // 获取文件数据 + async getFileData(url: string): Promise { + let isDone: boolean = false; + let fileInfo = await this.fileAccessHelper.getFileInfoFromUri(url); + try { + let fileIterator = fileInfo.scanFile({ suffix: ['.txt'] }); + if (!fileIterator) { + Logger.info(TAG, 'listFile interface returns an undefined object'); + } + while (!isDone) { + let result = fileIterator.next(); + isDone = result.done; + if (!isDone) { + let fileMsg: FileInfoType = new FileInfoType(result.value.uri, result.value.fileName, result.value.size); + let filterArray: Array = this.fileInfos.filter((item) => { + return item.fileName === fileMsg.fileName; + }) + if (filterArray.length > 0) { + return; + } + this.fileInfos.push(fileMsg); + } + } + } catch (err) { + Logger.info(TAG, `listFile failed, ${err}`); + } + } + + // 获取文件 + async getAllFiles(context: common.UIAbilityContext, dlpFileInfos: Array): Promise { + Logger.info(TAG, 'getAllFiles begin'); + Logger.info(TAG, 'getAllFiles begin' + JSON.stringify(dlpFileInfos)); + this.fileInfos = []; + let rootIterator = await this.fileAccessHelper.getRoots(); + // 获取目录url + let catalogueUrl: string = rootIterator.next().value.uri; + await this.getFileData(catalogueUrl); + await this.handleFileData(dlpFileInfos); + AppStorage.set('fileInfos', this.fileInfos); + } + + // 处理文件数据 + async handleFileData(dlpFileInfos: Array) { + if (dlpFileInfos.length > 0) { + for (let index = 0; index < this.fileInfos.length && index < RECENT_MAX; index++) { + dlpFileInfos.forEach(async (item: TestDlpFileInfo, ind: number) => { + let uriInfo: fileUri.FileUri = await this.getFileName(item.plaintextPath); + let fileInfo: FileInfoType = this.fileInfos[index]; + if (uriInfo.name === fileInfo.fileName) { + fileInfo.isEncryption = true; + } + }) + } + } + } + + // 删除文件 + async deleteFile(uri: string) { + Logger.info(`deleteFile start, uri is ${uri}`); + try { + let code = await this.fileAccessHelper.delete(uri); + if (code !== 0) { + Logger.error(`delete failed, code:${code}`); + } + } catch (err) { + let error: BusinessError = err as BusinessError; + Logger.error(`delete failed, errCode:${error.code}`); + } + } + + // 根据Uri获取名称 + async getFileName(uri: string) { + let uriInfo: fileUri.FileUri = new fileUri.FileUri(uri); + return uriInfo; + } + + // 新增文件 + async createFile(sourceUri: string, displayName: string): Promise { + Logger.info(`SourceUri:${sourceUri}----displayName:${displayName}`); + try { + // fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取 + let fileUri = await this.fileAccessHelper.createFile(sourceUri, displayName); + let file = fs.openSync(fileUri, fs.OpenMode.READ_WRITE); + Logger.info('the fd is ' + file.fd); + return file.fd; + } catch (err) { + let error: BusinessError = err as BusinessError; + Logger.error(`createFile failed, errCode:${error.code}, errMessage:${error.message}`); + return -1; + } + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/PreferencesManager.ets b/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/PreferencesManager.ets index 35d89ac75c..e448c048b6 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/PreferencesManager.ets +++ b/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/PreferencesManager.ets @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2023 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 dataPreferences from '@ohos.data.preferences'; -import common from '@ohos.app.ability.common'; -import { MediaFileUri } from './FileManager'; -import Logger from '../util/Logger'; -import { TestDlpFileInfo } from '../feature/DlpManager'; -import { BusinessError } from '@ohos.base'; - -let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; -let dataPreferencesManager: dataPreferences.Preferences = {} as dataPreferences.Preferences; - - -export class PreferencesManager { - private mediaFileUri: MediaFileUri = new MediaFileUri(); - - async getPreferences() { - try { - dataPreferences.getPreferences(context, 'myStore', (err: BusinessError, val: dataPreferences.Preferences) => { - if (err) { - Logger.error("Failed to get preferences. code =" + err.code + ", message =" + err.message); - return; - } - dataPreferencesManager = val; - this.getDlpFileInfos(); - Logger.info("Succeeded in getting preferences."); - }) - } catch (err) { - let code = (err as BusinessError).code; - let message = (err as BusinessError).message; - Logger.error("Failed to get preferences. code =" + code + ", message =" + message); - } - } - - async putDlpFileInfos(dlpFileInfos: Array) { - try { - dataPreferencesManager.put('dlpFileInfos', JSON.stringify(dlpFileInfos), async (err: BusinessError) => { - if (err) { - Logger.error("Failed to put value of 'dlpFileInfos'. code =" + err.code + ", message =" + err.message); - return; - } - Logger.info("Succeeded in putting value of 'dlpFileInfos'."); - dataPreferencesManager.flush(); - }) - } catch (err) { - let code = (err as BusinessError).code; - let message = (err as BusinessError).message; - Logger.error("Failed to put value of 'dlpFileInfos'. code =" + code + ", message =" + message); - } - } - - async getDlpFileInfos() { - try { - let dlpFileInfos: Array = []; - let promise = dataPreferencesManager.get('dlpFileInfos', []); - promise.then(async (data: dataPreferences.ValueType) => { - if (typeof data === 'string') { - let dlpFileInfos: Array = JSON.parse(data); - AppStorage.set('dlpFileInfos', dlpFileInfos); - await this.mediaFileUri.getAllFiles(context, dlpFileInfos); - Logger.info("Succeeded in getting value of 'dlpFileInfos'. dlpFileInfos: " + JSON.stringify(dlpFileInfos)); - } else { - await this.mediaFileUri.getAllFiles(context, dlpFileInfos); - } - }) - } catch (err) { - let code = (err as BusinessError).code; - let message = (err as BusinessError).message; - Logger.error("Failed to get value of 'dlpFileInfos'. code =" + code + ", message =" + message); - } - } +/* + * Copyright (c) 2023 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 dataPreferences from '@ohos.data.preferences'; +import common from '@ohos.app.ability.common'; +import { MediaFileUri } from './FileManager'; +import Logger from '../util/Logger'; +import { TestDlpFileInfo } from '../feature/DlpManager'; +import { BusinessError } from '@ohos.base'; + +let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; +let dataPreferencesManager: dataPreferences.Preferences = {} as dataPreferences.Preferences; + + +export class PreferencesManager { + private mediaFileUri: MediaFileUri = new MediaFileUri(); + + async getPreferences() { + try { + dataPreferences.getPreferences(context, 'myStore', (err: BusinessError, val: dataPreferences.Preferences) => { + if (err) { + Logger.error("Failed to get preferences. code =" + err.code + ", message =" + err.message); + return; + } + dataPreferencesManager = val; + this.getDlpFileInfos(); + Logger.info("Succeeded in getting preferences."); + }) + } catch (err) { + let code = (err as BusinessError).code; + let message = (err as BusinessError).message; + Logger.error("Failed to get preferences. code =" + code + ", message =" + message); + } + } + + async putDlpFileInfos(dlpFileInfos: Array) { + try { + dataPreferencesManager.put('dlpFileInfos', JSON.stringify(dlpFileInfos), async (err: BusinessError) => { + if (err) { + Logger.error("Failed to put value of 'dlpFileInfos'. code =" + err.code + ", message =" + err.message); + return; + } + Logger.info("Succeeded in putting value of 'dlpFileInfos'."); + dataPreferencesManager.flush(); + }) + } catch (err) { + let code = (err as BusinessError).code; + let message = (err as BusinessError).message; + Logger.error("Failed to put value of 'dlpFileInfos'. code =" + code + ", message =" + message); + } + } + + async getDlpFileInfos() { + try { + let dlpFileInfos: Array = []; + let promise = dataPreferencesManager.get('dlpFileInfos', []); + promise.then(async (data: dataPreferences.ValueType) => { + if (typeof data === 'string') { + let dlpFileInfos: Array = JSON.parse(data); + AppStorage.set('dlpFileInfos', dlpFileInfos); + await this.mediaFileUri.getAllFiles(context, dlpFileInfos); + Logger.info("Succeeded in getting value of 'dlpFileInfos'. dlpFileInfos: " + JSON.stringify(dlpFileInfos)); + } else { + await this.mediaFileUri.getAllFiles(context, dlpFileInfos); + } + }) + } catch (err) { + let code = (err as BusinessError).code; + let message = (err as BusinessError).message; + Logger.error("Failed to get value of 'dlpFileInfos'. code =" + code + ", message =" + message); + } + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/main/ets/util/Logger.ts b/code/SystemFeature/Security/DLP/entry/src/main/ets/util/Logger.ts index 61a8528793..ab4fc60479 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/ets/util/Logger.ts +++ b/code/SystemFeature/Security/DLP/entry/src/main/ets/util/Logger.ts @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog' - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0xFF00; - } - - debug(...args: string[]) { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]) { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]) { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]) { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog' + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('Sample_DLP'); \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/main/ets/util/ResourceUtils.ets b/code/SystemFeature/Security/DLP/entry/src/main/ets/util/ResourceUtils.ets index 3085317211..95ea48f5c3 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/ets/util/ResourceUtils.ets +++ b/code/SystemFeature/Security/DLP/entry/src/main/ets/util/ResourceUtils.ets @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; - -/** - * getResourceString将Resource类型的数据转换成string类型的数据 - * @param context - * @param ResourceData - */ -export function getResourceString(context: common.UIAbilityContext, resourceData: Resource): string { - let stringData: string = context.resourceManager.getStringSync(resourceData.id); - return stringData; +/* + * Copyright (c) 2023 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 common from '@ohos.app.ability.common'; + +/** + * getResourceString将Resource类型的数据转换成string类型的数据 + * @param context + * @param ResourceData + */ +export function getResourceString(context: common.UIAbilityContext, resourceData: Resource): string { + let stringData: string = context.resourceManager.getStringSync(resourceData.id); + return stringData; } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/main/module.json5 b/code/SystemFeature/Security/DLP/entry/src/main/module.json5 index 3f54f2c18d..a122c78927 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/module.json5 +++ b/code/SystemFeature/Security/DLP/entry/src/main/module.json5 @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2023 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.ts", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.FILE_ACCESS_MANAGER", - }, - { - "name": "ohos.permission.STORAGE_MANAGER", - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - }, - { - "name": "ohos.permission.ACCESS_DLP_FILE" - }, - { - "name": "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS" - }, - { - "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS" - }, - { - "name": "ohos.permission.GET_LOCAL_ACCOUNTS" - } - ] - } +/* + * Copyright (c) 2023 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.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.FILE_ACCESS_MANAGER", + }, + { + "name": "ohos.permission.STORAGE_MANAGER", + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + }, + { + "name": "ohos.permission.ACCESS_DLP_FILE" + }, + { + "name": "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS" + }, + { + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS" + }, + { + "name": "ohos.permission.GET_LOCAL_ACCOUNTS" + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/main/resources/base/element/color.json b/code/SystemFeature/Security/DLP/entry/src/main/resources/base/element/color.json index 65bbb43024..47ff61743b 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/Security/DLP/entry/src/main/resources/base/element/color.json @@ -1,16 +1,16 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "folder_color_99182431", - "value": "#99182431" - }, - { - "name": "modified_time_font_color", - "value": "#A3A7AD" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "folder_color_99182431", + "value": "#99182431" + }, + { + "name": "modified_time_font_color", + "value": "#A3A7AD" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_docs.svg b/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_docs.svg index b534ac5902..1e10662cd8 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_docs.svg +++ b/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_docs.svg @@ -1,13 +1,13 @@ - - - ic_docs - - - - - - - - - + + + ic_docs + + + + + + + + + \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_folder.svg b/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_folder.svg index a14cee6244..9b39e709bb 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_folder.svg +++ b/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_folder.svg @@ -1,13 +1,13 @@ - - - ic_folder - - - - - - - - - + + + ic_folder + + + + + + + + + \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_saveas.svg b/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_saveas.svg index 0c5f0e6946..19b2892ca2 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_saveas.svg +++ b/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/ic_saveas.svg @@ -1,13 +1,13 @@ - - - ic_saveas - - - - - - - - - + + + ic_saveas + + + + + + + + + \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/triangle.svg b/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/triangle.svg index b8e411603c..6bd84c78e2 100644 --- a/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/triangle.svg +++ b/code/SystemFeature/Security/DLP/entry/src/main/resources/base/media/triangle.svg @@ -1,11 +1,11 @@ - - - - -下拉三角 - - + + + + +下拉三角 + + diff --git a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/Ability.test.ets b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/Ability.test.ets index a0133054f6..f4937c1d45 100644 --- a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,209 +1,209 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect, beforeAll } from '@ohos/hypium'; -import Logger from './Logger'; -import { Driver, ON } from '@ohos.UiTest'; -import Want from '@ohos.app.ability.Want'; -import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; -import inputMethod from '@ohos.inputMethod'; -import resourceManager from '@ohos.resourceManager'; - -const BUNDLE = 'DLP'; -const TAG = '[Sample_DLP_TEST]'; -const delegator = abilityDelegatorRegistry.getAbilityDelegator(); - -async function getResourceString(resource: T): Promise { - let manage = delegator.getAppContext().resourceManager; - let text = await manage.getStringValue(resource); - return text; -} - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - beforeAll(async () => { - let want: Want = { - bundleName: 'com.samples.dlp', - abilityName: "EntryAbility" - } - await delegator.startAbility(want); - }) - /** - * 允许 - */ - it(BUNDLE + 'authorization', 0, async () => { - Logger.info(TAG, BUNDLE + 'authorization begin') - let driver = Driver.create(); - await driver.delayMs(5000); - // 点击聊天列表 - await driver.assertComponentExist(ON.text('允许')); - let authorizateBtn = await driver.findComponent(ON.text('允许')); - await driver.delayMs(1000); - await authorizateBtn.click(); - await driver.delayMs(1000); - }) - /** - * 添加普通文件 - */ - it(BUNDLE + 'AddFiles', 0, async () => { - Logger.info(TAG, BUNDLE + 'AddFiles begin'); - let driver = Driver.create(); - await driver.delayMs(1000); - // 添加普通文件 - await driver.assertComponentExist(ON.id('newFile')); - let addBtn = await driver.findComponent(ON.id('newFile')); - await driver.delayMs(1000); - await addBtn.click(); - await driver.delayMs(1000); - let authorizateBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.text_content')))); - await driver.delayMs(1000); - if(authorizateBtn) { - await authorizateBtn.click(); - await driver.delayMs(1000); - } - let authorizateBtn2 = await driver.findComponent(ON.text(await getResourceString($r('app.string.text_content')))); - await driver.delayMs(1000); - if(authorizateBtn2) { - await authorizateBtn2.click(); - await driver.delayMs(1000); - } - let timestamp = new Date().getTime(); - let textInput = await driver.findComponent(ON.type('TextInput')); - await driver.delayMs(1000); - await textInput.inputText(`xxx合同${timestamp}.txt`); - await driver.delayMs(1000); - let inputMethodController = inputMethod.getController(); - inputMethodController.hideTextInput(); - await driver.delayMs(1000); - let ImageArray = await driver.findComponents(ON.type('Image')); - Logger.info(TAG, `ImageArray lenth:${ImageArray.length}`); - let finishBtn = ImageArray[2]; - await finishBtn.click(); - Logger.info(TAG, BUNDLE + 'AddFiles end'); - }) - /** - * 加密操作 - */ - it(BUNDLE + 'AddOrdinaryFiles', 0, async () => { - Logger.info(TAG, BUNDLE + 'AddOrdinaryFiles begin'); - let driver = Driver.create(); - await driver.delayMs(1000); - // 点击聊天列表 - await driver.assertComponentExist(ON.id('fileItem')); - let fileItem = await driver.findComponent(ON.id('fileItem')); - await driver.delayMs(1000); - await fileItem.longClick(); - await driver.delayMs(1000); - await driver.assertComponentExist(ON.id('encryption')); - let encryptionBtn = await driver.findComponent(ON.id('encryption')); - await driver.delayMs(1000); - await encryptionBtn.click(); - await driver.delayMs(1000); - // 设置编辑权限 - let selectBtn = await driver.findComponent(ON.text('请选择权限')); - await selectBtn.click(); - await driver.delayMs(1000); - let editBtn = await driver.findComponent(ON.text('编辑')); - await editBtn.click(); - await driver.delayMs(1000); - let confirm = await driver.findComponent(ON.text('确定')); - await driver.delayMs(1000); - await confirm.click(); - await driver.delayMs(1000); - }) - /** - * 保存 - */ - it(BUNDLE + 'SaveContent', 0, async () => { - Logger.info(TAG, BUNDLE + 'SaveContent begin'); - let driver = Driver.create(); - await driver.delayMs(1000); - // 点击进入编辑页面 - let authorizateBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.text_content')))); - await driver.delayMs(1000); - if (authorizateBtn) { - authorizateBtn.click(); - await driver.delayMs(1000); - } - let fileItem = await driver.findComponent(ON.id('fileItem')); - await fileItem.click(); - await driver.delayMs(3000); - let webBtn = await driver.findComponent(ON.id('webComponent')); - await driver.delayMs(1000); - await webBtn.click(); - await webBtn.inputText('hello'); - await driver.delayMs(3000); - // 点击保存 - let saveBtn = await driver.findComponent(ON.id('saveBtn')); - await saveBtn.click(); - await driver.delayMs(1000); - // 返回Home页面 - let want: Want = { - bundleName: 'com.samples.dlp', - abilityName: "EntryAbility" - } - await delegator.startAbility(want); - Logger.info(TAG, BUNDLE + 'SaveContent end'); - }) - /** - * 只读权限 - */ - it(BUNDLE + 'OnlyRead', 0, async () => { - Logger.info(TAG, BUNDLE + 'OnlyRead begin'); - let driver = Driver.create(); - await driver.delayMs(3000); - // 点击进入编辑页面 - let fileItem = await driver.findComponent(ON.id('fileItem')); - await fileItem.longClick(); - await driver.delayMs(1000); - let encryptionBtn = await driver.findComponent(ON.id('encryption')); - await driver.delayMs(1000); - await encryptionBtn.click(); - await driver.delayMs(1000); - let file = await driver.findComponent(ON.id('fileItem')); - await driver.delayMs(1000); - await file.longClick(); - await driver.delayMs(1000); - let encryption = await driver.findComponent(ON.id('encryption')); - await encryption.click(); - await driver.delayMs(1000); - // 设置只读权限 - let selectBtn = await driver.findComponent(ON.text('请选择权限')); - await selectBtn.click(); - await driver.delayMs(1000); - let readBtn = await driver.findComponent(ON.text('只读')); - await readBtn.click(); - await driver.delayMs(1000); - let confirm = await driver.findComponent(ON.text('确定')); - await driver.delayMs(1000); - await confirm.click(); - await driver.delayMs(1000); - Logger.info(TAG, BUNDLE + 'OnlyRead end'); - }) - /** - * 验证只读权限 - */ - it(BUNDLE + 'CheckOnlyRead', 0, async () => { - Logger.info(TAG, BUNDLE + 'CheckOnlyRead begin'); - let driver = Driver.create(); - await driver.delayMs(1000); - // 点击进入编辑页面 - let fileItem = await driver.findComponent(ON.id('fileItem')); - await fileItem.click(); - await driver.delayMs(1000); - Logger.info(TAG, BUNDLE + 'CheckOnlyRead end'); - }) - }) +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +import Logger from './Logger'; +import { Driver, ON } from '@ohos.UiTest'; +import Want from '@ohos.app.ability.Want'; +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import inputMethod from '@ohos.inputMethod'; +import resourceManager from '@ohos.resourceManager'; + +const BUNDLE = 'DLP'; +const TAG = '[Sample_DLP_TEST]'; +const delegator = abilityDelegatorRegistry.getAbilityDelegator(); + +async function getResourceString(resource: T): Promise { + let manage = delegator.getAppContext().resourceManager; + let text = await manage.getStringValue(resource); + return text; +} + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + beforeAll(async () => { + let want: Want = { + bundleName: 'com.samples.dlp', + abilityName: "EntryAbility" + } + await delegator.startAbility(want); + }) + /** + * 允许 + */ + it(BUNDLE + 'authorization', 0, async () => { + Logger.info(TAG, BUNDLE + 'authorization begin') + let driver = Driver.create(); + await driver.delayMs(5000); + // 点击聊天列表 + await driver.assertComponentExist(ON.text('允许')); + let authorizateBtn = await driver.findComponent(ON.text('允许')); + await driver.delayMs(1000); + await authorizateBtn.click(); + await driver.delayMs(1000); + }) + /** + * 添加普通文件 + */ + it(BUNDLE + 'AddFiles', 0, async () => { + Logger.info(TAG, BUNDLE + 'AddFiles begin'); + let driver = Driver.create(); + await driver.delayMs(1000); + // 添加普通文件 + await driver.assertComponentExist(ON.id('newFile')); + let addBtn = await driver.findComponent(ON.id('newFile')); + await driver.delayMs(1000); + await addBtn.click(); + await driver.delayMs(1000); + let authorizateBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.text_content')))); + await driver.delayMs(1000); + if(authorizateBtn) { + await authorizateBtn.click(); + await driver.delayMs(1000); + } + let authorizateBtn2 = await driver.findComponent(ON.text(await getResourceString($r('app.string.text_content')))); + await driver.delayMs(1000); + if(authorizateBtn2) { + await authorizateBtn2.click(); + await driver.delayMs(1000); + } + let timestamp = new Date().getTime(); + let textInput = await driver.findComponent(ON.type('TextInput')); + await driver.delayMs(1000); + await textInput.inputText(`xxx合同${timestamp}.txt`); + await driver.delayMs(1000); + let inputMethodController = inputMethod.getController(); + inputMethodController.hideTextInput(); + await driver.delayMs(1000); + let ImageArray = await driver.findComponents(ON.type('Image')); + Logger.info(TAG, `ImageArray lenth:${ImageArray.length}`); + let finishBtn = ImageArray[2]; + await finishBtn.click(); + Logger.info(TAG, BUNDLE + 'AddFiles end'); + }) + /** + * 加密操作 + */ + it(BUNDLE + 'AddOrdinaryFiles', 0, async () => { + Logger.info(TAG, BUNDLE + 'AddOrdinaryFiles begin'); + let driver = Driver.create(); + await driver.delayMs(1000); + // 点击聊天列表 + await driver.assertComponentExist(ON.id('fileItem')); + let fileItem = await driver.findComponent(ON.id('fileItem')); + await driver.delayMs(1000); + await fileItem.longClick(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.id('encryption')); + let encryptionBtn = await driver.findComponent(ON.id('encryption')); + await driver.delayMs(1000); + await encryptionBtn.click(); + await driver.delayMs(1000); + // 设置编辑权限 + let selectBtn = await driver.findComponent(ON.text('请选择权限')); + await selectBtn.click(); + await driver.delayMs(1000); + let editBtn = await driver.findComponent(ON.text('编辑')); + await editBtn.click(); + await driver.delayMs(1000); + let confirm = await driver.findComponent(ON.text('确定')); + await driver.delayMs(1000); + await confirm.click(); + await driver.delayMs(1000); + }) + /** + * 保存 + */ + it(BUNDLE + 'SaveContent', 0, async () => { + Logger.info(TAG, BUNDLE + 'SaveContent begin'); + let driver = Driver.create(); + await driver.delayMs(1000); + // 点击进入编辑页面 + let authorizateBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.text_content')))); + await driver.delayMs(1000); + if (authorizateBtn) { + authorizateBtn.click(); + await driver.delayMs(1000); + } + let fileItem = await driver.findComponent(ON.id('fileItem')); + await fileItem.click(); + await driver.delayMs(3000); + let webBtn = await driver.findComponent(ON.id('webComponent')); + await driver.delayMs(1000); + await webBtn.click(); + await webBtn.inputText('hello'); + await driver.delayMs(3000); + // 点击保存 + let saveBtn = await driver.findComponent(ON.id('saveBtn')); + await saveBtn.click(); + await driver.delayMs(1000); + // 返回Home页面 + let want: Want = { + bundleName: 'com.samples.dlp', + abilityName: "EntryAbility" + } + await delegator.startAbility(want); + Logger.info(TAG, BUNDLE + 'SaveContent end'); + }) + /** + * 只读权限 + */ + it(BUNDLE + 'OnlyRead', 0, async () => { + Logger.info(TAG, BUNDLE + 'OnlyRead begin'); + let driver = Driver.create(); + await driver.delayMs(3000); + // 点击进入编辑页面 + let fileItem = await driver.findComponent(ON.id('fileItem')); + await fileItem.longClick(); + await driver.delayMs(1000); + let encryptionBtn = await driver.findComponent(ON.id('encryption')); + await driver.delayMs(1000); + await encryptionBtn.click(); + await driver.delayMs(1000); + let file = await driver.findComponent(ON.id('fileItem')); + await driver.delayMs(1000); + await file.longClick(); + await driver.delayMs(1000); + let encryption = await driver.findComponent(ON.id('encryption')); + await encryption.click(); + await driver.delayMs(1000); + // 设置只读权限 + let selectBtn = await driver.findComponent(ON.text('请选择权限')); + await selectBtn.click(); + await driver.delayMs(1000); + let readBtn = await driver.findComponent(ON.text('只读')); + await readBtn.click(); + await driver.delayMs(1000); + let confirm = await driver.findComponent(ON.text('确定')); + await driver.delayMs(1000); + await confirm.click(); + await driver.delayMs(1000); + Logger.info(TAG, BUNDLE + 'OnlyRead end'); + }) + /** + * 验证只读权限 + */ + it(BUNDLE + 'CheckOnlyRead', 0, async () => { + Logger.info(TAG, BUNDLE + 'CheckOnlyRead begin'); + let driver = Driver.create(); + await driver.delayMs(1000); + // 点击进入编辑页面 + let fileItem = await driver.findComponent(ON.id('fileItem')); + await fileItem.click(); + await driver.delayMs(1000); + Logger.info(TAG, BUNDLE + 'CheckOnlyRead end'); + }) + }) } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/List.test.ets b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/List.test.ets index ba94018f88..657d194164 100644 --- a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/List.test.ets +++ b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/List.test.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/Logger.ts b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/Logger.ts index fbceab7060..90c9e4074a 100644 --- a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/Logger.ts +++ b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/test/Logger.ts @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -class Logger { - // 日志对应的领域标识 - private domain: number = 0xF811; - // tag日志标识 - private prefix: string = '[Samples_AuthorizedControl]'; - // 格式字符串,用于日志的格式化输出 - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } -} - +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +class Logger { + // 日志对应的领域标识 + private domain: number = 0xF811; + // tag日志标识 + private prefix: string = '[Samples_AuthorizedControl]'; + // 格式字符串,用于日志的格式化输出 + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Samples_DLP]'); \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testability/TestAbility.ets index 650c1df316..53e4446e51 100644 --- a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testability/TestAbility.ets +++ b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; -import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; -import hilog from '@ohos.hilog'; -import { Hypium } from '@ohos/hypium'; -import testsuite from '../test/List.test'; -import window from '@ohos.window'; -import Want from '@ohos.app.ability.Want'; -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; - -export default class TestAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); - hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); - hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); - let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator - abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() - let abilityDelegatorArguments: abilityDelegatorRegistry.AbilityDelegatorArgs - abilityDelegatorArguments = abilityDelegatorRegistry.getArguments() - hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - } - - onDestroy() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); - windowStage.loadContent('testability/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() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); - } - - onForeground() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); - } - - onBackground() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); - } +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility'; +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import hilog from '@ohos.hilog'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; +import window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; + +export default class TestAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); + let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator + abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + let abilityDelegatorArguments: abilityDelegatorRegistry.AbilityDelegatorArgs + abilityDelegatorArguments = abilityDelegatorRegistry.getArguments() + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/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() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testability/pages/Index.ets index 8eb693b0eb..e91baaf849 100644 --- a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testability/pages/Index.ets +++ b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; - -@Entry -@Component -struct Index { - aboutToAppear() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); - } - - @State message: string = 'Hello World' - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(20) - .fontWeight(FontWeight.Bold) - } - .type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('35%') - .height('5%') - .onClick(() => { - }) - } - .width('100%') - } - .height('100%') - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(() => { + }) + } + .width('100%') + } + .height('100%') + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts index ba78cb5721..d9f862c2e0 100644 --- a/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts +++ b/code/SystemFeature/Security/DLP/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import TestRunner from '@ohos.application.testRunner'; -import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; - -var abilityDelegator = undefined -var abilityDelegatorArguments = undefined - -async function onAbilityCreateCallback() { - hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); -} - -async function addAbilityMonitorCallback(err: any) { - hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); -} - -export default class OpenHarmonyTestRunner implements TestRunner { - constructor() { - } - - onPrepare() { - hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); - } - - async onRun() { - hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - const bundleName = abilityDelegatorArguments.bundleName; - const testAbilityName = 'TestAbility'; - let lMonitor = { - abilityName: testAbilityName, - onAbilityCreate: onAbilityCreateCallback, - }; - abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) - const want = { - bundleName: bundleName, - abilityName: testAbilityName - }; - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - abilityDelegator.startAbility(want, (err: any, data: any) => { - hilog.info(0x0000, 'testTag', 'startAbility : err : %{public}s', JSON.stringify(err) ?? ''); - hilog.info(0x0000, 'testTag', 'startAbility : data : %{public}s', JSON.stringify(data) ?? ''); - }) - hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + const bundleName = abilityDelegatorArguments.bundleName; + const testAbilityName = 'TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + const want = { + bundleName: bundleName, + abilityName: testAbilityName + }; + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + abilityDelegator.startAbility(want, (err: any, data: any) => { + hilog.info(0x0000, 'testTag', 'startAbility : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'startAbility : data : %{public}s', JSON.stringify(data) ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/ohosTest/module.json5 b/code/SystemFeature/Security/DLP/entry/src/ohosTest/module.json5 index 7e44e83cf9..e6a499c49e 100644 --- a/code/SystemFeature/Security/DLP/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/Security/DLP/entry/src/ohosTest/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/element/color.json b/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/element/color.json index d66f9a7d4a..3c712962da 100644 --- a/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/element/color.json +++ b/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/element/color.json @@ -1,8 +1,8 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/element/string.json b/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/element/string.json index 70d125129f..530112a769 100644 --- a/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/element/string.json +++ b/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/element/string.json @@ -1,24 +1,24 @@ -{ - "string": [ - { - "name": "module_test_desc", - "value": "test ability description" - }, - { - "name": "TestAbility_desc", - "value": "the test ability" - }, - { - "name": "TestAbility_label", - "value": "test label" - }, - { - "name": "file_name", - "value": "xxx合同.txt" - }, - { - "name": "text_content", - "value": "允许" - } - ] +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "file_name", + "value": "xxx合同.txt" + }, + { + "name": "text_content", + "value": "允许" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/profile/test_pages.json index c3d813c41a..b7e7343cac 100644 --- a/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/profile/test_pages.json +++ b/code/SystemFeature/Security/DLP/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -1,5 +1,5 @@ -{ - "src": [ - "testability/pages/Index" - ] -} +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/code/SystemFeature/Security/DLP/hvigor/hvigor-config.json5 b/code/SystemFeature/Security/DLP/hvigor/hvigor-config.json5 index 213d992653..a7edd62de4 100644 --- a/code/SystemFeature/Security/DLP/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/Security/DLP/hvigor/hvigor-config.json5 @@ -1,18 +1,18 @@ -{ - "hvigorVersion": "3.0.9", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.9" - }, - "execution": { - // "daemon": true, /* Enable daemon compilation. Default: true */ - // "incremental": true, /* Enable incremental compilation. Default: true */ - // "parallel": true, /* Enable parallel compilation. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Default: false */ - } +{ + "hvigorVersion": "3.0.9", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.9" + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } } \ No newline at end of file diff --git a/code/SystemFeature/Security/DLP/oh-package.json5 b/code/SystemFeature/Security/DLP/oh-package.json5 index e35556872e..d8ae900705 100644 --- a/code/SystemFeature/Security/DLP/oh-package.json5 +++ b/code/SystemFeature/Security/DLP/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 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. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "dlp", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "dlp", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/SystemFeature/Security/DLP/ohosTest.md b/code/SystemFeature/Security/DLP/ohosTest.md index 7981ae61f8..3f2c8b5e0f 100644 --- a/code/SystemFeature/Security/DLP/ohosTest.md +++ b/code/SystemFeature/Security/DLP/ohosTest.md @@ -1,12 +1,12 @@ -# 数据防泄漏测试用例归档 - -## 用例表 - -| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 |测试结果| -|--------|-------------|----------------------|-------------------------------|--------------------------------|--------------------------------| -| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 |Pass| -| 新增普通文件 | 页面显示正常 | 点击新增按钮,输入文件名称,点击确定 | 拉起picker页面,文件命名成功,DLP页面显示新增文件 | 是 |Pass| -| 加密授权 | 长按点击加密按钮 | | 弹出提示框 | 是 |Pass| -| 验证编辑文件 | 文件已设置编辑权限 | 点击加密文件 | 成功跳转编辑应用 | 是 | Pass| -| 编辑数据保存 | 编辑页面 | 输入文本数据 | 数据保存成功 | 是 | Pass| +# 数据防泄漏测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 |测试结果| +|--------|-------------|----------------------|-------------------------------|--------------------------------|--------------------------------| +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 |Pass| +| 新增普通文件 | 页面显示正常 | 点击新增按钮,输入文件名称,点击确定 | 拉起picker页面,文件命名成功,DLP页面显示新增文件 | 是 |Pass| +| 加密授权 | 长按点击加密按钮 | | 弹出提示框 | 是 |Pass| +| 验证编辑文件 | 文件已设置编辑权限 | 点击加密文件 | 成功跳转编辑应用 | 是 | Pass| +| 编辑数据保存 | 编辑页面 | 输入文本数据 | 数据保存成功 | 是 | Pass| | 验证只读权限 | 文件已设置只读权限 | 点击文件 | 跳转编辑页面,页面置灰 | 是 | Pass| \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/AppScope/app.json5 b/code/SystemFeature/UIExtensionSamples/AppScope/app.json5 index 261c2c73fd..c9822f2a97 100644 --- a/code/SystemFeature/UIExtensionSamples/AppScope/app.json5 +++ b/code/SystemFeature/UIExtensionSamples/AppScope/app.json5 @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2024 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.UIExtension", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2024 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.UIExtension", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/SystemFeature/UIExtensionSamples/AppScope/resources/base/element/string.json b/code/SystemFeature/UIExtensionSamples/AppScope/resources/base/element/string.json index 4f432049b5..58d68b7a17 100644 --- a/code/SystemFeature/UIExtensionSamples/AppScope/resources/base/element/string.json +++ b/code/SystemFeature/UIExtensionSamples/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "UIExtensionSamples" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "UIExtensionSamples" + } + ] +} diff --git a/code/SystemFeature/UIExtensionSamples/README_zh.md b/code/SystemFeature/UIExtensionSamples/README_zh.md index bf7c2d31d7..2c15691135 100644 --- a/code/SystemFeature/UIExtensionSamples/README_zh.md +++ b/code/SystemFeature/UIExtensionSamples/README_zh.md @@ -1,152 +1,152 @@ -# 基础能力增强 - -### 介绍 - -本示例使用 [AbilityStartCallback](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-abilityStartCallback.md) , [UIExtensionContent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiExtensionContext.md) , [UIExtensionContentSession](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession.md) 中的接口进行实现。 - -### 效果预览 - -| 主页面 | 弹出状态Toast | UIExtensionContentSession页面 | UIExtension启动页 | -| :----------------------------------------------: | :---------------------------------------------------: | :--------------------------------------------------: | :----------------------------------------------------: | -| | | | | - -使用说明 - -AbilityStartCallback对应接口 - -1.点击主页面**AbilityStartCallback开发示例**按钮,跳转到'AbilityStartCallback开发示例'界面; - -2.点击**startAbilityByTyp onResult**按钮,拉起'选择音频'窗口,点击返回按钮,返回上级界面; - -3.点击**startAbilityByType onError**按钮,弹出提示'startAbilityByType onError...'信息。 - - - -UIExtensionContext对应接口 - -1.点击主页面**UIExtensionContext开发示例**按钮,跳转到'UIExtensionContext开发示例'界面; - -2.点击**openLink**按钮,启动一个新的UIAbility,点击返回按钮,返回上级界面; - -3.点击**启动UIExtensionAbility**按钮,启动一个新的UIExtensionAbility,在UIExtensionAbility界面上显示reportDrawnCompleted,terminateSelf callback,terminateSelf promise,terminateSelfWithResult callback,terminateSelfWithResult promise接口对应的按钮; - -4.点击**reportDrawnCompleted**按钮,弹出提示'UIExtensionContent.reportDrawnCompleted succeed.'信息; - -5.点击**terminateSelf callback**按钮,关闭UIExtensionAbility,显示'UIExtensionContext开发示例'界面; - -6.点击**启动UIExtensionAbility**按钮,在UIExtensionAbility界面上点击**terminateSelf promise**按钮,关闭UIExtensionAbility,显示'UIExtensionContext开发示例'界面; - -7.点击**启动UIExtensionAbility**按钮,在UIExtensionAbility界面上点击**terminateSelfWithResult callback**按钮,关闭UIExtensionAbility,显 示'UIExtensionContext开发示例'界面; - -8.点击**启动UIExtensionAbility**按钮,在UIExtensionAbility界面上点击**terminateSelfWithResult promise**按钮,关闭UIExtensionAbility,显示'UIExtensionContext开发示例'界面。 - - - -UIExtensionContentSession对应接口 - -1.点击主页面**UIExtensionContentSession开发示例**按钮,跳转到'UIExtensionContentSession开发示例'界面; - -2.点击**启动UIExtensionAbility**按钮,启动一个新的UIExtensionAbility,在UIExtensionAbility界面上显示terminateSelfWithResult callback,terminateSelfWithResult promise,setWindowPrivacyMode callback,setWindowPrivacyMode promise,getUIExtensionWindowProxy接口对应的按钮; - -3.点击**terminateSelfWithResult callback**按钮,关闭UIExtensionAbility,显示'UIExtensionContentSession开发示例'界面; - -4.点击**terminateSelfWithResult promise**按钮,关闭UIExtensionAbility,显示'UIExtensionContentSession开发示例'界面; - -5.点击**setWindowPrivacyMode callback**按钮,弹出提示'UIExtensionContentSession.setWindowPrivacyMode(callback)...'信息; - -6.点击**setWindowPrivacyMode promise**按钮,弹出提示'UIExtensionContentSession.setWindowPrivacyMode(promise)...'信息; - -7.点击**getUIExtensionWindowProxy**按钮,弹出提示'UIExtensionContentSession.getUIExtensionWindowProxy...'信息; - -### 工程目录 - -``` -entry/src/main/ets/ -|---entryability -| |---EntryAbility.ets // 首页的Ability -| |---OpenLinkUIAbility.ets // UIAbility(用于验证新接口使用) -|---pages -| |---Index.ets // 首页 -| |---OpenLinkIndex.ets // 被启动的OpenLink接口的展示页 -|---uiextensionentry -| |---ContextUIExtensionAbility.ets // UIExtensionAbility(用于验证新接口使用) -| |---SessionUIExtensionAbility.ets // UIExtensionAbility(用于验证新接口使用) -|---uiextensionpages -| |---AbilityStartCallback.ets // AbilityStartCallback的接口的展示页 -| |---UIExtensionContentSession.ets // UIExtensionContentSession的接口的展示页 -| |---UIExtensionContentSessionPage.ets // SessionUIExtensionAbility加载的页面 -| |---UIExtensionContext.ets // UIExtensionContext的接口的展示页 -| |---UIExtensionContextPage.ets // ContextUIExtensionAbility加载的页面 - -``` - -### 具体实现 - -* AbilityStartCallback对应接口实现,源码参考[AbilityStartCallback.ets](entry/src/main/ets/uiextensionpages/AbilityStartCallback.ets) - - * onResult接口实现:通过调用startAbilityByType接口,'所有照片'窗口,关闭窗口回调触发onResult接口; - * onError接口实现:通过调用startAbilityByType接口,调用失败触发onError接口; - -* UIExtensionContext对应接口实现,源码参考[UIExtensionContext.ets](entry/src/main/ets/uiextensionpages/UIExtensionContext.ets)和[UIExtensionContextPage.ets](entry/src/main/ets/uiextensionpages/UIExtensionContextPage.ets) - - * openLink接口实现:在被启动的UIAbility的module.json5中配置下列字段: - - -"actions"列表中包含"ohos.want.action.viewData" - - \- "entities"列表中包含"entity.system.browsable" - - \- "uris"列表中包含"scheme"为"https"且"domainVerify"为true的元素 - - 在调用端调用openLink接口,传入对应字段信息,可以拉起对应的UIAbility; - - * reportDrawnCompleted接口实现:通过调用this.context.reportDrawnCompleted口开发者提供打点功能; - - * terminateSelf(Promise)接口实现:通过调用this.context.terminateSelf()接口实现停止Ability自身功能; - - * terminateSelf(Callback)接口实现:通过调用this.context.terminateSelf()接口实现停止Ability自身功能; - - * terminateSelfWithResult(Promise)接口实现:通过调用this.context.terminateSelfWithResult()接口实现停止Ability自身,并将结果返回给调用者的功能; - - * terminateSelfWithResult(Callback)接口实现:通过调用this.context.terminateSelfWithResult()接口实现停止Ability自身,并将结果返回给调用者的功能; - -* UIExtensionContentSession对应接口实现,源码参考[UIExtensionContentSession.ets](entry/src/main/ets/uiextensionpages/UIExtensionContentSession.ets)和[UIExtensionContentSessionPage.ets](entry/src/main/ets/uiextensionpages/UIExtensionContentSessionPage.ets) - - * terminateSelfWithResult(Promise)接口实现:通过调用this.session.terminateSelfWithResult()接口,实现停止UIExtensionContentSession对应的窗口界面对象,并将结果返回给UIExtensionComponent控件的功能; - * terminateSelfWithResult(Callback)接口实现:通过调用this.session.terminateSelfWithResult()接口,实现停止UIExtensionContentSession对应的窗口界面对象,并将结果返回给UIExtensionComponent控件的功能; - * setWindowPrivacyMode(Promise)接口实现:通过调用this.session.setWindowPrivacyMode()接口,实现设置窗口是否为隐私模式功能; - * setWindowPrivacyMode(Callback)接口实现:通过调用this.session.setWindowPrivacyMode()接口,实现设置窗口是否为隐私模式功能; - * getUIExtensionWindowProxy接口实现:通过调用this.session.getUIExtensionWindowProxy()接口,实现获取UIExtension窗口代理功能; - -### 相关权限 - -[ohos.permission.START_INVISIBLE_ABILITY](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md) - -[ohos.permission.PRIVACY_WINDOW](https://gitee.com/openharmony/docs/blob/eb73c9e9dcdd421131f33bb8ed6ddc030881d06f/zh-cn/application-dev/security/permission-list.md) - -### 依赖 - -不涉及。 - -### 约束与限制 - -1.本示例仅支持标准系统上运行,支持设备:RK3568; - -2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31; - -3.本示例涉及使用系统接口:UIAbilityContext.requestModalUIExtension,UIAbilityContext.startAbilityByType -需要手动替换Full SDK才能编译通过; - -4.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.403, built on June 20, 2024)才可编译运行; - -5.本示例涉及[ohos.permission.START_INVISIBLE_ABILITY](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)权限为 system_core级别,需要配置高权限签名。 - -### 下载 - -```shell -git init -git config core.sparsecheckout true -echo code/SystemFeature/UIExtensionSamples > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git -git pull origin master -``` - +# 基础能力增强 + +### 介绍 + +本示例使用 [AbilityStartCallback](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-abilityStartCallback.md) , [UIExtensionContent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiExtensionContext.md) , [UIExtensionContentSession](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession.md) 中的接口进行实现。 + +### 效果预览 + +| 主页面 | 弹出状态Toast | UIExtensionContentSession页面 | UIExtension启动页 | +| :----------------------------------------------: | :---------------------------------------------------: | :--------------------------------------------------: | :----------------------------------------------------: | +| | | | | + +使用说明 + +AbilityStartCallback对应接口 + +1.点击主页面**AbilityStartCallback开发示例**按钮,跳转到'AbilityStartCallback开发示例'界面; + +2.点击**startAbilityByTyp onResult**按钮,拉起'选择音频'窗口,点击返回按钮,返回上级界面; + +3.点击**startAbilityByType onError**按钮,弹出提示'startAbilityByType onError...'信息。 + + + +UIExtensionContext对应接口 + +1.点击主页面**UIExtensionContext开发示例**按钮,跳转到'UIExtensionContext开发示例'界面; + +2.点击**openLink**按钮,启动一个新的UIAbility,点击返回按钮,返回上级界面; + +3.点击**启动UIExtensionAbility**按钮,启动一个新的UIExtensionAbility,在UIExtensionAbility界面上显示reportDrawnCompleted,terminateSelf callback,terminateSelf promise,terminateSelfWithResult callback,terminateSelfWithResult promise接口对应的按钮; + +4.点击**reportDrawnCompleted**按钮,弹出提示'UIExtensionContent.reportDrawnCompleted succeed.'信息; + +5.点击**terminateSelf callback**按钮,关闭UIExtensionAbility,显示'UIExtensionContext开发示例'界面; + +6.点击**启动UIExtensionAbility**按钮,在UIExtensionAbility界面上点击**terminateSelf promise**按钮,关闭UIExtensionAbility,显示'UIExtensionContext开发示例'界面; + +7.点击**启动UIExtensionAbility**按钮,在UIExtensionAbility界面上点击**terminateSelfWithResult callback**按钮,关闭UIExtensionAbility,显 示'UIExtensionContext开发示例'界面; + +8.点击**启动UIExtensionAbility**按钮,在UIExtensionAbility界面上点击**terminateSelfWithResult promise**按钮,关闭UIExtensionAbility,显示'UIExtensionContext开发示例'界面。 + + + +UIExtensionContentSession对应接口 + +1.点击主页面**UIExtensionContentSession开发示例**按钮,跳转到'UIExtensionContentSession开发示例'界面; + +2.点击**启动UIExtensionAbility**按钮,启动一个新的UIExtensionAbility,在UIExtensionAbility界面上显示terminateSelfWithResult callback,terminateSelfWithResult promise,setWindowPrivacyMode callback,setWindowPrivacyMode promise,getUIExtensionWindowProxy接口对应的按钮; + +3.点击**terminateSelfWithResult callback**按钮,关闭UIExtensionAbility,显示'UIExtensionContentSession开发示例'界面; + +4.点击**terminateSelfWithResult promise**按钮,关闭UIExtensionAbility,显示'UIExtensionContentSession开发示例'界面; + +5.点击**setWindowPrivacyMode callback**按钮,弹出提示'UIExtensionContentSession.setWindowPrivacyMode(callback)...'信息; + +6.点击**setWindowPrivacyMode promise**按钮,弹出提示'UIExtensionContentSession.setWindowPrivacyMode(promise)...'信息; + +7.点击**getUIExtensionWindowProxy**按钮,弹出提示'UIExtensionContentSession.getUIExtensionWindowProxy...'信息; + +### 工程目录 + +``` +entry/src/main/ets/ +|---entryability +| |---EntryAbility.ets // 首页的Ability +| |---OpenLinkUIAbility.ets // UIAbility(用于验证新接口使用) +|---pages +| |---Index.ets // 首页 +| |---OpenLinkIndex.ets // 被启动的OpenLink接口的展示页 +|---uiextensionentry +| |---ContextUIExtensionAbility.ets // UIExtensionAbility(用于验证新接口使用) +| |---SessionUIExtensionAbility.ets // UIExtensionAbility(用于验证新接口使用) +|---uiextensionpages +| |---AbilityStartCallback.ets // AbilityStartCallback的接口的展示页 +| |---UIExtensionContentSession.ets // UIExtensionContentSession的接口的展示页 +| |---UIExtensionContentSessionPage.ets // SessionUIExtensionAbility加载的页面 +| |---UIExtensionContext.ets // UIExtensionContext的接口的展示页 +| |---UIExtensionContextPage.ets // ContextUIExtensionAbility加载的页面 + +``` + +### 具体实现 + +* AbilityStartCallback对应接口实现,源码参考[AbilityStartCallback.ets](entry/src/main/ets/uiextensionpages/AbilityStartCallback.ets) + + * onResult接口实现:通过调用startAbilityByType接口,'所有照片'窗口,关闭窗口回调触发onResult接口; + * onError接口实现:通过调用startAbilityByType接口,调用失败触发onError接口; + +* UIExtensionContext对应接口实现,源码参考[UIExtensionContext.ets](entry/src/main/ets/uiextensionpages/UIExtensionContext.ets)和[UIExtensionContextPage.ets](entry/src/main/ets/uiextensionpages/UIExtensionContextPage.ets) + + * openLink接口实现:在被启动的UIAbility的module.json5中配置下列字段: + + -"actions"列表中包含"ohos.want.action.viewData" + + \- "entities"列表中包含"entity.system.browsable" + + \- "uris"列表中包含"scheme"为"https"且"domainVerify"为true的元素 + + 在调用端调用openLink接口,传入对应字段信息,可以拉起对应的UIAbility; + + * reportDrawnCompleted接口实现:通过调用this.context.reportDrawnCompleted口开发者提供打点功能; + + * terminateSelf(Promise)接口实现:通过调用this.context.terminateSelf()接口实现停止Ability自身功能; + + * terminateSelf(Callback)接口实现:通过调用this.context.terminateSelf()接口实现停止Ability自身功能; + + * terminateSelfWithResult(Promise)接口实现:通过调用this.context.terminateSelfWithResult()接口实现停止Ability自身,并将结果返回给调用者的功能; + + * terminateSelfWithResult(Callback)接口实现:通过调用this.context.terminateSelfWithResult()接口实现停止Ability自身,并将结果返回给调用者的功能; + +* UIExtensionContentSession对应接口实现,源码参考[UIExtensionContentSession.ets](entry/src/main/ets/uiextensionpages/UIExtensionContentSession.ets)和[UIExtensionContentSessionPage.ets](entry/src/main/ets/uiextensionpages/UIExtensionContentSessionPage.ets) + + * terminateSelfWithResult(Promise)接口实现:通过调用this.session.terminateSelfWithResult()接口,实现停止UIExtensionContentSession对应的窗口界面对象,并将结果返回给UIExtensionComponent控件的功能; + * terminateSelfWithResult(Callback)接口实现:通过调用this.session.terminateSelfWithResult()接口,实现停止UIExtensionContentSession对应的窗口界面对象,并将结果返回给UIExtensionComponent控件的功能; + * setWindowPrivacyMode(Promise)接口实现:通过调用this.session.setWindowPrivacyMode()接口,实现设置窗口是否为隐私模式功能; + * setWindowPrivacyMode(Callback)接口实现:通过调用this.session.setWindowPrivacyMode()接口,实现设置窗口是否为隐私模式功能; + * getUIExtensionWindowProxy接口实现:通过调用this.session.getUIExtensionWindowProxy()接口,实现获取UIExtension窗口代理功能; + +### 相关权限 + +[ohos.permission.START_INVISIBLE_ABILITY](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md) + +[ohos.permission.PRIVACY_WINDOW](https://gitee.com/openharmony/docs/blob/eb73c9e9dcdd421131f33bb8ed6ddc030881d06f/zh-cn/application-dev/security/permission-list.md) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568; + +2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31; + +3.本示例涉及使用系统接口:UIAbilityContext.requestModalUIExtension,UIAbilityContext.startAbilityByType +需要手动替换Full SDK才能编译通过; + +4.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.403, built on June 20, 2024)才可编译运行; + +5.本示例涉及[ohos.permission.START_INVISIBLE_ABILITY](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)权限为 system_core级别,需要配置高权限签名。 + +### 下载 + +```shell +git init +git config core.sparsecheckout true +echo code/SystemFeature/UIExtensionSamples > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` + diff --git a/code/SystemFeature/UIExtensionSamples/build-profile.json5 b/code/SystemFeature/UIExtensionSamples/build-profile.json5 index fbf59fade1..6240b41505 100644 --- a/code/SystemFeature/UIExtensionSamples/build-profile.json5 +++ b/code/SystemFeature/UIExtensionSamples/build-profile.json5 @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2024 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": 12, - "compileSdkVersion": 12, - "runtimeOS": "OpenHarmony", - } - ], - "buildModeSet": [ - { - "name": "debug", - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 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": 12, + "compileSdkVersion": 12, + "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/SystemFeature/UIExtensionSamples/entry/build-profile.json5 b/code/SystemFeature/UIExtensionSamples/entry/build-profile.json5 index 6f9f4c8e9e..ad6ca3258f 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/build-profile.json5 +++ b/code/SystemFeature/UIExtensionSamples/entry/build-profile.json5 @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2024 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", - } - ] +/* + * Copyright (c) 2024 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/SystemFeature/UIExtensionSamples/entry/oh-package.json5 b/code/SystemFeature/UIExtensionSamples/entry/oh-package.json5 index 2959d78c50..248c3b7541 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/oh-package.json5 +++ b/code/SystemFeature/UIExtensionSamples/entry/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "name": "entry", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": {} -} - +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/entryability/EntryAbility.ets b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/entryability/EntryAbility.ets index d0e87e9869..36296027ac 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,88 +1,88 @@ -/* - * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -const TAG: string = 'EntryAbility'; -const DOMAIN: number = 0xFF00; - -export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate'); - } - - onDestroy(): void { - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate') - - let windowClass: window.Window | undefined = undefined; - windowStage.getMainWindow((err: BusinessError, data) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); - return; - } - windowClass = data; - let systemBarProperties: window.SystemBarProperties = { - statusBarColor: '#f1f3f5', - navigationBarColor: '#f1f3f5', - }; - try { - windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); - }); - } catch (exception) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); - } - }); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); - }); - } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); - } -} +/* + * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG: string = 'EntryAbility'; +const DOMAIN: number = 0xFF00; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate') + + let windowClass: window.Window | undefined = undefined; + windowStage.getMainWindow((err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + return; + } + windowClass = data; + let systemBarProperties: window.SystemBarProperties = { + statusBarColor: '#f1f3f5', + navigationBarColor: '#f1f3f5', + }; + try { + windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); + }); + } catch (exception) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); + } + }); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/entryability/OpenLinkUIAbility.ets b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/entryability/OpenLinkUIAbility.ets index 8a9feb50e6..69fbba8077 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/entryability/OpenLinkUIAbility.ets +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/entryability/OpenLinkUIAbility.ets @@ -1,96 +1,96 @@ -/* - * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; -import { UIAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; - -const TAG: string = '[OpenLinkUIAbility]'; -const DOMAIN: number = 0xFF00; - -export default class OpenLinkUIAbility extends UIAbility { - onCreate() { - hilog.info(DOMAIN, TAG, 'UIExtAbility onCreate'); - } - - onForeground() { - hilog.info(DOMAIN, TAG, `UIExtAbility onForeground`); - } - - onBackground() { - hilog.info(DOMAIN, TAG, `UIExtAbility onBackground`); - } - - onDestroy() { - hilog.info(DOMAIN, TAG, `UIExtAbility onDestroy`); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate'); - - let windowClass: window.Window | undefined = undefined; - windowStage.getMainWindow((err: BusinessError, data) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); - return; - } - windowClass = data; - let systemBarProperties: window.SystemBarProperties = { - statusBarColor: '#f1f3f5', - navigationBarColor: '#f1f3f5', - }; - try { - windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { - const errCode: number = err.code; - if (errCode) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); - }); - } catch (exception) { - hilog.error(DOMAIN, TAG, - `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); - } - }); - - windowStage.loadContent('pages/OpenLinkIndex', (err) => { - if (err.code) { - hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); - }); - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - hilog.info(DOMAIN, TAG, `UIExtAbility onSessionCreate, want: ${JSON.stringify(want)}`); - - let param: Record = { - 'session': session - }; - - let storage: LocalStorage = new LocalStorage(param); - session.loadContent('uiextensionpages/UIExtensionContextPage', storage); - } - - onSessionDestroy(session: UIExtensionContentSession) { - hilog.info(DOMAIN, TAG, `UIExtAbility onSessionDestroy`); - } +/* + * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; +import { UIAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG: string = '[OpenLinkUIAbility]'; +const DOMAIN: number = 0xFF00; + +export default class OpenLinkUIAbility extends UIAbility { + onCreate() { + hilog.info(DOMAIN, TAG, 'UIExtAbility onCreate'); + } + + onForeground() { + hilog.info(DOMAIN, TAG, `UIExtAbility onForeground`); + } + + onBackground() { + hilog.info(DOMAIN, TAG, `UIExtAbility onBackground`); + } + + onDestroy() { + hilog.info(DOMAIN, TAG, `UIExtAbility onDestroy`); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + let windowClass: window.Window | undefined = undefined; + windowStage.getMainWindow((err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + return; + } + windowClass = data; + let systemBarProperties: window.SystemBarProperties = { + statusBarColor: '#f1f3f5', + navigationBarColor: '#f1f3f5', + }; + try { + windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => { + const errCode: number = err.code; + if (errCode) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.'); + }); + } catch (exception) { + hilog.error(DOMAIN, TAG, + `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); + } + }); + + windowStage.loadContent('pages/OpenLinkIndex', (err) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + hilog.info(DOMAIN, TAG, `UIExtAbility onSessionCreate, want: ${JSON.stringify(want)}`); + + let param: Record = { + 'session': session + }; + + let storage: LocalStorage = new LocalStorage(param); + session.loadContent('uiextensionpages/UIExtensionContextPage', storage); + } + + onSessionDestroy(session: UIExtensionContentSession) { + hilog.info(DOMAIN, TAG, `UIExtAbility onSessionDestroy`); + } }; \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionentry/ContextUIExtensionAbility.ets b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionentry/ContextUIExtensionAbility.ets index 021f255cdc..c135148158 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionentry/ContextUIExtensionAbility.ets +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionentry/ContextUIExtensionAbility.ets @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2024 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 { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const TAG: string = '[UIExtAbility]'; -const DOMAIN: number = 0xFF00; - -export default class ContextUIExtensionAbility extends UIExtensionAbility { - onCreate() { - hilog.info(DOMAIN, TAG, 'UIExtAbility onCreate'); - } - - onForeground() { - hilog.info(DOMAIN, TAG, `UIExtAbility onForeground`); - } - - onBackground() { - hilog.info(DOMAIN, TAG, `UIExtAbility onBackground`); - } - - onDestroy() { - hilog.info(DOMAIN, TAG, `UIExtAbility onDestroy`); - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - hilog.info(DOMAIN, TAG, `UIExtAbility onSessionCreate, want: ${JSON.stringify(want)}`); - - let param: Record = { - 'session': session - }; - - let storage: LocalStorage = new LocalStorage(param); - session.loadContent('uiextensionpages/UIExtensionContextPage', storage); - } - - onSessionDestroy(session: UIExtensionContentSession) { - hilog.info(DOMAIN, TAG, `UIExtAbility onSessionDestroy`); - } +/* + * Copyright (c) 2024 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 { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = '[UIExtAbility]'; +const DOMAIN: number = 0xFF00; + +export default class ContextUIExtensionAbility extends UIExtensionAbility { + onCreate() { + hilog.info(DOMAIN, TAG, 'UIExtAbility onCreate'); + } + + onForeground() { + hilog.info(DOMAIN, TAG, `UIExtAbility onForeground`); + } + + onBackground() { + hilog.info(DOMAIN, TAG, `UIExtAbility onBackground`); + } + + onDestroy() { + hilog.info(DOMAIN, TAG, `UIExtAbility onDestroy`); + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + hilog.info(DOMAIN, TAG, `UIExtAbility onSessionCreate, want: ${JSON.stringify(want)}`); + + let param: Record = { + 'session': session + }; + + let storage: LocalStorage = new LocalStorage(param); + session.loadContent('uiextensionpages/UIExtensionContextPage', storage); + } + + onSessionDestroy(session: UIExtensionContentSession) { + hilog.info(DOMAIN, TAG, `UIExtAbility onSessionDestroy`); + } }; \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionentry/SessionUIExtensionAbility.ets b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionentry/SessionUIExtensionAbility.ets index 45dc8a7ca4..f5b7fb56e2 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionentry/SessionUIExtensionAbility.ets +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionentry/SessionUIExtensionAbility.ets @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2024 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 { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'; - -const TAG: string = 'SessionUIExtensionAbility'; -const DOMAIN: number = 0xFF00; - -export default class SessionUIExtensionAbility extends UIExtensionAbility { - onCreate() { - hilog.info(DOMAIN, TAG, 'MyUIExtensionAbility onCreate'); - } - - onDestroy() { - hilog.info(DOMAIN, TAG, 'MyUIExtensionAbility onDestroy'); - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - let param: Record = { - 'session': session, - 'want': want - }; - - let storage: LocalStorage = new LocalStorage(param); - session.loadContent('uiextensionpages/UIExtensionContentSessionPage', storage); - } - - onForeground() { - hilog.info(DOMAIN, TAG, 'MyUIExtensionAbility onForeground'); - } - - onBackground() { - hilog.info(DOMAIN, TAG, 'MyUIExtensionAbility onBackground'); - } -} - - +/* + * Copyright (c) 2024 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 { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'; + +const TAG: string = 'SessionUIExtensionAbility'; +const DOMAIN: number = 0xFF00; + +export default class SessionUIExtensionAbility extends UIExtensionAbility { + onCreate() { + hilog.info(DOMAIN, TAG, 'MyUIExtensionAbility onCreate'); + } + + onDestroy() { + hilog.info(DOMAIN, TAG, 'MyUIExtensionAbility onDestroy'); + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + let param: Record = { + 'session': session, + 'want': want + }; + + let storage: LocalStorage = new LocalStorage(param); + session.loadContent('uiextensionpages/UIExtensionContentSessionPage', storage); + } + + onForeground() { + hilog.info(DOMAIN, TAG, 'MyUIExtensionAbility onForeground'); + } + + onBackground() { + hilog.info(DOMAIN, TAG, 'MyUIExtensionAbility onBackground'); + } +} + + diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/AbilityStartCallback.ets b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/AbilityStartCallback.ets index b49558edfe..1ca4c83437 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/AbilityStartCallback.ets +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/AbilityStartCallback.ets @@ -1,157 +1,157 @@ -/* - * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; -import { common } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { promptAction } from '@kit.ArkUI'; - -const TAG: string = '[AbilityStartCallback]'; -const DOMAIN: number = 0xFF00; - -@Entry -@Component -struct AbilityStartCallback { - private promptDuration: number = 2000; - private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.AbilityStartCallback')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: 8, - bottom: 8, - left: 12 - }) - } - } - .width('100%') - .height('14.36%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIAbilityContext_startAbilityByType_onResult')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - - Row() { - Image($r('app.media.ic_arrow')) - .width(24) - .height(24) - .margin({ top: 16, bottom: 16, right: 6 }) - } - } - .id('onResult') - .onClick(() => { - let wantParam: Record = {}; - let abilityStartCallback: common.AbilityStartCallback = { - onError: (code: number, name: string, message: string) => { - let msg = `startAbilityByType onError, code:${code} name:${name} message:${message}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); - }, - onResult: (abilityResult: common.AbilityResult) => { - hilog.info(DOMAIN, TAG, `resultCode:` + abilityResult.resultCode + `bundleName:` + - abilityResult.want?.bundleName); - let msg = `startAbilityByType onResult, - resultCode:${abilityResult.resultCode} bundleName:${abilityResult.want?.bundleName}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); - } - }; - - this.context.startAbilityByType('audioPicker', wantParam, abilityStartCallback, (err: BusinessError) => { - let msg = `startAbilityByType fail, err: ${JSON.stringify(err)}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); - }); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIAbilityContext_startAbilityByType_onError')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('onError') - .onClick(() => { - let wantParam: Record = {}; - let abilityStartCallback: common.AbilityStartCallback = { - onError: (code: number, name: string, message: string) => { - let msg = `startAbilityByType onError, code:${code} name:${name} message:${message}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); - }, - onResult: (abilityResult: common.AbilityResult) => { - hilog.info(DOMAIN, TAG, `resultCode:` + abilityResult.resultCode + `bundleName:` + - abilityResult.want?.bundleName); - let msg = `startAbilityByType onResult, - resultCode:${abilityResult.resultCode} bundleName:${abilityResult.want?.bundleName}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); - } - }; - - this.context.startAbilityByType('error', wantParam, abilityStartCallback, (err: BusinessError) => { - let msg = `startAbilityByType fail, err: ${JSON.stringify(err)}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); - }); - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .height('100%') - .width('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; +import { common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { promptAction } from '@kit.ArkUI'; + +const TAG: string = '[AbilityStartCallback]'; +const DOMAIN: number = 0xFF00; + +@Entry +@Component +struct AbilityStartCallback { + private promptDuration: number = 2000; + private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.AbilityStartCallback')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: 8, + bottom: 8, + left: 12 + }) + } + } + .width('100%') + .height('14.36%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIAbilityContext_startAbilityByType_onResult')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + + Row() { + Image($r('app.media.ic_arrow')) + .width(24) + .height(24) + .margin({ top: 16, bottom: 16, right: 6 }) + } + } + .id('onResult') + .onClick(() => { + let wantParam: Record = {}; + let abilityStartCallback: common.AbilityStartCallback = { + onError: (code: number, name: string, message: string) => { + let msg = `startAbilityByType onError, code:${code} name:${name} message:${message}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); + }, + onResult: (abilityResult: common.AbilityResult) => { + hilog.info(DOMAIN, TAG, `resultCode:` + abilityResult.resultCode + `bundleName:` + + abilityResult.want?.bundleName); + let msg = `startAbilityByType onResult, + resultCode:${abilityResult.resultCode} bundleName:${abilityResult.want?.bundleName}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); + } + }; + + this.context.startAbilityByType('audioPicker', wantParam, abilityStartCallback, (err: BusinessError) => { + let msg = `startAbilityByType fail, err: ${JSON.stringify(err)}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); + }); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIAbilityContext_startAbilityByType_onError')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('onError') + .onClick(() => { + let wantParam: Record = {}; + let abilityStartCallback: common.AbilityStartCallback = { + onError: (code: number, name: string, message: string) => { + let msg = `startAbilityByType onError, code:${code} name:${name} message:${message}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); + }, + onResult: (abilityResult: common.AbilityResult) => { + hilog.info(DOMAIN, TAG, `resultCode:` + abilityResult.resultCode + `bundleName:` + + abilityResult.want?.bundleName); + let msg = `startAbilityByType onResult, + resultCode:${abilityResult.resultCode} bundleName:${abilityResult.want?.bundleName}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); + } + }; + + this.context.startAbilityByType('error', wantParam, abilityStartCallback, (err: BusinessError) => { + let msg = `startAbilityByType fail, err: ${JSON.stringify(err)}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration, bottom: '11%' }); + }); + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .height('100%') + .width('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContentSession.ets b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContentSession.ets index 0ca668b651..41b4b2edb7 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContentSession.ets +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContentSession.ets @@ -1,114 +1,114 @@ -/* - * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; -import { common, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { promptAction } from '@kit.ArkUI'; - -const TAG: string = '[UIExtensionContentSession]'; -const DOMAIN: number = 0xFF00; - -@Entry -@Component -struct UIExtensionContentSession { - private promptDuration: number = 2000; - private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContentSession')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: 8, - bottom: 8, - left: 12 - }) - } - } - .width('100%') - .height('14.36%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionAbilityContext_requestModalUIExtension')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - - Row() { - Image($r('app.media.ic_arrow')) - .width(24) - .height(24) - .margin({ top: 16, bottom: 16, right: 6 }) - } - } - .id('startUIExtensionAbility') - .onClick(() => { - ((): void => { - let want: Want = { - bundleName: 'com.samples.UIExtension', - moduleName: 'entry', - abilityName: 'SessionUIExtensionAbility', - type: 'sys/commonUI', - parameters: { - bundleName: 'com.samples.UIExtension', - 'ability.want.params.uiExtensionType': 'sys/commonUI', - } - }; - - this.context.requestModalUIExtension(want) - .then(() => { - let msg: string = `requestModalUIExtension succeed.`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration }); - }) - .catch((err: BusinessError) => { - let msg = `requestModalUIExtension failed, code is ${err.code}, message is ${err.message}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration }); - }) - })() - }) - } - .height('8.86%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .height('100%') - .width('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit'; +import { common, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { promptAction } from '@kit.ArkUI'; + +const TAG: string = '[UIExtensionContentSession]'; +const DOMAIN: number = 0xFF00; + +@Entry +@Component +struct UIExtensionContentSession { + private promptDuration: number = 2000; + private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContentSession')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: 8, + bottom: 8, + left: 12 + }) + } + } + .width('100%') + .height('14.36%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionAbilityContext_requestModalUIExtension')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + + Row() { + Image($r('app.media.ic_arrow')) + .width(24) + .height(24) + .margin({ top: 16, bottom: 16, right: 6 }) + } + } + .id('startUIExtensionAbility') + .onClick(() => { + ((): void => { + let want: Want = { + bundleName: 'com.samples.UIExtension', + moduleName: 'entry', + abilityName: 'SessionUIExtensionAbility', + type: 'sys/commonUI', + parameters: { + bundleName: 'com.samples.UIExtension', + 'ability.want.params.uiExtensionType': 'sys/commonUI', + } + }; + + this.context.requestModalUIExtension(want) + .then(() => { + let msg: string = `requestModalUIExtension succeed.`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration }); + }) + .catch((err: BusinessError) => { + let msg = `requestModalUIExtension failed, code is ${err.code}, message is ${err.message}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration }); + }) + })() + }) + } + .height('8.86%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .height('100%') + .width('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContentSessionPage.ets b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContentSessionPage.ets index c7f62ce6bb..2211504a21 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContentSessionPage.ets +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContentSessionPage.ets @@ -1,213 +1,213 @@ -/* - * Copyright (c) 2024 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 { UIExtensionContentSession, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { promptAction } from '@kit.ArkUI'; -import uiExtension from '@ohos.arkui.uiExtension'; - -const TAG: string = 'UIExtensionContentSession'; -const DOMAIN: number = 0xFF00; -let storage: LocalStorage = LocalStorage.getShared(); - -@Entry -@Component -struct UIExtensionContentSessionPage { - private session: (UIExtensionContentSession | undefined) = storage.get('session'); - private want: (Want | undefined) = storage.get('want'); - private promptDuration: number = 2000; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionAbilityContext')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: '12%', - left: '2%' - }) - } - } - .width('100%') - .height('18%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContentSession_terminateSelfWithResultCallback')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - - } - .id('terminateSelfWithResultCallback') - .onClick(() => { - ((): void => { - this.session?.terminateSelfWithResult({ resultCode: 99, want: this.want }, () => { - hilog.info(DOMAIN, TAG, 'UIExtensionContentSession.terminateSelfWithResult(callback) called'); - }) - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContentSession_terminateSelfWithResultPromise')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('terminateSelfWithResultPromise') - .onClick(() => { - ((): void => { - this.session?.terminateSelfWithResult({ resultCode: 100, want: this.want }).then(() => { - hilog.info(DOMAIN, TAG, 'UIExtensionContentSession.terminateSelfWithResult(promise) called'); - }) - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContentSession_setWindowPrivacyModeCallback')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('setWindowPrivacyModeCallback') - .onClick(() => { - ((): void => { - this.session?.setWindowPrivacyMode(true, () => { - let msg = `UIExtensionContentSession.setWindowPrivacyMode(callback) called. isPrivacyMode: true`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration }); - }) - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContentSession_setWindowPrivacyModePromise')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('setWindowPrivacyModePromise') - .onClick(() => { - ((): void => { - this.session?.setWindowPrivacyMode(false).then(() => { - let msg = `UIExtensionContentSession.setWindowPrivacyMode(promise) called. isPrivacyMode: false`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration }); - }) - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContentSession_getUIExtensionWindowProxy')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('getUIExtensionWindowProxy') - .onClick(() => { - ((): void => { - let windowProxy: (uiExtension.WindowProxy | undefined) = this.session?.getUIExtensionWindowProxy(); - let msg = `UIExtensionContentSession.getUIExtensionWindowProxy called. proxy: ${typeof windowProxy}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration }); - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .height('100%') - .width('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2024 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 { UIExtensionContentSession, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { promptAction } from '@kit.ArkUI'; +import uiExtension from '@ohos.arkui.uiExtension'; + +const TAG: string = 'UIExtensionContentSession'; +const DOMAIN: number = 0xFF00; +let storage: LocalStorage = LocalStorage.getShared(); + +@Entry +@Component +struct UIExtensionContentSessionPage { + private session: (UIExtensionContentSession | undefined) = storage.get('session'); + private want: (Want | undefined) = storage.get('want'); + private promptDuration: number = 2000; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionAbilityContext')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: '12%', + left: '2%' + }) + } + } + .width('100%') + .height('18%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContentSession_terminateSelfWithResultCallback')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + + } + .id('terminateSelfWithResultCallback') + .onClick(() => { + ((): void => { + this.session?.terminateSelfWithResult({ resultCode: 99, want: this.want }, () => { + hilog.info(DOMAIN, TAG, 'UIExtensionContentSession.terminateSelfWithResult(callback) called'); + }) + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContentSession_terminateSelfWithResultPromise')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('terminateSelfWithResultPromise') + .onClick(() => { + ((): void => { + this.session?.terminateSelfWithResult({ resultCode: 100, want: this.want }).then(() => { + hilog.info(DOMAIN, TAG, 'UIExtensionContentSession.terminateSelfWithResult(promise) called'); + }) + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContentSession_setWindowPrivacyModeCallback')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('setWindowPrivacyModeCallback') + .onClick(() => { + ((): void => { + this.session?.setWindowPrivacyMode(true, () => { + let msg = `UIExtensionContentSession.setWindowPrivacyMode(callback) called. isPrivacyMode: true`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration }); + }) + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContentSession_setWindowPrivacyModePromise')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('setWindowPrivacyModePromise') + .onClick(() => { + ((): void => { + this.session?.setWindowPrivacyMode(false).then(() => { + let msg = `UIExtensionContentSession.setWindowPrivacyMode(promise) called. isPrivacyMode: false`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration }); + }) + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContentSession_getUIExtensionWindowProxy')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('getUIExtensionWindowProxy') + .onClick(() => { + ((): void => { + let windowProxy: (uiExtension.WindowProxy | undefined) = this.session?.getUIExtensionWindowProxy(); + let msg = `UIExtensionContentSession.getUIExtensionWindowProxy called. proxy: ${typeof windowProxy}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration }); + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .height('100%') + .width('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContext.ets b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContext.ets index 8a52297096..d2eabd2565 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContext.ets +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContext.ets @@ -1,169 +1,169 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import { common, OpenLinkOptions } from '@kit.AbilityKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { promptAction } from '@kit.ArkUI'; - -const TAG: string = '[UIExtensionContext]'; -const DOMAIN: number = 0xFF00; - -@Entry -@Component -struct UIExtensionContext { - private promptDuration: number = 2000; - private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - private uiExtContext = getContext(this) as common.UIExtensionContext; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContext')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: 8, - bottom: 8, - left: 12 - }) - } - } - .width('100%') - .height('14.36%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionAbilityContext_openLink')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - Row() { - Image($r('app.media.ic_arrow')) - .width(24) - .height(24) - .margin({ top: 16, bottom: 16, right: 6 }) - } - } - .id('openLink') - .onClick(() => { - ((): void => { - let link: string = 'http://docs.openharmony.cn'; - let openLinkOptions: OpenLinkOptions = { - appLinkingOnly: false - }; - try { - this.uiExtContext.openLink( - link, - openLinkOptions, - (err, result) => { - hilog.info(DOMAIN, TAG, 'openLink callback result:', JSON.stringify(result.resultCode)); - } - ).then(() => { - hilog.info(DOMAIN, TAG, 'open link success'); - }).catch((err: BusinessError) => { - hilog.info(DOMAIN, TAG, 'open link failed, errCode : %{public}s', JSON.stringify(err.code)); - }); - } catch (e) { - hilog.info(DOMAIN, TAG, 'exception occurred, errCode : %{public}s', JSON.stringify(e.code)); - } - - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionAbilityContext_requestModalUIExtension')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - - Row() { - Image($r('app.media.ic_arrow')) - .width(24) - .height(24) - .margin({ top: 16, bottom: 16, right: 6 }) - } - } - .id('startUIExtensionAbility') - .onClick(() => { - ((): void => { - - let want: Want = { - bundleName: 'com.samples.UIExtension', - moduleName: 'entry', - abilityName: 'ContextUIExtensionAbility', - type: 'sys/commonUI', - parameters: { - bundleName: 'com.samples.UIExtension', - 'ability.want.params.uiExtensionType': 'sys/commonUI', - } - }; - - this.context.requestModalUIExtension(want) - .then(() => { - let msg: string = `requestModalUIExtension succeed.`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration }); - }) - .catch((err: BusinessError) => { - let msg = `requestModalUIExtension failed, code is ${err.code}, message is ${err.message}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration }); - }) - - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import { common, OpenLinkOptions } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { promptAction } from '@kit.ArkUI'; + +const TAG: string = '[UIExtensionContext]'; +const DOMAIN: number = 0xFF00; + +@Entry +@Component +struct UIExtensionContext { + private promptDuration: number = 2000; + private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + private uiExtContext = getContext(this) as common.UIExtensionContext; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContext')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: 8, + bottom: 8, + left: 12 + }) + } + } + .width('100%') + .height('14.36%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionAbilityContext_openLink')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + Row() { + Image($r('app.media.ic_arrow')) + .width(24) + .height(24) + .margin({ top: 16, bottom: 16, right: 6 }) + } + } + .id('openLink') + .onClick(() => { + ((): void => { + let link: string = 'http://docs.openharmony.cn'; + let openLinkOptions: OpenLinkOptions = { + appLinkingOnly: false + }; + try { + this.uiExtContext.openLink( + link, + openLinkOptions, + (err, result) => { + hilog.info(DOMAIN, TAG, 'openLink callback result:', JSON.stringify(result.resultCode)); + } + ).then(() => { + hilog.info(DOMAIN, TAG, 'open link success'); + }).catch((err: BusinessError) => { + hilog.info(DOMAIN, TAG, 'open link failed, errCode : %{public}s', JSON.stringify(err.code)); + }); + } catch (e) { + hilog.info(DOMAIN, TAG, 'exception occurred, errCode : %{public}s', JSON.stringify(e.code)); + } + + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionAbilityContext_requestModalUIExtension')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + + Row() { + Image($r('app.media.ic_arrow')) + .width(24) + .height(24) + .margin({ top: 16, bottom: 16, right: 6 }) + } + } + .id('startUIExtensionAbility') + .onClick(() => { + ((): void => { + + let want: Want = { + bundleName: 'com.samples.UIExtension', + moduleName: 'entry', + abilityName: 'ContextUIExtensionAbility', + type: 'sys/commonUI', + parameters: { + bundleName: 'com.samples.UIExtension', + 'ability.want.params.uiExtensionType': 'sys/commonUI', + } + }; + + this.context.requestModalUIExtension(want) + .then(() => { + let msg: string = `requestModalUIExtension succeed.`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration }); + }) + .catch((err: BusinessError) => { + let msg = `requestModalUIExtension failed, code is ${err.code}, message is ${err.message}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration }); + }) + + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContextPage.ets b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContextPage.ets index 08aaa5a8f1..6f01a2ee00 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContextPage.ets +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/ets/uiextensionpages/UIExtensionContextPage.ets @@ -1,222 +1,222 @@ -/* - * Copyright (c) 2024 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 { common, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { promptAction } from '@kit.ArkUI'; - -const TAG: string = 'UIExtensionContent'; -const DOMAIN: number = 0xFF00; -let storage: LocalStorage = LocalStorage.getShared(); - -@Entry -@Component -struct UIExtensionContextPage { - private context = getContext(this) as common.UIExtensionContext; - private want: (Want | undefined) = storage.get('want'); - private promptDuration: number = 2000; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionAbilityContext')) - .fontSize(30) - .fontWeight(700) - .textAlign(TextAlign.Start) - .margin({ - top: '12%', - left: '2%' - }) - } - } - .width('100%') - .height('18%') - .justifyContent(FlexAlign.Start) - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContent_reportDrawnCompleted')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('reportDrawnCompleted') - .onClick(() => { - ((): void => { - try { - this.context.reportDrawnCompleted((err) => { - if (err.code) { - // 处理业务逻辑错误 - let msg = - `UIExtensionContent.reportDrawnCompleted failed, code is ${err.code}, message is ${err.message}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration }); - return; - } - // 执行正常业务 - let msg = `UIExtensionContent.reportDrawnCompleted succeed.`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration }); - }); - } catch (err) { - // 捕获同步的参数错误 - let msg = `UIExtensionContent.reportDrawnCompleted failed,err is ${JSON.stringify(err)}`; - hilog.info(DOMAIN, TAG, msg); - promptAction.showToast({ message: msg, duration: this.promptDuration }); - } - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContent_terminateSelfCallback')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('terminateSelfCallback') - .onClick(() => { - ((): void => { - this.context?.terminateSelf(() => { - hilog.info(DOMAIN, TAG, 'UIExtensionContent_terminateSelfCallback(callback) called'); - }) - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContent_terminateSelfPromise')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('terminateSelfPromise') - .onClick(() => { - ((): void => { - this.context?.terminateSelf().then(() => { - hilog.info(DOMAIN, TAG, 'UIExtensionContent_terminateSelfPromise(promise) called'); - }) - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContent_terminateSelfWithResultCallback')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('terminateSelfWithResultCallback') - .onClick(() => { - ((): void => { - this.context?.terminateSelfWithResult({ resultCode: 99, want: this.want }, () => { - hilog.info(DOMAIN, TAG, 'UIExtensionContent_terminateSelfWithResultCallback(callback) called'); - }) - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - ListItem() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { - Text($r('app.string.UIExtensionContent_terminateSelfWithResultPromise')) - .textAlign(TextAlign.Start) - .fontWeight(500) - .margin({ - top: 17, - bottom: 17, - left: 12 - }) - .fontSize(16) - .width('77.87%') - .height('39.29%') - .fontColor($r('app.color.text_color')) - } - .id('terminateSelfWithResultPromise') - .onClick(() => { - ((): void => { - this.context?.terminateSelfWithResult({ resultCode: 100, want: this.want }).then(() => { - hilog.info(DOMAIN, TAG, 'UIExtensionContent.terminateSelfWithResult(promise) called'); - }) - })() - }) - } - .height('8.45%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(24) - .margin({ top: 12, right: 12, left: 12 }) - - } - .height('86%') - .backgroundColor($r('app.color.backGrounding')) - } - .height('100%') - .width('100%') - .backgroundColor($r('app.color.backGrounding')) - } +/* + * Copyright (c) 2024 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 { common, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { promptAction } from '@kit.ArkUI'; + +const TAG: string = 'UIExtensionContent'; +const DOMAIN: number = 0xFF00; +let storage: LocalStorage = LocalStorage.getShared(); + +@Entry +@Component +struct UIExtensionContextPage { + private context = getContext(this) as common.UIExtensionContext; + private want: (Want | undefined) = storage.get('want'); + private promptDuration: number = 2000; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionAbilityContext')) + .fontSize(30) + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin({ + top: '12%', + left: '2%' + }) + } + } + .width('100%') + .height('18%') + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContent_reportDrawnCompleted')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('reportDrawnCompleted') + .onClick(() => { + ((): void => { + try { + this.context.reportDrawnCompleted((err) => { + if (err.code) { + // 处理业务逻辑错误 + let msg = + `UIExtensionContent.reportDrawnCompleted failed, code is ${err.code}, message is ${err.message}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration }); + return; + } + // 执行正常业务 + let msg = `UIExtensionContent.reportDrawnCompleted succeed.`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration }); + }); + } catch (err) { + // 捕获同步的参数错误 + let msg = `UIExtensionContent.reportDrawnCompleted failed,err is ${JSON.stringify(err)}`; + hilog.info(DOMAIN, TAG, msg); + promptAction.showToast({ message: msg, duration: this.promptDuration }); + } + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContent_terminateSelfCallback')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('terminateSelfCallback') + .onClick(() => { + ((): void => { + this.context?.terminateSelf(() => { + hilog.info(DOMAIN, TAG, 'UIExtensionContent_terminateSelfCallback(callback) called'); + }) + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContent_terminateSelfPromise')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('terminateSelfPromise') + .onClick(() => { + ((): void => { + this.context?.terminateSelf().then(() => { + hilog.info(DOMAIN, TAG, 'UIExtensionContent_terminateSelfPromise(promise) called'); + }) + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContent_terminateSelfWithResultCallback')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('terminateSelfWithResultCallback') + .onClick(() => { + ((): void => { + this.context?.terminateSelfWithResult({ resultCode: 99, want: this.want }, () => { + hilog.info(DOMAIN, TAG, 'UIExtensionContent_terminateSelfWithResultCallback(callback) called'); + }) + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) { + Text($r('app.string.UIExtensionContent_terminateSelfWithResultPromise')) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ + top: 17, + bottom: 17, + left: 12 + }) + .fontSize(16) + .width('77.87%') + .height('39.29%') + .fontColor($r('app.color.text_color')) + } + .id('terminateSelfWithResultPromise') + .onClick(() => { + ((): void => { + this.context?.terminateSelfWithResult({ resultCode: 100, want: this.want }).then(() => { + hilog.info(DOMAIN, TAG, 'UIExtensionContent.terminateSelfWithResult(promise) called'); + }) + })() + }) + } + .height('8.45%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(24) + .margin({ top: 12, right: 12, left: 12 }) + + } + .height('86%') + .backgroundColor($r('app.color.backGrounding')) + } + .height('100%') + .width('100%') + .backgroundColor($r('app.color.backGrounding')) + } } \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/module.json5 b/code/SystemFeature/UIExtensionSamples/entry/src/main/module.json5 index 50d3cb2061..7484f69d52 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/module.json5 +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/module.json5 @@ -1,105 +1,105 @@ -/* - * Copyright (c) 2024 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:startIcon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - }, - { - "name": "OpenLinkUIAbility", - "srcEntry": "./ets/entryability/OpenLinkUIAbility.ets", - "description": "uri", - "icon": "$media:layered_image", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:startIcon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "entities": [ - "entity.system.home", - "entity.system.browsable" - ], - "actions": [ - "action.system.home", - "ohos.want.action.viewData" - ], - "uris": [ - { - // scheme可以自定义 - "scheme": "http", - // host须配置关联的域名 - "host": "docs.openharmony.cn", - // path可选,为了避免匹配到多个应用,建议配置该字段 - "path": "" - } - ] - } - ] - } - ], - "extensionAbilities": [ - { - "name": "SessionUIExtensionAbility", - "srcEntry": "./ets/uiextensionentry/SessionUIExtensionAbility.ets", - "type": "sys/commonUI", - "exported": true - }, - { - "name": "ContextUIExtensionAbility", - "srcEntry": "./ets/uiextensionentry/ContextUIExtensionAbility.ets", - "type": "sys/commonUI", - "exported": true, - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.PRIVACY_WINDOW" - }, - { - "name": "ohos.permission.START_INVISIBLE_ABILITY" - } - ] - } +/* + * Copyright (c) 2024 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:startIcon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "OpenLinkUIAbility", + "srcEntry": "./ets/entryability/OpenLinkUIAbility.ets", + "description": "uri", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "entities": [ + "entity.system.home", + "entity.system.browsable" + ], + "actions": [ + "action.system.home", + "ohos.want.action.viewData" + ], + "uris": [ + { + // scheme可以自定义 + "scheme": "http", + // host须配置关联的域名 + "host": "docs.openharmony.cn", + // path可选,为了避免匹配到多个应用,建议配置该字段 + "path": "" + } + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "SessionUIExtensionAbility", + "srcEntry": "./ets/uiextensionentry/SessionUIExtensionAbility.ets", + "type": "sys/commonUI", + "exported": true + }, + { + "name": "ContextUIExtensionAbility", + "srcEntry": "./ets/uiextensionentry/ContextUIExtensionAbility.ets", + "type": "sys/commonUI", + "exported": true, + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.PRIVACY_WINDOW" + }, + { + "name": "ohos.permission.START_INVISIBLE_ABILITY" + } + ] + } } \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/resources/base/element/color.json b/code/SystemFeature/UIExtensionSamples/entry/src/main/resources/base/element/color.json index 73d32c4c75..6cdb3e3002 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/resources/base/element/color.json +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/resources/base/element/color.json @@ -1,16 +1,16 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, - { - "name": "backGrounding", - "value": "#f1f3f5" - }, - { - "name": "text_color", - "value": "#182431" - } - ] +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "backGrounding", + "value": "#f1f3f5" + }, + { + "name": "text_color", + "value": "#182431" + } + ] } \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/main/resources/base/profile/backup_config.json b/code/SystemFeature/UIExtensionSamples/entry/src/main/resources/base/profile/backup_config.json index d742c2f96e..78f40ae7c4 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/main/resources/base/profile/backup_config.json +++ b/code/SystemFeature/UIExtensionSamples/entry/src/main/resources/base/profile/backup_config.json @@ -1,3 +1,3 @@ -{ - "allowToBackupRestore": true +{ + "allowToBackupRestore": true } \ No newline at end of file diff --git a/code/SystemFeature/UIExtensionSamples/entry/src/ohosTest/module.json5 b/code/SystemFeature/UIExtensionSamples/entry/src/ohosTest/module.json5 index 20226beba8..944ed99859 100644 --- a/code/SystemFeature/UIExtensionSamples/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/UIExtensionSamples/entry/src/ohosTest/module.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/SystemFeature/UIExtensionSamples/hvigor/hvigor-config.json5 b/code/SystemFeature/UIExtensionSamples/hvigor/hvigor-config.json5 index e0bd0d8269..06b2783670 100644 --- a/code/SystemFeature/UIExtensionSamples/hvigor/hvigor-config.json5 +++ b/code/SystemFeature/UIExtensionSamples/hvigor/hvigor-config.json5 @@ -1,22 +1,22 @@ -{ - "modelVersion": "5.0.0", - "dependencies": { - }, - "execution": { - // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ - // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ - // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ - // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ - // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ - }, - "logging": { - // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ - }, - "debugging": { - // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ - }, - "nodeOptions": { - // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ - // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ - } -} +{ + "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/SystemFeature/UIExtensionSamples/oh-package.json5 b/code/SystemFeature/UIExtensionSamples/oh-package.json5 index 11d5feca88..ebdda7e54d 100644 --- a/code/SystemFeature/UIExtensionSamples/oh-package.json5 +++ b/code/SystemFeature/UIExtensionSamples/oh-package.json5 @@ -1,10 +1,10 @@ -{ - "modelVersion": "5.0.0", - "description": "Please describe the basic information.", - "dependencies": { - }, - "devDependencies": { - "@ohos/hypium": "1.0.18", - "@ohos/hamock": "1.0.0" - } -} +{ + "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/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/layoutAnimationSample/LayoutAnimationSample.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/layoutAnimationSample/LayoutAnimationSample.ets index 093f2ceddb..695d8e7597 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/layoutAnimationSample/LayoutAnimationSample.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/layoutAnimationSample/LayoutAnimationSample.ets @@ -1,202 +1,202 @@ -/* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 { TitleBar } from '../../../../common/TitleBar' -import { IntroductionTitle } from '../../../../common/IntroductionTitle' - -@Extend(Column) function columnStyle() { - .height(150) - .width('100%') - .padding(12) - .borderRadius(24) - .backgroundColor(Color.White) - .margin({ bottom: 12 }) -} - -@Extend(Text) function textStyle() { - .fontColor(Color.White) - .size({ width: 100, height: 100 }) - .margin(5) -} - -@Entry -@Component -struct LayoutAnimationSample { - @State mPadding: number = 5; - @State mMargin: number = 5; - @State mSize: number = 100; - @State mPositionX: number = 10; - @State mPositionY: number = 0; - @State mAlignment: Alignment = Alignment.Center; - @State mDirection: Direction = Direction.Rtl; - @State mColor: Color = Color.Pink; - @State mHorizontalAlign: HorizontalAlign = HorizontalAlign.Start; - intervalID: number | null = null; - - onPageShow() { - this.intervalID = setInterval(() => { - animateTo({ duration: 2000 }, () => { - this.mColor = this.mColor == Color.Pink ? Color.Orange : Color.Pink - this.mPadding = this.mPadding == 5 ? 20 : 5 - this.mMargin = this.mMargin == 5 ? 20 : 5 - this.mSize = this.mSize == 50 ? 100 : 50 - this.mPositionX = this.mPositionX == 10 ? 50 : 10 - this.mAlignment = this.mAlignment == Alignment.Center ? Alignment.TopStart : Alignment.Center - this.mDirection = this.mDirection == Direction.Rtl ? Direction.Ltr : Direction.Rtl - this.mHorizontalAlign = this.mHorizontalAlign == HorizontalAlign.Start ? HorizontalAlign.Center : HorizontalAlign.Start - }) - - }, 3000); - } - - onPageHide() { - clearInterval(this.intervalID) - } - - build() { - Column() { - TitleBar({ title: $r('app.string.layout_animation_expansion') }) - Scroll() { - Column() { - IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_align') }) - Column() { - Text($r('app.string.layout_animation_expansion_align')) - .textStyle() - .backgroundColor(this.mColor) - .align(this.mAlignment) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_size') }) - Column() { - Text() - .textStyle() - .size({ width: this.mSize, height: this.mSize }) - .backgroundColor(this.mColor) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_padding') }) - Column() { - Column() { - Text() - .size({ width: '100%', height: '100%' }) - .backgroundColor($r('app.color.white')) - } - .size({ width: 100, height: 100 }) - .margin(5) - .padding(this.mPadding) - .backgroundColor(this.mColor) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_margin') }) - Column() { - Row() { - ForEach(['1', '2', '3'], (item: string) => { - Text(item) - .textStyle() - .margin(this.mMargin) - .backgroundColor(this.mColor) - }) - } - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_direction') }) - Column() { - Row() { - ForEach(['1', '2', '3'], (item: string) => { - Text(item) - .textStyle() - .backgroundColor(this.mColor) - }) - } - .direction(this.mDirection) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_offset') }) - Column() { - Text() - .textStyle() - .offset({ - x: this.mPositionX, - y: this.mPositionY - }) - .backgroundColor(this.mColor) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_position') }) - Column() { - Text() - .textStyle() - .position({ - x: this.mPositionX, - y: this.mPositionY - }) - .backgroundColor(this.mColor) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_markAnchor') }) - Column() { - Text() - .textStyle() - .markAnchor({ - x: this.mPositionX, - y: this.mPositionY - }) - .backgroundColor(this.mColor) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_alignRules') }) - Column() { - RelativeContainer() { - Text() - .size({ width: 100, height: 100 }) - .alignRules({ - top: { - anchor: "__container__", - align: VerticalAlign.Top - }, - left: { - anchor: "__container__", - align: this.mHorizontalAlign - } - }) - .id('text1') - .backgroundColor(this.mColor) - } - .margin({ top: 10 }) - .size({ width: 300, height: 100 }) - .border({ width: 2, color: $r('app.color.radio_response_region_color') }) - } - .columnStyle() - - .margin({ bottom: 80 }) - } - .padding({ left: 12, right: 12 }) - .constraintSize({ minHeight: '100%' }) - - } - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.background_shallow_grey')) - } +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 { TitleBar } from '../../../../common/TitleBar' +import { IntroductionTitle } from '../../../../common/IntroductionTitle' + +@Extend(Column) function columnStyle() { + .height(150) + .width('100%') + .padding(12) + .borderRadius(24) + .backgroundColor(Color.White) + .margin({ bottom: 12 }) +} + +@Extend(Text) function textStyle() { + .fontColor(Color.White) + .size({ width: 100, height: 100 }) + .margin(5) +} + +@Entry +@Component +struct LayoutAnimationSample { + @State mPadding: number = 5; + @State mMargin: number = 5; + @State mSize: number = 100; + @State mPositionX: number = 10; + @State mPositionY: number = 0; + @State mAlignment: Alignment = Alignment.Center; + @State mDirection: Direction = Direction.Rtl; + @State mColor: Color = Color.Pink; + @State mHorizontalAlign: HorizontalAlign = HorizontalAlign.Start; + intervalID: number | null = null; + + onPageShow() { + this.intervalID = setInterval(() => { + animateTo({ duration: 2000 }, () => { + this.mColor = this.mColor == Color.Pink ? Color.Orange : Color.Pink + this.mPadding = this.mPadding == 5 ? 20 : 5 + this.mMargin = this.mMargin == 5 ? 20 : 5 + this.mSize = this.mSize == 50 ? 100 : 50 + this.mPositionX = this.mPositionX == 10 ? 50 : 10 + this.mAlignment = this.mAlignment == Alignment.Center ? Alignment.TopStart : Alignment.Center + this.mDirection = this.mDirection == Direction.Rtl ? Direction.Ltr : Direction.Rtl + this.mHorizontalAlign = this.mHorizontalAlign == HorizontalAlign.Start ? HorizontalAlign.Center : HorizontalAlign.Start + }) + + }, 3000); + } + + onPageHide() { + clearInterval(this.intervalID) + } + + build() { + Column() { + TitleBar({ title: $r('app.string.layout_animation_expansion') }) + Scroll() { + Column() { + IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_align') }) + Column() { + Text($r('app.string.layout_animation_expansion_align')) + .textStyle() + .backgroundColor(this.mColor) + .align(this.mAlignment) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_size') }) + Column() { + Text() + .textStyle() + .size({ width: this.mSize, height: this.mSize }) + .backgroundColor(this.mColor) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_padding') }) + Column() { + Column() { + Text() + .size({ width: '100%', height: '100%' }) + .backgroundColor($r('app.color.white')) + } + .size({ width: 100, height: 100 }) + .margin(5) + .padding(this.mPadding) + .backgroundColor(this.mColor) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_margin') }) + Column() { + Row() { + ForEach(['1', '2', '3'], (item: string) => { + Text(item) + .textStyle() + .margin(this.mMargin) + .backgroundColor(this.mColor) + }) + } + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_direction') }) + Column() { + Row() { + ForEach(['1', '2', '3'], (item: string) => { + Text(item) + .textStyle() + .backgroundColor(this.mColor) + }) + } + .direction(this.mDirection) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_offset') }) + Column() { + Text() + .textStyle() + .offset({ + x: this.mPositionX, + y: this.mPositionY + }) + .backgroundColor(this.mColor) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_position') }) + Column() { + Text() + .textStyle() + .position({ + x: this.mPositionX, + y: this.mPositionY + }) + .backgroundColor(this.mColor) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_markAnchor') }) + Column() { + Text() + .textStyle() + .markAnchor({ + x: this.mPositionX, + y: this.mPositionY + }) + .backgroundColor(this.mColor) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.layout_animation_expansion_alignRules') }) + Column() { + RelativeContainer() { + Text() + .size({ width: 100, height: 100 }) + .alignRules({ + top: { + anchor: "__container__", + align: VerticalAlign.Top + }, + left: { + anchor: "__container__", + align: this.mHorizontalAlign + } + }) + .id('text1') + .backgroundColor(this.mColor) + } + .margin({ top: 10 }) + .size({ width: 300, height: 100 }) + .border({ width: 2, color: $r('app.color.radio_response_region_color') }) + } + .columnStyle() + + .margin({ bottom: 80 }) + } + .padding({ left: 12, right: 12 }) + .constraintSize({ minHeight: '100%' }) + + } + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.background_shallow_grey')) + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/sideBarTransitionSample/SideBarTransitionSample.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/sideBarTransitionSample/SideBarTransitionSample.ets index 3365d4341e..a0af4fd590 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/sideBarTransitionSample/SideBarTransitionSample.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/sideBarTransitionSample/SideBarTransitionSample.ets @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2023 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 { ChangePanel } from './ChangePanel' -import { TitleBar } from '../../../../common/TitleBar' - -@Extend(Column) function columnStyle() { - .padding(16) - .borderRadius(24) - .backgroundColor(Color.White) - .margin({ top: 20, left: 20, right: 20, bottom: 20 }) -} - -@Entry -@Component -struct SideBarTransitionSample { - @State arr: number[] = [1, 2, 3] - @State current: number = 1 - @State mShowSideBar: boolean = false - @State mSideBarContainerType: SideBarContainerType = SideBarContainerType.Embed - - build() { - Column() { - TitleBar({ title: $r('app.string.side_bar_effects_title') }) - SideBarContainer(this.mSideBarContainerType) { - Column() { - ForEach(this.arr, (item: number, index: number) => { - Column({ space: 5 }) { - Image($r('app.media.icon')).width(64).height(64) - Text(item + '') - .fontSize(25) - .fontColor(this.current === item ? $r('app.color.tab_bar_select') : $r('app.color.tab_bar_unselect')) - } - .onClick(() => { - this.current = item - }) - }, (item: number) => item.toString()) - } - .visibility(this.mShowSideBar ? Visibility.Visible : Visibility.Hidden) - .width('100%') - .transition(TransitionEffect.opacity(0)) - .justifyContent(FlexAlign.SpaceEvenly) - .backgroundColor($r('app.color.contentArea_background_color')) - - Column() { - Column() { - Button(this.mShowSideBar ? $r('app.string.hide_side_bar') : $r('app.string.show_side_bar')) - .onClick(() => { - animateTo({ duration: 2000 }, () => { - this.mShowSideBar = !this.mShowSideBar - }) - }) - .id('hide_or_show_sideBar') - .margin({ bottom: 5 }) - ChangePanel({ - mSideBarContainerType: $mSideBarContainerType - }) - } - .columnStyle() - } - } - .showControlButton(false) - .showSideBar(this.mShowSideBar) - .sideBarWidth(150) - .minSideBarWidth(50) - .maxSideBarWidth(300) - } - .size({ width: '100%', height: '100%' }) - .justifyContent(FlexAlign.Center) - .backgroundColor($r('app.color.background_shallow_grey')) - } -} +/* + * Copyright (c) 2023 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 { ChangePanel } from './ChangePanel' +import { TitleBar } from '../../../../common/TitleBar' + +@Extend(Column) function columnStyle() { + .padding(16) + .borderRadius(24) + .backgroundColor(Color.White) + .margin({ top: 20, left: 20, right: 20, bottom: 20 }) +} + +@Entry +@Component +struct SideBarTransitionSample { + @State arr: number[] = [1, 2, 3] + @State current: number = 1 + @State mShowSideBar: boolean = false + @State mSideBarContainerType: SideBarContainerType = SideBarContainerType.Embed + + build() { + Column() { + TitleBar({ title: $r('app.string.side_bar_effects_title') }) + SideBarContainer(this.mSideBarContainerType) { + Column() { + ForEach(this.arr, (item: number, index: number) => { + Column({ space: 5 }) { + Image($r('app.media.icon')).width(64).height(64) + Text(item + '') + .fontSize(25) + .fontColor(this.current === item ? $r('app.color.tab_bar_select') : $r('app.color.tab_bar_unselect')) + } + .onClick(() => { + this.current = item + }) + }, (item: number) => item.toString()) + } + .visibility(this.mShowSideBar ? Visibility.Visible : Visibility.Hidden) + .width('100%') + .transition(TransitionEffect.opacity(0)) + .justifyContent(FlexAlign.SpaceEvenly) + .backgroundColor($r('app.color.contentArea_background_color')) + + Column() { + Column() { + Button(this.mShowSideBar ? $r('app.string.hide_side_bar') : $r('app.string.show_side_bar')) + .onClick(() => { + animateTo({ duration: 2000 }, () => { + this.mShowSideBar = !this.mShowSideBar + }) + }) + .id('hide_or_show_sideBar') + .margin({ bottom: 5 }) + ChangePanel({ + mSideBarContainerType: $mSideBarContainerType + }) + } + .columnStyle() + } + } + .showControlButton(false) + .showSideBar(this.mShowSideBar) + .sideBarWidth(150) + .minSideBarWidth(50) + .maxSideBarWidth(300) + } + .size({ width: '100%', height: '100%' }) + .justifyContent(FlexAlign.Center) + .backgroundColor($r('app.color.background_shallow_grey')) + } +} diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/sizeTransitionSample/SizeTransitionSample.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/sizeTransitionSample/SizeTransitionSample.ets index 9f8955da76..7dfcb409a1 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/sizeTransitionSample/SizeTransitionSample.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/animations/TransitionAnimations/sizeTransitionSample/SizeTransitionSample.ets @@ -1,193 +1,193 @@ -/* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 { getStringData } from '../../../../data/ResourceDataHandle' -import { TitleBar } from '../../../../common/TitleBar' -import { IntroductionTitle } from '../../../../common/IntroductionTitle' - -@Extend(Column) function columnStyle() { - .height(150) - .width('100%') - .padding(12) - .borderRadius(24) - .backgroundColor(Color.White) - .margin({ bottom: 12 }) -} - -@AnimatableExtend(Text) function animatableFontSize(size: number) { - .fontSize(size) -} - -@Entry -@Component -struct SizeTransitionSample { - @State mWidth: number = 400 - @State mTabIndex: number = 0 - @State mVisible: Visibility = Visibility.Visible - @State mFontSize: number = 20 - private intervalID = 0 - - @Builder tabbarTitle(name: Resource, index: number) { - Stack() { - Text(name) - .fontSize(22) - .fontColor(this.mTabIndex === index ? $r('app.color.title_colorone') : $r('app.color.title_colortwo')) - - if (this.mTabIndex === index) { - Row() - .backgroundColor($r('app.color.title_colorone')) - .width(200) - .height(2) - .position({ y: 48 }) - } - }.width(200) - .height(56) - } - - onPageShow() { - this.intervalID = setInterval(() => { - animateTo({ duration: 2000 }, () => { - this.mWidth = (this.mWidth == 400 || this.mVisible == Visibility.Hidden) ? 200 : 400 - if (this.mVisible == Visibility.Visible) { - this.mFontSize = this.mFontSize == 20 ? 40 : 20 - } - }) - setTimeout(() => { - animateTo({ duration: 2000 }, () => { - if (this.mWidth == 200 && this.mVisible == Visibility.Visible) { - this.mVisible = Visibility.Hidden - } - else if (this.mVisible == Visibility.Hidden) { - this.mVisible = Visibility.Visible - } - }) - }, 2000); - }, 4000); - } - - onPageHide() { - clearInterval(this.intervalID) - } - - build() { - Column() { - TitleBar({ title: $r('app.string.size_transition_expansion') }) - Scroll() { - Column() { - IntroductionTitle({ introduction: $r('app.string.size_transition_flex') }) - Column() { - Flex() { - Text($r('app.string.size_transition_flex')) - } - .visibility(this.mVisible) - .width(this.mWidth) - .backgroundColor($r('app.color.radio_response_region_color')) - .height(100) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.size_transition_grid_item') }) - Column() { - Grid() { - ForEach([1, 2, 3], (item: number) => { - GridItem() { - Text(getStringData($r('app.string.size_transition_grid_item')) + item) - }.margin(5).width(100) - }) - } - .visibility(this.mVisible) - .margin(5) - .width(this.mWidth) - .backgroundColor($r('app.color.radio_response_region_color')) - .height(100) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.size_transition_list_item') }) - Column() { - List() { - ForEach([1, 2, 3, 4], (item: number) => { - ListItem() { - Text(getStringData($r('app.string.size_transition_list_item')) + item) - }.margin(5).width(100) - }) - } - .visibility(this.mVisible) - .listDirection(Axis.Horizontal) - .margin(5) - .width(this.mWidth) - .backgroundColor($r('app.color.radio_response_region_color')) - .height(100) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.size_transition_swiper_item') }) - Column() { - Swiper() { - ForEach([1, 2, 3, 4], (item: number) => { - Text(getStringData($r('app.string.size_transition_swiper_item')) + item) - }) - } - .visibility(this.mVisible) - .margin(5) - .width(this.mWidth) - .backgroundColor($r('app.color.radio_response_region_color')) - .height(100) - } - .columnStyle() - - IntroductionTitle({ introduction: ($r('app.string.size_transition_expansion_tabContent')) }) - Column() { - Tabs() { - ForEach([0, 1, 2], (item: number) => { - TabContent() { - Text(getStringData($r('app.string.size_transition_expansion_tabContent')) + item) - } - .backgroundColor($r('app.color.select_option_bg_color')) - .tabBar(this.tabbarTitle($r('app.string.size_transition_expansion_tabContent'), item)) - }) - } - .visibility(this.mVisible) - .margin(5) - .width(this.mWidth) - .backgroundColor($r('app.color.radio_response_region_color')) - .height(100) - .onChange((index) => { - this.mTabIndex = index - }) - } - .columnStyle() - - IntroductionTitle({ introduction: $r('app.string.size_transition_font_size') }) - Column() { - Text(getStringData($r('app.string.size_transition_font_size')) + ': ' + this.mFontSize) - .margin(5) - .visibility(this.mVisible) - .animatableFontSize(this.mFontSize) - .backgroundColor($r('app.color.radio_response_region_color')) - .height(100) - .width(200) - } - .columnStyle() - .margin({ bottom: 80 }) - } - .constraintSize({ minWidth: '100%' }) - } - } - .width('100%') - .height('100%') - .backgroundColor($r('app.color.background_shallow_grey')) - } +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 { getStringData } from '../../../../data/ResourceDataHandle' +import { TitleBar } from '../../../../common/TitleBar' +import { IntroductionTitle } from '../../../../common/IntroductionTitle' + +@Extend(Column) function columnStyle() { + .height(150) + .width('100%') + .padding(12) + .borderRadius(24) + .backgroundColor(Color.White) + .margin({ bottom: 12 }) +} + +@AnimatableExtend(Text) function animatableFontSize(size: number) { + .fontSize(size) +} + +@Entry +@Component +struct SizeTransitionSample { + @State mWidth: number = 400 + @State mTabIndex: number = 0 + @State mVisible: Visibility = Visibility.Visible + @State mFontSize: number = 20 + private intervalID = 0 + + @Builder tabbarTitle(name: Resource, index: number) { + Stack() { + Text(name) + .fontSize(22) + .fontColor(this.mTabIndex === index ? $r('app.color.title_colorone') : $r('app.color.title_colortwo')) + + if (this.mTabIndex === index) { + Row() + .backgroundColor($r('app.color.title_colorone')) + .width(200) + .height(2) + .position({ y: 48 }) + } + }.width(200) + .height(56) + } + + onPageShow() { + this.intervalID = setInterval(() => { + animateTo({ duration: 2000 }, () => { + this.mWidth = (this.mWidth == 400 || this.mVisible == Visibility.Hidden) ? 200 : 400 + if (this.mVisible == Visibility.Visible) { + this.mFontSize = this.mFontSize == 20 ? 40 : 20 + } + }) + setTimeout(() => { + animateTo({ duration: 2000 }, () => { + if (this.mWidth == 200 && this.mVisible == Visibility.Visible) { + this.mVisible = Visibility.Hidden + } + else if (this.mVisible == Visibility.Hidden) { + this.mVisible = Visibility.Visible + } + }) + }, 2000); + }, 4000); + } + + onPageHide() { + clearInterval(this.intervalID) + } + + build() { + Column() { + TitleBar({ title: $r('app.string.size_transition_expansion') }) + Scroll() { + Column() { + IntroductionTitle({ introduction: $r('app.string.size_transition_flex') }) + Column() { + Flex() { + Text($r('app.string.size_transition_flex')) + } + .visibility(this.mVisible) + .width(this.mWidth) + .backgroundColor($r('app.color.radio_response_region_color')) + .height(100) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.size_transition_grid_item') }) + Column() { + Grid() { + ForEach([1, 2, 3], (item: number) => { + GridItem() { + Text(getStringData($r('app.string.size_transition_grid_item')) + item) + }.margin(5).width(100) + }) + } + .visibility(this.mVisible) + .margin(5) + .width(this.mWidth) + .backgroundColor($r('app.color.radio_response_region_color')) + .height(100) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.size_transition_list_item') }) + Column() { + List() { + ForEach([1, 2, 3, 4], (item: number) => { + ListItem() { + Text(getStringData($r('app.string.size_transition_list_item')) + item) + }.margin(5).width(100) + }) + } + .visibility(this.mVisible) + .listDirection(Axis.Horizontal) + .margin(5) + .width(this.mWidth) + .backgroundColor($r('app.color.radio_response_region_color')) + .height(100) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.size_transition_swiper_item') }) + Column() { + Swiper() { + ForEach([1, 2, 3, 4], (item: number) => { + Text(getStringData($r('app.string.size_transition_swiper_item')) + item) + }) + } + .visibility(this.mVisible) + .margin(5) + .width(this.mWidth) + .backgroundColor($r('app.color.radio_response_region_color')) + .height(100) + } + .columnStyle() + + IntroductionTitle({ introduction: ($r('app.string.size_transition_expansion_tabContent')) }) + Column() { + Tabs() { + ForEach([0, 1, 2], (item: number) => { + TabContent() { + Text(getStringData($r('app.string.size_transition_expansion_tabContent')) + item) + } + .backgroundColor($r('app.color.select_option_bg_color')) + .tabBar(this.tabbarTitle($r('app.string.size_transition_expansion_tabContent'), item)) + }) + } + .visibility(this.mVisible) + .margin(5) + .width(this.mWidth) + .backgroundColor($r('app.color.radio_response_region_color')) + .height(100) + .onChange((index) => { + this.mTabIndex = index + }) + } + .columnStyle() + + IntroductionTitle({ introduction: $r('app.string.size_transition_font_size') }) + Column() { + Text(getStringData($r('app.string.size_transition_font_size')) + ': ' + this.mFontSize) + .margin(5) + .visibility(this.mVisible) + .animatableFontSize(this.mFontSize) + .backgroundColor($r('app.color.radio_response_region_color')) + .height(100) + .width(200) + } + .columnStyle() + .margin({ bottom: 80 }) + } + .constraintSize({ minWidth: '100%' }) + } + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.background_shallow_grey')) + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/informationPresentationAndDynamicEffects/listSample/ListSample.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/informationPresentationAndDynamicEffects/listSample/ListSample.ets old mode 100755 new mode 100644 index 59709cdf4a..4901d4fb33 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/informationPresentationAndDynamicEffects/listSample/ListSample.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/informationPresentationAndDynamicEffects/listSample/ListSample.ets @@ -1,86 +1,86 @@ -/* - * Copyright (c) 2023 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 { TitleBar } from '../../../../common/TitleBar' - -@Extend(Text) function leftTitleStyle() { - .fontColor($r('app.color.font_color_shallow')) - .fontSize(18) - .height(22) - .alignSelf(ItemAlign.Start) - .margin({ left: 12, bottom: 8 }) -} - -@Extend(Column) function cardStyle() { - .backgroundColor(Color.White) - .borderRadius(24) - .width('100%') - .padding(12) - .margin({ bottom: 12 }) -} - -@Entry -@Component -struct ListSample { - @State arr: number[] = [0, 1, 2, 3, 4] - - @Builder itemEnd() { - Row() { - Button('Delete').margin('4vp') - Button('Set').margin('4vp') - }.padding('4vp').justifyContent(FlexAlign.SpaceEvenly) - } - - build() { - Column() { - TitleBar({ title: $r('app.string.list') }) - Text($r('app.string.delete_list_item')) - .leftTitleStyle() - Column() { - List({ space: 10 }) { - ForEach(this.arr, (item: number) => { - ListItem() { - Text('item' + item) - .width('100%') - .height(100) - .fontSize(16) - .textAlign(TextAlign.Center) - .borderRadius(10) - .backgroundColor(0xFFFFFF) - } - .transition({ type: TransitionType.Delete, opacity: 0 }) - .swipeAction({ - end: { - onAction: () => { - animateTo({ duration: 1000 }, () => { - let index = this.arr.indexOf(item) - this.arr.splice(index, 1) - }) - }, - actionAreaDistance: 56, - } - }) - }, (item: number) => item.toString()) - } - } - .cardStyle() - .width('100%') - } - .height('100%') - .width('100%') - .backgroundColor($r('app.color.background_light_gray')) - .padding({ left: 20, right: 20 }) - } +/* + * Copyright (c) 2023 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 { TitleBar } from '../../../../common/TitleBar' + +@Extend(Text) function leftTitleStyle() { + .fontColor($r('app.color.font_color_shallow')) + .fontSize(18) + .height(22) + .alignSelf(ItemAlign.Start) + .margin({ left: 12, bottom: 8 }) +} + +@Extend(Column) function cardStyle() { + .backgroundColor(Color.White) + .borderRadius(24) + .width('100%') + .padding(12) + .margin({ bottom: 12 }) +} + +@Entry +@Component +struct ListSample { + @State arr: number[] = [0, 1, 2, 3, 4] + + @Builder itemEnd() { + Row() { + Button('Delete').margin('4vp') + Button('Set').margin('4vp') + }.padding('4vp').justifyContent(FlexAlign.SpaceEvenly) + } + + build() { + Column() { + TitleBar({ title: $r('app.string.list') }) + Text($r('app.string.delete_list_item')) + .leftTitleStyle() + Column() { + List({ space: 10 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('item' + item) + .width('100%') + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + .transition({ type: TransitionType.Delete, opacity: 0 }) + .swipeAction({ + end: { + onAction: () => { + animateTo({ duration: 1000 }, () => { + let index = this.arr.indexOf(item) + this.arr.splice(index, 1) + }) + }, + actionAreaDistance: 56, + } + }) + }, (item: number) => item.toString()) + } + } + .cardStyle() + .width('100%') + } + .height('100%') + .width('100%') + .backgroundColor($r('app.color.background_light_gray')) + .padding({ left: 20, right: 20 }) + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/navigation/navRouterSample/NavRouterSample.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/navigation/navRouterSample/NavRouterSample.ets old mode 100755 new mode 100644 index e0dae1fb7c..210b601152 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/navigation/navRouterSample/NavRouterSample.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/navigation/navRouterSample/NavRouterSample.ets @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2023 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 { TitleBar } from '../../../../common/TitleBar' -import { getStringData } from '../../../../data/ResourceDataHandle' - -@Entry -@Component -struct NavRouterSample { - private arr: number[] = [1, 2, 3]; - - build() { - Column() { - TitleBar({ title: $r('app.string.navRouter_title') }) - Navigation() { - - List({ space: 12 }) { - ForEach(this.arr, (item: number) => { - ListItem() { - NavRouter() { - Text(getStringData($r('app.string.nav_router')) + item) - .width("100%") - .height(72) - .backgroundColor('#FFFFFF') - .borderRadius(24) - .fontSize(16) - .fontWeight(500) - .textAlign(TextAlign.Center) - NavDestination() { - Text("NavDestinationContent" + item) - } - .title("NavDestinationTitle" + item) - } - } - .id('Navigation' + item) - }, (item: number) => item.toString()) - } - .width("90%") - .margin({ top: 12 }) - } - .mode(NavigationMode.Stack) - } - .height('100%') - .width('100%') - .backgroundColor('#F1F3F5') - } +/* + * Copyright (c) 2023 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 { TitleBar } from '../../../../common/TitleBar' +import { getStringData } from '../../../../data/ResourceDataHandle' + +@Entry +@Component +struct NavRouterSample { + private arr: number[] = [1, 2, 3]; + + build() { + Column() { + TitleBar({ title: $r('app.string.navRouter_title') }) + Navigation() { + + List({ space: 12 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + NavRouter() { + Text(getStringData($r('app.string.nav_router')) + item) + .width("100%") + .height(72) + .backgroundColor('#FFFFFF') + .borderRadius(24) + .fontSize(16) + .fontWeight(500) + .textAlign(TextAlign.Center) + NavDestination() { + Text("NavDestinationContent" + item) + } + .title("NavDestinationTitle" + item) + } + } + .id('Navigation' + item) + }, (item: number) => item.toString()) + } + .width("90%") + .margin({ top: 12 }) + } + .mode(NavigationMode.Stack) + } + .height('100%') + .width('100%') + .backgroundColor('#F1F3F5') + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/scrollAndSwipe/swiperSample/SwiperCustomAnimationControlPanel.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/scrollAndSwipe/swiperSample/SwiperCustomAnimationControlPanel.ets index dd57a8f010..5baa988ffa 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/scrollAndSwipe/swiperSample/SwiperCustomAnimationControlPanel.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/scrollAndSwipe/swiperSample/SwiperCustomAnimationControlPanel.ets @@ -1,93 +1,93 @@ -/* - * Copyright (c) 2024 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 { CommonItemSelect, CommonSwitcher } from '../../../../common/AttributeModificationTool'; - -@Component -export struct CustomAnimationPropertiesControlPanel { - @Link changeOpacity: boolean; - @Link changeScale: boolean; - @Link closeTwoPagesTogether: boolean; - @Link cancelDefaultTranslate: boolean; - @Link customAnimationAutoPlay: boolean; - @Link customAnimationDuration: number; - @Link customAnimationCurve: string; - - build() { - Column() { - CommonSwitcher({ - bool: $changeOpacity, - name: $r('app.string.swiper_custom_property_opacity'), - testID: `custom_swiper_001` - }) - - Divider() - - CommonSwitcher({ - bool: $changeScale, - name: $r('app.string.swiper_custom_property_scale'), - testID: `custom_swiper_002` - }) - - Divider() - - CommonSwitcher({ - bool: $closeTwoPagesTogether, - name: $r('app.string.swiper_close_two_pages_together'), - testID: `custom_swiper_003` - }) - - Divider() - - CommonSwitcher({ - bool: $cancelDefaultTranslate, - name: $r('app.string.swiper_cancel_default_translate'), - testID: `custom_swiper_004` - }) - - Divider() - - CommonSwitcher({ - bool: $customAnimationAutoPlay, - name: $r('app.string.swiper_property_auto_play'), - testID: `custom_swiper_005` - }) - - Divider() - - CommonItemSelect({ - name: $r('app.string.swiper_properties_duration'), - selects: ['400', '1000', '2000'], - menuAlignType: MenuAlignType.END, - callback: (index, str) => { - this.customAnimationDuration = Number.parseInt(str); - }, - testId:`custom_swiper_006` - }) - - Divider() - - CommonItemSelect({ - name: $r('app.string.swiper_custom_property_curve'), - selects: ['Linear', 'Ease', 'FastOutSlowIn', 'Sharp', 'Rhythm', 'Smooth', 'Friction'], - menuAlignType: MenuAlignType.END, - callback: (index, str) => { - this.customAnimationCurve = str; - }, - testId:`custom_swiper_007` - }) - } - } +/* + * Copyright (c) 2024 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 { CommonItemSelect, CommonSwitcher } from '../../../../common/AttributeModificationTool'; + +@Component +export struct CustomAnimationPropertiesControlPanel { + @Link changeOpacity: boolean; + @Link changeScale: boolean; + @Link closeTwoPagesTogether: boolean; + @Link cancelDefaultTranslate: boolean; + @Link customAnimationAutoPlay: boolean; + @Link customAnimationDuration: number; + @Link customAnimationCurve: string; + + build() { + Column() { + CommonSwitcher({ + bool: $changeOpacity, + name: $r('app.string.swiper_custom_property_opacity'), + testID: `custom_swiper_001` + }) + + Divider() + + CommonSwitcher({ + bool: $changeScale, + name: $r('app.string.swiper_custom_property_scale'), + testID: `custom_swiper_002` + }) + + Divider() + + CommonSwitcher({ + bool: $closeTwoPagesTogether, + name: $r('app.string.swiper_close_two_pages_together'), + testID: `custom_swiper_003` + }) + + Divider() + + CommonSwitcher({ + bool: $cancelDefaultTranslate, + name: $r('app.string.swiper_cancel_default_translate'), + testID: `custom_swiper_004` + }) + + Divider() + + CommonSwitcher({ + bool: $customAnimationAutoPlay, + name: $r('app.string.swiper_property_auto_play'), + testID: `custom_swiper_005` + }) + + Divider() + + CommonItemSelect({ + name: $r('app.string.swiper_properties_duration'), + selects: ['400', '1000', '2000'], + menuAlignType: MenuAlignType.END, + callback: (index, str) => { + this.customAnimationDuration = Number.parseInt(str); + }, + testId:`custom_swiper_006` + }) + + Divider() + + CommonItemSelect({ + name: $r('app.string.swiper_custom_property_curve'), + selects: ['Linear', 'Ease', 'FastOutSlowIn', 'Sharp', 'Rhythm', 'Smooth', 'Friction'], + menuAlignType: MenuAlignType.END, + callback: (index, str) => { + this.customAnimationCurve = str; + }, + testId:`custom_swiper_007` + }) + } + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/textAndInput/imageSpanSample/ImageSpanSample.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/textAndInput/imageSpanSample/ImageSpanSample.ets index 9b69b8238d..f743f8b9b1 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/textAndInput/imageSpanSample/ImageSpanSample.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/components/textAndInput/imageSpanSample/ImageSpanSample.ets @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2022-2023 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 { ChangeVerticalAlign, ChangeObjectFit } from './ChangePanel' -import { IntroductionTitle } from '../../../../common/IntroductionTitle' -import { TitleBar } from '../../../../common/TitleBar' - -@Extend(Column) function backgroundStyle() { - .size({ width: '100%' }) - .margin({ top: 12 }) - .padding(12) - .borderRadius(24) - .justifyContent(FlexAlign.SpaceBetween) - .backgroundColor(Color.White) -} - -@Entry -@Component -struct ImageSpanSample { - @State imageSpanAlignment: ImageSpanAlignment = ImageSpanAlignment.BOTTOM - @State imageFit: ImageFit = ImageFit.Cover - - build() { - Column() { - TitleBar({ title: $r('app.string.image_span_title') }) - Scroll() { - Column() { - IntroductionTitle({ introduction: $r('app.string.image_span_and_span') }) - Column() { - Text(){ - Span($r('app.string.text_content_en_first')) - ImageSpan($r('app.media.banner')) - .verticalAlign(this.imageSpanAlignment) - .objectFit(this.imageFit) - .width(300) - .height(350) - .border({ width: 1 }) - Span($r('app.string.text_content_en_last')) - } - } - .backgroundStyle() - - IntroductionTitle({ introduction: $r('app.string.image_span_vertical_align_and_object_fit') }) - Column() { - ChangeVerticalAlign({ - imageSpanAlignment: $imageSpanAlignment - }) - ChangeObjectFit({ - imageFit: $imageFit - }) - } - .backgroundStyle() - .margin({ bottom: 80 }) - } - .constraintSize({ minHeight: '100%' }) // Let the minHeight of the component cover screen at least - } - .height('100%') - .padding({ left: 12, right: 12 }) - } - .backgroundColor($r('app.color.background_shallow_grey')) - } +/* + * Copyright (c) 2022-2023 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 { ChangeVerticalAlign, ChangeObjectFit } from './ChangePanel' +import { IntroductionTitle } from '../../../../common/IntroductionTitle' +import { TitleBar } from '../../../../common/TitleBar' + +@Extend(Column) function backgroundStyle() { + .size({ width: '100%' }) + .margin({ top: 12 }) + .padding(12) + .borderRadius(24) + .justifyContent(FlexAlign.SpaceBetween) + .backgroundColor(Color.White) +} + +@Entry +@Component +struct ImageSpanSample { + @State imageSpanAlignment: ImageSpanAlignment = ImageSpanAlignment.BOTTOM + @State imageFit: ImageFit = ImageFit.Cover + + build() { + Column() { + TitleBar({ title: $r('app.string.image_span_title') }) + Scroll() { + Column() { + IntroductionTitle({ introduction: $r('app.string.image_span_and_span') }) + Column() { + Text(){ + Span($r('app.string.text_content_en_first')) + ImageSpan($r('app.media.banner')) + .verticalAlign(this.imageSpanAlignment) + .objectFit(this.imageFit) + .width(300) + .height(350) + .border({ width: 1 }) + Span($r('app.string.text_content_en_last')) + } + } + .backgroundStyle() + + IntroductionTitle({ introduction: $r('app.string.image_span_vertical_align_and_object_fit') }) + Column() { + ChangeVerticalAlign({ + imageSpanAlignment: $imageSpanAlignment + }) + ChangeObjectFit({ + imageFit: $imageFit + }) + } + .backgroundStyle() + .margin({ bottom: 80 }) + } + .constraintSize({ minHeight: '100%' }) // Let the minHeight of the component cover screen at least + } + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor($r('app.color.background_shallow_grey')) + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomClickEvent.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomClickEvent.ets old mode 100755 new mode 100644 index 2804c8d9f3..e81c7ea33d --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomClickEvent.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomClickEvent.ets @@ -1,178 +1,178 @@ -/* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router'; -import { getStringData } from '../../../../data/ResourceDataHandle'; -import { IntroductionTitle } from '../../../../common/IntroductionTitle'; -import { TitleBar } from '../../../../common/TitleBar'; -import ShowToast from '../../../../util/ShowToast'; -import Logger from '../../../../util/Logger'; - -const TAG: string = 'CustomClickEvent'; - -@Entry -@Component -struct CustomClickEvent { - private btnFontColor: Resource = $r('app.color.white'); - - isTouchPointInCircle(info: TouchTestInfo): boolean { - let circleCenterX = info.rect.x + info.rect.width / 2; - let circleCenterY = info.rect.y + info.rect.height / 2; - let circleRadius = info.rect.width / 2; - let distance = Math.sqrt((circleCenterX - info.parentX)**2 + (circleCenterY - info.parentY)**2); - Logger.info(TAG, `isTouchPoinInCircle circleCenterX: ${circleCenterX}, circleCenterY: ${circleCenterY},\ - circleRadius: ${circleRadius}, distance: ${distance}`); - if (distance <= circleRadius) { - return true; - } - return false; - } - - build() { - Column() { - // 标题 - Column() { - Row() { - Image($r('app.media.ic_back')) - .width(24) - .height(24) - .margin({ left: 24 }) - .objectFit(ImageFit.Contain) - .onClick(() => { - router.back() - }) - .id('backBtn') - Text($r('app.string.custom_click_event')) - .fontSize(20) - .layoutWeight(1) - .fontWeight(700) - .margin({ left: 16 }) - .align(Alignment.Start) - Blank() - } - .height(56) - .width('100%') - } - .height(56) - .width('100%') - - Column() { - // 大小圆圈 - Column({ space: 12 }) { - Stack({ alignContent: Alignment.Bottom }) { - Button({ type: ButtonType.Circle }) { - Row() { - Text($r('app.string.custom_click_big_btn')) - .fontSize(21) - .fontWeight(500) - .fontFamily('HarmonyHeiTi-Medium') - .textAlign(TextAlign.Center) - .padding({ top: 56, bottom: 300 }) - } - .alignItems(VerticalAlign.Top) - } - .backgroundColor('#007DFF') - .width('100%') - .height('100%') - .fontSize(21) - .fontWeight(500) - .id('BigCircle') - .fontColor(this.btnFontColor) - .onClick(() => { - ShowToast.longToast($r('app.string.custom_bigcircle_prompt')); - }) - - Button($r('app.string.custom_click_small_btn'), { type: ButtonType.Circle }) - .backgroundColor('#F7CE00') - .width(240) - .fontSize(21) - .fontWeight(500) - .borderRadius(20) - .fontColor(this.btnFontColor) - .id('SmallCircle') - .onClick(() => { - ShowToast.longToast($r('app.string.custom_smallcircle_prompt')); - }) - } - .width('100%') - .hitTestBehavior(HitTestMode.Block) - .onChildTouchTest((touchinfo) => { - Logger.info(TAG, `touchinfo array len: ${touchinfo.length}`); - for(let i = 0; i < touchinfo.length; i++) { - let info: TouchTestInfo = touchinfo[i]; - Logger.info(TAG, `touchinfo info.id: ${info.id}`); - Logger.info(TAG, `touchinfo windowX: ${info.windowX}, windowY: ${info.windowY}`); - Logger.info(TAG, `touchinfo parentX: ${info.parentX}, parentY: ${info.parentY}`); - Logger.info(TAG, `touchinfo x: ${info.x}, y: ${info.y}`); - Logger.info(TAG, `touchinfo rect.x: ${info.rect.x}, rect.y: ${info.rect.y}, rect.width: ${info.rect.width}, rect.height: ${info.rect.height}`); - - if (info.id == 'SmallCircle' && info.x > 0 && info.y > 0 && this.isTouchPointInCircle(info) == true) { - Logger.info(TAG, `touchinfo touch point at scope of component: ${info.id}`); - return { id: 'SmallCircle', strategy: TouchTestStrategy.FORWARD }; - } - if (info.id == 'BigCircle' && info.x > 0 && info.y > 0 && this.isTouchPointInCircle(info) == true) { - Logger.info(TAG, `touchinfo touch point at scope of component: ${info.id}`); - return { id: 'BigCircle', strategy: TouchTestStrategy.FORWARD }; - } - } - return { strategy: TouchTestStrategy.DEFAULT }; - }) - } - .padding({ left: 24, right: 24, bottom: 32 }) - - // 文字提示 - Column() { - Row() { - Button({ type: ButtonType.Circle }) - .backgroundColor('#007DFF') - .width(8) - .height(8) - Text($r('app.string.big_circle_prompt')) - .fontSize(14) - .fontWeight(400) - .fontFamily('HarmonyHeiTi') - .textAlign(TextAlign.Start) - .margin({ left: 8 }) - } - .alignItems(VerticalAlign.Center) - .justifyContent(FlexAlign.Center) - - Row() { - Button({ type: ButtonType.Circle }) - .backgroundColor('#F7CE00') - .width(8) - .height(8) - Text($r('app.string.small_circle_prompt')) - .fontSize(14) - .fontWeight(400) - .fontFamily('HarmonyHeiTi') - .textAlign(TextAlign.Start) - .margin({ left: 8 }) - } - .alignItems(VerticalAlign.Center) - .justifyContent(FlexAlign.Center) - } - } - .height('90%') - .width('100%') - .alignItems(HorizontalAlign.Center) - .justifyContent(FlexAlign.Center) - .flexShrink(1) - } - .height('100%') - .width('100%') - .backgroundColor($r('app.color.background_shallow_grey')) - } -} +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router'; +import { getStringData } from '../../../../data/ResourceDataHandle'; +import { IntroductionTitle } from '../../../../common/IntroductionTitle'; +import { TitleBar } from '../../../../common/TitleBar'; +import ShowToast from '../../../../util/ShowToast'; +import Logger from '../../../../util/Logger'; + +const TAG: string = 'CustomClickEvent'; + +@Entry +@Component +struct CustomClickEvent { + private btnFontColor: Resource = $r('app.color.white'); + + isTouchPointInCircle(info: TouchTestInfo): boolean { + let circleCenterX = info.rect.x + info.rect.width / 2; + let circleCenterY = info.rect.y + info.rect.height / 2; + let circleRadius = info.rect.width / 2; + let distance = Math.sqrt((circleCenterX - info.parentX)**2 + (circleCenterY - info.parentY)**2); + Logger.info(TAG, `isTouchPoinInCircle circleCenterX: ${circleCenterX}, circleCenterY: ${circleCenterY},\ + circleRadius: ${circleRadius}, distance: ${distance}`); + if (distance <= circleRadius) { + return true; + } + return false; + } + + build() { + Column() { + // 标题 + Column() { + Row() { + Image($r('app.media.ic_back')) + .width(24) + .height(24) + .margin({ left: 24 }) + .objectFit(ImageFit.Contain) + .onClick(() => { + router.back() + }) + .id('backBtn') + Text($r('app.string.custom_click_event')) + .fontSize(20) + .layoutWeight(1) + .fontWeight(700) + .margin({ left: 16 }) + .align(Alignment.Start) + Blank() + } + .height(56) + .width('100%') + } + .height(56) + .width('100%') + + Column() { + // 大小圆圈 + Column({ space: 12 }) { + Stack({ alignContent: Alignment.Bottom }) { + Button({ type: ButtonType.Circle }) { + Row() { + Text($r('app.string.custom_click_big_btn')) + .fontSize(21) + .fontWeight(500) + .fontFamily('HarmonyHeiTi-Medium') + .textAlign(TextAlign.Center) + .padding({ top: 56, bottom: 300 }) + } + .alignItems(VerticalAlign.Top) + } + .backgroundColor('#007DFF') + .width('100%') + .height('100%') + .fontSize(21) + .fontWeight(500) + .id('BigCircle') + .fontColor(this.btnFontColor) + .onClick(() => { + ShowToast.longToast($r('app.string.custom_bigcircle_prompt')); + }) + + Button($r('app.string.custom_click_small_btn'), { type: ButtonType.Circle }) + .backgroundColor('#F7CE00') + .width(240) + .fontSize(21) + .fontWeight(500) + .borderRadius(20) + .fontColor(this.btnFontColor) + .id('SmallCircle') + .onClick(() => { + ShowToast.longToast($r('app.string.custom_smallcircle_prompt')); + }) + } + .width('100%') + .hitTestBehavior(HitTestMode.Block) + .onChildTouchTest((touchinfo) => { + Logger.info(TAG, `touchinfo array len: ${touchinfo.length}`); + for(let i = 0; i < touchinfo.length; i++) { + let info: TouchTestInfo = touchinfo[i]; + Logger.info(TAG, `touchinfo info.id: ${info.id}`); + Logger.info(TAG, `touchinfo windowX: ${info.windowX}, windowY: ${info.windowY}`); + Logger.info(TAG, `touchinfo parentX: ${info.parentX}, parentY: ${info.parentY}`); + Logger.info(TAG, `touchinfo x: ${info.x}, y: ${info.y}`); + Logger.info(TAG, `touchinfo rect.x: ${info.rect.x}, rect.y: ${info.rect.y}, rect.width: ${info.rect.width}, rect.height: ${info.rect.height}`); + + if (info.id == 'SmallCircle' && info.x > 0 && info.y > 0 && this.isTouchPointInCircle(info) == true) { + Logger.info(TAG, `touchinfo touch point at scope of component: ${info.id}`); + return { id: 'SmallCircle', strategy: TouchTestStrategy.FORWARD }; + } + if (info.id == 'BigCircle' && info.x > 0 && info.y > 0 && this.isTouchPointInCircle(info) == true) { + Logger.info(TAG, `touchinfo touch point at scope of component: ${info.id}`); + return { id: 'BigCircle', strategy: TouchTestStrategy.FORWARD }; + } + } + return { strategy: TouchTestStrategy.DEFAULT }; + }) + } + .padding({ left: 24, right: 24, bottom: 32 }) + + // 文字提示 + Column() { + Row() { + Button({ type: ButtonType.Circle }) + .backgroundColor('#007DFF') + .width(8) + .height(8) + Text($r('app.string.big_circle_prompt')) + .fontSize(14) + .fontWeight(400) + .fontFamily('HarmonyHeiTi') + .textAlign(TextAlign.Start) + .margin({ left: 8 }) + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + + Row() { + Button({ type: ButtonType.Circle }) + .backgroundColor('#F7CE00') + .width(8) + .height(8) + Text($r('app.string.small_circle_prompt')) + .fontSize(14) + .fontWeight(400) + .fontFamily('HarmonyHeiTi') + .textAlign(TextAlign.Start) + .margin({ left: 8 }) + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + } + } + .height('90%') + .width('100%') + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .flexShrink(1) + } + .height('100%') + .width('100%') + .backgroundColor($r('app.color.background_shallow_grey')) + } +} diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomEventHome.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomEventHome.ets old mode 100755 new mode 100644 index 50a24d697b..7e4701d739 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomEventHome.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomEventHome.ets @@ -1,99 +1,99 @@ -/* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router'; -import { getStringData } from '../../../../data/ResourceDataHandle'; -import { IntroductionTitle } from '../../../../common/IntroductionTitle'; -import { TitleBar } from '../../../../common/TitleBar'; -import ShowToast from '../../../../util/ShowToast'; - -@Entry -@Component -struct CustomEventHome { - private btnFontColor: Resource = $r('app.color.white'); - private customClickUrl: string = 'pages/universal/events/customEventSample/CustomClickEvent'; - private customScrollingUrl: string = 'pages/universal/events/customEventSample/CustomScrollingEvent'; - - build() { - Column() { - // 标题 - Column() { - Row() { - Image($r('app.media.ic_back')) - .width(24) - .height(24) - .margin({ left: 24 }) - .objectFit(ImageFit.Contain) - .onClick(() => { - router.back() - }) - .id('backBtn') - Text($r('app.string.send_event')) - .fontSize(20) - .layoutWeight(1) - .fontWeight(700) - .margin({ left: 16 }) - .align(Alignment.Start) - Blank() - } - .height(56) - .width('100%') - } - .height(56) - .width('100%') - - Blank() - Column({ space: 12 }) { - Button($r('app.string.custom_click_event_button')) - .backgroundColor('#007DFF') - .width('100%') - .height(40) - .fontSize(16) - .fontWeight(500) - .borderRadius(20) - .fontColor(this.btnFontColor) - .id('customClick') - .onClick(() => { - router.pushUrl({ - url: this.customClickUrl - }); - }) - - Button($r('app.string.custom_Scrolling_event_button')) - .backgroundColor('#007DFF') - .width('100%') - .height(40) - .fontSize(16) - .fontWeight(500) - .borderRadius(20) - .fontColor(this.btnFontColor) - .id('customScrolling') - .onClick(() => { - router.pushUrl({ - url: this.customScrollingUrl - }); - }) - } - .padding({ left: 24, right: 24, bottom: 16 }) - .width('100%') - .alignItems(HorizontalAlign.Center) - .justifyContent(FlexAlign.End) - .flexShrink(1) - } - .height('100%') - .width('100%') - .backgroundColor($r('app.color.background_shallow_grey')) - } +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router'; +import { getStringData } from '../../../../data/ResourceDataHandle'; +import { IntroductionTitle } from '../../../../common/IntroductionTitle'; +import { TitleBar } from '../../../../common/TitleBar'; +import ShowToast from '../../../../util/ShowToast'; + +@Entry +@Component +struct CustomEventHome { + private btnFontColor: Resource = $r('app.color.white'); + private customClickUrl: string = 'pages/universal/events/customEventSample/CustomClickEvent'; + private customScrollingUrl: string = 'pages/universal/events/customEventSample/CustomScrollingEvent'; + + build() { + Column() { + // 标题 + Column() { + Row() { + Image($r('app.media.ic_back')) + .width(24) + .height(24) + .margin({ left: 24 }) + .objectFit(ImageFit.Contain) + .onClick(() => { + router.back() + }) + .id('backBtn') + Text($r('app.string.send_event')) + .fontSize(20) + .layoutWeight(1) + .fontWeight(700) + .margin({ left: 16 }) + .align(Alignment.Start) + Blank() + } + .height(56) + .width('100%') + } + .height(56) + .width('100%') + + Blank() + Column({ space: 12 }) { + Button($r('app.string.custom_click_event_button')) + .backgroundColor('#007DFF') + .width('100%') + .height(40) + .fontSize(16) + .fontWeight(500) + .borderRadius(20) + .fontColor(this.btnFontColor) + .id('customClick') + .onClick(() => { + router.pushUrl({ + url: this.customClickUrl + }); + }) + + Button($r('app.string.custom_Scrolling_event_button')) + .backgroundColor('#007DFF') + .width('100%') + .height(40) + .fontSize(16) + .fontWeight(500) + .borderRadius(20) + .fontColor(this.btnFontColor) + .id('customScrolling') + .onClick(() => { + router.pushUrl({ + url: this.customScrollingUrl + }); + }) + } + .padding({ left: 24, right: 24, bottom: 16 }) + .width('100%') + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.End) + .flexShrink(1) + } + .height('100%') + .width('100%') + .backgroundColor($r('app.color.background_shallow_grey')) + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomScrollingEvent.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomScrollingEvent.ets old mode 100755 new mode 100644 index 21d4841f34..1dfeddc5cc --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomScrollingEvent.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomScrollingEvent.ets @@ -1,185 +1,185 @@ -/* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router'; -import { getStringData } from '../../../../data/ResourceDataHandle'; -import { IntroductionTitle } from '../../../../common/IntroductionTitle'; -import { TitleBar } from '../../../../common/TitleBar'; -import ShowToast from '../../../../util/ShowToast'; -import Logger from '../../../../util/Logger'; - -const TAG: string = 'CustomScrollingEvent'; - -@Entry -@Component -struct CustomScrollingEvent { - private scrollerForScroll: Scroller = new Scroller(); - private scrollerForList: Scroller = new Scroller(); - @State files: string[] = []; - @State listPosition: number = 0; // 0代表滚动到List顶部,1代表中间值,2代表滚动到List底部。 - - aboutToAppear() { - for (let i = 1; i <= 30; i++) { - let file: string = "file" + i.toString(); - this.files.push(file); - } - } - - build() { - Column() { - // 标题 - Column() { - Row() { - Image($r('app.media.ic_back')) - .width(24) - .height(24) - .margin({ left: 12 }) - .objectFit(ImageFit.Contain) - .onClick(() => { - router.back() - }) - .id('backBtn') - Text($r('app.string.custom_scrolling_event')) - .fontSize(20) - .layoutWeight(1) - .fontWeight(700) - .margin({ left: 16 }) - .align(Alignment.Start) - Blank() - } - .height(56) - .width('100%') - } - .height(56) - .width('100%') - .padding({ left: 12, right: 12 }) - - Scroll(this.scrollerForScroll) { - Column() { - Column() { - Text($r('app.string.custom_scrolling_area')) - .fontSize(36) - .fontWeight(400) - .fontFamily('HarmonyHeiTi') - .textAlign(TextAlign.Start) - .fontColor('#182431') - .opacity(0.15) - .margin({ top: 142 }) - .id('scrollText') - Image($r('app.media.button')) - .width(40) - .height(40) - .margin({ top: 78, bottom: 40 }) - .id('scrollBtn') - .objectFit(ImageFit.Contain) - } - .height(332) - .width('100%') - .border({ - width: 1, - color: '#55182431', - radius: 24, - style: BorderStyle.Solid - }) - .alignItems(HorizontalAlign.Center) - .justifyContent(FlexAlign.Center) - .margin({ bottom: 16 }) - .backgroundColor('#F2F3F4') - .id('ScrollArea') - - // 目录列表 - List({ space: 12, scroller: this.scrollerForList }) { - ForEach(this.files, (file: string, index: number) => { - ListItem() { - Row() { - Text(file) - .fontSize(16) - .fontWeight(500) - .fontFamily('HarmonyHeiTi-Medium') - .textAlign(TextAlign.Start) - } - .width('100%') - .height(56) - .borderRadius(24) - .backgroundColor(0xFFFFFF) - .alignItems(VerticalAlign.Center) - .padding({ left: 12, right: 12 }) - } - .id("ListItem" + index) - .width('100%') - }) - } - .width('100%') - .height('80%') - .listDirection(Axis.Vertical) // 排列方向 - .borderRadius(24) - .edgeEffect(EdgeEffect.None) // 边缘效果设置为Spring - .nestedScroll({ - scrollForward: NestedScrollMode.PARENT_FIRST, - scrollBackward: NestedScrollMode.SELF_FIRST - }) - .onReachStart(() => { - this.listPosition = 0 - }) - .onReachEnd(() => { - this.listPosition = 2 - }) - .onScrollFrameBegin((offset: number) => { - if ((this.listPosition == 0 && offset <= 0) || (this.listPosition == 2 && offset >= 0)) { - this.scrollerForScroll.scrollBy(0, offset); - return { offsetRemain: 0 }; - } - this.listPosition = 1; - return { offsetRemain: offset }; - }) - .id('fileList') - } - .margin({ left: 12, right: 12 }) - .onChildTouchTest((touchinfo) => { - Logger.info(TAG, `touchinfo array len: ${touchinfo.length}`); - for (let info of touchinfo) { - Logger.info(TAG, `touchinfo info.id: ${info.id}`); - Logger.info(TAG, `touchinfo windowX: ${info.windowX}, windowY: ${info.windowY}`); - Logger.info(TAG, `touchinfo parentX: ${info.parentX}, parentY: ${info.parentY}`); - Logger.info(TAG, `touchinfo x: ${info.x}, y: ${info.y}`); - Logger.info(TAG, `touchinfo rect.x: ${info.rect.x}, rect.y: ${info.rect.y}, rect.width: ${info.rect.width}, rect.height: ${info.rect.height}`); - let compontWidth = info.rect.x + info.rect.width; - let compontHeight = info.rect.y + info.rect.height; - if (info.id == 'ScrollArea' && - info.x > 0 && - info.parentX < compontWidth && - info.parentX > info.rect.x && - info.y > 0 && - info.parentY < compontHeight && - info.parentY > info.rect.y) { - Logger.info(TAG, `touchinfo touch point at scope of component: ${info.id}`); - return { id: 'fileList', strategy: TouchTestStrategy.FORWARD }; - } - } - return { strategy: TouchTestStrategy.DEFAULT }; - }) - } - .edgeEffect(EdgeEffect.Spring) - .friction(0.6) - .scrollBar(BarState.Off) - .width('100%') - .height(700) - .id('GlobalScroll') - } - .height('100%') - .width('100%') - .backgroundColor($r('app.color.background_shallow_grey')) - } +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router'; +import { getStringData } from '../../../../data/ResourceDataHandle'; +import { IntroductionTitle } from '../../../../common/IntroductionTitle'; +import { TitleBar } from '../../../../common/TitleBar'; +import ShowToast from '../../../../util/ShowToast'; +import Logger from '../../../../util/Logger'; + +const TAG: string = 'CustomScrollingEvent'; + +@Entry +@Component +struct CustomScrollingEvent { + private scrollerForScroll: Scroller = new Scroller(); + private scrollerForList: Scroller = new Scroller(); + @State files: string[] = []; + @State listPosition: number = 0; // 0代表滚动到List顶部,1代表中间值,2代表滚动到List底部。 + + aboutToAppear() { + for (let i = 1; i <= 30; i++) { + let file: string = "file" + i.toString(); + this.files.push(file); + } + } + + build() { + Column() { + // 标题 + Column() { + Row() { + Image($r('app.media.ic_back')) + .width(24) + .height(24) + .margin({ left: 12 }) + .objectFit(ImageFit.Contain) + .onClick(() => { + router.back() + }) + .id('backBtn') + Text($r('app.string.custom_scrolling_event')) + .fontSize(20) + .layoutWeight(1) + .fontWeight(700) + .margin({ left: 16 }) + .align(Alignment.Start) + Blank() + } + .height(56) + .width('100%') + } + .height(56) + .width('100%') + .padding({ left: 12, right: 12 }) + + Scroll(this.scrollerForScroll) { + Column() { + Column() { + Text($r('app.string.custom_scrolling_area')) + .fontSize(36) + .fontWeight(400) + .fontFamily('HarmonyHeiTi') + .textAlign(TextAlign.Start) + .fontColor('#182431') + .opacity(0.15) + .margin({ top: 142 }) + .id('scrollText') + Image($r('app.media.button')) + .width(40) + .height(40) + .margin({ top: 78, bottom: 40 }) + .id('scrollBtn') + .objectFit(ImageFit.Contain) + } + .height(332) + .width('100%') + .border({ + width: 1, + color: '#55182431', + radius: 24, + style: BorderStyle.Solid + }) + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .margin({ bottom: 16 }) + .backgroundColor('#F2F3F4') + .id('ScrollArea') + + // 目录列表 + List({ space: 12, scroller: this.scrollerForList }) { + ForEach(this.files, (file: string, index: number) => { + ListItem() { + Row() { + Text(file) + .fontSize(16) + .fontWeight(500) + .fontFamily('HarmonyHeiTi-Medium') + .textAlign(TextAlign.Start) + } + .width('100%') + .height(56) + .borderRadius(24) + .backgroundColor(0xFFFFFF) + .alignItems(VerticalAlign.Center) + .padding({ left: 12, right: 12 }) + } + .id("ListItem" + index) + .width('100%') + }) + } + .width('100%') + .height('80%') + .listDirection(Axis.Vertical) // 排列方向 + .borderRadius(24) + .edgeEffect(EdgeEffect.None) // 边缘效果设置为Spring + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.SELF_FIRST + }) + .onReachStart(() => { + this.listPosition = 0 + }) + .onReachEnd(() => { + this.listPosition = 2 + }) + .onScrollFrameBegin((offset: number) => { + if ((this.listPosition == 0 && offset <= 0) || (this.listPosition == 2 && offset >= 0)) { + this.scrollerForScroll.scrollBy(0, offset); + return { offsetRemain: 0 }; + } + this.listPosition = 1; + return { offsetRemain: offset }; + }) + .id('fileList') + } + .margin({ left: 12, right: 12 }) + .onChildTouchTest((touchinfo) => { + Logger.info(TAG, `touchinfo array len: ${touchinfo.length}`); + for (let info of touchinfo) { + Logger.info(TAG, `touchinfo info.id: ${info.id}`); + Logger.info(TAG, `touchinfo windowX: ${info.windowX}, windowY: ${info.windowY}`); + Logger.info(TAG, `touchinfo parentX: ${info.parentX}, parentY: ${info.parentY}`); + Logger.info(TAG, `touchinfo x: ${info.x}, y: ${info.y}`); + Logger.info(TAG, `touchinfo rect.x: ${info.rect.x}, rect.y: ${info.rect.y}, rect.width: ${info.rect.width}, rect.height: ${info.rect.height}`); + let compontWidth = info.rect.x + info.rect.width; + let compontHeight = info.rect.y + info.rect.height; + if (info.id == 'ScrollArea' && + info.x > 0 && + info.parentX < compontWidth && + info.parentX > info.rect.x && + info.y > 0 && + info.parentY < compontHeight && + info.parentY > info.rect.y) { + Logger.info(TAG, `touchinfo touch point at scope of component: ${info.id}`); + return { id: 'fileList', strategy: TouchTestStrategy.FORWARD }; + } + } + return { strategy: TouchTestStrategy.DEFAULT }; + }) + } + .edgeEffect(EdgeEffect.Spring) + .friction(0.6) + .scrollBar(BarState.Off) + .width('100%') + .height(700) + .id('GlobalScroll') + } + .height('100%') + .width('100%') + .backgroundColor($r('app.color.background_shallow_grey')) + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/gesture/customGesture/CustomGestureJudge.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/gesture/customGesture/CustomGestureJudge.ets index f3abf99812..81b124a5be 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/gesture/customGesture/CustomGestureJudge.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/gesture/customGesture/CustomGestureJudge.ets @@ -1,170 +1,170 @@ -/* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router'; -import { getStringData } from '../../../../data/ResourceDataHandle'; -import { IntroductionTitle } from '../../../../common/IntroductionTitle'; -import { TitleBar } from '../../../../common/TitleBar'; -import ShowToast from '../../../../util/ShowToast'; - -@Entry -@Component -struct CustomJudgeEvent { - private btnFontColor: Resource = $r('app.color.white'); - @State message: string = ''; - - build() { - Column() { - // 标题 - Column() { - Row() { - Image($r('app.media.ic_back')) - .width(24) - .height(24) - .margin({ left: 12 }) - .objectFit(ImageFit.Contain) - .onClick(() => { - router.back() - }) - .id('backBtn') - Text($r('app.string.custom_judge_title')) - .fontSize(20) - .layoutWeight(1) - .fontWeight(700) - .margin({ left: 16 }) - .align(Alignment.Start) - Blank() - } - .height('100%') - .width('100%') - } - .height(56) - .width('100%') - - // 上半部分 - Stack() { - Column() { - } - .height(340) - .width('100%') - .backgroundColor('#007DFF') - .opacity(0.1) - .alignItems(HorizontalAlign.Center) - .justifyContent(FlexAlign.Center) - .id('longPressColumn') - .border({ - width: 1, - color: '#007DFF', - radius: { topLeft: 24, topRight: 24, bottomLeft: 0, bottomRight: 0 }, - style: BorderStyle.Dotted - }) - - Text($r('app.string.custom_judge_long_press')) - .fontSize(16) - .fontWeight(400) - .fontFamily(' HarmonyHeiTi') - .textAlign(TextAlign.Center) - .opacity(0.7) - .fontColor('#007DFF') - .id('longPressPrompt') - } - .id('longPressArea') - .gesture( - TapGesture() - .tag("tap1") // 设置点击手势标志 - ) - .gesture( - LongPressGesture() - .tag("longPress1")// 设置长按手势标志 - .onAction(() => { - this.message = 'longPress'; - ShowToast.longToast($r('app.string.custom_long_press_prompt')); - }) - ) - .onGestureJudgeBegin((gestureInfo: GestureInfo, event: BaseGestureEvent) => { - // 自定义判定标准 - if (gestureInfo.type == GestureControl.GestureType.LONG_PRESS_GESTURE && - gestureInfo.tag == 'longPress1' && - event.fingerList.length > 0 && - event.fingerList[0].localY < 340) { - // 返回 CONTINUE 将保持系统判定。 - return GestureJudgeResult.CONTINUE; - } else { - return GestureJudgeResult.REJECT; - } - }) - - // 下半部分 - Stack() { - Column() { - } - .height(340) - .width('100%') - .backgroundColor('#F7CE00') - .opacity(0.1) - .alignItems(HorizontalAlign.Center) - .justifyContent(FlexAlign.Center) - .id('clickColumn') - .border({ - width: 1, - color: '#F7BD00', - radius: { topLeft: 0, topRight: 0, bottomLeft: 24, bottomRight: 24 }, - style: BorderStyle.Dotted - }) - - Text($r('app.string.custom_judge_click')) - .fontSize(16) - .fontWeight(400) - .fontFamily(' HarmonyHeiTi') - .textAlign(TextAlign.Center) - .fontColor('#FF9900') - .opacity(1) - .id('clickTextPrompt') - } - .id('clickArea') - .gesture( - TapGesture() - .tag("tap2")// 设置点击手势标志 - .onAction(() => { - this.message = 'tap'; - ShowToast.longToast($r('app.string.custom_tap_prompt')); - }) - ) - .gesture( - LongPressGesture() - .tag("longPress2")// 设置长按手势标志 - .onAction(() => { - this.message = 'longPress' - }) - ) - .onGestureJudgeBegin((gestureInfo: GestureInfo, event: BaseGestureEvent) => { - // 自定义判定标准 - if (gestureInfo.type == GestureControl.GestureType.TAP_GESTURE && - gestureInfo.tag == 'tap2' && - event.fingerList.length > 0 && - event.fingerList[0].localY <= 340) { - // 返回 CONTINUE 将保持系统判定。 - return GestureJudgeResult.CONTINUE; - } else { - return GestureJudgeResult.REJECT; - } - }) - } - .height('100%') - .width('100%') - .padding({ left: 12, right: 12 }) - .backgroundColor($r('app.color.background_shallow_grey')) - } -} +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router'; +import { getStringData } from '../../../../data/ResourceDataHandle'; +import { IntroductionTitle } from '../../../../common/IntroductionTitle'; +import { TitleBar } from '../../../../common/TitleBar'; +import ShowToast from '../../../../util/ShowToast'; + +@Entry +@Component +struct CustomJudgeEvent { + private btnFontColor: Resource = $r('app.color.white'); + @State message: string = ''; + + build() { + Column() { + // 标题 + Column() { + Row() { + Image($r('app.media.ic_back')) + .width(24) + .height(24) + .margin({ left: 12 }) + .objectFit(ImageFit.Contain) + .onClick(() => { + router.back() + }) + .id('backBtn') + Text($r('app.string.custom_judge_title')) + .fontSize(20) + .layoutWeight(1) + .fontWeight(700) + .margin({ left: 16 }) + .align(Alignment.Start) + Blank() + } + .height('100%') + .width('100%') + } + .height(56) + .width('100%') + + // 上半部分 + Stack() { + Column() { + } + .height(340) + .width('100%') + .backgroundColor('#007DFF') + .opacity(0.1) + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .id('longPressColumn') + .border({ + width: 1, + color: '#007DFF', + radius: { topLeft: 24, topRight: 24, bottomLeft: 0, bottomRight: 0 }, + style: BorderStyle.Dotted + }) + + Text($r('app.string.custom_judge_long_press')) + .fontSize(16) + .fontWeight(400) + .fontFamily(' HarmonyHeiTi') + .textAlign(TextAlign.Center) + .opacity(0.7) + .fontColor('#007DFF') + .id('longPressPrompt') + } + .id('longPressArea') + .gesture( + TapGesture() + .tag("tap1") // 设置点击手势标志 + ) + .gesture( + LongPressGesture() + .tag("longPress1")// 设置长按手势标志 + .onAction(() => { + this.message = 'longPress'; + ShowToast.longToast($r('app.string.custom_long_press_prompt')); + }) + ) + .onGestureJudgeBegin((gestureInfo: GestureInfo, event: BaseGestureEvent) => { + // 自定义判定标准 + if (gestureInfo.type == GestureControl.GestureType.LONG_PRESS_GESTURE && + gestureInfo.tag == 'longPress1' && + event.fingerList.length > 0 && + event.fingerList[0].localY < 340) { + // 返回 CONTINUE 将保持系统判定。 + return GestureJudgeResult.CONTINUE; + } else { + return GestureJudgeResult.REJECT; + } + }) + + // 下半部分 + Stack() { + Column() { + } + .height(340) + .width('100%') + .backgroundColor('#F7CE00') + .opacity(0.1) + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .id('clickColumn') + .border({ + width: 1, + color: '#F7BD00', + radius: { topLeft: 0, topRight: 0, bottomLeft: 24, bottomRight: 24 }, + style: BorderStyle.Dotted + }) + + Text($r('app.string.custom_judge_click')) + .fontSize(16) + .fontWeight(400) + .fontFamily(' HarmonyHeiTi') + .textAlign(TextAlign.Center) + .fontColor('#FF9900') + .opacity(1) + .id('clickTextPrompt') + } + .id('clickArea') + .gesture( + TapGesture() + .tag("tap2")// 设置点击手势标志 + .onAction(() => { + this.message = 'tap'; + ShowToast.longToast($r('app.string.custom_tap_prompt')); + }) + ) + .gesture( + LongPressGesture() + .tag("longPress2")// 设置长按手势标志 + .onAction(() => { + this.message = 'longPress' + }) + ) + .onGestureJudgeBegin((gestureInfo: GestureInfo, event: BaseGestureEvent) => { + // 自定义判定标准 + if (gestureInfo.type == GestureControl.GestureType.TAP_GESTURE && + gestureInfo.tag == 'tap2' && + event.fingerList.length > 0 && + event.fingerList[0].localY <= 340) { + // 返回 CONTINUE 将保持系统判定。 + return GestureJudgeResult.CONTINUE; + } else { + return GestureJudgeResult.REJECT; + } + }) + } + .height('100%') + .width('100%') + .padding({ left: 12, right: 12 }) + .backgroundColor($r('app.color.background_shallow_grey')) + } +} diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/backgroundSample/ChangePanel.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/backgroundSample/ChangePanel.ets index 838f932d2f..896d046fa8 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/backgroundSample/ChangePanel.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/backgroundSample/ChangePanel.ets @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2022-2023 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 { CommonItemSelect } from '../../../../common/AttributeModificationTool' -import { selectImageSizeData,selectImageAlignmentData } from '../../UniversialData' -import { getStringArrayData,getStringData } from '../../../../data/ResourceDataHandle' - -@Component -export struct ChangePanel { - @Link imageSize: ImageSize - @Link alignment: Alignment - - build() { - Column() { - CommonItemSelect({ - testId: "test_select1", - name: $r('app.string.set_background_image_size'), - selects: getStringArrayData(selectImageSizeData), - callback: (index) => { - switch (index) { - case 0: - this.imageSize = ImageSize.Cover - break - default: - this.imageSize = ImageSize.Contain - } - } - }) - - CommonItemSelect({ - testId: "test_select2", - name: $r('app.string.set_background_image_position'), - selects: getStringArrayData(selectImageAlignmentData), - callback: (index) => { - switch (index) { - case 0: - this.alignment = Alignment.TopStart - break - case 1: - this.alignment = Alignment.Top - break - case 2: - this.alignment = Alignment.TopEnd - break - case 3: - this.alignment = Alignment.Start - break - case 4: - this.alignment = Alignment.Center - break - case 5: - this.alignment = Alignment.End - break - case 6: - this.alignment = Alignment.BottomStart - break - case 7: - this.alignment = Alignment.Bottom - break - default: - this.alignment = Alignment.BottomEnd - } - } - }) - } - } +/* + * Copyright (c) 2022-2023 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 { CommonItemSelect } from '../../../../common/AttributeModificationTool' +import { selectImageSizeData,selectImageAlignmentData } from '../../UniversialData' +import { getStringArrayData,getStringData } from '../../../../data/ResourceDataHandle' + +@Component +export struct ChangePanel { + @Link imageSize: ImageSize + @Link alignment: Alignment + + build() { + Column() { + CommonItemSelect({ + testId: "test_select1", + name: $r('app.string.set_background_image_size'), + selects: getStringArrayData(selectImageSizeData), + callback: (index) => { + switch (index) { + case 0: + this.imageSize = ImageSize.Cover + break + default: + this.imageSize = ImageSize.Contain + } + } + }) + + CommonItemSelect({ + testId: "test_select2", + name: $r('app.string.set_background_image_position'), + selects: getStringArrayData(selectImageAlignmentData), + callback: (index) => { + switch (index) { + case 0: + this.alignment = Alignment.TopStart + break + case 1: + this.alignment = Alignment.Top + break + case 2: + this.alignment = Alignment.TopEnd + break + case 3: + this.alignment = Alignment.Start + break + case 4: + this.alignment = Alignment.Center + break + case 5: + this.alignment = Alignment.End + break + case 6: + this.alignment = Alignment.BottomStart + break + case 7: + this.alignment = Alignment.Bottom + break + default: + this.alignment = Alignment.BottomEnd + } + } + }) + } + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/effectsSample/ChangePanel.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/effectsSample/ChangePanel.ets index 5ca08b8ee8..a299e7ea07 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/effectsSample/ChangePanel.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/effectsSample/ChangePanel.ets @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2022-2023 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 { CommonItemSelect } from '../../../../common/AttributeModificationTool' -import { selectBlurStyleColorModeData, selectBlurStyleAdaptiveColorData, selectShadowTypeData} from '../../UniversialData' -import { getStringArrayData,getStringData } from '../../../../data/ResourceDataHandle' - -@Component -export struct BackgroundBlurChangePanel { - @Link mColorMode: ThemeColorMode - @Link mAdaptiveColor: AdaptiveColor - - build() { - Column() { - CommonItemSelect({ - testId: "test_select1", - name: $r('app.string.set_background_blur_style_color_mode'), - selects: getStringArrayData(selectBlurStyleColorModeData), - callback: (index) => { - switch (index) { - case 0: - this.mColorMode = ThemeColorMode.SYSTEM - break - case 1: - this.mColorMode = ThemeColorMode.LIGHT - break - default: - this.mColorMode = ThemeColorMode.DARK - } - } - }) - - CommonItemSelect({ - testId: "test_select2", - name: $r('app.string.set_background_blur_style_adaptive_color'), - selects: getStringArrayData(selectBlurStyleAdaptiveColorData), - callback: (index) => { - switch (index) { - case 0: - this.mAdaptiveColor = AdaptiveColor.DEFAULT - break - default: - this.mAdaptiveColor = AdaptiveColor.AVERAGE - } - } - }) - } - } -} - -@Component -export struct ShadowChangePanel { - @Link mShadowType: ShadowType - - build() { - Column() { - CommonItemSelect({ - testId: "test_select1", - name: $r('app.string.set_shadow_type'), - selects: getStringArrayData(selectShadowTypeData), - callback: (index) => { - switch (index) { - case 0: - this.mShadowType = ShadowType.COLOR - break - default: - this.mShadowType = ShadowType.BLUR - } - } - }) - } - } +/* + * Copyright (c) 2022-2023 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 { CommonItemSelect } from '../../../../common/AttributeModificationTool' +import { selectBlurStyleColorModeData, selectBlurStyleAdaptiveColorData, selectShadowTypeData} from '../../UniversialData' +import { getStringArrayData,getStringData } from '../../../../data/ResourceDataHandle' + +@Component +export struct BackgroundBlurChangePanel { + @Link mColorMode: ThemeColorMode + @Link mAdaptiveColor: AdaptiveColor + + build() { + Column() { + CommonItemSelect({ + testId: "test_select1", + name: $r('app.string.set_background_blur_style_color_mode'), + selects: getStringArrayData(selectBlurStyleColorModeData), + callback: (index) => { + switch (index) { + case 0: + this.mColorMode = ThemeColorMode.SYSTEM + break + case 1: + this.mColorMode = ThemeColorMode.LIGHT + break + default: + this.mColorMode = ThemeColorMode.DARK + } + } + }) + + CommonItemSelect({ + testId: "test_select2", + name: $r('app.string.set_background_blur_style_adaptive_color'), + selects: getStringArrayData(selectBlurStyleAdaptiveColorData), + callback: (index) => { + switch (index) { + case 0: + this.mAdaptiveColor = AdaptiveColor.DEFAULT + break + default: + this.mAdaptiveColor = AdaptiveColor.AVERAGE + } + } + }) + } + } +} + +@Component +export struct ShadowChangePanel { + @Link mShadowType: ShadowType + + build() { + Column() { + CommonItemSelect({ + testId: "test_select1", + name: $r('app.string.set_shadow_type'), + selects: getStringArrayData(selectShadowTypeData), + callback: (index) => { + switch (index) { + case 0: + this.mShadowType = ShadowType.COLOR + break + default: + this.mShadowType = ShadowType.BLUR + } + } + }) + } + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/foregroundSample/ForegroundSample.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/foregroundSample/ForegroundSample.ets index 5931b45f5c..ac534f496d 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/foregroundSample/ForegroundSample.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/foregroundSample/ForegroundSample.ets @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2022-2023 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 { IntroductionTitle } from '../../../../common/IntroductionTitle' -import { TitleBar } from '../../../../common/TitleBar' - -@Extend(Row) function rowStyle() { - .padding(8) - .height(120) - .borderRadius(24) - .backgroundColor(Color.White) - .margin({ bottom: 12 }) -} - -@Extend(Text) function textStyle(marginValue: number) { - .height(80) - .fontSize(18) - .layoutWeight(1) - .fontColor(Color.White) - .textAlign(TextAlign.Center) - .margin({ left: marginValue, right: marginValue }) -} - -@Entry -@Component -struct foreground { - - build() { - Column() { - TitleBar({ title: $r('app.string.prop_foreground') }) - Scroll() { - Column() { - IntroductionTitle({ introduction: $r('app.string.foreground_color') }) - Row() { - Text('Brand') - .textStyle(20) - .backgroundColor($r('app.color.scrollbar_background_color')) - .foregroundColor($r('app.color.background_blue')) - Text('Warning') - .textStyle(20) - .backgroundColor($r('app.color.scrollbar_background_color')) - .foregroundColor($r('app.color.background_orange')) - Text('Danger') - .textStyle(20) - .backgroundColor($r('app.color.scrollbar_background_color')) - .foregroundColor($r('app.color.background_pink')) - } - .rowStyle() - } - .padding({ left: 12, right: 12 }) - .margin({ bottom: 80 }) - .constraintSize({ minHeight: '100%' }) - } - } - .width('100%') - .backgroundColor($r('app.color.background_shallow_grey')) - } +/* + * Copyright (c) 2022-2023 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 { IntroductionTitle } from '../../../../common/IntroductionTitle' +import { TitleBar } from '../../../../common/TitleBar' + +@Extend(Row) function rowStyle() { + .padding(8) + .height(120) + .borderRadius(24) + .backgroundColor(Color.White) + .margin({ bottom: 12 }) +} + +@Extend(Text) function textStyle(marginValue: number) { + .height(80) + .fontSize(18) + .layoutWeight(1) + .fontColor(Color.White) + .textAlign(TextAlign.Center) + .margin({ left: marginValue, right: marginValue }) +} + +@Entry +@Component +struct foreground { + + build() { + Column() { + TitleBar({ title: $r('app.string.prop_foreground') }) + Scroll() { + Column() { + IntroductionTitle({ introduction: $r('app.string.foreground_color') }) + Row() { + Text('Brand') + .textStyle(20) + .backgroundColor($r('app.color.scrollbar_background_color')) + .foregroundColor($r('app.color.background_blue')) + Text('Warning') + .textStyle(20) + .backgroundColor($r('app.color.scrollbar_background_color')) + .foregroundColor($r('app.color.background_orange')) + Text('Danger') + .textStyle(20) + .backgroundColor($r('app.color.scrollbar_background_color')) + .foregroundColor($r('app.color.background_pink')) + } + .rowStyle() + } + .padding({ left: 12, right: 12 }) + .margin({ bottom: 80 }) + .constraintSize({ minHeight: '100%' }) + } + } + .width('100%') + .backgroundColor($r('app.color.background_shallow_grey')) + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/safeAreaSample/ChangePanel.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/safeAreaSample/ChangePanel.ets old mode 100755 new mode 100644 diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/safeAreaSample/SafeAreaSample.ets b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/safeAreaSample/SafeAreaSample.ets old mode 100755 new mode 100644 index a5f45070ec..cc9b30247d --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/safeAreaSample/SafeAreaSample.ets +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/safeAreaSample/SafeAreaSample.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2023-2024 Hunan OpenValley Digital Industry Development 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 { ChangePanel } from './ChangePanel' -import { IntroductionTitle } from '../../../../common/IntroductionTitle' -import { TitleBar } from '../../../../common/TitleBar' - -@Extend(Column) -function columnStyle() { - .width('90%') - .padding(16) - .margin(12) - .borderRadius(24) - .backgroundColor(Color.White) -} - -@Entry -@Component -struct SafeAreaSample { - @State mSafeAreaType: SafeAreaType[] = [SafeAreaType.CUTOUT] - @State mSafeAreaEdge: SafeAreaEdge[] = [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM] - - build() { - Column() { - Stack() { - Row() { - } - .height('100%') - .width('100%') - .backgroundImage($r('app.media.img_test_1')) - .backgroundImageSize(ImageSize.Cover) - .alignItems(VerticalAlign.Top) - .expandSafeArea(this.mSafeAreaType, this.mSafeAreaEdge) - - Column() { - TitleBar({ title: $r('app.string.safe_area') }) - Column() { - IntroductionTitle({ introduction: $r('app.string.safe_area_type_and_safe_area_edge') }) - ChangePanel({ - mSafeAreaType: $mSafeAreaType, - mSafeAreaEdge: $mSafeAreaEdge - }) - } - .columnStyle() - .alignItems(HorizontalAlign.Center) - - TextInput({ placeholder: $r('app.string.save_area_input_text') }) - .width(320) - .height(40) - .fontSize(14) - .fontColor(Color.Black) - .backgroundColor(Color.White) - .enableKeyboardOnFocus(false) - .margin({ top: 200 }) - .placeholderFont({ size: 14, weight: 400 }) - } - .width('100%') - .height('100%') - .alignItems(HorizontalAlign.Center) - } - } - .width('100%') - .height('100%') - } +/* + * Copyright (c) 2023-2024 Hunan OpenValley Digital Industry Development 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 { ChangePanel } from './ChangePanel' +import { IntroductionTitle } from '../../../../common/IntroductionTitle' +import { TitleBar } from '../../../../common/TitleBar' + +@Extend(Column) +function columnStyle() { + .width('90%') + .padding(16) + .margin(12) + .borderRadius(24) + .backgroundColor(Color.White) +} + +@Entry +@Component +struct SafeAreaSample { + @State mSafeAreaType: SafeAreaType[] = [SafeAreaType.CUTOUT] + @State mSafeAreaEdge: SafeAreaEdge[] = [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM] + + build() { + Column() { + Stack() { + Row() { + } + .height('100%') + .width('100%') + .backgroundImage($r('app.media.img_test_1')) + .backgroundImageSize(ImageSize.Cover) + .alignItems(VerticalAlign.Top) + .expandSafeArea(this.mSafeAreaType, this.mSafeAreaEdge) + + Column() { + TitleBar({ title: $r('app.string.safe_area') }) + Column() { + IntroductionTitle({ introduction: $r('app.string.safe_area_type_and_safe_area_edge') }) + ChangePanel({ + mSafeAreaType: $mSafeAreaType, + mSafeAreaEdge: $mSafeAreaEdge + }) + } + .columnStyle() + .alignItems(HorizontalAlign.Center) + + TextInput({ placeholder: $r('app.string.save_area_input_text') }) + .width(320) + .height(40) + .fontSize(14) + .fontColor(Color.Black) + .backgroundColor(Color.White) + .enableKeyboardOnFocus(false) + .margin({ top: 200 }) + .placeholderFont({ size: 14, weight: 400 }) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Center) + } + } + .width('100%') + .height('100%') + } } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/resources/ar/element/string.json b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/resources/ar/element/string.json index 20f9c01fac..0dae5b2032 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/resources/ar/element/string.json +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/resources/ar/element/string.json @@ -1,5988 +1,5988 @@ -{ - "string": [ - { - "name": "focus_control_tab_status", - "value": "مركز تنسيق نمط التبديل : لوحة المفاتيح الخارجية تبويب مفتاح التبديل مركز تنسيق عرض التغييرات" - }, - { - "name": "select_to_see_status", - "value": "اختيار نمط الدولة التبديل" - }, - { - "name": "disable_to_see_status", - "value": "تعطيل وضع نمط التبديل" - }, - { - "name": "press_to_see_status", - "value": "اضغط على مفتاح نمط الدولة" - }, - { - "name": "click_to_see_status", - "value": "الوضع العادي نمط التبديل" - }, - { - "name": "custom_event", - "value": "عنصر مخصص توزيع الحدث" - }, - { - "name": "custom_click_event_button", - "value": "نقر" - }, - { - "name": "custom_Scrolling_event_button", - "value": "توالت" - }, - { - "name": "custom_judge_title", - "value": "قاضي" - }, - { - "name": "custom_judge_long_press", - "value": "منطقة استجابة طويلة" - }, - { - "name": "custom_long_press_prompt", - "value": "اضغط على الجزء العلوي من المنطقة الزرقاء لفترة طويلة ، المنطقة الزرقاء سوف تستجيب" - }, - { - "name": "custom_judge_click", - "value": "انقر فوق منطقة الاستجابة" - }, - { - "name": "custom_tap_prompt", - "value": "انقر على الجزء السفلي من المنطقة الصفراء ، المنطقة الصفراء سوف تستجيب" - }, - { - "name": "custom_bigcircle_prompt", - "value": "العرف نصائح دائرة كبيرة" - }, - { - "name": "custom_smallcircle_prompt", - "value": "العرف نصائح دائرة صغيرة" - }, - { - "name": "custom_gesture", - "value": "العرف لفتة تحديد" - }, - { - "name": "send_event", - "value": "إرسال الحدث" - }, - { - "name": "custom_click_event", - "value": "نقر" - }, - { - "name": "custom_scrolling_event", - "value": "توالت" - }, - { - "name": "custom_scrolling_area", - "value": "منطقة التمرير" - }, - { - "name": "custom_click_big_btn", - "value": "دائرة كبيرة" - }, - { - "name": "custom_click_small_btn", - "value": "دائرة صغيرة" - }, - { - "name": "big_circle_prompt", - "value": "المنطقة الزرقاء مع دائرة الحدث" - }, - { - "name": "small_circle_prompt", - "value": "المنطقة الصفراء مع دائرة الأحداث" - }, - { - "name": "Blue", - "value": "بلو" - }, - { - "name": "button", - "value": "الأزرار" - }, - { - "name": "entry_desc", - "value": "مجموعة من المكونات" - }, - { - "name": "MainAbility_desc", - "value": "arkui العنصر ، السمة العامة ، طريقة عامة ، الخ ." - }, - { - "name": "animation", - "value": "أنمي" - }, - { - "name": "component", - "value": "مكون" - }, - { - "name": "universal", - "value": "عام ." - }, - { - "name": "global_method", - "value": "النهج العالمي" - }, - { - "name": "auxiliary", - "value": "المعدات المساعدة" - }, - { - "name": "common_properties", - "value": "السمة المشتركة" - }, - { - "name": "prop_background", - "value": "معلومات أساسية" - }, - { - "name": "safe_area", - "value": "منطقة الأمان" - }, - { - "name": "attribute_modifier", - "value": "خاصية تعديل" - }, - { - "name": "prop_foreground", - "value": "احتمال" - }, - { - "name": "prop_border", - "value": "حدود ." - }, - { - "name": "prop_outline", - "value": "مخطط" - }, - { - "name": "prop_font", - "value": "فونت" - }, - { - "name": "prop_bluefont", - "value": "#409EFF" - }, - { - "name": "prop_orangefont", - "value": "#E6A23C" - }, - { - "name": "prop_pinkfont", - "value": "#F56C6C" - }, - { - "name": "prop_size", - "value": "حجم" - }, - { - "name": "graphic_transformation", - "value": "تحويل الرسومات" - }, - { - "name": "common_events", - "value": "الأحداث المشتركة" - }, - { - "name": "click_event", - "value": "انقر فوق الحدث" - }, - { - "name": "touch_event", - "value": "لمس الحدث" - }, - { - "name": "show_hide_event", - "value": "إظهار / إخفاء الأحداث" - }, - { - "name": "drag_drop_event", - "value": "سحب وإسقاط الحدث" - }, - { - "name": "key_event", - "value": "الأحداث الرئيسية" - }, - { - "name": "focus_event", - "value": "التركيز على النشاط" - }, - { - "name": "mouse_event", - "value": "الماوس الحدث" - }, - { - "name": "component_area_change_event", - "value": "عنصر تغيير الحدث" - }, - { - "name": "gesture_processing", - "value": "لفتة تجهيز" - }, - { - "name": "basic_gestures", - "value": "لفتة الأساسية" - }, - { - "name": "tap_gesture", - "value": "انقر على لفتة" - }, - { - "name": "long_press_gesture", - "value": "لفتة طويلة" - }, - { - "name": "pan_gesture", - "value": "بانجيستور" - }, - { - "name": "pinch_gesture", - "value": "قرصة لفتة" - }, - { - "name": "rotation_gesture", - "value": "لفتة التناوب" - }, - { - "name": "swipe_gesture", - "value": "انزلاق الموقف" - }, - { - "name": "combined_gestures", - "value": "الجمع بين لفتة" - }, - { - "name": "transition_animation", - "value": "الانتقال من الرسوم المتحركة" - }, - { - "name": "interpolation_calculation", - "value": "حساب الاستيفاء" - }, - { - "name": "dialog", - "value": "الحوارات" - }, - { - "name": "button_and_selection", - "value": "أزرار واختيار" - }, - { - "name": "information_presentation_and_dynamic_effects", - "value": "عرض المعلومات و تأثير ديناميكي" - }, - { - "name": "blank_and_divider", - "value": "الفراغات و فواصل" - }, - { - "name": "text_and_input", - "value": "النص والمدخلات" - }, - { - "name": "layout_animation_expansion", - "value": "تصميم الرسوم المتحركة" - }, - { - "name": "layout_animation_expansion_align", - "value": "محاذاة الرسوم المتحركة" - }, - { - "name": "layout_animation_expansion_size", - "value": "حجم الرسوم المتحركة" - }, - { - "name": "layout_animation_expansion_padding", - "value": "ملء الرسوم المتحركة" - }, - { - "name": "layout_animation_expansion_margin", - "value": "الهوامش المتحركة" - }, - { - "name": "layout_animation_expansion_offset", - "value": "إزاحة الرسوم المتحركة" - }, - { - "name": "layout_animation_expansion_position", - "value": "الكلمات المتحركة" - }, - { - "name": "layout_animation_expansion_markAnchor", - "value": "مارك انكور للرسوم المتحركة" - }, - { - "name": "layout_animation_expansion_alignRules", - "value": "alignrules المتحركة" - }, - { - "name": "layout_animation_expansion_direction", - "value": "اتجاه الرسوم المتحركة" - }, - { - "name": "size_transition_expansion", - "value": "بعد الانتقال" - }, - { - "name": "alert_dialog", - "value": "تنبيه الحوار" - }, - { - "name": "alert_dialog_type_one", - "value": "مفتاح إنذار مربع الحوار" - }, - { - "name": "alert_dialog_type_two", - "value": "زر مزدوج مربع الحوار التنبيه" - }, - { - "name": "alert_dialog_type_two_button_one", - "value": "هذا هو الزر الأول" - }, - { - "name": "alert_dialog_type_two_button_two", - "value": "هذا هو الزر الثاني" - }, - { - "name": "alert_dialog_prompt", - "value": "جديلة" - }, - { - "name": "alert_dialog_warning", - "value": "حذر" - }, - { - "name": "alert_dialog_info", - "value": "أنت تقوم بعمل" - }, - { - "name": "alert_dialog_confirm", - "value": "أكّد" - }, - { - "name": "alert_dialog_cancel", - "value": "ألغى" - }, - { - "name": "alert_dialog_type", - "value": "نوع الحوار" - }, - { - "name": "alert_dialog_location", - "value": "موقع المحادثة" - }, - { - "name": "alert_dialog_auto_cancel", - "value": "انقر فوق طبقة قناع لإغلاق مربع الحوار" - }, - { - "name": "alert_dialog_true", - "value": "يمكن إغلاق" - }, - { - "name": "alert_dialog_false", - "value": "لم تغلق" - }, - { - "name": "alert_dialog_top", - "value": "أعلى رأسي" - }, - { - "name": "alert_dialog_center", - "value": "مركز عمودي" - }, - { - "name": "alert_dialog_bottom", - "value": "عمودي أسفل" - }, - { - "name": "alert_dialog_offset", - "value": "الموقف النسبي إزاحة مربع الحوار" - }, - { - "name": "alert_dialog_left", - "value": "أعلى اليسار ويقابل" - }, - { - "name": "alert_dialog_right", - "value": "أسفل اليمين ويقابل" - }, - { - "name": "alert_dialog_grid", - "value": "شبكة مختلفة عرض مربع الحوار" - }, - { - "name": "alert_dialog_grid_two", - "value": "عرض الشبكة" - }, - { - "name": "alert_dialog_grid_three", - "value": "عرض الشبكة" - }, - { - "name": "alert_dialog_grid_four", - "value": "عرض الشبكة" - }, - { - "name": "foreground_color", - "value": "تعيين لون المقدمة" - }, - { - "name": "background_color", - "value": "تعيين لون الخلفية" - }, - { - "name": "background_gradient", - "value": "تعيين خلفية التدرج" - }, - { - "name": "background_gradient_linear", - "value": "التدرج الخطي" - }, - { - "name": "background_gradient_sweep", - "value": "زاوية الانحدار" - }, - { - "name": "background_gradient_radial", - "value": "شعاعي التدرج" - }, - { - "name": "background_image_transformation_effect", - "value": "تحويل صورة الخلفية" - }, - { - "name": "set_background_image_size", - "value": "تعيين حجم الصورة الخلفية" - }, - { - "name": "set_background_image_position", - "value": "وضع صورة الخلفية" - }, - { - "name": "background_image_size_cover", - "value": "تغطية" - }, - { - "name": "background_image_size_contain", - "value": "احتواء" - }, - { - "name": "background_image_position_top_start", - "value": "توب ستارت" - }, - { - "name": "background_image_position_top", - "value": "توب ." - }, - { - "name": "background_image_position_top_end", - "value": "توبند" - }, - { - "name": "background_image_position_start", - "value": "توب ." - }, - { - "name": "background_image_position_center", - "value": "مركز" - }, - { - "name": "background_image_position_end", - "value": "نهاية ." - }, - { - "name": "background_image_position_bottom_start", - "value": "بداية القاع" - }, - { - "name": "background_image_position_bottom", - "value": "القاع" - }, - { - "name": "background_image_position_bottom_end", - "value": "نهاية القاع" - }, - { - "name": "background_image", - "value": "تعيين صورة الخلفية" - }, - { - "name": "background_image_default", - "value": "خرق" - }, - { - "name": "background_image_repeat", - "value": "س ص محور تكرار الرسم البياني" - }, - { - "name": "background_image_size", - "value": "حجم الصورة 50% عرض 100% ارتفاع" - }, - { - "name": "background_image_offset", - "value": "صورة الكلمات يقابلها إلى اليمين أو إلى الأسفل" - }, - { - "name": "auxiliary_badge", - "value": "شارات" - }, - { - "name": "badge_type", - "value": "نوع التسمية" - }, - { - "name": "badge_number", - "value": "العلامات الرقمية" - }, - { - "name": "badge_string", - "value": "نص التسمية" - }, - { - "name": "badge_max", - "value": "العلامة الرقمية أقصى عدد من الرسائل" - }, - { - "name": "badge_number_normal", - "value": "شارة عادية" - }, - { - "name": "badge_number_max", - "value": "ماكس شارات" - }, - { - "name": "badge_location", - "value": "وضع علامة" - }, - { - "name": "badge_left", - "value": "علامة على اليسار" - }, - { - "name": "badge_top", - "value": "أعلى اليمين التسمية" - }, - { - "name": "badge_right", - "value": "علامة الحق" - }, - { - "name": "badge_style", - "value": "علامة نمط" - }, - { - "name": "badge_blue", - "value": "علامة زرقاء كبيرة" - }, - { - "name": "badge_green", - "value": "علامة خضراء صغيرة" - }, - { - "name": "border_type", - "value": "نوع الحدود" - }, - { - "name": "border_type_dashed", - "value": "خط منقط" - }, - { - "name": "border_type_dotted", - "value": "نقطة" - }, - { - "name": "border_type_solid", - "value": "خط صلب" - }, - { - "name": "border_border_style", - "value": "عرض الحدود ، اللون ، فيليه" - }, - { - "name": "border_border_width", - "value": "عرض" - }, - { - "name": "border_border_color", - "value": "الألوان" - }, - { - "name": "border_border_radius", - "value": "فيليه" - }, - { - "name": "border_edge_style", - "value": "تعيين الحدود ، والأساليب ، والصفات ، على التوالي" - }, - { - "name": "border_style_top", - "value": "أعلى الحدود" - }, - { - "name": "border_style_bottom", - "value": "أسفل الحدود" - }, - { - "name": "border_style_left", - "value": "الحدود اليسرى" - }, - { - "name": "border_style_right", - "value": "الحدود اليمنى" - }, - { - "name": "border_radius", - "value": "تعيين أربع زوايا مستديرة" - }, - { - "name": "border_radius_left_top", - "value": "الحدود العليا اليسرى" - }, - { - "name": "border_radius_left_bottom", - "value": "أسفل اليسار الحدود" - }, - { - "name": "border_radius_right_top", - "value": "الحدود العليا اليمنى" - }, - { - "name": "border_radius_right_bottom", - "value": "أسفل الحدود اليمنى" - }, - { - "name": "border_3D", - "value": "تعيين الحدود ثلاثية الأبعاد" - }, - { - "name": "outline_text", - "value": "مخطط" - }, - { - "name": "outline_effect", - "value": "تأثير توقعات" - }, - { - "name": "outline_button", - "value": "الأزرار" - }, - { - "name": "button_title", - "value": "الأزرار" - }, - { - "name": "button_type", - "value": "نوع ." - }, - { - "name": "button_confirm", - "value": "أكّد" - }, - { - "name": "button_type_capsule", - "value": "الكبسولة" - }, - { - "name": "button_type_normal", - "value": "عادي ." - }, - { - "name": "button_type_circle", - "value": "دائرة" - }, - { - "name": "button_state_effect", - "value": "تأثير الدولة" - }, - { - "name": "button_state_effect_true", - "value": "تأثير" - }, - { - "name": "button_state_effect_false", - "value": "لا تأثير" - }, - { - "name": "button_disable_style", - "value": "تعطيل" - }, - { - "name": "button_custom_style", - "value": "نمط مخصص" - }, - { - "name": "button_border_radius", - "value": "جولة زر" - }, - { - "name": "button_with_icon", - "value": "زر الأيقونات" - }, - { - "name": "button_custom_bg_color", - "value": "لون مخصص" - }, - { - "name": "button_click", - "value": "اضغط على زر" - }, - { - "name": "click_action_tips", - "value": "انقر فوق المنطقة الرمادية لتغيير موقف الصليب" - }, - { - "name": "touch_action_tips", - "value": "لمس المنطقة الرمادية والانتقال إلى تغيير موقف الصليب" - }, - { - "name": "component_area_change_action_tips", - "value": "انزلاق يمكن تغيير حجم أو موقف المنطقة الرمادية للسيطرة على حركة الكرة في المنطقة" - }, - { - "name": "get_click_event_detail", - "value": "انقر على معلومات الموقع" - }, - { - "name": "drag_drop_action_tips", - "value": "اضغط على أيقونة التطبيق لفترة طويلة واسحب إلى مناطق مختلفة" - }, - { - "name": "component_drag_and_drop", - "value": "عنصر السحب والإفلات" - }, - { - "name": "griditem", - "value": "شبكة البند" - }, - { - "name": "multiselect", - "value": "اختيار متعددة" - }, - { - "name": "listitem", - "value": "قائمة البنود" - }, - { - "name": "hyperlink", - "value": "ارتباط تشعبي" - }, - { - "name": "text", - "value": "نص ." - }, - { - "name": "image", - "value": "صور" - }, - { - "name": "video", - "value": "فيديو : ." - }, - { - "name": "formcomponent", - "value": "شكل العنصر" - }, - { - "name": "custom_dialog", - "value": "تخصيص مربع الحوار" - }, - { - "name": "custom_dialog_style_custom", - "value": "مربع الحوار نمط مخصص" - }, - { - "name": "custom_dialog_style_custom_true", - "value": "عرف" - }, - { - "name": "custom_dialog_style_custom_false", - "value": "غير مخصص" - }, - { - "name": "custom_dialog_title", - "value": "طلب تمكين الأذونات التالية" - }, - { - "name": "custom_dialog_permission_microphone", - "value": "ميكروفون السلطة" - }, - { - "name": "custom_dialog_permission_microphone_info", - "value": "المكالمات الصوتية تتطلب إذن الميكروفون" - }, - { - "name": "custom_dialog_permission_location", - "value": "موقع السلطة" - }, - { - "name": "custom_dialog_permission_location_info", - "value": "الملاحة يتطلب إذن الموقع" - }, - { - "name": "custom_dialog_start", - "value": "فتح" - }, - { - "name": "date_picker_dialog", - "value": "تاريخ محدد" - }, - { - "name": "date_picker_dialog_date", - "value": "عرض تاريخ الحوار" - }, - { - "name": "date_picker_dialog_date_lunar", - "value": "التاريخ القمري" - }, - { - "name": "date_picker_dialog_date_gregorian", - "value": "تاريخ التقويم الغريغوري" - }, - { - "name": "date_picker_dialog_cancel", - "value": "ألغى" - }, - { - "name": "date_picker_toast_date", - "value": "اختيار الوقت :" - }, - { - "name": "date_picker_dialog_datetimeone", - "value": "2022-10-01" - }, - { - "name": "date_picker_dialog_datetimetwo", - "value": "1970-1-1" - }, - { - "name": "date_picker_dialog_datetimethree", - "value": "2100-12-31" - }, - { - "name": "date_picker_title", - "value": "تاريخ محدد" - }, - { - "name": "date_picker_lunar", - "value": "القمر" - }, - { - "name": "divider_title", - "value": "تحويلة" - }, - { - "name": "divider_stroke_width", - "value": "عرض السكتة الدماغية" - }, - { - "name": "divider_line_color", - "value": "لون الخط" - }, - { - "name": "divider_line_cap", - "value": "لين كابستيل" - }, - { - "name": "divider_horizontal", - "value": "الاتجاه الأفقي" - }, - { - "name": "divider_vertical", - "value": "عمودي" - }, - { - "name": "divider_attribute", - "value": "تحويلة" - }, - { - "name": "font_color", - "value": "الألوان" - }, - { - "name": "font_size", - "value": "حجم" - }, - { - "name": "font_thickness", - "value": "سمك ." - }, - { - "name": "font_style", - "value": "أسلوب ." - }, - { - "name": "interpolation_calculation_cubic_bezier_curve", - "value": "ثالث ترتيب منحنى بيزيير الكائن" - }, - { - "name": "interpolation_calculation_spring", - "value": "منحنى الربيع الكائن" - }, - { - "name": "interpolation_calculation_init_curve", - "value": "easein منحنى تفاضلي" - }, - { - "name": "interpolation_calculation_steps_curve", - "value": "سلم منحنى الكائن" - }, - { - "name": "page_transition", - "value": "التحويل بين الصفحات" - }, - { - "name": "page_transition_left", - "value": "مدخل / مخرج يمين يسار" - }, - { - "name": "page_transition_right", - "value": "المدخل الأيمن / المخرج الأيسر" - }, - { - "name": "page_transition_top", - "value": "أعلى مدخل / مخرج أسفل" - }, - { - "name": "page_transition_bottom", - "value": "أسفل مدخل / مخرج أعلى" - }, - { - "name": "page_transition_scale", - "value": "تكبير / تصغير" - }, - { - "name": "page_transition_rotate", - "value": "برغي في / خارج" - }, - { - "name": "page_transition_back", - "value": "تحويل صفحة العودة بين الصفحات" - }, - { - "name": "qrcode_title", - "value": "قركودي" - }, - { - "name": "qrcode_content", - "value": "المحتويات" - }, - { - "name": "qrcode_color", - "value": "الألوان" - }, - { - "name": "qrcode_enter_content", - "value": "أدخل تغيير رمز ثنائي الأبعاد" - }, - { - "name": "search_placeholder", - "value": "اكتب البحث ." - }, - { - "name": "search_name", - "value": "بحث ." - }, - { - "name": "radio_title", - "value": "راديو ." - }, - { - "name": "radio_no_response_region", - "value": "لا إضافة منطقة استجابة ( اضغط على زر الدخول )" - }, - { - "name": "radio_has_response_region", - "value": "إضافة منطقة استجابة ( انقر على زر خط )" - }, - { - "name": "radio_beijing", - "value": "بيجينغ" - }, - { - "name": "radio_shanghai", - "value": "شنغهاي ." - }, - { - "name": "radio_shenzhen", - "value": "شن تشن" - }, - { - "name": "radio_guangzhou", - "value": "غوانغ زهو" - }, - { - "name": "graphic_transformation_rotate", - "value": "استدارة" - }, - { - "name": "rotate_photo", - "value": "صورة التناوب" - }, - { - "name": "rotate_container", - "value": "عنصر التناوب" - }, - { - "name": "rotate_before_image", - "value": "الصورة الأصلية" - }, - { - "name": "rotate_before_component", - "value": "حاوية الجمعية" - }, - { - "name": "rotate_image_angle", - "value": "دوران" - }, - { - "name": "select_title", - "value": "مختار" - }, - { - "name": "select_has_icon", - "value": "اختيار الرموز" - }, - { - "name": "select_option_bg_and_text_style", - "value": "اختيار لون الخلفية و نمط النص" - }, - { - "name": "select_unselect_option_style", - "value": "خيارات الخلفية و نمط النص" - }, - { - "name": "select_button_style", - "value": "زر القائمة المنسدلة نمط النص" - }, - { - "name": "select_picture", - "value": "صور ." - }, - { - "name": "select_collection", - "value": "جمع" - }, - { - "name": "select_gesture", - "value": "الإيماءات" - }, - { - "name": "select_index", - "value": "حدد مؤشر الخيارات :" - }, - { - "name": "select_value", - "value": "قيمة الخيار المختار :" - }, - { - "name": "share_element_transition", - "value": "عنصر مشترك عملة" - }, - { - "name": "Multiplex_interface", - "value": "معدد" - }, - { - "name": "Floating_window", - "value": "نافذة عائمة" - }, - { - "name": "Tips_call", - "value": "إنتظر" - }, - { - "name": "Font_family_regular", - "value": "هارمونيوس اس سي روتاري" - }, - { - "name": "Font_family_medium", - "value": "هارمونيوس سان SC متوسطة" - }, - { - "name": "Folder_expansion", - "value": "مجلد التمديد" - }, - { - "name": "Shop_card_expansion", - "value": "تمديد بطاقة المحل" - }, - { - "name": "Today", - "value": "اليوم ." - }, - { - "name": "Gallery_card_expansion", - "value": "معرض بطاقة التمديد" - }, - { - "name": "size_width", - "value": "عرض" - }, - { - "name": "size_width_fixed_100vp", - "value": "عرض 100vp" - }, - { - "name": "size_width_percent", - "value": "عرض 60%" - }, - { - "name": "size_width_fixed_60vw", - "value": "عرض" - }, - { - "name": "size_height", - "value": "ارتفاع" - }, - { - "name": "size_height_fixed_60vh", - "value": "عرض 60vh" - }, - { - "name": "size_height_fixed_100vp", - "value": "ارتفاع 100vp" - }, - { - "name": "size_height_percent", - "value": "ارتفاع 60%" - }, - { - "name": "size_height_fixed_calc", - "value": "الارتفاع هو القيمة المحسوبة ( 200vp-100vp ) ." - }, - { - "name": "slider_title", - "value": "المنزلق" - }, - { - "name": "slider_step_tip", - "value": "خطوات ونصائح ( الخطوة 10 )" - }, - { - "name": "slider_current_value", - "value": "عرض القيمة الحالية ( مين - 50 / ماكس - 130 )" - }, - { - "name": "slider_events", - "value": "النشاطات" - }, - { - "name": "slider_attributes", - "value": "صفة" - }, - { - "name": "slider_vertical_reverse", - "value": "عمودي وعكس" - }, - { - "name": "slider_forward", - "value": "فورورد" - }, - { - "name": "slider_reverse", - "value": "عكس" - }, - { - "name": "slider_select_color", - "value": "اختيار اللون" - }, - { - "name": "slider_track_color", - "value": "لون المسار" - }, - { - "name": "slider_block_color", - "value": "لون مربع" - }, - { - "name": "slider_track_thickness", - "value": "سمك المسار" - }, - { - "name": "slider_event_begin", - "value": "تبدأ سحب شريط التمرير" - }, - { - "name": "slider_event_moving", - "value": "أثناء سحب شريط التمرير" - }, - { - "name": "slider_event_end", - "value": "نهاية سحب شريط التمرير" - }, - { - "name": "slider_event_click", - "value": "انقر فوق شريط التمرير لنقل شريط التمرير الموقف" - }, - { - "name": "slider_title_value", - "value": "النسبة المئوية من مجموع طول الشريحة :" - }, - { - "name": "span_title", - "value": "فترة طويلة من الزمن ، بما في ذلك فترة طويلة من الزمن" - }, - { - "name": "span_attribute", - "value": "تكوين خصائص مختلفة تمتد" - }, - { - "name": "span_content_one", - "value": "خفف من الصلب في النار والتبريد السريع ،" - }, - { - "name": "span_content_two", - "value": "لذلك يمكن أن يكون من الصعب ، لا تخاف من أي شيء ." - }, - { - "name": "span_content_three", - "value": "ومن خلال هذه الطريقة أن جيلنا قد تدرب على النضال و التجارب الرهيبة ،" - }, - { - "name": "span_content_four", - "value": "تعلم عدم الاستسلام للحياة ." - }, - { - "name": "span_decoration_and_letter_spacing", - "value": "الديكور و تباعد الحروف" - }, - { - "name": "span_letter_spacing", - "value": "تباعد الحروف" - }, - { - "name": "span_line_height", - "value": "خط الطول" - }, - { - "name": "span_decoration_type", - "value": "نوع الديكور" - }, - { - "name": "span_text_decoration", - "value": "الديكور اختبار النص" - }, - { - "name": "span_text_spacing", - "value": "رسالة الفضاء اختبار النص" - }, - { - "name": "span_inherits_text_attribute", - "value": "سبان يرث خصائص النص" - }, - { - "name": "span_does_not_inherit_text_attribute", - "value": "سبان لا ترث خصائص النص" - }, - { - "name": "span_upper_lower", - "value": "كبيرة أو صغيرة" - }, - { - "name": "span_decoration_color", - "value": "لون الديكور" - }, - { - "name": "span_decoration_none", - "value": "هل أنت بخير ؟ - لا -" - }, - { - "name": "span_decoration_linethrough", - "value": "خط مباشر" - }, - { - "name": "span_decoration_underline", - "value": "التأكيد" - }, - { - "name": "span_decoration_overline", - "value": "على الخط" - }, - { - "name": "image_span_title", - "value": "صورة تمتد" - }, - { - "name": "image_span_vertical_align", - "value": "المحاذاة العمودية" - }, - { - "name": "image_span_alignment_baseline", - "value": "خط الأساس" - }, - { - "name": "image_span_alignment_bottom", - "value": "القاع" - }, - { - "name": "image_span_alignment_center", - "value": "مركز" - }, - { - "name": "image_span_alignment_top", - "value": "توب ." - }, - { - "name": "image_span_object_fit", - "value": "موضوع مطابقة" - }, - { - "name": "image_fit_contain", - "value": "احتواء" - }, - { - "name": "image_fit_auto", - "value": "السيارات" - }, - { - "name": "image_fit_fill", - "value": "ملأ" - }, - { - "name": "image_fit_none", - "value": "هل أنت بخير ؟ - لا -" - }, - { - "name": "image_fit_scale_down", - "value": "تقليص حجم" - }, - { - "name": "image_fit_cover", - "value": "تغطية" - }, - { - "name": "image_span_and_span", - "value": "صورة تمتد تمتد" - }, - { - "name": "image_span_vertical_align_and_object_fit", - "value": "المحاذاة العمودية و موضوع تركيب الصورة تمتد" - }, - { - "name": "text_title", - "value": "نص ." - }, - { - "name": "text_width", - "value": "عرض النص" - }, - { - "name": "text_height", - "value": "ارتفاع النص" - }, - { - "name": "text_content", - "value": "خفف من الصلب في النار والتبريد السريع ، بحيث يمكن أن يكون من الصعب جدا ، لا تخافوا من أي شيء . وبهذه الطريقة فقط ، فإن جيلنا قد شحذ في النضال و التجارب الرهيبة و تعلمت عدم الاستسلام للحياة ." - }, - { - "name": "text_text_align_center", - "value": "مركز" - }, - { - "name": "text_text_align_start", - "value": "نقطة الانطلاق" - }, - { - "name": "text_text_align_end", - "value": "نهاية ." - }, - { - "name": "text_decoration_type", - "value": "نص نوع الديكور" - }, - { - "name": "text_decoration_type_under_line", - "value": "دوونلين" - }, - { - "name": "text_decoration_type_line_through", - "value": "من خلال خط" - }, - { - "name": "text_decoration_type_over_line", - "value": "أكثر من خط" - }, - { - "name": "text_text_align_type", - "value": "محاذاة النص" - }, - { - "name": "text_letter_spacing", - "value": "تباعد الحروف" - }, - { - "name": "text_overflow", - "value": "تجاوز النص" - }, - { - "name": "text_none", - "value": "هل أنت بخير ؟ - لا -" - }, - { - "name": "text_text_over_flow_clip", - "value": "قطع" - }, - { - "name": "text_text_over_flow_ellipsis", - "value": "القطع الناقص" - }, - { - "name": "text_line_height", - "value": "خط الطول" - }, - { - "name": "text_font_color", - "value": "لون الخط" - }, - { - "name": "text_over_flow", - "value": "تجاوز النص" - }, - { - "name": "text_text_case_normal", - "value": "عادي ." - }, - { - "name": "text_text_case", - "value": "حالة النص" - }, - { - "name": "text_text_case_uppercase", - "value": "حروف" - }, - { - "name": "text_text_case_lowercase", - "value": "حروف صغيرة" - }, - { - "name": "text_area_set_text_selection", - "value": "حدد النص" - }, - { - "name": "text_area_set_text_selection_start_select_error", - "value": "خطأ في تحديد بداية اختيار النص" - }, - { - "name": "text_area_set_text_selection_end_select_error", - "value": "خطأ في تحديد نهاية اختيار النص" - }, - { - "name": "text_input_set_text_selection_start_select", - "value": "بدء اختيار :" - }, - { - "name": "text_input_set_text_selection_end_select", - "value": "نهاية الاختيار :" - }, - { - "name": "avoiding_input_method_testing", - "value": "تجنب اختبار طريقة الإدخال" - }, - { - "name": "text_input_title", - "value": "مربع إدخال النص" - }, - { - "name": "text_input_normal_type", - "value": "الأرقام ، الحروف ، يؤكد ، والمسافات ، أحرف خاصة ." - }, - { - "name": "text_input_password_type", - "value": "أدخل كلمة السر" - }, - { - "name": "text_input_email_type", - "value": "أدخل البريد الإلكتروني" - }, - { - "name": "text_input_number_type", - "value": "وضع الإدخال الرقمي" - }, - { - "name": "text_input_phone_type", - "value": "Digits, spaces, plus signs (+), hyphens (-), asterisks (*), and number signs (#)" - }, - { - "name": "text_input_input_type", - "value": "نوع الإدخال" - }, - { - "name": "text_input_current_type", - "value": "النوع الحالي" - }, - { - "name": "text_input_show_password_icon", - "value": "عرض رمز كلمة السر" - }, - { - "name": "text_input_icon_show", - "value": "عرض ." - }, - { - "name": "text_input_icon_hide", - "value": "أخفى" - }, - { - "name": "text_input_event", - "value": "النشاطات" - }, - { - "name": "text_input_event_placeholder", - "value": "نسخ ، لصق ، قص ، ارتكاب ، تحرير الحدث" - }, - { - "name": "text_input_placeholder_style", - "value": "نمط النائبة" - }, - { - "name": "text_input_placeholder", - "value": "النائبة" - }, - { - "name": "text_input_filter", - "value": "فلتر الإدخال" - }, - { - "name": "text_input_only_input_english", - "value": "فقط أدخل الحروف الإنجليزية" - }, - { - "name": "text_input_caret_position", - "value": "موقف التمريض" - }, - { - "name": "text_input_set_text_selection", - "value": "حدد النص" - }, - { - "name": "text_input_max_length", - "value": "الحد من إدخال حرف طول" - }, - { - "name": "text_input_placeholder_max_length", - "value": "ما يصل إلى 12 حرفا" - }, - { - "name": "text_input_toast_paste", - "value": "لصق النص كما يلي :" - }, - { - "name": "text_input_toast_cut", - "value": "قص النص كما يلي :" - }, - { - "name": "text_input_toast_copy", - "value": "نسخ النص كما يلي :" - }, - { - "name": "text_input_toast_submit", - "value": "وفيما يلي نص الطلب :" - }, - { - "name": "text_input_toast_edit", - "value": "نص منقح كما يلي :" - }, - { - "name": "time_picker_dialog", - "value": "وقت الحوار" - }, - { - "name": "time_picker_dialog_time", - "value": "عرض مربع الحوار الوقت" - }, - { - "name": "time_picker_dialog_24_hour", - "value": "ساعة" - }, - { - "name": "time_picker_dialog_12_hour", - "value": "ح" - }, - { - "name": "time_picker_dialog_cancel", - "value": "ألغى" - }, - { - "name": "time_picker_toast_time", - "value": "اختيار الوقت :" - }, - { - "name": "time_picker_options_usemilitarytime", - "value": "استخدام الوقت العسكري" - }, - { - "name": "time_picker_dialog_timeone", - "value": "00 : 00" - }, - { - "name": "time_picker_dialog_timetwo", - "value": "10 / 01 / 2022 12 : 00" - }, - { - "name": "toggle_title", - "value": "تبديل" - }, - { - "name": "toggle_select", - "value": "مختار" - }, - { - "name": "toggle_unselect", - "value": "لا خيار" - }, - { - "name": "toggle_type_switch", - "value": "التبديل" - }, - { - "name": "checkbox", - "value": "خانة الاختيار" - }, - { - "name": "toggle_type_checkbox", - "value": "خانة الاختيار" - }, - { - "name": "toggle_type_button", - "value": "الأزرار" - }, - { - "name": "toggle_state", - "value": "مختار" - }, - { - "name": "graphic_transformation_translate", - "value": "ترجمة ." - }, - { - "name": "translate_image", - "value": "صورة الترجمة" - }, - { - "name": "translate_container", - "value": "عنصر الترجمة" - }, - { - "name": "translate_x_axis", - "value": "المحور العاشر" - }, - { - "name": "translate_y_axis", - "value": "المحور الصادي" - }, - { - "name": "components_display", - "value": "عرض" - }, - { - "name": "components_interaction", - "value": "تفاعلي" - }, - { - "name": "components_interaction_menuone", - "value": "قائمة البند 1" - }, - { - "name": "components_interaction_menutwo", - "value": "قائمة البند 2" - }, - { - "name": "components_interaction_menuthree", - "value": "قائمة البند 3" - }, - { - "name": "components_interaction_menufour", - "value": "قائمة البند 4" - }, - { - "name": "components_interaction_clicktextone", - "value": "معلومات أساسية" - }, - { - "name": "components_interaction_clicktexttwo", - "value": "مكان" - }, - { - "name": "components_interaction_clicktextthree", - "value": "فورجروند كيدز" - }, - { - "name": "components_interaction_hittestbehavior", - "value": "Hittest السلوك :" - }, - { - "name": "components_interaction_hovereffect", - "value": "تأثير تعليق" - }, - { - "name": "components_interaction_backgroundresponse", - "value": "انقر على خلفية الرد" - }, - { - "name": "components_interaction_foregroundresponse", - "value": "استجابة الجبهة انقر" - }, - { - "name": "components_interaction_contentresponse", - "value": "محتوى الرد انقر" - }, - { - "name": "components_display_content", - "value": "ABCDEFG" - }, - { - "name": "components_display_center", - "value": "مركز" - }, - { - "name": "components_display_topstart", - "value": "بداية" - }, - { - "name": "components_display_topend", - "value": "أعلى" - }, - { - "name": "components_display_top", - "value": "توب ." - }, - { - "name": "components_display_start", - "value": "بداية ." - }, - { - "name": "components_display_end", - "value": "نهاية ." - }, - { - "name": "components_display_bottomstart", - "value": "أسفل الحذاء" - }, - { - "name": "components_display_bottom", - "value": "القاع" - }, - { - "name": "components_display_bottomend", - "value": "رئيس كبير" - }, - { - "name": "components_display_none", - "value": "هل أنت بخير ؟ - لا -" - }, - { - "name": "components_display_hidden", - "value": "أخفى" - }, - { - "name": "components_display_visible", - "value": "مرئي" - }, - { - "name": "components_effects", - "value": "أثر" - }, - { - "name": "blur_effects", - "value": "تأثير ضبابي" - }, - { - "name": "blur_radius_modify", - "value": "نصف قطر غامض" - }, - { - "name": "background_blur", - "value": "الخلفية ضبابية" - }, - { - "name": "background_blur_style", - "value": "طمس الخلفية نمط" - }, - { - "name": "set_shadow_type", - "value": "تعيين نوع الظل" - }, - { - "name": "shadow_effects", - "value": "تأثير الظل" - }, - { - "name": "shadow_effects_content", - "value": "تأثير الظل" - }, - { - "name": "offset_min", - "value": "- 40" - }, - { - "name": "offset_max", - "value": "٤٠" - }, - { - "name": "x_offset", - "value": "س تعويض" - }, - { - "name": "y_offset", - "value": "ذ تعويض" - }, - { - "name": "shadow", - "value": "شادو" - }, - { - "name": "blur", - "value": "طمس" - }, - { - "name": "effects", - "value": "تأثير" - }, - { - "name": "effects_display", - "value": "عرض" - }, - { - "name": "grayscale_change", - "value": "مقياس الرمادية" - }, - { - "name": "brightness_change", - "value": "سطوع" - }, - { - "name": "saturate_change", - "value": "نقع" - }, - { - "name": "constrast_change", - "value": "قيد" - }, - { - "name": "invert_change", - "value": "تحويل" - }, - { - "name": "sepia_change", - "value": "الإنتان" - }, - { - "name": "hueRotate_change", - "value": "هيو روت" - }, - { - "name": "color_blend_change", - "value": "خلط الألوان" - }, - { - "name": "spherical_effect_change", - "value": "تأثير المجال" - }, - { - "name": "light_up_effect_change", - "value": "تأثير الإضاءة" - }, - { - "name": "pixel_stretch_effect_change", - "value": "تأثير بكسل تمتد" - }, - { - "name": "z_index", - "value": "ض مؤشر" - }, - { - "name": "overlay", - "value": "تغطية طبقة" - }, - { - "name": "visibility", - "value": "وضوح" - }, - { - "name": "opacity", - "value": "التعتيم" - }, - { - "name": "z_index_display", - "value": "ض مؤشر" - }, - { - "name": "Red", - "value": "رد : ." - }, - { - "name": "Yellow", - "value": "أصفر" - }, - { - "name": "positon_modify", - "value": "الوظائف" - }, - { - "name": "offset_modify", - "value": "قابل" - }, - { - "name": "visibility_change", - "value": "وضوح" - }, - { - "name": "opacity_change", - "value": "التعتيم" - }, - { - "name": "opacity_display", - "value": "التعتيم عرض" - }, - { - "name": "item_select", - "value": "قائمة البند" - }, - { - "name": "disabled", - "value": "المعوقون" - }, - { - "name": "button_disabled", - "value": "زر تعطيل" - }, - { - "name": "list_disabled", - "value": "قائمة المعوقين" - }, - { - "name": "focus", - "value": "فوكوس" - }, - { - "name": "popup_window", - "value": "نافذة منبثقة" - }, - { - "name": "touch_test", - "value": "لمس ." - }, - { - "name": "touch_region", - "value": "منطقة" - }, - { - "name": "hovereffect", - "value": "تحوم" - }, - { - "name": "bind_menu_customBuilder", - "value": "ربط القائمة custombuilder" - }, - { - "name": "bind_content_menu", - "value": "ربط محتوى القائمة" - }, - { - "name": "click_on_any_action_below", - "value": "انقر فوق أي من الإجراءات التالية" - }, - { - "name": "long_press_any_action_below", - "value": "اضغط على أي من العمليات التالية لفترة طويلة" - }, - { - "name": "bind_menu_content", - "value": "ربط محتوى القائمة" - }, - { - "name": "menu", - "value": "قائمة" - }, - { - "name": "multiState", - "value": "العديد من الدول" - }, - { - "name": "multi_short_key", - "value": "مفاتيح متعددة قصيرة" - }, - { - "name": "set_mouse_style", - "value": "تعيين نمط الماوس" - }, - { - "name": "multimode_input", - "value": "مدخلات المتعدد" - }, - { - "name": "short_key_pressed", - "value": "اضغط على مفتاح قصير" - }, - { - "name": "on_short_key", - "value": "وفي الوقت نفسه ، اضغط على مفتاح الاختصار السيطرة + لتحريك الحدث عن طريق النقر على الزر التالي" - }, - { - "name": "alert", - "value": "تنبيه" - }, - { - "name": "result", - "value": "نتيجة" - }, - { - "name": "popup", - "value": "نافذة منبثقة" - }, - { - "name": "custom_popup", - "value": "العرف المنبثقة" - }, - { - "name": "touch_test_region", - "value": "لمس منطقة الاختبار" - }, - { - "name": "action_sheet_dialog", - "value": "طاولة العمليات في مربع الحوار" - }, - { - "name": "action_sheet_title_autoCancel", - "value": "إذا كانت نافذة منبثقة تلقائيا إلغاء" - }, - { - "name": "action_sheet_click_sheets", - "value": "انقر فوق خيارات المحتوى" - }, - { - "name": "action_sheet_dialog_click_content", - "value": "انقر على المحتوى" - }, - { - "name": "text_picker_dialog", - "value": "نص محدد في مربع الحوار" - }, - { - "name": "text_picker_show", - "value": "عرض مربع الحوار النص" - }, - { - "name": "text_picker_click_text", - "value": "انقر فوق النص" - }, - { - "name": "text_picker_text_peach", - "value": "خوخ ." - }, - { - "name": "text_picker_text_apple", - "value": "تفاحة ." - }, - { - "name": "text_picker_text_orange", - "value": "برتقالي" - }, - { - "name": "text_picker_text_grape", - "value": "كرمة" - }, - { - "name": "text_picker_text_banana", - "value": "موز ." - }, - { - "name": "global_menu", - "value": "ربط قائمة السياق" - }, - { - "name": "global_menu_create_way", - "value": "طريقة الخلق" - }, - { - "name": "global_menu_click_right", - "value": "انقر بزر الماوس الأيمن فوق" - }, - { - "name": "global_menu_long_press", - "value": "الصحافة طويلة" - }, - { - "name": "global_menu_close", - "value": "انقر فوق إغلاق القائمة" - }, - { - "name": "component_transition", - "value": "عنصر التحويل" - }, - { - "name": "component_transition_show", - "value": "عرض ." - }, - { - "name": "component_transition_hide", - "value": "أخفى" - }, - { - "name": "attribute_animation", - "value": "خاصية الرسوم المتحركة" - }, - { - "name": "motion_path", - "value": "مسار الرسوم المتحركة" - }, - { - "name": "animate_to", - "value": "عرض الرسوم المتحركة" - }, - { - "name": "animate_over", - "value": "الانتهاء من الرسوم المتحركة" - }, - { - "name": "attribute_animation_change_size", - "value": "تغيير الحجم" - }, - { - "name": "attribute_animation_play_complete", - "value": "الانتهاء من اللعب" - }, - { - "name": "attribute_animation_unlimited_playback", - "value": "اللعب غير محدود" - }, - { - "name": "attribute_animation_play_speed", - "value": "سرعة اللعب" - }, - { - "name": "attribute_animation_delay", - "value": "تأخير 3 ثوان" - }, - { - "name": "attribute_animation_set_curve", - "value": "تعيين منحنى" - }, - { - "name": "attribute_animation_change_rotation", - "value": "تغيير التناوب" - }, - { - "name": "attribute_animation_play_count", - "value": "لعب" - }, - { - "name": "motion_path_click_me", - "value": "انقر على لي" - }, - { - "name": "general_mount", - "value": "تحميل وتفريغ الحدث" - }, - { - "name": "general_mount_toast", - "value": "جبل الصورة" - }, - { - "name": "general_unmount_toast", - "value": "إلغاء تثبيت الصورة" - }, - { - "name": "general_mount_text", - "value": "انقر فوق تحميل الصور غير المحملة" - }, - { - "name": "general_drag", - "value": "سحب وإسقاط الحدث" - }, - { - "name": "general_drag_text_one", - "value": "هنا ثلاثة عناصر النص ، اضغط باستمرار على النص واسحبه إلى القائمة أدناه" - }, - { - "name": "general_drag_text_two", - "value": "هذا هو عنصر القائمة" - }, - { - "name": "drag_list_one", - "value": "1 ." - }, - { - "name": "drag_list_two", - "value": "2 ." - }, - { - "name": "drag_list_three", - "value": "3 ." - }, - { - "name": "drag_list_four", - "value": "4 ." - }, - { - "name": "size_size", - "value": "حجم ." - }, - { - "name": "size_padding", - "value": "حشية" - }, - { - "name": "size_margin", - "value": "حافة" - }, - { - "name": "size_constraintSize", - "value": "حجم القيد" - }, - { - "name": "response_region", - "value": "منطقة الاستجابة" - }, - { - "name": "touch_hit_subtitle", - "value": "انقر فوق المنطقة الخضراء لتحريك المنطقة الزرقاء رد" - }, - { - "name": "option", - "value": "خيارات" - }, - { - "name": "hover_region", - "value": "تحوم الماوس فوق المنطقة الخضراء لمراقبة تأثير" - }, - { - "name": "multistatus_region", - "value": "تبديل الدولة ومراقبة تأثير" - }, - { - "name": "status_select", - "value": "اختيار الدولة" - }, - { - "name": "scroll_bar", - "value": "شريط التمرير" - }, - { - "name": "scroll_vertical_title", - "value": "التمرير الرأسي" - }, - { - "name": "scroll_horizontal_title", - "value": "التمرير الأفقي" - }, - { - "name": "auxiliary_refresh", - "value": "منعش" - }, - { - "name": "auxiliary_refresh_offset", - "value": "قابل" - }, - { - "name": "auxiliary_refresh_minvalue", - "value": "س" - }, - { - "name": "auxiliary_refresh_maxvalue", - "value": "١٠٠" - }, - { - "name": "auxiliary_refresh_friction", - "value": "احتكاك" - }, - { - "name": "auxiliary_panel", - "value": "لوحة" - }, - { - "name": "auxiliary_alphabetIndexer", - "value": "رسالة مفهرس" - }, - { - "name": "loading_progress", - "value": "تحميل الجدول" - }, - { - "name": "marquee_name", - "value": "ماركيز" - }, - { - "name": "marquee_src", - "value": "مرحبا arkui سلسلة أطول من المحتوى" - }, - { - "name": "marquee_fromstart", - "value": "من البداية" - }, - { - "name": "marquee_step", - "value": "خطوة" - }, - { - "name": "marquee_loop", - "value": "حلقة ." - }, - { - "name": "text_timer", - "value": "النص الموقت" - }, - { - "name": "text_timer_start", - "value": "بداية ." - }, - { - "name": "text_timer_pause", - "value": "وقفة" - }, - { - "name": "text_timer_reset", - "value": "إعادة" - }, - { - "name": "text_timer_iscountdown", - "value": "العد التنازلي" - }, - { - "name": "text_timer_timeformatone", - "value": "مم : الفولاذ المقاوم للصدأ" - }, - { - "name": "text_timer_groupformat", - "value": "شكل ." - }, - { - "name": "text_timer_timeformattwo", - "value": "عالية : مم : ثانية" - }, - { - "name": "text_timer_timeformatthree", - "value": "DD سمو مم SS . اس اس اس" - }, - { - "name": "text_clock", - "value": "كتلة النص" - }, - { - "name": "text_clock_start", - "value": "بداية ." - }, - { - "name": "text_clock_stop", - "value": "توقف" - }, - { - "name": "text_clock_timeformatone", - "value": "عالية : مم : ثانية" - }, - { - "name": "text_clock_groupformat", - "value": "شكل ." - }, - { - "name": "text_clock_timeformattwo", - "value": "السنة : الشهر : النهار" - }, - { - "name": "text_clock_timeformatthree", - "value": "ساعة - دقيقة - ثانية" - }, - { - "name": "progress_name", - "value": "تقدم" - }, - { - "name": "gauge_name", - "value": "متر ." - }, - { - "name": "gauge_value", - "value": "قيمة ." - }, - { - "name": "gauge_strokewidth", - "value": "السكتة الدماغية العرض" - }, - { - "name": "gauge_startangle", - "value": "زاوية البداية" - }, - { - "name": "gauge_endangle", - "value": "نهاية زاوية" - }, - { - "name": "data_panel", - "value": "لوحة البيانات" - }, - { - "name": "checkbox_checkboxgroup", - "value": "فحص مربع مجموعة" - }, - { - "name": "checkbox_title", - "value": "خانة الاختيار" - }, - { - "name": "checkbox_checkbox1", - "value": "خانة الاختيار 1" - }, - { - "name": "checkbox_checkbox2", - "value": "خانة الاختيار 2" - }, - { - "name": "checkbox_checkbox3", - "value": "خانة الاختيار 3" - }, - { - "name": "checkbox_checkgroup", - "value": "مجموعة مربع" - }, - { - "name": "checkbox_checkgroup_title", - "value": "مجموعة مربع" - }, - { - "name": "text_picker", - "value": "نص محدد" - }, - { - "name": "time_picker", - "value": "الوقت محدد" - }, - { - "name": "counter_name", - "value": "مكافحة" - }, - { - "name": "rating_name", - "value": "تصنيفات" - }, - { - "name": "rating_options_indicator", - "value": "المؤشر" - }, - { - "name": "rating_options_value", - "value": "قيمة ." - }, - { - "name": "rating_options_stars", - "value": "نجوم ." - }, - { - "name": "rich_text", - "value": "النص التشعبي" - }, - { - "name": "scroll_swiper", - "value": "المتداول والانزلاق" - }, - { - "name": "scroll_name", - "value": "ورقة لفة" - }, - { - "name": "swiper_name", - "value": "بطاقة ممغنطة" - }, - { - "name": "alphabetindexer_an", - "value": "واحد" - }, - { - "name": "alphabetindexer_bu", - "value": "يوم تقسيم" - }, - { - "name": "alphabetindexer_bai", - "value": "ابيض" - }, - { - "name": "alphabetindexer_bao", - "value": "بالة" - }, - { - "name": "alphabetindexer_bi", - "value": "بی" - }, - { - "name": "alphabetindexer_bing", - "value": "بنج" - }, - { - "name": "alphabetindexer_cao", - "value": "شاو" - }, - { - "name": "alphabetindexer_chen", - "value": "تشان ›" - }, - { - "name": "alphabetindexer_lv", - "value": "لو ." - }, - { - "name": "alphabetindexer_liu3", - "value": "ليو" - }, - { - "name": "alphabetindexer_liu", - "value": "خط وحدة واجهة" - }, - { - "name": "alphabetindexer_li", - "value": "الليثيوم" - }, - { - "name": "alphabetindexer_lou", - "value": "لو ." - }, - { - "name": "alphabetindexer_liang", - "value": "شعاع" - }, - { - "name": "alphabetindexer_lei", - "value": "رعد ." - }, - { - "name": "alphabetindexer_lu", - "value": "أرض ." - }, - { - "name": "alphabetindexer_cui", - "value": "تشوي" - }, - { - "name": "alphabetindexer_cheng", - "value": "تشنغ" - }, - { - "name": "alphabetindexer_list_display", - "value": "عرض قائمة" - }, - { - "name": "alphabetindexer_color_select", - "value": "اختيار اللون" - }, - { - "name": "alphabetindexer_selectedcolor_selectedcolor", - "value": "اختيار اللون" - }, - { - "name": "alphabetindexer_selectedcolor_selectedbgcolor", - "value": "اختيار لون الخلفية" - }, - { - "name": "alphabetindexer_selectedcolor_popupcolor", - "value": "لون النوافذ المنبثقة" - }, - { - "name": "alphabetindexer_selectedcolor_popupbackground", - "value": "الخلفية المنبثقة" - }, - { - "name": "alphabetindexer_selectedcolor_usingpopup", - "value": "استخدام النوافذ المنبثقة" - }, - { - "name": "panel_show_minibar", - "value": "عرض شريط ميني نوع الفريق" - }, - { - "name": "panel_close_minibar", - "value": "إغلاق شريط ميني نوع الفريق" - }, - { - "name": "panel_show_foldable", - "value": "عرض نوع قابلة للطي لوحة" - }, - { - "name": "panel_close_foldable", - "value": "إغلاق لوحة قابلة للطي" - }, - { - "name": "panel_show_temporary", - "value": "عرض لوحة نوع مؤقت" - }, - { - "name": "panel_close_temporary", - "value": "إغلاق لوحة نوع مؤقت" - }, - { - "name": "panel_radio_groupname", - "value": "فاكهة" - }, - { - "name": "checkbox_apple", - "value": "تفاحة ." - }, - { - "name": "checkbox_blueberry", - "value": "عنبية" - }, - { - "name": "checkbox_banbana", - "value": "موز ." - }, - { - "name": "checkbox_cherries", - "value": "كرز ." - }, - { - "name": "checkbox_durian", - "value": "دوريان" - }, - { - "name": "checkbox_orange", - "value": "برتقالي" - }, - { - "name": "checkbox_select_color", - "value": "اختيار اللون" - }, - { - "name": "checkbox_select_all", - "value": "اختيار كامل" - }, - { - "name": "normal_display", - "value": "عرض" - }, - { - "name": "normal_options", - "value": "خيارات" - }, - { - "name": "datapanel_circle", - "value": "دائرة" - }, - { - "name": "datapanel_line", - "value": "خط" - }, - { - "name": "progress_linear", - "value": "التقدم الخطي" - }, - { - "name": "progress_eclipse", - "value": "الكسوف التقدم" - }, - { - "name": "progress_scalering", - "value": "مقياس التقدم" - }, - { - "name": "progress_ring", - "value": "حلقة التقدم" - }, - { - "name": "progress_capsule", - "value": "كبسولة التقدم" - }, - { - "name": "progress_change", - "value": "تغيير الجدول الزمني" - }, - { - "name": "textclock_timeformat", - "value": "شكل الوقت" - }, - { - "name": "scroll_horizontal", - "value": "التمرير الأفقي" - }, - { - "name": "scroll_vertical", - "value": "التمرير الرأسي" - }, - { - "name": "interaction_disable_list", - "value": "قائمة الجرحى" - }, - { - "name": "interaction_show_one_alert", - "value": "انقر على عرض تذكير" - }, - { - "name": "interaction_show_two_alert", - "value": "انقر على زر عرض التنبيه المزدوج" - }, - { - "name": "interaction_placementontop", - "value": "وضع سقف :" - }, - { - "name": "interaction_arrowoffset", - "value": "تغيير إزاحة السهم :" - }, - { - "name": "interaction_showpopup", - "value": "عرض النوافذ المنبثقة" - }, - { - "name": "interaction_showcustompopup", - "value": "عرض مخصص المنبثقة" - }, - { - "name": "pan_start", - "value": "نقطة الانطلاق" - }, - { - "name": "pan_end", - "value": "نهاية ." - }, - { - "name": "pan_button", - "value": "تعديل pangesture الزناد" - }, - { - "name": "pinch_description", - "value": "اضغط على الإطار الأسود مع ثلاثة أصابع" - }, - { - "name": "pinch_scale", - "value": "نسبة العجن لفتة :" - }, - { - "name": "interaction_mask", - "value": "إسمك" - }, - { - "name": "rotation_description", - "value": "تدوير الصندوق الأسود مع اثنين من أصابع" - }, - { - "name": "swipe_description", - "value": "الشريحة بسرعة الصندوق الأسود في أي اتجاه مع إصبع واحد" - }, - { - "name": "combinded_description", - "value": "اضغط واسحب مربع أسود" - }, - { - "name": "transform_translate_invert", - "value": "التكبير مرتين و عكس ( التكبير مرتين )" - }, - { - "name": "key_press_description", - "value": "اضغط على لوحة المفاتيح الخارجية التبويب ، ثم اضغط على أي مفتاح" - }, - { - "name": "april", - "value": "ابريل" - }, - { - "name": "bind_click", - "value": "انقر على لي" - }, - { - "name": "interaction_disable", - "value": "تعطيل المكونات :" - }, - { - "name": "canvas_components", - "value": "قماش الجمعية" - }, - { - "name": "canvas_component_attributes", - "value": "السمة الأساسية" - }, - { - "name": "canvas_component_image_bitmap", - "value": "صورة نقطية" - }, - { - "name": "canvas_component_gradient", - "value": "كسر التدرج" - }, - { - "name": "canvas_component_method", - "value": "الطريقة الأساسية" - }, - { - "name": "canvas_component_path_2d", - "value": "باث" - }, - { - "name": "canvas_component_shadow", - "value": "شادو" - }, - { - "name": "canvas_component_transform", - "value": "تحويل" - }, - { - "name": "canvas_canvasZone", - "value": "قماش المنطقة" - }, - { - "name": "canvas_attributesOperations", - "value": "خاصية التشغيل" - }, - { - "name": "canvas_clearEffects", - "value": "تأثير واضح" - }, - { - "name": "canvas_show_message", - "value": "طباعة وحدة التحكم" - }, - { - "name": "scroll_To_effect", - "value": "انتقل إلى تأثير" - }, - { - "name": "scroller", - "value": "لف الجهاز" - }, - { - "name": "list", - "value": "قائمة" - }, - { - "name": "grid", - "value": "شبكة ." - }, - { - "name": "waterFlow", - "value": "تدفق المياه" - }, - { - "name": "tabs_switch_effect", - "value": "تسمية التبديل تأثير" - }, - { - "name": "image_fit_Full_effect", - "value": "صورة مطابقة / تأثير كامل" - }, - { - "name": "particle_effect", - "value": "تأثير الجسيمات" - }, - { - "name": "particle_spawn", - "value": "وضع البيض" - }, - { - "name": "particle_spawn_stop", - "value": "توقف" - }, - { - "name": "global_bindSheet_menu", - "value": "قائمة أوراق فضفاضة" - }, - { - "name": "global_bindSheet_text_allow_interaction", - "value": "تسمح صفحة التفاعل" - }, - { - "name": "global_bindSheet_text_desc", - "value": "تسمح صفحة وصف التفاعل" - }, - { - "name": "bindSheet_popup_style", - "value": "نمط البوب" - }, - { - "name": "bindSheet_default_popup", - "value": "نافذة منبثقة" - }, - { - "name": "bindSheet_centered_popup", - "value": "تركز نافذة منبثقة" - }, - { - "name": "bindSheet_popup_appears", - "value": "تظهر نافذة منبثقة" - }, - { - "name": "bindSheet_icon", - "value": "آيدول" - }, - { - "name": "bindSheet_blurred_background_texture", - "value": "غامض نسيج الخلفية" - }, - { - "name": "bindSheet_popup_modal_interface", - "value": "طريقة إخراج واجهة" - }, - { - "name": "pop_height", - "value": "بوب هايت" - }, - { - "name": "bindSheet_close_modal", - "value": "وضع قبالة" - }, - { - "name": "bindSheet_close_confirm", - "value": "أكّد" - }, - { - "name": "bindSheet_close_cancel", - "value": "ألغى" - }, - { - "name": "global_popUp_menu", - "value": "نافذة منبثقة" - }, - { - "name": "popUp_width", - "value": "عرض" - }, - { - "name": "placement", - "value": "إعادة التوطين" - }, - { - "name": "popUp_advanced_component", - "value": "بوبوب مكونات متقدمة" - }, - { - "name": "global_menu_avoid_rule", - "value": "قائمة تجنب القاعدة" - }, - { - "name": "global_menu_layout", - "value": "تصميم القائمة" - }, - { - "name": "global_menu_width", - "value": "عرض القائمة" - }, - { - "name": "menu_option", - "value": "قائمة الخيارات" - }, - { - "name": "vertical_layout", - "value": "تخطيط عمودي" - }, - { - "name": "horizontal_layout", - "value": "تخطيط أفقي" - }, - { - "name": "menu_width", - "value": "عرض" - }, - { - "name": "textclock_style", - "value": "أسلوب ." - }, - { - "name": "text_clock_textShadow", - "value": "نص الظل" - }, - { - "name": "text_clock_fontSetting", - "value": "إعدادات الخط" - }, - { - "name": "text_clock_select_button", - "value": "اختيار زر" - }, - { - "name": "text_clock_monospaced_numbers", - "value": "رقم واحد" - }, - { - "name": "text_clock_monovolume_numbers", - "value": "حجم واحد عدد" - }, - { - "name": "text_input_text_selection_menu", - "value": "قائمة اختيار النص" - }, - { - "name": "text_custom_menu", - "value": "نص مخصص القائمة" - }, - { - "name": "text_input_text_copy", - "value": "نسخ" - }, - { - "name": "text_input_text_copy_success", - "value": "نسخة ناجحة" - }, - { - "name": "text_input_text_paste", - "value": "لصق" - }, - { - "name": "text_input_text_paste_success", - "value": "لصق بنجاح" - }, - { - "name": "text_input_text_get", - "value": "الحصول على" - }, - { - "name": "text_input_text_delete", - "value": "حذف النص" - }, - { - "name": "text_input_line_break_strategy", - "value": "كسر استراتيجية" - }, - { - "name": "text_input_line_break_strategy_content", - "value": "أنها يمكن أن تكون مقسمة إلى المدمج في المكونات -- المكونات التي يتم توفيرها مباشرة من قبل arkui الإطار ، مكونات مخصصة -- التي يحددها المطور . المدمج في المكونات تشمل أزرار ، أزرار الراديو ، ومؤشرات التقدم ، والنصوص . يمكنك تعيين عرض هذه المكونات في طريقة ربط الوضع ، مكونات الصفحة مقسمة إلى وحدات واجهة المستخدم منفصلة لإنشاء وتطوير وإعادة استخدام وحدات مختلفة على الصفحة ، مما يجعل الصفحة أكثر هندسة المنحى ." - }, - { - "name": "text_input_word_break", - "value": "قطع" - }, - { - "name": "text_input_word_break_content", - "value": "هذه هي ميزة وضع WordBreak إلى نص WordBreak Taumatawakathangakoauotamateature ، وهذا هو ، عندما كنت لا تعرف ، سوف تجد أنك لا تعرف ." - }, - { - "name": "textarea_character_limit", - "value": "الحد من حرف" - }, - { - "name": "grid_item_polymorphic_styles", - "value": "نمط متعدد الأشكال" - }, - { - "name": "previous", - "value": "سابق" - }, - { - "name": "next_step", - "value": "الخطوة التالية" - }, - { - "name": "text_styled_string_title", - "value": "سلسلة نمط النص" - }, - { - "name": "text_mutable_styled_string", - "value": "نمط سلسلة" - }, - { - "name": "text_mutable_styled_string_start", - "value": "نقطة الانطلاق" - }, - { - "name": "text_mutable_styled_string_length", - "value": "طول ." - }, - { - "name": "text_mutable_styled_error", - "value": "من فضلك أدخل" - }, - { - "name": "text_styled_string_gesture_style", - "value": "لفتة نمط" - }, - { - "name": "rows_and_columns", - "value": "الصفوف والأعمدة" - }, - { - "name": "stack_flex_and_grid", - "value": "كومة ، والانحناء ، تنسجم" - }, - { - "name": "list_and_grid", - "value": "قائمة الشبكة" - }, - { - "name": "navigation", - "value": "ملاحة" - }, - { - "name": "canvas_and_graphic_drawing", - "value": "قماش والرسومات" - }, - { - "name": "size_transition_flex", - "value": "بنت ." - }, - { - "name": "size_transition_grid_item", - "value": "شبكة البند" - }, - { - "name": "size_transition_list_item", - "value": "قائمة البنود" - }, - { - "name": "size_transition_swiper_item", - "value": "مشروع بطاقة ممغنطة" - }, - { - "name": "size_transition_font_size", - "value": "حجم الخط" - }, - { - "name": "size_transition_expansion_tabContent", - "value": "علامة التبويب المحتوى" - }, - { - "name": "set_background_blur_style_color_mode", - "value": "تعيين نمط لون الخلفية الضبابية" - }, - { - "name": "set_background_blur_style_adaptive_color", - "value": "تعيين لون الخلفية الضبابي المتكيف" - }, - { - "name": "blur_style_system", - "value": "نظم" - }, - { - "name": "blur_style_light", - "value": "الإضاءة" - }, - { - "name": "blur_style_dark", - "value": "ظلام ." - }, - { - "name": "blur_style_default", - "value": "خرق" - }, - { - "name": "shadow_type_color", - "value": "الألوان" - }, - { - "name": "shadow_type_blur", - "value": "طمس" - }, - { - "name": "blur_style_average", - "value": "متوسط القيمة" - }, - { - "name": "divider_color_blue", - "value": "بلو" - }, - { - "name": "divider_color_green", - "value": "غرين" - }, - { - "name": "divider_color_orange", - "value": "برتقالي" - }, - { - "name": "divider_color_pink", - "value": "وردي" - }, - { - "name": "divider_line_type_butt", - "value": "السيجارة" - }, - { - "name": "divider_line_type_round", - "value": "دائرة" - }, - { - "name": "divider_line_type_square", - "value": "ساحة" - }, - { - "name": "safe_area_type_and_safe_area_edge", - "value": "safeareatype و safeareedge" - }, - { - "name": "save_area_input_text", - "value": "أدخل كلمة . . ." - }, - { - "name": "safe_area_type", - "value": "نوع المنطقة الأمنية" - }, - { - "name": "safe_area_edge", - "value": "سافاريادج" - }, - { - "name": "safe_area_edge_top", - "value": "توب ." - }, - { - "name": "safe_area_edge_bottom", - "value": "القاع" - }, - { - "name": "safe_area_edge_start", - "value": "بداية ." - }, - { - "name": "safe_area_edge_end", - "value": "نهاية ." - }, - { - "name": "safe_area_type_system", - "value": "نظم" - }, - { - "name": "safe_area_type_cutout", - "value": "شق" - }, - { - "name": "safe_area_type_keyboard", - "value": "لوحة المفاتيح ." - }, - { - "name": "System_icon", - "value": "رمز النظام" - }, - { - "name": "text_content_en", - "value": "خفف من الصلب في النار والتبريد السريع ، بحيث يمكن أن يكون من الصعب جدا ، لا تخافوا من أي شيء . وبهذه الطريقة فقط ، فإن جيلنا قد شحذ في النضال و التجارب الرهيبة و تعلمت عدم الاستسلام للحياة ." - }, - { - "name": "text_content_en_first", - "value": "خفف من الصلب في النار والتبريد السريع ، بحيث يمكن أن يكون من الصعب جدا ، لا تخافوا من أي شيء ." - }, - { - "name": "text_content_en_last", - "value": "وبهذه الطريقة فقط ، فإن جيلنا قد شحذ في النضال و التجارب الرهيبة و تعلمت عدم الاستسلام للحياة ." - }, - { - "name": "touch_hit_test", - "value": "انقر فوق منطقة ساخنة : تعيين منطقة ساخنة في المنطقة الخضراء" - }, - { - "name": "side_bar_effects_title", - "value": "تأثير الشريط الجانبي" - }, - { - "name": "set_side_bar_type", - "value": "تعيين نوع الشريط الجانبي" - }, - { - "name": "side_bar_container_content", - "value": "sidebar محتويات الحاوية" - }, - { - "name": "hide_side_bar", - "value": "إخفاء الشريط الجانبي" - }, - { - "name": "show_side_bar", - "value": "عرض شريط جانبي" - }, - { - "name": "side_bar_type_embed", - "value": "جزءا لا يتجزأ من" - }, - { - "name": "side_bar_type_overlay", - "value": "تغطية طبقة" - }, - { - "name": "side_bar_type_auto", - "value": "السيارات" - }, - { - "name": "auxiliary_refresh_refreshing", - "value": "منعش" - }, - { - "name": "rich_editor", - "value": "ريش ديتور" - }, - { - "name": "rich_editor_style", - "value": "أسلوب ." - }, - { - "name": "rich_editor_title", - "value": "ريش ديتور" - }, - { - "name": "nav_router", - "value": "توجيه الملاحة" - }, - { - "name": "tabs_name", - "value": "تبويب" - }, - { - "name": "select_name", - "value": "مختار" - }, - { - "name": "slider_name", - "value": "المنزلق" - }, - { - "name": "delete_list_item", - "value": "حذف قائمة البند" - }, - { - "name": "size_size_description_one", - "value": "العرض والارتفاع" - }, - { - "name": "size_size_description_two", - "value": "العرض والارتفاع 100%" - }, - { - "name": "size_size_padding_one", - "value": "أعلى ، أسفل ، اليسار واليمين الهوامش الداخلية 10vp" - }, - { - "name": "size_size_padding_two", - "value": "الهامش الداخلي 20%" - }, - { - "name": "size_size_margin_one", - "value": "أعلى ، أسفل ، يسار ، يمين" - }, - { - "name": "size_size_margin_two", - "value": "المسافة الخارجية العليا 20%" - }, - { - "name": "size_size_constraintSize_one", - "value": "الحد الأقصى للعرض والارتفاع 90vp" - }, - { - "name": "size_size_constraintSize_two", - "value": "الحد الأدنى من العرض والارتفاع 80vp" - }, - { - "name": "keyPress_event", - "value": "اضغط على الحدث" - }, - { - "name": "focus_event_description", - "value": "اضغط على علامة التبويب لوحة المفاتيح الخارجية للحصول على التركيز ، ثم اضغط على مفتاح التبديل" - }, - { - "name": "focus_event_button_one", - "value": "الزر الأول" - }, - { - "name": "focus_event_button_two", - "value": "الزر الثاني" - }, - { - "name": "focus_event_button_three", - "value": "الزر الثالث" - }, - { - "name": "focus_event_toast_text", - "value": "الزناد التركيز" - }, - { - "name": "press_event_toast_text", - "value": "زر الزناد الحدث" - }, - { - "name": "press_event_toast_description", - "value": "اضغط على أي مفتاح على لوحة المفاتيح الخارجية" - }, - { - "name": "mouse_event_move_description", - "value": "استخدام الماوس الخارجي للانتقال إلى زر" - }, - { - "name": "mouse_event_click_description", - "value": "استخدام الفأرة الخارجية للنقر على زر" - }, - { - "name": "mouse_event_hover_description", - "value": "ماوس" - }, - { - "name": "mouse_event_onHover_description", - "value": "الماوس لا تتحرك" - }, - { - "name": "mouse_event_onMouse_text", - "value": "على الماوس" - }, - { - "name": "mouse_event_mouseBtn_none", - "value": "هل أنت بخير ؟ - لا -" - }, - { - "name": "mouse_event_mouseBtn_left", - "value": "يسار ." - }, - { - "name": "mouse_event_mouseBtn_right", - "value": "صحيح ." - }, - { - "name": "mouse_event_mouseBtn_back", - "value": "العودة" - }, - { - "name": "mouse_event_mouseBtn_forward", - "value": "فورورد" - }, - { - "name": "mouse_event_mouseBtn_middle", - "value": "متوسط" - }, - { - "name": "mouse_event_mouseAction_hover", - "value": "تحوم" - }, - { - "name": "mouse_event_mouseAction_press", - "value": "ميديا ." - }, - { - "name": "mouse_event_mouseAction_move", - "value": "تحرك ." - }, - { - "name": "mouse_event_mouseAction_release", - "value": "أطلق" - }, - { - "name": "scroll_event", - "value": "عنصر المنطقة المرئية تغيير الحدث" - }, - { - "name": "scroll_event_description", - "value": "قائمة الشرائح يجعل الصورة تختفي و تظهر" - }, - { - "name": "scroll_event_toast_visible", - "value": "صور حب واضحة للعيان" - }, - { - "name": "scroll_event_toast_invisible", - "value": "صورة الحب اختفى تماما" - }, - { - "name": "location_settings", - "value": "وضع" - }, - { - "name": "location_settings_align", - "value": "طريقة محاذاة" - }, - { - "name": "location_settings_direction", - "value": "تخطيط أفقي" - }, - { - "name": "location_settings_position", - "value": "المواقع المطلقة" - }, - { - "name": "location_settings_markAnchor", - "value": "مجموعة مرساة" - }, - { - "name": "location_settings_offset", - "value": "بالنسبة لتحديد المواقع" - }, - { - "name": "location_settings_alignRules", - "value": "محاذاة القاعدة" - }, - { - "name": "location_settings_bottom_end", - "value": "نهاية القاع" - }, - { - "name": "location_settings_top_start", - "value": "أعلى بداية" - }, - { - "name": "location_settings_center", - "value": "مركز" - }, - { - "name": "location_settings_position_text", - "value": "الموقع ( 30 ، 10 )" - }, - { - "name": "location_settings_position_offSet_text", - "value": "Original : ENGLISH" - }, - { - "name": "layout_constrain", - "value": "تخطيط القيد" - }, - { - "name": "layout_constrain_aspectRatio", - "value": "عنصر نسبة الارتفاع" - }, - { - "name": "layout_constrain_displayPriority", - "value": "عنصر الأولوية" - }, - { - "name": "layout_constrain_big_container", - "value": "حاوية كبيرة" - }, - { - "name": "layout_constrain_middle_container", - "value": "حاوية متوسطة الحجم" - }, - { - "name": "layout_constrain_small_container", - "value": "حاوية صغيرة" - }, - { - "name": "layout_constrain_children_one", - "value": "1 : ( أولوية : 2 )" - }, - { - "name": "layout_constrain_children_two", - "value": "2 : ( الأولوية : 1 )" - }, - { - "name": "layout_constrain_children_three", - "value": "3 : ( الأولوية : 3 )" - }, - { - "name": "layout_constrain_children_four", - "value": "4 : ( الأولوية : 1 )" - }, - { - "name": "layout_constrain_children_five", - "value": "5 - ( الأولوية : 2 )" - }, - { - "name": "layout_constrain_one", - "value": "1 ." - }, - { - "name": "layout_constrain_two", - "value": "2 ." - }, - { - "name": "flex", - "value": "بنت ." - }, - { - "name": "flex_flexBasis", - "value": "فليكسباسيس" - }, - { - "name": "flex_flexGrow", - "value": "فلکسجرو" - }, - { - "name": "flex_flexShrink", - "value": "فليكس شرينك" - }, - { - "name": "flex_alignSelf", - "value": "اليغن سلف" - }, - { - "name": "flex_layoutWeight", - "value": "تخطيط الوزن" - }, - { - "name": "flex_no_layoutWeight", - "value": "عن تخطيط الوزن" - }, - { - "name": "flex_no_alignSelf_70", - "value": "محاذاة النفس ، الارتفاع : 70%" - }, - { - "name": "flex_end_alignSelf", - "value": "محاذاة نهاية النفس" - }, - { - "name": "flex_end_alignSelf_100", - "value": "محاذاة نهاية النفس" - }, - { - "name": "flex_shrink_0", - "value": "فليكس انكماش" - }, - { - "name": "flex_shrink_default", - "value": "فليكس شرينك" - }, - { - "name": "flex_shrink_1", - "value": "فليكس شرينك" - }, - { - "name": "flex_grow_1", - "value": "FlexGrow ( 1 )" - }, - { - "name": "flex_grow_2", - "value": "FlexGrow ( 2 )" - }, - { - "name": "flex_no_alignSelf_100", - "value": "محاذاة الذاتي ، الطول : 100%" - }, - { - "name": "flex_basis_100", - "value": "FlexBasis ( 100 )" - }, - { - "name": "flex_basis_auto", - "value": "FlexBasis ( تلقائي )" - }, - { - "name": "picture_border", - "value": "حدود الصورة" - }, - { - "name": "scale", - "value": "مقياس" - }, - { - "name": "transform", - "value": "تحويل" - }, - { - "name": "scale_image", - "value": "تكبير الصورة" - }, - { - "name": "transform_image", - "value": "تحويل الصورة" - }, - { - "name": "transform_init", - "value": "إنشاء مصفوفة من المرتبة الرابعة" - }, - { - "name": "transform_copy", - "value": "مصفوفة النسخ المتماثل" - }, - { - "name": "transform_combine", - "value": "تأثير مصفوفة تراكب" - }, - { - "name": "transform_invert", - "value": "عكس تأثير المصفوفة" - }, - { - "name": "transform_translate", - "value": "مصفوفة تأثير الترجمة" - }, - { - "name": "transform_scale", - "value": "تأثير حجم المصفوفة" - }, - { - "name": "transform_rotate", - "value": "تأثير مصفوفة التناوب" - }, - { - "name": "transform_transformPoint", - "value": "تأثير مصفوفة تحويل الإحداثيات" - }, - { - "name": "transform_combine_text", - "value": "ترجمة × 20 و التكبير مرتين" - }, - { - "name": "transform_translate_text", - "value": "س : 40 ، ص : 40 ، ض : 20" - }, - { - "name": "transform_scale_text", - "value": "العرض والارتفاع بمقدار مرتين" - }, - { - "name": "transform_rotate_text", - "value": "دوران 30 درجة" - }, - { - "name": "transform_transformPoint_before", - "value": "الإحداثيات بعد تحويل المصفوفة : [ 50 , 50 ]" - }, - { - "name": "transform_transformPoint_after", - "value": "الإحداثيات بعد تحويل المصفوفة : [ 100 , 0 ]" - }, - { - "name": "shape_crop", - "value": "شكل الخياطة" - }, - { - "name": "shape_crop_clip", - "value": "قطع" - }, - { - "name": "shape_crop_mask", - "value": "غطى" - }, - { - "name": "grid_settings", - "value": "إعدادات الشبكة" - }, - { - "name": "grid_settings_sm", - "value": "جهاز عرض خ" - }, - { - "name": "grid_settings_md", - "value": "عرض الجهاز MD" - }, - { - "name": "grid_settings_lg", - "value": "عرض الجهاز إل جي" - }, - { - "name": "grid_settings_useSize", - "value": "استخدام نوع الحجم" - }, - { - "name": "grid_settings_gridSpan", - "value": "gridspan شبكة تعويض" - }, - { - "name": "grid_edgeEffect_spring", - "value": "شبكة حافة تأثير الربيع" - }, - { - "name": "focus_control", - "value": "التركيز على السيطرة" - }, - { - "name": "focus_control_tab", - "value": "التركيز على السيطرة على التبويب" - }, - { - "name": "focus_control_lastPageId", - "value": "معرف الصفحة الأخيرة" - }, - { - "name": "focus_control_success", - "value": "التركيز على السيطرة على النجاح" - }, - { - "name": "focus_control_failed", - "value": "التركيز على السيطرة على الفشل" - }, - { - "name": "focus_control_group1", - "value": "المجموعة الأولى" - }, - { - "name": "focus_control_group2", - "value": "المجموعة الثانية" - }, - { - "name": "focus_control_group3", - "value": "المجموعة الثالثة" - }, - { - "name": "focus_control_input", - "value": "المدخلات" - }, - { - "name": "focus_control_request_focus", - "value": "التركيز على السيطرة على الطلب" - }, - { - "name": "component_id", - "value": "عنصر الهوية" - }, - { - "name": "component_id_onKeyTab", - "value": "اونكي تاب" - }, - { - "name": "component_id_click", - "value": "انقر فوق ابدأ" - }, - { - "name": "component_id_longClick", - "value": "نقرات طويلة" - }, - { - "name": "component_id_onTouch", - "value": "اونتوش" - }, - { - "name": "component_id_onMouse", - "value": "اونموس" - }, - { - "name": "component_id_click_text", - "value": "انقر على زر ابدأ" - }, - { - "name": "component_id_longClick_text", - "value": "تم النقر على زر \" LongClick \" لفترة طويلة" - }, - { - "name": "component_id_onTouch_text", - "value": "انقر على زر \" ontouch \"" - }, - { - "name": "component_id_onMouse_text", - "value": "\" onmouse \" زر في onmouse" - }, - { - "name": "component_blurred", - "value": "عنصر غامض" - }, - { - "name": "component_blurred_thin", - "value": "عنصر غامض رقيقة" - }, - { - "name": "restore_id", - "value": "استعادة الهوية" - }, - { - "name": "gesture_process", - "value": "لفتة العملية" - }, - { - "name": "bind_gesture_methods", - "value": "ملزمة لفتة طريقة" - }, - { - "name": "bind_gesture_priorityGesture", - "value": "prioritygeture يتجاهل النص أولوية تحديد الوالد مكون العمود" - }, - { - "name": "bind_gesture_parallelGesture", - "value": "parallelgesture يحدد الوالد الطفل عنصر العمود ، النص" - }, - { - "name": "bind_gesture_tapGesture", - "value": "انقر على الإيماءات :" - }, - { - "name": "bind_gesture_text", - "value": "نص ." - }, - { - "name": "bind_gesture_column", - "value": "عمود" - }, - { - "name": "double_click", - "value": "نقرا مزدوجا فوق الزناد" - }, - { - "name": "onAction", - "value": "على العمل :" - }, - { - "name": "long_press", - "value": "إصبع واحد طويل اضغط على النص" - }, - { - "name": "long_press_cancel", - "value": "إلغاء النشاط" - }, - { - "name": "long_press_text", - "value": "اضغط على لي مع إصبع واحد ، من فضلك ." - }, - { - "name": "pan_text", - "value": "سحب مربع أسود بأي شكل من الأشكال مع اثنين من أصابع" - }, - { - "name": "pan_text_one", - "value": "سحب مربع أسود مع إصبع واحد اليسار واليمين" - }, - { - "name": "pan_offset", - "value": "( بآلاف دولارات الولايات المتحدة )" - }, - { - "name": "pan_offset_y", - "value": "ي > ?" - }, - { - "name": "pinch_center", - "value": "مركز قرصة الإيماءات :" - }, - { - "name": "rotation_text", - "value": "لفتة التناوب" - }, - { - "name": "swipe_text_speed", - "value": "انزلاق الموقف" - }, - { - "name": "swipe_text_angle", - "value": "انزلاق الموقف" - }, - { - "name": "combinded_pan_start", - "value": "بداية الترجمة" - }, - { - "name": "combinded_pan_update", - "value": "بان التحديث" - }, - { - "name": "combinded_pan_end", - "value": "نهاية وعاء" - }, - { - "name": "combinded_longPress_onAction", - "value": "لونغبريس أون أكشن" - }, - { - "name": "combinded_longPress_end", - "value": "الصحافة نهاية طويلة" - }, - { - "name": "combinded_sequence", - "value": "تسلسل لفتة" - }, - { - "name": "combinded_longPress", - "value": "Longpress على العمل :" - }, - { - "name": "combinded_offset", - "value": "( بآلاف دولارات الولايات المتحدة )" - }, - { - "name": "combinded_x", - "value": "عشرة" - }, - { - "name": "key_press_keyType", - "value": "نوع المفتاح :" - }, - { - "name": "key_press_keyCode", - "value": "رمز المفتاح" - }, - { - "name": "key_press_keyText", - "value": "نص الكلمات الرئيسية :" - }, - { - "name": "key_press_down", - "value": "نزل" - }, - { - "name": "key_press_up", - "value": "صاعد" - }, - { - "name": "componentId_longClick", - "value": "نقرات طويلة" - }, - { - "name": "componentId_onTouch", - "value": "اونتوش" - }, - { - "name": "componentId_onMouse", - "value": "على الماوس" - }, - { - "name": "flex_auto", - "value": "السيارات" - }, - { - "name": "row_title", - "value": "فصيلة" - }, - { - "name": "row_introduction_arguments", - "value": "تعديل خط المعلمة" - }, - { - "name": "row_introduction_properties", - "value": "تعديل خصائص الخط" - }, - { - "name": "row_element_spacing", - "value": "عنصر تباعد" - }, - { - "name": "row_alignitems_top", - "value": "توب ." - }, - { - "name": "row_alignitems_bottom", - "value": "القاع" - }, - { - "name": "row_alignitems_center", - "value": "مركز" - }, - { - "name": "row_justifycontent_start", - "value": "نقطة الانطلاق" - }, - { - "name": "row_justifycontent_center", - "value": "مركز" - }, - { - "name": "row_justifycontent_end", - "value": "نهاية ." - }, - { - "name": "row_justifycontent_spacebetween", - "value": "بين الفراغات" - }, - { - "name": "row_justifycontent_spacearound", - "value": "الفضاء المحيط" - }, - { - "name": "row_justifycontent_spaceevenly", - "value": "مساحة موحدة" - }, - { - "name": "row_justifycontent_description", - "value": "تنسيق المغزل" - }, - { - "name": "row_alignitems_description", - "value": "تنسيق المحور الأفقي" - }, - { - "name": "row_introduction_tips", - "value": "نصيحة" - }, - { - "name": "row_tips", - "value": "عندما المغزل هو من نوع spacetween spacearound , أو spaceeven ، المعلمة الفضاء صف العنصر لا يعمل" - }, - { - "name": "rowsplit_title", - "value": "تقسيم أفقي تخطيط" - }, - { - "name": "rowsplit_introduction_properties", - "value": "تعديل خصائص rowsplit السحب والإسقاط" - }, - { - "name": "rowsplit_drag", - "value": "سحب التبديل" - }, - { - "name": "rowsplit_drag_divider", - "value": "سحب فواصل اليسار واليمين لتغيير الموقف" - }, - { - "name": "column_title", - "value": "عمود" - }, - { - "name": "column_introduction_arguments", - "value": "تعديل خط المعلمة" - }, - { - "name": "column_introduction_properties", - "value": "تعديل خصائص الخط" - }, - { - "name": "column_element_spacing", - "value": "عنصر تباعد" - }, - { - "name": "column_alignitems_start", - "value": "نقطة الانطلاق" - }, - { - "name": "column_alignitems_end", - "value": "نهاية ." - }, - { - "name": "column_alignitems_center", - "value": "مركز" - }, - { - "name": "column_justifycontent_start", - "value": "نقطة الانطلاق" - }, - { - "name": "column_justifycontent_center", - "value": "مركز" - }, - { - "name": "column_justifycontent_end", - "value": "نهاية ." - }, - { - "name": "column_justifycontent_spacebetween", - "value": "بين الفراغات" - }, - { - "name": "column_justifycontent_spacearound", - "value": "الفضاء المحيط" - }, - { - "name": "column_justifycontent_spaceevenly", - "value": "مساحة موحدة" - }, - { - "name": "column_justifycontent_description", - "value": "تنسيق المغزل" - }, - { - "name": "column_alignitems_description", - "value": "تنسيق المحور الأفقي" - }, - { - "name": "column_introduction_tips", - "value": "نصيحة" - }, - { - "name": "column_tips", - "value": "عندما المغزل هو من نوع spacetween spacearound , أو spaceeven ، المعلمة الفضاء صف العنصر لا يعمل" - }, - { - "name": "columnsplit_title", - "value": "تقسيم عمودي تخطيط" - }, - { - "name": "columnsplit_introduction_properties", - "value": "تعديل خاصية السحب والإفلات من columnsplit" - }, - { - "name": "columnsplit_drag", - "value": "سحب التبديل" - }, - { - "name": "columnsplit_introduction_drag_divider", - "value": "اسحب خط التقسيم صعودا وهبوطا لتغيير الموقف" - }, - { - "name": "sidebarcontainer_title", - "value": "sidebar حاوية" - }, - { - "name": "sidebarcontainer_content_text", - "value": "sidebarcontainer : حاوية الشريط الجانبي الذي يوفر عرض وإخفاء الشريط الجانبي . الشريط الجانبي ومحتوى المناطق المحددة من قبل عناصر فرعية ، أول عنصر فرعي يمثل الشريط الجانبي ، والثاني عنصر فرعي يمثل محتوى المنطقة . هذا العنصر هو مدعوم من المعهد الإصدار 8 . إذا كان محتوى جديد يضاف إلى الإصدارات اللاحقة ، الزاوية العليا علامة تستخدم علامة بداية الإصدارات الفردية من المحتوى ." - }, - { - "name": "sidebarcontainer_sidebar_text_one", - "value": "جمع" - }, - { - "name": "sidebarcontainer_sidebar_text_two", - "value": "الصفحة الرئيسية" - }, - { - "name": "sidebarcontainer_argument", - "value": "تعديل sidebarcontainer عينة" - }, - { - "name": "sidebarcontainer_property", - "value": "تعديل sidebarcontainer الملكية" - }, - { - "name": "sidebarcontainer_argument_type", - "value": "الشريط الجانبي نوع العرض" - }, - { - "name": "sidebarcontainer_type_embed", - "value": "جزءا لا يتجزأ من" - }, - { - "name": "sidebarcontainer_type_overlay", - "value": "تغطية طبقة" - }, - { - "name": "sidebarcontainer_show_switch", - "value": "عرض التبديل" - }, - { - "name": "sidebarcontainer_left_margin", - "value": "زر التحكم في المسافة إلى اليسار" - }, - { - "name": "sidebarcontainer_top_margin", - "value": "المسافة من زر التحكم" - }, - { - "name": "sidebarcontainer_show_button_switch", - "value": "زر التحكم عرض التبديل" - }, - { - "name": "sidebarcontainer_position_title", - "value": "الشريط الجانبي يظهر الموقع" - }, - { - "name": "sidebarcontainer_sidebar_show_position_start", - "value": "نقطة الانطلاق" - }, - { - "name": "sidebarcontainer_sidebar_show_position_end", - "value": "نهاية ." - }, - { - "name": "sidebarcontainer_min_width", - "value": "الحد الأدنى من عرض الشريط الجانبي" - }, - { - "name": "sidebarcontainer_max_width", - "value": "أقصى عرض الشريط الجانبي" - }, - { - "name": "sidebarcontainer_auto_hide", - "value": "هو الشريط الجانبي مخفي في الحد الأدنى من الدولة" - }, - { - "name": "sidebarcontainer_divider_width", - "value": "تقسيم خط العرض" - }, - { - "name": "sidebarcontainer_drag_divider", - "value": "اسحب فاصل لتغيير حجم الشريط الجانبي" - }, - { - "name": "sidebarcontainer__is_show_true", - "value": "الشريط الجانبي هو توسيع" - }, - { - "name": "sidebarcontainer__is_show_false", - "value": "الشريط الجانبي مغلق" - }, - { - "name": "stack_title", - "value": "كومة" - }, - { - "name": "stack_alignments_topstart", - "value": "توب ستارت" - }, - { - "name": "stack_alignments_top", - "value": "توب ." - }, - { - "name": "stack_alignments_topend", - "value": "توبند" - }, - { - "name": "stack_alignments_start", - "value": "نقطة الانطلاق" - }, - { - "name": "stack_alignment_center", - "value": "مركز" - }, - { - "name": "stack_alignment_end", - "value": "نهاية ." - }, - { - "name": "stack_alignments_bottomstart", - "value": "بداية القاع" - }, - { - "name": "stack_alignments_bottom", - "value": "القاع" - }, - { - "name": "stack_alignments_bottomend", - "value": "نهاية القاع" - }, - { - "name": "stack_alignment", - "value": "محاذاة المحتوى" - }, - { - "name": "stack_introduction", - "value": "خاصية المكدس والمعلمة aligncontent تم تحديثها" - }, - { - "name": "stack_introduction_zindex", - "value": "أكسيد الزنك" - }, - { - "name": "stack_zindex_four", - "value": "4 ." - }, - { - "name": "stack_zindex_one", - "value": "1 ." - }, - { - "name": "stack_zindex", - "value": "زيندكس" - }, - { - "name": "flex_title", - "value": "بنت ." - }, - { - "name": "flex_introduction_arguments", - "value": "تعديل تخطيط مرن المعلمات" - }, - { - "name": "flex_argument_direction", - "value": "الاتجاه" - }, - { - "name": "flex_argument_direction_row", - "value": "فصيلة" - }, - { - "name": "flex_argument_direction_row_reverse", - "value": "صف عكس" - }, - { - "name": "flex_argument_direction_column", - "value": "عمود" - }, - { - "name": "flex_argument_direction_column_reverse", - "value": "العمود عكس" - }, - { - "name": "flex_argument_wrap", - "value": "تعديل حزمة لتناسب هذا الانحناء" - }, - { - "name": "flex_argument_wrap_no_wrap", - "value": "بدون تغليف" - }, - { - "name": "flex_argument_wrap_wrap", - "value": "لف" - }, - { - "name": "flex_argument_wrap_wrap_reverse", - "value": "التعبئة والتغليف عكس" - }, - { - "name": "flex_introduction_direction", - "value": "تغيير اتجاه جميع الانحناء" - }, - { - "name": "flex_argument_justifycontent", - "value": "تعديل هذا فليكس justifycontent" - }, - { - "name": "flex_argument_justifycontent_start", - "value": "نقطة الانطلاق" - }, - { - "name": "flex_argument_justifycontent_center", - "value": "مركز" - }, - { - "name": "flex_argument_justifycontent_End", - "value": "نهاية ." - }, - { - "name": "flex_argument_justifycontent_space_between", - "value": "بين الفراغات" - }, - { - "name": "flex_argument_justifycontent_space_around", - "value": "الفضاء المحيط" - }, - { - "name": "flex_argument_justifycontent_speac_evenly", - "value": "مساحة موحدة" - }, - { - "name": "flex_argument_alignItems", - "value": "تعديل alignitems في هذا فليكس" - }, - { - "name": "flex_argumen_alignItems_auto", - "value": "السيارات" - }, - { - "name": "flex_argumen_alignItems_start", - "value": "نقطة الانطلاق" - }, - { - "name": "flex_argumen_alignItems_center", - "value": "مركز" - }, - { - "name": "flex_argumen_alignItems_end", - "value": "نهاية ." - }, - { - "name": "flex_argumen_alignItems_stretch", - "value": "امتدت" - }, - { - "name": "flex_argumen_alignItems_baseline", - "value": "خط الأساس" - }, - { - "name": "flex_argument_alignContent", - "value": "تعديل aligncontent هذا فليكس" - }, - { - "name": "gridcontainer_title", - "value": "gridcontainer نظام الشبكة" - }, - { - "name": "gridcontainer_introdional_arguments", - "value": "تعديل gridcontainer المعلمة" - }, - { - "name": "gridcontainer_introdional_properties", - "value": "تعديل خاصية gridcontainer" - }, - { - "name": "gridcontainer_sizetype", - "value": "سيزتايب" - }, - { - "name": "gridcontainer_sizetype_xs", - "value": "اكس اس" - }, - { - "name": "gridcontainer_sizetype_sm", - "value": "خ" - }, - { - "name": "gridcontainer_sizetype_md", - "value": "إم دي" - }, - { - "name": "gridcontainer_sizetype_lg", - "value": "إل جي" - }, - { - "name": "gridcontainer_sizetype_auto", - "value": "السيارات" - }, - { - "name": "gridcontainer_column", - "value": "عمود" - }, - { - "name": "gridcontainer_gutter", - "value": "مزراب" - }, - { - "name": "gridcontainer_margin", - "value": "حافة" - }, - { - "name": "image_video_and_media", - "value": "صورة الفيديو ووسائل الإعلام" - }, - { - "name": "image_title", - "value": "صور" - }, - { - "name": "image_animator_title", - "value": "صورة انيماتور" - }, - { - "name": "video_title", - "value": "فيديو : ." - }, - { - "name": "plugin_component_title", - "value": "المكونات في مكونات" - }, - { - "name": "xcomponent_title", - "value": "العنصر العاشر" - }, - { - "name": "image_show_test", - "value": "عرض الصور" - }, - { - "name": "image_object_fit", - "value": "objectfit ؛ objectfit" - }, - { - "name": "image_sourcesize_height", - "value": "حجم الارتفاع" - }, - { - "name": "image_sourcesize_width", - "value": "حجم العرض" - }, - { - "name": "object_fit_cover", - "value": "تغطية" - }, - { - "name": "object_fit_contain", - "value": "احتواء" - }, - { - "name": "object_fit_auto", - "value": "السيارات" - }, - { - "name": "object_fit_fill", - "value": "ملأ" - }, - { - "name": "object_fit_scale_down", - "value": "تقليص حجم" - }, - { - "name": "object_fit_none", - "value": "هل أنت بخير ؟ - لا -" - }, - { - "name": "object_fit_change", - "value": "ObjectFitChange" - }, - { - "name": "image_sourcesize_change", - "value": "تغيير حجم المصدر" - }, - { - "name": "image_rendermode_original", - "value": "طريقة التقديم الأصلي" - }, - { - "name": "image_rendermode_template", - "value": "تقديم نموذج" - }, - { - "name": "image_renderMode_change", - "value": "تغيير طريقة التقديم" - }, - { - "name": "image_repeat_xy", - "value": "تكرار س ص" - }, - { - "name": "image_repeat_x", - "value": "تكرار س" - }, - { - "name": "image_repeat_y", - "value": "تكرار ذ" - }, - { - "name": "image_repeat_no", - "value": "لا تكرار" - }, - { - "name": "image_repeat_change", - "value": "تكرار التغييرات" - }, - { - "name": "image_fill_color_title", - "value": "ملء لون العنوان" - }, - { - "name": "image_animator_show", - "value": "صورة انيماتور شو" - }, - { - "name": "image_animator_control", - "value": "imageanimator السيطرة" - }, - { - "name": "video_show", - "value": "عرض الفيديو" - }, - { - "name": "video_auto_play", - "value": "اللعب التلقائي" - }, - { - "name": "video_controls_show", - "value": "عرض التحكم" - }, - { - "name": "video_muted_show", - "value": "عرض صامت" - }, - { - "name": "video_fit_change", - "value": "فيديوفيت" - }, - { - "name": "video_loop_show", - "value": "لوپشو" - }, - { - "name": "video_current_rate_change", - "value": "التغيرات في سعر الصرف الحالي" - }, - { - "name": "video_play_mode", - "value": "طريقة تشغيل الفيديو" - }, - { - "name": "video_play_switch", - "value": "تشغيل الفيديو التبديل" - }, - { - "name": "web_title", - "value": "شبكي" - }, - { - "name": "web_show", - "value": "وان نيتكوم" - }, - { - "name": "web_use_reason", - "value": "سبب" - }, - { - "name": "xcomponent_show", - "value": "إكسكومبونينتشو" - }, - { - "name": "textarea_title", - "value": "حقل النص" - }, - { - "name": "patternlock_title", - "value": "رمز قفل" - }, - { - "name": "search_title", - "value": "بحث ." - }, - { - "name": "textarea_textalign_start", - "value": "نقطة الانطلاق" - }, - { - "name": "textarea_textalign_center", - "value": "مركز" - }, - { - "name": "textarea_textalign_end", - "value": "نهاية ." - }, - { - "name": "textareaa_textalign_change", - "value": "textarealatextalignchange" - }, - { - "name": "textarea_show", - "value": "تكست اريشو" - }, - { - "name": "textarea_control", - "value": "السيطرة على منطقة النص" - }, - { - "name": "textarea_copyoptions_none", - "value": "هل أنت بخير ؟ - لا -" - }, - { - "name": "textarea_copyoptions_inapp", - "value": "داخل التطبيق" - }, - { - "name": "textarea_copyoptions_localdevice", - "value": "الأجهزة المحلية" - }, - { - "name": "textarea_copyoptions_change", - "value": "تغيير خيارات النسخ المتماثل" - }, - { - "name": "textarea_placeholder_change", - "value": "تغيير النائبة" - }, - { - "name": "textarea_caretcolor_change", - "value": "علوم التمريض" - }, - { - "name": "patternlock_active_color", - "value": "باترن لوك اكتف كولور" - }, - { - "name": "patternlock_path_color", - "value": "patternlockparhcolor" - }, - { - "name": "patternlock_select_color", - "value": "نمط قفل اختيار اللون" - }, - { - "name": "patternlock_regular_color", - "value": "patternlockregular اللون" - }, - { - "name": "patternlock_side_length", - "value": "نمط طول القفل" - }, - { - "name": "patternlock_circle_radius", - "value": "نمط قفل دائرة نصف قطرها" - }, - { - "name": "patternlock_pathstroke_width", - "value": "patternlockpath strokewidth" - }, - { - "name": "patternlock_change", - "value": "تغيير نمط قفل" - }, - { - "name": "search_textalign_change", - "value": "البحث عن النص محاذاة التغييرات" - }, - { - "name": "search_placeholder_change", - "value": "البحث عن تغيير النائبة" - }, - { - "name": "search_copyOption_change", - "value": "البحث عن خيارات النسخ المتماثل التغييرات" - }, - { - "name": "search_change", - "value": "البحث عن التغييرات" - }, - { - "name": "list_title", - "value": "قائمة" - }, - { - "name": "list_introduction_arguments", - "value": "قائمة المعلمات" - }, - { - "name": "list_introduction_properties", - "value": "قائمة خصائص" - }, - { - "name": "list_introduction_state", - "value": "شريط الحالة" - }, - { - "name": "list_properties_direction", - "value": "قائمة الاتجاه" - }, - { - "name": "list_properties_direction_vertical", - "value": "عمودي" - }, - { - "name": "list_properties_direction_Horizontal", - "value": "الاتجاه الأفقي" - }, - { - "name": "list_argument_space", - "value": "الفضاء ." - }, - { - "name": "list_properties_divider_stroke_width", - "value": "فاصل - السكتة الدماغية العرض" - }, - { - "name": "list_properties_scroll_bar_width", - "value": "سكرول بار - عرض" - }, - { - "name": "list_properties_scroll_bar_color", - "value": "سكرول بار - لون" - }, - { - "name": "list_properties_divider_color", - "value": "فاصل - لون" - }, - { - "name": "list_properties_scroll_bar", - "value": "سكرول بار" - }, - { - "name": "list_properties_scroll_bar_off", - "value": "قريب" - }, - { - "name": "list_properties_scroll_bar_on", - "value": "ون" - }, - { - "name": "list_properties_scroll_bar_auto", - "value": "السيارات" - }, - { - "name": "list_properties_initial_index", - "value": "initial index" - }, - { - "name": "list_properties_edge_effect", - "value": "تأثير الحافة" - }, - { - "name": "list_properties_edge_effect_spring", - "value": "الربيع ." - }, - { - "name": "list_properties_edge_effect_fade", - "value": "تلاشى" - }, - { - "name": "list_properties_edge_effect_none", - "value": "هل أنت بخير ؟ - لا -" - }, - { - "name": "list_properties_chain_animation", - "value": "سلسلة الرسوم المتحركة" - }, - { - "name": "list_properties_multi_selectable", - "value": "اختيار متعددة" - }, - { - "name": "list_properties_lanes", - "value": "حارة" - }, - { - "name": "list_properties_align_list_item", - "value": "اليگنليستیتم" - }, - { - "name": "list_properties_align_list_item_start", - "value": "نقطة الانطلاق" - }, - { - "name": "list_properties_align_list_item_Center", - "value": "مركز" - }, - { - "name": "list_properties_align_list_item_End", - "value": "نهاية ." - }, - { - "name": "list_introduction_delete", - "value": "غادر انقر فوق حذف البند" - }, - { - "name": "list_item_title", - "value": "قائمة البنود" - }, - { - "name": "list_item_properties_selectable", - "value": "اختياري" - }, - { - "name": "list_item_introduction_drag", - "value": "اسحب العناصر مع الماوس لعرض خصائص اختيارية" - }, - { - "name": "list_item_introduction_properties", - "value": "تعديل خصائص listitem" - }, - { - "name": "grid_title", - "value": "شبكة ." - }, - { - "name": "grid_item_title", - "value": "شبكة البند" - }, - { - "name": "grid_properties_columns_template", - "value": "columnstemplate ( السيطرة على نسبة العمود الثالث )" - }, - { - "name": "grid_properties_columns_gap", - "value": "إزالة العمود" - }, - { - "name": "girid_properties_rows_gap", - "value": "روس جاب" - }, - { - "name": "grid_properties_layout_direction", - "value": "تخطيط الاتجاه" - }, - { - "name": "grid_properties_layout_direction_row", - "value": "فصيلة" - }, - { - "name": "grid_properties_layout_direction_column", - "value": "عمود" - }, - { - "name": "grid_properties_layout_direction_row_reverse", - "value": "صف عكس" - }, - { - "name": "grid_properties_layout_direction_column_reverse", - "value": "العمود عكس" - }, - { - "name": "grid_properties_rows_template", - "value": "rowstemplate ( السيطرة على نسبة من السطر الثالث )" - }, - { - "name": "grid_item_introduction", - "value": "تغيير الموقع" - }, - { - "name": "grid_item_row_start", - "value": "تغيير رقم السطر الأول" - }, - { - "name": "grid_item_row_end", - "value": "تعديل رقم خط النهاية" - }, - { - "name": "grid_item_column_start", - "value": "تغيير رقم العمود الأولي" - }, - { - "name": "grid_item_column_end", - "value": "تعديل نهاية العمود رقم" - }, - { - "name": "swiper_introduction_arguments", - "value": "انزلاق تحكم" - }, - { - "name": "swiper_introduction_properties", - "value": "تعديل خصائص المنزلق" - }, - { - "name": "swiper_properties_disable_swipe", - "value": "تعطيل التحول إلى اليسار أو اليمين" - }, - { - "name": "swiper_properties_item_space", - "value": "المسافة بين الصفحات المنزلقة" - }, - { - "name": "swiper_properties_vertical", - "value": "انزلاق عمودي" - }, - { - "name": "swiper_properties_duration", - "value": "مدة الانتقال المتحركة في الألف" - }, - { - "name": "swiper_properties_loop", - "value": "تمكين حلقة" - }, - { - "name": "swiper_properties_interval", - "value": "التلقائي الفاصل الزمني ( الوحدة : ماجستير )" - }, - { - "name": "swiper_controller_next", - "value": "الصفحة التالية" - }, - { - "name": "swiper_controller_previous", - "value": "الصفحة السابقة" - }, - { - "name": "swiper_common_interfaces_and_properties", - "value": "واجهة عامة والممتلكات" - }, - { - "name": "swiper_custom_properties", - "value": "خصائص مخصصة الانتقال المتحركة" - }, - { - "name": "swiper_modify_custom_properties", - "value": "تعديل خصائص مخصصة الانتقال المتحركة" - }, - { - "name": "swiper_custom_property_opacity", - "value": "تغيير التعتيم مدة الرسوم المتحركة" - }, - { - "name": "swiper_custom_property_scale", - "value": "زيادة مدة الصفحة المتحركة" - }, - { - "name": "swiper_close_two_pages_together", - "value": "الجمع بين صفحتين عند التكبير" - }, - { - "name": "swiper_cancel_default_translate", - "value": "إلغاء الترجمة الافتراضية" - }, - { - "name": "swiper_property_auto_play", - "value": "اللعب التلقائي" - }, - { - "name": "swiper_custom_property_curve", - "value": "عرف الانتقال منحنى الرسوم المتحركة" - }, - { - "name": "navRouter_title", - "value": "توجيه الملاحة" - }, - { - "name": "navigation_title", - "value": "ملاحة" - }, - { - "name": "navigation_first_page", - "value": "تصفح الصفحة الرئيسية" - }, - { - "name": "navigation_second_page", - "value": "تصفح ب" - }, - { - "name": "navigation_third_page", - "value": "تصفح ب" - }, - { - "name": "navigation_first_page_push", - "value": "انتقل إلى الصفحة الثانية" - }, - { - "name": "navigation_first_page_active", - "value": "انقر فوق تبديل حالة التنشيط" - }, - { - "name": "navigation_second_page_push", - "value": "انتقل إلى الصفحة الثالثة" - }, - { - "name": "navigation_third_page_back", - "value": "العودة إلى الصفحة الأولى" - }, - { - "name": "navigation_basic_title", - "value": "أساسيات الملاحة" - }, - { - "name": "navigation_expand", - "value": "تكشفت" - }, - { - "name": "navigation_list_expand_title", - "value": "قائمة التصفح يوسع منطقة آمنة" - }, - { - "name": "navigation_bindsheet_title", - "value": "منطقة الأمان" - }, - { - "name": "navigation_expand_title", - "value": "الملاحة في المنطقة الأمنية الموسعة" - }, - { - "name": "navigation_unexpand", - "value": "لا تتكشف" - }, - { - "name": "navigation_split_title", - "value": "الملاحة تقسيم" - }, - { - "name": "navigation_sidebar_title", - "value": "شريط التنقل" - }, - { - "name": "navigation_navbar_list_nopara", - "value": "قائمة" - }, - { - "name": "navigation_navbar_list", - "value": "قائمة د" - }, - { - "name": "navigation_navcontent_list", - "value": "المحتوى د" - }, - { - "name": "navigation_hidebar_title", - "value": "إخفاء شريط التنقل" - }, - { - "name": "navigation_replace_title", - "value": "استبدال الملاحة" - }, - { - "name": "navigation_replace_page", - "value": "استبدال الصفحة الحالية" - }, - { - "name": "navigation_modechange_title", - "value": "تغيير نمط" - }, - { - "name": "navigation_rotate_screen", - "value": "تدوير الشاشة" - }, - { - "name": "navigation_modevalue", - "value": "سمود القيمة" - }, - { - "name": "navigation_mode_callback", - "value": "طريقة الاستدعاء" - }, - { - "name": "navigation_safearea_title", - "value": "سلامة الملاحة في المنطقة" - }, - { - "name": "navigation_safearea_default", - "value": "خرق" - }, - { - "name": "navigation_safearea_expand", - "value": "تكشفت" - }, - { - "name": "navigation_safearea_unexpand", - "value": "لا تتكشف" - }, - { - "name": "navigation_router_title", - "value": "هوب هوب هار" - }, - { - "name": "navigation_router_har1", - "value": "القفز إلى har1" - }, - { - "name": "navigation_router_har2", - "value": "القفز إلى هارتو" - }, - { - "name": "tabs_title", - "value": "تبويب" - }, - { - "name": "tabs_introduction_arguments", - "value": "تعديل بارامترات التبويب" - }, - { - "name": "tabs_introduction_properties", - "value": "تعديل خصائص التبويب" - }, - { - "name": "tabs_arguments_bar_position", - "value": "بار الكلمات" - }, - { - "name": "tabs_arguments_bar_position_start", - "value": "نقطة الانطلاق" - }, - { - "name": "tabs_arguments_bar_position_end", - "value": "نهاية ." - }, - { - "name": "tabs_properties_vertical", - "value": "عمودي" - }, - { - "name": "tabs_properties_bar_mode", - "value": "بار مود" - }, - { - "name": "tabs_properties_bar_mode_fixed", - "value": "ثابت" - }, - { - "name": "tabs_properties_bar_scrollable", - "value": "قابل للتدوير" - }, - { - "name": "tabs_properties_is_scrollable", - "value": "قابل للتدوير" - }, - { - "name": "tabs_properties_animation_duration", - "value": "مدة الرسوم المتحركة ( ماجستير )" - }, - { - "name": "tabs_arguments_controller", - "value": "التبديل إلى مؤشر محدد" - }, - { - "name": "tab_content_title", - "value": "علامة التبويب المحتوى" - }, - { - "name": "tab_content_introduction", - "value": "subtab / أسفل التبويب الجلاد" - }, - { - "name": "tab_content_side", - "value": "تبديل الشريط الجانبي" - }, - { - "name": "stepper_title", - "value": "السائر السائر المشروع" - }, - { - "name": "canvas_title", - "value": "قماش" - }, - { - "name": "circle_title", - "value": "دائرة" - }, - { - "name": "ellipse_title", - "value": "القطع الناقص" - }, - { - "name": "line_title", - "value": "خط" - }, - { - "name": "polyline_title", - "value": "خط الرسم البياني" - }, - { - "name": "path_title", - "value": "مسار" - }, - { - "name": "polygon_title", - "value": "مضلع" - }, - { - "name": "rect_title", - "value": "ناظر" - }, - { - "name": "shape_title", - "value": "شكل ." - }, - { - "name": "circle_change", - "value": "دائرة التغيير" - }, - { - "name": "circle_change_fill", - "value": "دائرة تغيير ملء" - }, - { - "name": "circle_change_radius", - "value": "دائرة نصف قطرها" - }, - { - "name": "circle_change_fillopacity", - "value": "جولة تغيير ملء التعتيم" - }, - { - "name": "circle_change_strokewidth", - "value": "عرض الحلزون" - }, - { - "name": "circle_stroke_dash", - "value": "سيركلي تروك داش" - }, - { - "name": "circle_stroke_color", - "value": "نمط دائري" - }, - { - "name": "circle_stroke_opacity", - "value": "مسار دائري التعتيم" - }, - { - "name": "ellipse_fill", - "value": "بيضاوي الشكل ملء" - }, - { - "name": "ellipse_stroke_color", - "value": "القطع الناقص لون السكتة الدماغية" - }, - { - "name": "ellipse_stroke_width", - "value": "عرض القطع الناقص" - }, - { - "name": "ellipse_width", - "value": "عرض القطع الناقص" - }, - { - "name": "ellipse_height", - "value": "ارتفاع القطع الناقص" - }, - { - "name": "ellipse_fill_opacity", - "value": "بيضاوي الشكل ملء التعتيم" - }, - { - "name": "ellipse_stroke_opacity", - "value": "حذفي ستروبوسكوبيك التعتيم" - }, - { - "name": "ellipse_stroke_dash", - "value": "إليبسو ستروك داش" - }, - { - "name": "line_start_point_x", - "value": "خط البداية س" - }, - { - "name": "line_start_point_y", - "value": "خط البداية ذ" - }, - { - "name": "line_end_point_x", - "value": "خط النهاية ذ" - }, - { - "name": "line_end_point_y", - "value": "خط النهاية ذ" - }, - { - "name": "line_stroke_width", - "value": "خط العرض" - }, - { - "name": "line_stroke_color", - "value": "لون الخط" - }, - { - "name": "line_stroke_opacity", - "value": "خط التعتيم" - }, - { - "name": "line_stroke_dash", - "value": "لين ستروك داش" - }, - { - "name": "polygon_fill", - "value": "مضلع ملء" - }, - { - "name": "polygon_fill_opacity", - "value": "مضلع ملء التعتيم" - }, - { - "name": "polygon_stroke_color", - "value": "مضلع لون السكتة الدماغية" - }, - { - "name": "polygon_stroke_opacity", - "value": "مضلع السكتة الدماغية التعتيم" - }, - { - "name": "polygon_stroke_width", - "value": "عرض مضلع السكتة الدماغية" - }, - { - "name": "polygon_stroke_dash", - "value": "بوليغون ستروك داش" - }, - { - "name": "polyline_first_x", - "value": "بولين فيرست إكس" - }, - { - "name": "polyline_first_y", - "value": "بولين فيرست" - }, - { - "name": "polyline_second_x", - "value": "بولين سيكوندكس" - }, - { - "name": "polyline_second_y", - "value": "بولين سيندي" - }, - { - "name": "polyline_third_x", - "value": "بولين ثيردكس" - }, - { - "name": "polyline_third_y", - "value": "بولين ثيردي" - }, - { - "name": "polyline_stroke_width", - "value": "عرض السكتة الدماغية" - }, - { - "name": "polyline_stroke_color", - "value": "لون الخط" - }, - { - "name": "polyline_stroke_dash", - "value": "بولين ستروك داش" - }, - { - "name": "polyline_stroke_opacity", - "value": "السكتة الدماغية التعتيم" - }, - { - "name": "rect_height", - "value": "ارتفاع المستطيل" - }, - { - "name": "rect_width", - "value": "عرض مستطيل" - }, - { - "name": "rect_radius_width", - "value": "عرض المستطيل" - }, - { - "name": "rect_radius_height", - "value": "ارتفاع المستقيم" - }, - { - "name": "rect_fill_opacity", - "value": "مستطيلة التعتيم" - }, - { - "name": "rect_stroke", - "value": "السكتة الدماغية المستقيم" - }, - { - "name": "rect_stroke_width", - "value": "rectstrokewidth" - }, - { - "name": "rect_stroke_dash", - "value": "ريكت سروك داش" - }, - { - "name": "rect_stroke_opacity", - "value": "rectstrokeopacity" - }, - { - "name": "rect_fill", - "value": "ريكتفيل" - }, - { - "name": "path_line", - "value": "باث لين" - }, - { - "name": "path_triangle", - "value": "باث تريانجل" - }, - { - "name": "path_square", - "value": "باث سكوير" - }, - { - "name": "path_polygon", - "value": "باث بوليغون" - }, - { - "name": "path_camber_first", - "value": "باث كامبر فيرست" - }, - { - "name": "path_camber_second", - "value": "باث كامبر سوند" - }, - { - "name": "path_camber_third", - "value": "باث كامبر ثيرد" - }, - { - "name": "path_commands_select", - "value": "اختيار مسار القيادة" - }, - { - "name": "path_fill", - "value": "باث فيل" - }, - { - "name": "path_fill_opacity", - "value": "pathfill التعتيم" - }, - { - "name": "path_stroke_color", - "value": "باث ستروك كولور" - }, - { - "name": "path_stroke_opacity", - "value": "باث ستوك اوباسيتي" - }, - { - "name": "path_stroke_dash", - "value": "باث ستوك داش" - }, - { - "name": "path_stroke_width", - "value": "باث ستوك ويدث" - }, - { - "name": "shape_fill", - "value": "شكل ملء" - }, - { - "name": "shape_stroke_color", - "value": "شكل ولون السكتة الدماغية" - }, - { - "name": "shape_view_port_x", - "value": "shapeviewportx" - }, - { - "name": "shape_view_port_y", - "value": "شابي فيو بورتي" - }, - { - "name": "shape_view_port_width", - "value": "shapeviewportwidth" - }, - { - "name": "shape_view_port_height", - "value": "shapeviewportheight" - }, - { - "name": "shape_stroke_opacity", - "value": "shapestroke التعتيم" - }, - { - "name": "shape_fill_opacity", - "value": "shapefill التعتيم" - }, - { - "name": "shape_stroke_width", - "value": "شكل عرض السكتة الدماغية" - }, - { - "name": "shape_stroke_dash", - "value": "شابستروك داش" - }, - { - "name": "web", - "value": "شبكي" - }, - { - "name": "canvas_fillStyle", - "value": "فيل ستايل" - }, - { - "name": "canvas_lineWidth", - "value": "خط العرض" - }, - { - "name": "canvas_strokeStyle", - "value": "ستروك ستايل" - }, - { - "name": "canvas_lineCap", - "value": "لين كاب" - }, - { - "name": "canvas_lineJoin", - "value": "خط الانضمام" - }, - { - "name": "canvas_miterLimit", - "value": "ميتر ليميت" - }, - { - "name": "canvas_font", - "value": "فونت" - }, - { - "name": "canvas_textAlign", - "value": "محاذاة النص" - }, - { - "name": "canvas_textBaseline", - "value": "خط النص" - }, - { - "name": "canvas_globalAlpha", - "value": "غلوبال ألفا" - }, - { - "name": "canvas_lineDashOffset", - "value": "لين داش اوفست" - }, - { - "name": "canvas_globalCompositeOperation", - "value": "عملية التوليف العالمية" - }, - { - "name": "canvas_imageSmoothingEnabled", - "value": "imagesmoothing تمكين" - }, - { - "name": "canvas_createLinearGradient", - "value": "إنشاء التدرج الخطي" - }, - { - "name": "cavas_createRadialGradient", - "value": "خلق التدرج الإشعاعي" - }, - { - "name": "canvas_createRadialGradient", - "value": "خلق التدرج الإشعاعي" - }, - { - "name": "canvas_fillRect", - "value": "فيلريكت" - }, - { - "name": "canvas_strokeRect", - "value": "ستروك ريكت" - }, - { - "name": "canvas_fillText", - "value": "فيلت تكست" - }, - { - "name": "canvas_strokeText", - "value": "ستروكيتكست" - }, - { - "name": "canvas_measureText", - "value": "ميسوريتكست" - }, - { - "name": "canvas_stroke", - "value": "( ضرب ، ضرب ، الخ )" - }, - { - "name": "canvas_createPattern", - "value": "كرياتيباترن" - }, - { - "name": "canvas_fill", - "value": "شغل" - }, - { - "name": "canvas_clip", - "value": "قطع" - }, - { - "name": "canvas_rotate", - "value": "استدارة" - }, - { - "name": "canvas_scale", - "value": "مقياس" - }, - { - "name": "canvas_drawImage", - "value": "دراويماغي" - }, - { - "name": "canvas_getImageData", - "value": "الحصول على بيانات الصورة" - }, - { - "name": "canvas_putImageData", - "value": "بوتیمگدیتا" - }, - { - "name": "canvas_setLineDash", - "value": "ست لين داش" - }, - { - "name": "canvas_getLineDash", - "value": "جيتلين داش" - }, - { - "name": "canvas_transferFromImageBitmap", - "value": "transferfrom imagebitmap" - }, - { - "name": "canvas_toDataURL", - "value": "توداتورل" - }, - { - "name": "cavnas_clearRect", - "value": "كلير ريكت" - }, - { - "name": "canvas_clearRect", - "value": "كلير ريكت" - }, - { - "name": "canvas_shadowBlur", - "value": "شادوبلور" - }, - { - "name": "canvas_shadowColor", - "value": "لون الظل" - }, - { - "name": "canvas_shadowOffsetX", - "value": "شادووفسيتكس" - }, - { - "name": "canvas_shadowOffsetY", - "value": "الظل تعويض ذ" - }, - { - "name": "canvas_addColorStop", - "value": "addclorstop" - }, - { - "name": "canvas_beginPath", - "value": "بيغن باث" - }, - { - "name": "canvas_moveTo", - "value": "تحرك" - }, - { - "name": "canvas_lineTo", - "value": "لين تو" - }, - { - "name": "canvas_closePath", - "value": "كلوس باث" - }, - { - "name": "canvas_bezierCurveTo", - "value": "بيزير كيرفيتو" - }, - { - "name": "canvas_quadraticCurveTo", - "value": "الرسم البياني مع منحنى بيزيير" - }, - { - "name": "canvas_arc", - "value": "قوس" - }, - { - "name": "canvas_arcTo", - "value": "اركتو" - }, - { - "name": "canvas_ellipse", - "value": "القطع الناقص" - }, - { - "name": "canvas_rect", - "value": "ريست" - }, - { - "name": "canvas_transform", - "value": "تحول" - }, - { - "name": "canvas_setTransform", - "value": "ست ترانسفورم" - }, - { - "name": "canvas_translate", - "value": "ترجمة ." - }, - { - "name": "canvas_imageSmoothingQuality", - "value": "تجانس الصورة" - }, - { - "name": "navigator_title", - "value": "الملاح" - }, - { - "name": "navigator_first_page", - "value": "الصفحة الأولى من Navigaor" - }, - { - "name": "navigator_second_page", - "value": "الصفحة الثانية من المستكشف" - }, - { - "name": "navigator_third_page", - "value": "الصفحة الثالثة من المستكشف" - }, - { - "name": "navigator_first_page_push", - "value": "انتقل إلى الصفحة الثانية" - }, - { - "name": "navigator_first_page_active", - "value": "انقر فوق تبديل حالة التنشيط" - }, - { - "name": "navigator_second_page_push", - "value": "انتقل إلى الصفحة الثالثة" - }, - { - "name": "navigator_third_page_back", - "value": "العودة إلى الصفحة الأولى" - }, - { - "name": "navigator_return_message", - "value": "! مرحباً - ! مرحباً - هذه هي الصفحة الأولى من المعلمات" - }, - { - "name": "component_id_press_to_see_attributeModifier", - "value": "عرض attributemodifier حسب العنصر رقم" - }, - { - "name": "component_id_click_to_see_attributeModifier", - "value": "انقر على عنصر معرف لعرض attributemodifier" - }, - { - "name": "component_id_disable_to_see_attributeModifier", - "value": "العنصر رقم تعطيل عرض attributemodifier" - }, - { - "name": "component_id_disable_radio", - "value": "العنصر رقم تعطيل الراديو" - }, - { - "name": "component_id_press_list_to_see_attributeModifier", - "value": "عنصر معرف عرض attributemodifier القائمة" - }, - { - "name": "water_flow_title", - "value": "تدفق المياه" - }, - { - "name": "water_flow_controller", - "value": "تحكم تدفق المياه" - }, - { - "name": "water_flow_properties", - "value": "خصائص تدفق المياه" - }, - { - "name": "water_flow_controller_scrollEdge", - "value": "سكرول ايدج" - }, - { - "name": "water_flow_controller_scrollBy", - "value": "المتداول الصحافة" - }, - { - "name": "water_flow_controller_top", - "value": "توب ." - }, - { - "name": "water_flow_controller_bottom", - "value": "القاع" - }, - { - "name": "water_flow_properties_scroll_bar_width", - "value": "scrollbar العرض" - }, - { - "name": "water_flow_properties_scroll_bar_color", - "value": "لون سكرول بار" - }, - { - "name": "water_flow_properties_scroll_bar", - "value": "سكرول بار" - }, - { - "name": "water_flow_properties_edge_effect", - "value": "تأثير الحافة" - }, - { - "name": "water_flow_properties_edge_effect_spring", - "value": "الربيع ." - }, - { - "name": "water_flow_properties_edge_effect_fade", - "value": "تلاشى" - }, - { - "name": "water_flow_properties_edge_effect_none", - "value": "هل أنت بخير ؟ - لا -" - }, - { - "name": "horizontal_reach_start", - "value": "التمرير الأفقي على reachstart" - }, - { - "name": "horizontal_reach_end", - "value": "التمرير الأفقي على reachend" - }, - { - "name": "vertical_reach_start", - "value": "التمرير الرأسي على reachstart" - }, - { - "name": "vertical_reach_end", - "value": "التمرير الرأسي على reachend" - }, - { - "name": "current_initialIndex", - "value": "initialindex الحالي هو :" - }, - { - "name": "modify_initialIndex_tips", - "value": "بعد initialindex التغييرات ، أدخل هذه الصفحة مرة أخرى" - }, - { - "name": "current_scroll_event", - "value": "أحداث التمرير الحالية :" - }, - { - "name": "current_scroll_state", - "value": "الوضع الحالي :" - }, - { - "name": "current_scroll_distance", - "value": "المسافة الحالية التمرير :" - }, - { - "name": "current_scroll_index_first", - "value": "مؤشر التمرير الحالي ، الأول :" - }, - { - "name": "current_scroll_index_last", - "value": "وأخيرا :" - }, - { - "name": "current_event_value", - "value": "لا أحداث" - }, - { - "name": "current_event_on_scroll", - "value": "على المتداول" - }, - { - "name": "current_event_on_scroll_index", - "value": "أونسولل إنديكس" - }, - { - "name": "current_event_on_scroll_start", - "value": "أونسكرول ستارت" - }, - { - "name": "current_event_on_scroll_stop", - "value": "انسكولستوب" - }, - { - "name": "panel_background_color", - "value": "#ffffff" - }, - { - "name": "multiple_attribute_take_effect", - "value": "دينامية مجموعة خصائص العنصر : خصائص متعددة الإعدادات في وقت واحد" - }, - { - "name": "click_to_see_image_border_change", - "value": "انقر على زر عرض تغيير حدود الصورة" - }, - { - "name": "dynamical_updates_ui_directly", - "value": "خصائص العنصر هي مجموعة ديناميكية ، غير الدولة متغير يؤدي مباشرة إلى تحديث واجهة المستخدم" - }, - { - "name": "click_to_see_component_change", - "value": "انقر على زر عرض عنصر تغيير قيمة الممتلكات" - }, - { - "name": "click_to_see_text_component_change", - "value": "انقر فوق تحديث مكونات النص البناء باستخدام المعلمات" - } - ] +{ + "string": [ + { + "name": "focus_control_tab_status", + "value": "مركز تنسيق نمط التبديل : لوحة المفاتيح الخارجية تبويب مفتاح التبديل مركز تنسيق عرض التغييرات" + }, + { + "name": "select_to_see_status", + "value": "اختيار نمط الدولة التبديل" + }, + { + "name": "disable_to_see_status", + "value": "تعطيل وضع نمط التبديل" + }, + { + "name": "press_to_see_status", + "value": "اضغط على مفتاح نمط الدولة" + }, + { + "name": "click_to_see_status", + "value": "الوضع العادي نمط التبديل" + }, + { + "name": "custom_event", + "value": "عنصر مخصص توزيع الحدث" + }, + { + "name": "custom_click_event_button", + "value": "نقر" + }, + { + "name": "custom_Scrolling_event_button", + "value": "توالت" + }, + { + "name": "custom_judge_title", + "value": "قاضي" + }, + { + "name": "custom_judge_long_press", + "value": "منطقة استجابة طويلة" + }, + { + "name": "custom_long_press_prompt", + "value": "اضغط على الجزء العلوي من المنطقة الزرقاء لفترة طويلة ، المنطقة الزرقاء سوف تستجيب" + }, + { + "name": "custom_judge_click", + "value": "انقر فوق منطقة الاستجابة" + }, + { + "name": "custom_tap_prompt", + "value": "انقر على الجزء السفلي من المنطقة الصفراء ، المنطقة الصفراء سوف تستجيب" + }, + { + "name": "custom_bigcircle_prompt", + "value": "العرف نصائح دائرة كبيرة" + }, + { + "name": "custom_smallcircle_prompt", + "value": "العرف نصائح دائرة صغيرة" + }, + { + "name": "custom_gesture", + "value": "العرف لفتة تحديد" + }, + { + "name": "send_event", + "value": "إرسال الحدث" + }, + { + "name": "custom_click_event", + "value": "نقر" + }, + { + "name": "custom_scrolling_event", + "value": "توالت" + }, + { + "name": "custom_scrolling_area", + "value": "منطقة التمرير" + }, + { + "name": "custom_click_big_btn", + "value": "دائرة كبيرة" + }, + { + "name": "custom_click_small_btn", + "value": "دائرة صغيرة" + }, + { + "name": "big_circle_prompt", + "value": "المنطقة الزرقاء مع دائرة الحدث" + }, + { + "name": "small_circle_prompt", + "value": "المنطقة الصفراء مع دائرة الأحداث" + }, + { + "name": "Blue", + "value": "بلو" + }, + { + "name": "button", + "value": "الأزرار" + }, + { + "name": "entry_desc", + "value": "مجموعة من المكونات" + }, + { + "name": "MainAbility_desc", + "value": "arkui العنصر ، السمة العامة ، طريقة عامة ، الخ ." + }, + { + "name": "animation", + "value": "أنمي" + }, + { + "name": "component", + "value": "مكون" + }, + { + "name": "universal", + "value": "عام ." + }, + { + "name": "global_method", + "value": "النهج العالمي" + }, + { + "name": "auxiliary", + "value": "المعدات المساعدة" + }, + { + "name": "common_properties", + "value": "السمة المشتركة" + }, + { + "name": "prop_background", + "value": "معلومات أساسية" + }, + { + "name": "safe_area", + "value": "منطقة الأمان" + }, + { + "name": "attribute_modifier", + "value": "خاصية تعديل" + }, + { + "name": "prop_foreground", + "value": "احتمال" + }, + { + "name": "prop_border", + "value": "حدود ." + }, + { + "name": "prop_outline", + "value": "مخطط" + }, + { + "name": "prop_font", + "value": "فونت" + }, + { + "name": "prop_bluefont", + "value": "#409EFF" + }, + { + "name": "prop_orangefont", + "value": "#E6A23C" + }, + { + "name": "prop_pinkfont", + "value": "#F56C6C" + }, + { + "name": "prop_size", + "value": "حجم" + }, + { + "name": "graphic_transformation", + "value": "تحويل الرسومات" + }, + { + "name": "common_events", + "value": "الأحداث المشتركة" + }, + { + "name": "click_event", + "value": "انقر فوق الحدث" + }, + { + "name": "touch_event", + "value": "لمس الحدث" + }, + { + "name": "show_hide_event", + "value": "إظهار / إخفاء الأحداث" + }, + { + "name": "drag_drop_event", + "value": "سحب وإسقاط الحدث" + }, + { + "name": "key_event", + "value": "الأحداث الرئيسية" + }, + { + "name": "focus_event", + "value": "التركيز على النشاط" + }, + { + "name": "mouse_event", + "value": "الماوس الحدث" + }, + { + "name": "component_area_change_event", + "value": "عنصر تغيير الحدث" + }, + { + "name": "gesture_processing", + "value": "لفتة تجهيز" + }, + { + "name": "basic_gestures", + "value": "لفتة الأساسية" + }, + { + "name": "tap_gesture", + "value": "انقر على لفتة" + }, + { + "name": "long_press_gesture", + "value": "لفتة طويلة" + }, + { + "name": "pan_gesture", + "value": "بانجيستور" + }, + { + "name": "pinch_gesture", + "value": "قرصة لفتة" + }, + { + "name": "rotation_gesture", + "value": "لفتة التناوب" + }, + { + "name": "swipe_gesture", + "value": "انزلاق الموقف" + }, + { + "name": "combined_gestures", + "value": "الجمع بين لفتة" + }, + { + "name": "transition_animation", + "value": "الانتقال من الرسوم المتحركة" + }, + { + "name": "interpolation_calculation", + "value": "حساب الاستيفاء" + }, + { + "name": "dialog", + "value": "الحوارات" + }, + { + "name": "button_and_selection", + "value": "أزرار واختيار" + }, + { + "name": "information_presentation_and_dynamic_effects", + "value": "عرض المعلومات و تأثير ديناميكي" + }, + { + "name": "blank_and_divider", + "value": "الفراغات و فواصل" + }, + { + "name": "text_and_input", + "value": "النص والمدخلات" + }, + { + "name": "layout_animation_expansion", + "value": "تصميم الرسوم المتحركة" + }, + { + "name": "layout_animation_expansion_align", + "value": "محاذاة الرسوم المتحركة" + }, + { + "name": "layout_animation_expansion_size", + "value": "حجم الرسوم المتحركة" + }, + { + "name": "layout_animation_expansion_padding", + "value": "ملء الرسوم المتحركة" + }, + { + "name": "layout_animation_expansion_margin", + "value": "الهوامش المتحركة" + }, + { + "name": "layout_animation_expansion_offset", + "value": "إزاحة الرسوم المتحركة" + }, + { + "name": "layout_animation_expansion_position", + "value": "الكلمات المتحركة" + }, + { + "name": "layout_animation_expansion_markAnchor", + "value": "مارك انكور للرسوم المتحركة" + }, + { + "name": "layout_animation_expansion_alignRules", + "value": "alignrules المتحركة" + }, + { + "name": "layout_animation_expansion_direction", + "value": "اتجاه الرسوم المتحركة" + }, + { + "name": "size_transition_expansion", + "value": "بعد الانتقال" + }, + { + "name": "alert_dialog", + "value": "تنبيه الحوار" + }, + { + "name": "alert_dialog_type_one", + "value": "مفتاح إنذار مربع الحوار" + }, + { + "name": "alert_dialog_type_two", + "value": "زر مزدوج مربع الحوار التنبيه" + }, + { + "name": "alert_dialog_type_two_button_one", + "value": "هذا هو الزر الأول" + }, + { + "name": "alert_dialog_type_two_button_two", + "value": "هذا هو الزر الثاني" + }, + { + "name": "alert_dialog_prompt", + "value": "جديلة" + }, + { + "name": "alert_dialog_warning", + "value": "حذر" + }, + { + "name": "alert_dialog_info", + "value": "أنت تقوم بعمل" + }, + { + "name": "alert_dialog_confirm", + "value": "أكّد" + }, + { + "name": "alert_dialog_cancel", + "value": "ألغى" + }, + { + "name": "alert_dialog_type", + "value": "نوع الحوار" + }, + { + "name": "alert_dialog_location", + "value": "موقع المحادثة" + }, + { + "name": "alert_dialog_auto_cancel", + "value": "انقر فوق طبقة قناع لإغلاق مربع الحوار" + }, + { + "name": "alert_dialog_true", + "value": "يمكن إغلاق" + }, + { + "name": "alert_dialog_false", + "value": "لم تغلق" + }, + { + "name": "alert_dialog_top", + "value": "أعلى رأسي" + }, + { + "name": "alert_dialog_center", + "value": "مركز عمودي" + }, + { + "name": "alert_dialog_bottom", + "value": "عمودي أسفل" + }, + { + "name": "alert_dialog_offset", + "value": "الموقف النسبي إزاحة مربع الحوار" + }, + { + "name": "alert_dialog_left", + "value": "أعلى اليسار ويقابل" + }, + { + "name": "alert_dialog_right", + "value": "أسفل اليمين ويقابل" + }, + { + "name": "alert_dialog_grid", + "value": "شبكة مختلفة عرض مربع الحوار" + }, + { + "name": "alert_dialog_grid_two", + "value": "عرض الشبكة" + }, + { + "name": "alert_dialog_grid_three", + "value": "عرض الشبكة" + }, + { + "name": "alert_dialog_grid_four", + "value": "عرض الشبكة" + }, + { + "name": "foreground_color", + "value": "تعيين لون المقدمة" + }, + { + "name": "background_color", + "value": "تعيين لون الخلفية" + }, + { + "name": "background_gradient", + "value": "تعيين خلفية التدرج" + }, + { + "name": "background_gradient_linear", + "value": "التدرج الخطي" + }, + { + "name": "background_gradient_sweep", + "value": "زاوية الانحدار" + }, + { + "name": "background_gradient_radial", + "value": "شعاعي التدرج" + }, + { + "name": "background_image_transformation_effect", + "value": "تحويل صورة الخلفية" + }, + { + "name": "set_background_image_size", + "value": "تعيين حجم الصورة الخلفية" + }, + { + "name": "set_background_image_position", + "value": "وضع صورة الخلفية" + }, + { + "name": "background_image_size_cover", + "value": "تغطية" + }, + { + "name": "background_image_size_contain", + "value": "احتواء" + }, + { + "name": "background_image_position_top_start", + "value": "توب ستارت" + }, + { + "name": "background_image_position_top", + "value": "توب ." + }, + { + "name": "background_image_position_top_end", + "value": "توبند" + }, + { + "name": "background_image_position_start", + "value": "توب ." + }, + { + "name": "background_image_position_center", + "value": "مركز" + }, + { + "name": "background_image_position_end", + "value": "نهاية ." + }, + { + "name": "background_image_position_bottom_start", + "value": "بداية القاع" + }, + { + "name": "background_image_position_bottom", + "value": "القاع" + }, + { + "name": "background_image_position_bottom_end", + "value": "نهاية القاع" + }, + { + "name": "background_image", + "value": "تعيين صورة الخلفية" + }, + { + "name": "background_image_default", + "value": "خرق" + }, + { + "name": "background_image_repeat", + "value": "س ص محور تكرار الرسم البياني" + }, + { + "name": "background_image_size", + "value": "حجم الصورة 50% عرض 100% ارتفاع" + }, + { + "name": "background_image_offset", + "value": "صورة الكلمات يقابلها إلى اليمين أو إلى الأسفل" + }, + { + "name": "auxiliary_badge", + "value": "شارات" + }, + { + "name": "badge_type", + "value": "نوع التسمية" + }, + { + "name": "badge_number", + "value": "العلامات الرقمية" + }, + { + "name": "badge_string", + "value": "نص التسمية" + }, + { + "name": "badge_max", + "value": "العلامة الرقمية أقصى عدد من الرسائل" + }, + { + "name": "badge_number_normal", + "value": "شارة عادية" + }, + { + "name": "badge_number_max", + "value": "ماكس شارات" + }, + { + "name": "badge_location", + "value": "وضع علامة" + }, + { + "name": "badge_left", + "value": "علامة على اليسار" + }, + { + "name": "badge_top", + "value": "أعلى اليمين التسمية" + }, + { + "name": "badge_right", + "value": "علامة الحق" + }, + { + "name": "badge_style", + "value": "علامة نمط" + }, + { + "name": "badge_blue", + "value": "علامة زرقاء كبيرة" + }, + { + "name": "badge_green", + "value": "علامة خضراء صغيرة" + }, + { + "name": "border_type", + "value": "نوع الحدود" + }, + { + "name": "border_type_dashed", + "value": "خط منقط" + }, + { + "name": "border_type_dotted", + "value": "نقطة" + }, + { + "name": "border_type_solid", + "value": "خط صلب" + }, + { + "name": "border_border_style", + "value": "عرض الحدود ، اللون ، فيليه" + }, + { + "name": "border_border_width", + "value": "عرض" + }, + { + "name": "border_border_color", + "value": "الألوان" + }, + { + "name": "border_border_radius", + "value": "فيليه" + }, + { + "name": "border_edge_style", + "value": "تعيين الحدود ، والأساليب ، والصفات ، على التوالي" + }, + { + "name": "border_style_top", + "value": "أعلى الحدود" + }, + { + "name": "border_style_bottom", + "value": "أسفل الحدود" + }, + { + "name": "border_style_left", + "value": "الحدود اليسرى" + }, + { + "name": "border_style_right", + "value": "الحدود اليمنى" + }, + { + "name": "border_radius", + "value": "تعيين أربع زوايا مستديرة" + }, + { + "name": "border_radius_left_top", + "value": "الحدود العليا اليسرى" + }, + { + "name": "border_radius_left_bottom", + "value": "أسفل اليسار الحدود" + }, + { + "name": "border_radius_right_top", + "value": "الحدود العليا اليمنى" + }, + { + "name": "border_radius_right_bottom", + "value": "أسفل الحدود اليمنى" + }, + { + "name": "border_3D", + "value": "تعيين الحدود ثلاثية الأبعاد" + }, + { + "name": "outline_text", + "value": "مخطط" + }, + { + "name": "outline_effect", + "value": "تأثير توقعات" + }, + { + "name": "outline_button", + "value": "الأزرار" + }, + { + "name": "button_title", + "value": "الأزرار" + }, + { + "name": "button_type", + "value": "نوع ." + }, + { + "name": "button_confirm", + "value": "أكّد" + }, + { + "name": "button_type_capsule", + "value": "الكبسولة" + }, + { + "name": "button_type_normal", + "value": "عادي ." + }, + { + "name": "button_type_circle", + "value": "دائرة" + }, + { + "name": "button_state_effect", + "value": "تأثير الدولة" + }, + { + "name": "button_state_effect_true", + "value": "تأثير" + }, + { + "name": "button_state_effect_false", + "value": "لا تأثير" + }, + { + "name": "button_disable_style", + "value": "تعطيل" + }, + { + "name": "button_custom_style", + "value": "نمط مخصص" + }, + { + "name": "button_border_radius", + "value": "جولة زر" + }, + { + "name": "button_with_icon", + "value": "زر الأيقونات" + }, + { + "name": "button_custom_bg_color", + "value": "لون مخصص" + }, + { + "name": "button_click", + "value": "اضغط على زر" + }, + { + "name": "click_action_tips", + "value": "انقر فوق المنطقة الرمادية لتغيير موقف الصليب" + }, + { + "name": "touch_action_tips", + "value": "لمس المنطقة الرمادية والانتقال إلى تغيير موقف الصليب" + }, + { + "name": "component_area_change_action_tips", + "value": "انزلاق يمكن تغيير حجم أو موقف المنطقة الرمادية للسيطرة على حركة الكرة في المنطقة" + }, + { + "name": "get_click_event_detail", + "value": "انقر على معلومات الموقع" + }, + { + "name": "drag_drop_action_tips", + "value": "اضغط على أيقونة التطبيق لفترة طويلة واسحب إلى مناطق مختلفة" + }, + { + "name": "component_drag_and_drop", + "value": "عنصر السحب والإفلات" + }, + { + "name": "griditem", + "value": "شبكة البند" + }, + { + "name": "multiselect", + "value": "اختيار متعددة" + }, + { + "name": "listitem", + "value": "قائمة البنود" + }, + { + "name": "hyperlink", + "value": "ارتباط تشعبي" + }, + { + "name": "text", + "value": "نص ." + }, + { + "name": "image", + "value": "صور" + }, + { + "name": "video", + "value": "فيديو : ." + }, + { + "name": "formcomponent", + "value": "شكل العنصر" + }, + { + "name": "custom_dialog", + "value": "تخصيص مربع الحوار" + }, + { + "name": "custom_dialog_style_custom", + "value": "مربع الحوار نمط مخصص" + }, + { + "name": "custom_dialog_style_custom_true", + "value": "عرف" + }, + { + "name": "custom_dialog_style_custom_false", + "value": "غير مخصص" + }, + { + "name": "custom_dialog_title", + "value": "طلب تمكين الأذونات التالية" + }, + { + "name": "custom_dialog_permission_microphone", + "value": "ميكروفون السلطة" + }, + { + "name": "custom_dialog_permission_microphone_info", + "value": "المكالمات الصوتية تتطلب إذن الميكروفون" + }, + { + "name": "custom_dialog_permission_location", + "value": "موقع السلطة" + }, + { + "name": "custom_dialog_permission_location_info", + "value": "الملاحة يتطلب إذن الموقع" + }, + { + "name": "custom_dialog_start", + "value": "فتح" + }, + { + "name": "date_picker_dialog", + "value": "تاريخ محدد" + }, + { + "name": "date_picker_dialog_date", + "value": "عرض تاريخ الحوار" + }, + { + "name": "date_picker_dialog_date_lunar", + "value": "التاريخ القمري" + }, + { + "name": "date_picker_dialog_date_gregorian", + "value": "تاريخ التقويم الغريغوري" + }, + { + "name": "date_picker_dialog_cancel", + "value": "ألغى" + }, + { + "name": "date_picker_toast_date", + "value": "اختيار الوقت :" + }, + { + "name": "date_picker_dialog_datetimeone", + "value": "2022-10-01" + }, + { + "name": "date_picker_dialog_datetimetwo", + "value": "1970-1-1" + }, + { + "name": "date_picker_dialog_datetimethree", + "value": "2100-12-31" + }, + { + "name": "date_picker_title", + "value": "تاريخ محدد" + }, + { + "name": "date_picker_lunar", + "value": "القمر" + }, + { + "name": "divider_title", + "value": "تحويلة" + }, + { + "name": "divider_stroke_width", + "value": "عرض السكتة الدماغية" + }, + { + "name": "divider_line_color", + "value": "لون الخط" + }, + { + "name": "divider_line_cap", + "value": "لين كابستيل" + }, + { + "name": "divider_horizontal", + "value": "الاتجاه الأفقي" + }, + { + "name": "divider_vertical", + "value": "عمودي" + }, + { + "name": "divider_attribute", + "value": "تحويلة" + }, + { + "name": "font_color", + "value": "الألوان" + }, + { + "name": "font_size", + "value": "حجم" + }, + { + "name": "font_thickness", + "value": "سمك ." + }, + { + "name": "font_style", + "value": "أسلوب ." + }, + { + "name": "interpolation_calculation_cubic_bezier_curve", + "value": "ثالث ترتيب منحنى بيزيير الكائن" + }, + { + "name": "interpolation_calculation_spring", + "value": "منحنى الربيع الكائن" + }, + { + "name": "interpolation_calculation_init_curve", + "value": "easein منحنى تفاضلي" + }, + { + "name": "interpolation_calculation_steps_curve", + "value": "سلم منحنى الكائن" + }, + { + "name": "page_transition", + "value": "التحويل بين الصفحات" + }, + { + "name": "page_transition_left", + "value": "مدخل / مخرج يمين يسار" + }, + { + "name": "page_transition_right", + "value": "المدخل الأيمن / المخرج الأيسر" + }, + { + "name": "page_transition_top", + "value": "أعلى مدخل / مخرج أسفل" + }, + { + "name": "page_transition_bottom", + "value": "أسفل مدخل / مخرج أعلى" + }, + { + "name": "page_transition_scale", + "value": "تكبير / تصغير" + }, + { + "name": "page_transition_rotate", + "value": "برغي في / خارج" + }, + { + "name": "page_transition_back", + "value": "تحويل صفحة العودة بين الصفحات" + }, + { + "name": "qrcode_title", + "value": "قركودي" + }, + { + "name": "qrcode_content", + "value": "المحتويات" + }, + { + "name": "qrcode_color", + "value": "الألوان" + }, + { + "name": "qrcode_enter_content", + "value": "أدخل تغيير رمز ثنائي الأبعاد" + }, + { + "name": "search_placeholder", + "value": "اكتب البحث ." + }, + { + "name": "search_name", + "value": "بحث ." + }, + { + "name": "radio_title", + "value": "راديو ." + }, + { + "name": "radio_no_response_region", + "value": "لا إضافة منطقة استجابة ( اضغط على زر الدخول )" + }, + { + "name": "radio_has_response_region", + "value": "إضافة منطقة استجابة ( انقر على زر خط )" + }, + { + "name": "radio_beijing", + "value": "بيجينغ" + }, + { + "name": "radio_shanghai", + "value": "شنغهاي ." + }, + { + "name": "radio_shenzhen", + "value": "شن تشن" + }, + { + "name": "radio_guangzhou", + "value": "غوانغ زهو" + }, + { + "name": "graphic_transformation_rotate", + "value": "استدارة" + }, + { + "name": "rotate_photo", + "value": "صورة التناوب" + }, + { + "name": "rotate_container", + "value": "عنصر التناوب" + }, + { + "name": "rotate_before_image", + "value": "الصورة الأصلية" + }, + { + "name": "rotate_before_component", + "value": "حاوية الجمعية" + }, + { + "name": "rotate_image_angle", + "value": "دوران" + }, + { + "name": "select_title", + "value": "مختار" + }, + { + "name": "select_has_icon", + "value": "اختيار الرموز" + }, + { + "name": "select_option_bg_and_text_style", + "value": "اختيار لون الخلفية و نمط النص" + }, + { + "name": "select_unselect_option_style", + "value": "خيارات الخلفية و نمط النص" + }, + { + "name": "select_button_style", + "value": "زر القائمة المنسدلة نمط النص" + }, + { + "name": "select_picture", + "value": "صور ." + }, + { + "name": "select_collection", + "value": "جمع" + }, + { + "name": "select_gesture", + "value": "الإيماءات" + }, + { + "name": "select_index", + "value": "حدد مؤشر الخيارات :" + }, + { + "name": "select_value", + "value": "قيمة الخيار المختار :" + }, + { + "name": "share_element_transition", + "value": "عنصر مشترك عملة" + }, + { + "name": "Multiplex_interface", + "value": "معدد" + }, + { + "name": "Floating_window", + "value": "نافذة عائمة" + }, + { + "name": "Tips_call", + "value": "إنتظر" + }, + { + "name": "Font_family_regular", + "value": "هارمونيوس اس سي روتاري" + }, + { + "name": "Font_family_medium", + "value": "هارمونيوس سان SC متوسطة" + }, + { + "name": "Folder_expansion", + "value": "مجلد التمديد" + }, + { + "name": "Shop_card_expansion", + "value": "تمديد بطاقة المحل" + }, + { + "name": "Today", + "value": "اليوم ." + }, + { + "name": "Gallery_card_expansion", + "value": "معرض بطاقة التمديد" + }, + { + "name": "size_width", + "value": "عرض" + }, + { + "name": "size_width_fixed_100vp", + "value": "عرض 100vp" + }, + { + "name": "size_width_percent", + "value": "عرض 60%" + }, + { + "name": "size_width_fixed_60vw", + "value": "عرض" + }, + { + "name": "size_height", + "value": "ارتفاع" + }, + { + "name": "size_height_fixed_60vh", + "value": "عرض 60vh" + }, + { + "name": "size_height_fixed_100vp", + "value": "ارتفاع 100vp" + }, + { + "name": "size_height_percent", + "value": "ارتفاع 60%" + }, + { + "name": "size_height_fixed_calc", + "value": "الارتفاع هو القيمة المحسوبة ( 200vp-100vp ) ." + }, + { + "name": "slider_title", + "value": "المنزلق" + }, + { + "name": "slider_step_tip", + "value": "خطوات ونصائح ( الخطوة 10 )" + }, + { + "name": "slider_current_value", + "value": "عرض القيمة الحالية ( مين - 50 / ماكس - 130 )" + }, + { + "name": "slider_events", + "value": "النشاطات" + }, + { + "name": "slider_attributes", + "value": "صفة" + }, + { + "name": "slider_vertical_reverse", + "value": "عمودي وعكس" + }, + { + "name": "slider_forward", + "value": "فورورد" + }, + { + "name": "slider_reverse", + "value": "عكس" + }, + { + "name": "slider_select_color", + "value": "اختيار اللون" + }, + { + "name": "slider_track_color", + "value": "لون المسار" + }, + { + "name": "slider_block_color", + "value": "لون مربع" + }, + { + "name": "slider_track_thickness", + "value": "سمك المسار" + }, + { + "name": "slider_event_begin", + "value": "تبدأ سحب شريط التمرير" + }, + { + "name": "slider_event_moving", + "value": "أثناء سحب شريط التمرير" + }, + { + "name": "slider_event_end", + "value": "نهاية سحب شريط التمرير" + }, + { + "name": "slider_event_click", + "value": "انقر فوق شريط التمرير لنقل شريط التمرير الموقف" + }, + { + "name": "slider_title_value", + "value": "النسبة المئوية من مجموع طول الشريحة :" + }, + { + "name": "span_title", + "value": "فترة طويلة من الزمن ، بما في ذلك فترة طويلة من الزمن" + }, + { + "name": "span_attribute", + "value": "تكوين خصائص مختلفة تمتد" + }, + { + "name": "span_content_one", + "value": "خفف من الصلب في النار والتبريد السريع ،" + }, + { + "name": "span_content_two", + "value": "لذلك يمكن أن يكون من الصعب ، لا تخاف من أي شيء ." + }, + { + "name": "span_content_three", + "value": "ومن خلال هذه الطريقة أن جيلنا قد تدرب على النضال و التجارب الرهيبة ،" + }, + { + "name": "span_content_four", + "value": "تعلم عدم الاستسلام للحياة ." + }, + { + "name": "span_decoration_and_letter_spacing", + "value": "الديكور و تباعد الحروف" + }, + { + "name": "span_letter_spacing", + "value": "تباعد الحروف" + }, + { + "name": "span_line_height", + "value": "خط الطول" + }, + { + "name": "span_decoration_type", + "value": "نوع الديكور" + }, + { + "name": "span_text_decoration", + "value": "الديكور اختبار النص" + }, + { + "name": "span_text_spacing", + "value": "رسالة الفضاء اختبار النص" + }, + { + "name": "span_inherits_text_attribute", + "value": "سبان يرث خصائص النص" + }, + { + "name": "span_does_not_inherit_text_attribute", + "value": "سبان لا ترث خصائص النص" + }, + { + "name": "span_upper_lower", + "value": "كبيرة أو صغيرة" + }, + { + "name": "span_decoration_color", + "value": "لون الديكور" + }, + { + "name": "span_decoration_none", + "value": "هل أنت بخير ؟ - لا -" + }, + { + "name": "span_decoration_linethrough", + "value": "خط مباشر" + }, + { + "name": "span_decoration_underline", + "value": "التأكيد" + }, + { + "name": "span_decoration_overline", + "value": "على الخط" + }, + { + "name": "image_span_title", + "value": "صورة تمتد" + }, + { + "name": "image_span_vertical_align", + "value": "المحاذاة العمودية" + }, + { + "name": "image_span_alignment_baseline", + "value": "خط الأساس" + }, + { + "name": "image_span_alignment_bottom", + "value": "القاع" + }, + { + "name": "image_span_alignment_center", + "value": "مركز" + }, + { + "name": "image_span_alignment_top", + "value": "توب ." + }, + { + "name": "image_span_object_fit", + "value": "موضوع مطابقة" + }, + { + "name": "image_fit_contain", + "value": "احتواء" + }, + { + "name": "image_fit_auto", + "value": "السيارات" + }, + { + "name": "image_fit_fill", + "value": "ملأ" + }, + { + "name": "image_fit_none", + "value": "هل أنت بخير ؟ - لا -" + }, + { + "name": "image_fit_scale_down", + "value": "تقليص حجم" + }, + { + "name": "image_fit_cover", + "value": "تغطية" + }, + { + "name": "image_span_and_span", + "value": "صورة تمتد تمتد" + }, + { + "name": "image_span_vertical_align_and_object_fit", + "value": "المحاذاة العمودية و موضوع تركيب الصورة تمتد" + }, + { + "name": "text_title", + "value": "نص ." + }, + { + "name": "text_width", + "value": "عرض النص" + }, + { + "name": "text_height", + "value": "ارتفاع النص" + }, + { + "name": "text_content", + "value": "خفف من الصلب في النار والتبريد السريع ، بحيث يمكن أن يكون من الصعب جدا ، لا تخافوا من أي شيء . وبهذه الطريقة فقط ، فإن جيلنا قد شحذ في النضال و التجارب الرهيبة و تعلمت عدم الاستسلام للحياة ." + }, + { + "name": "text_text_align_center", + "value": "مركز" + }, + { + "name": "text_text_align_start", + "value": "نقطة الانطلاق" + }, + { + "name": "text_text_align_end", + "value": "نهاية ." + }, + { + "name": "text_decoration_type", + "value": "نص نوع الديكور" + }, + { + "name": "text_decoration_type_under_line", + "value": "دوونلين" + }, + { + "name": "text_decoration_type_line_through", + "value": "من خلال خط" + }, + { + "name": "text_decoration_type_over_line", + "value": "أكثر من خط" + }, + { + "name": "text_text_align_type", + "value": "محاذاة النص" + }, + { + "name": "text_letter_spacing", + "value": "تباعد الحروف" + }, + { + "name": "text_overflow", + "value": "تجاوز النص" + }, + { + "name": "text_none", + "value": "هل أنت بخير ؟ - لا -" + }, + { + "name": "text_text_over_flow_clip", + "value": "قطع" + }, + { + "name": "text_text_over_flow_ellipsis", + "value": "القطع الناقص" + }, + { + "name": "text_line_height", + "value": "خط الطول" + }, + { + "name": "text_font_color", + "value": "لون الخط" + }, + { + "name": "text_over_flow", + "value": "تجاوز النص" + }, + { + "name": "text_text_case_normal", + "value": "عادي ." + }, + { + "name": "text_text_case", + "value": "حالة النص" + }, + { + "name": "text_text_case_uppercase", + "value": "حروف" + }, + { + "name": "text_text_case_lowercase", + "value": "حروف صغيرة" + }, + { + "name": "text_area_set_text_selection", + "value": "حدد النص" + }, + { + "name": "text_area_set_text_selection_start_select_error", + "value": "خطأ في تحديد بداية اختيار النص" + }, + { + "name": "text_area_set_text_selection_end_select_error", + "value": "خطأ في تحديد نهاية اختيار النص" + }, + { + "name": "text_input_set_text_selection_start_select", + "value": "بدء اختيار :" + }, + { + "name": "text_input_set_text_selection_end_select", + "value": "نهاية الاختيار :" + }, + { + "name": "avoiding_input_method_testing", + "value": "تجنب اختبار طريقة الإدخال" + }, + { + "name": "text_input_title", + "value": "مربع إدخال النص" + }, + { + "name": "text_input_normal_type", + "value": "الأرقام ، الحروف ، يؤكد ، والمسافات ، أحرف خاصة ." + }, + { + "name": "text_input_password_type", + "value": "أدخل كلمة السر" + }, + { + "name": "text_input_email_type", + "value": "أدخل البريد الإلكتروني" + }, + { + "name": "text_input_number_type", + "value": "وضع الإدخال الرقمي" + }, + { + "name": "text_input_phone_type", + "value": "Digits, spaces, plus signs (+), hyphens (-), asterisks (*), and number signs (#)" + }, + { + "name": "text_input_input_type", + "value": "نوع الإدخال" + }, + { + "name": "text_input_current_type", + "value": "النوع الحالي" + }, + { + "name": "text_input_show_password_icon", + "value": "عرض رمز كلمة السر" + }, + { + "name": "text_input_icon_show", + "value": "عرض ." + }, + { + "name": "text_input_icon_hide", + "value": "أخفى" + }, + { + "name": "text_input_event", + "value": "النشاطات" + }, + { + "name": "text_input_event_placeholder", + "value": "نسخ ، لصق ، قص ، ارتكاب ، تحرير الحدث" + }, + { + "name": "text_input_placeholder_style", + "value": "نمط النائبة" + }, + { + "name": "text_input_placeholder", + "value": "النائبة" + }, + { + "name": "text_input_filter", + "value": "فلتر الإدخال" + }, + { + "name": "text_input_only_input_english", + "value": "فقط أدخل الحروف الإنجليزية" + }, + { + "name": "text_input_caret_position", + "value": "موقف التمريض" + }, + { + "name": "text_input_set_text_selection", + "value": "حدد النص" + }, + { + "name": "text_input_max_length", + "value": "الحد من إدخال حرف طول" + }, + { + "name": "text_input_placeholder_max_length", + "value": "ما يصل إلى 12 حرفا" + }, + { + "name": "text_input_toast_paste", + "value": "لصق النص كما يلي :" + }, + { + "name": "text_input_toast_cut", + "value": "قص النص كما يلي :" + }, + { + "name": "text_input_toast_copy", + "value": "نسخ النص كما يلي :" + }, + { + "name": "text_input_toast_submit", + "value": "وفيما يلي نص الطلب :" + }, + { + "name": "text_input_toast_edit", + "value": "نص منقح كما يلي :" + }, + { + "name": "time_picker_dialog", + "value": "وقت الحوار" + }, + { + "name": "time_picker_dialog_time", + "value": "عرض مربع الحوار الوقت" + }, + { + "name": "time_picker_dialog_24_hour", + "value": "ساعة" + }, + { + "name": "time_picker_dialog_12_hour", + "value": "ح" + }, + { + "name": "time_picker_dialog_cancel", + "value": "ألغى" + }, + { + "name": "time_picker_toast_time", + "value": "اختيار الوقت :" + }, + { + "name": "time_picker_options_usemilitarytime", + "value": "استخدام الوقت العسكري" + }, + { + "name": "time_picker_dialog_timeone", + "value": "00 : 00" + }, + { + "name": "time_picker_dialog_timetwo", + "value": "10 / 01 / 2022 12 : 00" + }, + { + "name": "toggle_title", + "value": "تبديل" + }, + { + "name": "toggle_select", + "value": "مختار" + }, + { + "name": "toggle_unselect", + "value": "لا خيار" + }, + { + "name": "toggle_type_switch", + "value": "التبديل" + }, + { + "name": "checkbox", + "value": "خانة الاختيار" + }, + { + "name": "toggle_type_checkbox", + "value": "خانة الاختيار" + }, + { + "name": "toggle_type_button", + "value": "الأزرار" + }, + { + "name": "toggle_state", + "value": "مختار" + }, + { + "name": "graphic_transformation_translate", + "value": "ترجمة ." + }, + { + "name": "translate_image", + "value": "صورة الترجمة" + }, + { + "name": "translate_container", + "value": "عنصر الترجمة" + }, + { + "name": "translate_x_axis", + "value": "المحور العاشر" + }, + { + "name": "translate_y_axis", + "value": "المحور الصادي" + }, + { + "name": "components_display", + "value": "عرض" + }, + { + "name": "components_interaction", + "value": "تفاعلي" + }, + { + "name": "components_interaction_menuone", + "value": "قائمة البند 1" + }, + { + "name": "components_interaction_menutwo", + "value": "قائمة البند 2" + }, + { + "name": "components_interaction_menuthree", + "value": "قائمة البند 3" + }, + { + "name": "components_interaction_menufour", + "value": "قائمة البند 4" + }, + { + "name": "components_interaction_clicktextone", + "value": "معلومات أساسية" + }, + { + "name": "components_interaction_clicktexttwo", + "value": "مكان" + }, + { + "name": "components_interaction_clicktextthree", + "value": "فورجروند كيدز" + }, + { + "name": "components_interaction_hittestbehavior", + "value": "Hittest السلوك :" + }, + { + "name": "components_interaction_hovereffect", + "value": "تأثير تعليق" + }, + { + "name": "components_interaction_backgroundresponse", + "value": "انقر على خلفية الرد" + }, + { + "name": "components_interaction_foregroundresponse", + "value": "استجابة الجبهة انقر" + }, + { + "name": "components_interaction_contentresponse", + "value": "محتوى الرد انقر" + }, + { + "name": "components_display_content", + "value": "ABCDEFG" + }, + { + "name": "components_display_center", + "value": "مركز" + }, + { + "name": "components_display_topstart", + "value": "بداية" + }, + { + "name": "components_display_topend", + "value": "أعلى" + }, + { + "name": "components_display_top", + "value": "توب ." + }, + { + "name": "components_display_start", + "value": "بداية ." + }, + { + "name": "components_display_end", + "value": "نهاية ." + }, + { + "name": "components_display_bottomstart", + "value": "أسفل الحذاء" + }, + { + "name": "components_display_bottom", + "value": "القاع" + }, + { + "name": "components_display_bottomend", + "value": "رئيس كبير" + }, + { + "name": "components_display_none", + "value": "هل أنت بخير ؟ - لا -" + }, + { + "name": "components_display_hidden", + "value": "أخفى" + }, + { + "name": "components_display_visible", + "value": "مرئي" + }, + { + "name": "components_effects", + "value": "أثر" + }, + { + "name": "blur_effects", + "value": "تأثير ضبابي" + }, + { + "name": "blur_radius_modify", + "value": "نصف قطر غامض" + }, + { + "name": "background_blur", + "value": "الخلفية ضبابية" + }, + { + "name": "background_blur_style", + "value": "طمس الخلفية نمط" + }, + { + "name": "set_shadow_type", + "value": "تعيين نوع الظل" + }, + { + "name": "shadow_effects", + "value": "تأثير الظل" + }, + { + "name": "shadow_effects_content", + "value": "تأثير الظل" + }, + { + "name": "offset_min", + "value": "- 40" + }, + { + "name": "offset_max", + "value": "٤٠" + }, + { + "name": "x_offset", + "value": "س تعويض" + }, + { + "name": "y_offset", + "value": "ذ تعويض" + }, + { + "name": "shadow", + "value": "شادو" + }, + { + "name": "blur", + "value": "طمس" + }, + { + "name": "effects", + "value": "تأثير" + }, + { + "name": "effects_display", + "value": "عرض" + }, + { + "name": "grayscale_change", + "value": "مقياس الرمادية" + }, + { + "name": "brightness_change", + "value": "سطوع" + }, + { + "name": "saturate_change", + "value": "نقع" + }, + { + "name": "constrast_change", + "value": "قيد" + }, + { + "name": "invert_change", + "value": "تحويل" + }, + { + "name": "sepia_change", + "value": "الإنتان" + }, + { + "name": "hueRotate_change", + "value": "هيو روت" + }, + { + "name": "color_blend_change", + "value": "خلط الألوان" + }, + { + "name": "spherical_effect_change", + "value": "تأثير المجال" + }, + { + "name": "light_up_effect_change", + "value": "تأثير الإضاءة" + }, + { + "name": "pixel_stretch_effect_change", + "value": "تأثير بكسل تمتد" + }, + { + "name": "z_index", + "value": "ض مؤشر" + }, + { + "name": "overlay", + "value": "تغطية طبقة" + }, + { + "name": "visibility", + "value": "وضوح" + }, + { + "name": "opacity", + "value": "التعتيم" + }, + { + "name": "z_index_display", + "value": "ض مؤشر" + }, + { + "name": "Red", + "value": "رد : ." + }, + { + "name": "Yellow", + "value": "أصفر" + }, + { + "name": "positon_modify", + "value": "الوظائف" + }, + { + "name": "offset_modify", + "value": "قابل" + }, + { + "name": "visibility_change", + "value": "وضوح" + }, + { + "name": "opacity_change", + "value": "التعتيم" + }, + { + "name": "opacity_display", + "value": "التعتيم عرض" + }, + { + "name": "item_select", + "value": "قائمة البند" + }, + { + "name": "disabled", + "value": "المعوقون" + }, + { + "name": "button_disabled", + "value": "زر تعطيل" + }, + { + "name": "list_disabled", + "value": "قائمة المعوقين" + }, + { + "name": "focus", + "value": "فوكوس" + }, + { + "name": "popup_window", + "value": "نافذة منبثقة" + }, + { + "name": "touch_test", + "value": "لمس ." + }, + { + "name": "touch_region", + "value": "منطقة" + }, + { + "name": "hovereffect", + "value": "تحوم" + }, + { + "name": "bind_menu_customBuilder", + "value": "ربط القائمة custombuilder" + }, + { + "name": "bind_content_menu", + "value": "ربط محتوى القائمة" + }, + { + "name": "click_on_any_action_below", + "value": "انقر فوق أي من الإجراءات التالية" + }, + { + "name": "long_press_any_action_below", + "value": "اضغط على أي من العمليات التالية لفترة طويلة" + }, + { + "name": "bind_menu_content", + "value": "ربط محتوى القائمة" + }, + { + "name": "menu", + "value": "قائمة" + }, + { + "name": "multiState", + "value": "العديد من الدول" + }, + { + "name": "multi_short_key", + "value": "مفاتيح متعددة قصيرة" + }, + { + "name": "set_mouse_style", + "value": "تعيين نمط الماوس" + }, + { + "name": "multimode_input", + "value": "مدخلات المتعدد" + }, + { + "name": "short_key_pressed", + "value": "اضغط على مفتاح قصير" + }, + { + "name": "on_short_key", + "value": "وفي الوقت نفسه ، اضغط على مفتاح الاختصار السيطرة + لتحريك الحدث عن طريق النقر على الزر التالي" + }, + { + "name": "alert", + "value": "تنبيه" + }, + { + "name": "result", + "value": "نتيجة" + }, + { + "name": "popup", + "value": "نافذة منبثقة" + }, + { + "name": "custom_popup", + "value": "العرف المنبثقة" + }, + { + "name": "touch_test_region", + "value": "لمس منطقة الاختبار" + }, + { + "name": "action_sheet_dialog", + "value": "طاولة العمليات في مربع الحوار" + }, + { + "name": "action_sheet_title_autoCancel", + "value": "إذا كانت نافذة منبثقة تلقائيا إلغاء" + }, + { + "name": "action_sheet_click_sheets", + "value": "انقر فوق خيارات المحتوى" + }, + { + "name": "action_sheet_dialog_click_content", + "value": "انقر على المحتوى" + }, + { + "name": "text_picker_dialog", + "value": "نص محدد في مربع الحوار" + }, + { + "name": "text_picker_show", + "value": "عرض مربع الحوار النص" + }, + { + "name": "text_picker_click_text", + "value": "انقر فوق النص" + }, + { + "name": "text_picker_text_peach", + "value": "خوخ ." + }, + { + "name": "text_picker_text_apple", + "value": "تفاحة ." + }, + { + "name": "text_picker_text_orange", + "value": "برتقالي" + }, + { + "name": "text_picker_text_grape", + "value": "كرمة" + }, + { + "name": "text_picker_text_banana", + "value": "موز ." + }, + { + "name": "global_menu", + "value": "ربط قائمة السياق" + }, + { + "name": "global_menu_create_way", + "value": "طريقة الخلق" + }, + { + "name": "global_menu_click_right", + "value": "انقر بزر الماوس الأيمن فوق" + }, + { + "name": "global_menu_long_press", + "value": "الصحافة طويلة" + }, + { + "name": "global_menu_close", + "value": "انقر فوق إغلاق القائمة" + }, + { + "name": "component_transition", + "value": "عنصر التحويل" + }, + { + "name": "component_transition_show", + "value": "عرض ." + }, + { + "name": "component_transition_hide", + "value": "أخفى" + }, + { + "name": "attribute_animation", + "value": "خاصية الرسوم المتحركة" + }, + { + "name": "motion_path", + "value": "مسار الرسوم المتحركة" + }, + { + "name": "animate_to", + "value": "عرض الرسوم المتحركة" + }, + { + "name": "animate_over", + "value": "الانتهاء من الرسوم المتحركة" + }, + { + "name": "attribute_animation_change_size", + "value": "تغيير الحجم" + }, + { + "name": "attribute_animation_play_complete", + "value": "الانتهاء من اللعب" + }, + { + "name": "attribute_animation_unlimited_playback", + "value": "اللعب غير محدود" + }, + { + "name": "attribute_animation_play_speed", + "value": "سرعة اللعب" + }, + { + "name": "attribute_animation_delay", + "value": "تأخير 3 ثوان" + }, + { + "name": "attribute_animation_set_curve", + "value": "تعيين منحنى" + }, + { + "name": "attribute_animation_change_rotation", + "value": "تغيير التناوب" + }, + { + "name": "attribute_animation_play_count", + "value": "لعب" + }, + { + "name": "motion_path_click_me", + "value": "انقر على لي" + }, + { + "name": "general_mount", + "value": "تحميل وتفريغ الحدث" + }, + { + "name": "general_mount_toast", + "value": "جبل الصورة" + }, + { + "name": "general_unmount_toast", + "value": "إلغاء تثبيت الصورة" + }, + { + "name": "general_mount_text", + "value": "انقر فوق تحميل الصور غير المحملة" + }, + { + "name": "general_drag", + "value": "سحب وإسقاط الحدث" + }, + { + "name": "general_drag_text_one", + "value": "هنا ثلاثة عناصر النص ، اضغط باستمرار على النص واسحبه إلى القائمة أدناه" + }, + { + "name": "general_drag_text_two", + "value": "هذا هو عنصر القائمة" + }, + { + "name": "drag_list_one", + "value": "1 ." + }, + { + "name": "drag_list_two", + "value": "2 ." + }, + { + "name": "drag_list_three", + "value": "3 ." + }, + { + "name": "drag_list_four", + "value": "4 ." + }, + { + "name": "size_size", + "value": "حجم ." + }, + { + "name": "size_padding", + "value": "حشية" + }, + { + "name": "size_margin", + "value": "حافة" + }, + { + "name": "size_constraintSize", + "value": "حجم القيد" + }, + { + "name": "response_region", + "value": "منطقة الاستجابة" + }, + { + "name": "touch_hit_subtitle", + "value": "انقر فوق المنطقة الخضراء لتحريك المنطقة الزرقاء رد" + }, + { + "name": "option", + "value": "خيارات" + }, + { + "name": "hover_region", + "value": "تحوم الماوس فوق المنطقة الخضراء لمراقبة تأثير" + }, + { + "name": "multistatus_region", + "value": "تبديل الدولة ومراقبة تأثير" + }, + { + "name": "status_select", + "value": "اختيار الدولة" + }, + { + "name": "scroll_bar", + "value": "شريط التمرير" + }, + { + "name": "scroll_vertical_title", + "value": "التمرير الرأسي" + }, + { + "name": "scroll_horizontal_title", + "value": "التمرير الأفقي" + }, + { + "name": "auxiliary_refresh", + "value": "منعش" + }, + { + "name": "auxiliary_refresh_offset", + "value": "قابل" + }, + { + "name": "auxiliary_refresh_minvalue", + "value": "س" + }, + { + "name": "auxiliary_refresh_maxvalue", + "value": "١٠٠" + }, + { + "name": "auxiliary_refresh_friction", + "value": "احتكاك" + }, + { + "name": "auxiliary_panel", + "value": "لوحة" + }, + { + "name": "auxiliary_alphabetIndexer", + "value": "رسالة مفهرس" + }, + { + "name": "loading_progress", + "value": "تحميل الجدول" + }, + { + "name": "marquee_name", + "value": "ماركيز" + }, + { + "name": "marquee_src", + "value": "مرحبا arkui سلسلة أطول من المحتوى" + }, + { + "name": "marquee_fromstart", + "value": "من البداية" + }, + { + "name": "marquee_step", + "value": "خطوة" + }, + { + "name": "marquee_loop", + "value": "حلقة ." + }, + { + "name": "text_timer", + "value": "النص الموقت" + }, + { + "name": "text_timer_start", + "value": "بداية ." + }, + { + "name": "text_timer_pause", + "value": "وقفة" + }, + { + "name": "text_timer_reset", + "value": "إعادة" + }, + { + "name": "text_timer_iscountdown", + "value": "العد التنازلي" + }, + { + "name": "text_timer_timeformatone", + "value": "مم : الفولاذ المقاوم للصدأ" + }, + { + "name": "text_timer_groupformat", + "value": "شكل ." + }, + { + "name": "text_timer_timeformattwo", + "value": "عالية : مم : ثانية" + }, + { + "name": "text_timer_timeformatthree", + "value": "DD سمو مم SS . اس اس اس" + }, + { + "name": "text_clock", + "value": "كتلة النص" + }, + { + "name": "text_clock_start", + "value": "بداية ." + }, + { + "name": "text_clock_stop", + "value": "توقف" + }, + { + "name": "text_clock_timeformatone", + "value": "عالية : مم : ثانية" + }, + { + "name": "text_clock_groupformat", + "value": "شكل ." + }, + { + "name": "text_clock_timeformattwo", + "value": "السنة : الشهر : النهار" + }, + { + "name": "text_clock_timeformatthree", + "value": "ساعة - دقيقة - ثانية" + }, + { + "name": "progress_name", + "value": "تقدم" + }, + { + "name": "gauge_name", + "value": "متر ." + }, + { + "name": "gauge_value", + "value": "قيمة ." + }, + { + "name": "gauge_strokewidth", + "value": "السكتة الدماغية العرض" + }, + { + "name": "gauge_startangle", + "value": "زاوية البداية" + }, + { + "name": "gauge_endangle", + "value": "نهاية زاوية" + }, + { + "name": "data_panel", + "value": "لوحة البيانات" + }, + { + "name": "checkbox_checkboxgroup", + "value": "فحص مربع مجموعة" + }, + { + "name": "checkbox_title", + "value": "خانة الاختيار" + }, + { + "name": "checkbox_checkbox1", + "value": "خانة الاختيار 1" + }, + { + "name": "checkbox_checkbox2", + "value": "خانة الاختيار 2" + }, + { + "name": "checkbox_checkbox3", + "value": "خانة الاختيار 3" + }, + { + "name": "checkbox_checkgroup", + "value": "مجموعة مربع" + }, + { + "name": "checkbox_checkgroup_title", + "value": "مجموعة مربع" + }, + { + "name": "text_picker", + "value": "نص محدد" + }, + { + "name": "time_picker", + "value": "الوقت محدد" + }, + { + "name": "counter_name", + "value": "مكافحة" + }, + { + "name": "rating_name", + "value": "تصنيفات" + }, + { + "name": "rating_options_indicator", + "value": "المؤشر" + }, + { + "name": "rating_options_value", + "value": "قيمة ." + }, + { + "name": "rating_options_stars", + "value": "نجوم ." + }, + { + "name": "rich_text", + "value": "النص التشعبي" + }, + { + "name": "scroll_swiper", + "value": "المتداول والانزلاق" + }, + { + "name": "scroll_name", + "value": "ورقة لفة" + }, + { + "name": "swiper_name", + "value": "بطاقة ممغنطة" + }, + { + "name": "alphabetindexer_an", + "value": "واحد" + }, + { + "name": "alphabetindexer_bu", + "value": "يوم تقسيم" + }, + { + "name": "alphabetindexer_bai", + "value": "ابيض" + }, + { + "name": "alphabetindexer_bao", + "value": "بالة" + }, + { + "name": "alphabetindexer_bi", + "value": "بی" + }, + { + "name": "alphabetindexer_bing", + "value": "بنج" + }, + { + "name": "alphabetindexer_cao", + "value": "شاو" + }, + { + "name": "alphabetindexer_chen", + "value": "تشان ›" + }, + { + "name": "alphabetindexer_lv", + "value": "لو ." + }, + { + "name": "alphabetindexer_liu3", + "value": "ليو" + }, + { + "name": "alphabetindexer_liu", + "value": "خط وحدة واجهة" + }, + { + "name": "alphabetindexer_li", + "value": "الليثيوم" + }, + { + "name": "alphabetindexer_lou", + "value": "لو ." + }, + { + "name": "alphabetindexer_liang", + "value": "شعاع" + }, + { + "name": "alphabetindexer_lei", + "value": "رعد ." + }, + { + "name": "alphabetindexer_lu", + "value": "أرض ." + }, + { + "name": "alphabetindexer_cui", + "value": "تشوي" + }, + { + "name": "alphabetindexer_cheng", + "value": "تشنغ" + }, + { + "name": "alphabetindexer_list_display", + "value": "عرض قائمة" + }, + { + "name": "alphabetindexer_color_select", + "value": "اختيار اللون" + }, + { + "name": "alphabetindexer_selectedcolor_selectedcolor", + "value": "اختيار اللون" + }, + { + "name": "alphabetindexer_selectedcolor_selectedbgcolor", + "value": "اختيار لون الخلفية" + }, + { + "name": "alphabetindexer_selectedcolor_popupcolor", + "value": "لون النوافذ المنبثقة" + }, + { + "name": "alphabetindexer_selectedcolor_popupbackground", + "value": "الخلفية المنبثقة" + }, + { + "name": "alphabetindexer_selectedcolor_usingpopup", + "value": "استخدام النوافذ المنبثقة" + }, + { + "name": "panel_show_minibar", + "value": "عرض شريط ميني نوع الفريق" + }, + { + "name": "panel_close_minibar", + "value": "إغلاق شريط ميني نوع الفريق" + }, + { + "name": "panel_show_foldable", + "value": "عرض نوع قابلة للطي لوحة" + }, + { + "name": "panel_close_foldable", + "value": "إغلاق لوحة قابلة للطي" + }, + { + "name": "panel_show_temporary", + "value": "عرض لوحة نوع مؤقت" + }, + { + "name": "panel_close_temporary", + "value": "إغلاق لوحة نوع مؤقت" + }, + { + "name": "panel_radio_groupname", + "value": "فاكهة" + }, + { + "name": "checkbox_apple", + "value": "تفاحة ." + }, + { + "name": "checkbox_blueberry", + "value": "عنبية" + }, + { + "name": "checkbox_banbana", + "value": "موز ." + }, + { + "name": "checkbox_cherries", + "value": "كرز ." + }, + { + "name": "checkbox_durian", + "value": "دوريان" + }, + { + "name": "checkbox_orange", + "value": "برتقالي" + }, + { + "name": "checkbox_select_color", + "value": "اختيار اللون" + }, + { + "name": "checkbox_select_all", + "value": "اختيار كامل" + }, + { + "name": "normal_display", + "value": "عرض" + }, + { + "name": "normal_options", + "value": "خيارات" + }, + { + "name": "datapanel_circle", + "value": "دائرة" + }, + { + "name": "datapanel_line", + "value": "خط" + }, + { + "name": "progress_linear", + "value": "التقدم الخطي" + }, + { + "name": "progress_eclipse", + "value": "الكسوف التقدم" + }, + { + "name": "progress_scalering", + "value": "مقياس التقدم" + }, + { + "name": "progress_ring", + "value": "حلقة التقدم" + }, + { + "name": "progress_capsule", + "value": "كبسولة التقدم" + }, + { + "name": "progress_change", + "value": "تغيير الجدول الزمني" + }, + { + "name": "textclock_timeformat", + "value": "شكل الوقت" + }, + { + "name": "scroll_horizontal", + "value": "التمرير الأفقي" + }, + { + "name": "scroll_vertical", + "value": "التمرير الرأسي" + }, + { + "name": "interaction_disable_list", + "value": "قائمة الجرحى" + }, + { + "name": "interaction_show_one_alert", + "value": "انقر على عرض تذكير" + }, + { + "name": "interaction_show_two_alert", + "value": "انقر على زر عرض التنبيه المزدوج" + }, + { + "name": "interaction_placementontop", + "value": "وضع سقف :" + }, + { + "name": "interaction_arrowoffset", + "value": "تغيير إزاحة السهم :" + }, + { + "name": "interaction_showpopup", + "value": "عرض النوافذ المنبثقة" + }, + { + "name": "interaction_showcustompopup", + "value": "عرض مخصص المنبثقة" + }, + { + "name": "pan_start", + "value": "نقطة الانطلاق" + }, + { + "name": "pan_end", + "value": "نهاية ." + }, + { + "name": "pan_button", + "value": "تعديل pangesture الزناد" + }, + { + "name": "pinch_description", + "value": "اضغط على الإطار الأسود مع ثلاثة أصابع" + }, + { + "name": "pinch_scale", + "value": "نسبة العجن لفتة :" + }, + { + "name": "interaction_mask", + "value": "إسمك" + }, + { + "name": "rotation_description", + "value": "تدوير الصندوق الأسود مع اثنين من أصابع" + }, + { + "name": "swipe_description", + "value": "الشريحة بسرعة الصندوق الأسود في أي اتجاه مع إصبع واحد" + }, + { + "name": "combinded_description", + "value": "اضغط واسحب مربع أسود" + }, + { + "name": "transform_translate_invert", + "value": "التكبير مرتين و عكس ( التكبير مرتين )" + }, + { + "name": "key_press_description", + "value": "اضغط على لوحة المفاتيح الخارجية التبويب ، ثم اضغط على أي مفتاح" + }, + { + "name": "april", + "value": "ابريل" + }, + { + "name": "bind_click", + "value": "انقر على لي" + }, + { + "name": "interaction_disable", + "value": "تعطيل المكونات :" + }, + { + "name": "canvas_components", + "value": "قماش الجمعية" + }, + { + "name": "canvas_component_attributes", + "value": "السمة الأساسية" + }, + { + "name": "canvas_component_image_bitmap", + "value": "صورة نقطية" + }, + { + "name": "canvas_component_gradient", + "value": "كسر التدرج" + }, + { + "name": "canvas_component_method", + "value": "الطريقة الأساسية" + }, + { + "name": "canvas_component_path_2d", + "value": "باث" + }, + { + "name": "canvas_component_shadow", + "value": "شادو" + }, + { + "name": "canvas_component_transform", + "value": "تحويل" + }, + { + "name": "canvas_canvasZone", + "value": "قماش المنطقة" + }, + { + "name": "canvas_attributesOperations", + "value": "خاصية التشغيل" + }, + { + "name": "canvas_clearEffects", + "value": "تأثير واضح" + }, + { + "name": "canvas_show_message", + "value": "طباعة وحدة التحكم" + }, + { + "name": "scroll_To_effect", + "value": "انتقل إلى تأثير" + }, + { + "name": "scroller", + "value": "لف الجهاز" + }, + { + "name": "list", + "value": "قائمة" + }, + { + "name": "grid", + "value": "شبكة ." + }, + { + "name": "waterFlow", + "value": "تدفق المياه" + }, + { + "name": "tabs_switch_effect", + "value": "تسمية التبديل تأثير" + }, + { + "name": "image_fit_Full_effect", + "value": "صورة مطابقة / تأثير كامل" + }, + { + "name": "particle_effect", + "value": "تأثير الجسيمات" + }, + { + "name": "particle_spawn", + "value": "وضع البيض" + }, + { + "name": "particle_spawn_stop", + "value": "توقف" + }, + { + "name": "global_bindSheet_menu", + "value": "قائمة أوراق فضفاضة" + }, + { + "name": "global_bindSheet_text_allow_interaction", + "value": "تسمح صفحة التفاعل" + }, + { + "name": "global_bindSheet_text_desc", + "value": "تسمح صفحة وصف التفاعل" + }, + { + "name": "bindSheet_popup_style", + "value": "نمط البوب" + }, + { + "name": "bindSheet_default_popup", + "value": "نافذة منبثقة" + }, + { + "name": "bindSheet_centered_popup", + "value": "تركز نافذة منبثقة" + }, + { + "name": "bindSheet_popup_appears", + "value": "تظهر نافذة منبثقة" + }, + { + "name": "bindSheet_icon", + "value": "آيدول" + }, + { + "name": "bindSheet_blurred_background_texture", + "value": "غامض نسيج الخلفية" + }, + { + "name": "bindSheet_popup_modal_interface", + "value": "طريقة إخراج واجهة" + }, + { + "name": "pop_height", + "value": "بوب هايت" + }, + { + "name": "bindSheet_close_modal", + "value": "وضع قبالة" + }, + { + "name": "bindSheet_close_confirm", + "value": "أكّد" + }, + { + "name": "bindSheet_close_cancel", + "value": "ألغى" + }, + { + "name": "global_popUp_menu", + "value": "نافذة منبثقة" + }, + { + "name": "popUp_width", + "value": "عرض" + }, + { + "name": "placement", + "value": "إعادة التوطين" + }, + { + "name": "popUp_advanced_component", + "value": "بوبوب مكونات متقدمة" + }, + { + "name": "global_menu_avoid_rule", + "value": "قائمة تجنب القاعدة" + }, + { + "name": "global_menu_layout", + "value": "تصميم القائمة" + }, + { + "name": "global_menu_width", + "value": "عرض القائمة" + }, + { + "name": "menu_option", + "value": "قائمة الخيارات" + }, + { + "name": "vertical_layout", + "value": "تخطيط عمودي" + }, + { + "name": "horizontal_layout", + "value": "تخطيط أفقي" + }, + { + "name": "menu_width", + "value": "عرض" + }, + { + "name": "textclock_style", + "value": "أسلوب ." + }, + { + "name": "text_clock_textShadow", + "value": "نص الظل" + }, + { + "name": "text_clock_fontSetting", + "value": "إعدادات الخط" + }, + { + "name": "text_clock_select_button", + "value": "اختيار زر" + }, + { + "name": "text_clock_monospaced_numbers", + "value": "رقم واحد" + }, + { + "name": "text_clock_monovolume_numbers", + "value": "حجم واحد عدد" + }, + { + "name": "text_input_text_selection_menu", + "value": "قائمة اختيار النص" + }, + { + "name": "text_custom_menu", + "value": "نص مخصص القائمة" + }, + { + "name": "text_input_text_copy", + "value": "نسخ" + }, + { + "name": "text_input_text_copy_success", + "value": "نسخة ناجحة" + }, + { + "name": "text_input_text_paste", + "value": "لصق" + }, + { + "name": "text_input_text_paste_success", + "value": "لصق بنجاح" + }, + { + "name": "text_input_text_get", + "value": "الحصول على" + }, + { + "name": "text_input_text_delete", + "value": "حذف النص" + }, + { + "name": "text_input_line_break_strategy", + "value": "كسر استراتيجية" + }, + { + "name": "text_input_line_break_strategy_content", + "value": "أنها يمكن أن تكون مقسمة إلى المدمج في المكونات -- المكونات التي يتم توفيرها مباشرة من قبل arkui الإطار ، مكونات مخصصة -- التي يحددها المطور . المدمج في المكونات تشمل أزرار ، أزرار الراديو ، ومؤشرات التقدم ، والنصوص . يمكنك تعيين عرض هذه المكونات في طريقة ربط الوضع ، مكونات الصفحة مقسمة إلى وحدات واجهة المستخدم منفصلة لإنشاء وتطوير وإعادة استخدام وحدات مختلفة على الصفحة ، مما يجعل الصفحة أكثر هندسة المنحى ." + }, + { + "name": "text_input_word_break", + "value": "قطع" + }, + { + "name": "text_input_word_break_content", + "value": "هذه هي ميزة وضع WordBreak إلى نص WordBreak Taumatawakathangakoauotamateature ، وهذا هو ، عندما كنت لا تعرف ، سوف تجد أنك لا تعرف ." + }, + { + "name": "textarea_character_limit", + "value": "الحد من حرف" + }, + { + "name": "grid_item_polymorphic_styles", + "value": "نمط متعدد الأشكال" + }, + { + "name": "previous", + "value": "سابق" + }, + { + "name": "next_step", + "value": "الخطوة التالية" + }, + { + "name": "text_styled_string_title", + "value": "سلسلة نمط النص" + }, + { + "name": "text_mutable_styled_string", + "value": "نمط سلسلة" + }, + { + "name": "text_mutable_styled_string_start", + "value": "نقطة الانطلاق" + }, + { + "name": "text_mutable_styled_string_length", + "value": "طول ." + }, + { + "name": "text_mutable_styled_error", + "value": "من فضلك أدخل" + }, + { + "name": "text_styled_string_gesture_style", + "value": "لفتة نمط" + }, + { + "name": "rows_and_columns", + "value": "الصفوف والأعمدة" + }, + { + "name": "stack_flex_and_grid", + "value": "كومة ، والانحناء ، تنسجم" + }, + { + "name": "list_and_grid", + "value": "قائمة الشبكة" + }, + { + "name": "navigation", + "value": "ملاحة" + }, + { + "name": "canvas_and_graphic_drawing", + "value": "قماش والرسومات" + }, + { + "name": "size_transition_flex", + "value": "بنت ." + }, + { + "name": "size_transition_grid_item", + "value": "شبكة البند" + }, + { + "name": "size_transition_list_item", + "value": "قائمة البنود" + }, + { + "name": "size_transition_swiper_item", + "value": "مشروع بطاقة ممغنطة" + }, + { + "name": "size_transition_font_size", + "value": "حجم الخط" + }, + { + "name": "size_transition_expansion_tabContent", + "value": "علامة التبويب المحتوى" + }, + { + "name": "set_background_blur_style_color_mode", + "value": "تعيين نمط لون الخلفية الضبابية" + }, + { + "name": "set_background_blur_style_adaptive_color", + "value": "تعيين لون الخلفية الضبابي المتكيف" + }, + { + "name": "blur_style_system", + "value": "نظم" + }, + { + "name": "blur_style_light", + "value": "الإضاءة" + }, + { + "name": "blur_style_dark", + "value": "ظلام ." + }, + { + "name": "blur_style_default", + "value": "خرق" + }, + { + "name": "shadow_type_color", + "value": "الألوان" + }, + { + "name": "shadow_type_blur", + "value": "طمس" + }, + { + "name": "blur_style_average", + "value": "متوسط القيمة" + }, + { + "name": "divider_color_blue", + "value": "بلو" + }, + { + "name": "divider_color_green", + "value": "غرين" + }, + { + "name": "divider_color_orange", + "value": "برتقالي" + }, + { + "name": "divider_color_pink", + "value": "وردي" + }, + { + "name": "divider_line_type_butt", + "value": "السيجارة" + }, + { + "name": "divider_line_type_round", + "value": "دائرة" + }, + { + "name": "divider_line_type_square", + "value": "ساحة" + }, + { + "name": "safe_area_type_and_safe_area_edge", + "value": "safeareatype و safeareedge" + }, + { + "name": "save_area_input_text", + "value": "أدخل كلمة . . ." + }, + { + "name": "safe_area_type", + "value": "نوع المنطقة الأمنية" + }, + { + "name": "safe_area_edge", + "value": "سافاريادج" + }, + { + "name": "safe_area_edge_top", + "value": "توب ." + }, + { + "name": "safe_area_edge_bottom", + "value": "القاع" + }, + { + "name": "safe_area_edge_start", + "value": "بداية ." + }, + { + "name": "safe_area_edge_end", + "value": "نهاية ." + }, + { + "name": "safe_area_type_system", + "value": "نظم" + }, + { + "name": "safe_area_type_cutout", + "value": "شق" + }, + { + "name": "safe_area_type_keyboard", + "value": "لوحة المفاتيح ." + }, + { + "name": "System_icon", + "value": "رمز النظام" + }, + { + "name": "text_content_en", + "value": "خفف من الصلب في النار والتبريد السريع ، بحيث يمكن أن يكون من الصعب جدا ، لا تخافوا من أي شيء . وبهذه الطريقة فقط ، فإن جيلنا قد شحذ في النضال و التجارب الرهيبة و تعلمت عدم الاستسلام للحياة ." + }, + { + "name": "text_content_en_first", + "value": "خفف من الصلب في النار والتبريد السريع ، بحيث يمكن أن يكون من الصعب جدا ، لا تخافوا من أي شيء ." + }, + { + "name": "text_content_en_last", + "value": "وبهذه الطريقة فقط ، فإن جيلنا قد شحذ في النضال و التجارب الرهيبة و تعلمت عدم الاستسلام للحياة ." + }, + { + "name": "touch_hit_test", + "value": "انقر فوق منطقة ساخنة : تعيين منطقة ساخنة في المنطقة الخضراء" + }, + { + "name": "side_bar_effects_title", + "value": "تأثير الشريط الجانبي" + }, + { + "name": "set_side_bar_type", + "value": "تعيين نوع الشريط الجانبي" + }, + { + "name": "side_bar_container_content", + "value": "sidebar محتويات الحاوية" + }, + { + "name": "hide_side_bar", + "value": "إخفاء الشريط الجانبي" + }, + { + "name": "show_side_bar", + "value": "عرض شريط جانبي" + }, + { + "name": "side_bar_type_embed", + "value": "جزءا لا يتجزأ من" + }, + { + "name": "side_bar_type_overlay", + "value": "تغطية طبقة" + }, + { + "name": "side_bar_type_auto", + "value": "السيارات" + }, + { + "name": "auxiliary_refresh_refreshing", + "value": "منعش" + }, + { + "name": "rich_editor", + "value": "ريش ديتور" + }, + { + "name": "rich_editor_style", + "value": "أسلوب ." + }, + { + "name": "rich_editor_title", + "value": "ريش ديتور" + }, + { + "name": "nav_router", + "value": "توجيه الملاحة" + }, + { + "name": "tabs_name", + "value": "تبويب" + }, + { + "name": "select_name", + "value": "مختار" + }, + { + "name": "slider_name", + "value": "المنزلق" + }, + { + "name": "delete_list_item", + "value": "حذف قائمة البند" + }, + { + "name": "size_size_description_one", + "value": "العرض والارتفاع" + }, + { + "name": "size_size_description_two", + "value": "العرض والارتفاع 100%" + }, + { + "name": "size_size_padding_one", + "value": "أعلى ، أسفل ، اليسار واليمين الهوامش الداخلية 10vp" + }, + { + "name": "size_size_padding_two", + "value": "الهامش الداخلي 20%" + }, + { + "name": "size_size_margin_one", + "value": "أعلى ، أسفل ، يسار ، يمين" + }, + { + "name": "size_size_margin_two", + "value": "المسافة الخارجية العليا 20%" + }, + { + "name": "size_size_constraintSize_one", + "value": "الحد الأقصى للعرض والارتفاع 90vp" + }, + { + "name": "size_size_constraintSize_two", + "value": "الحد الأدنى من العرض والارتفاع 80vp" + }, + { + "name": "keyPress_event", + "value": "اضغط على الحدث" + }, + { + "name": "focus_event_description", + "value": "اضغط على علامة التبويب لوحة المفاتيح الخارجية للحصول على التركيز ، ثم اضغط على مفتاح التبديل" + }, + { + "name": "focus_event_button_one", + "value": "الزر الأول" + }, + { + "name": "focus_event_button_two", + "value": "الزر الثاني" + }, + { + "name": "focus_event_button_three", + "value": "الزر الثالث" + }, + { + "name": "focus_event_toast_text", + "value": "الزناد التركيز" + }, + { + "name": "press_event_toast_text", + "value": "زر الزناد الحدث" + }, + { + "name": "press_event_toast_description", + "value": "اضغط على أي مفتاح على لوحة المفاتيح الخارجية" + }, + { + "name": "mouse_event_move_description", + "value": "استخدام الماوس الخارجي للانتقال إلى زر" + }, + { + "name": "mouse_event_click_description", + "value": "استخدام الفأرة الخارجية للنقر على زر" + }, + { + "name": "mouse_event_hover_description", + "value": "ماوس" + }, + { + "name": "mouse_event_onHover_description", + "value": "الماوس لا تتحرك" + }, + { + "name": "mouse_event_onMouse_text", + "value": "على الماوس" + }, + { + "name": "mouse_event_mouseBtn_none", + "value": "هل أنت بخير ؟ - لا -" + }, + { + "name": "mouse_event_mouseBtn_left", + "value": "يسار ." + }, + { + "name": "mouse_event_mouseBtn_right", + "value": "صحيح ." + }, + { + "name": "mouse_event_mouseBtn_back", + "value": "العودة" + }, + { + "name": "mouse_event_mouseBtn_forward", + "value": "فورورد" + }, + { + "name": "mouse_event_mouseBtn_middle", + "value": "متوسط" + }, + { + "name": "mouse_event_mouseAction_hover", + "value": "تحوم" + }, + { + "name": "mouse_event_mouseAction_press", + "value": "ميديا ." + }, + { + "name": "mouse_event_mouseAction_move", + "value": "تحرك ." + }, + { + "name": "mouse_event_mouseAction_release", + "value": "أطلق" + }, + { + "name": "scroll_event", + "value": "عنصر المنطقة المرئية تغيير الحدث" + }, + { + "name": "scroll_event_description", + "value": "قائمة الشرائح يجعل الصورة تختفي و تظهر" + }, + { + "name": "scroll_event_toast_visible", + "value": "صور حب واضحة للعيان" + }, + { + "name": "scroll_event_toast_invisible", + "value": "صورة الحب اختفى تماما" + }, + { + "name": "location_settings", + "value": "وضع" + }, + { + "name": "location_settings_align", + "value": "طريقة محاذاة" + }, + { + "name": "location_settings_direction", + "value": "تخطيط أفقي" + }, + { + "name": "location_settings_position", + "value": "المواقع المطلقة" + }, + { + "name": "location_settings_markAnchor", + "value": "مجموعة مرساة" + }, + { + "name": "location_settings_offset", + "value": "بالنسبة لتحديد المواقع" + }, + { + "name": "location_settings_alignRules", + "value": "محاذاة القاعدة" + }, + { + "name": "location_settings_bottom_end", + "value": "نهاية القاع" + }, + { + "name": "location_settings_top_start", + "value": "أعلى بداية" + }, + { + "name": "location_settings_center", + "value": "مركز" + }, + { + "name": "location_settings_position_text", + "value": "الموقع ( 30 ، 10 )" + }, + { + "name": "location_settings_position_offSet_text", + "value": "Original : ENGLISH" + }, + { + "name": "layout_constrain", + "value": "تخطيط القيد" + }, + { + "name": "layout_constrain_aspectRatio", + "value": "عنصر نسبة الارتفاع" + }, + { + "name": "layout_constrain_displayPriority", + "value": "عنصر الأولوية" + }, + { + "name": "layout_constrain_big_container", + "value": "حاوية كبيرة" + }, + { + "name": "layout_constrain_middle_container", + "value": "حاوية متوسطة الحجم" + }, + { + "name": "layout_constrain_small_container", + "value": "حاوية صغيرة" + }, + { + "name": "layout_constrain_children_one", + "value": "1 : ( أولوية : 2 )" + }, + { + "name": "layout_constrain_children_two", + "value": "2 : ( الأولوية : 1 )" + }, + { + "name": "layout_constrain_children_three", + "value": "3 : ( الأولوية : 3 )" + }, + { + "name": "layout_constrain_children_four", + "value": "4 : ( الأولوية : 1 )" + }, + { + "name": "layout_constrain_children_five", + "value": "5 - ( الأولوية : 2 )" + }, + { + "name": "layout_constrain_one", + "value": "1 ." + }, + { + "name": "layout_constrain_two", + "value": "2 ." + }, + { + "name": "flex", + "value": "بنت ." + }, + { + "name": "flex_flexBasis", + "value": "فليكسباسيس" + }, + { + "name": "flex_flexGrow", + "value": "فلکسجرو" + }, + { + "name": "flex_flexShrink", + "value": "فليكس شرينك" + }, + { + "name": "flex_alignSelf", + "value": "اليغن سلف" + }, + { + "name": "flex_layoutWeight", + "value": "تخطيط الوزن" + }, + { + "name": "flex_no_layoutWeight", + "value": "عن تخطيط الوزن" + }, + { + "name": "flex_no_alignSelf_70", + "value": "محاذاة النفس ، الارتفاع : 70%" + }, + { + "name": "flex_end_alignSelf", + "value": "محاذاة نهاية النفس" + }, + { + "name": "flex_end_alignSelf_100", + "value": "محاذاة نهاية النفس" + }, + { + "name": "flex_shrink_0", + "value": "فليكس انكماش" + }, + { + "name": "flex_shrink_default", + "value": "فليكس شرينك" + }, + { + "name": "flex_shrink_1", + "value": "فليكس شرينك" + }, + { + "name": "flex_grow_1", + "value": "FlexGrow ( 1 )" + }, + { + "name": "flex_grow_2", + "value": "FlexGrow ( 2 )" + }, + { + "name": "flex_no_alignSelf_100", + "value": "محاذاة الذاتي ، الطول : 100%" + }, + { + "name": "flex_basis_100", + "value": "FlexBasis ( 100 )" + }, + { + "name": "flex_basis_auto", + "value": "FlexBasis ( تلقائي )" + }, + { + "name": "picture_border", + "value": "حدود الصورة" + }, + { + "name": "scale", + "value": "مقياس" + }, + { + "name": "transform", + "value": "تحويل" + }, + { + "name": "scale_image", + "value": "تكبير الصورة" + }, + { + "name": "transform_image", + "value": "تحويل الصورة" + }, + { + "name": "transform_init", + "value": "إنشاء مصفوفة من المرتبة الرابعة" + }, + { + "name": "transform_copy", + "value": "مصفوفة النسخ المتماثل" + }, + { + "name": "transform_combine", + "value": "تأثير مصفوفة تراكب" + }, + { + "name": "transform_invert", + "value": "عكس تأثير المصفوفة" + }, + { + "name": "transform_translate", + "value": "مصفوفة تأثير الترجمة" + }, + { + "name": "transform_scale", + "value": "تأثير حجم المصفوفة" + }, + { + "name": "transform_rotate", + "value": "تأثير مصفوفة التناوب" + }, + { + "name": "transform_transformPoint", + "value": "تأثير مصفوفة تحويل الإحداثيات" + }, + { + "name": "transform_combine_text", + "value": "ترجمة × 20 و التكبير مرتين" + }, + { + "name": "transform_translate_text", + "value": "س : 40 ، ص : 40 ، ض : 20" + }, + { + "name": "transform_scale_text", + "value": "العرض والارتفاع بمقدار مرتين" + }, + { + "name": "transform_rotate_text", + "value": "دوران 30 درجة" + }, + { + "name": "transform_transformPoint_before", + "value": "الإحداثيات بعد تحويل المصفوفة : [ 50 , 50 ]" + }, + { + "name": "transform_transformPoint_after", + "value": "الإحداثيات بعد تحويل المصفوفة : [ 100 , 0 ]" + }, + { + "name": "shape_crop", + "value": "شكل الخياطة" + }, + { + "name": "shape_crop_clip", + "value": "قطع" + }, + { + "name": "shape_crop_mask", + "value": "غطى" + }, + { + "name": "grid_settings", + "value": "إعدادات الشبكة" + }, + { + "name": "grid_settings_sm", + "value": "جهاز عرض خ" + }, + { + "name": "grid_settings_md", + "value": "عرض الجهاز MD" + }, + { + "name": "grid_settings_lg", + "value": "عرض الجهاز إل جي" + }, + { + "name": "grid_settings_useSize", + "value": "استخدام نوع الحجم" + }, + { + "name": "grid_settings_gridSpan", + "value": "gridspan شبكة تعويض" + }, + { + "name": "grid_edgeEffect_spring", + "value": "شبكة حافة تأثير الربيع" + }, + { + "name": "focus_control", + "value": "التركيز على السيطرة" + }, + { + "name": "focus_control_tab", + "value": "التركيز على السيطرة على التبويب" + }, + { + "name": "focus_control_lastPageId", + "value": "معرف الصفحة الأخيرة" + }, + { + "name": "focus_control_success", + "value": "التركيز على السيطرة على النجاح" + }, + { + "name": "focus_control_failed", + "value": "التركيز على السيطرة على الفشل" + }, + { + "name": "focus_control_group1", + "value": "المجموعة الأولى" + }, + { + "name": "focus_control_group2", + "value": "المجموعة الثانية" + }, + { + "name": "focus_control_group3", + "value": "المجموعة الثالثة" + }, + { + "name": "focus_control_input", + "value": "المدخلات" + }, + { + "name": "focus_control_request_focus", + "value": "التركيز على السيطرة على الطلب" + }, + { + "name": "component_id", + "value": "عنصر الهوية" + }, + { + "name": "component_id_onKeyTab", + "value": "اونكي تاب" + }, + { + "name": "component_id_click", + "value": "انقر فوق ابدأ" + }, + { + "name": "component_id_longClick", + "value": "نقرات طويلة" + }, + { + "name": "component_id_onTouch", + "value": "اونتوش" + }, + { + "name": "component_id_onMouse", + "value": "اونموس" + }, + { + "name": "component_id_click_text", + "value": "انقر على زر ابدأ" + }, + { + "name": "component_id_longClick_text", + "value": "تم النقر على زر \" LongClick \" لفترة طويلة" + }, + { + "name": "component_id_onTouch_text", + "value": "انقر على زر \" ontouch \"" + }, + { + "name": "component_id_onMouse_text", + "value": "\" onmouse \" زر في onmouse" + }, + { + "name": "component_blurred", + "value": "عنصر غامض" + }, + { + "name": "component_blurred_thin", + "value": "عنصر غامض رقيقة" + }, + { + "name": "restore_id", + "value": "استعادة الهوية" + }, + { + "name": "gesture_process", + "value": "لفتة العملية" + }, + { + "name": "bind_gesture_methods", + "value": "ملزمة لفتة طريقة" + }, + { + "name": "bind_gesture_priorityGesture", + "value": "prioritygeture يتجاهل النص أولوية تحديد الوالد مكون العمود" + }, + { + "name": "bind_gesture_parallelGesture", + "value": "parallelgesture يحدد الوالد الطفل عنصر العمود ، النص" + }, + { + "name": "bind_gesture_tapGesture", + "value": "انقر على الإيماءات :" + }, + { + "name": "bind_gesture_text", + "value": "نص ." + }, + { + "name": "bind_gesture_column", + "value": "عمود" + }, + { + "name": "double_click", + "value": "نقرا مزدوجا فوق الزناد" + }, + { + "name": "onAction", + "value": "على العمل :" + }, + { + "name": "long_press", + "value": "إصبع واحد طويل اضغط على النص" + }, + { + "name": "long_press_cancel", + "value": "إلغاء النشاط" + }, + { + "name": "long_press_text", + "value": "اضغط على لي مع إصبع واحد ، من فضلك ." + }, + { + "name": "pan_text", + "value": "سحب مربع أسود بأي شكل من الأشكال مع اثنين من أصابع" + }, + { + "name": "pan_text_one", + "value": "سحب مربع أسود مع إصبع واحد اليسار واليمين" + }, + { + "name": "pan_offset", + "value": "( بآلاف دولارات الولايات المتحدة )" + }, + { + "name": "pan_offset_y", + "value": "ي > ?" + }, + { + "name": "pinch_center", + "value": "مركز قرصة الإيماءات :" + }, + { + "name": "rotation_text", + "value": "لفتة التناوب" + }, + { + "name": "swipe_text_speed", + "value": "انزلاق الموقف" + }, + { + "name": "swipe_text_angle", + "value": "انزلاق الموقف" + }, + { + "name": "combinded_pan_start", + "value": "بداية الترجمة" + }, + { + "name": "combinded_pan_update", + "value": "بان التحديث" + }, + { + "name": "combinded_pan_end", + "value": "نهاية وعاء" + }, + { + "name": "combinded_longPress_onAction", + "value": "لونغبريس أون أكشن" + }, + { + "name": "combinded_longPress_end", + "value": "الصحافة نهاية طويلة" + }, + { + "name": "combinded_sequence", + "value": "تسلسل لفتة" + }, + { + "name": "combinded_longPress", + "value": "Longpress على العمل :" + }, + { + "name": "combinded_offset", + "value": "( بآلاف دولارات الولايات المتحدة )" + }, + { + "name": "combinded_x", + "value": "عشرة" + }, + { + "name": "key_press_keyType", + "value": "نوع المفتاح :" + }, + { + "name": "key_press_keyCode", + "value": "رمز المفتاح" + }, + { + "name": "key_press_keyText", + "value": "نص الكلمات الرئيسية :" + }, + { + "name": "key_press_down", + "value": "نزل" + }, + { + "name": "key_press_up", + "value": "صاعد" + }, + { + "name": "componentId_longClick", + "value": "نقرات طويلة" + }, + { + "name": "componentId_onTouch", + "value": "اونتوش" + }, + { + "name": "componentId_onMouse", + "value": "على الماوس" + }, + { + "name": "flex_auto", + "value": "السيارات" + }, + { + "name": "row_title", + "value": "فصيلة" + }, + { + "name": "row_introduction_arguments", + "value": "تعديل خط المعلمة" + }, + { + "name": "row_introduction_properties", + "value": "تعديل خصائص الخط" + }, + { + "name": "row_element_spacing", + "value": "عنصر تباعد" + }, + { + "name": "row_alignitems_top", + "value": "توب ." + }, + { + "name": "row_alignitems_bottom", + "value": "القاع" + }, + { + "name": "row_alignitems_center", + "value": "مركز" + }, + { + "name": "row_justifycontent_start", + "value": "نقطة الانطلاق" + }, + { + "name": "row_justifycontent_center", + "value": "مركز" + }, + { + "name": "row_justifycontent_end", + "value": "نهاية ." + }, + { + "name": "row_justifycontent_spacebetween", + "value": "بين الفراغات" + }, + { + "name": "row_justifycontent_spacearound", + "value": "الفضاء المحيط" + }, + { + "name": "row_justifycontent_spaceevenly", + "value": "مساحة موحدة" + }, + { + "name": "row_justifycontent_description", + "value": "تنسيق المغزل" + }, + { + "name": "row_alignitems_description", + "value": "تنسيق المحور الأفقي" + }, + { + "name": "row_introduction_tips", + "value": "نصيحة" + }, + { + "name": "row_tips", + "value": "عندما المغزل هو من نوع spacetween spacearound , أو spaceeven ، المعلمة الفضاء صف العنصر لا يعمل" + }, + { + "name": "rowsplit_title", + "value": "تقسيم أفقي تخطيط" + }, + { + "name": "rowsplit_introduction_properties", + "value": "تعديل خصائص rowsplit السحب والإسقاط" + }, + { + "name": "rowsplit_drag", + "value": "سحب التبديل" + }, + { + "name": "rowsplit_drag_divider", + "value": "سحب فواصل اليسار واليمين لتغيير الموقف" + }, + { + "name": "column_title", + "value": "عمود" + }, + { + "name": "column_introduction_arguments", + "value": "تعديل خط المعلمة" + }, + { + "name": "column_introduction_properties", + "value": "تعديل خصائص الخط" + }, + { + "name": "column_element_spacing", + "value": "عنصر تباعد" + }, + { + "name": "column_alignitems_start", + "value": "نقطة الانطلاق" + }, + { + "name": "column_alignitems_end", + "value": "نهاية ." + }, + { + "name": "column_alignitems_center", + "value": "مركز" + }, + { + "name": "column_justifycontent_start", + "value": "نقطة الانطلاق" + }, + { + "name": "column_justifycontent_center", + "value": "مركز" + }, + { + "name": "column_justifycontent_end", + "value": "نهاية ." + }, + { + "name": "column_justifycontent_spacebetween", + "value": "بين الفراغات" + }, + { + "name": "column_justifycontent_spacearound", + "value": "الفضاء المحيط" + }, + { + "name": "column_justifycontent_spaceevenly", + "value": "مساحة موحدة" + }, + { + "name": "column_justifycontent_description", + "value": "تنسيق المغزل" + }, + { + "name": "column_alignitems_description", + "value": "تنسيق المحور الأفقي" + }, + { + "name": "column_introduction_tips", + "value": "نصيحة" + }, + { + "name": "column_tips", + "value": "عندما المغزل هو من نوع spacetween spacearound , أو spaceeven ، المعلمة الفضاء صف العنصر لا يعمل" + }, + { + "name": "columnsplit_title", + "value": "تقسيم عمودي تخطيط" + }, + { + "name": "columnsplit_introduction_properties", + "value": "تعديل خاصية السحب والإفلات من columnsplit" + }, + { + "name": "columnsplit_drag", + "value": "سحب التبديل" + }, + { + "name": "columnsplit_introduction_drag_divider", + "value": "اسحب خط التقسيم صعودا وهبوطا لتغيير الموقف" + }, + { + "name": "sidebarcontainer_title", + "value": "sidebar حاوية" + }, + { + "name": "sidebarcontainer_content_text", + "value": "sidebarcontainer : حاوية الشريط الجانبي الذي يوفر عرض وإخفاء الشريط الجانبي . الشريط الجانبي ومحتوى المناطق المحددة من قبل عناصر فرعية ، أول عنصر فرعي يمثل الشريط الجانبي ، والثاني عنصر فرعي يمثل محتوى المنطقة . هذا العنصر هو مدعوم من المعهد الإصدار 8 . إذا كان محتوى جديد يضاف إلى الإصدارات اللاحقة ، الزاوية العليا علامة تستخدم علامة بداية الإصدارات الفردية من المحتوى ." + }, + { + "name": "sidebarcontainer_sidebar_text_one", + "value": "جمع" + }, + { + "name": "sidebarcontainer_sidebar_text_two", + "value": "الصفحة الرئيسية" + }, + { + "name": "sidebarcontainer_argument", + "value": "تعديل sidebarcontainer عينة" + }, + { + "name": "sidebarcontainer_property", + "value": "تعديل sidebarcontainer الملكية" + }, + { + "name": "sidebarcontainer_argument_type", + "value": "الشريط الجانبي نوع العرض" + }, + { + "name": "sidebarcontainer_type_embed", + "value": "جزءا لا يتجزأ من" + }, + { + "name": "sidebarcontainer_type_overlay", + "value": "تغطية طبقة" + }, + { + "name": "sidebarcontainer_show_switch", + "value": "عرض التبديل" + }, + { + "name": "sidebarcontainer_left_margin", + "value": "زر التحكم في المسافة إلى اليسار" + }, + { + "name": "sidebarcontainer_top_margin", + "value": "المسافة من زر التحكم" + }, + { + "name": "sidebarcontainer_show_button_switch", + "value": "زر التحكم عرض التبديل" + }, + { + "name": "sidebarcontainer_position_title", + "value": "الشريط الجانبي يظهر الموقع" + }, + { + "name": "sidebarcontainer_sidebar_show_position_start", + "value": "نقطة الانطلاق" + }, + { + "name": "sidebarcontainer_sidebar_show_position_end", + "value": "نهاية ." + }, + { + "name": "sidebarcontainer_min_width", + "value": "الحد الأدنى من عرض الشريط الجانبي" + }, + { + "name": "sidebarcontainer_max_width", + "value": "أقصى عرض الشريط الجانبي" + }, + { + "name": "sidebarcontainer_auto_hide", + "value": "هو الشريط الجانبي مخفي في الحد الأدنى من الدولة" + }, + { + "name": "sidebarcontainer_divider_width", + "value": "تقسيم خط العرض" + }, + { + "name": "sidebarcontainer_drag_divider", + "value": "اسحب فاصل لتغيير حجم الشريط الجانبي" + }, + { + "name": "sidebarcontainer__is_show_true", + "value": "الشريط الجانبي هو توسيع" + }, + { + "name": "sidebarcontainer__is_show_false", + "value": "الشريط الجانبي مغلق" + }, + { + "name": "stack_title", + "value": "كومة" + }, + { + "name": "stack_alignments_topstart", + "value": "توب ستارت" + }, + { + "name": "stack_alignments_top", + "value": "توب ." + }, + { + "name": "stack_alignments_topend", + "value": "توبند" + }, + { + "name": "stack_alignments_start", + "value": "نقطة الانطلاق" + }, + { + "name": "stack_alignment_center", + "value": "مركز" + }, + { + "name": "stack_alignment_end", + "value": "نهاية ." + }, + { + "name": "stack_alignments_bottomstart", + "value": "بداية القاع" + }, + { + "name": "stack_alignments_bottom", + "value": "القاع" + }, + { + "name": "stack_alignments_bottomend", + "value": "نهاية القاع" + }, + { + "name": "stack_alignment", + "value": "محاذاة المحتوى" + }, + { + "name": "stack_introduction", + "value": "خاصية المكدس والمعلمة aligncontent تم تحديثها" + }, + { + "name": "stack_introduction_zindex", + "value": "أكسيد الزنك" + }, + { + "name": "stack_zindex_four", + "value": "4 ." + }, + { + "name": "stack_zindex_one", + "value": "1 ." + }, + { + "name": "stack_zindex", + "value": "زيندكس" + }, + { + "name": "flex_title", + "value": "بنت ." + }, + { + "name": "flex_introduction_arguments", + "value": "تعديل تخطيط مرن المعلمات" + }, + { + "name": "flex_argument_direction", + "value": "الاتجاه" + }, + { + "name": "flex_argument_direction_row", + "value": "فصيلة" + }, + { + "name": "flex_argument_direction_row_reverse", + "value": "صف عكس" + }, + { + "name": "flex_argument_direction_column", + "value": "عمود" + }, + { + "name": "flex_argument_direction_column_reverse", + "value": "العمود عكس" + }, + { + "name": "flex_argument_wrap", + "value": "تعديل حزمة لتناسب هذا الانحناء" + }, + { + "name": "flex_argument_wrap_no_wrap", + "value": "بدون تغليف" + }, + { + "name": "flex_argument_wrap_wrap", + "value": "لف" + }, + { + "name": "flex_argument_wrap_wrap_reverse", + "value": "التعبئة والتغليف عكس" + }, + { + "name": "flex_introduction_direction", + "value": "تغيير اتجاه جميع الانحناء" + }, + { + "name": "flex_argument_justifycontent", + "value": "تعديل هذا فليكس justifycontent" + }, + { + "name": "flex_argument_justifycontent_start", + "value": "نقطة الانطلاق" + }, + { + "name": "flex_argument_justifycontent_center", + "value": "مركز" + }, + { + "name": "flex_argument_justifycontent_End", + "value": "نهاية ." + }, + { + "name": "flex_argument_justifycontent_space_between", + "value": "بين الفراغات" + }, + { + "name": "flex_argument_justifycontent_space_around", + "value": "الفضاء المحيط" + }, + { + "name": "flex_argument_justifycontent_speac_evenly", + "value": "مساحة موحدة" + }, + { + "name": "flex_argument_alignItems", + "value": "تعديل alignitems في هذا فليكس" + }, + { + "name": "flex_argumen_alignItems_auto", + "value": "السيارات" + }, + { + "name": "flex_argumen_alignItems_start", + "value": "نقطة الانطلاق" + }, + { + "name": "flex_argumen_alignItems_center", + "value": "مركز" + }, + { + "name": "flex_argumen_alignItems_end", + "value": "نهاية ." + }, + { + "name": "flex_argumen_alignItems_stretch", + "value": "امتدت" + }, + { + "name": "flex_argumen_alignItems_baseline", + "value": "خط الأساس" + }, + { + "name": "flex_argument_alignContent", + "value": "تعديل aligncontent هذا فليكس" + }, + { + "name": "gridcontainer_title", + "value": "gridcontainer نظام الشبكة" + }, + { + "name": "gridcontainer_introdional_arguments", + "value": "تعديل gridcontainer المعلمة" + }, + { + "name": "gridcontainer_introdional_properties", + "value": "تعديل خاصية gridcontainer" + }, + { + "name": "gridcontainer_sizetype", + "value": "سيزتايب" + }, + { + "name": "gridcontainer_sizetype_xs", + "value": "اكس اس" + }, + { + "name": "gridcontainer_sizetype_sm", + "value": "خ" + }, + { + "name": "gridcontainer_sizetype_md", + "value": "إم دي" + }, + { + "name": "gridcontainer_sizetype_lg", + "value": "إل جي" + }, + { + "name": "gridcontainer_sizetype_auto", + "value": "السيارات" + }, + { + "name": "gridcontainer_column", + "value": "عمود" + }, + { + "name": "gridcontainer_gutter", + "value": "مزراب" + }, + { + "name": "gridcontainer_margin", + "value": "حافة" + }, + { + "name": "image_video_and_media", + "value": "صورة الفيديو ووسائل الإعلام" + }, + { + "name": "image_title", + "value": "صور" + }, + { + "name": "image_animator_title", + "value": "صورة انيماتور" + }, + { + "name": "video_title", + "value": "فيديو : ." + }, + { + "name": "plugin_component_title", + "value": "المكونات في مكونات" + }, + { + "name": "xcomponent_title", + "value": "العنصر العاشر" + }, + { + "name": "image_show_test", + "value": "عرض الصور" + }, + { + "name": "image_object_fit", + "value": "objectfit ؛ objectfit" + }, + { + "name": "image_sourcesize_height", + "value": "حجم الارتفاع" + }, + { + "name": "image_sourcesize_width", + "value": "حجم العرض" + }, + { + "name": "object_fit_cover", + "value": "تغطية" + }, + { + "name": "object_fit_contain", + "value": "احتواء" + }, + { + "name": "object_fit_auto", + "value": "السيارات" + }, + { + "name": "object_fit_fill", + "value": "ملأ" + }, + { + "name": "object_fit_scale_down", + "value": "تقليص حجم" + }, + { + "name": "object_fit_none", + "value": "هل أنت بخير ؟ - لا -" + }, + { + "name": "object_fit_change", + "value": "ObjectFitChange" + }, + { + "name": "image_sourcesize_change", + "value": "تغيير حجم المصدر" + }, + { + "name": "image_rendermode_original", + "value": "طريقة التقديم الأصلي" + }, + { + "name": "image_rendermode_template", + "value": "تقديم نموذج" + }, + { + "name": "image_renderMode_change", + "value": "تغيير طريقة التقديم" + }, + { + "name": "image_repeat_xy", + "value": "تكرار س ص" + }, + { + "name": "image_repeat_x", + "value": "تكرار س" + }, + { + "name": "image_repeat_y", + "value": "تكرار ذ" + }, + { + "name": "image_repeat_no", + "value": "لا تكرار" + }, + { + "name": "image_repeat_change", + "value": "تكرار التغييرات" + }, + { + "name": "image_fill_color_title", + "value": "ملء لون العنوان" + }, + { + "name": "image_animator_show", + "value": "صورة انيماتور شو" + }, + { + "name": "image_animator_control", + "value": "imageanimator السيطرة" + }, + { + "name": "video_show", + "value": "عرض الفيديو" + }, + { + "name": "video_auto_play", + "value": "اللعب التلقائي" + }, + { + "name": "video_controls_show", + "value": "عرض التحكم" + }, + { + "name": "video_muted_show", + "value": "عرض صامت" + }, + { + "name": "video_fit_change", + "value": "فيديوفيت" + }, + { + "name": "video_loop_show", + "value": "لوپشو" + }, + { + "name": "video_current_rate_change", + "value": "التغيرات في سعر الصرف الحالي" + }, + { + "name": "video_play_mode", + "value": "طريقة تشغيل الفيديو" + }, + { + "name": "video_play_switch", + "value": "تشغيل الفيديو التبديل" + }, + { + "name": "web_title", + "value": "شبكي" + }, + { + "name": "web_show", + "value": "وان نيتكوم" + }, + { + "name": "web_use_reason", + "value": "سبب" + }, + { + "name": "xcomponent_show", + "value": "إكسكومبونينتشو" + }, + { + "name": "textarea_title", + "value": "حقل النص" + }, + { + "name": "patternlock_title", + "value": "رمز قفل" + }, + { + "name": "search_title", + "value": "بحث ." + }, + { + "name": "textarea_textalign_start", + "value": "نقطة الانطلاق" + }, + { + "name": "textarea_textalign_center", + "value": "مركز" + }, + { + "name": "textarea_textalign_end", + "value": "نهاية ." + }, + { + "name": "textareaa_textalign_change", + "value": "textarealatextalignchange" + }, + { + "name": "textarea_show", + "value": "تكست اريشو" + }, + { + "name": "textarea_control", + "value": "السيطرة على منطقة النص" + }, + { + "name": "textarea_copyoptions_none", + "value": "هل أنت بخير ؟ - لا -" + }, + { + "name": "textarea_copyoptions_inapp", + "value": "داخل التطبيق" + }, + { + "name": "textarea_copyoptions_localdevice", + "value": "الأجهزة المحلية" + }, + { + "name": "textarea_copyoptions_change", + "value": "تغيير خيارات النسخ المتماثل" + }, + { + "name": "textarea_placeholder_change", + "value": "تغيير النائبة" + }, + { + "name": "textarea_caretcolor_change", + "value": "علوم التمريض" + }, + { + "name": "patternlock_active_color", + "value": "باترن لوك اكتف كولور" + }, + { + "name": "patternlock_path_color", + "value": "patternlockparhcolor" + }, + { + "name": "patternlock_select_color", + "value": "نمط قفل اختيار اللون" + }, + { + "name": "patternlock_regular_color", + "value": "patternlockregular اللون" + }, + { + "name": "patternlock_side_length", + "value": "نمط طول القفل" + }, + { + "name": "patternlock_circle_radius", + "value": "نمط قفل دائرة نصف قطرها" + }, + { + "name": "patternlock_pathstroke_width", + "value": "patternlockpath strokewidth" + }, + { + "name": "patternlock_change", + "value": "تغيير نمط قفل" + }, + { + "name": "search_textalign_change", + "value": "البحث عن النص محاذاة التغييرات" + }, + { + "name": "search_placeholder_change", + "value": "البحث عن تغيير النائبة" + }, + { + "name": "search_copyOption_change", + "value": "البحث عن خيارات النسخ المتماثل التغييرات" + }, + { + "name": "search_change", + "value": "البحث عن التغييرات" + }, + { + "name": "list_title", + "value": "قائمة" + }, + { + "name": "list_introduction_arguments", + "value": "قائمة المعلمات" + }, + { + "name": "list_introduction_properties", + "value": "قائمة خصائص" + }, + { + "name": "list_introduction_state", + "value": "شريط الحالة" + }, + { + "name": "list_properties_direction", + "value": "قائمة الاتجاه" + }, + { + "name": "list_properties_direction_vertical", + "value": "عمودي" + }, + { + "name": "list_properties_direction_Horizontal", + "value": "الاتجاه الأفقي" + }, + { + "name": "list_argument_space", + "value": "الفضاء ." + }, + { + "name": "list_properties_divider_stroke_width", + "value": "فاصل - السكتة الدماغية العرض" + }, + { + "name": "list_properties_scroll_bar_width", + "value": "سكرول بار - عرض" + }, + { + "name": "list_properties_scroll_bar_color", + "value": "سكرول بار - لون" + }, + { + "name": "list_properties_divider_color", + "value": "فاصل - لون" + }, + { + "name": "list_properties_scroll_bar", + "value": "سكرول بار" + }, + { + "name": "list_properties_scroll_bar_off", + "value": "قريب" + }, + { + "name": "list_properties_scroll_bar_on", + "value": "ون" + }, + { + "name": "list_properties_scroll_bar_auto", + "value": "السيارات" + }, + { + "name": "list_properties_initial_index", + "value": "initial index" + }, + { + "name": "list_properties_edge_effect", + "value": "تأثير الحافة" + }, + { + "name": "list_properties_edge_effect_spring", + "value": "الربيع ." + }, + { + "name": "list_properties_edge_effect_fade", + "value": "تلاشى" + }, + { + "name": "list_properties_edge_effect_none", + "value": "هل أنت بخير ؟ - لا -" + }, + { + "name": "list_properties_chain_animation", + "value": "سلسلة الرسوم المتحركة" + }, + { + "name": "list_properties_multi_selectable", + "value": "اختيار متعددة" + }, + { + "name": "list_properties_lanes", + "value": "حارة" + }, + { + "name": "list_properties_align_list_item", + "value": "اليگنليستیتم" + }, + { + "name": "list_properties_align_list_item_start", + "value": "نقطة الانطلاق" + }, + { + "name": "list_properties_align_list_item_Center", + "value": "مركز" + }, + { + "name": "list_properties_align_list_item_End", + "value": "نهاية ." + }, + { + "name": "list_introduction_delete", + "value": "غادر انقر فوق حذف البند" + }, + { + "name": "list_item_title", + "value": "قائمة البنود" + }, + { + "name": "list_item_properties_selectable", + "value": "اختياري" + }, + { + "name": "list_item_introduction_drag", + "value": "اسحب العناصر مع الماوس لعرض خصائص اختيارية" + }, + { + "name": "list_item_introduction_properties", + "value": "تعديل خصائص listitem" + }, + { + "name": "grid_title", + "value": "شبكة ." + }, + { + "name": "grid_item_title", + "value": "شبكة البند" + }, + { + "name": "grid_properties_columns_template", + "value": "columnstemplate ( السيطرة على نسبة العمود الثالث )" + }, + { + "name": "grid_properties_columns_gap", + "value": "إزالة العمود" + }, + { + "name": "girid_properties_rows_gap", + "value": "روس جاب" + }, + { + "name": "grid_properties_layout_direction", + "value": "تخطيط الاتجاه" + }, + { + "name": "grid_properties_layout_direction_row", + "value": "فصيلة" + }, + { + "name": "grid_properties_layout_direction_column", + "value": "عمود" + }, + { + "name": "grid_properties_layout_direction_row_reverse", + "value": "صف عكس" + }, + { + "name": "grid_properties_layout_direction_column_reverse", + "value": "العمود عكس" + }, + { + "name": "grid_properties_rows_template", + "value": "rowstemplate ( السيطرة على نسبة من السطر الثالث )" + }, + { + "name": "grid_item_introduction", + "value": "تغيير الموقع" + }, + { + "name": "grid_item_row_start", + "value": "تغيير رقم السطر الأول" + }, + { + "name": "grid_item_row_end", + "value": "تعديل رقم خط النهاية" + }, + { + "name": "grid_item_column_start", + "value": "تغيير رقم العمود الأولي" + }, + { + "name": "grid_item_column_end", + "value": "تعديل نهاية العمود رقم" + }, + { + "name": "swiper_introduction_arguments", + "value": "انزلاق تحكم" + }, + { + "name": "swiper_introduction_properties", + "value": "تعديل خصائص المنزلق" + }, + { + "name": "swiper_properties_disable_swipe", + "value": "تعطيل التحول إلى اليسار أو اليمين" + }, + { + "name": "swiper_properties_item_space", + "value": "المسافة بين الصفحات المنزلقة" + }, + { + "name": "swiper_properties_vertical", + "value": "انزلاق عمودي" + }, + { + "name": "swiper_properties_duration", + "value": "مدة الانتقال المتحركة في الألف" + }, + { + "name": "swiper_properties_loop", + "value": "تمكين حلقة" + }, + { + "name": "swiper_properties_interval", + "value": "التلقائي الفاصل الزمني ( الوحدة : ماجستير )" + }, + { + "name": "swiper_controller_next", + "value": "الصفحة التالية" + }, + { + "name": "swiper_controller_previous", + "value": "الصفحة السابقة" + }, + { + "name": "swiper_common_interfaces_and_properties", + "value": "واجهة عامة والممتلكات" + }, + { + "name": "swiper_custom_properties", + "value": "خصائص مخصصة الانتقال المتحركة" + }, + { + "name": "swiper_modify_custom_properties", + "value": "تعديل خصائص مخصصة الانتقال المتحركة" + }, + { + "name": "swiper_custom_property_opacity", + "value": "تغيير التعتيم مدة الرسوم المتحركة" + }, + { + "name": "swiper_custom_property_scale", + "value": "زيادة مدة الصفحة المتحركة" + }, + { + "name": "swiper_close_two_pages_together", + "value": "الجمع بين صفحتين عند التكبير" + }, + { + "name": "swiper_cancel_default_translate", + "value": "إلغاء الترجمة الافتراضية" + }, + { + "name": "swiper_property_auto_play", + "value": "اللعب التلقائي" + }, + { + "name": "swiper_custom_property_curve", + "value": "عرف الانتقال منحنى الرسوم المتحركة" + }, + { + "name": "navRouter_title", + "value": "توجيه الملاحة" + }, + { + "name": "navigation_title", + "value": "ملاحة" + }, + { + "name": "navigation_first_page", + "value": "تصفح الصفحة الرئيسية" + }, + { + "name": "navigation_second_page", + "value": "تصفح ب" + }, + { + "name": "navigation_third_page", + "value": "تصفح ب" + }, + { + "name": "navigation_first_page_push", + "value": "انتقل إلى الصفحة الثانية" + }, + { + "name": "navigation_first_page_active", + "value": "انقر فوق تبديل حالة التنشيط" + }, + { + "name": "navigation_second_page_push", + "value": "انتقل إلى الصفحة الثالثة" + }, + { + "name": "navigation_third_page_back", + "value": "العودة إلى الصفحة الأولى" + }, + { + "name": "navigation_basic_title", + "value": "أساسيات الملاحة" + }, + { + "name": "navigation_expand", + "value": "تكشفت" + }, + { + "name": "navigation_list_expand_title", + "value": "قائمة التصفح يوسع منطقة آمنة" + }, + { + "name": "navigation_bindsheet_title", + "value": "منطقة الأمان" + }, + { + "name": "navigation_expand_title", + "value": "الملاحة في المنطقة الأمنية الموسعة" + }, + { + "name": "navigation_unexpand", + "value": "لا تتكشف" + }, + { + "name": "navigation_split_title", + "value": "الملاحة تقسيم" + }, + { + "name": "navigation_sidebar_title", + "value": "شريط التنقل" + }, + { + "name": "navigation_navbar_list_nopara", + "value": "قائمة" + }, + { + "name": "navigation_navbar_list", + "value": "قائمة د" + }, + { + "name": "navigation_navcontent_list", + "value": "المحتوى د" + }, + { + "name": "navigation_hidebar_title", + "value": "إخفاء شريط التنقل" + }, + { + "name": "navigation_replace_title", + "value": "استبدال الملاحة" + }, + { + "name": "navigation_replace_page", + "value": "استبدال الصفحة الحالية" + }, + { + "name": "navigation_modechange_title", + "value": "تغيير نمط" + }, + { + "name": "navigation_rotate_screen", + "value": "تدوير الشاشة" + }, + { + "name": "navigation_modevalue", + "value": "سمود القيمة" + }, + { + "name": "navigation_mode_callback", + "value": "طريقة الاستدعاء" + }, + { + "name": "navigation_safearea_title", + "value": "سلامة الملاحة في المنطقة" + }, + { + "name": "navigation_safearea_default", + "value": "خرق" + }, + { + "name": "navigation_safearea_expand", + "value": "تكشفت" + }, + { + "name": "navigation_safearea_unexpand", + "value": "لا تتكشف" + }, + { + "name": "navigation_router_title", + "value": "هوب هوب هار" + }, + { + "name": "navigation_router_har1", + "value": "القفز إلى har1" + }, + { + "name": "navigation_router_har2", + "value": "القفز إلى هارتو" + }, + { + "name": "tabs_title", + "value": "تبويب" + }, + { + "name": "tabs_introduction_arguments", + "value": "تعديل بارامترات التبويب" + }, + { + "name": "tabs_introduction_properties", + "value": "تعديل خصائص التبويب" + }, + { + "name": "tabs_arguments_bar_position", + "value": "بار الكلمات" + }, + { + "name": "tabs_arguments_bar_position_start", + "value": "نقطة الانطلاق" + }, + { + "name": "tabs_arguments_bar_position_end", + "value": "نهاية ." + }, + { + "name": "tabs_properties_vertical", + "value": "عمودي" + }, + { + "name": "tabs_properties_bar_mode", + "value": "بار مود" + }, + { + "name": "tabs_properties_bar_mode_fixed", + "value": "ثابت" + }, + { + "name": "tabs_properties_bar_scrollable", + "value": "قابل للتدوير" + }, + { + "name": "tabs_properties_is_scrollable", + "value": "قابل للتدوير" + }, + { + "name": "tabs_properties_animation_duration", + "value": "مدة الرسوم المتحركة ( ماجستير )" + }, + { + "name": "tabs_arguments_controller", + "value": "التبديل إلى مؤشر محدد" + }, + { + "name": "tab_content_title", + "value": "علامة التبويب المحتوى" + }, + { + "name": "tab_content_introduction", + "value": "subtab / أسفل التبويب الجلاد" + }, + { + "name": "tab_content_side", + "value": "تبديل الشريط الجانبي" + }, + { + "name": "stepper_title", + "value": "السائر السائر المشروع" + }, + { + "name": "canvas_title", + "value": "قماش" + }, + { + "name": "circle_title", + "value": "دائرة" + }, + { + "name": "ellipse_title", + "value": "القطع الناقص" + }, + { + "name": "line_title", + "value": "خط" + }, + { + "name": "polyline_title", + "value": "خط الرسم البياني" + }, + { + "name": "path_title", + "value": "مسار" + }, + { + "name": "polygon_title", + "value": "مضلع" + }, + { + "name": "rect_title", + "value": "ناظر" + }, + { + "name": "shape_title", + "value": "شكل ." + }, + { + "name": "circle_change", + "value": "دائرة التغيير" + }, + { + "name": "circle_change_fill", + "value": "دائرة تغيير ملء" + }, + { + "name": "circle_change_radius", + "value": "دائرة نصف قطرها" + }, + { + "name": "circle_change_fillopacity", + "value": "جولة تغيير ملء التعتيم" + }, + { + "name": "circle_change_strokewidth", + "value": "عرض الحلزون" + }, + { + "name": "circle_stroke_dash", + "value": "سيركلي تروك داش" + }, + { + "name": "circle_stroke_color", + "value": "نمط دائري" + }, + { + "name": "circle_stroke_opacity", + "value": "مسار دائري التعتيم" + }, + { + "name": "ellipse_fill", + "value": "بيضاوي الشكل ملء" + }, + { + "name": "ellipse_stroke_color", + "value": "القطع الناقص لون السكتة الدماغية" + }, + { + "name": "ellipse_stroke_width", + "value": "عرض القطع الناقص" + }, + { + "name": "ellipse_width", + "value": "عرض القطع الناقص" + }, + { + "name": "ellipse_height", + "value": "ارتفاع القطع الناقص" + }, + { + "name": "ellipse_fill_opacity", + "value": "بيضاوي الشكل ملء التعتيم" + }, + { + "name": "ellipse_stroke_opacity", + "value": "حذفي ستروبوسكوبيك التعتيم" + }, + { + "name": "ellipse_stroke_dash", + "value": "إليبسو ستروك داش" + }, + { + "name": "line_start_point_x", + "value": "خط البداية س" + }, + { + "name": "line_start_point_y", + "value": "خط البداية ذ" + }, + { + "name": "line_end_point_x", + "value": "خط النهاية ذ" + }, + { + "name": "line_end_point_y", + "value": "خط النهاية ذ" + }, + { + "name": "line_stroke_width", + "value": "خط العرض" + }, + { + "name": "line_stroke_color", + "value": "لون الخط" + }, + { + "name": "line_stroke_opacity", + "value": "خط التعتيم" + }, + { + "name": "line_stroke_dash", + "value": "لين ستروك داش" + }, + { + "name": "polygon_fill", + "value": "مضلع ملء" + }, + { + "name": "polygon_fill_opacity", + "value": "مضلع ملء التعتيم" + }, + { + "name": "polygon_stroke_color", + "value": "مضلع لون السكتة الدماغية" + }, + { + "name": "polygon_stroke_opacity", + "value": "مضلع السكتة الدماغية التعتيم" + }, + { + "name": "polygon_stroke_width", + "value": "عرض مضلع السكتة الدماغية" + }, + { + "name": "polygon_stroke_dash", + "value": "بوليغون ستروك داش" + }, + { + "name": "polyline_first_x", + "value": "بولين فيرست إكس" + }, + { + "name": "polyline_first_y", + "value": "بولين فيرست" + }, + { + "name": "polyline_second_x", + "value": "بولين سيكوندكس" + }, + { + "name": "polyline_second_y", + "value": "بولين سيندي" + }, + { + "name": "polyline_third_x", + "value": "بولين ثيردكس" + }, + { + "name": "polyline_third_y", + "value": "بولين ثيردي" + }, + { + "name": "polyline_stroke_width", + "value": "عرض السكتة الدماغية" + }, + { + "name": "polyline_stroke_color", + "value": "لون الخط" + }, + { + "name": "polyline_stroke_dash", + "value": "بولين ستروك داش" + }, + { + "name": "polyline_stroke_opacity", + "value": "السكتة الدماغية التعتيم" + }, + { + "name": "rect_height", + "value": "ارتفاع المستطيل" + }, + { + "name": "rect_width", + "value": "عرض مستطيل" + }, + { + "name": "rect_radius_width", + "value": "عرض المستطيل" + }, + { + "name": "rect_radius_height", + "value": "ارتفاع المستقيم" + }, + { + "name": "rect_fill_opacity", + "value": "مستطيلة التعتيم" + }, + { + "name": "rect_stroke", + "value": "السكتة الدماغية المستقيم" + }, + { + "name": "rect_stroke_width", + "value": "rectstrokewidth" + }, + { + "name": "rect_stroke_dash", + "value": "ريكت سروك داش" + }, + { + "name": "rect_stroke_opacity", + "value": "rectstrokeopacity" + }, + { + "name": "rect_fill", + "value": "ريكتفيل" + }, + { + "name": "path_line", + "value": "باث لين" + }, + { + "name": "path_triangle", + "value": "باث تريانجل" + }, + { + "name": "path_square", + "value": "باث سكوير" + }, + { + "name": "path_polygon", + "value": "باث بوليغون" + }, + { + "name": "path_camber_first", + "value": "باث كامبر فيرست" + }, + { + "name": "path_camber_second", + "value": "باث كامبر سوند" + }, + { + "name": "path_camber_third", + "value": "باث كامبر ثيرد" + }, + { + "name": "path_commands_select", + "value": "اختيار مسار القيادة" + }, + { + "name": "path_fill", + "value": "باث فيل" + }, + { + "name": "path_fill_opacity", + "value": "pathfill التعتيم" + }, + { + "name": "path_stroke_color", + "value": "باث ستروك كولور" + }, + { + "name": "path_stroke_opacity", + "value": "باث ستوك اوباسيتي" + }, + { + "name": "path_stroke_dash", + "value": "باث ستوك داش" + }, + { + "name": "path_stroke_width", + "value": "باث ستوك ويدث" + }, + { + "name": "shape_fill", + "value": "شكل ملء" + }, + { + "name": "shape_stroke_color", + "value": "شكل ولون السكتة الدماغية" + }, + { + "name": "shape_view_port_x", + "value": "shapeviewportx" + }, + { + "name": "shape_view_port_y", + "value": "شابي فيو بورتي" + }, + { + "name": "shape_view_port_width", + "value": "shapeviewportwidth" + }, + { + "name": "shape_view_port_height", + "value": "shapeviewportheight" + }, + { + "name": "shape_stroke_opacity", + "value": "shapestroke التعتيم" + }, + { + "name": "shape_fill_opacity", + "value": "shapefill التعتيم" + }, + { + "name": "shape_stroke_width", + "value": "شكل عرض السكتة الدماغية" + }, + { + "name": "shape_stroke_dash", + "value": "شابستروك داش" + }, + { + "name": "web", + "value": "شبكي" + }, + { + "name": "canvas_fillStyle", + "value": "فيل ستايل" + }, + { + "name": "canvas_lineWidth", + "value": "خط العرض" + }, + { + "name": "canvas_strokeStyle", + "value": "ستروك ستايل" + }, + { + "name": "canvas_lineCap", + "value": "لين كاب" + }, + { + "name": "canvas_lineJoin", + "value": "خط الانضمام" + }, + { + "name": "canvas_miterLimit", + "value": "ميتر ليميت" + }, + { + "name": "canvas_font", + "value": "فونت" + }, + { + "name": "canvas_textAlign", + "value": "محاذاة النص" + }, + { + "name": "canvas_textBaseline", + "value": "خط النص" + }, + { + "name": "canvas_globalAlpha", + "value": "غلوبال ألفا" + }, + { + "name": "canvas_lineDashOffset", + "value": "لين داش اوفست" + }, + { + "name": "canvas_globalCompositeOperation", + "value": "عملية التوليف العالمية" + }, + { + "name": "canvas_imageSmoothingEnabled", + "value": "imagesmoothing تمكين" + }, + { + "name": "canvas_createLinearGradient", + "value": "إنشاء التدرج الخطي" + }, + { + "name": "cavas_createRadialGradient", + "value": "خلق التدرج الإشعاعي" + }, + { + "name": "canvas_createRadialGradient", + "value": "خلق التدرج الإشعاعي" + }, + { + "name": "canvas_fillRect", + "value": "فيلريكت" + }, + { + "name": "canvas_strokeRect", + "value": "ستروك ريكت" + }, + { + "name": "canvas_fillText", + "value": "فيلت تكست" + }, + { + "name": "canvas_strokeText", + "value": "ستروكيتكست" + }, + { + "name": "canvas_measureText", + "value": "ميسوريتكست" + }, + { + "name": "canvas_stroke", + "value": "( ضرب ، ضرب ، الخ )" + }, + { + "name": "canvas_createPattern", + "value": "كرياتيباترن" + }, + { + "name": "canvas_fill", + "value": "شغل" + }, + { + "name": "canvas_clip", + "value": "قطع" + }, + { + "name": "canvas_rotate", + "value": "استدارة" + }, + { + "name": "canvas_scale", + "value": "مقياس" + }, + { + "name": "canvas_drawImage", + "value": "دراويماغي" + }, + { + "name": "canvas_getImageData", + "value": "الحصول على بيانات الصورة" + }, + { + "name": "canvas_putImageData", + "value": "بوتیمگدیتا" + }, + { + "name": "canvas_setLineDash", + "value": "ست لين داش" + }, + { + "name": "canvas_getLineDash", + "value": "جيتلين داش" + }, + { + "name": "canvas_transferFromImageBitmap", + "value": "transferfrom imagebitmap" + }, + { + "name": "canvas_toDataURL", + "value": "توداتورل" + }, + { + "name": "cavnas_clearRect", + "value": "كلير ريكت" + }, + { + "name": "canvas_clearRect", + "value": "كلير ريكت" + }, + { + "name": "canvas_shadowBlur", + "value": "شادوبلور" + }, + { + "name": "canvas_shadowColor", + "value": "لون الظل" + }, + { + "name": "canvas_shadowOffsetX", + "value": "شادووفسيتكس" + }, + { + "name": "canvas_shadowOffsetY", + "value": "الظل تعويض ذ" + }, + { + "name": "canvas_addColorStop", + "value": "addclorstop" + }, + { + "name": "canvas_beginPath", + "value": "بيغن باث" + }, + { + "name": "canvas_moveTo", + "value": "تحرك" + }, + { + "name": "canvas_lineTo", + "value": "لين تو" + }, + { + "name": "canvas_closePath", + "value": "كلوس باث" + }, + { + "name": "canvas_bezierCurveTo", + "value": "بيزير كيرفيتو" + }, + { + "name": "canvas_quadraticCurveTo", + "value": "الرسم البياني مع منحنى بيزيير" + }, + { + "name": "canvas_arc", + "value": "قوس" + }, + { + "name": "canvas_arcTo", + "value": "اركتو" + }, + { + "name": "canvas_ellipse", + "value": "القطع الناقص" + }, + { + "name": "canvas_rect", + "value": "ريست" + }, + { + "name": "canvas_transform", + "value": "تحول" + }, + { + "name": "canvas_setTransform", + "value": "ست ترانسفورم" + }, + { + "name": "canvas_translate", + "value": "ترجمة ." + }, + { + "name": "canvas_imageSmoothingQuality", + "value": "تجانس الصورة" + }, + { + "name": "navigator_title", + "value": "الملاح" + }, + { + "name": "navigator_first_page", + "value": "الصفحة الأولى من Navigaor" + }, + { + "name": "navigator_second_page", + "value": "الصفحة الثانية من المستكشف" + }, + { + "name": "navigator_third_page", + "value": "الصفحة الثالثة من المستكشف" + }, + { + "name": "navigator_first_page_push", + "value": "انتقل إلى الصفحة الثانية" + }, + { + "name": "navigator_first_page_active", + "value": "انقر فوق تبديل حالة التنشيط" + }, + { + "name": "navigator_second_page_push", + "value": "انتقل إلى الصفحة الثالثة" + }, + { + "name": "navigator_third_page_back", + "value": "العودة إلى الصفحة الأولى" + }, + { + "name": "navigator_return_message", + "value": "! مرحباً - ! مرحباً - هذه هي الصفحة الأولى من المعلمات" + }, + { + "name": "component_id_press_to_see_attributeModifier", + "value": "عرض attributemodifier حسب العنصر رقم" + }, + { + "name": "component_id_click_to_see_attributeModifier", + "value": "انقر على عنصر معرف لعرض attributemodifier" + }, + { + "name": "component_id_disable_to_see_attributeModifier", + "value": "العنصر رقم تعطيل عرض attributemodifier" + }, + { + "name": "component_id_disable_radio", + "value": "العنصر رقم تعطيل الراديو" + }, + { + "name": "component_id_press_list_to_see_attributeModifier", + "value": "عنصر معرف عرض attributemodifier القائمة" + }, + { + "name": "water_flow_title", + "value": "تدفق المياه" + }, + { + "name": "water_flow_controller", + "value": "تحكم تدفق المياه" + }, + { + "name": "water_flow_properties", + "value": "خصائص تدفق المياه" + }, + { + "name": "water_flow_controller_scrollEdge", + "value": "سكرول ايدج" + }, + { + "name": "water_flow_controller_scrollBy", + "value": "المتداول الصحافة" + }, + { + "name": "water_flow_controller_top", + "value": "توب ." + }, + { + "name": "water_flow_controller_bottom", + "value": "القاع" + }, + { + "name": "water_flow_properties_scroll_bar_width", + "value": "scrollbar العرض" + }, + { + "name": "water_flow_properties_scroll_bar_color", + "value": "لون سكرول بار" + }, + { + "name": "water_flow_properties_scroll_bar", + "value": "سكرول بار" + }, + { + "name": "water_flow_properties_edge_effect", + "value": "تأثير الحافة" + }, + { + "name": "water_flow_properties_edge_effect_spring", + "value": "الربيع ." + }, + { + "name": "water_flow_properties_edge_effect_fade", + "value": "تلاشى" + }, + { + "name": "water_flow_properties_edge_effect_none", + "value": "هل أنت بخير ؟ - لا -" + }, + { + "name": "horizontal_reach_start", + "value": "التمرير الأفقي على reachstart" + }, + { + "name": "horizontal_reach_end", + "value": "التمرير الأفقي على reachend" + }, + { + "name": "vertical_reach_start", + "value": "التمرير الرأسي على reachstart" + }, + { + "name": "vertical_reach_end", + "value": "التمرير الرأسي على reachend" + }, + { + "name": "current_initialIndex", + "value": "initialindex الحالي هو :" + }, + { + "name": "modify_initialIndex_tips", + "value": "بعد initialindex التغييرات ، أدخل هذه الصفحة مرة أخرى" + }, + { + "name": "current_scroll_event", + "value": "أحداث التمرير الحالية :" + }, + { + "name": "current_scroll_state", + "value": "الوضع الحالي :" + }, + { + "name": "current_scroll_distance", + "value": "المسافة الحالية التمرير :" + }, + { + "name": "current_scroll_index_first", + "value": "مؤشر التمرير الحالي ، الأول :" + }, + { + "name": "current_scroll_index_last", + "value": "وأخيرا :" + }, + { + "name": "current_event_value", + "value": "لا أحداث" + }, + { + "name": "current_event_on_scroll", + "value": "على المتداول" + }, + { + "name": "current_event_on_scroll_index", + "value": "أونسولل إنديكس" + }, + { + "name": "current_event_on_scroll_start", + "value": "أونسكرول ستارت" + }, + { + "name": "current_event_on_scroll_stop", + "value": "انسكولستوب" + }, + { + "name": "panel_background_color", + "value": "#ffffff" + }, + { + "name": "multiple_attribute_take_effect", + "value": "دينامية مجموعة خصائص العنصر : خصائص متعددة الإعدادات في وقت واحد" + }, + { + "name": "click_to_see_image_border_change", + "value": "انقر على زر عرض تغيير حدود الصورة" + }, + { + "name": "dynamical_updates_ui_directly", + "value": "خصائص العنصر هي مجموعة ديناميكية ، غير الدولة متغير يؤدي مباشرة إلى تحديث واجهة المستخدم" + }, + { + "name": "click_to_see_component_change", + "value": "انقر على زر عرض عنصر تغيير قيمة الممتلكات" + }, + { + "name": "click_to_see_text_component_change", + "value": "انقر فوق تحديث مكونات النص البناء باستخدام المعلمات" + } + ] } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/harA/src/main/resources/ar/element/string.json b/code/UI/ArkTsComponentCollection/ComponentCollection/harA/src/main/resources/ar/element/string.json index 1c5e36d89f..6aaf8f9f5f 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/harA/src/main/resources/ar/element/string.json +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/harA/src/main/resources/ar/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "navigation_router_har2", - "value": "Har2 قفز إلى" - } - ] -} +{ + "string": [ + { + "name": "navigation_router_har2", + "value": "Har2 قفز إلى" + } + ] +} diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/harB/src/main/resources/ar/element/string.json b/code/UI/ArkTsComponentCollection/ComponentCollection/harB/src/main/resources/ar/element/string.json index ee4eff18f6..2da7944a84 100644 --- a/code/UI/ArkTsComponentCollection/ComponentCollection/harB/src/main/resources/ar/element/string.json +++ b/code/UI/ArkTsComponentCollection/ComponentCollection/harB/src/main/resources/ar/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "navigation_router_har1", - "value": "Har1 قفز إلى" - } - ] +{ + "string": [ + { + "name": "navigation_router_har1", + "value": "Har1 قفز إلى" + } + ] } \ No newline at end of file diff --git a/code/UI/ArkTsComponentCollection/ComponentCollection/screenshots/devices/general.jpeg b/code/UI/ArkTsComponentCollection/ComponentCollection/screenshots/devices/general.jpeg old mode 100755 new mode 100644 diff --git a/code/UI/ArkTsComponentCollection/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSyncCode.ets b/code/UI/ArkTsComponentCollection/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSyncCode.ets deleted file mode 100644 index 412e272ff0..0000000000 --- a/code/UI/ArkTsComponentCollection/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSyncCode.ets +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2023 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 { ObjectLinkComponent } from './ObjectLinkComponent'; -import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'; - -// 数组中元素的类,使用@Observed修饰 -@Observed -export class ClassObject { - public elementType: Resource; - public attributeType: Resource | string; - - constructor(elementType: Resource, attributeType: Resource | string) { - this.elementType = elementType; - this.attributeType = attributeType; - } -} - -// 初始化父组件中的数据 -const PARENT_DATA: ClassObject[] = [new ClassObject($r('app.string.partial_sync_element_one'), $r('app.string.partial_sync_attribute_one')), - new ClassObject($r('app.string.partial_sync_element_two'), $r('app.string.partial_sync_attribute_two')), - new ClassObject($r('app.string.partial_sync_element_three'), $r('app.string.partial_sync_attribute_three'))]; - -@Component -export struct ParentChildPartialContentSyncCode { - // 初始化父组件中状态变量 - @State parentData: ClassObject[] = PARENT_DATA; - // 与子组件同步的的数据是数组的第几个元素,默认选中第一个 - @State syncIndex: number = 0; - - build() { - Column({ space: 10 }) { - // 点击查看源码 - ViewCodeText({ webSrc: $rawfile('ParentChildPartialContentSyncCode.ets.html') }) - - Text($r('app.string.partial_sync_parent_tips')) - .fontColor($r('app.color.tips_font_color')) - .fontSize($r('app.float.tips_font_size')) - .width('100%') - .textAlign(TextAlign.Start) - // 父组件中List展示状态变量中的内容 - Column() { - ForEach(this.parentData, (item: ClassObject, index: number) => { - Column() { - ParentCompDataItem({ index: index, syncIndex: this.syncIndex, childObject: item }) - } - .backgroundColor(index === this.syncIndex ? $r('app.color.component_background_pink') : undefined) - .onClick(() => { - this.syncIndex = index; - }) - }, item => JSON.stringify(item)) - } - .width('100%') - .backgroundColor($r('app.color.component_background_pink')) - - //与父组件状态同步的子组件 - ObjectLinkComponent({ childObjectData: this.parentData[this.syncIndex] }) - } - .width('100%') - .padding(10) - .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) - } -} - -// 展示数组中单个元素的子组件 -@Component -struct ParentCompDataItem { - private index: number; - @Prop syncIndex: number; - // 使用@ObjectLink修饰,与父组件中元素同步 - @ObjectLink childObject: ClassObject; - - build() { - Column() { - Text(this.childObject.elementType) - .width('100%') - .fontSize(20) - if (this.index === this.syncIndex) { - TextInput({ text: this.childObject.attributeType }) - .fontSize(20) - .id(`attribute${this.index + 1}`) - .onChange((value: string) => { - // 更新父组件中元素的属性,子组件同步 - this.childObject.attributeType = value; - }) - } else { - Text(this.childObject.attributeType) - .width('100%') - .fontSize(20) - } - } - .padding(10) - .id(`arrayElement${this.index}`) - } -} - -- Gitee